[Scummvm-git-logs] scummvm master -> ba2ccee7011e1dcd7f22a67a718d92a9828ef71a
sev-
sev at scummvm.org
Mon May 17 14:00:01 UTC 2021
This automated email contains information about 1000 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
ef34899c44 ASYLUM: - Now reading subtitle information from vids.cap
232391f005 ASYLUM: Updated the MSVC project file
ffd1d02551 ASYLUM: Silenced a signed/unsigned mismatch warning
261b47d718 ASYLUM: Added a parameter to playVideo(), used to toggle subtitles
8d75c0e780 ASYLUM: Delete the scene object in the engine's destructor
089d0c6b8f ASYLUM: Improve scenres ActorDefinitions structure and reading.
04fe773cd2 ASYLUM: Actor bounding box test.
8a7e3bfada ASYLUM: Fixed displaying of transparent actors, and added some more test animations
30893ed56a ASYLUM: - Reverted back to Common::Point and Common::Rect
27a8f4b8f0 ASYLUM: Now reading common scene resources in an endian-safe way
1d4f3b236a ASYLUM: More work on video subtitles (tested videos 0-6)
610917b968 ASYLUM: Added the text resources for all of the game's video subtitles. Only the vertical placement of some multi-line s
8eef024f30 ASYLUM: - Finished up video subtitles. Multi-line subtitles are now displayed correctly
198afeaa80 ASYLUM: Cleanup
abd30b6154 ASYLUM: Added a flag to the Scene class to determine if the scene is active or not
209e9f33cc ASYLUM: Now the scene is deactivated/activated when the menu opens/closes
762c5d0fa2 ASYLUM: Added a debug console, with a command to play any of the game's videos. Cleaned up the AsylumEngine class a bit
19c253bcae ASYLUM: Fixed and improve GamePolygons reading. Debug test to show polygons on screen.
9d75d9f3d1 ASYLUM: Minor formatting. See you guys in a couple weeks :)
824373cb85 ASYLUM: - Removed duplicate code
95c2f1a201 ASYLUM: Removed one constructor of the GraphicResource class, so that the class can store the resource id of the loaded
e0bce0c64d ASYLUM: Some WIP code for walking with the mouse
ffcd82b310 ASYLUM: Cleanup and styling
d22bc0cf51 ASYLUM: Silenced a warning, some cleanup
18fd3a9588 ASYLUM: Some initial code for the "View cinematics" submenu
84ad75f451 ASYLUM: Prevent reloading a font with the same resource number as the currently loaded one
b03e6eafbb ASYLUM: Some initial code for scene hotspots
d851b62f28 ASYLUM: Scene ActionList read first steps.
dfd39bfc32 ASYLUM: Scene stuffs: New fields added. Renamed items to be accurate as original game. Still got work to do here.
96369ef78f ASYLUM: More scene fields read. Action item under WorldStats renamed.
409e176e46 ASYLUM: Scene WorldStats fields read added.
f65c0ba31e ASYLUM: Scene ActorItems fields read.
d4c8e85b8a ASYLUM: Some initial code for the "play speech" script command
c8a173e5eb ASYLUM: Fixed laggy cursor by removing exponential delay inside event loop. Changed delay to match apparent animation sp
b22dab25e6 ASYLUM: Fixed order for Polygon point data.
b8451e3c78 ASYLUM: Fixed minor error in blitting code causing image corruption in surfaces drawn partially offscreen.
e85dbe333c ASYLUM: Modified ShowPolygons to draw Polygons rather than bounding boxes. Fixed mouse click position detection to incor
c578b8d2ed ASYLUM: Added extra logic to handle large (multi-screen) polygons.
3b8e1235f5 ASYLUM: Renamed previously unknown variable for action script length.
9c7033c6a0 ASYLUM: * cleanup
b8a92e1a08 ASYLUM: Named CommonResource font resources.
4c4a9d5df5 ASYLUM: Fixed accidental misnaming - renamed font resources to match naming conventions.
34e750d48d ASYLUM: Added preliminary script interpreter and associated support functions and fixes. Added Debug channels.
7f37100008 ASYLUM: Fixed SVN keywords.
a9ff616822 ASYLUM: svn:keywords
19d9e775b9 ASYLUM: Fixed warnings.
7795ce38d8 ASYLUM: Added support for polygon testing inside bounding boxes.
90759f311a ASYLUM: -- Removed temporary testing value left in kSetActorStats case.
71dba6739f ASYLUM: Added temporary resource check to work around crash in Scene 6.
4245700936 ASYLUM: -- Added new console commands "script" and "scene" to run arbitrary scripts by number and to change scenes, resp
c2a7b40396 ASYLUM: Commit for changes accidentally left out of r231.
adf21355ee ASYLUM: Fixed warnings
a259fb4d98 ASYLUM: Updated the MSVC project file (added interpreter.*)
bc773b9544 ASYLUM: Formatting
de517ddf1f ASYLUM: More formatting. Basically tabify. SOmebody has wrong indentation setup. All
f46276e7d1 ASYLUM: Format last switch() statement. They all were indented in a wrong way.
6380032d48 ASYLUM: Turn printf() into respective debug() or warning(). Printf is not portable
f43b5843c8 ASYLUM: Since the game polygons list doesn't cover ALL interactive regions (hotspots), I added a method to draw active b
3cfa2cbb4c ASYLUM: Reworked the interpreter into a singleton ScriptManager. This will allow scripts to be run without needing acces
16ea284ef6 ASYLUM: * re-enabled script debugging
0af5fd7f83 ASYLUM: minor cleanup and debug output (sev, those printf's will be removed as soon as they've served their purpose ...
44e189d2d9 ASYLUM: * printf -> debugC
4e2fe3e3a8 ASYLUM: * clear debug channels on engine destruction
5939070342 ASYLUM: rolled checks for delayed scene changes and video into processDelayedEvents()
5cbfdcd695 ASYLUM: Started work on pathfinding. Currently I've disabled screen edge scrolling, and am drawing the active walk-able
d36733373b ASYLUM: lock/unlock input event processing depending on whether the show/hide cursor action has been processed
476f1d207a ASYLUM: started working on game flags. Also implemented a couple unknown fields on the scene
aab9670897 ASYLUM: Properly initialize the gameflags array and set the (what I'm assuming to be) ENTER_SCENE flag (though it's list
2b6a4d17c5 ASYLUM: Added kJumpIfGameFlag case.
54108200ee ASYLUM: Cleaned up extra newline. Debug function inserts one automatically.
c7799f2fa6 ASYLUM: Named Scene movement fields. Added function for setting the view window.
ac7e83c21a ASYLUM: Formatting.
927804b212 ASYLUM: First steps for BlowUpPuzzles
158562f095 ASYLUM: svn props
8a228b5ee7 ASYLUM: Cleanup
e86c52db38 ASYLUM: Proper code formatting (refer to the relevant ScummVM wiki page here: http://wiki.scummvm.org/index.php/Code_For
0a4aa79d62 ASYLUM: * Removed the setTarget (action/barrier) logic that was started, but never used (it's not necessary as target in
def25effdc ASYLUM: * killed a couple old forward declarations
c15eb6fe8f ASYLUM: abstract some variable accessors
49ca9374f0 ASYLUM: Simplify loading of default action list
024b4734f5 ASYLUM: updated opcode list as per r258
100118ec5c ASYLUM: More BlowUpPuzzle work. Press B to Switch between Scene & BlowUpPuzzle for test.
c00b822cb7 ASYLUM: BlowUpPuzzleVCR cursor with animation while regions.
e377059aee ASYLUM: Some work on grabbing Black Jack in VCR BlowUpPuzzle. It still buggy. See comments for more detail.
df4d55d55c ASYLUM: Fixed jack shadow and cursor update.
405fdc6e08 ASYLUM: Fixed off-screen exceptions. First concept of display graphics by priority (Already working for VCR jacks).
141ac36aa8 ASYLUM: Better implementation of grabbing jacks. All 3 jacks working now.
533ca05548 ASYLUM: A little more work on kEnableBarriers. None of the switch cases are there since none seem to be taken in Chapter
7910161572 ASYLUM: Fixed setPalette and fixed some warnings.
18197d2106 ASYLUM: Implementation of plug-in/out jacks on VCR BlowUpPuzzle.
17959bf930 ASYLUM: More accurate implementation of kPlaySpeech
a607878207 ASYLUM: Cleanup and comments
6922206396 ASYLUM: updated svn:props (was on a conference call with a client and had some time to kill :P)
db63436dcc ASYLUM: Fixed compilation
f2b0c32fca ASYLUM: Updated the MSVC project file
5b1c7c9a83 ASYLUM: More VCR puzzle done. [Now with button states working]
914e970a7c ASYLUM: Fixed previous commit mistaken files. Plus add support for TV sync while VCR ON.
6aeb8057ce ASYLUM: Finished VCR BlowUpPuzzle code.(Still missing some sound features like loop and stop specific sounds)
66d248b589 ASYLUM: Changed struct of BlowUpPuzzle (its now part of a scene Scene). Need REVIEW please.
f63ccbf79a ASYLUM: Implementation of dew little commands. Change some command names.
1769959bf8 ASYLUM: * A little work on Encounters (not much)
03e46ac514 ASYLUM: Minor update in Video file to allow displaying subtitles with special characters like "ã á ç é Ã, etc.".
b3d7287a2f ASYLUM: ScriptManager command action variable is now a pointer, to allow some commands to override parameter values.
04c2840c49 ASYLUM: Fixed GameFlag related commands in script.
54682e1f44 ASYLUM: Utilities class renamed to Shared. All common resources bound to shared singleton so they can be used by all eng
26d456e5be ASYLUM: Game startup sequence added, and some minor cleanups.
f75fea2be6 ASYLUM: formatting
e629ab0934 ASYLUM: Properly abstract remaining scene variable access and remove friend association to ScriptMan
9e18edaee3 ASYLUM: Some work on PlayAnimation command. It will only work with a proper BarrierUpdate according with each flag type.
bffebfd830 ASYLUM: More work on PlayAnimations. Still playing all animation initially (need proper updateBarrier).
f48ab391ac ASYLUM: Fixed a bug from the original game that caused the application to be locked (and occasionally crash) due to the
7cef62988d ASYLUM: * Added a console command to show the currently active game flags
d9348e1388 ASYLUM: Reorganization Flags under Shared for the upcoming work on Update routines. Start working on UpdateBarrier(incom
08d786e46e ASYLUM: * Add a reference to the scene resource's actor[0] to the mainActor instance (this is an interim hack until we r
55dd466b7a ASYLUM: oops (warning -> debugC)
a5218007dc ASYLUM: oops again (left debug screen scrolling on)
11bbfc3cab ASYLUM: properly initialize the scene's actionAreas :D :D :D
d6d90b7e3a ASYLUM: Add command "dump_action". This currently just prints out a list of ALL available actionAreas within the current
688356d898 ASYLUM: Some work on processing Barriers. (Still WIP). This will initiate a change in Scene Update function to make it l
cb24392707 ASYLUM: More Barriers work. Fixed DestroyBarrier command.
0a8407801a ASYLUM: Fixed memory leaked.
844ad2ab50 ASYLUM: Clean up!
d185c257c7 ASYLUM: ops (commented debugScreenScrolling)
ff72e9b326 ASYLUM: Refactoring and clean up!
619f8f86f6 ASYLUM: Preparing draw barriers...
051d5d3244 ASYLUM: Formatting
11d86e9e9c ASYLUM: More draw barriers done. Graphics Queue are now in Screen class. Did some refactor and clean up.
e9bde0e965 ASYLUM: Few script commands work.
0c8d8a9208 ASYLUM: kJumpBarrierFrame (0x51) command done.
7badaaaddc ASYLUM: Minor readability formatting
adbf7b6ab1 ASYLUM: More work on ScriptManager.
a52992c543 ASYLUM: Little work on Actors
49c0f35428 ASYLUM: Some barrier fixes.
0ebfa3758c ASYLUM: use CursorMan instead of the OSystem reference to manage cursors. This allows the cursor to be properly reset wh
bccc36a69c ASYLUM: This is still WIP, but it's the first steps towards refactoring the cursor code.
f169d00db0 ASYLUM: Comments
b9ee645fed ASYLUM: Implemented kJumpIfFlag2Bit0. Also modified kSetFlag2Bit0 to actually set the action area flag
3f4a861a41 ASYLUM: Initial implementation of updateMouse(). This still needs some work, and will likely be completed after the acto
feb852bd8b ASYLUM: Reworked the action list processor to use a function map as opposed to a switch tree. This is a cleaner solution
b1865b7319 ASYLUM: Refactored the actor code. Moved a lot of functions into the actor class where it belongs.
a6b0965471 ASYLUM: * Re-enabled updateMouse() (WIP)
21dde9125e ASYLUM: Closer implementation of kSetActorStats. This actually initializes the characters x1/y1 values, which are needed
bfec665d50 ASYLUM: Renamed actor->disable() to actor->update_4072A0. Also added the assignment to field_40 at the end of that metho
7c330b4b8a ASYLUM: Refactored BarrierItem into it's own class. Also moved the sound item structs into sound.h
87b32eadd2 ASYLUM: added barrier.cpp/h to vcproj
18733c4910 ASYLUM: fixed a valgrind warning
0002d52073 ASYLUM: minor cleanup
82016e35e1 ASYLUM: Little compilation fix.
05e47b3d71 ASYLUM: Fixed scene moving command. Still crashing with Path-Finding.
7550fd1453 ASYLUM: There's no need to access the scene's resources through Shared from within the scene itself
4e7c4a478b ASYLUM: refactored polygon code out to seperate class
612d6021f7 ASYLUM: * added proper source header to polygons.cpp/h
d1234430c2 ASYLUM: refactored actionlist into it's own class file
afff3e7222 ASYLUM: refactored worldstats into it's own class file
dc50ebf55f ASYLUM: polygon point cleanup moved to polygons destructor
103f2513f1 ASYLUM: cleanup
779cac61a9 ASYLUM: moved getActorX and getBarrierX from sceneres to worldstats
2cb80c6d8d ASYLUM: Removed sceneres. Scene resource loading is now handled in the scene constructor, and the parsing of worldstats,
b4385f8e9e ASYLUM: Removed the ScriptManager. The singleton functionality is rolled into the actionlist class (where it belongs)
4caee427b7 ASYLUM: removed the flag assignment to 183 (process_action_list) from the scene constructor
4c01ffb9e3 ASYLUM: moved the checkFlags() and setNextFrame() methods that relate directly to barriers into the barrier class (off o
badb49ed6d ASYLUM: Moved the gameflags from SharedResources to the AsylumEngine. Also removed the OSystem member from the SharedRes
9868f8c40a ASYLUM: oops (fixed: *** glibc detected *** /home/alex/workspaces/cpp/scummvm/scummvm: double free or corruption (out):
9f39977ddd ASYLUM: Removed Video reference from Shared
72c1b3e398 ASYLUM: Removed Sound reference from Shared
ddcb9beab2 ASYLUM: Removed Shared singleton. Moved getAngle() to actor class (only place it's used so far). Added screen() and scen
2c54ace443 ASYLUM: make function_map[] static/const, and undefine the MAPFUNC macro after the function_map has been set.
0a29c45b11 ASYLUM: properly check if the debugChannel is set :P
cf58a8244c ASYLUM: Fixed bug with cursor not being visible after the first script ran (hacked the fix and added a FIXME)
d91d5e5e5f ASYLUM: Fixed some warnings.
a422a0db00 ASYLUM: Scene actors init stuffs
461ddd8dd0 ASYLUM: First steps on drawing actors with priority.
52206f1189 ASYLUM: NEW SOUND SUBSYSTEM! This is still sort of WIP though because it's not a "true" implementation (direct from disa
a6d5a2a714 ASYLUM: Cleanup and comments
8a8ac36b21 ASYLUM: Finish missing sound parts from BlowUpPuzzleVCR. Still needs corrections in sound stop routines. After that, it
1142cd7286 ASYLUM: stopAllSounds() now optionally stops speech/music playback.
ab44e5c66b ASYLUM: Ran our engine through AStyle :P
d6c4926344 ASYLUM: Sync with ScummVM revision #44266
94d40fcac5 ASYLUM: Added the missing cursor.* files to the MSVC project file
dae5c31a10 ASYLUM: Fixed two warnings, for now, and added 2 FIXME's
83b9d232fb ASYLUM: Fixed another warning on an odd bit of code, and added a FIXME
800f24b810 ASYLUM: Commented out unused variables
b439e33021 ASYLUM: Emulate the title loader. I'm calling this emulation because we're not buffering resources the same way as the o
1ea346e064 ASYLUM: cleanup and comments
e60a1293cf ASYLUM: created a configuration management singleton. I know I've made a few of these and then factored them out in the
f26c50461b ASYLUM: Updated the MSVC project file, and fixed compilation
ab96b43829 ASYLUM: Alter detection routine slightly to check if the version of Sanitarium that is found is one that has had the Lev
fc33509d62 ASYLUM: Some fixes for ambiguous data endianness causing segfaults on big-endian architectures.
005cfdcf5a ASYLUM: * changed some variable casting from uint32 to int
99aa2737b3 ASYLUM: change command reads from Uint32 to Sint32
b70ec65759 ASYLUM: Commented out OLD_UPDATE on the scene for now, as I'm going to try to start implementing this properly (so thing
0437c5d622 ASYLUM: comment
0f3e70f32e ASYLUM: added new opcode return type that indicates that the opcode is implemented, but there are still some comments to
6354e07969 ASYLUM: started implementation of drawActorsAndBarriers()
27437d1796 ASYLUM: A bit more work and cleanup. This is not coming along very well though. I may have to start re-writing all the s
be1b96e4c0 ASYLUM: Little fix in Play Animation command.
abf0365eaa ASYLUM: New player speech implementation.(Missing subtitles)
1ca31867e8 ASYLUM: PlayerSpeech showing Text. (Still need to fix Sound::isPlaying to display the text while speech is playing)
05f33c9a4c ASYLUM: More accurate implementation of updateActorDirection (40A2E0), updateActorDirectionDefault (407260), and default
233812dee1 ASYLUM: Implement a more accurate scene initialization (40E460). Part of this involves setting the actor type, so the lo
b64ddddf9e ASYLUM: cleanup and comments
3f34ce3030 ASYLUM: Moved some static resources into a new staticres header.
63b9cfeb0a ASYLUM: commit staticres.h (forgot to do an svn add :P)
a33b9e677a ASYLUM: Added the ActionArray type. Slowly working on implementing this, but it looks to be what ties the actionlist to
d9aaf26c18 ASYLUM: Removed the actionarray class and rolled it into actionlist (which makes way more sense).
20184c8486 ASYLUM: Starting to implement proper actionlist processing using the scripts queue.
d22a3cae67 ASYLUM: minor cleanup and silenced a couple warning
84b6fde0d1 ASYLUM: Trying out a stack-based script queue management system. This is what I assume is an optimized version of the or
9cc79d0cea ASYLUM: remove "processing" flag and just check for flag 183
05ec1ccd5e ASYLUM: * Fixed proper _currentScript pointer initialization.
dcf0cce2c5 ASYLUM: * Fixed Sound::isPlaying buffered handle.
611e9e9582 ASYLUM: * Rework on game initially steps to build the real flow to start a new game. (Still missing SaveGame checks, New
817cdc8ce6 ASYLUM: * Implemented start New Game from MainMenu.
9e2855fd81 ASYLUM: include and comment macro for skipping intro videos
cc43cc88a3 ASYLUM: Major overhaul of data casting. Converted all uint32 member variables and fields to int32 (and uint16 to int16)
9e8cd4c502 ASYLUM: move video subtitle resource lookup table to staticres
7506f2d470 ASYLUM: minor whitespace cleanup
7485e6ad7f ASYLUM: a little more formatting
878182c704 ASYLUM: starting to unwind Scene::updateAmbientSounds a bit further
15e2aad8c8 ASYLUM: a little more work on volume calculation for ambient sound update
6629b1baf5 ASYLUM: * Fixed Update Barriers. Now all barriers should be visible.
003fe3e9ad ASYLUM: cleanup
df377b52b4 ASYLUM: minor cleanup
5b36ee78b5 ASYLUM: * Fixed scene/barriers drawing positions. We can now see all Barriers active in scene.
b23f2c8cec ASYLUM: * Fixed issue6 (unsigned characters for multi-language support) - revert signed to unsigned in resId, frameId, f
7963bd8aef ASYLUM: Remove GCC warnings
9c17b66fa8 ASYLUM: Silenced a (very) annoying warning
cb90401e0d ASYLUM: This commit is to checkin the changes I've made in relation to Scene::update::updateMouse. It doesn't really wor
efa59ec92a ASYLUM: Removed the commonRes struct from Worldstats, as there's really no need for it to be an entity unto itself. Roll
c0e8a9532e ASYLUM: ActionArea is a class, not a struct
fadb6681e4 ASYLUM: updates to kDisableActor and kHideActor. Disabled kRunBlowUpPuzzle for now.
d396b0daae ASYLUM: added updateSoundItems (from 0040D0E0)
a56c334e95 ASYLUM: Implemented an unknown opcode (kClearActorField970). Also added stub for a kHideActor update that is not going t
d50801e013 ASYLUM: somewhat simplified kEnableBarriers
1c5c6401c9 ASYLUM: make kShowActor as complete since we now have a stub for function 401320 (which, like in previous cases, depends
823d5417e1 ASYLUM: renamed kSetActorStats to kSetActorPosition and cleaned up a bit
fdf91af171 ASYLUM: Forgot this from r425. This removes the old setPosition and replaces it with the more appropriate one.
da61880d8e ASYLUM: This commit breaks A LOT of existing functionality. It also introduces a slew of new functions (namely hittests)
9d72b587bd ASYLUM: read the rest of the actor struct out of the res file
97e1f0ea7c ASYLUM: fix _mixer->playRaw to work with latest ScummVM trunk
a9b15453b7 ASYLUM: fixed the _mixer calls again since playRaw has recently been removed from trunk. Also added a FIXME since we'll
4665c8c55e ASYLUM: Syncing with more ScummVM audio changes in trunk.
21b7c50021 ASYLUM: identified a couple more actor object properties
81a5094f20 ASYLUM: formatting
bc43a2bfd5 ASYLUM: remove global_x/y (find a better way ... and actually finish it :P)
36f4a64535 ASYLUM: fix warning (extra ;)
784ee55823 ASYLUM: clean up
0194e07fcc ASYLUM: added detection entry for version from gog.com
748960b9b6 ASYLUM: new debug level for barriers
63941ec0c5 ASYLUM: include "common/random.h"
8ffc46acb2 ASYLUM: fix compile with latest trunk
ed378d586c ASYLUM: Fixed clipping (Issue #5). Fixed sprite delay when scrolling by using backbuffer.
6a94eee3c2 ASYLUM: Changed uses of rand() to utilize AsylumeEngine::_rnd instead (Issue #4).
c31a0d39c8 ASYLUM: Fix warning introduced by r442.
3fdd3ab5b9 ASYLUM: silenced a couple gcc warnings
17fec87f91 ASYLUM: fixed cppcheck warning (Mismatching allocation and deallocation)
d467701cc7 ASYLUM: set svn props
362cce9b63 ASYLUM: Changes for Debug Manager in trunk.
e5beddf490 ASYLUM: Fixed compilation
92ebb5af97 ASYLUM: Silenced a warning
a2fcb22eed ASYLUM: Add support for subtitles configuration option.
8b8a843282 ASYLUM: Changes for VideoDecoder in trunk.
53a233697d ASYLUM: pass actor index to updateActor (as opposed to just grabbing the default actor each time)
6119be865d ASYLUM: change isAttached to isActive for console debugger check
16d01549c0 ASYLUM: whitespace cleanup
5d48974ebd ASYLUM: reimplement main menu
afb4a6a3b5 ASYLUM: re-organize trunk
36d4208beb ASYLUM: Refactor ActionList class
44b58d8437 ASYLUM: Refactor Asylum engine class
589fdc3196 ASYLUM: Implement more opcodes logic
4a3e37e814 ASYLUM: Finish implementing kPlaySpeech opcode
6958752a3f ASYLUM: Enhance Actor class
7f7f332bac ASYLUM: Add macro to encapsulate ticks logging in updateScene and disable by default
744b1c1a80 ASYLUM: Introduce GameFlag enumeration
bf064f3788 ASYLUM: Cleanup some actor-related opcodes
3935d274fa ASYLUM: Cleanup ActionList and implement more opcodes
ffddfcd8db ASYLUM: Use typed resource ID
df74fd7a7c ASYLUM: Implement Set/Clear/JumpIfActionType opcodes
f0c46d5e7c ASYLUM: Implement remaining opcodes
e808235ae3 ASYLUM: Disable obsolete Actor methods
0f13d7dc3f ASYLUM: Refactor and cleanup Actor class
4d08eeae4d ASYLUM: Implement Actor::updateStatusEnabled() && Actor::updateFinish()
3a64ce802a ASYLUM: Add helper macros for access to engine subsystems
1e04f736ed ASYLUM: Refactor Barrier class
051ea98d5e ASYLUM: Update ConfigManager
29d47c54cc ASYLUM: Update scene drawing implementation
d569216ea4 ASYLUM: Implement processUpdateList
cf7c7ed9f6 ASYLUM: Cleanup Barrier::update
c62108194e ASYLUM: Implement Scene spec function for Chapter 1
7f7a8d4a26 ASYLUM: silenced GCC warnings
3dfab1cc46 ASYLUM: fix more GCC warnings (overflow in implicit constant conversion)
7170f10f7b ASYLUM: even more GCC warnings silenced
66b12b324f ASYLUM: add missing ADParams initializers
0eb39da884 ASYLUM: Enhance Debug console
ce330b1a45 ASYLUM: Rename Barrier to Object
fecb700e69 ASYLUM: Update shared enumerations
582794ff12 ASYLUM: Implement special logic for chapters 1, parts of 2, 3, 4 and 6
9249130d59 ASYLUM: Check that a scene exists before trying to load it
9eb5d19d3b ASYLUM: Implement Object::setVolume()
dd6afe7523 ASYLUM: Use subsystems access macros in ActionList
96878fef6e ASYLUM: Implement special logic for Chapter 7
4b449a14c2 ASYLUM: Treat ResourceId as an unsigned int
659a3e281e ASYLUM: Reduce header inter-dependency
62305021da ASYLUM: fix object disable (actor is now no longer hidden after the first script runs)
d8457b0bc2 ASYLUM: enhance "objects" console command
e10ad80b88 ASYLUM: added 'object' console command and an onscreen param for 'objects'
eae999fed4 ASYLUM: Implement special logic for chapter 2 (remaining part), 5 & 9
a821f1a583 ASYLUM: Fix ClearScreen opcode
88dab248d1 ASYLUM: Implement enableActorsChapter2
8eafe1b911 ASYLUM: Backed out revision 495 (fix object disable)
43805ab2d8 ASYLUM: Fix some problems with the Actor code
9b7e72932d ASYLUM: Fix object debug command
03bac323a6 ASYLUM: silence warning and minor cleanup
66982f21af ASYLUM: remove unnecessary comment
51b9a95e51 ASYLUM: Get rid of numActors/Objects/Actions
de67e921e2 ASYLUM: Do not try to play music with an empty ResourceId
fdb53b6b13 ASYLUM: expand Actor::toString to show a more detailed view when examining a particular actor
20754d9dd9 ASYLUM: Initialize scene before entering it
fd534e562e ASYLUM: implement Actor::updateStatus9()
ef1ebc55da ASYLUM: Extract SceneTitle to its own file
ee438adbdc ASYLUM: Introduce ResourcePackId
d7c22354a6 ASYLUM: Add ResourceManager class
2532fcd021 ASYLUM: Refactor game start and scene loading
46d1acac79 ASYLUM: Small correction to Actor::updateStatus9
32f3eed36c ASYLUM: Refactor Speech class
25fac6195d ASYLUM: Rename some methods of Text class
df639342c4 ASYLUM: Remove unused variables from Config class
b1c3d9d7e0 ASYLUM: Add some init code to Scene & Actor classes
977afaa9c3 ASYLUM: Actor class was reading too much data
10f0ac46ea ASYLUM: Use the current scene pack id when trying to load music resources
db2b09d61b ASYLUM: fix compile
2335f8f578 ASYLUM: Implement WorldStats::setWheelObjects() and Scene::playIntroSpeech()
64786bb7f7 ASYLUM: Fix crash on exit
d849243840 ASYLUM: added a 'world' console command to show a worldstats summary
e2c0ac1ee2 ASYLUM: Implement sound reactions
e91c49f188 ASYLUM: Implement more playSoundChapter functions
d95ec4be44 ASYLUM: Implement Special::playSoundPanning
d5e3c4536c ASYLUM: Remove checks for sound cache
a40c1e7484 ASYLUM: Implement changeMusic
4d383def95 ASYLUM: Add support for shared sound resources
ea952cc33d ASYLUM: Implement Sound panning/adjustement methods
71125b9916 ASYLUM: Throw an error when a resource pack cannot be opened
5bd13afb2b ASYLUM: Fixed scene reloading, to get the good palette after showing intro & when exiting menu
509a8dd028 ASYLUM: Implement Special::setPaletteGamma
980ecdf3d4 ASYLUM: Implement last 2 special chapter sound logic
b475ba03a8 ASYLUM: Implement special logic for chapter 8
50e69da09a ASYLUM: Implement Actor::getFieldValue()
2fcf5167ac ASYLUM: Small fix for object and actor coordinates
f5b8dfe959 ASYLUM: plug memory leak
692ade2186 ASYLUM: Switch ActorDirection to an enumeration
7c64f717ec ASYLUM: Add GraphicFrame helper functions
5ff3345115 ASYLUM: Fix Scene::hitTest() case for the main actor
c878f301f0 ASYLUM: silence warning
d38322ebca ASYLUM: Cleanup Pass 1
8528b9d964 ASYLUM: Cleanup Pass 2
3e6f065a91 ASYLUM: Cleanup Pass 3
5186ad9425 ASYLUM: Moved shared data to new structure
6a869e6171 ASYLUM: Rename Screen::clearScreen to Screen::clear
a778f4e7a4 ASYLUM: Scene loading & actor logic
b090514dbd ASYLUM: Add missing case in Speech::playIndexed
f49d9e2425 ASYLUM: Fix compilation with latest Singleton changes from trunk
16dd32098d ASYLUM: Add reaction-related Actor process methods
e812374b9f ASYLUM: Add stubs for loading ActorData as part of the scene (and cleanup scene loading a bit)
f8838d5322 ASYLUM: Remove unused actor field
3c3c0a5a4e ASYLUM: Fix compiler warnings (patch by DrMcCoy)
3cd5aa8d2b ASYLUM: Fix compilation with stream changes in trunk (r54385)
9362d3b943 ASYLUM: Use pow in Actor::distance().
fd5e272080 ASYLUM: Properly reset shared data in Actor::enableActorsChapter2
7ed0b6eb65 ASYLUM: Update actor helper functions
23c559939b ASYLUM: Implement a couple of small Actor helper functions
ca4c5d1b49 ASYLUM: Implement more Actor helper functions
1ca905680c ASYLUM: Implement some Actor::updateStatus methods
cba710ff8a ASYLUM: don't use itoa() as it's not portable (use sprintf() instead)
b3b0977555 ASYLUM: Implement more Actor::updateStatus* functions
351c466746 ASYLUM: Rename direction enum values
2d04087fc2 ASYLUM: Add stubs for two more graphic queue methods
e96fe9c8d3 ASYLUM: Add console command to run an encounter
307af404cf ASYLUM: Implement "script" debug command
871ed2f0ed ASYLUM: Implement ActionList::enableObject()
15e46d466a ASYLUM: Update event handling + encounter progress
377438ef7a ASYLUM: Update Encounter class
4cd87eaee2 ASYLUM: Implement AsylumEngine::switchMessageHandler()
c8a9d4cc0a ASYLUM: Implement Encounter::runScript()
a07548e605 ASYLUM: Implement Encounter::findKeyword()
01b0ea4915 ASYLUM: Implement Encounter::messageHandler()
e23232ddec ASYLUM: Add Encounter::isSpeaking() helper method
b808ab3e2a ASYLUM: Move two encounter flags from shared data to Encounter class
4534e7fbda ASYLUM: Move data.h to resources folder
df58690e9c ASYLUM: Move puzzle class to a separate puzzles directory
d2c8b7e83f ASYLUM: Move VCR puzzle to a separate file
7c179d025e ASYLUM: Enhance actions debug command slightly
a02af8db05 ASYLUM: Implement Encounter::init and update Encounter::messageHandler
11a6152eae ASYLUM: Update event handling
10615c7aed ASYLUM: Init puzzle on first use (the background id is scene-dependent)
4ddf064c3f ASYLUM: Implement Encounter init methods
46d6833e3e ASYLUM: Implement some speech-related encounter helper methods
32c6bcc631 ASYLUM: Implement two more Actor process methods
98ee55b9f3 ASYLUM: Update Text class
4c07c73e00 ASYLUM: Add loading of transparency tables
a6178aa903 ASYLUM: Fixed Actors and Objects positions according with Scene screen scrolling.
ce04e57184 ASYLUM: Revert previous commit!! Commented WorldStats xLeft and yTop from Scene::adjustCoordinates to correct actors and
98a98a8486 ASYLUM: Fix GCC compilation and warnings
fff878e1c0 ASYLUM: Cleanup some screen methods
12057a04d2 ASYLUM: Use subtitle config option when playing movies
9d195216a3 ASYLUM: Cleanup use of adjustCoordinates
f8b4d22f7b ASYLUM: Move coordinate adjustement to Screen::drawGraphicsInQueue
f4b1d284b1 ASYLUM: Convert MainMenu to implement EventHandler
0047d10a67 ASYLUM: Add Savegame class
8a6d76b65e ASYLUM: Overhaul event handling
3d7b00db63 ASYLUM: Implement some menu helper functions
912e3131a3 ASYLUM: Implement MainMenu::click()
1286a8bdc4 ASYLUM: Add back Menu credits, new game, quit and return to game
eaea0cd79d ASYLUM: Implement MainMenu update handlers for text, audio, setting and keyboard config
a326b61533 ASYLUM: Implement more menu click handling
7479a0f487 ASYLUM: Implement MainMenu::adjustTextVolume
30423dae12 ASYLUM: Implement menu music and main settings click handling
7de833af20 ASYLUM: Finish keyboard handling for shortcuts configuration
2172d82d2e ASYLUM: Implement rest of game startup
e1d12045d0 ASYLUM: Refactor parts of Scene class
814ac99ac4 ASYLUM: Update scene event handling and preload
fbe5ee0614 ASYLUM: Fix SceneTitle spinner not moving
818f241530 ASYLUM: Implement Scene::update(). Scene now draw again!
15421b6b79 ASYLUM: Fix GCC warnings in Menu
787546f83d ASYLUM: Finish implementing Object::playSounds
ee682f8458 ASYLUM: Reduce SceneTitle progress total time
e75170cc14 ASYLUM: Implement proper blitting methods in Screen class
fde7a99ece ASYLUM: Properly clip coordinates and adjust drawing width/height
151e417b72 ASYLUM: Wait 10ms when handling events (reduces CPU usage a lot)
b0248c93fd ASYLUM: Remove obsolete methods from Scene class
26cb6c9857 ASYLUM: Implement Scene mouse events
1b8bf43570 ASYLUM: Cleanup Scene and add documentation
a621f028f4 ASYLUM: Implement and update Scene hitTest methods
1cfd406ef3 ASYLUM: Implement scene drawing list actor priority adjustment
9e18348aae ASYLUM: Implement Scene::handleHit
b729447782 ASYLUM: Rename ActionList to ScriptManager and move to engine class
51bf14d497 ASYLUM: Move Special and Speech instances to engine class
b115baf346 ASYLUM: Implement special Scene hit actions
2540959025 ASYLUM: Finish implementing some Scene functions
4c7cb12983 ASYLUM: Update Scene::updateMouse() and Scene::updateAmbientSounds()
e8933a7c0b ASYLUM: Fix scene palette not being set properly after fade
6e1b4a1801 ASYLUM: Finish implementation of Scene::updateCursor()
7ac6893f22 ASYLUM: Implement main part of Scene::hitTestActor()
9b4c9572ea ASYLUM: Implement Scene::key() and Scene::speak()
7877692768 ASYLUM: Implement cursor animation
527a517e85 ASYLUM: Implement Scene::playerReaction
9d4fd0da2a ASYLUM: Implement Savegame::getMoviesViewed() and Savegame::setMovieViewed()
ba2a0a4070 ASYLUM: Implement remaining part of Scene::hitTestActor()
49215b5c16 ASYLUM: Implement proper version of Scene::findActionArea()
9cde7749f0 ASYLUM: Move isInActionArea from Scene to Actor
7a8741e08a ASYLUM: Implement sine/cosine table calculation on engine start
7463acb772 ASYLUM: Implement Scene::enterLoad() and Scene::changePlayer()
84dbd45ae0 ASYLUM: Add Game::reset() function
e137c665c1 ASYLUM: Cleanup sound queue
0fe5d4a88e ASYLUM: Properly stop music and sound when adjusting performance in the menu
d86ac73023 ASYLUM: silence a few warnings
f0eb2a9497 ASYLUM: Fix a couple more GCC warnings
d26a445376 ASYLUM: Finish implementation of Scene::updateCoordinates()
318aaf1997 ASYLUM: Add stub for screenshot function in Screen class
9057e1e6fc ASYLUM: Implement Encounter::key()
e3870d830c ASYLUM: Implement Encounter::mouse()
361b117283 ASYLUM: Implement Encounter::update()
c01a3f39e7 ASYLUM: Implement Encounter function findRect(), updateDrawingStatus1() and updateDrawingStatus2()
3c56473752 ASYLUM: Implement Encounter::updateScreen()
b8e6b28f8f ASYLUM: Implement Encounter::updateDrawingStatus() and Encounter::setupSpeech()
c5acdc2a04 ASYLUM: Implement Encounter::drawBackground() and Encounter::exit()
ac0ae2162f ASYLUM: Implement Encounter functions drawPortraits(), drawStructs() and drawDialog()
e5b3e4c476 ASYLUM: Fix two warnings and rename two flags in Encounter class
1ea8f311a9 ASYLUM: Implement Encounter functions getKeywordIndex(), choose(), checkKeywords(), checkKeywords() and updateFromRect()
5b43d804d9 ASYLUM: Implement Encounter::drawText()
ce312cfe83 ASYLUM: Implement more Actor status update
5c048aec55 ASYLUM: Add proper enumeration value for kObjectCave
bde3c3d0d1 ASYLUM: Add back processing of delayed events
730105912f ASYLUM: Update ResourcePackId enum values
436a6f3ef2 ASYLUM: Rename puzzle classes
7321b5cf73 ASYLUM: Update engine status comment
d1235f9a64 ASYLUM: Fix Screen::clear()
691da08b8d ASYLUM: Properly check for index validity in ResourcePack::get
701d31f34f ASYLUM: Check for NULL event handler before calling methods
7a8de08efb ASYLUM: Add palette and draw debug commands
c448ae8560 ASYLUM: silence a couple warnings
dc16c2e879 ASYLUM: silence one more warning
a91edc92eb ASYLUM: Update Puzzle to new event handling
34a6ee87cf ASYLUM: Add Puzzle::exit() default implementation
574abfd1b2 ASYLUM: Add stubs for puzzles
d45a2fd4a1 ASYLUM: Copy backbuffer to screen in Screen::clear()
54381ad846 ASYLUM: Implement most savegame handling (except actual write & read)
af09eeccee ASYLUM: Implement saving of games
46aa306513 ASYLUM: Implement loading of games
26eacef2fc ASYLUM: Move Video class to views
ae4d75e6a0 ASYLUM: Convert Video to new event handling
5cf0c83dc2 ASYLUM: Implement MainMenu::keySaveGame()
e7366c3a91 ASYLUM: Rename MainMenu to Menu
12405a143e ASYLUM: When running in debug mode, make the scene title faster
9ce5f05ba9 ASYLUM: Implement Menu::updateViewMovies()
3e7be182ca ASYLUM: Implement Menu::updateLoadGame() and Menu::updateDeleteGame()
28d349179c ASYLUM: Implement Menu::updateSaveGame()
5c1ba7b2c5 ASYLUM: Implement basic version of Sound::isValidSoundResource()
f0ffac2021 ASYLUM: Implement Sound::getAdjustedVolume()
dc44ab0138 ASYLUM: Implement Menu::clickDeleteGame()
5b5fa97915 ASYLUM: Implement Menu::clickViewMovies()
2743c1f763 ASYLUM: Fix problem in Savegame::getMoviesViewed()
dc5023408e ASYLUM: Implement Menu::clickLoadGame()
f39d411631 ASYLUM: Rename Menu _textScroll to _startIndex
2a785f0b52 ASYLUM: Implement Menu::clickSaveGame()
c9985fe1cd ASYLUM: Implement Scene::updateMusic()
474888bde7 ASYLUM: Fix savegame name editing width test
926ab4b6a0 ASYLUM: Small update to Scene::processUpdateList()
abcb2858e5 ASYLUM: Correct initial value of flag in Screen class
359794ec5d ASYLUM: Made several SharedData members public
10b68af638 ASYLUM: Remove last use of _delayedSceneIndex and delayedVideoIndex in Script class
bedc73b5f5 ASYLUM: Implement Encounter::drawScreen() minus palette changes
1d1ae9eea1 ASYLUM: Add debug command to start a puzzle
c19fba0b1f ASYLUM: Implement handleEvent in Puzzle class and let child classes implement init, key & mouse handlers
abfbc4de6e ASYLUM: Properly initialize GraphicQueueItem type
8fea270172 ASYLUM: Convert VCR puzzle to new event handling
109a98049a ASYLUM: Implement start of Tic Tac Toe puzzle
4e654d2dfb ASYLUM: Load the proper scene when using the puzzle command
f437a4a2e3 ASYLUM: Implement PuzzleTicTacToe::update()
a3d50bb1cd ASYLUM: Add a Screen::draw() helper function to draw backgrounds
1ba2e61c1d ASYLUM: Implement Polygons::contains()
42adf9dc52 ASYLUM: Implement Puzzle::hitTest helper functions
4082f2deae ASYLUM: Implement Tic Tac Toe puzzle game logic
6bddbc6158 ASYLUM: Correct use of ARRAYSIZE
fe4560c6cd ASYLUM: Add Screen::drawLine debug function
1150dcd7b3 ASYLUM: Use Polygon contains function in Puzzle::hitTest instead of custom code
9663342e0d ASYLUM: More work on Tic Tac Toe puzzle
5e77b91caa ASYLUM: Finish implementation of PuzzleTicTacToe::drawField()
f1702ca260 ASYLUM: Fix proper cursor not showing in Tic Tac Toe puzzle
73d6f33c57 ASYLUM: Check for valid sound resource before playing music
d145f93a7c ASYLUM: Use switchScene() when switching scenes through the debugger
2ec06b5da7 ASYLUM: Use per-entry current line in script manager
ec57d4bca7 ASYLUM: Implement parts of Fisherman puzzle
f5796088c0 ASYLUM: Implement rest of Fisherman puzzle
1ec34182d6 ASYLUM: Implement first part of Morgue Door puzzle
c6b1ad3dae ASYLUM: Implement PuzzleMorgueDoor::updateCursor()
2af4710142 ASYLUM: Implement parts of PuzzleMorgueDoor::updateState()
7e9d838945 ASYLUM: Implement rest of PuzzleMorgueDoor::updateState()
ea4745df71 ASYLUM: Puzzle 13 is really the clock puzzle
d7650f0409 ASYLUM: Do not try to load kResourceNone resources in GraphicResource::load()
254366a3ee ASYLUM: Implement parts of puzzle 11
aed293bdea ASYLUM: Implement beginning of TimeMachine puzzle
05fc5ab399 ASYLUM: Updated chapter 11 name (kResourcePackMorgueAndCemetery)
2dbec0c5e1 ASYLUM: Add reset() method to PuzzleMorgueDoor
ecdfe4532b ASYLUM: Implement frame indexes updates in PuzzleTimeMachine
81a1d389b1 ASYLUM: Cleanup Screen::clip() and fix wrong sign in Screen::blt()
9284925835 ASYLUM: Use local _point for coordinates in PuzzleTimeMachine
b52bed63d8 ASYLUM: Refactor puzzle event handling
8b02d1b6c6 ASYLUM: Revert back to previous Puzzle::key() implementation
25df731c64 ASYLUM: Implement Wheel puzzle initialization
09fd8412f4 ASYLUM: Implement Wheel puzzle helper functions
a9ca52abef ASYLUM: Fixed compilation after the latest trunk changes
beb8ef9da9 ASYLUM: fix linux compile
5acbe01dd8 ASYLUM: Rename special Scene chapter 5 function to drawRain
55a1bca99c ASYLUM: Fix regression with use of evt.mouse in puzzles updateCursor functions
76e623a681 ASYLUM: Rename rain frame index
8f0b6e04ba ASYLUM: Make sure we don't use negative modulo with unsigned int values in PuzzleTimeMachine
cb86e1b524 ASYLUM: Finish implementation of Wheel puzzle
26eae3bd44 ASYLUM: Fix a typo in Text::draw and add some comments
fa0705770b ASYLUM: Implement parts of Writings puzzle
fc53180f5f ASYLUM: Implement Lock puzzle
265d18ee14 ASYLUM: Implement proper Scene::hitTestPixel()
424c02a6af ASYLUM: Fix warning in TimeMachine puzzle
6186775f36 ASYLUM: Add stubs for Pipes puzzle
22f77dd05c ASYLUM: Overhaul script processing
35db68fb7c ASYLUM: Implement Actor::updatePlayerChapter9()
925c146a61 ASYLUM: Implement PuzzlePipes::updateCursor()
2b8aea3835 ASYLUM: Add stubs for Hive puzzles
4cfedb290d ASYLUM: Implement some of the Hive puzzles methods
f5994d02a8 ASYLUM: Add stubs for Board puzzles
148b5608b7 ASYLUM: Add character maps for Board puzzles
365ceb1b4f ASYLUM: Add base PuzzleBoard class for Board puzzles
dce22936ad ASYLUM: Implement shared Board puzzle methods
5632921ca5 ASYLUM: Implement PuzzleBoard::updateCursor()
aefb29447f ASYLUM: Implement PuzzleBoard::init()
62f092c54d ASYLUM: Add missing check in PuzzleBoard::update()
6a5257f0ce ASYLUM: Implement PuzzleBoardSalvation::mouseLeftDown()
98e29bbe0e ASYLUM: Implement mouseLeftDown() function for KeyHidesTo and Youth board puzzles
ebb7bc6673 ASYLUM: Sync with trunk
ec55db7494 ASYLUM: Fix some invalid array accesses, a missing array delete and a potential NULL pointer use
62098ed51e ASYLUM: Sync with the latest changes in trunk
2487a6e70b ASYLUM: Sync with sound/ to audio/ changes on trunk
aaba66f5b4 ASYLUM: Sync with palette changes on trunk
493593bf3e ASYLUM: Fix signed comparison warnings
3a003ea7e6 ASYLUM: fix compile (PI => M_PI)
57229d51ab ASYLUM: fix compilation against current master
baa64d84d4 ASYLUM: replace exit() with exitPuzzle() or exitEncounter()
be33e9b481 ASYLUM: fix initialization on Linux systems
e2f2138450 ASYLUM: Drop "Engine" from the engine name in AsylumMetaEngine::getName()
2b6758af00 ASYLUM: Switch to alternate AdvancedMetaEngine, avoid ADParams
75aabbdefb ASYLUM: add english demo
f36dbc95c2 ASYLUM: fix compilation against updated AdvancedDetector changes
96c6b1cd3f ASYLUM: Fix text centering for multi-line texts
4f386a7b98 ASYLUM: Terminate subtitle info buffer
9360e0a6a2 ASYLUM: Initialize all flag variables in SharedData to silence Valgrind warning
6614632919 ASYLUM: Move DECLARE_SINGLETON() inside namespace Common
d9b16f8846 ASYLUM: Implement Actor::checkAllActions()
9eb83256fe ASYLUM: Add stubs and rename Actor update methods
92968813ea ASYLUM: Implement Actor::updateStatus15_Chapter2_Actor11_Helper()
9b92fc5e64 ASYLUM: Implement Actor::updateStatus15_Chapter11_Player()
364fded725 ASYLUM: Cleanup Actor::getGraphicsFlags()
16ae198eea ASYLUM: Implement Actor::updateStatus15_Chapter2_Helper()
8b9d471a7f ASYLUM: Implement parts of Actor::process()
74d67ae3cd ASYLUM: Implement Actor::isInActionArea()
836e1f43d8 ASYLUM: Process all events in the queue on each call of AsylumEngine::handleEvents() instead of just one
1b9c4dd404 ASYLUM: Add DrawFlags enumeration and update drawing functions parameters
9f6d671569 ASYLUM: Change Screen::draw() functions to take Common::Point as source/destination parameters
db78a0c0f0 ASYLUM: Implement Actor::playSounds()
4229cdf88f ASYLUM: Implement more of Actor::process()
12f0c9fee2 ASYLUM: Fix typo in Scene::processUpdateList()
90d21d0ad8 ASYLUM: Add support for mirrored blit
1526593cf0 ASYLUM: Replace several pairs of (x, y) parameters by Common::Point
9979c06421 ASYLUM: Implement pipes puzzle
1db67c5c88 ASYLUM: Remove SVN keywords
a64de0c34b ASYLUM: silence warnings about shadowed variable declarations
b3a4c7fc9f ASYLUM: Fix mirrored blit
4cb90f4023 ASYLUM: Fix Scene::rectIntersect() and cleanup part of Scene::processUpdateList()
958b7f1041 ASYLUM: Fix GCC warning on undefined operation in Actor::playSounds()
e212e20a6b ASYLUM: Fix ResourceEntry::getData()
3ddd300f10 ASYLUM: Update Screen::draw() with mask source and destination rectangles calculation and add stub for Screen::blitMaske
b9eb9f91ec ASYLUM: Screen::blitFast() does not need flags
ee89b3837a ASYLUM: Implement Screen::addGraphicToQueueCrossfade() and add stub for Screen::blitCrossfade()
c920613363 ASYLUM: Remove colorkey parameter to blt* functions and use _useColorKey member instead
4325184d2a ASYLUM: Implement the rest of Screen::blit() and add stubs for all the helper blit functions
5987db75f0 ASYLUM: Implement Screen::blitMasked() and some helper methods
5b5cf905fa ASYLUM: Implement Screen::blitTranstable() and Screen::blitTranstableMirrored()
18e85a5efa ASYLUM: Implement part of Actor::updateStatus12_Chapter2()
519f4f86f2 ASYLUM: Implement Actor::updateAndDraw()
986176b445 ASYLUM: Finish implementation of Actor::update()
4e3a6d51dc ASYLUM: Update ActorData structure (it is holding a set of points and directions for pathfinding)
d2eabdf880 ASYLUM: Replace Actor::clearFields() by sane version
8596b8f213 ASYLUM: Update use of shared data in Actor::updateStatus12_Chapter2()
cae5eaa927 ASYLUM: Implement Actor::checkPath()
6b20fdb4e4 ASYLUM: Rename arrays holding the distances for each actor frame index
78681cf803 ASYLUM: Correct usage and implementation of Actor::getDistance()
345d0cf909 ASYLUM: Merge getDistanceForFrame() and getDistance()
010fd87b59 ASYLUM: Implement Actor::processAction* helper functions
2a4cf12823 ASYLUM: Fix showing of debug regions
c9d39ce3c2 ASYLUM: Add drawing rects and mask visualization
492eb8a30c ASYLUM: Cleanup Scene::processUpdateList() and Scene::pointIntersectsRect()
f011d86920 ASYLUM: Properly check for object flags when drawing
c727c909a6 ASYLUM: Implement some missing parts of Screen::blitMasked()
faaa1c1426 ASYLUM: Correct Screen::clip() and check for valid source rectangle in Screen::draw()
e44da6e34a ASYLUM: Update Screen::blitTranstable()
018ca6a4b2 ASYLUM: Add console command to modify actor coordinates
9be6905934 ASYLUM: Mark demo version as "Demo"
9805f4cebd ASYLUM: Add some bound checking to ScriptManager::process()
a5e03e18a1 ASYLUM: Implement Screen::blitCrossfade()
082789c8f2 ASYLUM: Rename Polygons helper function
3727e9a820 ASYLUM: Add option to draw the scene rects
def09b8c20 ASYLUM: Rename some movement-related Actor methods
5b3efe8192 ASYLUM: Cleanup polygon class
0c36e2755a ASYLUM: Fix checking of flags when processing action areas
9fef446809 ASYLUM: Adjust flag array size
48f733baf0 ASYLUM: Remove unused ActorResources enumeration
9bc78f83db ASYLUM: Update ScriptManager
62d576eae5 ASYLUM: Add debug drawing of zoomed mask
81c6898fa6 ASYLUM: Simplify handling of transparency tables
b15b5cb473 ASYLUM: Identify transparency field for Actor and Object
9d54c6b5fc ASYLUM: Rename several Actor methods
7828f300fa ASYLUM: Silence GCC Warning
80583b079b ASYLUM: Pipes puzzle: add spiders
4ef22bfb2f ASYLUM: Pipes puzzle: continuous progress bars
2cde66d926 ASYLUM: Implement Hive machine puzzle
2dd9930297 ASYLUM: Fix uninitialized variable warning in PuzzlePipes::update()
0c223c5875 ASYLUM: Fix flickering of text in the credits
07f49cdf9a ASYLUM: Initialize _frameIndexSpider in PuzzlePipes constructor
01f4a0769c ASYLUM: implement Screen::setPaletteGamma and part of Screen::setGammaLevel
7454be17cc ASYLUM: fix logic error in Screen::setGammaLevel
83194b47c8 ASYLUM: Silence more GCC warnings
a663c3da75 ASYLUM: fix a logic error in JumpIfGameFlag
2608705d6d ASYLUM: sanity check for a possible assertion in Polygon::contains
4c4027200a ASYLUM: Implement Screen::bltMasked()
da8d1c11b5 ASYLUM: Update engine status
71ffd5313a ASYLUM: Move DEBUG_SCENE_TIMES to scene.cpp
997002786d ASYLUM: Assign the current graphicResourceId in Cursor::set
ef730d52d9 ASYLUM: Add a TODO regarding a proper implentation of the intro speech
1706cc2ff7 ASYLUM: Implement Actor::processAction()
64c70dea97 ASYLUM: Implement Actor::updateDirection()
5ca35ddd2f ASYLUM: Fix playing of intro speech (wait until the sound is finished before showing the scene)
015c1cfb92 ASYLUM: Fix valgrind problems reported by eriktorbjorn
901f032b77 ASYLUM: Fix debug drawing of zoomed mask
6a31a7406d ASYLUM: Add a set of functions to pass a GraphicResource* directly to Screen::draw()
55523032ce ASYLUM: Implement Hive control puzzle
defb533d1e ASYLUM: Pipes puzzle: replace log(x)/log(2) with Common::intLog2(x)
185aedd05b ASYLUM: Pipes puzzle: fix lamp indicators
fd3e63e95e ASYLUM: Hive machine puzzle: fix typo
83cbf040a5 ASYLUM: Hive machine puzzle: add missing playSound() call and rename counters
c91086bee5 ASYLUM: Fix compilation with Visual Studio
db1ddf2b16 ASYLUM: Add the list of puzzles in the console command help message
cb241adfae ASYLUM: Fix credit text disappearing instead of fading out when at the top of the screen
55a9a133da ASYLUM: Implement the rest of Actor::process()
6b4f3435c0 ASYLUM: Remove Puzzle::reset() functions
ba2addab8d ASYLUM: Finish implementation of AsylumEngine::restart()
1ba0c2a354 ASYLUM: Fix crash when initializing Board puzzles
7c9a793a64 ASYLUM: Finish implementation of Scene::processUpdateList()
203e18669e ASYLUM: Implement Actor::updateStatus14_Chapter2()
96abeb1672 ASYLUM: Implement Actor::updateStatus15_Chapter2_Player()
6879945591 ASYLUM: Implement the missing part of Special::chapter2()
88d0d33464 ASYLUM: Cleanup Actor::updateStatus15_Chapter2_Player()
188264b94f ASYLUM: Implement Actor::updateStatus15_Chapter2_Actor11()
f453ab6da7 ASYLUM: Implement Actor::updateStatus15_Chapter2()
fb8afdc6d6 ASYLUM: Palette and gamma functions update
86126add5f ASYLUM: Implement palette fading timer and related functions
6475c3d9f9 ASYLUM: Implement Screen::paletteFade()
6201a4cf9e ASYLUM: Implement more palette related functions
9746136ee3 ASYLUM: Fix palette fading corruption (visible in the cinematics menu when starting a video)
da7fd8c203 ASYLUM: Fix GCC warning in Screen::paletteFade()
82ff79f04c ASYLUM: Implement Actor::canInteract()
ed60255adf ASYLUM: Add delay in event loop in the intro
f6733c0cfb ASYLUM: Update actor distances functions
d4e5d66e59 ASYLUM: Implement Actor::updateStatus18_Chapter2_Actor11()
e056a92862 ASYLUM: Remove unused member from SoundQueueItem
f6fd9adc50 ASYLUM: Implement Actor::updateStatus12_Chapter2_Actor11()
361c52ef01 ASYLUM: Add data written checks when saving games
5ba6a0605d ASYLUM: Correct usage of some shared data
c78554d6d0 ASYLUM: Reorganize and document shared data
e130e128b4 ASYLUM: Implement AsylumEngine::saveLoadWithSerializer()
5aad67007b ASYLUM: Change SharedData into a class and move method implementations into cpp file
906cbe7a23 ASYLUM: Rename puzzles/data.h to puzzles/puzzledata.h
28363f844d ASYLUM: Reorganize SharedData
3dc4f42062 ASYLUM: add a workaround for the cursor not remaining hidden during the intro speech
1d7ac2949e ASYLUM: fix some warnings found by eclipse
30b4f0b931 ASYLUM: fixed a bug in Actor::updateFinish()
b308839952 ASYLUM: Add detection entry for Russian version
c51cd5dea9 ASYLUM: Attempt to fix a bug in Text::draw(int32, int32, TextCentering, ...)
0978aa14ab ASYLUM: actually save configuration changes to settings file
ef991acd9e ASYLUM: Silence GCC Warnings
0ea5649869 ASYLUM: remove unused variable
71e1afe2c4 ASYLUM: make a couple actor fields int32
2e9ab6929a ASYLUM: revert commits aac7e28, 326ec63 and bfe63c2
ff0d80587f ASYLUM: Change text coordinates parameters to use Common::Point
0f14a09cd4 ASYLUM: Remove useless includes
b9cb91d016 ASYLUM: Cleanup puzzles
44540643e8 ASYLUM: Cleanup base classes
f8d11e354a ASYLUM: Cleanup script manager
5b0da5965c ASYLUM: Cleanup more base classes
78f275d796 ASYLUM: Cleanup Scene and related classes
99f2521155 ASYLUM: Cleanup Menu class
54ad18711d ASYLUM: Implement ScriptManager::saveLoadWithSerializer()
1a350dd104 ASYLUM: Handle empty savegame files
ecca126022 ASYLUM: Better debug output when writing/loading savegames
c935ba9eae ASYLUM: Prefix debug output with type
d1b6bbabfd ASYLUM: Move skipScriptProcessing and isEncounterRunning flags to SharedData
072fd08206 ASYLUM: Accept keypad enter to validate a savegame name
8f470f1fcb ASYLUM: Rename flag set when we are editing a savegame name
f106c50b36 ASYLUM: Move actorIndex to SharedData
8370719912 ASYLUM: Move Encounter disablePlayerOnExit flag to SharedData
70460193ad ASYLUM: Skip saving of viewed movies as part of the shared data
d6883a89a1 ASYLUM: Implement WorldStats::saveLoadWithSerializer()
ebfd32685b ASYLUM: Implement Object::saveLoadWithSerializer()
059c8820c3 ASYLUM: Implement saveLoadWithSerializer() for Actor and ActorData
639ccdaff9 ASYLUM: Implement ActionArea::saveLoadWithSerializer()
f09c34bc51 ASYLUM: Cleanup loading/saving of scene data
b1493f5be3 ASYLUM: Move puzzles handling to Puzzles class (formerly PuzzleData)
34b50ab2f3 ASYLUM: Add stubs for puzzles saveLoadWithSerializer()
6eb0271440 ASYLUM: Implement saveLoadWithSerializer() for most of the puzzles
ba2237ae0b ASYLUM: Implement saveLoadWithSerializer() for EncounterItem and EncounterVariables
f10091a616 ASYLUM: Implement saving of script data
4b7e86f226 ASYLUM: Fix problems with savegames in Menu
c3f531c272 ASYLUM: Add padding when saving strings
8032becd15 ASYLUM: Only handle final version savegames until we can verify all savegames are compatible
03cd0ddf56 ASYLUM: Fix loading of saved games
72d5a60e3b ASYLUM: Fix regression in loading of scenes from the console
46d189ec9f ASYLUM: Add more error handling to script opcodes manipulating objects
919afab0bf ASYLUM: Fix running of encounters from the debug console
8f2a9464e0 ASYLUM: Fix initialization of second portrait in Encounter::initPortraits()
4113ef8255 ASYLUM: Silence an analysis warning by adding a virtual destructor to SharedData
fa9083c250 ASYLUM: Implement missing priority code in Scene::processUpdateList()
b67ba25820 ASYLUM: Add missing call to Special::run() in Actor::update()
ee40059ed7 ASYLUM: Fix a bug in ScriptManager::opcodeJumpIfActorCoordinates()
46f5eb05c3 ASYLUM: Implement slightly better switching of scenes through the debugger
734afc0bbc ASYLUM: Change kResourceInvalid to be -1
d19ec57732 ASYLUM: Fix memory leak in ResourceManager
2f18c1cb36 ASYLUM: Misc. cleanups
f929f58e9a ASYLUM: Cleanup Actor class
bdec064f12 ASYLUM: More cleanup of Menu class
341bf99614 ASYLUM: Cleanup Screen class
156ffb1276 ASYLUM: Simplify Screen::setPaletteGamma()
21fa0d155e ASYLUM: Fix some potential out of bound array accesses
083afccd67 ASYLUM: Finish implementation of TimeMachine puzzle
407c96b3d2 ASYLUM: fix warnings
6d591a9a99 ASYLUM: Add timer ID to installTimerProc() call in Screen::startPaletteFade()
92181cef22 ASYLUM: Rename encounter flags
76fd40f931 ASYLUM: Update Encounter
5dffe40733 ASYLUM: Rename EncounterItem::keywordIndex to speechResourceId
e05d0c21e4 ASYLUM: Rename more Encounter script opcodes
03df42a1c7 ASYLUM: Fix part of encounter scripting
f4a96e448d ASYLUM: Rename the rest of Encounter opcodes
272d5ffa1f ASYLUM: Flag detections entries with ADGF_UNSTABLE
cc81d47548 ASYLUM: More encounter cleanup
b82752e649 ASYLUM: Pipes puzzle: fix initialization
be21e4e028 ASYLUM: Writings puzzle: fix an infinite loop in drawBackground()
1fc9a8a837 ASYLUM: HiveControl puzzle: add completion checks
a67ea83e23 ASYLUM: HiveControl puzzle: fix a bug
d61d51f190 ASYLUM: HiveControl puzzle: fix minor glitch in updateScreen()
f7213d1af5 ASYLUM: silence an analysis warning by adding a virtual destructor to ActorData
2c1b1d3cf4 ASYLUM: PuzzleBoard: fix checkSlots()
68b9df5a4b ASYLUM: identify a couple ActorStatus values
9277116e09 ASYLUM: identify more ActorStatus values
0553f5dfd8 ASYLUM: added a FIXME to Actor::update() for kActorStatusWalkingTo
0ab8d0c858 ASYLUM: add a some debug output and rename ActorDirection
472a7252c4 ASYLUM: align enum assignments
5d0af78206 ASYLUM: remove accidentally committed debug code
e73059638a ASYLUM: enable debug channel for Actor objects
cdb9c748c0 ASYLUM: fix a logic error in Actor::update
59cfa7ce66 ASYLUM: convert GUI options to sync with master
c97fe2a6ca ASYLUM: Fixed script reset while changing scenes.
0703dbfff4 ASYLUM: Fixed compilation with DEBUG definition
e68598ff9f ASYLUM: Fixed JumpAndSetDirection incorrect parameter set.
0dc2ab3402 ASYLUM: Fixed various issues in Actor position calculations. Still missing something yet to make Max climb the first sta
b6cce3a19f ASYLUM: add some debug output for sound queue events
bfe8276bc8 ASYLUM: update a comment
0c7b3038fe ASYLUM: replace isalnum() with Common::isAlNum()
7bf4a85cb2 ASYLUM: fix compilation with latest master
6f7307bd60 ASYLUM: remove unnecessary include
5b1bb1d145 ASYLUM: change kPlatformPC => kPlatformWindows
baf4fa93cb ASYLUM: access surface pixels via getPixels()
c92af6b25f ASYLUM: update engine to new build system
652e134c46 ASYLUM: fix compilation
926443d63f ASYLUM: fixed smacker video playing and added new debug level
34214332e9 ASYLUM: more script debug output
c1e47d473d ASYLUM: include the chapter number in the worldstats instance inspector
6004f808dc ASYLUM: add name to debug out for object inspection
5259f1e506 ASYLUM: added show_script and action commands
5db12fc55b ASYLUM: debugging helper to prevent printing running script line more than once
7388be8824 ASYLUM: script debugging in actor code
1b6120e974 ASYLUM: Fixed Scene Update Coordinates with Motion
de2ac3012c ASYLUM: Enable code to allow Actor to walk to a position
bf2d5d7765 ASYLUM: Fixed wrong coordinate check in Actor canMoveCheckActors
ad85c727d2 ASYLUM: Commented Script JumpIfActorCoordinates and added comments. This is to allow us to proceed within the script and
c7a7025ca5 ASYLUM: Fixed wrong palette info attached that was causing a segmentation fault.
5fbe1d706b ASYLUM: Skip intro talk about Max
b8a3047e3f ASYLUM: Fixed correct resourceId while Actor is disabled.
52fe2f8455 ASYLUM: debug for non implemented palette functions instead of error, so we can proceed with the game. A lot of bugs but
42e09f359b ASYLUM: Fixed incorrect string format
b374c59bdf ASYLUM: Fixed actor visibility entering the scene. Chapter 2 can now be played.
5dd9d33d2c ASYLUM: add debug output to special::check[Other]Object and test for kObjectInvalid
294e27d67f ASYLUM: Fixed chapter 2 specials crash
d25c7ed13a ASYLUM: Encounter tiny fixes.
410a7aab2e ASYLUM: Encounters speech play. Still buggy has it loops through all the voices but at least isn't stuck in the screen a
40e5cc51a1 ASYLUM: Few encounter script fixes.
c5ed6cb220 ASYLUM: Encounters script size has originl
230054c0c3 ASYLUM: Added missing debug channels
8ad1bcb8a9 ASYLUM: Rename variables to match changes to AdvancedMetaEngine.
ffe854efe7 ASYLUM: Fix Various GCC Compiler Warnings.
79ef1c65dd ASYLUM: Fix Compilation Due to initGraphics Function API.
86eee35eb4 ASYLUM: Correct Compilation On Newer GCC.
a9ef5fe57a ASYLUM: fix fallback detection
19d343e82f ASYLUM: Split detection features & adapt to new plugins.
9195e58c33 ASYLUM: Modify data search paths to match canonical locations.
e20a8bc6b1 ASYLUM: check param2
49941a57b4 ASYLUM: use max index instead of count
3c53386332 ASYLUM: fix an index
4f7978b243 ASYLUM: rework removeReactionHive
5bed7c1c55 ASYLUM: sync with removeReactionHive
88f63359e8 ASYLUM: align keywords
8157fc35ab ASYLUM: missing comma
87205c935e ASYLUM: reset text data at return
c7b652226c ASYLUM: unify script offset
994fb8133d ASYLUM: unloop dialogs
af823c01ee ASYLUM: fix build
19712bac19 ASYLUM: restore palette when VCR puzzle is completed
c08da99266 ASYLUM: add a workaround to handle action areas intersection
ae58cb534d ASYLUM: re-enable the console
051213bad5 ASYLUM: fix ActionArea::toString()
9f5008b18d ASYLUM: set a game flag when the Pipes puzzle is solved
560d0a68ad ASYLUM: don't reset the Pipes puzzle's data each time it's being run
6678429e49 ASYLUM: reorder PuzzlePipes::_connectors to match the original
c232bc5dec ASYLUM: fix a wrong index
eb9443461e ASYLUM: gitignore build files
30109163b4 ASYLUM: Fixed MacOS crash. Poll Events not allowed outside the main thread.
bbceb7b098 ASYLUM: Skip intro speech
bc16fa16b7 ASYLUM: Game detection improvements
1f473eedfe ASYLUM: Fixed metaengine mistake
28cbd2b28e ASYLUM: cleanup some warnings
617955615d ASYLUM: implement PuzzlePipes::saveLoadWithSerializer()
27cbc13eee ASYLUM: add inventory debug commands
bf0a3ab7b5 ASYLUM: add a debug command to list all possible inventory items
2c18077472 ASYLUM: handle intersecting action areas the way the original does (this reverts the workaround introduced in 1e933a1)
66e46adb21 ASYLUM: initialize puzzles when the 'scene' debug command is used
540a786eb4 ASYLUM: fix wrong condition in Actor::process()
a4882e97ca ASYLUM: fix a few bugs in pathfinding
305b370e5c ASYLUM: fix JumpIfActorCoordinates
a600d38ec1 ASYLUM: fix an assertion failure in Console::cmdShowScript()
f90b57ef85 ASYLUM: set the current cd number. This unbreaks chapter 4
e287e10fcf ASYLUM: fix chapter 5 crash
de51014306 ASYLUM: fix sound resource ids
988c66f01d ASYLUM: various fixes to the Board puzzles. Chapter 5 is completable now
e8fb7048dc ASYLUM: fix a crash caused by Screen::bltMasked()
c6087b8755 ASYLUM: fix a few bugs in the Morgue Door puzzle
f1da4bf798 ASYLUM: fix chapter 13 loading
361a99035c ASYLUM: unbreak chapter 8
b6ca135125 ASYLUM: rename some ScriptQueueEntry and ScriptQueue fields
69599ccdc6 ASYLUM: fix kOpcode(Set|Clear)CurrentItemOptions. From xesf@
bba8b4f839 ASYLUM: add a command to show encounter commands
219dbbbee5 ASYLUM: fix reverse animation playback
6876b50e4f ASYLUM: add scene motion logging
761d99e299 ASYLUM: fix index out of range
4df214d040 ASYLUM: implement SharedData::(set|get)Chapter2Data()
f89dd2baea ASYLUM: add a command to terminate a script
46c7750585 ASYLUM: unblock chapter 11
26f33b822b ASYLUM: fix ScriptManager::enableObject()
bce91352eb ASYLUM: fix PlaySoundUpdateObject opcode
ea894a619f ASYLUM: (Writings puzzle) implement text masking
a29d42231b ASYLUM: fix a few bugs related to scene motion
df473f0927 ASYLUM: check if the denominator is not zero
ff03d8fe89 ASYLUM: restore palette after finishing playing a video
52b02ee180 ASYLUM: fix a few bugs in chapter 2's hard-coded logic
0a594dad99 ASYLUM: fix processing order. This makes chapter 6 playable
ab69b65e6a ASYLUM: fix kOpcodeSetCounterFromActorReactions
c1a974d415 ASYLUM: small fixes to Actor::update()
2c2c67889d ASYLUM: add commands to get/set actor's status
cbbe4a05a4 ASYLUM: fix a bug in Scene::hitTestPixel()
e4af6a5045 ASYLUM: fix Actor::hasMoreReactions()
bf523e9918 ASYLUM: set a game flag when the Hive Control puzzle is solved
471ac0abfd ASYLUM: fix a few bugs in Object::update()
cbd1dc6c07 ASYLUM: use correct flag
bbd42feed2 ASYLUM: fix HasMoreReaction opcode
b0839e9bac ASYLUM: fix crash on exit
7214a190b0 ASYLUM: fixes to the Encounter system. Partly based on xesf's diff
733f109acc ASYLUM: return true if the test point is on the border of the polygon
4fb8b25682 ASYLUM: add a separate debug channel for script commands
b725db3de0 ASYLUM: identify more ActorStatus values
27f69f5a32 ASYLUM: fix kActorStatusWalking2 updating
f60246580b ASYLUM: fix Actor::isOnScreen()
54fe4387c5 ASYLUM: corrections to Scare Crow behavior
7dd49418c9 ASYLUM: fix a bug in Screen::graphicsSelectionSort()
459de7f44e ASYLUM: remove cache entry for shared sound when cd number is changed
ee37960ac4 ASYLUM: make actors interactable
413960ac6b ASYLUM: strict weak ordering is '<'
5649a0e257 ASYLUM: fix 'zoom' out of bounds
a3c7fc6e10 ASYLUM: skip non-existent objects
4a1d644b84 ASYLUM: fixes to Special::checkFlags()
ffb8df69d7 ASYLUM: implement wheels update
982bd7c359 ASYLUM: set a game flag when Hive Machine puzzle is solved
cc41cfb459 ASYLUM: original loops through the objects in reverse
fe40af0f44 ASYLUM: check if object exists
840f84bc84 ASYLUM: fix right bound of cursor.x
f23be0119e ASYLUM: fix saving
f94c11658a ASYLUM: fix background drawing in some of the puzzles
c3a3d999b5 ASYLUM: implement Special::chapter12()
56df11e356 ASYLUM: implement Special::chapter13()
bc3ebf36db ASYLUM: implement Special::chapter11()
74f1691ca1 ASYLUM: fix inventory ring drawing
c5547820fe ASYLUM: fixes to chapter 11's hard-coded logic
8eb94fc95e ASYLUM: restart chapter 11 properly
b754af14d6 ASYLUM: fix tentacle's status update
2d5d820c93 ASYLUM: add a missing else
530b4d51f6 ASYLUM: fix music changing
b2a9192793 ASYLUM: make AsylumEngine::getRandom() generate a number from [0; max) to match the original
7654475f3d ASYLUM: finish implementation of Object::playSounds()
b96cc26bd0 ASYLUM: add Special::chance()
e6f2916eea ASYLUM: access chapter 2 data using a single array
e11f8232cb ASYLUM: fix a few bugs in reflection positioning
8d1c397c48 ASYLUM: fix object 30's frameIndex ouf of range
efcae39518 ASYLUM: fixes to Actor::canInteract()
7ac489e077 ASYLUM: fix music playback in chapter 4
9d14df2602 ASYLUM: fix dstPitch
380950a300 ASYLUM: show all actors at scene enter
a6140c4944 ASYLUM: minor fixes (mostly formatting)
ff5a232343 ASYLUM: fix out of mixer slots in chapter 8
f1c0563024 ASYLUM: prevent actors from getting stuck when standing close to each other
94088dc756 ASYLUM: fix music won't play after moving to the next chapter
1379ce64ad ASYLUM: fix multiple inventory voices playing at the same time
d15af0f4b0 ASYLUM: fix segfault in PuzzleHiveControl::hitTest1()
5eed18bbc1 ASYLUM: fix showing of player's facial expressions
5b32634e45 ASYLUM: remove superfluous returns
410e8dc2a2 ASYLUM: remove .gitignore
72a3f0c365 ASYLUM: replace spaces in indentation with tabs
c2b1207e23 ASYLUM: always play intro
c8e9fe33a7 ASYLUM: mark the engine as highres
7c82553e8a ASYLUM: mark AsylumEngine::getSinCosValues() as const
263e20c004 ASYLUM: replace sprintf() with snprintf()
15bb6fd728 ASYLUM: replace 'Fallback to next case' comments with 'fallthrough'
ce59904eff ASYLUM: rework monster status update
b905953e5f ASYLUM: make FrameSoundItem::frameIndex unsigned
7c53e7560d ASYLUM: add const qualifier to silence a warning
06ebca09c3 ASYLUM: fix signed/unsigned comparison warnings
c6ab0e8503 ASYLUM: remove getDebugger() declaration
48e164b2d7 ASYLUM: clean up includes
ac43968c47 ASYLUM: formatting
93f08cc43d ASYLUM: fixes to the detection tables
b4a0418525 ASYLUM: Fix Uninitialized Variable Accesses Identified by Valgrind
c78293e4ce ASYLUM: simplify computation of inventory ring points
c524688f77 ASYLUM: simplify inventory voice system
408a85436a ASYLUM: (Hive Machine puzzle) get rid of the polygons previously used for hit testing
bf7755aa29 ASYLUM: fix integer overflow in Screen::graphicsSelectionSort()
139d15347f ASYLUM: remove an unused puzzle (Puzzle 11)
ec5b6935f8 ASYLUM: change return type of PuzzleBoard::updateScreen() to void
77a35a5c75 ASYLUM: get rid of global constructors
cf0049c23b ASYLUM: (Pipes puzzle) use the engine-level random source
aac8cee532 ASYLUM: optimizations to the board puzzles
0d71da53a6 ASYLUM: remove a useless ifdef
179627fab4 ASYLUM: add some missing updateScreen() calls
cf550f5ce2 ASYLUM: convert AsylumEngine::_gameFlags to uint32
ca1d780730 ASYLUM: clean up metaengine.cpp
c81c046450 ASYLUM: clean up destructors
a2d2495588 ASYLUM: add Keymapper support
b7130bab21 ASYLUM: fix savegame overwriting
ba2ccee701 ASYLUM: fix Quick Load/Quick Save
Commit: ef34899c44d3173dc228fb4ae536378b4ba0807c
https://github.com/scummvm/scummvm/commit/ef34899c44d3173dc228fb4ae536378b4ba0807c
Author: Filippos Karapetis (md5 at scummvm.org)
Date: 2021-05-17T15:35:24+02:00
Commit Message:
ASYLUM: - Now reading subtitle information from vids.cap
- Fixed video the font and font colors of video subtitles
- Fixed video the positioning of video subtitles
- Fixed positioning of multi-line subtitles
- The only thing left to do is to figure out where the index of the first subtitle is, per movie (right now the index of the first subtitle for movie 1 is hardcoded)
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@172 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/video.cpp
diff --git a/engines/asylum/video.cpp b/engines/asylum/video.cpp
index 275b440851..73d83af689 100644
--- a/engines/asylum/video.cpp
+++ b/engines/asylum/video.cpp
@@ -31,8 +31,7 @@ VideoPlayer::VideoPlayer(Graphics::VideoDecoder *decoder) :
Graphics::VideoPlayer(decoder) {
_text = new VideoText();
ResourcePack *resPack = new ResourcePack(1);
- _text->loadFont(resPack, 16); // 0x80010010, yellow font
- // TODO: font color
+ _text->loadFont(resPack, 57); // video font
delete resPack;
}
@@ -41,24 +40,49 @@ VideoPlayer::~VideoPlayer() {
}
bool VideoPlayer::playVideoWithSubtitles(Common::List<Common::Event> &stopEvents, int videoNumber) {
- // FIXME: this is a hack, only for video 1, with information taken from
- // the vids.cap file. The format of the vids.cap file is as follows:
- // [MOVxxx]
- // CAPTION = frameStart frameEnd subtitleIndex
- // TODO: We need to figure out where the index of the first subtitle is
- // loaded, as the subtitle indices are relative to the video being played,
- // and not to the actual subtitle indices inside res.000.
- // For now, we just hardcode the values from vids.cap and res.000
-
- if (videoNumber == 1) {
- VideoSubtitle newSubtitle;
- newSubtitle.frameStart = 287; // hardcoded from vids.cap
- newSubtitle.frameEnd = 453; // hardcoded from vids.cap
- newSubtitle.textRes = 1088; // hardcoded from vids.cap
-
- _subtitles.push_back(newSubtitle);
+ // Read vids.cap
+ char movieToken[10];
+ sprintf(movieToken, "[MOV%03d]", videoNumber);
+
+ Common::File subsFile;
+ subsFile.open("vids.cap");
+ char *buffer = new char[subsFile.size()];
+ subsFile.read(buffer, subsFile.size());
+ subsFile.close();
+
+ char *start = strstr(buffer, movieToken);
+ char *line = 0;
+ int textResourceStart = 1088; // HACK: this only works for video 1
+ assert(videoNumber == 1); // Remove this once the hack above is removed
+
+ if (start) {
+ start += 20; // skip token, newline and "CAPTION = "
+
+ int count = strcspn(start, "\r\n");
+ line = new char[count + 1];
+
+ strncpy(line, start, count);
+ line[count] = 0;
+
+ char *tok = strtok(line, " ");
+
+ while (tok) {
+ VideoSubtitle newSubtitle;
+ newSubtitle.frameStart = atoi(tok);
+ tok = strtok(NULL, " ");
+ newSubtitle.frameEnd = atoi(tok);
+ tok = strtok(NULL, " ");
+ newSubtitle.textRes = atoi(tok) + textResourceStart;
+ tok = strtok(NULL, " ");
+
+ _subtitles.push_back(newSubtitle);
+ }
+
+ delete line;
}
+ delete buffer;
+
return playVideo(stopEvents);
}
@@ -66,7 +90,7 @@ void VideoPlayer::performPostProcessing(byte *screen) {
int curFrame = _decoder->getCurFrame();
// Reset subtitle area, by filling it with zeroes
- memset(screen + 640 * 400, 0, 640 * 80);
+ memset(screen + 640 * 420, 0, 640 * 60);
for (uint32 i = 0; i < _subtitles.size(); i++) {
VideoSubtitle curSubtitle = _subtitles[i];
@@ -138,7 +162,7 @@ void VideoText::loadFont(ResourcePack *resPack, uint32 resId) {
void VideoText::drawResTextCentered(byte *screenBuffer, uint32 resId) {
ResourceEntry *textRes = _textPack->getResource(resId);
- drawTextCentered(screenBuffer, 0, 400, 640, (char *)textRes->data);
+ drawTextCentered(screenBuffer, 0, 420, 640, (char *)textRes->data);
}
void VideoText::setTextPos(uint32 x, uint32 y) {
@@ -147,14 +171,35 @@ void VideoText::setTextPos(uint32 x, uint32 y) {
}
void VideoText::drawTextCentered(byte *screenBuffer, uint32 x, uint32 y, uint32 width, char *text) {
- // HACK: make sure that the text fits on screen
- char textHack[80];
- strncpy(textHack, text, 80);
- textHack[79] = 0;
+ const int maxLength = 108; // max chars per line
+ int curY = y;
+ char *text1 = text;
+ char *text2 = 0;
+ int len = strlen(text);
+ int textWidth = 0;
+
+ if (len > maxLength) {
+ text1 = new char[maxLength];
+ strncpy(text1, text, maxLength);
+ text1[maxLength - 1] = 0; // terminate
+
+ text2 = new char[maxLength];
+ strcpy(text2, text + maxLength);
+ }
- int textWidth = getTextWidth(textHack);
+ textWidth = getTextWidth(text1);
setTextPos(x + (width - textWidth) / 2, y);
- drawText(screenBuffer, textHack);
+ drawText(screenBuffer, text1);
+
+ if (len > maxLength) {
+ textWidth = getTextWidth(text2);
+ setTextPos(x + (width - textWidth) / 2, y + 30);
+ drawText(screenBuffer, text2);
+
+ // Clean up
+ delete[] text1;
+ delete[] text2;
+ }
}
uint32 VideoText::getTextWidth(char *text) {
Commit: 232391f005081b9549495fa4aa51ee829f2e2b59
https://github.com/scummvm/scummvm/commit/232391f005081b9549495fa4aa51ee829f2e2b59
Author: Filippos Karapetis (md5 at scummvm.org)
Date: 2021-05-17T15:35:24+02:00
Commit Message:
ASYLUM: Updated the MSVC project file
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@173 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/asylum.vcproj
diff --git a/engines/asylum/asylum.vcproj b/engines/asylum/asylum.vcproj
index ea56ac3d8e..47a8403962 100644
--- a/engines/asylum/asylum.vcproj
+++ b/engines/asylum/asylum.vcproj
@@ -181,6 +181,14 @@
RelativePath="..\..\engines\asylum\detection.cpp"
>
</File>
+ <File
+ RelativePath="..\..\engines\asylum\encounters.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\engines\asylum\encounters.h"
+ >
+ </File>
<File
RelativePath="..\..\engines\asylum\graphics.cpp"
>
Commit: ffd1d025511d3d1c3e90fb4f73dba967d8fcb439
https://github.com/scummvm/scummvm/commit/ffd1d025511d3d1c3e90fb4f73dba967d8fcb439
Author: Filippos Karapetis (md5 at scummvm.org)
Date: 2021-05-17T15:35:24+02:00
Commit Message:
ASYLUM: Silenced a signed/unsigned mismatch warning
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@174 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/actor.cpp
diff --git a/engines/asylum/actor.cpp b/engines/asylum/actor.cpp
index 5f4d605f97..7697b92b3c 100644
--- a/engines/asylum/actor.cpp
+++ b/engines/asylum/actor.cpp
@@ -62,7 +62,7 @@ void MainActor::setAction(int action) {
// Flip horizontally if necessary
if (_currentAction > 100) {
- for (int i = 0; i < _graphic->getFrameCount(); i++) {
+ for (uint32 i = 0; i < _graphic->getFrameCount(); i++) {
GraphicFrame *frame = _graphic->getFrame(i);
byte *buffer = (byte *)frame->surface.pixels;
Commit: 261b47d7180c2a1e197d0c51e0513a123454d5fa
https://github.com/scummvm/scummvm/commit/261b47d7180c2a1e197d0c51e0513a123454d5fa
Author: Filippos Karapetis (md5 at scummvm.org)
Date: 2021-05-17T15:35:24+02:00
Commit Message:
ASYLUM: Added a parameter to playVideo(), used to toggle subtitles
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@175 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/asylum.cpp
engines/asylum/video.cpp
engines/asylum/video.h
diff --git a/engines/asylum/asylum.cpp b/engines/asylum/asylum.cpp
index b3982cdf8e..c3bbc8d331 100644
--- a/engines/asylum/asylum.cpp
+++ b/engines/asylum/asylum.cpp
@@ -83,10 +83,10 @@ Common::Error AsylumEngine::go() {
// Play intro movie
// Disabled for quick testing
- //_video->playVideo(0);
+ //_video->playVideo(0, kSubtitlesOff); // Note: this video has no subtitles
// Play first chapter movie (for testing)
- //_video->playVideo(1);
+ //_video->playVideo(1, kSubtitlesOn);
// Set up the game's main scene
_scene = new Scene(_screen, _sound, 5);
diff --git a/engines/asylum/video.cpp b/engines/asylum/video.cpp
index 73d83af689..b0b05a8963 100644
--- a/engines/asylum/video.cpp
+++ b/engines/asylum/video.cpp
@@ -119,15 +119,19 @@ Video::~Video() {
delete _smkDecoder;
}
-bool Video::playVideo(int number) {
+bool Video::playVideo(int number, VideoSubtitles subtitles) {
char filename[20];
sprintf(filename, "mov%03d.smk", number);
bool result = _smkDecoder->loadFile(filename);
g_system->showMouse(false);
- if (result)
- _player->playVideoWithSubtitles(_stopEvents, number);
+ if (result) {
+ if (subtitles == kSubtitlesOff)
+ _player->playVideo(_stopEvents);
+ else
+ _player->playVideoWithSubtitles(_stopEvents, number);
+ }
_smkDecoder->closeFile();
g_system->showMouse(true);
diff --git a/engines/asylum/video.h b/engines/asylum/video.h
index 135c162f5a..2be8b404a2 100644
--- a/engines/asylum/video.h
+++ b/engines/asylum/video.h
@@ -46,6 +46,11 @@ struct VideoSubtitle {
int textRes;
};
+enum VideoSubtitles {
+ kSubtitlesOff = 0,
+ kSubtitlesOn = 1
+};
+
class VideoText;
class VideoPlayer : public Graphics::VideoPlayer {
@@ -67,7 +72,7 @@ public:
Video(Audio::Mixer *mixer);
virtual ~Video();
- bool playVideo(int number);
+ bool playVideo(int number, VideoSubtitles subtitles);
private:
Common::List<Common::Event> _stopEvents;
Commit: 8d75c0e780e2285401c43dd3e3ce11e0df19e5e5
https://github.com/scummvm/scummvm/commit/8d75c0e780e2285401c43dd3e3ce11e0df19e5e5
Author: Filippos Karapetis (md5 at scummvm.org)
Date: 2021-05-17T15:35:24+02:00
Commit Message:
ASYLUM: Delete the scene object in the engine's destructor
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@176 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/asylum.cpp
diff --git a/engines/asylum/asylum.cpp b/engines/asylum/asylum.cpp
index c3bbc8d331..5d8b80ae31 100644
--- a/engines/asylum/asylum.cpp
+++ b/engines/asylum/asylum.cpp
@@ -45,6 +45,7 @@ AsylumEngine::AsylumEngine(OSystem *system, Common::Language language)
AsylumEngine::~AsylumEngine() {
//Common::clearAllDebugChannels();
+ delete _scene;
delete _mainMenu;
delete _video;
delete _sound;
Commit: 089d0c6b8f94e3253c75bb14a05efe68712b770b
https://github.com/scummvm/scummvm/commit/089d0c6b8f94e3253c75bb14a05efe68712b770b
Author: Alexandre Fontoura (alexandrefontoura at gmail.com)
Date: 2021-05-17T15:35:24+02:00
Commit Message:
ASYLUM: Improve scenres ActorDefinitions structure and reading.
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@177 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/scene.cpp
engines/asylum/sceneres.cpp
engines/asylum/sceneres.h
diff --git a/engines/asylum/scene.cpp b/engines/asylum/scene.cpp
index 3b466137f7..84536d5783 100644
--- a/engines/asylum/scene.cpp
+++ b/engines/asylum/scene.cpp
@@ -187,15 +187,15 @@ void Scene::copyToBackBufferClipped(GraphicFrame *frame, int x, int y) {
void Scene::updateActor(Screen *screen, ResourcePack *res, uint8 actorIndex) {
ActorDefinitions actor = _sceneResource->getWorldStats()->_actorsDef[actorIndex];
- GraphicResource *gra = new GraphicResource(res, actor.graphicResId);
+ GraphicResource *gra = new GraphicResource(res, actor.resId);
GraphicFrame *fra = gra->getFrame(actor.tickCount);
copyToBackBufferClipped(fra, actor.x, actor.y);
- if (actor.tickCount < gra->getFrameCount() - 1) {
+ if (actor.tickCount < actor.frameCount - 1) {
actor.tickCount++;
}else{
- actor.tickCount = 0;
+ actor.tickCount = actor.frameIdx;
}
_sceneResource->getWorldStats()->_actorsDef[actorIndex] = actor;
diff --git a/engines/asylum/sceneres.cpp b/engines/asylum/sceneres.cpp
index 3f8a0e1198..6478011a29 100644
--- a/engines/asylum/sceneres.cpp
+++ b/engines/asylum/sceneres.cpp
@@ -106,22 +106,10 @@ void SceneResource::loadWorldStats(Common::SeekableReadStream *stream) {
stream->seek(0x6FA); // where actors definitions start
- // FIXME Figure out all the actor definitions
for (uint32 a=0; a < _worldStats->_numActors; a++) {
ActorDefinitions actorDef;
memset(&actorDef, 0, sizeof(ActorDefinitions));
-
- actorDef.tickCount = 0;
- actorDef.id = stream->readUint32LE();
- actorDef.graphicResId = stream->readUint32LE();
- actorDef.x = stream->readUint32LE();
- actorDef.y = stream->readUint32LE();
- stream->skip(0x30);
- stream->read(actorDef.name, 52);
- stream->skip(0x158);
- actorDef.soundResId = stream->readUint32LE();
- stream->skip(0x4D8);
-
+ stream->read(&actorDef, sizeof(ActorDefinitions));
_worldStats->_actorsDef.push_back(actorDef);
}
diff --git a/engines/asylum/sceneres.h b/engines/asylum/sceneres.h
index 4c63a1726a..a4d69d8fae 100644
--- a/engines/asylum/sceneres.h
+++ b/engines/asylum/sceneres.h
@@ -44,6 +44,18 @@ class WorldStats;
class GamePolygons;
class ActionList;
+// ScummVM common Point uses int16 and we need int32
+typedef struct Point {
+ int32 x;
+ int32 y;
+} Point;
+
+// ScummVM common Rect uses int16 and we need int32
+typedef struct Rect {
+ int32 top, left;
+ int32 bottom, right;
+} Rect;
+
class SceneResource {
public:
SceneResource();
@@ -69,15 +81,60 @@ private:
}; // end of class Scene
-// FIXME add unknown fields
+typedef struct SoundItem {
+ uint32 resId;
+ uint32 field_4;
+ uint32 field_8;
+ uint32 field_C;
+} SoundItem;
+
+typedef struct FrameSoundItem {
+ uint32 resId;
+ uint32 frameIdx;
+ uint32 index;
+ uint32 field_C;
+ uint32 field_10;
+ uint32 field_14;
+} FrameSoundItem;
+
+// FIXME figure out unknown fields
typedef struct ActorDefinitions {
uint32 id;
- uint32 graphicResId;
+ uint32 resId;
uint32 x;
uint32 y;
- uint8 name[52];
+ Rect boundingBox;
+ uint32 field_20;
+ uint32 frameIdx;
+ uint32 frameCount;
+ uint32 field_2C;
+ uint32 field_30;
+ uint32 field_34;
+ uint32 flags;
+ uint32 field_3C;
+ uint8 name[52]; // field_40 till field_70;
+ uint32 field_74;
+ uint32 field_78;
+ uint32 field_7C;
+ uint32 field_80;
+ uint32 polyIdx;
+ uint32 flags2;
+ uint32 gameFlags[10];
+ uint32 field_B4;
+ uint32 tickCount;
+ uint32 tickCount2;
+ uint32 field_C0;
+ uint32 field_C4;
+ uint32 actionListIdx;
+ SoundItem soundItems[16];
+ FrameSoundItem frameSoundItems[50];
+ uint32 field_67C;
+ uint32 soundX;
+ uint32 soundY;
+ uint32 field_688;
+ uint32 field_68C[5];
uint32 soundResId;
- uint16 tickCount; // TODO this is for testing, not from direct decompilation
+ uint32 field_6A4;
} ActorDefinitions;
@@ -146,9 +203,9 @@ public:
typedef struct PolyDefinitions{
- uint32 numPoints;
- Common::Point points[Polygons_MAXSIZE];
- Common::Rect boundingRect;
+ uint32 numPoints;
+ Point points[Polygons_MAXSIZE];
+ Rect boundingRect;
} PolyDefinitions;
class GamePolygons {
Commit: 04fe773cd2b64cb57697d4c7152cf3ba0a61231b
https://github.com/scummvm/scummvm/commit/04fe773cd2b64cb57697d4c7152cf3ba0a61231b
Author: Alexandre Fontoura (alexandrefontoura at gmail.com)
Date: 2021-05-17T15:35:25+02:00
Commit Message:
ASYLUM: Actor bounding box test.
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@178 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/scene.cpp
diff --git a/engines/asylum/scene.cpp b/engines/asylum/scene.cpp
index 84536d5783..1f07066175 100644
--- a/engines/asylum/scene.cpp
+++ b/engines/asylum/scene.cpp
@@ -190,6 +190,13 @@ void Scene::updateActor(Screen *screen, ResourcePack *res, uint8 actorIndex) {
GraphicResource *gra = new GraphicResource(res, actor.resId);
GraphicFrame *fra = gra->getFrame(actor.tickCount);
+ // DEBUG bounding box
+ // FIXME this should be a generic method which draws for an entire graphicResource and not for single graphicFrames
+ fra->surface.drawLine(actor.boundingBox.top, actor.boundingBox.left, actor.boundingBox.top, actor.boundingBox.right, 0xFFFFFF);
+ fra->surface.drawLine(actor.boundingBox.top, actor.boundingBox.right-1, actor.boundingBox.bottom, actor.boundingBox.right-1, 0xFFFFFF);
+ fra->surface.drawLine(actor.boundingBox.bottom-1, actor.boundingBox.left, actor.boundingBox.bottom-1, actor.boundingBox.right, 0xFFFFFF);
+ fra->surface.drawLine(actor.boundingBox.top, actor.boundingBox.left, actor.boundingBox.bottom, actor.boundingBox.left, 0xFFFFFF);
+
copyToBackBufferClipped(fra, actor.x, actor.y);
if (actor.tickCount < actor.frameCount - 1) {
@@ -197,7 +204,7 @@ void Scene::updateActor(Screen *screen, ResourcePack *res, uint8 actorIndex) {
}else{
actor.tickCount = actor.frameIdx;
}
-
+
_sceneResource->getWorldStats()->_actorsDef[actorIndex] = actor;
delete gra;
Commit: 8a7e3bfada014b68fb9a5ff70afd28dfd69f4c94
https://github.com/scummvm/scummvm/commit/8a7e3bfada014b68fb9a5ff70afd28dfd69f4c94
Author: Filippos Karapetis (md5 at scummvm.org)
Date: 2021-05-17T15:35:25+02:00
Commit Message:
ASYLUM: Fixed displaying of transparent actors, and added some more test animations
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@179 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/scene.cpp
engines/asylum/scene.h
engines/asylum/screen.cpp
engines/asylum/screen.h
diff --git a/engines/asylum/scene.cpp b/engines/asylum/scene.cpp
index 1f07066175..9902014e62 100644
--- a/engines/asylum/scene.cpp
+++ b/engines/asylum/scene.cpp
@@ -144,14 +144,23 @@ void Scene::update() {
scrollScreen = true;
}
- if (scrollScreen)
- _screen->copyToBackBuffer(((byte *)bg->surface.pixels) + _startY * bg->surface.w + _startX, bg->surface.w, 0, 0, 640, 480);
-
- updateActor(_screen, _resPack, 7); // the "crazy prisoner banging head" anim
-
+ // Copy the background to the back buffer before updating the scene animations
+ _screen->copyToBackBuffer(((byte *)bg->surface.pixels) + _startY * bg->surface.w + _startX, bg->surface.w, 0, 0, 640, 480);
+
+ updateActor(_screen, _resPack, 0); // the "statue with fireworks" animation
+ //updateActor(_screen, _resPack, 1); // inside the middle room
+ //updateActor(_screen, _resPack, 2); // the lit candles at the base of the statue
+ updateActor(_screen, _resPack, 3); // the rat animation (in front of the statue)
+ updateActor(_screen, _resPack, 4); // inside the bottom room
+ updateActor(_screen, _resPack, 6); // inside the top room (should be shown before the rat animation)
+ updateActor(_screen, _resPack, 5); // the rat animation (outside the second room)
+ updateActor(_screen, _resPack, 7); // the "crazy prisoner banging head" animation
+ //updateActor(_screen, _resPack, 8); // going up the ladder
+ //updateActor(_screen, _resPack, 9); // going down the ladder
// TODO
}
+#if 0
void Scene::copyToSceneBackground(GraphicFrame *frame, int x, int y) {
int h = frame->surface.h;
int w = frame->surface.w;
@@ -164,6 +173,7 @@ void Scene::copyToSceneBackground(GraphicFrame *frame, int x, int y) {
buffer += frame->surface.w;
}
}
+#endif
void Scene::copyToBackBufferClipped(GraphicFrame *frame, int x, int y) {
Common::Rect screenRect(_startX, _startY, _startX + 640, _startY + 480);
@@ -175,13 +185,14 @@ void Scene::copyToBackBufferClipped(GraphicFrame *frame, int x, int y) {
animRect.translate(-_startX, -_startY);
int startX = animRect.right == 640 ? 0 : frame->surface.w - animRect.width();
- _screen->copyToBackBuffer(((byte*)frame->surface.pixels) +
- (frame->surface.h - animRect.height()) * frame->surface.pitch + startX,
- frame->surface.pitch,
- animRect.left,
- animRect.top,
- animRect.width(),
- animRect.height());
+ _screen->copyToBackBufferWithTransparency(((byte*)frame->surface.pixels) +
+ (frame->surface.h - animRect.height()) *
+ frame->surface.pitch + startX,
+ frame->surface.pitch,
+ animRect.left,
+ animRect.top,
+ animRect.width(),
+ animRect.height());
}
}
diff --git a/engines/asylum/scene.h b/engines/asylum/scene.h
index a8bf97ef00..cceb0545e4 100644
--- a/engines/asylum/scene.h
+++ b/engines/asylum/scene.h
@@ -50,7 +50,9 @@ public:
void enterScene();
private:
+#if 0
void copyToSceneBackground(GraphicFrame *frame, int x, int y);
+#endif
void copyToBackBufferClipped(GraphicFrame *frame, int x, int y);
Screen *_screen;
diff --git a/engines/asylum/screen.cpp b/engines/asylum/screen.cpp
index ea3e4a6f2e..b2fdbac2c1 100644
--- a/engines/asylum/screen.cpp
+++ b/engines/asylum/screen.cpp
@@ -51,6 +51,20 @@ void Screen::copyToBackBuffer(byte *buffer, int pitch, int x, int y, int width,
}
}
+void Screen::copyToBackBufferWithTransparency(byte *buffer, int pitch, int x, int y, int width, int height) {
+ int h = height;
+ int w = width;
+ byte *dest = (byte *)_backBuffer.pixels;
+
+ for (int curY = 0; curY < height; curY++) {
+ for (int curX = 0; curX < width; curX++) {
+ if (buffer[curX + curY * width] != 0) {
+ dest[x + curX + (y + curY) * 640] = buffer[curX + curY * pitch];
+ }
+ }
+ }
+}
+
void Screen::copyRectToScreen(byte *buffer, int pitch, int x, int y, int width, int height) {
_sys->copyRectToScreen(buffer, pitch, x, y, width, height);
}
diff --git a/engines/asylum/screen.h b/engines/asylum/screen.h
index 285d8de15f..0d3bb58fe9 100644
--- a/engines/asylum/screen.h
+++ b/engines/asylum/screen.h
@@ -41,6 +41,7 @@ public:
~Screen();
void copyToBackBuffer(byte *buffer, int pitch, int x, int y, int width, int height);
+ void copyToBackBufferWithTransparency(byte *buffer, int pitch, int x, int y, int width, int height);
void copyBackBufferToScreen();
void copyRectToScreen(byte *buffer, int pitch, int x, int y, int width, int height);
void copyRectToScreenWithTransparency(byte *buffer, int pitch, int x, int y, int width, int height);
Commit: 30893ed56a5e24801d933f2a8385b699852345c4
https://github.com/scummvm/scummvm/commit/30893ed56a5e24801d933f2a8385b699852345c4
Author: Filippos Karapetis (md5 at scummvm.org)
Date: 2021-05-17T15:35:25+02:00
Commit Message:
ASYLUM: - Reverted back to Common::Point and Common::Rect
- The actor definitions are now read in an endian-safe way, and the game's polygons are converted to ScummVM's polygon format
- Disabled the bounding box test (it was a bit annoying :P )
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@180 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/scene.cpp
engines/asylum/sceneres.cpp
engines/asylum/sceneres.h
diff --git a/engines/asylum/scene.cpp b/engines/asylum/scene.cpp
index 9902014e62..cb64f9daa1 100644
--- a/engines/asylum/scene.cpp
+++ b/engines/asylum/scene.cpp
@@ -201,12 +201,14 @@ void Scene::updateActor(Screen *screen, ResourcePack *res, uint8 actorIndex) {
GraphicResource *gra = new GraphicResource(res, actor.resId);
GraphicFrame *fra = gra->getFrame(actor.tickCount);
+#if 0
// DEBUG bounding box
// FIXME this should be a generic method which draws for an entire graphicResource and not for single graphicFrames
fra->surface.drawLine(actor.boundingBox.top, actor.boundingBox.left, actor.boundingBox.top, actor.boundingBox.right, 0xFFFFFF);
fra->surface.drawLine(actor.boundingBox.top, actor.boundingBox.right-1, actor.boundingBox.bottom, actor.boundingBox.right-1, 0xFFFFFF);
fra->surface.drawLine(actor.boundingBox.bottom-1, actor.boundingBox.left, actor.boundingBox.bottom-1, actor.boundingBox.right, 0xFFFFFF);
fra->surface.drawLine(actor.boundingBox.top, actor.boundingBox.left, actor.boundingBox.bottom, actor.boundingBox.left, 0xFFFFFF);
+#endif
copyToBackBufferClipped(fra, actor.x, actor.y);
diff --git a/engines/asylum/sceneres.cpp b/engines/asylum/sceneres.cpp
index 6478011a29..238bdbeaa0 100644
--- a/engines/asylum/sceneres.cpp
+++ b/engines/asylum/sceneres.cpp
@@ -106,10 +106,66 @@ void SceneResource::loadWorldStats(Common::SeekableReadStream *stream) {
stream->seek(0x6FA); // where actors definitions start
- for (uint32 a=0; a < _worldStats->_numActors; a++) {
+ for (uint32 a = 0; a < _worldStats->_numActors; a++) {
ActorDefinitions actorDef;
- memset(&actorDef, 0, sizeof(ActorDefinitions));
- stream->read(&actorDef, sizeof(ActorDefinitions));
+ int i;
+
+ actorDef.id = stream->readUint32LE();
+ actorDef.resId = stream->readUint32LE();
+ actorDef.x = stream->readUint32LE();
+ actorDef.y = stream->readUint32LE();
+ actorDef.boundingBox.left = stream->readUint32LE() & 0xFFFF;
+ actorDef.boundingBox.top = stream->readUint32LE() & 0xFFFF;
+ actorDef.boundingBox.right = stream->readUint32LE() & 0xFFFF;
+ actorDef.boundingBox.bottom = stream->readUint32LE() & 0xFFFF;
+ actorDef.field_20 = stream->readUint32LE();
+ actorDef.frameIdx = stream->readUint32LE();
+ actorDef.frameCount = stream->readUint32LE();
+ actorDef.field_2C = stream->readUint32LE();
+ actorDef.field_30 = stream->readUint32LE();
+ actorDef.field_34 = stream->readUint32LE();
+ actorDef.flags = stream->readUint32LE();
+ actorDef.field_3C = stream->readUint32LE();
+ stream->read(actorDef.name, sizeof(actorDef.name));
+ actorDef.field_74 = stream->readUint32LE();
+ actorDef.field_78 = stream->readUint32LE();
+ actorDef.field_7C = stream->readUint32LE();
+ actorDef.field_80 = stream->readUint32LE();
+ actorDef.polyIdx = stream->readUint32LE();
+ actorDef.flags2 = stream->readUint32LE();
+ for (i = 0; i < 10; i++)
+ actorDef.gameFlags[i] = stream->readUint32LE();
+ actorDef.field_B4 = stream->readUint32LE();
+ actorDef.tickCount = stream->readUint32LE();
+ actorDef.tickCount2 = stream->readUint32LE();
+ actorDef.field_C0 = stream->readUint32LE();
+ actorDef.field_C4 = stream->readUint32LE();
+ actorDef.actionListIdx = stream->readUint32LE();
+ for (i = 0; i < 16; i++) {
+ actorDef.soundItems[i].resId = stream->readUint32LE();
+ actorDef.soundItems[i].field_4 = stream->readUint32LE();
+ actorDef.soundItems[i].field_8 = stream->readUint32LE();
+ actorDef.soundItems[i].field_C = stream->readUint32LE();
+
+ }
+ for (i = 0; i < 50; i++) {
+ actorDef.frameSoundItems[i].resId = stream->readUint32LE();
+ actorDef.frameSoundItems[i].frameIdx = stream->readUint32LE();
+ actorDef.frameSoundItems[i].index = stream->readUint32LE();
+ actorDef.frameSoundItems[i].field_C = stream->readUint32LE();
+ actorDef.frameSoundItems[i].field_10 = stream->readUint32LE();
+ actorDef.frameSoundItems[i].field_14 = stream->readUint32LE();
+ }
+ actorDef.field_67C = stream->readUint32LE();
+ actorDef.soundX = stream->readUint32LE();
+ actorDef.soundY = stream->readUint32LE();
+ actorDef.field_688 = stream->readUint32LE();
+ for (i = 0; i < 5; i++) {
+ actorDef.field_68C[i] = stream->readUint32LE();
+ }
+ actorDef.soundResId = stream->readUint32LE();
+ actorDef.field_6A4 = stream->readUint32LE();
+
_worldStats->_actorsDef.push_back(actorDef);
}
@@ -159,15 +215,18 @@ void SceneResource::loadGamePolygons(Common::SeekableReadStream *stream) {
_gamePolygons->_size = stream->readUint32LE();
_gamePolygons->_numEntries = stream->readUint32LE();
- for (uint32 g=0; g < _gamePolygons->_numEntries; g++) {
+ for (uint32 g = 0; g < _gamePolygons->_numEntries; g++) {
PolyDefinitions poly;
memset(&poly, 0, sizeof(PolyDefinitions));
poly.numPoints = stream->readUint32LE();
- stream->read(poly.points, sizeof(Common::Point) * Polygons_MAXSIZE);
- poly.boundingRect.top = stream->readUint32LE();
- poly.boundingRect.left = stream->readUint32LE();
- poly.boundingRect.bottom = stream->readUint32LE();
- poly.boundingRect.right = stream->readUint32LE();
+ for (int i = 0; i < Polygons_MAXSIZE; i++) {
+ poly.points[i].x = stream->readUint32LE() & 0xFFFF;
+ poly.points[i].y = stream->readUint32LE() & 0xFFFF;
+ }
+ poly.boundingRect.top = stream->readUint32LE() & 0xFFFF;
+ poly.boundingRect.left = stream->readUint32LE() & 0xFFFF;
+ poly.boundingRect.bottom = stream->readUint32LE() & 0xFFFF;
+ poly.boundingRect.right = stream->readUint32LE() & 0xFFFF;
_gamePolygons->_Polygons.push_back(poly);
}
diff --git a/engines/asylum/sceneres.h b/engines/asylum/sceneres.h
index a4d69d8fae..b93328fee0 100644
--- a/engines/asylum/sceneres.h
+++ b/engines/asylum/sceneres.h
@@ -44,6 +44,8 @@ class WorldStats;
class GamePolygons;
class ActionList;
+#if 0
+// TODO/FIXME: Are there REALLY any points which go beyond 32768???
// ScummVM common Point uses int16 and we need int32
typedef struct Point {
int32 x;
@@ -55,6 +57,7 @@ typedef struct Rect {
int32 top, left;
int32 bottom, right;
} Rect;
+#endif
class SceneResource {
public:
@@ -103,7 +106,7 @@ typedef struct ActorDefinitions {
uint32 resId;
uint32 x;
uint32 y;
- Rect boundingBox;
+ Common::Rect boundingBox;
uint32 field_20;
uint32 frameIdx;
uint32 frameCount;
@@ -204,8 +207,8 @@ public:
typedef struct PolyDefinitions{
uint32 numPoints;
- Point points[Polygons_MAXSIZE];
- Rect boundingRect;
+ Common::Point points[Polygons_MAXSIZE];
+ Common::Rect boundingRect;
} PolyDefinitions;
class GamePolygons {
Commit: 27a8f4b8f06bab08ec27bcc33a5c7556d357f6d3
https://github.com/scummvm/scummvm/commit/27a8f4b8f06bab08ec27bcc33a5c7556d357f6d3
Author: Filippos Karapetis (md5 at scummvm.org)
Date: 2021-05-17T15:35:25+02:00
Commit Message:
ASYLUM: Now reading common scene resources in an endian-safe way
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@181 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/sceneres.cpp
diff --git a/engines/asylum/sceneres.cpp b/engines/asylum/sceneres.cpp
index 238bdbeaa0..5034d28bd8 100644
--- a/engines/asylum/sceneres.cpp
+++ b/engines/asylum/sceneres.cpp
@@ -80,7 +80,31 @@ void SceneResource::loadWorldStats(Common::SeekableReadStream *stream) {
stream->skip(24); // unused data
// read common graphic resources
- stream->read(&_worldStats->_commonRes,sizeof(CommonResources));
+ _worldStats->_commonRes.backgroundImage = stream->readUint32LE();
+ _worldStats->_commonRes.curScrollUp = stream->readUint32LE();
+ _worldStats->_commonRes.curScrollUpLeft = stream->readUint32LE();
+ _worldStats->_commonRes.curScrollLeft = stream->readUint32LE();
+ _worldStats->_commonRes.curScrollDownLeft = stream->readUint32LE();
+ _worldStats->_commonRes.curScrollDown = stream->readUint32LE();
+ _worldStats->_commonRes.curScrollDownRight = stream->readUint32LE();
+ _worldStats->_commonRes.curScrollRight = stream->readUint32LE();
+ _worldStats->_commonRes.curScrollUpRight = stream->readUint32LE();
+ _worldStats->_commonRes.curHand = stream->readUint32LE();
+ _worldStats->_commonRes.curMagnifyingGlass = stream->readUint32LE();
+ _worldStats->_commonRes.curTalkNCP = stream->readUint32LE();
+ _worldStats->_commonRes.curGrabPointer = stream->readUint32LE();
+ _worldStats->_commonRes.curTalkNCP2 = stream->readUint32LE();
+ _worldStats->_commonRes.unknown1 = stream->readUint32LE();
+ _worldStats->_commonRes.unknown2 = stream->readUint32LE();
+ _worldStats->_commonRes.unknown3 = stream->readUint32LE();
+ _worldStats->_commonRes.palette = stream->readUint32LE();
+ _worldStats->_commonRes.cellShadeMask1 = stream->readUint32LE();
+ _worldStats->_commonRes.cellShadeMask2 = stream->readUint32LE();
+ _worldStats->_commonRes.cellShadeMask3 = stream->readUint32LE();
+ _worldStats->_commonRes.unused = stream->readUint32LE();
+ _worldStats->_commonRes.smallCurUp = stream->readUint32LE();
+ _worldStats->_commonRes.smallCurDown = stream->readUint32LE();
+ _worldStats->_commonRes.unknown4 = stream->readUint32LE();
_worldStats->_width = stream->readUint32LE();
_worldStats->_height = stream->readUint32LE();
Commit: 1d4f3b236a2bb42f291d3ef21b1df79c6a40bf80
https://github.com/scummvm/scummvm/commit/1d4f3b236a2bb42f291d3ef21b1df79c6a40bf80
Author: Filippos Karapetis (md5 at scummvm.org)
Date: 2021-05-17T15:35:25+02:00
Commit Message:
ASYLUM: More work on video subtitles (tested videos 0-6)
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@182 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/asylum.cpp
engines/asylum/video.cpp
engines/asylum/video.h
diff --git a/engines/asylum/asylum.cpp b/engines/asylum/asylum.cpp
index 5d8b80ae31..1c97f0cffa 100644
--- a/engines/asylum/asylum.cpp
+++ b/engines/asylum/asylum.cpp
@@ -84,7 +84,7 @@ Common::Error AsylumEngine::go() {
// Play intro movie
// Disabled for quick testing
- //_video->playVideo(0, kSubtitlesOff); // Note: this video has no subtitles
+ //_video->playVideo(0, kSubtitlesOn); // Note: this video has no subtitles
// Play first chapter movie (for testing)
//_video->playVideo(1, kSubtitlesOn);
diff --git a/engines/asylum/video.cpp b/engines/asylum/video.cpp
index b0b05a8963..fca692f5c6 100644
--- a/engines/asylum/video.cpp
+++ b/engines/asylum/video.cpp
@@ -52,8 +52,13 @@ bool VideoPlayer::playVideoWithSubtitles(Common::List<Common::Event> &stopEvents
char *start = strstr(buffer, movieToken);
char *line = 0;
- int textResourceStart = 1088; // HACK: this only works for video 1
- assert(videoNumber == 1); // Remove this once the hack above is removed
+ int textResourceStart = 0;
+
+ // HACK: we hardcode all the text resources here
+ // -1 means that the video has no subtitles
+ int textRes[7] = { -1, 1088, 1279, 1122, 1286, 1132, 1133 };
+ assert(videoNumber <= 6); // only done videos 0-6 for now
+ textResourceStart = textRes[videoNumber];
if (start) {
start += 20; // skip token, newline and "CAPTION = "
@@ -166,7 +171,7 @@ void VideoText::loadFont(ResourcePack *resPack, uint32 resId) {
void VideoText::drawResTextCentered(byte *screenBuffer, uint32 resId) {
ResourceEntry *textRes = _textPack->getResource(resId);
- drawTextCentered(screenBuffer, 0, 420, 640, (char *)textRes->data);
+ drawTextCentered(screenBuffer, 0, 420, 640, (const char *)textRes->data);
}
void VideoText::setTextPos(uint32 x, uint32 y) {
@@ -174,56 +179,55 @@ void VideoText::setTextPos(uint32 x, uint32 y) {
_posY = y;
}
-void VideoText::drawTextCentered(byte *screenBuffer, uint32 x, uint32 y, uint32 width, char *text) {
- const int maxLength = 108; // max chars per line
- int curY = y;
- char *text1 = text;
- char *text2 = 0;
- int len = strlen(text);
- int textWidth = 0;
-
- if (len > maxLength) {
- text1 = new char[maxLength];
- strncpy(text1, text, maxLength);
- text1[maxLength - 1] = 0; // terminate
-
- text2 = new char[maxLength];
- strcpy(text2, text + maxLength);
+void VideoText::drawTextCentered(byte *screenBuffer, uint32 x, uint32 y, uint32 width, const char *text) {
+ Common::String textLine[4];
+ Common::String tmpLine;
+ int curLine = 0;
+ char *buf = strdup(text); // for strtok
+ char *tok = strtok(buf, " ");
+
+ // Videos can have up to 4 lines of text
+ // TODO: proper y locations. This has only been tested with up to 2 lines (videos 0-6)
+ while (tok) {
+ tmpLine += tok;
+ tmpLine += " ";
+ if (getTextWidth(tmpLine.c_str()) > 640) {
+ tmpLine = tok;
+ curLine++;
+ }
+ textLine[curLine] += tok;
+ textLine[curLine] += " ";
+ tok = strtok(NULL, " ");
}
- textWidth = getTextWidth(text1);
- setTextPos(x + (width - textWidth) / 2, y);
- drawText(screenBuffer, text1);
-
- if (len > maxLength) {
- textWidth = getTextWidth(text2);
- setTextPos(x + (width - textWidth) / 2, y + 30);
- drawText(screenBuffer, text2);
-
- // Clean up
- delete[] text1;
- delete[] text2;
+ for (int i = 0; i < curLine + 1; i++) {
+ int textWidth = getTextWidth(textLine[i].c_str());
+ setTextPos(x + (width - textWidth) / 2, y + i * 30);
+ drawText(screenBuffer, textLine[i].c_str());
}
+
+ free(buf);
}
-uint32 VideoText::getTextWidth(char *text) {
+uint32 VideoText::getTextWidth(const char *text) {
assert (_fontResource);
int width = 0;
uint8 character = *text;
+ const char *curChar = text;
while (character) {
GraphicFrame *font = _fontResource->getFrame(character);
width += font->surface.w + font->x - _curFontFlags;
- text++;
- character = *text;
+ curChar++;
+ character = *curChar;
}
return width;
}
uint32 VideoText::getResTextWidth(uint32 resId) {
ResourceEntry *textRes = _textPack->getResource(resId);
- return getTextWidth((char*)textRes->data);
+ return getTextWidth((const char *)textRes->data);
}
void VideoText::drawChar(byte *screenBuffer, char character) {
@@ -234,10 +238,11 @@ void VideoText::drawChar(byte *screenBuffer, char character) {
_posX += fontLetter->surface.w + fontLetter->x - _curFontFlags;
}
-void VideoText::drawText(byte *screenBuffer, char *text) {
- while (*text) {
- drawChar(screenBuffer, *text);
- text++;
+void VideoText::drawText(byte *screenBuffer, const char *text) {
+ const char *curChar = text;
+ while (*curChar) {
+ drawChar(screenBuffer, *curChar);
+ curChar++;
}
}
diff --git a/engines/asylum/video.h b/engines/asylum/video.h
index 2be8b404a2..34c8be71f1 100644
--- a/engines/asylum/video.h
+++ b/engines/asylum/video.h
@@ -96,12 +96,12 @@ public:
private:
void setTextPos(uint32 x, uint32 y);
- void drawTextCentered(byte *screenBuffer, uint32 x, uint32 y, uint32 width, char *text);
- uint32 getTextWidth(char *text);
+ void drawTextCentered(byte *screenBuffer, uint32 x, uint32 y, uint32 width, const char *text);
+ uint32 getTextWidth(const char *text);
uint32 getResTextWidth(uint32 resId);
void drawChar(byte *screenBuffer, char character);
- void drawText(byte *screenBuffer, char *text);
+ void drawText(byte *screenBuffer, const char *text);
void copyToVideoFrame(byte *screenBuffer, GraphicFrame *frame, int x, int y);
GraphicResource *_fontResource;
Commit: 610917b968d5cfaba4b48868aa6fe112f8d40d6e
https://github.com/scummvm/scummvm/commit/610917b968d5cfaba4b48868aa6fe112f8d40d6e
Author: Filippos Karapetis (md5 at scummvm.org)
Date: 2021-05-17T15:35:25+02:00
Commit Message:
ASYLUM: Added the text resources for all of the game's video subtitles. Only the vertical placement of some multi-line subtitles remains now
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@183 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/video.cpp
diff --git a/engines/asylum/video.cpp b/engines/asylum/video.cpp
index fca692f5c6..58511e783b 100644
--- a/engines/asylum/video.cpp
+++ b/engines/asylum/video.cpp
@@ -52,13 +52,18 @@ bool VideoPlayer::playVideoWithSubtitles(Common::List<Common::Event> &stopEvents
char *start = strstr(buffer, movieToken);
char *line = 0;
- int textResourceStart = 0;
- // HACK: we hardcode all the text resources here
- // -1 means that the video has no subtitles
- int textRes[7] = { -1, 1088, 1279, 1122, 1286, 1132, 1133 };
- assert(videoNumber <= 6); // only done videos 0-6 for now
- textResourceStart = textRes[videoNumber];
+ // We hardcode all the text resources here. It makes the resulting code easier,
+ // otherwise we'll have to read the text resources in the same obscure way they're stored
+ // in vids.cap
+ // -1 means that the video has no subtitles, -2 that it doesn't exist
+ // The negative values aren't used in the code, they just make the table easier to
+ // understand.
+ int textRes[49] = { -1, 1088, 1279, 1122, 1286, 1132, 1133, 1134, 1135, 1136, // 0 - 9
+ -1, -2, 1140, 1141, -2, -1, 1142, -1, -2, 1155, // 10 - 19
+ 1157, 1159, 1162, 1164, -2, 1171, 1177, 1184, 1190, 1201, // 20 - 29
+ -2, -2, -2, 1207, 1213, 1217, 1223, 1227, -2, 1228, // 30 - 39
+ -2, 1244, 1247, 1250, 1256, 1120, 1127, -1, -1}; // 40 - 48
if (start) {
start += 20; // skip token, newline and "CAPTION = "
@@ -77,7 +82,7 @@ bool VideoPlayer::playVideoWithSubtitles(Common::List<Common::Event> &stopEvents
tok = strtok(NULL, " ");
newSubtitle.frameEnd = atoi(tok);
tok = strtok(NULL, " ");
- newSubtitle.textRes = atoi(tok) + textResourceStart;
+ newSubtitle.textRes = atoi(tok) + textRes[videoNumber];
tok = strtok(NULL, " ");
_subtitles.push_back(newSubtitle);
Commit: 8eef024f301843e7442e34716a29031182f82135
https://github.com/scummvm/scummvm/commit/8eef024f301843e7442e34716a29031182f82135
Author: Filippos Karapetis (md5 at scummvm.org)
Date: 2021-05-17T15:35:25+02:00
Commit Message:
ASYLUM: - Finished up video subtitles. Multi-line subtitles are now displayed correctly
- Simplified the video subtitle displaying code
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@184 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/video.cpp
engines/asylum/video.h
diff --git a/engines/asylum/video.cpp b/engines/asylum/video.cpp
index 58511e783b..764ab2d8df 100644
--- a/engines/asylum/video.cpp
+++ b/engines/asylum/video.cpp
@@ -100,13 +100,14 @@ void VideoPlayer::performPostProcessing(byte *screen) {
int curFrame = _decoder->getCurFrame();
// Reset subtitle area, by filling it with zeroes
- memset(screen + 640 * 420, 0, 640 * 60);
+ memset(screen + 640 * 400, 0, 640 * 80);
for (uint32 i = 0; i < _subtitles.size(); i++) {
VideoSubtitle curSubtitle = _subtitles[i];
if (curFrame >= curSubtitle.frameStart &&
curFrame <= curSubtitle.frameEnd) {
- _text->drawResTextCentered(screen, curSubtitle.textRes);
+ _text->drawMovieSubtitle(screen, curSubtitle.textRes);
+ break;
}
}
@@ -149,8 +150,6 @@ bool Video::playVideo(int number, VideoSubtitles subtitles) {
}
VideoText::VideoText() {
- _posX = 0;
- _posY = 0;
_curFontFlags = 0;
_fontResource = 0;
@@ -174,31 +173,30 @@ void VideoText::loadFont(ResourcePack *resPack, uint32 resId) {
}
}
-void VideoText::drawResTextCentered(byte *screenBuffer, uint32 resId) {
- ResourceEntry *textRes = _textPack->getResource(resId);
- drawTextCentered(screenBuffer, 0, 420, 640, (const char *)textRes->data);
-}
-
-void VideoText::setTextPos(uint32 x, uint32 y) {
- _posX = x;
- _posY = y;
-}
-
-void VideoText::drawTextCentered(byte *screenBuffer, uint32 x, uint32 y, uint32 width, const char *text) {
+void VideoText::drawMovieSubtitle(byte *screenBuffer, uint32 resId) {
Common::String textLine[4];
Common::String tmpLine;
int curLine = 0;
- char *buf = strdup(text); // for strtok
- char *tok = strtok(buf, " ");
+ ResourceEntry *textRes = _textPack->getResource(resId);
+ char *text = strdup((const char *)textRes->data); // for strtok
+ char *tok = strtok(text, " ");
+ int startY = 420; // starting y for up to 2 subtitles
+ int spacing = 30; // spacing for up to 2 subtitles
// Videos can have up to 4 lines of text
- // TODO: proper y locations. This has only been tested with up to 2 lines (videos 0-6)
while (tok) {
tmpLine += tok;
tmpLine += " ";
if (getTextWidth(tmpLine.c_str()) > 640) {
tmpLine = tok;
curLine++;
+ if (curLine >= 2) {
+ startY = 410; // starting Y for 3 subtitles
+ spacing = 20; // spacing for 3-4 subtitles
+ }
+ if (curLine >= 3) {
+ startY = 402; // starting Y for 4 subtitles
+ }
}
textLine[curLine] += tok;
textLine[curLine] += " ";
@@ -207,11 +205,10 @@ void VideoText::drawTextCentered(byte *screenBuffer, uint32 x, uint32 y, uint32
for (int i = 0; i < curLine + 1; i++) {
int textWidth = getTextWidth(textLine[i].c_str());
- setTextPos(x + (width - textWidth) / 2, y + i * 30);
- drawText(screenBuffer, textLine[i].c_str());
+ drawText(screenBuffer, 0 + (640 - textWidth) / 2, startY + i * spacing, textLine[i].c_str());
}
- free(buf);
+ free(text);
}
uint32 VideoText::getTextWidth(const char *text) {
@@ -230,23 +227,15 @@ uint32 VideoText::getTextWidth(const char *text) {
return width;
}
-uint32 VideoText::getResTextWidth(uint32 resId) {
- ResourceEntry *textRes = _textPack->getResource(resId);
- return getTextWidth((const char *)textRes->data);
-}
-
-void VideoText::drawChar(byte *screenBuffer, char character) {
+void VideoText::drawText(byte *screenBuffer, int x, int y, const char *text) {
assert (_fontResource);
-
- GraphicFrame *fontLetter = _fontResource->getFrame(character);
- copyToVideoFrame(screenBuffer, fontLetter, _posX, _posY + fontLetter->y);
- _posX += fontLetter->surface.w + fontLetter->x - _curFontFlags;
-}
-
-void VideoText::drawText(byte *screenBuffer, const char *text) {
const char *curChar = text;
+ int curX = x;
+
while (*curChar) {
- drawChar(screenBuffer, *curChar);
+ GraphicFrame *fontLetter = _fontResource->getFrame(*curChar);
+ copyToVideoFrame(screenBuffer, fontLetter, curX, y + fontLetter->y);
+ curX += fontLetter->surface.w + fontLetter->x - _curFontFlags;
curChar++;
}
}
diff --git a/engines/asylum/video.h b/engines/asylum/video.h
index 34c8be71f1..58b9b55b2d 100644
--- a/engines/asylum/video.h
+++ b/engines/asylum/video.h
@@ -92,23 +92,16 @@ public:
~VideoText();
void loadFont(ResourcePack *resPack, uint32 resId);
- void drawResTextCentered(byte *screenBuffer, uint32 resId);
+ void drawMovieSubtitle(byte *screenBuffer, uint32 resId);
private:
- void setTextPos(uint32 x, uint32 y);
- void drawTextCentered(byte *screenBuffer, uint32 x, uint32 y, uint32 width, const char *text);
uint32 getTextWidth(const char *text);
- uint32 getResTextWidth(uint32 resId);
- void drawChar(byte *screenBuffer, char character);
- void drawText(byte *screenBuffer, const char *text);
+ void drawText(byte *screenBuffer, int x, int y, const char *text);
void copyToVideoFrame(byte *screenBuffer, GraphicFrame *frame, int x, int y);
GraphicResource *_fontResource;
ResourcePack *_textPack;
-
- uint32 _posX;
- uint32 _posY;
uint8 _curFontFlags;
}; // end of class VideoText
Commit: 198afeaa80d7a17ea2332c11a34d42875f381137
https://github.com/scummvm/scummvm/commit/198afeaa80d7a17ea2332c11a34d42875f381137
Author: Filippos Karapetis (md5 at scummvm.org)
Date: 2021-05-17T15:35:26+02:00
Commit Message:
ASYLUM: Cleanup
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@185 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/video.cpp
engines/asylum/video.h
diff --git a/engines/asylum/video.cpp b/engines/asylum/video.cpp
index 764ab2d8df..031a66c88a 100644
--- a/engines/asylum/video.cpp
+++ b/engines/asylum/video.cpp
@@ -122,7 +122,6 @@ Video::Video(Audio::Mixer *mixer) {
_smkDecoder = new Graphics::SmackerDecoder(mixer);
_player = new VideoPlayer(_smkDecoder);
- _videoNumber = -1;
}
Video::~Video() {
diff --git a/engines/asylum/video.h b/engines/asylum/video.h
index 58b9b55b2d..1dac8e9be8 100644
--- a/engines/asylum/video.h
+++ b/engines/asylum/video.h
@@ -78,8 +78,6 @@ private:
Common::List<Common::Event> _stopEvents;
Graphics::SmackerDecoder *_smkDecoder;
VideoPlayer *_player;
- int _videoNumber;
-
}; // end of class Video
// The VideoText class has some methods from the Text class,
Commit: abd30b6154d5c7fd6f733cd63fadd3a712382e80
https://github.com/scummvm/scummvm/commit/abd30b6154d5c7fd6f733cd63fadd3a712382e80
Author: Filippos Karapetis (md5 at scummvm.org)
Date: 2021-05-17T15:35:26+02:00
Commit Message:
ASYLUM: Added a flag to the Scene class to determine if the scene is active or not
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@186 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/scene.cpp
engines/asylum/scene.h
diff --git a/engines/asylum/scene.cpp b/engines/asylum/scene.cpp
index cb64f9daa1..f3e48f76d1 100644
--- a/engines/asylum/scene.cpp
+++ b/engines/asylum/scene.cpp
@@ -51,6 +51,7 @@ Scene::Scene(Screen *screen, Sound *sound, uint8 sceneIdx): _screen(screen), _so
_background = 0;
_startX = _startY = 0;
_leftClick = false;
+ _isActive = false;
}
Scene::~Scene() {
@@ -80,6 +81,7 @@ void Scene::enterScene() {
// Draw the actor walking towards the north
_sceneResource->getMainActor()->setAction(6);
_sceneResource->getMainActor()->drawActorAt(_screen, 200, 200);
+ _isActive = true;
}
void Scene::handleEvent(Common::Event *event, bool doUpdate) {
diff --git a/engines/asylum/scene.h b/engines/asylum/scene.h
index cceb0545e4..831bc94bc8 100644
--- a/engines/asylum/scene.h
+++ b/engines/asylum/scene.h
@@ -49,6 +49,10 @@ public:
void handleEvent(Common::Event *event, bool doUpdate);
void enterScene();
+ void activate() { _isActive = true; }
+ void deactivate() { _isActive = false; }
+ bool isActive() { return _isActive; }
+
private:
#if 0
void copyToSceneBackground(GraphicFrame *frame, int x, int y);
@@ -67,14 +71,15 @@ private:
GraphicResource *_cursorResource;
GraphicFrame *_background;
- uint8 _sceneIdx;
- uint32 _mouseX;
- uint32 _mouseY;
+ uint8 _sceneIdx;
+ uint32 _mouseX;
+ uint32 _mouseY;
int32 _startX;
int32 _startY;
- bool _leftClick;
- uint32 _curMouseCursor;
+ bool _leftClick;
+ uint32 _curMouseCursor;
int32 _cursorStep;
+ bool _isActive;
void update();
void updateCursor();
Commit: 209e9f33ccfd63f945c3a57bb31bbc3a38810af4
https://github.com/scummvm/scummvm/commit/209e9f33ccfd63f945c3a57bb31bbc3a38810af4
Author: Filippos Karapetis (md5 at scummvm.org)
Date: 2021-05-17T15:35:26+02:00
Commit Message:
ASYLUM: Now the scene is deactivated/activated when the menu opens/closes
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@187 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/menu.cpp
diff --git a/engines/asylum/menu.cpp b/engines/asylum/menu.cpp
index 6ae7e83258..8daa90892a 100644
--- a/engines/asylum/menu.cpp
+++ b/engines/asylum/menu.cpp
@@ -75,6 +75,7 @@ MainMenu::~MainMenu() {
void MainMenu::openMenu() {
_active = true;
+ _scene->deactivate();
// yellow font
_text->loadFont(_resPack, 0x80010010);
@@ -104,6 +105,7 @@ void MainMenu::openMenu() {
void MainMenu::closeMenu() {
_active = false;
+ _scene->activate();
// Stop menu sounds and menu music
_sound->stopSfx();
Commit: 762c5d0fa2663c3ed4eb3e1c8c12eb2d0a895cd5
https://github.com/scummvm/scummvm/commit/762c5d0fa2663c3ed4eb3e1c8c12eb2d0a895cd5
Author: Filippos Karapetis (md5 at scummvm.org)
Date: 2021-05-17T15:35:26+02:00
Commit Message:
ASYLUM: Added a debug console, with a command to play any of the game's videos. Cleaned up the AsylumEngine class a bit
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@188 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
A engines/asylum/console.cpp
A engines/asylum/console.h
engines/asylum/asylum.cpp
engines/asylum/asylum.h
engines/asylum/asylum.vcproj
engines/asylum/module.mk
diff --git a/engines/asylum/asylum.cpp b/engines/asylum/asylum.cpp
index 1c97f0cffa..b9059268d8 100644
--- a/engines/asylum/asylum.cpp
+++ b/engines/asylum/asylum.cpp
@@ -45,6 +45,7 @@ AsylumEngine::AsylumEngine(OSystem *system, Common::Language language)
AsylumEngine::~AsylumEngine() {
//Common::clearAllDebugChannels();
+ delete _console;
delete _scene;
delete _mainMenu;
delete _video;
@@ -69,8 +70,10 @@ Common::Error AsylumEngine::init() {
_screen = new Screen(_system);
_sound = new Sound(_mixer);
_video = new Video(_mixer);
+ _console = new Console(this);
_mainMenu = 0;
_scene = 0;
+ _delayedVideoNumber = -1;
return Common::kNoError;
}
@@ -111,6 +114,7 @@ void AsylumEngine::waitForTimer(int msec_delay) {
while (_system->getMillis() < start_time + msec_delay) {
checkForEvent(false);
+ checkForDelayedVideo();
_system->updateScreen();
_system->delayMillis(10);
}
@@ -122,37 +126,57 @@ void AsylumEngine::checkForEvent(bool doUpdate) {
if (_system->getEventManager()->pollEvent(ev)) {
if (ev.type == Common::EVENT_KEYDOWN) {
if (ev.kbd.keycode == Common::KEYCODE_ESCAPE) {
- /*
- // Push a quit event
- Common::Event event;
- event.type = Common::EVENT_QUIT;
- g_system->getEventManager()->pushEvent(event);
- */
// Toggle menu
if (_mainMenu->isActive()) {
_mainMenu->closeMenu();
_scene->enterScene();
- } else {
+ } else if (_scene->isActive()) {
_mainMenu->openMenu();
}
return;
}
+
+ if (ev.kbd.flags == Common::KBD_CTRL) {
+ if (ev.kbd.keycode == Common::KEYCODE_d)
+ _console->attach();
+ }
+
}
}
if (doUpdate) {
- // Copy background image
- _screen->copyBackBufferToScreen();
+ if (_mainMenu->isActive() || _scene->isActive()) {
+ // Copy background image
+ _screen->copyBackBufferToScreen();
+ }
+
+ if (_console->isAttached())
+ _console->onFrame();
}
if (_mainMenu->isActive()) {
// Main menu active, pass events to it
_mainMenu->handleEvent(&ev, doUpdate);
- } else {
+ } else if (_scene->isActive()) {
// Pass events to the game
_scene->handleEvent(&ev, doUpdate);
}
}
+void AsylumEngine::checkForDelayedVideo() {
+ if (_delayedVideoNumber >= 0) {
+ _sound->stopMusic();
+ _sound->stopSfx();
+ _video->playVideo(_delayedVideoNumber, kSubtitlesOn);
+ _delayedVideoNumber = -1;
+
+ if (_mainMenu->isActive()) {
+ _mainMenu->openMenu();
+ } else if (_scene->isActive()) {
+ _scene->enterScene();
+ }
+ }
+}
+
} // namespace Asylum
diff --git a/engines/asylum/asylum.h b/engines/asylum/asylum.h
index ffaf8ba728..34c57011b7 100644
--- a/engines/asylum/asylum.h
+++ b/engines/asylum/asylum.h
@@ -28,6 +28,7 @@
#include "engines/engine.h"
+#include "asylum/console.h"
#include "asylum/scene.h"
#include "asylum/menu.h"
#include "asylum/screen.h"
@@ -36,6 +37,7 @@
namespace Asylum {
+class Console;
class Scene;
class MainMenu;
class Scene;
@@ -55,22 +57,24 @@ public:
virtual Common::Error run();
virtual bool hasFeature(EngineFeature f) const;
+private:
void checkForEvent(bool doUpdate);
void waitForTimer(int msec_delay);
void updateMouseCursor();
+ void checkForDelayedVideo();
- Screen* getScreen() { return _screen; }
- Sound* getSound() { return _sound; }
-
-private:
Common::Language _language;
Common::RandomSource _rnd;
+ Console *_console;
Scene *_scene;
MainMenu *_mainMenu;
Screen *_screen;
Sound *_sound;
Video *_video;
+ int _delayedVideoNumber;
+
+ friend class Console;
};
} // namespace Asylum
diff --git a/engines/asylum/asylum.vcproj b/engines/asylum/asylum.vcproj
index 47a8403962..13de273c11 100644
--- a/engines/asylum/asylum.vcproj
+++ b/engines/asylum/asylum.vcproj
@@ -177,6 +177,14 @@
RelativePath="..\..\engines\asylum\asylum.h"
>
</File>
+ <File
+ RelativePath="..\..\engines\asylum\console.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\engines\asylum\console.h"
+ >
+ </File>
<File
RelativePath="..\..\engines\asylum\detection.cpp"
>
diff --git a/engines/asylum/console.cpp b/engines/asylum/console.cpp
new file mode 100644
index 0000000000..8581369b36
--- /dev/null
+++ b/engines/asylum/console.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.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+// Console module
+
+#include "asylum/asylum.h"
+#include "asylum/console.h"
+
+namespace Asylum {
+
+Console::Console(AsylumEngine *vm) : GUI::Debugger() {
+ _vm = vm;
+
+ DCmd_Register("video", WRAP_METHOD(Console, cmdPlayVideo));
+
+}
+
+Console::~Console() {
+}
+
+bool Console::cmdPlayVideo(int argc, const char **argv) {
+ if (argc != 2) {
+ DebugPrintf("Usage %s <video number>\n", argv[0]);
+ return true;
+ }
+
+ _vm->_delayedVideoNumber = atoi(argv[1]);
+
+ return false;
+}
+
+
+} // End of namespace Asulym
diff --git a/engines/asylum/console.h b/engines/asylum/console.h
new file mode 100644
index 0000000000..2d036f72a3
--- /dev/null
+++ b/engines/asylum/console.h
@@ -0,0 +1,51 @@
+/* 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.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+ // Console module header file
+
+#ifndef ASYLUM_CONSOLE_H
+#define ASYLUM_CONSOLE_H
+
+#include "gui/debugger.h"
+
+namespace Asylum {
+
+class AsylumEngine;
+
+class Console : public GUI::Debugger {
+public:
+ Console(AsylumEngine *vm);
+ virtual ~Console(void);
+
+private:
+ bool cmdPlayVideo(int argc, const char **argv);
+
+private:
+ AsylumEngine *_vm;
+};
+
+} // End of namespace Asylum
+
+#endif
diff --git a/engines/asylum/module.mk b/engines/asylum/module.mk
index c4d46c4259..25bfe1cb21 100644
--- a/engines/asylum/module.mk
+++ b/engines/asylum/module.mk
@@ -2,6 +2,7 @@ MODULE := engines/asylum
MODULE_OBJS := \
asylum.o \
+ console.o \
detection.o \
graphics.o \
menu.o \
Commit: 19c253bcae71236f54db271591823eb85094951a
https://github.com/scummvm/scummvm/commit/19c253bcae71236f54db271591823eb85094951a
Author: Alexandre Fontoura (alexandrefontoura at gmail.com)
Date: 2021-05-17T15:35:26+02:00
Commit Message:
ASYLUM: Fixed and improve GamePolygons reading. Debug test to show polygons on screen.
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@189 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/scene.cpp
engines/asylum/scene.h
engines/asylum/sceneres.cpp
engines/asylum/sceneres.h
diff --git a/engines/asylum/scene.cpp b/engines/asylum/scene.cpp
index f3e48f76d1..cdfe59c129 100644
--- a/engines/asylum/scene.cpp
+++ b/engines/asylum/scene.cpp
@@ -160,6 +160,10 @@ void Scene::update() {
//updateActor(_screen, _resPack, 8); // going up the ladder
//updateActor(_screen, _resPack, 9); // going down the ladder
// TODO
+
+#if 0
+ ShowPolygons();
+#endif
}
#if 0
@@ -198,6 +202,27 @@ void Scene::copyToBackBufferClipped(GraphicFrame *frame, int x, int y) {
}
}
+void Scene::copyToBackBufferClipped(Graphics::Surface *surface, int x, int y) {
+ Common::Rect screenRect(_startX, _startY, _startX + 640, _startY + 480);
+ Common::Rect animRect(x, y, x + surface->w, y + surface->h);
+ animRect.clip(screenRect);
+
+ if (!animRect.isEmpty()) {
+ // Translate anim rectangle
+ animRect.translate(-_startX, -_startY);
+
+ int startX = animRect.right == 640 ? 0 : surface->w - animRect.width();
+ _screen->copyToBackBufferWithTransparency(((byte*)surface->pixels) +
+ (surface->h - animRect.height()) *
+ surface->pitch + startX,
+ surface->pitch,
+ animRect.left,
+ animRect.top,
+ animRect.width(),
+ animRect.height());
+ }
+}
+
void Scene::updateActor(Screen *screen, ResourcePack *res, uint8 actorIndex) {
ActorDefinitions actor = _sceneResource->getWorldStats()->_actorsDef[actorIndex];
GraphicResource *gra = new GraphicResource(res, actor.resId);
@@ -225,4 +250,22 @@ void Scene::updateActor(Screen *screen, ResourcePack *res, uint8 actorIndex) {
delete gra;
}
+// POLYGONS DEBUG
+void Scene::ShowPolygons() {
+ for(uint32 p=0; p < _sceneResource->getGamePolygons()->_numEntries; p++) {
+ Graphics::Surface sur;
+ PolyDefinitions poly = _sceneResource->getGamePolygons()->_Polygons[p];
+
+ sur.create(poly.boundingBox.right-poly.boundingBox.left, poly.boundingBox.bottom-poly.boundingBox.top, 1);
+
+ for(uint32 i=0; i < poly.numPoints; i++) {
+ sur.drawLine(poly.points[i].x-poly.boundingBox.left, poly.points[i].y-poly.boundingBox.top, poly.points[i].x-poly.boundingBox.left+1, poly.points[i].y-poly.boundingBox.top+1, 0xFF);
+ }
+ sur.frameRect(Common::Rect(0, 0, sur.w, sur.h), 0xFF);
+
+ copyToBackBufferClipped(&sur, poly.boundingBox.left, poly.boundingBox.top);
+ sur.free();
+ }
+}
+
} // end of namespace Asylum
diff --git a/engines/asylum/scene.h b/engines/asylum/scene.h
index 831bc94bc8..a428d613ef 100644
--- a/engines/asylum/scene.h
+++ b/engines/asylum/scene.h
@@ -58,6 +58,7 @@ private:
void copyToSceneBackground(GraphicFrame *frame, int x, int y);
#endif
void copyToBackBufferClipped(GraphicFrame *frame, int x, int y);
+ void copyToBackBufferClipped(Graphics::Surface *surface, int x, int y);
Screen *_screen;
Sound *_sound;
@@ -85,6 +86,7 @@ private:
void updateCursor();
void updateActor(Screen *screen, ResourcePack *res, uint8 actorIndex);
+ void ShowPolygons();
}; // end of class Scene
} // end of namespace Asylum
diff --git a/engines/asylum/sceneres.cpp b/engines/asylum/sceneres.cpp
index 5034d28bd8..e49453a68b 100644
--- a/engines/asylum/sceneres.cpp
+++ b/engines/asylum/sceneres.cpp
@@ -33,6 +33,10 @@ SceneResource::SceneResource() {
SceneResource::~SceneResource() {
delete _worldStats;
delete _mainActor;
+ for(uint i=0; i< _gamePolygons->_numEntries; i++) {
+ delete[] _gamePolygons->_Polygons[i].points;
+ }
+ delete _gamePolygons;
}
bool SceneResource::load(uint8 sceneIdx) {
@@ -242,15 +246,20 @@ void SceneResource::loadGamePolygons(Common::SeekableReadStream *stream) {
for (uint32 g = 0; g < _gamePolygons->_numEntries; g++) {
PolyDefinitions poly;
memset(&poly, 0, sizeof(PolyDefinitions));
+
poly.numPoints = stream->readUint32LE();
- for (int i = 0; i < Polygons_MAXSIZE; i++) {
- poly.points[i].x = stream->readUint32LE() & 0xFFFF;
+ if(poly.numPoints > 0)
+ poly.points = new Common::Point[poly.numPoints];
+ for (uint32 i = 0; i < poly.numPoints; i++) {
poly.points[i].y = stream->readUint32LE() & 0xFFFF;
+ poly.points[i].x = stream->readUint32LE() & 0xFFFF;
}
- poly.boundingRect.top = stream->readUint32LE() & 0xFFFF;
- poly.boundingRect.left = stream->readUint32LE() & 0xFFFF;
- poly.boundingRect.bottom = stream->readUint32LE() & 0xFFFF;
- poly.boundingRect.right = stream->readUint32LE() & 0xFFFF;
+ stream->skip((Polygons_MAXSIZE - poly.numPoints) * 8);
+
+ poly.boundingBox.left = stream->readUint32LE() & 0xFFFF;
+ poly.boundingBox.top = stream->readUint32LE() & 0xFFFF;
+ poly.boundingBox.right = stream->readUint32LE() & 0xFFFF;
+ poly.boundingBox.bottom = stream->readUint32LE() & 0xFFFF;
_gamePolygons->_Polygons.push_back(poly);
}
diff --git a/engines/asylum/sceneres.h b/engines/asylum/sceneres.h
index b93328fee0..23c0c6be17 100644
--- a/engines/asylum/sceneres.h
+++ b/engines/asylum/sceneres.h
@@ -35,7 +35,7 @@
#include "asylum/respack.h"
#define SCENEMASK "scn.%03d"
-#define Polygons_MAXSIZE 100
+#define Polygons_MAXSIZE 200
namespace Asylum {
@@ -207,8 +207,8 @@ public:
typedef struct PolyDefinitions{
uint32 numPoints;
- Common::Point points[Polygons_MAXSIZE];
- Common::Rect boundingRect;
+ Common::Point *points;//[Polygons_MAXSIZE];
+ Common::Rect boundingBox;
} PolyDefinitions;
class GamePolygons {
Commit: 9d75d9f3d1e1c3038647853c63c4721867d4f600
https://github.com/scummvm/scummvm/commit/9d75d9f3d1e1c3038647853c63c4721867d4f600
Author: Alex Bevilacqua (alexbevi at gmail.com)
Date: 2021-05-17T15:35:26+02:00
Commit Message:
ASYLUM: Minor formatting. See you guys in a couple weeks :)
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@190 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/sceneres.cpp
diff --git a/engines/asylum/sceneres.cpp b/engines/asylum/sceneres.cpp
index e49453a68b..7d1b271263 100644
--- a/engines/asylum/sceneres.cpp
+++ b/engines/asylum/sceneres.cpp
@@ -84,31 +84,31 @@ void SceneResource::loadWorldStats(Common::SeekableReadStream *stream) {
stream->skip(24); // unused data
// read common graphic resources
- _worldStats->_commonRes.backgroundImage = stream->readUint32LE();
- _worldStats->_commonRes.curScrollUp = stream->readUint32LE();
- _worldStats->_commonRes.curScrollUpLeft = stream->readUint32LE();
- _worldStats->_commonRes.curScrollLeft = stream->readUint32LE();
- _worldStats->_commonRes.curScrollDownLeft = stream->readUint32LE();
- _worldStats->_commonRes.curScrollDown = stream->readUint32LE();
+ _worldStats->_commonRes.backgroundImage = stream->readUint32LE();
+ _worldStats->_commonRes.curScrollUp = stream->readUint32LE();
+ _worldStats->_commonRes.curScrollUpLeft = stream->readUint32LE();
+ _worldStats->_commonRes.curScrollLeft = stream->readUint32LE();
+ _worldStats->_commonRes.curScrollDownLeft = stream->readUint32LE();
+ _worldStats->_commonRes.curScrollDown = stream->readUint32LE();
_worldStats->_commonRes.curScrollDownRight = stream->readUint32LE();
- _worldStats->_commonRes.curScrollRight = stream->readUint32LE();
- _worldStats->_commonRes.curScrollUpRight = stream->readUint32LE();
- _worldStats->_commonRes.curHand = stream->readUint32LE();
+ _worldStats->_commonRes.curScrollRight = stream->readUint32LE();
+ _worldStats->_commonRes.curScrollUpRight = stream->readUint32LE();
+ _worldStats->_commonRes.curHand = stream->readUint32LE();
_worldStats->_commonRes.curMagnifyingGlass = stream->readUint32LE();
- _worldStats->_commonRes.curTalkNCP = stream->readUint32LE();
- _worldStats->_commonRes.curGrabPointer = stream->readUint32LE();
- _worldStats->_commonRes.curTalkNCP2 = stream->readUint32LE();
- _worldStats->_commonRes.unknown1 = stream->readUint32LE();
- _worldStats->_commonRes.unknown2 = stream->readUint32LE();
- _worldStats->_commonRes.unknown3 = stream->readUint32LE();
- _worldStats->_commonRes.palette = stream->readUint32LE();
- _worldStats->_commonRes.cellShadeMask1 = stream->readUint32LE();
- _worldStats->_commonRes.cellShadeMask2 = stream->readUint32LE();
- _worldStats->_commonRes.cellShadeMask3 = stream->readUint32LE();
- _worldStats->_commonRes.unused = stream->readUint32LE();
- _worldStats->_commonRes.smallCurUp = stream->readUint32LE();
- _worldStats->_commonRes.smallCurDown = stream->readUint32LE();
- _worldStats->_commonRes.unknown4 = stream->readUint32LE();
+ _worldStats->_commonRes.curTalkNCP = stream->readUint32LE();
+ _worldStats->_commonRes.curGrabPointer = stream->readUint32LE();
+ _worldStats->_commonRes.curTalkNCP2 = stream->readUint32LE();
+ _worldStats->_commonRes.unknown1 = stream->readUint32LE();
+ _worldStats->_commonRes.unknown2 = stream->readUint32LE();
+ _worldStats->_commonRes.unknown3 = stream->readUint32LE();
+ _worldStats->_commonRes.palette = stream->readUint32LE();
+ _worldStats->_commonRes.cellShadeMask1 = stream->readUint32LE();
+ _worldStats->_commonRes.cellShadeMask2 = stream->readUint32LE();
+ _worldStats->_commonRes.cellShadeMask3 = stream->readUint32LE();
+ _worldStats->_commonRes.unused = stream->readUint32LE();
+ _worldStats->_commonRes.smallCurUp = stream->readUint32LE();
+ _worldStats->_commonRes.smallCurDown = stream->readUint32LE();
+ _worldStats->_commonRes.unknown4 = stream->readUint32LE();
_worldStats->_width = stream->readUint32LE();
_worldStats->_height = stream->readUint32LE();
@@ -138,61 +138,72 @@ void SceneResource::loadWorldStats(Common::SeekableReadStream *stream) {
ActorDefinitions actorDef;
int i;
- actorDef.id = stream->readUint32LE();
+ actorDef.id = stream->readUint32LE();
actorDef.resId = stream->readUint32LE();
- actorDef.x = stream->readUint32LE();
- actorDef.y = stream->readUint32LE();
- actorDef.boundingBox.left = stream->readUint32LE() & 0xFFFF;
- actorDef.boundingBox.top = stream->readUint32LE() & 0xFFFF;
- actorDef.boundingBox.right = stream->readUint32LE() & 0xFFFF;
+ actorDef.x = stream->readUint32LE();
+ actorDef.y = stream->readUint32LE();
+
+ actorDef.boundingBox.left = stream->readUint32LE() & 0xFFFF;
+ actorDef.boundingBox.top = stream->readUint32LE() & 0xFFFF;
+ actorDef.boundingBox.right = stream->readUint32LE() & 0xFFFF;
actorDef.boundingBox.bottom = stream->readUint32LE() & 0xFFFF;
- actorDef.field_20 = stream->readUint32LE();
- actorDef.frameIdx = stream->readUint32LE();
+
+ actorDef.field_20 = stream->readUint32LE();
+ actorDef.frameIdx = stream->readUint32LE();
actorDef.frameCount = stream->readUint32LE();
- actorDef.field_2C = stream->readUint32LE();
- actorDef.field_30 = stream->readUint32LE();
- actorDef.field_34 = stream->readUint32LE();
- actorDef.flags = stream->readUint32LE();
- actorDef.field_3C = stream->readUint32LE();
+ actorDef.field_2C = stream->readUint32LE();
+ actorDef.field_30 = stream->readUint32LE();
+ actorDef.field_34 = stream->readUint32LE();
+ actorDef.flags = stream->readUint32LE();
+ actorDef.field_3C = stream->readUint32LE();
+
stream->read(actorDef.name, sizeof(actorDef.name));
+
actorDef.field_74 = stream->readUint32LE();
actorDef.field_78 = stream->readUint32LE();
actorDef.field_7C = stream->readUint32LE();
actorDef.field_80 = stream->readUint32LE();
- actorDef.polyIdx = stream->readUint32LE();
- actorDef.flags2 = stream->readUint32LE();
+ actorDef.polyIdx = stream->readUint32LE();
+ actorDef.flags2 = stream->readUint32LE();
+
for (i = 0; i < 10; i++)
actorDef.gameFlags[i] = stream->readUint32LE();
- actorDef.field_B4 = stream->readUint32LE();
- actorDef.tickCount = stream->readUint32LE();
- actorDef.tickCount2 = stream->readUint32LE();
- actorDef.field_C0 = stream->readUint32LE();
- actorDef.field_C4 = stream->readUint32LE();
+
+ actorDef.field_B4 = stream->readUint32LE();
+ actorDef.tickCount = stream->readUint32LE();
+ actorDef.tickCount2 = stream->readUint32LE();
+ actorDef.field_C0 = stream->readUint32LE();
+ actorDef.field_C4 = stream->readUint32LE();
actorDef.actionListIdx = stream->readUint32LE();
+
for (i = 0; i < 16; i++) {
- actorDef.soundItems[i].resId = stream->readUint32LE();
+ actorDef.soundItems[i].resId = stream->readUint32LE();
actorDef.soundItems[i].field_4 = stream->readUint32LE();
actorDef.soundItems[i].field_8 = stream->readUint32LE();
actorDef.soundItems[i].field_C = stream->readUint32LE();
}
+
for (i = 0; i < 50; i++) {
- actorDef.frameSoundItems[i].resId = stream->readUint32LE();
+ actorDef.frameSoundItems[i].resId = stream->readUint32LE();
actorDef.frameSoundItems[i].frameIdx = stream->readUint32LE();
- actorDef.frameSoundItems[i].index = stream->readUint32LE();
- actorDef.frameSoundItems[i].field_C = stream->readUint32LE();
+ actorDef.frameSoundItems[i].index = stream->readUint32LE();
+ actorDef.frameSoundItems[i].field_C = stream->readUint32LE();
actorDef.frameSoundItems[i].field_10 = stream->readUint32LE();
actorDef.frameSoundItems[i].field_14 = stream->readUint32LE();
}
+
actorDef.field_67C = stream->readUint32LE();
- actorDef.soundX = stream->readUint32LE();
- actorDef.soundY = stream->readUint32LE();
+ actorDef.soundX = stream->readUint32LE();
+ actorDef.soundY = stream->readUint32LE();
actorDef.field_688 = stream->readUint32LE();
+
for (i = 0; i < 5; i++) {
actorDef.field_68C[i] = stream->readUint32LE();
}
+
actorDef.soundResId = stream->readUint32LE();
- actorDef.field_6A4 = stream->readUint32LE();
+ actorDef.field_6A4 = stream->readUint32LE();
_worldStats->_actorsDef.push_back(actorDef);
}
@@ -246,20 +257,20 @@ void SceneResource::loadGamePolygons(Common::SeekableReadStream *stream) {
for (uint32 g = 0; g < _gamePolygons->_numEntries; g++) {
PolyDefinitions poly;
memset(&poly, 0, sizeof(PolyDefinitions));
-
+
poly.numPoints = stream->readUint32LE();
if(poly.numPoints > 0)
- poly.points = new Common::Point[poly.numPoints];
+ poly.points = new Common::Point[poly.numPoints];
for (uint32 i = 0; i < poly.numPoints; i++) {
poly.points[i].y = stream->readUint32LE() & 0xFFFF;
poly.points[i].x = stream->readUint32LE() & 0xFFFF;
}
stream->skip((Polygons_MAXSIZE - poly.numPoints) * 8);
- poly.boundingBox.left = stream->readUint32LE() & 0xFFFF;
- poly.boundingBox.top = stream->readUint32LE() & 0xFFFF;
- poly.boundingBox.right = stream->readUint32LE() & 0xFFFF;
- poly.boundingBox.bottom = stream->readUint32LE() & 0xFFFF;
+ poly.boundingBox.left = stream->readUint32LE() & 0xFFFF;
+ poly.boundingBox.top = stream->readUint32LE() & 0xFFFF;
+ poly.boundingBox.right = stream->readUint32LE() & 0xFFFF;
+ poly.boundingBox.bottom = stream->readUint32LE() & 0xFFFF;
_gamePolygons->_Polygons.push_back(poly);
}
Commit: 824373cb8568bd786a20d936cb9ee8ffecc23126
https://github.com/scummvm/scummvm/commit/824373cb8568bd786a20d936cb9ee8ffecc23126
Author: Filippos Karapetis (md5 at scummvm.org)
Date: 2021-05-17T15:35:27+02:00
Commit Message:
ASYLUM: - Removed duplicate code
- Added a console variable to toggle polygon visibility
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@191 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/console.cpp
engines/asylum/scene.cpp
engines/asylum/scene.h
diff --git a/engines/asylum/console.cpp b/engines/asylum/console.cpp
index 8581369b36..4bdf2924cf 100644
--- a/engines/asylum/console.cpp
+++ b/engines/asylum/console.cpp
@@ -27,13 +27,17 @@
#include "asylum/asylum.h"
#include "asylum/console.h"
+#include "asylum/scene.h"
namespace Asylum {
+extern int g_debugPolygons;
+
Console::Console(AsylumEngine *vm) : GUI::Debugger() {
_vm = vm;
DCmd_Register("video", WRAP_METHOD(Console, cmdPlayVideo));
+ DVar_Register("debugpolygons", &g_debugPolygons, DVAR_INT, 0);
}
diff --git a/engines/asylum/scene.cpp b/engines/asylum/scene.cpp
index cdfe59c129..e5b09a6e83 100644
--- a/engines/asylum/scene.cpp
+++ b/engines/asylum/scene.cpp
@@ -30,6 +30,8 @@ namespace Asylum {
#define SCREEN_EDGES 40
#define SCROLL_STEP 10
+int g_debugPolygons;
+
Scene::Scene(Screen *screen, Sound *sound, uint8 sceneIdx): _screen(screen), _sound(sound) {
_sceneIdx = sceneIdx;
_sceneResource = new SceneResource;
@@ -52,6 +54,7 @@ Scene::Scene(Screen *screen, Sound *sound, uint8 sceneIdx): _screen(screen), _so
_startX = _startY = 0;
_leftClick = false;
_isActive = false;
+ g_debugPolygons = 0;
}
Scene::~Scene() {
@@ -161,9 +164,8 @@ void Scene::update() {
//updateActor(_screen, _resPack, 9); // going down the ladder
// TODO
-#if 0
- ShowPolygons();
-#endif
+ if (g_debugPolygons)
+ ShowPolygons();
}
#if 0
@@ -181,27 +183,6 @@ void Scene::copyToSceneBackground(GraphicFrame *frame, int x, int y) {
}
#endif
-void Scene::copyToBackBufferClipped(GraphicFrame *frame, int x, int y) {
- Common::Rect screenRect(_startX, _startY, _startX + 640, _startY + 480);
- Common::Rect animRect(x, y, x + frame->surface.w, y + frame->surface.h);
- animRect.clip(screenRect);
-
- if (!animRect.isEmpty()) {
- // Translate anim rectangle
- animRect.translate(-_startX, -_startY);
-
- int startX = animRect.right == 640 ? 0 : frame->surface.w - animRect.width();
- _screen->copyToBackBufferWithTransparency(((byte*)frame->surface.pixels) +
- (frame->surface.h - animRect.height()) *
- frame->surface.pitch + startX,
- frame->surface.pitch,
- animRect.left,
- animRect.top,
- animRect.width(),
- animRect.height());
- }
-}
-
void Scene::copyToBackBufferClipped(Graphics::Surface *surface, int x, int y) {
Common::Rect screenRect(_startX, _startY, _startX + 640, _startY + 480);
Common::Rect animRect(x, y, x + surface->w, y + surface->h);
@@ -237,7 +218,7 @@ void Scene::updateActor(Screen *screen, ResourcePack *res, uint8 actorIndex) {
fra->surface.drawLine(actor.boundingBox.top, actor.boundingBox.left, actor.boundingBox.bottom, actor.boundingBox.left, 0xFFFFFF);
#endif
- copyToBackBufferClipped(fra, actor.x, actor.y);
+ copyToBackBufferClipped(&fra->surface, actor.x, actor.y);
if (actor.tickCount < actor.frameCount - 1) {
actor.tickCount++;
diff --git a/engines/asylum/scene.h b/engines/asylum/scene.h
index a428d613ef..b9fbba9c1c 100644
--- a/engines/asylum/scene.h
+++ b/engines/asylum/scene.h
@@ -57,7 +57,6 @@ private:
#if 0
void copyToSceneBackground(GraphicFrame *frame, int x, int y);
#endif
- void copyToBackBufferClipped(GraphicFrame *frame, int x, int y);
void copyToBackBufferClipped(Graphics::Surface *surface, int x, int y);
Screen *_screen;
Commit: 95c2f1a2017455924403c887558d942473dcf8a4
https://github.com/scummvm/scummvm/commit/95c2f1a2017455924403c887558d942473dcf8a4
Author: Filippos Karapetis (md5 at scummvm.org)
Date: 2021-05-17T15:35:27+02:00
Commit Message:
ASYLUM: Removed one constructor of the GraphicResource class, so that the class can store the resource id of the loaded graphic
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@192 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/graphics.cpp
engines/asylum/graphics.h
engines/asylum/text.cpp
engines/asylum/video.cpp
diff --git a/engines/asylum/graphics.cpp b/engines/asylum/graphics.cpp
index 29b7a60610..91113fe03d 100644
--- a/engines/asylum/graphics.cpp
+++ b/engines/asylum/graphics.cpp
@@ -28,8 +28,10 @@
namespace Asylum {
-GraphicResource::GraphicResource(byte *data, uint32 size) {
- init(data, size);
+GraphicResource::GraphicResource(ResourcePack *resPack, int entry) {
+ ResourceEntry *resEntry = resPack->getResource(entry);
+ _entryNum = entry;
+ init(resEntry->data, resEntry->size);
}
GraphicResource::~GraphicResource() {
diff --git a/engines/asylum/graphics.h b/engines/asylum/graphics.h
index 02481bb38b..4a9dbfe27e 100644
--- a/engines/asylum/graphics.h
+++ b/engines/asylum/graphics.h
@@ -44,12 +44,7 @@ struct GraphicFrame {
// Graphic resources can be sprites or images, with multiple frames
class GraphicResource {
public:
- GraphicResource(byte *data, uint32 size);
- GraphicResource(ResourcePack *resPack, int entry) {
- ResourceEntry *resEntry = resPack->getResource(entry);
- init(resEntry->data, resEntry->size);
- }
-
+ GraphicResource(ResourcePack *resPack, int entry);
~GraphicResource();
uint32 getFrameCount() { return _frames.size(); }
@@ -65,10 +60,13 @@ public:
* Copies a sprite to the target buffer, with transparency
*/
void copySpriteToDest(byte *dest, int frame);
+
+ uint32 getEntryNum() { return _entryNum; }
private:
Common::Array <GraphicFrame> _frames;
uint32 _flags;
+ uint32 _entryNum;
void init(byte *data, uint32 size);
};
diff --git a/engines/asylum/text.cpp b/engines/asylum/text.cpp
index a16931fe66..6ef9125e5b 100644
--- a/engines/asylum/text.cpp
+++ b/engines/asylum/text.cpp
@@ -46,8 +46,7 @@ Text::~Text() {
void Text::loadFont(ResourcePack *resPack, uint32 resId) {
delete _fontResource;
- ResourceEntry *fontRes = resPack->getResource(resId);
- _fontResource = new GraphicResource(fontRes->data, fontRes->size);
+ _fontResource = new GraphicResource(resPack, resId);
if (resId > 0) {
// load font flag data
diff --git a/engines/asylum/video.cpp b/engines/asylum/video.cpp
index 031a66c88a..17837deaed 100644
--- a/engines/asylum/video.cpp
+++ b/engines/asylum/video.cpp
@@ -163,8 +163,7 @@ VideoText::~VideoText() {
void VideoText::loadFont(ResourcePack *resPack, uint32 resId) {
delete _fontResource;
- ResourceEntry *fontRes = resPack->getResource(resId);
- _fontResource = new GraphicResource(fontRes->data, fontRes->size);
+ _fontResource = new GraphicResource(resPack, resId);
if (resId > 0) {
// load font flag data
Commit: e0bce0c64dfebabbb465867c6db94893f176b8aa
https://github.com/scummvm/scummvm/commit/e0bce0c64dfebabbb465867c6db94893f176b8aa
Author: Filippos Karapetis (md5 at scummvm.org)
Date: 2021-05-17T15:35:27+02:00
Commit Message:
ASYLUM: Some WIP code for walking with the mouse
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@193 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/actor.cpp
engines/asylum/actor.h
engines/asylum/scene.cpp
engines/asylum/scene.h
diff --git a/engines/asylum/actor.cpp b/engines/asylum/actor.cpp
index 7697b92b3c..adc735e587 100644
--- a/engines/asylum/actor.cpp
+++ b/engines/asylum/actor.cpp
@@ -114,38 +114,54 @@ void MainActor::drawActorAt(Screen *screen, uint16 x, uint16 y) {
void MainActor::walkTo(Screen *screen, uint16 x, uint16 y) {
// TODO: pathfinding! The character can walk literally anywhere
+ int newAction = _currentAction;
// Walking left...
if (x < _actorX) {
- setAction(kWalkW);
+ newAction = kWalkW;
_actorX--;
- drawActorAt(screen, _actorX, _actorY);
- return;
+ if (ABS(y - _actorY) <= 30) {
+ setAction(newAction);
+ drawActorAt(screen, _actorX, _actorY);
+ return;
+ }
}
// Walking right...
if (x > _actorX) {
- setAction(kWalkE);
+ newAction = kWalkE;
_actorX++;
- drawActorAt(screen, _actorX, _actorY);
- return;
+ if (ABS(y - _actorY) <= 30) {
+ setAction(newAction);
+ drawActorAt(screen, _actorX, _actorY);
+ return;
+ }
}
// Walking up...
if (y < _actorY) {
- setAction(kWalkN);
+ if (newAction != _currentAction && newAction == kWalkW && _actorX - x > 30)
+ newAction = kWalkNW; // up left
+ else if (newAction != _currentAction && newAction == kWalkE && x - _actorX > 30)
+ newAction = kWalkNE; // up right
+ else
+ newAction = kWalkN;
_actorY--;
- drawActorAt(screen, _actorX, _actorY);
- return;
}
// Walking down...
if (y > _actorY) {
- setAction(kWalkS);
+ if (newAction != _currentAction && newAction == kWalkW && _actorX - x > 30)
+ newAction = kWalkSW; // down left
+ else if (newAction != _currentAction && newAction == kWalkE && x - _actorX > 30)
+ newAction = kWalkSE; // down right
+ else
+ newAction = kWalkS;
_actorY++;
- drawActorAt(screen, _actorX, _actorY);
- return;
}
+
+ setAction(newAction);
+ drawActorAt(screen, _actorX, _actorY);
}
} // end of namespace Asylum
diff --git a/engines/asylum/actor.h b/engines/asylum/actor.h
index 71049923cd..0f1a8bd597 100644
--- a/engines/asylum/actor.h
+++ b/engines/asylum/actor.h
@@ -136,6 +136,7 @@ public:
void setAction(int action);
void drawActorAt(Screen *screen, uint16 x, uint16 y);
void walkTo(Screen *screen, uint16 x, uint16 y);
+ int getCurrentAction() { return _currentAction; }
uint16 _actorX, _actorY;
diff --git a/engines/asylum/scene.cpp b/engines/asylum/scene.cpp
index e5b09a6e83..58a1d370a4 100644
--- a/engines/asylum/scene.cpp
+++ b/engines/asylum/scene.cpp
@@ -53,6 +53,7 @@ Scene::Scene(Screen *screen, Sound *sound, uint8 sceneIdx): _screen(screen), _so
_background = 0;
_startX = _startY = 0;
_leftClick = false;
+ _rightButton = false;
_isActive = false;
g_debugPolygons = 0;
}
@@ -81,8 +82,8 @@ void Scene::enterScene() {
_sound->playMusic(_musPack, 0);
// TEST
- // Draw the actor walking towards the north
- _sceneResource->getMainActor()->setAction(6);
+ // Draw the actor facing south
+ _sceneResource->getMainActor()->setAction(15);
_sceneResource->getMainActor()->drawActorAt(_screen, 200, 200);
_isActive = true;
}
@@ -98,6 +99,14 @@ void Scene::handleEvent(Common::Event *event, bool doUpdate) {
case Common::EVENT_LBUTTONUP:
//_leftClick = true; // TODO
break;
+ case Common::EVENT_RBUTTONUP:
+ delete _cursorResource;
+ _cursorResource = new GraphicResource(_resPack, _sceneResource->getWorldStats()->_commonRes.curMagnifyingGlass);
+ _rightButton = false;
+ break;
+ case Common::EVENT_RBUTTONDOWN:
+ _rightButton = true;
+ break;
}
if (doUpdate || _leftClick)
@@ -117,18 +126,52 @@ void Scene::updateCursor() {
void Scene::update() {
bool scrollScreen = false;
GraphicFrame *bg = _bgResource->getFrame(0);
+ MainActor *mainActor = _sceneResource->getMainActor();
updateCursor();
- // Proof of concept for screen scrolling
-
// TESTING
- // Main Actor
- if (_sceneResource->getMainActor()->_actorX != 150 || _sceneResource->getMainActor()->_actorY != 150) {
- _sceneResource->getMainActor()->walkTo(_screen, 150, 150);
+ // Main actor walking
+ if (!_rightButton) {
+ mainActor->setAction(15); // face south
+ mainActor->drawActorAt(_screen, mainActor->_actorX, mainActor->_actorY);
} else {
- _sceneResource->getMainActor()->setAction(15); // face south
- _sceneResource->getMainActor()->drawActorAt(_screen, 150, 150);
+ mainActor->walkTo(_screen, _mouseX, _mouseY);
+
+ int newCursor = -1;
+
+ // Change cursor
+ switch (mainActor->getCurrentAction()) {
+ case kWalkN:
+ newCursor = _sceneResource->getWorldStats()->_commonRes.curScrollUp;
+ break;
+ case kWalkNE:
+ newCursor = _sceneResource->getWorldStats()->_commonRes.curScrollUpRight;
+ break;
+ case kWalkNW:
+ newCursor = _sceneResource->getWorldStats()->_commonRes.curScrollUpLeft;
+ break;
+ case kWalkS:
+ newCursor = _sceneResource->getWorldStats()->_commonRes.curScrollDown;
+ break;
+ case kWalkSE:
+ newCursor = _sceneResource->getWorldStats()->_commonRes.curScrollDownRight;
+ break;
+ case kWalkSW:
+ newCursor = _sceneResource->getWorldStats()->_commonRes.curScrollDownLeft;
+ break;
+ case kWalkW:
+ newCursor = _sceneResource->getWorldStats()->_commonRes.curScrollLeft;
+ break;
+ case kWalkE:
+ newCursor = _sceneResource->getWorldStats()->_commonRes.curScrollRight;
+ break;
+ }
+
+ if (_cursorResource->getEntryNum() != newCursor) {
+ delete _cursorResource;
+ _cursorResource = new GraphicResource(_resPack, newCursor);
+ }
}
// Horizontal scrolling
diff --git a/engines/asylum/scene.h b/engines/asylum/scene.h
index b9fbba9c1c..3070231218 100644
--- a/engines/asylum/scene.h
+++ b/engines/asylum/scene.h
@@ -77,6 +77,7 @@ private:
int32 _startX;
int32 _startY;
bool _leftClick;
+ bool _rightButton;
uint32 _curMouseCursor;
int32 _cursorStep;
bool _isActive;
Commit: ffcd82b310c6deb1e0c579c24da61e1c1a4f693c
https://github.com/scummvm/scummvm/commit/ffcd82b310c6deb1e0c579c24da61e1c1a4f693c
Author: Filippos Karapetis (md5 at scummvm.org)
Date: 2021-05-17T15:35:27+02:00
Commit Message:
ASYLUM: Cleanup and styling
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@194 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/scene.cpp
diff --git a/engines/asylum/scene.cpp b/engines/asylum/scene.cpp
index 58a1d370a4..aec774f853 100644
--- a/engines/asylum/scene.cpp
+++ b/engines/asylum/scene.cpp
@@ -128,8 +128,6 @@ void Scene::update() {
GraphicFrame *bg = _bgResource->getFrame(0);
MainActor *mainActor = _sceneResource->getMainActor();
- updateCursor();
-
// TESTING
// Main actor walking
if (!_rightButton) {
@@ -138,7 +136,7 @@ void Scene::update() {
} else {
mainActor->walkTo(_screen, _mouseX, _mouseY);
- int newCursor = -1;
+ uint32 newCursor = -1;
// Change cursor
switch (mainActor->getCurrentAction()) {
@@ -169,11 +167,13 @@ void Scene::update() {
}
if (_cursorResource->getEntryNum() != newCursor) {
- delete _cursorResource;
- _cursorResource = new GraphicResource(_resPack, newCursor);
+ delete _cursorResource;
+ _cursorResource = new GraphicResource(_resPack, newCursor);
}
}
+ updateCursor();
+
// Horizontal scrolling
if (_mouseX < SCREEN_EDGES && _startX >= SCROLL_STEP) {
_startX -= SCROLL_STEP;
@@ -280,10 +280,11 @@ void Scene::ShowPolygons() {
Graphics::Surface sur;
PolyDefinitions poly = _sceneResource->getGamePolygons()->_Polygons[p];
- sur.create(poly.boundingBox.right-poly.boundingBox.left, poly.boundingBox.bottom-poly.boundingBox.top, 1);
+ sur.create(poly.boundingBox.right - poly.boundingBox.left, poly.boundingBox.bottom - poly.boundingBox.top, 1);
- for(uint32 i=0; i < poly.numPoints; i++) {
- sur.drawLine(poly.points[i].x-poly.boundingBox.left, poly.points[i].y-poly.boundingBox.top, poly.points[i].x-poly.boundingBox.left+1, poly.points[i].y-poly.boundingBox.top+1, 0xFF);
+ for (uint32 i=0; i < poly.numPoints; i++) {
+ sur.drawLine(poly.points[i].x - poly.boundingBox.left, poly.points[i].y - poly.boundingBox.top,
+ poly.points[i].x - poly.boundingBox.left + 1, poly.points[i].y - poly.boundingBox.top + 1, 0xFF);
}
sur.frameRect(Common::Rect(0, 0, sur.w, sur.h), 0xFF);
Commit: d22bc0cf5118e33ecefb73ed931ff33cd2fa49ec
https://github.com/scummvm/scummvm/commit/d22bc0cf5118e33ecefb73ed931ff33cd2fa49ec
Author: Filippos Karapetis (md5 at scummvm.org)
Date: 2021-05-17T15:35:27+02:00
Commit Message:
ASYLUM: Silenced a warning, some cleanup
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@195 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/scene.cpp
diff --git a/engines/asylum/scene.cpp b/engines/asylum/scene.cpp
index aec774f853..b01e5e25e0 100644
--- a/engines/asylum/scene.cpp
+++ b/engines/asylum/scene.cpp
@@ -124,7 +124,7 @@ void Scene::updateCursor() {
}
void Scene::update() {
- bool scrollScreen = false;
+ //bool scrollScreen = false;
GraphicFrame *bg = _bgResource->getFrame(0);
MainActor *mainActor = _sceneResource->getMainActor();
@@ -136,7 +136,7 @@ void Scene::update() {
} else {
mainActor->walkTo(_screen, _mouseX, _mouseY);
- uint32 newCursor = -1;
+ uint32 newCursor = 0;
// Change cursor
switch (mainActor->getCurrentAction()) {
@@ -177,19 +177,19 @@ void Scene::update() {
// Horizontal scrolling
if (_mouseX < SCREEN_EDGES && _startX >= SCROLL_STEP) {
_startX -= SCROLL_STEP;
- scrollScreen = true;
+ //scrollScreen = true;
} else if (_mouseX > 640 - SCREEN_EDGES && _startX <= bg->surface.w - 640 - SCROLL_STEP) {
_startX += SCROLL_STEP;
- scrollScreen = true;
+ //scrollScreen = true;
}
// Vertical scrolling
if (_mouseY < SCREEN_EDGES && _startY >= SCROLL_STEP) {
_startY -= SCROLL_STEP;
- scrollScreen = true;
+ //scrollScreen = true;
} else if (_mouseY > 480 - SCREEN_EDGES && _startY <= bg->surface.h - 480 - SCROLL_STEP) {
_startY += SCROLL_STEP;
- scrollScreen = true;
+ //scrollScreen = true;
}
// Copy the background to the back buffer before updating the scene animations
Commit: 18fd3a9588941768d6ae6a24d0b6ec52361e67ce
https://github.com/scummvm/scummvm/commit/18fd3a9588941768d6ae6a24d0b6ec52361e67ce
Author: Filippos Karapetis (md5 at scummvm.org)
Date: 2021-05-17T15:35:27+02:00
Commit Message:
ASYLUM: Some initial code for the "View cinematics" submenu
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@196 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/menu.cpp
engines/asylum/menu.h
engines/asylum/text.cpp
engines/asylum/text.h
diff --git a/engines/asylum/menu.cpp b/engines/asylum/menu.cpp
index 8daa90892a..1c52966b00 100644
--- a/engines/asylum/menu.cpp
+++ b/engines/asylum/menu.cpp
@@ -333,7 +333,7 @@ void MainMenu::updateSubMenu() {
// TODO
break;
case kViewCinematics:
- // TODO
+ updateSubMenuCinematics();
break;
case kQuitGame:
updateSubMenuQuitGame();
@@ -395,6 +395,29 @@ void MainMenu::updateSubMenuNewGame() {
}
}
+void MainMenu::updateSubMenuCinematics() {
+ int currentCD = 1; // FIXME: dummy value
+ _text->drawResTextWithValueCentered(10, 100, 620, 0x80000548, currentCD);
+ _text->setTextPos(30, 340);
+ _text->drawResText(0x80000549); // Prev Page
+
+ if (_mouseX >= 280 && _mouseX <= 400 && _mouseY >= 340 && _mouseY <= 360) {
+ _text->loadFont(_resPack, 0x80010016); // blue font
+ if (_leftClick)
+ exitSubMenu();
+ } else {
+ _text->loadFont(_resPack, 0x80010010); // yellow font
+ }
+
+ _text->setTextPos(280, 340);
+ _text->drawResText(0x8000054B); // Main Menu
+
+ _text->loadFont(_resPack, 0x80010010); // yellow font
+
+ _text->setTextPos(500, 340);
+ _text->drawResText(0x8000054A); // Next Page
+}
+
void MainMenu::updateSubMenuSettings() {
uint32 sizeMinus = _text->getTextWidth("-");
uint32 sizePlus = _text->getTextWidth("+");
diff --git a/engines/asylum/menu.h b/engines/asylum/menu.h
index d752534120..b3d5e4aae0 100644
--- a/engines/asylum/menu.h
+++ b/engines/asylum/menu.h
@@ -121,6 +121,7 @@ private:
void updateSubMenu();
void exitSubMenu();
void updateSubMenuNewGame();
+ void updateSubMenuCinematics();
void updateSubMenuSettings();
void updateSubMenuQuitGame();
void updateSubMenuShowCredits();
diff --git a/engines/asylum/text.cpp b/engines/asylum/text.cpp
index 6ef9125e5b..9e380ae0d0 100644
--- a/engines/asylum/text.cpp
+++ b/engines/asylum/text.cpp
@@ -106,6 +106,14 @@ void Text::drawTextCentered(uint32 x, uint32 y, uint32 width, char *text) {
drawText(text);
}
+void Text::drawResTextWithValueCentered(uint32 x, uint32 y, uint32 width, uint32 resId, uint32 value) {
+ ResourceEntry *textRes = _textPack->getResource(resId);
+ char *text = (char *)textRes->data;
+ char txt[100];
+ sprintf(txt, text, value);
+ drawTextCentered(x, y, width, txt);
+}
+
void Text::drawResTextCentered(uint32 x, uint32 y, uint32 width, uint32 resId) {
ResourceEntry *textRes = _textPack->getResource(resId);
drawTextCentered(x, y, width, (char *)textRes->data);
diff --git a/engines/asylum/text.h b/engines/asylum/text.h
index 0571e79bea..156e146092 100644
--- a/engines/asylum/text.h
+++ b/engines/asylum/text.h
@@ -52,6 +52,7 @@ public:
void drawTextCentered(uint32 x, uint32 y, uint32 width, char *text);
void drawResTextCentered(uint32 x, uint32 y, uint32 width, uint32 resId);
+ void drawResTextWithValueCentered(uint32 x, uint32 y, uint32 width, uint32 resId, uint32 value);
void drawTextAlignRight(uint32 x, uint32 y, char *text);
void drawResTextAlignRight(uint32 x, uint32 y, uint32 resId);
Commit: 84ad75f451ff23d99f1deceedd184cadf8346e32
https://github.com/scummvm/scummvm/commit/84ad75f451ff23d99f1deceedd184cadf8346e32
Author: Filippos Karapetis (md5 at scummvm.org)
Date: 2021-05-17T15:35:27+02:00
Commit Message:
ASYLUM: Prevent reloading a font with the same resource number as the currently loaded one
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@197 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/text.cpp
diff --git a/engines/asylum/text.cpp b/engines/asylum/text.cpp
index 9e380ae0d0..a0f4b4bb1a 100644
--- a/engines/asylum/text.cpp
+++ b/engines/asylum/text.cpp
@@ -44,6 +44,9 @@ Text::~Text() {
// loadFont at address 00435640
void Text::loadFont(ResourcePack *resPack, uint32 resId) {
+ if (_fontResource && resId == _fontResource->getEntryNum())
+ return;
+
delete _fontResource;
_fontResource = new GraphicResource(resPack, resId);
Commit: b03e6eafbb1b0ef713aee0f1b7cdc837ff137d99
https://github.com/scummvm/scummvm/commit/b03e6eafbb1b0ef713aee0f1b7cdc837ff137d99
Author: Filippos Karapetis (md5 at scummvm.org)
Date: 2021-05-17T15:35:28+02:00
Commit Message:
ASYLUM: Some initial code for scene hotspots
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@198 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/scene.cpp
engines/asylum/sceneres.cpp
diff --git a/engines/asylum/scene.cpp b/engines/asylum/scene.cpp
index b01e5e25e0..1fd63eb6eb 100644
--- a/engines/asylum/scene.cpp
+++ b/engines/asylum/scene.cpp
@@ -97,7 +97,7 @@ void Scene::handleEvent(Common::Event *event, bool doUpdate) {
_mouseY = _ev->mouse.y;
break;
case Common::EVENT_LBUTTONUP:
- //_leftClick = true; // TODO
+ _leftClick = true;
break;
case Common::EVENT_RBUTTONUP:
delete _cursorResource;
@@ -127,6 +127,8 @@ void Scene::update() {
//bool scrollScreen = false;
GraphicFrame *bg = _bgResource->getFrame(0);
MainActor *mainActor = _sceneResource->getMainActor();
+ WorldStats *worldStats = _sceneResource->getWorldStats();
+ int32 curHotspot = -1;
// TESTING
// Main actor walking
@@ -141,28 +143,28 @@ void Scene::update() {
// Change cursor
switch (mainActor->getCurrentAction()) {
case kWalkN:
- newCursor = _sceneResource->getWorldStats()->_commonRes.curScrollUp;
+ newCursor = worldStats->_commonRes.curScrollUp;
break;
case kWalkNE:
- newCursor = _sceneResource->getWorldStats()->_commonRes.curScrollUpRight;
+ newCursor = worldStats->_commonRes.curScrollUpRight;
break;
case kWalkNW:
- newCursor = _sceneResource->getWorldStats()->_commonRes.curScrollUpLeft;
+ newCursor = worldStats->_commonRes.curScrollUpLeft;
break;
case kWalkS:
- newCursor = _sceneResource->getWorldStats()->_commonRes.curScrollDown;
+ newCursor = worldStats->_commonRes.curScrollDown;
break;
case kWalkSE:
- newCursor = _sceneResource->getWorldStats()->_commonRes.curScrollDownRight;
+ newCursor = worldStats->_commonRes.curScrollDownRight;
break;
case kWalkSW:
- newCursor = _sceneResource->getWorldStats()->_commonRes.curScrollDownLeft;
+ newCursor = worldStats->_commonRes.curScrollDownLeft;
break;
case kWalkW:
- newCursor = _sceneResource->getWorldStats()->_commonRes.curScrollLeft;
+ newCursor = worldStats->_commonRes.curScrollLeft;
break;
case kWalkE:
- newCursor = _sceneResource->getWorldStats()->_commonRes.curScrollRight;
+ newCursor = worldStats->_commonRes.curScrollRight;
break;
}
@@ -172,8 +174,6 @@ void Scene::update() {
}
}
- updateCursor();
-
// Horizontal scrolling
if (_mouseX < SCREEN_EDGES && _startX >= SCROLL_STEP) {
_startX -= SCROLL_STEP;
@@ -209,6 +209,38 @@ void Scene::update() {
if (g_debugPolygons)
ShowPolygons();
+
+ // Update cursor if it's in a hotspot
+ for (uint32 p = 0; p < _sceneResource->getGamePolygons()->_numEntries; p++) {
+ PolyDefinitions poly = _sceneResource->getGamePolygons()->_Polygons[p];
+ if (poly.boundingBox.contains(_mouseX, _mouseY)) {
+ curHotspot = (int32)p;
+ updateCursor();
+ break;
+ }
+ }
+
+ if (_leftClick) {
+ _leftClick = false;
+
+ if (curHotspot >= 0) {
+ for (uint32 a = 0; a < worldStats->_numActions; a++) {
+ if (worldStats->_actorsActionDef[a].polyIdx == curHotspot) {
+ printf("Hotspot: \"%s\", poly %d, action lists %d/%d, action type %d, sound res %d\n",
+ worldStats->_actorsActionDef[a].name,
+ worldStats->_actorsActionDef[a].polyIdx,
+ worldStats->_actorsActionDef[a].actionListIdx1,
+ worldStats->_actorsActionDef[a].actionListIdx2,
+ worldStats->_actorsActionDef[a].actionType,
+ worldStats->_actorsActionDef[a].soundResId);
+ // Play the SFX associated with the hotspot
+ // TODO: The hotspot sound res id is 0, seems like we need to get it from the associated action list
+ //_sound->playSfx(_resPack, worldStats->_actorsActionDef[a].soundResId);
+ }
+ }
+ }
+ }
+
}
#if 0
@@ -276,7 +308,7 @@ void Scene::updateActor(Screen *screen, ResourcePack *res, uint8 actorIndex) {
// POLYGONS DEBUG
void Scene::ShowPolygons() {
- for(uint32 p=0; p < _sceneResource->getGamePolygons()->_numEntries; p++) {
+ for (uint32 p = 0; p < _sceneResource->getGamePolygons()->_numEntries; p++) {
Graphics::Surface sur;
PolyDefinitions poly = _sceneResource->getGamePolygons()->_Polygons[p];
diff --git a/engines/asylum/sceneres.cpp b/engines/asylum/sceneres.cpp
index 7d1b271263..0e07291ba8 100644
--- a/engines/asylum/sceneres.cpp
+++ b/engines/asylum/sceneres.cpp
@@ -222,7 +222,7 @@ void SceneResource::loadWorldStats(Common::SeekableReadStream *stream) {
stream->seek(0xD6B5A); // where actors action definitions start
// FIXME Figure out all the actor action definitions
- for (uint32 a=0; a < _worldStats->_numActions; a++) {
+ for (uint32 a = 0; a < _worldStats->_numActions; a++) {
ActorActionDefinitions actorActionDef;
memset(&actorActionDef, 0, sizeof(ActorActionDefinitions));
@@ -259,7 +259,7 @@ void SceneResource::loadGamePolygons(Common::SeekableReadStream *stream) {
memset(&poly, 0, sizeof(PolyDefinitions));
poly.numPoints = stream->readUint32LE();
- if(poly.numPoints > 0)
+ if (poly.numPoints > 0)
poly.points = new Common::Point[poly.numPoints];
for (uint32 i = 0; i < poly.numPoints; i++) {
poly.points[i].y = stream->readUint32LE() & 0xFFFF;
Commit: d851b62f2813722fe8cbe473af00471baead524c
https://github.com/scummvm/scummvm/commit/d851b62f2813722fe8cbe473af00471baead524c
Author: Alexandre Fontoura (alexandrefontoura at gmail.com)
Date: 2021-05-17T15:35:28+02:00
Commit Message:
ASYLUM: Scene ActionList read first steps.
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@200 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/sceneres.cpp
engines/asylum/sceneres.h
diff --git a/engines/asylum/sceneres.cpp b/engines/asylum/sceneres.cpp
index 0e07291ba8..099b91e5fb 100644
--- a/engines/asylum/sceneres.cpp
+++ b/engines/asylum/sceneres.cpp
@@ -37,6 +37,7 @@ SceneResource::~SceneResource() {
delete[] _gamePolygons->_Polygons[i].points;
}
delete _gamePolygons;
+ delete _actionList;
}
bool SceneResource::load(uint8 sceneIdx) {
@@ -245,7 +246,6 @@ void SceneResource::loadWorldStats(Common::SeekableReadStream *stream) {
}
}
-// FIXME: load necessary Game Polygons content
void SceneResource::loadGamePolygons(Common::SeekableReadStream *stream) {
_gamePolygons = new GamePolygons;
@@ -276,9 +276,44 @@ void SceneResource::loadGamePolygons(Common::SeekableReadStream *stream) {
}
}
-// TODO: load necessary Action List content
+// FIXME: load necessary Action List content
void SceneResource::loadActionList(Common::SeekableReadStream *stream) {
+ _actionList = new ActionList;
+ stream->seek(0xE868E + _gamePolygons->_size * _gamePolygons->_numEntries); // jump to action list data
+
+ _actionList->_size = stream->readUint32LE();
+ _actionList->_numEntries = stream->readUint32LE();
+
+ for (uint32 a = 0; a < _actionList->_numEntries; a++) {
+ ActionDefinitions action;
+ memset(&action, 0, sizeof(ActionDefinitions));
+
+ for (uint32 c = 0; c < Commands_MAXSIZE; c++) {
+ ActionCommand command;
+ memset(&command, 0, sizeof(ActionCommand));
+
+ command.unknown = stream->readUint32LE();
+ command.opcode = stream->readUint32LE(); // command type
+ command.param1 = stream->readUint32LE(); // command parameters
+ command.param2 = stream->readUint32LE();
+ command.param3 = stream->readUint32LE();
+ command.param4 = stream->readUint32LE();
+ command.param5 = stream->readUint32LE();
+ command.param6 = stream->readUint32LE();
+ command.param7 = stream->readUint32LE();
+ command.param8 = stream->readUint32LE();
+ command.param9 = stream->readUint32LE();
+
+ action.commands[c] = command;
+ }
+
+ action.field_1BAC = stream->readUint32LE();
+ action.field_1BB0 = stream->readUint32LE();
+ action.counter = stream->readUint32LE();
+
+ _actionList->_Actions.push_back(action);
+ }
}
Common::String SceneResource::parseFilename(uint8 sceneIdx) {
diff --git a/engines/asylum/sceneres.h b/engines/asylum/sceneres.h
index 23c0c6be17..ed6f0a9655 100644
--- a/engines/asylum/sceneres.h
+++ b/engines/asylum/sceneres.h
@@ -36,6 +36,7 @@
#define SCENEMASK "scn.%03d"
#define Polygons_MAXSIZE 200
+#define Commands_MAXSIZE 161
namespace Asylum {
@@ -223,10 +224,36 @@ public:
}; // end of class GamePolygons
+typedef struct ActionCommand {
+ uint32 unknown;
+ uint32 opcode;
+ uint32 param1;
+ uint32 param2;
+ uint32 param3;
+ uint32 param4;
+ uint32 param5;
+ uint32 param6;
+ uint32 param7;
+ uint32 param8;
+ uint32 param9;
+} ActionCommand;
+
+typedef struct ActionDefinitions {
+ ActionCommand commands[161];
+ uint32 field_1BAC;
+ uint32 field_1BB0;
+ uint32 counter;
+} ActionDefinitions;
+
class ActionList {
public:
ActionList() {};
virtual ~ActionList() {};
+
+ uint32 _size;
+ uint32 _numEntries;
+
+ Common::Array<ActionDefinitions> _Actions;
}; // end of class ActionList
} // end of namespace Asylum
Commit: dfd39bfc32bc9fa039a5a8eb2f07e5983e9b944a
https://github.com/scummvm/scummvm/commit/dfd39bfc32bc9fa039a5a8eb2f07e5983e9b944a
Author: Alexandre Fontoura (alexandrefontoura at gmail.com)
Date: 2021-05-17T15:35:28+02:00
Commit Message:
ASYLUM: Scene stuffs: New fields added. Renamed items to be accurate as original game. Still got work to do here.
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@202 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/scene.cpp
engines/asylum/scene.h
engines/asylum/sceneres.cpp
engines/asylum/sceneres.h
diff --git a/engines/asylum/scene.cpp b/engines/asylum/scene.cpp
index 1fd63eb6eb..6f0371e2aa 100644
--- a/engines/asylum/scene.cpp
+++ b/engines/asylum/scene.cpp
@@ -195,16 +195,16 @@ void Scene::update() {
// Copy the background to the back buffer before updating the scene animations
_screen->copyToBackBuffer(((byte *)bg->surface.pixels) + _startY * bg->surface.w + _startX, bg->surface.w, 0, 0, 640, 480);
- updateActor(_screen, _resPack, 0); // the "statue with fireworks" animation
- //updateActor(_screen, _resPack, 1); // inside the middle room
- //updateActor(_screen, _resPack, 2); // the lit candles at the base of the statue
- updateActor(_screen, _resPack, 3); // the rat animation (in front of the statue)
- updateActor(_screen, _resPack, 4); // inside the bottom room
- updateActor(_screen, _resPack, 6); // inside the top room (should be shown before the rat animation)
- updateActor(_screen, _resPack, 5); // the rat animation (outside the second room)
- updateActor(_screen, _resPack, 7); // the "crazy prisoner banging head" animation
- //updateActor(_screen, _resPack, 8); // going up the ladder
- //updateActor(_screen, _resPack, 9); // going down the ladder
+ updateBarrier(_screen, _resPack, 0); // the "statue with fireworks" animation
+ //updateBarrier(_screen, _resPack, 1); // inside the middle room
+ //updateBarrier(_screen, _resPack, 2); // the lit candles at the base of the statue
+ updateBarrier(_screen, _resPack, 3); // the rat animation (in front of the statue)
+ updateBarrier(_screen, _resPack, 4); // inside the bottom room
+ updateBarrier(_screen, _resPack, 6); // inside the top room (should be shown before the rat animation)
+ updateBarrier(_screen, _resPack, 5); // the rat animation (outside the second room)
+ updateBarrier(_screen, _resPack, 7); // the "crazy prisoner banging head" animation
+ //updateBarrier(_screen, _resPack, 8); // going up the ladder
+ //updateBarrier(_screen, _resPack, 9); // going down the ladder
// TODO
if (g_debugPolygons)
@@ -213,7 +213,7 @@ void Scene::update() {
// Update cursor if it's in a hotspot
for (uint32 p = 0; p < _sceneResource->getGamePolygons()->_numEntries; p++) {
PolyDefinitions poly = _sceneResource->getGamePolygons()->_Polygons[p];
- if (poly.boundingBox.contains(_mouseX, _mouseY)) {
+ if (poly.boundingRect.contains(_mouseX, _mouseY)) {
curHotspot = (int32)p;
updateCursor();
break;
@@ -224,18 +224,18 @@ void Scene::update() {
_leftClick = false;
if (curHotspot >= 0) {
- for (uint32 a = 0; a < worldStats->_numActions; a++) {
- if (worldStats->_actorsActionDef[a].polyIdx == curHotspot) {
+ for (uint32 a = 0; a < worldStats->_numBarrierActions; a++) {
+ if (worldStats->_actors[a].polyIdx == curHotspot) {
printf("Hotspot: \"%s\", poly %d, action lists %d/%d, action type %d, sound res %d\n",
- worldStats->_actorsActionDef[a].name,
- worldStats->_actorsActionDef[a].polyIdx,
- worldStats->_actorsActionDef[a].actionListIdx1,
- worldStats->_actorsActionDef[a].actionListIdx2,
- worldStats->_actorsActionDef[a].actionType,
- worldStats->_actorsActionDef[a].soundResId);
+ worldStats->_actors[a].name,
+ worldStats->_actors[a].polyIdx,
+ worldStats->_actors[a].actionListIdx1,
+ worldStats->_actors[a].actionListIdx2,
+ worldStats->_actors[a].actionType,
+ worldStats->_actors[a].soundResId);
// Play the SFX associated with the hotspot
// TODO: The hotspot sound res id is 0, seems like we need to get it from the associated action list
- //_sound->playSfx(_resPack, worldStats->_actorsActionDef[a].soundResId);
+ //_sound->playSfx(_resPack, worldStats->_actors[a].soundResId);
}
}
}
@@ -279,29 +279,29 @@ void Scene::copyToBackBufferClipped(Graphics::Surface *surface, int x, int y) {
}
}
-void Scene::updateActor(Screen *screen, ResourcePack *res, uint8 actorIndex) {
- ActorDefinitions actor = _sceneResource->getWorldStats()->_actorsDef[actorIndex];
- GraphicResource *gra = new GraphicResource(res, actor.resId);
- GraphicFrame *fra = gra->getFrame(actor.tickCount);
+void Scene::updateBarrier(Screen *screen, ResourcePack *res, uint8 barrierIndex) {
+ BarrierItem barrier = _sceneResource->getWorldStats()->_barriers[barrierIndex];
+ GraphicResource *gra = new GraphicResource(res, barrier.resId);
+ GraphicFrame *fra = gra->getFrame(barrier.tickCount);
#if 0
// DEBUG bounding box
// FIXME this should be a generic method which draws for an entire graphicResource and not for single graphicFrames
- fra->surface.drawLine(actor.boundingBox.top, actor.boundingBox.left, actor.boundingBox.top, actor.boundingBox.right, 0xFFFFFF);
- fra->surface.drawLine(actor.boundingBox.top, actor.boundingBox.right-1, actor.boundingBox.bottom, actor.boundingBox.right-1, 0xFFFFFF);
- fra->surface.drawLine(actor.boundingBox.bottom-1, actor.boundingBox.left, actor.boundingBox.bottom-1, actor.boundingBox.right, 0xFFFFFF);
- fra->surface.drawLine(actor.boundingBox.top, actor.boundingBox.left, actor.boundingBox.bottom, actor.boundingBox.left, 0xFFFFFF);
+ fra->surface.drawLine(barrier.boundingRect.top, barrier.boundingRect.left, barrier.boundingRect.top, barrier.boundingRect.right, 0xFFFFFF);
+ fra->surface.drawLine(barrier.boundingRect.top, barrier.boundingRect.right-1, barrier.boundingRect.bottom, barrier.boundingRect.right-1, 0xFFFFFF);
+ fra->surface.drawLine(barrier.boundingRect.bottom-1, barrier.boundingRect.left, barrier.boundingRect.bottom-1, barrier.boundingRect.right, 0xFFFFFF);
+ fra->surface.drawLine(barrier.boundingRect.top, barrier.boundingRect.left, barrier.boundingRect.bottom, barrier.boundingRect.left, 0xFFFFFF);
#endif
- copyToBackBufferClipped(&fra->surface, actor.x, actor.y);
+ copyToBackBufferClipped(&fra->surface, barrier.x, barrier.y);
- if (actor.tickCount < actor.frameCount - 1) {
- actor.tickCount++;
+ if (barrier.tickCount < barrier.frameCount - 1) {
+ barrier.tickCount++;
}else{
- actor.tickCount = actor.frameIdx;
+ barrier.tickCount = barrier.frameIdx;
}
- _sceneResource->getWorldStats()->_actorsDef[actorIndex] = actor;
+ _sceneResource->getWorldStats()->_barriers[barrierIndex] = barrier;
delete gra;
}
@@ -312,15 +312,15 @@ void Scene::ShowPolygons() {
Graphics::Surface sur;
PolyDefinitions poly = _sceneResource->getGamePolygons()->_Polygons[p];
- sur.create(poly.boundingBox.right - poly.boundingBox.left, poly.boundingBox.bottom - poly.boundingBox.top, 1);
+ sur.create(poly.boundingRect.right - poly.boundingRect.left, poly.boundingRect.bottom - poly.boundingRect.top, 1);
for (uint32 i=0; i < poly.numPoints; i++) {
- sur.drawLine(poly.points[i].x - poly.boundingBox.left, poly.points[i].y - poly.boundingBox.top,
- poly.points[i].x - poly.boundingBox.left + 1, poly.points[i].y - poly.boundingBox.top + 1, 0xFF);
+ sur.drawLine(poly.points[i].x - poly.boundingRect.left, poly.points[i].y - poly.boundingRect.top,
+ poly.points[i].x - poly.boundingRect.left + 1, poly.points[i].y - poly.boundingRect.top + 1, 0xFF);
}
sur.frameRect(Common::Rect(0, 0, sur.w, sur.h), 0xFF);
- copyToBackBufferClipped(&sur, poly.boundingBox.left, poly.boundingBox.top);
+ copyToBackBufferClipped(&sur, poly.boundingRect.left, poly.boundingRect.top);
sur.free();
}
}
diff --git a/engines/asylum/scene.h b/engines/asylum/scene.h
index 3070231218..aa22266af0 100644
--- a/engines/asylum/scene.h
+++ b/engines/asylum/scene.h
@@ -84,7 +84,7 @@ private:
void update();
void updateCursor();
- void updateActor(Screen *screen, ResourcePack *res, uint8 actorIndex);
+ void updateBarrier(Screen *screen, ResourcePack *res, uint8 actorIndex);
void ShowPolygons();
}; // end of class Scene
diff --git a/engines/asylum/sceneres.cpp b/engines/asylum/sceneres.cpp
index 099b91e5fb..dfa385b049 100644
--- a/engines/asylum/sceneres.cpp
+++ b/engines/asylum/sceneres.cpp
@@ -99,9 +99,9 @@ void SceneResource::loadWorldStats(Common::SeekableReadStream *stream) {
_worldStats->_commonRes.curTalkNCP = stream->readUint32LE();
_worldStats->_commonRes.curGrabPointer = stream->readUint32LE();
_worldStats->_commonRes.curTalkNCP2 = stream->readUint32LE();
- _worldStats->_commonRes.unknown1 = stream->readUint32LE();
- _worldStats->_commonRes.unknown2 = stream->readUint32LE();
- _worldStats->_commonRes.unknown3 = stream->readUint32LE();
+ _worldStats->_commonRes.field_54 = stream->readUint32LE();
+ _worldStats->_commonRes.field_58 = stream->readUint32LE();
+ _worldStats->_commonRes.field_5C = stream->readUint32LE();
_worldStats->_commonRes.palette = stream->readUint32LE();
_worldStats->_commonRes.cellShadeMask1 = stream->readUint32LE();
_worldStats->_commonRes.cellShadeMask2 = stream->readUint32LE();
@@ -109,15 +109,15 @@ void SceneResource::loadWorldStats(Common::SeekableReadStream *stream) {
_worldStats->_commonRes.unused = stream->readUint32LE();
_worldStats->_commonRes.smallCurUp = stream->readUint32LE();
_worldStats->_commonRes.smallCurDown = stream->readUint32LE();
- _worldStats->_commonRes.unknown4 = stream->readUint32LE();
+ _worldStats->_commonRes.field_7C = stream->readUint32LE();
_worldStats->_width = stream->readUint32LE();
_worldStats->_height = stream->readUint32LE();
stream->skip(8); // unused data
- _worldStats->_numActions = stream->readUint32LE();
- _worldStats->_numActors = stream->readUint32LE();
+ _worldStats->_numBarrierActions = stream->readUint32LE();
+ _worldStats->_numBarriers = stream->readUint32LE();
stream->skip(20); // unused data
@@ -127,86 +127,86 @@ void SceneResource::loadWorldStats(Common::SeekableReadStream *stream) {
// FIXME Jump unknown resource list
stream->seek(0x2C6);
- _worldStats->_loadingScreenGrResId = stream->readUint32LE();
- _worldStats->_loadingScreenPalResId = stream->readUint32LE();
+ _worldStats->_sceneTitleGrResId = stream->readUint32LE();
+ _worldStats->_sceneTitlePalResId = stream->readUint32LE();
// FIXME Jump unknown sound resource list
// FIXME Jump resource list definitions
stream->seek(0x6FA); // where actors definitions start
- for (uint32 a = 0; a < _worldStats->_numActors; a++) {
- ActorDefinitions actorDef;
+ for (uint32 a = 0; a < _worldStats->_numBarriers; a++) {
+ BarrierItem barrier;
int i;
- actorDef.id = stream->readUint32LE();
- actorDef.resId = stream->readUint32LE();
- actorDef.x = stream->readUint32LE();
- actorDef.y = stream->readUint32LE();
-
- actorDef.boundingBox.left = stream->readUint32LE() & 0xFFFF;
- actorDef.boundingBox.top = stream->readUint32LE() & 0xFFFF;
- actorDef.boundingBox.right = stream->readUint32LE() & 0xFFFF;
- actorDef.boundingBox.bottom = stream->readUint32LE() & 0xFFFF;
-
- actorDef.field_20 = stream->readUint32LE();
- actorDef.frameIdx = stream->readUint32LE();
- actorDef.frameCount = stream->readUint32LE();
- actorDef.field_2C = stream->readUint32LE();
- actorDef.field_30 = stream->readUint32LE();
- actorDef.field_34 = stream->readUint32LE();
- actorDef.flags = stream->readUint32LE();
- actorDef.field_3C = stream->readUint32LE();
-
- stream->read(actorDef.name, sizeof(actorDef.name));
-
- actorDef.field_74 = stream->readUint32LE();
- actorDef.field_78 = stream->readUint32LE();
- actorDef.field_7C = stream->readUint32LE();
- actorDef.field_80 = stream->readUint32LE();
- actorDef.polyIdx = stream->readUint32LE();
- actorDef.flags2 = stream->readUint32LE();
+ barrier.id = stream->readUint32LE();
+ barrier.resId = stream->readUint32LE();
+ barrier.x = stream->readUint32LE();
+ barrier.y = stream->readUint32LE();
+
+ barrier.boundingRect.left = stream->readUint32LE() & 0xFFFF;
+ barrier.boundingRect.top = stream->readUint32LE() & 0xFFFF;
+ barrier.boundingRect.right = stream->readUint32LE() & 0xFFFF;
+ barrier.boundingRect.bottom = stream->readUint32LE() & 0xFFFF;
+
+ barrier.field_20 = stream->readUint32LE();
+ barrier.frameIdx = stream->readUint32LE();
+ barrier.frameCount = stream->readUint32LE();
+ barrier.field_2C = stream->readUint32LE();
+ barrier.field_30 = stream->readUint32LE();
+ barrier.field_34 = stream->readUint32LE();
+ barrier.flags = stream->readUint32LE();
+ barrier.field_3C = stream->readUint32LE();
+
+ stream->read(barrier.name, sizeof(barrier.name));
+
+ barrier.field_74 = stream->readUint32LE();
+ barrier.field_78 = stream->readUint32LE();
+ barrier.field_7C = stream->readUint32LE();
+ barrier.field_80 = stream->readUint32LE();
+ barrier.polyIdx = stream->readUint32LE();
+ barrier.flags2 = stream->readUint32LE();
for (i = 0; i < 10; i++)
- actorDef.gameFlags[i] = stream->readUint32LE();
+ barrier.gameFlags[i] = stream->readUint32LE();
- actorDef.field_B4 = stream->readUint32LE();
- actorDef.tickCount = stream->readUint32LE();
- actorDef.tickCount2 = stream->readUint32LE();
- actorDef.field_C0 = stream->readUint32LE();
- actorDef.field_C4 = stream->readUint32LE();
- actorDef.actionListIdx = stream->readUint32LE();
+ barrier.field_B4 = stream->readUint32LE();
+ barrier.tickCount = stream->readUint32LE();
+ barrier.tickCount2 = stream->readUint32LE();
+ barrier.field_C0 = stream->readUint32LE();
+ barrier.field_C4 = stream->readUint32LE();
+ barrier.actionListIdx = stream->readUint32LE();
for (i = 0; i < 16; i++) {
- actorDef.soundItems[i].resId = stream->readUint32LE();
- actorDef.soundItems[i].field_4 = stream->readUint32LE();
- actorDef.soundItems[i].field_8 = stream->readUint32LE();
- actorDef.soundItems[i].field_C = stream->readUint32LE();
+ barrier.soundItems[i].resId = stream->readUint32LE();
+ barrier.soundItems[i].field_4 = stream->readUint32LE();
+ barrier.soundItems[i].field_8 = stream->readUint32LE();
+ barrier.soundItems[i].field_C = stream->readUint32LE();
}
for (i = 0; i < 50; i++) {
- actorDef.frameSoundItems[i].resId = stream->readUint32LE();
- actorDef.frameSoundItems[i].frameIdx = stream->readUint32LE();
- actorDef.frameSoundItems[i].index = stream->readUint32LE();
- actorDef.frameSoundItems[i].field_C = stream->readUint32LE();
- actorDef.frameSoundItems[i].field_10 = stream->readUint32LE();
- actorDef.frameSoundItems[i].field_14 = stream->readUint32LE();
+ barrier.frameSoundItems[i].resId = stream->readUint32LE();
+ barrier.frameSoundItems[i].frameIdx = stream->readUint32LE();
+ barrier.frameSoundItems[i].index = stream->readUint32LE();
+ barrier.frameSoundItems[i].field_C = stream->readUint32LE();
+ barrier.frameSoundItems[i].field_10 = stream->readUint32LE();
+ barrier.frameSoundItems[i].field_14 = stream->readUint32LE();
}
- actorDef.field_67C = stream->readUint32LE();
- actorDef.soundX = stream->readUint32LE();
- actorDef.soundY = stream->readUint32LE();
- actorDef.field_688 = stream->readUint32LE();
+ barrier.field_67C = stream->readUint32LE();
+ barrier.soundX = stream->readUint32LE();
+ barrier.soundY = stream->readUint32LE();
+ barrier.field_688 = stream->readUint32LE();
for (i = 0; i < 5; i++) {
- actorDef.field_68C[i] = stream->readUint32LE();
+ barrier.field_68C[i] = stream->readUint32LE();
}
- actorDef.soundResId = stream->readUint32LE();
- actorDef.field_6A4 = stream->readUint32LE();
+ barrier.soundResId = stream->readUint32LE();
+ barrier.field_6A4 = stream->readUint32LE();
- _worldStats->_actorsDef.push_back(actorDef);
+ _worldStats->_barriers.push_back(barrier);
}
// TODO grab Max actor definitions
@@ -223,26 +223,26 @@ void SceneResource::loadWorldStats(Common::SeekableReadStream *stream) {
stream->seek(0xD6B5A); // where actors action definitions start
// FIXME Figure out all the actor action definitions
- for (uint32 a = 0; a < _worldStats->_numActions; a++) {
- ActorActionDefinitions actorActionDef;
- memset(&actorActionDef, 0, sizeof(ActorActionDefinitions));
+ for (uint32 a = 0; a < _worldStats->_numBarrierActions; a++) {
+ ActorItem actor;
+ memset(&actor, 0, sizeof(ActorItem));
- stream->read(actorActionDef.name,52);
- actorActionDef.id = stream->readUint32LE();
+ stream->read(actor.name,52);
+ actor.id = stream->readUint32LE();
stream->skip(0x14);
- actorActionDef.actionListIdx1 = stream->readUint32LE();
- actorActionDef.actionListIdx2 = stream->readUint32LE();
- actorActionDef.actionType = stream->readUint32LE();
+ actor.actionListIdx1 = stream->readUint32LE();
+ actor.actionListIdx2 = stream->readUint32LE();
+ actor.actionType = stream->readUint32LE();
stream->skip(0x2C);
- actorActionDef.polyIdx = stream->readUint32LE();
+ actor.polyIdx = stream->readUint32LE();
stream->skip(0x08);
- actorActionDef.soundResId = stream->readUint32LE();
+ actor.soundResId = stream->readUint32LE();
stream->skip(0x04);
- actorActionDef.palCorrection = stream->readUint32LE();
+ actor.palCorrection = stream->readUint32LE();
stream->skip(0x14);
- actorActionDef.soundVolume = stream->readUint32LE();
+ actor.soundVolume = stream->readUint32LE();
- _worldStats->_actorsActionDef.push_back(actorActionDef);
+ _worldStats->_actors.push_back(actor);
}
}
@@ -267,10 +267,10 @@ void SceneResource::loadGamePolygons(Common::SeekableReadStream *stream) {
}
stream->skip((Polygons_MAXSIZE - poly.numPoints) * 8);
- poly.boundingBox.left = stream->readUint32LE() & 0xFFFF;
- poly.boundingBox.top = stream->readUint32LE() & 0xFFFF;
- poly.boundingBox.right = stream->readUint32LE() & 0xFFFF;
- poly.boundingBox.bottom = stream->readUint32LE() & 0xFFFF;
+ poly.boundingRect.left = stream->readUint32LE() & 0xFFFF;
+ poly.boundingRect.top = stream->readUint32LE() & 0xFFFF;
+ poly.boundingRect.right = stream->readUint32LE() & 0xFFFF;
+ poly.boundingRect.bottom = stream->readUint32LE() & 0xFFFF;
_gamePolygons->_Polygons.push_back(poly);
}
diff --git a/engines/asylum/sceneres.h b/engines/asylum/sceneres.h
index ed6f0a9655..76be27ac32 100644
--- a/engines/asylum/sceneres.h
+++ b/engines/asylum/sceneres.h
@@ -101,13 +101,25 @@ typedef struct FrameSoundItem {
uint32 field_14;
} FrameSoundItem;
+typedef struct AmbientSoundItem {
+ uint32 field_0;
+ uint32 flags;
+ uint32 resId;
+ uint32 field_C;
+ uint32 field_10;
+ uint32 field_14;
+ uint32 flagNum[6];
+ uint32 x;
+ uint32 y;
+} AmbientSoundItem;
+
// FIXME figure out unknown fields
-typedef struct ActorDefinitions {
+typedef struct BarrierItem {
uint32 id;
uint32 resId;
uint32 x;
uint32 y;
- Common::Rect boundingBox;
+ Common::Rect boundingRect;
uint32 field_20;
uint32 frameIdx;
uint32 frameCount;
@@ -139,11 +151,10 @@ typedef struct ActorDefinitions {
uint32 field_68C[5];
uint32 soundResId;
uint32 field_6A4;
-} ActorDefinitions;
-
+} BarrierItem;
// FIXME add unknown fields
-typedef struct ActorActionDefinitions {
+typedef struct ActorItem {
char name[52];
uint32 id;
int32 actionListIdx1;
@@ -153,7 +164,7 @@ typedef struct ActorActionDefinitions {
uint32 soundResId;
uint32 palCorrection;
int32 soundVolume;
-} ActorActionDefinitions;
+} ActorItem;
typedef struct CommonResources {
uint32 backgroundImage;
@@ -170,9 +181,9 @@ typedef struct CommonResources {
uint32 curTalkNCP;
uint32 curGrabPointer;
uint32 curTalkNCP2;
- uint32 unknown1;
- uint32 unknown2;
- uint32 unknown3;
+ uint32 field_54;
+ uint32 field_58;
+ uint32 field_5C;
uint32 palette;
uint32 cellShadeMask1;
uint32 cellShadeMask2;
@@ -180,7 +191,7 @@ typedef struct CommonResources {
uint32 unused;
uint32 smallCurUp;
uint32 smallCurDown;
- uint32 unknown4;
+ uint32 field_7C;
} CommonResources;
@@ -191,25 +202,59 @@ public:
uint32 _size;
uint32 _numEntries;
- uint32 _numChapter;
- uint32 _width;
- uint32 _height;
- uint32 _numActions;
- uint32 _numActors;
- uint32 _loadingScreenGrResId;
- uint32 _loadingScreenPalResId;
-
- CommonResources _commonRes;
-
- Common::Array<ActorDefinitions> _actorsDef;
- Common::Array<ActorActionDefinitions> _actorsActionDef;
+
+ uint32 _numChapter;
+ uint32 _xLeft;
+ uint32 _yTop;
+ Common::Rect _boundingRect;
+ CommonResources _commonRes; // field_1C till field_7C
+
+ uint32 _width; // field_80
+ uint32 _height;
+ uint32 _field_88;
+ uint32 _field_8C;
+ uint32 _numBarrierActions; // field_90
+ uint32 _numBarriers;
+ uint32 _field_98;
+ uint32 _field_9C;
+ uint32 _field_A0;
+ uint32 _field_A4;
+ uint32 _field_A8;
+ uint32 _field_AC;
+ uint32 _field_B0;
+ uint32 _numActors; // Max and all other characters that have own interactions
+ uint32 _stereoReversedFlag;
+
+ Common::Rect _sceneRects[6]; // including scene size rect
+ uint8 _sceneRectIdx;
+
+ uint8 _field_11D[3];
+ uint32 _field_120;
+ uint32 _actionListIdx; // actionList start index
+ uint32 _grResId[100];
+ uint32 _sceneTitleGrResId;
+ uint32 _sceneTitlePalResId;
+ uint32 _actorType;
+
+ uint32 _soundResId[50];
+ AmbientSoundItem _ambientSounds[15];
+ uint32 _musicStatus;
+ uint32 _musicCurrentResId;
+ uint32 _musicFlag;
+ uint32 _musicResId;
+ uint32 _musicStatusExt;
+
+ // FIXME: Investigate if we need to actually reserve maxsize for this arrays.
+ // It always have that size under scene file and they are always save in savegames.
+ Common::Array<BarrierItem> _barriers; // maxsize 400
+ Common::Array<ActorItem> _actors; // maxsize 50
}; // end of class WorldStats
typedef struct PolyDefinitions{
uint32 numPoints;
Common::Point *points;//[Polygons_MAXSIZE];
- Common::Rect boundingBox;
+ Common::Rect boundingRect;
} PolyDefinitions;
class GamePolygons {
Commit: 96369ef78fcff966a6dce86e358ea2c08df82730
https://github.com/scummvm/scummvm/commit/96369ef78fcff966a6dce86e358ea2c08df82730
Author: Alexandre Fontoura (alexandrefontoura at gmail.com)
Date: 2021-05-17T15:35:28+02:00
Commit Message:
ASYLUM: More scene fields read. Action item under WorldStats renamed.
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@203 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/scene.cpp
engines/asylum/sceneres.cpp
engines/asylum/sceneres.h
diff --git a/engines/asylum/scene.cpp b/engines/asylum/scene.cpp
index 6f0371e2aa..1ec26ec5d1 100644
--- a/engines/asylum/scene.cpp
+++ b/engines/asylum/scene.cpp
@@ -224,15 +224,15 @@ void Scene::update() {
_leftClick = false;
if (curHotspot >= 0) {
- for (uint32 a = 0; a < worldStats->_numBarrierActions; a++) {
- if (worldStats->_actors[a].polyIdx == curHotspot) {
+ for (uint32 a = 0; a < worldStats->_numActions; a++) {
+ if (worldStats->_actions[a].polyIdx == curHotspot) {
printf("Hotspot: \"%s\", poly %d, action lists %d/%d, action type %d, sound res %d\n",
- worldStats->_actors[a].name,
- worldStats->_actors[a].polyIdx,
- worldStats->_actors[a].actionListIdx1,
- worldStats->_actors[a].actionListIdx2,
- worldStats->_actors[a].actionType,
- worldStats->_actors[a].soundResId);
+ worldStats->_actions[a].name,
+ worldStats->_actions[a].polyIdx,
+ worldStats->_actions[a].actionListIdx1,
+ worldStats->_actions[a].actionListIdx2,
+ worldStats->_actions[a].actionType,
+ worldStats->_actions[a].soundResId);
// Play the SFX associated with the hotspot
// TODO: The hotspot sound res id is 0, seems like we need to get it from the associated action list
//_sound->playSfx(_resPack, worldStats->_actors[a].soundResId);
diff --git a/engines/asylum/sceneres.cpp b/engines/asylum/sceneres.cpp
index dfa385b049..6791296e8d 100644
--- a/engines/asylum/sceneres.cpp
+++ b/engines/asylum/sceneres.cpp
@@ -80,9 +80,14 @@ void SceneResource::loadWorldStats(Common::SeekableReadStream *stream) {
_worldStats->_size = stream->readUint32LE();
_worldStats->_numEntries = stream->readUint32LE();
- _worldStats->_numChapter = stream->readUint32LE();
- stream->skip(24); // unused data
+ _worldStats->_numChapter = stream->readUint32LE();
+ _worldStats->_xLeft = stream->readUint32LE();
+ _worldStats->_yTop = stream->readUint32LE();
+ _worldStats->_boundingRect.left = stream->readUint32LE() & 0xFFFF;
+ _worldStats->_boundingRect.top = stream->readUint32LE() & 0xFFFF;
+ _worldStats->_boundingRect.right = stream->readUint32LE() & 0xFFFF;
+ _worldStats->_boundingRect.bottom = stream->readUint32LE() & 0xFFFF;
// read common graphic resources
_worldStats->_commonRes.backgroundImage = stream->readUint32LE();
@@ -111,22 +116,40 @@ void SceneResource::loadWorldStats(Common::SeekableReadStream *stream) {
_worldStats->_commonRes.smallCurDown = stream->readUint32LE();
_worldStats->_commonRes.field_7C = stream->readUint32LE();
- _worldStats->_width = stream->readUint32LE();
- _worldStats->_height = stream->readUint32LE();
-
- stream->skip(8); // unused data
-
- _worldStats->_numBarrierActions = stream->readUint32LE();
- _worldStats->_numBarriers = stream->readUint32LE();
-
- stream->skip(20); // unused data
+ _worldStats->_width = stream->readUint32LE();
+ _worldStats->_height = stream->readUint32LE();
+ _worldStats->_field_88 = stream->readUint32LE();
+ _worldStats->_field_8C = stream->readUint32LE();
+ _worldStats->_numActions = stream->readUint32LE();
+ _worldStats->_numBarriers = stream->readUint32LE();
+ _worldStats->_field_98 = stream->readUint32LE();
+ _worldStats->_field_9C = stream->readUint32LE();
+ _worldStats->_field_A0 = stream->readUint32LE();
+ _worldStats->_field_A4 = stream->readUint32LE();
+ _worldStats->_field_A8 = stream->readUint32LE();
+ _worldStats->_field_AC = stream->readUint32LE();
+ _worldStats->_field_B0 = stream->readUint32LE();
+ _worldStats->_numActors = stream->readUint32LE();
+ _worldStats->_stereoReversedFlag = stream->readUint32LE();
+
+ for(int r=0; r < 6; r++) {
+ _worldStats->_sceneRects[r].left = stream->readUint32LE() & 0xFFFF;
+ _worldStats->_sceneRects[r].top = stream->readUint32LE() & 0xFFFF;
+ _worldStats->_sceneRects[r].right = stream->readUint32LE() & 0xFFFF;
+ _worldStats->_sceneRects[r].bottom = stream->readUint32LE() & 0xFFFF;
+ }
+ _worldStats->_sceneRectIdx = stream->readByte();
+ _worldStats->_field_11D[0] = stream->readByte();
+ _worldStats->_field_11D[1] = stream->readByte();
+ _worldStats->_field_11D[2] = stream->readByte();
- // FIXME figure out what these 3 unknown fields are
- stream->skip(12);
+ _worldStats->_field_120 = stream->readUint32LE();
+ _worldStats->_actionListIdx = stream->readUint32LE();
- // FIXME Jump unknown resource list
+ for(int gr=0; gr < 100; gr++) {
+ _worldStats->_grResId[gr] = stream->readUint32LE();
+ }
- stream->seek(0x2C6);
_worldStats->_sceneTitleGrResId = stream->readUint32LE();
_worldStats->_sceneTitlePalResId = stream->readUint32LE();
@@ -222,27 +245,27 @@ void SceneResource::loadWorldStats(Common::SeekableReadStream *stream) {
stream->seek(0xD6B5A); // where actors action definitions start
- // FIXME Figure out all the actor action definitions
- for (uint32 a = 0; a < _worldStats->_numBarrierActions; a++) {
- ActorItem actor;
- memset(&actor, 0, sizeof(ActorItem));
+ // FIXME Figure out all the actions definitions
+ for (uint32 a = 0; a < _worldStats->_numActions; a++) {
+ ActionItem action;
+ memset(&action, 0, sizeof(ActionItem));
- stream->read(actor.name,52);
- actor.id = stream->readUint32LE();
+ stream->read(action.name,52);
+ action.id = stream->readUint32LE();
stream->skip(0x14);
- actor.actionListIdx1 = stream->readUint32LE();
- actor.actionListIdx2 = stream->readUint32LE();
- actor.actionType = stream->readUint32LE();
+ action.actionListIdx1 = stream->readUint32LE();
+ action.actionListIdx2 = stream->readUint32LE();
+ action.actionType = stream->readUint32LE();
stream->skip(0x2C);
- actor.polyIdx = stream->readUint32LE();
+ action.polyIdx = stream->readUint32LE();
stream->skip(0x08);
- actor.soundResId = stream->readUint32LE();
+ action.soundResId = stream->readUint32LE();
stream->skip(0x04);
- actor.palCorrection = stream->readUint32LE();
+ action.palCorrection = stream->readUint32LE();
stream->skip(0x14);
- actor.soundVolume = stream->readUint32LE();
+ action.soundVolume = stream->readUint32LE();
- _worldStats->_actors.push_back(actor);
+ _worldStats->_actions.push_back(action);
}
}
diff --git a/engines/asylum/sceneres.h b/engines/asylum/sceneres.h
index 76be27ac32..4f221a6ebe 100644
--- a/engines/asylum/sceneres.h
+++ b/engines/asylum/sceneres.h
@@ -154,7 +154,7 @@ typedef struct BarrierItem {
} BarrierItem;
// FIXME add unknown fields
-typedef struct ActorItem {
+typedef struct ActionItem {
char name[52];
uint32 id;
int32 actionListIdx1;
@@ -164,7 +164,7 @@ typedef struct ActorItem {
uint32 soundResId;
uint32 palCorrection;
int32 soundVolume;
-} ActorItem;
+} ActionItem;
typedef struct CommonResources {
uint32 backgroundImage;
@@ -204,16 +204,16 @@ public:
uint32 _numEntries;
uint32 _numChapter;
- uint32 _xLeft;
- uint32 _yTop;
+ uint32 _xLeft; // scene start x position
+ uint32 _yTop; // scene start y position
Common::Rect _boundingRect;
CommonResources _commonRes; // field_1C till field_7C
- uint32 _width; // field_80
+ uint32 _width; // field_80
uint32 _height;
uint32 _field_88;
uint32 _field_8C;
- uint32 _numBarrierActions; // field_90
+ uint32 _numActions; // field_90
uint32 _numBarriers;
uint32 _field_98;
uint32 _field_9C;
@@ -227,8 +227,8 @@ public:
Common::Rect _sceneRects[6]; // including scene size rect
uint8 _sceneRectIdx;
+ uint8 _field_11D[3];
- uint8 _field_11D[3];
uint32 _field_120;
uint32 _actionListIdx; // actionList start index
uint32 _grResId[100];
@@ -247,7 +247,8 @@ public:
// FIXME: Investigate if we need to actually reserve maxsize for this arrays.
// It always have that size under scene file and they are always save in savegames.
Common::Array<BarrierItem> _barriers; // maxsize 400
- Common::Array<ActorItem> _actors; // maxsize 50
+
+ Common::Array<ActionItem> _actions; // maxsize 400
}; // end of class WorldStats
Commit: 409e176e4651147bb47298fd1d7ba9fa1d6f076b
https://github.com/scummvm/scummvm/commit/409e176e4651147bb47298fd1d7ba9fa1d6f076b
Author: Alexandre Fontoura (alexandrefontoura at gmail.com)
Date: 2021-05-17T15:35:28+02:00
Commit Message:
ASYLUM: Scene WorldStats fields read added.
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@204 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/sceneres.cpp
engines/asylum/sceneres.h
diff --git a/engines/asylum/sceneres.cpp b/engines/asylum/sceneres.cpp
index 6791296e8d..36ab5f62fa 100644
--- a/engines/asylum/sceneres.cpp
+++ b/engines/asylum/sceneres.cpp
@@ -152,15 +152,37 @@ void SceneResource::loadWorldStats(Common::SeekableReadStream *stream) {
_worldStats->_sceneTitleGrResId = stream->readUint32LE();
_worldStats->_sceneTitlePalResId = stream->readUint32LE();
+ _worldStats->_actorType = stream->readUint32LE();
- // FIXME Jump unknown sound resource list
- // FIXME Jump resource list definitions
+ for(int s=0; s < 50; s++) {
+ _worldStats->_soundResId[s] = stream->readUint32LE();
+ }
+
+ for(int s=0; s < 15; s++) {
+ _worldStats->_ambientSounds[s].field_0 = stream->readUint32LE();
+ _worldStats->_ambientSounds[s].flags = stream->readUint32LE();
+ _worldStats->_ambientSounds[s].resId = stream->readUint32LE();
+ _worldStats->_ambientSounds[s].field_C = stream->readUint32LE();
+ _worldStats->_ambientSounds[s].field_10 = stream->readUint32LE();
+ _worldStats->_ambientSounds[s].field_14 = stream->readUint32LE();
+
+ for(int i=0; i < 6; i++)
+ _worldStats->_ambientSounds[s].flagNum[i] = stream->readUint32LE();
+
+ _worldStats->_ambientSounds[s].x = stream->readUint32LE();
+ _worldStats->_ambientSounds[s].y = stream->readUint32LE();
+ }
+ _worldStats->_numAmbientSound = stream->readUint32LE();
- stream->seek(0x6FA); // where actors definitions start
+ _worldStats->_musicStatus = stream->readUint32LE();
+ _worldStats->_musicCurrentResId = stream->readUint32LE();
+ _worldStats->_musicFlag = stream->readUint32LE();
+ _worldStats->_musicResId = stream->readUint32LE();
+ _worldStats->_musicStatusExt = stream->readUint32LE();
for (uint32 a = 0; a < _worldStats->_numBarriers; a++) {
+ int i;
BarrierItem barrier;
- int i;
barrier.id = stream->readUint32LE();
barrier.resId = stream->readUint32LE();
diff --git a/engines/asylum/sceneres.h b/engines/asylum/sceneres.h
index 4f221a6ebe..e430fc1bf8 100644
--- a/engines/asylum/sceneres.h
+++ b/engines/asylum/sceneres.h
@@ -238,6 +238,7 @@ public:
uint32 _soundResId[50];
AmbientSoundItem _ambientSounds[15];
+ uint32 _numAmbientSound;
uint32 _musicStatus;
uint32 _musicCurrentResId;
uint32 _musicFlag;
Commit: f65c0ba31e9cec240809abbf22b3b1e4062281ae
https://github.com/scummvm/scummvm/commit/f65c0ba31e9cec240809abbf22b3b1e4062281ae
Author: Alexandre Fontoura (alexandrefontoura at gmail.com)
Date: 2021-05-17T15:35:28+02:00
Commit Message:
ASYLUM: Scene ActorItems fields read.
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@205 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/scene.cpp
engines/asylum/sceneres.cpp
engines/asylum/sceneres.h
diff --git a/engines/asylum/scene.cpp b/engines/asylum/scene.cpp
index 1ec26ec5d1..4819c3fb76 100644
--- a/engines/asylum/scene.cpp
+++ b/engines/asylum/scene.cpp
@@ -212,7 +212,7 @@ void Scene::update() {
// Update cursor if it's in a hotspot
for (uint32 p = 0; p < _sceneResource->getGamePolygons()->_numEntries; p++) {
- PolyDefinitions poly = _sceneResource->getGamePolygons()->_Polygons[p];
+ PolyDefinitions poly = _sceneResource->getGamePolygons()->_polygons[p];
if (poly.boundingRect.contains(_mouseX, _mouseY)) {
curHotspot = (int32)p;
updateCursor();
@@ -310,7 +310,7 @@ void Scene::updateBarrier(Screen *screen, ResourcePack *res, uint8 barrierIndex)
void Scene::ShowPolygons() {
for (uint32 p = 0; p < _sceneResource->getGamePolygons()->_numEntries; p++) {
Graphics::Surface sur;
- PolyDefinitions poly = _sceneResource->getGamePolygons()->_Polygons[p];
+ PolyDefinitions poly = _sceneResource->getGamePolygons()->_polygons[p];
sur.create(poly.boundingRect.right - poly.boundingRect.left, poly.boundingRect.bottom - poly.boundingRect.top, 1);
diff --git a/engines/asylum/sceneres.cpp b/engines/asylum/sceneres.cpp
index 36ab5f62fa..5b75c1ca6d 100644
--- a/engines/asylum/sceneres.cpp
+++ b/engines/asylum/sceneres.cpp
@@ -34,7 +34,7 @@ SceneResource::~SceneResource() {
delete _worldStats;
delete _mainActor;
for(uint i=0; i< _gamePolygons->_numEntries; i++) {
- delete[] _gamePolygons->_Polygons[i].points;
+ delete[] _gamePolygons->_polygons[i].points;
}
delete _gamePolygons;
delete _actionList;
@@ -254,20 +254,103 @@ void SceneResource::loadWorldStats(Common::SeekableReadStream *stream) {
_worldStats->_barriers.push_back(barrier);
}
- // TODO grab Max actor definitions
- // TODO hardcoded for RES.005 ... need to verify if this
- // offset persists across the other files, and also how
- // scenes with multiple actors work
- stream->seek(0xA73B6);
+ // need to jump all unused barriers data to where actors data start
+ stream->seek(0xA6D7A);
+
+ for (uint32 a = 0; a < _worldStats->_numActors; a++) {
+ int i;
+ ActorItem actor;
+ memset(&actor, 0, sizeof(ActorItem));
+
+ actor.x0 = stream->readUint32LE();
+ actor.y0 = stream->readUint32LE();
+ actor.grResId = stream->readUint32LE();
+ actor.field_C = stream->readUint32LE();
+ actor.frameNum = stream->readUint32LE();
+ actor.frameCount = stream->readUint32LE();
+ actor.x1 = stream->readUint32LE();
+ actor.y1 = stream->readUint32LE();
+ actor.x2 = stream->readUint32LE();
+ actor.y2 = stream->readUint32LE();
+
+ actor.boundingRect.left = stream->readUint32LE() & 0xFFFF;
+ actor.boundingRect.top = stream->readUint32LE() & 0xFFFF;
+ actor.boundingRect.right = stream->readUint32LE() & 0xFFFF;
+ actor.boundingRect.bottom = stream->readUint32LE() & 0xFFFF;
+
+ actor.direction = stream->readUint32LE();
+ actor.field_3C = stream->readUint32LE();
+ actor.field_40 = stream->readUint32LE();
+ actor.field_44 = stream->readUint32LE();
+ actor.field_48 = stream->readUint32LE();
+ actor.flags = stream->readUint32LE();
+ actor.field_50 = stream->readUint32LE();
+ actor.field_54 = stream->readUint32LE();
+ actor.field_58 = stream->readUint32LE();
+ actor.field_5C = stream->readUint32LE();
+ actor.field_60 = stream->readUint32LE();
+ actor.actionIdx3 = stream->readUint32LE();
+
+ // TODO skip field_68 till field_617
+ stream->skip(0x5B0);
+
+ for(i=0; i < 8; i++) {
+ actor.reaction[i] = stream->readUint32LE();
+ }
+
+ actor.field_638 = stream->readUint32LE();
+ actor.field_63C = stream->readUint32LE();
+ actor.field_640 = stream->readUint32LE();
+ actor.field_644 = stream->readUint32LE();
+ actor.field_648 = stream->readUint32LE();
+ actor.field_64C = stream->readUint32LE();
+ actor.field_650 = stream->readUint32LE();
+
+ for(i=0; i < 55; i++) {
+ actor.grResTable[i] = stream->readUint32LE();
+ }
+
+ stream->read(actor.name, sizeof(actor.name));
+ for(i=0; i < 20; i++) {
+ actor.field_830[i] = stream->readUint32LE();
+ }
+ for(i=0; i < 20; i++) {
+ actor.field_880[i] = stream->readUint32LE();
+ }
+ for(i=0; i < 20; i++) {
+ actor.field_8D0[i] = stream->readUint32LE();
+ }
+
+ actor.actionIdx2 = stream->readUint32LE();
+ actor.field_924 = stream->readUint32LE();
+ actor.tickValue1 = stream->readUint32LE();
+ actor.field_92C = stream->readUint32LE();
+ actor.flags2 = stream->readUint32LE();
+ actor.field_934 = stream->readUint32LE();
+ actor.field_938 = stream->readUint32LE();
+ actor.soundResId = stream->readUint32LE();
+
+ // TODO skip field_940 till field_978
+ stream->skip(0x3C);
+
+ actor.actionIdx1 = stream->readUint32LE();
+
+ // TODO skip field_980 till field_9A0
+ stream->skip(0x24);
+
+ _worldStats->_actors.push_back(actor);
+ }
+
+ // TODO Take this out, it shouldn't be here (TEST ONLY)
+ stream->seek(0xA73B6);
uint8 mainActorData[500];
stream->read(mainActorData, 500);
-
_mainActor = new MainActor(mainActorData);
- stream->seek(0xD6B5A); // where actors action definitions start
+ stream->seek(0xD6B5A); // where action items start
- // FIXME Figure out all the actions definitions
+ // FIXME Figure out all the actions items
for (uint32 a = 0; a < _worldStats->_numActions; a++) {
ActionItem action;
memset(&action, 0, sizeof(ActionItem));
@@ -317,11 +400,10 @@ void SceneResource::loadGamePolygons(Common::SeekableReadStream *stream) {
poly.boundingRect.right = stream->readUint32LE() & 0xFFFF;
poly.boundingRect.bottom = stream->readUint32LE() & 0xFFFF;
- _gamePolygons->_Polygons.push_back(poly);
+ _gamePolygons->_polygons.push_back(poly);
}
}
-// FIXME: load necessary Action List content
void SceneResource::loadActionList(Common::SeekableReadStream *stream) {
_actionList = new ActionList;
@@ -357,7 +439,7 @@ void SceneResource::loadActionList(Common::SeekableReadStream *stream) {
action.field_1BB0 = stream->readUint32LE();
action.counter = stream->readUint32LE();
- _actionList->_Actions.push_back(action);
+ _actionList->_actions.push_back(action);
}
}
diff --git a/engines/asylum/sceneres.h b/engines/asylum/sceneres.h
index e430fc1bf8..c8ca0e4046 100644
--- a/engines/asylum/sceneres.h
+++ b/engines/asylum/sceneres.h
@@ -194,11 +194,65 @@ typedef struct CommonResources {
uint32 field_7C;
} CommonResources;
+typedef struct ActorItem {
+ uint32 x0;
+ uint32 y0;
+ uint32 grResId;
+ uint32 field_C;
+ uint32 frameNum;
+ uint32 frameCount;
+ uint32 x1;
+ uint32 y1;
+ uint32 x2;
+ uint32 y2;
+ Common::Rect boundingRect;
+ uint32 direction;
+ uint32 field_3C;
+ uint32 field_40;
+ uint32 field_44;
+ uint32 field_48;
+ uint32 flags;
+ uint32 field_50;
+ uint32 field_54;
+ uint32 field_58;
+ uint32 field_5C;
+ uint32 field_60;
+ uint32 actionIdx3;
+ // TODO field_68 till field_617
+ uint32 reaction[8];
+ uint32 field_638;
+ uint32 field_63C;
+ uint32 field_640;
+ uint32 field_644;
+ uint32 field_648;
+ uint32 field_64C;
+ uint32 field_650;
+ uint32 grResTable[55];
+ char name[256];
+ uint32 field_830[20];
+ uint32 field_880[20];
+ uint32 field_8D0[20];
+ uint32 actionIdx2;
+ uint32 field_924;
+ uint32 tickValue1;
+ uint32 field_92C;
+ uint32 flags2;
+ uint32 field_934;
+ uint32 field_938;
+ uint32 soundResId;
+ // TODO field_940 till field_978
+ uint32 actionIdx1;
+ // TODO field_980 till field_9A0
+} ActorItem;
class WorldStats {
public:
WorldStats() {};
- virtual ~WorldStats() {};
+ virtual ~WorldStats() {
+ _barriers.clear();
+ _actors.clear();
+ _actions.clear();
+ };
uint32 _size;
uint32 _numEntries;
@@ -248,7 +302,9 @@ public:
// FIXME: Investigate if we need to actually reserve maxsize for this arrays.
// It always have that size under scene file and they are always save in savegames.
Common::Array<BarrierItem> _barriers; // maxsize 400
+ Common::Array<ActorItem> _actors; // maxsize 50
+ // TODO add rest fields
Common::Array<ActionItem> _actions; // maxsize 400
}; // end of class WorldStats
@@ -262,12 +318,14 @@ typedef struct PolyDefinitions{
class GamePolygons {
public:
GamePolygons() {};
- virtual ~GamePolygons() {};
+ virtual ~GamePolygons() {
+ _polygons.clear();
+ };
uint32 _size;
uint32 _numEntries;
- Common::Array<PolyDefinitions> _Polygons;
+ Common::Array<PolyDefinitions> _polygons;
}; // end of class GamePolygons
@@ -295,12 +353,14 @@ typedef struct ActionDefinitions {
class ActionList {
public:
ActionList() {};
- virtual ~ActionList() {};
+ virtual ~ActionList() {
+ _actions.clear();
+ };
uint32 _size;
uint32 _numEntries;
- Common::Array<ActionDefinitions> _Actions;
+ Common::Array<ActionDefinitions> _actions;
}; // end of class ActionList
} // end of namespace Asylum
Commit: d4c8e85b8a1c0f8958aa63f0cf5c87f6b81efe52
https://github.com/scummvm/scummvm/commit/d4c8e85b8a1c0f8958aa63f0cf5c87f6b81efe52
Author: Filippos Karapetis (md5 at scummvm.org)
Date: 2021-05-17T15:35:28+02:00
Commit Message:
ASYLUM: Some initial code for the "play speech" script command
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@206 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/scene.cpp
engines/asylum/scene.h
diff --git a/engines/asylum/scene.cpp b/engines/asylum/scene.cpp
index 4819c3fb76..0a4815a0ab 100644
--- a/engines/asylum/scene.cpp
+++ b/engines/asylum/scene.cpp
@@ -38,6 +38,7 @@ Scene::Scene(Screen *screen, Sound *sound, uint8 sceneIdx): _screen(screen), _so
if (_sceneResource->load(_sceneIdx)) {
_text = new Text(_screen);
_resPack = new ResourcePack(sceneIdx);
+ _speechPack = new ResourcePack(3);
_sceneResource->getMainActor()->setResourcePack(_resPack);
@@ -62,6 +63,7 @@ Scene::~Scene() {
delete _cursorResource;
delete _bgResource;
delete _musPack;
+ delete _speechPack;
delete _resPack;
delete _text;
delete _sceneResource;
@@ -236,6 +238,16 @@ void Scene::update() {
// Play the SFX associated with the hotspot
// TODO: The hotspot sound res id is 0, seems like we need to get it from the associated action list
//_sound->playSfx(_resPack, worldStats->_actors[a].soundResId);
+
+ // TODO: This should all be moved to a script related class
+ ActionDefinitions actionDefs = _sceneResource->getActionList()->_actions[worldStats->_actions[a].actionListIdx1];
+ for (int command = 0; command < 161; command++) {
+ if (actionDefs.commands[command].opcode == 65) { // play voice
+ _sound->playSfx(_speechPack, actionDefs.commands[command].param1);
+ // TODO: param2 (usually 1) -> number of loops?
+ }
+ }
+ break;
}
}
}
diff --git a/engines/asylum/scene.h b/engines/asylum/scene.h
index aa22266af0..0545850dda 100644
--- a/engines/asylum/scene.h
+++ b/engines/asylum/scene.h
@@ -66,6 +66,7 @@ private:
Text *_text;
SceneResource *_sceneResource;
ResourcePack *_resPack;
+ ResourcePack *_speechPack;
ResourcePack *_musPack;
GraphicResource *_bgResource;
GraphicResource *_cursorResource;
Commit: c8a173e5eb6b130c3181225fa0305b4ff47f6d6d
https://github.com/scummvm/scummvm/commit/c8a173e5eb6b130c3181225fa0305b4ff47f6d6d
Author: Joseph Davies (deledrius at gmail.com)
Date: 2021-05-17T15:35:28+02:00
Commit Message:
ASYLUM: Fixed laggy cursor by removing exponential delay inside event loop. Changed delay to match apparent animation speed of original.
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@207 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/asylum.cpp
diff --git a/engines/asylum/asylum.cpp b/engines/asylum/asylum.cpp
index b9059268d8..0daf372d05 100644
--- a/engines/asylum/asylum.cpp
+++ b/engines/asylum/asylum.cpp
@@ -103,7 +103,7 @@ Common::Error AsylumEngine::go() {
while (!shouldQuit()) {
checkForEvent(true);
- waitForTimer(60);
+ waitForTimer(55);
}
return Common::kNoError;
@@ -116,7 +116,6 @@ void AsylumEngine::waitForTimer(int msec_delay) {
checkForEvent(false);
checkForDelayedVideo();
_system->updateScreen();
- _system->delayMillis(10);
}
}
Commit: b22dab25e65557cb71b7e33d3449bbf691e55932
https://github.com/scummvm/scummvm/commit/b22dab25e65557cb71b7e33d3449bbf691e55932
Author: Joseph Davies (deledrius at gmail.com)
Date: 2021-05-17T15:35:29+02:00
Commit Message:
ASYLUM: Fixed order for Polygon point data.
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@208 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/sceneres.cpp
diff --git a/engines/asylum/sceneres.cpp b/engines/asylum/sceneres.cpp
index 5b75c1ca6d..2930e30137 100644
--- a/engines/asylum/sceneres.cpp
+++ b/engines/asylum/sceneres.cpp
@@ -390,8 +390,8 @@ void SceneResource::loadGamePolygons(Common::SeekableReadStream *stream) {
if (poly.numPoints > 0)
poly.points = new Common::Point[poly.numPoints];
for (uint32 i = 0; i < poly.numPoints; i++) {
- poly.points[i].y = stream->readUint32LE() & 0xFFFF;
poly.points[i].x = stream->readUint32LE() & 0xFFFF;
+ poly.points[i].y = stream->readUint32LE() & 0xFFFF;
}
stream->skip((Polygons_MAXSIZE - poly.numPoints) * 8);
Commit: b8451e3c78b99b5589a11e0210e364b7d259af49
https://github.com/scummvm/scummvm/commit/b8451e3c78b99b5589a11e0210e364b7d259af49
Author: Joseph Davies (deledrius at gmail.com)
Date: 2021-05-17T15:35:29+02:00
Commit Message:
ASYLUM: Fixed minor error in blitting code causing image corruption in surfaces drawn partially offscreen.
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@209 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/screen.cpp
diff --git a/engines/asylum/screen.cpp b/engines/asylum/screen.cpp
index b2fdbac2c1..57a13e9691 100644
--- a/engines/asylum/screen.cpp
+++ b/engines/asylum/screen.cpp
@@ -58,7 +58,7 @@ void Screen::copyToBackBufferWithTransparency(byte *buffer, int pitch, int x, in
for (int curY = 0; curY < height; curY++) {
for (int curX = 0; curX < width; curX++) {
- if (buffer[curX + curY * width] != 0) {
+ if (buffer[curX + curY * pitch] != 0) {
dest[x + curX + (y + curY) * 640] = buffer[curX + curY * pitch];
}
}
@@ -74,7 +74,7 @@ void Screen::copyRectToScreenWithTransparency(byte *buffer, int pitch, int x, in
for (int curY = 0; curY < height; curY++) {
for (int curX = 0; curX < width; curX++) {
- if (buffer[curX + curY * width] != 0) {
+ if (buffer[curX + curY * pitch] != 0) {
screenBuffer[x + curX + (y + curY) * 640] = buffer[curX + curY * pitch];
}
}
Commit: e85dbe333c397313ce498ecfc0ae678c25b2a330
https://github.com/scummvm/scummvm/commit/e85dbe333c397313ce498ecfc0ae678c25b2a330
Author: Joseph Davies (deledrius at gmail.com)
Date: 2021-05-17T15:35:29+02:00
Commit Message:
ASYLUM: Modified ShowPolygons to draw Polygons rather than bounding boxes. Fixed mouse click position detection to incorporate viewport offset.
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@210 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/scene.cpp
diff --git a/engines/asylum/scene.cpp b/engines/asylum/scene.cpp
index 0a4815a0ab..a8dfb144d0 100644
--- a/engines/asylum/scene.cpp
+++ b/engines/asylum/scene.cpp
@@ -207,6 +207,7 @@ void Scene::update() {
updateBarrier(_screen, _resPack, 7); // the "crazy prisoner banging head" animation
//updateBarrier(_screen, _resPack, 8); // going up the ladder
//updateBarrier(_screen, _resPack, 9); // going down the ladder
+ //updateBarrier(_screen, _resPack, 59); // Wobbly Guy
// TODO
if (g_debugPolygons)
@@ -215,7 +216,7 @@ void Scene::update() {
// Update cursor if it's in a hotspot
for (uint32 p = 0; p < _sceneResource->getGamePolygons()->_numEntries; p++) {
PolyDefinitions poly = _sceneResource->getGamePolygons()->_polygons[p];
- if (poly.boundingRect.contains(_mouseX, _mouseY)) {
+ if (poly.boundingRect.contains(_mouseX + _startX, _mouseY + _startY)) {
curHotspot = (int32)p;
updateCursor();
break;
@@ -280,9 +281,11 @@ void Scene::copyToBackBufferClipped(Graphics::Surface *surface, int x, int y) {
animRect.translate(-_startX, -_startY);
int startX = animRect.right == 640 ? 0 : surface->w - animRect.width();
+ int startY = animRect.bottom == 480 ? 0 : surface->h - animRect.height();
+
_screen->copyToBackBufferWithTransparency(((byte*)surface->pixels) +
- (surface->h - animRect.height()) *
- surface->pitch + startX,
+ startY * surface->pitch +
+ startX * surface->bytesPerPixel,
surface->pitch,
animRect.left,
animRect.top,
@@ -299,10 +302,7 @@ void Scene::updateBarrier(Screen *screen, ResourcePack *res, uint8 barrierIndex)
#if 0
// DEBUG bounding box
// FIXME this should be a generic method which draws for an entire graphicResource and not for single graphicFrames
- fra->surface.drawLine(barrier.boundingRect.top, barrier.boundingRect.left, barrier.boundingRect.top, barrier.boundingRect.right, 0xFFFFFF);
- fra->surface.drawLine(barrier.boundingRect.top, barrier.boundingRect.right-1, barrier.boundingRect.bottom, barrier.boundingRect.right-1, 0xFFFFFF);
- fra->surface.drawLine(barrier.boundingRect.bottom-1, barrier.boundingRect.left, barrier.boundingRect.bottom-1, barrier.boundingRect.right, 0xFFFFFF);
- fra->surface.drawLine(barrier.boundingRect.top, barrier.boundingRect.left, barrier.boundingRect.bottom, barrier.boundingRect.left, 0xFFFFFF);
+ fra->surface.frameRect(barrier.boundingRect, 0xFF);
#endif
copyToBackBufferClipped(&fra->surface, barrier.x, barrier.y);
@@ -321,19 +321,25 @@ void Scene::updateBarrier(Screen *screen, ResourcePack *res, uint8 barrierIndex)
// POLYGONS DEBUG
void Scene::ShowPolygons() {
for (uint32 p = 0; p < _sceneResource->getGamePolygons()->_numEntries; p++) {
- Graphics::Surface sur;
+ Graphics::Surface surface;
PolyDefinitions poly = _sceneResource->getGamePolygons()->_polygons[p];
-
- sur.create(poly.boundingRect.right - poly.boundingRect.left, poly.boundingRect.bottom - poly.boundingRect.top, 1);
+ surface.create(poly.boundingRect.right - poly.boundingRect.left + 1, poly.boundingRect.bottom - poly.boundingRect.top + 1, 1);
+ // Draw all lines in Polygon
for (uint32 i=0; i < poly.numPoints; i++) {
- sur.drawLine(poly.points[i].x - poly.boundingRect.left, poly.points[i].y - poly.boundingRect.top,
- poly.points[i].x - poly.boundingRect.left + 1, poly.points[i].y - poly.boundingRect.top + 1, 0xFF);
+ surface.drawLine(
+ poly.points[i].x - poly.boundingRect.left,
+ poly.points[i].y - poly.boundingRect.top,
+ poly.points[(i+1) % poly.numPoints].x - poly.boundingRect.left,
+ poly.points[(i+1) % poly.numPoints].y - poly.boundingRect.top, 0xFF);
}
- sur.frameRect(Common::Rect(0, 0, sur.w, sur.h), 0xFF);
+
+ // Draw Bounding Box
+ //surface.frameRect(Common::Rect(0, 0, surface.w, surface.h), 0xFF);
+
+ copyToBackBufferClipped(&surface, poly.boundingRect.left, poly.boundingRect.top);
- copyToBackBufferClipped(&sur, poly.boundingRect.left, poly.boundingRect.top);
- sur.free();
+ surface.free();
}
}
Commit: c578b8d2ed147834d50c8d95f6813fee782dd348
https://github.com/scummvm/scummvm/commit/c578b8d2ed147834d50c8d95f6813fee782dd348
Author: Joseph Davies (deledrius at gmail.com)
Date: 2021-05-17T15:35:29+02:00
Commit Message:
ASYLUM: Added extra logic to handle large (multi-screen) polygons.
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@211 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/scene.cpp
diff --git a/engines/asylum/scene.cpp b/engines/asylum/scene.cpp
index a8dfb144d0..81a85235ba 100644
--- a/engines/asylum/scene.cpp
+++ b/engines/asylum/scene.cpp
@@ -282,6 +282,11 @@ void Scene::copyToBackBufferClipped(Graphics::Surface *surface, int x, int y) {
int startX = animRect.right == 640 ? 0 : surface->w - animRect.width();
int startY = animRect.bottom == 480 ? 0 : surface->h - animRect.height();
+
+ if(surface->w > 640)
+ startX = _startX;
+ if(surface->h > 480)
+ startY = _startY;
_screen->copyToBackBufferWithTransparency(((byte*)surface->pixels) +
startY * surface->pitch +
Commit: 3b8e1235f5e1a4216749c205235455cb807be7b8
https://github.com/scummvm/scummvm/commit/3b8e1235f5e1a4216749c205235455cb807be7b8
Author: Joseph Davies (deledrius at gmail.com)
Date: 2021-05-17T15:35:29+02:00
Commit Message:
ASYLUM: Renamed previously unknown variable for action script length.
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@214 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/sceneres.cpp
engines/asylum/sceneres.h
diff --git a/engines/asylum/sceneres.cpp b/engines/asylum/sceneres.cpp
index 2930e30137..a6da1e2cba 100644
--- a/engines/asylum/sceneres.cpp
+++ b/engines/asylum/sceneres.cpp
@@ -420,7 +420,7 @@ void SceneResource::loadActionList(Common::SeekableReadStream *stream) {
ActionCommand command;
memset(&command, 0, sizeof(ActionCommand));
- command.unknown = stream->readUint32LE();
+ command.numLines = stream->readUint32LE();
command.opcode = stream->readUint32LE(); // command type
command.param1 = stream->readUint32LE(); // command parameters
command.param2 = stream->readUint32LE();
diff --git a/engines/asylum/sceneres.h b/engines/asylum/sceneres.h
index c8ca0e4046..f99a5fae8d 100644
--- a/engines/asylum/sceneres.h
+++ b/engines/asylum/sceneres.h
@@ -330,7 +330,7 @@ public:
typedef struct ActionCommand {
- uint32 unknown;
+ uint32 numLines; // Only set on the first line of each script
uint32 opcode;
uint32 param1;
uint32 param2;
Commit: 9c7033c6a080254b9289657860576cd685c947ac
https://github.com/scummvm/scummvm/commit/9c7033c6a080254b9289657860576cd685c947ac
Author: Alex Bevilacqua (alexbevi at gmail.com)
Date: 2021-05-17T15:35:29+02:00
Commit Message:
ASYLUM: * cleanup
* renamed all public variables that were underscore-prefixed (unless these were meant to be controlled via getter/setters, but I doubt it :P)
* silenced a warning in screen.cpp
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@215 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/scene.cpp
engines/asylum/sceneres.cpp
engines/asylum/sceneres.h
engines/asylum/screen.cpp
diff --git a/engines/asylum/scene.cpp b/engines/asylum/scene.cpp
index 81a85235ba..3a8bf092d6 100644
--- a/engines/asylum/scene.cpp
+++ b/engines/asylum/scene.cpp
@@ -46,10 +46,10 @@ Scene::Scene(Screen *screen, Sound *sound, uint8 sceneIdx): _screen(screen), _so
sprintf(musPackFileName, "mus.%03d", sceneIdx);
_musPack = new ResourcePack(musPackFileName);
- _bgResource = new GraphicResource(_resPack, _sceneResource->getWorldStats()->_commonRes.backgroundImage);
+ _bgResource = new GraphicResource(_resPack, _sceneResource->getWorldStats()->commonRes.backgroundImage);
}
- _cursorResource = new GraphicResource(_resPack, _sceneResource->getWorldStats()->_commonRes.curMagnifyingGlass);
+ _cursorResource = new GraphicResource(_resPack, _sceneResource->getWorldStats()->commonRes.curMagnifyingGlass);
_background = 0;
_startX = _startY = 0;
@@ -70,7 +70,7 @@ Scene::~Scene() {
}
void Scene::enterScene() {
- _screen->setPalette(_resPack, _sceneResource->getWorldStats()->_commonRes.palette);
+ _screen->setPalette(_resPack, _sceneResource->getWorldStats()->commonRes.palette);
_background = _bgResource->getFrame(0);
_screen->copyToBackBuffer(((byte *)_background->surface.pixels) + _startY * _background->surface.w + _startX, _background->surface.w, 0, 0, 640, 480);
@@ -103,7 +103,7 @@ void Scene::handleEvent(Common::Event *event, bool doUpdate) {
break;
case Common::EVENT_RBUTTONUP:
delete _cursorResource;
- _cursorResource = new GraphicResource(_resPack, _sceneResource->getWorldStats()->_commonRes.curMagnifyingGlass);
+ _cursorResource = new GraphicResource(_resPack, _sceneResource->getWorldStats()->commonRes.curMagnifyingGlass);
_rightButton = false;
break;
case Common::EVENT_RBUTTONDOWN:
@@ -145,28 +145,28 @@ void Scene::update() {
// Change cursor
switch (mainActor->getCurrentAction()) {
case kWalkN:
- newCursor = worldStats->_commonRes.curScrollUp;
+ newCursor = worldStats->commonRes.curScrollUp;
break;
case kWalkNE:
- newCursor = worldStats->_commonRes.curScrollUpRight;
+ newCursor = worldStats->commonRes.curScrollUpRight;
break;
case kWalkNW:
- newCursor = worldStats->_commonRes.curScrollUpLeft;
+ newCursor = worldStats->commonRes.curScrollUpLeft;
break;
case kWalkS:
- newCursor = worldStats->_commonRes.curScrollDown;
+ newCursor = worldStats->commonRes.curScrollDown;
break;
case kWalkSE:
- newCursor = worldStats->_commonRes.curScrollDownRight;
+ newCursor = worldStats->commonRes.curScrollDownRight;
break;
case kWalkSW:
- newCursor = worldStats->_commonRes.curScrollDownLeft;
+ newCursor = worldStats->commonRes.curScrollDownLeft;
break;
case kWalkW:
- newCursor = worldStats->_commonRes.curScrollLeft;
+ newCursor = worldStats->commonRes.curScrollLeft;
break;
case kWalkE:
- newCursor = worldStats->_commonRes.curScrollRight;
+ newCursor = worldStats->commonRes.curScrollRight;
break;
}
@@ -214,8 +214,8 @@ void Scene::update() {
ShowPolygons();
// Update cursor if it's in a hotspot
- for (uint32 p = 0; p < _sceneResource->getGamePolygons()->_numEntries; p++) {
- PolyDefinitions poly = _sceneResource->getGamePolygons()->_polygons[p];
+ for (uint32 p = 0; p < _sceneResource->getGamePolygons()->numEntries; p++) {
+ PolyDefinitions poly = _sceneResource->getGamePolygons()->polygons[p];
if (poly.boundingRect.contains(_mouseX + _startX, _mouseY + _startY)) {
curHotspot = (int32)p;
updateCursor();
@@ -227,21 +227,21 @@ void Scene::update() {
_leftClick = false;
if (curHotspot >= 0) {
- for (uint32 a = 0; a < worldStats->_numActions; a++) {
- if (worldStats->_actions[a].polyIdx == curHotspot) {
+ for (uint32 a = 0; a < worldStats->numActions; a++) {
+ if (worldStats->actions[a].polyIdx == curHotspot) {
printf("Hotspot: \"%s\", poly %d, action lists %d/%d, action type %d, sound res %d\n",
- worldStats->_actions[a].name,
- worldStats->_actions[a].polyIdx,
- worldStats->_actions[a].actionListIdx1,
- worldStats->_actions[a].actionListIdx2,
- worldStats->_actions[a].actionType,
- worldStats->_actions[a].soundResId);
+ worldStats->actions[a].name,
+ worldStats->actions[a].polyIdx,
+ worldStats->actions[a].actionListIdx1,
+ worldStats->actions[a].actionListIdx2,
+ worldStats->actions[a].actionType,
+ worldStats->actions[a].soundResId);
// Play the SFX associated with the hotspot
// TODO: The hotspot sound res id is 0, seems like we need to get it from the associated action list
//_sound->playSfx(_resPack, worldStats->_actors[a].soundResId);
// TODO: This should all be moved to a script related class
- ActionDefinitions actionDefs = _sceneResource->getActionList()->_actions[worldStats->_actions[a].actionListIdx1];
+ ActionDefinitions actionDefs = _sceneResource->getActionList()->actions[worldStats->actions[a].actionListIdx1];
for (int command = 0; command < 161; command++) {
if (actionDefs.commands[command].opcode == 65) { // play voice
_sound->playSfx(_speechPack, actionDefs.commands[command].param1);
@@ -300,7 +300,7 @@ void Scene::copyToBackBufferClipped(Graphics::Surface *surface, int x, int y) {
}
void Scene::updateBarrier(Screen *screen, ResourcePack *res, uint8 barrierIndex) {
- BarrierItem barrier = _sceneResource->getWorldStats()->_barriers[barrierIndex];
+ BarrierItem barrier = _sceneResource->getWorldStats()->barriers[barrierIndex];
GraphicResource *gra = new GraphicResource(res, barrier.resId);
GraphicFrame *fra = gra->getFrame(barrier.tickCount);
@@ -318,16 +318,16 @@ void Scene::updateBarrier(Screen *screen, ResourcePack *res, uint8 barrierIndex)
barrier.tickCount = barrier.frameIdx;
}
- _sceneResource->getWorldStats()->_barriers[barrierIndex] = barrier;
+ _sceneResource->getWorldStats()->barriers[barrierIndex] = barrier;
delete gra;
}
// POLYGONS DEBUG
void Scene::ShowPolygons() {
- for (uint32 p = 0; p < _sceneResource->getGamePolygons()->_numEntries; p++) {
+ for (uint32 p = 0; p < _sceneResource->getGamePolygons()->numEntries; p++) {
Graphics::Surface surface;
- PolyDefinitions poly = _sceneResource->getGamePolygons()->_polygons[p];
+ PolyDefinitions poly = _sceneResource->getGamePolygons()->polygons[p];
surface.create(poly.boundingRect.right - poly.boundingRect.left + 1, poly.boundingRect.bottom - poly.boundingRect.top + 1, 1);
// Draw all lines in Polygon
diff --git a/engines/asylum/sceneres.cpp b/engines/asylum/sceneres.cpp
index a6da1e2cba..c4ca877060 100644
--- a/engines/asylum/sceneres.cpp
+++ b/engines/asylum/sceneres.cpp
@@ -33,8 +33,8 @@ SceneResource::SceneResource() {
SceneResource::~SceneResource() {
delete _worldStats;
delete _mainActor;
- for(uint i=0; i< _gamePolygons->_numEntries; i++) {
- delete[] _gamePolygons->_polygons[i].points;
+ for(uint i=0; i< _gamePolygons->numEntries; i++) {
+ delete[] _gamePolygons->polygons[i].points;
}
delete _gamePolygons;
delete _actionList;
@@ -78,109 +78,109 @@ bool SceneResource::load(uint8 sceneIdx) {
void SceneResource::loadWorldStats(Common::SeekableReadStream *stream) {
_worldStats = new WorldStats;
- _worldStats->_size = stream->readUint32LE();
- _worldStats->_numEntries = stream->readUint32LE();
+ _worldStats->size = stream->readUint32LE();
+ _worldStats->numEntries = stream->readUint32LE();
- _worldStats->_numChapter = stream->readUint32LE();
- _worldStats->_xLeft = stream->readUint32LE();
- _worldStats->_yTop = stream->readUint32LE();
- _worldStats->_boundingRect.left = stream->readUint32LE() & 0xFFFF;
- _worldStats->_boundingRect.top = stream->readUint32LE() & 0xFFFF;
- _worldStats->_boundingRect.right = stream->readUint32LE() & 0xFFFF;
- _worldStats->_boundingRect.bottom = stream->readUint32LE() & 0xFFFF;
+ _worldStats->numChapter = stream->readUint32LE();
+ _worldStats->xLeft = stream->readUint32LE();
+ _worldStats->yTop = stream->readUint32LE();
+ _worldStats->boundingRect.left = stream->readUint32LE() & 0xFFFF;
+ _worldStats->boundingRect.top = stream->readUint32LE() & 0xFFFF;
+ _worldStats->boundingRect.right = stream->readUint32LE() & 0xFFFF;
+ _worldStats->boundingRect.bottom = stream->readUint32LE() & 0xFFFF;
// read common graphic resources
- _worldStats->_commonRes.backgroundImage = stream->readUint32LE();
- _worldStats->_commonRes.curScrollUp = stream->readUint32LE();
- _worldStats->_commonRes.curScrollUpLeft = stream->readUint32LE();
- _worldStats->_commonRes.curScrollLeft = stream->readUint32LE();
- _worldStats->_commonRes.curScrollDownLeft = stream->readUint32LE();
- _worldStats->_commonRes.curScrollDown = stream->readUint32LE();
- _worldStats->_commonRes.curScrollDownRight = stream->readUint32LE();
- _worldStats->_commonRes.curScrollRight = stream->readUint32LE();
- _worldStats->_commonRes.curScrollUpRight = stream->readUint32LE();
- _worldStats->_commonRes.curHand = stream->readUint32LE();
- _worldStats->_commonRes.curMagnifyingGlass = stream->readUint32LE();
- _worldStats->_commonRes.curTalkNCP = stream->readUint32LE();
- _worldStats->_commonRes.curGrabPointer = stream->readUint32LE();
- _worldStats->_commonRes.curTalkNCP2 = stream->readUint32LE();
- _worldStats->_commonRes.field_54 = stream->readUint32LE();
- _worldStats->_commonRes.field_58 = stream->readUint32LE();
- _worldStats->_commonRes.field_5C = stream->readUint32LE();
- _worldStats->_commonRes.palette = stream->readUint32LE();
- _worldStats->_commonRes.cellShadeMask1 = stream->readUint32LE();
- _worldStats->_commonRes.cellShadeMask2 = stream->readUint32LE();
- _worldStats->_commonRes.cellShadeMask3 = stream->readUint32LE();
- _worldStats->_commonRes.unused = stream->readUint32LE();
- _worldStats->_commonRes.smallCurUp = stream->readUint32LE();
- _worldStats->_commonRes.smallCurDown = stream->readUint32LE();
- _worldStats->_commonRes.field_7C = stream->readUint32LE();
-
- _worldStats->_width = stream->readUint32LE();
- _worldStats->_height = stream->readUint32LE();
- _worldStats->_field_88 = stream->readUint32LE();
- _worldStats->_field_8C = stream->readUint32LE();
- _worldStats->_numActions = stream->readUint32LE();
- _worldStats->_numBarriers = stream->readUint32LE();
- _worldStats->_field_98 = stream->readUint32LE();
- _worldStats->_field_9C = stream->readUint32LE();
- _worldStats->_field_A0 = stream->readUint32LE();
- _worldStats->_field_A4 = stream->readUint32LE();
- _worldStats->_field_A8 = stream->readUint32LE();
- _worldStats->_field_AC = stream->readUint32LE();
- _worldStats->_field_B0 = stream->readUint32LE();
- _worldStats->_numActors = stream->readUint32LE();
- _worldStats->_stereoReversedFlag = stream->readUint32LE();
+ _worldStats->commonRes.backgroundImage = stream->readUint32LE();
+ _worldStats->commonRes.curScrollUp = stream->readUint32LE();
+ _worldStats->commonRes.curScrollUpLeft = stream->readUint32LE();
+ _worldStats->commonRes.curScrollLeft = stream->readUint32LE();
+ _worldStats->commonRes.curScrollDownLeft = stream->readUint32LE();
+ _worldStats->commonRes.curScrollDown = stream->readUint32LE();
+ _worldStats->commonRes.curScrollDownRight = stream->readUint32LE();
+ _worldStats->commonRes.curScrollRight = stream->readUint32LE();
+ _worldStats->commonRes.curScrollUpRight = stream->readUint32LE();
+ _worldStats->commonRes.curHand = stream->readUint32LE();
+ _worldStats->commonRes.curMagnifyingGlass = stream->readUint32LE();
+ _worldStats->commonRes.curTalkNCP = stream->readUint32LE();
+ _worldStats->commonRes.curGrabPointer = stream->readUint32LE();
+ _worldStats->commonRes.curTalkNCP2 = stream->readUint32LE();
+ _worldStats->commonRes.field_54 = stream->readUint32LE();
+ _worldStats->commonRes.field_58 = stream->readUint32LE();
+ _worldStats->commonRes.field_5C = stream->readUint32LE();
+ _worldStats->commonRes.palette = stream->readUint32LE();
+ _worldStats->commonRes.cellShadeMask1 = stream->readUint32LE();
+ _worldStats->commonRes.cellShadeMask2 = stream->readUint32LE();
+ _worldStats->commonRes.cellShadeMask3 = stream->readUint32LE();
+ _worldStats->commonRes.unused = stream->readUint32LE();
+ _worldStats->commonRes.smallCurUp = stream->readUint32LE();
+ _worldStats->commonRes.smallCurDown = stream->readUint32LE();
+ _worldStats->commonRes.field_7C = stream->readUint32LE();
+
+ _worldStats->width = stream->readUint32LE();
+ _worldStats->height = stream->readUint32LE();
+ _worldStats->field_88 = stream->readUint32LE();
+ _worldStats->field_8C = stream->readUint32LE();
+ _worldStats->numActions = stream->readUint32LE();
+ _worldStats->numBarriers = stream->readUint32LE();
+ _worldStats->field_98 = stream->readUint32LE();
+ _worldStats->field_9C = stream->readUint32LE();
+ _worldStats->field_A0 = stream->readUint32LE();
+ _worldStats->field_A4 = stream->readUint32LE();
+ _worldStats->field_A8 = stream->readUint32LE();
+ _worldStats->field_AC = stream->readUint32LE();
+ _worldStats->field_B0 = stream->readUint32LE();
+ _worldStats->numActors = stream->readUint32LE();
+ _worldStats->stereoReversedFlag = stream->readUint32LE();
for(int r=0; r < 6; r++) {
- _worldStats->_sceneRects[r].left = stream->readUint32LE() & 0xFFFF;
- _worldStats->_sceneRects[r].top = stream->readUint32LE() & 0xFFFF;
- _worldStats->_sceneRects[r].right = stream->readUint32LE() & 0xFFFF;
- _worldStats->_sceneRects[r].bottom = stream->readUint32LE() & 0xFFFF;
+ _worldStats->sceneRects[r].left = stream->readUint32LE() & 0xFFFF;
+ _worldStats->sceneRects[r].top = stream->readUint32LE() & 0xFFFF;
+ _worldStats->sceneRects[r].right = stream->readUint32LE() & 0xFFFF;
+ _worldStats->sceneRects[r].bottom = stream->readUint32LE() & 0xFFFF;
}
- _worldStats->_sceneRectIdx = stream->readByte();
- _worldStats->_field_11D[0] = stream->readByte();
- _worldStats->_field_11D[1] = stream->readByte();
- _worldStats->_field_11D[2] = stream->readByte();
+ _worldStats->sceneRectIdx = stream->readByte();
+ _worldStats->field_11D[0] = stream->readByte();
+ _worldStats->field_11D[1] = stream->readByte();
+ _worldStats->field_11D[2] = stream->readByte();
- _worldStats->_field_120 = stream->readUint32LE();
- _worldStats->_actionListIdx = stream->readUint32LE();
+ _worldStats->field_120 = stream->readUint32LE();
+ _worldStats->actionListIdx = stream->readUint32LE();
for(int gr=0; gr < 100; gr++) {
- _worldStats->_grResId[gr] = stream->readUint32LE();
+ _worldStats->grResId[gr] = stream->readUint32LE();
}
- _worldStats->_sceneTitleGrResId = stream->readUint32LE();
- _worldStats->_sceneTitlePalResId = stream->readUint32LE();
- _worldStats->_actorType = stream->readUint32LE();
+ _worldStats->sceneTitleGrResId = stream->readUint32LE();
+ _worldStats->sceneTitlePalResId = stream->readUint32LE();
+ _worldStats->actorType = stream->readUint32LE();
for(int s=0; s < 50; s++) {
- _worldStats->_soundResId[s] = stream->readUint32LE();
+ _worldStats->soundResId[s] = stream->readUint32LE();
}
for(int s=0; s < 15; s++) {
- _worldStats->_ambientSounds[s].field_0 = stream->readUint32LE();
- _worldStats->_ambientSounds[s].flags = stream->readUint32LE();
- _worldStats->_ambientSounds[s].resId = stream->readUint32LE();
- _worldStats->_ambientSounds[s].field_C = stream->readUint32LE();
- _worldStats->_ambientSounds[s].field_10 = stream->readUint32LE();
- _worldStats->_ambientSounds[s].field_14 = stream->readUint32LE();
+ _worldStats->ambientSounds[s].field_0 = stream->readUint32LE();
+ _worldStats->ambientSounds[s].flags = stream->readUint32LE();
+ _worldStats->ambientSounds[s].resId = stream->readUint32LE();
+ _worldStats->ambientSounds[s].field_C = stream->readUint32LE();
+ _worldStats->ambientSounds[s].field_10 = stream->readUint32LE();
+ _worldStats->ambientSounds[s].field_14 = stream->readUint32LE();
for(int i=0; i < 6; i++)
- _worldStats->_ambientSounds[s].flagNum[i] = stream->readUint32LE();
+ _worldStats->ambientSounds[s].flagNum[i] = stream->readUint32LE();
- _worldStats->_ambientSounds[s].x = stream->readUint32LE();
- _worldStats->_ambientSounds[s].y = stream->readUint32LE();
+ _worldStats->ambientSounds[s].x = stream->readUint32LE();
+ _worldStats->ambientSounds[s].y = stream->readUint32LE();
}
- _worldStats->_numAmbientSound = stream->readUint32LE();
+ _worldStats->numAmbientSound = stream->readUint32LE();
- _worldStats->_musicStatus = stream->readUint32LE();
- _worldStats->_musicCurrentResId = stream->readUint32LE();
- _worldStats->_musicFlag = stream->readUint32LE();
- _worldStats->_musicResId = stream->readUint32LE();
- _worldStats->_musicStatusExt = stream->readUint32LE();
+ _worldStats->musicStatus = stream->readUint32LE();
+ _worldStats->musicCurrentResId = stream->readUint32LE();
+ _worldStats->musicFlag = stream->readUint32LE();
+ _worldStats->musicResId = stream->readUint32LE();
+ _worldStats->musicStatusExt = stream->readUint32LE();
- for (uint32 a = 0; a < _worldStats->_numBarriers; a++) {
+ for (uint32 a = 0; a < _worldStats->numBarriers; a++) {
int i;
BarrierItem barrier;
@@ -251,13 +251,13 @@ void SceneResource::loadWorldStats(Common::SeekableReadStream *stream) {
barrier.soundResId = stream->readUint32LE();
barrier.field_6A4 = stream->readUint32LE();
- _worldStats->_barriers.push_back(barrier);
+ _worldStats->barriers.push_back(barrier);
}
// need to jump all unused barriers data to where actors data start
stream->seek(0xA6D7A);
- for (uint32 a = 0; a < _worldStats->_numActors; a++) {
+ for (uint32 a = 0; a < _worldStats->numActors; a++) {
int i;
ActorItem actor;
memset(&actor, 0, sizeof(ActorItem));
@@ -339,7 +339,7 @@ void SceneResource::loadWorldStats(Common::SeekableReadStream *stream) {
// TODO skip field_980 till field_9A0
stream->skip(0x24);
- _worldStats->_actors.push_back(actor);
+ _worldStats->actors.push_back(actor);
}
// TODO Take this out, it shouldn't be here (TEST ONLY)
@@ -351,7 +351,7 @@ void SceneResource::loadWorldStats(Common::SeekableReadStream *stream) {
stream->seek(0xD6B5A); // where action items start
// FIXME Figure out all the actions items
- for (uint32 a = 0; a < _worldStats->_numActions; a++) {
+ for (uint32 a = 0; a < _worldStats->numActions; a++) {
ActionItem action;
memset(&action, 0, sizeof(ActionItem));
@@ -370,7 +370,7 @@ void SceneResource::loadWorldStats(Common::SeekableReadStream *stream) {
stream->skip(0x14);
action.soundVolume = stream->readUint32LE();
- _worldStats->_actions.push_back(action);
+ _worldStats->actions.push_back(action);
}
}
@@ -379,10 +379,10 @@ void SceneResource::loadGamePolygons(Common::SeekableReadStream *stream) {
stream->seek(0xE8686); // jump to game Polygons data
- _gamePolygons->_size = stream->readUint32LE();
- _gamePolygons->_numEntries = stream->readUint32LE();
+ _gamePolygons->size = stream->readUint32LE();
+ _gamePolygons->numEntries = stream->readUint32LE();
- for (uint32 g = 0; g < _gamePolygons->_numEntries; g++) {
+ for (uint32 g = 0; g < _gamePolygons->numEntries; g++) {
PolyDefinitions poly;
memset(&poly, 0, sizeof(PolyDefinitions));
@@ -400,19 +400,19 @@ void SceneResource::loadGamePolygons(Common::SeekableReadStream *stream) {
poly.boundingRect.right = stream->readUint32LE() & 0xFFFF;
poly.boundingRect.bottom = stream->readUint32LE() & 0xFFFF;
- _gamePolygons->_polygons.push_back(poly);
+ _gamePolygons->polygons.push_back(poly);
}
}
void SceneResource::loadActionList(Common::SeekableReadStream *stream) {
_actionList = new ActionList;
- stream->seek(0xE868E + _gamePolygons->_size * _gamePolygons->_numEntries); // jump to action list data
+ stream->seek(0xE868E + _gamePolygons->size * _gamePolygons->numEntries); // jump to action list data
- _actionList->_size = stream->readUint32LE();
- _actionList->_numEntries = stream->readUint32LE();
+ _actionList->size = stream->readUint32LE();
+ _actionList->numEntries = stream->readUint32LE();
- for (uint32 a = 0; a < _actionList->_numEntries; a++) {
+ for (uint32 a = 0; a < _actionList->numEntries; a++) {
ActionDefinitions action;
memset(&action, 0, sizeof(ActionDefinitions));
@@ -421,16 +421,16 @@ void SceneResource::loadActionList(Common::SeekableReadStream *stream) {
memset(&command, 0, sizeof(ActionCommand));
command.numLines = stream->readUint32LE();
- command.opcode = stream->readUint32LE(); // command type
- command.param1 = stream->readUint32LE(); // command parameters
- command.param2 = stream->readUint32LE();
- command.param3 = stream->readUint32LE();
- command.param4 = stream->readUint32LE();
- command.param5 = stream->readUint32LE();
- command.param6 = stream->readUint32LE();
- command.param7 = stream->readUint32LE();
- command.param8 = stream->readUint32LE();
- command.param9 = stream->readUint32LE();
+ command.opcode = stream->readUint32LE(); // command type
+ command.param1 = stream->readUint32LE(); // command parameters
+ command.param2 = stream->readUint32LE();
+ command.param3 = stream->readUint32LE();
+ command.param4 = stream->readUint32LE();
+ command.param5 = stream->readUint32LE();
+ command.param6 = stream->readUint32LE();
+ command.param7 = stream->readUint32LE();
+ command.param8 = stream->readUint32LE();
+ command.param9 = stream->readUint32LE();
action.commands[c] = command;
}
@@ -439,7 +439,7 @@ void SceneResource::loadActionList(Common::SeekableReadStream *stream) {
action.field_1BB0 = stream->readUint32LE();
action.counter = stream->readUint32LE();
- _actionList->_actions.push_back(action);
+ _actionList->actions.push_back(action);
}
}
diff --git a/engines/asylum/sceneres.h b/engines/asylum/sceneres.h
index f99a5fae8d..958fec03af 100644
--- a/engines/asylum/sceneres.h
+++ b/engines/asylum/sceneres.h
@@ -34,7 +34,7 @@
#include "asylum/screen.h"
#include "asylum/respack.h"
-#define SCENEMASK "scn.%03d"
+#define SCENEMASK "scn.%03d"
#define Polygons_MAXSIZE 200
#define Commands_MAXSIZE 161
@@ -49,14 +49,12 @@ class ActionList;
// TODO/FIXME: Are there REALLY any points which go beyond 32768???
// ScummVM common Point uses int16 and we need int32
typedef struct Point {
- int32 x;
- int32 y;
+ int32 x, y;
} Point;
// ScummVM common Rect uses int16 and we need int32
typedef struct Rect {
- int32 top, left;
- int32 bottom, right;
+ int32 top, left, bottom, right;
} Rect;
#endif
@@ -67,10 +65,11 @@ public:
bool load(uint8 sceneIdx);
- WorldStats* getWorldStats() { return _worldStats; }
+ WorldStats* getWorldStats() { return _worldStats; }
GamePolygons* getGamePolygons() { return _gamePolygons; }
- ActionList* getActionList() { return _actionList; }
- MainActor* getMainActor() { return _mainActor; }
+ ActionList* getActionList() { return _actionList; }
+ MainActor* getMainActor() { return _mainActor; }
+
private:
WorldStats *_worldStats;
GamePolygons *_gamePolygons;
@@ -84,12 +83,12 @@ private:
}; // end of class Scene
-
typedef struct SoundItem {
uint32 resId;
uint32 field_4;
uint32 field_8;
uint32 field_C;
+
} SoundItem;
typedef struct FrameSoundItem {
@@ -99,6 +98,7 @@ typedef struct FrameSoundItem {
uint32 field_C;
uint32 field_10;
uint32 field_14;
+
} FrameSoundItem;
typedef struct AmbientSoundItem {
@@ -111,46 +111,48 @@ typedef struct AmbientSoundItem {
uint32 flagNum[6];
uint32 x;
uint32 y;
+
} AmbientSoundItem;
// FIXME figure out unknown fields
typedef struct BarrierItem {
- uint32 id;
- uint32 resId;
- uint32 x;
- uint32 y;
- Common::Rect boundingRect;
- uint32 field_20;
- uint32 frameIdx;
- uint32 frameCount;
- uint32 field_2C;
- uint32 field_30;
- uint32 field_34;
- uint32 flags;
- uint32 field_3C;
- uint8 name[52]; // field_40 till field_70;
- uint32 field_74;
- uint32 field_78;
- uint32 field_7C;
- uint32 field_80;
- uint32 polyIdx;
- uint32 flags2;
- uint32 gameFlags[10];
- uint32 field_B4;
- uint32 tickCount;
- uint32 tickCount2;
- uint32 field_C0;
- uint32 field_C4;
- uint32 actionListIdx;
- SoundItem soundItems[16];
+ uint32 id;
+ uint32 resId;
+ uint32 x;
+ uint32 y;
+ Common::Rect boundingRect;
+ uint32 field_20;
+ uint32 frameIdx;
+ uint32 frameCount;
+ uint32 field_2C;
+ uint32 field_30;
+ uint32 field_34;
+ uint32 flags;
+ uint32 field_3C;
+ uint8 name[52]; // field_40 till field_70;
+ uint32 field_74;
+ uint32 field_78;
+ uint32 field_7C;
+ uint32 field_80;
+ uint32 polyIdx;
+ uint32 flags2;
+ uint32 gameFlags[10];
+ uint32 field_B4;
+ uint32 tickCount;
+ uint32 tickCount2;
+ uint32 field_C0;
+ uint32 field_C4;
+ uint32 actionListIdx;
+ SoundItem soundItems[16];
FrameSoundItem frameSoundItems[50];
- uint32 field_67C;
- uint32 soundX;
- uint32 soundY;
- uint32 field_688;
- uint32 field_68C[5];
- uint32 soundResId;
- uint32 field_6A4;
+ uint32 field_67C;
+ uint32 soundX;
+ uint32 soundY;
+ uint32 field_688;
+ uint32 field_68C[5];
+ uint32 soundResId;
+ uint32 field_6A4;
+
} BarrierItem;
// FIXME add unknown fields
@@ -164,6 +166,7 @@ typedef struct ActionItem {
uint32 soundResId;
uint32 palCorrection;
int32 soundVolume;
+
} ActionItem;
typedef struct CommonResources {
@@ -192,142 +195,141 @@ typedef struct CommonResources {
uint32 smallCurUp;
uint32 smallCurDown;
uint32 field_7C;
+
} CommonResources;
+
typedef struct ActorItem {
- uint32 x0;
- uint32 y0;
- uint32 grResId;
- uint32 field_C;
- uint32 frameNum;
- uint32 frameCount;
- uint32 x1;
- uint32 y1;
- uint32 x2;
- uint32 y2;
+ uint32 x0;
+ uint32 y0;
+ uint32 grResId;
+ uint32 field_C;
+ uint32 frameNum;
+ uint32 frameCount;
+ uint32 x1;
+ uint32 y1;
+ uint32 x2;
+ uint32 y2;
Common::Rect boundingRect;
- uint32 direction;
- uint32 field_3C;
- uint32 field_40;
- uint32 field_44;
- uint32 field_48;
- uint32 flags;
- uint32 field_50;
- uint32 field_54;
- uint32 field_58;
- uint32 field_5C;
- uint32 field_60;
- uint32 actionIdx3;
+ uint32 direction;
+ uint32 field_3C;
+ uint32 field_40;
+ uint32 field_44;
+ uint32 field_48;
+ uint32 flags;
+ uint32 field_50;
+ uint32 field_54;
+ uint32 field_58;
+ uint32 field_5C;
+ uint32 field_60;
+ uint32 actionIdx3;
// TODO field_68 till field_617
- uint32 reaction[8];
- uint32 field_638;
- uint32 field_63C;
- uint32 field_640;
- uint32 field_644;
- uint32 field_648;
- uint32 field_64C;
- uint32 field_650;
- uint32 grResTable[55];
- char name[256];
- uint32 field_830[20];
- uint32 field_880[20];
- uint32 field_8D0[20];
- uint32 actionIdx2;
- uint32 field_924;
- uint32 tickValue1;
- uint32 field_92C;
- uint32 flags2;
- uint32 field_934;
- uint32 field_938;
- uint32 soundResId;
+ uint32 reaction[8];
+ uint32 field_638;
+ uint32 field_63C;
+ uint32 field_640;
+ uint32 field_644;
+ uint32 field_648;
+ uint32 field_64C;
+ uint32 field_650;
+ uint32 grResTable[55];
+ char name[256];
+ uint32 field_830[20];
+ uint32 field_880[20];
+ uint32 field_8D0[20];
+ uint32 actionIdx2;
+ uint32 field_924;
+ uint32 tickValue1;
+ uint32 field_92C;
+ uint32 flags2;
+ uint32 field_934;
+ uint32 field_938;
+ uint32 soundResId;
// TODO field_940 till field_978
- uint32 actionIdx1;
+ uint32 actionIdx1;
// TODO field_980 till field_9A0
+
} ActorItem;
class WorldStats {
public:
WorldStats() {};
virtual ~WorldStats() {
- _barriers.clear();
- _actors.clear();
- _actions.clear();
+ barriers.clear();
+ actors.clear();
+ actions.clear();
};
- uint32 _size;
- uint32 _numEntries;
-
- uint32 _numChapter;
- uint32 _xLeft; // scene start x position
- uint32 _yTop; // scene start y position
- Common::Rect _boundingRect;
- CommonResources _commonRes; // field_1C till field_7C
-
- uint32 _width; // field_80
- uint32 _height;
- uint32 _field_88;
- uint32 _field_8C;
- uint32 _numActions; // field_90
- uint32 _numBarriers;
- uint32 _field_98;
- uint32 _field_9C;
- uint32 _field_A0;
- uint32 _field_A4;
- uint32 _field_A8;
- uint32 _field_AC;
- uint32 _field_B0;
- uint32 _numActors; // Max and all other characters that have own interactions
- uint32 _stereoReversedFlag;
-
- Common::Rect _sceneRects[6]; // including scene size rect
- uint8 _sceneRectIdx;
- uint8 _field_11D[3];
-
- uint32 _field_120;
- uint32 _actionListIdx; // actionList start index
- uint32 _grResId[100];
- uint32 _sceneTitleGrResId;
- uint32 _sceneTitlePalResId;
- uint32 _actorType;
-
- uint32 _soundResId[50];
- AmbientSoundItem _ambientSounds[15];
- uint32 _numAmbientSound;
- uint32 _musicStatus;
- uint32 _musicCurrentResId;
- uint32 _musicFlag;
- uint32 _musicResId;
- uint32 _musicStatusExt;
+ uint32 size;
+ uint32 numEntries;
+ uint32 numChapter;
+ uint32 xLeft; // scene start x position
+ uint32 yTop; // scene start y position
+ Common::Rect boundingRect;
+ CommonResources commonRes; // field_1C till field_7C
+ uint32 width; // field_80
+ uint32 height;
+ uint32 field_88;
+ uint32 field_8C;
+ uint32 numActions; // field_90
+ uint32 numBarriers;
+ uint32 field_98;
+ uint32 field_9C;
+ uint32 field_A0;
+ uint32 field_A4;
+ uint32 field_A8;
+ uint32 field_AC;
+ uint32 field_B0;
+ uint32 numActors; // Max and all other characters that have
+ // own interactions
+ uint32 stereoReversedFlag;
+ Common::Rect sceneRects[6]; // including scene size rect
+ uint8 sceneRectIdx;
+ uint8 field_11D[3];
+ uint32 field_120;
+ uint32 actionListIdx; // actionList start index
+ uint32 grResId[100];
+ uint32 sceneTitleGrResId;
+ uint32 sceneTitlePalResId;
+ uint32 actorType;
+ uint32 soundResId[50];
+ AmbientSoundItem ambientSounds[15];
+ uint32 numAmbientSound;
+ uint32 musicStatus;
+ uint32 musicCurrentResId;
+ uint32 musicFlag;
+ uint32 musicResId;
+ uint32 musicStatusExt;
// FIXME: Investigate if we need to actually reserve maxsize for this arrays.
// It always have that size under scene file and they are always save in savegames.
- Common::Array<BarrierItem> _barriers; // maxsize 400
- Common::Array<ActorItem> _actors; // maxsize 50
-
+ Common::Array<BarrierItem> barriers; // maxsize 400
+ Common::Array<ActorItem> actors; // maxsize 50
// TODO add rest fields
- Common::Array<ActionItem> _actions; // maxsize 400
-}; // end of class WorldStats
+ Common::Array<ActionItem> actions; // maxsize 400
+}; // end of class WorldStats
typedef struct PolyDefinitions{
- uint32 numPoints;
- Common::Point *points;//[Polygons_MAXSIZE];
- Common::Rect boundingRect;
+ uint32 numPoints;
+ Common::Point *points; //[Polygons_MAXSIZE];
+ Common::Rect boundingRect;
+
} PolyDefinitions;
class GamePolygons {
public:
GamePolygons() {};
virtual ~GamePolygons() {
- _polygons.clear();
+ polygons.clear();
};
- uint32 _size;
- uint32 _numEntries;
+ uint32 size;
+ uint32 numEntries;
- Common::Array<PolyDefinitions> _polygons;
-}; // end of class GamePolygons
+ Common::Array<PolyDefinitions> polygons;
+}; // end of class GamePolygons
typedef struct ActionCommand {
uint32 numLines; // Only set on the first line of each script
@@ -341,6 +343,7 @@ typedef struct ActionCommand {
uint32 param7;
uint32 param8;
uint32 param9;
+
} ActionCommand;
typedef struct ActionDefinitions {
@@ -348,19 +351,21 @@ typedef struct ActionDefinitions {
uint32 field_1BAC;
uint32 field_1BB0;
uint32 counter;
+
} ActionDefinitions;
class ActionList {
public:
ActionList() {};
virtual ~ActionList() {
- _actions.clear();
+ actions.clear();
};
- uint32 _size;
- uint32 _numEntries;
+ uint32 size;
+ uint32 numEntries;
+
+ Common::Array<ActionDefinitions> actions;
- Common::Array<ActionDefinitions> _actions;
}; // end of class ActionList
} // end of namespace Asylum
diff --git a/engines/asylum/screen.cpp b/engines/asylum/screen.cpp
index 57a13e9691..a7de03d73d 100644
--- a/engines/asylum/screen.cpp
+++ b/engines/asylum/screen.cpp
@@ -52,8 +52,8 @@ void Screen::copyToBackBuffer(byte *buffer, int pitch, int x, int y, int width,
}
void Screen::copyToBackBufferWithTransparency(byte *buffer, int pitch, int x, int y, int width, int height) {
- int h = height;
- int w = width;
+ // int h = height;
+ // int w = width;
byte *dest = (byte *)_backBuffer.pixels;
for (int curY = 0; curY < height; curY++) {
Commit: b8a92e1a08f8e0004843a7cba21e422fa632ea8e
https://github.com/scummvm/scummvm/commit/b8a92e1a08f8e0004843a7cba21e422fa632ea8e
Author: Joseph Davies (deledrius at gmail.com)
Date: 2021-05-17T15:35:29+02:00
Commit Message:
ASYLUM: Named CommonResource font resources.
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@217 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/sceneres.cpp
engines/asylum/sceneres.h
diff --git a/engines/asylum/sceneres.cpp b/engines/asylum/sceneres.cpp
index c4ca877060..5b7e2fc6bf 100644
--- a/engines/asylum/sceneres.cpp
+++ b/engines/asylum/sceneres.cpp
@@ -104,9 +104,9 @@ void SceneResource::loadWorldStats(Common::SeekableReadStream *stream) {
_worldStats->commonRes.curTalkNCP = stream->readUint32LE();
_worldStats->commonRes.curGrabPointer = stream->readUint32LE();
_worldStats->commonRes.curTalkNCP2 = stream->readUint32LE();
- _worldStats->commonRes.field_54 = stream->readUint32LE();
- _worldStats->commonRes.field_58 = stream->readUint32LE();
- _worldStats->commonRes.field_5C = stream->readUint32LE();
+ _worldStats->commonRes.currFont1 = stream->readUint32LE();
+ _worldStats->commonRes.currFont2 = stream->readUint32LE();
+ _worldStats->commonRes.currFont3 = stream->readUint32LE();
_worldStats->commonRes.palette = stream->readUint32LE();
_worldStats->commonRes.cellShadeMask1 = stream->readUint32LE();
_worldStats->commonRes.cellShadeMask2 = stream->readUint32LE();
diff --git a/engines/asylum/sceneres.h b/engines/asylum/sceneres.h
index 958fec03af..f105c170e9 100644
--- a/engines/asylum/sceneres.h
+++ b/engines/asylum/sceneres.h
@@ -184,9 +184,9 @@ typedef struct CommonResources {
uint32 curTalkNCP;
uint32 curGrabPointer;
uint32 curTalkNCP2;
- uint32 field_54;
- uint32 field_58;
- uint32 field_5C;
+ uint32 currFont1;
+ uint32 currFont2;
+ uint32 currFont3;
uint32 palette;
uint32 cellShadeMask1;
uint32 cellShadeMask2;
Commit: 4c4a9d5df59a073710d53f758865c40392d0132a
https://github.com/scummvm/scummvm/commit/4c4a9d5df59a073710d53f758865c40392d0132a
Author: Joseph Davies (deledrius at gmail.com)
Date: 2021-05-17T15:35:30+02:00
Commit Message:
ASYLUM: Fixed accidental misnaming - renamed font resources to match naming conventions.
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@218 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/sceneres.cpp
engines/asylum/sceneres.h
diff --git a/engines/asylum/sceneres.cpp b/engines/asylum/sceneres.cpp
index 5b7e2fc6bf..f10cdba25b 100644
--- a/engines/asylum/sceneres.cpp
+++ b/engines/asylum/sceneres.cpp
@@ -104,9 +104,9 @@ void SceneResource::loadWorldStats(Common::SeekableReadStream *stream) {
_worldStats->commonRes.curTalkNCP = stream->readUint32LE();
_worldStats->commonRes.curGrabPointer = stream->readUint32LE();
_worldStats->commonRes.curTalkNCP2 = stream->readUint32LE();
- _worldStats->commonRes.currFont1 = stream->readUint32LE();
- _worldStats->commonRes.currFont2 = stream->readUint32LE();
- _worldStats->commonRes.currFont3 = stream->readUint32LE();
+ _worldStats->commonRes.font1 = stream->readUint32LE();
+ _worldStats->commonRes.font2 = stream->readUint32LE();
+ _worldStats->commonRes.font3 = stream->readUint32LE();
_worldStats->commonRes.palette = stream->readUint32LE();
_worldStats->commonRes.cellShadeMask1 = stream->readUint32LE();
_worldStats->commonRes.cellShadeMask2 = stream->readUint32LE();
diff --git a/engines/asylum/sceneres.h b/engines/asylum/sceneres.h
index f105c170e9..53cdd91489 100644
--- a/engines/asylum/sceneres.h
+++ b/engines/asylum/sceneres.h
@@ -184,9 +184,9 @@ typedef struct CommonResources {
uint32 curTalkNCP;
uint32 curGrabPointer;
uint32 curTalkNCP2;
- uint32 currFont1;
- uint32 currFont2;
- uint32 currFont3;
+ uint32 font1;
+ uint32 font2;
+ uint32 font3;
uint32 palette;
uint32 cellShadeMask1;
uint32 cellShadeMask2;
Commit: 34e750d48db5ddfd5c47fb1dd7d3f9af2430bc13
https://github.com/scummvm/scummvm/commit/34e750d48db5ddfd5c47fb1dd7d3f9af2430bc13
Author: Joseph Davies (deledrius at gmail.com)
Date: 2021-05-17T15:35:30+02:00
Commit Message:
ASYLUM: Added preliminary script interpreter and associated support functions and fixes. Added Debug channels.
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@224 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
A engines/asylum/interpreter.cpp
A engines/asylum/interpreter.h
engines/asylum/actor.cpp
engines/asylum/actor.h
engines/asylum/asylum.cpp
engines/asylum/asylum.h
engines/asylum/module.mk
engines/asylum/scene.cpp
engines/asylum/scene.h
engines/asylum/sceneres.cpp
engines/asylum/sceneres.h
diff --git a/engines/asylum/actor.cpp b/engines/asylum/actor.cpp
index adc735e587..0f3ece7f62 100644
--- a/engines/asylum/actor.cpp
+++ b/engines/asylum/actor.cpp
@@ -112,6 +112,18 @@ void MainActor::drawActorAt(Screen *screen, uint16 x, uint16 y) {
_actorY = y;
}
+void MainActor::drawActor(Screen *screen) {
+ GraphicFrame *frame = getFrame();
+
+ screen->copyToBackBufferWithTransparency(
+ ((byte *)frame->surface.pixels),
+ frame->surface.w,
+ _actorX,
+ _actorY - frame->surface.h,
+ frame->surface.w,
+ frame->surface.h );
+}
+
void MainActor::walkTo(Screen *screen, uint16 x, uint16 y) {
// TODO: pathfinding! The character can walk literally anywhere
int newAction = _currentAction;
@@ -122,7 +134,7 @@ void MainActor::walkTo(Screen *screen, uint16 x, uint16 y) {
_actorX--;
if (ABS(y - _actorY) <= 30) {
setAction(newAction);
- drawActorAt(screen, _actorX, _actorY);
+ drawActor(screen);
return;
}
}
@@ -133,7 +145,7 @@ void MainActor::walkTo(Screen *screen, uint16 x, uint16 y) {
_actorX++;
if (ABS(y - _actorY) <= 30) {
setAction(newAction);
- drawActorAt(screen, _actorX, _actorY);
+ drawActor(screen);
return;
}
}
@@ -161,7 +173,7 @@ void MainActor::walkTo(Screen *screen, uint16 x, uint16 y) {
}
setAction(newAction);
- drawActorAt(screen, _actorX, _actorY);
+ drawActor(screen);
}
} // end of namespace Asylum
diff --git a/engines/asylum/actor.h b/engines/asylum/actor.h
index 0f1a8bd597..70ece89096 100644
--- a/engines/asylum/actor.h
+++ b/engines/asylum/actor.h
@@ -135,6 +135,7 @@ public:
void setResourcePack(ResourcePack *resPack) { _resPack = resPack; }
void setAction(int action);
void drawActorAt(Screen *screen, uint16 x, uint16 y);
+ void drawActor(Screen *screen);
void walkTo(Screen *screen, uint16 x, uint16 y);
int getCurrentAction() { return _currentAction; }
diff --git a/engines/asylum/asylum.cpp b/engines/asylum/asylum.cpp
index 0daf372d05..140d4576d4 100644
--- a/engines/asylum/asylum.cpp
+++ b/engines/asylum/asylum.cpp
@@ -35,7 +35,16 @@ namespace Asylum {
AsylumEngine::AsylumEngine(OSystem *system, Common::Language language)
: Engine(system) {
-
+
+ Common::addDebugChannel(kDebugLevelMain, "Main", "Generic debug level");
+ Common::addDebugChannel(kDebugLevelResources, "Resources", "Resources debugging");
+ Common::addDebugChannel(kDebugLevelSprites, "Sprites", "Sprites debugging");
+ Common::addDebugChannel(kDebugLevelInput, "Input", "Input events debugging");
+ Common::addDebugChannel(kDebugLevelMenu, "Menu", "Menu debugging");
+ Common::addDebugChannel(kDebugLevelScripts, "Scripts", "Scripts debugging");
+ Common::addDebugChannel(kDebugLevelSound, "Sound", "Sound debugging");
+ Common::addDebugChannel(kDebugLevelSavegame, "Savegame", "Saving & restoring game debugging");
+
Common::File::addDefaultDirectory(_gameDataDir.getChild("Data"));
Common::File::addDefaultDirectory(_gameDataDir.getChild("Vids"));
Common::File::addDefaultDirectory(_gameDataDir.getChild("Music"));
@@ -67,12 +76,13 @@ Common::Error AsylumEngine::init() {
initGraphics(640, 480, true);
- _screen = new Screen(_system);
- _sound = new Sound(_mixer);
- _video = new Video(_mixer);
- _console = new Console(this);
- _mainMenu = 0;
- _scene = 0;
+ _screen = new Screen(_system);
+ _sound = new Sound(_mixer);
+ _video = new Video(_mixer);
+ _console = new Console(this);
+ _interpreter = 0;
+ _mainMenu = 0;
+ _scene = 0;
_delayedVideoNumber = -1;
return Common::kNoError;
@@ -94,6 +104,9 @@ Common::Error AsylumEngine::go() {
// Set up the game's main scene
_scene = new Scene(_screen, _sound, 5);
+
+ // Set up the game's script interpreter
+ _interpreter = new Interpreter(_scene);
// Set up main menu
_mainMenu = new MainMenu(_screen, _sound, _scene);
@@ -116,6 +129,7 @@ void AsylumEngine::waitForTimer(int msec_delay) {
checkForEvent(false);
checkForDelayedVideo();
_system->updateScreen();
+ _interpreter->processActionLists();
}
}
diff --git a/engines/asylum/asylum.h b/engines/asylum/asylum.h
index 34c57011b7..18aed639e2 100644
--- a/engines/asylum/asylum.h
+++ b/engines/asylum/asylum.h
@@ -34,6 +34,7 @@
#include "asylum/screen.h"
#include "asylum/sound.h"
#include "asylum/video.h"
+#include "asylum/interpreter.h"
namespace Asylum {
@@ -44,6 +45,18 @@ class Scene;
class Screen;
class Sound;
class Video;
+class Interpreter;
+
+enum kDebugLevels {
+ kDebugLevelMain = 1 << 0,
+ kDebugLevelResources = 1 << 1,
+ kDebugLevelSprites = 1 << 2,
+ kDebugLevelInput = 1 << 3,
+ kDebugLevelMenu = 1 << 4,
+ kDebugLevelScripts = 1 << 5,
+ kDebugLevelSound = 1 << 6,
+ kDebugLevelSavegame = 1 << 7
+};
class AsylumEngine: public Engine {
public:
@@ -66,12 +79,13 @@ private:
Common::Language _language;
Common::RandomSource _rnd;
- Console *_console;
- Scene *_scene;
- MainMenu *_mainMenu;
- Screen *_screen;
- Sound *_sound;
- Video *_video;
+ Console *_console;
+ Scene *_scene;
+ MainMenu *_mainMenu;
+ Screen *_screen;
+ Sound *_sound;
+ Video *_video;
+ Interpreter *_interpreter;
int _delayedVideoNumber;
friend class Console;
diff --git a/engines/asylum/interpreter.cpp b/engines/asylum/interpreter.cpp
new file mode 100644
index 0000000000..3e46bf3feb
--- /dev/null
+++ b/engines/asylum/interpreter.cpp
@@ -0,0 +1,183 @@
+/* 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.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#include "asylum/interpreter.h"
+#include "asylum/sceneres.h"
+
+namespace Asylum {
+
+Interpreter::Interpreter(Scene *scene): _scene(scene) {
+ _currentLine = 0;
+ _currentScriptIndex = _scene->getDefaultActionIndex();
+ _currentLoops = 0;
+ _processing = false;
+}
+
+Interpreter::~Interpreter() {
+}
+
+void Interpreter::processActionLists() {
+ bool done = false, waitCycle = false;
+ int lineIncrement = 1;
+ _processing = true;
+
+ if (_currentScriptIndex != -1) {
+ ActionDefinitions *_currentScript = _scene->getActionList(_currentScriptIndex);
+ if (!_currentScript)
+ return;
+
+ while (!done && !waitCycle) {
+ lineIncrement = 1; // Reset line increment value
+
+ if (_currentLoops > 1000) {
+ // TODO - processActionLists has run too many interations
+ }
+
+ ActionCommand currentCommand = _currentScript->commands[_currentLine];
+
+ switch (currentCommand.opcode) {
+ case kReturn0:
+ done = true;
+ lineIncrement = 0;
+ break;
+ case kShowCursor:
+ _scene->_screen->showCursor();
+ // TODO - Enable click events
+ break;
+ case kHideCursor:
+ _scene->_screen->hideCursor();
+ // TODO - Disable click events
+ break;
+ case kPlayAnimation: {
+ int barrierIndex = _scene->_sceneResource->getBarrierIndexById(currentCommand.param1);
+ if (barrierIndex >= 0)
+ _scene->_sceneResource->getWorldStats()->barriers[barrierIndex].flags |= 0x20; // TODO - enums for flags (0x20 is visible/playing?)
+ else
+ debugC(kDebugLevelScripts, "Requested invalid object ID:0x%02X in Scene %d Script %d Line %d.", currentCommand.param1, _scene->getSceneIndex(), _currentScriptIndex, _currentLine);
+ }
+ break;
+ case kHideActor:
+ {
+ int actorIndex = 0;
+ if (currentCommand.param1 == -1)
+ ;//actorIndex = _scene->getWorldStats()->playerActor;
+ else
+ actorIndex = currentCommand.param1;
+
+ if ((actorIndex >= 0) && (actorIndex < _scene->_sceneResource->getWorldStats()->numActors)) {
+ _scene->actorVisible(actorIndex, false);
+ }
+ else
+ debugC(kDebugLevelScripts, "Requested invalid actor ID:0x%02X in Scene %d Script %d Line %d.", currentCommand.param1, _scene->getSceneIndex(), _currentScriptIndex, _currentLine);
+ }
+ break;
+ case kShowActor:
+ {
+ int actorIndex = 0;
+ if (currentCommand.param1 == -1)
+ ;//actorIndex = _scene->getWorldStats()->playerActor;
+ else
+ actorIndex = currentCommand.param1;
+
+ if ((actorIndex >= 0) && (actorIndex < _scene->_sceneResource->getWorldStats()->numActors)) {
+ _scene->actorVisible(actorIndex, true);
+ }
+ else
+ debugC(kDebugLevelScripts, "Requested invalid actor ID:0x%02X in Scene %d Script %d Line %d.", currentCommand.param1, _scene->getSceneIndex(), _currentScriptIndex, _currentLine);
+ }
+ break;
+ case kSetActorStats: {
+ int actorIndex = 0;
+ if (currentCommand.param1 == -1)
+ ;//actorIndex = _scene->getWorldStats()->playerActor;
+ else
+ actorIndex = currentCommand.param1;
+
+ if ((actorIndex >= 0) && (actorIndex < _scene->_sceneResource->getWorldStats()->numActors)) {
+ _scene->setActorPosition(actorIndex, currentCommand.param2, currentCommand.param3);
+ _scene->setActorAction(actorIndex, 112);//currentCommand.param4);
+ }
+ else
+ debugC(kDebugLevelScripts, "Requested invalid actor ID:0x%02X in Scene %d Script %d Line %d.", currentCommand.param1, _scene->getSceneIndex(), _currentScriptIndex, _currentLine);
+ }
+ break;
+ case kReturn:
+ done = true;
+ lineIncrement = 0;
+ break;
+ case kDestroyObject: {
+ int barrierIndex = _scene->_sceneResource->getBarrierIndexById(currentCommand.param1);
+ if (barrierIndex >= 0)
+ _scene->_sceneResource->getWorldStats()->barriers[barrierIndex].flags &= 0xFFFFDF; // TODO - enums for flags (0x20 is visible/playing?)
+ else
+ debugC(kDebugLevelScripts, "Requested invalid object ID:0x%02X in Scene %d Script %d Line %d.", currentCommand.param1, _scene->getSceneIndex(), _currentScriptIndex, _currentLine);
+ }
+ break;
+ case kWaitUntilFramePlayed: {
+ int barrierIndex = _scene->_sceneResource->getBarrierIndexById(currentCommand.param1);
+ if (barrierIndex >= 0) {
+ int frameNum = 0;
+ if (currentCommand.param2 == -1)
+ frameNum = _scene->_sceneResource->getWorldStats()->barriers[barrierIndex].frameCount - 1;
+ else
+ frameNum = currentCommand.param2;
+
+ if (_scene->_sceneResource->getWorldStats()->barriers[barrierIndex].tickCount < frameNum) {
+ lineIncrement = 0;
+ waitCycle = true;
+ }
+ }
+ else
+ debugC(kDebugLevelScripts, "Requested invalid object ID:0x%02X in Scene %d Script %d Line %d.", currentCommand.param1, _scene->getSceneIndex(), _currentScriptIndex, _currentLine);
+ }
+ break;
+ case kPlaySpeech:
+ if (currentCommand.param1 >= 0) {
+ if (currentCommand.param3) // HACK - Find out why sometimes an offset is needed and other times not
+ _scene->_sound->playSfx(_scene->_speechPack, currentCommand.param1 - 9);
+ else
+ _scene->_sound->playSfx(_scene->_speechPack, currentCommand.param1);
+ }
+ else
+ debugC(kDebugLevelScripts, "Requested invalid sound ID:0x%02X in Scene %d Script %d Line %d.", currentCommand.param1, _scene->getSceneIndex(), _currentScriptIndex, _currentLine);
+ break;
+ default:
+ debugC(kDebugLevelScripts, "Unhandled opcode 0x%02X in Scene %d Script %d Line %d.", _currentScript->commands[_currentLine].opcode, _scene->getSceneIndex(), _currentScriptIndex, _currentLine);
+ break;
+ } // end switch
+
+ _currentLine += lineIncrement;
+
+ } // end while
+
+ if(done) {
+ _currentLine = 0;
+ _currentScriptIndex = 0;
+ }
+ }
+ _processing = false;
+}
+
+} // end of namespace Asylum
diff --git a/engines/asylum/interpreter.h b/engines/asylum/interpreter.h
new file mode 100644
index 0000000000..2e004de163
--- /dev/null
+++ b/engines/asylum/interpreter.h
@@ -0,0 +1,156 @@
+/* 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.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#ifndef ASYLUM_INTERPERTER_H_
+#define ASYLUM_INTERPERTER_H_
+
+#include "asylum/scene.h"
+
+namespace Asylum {
+
+
+class Interpreter {
+public:
+ Interpreter(Scene *scene);
+ ~Interpreter();
+
+ void processActionLists();
+ bool isProcessing() { return _processing; }
+
+private:
+ Scene * _scene;
+ int _currentLine;
+ int _currentScriptIndex;
+ int _currentLoops;
+ bool _processing;
+
+ friend class Console;
+};
+
+enum opcodes {
+ kReturn0 = 0x00,
+ kSetGameFlag,
+ kClearGameFlag,
+ kToogleGameFlag,
+ kJumpIfGameFlag,
+ kHideCursor,
+ kShowCursor,
+ kPlayAnimation,
+ kMoveScenePosition,
+ kHideActor,
+ kShowActor,
+ kSetActorStats,
+ k_unk0C_SET_SCENE_FIELD88,
+ kDisableActor,
+ kEnableActor,
+ kEnableBarriers,
+ kReturn, // 0x10
+ kDestroyObject,
+ k_unk12_JMP_WALK_ACTOR,
+ k_unk13_JMP_WALK_ACTOR,
+ k_unk14_JMP_WALK_ACTOR,
+ k_unk15,
+ kResetAnimation,
+ kClearFlag1Bit0,
+ k_unk18_PLAY_SND,
+ kJumpIfFlag2Bit0,
+ kSetFlag2Bit0,
+ kClearFlag2Bit0,
+ kJumpIfFlag2Bit2,
+ kSetFlag2Bit2,
+ kClearFlag2Bit2,
+ kJumpIfFlag2Bit1,
+ kSetFlag2Bit1, // 0x20
+ kClearFlag2Bit1,
+ k_unk22,
+ k_unk23,
+ k_unk24,
+ kRunEncounter,
+ kJumpIfFlag2Bit4,
+ kSetFlag2Bit4,
+ kClearFlag2Bit4,
+ kSetActorField638,
+ kJumpIfActorField638,
+ kChangeScene,
+ k_unk2C_ActorSub,
+ kPlayMovie,
+ kStopAllObjectsSounds,
+ kSetActionFlag01,
+ kClearActionFlag01, // 0x30
+ kResetSceneRect,
+ kChangeMusicById,
+ kStopMusic,
+ k_unk34_Status,
+ k_unk35,
+ k_unk36,
+ kRunMinigame,
+ kJumpIfFlag2Bit3,
+ kSetFlag2Bit3,
+ kClearFlag2Bit3,
+ k_unk3B_PALETTE_MOD,
+ k_unk3C_CMP_VAL,
+ kWaitUntilFramePlayed,
+ kUpdateMatteBars,
+ k_unk3F,
+ k_unk40_SOUND, // 0x40
+ kPlaySpeech,
+ k_unk42,
+ k_unk43,
+ kPaletteFade,
+ kStartPaletteFadeThread,
+ k_unk46,
+ kActorFaceObject,
+ k_unk48_MATTE_01,
+ k_unk49_MATTE_90,
+ kJumpIfSoundPlaying,
+ kChangePlayerCharacterIndex,
+ kChangeActorField40,
+ kStopSound,
+ k_unk4E_RANDOM_COMMAND,
+ kDrawGame,
+ kQuit, // 0x50
+ kJumpObjectFrame,
+ k_unk52,
+ k_unk53,
+ k_unk54_SET_ACTIONLIST_6EC,
+ k_unk55,
+ k_unk56,
+ k_unk57,
+ k_unk58,
+ k_unk59,
+ k_unk5A,
+ k_unk5B,
+ k_unk5C,
+ k_unk5D,
+ k_unk5E,
+ k_unk5F,
+ k_unk60_SET_OR_CLR_ACTIONAREA_FLAG, // 0x60
+ k_unk61,
+ k_unk62_SHOW_OPTIONS_SCREEN
+};
+
+} // end of namespace Asylum
+
+#endif
diff --git a/engines/asylum/module.mk b/engines/asylum/module.mk
index 25bfe1cb21..81a67061a7 100644
--- a/engines/asylum/module.mk
+++ b/engines/asylum/module.mk
@@ -14,7 +14,8 @@ MODULE_OBJS := \
text.o \
video.o \
actor.o \
- encounters.o
+ encounters.o \
+ interpreter.o
# This module can be built as a plugin
ifeq ($(ENABLE_ASYLUM), DYNAMIC_PLUGIN)
diff --git a/engines/asylum/scene.cpp b/engines/asylum/scene.cpp
index 3a8bf092d6..f4344b22a9 100644
--- a/engines/asylum/scene.cpp
+++ b/engines/asylum/scene.cpp
@@ -24,6 +24,7 @@
*/
#include "asylum/scene.h"
+#include "asylum/sceneres.h"
namespace Asylum {
@@ -41,6 +42,8 @@ Scene::Scene(Screen *screen, Sound *sound, uint8 sceneIdx): _screen(screen), _so
_speechPack = new ResourcePack(3);
_sceneResource->getMainActor()->setResourcePack(_resPack);
+
+ _text->loadFont(_resPack, _sceneResource->getWorldStats()->commonRes.font1);
char musPackFileName[10];
sprintf(musPackFileName, "mus.%03d", sceneIdx);
@@ -90,6 +93,77 @@ void Scene::enterScene() {
_isActive = true;
}
+int Scene::getDefaultActionIndex() {
+ if (_sceneResource) {
+ return _sceneResource->getWorldStats()->actionListIdx;
+ }
+ else
+ return -1;
+}
+
+ActionDefinitions * Scene::getActionList(int actionListIndex) {
+ if ((actionListIndex >= 0) && (actionListIndex < (int)_sceneResource->getWorldStats()->numActions)) {
+ return &_sceneResource->getActionList()->actions[actionListIndex];
+ }
+ else
+ return 0;
+}
+
+void Scene::setActorPosition(int actorIndex, int x, int y) {
+ if ((actorIndex >= 0) && (actorIndex < (int)_sceneResource->getWorldStats()->numActors)) {
+ _sceneResource->getWorldStats()->actors[actorIndex].boundingRect.left = x;
+ _sceneResource->getWorldStats()->actors[actorIndex].boundingRect.top = y;
+ }
+
+ // FIXME - Remove this once mainActor uses proper actor info
+ if (actorIndex == 0) {
+ _sceneResource->getMainActor()->_actorX = x;
+ _sceneResource->getMainActor()->_actorY = y;
+ }
+}
+
+void Scene::setActorAction(int actorIndex, int action) {
+ if ((actorIndex >= 0) && (actorIndex < (int)_sceneResource->getWorldStats()->numActors)) {
+ _sceneResource->getWorldStats()->actors[actorIndex].direction = action;
+ }
+
+ // FIXME - Remove this once mainActor uses proper actor info
+ if (actorIndex == 0) {
+ if(_sceneResource->getMainActor())
+ _sceneResource->getMainActor()->setAction(action);
+ }
+}
+
+void Scene::actorVisible(int actorIndex, bool visible) {
+ if ((actorIndex >= 0) && (actorIndex < (int)_sceneResource->getWorldStats()->numActors)) {
+ if(visible) // TODO - enums for flags (0x01 is visible)
+ _sceneResource->getWorldStats()->actors[actorIndex].flags |= 0x01;
+ else
+ _sceneResource->getWorldStats()->actors[actorIndex].flags &= 0xFFFFFFFE;
+ }
+
+
+ // FIXME - Remove this once mainActor uses proper actor info
+ if (actorIndex == 0) {
+ if(_sceneResource->getMainActor())
+ ;//_sceneResource->getMainActor()->setAction(action);
+ }
+}
+
+bool Scene::actorVisible(int actorIndex) {
+ if ((actorIndex >= 0) && (actorIndex < (int)_sceneResource->getWorldStats()->numActors)) {
+ return _sceneResource->getWorldStats()->actors[actorIndex].flags & 0x01; // TODO - enums for flags (0x01 is visible)
+ }
+
+ // FIXME - Remove this once mainActor uses proper actor info
+ if (actorIndex == 0) {
+ if(_sceneResource->getMainActor())
+ ;//_sceneResource->getMainActor()->setAction(action);
+ }
+
+ return false;
+}
+
void Scene::handleEvent(Common::Event *event, bool doUpdate) {
_ev = event;
@@ -132,11 +206,54 @@ void Scene::update() {
WorldStats *worldStats = _sceneResource->getWorldStats();
int32 curHotspot = -1;
- // TESTING
+ // Horizontal scrolling
+ if (_mouseX < SCREEN_EDGES && _startX >= SCROLL_STEP) {
+ _startX -= SCROLL_STEP;
+ //scrollScreen = true;
+ } else if (_mouseX > 640 - SCREEN_EDGES && _startX <= bg->surface.w - 640 - SCROLL_STEP) {
+ _startX += SCROLL_STEP;
+ //scrollScreen = true;
+ }
+
+ // Vertical scrolling
+ if (_mouseY < SCREEN_EDGES && _startY >= SCROLL_STEP) {
+ _startY -= SCROLL_STEP;
+ //scrollScreen = true;
+ } else if (_mouseY > 480 - SCREEN_EDGES && _startY <= bg->surface.h - 480 - SCROLL_STEP) {
+ _startY += SCROLL_STEP;
+ //scrollScreen = true;
+ }
+
+ // Copy the background to the back buffer before updating the scene animations
+ _screen->copyToBackBuffer(((byte *)bg->surface.pixels) + _startY * bg->surface.w + _startX, bg->surface.w, 0, 0, 640, 480);
+
+ updateBarrier(_screen, _resPack, 1); // inside the middle room
+ for(uint b=0; b < _sceneResource->getWorldStats()->barriers.size(); b++) {
+ if ((_sceneResource->getWorldStats()->barriers[b].flags & 0x20) != 0) // TODO - enums for flags (0x20 is visible/playing?)
+ updateBarrier(_screen, _resPack, b);
+ }
+ /*
+ updateBarrier(_screen, _resPack, 0); // the "statue with fireworks" animation
+ //updateBarrier(_screen, _resPack, 1); // inside the middle room
+ //updateBarrier(_screen, _resPack, 2); // the lit candles at the base of the statue
+ updateBarrier(_screen, _resPack, 3); // the rat animation (in front of the statue)
+ updateBarrier(_screen, _resPack, 4); // inside the bottom room
+ updateBarrier(_screen, _resPack, 6); // inside the top room (should be shown before the rat animation)
+ updateBarrier(_screen, _resPack, 5); // the rat animation (outside the second room)
+ updateBarrier(_screen, _resPack, 7); // the "crazy prisoner banging head" animation
+ //updateBarrier(_screen, _resPack, 8); // going up the ladder
+ //updateBarrier(_screen, _resPack, 9); // going down the ladder
+ updateBarrier(_screen, _resPack, 59); // Wobbly Guy
+ */
+ // TODO
+
+ // TESTING
// Main actor walking
if (!_rightButton) {
- mainActor->setAction(15); // face south
- mainActor->drawActorAt(_screen, mainActor->_actorX, mainActor->_actorY);
+ //mainActor->setAction(15); // face south
+ //mainActor->drawActorAt(_screen, mainActor->_actorX, mainActor->_actorY);
+ if (_sceneResource->getWorldStats()->actors[0].flags & 0x01) // TESTING - only draw if visible flag
+ mainActor->drawActor(_screen);
} else {
mainActor->walkTo(_screen, _mouseX, _mouseY);
@@ -176,40 +293,6 @@ void Scene::update() {
}
}
- // Horizontal scrolling
- if (_mouseX < SCREEN_EDGES && _startX >= SCROLL_STEP) {
- _startX -= SCROLL_STEP;
- //scrollScreen = true;
- } else if (_mouseX > 640 - SCREEN_EDGES && _startX <= bg->surface.w - 640 - SCROLL_STEP) {
- _startX += SCROLL_STEP;
- //scrollScreen = true;
- }
-
- // Vertical scrolling
- if (_mouseY < SCREEN_EDGES && _startY >= SCROLL_STEP) {
- _startY -= SCROLL_STEP;
- //scrollScreen = true;
- } else if (_mouseY > 480 - SCREEN_EDGES && _startY <= bg->surface.h - 480 - SCROLL_STEP) {
- _startY += SCROLL_STEP;
- //scrollScreen = true;
- }
-
- // Copy the background to the back buffer before updating the scene animations
- _screen->copyToBackBuffer(((byte *)bg->surface.pixels) + _startY * bg->surface.w + _startX, bg->surface.w, 0, 0, 640, 480);
-
- updateBarrier(_screen, _resPack, 0); // the "statue with fireworks" animation
- //updateBarrier(_screen, _resPack, 1); // inside the middle room
- //updateBarrier(_screen, _resPack, 2); // the lit candles at the base of the statue
- updateBarrier(_screen, _resPack, 3); // the rat animation (in front of the statue)
- updateBarrier(_screen, _resPack, 4); // inside the bottom room
- updateBarrier(_screen, _resPack, 6); // inside the top room (should be shown before the rat animation)
- updateBarrier(_screen, _resPack, 5); // the rat animation (outside the second room)
- updateBarrier(_screen, _resPack, 7); // the "crazy prisoner banging head" animation
- //updateBarrier(_screen, _resPack, 8); // going up the ladder
- //updateBarrier(_screen, _resPack, 9); // going down the ladder
- //updateBarrier(_screen, _resPack, 59); // Wobbly Guy
- // TODO
-
if (g_debugPolygons)
ShowPolygons();
@@ -229,7 +312,8 @@ void Scene::update() {
if (curHotspot >= 0) {
for (uint32 a = 0; a < worldStats->numActions; a++) {
if (worldStats->actions[a].polyIdx == curHotspot) {
- printf("Hotspot: \"%s\", poly %d, action lists %d/%d, action type %d, sound res %d\n",
+ printf("Hotspot: 0x%X - \"%s\", poly %d, action lists %d/%d, action type %d, sound res %d\n",
+ worldStats->actions[a].id,
worldStats->actions[a].name,
worldStats->actions[a].polyIdx,
worldStats->actions[a].actionListIdx1,
@@ -245,6 +329,7 @@ void Scene::update() {
for (int command = 0; command < 161; command++) {
if (actionDefs.commands[command].opcode == 65) { // play voice
_sound->playSfx(_speechPack, actionDefs.commands[command].param1);
+ //_text->drawResText(actionDefs.commands[command].param1+83);
// TODO: param2 (usually 1) -> number of loops?
}
}
diff --git a/engines/asylum/scene.h b/engines/asylum/scene.h
index 0545850dda..4634bb9c32 100644
--- a/engines/asylum/scene.h
+++ b/engines/asylum/scene.h
@@ -40,6 +40,8 @@ class Screen;
class Sound;
class SceneResource;
class Text;
+class ActionDefinitions;
+class Interpreter;
class Scene {
public:
@@ -52,6 +54,15 @@ public:
void activate() { _isActive = true; }
void deactivate() { _isActive = false; }
bool isActive() { return _isActive; }
+ int getSceneIndex() { return _sceneIdx; }
+
+ int getDefaultActionIndex();
+ ActionDefinitions *getActionList(int actionListIndex);
+
+ void setActorPosition(int actorIndex, int x, int y);
+ void setActorAction(int actorIndex, int action);
+ void actorVisible(int actorIndex, bool visible);
+ bool actorVisible(int actorIndex);
private:
#if 0
@@ -88,6 +99,8 @@ private:
void updateBarrier(Screen *screen, ResourcePack *res, uint8 actorIndex);
void ShowPolygons();
+
+ friend class Interpreter;
}; // end of class Scene
} // end of namespace Asylum
diff --git a/engines/asylum/sceneres.cpp b/engines/asylum/sceneres.cpp
index f10cdba25b..a17682ba13 100644
--- a/engines/asylum/sceneres.cpp
+++ b/engines/asylum/sceneres.cpp
@@ -40,6 +40,15 @@ SceneResource::~SceneResource() {
delete _actionList;
}
+int SceneResource::getBarrierIndexById(int id) {
+ for (int i=0; i < _worldStats->numBarriers; i++)
+ {
+ if (_worldStats->barriers[i].id == id)
+ return i;
+ }
+ return -1;
+}
+
bool SceneResource::load(uint8 sceneIdx) {
char sceneTag[6];
Common::File* fd = new Common::File;
diff --git a/engines/asylum/sceneres.h b/engines/asylum/sceneres.h
index 53cdd91489..12ba29a130 100644
--- a/engines/asylum/sceneres.h
+++ b/engines/asylum/sceneres.h
@@ -69,6 +69,8 @@ public:
GamePolygons* getGamePolygons() { return _gamePolygons; }
ActionList* getActionList() { return _actionList; }
MainActor* getMainActor() { return _mainActor; }
+
+ int getBarrierIndexById(int id);
private:
WorldStats *_worldStats;
Commit: 7f3710000821c3fb4d2a3af574af3d02cf25b467
https://github.com/scummvm/scummvm/commit/7f3710000821c3fb4d2a3af574af3d02cf25b467
Author: Joseph Davies (deledrius at gmail.com)
Date: 2021-05-17T15:35:30+02:00
Commit Message:
ASYLUM: Fixed SVN keywords.
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@225 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/interpreter.cpp
engines/asylum/interpreter.h
diff --git a/engines/asylum/interpreter.cpp b/engines/asylum/interpreter.cpp
index 3e46bf3feb..354855cb76 100644
--- a/engines/asylum/interpreter.cpp
+++ b/engines/asylum/interpreter.cpp
@@ -1,183 +1,183 @@
-/* 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.
- *
- * $URL$
- * $Id$
- *
- */
-
-#include "asylum/interpreter.h"
-#include "asylum/sceneres.h"
-
-namespace Asylum {
-
-Interpreter::Interpreter(Scene *scene): _scene(scene) {
- _currentLine = 0;
- _currentScriptIndex = _scene->getDefaultActionIndex();
- _currentLoops = 0;
- _processing = false;
-}
-
-Interpreter::~Interpreter() {
-}
-
-void Interpreter::processActionLists() {
- bool done = false, waitCycle = false;
- int lineIncrement = 1;
- _processing = true;
-
- if (_currentScriptIndex != -1) {
- ActionDefinitions *_currentScript = _scene->getActionList(_currentScriptIndex);
- if (!_currentScript)
- return;
-
- while (!done && !waitCycle) {
- lineIncrement = 1; // Reset line increment value
-
- if (_currentLoops > 1000) {
- // TODO - processActionLists has run too many interations
- }
-
- ActionCommand currentCommand = _currentScript->commands[_currentLine];
-
- switch (currentCommand.opcode) {
- case kReturn0:
- done = true;
- lineIncrement = 0;
- break;
- case kShowCursor:
- _scene->_screen->showCursor();
- // TODO - Enable click events
- break;
- case kHideCursor:
- _scene->_screen->hideCursor();
- // TODO - Disable click events
- break;
- case kPlayAnimation: {
- int barrierIndex = _scene->_sceneResource->getBarrierIndexById(currentCommand.param1);
- if (barrierIndex >= 0)
- _scene->_sceneResource->getWorldStats()->barriers[barrierIndex].flags |= 0x20; // TODO - enums for flags (0x20 is visible/playing?)
- else
- debugC(kDebugLevelScripts, "Requested invalid object ID:0x%02X in Scene %d Script %d Line %d.", currentCommand.param1, _scene->getSceneIndex(), _currentScriptIndex, _currentLine);
- }
- break;
- case kHideActor:
- {
- int actorIndex = 0;
- if (currentCommand.param1 == -1)
- ;//actorIndex = _scene->getWorldStats()->playerActor;
- else
- actorIndex = currentCommand.param1;
-
- if ((actorIndex >= 0) && (actorIndex < _scene->_sceneResource->getWorldStats()->numActors)) {
- _scene->actorVisible(actorIndex, false);
- }
- else
- debugC(kDebugLevelScripts, "Requested invalid actor ID:0x%02X in Scene %d Script %d Line %d.", currentCommand.param1, _scene->getSceneIndex(), _currentScriptIndex, _currentLine);
- }
- break;
- case kShowActor:
- {
- int actorIndex = 0;
- if (currentCommand.param1 == -1)
- ;//actorIndex = _scene->getWorldStats()->playerActor;
- else
- actorIndex = currentCommand.param1;
-
- if ((actorIndex >= 0) && (actorIndex < _scene->_sceneResource->getWorldStats()->numActors)) {
- _scene->actorVisible(actorIndex, true);
- }
- else
- debugC(kDebugLevelScripts, "Requested invalid actor ID:0x%02X in Scene %d Script %d Line %d.", currentCommand.param1, _scene->getSceneIndex(), _currentScriptIndex, _currentLine);
- }
- break;
- case kSetActorStats: {
- int actorIndex = 0;
- if (currentCommand.param1 == -1)
- ;//actorIndex = _scene->getWorldStats()->playerActor;
- else
- actorIndex = currentCommand.param1;
-
- if ((actorIndex >= 0) && (actorIndex < _scene->_sceneResource->getWorldStats()->numActors)) {
- _scene->setActorPosition(actorIndex, currentCommand.param2, currentCommand.param3);
- _scene->setActorAction(actorIndex, 112);//currentCommand.param4);
- }
- else
- debugC(kDebugLevelScripts, "Requested invalid actor ID:0x%02X in Scene %d Script %d Line %d.", currentCommand.param1, _scene->getSceneIndex(), _currentScriptIndex, _currentLine);
- }
- break;
- case kReturn:
- done = true;
- lineIncrement = 0;
- break;
- case kDestroyObject: {
- int barrierIndex = _scene->_sceneResource->getBarrierIndexById(currentCommand.param1);
- if (barrierIndex >= 0)
- _scene->_sceneResource->getWorldStats()->barriers[barrierIndex].flags &= 0xFFFFDF; // TODO - enums for flags (0x20 is visible/playing?)
- else
- debugC(kDebugLevelScripts, "Requested invalid object ID:0x%02X in Scene %d Script %d Line %d.", currentCommand.param1, _scene->getSceneIndex(), _currentScriptIndex, _currentLine);
- }
- break;
- case kWaitUntilFramePlayed: {
- int barrierIndex = _scene->_sceneResource->getBarrierIndexById(currentCommand.param1);
- if (barrierIndex >= 0) {
- int frameNum = 0;
- if (currentCommand.param2 == -1)
- frameNum = _scene->_sceneResource->getWorldStats()->barriers[barrierIndex].frameCount - 1;
- else
- frameNum = currentCommand.param2;
-
- if (_scene->_sceneResource->getWorldStats()->barriers[barrierIndex].tickCount < frameNum) {
- lineIncrement = 0;
- waitCycle = true;
- }
- }
- else
- debugC(kDebugLevelScripts, "Requested invalid object ID:0x%02X in Scene %d Script %d Line %d.", currentCommand.param1, _scene->getSceneIndex(), _currentScriptIndex, _currentLine);
- }
- break;
- case kPlaySpeech:
- if (currentCommand.param1 >= 0) {
- if (currentCommand.param3) // HACK - Find out why sometimes an offset is needed and other times not
- _scene->_sound->playSfx(_scene->_speechPack, currentCommand.param1 - 9);
- else
- _scene->_sound->playSfx(_scene->_speechPack, currentCommand.param1);
- }
- else
- debugC(kDebugLevelScripts, "Requested invalid sound ID:0x%02X in Scene %d Script %d Line %d.", currentCommand.param1, _scene->getSceneIndex(), _currentScriptIndex, _currentLine);
- break;
- default:
- debugC(kDebugLevelScripts, "Unhandled opcode 0x%02X in Scene %d Script %d Line %d.", _currentScript->commands[_currentLine].opcode, _scene->getSceneIndex(), _currentScriptIndex, _currentLine);
- break;
- } // end switch
-
- _currentLine += lineIncrement;
-
- } // end while
-
- if(done) {
- _currentLine = 0;
- _currentScriptIndex = 0;
- }
- }
- _processing = false;
-}
-
-} // end of namespace Asylum
+/* 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.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#include "asylum/interpreter.h"
+#include "asylum/sceneres.h"
+
+namespace Asylum {
+
+Interpreter::Interpreter(Scene *scene): _scene(scene) {
+ _currentLine = 0;
+ _currentScriptIndex = _scene->getDefaultActionIndex();
+ _currentLoops = 0;
+ _processing = false;
+}
+
+Interpreter::~Interpreter() {
+}
+
+void Interpreter::processActionLists() {
+ bool done = false, waitCycle = false;
+ int lineIncrement = 1;
+ _processing = true;
+
+ if (_currentScriptIndex != -1) {
+ ActionDefinitions *_currentScript = _scene->getActionList(_currentScriptIndex);
+ if (!_currentScript)
+ return;
+
+ while (!done && !waitCycle) {
+ lineIncrement = 1; // Reset line increment value
+
+ if (_currentLoops > 1000) {
+ // TODO - processActionLists has run too many interations
+ }
+
+ ActionCommand currentCommand = _currentScript->commands[_currentLine];
+
+ switch (currentCommand.opcode) {
+ case kReturn0:
+ done = true;
+ lineIncrement = 0;
+ break;
+ case kShowCursor:
+ _scene->_screen->showCursor();
+ // TODO - Enable click events
+ break;
+ case kHideCursor:
+ _scene->_screen->hideCursor();
+ // TODO - Disable click events
+ break;
+ case kPlayAnimation: {
+ int barrierIndex = _scene->_sceneResource->getBarrierIndexById(currentCommand.param1);
+ if (barrierIndex >= 0)
+ _scene->_sceneResource->getWorldStats()->barriers[barrierIndex].flags |= 0x20; // TODO - enums for flags (0x20 is visible/playing?)
+ else
+ debugC(kDebugLevelScripts, "Requested invalid object ID:0x%02X in Scene %d Script %d Line %d.", currentCommand.param1, _scene->getSceneIndex(), _currentScriptIndex, _currentLine);
+ }
+ break;
+ case kHideActor:
+ {
+ int actorIndex = 0;
+ if (currentCommand.param1 == -1)
+ ;//actorIndex = _scene->getWorldStats()->playerActor;
+ else
+ actorIndex = currentCommand.param1;
+
+ if ((actorIndex >= 0) && (actorIndex < _scene->_sceneResource->getWorldStats()->numActors)) {
+ _scene->actorVisible(actorIndex, false);
+ }
+ else
+ debugC(kDebugLevelScripts, "Requested invalid actor ID:0x%02X in Scene %d Script %d Line %d.", currentCommand.param1, _scene->getSceneIndex(), _currentScriptIndex, _currentLine);
+ }
+ break;
+ case kShowActor:
+ {
+ int actorIndex = 0;
+ if (currentCommand.param1 == -1)
+ ;//actorIndex = _scene->getWorldStats()->playerActor;
+ else
+ actorIndex = currentCommand.param1;
+
+ if ((actorIndex >= 0) && (actorIndex < _scene->_sceneResource->getWorldStats()->numActors)) {
+ _scene->actorVisible(actorIndex, true);
+ }
+ else
+ debugC(kDebugLevelScripts, "Requested invalid actor ID:0x%02X in Scene %d Script %d Line %d.", currentCommand.param1, _scene->getSceneIndex(), _currentScriptIndex, _currentLine);
+ }
+ break;
+ case kSetActorStats: {
+ int actorIndex = 0;
+ if (currentCommand.param1 == -1)
+ ;//actorIndex = _scene->getWorldStats()->playerActor;
+ else
+ actorIndex = currentCommand.param1;
+
+ if ((actorIndex >= 0) && (actorIndex < _scene->_sceneResource->getWorldStats()->numActors)) {
+ _scene->setActorPosition(actorIndex, currentCommand.param2, currentCommand.param3);
+ _scene->setActorAction(actorIndex, 112);//currentCommand.param4);
+ }
+ else
+ debugC(kDebugLevelScripts, "Requested invalid actor ID:0x%02X in Scene %d Script %d Line %d.", currentCommand.param1, _scene->getSceneIndex(), _currentScriptIndex, _currentLine);
+ }
+ break;
+ case kReturn:
+ done = true;
+ lineIncrement = 0;
+ break;
+ case kDestroyObject: {
+ int barrierIndex = _scene->_sceneResource->getBarrierIndexById(currentCommand.param1);
+ if (barrierIndex >= 0)
+ _scene->_sceneResource->getWorldStats()->barriers[barrierIndex].flags &= 0xFFFFDF; // TODO - enums for flags (0x20 is visible/playing?)
+ else
+ debugC(kDebugLevelScripts, "Requested invalid object ID:0x%02X in Scene %d Script %d Line %d.", currentCommand.param1, _scene->getSceneIndex(), _currentScriptIndex, _currentLine);
+ }
+ break;
+ case kWaitUntilFramePlayed: {
+ int barrierIndex = _scene->_sceneResource->getBarrierIndexById(currentCommand.param1);
+ if (barrierIndex >= 0) {
+ int frameNum = 0;
+ if (currentCommand.param2 == -1)
+ frameNum = _scene->_sceneResource->getWorldStats()->barriers[barrierIndex].frameCount - 1;
+ else
+ frameNum = currentCommand.param2;
+
+ if (_scene->_sceneResource->getWorldStats()->barriers[barrierIndex].tickCount < frameNum) {
+ lineIncrement = 0;
+ waitCycle = true;
+ }
+ }
+ else
+ debugC(kDebugLevelScripts, "Requested invalid object ID:0x%02X in Scene %d Script %d Line %d.", currentCommand.param1, _scene->getSceneIndex(), _currentScriptIndex, _currentLine);
+ }
+ break;
+ case kPlaySpeech:
+ if (currentCommand.param1 >= 0) {
+ if (currentCommand.param3) // HACK - Find out why sometimes an offset is needed and other times not
+ _scene->_sound->playSfx(_scene->_speechPack, currentCommand.param1 - 9);
+ else
+ _scene->_sound->playSfx(_scene->_speechPack, currentCommand.param1);
+ }
+ else
+ debugC(kDebugLevelScripts, "Requested invalid sound ID:0x%02X in Scene %d Script %d Line %d.", currentCommand.param1, _scene->getSceneIndex(), _currentScriptIndex, _currentLine);
+ break;
+ default:
+ debugC(kDebugLevelScripts, "Unhandled opcode 0x%02X in Scene %d Script %d Line %d.", _currentScript->commands[_currentLine].opcode, _scene->getSceneIndex(), _currentScriptIndex, _currentLine);
+ break;
+ } // end switch
+
+ _currentLine += lineIncrement;
+
+ } // end while
+
+ if(done) {
+ _currentLine = 0;
+ _currentScriptIndex = 0;
+ }
+ }
+ _processing = false;
+}
+
+} // end of namespace Asylum
diff --git a/engines/asylum/interpreter.h b/engines/asylum/interpreter.h
index 2e004de163..0db7c96269 100644
--- a/engines/asylum/interpreter.h
+++ b/engines/asylum/interpreter.h
@@ -1,156 +1,156 @@
-/* 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.
- *
- * $URL$
- * $Id$
- *
- */
-
-#ifndef ASYLUM_INTERPERTER_H_
-#define ASYLUM_INTERPERTER_H_
-
-#include "asylum/scene.h"
-
-namespace Asylum {
-
-
-class Interpreter {
-public:
- Interpreter(Scene *scene);
- ~Interpreter();
-
- void processActionLists();
- bool isProcessing() { return _processing; }
-
-private:
- Scene * _scene;
- int _currentLine;
- int _currentScriptIndex;
- int _currentLoops;
- bool _processing;
-
- friend class Console;
-};
-
-enum opcodes {
- kReturn0 = 0x00,
- kSetGameFlag,
- kClearGameFlag,
- kToogleGameFlag,
- kJumpIfGameFlag,
- kHideCursor,
- kShowCursor,
- kPlayAnimation,
- kMoveScenePosition,
- kHideActor,
- kShowActor,
- kSetActorStats,
- k_unk0C_SET_SCENE_FIELD88,
- kDisableActor,
- kEnableActor,
- kEnableBarriers,
- kReturn, // 0x10
- kDestroyObject,
- k_unk12_JMP_WALK_ACTOR,
- k_unk13_JMP_WALK_ACTOR,
- k_unk14_JMP_WALK_ACTOR,
- k_unk15,
- kResetAnimation,
- kClearFlag1Bit0,
- k_unk18_PLAY_SND,
- kJumpIfFlag2Bit0,
- kSetFlag2Bit0,
- kClearFlag2Bit0,
- kJumpIfFlag2Bit2,
- kSetFlag2Bit2,
- kClearFlag2Bit2,
- kJumpIfFlag2Bit1,
- kSetFlag2Bit1, // 0x20
- kClearFlag2Bit1,
- k_unk22,
- k_unk23,
- k_unk24,
- kRunEncounter,
- kJumpIfFlag2Bit4,
- kSetFlag2Bit4,
- kClearFlag2Bit4,
- kSetActorField638,
- kJumpIfActorField638,
- kChangeScene,
- k_unk2C_ActorSub,
- kPlayMovie,
- kStopAllObjectsSounds,
- kSetActionFlag01,
- kClearActionFlag01, // 0x30
- kResetSceneRect,
- kChangeMusicById,
- kStopMusic,
- k_unk34_Status,
- k_unk35,
- k_unk36,
- kRunMinigame,
- kJumpIfFlag2Bit3,
- kSetFlag2Bit3,
- kClearFlag2Bit3,
- k_unk3B_PALETTE_MOD,
- k_unk3C_CMP_VAL,
- kWaitUntilFramePlayed,
- kUpdateMatteBars,
- k_unk3F,
- k_unk40_SOUND, // 0x40
- kPlaySpeech,
- k_unk42,
- k_unk43,
- kPaletteFade,
- kStartPaletteFadeThread,
- k_unk46,
- kActorFaceObject,
- k_unk48_MATTE_01,
- k_unk49_MATTE_90,
- kJumpIfSoundPlaying,
- kChangePlayerCharacterIndex,
- kChangeActorField40,
- kStopSound,
- k_unk4E_RANDOM_COMMAND,
- kDrawGame,
- kQuit, // 0x50
- kJumpObjectFrame,
- k_unk52,
- k_unk53,
- k_unk54_SET_ACTIONLIST_6EC,
- k_unk55,
- k_unk56,
- k_unk57,
- k_unk58,
- k_unk59,
- k_unk5A,
- k_unk5B,
- k_unk5C,
- k_unk5D,
- k_unk5E,
- k_unk5F,
- k_unk60_SET_OR_CLR_ACTIONAREA_FLAG, // 0x60
- k_unk61,
- k_unk62_SHOW_OPTIONS_SCREEN
-};
-
-} // end of namespace Asylum
-
-#endif
+/* 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.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#ifndef ASYLUM_INTERPERTER_H_
+#define ASYLUM_INTERPERTER_H_
+
+#include "asylum/scene.h"
+
+namespace Asylum {
+
+
+class Interpreter {
+public:
+ Interpreter(Scene *scene);
+ ~Interpreter();
+
+ void processActionLists();
+ bool isProcessing() { return _processing; }
+
+private:
+ Scene * _scene;
+ int _currentLine;
+ int _currentScriptIndex;
+ int _currentLoops;
+ bool _processing;
+
+ friend class Console;
+};
+
+enum opcodes {
+ kReturn0 = 0x00,
+ kSetGameFlag,
+ kClearGameFlag,
+ kToogleGameFlag,
+ kJumpIfGameFlag,
+ kHideCursor,
+ kShowCursor,
+ kPlayAnimation,
+ kMoveScenePosition,
+ kHideActor,
+ kShowActor,
+ kSetActorStats,
+ k_unk0C_SET_SCENE_FIELD88,
+ kDisableActor,
+ kEnableActor,
+ kEnableBarriers,
+ kReturn, // 0x10
+ kDestroyObject,
+ k_unk12_JMP_WALK_ACTOR,
+ k_unk13_JMP_WALK_ACTOR,
+ k_unk14_JMP_WALK_ACTOR,
+ k_unk15,
+ kResetAnimation,
+ kClearFlag1Bit0,
+ k_unk18_PLAY_SND,
+ kJumpIfFlag2Bit0,
+ kSetFlag2Bit0,
+ kClearFlag2Bit0,
+ kJumpIfFlag2Bit2,
+ kSetFlag2Bit2,
+ kClearFlag2Bit2,
+ kJumpIfFlag2Bit1,
+ kSetFlag2Bit1, // 0x20
+ kClearFlag2Bit1,
+ k_unk22,
+ k_unk23,
+ k_unk24,
+ kRunEncounter,
+ kJumpIfFlag2Bit4,
+ kSetFlag2Bit4,
+ kClearFlag2Bit4,
+ kSetActorField638,
+ kJumpIfActorField638,
+ kChangeScene,
+ k_unk2C_ActorSub,
+ kPlayMovie,
+ kStopAllObjectsSounds,
+ kSetActionFlag01,
+ kClearActionFlag01, // 0x30
+ kResetSceneRect,
+ kChangeMusicById,
+ kStopMusic,
+ k_unk34_Status,
+ k_unk35,
+ k_unk36,
+ kRunMinigame,
+ kJumpIfFlag2Bit3,
+ kSetFlag2Bit3,
+ kClearFlag2Bit3,
+ k_unk3B_PALETTE_MOD,
+ k_unk3C_CMP_VAL,
+ kWaitUntilFramePlayed,
+ kUpdateMatteBars,
+ k_unk3F,
+ k_unk40_SOUND, // 0x40
+ kPlaySpeech,
+ k_unk42,
+ k_unk43,
+ kPaletteFade,
+ kStartPaletteFadeThread,
+ k_unk46,
+ kActorFaceObject,
+ k_unk48_MATTE_01,
+ k_unk49_MATTE_90,
+ kJumpIfSoundPlaying,
+ kChangePlayerCharacterIndex,
+ kChangeActorField40,
+ kStopSound,
+ k_unk4E_RANDOM_COMMAND,
+ kDrawGame,
+ kQuit, // 0x50
+ kJumpObjectFrame,
+ k_unk52,
+ k_unk53,
+ k_unk54_SET_ACTIONLIST_6EC,
+ k_unk55,
+ k_unk56,
+ k_unk57,
+ k_unk58,
+ k_unk59,
+ k_unk5A,
+ k_unk5B,
+ k_unk5C,
+ k_unk5D,
+ k_unk5E,
+ k_unk5F,
+ k_unk60_SET_OR_CLR_ACTIONAREA_FLAG, // 0x60
+ k_unk61,
+ k_unk62_SHOW_OPTIONS_SCREEN
+};
+
+} // end of namespace Asylum
+
+#endif
Commit: a9ff616822beb2638ba36081d51d2038043ce878
https://github.com/scummvm/scummvm/commit/a9ff616822beb2638ba36081d51d2038043ce878
Author: Alex Bevilacqua (alexbevi at gmail.com)
Date: 2021-05-17T15:35:30+02:00
Commit Message:
ASYLUM: svn:keywords
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@226 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/encounters.h
diff --git a/engines/asylum/encounters.h b/engines/asylum/encounters.h
index a90a51c68a..840d4a4064 100644
--- a/engines/asylum/encounters.h
+++ b/engines/asylum/encounters.h
@@ -52,4 +52,4 @@ private:
} // end of namespace Asylum
-#endif /* ENCOUNTERS_H_ */
+#endif
Commit: 19d9e775b9418c18259947ba1bc0fa209597f167
https://github.com/scummvm/scummvm/commit/19d9e775b9418c18259947ba1bc0fa209597f167
Author: Joseph Davies (deledrius at gmail.com)
Date: 2021-05-17T15:35:30+02:00
Commit Message:
ASYLUM: Fixed warnings.
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@227 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/sceneres.cpp
engines/asylum/sceneres.h
diff --git a/engines/asylum/sceneres.cpp b/engines/asylum/sceneres.cpp
index a17682ba13..563f2313ae 100644
--- a/engines/asylum/sceneres.cpp
+++ b/engines/asylum/sceneres.cpp
@@ -40,8 +40,8 @@ SceneResource::~SceneResource() {
delete _actionList;
}
-int SceneResource::getBarrierIndexById(int id) {
- for (int i=0; i < _worldStats->numBarriers; i++)
+int SceneResource::getBarrierIndexById(uint32 id) {
+ for (uint32 i=0; i < _worldStats->numBarriers; i++)
{
if (_worldStats->barriers[i].id == id)
return i;
diff --git a/engines/asylum/sceneres.h b/engines/asylum/sceneres.h
index 12ba29a130..5bf053d800 100644
--- a/engines/asylum/sceneres.h
+++ b/engines/asylum/sceneres.h
@@ -70,7 +70,7 @@ public:
ActionList* getActionList() { return _actionList; }
MainActor* getMainActor() { return _mainActor; }
- int getBarrierIndexById(int id);
+ int getBarrierIndexById(uint32 id);
private:
WorldStats *_worldStats;
Commit: 7795ce38d8a3efefec97fbb288e4a7aaa73e2105
https://github.com/scummvm/scummvm/commit/7795ce38d8a3efefec97fbb288e4a7aaa73e2105
Author: Joseph Davies (deledrius at gmail.com)
Date: 2021-05-17T15:35:30+02:00
Commit Message:
ASYLUM: Added support for polygon testing inside bounding boxes.
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@228 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/scene.cpp
engines/asylum/scene.h
diff --git a/engines/asylum/scene.cpp b/engines/asylum/scene.cpp
index f4344b22a9..f90087702c 100644
--- a/engines/asylum/scene.cpp
+++ b/engines/asylum/scene.cpp
@@ -59,7 +59,7 @@ Scene::Scene(Screen *screen, Sound *sound, uint8 sceneIdx): _screen(screen), _so
_leftClick = false;
_rightButton = false;
_isActive = false;
- g_debugPolygons = 0;
+ g_debugPolygons = 1;
}
Scene::~Scene() {
@@ -300,9 +300,11 @@ void Scene::update() {
for (uint32 p = 0; p < _sceneResource->getGamePolygons()->numEntries; p++) {
PolyDefinitions poly = _sceneResource->getGamePolygons()->polygons[p];
if (poly.boundingRect.contains(_mouseX + _startX, _mouseY + _startY)) {
- curHotspot = (int32)p;
- updateCursor();
- break;
+ if (pointInPoly(&poly, _mouseX + _startX, _mouseY + _startY)) {
+ curHotspot = (int32)p;
+ updateCursor();
+ break;
+ }
}
}
@@ -408,6 +410,33 @@ void Scene::updateBarrier(Screen *screen, ResourcePack *res, uint8 barrierIndex)
delete gra;
}
+bool Scene::pointInPoly(PolyDefinitions *poly, int x, int y) {
+ // Copied from backends/vkeybd/polygon.cpp
+ int yflag0;
+ int yflag1;
+ bool inside_flag = false;
+ unsigned int pt;
+
+ Common::Point *vtx0 = &poly->points[poly->numPoints - 1];
+ Common::Point *vtx1 = &poly->points[0];
+
+ yflag0 = (vtx0->y >= y);
+ for (pt = 0; pt < poly->numPoints; pt++, vtx1++) {
+ yflag1 = (vtx1->y >= y);
+ if (yflag0 != yflag1) {
+ if (((vtx1->y - y) * (vtx0->x - vtx1->x) >=
+ (vtx1->x - x) * (vtx0->y - vtx1->y)) == yflag1) {
+ inside_flag = !inside_flag;
+ }
+ }
+ yflag0 = yflag1;
+ vtx0 = vtx1;
+ }
+
+ return inside_flag;
+}
+
+
// POLYGONS DEBUG
void Scene::ShowPolygons() {
for (uint32 p = 0; p < _sceneResource->getGamePolygons()->numEntries; p++) {
diff --git a/engines/asylum/scene.h b/engines/asylum/scene.h
index 4634bb9c32..e923a666e3 100644
--- a/engines/asylum/scene.h
+++ b/engines/asylum/scene.h
@@ -40,8 +40,9 @@ class Screen;
class Sound;
class SceneResource;
class Text;
-class ActionDefinitions;
class Interpreter;
+class ActionDefinitions;
+class PolyDefinitions;
class Scene {
public:
@@ -99,6 +100,7 @@ private:
void updateBarrier(Screen *screen, ResourcePack *res, uint8 actorIndex);
void ShowPolygons();
+ bool pointInPoly(PolyDefinitions *poly, int x, int y);
friend class Interpreter;
}; // end of class Scene
Commit: 90759f311a717e8d7022a4885b6f89d796640a28
https://github.com/scummvm/scummvm/commit/90759f311a717e8d7022a4885b6f89d796640a28
Author: Joseph Davies (deledrius at gmail.com)
Date: 2021-05-17T15:35:30+02:00
Commit Message:
ASYLUM: -- Removed temporary testing value left in kSetActorStats case.
-- Added loop control (still needs failure code).
-- Added setActionByIndex to actor to support kSetActorStats instruction data.
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@229 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/actor.cpp
engines/asylum/actor.h
engines/asylum/interpreter.cpp
engines/asylum/scene.cpp
diff --git a/engines/asylum/actor.cpp b/engines/asylum/actor.cpp
index 0f3ece7f62..d75c6bca8a 100644
--- a/engines/asylum/actor.cpp
+++ b/engines/asylum/actor.cpp
@@ -58,6 +58,7 @@ void MainActor::setAction(int action) {
delete _graphic;
int act = (action < 100) ? action : action - 100;
+
_graphic = new GraphicResource(_resPack, _resources[act]);
// Flip horizontally if necessary
@@ -79,6 +80,10 @@ void MainActor::setAction(int action) {
_currentFrame = 0;
}
+void MainActor::setActionByIndex(int index) {
+ setAction(_resources[index] & 0xFFFF);
+}
+
GraphicFrame *MainActor::getFrame() {
assert(_graphic);
diff --git a/engines/asylum/actor.h b/engines/asylum/actor.h
index 70ece89096..3e3fac9613 100644
--- a/engines/asylum/actor.h
+++ b/engines/asylum/actor.h
@@ -134,6 +134,7 @@ public:
void setResourcePack(ResourcePack *resPack) { _resPack = resPack; }
void setAction(int action);
+ void setActionByIndex(int index);
void drawActorAt(Screen *screen, uint16 x, uint16 y);
void drawActor(Screen *screen);
void walkTo(Screen *screen, uint16 x, uint16 y);
diff --git a/engines/asylum/interpreter.cpp b/engines/asylum/interpreter.cpp
index 354855cb76..407ea39854 100644
--- a/engines/asylum/interpreter.cpp
+++ b/engines/asylum/interpreter.cpp
@@ -117,7 +117,7 @@ void Interpreter::processActionLists() {
if ((actorIndex >= 0) && (actorIndex < _scene->_sceneResource->getWorldStats()->numActors)) {
_scene->setActorPosition(actorIndex, currentCommand.param2, currentCommand.param3);
- _scene->setActorAction(actorIndex, 112);//currentCommand.param4);
+ _scene->setActorAction(actorIndex, currentCommand.param4);
}
else
debugC(kDebugLevelScripts, "Requested invalid actor ID:0x%02X in Scene %d Script %d Line %d.", currentCommand.param1, _scene->getSceneIndex(), _currentScriptIndex, _currentLine);
@@ -164,17 +164,19 @@ void Interpreter::processActionLists() {
debugC(kDebugLevelScripts, "Requested invalid sound ID:0x%02X in Scene %d Script %d Line %d.", currentCommand.param1, _scene->getSceneIndex(), _currentScriptIndex, _currentLine);
break;
default:
- debugC(kDebugLevelScripts, "Unhandled opcode 0x%02X in Scene %d Script %d Line %d.", _currentScript->commands[_currentLine].opcode, _scene->getSceneIndex(), _currentScriptIndex, _currentLine);
+ debugC(kDebugLevelScripts, "Unhandled opcode 0x%02X in Scene %d Script %d Line %d.", currentCommand.opcode, _scene->getSceneIndex(), _currentScriptIndex, _currentLine);
break;
} // end switch
_currentLine += lineIncrement;
+ _currentLoops++;
} // end while
if(done) {
_currentLine = 0;
_currentScriptIndex = 0;
+ _currentLoops = 0;
}
}
_processing = false;
diff --git a/engines/asylum/scene.cpp b/engines/asylum/scene.cpp
index f90087702c..4a35613897 100644
--- a/engines/asylum/scene.cpp
+++ b/engines/asylum/scene.cpp
@@ -130,7 +130,7 @@ void Scene::setActorAction(int actorIndex, int action) {
// FIXME - Remove this once mainActor uses proper actor info
if (actorIndex == 0) {
if(_sceneResource->getMainActor())
- _sceneResource->getMainActor()->setAction(action);
+ _sceneResource->getMainActor()->setActionByIndex(action); // The action appears to be an index rather than a direct resId
}
}
Commit: 71dba6739f34fdc899ca059027d87b847c5b6ff0
https://github.com/scummvm/scummvm/commit/71dba6739f34fdc899ca059027d87b847c5b6ff0
Author: Joseph Davies (deledrius at gmail.com)
Date: 2021-05-17T15:35:31+02:00
Commit Message:
ASYLUM: Added temporary resource check to work around crash in Scene 6.
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@230 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/scene.cpp
diff --git a/engines/asylum/scene.cpp b/engines/asylum/scene.cpp
index 4a35613897..4d4cade860 100644
--- a/engines/asylum/scene.cpp
+++ b/engines/asylum/scene.cpp
@@ -59,7 +59,7 @@ Scene::Scene(Screen *screen, Sound *sound, uint8 sceneIdx): _screen(screen), _so
_leftClick = false;
_rightButton = false;
_isActive = false;
- g_debugPolygons = 1;
+ g_debugPolygons = 0;
}
Scene::~Scene() {
@@ -389,7 +389,9 @@ void Scene::copyToBackBufferClipped(Graphics::Surface *surface, int x, int y) {
void Scene::updateBarrier(Screen *screen, ResourcePack *res, uint8 barrierIndex) {
BarrierItem barrier = _sceneResource->getWorldStats()->barriers[barrierIndex];
GraphicResource *gra = new GraphicResource(res, barrier.resId);
- GraphicFrame *fra = gra->getFrame(barrier.tickCount);
+ if (!gra->getFrameCount())
+ return;
+ GraphicFrame *fra = gra->getFrame(barrier.tickCount);
#if 0
// DEBUG bounding box
Commit: 42457009363343fac22b3dd024302c5eaaafc6e4
https://github.com/scummvm/scummvm/commit/42457009363343fac22b3dd024302c5eaaafc6e4
Author: Joseph Davies (deledrius at gmail.com)
Date: 2021-05-17T15:35:31+02:00
Commit Message:
ASYLUM: -- Added new console commands "script" and "scene" to run arbitrary scripts by number and to change scenes, respectively.
-- Modified scope of access for Interpreter so that it can queue video playback and scene changes.
-- Added delayedSceneChange capability to support console and script commands.
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@231 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/interpreter.h
diff --git a/engines/asylum/interpreter.h b/engines/asylum/interpreter.h
index 0db7c96269..f6e1e73eec 100644
--- a/engines/asylum/interpreter.h
+++ b/engines/asylum/interpreter.h
@@ -33,14 +33,16 @@ namespace Asylum {
class Interpreter {
public:
- Interpreter(Scene *scene);
+ Interpreter(AsylumEngine *vm);
~Interpreter();
+ void doSceneChanged();
void processActionLists();
bool isProcessing() { return _processing; }
private:
- Scene * _scene;
+ AsylumEngine *_engine;
+ Scene *_scene;
int _currentLine;
int _currentScriptIndex;
int _currentLoops;
Commit: c2a7b403966d7a094a0f0f24d635276b0d12eeac
https://github.com/scummvm/scummvm/commit/c2a7b403966d7a094a0f0f24d635276b0d12eeac
Author: Joseph Davies (deledrius at gmail.com)
Date: 2021-05-17T15:35:31+02:00
Commit Message:
ASYLUM: Commit for changes accidentally left out of r231.
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@232 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/asylum.cpp
engines/asylum/asylum.h
engines/asylum/console.cpp
engines/asylum/console.h
engines/asylum/interpreter.cpp
diff --git a/engines/asylum/asylum.cpp b/engines/asylum/asylum.cpp
index 140d4576d4..684da2c563 100644
--- a/engines/asylum/asylum.cpp
+++ b/engines/asylum/asylum.cpp
@@ -84,6 +84,7 @@ Common::Error AsylumEngine::init() {
_mainMenu = 0;
_scene = 0;
_delayedVideoNumber = -1;
+ _delayedSceneNumber = -1;
return Common::kNoError;
}
@@ -106,7 +107,7 @@ Common::Error AsylumEngine::go() {
_scene = new Scene(_screen, _sound, 5);
// Set up the game's script interpreter
- _interpreter = new Interpreter(_scene);
+ _interpreter = new Interpreter(this);
// Set up main menu
_mainMenu = new MainMenu(_screen, _sound, _scene);
@@ -128,6 +129,7 @@ void AsylumEngine::waitForTimer(int msec_delay) {
while (_system->getMillis() < start_time + msec_delay) {
checkForEvent(false);
checkForDelayedVideo();
+ checkForDelayedSceneChange();
_system->updateScreen();
_interpreter->processActionLists();
}
@@ -192,4 +194,21 @@ void AsylumEngine::checkForDelayedVideo() {
}
}
+
+void AsylumEngine::checkForDelayedSceneChange() {
+ if (_delayedSceneNumber >= 0 && !_interpreter->isProcessing()) {
+ _sound->stopMusic();
+ _sound->stopSfx();
+
+ if(_scene)
+ delete _scene;
+ _scene = new Scene(_screen, _sound, _delayedSceneNumber);
+
+ _interpreter->doSceneChanged();
+
+ _scene->enterScene();
+ _delayedSceneNumber = -1;
+ }
+}
+
} // namespace Asylum
diff --git a/engines/asylum/asylum.h b/engines/asylum/asylum.h
index 18aed639e2..70f9269a38 100644
--- a/engines/asylum/asylum.h
+++ b/engines/asylum/asylum.h
@@ -75,6 +75,7 @@ private:
void waitForTimer(int msec_delay);
void updateMouseCursor();
void checkForDelayedVideo();
+ void checkForDelayedSceneChange();
Common::Language _language;
Common::RandomSource _rnd;
@@ -87,8 +88,10 @@ private:
Video *_video;
Interpreter *_interpreter;
int _delayedVideoNumber;
+ int _delayedSceneNumber;
friend class Console;
+ friend class Interpreter;
};
} // namespace Asylum
diff --git a/engines/asylum/console.cpp b/engines/asylum/console.cpp
index 4bdf2924cf..210ecf24f3 100644
--- a/engines/asylum/console.cpp
+++ b/engines/asylum/console.cpp
@@ -37,6 +37,8 @@ Console::Console(AsylumEngine *vm) : GUI::Debugger() {
_vm = vm;
DCmd_Register("video", WRAP_METHOD(Console, cmdPlayVideo));
+ DCmd_Register("script", WRAP_METHOD(Console, cmdRunScript));
+ DCmd_Register("scene", WRAP_METHOD(Console, cmdChangeScene));
DVar_Register("debugpolygons", &g_debugPolygons, DVAR_INT, 0);
}
@@ -55,5 +57,28 @@ bool Console::cmdPlayVideo(int argc, const char **argv) {
return false;
}
+bool Console::cmdRunScript(int argc, const char **argv) {
+ if (argc != 2) {
+ DebugPrintf("Usage %s <script number>\n", argv[0]);
+ return true;
+ }
+
+ _vm->_interpreter->_currentScriptIndex = atoi(argv[1]);
+ _vm->_interpreter->_currentLine = 0;
+
+ return false;
+}
+
+bool Console::cmdChangeScene(int argc, const char **argv) {
+ if (argc != 2) {
+ DebugPrintf("Usage %s <scene number>\n", argv[0]);
+ return true;
+ }
+
+ _vm->_delayedSceneNumber = atoi(argv[1]);
+
+ return false;
+}
+
} // End of namespace Asulym
diff --git a/engines/asylum/console.h b/engines/asylum/console.h
index 2d036f72a3..9267f9eb38 100644
--- a/engines/asylum/console.h
+++ b/engines/asylum/console.h
@@ -41,6 +41,8 @@ public:
private:
bool cmdPlayVideo(int argc, const char **argv);
+ bool cmdRunScript(int argc, const char **argv);
+ bool cmdChangeScene(int argc, const char **argv);
private:
AsylumEngine *_vm;
diff --git a/engines/asylum/interpreter.cpp b/engines/asylum/interpreter.cpp
index 407ea39854..399a795e6f 100644
--- a/engines/asylum/interpreter.cpp
+++ b/engines/asylum/interpreter.cpp
@@ -28,16 +28,23 @@
namespace Asylum {
-Interpreter::Interpreter(Scene *scene): _scene(scene) {
+Interpreter::Interpreter(AsylumEngine *vm): _engine(vm) {
_currentLine = 0;
- _currentScriptIndex = _scene->getDefaultActionIndex();
+ _currentScriptIndex = 0;
_currentLoops = 0;
_processing = false;
+ doSceneChanged();
}
Interpreter::~Interpreter() {
}
+void Interpreter::doSceneChanged() {
+ _scene = _engine->_scene;
+ _currentLine = 0;
+ _currentScriptIndex = _scene->getDefaultActionIndex();
+}
+
void Interpreter::processActionLists() {
bool done = false, waitCycle = false;
int lineIncrement = 1;
@@ -135,6 +142,13 @@ void Interpreter::processActionLists() {
debugC(kDebugLevelScripts, "Requested invalid object ID:0x%02X in Scene %d Script %d Line %d.", currentCommand.param1, _scene->getSceneIndex(), _currentScriptIndex, _currentLine);
}
break;
+ case kChangeScene:
+ _engine->_delayedSceneNumber = currentCommand.param1 + 4;
+ debug(kDebugLevelScripts, "Queueing Scene Change to scene %d...", currentCommand.param1 + 4);
+ break;
+ case kPlayMovie:
+ _engine->_delayedVideoNumber = currentCommand.param1;
+ break;
case kWaitUntilFramePlayed: {
int barrierIndex = _scene->_sceneResource->getBarrierIndexById(currentCommand.param1);
if (barrierIndex >= 0) {
@@ -154,6 +168,7 @@ void Interpreter::processActionLists() {
}
break;
case kPlaySpeech:
+ // TODO - Add support for other param options
if (currentCommand.param1 >= 0) {
if (currentCommand.param3) // HACK - Find out why sometimes an offset is needed and other times not
_scene->_sound->playSfx(_scene->_speechPack, currentCommand.param1 - 9);
Commit: adf21355eedbced834982e1af94068a94db2dc8a
https://github.com/scummvm/scummvm/commit/adf21355eedbced834982e1af94068a94db2dc8a
Author: Filippos Karapetis (md5 at scummvm.org)
Date: 2021-05-17T15:35:31+02:00
Commit Message:
ASYLUM: Fixed warnings
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@233 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/interpreter.cpp
engines/asylum/scene.cpp
engines/asylum/scene.h
diff --git a/engines/asylum/interpreter.cpp b/engines/asylum/interpreter.cpp
index 399a795e6f..c60c775dcb 100644
--- a/engines/asylum/interpreter.cpp
+++ b/engines/asylum/interpreter.cpp
@@ -87,7 +87,7 @@ void Interpreter::processActionLists() {
break;
case kHideActor:
{
- int actorIndex = 0;
+ uint32 actorIndex = 0;
if (currentCommand.param1 == -1)
;//actorIndex = _scene->getWorldStats()->playerActor;
else
@@ -102,7 +102,7 @@ void Interpreter::processActionLists() {
break;
case kShowActor:
{
- int actorIndex = 0;
+ uint32 actorIndex = 0;
if (currentCommand.param1 == -1)
;//actorIndex = _scene->getWorldStats()->playerActor;
else
@@ -116,7 +116,7 @@ void Interpreter::processActionLists() {
}
break;
case kSetActorStats: {
- int actorIndex = 0;
+ uint32 actorIndex = 0;
if (currentCommand.param1 == -1)
;//actorIndex = _scene->getWorldStats()->playerActor;
else
@@ -152,7 +152,7 @@ void Interpreter::processActionLists() {
case kWaitUntilFramePlayed: {
int barrierIndex = _scene->_sceneResource->getBarrierIndexById(currentCommand.param1);
if (barrierIndex >= 0) {
- int frameNum = 0;
+ uint32 frameNum = 0;
if (currentCommand.param2 == -1)
frameNum = _scene->_sceneResource->getWorldStats()->barriers[barrierIndex].frameCount - 1;
else
diff --git a/engines/asylum/scene.cpp b/engines/asylum/scene.cpp
index 4d4cade860..05e3b365de 100644
--- a/engines/asylum/scene.cpp
+++ b/engines/asylum/scene.cpp
@@ -145,8 +145,8 @@ void Scene::actorVisible(int actorIndex, bool visible) {
// FIXME - Remove this once mainActor uses proper actor info
if (actorIndex == 0) {
- if(_sceneResource->getMainActor())
- ;//_sceneResource->getMainActor()->setAction(action);
+ //if(_sceneResource->getMainActor())
+ //_sceneResource->getMainActor()->setAction(action);
}
}
@@ -157,8 +157,8 @@ bool Scene::actorVisible(int actorIndex) {
// FIXME - Remove this once mainActor uses proper actor info
if (actorIndex == 0) {
- if(_sceneResource->getMainActor())
- ;//_sceneResource->getMainActor()->setAction(action);
+ //if(_sceneResource->getMainActor())
+ //_sceneResource->getMainActor()->setAction(action);
}
return false;
diff --git a/engines/asylum/scene.h b/engines/asylum/scene.h
index e923a666e3..c32e55c618 100644
--- a/engines/asylum/scene.h
+++ b/engines/asylum/scene.h
@@ -41,8 +41,8 @@ class Sound;
class SceneResource;
class Text;
class Interpreter;
-class ActionDefinitions;
-class PolyDefinitions;
+struct ActionDefinitions;
+struct PolyDefinitions;
class Scene {
public:
Commit: a259fb4d982e23580c430dfdc02edbd355efcf3c
https://github.com/scummvm/scummvm/commit/a259fb4d982e23580c430dfdc02edbd355efcf3c
Author: Filippos Karapetis (md5 at scummvm.org)
Date: 2021-05-17T15:35:31+02:00
Commit Message:
ASYLUM: Updated the MSVC project file (added interpreter.*)
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@234 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/asylum.vcproj
diff --git a/engines/asylum/asylum.vcproj b/engines/asylum/asylum.vcproj
index 13de273c11..f55ebd02c5 100644
--- a/engines/asylum/asylum.vcproj
+++ b/engines/asylum/asylum.vcproj
@@ -205,6 +205,14 @@
RelativePath="..\..\engines\asylum\graphics.h"
>
</File>
+ <File
+ RelativePath="..\..\engines\asylum\interpreter.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\engines\asylum\interpreter.h"
+ >
+ </File>
<File
RelativePath="..\..\engines\asylum\menu.cpp"
>
Commit: bc773b9544bf62415435d24917df0f987bd15413
https://github.com/scummvm/scummvm/commit/bc773b9544bf62415435d24917df0f987bd15413
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-05-17T15:35:31+02:00
Commit Message:
ASYLUM: Formatting
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@235 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/interpreter.cpp
engines/asylum/interpreter.h
diff --git a/engines/asylum/interpreter.cpp b/engines/asylum/interpreter.cpp
index c60c775dcb..5323d6443a 100644
--- a/engines/asylum/interpreter.cpp
+++ b/engines/asylum/interpreter.cpp
@@ -11,7 +11,7 @@
* 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
+ * 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
@@ -29,172 +29,169 @@
namespace Asylum {
Interpreter::Interpreter(AsylumEngine *vm): _engine(vm) {
- _currentLine = 0;
- _currentScriptIndex = 0;
- _currentLoops = 0;
- _processing = false;
- doSceneChanged();
+ _currentLine = 0;
+ _currentScriptIndex = 0;
+ _currentLoops = 0;
+ _processing = false;
+ doSceneChanged();
}
Interpreter::~Interpreter() {
}
void Interpreter::doSceneChanged() {
- _scene = _engine->_scene;
- _currentLine = 0;
- _currentScriptIndex = _scene->getDefaultActionIndex();
+ _scene = _engine->_scene;
+ _currentLine = 0;
+ _currentScriptIndex = _scene->getDefaultActionIndex();
}
void Interpreter::processActionLists() {
- bool done = false, waitCycle = false;
- int lineIncrement = 1;
- _processing = true;
+ bool done = false, waitCycle = false;
+ int lineIncrement = 1;
+ _processing = true;
- if (_currentScriptIndex != -1) {
- ActionDefinitions *_currentScript = _scene->getActionList(_currentScriptIndex);
- if (!_currentScript)
- return;
-
- while (!done && !waitCycle) {
- lineIncrement = 1; // Reset line increment value
-
- if (_currentLoops > 1000) {
- // TODO - processActionLists has run too many interations
- }
-
- ActionCommand currentCommand = _currentScript->commands[_currentLine];
-
- switch (currentCommand.opcode) {
- case kReturn0:
- done = true;
- lineIncrement = 0;
- break;
- case kShowCursor:
- _scene->_screen->showCursor();
- // TODO - Enable click events
- break;
- case kHideCursor:
- _scene->_screen->hideCursor();
- // TODO - Disable click events
- break;
- case kPlayAnimation: {
- int barrierIndex = _scene->_sceneResource->getBarrierIndexById(currentCommand.param1);
- if (barrierIndex >= 0)
- _scene->_sceneResource->getWorldStats()->barriers[barrierIndex].flags |= 0x20; // TODO - enums for flags (0x20 is visible/playing?)
- else
- debugC(kDebugLevelScripts, "Requested invalid object ID:0x%02X in Scene %d Script %d Line %d.", currentCommand.param1, _scene->getSceneIndex(), _currentScriptIndex, _currentLine);
- }
- break;
- case kHideActor:
- {
- uint32 actorIndex = 0;
- if (currentCommand.param1 == -1)
- ;//actorIndex = _scene->getWorldStats()->playerActor;
- else
- actorIndex = currentCommand.param1;
-
- if ((actorIndex >= 0) && (actorIndex < _scene->_sceneResource->getWorldStats()->numActors)) {
- _scene->actorVisible(actorIndex, false);
- }
- else
- debugC(kDebugLevelScripts, "Requested invalid actor ID:0x%02X in Scene %d Script %d Line %d.", currentCommand.param1, _scene->getSceneIndex(), _currentScriptIndex, _currentLine);
- }
- break;
- case kShowActor:
- {
- uint32 actorIndex = 0;
- if (currentCommand.param1 == -1)
- ;//actorIndex = _scene->getWorldStats()->playerActor;
- else
- actorIndex = currentCommand.param1;
-
- if ((actorIndex >= 0) && (actorIndex < _scene->_sceneResource->getWorldStats()->numActors)) {
- _scene->actorVisible(actorIndex, true);
- }
- else
- debugC(kDebugLevelScripts, "Requested invalid actor ID:0x%02X in Scene %d Script %d Line %d.", currentCommand.param1, _scene->getSceneIndex(), _currentScriptIndex, _currentLine);
- }
- break;
- case kSetActorStats: {
- uint32 actorIndex = 0;
- if (currentCommand.param1 == -1)
- ;//actorIndex = _scene->getWorldStats()->playerActor;
- else
- actorIndex = currentCommand.param1;
-
- if ((actorIndex >= 0) && (actorIndex < _scene->_sceneResource->getWorldStats()->numActors)) {
- _scene->setActorPosition(actorIndex, currentCommand.param2, currentCommand.param3);
- _scene->setActorAction(actorIndex, currentCommand.param4);
- }
- else
- debugC(kDebugLevelScripts, "Requested invalid actor ID:0x%02X in Scene %d Script %d Line %d.", currentCommand.param1, _scene->getSceneIndex(), _currentScriptIndex, _currentLine);
- }
- break;
- case kReturn:
- done = true;
- lineIncrement = 0;
- break;
- case kDestroyObject: {
- int barrierIndex = _scene->_sceneResource->getBarrierIndexById(currentCommand.param1);
- if (barrierIndex >= 0)
- _scene->_sceneResource->getWorldStats()->barriers[barrierIndex].flags &= 0xFFFFDF; // TODO - enums for flags (0x20 is visible/playing?)
- else
- debugC(kDebugLevelScripts, "Requested invalid object ID:0x%02X in Scene %d Script %d Line %d.", currentCommand.param1, _scene->getSceneIndex(), _currentScriptIndex, _currentLine);
- }
- break;
- case kChangeScene:
- _engine->_delayedSceneNumber = currentCommand.param1 + 4;
- debug(kDebugLevelScripts, "Queueing Scene Change to scene %d...", currentCommand.param1 + 4);
- break;
- case kPlayMovie:
- _engine->_delayedVideoNumber = currentCommand.param1;
- break;
- case kWaitUntilFramePlayed: {
- int barrierIndex = _scene->_sceneResource->getBarrierIndexById(currentCommand.param1);
- if (barrierIndex >= 0) {
- uint32 frameNum = 0;
- if (currentCommand.param2 == -1)
- frameNum = _scene->_sceneResource->getWorldStats()->barriers[barrierIndex].frameCount - 1;
- else
- frameNum = currentCommand.param2;
-
- if (_scene->_sceneResource->getWorldStats()->barriers[barrierIndex].tickCount < frameNum) {
- lineIncrement = 0;
- waitCycle = true;
- }
- }
- else
- debugC(kDebugLevelScripts, "Requested invalid object ID:0x%02X in Scene %d Script %d Line %d.", currentCommand.param1, _scene->getSceneIndex(), _currentScriptIndex, _currentLine);
- }
- break;
- case kPlaySpeech:
- // TODO - Add support for other param options
- if (currentCommand.param1 >= 0) {
- if (currentCommand.param3) // HACK - Find out why sometimes an offset is needed and other times not
- _scene->_sound->playSfx(_scene->_speechPack, currentCommand.param1 - 9);
- else
- _scene->_sound->playSfx(_scene->_speechPack, currentCommand.param1);
- }
- else
- debugC(kDebugLevelScripts, "Requested invalid sound ID:0x%02X in Scene %d Script %d Line %d.", currentCommand.param1, _scene->getSceneIndex(), _currentScriptIndex, _currentLine);
- break;
- default:
- debugC(kDebugLevelScripts, "Unhandled opcode 0x%02X in Scene %d Script %d Line %d.", currentCommand.opcode, _scene->getSceneIndex(), _currentScriptIndex, _currentLine);
- break;
- } // end switch
-
- _currentLine += lineIncrement;
- _currentLoops++;
-
- } // end while
+ if (_currentScriptIndex != -1) {
+ ActionDefinitions *_currentScript = _scene->getActionList(_currentScriptIndex);
+ if (!_currentScript)
+ return;
+
+ while (!done && !waitCycle) {
+ lineIncrement = 1; // Reset line increment value
+
+ if (_currentLoops > 1000) {
+ // TODO - processActionLists has run too many interations
+ }
+
+ ActionCommand currentCommand = _currentScript->commands[_currentLine];
+
+ switch (currentCommand.opcode) {
+ case kReturn0:
+ done = true;
+ lineIncrement = 0;
+ break;
+ case kShowCursor:
+ _scene->_screen->showCursor();
+ // TODO - Enable click events
+ break;
+ case kHideCursor:
+ _scene->_screen->hideCursor();
+ // TODO - Disable click events
+ break;
+ case kPlayAnimation: {
+ int barrierIndex = _scene->_sceneResource->getBarrierIndexById(currentCommand.param1);
+ if (barrierIndex >= 0)
+ _scene->_sceneResource->getWorldStats()->barriers[barrierIndex].flags |= 0x20; // TODO - enums for flags (0x20 is visible/playing?)
+ else
+ debugC(kDebugLevelScripts, "Requested invalid object ID:0x%02X in Scene %d Script %d Line %d.", currentCommand.param1, _scene->getSceneIndex(), _currentScriptIndex, _currentLine);
+ }
+ break;
+ case kHideActor: {
+ uint32 actorIndex = 0;
+ if (currentCommand.param1 == -1)
+ ;//actorIndex = _scene->getWorldStats()->playerActor;
+ else
+ actorIndex = currentCommand.param1;
+
+ if ((actorIndex >= 0) && (actorIndex < _scene->_sceneResource->getWorldStats()->numActors)) {
+ _scene->actorVisible(actorIndex, false);
+ }
+ else
+ debugC(kDebugLevelScripts, "Requested invalid actor ID:0x%02X in Scene %d Script %d Line %d.", currentCommand.param1, _scene->getSceneIndex(), _currentScriptIndex, _currentLine);
+ }
+ break;
+ case kShowActor: {
+ uint32 actorIndex = 0;
+ if (currentCommand.param1 == -1)
+ ;//actorIndex = _scene->getWorldStats()->playerActor;
+ else
+ actorIndex = currentCommand.param1;
+
+ if ((actorIndex >= 0) && (actorIndex < _scene->_sceneResource->getWorldStats()->numActors)) {
+ _scene->actorVisible(actorIndex, true);
+ }
+ else
+ debugC(kDebugLevelScripts, "Requested invalid actor ID:0x%02X in Scene %d Script %d Line %d.", currentCommand.param1, _scene->getSceneIndex(), _currentScriptIndex, _currentLine);
+ }
+ break;
+ case kSetActorStats: {
+ uint32 actorIndex = 0;
+ if (currentCommand.param1 == -1)
+ ;//actorIndex = _scene->getWorldStats()->playerActor;
+ else
+ actorIndex = currentCommand.param1;
+
+ if ((actorIndex >= 0) && (actorIndex < _scene->_sceneResource->getWorldStats()->numActors)) {
+ _scene->setActorPosition(actorIndex, currentCommand.param2, currentCommand.param3);
+ _scene->setActorAction(actorIndex, currentCommand.param4);
+ }
+ else
+ debugC(kDebugLevelScripts, "Requested invalid actor ID:0x%02X in Scene %d Script %d Line %d.", currentCommand.param1, _scene->getSceneIndex(), _currentScriptIndex, _currentLine);
+ }
+ break;
+ case kReturn:
+ done = true;
+ lineIncrement = 0;
+ break;
+ case kDestroyObject: {
+ int barrierIndex = _scene->_sceneResource->getBarrierIndexById(currentCommand.param1);
+ if (barrierIndex >= 0)
+ _scene->_sceneResource->getWorldStats()->barriers[barrierIndex].flags &= 0xFFFFDF; // TODO - enums for flags (0x20 is visible/playing?)
+ else
+ debugC(kDebugLevelScripts, "Requested invalid object ID:0x%02X in Scene %d Script %d Line %d.", currentCommand.param1, _scene->getSceneIndex(), _currentScriptIndex, _currentLine);
+ }
+ break;
+ case kChangeScene:
+ _engine->_delayedSceneNumber = currentCommand.param1 + 4;
+ debug(kDebugLevelScripts, "Queueing Scene Change to scene %d...", currentCommand.param1 + 4);
+ break;
+ case kPlayMovie:
+ _engine->_delayedVideoNumber = currentCommand.param1;
+ break;
+ case kWaitUntilFramePlayed: {
+ int barrierIndex = _scene->_sceneResource->getBarrierIndexById(currentCommand.param1);
+ if (barrierIndex >= 0) {
+ uint32 frameNum = 0;
+ if (currentCommand.param2 == -1)
+ frameNum = _scene->_sceneResource->getWorldStats()->barriers[barrierIndex].frameCount - 1;
+ else
+ frameNum = currentCommand.param2;
- if(done) {
- _currentLine = 0;
- _currentScriptIndex = 0;
- _currentLoops = 0;
- }
- }
- _processing = false;
+ if (_scene->_sceneResource->getWorldStats()->barriers[barrierIndex].tickCount < frameNum) {
+ lineIncrement = 0;
+ waitCycle = true;
+ }
+ } else {
+ debugC(kDebugLevelScripts, "Requested invalid object ID:0x%02X in Scene %d Script %d Line %d.", currentCommand.param1, _scene->getSceneIndex(), _currentScriptIndex, _currentLine);
+ }
+ break;
+ }
+ case kPlaySpeech:
+ // TODO - Add support for other param options
+ if (currentCommand.param1 >= 0) {
+ if (currentCommand.param3) // HACK - Find out why sometimes an offset is needed and other times not
+ _scene->_sound->playSfx(_scene->_speechPack, currentCommand.param1 - 9);
+ else
+ _scene->_sound->playSfx(_scene->_speechPack, currentCommand.param1);
+ } else
+ debugC(kDebugLevelScripts, "Requested invalid sound ID:0x%02X in Scene %d Script %d Line %d.", currentCommand.param1, _scene->getSceneIndex(), _currentScriptIndex, _currentLine);
+ break;
+ default:
+ debugC(kDebugLevelScripts, "Unhandled opcode 0x%02X in Scene %d Script %d Line %d.", currentCommand.opcode, _scene->getSceneIndex(), _currentScriptIndex, _currentLine);
+ break;
+ } // end switch
+
+ _currentLine += lineIncrement;
+ _currentLoops++;
+
+ } // end while
+
+ if (done) {
+ _currentLine = 0;
+ _currentScriptIndex = 0;
+ _currentLoops = 0;
+ }
+ }
+ _processing = false;
}
} // end of namespace Asylum
diff --git a/engines/asylum/interpreter.h b/engines/asylum/interpreter.h
index f6e1e73eec..b6633d4507 100644
--- a/engines/asylum/interpreter.h
+++ b/engines/asylum/interpreter.h
@@ -33,124 +33,124 @@ namespace Asylum {
class Interpreter {
public:
- Interpreter(AsylumEngine *vm);
- ~Interpreter();
-
- void doSceneChanged();
- void processActionLists();
- bool isProcessing() { return _processing; }
-
+ Interpreter(AsylumEngine *vm);
+ ~Interpreter();
+
+ void doSceneChanged();
+ void processActionLists();
+ bool isProcessing() { return _processing; }
+
private:
- AsylumEngine *_engine;
- Scene *_scene;
- int _currentLine;
- int _currentScriptIndex;
- int _currentLoops;
- bool _processing;
-
+ AsylumEngine *_engine;
+ Scene *_scene;
+ int _currentLine;
+ int _currentScriptIndex;
+ int _currentLoops;
+ bool _processing;
+
friend class Console;
};
enum opcodes {
- kReturn0 = 0x00,
- kSetGameFlag,
- kClearGameFlag,
- kToogleGameFlag,
- kJumpIfGameFlag,
- kHideCursor,
- kShowCursor,
- kPlayAnimation,
- kMoveScenePosition,
- kHideActor,
- kShowActor,
- kSetActorStats,
- k_unk0C_SET_SCENE_FIELD88,
- kDisableActor,
- kEnableActor,
- kEnableBarriers,
- kReturn, // 0x10
- kDestroyObject,
- k_unk12_JMP_WALK_ACTOR,
- k_unk13_JMP_WALK_ACTOR,
- k_unk14_JMP_WALK_ACTOR,
- k_unk15,
- kResetAnimation,
- kClearFlag1Bit0,
- k_unk18_PLAY_SND,
- kJumpIfFlag2Bit0,
- kSetFlag2Bit0,
- kClearFlag2Bit0,
- kJumpIfFlag2Bit2,
- kSetFlag2Bit2,
- kClearFlag2Bit2,
- kJumpIfFlag2Bit1,
- kSetFlag2Bit1, // 0x20
- kClearFlag2Bit1,
- k_unk22,
- k_unk23,
- k_unk24,
- kRunEncounter,
- kJumpIfFlag2Bit4,
- kSetFlag2Bit4,
- kClearFlag2Bit4,
- kSetActorField638,
- kJumpIfActorField638,
- kChangeScene,
- k_unk2C_ActorSub,
- kPlayMovie,
- kStopAllObjectsSounds,
- kSetActionFlag01,
- kClearActionFlag01, // 0x30
- kResetSceneRect,
- kChangeMusicById,
- kStopMusic,
- k_unk34_Status,
- k_unk35,
- k_unk36,
- kRunMinigame,
- kJumpIfFlag2Bit3,
- kSetFlag2Bit3,
- kClearFlag2Bit3,
- k_unk3B_PALETTE_MOD,
- k_unk3C_CMP_VAL,
- kWaitUntilFramePlayed,
- kUpdateMatteBars,
- k_unk3F,
- k_unk40_SOUND, // 0x40
- kPlaySpeech,
- k_unk42,
- k_unk43,
- kPaletteFade,
- kStartPaletteFadeThread,
- k_unk46,
- kActorFaceObject,
- k_unk48_MATTE_01,
- k_unk49_MATTE_90,
- kJumpIfSoundPlaying,
- kChangePlayerCharacterIndex,
- kChangeActorField40,
- kStopSound,
- k_unk4E_RANDOM_COMMAND,
- kDrawGame,
- kQuit, // 0x50
- kJumpObjectFrame,
- k_unk52,
- k_unk53,
- k_unk54_SET_ACTIONLIST_6EC,
- k_unk55,
- k_unk56,
- k_unk57,
- k_unk58,
- k_unk59,
- k_unk5A,
- k_unk5B,
- k_unk5C,
- k_unk5D,
- k_unk5E,
- k_unk5F,
- k_unk60_SET_OR_CLR_ACTIONAREA_FLAG, // 0x60
- k_unk61,
- k_unk62_SHOW_OPTIONS_SCREEN
+ kReturn0 = 0x00,
+ kSetGameFlag,
+ kClearGameFlag,
+ kToogleGameFlag,
+ kJumpIfGameFlag,
+ kHideCursor,
+ kShowCursor,
+ kPlayAnimation,
+ kMoveScenePosition,
+ kHideActor,
+ kShowActor,
+ kSetActorStats,
+ k_unk0C_SET_SCENE_FIELD88,
+ kDisableActor,
+ kEnableActor,
+ kEnableBarriers,
+ kReturn, // 0x10
+ kDestroyObject,
+ k_unk12_JMP_WALK_ACTOR,
+ k_unk13_JMP_WALK_ACTOR,
+ k_unk14_JMP_WALK_ACTOR,
+ k_unk15,
+ kResetAnimation,
+ kClearFlag1Bit0,
+ k_unk18_PLAY_SND,
+ kJumpIfFlag2Bit0,
+ kSetFlag2Bit0,
+ kClearFlag2Bit0,
+ kJumpIfFlag2Bit2,
+ kSetFlag2Bit2,
+ kClearFlag2Bit2,
+ kJumpIfFlag2Bit1,
+ kSetFlag2Bit1, // 0x20
+ kClearFlag2Bit1,
+ k_unk22,
+ k_unk23,
+ k_unk24,
+ kRunEncounter,
+ kJumpIfFlag2Bit4,
+ kSetFlag2Bit4,
+ kClearFlag2Bit4,
+ kSetActorField638,
+ kJumpIfActorField638,
+ kChangeScene,
+ k_unk2C_ActorSub,
+ kPlayMovie,
+ kStopAllObjectsSounds,
+ kSetActionFlag01,
+ kClearActionFlag01, // 0x30
+ kResetSceneRect,
+ kChangeMusicById,
+ kStopMusic,
+ k_unk34_Status,
+ k_unk35,
+ k_unk36,
+ kRunMinigame,
+ kJumpIfFlag2Bit3,
+ kSetFlag2Bit3,
+ kClearFlag2Bit3,
+ k_unk3B_PALETTE_MOD,
+ k_unk3C_CMP_VAL,
+ kWaitUntilFramePlayed,
+ kUpdateMatteBars,
+ k_unk3F,
+ k_unk40_SOUND, // 0x40
+ kPlaySpeech,
+ k_unk42,
+ k_unk43,
+ kPaletteFade,
+ kStartPaletteFadeThread,
+ k_unk46,
+ kActorFaceObject,
+ k_unk48_MATTE_01,
+ k_unk49_MATTE_90,
+ kJumpIfSoundPlaying,
+ kChangePlayerCharacterIndex,
+ kChangeActorField40,
+ kStopSound,
+ k_unk4E_RANDOM_COMMAND,
+ kDrawGame,
+ kQuit, // 0x50
+ kJumpObjectFrame,
+ k_unk52,
+ k_unk53,
+ k_unk54_SET_ACTIONLIST_6EC,
+ k_unk55,
+ k_unk56,
+ k_unk57,
+ k_unk58,
+ k_unk59,
+ k_unk5A,
+ k_unk5B,
+ k_unk5C,
+ k_unk5D,
+ k_unk5E,
+ k_unk5F,
+ k_unk60_SET_OR_CLR_ACTIONAREA_FLAG, // 0x60
+ k_unk61,
+ k_unk62_SHOW_OPTIONS_SCREEN
};
} // end of namespace Asylum
Commit: de517ddf1ff2a6489dcfa1d9bf817e0602f83d4f
https://github.com/scummvm/scummvm/commit/de517ddf1ff2a6489dcfa1d9bf817e0602f83d4f
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-05-17T15:35:31+02:00
Commit Message:
ASYLUM: More formatting. Basically tabify. SOmebody has wrong indentation setup. All
indents have to be tabs, not spaces.
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@236 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/asylum.cpp
engines/asylum/asylum.h
engines/asylum/menu.cpp
engines/asylum/menu.h
engines/asylum/scene.cpp
engines/asylum/scene.h
engines/asylum/sceneres.cpp
engines/asylum/sceneres.h
engines/asylum/screen.cpp
engines/asylum/text.cpp
engines/asylum/text.h
engines/asylum/video.cpp
engines/asylum/video.h
diff --git a/engines/asylum/asylum.cpp b/engines/asylum/asylum.cpp
index 684da2c563..c109bc3a1f 100644
--- a/engines/asylum/asylum.cpp
+++ b/engines/asylum/asylum.cpp
@@ -34,9 +34,9 @@
namespace Asylum {
AsylumEngine::AsylumEngine(OSystem *system, Common::Language language)
- : Engine(system) {
-
- Common::addDebugChannel(kDebugLevelMain, "Main", "Generic debug level");
+ : Engine(system) {
+
+ Common::addDebugChannel(kDebugLevelMain, "Main", "Generic debug level");
Common::addDebugChannel(kDebugLevelResources, "Resources", "Resources debugging");
Common::addDebugChannel(kDebugLevelSprites, "Sprites", "Sprites debugging");
Common::addDebugChannel(kDebugLevelInput, "Input", "Input events debugging");
@@ -45,15 +45,15 @@ AsylumEngine::AsylumEngine(OSystem *system, Common::Language language)
Common::addDebugChannel(kDebugLevelSound, "Sound", "Sound debugging");
Common::addDebugChannel(kDebugLevelSavegame, "Savegame", "Saving & restoring game debugging");
- Common::File::addDefaultDirectory(_gameDataDir.getChild("Data"));
- Common::File::addDefaultDirectory(_gameDataDir.getChild("Vids"));
+ Common::File::addDefaultDirectory(_gameDataDir.getChild("Data"));
+ Common::File::addDefaultDirectory(_gameDataDir.getChild("Vids"));
Common::File::addDefaultDirectory(_gameDataDir.getChild("Music"));
- _eventMan->registerRandomSource(_rnd, "asylum");
+ _eventMan->registerRandomSource(_rnd, "asylum");
}
AsylumEngine::~AsylumEngine() {
- //Common::clearAllDebugChannels();
+ //Common::clearAllDebugChannels();
delete _console;
delete _scene;
delete _mainMenu;
@@ -63,11 +63,11 @@ AsylumEngine::~AsylumEngine() {
}
Common::Error AsylumEngine::run() {
- Common::Error err;
- err = init();
- if (err != Common::kNoError)
- return err;
- return go();
+ Common::Error err;
+ err = init();
+ if (err != Common::kNoError)
+ return err;
+ return go();
}
// Will do the same as subroutine at address 0041A500
@@ -76,21 +76,21 @@ Common::Error AsylumEngine::init() {
initGraphics(640, 480, true);
- _screen = new Screen(_system);
- _sound = new Sound(_mixer);
- _video = new Video(_mixer);
- _console = new Console(this);
- _interpreter = 0;
- _mainMenu = 0;
- _scene = 0;
+ _screen = new Screen(_system);
+ _sound = new Sound(_mixer);
+ _video = new Video(_mixer);
+ _console = new Console(this);
+ _interpreter = 0;
+ _mainMenu = 0;
+ _scene = 0;
_delayedVideoNumber = -1;
_delayedSceneNumber = -1;
- return Common::kNoError;
+ return Common::kNoError;
}
Common::Error AsylumEngine::go() {
- // initializing game
+ // initializing game
// TODO: save dialogue key codes into sntrm_k.txt (need to figure out why they use such thing)
// TODO: load startup configurations (address 0041A970)
// TODO: init unknown game stuffs (address 0040F430)
@@ -104,9 +104,9 @@ Common::Error AsylumEngine::go() {
//_video->playVideo(1, kSubtitlesOn);
// Set up the game's main scene
- _scene = new Scene(_screen, _sound, 5);
-
- // Set up the game's script interpreter
+ _scene = new Scene(_screen, _sound, 5);
+
+ // Set up the game's script interpreter
_interpreter = new Interpreter(this);
// Set up main menu
@@ -120,7 +120,7 @@ Common::Error AsylumEngine::go() {
waitForTimer(55);
}
- return Common::kNoError;
+ return Common::kNoError;
}
void AsylumEngine::waitForTimer(int msec_delay) {
@@ -196,18 +196,18 @@ void AsylumEngine::checkForDelayedVideo() {
void AsylumEngine::checkForDelayedSceneChange() {
- if (_delayedSceneNumber >= 0 && !_interpreter->isProcessing()) {
+ if (_delayedSceneNumber >= 0 && !_interpreter->isProcessing()) {
_sound->stopMusic();
_sound->stopSfx();
- if(_scene)
- delete _scene;
- _scene = new Scene(_screen, _sound, _delayedSceneNumber);
+ if (_scene)
+ delete _scene;
+ _scene = new Scene(_screen, _sound, _delayedSceneNumber);
- _interpreter->doSceneChanged();
+ _interpreter->doSceneChanged();
- _scene->enterScene();
- _delayedSceneNumber = -1;
+ _scene->enterScene();
+ _delayedSceneNumber = -1;
}
}
diff --git a/engines/asylum/asylum.h b/engines/asylum/asylum.h
index 70f9269a38..f055c42317 100644
--- a/engines/asylum/asylum.h
+++ b/engines/asylum/asylum.h
@@ -11,7 +11,7 @@
* 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
+ * 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
@@ -48,27 +48,27 @@ class Video;
class Interpreter;
enum kDebugLevels {
- kDebugLevelMain = 1 << 0,
+ kDebugLevelMain = 1 << 0,
kDebugLevelResources = 1 << 1,
kDebugLevelSprites = 1 << 2,
- kDebugLevelInput = 1 << 3,
- kDebugLevelMenu = 1 << 4,
+ kDebugLevelInput = 1 << 3,
+ kDebugLevelMenu = 1 << 4,
kDebugLevelScripts = 1 << 5,
- kDebugLevelSound = 1 << 6,
+ kDebugLevelSound = 1 << 6,
kDebugLevelSavegame = 1 << 7
};
class AsylumEngine: public Engine {
public:
- AsylumEngine(OSystem *system, Common::Language language);
- virtual ~AsylumEngine();
+ AsylumEngine(OSystem *system, Common::Language language);
+ virtual ~AsylumEngine();
- // Engine APIs
- Common::Error init();
- Common::Error go();
- virtual Common::Error run();
- virtual bool hasFeature(EngineFeature f) const;
+ // Engine APIs
+ Common::Error init();
+ Common::Error go();
+ virtual Common::Error run();
+ virtual bool hasFeature(EngineFeature f) const;
private:
void checkForEvent(bool doUpdate);
@@ -77,18 +77,18 @@ private:
void checkForDelayedVideo();
void checkForDelayedSceneChange();
- Common::Language _language;
- Common::RandomSource _rnd;
+ Common::Language _language;
+ Common::RandomSource _rnd;
- Console *_console;
- Scene *_scene;
- MainMenu *_mainMenu;
- Screen *_screen;
- Sound *_sound;
- Video *_video;
+ Console *_console;
+ Scene *_scene;
+ MainMenu *_mainMenu;
+ Screen *_screen;
+ Sound *_sound;
+ Video *_video;
Interpreter *_interpreter;
- int _delayedVideoNumber;
- int _delayedSceneNumber;
+ int _delayedVideoNumber;
+ int _delayedSceneNumber;
friend class Console;
friend class Interpreter;
diff --git a/engines/asylum/menu.cpp b/engines/asylum/menu.cpp
index 1c52966b00..2dca7b2bb6 100644
--- a/engines/asylum/menu.cpp
+++ b/engines/asylum/menu.cpp
@@ -11,7 +11,7 @@
* 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
+ * 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
@@ -34,38 +34,38 @@ const int MenuIconFixedXpos[12] = { 28, 128, 225, 320, 410, 528, 16, 115, 237, 3
MainMenu::MainMenu(Screen *screen, Sound *sound, Scene *scene) :
_screen(screen), _sound(sound), _scene(scene) {
- _mouseX = 0;
- _mouseY = 0;
- _leftClick = false;
- _activeIcon = -1;
+ _mouseX = 0;
+ _mouseY = 0;
+ _leftClick = false;
+ _activeIcon = -1;
_previousActiveIcon = -1;
- _curIconFrame = 0;
- _curMouseCursor = 0;
- _cursorStep = 1;
- _creditsBgFrame = 0;
- _creditsTextScroll = 0x1E0 - 30;
- _activeMenuScreen = kMainMenu;
+ _curIconFrame = 0;
+ _curMouseCursor = 0;
+ _cursorStep = 1;
+ _creditsBgFrame = 0;
+ _creditsTextScroll = 0x1E0 - 30;
+ _activeMenuScreen = kMainMenu;
_active = false;
- _confGammaLevel = 2;
- _confGameQuality = 5;
+ _confGammaLevel = 2;
+ _confGameQuality = 5;
- _resPack = new ResourcePack(1);
- _bgResource = new GraphicResource(_resPack, 0);
- _eyeResource = new GraphicResource(_resPack, 1);
+ _resPack = new ResourcePack(1);
+ _bgResource = new GraphicResource(_resPack, 0);
+ _eyeResource = new GraphicResource(_resPack, 1);
_cursorResource = new GraphicResource(_resPack, 2);
- _iconResource = 0;
- _creditsResource = 0;
+ _iconResource = 0;
+ _creditsResource = 0;
_creditsFadeResource = 0;
- _text = new Text(_screen);
- _text->loadFont(_resPack, 16); // 0x80010010, yellow font
+ _text = new Text(_screen);
+ _text->loadFont(_resPack, 16); // 0x80010010, yellow font
}
MainMenu::~MainMenu() {
delete _creditsResource;
delete _creditsFadeResource;
- delete _text;
+ delete _text;
delete _iconResource;
delete _eyeResource;
delete _cursorResource;
@@ -77,8 +77,8 @@ void MainMenu::openMenu() {
_active = true;
_scene->deactivate();
- // yellow font
- _text->loadFont(_resPack, 0x80010010);
+ // yellow font
+ _text->loadFont(_resPack, 0x80010010);
// Load the graphics palette
_screen->setPalette(_resPack, 17);
@@ -157,54 +157,54 @@ void MainMenu::update() {
}
switch (_activeIcon) {
- case kNewGame:
- // Nothing here
- break;
- case kLoadGame:
- // TODO
- break;
- case kSaveGame:
- // TODO
- break;
- case kDeleteGame:
- // TODO
- break;
- case kViewCinematics:
- // TODO
- break;
- case kQuitGame:
- // Nothing here
- break;
- case kTextOptions:
- // TODO
- break;
- case kAudioOptions:
- // TODO
- break;
- case kSettings:
- // TODO
- break;
- case kKeyboardConfig:
- // TODO
- break;
- case kShowCredits:
- // TODO if game finished (gameFlag=901) then show resource image 33 and music 56 and than music 40
- if (!_creditsResource)
- _creditsResource = new GraphicResource(_resPack, 24);
- if (!_creditsFadeResource)
- _creditsFadeResource = new GraphicResource(_resPack, 23);
- _creditsTextScroll = 0x1E0 - 30;
- // Set credits palette
- _screen->setPalette(_resPack, 26);
- // Stop all sounds
- _sound->stopMusic();
- // Start playing music
- _sound->playMusic(_resPack, 38);
- break;
- case kReturnToGame:
- closeMenu();
- _scene->enterScene();
- break;
+ case kNewGame:
+ // Nothing here
+ break;
+ case kLoadGame:
+ // TODO
+ break;
+ case kSaveGame:
+ // TODO
+ break;
+ case kDeleteGame:
+ // TODO
+ break;
+ case kViewCinematics:
+ // TODO
+ break;
+ case kQuitGame:
+ // Nothing here
+ break;
+ case kTextOptions:
+ // TODO
+ break;
+ case kAudioOptions:
+ // TODO
+ break;
+ case kSettings:
+ // TODO
+ break;
+ case kKeyboardConfig:
+ // TODO
+ break;
+ case kShowCredits:
+ // TODO if game finished (gameFlag=901) then show resource image 33 and music 56 and than music 40
+ if (!_creditsResource)
+ _creditsResource = new GraphicResource(_resPack, 24);
+ if (!_creditsFadeResource)
+ _creditsFadeResource = new GraphicResource(_resPack, 23);
+ _creditsTextScroll = 0x1E0 - 30;
+ // Set credits palette
+ _screen->setPalette(_resPack, 26);
+ // Stop all sounds
+ _sound->stopMusic();
+ // Start playing music
+ _sound->playMusic(_resPack, 38);
+ break;
+ case kReturnToGame:
+ closeMenu();
+ _scene->enterScene();
+ break;
}
}
}
@@ -255,7 +255,7 @@ void MainMenu::updateEyesAnimation() {
void MainMenu::updateMainMenu() {
int rowId = 0;
- if (_mouseY >= 20 && _mouseY <= 20 + 48) {
+ if (_mouseY >= 20 && _mouseY <= 20 + 48) {
rowId = 0; // Top row
} else if (_mouseY >= 400 && _mouseY <= 400 + 48) {
rowId = 1; // Bottom row
@@ -266,8 +266,8 @@ void MainMenu::updateMainMenu() {
return;
}
- // yellow font
- _text->loadFont(_resPack, 0x80010010);
+ // yellow font
+ _text->loadFont(_resPack, 0x80010010);
// Icon animation
for (uint32 i = 0; i <= 5; i++) {
@@ -297,7 +297,7 @@ void MainMenu::updateMainMenu() {
_curIconFrame = 0;
// Show text
- _text->drawResTextCentered(MenuIconFixedXpos[iconNum], iconFrame->y + 50, _text->getResTextWidth(iconNum + 1309), iconNum + 1309);
+ _text->drawResTextCentered(MenuIconFixedXpos[iconNum], iconFrame->y + 50, _text->getResTextWidth(iconNum + 1309), iconNum + 1309);
// Play creepy voice
if (!_sound->isSfxActive() && _activeIcon != _previousActiveIcon) {
@@ -320,79 +320,79 @@ void MainMenu::updateSubMenu() {
_curIconFrame = 0;
switch (_activeIcon) {
- case kNewGame:
- updateSubMenuNewGame();
- break;
- case kLoadGame:
- // TODO
- break;
- case kSaveGame:
- // TODO
- break;
- case kDeleteGame:
- // TODO
- break;
- case kViewCinematics:
- updateSubMenuCinematics();
- break;
- case kQuitGame:
- updateSubMenuQuitGame();
- break;
- case kTextOptions:
- // TODO
- break;
- case kAudioOptions:
- // TODO
- break;
- case kSettings:
- updateSubMenuSettings();
- break;
- case kKeyboardConfig:
- // TODO
- break;
- case kShowCredits:
- updateSubMenuShowCredits();
- break;
- case kReturnToGame:
- // TODO
- break;
+ case kNewGame:
+ updateSubMenuNewGame();
+ break;
+ case kLoadGame:
+ // TODO
+ break;
+ case kSaveGame:
+ // TODO
+ break;
+ case kDeleteGame:
+ // TODO
+ break;
+ case kViewCinematics:
+ updateSubMenuCinematics();
+ break;
+ case kQuitGame:
+ updateSubMenuQuitGame();
+ break;
+ case kTextOptions:
+ // TODO
+ break;
+ case kAudioOptions:
+ // TODO
+ break;
+ case kSettings:
+ updateSubMenuSettings();
+ break;
+ case kKeyboardConfig:
+ // TODO
+ break;
+ case kShowCredits:
+ updateSubMenuShowCredits();
+ break;
+ case kReturnToGame:
+ // TODO
+ break;
}
}
void MainMenu::updateSubMenuNewGame() {
- // yellow font
- _text->loadFont(_resPack, 0x80010010);
+ // yellow font
+ _text->loadFont(_resPack, 0x80010010);
- // begin new game
+ // begin new game
_text->drawResTextCentered(10, 100, 620, 0x80000529);
// Yes
- if (_mouseX < 247 || _mouseX > 247 + _text->getResTextWidth(0x8000052A) || _mouseY < 273 || _mouseY > 273 + 24 )
- _text->loadFont(_resPack, 0x80010010); // yellow font
- else
- _text->loadFont(_resPack, 0x80010016); // blue font
- _text->setTextPos(247, 273);
+ if (_mouseX < 247 || _mouseX > 247 + _text->getResTextWidth(0x8000052A) || _mouseY < 273 || _mouseY > 273 + 24 )
+ _text->loadFont(_resPack, 0x80010010); // yellow font
+ else
+ _text->loadFont(_resPack, 0x80010016); // blue font
+ _text->setTextPos(247, 273);
_text->drawResText(0x8000052A);
- // No
- if (_mouseX < 369 || _mouseX > 369 + _text->getResTextWidth(0x8000052B) || _mouseY < 273 || _mouseY > 273 + 24 )
- _text->loadFont(_resPack, 0x80010010); // yellow font
- else
- _text->loadFont(_resPack, 0x80010016); // blue font
- _text->setTextPos(369, 273);
+ // No
+ if (_mouseX < 369 || _mouseX > 369 + _text->getResTextWidth(0x8000052B) || _mouseY < 273 || _mouseY > 273 + 24 )
+ _text->loadFont(_resPack, 0x80010010); // yellow font
+ else
+ _text->loadFont(_resPack, 0x80010016); // blue font
+ _text->setTextPos(369, 273);
_text->drawResText(0x8000052B);
- // action
- if (_leftClick) {
- // Yes
- if (_mouseX >= 247 && _mouseX <= 247 + 24 && _mouseY >= 273 && _mouseY <= 273 + _text->getResTextWidth(0x8000052A)) {
- _leftClick = false;
- // TODO handle new game event
- }
+ // action
+ if (_leftClick) {
+ // Yes
+ if (_mouseX >= 247 && _mouseX <= 247 + 24 && _mouseY >= 273 && _mouseY <= 273 + _text->getResTextWidth(0x8000052A)) {
+ _leftClick = false;
+ // TODO handle new game event
+ }
// No
- if (_mouseX >= 369 && _mouseX <= 369 + 24 && _mouseY >= 273 && _mouseY <= 273 + _text->getResTextWidth(0x8000052B))
- exitSubMenu();
- }
+ if (_mouseX >= 369 && _mouseX <= 369 + 24 && _mouseY >= 273 && _mouseY <= 273 + _text->getResTextWidth(0x8000052B))
+ exitSubMenu();
+ }
}
void MainMenu::updateSubMenuCinematics() {
@@ -419,217 +419,217 @@ void MainMenu::updateSubMenuCinematics() {
}
void MainMenu::updateSubMenuSettings() {
- uint32 sizeMinus = _text->getTextWidth("-");
- uint32 sizePlus = _text->getTextWidth("+");
- uint32 sizeMainMenu = _text->getResTextWidth(0x8000059D);
+ uint32 sizeMinus = _text->getTextWidth("-");
+ uint32 sizePlus = _text->getTextWidth("+");
+ uint32 sizeMainMenu = _text->getResTextWidth(0x8000059D);
- // yellow font
- _text->loadFont(_resPack, 0x80010010);
- // Settings
+ // yellow font
+ _text->loadFont(_resPack, 0x80010010);
+ // Settings
_text->drawResTextCentered(10, 100, 620, 0x80000598);
- // gamma correction
- _text->drawResTextAlignRight(320, 150, 0x80000599);
- if (_mouseX < 350 || _mouseX > sizeMinus + 350 || _mouseY < 150 || _mouseY > 174)
- _text->loadFont(_resPack, 0x80010010); // yellow font
- else
- _text->loadFont(_resPack, 0x80010016); // blue font
- _text->setTextPos(350, 150);
- _text->drawText("-");
-
- if (_mouseX < sizeMinus + 360 || _mouseX > sizeMinus + sizePlus + 360 || _mouseY < 150 || _mouseY > 174)
- _text->loadFont(_resPack, 0x80010010); // yellow font
- else
- _text->loadFont(_resPack, 0x80010016); // blue font
- _text->setTextPos(sizeMinus + 360, 150);
- _text->drawText("+");
-
- _text->setTextPos(sizeMinus + sizePlus + 365, 150);
- _text->loadFont(_resPack, 0x80010010);
- if(_confGammaLevel) {
- for (uint32 i = 0; i < _confGammaLevel; i++ ) {
- _text->drawText("]");
- }
- if (_confGammaLevel == 8)
- _text->drawText("*");
- } else
- _text->drawResText(0x8000059B);
-
- // performance
- _text->loadFont(_resPack, 0x80010010);
- _text->drawResTextAlignRight(320, 179, 0x8000059A);
- if (_mouseX < 350 || _mouseX > sizeMinus + 350 || _mouseY < 179 || _mouseY > 203)
- _text->loadFont(_resPack, 0x80010010); // yellow font
- else
- _text->loadFont(_resPack, 0x80010016); // blue font
- _text->setTextPos(350, 179);
- _text->drawText("-");
-
- if (_mouseX < sizeMinus + 360 || _mouseX > sizeMinus + sizePlus + 360 || _mouseY < 179 || _mouseY > 203)
- _text->loadFont(_resPack, 0x80010010); // yellow font
- else
- _text->loadFont(_resPack, 0x80010016); // blue font
- _text->setTextPos(sizeMinus + 360, 179);
- _text->drawText("+");
-
- _text->setTextPos(sizeMinus + sizePlus + 365, 179);
- _text->loadFont(_resPack, 0x80010010);
- if(_confGameQuality == 5) {
- _text->drawResText(0x8000059C);
- } else {
- for (uint32 i = 5; i > _confGameQuality; --i ) {
- _text->drawText("]");
- }
- if (!_confGameQuality)
- _text->drawText("*");
- }
-
- // back to main menu
- if (_mouseX < 300 || _mouseX > 300 + sizeMainMenu || _mouseY < 340 || _mouseY > 340 + 24)
- _text->loadFont(_resPack, 0x80010010); // yellow font
- else
- _text->loadFont(_resPack, 0x80010016); // blue font
- _text->setTextPos(300, 340);
- _text->drawResText(0x8000059D);
-
- // action
- if (_leftClick) {
- // back to main menu
- if (_mouseX >= 300 && _mouseX <= 300 + sizeMainMenu && _mouseY >= 340 && _mouseY <= 340 + 24) {
- // TODO: save new configurations
- exitSubMenu();
- }
-
- // gamma level minus
- if (_mouseX >= 350 && _mouseX <= sizeMinus + 350 && _mouseY >= 150 && _mouseY <= 174) {
- if(_confGammaLevel) {
- _confGammaLevel -= 1;
- // TODO: setResGammaLevel(0x80010011, 0);
- }
- }
- // gamma level plus
- if (_mouseX >= sizeMinus + 360 && _mouseX <= sizeMinus + sizePlus + 360 && _mouseY >= 150 && _mouseY <= 174) {
- if(_confGammaLevel < 8) {
- _confGammaLevel += 1;
- // TODO: setResGammaLevel(0x80010011, 0);
- }
- }
-
- // performance minus
- if (_mouseX >= 350 && _mouseX <= sizeMinus + 350 && _mouseY >= 179 && _mouseY <= 203) {
- if(_confGameQuality) {
- _confGameQuality -= 1;
- // TODO: change quality settings
- }
- }
- // performance plus
- if (_mouseX >= sizeMinus + 360 && _mouseX <= sizeMinus + sizePlus + 360 && _mouseY >= 179 && _mouseY <= 203) {
- if(_confGameQuality < 5) {
- _confGameQuality += 1;
- // TODO: change quality settings
- }
- }
- }
+ // gamma correction
+ _text->drawResTextAlignRight(320, 150, 0x80000599);
+ if (_mouseX < 350 || _mouseX > sizeMinus + 350 || _mouseY < 150 || _mouseY > 174)
+ _text->loadFont(_resPack, 0x80010010); // yellow font
+ else
+ _text->loadFont(_resPack, 0x80010016); // blue font
+ _text->setTextPos(350, 150);
+ _text->drawText("-");
+
+ if (_mouseX < sizeMinus + 360 || _mouseX > sizeMinus + sizePlus + 360 || _mouseY < 150 || _mouseY > 174)
+ _text->loadFont(_resPack, 0x80010010); // yellow font
+ else
+ _text->loadFont(_resPack, 0x80010016); // blue font
+ _text->setTextPos(sizeMinus + 360, 150);
+ _text->drawText("+");
+
+ _text->setTextPos(sizeMinus + sizePlus + 365, 150);
+ _text->loadFont(_resPack, 0x80010010);
+ if (_confGammaLevel) {
+ for (uint32 i = 0; i < _confGammaLevel; i++ ) {
+ _text->drawText("]");
+ }
+ if (_confGammaLevel == 8)
+ _text->drawText("*");
+ } else
+ _text->drawResText(0x8000059B);
+
+ // performance
+ _text->loadFont(_resPack, 0x80010010);
+ _text->drawResTextAlignRight(320, 179, 0x8000059A);
+ if (_mouseX < 350 || _mouseX > sizeMinus + 350 || _mouseY < 179 || _mouseY > 203)
+ _text->loadFont(_resPack, 0x80010010); // yellow font
+ else
+ _text->loadFont(_resPack, 0x80010016); // blue font
+ _text->setTextPos(350, 179);
+ _text->drawText("-");
+
+ if (_mouseX < sizeMinus + 360 || _mouseX > sizeMinus + sizePlus + 360 || _mouseY < 179 || _mouseY > 203)
+ _text->loadFont(_resPack, 0x80010010); // yellow font
+ else
+ _text->loadFont(_resPack, 0x80010016); // blue font
+ _text->setTextPos(sizeMinus + 360, 179);
+ _text->drawText("+");
+
+ _text->setTextPos(sizeMinus + sizePlus + 365, 179);
+ _text->loadFont(_resPack, 0x80010010);
+ if(_confGameQuality == 5) {
+ _text->drawResText(0x8000059C);
+ } else {
+ for (uint32 i = 5; i > _confGameQuality; --i ) {
+ _text->drawText("]");
+ }
+ if (!_confGameQuality)
+ _text->drawText("*");
+ }
+
+ // back to main menu
+ if (_mouseX < 300 || _mouseX > 300 + sizeMainMenu || _mouseY < 340 || _mouseY > 340 + 24)
+ _text->loadFont(_resPack, 0x80010010); // yellow font
+ else
+ _text->loadFont(_resPack, 0x80010016); // blue font
+ _text->setTextPos(300, 340);
+ _text->drawResText(0x8000059D);
+
+ // action
+ if (_leftClick) {
+ // back to main menu
+ if (_mouseX >= 300 && _mouseX <= 300 + sizeMainMenu && _mouseY >= 340 && _mouseY <= 340 + 24) {
+ // TODO: save new configurations
+ exitSubMenu();
+ }
+
+ // gamma level minus
+ if (_mouseX >= 350 && _mouseX <= sizeMinus + 350 && _mouseY >= 150 && _mouseY <= 174) {
+ if(_confGammaLevel) {
+ _confGammaLevel -= 1;
+ // TODO: setResGammaLevel(0x80010011, 0);
+ }
+ }
+ // gamma level plus
+ if (_mouseX >= sizeMinus + 360 && _mouseX <= sizeMinus + sizePlus + 360 && _mouseY >= 150 && _mouseY <= 174) {
+ if(_confGammaLevel < 8) {
+ _confGammaLevel += 1;
+ // TODO: setResGammaLevel(0x80010011, 0);
+ }
+ }
+
+ // performance minus
+ if (_mouseX >= 350 && _mouseX <= sizeMinus + 350 && _mouseY >= 179 && _mouseY <= 203) {
+ if(_confGameQuality) {
+ _confGameQuality -= 1;
+ // TODO: change quality settings
+ }
+ }
+ // performance plus
+ if (_mouseX >= sizeMinus + 360 && _mouseX <= sizeMinus + sizePlus + 360 && _mouseY >= 179 && _mouseY <= 203) {
+ if(_confGameQuality < 5) {
+ _confGameQuality += 1;
+ // TODO: change quality settings
+ }
+ }
+ }
}
void MainMenu::updateSubMenuQuitGame() {
- // yellow font
- _text->loadFont(_resPack, 0x80010010);
+ // yellow font
+ _text->loadFont(_resPack, 0x80010010);
- // begin new game
+ // begin new game
_text->drawResTextCentered(10, 100, 620, 0x80000580);
// Yes
- if (_mouseX < 247 || _mouseX > 247 + _text->getResTextWidth(0x80000581) || _mouseY < 273 || _mouseY > 273 + 24 )
- _text->loadFont(_resPack, 0x80010010); // yellow font
- else
- _text->loadFont(_resPack, 0x80010016); // blue font
- _text->setTextPos(247, 273);
+ if (_mouseX < 247 || _mouseX > 247 + _text->getResTextWidth(0x80000581) || _mouseY < 273 || _mouseY > 273 + 24 )
+ _text->loadFont(_resPack, 0x80010010); // yellow font
+ else
+ _text->loadFont(_resPack, 0x80010016); // blue font
+ _text->setTextPos(247, 273);
_text->drawResText(0x80000581);
- // No
- if (_mouseX < 369 || _mouseX > 369 + _text->getResTextWidth(0x80000582) || _mouseY < 273 || _mouseY > 273 + 24 )
- _text->loadFont(_resPack, 0x80010010); // yellow font
- else
- _text->loadFont(_resPack, 0x80010016); // blue font
- _text->setTextPos(369, 273);
+ // No
+ if (_mouseX < 369 || _mouseX > 369 + _text->getResTextWidth(0x80000582) || _mouseY < 273 || _mouseY > 273 + 24 )
+ _text->loadFont(_resPack, 0x80010010); // yellow font
+ else
+ _text->loadFont(_resPack, 0x80010016); // blue font
+ _text->setTextPos(369, 273);
_text->drawResText(0x80000582);
- // action
- if (_leftClick) {
- // Yes
- if (_mouseX >= 247 && _mouseX <= 247 + 24 && _mouseY >= 273 && _mouseY <= 273 + _text->getResTextWidth(0x80000581)) {
- _leftClick = false;
+ // action
+ if (_leftClick) {
+ // Yes
+ if (_mouseX >= 247 && _mouseX <= 247 + 24 && _mouseY >= 273 && _mouseY <= 273 + _text->getResTextWidth(0x80000581)) {
+ _leftClick = false;
// User clicked on quit, so push a quit event
Common::Event event;
event.type = Common::EVENT_QUIT;
g_system->getEventManager()->pushEvent(event);
- }
- // No
- if (_mouseX >= 369 && _mouseX <= 369 + 24 && _mouseY >= 273 && _mouseY <= 273 + _text->getResTextWidth(0x80000582))
- exitSubMenu();
- }
+ }
+ // No
+ if (_mouseX >= 369 && _mouseX <= 369 + 24 && _mouseY >= 273 && _mouseY <= 273 + _text->getResTextWidth(0x80000582))
+ exitSubMenu();
+ }
}
void MainMenu::updateSubMenuShowCredits() {
- int posY = _creditsTextScroll;
- int resId = 0;
- int step = 0;
- int minBound = 0;
- int maxBound = 0;
+ int posY = _creditsTextScroll;
+ int resId = 0;
+ int step = 0;
+ int minBound = 0;
+ int maxBound = 0;
- GraphicFrame *creditsFadeFrame = _creditsFadeResource->getFrame(0);
+ GraphicFrame *creditsFadeFrame = _creditsFadeResource->getFrame(0);
_screen->copyRectToScreenWithTransparency((byte *)creditsFadeFrame->surface.pixels, creditsFadeFrame->surface.w, creditsFadeFrame->x, creditsFadeFrame->y, creditsFadeFrame->surface.w, creditsFadeFrame->surface.h);
- GraphicFrame *creditsFrame = _creditsResource->getFrame(MIN<int>(_creditsResource->getFrameCount() - 1, _creditsBgFrame));
+ GraphicFrame *creditsFrame = _creditsResource->getFrame(MIN<int>(_creditsResource->getFrameCount() - 1, _creditsBgFrame));
_screen->copyRectToScreenWithTransparency((byte *)creditsFrame->surface.pixels, creditsFrame->surface.w, creditsFrame->x, creditsFrame->y, creditsFrame->surface.w, creditsFrame->surface.h);
_creditsBgFrame++;
- if (_creditsBgFrame >= _creditsResource->getFrameCount())
+ if (_creditsBgFrame >= _creditsResource->getFrameCount())
_creditsBgFrame = 0;
- do {
- if (posY + step >= 0) {
- if (posY + step > 450)
- break;
-
- minBound = posY + step + 24;
- if (minBound >= 0)
- if (minBound < 32) {
- // TODO fade side text
- posY = _creditsTextScroll;
- }
-
- maxBound = posY + step;
- if (posY + step < 480)
- if (maxBound > 448) {
- // TODO fade side text
- posY = _creditsTextScroll;
- }
-
- _text->setTextPos(320, step + posY);
- _text->drawResText(resId - 2147482201);
- posY = _creditsTextScroll;
- }
- step += 24;
- ++resId;
- } while (step < 0x21F0);
-
- _creditsTextScroll -= 2;
-
- // TODO: some palette stuffs
-
- // TODO: if gameFlag=901 (finished game) and already play music 56, start music 40
+ do {
+ if (posY + step >= 0) {
+ if (posY + step > 450)
+ break;
+
+ minBound = posY + step + 24;
+ if (minBound >= 0)
+ if (minBound < 32) {
+ // TODO fade side text
+ posY = _creditsTextScroll;
+ }
+
+ maxBound = posY + step;
+ if (posY + step < 480)
+ if (maxBound > 448) {
+ // TODO fade side text
+ posY = _creditsTextScroll;
+ }
+
+ _text->setTextPos(320, step + posY);
+ _text->drawResText(resId - 2147482201);
+ posY = _creditsTextScroll;
+ }
+ step += 24;
+ ++resId;
+ } while (step < 0x21F0);
+
+ _creditsTextScroll -= 2;
+
+ // TODO: some palette stuffs
+
+ // TODO: if gameFlag=901 (finished game) and already play music 56, start music 40
if (_leftClick) {
// Restore palette
_screen->setPalette(_resPack, 17);
- // Stop all sounds
- _sound->stopMusic();
- // Start playing music
- _sound->playMusic(_resPack, 39);
- exitSubMenu();
+ // Stop all sounds
+ _sound->stopMusic();
+ // Start playing music
+ _sound->playMusic(_resPack, 39);
+ exitSubMenu();
}
}
diff --git a/engines/asylum/menu.h b/engines/asylum/menu.h
index b3d5e4aae0..4a83584ecf 100644
--- a/engines/asylum/menu.h
+++ b/engines/asylum/menu.h
@@ -11,7 +11,7 @@
* 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
+ * 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
@@ -54,32 +54,32 @@ public:
private:
enum EyesAnimation {
- kEyesFront = 0,
- kEyesLeft = 1,
- kEyesRight = 2,
- kEyesTop = 3,
- kEyesBottom = 4,
- kEyesTopLeft = 5,
- kEyesTopRight = 6,
- kEyesBottomLeft = 7,
+ kEyesFront = 0,
+ kEyesLeft = 1,
+ kEyesRight = 2,
+ kEyesTop = 3,
+ kEyesBottom = 4,
+ kEyesTopLeft = 5,
+ kEyesTopRight = 6,
+ kEyesBottomLeft = 7,
kEyesBottomRight = 8,
- kEyesCrossed = 9
+ kEyesCrossed = 9
};
enum MenuScreen {
- kNewGame = 0,
- kLoadGame = 1,
- kSaveGame = 2,
- kDeleteGame = 3,
- kViewCinematics = 4,
- kQuitGame = 5,
- kTextOptions = 6,
- kAudioOptions = 7,
- kSettings = 8,
- kKeyboardConfig = 9,
- kShowCredits = 10,
- kReturnToGame = 11,
- kMainMenu = 12
+ kNewGame = 0,
+ kLoadGame = 1,
+ kSaveGame = 2,
+ kDeleteGame = 3,
+ kViewCinematics = 4,
+ kQuitGame = 5,
+ kTextOptions = 6,
+ kAudioOptions = 7,
+ kSettings = 8,
+ kKeyboardConfig = 9,
+ kShowCredits = 10,
+ kReturnToGame = 11,
+ kMainMenu = 12
};
Common::Event *_ev;
@@ -88,31 +88,31 @@ private:
Sound *_sound;
Scene *_scene;
- uint32 _mouseX;
- uint32 _mouseY;
- int32 _activeIcon;
- int32 _previousActiveIcon;
- uint32 _curIconFrame;
- uint32 _curMouseCursor;
- int32 _cursorStep;
- uint32 _creditsBgFrame;
- uint32 _creditsTextScroll;
+ uint32 _mouseX;
+ uint32 _mouseY;
+ int32 _activeIcon;
+ int32 _previousActiveIcon;
+ uint32 _curIconFrame;
+ uint32 _curMouseCursor;
+ int32 _cursorStep;
+ uint32 _creditsBgFrame;
+ uint32 _creditsTextScroll;
bool _leftClick;
bool _active;
- // FIXME this shouldnt be here. Need a proper config place
- uint32 _confGammaLevel;
- uint32 _confGameQuality;
+ // FIXME this shouldnt be here. Need a proper config place
+ uint32 _confGammaLevel;
+ uint32 _confGameQuality;
- MenuScreen _activeMenuScreen;
- ResourcePack *_resPack;
+ MenuScreen _activeMenuScreen;
+ ResourcePack *_resPack;
GraphicResource *_bgResource;
GraphicResource *_cursorResource;
GraphicResource *_eyeResource;
GraphicResource *_iconResource;
- GraphicResource *_creditsResource;
- GraphicResource *_creditsFadeResource;
- Text *_text;
+ GraphicResource *_creditsResource;
+ GraphicResource *_creditsFadeResource;
+ Text *_text;
void updateCursor();
void updateEyesAnimation();
@@ -120,11 +120,11 @@ private:
void updateSubMenu();
void exitSubMenu();
- void updateSubMenuNewGame();
+ void updateSubMenuNewGame();
void updateSubMenuCinematics();
- void updateSubMenuSettings();
- void updateSubMenuQuitGame();
- void updateSubMenuShowCredits();
+ void updateSubMenuSettings();
+ void updateSubMenuQuitGame();
+ void updateSubMenuShowCredits();
void update();
diff --git a/engines/asylum/scene.cpp b/engines/asylum/scene.cpp
index 05e3b365de..afe129febf 100644
--- a/engines/asylum/scene.cpp
+++ b/engines/asylum/scene.cpp
@@ -11,7 +11,7 @@
* 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
+ * 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
@@ -34,23 +34,23 @@ namespace Asylum {
int g_debugPolygons;
Scene::Scene(Screen *screen, Sound *sound, uint8 sceneIdx): _screen(screen), _sound(sound) {
- _sceneIdx = sceneIdx;
- _sceneResource = new SceneResource;
- if (_sceneResource->load(_sceneIdx)) {
- _text = new Text(_screen);
- _resPack = new ResourcePack(sceneIdx);
+ _sceneIdx = sceneIdx;
+ _sceneResource = new SceneResource;
+ if (_sceneResource->load(_sceneIdx)) {
+ _text = new Text(_screen);
+ _resPack = new ResourcePack(sceneIdx);
_speechPack = new ResourcePack(3);
_sceneResource->getMainActor()->setResourcePack(_resPack);
_text->loadFont(_resPack, _sceneResource->getWorldStats()->commonRes.font1);
- char musPackFileName[10];
- sprintf(musPackFileName, "mus.%03d", sceneIdx);
- _musPack = new ResourcePack(musPackFileName);
+ char musPackFileName[10];
+ sprintf(musPackFileName, "mus.%03d", sceneIdx);
+ _musPack = new ResourcePack(musPackFileName);
_bgResource = new GraphicResource(_resPack, _sceneResource->getWorldStats()->commonRes.backgroundImage);
- }
+ }
_cursorResource = new GraphicResource(_resPack, _sceneResource->getWorldStats()->commonRes.curMagnifyingGlass);
@@ -65,11 +65,11 @@ Scene::Scene(Screen *screen, Sound *sound, uint8 sceneIdx): _screen(screen), _so
Scene::~Scene() {
delete _cursorResource;
delete _bgResource;
- delete _musPack;
+ delete _musPack;
delete _speechPack;
- delete _resPack;
- delete _text;
- delete _sceneResource;
+ delete _resPack;
+ delete _text;
+ delete _sceneResource;
}
void Scene::enterScene() {
@@ -94,74 +94,74 @@ void Scene::enterScene() {
}
int Scene::getDefaultActionIndex() {
- if (_sceneResource) {
- return _sceneResource->getWorldStats()->actionListIdx;
- }
- else
- return -1;
+ if (_sceneResource) {
+ return _sceneResource->getWorldStats()->actionListIdx;
+ }
+ else
+ return -1;
}
ActionDefinitions * Scene::getActionList(int actionListIndex) {
- if ((actionListIndex >= 0) && (actionListIndex < (int)_sceneResource->getWorldStats()->numActions)) {
- return &_sceneResource->getActionList()->actions[actionListIndex];
- }
- else
- return 0;
+ if ((actionListIndex >= 0) && (actionListIndex < (int)_sceneResource->getWorldStats()->numActions)) {
+ return &_sceneResource->getActionList()->actions[actionListIndex];
+ }
+ else
+ return 0;
}
void Scene::setActorPosition(int actorIndex, int x, int y) {
- if ((actorIndex >= 0) && (actorIndex < (int)_sceneResource->getWorldStats()->numActors)) {
- _sceneResource->getWorldStats()->actors[actorIndex].boundingRect.left = x;
- _sceneResource->getWorldStats()->actors[actorIndex].boundingRect.top = y;
- }
-
- // FIXME - Remove this once mainActor uses proper actor info
- if (actorIndex == 0) {
- _sceneResource->getMainActor()->_actorX = x;
- _sceneResource->getMainActor()->_actorY = y;
- }
+ if ((actorIndex >= 0) && (actorIndex < (int)_sceneResource->getWorldStats()->numActors)) {
+ _sceneResource->getWorldStats()->actors[actorIndex].boundingRect.left = x;
+ _sceneResource->getWorldStats()->actors[actorIndex].boundingRect.top = y;
+ }
+
+ // FIXME - Remove this once mainActor uses proper actor info
+ if (actorIndex == 0) {
+ _sceneResource->getMainActor()->_actorX = x;
+ _sceneResource->getMainActor()->_actorY = y;
+ }
}
void Scene::setActorAction(int actorIndex, int action) {
- if ((actorIndex >= 0) && (actorIndex < (int)_sceneResource->getWorldStats()->numActors)) {
- _sceneResource->getWorldStats()->actors[actorIndex].direction = action;
- }
-
- // FIXME - Remove this once mainActor uses proper actor info
- if (actorIndex == 0) {
- if(_sceneResource->getMainActor())
- _sceneResource->getMainActor()->setActionByIndex(action); // The action appears to be an index rather than a direct resId
- }
+ if ((actorIndex >= 0) && (actorIndex < (int)_sceneResource->getWorldStats()->numActors)) {
+ _sceneResource->getWorldStats()->actors[actorIndex].direction = action;
+ }
+
+ // FIXME - Remove this once mainActor uses proper actor info
+ if (actorIndex == 0) {
+ if(_sceneResource->getMainActor())
+ _sceneResource->getMainActor()->setActionByIndex(action); // The action appears to be an index rather than a direct resId
+ }
}
void Scene::actorVisible(int actorIndex, bool visible) {
- if ((actorIndex >= 0) && (actorIndex < (int)_sceneResource->getWorldStats()->numActors)) {
- if(visible) // TODO - enums for flags (0x01 is visible)
- _sceneResource->getWorldStats()->actors[actorIndex].flags |= 0x01;
- else
- _sceneResource->getWorldStats()->actors[actorIndex].flags &= 0xFFFFFFFE;
- }
-
-
- // FIXME - Remove this once mainActor uses proper actor info
- if (actorIndex == 0) {
- //if(_sceneResource->getMainActor())
- //_sceneResource->getMainActor()->setAction(action);
- }
+ if ((actorIndex >= 0) && (actorIndex < (int)_sceneResource->getWorldStats()->numActors)) {
+ if(visible) // TODO - enums for flags (0x01 is visible)
+ _sceneResource->getWorldStats()->actors[actorIndex].flags |= 0x01;
+ else
+ _sceneResource->getWorldStats()->actors[actorIndex].flags &= 0xFFFFFFFE;
+ }
+
+
+ // FIXME - Remove this once mainActor uses proper actor info
+ if (actorIndex == 0) {
+ //if(_sceneResource->getMainActor())
+ //_sceneResource->getMainActor()->setAction(action);
+ }
}
bool Scene::actorVisible(int actorIndex) {
- if ((actorIndex >= 0) && (actorIndex < (int)_sceneResource->getWorldStats()->numActors)) {
- return _sceneResource->getWorldStats()->actors[actorIndex].flags & 0x01; // TODO - enums for flags (0x01 is visible)
- }
-
- // FIXME - Remove this once mainActor uses proper actor info
- if (actorIndex == 0) {
- //if(_sceneResource->getMainActor())
- //_sceneResource->getMainActor()->setAction(action);
- }
-
- return false;
+ if ((actorIndex >= 0) && (actorIndex < (int)_sceneResource->getWorldStats()->numActors)) {
+ return _sceneResource->getWorldStats()->actors[actorIndex].flags & 0x01; // TODO - enums for flags (0x01 is visible)
+ }
+
+ // FIXME - Remove this once mainActor uses proper actor info
+ if (actorIndex == 0) {
+ //if(_sceneResource->getMainActor())
+ //_sceneResource->getMainActor()->setAction(action);
+ }
+
+ return false;
}
void Scene::handleEvent(Common::Event *event, bool doUpdate) {
@@ -227,12 +227,12 @@ void Scene::update() {
// Copy the background to the back buffer before updating the scene animations
_screen->copyToBackBuffer(((byte *)bg->surface.pixels) + _startY * bg->surface.w + _startX, bg->surface.w, 0, 0, 640, 480);
- updateBarrier(_screen, _resPack, 1); // inside the middle room
- for(uint b=0; b < _sceneResource->getWorldStats()->barriers.size(); b++) {
- if ((_sceneResource->getWorldStats()->barriers[b].flags & 0x20) != 0) // TODO - enums for flags (0x20 is visible/playing?)
- updateBarrier(_screen, _resPack, b);
- }
- /*
+ updateBarrier(_screen, _resPack, 1); // inside the middle room
+ for(uint b=0; b < _sceneResource->getWorldStats()->barriers.size(); b++) {
+ if ((_sceneResource->getWorldStats()->barriers[b].flags & 0x20) != 0) // TODO - enums for flags (0x20 is visible/playing?)
+ updateBarrier(_screen, _resPack, b);
+ }
+ /*
updateBarrier(_screen, _resPack, 0); // the "statue with fireworks" animation
//updateBarrier(_screen, _resPack, 1); // inside the middle room
//updateBarrier(_screen, _resPack, 2); // the lit candles at the base of the statue
@@ -252,8 +252,8 @@ void Scene::update() {
if (!_rightButton) {
//mainActor->setAction(15); // face south
//mainActor->drawActorAt(_screen, mainActor->_actorX, mainActor->_actorY);
- if (_sceneResource->getWorldStats()->actors[0].flags & 0x01) // TESTING - only draw if visible flag
- mainActor->drawActor(_screen);
+ if (_sceneResource->getWorldStats()->actors[0].flags & 0x01) // TESTING - only draw if visible flag
+ mainActor->drawActor(_screen);
} else {
mainActor->walkTo(_screen, _mouseX, _mouseY);
@@ -300,11 +300,11 @@ void Scene::update() {
for (uint32 p = 0; p < _sceneResource->getGamePolygons()->numEntries; p++) {
PolyDefinitions poly = _sceneResource->getGamePolygons()->polygons[p];
if (poly.boundingRect.contains(_mouseX + _startX, _mouseY + _startY)) {
- if (pointInPoly(&poly, _mouseX + _startX, _mouseY + _startY)) {
- curHotspot = (int32)p;
- updateCursor();
- break;
- }
+ if (pointInPoly(&poly, _mouseX + _startX, _mouseY + _startY)) {
+ curHotspot = (int32)p;
+ updateCursor();
+ break;
+ }
}
}
@@ -315,7 +315,7 @@ void Scene::update() {
for (uint32 a = 0; a < worldStats->numActions; a++) {
if (worldStats->actions[a].polyIdx == curHotspot) {
printf("Hotspot: 0x%X - \"%s\", poly %d, action lists %d/%d, action type %d, sound res %d\n",
- worldStats->actions[a].id,
+ worldStats->actions[a].id,
worldStats->actions[a].name,
worldStats->actions[a].polyIdx,
worldStats->actions[a].actionListIdx1,
@@ -346,7 +346,7 @@ void Scene::update() {
#if 0
void Scene::copyToSceneBackground(GraphicFrame *frame, int x, int y) {
int h = frame->surface.h;
- int w = frame->surface.w;
+ int w = frame->surface.w;
byte *buffer = (byte *)frame->surface.pixels;
byte *dest = ((byte *)_background->surface.pixels) + y * _background->surface.w + x;
@@ -370,10 +370,10 @@ void Scene::copyToBackBufferClipped(Graphics::Surface *surface, int x, int y) {
int startX = animRect.right == 640 ? 0 : surface->w - animRect.width();
int startY = animRect.bottom == 480 ? 0 : surface->h - animRect.height();
- if(surface->w > 640)
- startX = _startX;
- if(surface->h > 480)
- startY = _startY;
+ if (surface->w > 640)
+ startX = _startX;
+ if (surface->h > 480)
+ startY = _startY;
_screen->copyToBackBufferWithTransparency(((byte*)surface->pixels) +
startY * surface->pitch +
@@ -390,31 +390,31 @@ void Scene::updateBarrier(Screen *screen, ResourcePack *res, uint8 barrierIndex)
BarrierItem barrier = _sceneResource->getWorldStats()->barriers[barrierIndex];
GraphicResource *gra = new GraphicResource(res, barrier.resId);
if (!gra->getFrameCount())
- return;
- GraphicFrame *fra = gra->getFrame(barrier.tickCount);
+ return;
+ GraphicFrame *fra = gra->getFrame(barrier.tickCount);
#if 0
- // DEBUG bounding box
- // FIXME this should be a generic method which draws for an entire graphicResource and not for single graphicFrames
- fra->surface.frameRect(barrier.boundingRect, 0xFF);
+ // DEBUG bounding box
+ // FIXME this should be a generic method which draws for an entire graphicResource and not for single graphicFrames
+ fra->surface.frameRect(barrier.boundingRect, 0xFF);
#endif
copyToBackBufferClipped(&fra->surface, barrier.x, barrier.y);
if (barrier.tickCount < barrier.frameCount - 1) {
barrier.tickCount++;
- }else{
+ } else {
barrier.tickCount = barrier.frameIdx;
}
-
+
_sceneResource->getWorldStats()->barriers[barrierIndex] = barrier;
- delete gra;
+ delete gra;
}
bool Scene::pointInPoly(PolyDefinitions *poly, int x, int y) {
- // Copied from backends/vkeybd/polygon.cpp
- int yflag0;
+ // Copied from backends/vkeybd/polygon.cpp
+ int yflag0;
int yflag1;
bool inside_flag = false;
unsigned int pt;
@@ -441,27 +441,27 @@ bool Scene::pointInPoly(PolyDefinitions *poly, int x, int y) {
// POLYGONS DEBUG
void Scene::ShowPolygons() {
- for (uint32 p = 0; p < _sceneResource->getGamePolygons()->numEntries; p++) {
- Graphics::Surface surface;
- PolyDefinitions poly = _sceneResource->getGamePolygons()->polygons[p];
- surface.create(poly.boundingRect.right - poly.boundingRect.left + 1, poly.boundingRect.bottom - poly.boundingRect.top + 1, 1);
-
- // Draw all lines in Polygon
- for (uint32 i=0; i < poly.numPoints; i++) {
- surface.drawLine(
- poly.points[i].x - poly.boundingRect.left,
- poly.points[i].y - poly.boundingRect.top,
+ for (uint32 p = 0; p < _sceneResource->getGamePolygons()->numEntries; p++) {
+ Graphics::Surface surface;
+ PolyDefinitions poly = _sceneResource->getGamePolygons()->polygons[p];
+ surface.create(poly.boundingRect.right - poly.boundingRect.left + 1, poly.boundingRect.bottom - poly.boundingRect.top + 1, 1);
+
+ // Draw all lines in Polygon
+ for (uint32 i=0; i < poly.numPoints; i++) {
+ surface.drawLine(
+ poly.points[i].x - poly.boundingRect.left,
+ poly.points[i].y - poly.boundingRect.top,
poly.points[(i+1) % poly.numPoints].x - poly.boundingRect.left,
poly.points[(i+1) % poly.numPoints].y - poly.boundingRect.top, 0xFF);
- }
-
- // Draw Bounding Box
- //surface.frameRect(Common::Rect(0, 0, surface.w, surface.h), 0xFF);
+ }
+
+ // Draw Bounding Box
+ //surface.frameRect(Common::Rect(0, 0, surface.w, surface.h), 0xFF);
- copyToBackBufferClipped(&surface, poly.boundingRect.left, poly.boundingRect.top);
+ copyToBackBufferClipped(&surface, poly.boundingRect.left, poly.boundingRect.top);
- surface.free();
- }
+ surface.free();
+ }
}
} // end of namespace Asylum
diff --git a/engines/asylum/scene.h b/engines/asylum/scene.h
index c32e55c618..208b1559b3 100644
--- a/engines/asylum/scene.h
+++ b/engines/asylum/scene.h
@@ -11,7 +11,7 @@
* 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
+ * 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
@@ -46,10 +46,10 @@ struct PolyDefinitions;
class Scene {
public:
- Scene(Screen *screen, Sound *sound, uint8 sceneIdx);
+ Scene(Screen *screen, Sound *sound, uint8 sceneIdx);
~Scene();
- void handleEvent(Common::Event *event, bool doUpdate);
+ void handleEvent(Common::Event *event, bool doUpdate);
void enterScene();
void activate() { _isActive = true; }
@@ -69,40 +69,40 @@ private:
#if 0
void copyToSceneBackground(GraphicFrame *frame, int x, int y);
#endif
- void copyToBackBufferClipped(Graphics::Surface *surface, int x, int y);
+ void copyToBackBufferClipped(Graphics::Surface *surface, int x, int y);
- Screen *_screen;
- Sound *_sound;
+ Screen *_screen;
+ Sound *_sound;
Common::Event *_ev;
- Text *_text;
- SceneResource *_sceneResource;
- ResourcePack *_resPack;
- ResourcePack *_speechPack;
- ResourcePack *_musPack;
- GraphicResource *_bgResource;
+ Text *_text;
+ SceneResource *_sceneResource;
+ ResourcePack *_resPack;
+ ResourcePack *_speechPack;
+ ResourcePack *_musPack;
+ GraphicResource *_bgResource;
GraphicResource *_cursorResource;
- GraphicFrame *_background;
-
- uint8 _sceneIdx;
- uint32 _mouseX;
- uint32 _mouseY;
- int32 _startX;
- int32 _startY;
- bool _leftClick;
- bool _rightButton;
- uint32 _curMouseCursor;
- int32 _cursorStep;
- bool _isActive;
+ GraphicFrame *_background;
+
+ uint8 _sceneIdx;
+ uint32 _mouseX;
+ uint32 _mouseY;
+ int32 _startX;
+ int32 _startY;
+ bool _leftClick;
+ bool _rightButton;
+ uint32 _curMouseCursor;
+ int32 _cursorStep;
+ bool _isActive;
void update();
void updateCursor();
- void updateBarrier(Screen *screen, ResourcePack *res, uint8 actorIndex);
+ void updateBarrier(Screen *screen, ResourcePack *res, uint8 actorIndex);
- void ShowPolygons();
- bool pointInPoly(PolyDefinitions *poly, int x, int y);
-
- friend class Interpreter;
+ void ShowPolygons();
+ bool pointInPoly(PolyDefinitions *poly, int x, int y);
+
+ friend class Interpreter;
}; // end of class Scene
} // end of namespace Asylum
diff --git a/engines/asylum/sceneres.cpp b/engines/asylum/sceneres.cpp
index 563f2313ae..3d93901b6a 100644
--- a/engines/asylum/sceneres.cpp
+++ b/engines/asylum/sceneres.cpp
@@ -11,7 +11,7 @@
* 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
+ * 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
@@ -33,174 +33,173 @@ SceneResource::SceneResource() {
SceneResource::~SceneResource() {
delete _worldStats;
delete _mainActor;
- for(uint i=0; i< _gamePolygons->numEntries; i++) {
- delete[] _gamePolygons->polygons[i].points;
- }
- delete _gamePolygons;
- delete _actionList;
+ for (uint i=0; i < _gamePolygons->numEntries; i++) {
+ delete[] _gamePolygons->polygons[i].points;
+ }
+ delete _gamePolygons;
+ delete _actionList;
}
int SceneResource::getBarrierIndexById(uint32 id) {
- for (uint32 i=0; i < _worldStats->numBarriers; i++)
- {
- if (_worldStats->barriers[i].id == id)
- return i;
- }
- return -1;
+ for (uint32 i=0; i < _worldStats->numBarriers; i++) {
+ if (_worldStats->barriers[i].id == id)
+ return i;
+ }
+ return -1;
}
bool SceneResource::load(uint8 sceneIdx) {
- char sceneTag[6];
- Common::File* fd = new Common::File;
+ char sceneTag[6];
+ Common::File* fd = new Common::File;
Common::String filename = parseFilename(sceneIdx);
- if (!fd->exists(filename)) {
- printf("Scene file doesn't exist %s", filename.c_str());
- return false;
- }
+ if (!fd->exists(filename)) {
+ printf("Scene file doesn't exist %s", filename.c_str());
+ return false;
+ }
- fd->open(filename);
+ fd->open(filename);
- if (!fd->isOpen()) {
- printf("Failed to load scene file %s", filename.c_str());
- return false;
- }
+ if (!fd->isOpen()) {
+ printf("Failed to load scene file %s", filename.c_str());
+ return false;
+ }
- fd->read(sceneTag,6);
+ fd->read(sceneTag,6);
- if (Common::String(sceneTag,6) != "DFISCN") {
- printf("The file isn't recognized as scene %s", filename.c_str());
- return false;
- }
+ if (Common::String(sceneTag,6) != "DFISCN") {
+ printf("The file isn't recognized as scene %s", filename.c_str());
+ return false;
+ }
- loadWorldStats(fd);
- loadGamePolygons(fd);
- loadActionList(fd);
+ loadWorldStats(fd);
+ loadGamePolygons(fd);
+ loadActionList(fd);
- fd->close();
- delete fd;
+ fd->close();
+ delete fd;
- return true;
+ return true;
}
// FIXME: load necessary World Stats content
void SceneResource::loadWorldStats(Common::SeekableReadStream *stream) {
- _worldStats = new WorldStats;
+ _worldStats = new WorldStats;
- _worldStats->size = stream->readUint32LE();
- _worldStats->numEntries = stream->readUint32LE();
+ _worldStats->size = stream->readUint32LE();
+ _worldStats->numEntries = stream->readUint32LE();
- _worldStats->numChapter = stream->readUint32LE();
- _worldStats->xLeft = stream->readUint32LE();
- _worldStats->yTop = stream->readUint32LE();
- _worldStats->boundingRect.left = stream->readUint32LE() & 0xFFFF;
- _worldStats->boundingRect.top = stream->readUint32LE() & 0xFFFF;
- _worldStats->boundingRect.right = stream->readUint32LE() & 0xFFFF;
+ _worldStats->numChapter = stream->readUint32LE();
+ _worldStats->xLeft = stream->readUint32LE();
+ _worldStats->yTop = stream->readUint32LE();
+ _worldStats->boundingRect.left = stream->readUint32LE() & 0xFFFF;
+ _worldStats->boundingRect.top = stream->readUint32LE() & 0xFFFF;
+ _worldStats->boundingRect.right = stream->readUint32LE() & 0xFFFF;
_worldStats->boundingRect.bottom = stream->readUint32LE() & 0xFFFF;
- // read common graphic resources
- _worldStats->commonRes.backgroundImage = stream->readUint32LE();
- _worldStats->commonRes.curScrollUp = stream->readUint32LE();
- _worldStats->commonRes.curScrollUpLeft = stream->readUint32LE();
- _worldStats->commonRes.curScrollLeft = stream->readUint32LE();
- _worldStats->commonRes.curScrollDownLeft = stream->readUint32LE();
- _worldStats->commonRes.curScrollDown = stream->readUint32LE();
- _worldStats->commonRes.curScrollDownRight = stream->readUint32LE();
- _worldStats->commonRes.curScrollRight = stream->readUint32LE();
- _worldStats->commonRes.curScrollUpRight = stream->readUint32LE();
- _worldStats->commonRes.curHand = stream->readUint32LE();
- _worldStats->commonRes.curMagnifyingGlass = stream->readUint32LE();
- _worldStats->commonRes.curTalkNCP = stream->readUint32LE();
- _worldStats->commonRes.curGrabPointer = stream->readUint32LE();
- _worldStats->commonRes.curTalkNCP2 = stream->readUint32LE();
- _worldStats->commonRes.font1 = stream->readUint32LE();
- _worldStats->commonRes.font2 = stream->readUint32LE();
- _worldStats->commonRes.font3 = stream->readUint32LE();
- _worldStats->commonRes.palette = stream->readUint32LE();
- _worldStats->commonRes.cellShadeMask1 = stream->readUint32LE();
- _worldStats->commonRes.cellShadeMask2 = stream->readUint32LE();
- _worldStats->commonRes.cellShadeMask3 = stream->readUint32LE();
- _worldStats->commonRes.unused = stream->readUint32LE();
- _worldStats->commonRes.smallCurUp = stream->readUint32LE();
- _worldStats->commonRes.smallCurDown = stream->readUint32LE();
- _worldStats->commonRes.field_7C = stream->readUint32LE();
-
- _worldStats->width = stream->readUint32LE();
- _worldStats->height = stream->readUint32LE();
- _worldStats->field_88 = stream->readUint32LE();
- _worldStats->field_8C = stream->readUint32LE();
- _worldStats->numActions = stream->readUint32LE();
- _worldStats->numBarriers = stream->readUint32LE();
- _worldStats->field_98 = stream->readUint32LE();
- _worldStats->field_9C = stream->readUint32LE();
- _worldStats->field_A0 = stream->readUint32LE();
- _worldStats->field_A4 = stream->readUint32LE();
- _worldStats->field_A8 = stream->readUint32LE();
- _worldStats->field_AC = stream->readUint32LE();
- _worldStats->field_B0 = stream->readUint32LE();
- _worldStats->numActors = stream->readUint32LE();
- _worldStats->stereoReversedFlag = stream->readUint32LE();
-
- for(int r=0; r < 6; r++) {
- _worldStats->sceneRects[r].left = stream->readUint32LE() & 0xFFFF;
- _worldStats->sceneRects[r].top = stream->readUint32LE() & 0xFFFF;
- _worldStats->sceneRects[r].right = stream->readUint32LE() & 0xFFFF;
- _worldStats->sceneRects[r].bottom = stream->readUint32LE() & 0xFFFF;
- }
- _worldStats->sceneRectIdx = stream->readByte();
- _worldStats->field_11D[0] = stream->readByte();
- _worldStats->field_11D[1] = stream->readByte();
- _worldStats->field_11D[2] = stream->readByte();
-
- _worldStats->field_120 = stream->readUint32LE();
- _worldStats->actionListIdx = stream->readUint32LE();
-
- for(int gr=0; gr < 100; gr++) {
- _worldStats->grResId[gr] = stream->readUint32LE();
- }
-
- _worldStats->sceneTitleGrResId = stream->readUint32LE();
- _worldStats->sceneTitlePalResId = stream->readUint32LE();
- _worldStats->actorType = stream->readUint32LE();
-
- for(int s=0; s < 50; s++) {
- _worldStats->soundResId[s] = stream->readUint32LE();
- }
-
- for(int s=0; s < 15; s++) {
- _worldStats->ambientSounds[s].field_0 = stream->readUint32LE();
- _worldStats->ambientSounds[s].flags = stream->readUint32LE();
- _worldStats->ambientSounds[s].resId = stream->readUint32LE();
- _worldStats->ambientSounds[s].field_C = stream->readUint32LE();
- _worldStats->ambientSounds[s].field_10 = stream->readUint32LE();
- _worldStats->ambientSounds[s].field_14 = stream->readUint32LE();
-
- for(int i=0; i < 6; i++)
- _worldStats->ambientSounds[s].flagNum[i] = stream->readUint32LE();
-
- _worldStats->ambientSounds[s].x = stream->readUint32LE();
- _worldStats->ambientSounds[s].y = stream->readUint32LE();
- }
- _worldStats->numAmbientSound = stream->readUint32LE();
-
- _worldStats->musicStatus = stream->readUint32LE();
- _worldStats->musicCurrentResId = stream->readUint32LE();
- _worldStats->musicFlag = stream->readUint32LE();
- _worldStats->musicResId = stream->readUint32LE();
- _worldStats->musicStatusExt = stream->readUint32LE();
-
- for (uint32 a = 0; a < _worldStats->numBarriers; a++) {
- int i;
- BarrierItem barrier;
-
- barrier.id = stream->readUint32LE();
+ // read common graphic resources
+ _worldStats->commonRes.backgroundImage = stream->readUint32LE();
+ _worldStats->commonRes.curScrollUp = stream->readUint32LE();
+ _worldStats->commonRes.curScrollUpLeft = stream->readUint32LE();
+ _worldStats->commonRes.curScrollLeft = stream->readUint32LE();
+ _worldStats->commonRes.curScrollDownLeft = stream->readUint32LE();
+ _worldStats->commonRes.curScrollDown = stream->readUint32LE();
+ _worldStats->commonRes.curScrollDownRight = stream->readUint32LE();
+ _worldStats->commonRes.curScrollRight = stream->readUint32LE();
+ _worldStats->commonRes.curScrollUpRight = stream->readUint32LE();
+ _worldStats->commonRes.curHand = stream->readUint32LE();
+ _worldStats->commonRes.curMagnifyingGlass = stream->readUint32LE();
+ _worldStats->commonRes.curTalkNCP = stream->readUint32LE();
+ _worldStats->commonRes.curGrabPointer = stream->readUint32LE();
+ _worldStats->commonRes.curTalkNCP2 = stream->readUint32LE();
+ _worldStats->commonRes.font1 = stream->readUint32LE();
+ _worldStats->commonRes.font2 = stream->readUint32LE();
+ _worldStats->commonRes.font3 = stream->readUint32LE();
+ _worldStats->commonRes.palette = stream->readUint32LE();
+ _worldStats->commonRes.cellShadeMask1 = stream->readUint32LE();
+ _worldStats->commonRes.cellShadeMask2 = stream->readUint32LE();
+ _worldStats->commonRes.cellShadeMask3 = stream->readUint32LE();
+ _worldStats->commonRes.unused = stream->readUint32LE();
+ _worldStats->commonRes.smallCurUp = stream->readUint32LE();
+ _worldStats->commonRes.smallCurDown = stream->readUint32LE();
+ _worldStats->commonRes.field_7C = stream->readUint32LE();
+
+ _worldStats->width = stream->readUint32LE();
+ _worldStats->height = stream->readUint32LE();
+ _worldStats->field_88 = stream->readUint32LE();
+ _worldStats->field_8C = stream->readUint32LE();
+ _worldStats->numActions = stream->readUint32LE();
+ _worldStats->numBarriers = stream->readUint32LE();
+ _worldStats->field_98 = stream->readUint32LE();
+ _worldStats->field_9C = stream->readUint32LE();
+ _worldStats->field_A0 = stream->readUint32LE();
+ _worldStats->field_A4 = stream->readUint32LE();
+ _worldStats->field_A8 = stream->readUint32LE();
+ _worldStats->field_AC = stream->readUint32LE();
+ _worldStats->field_B0 = stream->readUint32LE();
+ _worldStats->numActors = stream->readUint32LE();
+ _worldStats->stereoReversedFlag = stream->readUint32LE();
+
+ for (int r=0; r < 6; r++) {
+ _worldStats->sceneRects[r].left = stream->readUint32LE() & 0xFFFF;
+ _worldStats->sceneRects[r].top = stream->readUint32LE() & 0xFFFF;
+ _worldStats->sceneRects[r].right = stream->readUint32LE() & 0xFFFF;
+ _worldStats->sceneRects[r].bottom = stream->readUint32LE() & 0xFFFF;
+ }
+ _worldStats->sceneRectIdx = stream->readByte();
+ _worldStats->field_11D[0] = stream->readByte();
+ _worldStats->field_11D[1] = stream->readByte();
+ _worldStats->field_11D[2] = stream->readByte();
+
+ _worldStats->field_120 = stream->readUint32LE();
+ _worldStats->actionListIdx = stream->readUint32LE();
+
+ for (int gr=0; gr < 100; gr++) {
+ _worldStats->grResId[gr] = stream->readUint32LE();
+ }
+
+ _worldStats->sceneTitleGrResId = stream->readUint32LE();
+ _worldStats->sceneTitlePalResId = stream->readUint32LE();
+ _worldStats->actorType = stream->readUint32LE();
+
+ for(int s=0; s < 50; s++) {
+ _worldStats->soundResId[s] = stream->readUint32LE();
+ }
+
+ for(int s=0; s < 15; s++) {
+ _worldStats->ambientSounds[s].field_0 = stream->readUint32LE();
+ _worldStats->ambientSounds[s].flags = stream->readUint32LE();
+ _worldStats->ambientSounds[s].resId = stream->readUint32LE();
+ _worldStats->ambientSounds[s].field_C = stream->readUint32LE();
+ _worldStats->ambientSounds[s].field_10 = stream->readUint32LE();
+ _worldStats->ambientSounds[s].field_14 = stream->readUint32LE();
+
+ for(int i=0; i < 6; i++)
+ _worldStats->ambientSounds[s].flagNum[i] = stream->readUint32LE();
+
+ _worldStats->ambientSounds[s].x = stream->readUint32LE();
+ _worldStats->ambientSounds[s].y = stream->readUint32LE();
+ }
+ _worldStats->numAmbientSound = stream->readUint32LE();
+
+ _worldStats->musicStatus = stream->readUint32LE();
+ _worldStats->musicCurrentResId = stream->readUint32LE();
+ _worldStats->musicFlag = stream->readUint32LE();
+ _worldStats->musicResId = stream->readUint32LE();
+ _worldStats->musicStatusExt = stream->readUint32LE();
+
+ for (uint32 a = 0; a < _worldStats->numBarriers; a++) {
+ int i;
+ BarrierItem barrier;
+
+ barrier.id = stream->readUint32LE();
barrier.resId = stream->readUint32LE();
- barrier.x = stream->readUint32LE();
- barrier.y = stream->readUint32LE();
+ barrier.x = stream->readUint32LE();
+ barrier.y = stream->readUint32LE();
- barrier.boundingRect.left = stream->readUint32LE() & 0xFFFF;
- barrier.boundingRect.top = stream->readUint32LE() & 0xFFFF;
- barrier.boundingRect.right = stream->readUint32LE() & 0xFFFF;
+ barrier.boundingRect.left = stream->readUint32LE() & 0xFFFF;
+ barrier.boundingRect.top = stream->readUint32LE() & 0xFFFF;
+ barrier.boundingRect.right = stream->readUint32LE() & 0xFFFF;
barrier.boundingRect.bottom = stream->readUint32LE() & 0xFFFF;
barrier.field_20 = stream->readUint32LE();
@@ -209,7 +208,7 @@ void SceneResource::loadWorldStats(Common::SeekableReadStream *stream) {
barrier.field_2C = stream->readUint32LE();
barrier.field_30 = stream->readUint32LE();
barrier.field_34 = stream->readUint32LE();
- barrier.flags = stream->readUint32LE();
+ barrier.flags = stream->readUint32LE();
barrier.field_3C = stream->readUint32LE();
stream->read(barrier.name, sizeof(barrier.name));
@@ -218,21 +217,21 @@ void SceneResource::loadWorldStats(Common::SeekableReadStream *stream) {
barrier.field_78 = stream->readUint32LE();
barrier.field_7C = stream->readUint32LE();
barrier.field_80 = stream->readUint32LE();
- barrier.polyIdx = stream->readUint32LE();
- barrier.flags2 = stream->readUint32LE();
+ barrier.polyIdx = stream->readUint32LE();
+ barrier.flags2 = stream->readUint32LE();
for (i = 0; i < 10; i++)
barrier.gameFlags[i] = stream->readUint32LE();
- barrier.field_B4 = stream->readUint32LE();
- barrier.tickCount = stream->readUint32LE();
- barrier.tickCount2 = stream->readUint32LE();
- barrier.field_C0 = stream->readUint32LE();
- barrier.field_C4 = stream->readUint32LE();
+ barrier.field_B4 = stream->readUint32LE();
+ barrier.tickCount = stream->readUint32LE();
+ barrier.tickCount2 = stream->readUint32LE();
+ barrier.field_C0 = stream->readUint32LE();
+ barrier.field_C4 = stream->readUint32LE();
barrier.actionListIdx = stream->readUint32LE();
for (i = 0; i < 16; i++) {
- barrier.soundItems[i].resId = stream->readUint32LE();
+ barrier.soundItems[i].resId = stream->readUint32LE();
barrier.soundItems[i].field_4 = stream->readUint32LE();
barrier.soundItems[i].field_8 = stream->readUint32LE();
barrier.soundItems[i].field_C = stream->readUint32LE();
@@ -240,17 +239,17 @@ void SceneResource::loadWorldStats(Common::SeekableReadStream *stream) {
}
for (i = 0; i < 50; i++) {
- barrier.frameSoundItems[i].resId = stream->readUint32LE();
+ barrier.frameSoundItems[i].resId = stream->readUint32LE();
barrier.frameSoundItems[i].frameIdx = stream->readUint32LE();
- barrier.frameSoundItems[i].index = stream->readUint32LE();
- barrier.frameSoundItems[i].field_C = stream->readUint32LE();
+ barrier.frameSoundItems[i].index = stream->readUint32LE();
+ barrier.frameSoundItems[i].field_C = stream->readUint32LE();
barrier.frameSoundItems[i].field_10 = stream->readUint32LE();
barrier.frameSoundItems[i].field_14 = stream->readUint32LE();
}
barrier.field_67C = stream->readUint32LE();
- barrier.soundX = stream->readUint32LE();
- barrier.soundY = stream->readUint32LE();
+ barrier.soundX = stream->readUint32LE();
+ barrier.soundY = stream->readUint32LE();
barrier.field_688 = stream->readUint32LE();
for (i = 0; i < 5; i++) {
@@ -260,196 +259,196 @@ void SceneResource::loadWorldStats(Common::SeekableReadStream *stream) {
barrier.soundResId = stream->readUint32LE();
barrier.field_6A4 = stream->readUint32LE();
- _worldStats->barriers.push_back(barrier);
- }
-
- // need to jump all unused barriers data to where actors data start
- stream->seek(0xA6D7A);
-
- for (uint32 a = 0; a < _worldStats->numActors; a++) {
- int i;
- ActorItem actor;
- memset(&actor, 0, sizeof(ActorItem));
-
- actor.x0 = stream->readUint32LE();
- actor.y0 = stream->readUint32LE();
- actor.grResId = stream->readUint32LE();
- actor.field_C = stream->readUint32LE();
- actor.frameNum = stream->readUint32LE();
- actor.frameCount = stream->readUint32LE();
- actor.x1 = stream->readUint32LE();
- actor.y1 = stream->readUint32LE();
- actor.x2 = stream->readUint32LE();
- actor.y2 = stream->readUint32LE();
-
- actor.boundingRect.left = stream->readUint32LE() & 0xFFFF;
- actor.boundingRect.top = stream->readUint32LE() & 0xFFFF;
+ _worldStats->barriers.push_back(barrier);
+ }
+
+ // need to jump all unused barriers data to where actors data start
+ stream->seek(0xA6D7A);
+
+ for (uint32 a = 0; a < _worldStats->numActors; a++) {
+ int i;
+ ActorItem actor;
+ memset(&actor, 0, sizeof(ActorItem));
+
+ actor.x0 = stream->readUint32LE();
+ actor.y0 = stream->readUint32LE();
+ actor.grResId = stream->readUint32LE();
+ actor.field_C = stream->readUint32LE();
+ actor.frameNum = stream->readUint32LE();
+ actor.frameCount = stream->readUint32LE();
+ actor.x1 = stream->readUint32LE();
+ actor.y1 = stream->readUint32LE();
+ actor.x2 = stream->readUint32LE();
+ actor.y2 = stream->readUint32LE();
+
+ actor.boundingRect.left = stream->readUint32LE() & 0xFFFF;
+ actor.boundingRect.top = stream->readUint32LE() & 0xFFFF;
actor.boundingRect.right = stream->readUint32LE() & 0xFFFF;
actor.boundingRect.bottom = stream->readUint32LE() & 0xFFFF;
- actor.direction = stream->readUint32LE();
- actor.field_3C = stream->readUint32LE();
- actor.field_40 = stream->readUint32LE();
- actor.field_44 = stream->readUint32LE();
- actor.field_48 = stream->readUint32LE();
- actor.flags = stream->readUint32LE();
- actor.field_50 = stream->readUint32LE();
- actor.field_54 = stream->readUint32LE();
- actor.field_58 = stream->readUint32LE();
- actor.field_5C = stream->readUint32LE();
- actor.field_60 = stream->readUint32LE();
- actor.actionIdx3 = stream->readUint32LE();
-
- // TODO skip field_68 till field_617
- stream->skip(0x5B0);
-
- for(i=0; i < 8; i++) {
- actor.reaction[i] = stream->readUint32LE();
- }
-
- actor.field_638 = stream->readUint32LE();
- actor.field_63C = stream->readUint32LE();
- actor.field_640 = stream->readUint32LE();
- actor.field_644 = stream->readUint32LE();
- actor.field_648 = stream->readUint32LE();
- actor.field_64C = stream->readUint32LE();
- actor.field_650 = stream->readUint32LE();
-
- for(i=0; i < 55; i++) {
- actor.grResTable[i] = stream->readUint32LE();
- }
-
- stream->read(actor.name, sizeof(actor.name));
-
- for(i=0; i < 20; i++) {
- actor.field_830[i] = stream->readUint32LE();
- }
- for(i=0; i < 20; i++) {
- actor.field_880[i] = stream->readUint32LE();
- }
- for(i=0; i < 20; i++) {
- actor.field_8D0[i] = stream->readUint32LE();
- }
-
- actor.actionIdx2 = stream->readUint32LE();
- actor.field_924 = stream->readUint32LE();
- actor.tickValue1 = stream->readUint32LE();
- actor.field_92C = stream->readUint32LE();
- actor.flags2 = stream->readUint32LE();
- actor.field_934 = stream->readUint32LE();
- actor.field_938 = stream->readUint32LE();
- actor.soundResId = stream->readUint32LE();
-
- // TODO skip field_940 till field_978
- stream->skip(0x3C);
-
- actor.actionIdx1 = stream->readUint32LE();
-
- // TODO skip field_980 till field_9A0
- stream->skip(0x24);
-
- _worldStats->actors.push_back(actor);
- }
-
- // TODO Take this out, it shouldn't be here (TEST ONLY)
- stream->seek(0xA73B6);
- uint8 mainActorData[500];
- stream->read(mainActorData, 500);
- _mainActor = new MainActor(mainActorData);
-
- stream->seek(0xD6B5A); // where action items start
-
- // FIXME Figure out all the actions items
- for (uint32 a = 0; a < _worldStats->numActions; a++) {
- ActionItem action;
- memset(&action, 0, sizeof(ActionItem));
-
- stream->read(action.name,52);
- action.id = stream->readUint32LE();
- stream->skip(0x14);
- action.actionListIdx1 = stream->readUint32LE();
- action.actionListIdx2 = stream->readUint32LE();
- action.actionType = stream->readUint32LE();
- stream->skip(0x2C);
- action.polyIdx = stream->readUint32LE();
- stream->skip(0x08);
- action.soundResId = stream->readUint32LE();
- stream->skip(0x04);
- action.palCorrection = stream->readUint32LE();
- stream->skip(0x14);
- action.soundVolume = stream->readUint32LE();
-
- _worldStats->actions.push_back(action);
- }
+ actor.direction = stream->readUint32LE();
+ actor.field_3C = stream->readUint32LE();
+ actor.field_40 = stream->readUint32LE();
+ actor.field_44 = stream->readUint32LE();
+ actor.field_48 = stream->readUint32LE();
+ actor.flags = stream->readUint32LE();
+ actor.field_50 = stream->readUint32LE();
+ actor.field_54 = stream->readUint32LE();
+ actor.field_58 = stream->readUint32LE();
+ actor.field_5C = stream->readUint32LE();
+ actor.field_60 = stream->readUint32LE();
+ actor.actionIdx3 = stream->readUint32LE();
+
+ // TODO skip field_68 till field_617
+ stream->skip(0x5B0);
+
+ for (i = 0; i < 8; i++) {
+ actor.reaction[i] = stream->readUint32LE();
+ }
+
+ actor.field_638 = stream->readUint32LE();
+ actor.field_63C = stream->readUint32LE();
+ actor.field_640 = stream->readUint32LE();
+ actor.field_644 = stream->readUint32LE();
+ actor.field_648 = stream->readUint32LE();
+ actor.field_64C = stream->readUint32LE();
+ actor.field_650 = stream->readUint32LE();
+
+ for (i = 0; i < 55; i++) {
+ actor.grResTable[i] = stream->readUint32LE();
+ }
+
+ stream->read(actor.name, sizeof(actor.name));
+
+ for (i = 0; i < 20; i++) {
+ actor.field_830[i] = stream->readUint32LE();
+ }
+ for (i = 0; i < 20; i++) {
+ actor.field_880[i] = stream->readUint32LE();
+ }
+ for (i = 0; i < 20; i++) {
+ actor.field_8D0[i] = stream->readUint32LE();
+ }
+
+ actor.actionIdx2 = stream->readUint32LE();
+ actor.field_924 = stream->readUint32LE();
+ actor.tickValue1 = stream->readUint32LE();
+ actor.field_92C = stream->readUint32LE();
+ actor.flags2 = stream->readUint32LE();
+ actor.field_934 = stream->readUint32LE();
+ actor.field_938 = stream->readUint32LE();
+ actor.soundResId = stream->readUint32LE();
+
+ // TODO skip field_940 till field_978
+ stream->skip(0x3C);
+
+ actor.actionIdx1 = stream->readUint32LE();
+
+ // TODO skip field_980 till field_9A0
+ stream->skip(0x24);
+
+ _worldStats->actors.push_back(actor);
+ }
+
+ // TODO Take this out, it shouldn't be here (TEST ONLY)
+ stream->seek(0xA73B6);
+ uint8 mainActorData[500];
+ stream->read(mainActorData, 500);
+ _mainActor = new MainActor(mainActorData);
+
+ stream->seek(0xD6B5A); // where action items start
+
+ // FIXME Figure out all the actions items
+ for (uint32 a = 0; a < _worldStats->numActions; a++) {
+ ActionItem action;
+ memset(&action, 0, sizeof(ActionItem));
+
+ stream->read(action.name,52);
+ action.id = stream->readUint32LE();
+ stream->skip(0x14);
+ action.actionListIdx1 = stream->readUint32LE();
+ action.actionListIdx2 = stream->readUint32LE();
+ action.actionType = stream->readUint32LE();
+ stream->skip(0x2C);
+ action.polyIdx = stream->readUint32LE();
+ stream->skip(0x08);
+ action.soundResId = stream->readUint32LE();
+ stream->skip(0x04);
+ action.palCorrection = stream->readUint32LE();
+ stream->skip(0x14);
+ action.soundVolume = stream->readUint32LE();
+
+ _worldStats->actions.push_back(action);
+ }
}
void SceneResource::loadGamePolygons(Common::SeekableReadStream *stream) {
- _gamePolygons = new GamePolygons;
+ _gamePolygons = new GamePolygons;
- stream->seek(0xE8686); // jump to game Polygons data
+ stream->seek(0xE8686); // jump to game Polygons data
- _gamePolygons->size = stream->readUint32LE();
- _gamePolygons->numEntries = stream->readUint32LE();
+ _gamePolygons->size = stream->readUint32LE();
+ _gamePolygons->numEntries = stream->readUint32LE();
- for (uint32 g = 0; g < _gamePolygons->numEntries; g++) {
- PolyDefinitions poly;
- memset(&poly, 0, sizeof(PolyDefinitions));
+ for (uint32 g = 0; g < _gamePolygons->numEntries; g++) {
+ PolyDefinitions poly;
+ memset(&poly, 0, sizeof(PolyDefinitions));
- poly.numPoints = stream->readUint32LE();
- if (poly.numPoints > 0)
- poly.points = new Common::Point[poly.numPoints];
- for (uint32 i = 0; i < poly.numPoints; i++) {
+ poly.numPoints = stream->readUint32LE();
+ if (poly.numPoints > 0)
+ poly.points = new Common::Point[poly.numPoints];
+ for (uint32 i = 0; i < poly.numPoints; i++) {
poly.points[i].x = stream->readUint32LE() & 0xFFFF;
poly.points[i].y = stream->readUint32LE() & 0xFFFF;
}
- stream->skip((Polygons_MAXSIZE - poly.numPoints) * 8);
+ stream->skip((Polygons_MAXSIZE - poly.numPoints) * 8);
- poly.boundingRect.left = stream->readUint32LE() & 0xFFFF;
- poly.boundingRect.top = stream->readUint32LE() & 0xFFFF;
- poly.boundingRect.right = stream->readUint32LE() & 0xFFFF;
- poly.boundingRect.bottom = stream->readUint32LE() & 0xFFFF;
+ poly.boundingRect.left = stream->readUint32LE() & 0xFFFF;
+ poly.boundingRect.top = stream->readUint32LE() & 0xFFFF;
+ poly.boundingRect.right = stream->readUint32LE() & 0xFFFF;
+ poly.boundingRect.bottom = stream->readUint32LE() & 0xFFFF;
- _gamePolygons->polygons.push_back(poly);
- }
+ _gamePolygons->polygons.push_back(poly);
+ }
}
void SceneResource::loadActionList(Common::SeekableReadStream *stream) {
- _actionList = new ActionList;
-
- stream->seek(0xE868E + _gamePolygons->size * _gamePolygons->numEntries); // jump to action list data
-
- _actionList->size = stream->readUint32LE();
- _actionList->numEntries = stream->readUint32LE();
-
- for (uint32 a = 0; a < _actionList->numEntries; a++) {
- ActionDefinitions action;
- memset(&action, 0, sizeof(ActionDefinitions));
-
- for (uint32 c = 0; c < Commands_MAXSIZE; c++) {
- ActionCommand command;
- memset(&command, 0, sizeof(ActionCommand));
-
- command.numLines = stream->readUint32LE();
- command.opcode = stream->readUint32LE(); // command type
- command.param1 = stream->readUint32LE(); // command parameters
- command.param2 = stream->readUint32LE();
- command.param3 = stream->readUint32LE();
- command.param4 = stream->readUint32LE();
- command.param5 = stream->readUint32LE();
- command.param6 = stream->readUint32LE();
- command.param7 = stream->readUint32LE();
- command.param8 = stream->readUint32LE();
- command.param9 = stream->readUint32LE();
-
- action.commands[c] = command;
- }
-
- action.field_1BAC = stream->readUint32LE();
- action.field_1BB0 = stream->readUint32LE();
- action.counter = stream->readUint32LE();
-
- _actionList->actions.push_back(action);
- }
+ _actionList = new ActionList;
+
+ stream->seek(0xE868E + _gamePolygons->size * _gamePolygons->numEntries); // jump to action list data
+
+ _actionList->size = stream->readUint32LE();
+ _actionList->numEntries = stream->readUint32LE();
+
+ for (uint32 a = 0; a < _actionList->numEntries; a++) {
+ ActionDefinitions action;
+ memset(&action, 0, sizeof(ActionDefinitions));
+
+ for (uint32 c = 0; c < Commands_MAXSIZE; c++) {
+ ActionCommand command;
+ memset(&command, 0, sizeof(ActionCommand));
+
+ command.numLines = stream->readUint32LE();
+ command.opcode = stream->readUint32LE(); // command type
+ command.param1 = stream->readUint32LE(); // command parameters
+ command.param2 = stream->readUint32LE();
+ command.param3 = stream->readUint32LE();
+ command.param4 = stream->readUint32LE();
+ command.param5 = stream->readUint32LE();
+ command.param6 = stream->readUint32LE();
+ command.param7 = stream->readUint32LE();
+ command.param8 = stream->readUint32LE();
+ command.param9 = stream->readUint32LE();
+
+ action.commands[c] = command;
+ }
+
+ action.field_1BAC = stream->readUint32LE();
+ action.field_1BB0 = stream->readUint32LE();
+ action.counter = stream->readUint32LE();
+
+ _actionList->actions.push_back(action);
+ }
}
Common::String SceneResource::parseFilename(uint8 sceneIdx) {
diff --git a/engines/asylum/sceneres.h b/engines/asylum/sceneres.h
index 5bf053d800..c0cdf27407 100644
--- a/engines/asylum/sceneres.h
+++ b/engines/asylum/sceneres.h
@@ -11,7 +11,7 @@
* 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
+ * 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
@@ -34,7 +34,7 @@
#include "asylum/screen.h"
#include "asylum/respack.h"
-#define SCENEMASK "scn.%03d"
+#define SCENEMASK "scn.%03d"
#define Polygons_MAXSIZE 200
#define Commands_MAXSIZE 161
@@ -49,12 +49,12 @@ class ActionList;
// TODO/FIXME: Are there REALLY any points which go beyond 32768???
// ScummVM common Point uses int16 and we need int32
typedef struct Point {
- int32 x, y;
+ int32 x, y;
} Point;
// ScummVM common Rect uses int16 and we need int32
typedef struct Rect {
- int32 top, left, bottom, right;
+ int32 top, left, bottom, right;
} Rect;
#endif
@@ -63,310 +63,310 @@ public:
SceneResource();
virtual ~SceneResource();
- bool load(uint8 sceneIdx);
+ bool load(uint8 sceneIdx);
- WorldStats* getWorldStats() { return _worldStats; }
- GamePolygons* getGamePolygons() { return _gamePolygons; }
- ActionList* getActionList() { return _actionList; }
- MainActor* getMainActor() { return _mainActor; }
-
- int getBarrierIndexById(uint32 id);
+ WorldStats* getWorldStats() { return _worldStats; }
+ GamePolygons* getGamePolygons() { return _gamePolygons; }
+ ActionList* getActionList() { return _actionList; }
+ MainActor* getMainActor() { return _mainActor; }
+
+ int getBarrierIndexById(uint32 id);
private:
- WorldStats *_worldStats;
- GamePolygons *_gamePolygons;
- ActionList *_actionList;
- MainActor *_mainActor;
+ WorldStats *_worldStats;
+ GamePolygons *_gamePolygons;
+ ActionList *_actionList;
+ MainActor *_mainActor;
- void loadWorldStats(Common::SeekableReadStream *stream);
- void loadGamePolygons(Common::SeekableReadStream *stream);
- void loadActionList(Common::SeekableReadStream *stream);
- Common::String parseFilename(uint8 sceneIdx);
+ void loadWorldStats(Common::SeekableReadStream *stream);
+ void loadGamePolygons(Common::SeekableReadStream *stream);
+ void loadActionList(Common::SeekableReadStream *stream);
+ Common::String parseFilename(uint8 sceneIdx);
}; // end of class Scene
typedef struct SoundItem {
- uint32 resId;
- uint32 field_4;
- uint32 field_8;
- uint32 field_C;
+ uint32 resId;
+ uint32 field_4;
+ uint32 field_8;
+ uint32 field_C;
} SoundItem;
typedef struct FrameSoundItem {
- uint32 resId;
- uint32 frameIdx;
- uint32 index;
- uint32 field_C;
- uint32 field_10;
- uint32 field_14;
+ uint32 resId;
+ uint32 frameIdx;
+ uint32 index;
+ uint32 field_C;
+ uint32 field_10;
+ uint32 field_14;
} FrameSoundItem;
typedef struct AmbientSoundItem {
- uint32 field_0;
- uint32 flags;
- uint32 resId;
- uint32 field_C;
- uint32 field_10;
- uint32 field_14;
- uint32 flagNum[6];
- uint32 x;
- uint32 y;
+ uint32 field_0;
+ uint32 flags;
+ uint32 resId;
+ uint32 field_C;
+ uint32 field_10;
+ uint32 field_14;
+ uint32 flagNum[6];
+ uint32 x;
+ uint32 y;
} AmbientSoundItem;
// FIXME figure out unknown fields
typedef struct BarrierItem {
- uint32 id;
- uint32 resId;
- uint32 x;
- uint32 y;
+ uint32 id;
+ uint32 resId;
+ uint32 x;
+ uint32 y;
Common::Rect boundingRect;
- uint32 field_20;
- uint32 frameIdx;
- uint32 frameCount;
- uint32 field_2C;
- uint32 field_30;
- uint32 field_34;
- uint32 flags;
- uint32 field_3C;
- uint8 name[52]; // field_40 till field_70;
- uint32 field_74;
- uint32 field_78;
- uint32 field_7C;
- uint32 field_80;
- uint32 polyIdx;
- uint32 flags2;
- uint32 gameFlags[10];
- uint32 field_B4;
- uint32 tickCount;
- uint32 tickCount2;
- uint32 field_C0;
- uint32 field_C4;
- uint32 actionListIdx;
- SoundItem soundItems[16];
- FrameSoundItem frameSoundItems[50];
- uint32 field_67C;
- uint32 soundX;
- uint32 soundY;
- uint32 field_688;
- uint32 field_68C[5];
- uint32 soundResId;
- uint32 field_6A4;
+ uint32 field_20;
+ uint32 frameIdx;
+ uint32 frameCount;
+ uint32 field_2C;
+ uint32 field_30;
+ uint32 field_34;
+ uint32 flags;
+ uint32 field_3C;
+ uint8 name[52]; // field_40 till field_70;
+ uint32 field_74;
+ uint32 field_78;
+ uint32 field_7C;
+ uint32 field_80;
+ uint32 polyIdx;
+ uint32 flags2;
+ uint32 gameFlags[10];
+ uint32 field_B4;
+ uint32 tickCount;
+ uint32 tickCount2;
+ uint32 field_C0;
+ uint32 field_C4;
+ uint32 actionListIdx;
+ SoundItem soundItems[16];
+ FrameSoundItem frameSoundItems[50];
+ uint32 field_67C;
+ uint32 soundX;
+ uint32 soundY;
+ uint32 field_688;
+ uint32 field_68C[5];
+ uint32 soundResId;
+ uint32 field_6A4;
} BarrierItem;
// FIXME add unknown fields
typedef struct ActionItem {
- char name[52];
- uint32 id;
- int32 actionListIdx1;
- int32 actionListIdx2;
- int32 actionType; // 0-none, 1-findwhat, 2-talk, 3-findwhat??, 4-grab
- int32 polyIdx;
- uint32 soundResId;
- uint32 palCorrection;
- int32 soundVolume;
+ char name[52];
+ uint32 id;
+ int32 actionListIdx1;
+ int32 actionListIdx2;
+ int32 actionType; // 0-none, 1-findwhat, 2-talk, 3-findwhat??, 4-grab
+ int32 polyIdx;
+ uint32 soundResId;
+ uint32 palCorrection;
+ int32 soundVolume;
} ActionItem;
typedef struct CommonResources {
- uint32 backgroundImage;
- uint32 curScrollUp;
- uint32 curScrollUpLeft;
- uint32 curScrollLeft;
- uint32 curScrollDownLeft;
- uint32 curScrollDown;
- uint32 curScrollDownRight;
- uint32 curScrollRight;
- uint32 curScrollUpRight;
- uint32 curHand;
- uint32 curMagnifyingGlass;
- uint32 curTalkNCP;
- uint32 curGrabPointer;
- uint32 curTalkNCP2;
- uint32 font1;
- uint32 font2;
- uint32 font3;
- uint32 palette;
- uint32 cellShadeMask1;
- uint32 cellShadeMask2;
- uint32 cellShadeMask3;
- uint32 unused;
- uint32 smallCurUp;
- uint32 smallCurDown;
- uint32 field_7C;
+ uint32 backgroundImage;
+ uint32 curScrollUp;
+ uint32 curScrollUpLeft;
+ uint32 curScrollLeft;
+ uint32 curScrollDownLeft;
+ uint32 curScrollDown;
+ uint32 curScrollDownRight;
+ uint32 curScrollRight;
+ uint32 curScrollUpRight;
+ uint32 curHand;
+ uint32 curMagnifyingGlass;
+ uint32 curTalkNCP;
+ uint32 curGrabPointer;
+ uint32 curTalkNCP2;
+ uint32 font1;
+ uint32 font2;
+ uint32 font3;
+ uint32 palette;
+ uint32 cellShadeMask1;
+ uint32 cellShadeMask2;
+ uint32 cellShadeMask3;
+ uint32 unused;
+ uint32 smallCurUp;
+ uint32 smallCurDown;
+ uint32 field_7C;
} CommonResources;
typedef struct ActorItem {
- uint32 x0;
- uint32 y0;
- uint32 grResId;
- uint32 field_C;
- uint32 frameNum;
- uint32 frameCount;
- uint32 x1;
- uint32 y1;
- uint32 x2;
- uint32 y2;
- Common::Rect boundingRect;
- uint32 direction;
- uint32 field_3C;
- uint32 field_40;
- uint32 field_44;
- uint32 field_48;
- uint32 flags;
- uint32 field_50;
- uint32 field_54;
- uint32 field_58;
- uint32 field_5C;
- uint32 field_60;
- uint32 actionIdx3;
- // TODO field_68 till field_617
- uint32 reaction[8];
- uint32 field_638;
- uint32 field_63C;
- uint32 field_640;
- uint32 field_644;
- uint32 field_648;
- uint32 field_64C;
- uint32 field_650;
- uint32 grResTable[55];
- char name[256];
- uint32 field_830[20];
- uint32 field_880[20];
- uint32 field_8D0[20];
- uint32 actionIdx2;
- uint32 field_924;
- uint32 tickValue1;
- uint32 field_92C;
- uint32 flags2;
- uint32 field_934;
- uint32 field_938;
- uint32 soundResId;
- // TODO field_940 till field_978
- uint32 actionIdx1;
- // TODO field_980 till field_9A0
+ uint32 x0;
+ uint32 y0;
+ uint32 grResId;
+ uint32 field_C;
+ uint32 frameNum;
+ uint32 frameCount;
+ uint32 x1;
+ uint32 y1;
+ uint32 x2;
+ uint32 y2;
+ Common::Rect boundingRect;
+ uint32 direction;
+ uint32 field_3C;
+ uint32 field_40;
+ uint32 field_44;
+ uint32 field_48;
+ uint32 flags;
+ uint32 field_50;
+ uint32 field_54;
+ uint32 field_58;
+ uint32 field_5C;
+ uint32 field_60;
+ uint32 actionIdx3;
+ // TODO field_68 till field_617
+ uint32 reaction[8];
+ uint32 field_638;
+ uint32 field_63C;
+ uint32 field_640;
+ uint32 field_644;
+ uint32 field_648;
+ uint32 field_64C;
+ uint32 field_650;
+ uint32 grResTable[55];
+ char name[256];
+ uint32 field_830[20];
+ uint32 field_880[20];
+ uint32 field_8D0[20];
+ uint32 actionIdx2;
+ uint32 field_924;
+ uint32 tickValue1;
+ uint32 field_92C;
+ uint32 flags2;
+ uint32 field_934;
+ uint32 field_938;
+ uint32 soundResId;
+ // TODO field_940 till field_978
+ uint32 actionIdx1;
+ // TODO field_980 till field_9A0
} ActorItem;
class WorldStats {
public:
- WorldStats() {};
- virtual ~WorldStats() {
- barriers.clear();
- actors.clear();
- actions.clear();
- };
-
- uint32 size;
- uint32 numEntries;
- uint32 numChapter;
- uint32 xLeft; // scene start x position
- uint32 yTop; // scene start y position
- Common::Rect boundingRect;
- CommonResources commonRes; // field_1C till field_7C
- uint32 width; // field_80
- uint32 height;
- uint32 field_88;
- uint32 field_8C;
- uint32 numActions; // field_90
- uint32 numBarriers;
- uint32 field_98;
- uint32 field_9C;
- uint32 field_A0;
- uint32 field_A4;
- uint32 field_A8;
- uint32 field_AC;
- uint32 field_B0;
- uint32 numActors; // Max and all other characters that have
- // own interactions
- uint32 stereoReversedFlag;
- Common::Rect sceneRects[6]; // including scene size rect
- uint8 sceneRectIdx;
- uint8 field_11D[3];
- uint32 field_120;
- uint32 actionListIdx; // actionList start index
- uint32 grResId[100];
- uint32 sceneTitleGrResId;
- uint32 sceneTitlePalResId;
- uint32 actorType;
- uint32 soundResId[50];
- AmbientSoundItem ambientSounds[15];
- uint32 numAmbientSound;
- uint32 musicStatus;
- uint32 musicCurrentResId;
- uint32 musicFlag;
- uint32 musicResId;
- uint32 musicStatusExt;
-
- // FIXME: Investigate if we need to actually reserve maxsize for this arrays.
- // It always have that size under scene file and they are always save in savegames.
- Common::Array<BarrierItem> barriers; // maxsize 400
- Common::Array<ActorItem> actors; // maxsize 50
- // TODO add rest fields
- Common::Array<ActionItem> actions; // maxsize 400
+ WorldStats() {};
+ virtual ~WorldStats() {
+ barriers.clear();
+ actors.clear();
+ actions.clear();
+ };
+
+ uint32 size;
+ uint32 numEntries;
+ uint32 numChapter;
+ uint32 xLeft; // scene start x position
+ uint32 yTop; // scene start y position
+ Common::Rect boundingRect;
+ CommonResources commonRes; // field_1C till field_7C
+ uint32 width; // field_80
+ uint32 height;
+ uint32 field_88;
+ uint32 field_8C;
+ uint32 numActions; // field_90
+ uint32 numBarriers;
+ uint32 field_98;
+ uint32 field_9C;
+ uint32 field_A0;
+ uint32 field_A4;
+ uint32 field_A8;
+ uint32 field_AC;
+ uint32 field_B0;
+ uint32 numActors; // Max and all other characters that have
+ // own interactions
+ uint32 stereoReversedFlag;
+ Common::Rect sceneRects[6]; // including scene size rect
+ uint8 sceneRectIdx;
+ uint8 field_11D[3];
+ uint32 field_120;
+ uint32 actionListIdx; // actionList start index
+ uint32 grResId[100];
+ uint32 sceneTitleGrResId;
+ uint32 sceneTitlePalResId;
+ uint32 actorType;
+ uint32 soundResId[50];
+ AmbientSoundItem ambientSounds[15];
+ uint32 numAmbientSound;
+ uint32 musicStatus;
+ uint32 musicCurrentResId;
+ uint32 musicFlag;
+ uint32 musicResId;
+ uint32 musicStatusExt;
+
+ // FIXME: Investigate if we need to actually reserve maxsize for this arrays.
+ // It always have that size under scene file and they are always save in savegames.
+ Common::Array<BarrierItem> barriers; // maxsize 400
+ Common::Array<ActorItem> actors; // maxsize 50
+ // TODO add rest fields
+ Common::Array<ActionItem> actions; // maxsize 400
}; // end of class WorldStats
typedef struct PolyDefinitions{
- uint32 numPoints;
- Common::Point *points; //[Polygons_MAXSIZE];
+ uint32 numPoints;
+ Common::Point *points; //[Polygons_MAXSIZE];
Common::Rect boundingRect;
} PolyDefinitions;
class GamePolygons {
public:
- GamePolygons() {};
- virtual ~GamePolygons() {
- polygons.clear();
- };
+ GamePolygons() {};
+ virtual ~GamePolygons() {
+ polygons.clear();
+ };
- uint32 size;
- uint32 numEntries;
+ uint32 size;
+ uint32 numEntries;
- Common::Array<PolyDefinitions> polygons;
+ Common::Array<PolyDefinitions> polygons;
}; // end of class GamePolygons
typedef struct ActionCommand {
- uint32 numLines; // Only set on the first line of each script
- uint32 opcode;
- uint32 param1;
- uint32 param2;
- uint32 param3;
- uint32 param4;
- uint32 param5;
- uint32 param6;
- uint32 param7;
- uint32 param8;
- uint32 param9;
+ uint32 numLines; // Only set on the first line of each script
+ uint32 opcode;
+ uint32 param1;
+ uint32 param2;
+ uint32 param3;
+ uint32 param4;
+ uint32 param5;
+ uint32 param6;
+ uint32 param7;
+ uint32 param8;
+ uint32 param9;
} ActionCommand;
typedef struct ActionDefinitions {
- ActionCommand commands[161];
- uint32 field_1BAC;
- uint32 field_1BB0;
- uint32 counter;
+ ActionCommand commands[161];
+ uint32 field_1BAC;
+ uint32 field_1BB0;
+ uint32 counter;
} ActionDefinitions;
class ActionList {
public:
- ActionList() {};
- virtual ~ActionList() {
- actions.clear();
- };
+ ActionList() {};
+ virtual ~ActionList() {
+ actions.clear();
+ };
- uint32 size;
- uint32 numEntries;
+ uint32 size;
+ uint32 numEntries;
- Common::Array<ActionDefinitions> actions;
+ Common::Array<ActionDefinitions> actions;
}; // end of class ActionList
diff --git a/engines/asylum/screen.cpp b/engines/asylum/screen.cpp
index a7de03d73d..a9408ed958 100644
--- a/engines/asylum/screen.cpp
+++ b/engines/asylum/screen.cpp
@@ -41,7 +41,7 @@ void Screen::copyBackBufferToScreen() {
void Screen::copyToBackBuffer(byte *buffer, int pitch, int x, int y, int width, int height) {
int h = height;
- int w = width;
+ int w = width;
byte *dest = (byte *)_backBuffer.pixels;
while (h--) {
@@ -53,7 +53,7 @@ void Screen::copyToBackBuffer(byte *buffer, int pitch, int x, int y, int width,
void Screen::copyToBackBufferWithTransparency(byte *buffer, int pitch, int x, int y, int width, int height) {
// int h = height;
- // int w = width;
+ // int w = width;
byte *dest = (byte *)_backBuffer.pixels;
for (int curY = 0; curY < height; curY++) {
diff --git a/engines/asylum/text.cpp b/engines/asylum/text.cpp
index a0f4b4bb1a..1bdb574346 100644
--- a/engines/asylum/text.cpp
+++ b/engines/asylum/text.cpp
@@ -11,7 +11,7 @@
* 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
+ * 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
@@ -29,9 +29,9 @@
namespace Asylum {
Text::Text(Screen *screen) : _screen(screen) {
- _posX = 0;
- _posY = 0;
- _curFontFlags = 0;
+ _posX = 0;
+ _posY = 0;
+ _curFontFlags = 0;
_fontResource = 0;
_textPack = new ResourcePack(0);
@@ -51,36 +51,36 @@ void Text::loadFont(ResourcePack *resPack, uint32 resId) {
_fontResource = new GraphicResource(resPack, resId);
- if (resId > 0) {
- // load font flag data
- _curFontFlags = (_fontResource->getFlags() >> 4) & 0x0F;
- }
+ if (resId > 0) {
+ // load font flag data
+ _curFontFlags = (_fontResource->getFlags() >> 4) & 0x0F;
+ }
}
-
+
void Text::setTextPos(uint32 x, uint32 y) {
- _posX = x;
- _posY = y;
+ _posX = x;
+ _posY = y;
}
// getTextWidth at address 004357C0
uint32 Text::getTextWidth(char *text) {
assert (_fontResource);
- int width = 0;
- uint8 character = *text;
- while (character) {
+ int width = 0;
+ uint8 character = *text;
+ while (character) {
GraphicFrame *font = _fontResource->getFrame(character);
- width += font->surface.w + font->x - _curFontFlags;
+ width += font->surface.w + font->x - _curFontFlags;
- text++;
- character = *text;
- }
- return width;
+ text++;
+ character = *text;
+ }
+ return width;
}
uint32 Text::getResTextWidth(uint32 resId) {
- ResourceEntry *textRes = _textPack->getResource(resId);
- return getTextWidth((char*)textRes->data);
+ ResourceEntry *textRes = _textPack->getResource(resId);
+ return getTextWidth((char*)textRes->data);
}
void Text::drawChar(char character) {
@@ -88,29 +88,29 @@ void Text::drawChar(char character) {
GraphicFrame *fontLetter = _fontResource->getFrame(character);
_screen->copyRectToScreenWithTransparency((byte *)fontLetter->surface.pixels, fontLetter->surface.w, _posX, _posY + fontLetter->y, fontLetter->surface.w, fontLetter->surface.h);
- _posX += fontLetter->surface.w + fontLetter->x - _curFontFlags;
+ _posX += fontLetter->surface.w + fontLetter->x - _curFontFlags;
}
void Text::drawText(char *text) {
- while (*text) {
- drawChar(*text);
- text++;
- }
+ while (*text) {
+ drawChar(*text);
+ text++;
+ }
}
void Text::drawResText(uint32 resId) {
- ResourceEntry *textRes = _textPack->getResource(resId);
- drawText((char*)textRes->data);
+ ResourceEntry *textRes = _textPack->getResource(resId);
+ drawText((char*)textRes->data);
}
void Text::drawTextCentered(uint32 x, uint32 y, uint32 width, char *text) {
- int textWidth = getTextWidth(text);
- setTextPos(x + (width - textWidth) / 2, y);
- drawText(text);
+ int textWidth = getTextWidth(text);
+ setTextPos(x + (width - textWidth) / 2, y);
+ drawText(text);
}
void Text::drawResTextWithValueCentered(uint32 x, uint32 y, uint32 width, uint32 resId, uint32 value) {
- ResourceEntry *textRes = _textPack->getResource(resId);
+ ResourceEntry *textRes = _textPack->getResource(resId);
char *text = (char *)textRes->data;
char txt[100];
sprintf(txt, text, value);
@@ -118,14 +118,14 @@ void Text::drawResTextWithValueCentered(uint32 x, uint32 y, uint32 width, uint32
}
void Text::drawResTextCentered(uint32 x, uint32 y, uint32 width, uint32 resId) {
- ResourceEntry *textRes = _textPack->getResource(resId);
- drawTextCentered(x, y, width, (char *)textRes->data);
+ ResourceEntry *textRes = _textPack->getResource(resId);
+ drawTextCentered(x, y, width, (char *)textRes->data);
}
void Text::drawText(uint32 x, uint32 y, char *text) {
- int textWidth = getTextWidth(text);
- setTextPos(x - textWidth, y);
- drawText(text);
+ int textWidth = getTextWidth(text);
+ setTextPos(x - textWidth, y);
+ drawText(text);
}
void Text::drawResText(uint32 x, uint32 y, uint32 resId) {
@@ -134,13 +134,13 @@ void Text::drawResText(uint32 x, uint32 y, uint32 resId) {
}
void Text::drawTextAlignRight(uint32 x, uint32 y, char *text) {
- int textWidth = getTextWidth(text);
- setTextPos(x - textWidth, y);
- drawText(text);
+ int textWidth = getTextWidth(text);
+ setTextPos(x - textWidth, y);
+ drawText(text);
}
void Text::drawResTextAlignRight(uint32 x, uint32 y, uint32 resId) {
- ResourceEntry *textRes = _textPack->getResource(resId);
+ ResourceEntry *textRes = _textPack->getResource(resId);
drawTextAlignRight(x, y, (char *)textRes->data);
}
diff --git a/engines/asylum/text.h b/engines/asylum/text.h
index 156e146092..c5750093ac 100644
--- a/engines/asylum/text.h
+++ b/engines/asylum/text.h
@@ -11,7 +11,7 @@
* 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
+ * 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
@@ -38,33 +38,33 @@ public:
Text(Screen *screen);
~Text();
- void loadFont(ResourcePack *resPack, uint32 resId);
+ void loadFont(ResourcePack *resPack, uint32 resId);
- void setTextPos(uint32 x, uint32 y);
- uint32 getTextWidth(char *text);
- uint32 getResTextWidth(uint32 resId);
+ void setTextPos(uint32 x, uint32 y);
+ uint32 getTextWidth(char *text);
+ uint32 getResTextWidth(uint32 resId);
- void drawChar(char character);
- void drawText(char *text);
+ void drawChar(char character);
+ void drawText(char *text);
void drawText(uint32 x, uint32 y, char *text);
void drawResText(uint32 resId);
void drawResText(uint32 x, uint32 y, uint32 resId);
- void drawTextCentered(uint32 x, uint32 y, uint32 width, char *text);
- void drawResTextCentered(uint32 x, uint32 y, uint32 width, uint32 resId);
+ void drawTextCentered(uint32 x, uint32 y, uint32 width, char *text);
+ void drawResTextCentered(uint32 x, uint32 y, uint32 width, uint32 resId);
void drawResTextWithValueCentered(uint32 x, uint32 y, uint32 width, uint32 resId, uint32 value);
- void drawTextAlignRight(uint32 x, uint32 y, char *text);
- void drawResTextAlignRight(uint32 x, uint32 y, uint32 resId);
+ void drawTextAlignRight(uint32 x, uint32 y, char *text);
+ void drawResTextAlignRight(uint32 x, uint32 y, uint32 resId);
private:
- Screen *_screen;
+ Screen *_screen;
GraphicResource *_fontResource;
- ResourcePack *_textPack;
+ ResourcePack *_textPack;
uint32 _posX;
- uint32 _posY;
- uint8 _curFontFlags;
+ uint32 _posY;
+ uint8 _curFontFlags;
}; // end of class Text
diff --git a/engines/asylum/video.cpp b/engines/asylum/video.cpp
index 17837deaed..7f54ad72eb 100644
--- a/engines/asylum/video.cpp
+++ b/engines/asylum/video.cpp
@@ -11,7 +11,7 @@
* 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
+ * 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
@@ -59,11 +59,11 @@ bool VideoPlayer::playVideoWithSubtitles(Common::List<Common::Event> &stopEvents
// -1 means that the video has no subtitles, -2 that it doesn't exist
// The negative values aren't used in the code, they just make the table easier to
// understand.
- int textRes[49] = { -1, 1088, 1279, 1122, 1286, 1132, 1133, 1134, 1135, 1136, // 0 - 9
- -1, -2, 1140, 1141, -2, -1, 1142, -1, -2, 1155, // 10 - 19
- 1157, 1159, 1162, 1164, -2, 1171, 1177, 1184, 1190, 1201, // 20 - 29
- -2, -2, -2, 1207, 1213, 1217, 1223, 1227, -2, 1228, // 30 - 39
- -2, 1244, 1247, 1250, 1256, 1120, 1127, -1, -1}; // 40 - 48
+ int textRes[49] = { -1, 1088, 1279, 1122, 1286, 1132, 1133, 1134, 1135, 1136, // 0 - 9
+ -1, -2, 1140, 1141, -2, -1, 1142, -1, -2, 1155, // 10 - 19
+ 1157, 1159, 1162, 1164, -2, 1171, 1177, 1184, 1190, 1201, // 20 - 29
+ -2, -2, -2, 1207, 1213, 1217, 1223, 1227, -2, 1228, // 30 - 39
+ -2, 1244, 1247, 1250, 1256, 1120, 1127, -1, -1}; // 40 - 48
if (start) {
start += 20; // skip token, newline and "CAPTION = "
@@ -120,8 +120,8 @@ Video::Video(Audio::Mixer *mixer) {
stopEvent.kbd = Common::KEYCODE_ESCAPE;
_stopEvents.push_back(stopEvent);
- _smkDecoder = new Graphics::SmackerDecoder(mixer);
- _player = new VideoPlayer(_smkDecoder);
+ _smkDecoder = new Graphics::SmackerDecoder(mixer);
+ _player = new VideoPlayer(_smkDecoder);
}
Video::~Video() {
@@ -149,7 +149,7 @@ bool Video::playVideo(int number, VideoSubtitles subtitles) {
}
VideoText::VideoText() {
- _curFontFlags = 0;
+ _curFontFlags = 0;
_fontResource = 0;
_textPack = new ResourcePack(0);
@@ -165,10 +165,10 @@ void VideoText::loadFont(ResourcePack *resPack, uint32 resId) {
_fontResource = new GraphicResource(resPack, resId);
- if (resId > 0) {
- // load font flag data
- _curFontFlags = (_fontResource->getFlags() >> 4) & 0x0F;
- }
+ if (resId > 0) {
+ // load font flag data
+ _curFontFlags = (_fontResource->getFlags() >> 4) & 0x0F;
+ }
}
void VideoText::drawMovieSubtitle(byte *screenBuffer, uint32 resId) {
@@ -212,17 +212,17 @@ void VideoText::drawMovieSubtitle(byte *screenBuffer, uint32 resId) {
uint32 VideoText::getTextWidth(const char *text) {
assert (_fontResource);
- int width = 0;
- uint8 character = *text;
+ int width = 0;
+ uint8 character = *text;
const char *curChar = text;
- while (character) {
+ while (character) {
GraphicFrame *font = _fontResource->getFrame(character);
- width += font->surface.w + font->x - _curFontFlags;
+ width += font->surface.w + font->x - _curFontFlags;
- curChar++;
- character = *curChar;
- }
- return width;
+ curChar++;
+ character = *curChar;
+ }
+ return width;
}
void VideoText::drawText(byte *screenBuffer, int x, int y, const char *text) {
@@ -230,17 +230,17 @@ void VideoText::drawText(byte *screenBuffer, int x, int y, const char *text) {
const char *curChar = text;
int curX = x;
- while (*curChar) {
+ while (*curChar) {
GraphicFrame *fontLetter = _fontResource->getFrame(*curChar);
copyToVideoFrame(screenBuffer, fontLetter, curX, y + fontLetter->y);
curX += fontLetter->surface.w + fontLetter->x - _curFontFlags;
- curChar++;
- }
+ curChar++;
+ }
}
void VideoText::copyToVideoFrame(byte *screenBuffer, GraphicFrame *frame, int x, int y) {
int h = frame->surface.h;
- int w = frame->surface.w;
+ int w = frame->surface.w;
int screenBufferPitch = 640;
byte *buffer = (byte *)frame->surface.pixels;
byte *dest = screenBuffer + y * screenBufferPitch + x;
diff --git a/engines/asylum/video.h b/engines/asylum/video.h
index 1dac8e9be8..8d5e52c40e 100644
--- a/engines/asylum/video.h
+++ b/engines/asylum/video.h
@@ -11,7 +11,7 @@
* 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
+ * 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
@@ -63,7 +63,7 @@ public:
private:
void performPostProcessing(byte *screen);
- VideoText *_text;
+ VideoText *_text;
Common::Array<VideoSubtitle> _subtitles;
};
@@ -76,7 +76,7 @@ public:
private:
Common::List<Common::Event> _stopEvents;
- Graphics::SmackerDecoder *_smkDecoder;
+ Graphics::SmackerDecoder *_smkDecoder;
VideoPlayer *_player;
}; // end of class Video
@@ -89,18 +89,18 @@ public:
VideoText();
~VideoText();
- void loadFont(ResourcePack *resPack, uint32 resId);
+ void loadFont(ResourcePack *resPack, uint32 resId);
void drawMovieSubtitle(byte *screenBuffer, uint32 resId);
private:
- uint32 getTextWidth(const char *text);
+ uint32 getTextWidth(const char *text);
- void drawText(byte *screenBuffer, int x, int y, const char *text);
+ void drawText(byte *screenBuffer, int x, int y, const char *text);
void copyToVideoFrame(byte *screenBuffer, GraphicFrame *frame, int x, int y);
GraphicResource *_fontResource;
- ResourcePack *_textPack;
- uint8 _curFontFlags;
+ ResourcePack *_textPack;
+ uint8 _curFontFlags;
}; // end of class VideoText
Commit: f46276e7d14aaa8c1151afe3a696d376d54d099a
https://github.com/scummvm/scummvm/commit/f46276e7d14aaa8c1151afe3a696d376d54d099a
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-05-17T15:35:32+02:00
Commit Message:
ASYLUM: Format last switch() statement. They all were indented in a wrong way.
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@237 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/scene.cpp
diff --git a/engines/asylum/scene.cpp b/engines/asylum/scene.cpp
index afe129febf..457df4919e 100644
--- a/engines/asylum/scene.cpp
+++ b/engines/asylum/scene.cpp
@@ -261,30 +261,30 @@ void Scene::update() {
// Change cursor
switch (mainActor->getCurrentAction()) {
- case kWalkN:
- newCursor = worldStats->commonRes.curScrollUp;
- break;
- case kWalkNE:
- newCursor = worldStats->commonRes.curScrollUpRight;
- break;
- case kWalkNW:
- newCursor = worldStats->commonRes.curScrollUpLeft;
- break;
- case kWalkS:
- newCursor = worldStats->commonRes.curScrollDown;
- break;
- case kWalkSE:
- newCursor = worldStats->commonRes.curScrollDownRight;
- break;
- case kWalkSW:
- newCursor = worldStats->commonRes.curScrollDownLeft;
- break;
- case kWalkW:
- newCursor = worldStats->commonRes.curScrollLeft;
- break;
- case kWalkE:
- newCursor = worldStats->commonRes.curScrollRight;
- break;
+ case kWalkN:
+ newCursor = worldStats->commonRes.curScrollUp;
+ break;
+ case kWalkNE:
+ newCursor = worldStats->commonRes.curScrollUpRight;
+ break;
+ case kWalkNW:
+ newCursor = worldStats->commonRes.curScrollUpLeft;
+ break;
+ case kWalkS:
+ newCursor = worldStats->commonRes.curScrollDown;
+ break;
+ case kWalkSE:
+ newCursor = worldStats->commonRes.curScrollDownRight;
+ break;
+ case kWalkSW:
+ newCursor = worldStats->commonRes.curScrollDownLeft;
+ break;
+ case kWalkW:
+ newCursor = worldStats->commonRes.curScrollLeft;
+ break;
+ case kWalkE:
+ newCursor = worldStats->commonRes.curScrollRight;
+ break;
}
if (_cursorResource->getEntryNum() != newCursor) {
Commit: 6380032d48141d00a2567d3a7f054d775dd81931
https://github.com/scummvm/scummvm/commit/6380032d48141d00a2567d3a7f054d775dd81931
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-05-17T15:35:32+02:00
Commit Message:
ASYLUM: Turn printf() into respective debug() or warning(). Printf is not portable
enough for our purposes.
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@238 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/scene.cpp
engines/asylum/sceneres.cpp
diff --git a/engines/asylum/scene.cpp b/engines/asylum/scene.cpp
index 457df4919e..236902d735 100644
--- a/engines/asylum/scene.cpp
+++ b/engines/asylum/scene.cpp
@@ -314,7 +314,7 @@ void Scene::update() {
if (curHotspot >= 0) {
for (uint32 a = 0; a < worldStats->numActions; a++) {
if (worldStats->actions[a].polyIdx == curHotspot) {
- printf("Hotspot: 0x%X - \"%s\", poly %d, action lists %d/%d, action type %d, sound res %d\n",
+ debug(0, "Hotspot: 0x%X - \"%s\", poly %d, action lists %d/%d, action type %d, sound res %d\n",
worldStats->actions[a].id,
worldStats->actions[a].name,
worldStats->actions[a].polyIdx,
diff --git a/engines/asylum/sceneres.cpp b/engines/asylum/sceneres.cpp
index 3d93901b6a..393ee09204 100644
--- a/engines/asylum/sceneres.cpp
+++ b/engines/asylum/sceneres.cpp
@@ -54,21 +54,21 @@ bool SceneResource::load(uint8 sceneIdx) {
Common::String filename = parseFilename(sceneIdx);
if (!fd->exists(filename)) {
- printf("Scene file doesn't exist %s", filename.c_str());
+ warning("Scene file doesn't exist %s", filename.c_str());
return false;
}
fd->open(filename);
if (!fd->isOpen()) {
- printf("Failed to load scene file %s", filename.c_str());
+ warning("Failed to load scene file %s", filename.c_str());
return false;
}
fd->read(sceneTag,6);
if (Common::String(sceneTag,6) != "DFISCN") {
- printf("The file isn't recognized as scene %s", filename.c_str());
+ warning("The file isn't recognized as scene %s", filename.c_str());
return false;
}
Commit: f43b5843c8358b239cd78c369f07e81ecea3eb52
https://github.com/scummvm/scummvm/commit/f43b5843c8358b239cd78c369f07e81ecea3eb52
Author: Alex Bevilacqua (alexbevi at gmail.com)
Date: 2021-05-17T15:35:32+02:00
Commit Message:
ASYLUM: Since the game polygons list doesn't cover ALL interactive regions (hotspots), I added a method to draw active barriers as well. Though these have a polyIdx property, it's always zero, so I'm going based off the bounding box.
Also added a variable to the console to manage this, and renamed debugpolygons to "showpolygons"
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@239 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/console.cpp
engines/asylum/scene.cpp
engines/asylum/scene.h
diff --git a/engines/asylum/console.cpp b/engines/asylum/console.cpp
index 210ecf24f3..947140dbe0 100644
--- a/engines/asylum/console.cpp
+++ b/engines/asylum/console.cpp
@@ -32,6 +32,7 @@
namespace Asylum {
extern int g_debugPolygons;
+extern int g_debugBarriers;
Console::Console(AsylumEngine *vm) : GUI::Debugger() {
_vm = vm;
@@ -39,8 +40,9 @@ Console::Console(AsylumEngine *vm) : GUI::Debugger() {
DCmd_Register("video", WRAP_METHOD(Console, cmdPlayVideo));
DCmd_Register("script", WRAP_METHOD(Console, cmdRunScript));
DCmd_Register("scene", WRAP_METHOD(Console, cmdChangeScene));
- DVar_Register("debugpolygons", &g_debugPolygons, DVAR_INT, 0);
+ DVar_Register("showpolygons", &g_debugPolygons, DVAR_INT, 0);
+ DVar_Register("showbarriers", &g_debugBarriers, DVAR_INT, 0);
}
Console::~Console() {
diff --git a/engines/asylum/scene.cpp b/engines/asylum/scene.cpp
index 236902d735..54fc1d3477 100644
--- a/engines/asylum/scene.cpp
+++ b/engines/asylum/scene.cpp
@@ -32,13 +32,15 @@ namespace Asylum {
#define SCROLL_STEP 10
int g_debugPolygons;
+int g_debugBarriers;
Scene::Scene(Screen *screen, Sound *sound, uint8 sceneIdx): _screen(screen), _sound(sound) {
- _sceneIdx = sceneIdx;
- _sceneResource = new SceneResource;
+ _sceneIdx = sceneIdx;
+ _sceneResource = new SceneResource;
+
if (_sceneResource->load(_sceneIdx)) {
- _text = new Text(_screen);
- _resPack = new ResourcePack(sceneIdx);
+ _text = new Text(_screen);
+ _resPack = new ResourcePack(sceneIdx);
_speechPack = new ResourcePack(3);
_sceneResource->getMainActor()->setResourcePack(_resPack);
@@ -47,19 +49,21 @@ Scene::Scene(Screen *screen, Sound *sound, uint8 sceneIdx): _screen(screen), _so
char musPackFileName[10];
sprintf(musPackFileName, "mus.%03d", sceneIdx);
- _musPack = new ResourcePack(musPackFileName);
-
+ _musPack = new ResourcePack(musPackFileName);
_bgResource = new GraphicResource(_resPack, _sceneResource->getWorldStats()->commonRes.backgroundImage);
}
_cursorResource = new GraphicResource(_resPack, _sceneResource->getWorldStats()->commonRes.curMagnifyingGlass);
- _background = 0;
- _startX = _startY = 0;
- _leftClick = false;
+ _background = 0;
+ _startX = 0;
+ _startY = 0;
+ _leftClick = false;
_rightButton = false;
- _isActive = false;
+ _isActive = false;
+
g_debugPolygons = 0;
+ g_debugBarriers = 0;
}
Scene::~Scene() {
@@ -78,8 +82,8 @@ void Scene::enterScene() {
_background = _bgResource->getFrame(0);
_screen->copyToBackBuffer(((byte *)_background->surface.pixels) + _startY * _background->surface.w + _startX, _background->surface.w, 0, 0, 640, 480);
- _cursorStep = 1;
- _curMouseCursor = 0;
+ _cursorStep = 1;
+ _curMouseCursor = 0;
_screen->setCursor(_cursorResource, 0);
_screen->showCursor();
@@ -94,17 +98,15 @@ void Scene::enterScene() {
}
int Scene::getDefaultActionIndex() {
- if (_sceneResource) {
+ if (_sceneResource)
return _sceneResource->getWorldStats()->actionListIdx;
- }
else
return -1;
}
ActionDefinitions * Scene::getActionList(int actionListIndex) {
- if ((actionListIndex >= 0) && (actionListIndex < (int)_sceneResource->getWorldStats()->numActions)) {
+ if ((actionListIndex >= 0) && (actionListIndex < (int)_sceneResource->getWorldStats()->numActions))
return &_sceneResource->getActionList()->actions[actionListIndex];
- }
else
return 0;
}
@@ -141,8 +143,7 @@ void Scene::actorVisible(int actorIndex, bool visible) {
else
_sceneResource->getWorldStats()->actors[actorIndex].flags &= 0xFFFFFFFE;
}
-
-
+
// FIXME - Remove this once mainActor uses proper actor info
if (actorIndex == 0) {
//if(_sceneResource->getMainActor())
@@ -151,9 +152,8 @@ void Scene::actorVisible(int actorIndex, bool visible) {
}
bool Scene::actorVisible(int actorIndex) {
- if ((actorIndex >= 0) && (actorIndex < (int)_sceneResource->getWorldStats()->numActors)) {
+ if ((actorIndex >= 0) && (actorIndex < (int)_sceneResource->getWorldStats()->numActors))
return _sceneResource->getWorldStats()->actors[actorIndex].flags & 0x01; // TODO - enums for flags (0x01 is visible)
- }
// FIXME - Remove this once mainActor uses proper actor info
if (actorIndex == 0) {
@@ -178,7 +178,7 @@ void Scene::handleEvent(Common::Event *event, bool doUpdate) {
case Common::EVENT_RBUTTONUP:
delete _cursorResource;
_cursorResource = new GraphicResource(_resPack, _sceneResource->getWorldStats()->commonRes.curMagnifyingGlass);
- _rightButton = false;
+ _rightButton = false;
break;
case Common::EVENT_RBUTTONDOWN:
_rightButton = true;
@@ -201,9 +201,10 @@ void Scene::updateCursor() {
void Scene::update() {
//bool scrollScreen = false;
- GraphicFrame *bg = _bgResource->getFrame(0);
- MainActor *mainActor = _sceneResource->getMainActor();
- WorldStats *worldStats = _sceneResource->getWorldStats();
+ GraphicFrame *bg = _bgResource->getFrame(0);
+ MainActor *mainActor = _sceneResource->getMainActor();
+ WorldStats *worldStats = _sceneResource->getWorldStats();
+
int32 curHotspot = -1;
// Horizontal scrolling
@@ -245,9 +246,8 @@ void Scene::update() {
//updateBarrier(_screen, _resPack, 9); // going down the ladder
updateBarrier(_screen, _resPack, 59); // Wobbly Guy
*/
- // TODO
-
- // TESTING
+
+ // TESTING
// Main actor walking
if (!_rightButton) {
//mainActor->setAction(15); // face south
@@ -295,6 +295,8 @@ void Scene::update() {
if (g_debugPolygons)
ShowPolygons();
+ if (g_debugBarriers)
+ ShowBarriers();
// Update cursor if it's in a hotspot
for (uint32 p = 0; p < _sceneResource->getGamePolygons()->numEntries; p++) {
@@ -348,11 +350,11 @@ void Scene::copyToSceneBackground(GraphicFrame *frame, int x, int y) {
int h = frame->surface.h;
int w = frame->surface.w;
byte *buffer = (byte *)frame->surface.pixels;
- byte *dest = ((byte *)_background->surface.pixels) + y * _background->surface.w + x;
+ byte *dest = ((byte *)_background->surface.pixels) + y * _background->surface.w + x;
while (h--) {
memcpy(dest, buffer, w);
- dest += _background->surface.w;
+ dest += _background->surface.w;
buffer += frame->surface.w;
}
}
@@ -387,10 +389,11 @@ void Scene::copyToBackBufferClipped(Graphics::Surface *surface, int x, int y) {
}
void Scene::updateBarrier(Screen *screen, ResourcePack *res, uint8 barrierIndex) {
- BarrierItem barrier = _sceneResource->getWorldStats()->barriers[barrierIndex];
+ BarrierItem barrier = _sceneResource->getWorldStats()->barriers[barrierIndex];
GraphicResource *gra = new GraphicResource(res, barrier.resId);
if (!gra->getFrameCount())
return;
+
GraphicFrame *fra = gra->getFrame(barrier.tickCount);
#if 0
@@ -464,4 +467,21 @@ void Scene::ShowPolygons() {
}
}
+// BARRIER DEBUGGING
+void Scene::ShowBarriers() {
+ for (uint32 p = 0; p < _sceneResource->getWorldStats()->numBarriers; p++) {
+ Graphics::Surface surface;
+ BarrierItem b = _sceneResource->getWorldStats()->barriers[p];
+
+ if (b.flags & 0x20) {
+ surface.create(b.boundingRect.right - b.boundingRect.left + 1, b.boundingRect.bottom - b.boundingRect.top + 1, 1);
+ surface.frameRect(b.boundingRect, 0x22);
+ copyToBackBufferClipped(&surface, b.x, b.y);
+ }
+
+ surface.free();
+ }
+}
+
+
} // end of namespace Asylum
diff --git a/engines/asylum/scene.h b/engines/asylum/scene.h
index 208b1559b3..abec3ee707 100644
--- a/engines/asylum/scene.h
+++ b/engines/asylum/scene.h
@@ -100,6 +100,7 @@ private:
void updateBarrier(Screen *screen, ResourcePack *res, uint8 actorIndex);
void ShowPolygons();
+ void ShowBarriers();
bool pointInPoly(PolyDefinitions *poly, int x, int y);
friend class Interpreter;
Commit: 3cfa2cbb4ccbe6081d0530e2e31e31bb49e42426
https://github.com/scummvm/scummvm/commit/3cfa2cbb4ccbe6081d0530e2e31e31bb49e42426
Author: Alex Bevilacqua (alexbevi at gmail.com)
Date: 2021-05-17T15:35:32+02:00
Commit Message:
ASYLUM: Reworked the interpreter into a singleton ScriptManager. This will allow scripts to be run without needing access to an engine variable, and will allow us to remove some of the scene processing hacks.
Scripts are now being run on click events. This is pretty buggy, but it's to be expected at this point :)
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@240 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
A engines/asylum/scriptman.cpp
A engines/asylum/scriptman.h
R engines/asylum/interpreter.cpp
R engines/asylum/interpreter.h
engines/asylum/asylum.cpp
engines/asylum/asylum.h
engines/asylum/console.cpp
engines/asylum/module.mk
engines/asylum/scene.cpp
engines/asylum/scene.h
diff --git a/engines/asylum/asylum.cpp b/engines/asylum/asylum.cpp
index c109bc3a1f..4ec4852f3c 100644
--- a/engines/asylum/asylum.cpp
+++ b/engines/asylum/asylum.cpp
@@ -80,11 +80,8 @@ Common::Error AsylumEngine::init() {
_sound = new Sound(_mixer);
_video = new Video(_mixer);
_console = new Console(this);
- _interpreter = 0;
_mainMenu = 0;
_scene = 0;
- _delayedVideoNumber = -1;
- _delayedSceneNumber = -1;
return Common::kNoError;
}
@@ -105,9 +102,14 @@ Common::Error AsylumEngine::go() {
// Set up the game's main scene
_scene = new Scene(_screen, _sound, 5);
-
- // Set up the game's script interpreter
- _interpreter = new Interpreter(this);
+
+ // TODO Since the ScriptMan is a singleton, setScene assignments could
+ // probably be rolled into the Scene constructor :D
+ ScriptMan.setScene(_scene);
+
+ // TODO This can probably also be rolled into the scene constructor.
+ // Investigate if this will fuck up the execution sequence though :P
+ ScriptMan.setScript(_scene->getActionList(_scene->getDefaultActionIndex()));
// Set up main menu
_mainMenu = new MainMenu(_screen, _sound, _scene);
@@ -131,7 +133,7 @@ void AsylumEngine::waitForTimer(int msec_delay) {
checkForDelayedVideo();
checkForDelayedSceneChange();
_system->updateScreen();
- _interpreter->processActionLists();
+ ScriptMan.processActionList();
}
}
@@ -180,11 +182,12 @@ void AsylumEngine::checkForEvent(bool doUpdate) {
}
void AsylumEngine::checkForDelayedVideo() {
- if (_delayedVideoNumber >= 0) {
+ int videoIdx = ScriptMan.getDelayedVideoIndex();
+ if (videoIdx >= 0) {
_sound->stopMusic();
_sound->stopSfx();
- _video->playVideo(_delayedVideoNumber, kSubtitlesOn);
- _delayedVideoNumber = -1;
+ _video->playVideo(videoIdx, kSubtitlesOn);
+ ScriptMan.setDelayedVideoIndex(-1);
if (_mainMenu->isActive()) {
_mainMenu->openMenu();
@@ -196,18 +199,20 @@ void AsylumEngine::checkForDelayedVideo() {
void AsylumEngine::checkForDelayedSceneChange() {
- if (_delayedSceneNumber >= 0 && !_interpreter->isProcessing()) {
+ int sceneIdx = ScriptMan.getDelayedSceneIndex();
+ if (sceneIdx >=0 && !ScriptMan.isProcessing()) {
_sound->stopMusic();
_sound->stopSfx();
if (_scene)
delete _scene;
- _scene = new Scene(_screen, _sound, _delayedSceneNumber);
- _interpreter->doSceneChanged();
+ _scene = new Scene(_screen, _sound, sceneIdx);
+
+ ScriptMan.setScene(_scene);
_scene->enterScene();
- _delayedSceneNumber = -1;
+ ScriptMan.setDelayedSceneIndex(-1);
}
}
diff --git a/engines/asylum/asylum.h b/engines/asylum/asylum.h
index f055c42317..5e638b851e 100644
--- a/engines/asylum/asylum.h
+++ b/engines/asylum/asylum.h
@@ -34,7 +34,7 @@
#include "asylum/screen.h"
#include "asylum/sound.h"
#include "asylum/video.h"
-#include "asylum/interpreter.h"
+#include "asylum/scriptman.h"
namespace Asylum {
@@ -45,7 +45,6 @@ class Scene;
class Screen;
class Sound;
class Video;
-class Interpreter;
enum kDebugLevels {
kDebugLevelMain = 1 << 0,
@@ -86,12 +85,8 @@ private:
Screen *_screen;
Sound *_sound;
Video *_video;
- Interpreter *_interpreter;
- int _delayedVideoNumber;
- int _delayedSceneNumber;
friend class Console;
- friend class Interpreter;
};
} // namespace Asylum
diff --git a/engines/asylum/console.cpp b/engines/asylum/console.cpp
index 947140dbe0..b608d039ef 100644
--- a/engines/asylum/console.cpp
+++ b/engines/asylum/console.cpp
@@ -54,7 +54,7 @@ bool Console::cmdPlayVideo(int argc, const char **argv) {
return true;
}
- _vm->_delayedVideoNumber = atoi(argv[1]);
+ ScriptMan.setDelayedVideoIndex(atoi(argv[1]));
return false;
}
@@ -65,8 +65,10 @@ bool Console::cmdRunScript(int argc, const char **argv) {
return true;
}
+ /*
_vm->_interpreter->_currentScriptIndex = atoi(argv[1]);
_vm->_interpreter->_currentLine = 0;
+ */
return false;
}
@@ -77,7 +79,7 @@ bool Console::cmdChangeScene(int argc, const char **argv) {
return true;
}
- _vm->_delayedSceneNumber = atoi(argv[1]);
+ ScriptMan.setDelayedSceneIndex(atoi(argv[1]));
return false;
}
diff --git a/engines/asylum/module.mk b/engines/asylum/module.mk
index 81a67061a7..be315b6792 100644
--- a/engines/asylum/module.mk
+++ b/engines/asylum/module.mk
@@ -15,7 +15,7 @@ MODULE_OBJS := \
video.o \
actor.o \
encounters.o \
- interpreter.o
+ scriptman.o
# This module can be built as a plugin
ifeq ($(ENABLE_ASYLUM), DYNAMIC_PLUGIN)
diff --git a/engines/asylum/scene.cpp b/engines/asylum/scene.cpp
index 54fc1d3477..5c9d53207e 100644
--- a/engines/asylum/scene.cpp
+++ b/engines/asylum/scene.cpp
@@ -206,6 +206,7 @@ void Scene::update() {
WorldStats *worldStats = _sceneResource->getWorldStats();
int32 curHotspot = -1;
+ int32 curBarrier = -1;
// Horizontal scrolling
if (_mouseX < SCREEN_EDGES && _startX >= SCROLL_STEP) {
@@ -233,19 +234,6 @@ void Scene::update() {
if ((_sceneResource->getWorldStats()->barriers[b].flags & 0x20) != 0) // TODO - enums for flags (0x20 is visible/playing?)
updateBarrier(_screen, _resPack, b);
}
- /*
- updateBarrier(_screen, _resPack, 0); // the "statue with fireworks" animation
- //updateBarrier(_screen, _resPack, 1); // inside the middle room
- //updateBarrier(_screen, _resPack, 2); // the lit candles at the base of the statue
- updateBarrier(_screen, _resPack, 3); // the rat animation (in front of the statue)
- updateBarrier(_screen, _resPack, 4); // inside the bottom room
- updateBarrier(_screen, _resPack, 6); // inside the top room (should be shown before the rat animation)
- updateBarrier(_screen, _resPack, 5); // the rat animation (outside the second room)
- updateBarrier(_screen, _resPack, 7); // the "crazy prisoner banging head" animation
- //updateBarrier(_screen, _resPack, 8); // going up the ladder
- //updateBarrier(_screen, _resPack, 9); // going down the ladder
- updateBarrier(_screen, _resPack, 59); // Wobbly Guy
- */
// TESTING
// Main actor walking
@@ -295,10 +283,10 @@ void Scene::update() {
if (g_debugPolygons)
ShowPolygons();
- if (g_debugBarriers)
+ //if (g_debugBarriers)
ShowBarriers();
- // Update cursor if it's in a hotspot
+ // Update cursor if it's in a polygon hotspot
for (uint32 p = 0; p < _sceneResource->getGamePolygons()->numEntries; p++) {
PolyDefinitions poly = _sceneResource->getGamePolygons()->polygons[p];
if (poly.boundingRect.contains(_mouseX + _startX, _mouseY + _startY)) {
@@ -310,6 +298,19 @@ void Scene::update() {
}
}
+ // Check if we're within a barrier
+ for (uint32 p = 0; p < worldStats->numBarriers; p++) {
+ BarrierItem b = worldStats->barriers[p];
+ if (b.flags & 0x20) {
+ if ((b.boundingRect.left + b.x <= _mouseX + _startX) && (_mouseX + _startX < b.boundingRect.right + b.x) && (b.boundingRect.top + b.y <= _mouseY + _startY) && (_mouseY + _startY < b.boundingRect.bottom + b.y)) {
+ updateCursor();
+ curBarrier = (int32)p;
+ break;
+ }
+
+ }
+ }
+
if (_leftClick) {
_leftClick = false;
@@ -324,10 +325,13 @@ void Scene::update() {
worldStats->actions[a].actionListIdx2,
worldStats->actions[a].actionType,
worldStats->actions[a].soundResId);
- // Play the SFX associated with the hotspot
- // TODO: The hotspot sound res id is 0, seems like we need to get it from the associated action list
- //_sound->playSfx(_resPack, worldStats->_actors[a].soundResId);
+ // TODO
+ // This isn't always loading the right audio resources when it processes
+ // the action list ... investigate
+ ScriptMan.setScript(&_sceneResource->getActionList()->actions[worldStats->actions[a].actionListIdx1]);
+
+ /*
// TODO: This should all be moved to a script related class
ActionDefinitions actionDefs = _sceneResource->getActionList()->actions[worldStats->actions[a].actionListIdx1];
for (int command = 0; command < 161; command++) {
@@ -338,11 +342,13 @@ void Scene::update() {
}
}
break;
+ */
}
}
+ } else if (curBarrier >= 0) {
+ ScriptMan.setScript(getActionList(worldStats->barriers[curBarrier].actionListIdx));
}
}
-
}
#if 0
diff --git a/engines/asylum/scene.h b/engines/asylum/scene.h
index abec3ee707..f8bff1ad10 100644
--- a/engines/asylum/scene.h
+++ b/engines/asylum/scene.h
@@ -103,7 +103,7 @@ private:
void ShowBarriers();
bool pointInPoly(PolyDefinitions *poly, int x, int y);
- friend class Interpreter;
+ friend class ScriptManager;
}; // end of class Scene
} // end of namespace Asylum
diff --git a/engines/asylum/interpreter.cpp b/engines/asylum/scriptman.cpp
similarity index 66%
rename from engines/asylum/interpreter.cpp
rename to engines/asylum/scriptman.cpp
index 5323d6443a..f837f92fa4 100644
--- a/engines/asylum/interpreter.cpp
+++ b/engines/asylum/scriptman.cpp
@@ -8,145 +8,152 @@
* 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
+ * 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.
*
* $URL$
* $Id$
- *
*/
-#include "asylum/interpreter.h"
-#include "asylum/sceneres.h"
+#include "asylum/scriptman.h"
-namespace Asylum {
+#include "common/system.h"
-Interpreter::Interpreter(AsylumEngine *vm): _engine(vm) {
- _currentLine = 0;
- _currentScriptIndex = 0;
- _currentLoops = 0;
- _processing = false;
- doSceneChanged();
-}
+DECLARE_SINGLETON(Asylum::ScriptManager);
-Interpreter::~Interpreter() {
-}
+namespace Asylum {
-void Interpreter::doSceneChanged() {
- _scene = _engine->_scene;
- _currentLine = 0;
- _currentScriptIndex = _scene->getDefaultActionIndex();
+static bool g_initialized = false;
+
+ScriptManager::ScriptManager() {
+ if (!g_initialized) {
+ g_initialized = true;
+ _currentLine = 0;
+ _currentLoops = 0;
+ _processing = false;
+ _delayedSceneIndex = -1;
+ _delayedVideoIndex = -1;
+ }
}
-void Interpreter::processActionLists() {
+void ScriptManager::processActionList() {
bool done = false, waitCycle = false;
int lineIncrement = 1;
+
_processing = true;
- if (_currentScriptIndex != -1) {
- ActionDefinitions *_currentScript = _scene->getActionList(_currentScriptIndex);
- if (!_currentScript)
- return;
-
+ if (_currentScript) {
while (!done && !waitCycle) {
lineIncrement = 1; // Reset line increment value
-
+
if (_currentLoops > 1000) {
// TODO - processActionLists has run too many interations
}
-
+
ActionCommand currentCommand = _currentScript->commands[_currentLine];
-
+
switch (currentCommand.opcode) {
+
case kReturn0:
- done = true;
+ done = true;
lineIncrement = 0;
break;
+
case kShowCursor:
_scene->_screen->showCursor();
// TODO - Enable click events
break;
+
case kHideCursor:
_scene->_screen->hideCursor();
// TODO - Disable click events
break;
+
case kPlayAnimation: {
int barrierIndex = _scene->_sceneResource->getBarrierIndexById(currentCommand.param1);
if (barrierIndex >= 0)
_scene->_sceneResource->getWorldStats()->barriers[barrierIndex].flags |= 0x20; // TODO - enums for flags (0x20 is visible/playing?)
else
- debugC(kDebugLevelScripts, "Requested invalid object ID:0x%02X in Scene %d Script %d Line %d.", currentCommand.param1, _scene->getSceneIndex(), _currentScriptIndex, _currentLine);
+ ; //debugC(kDebugLevelScripts, "Requested invalid object ID:0x%02X in Scene %d Script %d Line %d.", currentCommand.param1, _scene->getSceneIndex(), _currentScriptIndex, _currentLine);
}
break;
+
case kHideActor: {
uint32 actorIndex = 0;
if (currentCommand.param1 == -1)
;//actorIndex = _scene->getWorldStats()->playerActor;
else
actorIndex = currentCommand.param1;
-
+
if ((actorIndex >= 0) && (actorIndex < _scene->_sceneResource->getWorldStats()->numActors)) {
_scene->actorVisible(actorIndex, false);
}
else
- debugC(kDebugLevelScripts, "Requested invalid actor ID:0x%02X in Scene %d Script %d Line %d.", currentCommand.param1, _scene->getSceneIndex(), _currentScriptIndex, _currentLine);
+ ; //debugC(kDebugLevelScripts, "Requested invalid actor ID:0x%02X in Scene %d Script %d Line %d.", currentCommand.param1, _scene->getSceneIndex(), _currentScriptIndex, _currentLine);
}
break;
+
case kShowActor: {
uint32 actorIndex = 0;
if (currentCommand.param1 == -1)
;//actorIndex = _scene->getWorldStats()->playerActor;
else
actorIndex = currentCommand.param1;
-
+
if ((actorIndex >= 0) && (actorIndex < _scene->_sceneResource->getWorldStats()->numActors)) {
_scene->actorVisible(actorIndex, true);
}
else
- debugC(kDebugLevelScripts, "Requested invalid actor ID:0x%02X in Scene %d Script %d Line %d.", currentCommand.param1, _scene->getSceneIndex(), _currentScriptIndex, _currentLine);
+ ; //debugC(kDebugLevelScripts, "Requested invalid actor ID:0x%02X in Scene %d Script %d Line %d.", currentCommand.param1, _scene->getSceneIndex(), _currentScriptIndex, _currentLine);
}
break;
+
case kSetActorStats: {
uint32 actorIndex = 0;
if (currentCommand.param1 == -1)
;//actorIndex = _scene->getWorldStats()->playerActor;
else
actorIndex = currentCommand.param1;
-
+
if ((actorIndex >= 0) && (actorIndex < _scene->_sceneResource->getWorldStats()->numActors)) {
_scene->setActorPosition(actorIndex, currentCommand.param2, currentCommand.param3);
_scene->setActorAction(actorIndex, currentCommand.param4);
}
else
- debugC(kDebugLevelScripts, "Requested invalid actor ID:0x%02X in Scene %d Script %d Line %d.", currentCommand.param1, _scene->getSceneIndex(), _currentScriptIndex, _currentLine);
+ ; //debugC(kDebugLevelScripts, "Requested invalid actor ID:0x%02X in Scene %d Script %d Line %d.", currentCommand.param1, _scene->getSceneIndex(), _currentScriptIndex, _currentLine);
}
break;
+
case kReturn:
- done = true;
+ done = true;
lineIncrement = 0;
break;
+
case kDestroyObject: {
int barrierIndex = _scene->_sceneResource->getBarrierIndexById(currentCommand.param1);
if (barrierIndex >= 0)
_scene->_sceneResource->getWorldStats()->barriers[barrierIndex].flags &= 0xFFFFDF; // TODO - enums for flags (0x20 is visible/playing?)
else
- debugC(kDebugLevelScripts, "Requested invalid object ID:0x%02X in Scene %d Script %d Line %d.", currentCommand.param1, _scene->getSceneIndex(), _currentScriptIndex, _currentLine);
+ ; //debugC(kDebugLevelScripts, "Requested invalid object ID:0x%02X in Scene %d Script %d Line %d.", currentCommand.param1, _scene->getSceneIndex(), _currentScriptIndex, _currentLine);
}
break;
+
case kChangeScene:
- _engine->_delayedSceneNumber = currentCommand.param1 + 4;
+ _delayedSceneIndex = currentCommand.param1 + 4;
debug(kDebugLevelScripts, "Queueing Scene Change to scene %d...", currentCommand.param1 + 4);
break;
+
case kPlayMovie:
- _engine->_delayedVideoNumber = currentCommand.param1;
+ _delayedVideoIndex = currentCommand.param1;
break;
+
case kWaitUntilFramePlayed: {
int barrierIndex = _scene->_sceneResource->getBarrierIndexById(currentCommand.param1);
if (barrierIndex >= 0) {
@@ -161,37 +168,46 @@ void Interpreter::processActionLists() {
waitCycle = true;
}
} else {
- debugC(kDebugLevelScripts, "Requested invalid object ID:0x%02X in Scene %d Script %d Line %d.", currentCommand.param1, _scene->getSceneIndex(), _currentScriptIndex, _currentLine);
+ ; //debugC(kDebugLevelScripts, "Requested invalid object ID:0x%02X in Scene %d Script %d Line %d.", currentCommand.param1, _scene->getSceneIndex(), _currentScriptIndex, _currentLine);
}
break;
}
+
case kPlaySpeech:
// TODO - Add support for other param options
if (currentCommand.param1 >= 0) {
if (currentCommand.param3) // HACK - Find out why sometimes an offset is needed and other times not
_scene->_sound->playSfx(_scene->_speechPack, currentCommand.param1 - 9);
else
- _scene->_sound->playSfx(_scene->_speechPack, currentCommand.param1);
+ _scene->_sound->playSfx(_scene->_speechPack, currentCommand.param1);
} else
- debugC(kDebugLevelScripts, "Requested invalid sound ID:0x%02X in Scene %d Script %d Line %d.", currentCommand.param1, _scene->getSceneIndex(), _currentScriptIndex, _currentLine);
+ ; //debugC(kDebugLevelScripts, "Requested invalid sound ID:0x%02X in Scene %d Script %d Line %d.", currentCommand.param1, _scene->getSceneIndex(), _currentScriptIndex, _currentLine);
break;
+
default:
- debugC(kDebugLevelScripts, "Unhandled opcode 0x%02X in Scene %d Script %d Line %d.", currentCommand.opcode, _scene->getSceneIndex(), _currentScriptIndex, _currentLine);
+ ; //debugC(kDebugLevelScripts, "Unhandled opcode 0x%02X in Scene %d Script %d Line %d.", currentCommand.opcode, _scene->getSceneIndex(), _currentScriptIndex, _currentLine);
break;
+
} // end switch
-
+
_currentLine += lineIncrement;
_currentLoops++;
-
+
} // end while
if (done) {
- _currentLine = 0;
- _currentScriptIndex = 0;
- _currentLoops = 0;
+ _currentLine = 0;
+ _currentLoops = 0;
+ _currentScript = 0;
}
+
}
+
_processing = false;
}
+ScriptManager::~ScriptManager() {
+ // TODO Auto-generated destructor stub
+}
+
} // end of namespace Asylum
diff --git a/engines/asylum/interpreter.h b/engines/asylum/scriptman.h
similarity index 75%
rename from engines/asylum/interpreter.h
rename to engines/asylum/scriptman.h
index b6633d4507..76ad980ce7 100644
--- a/engines/asylum/interpreter.h
+++ b/engines/asylum/scriptman.h
@@ -8,48 +8,66 @@
* 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.
*
* $URL$
* $Id$
- *
*/
-#ifndef ASYLUM_INTERPERTER_H_
-#define ASYLUM_INTERPERTER_H_
+#ifndef ASYLUM_SCRIPTMANAGER_H_
+#define ASYLUM_SCRIPTMANAGER_H_
+
+#include "common/singleton.h"
#include "asylum/scene.h"
+#include "asylum/sceneres.h"
namespace Asylum {
+struct ActionCommand;
-class Interpreter {
+class ScriptManager: public Common::Singleton<ScriptManager> {
public:
- Interpreter(AsylumEngine *vm);
- ~Interpreter();
-
- void doSceneChanged();
- void processActionLists();
+
+ void processActionList();
+
+ void setScene(Scene *scene) { _scene = scene; }
+ void setScript(ActionDefinitions *action) { _currentScript = action; }
+
+ void setDelayedSceneIndex(int index) { _delayedSceneIndex = index; }
+ int getDelayedSceneIndex() { return _delayedSceneIndex; }
+
+ void setDelayedVideoIndex(int index) { _delayedVideoIndex = index; }
+ int getDelayedVideoIndex() { return _delayedVideoIndex; }
+
bool isProcessing() { return _processing; }
-
+
private:
- AsylumEngine *_engine;
- Scene *_scene;
- int _currentLine;
- int _currentScriptIndex;
- int _currentLoops;
+ friend class Common::Singleton<SingletonBaseType>;
+ ScriptManager();
+ ~ScriptManager();
+
+ int _currentLine;
+ int _currentLoops;
bool _processing;
-
+ int _delayedSceneIndex;
+ int _delayedVideoIndex;
+
+ Scene *_scene;
+ ActionDefinitions *_currentScript;
+
friend class Console;
-};
+
+
+}; // end of class ScriptManager
enum opcodes {
kReturn0 = 0x00,
@@ -153,6 +171,8 @@ enum opcodes {
k_unk62_SHOW_OPTIONS_SCREEN
};
+#define ScriptMan (::Asylum::ScriptManager::instance())
+
} // end of namespace Asylum
#endif
Commit: 16ea284ef61ee63b1dd099968ccfdc56e21d23db
https://github.com/scummvm/scummvm/commit/16ea284ef61ee63b1dd099968ccfdc56e21d23db
Author: Alex Bevilacqua (alexbevi at gmail.com)
Date: 2021-05-17T15:35:32+02:00
Commit Message:
ASYLUM: * re-enabled script debugging
* added kDebugScripts debugC calls back to processActionList()
* cleanup
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@242 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/console.cpp
engines/asylum/scene.cpp
engines/asylum/scriptman.cpp
engines/asylum/scriptman.h
diff --git a/engines/asylum/console.cpp b/engines/asylum/console.cpp
index b608d039ef..a86da3396f 100644
--- a/engines/asylum/console.cpp
+++ b/engines/asylum/console.cpp
@@ -65,10 +65,7 @@ bool Console::cmdRunScript(int argc, const char **argv) {
return true;
}
- /*
- _vm->_interpreter->_currentScriptIndex = atoi(argv[1]);
- _vm->_interpreter->_currentLine = 0;
- */
+ ScriptMan.setScriptIndex(atoi(argv[1]));
return false;
}
diff --git a/engines/asylum/scene.cpp b/engines/asylum/scene.cpp
index 5c9d53207e..f867d6faf8 100644
--- a/engines/asylum/scene.cpp
+++ b/engines/asylum/scene.cpp
@@ -90,10 +90,6 @@ void Scene::enterScene() {
// Music testing: play the first music track
_sound->playMusic(_musPack, 0);
- // TEST
- // Draw the actor facing south
- _sceneResource->getMainActor()->setAction(15);
- _sceneResource->getMainActor()->drawActorAt(_screen, 200, 200);
_isActive = true;
}
diff --git a/engines/asylum/scriptman.cpp b/engines/asylum/scriptman.cpp
index f837f92fa4..6f19db94d1 100644
--- a/engines/asylum/scriptman.cpp
+++ b/engines/asylum/scriptman.cpp
@@ -43,6 +43,11 @@ ScriptManager::ScriptManager() {
}
}
+void ScriptManager::setScriptIndex(uint32 index) {
+ _currentScript = _scene->getActionList(index);
+ _currentLine = 0;
+}
+
void ScriptManager::processActionList() {
bool done = false, waitCycle = false;
int lineIncrement = 1;
@@ -81,7 +86,7 @@ void ScriptManager::processActionList() {
if (barrierIndex >= 0)
_scene->_sceneResource->getWorldStats()->barriers[barrierIndex].flags |= 0x20; // TODO - enums for flags (0x20 is visible/playing?)
else
- ; //debugC(kDebugLevelScripts, "Requested invalid object ID:0x%02X in Scene %d Script %d Line %d.", currentCommand.param1, _scene->getSceneIndex(), _currentScriptIndex, _currentLine);
+ debugC(kDebugLevelScripts, "Requested invalid object ID:0x%02X in Scene %d Line %d.", currentCommand.param1, _scene->getSceneIndex(), _currentLine);
}
break;
@@ -96,7 +101,7 @@ void ScriptManager::processActionList() {
_scene->actorVisible(actorIndex, false);
}
else
- ; //debugC(kDebugLevelScripts, "Requested invalid actor ID:0x%02X in Scene %d Script %d Line %d.", currentCommand.param1, _scene->getSceneIndex(), _currentScriptIndex, _currentLine);
+ debugC(kDebugLevelScripts, "Requested invalid actor ID:0x%02X in Scene %d Line %d.", currentCommand.param1, _scene->getSceneIndex(), _currentLine);
}
break;
@@ -111,7 +116,7 @@ void ScriptManager::processActionList() {
_scene->actorVisible(actorIndex, true);
}
else
- ; //debugC(kDebugLevelScripts, "Requested invalid actor ID:0x%02X in Scene %d Script %d Line %d.", currentCommand.param1, _scene->getSceneIndex(), _currentScriptIndex, _currentLine);
+ debugC(kDebugLevelScripts, "Requested invalid actor ID:0x%02X in Scene %d Line %d.", currentCommand.param1, _scene->getSceneIndex(), _currentLine);
}
break;
@@ -127,7 +132,7 @@ void ScriptManager::processActionList() {
_scene->setActorAction(actorIndex, currentCommand.param4);
}
else
- ; //debugC(kDebugLevelScripts, "Requested invalid actor ID:0x%02X in Scene %d Script %d Line %d.", currentCommand.param1, _scene->getSceneIndex(), _currentScriptIndex, _currentLine);
+ debugC(kDebugLevelScripts, "Requested invalid actor ID:0x%02X in Scene %d Script %d Line %d.", currentCommand.param1, _scene->getSceneIndex(), _currentLine);
}
break;
@@ -141,7 +146,7 @@ void ScriptManager::processActionList() {
if (barrierIndex >= 0)
_scene->_sceneResource->getWorldStats()->barriers[barrierIndex].flags &= 0xFFFFDF; // TODO - enums for flags (0x20 is visible/playing?)
else
- ; //debugC(kDebugLevelScripts, "Requested invalid object ID:0x%02X in Scene %d Script %d Line %d.", currentCommand.param1, _scene->getSceneIndex(), _currentScriptIndex, _currentLine);
+ debugC(kDebugLevelScripts, "Requested invalid object ID:0x%02X in Scene %d Line %d.", currentCommand.param1, _scene->getSceneIndex(), _currentLine);
}
break;
@@ -168,7 +173,7 @@ void ScriptManager::processActionList() {
waitCycle = true;
}
} else {
- ; //debugC(kDebugLevelScripts, "Requested invalid object ID:0x%02X in Scene %d Script %d Line %d.", currentCommand.param1, _scene->getSceneIndex(), _currentScriptIndex, _currentLine);
+ debugC(kDebugLevelScripts, "Requested invalid object ID:0x%02X in Scene %d Line %d.", currentCommand.param1, _scene->getSceneIndex(), _currentLine);
}
break;
}
@@ -181,11 +186,11 @@ void ScriptManager::processActionList() {
else
_scene->_sound->playSfx(_scene->_speechPack, currentCommand.param1);
} else
- ; //debugC(kDebugLevelScripts, "Requested invalid sound ID:0x%02X in Scene %d Script %d Line %d.", currentCommand.param1, _scene->getSceneIndex(), _currentScriptIndex, _currentLine);
+ debugC(kDebugLevelScripts, "Requested invalid sound ID:0x%02X in Scene %d Line %d.", currentCommand.param1, _scene->getSceneIndex(), _currentLine);
break;
default:
- ; //debugC(kDebugLevelScripts, "Unhandled opcode 0x%02X in Scene %d Script %d Line %d.", currentCommand.opcode, _scene->getSceneIndex(), _currentScriptIndex, _currentLine);
+ debugC(kDebugLevelScripts, "Unhandled opcode 0x%02X in Scene %d Line %d.", currentCommand.opcode, _scene->getSceneIndex(), _currentLine);
break;
} // end switch
diff --git a/engines/asylum/scriptman.h b/engines/asylum/scriptman.h
index 76ad980ce7..644d8e3aaf 100644
--- a/engines/asylum/scriptman.h
+++ b/engines/asylum/scriptman.h
@@ -41,6 +41,7 @@ public:
void setScene(Scene *scene) { _scene = scene; }
void setScript(ActionDefinitions *action) { _currentScript = action; }
+ void setScriptIndex(uint32 index);
void setDelayedSceneIndex(int index) { _delayedSceneIndex = index; }
int getDelayedSceneIndex() { return _delayedSceneIndex; }
Commit: 0af5fd7f83aeefaf886fae5e4585a1aed7bb1cd3
https://github.com/scummvm/scummvm/commit/0af5fd7f83aeefaf886fae5e4585a1aed7bb1cd3
Author: Alex Bevilacqua (alexbevi at gmail.com)
Date: 2021-05-17T15:35:32+02:00
Commit Message:
ASYLUM: minor cleanup and debug output (sev, those printf's will be removed as soon as they've served their purpose ... scout's honour :D)
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@243 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/scene.cpp
engines/asylum/scriptman.cpp
engines/asylum/scriptman.h
diff --git a/engines/asylum/scene.cpp b/engines/asylum/scene.cpp
index f867d6faf8..9c0168059d 100644
--- a/engines/asylum/scene.cpp
+++ b/engines/asylum/scene.cpp
@@ -279,7 +279,7 @@ void Scene::update() {
if (g_debugPolygons)
ShowPolygons();
- //if (g_debugBarriers)
+ if (g_debugBarriers)
ShowBarriers();
// Update cursor if it's in a polygon hotspot
@@ -303,7 +303,6 @@ void Scene::update() {
curBarrier = (int32)p;
break;
}
-
}
}
@@ -313,7 +312,7 @@ void Scene::update() {
if (curHotspot >= 0) {
for (uint32 a = 0; a < worldStats->numActions; a++) {
if (worldStats->actions[a].polyIdx == curHotspot) {
- debug(0, "Hotspot: 0x%X - \"%s\", poly %d, action lists %d/%d, action type %d, sound res %d\n",
+ printf("Hotspot: 0x%X - \"%s\", poly %d, action lists %d/%d, action type %d, sound res %d\n",
worldStats->actions[a].id,
worldStats->actions[a].name,
worldStats->actions[a].polyIdx,
@@ -342,7 +341,14 @@ void Scene::update() {
}
}
} else if (curBarrier >= 0) {
- ScriptMan.setScript(getActionList(worldStats->barriers[curBarrier].actionListIdx));
+ BarrierItem b = worldStats->barriers[curBarrier];
+ printf("%s: action(%d) sound(%d) flags(%d/%d)\n",
+ b.name,
+ b.actionListIdx,
+ b.soundResId,
+ b.flags,
+ b.flags2);
+ ScriptMan.setScript(getActionList(b.actionListIdx));
}
}
}
@@ -443,7 +449,6 @@ bool Scene::pointInPoly(PolyDefinitions *poly, int x, int y) {
return inside_flag;
}
-
// POLYGONS DEBUG
void Scene::ShowPolygons() {
for (uint32 p = 0; p < _sceneResource->getGamePolygons()->numEntries; p++) {
@@ -485,5 +490,4 @@ void Scene::ShowBarriers() {
}
}
-
} // end of namespace Asylum
diff --git a/engines/asylum/scriptman.cpp b/engines/asylum/scriptman.cpp
index 6f19db94d1..99078fe546 100644
--- a/engines/asylum/scriptman.cpp
+++ b/engines/asylum/scriptman.cpp
@@ -43,9 +43,30 @@ ScriptManager::ScriptManager() {
}
}
+void ScriptManager::setScript(ActionDefinitions *action) {
+ _currentScript = action;
+
+ for (uint8 i = 0; i < _currentScript->commands[0].numLines; i++) {
+ printf("Line: %02d/%02d :: 0x%02X (%d, %d, %d, %d, %d, %d, %d, %d, %d)\n",
+ i,
+ _currentScript->commands[0].numLines - 1,
+ _currentScript->commands[i].opcode,
+ _currentScript->commands[i].param1,
+ _currentScript->commands[i].param2,
+ _currentScript->commands[i].param3,
+ _currentScript->commands[i].param4,
+ _currentScript->commands[i].param5,
+ _currentScript->commands[i].param6,
+ _currentScript->commands[i].param7,
+ _currentScript->commands[i].param8,
+ _currentScript->commands[i].param9);
+ }
+}
+
void ScriptManager::setScriptIndex(uint32 index) {
- _currentScript = _scene->getActionList(index);
- _currentLine = 0;
+ _currentScript = 0;
+ _currentLine = 0;
+ setScript(_scene->getActionList(index));
}
void ScriptManager::processActionList() {
@@ -71,6 +92,16 @@ void ScriptManager::processActionList() {
lineIncrement = 0;
break;
+ case kJumpIfGameFlag:
+ // TODO
+ // need to know the source object that owns the
+ // script we're parsing so that it's flags can
+ // be checked
+ // param1 = flag
+ // param2 = false command
+ // param3 = true command
+ break;
+
case kShowCursor:
_scene->_screen->showCursor();
// TODO - Enable click events
diff --git a/engines/asylum/scriptman.h b/engines/asylum/scriptman.h
index 644d8e3aaf..d6c9a16d04 100644
--- a/engines/asylum/scriptman.h
+++ b/engines/asylum/scriptman.h
@@ -40,7 +40,7 @@ public:
void processActionList();
void setScene(Scene *scene) { _scene = scene; }
- void setScript(ActionDefinitions *action) { _currentScript = action; }
+ void setScript(ActionDefinitions *action);
void setScriptIndex(uint32 index);
void setDelayedSceneIndex(int index) { _delayedSceneIndex = index; }
Commit: 44e189d2d9966a26c703dfd8252e3005124de0be
https://github.com/scummvm/scummvm/commit/44e189d2d9966a26c703dfd8252e3005124de0be
Author: Alex Bevilacqua (alexbevi at gmail.com)
Date: 2021-05-17T15:35:32+02:00
Commit Message:
ASYLUM: * printf -> debugC
* added bounds check to scene switch console command
* fixed crash when switching scenes
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@244 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/console.cpp
engines/asylum/scene.cpp
engines/asylum/scriptman.cpp
diff --git a/engines/asylum/console.cpp b/engines/asylum/console.cpp
index a86da3396f..ed9eb7781a 100644
--- a/engines/asylum/console.cpp
+++ b/engines/asylum/console.cpp
@@ -64,7 +64,7 @@ bool Console::cmdRunScript(int argc, const char **argv) {
DebugPrintf("Usage %s <script number>\n", argv[0]);
return true;
}
-
+
ScriptMan.setScriptIndex(atoi(argv[1]));
return false;
@@ -76,7 +76,13 @@ bool Console::cmdChangeScene(int argc, const char **argv) {
return true;
}
+ if (atoi(argv[1]) - 4 < 1 || atoi(argv[1]) - 4 >= 15) {
+ DebugPrintf("Attempt to SetupStartingInfo(%d); Invalid world\n", atoi(argv[1]));
+ return true;
+ }
+
ScriptMan.setDelayedSceneIndex(atoi(argv[1]));
+ ScriptMan.setScript(0);
return false;
}
diff --git a/engines/asylum/scene.cpp b/engines/asylum/scene.cpp
index 9c0168059d..d2550ffed6 100644
--- a/engines/asylum/scene.cpp
+++ b/engines/asylum/scene.cpp
@@ -312,7 +312,7 @@ void Scene::update() {
if (curHotspot >= 0) {
for (uint32 a = 0; a < worldStats->numActions; a++) {
if (worldStats->actions[a].polyIdx == curHotspot) {
- printf("Hotspot: 0x%X - \"%s\", poly %d, action lists %d/%d, action type %d, sound res %d\n",
+ debugC(kDebugLevelScripts, "Hotspot: 0x%X - \"%s\", poly %d, action lists %d/%d, action type %d, sound res %d\n",
worldStats->actions[a].id,
worldStats->actions[a].name,
worldStats->actions[a].polyIdx,
@@ -342,7 +342,7 @@ void Scene::update() {
}
} else if (curBarrier >= 0) {
BarrierItem b = worldStats->barriers[curBarrier];
- printf("%s: action(%d) sound(%d) flags(%d/%d)\n",
+ debugC(kDebugLevelScripts, "%s: action(%d) sound(%d) flags(%d/%d)\n",
b.name,
b.actionListIdx,
b.soundResId,
diff --git a/engines/asylum/scriptman.cpp b/engines/asylum/scriptman.cpp
index 99078fe546..3d53de3f0d 100644
--- a/engines/asylum/scriptman.cpp
+++ b/engines/asylum/scriptman.cpp
@@ -46,20 +46,23 @@ ScriptManager::ScriptManager() {
void ScriptManager::setScript(ActionDefinitions *action) {
_currentScript = action;
- for (uint8 i = 0; i < _currentScript->commands[0].numLines; i++) {
- printf("Line: %02d/%02d :: 0x%02X (%d, %d, %d, %d, %d, %d, %d, %d, %d)\n",
- i,
- _currentScript->commands[0].numLines - 1,
- _currentScript->commands[i].opcode,
- _currentScript->commands[i].param1,
- _currentScript->commands[i].param2,
- _currentScript->commands[i].param3,
- _currentScript->commands[i].param4,
- _currentScript->commands[i].param5,
- _currentScript->commands[i].param6,
- _currentScript->commands[i].param7,
- _currentScript->commands[i].param8,
- _currentScript->commands[i].param9);
+ if (_currentScript) {
+ for (uint8 i = 0; i < _currentScript->commands[0].numLines; i++) {
+ debugC(kDebugLevelScripts,
+ "Line: %02d/%02d :: 0x%02X (%d, %d, %d, %d, %d, %d, %d, %d, %d)\n",
+ i,
+ _currentScript->commands[0].numLines - 1,
+ _currentScript->commands[i].opcode,
+ _currentScript->commands[i].param1,
+ _currentScript->commands[i].param2,
+ _currentScript->commands[i].param3,
+ _currentScript->commands[i].param4,
+ _currentScript->commands[i].param5,
+ _currentScript->commands[i].param6,
+ _currentScript->commands[i].param7,
+ _currentScript->commands[i].param8,
+ _currentScript->commands[i].param9);
+ }
}
}
Commit: 4e2fe3e3a8557ae4433bfd8db8c4ad74fd40a5bb
https://github.com/scummvm/scummvm/commit/4e2fe3e3a8557ae4433bfd8db8c4ad74fd40a5bb
Author: Alex Bevilacqua (alexbevi at gmail.com)
Date: 2021-05-17T15:35:33+02:00
Commit Message:
ASYLUM: * clear debug channels on engine destruction
* cleanup
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@245 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/asylum.cpp
diff --git a/engines/asylum/asylum.cpp b/engines/asylum/asylum.cpp
index 4ec4852f3c..a14e209d31 100644
--- a/engines/asylum/asylum.cpp
+++ b/engines/asylum/asylum.cpp
@@ -53,7 +53,8 @@ AsylumEngine::AsylumEngine(OSystem *system, Common::Language language)
}
AsylumEngine::~AsylumEngine() {
- //Common::clearAllDebugChannels();
+ Common::clearAllDebugChannels();
+
delete _console;
delete _scene;
delete _mainMenu;
@@ -72,16 +73,14 @@ Common::Error AsylumEngine::run() {
// Will do the same as subroutine at address 0041A500
Common::Error AsylumEngine::init() {
- // initialize engine objects
-
initGraphics(640, 480, true);
- _screen = new Screen(_system);
- _sound = new Sound(_mixer);
- _video = new Video(_mixer);
- _console = new Console(this);
- _mainMenu = 0;
- _scene = 0;
+ _screen = new Screen(_system);
+ _sound = new Sound(_mixer);
+ _video = new Video(_mixer);
+ _console = new Console(this);
+ _mainMenu = 0;
+ _scene = 0;
return Common::kNoError;
}
Commit: 5939070342ee48ffdac2ed6aa8379397117c77a1
https://github.com/scummvm/scummvm/commit/5939070342ee48ffdac2ed6aa8379397117c77a1
Author: Alex Bevilacqua (alexbevi at gmail.com)
Date: 2021-05-17T15:35:33+02:00
Commit Message:
ASYLUM: rolled checks for delayed scene changes and video into processDelayedEvents()
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@246 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/asylum.cpp
engines/asylum/asylum.h
diff --git a/engines/asylum/asylum.cpp b/engines/asylum/asylum.cpp
index a14e209d31..fc8fbcf1df 100644
--- a/engines/asylum/asylum.cpp
+++ b/engines/asylum/asylum.cpp
@@ -129,8 +129,7 @@ void AsylumEngine::waitForTimer(int msec_delay) {
while (_system->getMillis() < start_time + msec_delay) {
checkForEvent(false);
- checkForDelayedVideo();
- checkForDelayedSceneChange();
+ processDelayedEvents();
_system->updateScreen();
ScriptMan.processActionList();
}
@@ -180,7 +179,8 @@ void AsylumEngine::checkForEvent(bool doUpdate) {
}
}
-void AsylumEngine::checkForDelayedVideo() {
+void AsylumEngine::processDelayedEvents() {
+ // check for a delayed video
int videoIdx = ScriptMan.getDelayedVideoIndex();
if (videoIdx >= 0) {
_sound->stopMusic();
@@ -194,10 +194,8 @@ void AsylumEngine::checkForDelayedVideo() {
_scene->enterScene();
}
}
-}
-
-void AsylumEngine::checkForDelayedSceneChange() {
+ // check for a delayed scene change
int sceneIdx = ScriptMan.getDelayedSceneIndex();
if (sceneIdx >=0 && !ScriptMan.isProcessing()) {
_sound->stopMusic();
diff --git a/engines/asylum/asylum.h b/engines/asylum/asylum.h
index 5e638b851e..e3927da760 100644
--- a/engines/asylum/asylum.h
+++ b/engines/asylum/asylum.h
@@ -73,8 +73,7 @@ private:
void checkForEvent(bool doUpdate);
void waitForTimer(int msec_delay);
void updateMouseCursor();
- void checkForDelayedVideo();
- void checkForDelayedSceneChange();
+ void processDelayedEvents();
Common::Language _language;
Common::RandomSource _rnd;
Commit: 5cbfdcd6954f2934f9f9aef07707055e8ddda6f0
https://github.com/scummvm/scummvm/commit/5cbfdcd6954f2934f9f9aef07707055e8ddda6f0
Author: Alex Bevilacqua (alexbevi at gmail.com)
Date: 2021-05-17T15:35:33+02:00
Commit Message:
ASYLUM: Started work on pathfinding. Currently I've disabled screen edge scrolling, and am drawing the active walk-able region's polygon
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@247 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/asylum.cpp
engines/asylum/scene.cpp
engines/asylum/scene.h
engines/asylum/scriptman.cpp
diff --git a/engines/asylum/asylum.cpp b/engines/asylum/asylum.cpp
index fc8fbcf1df..4ab84ae111 100644
--- a/engines/asylum/asylum.cpp
+++ b/engines/asylum/asylum.cpp
@@ -210,6 +210,7 @@ void AsylumEngine::processDelayedEvents() {
_scene->enterScene();
ScriptMan.setDelayedSceneIndex(-1);
+ ScriptMan.setScript(_scene->getActionList(_scene->getDefaultActionIndex()));
}
}
diff --git a/engines/asylum/scene.cpp b/engines/asylum/scene.cpp
index d2550ffed6..378f2f1b4b 100644
--- a/engines/asylum/scene.cpp
+++ b/engines/asylum/scene.cpp
@@ -204,6 +204,7 @@ void Scene::update() {
int32 curHotspot = -1;
int32 curBarrier = -1;
+ /*
// Horizontal scrolling
if (_mouseX < SCREEN_EDGES && _startX >= SCROLL_STEP) {
_startX -= SCROLL_STEP;
@@ -221,6 +222,7 @@ void Scene::update() {
_startY += SCROLL_STEP;
//scrollScreen = true;
}
+ */
// Copy the background to the back buffer before updating the scene animations
_screen->copyToBackBuffer(((byte *)bg->surface.pixels) + _startY * bg->surface.w + _startX, bg->surface.w, 0, 0, 640, 480);
@@ -306,6 +308,21 @@ void Scene::update() {
}
}
+ // DEBUGGING
+ // Check current walk region
+ for (uint32 a = 0; a < worldStats->numActions; a++) {
+ if (worldStats->actions[a].actionType == 0) {
+ PolyDefinitions poly = _sceneResource->getGamePolygons()->polygons[worldStats->actions[a].polyIdx];
+ if (pointInPoly(&poly, mainActor->_actorX, mainActor->_actorY)) {
+ ShowWalkRegion(&poly);
+ break;
+ }
+ }
+ }
+
+ // if
+ //ShowWalkRegion(15);
+
if (_leftClick) {
_leftClick = false;
@@ -449,6 +466,24 @@ bool Scene::pointInPoly(PolyDefinitions *poly, int x, int y) {
return inside_flag;
}
+void Scene::ShowWalkRegion(PolyDefinitions *poly) {
+ Graphics::Surface surface;
+ surface.create(poly->boundingRect.right - poly->boundingRect.left + 1, poly->boundingRect.bottom - poly->boundingRect.top + 1, 1);
+
+ // Draw all lines in Polygon
+ for (uint32 i=0; i < poly->numPoints; i++) {
+ surface.drawLine(
+ poly->points[i].x - poly->boundingRect.left,
+ poly->points[i].y - poly->boundingRect.top,
+ poly->points[(i+1) % poly->numPoints].x - poly->boundingRect.left,
+ poly->points[(i+1) % poly->numPoints].y - poly->boundingRect.top, 0x3A);
+ }
+
+ copyToBackBufferClipped(&surface, poly->boundingRect.left, poly->boundingRect.top);
+
+ surface.free();
+}
+
// POLYGONS DEBUG
void Scene::ShowPolygons() {
for (uint32 p = 0; p < _sceneResource->getGamePolygons()->numEntries; p++) {
diff --git a/engines/asylum/scene.h b/engines/asylum/scene.h
index f8bff1ad10..957915de1a 100644
--- a/engines/asylum/scene.h
+++ b/engines/asylum/scene.h
@@ -101,6 +101,7 @@ private:
void ShowPolygons();
void ShowBarriers();
+ void ShowWalkRegion(PolyDefinitions *poly);
bool pointInPoly(PolyDefinitions *poly, int x, int y);
friend class ScriptManager;
diff --git a/engines/asylum/scriptman.cpp b/engines/asylum/scriptman.cpp
index 3d53de3f0d..cd357234a7 100644
--- a/engines/asylum/scriptman.cpp
+++ b/engines/asylum/scriptman.cpp
@@ -215,7 +215,7 @@ void ScriptManager::processActionList() {
case kPlaySpeech:
// TODO - Add support for other param options
if (currentCommand.param1 >= 0) {
- if (currentCommand.param3) // HACK - Find out why sometimes an offset is needed and other times not
+ if (currentCommand.param3 && currentCommand.param1 > 0) // HACK - Find out why sometimes an offset is needed and other times not
_scene->_sound->playSfx(_scene->_speechPack, currentCommand.param1 - 9);
else
_scene->_sound->playSfx(_scene->_speechPack, currentCommand.param1);
Commit: d36733373b947b5b233d9cd6fe3d5b43ffa1ea8b
https://github.com/scummvm/scummvm/commit/d36733373b947b5b233d9cd6fe3d5b43ffa1ea8b
Author: Alex Bevilacqua (alexbevi at gmail.com)
Date: 2021-05-17T15:35:33+02:00
Commit Message:
ASYLUM: lock/unlock input event processing depending on whether the show/hide cursor action has been processed
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@249 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/scene.cpp
engines/asylum/scriptman.cpp
engines/asylum/scriptman.h
diff --git a/engines/asylum/scene.cpp b/engines/asylum/scene.cpp
index 378f2f1b4b..43fc113c85 100644
--- a/engines/asylum/scene.cpp
+++ b/engines/asylum/scene.cpp
@@ -164,20 +164,31 @@ void Scene::handleEvent(Common::Event *event, bool doUpdate) {
_ev = event;
switch (_ev->type) {
+
case Common::EVENT_MOUSEMOVE:
_mouseX = _ev->mouse.x;
_mouseY = _ev->mouse.y;
break;
+
case Common::EVENT_LBUTTONUP:
- _leftClick = true;
+ if (ScriptMan.isInputAllowed())
+ _leftClick = true;
break;
+
case Common::EVENT_RBUTTONUP:
- delete _cursorResource;
- _cursorResource = new GraphicResource(_resPack, _sceneResource->getWorldStats()->commonRes.curMagnifyingGlass);
- _rightButton = false;
+ if (ScriptMan.isInputAllowed()) {
+ delete _cursorResource;
+ // TODO This isn't always going to be the magnifying glass
+ // Should check the current pointer region to identify the type
+ // of cursor to use
+ _cursorResource = new GraphicResource(_resPack, _sceneResource->getWorldStats()->commonRes.curMagnifyingGlass);
+ _rightButton = false;
+ }
break;
+
case Common::EVENT_RBUTTONDOWN:
- _rightButton = true;
+ if (ScriptMan.isInputAllowed())
+ _rightButton = true;
break;
}
@@ -320,9 +331,6 @@ void Scene::update() {
}
}
- // if
- //ShowWalkRegion(15);
-
if (_leftClick) {
_leftClick = false;
diff --git a/engines/asylum/scriptman.cpp b/engines/asylum/scriptman.cpp
index cd357234a7..387e5ffdd9 100644
--- a/engines/asylum/scriptman.cpp
+++ b/engines/asylum/scriptman.cpp
@@ -107,12 +107,12 @@ void ScriptManager::processActionList() {
case kShowCursor:
_scene->_screen->showCursor();
- // TODO - Enable click events
+ _allowInput = true;
break;
case kHideCursor:
_scene->_screen->hideCursor();
- // TODO - Disable click events
+ _allowInput = false;
break;
case kPlayAnimation: {
diff --git a/engines/asylum/scriptman.h b/engines/asylum/scriptman.h
index d6c9a16d04..3533f5cf22 100644
--- a/engines/asylum/scriptman.h
+++ b/engines/asylum/scriptman.h
@@ -49,6 +49,7 @@ public:
void setDelayedVideoIndex(int index) { _delayedVideoIndex = index; }
int getDelayedVideoIndex() { return _delayedVideoIndex; }
+ bool isInputAllowed() { return _allowInput; }
bool isProcessing() { return _processing; }
private:
@@ -61,6 +62,7 @@ private:
bool _processing;
int _delayedSceneIndex;
int _delayedVideoIndex;
+ bool _allowInput;
Scene *_scene;
ActionDefinitions *_currentScript;
Commit: 476f1d207acfce524f405265465dc85107caa7c4
https://github.com/scummvm/scummvm/commit/476f1d207acfce524f405265465dc85107caa7c4
Author: Alex Bevilacqua (alexbevi at gmail.com)
Date: 2021-05-17T15:35:33+02:00
Commit Message:
ASYLUM: started working on game flags. Also implemented a couple unknown fields on the scene
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@250 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/scene.cpp
engines/asylum/sceneres.cpp
engines/asylum/sceneres.h
engines/asylum/scriptman.cpp
engines/asylum/scriptman.h
diff --git a/engines/asylum/scene.cpp b/engines/asylum/scene.cpp
index 43fc113c85..9e842d5dee 100644
--- a/engines/asylum/scene.cpp
+++ b/engines/asylum/scene.cpp
@@ -80,7 +80,9 @@ void Scene::enterScene() {
_screen->setPalette(_resPack, _sceneResource->getWorldStats()->commonRes.palette);
_background = _bgResource->getFrame(0);
- _screen->copyToBackBuffer(((byte *)_background->surface.pixels) + _startY * _background->surface.w + _startX, _background->surface.w, 0, 0, 640, 480);
+ _screen->copyToBackBuffer(
+ ((byte *)_background->surface.pixels) + _startY * _background->surface.w + _startX, _background->surface.w,
+ 0, 0, 640, 480);
_cursorStep = 1;
_curMouseCursor = 0;
@@ -295,18 +297,6 @@ void Scene::update() {
if (g_debugBarriers)
ShowBarriers();
- // Update cursor if it's in a polygon hotspot
- for (uint32 p = 0; p < _sceneResource->getGamePolygons()->numEntries; p++) {
- PolyDefinitions poly = _sceneResource->getGamePolygons()->polygons[p];
- if (poly.boundingRect.contains(_mouseX + _startX, _mouseY + _startY)) {
- if (pointInPoly(&poly, _mouseX + _startX, _mouseY + _startY)) {
- curHotspot = (int32)p;
- updateCursor();
- break;
- }
- }
- }
-
// Check if we're within a barrier
for (uint32 p = 0; p < worldStats->numBarriers; p++) {
BarrierItem b = worldStats->barriers[p];
@@ -319,6 +309,25 @@ void Scene::update() {
}
}
+ // FIXME? I'm assigning a higher priority to barriers than polygons. I'm assuming
+ // that barriers that overlap polygons will have actions associated with them, and
+ // the polygon will be part of a walk/look region (so it's accessible elsewhere).
+ // This could be completely wrong, and if so, we just have to check to see which
+ // of the barrier/polygon action scripts should be processed first
+ if (curBarrier < 0) {
+ // Update cursor if it's in a polygon hotspot
+ for (uint32 p = 0; p < _sceneResource->getGamePolygons()->numEntries; p++) {
+ PolyDefinitions poly = _sceneResource->getGamePolygons()->polygons[p];
+ if (poly.boundingRect.contains(_mouseX + _startX, _mouseY + _startY)) {
+ if (pointInPoly(&poly, _mouseX + _startX, _mouseY + _startY)) {
+ curHotspot = (int32)p;
+ updateCursor();
+ break;
+ }
+ }
+ }
+ }
+
// DEBUGGING
// Check current walk region
for (uint32 a = 0; a < worldStats->numActions; a++) {
@@ -402,7 +411,7 @@ void Scene::copyToBackBufferClipped(Graphics::Surface *surface, int x, int y) {
// Translate anim rectangle
animRect.translate(-_startX, -_startY);
- int startX = animRect.right == 640 ? 0 : surface->w - animRect.width();
+ int startX = animRect.right == 640 ? 0 : surface->w - animRect.width();
int startY = animRect.bottom == 480 ? 0 : surface->h - animRect.height();
if (surface->w > 640)
@@ -410,14 +419,15 @@ void Scene::copyToBackBufferClipped(Graphics::Surface *surface, int x, int y) {
if (surface->h > 480)
startY = _startY;
- _screen->copyToBackBufferWithTransparency(((byte*)surface->pixels) +
- startY * surface->pitch +
- startX * surface->bytesPerPixel,
- surface->pitch,
- animRect.left,
- animRect.top,
- animRect.width(),
- animRect.height());
+ _screen->copyToBackBufferWithTransparency(
+ ((byte*)surface->pixels) +
+ startY * surface->pitch +
+ startX * surface->bytesPerPixel,
+ surface->pitch,
+ animRect.left,
+ animRect.top,
+ animRect.width(),
+ animRect.height());
}
}
@@ -450,8 +460,8 @@ void Scene::updateBarrier(Screen *screen, ResourcePack *res, uint8 barrierIndex)
bool Scene::pointInPoly(PolyDefinitions *poly, int x, int y) {
// Copied from backends/vkeybd/polygon.cpp
- int yflag0;
- int yflag1;
+ int yflag0;
+ int yflag1;
bool inside_flag = false;
unsigned int pt;
@@ -468,12 +478,13 @@ bool Scene::pointInPoly(PolyDefinitions *poly, int x, int y) {
}
}
yflag0 = yflag1;
- vtx0 = vtx1;
+ vtx0 = vtx1;
}
return inside_flag;
}
+// WALK REGION DEBUG
void Scene::ShowWalkRegion(PolyDefinitions *poly) {
Graphics::Surface surface;
surface.create(poly->boundingRect.right - poly->boundingRect.left + 1, poly->boundingRect.bottom - poly->boundingRect.top + 1, 1);
diff --git a/engines/asylum/sceneres.cpp b/engines/asylum/sceneres.cpp
index 393ee09204..3160f5f421 100644
--- a/engines/asylum/sceneres.cpp
+++ b/engines/asylum/sceneres.cpp
@@ -122,7 +122,7 @@ void SceneResource::loadWorldStats(Common::SeekableReadStream *stream) {
_worldStats->commonRes.unused = stream->readUint32LE();
_worldStats->commonRes.smallCurUp = stream->readUint32LE();
_worldStats->commonRes.smallCurDown = stream->readUint32LE();
- _worldStats->commonRes.field_7C = stream->readUint32LE();
+ _worldStats->commonRes.encounterFrameBg = stream->readUint32LE();
_worldStats->width = stream->readUint32LE();
_worldStats->height = stream->readUint32LE();
@@ -306,13 +306,13 @@ void SceneResource::loadWorldStats(Common::SeekableReadStream *stream) {
actor.reaction[i] = stream->readUint32LE();
}
- actor.field_638 = stream->readUint32LE();
- actor.field_63C = stream->readUint32LE();
- actor.field_640 = stream->readUint32LE();
- actor.field_644 = stream->readUint32LE();
- actor.field_648 = stream->readUint32LE();
- actor.field_64C = stream->readUint32LE();
- actor.field_650 = stream->readUint32LE();
+ actor.field_638 = stream->readUint32LE();
+ actor.walkingSound1 = stream->readUint32LE();
+ actor.walkingSound2 = stream->readUint32LE();
+ actor.walkingSound3 = stream->readUint32LE();
+ actor.walkingSound4 = stream->readUint32LE();
+ actor.field_64C = stream->readUint32LE();
+ actor.field_650 = stream->readUint32LE();
for (i = 0; i < 55; i++) {
actor.grResTable[i] = stream->readUint32LE();
diff --git a/engines/asylum/sceneres.h b/engines/asylum/sceneres.h
index c0cdf27407..0b71c3c1d8 100644
--- a/engines/asylum/sceneres.h
+++ b/engines/asylum/sceneres.h
@@ -196,7 +196,7 @@ typedef struct CommonResources {
uint32 unused;
uint32 smallCurUp;
uint32 smallCurDown;
- uint32 field_7C;
+ uint32 encounterFrameBg;
} CommonResources;
@@ -228,10 +228,10 @@ typedef struct ActorItem {
// TODO field_68 till field_617
uint32 reaction[8];
uint32 field_638;
- uint32 field_63C;
- uint32 field_640;
- uint32 field_644;
- uint32 field_648;
+ uint32 walkingSound1;
+ uint32 walkingSound2;
+ uint32 walkingSound3;
+ uint32 walkingSound4;
uint32 field_64C;
uint32 field_650;
uint32 grResTable[55];
diff --git a/engines/asylum/scriptman.cpp b/engines/asylum/scriptman.cpp
index 387e5ffdd9..97a6f8881d 100644
--- a/engines/asylum/scriptman.cpp
+++ b/engines/asylum/scriptman.cpp
@@ -34,12 +34,16 @@ static bool g_initialized = false;
ScriptManager::ScriptManager() {
if (!g_initialized) {
- g_initialized = true;
- _currentLine = 0;
- _currentLoops = 0;
- _processing = false;
- _delayedSceneIndex = -1;
- _delayedVideoIndex = -1;
+ g_initialized = true;
+ _currentLine = 0;
+ _currentLoops = 0;
+ _processing = false;
+ _delayedSceneIndex = -1;
+ _delayedVideoIndex = -1;
+ _allowInput = true;
+ _currentTarget = kTargetNothing;
+ _currentTargetBarrier = 0;
+ _currentTargetAction = 0;
}
}
@@ -63,15 +67,33 @@ void ScriptManager::setScript(ActionDefinitions *action) {
_currentScript->commands[i].param8,
_currentScript->commands[i].param9);
}
+ } else {
+ _currentTarget = kTargetNothing;
}
}
+void ScriptManager::setScriptTarget(BarrierItem *barrier) {
+ _currentTarget = kTargetBarrier;
+ _currentTargetBarrier = barrier;
+ setScriptIndex(_currentTargetBarrier->actionListIdx);
+}
+void ScriptManager::setScriptTarget(ActionItem *action) {
+ _currentTarget = kTargetAction;
+ _currentTargetAction = action;
+ setScriptIndex(_currentTargetAction->actionListIdx1);
+}
+
+
void ScriptManager::setScriptIndex(uint32 index) {
_currentScript = 0;
_currentLine = 0;
setScript(_scene->getActionList(index));
}
+void ScriptManager::setGameFlag(int flag) {
+ _gameFlags[flag] &= ~(1 << flag);
+}
+
void ScriptManager::processActionList() {
bool done = false, waitCycle = false;
int lineIncrement = 1;
@@ -83,7 +105,7 @@ void ScriptManager::processActionList() {
lineIncrement = 1; // Reset line increment value
if (_currentLoops > 1000) {
- // TODO - processActionLists has run too many interations
+ // TODO - processActionLists has run too many iterations
}
ActionCommand currentCommand = _currentScript->commands[_currentLine];
@@ -105,6 +127,16 @@ void ScriptManager::processActionList() {
// param3 = true command
break;
+ case kSetGameFlag:
+ setGameFlag(currentCommand.param1);
+ break;
+
+ case kClearGameFlag: {
+ int flagNum = currentCommand.param1;
+ _gameFlags[flagNum] &= ~(1 << flagNum);
+ }
+ break;
+
case kShowCursor:
_scene->_screen->showCursor();
_allowInput = true;
diff --git a/engines/asylum/scriptman.h b/engines/asylum/scriptman.h
index 3533f5cf22..b26236bb74 100644
--- a/engines/asylum/scriptman.h
+++ b/engines/asylum/scriptman.h
@@ -33,6 +33,8 @@
namespace Asylum {
struct ActionCommand;
+struct ActionItem;
+struct BarrierItem;
class ScriptManager: public Common::Singleton<ScriptManager> {
public:
@@ -43,6 +45,9 @@ public:
void setScript(ActionDefinitions *action);
void setScriptIndex(uint32 index);
+ void setScriptTarget(BarrierItem *barrier);
+ void setScriptTarget(ActionItem *action);
+
void setDelayedSceneIndex(int index) { _delayedSceneIndex = index; }
int getDelayedSceneIndex() { return _delayedSceneIndex; }
@@ -52,6 +57,8 @@ public:
bool isInputAllowed() { return _allowInput; }
bool isProcessing() { return _processing; }
+ void setGameFlag(int flag);
+
private:
friend class Common::Singleton<SingletonBaseType>;
ScriptManager();
@@ -67,11 +74,26 @@ private:
Scene *_scene;
ActionDefinitions *_currentScript;
+ // NOTE
+ // Storing the gameflags on the
+ // scriptmanager since this makes the
+ // most sense
+ int _gameFlags[1512];
+ int _currentTarget;
+ BarrierItem *_currentTargetBarrier;
+ ActionItem *_currentTargetAction;
+
friend class Console;
}; // end of class ScriptManager
+enum targets {
+ kTargetNothing = 0,
+ kTargetBarrier,
+ kTargetAction
+};
+
enum opcodes {
kReturn0 = 0x00,
kSetGameFlag,
Commit: aab9670897ae78a2a1e3428212fb7114cac6a16d
https://github.com/scummvm/scummvm/commit/aab9670897ae78a2a1e3428212fb7114cac6a16d
Author: Alex Bevilacqua (alexbevi at gmail.com)
Date: 2021-05-17T15:35:33+02:00
Commit Message:
ASYLUM: Properly initialize the gameflags array and set the (what I'm assuming to be) ENTER_SCENE flag (though it's listed as Process Action List in the wiki at the moment .. which could be right)
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@251 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/scene.cpp
engines/asylum/scriptman.cpp
diff --git a/engines/asylum/scene.cpp b/engines/asylum/scene.cpp
index 9e842d5dee..56b41fb508 100644
--- a/engines/asylum/scene.cpp
+++ b/engines/asylum/scene.cpp
@@ -64,6 +64,9 @@ Scene::Scene(Screen *screen, Sound *sound, uint8 sceneIdx): _screen(screen), _so
g_debugPolygons = 0;
g_debugBarriers = 0;
+
+ // TODO Not sure why this is done ... yet
+ ScriptMan.setGameFlag(183);
}
Scene::~Scene() {
diff --git a/engines/asylum/scriptman.cpp b/engines/asylum/scriptman.cpp
index 97a6f8881d..a78069dca3 100644
--- a/engines/asylum/scriptman.cpp
+++ b/engines/asylum/scriptman.cpp
@@ -44,6 +44,8 @@ ScriptManager::ScriptManager() {
_currentTarget = kTargetNothing;
_currentTargetBarrier = 0;
_currentTargetAction = 0;
+
+ memset(_gameFlags, 0, 1512);
}
}
Commit: 2b6a4d17c50d9de79a997fb2dc27621dac2aa691
https://github.com/scummvm/scummvm/commit/2b6a4d17c50d9de79a997fb2dc27621dac2aa691
Author: Joseph Davies (deledrius at gmail.com)
Date: 2021-05-17T15:35:33+02:00
Commit Message:
ASYLUM: Added kJumpIfGameFlag case.
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@253 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/scriptman.cpp
diff --git a/engines/asylum/scriptman.cpp b/engines/asylum/scriptman.cpp
index a78069dca3..704db66346 100644
--- a/engines/asylum/scriptman.cpp
+++ b/engines/asylum/scriptman.cpp
@@ -120,13 +120,18 @@ void ScriptManager::processActionList() {
break;
case kJumpIfGameFlag:
- // TODO
- // need to know the source object that owns the
- // script we're parsing so that it's flags can
- // be checked
- // param1 = flag
- // param2 = false command
- // param3 = true command
+ if(currentCommand.param1 >= 0) {
+ bool doJump = false;
+ if(currentCommand.param2) {
+ doJump = _gameFlags[currentCommand.param1] == 0;
+ }
+ else {
+ doJump = _gameFlags[currentCommand.param1] != 0;
+ }
+
+ if(doJump)
+ _currentLine = currentCommand.param3;
+ }
break;
case kSetGameFlag:
@@ -202,7 +207,7 @@ void ScriptManager::processActionList() {
else
debugC(kDebugLevelScripts, "Requested invalid actor ID:0x%02X in Scene %d Script %d Line %d.", currentCommand.param1, _scene->getSceneIndex(), _currentLine);
}
- break;
+ break;
case kReturn:
done = true;
Commit: 54108200ee78918538fadd08044b0912a4f89ee7
https://github.com/scummvm/scummvm/commit/54108200ee78918538fadd08044b0912a4f89ee7
Author: Joseph Davies (deledrius at gmail.com)
Date: 2021-05-17T15:35:34+02:00
Commit Message:
ASYLUM: Cleaned up extra newline. Debug function inserts one automatically.
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@254 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/scriptman.cpp
diff --git a/engines/asylum/scriptman.cpp b/engines/asylum/scriptman.cpp
index 704db66346..87bdd485a4 100644
--- a/engines/asylum/scriptman.cpp
+++ b/engines/asylum/scriptman.cpp
@@ -55,7 +55,7 @@ void ScriptManager::setScript(ActionDefinitions *action) {
if (_currentScript) {
for (uint8 i = 0; i < _currentScript->commands[0].numLines; i++) {
debugC(kDebugLevelScripts,
- "Line: %02d/%02d :: 0x%02X (%d, %d, %d, %d, %d, %d, %d, %d, %d)\n",
+ "Line: %02d/%02d :: 0x%02X (%d, %d, %d, %d, %d, %d, %d, %d, %d)",
i,
_currentScript->commands[0].numLines - 1,
_currentScript->commands[i].opcode,
Commit: c7799f2fa62ca61329d0561aaccaf63a93e7e302
https://github.com/scummvm/scummvm/commit/c7799f2fa62ca61329d0561aaccaf63a93e7e302
Author: Joseph Davies (deledrius at gmail.com)
Date: 2021-05-17T15:35:34+02:00
Commit Message:
ASYLUM: Named Scene movement fields. Added function for setting the view window.
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@255 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/scene.cpp
engines/asylum/scene.h
engines/asylum/sceneres.cpp
engines/asylum/sceneres.h
diff --git a/engines/asylum/scene.cpp b/engines/asylum/scene.cpp
index 56b41fb508..017c37568f 100644
--- a/engines/asylum/scene.cpp
+++ b/engines/asylum/scene.cpp
@@ -165,6 +165,24 @@ bool Scene::actorVisible(int actorIndex) {
return false;
}
+void Scene::setScenePosition(int x, int y)
+{
+ GraphicFrame *bg = _bgResource->getFrame(0);
+ _startX = x;
+ _startY = y;
+
+ if (_startX < 0)
+ _startX = 0;
+ if (_startX > (bg->surface.w - 640))
+ _startX = bg->surface.w - 640;
+
+
+ if (_startX < 0)
+ _startY = 0;
+ if (_startX > (bg->surface.h - 480))
+ _startY = bg->surface.h - 480;
+}
+
void Scene::handleEvent(Common::Event *event, bool doUpdate) {
_ev = event;
diff --git a/engines/asylum/scene.h b/engines/asylum/scene.h
index 957915de1a..32784d96a6 100644
--- a/engines/asylum/scene.h
+++ b/engines/asylum/scene.h
@@ -64,6 +64,8 @@ public:
void setActorAction(int actorIndex, int action);
void actorVisible(int actorIndex, bool visible);
bool actorVisible(int actorIndex);
+
+ void setScenePosition(int x, int y);
private:
#if 0
diff --git a/engines/asylum/sceneres.cpp b/engines/asylum/sceneres.cpp
index 3160f5f421..f5ced5ac7b 100644
--- a/engines/asylum/sceneres.cpp
+++ b/engines/asylum/sceneres.cpp
@@ -126,12 +126,12 @@ void SceneResource::loadWorldStats(Common::SeekableReadStream *stream) {
_worldStats->width = stream->readUint32LE();
_worldStats->height = stream->readUint32LE();
- _worldStats->field_88 = stream->readUint32LE();
+ _worldStats->motionStatus = stream->readUint32LE();
_worldStats->field_8C = stream->readUint32LE();
_worldStats->numActions = stream->readUint32LE();
_worldStats->numBarriers = stream->readUint32LE();
- _worldStats->field_98 = stream->readUint32LE();
- _worldStats->field_9C = stream->readUint32LE();
+ _worldStats->targetX = stream->readUint32LE();
+ _worldStats->targetY = stream->readUint32LE();
_worldStats->field_A0 = stream->readUint32LE();
_worldStats->field_A4 = stream->readUint32LE();
_worldStats->field_A8 = stream->readUint32LE();
diff --git a/engines/asylum/sceneres.h b/engines/asylum/sceneres.h
index 0b71c3c1d8..c45b0ba13e 100644
--- a/engines/asylum/sceneres.h
+++ b/engines/asylum/sceneres.h
@@ -271,12 +271,12 @@ public:
CommonResources commonRes; // field_1C till field_7C
uint32 width; // field_80
uint32 height;
- uint32 field_88;
+ uint32 motionStatus;
uint32 field_8C;
uint32 numActions; // field_90
uint32 numBarriers;
- uint32 field_98;
- uint32 field_9C;
+ uint32 targetX;
+ uint32 targetY;
uint32 field_A0;
uint32 field_A4;
uint32 field_A8;
Commit: ac7e83c21ac8c1e9abc08098bf1ac8607c55e80c
https://github.com/scummvm/scummvm/commit/ac7e83c21ac8c1e9abc08098bf1ac8607c55e80c
Author: Joseph Davies (deledrius at gmail.com)
Date: 2021-05-17T15:35:34+02:00
Commit Message:
ASYLUM: Formatting.
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@256 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/scriptman.cpp
diff --git a/engines/asylum/scriptman.cpp b/engines/asylum/scriptman.cpp
index 87bdd485a4..e87b1dbd1f 100644
--- a/engines/asylum/scriptman.cpp
+++ b/engines/asylum/scriptman.cpp
@@ -120,9 +120,9 @@ void ScriptManager::processActionList() {
break;
case kJumpIfGameFlag:
- if(currentCommand.param1 >= 0) {
+ if (currentCommand.param1) {
bool doJump = false;
- if(currentCommand.param2) {
+ if (currentCommand.param2) {
doJump = _gameFlags[currentCommand.param1] == 0;
}
else {
@@ -160,7 +160,7 @@ void ScriptManager::processActionList() {
_scene->_sceneResource->getWorldStats()->barriers[barrierIndex].flags |= 0x20; // TODO - enums for flags (0x20 is visible/playing?)
else
debugC(kDebugLevelScripts, "Requested invalid object ID:0x%02X in Scene %d Line %d.", currentCommand.param1, _scene->getSceneIndex(), _currentLine);
- }
+ }
break;
case kHideActor: {
Commit: 927804b212085a0a4b226976bf46216709693906
https://github.com/scummvm/scummvm/commit/927804b212085a0a4b226976bf46216709693906
Author: Alexandre Fontoura (alexandrefontoura at gmail.com)
Date: 2021-05-17T15:35:34+02:00
Commit Message:
ASYLUM: First steps for BlowUpPuzzles
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@259 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
A engines/asylum/blowuppuzzle.cpp
A engines/asylum/blowuppuzzle.h
engines/asylum/asylum.vcproj
engines/asylum/module.mk
engines/asylum/scene.h
engines/asylum/sceneres.h
engines/asylum/scriptman.cpp
engines/asylum/scriptman.h
diff --git a/engines/asylum/asylum.vcproj b/engines/asylum/asylum.vcproj
index f55ebd02c5..31788cbe99 100644
--- a/engines/asylum/asylum.vcproj
+++ b/engines/asylum/asylum.vcproj
@@ -177,6 +177,14 @@
RelativePath="..\..\engines\asylum\asylum.h"
>
</File>
+ <File
+ RelativePath="..\..\engines\asylum\blowuppuzzle.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\engines\asylum\blowuppuzzle.h"
+ >
+ </File>
<File
RelativePath="..\..\engines\asylum\console.cpp"
>
diff --git a/engines/asylum/blowuppuzzle.cpp b/engines/asylum/blowuppuzzle.cpp
new file mode 100644
index 0000000000..7baf876d74
--- /dev/null
+++ b/engines/asylum/blowuppuzzle.cpp
@@ -0,0 +1,115 @@
+/* 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.
+ *
+ * $URL: https://asylumengine.googlecode.com/svn/trunk/menu.cpp $
+ * $Id: menu.cpp 236 2009-07-08 19:17:47Z sev.mail $
+ *
+ */
+
+#include "asylum/blowuppuzzle.h"
+#include "asylum/respack.h"
+#include "asylum/graphics.h"
+
+namespace Asylum {
+
+BlowUpPuzzle::BlowUpPuzzle(Screen *screen, Sound *sound, Scene *scene) :
+ _screen(screen), _sound(sound), _scene(scene) {
+}
+
+BlowUpPuzzle::~BlowUpPuzzle() {
+}
+
+void BlowUpPuzzle::updateCursor() {
+ _curMouseCursor += _cursorStep;
+ if (_curMouseCursor == 0)
+ _cursorStep = 1;
+ if (_curMouseCursor == _cursorResource->getFrameCount() - 1)
+ _cursorStep = -1;
+
+ _screen->setCursor(_cursorResource, _curMouseCursor);
+}
+
+// BlowUp Puzzle VCR
+
+BlowUpPuzzleVCR::BlowUpPuzzleVCR(Screen *screen, Sound *sound, Scene *scene) : BlowUpPuzzle(screen, sound, scene) {
+ this->_mouseX = 0;
+ _mouseY = 0;
+ _leftClick = false;
+ _curMouseCursor = 0;
+ _cursorStep = 1;
+ _active = false;
+
+ _cursorResource = new GraphicResource(_scene->_resPack, 2);
+ _bgResource = new GraphicResource(_scene->_resPack, _scene->_sceneResource->_worldStats->grResId[0]);
+}
+
+BlowUpPuzzleVCR::~BlowUpPuzzleVCR() {
+ delete _cursorResource;
+ delete _bgResource;
+}
+
+void BlowUpPuzzleVCR::openBlowUp() {
+ _active = true;
+ _scene->deactivate();
+
+ // Load the graphics palette
+ _screen->setPalette(_scene->_resPack, 183);
+
+ // show blow up puzzle BG
+ GraphicFrame *bg = _bgResource->getFrame(1);
+ _screen->copyToBackBuffer((byte *)bg->surface.pixels, bg->surface.w, 0, 0, bg->surface.w, bg->surface.h);
+
+ // Set mouse cursor
+ _screen->setCursor(_cursorResource, 0);
+ _screen->showCursor();
+
+ _leftClick = false;
+ _mouseX = _mouseY = 0;
+}
+
+void BlowUpPuzzleVCR::closeBlowUp() {
+ _active = false;
+ _scene->activate();
+}
+
+void BlowUpPuzzleVCR::handleEvent(Common::Event *event, bool doUpdate) {
+ _ev = event;
+
+ switch (_ev->type) {
+ case Common::EVENT_MOUSEMOVE:
+ _mouseX = _ev->mouse.x;
+ _mouseY = _ev->mouse.y;
+ break;
+ case Common::EVENT_LBUTTONUP:
+ _leftClick = true;
+ break;
+ default:
+ break;
+ }
+
+ if (doUpdate || _leftClick)
+ update();
+}
+
+void BlowUpPuzzleVCR::update() {
+ updateCursor();
+}
+
+} // end of namespace Asylum
diff --git a/engines/asylum/blowuppuzzle.h b/engines/asylum/blowuppuzzle.h
new file mode 100644
index 0000000000..b10572321e
--- /dev/null
+++ b/engines/asylum/blowuppuzzle.h
@@ -0,0 +1,90 @@
+/* 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.
+ *
+ * $URL: https://asylumengine.googlecode.com/svn/trunk/menu.h $
+ * $Id: menu.h 236 2009-07-08 19:17:47Z sev.mail $
+ *
+ */
+
+#ifndef ASYLUM_BLOWUPPUZZLE_H_
+#define ASYLUM_BLOWUPPUZZLE_H_
+
+#include "common/events.h"
+
+#include "asylum/asylum.h"
+#include "asylum/respack.h"
+#include "asylum/graphics.h"
+
+namespace Asylum {
+
+class Scene;
+class Screen;
+class Sound;
+
+class BlowUpPuzzle {
+public:
+ BlowUpPuzzle(Screen *screen, Sound *sound, Scene *scene);
+ virtual ~BlowUpPuzzle();
+
+ virtual void handleEvent(Common::Event *event, bool doUpdate);
+ virtual void openBlowUp();
+ virtual void closeBlowUp();
+
+ bool isActive() { return _active; }
+protected:
+ Common::Event *_ev;
+
+ Screen *_screen;
+ Sound *_sound;
+ Scene *_scene;
+
+ uint32 _mouseX;
+ uint32 _mouseY;
+ uint32 _curMouseCursor;
+ int32 _cursorStep;
+ bool _leftClick;
+ bool _active;
+
+ GraphicResource *_bgResource;
+ GraphicResource *_cursorResource;
+
+ void updateCursor();
+
+ virtual void update();
+
+}; // end of class BlowUpPuzzle
+
+
+class BlowUpPuzzleVCR : public BlowUpPuzzle {
+public:
+ BlowUpPuzzleVCR(Screen *screen, Sound *sound, Scene *scene);
+ ~BlowUpPuzzleVCR();
+
+ void handleEvent(Common::Event *event, bool doUpdate);
+ void openBlowUp();
+ void closeBlowUp();
+private:
+ void update();
+}; // end of class BlowUpPuzzleVCR
+
+
+} // end of namespace Asylum
+
+#endif
diff --git a/engines/asylum/module.mk b/engines/asylum/module.mk
index be315b6792..58a497e5ad 100644
--- a/engines/asylum/module.mk
+++ b/engines/asylum/module.mk
@@ -15,7 +15,8 @@ MODULE_OBJS := \
video.o \
actor.o \
encounters.o \
- scriptman.o
+ scriptman.o \
+ blowuppuzzle.o
# This module can be built as a plugin
ifeq ($(ENABLE_ASYLUM), DYNAMIC_PLUGIN)
diff --git a/engines/asylum/scene.h b/engines/asylum/scene.h
index 32784d96a6..cdb07e5893 100644
--- a/engines/asylum/scene.h
+++ b/engines/asylum/scene.h
@@ -33,6 +33,7 @@
#include "asylum/graphics.h"
#include "asylum/text.h"
#include "asylum/sceneres.h"
+#include "asylum/blowuppuzzle.h"
namespace Asylum {
@@ -40,7 +41,7 @@ class Screen;
class Sound;
class SceneResource;
class Text;
-class Interpreter;
+class BlowUpPuzzle;
struct ActionDefinitions;
struct PolyDefinitions;
@@ -73,20 +74,26 @@ private:
#endif
void copyToBackBufferClipped(Graphics::Surface *surface, int x, int y);
+public:
+ uint8 _sceneIdx;
+
+ SceneResource *_sceneResource;
+
+ ResourcePack *_resPack;
+ ResourcePack *_speechPack;
+ ResourcePack *_musPack;
+
+private:
Screen *_screen;
Sound *_sound;
+ BlowUpPuzzle *_blowUp;
Common::Event *_ev;
Text *_text;
- SceneResource *_sceneResource;
- ResourcePack *_resPack;
- ResourcePack *_speechPack;
- ResourcePack *_musPack;
GraphicResource *_bgResource;
GraphicResource *_cursorResource;
GraphicFrame *_background;
- uint8 _sceneIdx;
uint32 _mouseX;
uint32 _mouseY;
int32 _startX;
diff --git a/engines/asylum/sceneres.h b/engines/asylum/sceneres.h
index c45b0ba13e..41d0b16b51 100644
--- a/engines/asylum/sceneres.h
+++ b/engines/asylum/sceneres.h
@@ -72,11 +72,11 @@ public:
int getBarrierIndexById(uint32 id);
-private:
WorldStats *_worldStats;
GamePolygons *_gamePolygons;
ActionList *_actionList;
MainActor *_mainActor;
+private:
void loadWorldStats(Common::SeekableReadStream *stream);
void loadGamePolygons(Common::SeekableReadStream *stream);
diff --git a/engines/asylum/scriptman.cpp b/engines/asylum/scriptman.cpp
index e87b1dbd1f..d563d67492 100644
--- a/engines/asylum/scriptman.cpp
+++ b/engines/asylum/scriptman.cpp
@@ -232,6 +232,13 @@ void ScriptManager::processActionList() {
_delayedVideoIndex = currentCommand.param1;
break;
+ case kRunBlowUpPuzzle: {
+ int blowUpPuzzleIdx = currentCommand.param1;
+ // TODO: do proper blow up puzzle initialization
+ //_scene->_blowUp = new BlowUpPuzzleVCR(_scene->_screen, _scene->_sound, _scene);
+ }
+ break;
+
case kWaitUntilFramePlayed: {
int barrierIndex = _scene->_sceneResource->getBarrierIndexById(currentCommand.param1);
if (barrierIndex >= 0) {
diff --git a/engines/asylum/scriptman.h b/engines/asylum/scriptman.h
index b26236bb74..4ccbeb2bd5 100644
--- a/engines/asylum/scriptman.h
+++ b/engines/asylum/scriptman.h
@@ -150,7 +150,7 @@ enum opcodes {
k_unk34_Status,
k_unk35,
k_unk36,
- kRunMinigame,
+ kRunBlowUpPuzzle,
kJumpIfFlag2Bit3,
kSetFlag2Bit3,
kClearFlag2Bit3,
Commit: 158562f0959029f982995db9a5390db7c185b526
https://github.com/scummvm/scummvm/commit/158562f0959029f982995db9a5390db7c185b526
Author: Alex Bevilacqua (alexbevi at gmail.com)
Date: 2021-05-17T15:35:34+02:00
Commit Message:
ASYLUM: svn props
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@260 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/blowuppuzzle.cpp
engines/asylum/blowuppuzzle.h
diff --git a/engines/asylum/blowuppuzzle.cpp b/engines/asylum/blowuppuzzle.cpp
index 7baf876d74..3d252f7eb2 100644
--- a/engines/asylum/blowuppuzzle.cpp
+++ b/engines/asylum/blowuppuzzle.cpp
@@ -1,115 +1,115 @@
-/* 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.
- *
- * $URL: https://asylumengine.googlecode.com/svn/trunk/menu.cpp $
- * $Id: menu.cpp 236 2009-07-08 19:17:47Z sev.mail $
- *
- */
-
-#include "asylum/blowuppuzzle.h"
-#include "asylum/respack.h"
-#include "asylum/graphics.h"
-
-namespace Asylum {
-
-BlowUpPuzzle::BlowUpPuzzle(Screen *screen, Sound *sound, Scene *scene) :
- _screen(screen), _sound(sound), _scene(scene) {
-}
-
-BlowUpPuzzle::~BlowUpPuzzle() {
-}
-
-void BlowUpPuzzle::updateCursor() {
- _curMouseCursor += _cursorStep;
- if (_curMouseCursor == 0)
- _cursorStep = 1;
- if (_curMouseCursor == _cursorResource->getFrameCount() - 1)
- _cursorStep = -1;
-
- _screen->setCursor(_cursorResource, _curMouseCursor);
-}
-
-// BlowUp Puzzle VCR
-
-BlowUpPuzzleVCR::BlowUpPuzzleVCR(Screen *screen, Sound *sound, Scene *scene) : BlowUpPuzzle(screen, sound, scene) {
- this->_mouseX = 0;
- _mouseY = 0;
- _leftClick = false;
- _curMouseCursor = 0;
- _cursorStep = 1;
- _active = false;
-
- _cursorResource = new GraphicResource(_scene->_resPack, 2);
- _bgResource = new GraphicResource(_scene->_resPack, _scene->_sceneResource->_worldStats->grResId[0]);
-}
-
-BlowUpPuzzleVCR::~BlowUpPuzzleVCR() {
- delete _cursorResource;
- delete _bgResource;
-}
-
-void BlowUpPuzzleVCR::openBlowUp() {
- _active = true;
- _scene->deactivate();
-
- // Load the graphics palette
- _screen->setPalette(_scene->_resPack, 183);
-
- // show blow up puzzle BG
- GraphicFrame *bg = _bgResource->getFrame(1);
- _screen->copyToBackBuffer((byte *)bg->surface.pixels, bg->surface.w, 0, 0, bg->surface.w, bg->surface.h);
-
- // Set mouse cursor
- _screen->setCursor(_cursorResource, 0);
- _screen->showCursor();
-
- _leftClick = false;
- _mouseX = _mouseY = 0;
-}
-
-void BlowUpPuzzleVCR::closeBlowUp() {
- _active = false;
- _scene->activate();
-}
-
-void BlowUpPuzzleVCR::handleEvent(Common::Event *event, bool doUpdate) {
- _ev = event;
-
- switch (_ev->type) {
- case Common::EVENT_MOUSEMOVE:
- _mouseX = _ev->mouse.x;
- _mouseY = _ev->mouse.y;
- break;
- case Common::EVENT_LBUTTONUP:
- _leftClick = true;
- break;
- default:
- break;
- }
-
- if (doUpdate || _leftClick)
- update();
-}
-
-void BlowUpPuzzleVCR::update() {
- updateCursor();
-}
-
-} // end of namespace Asylum
+/* 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.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#include "asylum/blowuppuzzle.h"
+#include "asylum/respack.h"
+#include "asylum/graphics.h"
+
+namespace Asylum {
+
+BlowUpPuzzle::BlowUpPuzzle(Screen *screen, Sound *sound, Scene *scene) :
+ _screen(screen), _sound(sound), _scene(scene) {
+}
+
+BlowUpPuzzle::~BlowUpPuzzle() {
+}
+
+void BlowUpPuzzle::updateCursor() {
+ _curMouseCursor += _cursorStep;
+ if (_curMouseCursor == 0)
+ _cursorStep = 1;
+ if (_curMouseCursor == _cursorResource->getFrameCount() - 1)
+ _cursorStep = -1;
+
+ _screen->setCursor(_cursorResource, _curMouseCursor);
+}
+
+// BlowUp Puzzle VCR
+
+BlowUpPuzzleVCR::BlowUpPuzzleVCR(Screen *screen, Sound *sound, Scene *scene) : BlowUpPuzzle(screen, sound, scene) {
+ this->_mouseX = 0;
+ _mouseY = 0;
+ _leftClick = false;
+ _curMouseCursor = 0;
+ _cursorStep = 1;
+ _active = false;
+
+ _cursorResource = new GraphicResource(_scene->_resPack, 2);
+ _bgResource = new GraphicResource(_scene->_resPack, _scene->_sceneResource->_worldStats->grResId[0]);
+}
+
+BlowUpPuzzleVCR::~BlowUpPuzzleVCR() {
+ delete _cursorResource;
+ delete _bgResource;
+}
+
+void BlowUpPuzzleVCR::openBlowUp() {
+ _active = true;
+ _scene->deactivate();
+
+ // Load the graphics palette
+ _screen->setPalette(_scene->_resPack, 183);
+
+ // show blow up puzzle BG
+ GraphicFrame *bg = _bgResource->getFrame(1);
+ _screen->copyToBackBuffer((byte *)bg->surface.pixels, bg->surface.w, 0, 0, bg->surface.w, bg->surface.h);
+
+ // Set mouse cursor
+ _screen->setCursor(_cursorResource, 0);
+ _screen->showCursor();
+
+ _leftClick = false;
+ _mouseX = _mouseY = 0;
+}
+
+void BlowUpPuzzleVCR::closeBlowUp() {
+ _active = false;
+ _scene->activate();
+}
+
+void BlowUpPuzzleVCR::handleEvent(Common::Event *event, bool doUpdate) {
+ _ev = event;
+
+ switch (_ev->type) {
+ case Common::EVENT_MOUSEMOVE:
+ _mouseX = _ev->mouse.x;
+ _mouseY = _ev->mouse.y;
+ break;
+ case Common::EVENT_LBUTTONUP:
+ _leftClick = true;
+ break;
+ default:
+ break;
+ }
+
+ if (doUpdate || _leftClick)
+ update();
+}
+
+void BlowUpPuzzleVCR::update() {
+ updateCursor();
+}
+
+} // end of namespace Asylum
diff --git a/engines/asylum/blowuppuzzle.h b/engines/asylum/blowuppuzzle.h
index b10572321e..deeec690fd 100644
--- a/engines/asylum/blowuppuzzle.h
+++ b/engines/asylum/blowuppuzzle.h
@@ -1,90 +1,90 @@
-/* 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.
- *
- * $URL: https://asylumengine.googlecode.com/svn/trunk/menu.h $
- * $Id: menu.h 236 2009-07-08 19:17:47Z sev.mail $
- *
- */
-
-#ifndef ASYLUM_BLOWUPPUZZLE_H_
-#define ASYLUM_BLOWUPPUZZLE_H_
-
-#include "common/events.h"
-
-#include "asylum/asylum.h"
-#include "asylum/respack.h"
-#include "asylum/graphics.h"
-
-namespace Asylum {
-
-class Scene;
-class Screen;
-class Sound;
-
-class BlowUpPuzzle {
-public:
- BlowUpPuzzle(Screen *screen, Sound *sound, Scene *scene);
- virtual ~BlowUpPuzzle();
-
- virtual void handleEvent(Common::Event *event, bool doUpdate);
- virtual void openBlowUp();
- virtual void closeBlowUp();
-
- bool isActive() { return _active; }
-protected:
- Common::Event *_ev;
-
- Screen *_screen;
- Sound *_sound;
- Scene *_scene;
-
- uint32 _mouseX;
- uint32 _mouseY;
- uint32 _curMouseCursor;
- int32 _cursorStep;
- bool _leftClick;
- bool _active;
-
- GraphicResource *_bgResource;
- GraphicResource *_cursorResource;
-
- void updateCursor();
-
- virtual void update();
-
-}; // end of class BlowUpPuzzle
-
-
-class BlowUpPuzzleVCR : public BlowUpPuzzle {
-public:
- BlowUpPuzzleVCR(Screen *screen, Sound *sound, Scene *scene);
- ~BlowUpPuzzleVCR();
-
- void handleEvent(Common::Event *event, bool doUpdate);
- void openBlowUp();
- void closeBlowUp();
-private:
- void update();
-}; // end of class BlowUpPuzzleVCR
-
-
-} // end of namespace Asylum
-
-#endif
+/* 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.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#ifndef ASYLUM_BLOWUPPUZZLE_H_
+#define ASYLUM_BLOWUPPUZZLE_H_
+
+#include "common/events.h"
+
+#include "asylum/asylum.h"
+#include "asylum/respack.h"
+#include "asylum/graphics.h"
+
+namespace Asylum {
+
+class Scene;
+class Screen;
+class Sound;
+
+class BlowUpPuzzle {
+public:
+ BlowUpPuzzle(Screen *screen, Sound *sound, Scene *scene);
+ virtual ~BlowUpPuzzle();
+
+ virtual void handleEvent(Common::Event *event, bool doUpdate);
+ virtual void openBlowUp();
+ virtual void closeBlowUp();
+
+ bool isActive() { return _active; }
+protected:
+ Common::Event *_ev;
+
+ Screen *_screen;
+ Sound *_sound;
+ Scene *_scene;
+
+ uint32 _mouseX;
+ uint32 _mouseY;
+ uint32 _curMouseCursor;
+ int32 _cursorStep;
+ bool _leftClick;
+ bool _active;
+
+ GraphicResource *_bgResource;
+ GraphicResource *_cursorResource;
+
+ void updateCursor();
+
+ virtual void update();
+
+}; // end of class BlowUpPuzzle
+
+
+class BlowUpPuzzleVCR : public BlowUpPuzzle {
+public:
+ BlowUpPuzzleVCR(Screen *screen, Sound *sound, Scene *scene);
+ ~BlowUpPuzzleVCR();
+
+ void handleEvent(Common::Event *event, bool doUpdate);
+ void openBlowUp();
+ void closeBlowUp();
+private:
+ void update();
+}; // end of class BlowUpPuzzleVCR
+
+
+} // end of namespace Asylum
+
+#endif
Commit: 8a228b5ee7f0fc7a81621302a1f8af4edf1b7bc7
https://github.com/scummvm/scummvm/commit/8a228b5ee7f0fc7a81621302a1f8af4edf1b7bc7
Author: Alex Bevilacqua (alexbevi at gmail.com)
Date: 2021-05-17T15:35:34+02:00
Commit Message:
ASYLUM: Cleanup
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@261 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/scene.cpp
engines/asylum/scene.h
diff --git a/engines/asylum/scene.cpp b/engines/asylum/scene.cpp
index 017c37568f..8a863573cd 100644
--- a/engines/asylum/scene.cpp
+++ b/engines/asylum/scene.cpp
@@ -230,7 +230,6 @@ void Scene::updateCursor() {
}
void Scene::update() {
- //bool scrollScreen = false;
GraphicFrame *bg = _bgResource->getFrame(0);
MainActor *mainActor = _sceneResource->getMainActor();
WorldStats *worldStats = _sceneResource->getWorldStats();
@@ -238,25 +237,9 @@ void Scene::update() {
int32 curHotspot = -1;
int32 curBarrier = -1;
- /*
- // Horizontal scrolling
- if (_mouseX < SCREEN_EDGES && _startX >= SCROLL_STEP) {
- _startX -= SCROLL_STEP;
- //scrollScreen = true;
- } else if (_mouseX > 640 - SCREEN_EDGES && _startX <= bg->surface.w - 640 - SCROLL_STEP) {
- _startX += SCROLL_STEP;
- //scrollScreen = true;
- }
-
- // Vertical scrolling
- if (_mouseY < SCREEN_EDGES && _startY >= SCROLL_STEP) {
- _startY -= SCROLL_STEP;
- //scrollScreen = true;
- } else if (_mouseY > 480 - SCREEN_EDGES && _startY <= bg->surface.h - 480 - SCROLL_STEP) {
- _startY += SCROLL_STEP;
- //scrollScreen = true;
- }
- */
+ // DEBUG
+ // Force the screen to scroll if the mouse approaches the edges
+ // debugScreenScrolling(bg);
// Copy the background to the back buffer before updating the scene animations
_screen->copyToBackBuffer(((byte *)bg->surface.pixels) + _startY * bg->surface.w + _startX, bg->surface.w, 0, 0, 640, 480);
@@ -270,8 +253,6 @@ void Scene::update() {
// TESTING
// Main actor walking
if (!_rightButton) {
- //mainActor->setAction(15); // face south
- //mainActor->drawActorAt(_screen, mainActor->_actorX, mainActor->_actorY);
if (_sceneResource->getWorldStats()->actors[0].flags & 0x01) // TESTING - only draw if visible flag
mainActor->drawActor(_screen);
} else {
@@ -281,30 +262,14 @@ void Scene::update() {
// Change cursor
switch (mainActor->getCurrentAction()) {
- case kWalkN:
- newCursor = worldStats->commonRes.curScrollUp;
- break;
- case kWalkNE:
- newCursor = worldStats->commonRes.curScrollUpRight;
- break;
- case kWalkNW:
- newCursor = worldStats->commonRes.curScrollUpLeft;
- break;
- case kWalkS:
- newCursor = worldStats->commonRes.curScrollDown;
- break;
- case kWalkSE:
- newCursor = worldStats->commonRes.curScrollDownRight;
- break;
- case kWalkSW:
- newCursor = worldStats->commonRes.curScrollDownLeft;
- break;
- case kWalkW:
- newCursor = worldStats->commonRes.curScrollLeft;
- break;
- case kWalkE:
- newCursor = worldStats->commonRes.curScrollRight;
- break;
+ case kWalkN: newCursor = worldStats->commonRes.curScrollUp; break;
+ case kWalkNE: newCursor = worldStats->commonRes.curScrollUpRight; break;
+ case kWalkNW: newCursor = worldStats->commonRes.curScrollUpLeft; break;
+ case kWalkS: newCursor = worldStats->commonRes.curScrollDown; break;
+ case kWalkSE: newCursor = worldStats->commonRes.curScrollDownRight; break;
+ case kWalkSW: newCursor = worldStats->commonRes.curScrollDownLeft; break;
+ case kWalkW: newCursor = worldStats->commonRes.curScrollLeft; break;
+ case kWalkE: newCursor = worldStats->commonRes.curScrollRight; break;
}
if (_cursorResource->getEntryNum() != newCursor) {
@@ -314,9 +279,9 @@ void Scene::update() {
}
if (g_debugPolygons)
- ShowPolygons();
+ debugShowPolygons();
if (g_debugBarriers)
- ShowBarriers();
+ debugShowBarriers();
// Check if we're within a barrier
for (uint32 p = 0; p < worldStats->numBarriers; p++) {
@@ -355,7 +320,7 @@ void Scene::update() {
if (worldStats->actions[a].actionType == 0) {
PolyDefinitions poly = _sceneResource->getGamePolygons()->polygons[worldStats->actions[a].polyIdx];
if (pointInPoly(&poly, mainActor->_actorX, mainActor->_actorY)) {
- ShowWalkRegion(&poly);
+ debugShowWalkRegion(&poly);
break;
}
}
@@ -505,8 +470,22 @@ bool Scene::pointInPoly(PolyDefinitions *poly, int x, int y) {
return inside_flag;
}
+void Scene::debugScreenScrolling(GraphicFrame *bg) {
+ // Horizontal scrolling
+ if (_mouseX < SCREEN_EDGES && _startX >= SCROLL_STEP)
+ _startX -= SCROLL_STEP;
+ else if (_mouseX > 640 - SCREEN_EDGES && _startX <= bg->surface.w - 640 - SCROLL_STEP)
+ _startX += SCROLL_STEP;
+
+ // Vertical scrolling
+ if (_mouseY < SCREEN_EDGES && _startY >= SCROLL_STEP)
+ _startY -= SCROLL_STEP;
+ else if (_mouseY > 480 - SCREEN_EDGES && _startY <= bg->surface.h - 480 - SCROLL_STEP)
+ _startY += SCROLL_STEP;
+}
+
// WALK REGION DEBUG
-void Scene::ShowWalkRegion(PolyDefinitions *poly) {
+void Scene::debugShowWalkRegion(PolyDefinitions *poly) {
Graphics::Surface surface;
surface.create(poly->boundingRect.right - poly->boundingRect.left + 1, poly->boundingRect.bottom - poly->boundingRect.top + 1, 1);
@@ -525,7 +504,7 @@ void Scene::ShowWalkRegion(PolyDefinitions *poly) {
}
// POLYGONS DEBUG
-void Scene::ShowPolygons() {
+void Scene::debugShowPolygons() {
for (uint32 p = 0; p < _sceneResource->getGamePolygons()->numEntries; p++) {
Graphics::Surface surface;
PolyDefinitions poly = _sceneResource->getGamePolygons()->polygons[p];
@@ -540,9 +519,6 @@ void Scene::ShowPolygons() {
poly.points[(i+1) % poly.numPoints].y - poly.boundingRect.top, 0xFF);
}
- // Draw Bounding Box
- //surface.frameRect(Common::Rect(0, 0, surface.w, surface.h), 0xFF);
-
copyToBackBufferClipped(&surface, poly.boundingRect.left, poly.boundingRect.top);
surface.free();
@@ -550,7 +526,7 @@ void Scene::ShowPolygons() {
}
// BARRIER DEBUGGING
-void Scene::ShowBarriers() {
+void Scene::debugShowBarriers() {
for (uint32 p = 0; p < _sceneResource->getWorldStats()->numBarriers; p++) {
Graphics::Surface surface;
BarrierItem b = _sceneResource->getWorldStats()->barriers[p];
diff --git a/engines/asylum/scene.h b/engines/asylum/scene.h
index cdb07e5893..e50c541167 100644
--- a/engines/asylum/scene.h
+++ b/engines/asylum/scene.h
@@ -108,9 +108,10 @@ private:
void updateCursor();
void updateBarrier(Screen *screen, ResourcePack *res, uint8 actorIndex);
- void ShowPolygons();
- void ShowBarriers();
- void ShowWalkRegion(PolyDefinitions *poly);
+ void debugScreenScrolling(GraphicFrame *bg);
+ void debugShowPolygons();
+ void debugShowBarriers();
+ void debugShowWalkRegion(PolyDefinitions *poly);
bool pointInPoly(PolyDefinitions *poly, int x, int y);
friend class ScriptManager;
Commit: e86c52db38f77a4abec1e5eaac18d14156b2ae22
https://github.com/scummvm/scummvm/commit/e86c52db38f77a4abec1e5eaac18d14156b2ae22
Author: Filippos Karapetis (md5 at scummvm.org)
Date: 2021-05-17T15:35:34+02:00
Commit Message:
ASYLUM: Proper code formatting (refer to the relevant ScummVM wiki page here: http://wiki.scummvm.org/index.php/Code_Formatting_Conventions)
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@262 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/scene.cpp
diff --git a/engines/asylum/scene.cpp b/engines/asylum/scene.cpp
index 8a863573cd..e39757c51e 100644
--- a/engines/asylum/scene.cpp
+++ b/engines/asylum/scene.cpp
@@ -262,14 +262,30 @@ void Scene::update() {
// Change cursor
switch (mainActor->getCurrentAction()) {
- case kWalkN: newCursor = worldStats->commonRes.curScrollUp; break;
- case kWalkNE: newCursor = worldStats->commonRes.curScrollUpRight; break;
- case kWalkNW: newCursor = worldStats->commonRes.curScrollUpLeft; break;
- case kWalkS: newCursor = worldStats->commonRes.curScrollDown; break;
- case kWalkSE: newCursor = worldStats->commonRes.curScrollDownRight; break;
- case kWalkSW: newCursor = worldStats->commonRes.curScrollDownLeft; break;
- case kWalkW: newCursor = worldStats->commonRes.curScrollLeft; break;
- case kWalkE: newCursor = worldStats->commonRes.curScrollRight; break;
+ case kWalkN:
+ newCursor = worldStats->commonRes.curScrollUp;
+ break;
+ case kWalkNE:
+ newCursor = worldStats->commonRes.curScrollUpRight;
+ break;
+ case kWalkNW:
+ newCursor = worldStats->commonRes.curScrollUpLeft;
+ break;
+ case kWalkS:
+ newCursor = worldStats->commonRes.curScrollDown;
+ break;
+ case kWalkSE:
+ newCursor = worldStats->commonRes.curScrollDownRight;
+ break;
+ case kWalkSW:
+ newCursor = worldStats->commonRes.curScrollDownLeft;
+ break;
+ case kWalkW:
+ newCursor = worldStats->commonRes.curScrollLeft;
+ break;
+ case kWalkE:
+ newCursor = worldStats->commonRes.curScrollRight;
+ break;
}
if (_cursorResource->getEntryNum() != newCursor) {
Commit: 0a4aa79d620e7f5f27bf1df0b476d1dd62c33b31
https://github.com/scummvm/scummvm/commit/0a4aa79d620e7f5f27bf1df0b476d1dd62c33b31
Author: Alex Bevilacqua (alexbevi at gmail.com)
Date: 2021-05-17T15:35:35+02:00
Commit Message:
ASYLUM: * Removed the setTarget (action/barrier) logic that was started, but never used (it's not necessary as target info is determined by various script actions).
* INCOMPLETE kEnableBarriers and kEnableActor. I'm slowly working through this, but figure if maybe someone sees how it's coming, they can hope in and lend a hand ;)
* added ALL opcode cases, along with their corresponding hex values. This is just for the time being, and is for my own reference. It will NOT be part of the final code once the opcode methods have been fully implemented.
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@263 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/scriptman.cpp
engines/asylum/scriptman.h
diff --git a/engines/asylum/scriptman.cpp b/engines/asylum/scriptman.cpp
index d563d67492..7fb56209a4 100644
--- a/engines/asylum/scriptman.cpp
+++ b/engines/asylum/scriptman.cpp
@@ -41,9 +41,6 @@ ScriptManager::ScriptManager() {
_delayedSceneIndex = -1;
_delayedVideoIndex = -1;
_allowInput = true;
- _currentTarget = kTargetNothing;
- _currentTargetBarrier = 0;
- _currentTargetAction = 0;
memset(_gameFlags, 0, 1512);
}
@@ -69,22 +66,13 @@ void ScriptManager::setScript(ActionDefinitions *action) {
_currentScript->commands[i].param8,
_currentScript->commands[i].param9);
}
- } else {
- _currentTarget = kTargetNothing;
}
}
-void ScriptManager::setScriptTarget(BarrierItem *barrier) {
- _currentTarget = kTargetBarrier;
- _currentTargetBarrier = barrier;
- setScriptIndex(_currentTargetBarrier->actionListIdx);
+void ScriptManager::setScene(Scene* scene) {
+ _scene = scene;
+ _stats = _scene->_sceneResource->getWorldStats();
}
-void ScriptManager::setScriptTarget(ActionItem *action) {
- _currentTarget = kTargetAction;
- _currentTargetAction = action;
- setScriptIndex(_currentTargetAction->actionListIdx1);
-}
-
void ScriptManager::setScriptIndex(uint32 index) {
_currentScript = 0;
@@ -114,71 +102,70 @@ void ScriptManager::processActionList() {
switch (currentCommand.opcode) {
- case kReturn0:
+/* 0x00 */ case kReturn0:
done = true;
lineIncrement = 0;
break;
- case kJumpIfGameFlag:
- if (currentCommand.param1) {
- bool doJump = false;
- if (currentCommand.param2) {
- doJump = _gameFlags[currentCommand.param1] == 0;
- }
- else {
- doJump = _gameFlags[currentCommand.param1] != 0;
- }
-
- if(doJump)
- _currentLine = currentCommand.param3;
- }
- break;
-
- case kSetGameFlag:
+/* 0x01 */ case kSetGameFlag:
setGameFlag(currentCommand.param1);
break;
- case kClearGameFlag: {
+/* 0x02 */ case kClearGameFlag: {
int flagNum = currentCommand.param1;
_gameFlags[flagNum] &= ~(1 << flagNum);
}
break;
- case kShowCursor:
- _scene->_screen->showCursor();
- _allowInput = true;
+/* 0x03 */ //case kToogleGameFlag:
+/* 0x04 */ case kJumpIfGameFlag:
+ if (currentCommand.param1) {
+ bool doJump = false;
+ if (currentCommand.param2)
+ doJump = _gameFlags[currentCommand.param1] == 0;
+ else
+ doJump = _gameFlags[currentCommand.param1] != 0;
+
+ if(doJump)
+ _currentLine = currentCommand.param3;
+ }
break;
- case kHideCursor:
+/* 0x05 */ case kHideCursor:
_scene->_screen->hideCursor();
_allowInput = false;
break;
- case kPlayAnimation: {
+/* 0x06 */ case kShowCursor:
+ _scene->_screen->showCursor();
+ _allowInput = true;
+ break;
+
+/* 0x07 */ case kPlayAnimation: {
int barrierIndex = _scene->_sceneResource->getBarrierIndexById(currentCommand.param1);
if (barrierIndex >= 0)
_scene->_sceneResource->getWorldStats()->barriers[barrierIndex].flags |= 0x20; // TODO - enums for flags (0x20 is visible/playing?)
else
debugC(kDebugLevelScripts, "Requested invalid object ID:0x%02X in Scene %d Line %d.", currentCommand.param1, _scene->getSceneIndex(), _currentLine);
- }
+ }
break;
- case kHideActor: {
+/* 0x08 */ //case kMoveScenePosition:
+/* 0x09 */ case kHideActor: {
uint32 actorIndex = 0;
if (currentCommand.param1 == -1)
;//actorIndex = _scene->getWorldStats()->playerActor;
else
actorIndex = currentCommand.param1;
- if ((actorIndex >= 0) && (actorIndex < _scene->_sceneResource->getWorldStats()->numActors)) {
+ if ((actorIndex >= 0) && (actorIndex < _scene->_sceneResource->getWorldStats()->numActors))
_scene->actorVisible(actorIndex, false);
- }
else
debugC(kDebugLevelScripts, "Requested invalid actor ID:0x%02X in Scene %d Line %d.", currentCommand.param1, _scene->getSceneIndex(), _currentLine);
}
break;
- case kShowActor: {
+/* 0x0A */ case kShowActor: {
uint32 actorIndex = 0;
if (currentCommand.param1 == -1)
;//actorIndex = _scene->getWorldStats()->playerActor;
@@ -193,7 +180,7 @@ void ScriptManager::processActionList() {
}
break;
- case kSetActorStats: {
+/* 0x0B */ case kSetActorStats: {
uint32 actorIndex = 0;
if (currentCommand.param1 == -1)
;//actorIndex = _scene->getWorldStats()->playerActor;
@@ -207,14 +194,112 @@ void ScriptManager::processActionList() {
else
debugC(kDebugLevelScripts, "Requested invalid actor ID:0x%02X in Scene %d Script %d Line %d.", currentCommand.param1, _scene->getSceneIndex(), _currentLine);
}
- break;
+ break;
+
+/* 0x0C */ //case k_unk0C_SET_SCENE_FIELD88:
+/* 0x0D */ //case kDisableActor:
+/* 0x0E */ case kEnableActor: {
+ int actorIndex = 0;
+ if (currentCommand.param1 == -1)
+ ;//actorIndex = _scene->getWorldStats()->playerActor;
+ else
+ actorIndex = currentCommand.param1;
+
+ printf("%d\n", _stats->actors[actorIndex].field_40);
+
+ if (_stats->actors[actorIndex].field_40 == 5) {
+ /*
+ v14 = 2468 * characterIndex;
+ v19 = scene.characters[characterIndex].direction;
+ if ( v19 > 4 )
+ v20 = 8 - v19;
+ else
+ v20 = scene.characters[characterIndex].direction;
+ v21 = scene.characters[0].grResTable[characterIndex + v20 + 616 * characterIndex + 5];
+ LABEL_82:
+ *(int *)((char *)&scene.characters[0].grResId + v14) = v21;
+ v16 = v21;
+ LABEL_83:
+ *(int *)((char *)&scene.characters[0].frameCount + v14) = grGetFrameCount__(v16);
+ *(int *)((char *)&scene.characters[0].frameNumber + v14) = 0;
+ goto LABEL_84;
+ default:
+ goto LABEL_84;
+ }
+ while ( 1 )
+ {
+ v32 = *v30 < (unsigned __int8)*v31;
+ if ( *v30 != *v31 )
+ break;
+ if ( !*v30 )
+ goto LABEL_70;
+ v42 = *(v30 + 1);
+ v43 = *(v31 + 1);
+ v33 = *(v30 + 1);
+ v32 = v42 < v43;
+ if ( v42 != v43 )
+ break;
+ v30 += 2;
+ v31 += 2;
+ if ( !v33 )
+ {
+ LABEL_70:
+ v34 = 0;
+ goto LABEL_72;
+ }
+ }
+ v34 = -v32 - (v32 - 1);
+ LABEL_72:
+ if ( !v34 )
+ v3 = 4;
+ LABEL_84:
+ result = 617 * v4;
+ scene.characters[v4].field_40 = v3;
+
+ */
+ }
+ }
+ break;
+
+/* 0x0F */ case kEnableBarriers: {
+ int barIdx = _scene->_sceneResource->getBarrierIndexById(currentCommand.param1);
+ int sndIdx = currentCommand.param3;
+ int v59 = currentCommand.param2;
+ int v61 = _currentScript->counter; // actionList + 1773
- case kReturn:
+ if (!v61 && _scene->getSceneIndex() != 13)
+ _scene->_sound->playSfx(_scene->_resPack, ((sndIdx != 0) & 5) - 2146303999);
+
+ if (v61 >= 3 * v59 - 1) {
+ _currentScript->counter = 0;
+ _scene->_sceneResource->getWorldStats()->barriers[barIdx].field_67C = 0;
+ // processActionListSub02(currentCommand.opcode, v59, _currentScript->counter, 2);
+ _currentLoops = 1; // v4 = 1;
+ } else {
+ int v64;
+ int v62 = v61 + 1;
+ _currentScript->counter = v62;
+ if (sndIdx) {
+ v64 = 1;
+ int v170 = 3 - v62 / v59;
+ _scene->_sceneResource->getWorldStats()->barriers[barIdx].field_67C = v170;
+ } else {
+ v64 = 0;
+ _scene->_sceneResource->getWorldStats()->barriers[barIdx].field_67C = v62 / v59 + 1;
+ }
+
+ //processActionListSub02(currentCommand.opcode, v59, _currentScript->counter, v64);
+
+ }
+ }
+ break;
+
+/* 0x10 */ case kReturn:
done = true;
lineIncrement = 0;
break;
- case kDestroyObject: {
+/* 0x11 */ case kDestroyObject: {
int barrierIndex = _scene->_sceneResource->getBarrierIndexById(currentCommand.param1);
if (barrierIndex >= 0)
_scene->_sceneResource->getWorldStats()->barriers[barrierIndex].flags &= 0xFFFFDF; // TODO - enums for flags (0x20 is visible/playing?)
@@ -223,23 +308,63 @@ void ScriptManager::processActionList() {
}
break;
- case kChangeScene:
+/* 0x12 */ //case k_unk12_JMP_WALK_ACTOR:
+/* 0x13 */ //case k_unk13_JMP_WALK_ACTOR:
+/* 0x14 */ //case k_unk14_JMP_WALK_ACTOR:
+/* 0x15 */ //case k_unk15:
+/* 0x16 */ //case kResetAnimation:
+/* 0x17 */ //case kClearFlag1Bit0:
+/* 0x18 */ //case k_unk18_PLAY_SND:
+/* 0x19 */ //case kJumpIfFlag2Bit0:
+/* 0x1A */ //case kSetFlag2Bit0:
+/* 0x1B */ //case kClearFlag2Bit0:
+/* 0x1C */ //case kJumpIfFlag2Bit2:
+/* 0x1D */ //case kSetFlag2Bit2:
+/* 0x1E */ //case kClearFlag2Bit2:
+/* 0x1F */ //case kJumpIfFlag2Bit1:
+/* 0x20 */ //case kSetFlag2Bit1:
+/* 0x21 */ //case kClearFlag2Bit1:
+/* 0x22 */ //case k_unk22:
+/* 0x23 */ //case k_unk23:
+/* 0x24 */ //case k_unk24:
+/* 0x25 */ //case kRunEncounter:
+/* 0x26 */ //case kJumpIfFlag2Bit4:
+/* 0x27 */ //case kSetFlag2Bit4:
+/* 0x28 */ //case kClearFlag2Bit4:
+/* 0x29 */ //case kSetActorField638:
+/* 0x2A */ //case kJumpIfActorField638:
+/* 0x2B */ case kChangeScene:
_delayedSceneIndex = currentCommand.param1 + 4;
debug(kDebugLevelScripts, "Queueing Scene Change to scene %d...", currentCommand.param1 + 4);
break;
- case kPlayMovie:
+/* 0x2C */ //case k_unk2C_ActorSub:
+/* 0x2D */ case kPlayMovie:
_delayedVideoIndex = currentCommand.param1;
break;
- case kRunBlowUpPuzzle: {
- int blowUpPuzzleIdx = currentCommand.param1;
- // TODO: do proper blow up puzzle initialization
- //_scene->_blowUp = new BlowUpPuzzleVCR(_scene->_screen, _scene->_sound, _scene);
- }
- break;
+/* 0x2E */ //case kStopAllObjectsSounds:
+/* 0x2F */ //case kSetActionFlag01:
+/* 0x30 */ //case kClearActionFlag01:
+/* 0x31 */ //case kResetSceneRect:
+/* 0x32 */ //case kChangeMusicById:
+/* 0x33 */ //case kStopMusic:
+/* 0x34 */ //case k_unk34_Status:
+/* 0x35 */ //case k_unk35:
+/* 0x36 */ //case k_unk36:
+/* 0x37 */ case kRunBlowUpPuzzle: {
+ int blowUpPuzzleIdx = currentCommand.param1;
+ // TODO: do proper blow up puzzle initialization
+ //_scene->_blowUp = new BlowUpPuzzleVCR(_scene->_screen, _scene->_sound, _scene);
+ }
+ break;
- case kWaitUntilFramePlayed: {
+/* 0x38 */ //case kJumpIfFlag2Bit3:
+/* 0x39 */ //case kSetFlag2Bit3:
+/* 0x3A */ //case kClearFlag2Bit3:
+/* 0x3B */ //case k_unk3B_PALETTE_MOD:
+/* 0x3C */ //case k_unk3C_CMP_VAL:
+/* 0x3D */ case kWaitUntilFramePlayed: {
int barrierIndex = _scene->_sceneResource->getBarrierIndexById(currentCommand.param1);
if (barrierIndex >= 0) {
uint32 frameNum = 0;
@@ -252,16 +377,21 @@ void ScriptManager::processActionList() {
lineIncrement = 0;
waitCycle = true;
}
- } else {
- debugC(kDebugLevelScripts, "Requested invalid object ID:0x%02X in Scene %d Line %d.", currentCommand.param1, _scene->getSceneIndex(), _currentLine);
- }
- break;
+ } else
+ debugC(kDebugLevelScripts, "Requested invalid object ID:0x%02X in Scene %d Line %d.",
+ currentCommand.param1,
+ _scene->getSceneIndex(),
+ _currentLine);
}
+ break;
- case kPlaySpeech:
+/* 0x3E */ //case kUpdateMatteBars:
+/* 0x3F */ //case k_unk3F:
+/* 0x40 */ //case k_unk40_SOUND:
+/* 0x41 */ case kPlaySpeech:
// TODO - Add support for other param options
if (currentCommand.param1 >= 0) {
- if (currentCommand.param3 && currentCommand.param1 > 0) // HACK - Find out why sometimes an offset is needed and other times not
+ if (currentCommand.param3 && currentCommand.param1 > 0) // HACK - Find out why sometimes an offset is needed and other times not
_scene->_sound->playSfx(_scene->_speechPack, currentCommand.param1 - 9);
else
_scene->_sound->playSfx(_scene->_speechPack, currentCommand.param1);
@@ -269,8 +399,45 @@ void ScriptManager::processActionList() {
debugC(kDebugLevelScripts, "Requested invalid sound ID:0x%02X in Scene %d Line %d.", currentCommand.param1, _scene->getSceneIndex(), _currentLine);
break;
+/* 0x42 */ //case k_unk42:
+/* 0x43 */ //case k_unk43:
+/* 0x44 */ //case kPaletteFade:
+/* 0x45 */ //case kStartPaletteFadeThread:
+/* 0x46 */ //case k_unk46:
+/* 0x47 */ //case kActorFaceObject:
+/* 0x48 */ //case k_unk48_MATTE_01:
+/* 0x49 */ //case k_unk49_MATTE_90:
+/* 0x4A */ //case kJumpIfSoundPlaying:
+/* 0x4B */ //case kChangePlayerCharacterIndex:
+/* 0x4C */ //case kChangeActorField40:
+/* 0x4D */ //case kStopSound:
+/* 0x4E */ //case k_unk4E_RANDOM_COMMAND:
+/* 0x4F */ //case kDrawGame:
+/* 0x50 */ //case kQuit:
+/* 0x51 */ //case kJumpObjectFrame:
+/* 0x52 */ //case k_unk52:
+/* 0x53 */ //case k_unk53:
+/* 0x54 */ //case k_unk54_SET_ACTIONLIST_6EC:
+/* 0x55 */ //case k_unk55:
+/* 0x56 */ //case k_unk56:
+/* 0x57 */ //case k_unk57:
+/* 0x58 */ //case k_unk58:
+/* 0x59 */ //case k_unk59:
+/* 0x5A */ //case k_unk5A:
+/* 0x5B */ //case k_unk5B:
+/* 0x5C */ //case k_unk5C:
+/* 0x5D */ //case k_unk5D:
+/* 0x5E */ //case k_unk5E:
+/* 0x5F */ //case k_unk5F:
+/* 0x60 */ //case k_unk60_SET_OR_CLR_ACTIONAREA_FLAG:
+/* 0x61 */ //case k_unk61:
+/* 0x62 */ //case k_unk62_SHOW_OPTIONS_SCREEN:
+
default:
- debugC(kDebugLevelScripts, "Unhandled opcode 0x%02X in Scene %d Line %d.", currentCommand.opcode, _scene->getSceneIndex(), _currentLine);
+ debugC(kDebugLevelScripts, "Unhandled opcode 0x%02X in Scene %d Line %d.",
+ currentCommand.opcode,
+ _scene->getSceneIndex(),
+ _currentLine);
break;
} // end switch
@@ -291,6 +458,44 @@ void ScriptManager::processActionList() {
_processing = false;
}
+void ScriptManager::processActionListSub02(ActionCommand *command, int a3, int a4) {
+ int v4 = 0;
+ int result;
+ int barrierIdx = 0;
+ if (a4) {
+ if (a4 == 1) {
+ ;
+ } else {
+ result = a4 - 2;
+ int v8 = command->param4;
+
+ for (int i = 7; i > 0; i--) {
+ barrierIdx = _scene->_sceneResource->getBarrierIndexById(v8);
+ if (barrierIdx)
+ _scene->_sceneResource->getWorldStats()->barriers[barrierIdx].field_67C = 0;
+ v8 += 4;
+ }
+ }
+
+ switch (_scene->getSceneIndex()) {
+ case 7:
+ break;
+ case 6:
+ break;
+ case 8:
+ break;
+ case 3:
+ break;
+ case 4:
+ break;
+ default:
+ return;
+ }
+
+
+ }
+}
+
ScriptManager::~ScriptManager() {
// TODO Auto-generated destructor stub
}
diff --git a/engines/asylum/scriptman.h b/engines/asylum/scriptman.h
index 4ccbeb2bd5..deec2c0dcb 100644
--- a/engines/asylum/scriptman.h
+++ b/engines/asylum/scriptman.h
@@ -35,19 +35,17 @@ namespace Asylum {
struct ActionCommand;
struct ActionItem;
struct BarrierItem;
+struct WorldStats;
class ScriptManager: public Common::Singleton<ScriptManager> {
public:
void processActionList();
- void setScene(Scene *scene) { _scene = scene; }
+ void setScene(Scene *scene);
void setScript(ActionDefinitions *action);
void setScriptIndex(uint32 index);
- void setScriptTarget(BarrierItem *barrier);
- void setScriptTarget(ActionItem *action);
-
void setDelayedSceneIndex(int index) { _delayedSceneIndex = index; }
int getDelayedSceneIndex() { return _delayedSceneIndex; }
@@ -64,6 +62,8 @@ private:
ScriptManager();
~ScriptManager();
+ WorldStats* _stats;
+
int _currentLine;
int _currentLoops;
bool _processing;
@@ -78,22 +78,15 @@ private:
// Storing the gameflags on the
// scriptmanager since this makes the
// most sense
- int _gameFlags[1512];
- int _currentTarget;
- BarrierItem *_currentTargetBarrier;
- ActionItem *_currentTargetAction;
+ int _gameFlags[1512];
+
+ void processActionListSub02(ActionCommand* command, int a3, int a4);
friend class Console;
}; // end of class ScriptManager
-enum targets {
- kTargetNothing = 0,
- kTargetBarrier,
- kTargetAction
-};
-
enum opcodes {
kReturn0 = 0x00,
kSetGameFlag,
Commit: def25effdcfb55eb74e7f9bfa5fd9f18da4f6eb1
https://github.com/scummvm/scummvm/commit/def25effdcfb55eb74e7f9bfa5fd9f18da4f6eb1
Author: Alex Bevilacqua (alexbevi at gmail.com)
Date: 2021-05-17T15:35:35+02:00
Commit Message:
ASYLUM: * killed a couple old forward declarations
* removed WorldStats variable instance
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@264 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/scriptman.cpp
engines/asylum/scriptman.h
diff --git a/engines/asylum/scriptman.cpp b/engines/asylum/scriptman.cpp
index 7fb56209a4..e3a07feaac 100644
--- a/engines/asylum/scriptman.cpp
+++ b/engines/asylum/scriptman.cpp
@@ -71,7 +71,6 @@ void ScriptManager::setScript(ActionDefinitions *action) {
void ScriptManager::setScene(Scene* scene) {
_scene = scene;
- _stats = _scene->_sceneResource->getWorldStats();
}
void ScriptManager::setScriptIndex(uint32 index) {
@@ -205,9 +204,7 @@ void ScriptManager::processActionList() {
else
actorIndex = currentCommand.param1;
- printf("%d\n", _stats->actors[actorIndex].field_40);
-
- if (_stats->actors[actorIndex].field_40 == 5) {
+ if (_scene->_sceneResource->getWorldStats()->actors[actorIndex].field_40 == 5) {
/*
v14 = 2468 * characterIndex;
v19 = scene.characters[characterIndex].direction;
diff --git a/engines/asylum/scriptman.h b/engines/asylum/scriptman.h
index deec2c0dcb..271ee92adf 100644
--- a/engines/asylum/scriptman.h
+++ b/engines/asylum/scriptman.h
@@ -33,9 +33,6 @@
namespace Asylum {
struct ActionCommand;
-struct ActionItem;
-struct BarrierItem;
-struct WorldStats;
class ScriptManager: public Common::Singleton<ScriptManager> {
public:
@@ -62,8 +59,6 @@ private:
ScriptManager();
~ScriptManager();
- WorldStats* _stats;
-
int _currentLine;
int _currentLoops;
bool _processing;
Commit: c15eb6fe8f12dba8c20d85ca3027d3fa5d8f2986
https://github.com/scummvm/scummvm/commit/c15eb6fe8f12dba8c20d85ca3027d3fa5d8f2986
Author: Alex Bevilacqua (alexbevi at gmail.com)
Date: 2021-05-17T15:35:35+02:00
Commit Message:
ASYLUM: abstract some variable accessors
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@265 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/blowuppuzzle.cpp
engines/asylum/scene.h
engines/asylum/sceneres.h
diff --git a/engines/asylum/blowuppuzzle.cpp b/engines/asylum/blowuppuzzle.cpp
index 3d252f7eb2..047c04a5df 100644
--- a/engines/asylum/blowuppuzzle.cpp
+++ b/engines/asylum/blowuppuzzle.cpp
@@ -49,15 +49,14 @@ void BlowUpPuzzle::updateCursor() {
// BlowUp Puzzle VCR
BlowUpPuzzleVCR::BlowUpPuzzleVCR(Screen *screen, Sound *sound, Scene *scene) : BlowUpPuzzle(screen, sound, scene) {
- this->_mouseX = 0;
- _mouseY = 0;
- _leftClick = false;
- _curMouseCursor = 0;
- _cursorStep = 1;
- _active = false;
-
- _cursorResource = new GraphicResource(_scene->_resPack, 2);
- _bgResource = new GraphicResource(_scene->_resPack, _scene->_sceneResource->_worldStats->grResId[0]);
+ this->_mouseX = 0;
+ _mouseY = 0;
+ _leftClick = false;
+ _curMouseCursor = 0;
+ _cursorStep = 1;
+ _active = false;
+ _cursorResource = _scene->getGraphicResource(2);
+ _bgResource = _scene->getGraphicResource(_scene->getResources()->getWorldStats()->grResId[0]);
}
BlowUpPuzzleVCR::~BlowUpPuzzleVCR() {
@@ -70,7 +69,7 @@ void BlowUpPuzzleVCR::openBlowUp() {
_scene->deactivate();
// Load the graphics palette
- _screen->setPalette(_scene->_resPack, 183);
+ _screen->setPalette(_scene->getResourcePack(), 183);
// show blow up puzzle BG
GraphicFrame *bg = _bgResource->getFrame(1);
diff --git a/engines/asylum/scene.h b/engines/asylum/scene.h
index e50c541167..72bf8b5150 100644
--- a/engines/asylum/scene.h
+++ b/engines/asylum/scene.h
@@ -39,9 +39,9 @@ namespace Asylum {
class Screen;
class Sound;
-class SceneResource;
class Text;
class BlowUpPuzzle;
+class SceneResource;
struct ActionDefinitions;
struct PolyDefinitions;
@@ -68,22 +68,22 @@ public:
void setScenePosition(int x, int y);
+ SceneResource* getResources() { return _sceneResource; }
+ ResourcePack* getResourcePack() { return _resPack; }
+ GraphicResource* getGraphicResource(uint32 entry) { return new GraphicResource(_resPack, entry); }
+
private:
#if 0
void copyToSceneBackground(GraphicFrame *frame, int x, int y);
#endif
void copyToBackBufferClipped(Graphics::Surface *surface, int x, int y);
-public:
- uint8 _sceneIdx;
-
- SceneResource *_sceneResource;
-
+ uint8 _sceneIdx;
+ SceneResource *_sceneResource;
ResourcePack *_resPack;
ResourcePack *_speechPack;
ResourcePack *_musPack;
-private:
Screen *_screen;
Sound *_sound;
BlowUpPuzzle *_blowUp;
diff --git a/engines/asylum/sceneres.h b/engines/asylum/sceneres.h
index 41d0b16b51..6a6123b32c 100644
--- a/engines/asylum/sceneres.h
+++ b/engines/asylum/sceneres.h
@@ -72,11 +72,12 @@ public:
int getBarrierIndexById(uint32 id);
+private:
+
WorldStats *_worldStats;
GamePolygons *_gamePolygons;
ActionList *_actionList;
MainActor *_mainActor;
-private:
void loadWorldStats(Common::SeekableReadStream *stream);
void loadGamePolygons(Common::SeekableReadStream *stream);
Commit: 49ca9374f044185c2b42a8c27456fce08f0b4916
https://github.com/scummvm/scummvm/commit/49ca9374f044185c2b42a8c27456fce08f0b4916
Author: Alex Bevilacqua (alexbevi at gmail.com)
Date: 2021-05-17T15:35:35+02:00
Commit Message:
ASYLUM: Simplify loading of default action list
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@266 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/asylum.cpp
engines/asylum/scene.cpp
engines/asylum/scene.h
diff --git a/engines/asylum/asylum.cpp b/engines/asylum/asylum.cpp
index 4ab84ae111..aacb5d83ed 100644
--- a/engines/asylum/asylum.cpp
+++ b/engines/asylum/asylum.cpp
@@ -108,7 +108,7 @@ Common::Error AsylumEngine::go() {
// TODO This can probably also be rolled into the scene constructor.
// Investigate if this will fuck up the execution sequence though :P
- ScriptMan.setScript(_scene->getActionList(_scene->getDefaultActionIndex()));
+ ScriptMan.setScript(_scene->getDefaultActionList());
// Set up main menu
_mainMenu = new MainMenu(_screen, _sound, _scene);
@@ -210,7 +210,7 @@ void AsylumEngine::processDelayedEvents() {
_scene->enterScene();
ScriptMan.setDelayedSceneIndex(-1);
- ScriptMan.setScript(_scene->getActionList(_scene->getDefaultActionIndex()));
+ ScriptMan.setScript(_scene->getDefaultActionList());
}
}
diff --git a/engines/asylum/scene.cpp b/engines/asylum/scene.cpp
index e39757c51e..d4a1179101 100644
--- a/engines/asylum/scene.cpp
+++ b/engines/asylum/scene.cpp
@@ -98,14 +98,14 @@ void Scene::enterScene() {
_isActive = true;
}
-int Scene::getDefaultActionIndex() {
+ActionDefinitions* Scene::getDefaultActionList() {
if (_sceneResource)
- return _sceneResource->getWorldStats()->actionListIdx;
+ return getActionList(_sceneResource->getWorldStats()->actionListIdx);
else
- return -1;
+ return 0;
}
-ActionDefinitions * Scene::getActionList(int actionListIndex) {
+ActionDefinitions* Scene::getActionList(int actionListIndex) {
if ((actionListIndex >= 0) && (actionListIndex < (int)_sceneResource->getWorldStats()->numActions))
return &_sceneResource->getActionList()->actions[actionListIndex];
else
diff --git a/engines/asylum/scene.h b/engines/asylum/scene.h
index 72bf8b5150..1335bf033e 100644
--- a/engines/asylum/scene.h
+++ b/engines/asylum/scene.h
@@ -58,8 +58,8 @@ public:
bool isActive() { return _isActive; }
int getSceneIndex() { return _sceneIdx; }
- int getDefaultActionIndex();
- ActionDefinitions *getActionList(int actionListIndex);
+ ActionDefinitions* getDefaultActionList();
+ ActionDefinitions* getActionList(int actionListIndex);
void setActorPosition(int actorIndex, int x, int y);
void setActorAction(int actorIndex, int action);
Commit: 024b4734f59f3b7ecf97c8dae789f79c426403fd
https://github.com/scummvm/scummvm/commit/024b4734f59f3b7ecf97c8dae789f79c426403fd
Author: Alex Bevilacqua (alexbevi at gmail.com)
Date: 2021-05-17T15:35:35+02:00
Commit Message:
ASYLUM: updated opcode list as per r258
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@267 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/scriptman.cpp
engines/asylum/scriptman.h
diff --git a/engines/asylum/scriptman.cpp b/engines/asylum/scriptman.cpp
index e3a07feaac..05b6a0a641 100644
--- a/engines/asylum/scriptman.cpp
+++ b/engines/asylum/scriptman.cpp
@@ -195,7 +195,7 @@ void ScriptManager::processActionList() {
}
break;
-/* 0x0C */ //case k_unk0C_SET_SCENE_FIELD88:
+/* 0x0C */ //case kSetSceneMotionStat:
/* 0x0D */ //case kDisableActor:
/* 0x0E */ case kEnableActor: {
int actorIndex = 0;
@@ -467,9 +467,9 @@ void ScriptManager::processActionListSub02(ActionCommand *command, int a3, int a
int v8 = command->param4;
for (int i = 7; i > 0; i--) {
- barrierIdx = _scene->_sceneResource->getBarrierIndexById(v8);
+ barrierIdx = _scene->getResources()->getBarrierIndexById(v8);
if (barrierIdx)
- _scene->_sceneResource->getWorldStats()->barriers[barrierIdx].field_67C = 0;
+ _scene->getResources()->getWorldStats()->barriers[barrierIdx].field_67C = 0;
v8 += 4;
}
}
diff --git a/engines/asylum/scriptman.h b/engines/asylum/scriptman.h
index 271ee92adf..1b67680720 100644
--- a/engines/asylum/scriptman.h
+++ b/engines/asylum/scriptman.h
@@ -95,7 +95,7 @@ enum opcodes {
kHideActor,
kShowActor,
kSetActorStats,
- k_unk0C_SET_SCENE_FIELD88,
+ kSetSceneMotionStat,
kDisableActor,
kEnableActor,
kEnableBarriers,
Commit: 100118ec5cc30a821523ca03357808f850ade688
https://github.com/scummvm/scummvm/commit/100118ec5cc30a821523ca03357808f850ade688
Author: Alexandre Fontoura (alexandrefontoura at gmail.com)
Date: 2021-05-17T15:35:35+02:00
Commit Message:
ASYLUM: More BlowUpPuzzle work. Press B to Switch between Scene & BlowUpPuzzle for test.
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@268 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/asylum.cpp
engines/asylum/asylum.h
engines/asylum/blowuppuzzle.cpp
engines/asylum/blowuppuzzle.h
engines/asylum/scene.h
engines/asylum/scriptman.cpp
diff --git a/engines/asylum/asylum.cpp b/engines/asylum/asylum.cpp
index aacb5d83ed..37ca4652a6 100644
--- a/engines/asylum/asylum.cpp
+++ b/engines/asylum/asylum.cpp
@@ -55,6 +55,7 @@ AsylumEngine::AsylumEngine(OSystem *system, Common::Language language)
AsylumEngine::~AsylumEngine() {
Common::clearAllDebugChannels();
+ delete _blowUp;
delete _console;
delete _scene;
delete _mainMenu;
@@ -81,6 +82,7 @@ Common::Error AsylumEngine::init() {
_console = new Console(this);
_mainMenu = 0;
_scene = 0;
+ _blowUp = 0;
return Common::kNoError;
}
@@ -102,6 +104,8 @@ Common::Error AsylumEngine::go() {
// Set up the game's main scene
_scene = new Scene(_screen, _sound, 5);
+ _blowUp = new BlowUpPuzzleVCR(_screen, _sound, _scene);
+
// TODO Since the ScriptMan is a singleton, setScene assignments could
// probably be rolled into the Scene constructor :D
ScriptMan.setScene(_scene);
@@ -147,11 +151,20 @@ void AsylumEngine::checkForEvent(bool doUpdate) {
_scene->enterScene();
} else if (_scene->isActive()) {
_mainMenu->openMenu();
+ } else if (_blowUp->isActive()) {
+ _blowUp->closeBlowUp();
+ _scene->enterScene();
}
return;
}
+ // FIXME: TEST ONLY
+ if (ev.kbd.keycode == Common::KEYCODE_b) {
+ //_mainMenu->closeMenu();
+ _blowUp->openBlowUp();
+ }
+
if (ev.kbd.flags == Common::KBD_CTRL) {
if (ev.kbd.keycode == Common::KEYCODE_d)
_console->attach();
@@ -161,7 +174,7 @@ void AsylumEngine::checkForEvent(bool doUpdate) {
}
if (doUpdate) {
- if (_mainMenu->isActive() || _scene->isActive()) {
+ if (_mainMenu->isActive() || _scene->isActive() || _blowUp->isActive()) {
// Copy background image
_screen->copyBackBufferToScreen();
}
@@ -176,6 +189,9 @@ void AsylumEngine::checkForEvent(bool doUpdate) {
} else if (_scene->isActive()) {
// Pass events to the game
_scene->handleEvent(&ev, doUpdate);
+ } else if (_blowUp->isActive()) {
+ // Pass events to BlowUp Puzzles
+ _blowUp->handleEvent(&ev, doUpdate);
}
}
diff --git a/engines/asylum/asylum.h b/engines/asylum/asylum.h
index e3927da760..74ac3ec208 100644
--- a/engines/asylum/asylum.h
+++ b/engines/asylum/asylum.h
@@ -35,6 +35,7 @@
#include "asylum/sound.h"
#include "asylum/video.h"
#include "asylum/scriptman.h"
+#include "asylum/blowuppuzzle.h"
namespace Asylum {
@@ -45,6 +46,8 @@ class Scene;
class Screen;
class Sound;
class Video;
+class BlowUpPuzzle;
+class BlowUpPuzzleVCR;
enum kDebugLevels {
kDebugLevelMain = 1 << 0,
@@ -78,12 +81,13 @@ private:
Common::Language _language;
Common::RandomSource _rnd;
- Console *_console;
- Scene *_scene;
- MainMenu *_mainMenu;
- Screen *_screen;
- Sound *_sound;
- Video *_video;
+ Console *_console;
+ Scene *_scene;
+ MainMenu *_mainMenu;
+ Screen *_screen;
+ Sound *_sound;
+ Video *_video;
+ BlowUpPuzzle *_blowUp;
friend class Console;
};
diff --git a/engines/asylum/blowuppuzzle.cpp b/engines/asylum/blowuppuzzle.cpp
index 047c04a5df..b6658e5f34 100644
--- a/engines/asylum/blowuppuzzle.cpp
+++ b/engines/asylum/blowuppuzzle.cpp
@@ -49,14 +49,20 @@ void BlowUpPuzzle::updateCursor() {
// BlowUp Puzzle VCR
BlowUpPuzzleVCR::BlowUpPuzzleVCR(Screen *screen, Sound *sound, Scene *scene) : BlowUpPuzzle(screen, sound, scene) {
- this->_mouseX = 0;
- _mouseY = 0;
- _leftClick = false;
- _curMouseCursor = 0;
- _cursorStep = 1;
- _active = false;
- _cursorResource = _scene->getGraphicResource(2);
- _bgResource = _scene->getGraphicResource(_scene->getResources()->getWorldStats()->grResId[0]);
+ _mouseX = 0;
+ _mouseY = 0;
+ _leftClick = false;
+ _curMouseCursor = 0;
+ _cursorStep = 1;
+ _active = false;
+ _cursorResource = _scene->getGraphicResource(_scene->getResources()->getWorldStats()->grResId[28]);
+ _bgResource = _scene->getGraphicResource(_scene->getResources()->getWorldStats()->grResId[0]);
+ _tvScreenAnimIdx = 0;
+ _isAccomplished = 0;
+
+ // reset all states
+ memset(&_jacksState,0,sizeof(_jacksState));
+ memset(&_buttonsState,0,sizeof(_buttonsState));
}
BlowUpPuzzleVCR::~BlowUpPuzzleVCR() {
@@ -67,14 +73,16 @@ BlowUpPuzzleVCR::~BlowUpPuzzleVCR() {
void BlowUpPuzzleVCR::openBlowUp() {
_active = true;
_scene->deactivate();
+ // FIXME: decomment this line when stopSfx works properly (it nows stop together SFX and Music
+ //_sound->stopSfx();
// Load the graphics palette
_screen->setPalette(_scene->getResourcePack(), 183);
-
+
// show blow up puzzle BG
- GraphicFrame *bg = _bgResource->getFrame(1);
+ GraphicFrame *bg = _bgResource->getFrame(0);
_screen->copyToBackBuffer((byte *)bg->surface.pixels, bg->surface.w, 0, 0, bg->surface.w, bg->surface.h);
-
+
// Set mouse cursor
_screen->setCursor(_cursorResource, 0);
_screen->showCursor();
@@ -108,7 +116,120 @@ void BlowUpPuzzleVCR::handleEvent(Common::Event *event, bool doUpdate) {
}
void BlowUpPuzzleVCR::update() {
- updateCursor();
+ //updateCursor();
+
+ if (_leftClick) {
+ _leftClick = false;
+ }
+
+ // VCR Jacks State
+ // 0 -> on table
+ // 1 -> pluged in red hole
+ // 2 -> pluged in yellow hole
+ // 3 -> pluged in black hole
+ // 4 -> show shadows
+ updateBlackJack();
+ updateRedJack();
+ updateYellowJack();
+}
+
+void BlowUpPuzzleVCR::updateBlackJack() {
+ int grResId = -1;
+ int frameNum = 0;
+ int x = 0;
+ int y = 0;
+
+ switch(_jacksState[kBlack]){
+ case kOnTable:
+ grResId = _scene->getResources()->getWorldStats()->grResId[1];
+ frameNum = 0;
+ x = 0;
+ y = 411;
+ break;
+ case kPluggedOnRed:
+ break;
+ case kPluggedOnYellow:
+ break;
+ case kPluggedOnBlack:
+ break;
+ case kShowShadows:
+ break;
+ default:
+ break;
+ }
+
+ if(grResId != -1)
+ {
+ GraphicResource *jack = _scene->getGraphicResource(grResId);
+ GraphicFrame *fra = jack->getFrame(0);
+ _screen->copyRectToScreenWithTransparency((byte *)fra->surface.pixels, fra->surface.w, x, y, fra->surface.w, fra->surface.h);
+ }
+}
+
+void BlowUpPuzzleVCR::updateRedJack() {
+ int grResId = -1;
+ int frameNum = 0;
+ int x = 0;
+ int y = 0;
+
+ switch(_jacksState[kRed]){
+ case kOnTable:
+ grResId = _scene->getResources()->getWorldStats()->grResId[2];
+ frameNum = 0;
+ x = 76;
+ y = 428;
+ break;
+ case kPluggedOnRed:
+ break;
+ case kPluggedOnYellow:
+ break;
+ case kPluggedOnBlack:
+ break;
+ case kShowShadows:
+ break;
+ default:
+ break;
+ }
+
+ if(grResId != -1)
+ {
+ GraphicResource *jack = _scene->getGraphicResource(grResId);
+ GraphicFrame *fra = jack->getFrame(0);
+ _screen->copyRectToScreenWithTransparency((byte *)fra->surface.pixels, fra->surface.w, x, y, fra->surface.w, fra->surface.h);
+ }
+}
+
+void BlowUpPuzzleVCR::updateYellowJack() {
+ int grResId = -1;
+ int frameNum = 0;
+ int x = 0;
+ int y = 0;
+
+ switch(_jacksState[kYellow]){
+ case kOnTable:
+ grResId = _scene->getResources()->getWorldStats()->grResId[3];
+ frameNum = 0;
+ x = 187;
+ y = 439;
+ break;
+ case kPluggedOnRed:
+ break;
+ case kPluggedOnYellow:
+ break;
+ case kPluggedOnBlack:
+ break;
+ case kShowShadows:
+ break;
+ default:
+ break;
+ }
+
+ if(grResId != -1)
+ {
+ GraphicResource *jack = _scene->getGraphicResource(grResId);
+ GraphicFrame *fra = jack->getFrame(0);
+ _screen->copyRectToScreenWithTransparency((byte *)fra->surface.pixels, fra->surface.w, x, y, fra->surface.w, fra->surface.h);
+ }
}
} // end of namespace Asylum
diff --git a/engines/asylum/blowuppuzzle.h b/engines/asylum/blowuppuzzle.h
index deeec690fd..4ba9950fe0 100644
--- a/engines/asylum/blowuppuzzle.h
+++ b/engines/asylum/blowuppuzzle.h
@@ -27,6 +27,7 @@
#define ASYLUM_BLOWUPPUZZLE_H_
#include "common/events.h"
+#include "common/rect.h"
#include "asylum/asylum.h"
#include "asylum/respack.h"
@@ -43,9 +44,9 @@ public:
BlowUpPuzzle(Screen *screen, Sound *sound, Scene *scene);
virtual ~BlowUpPuzzle();
- virtual void handleEvent(Common::Event *event, bool doUpdate);
- virtual void openBlowUp();
- virtual void closeBlowUp();
+ virtual void handleEvent(Common::Event *event, bool doUpdate){};
+ virtual void openBlowUp(){};
+ virtual void closeBlowUp(){};
bool isActive() { return _active; }
protected:
@@ -67,11 +68,28 @@ protected:
void updateCursor();
- virtual void update();
+ virtual void update() {};
}; // end of class BlowUpPuzzle
+
+
+
+
+/*const Common::Rect BlowUpPuzzleVCRPolies[10] = {
+ Common::Rect(0x0F7, 0x157, 0x13A, 0x183),
+ Common::Rect(0x14B, 0x15C, 0x17B, 0x18B),
+ Common::Rect(0x18C, 0x161, 0x1D2, 0x18F),
+ Common::Rect(0x1FB, 0x156, 0x233, 0x185),
+ Common::Rect(0x154, 0x196, 0x173, 0x1AF),
+ Common::Rect(0x19A, 0x19B, 0x1B9, 0x1B3),
+ Common::Rect(0x1E3, 0x1A0, 0x202, 0x1BC),
+ Common::Rect(0x0, 0x19B, 0x3C, 1E0),
+ Common::Rect(0x4C, 0x1AC, 0x0A0, 0x1E0),
+ Common::Rect(0x0BB, 0x1B7, 0x0F0, 0x1E0)
+};*/
+
class BlowUpPuzzleVCR : public BlowUpPuzzle {
public:
BlowUpPuzzleVCR(Screen *screen, Sound *sound, Scene *scene);
@@ -81,7 +99,35 @@ public:
void openBlowUp();
void closeBlowUp();
private:
+ enum Jack {
+ kBlack = 0,
+ kRed = 1,
+ kYellow = 2
+ };
+
+ enum JackState {
+ kOnTable = 0,
+ kPluggedOnRed = 1,
+ kPluggedOnYellow = 2,
+ kPluggedOnBlack = 3,
+ kShowShadows = 4
+ };
+
+ int _jacksState[3];
+ int _buttonsState[4];
+ int _tvScreenAnimIdx;
+ int _isAccomplished;
+ // TODO: members for playing sound
+
+ /*GraphicResource *_blackJack;
+ GraphicResource *_redJack;
+ GraphicResource *_yellowJack;*/
+
void update();
+
+ void updateBlackJack();
+ void updateRedJack();
+ void updateYellowJack();
}; // end of class BlowUpPuzzleVCR
diff --git a/engines/asylum/scene.h b/engines/asylum/scene.h
index 1335bf033e..bf2160d46f 100644
--- a/engines/asylum/scene.h
+++ b/engines/asylum/scene.h
@@ -33,14 +33,12 @@
#include "asylum/graphics.h"
#include "asylum/text.h"
#include "asylum/sceneres.h"
-#include "asylum/blowuppuzzle.h"
namespace Asylum {
class Screen;
class Sound;
class Text;
-class BlowUpPuzzle;
class SceneResource;
struct ActionDefinitions;
struct PolyDefinitions;
@@ -86,7 +84,6 @@ private:
Screen *_screen;
Sound *_sound;
- BlowUpPuzzle *_blowUp;
Common::Event *_ev;
Text *_text;
diff --git a/engines/asylum/scriptman.cpp b/engines/asylum/scriptman.cpp
index 05b6a0a641..bac848335a 100644
--- a/engines/asylum/scriptman.cpp
+++ b/engines/asylum/scriptman.cpp
@@ -352,7 +352,6 @@ void ScriptManager::processActionList() {
/* 0x37 */ case kRunBlowUpPuzzle: {
int blowUpPuzzleIdx = currentCommand.param1;
// TODO: do proper blow up puzzle initialization
- //_scene->_blowUp = new BlowUpPuzzleVCR(_scene->_screen, _scene->_sound, _scene);
}
break;
Commit: c00b822cb7e4241b0127f2854d63cca2965af1ff
https://github.com/scummvm/scummvm/commit/c00b822cb7e4241b0127f2854d63cca2965af1ff
Author: Alexandre Fontoura (alexandrefontoura at gmail.com)
Date: 2021-05-17T15:35:35+02:00
Commit Message:
ASYLUM: BlowUpPuzzleVCR cursor with animation while regions.
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@269 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/blowuppuzzle.cpp
engines/asylum/blowuppuzzle.h
diff --git a/engines/asylum/blowuppuzzle.cpp b/engines/asylum/blowuppuzzle.cpp
index b6658e5f34..f2428d274d 100644
--- a/engines/asylum/blowuppuzzle.cpp
+++ b/engines/asylum/blowuppuzzle.cpp
@@ -115,13 +115,18 @@ void BlowUpPuzzleVCR::handleEvent(Common::Event *event, bool doUpdate) {
update();
}
-void BlowUpPuzzleVCR::update() {
- //updateCursor();
+int BlowUpPuzzleVCR::inPolyRegion(int x, int y, int polyIdx) {
+ return x >= BlowUpPuzzleVCRPolies[polyIdx].left && x <= BlowUpPuzzleVCRPolies[polyIdx].right &&
+ y >= BlowUpPuzzleVCRPolies[polyIdx].top && y <= BlowUpPuzzleVCRPolies[polyIdx].bottom;
+}
+void BlowUpPuzzleVCR::update() {
if (_leftClick) {
_leftClick = false;
}
+ isCursorInPolyRegion();
+
// VCR Jacks State
// 0 -> on table
// 1 -> pluged in red hole
@@ -232,4 +237,27 @@ void BlowUpPuzzleVCR::updateYellowJack() {
}
}
+
+void BlowUpPuzzleVCR::isCursorInPolyRegion() {
+
+ // TODO: check if jack states are shadow, if not than do this
+ if(1) {
+ if(inPolyRegion(_mouseX, _mouseY, 0) ||
+ inPolyRegion(_mouseX, _mouseY, 1) ||
+ inPolyRegion(_mouseX, _mouseY, 2) ||
+ inPolyRegion(_mouseX, _mouseY, 3) ||
+ inPolyRegion(_mouseX, _mouseY, 7) ||
+ inPolyRegion(_mouseX, _mouseY, 8) ||
+ inPolyRegion(_mouseX, _mouseY, 9)) {
+ updateCursor();
+ } else {
+ if(_curMouseCursor != 0) { // reset cursor
+ _curMouseCursor = 0;
+ _cursorStep = 1;
+ updateCursor();
+ }
+ }
+ }
+}
+
} // end of namespace Asylum
diff --git a/engines/asylum/blowuppuzzle.h b/engines/asylum/blowuppuzzle.h
index 4ba9950fe0..e0e7e4335c 100644
--- a/engines/asylum/blowuppuzzle.h
+++ b/engines/asylum/blowuppuzzle.h
@@ -77,7 +77,7 @@ protected:
-/*const Common::Rect BlowUpPuzzleVCRPolies[10] = {
+const Common::Rect BlowUpPuzzleVCRPolies[10] = {
Common::Rect(0x0F7, 0x157, 0x13A, 0x183),
Common::Rect(0x14B, 0x15C, 0x17B, 0x18B),
Common::Rect(0x18C, 0x161, 0x1D2, 0x18F),
@@ -85,10 +85,10 @@ protected:
Common::Rect(0x154, 0x196, 0x173, 0x1AF),
Common::Rect(0x19A, 0x19B, 0x1B9, 0x1B3),
Common::Rect(0x1E3, 0x1A0, 0x202, 0x1BC),
- Common::Rect(0x0, 0x19B, 0x3C, 1E0),
+ Common::Rect(0x0, 0x19B, 0x3C, 0x1E0),
Common::Rect(0x4C, 0x1AC, 0x0A0, 0x1E0),
Common::Rect(0x0BB, 0x1B7, 0x0F0, 0x1E0)
-};*/
+};
class BlowUpPuzzleVCR : public BlowUpPuzzle {
public:
@@ -123,11 +123,15 @@ private:
GraphicResource *_redJack;
GraphicResource *_yellowJack;*/
+ int inPolyRegion(int x, int y, int polyIdx);
+
void update();
void updateBlackJack();
void updateRedJack();
void updateYellowJack();
+
+ void isCursorInPolyRegion();
}; // end of class BlowUpPuzzleVCR
Commit: e377059aeee205fb84ec42c6e5339ae5170baaa7
https://github.com/scummvm/scummvm/commit/e377059aeee205fb84ec42c6e5339ae5170baaa7
Author: Alexandre Fontoura (alexandrefontoura at gmail.com)
Date: 2021-05-17T15:35:36+02:00
Commit Message:
ASYLUM: Some work on grabbing Black Jack in VCR BlowUpPuzzle. It still buggy. See comments for more detail.
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@270 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/blowuppuzzle.cpp
engines/asylum/blowuppuzzle.h
diff --git a/engines/asylum/blowuppuzzle.cpp b/engines/asylum/blowuppuzzle.cpp
index f2428d274d..b0f6b857dc 100644
--- a/engines/asylum/blowuppuzzle.cpp
+++ b/engines/asylum/blowuppuzzle.cpp
@@ -51,7 +51,8 @@ void BlowUpPuzzle::updateCursor() {
BlowUpPuzzleVCR::BlowUpPuzzleVCR(Screen *screen, Sound *sound, Scene *scene) : BlowUpPuzzle(screen, sound, scene) {
_mouseX = 0;
_mouseY = 0;
- _leftClick = false;
+ _leftClickUp = false;
+ _leftClickDown = false;
_curMouseCursor = 0;
_cursorStep = 1;
_active = false;
@@ -87,7 +88,8 @@ void BlowUpPuzzleVCR::openBlowUp() {
_screen->setCursor(_cursorResource, 0);
_screen->showCursor();
- _leftClick = false;
+ _leftClickUp = false;
+ _leftClickDown = false;
_mouseX = _mouseY = 0;
}
@@ -105,13 +107,16 @@ void BlowUpPuzzleVCR::handleEvent(Common::Event *event, bool doUpdate) {
_mouseY = _ev->mouse.y;
break;
case Common::EVENT_LBUTTONUP:
- _leftClick = true;
+ _leftClickUp = true;
+ break;
+ case Common::EVENT_LBUTTONDOWN:
+ _leftClickDown = true;
break;
default:
break;
}
- if (doUpdate || _leftClick)
+ if (doUpdate || _leftClickUp || _leftClickDown)
update();
}
@@ -121,21 +126,23 @@ int BlowUpPuzzleVCR::inPolyRegion(int x, int y, int polyIdx) {
}
void BlowUpPuzzleVCR::update() {
- if (_leftClick) {
- _leftClick = false;
+ // TODO: set states
+ if (_leftClickDown) {
+ _leftClickDown = false;
+ handleMouseDown();
+ }
+
+ // TODO: put sound working
+ if (_leftClickUp) {
+ _leftClickUp = false;
+ handleMouseUp();
}
- isCursorInPolyRegion();
+ updateCursorInPolyRegion();
- // VCR Jacks State
- // 0 -> on table
- // 1 -> pluged in red hole
- // 2 -> pluged in yellow hole
- // 3 -> pluged in black hole
- // 4 -> show shadows
- updateBlackJack();
- updateRedJack();
updateYellowJack();
+ updateRedJack();
+ updateBlackJack();
}
void BlowUpPuzzleVCR::updateBlackJack() {
@@ -157,7 +164,34 @@ void BlowUpPuzzleVCR::updateBlackJack() {
break;
case kPluggedOnBlack:
break;
- case kShowShadows:
+ case kOnHand: {
+ // Jack info
+ int jackY = _mouseY;
+ if(_mouseY < 356) {
+ jackY = 356;
+ }
+
+ GraphicResource *j = _scene->getGraphicResource(_scene->getResources()->getWorldStats()->grResId[27]);
+ GraphicFrame *f = j->getFrame(0);
+
+ // FIXME: this must be a special copy to screen function to cut parts of the screen (shouldn't be calculated here
+ int newHeight = (480-_mouseY) + 14;
+ if (newHeight > f->surface.h) {
+ newHeight = f->surface.h;
+ }
+
+ _screen->copyRectToScreenWithTransparency((byte *)f->surface.pixels, f->surface.w, _mouseX - 114, jackY - 14, f->surface.w, newHeight);
+
+ // Shadow Info
+ int shadowY = (_mouseY - 356) / 4;
+ if(_mouseY < 356) {
+ shadowY = 356;
+ }
+ grResId = _scene->getResources()->getWorldStats()->grResId[30];
+ frameNum = 0;
+ x = _mouseX - shadowY;
+ y = 450;
+ }
break;
default:
break;
@@ -190,7 +224,7 @@ void BlowUpPuzzleVCR::updateRedJack() {
break;
case kPluggedOnBlack:
break;
- case kShowShadows:
+ case kOnHand:
break;
default:
break;
@@ -223,7 +257,7 @@ void BlowUpPuzzleVCR::updateYellowJack() {
break;
case kPluggedOnBlack:
break;
- case kShowShadows:
+ case kOnHand:
break;
default:
break;
@@ -238,18 +272,26 @@ void BlowUpPuzzleVCR::updateYellowJack() {
}
-void BlowUpPuzzleVCR::isCursorInPolyRegion() {
-
- // TODO: check if jack states are shadow, if not than do this
- if(1) {
- if(inPolyRegion(_mouseX, _mouseY, 0) ||
- inPolyRegion(_mouseX, _mouseY, 1) ||
- inPolyRegion(_mouseX, _mouseY, 2) ||
- inPolyRegion(_mouseX, _mouseY, 3) ||
- inPolyRegion(_mouseX, _mouseY, 7) ||
- inPolyRegion(_mouseX, _mouseY, 8) ||
- inPolyRegion(_mouseX, _mouseY, 9)) {
- updateCursor();
+void BlowUpPuzzleVCR::updateCursorInPolyRegion() {
+ int showCursor = 0;
+
+ if ( _jacksState[kBlack] == kOnHand ) {
+ showCursor = 1;
+ } else if ( _jacksState[kRed] == 4 ) {
+ showCursor = 2;
+ } else {
+ showCursor = ((_jacksState[kYellow] != 4) - 1) & 3;
+ }
+
+ if(showCursor) {
+ if(inPolyRegion(_mouseX, _mouseY, kRewindButton)
+ || inPolyRegion(_mouseX, _mouseY, kStopButton)
+ || inPolyRegion(_mouseX, _mouseY, kPlayButton)
+ || inPolyRegion(_mouseX, _mouseY, kRecButton)
+ || inPolyRegion(_mouseX, _mouseY, kBlackJack)
+ || inPolyRegion(_mouseX, _mouseY, kRedJack)
+ || inPolyRegion(_mouseX, _mouseY, kYellowJack)) {
+ //updateCursor();
} else {
if(_curMouseCursor != 0) { // reset cursor
_curMouseCursor = 0;
@@ -260,4 +302,34 @@ void BlowUpPuzzleVCR::isCursorInPolyRegion() {
}
}
+void BlowUpPuzzleVCR::handleMouseDown() {
+ // TODO: Jack hole regions
+ if(inPolyRegion(_mouseX, _mouseY, kRedHole)) { // red jack hole
+
+ }
+
+ if(inPolyRegion(_mouseX, _mouseY, kYellowHole)) { // yellow jack hole
+
+ }
+
+ if(inPolyRegion(_mouseX, _mouseY, kBlackHole)) { // black jack hole
+
+ }
+
+ // Get Jacks from Table
+ if (inPolyRegion(_mouseX, _mouseY, kBlackJack)) {
+ _jacksState[kBlack] = kOnHand;
+ } else if (inPolyRegion(_mouseX, _mouseY, kRedJack)) {
+ _jacksState[kRed] = kOnHand;
+ } else if (inPolyRegion(_mouseX, _mouseY, kYellowJack)) {
+ _jacksState[kYellow] = kOnHand;
+ }
+
+ // TODO: VCR button regions
+}
+
+void BlowUpPuzzleVCR::handleMouseUp() {
+
+}
+
} // end of namespace Asylum
diff --git a/engines/asylum/blowuppuzzle.h b/engines/asylum/blowuppuzzle.h
index e0e7e4335c..2a19d4c12d 100644
--- a/engines/asylum/blowuppuzzle.h
+++ b/engines/asylum/blowuppuzzle.h
@@ -60,7 +60,8 @@ protected:
uint32 _mouseY;
uint32 _curMouseCursor;
int32 _cursorStep;
- bool _leftClick;
+ bool _leftClickUp;
+ bool _leftClickDown;
bool _active;
GraphicResource *_bgResource;
@@ -78,16 +79,16 @@ protected:
const Common::Rect BlowUpPuzzleVCRPolies[10] = {
- Common::Rect(0x0F7, 0x157, 0x13A, 0x183),
- Common::Rect(0x14B, 0x15C, 0x17B, 0x18B),
- Common::Rect(0x18C, 0x161, 0x1D2, 0x18F),
- Common::Rect(0x1FB, 0x156, 0x233, 0x185),
- Common::Rect(0x154, 0x196, 0x173, 0x1AF),
- Common::Rect(0x19A, 0x19B, 0x1B9, 0x1B3),
- Common::Rect(0x1E3, 0x1A0, 0x202, 0x1BC),
- Common::Rect(0x0, 0x19B, 0x3C, 0x1E0),
- Common::Rect(0x4C, 0x1AC, 0x0A0, 0x1E0),
- Common::Rect(0x0BB, 0x1B7, 0x0F0, 0x1E0)
+ Common::Rect(0x0F7, 0x157, 0x13A, 0x183), // rewind button region
+ Common::Rect(0x14B, 0x15C, 0x17B, 0x18B), // stop button region
+ Common::Rect(0x18C, 0x161, 0x1D2, 0x18F), // play button region
+ Common::Rect(0x1FB, 0x156, 0x233, 0x185), // rec button region
+ Common::Rect(0x154, 0x196, 0x173, 0x1AF), // red jack hole region
+ Common::Rect(0x19A, 0x19B, 0x1B9, 0x1B3), // yellow jack hole region
+ Common::Rect(0x1E3, 0x1A0, 0x202, 0x1BC), // black jack hole region
+ Common::Rect(0x0, 0x19B, 0x3C, 0x1E0), // black jack on table region
+ Common::Rect(0x4C, 0x1AC, 0x0A0, 0x1E0), // red jack on table region
+ Common::Rect(0x0BB, 0x1B7, 0x0F0, 0x1E0) // yellow jack on table region
};
class BlowUpPuzzleVCR : public BlowUpPuzzle {
@@ -110,7 +111,20 @@ private:
kPluggedOnRed = 1,
kPluggedOnYellow = 2,
kPluggedOnBlack = 3,
- kShowShadows = 4
+ kOnHand = 4
+ };
+
+ enum VCRRegions {
+ kRewindButton = 0,
+ kStopButton = 1,
+ kPlayButton = 2,
+ kRecButton = 3,
+ kRedHole = 4,
+ kYellowHole = 5,
+ kBlackHole = 6,
+ kBlackJack = 7,
+ kRedJack = 8,
+ kYellowJack = 9
};
int _jacksState[3];
@@ -131,7 +145,10 @@ private:
void updateRedJack();
void updateYellowJack();
- void isCursorInPolyRegion();
+ void updateCursorInPolyRegion();
+
+ void handleMouseDown();
+ void handleMouseUp();
}; // end of class BlowUpPuzzleVCR
Commit: df4d55d55c5c1419934564f6309a7d5376ee7041
https://github.com/scummvm/scummvm/commit/df4d55d55c5c1419934564f6309a7d5376ee7041
Author: Alexandre Fontoura (alexandrefontoura at gmail.com)
Date: 2021-05-17T15:35:36+02:00
Commit Message:
ASYLUM: Fixed jack shadow and cursor update.
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@271 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/blowuppuzzle.cpp
diff --git a/engines/asylum/blowuppuzzle.cpp b/engines/asylum/blowuppuzzle.cpp
index b0f6b857dc..7623a5cf97 100644
--- a/engines/asylum/blowuppuzzle.cpp
+++ b/engines/asylum/blowuppuzzle.cpp
@@ -140,9 +140,9 @@ void BlowUpPuzzleVCR::update() {
updateCursorInPolyRegion();
- updateYellowJack();
+ updateBlackJack();
updateRedJack();
- updateBlackJack();
+ updateYellowJack();
}
void BlowUpPuzzleVCR::updateBlackJack() {
@@ -185,7 +185,7 @@ void BlowUpPuzzleVCR::updateBlackJack() {
// Shadow Info
int shadowY = (_mouseY - 356) / 4;
if(_mouseY < 356) {
- shadowY = 356;
+ shadowY = 0;
}
grResId = _scene->getResources()->getWorldStats()->grResId[30];
frameNum = 0;
@@ -277,13 +277,13 @@ void BlowUpPuzzleVCR::updateCursorInPolyRegion() {
if ( _jacksState[kBlack] == kOnHand ) {
showCursor = 1;
- } else if ( _jacksState[kRed] == 4 ) {
+ } else if ( _jacksState[kRed] == kOnHand ) {
showCursor = 2;
} else {
- showCursor = ((_jacksState[kYellow] != 4) - 1) & 3;
+ showCursor = ((_jacksState[kYellow] != kOnHand) - 1) & 3;
}
- if(showCursor) {
+ if(!showCursor) {
if(inPolyRegion(_mouseX, _mouseY, kRewindButton)
|| inPolyRegion(_mouseX, _mouseY, kStopButton)
|| inPolyRegion(_mouseX, _mouseY, kPlayButton)
@@ -291,15 +291,19 @@ void BlowUpPuzzleVCR::updateCursorInPolyRegion() {
|| inPolyRegion(_mouseX, _mouseY, kBlackJack)
|| inPolyRegion(_mouseX, _mouseY, kRedJack)
|| inPolyRegion(_mouseX, _mouseY, kYellowJack)) {
- //updateCursor();
+ updateCursor();
} else {
if(_curMouseCursor != 0) { // reset cursor
+ _screen->showCursor();
_curMouseCursor = 0;
_cursorStep = 1;
updateCursor();
}
}
+ } else {
+ _screen->hideCursor();
}
+
}
void BlowUpPuzzleVCR::handleMouseDown() {
Commit: 405fdc6e08f72e2b4d8766478e03eabdf1673a4b
https://github.com/scummvm/scummvm/commit/405fdc6e08f72e2b4d8766478e03eabdf1673a4b
Author: Alexandre Fontoura (alexandrefontoura at gmail.com)
Date: 2021-05-17T15:35:36+02:00
Commit Message:
ASYLUM: Fixed off-screen exceptions. First concept of display graphics by priority (Already working for VCR jacks).
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@272 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/blowuppuzzle.cpp
engines/asylum/blowuppuzzle.h
engines/asylum/screen.cpp
diff --git a/engines/asylum/blowuppuzzle.cpp b/engines/asylum/blowuppuzzle.cpp
index 7623a5cf97..ed047c9240 100644
--- a/engines/asylum/blowuppuzzle.cpp
+++ b/engines/asylum/blowuppuzzle.cpp
@@ -46,7 +46,44 @@ void BlowUpPuzzle::updateCursor() {
_screen->setCursor(_cursorResource, _curMouseCursor);
}
-// BlowUp Puzzle VCR
+void BlowUpPuzzle::addGraphicToQueue(GraphicQueueItem item) {
+ _queueItems.push_back(item);
+}
+
+void BlowUpPuzzle::updateGraphicsInQueue() {
+ // sort by priority first
+ graphicsSelectionSort();
+ for(uint i = 0; i < _queueItems.size(); i++) {
+ GraphicResource *jack = _scene->getGraphicResource(_queueItems[i].resId);
+ GraphicFrame *fra = jack->getFrame(_queueItems[i].frameIdx);
+ _screen->copyRectToScreenWithTransparency((byte *)fra->surface.pixels, fra->surface.w, _queueItems[i].x, _queueItems[i].y, fra->surface.w, fra->surface.h);
+ }
+}
+
+void BlowUpPuzzle::graphicsSelectionSort() {
+ uint minIdx;
+
+ for (uint i = 0; i < _queueItems.size() - 1; i++) {
+ minIdx = i;
+
+ for (uint j = i + 1; j < _queueItems.size(); j++)
+ if (_queueItems[j].priority > _queueItems[i].priority)
+ minIdx = j;
+
+ if(i != minIdx)
+ swapGraphicItem(i, minIdx);
+ }
+}
+
+void BlowUpPuzzle::swapGraphicItem(int item1, int item2) {
+ GraphicQueueItem temp;
+ temp = _queueItems[item1];
+ _queueItems[item1] = _queueItems[item2];
+ _queueItems[item2] = temp;
+}
+
+
+// BlowUp Puzzle VCR ---------------------------------------------------------------------------------------------
BlowUpPuzzleVCR::BlowUpPuzzleVCR(Screen *screen, Sound *sound, Scene *scene) : BlowUpPuzzle(screen, sound, scene) {
_mouseX = 0;
@@ -126,13 +163,13 @@ int BlowUpPuzzleVCR::inPolyRegion(int x, int y, int polyIdx) {
}
void BlowUpPuzzleVCR::update() {
- // TODO: set states
+ _queueItems.clear();
+
if (_leftClickDown) {
_leftClickDown = false;
handleMouseDown();
}
- // TODO: put sound working
if (_leftClickUp) {
_leftClickUp = false;
handleMouseUp();
@@ -143,20 +180,22 @@ void BlowUpPuzzleVCR::update() {
updateBlackJack();
updateRedJack();
updateYellowJack();
+
+ if(!_isAccomplished) {
+ updateGraphicsInQueue();
+ }
}
void BlowUpPuzzleVCR::updateBlackJack() {
- int grResId = -1;
- int frameNum = 0;
- int x = 0;
- int y = 0;
+ GraphicQueueItem jackItem;
switch(_jacksState[kBlack]){
case kOnTable:
- grResId = _scene->getResources()->getWorldStats()->grResId[1];
- frameNum = 0;
- x = 0;
- y = 411;
+ jackItem.resId = _scene->getResources()->getWorldStats()->grResId[1];
+ jackItem.frameIdx = 0;
+ jackItem.x = 0;
+ jackItem.y = 411;
+ jackItem.priority = 3;
break;
case kPluggedOnRed:
break;
@@ -165,58 +204,54 @@ void BlowUpPuzzleVCR::updateBlackJack() {
case kPluggedOnBlack:
break;
case kOnHand: {
- // Jack info
+ // Jack info --------------------------
int jackY = _mouseY;
if(_mouseY < 356) {
jackY = 356;
}
- GraphicResource *j = _scene->getGraphicResource(_scene->getResources()->getWorldStats()->grResId[27]);
- GraphicFrame *f = j->getFrame(0);
-
- // FIXME: this must be a special copy to screen function to cut parts of the screen (shouldn't be calculated here
- int newHeight = (480-_mouseY) + 14;
- if (newHeight > f->surface.h) {
- newHeight = f->surface.h;
- }
+ GraphicQueueItem jackItemOnHand;
+ jackItemOnHand.resId = _scene->getResources()->getWorldStats()->grResId[27];
+ jackItemOnHand.frameIdx = 0;
+ jackItemOnHand.x = _mouseX - 114;
+ jackItemOnHand.y = jackY - 14;
+ jackItemOnHand.priority = 1;
+
+ addGraphicToQueue(jackItemOnHand);
- _screen->copyRectToScreenWithTransparency((byte *)f->surface.pixels, f->surface.w, _mouseX - 114, jackY - 14, f->surface.w, newHeight);
-
- // Shadow Info
+ // Shadow Info -------------------------
int shadowY = (_mouseY - 356) / 4;
if(_mouseY < 356) {
shadowY = 0;
}
- grResId = _scene->getResources()->getWorldStats()->grResId[30];
- frameNum = 0;
- x = _mouseX - shadowY;
- y = 450;
+ jackItem.resId = _scene->getResources()->getWorldStats()->grResId[30];
+ jackItem.frameIdx = 0;
+ jackItem.x = _mouseX - shadowY;
+ jackItem.y = 450;
+ jackItem.priority = 2;
}
break;
default:
+ jackItem.resId = 0;
break;
}
- if(grResId != -1)
+ if(jackItem.resId != 0)
{
- GraphicResource *jack = _scene->getGraphicResource(grResId);
- GraphicFrame *fra = jack->getFrame(0);
- _screen->copyRectToScreenWithTransparency((byte *)fra->surface.pixels, fra->surface.w, x, y, fra->surface.w, fra->surface.h);
+ addGraphicToQueue(jackItem);
}
}
void BlowUpPuzzleVCR::updateRedJack() {
- int grResId = -1;
- int frameNum = 0;
- int x = 0;
- int y = 0;
+ GraphicQueueItem jackItem;
switch(_jacksState[kRed]){
case kOnTable:
- grResId = _scene->getResources()->getWorldStats()->grResId[2];
- frameNum = 0;
- x = 76;
- y = 428;
+ jackItem.resId = _scene->getResources()->getWorldStats()->grResId[2];
+ jackItem.frameIdx = 0;
+ jackItem.x = 76;
+ jackItem.y = 428;
+ jackItem.priority = 3;
break;
case kPluggedOnRed:
break;
@@ -227,29 +262,26 @@ void BlowUpPuzzleVCR::updateRedJack() {
case kOnHand:
break;
default:
+ jackItem.resId = 0;
break;
}
- if(grResId != -1)
+ if(jackItem.resId != 0)
{
- GraphicResource *jack = _scene->getGraphicResource(grResId);
- GraphicFrame *fra = jack->getFrame(0);
- _screen->copyRectToScreenWithTransparency((byte *)fra->surface.pixels, fra->surface.w, x, y, fra->surface.w, fra->surface.h);
+ addGraphicToQueue(jackItem);
}
}
void BlowUpPuzzleVCR::updateYellowJack() {
- int grResId = -1;
- int frameNum = 0;
- int x = 0;
- int y = 0;
+ GraphicQueueItem jackItem;
switch(_jacksState[kYellow]){
case kOnTable:
- grResId = _scene->getResources()->getWorldStats()->grResId[3];
- frameNum = 0;
- x = 187;
- y = 439;
+ jackItem.resId = _scene->getResources()->getWorldStats()->grResId[3];
+ jackItem.frameIdx = 0;
+ jackItem.x = 187;
+ jackItem.y = 439;
+ jackItem.priority = 3;
break;
case kPluggedOnRed:
break;
@@ -260,14 +292,13 @@ void BlowUpPuzzleVCR::updateYellowJack() {
case kOnHand:
break;
default:
+ jackItem.resId = 0;
break;
}
- if(grResId != -1)
+ if(jackItem.resId != 0)
{
- GraphicResource *jack = _scene->getGraphicResource(grResId);
- GraphicFrame *fra = jack->getFrame(0);
- _screen->copyRectToScreenWithTransparency((byte *)fra->surface.pixels, fra->surface.w, x, y, fra->surface.w, fra->surface.h);
+ addGraphicToQueue(jackItem);
}
}
diff --git a/engines/asylum/blowuppuzzle.h b/engines/asylum/blowuppuzzle.h
index 2a19d4c12d..36aa540827 100644
--- a/engines/asylum/blowuppuzzle.h
+++ b/engines/asylum/blowuppuzzle.h
@@ -39,6 +39,17 @@ class Scene;
class Screen;
class Sound;
+typedef struct GraphicQueueItem {
+ uint32 resId;
+ uint32 frameIdx;
+ uint32 x;
+ uint32 y;
+ uint32 flags;
+ uint32 transTableNum;
+ uint32 priority;
+
+} GraphicQueueItem;
+
class BlowUpPuzzle {
public:
BlowUpPuzzle(Screen *screen, Sound *sound, Scene *scene);
@@ -67,16 +78,21 @@ protected:
GraphicResource *_bgResource;
GraphicResource *_cursorResource;
- void updateCursor();
+ Common::Array<GraphicQueueItem> _queueItems;
+ void updateCursor();
virtual void update() {};
-}; // end of class BlowUpPuzzle
-
-
+ // This should probably be inside screen class
+ void addGraphicToQueue(GraphicQueueItem item);
+ void updateGraphicsInQueue();
+ void graphicsSelectionSort();
+ void swapGraphicItem(int item1, int item2);
+}; // end of class BlowUpPuzzle
+// ---- VCR -------------------
const Common::Rect BlowUpPuzzleVCRPolies[10] = {
Common::Rect(0x0F7, 0x157, 0x13A, 0x183), // rewind button region
@@ -133,10 +149,6 @@ private:
int _isAccomplished;
// TODO: members for playing sound
- /*GraphicResource *_blackJack;
- GraphicResource *_redJack;
- GraphicResource *_yellowJack;*/
-
int inPolyRegion(int x, int y, int polyIdx);
void update();
@@ -151,7 +163,6 @@ private:
void handleMouseUp();
}; // end of class BlowUpPuzzleVCR
-
} // end of namespace Asylum
#endif
diff --git a/engines/asylum/screen.cpp b/engines/asylum/screen.cpp
index a9408ed958..879b7c2e16 100644
--- a/engines/asylum/screen.cpp
+++ b/engines/asylum/screen.cpp
@@ -74,8 +74,8 @@ void Screen::copyRectToScreenWithTransparency(byte *buffer, int pitch, int x, in
for (int curY = 0; curY < height; curY++) {
for (int curX = 0; curX < width; curX++) {
- if (buffer[curX + curY * pitch] != 0) {
- screenBuffer[x + curX + (y + curY) * 640] = buffer[curX + curY * pitch];
+ if (buffer[curX + curY * pitch] != 0 && (x + curX + (y + curY) * 640 <= 640*480)) {
+ screenBuffer[x + curX + (y + curY) * 640] = buffer[curX + curY * pitch];
}
}
}
Commit: 141ac36aa818b6f4e542543545bc62de5423e762
https://github.com/scummvm/scummvm/commit/141ac36aa818b6f4e542543545bc62de5423e762
Author: Alexandre Fontoura (alexandrefontoura at gmail.com)
Date: 2021-05-17T15:35:36+02:00
Commit Message:
ASYLUM: Better implementation of grabbing jacks. All 3 jacks working now.
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@273 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/blowuppuzzle.cpp
engines/asylum/blowuppuzzle.h
diff --git a/engines/asylum/blowuppuzzle.cpp b/engines/asylum/blowuppuzzle.cpp
index ed047c9240..b3a8e28958 100644
--- a/engines/asylum/blowuppuzzle.cpp
+++ b/engines/asylum/blowuppuzzle.cpp
@@ -175,131 +175,152 @@ void BlowUpPuzzleVCR::update() {
handleMouseUp();
}
- updateCursorInPolyRegion();
-
updateBlackJack();
updateRedJack();
updateYellowJack();
+ updateCursorInPolyRegion();
+
if(!_isAccomplished) {
updateGraphicsInQueue();
}
}
-void BlowUpPuzzleVCR::updateBlackJack() {
- GraphicQueueItem jackItem;
+GraphicQueueItem BlowUpPuzzleVCR::getGraphicJackItem(int resId) {
+ GraphicQueueItem jackItemOnHand;
+
+ int jackY = _mouseY;
+ if(_mouseY < 356) {
+ jackY = 356;
+ }
+
+ jackItemOnHand.resId = _scene->getResources()->getWorldStats()->grResId[resId];
+ jackItemOnHand.frameIdx = 0;
+ jackItemOnHand.x = _mouseX - 114;
+ jackItemOnHand.y = jackY - 14;
+ jackItemOnHand.priority = 1;
+
+ return jackItemOnHand;
+}
- switch(_jacksState[kBlack]){
+GraphicQueueItem BlowUpPuzzleVCR::getGraphicShadowItem() {
+ GraphicQueueItem shadowItem;
+
+ int shadowY = (_mouseY - 356) / 4;
+ if(_mouseY < 356) {
+ shadowY = 0;
+ }
+ shadowItem.resId = _scene->getResources()->getWorldStats()->grResId[30];
+ shadowItem.frameIdx = 0;
+ shadowItem.x = _mouseX - shadowY;
+ shadowItem.y = 450;
+ shadowItem.priority = 2;
+
+ return shadowItem;
+}
+
+void BlowUpPuzzleVCR::updateJack(Jack jack, JackInfo onTable, JackInfo pluggedOnRed, JackInfo pluggedOnYellow, JackInfo pluggedOnBlack, int resIdOnHand) {
+ GraphicQueueItem item;
+
+ switch(_jacksState[jack]){
case kOnTable:
- jackItem.resId = _scene->getResources()->getWorldStats()->grResId[1];
- jackItem.frameIdx = 0;
- jackItem.x = 0;
- jackItem.y = 411;
- jackItem.priority = 3;
+ item.resId = _scene->getResources()->getWorldStats()->grResId[onTable.resId];
+ item.frameIdx = 0;
+ item.x = onTable.x;
+ item.y = onTable.y;
+ item.priority = 3;
break;
case kPluggedOnRed:
+ item.resId = _scene->getResources()->getWorldStats()->grResId[pluggedOnRed.resId];
+ item.frameIdx = 0;
+ item.x = 329;
+ item.y = 407;
+ item.priority = 3;
break;
case kPluggedOnYellow:
+ item.resId = _scene->getResources()->getWorldStats()->grResId[pluggedOnYellow.resId];
+ item.frameIdx = 0;
+ item.x = 402;
+ item.y = 413;
+ item.priority = 3;
break;
case kPluggedOnBlack:
+ item.resId = _scene->getResources()->getWorldStats()->grResId[pluggedOnBlack.resId];
+ item.frameIdx = 0;
+ item.x = 477;
+ item.y = 418;
+ item.priority = 3;
break;
case kOnHand: {
- // Jack info --------------------------
- int jackY = _mouseY;
- if(_mouseY < 356) {
- jackY = 356;
- }
-
- GraphicQueueItem jackItemOnHand;
- jackItemOnHand.resId = _scene->getResources()->getWorldStats()->grResId[27];
- jackItemOnHand.frameIdx = 0;
- jackItemOnHand.x = _mouseX - 114;
- jackItemOnHand.y = jackY - 14;
- jackItemOnHand.priority = 1;
-
+ GraphicQueueItem jackItemOnHand = getGraphicJackItem(resIdOnHand);
addGraphicToQueue(jackItemOnHand);
- // Shadow Info -------------------------
- int shadowY = (_mouseY - 356) / 4;
- if(_mouseY < 356) {
- shadowY = 0;
- }
- jackItem.resId = _scene->getResources()->getWorldStats()->grResId[30];
- jackItem.frameIdx = 0;
- jackItem.x = _mouseX - shadowY;
- jackItem.y = 450;
- jackItem.priority = 2;
- }
+ item = getGraphicShadowItem();
+ }
break;
default:
- jackItem.resId = 0;
+ item.resId = 0;
break;
}
- if(jackItem.resId != 0)
+ if(item.resId != 0)
{
- addGraphicToQueue(jackItem);
+ addGraphicToQueue(item);
}
}
+void BlowUpPuzzleVCR::updateBlackJack() {
+ JackInfo onTable;
+ onTable.resId = 1;
+ onTable.x = 0;
+ onTable.y = 411;
+
+ JackInfo pluggedOnRed;
+ pluggedOnRed.resId = 5;
+
+ JackInfo pluggedOnYellow;
+ pluggedOnYellow.resId = 8;
+
+ JackInfo pluggedOnBlack;
+ pluggedOnBlack.resId = 11;
+
+ updateJack(kBlack, onTable, pluggedOnRed, pluggedOnYellow, pluggedOnBlack, 27);
+}
+
void BlowUpPuzzleVCR::updateRedJack() {
- GraphicQueueItem jackItem;
+ JackInfo onTable;
+ onTable.resId = 2;
+ onTable.x = 76;
+ onTable.y = 428;
- switch(_jacksState[kRed]){
- case kOnTable:
- jackItem.resId = _scene->getResources()->getWorldStats()->grResId[2];
- jackItem.frameIdx = 0;
- jackItem.x = 76;
- jackItem.y = 428;
- jackItem.priority = 3;
- break;
- case kPluggedOnRed:
- break;
- case kPluggedOnYellow:
- break;
- case kPluggedOnBlack:
- break;
- case kOnHand:
- break;
- default:
- jackItem.resId = 0;
- break;
- }
+ JackInfo pluggedOnRed;
+ pluggedOnRed.resId = 4;
- if(jackItem.resId != 0)
- {
- addGraphicToQueue(jackItem);
- }
+ JackInfo pluggedOnYellow;
+ pluggedOnYellow.resId = 7;
+
+ JackInfo pluggedOnBlack;
+ pluggedOnBlack.resId = 10;
+
+ updateJack(kRed, onTable, pluggedOnRed, pluggedOnYellow, pluggedOnBlack, 25);
}
void BlowUpPuzzleVCR::updateYellowJack() {
- GraphicQueueItem jackItem;
+ JackInfo onTable;
+ onTable.resId = 3;
+ onTable.x = 187;
+ onTable.y = 439;
- switch(_jacksState[kYellow]){
- case kOnTable:
- jackItem.resId = _scene->getResources()->getWorldStats()->grResId[3];
- jackItem.frameIdx = 0;
- jackItem.x = 187;
- jackItem.y = 439;
- jackItem.priority = 3;
- break;
- case kPluggedOnRed:
- break;
- case kPluggedOnYellow:
- break;
- case kPluggedOnBlack:
- break;
- case kOnHand:
- break;
- default:
- jackItem.resId = 0;
- break;
- }
+ JackInfo pluggedOnRed;
+ pluggedOnRed.resId = 6;
- if(jackItem.resId != 0)
- {
- addGraphicToQueue(jackItem);
- }
+ JackInfo pluggedOnYellow;
+ pluggedOnYellow.resId = 9;
+
+ JackInfo pluggedOnBlack;
+ pluggedOnBlack.resId = 12;
+
+ updateJack(kYellow, onTable, pluggedOnRed, pluggedOnYellow, pluggedOnBlack, 26);
}
@@ -338,17 +359,42 @@ void BlowUpPuzzleVCR::updateCursorInPolyRegion() {
}
void BlowUpPuzzleVCR::handleMouseDown() {
- // TODO: Jack hole regions
- if(inPolyRegion(_mouseX, _mouseY, kRedHole)) { // red jack hole
+ /*int newState = 1; // v1
+ if(_jacksState[kBlack] != kOnHand) {
+ if(_jacksState[kRed] == kOnHand) {
+ newState = 2;
+ } else {
+ newState = ((_jacksState[kYellow] != kOnHand) - 1) & 3;
+ }
+ }*/
+ // TODO: put jacks in holes
+ if(inPolyRegion(_mouseX, _mouseY, kRedHole)) {
}
- if(inPolyRegion(_mouseX, _mouseY, kYellowHole)) { // yellow jack hole
-
+ if(inPolyRegion(_mouseX, _mouseY, kYellowHole)) {
}
- if(inPolyRegion(_mouseX, _mouseY, kBlackHole)) { // black jack hole
+ if(inPolyRegion(_mouseX, _mouseY, kBlackHole)) {
+ }
+ // Put jacks on table --
+ int jackType = 0;
+ if(_jacksState[kBlack] == kOnHand) {
+ jackType = kBlack+1;
+ } else if(_jacksState[kRed] == kOnHand) {
+ jackType = kRed+1;
+ } else {
+ jackType = ((_jacksState[kYellow] != kOnHand) - 1) & 3;
+ }
+ if(jackType) {
+ if (_mouseX >= (uint32)BlowUpPuzzleVCRPolies[kBlackJack].left && _mouseX <= (uint32)BlowUpPuzzleVCRPolies[kYellowJack].right &&
+ _mouseY >= (uint32)BlowUpPuzzleVCRPolies[kBlackJack].top && _mouseY <= (uint32)BlowUpPuzzleVCRPolies[kYellowJack].bottom) {
+ _jacksState[jackType-1] = kOnTable;
+ _sound->playSfx(_scene->getResourcePack(), _scene->getResources()->getWorldStats()->grResId[50]);
+ _screen->showCursor();
+ }
+ return;
}
// Get Jacks from Table
diff --git a/engines/asylum/blowuppuzzle.h b/engines/asylum/blowuppuzzle.h
index 36aa540827..e98d74a223 100644
--- a/engines/asylum/blowuppuzzle.h
+++ b/engines/asylum/blowuppuzzle.h
@@ -94,6 +94,12 @@ protected:
// ---- VCR -------------------
+typedef struct JackInfo {
+ uint32 resId;
+ uint32 x;
+ uint32 y;
+} JackInfo;
+
const Common::Rect BlowUpPuzzleVCRPolies[10] = {
Common::Rect(0x0F7, 0x157, 0x13A, 0x183), // rewind button region
Common::Rect(0x14B, 0x15C, 0x17B, 0x18B), // stop button region
@@ -153,6 +159,9 @@ private:
void update();
+ GraphicQueueItem getGraphicJackItem(int resId);
+ GraphicQueueItem getGraphicShadowItem();
+ void updateJack(Jack jack, JackInfo onTable, JackInfo pluggedOnRed, JackInfo pluggedOnYellow, JackInfo pluggedOnBlack, int resIdOnHand);
void updateBlackJack();
void updateRedJack();
void updateYellowJack();
Commit: 533ca05548cdd7f1d936645d811be81d7b2cc82a
https://github.com/scummvm/scummvm/commit/533ca05548cdd7f1d936645d811be81d7b2cc82a
Author: Alex Bevilacqua (alexbevi at gmail.com)
Date: 2021-05-17T15:35:37+02:00
Commit Message:
ASYLUM: A little more work on kEnableBarriers. None of the switch cases are there since none seem to be taken in Chapter 1. Also, all cases tend to alter Field_67C, which usually refers back to the script counter. Since nothing seems to affect the flags, I'm not sure if we're updating the scene properly :(
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@274 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/encounters.h
engines/asylum/scriptman.cpp
engines/asylum/scriptman.h
diff --git a/engines/asylum/encounters.h b/engines/asylum/encounters.h
index 840d4a4064..9eba976cd2 100644
--- a/engines/asylum/encounters.h
+++ b/engines/asylum/encounters.h
@@ -38,6 +38,17 @@ typedef struct EncounterItem {
uint16 value;
} EncounterItem;
+typedef struct EncounterStruct {
+ uint32 x1;
+ uint32 y1;
+ uint32 x2;
+ uint32 y2;
+ uint32 frameNum;
+ uint32 transTableNum;
+ uint32 status;
+ uint32 grResId;
+};
+
class Encounter {
public:
Encounter();
diff --git a/engines/asylum/scriptman.cpp b/engines/asylum/scriptman.cpp
index bac848335a..b436ec8dc1 100644
--- a/engines/asylum/scriptman.cpp
+++ b/engines/asylum/scriptman.cpp
@@ -34,13 +34,13 @@ static bool g_initialized = false;
ScriptManager::ScriptManager() {
if (!g_initialized) {
- g_initialized = true;
- _currentLine = 0;
- _currentLoops = 0;
- _processing = false;
- _delayedSceneIndex = -1;
- _delayedVideoIndex = -1;
- _allowInput = true;
+ g_initialized = true;
+ _currentLine = 0;
+ _currentLoops = 0;
+ _processing = false;
+ _delayedSceneIndex = -1;
+ _delayedVideoIndex = -1;
+ _allowInput = true;
memset(_gameFlags, 0, 1512);
}
@@ -145,7 +145,11 @@ void ScriptManager::processActionList() {
if (barrierIndex >= 0)
_scene->_sceneResource->getWorldStats()->barriers[barrierIndex].flags |= 0x20; // TODO - enums for flags (0x20 is visible/playing?)
else
- debugC(kDebugLevelScripts, "Requested invalid object ID:0x%02X in Scene %d Line %d.", currentCommand.param1, _scene->getSceneIndex(), _currentLine);
+ debugC(kDebugLevelScripts,
+ "Requested invalid object ID:0x%02X in Scene %d Line %d.",
+ currentCommand.param1,
+ _scene->getSceneIndex(),
+ _currentLine);
}
break;
@@ -160,7 +164,11 @@ void ScriptManager::processActionList() {
if ((actorIndex >= 0) && (actorIndex < _scene->_sceneResource->getWorldStats()->numActors))
_scene->actorVisible(actorIndex, false);
else
- debugC(kDebugLevelScripts, "Requested invalid actor ID:0x%02X in Scene %d Line %d.", currentCommand.param1, _scene->getSceneIndex(), _currentLine);
+ debugC(kDebugLevelScripts,
+ "Requested invalid actor ID:0x%02X in Scene %d Line %d.",
+ currentCommand.param1,
+ _scene->getSceneIndex(),
+ _currentLine);
}
break;
@@ -171,11 +179,14 @@ void ScriptManager::processActionList() {
else
actorIndex = currentCommand.param1;
- if ((actorIndex >= 0) && (actorIndex < _scene->_sceneResource->getWorldStats()->numActors)) {
+ if ((actorIndex >= 0) && (actorIndex < _scene->_sceneResource->getWorldStats()->numActors))
_scene->actorVisible(actorIndex, true);
- }
else
- debugC(kDebugLevelScripts, "Requested invalid actor ID:0x%02X in Scene %d Line %d.", currentCommand.param1, _scene->getSceneIndex(), _currentLine);
+ debugC(kDebugLevelScripts,
+ "Requested invalid actor ID:0x%02X in Scene %d Line %d.",
+ currentCommand.param1,
+ _scene->getSceneIndex(),
+ _currentLine);
}
break;
@@ -191,7 +202,11 @@ void ScriptManager::processActionList() {
_scene->setActorAction(actorIndex, currentCommand.param4);
}
else
- debugC(kDebugLevelScripts, "Requested invalid actor ID:0x%02X in Scene %d Script %d Line %d.", currentCommand.param1, _scene->getSceneIndex(), _currentLine);
+ debugC(kDebugLevelScripts,
+ "Requested invalid actor ID:0x%02X in Scene %d Script %d Line %d.",
+ currentCommand.param1,
+ _scene->getSceneIndex(),
+ _currentLine);
}
break;
@@ -205,55 +220,7 @@ void ScriptManager::processActionList() {
actorIndex = currentCommand.param1;
if (_scene->_sceneResource->getWorldStats()->actors[actorIndex].field_40 == 5) {
- /*
- v14 = 2468 * characterIndex;
- v19 = scene.characters[characterIndex].direction;
- if ( v19 > 4 )
- v20 = 8 - v19;
- else
- v20 = scene.characters[characterIndex].direction;
- v21 = scene.characters[0].grResTable[characterIndex + v20 + 616 * characterIndex + 5];
- LABEL_82:
- *(int *)((char *)&scene.characters[0].grResId + v14) = v21;
- v16 = v21;
- LABEL_83:
- *(int *)((char *)&scene.characters[0].frameCount + v14) = grGetFrameCount__(v16);
- *(int *)((char *)&scene.characters[0].frameNumber + v14) = 0;
- goto LABEL_84;
- default:
- goto LABEL_84;
- }
- while ( 1 )
- {
- v32 = *v30 < (unsigned __int8)*v31;
- if ( *v30 != *v31 )
- break;
- if ( !*v30 )
- goto LABEL_70;
- v42 = *(v30 + 1);
- v43 = *(v31 + 1);
- v33 = *(v30 + 1);
- v32 = v42 < v43;
- if ( v42 != v43 )
- break;
- v30 += 2;
- v31 += 2;
- if ( !v33 )
- {
- LABEL_70:
- v34 = 0;
- goto LABEL_72;
- }
- }
- v34 = -v32 - (v32 - 1);
- LABEL_72:
- if ( !v34 )
- v3 = 4;
- LABEL_84:
- result = 617 * v4;
- scene.characters[v4].field_40 = v3;
-
- */
+ enableActorSub(actorIndex, 4);
}
}
break;
@@ -261,20 +228,25 @@ void ScriptManager::processActionList() {
/* 0x0F */ case kEnableBarriers: {
int barIdx = _scene->_sceneResource->getBarrierIndexById(currentCommand.param1);
int sndIdx = currentCommand.param3;
- int v59 = currentCommand.param2;
- int v61 = _currentScript->counter; // actionList + 1773
-
- if (!v61 && _scene->getSceneIndex() != 13)
- _scene->_sound->playSfx(_scene->_resPack, ((sndIdx != 0) & 5) - 2146303999);
+ int v59 = currentCommand.param2;
+
+ if (!_currentScript->counter && _scene->getSceneIndex() != 13 && sndIdx != 0) {
+ // TODO
+ // Find a script that actually has a valid param3
+ // to see if this code is accurate :P
+ ResourcePack *tmpRes = new ResourcePack(12);
+ _scene->_sound->playSfx(tmpRes, ((sndIdx != 0) & 5) + 0x80120001);
+ delete tmpRes;
+ }
- if (v61 >= 3 * v59 - 1) {
+ if (_currentScript->counter >= 3 * v59 - 1) {
_currentScript->counter = 0;
_scene->_sceneResource->getWorldStats()->barriers[barIdx].field_67C = 0;
- // processActionListSub02(currentCommand.opcode, v59, _currentScript->counter, 2);
+ processActionListSub02(_currentScript, ¤tCommand, 2);
_currentLoops = 1; // v4 = 1;
} else {
int v64;
- int v62 = v61 + 1;
+ int v62 = _currentScript->counter + 1;
_currentScript->counter = v62;
if (sndIdx) {
v64 = 1;
@@ -285,7 +257,7 @@ void ScriptManager::processActionList() {
_scene->_sceneResource->getWorldStats()->barriers[barIdx].field_67C = v62 / v59 + 1;
}
- //processActionListSub02(currentCommand.opcode, v59, _currentScript->counter, v64);
+ processActionListSub02(_currentScript, ¤tCommand, v64);
}
}
@@ -301,7 +273,11 @@ void ScriptManager::processActionList() {
if (barrierIndex >= 0)
_scene->_sceneResource->getWorldStats()->barriers[barrierIndex].flags &= 0xFFFFDF; // TODO - enums for flags (0x20 is visible/playing?)
else
- debugC(kDebugLevelScripts, "Requested invalid object ID:0x%02X in Scene %d Line %d.", currentCommand.param1, _scene->getSceneIndex(), _currentLine);
+ debugC(kDebugLevelScripts,
+ "Requested invalid object ID:0x%02X in Scene %d Line %d.",
+ currentCommand.param1,
+ _scene->getSceneIndex(),
+ _currentLine);
}
break;
@@ -332,7 +308,9 @@ void ScriptManager::processActionList() {
/* 0x2A */ //case kJumpIfActorField638:
/* 0x2B */ case kChangeScene:
_delayedSceneIndex = currentCommand.param1 + 4;
- debug(kDebugLevelScripts, "Queueing Scene Change to scene %d...", currentCommand.param1 + 4);
+ debug(kDebugLevelScripts,
+ "Queueing Scene Change to scene %d...",
+ currentCommand.param1 + 4);
break;
/* 0x2C */ //case k_unk2C_ActorSub:
@@ -374,7 +352,8 @@ void ScriptManager::processActionList() {
waitCycle = true;
}
} else
- debugC(kDebugLevelScripts, "Requested invalid object ID:0x%02X in Scene %d Line %d.",
+ debugC(kDebugLevelScripts,
+ "Requested invalid object ID:0x%02X in Scene %d Line %d.",
currentCommand.param1,
_scene->getSceneIndex(),
_currentLine);
@@ -392,7 +371,11 @@ void ScriptManager::processActionList() {
else
_scene->_sound->playSfx(_scene->_speechPack, currentCommand.param1);
} else
- debugC(kDebugLevelScripts, "Requested invalid sound ID:0x%02X in Scene %d Line %d.", currentCommand.param1, _scene->getSceneIndex(), _currentLine);
+ debugC(kDebugLevelScripts,
+ "Requested invalid sound ID:0x%02X in Scene %d Line %d.",
+ currentCommand.param1,
+ _scene->getSceneIndex(),
+ _currentLine);
break;
/* 0x42 */ //case k_unk42:
@@ -430,7 +413,8 @@ void ScriptManager::processActionList() {
/* 0x62 */ //case k_unk62_SHOW_OPTIONS_SCREEN:
default:
- debugC(kDebugLevelScripts, "Unhandled opcode 0x%02X in Scene %d Line %d.",
+ debugC(kDebugLevelScripts,
+ "Unhandled opcode 0x%02X in Scene %d Line %d.",
currentCommand.opcode,
_scene->getSceneIndex(),
_currentLine);
@@ -454,7 +438,7 @@ void ScriptManager::processActionList() {
_processing = false;
}
-void ScriptManager::processActionListSub02(ActionCommand *command, int a3, int a4) {
+void ScriptManager::processActionListSub02(ActionDefinitions* script, ActionCommand *command, int a4) {
int v4 = 0;
int result;
int barrierIdx = 0;
@@ -472,24 +456,61 @@ void ScriptManager::processActionListSub02(ActionCommand *command, int a3, int a
v8 += 4;
}
}
-
+ // TODO
+ switch (_scene->getSceneIndex()) {
+ case 7:
+ warning("Scene 7 / v4 != 0 Not Implemented");
+ break;
+ case 6:
+ warning("Scene 6 / v4 != 0 Not Implemented");
+ break;
+ case 8:
+ warning("Scene 8 / v4 != 0 Not Implemented");
+ break;
+ case 3:
+ warning("Scene 3 / v4 != 0 Not Implemented");
+ break;
+ case 4:
+ warning("Scene 4 / v4 != 0 Not Implemented");
+ break;
+ default:
+ return;
+ }
+ } else {
+ int v13 = command->param4;
+ int v4 = script->counter / command->param2 + 4;
+ for (int i = 7; i > 0; i--) {
+ barrierIdx = _scene->getResources()->getBarrierIndexById(v13);
+ if (barrierIdx >= 0)
+ _scene->getResources()->getWorldStats()->barriers[barrierIdx].field_67C = v4;
+ v13 += 4;
+ }
+ // TODO
switch (_scene->getSceneIndex()) {
case 7:
+ warning("Scene 7 / v4 = 0 Not Implemented");
break;
case 6:
+ warning("Scene 6 / v4 = 0 Not Implemented");
break;
case 8:
+ warning("Scene 8 / v4 = 0 Not Implemented");
break;
case 3:
+ warning("Scene 3 / v4 = 0 Not Implemented");
break;
case 4:
+ warning("Scene 4 / v4 = 0 Not Implemented");
break;
default:
return;
}
+ }
+}
+
+void ScriptManager::enableActorSub(int actorIndex, int condition) {
- }
}
ScriptManager::~ScriptManager() {
diff --git a/engines/asylum/scriptman.h b/engines/asylum/scriptman.h
index 1b67680720..ad03f5346a 100644
--- a/engines/asylum/scriptman.h
+++ b/engines/asylum/scriptman.h
@@ -75,7 +75,8 @@ private:
// most sense
int _gameFlags[1512];
- void processActionListSub02(ActionCommand* command, int a3, int a4);
+ void processActionListSub02(ActionDefinitions* script, ActionCommand* command, int a4);
+ void enableActorSub(int actorIndex, int condition);
friend class Console;
Commit: 79101615725fc96d9d56230ed0edc796b5e1d97f
https://github.com/scummvm/scummvm/commit/79101615725fc96d9d56230ed0edc796b5e1d97f
Author: Alexandre Fontoura (alexandrefontoura at gmail.com)
Date: 2021-05-17T15:35:38+02:00
Commit Message:
ASYLUM: Fixed setPalette and fixed some warnings.
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@275 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/actor.cpp
engines/asylum/blowuppuzzle.cpp
engines/asylum/blowuppuzzle.h
engines/asylum/encounters.h
engines/asylum/screen.cpp
engines/asylum/scriptman.cpp
diff --git a/engines/asylum/actor.cpp b/engines/asylum/actor.cpp
index d75c6bca8a..815ddf405f 100644
--- a/engines/asylum/actor.cpp
+++ b/engines/asylum/actor.cpp
@@ -136,7 +136,7 @@ void MainActor::walkTo(Screen *screen, uint16 x, uint16 y) {
// Walking left...
if (x < _actorX) {
newAction = kWalkW;
- _actorX--;
+ _actorX-=2;
if (ABS(y - _actorY) <= 30) {
setAction(newAction);
drawActor(screen);
@@ -147,7 +147,7 @@ void MainActor::walkTo(Screen *screen, uint16 x, uint16 y) {
// Walking right...
if (x > _actorX) {
newAction = kWalkE;
- _actorX++;
+ _actorX+=2;
if (ABS(y - _actorY) <= 30) {
setAction(newAction);
drawActor(screen);
@@ -163,7 +163,7 @@ void MainActor::walkTo(Screen *screen, uint16 x, uint16 y) {
newAction = kWalkNE; // up right
else
newAction = kWalkN;
- _actorY--;
+ _actorY-=2;
}
// Walking down...
@@ -174,7 +174,7 @@ void MainActor::walkTo(Screen *screen, uint16 x, uint16 y) {
newAction = kWalkSE; // down right
else
newAction = kWalkS;
- _actorY++;
+ _actorY+=2;
}
setAction(newAction);
diff --git a/engines/asylum/blowuppuzzle.cpp b/engines/asylum/blowuppuzzle.cpp
index b3a8e28958..666b7d8c65 100644
--- a/engines/asylum/blowuppuzzle.cpp
+++ b/engines/asylum/blowuppuzzle.cpp
@@ -100,6 +100,7 @@ BlowUpPuzzleVCR::BlowUpPuzzleVCR(Screen *screen, Sound *sound, Scene *scene) : B
// reset all states
memset(&_jacksState,0,sizeof(_jacksState));
+ memset(&_holesState,0,sizeof(_holesState));
memset(&_buttonsState,0,sizeof(_buttonsState));
}
@@ -115,8 +116,8 @@ void BlowUpPuzzleVCR::openBlowUp() {
//_sound->stopSfx();
// Load the graphics palette
- _screen->setPalette(_scene->getResourcePack(), 183);
-
+ _screen->setPalette(_scene->getResourcePack(), _scene->getResources()->getWorldStats()->grResId[29]);
+
// show blow up puzzle BG
GraphicFrame *bg = _bgResource->getFrame(0);
_screen->copyToBackBuffer((byte *)bg->surface.pixels, bg->surface.w, 0, 0, bg->surface.w, bg->surface.h);
@@ -359,14 +360,14 @@ void BlowUpPuzzleVCR::updateCursorInPolyRegion() {
}
void BlowUpPuzzleVCR::handleMouseDown() {
- /*int newState = 1; // v1
+ int jackType = 1; // v1
if(_jacksState[kBlack] != kOnHand) {
if(_jacksState[kRed] == kOnHand) {
- newState = 2;
+ jackType = 2;
} else {
- newState = ((_jacksState[kYellow] != kOnHand) - 1) & 3;
+ jackType = ((_jacksState[kYellow] != kOnHand) - 1) & 3;
}
- }*/
+ }
// TODO: put jacks in holes
if(inPolyRegion(_mouseX, _mouseY, kRedHole)) {
@@ -379,7 +380,7 @@ void BlowUpPuzzleVCR::handleMouseDown() {
}
// Put jacks on table --
- int jackType = 0;
+ jackType = 0;
if(_jacksState[kBlack] == kOnHand) {
jackType = kBlack+1;
} else if(_jacksState[kRed] == kOnHand) {
diff --git a/engines/asylum/blowuppuzzle.h b/engines/asylum/blowuppuzzle.h
index e98d74a223..034c1a9b42 100644
--- a/engines/asylum/blowuppuzzle.h
+++ b/engines/asylum/blowuppuzzle.h
@@ -150,6 +150,7 @@ private:
};
int _jacksState[3];
+ int _holesState[3];
int _buttonsState[4];
int _tvScreenAnimIdx;
int _isAccomplished;
diff --git a/engines/asylum/encounters.h b/engines/asylum/encounters.h
index 9eba976cd2..7c89970909 100644
--- a/engines/asylum/encounters.h
+++ b/engines/asylum/encounters.h
@@ -47,7 +47,7 @@ typedef struct EncounterStruct {
uint32 transTableNum;
uint32 status;
uint32 grResId;
-};
+} EncounterStruct;
class Encounter {
public:
diff --git a/engines/asylum/screen.cpp b/engines/asylum/screen.cpp
index 879b7c2e16..f1dc2ec53f 100644
--- a/engines/asylum/screen.cpp
+++ b/engines/asylum/screen.cpp
@@ -87,7 +87,10 @@ void Screen::setPalette(byte *rgbPalette) {
byte palette[256 * 4];
byte *p = rgbPalette;
- for (int i = 0; i < 256; i++) {
+ // skip first color and set it to black always.
+ memset(palette, 0, 4); p+=3;
+
+ for (int i = 1; i < 256; i++) {
palette[i * 4 + 0] = *p++ << 2;
palette[i * 4 + 1] = *p++ << 2;
palette[i * 4 + 2] = *p++ << 2;
diff --git a/engines/asylum/scriptman.cpp b/engines/asylum/scriptman.cpp
index b436ec8dc1..5a826ce82d 100644
--- a/engines/asylum/scriptman.cpp
+++ b/engines/asylum/scriptman.cpp
@@ -227,15 +227,15 @@ void ScriptManager::processActionList() {
/* 0x0F */ case kEnableBarriers: {
int barIdx = _scene->_sceneResource->getBarrierIndexById(currentCommand.param1);
- int sndIdx = currentCommand.param3;
- int v59 = currentCommand.param2;
+ uint32 sndIdx = currentCommand.param3;
+ uint32 v59 = currentCommand.param2;
if (!_currentScript->counter && _scene->getSceneIndex() != 13 && sndIdx != 0) {
// TODO
// Find a script that actually has a valid param3
// to see if this code is accurate :P
ResourcePack *tmpRes = new ResourcePack(12);
- _scene->_sound->playSfx(tmpRes, ((sndIdx != 0) & 5) + 0x80120001);
+ _scene->_sound->playSfx(tmpRes, ((int)(sndIdx != 0) & 5) + 0x80120001);
delete tmpRes;
}
Commit: 18197d210667a44c8ef472e4f16613e370e3268c
https://github.com/scummvm/scummvm/commit/18197d210667a44c8ef472e4f16613e370e3268c
Author: Alexandre Fontoura (alexandrefontoura at gmail.com)
Date: 2021-05-17T15:35:38+02:00
Commit Message:
ASYLUM: Implementation of plug-in/out jacks on VCR BlowUpPuzzle.
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@276 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/blowuppuzzle.cpp
engines/asylum/blowuppuzzle.h
diff --git a/engines/asylum/blowuppuzzle.cpp b/engines/asylum/blowuppuzzle.cpp
index 666b7d8c65..60d5cd89d0 100644
--- a/engines/asylum/blowuppuzzle.cpp
+++ b/engines/asylum/blowuppuzzle.cpp
@@ -90,6 +90,7 @@ BlowUpPuzzleVCR::BlowUpPuzzleVCR(Screen *screen, Sound *sound, Scene *scene) : B
_mouseY = 0;
_leftClickUp = false;
_leftClickDown = false;
+ _rightClickDown = false;
_curMouseCursor = 0;
_cursorStep = 1;
_active = false;
@@ -128,6 +129,7 @@ void BlowUpPuzzleVCR::openBlowUp() {
_leftClickUp = false;
_leftClickDown = false;
+ _rightClickDown = false;
_mouseX = _mouseY = 0;
}
@@ -150,6 +152,9 @@ void BlowUpPuzzleVCR::handleEvent(Common::Event *event, bool doUpdate) {
case Common::EVENT_LBUTTONDOWN:
_leftClickDown = true;
break;
+ case Common::EVENT_RBUTTONDOWN:
+ _rightClickDown = true;
+ break;
default:
break;
}
@@ -166,6 +171,13 @@ int BlowUpPuzzleVCR::inPolyRegion(int x, int y, int polyIdx) {
void BlowUpPuzzleVCR::update() {
_queueItems.clear();
+ if (_rightClickDown) { // quits BlowUp Puzzle
+ _rightClickDown = false;
+ closeBlowUp();
+ // TODO: stop sound fx grResId[47] (TV On sfx)
+ _scene->enterScene();
+ }
+
if (_leftClickDown) {
_leftClickDown = false;
handleMouseDown();
@@ -329,9 +341,9 @@ void BlowUpPuzzleVCR::updateCursorInPolyRegion() {
int showCursor = 0;
if ( _jacksState[kBlack] == kOnHand ) {
- showCursor = 1;
+ showCursor = kBlack+1;
} else if ( _jacksState[kRed] == kOnHand ) {
- showCursor = 2;
+ showCursor = kRed+1;
} else {
showCursor = ((_jacksState[kYellow] != kOnHand) - 1) & 3;
}
@@ -346,11 +358,22 @@ void BlowUpPuzzleVCR::updateCursorInPolyRegion() {
|| inPolyRegion(_mouseX, _mouseY, kYellowJack)) {
updateCursor();
} else {
- if(_curMouseCursor != 0) { // reset cursor
- _screen->showCursor();
- _curMouseCursor = 0;
- _cursorStep = 1;
- updateCursor();
+ if(inPolyRegion(_mouseX, _mouseY, kRedHole) && _holesState[kPluggedOnRed-1]
+ || inPolyRegion(_mouseX, _mouseY, kYellowHole) && _holesState[kPluggedOnYellow-1]
+ || inPolyRegion(_mouseX, _mouseY, kBlackHole) && _holesState[kPluggedOnBlack-1]) {
+ if(_curMouseCursor != 2) { // reset cursor
+ _screen->showCursor();
+ _curMouseCursor = 2;
+ _cursorStep = 1;
+ updateCursor();
+ }
+ } else {
+ if(_curMouseCursor != 0) { // reset cursor
+ _screen->showCursor();
+ _curMouseCursor = 0;
+ _cursorStep = 1;
+ updateCursor();
+ }
}
}
} else {
@@ -359,28 +382,30 @@ void BlowUpPuzzleVCR::updateCursorInPolyRegion() {
}
-void BlowUpPuzzleVCR::handleMouseDown() {
- int jackType = 1; // v1
- if(_jacksState[kBlack] != kOnHand) {
- if(_jacksState[kRed] == kOnHand) {
- jackType = 2;
- } else {
- jackType = ((_jacksState[kYellow] != kOnHand) - 1) & 3;
+// common function to set and unset the jack on holes for each type of jack
+int BlowUpPuzzleVCR::setJackOnHole(int jackType, JackState plugged) {
+ if(!_holesState[plugged-1]) {
+ if(_jacksState[jackType-1] == kOnHand) {
+ _jacksState[jackType-1] = plugged;
+ _holesState[plugged-1] = jackType; // set jack on red
+ _sound->playSfx(_scene->getResourcePack(), _scene->getResources()->getWorldStats()->grResId[44]);
}
+ } else if(jackType == 0) {
+ jackType = _holesState[plugged-1];
+ _jacksState[jackType-1] = kOnHand;
+ _holesState[plugged-1] = 0;
+ _sound->playSfx(_scene->getResourcePack(), _scene->getResources()->getWorldStats()->grResId[43]);
+ return 0;
}
+ return 1;
+}
- // TODO: put jacks in holes
- if(inPolyRegion(_mouseX, _mouseY, kRedHole)) {
- }
-
- if(inPolyRegion(_mouseX, _mouseY, kYellowHole)) {
- }
+void BlowUpPuzzleVCR::handleMouseDown() {
- if(inPolyRegion(_mouseX, _mouseY, kBlackHole)) {
- }
+ if(_isAccomplished)
+ return;
- // Put jacks on table --
- jackType = 0;
+ int jackType = 0;
if(_jacksState[kBlack] == kOnHand) {
jackType = kBlack+1;
} else if(_jacksState[kRed] == kOnHand) {
@@ -388,6 +413,25 @@ void BlowUpPuzzleVCR::handleMouseDown() {
} else {
jackType = ((_jacksState[kYellow] != kOnHand) - 1) & 3;
}
+
+ // Plug-in jacks
+ if(inPolyRegion(_mouseX, _mouseY, kRedHole)) {
+ if(!setJackOnHole(jackType, kPluggedOnRed)) {
+ return;
+ }
+ }
+ if(inPolyRegion(_mouseX, _mouseY, kYellowHole)) {
+ if(!setJackOnHole(jackType, kPluggedOnYellow)) {
+ return;
+ }
+ }
+ if(inPolyRegion(_mouseX, _mouseY, kBlackHole)) {
+ if(!setJackOnHole(jackType, kPluggedOnBlack)) {
+ return;
+ }
+ }
+
+ // Put jacks on table --
if(jackType) {
if (_mouseX >= (uint32)BlowUpPuzzleVCRPolies[kBlackJack].left && _mouseX <= (uint32)BlowUpPuzzleVCRPolies[kYellowJack].right &&
_mouseY >= (uint32)BlowUpPuzzleVCRPolies[kBlackJack].top && _mouseY <= (uint32)BlowUpPuzzleVCRPolies[kYellowJack].bottom) {
diff --git a/engines/asylum/blowuppuzzle.h b/engines/asylum/blowuppuzzle.h
index 034c1a9b42..a3f93372af 100644
--- a/engines/asylum/blowuppuzzle.h
+++ b/engines/asylum/blowuppuzzle.h
@@ -73,6 +73,7 @@ protected:
int32 _cursorStep;
bool _leftClickUp;
bool _leftClickDown;
+ bool _rightClickDown;
bool _active;
GraphicResource *_bgResource;
@@ -154,7 +155,6 @@ private:
int _buttonsState[4];
int _tvScreenAnimIdx;
int _isAccomplished;
- // TODO: members for playing sound
int inPolyRegion(int x, int y, int polyIdx);
@@ -169,6 +169,7 @@ private:
void updateCursorInPolyRegion();
+ int setJackOnHole(int jackType, JackState plugged);
void handleMouseDown();
void handleMouseUp();
}; // end of class BlowUpPuzzleVCR
Commit: 17959bf9306eb783460f2e002d895b9f9975f92d
https://github.com/scummvm/scummvm/commit/17959bf9306eb783460f2e002d895b9f9975f92d
Author: Alex Bevilacqua (alexbevi at gmail.com)
Date: 2021-05-17T15:35:38+02:00
Commit Message:
ASYLUM: More accurate implementation of kPlaySpeech
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@278 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/scriptman.cpp
diff --git a/engines/asylum/scriptman.cpp b/engines/asylum/scriptman.cpp
index 5a826ce82d..4225f56f1e 100644
--- a/engines/asylum/scriptman.cpp
+++ b/engines/asylum/scriptman.cpp
@@ -363,19 +363,24 @@ void ScriptManager::processActionList() {
/* 0x3E */ //case kUpdateMatteBars:
/* 0x3F */ //case k_unk3F:
/* 0x40 */ //case k_unk40_SOUND:
-/* 0x41 */ case kPlaySpeech:
+/* 0x41 */ case kPlaySpeech: {
// TODO - Add support for other param options
- if (currentCommand.param1 >= 0) {
- if (currentCommand.param3 && currentCommand.param1 > 0) // HACK - Find out why sometimes an offset is needed and other times not
- _scene->_sound->playSfx(_scene->_speechPack, currentCommand.param1 - 9);
- else
- _scene->_sound->playSfx(_scene->_speechPack, currentCommand.param1);
+ uint32 sndIdx = currentCommand.param1;
+ if ((int)currentCommand.param1 >= 0) {
+ if (sndIdx >= 259) {
+ sndIdx -= 9;
+ _scene->_sound->playSfx(_scene->_speechPack, sndIdx - 0x7FFD0000);
+ } else {
+ _scene->_sound->playSfx(_scene->_speechPack, sndIdx);
+ }
+
} else
debugC(kDebugLevelScripts,
"Requested invalid sound ID:0x%02X in Scene %d Line %d.",
currentCommand.param1,
_scene->getSceneIndex(),
_currentLine);
+ }
break;
/* 0x42 */ //case k_unk42:
Commit: a60787820757b7ac945c384fe40c4f2ab993a870
https://github.com/scummvm/scummvm/commit/a60787820757b7ac945c384fe40c4f2ab993a870
Author: Alex Bevilacqua (alexbevi at gmail.com)
Date: 2021-05-17T15:35:38+02:00
Commit Message:
ASYLUM: Cleanup and comments
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@279 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/scene.cpp
engines/asylum/scene.h
engines/asylum/scriptman.cpp
diff --git a/engines/asylum/scene.cpp b/engines/asylum/scene.cpp
index d4a1179101..6f6a7856b0 100644
--- a/engines/asylum/scene.cpp
+++ b/engines/asylum/scene.cpp
@@ -220,6 +220,43 @@ void Scene::handleEvent(Common::Event *event, bool doUpdate) {
}
void Scene::updateCursor() {
+ uint32 newCursor = 0;
+
+ // Change cursor
+ switch (_sceneResource->getMainActor()->getCurrentAction()) {
+ case kWalkN:
+ newCursor = _sceneResource->getWorldStats()->commonRes.curScrollUp;
+ break;
+ case kWalkNE:
+ newCursor = _sceneResource->getWorldStats()->commonRes.curScrollUpRight;
+ break;
+ case kWalkNW:
+ newCursor = _sceneResource->getWorldStats()->commonRes.curScrollUpLeft;
+ break;
+ case kWalkS:
+ newCursor = _sceneResource->getWorldStats()->commonRes.curScrollDown;
+ break;
+ case kWalkSE:
+ newCursor = _sceneResource->getWorldStats()->commonRes.curScrollDownRight;
+ break;
+ case kWalkSW:
+ newCursor = _sceneResource->getWorldStats()->commonRes.curScrollDownLeft;
+ break;
+ case kWalkW:
+ newCursor = _sceneResource->getWorldStats()->commonRes.curScrollLeft;
+ break;
+ case kWalkE:
+ newCursor = _sceneResource->getWorldStats()->commonRes.curScrollRight;
+ break;
+ }
+
+ if (_cursorResource->getEntryNum() != newCursor) {
+ delete _cursorResource;
+ _cursorResource = new GraphicResource(_resPack, newCursor);
+ }
+}
+
+void Scene::animateCursor() {
_curMouseCursor += _cursorStep;
if (_curMouseCursor == 0)
_cursorStep = 1;
@@ -242,9 +279,19 @@ void Scene::update() {
// debugScreenScrolling(bg);
// Copy the background to the back buffer before updating the scene animations
- _screen->copyToBackBuffer(((byte *)bg->surface.pixels) + _startY * bg->surface.w + _startX, bg->surface.w, 0, 0, 640, 480);
-
+ _screen->copyToBackBuffer(((byte *)bg->surface.pixels) + _startY * bg->surface.w + _startX,
+ bg->surface.w,
+ 0,
+ 0,
+ 640,
+ 480);
+
+ // TODO
+ // This is a hack for scene 1. This really shouldn't be hardcoded, as the
+ // activation of this barrier should be interpreted by the script manager,
+ // but at the moment, we're not sure where it is in the script.
updateBarrier(_screen, _resPack, 1); // inside the middle room
+
for(uint b=0; b < _sceneResource->getWorldStats()->barriers.size(); b++) {
if ((_sceneResource->getWorldStats()->barriers[b].flags & 0x20) != 0) // TODO - enums for flags (0x20 is visible/playing?)
updateBarrier(_screen, _resPack, b);
@@ -257,41 +304,7 @@ void Scene::update() {
mainActor->drawActor(_screen);
} else {
mainActor->walkTo(_screen, _mouseX, _mouseY);
-
- uint32 newCursor = 0;
-
- // Change cursor
- switch (mainActor->getCurrentAction()) {
- case kWalkN:
- newCursor = worldStats->commonRes.curScrollUp;
- break;
- case kWalkNE:
- newCursor = worldStats->commonRes.curScrollUpRight;
- break;
- case kWalkNW:
- newCursor = worldStats->commonRes.curScrollUpLeft;
- break;
- case kWalkS:
- newCursor = worldStats->commonRes.curScrollDown;
- break;
- case kWalkSE:
- newCursor = worldStats->commonRes.curScrollDownRight;
- break;
- case kWalkSW:
- newCursor = worldStats->commonRes.curScrollDownLeft;
- break;
- case kWalkW:
- newCursor = worldStats->commonRes.curScrollLeft;
- break;
- case kWalkE:
- newCursor = worldStats->commonRes.curScrollRight;
- break;
- }
-
- if (_cursorResource->getEntryNum() != newCursor) {
- delete _cursorResource;
- _cursorResource = new GraphicResource(_resPack, newCursor);
- }
+ updateCursor();
}
if (g_debugPolygons)
@@ -304,7 +317,7 @@ void Scene::update() {
BarrierItem b = worldStats->barriers[p];
if (b.flags & 0x20) {
if ((b.boundingRect.left + b.x <= _mouseX + _startX) && (_mouseX + _startX < b.boundingRect.right + b.x) && (b.boundingRect.top + b.y <= _mouseY + _startY) && (_mouseY + _startY < b.boundingRect.bottom + b.y)) {
- updateCursor();
+ animateCursor();
curBarrier = (int32)p;
break;
}
@@ -323,7 +336,7 @@ void Scene::update() {
if (poly.boundingRect.contains(_mouseX + _startX, _mouseY + _startY)) {
if (pointInPoly(&poly, _mouseX + _startX, _mouseY + _startY)) {
curHotspot = (int32)p;
- updateCursor();
+ animateCursor();
break;
}
}
@@ -356,24 +369,7 @@ void Scene::update() {
worldStats->actions[a].actionListIdx2,
worldStats->actions[a].actionType,
worldStats->actions[a].soundResId);
-
- // TODO
- // This isn't always loading the right audio resources when it processes
- // the action list ... investigate
ScriptMan.setScript(&_sceneResource->getActionList()->actions[worldStats->actions[a].actionListIdx1]);
-
- /*
- // TODO: This should all be moved to a script related class
- ActionDefinitions actionDefs = _sceneResource->getActionList()->actions[worldStats->actions[a].actionListIdx1];
- for (int command = 0; command < 161; command++) {
- if (actionDefs.commands[command].opcode == 65) { // play voice
- _sound->playSfx(_speechPack, actionDefs.commands[command].param1);
- //_text->drawResText(actionDefs.commands[command].param1+83);
- // TODO: param2 (usually 1) -> number of loops?
- }
- }
- break;
- */
}
}
} else if (curBarrier >= 0) {
@@ -503,7 +499,9 @@ void Scene::debugScreenScrolling(GraphicFrame *bg) {
// WALK REGION DEBUG
void Scene::debugShowWalkRegion(PolyDefinitions *poly) {
Graphics::Surface surface;
- surface.create(poly->boundingRect.right - poly->boundingRect.left + 1, poly->boundingRect.bottom - poly->boundingRect.top + 1, 1);
+ surface.create(poly->boundingRect.right - poly->boundingRect.left + 1,
+ poly->boundingRect.bottom - poly->boundingRect.top + 1,
+ 1);
// Draw all lines in Polygon
for (uint32 i=0; i < poly->numPoints; i++) {
@@ -524,7 +522,9 @@ void Scene::debugShowPolygons() {
for (uint32 p = 0; p < _sceneResource->getGamePolygons()->numEntries; p++) {
Graphics::Surface surface;
PolyDefinitions poly = _sceneResource->getGamePolygons()->polygons[p];
- surface.create(poly.boundingRect.right - poly.boundingRect.left + 1, poly.boundingRect.bottom - poly.boundingRect.top + 1, 1);
+ surface.create(poly.boundingRect.right - poly.boundingRect.left + 1,
+ poly.boundingRect.bottom - poly.boundingRect.top + 1,
+ 1);
// Draw all lines in Polygon
for (uint32 i=0; i < poly.numPoints; i++) {
@@ -548,7 +548,9 @@ void Scene::debugShowBarriers() {
BarrierItem b = _sceneResource->getWorldStats()->barriers[p];
if (b.flags & 0x20) {
- surface.create(b.boundingRect.right - b.boundingRect.left + 1, b.boundingRect.bottom - b.boundingRect.top + 1, 1);
+ surface.create(b.boundingRect.right - b.boundingRect.left + 1,
+ b.boundingRect.bottom - b.boundingRect.top + 1,
+ 1);
surface.frameRect(b.boundingRect, 0x22);
copyToBackBufferClipped(&surface, b.x, b.y);
}
diff --git a/engines/asylum/scene.h b/engines/asylum/scene.h
index bf2160d46f..d27bef199e 100644
--- a/engines/asylum/scene.h
+++ b/engines/asylum/scene.h
@@ -102,7 +102,19 @@ private:
bool _isActive;
void update();
+
+ /**
+ * Check whether the cursor resource needs to be changed, and
+ * if so, make that change
+ */
void updateCursor();
+
+ /**
+ * Update the cursor to visually indicate that it is over a
+ * clickable region (by running its associated animation)
+ */
+ void animateCursor();
+
void updateBarrier(Screen *screen, ResourcePack *res, uint8 actorIndex);
void debugScreenScrolling(GraphicFrame *bg);
diff --git a/engines/asylum/scriptman.cpp b/engines/asylum/scriptman.cpp
index 4225f56f1e..f843a1dfc4 100644
--- a/engines/asylum/scriptman.cpp
+++ b/engines/asylum/scriptman.cpp
@@ -125,7 +125,7 @@ void ScriptManager::processActionList() {
else
doJump = _gameFlags[currentCommand.param1] != 0;
- if(doJump)
+ if (doJump)
_currentLine = currentCommand.param3;
}
break;
Commit: 6922206396e6cf8f7ad1c1a2d754b41f39cbd2d1
https://github.com/scummvm/scummvm/commit/6922206396e6cf8f7ad1c1a2d754b41f39cbd2d1
Author: Alex Bevilacqua (alexbevi at gmail.com)
Date: 2021-05-17T15:35:38+02:00
Commit Message:
ASYLUM: updated svn:props (was on a conference call with a client and had some time to kill :P)
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@280 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/graphics.cpp
engines/asylum/menu.cpp
engines/asylum/menu.h
engines/asylum/respack.cpp
engines/asylum/respack.h
engines/asylum/scene.cpp
engines/asylum/scene.h
engines/asylum/sceneres.cpp
engines/asylum/sceneres.h
engines/asylum/screen.cpp
engines/asylum/screen.h
engines/asylum/sound.cpp
engines/asylum/sound.h
engines/asylum/text.cpp
engines/asylum/text.h
diff --git a/engines/asylum/graphics.cpp b/engines/asylum/graphics.cpp
index 91113fe03d..c500f01c35 100644
--- a/engines/asylum/graphics.cpp
+++ b/engines/asylum/graphics.cpp
@@ -1,108 +1,108 @@
-/* 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.
- *
- * $URL$
- * $Id$
- *
- */
-
-#include "asylum/graphics.h"
-#include "common/endian.h"
-
-namespace Asylum {
-
-GraphicResource::GraphicResource(ResourcePack *resPack, int entry) {
- ResourceEntry *resEntry = resPack->getResource(entry);
- _entryNum = entry;
- init(resEntry->data, resEntry->size);
-}
-
-GraphicResource::~GraphicResource() {
- for (uint32 i = 0; i < _frames.size(); i++) {
- _frames[i].surface.free();
- }
-
- _frames.clear();
-}
-
-void GraphicResource::init(byte *data, uint32 size) {
- byte *dataPtr = data;
- uint32 contentOffset = 0;
- uint32 frameCount = 0;
-
- uint32 i = 0;
-
- dataPtr += 4; // tag value
-
- _flags = READ_UINT32(dataPtr); dataPtr += 4;
-
- contentOffset = READ_UINT32(dataPtr); dataPtr += 4;
-
- dataPtr += 4; // unknown
- dataPtr += 4; // unknown
- dataPtr += 4; // unknown
-
- frameCount = READ_UINT16(dataPtr); dataPtr += 2;
-
- dataPtr += 2; // max width
-
- _frames.resize(frameCount);
-
- // Read frame offsets
- uint32 prevOffset = READ_UINT32(dataPtr) + contentOffset; dataPtr += 4;
- uint32 nextOffset = 0;
-
- for (i = 0; i < frameCount; i++) {
- GraphicFrame frame;
- frame.offset = prevOffset;
-
- // Read the offset of the next entry to determine the size of this one
- nextOffset = (i < frameCount - 1) ? READ_UINT32(dataPtr) + contentOffset : size;
- dataPtr += 4; // offset
- frame.size = (nextOffset > 0) ? nextOffset - prevOffset : size - prevOffset;
-
- _frames[i] = frame;
-
- prevOffset = nextOffset;
- }
-
- // Reset pointer
- dataPtr = data;
-
- // Read frame data
- for (i = 0; i < frameCount; i++) {
- dataPtr = data + _frames[i].offset;
-
- dataPtr += 4; // size
- dataPtr += 4; // flag
-
- _frames[i].x = READ_UINT16(dataPtr); dataPtr += 2;
- _frames[i].y = READ_UINT16(dataPtr); dataPtr += 2;
-
- uint16 height = READ_UINT16(dataPtr); dataPtr += 2;
- uint16 width = READ_UINT16(dataPtr); dataPtr += 2;
-
- _frames[i].surface.create(width, height, 1);
-
- memcpy(_frames[i].surface.pixels, dataPtr, width * height);
- }
-}
-
-} // end of namespace Asylum
+/* 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.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#include "asylum/graphics.h"
+#include "common/endian.h"
+
+namespace Asylum {
+
+GraphicResource::GraphicResource(ResourcePack *resPack, int entry) {
+ ResourceEntry *resEntry = resPack->getResource(entry);
+ _entryNum = entry;
+ init(resEntry->data, resEntry->size);
+}
+
+GraphicResource::~GraphicResource() {
+ for (uint32 i = 0; i < _frames.size(); i++) {
+ _frames[i].surface.free();
+ }
+
+ _frames.clear();
+}
+
+void GraphicResource::init(byte *data, uint32 size) {
+ byte *dataPtr = data;
+ uint32 contentOffset = 0;
+ uint32 frameCount = 0;
+
+ uint32 i = 0;
+
+ dataPtr += 4; // tag value
+
+ _flags = READ_UINT32(dataPtr); dataPtr += 4;
+
+ contentOffset = READ_UINT32(dataPtr); dataPtr += 4;
+
+ dataPtr += 4; // unknown
+ dataPtr += 4; // unknown
+ dataPtr += 4; // unknown
+
+ frameCount = READ_UINT16(dataPtr); dataPtr += 2;
+
+ dataPtr += 2; // max width
+
+ _frames.resize(frameCount);
+
+ // Read frame offsets
+ uint32 prevOffset = READ_UINT32(dataPtr) + contentOffset; dataPtr += 4;
+ uint32 nextOffset = 0;
+
+ for (i = 0; i < frameCount; i++) {
+ GraphicFrame frame;
+ frame.offset = prevOffset;
+
+ // Read the offset of the next entry to determine the size of this one
+ nextOffset = (i < frameCount - 1) ? READ_UINT32(dataPtr) + contentOffset : size;
+ dataPtr += 4; // offset
+ frame.size = (nextOffset > 0) ? nextOffset - prevOffset : size - prevOffset;
+
+ _frames[i] = frame;
+
+ prevOffset = nextOffset;
+ }
+
+ // Reset pointer
+ dataPtr = data;
+
+ // Read frame data
+ for (i = 0; i < frameCount; i++) {
+ dataPtr = data + _frames[i].offset;
+
+ dataPtr += 4; // size
+ dataPtr += 4; // flag
+
+ _frames[i].x = READ_UINT16(dataPtr); dataPtr += 2;
+ _frames[i].y = READ_UINT16(dataPtr); dataPtr += 2;
+
+ uint16 height = READ_UINT16(dataPtr); dataPtr += 2;
+ uint16 width = READ_UINT16(dataPtr); dataPtr += 2;
+
+ _frames[i].surface.create(width, height, 1);
+
+ memcpy(_frames[i].surface.pixels, dataPtr, width * height);
+ }
+}
+
+} // end of namespace Asylum
diff --git a/engines/asylum/menu.cpp b/engines/asylum/menu.cpp
index 2dca7b2bb6..5d7872a576 100644
--- a/engines/asylum/menu.cpp
+++ b/engines/asylum/menu.cpp
@@ -1,650 +1,650 @@
-/* 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.
- *
- * $URL$
- * $Id$
- *
- */
-
-#include "asylum/menu.h"
-#include "asylum/respack.h"
-#include "asylum/graphics.h"
-
-namespace Asylum {
-
-/** This fixes the menu icons text x position on screen */
-const int MenuIconFixedXpos[12] = { 28, 128, 225, 320, 410, 528, 16, 115, 237, 310, 508, 419 };
-
-MainMenu::MainMenu(Screen *screen, Sound *sound, Scene *scene) :
- _screen(screen), _sound(sound), _scene(scene) {
- _mouseX = 0;
- _mouseY = 0;
- _leftClick = false;
- _activeIcon = -1;
- _previousActiveIcon = -1;
- _curIconFrame = 0;
- _curMouseCursor = 0;
- _cursorStep = 1;
- _creditsBgFrame = 0;
- _creditsTextScroll = 0x1E0 - 30;
- _activeMenuScreen = kMainMenu;
- _active = false;
- _confGammaLevel = 2;
- _confGameQuality = 5;
-
- _resPack = new ResourcePack(1);
- _bgResource = new GraphicResource(_resPack, 0);
- _eyeResource = new GraphicResource(_resPack, 1);
- _cursorResource = new GraphicResource(_resPack, 2);
-
- _iconResource = 0;
- _creditsResource = 0;
- _creditsFadeResource = 0;
-
- _text = new Text(_screen);
- _text->loadFont(_resPack, 16); // 0x80010010, yellow font
-}
-
-MainMenu::~MainMenu() {
- delete _creditsResource;
- delete _creditsFadeResource;
- delete _text;
- delete _iconResource;
- delete _eyeResource;
- delete _cursorResource;
- delete _bgResource;
- delete _resPack;
-}
-
-void MainMenu::openMenu() {
- _active = true;
- _scene->deactivate();
-
- // yellow font
- _text->loadFont(_resPack, 0x80010010);
-
- // Load the graphics palette
- _screen->setPalette(_resPack, 17);
- // Copy the bright background to the back buffer
- GraphicFrame *bg = _bgResource->getFrame(1);
- _screen->copyToBackBuffer((byte *)bg->surface.pixels, bg->surface.w, 0, 0, bg->surface.w, bg->surface.h);
-
- // Set mouse cursor
- _screen->setCursor(_cursorResource, 0);
- _screen->showCursor();
-
- // Stop all sounds
- _sound->stopMusic();
- _sound->stopSfx();
-
- // Start playing music
- _sound->playMusic(_resPack, 39);
-
- _previousActiveIcon = _activeIcon = -1;
- _leftClick = false;
- _activeMenuScreen = kMainMenu;
- _mouseX = _mouseY = 0;
-}
-
-void MainMenu::closeMenu() {
- _active = false;
- _scene->activate();
-
- // Stop menu sounds and menu music
- _sound->stopSfx();
- _sound->stopMusic();
-}
-
-void MainMenu::handleEvent(Common::Event *event, bool doUpdate) {
- _ev = event;
-
- switch (_ev->type) {
- case Common::EVENT_MOUSEMOVE:
- _mouseX = _ev->mouse.x;
- _mouseY = _ev->mouse.y;
- break;
- case Common::EVENT_LBUTTONUP:
- _leftClick = true;
- break;
- default:
- break;
- }
-
- if (doUpdate || _leftClick)
- update();
-}
-
-void MainMenu::update() {
- updateEyesAnimation();
- updateCursor();
-
- if (_activeMenuScreen == kMainMenu) {
- updateMainMenu();
- } else {
- updateSubMenu();
- }
-
- if (_leftClick) {
- _leftClick = false;
-
- if (_activeIcon != -1) {
- // Copy the dark background to the back buffer
- GraphicFrame *bg = _bgResource->getFrame(0);
- _screen->copyToBackBuffer((byte *)bg->surface.pixels, bg->surface.w, 0, 0, bg->surface.w, bg->surface.h);
- _activeMenuScreen = (MenuScreen) _activeIcon;
-
- // Set the cursor
- delete _cursorResource;
- _cursorResource = new GraphicResource(_resPack, 3);
- _screen->setCursor(_cursorResource, 0);
- }
-
- switch (_activeIcon) {
- case kNewGame:
- // Nothing here
- break;
- case kLoadGame:
- // TODO
- break;
- case kSaveGame:
- // TODO
- break;
- case kDeleteGame:
- // TODO
- break;
- case kViewCinematics:
- // TODO
- break;
- case kQuitGame:
- // Nothing here
- break;
- case kTextOptions:
- // TODO
- break;
- case kAudioOptions:
- // TODO
- break;
- case kSettings:
- // TODO
- break;
- case kKeyboardConfig:
- // TODO
- break;
- case kShowCredits:
- // TODO if game finished (gameFlag=901) then show resource image 33 and music 56 and than music 40
- if (!_creditsResource)
- _creditsResource = new GraphicResource(_resPack, 24);
- if (!_creditsFadeResource)
- _creditsFadeResource = new GraphicResource(_resPack, 23);
- _creditsTextScroll = 0x1E0 - 30;
- // Set credits palette
- _screen->setPalette(_resPack, 26);
- // Stop all sounds
- _sound->stopMusic();
- // Start playing music
- _sound->playMusic(_resPack, 38);
- break;
- case kReturnToGame:
- closeMenu();
- _scene->enterScene();
- break;
- }
- }
-}
-
-void MainMenu::updateCursor() {
- _curMouseCursor += _cursorStep;
- if (_curMouseCursor == 0)
- _cursorStep = 1;
- if (_curMouseCursor == _cursorResource->getFrameCount() - 1)
- _cursorStep = -1;
-
- _screen->setCursor(_cursorResource, _curMouseCursor);
-}
-
-void MainMenu::updateEyesAnimation() {
- // Eyes animation
- // Get the appropriate eye resource depending on the mouse position
- int eyeFrameNum = kEyesFront;
-
- if (_mouseX <= 200) {
- if (_mouseY <= 160)
- eyeFrameNum = kEyesTopLeft;
- else if (_mouseY > 160 && _mouseY <= 320)
- eyeFrameNum = kEyesLeft;
- else
- eyeFrameNum = kEyesBottomLeft;
- } else if (_mouseX > 200 && _mouseX <= 400) {
- if (_mouseY <= 160)
- eyeFrameNum = kEyesTop;
- else if (_mouseY > 160 && _mouseY <= 320)
- eyeFrameNum = kEyesFront;
- else
- eyeFrameNum = kEyesBottom;
- } else if (_mouseX > 400) {
- if (_mouseY <= 160)
- eyeFrameNum = kEyesTopRight;
- else if (_mouseY > 160 && _mouseY <= 320)
- eyeFrameNum = kEyesRight;
- else
- eyeFrameNum = kEyesBottomRight;
- }
- // TODO: kEyesCrossed state
-
- GraphicFrame *eyeFrame = _eyeResource->getFrame(eyeFrameNum);
- _screen->copyRectToScreenWithTransparency((byte *)eyeFrame->surface.pixels, eyeFrame->surface.w, eyeFrame->x, eyeFrame->y, eyeFrame->surface.w, eyeFrame->surface.h);
-}
-
-void MainMenu::updateMainMenu() {
- int rowId = 0;
-
- if (_mouseY >= 20 && _mouseY <= 20 + 48) {
- rowId = 0; // Top row
- } else if (_mouseY >= 400 && _mouseY <= 400 + 48) {
- rowId = 1; // Bottom row
- } else {
- // No row selected
- _previousActiveIcon = _activeIcon = -1;
- _leftClick = false;
- return;
- }
-
- // yellow font
- _text->loadFont(_resPack, 0x80010010);
-
- // Icon animation
- for (uint32 i = 0; i <= 5; i++) {
- uint32 curX = 40 + i * 100;
- if (_mouseX >= curX && _mouseX <= curX + 55) {
- int iconNum = i + 6 * rowId;
- _activeIcon = iconNum;
-
- // The last 2 icons are swapped
- if (iconNum == 11)
- iconNum = 10;
- else if (iconNum == 10)
- iconNum = 11;
-
- // Get the current icon animation
- if (!_iconResource || _activeIcon != _previousActiveIcon) {
- delete _iconResource;
- _iconResource = new GraphicResource(_resPack, iconNum + 4);
- }
-
- GraphicFrame *iconFrame = _iconResource->getFrame(MIN<int>(_iconResource->getFrameCount() - 1, _curIconFrame));
- _screen->copyRectToScreenWithTransparency((byte *)iconFrame->surface.pixels, iconFrame->surface.w, iconFrame->x, iconFrame->y, iconFrame->surface.w, iconFrame->surface.h);
-
- // Cycle icon frame
- _curIconFrame++;
- if (_curIconFrame >= _iconResource->getFrameCount())
- _curIconFrame = 0;
-
- // Show text
- _text->drawResTextCentered(MenuIconFixedXpos[iconNum], iconFrame->y + 50, _text->getResTextWidth(iconNum + 1309), iconNum + 1309);
-
- // Play creepy voice
- if (!_sound->isSfxActive() && _activeIcon != _previousActiveIcon) {
- _sound->playSfx(_resPack, iconNum + 44);
- _previousActiveIcon = _activeIcon;
- }
-
- break;
- }
- }
-}
-
-void MainMenu::updateSubMenu() {
- GraphicFrame *iconFrame = _iconResource->getFrame(MIN<int>(_iconResource->getFrameCount() - 1, _curIconFrame));
- _screen->copyRectToScreenWithTransparency((byte *)iconFrame->surface.pixels, iconFrame->surface.w, iconFrame->x, iconFrame->y, iconFrame->surface.w, iconFrame->surface.h);
-
- // Cycle icon frame
- _curIconFrame++;
- if (_curIconFrame >= _iconResource->getFrameCount())
- _curIconFrame = 0;
-
- switch (_activeIcon) {
- case kNewGame:
- updateSubMenuNewGame();
- break;
- case kLoadGame:
- // TODO
- break;
- case kSaveGame:
- // TODO
- break;
- case kDeleteGame:
- // TODO
- break;
- case kViewCinematics:
- updateSubMenuCinematics();
- break;
- case kQuitGame:
- updateSubMenuQuitGame();
- break;
- case kTextOptions:
- // TODO
- break;
- case kAudioOptions:
- // TODO
- break;
- case kSettings:
- updateSubMenuSettings();
- break;
- case kKeyboardConfig:
- // TODO
- break;
- case kShowCredits:
- updateSubMenuShowCredits();
- break;
- case kReturnToGame:
- // TODO
- break;
- }
-}
-
-void MainMenu::updateSubMenuNewGame() {
- // yellow font
- _text->loadFont(_resPack, 0x80010010);
-
- // begin new game
- _text->drawResTextCentered(10, 100, 620, 0x80000529);
-
- // Yes
- if (_mouseX < 247 || _mouseX > 247 + _text->getResTextWidth(0x8000052A) || _mouseY < 273 || _mouseY > 273 + 24 )
- _text->loadFont(_resPack, 0x80010010); // yellow font
- else
- _text->loadFont(_resPack, 0x80010016); // blue font
- _text->setTextPos(247, 273);
- _text->drawResText(0x8000052A);
-
- // No
- if (_mouseX < 369 || _mouseX > 369 + _text->getResTextWidth(0x8000052B) || _mouseY < 273 || _mouseY > 273 + 24 )
- _text->loadFont(_resPack, 0x80010010); // yellow font
- else
- _text->loadFont(_resPack, 0x80010016); // blue font
- _text->setTextPos(369, 273);
- _text->drawResText(0x8000052B);
-
- // action
- if (_leftClick) {
- // Yes
- if (_mouseX >= 247 && _mouseX <= 247 + 24 && _mouseY >= 273 && _mouseY <= 273 + _text->getResTextWidth(0x8000052A)) {
- _leftClick = false;
- // TODO handle new game event
- }
- // No
- if (_mouseX >= 369 && _mouseX <= 369 + 24 && _mouseY >= 273 && _mouseY <= 273 + _text->getResTextWidth(0x8000052B))
- exitSubMenu();
- }
-}
-
-void MainMenu::updateSubMenuCinematics() {
- int currentCD = 1; // FIXME: dummy value
- _text->drawResTextWithValueCentered(10, 100, 620, 0x80000548, currentCD);
- _text->setTextPos(30, 340);
- _text->drawResText(0x80000549); // Prev Page
-
- if (_mouseX >= 280 && _mouseX <= 400 && _mouseY >= 340 && _mouseY <= 360) {
- _text->loadFont(_resPack, 0x80010016); // blue font
- if (_leftClick)
- exitSubMenu();
- } else {
- _text->loadFont(_resPack, 0x80010010); // yellow font
- }
-
- _text->setTextPos(280, 340);
- _text->drawResText(0x8000054B); // Main Menu
-
- _text->loadFont(_resPack, 0x80010010); // yellow font
-
- _text->setTextPos(500, 340);
- _text->drawResText(0x8000054A); // Next Page
-}
-
-void MainMenu::updateSubMenuSettings() {
- uint32 sizeMinus = _text->getTextWidth("-");
- uint32 sizePlus = _text->getTextWidth("+");
- uint32 sizeMainMenu = _text->getResTextWidth(0x8000059D);
-
- // yellow font
- _text->loadFont(_resPack, 0x80010010);
- // Settings
- _text->drawResTextCentered(10, 100, 620, 0x80000598);
-
- // gamma correction
- _text->drawResTextAlignRight(320, 150, 0x80000599);
- if (_mouseX < 350 || _mouseX > sizeMinus + 350 || _mouseY < 150 || _mouseY > 174)
- _text->loadFont(_resPack, 0x80010010); // yellow font
- else
- _text->loadFont(_resPack, 0x80010016); // blue font
- _text->setTextPos(350, 150);
- _text->drawText("-");
-
- if (_mouseX < sizeMinus + 360 || _mouseX > sizeMinus + sizePlus + 360 || _mouseY < 150 || _mouseY > 174)
- _text->loadFont(_resPack, 0x80010010); // yellow font
- else
- _text->loadFont(_resPack, 0x80010016); // blue font
- _text->setTextPos(sizeMinus + 360, 150);
- _text->drawText("+");
-
- _text->setTextPos(sizeMinus + sizePlus + 365, 150);
- _text->loadFont(_resPack, 0x80010010);
- if (_confGammaLevel) {
- for (uint32 i = 0; i < _confGammaLevel; i++ ) {
- _text->drawText("]");
- }
- if (_confGammaLevel == 8)
- _text->drawText("*");
- } else
- _text->drawResText(0x8000059B);
-
- // performance
- _text->loadFont(_resPack, 0x80010010);
- _text->drawResTextAlignRight(320, 179, 0x8000059A);
- if (_mouseX < 350 || _mouseX > sizeMinus + 350 || _mouseY < 179 || _mouseY > 203)
- _text->loadFont(_resPack, 0x80010010); // yellow font
- else
- _text->loadFont(_resPack, 0x80010016); // blue font
- _text->setTextPos(350, 179);
- _text->drawText("-");
-
- if (_mouseX < sizeMinus + 360 || _mouseX > sizeMinus + sizePlus + 360 || _mouseY < 179 || _mouseY > 203)
- _text->loadFont(_resPack, 0x80010010); // yellow font
- else
- _text->loadFont(_resPack, 0x80010016); // blue font
- _text->setTextPos(sizeMinus + 360, 179);
- _text->drawText("+");
-
- _text->setTextPos(sizeMinus + sizePlus + 365, 179);
- _text->loadFont(_resPack, 0x80010010);
- if(_confGameQuality == 5) {
- _text->drawResText(0x8000059C);
- } else {
- for (uint32 i = 5; i > _confGameQuality; --i ) {
- _text->drawText("]");
- }
- if (!_confGameQuality)
- _text->drawText("*");
- }
-
- // back to main menu
- if (_mouseX < 300 || _mouseX > 300 + sizeMainMenu || _mouseY < 340 || _mouseY > 340 + 24)
- _text->loadFont(_resPack, 0x80010010); // yellow font
- else
- _text->loadFont(_resPack, 0x80010016); // blue font
- _text->setTextPos(300, 340);
- _text->drawResText(0x8000059D);
-
- // action
- if (_leftClick) {
- // back to main menu
- if (_mouseX >= 300 && _mouseX <= 300 + sizeMainMenu && _mouseY >= 340 && _mouseY <= 340 + 24) {
- // TODO: save new configurations
- exitSubMenu();
- }
-
- // gamma level minus
- if (_mouseX >= 350 && _mouseX <= sizeMinus + 350 && _mouseY >= 150 && _mouseY <= 174) {
- if(_confGammaLevel) {
- _confGammaLevel -= 1;
- // TODO: setResGammaLevel(0x80010011, 0);
- }
- }
- // gamma level plus
- if (_mouseX >= sizeMinus + 360 && _mouseX <= sizeMinus + sizePlus + 360 && _mouseY >= 150 && _mouseY <= 174) {
- if(_confGammaLevel < 8) {
- _confGammaLevel += 1;
- // TODO: setResGammaLevel(0x80010011, 0);
- }
- }
-
- // performance minus
- if (_mouseX >= 350 && _mouseX <= sizeMinus + 350 && _mouseY >= 179 && _mouseY <= 203) {
- if(_confGameQuality) {
- _confGameQuality -= 1;
- // TODO: change quality settings
- }
- }
- // performance plus
- if (_mouseX >= sizeMinus + 360 && _mouseX <= sizeMinus + sizePlus + 360 && _mouseY >= 179 && _mouseY <= 203) {
- if(_confGameQuality < 5) {
- _confGameQuality += 1;
- // TODO: change quality settings
- }
- }
- }
-}
-
-void MainMenu::updateSubMenuQuitGame() {
- // yellow font
- _text->loadFont(_resPack, 0x80010010);
-
- // begin new game
- _text->drawResTextCentered(10, 100, 620, 0x80000580);
-
- // Yes
- if (_mouseX < 247 || _mouseX > 247 + _text->getResTextWidth(0x80000581) || _mouseY < 273 || _mouseY > 273 + 24 )
- _text->loadFont(_resPack, 0x80010010); // yellow font
- else
- _text->loadFont(_resPack, 0x80010016); // blue font
- _text->setTextPos(247, 273);
- _text->drawResText(0x80000581);
-
- // No
- if (_mouseX < 369 || _mouseX > 369 + _text->getResTextWidth(0x80000582) || _mouseY < 273 || _mouseY > 273 + 24 )
- _text->loadFont(_resPack, 0x80010010); // yellow font
- else
- _text->loadFont(_resPack, 0x80010016); // blue font
- _text->setTextPos(369, 273);
- _text->drawResText(0x80000582);
-
- // action
- if (_leftClick) {
- // Yes
- if (_mouseX >= 247 && _mouseX <= 247 + 24 && _mouseY >= 273 && _mouseY <= 273 + _text->getResTextWidth(0x80000581)) {
- _leftClick = false;
-
- // User clicked on quit, so push a quit event
- Common::Event event;
- event.type = Common::EVENT_QUIT;
- g_system->getEventManager()->pushEvent(event);
- }
- // No
- if (_mouseX >= 369 && _mouseX <= 369 + 24 && _mouseY >= 273 && _mouseY <= 273 + _text->getResTextWidth(0x80000582))
- exitSubMenu();
- }
-}
-
-void MainMenu::updateSubMenuShowCredits() {
- int posY = _creditsTextScroll;
- int resId = 0;
- int step = 0;
- int minBound = 0;
- int maxBound = 0;
-
- GraphicFrame *creditsFadeFrame = _creditsFadeResource->getFrame(0);
- _screen->copyRectToScreenWithTransparency((byte *)creditsFadeFrame->surface.pixels, creditsFadeFrame->surface.w, creditsFadeFrame->x, creditsFadeFrame->y, creditsFadeFrame->surface.w, creditsFadeFrame->surface.h);
-
- GraphicFrame *creditsFrame = _creditsResource->getFrame(MIN<int>(_creditsResource->getFrameCount() - 1, _creditsBgFrame));
- _screen->copyRectToScreenWithTransparency((byte *)creditsFrame->surface.pixels, creditsFrame->surface.w, creditsFrame->x, creditsFrame->y, creditsFrame->surface.w, creditsFrame->surface.h);
-
- _creditsBgFrame++;
- if (_creditsBgFrame >= _creditsResource->getFrameCount())
- _creditsBgFrame = 0;
-
- do {
- if (posY + step >= 0) {
- if (posY + step > 450)
- break;
-
- minBound = posY + step + 24;
- if (minBound >= 0)
- if (minBound < 32) {
- // TODO fade side text
- posY = _creditsTextScroll;
- }
-
- maxBound = posY + step;
- if (posY + step < 480)
- if (maxBound > 448) {
- // TODO fade side text
- posY = _creditsTextScroll;
- }
-
- _text->setTextPos(320, step + posY);
- _text->drawResText(resId - 2147482201);
- posY = _creditsTextScroll;
- }
- step += 24;
- ++resId;
- } while (step < 0x21F0);
-
- _creditsTextScroll -= 2;
-
- // TODO: some palette stuffs
-
- // TODO: if gameFlag=901 (finished game) and already play music 56, start music 40
-
- if (_leftClick) {
- // Restore palette
- _screen->setPalette(_resPack, 17);
- // Stop all sounds
- _sound->stopMusic();
- // Start playing music
- _sound->playMusic(_resPack, 39);
- exitSubMenu();
- }
-}
-
-void MainMenu::exitSubMenu() {
- _leftClick = false;
- _activeMenuScreen = kMainMenu;
-
- // Copy the bright background to the back buffer
- GraphicFrame *bg = _bgResource->getFrame(1);
- _screen->copyToBackBuffer((byte *)bg->surface.pixels, bg->surface.w, 0, 0, bg->surface.w, bg->surface.h);
-
- // Set the cursor
- delete _cursorResource;
- _cursorResource = new GraphicResource(_resPack, 2);
- _screen->setCursor(_cursorResource, 0);
-}
-
-} // end of namespace Asylum
+/* 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.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#include "asylum/menu.h"
+#include "asylum/respack.h"
+#include "asylum/graphics.h"
+
+namespace Asylum {
+
+/** This fixes the menu icons text x position on screen */
+const int MenuIconFixedXpos[12] = { 28, 128, 225, 320, 410, 528, 16, 115, 237, 310, 508, 419 };
+
+MainMenu::MainMenu(Screen *screen, Sound *sound, Scene *scene) :
+ _screen(screen), _sound(sound), _scene(scene) {
+ _mouseX = 0;
+ _mouseY = 0;
+ _leftClick = false;
+ _activeIcon = -1;
+ _previousActiveIcon = -1;
+ _curIconFrame = 0;
+ _curMouseCursor = 0;
+ _cursorStep = 1;
+ _creditsBgFrame = 0;
+ _creditsTextScroll = 0x1E0 - 30;
+ _activeMenuScreen = kMainMenu;
+ _active = false;
+ _confGammaLevel = 2;
+ _confGameQuality = 5;
+
+ _resPack = new ResourcePack(1);
+ _bgResource = new GraphicResource(_resPack, 0);
+ _eyeResource = new GraphicResource(_resPack, 1);
+ _cursorResource = new GraphicResource(_resPack, 2);
+
+ _iconResource = 0;
+ _creditsResource = 0;
+ _creditsFadeResource = 0;
+
+ _text = new Text(_screen);
+ _text->loadFont(_resPack, 16); // 0x80010010, yellow font
+}
+
+MainMenu::~MainMenu() {
+ delete _creditsResource;
+ delete _creditsFadeResource;
+ delete _text;
+ delete _iconResource;
+ delete _eyeResource;
+ delete _cursorResource;
+ delete _bgResource;
+ delete _resPack;
+}
+
+void MainMenu::openMenu() {
+ _active = true;
+ _scene->deactivate();
+
+ // yellow font
+ _text->loadFont(_resPack, 0x80010010);
+
+ // Load the graphics palette
+ _screen->setPalette(_resPack, 17);
+ // Copy the bright background to the back buffer
+ GraphicFrame *bg = _bgResource->getFrame(1);
+ _screen->copyToBackBuffer((byte *)bg->surface.pixels, bg->surface.w, 0, 0, bg->surface.w, bg->surface.h);
+
+ // Set mouse cursor
+ _screen->setCursor(_cursorResource, 0);
+ _screen->showCursor();
+
+ // Stop all sounds
+ _sound->stopMusic();
+ _sound->stopSfx();
+
+ // Start playing music
+ _sound->playMusic(_resPack, 39);
+
+ _previousActiveIcon = _activeIcon = -1;
+ _leftClick = false;
+ _activeMenuScreen = kMainMenu;
+ _mouseX = _mouseY = 0;
+}
+
+void MainMenu::closeMenu() {
+ _active = false;
+ _scene->activate();
+
+ // Stop menu sounds and menu music
+ _sound->stopSfx();
+ _sound->stopMusic();
+}
+
+void MainMenu::handleEvent(Common::Event *event, bool doUpdate) {
+ _ev = event;
+
+ switch (_ev->type) {
+ case Common::EVENT_MOUSEMOVE:
+ _mouseX = _ev->mouse.x;
+ _mouseY = _ev->mouse.y;
+ break;
+ case Common::EVENT_LBUTTONUP:
+ _leftClick = true;
+ break;
+ default:
+ break;
+ }
+
+ if (doUpdate || _leftClick)
+ update();
+}
+
+void MainMenu::update() {
+ updateEyesAnimation();
+ updateCursor();
+
+ if (_activeMenuScreen == kMainMenu) {
+ updateMainMenu();
+ } else {
+ updateSubMenu();
+ }
+
+ if (_leftClick) {
+ _leftClick = false;
+
+ if (_activeIcon != -1) {
+ // Copy the dark background to the back buffer
+ GraphicFrame *bg = _bgResource->getFrame(0);
+ _screen->copyToBackBuffer((byte *)bg->surface.pixels, bg->surface.w, 0, 0, bg->surface.w, bg->surface.h);
+ _activeMenuScreen = (MenuScreen) _activeIcon;
+
+ // Set the cursor
+ delete _cursorResource;
+ _cursorResource = new GraphicResource(_resPack, 3);
+ _screen->setCursor(_cursorResource, 0);
+ }
+
+ switch (_activeIcon) {
+ case kNewGame:
+ // Nothing here
+ break;
+ case kLoadGame:
+ // TODO
+ break;
+ case kSaveGame:
+ // TODO
+ break;
+ case kDeleteGame:
+ // TODO
+ break;
+ case kViewCinematics:
+ // TODO
+ break;
+ case kQuitGame:
+ // Nothing here
+ break;
+ case kTextOptions:
+ // TODO
+ break;
+ case kAudioOptions:
+ // TODO
+ break;
+ case kSettings:
+ // TODO
+ break;
+ case kKeyboardConfig:
+ // TODO
+ break;
+ case kShowCredits:
+ // TODO if game finished (gameFlag=901) then show resource image 33 and music 56 and than music 40
+ if (!_creditsResource)
+ _creditsResource = new GraphicResource(_resPack, 24);
+ if (!_creditsFadeResource)
+ _creditsFadeResource = new GraphicResource(_resPack, 23);
+ _creditsTextScroll = 0x1E0 - 30;
+ // Set credits palette
+ _screen->setPalette(_resPack, 26);
+ // Stop all sounds
+ _sound->stopMusic();
+ // Start playing music
+ _sound->playMusic(_resPack, 38);
+ break;
+ case kReturnToGame:
+ closeMenu();
+ _scene->enterScene();
+ break;
+ }
+ }
+}
+
+void MainMenu::updateCursor() {
+ _curMouseCursor += _cursorStep;
+ if (_curMouseCursor == 0)
+ _cursorStep = 1;
+ if (_curMouseCursor == _cursorResource->getFrameCount() - 1)
+ _cursorStep = -1;
+
+ _screen->setCursor(_cursorResource, _curMouseCursor);
+}
+
+void MainMenu::updateEyesAnimation() {
+ // Eyes animation
+ // Get the appropriate eye resource depending on the mouse position
+ int eyeFrameNum = kEyesFront;
+
+ if (_mouseX <= 200) {
+ if (_mouseY <= 160)
+ eyeFrameNum = kEyesTopLeft;
+ else if (_mouseY > 160 && _mouseY <= 320)
+ eyeFrameNum = kEyesLeft;
+ else
+ eyeFrameNum = kEyesBottomLeft;
+ } else if (_mouseX > 200 && _mouseX <= 400) {
+ if (_mouseY <= 160)
+ eyeFrameNum = kEyesTop;
+ else if (_mouseY > 160 && _mouseY <= 320)
+ eyeFrameNum = kEyesFront;
+ else
+ eyeFrameNum = kEyesBottom;
+ } else if (_mouseX > 400) {
+ if (_mouseY <= 160)
+ eyeFrameNum = kEyesTopRight;
+ else if (_mouseY > 160 && _mouseY <= 320)
+ eyeFrameNum = kEyesRight;
+ else
+ eyeFrameNum = kEyesBottomRight;
+ }
+ // TODO: kEyesCrossed state
+
+ GraphicFrame *eyeFrame = _eyeResource->getFrame(eyeFrameNum);
+ _screen->copyRectToScreenWithTransparency((byte *)eyeFrame->surface.pixels, eyeFrame->surface.w, eyeFrame->x, eyeFrame->y, eyeFrame->surface.w, eyeFrame->surface.h);
+}
+
+void MainMenu::updateMainMenu() {
+ int rowId = 0;
+
+ if (_mouseY >= 20 && _mouseY <= 20 + 48) {
+ rowId = 0; // Top row
+ } else if (_mouseY >= 400 && _mouseY <= 400 + 48) {
+ rowId = 1; // Bottom row
+ } else {
+ // No row selected
+ _previousActiveIcon = _activeIcon = -1;
+ _leftClick = false;
+ return;
+ }
+
+ // yellow font
+ _text->loadFont(_resPack, 0x80010010);
+
+ // Icon animation
+ for (uint32 i = 0; i <= 5; i++) {
+ uint32 curX = 40 + i * 100;
+ if (_mouseX >= curX && _mouseX <= curX + 55) {
+ int iconNum = i + 6 * rowId;
+ _activeIcon = iconNum;
+
+ // The last 2 icons are swapped
+ if (iconNum == 11)
+ iconNum = 10;
+ else if (iconNum == 10)
+ iconNum = 11;
+
+ // Get the current icon animation
+ if (!_iconResource || _activeIcon != _previousActiveIcon) {
+ delete _iconResource;
+ _iconResource = new GraphicResource(_resPack, iconNum + 4);
+ }
+
+ GraphicFrame *iconFrame = _iconResource->getFrame(MIN<int>(_iconResource->getFrameCount() - 1, _curIconFrame));
+ _screen->copyRectToScreenWithTransparency((byte *)iconFrame->surface.pixels, iconFrame->surface.w, iconFrame->x, iconFrame->y, iconFrame->surface.w, iconFrame->surface.h);
+
+ // Cycle icon frame
+ _curIconFrame++;
+ if (_curIconFrame >= _iconResource->getFrameCount())
+ _curIconFrame = 0;
+
+ // Show text
+ _text->drawResTextCentered(MenuIconFixedXpos[iconNum], iconFrame->y + 50, _text->getResTextWidth(iconNum + 1309), iconNum + 1309);
+
+ // Play creepy voice
+ if (!_sound->isSfxActive() && _activeIcon != _previousActiveIcon) {
+ _sound->playSfx(_resPack, iconNum + 44);
+ _previousActiveIcon = _activeIcon;
+ }
+
+ break;
+ }
+ }
+}
+
+void MainMenu::updateSubMenu() {
+ GraphicFrame *iconFrame = _iconResource->getFrame(MIN<int>(_iconResource->getFrameCount() - 1, _curIconFrame));
+ _screen->copyRectToScreenWithTransparency((byte *)iconFrame->surface.pixels, iconFrame->surface.w, iconFrame->x, iconFrame->y, iconFrame->surface.w, iconFrame->surface.h);
+
+ // Cycle icon frame
+ _curIconFrame++;
+ if (_curIconFrame >= _iconResource->getFrameCount())
+ _curIconFrame = 0;
+
+ switch (_activeIcon) {
+ case kNewGame:
+ updateSubMenuNewGame();
+ break;
+ case kLoadGame:
+ // TODO
+ break;
+ case kSaveGame:
+ // TODO
+ break;
+ case kDeleteGame:
+ // TODO
+ break;
+ case kViewCinematics:
+ updateSubMenuCinematics();
+ break;
+ case kQuitGame:
+ updateSubMenuQuitGame();
+ break;
+ case kTextOptions:
+ // TODO
+ break;
+ case kAudioOptions:
+ // TODO
+ break;
+ case kSettings:
+ updateSubMenuSettings();
+ break;
+ case kKeyboardConfig:
+ // TODO
+ break;
+ case kShowCredits:
+ updateSubMenuShowCredits();
+ break;
+ case kReturnToGame:
+ // TODO
+ break;
+ }
+}
+
+void MainMenu::updateSubMenuNewGame() {
+ // yellow font
+ _text->loadFont(_resPack, 0x80010010);
+
+ // begin new game
+ _text->drawResTextCentered(10, 100, 620, 0x80000529);
+
+ // Yes
+ if (_mouseX < 247 || _mouseX > 247 + _text->getResTextWidth(0x8000052A) || _mouseY < 273 || _mouseY > 273 + 24 )
+ _text->loadFont(_resPack, 0x80010010); // yellow font
+ else
+ _text->loadFont(_resPack, 0x80010016); // blue font
+ _text->setTextPos(247, 273);
+ _text->drawResText(0x8000052A);
+
+ // No
+ if (_mouseX < 369 || _mouseX > 369 + _text->getResTextWidth(0x8000052B) || _mouseY < 273 || _mouseY > 273 + 24 )
+ _text->loadFont(_resPack, 0x80010010); // yellow font
+ else
+ _text->loadFont(_resPack, 0x80010016); // blue font
+ _text->setTextPos(369, 273);
+ _text->drawResText(0x8000052B);
+
+ // action
+ if (_leftClick) {
+ // Yes
+ if (_mouseX >= 247 && _mouseX <= 247 + 24 && _mouseY >= 273 && _mouseY <= 273 + _text->getResTextWidth(0x8000052A)) {
+ _leftClick = false;
+ // TODO handle new game event
+ }
+ // No
+ if (_mouseX >= 369 && _mouseX <= 369 + 24 && _mouseY >= 273 && _mouseY <= 273 + _text->getResTextWidth(0x8000052B))
+ exitSubMenu();
+ }
+}
+
+void MainMenu::updateSubMenuCinematics() {
+ int currentCD = 1; // FIXME: dummy value
+ _text->drawResTextWithValueCentered(10, 100, 620, 0x80000548, currentCD);
+ _text->setTextPos(30, 340);
+ _text->drawResText(0x80000549); // Prev Page
+
+ if (_mouseX >= 280 && _mouseX <= 400 && _mouseY >= 340 && _mouseY <= 360) {
+ _text->loadFont(_resPack, 0x80010016); // blue font
+ if (_leftClick)
+ exitSubMenu();
+ } else {
+ _text->loadFont(_resPack, 0x80010010); // yellow font
+ }
+
+ _text->setTextPos(280, 340);
+ _text->drawResText(0x8000054B); // Main Menu
+
+ _text->loadFont(_resPack, 0x80010010); // yellow font
+
+ _text->setTextPos(500, 340);
+ _text->drawResText(0x8000054A); // Next Page
+}
+
+void MainMenu::updateSubMenuSettings() {
+ uint32 sizeMinus = _text->getTextWidth("-");
+ uint32 sizePlus = _text->getTextWidth("+");
+ uint32 sizeMainMenu = _text->getResTextWidth(0x8000059D);
+
+ // yellow font
+ _text->loadFont(_resPack, 0x80010010);
+ // Settings
+ _text->drawResTextCentered(10, 100, 620, 0x80000598);
+
+ // gamma correction
+ _text->drawResTextAlignRight(320, 150, 0x80000599);
+ if (_mouseX < 350 || _mouseX > sizeMinus + 350 || _mouseY < 150 || _mouseY > 174)
+ _text->loadFont(_resPack, 0x80010010); // yellow font
+ else
+ _text->loadFont(_resPack, 0x80010016); // blue font
+ _text->setTextPos(350, 150);
+ _text->drawText("-");
+
+ if (_mouseX < sizeMinus + 360 || _mouseX > sizeMinus + sizePlus + 360 || _mouseY < 150 || _mouseY > 174)
+ _text->loadFont(_resPack, 0x80010010); // yellow font
+ else
+ _text->loadFont(_resPack, 0x80010016); // blue font
+ _text->setTextPos(sizeMinus + 360, 150);
+ _text->drawText("+");
+
+ _text->setTextPos(sizeMinus + sizePlus + 365, 150);
+ _text->loadFont(_resPack, 0x80010010);
+ if (_confGammaLevel) {
+ for (uint32 i = 0; i < _confGammaLevel; i++ ) {
+ _text->drawText("]");
+ }
+ if (_confGammaLevel == 8)
+ _text->drawText("*");
+ } else
+ _text->drawResText(0x8000059B);
+
+ // performance
+ _text->loadFont(_resPack, 0x80010010);
+ _text->drawResTextAlignRight(320, 179, 0x8000059A);
+ if (_mouseX < 350 || _mouseX > sizeMinus + 350 || _mouseY < 179 || _mouseY > 203)
+ _text->loadFont(_resPack, 0x80010010); // yellow font
+ else
+ _text->loadFont(_resPack, 0x80010016); // blue font
+ _text->setTextPos(350, 179);
+ _text->drawText("-");
+
+ if (_mouseX < sizeMinus + 360 || _mouseX > sizeMinus + sizePlus + 360 || _mouseY < 179 || _mouseY > 203)
+ _text->loadFont(_resPack, 0x80010010); // yellow font
+ else
+ _text->loadFont(_resPack, 0x80010016); // blue font
+ _text->setTextPos(sizeMinus + 360, 179);
+ _text->drawText("+");
+
+ _text->setTextPos(sizeMinus + sizePlus + 365, 179);
+ _text->loadFont(_resPack, 0x80010010);
+ if(_confGameQuality == 5) {
+ _text->drawResText(0x8000059C);
+ } else {
+ for (uint32 i = 5; i > _confGameQuality; --i ) {
+ _text->drawText("]");
+ }
+ if (!_confGameQuality)
+ _text->drawText("*");
+ }
+
+ // back to main menu
+ if (_mouseX < 300 || _mouseX > 300 + sizeMainMenu || _mouseY < 340 || _mouseY > 340 + 24)
+ _text->loadFont(_resPack, 0x80010010); // yellow font
+ else
+ _text->loadFont(_resPack, 0x80010016); // blue font
+ _text->setTextPos(300, 340);
+ _text->drawResText(0x8000059D);
+
+ // action
+ if (_leftClick) {
+ // back to main menu
+ if (_mouseX >= 300 && _mouseX <= 300 + sizeMainMenu && _mouseY >= 340 && _mouseY <= 340 + 24) {
+ // TODO: save new configurations
+ exitSubMenu();
+ }
+
+ // gamma level minus
+ if (_mouseX >= 350 && _mouseX <= sizeMinus + 350 && _mouseY >= 150 && _mouseY <= 174) {
+ if(_confGammaLevel) {
+ _confGammaLevel -= 1;
+ // TODO: setResGammaLevel(0x80010011, 0);
+ }
+ }
+ // gamma level plus
+ if (_mouseX >= sizeMinus + 360 && _mouseX <= sizeMinus + sizePlus + 360 && _mouseY >= 150 && _mouseY <= 174) {
+ if(_confGammaLevel < 8) {
+ _confGammaLevel += 1;
+ // TODO: setResGammaLevel(0x80010011, 0);
+ }
+ }
+
+ // performance minus
+ if (_mouseX >= 350 && _mouseX <= sizeMinus + 350 && _mouseY >= 179 && _mouseY <= 203) {
+ if(_confGameQuality) {
+ _confGameQuality -= 1;
+ // TODO: change quality settings
+ }
+ }
+ // performance plus
+ if (_mouseX >= sizeMinus + 360 && _mouseX <= sizeMinus + sizePlus + 360 && _mouseY >= 179 && _mouseY <= 203) {
+ if(_confGameQuality < 5) {
+ _confGameQuality += 1;
+ // TODO: change quality settings
+ }
+ }
+ }
+}
+
+void MainMenu::updateSubMenuQuitGame() {
+ // yellow font
+ _text->loadFont(_resPack, 0x80010010);
+
+ // begin new game
+ _text->drawResTextCentered(10, 100, 620, 0x80000580);
+
+ // Yes
+ if (_mouseX < 247 || _mouseX > 247 + _text->getResTextWidth(0x80000581) || _mouseY < 273 || _mouseY > 273 + 24 )
+ _text->loadFont(_resPack, 0x80010010); // yellow font
+ else
+ _text->loadFont(_resPack, 0x80010016); // blue font
+ _text->setTextPos(247, 273);
+ _text->drawResText(0x80000581);
+
+ // No
+ if (_mouseX < 369 || _mouseX > 369 + _text->getResTextWidth(0x80000582) || _mouseY < 273 || _mouseY > 273 + 24 )
+ _text->loadFont(_resPack, 0x80010010); // yellow font
+ else
+ _text->loadFont(_resPack, 0x80010016); // blue font
+ _text->setTextPos(369, 273);
+ _text->drawResText(0x80000582);
+
+ // action
+ if (_leftClick) {
+ // Yes
+ if (_mouseX >= 247 && _mouseX <= 247 + 24 && _mouseY >= 273 && _mouseY <= 273 + _text->getResTextWidth(0x80000581)) {
+ _leftClick = false;
+
+ // User clicked on quit, so push a quit event
+ Common::Event event;
+ event.type = Common::EVENT_QUIT;
+ g_system->getEventManager()->pushEvent(event);
+ }
+ // No
+ if (_mouseX >= 369 && _mouseX <= 369 + 24 && _mouseY >= 273 && _mouseY <= 273 + _text->getResTextWidth(0x80000582))
+ exitSubMenu();
+ }
+}
+
+void MainMenu::updateSubMenuShowCredits() {
+ int posY = _creditsTextScroll;
+ int resId = 0;
+ int step = 0;
+ int minBound = 0;
+ int maxBound = 0;
+
+ GraphicFrame *creditsFadeFrame = _creditsFadeResource->getFrame(0);
+ _screen->copyRectToScreenWithTransparency((byte *)creditsFadeFrame->surface.pixels, creditsFadeFrame->surface.w, creditsFadeFrame->x, creditsFadeFrame->y, creditsFadeFrame->surface.w, creditsFadeFrame->surface.h);
+
+ GraphicFrame *creditsFrame = _creditsResource->getFrame(MIN<int>(_creditsResource->getFrameCount() - 1, _creditsBgFrame));
+ _screen->copyRectToScreenWithTransparency((byte *)creditsFrame->surface.pixels, creditsFrame->surface.w, creditsFrame->x, creditsFrame->y, creditsFrame->surface.w, creditsFrame->surface.h);
+
+ _creditsBgFrame++;
+ if (_creditsBgFrame >= _creditsResource->getFrameCount())
+ _creditsBgFrame = 0;
+
+ do {
+ if (posY + step >= 0) {
+ if (posY + step > 450)
+ break;
+
+ minBound = posY + step + 24;
+ if (minBound >= 0)
+ if (minBound < 32) {
+ // TODO fade side text
+ posY = _creditsTextScroll;
+ }
+
+ maxBound = posY + step;
+ if (posY + step < 480)
+ if (maxBound > 448) {
+ // TODO fade side text
+ posY = _creditsTextScroll;
+ }
+
+ _text->setTextPos(320, step + posY);
+ _text->drawResText(resId - 2147482201);
+ posY = _creditsTextScroll;
+ }
+ step += 24;
+ ++resId;
+ } while (step < 0x21F0);
+
+ _creditsTextScroll -= 2;
+
+ // TODO: some palette stuffs
+
+ // TODO: if gameFlag=901 (finished game) and already play music 56, start music 40
+
+ if (_leftClick) {
+ // Restore palette
+ _screen->setPalette(_resPack, 17);
+ // Stop all sounds
+ _sound->stopMusic();
+ // Start playing music
+ _sound->playMusic(_resPack, 39);
+ exitSubMenu();
+ }
+}
+
+void MainMenu::exitSubMenu() {
+ _leftClick = false;
+ _activeMenuScreen = kMainMenu;
+
+ // Copy the bright background to the back buffer
+ GraphicFrame *bg = _bgResource->getFrame(1);
+ _screen->copyToBackBuffer((byte *)bg->surface.pixels, bg->surface.w, 0, 0, bg->surface.w, bg->surface.h);
+
+ // Set the cursor
+ delete _cursorResource;
+ _cursorResource = new GraphicResource(_resPack, 2);
+ _screen->setCursor(_cursorResource, 0);
+}
+
+} // end of namespace Asylum
diff --git a/engines/asylum/menu.h b/engines/asylum/menu.h
index 4a83584ecf..e35de1d85a 100644
--- a/engines/asylum/menu.h
+++ b/engines/asylum/menu.h
@@ -1,135 +1,135 @@
-/* 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.
- *
- * $URL$
- * $Id$
- *
- */
-
-#ifndef ASYLUM_MENU_H_
-#define ASYLUM_MENU_H_
-
-#include "common/events.h"
-
-#include "asylum/asylum.h"
-#include "asylum/respack.h"
-#include "asylum/scene.h"
-#include "asylum/graphics.h"
-#include "asylum/text.h"
-
-namespace Asylum {
-
-class Scene;
-class Screen;
-class Sound;
-class Text;
-
-class MainMenu {
-public:
- MainMenu(Screen *screen, Sound *sound, Scene *scene);
- ~MainMenu();
-
- void handleEvent(Common::Event *event, bool doUpdate);
- bool isActive() { return _active; }
- void openMenu();
- void closeMenu();
-
-private:
-
- enum EyesAnimation {
- kEyesFront = 0,
- kEyesLeft = 1,
- kEyesRight = 2,
- kEyesTop = 3,
- kEyesBottom = 4,
- kEyesTopLeft = 5,
- kEyesTopRight = 6,
- kEyesBottomLeft = 7,
- kEyesBottomRight = 8,
- kEyesCrossed = 9
- };
-
- enum MenuScreen {
- kNewGame = 0,
- kLoadGame = 1,
- kSaveGame = 2,
- kDeleteGame = 3,
- kViewCinematics = 4,
- kQuitGame = 5,
- kTextOptions = 6,
- kAudioOptions = 7,
- kSettings = 8,
- kKeyboardConfig = 9,
- kShowCredits = 10,
- kReturnToGame = 11,
- kMainMenu = 12
- };
-
- Common::Event *_ev;
-
- Screen *_screen;
- Sound *_sound;
- Scene *_scene;
-
- uint32 _mouseX;
- uint32 _mouseY;
- int32 _activeIcon;
- int32 _previousActiveIcon;
- uint32 _curIconFrame;
- uint32 _curMouseCursor;
- int32 _cursorStep;
- uint32 _creditsBgFrame;
- uint32 _creditsTextScroll;
- bool _leftClick;
- bool _active;
-
- // FIXME this shouldnt be here. Need a proper config place
- uint32 _confGammaLevel;
- uint32 _confGameQuality;
-
- MenuScreen _activeMenuScreen;
- ResourcePack *_resPack;
- GraphicResource *_bgResource;
- GraphicResource *_cursorResource;
- GraphicResource *_eyeResource;
- GraphicResource *_iconResource;
- GraphicResource *_creditsResource;
- GraphicResource *_creditsFadeResource;
- Text *_text;
-
- void updateCursor();
- void updateEyesAnimation();
- void updateMainMenu();
-
- void updateSubMenu();
- void exitSubMenu();
- void updateSubMenuNewGame();
- void updateSubMenuCinematics();
- void updateSubMenuSettings();
- void updateSubMenuQuitGame();
- void updateSubMenuShowCredits();
-
- void update();
-
-}; // end of class MainMenu
-
-} // end of namespace Asylum
-
-#endif
+/* 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.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#ifndef ASYLUM_MENU_H_
+#define ASYLUM_MENU_H_
+
+#include "common/events.h"
+
+#include "asylum/asylum.h"
+#include "asylum/respack.h"
+#include "asylum/scene.h"
+#include "asylum/graphics.h"
+#include "asylum/text.h"
+
+namespace Asylum {
+
+class Scene;
+class Screen;
+class Sound;
+class Text;
+
+class MainMenu {
+public:
+ MainMenu(Screen *screen, Sound *sound, Scene *scene);
+ ~MainMenu();
+
+ void handleEvent(Common::Event *event, bool doUpdate);
+ bool isActive() { return _active; }
+ void openMenu();
+ void closeMenu();
+
+private:
+
+ enum EyesAnimation {
+ kEyesFront = 0,
+ kEyesLeft = 1,
+ kEyesRight = 2,
+ kEyesTop = 3,
+ kEyesBottom = 4,
+ kEyesTopLeft = 5,
+ kEyesTopRight = 6,
+ kEyesBottomLeft = 7,
+ kEyesBottomRight = 8,
+ kEyesCrossed = 9
+ };
+
+ enum MenuScreen {
+ kNewGame = 0,
+ kLoadGame = 1,
+ kSaveGame = 2,
+ kDeleteGame = 3,
+ kViewCinematics = 4,
+ kQuitGame = 5,
+ kTextOptions = 6,
+ kAudioOptions = 7,
+ kSettings = 8,
+ kKeyboardConfig = 9,
+ kShowCredits = 10,
+ kReturnToGame = 11,
+ kMainMenu = 12
+ };
+
+ Common::Event *_ev;
+
+ Screen *_screen;
+ Sound *_sound;
+ Scene *_scene;
+
+ uint32 _mouseX;
+ uint32 _mouseY;
+ int32 _activeIcon;
+ int32 _previousActiveIcon;
+ uint32 _curIconFrame;
+ uint32 _curMouseCursor;
+ int32 _cursorStep;
+ uint32 _creditsBgFrame;
+ uint32 _creditsTextScroll;
+ bool _leftClick;
+ bool _active;
+
+ // FIXME this shouldnt be here. Need a proper config place
+ uint32 _confGammaLevel;
+ uint32 _confGameQuality;
+
+ MenuScreen _activeMenuScreen;
+ ResourcePack *_resPack;
+ GraphicResource *_bgResource;
+ GraphicResource *_cursorResource;
+ GraphicResource *_eyeResource;
+ GraphicResource *_iconResource;
+ GraphicResource *_creditsResource;
+ GraphicResource *_creditsFadeResource;
+ Text *_text;
+
+ void updateCursor();
+ void updateEyesAnimation();
+ void updateMainMenu();
+
+ void updateSubMenu();
+ void exitSubMenu();
+ void updateSubMenuNewGame();
+ void updateSubMenuCinematics();
+ void updateSubMenuSettings();
+ void updateSubMenuQuitGame();
+ void updateSubMenuShowCredits();
+
+ void update();
+
+}; // end of class MainMenu
+
+} // end of namespace Asylum
+
+#endif
diff --git a/engines/asylum/respack.cpp b/engines/asylum/respack.cpp
index 091e74c900..cdb5670439 100644
--- a/engines/asylum/respack.cpp
+++ b/engines/asylum/respack.cpp
@@ -1,88 +1,88 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * $URL$
- * $Id$
- *
- */
-
-#include "asylum/respack.h"
-
-namespace Asylum {
-
-ResourcePack::ResourcePack(const char *resourceFile) {
- init(resourceFile);
-}
-
-ResourcePack::ResourcePack(int resourceIndex) {
- // We don't use the file number part of resource IDs
- //uint32 fileNum = (resourceID >> 16) & 0x7FFF;
- char filename[20];
- sprintf(filename, "res.%03d", resourceIndex);
- init(filename);
-}
-
-ResourcePack::~ResourcePack() {
- for (uint32 i = 0; i < _resources.size(); i++) {
- delete _resources[i].data;
- }
-
- _resources.clear();
-
- _packFile.close();
-}
-
-void ResourcePack::init(const char *resourceFile) {
- _packFile.open(resourceFile);
-
- uint32 entryCount = _packFile.readUint32LE();
- _resources.resize(entryCount);
-
- uint32 prevOffset = _packFile.readUint32LE();
- uint32 nextOffset = 0;
-
- for (uint32 i = 0; i < entryCount; i++) {
- ResourceEntry entry;
- entry.offset = prevOffset;
-
- // Read the offset of the next entry to determine the size of this one
- nextOffset = (i < entryCount - 1) ? _packFile.readUint32LE() : _packFile.size();
- entry.size = (nextOffset > 0) ? nextOffset - prevOffset : _packFile.size() - prevOffset;
- entry.data = 0;
-
- _resources[i] = entry;
-
- prevOffset = nextOffset;
- }
-}
-
-ResourceEntry *ResourcePack::getResource(uint32 resourceId) {
- uint16 index = resourceId & 0xFFFF;
- if (!_resources[index].data) {
- // Load the requested resource if it's not loaded already
- _packFile.seek(_resources[index].offset, SEEK_SET);
- _resources[index].data = new byte[_resources[index].size];
- _packFile.read(_resources[index].data, _resources[index].size);
- }
-
- return &_resources[index];
-}
-
-} // end of namespace Asylum
+/* 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.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#include "asylum/respack.h"
+
+namespace Asylum {
+
+ResourcePack::ResourcePack(const char *resourceFile) {
+ init(resourceFile);
+}
+
+ResourcePack::ResourcePack(int resourceIndex) {
+ // We don't use the file number part of resource IDs
+ //uint32 fileNum = (resourceID >> 16) & 0x7FFF;
+ char filename[20];
+ sprintf(filename, "res.%03d", resourceIndex);
+ init(filename);
+}
+
+ResourcePack::~ResourcePack() {
+ for (uint32 i = 0; i < _resources.size(); i++) {
+ delete _resources[i].data;
+ }
+
+ _resources.clear();
+
+ _packFile.close();
+}
+
+void ResourcePack::init(const char *resourceFile) {
+ _packFile.open(resourceFile);
+
+ uint32 entryCount = _packFile.readUint32LE();
+ _resources.resize(entryCount);
+
+ uint32 prevOffset = _packFile.readUint32LE();
+ uint32 nextOffset = 0;
+
+ for (uint32 i = 0; i < entryCount; i++) {
+ ResourceEntry entry;
+ entry.offset = prevOffset;
+
+ // Read the offset of the next entry to determine the size of this one
+ nextOffset = (i < entryCount - 1) ? _packFile.readUint32LE() : _packFile.size();
+ entry.size = (nextOffset > 0) ? nextOffset - prevOffset : _packFile.size() - prevOffset;
+ entry.data = 0;
+
+ _resources[i] = entry;
+
+ prevOffset = nextOffset;
+ }
+}
+
+ResourceEntry *ResourcePack::getResource(uint32 resourceId) {
+ uint16 index = resourceId & 0xFFFF;
+ if (!_resources[index].data) {
+ // Load the requested resource if it's not loaded already
+ _packFile.seek(_resources[index].offset, SEEK_SET);
+ _resources[index].data = new byte[_resources[index].size];
+ _packFile.read(_resources[index].data, _resources[index].size);
+ }
+
+ return &_resources[index];
+}
+
+} // end of namespace Asylum
diff --git a/engines/asylum/respack.h b/engines/asylum/respack.h
index 046abb20b3..425b4bc6fc 100644
--- a/engines/asylum/respack.h
+++ b/engines/asylum/respack.h
@@ -1,58 +1,58 @@
-/* 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.
- *
- * $URL$
- * $Id$
- *
- */
-
-#ifndef ASYLUM_RESOURCEPACK_H_
-#define ASYLUM_RESOURCEPACK_H_
-
-#include "common/array.h"
-#include "common/file.h"
-
-namespace Asylum {
-
-struct ResourceEntry {
- byte *data;
- uint32 size;
- uint32 offset;
-};
-
-class ResourcePack {
-public:
- ResourcePack(const char *resourceFile);
- ResourcePack(int resourceIndex);
- ~ResourcePack();
-
- ResourceEntry *getResource(uint32 resourceId);
- uint32 getResourceCount() { return _resources.size(); }
-
-private:
- Common::Array <ResourceEntry> _resources;
- Common::File _packFile;
-
- void init(const char *resourceFile);
-};
-
-} // end of namespace Asylum
-
-#endif
+/* 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.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#ifndef ASYLUM_RESOURCEPACK_H_
+#define ASYLUM_RESOURCEPACK_H_
+
+#include "common/array.h"
+#include "common/file.h"
+
+namespace Asylum {
+
+struct ResourceEntry {
+ byte *data;
+ uint32 size;
+ uint32 offset;
+};
+
+class ResourcePack {
+public:
+ ResourcePack(const char *resourceFile);
+ ResourcePack(int resourceIndex);
+ ~ResourcePack();
+
+ ResourceEntry *getResource(uint32 resourceId);
+ uint32 getResourceCount() { return _resources.size(); }
+
+private:
+ Common::Array <ResourceEntry> _resources;
+ Common::File _packFile;
+
+ void init(const char *resourceFile);
+};
+
+} // end of namespace Asylum
+
+#endif
diff --git a/engines/asylum/scene.cpp b/engines/asylum/scene.cpp
index 6f6a7856b0..2ba0fa3ec4 100644
--- a/engines/asylum/scene.cpp
+++ b/engines/asylum/scene.cpp
@@ -1,562 +1,561 @@
-/* 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.
- *
- * $URL$
- * $Id$
- *
- */
-
-#include "asylum/scene.h"
-#include "asylum/sceneres.h"
-
-namespace Asylum {
-
-#define SCREEN_EDGES 40
-#define SCROLL_STEP 10
-
-int g_debugPolygons;
-int g_debugBarriers;
-
-Scene::Scene(Screen *screen, Sound *sound, uint8 sceneIdx): _screen(screen), _sound(sound) {
- _sceneIdx = sceneIdx;
- _sceneResource = new SceneResource;
-
- if (_sceneResource->load(_sceneIdx)) {
- _text = new Text(_screen);
- _resPack = new ResourcePack(sceneIdx);
- _speechPack = new ResourcePack(3);
-
- _sceneResource->getMainActor()->setResourcePack(_resPack);
-
- _text->loadFont(_resPack, _sceneResource->getWorldStats()->commonRes.font1);
-
- char musPackFileName[10];
- sprintf(musPackFileName, "mus.%03d", sceneIdx);
- _musPack = new ResourcePack(musPackFileName);
- _bgResource = new GraphicResource(_resPack, _sceneResource->getWorldStats()->commonRes.backgroundImage);
- }
-
- _cursorResource = new GraphicResource(_resPack, _sceneResource->getWorldStats()->commonRes.curMagnifyingGlass);
-
- _background = 0;
- _startX = 0;
- _startY = 0;
- _leftClick = false;
- _rightButton = false;
- _isActive = false;
-
- g_debugPolygons = 0;
- g_debugBarriers = 0;
-
- // TODO Not sure why this is done ... yet
- ScriptMan.setGameFlag(183);
-}
-
-Scene::~Scene() {
- delete _cursorResource;
- delete _bgResource;
- delete _musPack;
- delete _speechPack;
- delete _resPack;
- delete _text;
- delete _sceneResource;
- }
-
-void Scene::enterScene() {
- _screen->setPalette(_resPack, _sceneResource->getWorldStats()->commonRes.palette);
-
- _background = _bgResource->getFrame(0);
- _screen->copyToBackBuffer(
- ((byte *)_background->surface.pixels) + _startY * _background->surface.w + _startX, _background->surface.w,
- 0, 0, 640, 480);
-
- _cursorStep = 1;
- _curMouseCursor = 0;
- _screen->setCursor(_cursorResource, 0);
- _screen->showCursor();
-
- // Music testing: play the first music track
- _sound->playMusic(_musPack, 0);
-
- _isActive = true;
-}
-
-ActionDefinitions* Scene::getDefaultActionList() {
- if (_sceneResource)
- return getActionList(_sceneResource->getWorldStats()->actionListIdx);
- else
- return 0;
-}
-
-ActionDefinitions* Scene::getActionList(int actionListIndex) {
- if ((actionListIndex >= 0) && (actionListIndex < (int)_sceneResource->getWorldStats()->numActions))
- return &_sceneResource->getActionList()->actions[actionListIndex];
- else
- return 0;
-}
-
-void Scene::setActorPosition(int actorIndex, int x, int y) {
- if ((actorIndex >= 0) && (actorIndex < (int)_sceneResource->getWorldStats()->numActors)) {
- _sceneResource->getWorldStats()->actors[actorIndex].boundingRect.left = x;
- _sceneResource->getWorldStats()->actors[actorIndex].boundingRect.top = y;
- }
-
- // FIXME - Remove this once mainActor uses proper actor info
- if (actorIndex == 0) {
- _sceneResource->getMainActor()->_actorX = x;
- _sceneResource->getMainActor()->_actorY = y;
- }
-}
-
-void Scene::setActorAction(int actorIndex, int action) {
- if ((actorIndex >= 0) && (actorIndex < (int)_sceneResource->getWorldStats()->numActors)) {
- _sceneResource->getWorldStats()->actors[actorIndex].direction = action;
- }
-
- // FIXME - Remove this once mainActor uses proper actor info
- if (actorIndex == 0) {
- if(_sceneResource->getMainActor())
- _sceneResource->getMainActor()->setActionByIndex(action); // The action appears to be an index rather than a direct resId
- }
-}
-
-void Scene::actorVisible(int actorIndex, bool visible) {
- if ((actorIndex >= 0) && (actorIndex < (int)_sceneResource->getWorldStats()->numActors)) {
- if(visible) // TODO - enums for flags (0x01 is visible)
- _sceneResource->getWorldStats()->actors[actorIndex].flags |= 0x01;
- else
- _sceneResource->getWorldStats()->actors[actorIndex].flags &= 0xFFFFFFFE;
- }
-
- // FIXME - Remove this once mainActor uses proper actor info
- if (actorIndex == 0) {
- //if(_sceneResource->getMainActor())
- //_sceneResource->getMainActor()->setAction(action);
- }
-}
-
-bool Scene::actorVisible(int actorIndex) {
- if ((actorIndex >= 0) && (actorIndex < (int)_sceneResource->getWorldStats()->numActors))
- return _sceneResource->getWorldStats()->actors[actorIndex].flags & 0x01; // TODO - enums for flags (0x01 is visible)
-
- // FIXME - Remove this once mainActor uses proper actor info
- if (actorIndex == 0) {
- //if(_sceneResource->getMainActor())
- //_sceneResource->getMainActor()->setAction(action);
- }
-
- return false;
-}
-
-void Scene::setScenePosition(int x, int y)
-{
- GraphicFrame *bg = _bgResource->getFrame(0);
- _startX = x;
- _startY = y;
-
- if (_startX < 0)
- _startX = 0;
- if (_startX > (bg->surface.w - 640))
- _startX = bg->surface.w - 640;
-
-
- if (_startX < 0)
- _startY = 0;
- if (_startX > (bg->surface.h - 480))
- _startY = bg->surface.h - 480;
-}
-
-void Scene::handleEvent(Common::Event *event, bool doUpdate) {
- _ev = event;
-
- switch (_ev->type) {
-
- case Common::EVENT_MOUSEMOVE:
- _mouseX = _ev->mouse.x;
- _mouseY = _ev->mouse.y;
- break;
-
- case Common::EVENT_LBUTTONUP:
- if (ScriptMan.isInputAllowed())
- _leftClick = true;
- break;
-
- case Common::EVENT_RBUTTONUP:
- if (ScriptMan.isInputAllowed()) {
- delete _cursorResource;
- // TODO This isn't always going to be the magnifying glass
- // Should check the current pointer region to identify the type
- // of cursor to use
- _cursorResource = new GraphicResource(_resPack, _sceneResource->getWorldStats()->commonRes.curMagnifyingGlass);
- _rightButton = false;
- }
- break;
-
- case Common::EVENT_RBUTTONDOWN:
- if (ScriptMan.isInputAllowed())
- _rightButton = true;
- break;
- }
-
- if (doUpdate || _leftClick)
- update();
-}
-
-void Scene::updateCursor() {
- uint32 newCursor = 0;
-
- // Change cursor
- switch (_sceneResource->getMainActor()->getCurrentAction()) {
- case kWalkN:
- newCursor = _sceneResource->getWorldStats()->commonRes.curScrollUp;
- break;
- case kWalkNE:
- newCursor = _sceneResource->getWorldStats()->commonRes.curScrollUpRight;
- break;
- case kWalkNW:
- newCursor = _sceneResource->getWorldStats()->commonRes.curScrollUpLeft;
- break;
- case kWalkS:
- newCursor = _sceneResource->getWorldStats()->commonRes.curScrollDown;
- break;
- case kWalkSE:
- newCursor = _sceneResource->getWorldStats()->commonRes.curScrollDownRight;
- break;
- case kWalkSW:
- newCursor = _sceneResource->getWorldStats()->commonRes.curScrollDownLeft;
- break;
- case kWalkW:
- newCursor = _sceneResource->getWorldStats()->commonRes.curScrollLeft;
- break;
- case kWalkE:
- newCursor = _sceneResource->getWorldStats()->commonRes.curScrollRight;
- break;
- }
-
- if (_cursorResource->getEntryNum() != newCursor) {
- delete _cursorResource;
- _cursorResource = new GraphicResource(_resPack, newCursor);
- }
-}
-
-void Scene::animateCursor() {
- _curMouseCursor += _cursorStep;
- if (_curMouseCursor == 0)
- _cursorStep = 1;
- if (_curMouseCursor == _cursorResource->getFrameCount() - 1)
- _cursorStep = -1;
-
- _screen->setCursor(_cursorResource, _curMouseCursor);
-}
-
-void Scene::update() {
- GraphicFrame *bg = _bgResource->getFrame(0);
- MainActor *mainActor = _sceneResource->getMainActor();
- WorldStats *worldStats = _sceneResource->getWorldStats();
-
- int32 curHotspot = -1;
- int32 curBarrier = -1;
-
- // DEBUG
- // Force the screen to scroll if the mouse approaches the edges
- // debugScreenScrolling(bg);
-
- // Copy the background to the back buffer before updating the scene animations
- _screen->copyToBackBuffer(((byte *)bg->surface.pixels) + _startY * bg->surface.w + _startX,
- bg->surface.w,
- 0,
- 0,
- 640,
- 480);
-
- // TODO
- // This is a hack for scene 1. This really shouldn't be hardcoded, as the
- // activation of this barrier should be interpreted by the script manager,
- // but at the moment, we're not sure where it is in the script.
- updateBarrier(_screen, _resPack, 1); // inside the middle room
-
- for(uint b=0; b < _sceneResource->getWorldStats()->barriers.size(); b++) {
- if ((_sceneResource->getWorldStats()->barriers[b].flags & 0x20) != 0) // TODO - enums for flags (0x20 is visible/playing?)
- updateBarrier(_screen, _resPack, b);
- }
-
- // TESTING
- // Main actor walking
- if (!_rightButton) {
- if (_sceneResource->getWorldStats()->actors[0].flags & 0x01) // TESTING - only draw if visible flag
- mainActor->drawActor(_screen);
- } else {
- mainActor->walkTo(_screen, _mouseX, _mouseY);
- updateCursor();
- }
-
- if (g_debugPolygons)
- debugShowPolygons();
- if (g_debugBarriers)
- debugShowBarriers();
-
- // Check if we're within a barrier
- for (uint32 p = 0; p < worldStats->numBarriers; p++) {
- BarrierItem b = worldStats->barriers[p];
- if (b.flags & 0x20) {
- if ((b.boundingRect.left + b.x <= _mouseX + _startX) && (_mouseX + _startX < b.boundingRect.right + b.x) && (b.boundingRect.top + b.y <= _mouseY + _startY) && (_mouseY + _startY < b.boundingRect.bottom + b.y)) {
- animateCursor();
- curBarrier = (int32)p;
- break;
- }
- }
- }
-
- // FIXME? I'm assigning a higher priority to barriers than polygons. I'm assuming
- // that barriers that overlap polygons will have actions associated with them, and
- // the polygon will be part of a walk/look region (so it's accessible elsewhere).
- // This could be completely wrong, and if so, we just have to check to see which
- // of the barrier/polygon action scripts should be processed first
- if (curBarrier < 0) {
- // Update cursor if it's in a polygon hotspot
- for (uint32 p = 0; p < _sceneResource->getGamePolygons()->numEntries; p++) {
- PolyDefinitions poly = _sceneResource->getGamePolygons()->polygons[p];
- if (poly.boundingRect.contains(_mouseX + _startX, _mouseY + _startY)) {
- if (pointInPoly(&poly, _mouseX + _startX, _mouseY + _startY)) {
- curHotspot = (int32)p;
- animateCursor();
- break;
- }
- }
- }
- }
-
- // DEBUGGING
- // Check current walk region
- for (uint32 a = 0; a < worldStats->numActions; a++) {
- if (worldStats->actions[a].actionType == 0) {
- PolyDefinitions poly = _sceneResource->getGamePolygons()->polygons[worldStats->actions[a].polyIdx];
- if (pointInPoly(&poly, mainActor->_actorX, mainActor->_actorY)) {
- debugShowWalkRegion(&poly);
- break;
- }
- }
- }
-
- if (_leftClick) {
- _leftClick = false;
-
- if (curHotspot >= 0) {
- for (uint32 a = 0; a < worldStats->numActions; a++) {
- if (worldStats->actions[a].polyIdx == curHotspot) {
- debugC(kDebugLevelScripts, "Hotspot: 0x%X - \"%s\", poly %d, action lists %d/%d, action type %d, sound res %d\n",
- worldStats->actions[a].id,
- worldStats->actions[a].name,
- worldStats->actions[a].polyIdx,
- worldStats->actions[a].actionListIdx1,
- worldStats->actions[a].actionListIdx2,
- worldStats->actions[a].actionType,
- worldStats->actions[a].soundResId);
- ScriptMan.setScript(&_sceneResource->getActionList()->actions[worldStats->actions[a].actionListIdx1]);
- }
- }
- } else if (curBarrier >= 0) {
- BarrierItem b = worldStats->barriers[curBarrier];
- debugC(kDebugLevelScripts, "%s: action(%d) sound(%d) flags(%d/%d)\n",
- b.name,
- b.actionListIdx,
- b.soundResId,
- b.flags,
- b.flags2);
- ScriptMan.setScript(getActionList(b.actionListIdx));
- }
- }
-}
-
-#if 0
-void Scene::copyToSceneBackground(GraphicFrame *frame, int x, int y) {
- int h = frame->surface.h;
- int w = frame->surface.w;
- byte *buffer = (byte *)frame->surface.pixels;
- byte *dest = ((byte *)_background->surface.pixels) + y * _background->surface.w + x;
-
- while (h--) {
- memcpy(dest, buffer, w);
- dest += _background->surface.w;
- buffer += frame->surface.w;
- }
-}
-#endif
-
-void Scene::copyToBackBufferClipped(Graphics::Surface *surface, int x, int y) {
- Common::Rect screenRect(_startX, _startY, _startX + 640, _startY + 480);
- Common::Rect animRect(x, y, x + surface->w, y + surface->h);
- animRect.clip(screenRect);
-
- if (!animRect.isEmpty()) {
- // Translate anim rectangle
- animRect.translate(-_startX, -_startY);
-
- int startX = animRect.right == 640 ? 0 : surface->w - animRect.width();
- int startY = animRect.bottom == 480 ? 0 : surface->h - animRect.height();
-
- if (surface->w > 640)
- startX = _startX;
- if (surface->h > 480)
- startY = _startY;
-
- _screen->copyToBackBufferWithTransparency(
- ((byte*)surface->pixels) +
- startY * surface->pitch +
- startX * surface->bytesPerPixel,
- surface->pitch,
- animRect.left,
- animRect.top,
- animRect.width(),
- animRect.height());
- }
-}
-
-void Scene::updateBarrier(Screen *screen, ResourcePack *res, uint8 barrierIndex) {
- BarrierItem barrier = _sceneResource->getWorldStats()->barriers[barrierIndex];
- GraphicResource *gra = new GraphicResource(res, barrier.resId);
- if (!gra->getFrameCount())
- return;
-
- GraphicFrame *fra = gra->getFrame(barrier.tickCount);
-
-#if 0
- // DEBUG bounding box
- // FIXME this should be a generic method which draws for an entire graphicResource and not for single graphicFrames
- fra->surface.frameRect(barrier.boundingRect, 0xFF);
-#endif
-
- copyToBackBufferClipped(&fra->surface, barrier.x, barrier.y);
-
- if (barrier.tickCount < barrier.frameCount - 1) {
- barrier.tickCount++;
- } else {
- barrier.tickCount = barrier.frameIdx;
- }
-
- _sceneResource->getWorldStats()->barriers[barrierIndex] = barrier;
-
- delete gra;
-}
-
-bool Scene::pointInPoly(PolyDefinitions *poly, int x, int y) {
- // Copied from backends/vkeybd/polygon.cpp
- int yflag0;
- int yflag1;
- bool inside_flag = false;
- unsigned int pt;
-
- Common::Point *vtx0 = &poly->points[poly->numPoints - 1];
- Common::Point *vtx1 = &poly->points[0];
-
- yflag0 = (vtx0->y >= y);
- for (pt = 0; pt < poly->numPoints; pt++, vtx1++) {
- yflag1 = (vtx1->y >= y);
- if (yflag0 != yflag1) {
- if (((vtx1->y - y) * (vtx0->x - vtx1->x) >=
- (vtx1->x - x) * (vtx0->y - vtx1->y)) == yflag1) {
- inside_flag = !inside_flag;
- }
- }
- yflag0 = yflag1;
- vtx0 = vtx1;
- }
-
- return inside_flag;
-}
-
-void Scene::debugScreenScrolling(GraphicFrame *bg) {
- // Horizontal scrolling
- if (_mouseX < SCREEN_EDGES && _startX >= SCROLL_STEP)
- _startX -= SCROLL_STEP;
- else if (_mouseX > 640 - SCREEN_EDGES && _startX <= bg->surface.w - 640 - SCROLL_STEP)
- _startX += SCROLL_STEP;
-
- // Vertical scrolling
- if (_mouseY < SCREEN_EDGES && _startY >= SCROLL_STEP)
- _startY -= SCROLL_STEP;
- else if (_mouseY > 480 - SCREEN_EDGES && _startY <= bg->surface.h - 480 - SCROLL_STEP)
- _startY += SCROLL_STEP;
-}
-
-// WALK REGION DEBUG
-void Scene::debugShowWalkRegion(PolyDefinitions *poly) {
- Graphics::Surface surface;
- surface.create(poly->boundingRect.right - poly->boundingRect.left + 1,
- poly->boundingRect.bottom - poly->boundingRect.top + 1,
- 1);
-
- // Draw all lines in Polygon
- for (uint32 i=0; i < poly->numPoints; i++) {
- surface.drawLine(
- poly->points[i].x - poly->boundingRect.left,
- poly->points[i].y - poly->boundingRect.top,
- poly->points[(i+1) % poly->numPoints].x - poly->boundingRect.left,
- poly->points[(i+1) % poly->numPoints].y - poly->boundingRect.top, 0x3A);
- }
-
- copyToBackBufferClipped(&surface, poly->boundingRect.left, poly->boundingRect.top);
-
- surface.free();
-}
-
-// POLYGONS DEBUG
-void Scene::debugShowPolygons() {
- for (uint32 p = 0; p < _sceneResource->getGamePolygons()->numEntries; p++) {
- Graphics::Surface surface;
- PolyDefinitions poly = _sceneResource->getGamePolygons()->polygons[p];
- surface.create(poly.boundingRect.right - poly.boundingRect.left + 1,
- poly.boundingRect.bottom - poly.boundingRect.top + 1,
- 1);
-
- // Draw all lines in Polygon
- for (uint32 i=0; i < poly.numPoints; i++) {
- surface.drawLine(
- poly.points[i].x - poly.boundingRect.left,
- poly.points[i].y - poly.boundingRect.top,
- poly.points[(i+1) % poly.numPoints].x - poly.boundingRect.left,
- poly.points[(i+1) % poly.numPoints].y - poly.boundingRect.top, 0xFF);
- }
-
- copyToBackBufferClipped(&surface, poly.boundingRect.left, poly.boundingRect.top);
-
- surface.free();
- }
-}
-
-// BARRIER DEBUGGING
-void Scene::debugShowBarriers() {
- for (uint32 p = 0; p < _sceneResource->getWorldStats()->numBarriers; p++) {
- Graphics::Surface surface;
- BarrierItem b = _sceneResource->getWorldStats()->barriers[p];
-
- if (b.flags & 0x20) {
- surface.create(b.boundingRect.right - b.boundingRect.left + 1,
- b.boundingRect.bottom - b.boundingRect.top + 1,
- 1);
- surface.frameRect(b.boundingRect, 0x22);
- copyToBackBufferClipped(&surface, b.x, b.y);
- }
-
- surface.free();
- }
-}
-
-} // end of namespace Asylum
+/* 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.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#include "asylum/scene.h"
+#include "asylum/sceneres.h"
+
+namespace Asylum {
+
+#define SCREEN_EDGES 40
+#define SCROLL_STEP 10
+
+int g_debugPolygons;
+int g_debugBarriers;
+
+Scene::Scene(Screen *screen, Sound *sound, uint8 sceneIdx): _screen(screen), _sound(sound) {
+ _sceneIdx = sceneIdx;
+ _sceneResource = new SceneResource;
+
+ if (_sceneResource->load(_sceneIdx)) {
+ _text = new Text(_screen);
+ _resPack = new ResourcePack(sceneIdx);
+ _speechPack = new ResourcePack(3);
+
+ _sceneResource->getMainActor()->setResourcePack(_resPack);
+
+ _text->loadFont(_resPack, _sceneResource->getWorldStats()->commonRes.font1);
+
+ char musPackFileName[10];
+ sprintf(musPackFileName, "mus.%03d", sceneIdx);
+ _musPack = new ResourcePack(musPackFileName);
+ _bgResource = new GraphicResource(_resPack, _sceneResource->getWorldStats()->commonRes.backgroundImage);
+ }
+
+ _cursorResource = new GraphicResource(_resPack, _sceneResource->getWorldStats()->commonRes.curMagnifyingGlass);
+
+ _background = 0;
+ _startX = 0;
+ _startY = 0;
+ _leftClick = false;
+ _rightButton = false;
+ _isActive = false;
+
+ g_debugPolygons = 0;
+ g_debugBarriers = 0;
+
+ // TODO Not sure why this is done ... yet
+ ScriptMan.setGameFlag(183);
+}
+
+Scene::~Scene() {
+ delete _cursorResource;
+ delete _bgResource;
+ delete _musPack;
+ delete _speechPack;
+ delete _resPack;
+ delete _text;
+ delete _sceneResource;
+ }
+
+void Scene::enterScene() {
+ _screen->setPalette(_resPack, _sceneResource->getWorldStats()->commonRes.palette);
+ _background = _bgResource->getFrame(0);
+ _screen->copyToBackBuffer(
+ ((byte *)_background->surface.pixels) + _startY * _background->surface.w + _startX, _background->surface.w,
+ 0, 0, 640, 480);
+
+ _cursorStep = 1;
+ _curMouseCursor = 0;
+ _screen->setCursor(_cursorResource, 0);
+ _screen->showCursor();
+
+ // Music testing: play the first music track
+ _sound->playMusic(_musPack, 0);
+
+ _isActive = true;
+}
+
+ActionDefinitions* Scene::getDefaultActionList() {
+ if (_sceneResource)
+ return getActionList(_sceneResource->getWorldStats()->actionListIdx);
+ else
+ return 0;
+}
+
+ActionDefinitions* Scene::getActionList(int actionListIndex) {
+ if ((actionListIndex >= 0) && (actionListIndex < (int)_sceneResource->getWorldStats()->numActions))
+ return &_sceneResource->getActionList()->actions[actionListIndex];
+ else
+ return 0;
+}
+
+void Scene::setActorPosition(int actorIndex, int x, int y) {
+ if ((actorIndex >= 0) && (actorIndex < (int)_sceneResource->getWorldStats()->numActors)) {
+ _sceneResource->getWorldStats()->actors[actorIndex].boundingRect.left = x;
+ _sceneResource->getWorldStats()->actors[actorIndex].boundingRect.top = y;
+ }
+
+ // FIXME - Remove this once mainActor uses proper actor info
+ if (actorIndex == 0) {
+ _sceneResource->getMainActor()->_actorX = x;
+ _sceneResource->getMainActor()->_actorY = y;
+ }
+}
+
+void Scene::setActorAction(int actorIndex, int action) {
+ if ((actorIndex >= 0) && (actorIndex < (int)_sceneResource->getWorldStats()->numActors)) {
+ _sceneResource->getWorldStats()->actors[actorIndex].direction = action;
+ }
+
+ // FIXME - Remove this once mainActor uses proper actor info
+ if (actorIndex == 0) {
+ if(_sceneResource->getMainActor())
+ _sceneResource->getMainActor()->setActionByIndex(action); // The action appears to be an index rather than a direct resId
+ }
+}
+
+void Scene::actorVisible(int actorIndex, bool visible) {
+ if ((actorIndex >= 0) && (actorIndex < (int)_sceneResource->getWorldStats()->numActors)) {
+ if(visible) // TODO - enums for flags (0x01 is visible)
+ _sceneResource->getWorldStats()->actors[actorIndex].flags |= 0x01;
+ else
+ _sceneResource->getWorldStats()->actors[actorIndex].flags &= 0xFFFFFFFE;
+ }
+
+ // FIXME - Remove this once mainActor uses proper actor info
+ if (actorIndex == 0) {
+ //if(_sceneResource->getMainActor())
+ //_sceneResource->getMainActor()->setAction(action);
+ }
+}
+
+bool Scene::actorVisible(int actorIndex) {
+ if ((actorIndex >= 0) && (actorIndex < (int)_sceneResource->getWorldStats()->numActors))
+ return _sceneResource->getWorldStats()->actors[actorIndex].flags & 0x01; // TODO - enums for flags (0x01 is visible)
+
+ // FIXME - Remove this once mainActor uses proper actor info
+ if (actorIndex == 0) {
+ //if(_sceneResource->getMainActor())
+ //_sceneResource->getMainActor()->setAction(action);
+ }
+
+ return false;
+}
+
+void Scene::setScenePosition(int x, int y)
+{
+ GraphicFrame *bg = _bgResource->getFrame(0);
+ _startX = x;
+ _startY = y;
+
+ if (_startX < 0)
+ _startX = 0;
+ if (_startX > (bg->surface.w - 640))
+ _startX = bg->surface.w - 640;
+
+
+ if (_startX < 0)
+ _startY = 0;
+ if (_startX > (bg->surface.h - 480))
+ _startY = bg->surface.h - 480;
+}
+
+void Scene::handleEvent(Common::Event *event, bool doUpdate) {
+ _ev = event;
+
+ switch (_ev->type) {
+
+ case Common::EVENT_MOUSEMOVE:
+ _mouseX = _ev->mouse.x;
+ _mouseY = _ev->mouse.y;
+ break;
+
+ case Common::EVENT_LBUTTONUP:
+ if (ScriptMan.isInputAllowed())
+ _leftClick = true;
+ break;
+
+ case Common::EVENT_RBUTTONUP:
+ if (ScriptMan.isInputAllowed()) {
+ delete _cursorResource;
+ // TODO This isn't always going to be the magnifying glass
+ // Should check the current pointer region to identify the type
+ // of cursor to use
+ _cursorResource = new GraphicResource(_resPack, _sceneResource->getWorldStats()->commonRes.curMagnifyingGlass);
+ _rightButton = false;
+ }
+ break;
+
+ case Common::EVENT_RBUTTONDOWN:
+ if (ScriptMan.isInputAllowed())
+ _rightButton = true;
+ break;
+ }
+
+ if (doUpdate || _leftClick)
+ update();
+}
+
+void Scene::updateCursor() {
+ uint32 newCursor = 0;
+
+ // Change cursor
+ switch (_sceneResource->getMainActor()->getCurrentAction()) {
+ case kWalkN:
+ newCursor = _sceneResource->getWorldStats()->commonRes.curScrollUp;
+ break;
+ case kWalkNE:
+ newCursor = _sceneResource->getWorldStats()->commonRes.curScrollUpRight;
+ break;
+ case kWalkNW:
+ newCursor = _sceneResource->getWorldStats()->commonRes.curScrollUpLeft;
+ break;
+ case kWalkS:
+ newCursor = _sceneResource->getWorldStats()->commonRes.curScrollDown;
+ break;
+ case kWalkSE:
+ newCursor = _sceneResource->getWorldStats()->commonRes.curScrollDownRight;
+ break;
+ case kWalkSW:
+ newCursor = _sceneResource->getWorldStats()->commonRes.curScrollDownLeft;
+ break;
+ case kWalkW:
+ newCursor = _sceneResource->getWorldStats()->commonRes.curScrollLeft;
+ break;
+ case kWalkE:
+ newCursor = _sceneResource->getWorldStats()->commonRes.curScrollRight;
+ break;
+ }
+
+ if (_cursorResource->getEntryNum() != newCursor) {
+ delete _cursorResource;
+ _cursorResource = new GraphicResource(_resPack, newCursor);
+ }
+}
+
+void Scene::animateCursor() {
+ _curMouseCursor += _cursorStep;
+ if (_curMouseCursor == 0)
+ _cursorStep = 1;
+ if (_curMouseCursor == _cursorResource->getFrameCount() - 1)
+ _cursorStep = -1;
+
+ _screen->setCursor(_cursorResource, _curMouseCursor);
+}
+
+void Scene::update() {
+ GraphicFrame *bg = _bgResource->getFrame(0);
+ MainActor *mainActor = _sceneResource->getMainActor();
+ WorldStats *worldStats = _sceneResource->getWorldStats();
+
+ int32 curHotspot = -1;
+ int32 curBarrier = -1;
+
+ // DEBUG
+ // Force the screen to scroll if the mouse approaches the edges
+ // debugScreenScrolling(bg);
+
+ // Copy the background to the back buffer before updating the scene animations
+ _screen->copyToBackBuffer(((byte *)bg->surface.pixels) + _startY * bg->surface.w + _startX,
+ bg->surface.w,
+ 0,
+ 0,
+ 640,
+ 480);
+
+ // TODO
+ // This is a hack for scene 1. This really shouldn't be hardcoded, as the
+ // activation of this barrier should be interpreted by the script manager,
+ // but at the moment, we're not sure where it is in the script.
+ updateBarrier(_screen, _resPack, 1); // inside the middle room
+
+ for(uint b=0; b < _sceneResource->getWorldStats()->barriers.size(); b++) {
+ if ((_sceneResource->getWorldStats()->barriers[b].flags & 0x20) != 0) // TODO - enums for flags (0x20 is visible/playing?)
+ updateBarrier(_screen, _resPack, b);
+ }
+
+ // TESTING
+ // Main actor walking
+ if (!_rightButton) {
+ if (_sceneResource->getWorldStats()->actors[0].flags & 0x01) // TESTING - only draw if visible flag
+ mainActor->drawActor(_screen);
+ } else {
+ mainActor->walkTo(_screen, _mouseX, _mouseY);
+ updateCursor();
+ }
+
+ if (g_debugPolygons)
+ debugShowPolygons();
+ if (g_debugBarriers)
+ debugShowBarriers();
+
+ // Check if we're within a barrier
+ for (uint32 p = 0; p < worldStats->numBarriers; p++) {
+ BarrierItem b = worldStats->barriers[p];
+ if (b.flags & 0x20) {
+ if ((b.boundingRect.left + b.x <= _mouseX + _startX) && (_mouseX + _startX < b.boundingRect.right + b.x) && (b.boundingRect.top + b.y <= _mouseY + _startY) && (_mouseY + _startY < b.boundingRect.bottom + b.y)) {
+ animateCursor();
+ curBarrier = (int32)p;
+ break;
+ }
+ }
+ }
+
+ // FIXME? I'm assigning a higher priority to barriers than polygons. I'm assuming
+ // that barriers that overlap polygons will have actions associated with them, and
+ // the polygon will be part of a walk/look region (so it's accessible elsewhere).
+ // This could be completely wrong, and if so, we just have to check to see which
+ // of the barrier/polygon action scripts should be processed first
+ if (curBarrier < 0) {
+ // Update cursor if it's in a polygon hotspot
+ for (uint32 p = 0; p < _sceneResource->getGamePolygons()->numEntries; p++) {
+ PolyDefinitions poly = _sceneResource->getGamePolygons()->polygons[p];
+ if (poly.boundingRect.contains(_mouseX + _startX, _mouseY + _startY)) {
+ if (pointInPoly(&poly, _mouseX + _startX, _mouseY + _startY)) {
+ curHotspot = (int32)p;
+ animateCursor();
+ break;
+ }
+ }
+ }
+ }
+
+ // DEBUGGING
+ // Check current walk region
+ for (uint32 a = 0; a < worldStats->numActions; a++) {
+ if (worldStats->actions[a].actionType == 0) {
+ PolyDefinitions poly = _sceneResource->getGamePolygons()->polygons[worldStats->actions[a].polyIdx];
+ if (pointInPoly(&poly, mainActor->_actorX, mainActor->_actorY)) {
+ debugShowWalkRegion(&poly);
+ break;
+ }
+ }
+ }
+
+ if (_leftClick) {
+ _leftClick = false;
+
+ if (curHotspot >= 0) {
+ for (uint32 a = 0; a < worldStats->numActions; a++) {
+ if (worldStats->actions[a].polyIdx == curHotspot) {
+ debugC(kDebugLevelScripts, "Hotspot: 0x%X - \"%s\", poly %d, action lists %d/%d, action type %d, sound res %d\n",
+ worldStats->actions[a].id,
+ worldStats->actions[a].name,
+ worldStats->actions[a].polyIdx,
+ worldStats->actions[a].actionListIdx1,
+ worldStats->actions[a].actionListIdx2,
+ worldStats->actions[a].actionType,
+ worldStats->actions[a].soundResId);
+ ScriptMan.setScript(&_sceneResource->getActionList()->actions[worldStats->actions[a].actionListIdx1]);
+ }
+ }
+ } else if (curBarrier >= 0) {
+ BarrierItem b = worldStats->barriers[curBarrier];
+ debugC(kDebugLevelScripts, "%s: action(%d) sound(%d) flags(%d/%d)\n",
+ b.name,
+ b.actionListIdx,
+ b.soundResId,
+ b.flags,
+ b.flags2);
+ ScriptMan.setScript(getActionList(b.actionListIdx));
+ }
+ }
+}
+
+#if 0
+void Scene::copyToSceneBackground(GraphicFrame *frame, int x, int y) {
+ int h = frame->surface.h;
+ int w = frame->surface.w;
+ byte *buffer = (byte *)frame->surface.pixels;
+ byte *dest = ((byte *)_background->surface.pixels) + y * _background->surface.w + x;
+
+ while (h--) {
+ memcpy(dest, buffer, w);
+ dest += _background->surface.w;
+ buffer += frame->surface.w;
+ }
+}
+#endif
+
+void Scene::copyToBackBufferClipped(Graphics::Surface *surface, int x, int y) {
+ Common::Rect screenRect(_startX, _startY, _startX + 640, _startY + 480);
+ Common::Rect animRect(x, y, x + surface->w, y + surface->h);
+ animRect.clip(screenRect);
+
+ if (!animRect.isEmpty()) {
+ // Translate anim rectangle
+ animRect.translate(-_startX, -_startY);
+
+ int startX = animRect.right == 640 ? 0 : surface->w - animRect.width();
+ int startY = animRect.bottom == 480 ? 0 : surface->h - animRect.height();
+
+ if (surface->w > 640)
+ startX = _startX;
+ if (surface->h > 480)
+ startY = _startY;
+
+ _screen->copyToBackBufferWithTransparency(
+ ((byte*)surface->pixels) +
+ startY * surface->pitch +
+ startX * surface->bytesPerPixel,
+ surface->pitch,
+ animRect.left,
+ animRect.top,
+ animRect.width(),
+ animRect.height());
+ }
+}
+
+void Scene::updateBarrier(Screen *screen, ResourcePack *res, uint8 barrierIndex) {
+ BarrierItem barrier = _sceneResource->getWorldStats()->barriers[barrierIndex];
+ GraphicResource *gra = new GraphicResource(res, barrier.resId);
+ if (!gra->getFrameCount())
+ return;
+
+ GraphicFrame *fra = gra->getFrame(barrier.tickCount);
+
+#if 0
+ // DEBUG bounding box
+ // FIXME this should be a generic method which draws for an entire graphicResource and not for single graphicFrames
+ fra->surface.frameRect(barrier.boundingRect, 0xFF);
+#endif
+
+ copyToBackBufferClipped(&fra->surface, barrier.x, barrier.y);
+
+ if (barrier.tickCount < barrier.frameCount - 1) {
+ barrier.tickCount++;
+ } else {
+ barrier.tickCount = barrier.frameIdx;
+ }
+
+ _sceneResource->getWorldStats()->barriers[barrierIndex] = barrier;
+
+ delete gra;
+}
+
+bool Scene::pointInPoly(PolyDefinitions *poly, int x, int y) {
+ // Copied from backends/vkeybd/polygon.cpp
+ int yflag0;
+ int yflag1;
+ bool inside_flag = false;
+ unsigned int pt;
+
+ Common::Point *vtx0 = &poly->points[poly->numPoints - 1];
+ Common::Point *vtx1 = &poly->points[0];
+
+ yflag0 = (vtx0->y >= y);
+ for (pt = 0; pt < poly->numPoints; pt++, vtx1++) {
+ yflag1 = (vtx1->y >= y);
+ if (yflag0 != yflag1) {
+ if (((vtx1->y - y) * (vtx0->x - vtx1->x) >=
+ (vtx1->x - x) * (vtx0->y - vtx1->y)) == yflag1) {
+ inside_flag = !inside_flag;
+ }
+ }
+ yflag0 = yflag1;
+ vtx0 = vtx1;
+ }
+
+ return inside_flag;
+}
+
+void Scene::debugScreenScrolling(GraphicFrame *bg) {
+ // Horizontal scrolling
+ if (_mouseX < SCREEN_EDGES && _startX >= SCROLL_STEP)
+ _startX -= SCROLL_STEP;
+ else if (_mouseX > 640 - SCREEN_EDGES && _startX <= bg->surface.w - 640 - SCROLL_STEP)
+ _startX += SCROLL_STEP;
+
+ // Vertical scrolling
+ if (_mouseY < SCREEN_EDGES && _startY >= SCROLL_STEP)
+ _startY -= SCROLL_STEP;
+ else if (_mouseY > 480 - SCREEN_EDGES && _startY <= bg->surface.h - 480 - SCROLL_STEP)
+ _startY += SCROLL_STEP;
+}
+
+// WALK REGION DEBUG
+void Scene::debugShowWalkRegion(PolyDefinitions *poly) {
+ Graphics::Surface surface;
+ surface.create(poly->boundingRect.right - poly->boundingRect.left + 1,
+ poly->boundingRect.bottom - poly->boundingRect.top + 1,
+ 1);
+
+ // Draw all lines in Polygon
+ for (uint32 i=0; i < poly->numPoints; i++) {
+ surface.drawLine(
+ poly->points[i].x - poly->boundingRect.left,
+ poly->points[i].y - poly->boundingRect.top,
+ poly->points[(i+1) % poly->numPoints].x - poly->boundingRect.left,
+ poly->points[(i+1) % poly->numPoints].y - poly->boundingRect.top, 0x3A);
+ }
+
+ copyToBackBufferClipped(&surface, poly->boundingRect.left, poly->boundingRect.top);
+
+ surface.free();
+}
+
+// POLYGONS DEBUG
+void Scene::debugShowPolygons() {
+ for (uint32 p = 0; p < _sceneResource->getGamePolygons()->numEntries; p++) {
+ Graphics::Surface surface;
+ PolyDefinitions poly = _sceneResource->getGamePolygons()->polygons[p];
+ surface.create(poly.boundingRect.right - poly.boundingRect.left + 1,
+ poly.boundingRect.bottom - poly.boundingRect.top + 1,
+ 1);
+
+ // Draw all lines in Polygon
+ for (uint32 i=0; i < poly.numPoints; i++) {
+ surface.drawLine(
+ poly.points[i].x - poly.boundingRect.left,
+ poly.points[i].y - poly.boundingRect.top,
+ poly.points[(i+1) % poly.numPoints].x - poly.boundingRect.left,
+ poly.points[(i+1) % poly.numPoints].y - poly.boundingRect.top, 0xFF);
+ }
+
+ copyToBackBufferClipped(&surface, poly.boundingRect.left, poly.boundingRect.top);
+
+ surface.free();
+ }
+}
+
+// BARRIER DEBUGGING
+void Scene::debugShowBarriers() {
+ for (uint32 p = 0; p < _sceneResource->getWorldStats()->numBarriers; p++) {
+ Graphics::Surface surface;
+ BarrierItem b = _sceneResource->getWorldStats()->barriers[p];
+
+ if (b.flags & 0x20) {
+ surface.create(b.boundingRect.right - b.boundingRect.left + 1,
+ b.boundingRect.bottom - b.boundingRect.top + 1,
+ 1);
+ surface.frameRect(b.boundingRect, 0x22);
+ copyToBackBufferClipped(&surface, b.x, b.y);
+ }
+
+ surface.free();
+ }
+}
+
+} // end of namespace Asylum
diff --git a/engines/asylum/scene.h b/engines/asylum/scene.h
index d27bef199e..bee98b93a5 100644
--- a/engines/asylum/scene.h
+++ b/engines/asylum/scene.h
@@ -1,131 +1,131 @@
-/* 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.
- *
- * $URL$
- * $Id$
- *
- */
-
-#ifndef ASYLUM_SCENE_H_
-#define ASYLUM_SCENE_H_
-
-#include "common/events.h"
-
-#include "asylum/asylum.h"
-#include "asylum/respack.h"
-#include "asylum/graphics.h"
-#include "asylum/text.h"
-#include "asylum/sceneres.h"
-
-namespace Asylum {
-
-class Screen;
-class Sound;
-class Text;
-class SceneResource;
-struct ActionDefinitions;
-struct PolyDefinitions;
-
-class Scene {
-public:
- Scene(Screen *screen, Sound *sound, uint8 sceneIdx);
- ~Scene();
-
- void handleEvent(Common::Event *event, bool doUpdate);
-
- void enterScene();
- void activate() { _isActive = true; }
- void deactivate() { _isActive = false; }
- bool isActive() { return _isActive; }
- int getSceneIndex() { return _sceneIdx; }
-
- ActionDefinitions* getDefaultActionList();
- ActionDefinitions* getActionList(int actionListIndex);
-
- void setActorPosition(int actorIndex, int x, int y);
- void setActorAction(int actorIndex, int action);
- void actorVisible(int actorIndex, bool visible);
- bool actorVisible(int actorIndex);
-
- void setScenePosition(int x, int y);
-
- SceneResource* getResources() { return _sceneResource; }
- ResourcePack* getResourcePack() { return _resPack; }
- GraphicResource* getGraphicResource(uint32 entry) { return new GraphicResource(_resPack, entry); }
-
-private:
-#if 0
- void copyToSceneBackground(GraphicFrame *frame, int x, int y);
-#endif
- void copyToBackBufferClipped(Graphics::Surface *surface, int x, int y);
-
- uint8 _sceneIdx;
- SceneResource *_sceneResource;
- ResourcePack *_resPack;
- ResourcePack *_speechPack;
- ResourcePack *_musPack;
-
- Screen *_screen;
- Sound *_sound;
- Common::Event *_ev;
-
- Text *_text;
- GraphicResource *_bgResource;
- GraphicResource *_cursorResource;
- GraphicFrame *_background;
-
- uint32 _mouseX;
- uint32 _mouseY;
- int32 _startX;
- int32 _startY;
- bool _leftClick;
- bool _rightButton;
- uint32 _curMouseCursor;
- int32 _cursorStep;
- bool _isActive;
-
- void update();
-
- /**
- * Check whether the cursor resource needs to be changed, and
+/* 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.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#ifndef ASYLUM_SCENE_H_
+#define ASYLUM_SCENE_H_
+
+#include "common/events.h"
+
+#include "asylum/asylum.h"
+#include "asylum/respack.h"
+#include "asylum/graphics.h"
+#include "asylum/text.h"
+#include "asylum/sceneres.h"
+
+namespace Asylum {
+
+class Screen;
+class Sound;
+class Text;
+class SceneResource;
+struct ActionDefinitions;
+struct PolyDefinitions;
+
+class Scene {
+public:
+ Scene(Screen *screen, Sound *sound, uint8 sceneIdx);
+ ~Scene();
+
+ void handleEvent(Common::Event *event, bool doUpdate);
+
+ void enterScene();
+ void activate() { _isActive = true; }
+ void deactivate() { _isActive = false; }
+ bool isActive() { return _isActive; }
+ int getSceneIndex() { return _sceneIdx; }
+
+ ActionDefinitions* getDefaultActionList();
+ ActionDefinitions* getActionList(int actionListIndex);
+
+ void setActorPosition(int actorIndex, int x, int y);
+ void setActorAction(int actorIndex, int action);
+ void actorVisible(int actorIndex, bool visible);
+ bool actorVisible(int actorIndex);
+
+ void setScenePosition(int x, int y);
+
+ SceneResource* getResources() { return _sceneResource; }
+ ResourcePack* getResourcePack() { return _resPack; }
+ GraphicResource* getGraphicResource(uint32 entry) { return new GraphicResource(_resPack, entry); }
+
+private:
+#if 0
+ void copyToSceneBackground(GraphicFrame *frame, int x, int y);
+#endif
+ void copyToBackBufferClipped(Graphics::Surface *surface, int x, int y);
+
+ uint8 _sceneIdx;
+ SceneResource *_sceneResource;
+ ResourcePack *_resPack;
+ ResourcePack *_speechPack;
+ ResourcePack *_musPack;
+
+ Screen *_screen;
+ Sound *_sound;
+ Common::Event *_ev;
+
+ Text *_text;
+ GraphicResource *_bgResource;
+ GraphicResource *_cursorResource;
+ GraphicFrame *_background;
+
+ uint32 _mouseX;
+ uint32 _mouseY;
+ int32 _startX;
+ int32 _startY;
+ bool _leftClick;
+ bool _rightButton;
+ uint32 _curMouseCursor;
+ int32 _cursorStep;
+ bool _isActive;
+
+ void update();
+
+ /**
+ * Check whether the cursor resource needs to be changed, and
* if so, make that change
- */
- void updateCursor();
-
- /**
- * Update the cursor to visually indicate that it is over a
+ */
+ void updateCursor();
+
+ /**
+ * Update the cursor to visually indicate that it is over a
* clickable region (by running its associated animation)
- */
- void animateCursor();
-
- void updateBarrier(Screen *screen, ResourcePack *res, uint8 actorIndex);
-
- void debugScreenScrolling(GraphicFrame *bg);
- void debugShowPolygons();
- void debugShowBarriers();
- void debugShowWalkRegion(PolyDefinitions *poly);
- bool pointInPoly(PolyDefinitions *poly, int x, int y);
-
- friend class ScriptManager;
-}; // end of class Scene
-
-} // end of namespace Asylum
-
-#endif
+ */
+ void animateCursor();
+
+ void updateBarrier(Screen *screen, ResourcePack *res, uint8 actorIndex);
+
+ void debugScreenScrolling(GraphicFrame *bg);
+ void debugShowPolygons();
+ void debugShowBarriers();
+ void debugShowWalkRegion(PolyDefinitions *poly);
+ bool pointInPoly(PolyDefinitions *poly, int x, int y);
+
+ friend class ScriptManager;
+}; // end of class Scene
+
+} // end of namespace Asylum
+
+#endif
diff --git a/engines/asylum/sceneres.cpp b/engines/asylum/sceneres.cpp
index f5ced5ac7b..9729c49c9f 100644
--- a/engines/asylum/sceneres.cpp
+++ b/engines/asylum/sceneres.cpp
@@ -1,461 +1,461 @@
-/* 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.
- *
- * $URL$
- * $Id$
- *
- */
-
-#include "asylum/sceneres.h"
-
-namespace Asylum {
-
-SceneResource::SceneResource() {
-}
-
-SceneResource::~SceneResource() {
- delete _worldStats;
- delete _mainActor;
- for (uint i=0; i < _gamePolygons->numEntries; i++) {
- delete[] _gamePolygons->polygons[i].points;
- }
- delete _gamePolygons;
- delete _actionList;
-}
-
-int SceneResource::getBarrierIndexById(uint32 id) {
- for (uint32 i=0; i < _worldStats->numBarriers; i++) {
- if (_worldStats->barriers[i].id == id)
- return i;
- }
- return -1;
-}
-
-bool SceneResource::load(uint8 sceneIdx) {
- char sceneTag[6];
- Common::File* fd = new Common::File;
- Common::String filename = parseFilename(sceneIdx);
-
- if (!fd->exists(filename)) {
- warning("Scene file doesn't exist %s", filename.c_str());
- return false;
- }
-
- fd->open(filename);
-
- if (!fd->isOpen()) {
- warning("Failed to load scene file %s", filename.c_str());
- return false;
- }
-
- fd->read(sceneTag,6);
-
- if (Common::String(sceneTag,6) != "DFISCN") {
- warning("The file isn't recognized as scene %s", filename.c_str());
- return false;
- }
-
- loadWorldStats(fd);
- loadGamePolygons(fd);
- loadActionList(fd);
-
- fd->close();
- delete fd;
-
- return true;
-}
-
-// FIXME: load necessary World Stats content
-void SceneResource::loadWorldStats(Common::SeekableReadStream *stream) {
- _worldStats = new WorldStats;
-
- _worldStats->size = stream->readUint32LE();
- _worldStats->numEntries = stream->readUint32LE();
-
- _worldStats->numChapter = stream->readUint32LE();
- _worldStats->xLeft = stream->readUint32LE();
- _worldStats->yTop = stream->readUint32LE();
- _worldStats->boundingRect.left = stream->readUint32LE() & 0xFFFF;
- _worldStats->boundingRect.top = stream->readUint32LE() & 0xFFFF;
- _worldStats->boundingRect.right = stream->readUint32LE() & 0xFFFF;
- _worldStats->boundingRect.bottom = stream->readUint32LE() & 0xFFFF;
-
- // read common graphic resources
- _worldStats->commonRes.backgroundImage = stream->readUint32LE();
- _worldStats->commonRes.curScrollUp = stream->readUint32LE();
- _worldStats->commonRes.curScrollUpLeft = stream->readUint32LE();
- _worldStats->commonRes.curScrollLeft = stream->readUint32LE();
- _worldStats->commonRes.curScrollDownLeft = stream->readUint32LE();
- _worldStats->commonRes.curScrollDown = stream->readUint32LE();
- _worldStats->commonRes.curScrollDownRight = stream->readUint32LE();
- _worldStats->commonRes.curScrollRight = stream->readUint32LE();
- _worldStats->commonRes.curScrollUpRight = stream->readUint32LE();
- _worldStats->commonRes.curHand = stream->readUint32LE();
- _worldStats->commonRes.curMagnifyingGlass = stream->readUint32LE();
- _worldStats->commonRes.curTalkNCP = stream->readUint32LE();
- _worldStats->commonRes.curGrabPointer = stream->readUint32LE();
- _worldStats->commonRes.curTalkNCP2 = stream->readUint32LE();
- _worldStats->commonRes.font1 = stream->readUint32LE();
- _worldStats->commonRes.font2 = stream->readUint32LE();
- _worldStats->commonRes.font3 = stream->readUint32LE();
- _worldStats->commonRes.palette = stream->readUint32LE();
- _worldStats->commonRes.cellShadeMask1 = stream->readUint32LE();
- _worldStats->commonRes.cellShadeMask2 = stream->readUint32LE();
- _worldStats->commonRes.cellShadeMask3 = stream->readUint32LE();
- _worldStats->commonRes.unused = stream->readUint32LE();
- _worldStats->commonRes.smallCurUp = stream->readUint32LE();
- _worldStats->commonRes.smallCurDown = stream->readUint32LE();
- _worldStats->commonRes.encounterFrameBg = stream->readUint32LE();
-
- _worldStats->width = stream->readUint32LE();
- _worldStats->height = stream->readUint32LE();
- _worldStats->motionStatus = stream->readUint32LE();
- _worldStats->field_8C = stream->readUint32LE();
- _worldStats->numActions = stream->readUint32LE();
- _worldStats->numBarriers = stream->readUint32LE();
- _worldStats->targetX = stream->readUint32LE();
- _worldStats->targetY = stream->readUint32LE();
- _worldStats->field_A0 = stream->readUint32LE();
- _worldStats->field_A4 = stream->readUint32LE();
- _worldStats->field_A8 = stream->readUint32LE();
- _worldStats->field_AC = stream->readUint32LE();
- _worldStats->field_B0 = stream->readUint32LE();
- _worldStats->numActors = stream->readUint32LE();
- _worldStats->stereoReversedFlag = stream->readUint32LE();
-
- for (int r=0; r < 6; r++) {
- _worldStats->sceneRects[r].left = stream->readUint32LE() & 0xFFFF;
- _worldStats->sceneRects[r].top = stream->readUint32LE() & 0xFFFF;
- _worldStats->sceneRects[r].right = stream->readUint32LE() & 0xFFFF;
- _worldStats->sceneRects[r].bottom = stream->readUint32LE() & 0xFFFF;
- }
- _worldStats->sceneRectIdx = stream->readByte();
- _worldStats->field_11D[0] = stream->readByte();
- _worldStats->field_11D[1] = stream->readByte();
- _worldStats->field_11D[2] = stream->readByte();
-
- _worldStats->field_120 = stream->readUint32LE();
- _worldStats->actionListIdx = stream->readUint32LE();
-
- for (int gr=0; gr < 100; gr++) {
- _worldStats->grResId[gr] = stream->readUint32LE();
- }
-
- _worldStats->sceneTitleGrResId = stream->readUint32LE();
- _worldStats->sceneTitlePalResId = stream->readUint32LE();
- _worldStats->actorType = stream->readUint32LE();
-
- for(int s=0; s < 50; s++) {
- _worldStats->soundResId[s] = stream->readUint32LE();
- }
-
- for(int s=0; s < 15; s++) {
- _worldStats->ambientSounds[s].field_0 = stream->readUint32LE();
- _worldStats->ambientSounds[s].flags = stream->readUint32LE();
- _worldStats->ambientSounds[s].resId = stream->readUint32LE();
- _worldStats->ambientSounds[s].field_C = stream->readUint32LE();
- _worldStats->ambientSounds[s].field_10 = stream->readUint32LE();
- _worldStats->ambientSounds[s].field_14 = stream->readUint32LE();
-
- for(int i=0; i < 6; i++)
- _worldStats->ambientSounds[s].flagNum[i] = stream->readUint32LE();
-
- _worldStats->ambientSounds[s].x = stream->readUint32LE();
- _worldStats->ambientSounds[s].y = stream->readUint32LE();
- }
- _worldStats->numAmbientSound = stream->readUint32LE();
-
- _worldStats->musicStatus = stream->readUint32LE();
- _worldStats->musicCurrentResId = stream->readUint32LE();
- _worldStats->musicFlag = stream->readUint32LE();
- _worldStats->musicResId = stream->readUint32LE();
- _worldStats->musicStatusExt = stream->readUint32LE();
-
- for (uint32 a = 0; a < _worldStats->numBarriers; a++) {
- int i;
- BarrierItem barrier;
-
- barrier.id = stream->readUint32LE();
- barrier.resId = stream->readUint32LE();
- barrier.x = stream->readUint32LE();
- barrier.y = stream->readUint32LE();
-
- barrier.boundingRect.left = stream->readUint32LE() & 0xFFFF;
- barrier.boundingRect.top = stream->readUint32LE() & 0xFFFF;
- barrier.boundingRect.right = stream->readUint32LE() & 0xFFFF;
- barrier.boundingRect.bottom = stream->readUint32LE() & 0xFFFF;
-
- barrier.field_20 = stream->readUint32LE();
- barrier.frameIdx = stream->readUint32LE();
- barrier.frameCount = stream->readUint32LE();
- barrier.field_2C = stream->readUint32LE();
- barrier.field_30 = stream->readUint32LE();
- barrier.field_34 = stream->readUint32LE();
- barrier.flags = stream->readUint32LE();
- barrier.field_3C = stream->readUint32LE();
-
- stream->read(barrier.name, sizeof(barrier.name));
-
- barrier.field_74 = stream->readUint32LE();
- barrier.field_78 = stream->readUint32LE();
- barrier.field_7C = stream->readUint32LE();
- barrier.field_80 = stream->readUint32LE();
- barrier.polyIdx = stream->readUint32LE();
- barrier.flags2 = stream->readUint32LE();
-
- for (i = 0; i < 10; i++)
- barrier.gameFlags[i] = stream->readUint32LE();
-
- barrier.field_B4 = stream->readUint32LE();
- barrier.tickCount = stream->readUint32LE();
- barrier.tickCount2 = stream->readUint32LE();
- barrier.field_C0 = stream->readUint32LE();
- barrier.field_C4 = stream->readUint32LE();
- barrier.actionListIdx = stream->readUint32LE();
-
- for (i = 0; i < 16; i++) {
- barrier.soundItems[i].resId = stream->readUint32LE();
- barrier.soundItems[i].field_4 = stream->readUint32LE();
- barrier.soundItems[i].field_8 = stream->readUint32LE();
- barrier.soundItems[i].field_C = stream->readUint32LE();
-
- }
-
- for (i = 0; i < 50; i++) {
- barrier.frameSoundItems[i].resId = stream->readUint32LE();
- barrier.frameSoundItems[i].frameIdx = stream->readUint32LE();
- barrier.frameSoundItems[i].index = stream->readUint32LE();
- barrier.frameSoundItems[i].field_C = stream->readUint32LE();
- barrier.frameSoundItems[i].field_10 = stream->readUint32LE();
- barrier.frameSoundItems[i].field_14 = stream->readUint32LE();
- }
-
- barrier.field_67C = stream->readUint32LE();
- barrier.soundX = stream->readUint32LE();
- barrier.soundY = stream->readUint32LE();
- barrier.field_688 = stream->readUint32LE();
-
- for (i = 0; i < 5; i++) {
- barrier.field_68C[i] = stream->readUint32LE();
- }
-
- barrier.soundResId = stream->readUint32LE();
- barrier.field_6A4 = stream->readUint32LE();
-
- _worldStats->barriers.push_back(barrier);
- }
-
- // need to jump all unused barriers data to where actors data start
- stream->seek(0xA6D7A);
-
- for (uint32 a = 0; a < _worldStats->numActors; a++) {
- int i;
- ActorItem actor;
- memset(&actor, 0, sizeof(ActorItem));
-
- actor.x0 = stream->readUint32LE();
- actor.y0 = stream->readUint32LE();
- actor.grResId = stream->readUint32LE();
- actor.field_C = stream->readUint32LE();
- actor.frameNum = stream->readUint32LE();
- actor.frameCount = stream->readUint32LE();
- actor.x1 = stream->readUint32LE();
- actor.y1 = stream->readUint32LE();
- actor.x2 = stream->readUint32LE();
- actor.y2 = stream->readUint32LE();
-
- actor.boundingRect.left = stream->readUint32LE() & 0xFFFF;
- actor.boundingRect.top = stream->readUint32LE() & 0xFFFF;
- actor.boundingRect.right = stream->readUint32LE() & 0xFFFF;
- actor.boundingRect.bottom = stream->readUint32LE() & 0xFFFF;
-
- actor.direction = stream->readUint32LE();
- actor.field_3C = stream->readUint32LE();
- actor.field_40 = stream->readUint32LE();
- actor.field_44 = stream->readUint32LE();
- actor.field_48 = stream->readUint32LE();
- actor.flags = stream->readUint32LE();
- actor.field_50 = stream->readUint32LE();
- actor.field_54 = stream->readUint32LE();
- actor.field_58 = stream->readUint32LE();
- actor.field_5C = stream->readUint32LE();
- actor.field_60 = stream->readUint32LE();
- actor.actionIdx3 = stream->readUint32LE();
-
- // TODO skip field_68 till field_617
- stream->skip(0x5B0);
-
- for (i = 0; i < 8; i++) {
- actor.reaction[i] = stream->readUint32LE();
- }
-
- actor.field_638 = stream->readUint32LE();
- actor.walkingSound1 = stream->readUint32LE();
- actor.walkingSound2 = stream->readUint32LE();
- actor.walkingSound3 = stream->readUint32LE();
- actor.walkingSound4 = stream->readUint32LE();
- actor.field_64C = stream->readUint32LE();
- actor.field_650 = stream->readUint32LE();
-
- for (i = 0; i < 55; i++) {
- actor.grResTable[i] = stream->readUint32LE();
- }
-
- stream->read(actor.name, sizeof(actor.name));
-
- for (i = 0; i < 20; i++) {
- actor.field_830[i] = stream->readUint32LE();
- }
- for (i = 0; i < 20; i++) {
- actor.field_880[i] = stream->readUint32LE();
- }
- for (i = 0; i < 20; i++) {
- actor.field_8D0[i] = stream->readUint32LE();
- }
-
- actor.actionIdx2 = stream->readUint32LE();
- actor.field_924 = stream->readUint32LE();
- actor.tickValue1 = stream->readUint32LE();
- actor.field_92C = stream->readUint32LE();
- actor.flags2 = stream->readUint32LE();
- actor.field_934 = stream->readUint32LE();
- actor.field_938 = stream->readUint32LE();
- actor.soundResId = stream->readUint32LE();
-
- // TODO skip field_940 till field_978
- stream->skip(0x3C);
-
- actor.actionIdx1 = stream->readUint32LE();
-
- // TODO skip field_980 till field_9A0
- stream->skip(0x24);
-
- _worldStats->actors.push_back(actor);
- }
-
- // TODO Take this out, it shouldn't be here (TEST ONLY)
- stream->seek(0xA73B6);
- uint8 mainActorData[500];
- stream->read(mainActorData, 500);
- _mainActor = new MainActor(mainActorData);
-
- stream->seek(0xD6B5A); // where action items start
-
- // FIXME Figure out all the actions items
- for (uint32 a = 0; a < _worldStats->numActions; a++) {
- ActionItem action;
- memset(&action, 0, sizeof(ActionItem));
-
- stream->read(action.name,52);
- action.id = stream->readUint32LE();
- stream->skip(0x14);
- action.actionListIdx1 = stream->readUint32LE();
- action.actionListIdx2 = stream->readUint32LE();
- action.actionType = stream->readUint32LE();
- stream->skip(0x2C);
- action.polyIdx = stream->readUint32LE();
- stream->skip(0x08);
- action.soundResId = stream->readUint32LE();
- stream->skip(0x04);
- action.palCorrection = stream->readUint32LE();
- stream->skip(0x14);
- action.soundVolume = stream->readUint32LE();
-
- _worldStats->actions.push_back(action);
- }
-}
-
-void SceneResource::loadGamePolygons(Common::SeekableReadStream *stream) {
- _gamePolygons = new GamePolygons;
-
- stream->seek(0xE8686); // jump to game Polygons data
-
- _gamePolygons->size = stream->readUint32LE();
- _gamePolygons->numEntries = stream->readUint32LE();
-
- for (uint32 g = 0; g < _gamePolygons->numEntries; g++) {
- PolyDefinitions poly;
- memset(&poly, 0, sizeof(PolyDefinitions));
-
- poly.numPoints = stream->readUint32LE();
- if (poly.numPoints > 0)
- poly.points = new Common::Point[poly.numPoints];
- for (uint32 i = 0; i < poly.numPoints; i++) {
- poly.points[i].x = stream->readUint32LE() & 0xFFFF;
- poly.points[i].y = stream->readUint32LE() & 0xFFFF;
- }
- stream->skip((Polygons_MAXSIZE - poly.numPoints) * 8);
-
- poly.boundingRect.left = stream->readUint32LE() & 0xFFFF;
- poly.boundingRect.top = stream->readUint32LE() & 0xFFFF;
- poly.boundingRect.right = stream->readUint32LE() & 0xFFFF;
- poly.boundingRect.bottom = stream->readUint32LE() & 0xFFFF;
-
- _gamePolygons->polygons.push_back(poly);
- }
-}
-
-void SceneResource::loadActionList(Common::SeekableReadStream *stream) {
- _actionList = new ActionList;
-
- stream->seek(0xE868E + _gamePolygons->size * _gamePolygons->numEntries); // jump to action list data
-
- _actionList->size = stream->readUint32LE();
- _actionList->numEntries = stream->readUint32LE();
-
- for (uint32 a = 0; a < _actionList->numEntries; a++) {
- ActionDefinitions action;
- memset(&action, 0, sizeof(ActionDefinitions));
-
- for (uint32 c = 0; c < Commands_MAXSIZE; c++) {
- ActionCommand command;
- memset(&command, 0, sizeof(ActionCommand));
-
- command.numLines = stream->readUint32LE();
- command.opcode = stream->readUint32LE(); // command type
- command.param1 = stream->readUint32LE(); // command parameters
- command.param2 = stream->readUint32LE();
- command.param3 = stream->readUint32LE();
- command.param4 = stream->readUint32LE();
- command.param5 = stream->readUint32LE();
- command.param6 = stream->readUint32LE();
- command.param7 = stream->readUint32LE();
- command.param8 = stream->readUint32LE();
- command.param9 = stream->readUint32LE();
-
- action.commands[c] = command;
- }
-
- action.field_1BAC = stream->readUint32LE();
- action.field_1BB0 = stream->readUint32LE();
- action.counter = stream->readUint32LE();
-
- _actionList->actions.push_back(action);
- }
-}
-
-Common::String SceneResource::parseFilename(uint8 sceneIdx) {
- char filename[10];
- sprintf(filename, SCENEMASK, sceneIdx);
-
- return Common::String(filename);
-}
-
-} // end of namespace Asylum
+/* 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.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#include "asylum/sceneres.h"
+
+namespace Asylum {
+
+SceneResource::SceneResource() {
+}
+
+SceneResource::~SceneResource() {
+ delete _worldStats;
+ delete _mainActor;
+ for (uint i=0; i < _gamePolygons->numEntries; i++) {
+ delete[] _gamePolygons->polygons[i].points;
+ }
+ delete _gamePolygons;
+ delete _actionList;
+}
+
+int SceneResource::getBarrierIndexById(uint32 id) {
+ for (uint32 i=0; i < _worldStats->numBarriers; i++) {
+ if (_worldStats->barriers[i].id == id)
+ return i;
+ }
+ return -1;
+}
+
+bool SceneResource::load(uint8 sceneIdx) {
+ char sceneTag[6];
+ Common::File* fd = new Common::File;
+ Common::String filename = parseFilename(sceneIdx);
+
+ if (!fd->exists(filename)) {
+ warning("Scene file doesn't exist %s", filename.c_str());
+ return false;
+ }
+
+ fd->open(filename);
+
+ if (!fd->isOpen()) {
+ warning("Failed to load scene file %s", filename.c_str());
+ return false;
+ }
+
+ fd->read(sceneTag,6);
+
+ if (Common::String(sceneTag,6) != "DFISCN") {
+ warning("The file isn't recognized as scene %s", filename.c_str());
+ return false;
+ }
+
+ loadWorldStats(fd);
+ loadGamePolygons(fd);
+ loadActionList(fd);
+
+ fd->close();
+ delete fd;
+
+ return true;
+}
+
+// FIXME: load necessary World Stats content
+void SceneResource::loadWorldStats(Common::SeekableReadStream *stream) {
+ _worldStats = new WorldStats;
+
+ _worldStats->size = stream->readUint32LE();
+ _worldStats->numEntries = stream->readUint32LE();
+
+ _worldStats->numChapter = stream->readUint32LE();
+ _worldStats->xLeft = stream->readUint32LE();
+ _worldStats->yTop = stream->readUint32LE();
+ _worldStats->boundingRect.left = stream->readUint32LE() & 0xFFFF;
+ _worldStats->boundingRect.top = stream->readUint32LE() & 0xFFFF;
+ _worldStats->boundingRect.right = stream->readUint32LE() & 0xFFFF;
+ _worldStats->boundingRect.bottom = stream->readUint32LE() & 0xFFFF;
+
+ // read common graphic resources
+ _worldStats->commonRes.backgroundImage = stream->readUint32LE();
+ _worldStats->commonRes.curScrollUp = stream->readUint32LE();
+ _worldStats->commonRes.curScrollUpLeft = stream->readUint32LE();
+ _worldStats->commonRes.curScrollLeft = stream->readUint32LE();
+ _worldStats->commonRes.curScrollDownLeft = stream->readUint32LE();
+ _worldStats->commonRes.curScrollDown = stream->readUint32LE();
+ _worldStats->commonRes.curScrollDownRight = stream->readUint32LE();
+ _worldStats->commonRes.curScrollRight = stream->readUint32LE();
+ _worldStats->commonRes.curScrollUpRight = stream->readUint32LE();
+ _worldStats->commonRes.curHand = stream->readUint32LE();
+ _worldStats->commonRes.curMagnifyingGlass = stream->readUint32LE();
+ _worldStats->commonRes.curTalkNCP = stream->readUint32LE();
+ _worldStats->commonRes.curGrabPointer = stream->readUint32LE();
+ _worldStats->commonRes.curTalkNCP2 = stream->readUint32LE();
+ _worldStats->commonRes.font1 = stream->readUint32LE();
+ _worldStats->commonRes.font2 = stream->readUint32LE();
+ _worldStats->commonRes.font3 = stream->readUint32LE();
+ _worldStats->commonRes.palette = stream->readUint32LE();
+ _worldStats->commonRes.cellShadeMask1 = stream->readUint32LE();
+ _worldStats->commonRes.cellShadeMask2 = stream->readUint32LE();
+ _worldStats->commonRes.cellShadeMask3 = stream->readUint32LE();
+ _worldStats->commonRes.unused = stream->readUint32LE();
+ _worldStats->commonRes.smallCurUp = stream->readUint32LE();
+ _worldStats->commonRes.smallCurDown = stream->readUint32LE();
+ _worldStats->commonRes.encounterFrameBg = stream->readUint32LE();
+
+ _worldStats->width = stream->readUint32LE();
+ _worldStats->height = stream->readUint32LE();
+ _worldStats->motionStatus = stream->readUint32LE();
+ _worldStats->field_8C = stream->readUint32LE();
+ _worldStats->numActions = stream->readUint32LE();
+ _worldStats->numBarriers = stream->readUint32LE();
+ _worldStats->targetX = stream->readUint32LE();
+ _worldStats->targetY = stream->readUint32LE();
+ _worldStats->field_A0 = stream->readUint32LE();
+ _worldStats->field_A4 = stream->readUint32LE();
+ _worldStats->field_A8 = stream->readUint32LE();
+ _worldStats->field_AC = stream->readUint32LE();
+ _worldStats->field_B0 = stream->readUint32LE();
+ _worldStats->numActors = stream->readUint32LE();
+ _worldStats->stereoReversedFlag = stream->readUint32LE();
+
+ for (int r=0; r < 6; r++) {
+ _worldStats->sceneRects[r].left = stream->readUint32LE() & 0xFFFF;
+ _worldStats->sceneRects[r].top = stream->readUint32LE() & 0xFFFF;
+ _worldStats->sceneRects[r].right = stream->readUint32LE() & 0xFFFF;
+ _worldStats->sceneRects[r].bottom = stream->readUint32LE() & 0xFFFF;
+ }
+ _worldStats->sceneRectIdx = stream->readByte();
+ _worldStats->field_11D[0] = stream->readByte();
+ _worldStats->field_11D[1] = stream->readByte();
+ _worldStats->field_11D[2] = stream->readByte();
+
+ _worldStats->field_120 = stream->readUint32LE();
+ _worldStats->actionListIdx = stream->readUint32LE();
+
+ for (int gr=0; gr < 100; gr++) {
+ _worldStats->grResId[gr] = stream->readUint32LE();
+ }
+
+ _worldStats->sceneTitleGrResId = stream->readUint32LE();
+ _worldStats->sceneTitlePalResId = stream->readUint32LE();
+ _worldStats->actorType = stream->readUint32LE();
+
+ for(int s=0; s < 50; s++) {
+ _worldStats->soundResId[s] = stream->readUint32LE();
+ }
+
+ for(int s=0; s < 15; s++) {
+ _worldStats->ambientSounds[s].field_0 = stream->readUint32LE();
+ _worldStats->ambientSounds[s].flags = stream->readUint32LE();
+ _worldStats->ambientSounds[s].resId = stream->readUint32LE();
+ _worldStats->ambientSounds[s].field_C = stream->readUint32LE();
+ _worldStats->ambientSounds[s].field_10 = stream->readUint32LE();
+ _worldStats->ambientSounds[s].field_14 = stream->readUint32LE();
+
+ for(int i=0; i < 6; i++)
+ _worldStats->ambientSounds[s].flagNum[i] = stream->readUint32LE();
+
+ _worldStats->ambientSounds[s].x = stream->readUint32LE();
+ _worldStats->ambientSounds[s].y = stream->readUint32LE();
+ }
+ _worldStats->numAmbientSound = stream->readUint32LE();
+
+ _worldStats->musicStatus = stream->readUint32LE();
+ _worldStats->musicCurrentResId = stream->readUint32LE();
+ _worldStats->musicFlag = stream->readUint32LE();
+ _worldStats->musicResId = stream->readUint32LE();
+ _worldStats->musicStatusExt = stream->readUint32LE();
+
+ for (uint32 a = 0; a < _worldStats->numBarriers; a++) {
+ int i;
+ BarrierItem barrier;
+
+ barrier.id = stream->readUint32LE();
+ barrier.resId = stream->readUint32LE();
+ barrier.x = stream->readUint32LE();
+ barrier.y = stream->readUint32LE();
+
+ barrier.boundingRect.left = stream->readUint32LE() & 0xFFFF;
+ barrier.boundingRect.top = stream->readUint32LE() & 0xFFFF;
+ barrier.boundingRect.right = stream->readUint32LE() & 0xFFFF;
+ barrier.boundingRect.bottom = stream->readUint32LE() & 0xFFFF;
+
+ barrier.field_20 = stream->readUint32LE();
+ barrier.frameIdx = stream->readUint32LE();
+ barrier.frameCount = stream->readUint32LE();
+ barrier.field_2C = stream->readUint32LE();
+ barrier.field_30 = stream->readUint32LE();
+ barrier.field_34 = stream->readUint32LE();
+ barrier.flags = stream->readUint32LE();
+ barrier.field_3C = stream->readUint32LE();
+
+ stream->read(barrier.name, sizeof(barrier.name));
+
+ barrier.field_74 = stream->readUint32LE();
+ barrier.field_78 = stream->readUint32LE();
+ barrier.field_7C = stream->readUint32LE();
+ barrier.field_80 = stream->readUint32LE();
+ barrier.polyIdx = stream->readUint32LE();
+ barrier.flags2 = stream->readUint32LE();
+
+ for (i = 0; i < 10; i++)
+ barrier.gameFlags[i] = stream->readUint32LE();
+
+ barrier.field_B4 = stream->readUint32LE();
+ barrier.tickCount = stream->readUint32LE();
+ barrier.tickCount2 = stream->readUint32LE();
+ barrier.field_C0 = stream->readUint32LE();
+ barrier.field_C4 = stream->readUint32LE();
+ barrier.actionListIdx = stream->readUint32LE();
+
+ for (i = 0; i < 16; i++) {
+ barrier.soundItems[i].resId = stream->readUint32LE();
+ barrier.soundItems[i].field_4 = stream->readUint32LE();
+ barrier.soundItems[i].field_8 = stream->readUint32LE();
+ barrier.soundItems[i].field_C = stream->readUint32LE();
+
+ }
+
+ for (i = 0; i < 50; i++) {
+ barrier.frameSoundItems[i].resId = stream->readUint32LE();
+ barrier.frameSoundItems[i].frameIdx = stream->readUint32LE();
+ barrier.frameSoundItems[i].index = stream->readUint32LE();
+ barrier.frameSoundItems[i].field_C = stream->readUint32LE();
+ barrier.frameSoundItems[i].field_10 = stream->readUint32LE();
+ barrier.frameSoundItems[i].field_14 = stream->readUint32LE();
+ }
+
+ barrier.field_67C = stream->readUint32LE();
+ barrier.soundX = stream->readUint32LE();
+ barrier.soundY = stream->readUint32LE();
+ barrier.field_688 = stream->readUint32LE();
+
+ for (i = 0; i < 5; i++) {
+ barrier.field_68C[i] = stream->readUint32LE();
+ }
+
+ barrier.soundResId = stream->readUint32LE();
+ barrier.field_6A4 = stream->readUint32LE();
+
+ _worldStats->barriers.push_back(barrier);
+ }
+
+ // need to jump all unused barriers data to where actors data start
+ stream->seek(0xA6D7A);
+
+ for (uint32 a = 0; a < _worldStats->numActors; a++) {
+ int i;
+ ActorItem actor;
+ memset(&actor, 0, sizeof(ActorItem));
+
+ actor.x0 = stream->readUint32LE();
+ actor.y0 = stream->readUint32LE();
+ actor.grResId = stream->readUint32LE();
+ actor.field_C = stream->readUint32LE();
+ actor.frameNum = stream->readUint32LE();
+ actor.frameCount = stream->readUint32LE();
+ actor.x1 = stream->readUint32LE();
+ actor.y1 = stream->readUint32LE();
+ actor.x2 = stream->readUint32LE();
+ actor.y2 = stream->readUint32LE();
+
+ actor.boundingRect.left = stream->readUint32LE() & 0xFFFF;
+ actor.boundingRect.top = stream->readUint32LE() & 0xFFFF;
+ actor.boundingRect.right = stream->readUint32LE() & 0xFFFF;
+ actor.boundingRect.bottom = stream->readUint32LE() & 0xFFFF;
+
+ actor.direction = stream->readUint32LE();
+ actor.field_3C = stream->readUint32LE();
+ actor.field_40 = stream->readUint32LE();
+ actor.field_44 = stream->readUint32LE();
+ actor.field_48 = stream->readUint32LE();
+ actor.flags = stream->readUint32LE();
+ actor.field_50 = stream->readUint32LE();
+ actor.field_54 = stream->readUint32LE();
+ actor.field_58 = stream->readUint32LE();
+ actor.field_5C = stream->readUint32LE();
+ actor.field_60 = stream->readUint32LE();
+ actor.actionIdx3 = stream->readUint32LE();
+
+ // TODO skip field_68 till field_617
+ stream->skip(0x5B0);
+
+ for (i = 0; i < 8; i++) {
+ actor.reaction[i] = stream->readUint32LE();
+ }
+
+ actor.field_638 = stream->readUint32LE();
+ actor.walkingSound1 = stream->readUint32LE();
+ actor.walkingSound2 = stream->readUint32LE();
+ actor.walkingSound3 = stream->readUint32LE();
+ actor.walkingSound4 = stream->readUint32LE();
+ actor.field_64C = stream->readUint32LE();
+ actor.field_650 = stream->readUint32LE();
+
+ for (i = 0; i < 55; i++) {
+ actor.grResTable[i] = stream->readUint32LE();
+ }
+
+ stream->read(actor.name, sizeof(actor.name));
+
+ for (i = 0; i < 20; i++) {
+ actor.field_830[i] = stream->readUint32LE();
+ }
+ for (i = 0; i < 20; i++) {
+ actor.field_880[i] = stream->readUint32LE();
+ }
+ for (i = 0; i < 20; i++) {
+ actor.field_8D0[i] = stream->readUint32LE();
+ }
+
+ actor.actionIdx2 = stream->readUint32LE();
+ actor.field_924 = stream->readUint32LE();
+ actor.tickValue1 = stream->readUint32LE();
+ actor.field_92C = stream->readUint32LE();
+ actor.flags2 = stream->readUint32LE();
+ actor.field_934 = stream->readUint32LE();
+ actor.field_938 = stream->readUint32LE();
+ actor.soundResId = stream->readUint32LE();
+
+ // TODO skip field_940 till field_978
+ stream->skip(0x3C);
+
+ actor.actionIdx1 = stream->readUint32LE();
+
+ // TODO skip field_980 till field_9A0
+ stream->skip(0x24);
+
+ _worldStats->actors.push_back(actor);
+ }
+
+ // TODO Take this out, it shouldn't be here (TEST ONLY)
+ stream->seek(0xA73B6);
+ uint8 mainActorData[500];
+ stream->read(mainActorData, 500);
+ _mainActor = new MainActor(mainActorData);
+
+ stream->seek(0xD6B5A); // where action items start
+
+ // FIXME Figure out all the actions items
+ for (uint32 a = 0; a < _worldStats->numActions; a++) {
+ ActionItem action;
+ memset(&action, 0, sizeof(ActionItem));
+
+ stream->read(action.name,52);
+ action.id = stream->readUint32LE();
+ stream->skip(0x14);
+ action.actionListIdx1 = stream->readUint32LE();
+ action.actionListIdx2 = stream->readUint32LE();
+ action.actionType = stream->readUint32LE();
+ stream->skip(0x2C);
+ action.polyIdx = stream->readUint32LE();
+ stream->skip(0x08);
+ action.soundResId = stream->readUint32LE();
+ stream->skip(0x04);
+ action.palCorrection = stream->readUint32LE();
+ stream->skip(0x14);
+ action.soundVolume = stream->readUint32LE();
+
+ _worldStats->actions.push_back(action);
+ }
+}
+
+void SceneResource::loadGamePolygons(Common::SeekableReadStream *stream) {
+ _gamePolygons = new GamePolygons;
+
+ stream->seek(0xE8686); // jump to game Polygons data
+
+ _gamePolygons->size = stream->readUint32LE();
+ _gamePolygons->numEntries = stream->readUint32LE();
+
+ for (uint32 g = 0; g < _gamePolygons->numEntries; g++) {
+ PolyDefinitions poly;
+ memset(&poly, 0, sizeof(PolyDefinitions));
+
+ poly.numPoints = stream->readUint32LE();
+ if (poly.numPoints > 0)
+ poly.points = new Common::Point[poly.numPoints];
+ for (uint32 i = 0; i < poly.numPoints; i++) {
+ poly.points[i].x = stream->readUint32LE() & 0xFFFF;
+ poly.points[i].y = stream->readUint32LE() & 0xFFFF;
+ }
+ stream->skip((Polygons_MAXSIZE - poly.numPoints) * 8);
+
+ poly.boundingRect.left = stream->readUint32LE() & 0xFFFF;
+ poly.boundingRect.top = stream->readUint32LE() & 0xFFFF;
+ poly.boundingRect.right = stream->readUint32LE() & 0xFFFF;
+ poly.boundingRect.bottom = stream->readUint32LE() & 0xFFFF;
+
+ _gamePolygons->polygons.push_back(poly);
+ }
+}
+
+void SceneResource::loadActionList(Common::SeekableReadStream *stream) {
+ _actionList = new ActionList;
+
+ stream->seek(0xE868E + _gamePolygons->size * _gamePolygons->numEntries); // jump to action list data
+
+ _actionList->size = stream->readUint32LE();
+ _actionList->numEntries = stream->readUint32LE();
+
+ for (uint32 a = 0; a < _actionList->numEntries; a++) {
+ ActionDefinitions action;
+ memset(&action, 0, sizeof(ActionDefinitions));
+
+ for (uint32 c = 0; c < Commands_MAXSIZE; c++) {
+ ActionCommand command;
+ memset(&command, 0, sizeof(ActionCommand));
+
+ command.numLines = stream->readUint32LE();
+ command.opcode = stream->readUint32LE(); // command type
+ command.param1 = stream->readUint32LE(); // command parameters
+ command.param2 = stream->readUint32LE();
+ command.param3 = stream->readUint32LE();
+ command.param4 = stream->readUint32LE();
+ command.param5 = stream->readUint32LE();
+ command.param6 = stream->readUint32LE();
+ command.param7 = stream->readUint32LE();
+ command.param8 = stream->readUint32LE();
+ command.param9 = stream->readUint32LE();
+
+ action.commands[c] = command;
+ }
+
+ action.field_1BAC = stream->readUint32LE();
+ action.field_1BB0 = stream->readUint32LE();
+ action.counter = stream->readUint32LE();
+
+ _actionList->actions.push_back(action);
+ }
+}
+
+Common::String SceneResource::parseFilename(uint8 sceneIdx) {
+ char filename[10];
+ sprintf(filename, SCENEMASK, sceneIdx);
+
+ return Common::String(filename);
+}
+
+} // end of namespace Asylum
diff --git a/engines/asylum/sceneres.h b/engines/asylum/sceneres.h
index 6a6123b32c..0528de1c9e 100644
--- a/engines/asylum/sceneres.h
+++ b/engines/asylum/sceneres.h
@@ -1,376 +1,376 @@
-/* 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.
- *
- * $URL$
- * $Id$
- *
- */
-
-#ifndef ASYLUM_SCENERESOURCE_H_
-#define ASYLUM_SCENERESOURCE_H_
-
-#include "common/file.h"
-#include "common/array.h"
-#include "common/rect.h"
-
-#include "asylum/actor.h"
-#include "asylum/screen.h"
-#include "asylum/respack.h"
-
-#define SCENEMASK "scn.%03d"
-#define Polygons_MAXSIZE 200
-#define Commands_MAXSIZE 161
-
-namespace Asylum {
-
-class AsylumEngine;
-class WorldStats;
-class GamePolygons;
-class ActionList;
-
-#if 0
-// TODO/FIXME: Are there REALLY any points which go beyond 32768???
-// ScummVM common Point uses int16 and we need int32
-typedef struct Point {
- int32 x, y;
-} Point;
-
-// ScummVM common Rect uses int16 and we need int32
-typedef struct Rect {
- int32 top, left, bottom, right;
-} Rect;
-#endif
-
-class SceneResource {
-public:
- SceneResource();
- virtual ~SceneResource();
-
- bool load(uint8 sceneIdx);
-
- WorldStats* getWorldStats() { return _worldStats; }
- GamePolygons* getGamePolygons() { return _gamePolygons; }
- ActionList* getActionList() { return _actionList; }
- MainActor* getMainActor() { return _mainActor; }
-
- int getBarrierIndexById(uint32 id);
-
-private:
-
- WorldStats *_worldStats;
- GamePolygons *_gamePolygons;
- ActionList *_actionList;
- MainActor *_mainActor;
-
- void loadWorldStats(Common::SeekableReadStream *stream);
- void loadGamePolygons(Common::SeekableReadStream *stream);
- void loadActionList(Common::SeekableReadStream *stream);
- Common::String parseFilename(uint8 sceneIdx);
-
-}; // end of class Scene
-
-typedef struct SoundItem {
- uint32 resId;
- uint32 field_4;
- uint32 field_8;
- uint32 field_C;
-
-} SoundItem;
-
-typedef struct FrameSoundItem {
- uint32 resId;
- uint32 frameIdx;
- uint32 index;
- uint32 field_C;
- uint32 field_10;
- uint32 field_14;
-
-} FrameSoundItem;
-
-typedef struct AmbientSoundItem {
- uint32 field_0;
- uint32 flags;
- uint32 resId;
- uint32 field_C;
- uint32 field_10;
- uint32 field_14;
- uint32 flagNum[6];
- uint32 x;
- uint32 y;
-
-} AmbientSoundItem;
-
-// FIXME figure out unknown fields
-typedef struct BarrierItem {
- uint32 id;
- uint32 resId;
- uint32 x;
- uint32 y;
- Common::Rect boundingRect;
- uint32 field_20;
- uint32 frameIdx;
- uint32 frameCount;
- uint32 field_2C;
- uint32 field_30;
- uint32 field_34;
- uint32 flags;
- uint32 field_3C;
- uint8 name[52]; // field_40 till field_70;
- uint32 field_74;
- uint32 field_78;
- uint32 field_7C;
- uint32 field_80;
- uint32 polyIdx;
- uint32 flags2;
- uint32 gameFlags[10];
- uint32 field_B4;
- uint32 tickCount;
- uint32 tickCount2;
- uint32 field_C0;
- uint32 field_C4;
- uint32 actionListIdx;
- SoundItem soundItems[16];
- FrameSoundItem frameSoundItems[50];
- uint32 field_67C;
- uint32 soundX;
- uint32 soundY;
- uint32 field_688;
- uint32 field_68C[5];
- uint32 soundResId;
- uint32 field_6A4;
-
-} BarrierItem;
-
-// FIXME add unknown fields
-typedef struct ActionItem {
- char name[52];
- uint32 id;
- int32 actionListIdx1;
- int32 actionListIdx2;
- int32 actionType; // 0-none, 1-findwhat, 2-talk, 3-findwhat??, 4-grab
- int32 polyIdx;
- uint32 soundResId;
- uint32 palCorrection;
- int32 soundVolume;
-
-} ActionItem;
-
-typedef struct CommonResources {
- uint32 backgroundImage;
- uint32 curScrollUp;
- uint32 curScrollUpLeft;
- uint32 curScrollLeft;
- uint32 curScrollDownLeft;
- uint32 curScrollDown;
- uint32 curScrollDownRight;
- uint32 curScrollRight;
- uint32 curScrollUpRight;
- uint32 curHand;
- uint32 curMagnifyingGlass;
- uint32 curTalkNCP;
- uint32 curGrabPointer;
- uint32 curTalkNCP2;
- uint32 font1;
- uint32 font2;
- uint32 font3;
- uint32 palette;
- uint32 cellShadeMask1;
- uint32 cellShadeMask2;
- uint32 cellShadeMask3;
- uint32 unused;
- uint32 smallCurUp;
- uint32 smallCurDown;
- uint32 encounterFrameBg;
-
-} CommonResources;
-
-
-typedef struct ActorItem {
- uint32 x0;
- uint32 y0;
- uint32 grResId;
- uint32 field_C;
- uint32 frameNum;
- uint32 frameCount;
- uint32 x1;
- uint32 y1;
- uint32 x2;
- uint32 y2;
- Common::Rect boundingRect;
- uint32 direction;
- uint32 field_3C;
- uint32 field_40;
- uint32 field_44;
- uint32 field_48;
- uint32 flags;
- uint32 field_50;
- uint32 field_54;
- uint32 field_58;
- uint32 field_5C;
- uint32 field_60;
- uint32 actionIdx3;
- // TODO field_68 till field_617
- uint32 reaction[8];
- uint32 field_638;
- uint32 walkingSound1;
- uint32 walkingSound2;
- uint32 walkingSound3;
- uint32 walkingSound4;
- uint32 field_64C;
- uint32 field_650;
- uint32 grResTable[55];
- char name[256];
- uint32 field_830[20];
- uint32 field_880[20];
- uint32 field_8D0[20];
- uint32 actionIdx2;
- uint32 field_924;
- uint32 tickValue1;
- uint32 field_92C;
- uint32 flags2;
- uint32 field_934;
- uint32 field_938;
- uint32 soundResId;
- // TODO field_940 till field_978
- uint32 actionIdx1;
- // TODO field_980 till field_9A0
-
-} ActorItem;
-
-class WorldStats {
-public:
- WorldStats() {};
- virtual ~WorldStats() {
- barriers.clear();
- actors.clear();
- actions.clear();
- };
-
- uint32 size;
- uint32 numEntries;
- uint32 numChapter;
- uint32 xLeft; // scene start x position
- uint32 yTop; // scene start y position
- Common::Rect boundingRect;
- CommonResources commonRes; // field_1C till field_7C
- uint32 width; // field_80
- uint32 height;
- uint32 motionStatus;
- uint32 field_8C;
- uint32 numActions; // field_90
- uint32 numBarriers;
- uint32 targetX;
- uint32 targetY;
- uint32 field_A0;
- uint32 field_A4;
- uint32 field_A8;
- uint32 field_AC;
- uint32 field_B0;
- uint32 numActors; // Max and all other characters that have
- // own interactions
- uint32 stereoReversedFlag;
- Common::Rect sceneRects[6]; // including scene size rect
- uint8 sceneRectIdx;
- uint8 field_11D[3];
- uint32 field_120;
- uint32 actionListIdx; // actionList start index
- uint32 grResId[100];
- uint32 sceneTitleGrResId;
- uint32 sceneTitlePalResId;
- uint32 actorType;
- uint32 soundResId[50];
- AmbientSoundItem ambientSounds[15];
- uint32 numAmbientSound;
- uint32 musicStatus;
- uint32 musicCurrentResId;
- uint32 musicFlag;
- uint32 musicResId;
- uint32 musicStatusExt;
-
- // FIXME: Investigate if we need to actually reserve maxsize for this arrays.
- // It always have that size under scene file and they are always save in savegames.
- Common::Array<BarrierItem> barriers; // maxsize 400
- Common::Array<ActorItem> actors; // maxsize 50
- // TODO add rest fields
- Common::Array<ActionItem> actions; // maxsize 400
-
-}; // end of class WorldStats
-
-typedef struct PolyDefinitions{
- uint32 numPoints;
- Common::Point *points; //[Polygons_MAXSIZE];
- Common::Rect boundingRect;
-
-} PolyDefinitions;
-
-class GamePolygons {
-public:
- GamePolygons() {};
- virtual ~GamePolygons() {
- polygons.clear();
- };
-
- uint32 size;
- uint32 numEntries;
-
- Common::Array<PolyDefinitions> polygons;
-
-}; // end of class GamePolygons
-
-typedef struct ActionCommand {
- uint32 numLines; // Only set on the first line of each script
- uint32 opcode;
- uint32 param1;
- uint32 param2;
- uint32 param3;
- uint32 param4;
- uint32 param5;
- uint32 param6;
- uint32 param7;
- uint32 param8;
- uint32 param9;
-
-} ActionCommand;
-
-typedef struct ActionDefinitions {
- ActionCommand commands[161];
- uint32 field_1BAC;
- uint32 field_1BB0;
- uint32 counter;
-
-} ActionDefinitions;
-
-class ActionList {
-public:
- ActionList() {};
- virtual ~ActionList() {
- actions.clear();
- };
-
- uint32 size;
- uint32 numEntries;
-
- Common::Array<ActionDefinitions> actions;
-
-}; // end of class ActionList
-
-} // end of namespace Asylum
-
-#endif
+/* 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.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#ifndef ASYLUM_SCENERESOURCE_H_
+#define ASYLUM_SCENERESOURCE_H_
+
+#include "common/file.h"
+#include "common/array.h"
+#include "common/rect.h"
+
+#include "asylum/actor.h"
+#include "asylum/screen.h"
+#include "asylum/respack.h"
+
+#define SCENEMASK "scn.%03d"
+#define Polygons_MAXSIZE 200
+#define Commands_MAXSIZE 161
+
+namespace Asylum {
+
+class AsylumEngine;
+class WorldStats;
+class GamePolygons;
+class ActionList;
+
+#if 0
+// TODO/FIXME: Are there REALLY any points which go beyond 32768???
+// ScummVM common Point uses int16 and we need int32
+typedef struct Point {
+ int32 x, y;
+} Point;
+
+// ScummVM common Rect uses int16 and we need int32
+typedef struct Rect {
+ int32 top, left, bottom, right;
+} Rect;
+#endif
+
+class SceneResource {
+public:
+ SceneResource();
+ virtual ~SceneResource();
+
+ bool load(uint8 sceneIdx);
+
+ WorldStats* getWorldStats() { return _worldStats; }
+ GamePolygons* getGamePolygons() { return _gamePolygons; }
+ ActionList* getActionList() { return _actionList; }
+ MainActor* getMainActor() { return _mainActor; }
+
+ int getBarrierIndexById(uint32 id);
+
+private:
+
+ WorldStats *_worldStats;
+ GamePolygons *_gamePolygons;
+ ActionList *_actionList;
+ MainActor *_mainActor;
+
+ void loadWorldStats(Common::SeekableReadStream *stream);
+ void loadGamePolygons(Common::SeekableReadStream *stream);
+ void loadActionList(Common::SeekableReadStream *stream);
+ Common::String parseFilename(uint8 sceneIdx);
+
+}; // end of class Scene
+
+typedef struct SoundItem {
+ uint32 resId;
+ uint32 field_4;
+ uint32 field_8;
+ uint32 field_C;
+
+} SoundItem;
+
+typedef struct FrameSoundItem {
+ uint32 resId;
+ uint32 frameIdx;
+ uint32 index;
+ uint32 field_C;
+ uint32 field_10;
+ uint32 field_14;
+
+} FrameSoundItem;
+
+typedef struct AmbientSoundItem {
+ uint32 field_0;
+ uint32 flags;
+ uint32 resId;
+ uint32 field_C;
+ uint32 field_10;
+ uint32 field_14;
+ uint32 flagNum[6];
+ uint32 x;
+ uint32 y;
+
+} AmbientSoundItem;
+
+// FIXME figure out unknown fields
+typedef struct BarrierItem {
+ uint32 id;
+ uint32 resId;
+ uint32 x;
+ uint32 y;
+ Common::Rect boundingRect;
+ uint32 field_20;
+ uint32 frameIdx;
+ uint32 frameCount;
+ uint32 field_2C;
+ uint32 field_30;
+ uint32 field_34;
+ uint32 flags;
+ uint32 field_3C;
+ uint8 name[52]; // field_40 till field_70;
+ uint32 field_74;
+ uint32 field_78;
+ uint32 field_7C;
+ uint32 field_80;
+ uint32 polyIdx;
+ uint32 flags2;
+ uint32 gameFlags[10];
+ uint32 field_B4;
+ uint32 tickCount;
+ uint32 tickCount2;
+ uint32 field_C0;
+ uint32 field_C4;
+ uint32 actionListIdx;
+ SoundItem soundItems[16];
+ FrameSoundItem frameSoundItems[50];
+ uint32 field_67C;
+ uint32 soundX;
+ uint32 soundY;
+ uint32 field_688;
+ uint32 field_68C[5];
+ uint32 soundResId;
+ uint32 field_6A4;
+
+} BarrierItem;
+
+// FIXME add unknown fields
+typedef struct ActionItem {
+ char name[52];
+ uint32 id;
+ int32 actionListIdx1;
+ int32 actionListIdx2;
+ int32 actionType; // 0-none, 1-findwhat, 2-talk, 3-findwhat??, 4-grab
+ int32 polyIdx;
+ uint32 soundResId;
+ uint32 palCorrection;
+ int32 soundVolume;
+
+} ActionItem;
+
+typedef struct CommonResources {
+ uint32 backgroundImage;
+ uint32 curScrollUp;
+ uint32 curScrollUpLeft;
+ uint32 curScrollLeft;
+ uint32 curScrollDownLeft;
+ uint32 curScrollDown;
+ uint32 curScrollDownRight;
+ uint32 curScrollRight;
+ uint32 curScrollUpRight;
+ uint32 curHand;
+ uint32 curMagnifyingGlass;
+ uint32 curTalkNCP;
+ uint32 curGrabPointer;
+ uint32 curTalkNCP2;
+ uint32 font1;
+ uint32 font2;
+ uint32 font3;
+ uint32 palette;
+ uint32 cellShadeMask1;
+ uint32 cellShadeMask2;
+ uint32 cellShadeMask3;
+ uint32 unused;
+ uint32 smallCurUp;
+ uint32 smallCurDown;
+ uint32 encounterFrameBg;
+
+} CommonResources;
+
+
+typedef struct ActorItem {
+ uint32 x0;
+ uint32 y0;
+ uint32 grResId;
+ uint32 field_C;
+ uint32 frameNum;
+ uint32 frameCount;
+ uint32 x1;
+ uint32 y1;
+ uint32 x2;
+ uint32 y2;
+ Common::Rect boundingRect;
+ uint32 direction;
+ uint32 field_3C;
+ uint32 field_40;
+ uint32 field_44;
+ uint32 field_48;
+ uint32 flags;
+ uint32 field_50;
+ uint32 field_54;
+ uint32 field_58;
+ uint32 field_5C;
+ uint32 field_60;
+ uint32 actionIdx3;
+ // TODO field_68 till field_617
+ uint32 reaction[8];
+ uint32 field_638;
+ uint32 walkingSound1;
+ uint32 walkingSound2;
+ uint32 walkingSound3;
+ uint32 walkingSound4;
+ uint32 field_64C;
+ uint32 field_650;
+ uint32 grResTable[55];
+ char name[256];
+ uint32 field_830[20];
+ uint32 field_880[20];
+ uint32 field_8D0[20];
+ uint32 actionIdx2;
+ uint32 field_924;
+ uint32 tickValue1;
+ uint32 field_92C;
+ uint32 flags2;
+ uint32 field_934;
+ uint32 field_938;
+ uint32 soundResId;
+ // TODO field_940 till field_978
+ uint32 actionIdx1;
+ // TODO field_980 till field_9A0
+
+} ActorItem;
+
+class WorldStats {
+public:
+ WorldStats() {};
+ virtual ~WorldStats() {
+ barriers.clear();
+ actors.clear();
+ actions.clear();
+ };
+
+ uint32 size;
+ uint32 numEntries;
+ uint32 numChapter;
+ uint32 xLeft; // scene start x position
+ uint32 yTop; // scene start y position
+ Common::Rect boundingRect;
+ CommonResources commonRes; // field_1C till field_7C
+ uint32 width; // field_80
+ uint32 height;
+ uint32 motionStatus;
+ uint32 field_8C;
+ uint32 numActions; // field_90
+ uint32 numBarriers;
+ uint32 targetX;
+ uint32 targetY;
+ uint32 field_A0;
+ uint32 field_A4;
+ uint32 field_A8;
+ uint32 field_AC;
+ uint32 field_B0;
+ uint32 numActors; // Max and all other characters that have
+ // own interactions
+ uint32 stereoReversedFlag;
+ Common::Rect sceneRects[6]; // including scene size rect
+ uint8 sceneRectIdx;
+ uint8 field_11D[3];
+ uint32 field_120;
+ uint32 actionListIdx; // actionList start index
+ uint32 grResId[100];
+ uint32 sceneTitleGrResId;
+ uint32 sceneTitlePalResId;
+ uint32 actorType;
+ uint32 soundResId[50];
+ AmbientSoundItem ambientSounds[15];
+ uint32 numAmbientSound;
+ uint32 musicStatus;
+ uint32 musicCurrentResId;
+ uint32 musicFlag;
+ uint32 musicResId;
+ uint32 musicStatusExt;
+
+ // FIXME: Investigate if we need to actually reserve maxsize for this arrays.
+ // It always have that size under scene file and they are always save in savegames.
+ Common::Array<BarrierItem> barriers; // maxsize 400
+ Common::Array<ActorItem> actors; // maxsize 50
+ // TODO add rest fields
+ Common::Array<ActionItem> actions; // maxsize 400
+
+}; // end of class WorldStats
+
+typedef struct PolyDefinitions{
+ uint32 numPoints;
+ Common::Point *points; //[Polygons_MAXSIZE];
+ Common::Rect boundingRect;
+
+} PolyDefinitions;
+
+class GamePolygons {
+public:
+ GamePolygons() {};
+ virtual ~GamePolygons() {
+ polygons.clear();
+ };
+
+ uint32 size;
+ uint32 numEntries;
+
+ Common::Array<PolyDefinitions> polygons;
+
+}; // end of class GamePolygons
+
+typedef struct ActionCommand {
+ uint32 numLines; // Only set on the first line of each script
+ uint32 opcode;
+ uint32 param1;
+ uint32 param2;
+ uint32 param3;
+ uint32 param4;
+ uint32 param5;
+ uint32 param6;
+ uint32 param7;
+ uint32 param8;
+ uint32 param9;
+
+} ActionCommand;
+
+typedef struct ActionDefinitions {
+ ActionCommand commands[161];
+ uint32 field_1BAC;
+ uint32 field_1BB0;
+ uint32 counter;
+
+} ActionDefinitions;
+
+class ActionList {
+public:
+ ActionList() {};
+ virtual ~ActionList() {
+ actions.clear();
+ };
+
+ uint32 size;
+ uint32 numEntries;
+
+ Common::Array<ActionDefinitions> actions;
+
+}; // end of class ActionList
+
+} // end of namespace Asylum
+
+#endif
diff --git a/engines/asylum/screen.cpp b/engines/asylum/screen.cpp
index f1dc2ec53f..ea22855c56 100644
--- a/engines/asylum/screen.cpp
+++ b/engines/asylum/screen.cpp
@@ -1,103 +1,103 @@
-/* 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.
- *
- * $URL$
- * $Id$
- *
- */
-
-#include "asylum/screen.h"
-
-namespace Asylum {
-
-Screen::Screen(OSystem *sys) : _sys(sys) {
- _backBuffer.create(640, 480, 1);
-}
-
-Screen::~Screen() {
- _backBuffer.free();
-}
-
-void Screen::copyBackBufferToScreen() {
- _sys->copyRectToScreen((byte *)_backBuffer.pixels, _backBuffer.w, 0, 0, _backBuffer.w, _backBuffer.h);
-}
-
-void Screen::copyToBackBuffer(byte *buffer, int pitch, int x, int y, int width, int height) {
- int h = height;
- int w = width;
- byte *dest = (byte *)_backBuffer.pixels;
-
- while (h--) {
- memcpy(dest + y * _backBuffer.pitch + x, buffer, w);
- dest += 640;
- buffer += pitch;
- }
-}
-
-void Screen::copyToBackBufferWithTransparency(byte *buffer, int pitch, int x, int y, int width, int height) {
- // int h = height;
- // int w = width;
- byte *dest = (byte *)_backBuffer.pixels;
-
- for (int curY = 0; curY < height; curY++) {
- for (int curX = 0; curX < width; curX++) {
- if (buffer[curX + curY * pitch] != 0) {
- dest[x + curX + (y + curY) * 640] = buffer[curX + curY * pitch];
- }
- }
- }
-}
-
-void Screen::copyRectToScreen(byte *buffer, int pitch, int x, int y, int width, int height) {
- _sys->copyRectToScreen(buffer, pitch, x, y, width, height);
-}
-
-void Screen::copyRectToScreenWithTransparency(byte *buffer, int pitch, int x, int y, int width, int height) {
- byte *screenBuffer = (byte *)_sys->lockScreen()->pixels;
-
- for (int curY = 0; curY < height; curY++) {
- for (int curX = 0; curX < width; curX++) {
- if (buffer[curX + curY * pitch] != 0 && (x + curX + (y + curY) * 640 <= 640*480)) {
- screenBuffer[x + curX + (y + curY) * 640] = buffer[curX + curY * pitch];
- }
- }
- }
-
- _sys->unlockScreen();
-}
-
-void Screen::setPalette(byte *rgbPalette) {
- byte palette[256 * 4];
- byte *p = rgbPalette;
-
- // skip first color and set it to black always.
- memset(palette, 0, 4); p+=3;
-
- for (int i = 1; i < 256; i++) {
- palette[i * 4 + 0] = *p++ << 2;
- palette[i * 4 + 1] = *p++ << 2;
- palette[i * 4 + 2] = *p++ << 2;
- palette[i * 4 + 3] = 0;
- }
-
- _sys->setPalette(palette, 0, 256);
-}
-
-} // end of namespace Asylum
+/* 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.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#include "asylum/screen.h"
+
+namespace Asylum {
+
+Screen::Screen(OSystem *sys) : _sys(sys) {
+ _backBuffer.create(640, 480, 1);
+}
+
+Screen::~Screen() {
+ _backBuffer.free();
+}
+
+void Screen::copyBackBufferToScreen() {
+ _sys->copyRectToScreen((byte *)_backBuffer.pixels, _backBuffer.w, 0, 0, _backBuffer.w, _backBuffer.h);
+}
+
+void Screen::copyToBackBuffer(byte *buffer, int pitch, int x, int y, int width, int height) {
+ int h = height;
+ int w = width;
+ byte *dest = (byte *)_backBuffer.pixels;
+
+ while (h--) {
+ memcpy(dest + y * _backBuffer.pitch + x, buffer, w);
+ dest += 640;
+ buffer += pitch;
+ }
+}
+
+void Screen::copyToBackBufferWithTransparency(byte *buffer, int pitch, int x, int y, int width, int height) {
+ // int h = height;
+ // int w = width;
+ byte *dest = (byte *)_backBuffer.pixels;
+
+ for (int curY = 0; curY < height; curY++) {
+ for (int curX = 0; curX < width; curX++) {
+ if (buffer[curX + curY * pitch] != 0) {
+ dest[x + curX + (y + curY) * 640] = buffer[curX + curY * pitch];
+ }
+ }
+ }
+}
+
+void Screen::copyRectToScreen(byte *buffer, int pitch, int x, int y, int width, int height) {
+ _sys->copyRectToScreen(buffer, pitch, x, y, width, height);
+}
+
+void Screen::copyRectToScreenWithTransparency(byte *buffer, int pitch, int x, int y, int width, int height) {
+ byte *screenBuffer = (byte *)_sys->lockScreen()->pixels;
+
+ for (int curY = 0; curY < height; curY++) {
+ for (int curX = 0; curX < width; curX++) {
+ if (buffer[curX + curY * pitch] != 0 && (x + curX + (y + curY) * 640 <= 640*480)) {
+ screenBuffer[x + curX + (y + curY) * 640] = buffer[curX + curY * pitch];
+ }
+ }
+ }
+
+ _sys->unlockScreen();
+}
+
+void Screen::setPalette(byte *rgbPalette) {
+ byte palette[256 * 4];
+ byte *p = rgbPalette;
+
+ // skip first color and set it to black always.
+ memset(palette, 0, 4); p+=3;
+
+ for (int i = 1; i < 256; i++) {
+ palette[i * 4 + 0] = *p++ << 2;
+ palette[i * 4 + 1] = *p++ << 2;
+ palette[i * 4 + 2] = *p++ << 2;
+ palette[i * 4 + 3] = 0;
+ }
+
+ _sys->setPalette(palette, 0, 256);
+}
+
+} // end of namespace Asylum
diff --git a/engines/asylum/screen.h b/engines/asylum/screen.h
index 0d3bb58fe9..b59b6075eb 100644
--- a/engines/asylum/screen.h
+++ b/engines/asylum/screen.h
@@ -1,66 +1,66 @@
-/* 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.
- *
- * $URL$
- * $Id$
- *
- */
-
-#ifndef ASYLUM_SCREEN_H_
-#define ASYLUM_SCREEN_H_
-
-#include "asylum/asylum.h"
-#include "asylum/graphics.h"
-#include "asylum/respack.h"
-
-#include "common/system.h" // for OSystem
-#include "graphics/surface.h"
-
-namespace Asylum {
-
-class Screen {
-public:
- Screen(OSystem *sys);
- ~Screen();
-
- void copyToBackBuffer(byte *buffer, int pitch, int x, int y, int width, int height);
- void copyToBackBufferWithTransparency(byte *buffer, int pitch, int x, int y, int width, int height);
- void copyBackBufferToScreen();
- void copyRectToScreen(byte *buffer, int pitch, int x, int y, int width, int height);
- void copyRectToScreenWithTransparency(byte *buffer, int pitch, int x, int y, int width, int height);
- void setPalette(byte *rgbPalette);
- void setPalette(ResourcePack *resPack, int entry) { setPalette(resPack->getResource(entry)->data + 32); }
-
- void showCursor() { _sys->showMouse(true); }
- void hideCursor() { _sys->showMouse(false); }
- void setCursor(byte *data, byte width, byte height) { _sys->setMouseCursor(data, width, height, 0, 0, 0); }
- void setCursor(GraphicResource *cursorRes, int frame) {
- GraphicFrame *mouseCursor = cursorRes->getFrame(frame);
- setCursor((byte *)mouseCursor->surface.pixels, mouseCursor->surface.w, mouseCursor->surface.h);
- }
-
-private:
- Graphics::Surface _backBuffer;
- OSystem *_sys;
-};
-
-} // end of namespace Asylum
-
-#endif
+/* 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.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#ifndef ASYLUM_SCREEN_H_
+#define ASYLUM_SCREEN_H_
+
+#include "asylum/asylum.h"
+#include "asylum/graphics.h"
+#include "asylum/respack.h"
+
+#include "common/system.h" // for OSystem
+#include "graphics/surface.h"
+
+namespace Asylum {
+
+class Screen {
+public:
+ Screen(OSystem *sys);
+ ~Screen();
+
+ void copyToBackBuffer(byte *buffer, int pitch, int x, int y, int width, int height);
+ void copyToBackBufferWithTransparency(byte *buffer, int pitch, int x, int y, int width, int height);
+ void copyBackBufferToScreen();
+ void copyRectToScreen(byte *buffer, int pitch, int x, int y, int width, int height);
+ void copyRectToScreenWithTransparency(byte *buffer, int pitch, int x, int y, int width, int height);
+ void setPalette(byte *rgbPalette);
+ void setPalette(ResourcePack *resPack, int entry) { setPalette(resPack->getResource(entry)->data + 32); }
+
+ void showCursor() { _sys->showMouse(true); }
+ void hideCursor() { _sys->showMouse(false); }
+ void setCursor(byte *data, byte width, byte height) { _sys->setMouseCursor(data, width, height, 0, 0, 0); }
+ void setCursor(GraphicResource *cursorRes, int frame) {
+ GraphicFrame *mouseCursor = cursorRes->getFrame(frame);
+ setCursor((byte *)mouseCursor->surface.pixels, mouseCursor->surface.w, mouseCursor->surface.h);
+ }
+
+private:
+ Graphics::Surface _backBuffer;
+ OSystem *_sys;
+};
+
+} // end of namespace Asylum
+
+#endif
diff --git a/engines/asylum/sound.cpp b/engines/asylum/sound.cpp
index 31c6b6a78b..677e316946 100644
--- a/engines/asylum/sound.cpp
+++ b/engines/asylum/sound.cpp
@@ -1,55 +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.
- *
- * $URL$
- * $Id$
- *
- */
-
-#include "asylum/sound.h"
-
-#include "common/stream.h"
-#include "sound/wave.h"
-
-namespace Asylum {
-
-Sound::Sound(Audio::Mixer *mixer) : _mixer(mixer) {
-}
-
-Sound::~Sound() {
-}
-
-void Sound::playSfx(byte *data, uint32 size) {
- Common::MemoryReadStream *mem = new Common::MemoryReadStream(data, size);
-
- // Now create the audio stream and play it (it's just a regular WAVE file)
- Audio::AudioStream *sfx = Audio::makeWAVStream(mem, true);
- _mixer->playInputStream(Audio::Mixer::kSFXSoundType, &_sfxHandle, sfx);
-}
-
-void Sound::playMusic(byte *data, uint32 size) {
- Common::MemoryReadStream *mem = new Common::MemoryReadStream(data, size);
-
- // Now create the audio stream and play it (it's just a regular WAVE file)
- Audio::AudioStream *mus = Audio::makeWAVStream(mem, true);
- _mixer->playInputStream(Audio::Mixer::kMusicSoundType, &_musicHandle, mus);
-}
-
-} // end of namespace Asylum
+/* 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.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#include "asylum/sound.h"
+
+#include "common/stream.h"
+#include "sound/wave.h"
+
+namespace Asylum {
+
+Sound::Sound(Audio::Mixer *mixer) : _mixer(mixer) {
+}
+
+Sound::~Sound() {
+}
+
+void Sound::playSfx(byte *data, uint32 size) {
+ Common::MemoryReadStream *mem = new Common::MemoryReadStream(data, size);
+
+ // Now create the audio stream and play it (it's just a regular WAVE file)
+ Audio::AudioStream *sfx = Audio::makeWAVStream(mem, true);
+ _mixer->playInputStream(Audio::Mixer::kSFXSoundType, &_sfxHandle, sfx);
+}
+
+void Sound::playMusic(byte *data, uint32 size) {
+ Common::MemoryReadStream *mem = new Common::MemoryReadStream(data, size);
+
+ // Now create the audio stream and play it (it's just a regular WAVE file)
+ Audio::AudioStream *mus = Audio::makeWAVStream(mem, true);
+ _mixer->playInputStream(Audio::Mixer::kMusicSoundType, &_musicHandle, mus);
+}
+
+} // end of namespace Asylum
diff --git a/engines/asylum/sound.h b/engines/asylum/sound.h
index 4152060638..0ef54e07de 100644
--- a/engines/asylum/sound.h
+++ b/engines/asylum/sound.h
@@ -1,67 +1,67 @@
-/* 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.
- *
- * $URL$
- * $Id$
- *
- */
-
-#ifndef ASYLUM_SOUND_H_
-#define ASYLUM_SOUND_H_
-
-#include "sound/mixer.h"
-#include "asylum/respack.h"
-
-namespace Asylum {
-
-class Sound {
-public:
- Sound(Audio::Mixer *mixer);
- ~Sound();
-
- void playSfx(byte *data, uint32 size);
- void playSfx(ResourcePack *resPack, uint32 resourceId) {
- ResourceEntry *resEntry = resPack->getResource(resourceId);
- playSfx(resEntry->data, resEntry->size);
- }
- bool isSfxActive() { return _mixer->isSoundHandleActive(_sfxHandle); }
- void pauseSfx() { _mixer->pauseHandle(_sfxHandle, true); }
- void resumeSfx() { _mixer->pauseHandle(_sfxHandle, false); }
- void stopSfx() { _mixer->stopHandle(_sfxHandle); }
-
- void playMusic(byte *data, uint32 size);
- void playMusic(ResourcePack *resPack, uint32 resourceId) {
- ResourceEntry *resEntry = resPack->getResource(resourceId);
- playMusic(resEntry->data, resEntry->size);
- }
- bool isMusicActive() { return _mixer->isSoundHandleActive(_musicHandle); }
- void pauseMusic() { _mixer->pauseHandle(_musicHandle, true); }
- void resumeMusic() { _mixer->pauseHandle(_musicHandle, false); }
- void stopMusic() { _mixer->stopHandle(_musicHandle); }
-
-private:
- Audio::SoundHandle _sfxHandle;
- Audio::SoundHandle _musicHandle;
- Audio::Mixer *_mixer;
-};
-
-} // end of namespace Asylum
-
-#endif
+/* 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.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#ifndef ASYLUM_SOUND_H_
+#define ASYLUM_SOUND_H_
+
+#include "sound/mixer.h"
+#include "asylum/respack.h"
+
+namespace Asylum {
+
+class Sound {
+public:
+ Sound(Audio::Mixer *mixer);
+ ~Sound();
+
+ void playSfx(byte *data, uint32 size);
+ void playSfx(ResourcePack *resPack, uint32 resourceId) {
+ ResourceEntry *resEntry = resPack->getResource(resourceId);
+ playSfx(resEntry->data, resEntry->size);
+ }
+ bool isSfxActive() { return _mixer->isSoundHandleActive(_sfxHandle); }
+ void pauseSfx() { _mixer->pauseHandle(_sfxHandle, true); }
+ void resumeSfx() { _mixer->pauseHandle(_sfxHandle, false); }
+ void stopSfx() { _mixer->stopHandle(_sfxHandle); }
+
+ void playMusic(byte *data, uint32 size);
+ void playMusic(ResourcePack *resPack, uint32 resourceId) {
+ ResourceEntry *resEntry = resPack->getResource(resourceId);
+ playMusic(resEntry->data, resEntry->size);
+ }
+ bool isMusicActive() { return _mixer->isSoundHandleActive(_musicHandle); }
+ void pauseMusic() { _mixer->pauseHandle(_musicHandle, true); }
+ void resumeMusic() { _mixer->pauseHandle(_musicHandle, false); }
+ void stopMusic() { _mixer->stopHandle(_musicHandle); }
+
+private:
+ Audio::SoundHandle _sfxHandle;
+ Audio::SoundHandle _musicHandle;
+ Audio::Mixer *_mixer;
+};
+
+} // end of namespace Asylum
+
+#endif
diff --git a/engines/asylum/text.cpp b/engines/asylum/text.cpp
index 1bdb574346..11c43e52f6 100644
--- a/engines/asylum/text.cpp
+++ b/engines/asylum/text.cpp
@@ -1,147 +1,147 @@
-/* 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.
- *
- * $URL$
- * $Id$
- *
- */
-
-#include "asylum/text.h"
-#include "common/endian.h"
-
-namespace Asylum {
-
-Text::Text(Screen *screen) : _screen(screen) {
- _posX = 0;
- _posY = 0;
- _curFontFlags = 0;
- _fontResource = 0;
-
- _textPack = new ResourcePack(0);
-}
-
-Text::~Text() {
- delete _textPack;
- delete _fontResource;
-}
-
-// loadFont at address 00435640
-void Text::loadFont(ResourcePack *resPack, uint32 resId) {
- if (_fontResource && resId == _fontResource->getEntryNum())
- return;
-
- delete _fontResource;
-
- _fontResource = new GraphicResource(resPack, resId);
-
- if (resId > 0) {
- // load font flag data
- _curFontFlags = (_fontResource->getFlags() >> 4) & 0x0F;
- }
-}
-
-void Text::setTextPos(uint32 x, uint32 y) {
- _posX = x;
- _posY = y;
-}
-
-// getTextWidth at address 004357C0
-uint32 Text::getTextWidth(char *text) {
- assert (_fontResource);
-
- int width = 0;
- uint8 character = *text;
- while (character) {
- GraphicFrame *font = _fontResource->getFrame(character);
- width += font->surface.w + font->x - _curFontFlags;
-
- text++;
- character = *text;
- }
- return width;
-}
-
-uint32 Text::getResTextWidth(uint32 resId) {
- ResourceEntry *textRes = _textPack->getResource(resId);
- return getTextWidth((char*)textRes->data);
-}
-
-void Text::drawChar(char character) {
- assert (_fontResource);
-
- GraphicFrame *fontLetter = _fontResource->getFrame(character);
- _screen->copyRectToScreenWithTransparency((byte *)fontLetter->surface.pixels, fontLetter->surface.w, _posX, _posY + fontLetter->y, fontLetter->surface.w, fontLetter->surface.h);
- _posX += fontLetter->surface.w + fontLetter->x - _curFontFlags;
-}
-
-void Text::drawText(char *text) {
- while (*text) {
- drawChar(*text);
- text++;
- }
-}
-
-void Text::drawResText(uint32 resId) {
- ResourceEntry *textRes = _textPack->getResource(resId);
- drawText((char*)textRes->data);
-}
-
-void Text::drawTextCentered(uint32 x, uint32 y, uint32 width, char *text) {
- int textWidth = getTextWidth(text);
- setTextPos(x + (width - textWidth) / 2, y);
- drawText(text);
-}
-
-void Text::drawResTextWithValueCentered(uint32 x, uint32 y, uint32 width, uint32 resId, uint32 value) {
- ResourceEntry *textRes = _textPack->getResource(resId);
- char *text = (char *)textRes->data;
- char txt[100];
- sprintf(txt, text, value);
- drawTextCentered(x, y, width, txt);
-}
-
-void Text::drawResTextCentered(uint32 x, uint32 y, uint32 width, uint32 resId) {
- ResourceEntry *textRes = _textPack->getResource(resId);
- drawTextCentered(x, y, width, (char *)textRes->data);
-}
-
-void Text::drawText(uint32 x, uint32 y, char *text) {
- int textWidth = getTextWidth(text);
- setTextPos(x - textWidth, y);
- drawText(text);
-}
-
-void Text::drawResText(uint32 x, uint32 y, uint32 resId) {
- ResourceEntry *textRes = _textPack->getResource(resId);
- drawText(x, y, (char *)textRes->data);
-}
-
-void Text::drawTextAlignRight(uint32 x, uint32 y, char *text) {
- int textWidth = getTextWidth(text);
- setTextPos(x - textWidth, y);
- drawText(text);
-}
-
-void Text::drawResTextAlignRight(uint32 x, uint32 y, uint32 resId) {
- ResourceEntry *textRes = _textPack->getResource(resId);
- drawTextAlignRight(x, y, (char *)textRes->data);
-}
-
-} // end of namespace Asylum
+/* 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.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#include "asylum/text.h"
+#include "common/endian.h"
+
+namespace Asylum {
+
+Text::Text(Screen *screen) : _screen(screen) {
+ _posX = 0;
+ _posY = 0;
+ _curFontFlags = 0;
+ _fontResource = 0;
+
+ _textPack = new ResourcePack(0);
+}
+
+Text::~Text() {
+ delete _textPack;
+ delete _fontResource;
+}
+
+// loadFont at address 00435640
+void Text::loadFont(ResourcePack *resPack, uint32 resId) {
+ if (_fontResource && resId == _fontResource->getEntryNum())
+ return;
+
+ delete _fontResource;
+
+ _fontResource = new GraphicResource(resPack, resId);
+
+ if (resId > 0) {
+ // load font flag data
+ _curFontFlags = (_fontResource->getFlags() >> 4) & 0x0F;
+ }
+}
+
+void Text::setTextPos(uint32 x, uint32 y) {
+ _posX = x;
+ _posY = y;
+}
+
+// getTextWidth at address 004357C0
+uint32 Text::getTextWidth(char *text) {
+ assert (_fontResource);
+
+ int width = 0;
+ uint8 character = *text;
+ while (character) {
+ GraphicFrame *font = _fontResource->getFrame(character);
+ width += font->surface.w + font->x - _curFontFlags;
+
+ text++;
+ character = *text;
+ }
+ return width;
+}
+
+uint32 Text::getResTextWidth(uint32 resId) {
+ ResourceEntry *textRes = _textPack->getResource(resId);
+ return getTextWidth((char*)textRes->data);
+}
+
+void Text::drawChar(char character) {
+ assert (_fontResource);
+
+ GraphicFrame *fontLetter = _fontResource->getFrame(character);
+ _screen->copyRectToScreenWithTransparency((byte *)fontLetter->surface.pixels, fontLetter->surface.w, _posX, _posY + fontLetter->y, fontLetter->surface.w, fontLetter->surface.h);
+ _posX += fontLetter->surface.w + fontLetter->x - _curFontFlags;
+}
+
+void Text::drawText(char *text) {
+ while (*text) {
+ drawChar(*text);
+ text++;
+ }
+}
+
+void Text::drawResText(uint32 resId) {
+ ResourceEntry *textRes = _textPack->getResource(resId);
+ drawText((char*)textRes->data);
+}
+
+void Text::drawTextCentered(uint32 x, uint32 y, uint32 width, char *text) {
+ int textWidth = getTextWidth(text);
+ setTextPos(x + (width - textWidth) / 2, y);
+ drawText(text);
+}
+
+void Text::drawResTextWithValueCentered(uint32 x, uint32 y, uint32 width, uint32 resId, uint32 value) {
+ ResourceEntry *textRes = _textPack->getResource(resId);
+ char *text = (char *)textRes->data;
+ char txt[100];
+ sprintf(txt, text, value);
+ drawTextCentered(x, y, width, txt);
+}
+
+void Text::drawResTextCentered(uint32 x, uint32 y, uint32 width, uint32 resId) {
+ ResourceEntry *textRes = _textPack->getResource(resId);
+ drawTextCentered(x, y, width, (char *)textRes->data);
+}
+
+void Text::drawText(uint32 x, uint32 y, char *text) {
+ int textWidth = getTextWidth(text);
+ setTextPos(x - textWidth, y);
+ drawText(text);
+}
+
+void Text::drawResText(uint32 x, uint32 y, uint32 resId) {
+ ResourceEntry *textRes = _textPack->getResource(resId);
+ drawText(x, y, (char *)textRes->data);
+}
+
+void Text::drawTextAlignRight(uint32 x, uint32 y, char *text) {
+ int textWidth = getTextWidth(text);
+ setTextPos(x - textWidth, y);
+ drawText(text);
+}
+
+void Text::drawResTextAlignRight(uint32 x, uint32 y, uint32 resId) {
+ ResourceEntry *textRes = _textPack->getResource(resId);
+ drawTextAlignRight(x, y, (char *)textRes->data);
+}
+
+} // end of namespace Asylum
diff --git a/engines/asylum/text.h b/engines/asylum/text.h
index c5750093ac..6dfac2d942 100644
--- a/engines/asylum/text.h
+++ b/engines/asylum/text.h
@@ -1,73 +1,73 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * $URL$
- * $Id$
- *
- */
-
-#ifndef ASYLUM_TEXT_H_
-#define ASYLUM_TEXT_H_
-
-#include "asylum/screen.h"
-#include "asylum/respack.h"
-
-namespace Asylum {
-
-class Screen;
-
-class Text {
-public:
- Text(Screen *screen);
- ~Text();
-
- void loadFont(ResourcePack *resPack, uint32 resId);
-
- void setTextPos(uint32 x, uint32 y);
- uint32 getTextWidth(char *text);
- uint32 getResTextWidth(uint32 resId);
-
- void drawChar(char character);
- void drawText(char *text);
- void drawText(uint32 x, uint32 y, char *text);
- void drawResText(uint32 resId);
- void drawResText(uint32 x, uint32 y, uint32 resId);
-
- void drawTextCentered(uint32 x, uint32 y, uint32 width, char *text);
- void drawResTextCentered(uint32 x, uint32 y, uint32 width, uint32 resId);
- void drawResTextWithValueCentered(uint32 x, uint32 y, uint32 width, uint32 resId, uint32 value);
-
- void drawTextAlignRight(uint32 x, uint32 y, char *text);
- void drawResTextAlignRight(uint32 x, uint32 y, uint32 resId);
-
-private:
- Screen *_screen;
- GraphicResource *_fontResource;
- ResourcePack *_textPack;
-
- uint32 _posX;
- uint32 _posY;
- uint8 _curFontFlags;
-
-}; // end of class Text
-
-} // end of namespace Asylum
-
-#endif
+/* 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.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#ifndef ASYLUM_TEXT_H_
+#define ASYLUM_TEXT_H_
+
+#include "asylum/screen.h"
+#include "asylum/respack.h"
+
+namespace Asylum {
+
+class Screen;
+
+class Text {
+public:
+ Text(Screen *screen);
+ ~Text();
+
+ void loadFont(ResourcePack *resPack, uint32 resId);
+
+ void setTextPos(uint32 x, uint32 y);
+ uint32 getTextWidth(char *text);
+ uint32 getResTextWidth(uint32 resId);
+
+ void drawChar(char character);
+ void drawText(char *text);
+ void drawText(uint32 x, uint32 y, char *text);
+ void drawResText(uint32 resId);
+ void drawResText(uint32 x, uint32 y, uint32 resId);
+
+ void drawTextCentered(uint32 x, uint32 y, uint32 width, char *text);
+ void drawResTextCentered(uint32 x, uint32 y, uint32 width, uint32 resId);
+ void drawResTextWithValueCentered(uint32 x, uint32 y, uint32 width, uint32 resId, uint32 value);
+
+ void drawTextAlignRight(uint32 x, uint32 y, char *text);
+ void drawResTextAlignRight(uint32 x, uint32 y, uint32 resId);
+
+private:
+ Screen *_screen;
+ GraphicResource *_fontResource;
+ ResourcePack *_textPack;
+
+ uint32 _posX;
+ uint32 _posY;
+ uint8 _curFontFlags;
+
+}; // end of class Text
+
+} // end of namespace Asylum
+
+#endif
Commit: db63436dcc3eddc51ca6cbbe92e28bb84fef0fbd
https://github.com/scummvm/scummvm/commit/db63436dcc3eddc51ca6cbbe92e28bb84fef0fbd
Author: Filippos Karapetis (md5 at scummvm.org)
Date: 2021-05-17T15:35:38+02:00
Commit Message:
ASYLUM: Fixed compilation
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@281 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/asylum.cpp
diff --git a/engines/asylum/asylum.cpp b/engines/asylum/asylum.cpp
index 37ca4652a6..ab497932a8 100644
--- a/engines/asylum/asylum.cpp
+++ b/engines/asylum/asylum.cpp
@@ -27,6 +27,7 @@
#include "common/events.h"
#include "common/system.h"
#include "common/file.h"
+#include "common/EventRecorder.h"
#include "asylum/asylum.h"
#include "asylum/respack.h"
@@ -49,7 +50,7 @@ AsylumEngine::AsylumEngine(OSystem *system, Common::Language language)
Common::File::addDefaultDirectory(_gameDataDir.getChild("Vids"));
Common::File::addDefaultDirectory(_gameDataDir.getChild("Music"));
- _eventMan->registerRandomSource(_rnd, "asylum");
+ g_eventRec.registerRandomSource(_rnd, "asylum");
}
AsylumEngine::~AsylumEngine() {
Commit: f2b0c32fcae828a20b1bbdf027e8e26842e21857
https://github.com/scummvm/scummvm/commit/f2b0c32fcae828a20b1bbdf027e8e26842e21857
Author: Filippos Karapetis (md5 at scummvm.org)
Date: 2021-05-17T15:35:38+02:00
Commit Message:
ASYLUM: Updated the MSVC project file
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@282 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/asylum.vcproj
diff --git a/engines/asylum/asylum.vcproj b/engines/asylum/asylum.vcproj
index 31788cbe99..1c8b5df3de 100644
--- a/engines/asylum/asylum.vcproj
+++ b/engines/asylum/asylum.vcproj
@@ -9,283 +9,43 @@
TargetFrameworkVersion="131072"
>
<Platforms>
- <Platform
- Name="Win32"
- />
+ <Platform Name="Win32" />
</Platforms>
- <ToolFiles>
- </ToolFiles>
<Configurations>
- <Configuration
- Name="Debug|Win32"
- OutputDirectory="asylum_Debug"
- IntermediateDirectory="asylum_Debug"
- ConfigurationType="4"
- CharacterSet="2"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- />
- <Tool
- Name="VCCLCompilerTool"
- AdditionalOptions="/wd4201 /wd4512 /wd4511 /wd4100 /wd4121 /wd4310 /wd4706 /wd4127 /wd4189 /wd4702 /wd4996"
- Optimization="0"
- AdditionalIncludeDirectories="../..;../../engines"
- PreprocessorDefinitions="WIN32;_DEBUG;USE_ZLIB;USE_MAD;USE_VORBIS"
- MinimalRebuild="true"
- ExceptionHandling="1"
- BasicRuntimeChecks="3"
- RuntimeLibrary="1"
- BufferSecurityCheck="true"
- EnableFunctionLevelLinking="true"
- ForceConformanceInForLoopScope="true"
- UsePrecompiledHeader="0"
- WarningLevel="4"
- WarnAsError="false"
- SuppressStartupBanner="false"
- DebugInformationFormat="4"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLibrarianTool"
- OutputFile="$(OutDir)/asylum.lib"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- <Configuration
- Name="Release|Win32"
- OutputDirectory="asylum_Release"
- IntermediateDirectory="asylum_Release"
- ConfigurationType="4"
- CharacterSet="2"
- WholeProgramOptimization="1"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- />
- <Tool
- Name="VCCLCompilerTool"
- AdditionalOptions="/wd4201 /wd4512 /wd4511 /wd4100 /wd4121 /wd4310 /wd4706 /wd4127 /wd4189 /wd4702 /wd4996"
- Optimization="3"
- InlineFunctionExpansion="2"
- OmitFramePointers="true"
- AdditionalIncludeDirectories="../../;../../engines"
- PreprocessorDefinitions="WIN32;NDEBUG;USE_ZLIB;USE_MAD;USE_VORBIS"
- StringPooling="true"
- ExceptionHandling="1"
- RuntimeLibrary="0"
- BufferSecurityCheck="false"
- EnableFunctionLevelLinking="false"
- ForceConformanceInForLoopScope="true"
- UsePrecompiledHeader="0"
- WarningLevel="4"
- WarnAsError="true"
- DebugInformationFormat="0"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLibrarianTool"
- OutputFile="$(OutDir)/asylum.lib"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
+ <Configuration Name="Debug|Win32" ConfigurationType="4" InheritedPropertySheets=".\ScummVM_Debug.vsprops" />
+ <Configuration Name="Release|Win32" ConfigurationType="4" InheritedPropertySheets=".\ScummVM_Release.vsprops" />
</Configurations>
- <References>
- </References>
<Files>
- <File
- RelativePath="..\..\engines\asylum\actor.cpp"
- >
- </File>
- <File
- RelativePath="..\..\engines\asylum\actor.h"
- >
- </File>
- <File
- RelativePath="..\..\engines\asylum\asylum.cpp"
- >
- </File>
- <File
- RelativePath="..\..\engines\asylum\asylum.h"
- >
- </File>
- <File
- RelativePath="..\..\engines\asylum\blowuppuzzle.cpp"
- >
- </File>
- <File
- RelativePath="..\..\engines\asylum\blowuppuzzle.h"
- >
- </File>
- <File
- RelativePath="..\..\engines\asylum\console.cpp"
- >
- </File>
- <File
- RelativePath="..\..\engines\asylum\console.h"
- >
- </File>
- <File
- RelativePath="..\..\engines\asylum\detection.cpp"
- >
- </File>
- <File
- RelativePath="..\..\engines\asylum\encounters.cpp"
- >
- </File>
- <File
- RelativePath="..\..\engines\asylum\encounters.h"
- >
- </File>
- <File
- RelativePath="..\..\engines\asylum\graphics.cpp"
- >
- </File>
- <File
- RelativePath="..\..\engines\asylum\graphics.h"
- >
- </File>
- <File
- RelativePath="..\..\engines\asylum\interpreter.cpp"
- >
- </File>
- <File
- RelativePath="..\..\engines\asylum\interpreter.h"
- >
- </File>
- <File
- RelativePath="..\..\engines\asylum\menu.cpp"
- >
- </File>
- <File
- RelativePath="..\..\engines\asylum\menu.h"
- >
- </File>
- <File
- RelativePath="..\..\engines\asylum\respack.cpp"
- >
- </File>
- <File
- RelativePath="..\..\engines\asylum\respack.h"
- >
- </File>
- <File
- RelativePath="..\..\engines\asylum\scene.cpp"
- >
- </File>
- <File
- RelativePath="..\..\engines\asylum\scene.h"
- >
- </File>
- <File
- RelativePath="..\..\engines\asylum\sceneres.cpp"
- >
- </File>
- <File
- RelativePath="..\..\engines\asylum\sceneres.h"
- >
- </File>
- <File
- RelativePath="..\..\engines\asylum\screen.cpp"
- >
- </File>
- <File
- RelativePath="..\..\engines\asylum\screen.h"
- >
- </File>
- <File
- RelativePath="..\..\engines\asylum\sound.cpp"
- >
- </File>
- <File
- RelativePath="..\..\engines\asylum\sound.h"
- >
- </File>
- <File
- RelativePath="..\..\engines\asylum\text.cpp"
- >
- </File>
- <File
- RelativePath="..\..\engines\asylum\text.h"
- >
- </File>
- <File
- RelativePath="..\..\engines\asylum\video.cpp"
- >
- </File>
- <File
- RelativePath="..\..\engines\asylum\video.h"
- >
- </File>
+ <File RelativePath="..\..\engines\asylum\actor.cpp" />
+ <File RelativePath="..\..\engines\asylum\actor.h" />
+ <File RelativePath="..\..\engines\asylum\asylum.cpp" />
+ <File RelativePath="..\..\engines\asylum\asylum.h" />
+ <File RelativePath="..\..\engines\asylum\blowuppuzzle.cpp" />
+ <File RelativePath="..\..\engines\asylum\blowuppuzzle.h" />
+ <File RelativePath="..\..\engines\asylum\console.cpp" />
+ <File RelativePath="..\..\engines\asylum\console.h" />
+ <File RelativePath="..\..\engines\asylum\detection.cpp" />
+ <File RelativePath="..\..\engines\asylum\encounters.cpp" />
+ <File RelativePath="..\..\engines\asylum\encounters.h" />
+ <File RelativePath="..\..\engines\asylum\graphics.cpp" />
+ <File RelativePath="..\..\engines\asylum\graphics.h" />
+ <File RelativePath="..\..\engines\asylum\menu.cpp" />
+ <File RelativePath="..\..\engines\asylum\menu.h" />
+ <File RelativePath="..\..\engines\asylum\respack.cpp" />
+ <File RelativePath="..\..\engines\asylum\respack.h" />
+ <File RelativePath="..\..\engines\asylum\scene.cpp" />
+ <File RelativePath="..\..\engines\asylum\scene.h" />
+ <File RelativePath="..\..\engines\asylum\sceneres.cpp" />
+ <File RelativePath="..\..\engines\asylum\sceneres.h" />
+ <File RelativePath="..\..\engines\asylum\screen.cpp" />
+ <File RelativePath="..\..\engines\asylum\screen.h" />
+ <File RelativePath="..\..\engines\asylum\scriptman.cpp" />
+ <File RelativePath="..\..\engines\asylum\scriptman.h" />
+ <File RelativePath="..\..\engines\asylum\sound.cpp" />
+ <File RelativePath="..\..\engines\asylum\sound.h" />
+ <File RelativePath="..\..\engines\asylum\text.cpp" />
+ <File RelativePath="..\..\engines\asylum\text.h" />
+ <File RelativePath="..\..\engines\asylum\video.cpp" />
+ <File RelativePath="..\..\engines\asylum\video.h" />
</Files>
- <Globals>
- </Globals>
</VisualStudioProject>
Commit: 5b1c7c9a837e88b6e2936f970ecdc055336b6480
https://github.com/scummvm/scummvm/commit/5b1c7c9a837e88b6e2936f970ecdc055336b6480
Author: Alexandre Fontoura (alexandrefontoura at gmail.com)
Date: 2021-05-17T15:35:39+02:00
Commit Message:
ASYLUM: More VCR puzzle done. [Now with button states working]
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@283 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/blowuppuzzle.cpp
engines/asylum/blowuppuzzle.h
diff --git a/engines/asylum/blowuppuzzle.cpp b/engines/asylum/blowuppuzzle.cpp
index 60d5cd89d0..4beb16cd31 100644
--- a/engines/asylum/blowuppuzzle.cpp
+++ b/engines/asylum/blowuppuzzle.cpp
@@ -97,7 +97,7 @@ BlowUpPuzzleVCR::BlowUpPuzzleVCR(Screen *screen, Sound *sound, Scene *scene) : B
_cursorResource = _scene->getGraphicResource(_scene->getResources()->getWorldStats()->grResId[28]);
_bgResource = _scene->getGraphicResource(_scene->getResources()->getWorldStats()->grResId[0]);
_tvScreenAnimIdx = 0;
- _isAccomplished = 0;
+ _isAccomplished = false;
// reset all states
memset(&_jacksState,0,sizeof(_jacksState));
@@ -452,10 +452,45 @@ void BlowUpPuzzleVCR::handleMouseDown() {
}
// TODO: VCR button regions
+ if (inPolyRegion(_mouseX, _mouseY, kRewindButton)) {
+ _sound->playSfx(_scene->getResourcePack(), _scene->getResources()->getWorldStats()->grResId[39]);
+ if(!_buttonsState[kRewind]) {
+ _buttonsState[kRewind] = 2;
+ return;
+ }
+ if(_buttonsState[kRewind] == 1) {
+ _buttonsState[kRewind] = 3;
+ return;
+ }
+ } else if (inPolyRegion(_mouseX, _mouseY, kPlayButton)) {
+
+ } else if (inPolyRegion(_mouseX, _mouseY, kStopButton)) {
+
+ } else if (inPolyRegion(_mouseX, _mouseY, kRecButton)) {
+
+ }
}
void BlowUpPuzzleVCR::handleMouseUp() {
+ if(_isAccomplished)
+ return;
+
+ // TODO: check rec button states
+
+ // TODO: check rewind button states
+
+ // if button play ON than check the jacks
+ if(1) { // play button == 3
+ // TODO: reset button play state
+ if(_holesState[kRed] == kPluggedOnRed && _holesState[kYellow] == kPluggedOnYellow && _holesState[kBlack] == kPluggedOnBlack) {
+ // TODO: set game flag 220
+ _isAccomplished = true;
+ }
+ } else { //if() { // play button == 2
+ // TODO: reset state
+ }
+ // TODO: check stop button states
}
} // end of namespace Asylum
diff --git a/engines/asylum/blowuppuzzle.h b/engines/asylum/blowuppuzzle.h
index a3f93372af..09bdb12696 100644
--- a/engines/asylum/blowuppuzzle.h
+++ b/engines/asylum/blowuppuzzle.h
@@ -150,11 +150,18 @@ private:
kYellowJack = 9
};
+ enum Button {
+ kRewind = 0,
+ kStop = 1,
+ kPlay = 2,
+ kRec = 3
+ };
+
int _jacksState[3];
int _holesState[3];
int _buttonsState[4];
int _tvScreenAnimIdx;
- int _isAccomplished;
+ bool _isAccomplished;
int inPolyRegion(int x, int y, int polyIdx);
Commit: 914e970a7cfdca401a604a3de2cc1fe3601f20a6
https://github.com/scummvm/scummvm/commit/914e970a7cfdca401a604a3de2cc1fe3601f20a6
Author: Alexandre Fontoura (alexandrefontoura at gmail.com)
Date: 2021-05-17T15:35:39+02:00
Commit Message:
ASYLUM: Fixed previous commit mistaken files. Plus add support for TV sync while VCR ON.
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@284 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/blowuppuzzle.cpp
engines/asylum/blowuppuzzle.h
diff --git a/engines/asylum/blowuppuzzle.cpp b/engines/asylum/blowuppuzzle.cpp
index 4beb16cd31..8a70a6aa93 100644
--- a/engines/asylum/blowuppuzzle.cpp
+++ b/engines/asylum/blowuppuzzle.cpp
@@ -46,6 +46,18 @@ void BlowUpPuzzle::updateCursor() {
_screen->setCursor(_cursorResource, _curMouseCursor);
}
+void BlowUpPuzzle::addGraphicToQueue(uint32 redId, uint32 x, uint32 y, uint32 frameIdx, uint32 flags, uint32 priority) {
+ GraphicQueueItem item;
+ item.resId = redId;
+ item.x = x;
+ item.y = y;
+ item.frameIdx = frameIdx;
+ item.flags = flags;
+ item.priority = priority;
+
+ _queueItems.push_back(item);
+}
+
void BlowUpPuzzle::addGraphicToQueue(GraphicQueueItem item) {
_queueItems.push_back(item);
}
@@ -188,15 +200,28 @@ void BlowUpPuzzleVCR::update() {
handleMouseUp();
}
+ updateCursorInPolyRegion();
+
updateBlackJack();
updateRedJack();
updateYellowJack();
- updateCursorInPolyRegion();
+ updatePowerButton();
+ updateRewindButton();
+ updatePlayButton();
+ updateStopButton();
- if(!_isAccomplished) {
- updateGraphicsInQueue();
+ if(_buttonsState[kPower] == kON) {
+ addGraphicToQueue(_scene->getResources()->getWorldStats()->grResId[22], 0, 37, _tvScreenAnimIdx, 0, 1);
+ addGraphicToQueue(_scene->getResources()->getWorldStats()->grResId[23], 238, 22, _tvScreenAnimIdx++, 0, 1);
+ _tvScreenAnimIdx %= 6;
}
+
+ if(_isAccomplished) {
+ debug("BlowUpPuzzle ACCOMPLISHED!!");
+ } else {
+ updateGraphicsInQueue();
+ }
}
GraphicQueueItem BlowUpPuzzleVCR::getGraphicJackItem(int resId) {
@@ -232,7 +257,7 @@ GraphicQueueItem BlowUpPuzzleVCR::getGraphicShadowItem() {
return shadowItem;
}
-void BlowUpPuzzleVCR::updateJack(Jack jack, JackInfo onTable, JackInfo pluggedOnRed, JackInfo pluggedOnYellow, JackInfo pluggedOnBlack, int resIdOnHand) {
+void BlowUpPuzzleVCR::updateJack(Jack jack, VCRDrawInfo onTable, VCRDrawInfo pluggedOnRed, VCRDrawInfo pluggedOnYellow, VCRDrawInfo pluggedOnBlack, int resIdOnHand) {
GraphicQueueItem item;
switch(_jacksState[jack]){
@@ -283,60 +308,165 @@ void BlowUpPuzzleVCR::updateJack(Jack jack, JackInfo onTable, JackInfo pluggedOn
}
void BlowUpPuzzleVCR::updateBlackJack() {
- JackInfo onTable;
+ VCRDrawInfo onTable;
onTable.resId = 1;
onTable.x = 0;
onTable.y = 411;
- JackInfo pluggedOnRed;
+ VCRDrawInfo pluggedOnRed;
pluggedOnRed.resId = 5;
- JackInfo pluggedOnYellow;
+ VCRDrawInfo pluggedOnYellow;
pluggedOnYellow.resId = 8;
- JackInfo pluggedOnBlack;
+ VCRDrawInfo pluggedOnBlack;
pluggedOnBlack.resId = 11;
updateJack(kBlack, onTable, pluggedOnRed, pluggedOnYellow, pluggedOnBlack, 27);
}
void BlowUpPuzzleVCR::updateRedJack() {
- JackInfo onTable;
+ VCRDrawInfo onTable;
onTable.resId = 2;
onTable.x = 76;
onTable.y = 428;
- JackInfo pluggedOnRed;
+ VCRDrawInfo pluggedOnRed;
pluggedOnRed.resId = 4;
- JackInfo pluggedOnYellow;
+ VCRDrawInfo pluggedOnYellow;
pluggedOnYellow.resId = 7;
- JackInfo pluggedOnBlack;
+ VCRDrawInfo pluggedOnBlack;
pluggedOnBlack.resId = 10;
updateJack(kRed, onTable, pluggedOnRed, pluggedOnYellow, pluggedOnBlack, 25);
}
void BlowUpPuzzleVCR::updateYellowJack() {
- JackInfo onTable;
+ VCRDrawInfo onTable;
onTable.resId = 3;
onTable.x = 187;
onTable.y = 439;
- JackInfo pluggedOnRed;
+ VCRDrawInfo pluggedOnRed;
pluggedOnRed.resId = 6;
- JackInfo pluggedOnYellow;
+ VCRDrawInfo pluggedOnYellow;
pluggedOnYellow.resId = 9;
- JackInfo pluggedOnBlack;
+ VCRDrawInfo pluggedOnBlack;
pluggedOnBlack.resId = 12;
updateJack(kYellow, onTable, pluggedOnRed, pluggedOnYellow, pluggedOnBlack, 26);
}
+// common function to set and unset the jack on holes for each type of jack
+int BlowUpPuzzleVCR::setJackOnHole(int jackType, JackState plugged) {
+ if(!_holesState[plugged-1]) {
+ if(_jacksState[jackType-1] == kOnHand) {
+ _jacksState[jackType-1] = plugged;
+ _holesState[plugged-1] = jackType; // set jack on red
+ _sound->playSfx(_scene->getResourcePack(), _scene->getResources()->getWorldStats()->grResId[44]);
+ }
+ } else if(jackType == 0) {
+ jackType = _holesState[plugged-1];
+ _jacksState[jackType-1] = kOnHand;
+ _holesState[plugged-1] = 0;
+ _sound->playSfx(_scene->getResourcePack(), _scene->getResources()->getWorldStats()->grResId[43]);
+ return 0;
+ }
+ return 1;
+}
+
+void BlowUpPuzzleVCR::updateButton(Button button, VCRDrawInfo btON, VCRDrawInfo btDown) {
+ GraphicQueueItem item;
+
+ switch(_buttonsState[button]){
+ case kON:
+ item.resId = _scene->getResources()->getWorldStats()->grResId[btON.resId];
+ item.frameIdx = 0;
+ item.x = btON.x;
+ item.y = btON.y;
+ item.priority = 3;
+ break;
+ case kDownON:
+ case kDownOFF:
+ item.resId = _scene->getResources()->getWorldStats()->grResId[btDown.resId];
+ item.frameIdx = 0;
+ item.x = btDown.x;
+ item.y = btDown.y;
+ item.priority = 3;
+ break;
+ default:
+ item.resId = 0;
+ break;
+ }
+
+ if(item.resId != 0)
+ {
+ addGraphicToQueue(item);
+ }
+}
+
+void BlowUpPuzzleVCR::updatePowerButton() {
+ VCRDrawInfo btON;
+ btON.resId = 17;
+ btON.x = 512;
+ btON.y = 347;
+
+ VCRDrawInfo btDown;
+ btDown.resId = 21;
+ btDown.x = 506;
+ btDown.y = 343;
+
+ updateButton(kPower, btON, btDown);
+}
+
+void BlowUpPuzzleVCR::updateRewindButton() {
+ VCRDrawInfo btON;
+ btON.resId = 14;
+ btON.x = 248;
+ btON.y = 347;
+
+ VCRDrawInfo btDown;
+ btDown.resId = 18;
+ btDown.x = 245;
+ btDown.y = 344;
+
+ updateButton(kRewind, btON, btDown);
+}
+
+void BlowUpPuzzleVCR::updatePlayButton() {
+ VCRDrawInfo btON;
+ btON.resId = 16;
+ btON.x = 401;
+ btON.y = 359;
+
+ VCRDrawInfo btDown;
+ btDown.resId = 20;
+ btDown.x = 391;
+ btDown.y = 355;
+
+ updateButton(kPlay, btON, btDown);
+}
+
+void BlowUpPuzzleVCR::updateStopButton() {
+ VCRDrawInfo btON;
+ btON.resId = 15;
+ btON.x = 330;
+ btON.y = 354;
+
+ VCRDrawInfo btDown;
+ btDown.resId = 19;
+ btDown.x = 326;
+ btDown.y = 350;
+
+ updateButton(kStop, btON, btDown);
+}
+
+
void BlowUpPuzzleVCR::updateCursorInPolyRegion() {
int showCursor = 0;
@@ -352,7 +482,7 @@ void BlowUpPuzzleVCR::updateCursorInPolyRegion() {
if(inPolyRegion(_mouseX, _mouseY, kRewindButton)
|| inPolyRegion(_mouseX, _mouseY, kStopButton)
|| inPolyRegion(_mouseX, _mouseY, kPlayButton)
- || inPolyRegion(_mouseX, _mouseY, kRecButton)
+ || inPolyRegion(_mouseX, _mouseY, kPowerButton)
|| inPolyRegion(_mouseX, _mouseY, kBlackJack)
|| inPolyRegion(_mouseX, _mouseY, kRedJack)
|| inPolyRegion(_mouseX, _mouseY, kYellowJack)) {
@@ -379,25 +509,6 @@ void BlowUpPuzzleVCR::updateCursorInPolyRegion() {
} else {
_screen->hideCursor();
}
-
-}
-
-// common function to set and unset the jack on holes for each type of jack
-int BlowUpPuzzleVCR::setJackOnHole(int jackType, JackState plugged) {
- if(!_holesState[plugged-1]) {
- if(_jacksState[jackType-1] == kOnHand) {
- _jacksState[jackType-1] = plugged;
- _holesState[plugged-1] = jackType; // set jack on red
- _sound->playSfx(_scene->getResourcePack(), _scene->getResources()->getWorldStats()->grResId[44]);
- }
- } else if(jackType == 0) {
- jackType = _holesState[plugged-1];
- _jacksState[jackType-1] = kOnHand;
- _holesState[plugged-1] = 0;
- _sound->playSfx(_scene->getResourcePack(), _scene->getResources()->getWorldStats()->grResId[43]);
- return 0;
- }
- return 1;
}
void BlowUpPuzzleVCR::handleMouseDown() {
@@ -427,6 +538,12 @@ void BlowUpPuzzleVCR::handleMouseDown() {
}
if(inPolyRegion(_mouseX, _mouseY, kBlackHole)) {
if(!setJackOnHole(jackType, kPluggedOnBlack)) {
+ if(_holesState[kBlackHole] != kPluggedOnYellow && _buttonsState[kPower] == 1) { // TODO: check this better
+ _buttonsState[kPower] = kOFF;
+ _buttonsState[kStop] = kOFF;
+ _buttonsState[kPlay] = kOFF;
+ _buttonsState[kRewind] = kOFF;
+ }
return;
}
}
@@ -455,19 +572,42 @@ void BlowUpPuzzleVCR::handleMouseDown() {
if (inPolyRegion(_mouseX, _mouseY, kRewindButton)) {
_sound->playSfx(_scene->getResourcePack(), _scene->getResources()->getWorldStats()->grResId[39]);
if(!_buttonsState[kRewind]) {
- _buttonsState[kRewind] = 2;
+ _buttonsState[kRewind] = kDownON;
return;
}
- if(_buttonsState[kRewind] == 1) {
- _buttonsState[kRewind] = 3;
+ if(_buttonsState[kRewind] == kON) {
+ _buttonsState[kRewind] = kDownOFF;
return;
}
} else if (inPolyRegion(_mouseX, _mouseY, kPlayButton)) {
-
+ _sound->playSfx(_scene->getResourcePack(), _scene->getResources()->getWorldStats()->grResId[39]);
+ if(!_buttonsState[kPlay]) {
+ _buttonsState[kPlay] = kDownON;
+ return;
+ }
+ if(_buttonsState[kPlay] == kON) {
+ _buttonsState[kPlay] = kDownOFF;
+ return;
+ }
} else if (inPolyRegion(_mouseX, _mouseY, kStopButton)) {
+ _sound->playSfx(_scene->getResourcePack(), _scene->getResources()->getWorldStats()->grResId[39]);
+ if(_buttonsState[kStop]) {
+ if(_buttonsState[kStop] == kON) {
+ _buttonsState[kStop] = kDownOFF;
+ return;
+ }
+ } else {
+ _buttonsState[kStop] = kDownON;
+ return;
+ }
+ } else if (inPolyRegion(_mouseX, _mouseY, kPowerButton)) {
+ _sound->playSfx(_scene->getResourcePack(), _scene->getResources()->getWorldStats()->grResId[39]);
- } else if (inPolyRegion(_mouseX, _mouseY, kRecButton)) {
-
+ if(!_buttonsState[kPower] && _holesState[kPluggedOnBlack-1] == kBlack+1 && _holesState[kPluggedOnRed-1] && _holesState[kPluggedOnYellow-1]) {
+ _buttonsState[kPower] = kDownON;
+ } else {
+ _buttonsState[kPower] = kDownOFF;
+ }
}
}
@@ -475,22 +615,45 @@ void BlowUpPuzzleVCR::handleMouseUp() {
if(_isAccomplished)
return;
- // TODO: check rec button states
+ if(_buttonsState[kPower] == kDownON) {
+ // TODO: check if next sound is already playing
+ _sound->playSfx(_scene->getResourcePack(), _scene->getResources()->getWorldStats()->grResId[47]);
+ _buttonsState[kPower] = kON;
+ _buttonsState[kStop] = kON;
+ _buttonsState[kPlay] = kON;
+ _buttonsState[kRewind] = kON;
+ } else if(_buttonsState[kPower] == kDownOFF) {
+ _buttonsState[kPower] = kOFF;
+ _buttonsState[kStop] = kOFF;
+ _buttonsState[kPlay] = kOFF;
+ _buttonsState[kRewind] = kOFF;
+ // TODO: stop sound grResId[47]
+ }
- // TODO: check rewind button states
+ if(_buttonsState[kRewind] == kDownOFF) {
+ _buttonsState[kRewind] = kON;
+ _sound->playSfx(_scene->getResourcePack(), _scene->getResources()->getWorldStats()->grResId[46]);
+ } else if(_buttonsState[kRewind] == kDownON) {
+ _buttonsState[kRewind] = kOFF;
+ }
- // if button play ON than check the jacks
- if(1) { // play button == 3
- // TODO: reset button play state
- if(_holesState[kRed] == kPluggedOnRed && _holesState[kYellow] == kPluggedOnYellow && _holesState[kBlack] == kPluggedOnBlack) {
+ if(_buttonsState[kPlay] == kDownOFF) {
+ _buttonsState[kPlay] = kON;
+ if(_holesState[kPluggedOnRed-1] == kRed+1 && _holesState[kPluggedOnYellow-1] == kYellow+1 && _holesState[kPluggedOnBlack-1] == kBlack+1) {
// TODO: set game flag 220
_isAccomplished = true;
}
- } else { //if() { // play button == 2
- // TODO: reset state
+ } else if(_buttonsState[kPlay] == kDownON) {
+ _buttonsState[kPlay] = kOFF;
}
- // TODO: check stop button states
+ if(_buttonsState[kStop] == kDownOFF) {
+ _buttonsState[kStop] = kON;
+ return;
+ }
+ if(_buttonsState[kStop] == kDownON) {
+ _buttonsState[kStop] = kOFF;
+ }
}
} // end of namespace Asylum
diff --git a/engines/asylum/blowuppuzzle.h b/engines/asylum/blowuppuzzle.h
index 09bdb12696..48664dc7d1 100644
--- a/engines/asylum/blowuppuzzle.h
+++ b/engines/asylum/blowuppuzzle.h
@@ -81,10 +81,11 @@ protected:
Common::Array<GraphicQueueItem> _queueItems;
- void updateCursor();
+ void updateCursor();
virtual void update() {};
- // This should probably be inside screen class
+ // FIXME This should probably be inside screen class
+ void addGraphicToQueue(uint32 redId, uint32 x, uint32 y, uint32 frameIdx, uint32 flags, uint32 priority);
void addGraphicToQueue(GraphicQueueItem item);
void updateGraphicsInQueue();
void graphicsSelectionSort();
@@ -95,11 +96,11 @@ protected:
// ---- VCR -------------------
-typedef struct JackInfo {
+typedef struct VCRDrawInfo {
uint32 resId;
uint32 x;
uint32 y;
-} JackInfo;
+} VCRDrawInfo;
const Common::Rect BlowUpPuzzleVCRPolies[10] = {
Common::Rect(0x0F7, 0x157, 0x13A, 0x183), // rewind button region
@@ -141,7 +142,7 @@ private:
kRewindButton = 0,
kStopButton = 1,
kPlayButton = 2,
- kRecButton = 3,
+ kPowerButton = 3,
kRedHole = 4,
kYellowHole = 5,
kBlackHole = 6,
@@ -154,7 +155,14 @@ private:
kRewind = 0,
kStop = 1,
kPlay = 2,
- kRec = 3
+ kPower = 3
+ };
+
+ enum ButtonState {
+ kOFF = 0,
+ kON = 1,
+ kDownON = 2,
+ kDownOFF = 3
};
int _jacksState[3];
@@ -167,16 +175,24 @@ private:
void update();
+ void updateCursorInPolyRegion();
+
GraphicQueueItem getGraphicJackItem(int resId);
GraphicQueueItem getGraphicShadowItem();
- void updateJack(Jack jack, JackInfo onTable, JackInfo pluggedOnRed, JackInfo pluggedOnYellow, JackInfo pluggedOnBlack, int resIdOnHand);
+ void updateJack(Jack jack, VCRDrawInfo onTable, VCRDrawInfo pluggedOnRed, VCRDrawInfo pluggedOnYellow, VCRDrawInfo pluggedOnBlack, int resIdOnHand);
void updateBlackJack();
void updateRedJack();
void updateYellowJack();
+ int setJackOnHole(int jackType, JackState plugged);
- void updateCursorInPolyRegion();
+ void updateButton(Button button, VCRDrawInfo btON, VCRDrawInfo btDown);
+ void updatePowerButton();
+ void updateRewindButton();
+ void updatePlayButton();
+ void updateStopButton();
- int setJackOnHole(int jackType, JackState plugged);
+ void updateTVSync();
+
void handleMouseDown();
void handleMouseUp();
}; // end of class BlowUpPuzzleVCR
Commit: 6aeb8057cedba028e3c272a34455492a3eccf34f
https://github.com/scummvm/scummvm/commit/6aeb8057cedba028e3c272a34455492a3eccf34f
Author: Alexandre Fontoura (alexandrefontoura at gmail.com)
Date: 2021-05-17T15:35:39+02:00
Commit Message:
ASYLUM: Finished VCR BlowUpPuzzle code.(Still missing some sound features like loop and stop specific sounds)
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@285 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/asylum.cpp
engines/asylum/blowuppuzzle.cpp
engines/asylum/blowuppuzzle.h
engines/asylum/scene.h
engines/asylum/screen.cpp
engines/asylum/screen.h
diff --git a/engines/asylum/asylum.cpp b/engines/asylum/asylum.cpp
index ab497932a8..e8ab3cd1d4 100644
--- a/engines/asylum/asylum.cpp
+++ b/engines/asylum/asylum.cpp
@@ -105,7 +105,7 @@ Common::Error AsylumEngine::go() {
// Set up the game's main scene
_scene = new Scene(_screen, _sound, 5);
- _blowUp = new BlowUpPuzzleVCR(_screen, _sound, _scene);
+ _blowUp = new BlowUpPuzzleVCR(_screen, _sound, _scene, _video);
// TODO Since the ScriptMan is a singleton, setScene assignments could
// probably be rolled into the Scene constructor :D
diff --git a/engines/asylum/blowuppuzzle.cpp b/engines/asylum/blowuppuzzle.cpp
index 8a70a6aa93..401ad658b6 100644
--- a/engines/asylum/blowuppuzzle.cpp
+++ b/engines/asylum/blowuppuzzle.cpp
@@ -29,8 +29,8 @@
namespace Asylum {
-BlowUpPuzzle::BlowUpPuzzle(Screen *screen, Sound *sound, Scene *scene) :
- _screen(screen), _sound(sound), _scene(scene) {
+BlowUpPuzzle::BlowUpPuzzle(Screen *screen, Sound *sound, Scene *scene, Video *video) :
+ _screen(screen), _sound(sound), _scene(scene), _video(video) {
}
BlowUpPuzzle::~BlowUpPuzzle() {
@@ -97,7 +97,7 @@ void BlowUpPuzzle::swapGraphicItem(int item1, int item2) {
// BlowUp Puzzle VCR ---------------------------------------------------------------------------------------------
-BlowUpPuzzleVCR::BlowUpPuzzleVCR(Screen *screen, Sound *sound, Scene *scene) : BlowUpPuzzle(screen, sound, scene) {
+BlowUpPuzzleVCR::BlowUpPuzzleVCR(Screen *screen, Sound *sound, Scene *scene, Video *video) : BlowUpPuzzle(screen, sound, scene, video) {
_mouseX = 0;
_mouseY = 0;
_leftClickUp = false;
@@ -219,6 +219,22 @@ void BlowUpPuzzleVCR::update() {
if(_isAccomplished) {
debug("BlowUpPuzzle ACCOMPLISHED!!");
+
+ updateGraphicsInQueue();
+
+ int barSize = 0;
+ do {
+ _screen->drawWideScreen(barSize);
+ barSize += 4;
+ } while(barSize < 84);
+
+ // TODO: fade palette to grey
+
+ _video->playVideo(2, kSubtitlesOn);
+
+ _isAccomplished = false;
+ _active = false;
+ _scene->enterScene();
} else {
updateGraphicsInQueue();
}
diff --git a/engines/asylum/blowuppuzzle.h b/engines/asylum/blowuppuzzle.h
index 48664dc7d1..6e37bf5423 100644
--- a/engines/asylum/blowuppuzzle.h
+++ b/engines/asylum/blowuppuzzle.h
@@ -38,6 +38,7 @@ namespace Asylum {
class Scene;
class Screen;
class Sound;
+class Video;
typedef struct GraphicQueueItem {
uint32 resId;
@@ -52,7 +53,7 @@ typedef struct GraphicQueueItem {
class BlowUpPuzzle {
public:
- BlowUpPuzzle(Screen *screen, Sound *sound, Scene *scene);
+ BlowUpPuzzle(Screen *screen, Sound *sound, Scene *scene, Video *video);
virtual ~BlowUpPuzzle();
virtual void handleEvent(Common::Event *event, bool doUpdate){};
@@ -66,6 +67,7 @@ protected:
Screen *_screen;
Sound *_sound;
Scene *_scene;
+ Video *_video;
uint32 _mouseX;
uint32 _mouseY;
@@ -117,7 +119,7 @@ const Common::Rect BlowUpPuzzleVCRPolies[10] = {
class BlowUpPuzzleVCR : public BlowUpPuzzle {
public:
- BlowUpPuzzleVCR(Screen *screen, Sound *sound, Scene *scene);
+ BlowUpPuzzleVCR(Screen *screen, Sound *sound, Scene *scene, Video *video);
~BlowUpPuzzleVCR();
void handleEvent(Common::Event *event, bool doUpdate);
diff --git a/engines/asylum/scene.h b/engines/asylum/scene.h
index bee98b93a5..65d03a5979 100644
--- a/engines/asylum/scene.h
+++ b/engines/asylum/scene.h
@@ -68,6 +68,7 @@ public:
SceneResource* getResources() { return _sceneResource; }
ResourcePack* getResourcePack() { return _resPack; }
+ ResourcePack* getResourceMusicPack() { return _musPack; }
GraphicResource* getGraphicResource(uint32 entry) { return new GraphicResource(_resPack, entry); }
private:
diff --git a/engines/asylum/screen.cpp b/engines/asylum/screen.cpp
index ea22855c56..675cfdc16f 100644
--- a/engines/asylum/screen.cpp
+++ b/engines/asylum/screen.cpp
@@ -100,4 +100,14 @@ void Screen::setPalette(byte *rgbPalette) {
_sys->setPalette(palette, 0, 256);
}
+void Screen::drawWideScreen(int16 barSize) {
+ if(barSize > 0) {
+
+ _sys->lockScreen()->fillRect(Common::Rect(0, 0, 640, barSize), 0);
+ _sys->unlockScreen();
+ _sys->lockScreen()->fillRect(Common::Rect(0, 480 - barSize, 640, 480), 0);
+ _sys->unlockScreen();
+ }
+}
+
} // end of namespace Asylum
diff --git a/engines/asylum/screen.h b/engines/asylum/screen.h
index b59b6075eb..daeee991ff 100644
--- a/engines/asylum/screen.h
+++ b/engines/asylum/screen.h
@@ -47,6 +47,7 @@ public:
void copyRectToScreenWithTransparency(byte *buffer, int pitch, int x, int y, int width, int height);
void setPalette(byte *rgbPalette);
void setPalette(ResourcePack *resPack, int entry) { setPalette(resPack->getResource(entry)->data + 32); }
+ void drawWideScreen(int16 barSize);
void showCursor() { _sys->showMouse(true); }
void hideCursor() { _sys->showMouse(false); }
Commit: 66d248b589d98dac3665c1f353a38c2592fe55e2
https://github.com/scummvm/scummvm/commit/66d248b589d98dac3665c1f353a38c2592fe55e2
Author: Alexandre Fontoura (alexandrefontoura at gmail.com)
Date: 2021-05-17T15:35:39+02:00
Commit Message:
ASYLUM: Changed struct of BlowUpPuzzle (its now part of a scene Scene). Need REVIEW please.
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@286 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/asylum.cpp
engines/asylum/asylum.h
engines/asylum/blowuppuzzle.cpp
engines/asylum/blowuppuzzle.h
engines/asylum/scene.cpp
engines/asylum/scene.h
engines/asylum/scriptman.cpp
diff --git a/engines/asylum/asylum.cpp b/engines/asylum/asylum.cpp
index e8ab3cd1d4..912e88a16f 100644
--- a/engines/asylum/asylum.cpp
+++ b/engines/asylum/asylum.cpp
@@ -56,7 +56,6 @@ AsylumEngine::AsylumEngine(OSystem *system, Common::Language language)
AsylumEngine::~AsylumEngine() {
Common::clearAllDebugChannels();
- delete _blowUp;
delete _console;
delete _scene;
delete _mainMenu;
@@ -83,7 +82,6 @@ Common::Error AsylumEngine::init() {
_console = new Console(this);
_mainMenu = 0;
_scene = 0;
- _blowUp = 0;
return Common::kNoError;
}
@@ -103,9 +101,8 @@ Common::Error AsylumEngine::go() {
//_video->playVideo(1, kSubtitlesOn);
// Set up the game's main scene
- _scene = new Scene(_screen, _sound, 5);
-
- _blowUp = new BlowUpPuzzleVCR(_screen, _sound, _scene, _video);
+ _scene = new Scene(_screen, _sound, _video, 5);
+ _scene->setBlowUpPuzzle(new BlowUpPuzzleVCR(_scene)); // this will be done by a Script command
// TODO Since the ScriptMan is a singleton, setScene assignments could
// probably be rolled into the Scene constructor :D
@@ -152,8 +149,8 @@ void AsylumEngine::checkForEvent(bool doUpdate) {
_scene->enterScene();
} else if (_scene->isActive()) {
_mainMenu->openMenu();
- } else if (_blowUp->isActive()) {
- _blowUp->closeBlowUp();
+ } else if (_scene->getBlowUpPuzzle()->isActive()) {
+ _scene->getBlowUpPuzzle()->closeBlowUp();
_scene->enterScene();
}
@@ -163,7 +160,7 @@ void AsylumEngine::checkForEvent(bool doUpdate) {
// FIXME: TEST ONLY
if (ev.kbd.keycode == Common::KEYCODE_b) {
//_mainMenu->closeMenu();
- _blowUp->openBlowUp();
+ _scene->getBlowUpPuzzle()->openBlowUp();
}
if (ev.kbd.flags == Common::KBD_CTRL) {
@@ -175,7 +172,7 @@ void AsylumEngine::checkForEvent(bool doUpdate) {
}
if (doUpdate) {
- if (_mainMenu->isActive() || _scene->isActive() || _blowUp->isActive()) {
+ if (_mainMenu->isActive() || _scene->isActive() || _scene->getBlowUpPuzzle()->isActive()) {
// Copy background image
_screen->copyBackBufferToScreen();
}
@@ -190,9 +187,9 @@ void AsylumEngine::checkForEvent(bool doUpdate) {
} else if (_scene->isActive()) {
// Pass events to the game
_scene->handleEvent(&ev, doUpdate);
- } else if (_blowUp->isActive()) {
+ } else if (_scene->getBlowUpPuzzle()->isActive()) {
// Pass events to BlowUp Puzzles
- _blowUp->handleEvent(&ev, doUpdate);
+ _scene->getBlowUpPuzzle()->handleEvent(&ev, doUpdate);
}
}
@@ -221,7 +218,7 @@ void AsylumEngine::processDelayedEvents() {
if (_scene)
delete _scene;
- _scene = new Scene(_screen, _sound, sceneIdx);
+ _scene = new Scene(_screen, _sound, _video, sceneIdx);
ScriptMan.setScene(_scene);
diff --git a/engines/asylum/asylum.h b/engines/asylum/asylum.h
index 74ac3ec208..631a969c7f 100644
--- a/engines/asylum/asylum.h
+++ b/engines/asylum/asylum.h
@@ -46,8 +46,6 @@ class Scene;
class Screen;
class Sound;
class Video;
-class BlowUpPuzzle;
-class BlowUpPuzzleVCR;
enum kDebugLevels {
kDebugLevelMain = 1 << 0,
@@ -87,7 +85,6 @@ private:
Screen *_screen;
Sound *_sound;
Video *_video;
- BlowUpPuzzle *_blowUp;
friend class Console;
};
diff --git a/engines/asylum/blowuppuzzle.cpp b/engines/asylum/blowuppuzzle.cpp
index 401ad658b6..d9b9a6f35b 100644
--- a/engines/asylum/blowuppuzzle.cpp
+++ b/engines/asylum/blowuppuzzle.cpp
@@ -29,8 +29,8 @@
namespace Asylum {
-BlowUpPuzzle::BlowUpPuzzle(Screen *screen, Sound *sound, Scene *scene, Video *video) :
- _screen(screen), _sound(sound), _scene(scene), _video(video) {
+BlowUpPuzzle::BlowUpPuzzle(Scene *scene) :
+ _scene(scene), _screen(scene->getScreen()), _sound(scene->getSound()), _video(scene->getVideo()) {
}
BlowUpPuzzle::~BlowUpPuzzle() {
@@ -97,7 +97,7 @@ void BlowUpPuzzle::swapGraphicItem(int item1, int item2) {
// BlowUp Puzzle VCR ---------------------------------------------------------------------------------------------
-BlowUpPuzzleVCR::BlowUpPuzzleVCR(Screen *screen, Sound *sound, Scene *scene, Video *video) : BlowUpPuzzle(screen, sound, scene, video) {
+BlowUpPuzzleVCR::BlowUpPuzzleVCR(Scene *scene) : BlowUpPuzzle(scene) {
_mouseX = 0;
_mouseY = 0;
_leftClickUp = false;
diff --git a/engines/asylum/blowuppuzzle.h b/engines/asylum/blowuppuzzle.h
index 6e37bf5423..f0c288c5bc 100644
--- a/engines/asylum/blowuppuzzle.h
+++ b/engines/asylum/blowuppuzzle.h
@@ -53,7 +53,7 @@ typedef struct GraphicQueueItem {
class BlowUpPuzzle {
public:
- BlowUpPuzzle(Screen *screen, Sound *sound, Scene *scene, Video *video);
+ BlowUpPuzzle(Scene *scene);
virtual ~BlowUpPuzzle();
virtual void handleEvent(Common::Event *event, bool doUpdate){};
@@ -119,7 +119,7 @@ const Common::Rect BlowUpPuzzleVCRPolies[10] = {
class BlowUpPuzzleVCR : public BlowUpPuzzle {
public:
- BlowUpPuzzleVCR(Screen *screen, Sound *sound, Scene *scene, Video *video);
+ BlowUpPuzzleVCR(Scene *scene);
~BlowUpPuzzleVCR();
void handleEvent(Common::Event *event, bool doUpdate);
diff --git a/engines/asylum/scene.cpp b/engines/asylum/scene.cpp
index 2ba0fa3ec4..678fec5c94 100644
--- a/engines/asylum/scene.cpp
+++ b/engines/asylum/scene.cpp
@@ -34,7 +34,7 @@ namespace Asylum {
int g_debugPolygons;
int g_debugBarriers;
-Scene::Scene(Screen *screen, Sound *sound, uint8 sceneIdx): _screen(screen), _sound(sound) {
+Scene::Scene(Screen *screen, Sound *sound, Video *video, uint8 sceneIdx): _screen(screen), _sound(sound), _video(video) {
_sceneIdx = sceneIdx;
_sceneResource = new SceneResource;
@@ -51,6 +51,8 @@ Scene::Scene(Screen *screen, Sound *sound, uint8 sceneIdx): _screen(screen), _so
sprintf(musPackFileName, "mus.%03d", sceneIdx);
_musPack = new ResourcePack(musPackFileName);
_bgResource = new GraphicResource(_resPack, _sceneResource->getWorldStats()->commonRes.backgroundImage);
+
+ _blowUp = 0;
}
_cursorResource = new GraphicResource(_resPack, _sceneResource->getWorldStats()->commonRes.curMagnifyingGlass);
@@ -77,6 +79,7 @@ Scene::~Scene() {
delete _resPack;
delete _text;
delete _sceneResource;
+ delete _blowUp;
}
void Scene::enterScene() {
diff --git a/engines/asylum/scene.h b/engines/asylum/scene.h
index 65d03a5979..b3ef253566 100644
--- a/engines/asylum/scene.h
+++ b/engines/asylum/scene.h
@@ -38,14 +38,16 @@ namespace Asylum {
class Screen;
class Sound;
+class Video;
class Text;
class SceneResource;
+class BlowUpPuzzle;
struct ActionDefinitions;
struct PolyDefinitions;
class Scene {
public:
- Scene(Screen *screen, Sound *sound, uint8 sceneIdx);
+ Scene(Screen *screen, Sound *sound, Video *video, uint8 sceneIdx);
~Scene();
void handleEvent(Common::Event *event, bool doUpdate);
@@ -70,6 +72,13 @@ public:
ResourcePack* getResourcePack() { return _resPack; }
ResourcePack* getResourceMusicPack() { return _musPack; }
GraphicResource* getGraphicResource(uint32 entry) { return new GraphicResource(_resPack, entry); }
+
+ BlowUpPuzzle* getBlowUpPuzzle() { return _blowUp; }
+ void setBlowUpPuzzle(BlowUpPuzzle* puzzle) { _blowUp = puzzle; }
+
+ Screen* getScreen() { return _screen; }
+ Sound* getSound() { return _sound; }
+ Video* getVideo() { return _video; }
private:
#if 0
@@ -85,6 +94,8 @@ private:
Screen *_screen;
Sound *_sound;
+ Video *_video;
+ BlowUpPuzzle *_blowUp;
Common::Event *_ev;
Text *_text;
diff --git a/engines/asylum/scriptman.cpp b/engines/asylum/scriptman.cpp
index f843a1dfc4..2eaa5b7425 100644
--- a/engines/asylum/scriptman.cpp
+++ b/engines/asylum/scriptman.cpp
@@ -329,7 +329,8 @@ void ScriptManager::processActionList() {
/* 0x36 */ //case k_unk36:
/* 0x37 */ case kRunBlowUpPuzzle: {
int blowUpPuzzleIdx = currentCommand.param1;
- // TODO: do proper blow up puzzle initialization
+ _scene->setBlowUpPuzzle(new BlowUpPuzzleVCR(_scene));
+ _scene->getBlowUpPuzzle()->openBlowUp();
}
break;
Commit: f63ccbf79ab6c70f3dc55022dc25bc1b92c9b48a
https://github.com/scummvm/scummvm/commit/f63ccbf79ab6c70f3dc55022dc25bc1b92c9b48a
Author: Alexandre Fontoura (alexandrefontoura at gmail.com)
Date: 2021-05-17T15:35:39+02:00
Commit Message:
ASYLUM: Implementation of dew little commands. Change some command names.
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@287 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/screen.cpp
engines/asylum/screen.h
engines/asylum/scriptman.cpp
engines/asylum/scriptman.h
diff --git a/engines/asylum/screen.cpp b/engines/asylum/screen.cpp
index 675cfdc16f..6db6e17d78 100644
--- a/engines/asylum/screen.cpp
+++ b/engines/asylum/screen.cpp
@@ -110,4 +110,8 @@ void Screen::drawWideScreen(int16 barSize) {
}
}
+void Screen::clearScreen() {
+ _sys->fillScreen(0);
+}
+
} // end of namespace Asylum
diff --git a/engines/asylum/screen.h b/engines/asylum/screen.h
index daeee991ff..826f8f6c2d 100644
--- a/engines/asylum/screen.h
+++ b/engines/asylum/screen.h
@@ -48,6 +48,7 @@ public:
void setPalette(byte *rgbPalette);
void setPalette(ResourcePack *resPack, int entry) { setPalette(resPack->getResource(entry)->data + 32); }
void drawWideScreen(int16 barSize);
+ void clearScreen();
void showCursor() { _sys->showMouse(true); }
void hideCursor() { _sys->showMouse(false); }
diff --git a/engines/asylum/scriptman.cpp b/engines/asylum/scriptman.cpp
index 2eaa5b7425..fb2726c787 100644
--- a/engines/asylum/scriptman.cpp
+++ b/engines/asylum/scriptman.cpp
@@ -97,6 +97,7 @@ void ScriptManager::processActionList() {
// TODO - processActionLists has run too many iterations
}
+ // TODO: this should be a pointer to allow changes in commands array
ActionCommand currentCommand = _currentScript->commands[_currentLine];
switch (currentCommand.opcode) {
@@ -318,12 +319,19 @@ void ScriptManager::processActionList() {
_delayedVideoIndex = currentCommand.param1;
break;
-/* 0x2E */ //case kStopAllObjectsSounds:
+/* 0x2E */ case kStopAllBarriersSounds:
+ // TODO: do this for all barriers that have sfx playing
+ _scene->_sound->stopSfx();
+ break;
+
/* 0x2F */ //case kSetActionFlag01:
/* 0x30 */ //case kClearActionFlag01:
/* 0x31 */ //case kResetSceneRect:
/* 0x32 */ //case kChangeMusicById:
-/* 0x33 */ //case kStopMusic:
+/* 0x33 */ case kStopMusic:
+ _scene->_sound->stopMusic();
+ break;
+
/* 0x34 */ //case k_unk34_Status:
/* 0x35 */ //case k_unk35:
/* 0x36 */ //case k_unk36:
@@ -361,13 +369,23 @@ void ScriptManager::processActionList() {
}
break;
-/* 0x3E */ //case kUpdateMatteBars:
+/* 0x3E */ case kUpdateWideScreen: {
+ int barSize = currentCommand.param1;
+ if(barSize >= 22) {
+ currentCommand.param1 = 0;
+ } else {
+ _scene->_screen->drawWideScreen(4 * barSize);
+ currentCommand.param1++;
+ }
+ }
+ break;
+
/* 0x3F */ //case k_unk3F:
/* 0x40 */ //case k_unk40_SOUND:
/* 0x41 */ case kPlaySpeech: {
// TODO - Add support for other param options
uint32 sndIdx = currentCommand.param1;
- if ((int)currentCommand.param1 >= 0) {
+ if ((int)sndIdx >= 0) {
if (sndIdx >= 259) {
sndIdx -= 9;
_scene->_sound->playSfx(_scene->_speechPack, sndIdx - 0x7FFD0000);
@@ -394,10 +412,26 @@ void ScriptManager::processActionList() {
/* 0x49 */ //case k_unk49_MATTE_90:
/* 0x4A */ //case kJumpIfSoundPlaying:
/* 0x4B */ //case kChangePlayerCharacterIndex:
-/* 0x4C */ //case kChangeActorField40:
+/* 0x4C */ case kChangeActorField40: { // TODO: figure out what is this field and what values are set
+ int actorIdx = currentCommand.param1;
+ int fieldType = currentCommand.param2;
+ if(fieldType) {
+ if(_scene->getResources()->getWorldStats()->actors[actorIdx].field_40 < 11) {
+ _scene->getResources()->getWorldStats()->actors[actorIdx].field_40 = 14;
+ }
+ } else {
+ _scene->getResources()->getWorldStats()->actors[actorIdx].field_40 = 4;
+ }
+ }
+ break;
/* 0x4D */ //case kStopSound:
/* 0x4E */ //case k_unk4E_RANDOM_COMMAND:
-/* 0x4F */ //case kDrawGame:
+/* 0x4F */ case kClearScreen:
+ if(currentCommand.param1) {
+ _scene->_screen->clearScreen();
+ }
+ break;
+
/* 0x50 */ //case kQuit:
/* 0x51 */ //case kJumpObjectFrame:
/* 0x52 */ //case k_unk52:
diff --git a/engines/asylum/scriptman.h b/engines/asylum/scriptman.h
index ad03f5346a..b1f613b1ee 100644
--- a/engines/asylum/scriptman.h
+++ b/engines/asylum/scriptman.h
@@ -130,7 +130,7 @@ enum opcodes {
kChangeScene,
k_unk2C_ActorSub,
kPlayMovie,
- kStopAllObjectsSounds,
+ kStopAllBarriersSounds,
kSetActionFlag01,
kClearActionFlag01, // 0x30
kResetSceneRect,
@@ -146,7 +146,7 @@ enum opcodes {
k_unk3B_PALETTE_MOD,
k_unk3C_CMP_VAL,
kWaitUntilFramePlayed,
- kUpdateMatteBars,
+ kUpdateWideScreen,
k_unk3F,
k_unk40_SOUND, // 0x40
kPlaySpeech,
@@ -163,7 +163,7 @@ enum opcodes {
kChangeActorField40,
kStopSound,
k_unk4E_RANDOM_COMMAND,
- kDrawGame,
+ kClearScreen,
kQuit, // 0x50
kJumpObjectFrame,
k_unk52,
Commit: 1769959bf8892ef701f3f03ce6eb99d7a56aee2c
https://github.com/scummvm/scummvm/commit/1769959bf8892ef701f3f03ce6eb99d7a56aee2c
Author: Alex Bevilacqua (alexbevi at gmail.com)
Date: 2021-05-17T15:35:39+02:00
Commit Message:
ASYLUM: * A little work on Encounters (not much)
* The beginnings of actor pathfinding
* Created a new singleton called Utils (utilities.cpp/h). Need feedback as to whether or not we should use this as the common container for objects we only ever need to instantiate once (like screen, sound, video .. etc).
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@288 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
A engines/asylum/utilities.cpp
A engines/asylum/utilities.h
engines/asylum/actor.cpp
engines/asylum/actor.h
engines/asylum/asylum.cpp
engines/asylum/asylum.h
engines/asylum/encounters.cpp
engines/asylum/encounters.h
engines/asylum/module.mk
engines/asylum/scene.cpp
engines/asylum/scene.h
engines/asylum/sceneres.cpp
engines/asylum/sceneres.h
diff --git a/engines/asylum/actor.cpp b/engines/asylum/actor.cpp
index 815ddf405f..38517a89de 100644
--- a/engines/asylum/actor.cpp
+++ b/engines/asylum/actor.cpp
@@ -23,10 +23,11 @@
*
*/
+#include "common/endian.h"
+
#include "asylum/actor.h"
#include "asylum/screen.h"
-
-#include "common/endian.h"
+#include "asylum/utilities.h"
namespace Asylum {
@@ -129,52 +130,79 @@ void MainActor::drawActor(Screen *screen) {
frame->surface.h );
}
-void MainActor::walkTo(Screen *screen, uint16 x, uint16 y) {
+void MainActor::walkTo(Screen *screen, uint16 x, uint16 y, PolyDefinitions *region) {
// TODO: pathfinding! The character can walk literally anywhere
int newAction = _currentAction;
+ // step is the increment by which to move the
+ // actor in a given direction
+ int step = 2;
+
+ uint16 newX = _actorX;
+ uint16 newY = _actorY;
+ bool done = false;
// Walking left...
if (x < _actorX) {
newAction = kWalkW;
- _actorX-=2;
- if (ABS(y - _actorY) <= 30) {
- setAction(newAction);
- drawActor(screen);
- return;
- }
+ newX -= step;
+ if (ABS(y - _actorY) <= 30)
+ done = true;
}
// Walking right...
if (x > _actorX) {
newAction = kWalkE;
- _actorX+=2;
- if (ABS(y - _actorY) <= 30) {
- setAction(newAction);
- drawActor(screen);
- return;
- }
+ newX += step;
+ if (ABS(y - _actorY) <= 30)
+ done = true;
}
// Walking up...
- if (y < _actorY) {
+ if (y < _actorY && !done) {
if (newAction != _currentAction && newAction == kWalkW && _actorX - x > 30)
newAction = kWalkNW; // up left
else if (newAction != _currentAction && newAction == kWalkE && x - _actorX > 30)
newAction = kWalkNE; // up right
else
newAction = kWalkN;
- _actorY-=2;
+
+ newY -= step;
}
// Walking down...
- if (y > _actorY) {
+ if (y > _actorY && !done) {
if (newAction != _currentAction && newAction == kWalkW && _actorX - x > 30)
newAction = kWalkSW; // down left
else if (newAction != _currentAction && newAction == kWalkE && x - _actorX > 30)
newAction = kWalkSE; // down right
else
newAction = kWalkS;
- _actorY+=2;
+
+ newY += step;
+ }
+
+ // DEBUGGING
+ // Show registration point from
+ // which we're calculating the
+ // actor's barrier hit-test
+ Graphics::Surface surface;
+ surface.create(5, 5, 1);
+ Common::Rect rect;
+
+ rect.top = newY;
+ rect.left = newX;
+ rect.right = newX;
+ rect.bottom = newY + 4;
+ surface.frameRect(rect, 0x33);
+
+ screen->copyRectToScreen((byte*)surface.pixels, 5, newX, newY, 5, 5);
+
+ surface.free();
+
+
+ if (Utils.pointInPoly(region, newX, newY)) {
+ _actorX = newX;
+ _actorY = newY;
}
setAction(newAction);
diff --git a/engines/asylum/actor.h b/engines/asylum/actor.h
index 3e3fac9613..cfb4e89ccf 100644
--- a/engines/asylum/actor.h
+++ b/engines/asylum/actor.h
@@ -32,6 +32,7 @@
namespace Asylum {
class Screen;
+struct PolyDefinitions;
// TODO properly use this enum as opposed to just
// using it for visual reference :P
@@ -137,7 +138,7 @@ public:
void setActionByIndex(int index);
void drawActorAt(Screen *screen, uint16 x, uint16 y);
void drawActor(Screen *screen);
- void walkTo(Screen *screen, uint16 x, uint16 y);
+ void walkTo(Screen *screen, uint16 x, uint16 y, PolyDefinitions *region);
int getCurrentAction() { return _currentAction; }
uint16 _actorX, _actorY;
diff --git a/engines/asylum/asylum.cpp b/engines/asylum/asylum.cpp
index 912e88a16f..b42369e45c 100644
--- a/engines/asylum/asylum.cpp
+++ b/engines/asylum/asylum.cpp
@@ -62,6 +62,7 @@ AsylumEngine::~AsylumEngine() {
delete _video;
delete _sound;
delete _screen;
+ delete _encounter;
}
Common::Error AsylumEngine::run() {
@@ -115,6 +116,10 @@ Common::Error AsylumEngine::go() {
// Set up main menu
_mainMenu = new MainMenu(_screen, _sound, _scene);
+
+ // XXX Testing
+ _encounter = new Encounter(_scene);
+
// Enter first scene
_scene->enterScene();
@@ -157,6 +162,11 @@ void AsylumEngine::checkForEvent(bool doUpdate) {
return;
}
+ // XXX Encounter TEST
+ if (ev.kbd.keycode == Common::KEYCODE_e) {
+ _encounter->run(1, 1584, 1584, 0);
+ }
+
// FIXME: TEST ONLY
if (ev.kbd.keycode == Common::KEYCODE_b) {
//_mainMenu->closeMenu();
diff --git a/engines/asylum/asylum.h b/engines/asylum/asylum.h
index 631a969c7f..d29ff6bf5a 100644
--- a/engines/asylum/asylum.h
+++ b/engines/asylum/asylum.h
@@ -36,6 +36,7 @@
#include "asylum/video.h"
#include "asylum/scriptman.h"
#include "asylum/blowuppuzzle.h"
+#include "asylum/encounters.h"
namespace Asylum {
@@ -46,6 +47,7 @@ class Scene;
class Screen;
class Sound;
class Video;
+class Encounter;
enum kDebugLevels {
kDebugLevelMain = 1 << 0,
@@ -79,12 +81,13 @@ private:
Common::Language _language;
Common::RandomSource _rnd;
- Console *_console;
- Scene *_scene;
- MainMenu *_mainMenu;
- Screen *_screen;
- Sound *_sound;
- Video *_video;
+ Console *_console;
+ Scene *_scene;
+ MainMenu *_mainMenu;
+ Screen *_screen;
+ Sound *_sound;
+ Video *_video;
+ Encounter *_encounter;
friend class Console;
};
diff --git a/engines/asylum/encounters.cpp b/engines/asylum/encounters.cpp
index e6cb509901..de105d6bb8 100644
--- a/engines/asylum/encounters.cpp
+++ b/engines/asylum/encounters.cpp
@@ -29,7 +29,7 @@
namespace Asylum {
-Encounter::Encounter() {
+Encounter::Encounter(Scene *scene) {
Common::File file;
// TODO error checks
@@ -63,10 +63,71 @@ Encounter::Encounter() {
}
file.close();
+
+ _scene = scene;
+}
+
+void Encounter::run(int encounterIdx, int barrierId1, int barrierId2, int characterIdx) {
+ // Line: 12/15 :: 0x25 (1, 1584, 1584, 0, 0, 0, 0, 0, 0) // First Encounter
+
+ //debugC(kDebugLevelEncounter, "Running Encounter %d", encounterIdx);
+
+ _currentEncounter = &_items[encounterIdx];
+ setVariable(1, 0);
+ setVariable(2, _currentEncounter->value);
+
+ BarrierItem *b1 = _scene->getResources()->getBarrierById(barrierId1);
+/*
+ int __cdecl runEncounter(int newMessageHandler, int encounterIndex, int objectId1, int objectId2, int characterIndex)
+{
+ int result; // eax at 7
+ EncounterItem *v6; // eax at 2
+ int v7; // ST04_4 at 4
+ int v8; // eax at 4
+
+ if ( !encounterKeywordIndex )
+ {
+ v6 = getEncounterItem(0);
+ encounterItem = v6;
+ encounterKeywordIndex = *(_DWORD *)&v6->keywordIndex;
+ }
+ if ( encounterIndex < 0 )
+ {
+ result = 0;
+ }
+ else
+ {
+ encounter_newMessageHandler = newMessageHandler;
+ encounterIndex = encounterIndex;
+ encounterItem = getEncounterItem(encounterIndex);
+ encounter_objectId01 = objectId1;
+ v7 = characterIndex;
+ encounter_objectId02 = objectId2;
+ characterIndex2 = characterIndex;
+ v8 = getObjectIndexById(objectId2);
+ object_sound_sub_414C30(v8, v7);
+ setEncounterVariable(1, 0);
+ setEncounterVariable(2, encounterItem->value);
+ if ( scene.characters[playerCharacterIndex].field_40 == 5 )
+ {
+ encounter_flag02 = 1;
+ }
+ else
+ {
+ encounter_flag02 = 0;
+ character_sub_4072A0(playerCharacterIndex, 5);
+ }
+ flag04 = 0;
+ switchMessageHandler((int (__cdecl *)(_DWORD, _DWORD, _DWORD))handleMessageEncounter);
+ result = 1;
+ }
+ return result;
+}
+ */
}
Encounter::~Encounter() {
- // TODO Auto-generated destructor stub
+ free(_variables);
}
}
diff --git a/engines/asylum/encounters.h b/engines/asylum/encounters.h
index 7c89970909..1f0dd1c753 100644
--- a/engines/asylum/encounters.h
+++ b/engines/asylum/encounters.h
@@ -27,6 +27,7 @@
#define ASYLUM_ENCOUNTERS_H_
#include "common/array.h"
+#include "asylum/scene.h"
namespace Asylum {
@@ -51,13 +52,19 @@ typedef struct EncounterStruct {
class Encounter {
public:
- Encounter();
+ Encounter(Scene *scene);
virtual ~Encounter();
+ void setVariable(int idx, int value) { _variables[idx] = value; }
+ void run(int encounterIdx, int barrierId1, int barrierId2, int characterIdx);
+
private:
uint16 *_variables;
uint16 _anvilStyleFlag;
+
+ EncounterItem *_currentEncounter;
Common::Array<EncounterItem> _items;
+ Scene *_scene;
}; // end of class Encounter
diff --git a/engines/asylum/module.mk b/engines/asylum/module.mk
index 58a497e5ad..06c57d541a 100644
--- a/engines/asylum/module.mk
+++ b/engines/asylum/module.mk
@@ -16,7 +16,8 @@ MODULE_OBJS := \
actor.o \
encounters.o \
scriptman.o \
- blowuppuzzle.o
+ blowuppuzzle.o \
+ utilities.o
# This module can be built as a plugin
ifeq ($(ENABLE_ASYLUM), DYNAMIC_PLUGIN)
diff --git a/engines/asylum/scene.cpp b/engines/asylum/scene.cpp
index 678fec5c94..87b217cba2 100644
--- a/engines/asylum/scene.cpp
+++ b/engines/asylum/scene.cpp
@@ -25,6 +25,7 @@
#include "asylum/scene.h"
#include "asylum/sceneres.h"
+#include "asylum/utilities.h"
namespace Asylum {
@@ -98,6 +99,7 @@ void Scene::enterScene() {
_sound->playMusic(_musPack, 0);
_isActive = true;
+ _walking = false;
}
ActionDefinitions* Scene::getDefaultActionList() {
@@ -299,13 +301,41 @@ void Scene::update() {
updateBarrier(_screen, _resPack, b);
}
+ // DEBUGGING
+ // Check current walk region
+ PolyDefinitions currentWalkRegion;
+
+ for (uint32 a = 0; a < worldStats->numActions; a++) {
+ if (worldStats->actions[a].actionType == 0) {
+ PolyDefinitions poly = _sceneResource->getGamePolygons()->polygons[worldStats->actions[a].polyIdx];
+ if (Utils.pointInPoly(&poly, mainActor->_actorX, mainActor->_actorY)) {
+ debugShowWalkRegion(&poly);
+ currentWalkRegion = poly;
+ break;
+ }
+ }
+ }
+
+
// TESTING
// Main actor walking
if (!_rightButton) {
- if (_sceneResource->getWorldStats()->actors[0].flags & 0x01) // TESTING - only draw if visible flag
+ if (_sceneResource->getWorldStats()->actors[0].flags & 0x01) { // TESTING - only draw if visible flag
+ // Check if the character was walking before the right-button
+ // was released. If so, change the resource to one where he/she
+ // is standing still, facing the last active direction
+ if (_walking) {
+ int currentAction = mainActor->getCurrentAction();
+ if (currentAction > 0)
+ mainActor->setAction(currentAction + 5);
+ _walking = false;
+ }
mainActor->drawActor(_screen);
+ }
} else {
- mainActor->walkTo(_screen, _mouseX, _mouseY);
+ _walking = true;
+
+ mainActor->walkTo(_screen, _mouseX, _mouseY, ¤tWalkRegion);
updateCursor();
}
@@ -318,7 +348,10 @@ void Scene::update() {
for (uint32 p = 0; p < worldStats->numBarriers; p++) {
BarrierItem b = worldStats->barriers[p];
if (b.flags & 0x20) {
- if ((b.boundingRect.left + b.x <= _mouseX + _startX) && (_mouseX + _startX < b.boundingRect.right + b.x) && (b.boundingRect.top + b.y <= _mouseY + _startY) && (_mouseY + _startY < b.boundingRect.bottom + b.y)) {
+ if ((b.boundingRect.left + b.x <= _mouseX + _startX) &&
+ (_mouseX + _startX < b.boundingRect.right + b.x) &&
+ (b.boundingRect.top + b.y <= _mouseY + _startY) &&
+ (_mouseY + _startY < b.boundingRect.bottom + b.y)) {
animateCursor();
curBarrier = (int32)p;
break;
@@ -336,7 +369,7 @@ void Scene::update() {
for (uint32 p = 0; p < _sceneResource->getGamePolygons()->numEntries; p++) {
PolyDefinitions poly = _sceneResource->getGamePolygons()->polygons[p];
if (poly.boundingRect.contains(_mouseX + _startX, _mouseY + _startY)) {
- if (pointInPoly(&poly, _mouseX + _startX, _mouseY + _startY)) {
+ if (Utils.pointInPoly(&poly, _mouseX + _startX, _mouseY + _startY)) {
curHotspot = (int32)p;
animateCursor();
break;
@@ -345,18 +378,6 @@ void Scene::update() {
}
}
- // DEBUGGING
- // Check current walk region
- for (uint32 a = 0; a < worldStats->numActions; a++) {
- if (worldStats->actions[a].actionType == 0) {
- PolyDefinitions poly = _sceneResource->getGamePolygons()->polygons[worldStats->actions[a].polyIdx];
- if (pointInPoly(&poly, mainActor->_actorX, mainActor->_actorY)) {
- debugShowWalkRegion(&poly);
- break;
- }
- }
- }
-
if (_leftClick) {
_leftClick = false;
@@ -458,32 +479,6 @@ void Scene::updateBarrier(Screen *screen, ResourcePack *res, uint8 barrierIndex)
delete gra;
}
-bool Scene::pointInPoly(PolyDefinitions *poly, int x, int y) {
- // Copied from backends/vkeybd/polygon.cpp
- int yflag0;
- int yflag1;
- bool inside_flag = false;
- unsigned int pt;
-
- Common::Point *vtx0 = &poly->points[poly->numPoints - 1];
- Common::Point *vtx1 = &poly->points[0];
-
- yflag0 = (vtx0->y >= y);
- for (pt = 0; pt < poly->numPoints; pt++, vtx1++) {
- yflag1 = (vtx1->y >= y);
- if (yflag0 != yflag1) {
- if (((vtx1->y - y) * (vtx0->x - vtx1->x) >=
- (vtx1->x - x) * (vtx0->y - vtx1->y)) == yflag1) {
- inside_flag = !inside_flag;
- }
- }
- yflag0 = yflag1;
- vtx0 = vtx1;
- }
-
- return inside_flag;
-}
-
void Scene::debugScreenScrolling(GraphicFrame *bg) {
// Horizontal scrolling
if (_mouseX < SCREEN_EDGES && _startX >= SCROLL_STEP)
diff --git a/engines/asylum/scene.h b/engines/asylum/scene.h
index b3ef253566..eba2a422bf 100644
--- a/engines/asylum/scene.h
+++ b/engines/asylum/scene.h
@@ -60,7 +60,7 @@ public:
ActionDefinitions* getDefaultActionList();
ActionDefinitions* getActionList(int actionListIndex);
-
+
void setActorPosition(int actorIndex, int x, int y);
void setActorAction(int actorIndex, int action);
void actorVisible(int actorIndex, bool visible);
@@ -103,6 +103,7 @@ private:
GraphicResource *_cursorResource;
GraphicFrame *_background;
+ bool _walking;
uint32 _mouseX;
uint32 _mouseY;
int32 _startX;
@@ -133,7 +134,6 @@ private:
void debugShowPolygons();
void debugShowBarriers();
void debugShowWalkRegion(PolyDefinitions *poly);
- bool pointInPoly(PolyDefinitions *poly, int x, int y);
friend class ScriptManager;
}; // end of class Scene
diff --git a/engines/asylum/sceneres.cpp b/engines/asylum/sceneres.cpp
index 9729c49c9f..a4b379e1cb 100644
--- a/engines/asylum/sceneres.cpp
+++ b/engines/asylum/sceneres.cpp
@@ -48,6 +48,10 @@ int SceneResource::getBarrierIndexById(uint32 id) {
return -1;
}
+BarrierItem* SceneResource::getBarrierById(uint32 id) {
+ return &_worldStats->barriers[getBarrierIndexById(id)];
+}
+
bool SceneResource::load(uint8 sceneIdx) {
char sceneTag[6];
Common::File* fd = new Common::File;
diff --git a/engines/asylum/sceneres.h b/engines/asylum/sceneres.h
index 0528de1c9e..5830865859 100644
--- a/engines/asylum/sceneres.h
+++ b/engines/asylum/sceneres.h
@@ -44,6 +44,7 @@ class AsylumEngine;
class WorldStats;
class GamePolygons;
class ActionList;
+struct BarrierItem;
#if 0
// TODO/FIXME: Are there REALLY any points which go beyond 32768???
@@ -71,6 +72,7 @@ public:
MainActor* getMainActor() { return _mainActor; }
int getBarrierIndexById(uint32 id);
+ BarrierItem* getBarrierById(uint32 id);
private:
diff --git a/engines/asylum/utilities.cpp b/engines/asylum/utilities.cpp
new file mode 100644
index 0000000000..5afdf84d05
--- /dev/null
+++ b/engines/asylum/utilities.cpp
@@ -0,0 +1,73 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#include "asylum/utilities.h"
+
+#include "common/system.h"
+
+DECLARE_SINGLETON(Asylum::Utilities);
+
+namespace Asylum {
+
+static bool g_initialized = false;
+
+Utilities::Utilities() {
+ if (!g_initialized) {
+ g_initialized = true;
+ }
+
+}
+
+Utilities::~Utilities() {
+ g_initialized = false;
+}
+
+bool Utilities::pointInPoly(PolyDefinitions *poly, int x, int y) {
+ // Copied from backends/vkeybd/polygon.cpp
+ int yflag0;
+ int yflag1;
+ bool inside_flag = false;
+ unsigned int pt;
+
+ Common::Point *vtx0 = &poly->points[poly->numPoints - 1];
+ Common::Point *vtx1 = &poly->points[0];
+
+ yflag0 = (vtx0->y >= y);
+ for (pt = 0; pt < poly->numPoints; pt++, vtx1++) {
+ yflag1 = (vtx1->y >= y);
+ if (yflag0 != yflag1) {
+ if (((vtx1->y - y) * (vtx0->x - vtx1->x) >=
+ (vtx1->x - x) * (vtx0->y - vtx1->y)) == yflag1) {
+ inside_flag = !inside_flag;
+ }
+ }
+ yflag0 = yflag1;
+ vtx0 = vtx1;
+ }
+
+ return inside_flag;
+}
+
+} // end of namespace Asylum
diff --git a/engines/asylum/utilities.h b/engines/asylum/utilities.h
new file mode 100644
index 0000000000..2c7d5b39a1
--- /dev/null
+++ b/engines/asylum/utilities.h
@@ -0,0 +1,49 @@
+/* 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.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#ifndef ASYLUM_UTILITIES_H_
+#define ASYLUM_UTILITIES_H_
+
+#include "common/singleton.h"
+
+#include "asylum/sceneres.h"
+
+namespace Asylum {
+
+class Utilities: public Common::Singleton<Utilities> {
+public:
+ bool pointInPoly(PolyDefinitions *poly, int x, int y);
+
+private:
+ friend class Common::Singleton<SingletonBaseType>;
+ Utilities();
+ ~Utilities();
+}; // end of class Utilities
+
+#define Utils (::Asylum::Utilities::instance())
+
+} // end of namespace Asylum
+
+#endif
Commit: 03e46ac514bfae3b90bfb41adb07adf09776553f
https://github.com/scummvm/scummvm/commit/03e46ac514bfae3b90bfb41adb07adf09776553f
Author: Alexandre Fontoura (alexandrefontoura at gmail.com)
Date: 2021-05-17T15:35:40+02:00
Commit Message:
ASYLUM: Minor update in Video file to allow displaying subtitles with special characters like "ã á ç é Ã, etc.".
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@289 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/video.cpp
diff --git a/engines/asylum/video.cpp b/engines/asylum/video.cpp
index 7f54ad72eb..87f02df024 100644
--- a/engines/asylum/video.cpp
+++ b/engines/asylum/video.cpp
@@ -227,7 +227,7 @@ uint32 VideoText::getTextWidth(const char *text) {
void VideoText::drawText(byte *screenBuffer, int x, int y, const char *text) {
assert (_fontResource);
- const char *curChar = text;
+ const byte *curChar = (byte *)text;
int curX = x;
while (*curChar) {
Commit: b3d7287a2fdca3d7d41ff321bb5ab4149de91c6d
https://github.com/scummvm/scummvm/commit/b3d7287a2fdca3d7d41ff321bb5ab4149de91c6d
Author: Alexandre Fontoura (alexandrefontoura at gmail.com)
Date: 2021-05-17T15:35:40+02:00
Commit Message:
ASYLUM: ScriptManager command action variable is now a pointer, to allow some commands to override parameter values.
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@290 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/scriptman.cpp
diff --git a/engines/asylum/scriptman.cpp b/engines/asylum/scriptman.cpp
index fb2726c787..c82537d91c 100644
--- a/engines/asylum/scriptman.cpp
+++ b/engines/asylum/scriptman.cpp
@@ -98,9 +98,9 @@ void ScriptManager::processActionList() {
}
// TODO: this should be a pointer to allow changes in commands array
- ActionCommand currentCommand = _currentScript->commands[_currentLine];
+ ActionCommand *currentCommand = &_currentScript->commands[_currentLine];
- switch (currentCommand.opcode) {
+ switch (currentCommand->opcode) {
/* 0x00 */ case kReturn0:
done = true;
@@ -108,26 +108,26 @@ void ScriptManager::processActionList() {
break;
/* 0x01 */ case kSetGameFlag:
- setGameFlag(currentCommand.param1);
+ setGameFlag(currentCommand->param1);
break;
/* 0x02 */ case kClearGameFlag: {
- int flagNum = currentCommand.param1;
+ int flagNum = currentCommand->param1;
_gameFlags[flagNum] &= ~(1 << flagNum);
}
break;
/* 0x03 */ //case kToogleGameFlag:
/* 0x04 */ case kJumpIfGameFlag:
- if (currentCommand.param1) {
+ if (currentCommand->param1) {
bool doJump = false;
- if (currentCommand.param2)
- doJump = _gameFlags[currentCommand.param1] == 0;
+ if (currentCommand->param2)
+ doJump = _gameFlags[currentCommand->param1] == 0;
else
- doJump = _gameFlags[currentCommand.param1] != 0;
+ doJump = _gameFlags[currentCommand->param1] != 0;
if (doJump)
- _currentLine = currentCommand.param3;
+ _currentLine = currentCommand->param3;
}
break;
@@ -142,13 +142,13 @@ void ScriptManager::processActionList() {
break;
/* 0x07 */ case kPlayAnimation: {
- int barrierIndex = _scene->_sceneResource->getBarrierIndexById(currentCommand.param1);
+ int barrierIndex = _scene->_sceneResource->getBarrierIndexById(currentCommand->param1);
if (barrierIndex >= 0)
_scene->_sceneResource->getWorldStats()->barriers[barrierIndex].flags |= 0x20; // TODO - enums for flags (0x20 is visible/playing?)
else
debugC(kDebugLevelScripts,
"Requested invalid object ID:0x%02X in Scene %d Line %d.",
- currentCommand.param1,
+ currentCommand->param1,
_scene->getSceneIndex(),
_currentLine);
}
@@ -157,17 +157,17 @@ void ScriptManager::processActionList() {
/* 0x08 */ //case kMoveScenePosition:
/* 0x09 */ case kHideActor: {
uint32 actorIndex = 0;
- if (currentCommand.param1 == -1)
+ if (currentCommand->param1 == -1)
;//actorIndex = _scene->getWorldStats()->playerActor;
else
- actorIndex = currentCommand.param1;
+ actorIndex = currentCommand->param1;
if ((actorIndex >= 0) && (actorIndex < _scene->_sceneResource->getWorldStats()->numActors))
_scene->actorVisible(actorIndex, false);
else
debugC(kDebugLevelScripts,
"Requested invalid actor ID:0x%02X in Scene %d Line %d.",
- currentCommand.param1,
+ currentCommand->param1,
_scene->getSceneIndex(),
_currentLine);
}
@@ -175,17 +175,17 @@ void ScriptManager::processActionList() {
/* 0x0A */ case kShowActor: {
uint32 actorIndex = 0;
- if (currentCommand.param1 == -1)
+ if (currentCommand->param1 == -1)
;//actorIndex = _scene->getWorldStats()->playerActor;
else
- actorIndex = currentCommand.param1;
+ actorIndex = currentCommand->param1;
if ((actorIndex >= 0) && (actorIndex < _scene->_sceneResource->getWorldStats()->numActors))
_scene->actorVisible(actorIndex, true);
else
debugC(kDebugLevelScripts,
"Requested invalid actor ID:0x%02X in Scene %d Line %d.",
- currentCommand.param1,
+ currentCommand->param1,
_scene->getSceneIndex(),
_currentLine);
}
@@ -193,19 +193,19 @@ void ScriptManager::processActionList() {
/* 0x0B */ case kSetActorStats: {
uint32 actorIndex = 0;
- if (currentCommand.param1 == -1)
+ if (currentCommand->param1 == -1)
;//actorIndex = _scene->getWorldStats()->playerActor;
else
- actorIndex = currentCommand.param1;
+ actorIndex = currentCommand->param1;
if ((actorIndex >= 0) && (actorIndex < _scene->_sceneResource->getWorldStats()->numActors)) {
- _scene->setActorPosition(actorIndex, currentCommand.param2, currentCommand.param3);
- _scene->setActorAction(actorIndex, currentCommand.param4);
+ _scene->setActorPosition(actorIndex, currentCommand->param2, currentCommand->param3);
+ _scene->setActorAction(actorIndex, currentCommand->param4);
}
else
debugC(kDebugLevelScripts,
"Requested invalid actor ID:0x%02X in Scene %d Script %d Line %d.",
- currentCommand.param1,
+ currentCommand->param1,
_scene->getSceneIndex(),
_currentLine);
}
@@ -215,10 +215,10 @@ void ScriptManager::processActionList() {
/* 0x0D */ //case kDisableActor:
/* 0x0E */ case kEnableActor: {
int actorIndex = 0;
- if (currentCommand.param1 == -1)
+ if (currentCommand->param1 == -1)
;//actorIndex = _scene->getWorldStats()->playerActor;
else
- actorIndex = currentCommand.param1;
+ actorIndex = currentCommand->param1;
if (_scene->_sceneResource->getWorldStats()->actors[actorIndex].field_40 == 5) {
enableActorSub(actorIndex, 4);
@@ -227,9 +227,9 @@ void ScriptManager::processActionList() {
break;
/* 0x0F */ case kEnableBarriers: {
- int barIdx = _scene->_sceneResource->getBarrierIndexById(currentCommand.param1);
- uint32 sndIdx = currentCommand.param3;
- uint32 v59 = currentCommand.param2;
+ int barIdx = _scene->_sceneResource->getBarrierIndexById(currentCommand->param1);
+ uint32 sndIdx = currentCommand->param3;
+ uint32 v59 = currentCommand->param2;
if (!_currentScript->counter && _scene->getSceneIndex() != 13 && sndIdx != 0) {
// TODO
@@ -243,7 +243,7 @@ void ScriptManager::processActionList() {
if (_currentScript->counter >= 3 * v59 - 1) {
_currentScript->counter = 0;
_scene->_sceneResource->getWorldStats()->barriers[barIdx].field_67C = 0;
- processActionListSub02(_currentScript, ¤tCommand, 2);
+ processActionListSub02(_currentScript, currentCommand, 2);
_currentLoops = 1; // v4 = 1;
} else {
int v64;
@@ -258,7 +258,7 @@ void ScriptManager::processActionList() {
_scene->_sceneResource->getWorldStats()->barriers[barIdx].field_67C = v62 / v59 + 1;
}
- processActionListSub02(_currentScript, ¤tCommand, v64);
+ processActionListSub02(_currentScript, currentCommand, v64);
}
}
@@ -270,13 +270,13 @@ void ScriptManager::processActionList() {
break;
/* 0x11 */ case kDestroyObject: {
- int barrierIndex = _scene->_sceneResource->getBarrierIndexById(currentCommand.param1);
+ int barrierIndex = _scene->_sceneResource->getBarrierIndexById(currentCommand->param1);
if (barrierIndex >= 0)
_scene->_sceneResource->getWorldStats()->barriers[barrierIndex].flags &= 0xFFFFDF; // TODO - enums for flags (0x20 is visible/playing?)
else
debugC(kDebugLevelScripts,
"Requested invalid object ID:0x%02X in Scene %d Line %d.",
- currentCommand.param1,
+ currentCommand->param1,
_scene->getSceneIndex(),
_currentLine);
}
@@ -308,15 +308,15 @@ void ScriptManager::processActionList() {
/* 0x29 */ //case kSetActorField638:
/* 0x2A */ //case kJumpIfActorField638:
/* 0x2B */ case kChangeScene:
- _delayedSceneIndex = currentCommand.param1 + 4;
+ _delayedSceneIndex = currentCommand->param1 + 4;
debug(kDebugLevelScripts,
"Queueing Scene Change to scene %d...",
- currentCommand.param1 + 4);
+ _delayedSceneIndex);
break;
/* 0x2C */ //case k_unk2C_ActorSub:
/* 0x2D */ case kPlayMovie:
- _delayedVideoIndex = currentCommand.param1;
+ _delayedVideoIndex = currentCommand->param1;
break;
/* 0x2E */ case kStopAllBarriersSounds:
@@ -336,7 +336,7 @@ void ScriptManager::processActionList() {
/* 0x35 */ //case k_unk35:
/* 0x36 */ //case k_unk36:
/* 0x37 */ case kRunBlowUpPuzzle: {
- int blowUpPuzzleIdx = currentCommand.param1;
+ int blowUpPuzzleIdx = currentCommand->param1;
_scene->setBlowUpPuzzle(new BlowUpPuzzleVCR(_scene));
_scene->getBlowUpPuzzle()->openBlowUp();
}
@@ -348,13 +348,13 @@ void ScriptManager::processActionList() {
/* 0x3B */ //case k_unk3B_PALETTE_MOD:
/* 0x3C */ //case k_unk3C_CMP_VAL:
/* 0x3D */ case kWaitUntilFramePlayed: {
- int barrierIndex = _scene->_sceneResource->getBarrierIndexById(currentCommand.param1);
+ int barrierIndex = _scene->_sceneResource->getBarrierIndexById(currentCommand->param1);
if (barrierIndex >= 0) {
uint32 frameNum = 0;
- if (currentCommand.param2 == -1)
+ if (currentCommand->param2 == -1)
frameNum = _scene->_sceneResource->getWorldStats()->barriers[barrierIndex].frameCount - 1;
else
- frameNum = currentCommand.param2;
+ frameNum = currentCommand->param2;
if (_scene->_sceneResource->getWorldStats()->barriers[barrierIndex].tickCount < frameNum) {
lineIncrement = 0;
@@ -363,19 +363,19 @@ void ScriptManager::processActionList() {
} else
debugC(kDebugLevelScripts,
"Requested invalid object ID:0x%02X in Scene %d Line %d.",
- currentCommand.param1,
+ currentCommand->param1,
_scene->getSceneIndex(),
_currentLine);
}
break;
/* 0x3E */ case kUpdateWideScreen: {
- int barSize = currentCommand.param1;
+ int barSize = currentCommand->param1;
if(barSize >= 22) {
- currentCommand.param1 = 0;
+ currentCommand->param1 = 0;
} else {
_scene->_screen->drawWideScreen(4 * barSize);
- currentCommand.param1++;
+ currentCommand->param1++;
}
}
break;
@@ -384,7 +384,7 @@ void ScriptManager::processActionList() {
/* 0x40 */ //case k_unk40_SOUND:
/* 0x41 */ case kPlaySpeech: {
// TODO - Add support for other param options
- uint32 sndIdx = currentCommand.param1;
+ uint32 sndIdx = currentCommand->param1;
if ((int)sndIdx >= 0) {
if (sndIdx >= 259) {
sndIdx -= 9;
@@ -396,7 +396,7 @@ void ScriptManager::processActionList() {
} else
debugC(kDebugLevelScripts,
"Requested invalid sound ID:0x%02X in Scene %d Line %d.",
- currentCommand.param1,
+ currentCommand->param1,
_scene->getSceneIndex(),
_currentLine);
}
@@ -413,8 +413,8 @@ void ScriptManager::processActionList() {
/* 0x4A */ //case kJumpIfSoundPlaying:
/* 0x4B */ //case kChangePlayerCharacterIndex:
/* 0x4C */ case kChangeActorField40: { // TODO: figure out what is this field and what values are set
- int actorIdx = currentCommand.param1;
- int fieldType = currentCommand.param2;
+ int actorIdx = currentCommand->param1;
+ int fieldType = currentCommand->param2;
if(fieldType) {
if(_scene->getResources()->getWorldStats()->actors[actorIdx].field_40 < 11) {
_scene->getResources()->getWorldStats()->actors[actorIdx].field_40 = 14;
@@ -427,7 +427,7 @@ void ScriptManager::processActionList() {
/* 0x4D */ //case kStopSound:
/* 0x4E */ //case k_unk4E_RANDOM_COMMAND:
/* 0x4F */ case kClearScreen:
- if(currentCommand.param1) {
+ if(currentCommand->param1) {
_scene->_screen->clearScreen();
}
break;
@@ -455,7 +455,7 @@ void ScriptManager::processActionList() {
default:
debugC(kDebugLevelScripts,
"Unhandled opcode 0x%02X in Scene %d Line %d.",
- currentCommand.opcode,
+ currentCommand->opcode,
_scene->getSceneIndex(),
_currentLine);
break;
Commit: 04c2840c49a31270cd4320d869c691fe24993eeb
https://github.com/scummvm/scummvm/commit/04c2840c49a31270cd4320d869c691fe24993eeb
Author: Alexandre Fontoura (alexandrefontoura at gmail.com)
Date: 2021-05-17T15:35:40+02:00
Commit Message:
ASYLUM: Fixed GameFlag related commands in script.
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@291 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/scriptman.cpp
engines/asylum/scriptman.h
diff --git a/engines/asylum/scriptman.cpp b/engines/asylum/scriptman.cpp
index c82537d91c..b862bd1aff 100644
--- a/engines/asylum/scriptman.cpp
+++ b/engines/asylum/scriptman.cpp
@@ -80,7 +80,23 @@ void ScriptManager::setScriptIndex(uint32 index) {
}
void ScriptManager::setGameFlag(int flag) {
- _gameFlags[flag] &= ~(1 << flag);
+ _gameFlags[flag / 32] |= 1 << flag % -32;
+}
+
+void ScriptManager::clearGameFlag(int flag) {
+ _gameFlags[flag / 32] &= ~(1 << flag % -32);
+}
+
+void ScriptManager::toggleGameFlag(int flag) {
+ _gameFlags[flag / 32] ^= 1 << flag % -32;
+}
+
+bool ScriptManager::isGameFlagSet(int flag) {
+ return ((1 << flag % -32) & (unsigned int)_gameFlags[flag / 32]) >> flag % -32 != 0;
+}
+
+bool ScriptManager::isGameFlagNotSet(int flag) {
+ return ((1 << flag % -32) & (unsigned int)_gameFlags[flag / 32]) >> flag % -32 == 0;
}
void ScriptManager::processActionList() {
@@ -107,28 +123,37 @@ void ScriptManager::processActionList() {
lineIncrement = 0;
break;
-/* 0x01 */ case kSetGameFlag:
- setGameFlag(currentCommand->param1);
+/* 0x01 */ case kSetGameFlag: {
+ int flagNum = currentCommand->param1;
+ if(flagNum >= 0)
+ setGameFlag(currentCommand->param1);
+ }
break;
/* 0x02 */ case kClearGameFlag: {
int flagNum = currentCommand->param1;
- _gameFlags[flagNum] &= ~(1 << flagNum);
+ if(flagNum >= 0)
+ clearGameFlag(currentCommand->param1);
}
break;
-/* 0x03 */ //case kToogleGameFlag:
-/* 0x04 */ case kJumpIfGameFlag:
- if (currentCommand->param1) {
- bool doJump = false;
+/* 0x03 */ case kToogleGameFlag: {
+ int flagNum = currentCommand->param1;
+ if(flagNum >= 0)
+ toggleGameFlag(currentCommand->param1);
+ }
+ break;
+/* 0x04 */ case kJumpIfGameFlag: {
+ int flagNum = currentCommand->param1;
+ if (flagNum) {
+ bool doJump = isGameFlagNotSet(flagNum);
if (currentCommand->param2)
- doJump = _gameFlags[currentCommand->param1] == 0;
- else
- doJump = _gameFlags[currentCommand->param1] != 0;
+ doJump = isGameFlagSet(flagNum);
if (doJump)
_currentLine = currentCommand->param3;
}
+ }
break;
/* 0x05 */ case kHideCursor:
@@ -139,6 +164,7 @@ void ScriptManager::processActionList() {
/* 0x06 */ case kShowCursor:
_scene->_screen->showCursor();
_allowInput = true;
+ // TODO: clear_flag_01()
break;
/* 0x07 */ case kPlayAnimation: {
diff --git a/engines/asylum/scriptman.h b/engines/asylum/scriptman.h
index b1f613b1ee..1f46a0ae9e 100644
--- a/engines/asylum/scriptman.h
+++ b/engines/asylum/scriptman.h
@@ -53,6 +53,10 @@ public:
bool isProcessing() { return _processing; }
void setGameFlag(int flag);
+ void clearGameFlag(int flag);
+ void toggleGameFlag(int flag);
+ bool isGameFlagSet(int flag);
+ bool isGameFlagNotSet(int flag);
private:
friend class Common::Singleton<SingletonBaseType>;
Commit: 54682e1f44f9b86f4a9aeaa55aed5fc3f301aadb
https://github.com/scummvm/scummvm/commit/54682e1f44f9b86f4a9aeaa55aed5fc3f301aadb
Author: Alex Bevilacqua (alexbevi at gmail.com)
Date: 2021-05-17T15:35:40+02:00
Commit Message:
ASYLUM: Utilities class renamed to Shared. All common resources bound to shared singleton so they can be used by all engine components without needing a direct reference back to the engine variables (Screen, Sound, Video, Scene).
Better Pathfinding (you can actually walk around now)
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@292 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
A engines/asylum/shared.cpp
A engines/asylum/shared.h
R engines/asylum/utilities.cpp
R engines/asylum/utilities.h
engines/asylum/actor.cpp
engines/asylum/actor.h
engines/asylum/asylum.cpp
engines/asylum/blowuppuzzle.cpp
engines/asylum/blowuppuzzle.h
engines/asylum/menu.cpp
engines/asylum/menu.h
engines/asylum/module.mk
engines/asylum/scene.cpp
engines/asylum/scene.h
engines/asylum/scriptman.cpp
engines/asylum/scriptman.h
diff --git a/engines/asylum/actor.cpp b/engines/asylum/actor.cpp
index 38517a89de..11af755675 100644
--- a/engines/asylum/actor.cpp
+++ b/engines/asylum/actor.cpp
@@ -27,7 +27,7 @@
#include "asylum/actor.h"
#include "asylum/screen.h"
-#include "asylum/utilities.h"
+#include "asylum/shared.h"
namespace Asylum {
@@ -39,10 +39,12 @@ MainActor::MainActor(uint8 *data) {
dataPtr += 4;
}
- _resPack = 0;
- _graphic = 0;
- _actorX = _actorY = 0;
- _currentAction = 0;
+ _resPack = 0;
+ _graphic = 0;
+ _actorX = 0;
+ _actorY = 0;
+ _currentAction = 0;
+ _currentWalkArea = 0;
}
MainActor::~MainActor() {
@@ -103,10 +105,10 @@ GraphicFrame *MainActor::getFrame() {
return frame;
}
-void MainActor::drawActorAt(Screen *screen, uint16 x, uint16 y) {
+void MainActor::drawActorAt(uint16 x, uint16 y) {
GraphicFrame *frame = getFrame();
- screen->copyRectToScreenWithTransparency(
+ Shared.getScreen()->copyRectToScreenWithTransparency(
((byte *)frame->surface.pixels),
frame->surface.w,
x,
@@ -118,10 +120,10 @@ void MainActor::drawActorAt(Screen *screen, uint16 x, uint16 y) {
_actorY = y;
}
-void MainActor::drawActor(Screen *screen) {
+void MainActor::drawActor() {
GraphicFrame *frame = getFrame();
- screen->copyToBackBufferWithTransparency(
+ Shared.getScreen()->copyToBackBufferWithTransparency(
((byte *)frame->surface.pixels),
frame->surface.w,
_actorX,
@@ -130,7 +132,14 @@ void MainActor::drawActor(Screen *screen) {
frame->surface.h );
}
-void MainActor::walkTo(Screen *screen, uint16 x, uint16 y, PolyDefinitions *region) {
+void MainActor::setWalkArea(ActionItem *target) {
+ if (_currentWalkArea != target) {
+ ScriptMan.setScriptIndex(target->actionListIdx1);
+ _currentWalkArea = target;
+ }
+}
+
+void MainActor::walkTo(uint16 x, uint16 y) {
// TODO: pathfinding! The character can walk literally anywhere
int newAction = _currentAction;
@@ -195,18 +204,47 @@ void MainActor::walkTo(Screen *screen, uint16 x, uint16 y, PolyDefinitions *regi
rect.bottom = newY + 4;
surface.frameRect(rect, 0x33);
- screen->copyRectToScreen((byte*)surface.pixels, 5, newX, newY, 5, 5);
+ Shared.getScreen()->copyRectToScreen((byte*)surface.pixels, 5, newX, newY, 5, 5);
surface.free();
+ int availableAreas[5];
+ int areaPtr = 0;
+ ActionItem *area;
+
+ // Check what valid walk region(s) is/are currently available
+ for (uint32 a = 0; a < Shared.getScene()->getResources()->getWorldStats()->numActions; a++) {
+ if (Shared.getScene()->getResources()->getWorldStats()->actions[a].actionType == 0) {
+ area = &Shared.getScene()->getResources()->getWorldStats()->actions[a];
+ PolyDefinitions poly = Shared.getScene()->getResources()->getGamePolygons()->polygons[area->polyIdx];
+ if (Shared.pointInPoly(&poly, _actorX, _actorY)) {
+ availableAreas[areaPtr] = a;
+ areaPtr++;
+
+ if (areaPtr > 5)
+ error("More than 5 overlapping walk regions found. Increase buffer");
+ }
+ }
+ }
- if (Utils.pointInPoly(region, newX, newY)) {
- _actorX = newX;
- _actorY = newY;
+ // Set the current walk region to the first available action area
+ // in the collection
+ setWalkArea(&Shared.getScene()->getResources()->getWorldStats()->actions[availableAreas[0]]);
+
+ // Check that we can walk in the current direction within any of the available
+ // walkable regions
+ for (int i = 0; i < areaPtr; i++) {
+ area = &Shared.getScene()->getResources()->getWorldStats()->actions[availableAreas[i]];
+ PolyDefinitions *region = &Shared.getScene()->getResources()->getGamePolygons()->polygons[area->polyIdx];
+ if (Shared.pointInPoly(region, newX, newY)) {
+ _actorX = newX;
+ _actorY = newY;
+ break;
+ }
}
setAction(newAction);
- drawActor(screen);
+ drawActor();
}
} // end of namespace Asylum
diff --git a/engines/asylum/actor.h b/engines/asylum/actor.h
index cfb4e89ccf..41b36f8dfc 100644
--- a/engines/asylum/actor.h
+++ b/engines/asylum/actor.h
@@ -32,7 +32,7 @@
namespace Asylum {
class Screen;
-struct PolyDefinitions;
+struct ActionItem;
// TODO properly use this enum as opposed to just
// using it for visual reference :P
@@ -134,21 +134,24 @@ public:
virtual ~MainActor();
void setResourcePack(ResourcePack *resPack) { _resPack = resPack; }
+ void setWalkArea(ActionItem *target); // depreciate
void setAction(int action);
void setActionByIndex(int index);
- void drawActorAt(Screen *screen, uint16 x, uint16 y);
- void drawActor(Screen *screen);
- void walkTo(Screen *screen, uint16 x, uint16 y, PolyDefinitions *region);
+ void drawActorAt(uint16 x, uint16 y);
+ void drawActor();
+ void walkTo(uint16 x, uint16 y);
int getCurrentAction() { return _currentAction; }
uint16 _actorX, _actorY;
private:
GraphicResource *_graphic;
- ResourcePack *_resPack;
- uint32 _resources[61];
- uint8 _currentFrame;
- int _currentAction;
+ ResourcePack *_resPack;
+ uint32 _resources[61];
+ uint8 _currentFrame;
+ int _currentAction;
+
+ ActionItem *_currentWalkArea;
GraphicFrame *getFrame();
diff --git a/engines/asylum/asylum.cpp b/engines/asylum/asylum.cpp
index b42369e45c..0e5e0badc9 100644
--- a/engines/asylum/asylum.cpp
+++ b/engines/asylum/asylum.cpp
@@ -31,6 +31,7 @@
#include "asylum/asylum.h"
#include "asylum/respack.h"
+#include "asylum/shared.h"
namespace Asylum {
@@ -84,6 +85,10 @@ Common::Error AsylumEngine::init() {
_mainMenu = 0;
_scene = 0;
+ Shared.setScreen(_screen);
+ Shared.setSound(_sound);
+ Shared.setVideo(_video);
+
return Common::kNoError;
}
@@ -102,19 +107,17 @@ Common::Error AsylumEngine::go() {
//_video->playVideo(1, kSubtitlesOn);
// Set up the game's main scene
- _scene = new Scene(_screen, _sound, _video, 5);
- _scene->setBlowUpPuzzle(new BlowUpPuzzleVCR(_scene)); // this will be done by a Script command
+ _scene = new Scene(5);
+ Shared.setScene(_scene);
- // TODO Since the ScriptMan is a singleton, setScene assignments could
- // probably be rolled into the Scene constructor :D
- ScriptMan.setScene(_scene);
+ _scene->setBlowUpPuzzle(new BlowUpPuzzleVCR()); // this will be done by a Script command
// TODO This can probably also be rolled into the scene constructor.
// Investigate if this will fuck up the execution sequence though :P
ScriptMan.setScript(_scene->getDefaultActionList());
// Set up main menu
- _mainMenu = new MainMenu(_screen, _sound, _scene);
+ _mainMenu = new MainMenu();
// XXX Testing
@@ -228,11 +231,9 @@ void AsylumEngine::processDelayedEvents() {
if (_scene)
delete _scene;
- _scene = new Scene(_screen, _sound, _video, sceneIdx);
-
- ScriptMan.setScene(_scene);
-
+ _scene = new Scene(sceneIdx);
_scene->enterScene();
+
ScriptMan.setDelayedSceneIndex(-1);
ScriptMan.setScript(_scene->getDefaultActionList());
}
diff --git a/engines/asylum/blowuppuzzle.cpp b/engines/asylum/blowuppuzzle.cpp
index d9b9a6f35b..c921158720 100644
--- a/engines/asylum/blowuppuzzle.cpp
+++ b/engines/asylum/blowuppuzzle.cpp
@@ -26,11 +26,11 @@
#include "asylum/blowuppuzzle.h"
#include "asylum/respack.h"
#include "asylum/graphics.h"
+#include "asylum/shared.h"
namespace Asylum {
-BlowUpPuzzle::BlowUpPuzzle(Scene *scene) :
- _scene(scene), _screen(scene->getScreen()), _sound(scene->getSound()), _video(scene->getVideo()) {
+BlowUpPuzzle::BlowUpPuzzle() {
}
BlowUpPuzzle::~BlowUpPuzzle() {
@@ -43,7 +43,7 @@ void BlowUpPuzzle::updateCursor() {
if (_curMouseCursor == _cursorResource->getFrameCount() - 1)
_cursorStep = -1;
- _screen->setCursor(_cursorResource, _curMouseCursor);
+ Shared.getScreen()->setCursor(_cursorResource, _curMouseCursor);
}
void BlowUpPuzzle::addGraphicToQueue(uint32 redId, uint32 x, uint32 y, uint32 frameIdx, uint32 flags, uint32 priority) {
@@ -66,9 +66,9 @@ void BlowUpPuzzle::updateGraphicsInQueue() {
// sort by priority first
graphicsSelectionSort();
for(uint i = 0; i < _queueItems.size(); i++) {
- GraphicResource *jack = _scene->getGraphicResource(_queueItems[i].resId);
+ GraphicResource *jack = Shared.getScene()->getGraphicResource(_queueItems[i].resId);
GraphicFrame *fra = jack->getFrame(_queueItems[i].frameIdx);
- _screen->copyRectToScreenWithTransparency((byte *)fra->surface.pixels, fra->surface.w, _queueItems[i].x, _queueItems[i].y, fra->surface.w, fra->surface.h);
+ Shared.getScreen()->copyRectToScreenWithTransparency((byte *)fra->surface.pixels, fra->surface.w, _queueItems[i].x, _queueItems[i].y, fra->surface.w, fra->surface.h);
}
}
@@ -97,7 +97,7 @@ void BlowUpPuzzle::swapGraphicItem(int item1, int item2) {
// BlowUp Puzzle VCR ---------------------------------------------------------------------------------------------
-BlowUpPuzzleVCR::BlowUpPuzzleVCR(Scene *scene) : BlowUpPuzzle(scene) {
+BlowUpPuzzleVCR::BlowUpPuzzleVCR() {
_mouseX = 0;
_mouseY = 0;
_leftClickUp = false;
@@ -106,8 +106,8 @@ BlowUpPuzzleVCR::BlowUpPuzzleVCR(Scene *scene) : BlowUpPuzzle(scene) {
_curMouseCursor = 0;
_cursorStep = 1;
_active = false;
- _cursorResource = _scene->getGraphicResource(_scene->getResources()->getWorldStats()->grResId[28]);
- _bgResource = _scene->getGraphicResource(_scene->getResources()->getWorldStats()->grResId[0]);
+ _cursorResource = Shared.getScene()->getGraphicResource(Shared.getScene()->getResources()->getWorldStats()->grResId[28]);
+ _bgResource = Shared.getScene()->getGraphicResource(Shared.getScene()->getResources()->getWorldStats()->grResId[0]);
_tvScreenAnimIdx = 0;
_isAccomplished = false;
@@ -124,20 +124,20 @@ BlowUpPuzzleVCR::~BlowUpPuzzleVCR() {
void BlowUpPuzzleVCR::openBlowUp() {
_active = true;
- _scene->deactivate();
+ Shared.getScene()->deactivate();
// FIXME: decomment this line when stopSfx works properly (it nows stop together SFX and Music
- //_sound->stopSfx();
+ //Shared.getSound()->stopSfx();
// Load the graphics palette
- _screen->setPalette(_scene->getResourcePack(), _scene->getResources()->getWorldStats()->grResId[29]);
+ Shared.getScreen()->setPalette(Shared.getScene()->getResourcePack(), Shared.getScene()->getResources()->getWorldStats()->grResId[29]);
// show blow up puzzle BG
GraphicFrame *bg = _bgResource->getFrame(0);
- _screen->copyToBackBuffer((byte *)bg->surface.pixels, bg->surface.w, 0, 0, bg->surface.w, bg->surface.h);
+ Shared.getScreen()->copyToBackBuffer((byte *)bg->surface.pixels, bg->surface.w, 0, 0, bg->surface.w, bg->surface.h);
// Set mouse cursor
- _screen->setCursor(_cursorResource, 0);
- _screen->showCursor();
+ Shared.getScreen()->setCursor(_cursorResource, 0);
+ Shared.getScreen()->showCursor();
_leftClickUp = false;
_leftClickDown = false;
@@ -147,7 +147,7 @@ void BlowUpPuzzleVCR::openBlowUp() {
void BlowUpPuzzleVCR::closeBlowUp() {
_active = false;
- _scene->activate();
+ Shared.getScene()->activate();
}
void BlowUpPuzzleVCR::handleEvent(Common::Event *event, bool doUpdate) {
@@ -187,7 +187,7 @@ void BlowUpPuzzleVCR::update() {
_rightClickDown = false;
closeBlowUp();
// TODO: stop sound fx grResId[47] (TV On sfx)
- _scene->enterScene();
+ Shared.getScene()->enterScene();
}
if (_leftClickDown) {
@@ -212,8 +212,8 @@ void BlowUpPuzzleVCR::update() {
updateStopButton();
if(_buttonsState[kPower] == kON) {
- addGraphicToQueue(_scene->getResources()->getWorldStats()->grResId[22], 0, 37, _tvScreenAnimIdx, 0, 1);
- addGraphicToQueue(_scene->getResources()->getWorldStats()->grResId[23], 238, 22, _tvScreenAnimIdx++, 0, 1);
+ addGraphicToQueue(Shared.getScene()->getResources()->getWorldStats()->grResId[22], 0, 37, _tvScreenAnimIdx, 0, 1);
+ addGraphicToQueue(Shared.getScene()->getResources()->getWorldStats()->grResId[23], 238, 22, _tvScreenAnimIdx++, 0, 1);
_tvScreenAnimIdx %= 6;
}
@@ -224,17 +224,17 @@ void BlowUpPuzzleVCR::update() {
int barSize = 0;
do {
- _screen->drawWideScreen(barSize);
+ Shared.getScreen()->drawWideScreen(barSize);
barSize += 4;
} while(barSize < 84);
// TODO: fade palette to grey
- _video->playVideo(2, kSubtitlesOn);
+ Shared.getVideo()->playVideo(2, kSubtitlesOn);
_isAccomplished = false;
_active = false;
- _scene->enterScene();
+ Shared.getScene()->enterScene();
} else {
updateGraphicsInQueue();
}
@@ -248,7 +248,7 @@ GraphicQueueItem BlowUpPuzzleVCR::getGraphicJackItem(int resId) {
jackY = 356;
}
- jackItemOnHand.resId = _scene->getResources()->getWorldStats()->grResId[resId];
+ jackItemOnHand.resId = Shared.getScene()->getResources()->getWorldStats()->grResId[resId];
jackItemOnHand.frameIdx = 0;
jackItemOnHand.x = _mouseX - 114;
jackItemOnHand.y = jackY - 14;
@@ -264,7 +264,7 @@ GraphicQueueItem BlowUpPuzzleVCR::getGraphicShadowItem() {
if(_mouseY < 356) {
shadowY = 0;
}
- shadowItem.resId = _scene->getResources()->getWorldStats()->grResId[30];
+ shadowItem.resId = Shared.getScene()->getResources()->getWorldStats()->grResId[30];
shadowItem.frameIdx = 0;
shadowItem.x = _mouseX - shadowY;
shadowItem.y = 450;
@@ -278,28 +278,28 @@ void BlowUpPuzzleVCR::updateJack(Jack jack, VCRDrawInfo onTable, VCRDrawInfo plu
switch(_jacksState[jack]){
case kOnTable:
- item.resId = _scene->getResources()->getWorldStats()->grResId[onTable.resId];
+ item.resId = Shared.getScene()->getResources()->getWorldStats()->grResId[onTable.resId];
item.frameIdx = 0;
item.x = onTable.x;
item.y = onTable.y;
item.priority = 3;
break;
case kPluggedOnRed:
- item.resId = _scene->getResources()->getWorldStats()->grResId[pluggedOnRed.resId];
+ item.resId = Shared.getScene()->getResources()->getWorldStats()->grResId[pluggedOnRed.resId];
item.frameIdx = 0;
item.x = 329;
item.y = 407;
item.priority = 3;
break;
case kPluggedOnYellow:
- item.resId = _scene->getResources()->getWorldStats()->grResId[pluggedOnYellow.resId];
+ item.resId = Shared.getScene()->getResources()->getWorldStats()->grResId[pluggedOnYellow.resId];
item.frameIdx = 0;
item.x = 402;
item.y = 413;
item.priority = 3;
break;
case kPluggedOnBlack:
- item.resId = _scene->getResources()->getWorldStats()->grResId[pluggedOnBlack.resId];
+ item.resId = Shared.getScene()->getResources()->getWorldStats()->grResId[pluggedOnBlack.resId];
item.frameIdx = 0;
item.x = 477;
item.y = 418;
@@ -384,13 +384,13 @@ int BlowUpPuzzleVCR::setJackOnHole(int jackType, JackState plugged) {
if(_jacksState[jackType-1] == kOnHand) {
_jacksState[jackType-1] = plugged;
_holesState[plugged-1] = jackType; // set jack on red
- _sound->playSfx(_scene->getResourcePack(), _scene->getResources()->getWorldStats()->grResId[44]);
+ Shared.getSound()->playSfx(Shared.getScene()->getResourcePack(), Shared.getScene()->getResources()->getWorldStats()->grResId[44]);
}
} else if(jackType == 0) {
jackType = _holesState[plugged-1];
_jacksState[jackType-1] = kOnHand;
_holesState[plugged-1] = 0;
- _sound->playSfx(_scene->getResourcePack(), _scene->getResources()->getWorldStats()->grResId[43]);
+ Shared.getSound()->playSfx(Shared.getScene()->getResourcePack(), Shared.getScene()->getResources()->getWorldStats()->grResId[43]);
return 0;
}
return 1;
@@ -401,7 +401,7 @@ void BlowUpPuzzleVCR::updateButton(Button button, VCRDrawInfo btON, VCRDrawInfo
switch(_buttonsState[button]){
case kON:
- item.resId = _scene->getResources()->getWorldStats()->grResId[btON.resId];
+ item.resId = Shared.getScene()->getResources()->getWorldStats()->grResId[btON.resId];
item.frameIdx = 0;
item.x = btON.x;
item.y = btON.y;
@@ -409,7 +409,7 @@ void BlowUpPuzzleVCR::updateButton(Button button, VCRDrawInfo btON, VCRDrawInfo
break;
case kDownON:
case kDownOFF:
- item.resId = _scene->getResources()->getWorldStats()->grResId[btDown.resId];
+ item.resId = Shared.getScene()->getResources()->getWorldStats()->grResId[btDown.resId];
item.frameIdx = 0;
item.x = btDown.x;
item.y = btDown.y;
@@ -508,14 +508,14 @@ void BlowUpPuzzleVCR::updateCursorInPolyRegion() {
|| inPolyRegion(_mouseX, _mouseY, kYellowHole) && _holesState[kPluggedOnYellow-1]
|| inPolyRegion(_mouseX, _mouseY, kBlackHole) && _holesState[kPluggedOnBlack-1]) {
if(_curMouseCursor != 2) { // reset cursor
- _screen->showCursor();
+ Shared.getScreen()->showCursor();
_curMouseCursor = 2;
_cursorStep = 1;
updateCursor();
}
} else {
if(_curMouseCursor != 0) { // reset cursor
- _screen->showCursor();
+ Shared.getScreen()->showCursor();
_curMouseCursor = 0;
_cursorStep = 1;
updateCursor();
@@ -523,7 +523,7 @@ void BlowUpPuzzleVCR::updateCursorInPolyRegion() {
}
}
} else {
- _screen->hideCursor();
+ Shared.getScreen()->hideCursor();
}
}
@@ -569,8 +569,8 @@ void BlowUpPuzzleVCR::handleMouseDown() {
if (_mouseX >= (uint32)BlowUpPuzzleVCRPolies[kBlackJack].left && _mouseX <= (uint32)BlowUpPuzzleVCRPolies[kYellowJack].right &&
_mouseY >= (uint32)BlowUpPuzzleVCRPolies[kBlackJack].top && _mouseY <= (uint32)BlowUpPuzzleVCRPolies[kYellowJack].bottom) {
_jacksState[jackType-1] = kOnTable;
- _sound->playSfx(_scene->getResourcePack(), _scene->getResources()->getWorldStats()->grResId[50]);
- _screen->showCursor();
+ Shared.getSound()->playSfx(Shared.getScene()->getResourcePack(), Shared.getScene()->getResources()->getWorldStats()->grResId[50]);
+ Shared.getScreen()->showCursor();
}
return;
}
@@ -586,7 +586,7 @@ void BlowUpPuzzleVCR::handleMouseDown() {
// TODO: VCR button regions
if (inPolyRegion(_mouseX, _mouseY, kRewindButton)) {
- _sound->playSfx(_scene->getResourcePack(), _scene->getResources()->getWorldStats()->grResId[39]);
+ Shared.getSound()->playSfx(Shared.getScene()->getResourcePack(), Shared.getScene()->getResources()->getWorldStats()->grResId[39]);
if(!_buttonsState[kRewind]) {
_buttonsState[kRewind] = kDownON;
return;
@@ -596,7 +596,7 @@ void BlowUpPuzzleVCR::handleMouseDown() {
return;
}
} else if (inPolyRegion(_mouseX, _mouseY, kPlayButton)) {
- _sound->playSfx(_scene->getResourcePack(), _scene->getResources()->getWorldStats()->grResId[39]);
+ Shared.getSound()->playSfx(Shared.getScene()->getResourcePack(), Shared.getScene()->getResources()->getWorldStats()->grResId[39]);
if(!_buttonsState[kPlay]) {
_buttonsState[kPlay] = kDownON;
return;
@@ -606,7 +606,7 @@ void BlowUpPuzzleVCR::handleMouseDown() {
return;
}
} else if (inPolyRegion(_mouseX, _mouseY, kStopButton)) {
- _sound->playSfx(_scene->getResourcePack(), _scene->getResources()->getWorldStats()->grResId[39]);
+ Shared.getSound()->playSfx(Shared.getScene()->getResourcePack(), Shared.getScene()->getResources()->getWorldStats()->grResId[39]);
if(_buttonsState[kStop]) {
if(_buttonsState[kStop] == kON) {
_buttonsState[kStop] = kDownOFF;
@@ -617,7 +617,7 @@ void BlowUpPuzzleVCR::handleMouseDown() {
return;
}
} else if (inPolyRegion(_mouseX, _mouseY, kPowerButton)) {
- _sound->playSfx(_scene->getResourcePack(), _scene->getResources()->getWorldStats()->grResId[39]);
+ Shared.getSound()->playSfx(Shared.getScene()->getResourcePack(), Shared.getScene()->getResources()->getWorldStats()->grResId[39]);
if(!_buttonsState[kPower] && _holesState[kPluggedOnBlack-1] == kBlack+1 && _holesState[kPluggedOnRed-1] && _holesState[kPluggedOnYellow-1]) {
_buttonsState[kPower] = kDownON;
@@ -633,7 +633,7 @@ void BlowUpPuzzleVCR::handleMouseUp() {
if(_buttonsState[kPower] == kDownON) {
// TODO: check if next sound is already playing
- _sound->playSfx(_scene->getResourcePack(), _scene->getResources()->getWorldStats()->grResId[47]);
+ Shared.getSound()->playSfx(Shared.getScene()->getResourcePack(), Shared.getScene()->getResources()->getWorldStats()->grResId[47]);
_buttonsState[kPower] = kON;
_buttonsState[kStop] = kON;
_buttonsState[kPlay] = kON;
@@ -648,7 +648,7 @@ void BlowUpPuzzleVCR::handleMouseUp() {
if(_buttonsState[kRewind] == kDownOFF) {
_buttonsState[kRewind] = kON;
- _sound->playSfx(_scene->getResourcePack(), _scene->getResources()->getWorldStats()->grResId[46]);
+ Shared.getSound()->playSfx(Shared.getScene()->getResourcePack(), Shared.getScene()->getResources()->getWorldStats()->grResId[46]);
} else if(_buttonsState[kRewind] == kDownON) {
_buttonsState[kRewind] = kOFF;
}
diff --git a/engines/asylum/blowuppuzzle.h b/engines/asylum/blowuppuzzle.h
index f0c288c5bc..eca09cd6ee 100644
--- a/engines/asylum/blowuppuzzle.h
+++ b/engines/asylum/blowuppuzzle.h
@@ -53,7 +53,7 @@ typedef struct GraphicQueueItem {
class BlowUpPuzzle {
public:
- BlowUpPuzzle(Scene *scene);
+ BlowUpPuzzle();
virtual ~BlowUpPuzzle();
virtual void handleEvent(Common::Event *event, bool doUpdate){};
@@ -64,11 +64,6 @@ public:
protected:
Common::Event *_ev;
- Screen *_screen;
- Sound *_sound;
- Scene *_scene;
- Video *_video;
-
uint32 _mouseX;
uint32 _mouseY;
uint32 _curMouseCursor;
@@ -119,7 +114,7 @@ const Common::Rect BlowUpPuzzleVCRPolies[10] = {
class BlowUpPuzzleVCR : public BlowUpPuzzle {
public:
- BlowUpPuzzleVCR(Scene *scene);
+ BlowUpPuzzleVCR();
~BlowUpPuzzleVCR();
void handleEvent(Common::Event *event, bool doUpdate);
diff --git a/engines/asylum/menu.cpp b/engines/asylum/menu.cpp
index 5d7872a576..1018c7f984 100644
--- a/engines/asylum/menu.cpp
+++ b/engines/asylum/menu.cpp
@@ -26,14 +26,14 @@
#include "asylum/menu.h"
#include "asylum/respack.h"
#include "asylum/graphics.h"
+#include "asylum/shared.h"
namespace Asylum {
/** This fixes the menu icons text x position on screen */
const int MenuIconFixedXpos[12] = { 28, 128, 225, 320, 410, 528, 16, 115, 237, 310, 508, 419 };
-MainMenu::MainMenu(Screen *screen, Sound *sound, Scene *scene) :
- _screen(screen), _sound(sound), _scene(scene) {
+MainMenu::MainMenu() {
_mouseX = 0;
_mouseY = 0;
_leftClick = false;
@@ -58,7 +58,7 @@ MainMenu::MainMenu(Screen *screen, Sound *sound, Scene *scene) :
_creditsResource = 0;
_creditsFadeResource = 0;
- _text = new Text(_screen);
+ _text = new Text(Shared.getScreen());
_text->loadFont(_resPack, 16); // 0x80010010, yellow font
}
@@ -75,27 +75,27 @@ MainMenu::~MainMenu() {
void MainMenu::openMenu() {
_active = true;
- _scene->deactivate();
+ Shared.getScene()->deactivate();
// yellow font
_text->loadFont(_resPack, 0x80010010);
// Load the graphics palette
- _screen->setPalette(_resPack, 17);
+ Shared.getScreen()->setPalette(_resPack, 17);
// Copy the bright background to the back buffer
GraphicFrame *bg = _bgResource->getFrame(1);
- _screen->copyToBackBuffer((byte *)bg->surface.pixels, bg->surface.w, 0, 0, bg->surface.w, bg->surface.h);
+ Shared.getScreen()->copyToBackBuffer((byte *)bg->surface.pixels, bg->surface.w, 0, 0, bg->surface.w, bg->surface.h);
// Set mouse cursor
- _screen->setCursor(_cursorResource, 0);
- _screen->showCursor();
+ Shared.getScreen()->setCursor(_cursorResource, 0);
+ Shared.getScreen()->showCursor();
// Stop all sounds
- _sound->stopMusic();
- _sound->stopSfx();
+ Shared.getSound()->stopMusic();
+ Shared.getSound()->stopSfx();
// Start playing music
- _sound->playMusic(_resPack, 39);
+ Shared.getSound()->playMusic(_resPack, 39);
_previousActiveIcon = _activeIcon = -1;
_leftClick = false;
@@ -105,11 +105,11 @@ void MainMenu::openMenu() {
void MainMenu::closeMenu() {
_active = false;
- _scene->activate();
+ Shared.getScene()->activate();
// Stop menu sounds and menu music
- _sound->stopSfx();
- _sound->stopMusic();
+ Shared.getSound()->stopSfx();
+ Shared.getSound()->stopMusic();
}
void MainMenu::handleEvent(Common::Event *event, bool doUpdate) {
@@ -147,13 +147,13 @@ void MainMenu::update() {
if (_activeIcon != -1) {
// Copy the dark background to the back buffer
GraphicFrame *bg = _bgResource->getFrame(0);
- _screen->copyToBackBuffer((byte *)bg->surface.pixels, bg->surface.w, 0, 0, bg->surface.w, bg->surface.h);
+ Shared.getScreen()->copyToBackBuffer((byte *)bg->surface.pixels, bg->surface.w, 0, 0, bg->surface.w, bg->surface.h);
_activeMenuScreen = (MenuScreen) _activeIcon;
// Set the cursor
delete _cursorResource;
_cursorResource = new GraphicResource(_resPack, 3);
- _screen->setCursor(_cursorResource, 0);
+ Shared.getScreen()->setCursor(_cursorResource, 0);
}
switch (_activeIcon) {
@@ -195,15 +195,15 @@ void MainMenu::update() {
_creditsFadeResource = new GraphicResource(_resPack, 23);
_creditsTextScroll = 0x1E0 - 30;
// Set credits palette
- _screen->setPalette(_resPack, 26);
+ Shared.getScreen()->setPalette(_resPack, 26);
// Stop all sounds
- _sound->stopMusic();
+ Shared.getSound()->stopMusic();
// Start playing music
- _sound->playMusic(_resPack, 38);
+ Shared.getSound()->playMusic(_resPack, 38);
break;
case kReturnToGame:
closeMenu();
- _scene->enterScene();
+ Shared.getScene()->enterScene();
break;
}
}
@@ -216,7 +216,7 @@ void MainMenu::updateCursor() {
if (_curMouseCursor == _cursorResource->getFrameCount() - 1)
_cursorStep = -1;
- _screen->setCursor(_cursorResource, _curMouseCursor);
+ Shared.getScreen()->setCursor(_cursorResource, _curMouseCursor);
}
void MainMenu::updateEyesAnimation() {
@@ -249,7 +249,7 @@ void MainMenu::updateEyesAnimation() {
// TODO: kEyesCrossed state
GraphicFrame *eyeFrame = _eyeResource->getFrame(eyeFrameNum);
- _screen->copyRectToScreenWithTransparency((byte *)eyeFrame->surface.pixels, eyeFrame->surface.w, eyeFrame->x, eyeFrame->y, eyeFrame->surface.w, eyeFrame->surface.h);
+ Shared.getScreen()->copyRectToScreenWithTransparency((byte *)eyeFrame->surface.pixels, eyeFrame->surface.w, eyeFrame->x, eyeFrame->y, eyeFrame->surface.w, eyeFrame->surface.h);
}
void MainMenu::updateMainMenu() {
@@ -289,7 +289,7 @@ void MainMenu::updateMainMenu() {
}
GraphicFrame *iconFrame = _iconResource->getFrame(MIN<int>(_iconResource->getFrameCount() - 1, _curIconFrame));
- _screen->copyRectToScreenWithTransparency((byte *)iconFrame->surface.pixels, iconFrame->surface.w, iconFrame->x, iconFrame->y, iconFrame->surface.w, iconFrame->surface.h);
+ Shared.getScreen()->copyRectToScreenWithTransparency((byte *)iconFrame->surface.pixels, iconFrame->surface.w, iconFrame->x, iconFrame->y, iconFrame->surface.w, iconFrame->surface.h);
// Cycle icon frame
_curIconFrame++;
@@ -300,8 +300,8 @@ void MainMenu::updateMainMenu() {
_text->drawResTextCentered(MenuIconFixedXpos[iconNum], iconFrame->y + 50, _text->getResTextWidth(iconNum + 1309), iconNum + 1309);
// Play creepy voice
- if (!_sound->isSfxActive() && _activeIcon != _previousActiveIcon) {
- _sound->playSfx(_resPack, iconNum + 44);
+ if (!Shared.getSound()->isSfxActive() && _activeIcon != _previousActiveIcon) {
+ Shared.getSound()->playSfx(_resPack, iconNum + 44);
_previousActiveIcon = _activeIcon;
}
@@ -312,7 +312,7 @@ void MainMenu::updateMainMenu() {
void MainMenu::updateSubMenu() {
GraphicFrame *iconFrame = _iconResource->getFrame(MIN<int>(_iconResource->getFrameCount() - 1, _curIconFrame));
- _screen->copyRectToScreenWithTransparency((byte *)iconFrame->surface.pixels, iconFrame->surface.w, iconFrame->x, iconFrame->y, iconFrame->surface.w, iconFrame->surface.h);
+ Shared.getScreen()->copyRectToScreenWithTransparency((byte *)iconFrame->surface.pixels, iconFrame->surface.w, iconFrame->x, iconFrame->y, iconFrame->surface.w, iconFrame->surface.h);
// Cycle icon frame
_curIconFrame++;
@@ -580,10 +580,10 @@ void MainMenu::updateSubMenuShowCredits() {
int maxBound = 0;
GraphicFrame *creditsFadeFrame = _creditsFadeResource->getFrame(0);
- _screen->copyRectToScreenWithTransparency((byte *)creditsFadeFrame->surface.pixels, creditsFadeFrame->surface.w, creditsFadeFrame->x, creditsFadeFrame->y, creditsFadeFrame->surface.w, creditsFadeFrame->surface.h);
+ Shared.getScreen()->copyRectToScreenWithTransparency((byte *)creditsFadeFrame->surface.pixels, creditsFadeFrame->surface.w, creditsFadeFrame->x, creditsFadeFrame->y, creditsFadeFrame->surface.w, creditsFadeFrame->surface.h);
GraphicFrame *creditsFrame = _creditsResource->getFrame(MIN<int>(_creditsResource->getFrameCount() - 1, _creditsBgFrame));
- _screen->copyRectToScreenWithTransparency((byte *)creditsFrame->surface.pixels, creditsFrame->surface.w, creditsFrame->x, creditsFrame->y, creditsFrame->surface.w, creditsFrame->surface.h);
+ Shared.getScreen()->copyRectToScreenWithTransparency((byte *)creditsFrame->surface.pixels, creditsFrame->surface.w, creditsFrame->x, creditsFrame->y, creditsFrame->surface.w, creditsFrame->surface.h);
_creditsBgFrame++;
if (_creditsBgFrame >= _creditsResource->getFrameCount())
@@ -624,11 +624,11 @@ void MainMenu::updateSubMenuShowCredits() {
if (_leftClick) {
// Restore palette
- _screen->setPalette(_resPack, 17);
+ Shared.getScreen()->setPalette(_resPack, 17);
// Stop all sounds
- _sound->stopMusic();
+ Shared.getSound()->stopMusic();
// Start playing music
- _sound->playMusic(_resPack, 39);
+ Shared.getSound()->playMusic(_resPack, 39);
exitSubMenu();
}
}
@@ -639,12 +639,12 @@ void MainMenu::exitSubMenu() {
// Copy the bright background to the back buffer
GraphicFrame *bg = _bgResource->getFrame(1);
- _screen->copyToBackBuffer((byte *)bg->surface.pixels, bg->surface.w, 0, 0, bg->surface.w, bg->surface.h);
+ Shared.getScreen()->copyToBackBuffer((byte *)bg->surface.pixels, bg->surface.w, 0, 0, bg->surface.w, bg->surface.h);
// Set the cursor
delete _cursorResource;
_cursorResource = new GraphicResource(_resPack, 2);
- _screen->setCursor(_cursorResource, 0);
+ Shared.getScreen()->setCursor(_cursorResource, 0);
}
} // end of namespace Asylum
diff --git a/engines/asylum/menu.h b/engines/asylum/menu.h
index e35de1d85a..8e7d9478cc 100644
--- a/engines/asylum/menu.h
+++ b/engines/asylum/menu.h
@@ -36,14 +36,11 @@
namespace Asylum {
-class Scene;
-class Screen;
-class Sound;
class Text;
class MainMenu {
public:
- MainMenu(Screen *screen, Sound *sound, Scene *scene);
+ MainMenu();
~MainMenu();
void handleEvent(Common::Event *event, bool doUpdate);
@@ -84,10 +81,6 @@ private:
Common::Event *_ev;
- Screen *_screen;
- Sound *_sound;
- Scene *_scene;
-
uint32 _mouseX;
uint32 _mouseY;
int32 _activeIcon;
diff --git a/engines/asylum/module.mk b/engines/asylum/module.mk
index 06c57d541a..296ccb57ea 100644
--- a/engines/asylum/module.mk
+++ b/engines/asylum/module.mk
@@ -17,7 +17,7 @@ MODULE_OBJS := \
encounters.o \
scriptman.o \
blowuppuzzle.o \
- utilities.o
+ shared.o
# This module can be built as a plugin
ifeq ($(ENABLE_ASYLUM), DYNAMIC_PLUGIN)
diff --git a/engines/asylum/scene.cpp b/engines/asylum/scene.cpp
index 87b217cba2..65f0829838 100644
--- a/engines/asylum/scene.cpp
+++ b/engines/asylum/scene.cpp
@@ -25,7 +25,7 @@
#include "asylum/scene.h"
#include "asylum/sceneres.h"
-#include "asylum/utilities.h"
+#include "asylum/shared.h"
namespace Asylum {
@@ -35,12 +35,12 @@ namespace Asylum {
int g_debugPolygons;
int g_debugBarriers;
-Scene::Scene(Screen *screen, Sound *sound, Video *video, uint8 sceneIdx): _screen(screen), _sound(sound), _video(video) {
+Scene::Scene(uint8 sceneIdx) {
_sceneIdx = sceneIdx;
_sceneResource = new SceneResource;
if (_sceneResource->load(_sceneIdx)) {
- _text = new Text(_screen);
+ _text = new Text(Shared.getScreen());
_resPack = new ResourcePack(sceneIdx);
_speechPack = new ResourcePack(3);
@@ -84,19 +84,19 @@ Scene::~Scene() {
}
void Scene::enterScene() {
- _screen->setPalette(_resPack, _sceneResource->getWorldStats()->commonRes.palette);
+ Shared.getScreen()->setPalette(_resPack, _sceneResource->getWorldStats()->commonRes.palette);
_background = _bgResource->getFrame(0);
- _screen->copyToBackBuffer(
+ Shared.getScreen()->copyToBackBuffer(
((byte *)_background->surface.pixels) + _startY * _background->surface.w + _startX, _background->surface.w,
0, 0, 640, 480);
_cursorStep = 1;
_curMouseCursor = 0;
- _screen->setCursor(_cursorResource, 0);
- _screen->showCursor();
+ Shared.getScreen()->setCursor(_cursorResource, 0);
+ Shared.getScreen()->showCursor();
// Music testing: play the first music track
- _sound->playMusic(_musPack, 0);
+ Shared.getSound()->playMusic(_musPack, 0);
_isActive = true;
_walking = false;
@@ -267,7 +267,7 @@ void Scene::animateCursor() {
if (_curMouseCursor == _cursorResource->getFrameCount() - 1)
_cursorStep = -1;
- _screen->setCursor(_cursorResource, _curMouseCursor);
+ Shared.getScreen()->setCursor(_cursorResource, _curMouseCursor);
}
void Scene::update() {
@@ -283,7 +283,7 @@ void Scene::update() {
// debugScreenScrolling(bg);
// Copy the background to the back buffer before updating the scene animations
- _screen->copyToBackBuffer(((byte *)bg->surface.pixels) + _startY * bg->surface.w + _startX,
+ Shared.getScreen()->copyToBackBuffer(((byte *)bg->surface.pixels) + _startY * bg->surface.w + _startX,
bg->surface.w,
0,
0,
@@ -294,24 +294,23 @@ void Scene::update() {
// This is a hack for scene 1. This really shouldn't be hardcoded, as the
// activation of this barrier should be interpreted by the script manager,
// but at the moment, we're not sure where it is in the script.
- updateBarrier(_screen, _resPack, 1); // inside the middle room
+ updateBarrier(Shared.getScreen(), _resPack, 1); // inside the middle room
for(uint b=0; b < _sceneResource->getWorldStats()->barriers.size(); b++) {
if ((_sceneResource->getWorldStats()->barriers[b].flags & 0x20) != 0) // TODO - enums for flags (0x20 is visible/playing?)
- updateBarrier(_screen, _resPack, b);
+ updateBarrier(Shared.getScreen(), _resPack, b);
}
// DEBUGGING
// Check current walk region
- PolyDefinitions currentWalkRegion;
-
for (uint32 a = 0; a < worldStats->numActions; a++) {
if (worldStats->actions[a].actionType == 0) {
- PolyDefinitions poly = _sceneResource->getGamePolygons()->polygons[worldStats->actions[a].polyIdx];
- if (Utils.pointInPoly(&poly, mainActor->_actorX, mainActor->_actorY)) {
+ ActionItem *area = &worldStats->actions[a];
+ PolyDefinitions poly = _sceneResource->getGamePolygons()->polygons[area->polyIdx];
+ if (Shared.pointInPoly(&poly, mainActor->_actorX, mainActor->_actorY)) {
debugShowWalkRegion(&poly);
- currentWalkRegion = poly;
- break;
+ mainActor->setWalkArea(area);
+ //break;
}
}
}
@@ -330,12 +329,12 @@ void Scene::update() {
mainActor->setAction(currentAction + 5);
_walking = false;
}
- mainActor->drawActor(_screen);
+ mainActor->drawActor();
}
} else {
_walking = true;
- mainActor->walkTo(_screen, _mouseX, _mouseY, ¤tWalkRegion);
+ mainActor->walkTo(_mouseX, _mouseY);
updateCursor();
}
@@ -369,7 +368,7 @@ void Scene::update() {
for (uint32 p = 0; p < _sceneResource->getGamePolygons()->numEntries; p++) {
PolyDefinitions poly = _sceneResource->getGamePolygons()->polygons[p];
if (poly.boundingRect.contains(_mouseX + _startX, _mouseY + _startY)) {
- if (Utils.pointInPoly(&poly, _mouseX + _startX, _mouseY + _startY)) {
+ if (Shared.pointInPoly(&poly, _mouseX + _startX, _mouseY + _startY)) {
curHotspot = (int32)p;
animateCursor();
break;
@@ -440,7 +439,7 @@ void Scene::copyToBackBufferClipped(Graphics::Surface *surface, int x, int y) {
if (surface->h > 480)
startY = _startY;
- _screen->copyToBackBufferWithTransparency(
+ Shared.getScreen()->copyToBackBufferWithTransparency(
((byte*)surface->pixels) +
startY * surface->pitch +
startX * surface->bytesPerPixel,
diff --git a/engines/asylum/scene.h b/engines/asylum/scene.h
index eba2a422bf..98c6b16cc3 100644
--- a/engines/asylum/scene.h
+++ b/engines/asylum/scene.h
@@ -47,7 +47,7 @@ struct PolyDefinitions;
class Scene {
public:
- Scene(Screen *screen, Sound *sound, Video *video, uint8 sceneIdx);
+ Scene(uint8 sceneIdx);
~Scene();
void handleEvent(Common::Event *event, bool doUpdate);
@@ -76,10 +76,6 @@ public:
BlowUpPuzzle* getBlowUpPuzzle() { return _blowUp; }
void setBlowUpPuzzle(BlowUpPuzzle* puzzle) { _blowUp = puzzle; }
- Screen* getScreen() { return _screen; }
- Sound* getSound() { return _sound; }
- Video* getVideo() { return _video; }
-
private:
#if 0
void copyToSceneBackground(GraphicFrame *frame, int x, int y);
@@ -91,13 +87,8 @@ private:
ResourcePack *_resPack;
ResourcePack *_speechPack;
ResourcePack *_musPack;
-
- Screen *_screen;
- Sound *_sound;
- Video *_video;
- BlowUpPuzzle *_blowUp;
- Common::Event *_ev;
-
+ BlowUpPuzzle *_blowUp;
+ Common::Event *_ev;
Text *_text;
GraphicResource *_bgResource;
GraphicResource *_cursorResource;
diff --git a/engines/asylum/scriptman.cpp b/engines/asylum/scriptman.cpp
index b862bd1aff..0f273bfc9d 100644
--- a/engines/asylum/scriptman.cpp
+++ b/engines/asylum/scriptman.cpp
@@ -22,10 +22,11 @@
* $Id$
*/
-#include "asylum/scriptman.h"
-
#include "common/system.h"
+#include "asylum/scriptman.h"
+#include "asylum/shared.h"
+
DECLARE_SINGLETON(Asylum::ScriptManager);
namespace Asylum {
@@ -69,14 +70,10 @@ void ScriptManager::setScript(ActionDefinitions *action) {
}
}
-void ScriptManager::setScene(Scene* scene) {
- _scene = scene;
-}
-
void ScriptManager::setScriptIndex(uint32 index) {
_currentScript = 0;
_currentLine = 0;
- setScript(_scene->getActionList(index));
+ setScript(Shared.getScene()->getActionList(index));
}
void ScriptManager::setGameFlag(int flag) {
@@ -157,25 +154,25 @@ void ScriptManager::processActionList() {
break;
/* 0x05 */ case kHideCursor:
- _scene->_screen->hideCursor();
+ Shared.getScreen()->hideCursor();
_allowInput = false;
break;
/* 0x06 */ case kShowCursor:
- _scene->_screen->showCursor();
+ Shared.getScreen()->showCursor();
_allowInput = true;
// TODO: clear_flag_01()
break;
/* 0x07 */ case kPlayAnimation: {
- int barrierIndex = _scene->_sceneResource->getBarrierIndexById(currentCommand->param1);
+ int barrierIndex = Shared.getScene()->_sceneResource->getBarrierIndexById(currentCommand->param1);
if (barrierIndex >= 0)
- _scene->_sceneResource->getWorldStats()->barriers[barrierIndex].flags |= 0x20; // TODO - enums for flags (0x20 is visible/playing?)
+ Shared.getScene()->_sceneResource->getWorldStats()->barriers[barrierIndex].flags |= 0x20; // TODO - enums for flags (0x20 is visible/playing?)
else
debugC(kDebugLevelScripts,
"Requested invalid object ID:0x%02X in Scene %d Line %d.",
currentCommand->param1,
- _scene->getSceneIndex(),
+ Shared.getScene()->getSceneIndex(),
_currentLine);
}
break;
@@ -184,17 +181,17 @@ void ScriptManager::processActionList() {
/* 0x09 */ case kHideActor: {
uint32 actorIndex = 0;
if (currentCommand->param1 == -1)
- ;//actorIndex = _scene->getWorldStats()->playerActor;
+ ;//actorIndex = Shared.getScene()->getWorldStats()->playerActor;
else
actorIndex = currentCommand->param1;
- if ((actorIndex >= 0) && (actorIndex < _scene->_sceneResource->getWorldStats()->numActors))
- _scene->actorVisible(actorIndex, false);
+ if ((actorIndex >= 0) && (actorIndex < Shared.getScene()->_sceneResource->getWorldStats()->numActors))
+ Shared.getScene()->actorVisible(actorIndex, false);
else
debugC(kDebugLevelScripts,
"Requested invalid actor ID:0x%02X in Scene %d Line %d.",
currentCommand->param1,
- _scene->getSceneIndex(),
+ Shared.getScene()->getSceneIndex(),
_currentLine);
}
break;
@@ -202,17 +199,17 @@ void ScriptManager::processActionList() {
/* 0x0A */ case kShowActor: {
uint32 actorIndex = 0;
if (currentCommand->param1 == -1)
- ;//actorIndex = _scene->getWorldStats()->playerActor;
+ ;//actorIndex = Shared.getScene()->getWorldStats()->playerActor;
else
actorIndex = currentCommand->param1;
- if ((actorIndex >= 0) && (actorIndex < _scene->_sceneResource->getWorldStats()->numActors))
- _scene->actorVisible(actorIndex, true);
+ if ((actorIndex >= 0) && (actorIndex < Shared.getScene()->_sceneResource->getWorldStats()->numActors))
+ Shared.getScene()->actorVisible(actorIndex, true);
else
debugC(kDebugLevelScripts,
"Requested invalid actor ID:0x%02X in Scene %d Line %d.",
currentCommand->param1,
- _scene->getSceneIndex(),
+ Shared.getScene()->getSceneIndex(),
_currentLine);
}
break;
@@ -220,19 +217,19 @@ void ScriptManager::processActionList() {
/* 0x0B */ case kSetActorStats: {
uint32 actorIndex = 0;
if (currentCommand->param1 == -1)
- ;//actorIndex = _scene->getWorldStats()->playerActor;
+ ;//actorIndex = Shared.getScene()->getWorldStats()->playerActor;
else
actorIndex = currentCommand->param1;
- if ((actorIndex >= 0) && (actorIndex < _scene->_sceneResource->getWorldStats()->numActors)) {
- _scene->setActorPosition(actorIndex, currentCommand->param2, currentCommand->param3);
- _scene->setActorAction(actorIndex, currentCommand->param4);
+ if ((actorIndex >= 0) && (actorIndex < Shared.getScene()->_sceneResource->getWorldStats()->numActors)) {
+ Shared.getScene()->setActorPosition(actorIndex, currentCommand->param2, currentCommand->param3);
+ Shared.getScene()->setActorAction(actorIndex, currentCommand->param4);
}
else
debugC(kDebugLevelScripts,
"Requested invalid actor ID:0x%02X in Scene %d Script %d Line %d.",
currentCommand->param1,
- _scene->getSceneIndex(),
+ Shared.getScene()->getSceneIndex(),
_currentLine);
}
break;
@@ -242,33 +239,33 @@ void ScriptManager::processActionList() {
/* 0x0E */ case kEnableActor: {
int actorIndex = 0;
if (currentCommand->param1 == -1)
- ;//actorIndex = _scene->getWorldStats()->playerActor;
+ ;//actorIndex = Shared.getScene()->getWorldStats()->playerActor;
else
actorIndex = currentCommand->param1;
- if (_scene->_sceneResource->getWorldStats()->actors[actorIndex].field_40 == 5) {
+ if (Shared.getScene()->_sceneResource->getWorldStats()->actors[actorIndex].field_40 == 5) {
enableActorSub(actorIndex, 4);
}
}
break;
/* 0x0F */ case kEnableBarriers: {
- int barIdx = _scene->_sceneResource->getBarrierIndexById(currentCommand->param1);
+ int barIdx = Shared.getScene()->_sceneResource->getBarrierIndexById(currentCommand->param1);
uint32 sndIdx = currentCommand->param3;
uint32 v59 = currentCommand->param2;
- if (!_currentScript->counter && _scene->getSceneIndex() != 13 && sndIdx != 0) {
+ if (!_currentScript->counter && Shared.getScene()->getSceneIndex() != 13 && sndIdx != 0) {
// TODO
// Find a script that actually has a valid param3
// to see if this code is accurate :P
ResourcePack *tmpRes = new ResourcePack(12);
- _scene->_sound->playSfx(tmpRes, ((int)(sndIdx != 0) & 5) + 0x80120001);
+ Shared.getSound()->playSfx(tmpRes, ((int)(sndIdx != 0) & 5) + 0x80120001);
delete tmpRes;
}
if (_currentScript->counter >= 3 * v59 - 1) {
_currentScript->counter = 0;
- _scene->_sceneResource->getWorldStats()->barriers[barIdx].field_67C = 0;
+ Shared.getScene()->_sceneResource->getWorldStats()->barriers[barIdx].field_67C = 0;
processActionListSub02(_currentScript, currentCommand, 2);
_currentLoops = 1; // v4 = 1;
} else {
@@ -278,10 +275,10 @@ void ScriptManager::processActionList() {
if (sndIdx) {
v64 = 1;
int v170 = 3 - v62 / v59;
- _scene->_sceneResource->getWorldStats()->barriers[barIdx].field_67C = v170;
+ Shared.getScene()->_sceneResource->getWorldStats()->barriers[barIdx].field_67C = v170;
} else {
v64 = 0;
- _scene->_sceneResource->getWorldStats()->barriers[barIdx].field_67C = v62 / v59 + 1;
+ Shared.getScene()->_sceneResource->getWorldStats()->barriers[barIdx].field_67C = v62 / v59 + 1;
}
processActionListSub02(_currentScript, currentCommand, v64);
@@ -296,14 +293,14 @@ void ScriptManager::processActionList() {
break;
/* 0x11 */ case kDestroyObject: {
- int barrierIndex = _scene->_sceneResource->getBarrierIndexById(currentCommand->param1);
+ int barrierIndex = Shared.getScene()->_sceneResource->getBarrierIndexById(currentCommand->param1);
if (barrierIndex >= 0)
- _scene->_sceneResource->getWorldStats()->barriers[barrierIndex].flags &= 0xFFFFDF; // TODO - enums for flags (0x20 is visible/playing?)
+ Shared.getScene()->_sceneResource->getWorldStats()->barriers[barrierIndex].flags &= 0xFFFFDF; // TODO - enums for flags (0x20 is visible/playing?)
else
debugC(kDebugLevelScripts,
"Requested invalid object ID:0x%02X in Scene %d Line %d.",
currentCommand->param1,
- _scene->getSceneIndex(),
+ Shared.getScene()->getSceneIndex(),
_currentLine);
}
break;
@@ -347,7 +344,7 @@ void ScriptManager::processActionList() {
/* 0x2E */ case kStopAllBarriersSounds:
// TODO: do this for all barriers that have sfx playing
- _scene->_sound->stopSfx();
+ Shared.getSound()->stopSfx();
break;
/* 0x2F */ //case kSetActionFlag01:
@@ -355,7 +352,7 @@ void ScriptManager::processActionList() {
/* 0x31 */ //case kResetSceneRect:
/* 0x32 */ //case kChangeMusicById:
/* 0x33 */ case kStopMusic:
- _scene->_sound->stopMusic();
+ Shared.getSound()->stopMusic();
break;
/* 0x34 */ //case k_unk34_Status:
@@ -363,8 +360,8 @@ void ScriptManager::processActionList() {
/* 0x36 */ //case k_unk36:
/* 0x37 */ case kRunBlowUpPuzzle: {
int blowUpPuzzleIdx = currentCommand->param1;
- _scene->setBlowUpPuzzle(new BlowUpPuzzleVCR(_scene));
- _scene->getBlowUpPuzzle()->openBlowUp();
+ Shared.getScene()->setBlowUpPuzzle(new BlowUpPuzzleVCR());
+ Shared.getScene()->getBlowUpPuzzle()->openBlowUp();
}
break;
@@ -374,15 +371,15 @@ void ScriptManager::processActionList() {
/* 0x3B */ //case k_unk3B_PALETTE_MOD:
/* 0x3C */ //case k_unk3C_CMP_VAL:
/* 0x3D */ case kWaitUntilFramePlayed: {
- int barrierIndex = _scene->_sceneResource->getBarrierIndexById(currentCommand->param1);
+ int barrierIndex = Shared.getScene()->_sceneResource->getBarrierIndexById(currentCommand->param1);
if (barrierIndex >= 0) {
uint32 frameNum = 0;
if (currentCommand->param2 == -1)
- frameNum = _scene->_sceneResource->getWorldStats()->barriers[barrierIndex].frameCount - 1;
+ frameNum = Shared.getScene()->_sceneResource->getWorldStats()->barriers[barrierIndex].frameCount - 1;
else
frameNum = currentCommand->param2;
- if (_scene->_sceneResource->getWorldStats()->barriers[barrierIndex].tickCount < frameNum) {
+ if (Shared.getScene()->_sceneResource->getWorldStats()->barriers[barrierIndex].tickCount < frameNum) {
lineIncrement = 0;
waitCycle = true;
}
@@ -390,7 +387,7 @@ void ScriptManager::processActionList() {
debugC(kDebugLevelScripts,
"Requested invalid object ID:0x%02X in Scene %d Line %d.",
currentCommand->param1,
- _scene->getSceneIndex(),
+ Shared.getScene()->getSceneIndex(),
_currentLine);
}
break;
@@ -400,7 +397,7 @@ void ScriptManager::processActionList() {
if(barSize >= 22) {
currentCommand->param1 = 0;
} else {
- _scene->_screen->drawWideScreen(4 * barSize);
+ Shared.getScreen()->drawWideScreen(4 * barSize);
currentCommand->param1++;
}
}
@@ -414,16 +411,16 @@ void ScriptManager::processActionList() {
if ((int)sndIdx >= 0) {
if (sndIdx >= 259) {
sndIdx -= 9;
- _scene->_sound->playSfx(_scene->_speechPack, sndIdx - 0x7FFD0000);
+ Shared.getSound()->playSfx(Shared.getScene()->_speechPack, sndIdx - 0x7FFD0000);
} else {
- _scene->_sound->playSfx(_scene->_speechPack, sndIdx);
+ Shared.getSound()->playSfx(Shared.getScene()->_speechPack, sndIdx);
}
} else
debugC(kDebugLevelScripts,
"Requested invalid sound ID:0x%02X in Scene %d Line %d.",
currentCommand->param1,
- _scene->getSceneIndex(),
+ Shared.getScene()->getSceneIndex(),
_currentLine);
}
break;
@@ -442,11 +439,11 @@ void ScriptManager::processActionList() {
int actorIdx = currentCommand->param1;
int fieldType = currentCommand->param2;
if(fieldType) {
- if(_scene->getResources()->getWorldStats()->actors[actorIdx].field_40 < 11) {
- _scene->getResources()->getWorldStats()->actors[actorIdx].field_40 = 14;
+ if(Shared.getScene()->getResources()->getWorldStats()->actors[actorIdx].field_40 < 11) {
+ Shared.getScene()->getResources()->getWorldStats()->actors[actorIdx].field_40 = 14;
}
} else {
- _scene->getResources()->getWorldStats()->actors[actorIdx].field_40 = 4;
+ Shared.getScene()->getResources()->getWorldStats()->actors[actorIdx].field_40 = 4;
}
}
break;
@@ -454,7 +451,7 @@ void ScriptManager::processActionList() {
/* 0x4E */ //case k_unk4E_RANDOM_COMMAND:
/* 0x4F */ case kClearScreen:
if(currentCommand->param1) {
- _scene->_screen->clearScreen();
+ Shared.getScreen()->clearScreen();
}
break;
@@ -482,7 +479,7 @@ void ScriptManager::processActionList() {
debugC(kDebugLevelScripts,
"Unhandled opcode 0x%02X in Scene %d Line %d.",
currentCommand->opcode,
- _scene->getSceneIndex(),
+ Shared.getScene()->getSceneIndex(),
_currentLine);
break;
@@ -516,14 +513,14 @@ void ScriptManager::processActionListSub02(ActionDefinitions* script, ActionComm
int v8 = command->param4;
for (int i = 7; i > 0; i--) {
- barrierIdx = _scene->getResources()->getBarrierIndexById(v8);
- if (barrierIdx)
- _scene->getResources()->getWorldStats()->barriers[barrierIdx].field_67C = 0;
+ barrierIdx = Shared.getScene()->getResources()->getBarrierIndexById(v8);
+ if (barrierIdx >= 0)
+ Shared.getScene()->getResources()->getWorldStats()->barriers[barrierIdx].field_67C = 0;
v8 += 4;
}
}
// TODO
- switch (_scene->getSceneIndex()) {
+ switch (Shared.getScene()->getSceneIndex()) {
case 7:
warning("Scene 7 / v4 != 0 Not Implemented");
break;
@@ -546,13 +543,13 @@ void ScriptManager::processActionListSub02(ActionDefinitions* script, ActionComm
int v13 = command->param4;
int v4 = script->counter / command->param2 + 4;
for (int i = 7; i > 0; i--) {
- barrierIdx = _scene->getResources()->getBarrierIndexById(v13);
+ barrierIdx = Shared.getScene()->getResources()->getBarrierIndexById(v13);
if (barrierIdx >= 0)
- _scene->getResources()->getWorldStats()->barriers[barrierIdx].field_67C = v4;
+ Shared.getScene()->getResources()->getWorldStats()->barriers[barrierIdx].field_67C = v4;
v13 += 4;
}
// TODO
- switch (_scene->getSceneIndex()) {
+ switch (Shared.getScene()->getSceneIndex()) {
case 7:
warning("Scene 7 / v4 = 0 Not Implemented");
break;
diff --git a/engines/asylum/scriptman.h b/engines/asylum/scriptman.h
index 1f46a0ae9e..64d06f8784 100644
--- a/engines/asylum/scriptman.h
+++ b/engines/asylum/scriptman.h
@@ -39,7 +39,6 @@ public:
void processActionList();
- void setScene(Scene *scene);
void setScript(ActionDefinitions *action);
void setScriptIndex(uint32 index);
@@ -70,7 +69,6 @@ private:
int _delayedVideoIndex;
bool _allowInput;
- Scene *_scene;
ActionDefinitions *_currentScript;
// NOTE
diff --git a/engines/asylum/utilities.cpp b/engines/asylum/shared.cpp
similarity index 88%
rename from engines/asylum/utilities.cpp
rename to engines/asylum/shared.cpp
index 5afdf84d05..c17943646b 100644
--- a/engines/asylum/utilities.cpp
+++ b/engines/asylum/shared.cpp
@@ -23,28 +23,28 @@
*
*/
-#include "asylum/utilities.h"
+#include "asylum/shared.h"
#include "common/system.h"
-DECLARE_SINGLETON(Asylum::Utilities);
+DECLARE_SINGLETON(Asylum::SharedResources);
namespace Asylum {
static bool g_initialized = false;
-Utilities::Utilities() {
+SharedResources::SharedResources() {
if (!g_initialized) {
g_initialized = true;
}
}
-Utilities::~Utilities() {
+SharedResources::~SharedResources() {
g_initialized = false;
}
-bool Utilities::pointInPoly(PolyDefinitions *poly, int x, int y) {
+bool SharedResources::pointInPoly(PolyDefinitions *poly, int x, int y) {
// Copied from backends/vkeybd/polygon.cpp
int yflag0;
int yflag1;
diff --git a/engines/asylum/shared.h b/engines/asylum/shared.h
new file mode 100644
index 0000000000..3902f51ac0
--- /dev/null
+++ b/engines/asylum/shared.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.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#ifndef ASYLUM_SHARED_H
+#define ASYLUM_SHARED_H_
+
+#include "common/singleton.h"
+
+#include "asylum/sceneres.h"
+
+namespace Asylum {
+
+/**
+ * Shared Resources are classes that are instantiated at the engine level.
+ * Binding them to this singleton simplifies implementation of new classes
+ * that will require access to common interfaces and tools.
+ *
+ * A candidate for a shared resource would be any class that will be utilized
+ * by one-to-many instances of another class, but will never need more than
+ * one instance itself.
+ *
+ * Each component herin could technically be a singleton unto itself, but
+ * by using this method, destruction can be handled by the engine.
+ */
+class SharedResources: public Common::Singleton<SharedResources> {
+public:
+
+ void setVideo(Video* video) { _video = video; }
+ Video* getVideo() { return _video; }
+
+ void setScreen(Screen* screen) { _screen = screen; }
+ Screen* getScreen() { return _screen; }
+
+ void setSound(Sound* sound) { _sound = sound; }
+ Sound* getSound() { return _sound; }
+
+ void setScene(Scene* scene) { _scene = scene; }
+ Scene* getScene() { return _scene; }
+
+ bool pointInPoly(PolyDefinitions *poly, int x, int y);
+
+private:
+ friend class Common::Singleton<SingletonBaseType>;
+ SharedResources();
+ ~SharedResources();
+
+ Video *_video;
+ Screen *_screen;
+ Sound *_sound;
+ Scene *_scene;
+
+}; // end of class SharedResources
+
+#define Shared (::Asylum::SharedResources::instance())
+
+} // end of namespace Asylum
+
+#endif
diff --git a/engines/asylum/utilities.h b/engines/asylum/utilities.h
deleted file mode 100644
index 2c7d5b39a1..0000000000
--- a/engines/asylum/utilities.h
+++ /dev/null
@@ -1,49 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * $URL$
- * $Id$
- *
- */
-
-#ifndef ASYLUM_UTILITIES_H_
-#define ASYLUM_UTILITIES_H_
-
-#include "common/singleton.h"
-
-#include "asylum/sceneres.h"
-
-namespace Asylum {
-
-class Utilities: public Common::Singleton<Utilities> {
-public:
- bool pointInPoly(PolyDefinitions *poly, int x, int y);
-
-private:
- friend class Common::Singleton<SingletonBaseType>;
- Utilities();
- ~Utilities();
-}; // end of class Utilities
-
-#define Utils (::Asylum::Utilities::instance())
-
-} // end of namespace Asylum
-
-#endif
Commit: 26d456e5be3c0e5ded6a1fa1618546bd863c0644
https://github.com/scummvm/scummvm/commit/26d456e5be3c0e5ded6a1fa1618546bd863c0644
Author: Alex Bevilacqua (alexbevi at gmail.com)
Date: 2021-05-17T15:35:40+02:00
Commit Message:
ASYLUM: Game startup sequence added, and some minor cleanups.
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@293 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/actor.cpp
engines/asylum/asylum.cpp
engines/asylum/asylum.h
engines/asylum/scene.cpp
diff --git a/engines/asylum/actor.cpp b/engines/asylum/actor.cpp
index 11af755675..33eeb1b985 100644
--- a/engines/asylum/actor.cpp
+++ b/engines/asylum/actor.cpp
@@ -136,11 +136,11 @@ void MainActor::setWalkArea(ActionItem *target) {
if (_currentWalkArea != target) {
ScriptMan.setScriptIndex(target->actionListIdx1);
_currentWalkArea = target;
+ debugC(kDebugLevelScripts, "%s", target->name);
}
}
void MainActor::walkTo(uint16 x, uint16 y) {
- // TODO: pathfinding! The character can walk literally anywhere
int newAction = _currentAction;
// step is the increment by which to move the
@@ -150,6 +150,7 @@ void MainActor::walkTo(uint16 x, uint16 y) {
uint16 newX = _actorX;
uint16 newY = _actorY;
bool done = false;
+
// Walking left...
if (x < _actorX) {
newAction = kWalkW;
@@ -191,16 +192,15 @@ void MainActor::walkTo(uint16 x, uint16 y) {
}
// DEBUGGING
- // Show registration point from
- // which we're calculating the
+ // Show registration point from which we're calculating the
// actor's barrier hit-test
Graphics::Surface surface;
surface.create(5, 5, 1);
Common::Rect rect;
- rect.top = newY;
- rect.left = newX;
- rect.right = newX;
+ rect.top = newY;
+ rect.left = newX;
+ rect.right = newX;
rect.bottom = newY + 4;
surface.frameRect(rect, 0x33);
@@ -208,6 +208,11 @@ void MainActor::walkTo(uint16 x, uint16 y) {
surface.free();
+ // TODO Basic pathfinding implementation is done. Now it needs to be refined to
+ // actually make it playable. The logic is currently VERY rigid, so you have to have
+ // the actor at the PERFECT spot to be able to intersect a walk region and move to
+ // the next one.
+
int availableAreas[5];
int areaPtr = 0;
ActionItem *area;
diff --git a/engines/asylum/asylum.cpp b/engines/asylum/asylum.cpp
index 0e5e0badc9..24aa6c987c 100644
--- a/engines/asylum/asylum.cpp
+++ b/engines/asylum/asylum.cpp
@@ -93,38 +93,40 @@ Common::Error AsylumEngine::init() {
}
Common::Error AsylumEngine::go() {
- // initializing game
// TODO: save dialogue key codes into sntrm_k.txt (need to figure out why they use such thing)
// TODO: load startup configurations (address 0041A970)
// TODO: init unknown game stuffs (address 0040F430)
// TODO: if savegame exists on folder, than start NewGame()
- // Play intro movie
- // Disabled for quick testing
- //_video->playVideo(0, kSubtitlesOn); // Note: this video has no subtitles
-
- // Play first chapter movie (for testing)
- //_video->playVideo(1, kSubtitlesOn);
-
// Set up the game's main scene
_scene = new Scene(5);
Shared.setScene(_scene);
+ // XXX This is just here for testing purposes. It is also defined
+ // in the processActionList() method when the necessary action is fired.
+ // Once the blowup puzzle testing is removed from checkForEvent(), this
+ // can be removed as well.
_scene->setBlowUpPuzzle(new BlowUpPuzzleVCR()); // this will be done by a Script command
- // TODO This can probably also be rolled into the scene constructor.
+ // XXX This can probably also be rolled into the scene constructor.
// Investigate if this will fuck up the execution sequence though :P
ScriptMan.setScript(_scene->getDefaultActionList());
// Set up main menu
_mainMenu = new MainMenu();
-
// XXX Testing
_encounter = new Encounter(_scene);
+ // TODO you should be able to skip this if you want. The original
+ // allows this through the /SKIP command line argument.
+ // Also, this routine is used to set game flags 4 and 12, so if we're
+ // skipping the intro, but not loading a save file, those flags
+ // need to be set somewhere else.
+ playIntro();
+
// Enter first scene
- _scene->enterScene();
+ //_scene->enterScene();
while (!shouldQuit()) {
checkForEvent(true);
@@ -145,6 +147,41 @@ void AsylumEngine::waitForTimer(int msec_delay) {
}
}
+void AsylumEngine::playIntro() {
+ _video->playVideo(1, kSubtitlesOn);
+ if (_scene->getResources()->getWorldStats()->musicCurrentResId != 0xFFFFFD66)
+ _sound->playMusic(_scene->getResourceMusicPack(),
+ _scene->getResources()->getWorldStats()->musicCurrentResId);
+
+ _screen->clearScreen();
+
+ ScriptMan.setGameFlag(4);
+ ScriptMan.setGameFlag(12);
+
+ ResourcePack *introRes = new ResourcePack(18);
+
+ _sound->playSfx(introRes, 7);
+
+ if (_sound->isSfxActive()) {
+ while( _sound->isSfxActive()) {
+ ;
+ }
+ }
+
+ delete introRes;
+
+ // TODO Since we've currently only got one sfx handle to play with in
+ // the sound class, entering the scene overwrites the "alarm" loop.
+ // This sound is technically supposed to play until the actor disables
+ // the alarm by flipping the switch. The sound class needs to be extended
+ // to be able to handle multiple handles.
+ // The currently active sound resources can probably also be buffered into
+ // the scene's soundResId[] array (seems that's the way the original worked,
+ // especially when you examine isSoundinList() or isSoundPlaying())
+
+ _scene->enterScene();
+}
+
void AsylumEngine::checkForEvent(bool doUpdate) {
Common::Event ev;
@@ -167,7 +204,7 @@ void AsylumEngine::checkForEvent(bool doUpdate) {
// XXX Encounter TEST
if (ev.kbd.keycode == Common::KEYCODE_e) {
- _encounter->run(1, 1584, 1584, 0);
+ //_encounter->run(1, 1584, 1584, 0);
}
// FIXME: TEST ONLY
@@ -232,6 +269,7 @@ void AsylumEngine::processDelayedEvents() {
delete _scene;
_scene = new Scene(sceneIdx);
+ Shared.setScene(_scene);
_scene->enterScene();
ScriptMan.setDelayedSceneIndex(-1);
diff --git a/engines/asylum/asylum.h b/engines/asylum/asylum.h
index d29ff6bf5a..3ca98816dc 100644
--- a/engines/asylum/asylum.h
+++ b/engines/asylum/asylum.h
@@ -77,6 +77,7 @@ private:
void waitForTimer(int msec_delay);
void updateMouseCursor();
void processDelayedEvents();
+ void playIntro();
Common::Language _language;
Common::RandomSource _rnd;
diff --git a/engines/asylum/scene.cpp b/engines/asylum/scene.cpp
index 65f0829838..e4d703add8 100644
--- a/engines/asylum/scene.cpp
+++ b/engines/asylum/scene.cpp
@@ -119,7 +119,7 @@ ActionDefinitions* Scene::getActionList(int actionListIndex) {
void Scene::setActorPosition(int actorIndex, int x, int y) {
if ((actorIndex >= 0) && (actorIndex < (int)_sceneResource->getWorldStats()->numActors)) {
_sceneResource->getWorldStats()->actors[actorIndex].boundingRect.left = x;
- _sceneResource->getWorldStats()->actors[actorIndex].boundingRect.top = y;
+ _sceneResource->getWorldStats()->actors[actorIndex].boundingRect.top = y;
}
// FIXME - Remove this once mainActor uses proper actor info
@@ -280,7 +280,7 @@ void Scene::update() {
// DEBUG
// Force the screen to scroll if the mouse approaches the edges
- // debugScreenScrolling(bg);
+ //debugScreenScrolling(bg);
// Copy the background to the back buffer before updating the scene animations
Shared.getScreen()->copyToBackBuffer(((byte *)bg->surface.pixels) + _startY * bg->surface.w + _startX,
@@ -309,15 +309,11 @@ void Scene::update() {
PolyDefinitions poly = _sceneResource->getGamePolygons()->polygons[area->polyIdx];
if (Shared.pointInPoly(&poly, mainActor->_actorX, mainActor->_actorY)) {
debugShowWalkRegion(&poly);
- mainActor->setWalkArea(area);
//break;
}
}
}
-
- // TESTING
- // Main actor walking
if (!_rightButton) {
if (_sceneResource->getWorldStats()->actors[0].flags & 0x01) { // TESTING - only draw if visible flag
// Check if the character was walking before the right-button
@@ -438,7 +434,7 @@ void Scene::copyToBackBufferClipped(Graphics::Surface *surface, int x, int y) {
startX = _startX;
if (surface->h > 480)
startY = _startY;
-
+
Shared.getScreen()->copyToBackBufferWithTransparency(
((byte*)surface->pixels) +
startY * surface->pitch +
Commit: f75fea2be642e41d1a042abf9a168268171801b8
https://github.com/scummvm/scummvm/commit/f75fea2be642e41d1a042abf9a168268171801b8
Author: Alex Bevilacqua (alexbevi at gmail.com)
Date: 2021-05-17T15:35:40+02:00
Commit Message:
ASYLUM: formatting
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@294 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/asylum.cpp
diff --git a/engines/asylum/asylum.cpp b/engines/asylum/asylum.cpp
index 24aa6c987c..91f3a401b5 100644
--- a/engines/asylum/asylum.cpp
+++ b/engines/asylum/asylum.cpp
@@ -163,7 +163,7 @@ void AsylumEngine::playIntro() {
_sound->playSfx(introRes, 7);
if (_sound->isSfxActive()) {
- while( _sound->isSfxActive()) {
+ while (_sound->isSfxActive()) {
;
}
}
@@ -202,12 +202,7 @@ void AsylumEngine::checkForEvent(bool doUpdate) {
return;
}
- // XXX Encounter TEST
- if (ev.kbd.keycode == Common::KEYCODE_e) {
- //_encounter->run(1, 1584, 1584, 0);
- }
-
- // FIXME: TEST ONLY
+ // XXX: TEST ONLY
if (ev.kbd.keycode == Common::KEYCODE_b) {
//_mainMenu->closeMenu();
_scene->getBlowUpPuzzle()->openBlowUp();
@@ -222,25 +217,23 @@ void AsylumEngine::checkForEvent(bool doUpdate) {
}
if (doUpdate) {
- if (_mainMenu->isActive() || _scene->isActive() || _scene->getBlowUpPuzzle()->isActive()) {
+ if (_mainMenu->isActive() || _scene->isActive() || _scene->getBlowUpPuzzle()->isActive())
// Copy background image
_screen->copyBackBufferToScreen();
- }
if (_console->isAttached())
_console->onFrame();
}
- if (_mainMenu->isActive()) {
+ if (_mainMenu->isActive())
// Main menu active, pass events to it
_mainMenu->handleEvent(&ev, doUpdate);
- } else if (_scene->isActive()) {
+ else if (_scene->isActive())
// Pass events to the game
_scene->handleEvent(&ev, doUpdate);
- } else if (_scene->getBlowUpPuzzle()->isActive()) {
+ else if (_scene->getBlowUpPuzzle()->isActive())
// Pass events to BlowUp Puzzles
_scene->getBlowUpPuzzle()->handleEvent(&ev, doUpdate);
- }
}
void AsylumEngine::processDelayedEvents() {
@@ -252,11 +245,10 @@ void AsylumEngine::processDelayedEvents() {
_video->playVideo(videoIdx, kSubtitlesOn);
ScriptMan.setDelayedVideoIndex(-1);
- if (_mainMenu->isActive()) {
+ if (_mainMenu->isActive())
_mainMenu->openMenu();
- } else if (_scene->isActive()) {
+ else if (_scene->isActive())
_scene->enterScene();
- }
}
// check for a delayed scene change
Commit: e629ab0934f1318431c8bcc664f851144c754f8d
https://github.com/scummvm/scummvm/commit/e629ab0934f1318431c8bcc664f851144c754f8d
Author: Alex Bevilacqua (alexbevi at gmail.com)
Date: 2021-05-17T15:35:41+02:00
Commit Message:
ASYLUM: Properly abstract remaining scene variable access and remove friend association to ScriptMan
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@295 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/scene.h
engines/asylum/scriptman.cpp
diff --git a/engines/asylum/scene.h b/engines/asylum/scene.h
index 98c6b16cc3..5f54efda8d 100644
--- a/engines/asylum/scene.h
+++ b/engines/asylum/scene.h
@@ -70,7 +70,9 @@ public:
SceneResource* getResources() { return _sceneResource; }
ResourcePack* getResourcePack() { return _resPack; }
- ResourcePack* getResourceMusicPack() { return _musPack; }
+ ResourcePack* getMusicPack() { return _musPack; }
+ ResourcePack* getSpeechPack() { return _speechPack; }
+
GraphicResource* getGraphicResource(uint32 entry) { return new GraphicResource(_resPack, entry); }
BlowUpPuzzle* getBlowUpPuzzle() { return _blowUp; }
@@ -125,8 +127,6 @@ private:
void debugShowPolygons();
void debugShowBarriers();
void debugShowWalkRegion(PolyDefinitions *poly);
-
- friend class ScriptManager;
}; // end of class Scene
} // end of namespace Asylum
diff --git a/engines/asylum/scriptman.cpp b/engines/asylum/scriptman.cpp
index 0f273bfc9d..1e7a1ed641 100644
--- a/engines/asylum/scriptman.cpp
+++ b/engines/asylum/scriptman.cpp
@@ -165,9 +165,9 @@ void ScriptManager::processActionList() {
break;
/* 0x07 */ case kPlayAnimation: {
- int barrierIndex = Shared.getScene()->_sceneResource->getBarrierIndexById(currentCommand->param1);
+ int barrierIndex = Shared.getScene()->getResources()->getBarrierIndexById(currentCommand->param1);
if (barrierIndex >= 0)
- Shared.getScene()->_sceneResource->getWorldStats()->barriers[barrierIndex].flags |= 0x20; // TODO - enums for flags (0x20 is visible/playing?)
+ Shared.getScene()->getResources()->getWorldStats()->barriers[barrierIndex].flags |= 0x20; // TODO - enums for flags (0x20 is visible/playing?)
else
debugC(kDebugLevelScripts,
"Requested invalid object ID:0x%02X in Scene %d Line %d.",
@@ -185,7 +185,7 @@ void ScriptManager::processActionList() {
else
actorIndex = currentCommand->param1;
- if ((actorIndex >= 0) && (actorIndex < Shared.getScene()->_sceneResource->getWorldStats()->numActors))
+ if ((actorIndex >= 0) && (actorIndex < Shared.getScene()->getResources()->getWorldStats()->numActors))
Shared.getScene()->actorVisible(actorIndex, false);
else
debugC(kDebugLevelScripts,
@@ -203,7 +203,7 @@ void ScriptManager::processActionList() {
else
actorIndex = currentCommand->param1;
- if ((actorIndex >= 0) && (actorIndex < Shared.getScene()->_sceneResource->getWorldStats()->numActors))
+ if ((actorIndex >= 0) && (actorIndex < Shared.getScene()->getResources()->getWorldStats()->numActors))
Shared.getScene()->actorVisible(actorIndex, true);
else
debugC(kDebugLevelScripts,
@@ -221,7 +221,7 @@ void ScriptManager::processActionList() {
else
actorIndex = currentCommand->param1;
- if ((actorIndex >= 0) && (actorIndex < Shared.getScene()->_sceneResource->getWorldStats()->numActors)) {
+ if ((actorIndex >= 0) && (actorIndex < Shared.getScene()->getResources()->getWorldStats()->numActors)) {
Shared.getScene()->setActorPosition(actorIndex, currentCommand->param2, currentCommand->param3);
Shared.getScene()->setActorAction(actorIndex, currentCommand->param4);
}
@@ -243,14 +243,14 @@ void ScriptManager::processActionList() {
else
actorIndex = currentCommand->param1;
- if (Shared.getScene()->_sceneResource->getWorldStats()->actors[actorIndex].field_40 == 5) {
+ if (Shared.getScene()->getResources()->getWorldStats()->actors[actorIndex].field_40 == 5) {
enableActorSub(actorIndex, 4);
}
}
break;
/* 0x0F */ case kEnableBarriers: {
- int barIdx = Shared.getScene()->_sceneResource->getBarrierIndexById(currentCommand->param1);
+ int barIdx = Shared.getScene()->getResources()->getBarrierIndexById(currentCommand->param1);
uint32 sndIdx = currentCommand->param3;
uint32 v59 = currentCommand->param2;
@@ -265,7 +265,7 @@ void ScriptManager::processActionList() {
if (_currentScript->counter >= 3 * v59 - 1) {
_currentScript->counter = 0;
- Shared.getScene()->_sceneResource->getWorldStats()->barriers[barIdx].field_67C = 0;
+ Shared.getScene()->getResources()->getWorldStats()->barriers[barIdx].field_67C = 0;
processActionListSub02(_currentScript, currentCommand, 2);
_currentLoops = 1; // v4 = 1;
} else {
@@ -275,10 +275,10 @@ void ScriptManager::processActionList() {
if (sndIdx) {
v64 = 1;
int v170 = 3 - v62 / v59;
- Shared.getScene()->_sceneResource->getWorldStats()->barriers[barIdx].field_67C = v170;
+ Shared.getScene()->getResources()->getWorldStats()->barriers[barIdx].field_67C = v170;
} else {
v64 = 0;
- Shared.getScene()->_sceneResource->getWorldStats()->barriers[barIdx].field_67C = v62 / v59 + 1;
+ Shared.getScene()->getResources()->getWorldStats()->barriers[barIdx].field_67C = v62 / v59 + 1;
}
processActionListSub02(_currentScript, currentCommand, v64);
@@ -293,9 +293,9 @@ void ScriptManager::processActionList() {
break;
/* 0x11 */ case kDestroyObject: {
- int barrierIndex = Shared.getScene()->_sceneResource->getBarrierIndexById(currentCommand->param1);
+ int barrierIndex = Shared.getScene()->getResources()->getBarrierIndexById(currentCommand->param1);
if (barrierIndex >= 0)
- Shared.getScene()->_sceneResource->getWorldStats()->barriers[barrierIndex].flags &= 0xFFFFDF; // TODO - enums for flags (0x20 is visible/playing?)
+ Shared.getScene()->getResources()->getWorldStats()->barriers[barrierIndex].flags &= 0xFFFFDF; // TODO - enums for flags (0x20 is visible/playing?)
else
debugC(kDebugLevelScripts,
"Requested invalid object ID:0x%02X in Scene %d Line %d.",
@@ -371,15 +371,15 @@ void ScriptManager::processActionList() {
/* 0x3B */ //case k_unk3B_PALETTE_MOD:
/* 0x3C */ //case k_unk3C_CMP_VAL:
/* 0x3D */ case kWaitUntilFramePlayed: {
- int barrierIndex = Shared.getScene()->_sceneResource->getBarrierIndexById(currentCommand->param1);
+ int barrierIndex = Shared.getScene()->getResources()->getBarrierIndexById(currentCommand->param1);
if (barrierIndex >= 0) {
uint32 frameNum = 0;
if (currentCommand->param2 == -1)
- frameNum = Shared.getScene()->_sceneResource->getWorldStats()->barriers[barrierIndex].frameCount - 1;
+ frameNum = Shared.getScene()->getResources()->getWorldStats()->barriers[barrierIndex].frameCount - 1;
else
frameNum = currentCommand->param2;
- if (Shared.getScene()->_sceneResource->getWorldStats()->barriers[barrierIndex].tickCount < frameNum) {
+ if (Shared.getScene()->getResources()->getWorldStats()->barriers[barrierIndex].tickCount < frameNum) {
lineIncrement = 0;
waitCycle = true;
}
@@ -411,9 +411,9 @@ void ScriptManager::processActionList() {
if ((int)sndIdx >= 0) {
if (sndIdx >= 259) {
sndIdx -= 9;
- Shared.getSound()->playSfx(Shared.getScene()->_speechPack, sndIdx - 0x7FFD0000);
+ Shared.getSound()->playSfx(Shared.getScene()->getSpeechPack(), sndIdx - 0x7FFD0000);
} else {
- Shared.getSound()->playSfx(Shared.getScene()->_speechPack, sndIdx);
+ Shared.getSound()->playSfx(Shared.getScene()->getSpeechPack(), sndIdx);
}
} else
Commit: 9e18edaee36dc88e4a95b0de06661fd5a41a2517
https://github.com/scummvm/scummvm/commit/9e18edaee36dc88e4a95b0de06661fd5a41a2517
Author: Alexandre Fontoura (alexandrefontoura at gmail.com)
Date: 2021-05-17T15:35:41+02:00
Commit Message:
ASYLUM: Some work on PlayAnimation command. It will only work with a proper BarrierUpdate according with each flag type.
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@296 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/asylum.cpp
engines/asylum/scene.cpp
engines/asylum/sceneres.cpp
engines/asylum/sceneres.h
engines/asylum/scriptman.cpp
engines/asylum/scriptman.h
diff --git a/engines/asylum/asylum.cpp b/engines/asylum/asylum.cpp
index 91f3a401b5..def9933022 100644
--- a/engines/asylum/asylum.cpp
+++ b/engines/asylum/asylum.cpp
@@ -123,10 +123,10 @@ Common::Error AsylumEngine::go() {
// Also, this routine is used to set game flags 4 and 12, so if we're
// skipping the intro, but not loading a save file, those flags
// need to be set somewhere else.
- playIntro();
+ //playIntro();
// Enter first scene
- //_scene->enterScene();
+ _scene->enterScene();
while (!shouldQuit()) {
checkForEvent(true);
@@ -150,7 +150,7 @@ void AsylumEngine::waitForTimer(int msec_delay) {
void AsylumEngine::playIntro() {
_video->playVideo(1, kSubtitlesOn);
if (_scene->getResources()->getWorldStats()->musicCurrentResId != 0xFFFFFD66)
- _sound->playMusic(_scene->getResourceMusicPack(),
+ _sound->playMusic(_scene->getMusicPack(),
_scene->getResources()->getWorldStats()->musicCurrentResId);
_screen->clearScreen();
diff --git a/engines/asylum/scene.cpp b/engines/asylum/scene.cpp
index e4d703add8..a437c4fe2d 100644
--- a/engines/asylum/scene.cpp
+++ b/engines/asylum/scene.cpp
@@ -294,10 +294,10 @@ void Scene::update() {
// This is a hack for scene 1. This really shouldn't be hardcoded, as the
// activation of this barrier should be interpreted by the script manager,
// but at the moment, we're not sure where it is in the script.
- updateBarrier(Shared.getScreen(), _resPack, 1); // inside the middle room
+ updateBarrier(Shared.getScreen(), _resPack, 1); // inside the middle room
for(uint b=0; b < _sceneResource->getWorldStats()->barriers.size(); b++) {
- if ((_sceneResource->getWorldStats()->barriers[b].flags & 0x20) != 0) // TODO - enums for flags (0x20 is visible/playing?)
+ if ((_sceneResource->getWorldStats()->barriers[b].flags & 0x20)) // TODO - enums for flags (0x20 is visible/playing?)
updateBarrier(Shared.getScreen(), _resPack, b);
}
diff --git a/engines/asylum/sceneres.cpp b/engines/asylum/sceneres.cpp
index a4b379e1cb..9ddc214400 100644
--- a/engines/asylum/sceneres.cpp
+++ b/engines/asylum/sceneres.cpp
@@ -52,6 +52,10 @@ BarrierItem* SceneResource::getBarrierById(uint32 id) {
return &_worldStats->barriers[getBarrierIndexById(id)];
}
+BarrierItem* SceneResource::getBarrierByIndex(uint32 idx) {
+ return &_worldStats->barriers[idx];
+}
+
bool SceneResource::load(uint8 sceneIdx) {
char sceneTag[6];
Common::File* fd = new Common::File;
diff --git a/engines/asylum/sceneres.h b/engines/asylum/sceneres.h
index 5830865859..282f869a31 100644
--- a/engines/asylum/sceneres.h
+++ b/engines/asylum/sceneres.h
@@ -73,6 +73,7 @@ public:
int getBarrierIndexById(uint32 id);
BarrierItem* getBarrierById(uint32 id);
+ BarrierItem* getBarrierByIndex(uint32 idx);
private:
diff --git a/engines/asylum/scriptman.cpp b/engines/asylum/scriptman.cpp
index 1e7a1ed641..595e471c26 100644
--- a/engines/asylum/scriptman.cpp
+++ b/engines/asylum/scriptman.cpp
@@ -96,6 +96,26 @@ bool ScriptManager::isGameFlagNotSet(int flag) {
return ((1 << flag % -32) & (unsigned int)_gameFlags[flag / 32]) >> flag % -32 == 0;
}
+// TODO: put this under scene resource
+int ScriptManager::checkBarrierFlags(int barrierId) {
+ int flags = Shared.getScene()->getResources()->getBarrierById(barrierId)->flags;
+ return flags & 1 && (flags & 8 || flags & 0x10000);
+}
+int ScriptManager::setBarrierNextFrame(int barrierId, int barrierFlags) {
+ int barrierIndex = Shared.getScene()->getResources()->getBarrierIndexById(barrierId);
+
+ BarrierItem *barrier = Shared.getScene()->getResources()->getBarrierByIndex(barrierIndex);
+ int newFlag = barrierFlags | 1 | barrier->flags;
+
+ if(newFlag & 0x10000) {
+ barrier->frameIdx = barrier->frameCount - 1;
+ } else {
+ barrier->frameIdx = 0;
+ }
+
+ return barrierIndex;
+}
+
void ScriptManager::processActionList() {
bool done = false, waitCycle = false;
int lineIncrement = 1;
@@ -110,7 +130,6 @@ void ScriptManager::processActionList() {
// TODO - processActionLists has run too many iterations
}
- // TODO: this should be a pointer to allow changes in commands array
ActionCommand *currentCommand = &_currentScript->commands[_currentLine];
switch (currentCommand->opcode) {
@@ -165,6 +184,51 @@ void ScriptManager::processActionList() {
break;
/* 0x07 */ case kPlayAnimation: {
+ /*int barrierId = currentCommand->param1;
+ if(currentCommand->param2 == 2) {
+ if(!checkBarrierFlags(barrierId)) {
+ currentCommand->param2 = 1;
+ return;
+ }
+ lineIncrement = 1;
+ } else {
+ int barrierIndex = Shared.getScene()->getResources()->getBarrierIndexById(barrierId);
+ BarrierItem *barrier = Shared.getScene()->getResources()->getBarrierByIndex(barrierIndex);
+
+ if(currentCommand->param4) { // RECHECK THIS
+ int newBarriedIndex = 213 * barrierIndex;
+ barrier->flags &= 0xFFFEF1C7;
+ Shared.getScene()->getResources()->getBarrierByIndex(2*newBarriedIndex)->flags = barrier->flags | 0x20;
+ } else if(currentCommand->param3) {
+ barrier->flags &= 0xFFFEF1C7;
+ barrier->flags |= 0x10000;
+ } else {
+ barrier->flags &= 0x10000;
+ if(barrier->flags == 0) {
+ barrier->flags &= 0x10E38;
+ if(barrier->flags == 0) {
+ barrier->flags |= 8;
+ }
+ } else {
+ barrier->flags |= 8;
+ barrier->flags &= 0xFFFEFFFF;
+ }
+ }
+
+ setBarrierNextFrame(barrierId, barrier->flags);
+
+ if(barrier->field_688 == 1) {
+ // TODO: get barrier position
+ }
+
+ if(currentCommand->param2) {
+ currentCommand->param2 = 2;
+ lineIncrement = 1;
+ }
+ }*/
+
+
+ // TODO: take this part of the code when the updateBarrier function is like original and decomment the above code
int barrierIndex = Shared.getScene()->getResources()->getBarrierIndexById(currentCommand->param1);
if (barrierIndex >= 0)
Shared.getScene()->getResources()->getWorldStats()->barriers[barrierIndex].flags |= 0x20; // TODO - enums for flags (0x20 is visible/playing?)
diff --git a/engines/asylum/scriptman.h b/engines/asylum/scriptman.h
index 64d06f8784..06d6a284cc 100644
--- a/engines/asylum/scriptman.h
+++ b/engines/asylum/scriptman.h
@@ -56,6 +56,9 @@ public:
void toggleGameFlag(int flag);
bool isGameFlagSet(int flag);
bool isGameFlagNotSet(int flag);
+
+ int checkBarrierFlags(int barrierId);
+ int setBarrierNextFrame(int barrierId, int barrierFlags);
private:
friend class Common::Singleton<SingletonBaseType>;
Commit: bffebfd83052101a76b78cd4bc89e2d7a524f6c2
https://github.com/scummvm/scummvm/commit/bffebfd83052101a76b78cd4bc89e2d7a524f6c2
Author: Alexandre Fontoura (alexandrefontoura at gmail.com)
Date: 2021-05-17T15:35:41+02:00
Commit Message:
ASYLUM: More work on PlayAnimations. Still playing all animation initially (need proper updateBarrier).
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@297 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/scene.cpp
engines/asylum/scriptman.cpp
diff --git a/engines/asylum/scene.cpp b/engines/asylum/scene.cpp
index a437c4fe2d..4c3f560e9d 100644
--- a/engines/asylum/scene.cpp
+++ b/engines/asylum/scene.cpp
@@ -299,6 +299,10 @@ void Scene::update() {
for(uint b=0; b < _sceneResource->getWorldStats()->barriers.size(); b++) {
if ((_sceneResource->getWorldStats()->barriers[b].flags & 0x20)) // TODO - enums for flags (0x20 is visible/playing?)
updateBarrier(Shared.getScreen(), _resPack, b);
+
+ if (_sceneResource->getWorldStats()->barriers[b].flags & 8) {
+ updateBarrier(Shared.getScreen(), _resPack, b);
+ }
}
// DEBUGGING
@@ -467,6 +471,7 @@ void Scene::updateBarrier(Screen *screen, ResourcePack *res, uint8 barrierIndex)
barrier.tickCount++;
} else {
barrier.tickCount = barrier.frameIdx;
+ barrier.flags &= 0xFFFFFFF7;
}
_sceneResource->getWorldStats()->barriers[barrierIndex] = barrier;
diff --git a/engines/asylum/scriptman.cpp b/engines/asylum/scriptman.cpp
index 595e471c26..239aad0be7 100644
--- a/engines/asylum/scriptman.cpp
+++ b/engines/asylum/scriptman.cpp
@@ -184,7 +184,7 @@ void ScriptManager::processActionList() {
break;
/* 0x07 */ case kPlayAnimation: {
- /*int barrierId = currentCommand->param1;
+ int barrierId = currentCommand->param1;
if(currentCommand->param2 == 2) {
if(!checkBarrierFlags(barrierId)) {
currentCommand->param2 = 1;
@@ -225,11 +225,11 @@ void ScriptManager::processActionList() {
currentCommand->param2 = 2;
lineIncrement = 1;
}
- }*/
+ }
// TODO: take this part of the code when the updateBarrier function is like original and decomment the above code
- int barrierIndex = Shared.getScene()->getResources()->getBarrierIndexById(currentCommand->param1);
+ /*int barrierIndex = Shared.getScene()->getResources()->getBarrierIndexById(currentCommand->param1);
if (barrierIndex >= 0)
Shared.getScene()->getResources()->getWorldStats()->barriers[barrierIndex].flags |= 0x20; // TODO - enums for flags (0x20 is visible/playing?)
else
@@ -237,7 +237,7 @@ void ScriptManager::processActionList() {
"Requested invalid object ID:0x%02X in Scene %d Line %d.",
currentCommand->param1,
Shared.getScene()->getSceneIndex(),
- _currentLine);
+ _currentLine);*/
}
break;
Commit: f48ab391ac508122b63751c2a3acba65645d05ce
https://github.com/scummvm/scummvm/commit/f48ab391ac508122b63751c2a3acba65645d05ce
Author: Alex Bevilacqua (alexbevi at gmail.com)
Date: 2021-05-17T15:35:41+02:00
Commit Message:
ASYLUM: Fixed a bug from the original game that caused the application to be locked (and occasionally crash) due to the fact that the application was locked in a while loop during the playing of the first sfx item after the intro video.
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@298 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/asylum.cpp
engines/asylum/asylum.h
diff --git a/engines/asylum/asylum.cpp b/engines/asylum/asylum.cpp
index def9933022..2be56a3d1c 100644
--- a/engines/asylum/asylum.cpp
+++ b/engines/asylum/asylum.cpp
@@ -89,6 +89,8 @@ Common::Error AsylumEngine::init() {
Shared.setSound(_sound);
Shared.setVideo(_video);
+ _introPlaying = false;
+
return Common::kNoError;
}
@@ -123,10 +125,10 @@ Common::Error AsylumEngine::go() {
// Also, this routine is used to set game flags 4 and 12, so if we're
// skipping the intro, but not loading a save file, those flags
// need to be set somewhere else.
- //playIntro();
+ playIntro();
// Enter first scene
- _scene->enterScene();
+ //_scene->enterScene();
while (!shouldQuit()) {
checkForEvent(true);
@@ -162,27 +164,40 @@ void AsylumEngine::playIntro() {
_sound->playSfx(introRes, 7);
- if (_sound->isSfxActive()) {
- while (_sound->isSfxActive()) {
- ;
- }
- }
+ _introPlaying = true;
delete introRes;
-
- // TODO Since we've currently only got one sfx handle to play with in
- // the sound class, entering the scene overwrites the "alarm" loop.
- // This sound is technically supposed to play until the actor disables
- // the alarm by flipping the switch. The sound class needs to be extended
- // to be able to handle multiple handles.
- // The currently active sound resources can probably also be buffered into
- // the scene's soundResId[] array (seems that's the way the original worked,
- // especially when you examine isSoundinList() or isSoundPlaying())
-
- _scene->enterScene();
}
void AsylumEngine::checkForEvent(bool doUpdate) {
+
+ // NOTE
+ // In the original version of Sanitarium, the control loop for the sound
+ // effect that played after the intro video involved a while loop that
+ // executed until the sound handle was released.
+ // This caused the application to be locked until the while loop's execution
+ // completed successfully. Our implementation circumvents this issue
+ // by moving the logic to the event loop and checking whether a flag is
+ // set to determine if control should be returned to the engine.
+ if (_introPlaying) {
+ if (!_sound->isSfxActive()) {
+ _introPlaying = false;
+
+ // TODO Since we've currently only got one sfx handle to play with in
+ // the sound class, entering the scene overwrites the "alarm" loop.
+ // This sound is technically supposed to play until the actor disables
+ // the alarm by flipping the switch. The sound class needs to be extended
+ // to be able to handle multiple handles.
+ // The currently active sound resources can probably also be buffered into
+ // the scene's soundResId[] array (seems that's the way the original worked,
+ // especially when you examine isSoundinList() or isSoundPlaying())
+
+ _scene->enterScene();
+ } else {
+ return;
+ }
+ }
+
Common::Event ev;
if (_system->getEventManager()->pollEvent(ev)) {
@@ -234,6 +249,10 @@ void AsylumEngine::checkForEvent(bool doUpdate) {
else if (_scene->getBlowUpPuzzle()->isActive())
// Pass events to BlowUp Puzzles
_scene->getBlowUpPuzzle()->handleEvent(&ev, doUpdate);
+
+ if (_introPlaying) {
+
+ }
}
void AsylumEngine::processDelayedEvents() {
diff --git a/engines/asylum/asylum.h b/engines/asylum/asylum.h
index 3ca98816dc..4304050644 100644
--- a/engines/asylum/asylum.h
+++ b/engines/asylum/asylum.h
@@ -82,6 +82,8 @@ private:
Common::Language _language;
Common::RandomSource _rnd;
+ bool _introPlaying;
+
Console *_console;
Scene *_scene;
MainMenu *_mainMenu;
Commit: 7cef62988d70df075006a64da5f109e17dd5df05
https://github.com/scummvm/scummvm/commit/7cef62988d70df075006a64da5f109e17dd5df05
Author: Alex Bevilacqua (alexbevi at gmail.com)
Date: 2021-05-17T15:35:41+02:00
Commit Message:
ASYLUM: * Added a console command to show the currently active game flags
* Tweaked the logic for the JumpIfFlagSet opcode
* Added the two flag registrations that would be set if the intro ran to the main engine (so we can disable the intro for now)
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@301 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/asylum.cpp
engines/asylum/console.cpp
engines/asylum/console.h
engines/asylum/scriptman.cpp
diff --git a/engines/asylum/asylum.cpp b/engines/asylum/asylum.cpp
index 2be56a3d1c..b0bfe17e43 100644
--- a/engines/asylum/asylum.cpp
+++ b/engines/asylum/asylum.cpp
@@ -125,10 +125,12 @@ Common::Error AsylumEngine::go() {
// Also, this routine is used to set game flags 4 and 12, so if we're
// skipping the intro, but not loading a save file, those flags
// need to be set somewhere else.
- playIntro();
+ //playIntro();
// Enter first scene
- //_scene->enterScene();
+ ScriptMan.setGameFlag(4);
+ ScriptMan.setGameFlag(12);
+ _scene->enterScene();
while (!shouldQuit()) {
checkForEvent(true);
diff --git a/engines/asylum/console.cpp b/engines/asylum/console.cpp
index ed9eb7781a..7b996590a3 100644
--- a/engines/asylum/console.cpp
+++ b/engines/asylum/console.cpp
@@ -40,6 +40,7 @@ Console::Console(AsylumEngine *vm) : GUI::Debugger() {
DCmd_Register("video", WRAP_METHOD(Console, cmdPlayVideo));
DCmd_Register("script", WRAP_METHOD(Console, cmdRunScript));
DCmd_Register("scene", WRAP_METHOD(Console, cmdChangeScene));
+ DCmd_Register("flags", WRAP_METHOD(Console, cmdShowFlags));
DVar_Register("showpolygons", &g_debugPolygons, DVAR_INT, 0);
DVar_Register("showbarriers", &g_debugBarriers, DVAR_INT, 0);
@@ -48,6 +49,16 @@ Console::Console(AsylumEngine *vm) : GUI::Debugger() {
Console::~Console() {
}
+bool Console::cmdShowFlags(int argc, const char **argv) {
+ for (int i = 0; i < 1512; i++) {
+ if (ScriptMan.isGameFlagSet(i)) {
+ DebugPrintf("Game Flag %d is Active\n", i);
+ }
+ }
+
+ return true;
+}
+
bool Console::cmdPlayVideo(int argc, const char **argv) {
if (argc != 2) {
DebugPrintf("Usage %s <video number>\n", argv[0]);
diff --git a/engines/asylum/console.h b/engines/asylum/console.h
index 9267f9eb38..bf053777b7 100644
--- a/engines/asylum/console.h
+++ b/engines/asylum/console.h
@@ -43,6 +43,7 @@ private:
bool cmdPlayVideo(int argc, const char **argv);
bool cmdRunScript(int argc, const char **argv);
bool cmdChangeScene(int argc, const char **argv);
+ bool cmdShowFlags(int argc, const char **argv);
private:
AsylumEngine *_vm;
diff --git a/engines/asylum/scriptman.cpp b/engines/asylum/scriptman.cpp
index 239aad0be7..b106199385 100644
--- a/engines/asylum/scriptman.cpp
+++ b/engines/asylum/scriptman.cpp
@@ -162,9 +162,9 @@ void ScriptManager::processActionList() {
/* 0x04 */ case kJumpIfGameFlag: {
int flagNum = currentCommand->param1;
if (flagNum) {
- bool doJump = isGameFlagNotSet(flagNum);
+ bool doJump = isGameFlagSet(flagNum);
if (currentCommand->param2)
- doJump = isGameFlagSet(flagNum);
+ doJump = isGameFlagNotSet(flagNum);
if (doJump)
_currentLine = currentCommand->param3;
@@ -319,12 +319,10 @@ void ScriptManager::processActionList() {
uint32 v59 = currentCommand->param2;
if (!_currentScript->counter && Shared.getScene()->getSceneIndex() != 13 && sndIdx != 0) {
- // TODO
- // Find a script that actually has a valid param3
- // to see if this code is accurate :P
- ResourcePack *tmpRes = new ResourcePack(12);
- Shared.getSound()->playSfx(tmpRes, ((int)(sndIdx != 0) & 5) + 0x80120001);
- delete tmpRes;
+ ResourcePack *sfx = new ResourcePack(18);
+ Shared.getSound()->playSfx(sfx, ((unsigned int)(sndIdx != 0) & 5) + 0x80120001);
+ delete sfx;
+ //Shared.getSound()->playSfx(Shared.getScene()->getSpeechPack(),sndIdx + 86);
}
if (_currentScript->counter >= 3 * v59 - 1) {
Commit: d9348e1388a66d0d007405d1cc572db9e0a9185e
https://github.com/scummvm/scummvm/commit/d9348e1388a66d0d007405d1cc572db9e0a9185e
Author: Alexandre Fontoura (alexandrefontoura at gmail.com)
Date: 2021-05-17T15:35:41+02:00
Commit Message:
ASYLUM: Reorganization Flags under Shared for the upcoming work on Update routines. Start working on UpdateBarrier(incomplete)
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@302 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/asylum.cpp
engines/asylum/console.cpp
engines/asylum/scene.cpp
engines/asylum/scene.h
engines/asylum/scriptman.cpp
engines/asylum/scriptman.h
engines/asylum/shared.cpp
engines/asylum/shared.h
diff --git a/engines/asylum/asylum.cpp b/engines/asylum/asylum.cpp
index b0bfe17e43..01bd51ceb1 100644
--- a/engines/asylum/asylum.cpp
+++ b/engines/asylum/asylum.cpp
@@ -85,6 +85,7 @@ Common::Error AsylumEngine::init() {
_mainMenu = 0;
_scene = 0;
+ Shared.setOSystem(_system);
Shared.setScreen(_screen);
Shared.setSound(_sound);
Shared.setVideo(_video);
@@ -128,8 +129,8 @@ Common::Error AsylumEngine::go() {
//playIntro();
// Enter first scene
- ScriptMan.setGameFlag(4);
- ScriptMan.setGameFlag(12);
+ Shared.setGameFlag(4);
+ Shared.setGameFlag(12);
_scene->enterScene();
while (!shouldQuit()) {
@@ -159,8 +160,8 @@ void AsylumEngine::playIntro() {
_screen->clearScreen();
- ScriptMan.setGameFlag(4);
- ScriptMan.setGameFlag(12);
+ Shared.setGameFlag(4);
+ Shared.setGameFlag(12);
ResourcePack *introRes = new ResourcePack(18);
diff --git a/engines/asylum/console.cpp b/engines/asylum/console.cpp
index 7b996590a3..ebbf69b7c4 100644
--- a/engines/asylum/console.cpp
+++ b/engines/asylum/console.cpp
@@ -28,6 +28,7 @@
#include "asylum/asylum.h"
#include "asylum/console.h"
#include "asylum/scene.h"
+#include "asylum/shared.h"
namespace Asylum {
@@ -51,7 +52,7 @@ Console::~Console() {
bool Console::cmdShowFlags(int argc, const char **argv) {
for (int i = 0; i < 1512; i++) {
- if (ScriptMan.isGameFlagSet(i)) {
+ if (Shared.isGameFlagSet(i)) {
DebugPrintf("Game Flag %d is Active\n", i);
}
}
diff --git a/engines/asylum/scene.cpp b/engines/asylum/scene.cpp
index 4c3f560e9d..f2674e22f2 100644
--- a/engines/asylum/scene.cpp
+++ b/engines/asylum/scene.cpp
@@ -69,7 +69,7 @@ Scene::Scene(uint8 sceneIdx) {
g_debugBarriers = 0;
// TODO Not sure why this is done ... yet
- ScriptMan.setGameFlag(183);
+ Shared.setGameFlag(183);
}
Scene::~Scene() {
@@ -280,7 +280,7 @@ void Scene::update() {
// DEBUG
// Force the screen to scroll if the mouse approaches the edges
- //debugScreenScrolling(bg);
+ debugScreenScrolling(bg);
// Copy the background to the back buffer before updating the scene animations
Shared.getScreen()->copyToBackBuffer(((byte *)bg->surface.pixels) + _startY * bg->surface.w + _startX,
@@ -297,12 +297,15 @@ void Scene::update() {
updateBarrier(Shared.getScreen(), _resPack, 1); // inside the middle room
for(uint b=0; b < _sceneResource->getWorldStats()->barriers.size(); b++) {
- if ((_sceneResource->getWorldStats()->barriers[b].flags & 0x20)) // TODO - enums for flags (0x20 is visible/playing?)
- updateBarrier(Shared.getScreen(), _resPack, b);
+ if((_sceneResource->getWorldStats()->barriers[b].field_3C == 4)) {
+ if ((_sceneResource->getWorldStats()->barriers[b].flags & 0x20)) // TODO - enums for flags (0x20 is visible/playing?)
+ updateBarrier(Shared.getScreen(), _resPack, b);
if (_sceneResource->getWorldStats()->barriers[b].flags & 8) {
updateBarrier(Shared.getScreen(), _resPack, b);
}
+
+ }
}
// DEBUGGING
@@ -451,6 +454,49 @@ void Scene::copyToBackBufferClipped(Graphics::Surface *surface, int x, int y) {
}
}
+// WIP:
+bool Scene::isBarrierFlagsSet(BarrierItem *barrier) {
+ if(barrier->flags & 1)
+ {
+ for(uint f=0; f < 10; f++) {
+ uint32 flag = barrier->gameFlags[f];
+ if(flag <= 0)
+ {
+
+ }
+ }
+
+ return true;
+ }
+ return false;
+}
+
+// WIP: This is a new function that will treat all updates for Barriers when its done
+void Scene::updateBarriers(WorldStats *worldStats) {
+ Screen *screen = Shared.getScreen();
+ OSystem *system = Shared.getOSystem();
+
+ uint barriersCount = worldStats->barriers.size();
+ int startTickCount = 0;
+
+ if(barriersCount > 0) {
+ for(uint b=0; b < barriersCount; b++) {
+ BarrierItem *barrier = &worldStats->barriers[b];
+
+ startTickCount = system->getMillis();
+
+ if(barrier->field_3C == 4) {
+ if(isBarrierFlagsSet(barrier)) {
+
+ } else {
+ // TODO: get tick count
+ // update barrier sounds
+ }
+ }
+ }
+ }
+}
+
void Scene::updateBarrier(Screen *screen, ResourcePack *res, uint8 barrierIndex) {
BarrierItem barrier = _sceneResource->getWorldStats()->barriers[barrierIndex];
GraphicResource *gra = new GraphicResource(res, barrier.resId);
diff --git a/engines/asylum/scene.h b/engines/asylum/scene.h
index 5f54efda8d..5d7b40031a 100644
--- a/engines/asylum/scene.h
+++ b/engines/asylum/scene.h
@@ -41,9 +41,11 @@ class Sound;
class Video;
class Text;
class SceneResource;
+class WorldStats;
class BlowUpPuzzle;
struct ActionDefinitions;
struct PolyDefinitions;
+struct BarrierItem;
class Scene {
public:
@@ -121,8 +123,11 @@ private:
*/
void animateCursor();
- void updateBarrier(Screen *screen, ResourcePack *res, uint8 actorIndex);
+ bool isBarrierFlagsSet(BarrierItem *barrier);
+ void updateBarriers(WorldStats *worldStats);
+ void updateBarrier(Screen *screen, ResourcePack *res, uint8 actorIndex);
+
void debugScreenScrolling(GraphicFrame *bg);
void debugShowPolygons();
void debugShowBarriers();
diff --git a/engines/asylum/scriptman.cpp b/engines/asylum/scriptman.cpp
index b106199385..588ad9a89c 100644
--- a/engines/asylum/scriptman.cpp
+++ b/engines/asylum/scriptman.cpp
@@ -42,8 +42,6 @@ ScriptManager::ScriptManager() {
_delayedSceneIndex = -1;
_delayedVideoIndex = -1;
_allowInput = true;
-
- memset(_gameFlags, 0, 1512);
}
}
@@ -76,31 +74,11 @@ void ScriptManager::setScriptIndex(uint32 index) {
setScript(Shared.getScene()->getActionList(index));
}
-void ScriptManager::setGameFlag(int flag) {
- _gameFlags[flag / 32] |= 1 << flag % -32;
-}
-
-void ScriptManager::clearGameFlag(int flag) {
- _gameFlags[flag / 32] &= ~(1 << flag % -32);
-}
-
-void ScriptManager::toggleGameFlag(int flag) {
- _gameFlags[flag / 32] ^= 1 << flag % -32;
-}
-
-bool ScriptManager::isGameFlagSet(int flag) {
- return ((1 << flag % -32) & (unsigned int)_gameFlags[flag / 32]) >> flag % -32 != 0;
-}
-
-bool ScriptManager::isGameFlagNotSet(int flag) {
- return ((1 << flag % -32) & (unsigned int)_gameFlags[flag / 32]) >> flag % -32 == 0;
-}
-
-// TODO: put this under scene resource
int ScriptManager::checkBarrierFlags(int barrierId) {
int flags = Shared.getScene()->getResources()->getBarrierById(barrierId)->flags;
return flags & 1 && (flags & 8 || flags & 0x10000);
}
+
int ScriptManager::setBarrierNextFrame(int barrierId, int barrierFlags) {
int barrierIndex = Shared.getScene()->getResources()->getBarrierIndexById(barrierId);
@@ -142,29 +120,29 @@ void ScriptManager::processActionList() {
/* 0x01 */ case kSetGameFlag: {
int flagNum = currentCommand->param1;
if(flagNum >= 0)
- setGameFlag(currentCommand->param1);
+ Shared.setGameFlag(currentCommand->param1);
}
break;
/* 0x02 */ case kClearGameFlag: {
int flagNum = currentCommand->param1;
if(flagNum >= 0)
- clearGameFlag(currentCommand->param1);
+ Shared.clearGameFlag(currentCommand->param1);
}
break;
/* 0x03 */ case kToogleGameFlag: {
int flagNum = currentCommand->param1;
if(flagNum >= 0)
- toggleGameFlag(currentCommand->param1);
+ Shared.toggleGameFlag(currentCommand->param1);
}
break;
/* 0x04 */ case kJumpIfGameFlag: {
int flagNum = currentCommand->param1;
if (flagNum) {
- bool doJump = isGameFlagSet(flagNum);
+ bool doJump = Shared.isGameFlagSet(flagNum);
if (currentCommand->param2)
- doJump = isGameFlagNotSet(flagNum);
+ doJump = Shared.isGameFlagNotSet(flagNum);
if (doJump)
_currentLine = currentCommand->param3;
diff --git a/engines/asylum/scriptman.h b/engines/asylum/scriptman.h
index 06d6a284cc..3dd5e99cbf 100644
--- a/engines/asylum/scriptman.h
+++ b/engines/asylum/scriptman.h
@@ -50,12 +50,6 @@ public:
bool isInputAllowed() { return _allowInput; }
bool isProcessing() { return _processing; }
-
- void setGameFlag(int flag);
- void clearGameFlag(int flag);
- void toggleGameFlag(int flag);
- bool isGameFlagSet(int flag);
- bool isGameFlagNotSet(int flag);
int checkBarrierFlags(int barrierId);
int setBarrierNextFrame(int barrierId, int barrierFlags);
@@ -74,12 +68,6 @@ private:
ActionDefinitions *_currentScript;
- // NOTE
- // Storing the gameflags on the
- // scriptmanager since this makes the
- // most sense
- int _gameFlags[1512];
-
void processActionListSub02(ActionDefinitions* script, ActionCommand* command, int a4);
void enableActorSub(int actorIndex, int condition);
diff --git a/engines/asylum/shared.cpp b/engines/asylum/shared.cpp
index c17943646b..b26d73ed7e 100644
--- a/engines/asylum/shared.cpp
+++ b/engines/asylum/shared.cpp
@@ -37,7 +37,7 @@ SharedResources::SharedResources() {
if (!g_initialized) {
g_initialized = true;
}
-
+ memset(_gameFlags, 0, 1512);
}
SharedResources::~SharedResources() {
@@ -70,4 +70,24 @@ bool SharedResources::pointInPoly(PolyDefinitions *poly, int x, int y) {
return inside_flag;
}
+void SharedResources::setGameFlag(int flag) {
+ _gameFlags[flag / 32] |= 1 << flag % -32;
+}
+
+void SharedResources::clearGameFlag(int flag) {
+ _gameFlags[flag / 32] &= ~(1 << flag % -32);
+}
+
+void SharedResources::toggleGameFlag(int flag) {
+ _gameFlags[flag / 32] ^= 1 << flag % -32;
+}
+
+bool SharedResources::isGameFlagSet(int flag) {
+ return ((1 << flag % -32) & (unsigned int)_gameFlags[flag / 32]) >> flag % -32 != 0;
+}
+
+bool SharedResources::isGameFlagNotSet(int flag) {
+ return ((1 << flag % -32) & (unsigned int)_gameFlags[flag / 32]) >> flag % -32 == 0;
+}
+
} // end of namespace Asylum
diff --git a/engines/asylum/shared.h b/engines/asylum/shared.h
index 3902f51ac0..063fb5b24f 100644
--- a/engines/asylum/shared.h
+++ b/engines/asylum/shared.h
@@ -47,6 +47,9 @@ namespace Asylum {
class SharedResources: public Common::Singleton<SharedResources> {
public:
+ void setOSystem(OSystem* system) { _system = system; }
+ OSystem* getOSystem() { return _system; }
+
void setVideo(Video* video) { _video = video; }
Video* getVideo() { return _video; }
@@ -61,16 +64,29 @@ public:
bool pointInPoly(PolyDefinitions *poly, int x, int y);
+ void setGameFlag(int flag);
+ void clearGameFlag(int flag);
+ void toggleGameFlag(int flag);
+ bool isGameFlagSet(int flag);
+ bool isGameFlagNotSet(int flag);
+
private:
friend class Common::Singleton<SingletonBaseType>;
SharedResources();
~SharedResources();
+ OSystem *_system;
Video *_video;
Screen *_screen;
Sound *_sound;
Scene *_scene;
+ // NOTE
+ // Storing the gameflags on the
+ // scriptmanager since this makes the
+ // most sense
+ int _gameFlags[1512];
+
}; // end of class SharedResources
#define Shared (::Asylum::SharedResources::instance())
Commit: 08d786e46ee566397b6a3f2f047ff30f0458fbff
https://github.com/scummvm/scummvm/commit/08d786e46ee566397b6a3f2f047ff30f0458fbff
Author: Alex Bevilacqua (alexbevi at gmail.com)
Date: 2021-05-17T15:35:42+02:00
Commit Message:
ASYLUM: * Add a reference to the scene resource's actor[0] to the mainActor instance (this is an interim hack until we refactor the actor class to include ALL actor data)
* Add a toggle_flag command to the console
* Clear flag 183 when the current action has been processessed
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@303 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/actor.cpp
engines/asylum/actor.h
engines/asylum/console.cpp
engines/asylum/console.h
engines/asylum/sceneres.cpp
engines/asylum/sceneres.h
engines/asylum/scriptman.cpp
diff --git a/engines/asylum/actor.cpp b/engines/asylum/actor.cpp
index 33eeb1b985..a77e1fb42c 100644
--- a/engines/asylum/actor.cpp
+++ b/engines/asylum/actor.cpp
@@ -31,7 +31,7 @@
namespace Asylum {
-MainActor::MainActor(uint8 *data) {
+MainActor::MainActor(uint8 *data, ActorItem *actorRef) {
byte *dataPtr = data;
for (uint32 i = 0; i < 60; i++){
@@ -45,6 +45,7 @@ MainActor::MainActor(uint8 *data) {
_actorY = 0;
_currentAction = 0;
_currentWalkArea = 0;
+ _actorRef = actorRef;
}
MainActor::~MainActor() {
@@ -226,16 +227,15 @@ void MainActor::walkTo(uint16 x, uint16 y) {
availableAreas[areaPtr] = a;
areaPtr++;
+ setWalkArea(&Shared.getScene()->getResources()->getWorldStats()->actions[a]);
+
if (areaPtr > 5)
error("More than 5 overlapping walk regions found. Increase buffer");
+
}
}
}
- // Set the current walk region to the first available action area
- // in the collection
- setWalkArea(&Shared.getScene()->getResources()->getWorldStats()->actions[availableAreas[0]]);
-
// Check that we can walk in the current direction within any of the available
// walkable regions
for (int i = 0; i < areaPtr; i++) {
@@ -252,4 +252,23 @@ void MainActor::walkTo(uint16 x, uint16 y) {
drawActor();
}
+void MainActor::disable(int param) {
+ switch (param) {
+
+ case 5:
+ int dir = _actorRef->direction;
+ if (dir > 4)
+ _actorRef->direction = 8 - dir;
+
+ setAction(dir + 5);
+ break;
+
+ }
+
+}
+
+void MainActor::setDirection(int direction) {
+
+}
+
} // end of namespace Asylum
diff --git a/engines/asylum/actor.h b/engines/asylum/actor.h
index 41b36f8dfc..7334aaa4d6 100644
--- a/engines/asylum/actor.h
+++ b/engines/asylum/actor.h
@@ -33,9 +33,8 @@ namespace Asylum {
class Screen;
struct ActionItem;
+struct ActorItem;
-// TODO properly use this enum as opposed to just
-// using it for visual reference :P
// TODO investigate other actor resources (from other
// scenes) to see if the unused blocks in the actor
// definition are in fact used elsewhere
@@ -130,7 +129,7 @@ enum ActorResources {
class MainActor {
public:
- MainActor(uint8 *data);
+ MainActor(uint8 *data, ActorItem *actorRef);
virtual ~MainActor();
void setResourcePack(ResourcePack *resPack) { _resPack = resPack; }
@@ -140,6 +139,8 @@ public:
void drawActorAt(uint16 x, uint16 y);
void drawActor();
void walkTo(uint16 x, uint16 y);
+ void disable(int param);
+ void setDirection(int direction);
int getCurrentAction() { return _currentAction; }
uint16 _actorX, _actorY;
@@ -151,7 +152,8 @@ private:
uint8 _currentFrame;
int _currentAction;
- ActionItem *_currentWalkArea;
+ ActionItem *_currentWalkArea;
+ ActorItem *_actorRef;
GraphicFrame *getFrame();
diff --git a/engines/asylum/console.cpp b/engines/asylum/console.cpp
index ebbf69b7c4..56789434e4 100644
--- a/engines/asylum/console.cpp
+++ b/engines/asylum/console.cpp
@@ -42,6 +42,7 @@ Console::Console(AsylumEngine *vm) : GUI::Debugger() {
DCmd_Register("script", WRAP_METHOD(Console, cmdRunScript));
DCmd_Register("scene", WRAP_METHOD(Console, cmdChangeScene));
DCmd_Register("flags", WRAP_METHOD(Console, cmdShowFlags));
+ DCmd_Register("toggle_flag", WRAP_METHOD(Console, cmdToggleFlag));
DVar_Register("showpolygons", &g_debugPolygons, DVAR_INT, 0);
DVar_Register("showbarriers", &g_debugBarriers, DVAR_INT, 0);
@@ -60,6 +61,17 @@ bool Console::cmdShowFlags(int argc, const char **argv) {
return true;
}
+bool Console::cmdToggleFlag(int argc, const char **argv) {
+ if (argc != 2 || atoi(argv[1]) > 1512 || atoi(argv[1]) < 0) {
+ DebugPrintf("Enter a value between 0 and 1512\n");
+ return true;
+ }
+ Shared.toggleGameFlag(atoi(argv[1]));
+ DebugPrintf("Flag %d == %d\n", atoi(argv[1]), Shared.isGameFlagSet(atoi(argv[1])));
+
+ return true;
+}
+
bool Console::cmdPlayVideo(int argc, const char **argv) {
if (argc != 2) {
DebugPrintf("Usage %s <video number>\n", argv[0]);
diff --git a/engines/asylum/console.h b/engines/asylum/console.h
index bf053777b7..7ae1907da0 100644
--- a/engines/asylum/console.h
+++ b/engines/asylum/console.h
@@ -44,6 +44,7 @@ private:
bool cmdRunScript(int argc, const char **argv);
bool cmdChangeScene(int argc, const char **argv);
bool cmdShowFlags(int argc, const char **argv);
+ bool cmdToggleFlag(int argc, const char **argv);
private:
AsylumEngine *_vm;
diff --git a/engines/asylum/sceneres.cpp b/engines/asylum/sceneres.cpp
index 9ddc214400..d4dc396fbd 100644
--- a/engines/asylum/sceneres.cpp
+++ b/engines/asylum/sceneres.cpp
@@ -362,7 +362,7 @@ void SceneResource::loadWorldStats(Common::SeekableReadStream *stream) {
stream->seek(0xA73B6);
uint8 mainActorData[500];
stream->read(mainActorData, 500);
- _mainActor = new MainActor(mainActorData);
+ _mainActor = new MainActor(mainActorData, &_worldStats->actors[0]);
stream->seek(0xD6B5A); // where action items start
diff --git a/engines/asylum/sceneres.h b/engines/asylum/sceneres.h
index 282f869a31..8f724cecf0 100644
--- a/engines/asylum/sceneres.h
+++ b/engines/asylum/sceneres.h
@@ -337,6 +337,31 @@ public:
}; // end of class GamePolygons
+// TODO Initialize the ActionArea collection
+// if it's actually needed
+typedef struct ActionArea {
+ char name[52];
+ uint32 id;
+ uint32 field01;
+ uint32 field02;
+ uint32 field_40;
+ uint32 field_44;
+ uint32 flags;
+ uint32 actionListIndex01;
+ uint32 actionListIndex02;
+ uint32 flags2;
+ uint32 flagNums[10];
+ uint32 field_7C;
+ uint32 polyIdx;
+ uint32 field_84;
+ uint32 field_88;
+ uint32 soundResId;
+ uint32 field_90;
+ uint32 paletteValue;
+ uint32 array[5];
+ uint32 volume;
+} ActionArea;
+
typedef struct ActionCommand {
uint32 numLines; // Only set on the first line of each script
uint32 opcode;
diff --git a/engines/asylum/scriptman.cpp b/engines/asylum/scriptman.cpp
index 588ad9a89c..9fb5692743 100644
--- a/engines/asylum/scriptman.cpp
+++ b/engines/asylum/scriptman.cpp
@@ -277,7 +277,11 @@ void ScriptManager::processActionList() {
break;
/* 0x0C */ //case kSetSceneMotionStat:
-/* 0x0D */ //case kDisableActor:
+/* 0x0D */ case kDisableActor: {
+ // TODO handle character index != 0
+ Shared.getScene()->getResources()->getMainActor()->disable(5);
+ }
+ break;
/* 0x0E */ case kEnableActor: {
int actorIndex = 0;
if (currentCommand->param1 == -1)
@@ -353,7 +357,21 @@ void ScriptManager::processActionList() {
/* 0x17 */ //case kClearFlag1Bit0:
/* 0x18 */ //case k_unk18_PLAY_SND:
/* 0x19 */ //case kJumpIfFlag2Bit0:
-/* 0x1A */ //case kSetFlag2Bit0:
+/* 0x1A */ case kSetFlag2Bit0: {
+ int targetType = currentCommand->param2;
+ if (targetType == 2)
+ Shared.getScene()->getResources()->getWorldStats()->actors[currentCommand->param1].flags2 |= 1;
+ else
+ if (targetType == 1) {
+ // int actionIdx = getActionIndex(currentCommand->param1);
+ //scene.actionAreas[actionIdx].flags |= 1;
+ debugC(kDebugLevelScripts, "ActionArea Flag Set not implemented");
+
+ } else {
+ Shared.getScene()->getResources()->getBarrierById(currentCommand->param1)->flags2 |= 1;
+ }
+ }
+ break;
/* 0x1B */ //case kClearFlag2Bit0:
/* 0x1C */ //case kJumpIfFlag2Bit2:
/* 0x1D */ //case kSetFlag2Bit2:
@@ -409,7 +427,16 @@ void ScriptManager::processActionList() {
/* 0x39 */ //case kSetFlag2Bit3:
/* 0x3A */ //case kClearFlag2Bit3:
/* 0x3B */ //case k_unk3B_PALETTE_MOD:
-/* 0x3C */ //case k_unk3C_CMP_VAL:
+/* 0x3C */ case k_unk3C_CMP_VAL: {
+ if (currentCommand->param1) {
+ if (currentCommand->param2 >= currentCommand->param1)
+ currentCommand->param2 = 0;
+ else
+ currentCommand->param2 = currentCommand->param1 + 1;
+ // XXX done = true; ???
+ }
+ }
+ break;
/* 0x3D */ case kWaitUntilFramePlayed: {
int barrierIndex = Shared.getScene()->getResources()->getBarrierIndexById(currentCommand->param1);
if (barrierIndex >= 0) {
@@ -516,7 +543,8 @@ void ScriptManager::processActionList() {
/* 0x62 */ //case k_unk62_SHOW_OPTIONS_SCREEN:
default:
- debugC(kDebugLevelScripts,
+ //debugC(kDebugLevelScripts,
+ warning(
"Unhandled opcode 0x%02X in Scene %d Line %d.",
currentCommand->opcode,
Shared.getScene()->getSceneIndex(),
@@ -534,6 +562,8 @@ void ScriptManager::processActionList() {
_currentLine = 0;
_currentLoops = 0;
_currentScript = 0;
+
+ Shared.clearGameFlag(183);
}
}
Commit: 55dd466b7a5015ac4486739a91b6bca1b8106180
https://github.com/scummvm/scummvm/commit/55dd466b7a5015ac4486739a91b6bca1b8106180
Author: Alex Bevilacqua (alexbevi at gmail.com)
Date: 2021-05-17T15:35:42+02:00
Commit Message:
ASYLUM: oops (warning -> debugC)
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@304 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/scriptman.cpp
diff --git a/engines/asylum/scriptman.cpp b/engines/asylum/scriptman.cpp
index 9fb5692743..6e5afd917a 100644
--- a/engines/asylum/scriptman.cpp
+++ b/engines/asylum/scriptman.cpp
@@ -543,8 +543,7 @@ void ScriptManager::processActionList() {
/* 0x62 */ //case k_unk62_SHOW_OPTIONS_SCREEN:
default:
- //debugC(kDebugLevelScripts,
- warning(
+ debugC(kDebugLevelScripts,
"Unhandled opcode 0x%02X in Scene %d Line %d.",
currentCommand->opcode,
Shared.getScene()->getSceneIndex(),
Commit: a5218007dc5761ce9bdbd71f18528d10675f3a50
https://github.com/scummvm/scummvm/commit/a5218007dc5761ce9bdbd71f18528d10675f3a50
Author: Alex Bevilacqua (alexbevi at gmail.com)
Date: 2021-05-17T15:35:42+02:00
Commit Message:
ASYLUM: oops again (left debug screen scrolling on)
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@305 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/scene.cpp
diff --git a/engines/asylum/scene.cpp b/engines/asylum/scene.cpp
index f2674e22f2..92c709ced6 100644
--- a/engines/asylum/scene.cpp
+++ b/engines/asylum/scene.cpp
@@ -280,7 +280,7 @@ void Scene::update() {
// DEBUG
// Force the screen to scroll if the mouse approaches the edges
- debugScreenScrolling(bg);
+ //debugScreenScrolling(bg);
// Copy the background to the back buffer before updating the scene animations
Shared.getScreen()->copyToBackBuffer(((byte *)bg->surface.pixels) + _startY * bg->surface.w + _startX,
Commit: 11bbfc3cab8d9484488706ceaaacd51d56966807
https://github.com/scummvm/scummvm/commit/11bbfc3cab8d9484488706ceaaacd51d56966807
Author: Alex Bevilacqua (alexbevi at gmail.com)
Date: 2021-05-17T15:35:42+02:00
Commit Message:
ASYLUM: properly initialize the scene's actionAreas :D :D :D
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@306 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/actor.cpp
engines/asylum/actor.h
engines/asylum/scene.cpp
engines/asylum/sceneres.cpp
engines/asylum/sceneres.h
diff --git a/engines/asylum/actor.cpp b/engines/asylum/actor.cpp
index a77e1fb42c..966ba8816f 100644
--- a/engines/asylum/actor.cpp
+++ b/engines/asylum/actor.cpp
@@ -133,7 +133,7 @@ void MainActor::drawActor() {
frame->surface.h );
}
-void MainActor::setWalkArea(ActionItem *target) {
+void MainActor::setWalkArea(ActionArea *target) {
if (_currentWalkArea != target) {
ScriptMan.setScriptIndex(target->actionListIdx1);
_currentWalkArea = target;
@@ -216,7 +216,7 @@ void MainActor::walkTo(uint16 x, uint16 y) {
int availableAreas[5];
int areaPtr = 0;
- ActionItem *area;
+ ActionArea *area;
// Check what valid walk region(s) is/are currently available
for (uint32 a = 0; a < Shared.getScene()->getResources()->getWorldStats()->numActions; a++) {
diff --git a/engines/asylum/actor.h b/engines/asylum/actor.h
index 7334aaa4d6..68e02ad8f5 100644
--- a/engines/asylum/actor.h
+++ b/engines/asylum/actor.h
@@ -32,7 +32,7 @@
namespace Asylum {
class Screen;
-struct ActionItem;
+struct ActionArea;
struct ActorItem;
// TODO investigate other actor resources (from other
@@ -133,7 +133,7 @@ public:
virtual ~MainActor();
void setResourcePack(ResourcePack *resPack) { _resPack = resPack; }
- void setWalkArea(ActionItem *target); // depreciate
+ void setWalkArea(ActionArea *target); // TODO depreciate
void setAction(int action);
void setActionByIndex(int index);
void drawActorAt(uint16 x, uint16 y);
@@ -152,7 +152,7 @@ private:
uint8 _currentFrame;
int _currentAction;
- ActionItem *_currentWalkArea;
+ ActionArea *_currentWalkArea;
ActorItem *_actorRef;
GraphicFrame *getFrame();
diff --git a/engines/asylum/scene.cpp b/engines/asylum/scene.cpp
index 92c709ced6..f4c843d4d0 100644
--- a/engines/asylum/scene.cpp
+++ b/engines/asylum/scene.cpp
@@ -312,7 +312,7 @@ void Scene::update() {
// Check current walk region
for (uint32 a = 0; a < worldStats->numActions; a++) {
if (worldStats->actions[a].actionType == 0) {
- ActionItem *area = &worldStats->actions[a];
+ ActionArea *area = &worldStats->actions[a];
PolyDefinitions poly = _sceneResource->getGamePolygons()->polygons[area->polyIdx];
if (Shared.pointInPoly(&poly, mainActor->_actorX, mainActor->_actorY)) {
debugShowWalkRegion(&poly);
diff --git a/engines/asylum/sceneres.cpp b/engines/asylum/sceneres.cpp
index d4dc396fbd..dff35a1052 100644
--- a/engines/asylum/sceneres.cpp
+++ b/engines/asylum/sceneres.cpp
@@ -339,12 +339,12 @@ void SceneResource::loadWorldStats(Common::SeekableReadStream *stream) {
}
actor.actionIdx2 = stream->readUint32LE();
- actor.field_924 = stream->readUint32LE();
+ actor.field_924 = stream->readUint32LE();
actor.tickValue1 = stream->readUint32LE();
- actor.field_92C = stream->readUint32LE();
- actor.flags2 = stream->readUint32LE();
- actor.field_934 = stream->readUint32LE();
- actor.field_938 = stream->readUint32LE();
+ actor.field_92C = stream->readUint32LE();
+ actor.flags2 = stream->readUint32LE();
+ actor.field_934 = stream->readUint32LE();
+ actor.field_938 = stream->readUint32LE();
actor.soundResId = stream->readUint32LE();
// TODO skip field_940 till field_978
@@ -368,23 +368,31 @@ void SceneResource::loadWorldStats(Common::SeekableReadStream *stream) {
// FIXME Figure out all the actions items
for (uint32 a = 0; a < _worldStats->numActions; a++) {
- ActionItem action;
- memset(&action, 0, sizeof(ActionItem));
+ ActionArea action;
+ memset(&action, 0, sizeof(ActionArea));
stream->read(action.name,52);
- action.id = stream->readUint32LE();
- stream->skip(0x14);
- action.actionListIdx1 = stream->readUint32LE();
- action.actionListIdx2 = stream->readUint32LE();
- action.actionType = stream->readUint32LE();
- stream->skip(0x2C);
- action.polyIdx = stream->readUint32LE();
- stream->skip(0x08);
- action.soundResId = stream->readUint32LE();
- stream->skip(0x04);
- action.palCorrection = stream->readUint32LE();
- stream->skip(0x14);
- action.soundVolume = stream->readUint32LE();
+ action.id = stream->readUint32LE();
+ action.field01 = stream->readUint32LE();
+ action.field02 = stream->readUint32LE();
+ action.field_40 = stream->readUint32LE();
+ action.field_44 = stream->readUint32LE();
+ action.flags = stream->readUint32LE();
+ action.actionListIdx1 = stream->readUint32LE();
+ action.actionListIdx2 = stream->readUint32LE();
+ action.actionType = stream->readUint32LE();
+ for (int aa1 = 0; aa1 < 10; aa1++)
+ action.flagNums[aa1] = stream->readUint32LE();
+ action.field_7C = stream->readUint32LE();
+ action.polyIdx = stream->readUint32LE();
+ action.field_84 = stream->readUint32LE();
+ action.field_88 = stream->readUint32LE();
+ action.soundResId = stream->readUint32LE();
+ action.field_90 = stream->readUint32LE();
+ action.paletteValue = stream->readUint32LE();
+ for (int aa2 = 0; aa2 < 5; aa2++)
+ action.array[aa2] = stream->readUint32LE();
+ action.volume = stream->readUint32LE();
_worldStats->actions.push_back(action);
}
diff --git a/engines/asylum/sceneres.h b/engines/asylum/sceneres.h
index 8f724cecf0..04f778c02b 100644
--- a/engines/asylum/sceneres.h
+++ b/engines/asylum/sceneres.h
@@ -161,20 +161,6 @@ typedef struct BarrierItem {
} BarrierItem;
-// FIXME add unknown fields
-typedef struct ActionItem {
- char name[52];
- uint32 id;
- int32 actionListIdx1;
- int32 actionListIdx2;
- int32 actionType; // 0-none, 1-findwhat, 2-talk, 3-findwhat??, 4-grab
- int32 polyIdx;
- uint32 soundResId;
- uint32 palCorrection;
- int32 soundVolume;
-
-} ActionItem;
-
typedef struct CommonResources {
uint32 backgroundImage;
uint32 curScrollUp;
@@ -312,7 +298,7 @@ public:
Common::Array<BarrierItem> barriers; // maxsize 400
Common::Array<ActorItem> actors; // maxsize 50
// TODO add rest fields
- Common::Array<ActionItem> actions; // maxsize 400
+ Common::Array<ActionArea> actions; // maxsize 400
}; // end of class WorldStats
@@ -337,8 +323,6 @@ public:
}; // end of class GamePolygons
-// TODO Initialize the ActionArea collection
-// if it's actually needed
typedef struct ActionArea {
char name[52];
uint32 id;
@@ -347,9 +331,9 @@ typedef struct ActionArea {
uint32 field_40;
uint32 field_44;
uint32 flags;
- uint32 actionListIndex01;
- uint32 actionListIndex02;
- uint32 flags2;
+ uint32 actionListIdx1;
+ uint32 actionListIdx2;
+ uint32 actionType; // aka flags2: 0-none, 1-findwhat, 2-talk, 3-findwhat??, 4-grab
uint32 flagNums[10];
uint32 field_7C;
uint32 polyIdx;
Commit: d6d90b7e3a661f598a497d4355960f5cf63f5bbe
https://github.com/scummvm/scummvm/commit/d6d90b7e3a661f598a497d4355960f5cf63f5bbe
Author: Alex Bevilacqua (alexbevi at gmail.com)
Date: 2021-05-17T15:35:42+02:00
Commit Message:
ASYLUM: Add command "dump_action". This currently just prints out a list of ALL available actionAreas within the current scene resource. The logic to print out a single actionArea will come once the getActionAreaById (or index) is implemented.
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@307 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/console.cpp
engines/asylum/console.h
diff --git a/engines/asylum/console.cpp b/engines/asylum/console.cpp
index 56789434e4..a1b7e3880e 100644
--- a/engines/asylum/console.cpp
+++ b/engines/asylum/console.cpp
@@ -27,7 +27,6 @@
#include "asylum/asylum.h"
#include "asylum/console.h"
-#include "asylum/scene.h"
#include "asylum/shared.h"
namespace Asylum {
@@ -43,6 +42,7 @@ Console::Console(AsylumEngine *vm) : GUI::Debugger() {
DCmd_Register("scene", WRAP_METHOD(Console, cmdChangeScene));
DCmd_Register("flags", WRAP_METHOD(Console, cmdShowFlags));
DCmd_Register("toggle_flag", WRAP_METHOD(Console, cmdToggleFlag));
+ DCmd_Register("dump_action", WRAP_METHOD(Console, cmdDumpActionArea));
DVar_Register("showpolygons", &g_debugPolygons, DVAR_INT, 0);
DVar_Register("showbarriers", &g_debugBarriers, DVAR_INT, 0);
@@ -51,6 +51,46 @@ Console::Console(AsylumEngine *vm) : GUI::Debugger() {
Console::~Console() {
}
+bool Console::cmdDumpActionArea(int argc, const char **argv) {
+
+ if (argc == 2) {
+ // TODO Get an action area by index/id
+ } else {
+ for (uint32 i = 0; i < Shared.getScene()->getResources()->getWorldStats()->numActions; i++) {
+ ActionArea *a = &Shared.getScene()->getResources()->getWorldStats()->actions[i];
+ printActionAreaStats(a);
+ }
+ }
+
+ return true;
+}
+
+void Console::printActionAreaStats(ActionArea *a) {
+ DebugPrintf("id[%d] name[%s] field01[%d] field02[%d] field40[%d] field44[%d] flags[%d] \n"
+ "actionListIdx1[%d] actionListIdx2[%d] actionType[%d] field_7C[%d] polyIdx[%d]\n"
+ "field_84[%d] field_88[%d] soundResId[%d] field_90[%d] palette[%d] volume[%d]\n\n",
+ a->id,
+ a->name,
+ a->field01,
+ a->field02,
+ a->field_40,
+ a->field_44,
+ a->flags,
+ a->actionListIdx1,
+ a->actionListIdx2,
+ a->actionType,
+ //a->flagNums[10],
+ a->field_7C,
+ a->polyIdx,
+ a->field_84,
+ a->field_88,
+ a->soundResId,
+ a->field_90,
+ a->paletteValue,
+ //a->array[5],
+ a->volume);
+}
+
bool Console::cmdShowFlags(int argc, const char **argv) {
for (int i = 0; i < 1512; i++) {
if (Shared.isGameFlagSet(i)) {
diff --git a/engines/asylum/console.h b/engines/asylum/console.h
index 7ae1907da0..29d97e5c6a 100644
--- a/engines/asylum/console.h
+++ b/engines/asylum/console.h
@@ -33,6 +33,7 @@
namespace Asylum {
class AsylumEngine;
+struct ActionArea;
class Console : public GUI::Debugger {
public:
@@ -45,6 +46,9 @@ private:
bool cmdChangeScene(int argc, const char **argv);
bool cmdShowFlags(int argc, const char **argv);
bool cmdToggleFlag(int argc, const char **argv);
+ bool cmdDumpActionArea(int argc, const char **argv);
+
+ void printActionAreaStats(ActionArea *a);
private:
AsylumEngine *_vm;
Commit: 688356d898299c78d5cad6b559031e767920fae3
https://github.com/scummvm/scummvm/commit/688356d898299c78d5cad6b559031e767920fae3
Author: Alexandre Fontoura (alexandrefontoura at gmail.com)
Date: 2021-05-17T15:35:42+02:00
Commit Message:
ASYLUM: Some work on processing Barriers. (Still WIP). This will initiate a change in Scene Update function to make it like original game. Some functions are already declared but nothing was done yet.
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@308 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/asylum.cpp
engines/asylum/scene.cpp
engines/asylum/scene.h
engines/asylum/scriptman.cpp
diff --git a/engines/asylum/asylum.cpp b/engines/asylum/asylum.cpp
index 01bd51ceb1..bbdd7d03b5 100644
--- a/engines/asylum/asylum.cpp
+++ b/engines/asylum/asylum.cpp
@@ -172,7 +172,7 @@ void AsylumEngine::playIntro() {
delete introRes;
}
-void AsylumEngine::checkForEvent(bool doUpdate) {
+void AsylumEngine::checkForEvent(bool doUpdate) { // k_sub_40AE30 (0040AE30)
// NOTE
// In the original version of Sanitarium, the control loop for the sound
diff --git a/engines/asylum/scene.cpp b/engines/asylum/scene.cpp
index f4c843d4d0..47fd1fa4e8 100644
--- a/engines/asylum/scene.cpp
+++ b/engines/asylum/scene.cpp
@@ -289,7 +289,8 @@ void Scene::update() {
0,
640,
480);
-
+
+ /* COMMENTED WHILE DEVELOPING NEW VERSION
// TODO
// This is a hack for scene 1. This really shouldn't be hardcoded, as the
// activation of this barrier should be interpreted by the script manager,
@@ -306,7 +307,9 @@ void Scene::update() {
}
}
- }
+ }*/
+
+ processBarriers(worldStats);
// DEBUGGING
// Check current walk region
@@ -454,49 +457,6 @@ void Scene::copyToBackBufferClipped(Graphics::Surface *surface, int x, int y) {
}
}
-// WIP:
-bool Scene::isBarrierFlagsSet(BarrierItem *barrier) {
- if(barrier->flags & 1)
- {
- for(uint f=0; f < 10; f++) {
- uint32 flag = barrier->gameFlags[f];
- if(flag <= 0)
- {
-
- }
- }
-
- return true;
- }
- return false;
-}
-
-// WIP: This is a new function that will treat all updates for Barriers when its done
-void Scene::updateBarriers(WorldStats *worldStats) {
- Screen *screen = Shared.getScreen();
- OSystem *system = Shared.getOSystem();
-
- uint barriersCount = worldStats->barriers.size();
- int startTickCount = 0;
-
- if(barriersCount > 0) {
- for(uint b=0; b < barriersCount; b++) {
- BarrierItem *barrier = &worldStats->barriers[b];
-
- startTickCount = system->getMillis();
-
- if(barrier->field_3C == 4) {
- if(isBarrierFlagsSet(barrier)) {
-
- } else {
- // TODO: get tick count
- // update barrier sounds
- }
- }
- }
- }
-}
-
void Scene::updateBarrier(Screen *screen, ResourcePack *res, uint8 barrierIndex) {
BarrierItem barrier = _sceneResource->getWorldStats()->barriers[barrierIndex];
GraphicResource *gra = new GraphicResource(res, barrier.resId);
@@ -602,4 +562,157 @@ void Scene::debugShowBarriers() {
}
}
+
+
+// -------------------------------------------
+// --- NEXT CODE BLOCK IS WORK IN PROGRESS ---
+// this block will improve scene process
+// and drawing
+// -------------------------------------------
+
+bool Scene::isBarrierVisible(BarrierItem *barrier) {
+ if((barrier->flags & 0xFF) & 1)
+ {
+ for(uint f=0; f < 10; f++) {
+ bool isSet = false;
+ uint32 flag = barrier->gameFlags[f];
+
+ if(flag <= 0)
+ {
+ isSet = Shared.isGameFlagNotSet(-flag);
+ } else {
+ isSet = Shared.isGameFlagSet(flag);
+ }
+
+ if(!isSet) {
+ return false;
+ }
+ }
+
+ return true;
+ }
+ return false;
+}
+
+uint32 Scene::getRandomResId(BarrierItem *barrier) {
+ int numRes = 1;
+ uint32 rndResId[5];
+ for(int i=0; i < 5; i++) {
+ if(barrier->field_68C[i]) {
+ rndResId[numRes] = barrier->field_68C[i];
+ numRes++;
+ }
+ }
+ return rndResId[rand() % numRes];
+}
+
+// This is a new function that will process all update for Barriers
+void Scene::processBarriers(WorldStats *worldStats) { // old updateBarriers
+ Screen *screen = Shared.getScreen();
+ OSystem *system = Shared.getOSystem();
+
+ uint barriersCount = worldStats->barriers.size();
+ int startTickCount = 0;
+ bool canUpdateSound = false;
+
+ if(barriersCount > 0) {
+ for(uint b=0; b < barriersCount; b++) {
+ BarrierItem *barrier = &worldStats->barriers[b];
+
+ // DEBUG
+ /*printf("barrierIdx: %d\n",b);
+ if(b==28)
+ printf("barrierIdx: %d frameIdx:%d\n",b,barrier->frameIdx);*/
+
+ startTickCount = system->getMillis();
+
+ if(barrier->field_3C == 4) {
+ if(isBarrierVisible(barrier)) {
+ uint32 flag = barrier->flags;
+ if(flag & 0x20) {
+ if(system->getMillis() - barrier->tickCount >= 0x3E8 / barrier->field_B4) {
+ barrier->frameIdx = (barrier->frameIdx + 1) % barrier->frameCount;
+ // update ticks
+ barrier->tickCount = system->getMillis();
+ canUpdateSound = true;
+ }
+ } else if(flag & 0x10) {
+ uint32 frameIdx = barrier->frameIdx;
+ char equalZero = frameIdx == 0;
+ char lessZero = frameIdx < 0;
+ if(!frameIdx) {
+ if(system->getMillis() - barrier->tickCount >= 1000 * barrier->tickCount2) {
+ if(rand() % barrier->field_C0 == 1) {
+ if(barrier->field_68C) {
+ // TODO: fix this, and find a better way to get frame count
+ // Sometimes we get wrong random resource id
+
+ /*barrier->resId = getRandomResId(barrier);
+ GraphicResource *gra = new GraphicResource(_resPack, barrier->resId);
+ barrier->frameCount = gra->getFrameCount();
+ delete gra; */
+ }
+ barrier->frameIdx++;
+ }
+ barrier->tickCount = system->getMillis();
+ canUpdateSound = true;
+ }
+ frameIdx = barrier->frameIdx;
+ equalZero = frameIdx == 0;
+ lessZero = frameIdx < 0;
+ }
+
+ if(!(lessZero ^ 0 | equalZero)) {
+ if(system->getMillis() - barrier->tickCount >= 0x3E8 / barrier->field_B4) {
+ barrier->frameIdx = (barrier->frameIdx + 1) % barrier->frameCount;
+ // update ticks
+ barrier->tickCount = system->getMillis();
+ canUpdateSound = true;
+ }
+ }
+ } else if(flag & 8) {
+ if(system->getMillis() - barrier->tickCount >= 0x3E8 / barrier->field_B4) {
+ uint32 frameIdx = barrier->frameIdx + 1;
+ if(frameIdx < barrier->frameCount - 1) {
+ if(barrier->field_688 == 1) {
+ // TODO: get global x, y positions
+ }
+ } else {
+ barrier->flags &= 0xFFFFFFF7;
+ if(barrier->field_688 == 1) {
+ // TODO: reset global x, y positions
+ }
+ }
+ barrier->frameIdx = frameIdx;
+ }
+ } else if((flag & 0xF) & 8) { // check this
+ if(system->getMillis() - barrier->tickCount >= 1000 * barrier->tickCount2) {
+ if(rand() % (barrier->field_C0+1) == 1) { // TODO: THIS ISNT WORKING
+ barrier->frameIdx = (barrier->frameIdx + 1) % barrier->frameCount;
+ // update ticks
+ barrier->tickCount = system->getMillis();
+ canUpdateSound = true;
+ }
+ }
+ } else if(!((flag & 0xFFFF) & 6)) {
+
+ }
+
+ // TODO: go to next flags
+
+ // FIXME: this must be on drawBarrier function
+ if(b!=10 && b!=17 && b!=34 && b!=54 && b!=57 && b!=61) { // TODO: fix this
+ GraphicResource *gra = new GraphicResource(_resPack, barrier->resId);
+ GraphicFrame *fra = gra->getFrame(barrier->frameIdx);
+ copyToBackBufferClipped(&fra->surface, barrier->x, barrier->y);
+ }
+ } else {
+ // TODO: get tick count
+ // update barrier sounds
+ }
+ }
+ }
+ }
+}
+
} // end of namespace Asylum
diff --git a/engines/asylum/scene.h b/engines/asylum/scene.h
index 5d7b40031a..8d64ae15af 100644
--- a/engines/asylum/scene.h
+++ b/engines/asylum/scene.h
@@ -123,15 +123,29 @@ private:
*/
void animateCursor();
- bool isBarrierFlagsSet(BarrierItem *barrier);
- void updateBarriers(WorldStats *worldStats);
-
void updateBarrier(Screen *screen, ResourcePack *res, uint8 actorIndex);
void debugScreenScrolling(GraphicFrame *bg);
void debugShowPolygons();
void debugShowBarriers();
void debugShowWalkRegion(PolyDefinitions *poly);
+
+ // --------
+ // This are new functions to treat game process update and game draw exactly like original
+
+ int processScene(); // old updateGame (0040B5B0)
+ int processActors();
+ void processBarriers(WorldStats *worldStats);
+ int processAmbientSounds();
+ int processMusic();
+ int processAdjustScreen();
+
+ int drawScene();
+ int drawBarriers(); // old object_sub_40E1A0 (0040E1A0)
+
+ bool isBarrierVisible(BarrierItem *barrier);
+ uint32 getRandomResId(BarrierItem *barrier);
+
}; // end of class Scene
} // end of namespace Asylum
diff --git a/engines/asylum/scriptman.cpp b/engines/asylum/scriptman.cpp
index 6e5afd917a..3d2e7c4472 100644
--- a/engines/asylum/scriptman.cpp
+++ b/engines/asylum/scriptman.cpp
@@ -84,6 +84,7 @@ int ScriptManager::setBarrierNextFrame(int barrierId, int barrierFlags) {
BarrierItem *barrier = Shared.getScene()->getResources()->getBarrierByIndex(barrierIndex);
int newFlag = barrierFlags | 1 | barrier->flags;
+ barrier->flags |= barrierFlags | 1;
if(newFlag & 0x10000) {
barrier->frameIdx = barrier->frameCount - 1;
@@ -446,7 +447,7 @@ void ScriptManager::processActionList() {
else
frameNum = currentCommand->param2;
- if (Shared.getScene()->getResources()->getWorldStats()->barriers[barrierIndex].tickCount < frameNum) {
+ if (Shared.getScene()->getResources()->getWorldStats()->barriers[barrierIndex].frameIdx < frameNum) {
lineIncrement = 0;
waitCycle = true;
}
Commit: cb24392707514fb125f3444e1646b7200d77e378
https://github.com/scummvm/scummvm/commit/cb24392707514fb125f3444e1646b7200d77e378
Author: Alexandre Fontoura (alexandrefontoura at gmail.com)
Date: 2021-05-17T15:35:42+02:00
Commit Message:
ASYLUM: More Barriers work. Fixed DestroyBarrier command.
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@309 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/scene.cpp
engines/asylum/scriptman.cpp
engines/asylum/scriptman.h
diff --git a/engines/asylum/scene.cpp b/engines/asylum/scene.cpp
index 47fd1fa4e8..6e1ac7b800 100644
--- a/engines/asylum/scene.cpp
+++ b/engines/asylum/scene.cpp
@@ -571,14 +571,12 @@ void Scene::debugShowBarriers() {
// -------------------------------------------
bool Scene::isBarrierVisible(BarrierItem *barrier) {
- if((barrier->flags & 0xFF) & 1)
- {
+ if((barrier->flags & 0xFF) & 1) {
for(uint f=0; f < 10; f++) {
bool isSet = false;
uint32 flag = barrier->gameFlags[f];
- if(flag <= 0)
- {
+ if(flag <= 0) {
isSet = Shared.isGameFlagNotSet(-flag);
} else {
isSet = Shared.isGameFlagSet(flag);
@@ -613,16 +611,16 @@ void Scene::processBarriers(WorldStats *worldStats) { // old updateBarriers
uint barriersCount = worldStats->barriers.size();
int startTickCount = 0;
- bool canUpdateSound = false;
+ bool canPlaySound = false;
if(barriersCount > 0) {
for(uint b=0; b < barriersCount; b++) {
BarrierItem *barrier = &worldStats->barriers[b];
// DEBUG
- /*printf("barrierIdx: %d\n",b);
+ printf("barrierIdx: %d\n",b);
if(b==28)
- printf("barrierIdx: %d frameIdx:%d\n",b,barrier->frameIdx);*/
+ printf("barrierIdx: %d frameIdx:%d\n",b,barrier->frameIdx);
startTickCount = system->getMillis();
@@ -634,7 +632,7 @@ void Scene::processBarriers(WorldStats *worldStats) { // old updateBarriers
barrier->frameIdx = (barrier->frameIdx + 1) % barrier->frameCount;
// update ticks
barrier->tickCount = system->getMillis();
- canUpdateSound = true;
+ canPlaySound = true;
}
} else if(flag & 0x10) {
uint32 frameIdx = barrier->frameIdx;
@@ -655,7 +653,7 @@ void Scene::processBarriers(WorldStats *worldStats) { // old updateBarriers
barrier->frameIdx++;
}
barrier->tickCount = system->getMillis();
- canUpdateSound = true;
+ canPlaySound = true;
}
frameIdx = barrier->frameIdx;
equalZero = frameIdx == 0;
@@ -663,15 +661,17 @@ void Scene::processBarriers(WorldStats *worldStats) { // old updateBarriers
}
if(!(lessZero ^ 0 | equalZero)) {
- if(system->getMillis() - barrier->tickCount >= 0x3E8 / barrier->field_B4) {
+ // FIXME: we shouldn't increment field_B4 (check why this value came zero sometimes)
+ if(system->getMillis() - barrier->tickCount >= 0x3E8 / (barrier->field_B4+1)) {
barrier->frameIdx = (barrier->frameIdx + 1) % barrier->frameCount;
// update ticks
barrier->tickCount = system->getMillis();
- canUpdateSound = true;
+ canPlaySound = true;
}
}
} else if(flag & 8) {
- if(system->getMillis() - barrier->tickCount >= 0x3E8 / barrier->field_B4) {
+ // FIXME: we shouldn't increment field_B4 (check why this value came zero sometimes)
+ if(system->getMillis() - barrier->tickCount >= 0x3E8 / (barrier->field_B4+1)) {
uint32 frameIdx = barrier->frameIdx + 1;
if(frameIdx < barrier->frameCount - 1) {
if(barrier->field_688 == 1) {
@@ -685,31 +685,82 @@ void Scene::processBarriers(WorldStats *worldStats) { // old updateBarriers
}
barrier->frameIdx = frameIdx;
}
- } else if((flag & 0xF) & 8) { // check this
+ } else if((flag & 0xFF) & 8) { // check this
if(system->getMillis() - barrier->tickCount >= 1000 * barrier->tickCount2) {
- if(rand() % (barrier->field_C0+1) == 1) { // TODO: THIS ISNT WORKING
+ if(rand() % barrier->field_C0 == 1) { // TODO: THIS ISNT WORKING
barrier->frameIdx = (barrier->frameIdx + 1) % barrier->frameCount;
// update ticks
barrier->tickCount = system->getMillis();
- canUpdateSound = true;
+ canPlaySound = true;
}
}
} else if(!((flag & 0xFFFF) & 6)) {
-
+ // FIXME: we shouldn't increment field_B4 (check why this value came zero sometimes)
+ if((system->getMillis() - barrier->tickCount >= 0x3E8 / (barrier->field_B4+1)) && (flag & 0x10000)) {
+ uint frameIdx = barrier->frameIdx - 1;
+ if(frameIdx <= 0) {
+ barrier->flags &= 0xFFFEFFFF;
+ if(barrier->field_688 == 1) {
+ // TODO: reset global x, y positions
+ }
+ // update ticks
+ barrier->tickCount = system->getMillis();
+ canPlaySound = true;
+ }
+ if(barrier->field_688 == 1) {
+ // TODO: get global x, y positions
+ }
+ barrier->frameIdx = frameIdx;
+ } else if(system->getMillis() - barrier->tickCount >= 0x3E8 / (barrier->field_B4+1)) {
+ if((flag & 0xFF) & 2) {
+ if(barrier->frameIdx == barrier->frameCount - 1) {
+ barrier->frameIdx--;
+ barrier->flags = ((flag & 0xFF) & 0xFD) | 4;
+ } else {
+ barrier->frameIdx++;
+ }
+ } else if((flag & 0xFF) & 4) {
+ if(barrier->frameIdx) {
+ barrier->frameIdx--;
+ } else {
+ barrier->frameIdx++;
+ barrier->flags = ((flag & 0xFF) & 0xFB) | 2;
+ }
+ }
+ }
}
- // TODO: go to next flags
+ flag = barrier->flags;
+ flag &= 0x40000;
+ if(flag != 0) {
+ if(barrier->frameIdx == barrier->frameCount - 1) {
+ if(barrier->field_B4 <= 15) {
+ barrier->field_B4 -= 2;
+ if(barrier->field_B4 < 0) // FIXME: check this
+ barrier->field_B4 = 0;
+ } else {
+ barrier->field_B4 = 15;
+ }
+ if(!barrier->field_B4)
+ barrier->flags &= 0xFFFEF1C7;
+ }
+ }
- // FIXME: this must be on drawBarrier function
+ // TODO: this must be on drawBarrier function
if(b!=10 && b!=17 && b!=34 && b!=54 && b!=57 && b!=61) { // TODO: fix this
- GraphicResource *gra = new GraphicResource(_resPack, barrier->resId);
- GraphicFrame *fra = gra->getFrame(barrier->frameIdx);
- copyToBackBufferClipped(&fra->surface, barrier->x, barrier->y);
+ if(!(barrier->flags & 4) && !((barrier->flags & 0xFF) & 0x40)) {
+ GraphicResource *gra = new GraphicResource(_resPack, barrier->resId);
+ GraphicFrame *fra = gra->getFrame(barrier->frameIdx);
+ copyToBackBufferClipped(&fra->surface, barrier->x, barrier->y);
+ }
}
- } else {
- // TODO: get tick count
- // update barrier sounds
}
+
+ if(canPlaySound) {
+ // TODO: play sounds
+ }
+
+ // TODO: get sound functions according with scene
}
}
}
diff --git a/engines/asylum/scriptman.cpp b/engines/asylum/scriptman.cpp
index 3d2e7c4472..c07a4297d8 100644
--- a/engines/asylum/scriptman.cpp
+++ b/engines/asylum/scriptman.cpp
@@ -337,11 +337,13 @@ void ScriptManager::processActionList() {
lineIncrement = 0;
break;
-/* 0x11 */ case kDestroyObject: {
+/* 0x11 */ case kDestroyBarrier: {
int barrierIndex = Shared.getScene()->getResources()->getBarrierIndexById(currentCommand->param1);
- if (barrierIndex >= 0)
- Shared.getScene()->getResources()->getWorldStats()->barriers[barrierIndex].flags &= 0xFFFFDF; // TODO - enums for flags (0x20 is visible/playing?)
- else
+ if (barrierIndex >= 0) {
+ Shared.getScene()->getResources()->getWorldStats()->barriers[barrierIndex].flags &= 0xFFFFFFFE;
+ Shared.getScene()->getResources()->getWorldStats()->barriers[barrierIndex].flags |= 0x20000;
+ // TODO: delete graphic from draw queue
+ } else
debugC(kDebugLevelScripts,
"Requested invalid object ID:0x%02X in Scene %d Line %d.",
currentCommand->param1,
diff --git a/engines/asylum/scriptman.h b/engines/asylum/scriptman.h
index 3dd5e99cbf..beb4639ecc 100644
--- a/engines/asylum/scriptman.h
+++ b/engines/asylum/scriptman.h
@@ -94,7 +94,7 @@ enum opcodes {
kEnableActor,
kEnableBarriers,
kReturn, // 0x10
- kDestroyObject,
+ kDestroyBarrier,
k_unk12_JMP_WALK_ACTOR,
k_unk13_JMP_WALK_ACTOR,
k_unk14_JMP_WALK_ACTOR,
Commit: 0a8407801a6ba256518793cb0201d4661c0e7cf2
https://github.com/scummvm/scummvm/commit/0a8407801a6ba256518793cb0201d4661c0e7cf2
Author: Alexandre Fontoura (alexandrefontoura at gmail.com)
Date: 2021-05-17T15:35:43+02:00
Commit Message:
ASYLUM: Fixed memory leaked.
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@310 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/scene.cpp
diff --git a/engines/asylum/scene.cpp b/engines/asylum/scene.cpp
index 6e1ac7b800..c48b377078 100644
--- a/engines/asylum/scene.cpp
+++ b/engines/asylum/scene.cpp
@@ -618,9 +618,9 @@ void Scene::processBarriers(WorldStats *worldStats) { // old updateBarriers
BarrierItem *barrier = &worldStats->barriers[b];
// DEBUG
- printf("barrierIdx: %d\n",b);
+ /*printf("barrierIdx: %d\n",b);
if(b==28)
- printf("barrierIdx: %d frameIdx:%d\n",b,barrier->frameIdx);
+ printf("barrierIdx: %d frameIdx:%d\n",b,barrier->frameIdx);*/
startTickCount = system->getMillis();
@@ -628,7 +628,7 @@ void Scene::processBarriers(WorldStats *worldStats) { // old updateBarriers
if(isBarrierVisible(barrier)) {
uint32 flag = barrier->flags;
if(flag & 0x20) {
- if(system->getMillis() - barrier->tickCount >= 0x3E8 / barrier->field_B4) {
+ if(system->getMillis() - barrier->tickCount >= 0x3E8 / (barrier->field_B4+1)) {
barrier->frameIdx = (barrier->frameIdx + 1) % barrier->frameCount;
// update ticks
barrier->tickCount = system->getMillis();
@@ -752,6 +752,7 @@ void Scene::processBarriers(WorldStats *worldStats) { // old updateBarriers
GraphicResource *gra = new GraphicResource(_resPack, barrier->resId);
GraphicFrame *fra = gra->getFrame(barrier->frameIdx);
copyToBackBufferClipped(&fra->surface, barrier->x, barrier->y);
+ delete gra;
}
}
}
Commit: 844ad2ab50a6cf2fde96716a402ea4a22634bafc
https://github.com/scummvm/scummvm/commit/844ad2ab50a6cf2fde96716a402ea4a22634bafc
Author: Alexandre Fontoura (alexandrefontoura at gmail.com)
Date: 2021-05-17T15:35:43+02:00
Commit Message:
ASYLUM: Clean up!
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@311 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/scene.cpp
engines/asylum/scriptman.cpp
diff --git a/engines/asylum/scene.cpp b/engines/asylum/scene.cpp
index c48b377078..785ad42691 100644
--- a/engines/asylum/scene.cpp
+++ b/engines/asylum/scene.cpp
@@ -280,7 +280,7 @@ void Scene::update() {
// DEBUG
// Force the screen to scroll if the mouse approaches the edges
- //debugScreenScrolling(bg);
+ debugScreenScrolling(bg);
// Copy the background to the back buffer before updating the scene animations
Shared.getScreen()->copyToBackBuffer(((byte *)bg->surface.pixels) + _startY * bg->surface.w + _startX,
@@ -290,25 +290,6 @@ void Scene::update() {
640,
480);
- /* COMMENTED WHILE DEVELOPING NEW VERSION
- // TODO
- // This is a hack for scene 1. This really shouldn't be hardcoded, as the
- // activation of this barrier should be interpreted by the script manager,
- // but at the moment, we're not sure where it is in the script.
- updateBarrier(Shared.getScreen(), _resPack, 1); // inside the middle room
-
- for(uint b=0; b < _sceneResource->getWorldStats()->barriers.size(); b++) {
- if((_sceneResource->getWorldStats()->barriers[b].field_3C == 4)) {
- if ((_sceneResource->getWorldStats()->barriers[b].flags & 0x20)) // TODO - enums for flags (0x20 is visible/playing?)
- updateBarrier(Shared.getScreen(), _resPack, b);
-
- if (_sceneResource->getWorldStats()->barriers[b].flags & 8) {
- updateBarrier(Shared.getScreen(), _resPack, b);
- }
-
- }
- }*/
-
processBarriers(worldStats);
// DEBUGGING
@@ -617,13 +598,6 @@ void Scene::processBarriers(WorldStats *worldStats) { // old updateBarriers
for(uint b=0; b < barriersCount; b++) {
BarrierItem *barrier = &worldStats->barriers[b];
- // DEBUG
- /*printf("barrierIdx: %d\n",b);
- if(b==28)
- printf("barrierIdx: %d frameIdx:%d\n",b,barrier->frameIdx);*/
-
- startTickCount = system->getMillis();
-
if(barrier->field_3C == 4) {
if(isBarrierVisible(barrier)) {
uint32 flag = barrier->flags;
@@ -747,13 +721,11 @@ void Scene::processBarriers(WorldStats *worldStats) { // old updateBarriers
}
// TODO: this must be on drawBarrier function
- if(b!=10 && b!=17 && b!=34 && b!=54 && b!=57 && b!=61) { // TODO: fix this
- if(!(barrier->flags & 4) && !((barrier->flags & 0xFF) & 0x40)) {
- GraphicResource *gra = new GraphicResource(_resPack, barrier->resId);
- GraphicFrame *fra = gra->getFrame(barrier->frameIdx);
- copyToBackBufferClipped(&fra->surface, barrier->x, barrier->y);
- delete gra;
- }
+ if(!(barrier->flags & 4) && !((barrier->flags & 0xFF) & 0x40)) {
+ GraphicResource *gra = new GraphicResource(_resPack, barrier->resId);
+ GraphicFrame *fra = gra->getFrame(barrier->frameIdx);
+ copyToBackBufferClipped(&fra->surface, barrier->x, barrier->y);
+ delete gra;
}
}
diff --git a/engines/asylum/scriptman.cpp b/engines/asylum/scriptman.cpp
index c07a4297d8..d1909f7717 100644
--- a/engines/asylum/scriptman.cpp
+++ b/engines/asylum/scriptman.cpp
@@ -205,18 +205,6 @@ void ScriptManager::processActionList() {
lineIncrement = 1;
}
}
-
-
- // TODO: take this part of the code when the updateBarrier function is like original and decomment the above code
- /*int barrierIndex = Shared.getScene()->getResources()->getBarrierIndexById(currentCommand->param1);
- if (barrierIndex >= 0)
- Shared.getScene()->getResources()->getWorldStats()->barriers[barrierIndex].flags |= 0x20; // TODO - enums for flags (0x20 is visible/playing?)
- else
- debugC(kDebugLevelScripts,
- "Requested invalid object ID:0x%02X in Scene %d Line %d.",
- currentCommand->param1,
- Shared.getScene()->getSceneIndex(),
- _currentLine);*/
}
break;
Commit: d185c257c7deaf5c8c807ab4a914ea145f5b8adc
https://github.com/scummvm/scummvm/commit/d185c257c7deaf5c8c807ab4a914ea145f5b8adc
Author: Alexandre Fontoura (alexandrefontoura at gmail.com)
Date: 2021-05-17T15:35:43+02:00
Commit Message:
ASYLUM: ops (commented debugScreenScrolling)
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@312 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/scene.cpp
diff --git a/engines/asylum/scene.cpp b/engines/asylum/scene.cpp
index 785ad42691..56a4cb2578 100644
--- a/engines/asylum/scene.cpp
+++ b/engines/asylum/scene.cpp
@@ -280,7 +280,7 @@ void Scene::update() {
// DEBUG
// Force the screen to scroll if the mouse approaches the edges
- debugScreenScrolling(bg);
+ //debugScreenScrolling(bg);
// Copy the background to the back buffer before updating the scene animations
Shared.getScreen()->copyToBackBuffer(((byte *)bg->surface.pixels) + _startY * bg->surface.w + _startX,
Commit: ff72e9b326cb551ca163793488eb9194ef7ea844
https://github.com/scummvm/scummvm/commit/ff72e9b326cb551ca163793488eb9194ef7ea844
Author: Alexandre Fontoura (alexandrefontoura at gmail.com)
Date: 2021-05-17T15:35:43+02:00
Commit Message:
ASYLUM: Refactoring and clean up!
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@313 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/asylum.cpp
engines/asylum/scene.cpp
engines/asylum/scene.h
engines/asylum/scriptman.cpp
engines/asylum/scriptman.h
engines/asylum/shared.h
diff --git a/engines/asylum/asylum.cpp b/engines/asylum/asylum.cpp
index bbdd7d03b5..5e88f116ad 100644
--- a/engines/asylum/asylum.cpp
+++ b/engines/asylum/asylum.cpp
@@ -148,7 +148,6 @@ void AsylumEngine::waitForTimer(int msec_delay) {
checkForEvent(false);
processDelayedEvents();
_system->updateScreen();
- ScriptMan.processActionList();
}
}
diff --git a/engines/asylum/scene.cpp b/engines/asylum/scene.cpp
index 56a4cb2578..03d73ac0e5 100644
--- a/engines/asylum/scene.cpp
+++ b/engines/asylum/scene.cpp
@@ -26,6 +26,7 @@
#include "asylum/scene.h"
#include "asylum/sceneres.h"
#include "asylum/shared.h"
+#include "asylum/scriptman.h"
namespace Asylum {
@@ -270,28 +271,50 @@ void Scene::animateCursor() {
Shared.getScreen()->setCursor(_cursorResource, _curMouseCursor);
}
+// -------------------------------------------
+// ---------- PROCESS SCENE REGION -----------
+// -------------------------------------------
+
void Scene::update() {
- GraphicFrame *bg = _bgResource->getFrame(0);
+ if(processScene())
+ return;
+
+ // TODO: check game quality
+ drawScene();
+
+ //TODO: other process stuffs from sub 0040AE30
+}
+
+int Scene::processScene() {
+ GraphicFrame *bg = _bgResource->getFrame(0);
MainActor *mainActor = _sceneResource->getMainActor();
WorldStats *worldStats = _sceneResource->getWorldStats();
- int32 curHotspot = -1;
+ // Copy the background to the back buffer before updating the scene animations
+ Shared.getScreen()->copyToBackBuffer(((byte *)bg->surface.pixels) + _startY * bg->surface.w + _startX,
+ bg->surface.w, 0, 0, 640, 480);
+
+ // TODO: processActors
+
+ processBarriers(worldStats);
+
+ // TODO: we must get rid of this
+ OLD_UPDATE(bg, mainActor, worldStats);
+
+ if(ScriptMan.processActionList())
+ return 1;
+
+ return 0;
+}
+
+void Scene::OLD_UPDATE(GraphicFrame *bg, MainActor *mainActor, WorldStats *worldStats) {
+int32 curHotspot = -1;
int32 curBarrier = -1;
// DEBUG
// Force the screen to scroll if the mouse approaches the edges
//debugScreenScrolling(bg);
- // Copy the background to the back buffer before updating the scene animations
- Shared.getScreen()->copyToBackBuffer(((byte *)bg->surface.pixels) + _startY * bg->surface.w + _startX,
- bg->surface.w,
- 0,
- 0,
- 640,
- 480);
-
- processBarriers(worldStats);
-
// DEBUGGING
// Check current walk region
for (uint32 a = 0; a < worldStats->numActions; a++) {
@@ -394,163 +417,9 @@ void Scene::update() {
}
}
-#if 0
-void Scene::copyToSceneBackground(GraphicFrame *frame, int x, int y) {
- int h = frame->surface.h;
- int w = frame->surface.w;
- byte *buffer = (byte *)frame->surface.pixels;
- byte *dest = ((byte *)_background->surface.pixels) + y * _background->surface.w + x;
-
- while (h--) {
- memcpy(dest, buffer, w);
- dest += _background->surface.w;
- buffer += frame->surface.w;
- }
-}
-#endif
-
-void Scene::copyToBackBufferClipped(Graphics::Surface *surface, int x, int y) {
- Common::Rect screenRect(_startX, _startY, _startX + 640, _startY + 480);
- Common::Rect animRect(x, y, x + surface->w, y + surface->h);
- animRect.clip(screenRect);
-
- if (!animRect.isEmpty()) {
- // Translate anim rectangle
- animRect.translate(-_startX, -_startY);
-
- int startX = animRect.right == 640 ? 0 : surface->w - animRect.width();
- int startY = animRect.bottom == 480 ? 0 : surface->h - animRect.height();
-
- if (surface->w > 640)
- startX = _startX;
- if (surface->h > 480)
- startY = _startY;
-
- Shared.getScreen()->copyToBackBufferWithTransparency(
- ((byte*)surface->pixels) +
- startY * surface->pitch +
- startX * surface->bytesPerPixel,
- surface->pitch,
- animRect.left,
- animRect.top,
- animRect.width(),
- animRect.height());
- }
-}
-
-void Scene::updateBarrier(Screen *screen, ResourcePack *res, uint8 barrierIndex) {
- BarrierItem barrier = _sceneResource->getWorldStats()->barriers[barrierIndex];
- GraphicResource *gra = new GraphicResource(res, barrier.resId);
- if (!gra->getFrameCount())
- return;
-
- GraphicFrame *fra = gra->getFrame(barrier.tickCount);
-
-#if 0
- // DEBUG bounding box
- // FIXME this should be a generic method which draws for an entire graphicResource and not for single graphicFrames
- fra->surface.frameRect(barrier.boundingRect, 0xFF);
-#endif
-
- copyToBackBufferClipped(&fra->surface, barrier.x, barrier.y);
-
- if (barrier.tickCount < barrier.frameCount - 1) {
- barrier.tickCount++;
- } else {
- barrier.tickCount = barrier.frameIdx;
- barrier.flags &= 0xFFFFFFF7;
- }
-
- _sceneResource->getWorldStats()->barriers[barrierIndex] = barrier;
-
- delete gra;
-}
-
-void Scene::debugScreenScrolling(GraphicFrame *bg) {
- // Horizontal scrolling
- if (_mouseX < SCREEN_EDGES && _startX >= SCROLL_STEP)
- _startX -= SCROLL_STEP;
- else if (_mouseX > 640 - SCREEN_EDGES && _startX <= bg->surface.w - 640 - SCROLL_STEP)
- _startX += SCROLL_STEP;
-
- // Vertical scrolling
- if (_mouseY < SCREEN_EDGES && _startY >= SCROLL_STEP)
- _startY -= SCROLL_STEP;
- else if (_mouseY > 480 - SCREEN_EDGES && _startY <= bg->surface.h - 480 - SCROLL_STEP)
- _startY += SCROLL_STEP;
-}
-
-// WALK REGION DEBUG
-void Scene::debugShowWalkRegion(PolyDefinitions *poly) {
- Graphics::Surface surface;
- surface.create(poly->boundingRect.right - poly->boundingRect.left + 1,
- poly->boundingRect.bottom - poly->boundingRect.top + 1,
- 1);
-
- // Draw all lines in Polygon
- for (uint32 i=0; i < poly->numPoints; i++) {
- surface.drawLine(
- poly->points[i].x - poly->boundingRect.left,
- poly->points[i].y - poly->boundingRect.top,
- poly->points[(i+1) % poly->numPoints].x - poly->boundingRect.left,
- poly->points[(i+1) % poly->numPoints].y - poly->boundingRect.top, 0x3A);
- }
-
- copyToBackBufferClipped(&surface, poly->boundingRect.left, poly->boundingRect.top);
-
- surface.free();
-}
-
-// POLYGONS DEBUG
-void Scene::debugShowPolygons() {
- for (uint32 p = 0; p < _sceneResource->getGamePolygons()->numEntries; p++) {
- Graphics::Surface surface;
- PolyDefinitions poly = _sceneResource->getGamePolygons()->polygons[p];
- surface.create(poly.boundingRect.right - poly.boundingRect.left + 1,
- poly.boundingRect.bottom - poly.boundingRect.top + 1,
- 1);
-
- // Draw all lines in Polygon
- for (uint32 i=0; i < poly.numPoints; i++) {
- surface.drawLine(
- poly.points[i].x - poly.boundingRect.left,
- poly.points[i].y - poly.boundingRect.top,
- poly.points[(i+1) % poly.numPoints].x - poly.boundingRect.left,
- poly.points[(i+1) % poly.numPoints].y - poly.boundingRect.top, 0xFF);
- }
-
- copyToBackBufferClipped(&surface, poly.boundingRect.left, poly.boundingRect.top);
-
- surface.free();
- }
-}
-
-// BARRIER DEBUGGING
-void Scene::debugShowBarriers() {
- for (uint32 p = 0; p < _sceneResource->getWorldStats()->numBarriers; p++) {
- Graphics::Surface surface;
- BarrierItem b = _sceneResource->getWorldStats()->barriers[p];
-
- if (b.flags & 0x20) {
- surface.create(b.boundingRect.right - b.boundingRect.left + 1,
- b.boundingRect.bottom - b.boundingRect.top + 1,
- 1);
- surface.frameRect(b.boundingRect, 0x22);
- copyToBackBufferClipped(&surface, b.x, b.y);
- }
-
- surface.free();
- }
+void Scene::processActors() {
}
-
-
-// -------------------------------------------
-// --- NEXT CODE BLOCK IS WORK IN PROGRESS ---
-// this block will improve scene process
-// and drawing
-// -------------------------------------------
-
bool Scene::isBarrierVisible(BarrierItem *barrier) {
if((barrier->flags & 0xFF) & 1) {
for(uint f=0; f < 10; f++) {
@@ -585,10 +454,8 @@ uint32 Scene::getRandomResId(BarrierItem *barrier) {
return rndResId[rand() % numRes];
}
-// This is a new function that will process all update for Barriers
-void Scene::processBarriers(WorldStats *worldStats) { // old updateBarriers
+void Scene::processBarriers(WorldStats *worldStats) {
Screen *screen = Shared.getScreen();
- OSystem *system = Shared.getOSystem();
uint barriersCount = worldStats->barriers.size();
int startTickCount = 0;
@@ -602,10 +469,10 @@ void Scene::processBarriers(WorldStats *worldStats) { // old updateBarriers
if(isBarrierVisible(barrier)) {
uint32 flag = barrier->flags;
if(flag & 0x20) {
- if(system->getMillis() - barrier->tickCount >= 0x3E8 / (barrier->field_B4+1)) {
+ if(Shared.getMillis() - barrier->tickCount >= 0x3E8 / (barrier->field_B4+1)) {
barrier->frameIdx = (barrier->frameIdx + 1) % barrier->frameCount;
// update ticks
- barrier->tickCount = system->getMillis();
+ barrier->tickCount = Shared.getMillis();
canPlaySound = true;
}
} else if(flag & 0x10) {
@@ -613,7 +480,7 @@ void Scene::processBarriers(WorldStats *worldStats) { // old updateBarriers
char equalZero = frameIdx == 0;
char lessZero = frameIdx < 0;
if(!frameIdx) {
- if(system->getMillis() - barrier->tickCount >= 1000 * barrier->tickCount2) {
+ if(Shared.getMillis() - barrier->tickCount >= 1000 * barrier->tickCount2) {
if(rand() % barrier->field_C0 == 1) {
if(barrier->field_68C) {
// TODO: fix this, and find a better way to get frame count
@@ -626,7 +493,7 @@ void Scene::processBarriers(WorldStats *worldStats) { // old updateBarriers
}
barrier->frameIdx++;
}
- barrier->tickCount = system->getMillis();
+ barrier->tickCount = Shared.getMillis();
canPlaySound = true;
}
frameIdx = barrier->frameIdx;
@@ -636,16 +503,16 @@ void Scene::processBarriers(WorldStats *worldStats) { // old updateBarriers
if(!(lessZero ^ 0 | equalZero)) {
// FIXME: we shouldn't increment field_B4 (check why this value came zero sometimes)
- if(system->getMillis() - barrier->tickCount >= 0x3E8 / (barrier->field_B4+1)) {
+ if(Shared.getMillis() - barrier->tickCount >= 0x3E8 / (barrier->field_B4+1)) {
barrier->frameIdx = (barrier->frameIdx + 1) % barrier->frameCount;
// update ticks
- barrier->tickCount = system->getMillis();
+ barrier->tickCount = Shared.getMillis();
canPlaySound = true;
}
}
} else if(flag & 8) {
// FIXME: we shouldn't increment field_B4 (check why this value came zero sometimes)
- if(system->getMillis() - barrier->tickCount >= 0x3E8 / (barrier->field_B4+1)) {
+ if(Shared.getMillis() - barrier->tickCount >= 0x3E8 / (barrier->field_B4+1)) {
uint32 frameIdx = barrier->frameIdx + 1;
if(frameIdx < barrier->frameCount - 1) {
if(barrier->field_688 == 1) {
@@ -660,17 +527,17 @@ void Scene::processBarriers(WorldStats *worldStats) { // old updateBarriers
barrier->frameIdx = frameIdx;
}
} else if((flag & 0xFF) & 8) { // check this
- if(system->getMillis() - barrier->tickCount >= 1000 * barrier->tickCount2) {
+ if(Shared.getMillis() - barrier->tickCount >= 1000 * barrier->tickCount2) {
if(rand() % barrier->field_C0 == 1) { // TODO: THIS ISNT WORKING
barrier->frameIdx = (barrier->frameIdx + 1) % barrier->frameCount;
// update ticks
- barrier->tickCount = system->getMillis();
+ barrier->tickCount = Shared.getMillis();
canPlaySound = true;
}
}
} else if(!((flag & 0xFFFF) & 6)) {
// FIXME: we shouldn't increment field_B4 (check why this value came zero sometimes)
- if((system->getMillis() - barrier->tickCount >= 0x3E8 / (barrier->field_B4+1)) && (flag & 0x10000)) {
+ if((Shared.getMillis() - barrier->tickCount >= 0x3E8 / (barrier->field_B4+1)) && (flag & 0x10000)) {
uint frameIdx = barrier->frameIdx - 1;
if(frameIdx <= 0) {
barrier->flags &= 0xFFFEFFFF;
@@ -678,14 +545,14 @@ void Scene::processBarriers(WorldStats *worldStats) { // old updateBarriers
// TODO: reset global x, y positions
}
// update ticks
- barrier->tickCount = system->getMillis();
+ barrier->tickCount = Shared.getMillis();
canPlaySound = true;
}
if(barrier->field_688 == 1) {
// TODO: get global x, y positions
}
barrier->frameIdx = frameIdx;
- } else if(system->getMillis() - barrier->tickCount >= 0x3E8 / (barrier->field_B4+1)) {
+ } else if(Shared.getMillis() - barrier->tickCount >= 0x3E8 / (barrier->field_B4+1)) {
if((flag & 0xFF) & 2) {
if(barrier->frameIdx == barrier->frameCount - 1) {
barrier->frameIdx--;
@@ -739,4 +606,140 @@ void Scene::processBarriers(WorldStats *worldStats) { // old updateBarriers
}
}
+void Scene::processAmbientSounds() {
+}
+
+void Scene::processMusic() {
+}
+
+void Scene::processAdjustScreen() {
+}
+
+// ----------------------------------
+// ---------- DRAW REGION -----------
+// ----------------------------------
+
+int Scene::drawScene() {
+ return 1;
+}
+
+int Scene::drawBarriers() {
+ return 1;
+}
+
+
+// ----------------------------------
+// ---------- SCREEN REGION -----------
+// ----------------------------------
+
+void Scene::copyToBackBufferClipped(Graphics::Surface *surface, int x, int y) {
+ Common::Rect screenRect(_startX, _startY, _startX + 640, _startY + 480);
+ Common::Rect animRect(x, y, x + surface->w, y + surface->h);
+ animRect.clip(screenRect);
+
+ if (!animRect.isEmpty()) {
+ // Translate anim rectangle
+ animRect.translate(-_startX, -_startY);
+
+ int startX = animRect.right == 640 ? 0 : surface->w - animRect.width();
+ int startY = animRect.bottom == 480 ? 0 : surface->h - animRect.height();
+
+ if (surface->w > 640)
+ startX = _startX;
+ if (surface->h > 480)
+ startY = _startY;
+
+ Shared.getScreen()->copyToBackBufferWithTransparency(
+ ((byte*)surface->pixels) +
+ startY * surface->pitch +
+ startX * surface->bytesPerPixel,
+ surface->pitch,
+ animRect.left,
+ animRect.top,
+ animRect.width(),
+ animRect.height());
+ }
+}
+
+// ----------------------------------
+// ---------- DEBUG REGION -----------
+// ----------------------------------
+
+void Scene::debugScreenScrolling(GraphicFrame *bg) {
+ // Horizontal scrolling
+ if (_mouseX < SCREEN_EDGES && _startX >= SCROLL_STEP)
+ _startX -= SCROLL_STEP;
+ else if (_mouseX > 640 - SCREEN_EDGES && _startX <= bg->surface.w - 640 - SCROLL_STEP)
+ _startX += SCROLL_STEP;
+
+ // Vertical scrolling
+ if (_mouseY < SCREEN_EDGES && _startY >= SCROLL_STEP)
+ _startY -= SCROLL_STEP;
+ else if (_mouseY > 480 - SCREEN_EDGES && _startY <= bg->surface.h - 480 - SCROLL_STEP)
+ _startY += SCROLL_STEP;
+}
+
+// WALK REGION DEBUG
+void Scene::debugShowWalkRegion(PolyDefinitions *poly) {
+ Graphics::Surface surface;
+ surface.create(poly->boundingRect.right - poly->boundingRect.left + 1,
+ poly->boundingRect.bottom - poly->boundingRect.top + 1,
+ 1);
+
+ // Draw all lines in Polygon
+ for (uint32 i=0; i < poly->numPoints; i++) {
+ surface.drawLine(
+ poly->points[i].x - poly->boundingRect.left,
+ poly->points[i].y - poly->boundingRect.top,
+ poly->points[(i+1) % poly->numPoints].x - poly->boundingRect.left,
+ poly->points[(i+1) % poly->numPoints].y - poly->boundingRect.top, 0x3A);
+ }
+
+ copyToBackBufferClipped(&surface, poly->boundingRect.left, poly->boundingRect.top);
+
+ surface.free();
+}
+
+// POLYGONS DEBUG
+void Scene::debugShowPolygons() {
+ for (uint32 p = 0; p < _sceneResource->getGamePolygons()->numEntries; p++) {
+ Graphics::Surface surface;
+ PolyDefinitions poly = _sceneResource->getGamePolygons()->polygons[p];
+ surface.create(poly.boundingRect.right - poly.boundingRect.left + 1,
+ poly.boundingRect.bottom - poly.boundingRect.top + 1,
+ 1);
+
+ // Draw all lines in Polygon
+ for (uint32 i=0; i < poly.numPoints; i++) {
+ surface.drawLine(
+ poly.points[i].x - poly.boundingRect.left,
+ poly.points[i].y - poly.boundingRect.top,
+ poly.points[(i+1) % poly.numPoints].x - poly.boundingRect.left,
+ poly.points[(i+1) % poly.numPoints].y - poly.boundingRect.top, 0xFF);
+ }
+
+ copyToBackBufferClipped(&surface, poly.boundingRect.left, poly.boundingRect.top);
+
+ surface.free();
+ }
+}
+
+// BARRIER DEBUGGING
+void Scene::debugShowBarriers() {
+ for (uint32 p = 0; p < _sceneResource->getWorldStats()->numBarriers; p++) {
+ Graphics::Surface surface;
+ BarrierItem b = _sceneResource->getWorldStats()->barriers[p];
+
+ if (b.flags & 0x20) {
+ surface.create(b.boundingRect.right - b.boundingRect.left + 1,
+ b.boundingRect.bottom - b.boundingRect.top + 1,
+ 1);
+ surface.frameRect(b.boundingRect, 0x22);
+ copyToBackBufferClipped(&surface, b.x, b.y);
+ }
+
+ surface.free();
+ }
+}
+
} // end of namespace Asylum
diff --git a/engines/asylum/scene.h b/engines/asylum/scene.h
index 8d64ae15af..64fd7a0c09 100644
--- a/engines/asylum/scene.h
+++ b/engines/asylum/scene.h
@@ -110,6 +110,18 @@ private:
bool _isActive;
void update();
+
+ int processScene();
+ void processActors();
+ bool isBarrierVisible(BarrierItem *barrier);
+ uint32 getRandomResId(BarrierItem *barrier);
+ void processBarriers(WorldStats *worldStats);
+ void processAmbientSounds();
+ void processMusic();
+ void processAdjustScreen();
+
+ int drawScene();
+ int drawBarriers();
/**
* Check whether the cursor resource needs to be changed, and
@@ -123,28 +135,13 @@ private:
*/
void animateCursor();
- void updateBarrier(Screen *screen, ResourcePack *res, uint8 actorIndex);
-
void debugScreenScrolling(GraphicFrame *bg);
void debugShowPolygons();
void debugShowBarriers();
void debugShowWalkRegion(PolyDefinitions *poly);
- // --------
- // This are new functions to treat game process update and game draw exactly like original
-
- int processScene(); // old updateGame (0040B5B0)
- int processActors();
- void processBarriers(WorldStats *worldStats);
- int processAmbientSounds();
- int processMusic();
- int processAdjustScreen();
-
- int drawScene();
- int drawBarriers(); // old object_sub_40E1A0 (0040E1A0)
-
- bool isBarrierVisible(BarrierItem *barrier);
- uint32 getRandomResId(BarrierItem *barrier);
+ // TODO: get rid of this
+ void OLD_UPDATE(GraphicFrame *bg, MainActor *mainActor, WorldStats *worldStats);
}; // end of class Scene
diff --git a/engines/asylum/scriptman.cpp b/engines/asylum/scriptman.cpp
index d1909f7717..dfd273bb24 100644
--- a/engines/asylum/scriptman.cpp
+++ b/engines/asylum/scriptman.cpp
@@ -95,7 +95,7 @@ int ScriptManager::setBarrierNextFrame(int barrierId, int barrierFlags) {
return barrierIndex;
}
-void ScriptManager::processActionList() {
+int ScriptManager::processActionList() {
bool done = false, waitCycle = false;
int lineIncrement = 1;
@@ -167,7 +167,7 @@ void ScriptManager::processActionList() {
if(currentCommand->param2 == 2) {
if(!checkBarrierFlags(barrierId)) {
currentCommand->param2 = 1;
- return;
+ break;
}
lineIncrement = 1;
} else {
@@ -559,6 +559,8 @@ void ScriptManager::processActionList() {
}
_processing = false;
+
+ return 0;
}
void ScriptManager::processActionListSub02(ActionDefinitions* script, ActionCommand *command, int a4) {
diff --git a/engines/asylum/scriptman.h b/engines/asylum/scriptman.h
index beb4639ecc..50c77797be 100644
--- a/engines/asylum/scriptman.h
+++ b/engines/asylum/scriptman.h
@@ -37,7 +37,7 @@ struct ActionCommand;
class ScriptManager: public Common::Singleton<ScriptManager> {
public:
- void processActionList();
+ int processActionList();
void setScript(ActionDefinitions *action);
void setScriptIndex(uint32 index);
diff --git a/engines/asylum/shared.h b/engines/asylum/shared.h
index 063fb5b24f..1f3d5b7da6 100644
--- a/engines/asylum/shared.h
+++ b/engines/asylum/shared.h
@@ -48,7 +48,7 @@ class SharedResources: public Common::Singleton<SharedResources> {
public:
void setOSystem(OSystem* system) { _system = system; }
- OSystem* getOSystem() { return _system; }
+ uint32 getMillis() { return _system->getMillis(); }
void setVideo(Video* video) { _video = video; }
Video* getVideo() { return _video; }
Commit: 619f8f86f6da7d7ed70df7273a4d5ed9fdd08d25
https://github.com/scummvm/scummvm/commit/619f8f86f6da7d7ed70df7273a4d5ed9fdd08d25
Author: Alexandre Fontoura (alexandrefontoura at gmail.com)
Date: 2021-05-17T15:35:43+02:00
Commit Message:
ASYLUM: Preparing draw barriers...
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@314 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/asylum.cpp
engines/asylum/asylum.h
engines/asylum/scene.cpp
engines/asylum/scene.h
diff --git a/engines/asylum/asylum.cpp b/engines/asylum/asylum.cpp
index 5e88f116ad..52f8faed98 100644
--- a/engines/asylum/asylum.cpp
+++ b/engines/asylum/asylum.cpp
@@ -46,7 +46,8 @@ AsylumEngine::AsylumEngine(OSystem *system, Common::Language language)
Common::addDebugChannel(kDebugLevelScripts, "Scripts", "Scripts debugging");
Common::addDebugChannel(kDebugLevelSound, "Sound", "Sound debugging");
Common::addDebugChannel(kDebugLevelSavegame, "Savegame", "Saving & restoring game debugging");
-
+ Common::addDebugChannel(kDebugLevelScene, "Scene", "Scene process and draw debugging");
+
Common::File::addDefaultDirectory(_gameDataDir.getChild("Data"));
Common::File::addDefaultDirectory(_gameDataDir.getChild("Vids"));
Common::File::addDefaultDirectory(_gameDataDir.getChild("Music"));
diff --git a/engines/asylum/asylum.h b/engines/asylum/asylum.h
index 4304050644..e577fa754e 100644
--- a/engines/asylum/asylum.h
+++ b/engines/asylum/asylum.h
@@ -57,7 +57,8 @@ enum kDebugLevels {
kDebugLevelMenu = 1 << 4,
kDebugLevelScripts = 1 << 5,
kDebugLevelSound = 1 << 6,
- kDebugLevelSavegame = 1 << 7
+ kDebugLevelSavegame = 1 << 7,
+ kDebugLevelScene = 1 << 8
};
class AsylumEngine: public Engine {
diff --git a/engines/asylum/scene.cpp b/engines/asylum/scene.cpp
index 03d73ac0e5..8bffd35bb2 100644
--- a/engines/asylum/scene.cpp
+++ b/engines/asylum/scene.cpp
@@ -59,12 +59,13 @@ Scene::Scene(uint8 sceneIdx) {
_cursorResource = new GraphicResource(_resPack, _sceneResource->getWorldStats()->commonRes.curMagnifyingGlass);
- _background = 0;
- _startX = 0;
- _startY = 0;
- _leftClick = false;
- _rightButton = false;
- _isActive = false;
+ _background = 0;
+ _startX = 0;
+ _startY = 0;
+ _leftClick = false;
+ _rightButton = false;
+ _isActive = false;
+ _skipDrawScene = 0;
g_debugPolygons = 0;
g_debugBarriers = 0;
@@ -276,7 +277,7 @@ void Scene::animateCursor() {
// -------------------------------------------
void Scene::update() {
- if(processScene())
+ if(updateScene())
return;
// TODO: check game quality
@@ -285,7 +286,8 @@ void Scene::update() {
//TODO: other process stuffs from sub 0040AE30
}
-int Scene::processScene() {
+int Scene::updateScene() {
+ uint32 startTick = 0;
GraphicFrame *bg = _bgResource->getFrame(0);
MainActor *mainActor = _sceneResource->getMainActor();
WorldStats *worldStats = _sceneResource->getWorldStats();
@@ -294,9 +296,32 @@ int Scene::processScene() {
Shared.getScreen()->copyToBackBuffer(((byte *)bg->surface.pixels) + _startY * bg->surface.w + _startX,
bg->surface.w, 0, 0, 640, 480);
- // TODO: processActors
+ // Actors
+ startTick = Shared.getMillis();
+ for(uint32 a=0; a < worldStats->numActors; a++) {
+ updateActor(a);
+ }
+ debugC(kDebugLevelScene, "UpdateActors Time: %d", Shared.getMillis() - startTick);
+
+ // Barriers
+ startTick = Shared.getMillis();
+ updateBarriers(worldStats);
+ debugC(kDebugLevelScene, "UpdateBarriers Time: %d", Shared.getMillis() - startTick);
+
+ // Ambient Sounds
+ startTick = Shared.getMillis();
+ updateAmbientSounds();
+ debugC(kDebugLevelScene, "UpdateAmbientSounds Time: %d", Shared.getMillis() - startTick);
+
+ // Music
+ startTick = Shared.getMillis();
+ updateMusic();
+ debugC(kDebugLevelScene, "UpdateMusic Time: %d", Shared.getMillis() - startTick);
- processBarriers(worldStats);
+ // Adjust Screen
+ startTick = Shared.getMillis();
+ updateAdjustScreen();
+ debugC(kDebugLevelScene, "AdjustScreenStart Time: %d", Shared.getMillis() - startTick);
// TODO: we must get rid of this
OLD_UPDATE(bg, mainActor, worldStats);
@@ -307,117 +332,7 @@ int Scene::processScene() {
return 0;
}
-void Scene::OLD_UPDATE(GraphicFrame *bg, MainActor *mainActor, WorldStats *worldStats) {
-int32 curHotspot = -1;
- int32 curBarrier = -1;
-
- // DEBUG
- // Force the screen to scroll if the mouse approaches the edges
- //debugScreenScrolling(bg);
-
- // DEBUGGING
- // Check current walk region
- for (uint32 a = 0; a < worldStats->numActions; a++) {
- if (worldStats->actions[a].actionType == 0) {
- ActionArea *area = &worldStats->actions[a];
- PolyDefinitions poly = _sceneResource->getGamePolygons()->polygons[area->polyIdx];
- if (Shared.pointInPoly(&poly, mainActor->_actorX, mainActor->_actorY)) {
- debugShowWalkRegion(&poly);
- //break;
- }
- }
- }
-
- if (!_rightButton) {
- if (_sceneResource->getWorldStats()->actors[0].flags & 0x01) { // TESTING - only draw if visible flag
- // Check if the character was walking before the right-button
- // was released. If so, change the resource to one where he/she
- // is standing still, facing the last active direction
- if (_walking) {
- int currentAction = mainActor->getCurrentAction();
- if (currentAction > 0)
- mainActor->setAction(currentAction + 5);
- _walking = false;
- }
- mainActor->drawActor();
- }
- } else {
- _walking = true;
-
- mainActor->walkTo(_mouseX, _mouseY);
- updateCursor();
- }
-
- if (g_debugPolygons)
- debugShowPolygons();
- if (g_debugBarriers)
- debugShowBarriers();
-
- // Check if we're within a barrier
- for (uint32 p = 0; p < worldStats->numBarriers; p++) {
- BarrierItem b = worldStats->barriers[p];
- if (b.flags & 0x20) {
- if ((b.boundingRect.left + b.x <= _mouseX + _startX) &&
- (_mouseX + _startX < b.boundingRect.right + b.x) &&
- (b.boundingRect.top + b.y <= _mouseY + _startY) &&
- (_mouseY + _startY < b.boundingRect.bottom + b.y)) {
- animateCursor();
- curBarrier = (int32)p;
- break;
- }
- }
- }
-
- // FIXME? I'm assigning a higher priority to barriers than polygons. I'm assuming
- // that barriers that overlap polygons will have actions associated with them, and
- // the polygon will be part of a walk/look region (so it's accessible elsewhere).
- // This could be completely wrong, and if so, we just have to check to see which
- // of the barrier/polygon action scripts should be processed first
- if (curBarrier < 0) {
- // Update cursor if it's in a polygon hotspot
- for (uint32 p = 0; p < _sceneResource->getGamePolygons()->numEntries; p++) {
- PolyDefinitions poly = _sceneResource->getGamePolygons()->polygons[p];
- if (poly.boundingRect.contains(_mouseX + _startX, _mouseY + _startY)) {
- if (Shared.pointInPoly(&poly, _mouseX + _startX, _mouseY + _startY)) {
- curHotspot = (int32)p;
- animateCursor();
- break;
- }
- }
- }
- }
-
- if (_leftClick) {
- _leftClick = false;
-
- if (curHotspot >= 0) {
- for (uint32 a = 0; a < worldStats->numActions; a++) {
- if (worldStats->actions[a].polyIdx == curHotspot) {
- debugC(kDebugLevelScripts, "Hotspot: 0x%X - \"%s\", poly %d, action lists %d/%d, action type %d, sound res %d\n",
- worldStats->actions[a].id,
- worldStats->actions[a].name,
- worldStats->actions[a].polyIdx,
- worldStats->actions[a].actionListIdx1,
- worldStats->actions[a].actionListIdx2,
- worldStats->actions[a].actionType,
- worldStats->actions[a].soundResId);
- ScriptMan.setScript(&_sceneResource->getActionList()->actions[worldStats->actions[a].actionListIdx1]);
- }
- }
- } else if (curBarrier >= 0) {
- BarrierItem b = worldStats->barriers[curBarrier];
- debugC(kDebugLevelScripts, "%s: action(%d) sound(%d) flags(%d/%d)\n",
- b.name,
- b.actionListIdx,
- b.soundResId,
- b.flags,
- b.flags2);
- ScriptMan.setScript(getActionList(b.actionListIdx));
- }
- }
-}
-
-void Scene::processActors() {
+void Scene::updateActor(uint32 actor) {
}
bool Scene::isBarrierVisible(BarrierItem *barrier) {
@@ -454,7 +369,7 @@ uint32 Scene::getRandomResId(BarrierItem *barrier) {
return rndResId[rand() % numRes];
}
-void Scene::processBarriers(WorldStats *worldStats) {
+void Scene::updateBarriers(WorldStats *worldStats) {
Screen *screen = Shared.getScreen();
uint barriersCount = worldStats->barriers.size();
@@ -471,7 +386,6 @@ void Scene::processBarriers(WorldStats *worldStats) {
if(flag & 0x20) {
if(Shared.getMillis() - barrier->tickCount >= 0x3E8 / (barrier->field_B4+1)) {
barrier->frameIdx = (barrier->frameIdx + 1) % barrier->frameCount;
- // update ticks
barrier->tickCount = Shared.getMillis();
canPlaySound = true;
}
@@ -505,7 +419,6 @@ void Scene::processBarriers(WorldStats *worldStats) {
// FIXME: we shouldn't increment field_B4 (check why this value came zero sometimes)
if(Shared.getMillis() - barrier->tickCount >= 0x3E8 / (barrier->field_B4+1)) {
barrier->frameIdx = (barrier->frameIdx + 1) % barrier->frameCount;
- // update ticks
barrier->tickCount = Shared.getMillis();
canPlaySound = true;
}
@@ -530,7 +443,6 @@ void Scene::processBarriers(WorldStats *worldStats) {
if(Shared.getMillis() - barrier->tickCount >= 1000 * barrier->tickCount2) {
if(rand() % barrier->field_C0 == 1) { // TODO: THIS ISNT WORKING
barrier->frameIdx = (barrier->frameIdx + 1) % barrier->frameCount;
- // update ticks
barrier->tickCount = Shared.getMillis();
canPlaySound = true;
}
@@ -544,7 +456,6 @@ void Scene::processBarriers(WorldStats *worldStats) {
if(barrier->field_688 == 1) {
// TODO: reset global x, y positions
}
- // update ticks
barrier->tickCount = Shared.getMillis();
canPlaySound = true;
}
@@ -586,14 +497,6 @@ void Scene::processBarriers(WorldStats *worldStats) {
barrier->flags &= 0xFFFEF1C7;
}
}
-
- // TODO: this must be on drawBarrier function
- if(!(barrier->flags & 4) && !((barrier->flags & 0xFF) & 0x40)) {
- GraphicResource *gra = new GraphicResource(_resPack, barrier->resId);
- GraphicFrame *fra = gra->getFrame(barrier->frameIdx);
- copyToBackBufferClipped(&fra->surface, barrier->x, barrier->y);
- delete gra;
- }
}
if(canPlaySound) {
@@ -606,13 +509,124 @@ void Scene::processBarriers(WorldStats *worldStats) {
}
}
-void Scene::processAmbientSounds() {
+void Scene::updateAmbientSounds() {
+}
+
+void Scene::updateMusic() {
}
-void Scene::processMusic() {
+void Scene::updateAdjustScreen() {
}
-void Scene::processAdjustScreen() {
+
+void Scene::OLD_UPDATE(GraphicFrame *bg, MainActor *mainActor, WorldStats *worldStats) {
+int32 curHotspot = -1;
+ int32 curBarrier = -1;
+
+ // DEBUG
+ // Force the screen to scroll if the mouse approaches the edges
+ //debugScreenScrolling(bg);
+
+ // DEBUGGING
+ // Check current walk region
+ for (uint32 a = 0; a < worldStats->numActions; a++) {
+ if (worldStats->actions[a].actionType == 0) {
+ ActionArea *area = &worldStats->actions[a];
+ PolyDefinitions poly = _sceneResource->getGamePolygons()->polygons[area->polyIdx];
+ if (Shared.pointInPoly(&poly, mainActor->_actorX, mainActor->_actorY)) {
+ debugShowWalkRegion(&poly);
+ //break;
+ }
+ }
+ }
+
+ if (!_rightButton) {
+ if (_sceneResource->getWorldStats()->actors[0].flags & 0x01) { // TESTING - only draw if visible flag
+ // Check if the character was walking before the right-button
+ // was released. If so, change the resource to one where he/she
+ // is standing still, facing the last active direction
+ if (_walking) {
+ int currentAction = mainActor->getCurrentAction();
+ if (currentAction > 0)
+ mainActor->setAction(currentAction + 5);
+ _walking = false;
+ }
+ mainActor->drawActor();
+ }
+ } else {
+ _walking = true;
+
+ mainActor->walkTo(_mouseX, _mouseY);
+ updateCursor();
+ }
+
+ if (g_debugPolygons)
+ debugShowPolygons();
+ if (g_debugBarriers)
+ debugShowBarriers();
+
+ // Check if we're within a barrier
+ for (uint32 p = 0; p < worldStats->numBarriers; p++) {
+ BarrierItem b = worldStats->barriers[p];
+ if (b.flags & 0x20) {
+ if ((b.boundingRect.left + b.x <= _mouseX + _startX) &&
+ (_mouseX + _startX < b.boundingRect.right + b.x) &&
+ (b.boundingRect.top + b.y <= _mouseY + _startY) &&
+ (_mouseY + _startY < b.boundingRect.bottom + b.y)) {
+ animateCursor();
+ curBarrier = (int32)p;
+ break;
+ }
+ }
+ }
+
+ // FIXME? I'm assigning a higher priority to barriers than polygons. I'm assuming
+ // that barriers that overlap polygons will have actions associated with them, and
+ // the polygon will be part of a walk/look region (so it's accessible elsewhere).
+ // This could be completely wrong, and if so, we just have to check to see which
+ // of the barrier/polygon action scripts should be processed first
+ if (curBarrier < 0) {
+ // Update cursor if it's in a polygon hotspot
+ for (uint32 p = 0; p < _sceneResource->getGamePolygons()->numEntries; p++) {
+ PolyDefinitions poly = _sceneResource->getGamePolygons()->polygons[p];
+ if (poly.boundingRect.contains(_mouseX + _startX, _mouseY + _startY)) {
+ if (Shared.pointInPoly(&poly, _mouseX + _startX, _mouseY + _startY)) {
+ curHotspot = (int32)p;
+ animateCursor();
+ break;
+ }
+ }
+ }
+ }
+
+ if (_leftClick) {
+ _leftClick = false;
+
+ if (curHotspot >= 0) {
+ for (uint32 a = 0; a < worldStats->numActions; a++) {
+ if (worldStats->actions[a].polyIdx == curHotspot) {
+ debugC(kDebugLevelScripts, "Hotspot: 0x%X - \"%s\", poly %d, action lists %d/%d, action type %d, sound res %d\n",
+ worldStats->actions[a].id,
+ worldStats->actions[a].name,
+ worldStats->actions[a].polyIdx,
+ worldStats->actions[a].actionListIdx1,
+ worldStats->actions[a].actionListIdx2,
+ worldStats->actions[a].actionType,
+ worldStats->actions[a].soundResId);
+ ScriptMan.setScript(&_sceneResource->getActionList()->actions[worldStats->actions[a].actionListIdx1]);
+ }
+ }
+ } else if (curBarrier >= 0) {
+ BarrierItem b = worldStats->barriers[curBarrier];
+ debugC(kDebugLevelScripts, "%s: action(%d) sound(%d) flags(%d/%d)\n",
+ b.name,
+ b.actionListIdx,
+ b.soundResId,
+ b.flags,
+ b.flags2);
+ ScriptMan.setScript(getActionList(b.actionListIdx));
+ }
+ }
}
// ----------------------------------
@@ -620,10 +634,42 @@ void Scene::processAdjustScreen() {
// ----------------------------------
int Scene::drawScene() {
+
+ // TODO: clear graphic queue list
+
+ if(_skipDrawScene) {
+ // TODO: clear screen
+ } else {
+ // TODO: draw scene stuff
+ // TODO: prepare Actors and Barriers draw
+ // TODO: draw actors
+ drawBarriers();
+ // TODO: draw main actor stuff
+ }
+
return 1;
}
int Scene::drawBarriers() {
+ WorldStats *worldStats = _sceneResource->getWorldStats();
+ uint barriersCount = worldStats->barriers.size();
+
+ if(barriersCount > 0) {
+ for(uint b=0; b < barriersCount; b++) {
+ BarrierItem *barrier = &worldStats->barriers[b];
+
+ if(isBarrierVisible(barrier)) { // TODO: should be isBarrierOnScreen
+ // FIXME: do this like original (next phase)
+ if(!(barrier->flags & 4) && !((barrier->flags & 0xFF) & 0x40)) {
+ GraphicResource *gra = new GraphicResource(_resPack, barrier->resId);
+ GraphicFrame *fra = gra->getFrame(barrier->frameIdx);
+ copyToBackBufferClipped(&fra->surface, barrier->x, barrier->y);
+ delete gra;
+ }
+ }
+ }
+ }
+
return 1;
}
diff --git a/engines/asylum/scene.h b/engines/asylum/scene.h
index 64fd7a0c09..e7e6e5b74e 100644
--- a/engines/asylum/scene.h
+++ b/engines/asylum/scene.h
@@ -108,17 +108,18 @@ private:
uint32 _curMouseCursor;
int32 _cursorStep;
bool _isActive;
+ bool _skipDrawScene;
void update();
- int processScene();
- void processActors();
+ int updateScene();
+ void updateActor(uint32 actor);
bool isBarrierVisible(BarrierItem *barrier);
uint32 getRandomResId(BarrierItem *barrier);
- void processBarriers(WorldStats *worldStats);
- void processAmbientSounds();
- void processMusic();
- void processAdjustScreen();
+ void updateBarriers(WorldStats *worldStats);
+ void updateAmbientSounds();
+ void updateMusic();
+ void updateAdjustScreen();
int drawScene();
int drawBarriers();
Commit: 051d5d32442f048a1256d7721a64b5c893945b5b
https://github.com/scummvm/scummvm/commit/051d5d32442f048a1256d7721a64b5c893945b5b
Author: Alex Bevilacqua (alexbevi at gmail.com)
Date: 2021-05-17T15:35:43+02:00
Commit Message:
ASYLUM: Formatting
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@315 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/scene.cpp
engines/asylum/scene.h
diff --git a/engines/asylum/scene.cpp b/engines/asylum/scene.cpp
index 8bffd35bb2..cf94e91305 100644
--- a/engines/asylum/scene.cpp
+++ b/engines/asylum/scene.cpp
@@ -226,33 +226,35 @@ void Scene::handleEvent(Common::Event *event, bool doUpdate) {
}
void Scene::updateCursor() {
- uint32 newCursor = 0;
+ int action = _sceneResource->getMainActor()->getCurrentAction();
+ CommonResources *cr = &_sceneResource->getWorldStats()->commonRes;
+ uint32 newCursor = 0;
// Change cursor
- switch (_sceneResource->getMainActor()->getCurrentAction()) {
+ switch (action) {
case kWalkN:
- newCursor = _sceneResource->getWorldStats()->commonRes.curScrollUp;
+ newCursor = cr->curScrollUp;
break;
case kWalkNE:
- newCursor = _sceneResource->getWorldStats()->commonRes.curScrollUpRight;
+ newCursor = cr->curScrollUpRight;
break;
case kWalkNW:
- newCursor = _sceneResource->getWorldStats()->commonRes.curScrollUpLeft;
+ newCursor = cr->curScrollUpLeft;
break;
case kWalkS:
- newCursor = _sceneResource->getWorldStats()->commonRes.curScrollDown;
+ newCursor = cr->curScrollDown;
break;
case kWalkSE:
- newCursor = _sceneResource->getWorldStats()->commonRes.curScrollDownRight;
+ newCursor = cr->curScrollDownRight;
break;
case kWalkSW:
- newCursor = _sceneResource->getWorldStats()->commonRes.curScrollDownLeft;
+ newCursor = cr->curScrollDownLeft;
break;
case kWalkW:
- newCursor = _sceneResource->getWorldStats()->commonRes.curScrollLeft;
+ newCursor = cr->curScrollLeft;
break;
case kWalkE:
- newCursor = _sceneResource->getWorldStats()->commonRes.curScrollRight;
+ newCursor = cr->curScrollRight;
break;
}
@@ -287,7 +289,7 @@ void Scene::update() {
}
int Scene::updateScene() {
- uint32 startTick = 0;
+ uint32 startTick = 0;
GraphicFrame *bg = _bgResource->getFrame(0);
MainActor *mainActor = _sceneResource->getMainActor();
WorldStats *worldStats = _sceneResource->getWorldStats();
@@ -298,7 +300,7 @@ int Scene::updateScene() {
// Actors
startTick = Shared.getMillis();
- for(uint32 a=0; a < worldStats->numActors; a++) {
+ for (uint32 a = 0; a < worldStats->numActors; a++) {
updateActor(a);
}
debugC(kDebugLevelScene, "UpdateActors Time: %d", Shared.getMillis() - startTick);
@@ -336,12 +338,12 @@ void Scene::updateActor(uint32 actor) {
}
bool Scene::isBarrierVisible(BarrierItem *barrier) {
- if((barrier->flags & 0xFF) & 1) {
- for(uint f=0; f < 10; f++) {
- bool isSet = false;
- uint32 flag = barrier->gameFlags[f];
+ if ((barrier->flags & 0xFF) & 1) {
+ for (uint32 f = 0; f < 10; f++) {
+ bool isSet = false;
+ uint32 flag = barrier->gameFlags[f];
- if(flag <= 0) {
+ if (flag <= 0) {
isSet = Shared.isGameFlagNotSet(-flag);
} else {
isSet = Shared.isGameFlagSet(flag);
@@ -360,8 +362,8 @@ bool Scene::isBarrierVisible(BarrierItem *barrier) {
uint32 Scene::getRandomResId(BarrierItem *barrier) {
int numRes = 1;
uint32 rndResId[5];
- for(int i=0; i < 5; i++) {
- if(barrier->field_68C[i]) {
+ for (int i = 0; i < 5; i++) {
+ if (barrier->field_68C[i]) {
rndResId[numRes] = barrier->field_68C[i];
numRes++;
}
@@ -372,31 +374,31 @@ uint32 Scene::getRandomResId(BarrierItem *barrier) {
void Scene::updateBarriers(WorldStats *worldStats) {
Screen *screen = Shared.getScreen();
- uint barriersCount = worldStats->barriers.size();
- int startTickCount = 0;
- bool canPlaySound = false;
+ uint barriersCount = worldStats->barriers.size();
+ int startTickCount = 0;
+ bool canPlaySound = false;
- if(barriersCount > 0) {
- for(uint b=0; b < barriersCount; b++) {
+ if (barriersCount > 0) {
+ for (uint32 b = 0; b < barriersCount; b++) {
BarrierItem *barrier = &worldStats->barriers[b];
- if(barrier->field_3C == 4) {
- if(isBarrierVisible(barrier)) {
+ if (barrier->field_3C == 4) {
+ if (isBarrierVisible(barrier)) {
uint32 flag = barrier->flags;
- if(flag & 0x20) {
- if(Shared.getMillis() - barrier->tickCount >= 0x3E8 / (barrier->field_B4+1)) {
+ if (flag & 0x20) {
+ if (Shared.getMillis() - barrier->tickCount >= 0x3E8 / (barrier->field_B4+1)) {
barrier->frameIdx = (barrier->frameIdx + 1) % barrier->frameCount;
barrier->tickCount = Shared.getMillis();
canPlaySound = true;
}
- } else if(flag & 0x10) {
- uint32 frameIdx = barrier->frameIdx;
- char equalZero = frameIdx == 0;
- char lessZero = frameIdx < 0;
- if(!frameIdx) {
- if(Shared.getMillis() - barrier->tickCount >= 1000 * barrier->tickCount2) {
- if(rand() % barrier->field_C0 == 1) {
- if(barrier->field_68C) {
+ } else if (flag & 0x10) {
+ uint32 frameIdx = barrier->frameIdx;
+ char equalZero = frameIdx == 0;
+ char lessZero = frameIdx < 0;
+ if (!frameIdx) {
+ if (Shared.getMillis() - barrier->tickCount >= 1000 * barrier->tickCount2) {
+ if (rand() % barrier->field_C0 == 1) {
+ if (barrier->field_68C) {
// TODO: fix this, and find a better way to get frame count
// Sometimes we get wrong random resource id
@@ -410,69 +412,69 @@ void Scene::updateBarriers(WorldStats *worldStats) {
barrier->tickCount = Shared.getMillis();
canPlaySound = true;
}
- frameIdx = barrier->frameIdx;
+ frameIdx = barrier->frameIdx;
equalZero = frameIdx == 0;
- lessZero = frameIdx < 0;
+ lessZero = frameIdx < 0;
}
- if(!(lessZero ^ 0 | equalZero)) {
+ if (!(lessZero ^ 0 | equalZero)) {
// FIXME: we shouldn't increment field_B4 (check why this value came zero sometimes)
- if(Shared.getMillis() - barrier->tickCount >= 0x3E8 / (barrier->field_B4+1)) {
- barrier->frameIdx = (barrier->frameIdx + 1) % barrier->frameCount;
+ if (Shared.getMillis() - barrier->tickCount >= 0x3E8 / (barrier->field_B4+1)) {
+ barrier->frameIdx = (barrier->frameIdx + 1) % barrier->frameCount;
barrier->tickCount = Shared.getMillis();
canPlaySound = true;
}
}
- } else if(flag & 8) {
+ } else if (flag & 8) {
// FIXME: we shouldn't increment field_B4 (check why this value came zero sometimes)
- if(Shared.getMillis() - barrier->tickCount >= 0x3E8 / (barrier->field_B4+1)) {
+ if (Shared.getMillis() - barrier->tickCount >= 0x3E8 / (barrier->field_B4+1)) {
uint32 frameIdx = barrier->frameIdx + 1;
- if(frameIdx < barrier->frameCount - 1) {
- if(barrier->field_688 == 1) {
+ if (frameIdx < barrier->frameCount - 1) {
+ if (barrier->field_688 == 1) {
// TODO: get global x, y positions
}
} else {
barrier->flags &= 0xFFFFFFF7;
- if(barrier->field_688 == 1) {
+ if (barrier->field_688 == 1) {
// TODO: reset global x, y positions
}
}
barrier->frameIdx = frameIdx;
}
- } else if((flag & 0xFF) & 8) { // check this
- if(Shared.getMillis() - barrier->tickCount >= 1000 * barrier->tickCount2) {
- if(rand() % barrier->field_C0 == 1) { // TODO: THIS ISNT WORKING
- barrier->frameIdx = (barrier->frameIdx + 1) % barrier->frameCount;
+ } else if ((flag & 0xFF) & 8) { // check this
+ if (Shared.getMillis() - barrier->tickCount >= 1000 * barrier->tickCount2) {
+ if (rand() % barrier->field_C0 == 1) { // TODO: THIS ISNT WORKING
+ barrier->frameIdx = (barrier->frameIdx + 1) % barrier->frameCount;
barrier->tickCount = Shared.getMillis();
canPlaySound = true;
}
}
- } else if(!((flag & 0xFFFF) & 6)) {
+ } else if (!((flag & 0xFFFF) & 6)) {
// FIXME: we shouldn't increment field_B4 (check why this value came zero sometimes)
- if((Shared.getMillis() - barrier->tickCount >= 0x3E8 / (barrier->field_B4+1)) && (flag & 0x10000)) {
- uint frameIdx = barrier->frameIdx - 1;
- if(frameIdx <= 0) {
+ if ((Shared.getMillis() - barrier->tickCount >= 0x3E8 / (barrier->field_B4+1)) && (flag & 0x10000)) {
+ uint32 frameIdx = barrier->frameIdx - 1;
+ if (frameIdx <= 0) {
barrier->flags &= 0xFFFEFFFF;
- if(barrier->field_688 == 1) {
+ if (barrier->field_688 == 1) {
// TODO: reset global x, y positions
}
barrier->tickCount = Shared.getMillis();
canPlaySound = true;
}
- if(barrier->field_688 == 1) {
+ if (barrier->field_688 == 1) {
// TODO: get global x, y positions
}
barrier->frameIdx = frameIdx;
- } else if(Shared.getMillis() - barrier->tickCount >= 0x3E8 / (barrier->field_B4+1)) {
- if((flag & 0xFF) & 2) {
- if(barrier->frameIdx == barrier->frameCount - 1) {
+ } else if (Shared.getMillis() - barrier->tickCount >= 0x3E8 / (barrier->field_B4+1)) {
+ if ((flag & 0xFF) & 2) {
+ if (barrier->frameIdx == barrier->frameCount - 1) {
barrier->frameIdx--;
barrier->flags = ((flag & 0xFF) & 0xFD) | 4;
} else {
barrier->frameIdx++;
}
- } else if((flag & 0xFF) & 4) {
- if(barrier->frameIdx) {
+ } else if ((flag & 0xFF) & 4) {
+ if (barrier->frameIdx) {
barrier->frameIdx--;
} else {
barrier->frameIdx++;
@@ -484,22 +486,22 @@ void Scene::updateBarriers(WorldStats *worldStats) {
flag = barrier->flags;
flag &= 0x40000;
- if(flag != 0) {
- if(barrier->frameIdx == barrier->frameCount - 1) {
- if(barrier->field_B4 <= 15) {
+ if (flag != 0) {
+ if (barrier->frameIdx == barrier->frameCount - 1) {
+ if (barrier->field_B4 <= 15) {
barrier->field_B4 -= 2;
- if(barrier->field_B4 < 0) // FIXME: check this
+ if (barrier->field_B4 < 0) // FIXME: check this
barrier->field_B4 = 0;
} else {
barrier->field_B4 = 15;
}
- if(!barrier->field_B4)
+ if (!barrier->field_B4)
barrier->flags &= 0xFFFEF1C7;
}
}
}
- if(canPlaySound) {
+ if (canPlaySound) {
// TODO: play sounds
}
@@ -520,7 +522,7 @@ void Scene::updateAdjustScreen() {
void Scene::OLD_UPDATE(GraphicFrame *bg, MainActor *mainActor, WorldStats *worldStats) {
-int32 curHotspot = -1;
+ int32 curHotspot = -1;
int32 curBarrier = -1;
// DEBUG
@@ -539,7 +541,7 @@ int32 curHotspot = -1;
}
}
}
-
+ uint32 newCursor = 0;
if (!_rightButton) {
if (_sceneResource->getWorldStats()->actors[0].flags & 0x01) { // TESTING - only draw if visible flag
// Check if the character was walking before the right-button
@@ -637,7 +639,7 @@ int Scene::drawScene() {
// TODO: clear graphic queue list
- if(_skipDrawScene) {
+ if (_skipDrawScene) {
// TODO: clear screen
} else {
// TODO: draw scene stuff
@@ -654,15 +656,15 @@ int Scene::drawBarriers() {
WorldStats *worldStats = _sceneResource->getWorldStats();
uint barriersCount = worldStats->barriers.size();
- if(barriersCount > 0) {
- for(uint b=0; b < barriersCount; b++) {
+ if (barriersCount > 0) {
+ for (uint32 b = 0; b < barriersCount; b++) {
BarrierItem *barrier = &worldStats->barriers[b];
- if(isBarrierVisible(barrier)) { // TODO: should be isBarrierOnScreen
+ if (isBarrierVisible(barrier)) { // TODO: should be isBarrierOnScreen
// FIXME: do this like original (next phase)
- if(!(barrier->flags & 4) && !((barrier->flags & 0xFF) & 0x40)) {
+ if (!(barrier->flags & 4) && !((barrier->flags & 0xFF) & 0x40)) {
GraphicResource *gra = new GraphicResource(_resPack, barrier->resId);
- GraphicFrame *fra = gra->getFrame(barrier->frameIdx);
+ GraphicFrame *fra = gra->getFrame(barrier->frameIdx);
copyToBackBufferClipped(&fra->surface, barrier->x, barrier->y);
delete gra;
}
diff --git a/engines/asylum/scene.h b/engines/asylum/scene.h
index e7e6e5b74e..bf653a46e0 100644
--- a/engines/asylum/scene.h
+++ b/engines/asylum/scene.h
@@ -58,7 +58,7 @@ public:
void activate() { _isActive = true; }
void deactivate() { _isActive = false; }
bool isActive() { return _isActive; }
- int getSceneIndex() { return _sceneIdx; }
+ int getSceneIndex() { return _sceneIdx; }
ActionDefinitions* getDefaultActionList();
ActionDefinitions* getActionList(int actionListIndex);
@@ -67,18 +67,15 @@ public:
void setActorAction(int actorIndex, int action);
void actorVisible(int actorIndex, bool visible);
bool actorVisible(int actorIndex);
-
void setScenePosition(int x, int y);
SceneResource* getResources() { return _sceneResource; }
ResourcePack* getResourcePack() { return _resPack; }
ResourcePack* getMusicPack() { return _musPack; }
ResourcePack* getSpeechPack() { return _speechPack; }
-
GraphicResource* getGraphicResource(uint32 entry) { return new GraphicResource(_resPack, entry); }
-
- BlowUpPuzzle* getBlowUpPuzzle() { return _blowUp; }
- void setBlowUpPuzzle(BlowUpPuzzle* puzzle) { _blowUp = puzzle; }
+ BlowUpPuzzle* getBlowUpPuzzle() { return _blowUp; }
+ void setBlowUpPuzzle(BlowUpPuzzle* puzzle) { _blowUp = puzzle; }
private:
#if 0
@@ -110,19 +107,17 @@ private:
bool _isActive;
bool _skipDrawScene;
- void update();
-
- int updateScene();
- void updateActor(uint32 actor);
- bool isBarrierVisible(BarrierItem *barrier);
+ void update();
+ int updateScene();
+ void updateActor(uint32 actor);
+ bool isBarrierVisible(BarrierItem *barrier);
uint32 getRandomResId(BarrierItem *barrier);
- void updateBarriers(WorldStats *worldStats);
- void updateAmbientSounds();
- void updateMusic();
- void updateAdjustScreen();
-
- int drawScene();
- int drawBarriers();
+ void updateBarriers(WorldStats *worldStats);
+ void updateAmbientSounds();
+ void updateMusic();
+ void updateAdjustScreen();
+ int drawScene();
+ int drawBarriers();
/**
* Check whether the cursor resource needs to be changed, and
Commit: 11d86e9e9c81f02dbbec53ac1d1b16d4ec741231
https://github.com/scummvm/scummvm/commit/11d86e9e9c81f02dbbec53ac1d1b16d4ec741231
Author: Alexandre Fontoura (alexandrefontoura at gmail.com)
Date: 2021-05-17T15:35:43+02:00
Commit Message:
ASYLUM: More draw barriers done. Graphics Queue are now in Screen class. Did some refactor and clean up.
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@316 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/blowuppuzzle.cpp
engines/asylum/blowuppuzzle.h
engines/asylum/scene.cpp
engines/asylum/scene.h
engines/asylum/sceneres.cpp
engines/asylum/sceneres.h
engines/asylum/screen.cpp
engines/asylum/screen.h
diff --git a/engines/asylum/blowuppuzzle.cpp b/engines/asylum/blowuppuzzle.cpp
index c921158720..e21b65d961 100644
--- a/engines/asylum/blowuppuzzle.cpp
+++ b/engines/asylum/blowuppuzzle.cpp
@@ -46,54 +46,6 @@ void BlowUpPuzzle::updateCursor() {
Shared.getScreen()->setCursor(_cursorResource, _curMouseCursor);
}
-void BlowUpPuzzle::addGraphicToQueue(uint32 redId, uint32 x, uint32 y, uint32 frameIdx, uint32 flags, uint32 priority) {
- GraphicQueueItem item;
- item.resId = redId;
- item.x = x;
- item.y = y;
- item.frameIdx = frameIdx;
- item.flags = flags;
- item.priority = priority;
-
- _queueItems.push_back(item);
-}
-
-void BlowUpPuzzle::addGraphicToQueue(GraphicQueueItem item) {
- _queueItems.push_back(item);
-}
-
-void BlowUpPuzzle::updateGraphicsInQueue() {
- // sort by priority first
- graphicsSelectionSort();
- for(uint i = 0; i < _queueItems.size(); i++) {
- GraphicResource *jack = Shared.getScene()->getGraphicResource(_queueItems[i].resId);
- GraphicFrame *fra = jack->getFrame(_queueItems[i].frameIdx);
- Shared.getScreen()->copyRectToScreenWithTransparency((byte *)fra->surface.pixels, fra->surface.w, _queueItems[i].x, _queueItems[i].y, fra->surface.w, fra->surface.h);
- }
-}
-
-void BlowUpPuzzle::graphicsSelectionSort() {
- uint minIdx;
-
- for (uint i = 0; i < _queueItems.size() - 1; i++) {
- minIdx = i;
-
- for (uint j = i + 1; j < _queueItems.size(); j++)
- if (_queueItems[j].priority > _queueItems[i].priority)
- minIdx = j;
-
- if(i != minIdx)
- swapGraphicItem(i, minIdx);
- }
-}
-
-void BlowUpPuzzle::swapGraphicItem(int item1, int item2) {
- GraphicQueueItem temp;
- temp = _queueItems[item1];
- _queueItems[item1] = _queueItems[item2];
- _queueItems[item2] = temp;
-}
-
// BlowUp Puzzle VCR ---------------------------------------------------------------------------------------------
@@ -181,7 +133,7 @@ int BlowUpPuzzleVCR::inPolyRegion(int x, int y, int polyIdx) {
}
void BlowUpPuzzleVCR::update() {
- _queueItems.clear();
+ Shared.getScreen()->clearGraphicsInQueue();
if (_rightClickDown) { // quits BlowUp Puzzle
_rightClickDown = false;
@@ -212,15 +164,13 @@ void BlowUpPuzzleVCR::update() {
updateStopButton();
if(_buttonsState[kPower] == kON) {
- addGraphicToQueue(Shared.getScene()->getResources()->getWorldStats()->grResId[22], 0, 37, _tvScreenAnimIdx, 0, 1);
- addGraphicToQueue(Shared.getScene()->getResources()->getWorldStats()->grResId[23], 238, 22, _tvScreenAnimIdx++, 0, 1);
+ Shared.getScreen()->addGraphicToQueue(Shared.getScene()->getResources()->getWorldStats()->grResId[22], _tvScreenAnimIdx, 0, 37, 0, 0, 1);
+ Shared.getScreen()->addGraphicToQueue(Shared.getScene()->getResources()->getWorldStats()->grResId[23], _tvScreenAnimIdx++, 238, 22, 0, 0, 1);
_tvScreenAnimIdx %= 6;
}
if(_isAccomplished) {
- debug("BlowUpPuzzle ACCOMPLISHED!!");
-
- updateGraphicsInQueue();
+ Shared.getScreen()->drawGraphicsInQueue();
int barSize = 0;
do {
@@ -236,7 +186,7 @@ void BlowUpPuzzleVCR::update() {
_active = false;
Shared.getScene()->enterScene();
} else {
- updateGraphicsInQueue();
+ Shared.getScreen()->drawGraphicsInQueue();
}
}
@@ -307,7 +257,7 @@ void BlowUpPuzzleVCR::updateJack(Jack jack, VCRDrawInfo onTable, VCRDrawInfo plu
break;
case kOnHand: {
GraphicQueueItem jackItemOnHand = getGraphicJackItem(resIdOnHand);
- addGraphicToQueue(jackItemOnHand);
+ Shared.getScreen()->addGraphicToQueue(jackItemOnHand);
item = getGraphicShadowItem();
}
@@ -319,7 +269,7 @@ void BlowUpPuzzleVCR::updateJack(Jack jack, VCRDrawInfo onTable, VCRDrawInfo plu
if(item.resId != 0)
{
- addGraphicToQueue(item);
+ Shared.getScreen()->addGraphicToQueue(item);
}
}
@@ -422,7 +372,7 @@ void BlowUpPuzzleVCR::updateButton(Button button, VCRDrawInfo btON, VCRDrawInfo
if(item.resId != 0)
{
- addGraphicToQueue(item);
+ Shared.getScreen()->addGraphicToQueue(item);
}
}
diff --git a/engines/asylum/blowuppuzzle.h b/engines/asylum/blowuppuzzle.h
index eca09cd6ee..4a2107e245 100644
--- a/engines/asylum/blowuppuzzle.h
+++ b/engines/asylum/blowuppuzzle.h
@@ -39,17 +39,7 @@ class Scene;
class Screen;
class Sound;
class Video;
-
-typedef struct GraphicQueueItem {
- uint32 resId;
- uint32 frameIdx;
- uint32 x;
- uint32 y;
- uint32 flags;
- uint32 transTableNum;
- uint32 priority;
-
-} GraphicQueueItem;
+struct GraphicQueueItem;
class BlowUpPuzzle {
public:
@@ -76,18 +66,9 @@ protected:
GraphicResource *_bgResource;
GraphicResource *_cursorResource;
- Common::Array<GraphicQueueItem> _queueItems;
-
void updateCursor();
virtual void update() {};
- // FIXME This should probably be inside screen class
- void addGraphicToQueue(uint32 redId, uint32 x, uint32 y, uint32 frameIdx, uint32 flags, uint32 priority);
- void addGraphicToQueue(GraphicQueueItem item);
- void updateGraphicsInQueue();
- void graphicsSelectionSort();
- void swapGraphicItem(int item1, int item2);
-
}; // end of class BlowUpPuzzle
diff --git a/engines/asylum/scene.cpp b/engines/asylum/scene.cpp
index cf94e91305..04e13d7fd9 100644
--- a/engines/asylum/scene.cpp
+++ b/engines/asylum/scene.cpp
@@ -290,13 +290,7 @@ void Scene::update() {
int Scene::updateScene() {
uint32 startTick = 0;
- GraphicFrame *bg = _bgResource->getFrame(0);
- MainActor *mainActor = _sceneResource->getMainActor();
- WorldStats *worldStats = _sceneResource->getWorldStats();
-
- // Copy the background to the back buffer before updating the scene animations
- Shared.getScreen()->copyToBackBuffer(((byte *)bg->surface.pixels) + _startY * bg->surface.w + _startX,
- bg->surface.w, 0, 0, 640, 480);
+ WorldStats *worldStats = _sceneResource->getWorldStats();
// Actors
startTick = Shared.getMillis();
@@ -325,9 +319,6 @@ int Scene::updateScene() {
updateAdjustScreen();
debugC(kDebugLevelScene, "AdjustScreenStart Time: %d", Shared.getMillis() - startTick);
- // TODO: we must get rid of this
- OLD_UPDATE(bg, mainActor, worldStats);
-
if(ScriptMan.processActionList())
return 1;
@@ -344,7 +335,7 @@ bool Scene::isBarrierVisible(BarrierItem *barrier) {
uint32 flag = barrier->gameFlags[f];
if (flag <= 0) {
- isSet = Shared.isGameFlagNotSet(-flag);
+ isSet = Shared.isGameFlagNotSet(flag); // -flag
} else {
isSet = Shared.isGameFlagSet(flag);
}
@@ -359,6 +350,15 @@ bool Scene::isBarrierVisible(BarrierItem *barrier) {
return false;
}
+
+bool Scene::isBarrierOnScreen(BarrierItem *barrier) {
+ WorldStats *worldStats = _sceneResource->getWorldStats();
+ Common::Rect screenRect = Common::Rect(worldStats->xLeft, worldStats->yTop, worldStats->xLeft + 640, worldStats->yTop + 480);
+ Common::Rect barrierRect = barrier->boundingRect;
+ barrierRect.translate(barrier->x, barrier->y);
+ return isBarrierVisible(barrier) && (barrier->flags & 1) && screenRect.intersects(barrierRect);
+}
+
uint32 Scene::getRandomResId(BarrierItem *barrier) {
int numRes = 1;
uint32 rndResId[5];
@@ -521,9 +521,10 @@ void Scene::updateAdjustScreen() {
}
-void Scene::OLD_UPDATE(GraphicFrame *bg, MainActor *mainActor, WorldStats *worldStats) {
+void Scene::OLD_UPDATE(WorldStats *worldStats) {
int32 curHotspot = -1;
int32 curBarrier = -1;
+ MainActor *mainActor = _sceneResource->getMainActor();
// DEBUG
// Force the screen to scroll if the mouse approaches the edges
@@ -606,7 +607,7 @@ void Scene::OLD_UPDATE(GraphicFrame *bg, MainActor *mainActor, WorldStats *world
if (curHotspot >= 0) {
for (uint32 a = 0; a < worldStats->numActions; a++) {
- if (worldStats->actions[a].polyIdx == curHotspot) {
+ if (worldStats->actions[a].polyIdx == (uint32)curHotspot) {
debugC(kDebugLevelScripts, "Hotspot: 0x%X - \"%s\", poly %d, action lists %d/%d, action type %d, sound res %d\n",
worldStats->actions[a].id,
worldStats->actions[a].name,
@@ -637,16 +638,25 @@ void Scene::OLD_UPDATE(GraphicFrame *bg, MainActor *mainActor, WorldStats *world
int Scene::drawScene() {
- // TODO: clear graphic queue list
+ Shared.getScreen()->clearGraphicsInQueue();
if (_skipDrawScene) {
- // TODO: clear screen
+ Shared.getScreen()->clearScreen();
} else {
- // TODO: draw scene stuff
+ // Draw scene background
+ WorldStats *worldStats = _sceneResource->getWorldStats();
+ GraphicFrame *bg = _bgResource->getFrame(0);
+ Shared.getScreen()->copyToBackBuffer(((byte *)bg->surface.pixels) + _startY * bg->surface.w + _startX, bg->surface.w, worldStats->xLeft, worldStats->yTop, 640, 480);
+
// TODO: prepare Actors and Barriers draw
// TODO: draw actors
drawBarriers();
// TODO: draw main actor stuff
+
+ Shared.getScreen()->drawGraphicsInQueue();
+
+ // TODO: we must get rid of this
+ OLD_UPDATE(worldStats);
}
return 1;
@@ -660,13 +670,17 @@ int Scene::drawBarriers() {
for (uint32 b = 0; b < barriersCount; b++) {
BarrierItem *barrier = &worldStats->barriers[b];
- if (isBarrierVisible(barrier)) { // TODO: should be isBarrierOnScreen
- // FIXME: do this like original (next phase)
- if (!(barrier->flags & 4) && !((barrier->flags & 0xFF) & 0x40)) {
- GraphicResource *gra = new GraphicResource(_resPack, barrier->resId);
- GraphicFrame *fra = gra->getFrame(barrier->frameIdx);
- copyToBackBufferClipped(&fra->surface, barrier->x, barrier->y);
- delete gra;
+ if (!(barrier->flags & 4) && !((barrier->flags & 0xFF) & 0x40)) {
+ if (isBarrierOnScreen(barrier)) {
+ //TODO: need to do something here yet
+
+ if (barrier->field_67C <= 0 || barrier->field_67C >= 4) { // TODO: still missing a condition for game quality config
+ Shared.getScreen()->addGraphicToQueue(barrier->resId, barrier->frameIdx, barrier->x, barrier->y, (barrier->flags >> 11) & 2, barrier->field_67C - 3, barrier->priority);
+ } else {
+ // TODO: Do Cross Fade
+ // parameters: barrier->resId, barrier->frameIdx, barrier->x, barrier->y, worldStats->commonRes.backgroundImage, worldStats->xLeft, worldStats->yTop, 0, 0, barrier->field_67C - 1
+ Shared.getScreen()->addGraphicToQueue(barrier->resId, barrier->frameIdx, barrier->x, barrier->y, 0, 0, 0);
+ }
}
}
}
diff --git a/engines/asylum/scene.h b/engines/asylum/scene.h
index bf653a46e0..323c853785 100644
--- a/engines/asylum/scene.h
+++ b/engines/asylum/scene.h
@@ -110,8 +110,6 @@ private:
void update();
int updateScene();
void updateActor(uint32 actor);
- bool isBarrierVisible(BarrierItem *barrier);
- uint32 getRandomResId(BarrierItem *barrier);
void updateBarriers(WorldStats *worldStats);
void updateAmbientSounds();
void updateMusic();
@@ -119,6 +117,10 @@ private:
int drawScene();
int drawBarriers();
+ bool isBarrierVisible(BarrierItem *barrier);
+ bool isBarrierOnScreen(BarrierItem *barrier);
+ uint32 getRandomResId(BarrierItem *barrier);
+
/**
* Check whether the cursor resource needs to be changed, and
* if so, make that change
@@ -137,7 +139,7 @@ private:
void debugShowWalkRegion(PolyDefinitions *poly);
// TODO: get rid of this
- void OLD_UPDATE(GraphicFrame *bg, MainActor *mainActor, WorldStats *worldStats);
+ void OLD_UPDATE(WorldStats *worldStats);
}; // end of class Scene
diff --git a/engines/asylum/sceneres.cpp b/engines/asylum/sceneres.cpp
index dff35a1052..9dba4a175f 100644
--- a/engines/asylum/sceneres.cpp
+++ b/engines/asylum/sceneres.cpp
@@ -235,7 +235,7 @@ void SceneResource::loadWorldStats(Common::SeekableReadStream *stream) {
barrier.tickCount = stream->readUint32LE();
barrier.tickCount2 = stream->readUint32LE();
barrier.field_C0 = stream->readUint32LE();
- barrier.field_C4 = stream->readUint32LE();
+ barrier.priority = stream->readUint32LE();
barrier.actionListIdx = stream->readUint32LE();
for (i = 0; i < 16; i++) {
diff --git a/engines/asylum/sceneres.h b/engines/asylum/sceneres.h
index 04f778c02b..1bd07afa83 100644
--- a/engines/asylum/sceneres.h
+++ b/engines/asylum/sceneres.h
@@ -147,7 +147,7 @@ typedef struct BarrierItem {
uint32 tickCount;
uint32 tickCount2;
uint32 field_C0;
- uint32 field_C4;
+ uint32 priority;
uint32 actionListIdx;
SoundItem soundItems[16];
FrameSoundItem frameSoundItems[50];
diff --git a/engines/asylum/screen.cpp b/engines/asylum/screen.cpp
index 6db6e17d78..1a4319bb4f 100644
--- a/engines/asylum/screen.cpp
+++ b/engines/asylum/screen.cpp
@@ -24,6 +24,7 @@
*/
#include "asylum/screen.h"
+#include "asylum/shared.h"
namespace Asylum {
@@ -114,4 +115,61 @@ void Screen::clearScreen() {
_sys->fillScreen(0);
}
+void Screen::addGraphicToQueue(uint32 redId, uint32 frameIdx, uint32 x, uint32 y, uint32 flags, uint32 transTableNum, uint32 priority) {
+ GraphicQueueItem item;
+ item.resId = redId;
+ item.x = x;
+ item.y = y;
+ item.frameIdx = frameIdx;
+ item.flags = flags;
+ item.priority = priority;
+
+ _queueItems.push_back(item);
+}
+
+void Screen::addCrossFadeGraphicToQueue(uint32 redId, uint32 frameIdx, uint32 x, uint32 y, uint32 redId2, uint32 x2, uint32 y2, uint32 flags, uint32 priority) {
+
+}
+
+void Screen::addGraphicToQueue(GraphicQueueItem item) {
+ _queueItems.push_back(item);
+}
+
+void Screen::drawGraphicsInQueue() {
+ // sort by priority first
+ graphicsSelectionSort();
+ for(uint i = 0; i < _queueItems.size(); i++) {
+ GraphicResource *grRes = Shared.getScene()->getGraphicResource(_queueItems[i].resId);
+ GraphicFrame *fra = grRes->getFrame(_queueItems[i].frameIdx);
+ copyRectToScreenWithTransparency((byte *)fra->surface.pixels, fra->surface.w, _queueItems[i].x, _queueItems[i].y, fra->surface.w, fra->surface.h);
+ delete grRes;
+ }
+}
+
+void Screen::clearGraphicsInQueue() {
+ _queueItems.clear();
+}
+
+void Screen::graphicsSelectionSort() {
+ uint minIdx;
+
+ for (uint i = 0; i < _queueItems.size() - 1; i++) {
+ minIdx = i;
+
+ for (uint j = i + 1; j < _queueItems.size(); j++)
+ if (_queueItems[j].priority > _queueItems[i].priority)
+ minIdx = j;
+
+ if(i != minIdx)
+ swapGraphicItem(i, minIdx);
+ }
+}
+
+void Screen::swapGraphicItem(int item1, int item2) {
+ GraphicQueueItem temp;
+ temp = _queueItems[item1];
+ _queueItems[item1] = _queueItems[item2];
+ _queueItems[item2] = temp;
+}
+
} // end of namespace Asylum
diff --git a/engines/asylum/screen.h b/engines/asylum/screen.h
index 826f8f6c2d..c8d2ceeeb0 100644
--- a/engines/asylum/screen.h
+++ b/engines/asylum/screen.h
@@ -35,6 +35,17 @@
namespace Asylum {
+typedef struct GraphicQueueItem {
+ uint32 resId;
+ uint32 frameIdx;
+ uint32 x;
+ uint32 y;
+ uint32 flags;
+ uint32 transTableNum;
+ uint32 priority;
+
+} GraphicQueueItem;
+
class Screen {
public:
Screen(OSystem *sys);
@@ -58,9 +69,19 @@ public:
setCursor((byte *)mouseCursor->surface.pixels, mouseCursor->surface.w, mouseCursor->surface.h);
}
+ void addGraphicToQueue(uint32 redId, uint32 frameIdx, uint32 x, uint32 y, uint32 flags, uint32 transTableNum, uint32 priority);
+ void addCrossFadeGraphicToQueue(uint32 redId, uint32 frameIdx, uint32 x, uint32 y, uint32 redId2, uint32 x2, uint32 y2, uint32 flags, uint32 priority);
+ void addGraphicToQueue(GraphicQueueItem item);
+ void drawGraphicsInQueue();
+ void clearGraphicsInQueue();
+ void graphicsSelectionSort();
+ void swapGraphicItem(int item1, int item2);
+
private:
Graphics::Surface _backBuffer;
OSystem *_sys;
+
+ Common::Array<GraphicQueueItem> _queueItems;
};
} // end of namespace Asylum
Commit: e9bde0e96582b9a202299860d08bb864fa36b7ea
https://github.com/scummvm/scummvm/commit/e9bde0e96582b9a202299860d08bb864fa36b7ea
Author: Alexandre Fontoura (alexandrefontoura at gmail.com)
Date: 2021-05-17T15:35:44+02:00
Commit Message:
ASYLUM: Few script commands work.
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@317 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/screen.cpp
engines/asylum/screen.h
engines/asylum/scriptman.cpp
diff --git a/engines/asylum/screen.cpp b/engines/asylum/screen.cpp
index 1a4319bb4f..5bc8a953c1 100644
--- a/engines/asylum/screen.cpp
+++ b/engines/asylum/screen.cpp
@@ -172,4 +172,13 @@ void Screen::swapGraphicItem(int item1, int item2) {
_queueItems[item2] = temp;
}
+void Screen::deleteGraphicFromQueue(uint32 resId) {
+ for(uint i = 0; i < _queueItems.size(); i++) {
+ if(_queueItems[i].resId == resId) {
+ _queueItems.remove_at(i);
+ break;
+ }
+ }
+}
+
} // end of namespace Asylum
diff --git a/engines/asylum/screen.h b/engines/asylum/screen.h
index c8d2ceeeb0..56cf7a50b2 100644
--- a/engines/asylum/screen.h
+++ b/engines/asylum/screen.h
@@ -76,6 +76,7 @@ public:
void clearGraphicsInQueue();
void graphicsSelectionSort();
void swapGraphicItem(int item1, int item2);
+ void deleteGraphicFromQueue(uint32 resId);
private:
Graphics::Surface _backBuffer;
diff --git a/engines/asylum/scriptman.cpp b/engines/asylum/scriptman.cpp
index dfd273bb24..eb36685ad1 100644
--- a/engines/asylum/scriptman.cpp
+++ b/engines/asylum/scriptman.cpp
@@ -177,7 +177,7 @@ int ScriptManager::processActionList() {
if(currentCommand->param4) { // RECHECK THIS
int newBarriedIndex = 213 * barrierIndex;
barrier->flags &= 0xFFFEF1C7;
- Shared.getScene()->getResources()->getBarrierByIndex(2*newBarriedIndex)->flags = barrier->flags | 0x20;
+ Shared.getScene()->getResources()->getBarrierByIndex(newBarriedIndex)->flags = barrier->flags | 0x20;
} else if(currentCommand->param3) {
barrier->flags &= 0xFFFEF1C7;
barrier->flags |= 0x10000;
@@ -208,7 +208,72 @@ int ScriptManager::processActionList() {
}
break;
-/* 0x08 */ //case kMoveScenePosition:
+/* 0x08 */ case kMoveScenePosition: {
+ WorldStats *worldStats = Shared.getScene()->getResources()->getWorldStats();
+ if (currentCommand->param3 < 1) {
+ worldStats->xLeft = currentCommand->param1;
+ worldStats->yTop = currentCommand->param2;
+ worldStats->motionStatus = 3;
+ } else if (!currentCommand->param4) {
+ worldStats->motionStatus = 5;
+ worldStats->targetX = currentCommand->param1;
+ worldStats->targetY = currentCommand->param2;
+ worldStats->field_A0 = currentCommand->param3;
+
+ if (worldStats->targetX < worldStats->sceneRects[worldStats->sceneRectIdx].left) {
+ worldStats->targetX = worldStats->sceneRects[worldStats->sceneRectIdx].left;
+ }
+
+ if (worldStats->targetY < worldStats->sceneRects[worldStats->sceneRectIdx].top) {
+ worldStats->targetY = worldStats->sceneRects[worldStats->sceneRectIdx].top;
+ }
+
+ if (worldStats->targetX + 640 > worldStats->sceneRects[worldStats->sceneRectIdx].right) {
+ worldStats->targetX = worldStats->sceneRects[worldStats->sceneRectIdx].right - 640;
+ }
+
+ if (worldStats->targetY + 480 > worldStats->sceneRects[worldStats->sceneRectIdx].bottom) {
+ worldStats->targetY = worldStats->sceneRects[worldStats->sceneRectIdx].bottom - 480;
+ }
+
+ // TODO: reverse asm block
+
+ } else if (currentCommand->param5) {
+ if (worldStats->motionStatus == 2)
+ lineIncrement = 1;
+ else
+ currentCommand->param5 = 0;
+ } else {
+ currentCommand->param5 = 1;
+ worldStats->motionStatus = 2;
+ worldStats->targetX = currentCommand->param1;
+ worldStats->targetY = currentCommand->param2;
+ worldStats->field_A0 = currentCommand->param3;
+
+ if (worldStats->targetX + 640 > worldStats->width) {
+ worldStats->targetX = worldStats->width - 640;
+ }
+
+ if (worldStats->targetX < worldStats->sceneRects[worldStats->sceneRectIdx].left) {
+ worldStats->targetX = worldStats->sceneRects[worldStats->sceneRectIdx].left;
+ }
+
+ if (worldStats->targetY < worldStats->sceneRects[worldStats->sceneRectIdx].top) {
+ worldStats->targetY = worldStats->sceneRects[worldStats->sceneRectIdx].top;
+ }
+
+ if (worldStats->targetX + 640 > worldStats->sceneRects[worldStats->sceneRectIdx].right) {
+ worldStats->targetX = worldStats->sceneRects[worldStats->sceneRectIdx].right - 640;
+ }
+
+ if (worldStats->targetY + 480 > worldStats->sceneRects[worldStats->sceneRectIdx].bottom) {
+ worldStats->targetY = worldStats->sceneRects[worldStats->sceneRectIdx].bottom - 480;
+ }
+
+ // TODO: reverse asm block
+ }
+ }
+ break;
/* 0x09 */ case kHideActor: {
uint32 actorIndex = 0;
if (currentCommand->param1 == -1)
@@ -265,10 +330,16 @@ int ScriptManager::processActionList() {
}
break;
-/* 0x0C */ //case kSetSceneMotionStat:
+/* 0x0C */ case kSetSceneMotionStat:
+ Shared.getScene()->getResources()->getWorldStats()->motionStatus = currentCommand->param1;
+ break;
/* 0x0D */ case kDisableActor: {
- // TODO handle character index != 0
- Shared.getScene()->getResources()->getMainActor()->disable(5);
+ int actorIndex = 0;
+ if (currentCommand->param1 == -1)
+ ;//actorIndex = Shared.getScene()->getWorldStats()->playerActor;
+ else
+ actorIndex = currentCommand->param1;
+ Shared.getScene()->getResources()->getMainActor()->disable(actorIndex);
}
break;
/* 0x0E */ case kEnableActor: {
@@ -328,9 +399,10 @@ int ScriptManager::processActionList() {
/* 0x11 */ case kDestroyBarrier: {
int barrierIndex = Shared.getScene()->getResources()->getBarrierIndexById(currentCommand->param1);
if (barrierIndex >= 0) {
- Shared.getScene()->getResources()->getWorldStats()->barriers[barrierIndex].flags &= 0xFFFFFFFE;
- Shared.getScene()->getResources()->getWorldStats()->barriers[barrierIndex].flags |= 0x20000;
- // TODO: delete graphic from draw queue
+ BarrierItem *barrier = &Shared.getScene()->getResources()->getWorldStats()->barriers[barrierIndex];
+ barrier->flags &= 0xFFFFFFFE;
+ barrier->flags |= 0x20000;
+ Shared.getScreen()->deleteGraphicFromQueue(barrier->resId);
} else
debugC(kDebugLevelScripts,
"Requested invalid object ID:0x%02X in Scene %d Line %d.",
@@ -344,8 +416,22 @@ int ScriptManager::processActionList() {
/* 0x13 */ //case k_unk13_JMP_WALK_ACTOR:
/* 0x14 */ //case k_unk14_JMP_WALK_ACTOR:
/* 0x15 */ //case k_unk15:
-/* 0x16 */ //case kResetAnimation:
-/* 0x17 */ //case kClearFlag1Bit0:
+/* 0x16 */ case kResetAnimation: {
+ int barrierIndex = Shared.getScene()->getResources()->getBarrierIndexById(currentCommand->param1);
+ BarrierItem *barrier = &Shared.getScene()->getResources()->getWorldStats()->barriers[barrierIndex];
+ if ((barrier->flags & 0x10000) == 0) {
+ barrier->frameIdx = 0;
+ } else {
+ barrier->frameIdx = barrier->frameCount - 1;
+ }
+ }
+ break;
+/* 0x17 */ case kClearFlag1Bit0: {
+ int barrierIndex = Shared.getScene()->getResources()->getBarrierIndexById(currentCommand->param1);
+ BarrierItem *barrier = &Shared.getScene()->getResources()->getWorldStats()->barriers[barrierIndex];
+ barrier->flags &= 0xFFFFFFFE;
+ }
+ break;
/* 0x18 */ //case k_unk18_PLAY_SND:
/* 0x19 */ //case kJumpIfFlag2Bit0:
/* 0x1A */ case kSetFlag2Bit0: {
@@ -388,6 +474,7 @@ int ScriptManager::processActionList() {
/* 0x2C */ //case k_unk2C_ActorSub:
/* 0x2D */ case kPlayMovie:
+ // TODO: add missing code here
_delayedVideoIndex = currentCommand->param1;
break;
@@ -404,7 +491,14 @@ int ScriptManager::processActionList() {
Shared.getSound()->stopMusic();
break;
-/* 0x34 */ //case k_unk34_Status:
+/* 0x34 */ case k_unk34_Status:
+ if (currentCommand->param1 >= 2) {
+ currentCommand->param1 = 0;
+ } else {
+ currentCommand->param1++;
+ lineIncrement = 1;
+ }
+ break;
/* 0x35 */ //case k_unk35:
/* 0x36 */ //case k_unk36:
/* 0x37 */ case kRunBlowUpPuzzle: {
@@ -420,11 +514,12 @@ int ScriptManager::processActionList() {
/* 0x3B */ //case k_unk3B_PALETTE_MOD:
/* 0x3C */ case k_unk3C_CMP_VAL: {
if (currentCommand->param1) {
- if (currentCommand->param2 >= currentCommand->param1)
+ if (currentCommand->param2 >= currentCommand->param1) {
currentCommand->param2 = 0;
- else
- currentCommand->param2 = currentCommand->param1 + 1;
- // XXX done = true; ???
+ } else {
+ currentCommand->param2++;
+ lineIncrement = 1;
+ }
}
}
break;
Commit: 0c8d8a920823ea981f4936a3318b85066b68ff76
https://github.com/scummvm/scummvm/commit/0c8d8a920823ea981f4936a3318b85066b68ff76
Author: Alexandre Fontoura (alexandrefontoura at gmail.com)
Date: 2021-05-17T15:35:44+02:00
Commit Message:
ASYLUM: kJumpBarrierFrame (0x51) command done.
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@318 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/scriptman.cpp
engines/asylum/scriptman.h
diff --git a/engines/asylum/scriptman.cpp b/engines/asylum/scriptman.cpp
index eb36685ad1..25dccbd39a 100644
--- a/engines/asylum/scriptman.cpp
+++ b/engines/asylum/scriptman.cpp
@@ -220,19 +220,19 @@ int ScriptManager::processActionList() {
worldStats->targetY = currentCommand->param2;
worldStats->field_A0 = currentCommand->param3;
- if (worldStats->targetX < worldStats->sceneRects[worldStats->sceneRectIdx].left) {
+ if (worldStats->targetX < (uint32)worldStats->sceneRects[worldStats->sceneRectIdx].left) {
worldStats->targetX = worldStats->sceneRects[worldStats->sceneRectIdx].left;
}
- if (worldStats->targetY < worldStats->sceneRects[worldStats->sceneRectIdx].top) {
+ if (worldStats->targetY < (uint32)worldStats->sceneRects[worldStats->sceneRectIdx].top) {
worldStats->targetY = worldStats->sceneRects[worldStats->sceneRectIdx].top;
}
- if (worldStats->targetX + 640 > worldStats->sceneRects[worldStats->sceneRectIdx].right) {
+ if (worldStats->targetX + 640 > (uint32)worldStats->sceneRects[worldStats->sceneRectIdx].right) {
worldStats->targetX = worldStats->sceneRects[worldStats->sceneRectIdx].right - 640;
}
- if (worldStats->targetY + 480 > worldStats->sceneRects[worldStats->sceneRectIdx].bottom) {
+ if (worldStats->targetY + 480 > (uint32)worldStats->sceneRects[worldStats->sceneRectIdx].bottom) {
worldStats->targetY = worldStats->sceneRects[worldStats->sceneRectIdx].bottom - 480;
}
@@ -254,19 +254,19 @@ int ScriptManager::processActionList() {
worldStats->targetX = worldStats->width - 640;
}
- if (worldStats->targetX < worldStats->sceneRects[worldStats->sceneRectIdx].left) {
+ if (worldStats->targetX < (uint32)worldStats->sceneRects[worldStats->sceneRectIdx].left) {
worldStats->targetX = worldStats->sceneRects[worldStats->sceneRectIdx].left;
}
- if (worldStats->targetY < worldStats->sceneRects[worldStats->sceneRectIdx].top) {
+ if (worldStats->targetY < (uint32)worldStats->sceneRects[worldStats->sceneRectIdx].top) {
worldStats->targetY = worldStats->sceneRects[worldStats->sceneRectIdx].top;
}
- if (worldStats->targetX + 640 > worldStats->sceneRects[worldStats->sceneRectIdx].right) {
+ if (worldStats->targetX + 640 > (uint32)worldStats->sceneRects[worldStats->sceneRectIdx].right) {
worldStats->targetX = worldStats->sceneRects[worldStats->sceneRectIdx].right - 640;
}
- if (worldStats->targetY + 480 > worldStats->sceneRects[worldStats->sceneRectIdx].bottom) {
+ if (worldStats->targetY + 480 > (uint32)worldStats->sceneRects[worldStats->sceneRectIdx].bottom) {
worldStats->targetY = worldStats->sceneRects[worldStats->sceneRectIdx].bottom - 480;
}
@@ -609,7 +609,32 @@ int ScriptManager::processActionList() {
break;
/* 0x50 */ //case kQuit:
-/* 0x51 */ //case kJumpObjectFrame:
+/* 0x51 */ case kJumpBarrierFrame: {
+ BarrierItem *barrier = Shared.getScene()->getResources()->getBarrierById(currentCommand->param1);
+ if (currentCommand->param2 == -1) {
+ currentCommand->param2 = barrier->frameCount - 1;
+ }
+
+ if (currentCommand->param3 && currentCommand->param2 == barrier->frameIdx) {
+ break;
+ } else if (currentCommand->param4 && currentCommand->param2 < barrier->frameIdx) {
+ break;
+ } else if (currentCommand->param5 && currentCommand->param2 > barrier->frameIdx) {
+ break;
+ } else if (currentCommand->param6 && currentCommand->param2 <= barrier->frameIdx) {
+ break;
+ } else if (currentCommand->param7 && currentCommand->param2 >= barrier->frameIdx) {
+ break;
+ } else if (currentCommand->param8 && currentCommand->param2 != barrier->frameIdx) {
+ break;
+ }
+
+ ActionCommand *cmd = &_currentScript->commands[currentCommand->param9];
+ if (cmd->opcode != kReturn && cmd->opcode) {
+ done = true;
+ }
+ }
+ break;
/* 0x52 */ //case k_unk52:
/* 0x53 */ //case k_unk53:
/* 0x54 */ //case k_unk54_SET_ACTIONLIST_6EC:
diff --git a/engines/asylum/scriptman.h b/engines/asylum/scriptman.h
index 50c77797be..661b955358 100644
--- a/engines/asylum/scriptman.h
+++ b/engines/asylum/scriptman.h
@@ -158,7 +158,7 @@ enum opcodes {
k_unk4E_RANDOM_COMMAND,
kClearScreen,
kQuit, // 0x50
- kJumpObjectFrame,
+ kJumpBarrierFrame,
k_unk52,
k_unk53,
k_unk54_SET_ACTIONLIST_6EC,
Commit: 7badaaaddced20dc2dd1dc68bdcbcc0a8dd1763e
https://github.com/scummvm/scummvm/commit/7badaaaddced20dc2dd1dc68bdcbcc0a8dd1763e
Author: Alex Bevilacqua (alexbevi at gmail.com)
Date: 2021-05-17T15:35:44+02:00
Commit Message:
ASYLUM: Minor readability formatting
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@319 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/scriptman.cpp
diff --git a/engines/asylum/scriptman.cpp b/engines/asylum/scriptman.cpp
index 25dccbd39a..745f3ca1bd 100644
--- a/engines/asylum/scriptman.cpp
+++ b/engines/asylum/scriptman.cpp
@@ -209,66 +209,52 @@ int ScriptManager::processActionList() {
break;
/* 0x08 */ case kMoveScenePosition: {
- WorldStats *worldStats = Shared.getScene()->getResources()->getWorldStats();
+ WorldStats *ws = Shared.getScene()->getResources()->getWorldStats();
+ Common::Rect *sr = &ws->sceneRects[ws->sceneRectIdx];
+
if (currentCommand->param3 < 1) {
- worldStats->xLeft = currentCommand->param1;
- worldStats->yTop = currentCommand->param2;
- worldStats->motionStatus = 3;
+ ws->xLeft = currentCommand->param1;
+ ws->yTop = currentCommand->param2;
+ ws->motionStatus = 3;
} else if (!currentCommand->param4) {
- worldStats->motionStatus = 5;
- worldStats->targetX = currentCommand->param1;
- worldStats->targetY = currentCommand->param2;
- worldStats->field_A0 = currentCommand->param3;
-
- if (worldStats->targetX < (uint32)worldStats->sceneRects[worldStats->sceneRectIdx].left) {
- worldStats->targetX = worldStats->sceneRects[worldStats->sceneRectIdx].left;
- }
-
- if (worldStats->targetY < (uint32)worldStats->sceneRects[worldStats->sceneRectIdx].top) {
- worldStats->targetY = worldStats->sceneRects[worldStats->sceneRectIdx].top;
- }
-
- if (worldStats->targetX + 640 > (uint32)worldStats->sceneRects[worldStats->sceneRectIdx].right) {
- worldStats->targetX = worldStats->sceneRects[worldStats->sceneRectIdx].right - 640;
- }
-
- if (worldStats->targetY + 480 > (uint32)worldStats->sceneRects[worldStats->sceneRectIdx].bottom) {
- worldStats->targetY = worldStats->sceneRects[worldStats->sceneRectIdx].bottom - 480;
- }
+ ws->motionStatus = 5;
+ ws->targetX = currentCommand->param1;
+ ws->targetY = currentCommand->param2;
+ ws->field_A0 = currentCommand->param3;
+
+ if (ws->targetX < (uint32)sr->left)
+ ws->targetX = sr->left;
+ if (ws->targetY < (uint32)sr->top)
+ ws->targetY = sr->top;
+ if (ws->targetX + 640 > (uint32)sr->right)
+ ws->targetX = sr->right - 640;
+ if (ws->targetY + 480 > (uint32)sr->bottom)
+ ws->targetY = sr->bottom - 480;
// TODO: reverse asm block
} else if (currentCommand->param5) {
- if (worldStats->motionStatus == 2)
+ if (ws->motionStatus == 2)
lineIncrement = 1;
else
currentCommand->param5 = 0;
} else {
currentCommand->param5 = 1;
- worldStats->motionStatus = 2;
- worldStats->targetX = currentCommand->param1;
- worldStats->targetY = currentCommand->param2;
- worldStats->field_A0 = currentCommand->param3;
-
- if (worldStats->targetX + 640 > worldStats->width) {
- worldStats->targetX = worldStats->width - 640;
- }
-
- if (worldStats->targetX < (uint32)worldStats->sceneRects[worldStats->sceneRectIdx].left) {
- worldStats->targetX = worldStats->sceneRects[worldStats->sceneRectIdx].left;
- }
-
- if (worldStats->targetY < (uint32)worldStats->sceneRects[worldStats->sceneRectIdx].top) {
- worldStats->targetY = worldStats->sceneRects[worldStats->sceneRectIdx].top;
- }
-
- if (worldStats->targetX + 640 > (uint32)worldStats->sceneRects[worldStats->sceneRectIdx].right) {
- worldStats->targetX = worldStats->sceneRects[worldStats->sceneRectIdx].right - 640;
- }
-
- if (worldStats->targetY + 480 > (uint32)worldStats->sceneRects[worldStats->sceneRectIdx].bottom) {
- worldStats->targetY = worldStats->sceneRects[worldStats->sceneRectIdx].bottom - 480;
- }
+ ws->motionStatus = 2;
+ ws->targetX = currentCommand->param1;
+ ws->targetY = currentCommand->param2;
+ ws->field_A0 = currentCommand->param3;
+
+ if (ws->targetX + 640 > ws->width)
+ ws->targetX = ws->width - 640;
+ if (ws->targetX < (uint32)sr->left)
+ ws->targetX = sr->left;
+ if (ws->targetY < (uint32)sr->top)
+ ws->targetY = sr->top;
+ if (ws->targetX + 640 > (uint32)sr->right)
+ ws->targetX = sr->right - 640;
+ if (ws->targetY + 480 > (uint32)sr->bottom)
+ ws->targetY = sr->bottom - 480;
// TODO: reverse asm block
}
@@ -443,7 +429,6 @@ int ScriptManager::processActionList() {
// int actionIdx = getActionIndex(currentCommand->param1);
//scene.actionAreas[actionIdx].flags |= 1;
debugC(kDebugLevelScripts, "ActionArea Flag Set not implemented");
-
} else {
Shared.getScene()->getResources()->getBarrierById(currentCommand->param1)->flags2 |= 1;
}
Commit: adbf7b6ab1a500fada96d8f24d8be99cc9bb3211
https://github.com/scummvm/scummvm/commit/adbf7b6ab1a500fada96d8f24d8be99cc9bb3211
Author: Alexandre Fontoura (alexandrefontoura at gmail.com)
Date: 2021-05-17T15:35:44+02:00
Commit Message:
ASYLUM: More work on ScriptManager.
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@320 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/sceneres.h
engines/asylum/scriptman.cpp
engines/asylum/scriptman.h
diff --git a/engines/asylum/sceneres.h b/engines/asylum/sceneres.h
index 1bd07afa83..d9eddab6f6 100644
--- a/engines/asylum/sceneres.h
+++ b/engines/asylum/sceneres.h
@@ -299,7 +299,9 @@ public:
Common::Array<ActorItem> actors; // maxsize 50
// TODO add rest fields
Common::Array<ActionArea> actions; // maxsize 400
-
+ // TODO add rest fields
+ uint32 field_E860C;
+ // TODO add rest fields
}; // end of class WorldStats
typedef struct PolyDefinitions{
diff --git a/engines/asylum/scriptman.cpp b/engines/asylum/scriptman.cpp
index 745f3ca1bd..c3e58d406b 100644
--- a/engines/asylum/scriptman.cpp
+++ b/engines/asylum/scriptman.cpp
@@ -383,9 +383,8 @@ int ScriptManager::processActionList() {
break;
/* 0x11 */ case kDestroyBarrier: {
- int barrierIndex = Shared.getScene()->getResources()->getBarrierIndexById(currentCommand->param1);
- if (barrierIndex >= 0) {
- BarrierItem *barrier = &Shared.getScene()->getResources()->getWorldStats()->barriers[barrierIndex];
+ BarrierItem *barrier = Shared.getScene()->getResources()->getBarrierById(currentCommand->param1);
+ if (barrier) {
barrier->flags &= 0xFFFFFFFE;
barrier->flags |= 0x20000;
Shared.getScreen()->deleteGraphicFromQueue(barrier->resId);
@@ -403,8 +402,7 @@ int ScriptManager::processActionList() {
/* 0x14 */ //case k_unk14_JMP_WALK_ACTOR:
/* 0x15 */ //case k_unk15:
/* 0x16 */ case kResetAnimation: {
- int barrierIndex = Shared.getScene()->getResources()->getBarrierIndexById(currentCommand->param1);
- BarrierItem *barrier = &Shared.getScene()->getResources()->getWorldStats()->barriers[barrierIndex];
+ BarrierItem *barrier = Shared.getScene()->getResources()->getBarrierById(currentCommand->param1);
if ((barrier->flags & 0x10000) == 0) {
barrier->frameIdx = 0;
} else {
@@ -413,8 +411,7 @@ int ScriptManager::processActionList() {
}
break;
/* 0x17 */ case kClearFlag1Bit0: {
- int barrierIndex = Shared.getScene()->getResources()->getBarrierIndexById(currentCommand->param1);
- BarrierItem *barrier = &Shared.getScene()->getResources()->getWorldStats()->barriers[barrierIndex];
+ BarrierItem *barrier = Shared.getScene()->getResources()->getBarrierById(currentCommand->param1);
barrier->flags &= 0xFFFFFFFE;
}
break;
@@ -486,7 +483,7 @@ int ScriptManager::processActionList() {
break;
/* 0x35 */ //case k_unk35:
/* 0x36 */ //case k_unk36:
-/* 0x37 */ case kRunBlowUpPuzzle: {
+/* 0x37 */ case kRunBlowUpPuzzle: { // FIXME: improve this to call other blowUpPuzzles than VCR
int blowUpPuzzleIdx = currentCommand->param1;
Shared.getScene()->setBlowUpPuzzle(new BlowUpPuzzleVCR());
Shared.getScene()->getBlowUpPuzzle()->openBlowUp();
@@ -509,15 +506,15 @@ int ScriptManager::processActionList() {
}
break;
/* 0x3D */ case kWaitUntilFramePlayed: {
- int barrierIndex = Shared.getScene()->getResources()->getBarrierIndexById(currentCommand->param1);
- if (barrierIndex >= 0) {
+ BarrierItem *barrier = Shared.getScene()->getResources()->getBarrierById(currentCommand->param1);
+ if (barrier) {
uint32 frameNum = 0;
if (currentCommand->param2 == -1)
- frameNum = Shared.getScene()->getResources()->getWorldStats()->barriers[barrierIndex].frameCount - 1;
+ frameNum = barrier->frameCount - 1;
else
frameNum = currentCommand->param2;
- if (Shared.getScene()->getResources()->getWorldStats()->barriers[barrierIndex].frameIdx < frameNum) {
+ if (barrier->frameIdx < frameNum) {
lineIncrement = 0;
waitCycle = true;
}
@@ -622,21 +619,86 @@ int ScriptManager::processActionList() {
break;
/* 0x52 */ //case k_unk52:
/* 0x53 */ //case k_unk53:
-/* 0x54 */ //case k_unk54_SET_ACTIONLIST_6EC:
-/* 0x55 */ //case k_unk55:
+/* 0x54 */ case k_unk54_SET_ACTIONLIST_6EC:
+ if (currentCommand->param2) {
+ _currentScript->field_1BB0 = rand() % currentCommand->param1;
+ } else {
+ _currentScript->field_1BB0 = currentCommand->param1;
+ }
+ break;
+/* 0x55 */ case k_unk55: {
+ if (!currentCommand->param2) {
+ if (currentCommand->param3 && _currentScript->field_1BB0 < currentCommand->param1)
+ break;
+ else if (currentCommand->param4 && _currentScript->field_1BB0 > currentCommand->param1)
+ break;
+ else if (currentCommand->param5 && _currentScript->field_1BB0 <= currentCommand->param1)
+ break;
+ else if (currentCommand->param6 && _currentScript->field_1BB0 >= currentCommand->param1)
+ break;
+ else if (currentCommand->param7 && _currentScript->field_1BB0 != currentCommand->param1)
+ break;
+ } else if(_currentScript->field_1BB0 == currentCommand->param1)
+ break;
+
+ ActionCommand *cmd = &_currentScript->commands[currentCommand->param8];
+ if (cmd->opcode != kReturn && cmd->opcode) {
+ done = true;
+ } else {
+ lineIncrement = currentCommand->param8;
+ }
+ }
+ break;
/* 0x56 */ //case k_unk56:
-/* 0x57 */ //case k_unk57:
-/* 0x58 */ //case k_unk58:
+/* 0x57 */ case kSetResourcePalette: {
+ if (currentCommand->param1 > 0) {
+ Shared.getScreen()->setPalette(Shared.getScene()->getResourcePack(), Shared.getScene()->getResources()->getWorldStats()->grResId[currentCommand->param1]);
+ }
+ }
+ break;
+/* 0x58 */ case kSetBarrierFrameIdxFlaged: {
+ BarrierItem *barrier = Shared.getScene()->getResources()->getBarrierById(currentCommand->param1);
+ if (currentCommand->param3) {
+ barrier->flags = 1 | barrier->flags;
+ } else {
+ barrier->flags = barrier->flags & 0xFFFFFFFE;
+ }
+ barrier->frameIdx = currentCommand->param2;
+ }
+ break;
/* 0x59 */ //case k_unk59:
/* 0x5A */ //case k_unk5A:
/* 0x5B */ //case k_unk5B:
/* 0x5C */ //case k_unk5C:
/* 0x5D */ //case k_unk5D:
/* 0x5E */ //case k_unk5E:
-/* 0x5F */ //case k_unk5F:
+/* 0x5F */ case kSetBarrierLastFrameIdx: {
+ BarrierItem *barrier = Shared.getScene()->getResources()->getBarrierById(currentCommand->param1);
+ if (barrier->frameIdx == barrier->frameCount - 1) {
+ lineIncrement = 0;
+ barrier->flags &= 0xFFFEF1C7;
+ } else {
+ lineIncrement = 1;
+ }
+ }
+ break;
/* 0x60 */ //case k_unk60_SET_OR_CLR_ACTIONAREA_FLAG:
-/* 0x61 */ //case k_unk61:
+/* 0x61 */ case k_unk61:
+ if (currentCommand->param2) {
+ if (Shared.getScene()->getResources()->getWorldStats()->field_E860C == -1) {
+ lineIncrement = 0;
+ currentCommand->param2 = 0;
+ } else {
+ lineIncrement = 1;
+ }
+ } else {
+ // TODO: do something for scene number 9
+ currentCommand->param2 = 1;
+ lineIncrement = 1;
+ }
+ break;
/* 0x62 */ //case k_unk62_SHOW_OPTIONS_SCREEN:
+/* 0x63 */ //case k_unk61:
default:
debugC(kDebugLevelScripts,
diff --git a/engines/asylum/scriptman.h b/engines/asylum/scriptman.h
index 661b955358..dff8367e5c 100644
--- a/engines/asylum/scriptman.h
+++ b/engines/asylum/scriptman.h
@@ -164,18 +164,19 @@ enum opcodes {
k_unk54_SET_ACTIONLIST_6EC,
k_unk55,
k_unk56,
- k_unk57,
- k_unk58,
+ kSetResourcePalette,
+ kSetBarrierFrameIdxFlaged,
k_unk59,
k_unk5A,
k_unk5B,
k_unk5C,
k_unk5D,
k_unk5E,
- k_unk5F,
+ kSetBarrierLastFrameIdx,
k_unk60_SET_OR_CLR_ACTIONAREA_FLAG, // 0x60
k_unk61,
- k_unk62_SHOW_OPTIONS_SCREEN
+ k_unk62_SHOW_OPTIONS_SCREEN,
+ k_unk63
};
#define ScriptMan (::Asylum::ScriptManager::instance())
Commit: a52992c543370659b3f25e0f286b473bcf87be40
https://github.com/scummvm/scummvm/commit/a52992c543370659b3f25e0f286b473bcf87be40
Author: Alexandre Fontoura (alexandrefontoura at gmail.com)
Date: 2021-05-17T15:35:44+02:00
Commit Message:
ASYLUM: Little work on Actors
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@321 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/scene.cpp
engines/asylum/scene.h
engines/asylum/sceneres.cpp
engines/asylum/sceneres.h
diff --git a/engines/asylum/scene.cpp b/engines/asylum/scene.cpp
index 04e13d7fd9..5e192b9098 100644
--- a/engines/asylum/scene.cpp
+++ b/engines/asylum/scene.cpp
@@ -70,8 +70,26 @@ Scene::Scene(uint8 sceneIdx) {
g_debugPolygons = 0;
g_debugBarriers = 0;
- // TODO Not sure why this is done ... yet
Shared.setGameFlag(183);
+
+ // TODO: do all the rest stuffs in sub at address 40E460
+ WorldStats *worldStats = _sceneResource->getWorldStats();
+ _playerActorIdx = 0;
+
+ if (worldStats->numBarriers > 0) {
+ uint32 priority = 0x0FFB;
+ for (int b=0; b < worldStats->numBarriers; b++) {
+ BarrierItem *barrier = &worldStats->barriers[b];
+ barrier->priority = priority;
+ barrier->flags &= 0xFFFF3FFF;
+ priority -= 4;
+ }
+ }
+ worldStats->sceneRectIdx = 0;
+ Shared.getScreen()->clearGraphicsInQueue();
+ worldStats->motionStatus = 1;
+ // TODO: do some rect stuffs from player actor
+ // TODO: reset actors flags
}
Scene::~Scene() {
@@ -325,7 +343,104 @@ int Scene::updateScene() {
return 0;
}
-void Scene::updateActor(uint32 actor) {
+int Scene::isActorVisible(ActorItem *actor) {
+ return actor->flags & 1;
+}
+
+void Scene::updateActor(uint32 actorIdx) {
+ WorldStats *worldStats = _sceneResource->getWorldStats();
+ ActorItem *actor = &worldStats->actors[actorIdx];
+
+ if (isActorVisible(actor)) {
+ switch (actor->field_40) {
+
+ case 0x10:
+ if (worldStats->numChapter == 2) {
+ // TODO: updateCharacterSub14()
+ } else if (worldStats->numChapter == 1) {
+ if (_playerActorIdx == actorIdx) {
+ // TODO: updateActorSub21();
+ }
+ }
+ break;
+ case 0x11:
+ if (worldStats->numChapter == 2) {
+ // TODO: put code here
+ } else if (worldStats->numChapter == 11) {
+ if (_playerActorIdx == actorIdx) {
+ // TODO: put code here
+ }
+ }
+ break;
+ case 0xF:
+ if (worldStats->numChapter == 2) {
+ // TODO: put code here
+ } else if (worldStats->numChapter == 11) {
+ // TODO: put code here
+ }
+ break;
+ case 0x12:
+ if (worldStats->numChapter == 2) {
+ // TODO: put code here
+ }
+ break;
+ case 0x5: {
+ uint32 frameNum = actor->frameNum + 1;
+ actor->frameNum = frameNum % actor->frameCount;
+
+ if (Shared.getMillis() - actor->tickValue1 > 300) {
+ if (rand() % 100 < 50) {
+ // TODO: check sound playing
+ }
+ actor->tickValue1 = Shared.getMillis();
+ }
+ }
+ break;
+ case 0xC:
+ if (worldStats->numChapter == 2) {
+ // TODO: put code here
+ } else if (worldStats->numChapter == 11) {
+ // TODO: put code here
+ }
+ case 0x1:
+ // TODO: do actor direction
+ break;
+ case 0x2:
+ case 0xD:
+ // TODO: do actor direction
+ break;
+ case 0x3:
+ case 0x13:
+ // TODO: updateCharacterSub05();
+ break;
+ case 0x7:
+ // TODO: something
+ break;
+ case 0x4:
+ if (actor->field_944 != 5) {
+ // TODO: updateCharacterSub01_sw(1, actorIdx);
+ }
+ break;
+ case 0xE:
+ // TODO: updateCharacterSub02(1, actorIdx);
+ break;
+ case 0x15:
+ // TODO: updateCharacterSub06(1, actorIdx);
+ break;
+ case 0x9:
+ // TODO: updateCharacterSub03(1, actorIdx);
+ break;
+ case 0x6:
+ case 0xA:
+ actor->frameNum = (actor->frameNum + 1) % actor->frameCount;
+ break;
+ case 0x8:
+ // TODO: actor sound
+ break;
+ default:
+ break;
+ }
+ }
}
bool Scene::isBarrierVisible(BarrierItem *barrier) {
diff --git a/engines/asylum/scene.h b/engines/asylum/scene.h
index 323c853785..ae53df0879 100644
--- a/engines/asylum/scene.h
+++ b/engines/asylum/scene.h
@@ -47,6 +47,8 @@ struct ActionDefinitions;
struct PolyDefinitions;
struct BarrierItem;
+//uint32 playerTypeTable[16] = {0, 0, 0, 0, 1, 0, 2, 0, 3, 0, 1, 1, 3, 0, 0, 0};
+
class Scene {
public:
Scene(uint8 sceneIdx);
@@ -78,9 +80,6 @@ public:
void setBlowUpPuzzle(BlowUpPuzzle* puzzle) { _blowUp = puzzle; }
private:
-#if 0
- void copyToSceneBackground(GraphicFrame *frame, int x, int y);
-#endif
void copyToBackBufferClipped(Graphics::Surface *surface, int x, int y);
uint8 _sceneIdx;
@@ -106,10 +105,11 @@ private:
int32 _cursorStep;
bool _isActive;
bool _skipDrawScene;
+ uint32 _playerActorIdx;
void update();
int updateScene();
- void updateActor(uint32 actor);
+ void updateActor(uint32 actorIdx);
void updateBarriers(WorldStats *worldStats);
void updateAmbientSounds();
void updateMusic();
@@ -117,6 +117,8 @@ private:
int drawScene();
int drawBarriers();
+ int isActorVisible(ActorItem *actor);
+
bool isBarrierVisible(BarrierItem *barrier);
bool isBarrierOnScreen(BarrierItem *barrier);
uint32 getRandomResId(BarrierItem *barrier);
diff --git a/engines/asylum/sceneres.cpp b/engines/asylum/sceneres.cpp
index 9dba4a175f..5ba542cc8b 100644
--- a/engines/asylum/sceneres.cpp
+++ b/engines/asylum/sceneres.cpp
@@ -271,7 +271,7 @@ void SceneResource::loadWorldStats(Common::SeekableReadStream *stream) {
}
// need to jump all unused barriers data to where actors data start
- stream->seek(0xA6D7A);
+ stream->seek(0xA6D7A);
for (uint32 a = 0; a < _worldStats->numActors; a++) {
int i;
diff --git a/engines/asylum/sceneres.h b/engines/asylum/sceneres.h
index d9eddab6f6..6d450081af 100644
--- a/engines/asylum/sceneres.h
+++ b/engines/asylum/sceneres.h
@@ -46,19 +46,6 @@ class GamePolygons;
class ActionList;
struct BarrierItem;
-#if 0
-// TODO/FIXME: Are there REALLY any points which go beyond 32768???
-// ScummVM common Point uses int16 and we need int32
-typedef struct Point {
- int32 x, y;
-} Point;
-
-// ScummVM common Rect uses int16 and we need int32
-typedef struct Rect {
- int32 top, left, bottom, right;
-} Rect;
-#endif
-
class SceneResource {
public:
SceneResource();
@@ -236,8 +223,10 @@ typedef struct ActorItem {
uint32 flags2;
uint32 field_934;
uint32 field_938;
- uint32 soundResId;
- // TODO field_940 till field_978
+ uint32 soundResId; // field_93C
+ uint32 field_940;
+ uint32 field_944;
+ // TODO field_948 till field_978
uint32 actionIdx1;
// TODO field_980 till field_9A0
Commit: 49c0f354287398f56bb6d4ab0bab0d2d13127447
https://github.com/scummvm/scummvm/commit/49c0f354287398f56bb6d4ab0bab0d2d13127447
Author: Alexandre Fontoura (alexandrefontoura at gmail.com)
Date: 2021-05-17T15:35:44+02:00
Commit Message:
ASYLUM: Some barrier fixes.
Fixed addGraphicInQueue.
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@322 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/scene.cpp
engines/asylum/screen.cpp
diff --git a/engines/asylum/scene.cpp b/engines/asylum/scene.cpp
index 5e192b9098..3bc093d5be 100644
--- a/engines/asylum/scene.cpp
+++ b/engines/asylum/scene.cpp
@@ -78,7 +78,7 @@ Scene::Scene(uint8 sceneIdx) {
if (worldStats->numBarriers > 0) {
uint32 priority = 0x0FFB;
- for (int b=0; b < worldStats->numBarriers; b++) {
+ for (uint32 b=0; b < worldStats->numBarriers; b++) {
BarrierItem *barrier = &worldStats->barriers[b];
barrier->priority = priority;
barrier->flags &= 0xFFFF3FFF;
@@ -475,15 +475,19 @@ bool Scene::isBarrierOnScreen(BarrierItem *barrier) {
}
uint32 Scene::getRandomResId(BarrierItem *barrier) {
- int numRes = 1;
+ int numRes = 0;
uint32 rndResId[5];
+ memset(&rndResId, 0, sizeof(rndResId));
for (int i = 0; i < 5; i++) {
if (barrier->field_68C[i]) {
rndResId[numRes] = barrier->field_68C[i];
numRes++;
}
}
- return rndResId[rand() % numRes];
+ if(numRes > 0)
+ return rndResId[rand() % numRes];
+
+ return barrier->resId;
}
void Scene::updateBarriers(WorldStats *worldStats) {
@@ -497,11 +501,14 @@ void Scene::updateBarriers(WorldStats *worldStats) {
for (uint32 b = 0; b < barriersCount; b++) {
BarrierItem *barrier = &worldStats->barriers[b];
+ if(b==61)
+ printf("%d: \n",b);
+
if (barrier->field_3C == 4) {
if (isBarrierVisible(barrier)) {
uint32 flag = barrier->flags;
if (flag & 0x20) {
- if (Shared.getMillis() - barrier->tickCount >= 0x3E8 / (barrier->field_B4+1)) {
+ if (barrier->field_B4 && (Shared.getMillis() - barrier->tickCount >= 0x3E8 / barrier->field_B4)) {
barrier->frameIdx = (barrier->frameIdx + 1) % barrier->frameCount;
barrier->tickCount = Shared.getMillis();
canPlaySound = true;
@@ -513,14 +520,14 @@ void Scene::updateBarriers(WorldStats *worldStats) {
if (!frameIdx) {
if (Shared.getMillis() - barrier->tickCount >= 1000 * barrier->tickCount2) {
if (rand() % barrier->field_C0 == 1) {
- if (barrier->field_68C) {
+ if (barrier->field_68C[0]) {
// TODO: fix this, and find a better way to get frame count
// Sometimes we get wrong random resource id
- /*barrier->resId = getRandomResId(barrier);
+ barrier->resId = getRandomResId(barrier);
GraphicResource *gra = new GraphicResource(_resPack, barrier->resId);
barrier->frameCount = gra->getFrameCount();
- delete gra; */
+ delete gra;
}
barrier->frameIdx++;
}
@@ -534,7 +541,7 @@ void Scene::updateBarriers(WorldStats *worldStats) {
if (!(lessZero ^ 0 | equalZero)) {
// FIXME: we shouldn't increment field_B4 (check why this value came zero sometimes)
- if (Shared.getMillis() - barrier->tickCount >= 0x3E8 / (barrier->field_B4+1)) {
+ if (barrier->field_B4 && (Shared.getMillis() - barrier->tickCount >= 0x3E8 / barrier->field_B4)) {
barrier->frameIdx = (barrier->frameIdx + 1) % barrier->frameCount;
barrier->tickCount = Shared.getMillis();
canPlaySound = true;
@@ -542,7 +549,7 @@ void Scene::updateBarriers(WorldStats *worldStats) {
}
} else if (flag & 8) {
// FIXME: we shouldn't increment field_B4 (check why this value came zero sometimes)
- if (Shared.getMillis() - barrier->tickCount >= 0x3E8 / (barrier->field_B4+1)) {
+ if (barrier->field_B4 && (Shared.getMillis() - barrier->tickCount >= 0x3E8 / barrier->field_B4)) {
uint32 frameIdx = barrier->frameIdx + 1;
if (frameIdx < barrier->frameCount - 1) {
if (barrier->field_688 == 1) {
@@ -566,7 +573,7 @@ void Scene::updateBarriers(WorldStats *worldStats) {
}
} else if (!((flag & 0xFFFF) & 6)) {
// FIXME: we shouldn't increment field_B4 (check why this value came zero sometimes)
- if ((Shared.getMillis() - barrier->tickCount >= 0x3E8 / (barrier->field_B4+1)) && (flag & 0x10000)) {
+ if (barrier->field_B4 && (Shared.getMillis() - barrier->tickCount >= 0x3E8 / barrier->field_B4) && (flag & 0x10000)) {
uint32 frameIdx = barrier->frameIdx - 1;
if (frameIdx <= 0) {
barrier->flags &= 0xFFFEFFFF;
@@ -580,7 +587,7 @@ void Scene::updateBarriers(WorldStats *worldStats) {
// TODO: get global x, y positions
}
barrier->frameIdx = frameIdx;
- } else if (Shared.getMillis() - barrier->tickCount >= 0x3E8 / (barrier->field_B4+1)) {
+ } else if (barrier->field_B4 && (Shared.getMillis() - barrier->tickCount >= 0x3E8 / barrier->field_B4)) {
if ((flag & 0xFF) & 2) {
if (barrier->frameIdx == barrier->frameCount - 1) {
barrier->frameIdx--;
@@ -641,10 +648,6 @@ void Scene::OLD_UPDATE(WorldStats *worldStats) {
int32 curBarrier = -1;
MainActor *mainActor = _sceneResource->getMainActor();
- // DEBUG
- // Force the screen to scroll if the mouse approaches the edges
- //debugScreenScrolling(bg);
-
// DEBUGGING
// Check current walk region
for (uint32 a = 0; a < worldStats->numActions; a++) {
@@ -763,6 +766,10 @@ int Scene::drawScene() {
GraphicFrame *bg = _bgResource->getFrame(0);
Shared.getScreen()->copyToBackBuffer(((byte *)bg->surface.pixels) + _startY * bg->surface.w + _startX, bg->surface.w, worldStats->xLeft, worldStats->yTop, 640, 480);
+ // DEBUG
+ // Force the screen to scroll if the mouse approaches the edges
+ //debugScreenScrolling(bg);
+
// TODO: prepare Actors and Barriers draw
// TODO: draw actors
drawBarriers();
diff --git a/engines/asylum/screen.cpp b/engines/asylum/screen.cpp
index 5bc8a953c1..42c7cf5d81 100644
--- a/engines/asylum/screen.cpp
+++ b/engines/asylum/screen.cpp
@@ -153,7 +153,7 @@ void Screen::clearGraphicsInQueue() {
void Screen::graphicsSelectionSort() {
uint minIdx;
- for (uint i = 0; i < _queueItems.size() - 1; i++) {
+ for (uint i = 0; i < _queueItems.size(); i++) {
minIdx = i;
for (uint j = i + 1; j < _queueItems.size(); j++)
Commit: 0ebfa3758cb7e3449c4c4bc9afc74f1a1670a721
https://github.com/scummvm/scummvm/commit/0ebfa3758cb7e3449c4c4bc9afc74f1a1670a721
Author: Alex Bevilacqua (alexbevi at gmail.com)
Date: 2021-05-17T15:35:44+02:00
Commit Message:
ASYLUM: use CursorMan instead of the OSystem reference to manage cursors. This allows the cursor to be properly reset when returning from the GMM or the Debug Console
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@323 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/screen.h
diff --git a/engines/asylum/screen.h b/engines/asylum/screen.h
index 56cf7a50b2..f514a058da 100644
--- a/engines/asylum/screen.h
+++ b/engines/asylum/screen.h
@@ -31,6 +31,7 @@
#include "asylum/respack.h"
#include "common/system.h" // for OSystem
+#include "graphics/cursorman.h"
#include "graphics/surface.h"
namespace Asylum {
@@ -61,9 +62,9 @@ public:
void drawWideScreen(int16 barSize);
void clearScreen();
- void showCursor() { _sys->showMouse(true); }
- void hideCursor() { _sys->showMouse(false); }
- void setCursor(byte *data, byte width, byte height) { _sys->setMouseCursor(data, width, height, 0, 0, 0); }
+ void showCursor() { CursorMan.showMouse(true); }
+ void hideCursor() { CursorMan.showMouse(false); }
+ void setCursor(byte *data, byte width, byte height) { CursorMan.replaceCursor(data, width, height, 0, 0, 0); }
void setCursor(GraphicResource *cursorRes, int frame) {
GraphicFrame *mouseCursor = cursorRes->getFrame(frame);
setCursor((byte *)mouseCursor->surface.pixels, mouseCursor->surface.w, mouseCursor->surface.h);
Commit: bccc36a69c9c39bdd8d9c471078011cfe7701580
https://github.com/scummvm/scummvm/commit/bccc36a69c9c39bdd8d9c471078011cfe7701580
Author: Alex Bevilacqua (alexbevi at gmail.com)
Date: 2021-05-17T15:35:45+02:00
Commit Message:
ASYLUM: This is still WIP, but it's the first steps towards refactoring the cursor code.
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@324 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
A engines/asylum/cursor.cpp
A engines/asylum/cursor.h
engines/asylum/blowuppuzzle.cpp
engines/asylum/blowuppuzzle.h
engines/asylum/menu.cpp
engines/asylum/menu.h
engines/asylum/module.mk
engines/asylum/scene.cpp
engines/asylum/scene.h
engines/asylum/screen.h
engines/asylum/scriptman.cpp
diff --git a/engines/asylum/blowuppuzzle.cpp b/engines/asylum/blowuppuzzle.cpp
index e21b65d961..3c03927355 100644
--- a/engines/asylum/blowuppuzzle.cpp
+++ b/engines/asylum/blowuppuzzle.cpp
@@ -36,32 +36,19 @@ BlowUpPuzzle::BlowUpPuzzle() {
BlowUpPuzzle::~BlowUpPuzzle() {
}
-void BlowUpPuzzle::updateCursor() {
- _curMouseCursor += _cursorStep;
- if (_curMouseCursor == 0)
- _cursorStep = 1;
- if (_curMouseCursor == _cursorResource->getFrameCount() - 1)
- _cursorStep = -1;
-
- Shared.getScreen()->setCursor(_cursorResource, _curMouseCursor);
-}
-
-
// BlowUp Puzzle VCR ---------------------------------------------------------------------------------------------
BlowUpPuzzleVCR::BlowUpPuzzleVCR() {
- _mouseX = 0;
- _mouseY = 0;
- _leftClickUp = false;
- _leftClickDown = false;
- _rightClickDown = false;
- _curMouseCursor = 0;
- _cursorStep = 1;
- _active = false;
- _cursorResource = Shared.getScene()->getGraphicResource(Shared.getScene()->getResources()->getWorldStats()->grResId[28]);
- _bgResource = Shared.getScene()->getGraphicResource(Shared.getScene()->getResources()->getWorldStats()->grResId[0]);
- _tvScreenAnimIdx = 0;
- _isAccomplished = false;
+ _leftClickUp = false;
+ _leftClickDown = false;
+ _rightClickDown = false;
+ _active = false;
+ _bgResource = Shared.getScene()->getGraphicResource(Shared.getScene()->getResources()->getWorldStats()->grResId[0]);
+ _tvScreenAnimIdx = 0;
+ _isAccomplished = false;
+
+ // setup cursor
+ _cursor = new Cursor(Shared.getScene()->getResourcePack());
// reset all states
memset(&_jacksState,0,sizeof(_jacksState));
@@ -70,7 +57,7 @@ BlowUpPuzzleVCR::BlowUpPuzzleVCR() {
}
BlowUpPuzzleVCR::~BlowUpPuzzleVCR() {
- delete _cursorResource;
+ delete _cursor;
delete _bgResource;
}
@@ -88,13 +75,12 @@ void BlowUpPuzzleVCR::openBlowUp() {
Shared.getScreen()->copyToBackBuffer((byte *)bg->surface.pixels, bg->surface.w, 0, 0, bg->surface.w, bg->surface.h);
// Set mouse cursor
- Shared.getScreen()->setCursor(_cursorResource, 0);
- Shared.getScreen()->showCursor();
+ _cursor->load(Shared.getScene()->getResources()->getWorldStats()->grResId[28]);
+ _cursor->show();
- _leftClickUp = false;
- _leftClickDown = false;
+ _leftClickUp = false;
+ _leftClickDown = false;
_rightClickDown = false;
- _mouseX = _mouseY = 0;
}
void BlowUpPuzzleVCR::closeBlowUp() {
@@ -107,8 +93,7 @@ void BlowUpPuzzleVCR::handleEvent(Common::Event *event, bool doUpdate) {
switch (_ev->type) {
case Common::EVENT_MOUSEMOVE:
- _mouseX = _ev->mouse.x;
- _mouseY = _ev->mouse.y;
+ _cursor->setCoords(_ev->mouse.x, _ev->mouse.y);
break;
case Common::EVENT_LBUTTONUP:
_leftClickUp = true;
@@ -193,14 +178,14 @@ void BlowUpPuzzleVCR::update() {
GraphicQueueItem BlowUpPuzzleVCR::getGraphicJackItem(int resId) {
GraphicQueueItem jackItemOnHand;
- int jackY = _mouseY;
- if(_mouseY < 356) {
+ int jackY = _cursor->y();
+ if(_cursor->y() < 356) {
jackY = 356;
}
jackItemOnHand.resId = Shared.getScene()->getResources()->getWorldStats()->grResId[resId];
jackItemOnHand.frameIdx = 0;
- jackItemOnHand.x = _mouseX - 114;
+ jackItemOnHand.x = _cursor->x() - 114;
jackItemOnHand.y = jackY - 14;
jackItemOnHand.priority = 1;
@@ -210,13 +195,13 @@ GraphicQueueItem BlowUpPuzzleVCR::getGraphicJackItem(int resId) {
GraphicQueueItem BlowUpPuzzleVCR::getGraphicShadowItem() {
GraphicQueueItem shadowItem;
- int shadowY = (_mouseY - 356) / 4;
- if(_mouseY < 356) {
+ int shadowY = (_cursor->y() - 356) / 4;
+ if(_cursor->y() < 356) {
shadowY = 0;
}
shadowItem.resId = Shared.getScene()->getResources()->getWorldStats()->grResId[30];
shadowItem.frameIdx = 0;
- shadowItem.x = _mouseX - shadowY;
+ shadowItem.x = _cursor->x() - shadowY;
shadowItem.y = 450;
shadowItem.priority = 2;
@@ -445,35 +430,35 @@ void BlowUpPuzzleVCR::updateCursorInPolyRegion() {
}
if(!showCursor) {
- if(inPolyRegion(_mouseX, _mouseY, kRewindButton)
- || inPolyRegion(_mouseX, _mouseY, kStopButton)
- || inPolyRegion(_mouseX, _mouseY, kPlayButton)
- || inPolyRegion(_mouseX, _mouseY, kPowerButton)
- || inPolyRegion(_mouseX, _mouseY, kBlackJack)
- || inPolyRegion(_mouseX, _mouseY, kRedJack)
- || inPolyRegion(_mouseX, _mouseY, kYellowJack)) {
- updateCursor();
+ if(inPolyRegion(_cursor->x(), _cursor->y(), kRewindButton)
+ || inPolyRegion(_cursor->x(), _cursor->y(), kStopButton)
+ || inPolyRegion(_cursor->x(), _cursor->y(), kPlayButton)
+ || inPolyRegion(_cursor->x(), _cursor->y(), kPowerButton)
+ || inPolyRegion(_cursor->x(), _cursor->y(), kBlackJack)
+ || inPolyRegion(_cursor->x(), _cursor->y(), kRedJack)
+ || inPolyRegion(_cursor->x(), _cursor->y(), kYellowJack)) {
+ _cursor->animate();
} else {
- if(inPolyRegion(_mouseX, _mouseY, kRedHole) && _holesState[kPluggedOnRed-1]
- || inPolyRegion(_mouseX, _mouseY, kYellowHole) && _holesState[kPluggedOnYellow-1]
- || inPolyRegion(_mouseX, _mouseY, kBlackHole) && _holesState[kPluggedOnBlack-1]) {
- if(_curMouseCursor != 2) { // reset cursor
- Shared.getScreen()->showCursor();
- _curMouseCursor = 2;
- _cursorStep = 1;
- updateCursor();
+ if(inPolyRegion(_cursor->x(), _cursor->y(), kRedHole) && _holesState[kPluggedOnRed-1]
+ || inPolyRegion(_cursor->x(), _cursor->y(), kYellowHole) && _holesState[kPluggedOnYellow-1]
+ || inPolyRegion(_cursor->x(), _cursor->y(), kBlackHole) && _holesState[kPluggedOnBlack-1]) {
+ if(_cursor->currentFrame() != 2) { // reset cursor
+ _cursor->show();
+ _cursor->set(2);
+ //_cursorStep = 1;
+ _cursor->animate();
}
} else {
- if(_curMouseCursor != 0) { // reset cursor
- Shared.getScreen()->showCursor();
- _curMouseCursor = 0;
- _cursorStep = 1;
- updateCursor();
+ if(_cursor->currentFrame() != 0) { // reset cursor
+ _cursor->show();
+ _cursor->set(0);
+ //_cursorStep = 1;
+ _cursor->animate();
}
}
}
} else {
- Shared.getScreen()->hideCursor();
+ _cursor->hide();
}
}
@@ -492,17 +477,17 @@ void BlowUpPuzzleVCR::handleMouseDown() {
}
// Plug-in jacks
- if(inPolyRegion(_mouseX, _mouseY, kRedHole)) {
+ if(inPolyRegion(_cursor->x(), _cursor->y(), kRedHole)) {
if(!setJackOnHole(jackType, kPluggedOnRed)) {
return;
}
}
- if(inPolyRegion(_mouseX, _mouseY, kYellowHole)) {
+ if(inPolyRegion(_cursor->x(), _cursor->y(), kYellowHole)) {
if(!setJackOnHole(jackType, kPluggedOnYellow)) {
return;
}
}
- if(inPolyRegion(_mouseX, _mouseY, kBlackHole)) {
+ if(inPolyRegion(_cursor->x(), _cursor->y(), kBlackHole)) {
if(!setJackOnHole(jackType, kPluggedOnBlack)) {
if(_holesState[kBlackHole] != kPluggedOnYellow && _buttonsState[kPower] == 1) { // TODO: check this better
_buttonsState[kPower] = kOFF;
@@ -516,26 +501,26 @@ void BlowUpPuzzleVCR::handleMouseDown() {
// Put jacks on table --
if(jackType) {
- if (_mouseX >= (uint32)BlowUpPuzzleVCRPolies[kBlackJack].left && _mouseX <= (uint32)BlowUpPuzzleVCRPolies[kYellowJack].right &&
- _mouseY >= (uint32)BlowUpPuzzleVCRPolies[kBlackJack].top && _mouseY <= (uint32)BlowUpPuzzleVCRPolies[kYellowJack].bottom) {
+ if (_cursor->x() >= (uint32)BlowUpPuzzleVCRPolies[kBlackJack].left && _cursor->x() <= (uint32)BlowUpPuzzleVCRPolies[kYellowJack].right &&
+ _cursor->y() >= (uint32)BlowUpPuzzleVCRPolies[kBlackJack].top && _cursor->y() <= (uint32)BlowUpPuzzleVCRPolies[kYellowJack].bottom) {
_jacksState[jackType-1] = kOnTable;
Shared.getSound()->playSfx(Shared.getScene()->getResourcePack(), Shared.getScene()->getResources()->getWorldStats()->grResId[50]);
- Shared.getScreen()->showCursor();
+ _cursor->show();
}
return;
}
// Get Jacks from Table
- if (inPolyRegion(_mouseX, _mouseY, kBlackJack)) {
+ if (inPolyRegion(_cursor->x(), _cursor->y(), kBlackJack)) {
_jacksState[kBlack] = kOnHand;
- } else if (inPolyRegion(_mouseX, _mouseY, kRedJack)) {
+ } else if (inPolyRegion(_cursor->x(), _cursor->y(), kRedJack)) {
_jacksState[kRed] = kOnHand;
- } else if (inPolyRegion(_mouseX, _mouseY, kYellowJack)) {
+ } else if (inPolyRegion(_cursor->x(), _cursor->y(), kYellowJack)) {
_jacksState[kYellow] = kOnHand;
}
// TODO: VCR button regions
- if (inPolyRegion(_mouseX, _mouseY, kRewindButton)) {
+ if (inPolyRegion(_cursor->x(), _cursor->y(), kRewindButton)) {
Shared.getSound()->playSfx(Shared.getScene()->getResourcePack(), Shared.getScene()->getResources()->getWorldStats()->grResId[39]);
if(!_buttonsState[kRewind]) {
_buttonsState[kRewind] = kDownON;
@@ -545,7 +530,7 @@ void BlowUpPuzzleVCR::handleMouseDown() {
_buttonsState[kRewind] = kDownOFF;
return;
}
- } else if (inPolyRegion(_mouseX, _mouseY, kPlayButton)) {
+ } else if (inPolyRegion(_cursor->x(), _cursor->y(), kPlayButton)) {
Shared.getSound()->playSfx(Shared.getScene()->getResourcePack(), Shared.getScene()->getResources()->getWorldStats()->grResId[39]);
if(!_buttonsState[kPlay]) {
_buttonsState[kPlay] = kDownON;
@@ -555,7 +540,7 @@ void BlowUpPuzzleVCR::handleMouseDown() {
_buttonsState[kPlay] = kDownOFF;
return;
}
- } else if (inPolyRegion(_mouseX, _mouseY, kStopButton)) {
+ } else if (inPolyRegion(_cursor->x(), _cursor->y(), kStopButton)) {
Shared.getSound()->playSfx(Shared.getScene()->getResourcePack(), Shared.getScene()->getResources()->getWorldStats()->grResId[39]);
if(_buttonsState[kStop]) {
if(_buttonsState[kStop] == kON) {
@@ -566,7 +551,7 @@ void BlowUpPuzzleVCR::handleMouseDown() {
_buttonsState[kStop] = kDownON;
return;
}
- } else if (inPolyRegion(_mouseX, _mouseY, kPowerButton)) {
+ } else if (inPolyRegion(_cursor->x(), _cursor->y(), kPowerButton)) {
Shared.getSound()->playSfx(Shared.getScene()->getResourcePack(), Shared.getScene()->getResources()->getWorldStats()->grResId[39]);
if(!_buttonsState[kPower] && _holesState[kPluggedOnBlack-1] == kBlack+1 && _holesState[kPluggedOnRed-1] && _holesState[kPluggedOnYellow-1]) {
diff --git a/engines/asylum/blowuppuzzle.h b/engines/asylum/blowuppuzzle.h
index 4a2107e245..55a58330c4 100644
--- a/engines/asylum/blowuppuzzle.h
+++ b/engines/asylum/blowuppuzzle.h
@@ -32,6 +32,7 @@
#include "asylum/asylum.h"
#include "asylum/respack.h"
#include "asylum/graphics.h"
+#include "asylum/cursor.h"
namespace Asylum {
@@ -39,6 +40,7 @@ class Scene;
class Screen;
class Sound;
class Video;
+class Cursor;
struct GraphicQueueItem;
class BlowUpPuzzle {
@@ -54,19 +56,14 @@ public:
protected:
Common::Event *_ev;
- uint32 _mouseX;
- uint32 _mouseY;
- uint32 _curMouseCursor;
- int32 _cursorStep;
+ Cursor *_cursor;
bool _leftClickUp;
bool _leftClickDown;
bool _rightClickDown;
bool _active;
GraphicResource *_bgResource;
- GraphicResource *_cursorResource;
- void updateCursor();
virtual void update() {};
}; // end of class BlowUpPuzzle
diff --git a/engines/asylum/cursor.cpp b/engines/asylum/cursor.cpp
new file mode 100644
index 0000000000..c631dff03c
--- /dev/null
+++ b/engines/asylum/cursor.cpp
@@ -0,0 +1,122 @@
+/* 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.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#include "graphics/cursorman.h"
+#include "asylum/cursor.h"
+
+namespace Asylum {
+
+Cursor::Cursor(ResourcePack *res) {
+ _resPack = res;
+ _mouseX = 0;
+ _mouseY = 0;
+ cursorLoaded = false;
+}
+
+Cursor::~Cursor() {
+ if (cursorLoaded)
+ delete _cursorResource;
+}
+
+void Cursor::load(uint32 index) {
+ if (cursorLoaded)
+ delete _cursorResource;
+
+ _cursorResource = new GraphicResource(_resPack, index);
+ _cursorStep = 1;
+ _curFrame = 0;
+ cursorLoaded = true;
+}
+
+void Cursor::hide() {
+ CursorMan.showMouse(false);
+}
+
+void Cursor::show() {
+ CursorMan.showMouse(true);
+}
+
+void Cursor::set(byte *data, byte width, byte height) {
+ CursorMan.replaceCursor(data, width, height, 0, 0, 0);
+}
+
+void Cursor::set(int frame) {
+ GraphicFrame *mouseCursor = _cursorResource->getFrame(frame);
+ set((byte *)mouseCursor->surface.pixels, mouseCursor->surface.w, mouseCursor->surface.h);
+
+ _curFrame = frame;
+}
+
+void Cursor::setCoords(uint32 mouseX, uint32 mouseY) {
+ _mouseX = mouseX;
+ _mouseY = mouseY;
+}
+
+void Cursor::animate() {
+ _curFrame += _cursorStep;
+ if (_curFrame == 0)
+ _cursorStep = 1;
+ if (_curFrame == _cursorResource->getFrameCount() - 1)
+ _cursorStep = -1;
+
+ set(_curFrame);
+}
+
+void Cursor::update(CommonResources *cr, int currentAction) {
+ uint32 newCursor = 0;
+
+ // Change cursor
+ switch (currentAction) {
+ case kWalkN:
+ newCursor = cr->curScrollUp;
+ break;
+ case kWalkNE:
+ newCursor = cr->curScrollUpRight;
+ break;
+ case kWalkNW:
+ newCursor = cr->curScrollUpLeft;
+ break;
+ case kWalkS:
+ newCursor = cr->curScrollDown;
+ break;
+ case kWalkSE:
+ newCursor = cr->curScrollDownRight;
+ break;
+ case kWalkSW:
+ newCursor = cr->curScrollDownLeft;
+ break;
+ case kWalkW:
+ newCursor = cr->curScrollLeft;
+ break;
+ case kWalkE:
+ newCursor = cr->curScrollRight;
+ break;
+ }
+
+ if (_cursorResource->getEntryNum() != newCursor)
+ load(newCursor);
+}
+
+} // end of namespace Asylum
diff --git a/engines/asylum/cursor.h b/engines/asylum/cursor.h
new file mode 100644
index 0000000000..71bb09ecea
--- /dev/null
+++ b/engines/asylum/cursor.h
@@ -0,0 +1,71 @@
+/* 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.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#ifndef ASYLUM_CURSOR_H_
+#define ASYLUM_CURSOR_H_
+
+#include "asylum/sceneres.h"
+
+namespace Asylum {
+
+struct CommonResources;
+
+class Cursor {
+public:
+ Cursor(ResourcePack *res);
+ virtual ~Cursor();
+
+ void show();
+ void hide();
+ /**
+ * Load a GraphicResource at the position specified by
+ * index from the _resPack ResourcePack
+ */
+ void load(uint32 index);
+ void set(byte *data, byte width, byte height);
+ void set(int frame);
+ void setCoords(uint32 mouseX, uint32 mouseY);
+ void update();
+ void update(CommonResources *cr, int currentAction);
+ void animate();
+
+ uint32 x() { return _mouseX; }
+ uint32 y() { return _mouseY; }
+ uint32 currentFrame() { return _curFrame; }
+
+private:
+ ResourcePack *_resPack;
+ GraphicResource *_cursorResource;
+ bool cursorLoaded;
+ uint32 _curFrame;
+ int32 _cursorStep;
+ uint32 _mouseX;
+ uint32 _mouseY;
+
+}; // end of class Cursor
+
+} // end of namespace Asylum
+
+#endif
diff --git a/engines/asylum/menu.cpp b/engines/asylum/menu.cpp
index 1018c7f984..d91768f172 100644
--- a/engines/asylum/menu.cpp
+++ b/engines/asylum/menu.cpp
@@ -34,8 +34,6 @@ namespace Asylum {
const int MenuIconFixedXpos[12] = { 28, 128, 225, 320, 410, 528, 16, 115, 237, 310, 508, 419 };
MainMenu::MainMenu() {
- _mouseX = 0;
- _mouseY = 0;
_leftClick = false;
_activeIcon = -1;
_previousActiveIcon = -1;
@@ -52,7 +50,8 @@ MainMenu::MainMenu() {
_resPack = new ResourcePack(1);
_bgResource = new GraphicResource(_resPack, 0);
_eyeResource = new GraphicResource(_resPack, 1);
- _cursorResource = new GraphicResource(_resPack, 2);
+
+ _cursor = new Cursor(_resPack);
_iconResource = 0;
_creditsResource = 0;
@@ -68,7 +67,7 @@ MainMenu::~MainMenu() {
delete _text;
delete _iconResource;
delete _eyeResource;
- delete _cursorResource;
+ delete _cursor;
delete _bgResource;
delete _resPack;
}
@@ -87,8 +86,8 @@ void MainMenu::openMenu() {
Shared.getScreen()->copyToBackBuffer((byte *)bg->surface.pixels, bg->surface.w, 0, 0, bg->surface.w, bg->surface.h);
// Set mouse cursor
- Shared.getScreen()->setCursor(_cursorResource, 0);
- Shared.getScreen()->showCursor();
+ _cursor->load(2);
+ _cursor->show();
// Stop all sounds
Shared.getSound()->stopMusic();
@@ -100,7 +99,6 @@ void MainMenu::openMenu() {
_previousActiveIcon = _activeIcon = -1;
_leftClick = false;
_activeMenuScreen = kMainMenu;
- _mouseX = _mouseY = 0;
}
void MainMenu::closeMenu() {
@@ -117,8 +115,7 @@ void MainMenu::handleEvent(Common::Event *event, bool doUpdate) {
switch (_ev->type) {
case Common::EVENT_MOUSEMOVE:
- _mouseX = _ev->mouse.x;
- _mouseY = _ev->mouse.y;
+ _cursor->setCoords(_ev->mouse.x, _ev->mouse.y);
break;
case Common::EVENT_LBUTTONUP:
_leftClick = true;
@@ -133,7 +130,7 @@ void MainMenu::handleEvent(Common::Event *event, bool doUpdate) {
void MainMenu::update() {
updateEyesAnimation();
- updateCursor();
+ _cursor->animate();
if (_activeMenuScreen == kMainMenu) {
updateMainMenu();
@@ -151,9 +148,7 @@ void MainMenu::update() {
_activeMenuScreen = (MenuScreen) _activeIcon;
// Set the cursor
- delete _cursorResource;
- _cursorResource = new GraphicResource(_resPack, 3);
- Shared.getScreen()->setCursor(_cursorResource, 0);
+ _cursor->load(3);
}
switch (_activeIcon) {
@@ -209,39 +204,29 @@ void MainMenu::update() {
}
}
-void MainMenu::updateCursor() {
- _curMouseCursor += _cursorStep;
- if (_curMouseCursor == 0)
- _cursorStep = 1;
- if (_curMouseCursor == _cursorResource->getFrameCount() - 1)
- _cursorStep = -1;
-
- Shared.getScreen()->setCursor(_cursorResource, _curMouseCursor);
-}
-
void MainMenu::updateEyesAnimation() {
// Eyes animation
// Get the appropriate eye resource depending on the mouse position
int eyeFrameNum = kEyesFront;
- if (_mouseX <= 200) {
- if (_mouseY <= 160)
+ if (_cursor->x() <= 200) {
+ if (_cursor->y() <= 160)
eyeFrameNum = kEyesTopLeft;
- else if (_mouseY > 160 && _mouseY <= 320)
+ else if (_cursor->y() > 160 && _cursor->y() <= 320)
eyeFrameNum = kEyesLeft;
else
eyeFrameNum = kEyesBottomLeft;
- } else if (_mouseX > 200 && _mouseX <= 400) {
- if (_mouseY <= 160)
+ } else if (_cursor->x() > 200 && _cursor->x() <= 400) {
+ if (_cursor->y() <= 160)
eyeFrameNum = kEyesTop;
- else if (_mouseY > 160 && _mouseY <= 320)
+ else if (_cursor->y() > 160 && _cursor->y() <= 320)
eyeFrameNum = kEyesFront;
else
eyeFrameNum = kEyesBottom;
- } else if (_mouseX > 400) {
- if (_mouseY <= 160)
+ } else if (_cursor->x() > 400) {
+ if (_cursor->y() <= 160)
eyeFrameNum = kEyesTopRight;
- else if (_mouseY > 160 && _mouseY <= 320)
+ else if (_cursor->y() > 160 && _cursor->y() <= 320)
eyeFrameNum = kEyesRight;
else
eyeFrameNum = kEyesBottomRight;
@@ -255,9 +240,9 @@ void MainMenu::updateEyesAnimation() {
void MainMenu::updateMainMenu() {
int rowId = 0;
- if (_mouseY >= 20 && _mouseY <= 20 + 48) {
+ if (_cursor->y() >= 20 && _cursor->y() <= 20 + 48) {
rowId = 0; // Top row
- } else if (_mouseY >= 400 && _mouseY <= 400 + 48) {
+ } else if (_cursor->y() >= 400 && _cursor->y() <= 400 + 48) {
rowId = 1; // Bottom row
} else {
// No row selected
@@ -272,7 +257,7 @@ void MainMenu::updateMainMenu() {
// Icon animation
for (uint32 i = 0; i <= 5; i++) {
uint32 curX = 40 + i * 100;
- if (_mouseX >= curX && _mouseX <= curX + 55) {
+ if (_cursor->x() >= curX && _cursor->x() <= curX + 55) {
int iconNum = i + 6 * rowId;
_activeIcon = iconNum;
@@ -367,7 +352,7 @@ void MainMenu::updateSubMenuNewGame() {
_text->drawResTextCentered(10, 100, 620, 0x80000529);
// Yes
- if (_mouseX < 247 || _mouseX > 247 + _text->getResTextWidth(0x8000052A) || _mouseY < 273 || _mouseY > 273 + 24 )
+ if (_cursor->x() < 247 || _cursor->x() > 247 + _text->getResTextWidth(0x8000052A) || _cursor->y() < 273 || _cursor->y() > 273 + 24 )
_text->loadFont(_resPack, 0x80010010); // yellow font
else
_text->loadFont(_resPack, 0x80010016); // blue font
@@ -375,7 +360,7 @@ void MainMenu::updateSubMenuNewGame() {
_text->drawResText(0x8000052A);
// No
- if (_mouseX < 369 || _mouseX > 369 + _text->getResTextWidth(0x8000052B) || _mouseY < 273 || _mouseY > 273 + 24 )
+ if (_cursor->x() < 369 || _cursor->x() > 369 + _text->getResTextWidth(0x8000052B) || _cursor->y() < 273 || _cursor->y() > 273 + 24 )
_text->loadFont(_resPack, 0x80010010); // yellow font
else
_text->loadFont(_resPack, 0x80010016); // blue font
@@ -385,12 +370,12 @@ void MainMenu::updateSubMenuNewGame() {
// action
if (_leftClick) {
// Yes
- if (_mouseX >= 247 && _mouseX <= 247 + 24 && _mouseY >= 273 && _mouseY <= 273 + _text->getResTextWidth(0x8000052A)) {
+ if (_cursor->x() >= 247 && _cursor->x() <= 247 + 24 && _cursor->y() >= 273 && _cursor->y() <= 273 + _text->getResTextWidth(0x8000052A)) {
_leftClick = false;
// TODO handle new game event
}
// No
- if (_mouseX >= 369 && _mouseX <= 369 + 24 && _mouseY >= 273 && _mouseY <= 273 + _text->getResTextWidth(0x8000052B))
+ if (_cursor->x() >= 369 && _cursor->x() <= 369 + 24 && _cursor->y() >= 273 && _cursor->y() <= 273 + _text->getResTextWidth(0x8000052B))
exitSubMenu();
}
}
@@ -401,7 +386,7 @@ void MainMenu::updateSubMenuCinematics() {
_text->setTextPos(30, 340);
_text->drawResText(0x80000549); // Prev Page
- if (_mouseX >= 280 && _mouseX <= 400 && _mouseY >= 340 && _mouseY <= 360) {
+ if (_cursor->x() >= 280 && _cursor->x() <= 400 && _cursor->y() >= 340 && _cursor->y() <= 360) {
_text->loadFont(_resPack, 0x80010016); // blue font
if (_leftClick)
exitSubMenu();
@@ -430,14 +415,14 @@ void MainMenu::updateSubMenuSettings() {
// gamma correction
_text->drawResTextAlignRight(320, 150, 0x80000599);
- if (_mouseX < 350 || _mouseX > sizeMinus + 350 || _mouseY < 150 || _mouseY > 174)
+ if (_cursor->x() < 350 || _cursor->x() > sizeMinus + 350 || _cursor->y() < 150 || _cursor->y() > 174)
_text->loadFont(_resPack, 0x80010010); // yellow font
else
_text->loadFont(_resPack, 0x80010016); // blue font
_text->setTextPos(350, 150);
_text->drawText("-");
- if (_mouseX < sizeMinus + 360 || _mouseX > sizeMinus + sizePlus + 360 || _mouseY < 150 || _mouseY > 174)
+ if (_cursor->x() < sizeMinus + 360 || _cursor->x() > sizeMinus + sizePlus + 360 || _cursor->y() < 150 || _cursor->y() > 174)
_text->loadFont(_resPack, 0x80010010); // yellow font
else
_text->loadFont(_resPack, 0x80010016); // blue font
@@ -458,14 +443,14 @@ void MainMenu::updateSubMenuSettings() {
// performance
_text->loadFont(_resPack, 0x80010010);
_text->drawResTextAlignRight(320, 179, 0x8000059A);
- if (_mouseX < 350 || _mouseX > sizeMinus + 350 || _mouseY < 179 || _mouseY > 203)
+ if (_cursor->x() < 350 || _cursor->x() > sizeMinus + 350 || _cursor->y() < 179 || _cursor->y() > 203)
_text->loadFont(_resPack, 0x80010010); // yellow font
else
_text->loadFont(_resPack, 0x80010016); // blue font
_text->setTextPos(350, 179);
_text->drawText("-");
- if (_mouseX < sizeMinus + 360 || _mouseX > sizeMinus + sizePlus + 360 || _mouseY < 179 || _mouseY > 203)
+ if (_cursor->x() < sizeMinus + 360 || _cursor->x() > sizeMinus + sizePlus + 360 || _cursor->y() < 179 || _cursor->y() > 203)
_text->loadFont(_resPack, 0x80010010); // yellow font
else
_text->loadFont(_resPack, 0x80010016); // blue font
@@ -485,7 +470,7 @@ void MainMenu::updateSubMenuSettings() {
}
// back to main menu
- if (_mouseX < 300 || _mouseX > 300 + sizeMainMenu || _mouseY < 340 || _mouseY > 340 + 24)
+ if (_cursor->x() < 300 || _cursor->x() > 300 + sizeMainMenu || _cursor->y() < 340 || _cursor->y() > 340 + 24)
_text->loadFont(_resPack, 0x80010010); // yellow font
else
_text->loadFont(_resPack, 0x80010016); // blue font
@@ -495,20 +480,20 @@ void MainMenu::updateSubMenuSettings() {
// action
if (_leftClick) {
// back to main menu
- if (_mouseX >= 300 && _mouseX <= 300 + sizeMainMenu && _mouseY >= 340 && _mouseY <= 340 + 24) {
+ if (_cursor->x() >= 300 && _cursor->x() <= 300 + sizeMainMenu && _cursor->y() >= 340 && _cursor->y() <= 340 + 24) {
// TODO: save new configurations
exitSubMenu();
}
// gamma level minus
- if (_mouseX >= 350 && _mouseX <= sizeMinus + 350 && _mouseY >= 150 && _mouseY <= 174) {
+ if (_cursor->x() >= 350 && _cursor->x() <= sizeMinus + 350 && _cursor->y() >= 150 && _cursor->y() <= 174) {
if(_confGammaLevel) {
_confGammaLevel -= 1;
// TODO: setResGammaLevel(0x80010011, 0);
}
}
// gamma level plus
- if (_mouseX >= sizeMinus + 360 && _mouseX <= sizeMinus + sizePlus + 360 && _mouseY >= 150 && _mouseY <= 174) {
+ if (_cursor->x() >= sizeMinus + 360 && _cursor->x() <= sizeMinus + sizePlus + 360 && _cursor->y() >= 150 && _cursor->y() <= 174) {
if(_confGammaLevel < 8) {
_confGammaLevel += 1;
// TODO: setResGammaLevel(0x80010011, 0);
@@ -516,14 +501,14 @@ void MainMenu::updateSubMenuSettings() {
}
// performance minus
- if (_mouseX >= 350 && _mouseX <= sizeMinus + 350 && _mouseY >= 179 && _mouseY <= 203) {
+ if (_cursor->x() >= 350 && _cursor->x() <= sizeMinus + 350 && _cursor->y() >= 179 && _cursor->y() <= 203) {
if(_confGameQuality) {
_confGameQuality -= 1;
// TODO: change quality settings
}
}
// performance plus
- if (_mouseX >= sizeMinus + 360 && _mouseX <= sizeMinus + sizePlus + 360 && _mouseY >= 179 && _mouseY <= 203) {
+ if (_cursor->x() >= sizeMinus + 360 && _cursor->x() <= sizeMinus + sizePlus + 360 && _cursor->y() >= 179 && _cursor->y() <= 203) {
if(_confGameQuality < 5) {
_confGameQuality += 1;
// TODO: change quality settings
@@ -540,7 +525,7 @@ void MainMenu::updateSubMenuQuitGame() {
_text->drawResTextCentered(10, 100, 620, 0x80000580);
// Yes
- if (_mouseX < 247 || _mouseX > 247 + _text->getResTextWidth(0x80000581) || _mouseY < 273 || _mouseY > 273 + 24 )
+ if (_cursor->x() < 247 || _cursor->x() > 247 + _text->getResTextWidth(0x80000581) || _cursor->y() < 273 || _cursor->y() > 273 + 24 )
_text->loadFont(_resPack, 0x80010010); // yellow font
else
_text->loadFont(_resPack, 0x80010016); // blue font
@@ -548,7 +533,7 @@ void MainMenu::updateSubMenuQuitGame() {
_text->drawResText(0x80000581);
// No
- if (_mouseX < 369 || _mouseX > 369 + _text->getResTextWidth(0x80000582) || _mouseY < 273 || _mouseY > 273 + 24 )
+ if (_cursor->x() < 369 || _cursor->x() > 369 + _text->getResTextWidth(0x80000582) || _cursor->y() < 273 || _cursor->y() > 273 + 24 )
_text->loadFont(_resPack, 0x80010010); // yellow font
else
_text->loadFont(_resPack, 0x80010016); // blue font
@@ -558,7 +543,7 @@ void MainMenu::updateSubMenuQuitGame() {
// action
if (_leftClick) {
// Yes
- if (_mouseX >= 247 && _mouseX <= 247 + 24 && _mouseY >= 273 && _mouseY <= 273 + _text->getResTextWidth(0x80000581)) {
+ if (_cursor->x() >= 247 && _cursor->x() <= 247 + 24 && _cursor->y() >= 273 && _cursor->y() <= 273 + _text->getResTextWidth(0x80000581)) {
_leftClick = false;
// User clicked on quit, so push a quit event
@@ -567,7 +552,7 @@ void MainMenu::updateSubMenuQuitGame() {
g_system->getEventManager()->pushEvent(event);
}
// No
- if (_mouseX >= 369 && _mouseX <= 369 + 24 && _mouseY >= 273 && _mouseY <= 273 + _text->getResTextWidth(0x80000582))
+ if (_cursor->x() >= 369 && _cursor->x() <= 369 + 24 && _cursor->y() >= 273 && _cursor->y() <= 273 + _text->getResTextWidth(0x80000582))
exitSubMenu();
}
}
@@ -642,9 +627,7 @@ void MainMenu::exitSubMenu() {
Shared.getScreen()->copyToBackBuffer((byte *)bg->surface.pixels, bg->surface.w, 0, 0, bg->surface.w, bg->surface.h);
// Set the cursor
- delete _cursorResource;
- _cursorResource = new GraphicResource(_resPack, 2);
- Shared.getScreen()->setCursor(_cursorResource, 0);
+ _cursor->load(2);
}
} // end of namespace Asylum
diff --git a/engines/asylum/menu.h b/engines/asylum/menu.h
index 8e7d9478cc..5aaac83e35 100644
--- a/engines/asylum/menu.h
+++ b/engines/asylum/menu.h
@@ -33,10 +33,12 @@
#include "asylum/scene.h"
#include "asylum/graphics.h"
#include "asylum/text.h"
+#include "asylum/cursor.h"
namespace Asylum {
class Text;
+class Cursor;
class MainMenu {
public:
@@ -81,17 +83,16 @@ private:
Common::Event *_ev;
- uint32 _mouseX;
- uint32 _mouseY;
- int32 _activeIcon;
- int32 _previousActiveIcon;
- uint32 _curIconFrame;
- uint32 _curMouseCursor;
- int32 _cursorStep;
- uint32 _creditsBgFrame;
- uint32 _creditsTextScroll;
- bool _leftClick;
- bool _active;
+ Cursor *_cursor;
+ int32 _activeIcon;
+ int32 _previousActiveIcon;
+ uint32 _curIconFrame;
+ uint32 _curMouseCursor;
+ int32 _cursorStep;
+ uint32 _creditsBgFrame;
+ uint32 _creditsTextScroll;
+ bool _leftClick;
+ bool _active;
// FIXME this shouldnt be here. Need a proper config place
uint32 _confGammaLevel;
@@ -100,14 +101,12 @@ private:
MenuScreen _activeMenuScreen;
ResourcePack *_resPack;
GraphicResource *_bgResource;
- GraphicResource *_cursorResource;
GraphicResource *_eyeResource;
GraphicResource *_iconResource;
GraphicResource *_creditsResource;
GraphicResource *_creditsFadeResource;
Text *_text;
- void updateCursor();
void updateEyesAnimation();
void updateMainMenu();
diff --git a/engines/asylum/module.mk b/engines/asylum/module.mk
index 296ccb57ea..eb7fd4dbe5 100644
--- a/engines/asylum/module.mk
+++ b/engines/asylum/module.mk
@@ -17,7 +17,8 @@ MODULE_OBJS := \
encounters.o \
scriptman.o \
blowuppuzzle.o \
- shared.o
+ shared.o \
+ cursor.o
# This module can be built as a plugin
ifeq ($(ENABLE_ASYLUM), DYNAMIC_PLUGIN)
diff --git a/engines/asylum/scene.cpp b/engines/asylum/scene.cpp
index 3bc093d5be..452cd2964f 100644
--- a/engines/asylum/scene.cpp
+++ b/engines/asylum/scene.cpp
@@ -57,7 +57,7 @@ Scene::Scene(uint8 sceneIdx) {
_blowUp = 0;
}
- _cursorResource = new GraphicResource(_resPack, _sceneResource->getWorldStats()->commonRes.curMagnifyingGlass);
+ _cursor = new Cursor(_resPack);
_background = 0;
_startX = 0;
@@ -78,22 +78,24 @@ Scene::Scene(uint8 sceneIdx) {
if (worldStats->numBarriers > 0) {
uint32 priority = 0x0FFB;
- for (uint32 b=0; b < worldStats->numBarriers; b++) {
+ for (uint32 b = 0; b < worldStats->numBarriers; b++) {
BarrierItem *barrier = &worldStats->barriers[b];
barrier->priority = priority;
barrier->flags &= 0xFFFF3FFF;
priority -= 4;
}
}
+
worldStats->sceneRectIdx = 0;
Shared.getScreen()->clearGraphicsInQueue();
worldStats->motionStatus = 1;
+
// TODO: do some rect stuffs from player actor
// TODO: reset actors flags
}
Scene::~Scene() {
- delete _cursorResource;
+ delete _cursor;
delete _bgResource;
delete _musPack;
delete _speechPack;
@@ -110,10 +112,8 @@ void Scene::enterScene() {
((byte *)_background->surface.pixels) + _startY * _background->surface.w + _startX, _background->surface.w,
0, 0, 640, 480);
- _cursorStep = 1;
- _curMouseCursor = 0;
- Shared.getScreen()->setCursor(_cursorResource, 0);
- Shared.getScreen()->showCursor();
+ _cursor->load(_sceneResource->getWorldStats()->commonRes.curMagnifyingGlass);
+ _cursor->show();
// Music testing: play the first music track
Shared.getSound()->playMusic(_musPack, 0);
@@ -213,8 +213,7 @@ void Scene::handleEvent(Common::Event *event, bool doUpdate) {
switch (_ev->type) {
case Common::EVENT_MOUSEMOVE:
- _mouseX = _ev->mouse.x;
- _mouseY = _ev->mouse.y;
+ _cursor->setCoords(_ev->mouse.x, _ev->mouse.y);
break;
case Common::EVENT_LBUTTONUP:
@@ -224,11 +223,10 @@ void Scene::handleEvent(Common::Event *event, bool doUpdate) {
case Common::EVENT_RBUTTONUP:
if (ScriptMan.isInputAllowed()) {
- delete _cursorResource;
// TODO This isn't always going to be the magnifying glass
// Should check the current pointer region to identify the type
// of cursor to use
- _cursorResource = new GraphicResource(_resPack, _sceneResource->getWorldStats()->commonRes.curMagnifyingGlass);
+ _cursor->load(_sceneResource->getWorldStats()->commonRes.curMagnifyingGlass);
_rightButton = false;
}
break;
@@ -243,55 +241,6 @@ void Scene::handleEvent(Common::Event *event, bool doUpdate) {
update();
}
-void Scene::updateCursor() {
- int action = _sceneResource->getMainActor()->getCurrentAction();
- CommonResources *cr = &_sceneResource->getWorldStats()->commonRes;
- uint32 newCursor = 0;
-
- // Change cursor
- switch (action) {
- case kWalkN:
- newCursor = cr->curScrollUp;
- break;
- case kWalkNE:
- newCursor = cr->curScrollUpRight;
- break;
- case kWalkNW:
- newCursor = cr->curScrollUpLeft;
- break;
- case kWalkS:
- newCursor = cr->curScrollDown;
- break;
- case kWalkSE:
- newCursor = cr->curScrollDownRight;
- break;
- case kWalkSW:
- newCursor = cr->curScrollDownLeft;
- break;
- case kWalkW:
- newCursor = cr->curScrollLeft;
- break;
- case kWalkE:
- newCursor = cr->curScrollRight;
- break;
- }
-
- if (_cursorResource->getEntryNum() != newCursor) {
- delete _cursorResource;
- _cursorResource = new GraphicResource(_resPack, newCursor);
- }
-}
-
-void Scene::animateCursor() {
- _curMouseCursor += _cursorStep;
- if (_curMouseCursor == 0)
- _cursorStep = 1;
- if (_curMouseCursor == _cursorResource->getFrameCount() - 1)
- _cursorStep = -1;
-
- Shared.getScreen()->setCursor(_cursorResource, _curMouseCursor);
-}
-
// -------------------------------------------
// ---------- PROCESS SCENE REGION -----------
// -------------------------------------------
@@ -348,8 +297,8 @@ int Scene::isActorVisible(ActorItem *actor) {
}
void Scene::updateActor(uint32 actorIdx) {
- WorldStats *worldStats = _sceneResource->getWorldStats();
- ActorItem *actor = &worldStats->actors[actorIdx];
+ WorldStats *worldStats = _sceneResource->getWorldStats();
+ ActorItem *actor = &worldStats->actors[actorIdx];
if (isActorVisible(actor)) {
switch (actor->field_40) {
@@ -465,10 +414,9 @@ bool Scene::isBarrierVisible(BarrierItem *barrier) {
return false;
}
-
bool Scene::isBarrierOnScreen(BarrierItem *barrier) {
- WorldStats *worldStats = _sceneResource->getWorldStats();
- Common::Rect screenRect = Common::Rect(worldStats->xLeft, worldStats->yTop, worldStats->xLeft + 640, worldStats->yTop + 480);
+ WorldStats *worldStats = _sceneResource->getWorldStats();
+ Common::Rect screenRect = Common::Rect(worldStats->xLeft, worldStats->yTop, worldStats->xLeft + 640, worldStats->yTop + 480);
Common::Rect barrierRect = barrier->boundingRect;
barrierRect.translate(barrier->x, barrier->y);
return isBarrierVisible(barrier) && (barrier->flags & 1) && screenRect.intersects(barrierRect);
@@ -501,17 +449,14 @@ void Scene::updateBarriers(WorldStats *worldStats) {
for (uint32 b = 0; b < barriersCount; b++) {
BarrierItem *barrier = &worldStats->barriers[b];
- if(b==61)
- printf("%d: \n",b);
-
if (barrier->field_3C == 4) {
if (isBarrierVisible(barrier)) {
uint32 flag = barrier->flags;
if (flag & 0x20) {
if (barrier->field_B4 && (Shared.getMillis() - barrier->tickCount >= 0x3E8 / barrier->field_B4)) {
- barrier->frameIdx = (barrier->frameIdx + 1) % barrier->frameCount;
+ barrier->frameIdx = (barrier->frameIdx + 1) % barrier->frameCount;
barrier->tickCount = Shared.getMillis();
- canPlaySound = true;
+ canPlaySound = true;
}
} else if (flag & 0x10) {
uint32 frameIdx = barrier->frameIdx;
@@ -526,13 +471,13 @@ void Scene::updateBarriers(WorldStats *worldStats) {
barrier->resId = getRandomResId(barrier);
GraphicResource *gra = new GraphicResource(_resPack, barrier->resId);
- barrier->frameCount = gra->getFrameCount();
+ barrier->frameCount = gra->getFrameCount();
delete gra;
}
barrier->frameIdx++;
}
barrier->tickCount = Shared.getMillis();
- canPlaySound = true;
+ canPlaySound = true;
}
frameIdx = barrier->frameIdx;
equalZero = frameIdx == 0;
@@ -677,8 +622,9 @@ void Scene::OLD_UPDATE(WorldStats *worldStats) {
} else {
_walking = true;
- mainActor->walkTo(_mouseX, _mouseY);
- updateCursor();
+ mainActor->walkTo(_cursor->x(), _cursor->y());
+ _cursor->update(&_sceneResource->getWorldStats()->commonRes,
+ _sceneResource->getMainActor()->getCurrentAction());
}
if (g_debugPolygons)
@@ -690,11 +636,11 @@ void Scene::OLD_UPDATE(WorldStats *worldStats) {
for (uint32 p = 0; p < worldStats->numBarriers; p++) {
BarrierItem b = worldStats->barriers[p];
if (b.flags & 0x20) {
- if ((b.boundingRect.left + b.x <= _mouseX + _startX) &&
- (_mouseX + _startX < b.boundingRect.right + b.x) &&
- (b.boundingRect.top + b.y <= _mouseY + _startY) &&
- (_mouseY + _startY < b.boundingRect.bottom + b.y)) {
- animateCursor();
+ if ((b.boundingRect.left + b.x <= _cursor->x() + _startX) &&
+ (_cursor->x() + _startX < b.boundingRect.right + b.x) &&
+ (b.boundingRect.top + b.y <= _cursor->y() + _startY) &&
+ (_cursor->y() + _startY < b.boundingRect.bottom + b.y)) {
+ _cursor->animate();
curBarrier = (int32)p;
break;
}
@@ -710,10 +656,10 @@ void Scene::OLD_UPDATE(WorldStats *worldStats) {
// Update cursor if it's in a polygon hotspot
for (uint32 p = 0; p < _sceneResource->getGamePolygons()->numEntries; p++) {
PolyDefinitions poly = _sceneResource->getGamePolygons()->polygons[p];
- if (poly.boundingRect.contains(_mouseX + _startX, _mouseY + _startY)) {
- if (Shared.pointInPoly(&poly, _mouseX + _startX, _mouseY + _startY)) {
+ if (poly.boundingRect.contains(_cursor->x() + _startX, _cursor->y() + _startY)) {
+ if (Shared.pointInPoly(&poly, _cursor->x() + _startX, _cursor->y() + _startY)) {
curHotspot = (int32)p;
- animateCursor();
+ _cursor->animate();
break;
}
}
@@ -851,15 +797,15 @@ void Scene::copyToBackBufferClipped(Graphics::Surface *surface, int x, int y) {
void Scene::debugScreenScrolling(GraphicFrame *bg) {
// Horizontal scrolling
- if (_mouseX < SCREEN_EDGES && _startX >= SCROLL_STEP)
+ if (_cursor->x() < SCREEN_EDGES && _startX >= SCROLL_STEP)
_startX -= SCROLL_STEP;
- else if (_mouseX > 640 - SCREEN_EDGES && _startX <= bg->surface.w - 640 - SCROLL_STEP)
+ else if (_cursor->x() > 640 - SCREEN_EDGES && _startX <= bg->surface.w - 640 - SCROLL_STEP)
_startX += SCROLL_STEP;
// Vertical scrolling
- if (_mouseY < SCREEN_EDGES && _startY >= SCROLL_STEP)
+ if (_cursor->y() < SCREEN_EDGES && _startY >= SCROLL_STEP)
_startY -= SCROLL_STEP;
- else if (_mouseY > 480 - SCREEN_EDGES && _startY <= bg->surface.h - 480 - SCROLL_STEP)
+ else if (_cursor->y() > 480 - SCREEN_EDGES && _startY <= bg->surface.h - 480 - SCROLL_STEP)
_startY += SCROLL_STEP;
}
diff --git a/engines/asylum/scene.h b/engines/asylum/scene.h
index ae53df0879..5e62d36afb 100644
--- a/engines/asylum/scene.h
+++ b/engines/asylum/scene.h
@@ -33,12 +33,14 @@
#include "asylum/graphics.h"
#include "asylum/text.h"
#include "asylum/sceneres.h"
+#include "asylum/cursor.h"
namespace Asylum {
class Screen;
class Sound;
class Video;
+class Cursor;
class Text;
class SceneResource;
class WorldStats;
@@ -70,7 +72,7 @@ public:
void actorVisible(int actorIndex, bool visible);
bool actorVisible(int actorIndex);
void setScenePosition(int x, int y);
-
+ Cursor* getCursor() { return _cursor; }
SceneResource* getResources() { return _sceneResource; }
ResourcePack* getResourcePack() { return _resPack; }
ResourcePack* getMusicPack() { return _musPack; }
@@ -81,7 +83,7 @@ public:
private:
void copyToBackBufferClipped(Graphics::Surface *surface, int x, int y);
-
+ Cursor *_cursor;
uint8 _sceneIdx;
SceneResource *_sceneResource;
ResourcePack *_resPack;
@@ -91,18 +93,13 @@ private:
Common::Event *_ev;
Text *_text;
GraphicResource *_bgResource;
- GraphicResource *_cursorResource;
GraphicFrame *_background;
bool _walking;
- uint32 _mouseX;
- uint32 _mouseY;
int32 _startX;
int32 _startY;
bool _leftClick;
bool _rightButton;
- uint32 _curMouseCursor;
- int32 _cursorStep;
bool _isActive;
bool _skipDrawScene;
uint32 _playerActorIdx;
@@ -123,18 +120,6 @@ private:
bool isBarrierOnScreen(BarrierItem *barrier);
uint32 getRandomResId(BarrierItem *barrier);
- /**
- * Check whether the cursor resource needs to be changed, and
- * if so, make that change
- */
- void updateCursor();
-
- /**
- * Update the cursor to visually indicate that it is over a
- * clickable region (by running its associated animation)
- */
- void animateCursor();
-
void debugScreenScrolling(GraphicFrame *bg);
void debugShowPolygons();
void debugShowBarriers();
diff --git a/engines/asylum/screen.h b/engines/asylum/screen.h
index f514a058da..836ead8985 100644
--- a/engines/asylum/screen.h
+++ b/engines/asylum/screen.h
@@ -31,7 +31,6 @@
#include "asylum/respack.h"
#include "common/system.h" // for OSystem
-#include "graphics/cursorman.h"
#include "graphics/surface.h"
namespace Asylum {
@@ -62,14 +61,6 @@ public:
void drawWideScreen(int16 barSize);
void clearScreen();
- void showCursor() { CursorMan.showMouse(true); }
- void hideCursor() { CursorMan.showMouse(false); }
- void setCursor(byte *data, byte width, byte height) { CursorMan.replaceCursor(data, width, height, 0, 0, 0); }
- void setCursor(GraphicResource *cursorRes, int frame) {
- GraphicFrame *mouseCursor = cursorRes->getFrame(frame);
- setCursor((byte *)mouseCursor->surface.pixels, mouseCursor->surface.w, mouseCursor->surface.h);
- }
-
void addGraphicToQueue(uint32 redId, uint32 frameIdx, uint32 x, uint32 y, uint32 flags, uint32 transTableNum, uint32 priority);
void addCrossFadeGraphicToQueue(uint32 redId, uint32 frameIdx, uint32 x, uint32 y, uint32 redId2, uint32 x2, uint32 y2, uint32 flags, uint32 priority);
void addGraphicToQueue(GraphicQueueItem item);
diff --git a/engines/asylum/scriptman.cpp b/engines/asylum/scriptman.cpp
index c3e58d406b..a3a94473f6 100644
--- a/engines/asylum/scriptman.cpp
+++ b/engines/asylum/scriptman.cpp
@@ -152,12 +152,12 @@ int ScriptManager::processActionList() {
break;
/* 0x05 */ case kHideCursor:
- Shared.getScreen()->hideCursor();
+ Shared.getScene()->getCursor()->hide();
_allowInput = false;
break;
/* 0x06 */ case kShowCursor:
- Shared.getScreen()->showCursor();
+ Shared.getScene()->getCursor()->show();
_allowInput = true;
// TODO: clear_flag_01()
break;
Commit: f169d00db0a39f9da2038a6845bf0304c016f543
https://github.com/scummvm/scummvm/commit/f169d00db0a39f9da2038a6845bf0304c016f543
Author: Alex Bevilacqua (alexbevi at gmail.com)
Date: 2021-05-17T15:35:45+02:00
Commit Message:
ASYLUM: Comments
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@325 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/cursor.h
diff --git a/engines/asylum/cursor.h b/engines/asylum/cursor.h
index 71bb09ecea..59c2dac309 100644
--- a/engines/asylum/cursor.h
+++ b/engines/asylum/cursor.h
@@ -32,30 +32,68 @@ namespace Asylum {
struct CommonResources;
+/**
+ * Asylum cursors are GraphicResources, and are stored in
+ * ResourcePacks, as are all game assets.
+ */
class Cursor {
public:
Cursor(ResourcePack *res);
virtual ~Cursor();
-
+ /**
+ * Show the current cursor
+ */
void show();
+ /**
+ * Hide the current cursor
+ */
void hide();
/**
* Load a GraphicResource at the position specified by
- * index from the _resPack ResourcePack
+ * index from the buffered ResourcePack
*/
void load(uint32 index);
- void set(byte *data, byte width, byte height);
+ /**
+ * Set the current cursor to a specific frame
+ * within the loaded cursorResource
+ */
void set(int frame);
+ /**
+ * Set the x/y coordinates of the cursor
+ */
void setCoords(uint32 mouseX, uint32 mouseY);
- void update();
+ /**
+ * Scene-based update to the current cursor. This
+ * checks whether the cursor should be updated depending
+ * on the MainActor's current action.
+ *
+ * TODO this probably doesn't belong here, but on the
+ * scene, where it originally was
+ */
void update(CommonResources *cr, int currentAction);
+ /**
+ * Get the next logical frame from the currently loaded
+ * cursorResource and draw it
+ */
void animate();
+ /**
+ * Get the X position of the cursor
+ */
uint32 x() { return _mouseX; }
+ /**
+ * get the Y position of the cursor
+ */
uint32 y() { return _mouseY; }
+ /**
+ * Get the current frame number of the
+ * loaded cursorResource
+ */
uint32 currentFrame() { return _curFrame; }
private:
+ void set(byte *data, byte width, byte height);
+
ResourcePack *_resPack;
GraphicResource *_cursorResource;
bool cursorLoaded;
Commit: b9ee645fed1bd9ada463dfd42770162c710241ad
https://github.com/scummvm/scummvm/commit/b9ee645fed1bd9ada463dfd42770162c710241ad
Author: Alex Bevilacqua (alexbevi at gmail.com)
Date: 2021-05-17T15:35:45+02:00
Commit Message:
ASYLUM: Implemented kJumpIfFlag2Bit0. Also modified kSetFlag2Bit0 to actually set the action area flag
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@326 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/sceneres.cpp
engines/asylum/sceneres.h
engines/asylum/scriptman.cpp
diff --git a/engines/asylum/sceneres.cpp b/engines/asylum/sceneres.cpp
index 5ba542cc8b..b392dcefa7 100644
--- a/engines/asylum/sceneres.cpp
+++ b/engines/asylum/sceneres.cpp
@@ -40,6 +40,18 @@ SceneResource::~SceneResource() {
delete _actionList;
}
+int SceneResource::getActionAreaIndexById(uint32 id) {
+ for (uint32 i = 0; i < _worldStats->numActions; i++) {
+ if (_worldStats->actions[i].id == id)
+ return i;
+ }
+ return -1;
+}
+
+ActionArea* SceneResource::getActionAreaById(uint32 id) {
+ return &_worldStats->actions[getActionAreaIndexById(id)];
+}
+
int SceneResource::getBarrierIndexById(uint32 id) {
for (uint32 i=0; i < _worldStats->numBarriers; i++) {
if (_worldStats->barriers[i].id == id)
diff --git a/engines/asylum/sceneres.h b/engines/asylum/sceneres.h
index 6d450081af..ec57acd43d 100644
--- a/engines/asylum/sceneres.h
+++ b/engines/asylum/sceneres.h
@@ -45,6 +45,7 @@ class WorldStats;
class GamePolygons;
class ActionList;
struct BarrierItem;
+struct ActionArea;
class SceneResource {
public:
@@ -59,6 +60,8 @@ public:
MainActor* getMainActor() { return _mainActor; }
int getBarrierIndexById(uint32 id);
+ int getActionAreaIndexById(uint32 id);
+ ActionArea* getActionAreaById(uint32 id);
BarrierItem* getBarrierById(uint32 id);
BarrierItem* getBarrierByIndex(uint32 idx);
diff --git a/engines/asylum/scriptman.cpp b/engines/asylum/scriptman.cpp
index a3a94473f6..b0a30a4d87 100644
--- a/engines/asylum/scriptman.cpp
+++ b/engines/asylum/scriptman.cpp
@@ -410,25 +410,35 @@ int ScriptManager::processActionList() {
}
}
break;
+
/* 0x17 */ case kClearFlag1Bit0: {
BarrierItem *barrier = Shared.getScene()->getResources()->getBarrierById(currentCommand->param1);
barrier->flags &= 0xFFFFFFFE;
}
break;
+
/* 0x18 */ //case k_unk18_PLAY_SND:
-/* 0x19 */ //case kJumpIfFlag2Bit0:
+/* 0x19 */ case kJumpIfFlag2Bit0: {
+ int targetType = currentCommand->param2;
+ if (targetType <= 0)
+ done = Shared.getScene()->getResources()->getBarrierById(currentCommand->param1)->flags2 & 1 == 0;
+ else
+ if (targetType == 1) // v4 == 1, so 1
+ done = Shared.getScene()->getResources()->getActionAreaById(currentCommand->param1)->actionType & 1 == 0;
+ else
+ done = Shared.getScene()->getResources()->getWorldStats()->actors[currentCommand->param1].flags2 & 1 == 0;
+ }
+ break;
+
/* 0x1A */ case kSetFlag2Bit0: {
int targetType = currentCommand->param2;
if (targetType == 2)
Shared.getScene()->getResources()->getWorldStats()->actors[currentCommand->param1].flags2 |= 1;
else
- if (targetType == 1) {
- // int actionIdx = getActionIndex(currentCommand->param1);
- //scene.actionAreas[actionIdx].flags |= 1;
- debugC(kDebugLevelScripts, "ActionArea Flag Set not implemented");
- } else {
+ if (targetType == 1)
+ Shared.getScene()->getResources()->getActionAreaById(currentCommand->param1)->actionType |= 1;
+ else
Shared.getScene()->getResources()->getBarrierById(currentCommand->param1)->flags2 |= 1;
- }
}
break;
/* 0x1B */ //case kClearFlag2Bit0:
@@ -701,8 +711,7 @@ int ScriptManager::processActionList() {
/* 0x63 */ //case k_unk61:
default:
- debugC(kDebugLevelScripts,
- "Unhandled opcode 0x%02X in Scene %d Line %d.",
+ warning("Unhandled opcode 0x%02X in Scene %d Line %d.",
currentCommand->opcode,
Shared.getScene()->getSceneIndex(),
_currentLine);
Commit: 3f4a861a410dca3312b55aab212fba8836df47b8
https://github.com/scummvm/scummvm/commit/3f4a861a410dca3312b55aab212fba8836df47b8
Author: Alex Bevilacqua (alexbevi at gmail.com)
Date: 2021-05-17T15:35:45+02:00
Commit Message:
ASYLUM: Initial implementation of updateMouse(). This still needs some work, and will likely be completed after the actor code refactoring.
The method implementation is currently commented out.
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@327 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/scene.cpp
engines/asylum/scene.h
diff --git a/engines/asylum/scene.cpp b/engines/asylum/scene.cpp
index 452cd2964f..645edf34ff 100644
--- a/engines/asylum/scene.cpp
+++ b/engines/asylum/scene.cpp
@@ -144,8 +144,8 @@ void Scene::setActorPosition(int actorIndex, int x, int y) {
// FIXME - Remove this once mainActor uses proper actor info
if (actorIndex == 0) {
- _sceneResource->getMainActor()->_actorX = x;
- _sceneResource->getMainActor()->_actorY = y;
+ _sceneResource->getMainActor()->x(x);
+ _sceneResource->getMainActor()->y(y);
}
}
@@ -256,9 +256,14 @@ void Scene::update() {
}
int Scene::updateScene() {
- uint32 startTick = 0;
- WorldStats *worldStats = _sceneResource->getWorldStats();
+ uint32 startTick = 0;
+ WorldStats *worldStats = _sceneResource->getWorldStats();
+ // Mouse
+ //startTick = Shared.getMillis();
+ //updateMouse();
+ //debugC(kDebugLevelScene, "UpdateMouse Time: %d", Shared.getMillis() - startTick);
+
// Actors
startTick = Shared.getMillis();
for (uint32 a = 0; a < worldStats->numActors; a++) {
@@ -296,6 +301,143 @@ int Scene::isActorVisible(ActorItem *actor) {
return actor->flags & 1;
}
+void Scene::updateMouse() {
+ Common::Rect actorPos;
+ ActorItem *actor = &_sceneResource->getWorldStats()->actors[_playerActorIdx];
+
+ if (_sceneIdx != 2 || _playerActorIdx != 10) {
+ actorPos.top = actor->y0;
+ actorPos.left = actor->x0 + 20;
+ actorPos.right = actor->x0 + 2 + actor->x2;
+ actorPos.bottom = actor->y0 + actor->y2;
+ } else {
+ actorPos.top = actor->y0 + 60;
+ actorPos.left = actor->x0 + 50;
+ actorPos.right = actor->x0 + actor->x2 + 10;
+ actorPos.bottom = actor->y0 + actor->y2 - 20;
+ }
+
+ int dir = -1;
+ bool done = false;
+
+ if (_cursor->x() < actorPos.left) {
+ if (_cursor->y() >= actorPos.top) {
+ if (_cursor->y() > actorPos.bottom) {
+ if (actor->direction == 2) {
+ if (_cursor->y() - actorPos.bottom > 10)
+ dir = 3;
+ } else {
+ if (actor->direction == 4) {
+ if (actorPos.left - _cursor->x() > 10)
+ dir = 3;
+ } else {
+ dir = 3;
+ }
+ }
+ } else {
+ if (actor->direction == 1) {
+ if (_cursor->y() - actorPos.top > 10)
+ dir = 2;
+ } else {
+ if (actor->direction == 3) {
+ if (actorPos.bottom - _cursor->y() > 10)
+ dir = 2;
+ } else {
+ dir = 2;
+ }
+ }
+ }
+ } else {
+ if (actor->direction) {
+ if (actor->direction == 2) {
+ if (actorPos.top - _cursor->y() > 10)
+ dir = 1;
+ } else {
+ dir = 1;
+ }
+ } else {
+ if (actorPos.left - _cursor->x() > 10)
+ dir = 1;
+ }
+ }
+ done = true;
+ }
+
+ if (!done && _cursor->x() <= actorPos.right) {
+ if (_cursor->y() >= actorPos.top) {
+ if (_cursor->y() > actorPos.bottom) {
+ if (actor->direction == 3) {
+ if (_cursor->x() - actorPos.left > 10)
+ dir = 4;
+ } else {
+ if (actor->direction == 5) {
+ if (actorPos.right - _cursor->x() > 10)
+ dir = 4;
+ } else {
+ dir = 4;
+ }
+ }
+ }
+ } else {
+ if (actor->direction == 1) {
+ if (_cursor->x() - actorPos.left > 10)
+ dir = 0;
+ } else {
+ if (actor->direction == 7) {
+ if (actorPos.right - _cursor->x() > 10)
+ dir = 0;
+ } else {
+ dir = 0;
+ }
+ }
+ }
+ done = true;
+ }
+
+ if (!done && _cursor->y() < actorPos.top) {
+ if (actor->direction) {
+ if (actor->direction == 6) {
+ if (actorPos.top - _cursor->y() > 10)
+ dir = 7;
+ } else {
+ dir = 7;
+ }
+ } else {
+ if (_cursor->x() - actorPos.right > 10)
+ dir = 7;
+ }
+ done = true;
+ }
+
+ if (!done && _cursor->y() <= actorPos.bottom) {
+ if (actor->direction == 5) {
+ if (actorPos.bottom - _cursor->y() > 10)
+ dir = 6;
+ } else {
+ if (actor->direction == 7) {
+ if (_cursor->y() - actorPos.top > 10)
+ dir = 6;
+ } else {
+ dir = 6;
+ }
+ }
+ done = true;
+ }
+
+ if (!done && actor->direction == 4) {
+ if (_cursor->x() - actorPos.right <= 10)
+ done = true;
+ if (!done)
+ dir = 5;
+ }
+
+ if (!done && (actor->direction != 6 || _cursor->y() - actorPos.bottom > 10)) {
+ dir = 5;
+ }
+
+ //printf("Current Dir %d -- New Dir %d\n", actor->direction, dir);
+}
+
void Scene::updateActor(uint32 actorIdx) {
WorldStats *worldStats = _sceneResource->getWorldStats();
ActorItem *actor = &worldStats->actors[actorIdx];
@@ -599,7 +741,7 @@ void Scene::OLD_UPDATE(WorldStats *worldStats) {
if (worldStats->actions[a].actionType == 0) {
ActionArea *area = &worldStats->actions[a];
PolyDefinitions poly = _sceneResource->getGamePolygons()->polygons[area->polyIdx];
- if (Shared.pointInPoly(&poly, mainActor->_actorX, mainActor->_actorY)) {
+ if (Shared.pointInPoly(&poly, mainActor->x(), mainActor->y())) {
debugShowWalkRegion(&poly);
//break;
}
diff --git a/engines/asylum/scene.h b/engines/asylum/scene.h
index 5e62d36afb..bdbb047cc2 100644
--- a/engines/asylum/scene.h
+++ b/engines/asylum/scene.h
@@ -106,6 +106,7 @@ private:
void update();
int updateScene();
+ void updateMouse();
void updateActor(uint32 actorIdx);
void updateBarriers(WorldStats *worldStats);
void updateAmbientSounds();
@@ -113,9 +114,7 @@ private:
void updateAdjustScreen();
int drawScene();
int drawBarriers();
-
- int isActorVisible(ActorItem *actor);
-
+ int isActorVisible(ActorItem *actor);
bool isBarrierVisible(BarrierItem *barrier);
bool isBarrierOnScreen(BarrierItem *barrier);
uint32 getRandomResId(BarrierItem *barrier);
Commit: feb852bd8be7d4c5686990654014b2d0f20d84cb
https://github.com/scummvm/scummvm/commit/feb852bd8be7d4c5686990654014b2d0f20d84cb
Author: Alex Bevilacqua (alexbevi at gmail.com)
Date: 2021-05-17T15:35:45+02:00
Commit Message:
ASYLUM: Reworked the action list processor to use a function map as opposed to a switch tree. This is a cleaner solution, thought i'm not sure if there's a tradeoff as far as efficiency is concerned.
Also implemented the angle processing algorithm (and the associated lookup tables)
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@328 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/actor.cpp
engines/asylum/actor.h
engines/asylum/asylum.cpp
engines/asylum/console.cpp
engines/asylum/scene.cpp
engines/asylum/scriptman.cpp
engines/asylum/scriptman.h
engines/asylum/shared.cpp
engines/asylum/shared.h
diff --git a/engines/asylum/actor.cpp b/engines/asylum/actor.cpp
index 966ba8816f..60c13d1389 100644
--- a/engines/asylum/actor.cpp
+++ b/engines/asylum/actor.cpp
@@ -106,19 +106,18 @@ GraphicFrame *MainActor::getFrame() {
return frame;
}
-void MainActor::drawActorAt(uint16 x, uint16 y) {
+void MainActor::drawActorAt(uint16 curX, uint16 curY) {
GraphicFrame *frame = getFrame();
Shared.getScreen()->copyRectToScreenWithTransparency(
((byte *)frame->surface.pixels),
frame->surface.w,
- x,
- y,
+ curX,
+ curY,
frame->surface.w,
frame->surface.h );
-
- _actorX = x;
- _actorY = y;
+ x(curX);
+ y(curY);
}
void MainActor::drawActor() {
@@ -141,7 +140,7 @@ void MainActor::setWalkArea(ActionArea *target) {
}
}
-void MainActor::walkTo(uint16 x, uint16 y) {
+void MainActor::walkTo(uint16 curX, uint16 curY) {
int newAction = _currentAction;
// step is the increment by which to move the
@@ -153,26 +152,26 @@ void MainActor::walkTo(uint16 x, uint16 y) {
bool done = false;
// Walking left...
- if (x < _actorX) {
+ if (curX < _actorX) {
newAction = kWalkW;
newX -= step;
- if (ABS(y - _actorY) <= 30)
+ if (ABS(curY - _actorY) <= 30)
done = true;
}
// Walking right...
- if (x > _actorX) {
+ if (curX > _actorX) {
newAction = kWalkE;
newX += step;
- if (ABS(y - _actorY) <= 30)
+ if (ABS(curY - _actorY) <= 30)
done = true;
}
// Walking up...
- if (y < _actorY && !done) {
- if (newAction != _currentAction && newAction == kWalkW && _actorX - x > 30)
+ if (curY < _actorY && !done) {
+ if (newAction != _currentAction && newAction == kWalkW && _actorX - curX > 30)
newAction = kWalkNW; // up left
- else if (newAction != _currentAction && newAction == kWalkE && x - _actorX > 30)
+ else if (newAction != _currentAction && newAction == kWalkE && curX - _actorX > 30)
newAction = kWalkNE; // up right
else
newAction = kWalkN;
@@ -181,10 +180,10 @@ void MainActor::walkTo(uint16 x, uint16 y) {
}
// Walking down...
- if (y > _actorY && !done) {
- if (newAction != _currentAction && newAction == kWalkW && _actorX - x > 30)
+ if (curY > _actorY && !done) {
+ if (newAction != _currentAction && newAction == kWalkW && _actorX - curX > 30)
newAction = kWalkSW; // down left
- else if (newAction != _currentAction && newAction == kWalkE && x - _actorX > 30)
+ else if (newAction != _currentAction && newAction == kWalkE && curX - _actorX > 30)
newAction = kWalkSE; // down right
else
newAction = kWalkS;
@@ -210,7 +209,7 @@ void MainActor::walkTo(uint16 x, uint16 y) {
surface.free();
// TODO Basic pathfinding implementation is done. Now it needs to be refined to
- // actually make it playable. The logic is currently VERY rigid, so you have to have
+ // actuallcurY make it playable. The logic is currently VERY rigid, so you have to have
// the actor at the PERFECT spot to be able to intersect a walk region and move to
// the next one.
@@ -242,8 +241,8 @@ void MainActor::walkTo(uint16 x, uint16 y) {
area = &Shared.getScene()->getResources()->getWorldStats()->actions[availableAreas[i]];
PolyDefinitions *region = &Shared.getScene()->getResources()->getGamePolygons()->polygons[area->polyIdx];
if (Shared.pointInPoly(region, newX, newY)) {
- _actorX = newX;
- _actorY = newY;
+ x(newX);
+ y(newY);
break;
}
}
@@ -252,6 +251,16 @@ void MainActor::walkTo(uint16 x, uint16 y) {
drawActor();
}
+void MainActor::x(uint16 pos) {
+ _actorX = pos;
+ _actorRef->x0 = pos;
+}
+
+void MainActor::y(uint16 pos) {
+ _actorY = pos;
+ _actorRef->y0 = pos;
+}
+
void MainActor::disable(int param) {
switch (param) {
diff --git a/engines/asylum/actor.h b/engines/asylum/actor.h
index 68e02ad8f5..c4e12cff05 100644
--- a/engines/asylum/actor.h
+++ b/engines/asylum/actor.h
@@ -136,22 +136,31 @@ public:
void setWalkArea(ActionArea *target); // TODO depreciate
void setAction(int action);
void setActionByIndex(int index);
- void drawActorAt(uint16 x, uint16 y);
+ void drawActorAt(uint16 curX, uint16 curY);
void drawActor();
- void walkTo(uint16 x, uint16 y);
+ void walkTo(uint16 curX, uint16 curY);
void disable(int param);
void setDirection(int direction);
int getCurrentAction() { return _currentAction; }
-
- uint16 _actorX, _actorY;
+ // XXX
+ // Setting the actorRef x/y values is just a hack
+ // while we fix the actor code. The mainactor class will
+ // likely be completely redone, so the screen coords of
+ // the actor should be updated on the ActorItem reference
+ // when updating the class
+ void x(uint16 pos);
+ void y(uint16 pos);
+ uint16 x() { return _actorX; }
+ uint16 y() { return _actorY; }
private:
GraphicResource *_graphic;
ResourcePack *_resPack;
- uint32 _resources[61];
- uint8 _currentFrame;
- int _currentAction;
-
+ uint32 _resources[61];
+ uint8 _currentFrame;
+ int _currentAction;
+ uint16 _actorX;
+ uint16 _actorY;
ActionArea *_currentWalkArea;
ActorItem *_actorRef;
diff --git a/engines/asylum/asylum.cpp b/engines/asylum/asylum.cpp
index 52f8faed98..461db83562 100644
--- a/engines/asylum/asylum.cpp
+++ b/engines/asylum/asylum.cpp
@@ -260,12 +260,12 @@ void AsylumEngine::checkForEvent(bool doUpdate) { // k_sub_40AE30 (0040AE30)
void AsylumEngine::processDelayedEvents() {
// check for a delayed video
- int videoIdx = ScriptMan.getDelayedVideoIndex();
+ int videoIdx = ScriptMan.delayedVideoIndex;
if (videoIdx >= 0) {
_sound->stopMusic();
_sound->stopSfx();
_video->playVideo(videoIdx, kSubtitlesOn);
- ScriptMan.setDelayedVideoIndex(-1);
+ ScriptMan.delayedVideoIndex = -1;
if (_mainMenu->isActive())
_mainMenu->openMenu();
@@ -274,8 +274,8 @@ void AsylumEngine::processDelayedEvents() {
}
// check for a delayed scene change
- int sceneIdx = ScriptMan.getDelayedSceneIndex();
- if (sceneIdx >=0 && !ScriptMan.isProcessing()) {
+ int sceneIdx = ScriptMan.delayedSceneIndex;
+ if (sceneIdx >=0 && !ScriptMan.processing) {
_sound->stopMusic();
_sound->stopSfx();
@@ -286,7 +286,7 @@ void AsylumEngine::processDelayedEvents() {
Shared.setScene(_scene);
_scene->enterScene();
- ScriptMan.setDelayedSceneIndex(-1);
+ ScriptMan.delayedSceneIndex = -1;
ScriptMan.setScript(_scene->getDefaultActionList());
}
}
diff --git a/engines/asylum/console.cpp b/engines/asylum/console.cpp
index a1b7e3880e..317dfbada3 100644
--- a/engines/asylum/console.cpp
+++ b/engines/asylum/console.cpp
@@ -118,7 +118,7 @@ bool Console::cmdPlayVideo(int argc, const char **argv) {
return true;
}
- ScriptMan.setDelayedVideoIndex(atoi(argv[1]));
+ ScriptMan.delayedVideoIndex = atoi(argv[1]);
return false;
}
@@ -145,7 +145,7 @@ bool Console::cmdChangeScene(int argc, const char **argv) {
return true;
}
- ScriptMan.setDelayedSceneIndex(atoi(argv[1]));
+ ScriptMan.delayedSceneIndex = atoi(argv[1]);
ScriptMan.setScript(0);
return false;
diff --git a/engines/asylum/scene.cpp b/engines/asylum/scene.cpp
index 645edf34ff..60a4c5dac4 100644
--- a/engines/asylum/scene.cpp
+++ b/engines/asylum/scene.cpp
@@ -217,12 +217,12 @@ void Scene::handleEvent(Common::Event *event, bool doUpdate) {
break;
case Common::EVENT_LBUTTONUP:
- if (ScriptMan.isInputAllowed())
+ if (ScriptMan.allowInput)
_leftClick = true;
break;
case Common::EVENT_RBUTTONUP:
- if (ScriptMan.isInputAllowed()) {
+ if (ScriptMan.allowInput) {
// TODO This isn't always going to be the magnifying glass
// Should check the current pointer region to identify the type
// of cursor to use
@@ -232,7 +232,7 @@ void Scene::handleEvent(Common::Event *event, bool doUpdate) {
break;
case Common::EVENT_RBUTTONDOWN:
- if (ScriptMan.isInputAllowed())
+ if (ScriptMan.allowInput)
_rightButton = true;
break;
}
diff --git a/engines/asylum/scriptman.cpp b/engines/asylum/scriptman.cpp
index b0a30a4d87..1920a32338 100644
--- a/engines/asylum/scriptman.cpp
+++ b/engines/asylum/scriptman.cpp
@@ -4,18 +4,18 @@
* 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
+ * 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
+ * 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
+ * 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
+ * along with this program { if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* $URL$
@@ -33,18 +33,134 @@ namespace Asylum {
static bool g_initialized = false;
+typedef int AsylumFunc(ActionCommand *cmd);
+
+struct AsylumFunction {
+ const char *name;
+ AsylumFunc *function;
+};
+
+#define MAPFUNC(name, func) {name, func}
+
+AsylumFunction function_map[] = {
+ /*0x00*/ MAPFUNC("kReturn0", kReturn0),
+ /*0x01*/ MAPFUNC("kSetGameFlag", kSetGameFlag),
+ /*0x02*/ MAPFUNC("kClearGameFlag", kClearGameFlag),
+ /*0x03*/ MAPFUNC("kToggleGameFlag", kToggleGameFlag),
+ /*0x04*/ MAPFUNC("kJumpIfGameFlag", kJumpIfGameFlag),
+ /*0x05*/ MAPFUNC("kHideCursor", kHideCursor),
+ /*0x06*/ MAPFUNC("kShowCursor", kShowCursor),
+ /*0x07*/ MAPFUNC("kPlayAnimation", kPlayAnimation),
+ /*0x08*/ MAPFUNC("kMoveScenePosition", kMoveScenePosition),
+ /*0x09*/ MAPFUNC("kHideActor", kHideActor),
+ /*0x0A*/ MAPFUNC("kShowActor", kShowActor),
+ /*0x0B*/ MAPFUNC("kSetActorStats", kSetActorStats),
+ /*0x0C*/ MAPFUNC("kSetSceneMotionStat", kSetSceneMotionStat),
+ /*0x0D*/ MAPFUNC("kDisableActor", kDisableActor),
+ /*0x0E*/ MAPFUNC("kEnableActor", kEnableActor),
+ /*0x0F*/ MAPFUNC("kEnableBarriers", kEnableBarriers),
+ /*0x10*/ MAPFUNC("kReturn", kReturn),
+ /*0x11*/ MAPFUNC("kDestroyBarrier", kDestroyBarrier),
+ /*0x12*/ MAPFUNC("k_unk12_JMP_WALK_ACTOR", k_unk12_JMP_WALK_ACTOR),
+ /*0x13*/ MAPFUNC("k_unk13_JMP_WALK_ACTOR", k_unk13_JMP_WALK_ACTOR),
+ /*0x14*/ MAPFUNC("k_unk14_JMP_WALK_ACTOR", k_unk14_JMP_WALK_ACTOR),
+ /*0x15*/ MAPFUNC("k_unk15", k_unk15),
+ /*0x16*/ MAPFUNC("kResetAnimation", kResetAnimation),
+ /*0x17*/ MAPFUNC("kClearFlag1Bit0", kClearFlag1Bit0),
+ /*0x18*/ MAPFUNC("k_unk18_PLAY_SND", k_unk18_PLAY_SND),
+ /*0x19*/ MAPFUNC("kJumpIfFlag2Bit0", kJumpIfFlag2Bit0),
+ /*0x1A*/ MAPFUNC("kSetFlag2Bit0", kSetFlag2Bit0),
+ /*0x1B*/ MAPFUNC("kClearFlag2Bit0", kClearFlag2Bit0),
+ /*0x1C*/ MAPFUNC("kJumpIfFlag2Bit2", kJumpIfFlag2Bit2),
+ /*0x1D*/ MAPFUNC("kSetFlag2Bit2", kSetFlag2Bit2),
+ /*0x1E*/ MAPFUNC("kClearFlag2Bit2", kClearFlag2Bit2),
+ /*0x1F*/ MAPFUNC("kJumpIfFlag2Bit1", kJumpIfFlag2Bit1),
+ /*0x20*/ MAPFUNC("kSetFlag2Bit1", kSetFlag2Bit1),
+ /*0x21*/ MAPFUNC("kClearFlag2Bit1", kClearFlag2Bit1),
+ /*0x22*/ MAPFUNC("k_unk22", k_unk22),
+ /*0x23*/ MAPFUNC("k_unk23", k_unk23),
+ /*0x24*/ MAPFUNC("k_unk24", k_unk24),
+ /*0x25*/ MAPFUNC("kRunEncounter", kRunEncounter),
+ /*0x26*/ MAPFUNC("kJumpIfFlag2Bit4", kJumpIfFlag2Bit4),
+ /*0x27*/ MAPFUNC("kSetFlag2Bit4", kSetFlag2Bit4),
+ /*0x28*/ MAPFUNC("kClearFlag2Bit4", kClearFlag2Bit4),
+ /*0x29*/ MAPFUNC("kSetActorField638", kSetActorField638),
+ /*0x2A*/ MAPFUNC("kJumpIfActorField638", kJumpIfActorField638),
+ /*0x2B*/ MAPFUNC("kChangeScene", kChangeScene),
+ /*0x2C*/ MAPFUNC("k_unk2C_ActorSub", k_unk2C_ActorSub),
+ /*0x2D*/ MAPFUNC("kPlayMovie", kPlayMovie),
+ /*0x2E*/ MAPFUNC("kStopAllBarriersSounds", kStopAllBarriersSounds),
+ /*0x2F*/ MAPFUNC("kSetActionFlag01", kSetActionFlag01),
+ /*0x30*/ MAPFUNC("kClearActionFlag01", kClearActionFlag01),
+ /*0x31*/ MAPFUNC("kResetSceneRect", kResetSceneRect),
+ /*0x32*/ MAPFUNC("kChangeMusicById", kChangeMusicById),
+ /*0x33*/ MAPFUNC("kStopMusic", kStopMusic),
+ /*0x34*/ MAPFUNC("k_unk34_Status", k_unk34_Status),
+ /*0x35*/ MAPFUNC("k_unk35", k_unk35),
+ /*0x36*/ MAPFUNC("k_unk36", k_unk36),
+ /*0x37*/ MAPFUNC("kRunBlowUpPuzzle", kRunBlowUpPuzzle),
+ /*0x38*/ MAPFUNC("kJumpIfFlag2Bit3", kJumpIfFlag2Bit3),
+ /*0x39*/ MAPFUNC("kSetFlag2Bit3", kSetFlag2Bit3),
+ /*0x3A*/ MAPFUNC("kClearFlag2Bit3", kClearFlag2Bit3),
+ /*0x3B*/ MAPFUNC("k_unk3B_PALETTE_MOD", k_unk3B_PALETTE_MOD),
+ /*0x3C*/ MAPFUNC("k_unk3C_CMP_VAL", k_unk3C_CMP_VAL),
+ /*0x3D*/ MAPFUNC("kWaitUntilFramePlayed", kWaitUntilFramePlayed),
+ /*0x3E*/ MAPFUNC("kUpdateWideScreen", kUpdateWideScreen),
+ /*0x3F*/ MAPFUNC("k_unk3F", k_unk3F),
+ /*0x40*/ MAPFUNC("k_unk40_SOUND", k_unk40_SOUND),
+ /*0x41*/ MAPFUNC("kPlaySpeech", kPlaySpeech),
+ /*0x42*/ MAPFUNC("k_unk42", k_unk42),
+ /*0x43*/ MAPFUNC("k_unk43", k_unk43),
+ /*0x44*/ MAPFUNC("kPaletteFade", kPaletteFade),
+ /*0x45*/ MAPFUNC("kStartPaletteFadeThread", kStartPaletteFadeThread),
+ /*0x46*/ MAPFUNC("k_unk46", k_unk46),
+ /*0x47*/ MAPFUNC("kActorFaceObject", kActorFaceObject),
+ /*0x48*/ MAPFUNC("k_unk48_MATTE_01", k_unk48_MATTE_01),
+ /*0x49*/ MAPFUNC("k_unk49_MATTE_90", k_unk49_MATTE_90),
+ /*0x4A*/ MAPFUNC("kJumpIfSoundPlaying", kJumpIfSoundPlaying),
+ /*0x4B*/ MAPFUNC("kChangePlayerCharacterIndex", kChangePlayerCharacterIndex),
+ /*0x4C*/ MAPFUNC("kChangeActorField40", kChangeActorField40),
+ /*0x4D*/ MAPFUNC("kStopSound", kStopSound),
+ /*0x4E*/ MAPFUNC("k_unk4E_RANDOM_COMMAND", k_unk4E_RANDOM_COMMAND),
+ /*0x4F*/ MAPFUNC("kClearScreen", kClearScreen),
+ /*0x50*/ MAPFUNC("kQuit", kQuit),
+ /*0x51*/ MAPFUNC("kJumpBarrierFrame", kJumpBarrierFrame),
+ /*0x52*/ MAPFUNC("k_unk52", k_unk52),
+ /*0x53*/ MAPFUNC("k_unk53", k_unk53),
+ /*0x54*/ MAPFUNC("k_unk54_SET_ACTIONLIST_6EC", k_unk54_SET_ACTIONLIST_6EC),
+ /*0x55*/ MAPFUNC("k_unk55", k_unk55),
+ /*0x56*/ MAPFUNC("k_unk56", k_unk56),
+ /*0x57*/ MAPFUNC("kSetResourcePalette", kSetResourcePalette),
+ /*0x58*/ MAPFUNC("kSetBarrierFrameIdxFlaged", kSetBarrierFrameIdxFlaged),
+ /*0x59*/ MAPFUNC("k_unk59", k_unk59),
+ /*0x5A*/ MAPFUNC("k_unk5A", k_unk5A),
+ /*0x5B*/ MAPFUNC("k_unk5B", k_unk5B),
+ /*0x5C*/ MAPFUNC("k_unk5C", k_unk5C),
+ /*0x5D*/ MAPFUNC("k_unk5D", k_unk5D),
+ /*0x5E*/ MAPFUNC("k_unk5E", k_unk5E),
+ /*0x5F*/ MAPFUNC("kSetBarrierLastFrameIdx", kSetBarrierLastFrameIdx),
+ /*0x60*/ MAPFUNC("k_unk60_SET_OR_CLR_ACTIONAREA_FLAG", k_unk60_SET_OR_CLR_ACTIONAREA_FLAG),
+ /*0x61*/ MAPFUNC("k_unk61", k_unk61),
+ /*0x62*/ MAPFUNC("k_unk62_SHOW_OPTIONS_SCREEN", k_unk62_SHOW_OPTIONS_SCREEN),
+ /*0x63*/ MAPFUNC("k_unk63", k_unk63)
+};
+
ScriptManager::ScriptManager() {
if (!g_initialized) {
- g_initialized = true;
- _currentLine = 0;
- _currentLoops = 0;
- _processing = false;
- _delayedSceneIndex = -1;
- _delayedVideoIndex = -1;
- _allowInput = true;
+ g_initialized = true;
+ currentLine = 0;
+ currentLoops = 0;
+ processing = false;
+ delayedSceneIndex = -1;
+ delayedVideoIndex = -1;
+ allowInput = true;
}
}
+ScriptManager::~ScriptManager() {
+ // TODO Release function_map list
+}
+
void ScriptManager::setScript(ActionDefinitions *action) {
_currentScript = action;
@@ -69,8 +185,8 @@ void ScriptManager::setScript(ActionDefinitions *action) {
}
void ScriptManager::setScriptIndex(uint32 index) {
- _currentScript = 0;
- _currentLine = 0;
+ _currentScript = 0;
+ currentLine = 0;
setScript(Shared.getScene()->getActionList(index));
}
@@ -96,647 +212,47 @@ int ScriptManager::setBarrierNextFrame(int barrierId, int barrierFlags) {
}
int ScriptManager::processActionList() {
- bool done = false, waitCycle = false;
- int lineIncrement = 1;
-
- _processing = true;
+ done = false;
+ waitCycle = false;
+ lineIncrement = 1;
+ processing = true;
if (_currentScript) {
while (!done && !waitCycle) {
- lineIncrement = 1; // Reset line increment value
+ lineIncrement = 1; //Reset line increment value
- if (_currentLoops > 1000) {
- // TODO - processActionLists has run too many iterations
+ if (currentLoops > 1000) {
+ //TODO - processActionLists has run too many iterations
}
- ActionCommand *currentCommand = &_currentScript->commands[_currentLine];
+ ActionCommand *currentCommand = &_currentScript->commands[currentLine];
- switch (currentCommand->opcode) {
+ uint32 opcode = currentCommand->opcode;
+ int cmdRet = function_map[opcode].function(currentCommand);
+ if (cmdRet == -2)
+ warning("Unhandled opcode %s (0x%02X) in Scene %d Line %d.",
+ function_map[opcode].name,
+ currentCommand->opcode,
+ Shared.getScene()->getSceneIndex(),
+ currentLine);
-/* 0x00 */ case kReturn0:
- done = true;
- lineIncrement = 0;
- break;
-
-/* 0x01 */ case kSetGameFlag: {
- int flagNum = currentCommand->param1;
- if(flagNum >= 0)
- Shared.setGameFlag(currentCommand->param1);
- }
- break;
-
-/* 0x02 */ case kClearGameFlag: {
- int flagNum = currentCommand->param1;
- if(flagNum >= 0)
- Shared.clearGameFlag(currentCommand->param1);
- }
- break;
-
-/* 0x03 */ case kToogleGameFlag: {
- int flagNum = currentCommand->param1;
- if(flagNum >= 0)
- Shared.toggleGameFlag(currentCommand->param1);
- }
- break;
-/* 0x04 */ case kJumpIfGameFlag: {
- int flagNum = currentCommand->param1;
- if (flagNum) {
- bool doJump = Shared.isGameFlagSet(flagNum);
- if (currentCommand->param2)
- doJump = Shared.isGameFlagNotSet(flagNum);
-
- if (doJump)
- _currentLine = currentCommand->param3;
- }
- }
- break;
-
-/* 0x05 */ case kHideCursor:
- Shared.getScene()->getCursor()->hide();
- _allowInput = false;
- break;
-
-/* 0x06 */ case kShowCursor:
- Shared.getScene()->getCursor()->show();
- _allowInput = true;
- // TODO: clear_flag_01()
- break;
-
-/* 0x07 */ case kPlayAnimation: {
- int barrierId = currentCommand->param1;
- if(currentCommand->param2 == 2) {
- if(!checkBarrierFlags(barrierId)) {
- currentCommand->param2 = 1;
- break;
- }
- lineIncrement = 1;
- } else {
- int barrierIndex = Shared.getScene()->getResources()->getBarrierIndexById(barrierId);
- BarrierItem *barrier = Shared.getScene()->getResources()->getBarrierByIndex(barrierIndex);
-
- if(currentCommand->param4) { // RECHECK THIS
- int newBarriedIndex = 213 * barrierIndex;
- barrier->flags &= 0xFFFEF1C7;
- Shared.getScene()->getResources()->getBarrierByIndex(newBarriedIndex)->flags = barrier->flags | 0x20;
- } else if(currentCommand->param3) {
- barrier->flags &= 0xFFFEF1C7;
- barrier->flags |= 0x10000;
- } else {
- barrier->flags &= 0x10000;
- if(barrier->flags == 0) {
- barrier->flags &= 0x10E38;
- if(barrier->flags == 0) {
- barrier->flags |= 8;
- }
- } else {
- barrier->flags |= 8;
- barrier->flags &= 0xFFFEFFFF;
- }
- }
-
- setBarrierNextFrame(barrierId, barrier->flags);
-
- if(barrier->field_688 == 1) {
- // TODO: get barrier position
- }
-
- if(currentCommand->param2) {
- currentCommand->param2 = 2;
- lineIncrement = 1;
- }
- }
- }
- break;
-
-/* 0x08 */ case kMoveScenePosition: {
- WorldStats *ws = Shared.getScene()->getResources()->getWorldStats();
- Common::Rect *sr = &ws->sceneRects[ws->sceneRectIdx];
-
- if (currentCommand->param3 < 1) {
- ws->xLeft = currentCommand->param1;
- ws->yTop = currentCommand->param2;
- ws->motionStatus = 3;
- } else if (!currentCommand->param4) {
- ws->motionStatus = 5;
- ws->targetX = currentCommand->param1;
- ws->targetY = currentCommand->param2;
- ws->field_A0 = currentCommand->param3;
-
- if (ws->targetX < (uint32)sr->left)
- ws->targetX = sr->left;
- if (ws->targetY < (uint32)sr->top)
- ws->targetY = sr->top;
- if (ws->targetX + 640 > (uint32)sr->right)
- ws->targetX = sr->right - 640;
- if (ws->targetY + 480 > (uint32)sr->bottom)
- ws->targetY = sr->bottom - 480;
-
- // TODO: reverse asm block
-
- } else if (currentCommand->param5) {
- if (ws->motionStatus == 2)
- lineIncrement = 1;
- else
- currentCommand->param5 = 0;
- } else {
- currentCommand->param5 = 1;
- ws->motionStatus = 2;
- ws->targetX = currentCommand->param1;
- ws->targetY = currentCommand->param2;
- ws->field_A0 = currentCommand->param3;
-
- if (ws->targetX + 640 > ws->width)
- ws->targetX = ws->width - 640;
- if (ws->targetX < (uint32)sr->left)
- ws->targetX = sr->left;
- if (ws->targetY < (uint32)sr->top)
- ws->targetY = sr->top;
- if (ws->targetX + 640 > (uint32)sr->right)
- ws->targetX = sr->right - 640;
- if (ws->targetY + 480 > (uint32)sr->bottom)
- ws->targetY = sr->bottom - 480;
-
- // TODO: reverse asm block
- }
- }
- break;
-/* 0x09 */ case kHideActor: {
- uint32 actorIndex = 0;
- if (currentCommand->param1 == -1)
- ;//actorIndex = Shared.getScene()->getWorldStats()->playerActor;
- else
- actorIndex = currentCommand->param1;
-
- if ((actorIndex >= 0) && (actorIndex < Shared.getScene()->getResources()->getWorldStats()->numActors))
- Shared.getScene()->actorVisible(actorIndex, false);
- else
- debugC(kDebugLevelScripts,
- "Requested invalid actor ID:0x%02X in Scene %d Line %d.",
- currentCommand->param1,
- Shared.getScene()->getSceneIndex(),
- _currentLine);
- }
- break;
-
-/* 0x0A */ case kShowActor: {
- uint32 actorIndex = 0;
- if (currentCommand->param1 == -1)
- ;//actorIndex = Shared.getScene()->getWorldStats()->playerActor;
- else
- actorIndex = currentCommand->param1;
-
- if ((actorIndex >= 0) && (actorIndex < Shared.getScene()->getResources()->getWorldStats()->numActors))
- Shared.getScene()->actorVisible(actorIndex, true);
- else
- debugC(kDebugLevelScripts,
- "Requested invalid actor ID:0x%02X in Scene %d Line %d.",
- currentCommand->param1,
- Shared.getScene()->getSceneIndex(),
- _currentLine);
- }
- break;
-
-/* 0x0B */ case kSetActorStats: {
- uint32 actorIndex = 0;
- if (currentCommand->param1 == -1)
- ;//actorIndex = Shared.getScene()->getWorldStats()->playerActor;
- else
- actorIndex = currentCommand->param1;
-
- if ((actorIndex >= 0) && (actorIndex < Shared.getScene()->getResources()->getWorldStats()->numActors)) {
- Shared.getScene()->setActorPosition(actorIndex, currentCommand->param2, currentCommand->param3);
- Shared.getScene()->setActorAction(actorIndex, currentCommand->param4);
- }
- else
- debugC(kDebugLevelScripts,
- "Requested invalid actor ID:0x%02X in Scene %d Script %d Line %d.",
- currentCommand->param1,
- Shared.getScene()->getSceneIndex(),
- _currentLine);
- }
- break;
-
-/* 0x0C */ case kSetSceneMotionStat:
- Shared.getScene()->getResources()->getWorldStats()->motionStatus = currentCommand->param1;
- break;
-/* 0x0D */ case kDisableActor: {
- int actorIndex = 0;
- if (currentCommand->param1 == -1)
- ;//actorIndex = Shared.getScene()->getWorldStats()->playerActor;
- else
- actorIndex = currentCommand->param1;
- Shared.getScene()->getResources()->getMainActor()->disable(actorIndex);
- }
- break;
-/* 0x0E */ case kEnableActor: {
- int actorIndex = 0;
- if (currentCommand->param1 == -1)
- ;//actorIndex = Shared.getScene()->getWorldStats()->playerActor;
- else
- actorIndex = currentCommand->param1;
-
- if (Shared.getScene()->getResources()->getWorldStats()->actors[actorIndex].field_40 == 5) {
- enableActorSub(actorIndex, 4);
- }
- }
- break;
-
-/* 0x0F */ case kEnableBarriers: {
- int barIdx = Shared.getScene()->getResources()->getBarrierIndexById(currentCommand->param1);
- uint32 sndIdx = currentCommand->param3;
- uint32 v59 = currentCommand->param2;
-
- if (!_currentScript->counter && Shared.getScene()->getSceneIndex() != 13 && sndIdx != 0) {
- ResourcePack *sfx = new ResourcePack(18);
- Shared.getSound()->playSfx(sfx, ((unsigned int)(sndIdx != 0) & 5) + 0x80120001);
- delete sfx;
- //Shared.getSound()->playSfx(Shared.getScene()->getSpeechPack(),sndIdx + 86);
- }
+ currentLine += lineIncrement;
+ currentLoops++;
- if (_currentScript->counter >= 3 * v59 - 1) {
- _currentScript->counter = 0;
- Shared.getScene()->getResources()->getWorldStats()->barriers[barIdx].field_67C = 0;
- processActionListSub02(_currentScript, currentCommand, 2);
- _currentLoops = 1; // v4 = 1;
- } else {
- int v64;
- int v62 = _currentScript->counter + 1;
- _currentScript->counter = v62;
- if (sndIdx) {
- v64 = 1;
- int v170 = 3 - v62 / v59;
- Shared.getScene()->getResources()->getWorldStats()->barriers[barIdx].field_67C = v170;
- } else {
- v64 = 0;
- Shared.getScene()->getResources()->getWorldStats()->barriers[barIdx].field_67C = v62 / v59 + 1;
- }
-
- processActionListSub02(_currentScript, currentCommand, v64);
-
- }
- }
- break;
-
-/* 0x10 */ case kReturn:
- done = true;
- lineIncrement = 0;
- break;
-
-/* 0x11 */ case kDestroyBarrier: {
- BarrierItem *barrier = Shared.getScene()->getResources()->getBarrierById(currentCommand->param1);
- if (barrier) {
- barrier->flags &= 0xFFFFFFFE;
- barrier->flags |= 0x20000;
- Shared.getScreen()->deleteGraphicFromQueue(barrier->resId);
- } else
- debugC(kDebugLevelScripts,
- "Requested invalid object ID:0x%02X in Scene %d Line %d.",
- currentCommand->param1,
- Shared.getScene()->getSceneIndex(),
- _currentLine);
- }
- break;
-
-/* 0x12 */ //case k_unk12_JMP_WALK_ACTOR:
-/* 0x13 */ //case k_unk13_JMP_WALK_ACTOR:
-/* 0x14 */ //case k_unk14_JMP_WALK_ACTOR:
-/* 0x15 */ //case k_unk15:
-/* 0x16 */ case kResetAnimation: {
- BarrierItem *barrier = Shared.getScene()->getResources()->getBarrierById(currentCommand->param1);
- if ((barrier->flags & 0x10000) == 0) {
- barrier->frameIdx = 0;
- } else {
- barrier->frameIdx = barrier->frameCount - 1;
- }
- }
- break;
-
-/* 0x17 */ case kClearFlag1Bit0: {
- BarrierItem *barrier = Shared.getScene()->getResources()->getBarrierById(currentCommand->param1);
- barrier->flags &= 0xFFFFFFFE;
- }
- break;
-
-/* 0x18 */ //case k_unk18_PLAY_SND:
-/* 0x19 */ case kJumpIfFlag2Bit0: {
- int targetType = currentCommand->param2;
- if (targetType <= 0)
- done = Shared.getScene()->getResources()->getBarrierById(currentCommand->param1)->flags2 & 1 == 0;
- else
- if (targetType == 1) // v4 == 1, so 1
- done = Shared.getScene()->getResources()->getActionAreaById(currentCommand->param1)->actionType & 1 == 0;
- else
- done = Shared.getScene()->getResources()->getWorldStats()->actors[currentCommand->param1].flags2 & 1 == 0;
- }
- break;
-
-/* 0x1A */ case kSetFlag2Bit0: {
- int targetType = currentCommand->param2;
- if (targetType == 2)
- Shared.getScene()->getResources()->getWorldStats()->actors[currentCommand->param1].flags2 |= 1;
- else
- if (targetType == 1)
- Shared.getScene()->getResources()->getActionAreaById(currentCommand->param1)->actionType |= 1;
- else
- Shared.getScene()->getResources()->getBarrierById(currentCommand->param1)->flags2 |= 1;
- }
- break;
-/* 0x1B */ //case kClearFlag2Bit0:
-/* 0x1C */ //case kJumpIfFlag2Bit2:
-/* 0x1D */ //case kSetFlag2Bit2:
-/* 0x1E */ //case kClearFlag2Bit2:
-/* 0x1F */ //case kJumpIfFlag2Bit1:
-/* 0x20 */ //case kSetFlag2Bit1:
-/* 0x21 */ //case kClearFlag2Bit1:
-/* 0x22 */ //case k_unk22:
-/* 0x23 */ //case k_unk23:
-/* 0x24 */ //case k_unk24:
-/* 0x25 */ //case kRunEncounter:
-/* 0x26 */ //case kJumpIfFlag2Bit4:
-/* 0x27 */ //case kSetFlag2Bit4:
-/* 0x28 */ //case kClearFlag2Bit4:
-/* 0x29 */ //case kSetActorField638:
-/* 0x2A */ //case kJumpIfActorField638:
-/* 0x2B */ case kChangeScene:
- _delayedSceneIndex = currentCommand->param1 + 4;
- debug(kDebugLevelScripts,
- "Queueing Scene Change to scene %d...",
- _delayedSceneIndex);
- break;
-
-/* 0x2C */ //case k_unk2C_ActorSub:
-/* 0x2D */ case kPlayMovie:
- // TODO: add missing code here
- _delayedVideoIndex = currentCommand->param1;
- break;
-
-/* 0x2E */ case kStopAllBarriersSounds:
- // TODO: do this for all barriers that have sfx playing
- Shared.getSound()->stopSfx();
- break;
-
-/* 0x2F */ //case kSetActionFlag01:
-/* 0x30 */ //case kClearActionFlag01:
-/* 0x31 */ //case kResetSceneRect:
-/* 0x32 */ //case kChangeMusicById:
-/* 0x33 */ case kStopMusic:
- Shared.getSound()->stopMusic();
- break;
-
-/* 0x34 */ case k_unk34_Status:
- if (currentCommand->param1 >= 2) {
- currentCommand->param1 = 0;
- } else {
- currentCommand->param1++;
- lineIncrement = 1;
- }
- break;
-/* 0x35 */ //case k_unk35:
-/* 0x36 */ //case k_unk36:
-/* 0x37 */ case kRunBlowUpPuzzle: { // FIXME: improve this to call other blowUpPuzzles than VCR
- int blowUpPuzzleIdx = currentCommand->param1;
- Shared.getScene()->setBlowUpPuzzle(new BlowUpPuzzleVCR());
- Shared.getScene()->getBlowUpPuzzle()->openBlowUp();
- }
- break;
-
-/* 0x38 */ //case kJumpIfFlag2Bit3:
-/* 0x39 */ //case kSetFlag2Bit3:
-/* 0x3A */ //case kClearFlag2Bit3:
-/* 0x3B */ //case k_unk3B_PALETTE_MOD:
-/* 0x3C */ case k_unk3C_CMP_VAL: {
- if (currentCommand->param1) {
- if (currentCommand->param2 >= currentCommand->param1) {
- currentCommand->param2 = 0;
- } else {
- currentCommand->param2++;
- lineIncrement = 1;
- }
- }
- }
- break;
-/* 0x3D */ case kWaitUntilFramePlayed: {
- BarrierItem *barrier = Shared.getScene()->getResources()->getBarrierById(currentCommand->param1);
- if (barrier) {
- uint32 frameNum = 0;
- if (currentCommand->param2 == -1)
- frameNum = barrier->frameCount - 1;
- else
- frameNum = currentCommand->param2;
-
- if (barrier->frameIdx < frameNum) {
- lineIncrement = 0;
- waitCycle = true;
- }
- } else
- debugC(kDebugLevelScripts,
- "Requested invalid object ID:0x%02X in Scene %d Line %d.",
- currentCommand->param1,
- Shared.getScene()->getSceneIndex(),
- _currentLine);
- }
- break;
-
-/* 0x3E */ case kUpdateWideScreen: {
- int barSize = currentCommand->param1;
- if(barSize >= 22) {
- currentCommand->param1 = 0;
- } else {
- Shared.getScreen()->drawWideScreen(4 * barSize);
- currentCommand->param1++;
- }
- }
- break;
-
-/* 0x3F */ //case k_unk3F:
-/* 0x40 */ //case k_unk40_SOUND:
-/* 0x41 */ case kPlaySpeech: {
- // TODO - Add support for other param options
- uint32 sndIdx = currentCommand->param1;
- if ((int)sndIdx >= 0) {
- if (sndIdx >= 259) {
- sndIdx -= 9;
- Shared.getSound()->playSfx(Shared.getScene()->getSpeechPack(), sndIdx - 0x7FFD0000);
- } else {
- Shared.getSound()->playSfx(Shared.getScene()->getSpeechPack(), sndIdx);
- }
-
- } else
- debugC(kDebugLevelScripts,
- "Requested invalid sound ID:0x%02X in Scene %d Line %d.",
- currentCommand->param1,
- Shared.getScene()->getSceneIndex(),
- _currentLine);
- }
- break;
-
-/* 0x42 */ //case k_unk42:
-/* 0x43 */ //case k_unk43:
-/* 0x44 */ //case kPaletteFade:
-/* 0x45 */ //case kStartPaletteFadeThread:
-/* 0x46 */ //case k_unk46:
-/* 0x47 */ //case kActorFaceObject:
-/* 0x48 */ //case k_unk48_MATTE_01:
-/* 0x49 */ //case k_unk49_MATTE_90:
-/* 0x4A */ //case kJumpIfSoundPlaying:
-/* 0x4B */ //case kChangePlayerCharacterIndex:
-/* 0x4C */ case kChangeActorField40: { // TODO: figure out what is this field and what values are set
- int actorIdx = currentCommand->param1;
- int fieldType = currentCommand->param2;
- if(fieldType) {
- if(Shared.getScene()->getResources()->getWorldStats()->actors[actorIdx].field_40 < 11) {
- Shared.getScene()->getResources()->getWorldStats()->actors[actorIdx].field_40 = 14;
- }
- } else {
- Shared.getScene()->getResources()->getWorldStats()->actors[actorIdx].field_40 = 4;
- }
- }
- break;
-/* 0x4D */ //case kStopSound:
-/* 0x4E */ //case k_unk4E_RANDOM_COMMAND:
-/* 0x4F */ case kClearScreen:
- if(currentCommand->param1) {
- Shared.getScreen()->clearScreen();
- }
- break;
-
-/* 0x50 */ //case kQuit:
-/* 0x51 */ case kJumpBarrierFrame: {
- BarrierItem *barrier = Shared.getScene()->getResources()->getBarrierById(currentCommand->param1);
- if (currentCommand->param2 == -1) {
- currentCommand->param2 = barrier->frameCount - 1;
- }
-
- if (currentCommand->param3 && currentCommand->param2 == barrier->frameIdx) {
- break;
- } else if (currentCommand->param4 && currentCommand->param2 < barrier->frameIdx) {
- break;
- } else if (currentCommand->param5 && currentCommand->param2 > barrier->frameIdx) {
- break;
- } else if (currentCommand->param6 && currentCommand->param2 <= barrier->frameIdx) {
- break;
- } else if (currentCommand->param7 && currentCommand->param2 >= barrier->frameIdx) {
- break;
- } else if (currentCommand->param8 && currentCommand->param2 != barrier->frameIdx) {
- break;
- }
-
- ActionCommand *cmd = &_currentScript->commands[currentCommand->param9];
- if (cmd->opcode != kReturn && cmd->opcode) {
- done = true;
- }
- }
- break;
-/* 0x52 */ //case k_unk52:
-/* 0x53 */ //case k_unk53:
-/* 0x54 */ case k_unk54_SET_ACTIONLIST_6EC:
- if (currentCommand->param2) {
- _currentScript->field_1BB0 = rand() % currentCommand->param1;
- } else {
- _currentScript->field_1BB0 = currentCommand->param1;
- }
- break;
-/* 0x55 */ case k_unk55: {
- if (!currentCommand->param2) {
- if (currentCommand->param3 && _currentScript->field_1BB0 < currentCommand->param1)
- break;
- else if (currentCommand->param4 && _currentScript->field_1BB0 > currentCommand->param1)
- break;
- else if (currentCommand->param5 && _currentScript->field_1BB0 <= currentCommand->param1)
- break;
- else if (currentCommand->param6 && _currentScript->field_1BB0 >= currentCommand->param1)
- break;
- else if (currentCommand->param7 && _currentScript->field_1BB0 != currentCommand->param1)
- break;
- } else if(_currentScript->field_1BB0 == currentCommand->param1)
- break;
-
- ActionCommand *cmd = &_currentScript->commands[currentCommand->param8];
- if (cmd->opcode != kReturn && cmd->opcode) {
- done = true;
- } else {
- lineIncrement = currentCommand->param8;
- }
- }
- break;
-/* 0x56 */ //case k_unk56:
-/* 0x57 */ case kSetResourcePalette: {
- if (currentCommand->param1 > 0) {
- Shared.getScreen()->setPalette(Shared.getScene()->getResourcePack(), Shared.getScene()->getResources()->getWorldStats()->grResId[currentCommand->param1]);
- }
- }
- break;
-/* 0x58 */ case kSetBarrierFrameIdxFlaged: {
- BarrierItem *barrier = Shared.getScene()->getResources()->getBarrierById(currentCommand->param1);
- if (currentCommand->param3) {
- barrier->flags = 1 | barrier->flags;
- } else {
- barrier->flags = barrier->flags & 0xFFFFFFFE;
- }
- barrier->frameIdx = currentCommand->param2;
- }
- break;
-/* 0x59 */ //case k_unk59:
-/* 0x5A */ //case k_unk5A:
-/* 0x5B */ //case k_unk5B:
-/* 0x5C */ //case k_unk5C:
-/* 0x5D */ //case k_unk5D:
-/* 0x5E */ //case k_unk5E:
-/* 0x5F */ case kSetBarrierLastFrameIdx: {
- BarrierItem *barrier = Shared.getScene()->getResources()->getBarrierById(currentCommand->param1);
- if (barrier->frameIdx == barrier->frameCount - 1) {
- lineIncrement = 0;
- barrier->flags &= 0xFFFEF1C7;
- } else {
- lineIncrement = 1;
- }
- }
- break;
-/* 0x60 */ //case k_unk60_SET_OR_CLR_ACTIONAREA_FLAG:
-/* 0x61 */ case k_unk61:
- if (currentCommand->param2) {
- if (Shared.getScene()->getResources()->getWorldStats()->field_E860C == -1) {
- lineIncrement = 0;
- currentCommand->param2 = 0;
- } else {
- lineIncrement = 1;
- }
- } else {
- // TODO: do something for scene number 9
- currentCommand->param2 = 1;
- lineIncrement = 1;
- }
- break;
-/* 0x62 */ //case k_unk62_SHOW_OPTIONS_SCREEN:
-/* 0x63 */ //case k_unk61:
-
- default:
- warning("Unhandled opcode 0x%02X in Scene %d Line %d.",
- currentCommand->opcode,
- Shared.getScene()->getSceneIndex(),
- _currentLine);
- break;
-
- } // end switch
-
- _currentLine += lineIncrement;
- _currentLoops++;
-
- } // end while
+ } // end while
if (done) {
- _currentLine = 0;
- _currentLoops = 0;
- _currentScript = 0;
+ currentLine = 0;
+ currentLoops = 0;
+ _currentScript = 0;
Shared.clearGameFlag(183);
}
-
}
- _processing = false;
+ processing = false;
- return 0;
+ return 0;
}
void ScriptManager::processActionListSub02(ActionDefinitions* script, ActionCommand *command, int a4) {
@@ -781,10 +297,10 @@ void ScriptManager::processActionListSub02(ActionDefinitions* script, ActionComm
int v13 = command->param4;
int v4 = script->counter / command->param2 + 4;
for (int i = 7; i > 0; i--) {
- barrierIdx = Shared.getScene()->getResources()->getBarrierIndexById(v13);
- if (barrierIdx >= 0)
- Shared.getScene()->getResources()->getWorldStats()->barriers[barrierIdx].field_67C = v4;
- v13 += 4;
+ barrierIdx = Shared.getScene()->getResources()->getBarrierIndexById(v13);
+ if (barrierIdx >= 0)
+ Shared.getScene()->getResources()->getWorldStats()->barriers[barrierIdx].field_67C = v4;
+ v13 += 4;
}
// TODO
switch (Shared.getScene()->getSceneIndex()) {
@@ -804,18 +320,837 @@ void ScriptManager::processActionListSub02(ActionDefinitions* script, ActionComm
warning("Scene 4 / v4 = 0 Not Implemented");
break;
default:
- return;
+ return;
}
}
-
}
void ScriptManager::enableActorSub(int actorIndex, int condition) {
}
-ScriptManager::~ScriptManager() {
- // TODO Auto-generated destructor stub
+/* Opcode Functions */
+
+int kReturn0(ActionCommand *cmd) {
+ ScriptMan.done = true;
+ ScriptMan.lineIncrement = 0;
+ return 0;
+}
+
+int kSetGameFlag(ActionCommand *cmd) {
+ int flagNum = cmd->param1;
+
+ if (flagNum >= 0)
+ Shared.setGameFlag(flagNum);
+
+ return 0;
+}
+
+int kClearGameFlag(ActionCommand *cmd) {
+ int flagNum = cmd->param1;
+
+ if (flagNum >= 0)
+ Shared.clearGameFlag(flagNum);
+
+ return 0;
+}
+
+int kToggleGameFlag(ActionCommand *cmd) {
+ int flagNum = cmd->param1;
+
+ if (flagNum >= 0)
+ Shared.toggleGameFlag(flagNum);
+
+ return 0;
+}
+
+int kJumpIfGameFlag(ActionCommand *cmd) {
+ int flagNum = cmd->param1;
+
+ if (flagNum) {
+ bool doJump = Shared.isGameFlagSet(flagNum);
+ if (cmd->param2)
+ doJump = Shared.isGameFlagNotSet(flagNum);
+ if (doJump)
+ ScriptMan.currentLine = cmd->param3;
+ }
+
+ return 0;
+}
+
+int kHideCursor(ActionCommand *cmd) {
+ Shared.getScene()->getCursor()->hide();
+ ScriptMan.allowInput = false;
+
+ return 0;
+}
+
+int kShowCursor(ActionCommand *cmd) {
+ Shared.getScene()->getCursor()->show();
+ ScriptMan.allowInput = true;
+
+ // TODO clear_flag_01()
+ return 0;
+}
+
+int kPlayAnimation(ActionCommand *cmd) {
+ int barrierId = cmd->param1;
+
+ if (cmd->param2 == 2) {
+ if (!ScriptMan.checkBarrierFlags(barrierId)) {
+ cmd->param2 = 1;
+ // FIXME Not sure why this break was here
+ // break;
+ }
+ ScriptMan.lineIncrement = 1;
+ } else {
+ int barrierIndex = Shared.getScene()->getResources()->getBarrierIndexById(barrierId);
+ BarrierItem *barrier = Shared.getScene()->getResources()->getBarrierByIndex(barrierIndex);
+
+ if (cmd->param4) { // RECHECK THIS
+ int newBarriedIndex = 213 * barrierIndex;
+ barrier->flags &= 0xFFFEF1C7;
+ Shared.getScene()->getResources()->getBarrierByIndex(newBarriedIndex)->flags = barrier->flags | 0x20;
+ } else if (cmd->param3) {
+ barrier->flags &= 0xFFFEF1C7;
+ barrier->flags |= 0x10000;
+ } else {
+ barrier->flags &= 0x10000;
+ if(barrier->flags == 0) {
+ barrier->flags &= 0x10E38;
+ if(barrier->flags == 0) {
+ barrier->flags |= 8;
+ }
+ } else {
+ barrier->flags |= 8;
+ barrier->flags &= 0xFFFEFFFF;
+ }
+ }
+
+ ScriptMan.setBarrierNextFrame(barrierId, barrier->flags);
+
+ if(barrier->field_688 == 1) {
+ // TODO: get barrier position
+ }
+
+ if(cmd->param2) {
+ cmd->param2 = 2;
+ ScriptMan.lineIncrement = 1;
+ }
+ }
+
+ return 0;
+}
+
+int kMoveScenePosition(ActionCommand *cmd) {
+ WorldStats *ws = Shared.getScene()->getResources()->getWorldStats();
+ Common::Rect *sr = &ws->sceneRects[ws->sceneRectIdx];
+
+ if (cmd->param3 < 1) {
+ ws->xLeft = cmd->param1;
+ ws->yTop = cmd->param2;
+ ws->motionStatus = 3;
+ } else if (!cmd->param4) {
+ ws->motionStatus = 5;
+ ws->targetX = cmd->param1;
+ ws->targetY = cmd->param2;
+ ws->field_A0 = cmd->param3;
+
+ if (ws->targetX < (uint32)sr->left)
+ ws->targetX = sr->left;
+ if (ws->targetY < (uint32)sr->top)
+ ws->targetY = sr->top;
+ if (ws->targetX + 640 > (uint32)sr->right)
+ ws->targetX = sr->right - 640;
+ if (ws->targetY + 480 > (uint32)sr->bottom)
+ ws->targetY = sr->bottom - 480;
+
+ // TODO: reverse asm block
+
+ } else if (cmd->param5) {
+ if (ws->motionStatus == 2)
+ ScriptMan.lineIncrement = 1;
+ else
+ cmd->param5 = 0;
+ } else {
+ cmd->param5 = 1;
+ ws->motionStatus = 2;
+ ws->targetX = cmd->param1;
+ ws->targetY = cmd->param2;
+ ws->field_A0 = cmd->param3;
+
+ if (ws->targetX + 640 > ws->width)
+ ws->targetX = ws->width - 640;
+ if (ws->targetX < (uint32)sr->left)
+ ws->targetX = sr->left;
+ if (ws->targetY < (uint32)sr->top)
+ ws->targetY = sr->top;
+ if (ws->targetX + 640 > (uint32)sr->right)
+ ws->targetX = sr->right - 640;
+ if (ws->targetY + 480 > (uint32)sr->bottom)
+ ws->targetY = sr->bottom - 480;
+
+ // TODO: reverse asm block
+ }
+
+ return 0;
+}
+
+int kHideActor(ActionCommand *cmd) {
+ uint32 actorIndex = 0;
+
+ if (cmd->param1 == -1)
+ ;//actorIndex = Shared.getScene()->getWorldStats()->playerActor;
+ else
+ actorIndex = cmd->param1;
+
+ if ((actorIndex >= 0) && (actorIndex < Shared.getScene()->getResources()->getWorldStats()->numActors))
+ Shared.getScene()->actorVisible(actorIndex, false);
+ else
+ debugC(kDebugLevelScripts,
+ "Requested invalid actor ID:0x%02X in Scene %d Line %d.",
+ cmd->param1,
+ Shared.getScene()->getSceneIndex(),
+ ScriptMan.currentLine);
+
+ return 0;
+}
+
+int kShowActor(ActionCommand *cmd) {
+ uint32 actorIndex = 0;
+
+ if (cmd->param1 == -1)
+ ;//actorIndex = Shared.getScene()->getWorldStats()->playerActor;
+ else
+ actorIndex = cmd->param1;
+
+ if ((actorIndex >= 0) && (actorIndex < Shared.getScene()->getResources()->getWorldStats()->numActors))
+ Shared.getScene()->actorVisible(actorIndex, true);
+ else
+ debugC(kDebugLevelScripts,
+ "Requested invalid actor ID:0x%02X in Scene %d Line %d.",
+ cmd->param1,
+ Shared.getScene()->getSceneIndex(),
+ ScriptMan.currentLine);
+}
+
+int kSetActorStats(ActionCommand *cmd) {
+ uint32 actorIndex = 0;
+
+ if (cmd->param1 == -1)
+ ;//actorIndex = Shared.getScene()->getWorldStats()->playerActor;
+ else
+ actorIndex = cmd->param1;
+
+ if ((actorIndex >= 0) && (actorIndex < Shared.getScene()->getResources()->getWorldStats()->numActors)) {
+ Shared.getScene()->setActorPosition(actorIndex, cmd->param2, cmd->param3);
+ Shared.getScene()->setActorAction(actorIndex, cmd->param4);
+ } else
+ debugC(kDebugLevelScripts,
+ "Requested invalid actor ID:0x%02X in Scene %d Script %d Line %d.",
+ cmd->param1,
+ Shared.getScene()->getSceneIndex(),
+ ScriptMan.currentLine);
+
+ return 0;
+}
+
+int kSetSceneMotionStat(ActionCommand *cmd) {
+ Shared.getScene()->getResources()->getWorldStats()->motionStatus = cmd->param1;
+
+ return 0;
+}
+
+int kDisableActor(ActionCommand *cmd) {
+ int actorIndex = 0;
+
+ if (cmd->param1 == -1)
+ ;//actorIndex = Shared.getScene()->getWorldStats()->playerActor;
+ else
+ actorIndex = cmd->param1;
+
+ Shared.getScene()->getResources()->getMainActor()->disable(actorIndex);
+
+ return 0;
+}
+
+int kEnableActor(ActionCommand *cmd) {
+ int actorIndex = 0;
+
+ if (cmd->param1 == -1)
+ ;//actorIndex = Shared.getScene()->getWorldStats()->playerActor;
+ else
+ actorIndex = cmd->param1;
+
+ if (Shared.getScene()->getResources()->getWorldStats()->actors[actorIndex].field_40 == 5)
+ ScriptMan.enableActorSub(actorIndex, 4);
+
+ return 0;
+}
+
+int kEnableBarriers(ActionCommand *cmd) {
+ int barIdx = Shared.getScene()->getResources()->getBarrierIndexById(cmd->param1);
+ uint32 sndIdx = cmd->param3;
+ uint32 v59 = cmd->param2;
+
+ if (!ScriptMan.getScript()->counter && Shared.getScene()->getSceneIndex() != 13 && sndIdx != 0) {
+ ResourcePack *sfx = new ResourcePack(18);
+ Shared.getSound()->playSfx(sfx, ((unsigned int)(sndIdx != 0) & 5) + 0x80120001);
+ delete sfx;
+ //Shared.getSound()->playSfx(Shared.getScene()->getSpeechPack(),sndIdx + 86);
+ }
+
+ if (ScriptMan.getScript()->counter >= 3 * v59 - 1) {
+ ScriptMan.getScript()->counter = 0;
+ Shared.getScene()->getResources()->getWorldStats()->barriers[barIdx].field_67C = 0;
+ ScriptMan.processActionListSub02(ScriptMan.getScript(), cmd, 2);
+ ScriptMan.currentLoops = 1; // v4 = 1;
+ } else {
+ int v64;
+ int v62 = ScriptMan.getScript()->counter + 1;
+ ScriptMan.getScript()->counter = v62;
+ if (sndIdx) {
+ v64 = 1;
+ int v170 = 3 - v62 / v59;
+ Shared.getScene()->getResources()->getWorldStats()->barriers[barIdx].field_67C = v170;
+ } else {
+ v64 = 0;
+ Shared.getScene()->getResources()->getWorldStats()->barriers[barIdx].field_67C = v62 / v59 + 1;
+ }
+
+ ScriptMan.processActionListSub02(ScriptMan.getScript(), cmd, v64);
+ }
+
+ return 0;
+}
+
+int kReturn(ActionCommand *cmd) {
+ ScriptMan.done = true;
+ ScriptMan.lineIncrement = 0;
+
+ return 0;
+}
+
+int kDestroyBarrier(ActionCommand *cmd) {
+ BarrierItem *barrier = Shared.getScene()->getResources()->getBarrierById(cmd->param1);
+
+ if (barrier) {
+ barrier->flags &= 0xFFFFFFFE;
+ barrier->flags |= 0x20000;
+ Shared.getScreen()->deleteGraphicFromQueue(barrier->resId);
+ } else
+ debugC(kDebugLevelScripts,
+ "Requested invalid object ID:0x%02X in Scene %d Line %d.",
+ cmd->param1,
+ Shared.getScene()->getSceneIndex(),
+ ScriptMan.currentLine);
+
+ return 0;
+}
+
+int k_unk12_JMP_WALK_ACTOR(ActionCommand *cmd) {
+ return -2;
+}
+int k_unk13_JMP_WALK_ACTOR(ActionCommand *cmd) {
+ return -2;
+}
+int k_unk14_JMP_WALK_ACTOR(ActionCommand *cmd) {
+ return -2;
+}
+int k_unk15(ActionCommand *cmd) {
+ return -2;
+}
+
+int kResetAnimation(ActionCommand *cmd) {
+ BarrierItem *barrier = Shared.getScene()->getResources()->getBarrierById(cmd->param1);
+
+ if ((barrier->flags & 0x10000) == 0)
+ barrier->frameIdx = 0;
+ else
+ barrier->frameIdx = barrier->frameCount - 1;
+
+ return 0;
+}
+
+int kClearFlag1Bit0(ActionCommand *cmd) {
+ BarrierItem *barrier = Shared.getScene()->getResources()->getBarrierById(cmd->param1);
+
+ barrier->flags &= 0xFFFFFFFE;
+
+ return 0;
+}
+
+int k_unk18_PLAY_SND(ActionCommand *cmd) {
+ return -2;
+}
+
+int kJumpIfFlag2Bit0(ActionCommand *cmd) {
+ int targetType = cmd->param2;
+
+ return 0;
+
+ // TODO targetType == 7 is trying to access an out of bounds actor
+ // look at the disassembly again
+
+ if (targetType <= 0)
+ ScriptMan.done = (Shared.getScene()->getResources()->getBarrierById(cmd->param1)->flags2 & 1) == 0;
+ else
+ if (targetType == 1) // v4 == 1, so 1
+ ScriptMan.done = (Shared.getScene()->getResources()->getActionAreaById(cmd->param1)->actionType & 1) == 0;
+ else
+ ScriptMan.done = (Shared.getScene()->getResources()->getWorldStats()->actors[cmd->param1].flags2 & 1) == 0;
+
+ return 0;
+}
+
+int kSetFlag2Bit0(ActionCommand *cmd) {
+ int targetType = cmd->param2;
+
+ if (targetType == 2)
+ Shared.getScene()->getResources()->getWorldStats()->actors[cmd->param1].flags2 |= 1;
+ else
+ if (targetType == 1)
+ Shared.getScene()->getResources()->getActionAreaById(cmd->param1)->actionType |= 1;
+ else
+ Shared.getScene()->getResources()->getBarrierById(cmd->param1)->flags2 |= 1;
+
+ return 0;
+}
+
+int kClearFlag2Bit0(ActionCommand *cmd) {
+ return -2;
+}
+int kJumpIfFlag2Bit2(ActionCommand *cmd) {
+ return -2;
+}
+int kSetFlag2Bit2(ActionCommand *cmd) {
+ return -2;
+}
+int kClearFlag2Bit2(ActionCommand *cmd) {
+ return -2;
+}
+int kJumpIfFlag2Bit1(ActionCommand *cmd) {
+ return -2;
+}
+int kSetFlag2Bit1(ActionCommand *cmd) {
+ return -2;
+}
+int kClearFlag2Bit1(ActionCommand *cmd) {
+ return -2;
+}
+int k_unk22(ActionCommand *cmd) {
+ return -2;
+}
+int k_unk23(ActionCommand *cmd) {
+ return -2;
+}
+int k_unk24(ActionCommand *cmd) {
+ return -2;
+}
+int kRunEncounter(ActionCommand *cmd) {
+ return -2;
+}
+int kJumpIfFlag2Bit4(ActionCommand *cmd) {
+ return -2;
+}
+int kSetFlag2Bit4(ActionCommand *cmd) {
+ return -2;
+}
+int kClearFlag2Bit4(ActionCommand *cmd) {
+ return -2;
+}
+int kSetActorField638(ActionCommand *cmd) {
+ return -2;
+}
+int kJumpIfActorField638(ActionCommand *cmd) {
+ return -2;
+}
+
+int kChangeScene(ActionCommand *cmd) {
+ ScriptMan.delayedSceneIndex = cmd->param1 + 4;
+ debug(kDebugLevelScripts,
+ "Queueing Scene Change to scene %d...",
+ ScriptMan.delayedSceneIndex);
+
+ return 0;
+}
+
+int k_unk2C_ActorSub(ActionCommand *cmd) {
+ return -2;
+}
+
+int kPlayMovie(ActionCommand *cmd) {
+ // TODO: add missing code here
+ ScriptMan.delayedVideoIndex = cmd->param1;
+
+ return 0;
+}
+
+int kStopAllBarriersSounds(ActionCommand *cmd) {
+ // TODO: do this for all barriers that have sfx playing
+ Shared.getSound()->stopSfx();
+
+ return 0;
+}
+
+int kSetActionFlag01(ActionCommand *cmd) {
+ return -2;
+}
+int kClearActionFlag01(ActionCommand *cmd) {
+ return -2;
+}
+int kResetSceneRect(ActionCommand *cmd) {
+ return -2;
+}
+int kChangeMusicById(ActionCommand *cmd) {
+ return -2;
+}
+
+int kStopMusic(ActionCommand *cmd) {
+ Shared.getSound()->stopMusic();
+
+ return 0;
+}
+
+int k_unk34_Status(ActionCommand *cmd) {
+ if (cmd->param1 >= 2) {
+ cmd->param1 = 0;
+ } else {
+ cmd->param1++;
+ ScriptMan.lineIncrement = 1;
+ }
+
+ return 0;
+}
+
+int k_unk35(ActionCommand *cmd) {
+ return -2;
+}
+int k_unk36(ActionCommand *cmd) {
+ return -2;
+}
+
+int kRunBlowUpPuzzle(ActionCommand *cmd) {
+ // FIXME: improve this to call other blowUpPuzzles than VCR
+ //int puzzleIdx = cmd->param1;
+
+ Shared.getScene()->setBlowUpPuzzle(new BlowUpPuzzleVCR());
+ Shared.getScene()->getBlowUpPuzzle()->openBlowUp();
+
+ return 0;
+}
+
+int kJumpIfFlag2Bit3(ActionCommand *cmd) {
+ return -2;
+}
+int kSetFlag2Bit3(ActionCommand *cmd) {
+ return -2;
+}
+int kClearFlag2Bit3(ActionCommand *cmd) {
+ return -2;
+}
+int k_unk3B_PALETTE_MOD(ActionCommand *cmd) {
+ return -2;
+}
+
+int k_unk3C_CMP_VAL(ActionCommand *cmd) {
+ if (cmd->param1) {
+ if (cmd->param2 >= cmd->param1) {
+ cmd->param2 = 0;
+ } else {
+ cmd->param2++;
+ ScriptMan.lineIncrement = 1;
+ }
+ }
+
+ return 0;
+}
+
+int kWaitUntilFramePlayed(ActionCommand *cmd) {
+ BarrierItem *barrier = Shared.getScene()->getResources()->getBarrierById(cmd->param1);
+
+ if (barrier) {
+ uint32 frameNum = 0;
+ if (cmd->param2 == -1)
+ frameNum = barrier->frameCount - 1;
+ else
+ frameNum = cmd->param2;
+
+ if (barrier->frameIdx < frameNum) {
+ ScriptMan.lineIncrement = 0;
+ ScriptMan.waitCycle = true;
+ }
+ } else
+ debugC(kDebugLevelScripts,
+ "Requested invalid object ID:0x%02X in Scene %d Line %d.",
+ cmd->param1,
+ Shared.getScene()->getSceneIndex(),
+ ScriptMan.currentLine);
+
+ return 0;
+}
+
+int kUpdateWideScreen(ActionCommand *cmd) {
+ int barSize = cmd->param1;
+
+ if (barSize >= 22) {
+ cmd->param1 = 0;
+ } else {
+ Shared.getScreen()->drawWideScreen(4 * barSize);
+ cmd->param1++;
+ }
+
+ return 0;
+}
+
+int k_unk3F(ActionCommand *cmd) {
+ return -2;
+}
+int k_unk40_SOUND(ActionCommand *cmd) {
+ return -2;
+}
+
+int kPlaySpeech(ActionCommand *cmd) {
+ //TODO - Add support for other param options
+ uint32 sndIdx = cmd->param1;
+
+ if ((int)sndIdx >= 0) {
+ if (sndIdx >= 259) {
+ sndIdx -= 9;
+ Shared.getSound()->playSfx(Shared.getScene()->getSpeechPack(), sndIdx - 0x7FFD0000);
+ } else {
+ Shared.getSound()->playSfx(Shared.getScene()->getSpeechPack(), sndIdx);
+ }
+ } else
+ debugC(kDebugLevelScripts,
+ "Requested invalid sound ID:0x%02X in Scene %d Line %d.",
+ cmd->param1,
+ Shared.getScene()->getSceneIndex(),
+ ScriptMan.currentLine);
+
+ return 0;
+}
+
+int k_unk42(ActionCommand *cmd) {
+ return -2;
+}
+int k_unk43(ActionCommand *cmd) {
+ return -2;
+}
+int kPaletteFade(ActionCommand *cmd) {
+ return -2;
+}
+int kStartPaletteFadeThread(ActionCommand *cmd) {
+ return -2;
+}
+int k_unk46(ActionCommand *cmd) {
+ return -2;
+}
+int kActorFaceObject(ActionCommand *cmd) {
+ return -2;
+}
+int k_unk48_MATTE_01(ActionCommand *cmd) {
+ return -2;
+}
+int k_unk49_MATTE_90(ActionCommand *cmd) {
+ return -2;
+}
+int kJumpIfSoundPlaying(ActionCommand *cmd) {
+ return -2;
+}
+int kChangePlayerCharacterIndex(ActionCommand *cmd) {
+ return -2;
+}
+
+int kChangeActorField40(ActionCommand *cmd) {
+ // TODO: figure out what is this field and what values are set
+ int actorIdx = cmd->param1;
+ int fieldType = cmd->param2;
+
+ if (fieldType) {
+ if (Shared.getScene()->getResources()->getWorldStats()->actors[actorIdx].field_40 < 11)
+ Shared.getScene()->getResources()->getWorldStats()->actors[actorIdx].field_40 = 14;
+ } else {
+ Shared.getScene()->getResources()->getWorldStats()->actors[actorIdx].field_40 = 4;
+ }
+
+ return 0;
+}
+
+int kStopSound(ActionCommand *cmd) {
+ return -2;
+}
+int k_unk4E_RANDOM_COMMAND(ActionCommand *cmd) {
+ return -2;
+}
+
+int kClearScreen(ActionCommand *cmd) {
+ if (cmd->param1)
+ Shared.getScreen()->clearScreen();
+
+ return 0;
+}
+
+int kQuit(ActionCommand *cmd) {
+ return -2;
+}
+
+int kJumpBarrierFrame(ActionCommand *cmd) {
+ BarrierItem *barrier = Shared.getScene()->getResources()->getBarrierById(cmd->param1);
+
+ if (cmd->param2 == -1)
+ cmd->param2 = barrier->frameCount - 1;
+
+ if (cmd->param3 && cmd->param2 == barrier->frameIdx) {
+ //break;
+ } else if (cmd->param4 && cmd->param2 < barrier->frameIdx) {
+ //break;
+ } else if (cmd->param5 && cmd->param2 > barrier->frameIdx) {
+ //break;
+ } else if (cmd->param6 && cmd->param2 <= barrier->frameIdx) {
+ //break;
+ } else if (cmd->param7 && cmd->param2 >= barrier->frameIdx) {
+ //break;
+ } else if (cmd->param8 && cmd->param2 != barrier->frameIdx) {
+ //break;
+ }
+
+ ActionCommand *nextCmd = &ScriptMan.getScript()->commands[cmd->param9];
+
+ // 0x10 == kReturn
+ if (nextCmd->opcode != 0x10 && nextCmd->opcode)
+ ScriptMan.done = true;
+
+ return 0;
+}
+
+int k_unk52(ActionCommand *cmd) {
+ return -2;
+}
+int k_unk53(ActionCommand *cmd) {
+ return -2;
+}
+
+int k_unk54_SET_ACTIONLIST_6EC(ActionCommand *cmd) {
+ if (cmd->param2)
+ ScriptMan.getScript()->field_1BB0 = rand() % cmd->param1;
+ else
+ ScriptMan.getScript()->field_1BB0 = cmd->param1;
+
+ return 0;
+}
+
+int k_unk55(ActionCommand *cmd) {
+ // TODO
+ /*
+ if (!cmd->param2) {
+ if (cmd->param3 && ScriptMan.getScript()->field_1BB0 < cmd->param1)
+ //break;
+ else if (cmd->param4 && ScriptMan.getScript()->field_1BB0 > cmd->param1)
+ //break;
+ else if (cmd->param5 && ScriptMan.getScript()->field_1BB0 <= cmd->param1)
+ //break;
+ else if (cmd->param6 && ScriptMan.getScript()->field_1BB0 >= cmd->param1)
+ //break;
+ else if (cmd->param7 && ScriptMan.getScript()->field_1BB0 != cmd->param1)
+ //break;
+ } else if(ScriptMan.getScript()->field_1BB0 == cmd->param1) {
+ //break;
+ }
+ */
+
+ ActionCommand *nextCmd = &ScriptMan.getScript()->commands[cmd->param8];
+
+ if (nextCmd->opcode != 0x10 && nextCmd->opcode)
+ ScriptMan.done = true;
+ else
+ ScriptMan.lineIncrement = cmd->param8;
+
+ return 0;
+}
+
+int k_unk56(ActionCommand *cmd) {
+ return -2;
+}
+
+int kSetResourcePalette(ActionCommand *cmd) {
+ if (cmd->param1 > 0)
+ Shared.getScreen()->setPalette(Shared.getScene()->getResourcePack(), Shared.getScene()->getResources()->getWorldStats()->grResId[cmd->param1]);
+
+ return 0;
+}
+
+int kSetBarrierFrameIdxFlaged(ActionCommand *cmd) {
+ BarrierItem *barrier = Shared.getScene()->getResources()->getBarrierById(cmd->param1);
+
+ if (cmd->param3)
+ barrier->flags = 1 | barrier->flags;
+ else
+ barrier->flags = barrier->flags & 0xFFFFFFFE;
+
+ barrier->frameIdx = cmd->param2;
+
+ return 0;
+}
+
+int k_unk59(ActionCommand *cmd) {
+
+}
+int k_unk5A(ActionCommand *cmd) {
+ return -2;
+}
+int k_unk5B(ActionCommand *cmd) {
+ return -2;
+}
+int k_unk5C(ActionCommand *cmd) {
+ return -2;
+}
+int k_unk5D(ActionCommand *cmd) {
+ return -2;
+}
+int k_unk5E(ActionCommand *cmd) {
+ return -2;
+}
+
+int kSetBarrierLastFrameIdx(ActionCommand *cmd) {
+ BarrierItem *barrier = Shared.getScene()->getResources()->getBarrierById(cmd->param1);
+
+ if (barrier->frameIdx == barrier->frameCount - 1) {
+ ScriptMan.lineIncrement = 0;
+ barrier->flags &= 0xFFFEF1C7;
+ } else {
+ ScriptMan.lineIncrement = 1;
+ }
+
+ return 0;
+}
+
+int k_unk60_SET_OR_CLR_ACTIONAREA_FLAG(ActionCommand *cmd) {
+ return -2;
+}
+
+int k_unk61(ActionCommand *cmd) {
+ if (cmd->param2) {
+ if (Shared.getScene()->getResources()->getWorldStats()->field_E860C == -1) {
+ ScriptMan.lineIncrement = 0;
+ cmd->param2 = 0;
+ } else {
+ ScriptMan.lineIncrement = 1;
+ }
+ } else {
+ // TODO: do something for scene number 9
+ cmd->param2 = 1;
+ ScriptMan.lineIncrement = 1;
+ }
+
+ return 0;
+}
+
+int k_unk62_SHOW_OPTIONS_SCREEN(ActionCommand *cmd) {
+ return -2;
+}
+int k_unk63(ActionCommand *cmd) {
+ return -2;
}
} // end of namespace Asylum
diff --git a/engines/asylum/scriptman.h b/engines/asylum/scriptman.h
index dff8367e5c..9ff384f534 100644
--- a/engines/asylum/scriptman.h
+++ b/engines/asylum/scriptman.h
@@ -41,143 +41,141 @@ public:
void setScript(ActionDefinitions *action);
void setScriptIndex(uint32 index);
+ ActionDefinitions* getScript() { return _currentScript; }
- void setDelayedSceneIndex(int index) { _delayedSceneIndex = index; }
- int getDelayedSceneIndex() { return _delayedSceneIndex; }
-
- void setDelayedVideoIndex(int index) { _delayedVideoIndex = index; }
- int getDelayedVideoIndex() { return _delayedVideoIndex; }
-
- bool isInputAllowed() { return _allowInput; }
- bool isProcessing() { return _processing; }
-
int checkBarrierFlags(int barrierId);
int setBarrierNextFrame(int barrierId, int barrierFlags);
+ void processActionListSub02(ActionDefinitions* script, ActionCommand* command, int a4);
+ void enableActorSub(int actorIndex, int condition);
+
+ // FIXME
+ // Made all the internal control variables public and removed the getter/setter
+ // pairs for simplicity. This should be refactored later, once the function mapping
+ // is cleaned up properly
+ int currentLine;
+ int currentLoops;
+ int delayedSceneIndex;
+ int delayedVideoIndex;
+ bool allowInput;
+ bool processing;
+ int lineIncrement;
+ bool done;
+ bool waitCycle;
+
private:
friend class Common::Singleton<SingletonBaseType>;
ScriptManager();
~ScriptManager();
- int _currentLine;
- int _currentLoops;
- bool _processing;
- int _delayedSceneIndex;
- int _delayedVideoIndex;
- bool _allowInput;
-
ActionDefinitions *_currentScript;
- void processActionListSub02(ActionDefinitions* script, ActionCommand* command, int a4);
- void enableActorSub(int actorIndex, int condition);
-
friend class Console;
-
}; // end of class ScriptManager
-enum opcodes {
- kReturn0 = 0x00,
- kSetGameFlag,
- kClearGameFlag,
- kToogleGameFlag,
- kJumpIfGameFlag,
- kHideCursor,
- kShowCursor,
- kPlayAnimation,
- kMoveScenePosition,
- kHideActor,
- kShowActor,
- kSetActorStats,
- kSetSceneMotionStat,
- kDisableActor,
- kEnableActor,
- kEnableBarriers,
- kReturn, // 0x10
- kDestroyBarrier,
- k_unk12_JMP_WALK_ACTOR,
- k_unk13_JMP_WALK_ACTOR,
- k_unk14_JMP_WALK_ACTOR,
- k_unk15,
- kResetAnimation,
- kClearFlag1Bit0,
- k_unk18_PLAY_SND,
- kJumpIfFlag2Bit0,
- kSetFlag2Bit0,
- kClearFlag2Bit0,
- kJumpIfFlag2Bit2,
- kSetFlag2Bit2,
- kClearFlag2Bit2,
- kJumpIfFlag2Bit1,
- kSetFlag2Bit1, // 0x20
- kClearFlag2Bit1,
- k_unk22,
- k_unk23,
- k_unk24,
- kRunEncounter,
- kJumpIfFlag2Bit4,
- kSetFlag2Bit4,
- kClearFlag2Bit4,
- kSetActorField638,
- kJumpIfActorField638,
- kChangeScene,
- k_unk2C_ActorSub,
- kPlayMovie,
- kStopAllBarriersSounds,
- kSetActionFlag01,
- kClearActionFlag01, // 0x30
- kResetSceneRect,
- kChangeMusicById,
- kStopMusic,
- k_unk34_Status,
- k_unk35,
- k_unk36,
- kRunBlowUpPuzzle,
- kJumpIfFlag2Bit3,
- kSetFlag2Bit3,
- kClearFlag2Bit3,
- k_unk3B_PALETTE_MOD,
- k_unk3C_CMP_VAL,
- kWaitUntilFramePlayed,
- kUpdateWideScreen,
- k_unk3F,
- k_unk40_SOUND, // 0x40
- kPlaySpeech,
- k_unk42,
- k_unk43,
- kPaletteFade,
- kStartPaletteFadeThread,
- k_unk46,
- kActorFaceObject,
- k_unk48_MATTE_01,
- k_unk49_MATTE_90,
- kJumpIfSoundPlaying,
- kChangePlayerCharacterIndex,
- kChangeActorField40,
- kStopSound,
- k_unk4E_RANDOM_COMMAND,
- kClearScreen,
- kQuit, // 0x50
- kJumpBarrierFrame,
- k_unk52,
- k_unk53,
- k_unk54_SET_ACTIONLIST_6EC,
- k_unk55,
- k_unk56,
- kSetResourcePalette,
- kSetBarrierFrameIdxFlaged,
- k_unk59,
- k_unk5A,
- k_unk5B,
- k_unk5C,
- k_unk5D,
- k_unk5E,
- kSetBarrierLastFrameIdx,
- k_unk60_SET_OR_CLR_ACTIONAREA_FLAG, // 0x60
- k_unk61,
- k_unk62_SHOW_OPTIONS_SCREEN,
- k_unk63
-};
+// opcode functions
+int kReturn0(ActionCommand *cmd);
+int kSetGameFlag(ActionCommand *cmd);
+int kClearGameFlag(ActionCommand *cmd);
+int kToggleGameFlag(ActionCommand *cmd);
+int kJumpIfGameFlag(ActionCommand *cmd);
+int kHideCursor(ActionCommand *cmd);
+int kShowCursor(ActionCommand *cmd);
+int kPlayAnimation(ActionCommand *cmd);
+int kMoveScenePosition(ActionCommand *cmd);
+int kHideActor(ActionCommand *cmd);
+int kShowActor(ActionCommand *cmd);
+int kSetActorStats(ActionCommand *cmd);
+int kSetSceneMotionStat(ActionCommand *cmd);
+int kDisableActor(ActionCommand *cmd);
+int kEnableActor(ActionCommand *cmd);
+int kEnableBarriers(ActionCommand *cmd);
+int kReturn(ActionCommand *cmd);
+int kDestroyBarrier(ActionCommand *cmd);
+int k_unk12_JMP_WALK_ACTOR(ActionCommand *cmd);
+int k_unk13_JMP_WALK_ACTOR(ActionCommand *cmd);
+int k_unk14_JMP_WALK_ACTOR(ActionCommand *cmd);
+int k_unk15(ActionCommand *cmd);
+int kResetAnimation(ActionCommand *cmd);
+int kClearFlag1Bit0(ActionCommand *cmd);
+int k_unk18_PLAY_SND(ActionCommand *cmd);
+int kJumpIfFlag2Bit0(ActionCommand *cmd);
+int kSetFlag2Bit0(ActionCommand *cmd);
+int kClearFlag2Bit0(ActionCommand *cmd);
+int kJumpIfFlag2Bit2(ActionCommand *cmd);
+int kSetFlag2Bit2(ActionCommand *cmd);
+int kClearFlag2Bit2(ActionCommand *cmd);
+int kJumpIfFlag2Bit1(ActionCommand *cmd);
+int kSetFlag2Bit1(ActionCommand *cmd);
+int kClearFlag2Bit1(ActionCommand *cmd);
+int k_unk22(ActionCommand *cmd);
+int k_unk23(ActionCommand *cmd);
+int k_unk24(ActionCommand *cmd);
+int kRunEncounter(ActionCommand *cmd);
+int kJumpIfFlag2Bit4(ActionCommand *cmd);
+int kSetFlag2Bit4(ActionCommand *cmd);
+int kClearFlag2Bit4(ActionCommand *cmd);
+int kSetActorField638(ActionCommand *cmd);
+int kJumpIfActorField638(ActionCommand *cmd);
+int kChangeScene(ActionCommand *cmd);
+int k_unk2C_ActorSub(ActionCommand *cmd);
+int kPlayMovie(ActionCommand *cmd);
+int kStopAllBarriersSounds(ActionCommand *cmd);
+int kSetActionFlag01(ActionCommand *cmd);
+int kClearActionFlag01(ActionCommand *cmd);
+int kResetSceneRect(ActionCommand *cmd);
+int kChangeMusicById(ActionCommand *cmd);
+int kStopMusic(ActionCommand *cmd);
+int k_unk34_Status(ActionCommand *cmd);
+int k_unk35(ActionCommand *cmd);
+int k_unk36(ActionCommand *cmd);
+int kRunBlowUpPuzzle(ActionCommand *cmd);
+int kJumpIfFlag2Bit3(ActionCommand *cmd);
+int kSetFlag2Bit3(ActionCommand *cmd);
+int kClearFlag2Bit3(ActionCommand *cmd);
+int k_unk3B_PALETTE_MOD(ActionCommand *cmd);
+int k_unk3C_CMP_VAL(ActionCommand *cmd);
+int kWaitUntilFramePlayed(ActionCommand *cmd);
+int kUpdateWideScreen(ActionCommand *cmd);
+int k_unk3F(ActionCommand *cmd);
+int k_unk40_SOUND(ActionCommand *cmd);
+int kPlaySpeech(ActionCommand *cmd);
+int k_unk42(ActionCommand *cmd);
+int k_unk43(ActionCommand *cmd);
+int kPaletteFade(ActionCommand *cmd);
+int kStartPaletteFadeThread(ActionCommand *cmd);
+int k_unk46(ActionCommand *cmd);
+int kActorFaceObject(ActionCommand *cmd);
+int k_unk48_MATTE_01(ActionCommand *cmd);
+int k_unk49_MATTE_90(ActionCommand *cmd);
+int kJumpIfSoundPlaying(ActionCommand *cmd);
+int kChangePlayerCharacterIndex(ActionCommand *cmd);
+int kChangeActorField40(ActionCommand *cmd);
+int kStopSound(ActionCommand *cmd);
+int k_unk4E_RANDOM_COMMAND(ActionCommand *cmd);
+int kClearScreen(ActionCommand *cmd);
+int kQuit(ActionCommand *cmd);
+int kJumpBarrierFrame(ActionCommand *cmd);
+int k_unk52(ActionCommand *cmd);
+int k_unk53(ActionCommand *cmd);
+int k_unk54_SET_ACTIONLIST_6EC(ActionCommand *cmd);
+int k_unk55(ActionCommand *cmd);
+int k_unk56(ActionCommand *cmd);
+int kSetResourcePalette(ActionCommand *cmd);
+int kSetBarrierFrameIdxFlaged(ActionCommand *cmd);
+int k_unk59(ActionCommand *cmd);
+int k_unk5A(ActionCommand *cmd);
+int k_unk5B(ActionCommand *cmd);
+int k_unk5C(ActionCommand *cmd);
+int k_unk5D(ActionCommand *cmd);
+int k_unk5E(ActionCommand *cmd);
+int kSetBarrierLastFrameIdx(ActionCommand *cmd);
+int k_unk60_SET_OR_CLR_ACTIONAREA_FLAG(ActionCommand *cmd);
+int k_unk61(ActionCommand *cmd);
+int k_unk62_SHOW_OPTIONS_SCREEN(ActionCommand *cmd);
+int k_unk63(ActionCommand *cmd);
+
#define ScriptMan (::Asylum::ScriptManager::instance())
diff --git a/engines/asylum/shared.cpp b/engines/asylum/shared.cpp
index b26d73ed7e..83a3f501df 100644
--- a/engines/asylum/shared.cpp
+++ b/engines/asylum/shared.cpp
@@ -70,6 +70,92 @@ bool SharedResources::pointInPoly(PolyDefinitions *poly, int x, int y) {
return inside_flag;
}
+int SharedResources::getAngle(int x1, int y1, int x2, int y2) {
+ uint32 v5 = (x2 << 16) - (x1 << 16);
+ int v6 = 0;
+ int v4 = (y1 << 16) - (y2 << 16);
+
+ if (v5 < 0) {
+ v6 = 2;
+ v5 = -v5;
+ }
+
+ if (v4 < 0) {
+ v6 |= 1;
+ v4 = -v4;
+ }
+
+ int v7;
+ int v8 = -1;
+
+ if (v5) {
+ v7 = (v4 << 8) / v5;
+
+ if (v7 < 0x100)
+ v8 = angleTable01[v7];
+ if (v7 < 0x1000 && v8 < 0)
+ v8 = angleTable02[v7 >> 4];
+ if (v7 < 0x10000 && v8 < 0)
+ v8 = angleTable03[v7 >> 8];
+ } else {
+ v8 = 90;
+ }
+
+ switch (v6) {
+ case 1:
+ v8 = 360 - v8;
+ break;
+ case 2:
+ v8 = 180 - v8;
+ break;
+ case 3:
+ v8 += 180;
+ break;
+ }
+
+ if (v8 >= 360)
+ v8 -= 360;
+
+ int result;
+
+ if (v8 < 157 || v8 >= 202) {
+ if (v8 < 112 || v8 >= 157) {
+ if (v8 < 67 || v8 >= 112) {
+ if (v8 < 22 || v8 >= 67) {
+ if ((v8 < 0 || v8 >= 22) && (v8 < 337 || v8 > 359)) {
+ if (v8 < 292 || v8 >= 337) {
+ if (v8 < 247 || v8 >= 292) {
+ if (v8 < 202 || v8 >= 247) {
+ error("getAngle returned a bad angle: %d.", v8);
+ result = x1;
+ } else {
+ result = 3;
+ }
+ } else {
+ result = 4;
+ }
+ } else {
+ result = 5;
+ }
+ } else {
+ result = 6;
+ }
+ } else {
+ result = 7;
+ }
+ } else {
+ result = 0;
+ }
+ } else {
+ result = 1;
+ }
+ } else {
+ result = 2;
+ }
+
+ return result;
+}
+
void SharedResources::setGameFlag(int flag) {
_gameFlags[flag / 32] |= 1 << flag % -32;
}
diff --git a/engines/asylum/shared.h b/engines/asylum/shared.h
index 1f3d5b7da6..bedd426911 100644
--- a/engines/asylum/shared.h
+++ b/engines/asylum/shared.h
@@ -63,6 +63,7 @@ public:
Scene* getScene() { return _scene; }
bool pointInPoly(PolyDefinitions *poly, int x, int y);
+ int getAngle(int x1, int y1, int x2, int y2);
void setGameFlag(int flag);
void clearGameFlag(int flag);
@@ -76,19 +77,73 @@ private:
~SharedResources();
OSystem *_system;
- Video *_video;
- Screen *_screen;
- Sound *_sound;
- Scene *_scene;
-
- // NOTE
- // Storing the gameflags on the
- // scriptmanager since this makes the
- // most sense
+ Video *_video;
+ Screen *_screen;
+ Sound *_sound;
+ Scene *_scene;
+
int _gameFlags[1512];
}; // end of class SharedResources
+ // Angle Tables used by getAngle()
+ const uint8 angleTable01[256] = {
+ 0x00,0x00,0x00,0x01,0x01,0x01,0x01,0x02,0x02,0x02,0x02,0x02,0x03,0x03,0x03,0x03,
+ 0x04,0x04,0x04,0x04,0x04,0x05,0x05,0x05,0x05,0x06,0x06,0x06,0x06,0x06,0x07,0x07,
+ 0x07,0x07,0x08,0x08,0x08,0x08,0x08,0x09,0x09,0x09,0x09,0x0A,0x0A,0x0A,0x0A,0x0A,
+ 0x0B,0x0B,0x0B,0x0B,0x0B,0x0C,0x0C,0x0C,0x0C,0x0D,0x0D,0x0D,0x0D,0x0D,0x0E,0x0E,
+ 0x0E,0x0E,0x0E,0x0F,0x0F,0x0F,0x0F,0x10,0x10,0x10,0x10,0x10,0x11,0x11,0x11,0x11,
+ 0x11,0x12,0x12,0x12,0x12,0x12,0x13,0x13,0x13,0x13,0x13,0x14,0x14,0x14,0x14,0x14,
+ 0x15,0x15,0x15,0x15,0x15,0x16,0x16,0x16,0x16,0x16,0x16,0x17,0x17,0x17,0x17,0x17,
+ 0x18,0x18,0x18,0x18,0x18,0x19,0x19,0x19,0x19,0x19,0x19,0x1A,0x1A,0x1A,0x1A,0x1A,
+ 0x1B,0x1B,0x1B,0x1B,0x1B,0x1B,0x1C,0x1C,0x1C,0x1C,0x1C,0x1D,0x1D,0x1D,0x1D,0x1D,
+ 0x1D,0x1E,0x1E,0x1E,0x1E,0x1E,0x1E,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x20,0x20,0x20,
+ 0x20,0x20,0x20,0x20,0x21,0x21,0x21,0x21,0x21,0x21,0x22,0x22,0x22,0x22,0x22,0x22,
+ 0x23,0x23,0x23,0x23,0x23,0x23,0x23,0x24,0x24,0x24,0x24,0x24,0x24,0x24,0x25,0x25,
+ 0x25,0x25,0x25,0x25,0x25,0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x27,0x27,0x27,0x27,
+ 0x27,0x27,0x27,0x27,0x28,0x28,0x28,0x28,0x28,0x28,0x28,0x29,0x29,0x29,0x29,0x29,
+ 0x29,0x29,0x29,0x2A,0x2A,0x2A,0x2A,0x2A,0x2A,0x2A,0x2A,0x2B,0x2B,0x2B,0x2B,0x2B,
+ 0x2B,0x2B,0x2B,0x2C,0x2C,0x2C,0x2C,0x2C,0x2C,0x2C,0x2C,0x2C,0x2D,0x2D,0x2D,0x2D
+ };
+
+ const uint8 angleTable02[256] = {
+ 0x00,0x04,0x07,0x0B,0x0E,0x11,0x15,0x18,0x1B,0x1D,0x20,0x23,0x25,0x27,0x29,0x2B,
+ 0x2D,0x2F,0x30,0x32,0x33,0x35,0x36,0x37,0x38,0x39,0x3A,0x3B,0x3C,0x3D,0x3E,0x3F,
+ 0x3F,0x40,0x41,0x41,0x42,0x43,0x43,0x44,0x44,0x45,0x45,0x46,0x46,0x46,0x47,0x47,
+ 0x48,0x48,0x48,0x49,0x49,0x49,0x49,0x4A,0x4A,0x4A,0x4B,0x4B,0x4B,0x4B,0x4C,0x4C,
+ 0x4C,0x4C,0x4C,0x4D,0x4D,0x4D,0x4D,0x4D,0x4D,0x4E,0x4E,0x4E,0x4E,0x4E,0x4E,0x4F,
+ 0x4F,0x4F,0x4F,0x4F,0x4F,0x4F,0x4F,0x50,0x50,0x50,0x50,0x50,0x50,0x50,0x50,0x50,
+ 0x51,0x51,0x51,0x51,0x51,0x51,0x51,0x51,0x51,0x51,0x51,0x51,0x52,0x52,0x52,0x52,
+ 0x52,0x52,0x52,0x52,0x52,0x52,0x52,0x52,0x52,0x52,0x53,0x53,0x53,0x53,0x53,0x53,
+ 0x53,0x53,0x53,0x53,0x53,0x53,0x53,0x53,0x53,0x53,0x53,0x53,0x53,0x54,0x54,0x54,
+ 0x54,0x54,0x54,0x54,0x54,0x54,0x54,0x54,0x54,0x54,0x54,0x54,0x54,0x54,0x54,0x54,
+ 0x54,0x54,0x54,0x54,0x54,0x54,0x54,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,
+ 0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,
+ 0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x56,0x56,0x56,0x56,
+ 0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,
+ 0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,
+ 0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56
+ };
+
+ const uint8 angleTable03[256] = {
+ 0x00,0x45,0x63,0x72,0x76,0x79,0x81,0x82,0x83,0x84,0x84,0x85,0x85,0x86,0x86,0x86,
+ 0x86,0x87,0x87,0x87,0x87,0x87,0x87,0x88,0x88,0x88,0x88,0x88,0x88,0x88,0x88,0x88,
+ 0x88,0x88,0x88,0x88,0x88,0x88,0x88,0x89,0x89,0x89,0x89,0x89,0x89,0x89,0x89,0x89,
+ 0x89,0x89,0x89,0x89,0x89,0x89,0x89,0x89,0x89,0x89,0x89,0x89,0x89,0x89,0x89,0x89,
+ 0x89,0x89,0x89,0x89,0x89,0x89,0x89,0x89,0x89,0x89,0x89,0x89,0x89,0x89,0x89,0x89,
+ 0x89,0x89,0x89,0x89,0x89,0x89,0x89,0x89,0x89,0x89,0x89,0x89,0x89,0x89,0x89,0x89,
+ 0x89,0x89,0x89,0x89,0x89,0x89,0x89,0x89,0x89,0x89,0x89,0x89,0x89,0x89,0x89,0x89,
+ 0x89,0x89,0x89,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,
+ 0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,
+ 0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,
+ 0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,
+ 0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,
+ 0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,
+ 0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,
+ 0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,
+ 0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90
+ };
+
#define Shared (::Asylum::SharedResources::instance())
} // end of namespace Asylum
Commit: b1865b731959ee0cd24a1d6778f7f0a8f527401b
https://github.com/scummvm/scummvm/commit/b1865b731959ee0cd24a1d6778f7f0a8f527401b
Author: Alex Bevilacqua (alexbevi at gmail.com)
Date: 2021-05-17T15:35:45+02:00
Commit Message:
ASYLUM: Refactored the actor code. Moved a lot of functions into the actor class where it belongs.
NOTE that cursor changes when using the right mouse button aren't working at the moment
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@329 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/actor.cpp
engines/asylum/actor.h
engines/asylum/cursor.cpp
engines/asylum/scene.cpp
engines/asylum/scene.h
engines/asylum/sceneres.cpp
engines/asylum/sceneres.h
engines/asylum/scriptman.cpp
diff --git a/engines/asylum/actor.cpp b/engines/asylum/actor.cpp
index 60c13d1389..bfc961d44a 100644
--- a/engines/asylum/actor.cpp
+++ b/engines/asylum/actor.cpp
@@ -31,28 +31,48 @@
namespace Asylum {
-MainActor::MainActor(uint8 *data, ActorItem *actorRef) {
- byte *dataPtr = data;
-
- for (uint32 i = 0; i < 60; i++){
- _resources[i] = READ_UINT32(dataPtr);
- dataPtr += 4;
- }
-
- _resPack = 0;
+Actor::Actor() {
_graphic = 0;
- _actorX = 0;
- _actorY = 0;
_currentAction = 0;
_currentWalkArea = 0;
- _actorRef = actorRef;
}
-MainActor::~MainActor() {
+Actor::~Actor() {
delete _graphic;
+
+ // free _resources?
+}
+
+void Actor::setPostion(uint32 targetX, uint32 targetY) {
+ boundingRect.left = targetX;
+ boundingRect.top = targetY;
+
+ x = targetX;
+ y = targetY;
+}
+
+void Actor::visible(bool value) {
+ if (value) // TODO - enums for flags (0x01 is visible)
+ flags |= 0x01;
+ else
+ flags &= 0xFFFFFFFE;
+}
+
+void Actor::setDirection(int dir) {
+ direction = dir;
+ setActionByIndex(dir);
}
-void MainActor::setAction(int action) {
+void Actor::setRawResources(uint8 *data) {
+ byte *dataPtr = data;
+
+ for (uint32 i = 0; i < 60; i++){
+ _resources[i] = READ_UINT32(dataPtr);
+ dataPtr += 4;
+ }
+}
+
+void Actor::setAction(int action) {
assert(_resPack);
if (action == _currentAction)
@@ -84,11 +104,11 @@ void MainActor::setAction(int action) {
_currentFrame = 0;
}
-void MainActor::setActionByIndex(int index) {
+void Actor::setActionByIndex(int index) {
setAction(_resources[index] & 0xFFFF);
}
-GraphicFrame *MainActor::getFrame() {
+GraphicFrame *Actor::getFrame() {
assert(_graphic);
GraphicFrame *frame = _graphic->getFrame(_currentFrame);
@@ -106,7 +126,7 @@ GraphicFrame *MainActor::getFrame() {
return frame;
}
-void MainActor::drawActorAt(uint16 curX, uint16 curY) {
+void Actor::drawActorAt(uint16 curX, uint16 curY) {
GraphicFrame *frame = getFrame();
Shared.getScreen()->copyRectToScreenWithTransparency(
@@ -116,23 +136,23 @@ void MainActor::drawActorAt(uint16 curX, uint16 curY) {
curY,
frame->surface.w,
frame->surface.h );
- x(curX);
- y(curY);
+ x = curX;
+ y = curY;
}
-void MainActor::drawActor() {
+void Actor::drawActor() {
GraphicFrame *frame = getFrame();
Shared.getScreen()->copyToBackBufferWithTransparency(
((byte *)frame->surface.pixels),
frame->surface.w,
- _actorX,
- _actorY - frame->surface.h,
+ x,
+ y - frame->surface.h,
frame->surface.w,
frame->surface.h );
}
-void MainActor::setWalkArea(ActionArea *target) {
+void Actor::setWalkArea(ActionArea *target) {
if (_currentWalkArea != target) {
ScriptMan.setScriptIndex(target->actionListIdx1);
_currentWalkArea = target;
@@ -140,38 +160,38 @@ void MainActor::setWalkArea(ActionArea *target) {
}
}
-void MainActor::walkTo(uint16 curX, uint16 curY) {
+void Actor::walkTo(uint16 curX, uint16 curY) {
int newAction = _currentAction;
// step is the increment by which to move the
// actor in a given direction
int step = 2;
- uint16 newX = _actorX;
- uint16 newY = _actorY;
+ uint16 newX = x;
+ uint16 newY = y;
bool done = false;
// Walking left...
- if (curX < _actorX) {
+ if (curX < x) {
newAction = kWalkW;
newX -= step;
- if (ABS(curY - _actorY) <= 30)
+ if (ABS(curY - y) <= 30)
done = true;
}
// Walking right...
- if (curX > _actorX) {
+ if (curX > x) {
newAction = kWalkE;
newX += step;
- if (ABS(curY - _actorY) <= 30)
+ if (ABS(curY - y) <= 30)
done = true;
}
// Walking up...
- if (curY < _actorY && !done) {
- if (newAction != _currentAction && newAction == kWalkW && _actorX - curX > 30)
+ if (curY < y && !done) {
+ if (newAction != _currentAction && newAction == kWalkW && x - curX > 30)
newAction = kWalkNW; // up left
- else if (newAction != _currentAction && newAction == kWalkE && curX - _actorX > 30)
+ else if (newAction != _currentAction && newAction == kWalkE && curX - x > 30)
newAction = kWalkNE; // up right
else
newAction = kWalkN;
@@ -180,10 +200,10 @@ void MainActor::walkTo(uint16 curX, uint16 curY) {
}
// Walking down...
- if (curY > _actorY && !done) {
- if (newAction != _currentAction && newAction == kWalkW && _actorX - curX > 30)
+ if (curY > y && !done) {
+ if (newAction != _currentAction && newAction == kWalkW && x - curX > 30)
newAction = kWalkSW; // down left
- else if (newAction != _currentAction && newAction == kWalkE && curX - _actorX > 30)
+ else if (newAction != _currentAction && newAction == kWalkE && curX - x > 30)
newAction = kWalkSE; // down right
else
newAction = kWalkS;
@@ -222,7 +242,7 @@ void MainActor::walkTo(uint16 curX, uint16 curY) {
if (Shared.getScene()->getResources()->getWorldStats()->actions[a].actionType == 0) {
area = &Shared.getScene()->getResources()->getWorldStats()->actions[a];
PolyDefinitions poly = Shared.getScene()->getResources()->getGamePolygons()->polygons[area->polyIdx];
- if (Shared.pointInPoly(&poly, _actorX, _actorY)) {
+ if (Shared.pointInPoly(&poly, x, y)) {
availableAreas[areaPtr] = a;
areaPtr++;
@@ -241,8 +261,8 @@ void MainActor::walkTo(uint16 curX, uint16 curY) {
area = &Shared.getScene()->getResources()->getWorldStats()->actions[availableAreas[i]];
PolyDefinitions *region = &Shared.getScene()->getResources()->getGamePolygons()->polygons[area->polyIdx];
if (Shared.pointInPoly(region, newX, newY)) {
- x(newX);
- y(newY);
+ x = newX;
+ y = newY;
break;
}
}
@@ -251,23 +271,13 @@ void MainActor::walkTo(uint16 curX, uint16 curY) {
drawActor();
}
-void MainActor::x(uint16 pos) {
- _actorX = pos;
- _actorRef->x0 = pos;
-}
-
-void MainActor::y(uint16 pos) {
- _actorY = pos;
- _actorRef->y0 = pos;
-}
-
-void MainActor::disable(int param) {
+void Actor::disable(int param) {
switch (param) {
case 5:
- int dir = _actorRef->direction;
+ int dir = direction;
if (dir > 4)
- _actorRef->direction = 8 - dir;
+ direction = 8 - dir;
setAction(dir + 5);
break;
@@ -276,8 +286,5 @@ void MainActor::disable(int param) {
}
-void MainActor::setDirection(int direction) {
-
-}
} // end of namespace Asylum
diff --git a/engines/asylum/actor.h b/engines/asylum/actor.h
index c4e12cff05..3b7eedc662 100644
--- a/engines/asylum/actor.h
+++ b/engines/asylum/actor.h
@@ -33,7 +33,6 @@ namespace Asylum {
class Screen;
struct ActionArea;
-struct ActorItem;
// TODO investigate other actor resources (from other
// scenes) to see if the unused blocks in the actor
@@ -127,12 +126,29 @@ enum ActorResources {
// TODO: finish these
};
-class MainActor {
+class Actor {
public:
- MainActor(uint8 *data, ActorItem *actorRef);
- virtual ~MainActor();
-
- void setResourcePack(ResourcePack *resPack) { _resPack = resPack; }
+ Actor();
+ virtual ~Actor();
+
+ /**
+ * Initialize the 500 byte resource index from the scene
+ * file (at offset 0xA73B6).
+ *
+ * TODO remove this or add it in the right place
+ */
+ void setRawResources(uint8* data);
+
+ bool visible() { return flags & 0x01; }
+ void visible(bool value);
+ void setPostion(uint32 targetX, uint32 targetY);
+ void setDirection(int dir);
+
+ // FIXME
+ // I don't really like how this is used in the scene constructor
+ void setResourcePack(ResourcePack *res) { _resPack = res; }
+
+ // OLD METHODS
void setWalkArea(ActionArea *target); // TODO depreciate
void setAction(int action);
void setActionByIndex(int index);
@@ -140,29 +156,67 @@ public:
void drawActor();
void walkTo(uint16 curX, uint16 curY);
void disable(int param);
- void setDirection(int direction);
+
int getCurrentAction() { return _currentAction; }
- // XXX
- // Setting the actorRef x/y values is just a hack
- // while we fix the actor code. The mainactor class will
- // likely be completely redone, so the screen coords of
- // the actor should be updated on the ActorItem reference
- // when updating the class
- void x(uint16 pos);
- void y(uint16 pos);
- uint16 x() { return _actorX; }
- uint16 y() { return _actorY; }
+
+ uint32 x;
+ uint32 y;
+ uint32 grResId;
+ uint32 field_C;
+ uint32 frameNum;
+ uint32 frameCount;
+ uint32 x1;
+ uint32 y1;
+ uint32 x2;
+ uint32 y2;
+ Common::Rect boundingRect;
+ uint32 direction;
+ uint32 field_3C;
+ uint32 field_40;
+ uint32 field_44;
+ uint32 field_48;
+ uint32 flags;
+ uint32 field_50;
+ uint32 field_54;
+ uint32 field_58;
+ uint32 field_5C;
+ uint32 field_60;
+ uint32 actionIdx3;
+ // TODO field_68 till field_617
+ uint32 reaction[8];
+ uint32 field_638;
+ uint32 walkingSound1;
+ uint32 walkingSound2;
+ uint32 walkingSound3;
+ uint32 walkingSound4;
+ uint32 field_64C;
+ uint32 field_650;
+ uint32 grResTable[55];
+ char name[256];
+ uint32 field_830[20];
+ uint32 field_880[20];
+ uint32 field_8D0[20];
+ uint32 actionIdx2;
+ uint32 field_924;
+ uint32 tickValue1;
+ uint32 field_92C;
+ uint32 flags2;
+ uint32 field_934;
+ uint32 field_938;
+ uint32 soundResId; // field_93C
+ uint32 field_940;
+ uint32 field_944;
+ // TODO field_948 till field_978
+ uint32 actionIdx1;
+ // TODO field_980 till field_9A0
private:
- GraphicResource *_graphic;
ResourcePack *_resPack;
- uint32 _resources[61];
- uint8 _currentFrame;
- int _currentAction;
- uint16 _actorX;
- uint16 _actorY;
- ActionArea *_currentWalkArea;
- ActorItem *_actorRef;
+ GraphicResource *_graphic;
+ uint32 _resources[61];
+ uint8 _currentFrame;
+ int _currentAction;
+ ActionArea *_currentWalkArea;
GraphicFrame *getFrame();
diff --git a/engines/asylum/cursor.cpp b/engines/asylum/cursor.cpp
index c631dff03c..84c962fe38 100644
--- a/engines/asylum/cursor.cpp
+++ b/engines/asylum/cursor.cpp
@@ -115,7 +115,9 @@ void Cursor::update(CommonResources *cr, int currentAction) {
break;
}
- if (_cursorResource->getEntryNum() != newCursor)
+ // FIXME Added the newCursor > 0 check because cursors
+ // aren't working properly with the new actor code
+ if (_cursorResource->getEntryNum() != newCursor && newCursor > 0)
load(newCursor);
}
diff --git a/engines/asylum/scene.cpp b/engines/asylum/scene.cpp
index 60a4c5dac4..ed2314f3bc 100644
--- a/engines/asylum/scene.cpp
+++ b/engines/asylum/scene.cpp
@@ -24,9 +24,9 @@
*/
#include "asylum/scene.h"
-#include "asylum/sceneres.h"
#include "asylum/shared.h"
#include "asylum/scriptman.h"
+#include "asylum/actor.h"
namespace Asylum {
@@ -45,8 +45,13 @@ Scene::Scene(uint8 sceneIdx) {
_resPack = new ResourcePack(sceneIdx);
_speechPack = new ResourcePack(3);
- _sceneResource->getMainActor()->setResourcePack(_resPack);
-
+ // FIXME
+ // Is there EVER more than one actor enabled for a scene? I can't
+ // remember, so I guess a playthrough is in order :P
+ // Either way, this is kinda dumb
+ for (uint8 i = 0; i < _sceneResource->getWorldStats()->numActors; i++)
+ _sceneResource->getWorldStats()->actors[i].setResourcePack(_resPack);
+
_text->loadFont(_resPack, _sceneResource->getWorldStats()->commonRes.font1);
char musPackFileName[10];
@@ -105,6 +110,10 @@ Scene::~Scene() {
delete _blowUp;
}
+Actor* Scene::getActor() {
+ return &_sceneResource->getWorldStats()->actors[_playerActorIdx];
+}
+
void Scene::enterScene() {
Shared.getScreen()->setPalette(_resPack, _sceneResource->getWorldStats()->commonRes.palette);
_background = _bgResource->getFrame(0);
@@ -136,59 +145,6 @@ ActionDefinitions* Scene::getActionList(int actionListIndex) {
return 0;
}
-void Scene::setActorPosition(int actorIndex, int x, int y) {
- if ((actorIndex >= 0) && (actorIndex < (int)_sceneResource->getWorldStats()->numActors)) {
- _sceneResource->getWorldStats()->actors[actorIndex].boundingRect.left = x;
- _sceneResource->getWorldStats()->actors[actorIndex].boundingRect.top = y;
- }
-
- // FIXME - Remove this once mainActor uses proper actor info
- if (actorIndex == 0) {
- _sceneResource->getMainActor()->x(x);
- _sceneResource->getMainActor()->y(y);
- }
-}
-
-void Scene::setActorAction(int actorIndex, int action) {
- if ((actorIndex >= 0) && (actorIndex < (int)_sceneResource->getWorldStats()->numActors)) {
- _sceneResource->getWorldStats()->actors[actorIndex].direction = action;
- }
-
- // FIXME - Remove this once mainActor uses proper actor info
- if (actorIndex == 0) {
- if(_sceneResource->getMainActor())
- _sceneResource->getMainActor()->setActionByIndex(action); // The action appears to be an index rather than a direct resId
- }
-}
-
-void Scene::actorVisible(int actorIndex, bool visible) {
- if ((actorIndex >= 0) && (actorIndex < (int)_sceneResource->getWorldStats()->numActors)) {
- if(visible) // TODO - enums for flags (0x01 is visible)
- _sceneResource->getWorldStats()->actors[actorIndex].flags |= 0x01;
- else
- _sceneResource->getWorldStats()->actors[actorIndex].flags &= 0xFFFFFFFE;
- }
-
- // FIXME - Remove this once mainActor uses proper actor info
- if (actorIndex == 0) {
- //if(_sceneResource->getMainActor())
- //_sceneResource->getMainActor()->setAction(action);
- }
-}
-
-bool Scene::actorVisible(int actorIndex) {
- if ((actorIndex >= 0) && (actorIndex < (int)_sceneResource->getWorldStats()->numActors))
- return _sceneResource->getWorldStats()->actors[actorIndex].flags & 0x01; // TODO - enums for flags (0x01 is visible)
-
- // FIXME - Remove this once mainActor uses proper actor info
- if (actorIndex == 0) {
- //if(_sceneResource->getMainActor())
- //_sceneResource->getMainActor()->setAction(action);
- }
-
- return false;
-}
-
void Scene::setScenePosition(int x, int y)
{
GraphicFrame *bg = _bgResource->getFrame(0);
@@ -297,24 +253,19 @@ int Scene::updateScene() {
return 0;
}
-int Scene::isActorVisible(ActorItem *actor) {
- return actor->flags & 1;
-}
-
void Scene::updateMouse() {
Common::Rect actorPos;
- ActorItem *actor = &_sceneResource->getWorldStats()->actors[_playerActorIdx];
if (_sceneIdx != 2 || _playerActorIdx != 10) {
- actorPos.top = actor->y0;
- actorPos.left = actor->x0 + 20;
- actorPos.right = actor->x0 + 2 + actor->x2;
- actorPos.bottom = actor->y0 + actor->y2;
+ actorPos.top = getActor()->y;
+ actorPos.left = getActor()->x + 20;
+ actorPos.right = getActor()->x + 2 + getActor()->x2;
+ actorPos.bottom = getActor()->y + getActor()->y2;
} else {
- actorPos.top = actor->y0 + 60;
- actorPos.left = actor->x0 + 50;
- actorPos.right = actor->x0 + actor->x2 + 10;
- actorPos.bottom = actor->y0 + actor->y2 - 20;
+ actorPos.top = getActor()->y + 60;
+ actorPos.left = getActor()->x + 50;
+ actorPos.right = getActor()->x + getActor()->x2 + 10;
+ actorPos.bottom = getActor()->y + getActor()->y2 - 20;
}
int dir = -1;
@@ -323,11 +274,11 @@ void Scene::updateMouse() {
if (_cursor->x() < actorPos.left) {
if (_cursor->y() >= actorPos.top) {
if (_cursor->y() > actorPos.bottom) {
- if (actor->direction == 2) {
+ if (getActor()->direction == 2) {
if (_cursor->y() - actorPos.bottom > 10)
dir = 3;
} else {
- if (actor->direction == 4) {
+ if (getActor()->direction == 4) {
if (actorPos.left - _cursor->x() > 10)
dir = 3;
} else {
@@ -335,11 +286,11 @@ void Scene::updateMouse() {
}
}
} else {
- if (actor->direction == 1) {
+ if (getActor()->direction == 1) {
if (_cursor->y() - actorPos.top > 10)
dir = 2;
} else {
- if (actor->direction == 3) {
+ if (getActor()->direction == 3) {
if (actorPos.bottom - _cursor->y() > 10)
dir = 2;
} else {
@@ -348,8 +299,8 @@ void Scene::updateMouse() {
}
}
} else {
- if (actor->direction) {
- if (actor->direction == 2) {
+ if (getActor()->direction) {
+ if (getActor()->direction == 2) {
if (actorPos.top - _cursor->y() > 10)
dir = 1;
} else {
@@ -366,11 +317,11 @@ void Scene::updateMouse() {
if (!done && _cursor->x() <= actorPos.right) {
if (_cursor->y() >= actorPos.top) {
if (_cursor->y() > actorPos.bottom) {
- if (actor->direction == 3) {
+ if (getActor()->direction == 3) {
if (_cursor->x() - actorPos.left > 10)
dir = 4;
} else {
- if (actor->direction == 5) {
+ if (getActor()->direction == 5) {
if (actorPos.right - _cursor->x() > 10)
dir = 4;
} else {
@@ -379,11 +330,11 @@ void Scene::updateMouse() {
}
}
} else {
- if (actor->direction == 1) {
+ if (getActor()->direction == 1) {
if (_cursor->x() - actorPos.left > 10)
dir = 0;
} else {
- if (actor->direction == 7) {
+ if (getActor()->direction == 7) {
if (actorPos.right - _cursor->x() > 10)
dir = 0;
} else {
@@ -395,8 +346,8 @@ void Scene::updateMouse() {
}
if (!done && _cursor->y() < actorPos.top) {
- if (actor->direction) {
- if (actor->direction == 6) {
+ if (getActor()->direction) {
+ if (getActor()->direction == 6) {
if (actorPos.top - _cursor->y() > 10)
dir = 7;
} else {
@@ -410,11 +361,11 @@ void Scene::updateMouse() {
}
if (!done && _cursor->y() <= actorPos.bottom) {
- if (actor->direction == 5) {
+ if (getActor()->direction == 5) {
if (actorPos.bottom - _cursor->y() > 10)
dir = 6;
} else {
- if (actor->direction == 7) {
+ if (getActor()->direction == 7) {
if (_cursor->y() - actorPos.top > 10)
dir = 6;
} else {
@@ -424,14 +375,14 @@ void Scene::updateMouse() {
done = true;
}
- if (!done && actor->direction == 4) {
+ if (!done && getActor()->direction == 4) {
if (_cursor->x() - actorPos.right <= 10)
done = true;
if (!done)
dir = 5;
}
- if (!done && (actor->direction != 6 || _cursor->y() - actorPos.bottom > 10)) {
+ if (!done && (getActor()->direction != 6 || _cursor->y() - actorPos.bottom > 10)) {
dir = 5;
}
@@ -440,9 +391,9 @@ void Scene::updateMouse() {
void Scene::updateActor(uint32 actorIdx) {
WorldStats *worldStats = _sceneResource->getWorldStats();
- ActorItem *actor = &worldStats->actors[actorIdx];
+ Actor *actor = getActor();
- if (isActorVisible(actor)) {
+ if (actor->visible()) {
switch (actor->field_40) {
case 0x10:
@@ -733,7 +684,6 @@ void Scene::updateAdjustScreen() {
void Scene::OLD_UPDATE(WorldStats *worldStats) {
int32 curHotspot = -1;
int32 curBarrier = -1;
- MainActor *mainActor = _sceneResource->getMainActor();
// DEBUGGING
// Check current walk region
@@ -741,32 +691,31 @@ void Scene::OLD_UPDATE(WorldStats *worldStats) {
if (worldStats->actions[a].actionType == 0) {
ActionArea *area = &worldStats->actions[a];
PolyDefinitions poly = _sceneResource->getGamePolygons()->polygons[area->polyIdx];
- if (Shared.pointInPoly(&poly, mainActor->x(), mainActor->y())) {
+ if (Shared.pointInPoly(&poly, getActor()->x, getActor()->y)) {
debugShowWalkRegion(&poly);
//break;
}
}
}
- uint32 newCursor = 0;
+
if (!_rightButton) {
if (_sceneResource->getWorldStats()->actors[0].flags & 0x01) { // TESTING - only draw if visible flag
// Check if the character was walking before the right-button
// was released. If so, change the resource to one where he/she
// is standing still, facing the last active direction
if (_walking) {
- int currentAction = mainActor->getCurrentAction();
+ int currentAction = getActor()->getCurrentAction();
if (currentAction > 0)
- mainActor->setAction(currentAction + 5);
+ getActor()->setAction(currentAction + 5);
_walking = false;
}
- mainActor->drawActor();
+ getActor()->drawActor();
}
} else {
_walking = true;
- mainActor->walkTo(_cursor->x(), _cursor->y());
- _cursor->update(&_sceneResource->getWorldStats()->commonRes,
- _sceneResource->getMainActor()->getCurrentAction());
+ getActor()->walkTo(_cursor->x(), _cursor->y());
+ _cursor->update(&_sceneResource->getWorldStats()->commonRes, getActor()->direction);
}
if (g_debugPolygons)
@@ -852,7 +801,9 @@ int Scene::drawScene() {
// Draw scene background
WorldStats *worldStats = _sceneResource->getWorldStats();
GraphicFrame *bg = _bgResource->getFrame(0);
- Shared.getScreen()->copyToBackBuffer(((byte *)bg->surface.pixels) + _startY * bg->surface.w + _startX, bg->surface.w, worldStats->xLeft, worldStats->yTop, 640, 480);
+ Shared.getScreen()->copyToBackBuffer(
+ ((byte *)bg->surface.pixels) + _startY * bg->surface.w + _startX, bg->surface.w, worldStats->xLeft,
+ worldStats->yTop, 640, 480);
// DEBUG
// Force the screen to scroll if the mouse approaches the edges
diff --git a/engines/asylum/scene.h b/engines/asylum/scene.h
index bdbb047cc2..112b7ece60 100644
--- a/engines/asylum/scene.h
+++ b/engines/asylum/scene.h
@@ -35,6 +35,7 @@
#include "asylum/sceneres.h"
#include "asylum/cursor.h"
+
namespace Asylum {
class Screen;
@@ -59,27 +60,27 @@ public:
void handleEvent(Common::Event *event, bool doUpdate);
void enterScene();
- void activate() { _isActive = true; }
- void deactivate() { _isActive = false; }
- bool isActive() { return _isActive; }
+ void activate() { _isActive = true; }
+ void deactivate() { _isActive = false; }
+ bool isActive() { return _isActive; }
int getSceneIndex() { return _sceneIdx; }
ActionDefinitions* getDefaultActionList();
ActionDefinitions* getActionList(int actionListIndex);
- void setActorPosition(int actorIndex, int x, int y);
- void setActorAction(int actorIndex, int action);
- void actorVisible(int actorIndex, bool visible);
- bool actorVisible(int actorIndex);
- void setScenePosition(int x, int y);
- Cursor* getCursor() { return _cursor; }
- SceneResource* getResources() { return _sceneResource; }
+
+ Actor* getActor();
+
+ Cursor* getCursor() { return _cursor; }
+ SceneResource* getResources() { return _sceneResource; }
ResourcePack* getResourcePack() { return _resPack; }
- ResourcePack* getMusicPack() { return _musPack; }
- ResourcePack* getSpeechPack() { return _speechPack; }
+ ResourcePack* getMusicPack() { return _musPack; }
+ ResourcePack* getSpeechPack() { return _speechPack; }
GraphicResource* getGraphicResource(uint32 entry) { return new GraphicResource(_resPack, entry); }
BlowUpPuzzle* getBlowUpPuzzle() { return _blowUp; }
- void setBlowUpPuzzle(BlowUpPuzzle* puzzle) { _blowUp = puzzle; }
+
+ void setBlowUpPuzzle(BlowUpPuzzle* puzzle) { _blowUp = puzzle; }
+ void setScenePosition(int x, int y);
private:
void copyToBackBufferClipped(Graphics::Surface *surface, int x, int y);
@@ -114,7 +115,6 @@ private:
void updateAdjustScreen();
int drawScene();
int drawBarriers();
- int isActorVisible(ActorItem *actor);
bool isBarrierVisible(BarrierItem *barrier);
bool isBarrierOnScreen(BarrierItem *barrier);
uint32 getRandomResId(BarrierItem *barrier);
diff --git a/engines/asylum/sceneres.cpp b/engines/asylum/sceneres.cpp
index b392dcefa7..cd7ba67d76 100644
--- a/engines/asylum/sceneres.cpp
+++ b/engines/asylum/sceneres.cpp
@@ -32,10 +32,11 @@ SceneResource::SceneResource() {
SceneResource::~SceneResource() {
delete _worldStats;
- delete _mainActor;
- for (uint i=0; i < _gamePolygons->numEntries; i++) {
+
+ uint8 i;
+ for (i = 0; i < _gamePolygons->numEntries; i++)
delete[] _gamePolygons->polygons[i].points;
- }
+
delete _gamePolygons;
delete _actionList;
}
@@ -190,7 +191,7 @@ void SceneResource::loadWorldStats(Common::SeekableReadStream *stream) {
_worldStats->ambientSounds[s].field_0 = stream->readUint32LE();
_worldStats->ambientSounds[s].flags = stream->readUint32LE();
_worldStats->ambientSounds[s].resId = stream->readUint32LE();
- _worldStats->ambientSounds[s].field_C = stream->readUint32LE();
+ _worldStats->ambientSounds[s].field_C = stream->readUint32LE();
_worldStats->ambientSounds[s].field_10 = stream->readUint32LE();
_worldStats->ambientSounds[s].field_14 = stream->readUint32LE();
@@ -287,68 +288,62 @@ void SceneResource::loadWorldStats(Common::SeekableReadStream *stream) {
for (uint32 a = 0; a < _worldStats->numActors; a++) {
int i;
- ActorItem actor;
- memset(&actor, 0, sizeof(ActorItem));
-
- actor.x0 = stream->readUint32LE();
- actor.y0 = stream->readUint32LE();
- actor.grResId = stream->readUint32LE();
- actor.field_C = stream->readUint32LE();
- actor.frameNum = stream->readUint32LE();
+ Actor actor;
+
+ actor.x = stream->readUint32LE();
+ actor.y = stream->readUint32LE();
+ actor.grResId = stream->readUint32LE();
+ actor.field_C = stream->readUint32LE();
+ actor.frameNum = stream->readUint32LE();
actor.frameCount = stream->readUint32LE();
- actor.x1 = stream->readUint32LE();
- actor.y1 = stream->readUint32LE();
- actor.x2 = stream->readUint32LE();
- actor.y2 = stream->readUint32LE();
+ actor.x1 = stream->readUint32LE();
+ actor.y1 = stream->readUint32LE();
+ actor.x2 = stream->readUint32LE();
+ actor.y2 = stream->readUint32LE();
- actor.boundingRect.left = stream->readUint32LE() & 0xFFFF;
- actor.boundingRect.top = stream->readUint32LE() & 0xFFFF;
+ actor.boundingRect.left = stream->readUint32LE() & 0xFFFF;
+ actor.boundingRect.top = stream->readUint32LE() & 0xFFFF;
actor.boundingRect.right = stream->readUint32LE() & 0xFFFF;
actor.boundingRect.bottom = stream->readUint32LE() & 0xFFFF;
- actor.direction = stream->readUint32LE();
- actor.field_3C = stream->readUint32LE();
- actor.field_40 = stream->readUint32LE();
- actor.field_44 = stream->readUint32LE();
- actor.field_48 = stream->readUint32LE();
- actor.flags = stream->readUint32LE();
- actor.field_50 = stream->readUint32LE();
- actor.field_54 = stream->readUint32LE();
- actor.field_58 = stream->readUint32LE();
- actor.field_5C = stream->readUint32LE();
- actor.field_60 = stream->readUint32LE();
+ actor.direction = stream->readUint32LE();
+ actor.field_3C = stream->readUint32LE();
+ actor.field_40 = stream->readUint32LE();
+ actor.field_44 = stream->readUint32LE();
+ actor.field_48 = stream->readUint32LE();
+ actor.flags = stream->readUint32LE();
+ actor.field_50 = stream->readUint32LE();
+ actor.field_54 = stream->readUint32LE();
+ actor.field_58 = stream->readUint32LE();
+ actor.field_5C = stream->readUint32LE();
+ actor.field_60 = stream->readUint32LE();
actor.actionIdx3 = stream->readUint32LE();
// TODO skip field_68 till field_617
stream->skip(0x5B0);
- for (i = 0; i < 8; i++) {
+ for (i = 0; i < 8; i++)
actor.reaction[i] = stream->readUint32LE();
- }
- actor.field_638 = stream->readUint32LE();
+ actor.field_638 = stream->readUint32LE();
actor.walkingSound1 = stream->readUint32LE();
actor.walkingSound2 = stream->readUint32LE();
actor.walkingSound3 = stream->readUint32LE();
actor.walkingSound4 = stream->readUint32LE();
- actor.field_64C = stream->readUint32LE();
- actor.field_650 = stream->readUint32LE();
+ actor.field_64C = stream->readUint32LE();
+ actor.field_650 = stream->readUint32LE();
- for (i = 0; i < 55; i++) {
+ for (i = 0; i < 55; i++)
actor.grResTable[i] = stream->readUint32LE();
- }
stream->read(actor.name, sizeof(actor.name));
- for (i = 0; i < 20; i++) {
+ for (i = 0; i < 20; i++)
actor.field_830[i] = stream->readUint32LE();
- }
- for (i = 0; i < 20; i++) {
+ for (i = 0; i < 20; i++)
actor.field_880[i] = stream->readUint32LE();
- }
- for (i = 0; i < 20; i++) {
+ for (i = 0; i < 20; i++)
actor.field_8D0[i] = stream->readUint32LE();
- }
actor.actionIdx2 = stream->readUint32LE();
actor.field_924 = stream->readUint32LE();
@@ -372,9 +367,14 @@ void SceneResource::loadWorldStats(Common::SeekableReadStream *stream) {
// TODO Take this out, it shouldn't be here (TEST ONLY)
stream->seek(0xA73B6);
+
uint8 mainActorData[500];
stream->read(mainActorData, 500);
- _mainActor = new MainActor(mainActorData, &_worldStats->actors[0]);
+
+ // FIXME
+ // This is ONLY ever going to work for scenes where there's only
+ // one actor in the worldStats->actors[] collection
+ _worldStats->actors[0].setRawResources(mainActorData);
stream->seek(0xD6B5A); // where action items start
diff --git a/engines/asylum/sceneres.h b/engines/asylum/sceneres.h
index ec57acd43d..9ae9b0f5e6 100644
--- a/engines/asylum/sceneres.h
+++ b/engines/asylum/sceneres.h
@@ -57,7 +57,6 @@ public:
WorldStats* getWorldStats() { return _worldStats; }
GamePolygons* getGamePolygons() { return _gamePolygons; }
ActionList* getActionList() { return _actionList; }
- MainActor* getMainActor() { return _mainActor; }
int getBarrierIndexById(uint32 id);
int getActionAreaIndexById(uint32 id);
@@ -70,11 +69,11 @@ private:
WorldStats *_worldStats;
GamePolygons *_gamePolygons;
ActionList *_actionList;
- MainActor *_mainActor;
void loadWorldStats(Common::SeekableReadStream *stream);
void loadGamePolygons(Common::SeekableReadStream *stream);
void loadActionList(Common::SeekableReadStream *stream);
+
Common::String parseFilename(uint8 sceneIdx);
}; // end of class Scene
@@ -180,61 +179,6 @@ typedef struct CommonResources {
} CommonResources;
-
-typedef struct ActorItem {
- uint32 x0;
- uint32 y0;
- uint32 grResId;
- uint32 field_C;
- uint32 frameNum;
- uint32 frameCount;
- uint32 x1;
- uint32 y1;
- uint32 x2;
- uint32 y2;
- Common::Rect boundingRect;
- uint32 direction;
- uint32 field_3C;
- uint32 field_40;
- uint32 field_44;
- uint32 field_48;
- uint32 flags;
- uint32 field_50;
- uint32 field_54;
- uint32 field_58;
- uint32 field_5C;
- uint32 field_60;
- uint32 actionIdx3;
- // TODO field_68 till field_617
- uint32 reaction[8];
- uint32 field_638;
- uint32 walkingSound1;
- uint32 walkingSound2;
- uint32 walkingSound3;
- uint32 walkingSound4;
- uint32 field_64C;
- uint32 field_650;
- uint32 grResTable[55];
- char name[256];
- uint32 field_830[20];
- uint32 field_880[20];
- uint32 field_8D0[20];
- uint32 actionIdx2;
- uint32 field_924;
- uint32 tickValue1;
- uint32 field_92C;
- uint32 flags2;
- uint32 field_934;
- uint32 field_938;
- uint32 soundResId; // field_93C
- uint32 field_940;
- uint32 field_944;
- // TODO field_948 till field_978
- uint32 actionIdx1;
- // TODO field_980 till field_9A0
-
-} ActorItem;
-
class WorldStats {
public:
WorldStats() {};
@@ -288,7 +232,7 @@ public:
// FIXME: Investigate if we need to actually reserve maxsize for this arrays.
// It always have that size under scene file and they are always save in savegames.
Common::Array<BarrierItem> barriers; // maxsize 400
- Common::Array<ActorItem> actors; // maxsize 50
+ Common::Array<Actor> actors; // maxsize 50
// TODO add rest fields
Common::Array<ActionArea> actions; // maxsize 400
// TODO add rest fields
diff --git a/engines/asylum/scriptman.cpp b/engines/asylum/scriptman.cpp
index 1920a32338..7b62f2f0c1 100644
--- a/engines/asylum/scriptman.cpp
+++ b/engines/asylum/scriptman.cpp
@@ -505,7 +505,7 @@ int kHideActor(ActionCommand *cmd) {
actorIndex = cmd->param1;
if ((actorIndex >= 0) && (actorIndex < Shared.getScene()->getResources()->getWorldStats()->numActors))
- Shared.getScene()->actorVisible(actorIndex, false);
+ Shared.getScene()->getActor()->visible(false);
else
debugC(kDebugLevelScripts,
"Requested invalid actor ID:0x%02X in Scene %d Line %d.",
@@ -525,7 +525,7 @@ int kShowActor(ActionCommand *cmd) {
actorIndex = cmd->param1;
if ((actorIndex >= 0) && (actorIndex < Shared.getScene()->getResources()->getWorldStats()->numActors))
- Shared.getScene()->actorVisible(actorIndex, true);
+ Shared.getScene()->getActor()->visible(true);
else
debugC(kDebugLevelScripts,
"Requested invalid actor ID:0x%02X in Scene %d Line %d.",
@@ -543,8 +543,8 @@ int kSetActorStats(ActionCommand *cmd) {
actorIndex = cmd->param1;
if ((actorIndex >= 0) && (actorIndex < Shared.getScene()->getResources()->getWorldStats()->numActors)) {
- Shared.getScene()->setActorPosition(actorIndex, cmd->param2, cmd->param3);
- Shared.getScene()->setActorAction(actorIndex, cmd->param4);
+ Shared.getScene()->getActor()->setPostion(cmd->param2, cmd->param3);
+ Shared.getScene()->getActor()->setAction(cmd->param4);
} else
debugC(kDebugLevelScripts,
"Requested invalid actor ID:0x%02X in Scene %d Script %d Line %d.",
@@ -569,7 +569,8 @@ int kDisableActor(ActionCommand *cmd) {
else
actorIndex = cmd->param1;
- Shared.getScene()->getResources()->getMainActor()->disable(actorIndex);
+ // TODO Finish implementing this function
+ Shared.getScene()->getActor()->disable(actorIndex);
return 0;
}
Commit: a6b0965471e22915b85c74b424a1c6851cba9da4
https://github.com/scummvm/scummvm/commit/a6b0965471e22915b85c74b424a1c6851cba9da4
Author: Alex Bevilacqua (alexbevi at gmail.com)
Date: 2021-05-17T15:35:45+02:00
Commit Message:
ASYLUM: * Re-enabled updateMouse() (WIP)
* Updated return types for scripts (-1 == incomplete, -2 == unimplemented)
* Added actor method faceTarget(). This does NOT work, as the x1/y1 values are always -100 ... investigate!
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@330 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/actor.cpp
engines/asylum/actor.h
engines/asylum/scene.cpp
engines/asylum/scriptman.cpp
diff --git a/engines/asylum/actor.cpp b/engines/asylum/actor.cpp
index bfc961d44a..406c3efa83 100644
--- a/engines/asylum/actor.cpp
+++ b/engines/asylum/actor.cpp
@@ -28,6 +28,7 @@
#include "asylum/actor.h"
#include "asylum/screen.h"
#include "asylum/shared.h"
+#include "asylum/sceneres.h"
namespace Asylum {
@@ -286,5 +287,67 @@ void Actor::disable(int param) {
}
+void Actor::faceTarget(int targetId, int targetType) {
+ int newX2, newY2;
+
+ printf("faceTarget: id %d type %d\n", targetId, targetType);
+
+ if (targetType) {
+ if (targetType == 1) {
+ int actionIdx = Shared.getScene()->getResources()->getActionAreaIndexById(targetId);
+ if (actionIdx == -1) {
+ warning("No ActionArea found for id %d", targetId);
+ return;
+ }
+
+ uint32 polyIdx = Shared.getScene()->getResources()->getWorldStats()->actions[actionIdx].polyIdx;
+ PolyDefinitions *poly = &Shared.getScene()->getResources()->getGamePolygons()->polygons[polyIdx];
+
+ newX2= poly->boundingRect.left + (poly->boundingRect.right - poly->boundingRect.left) / 2;
+ newY2 = poly->boundingRect.top + (poly->boundingRect.bottom - poly->boundingRect.top) / 2;
+ } else {
+ if (targetType == 2) {
+ newX2 = x2 + x1;
+ newY2 = y2 + y1;
+ } else {
+ newX2 = newY2 = targetId;
+ }
+ }
+ } else {
+ int barrierIdx = Shared.getScene()->getResources()->getBarrierIndexById(targetId);
+ if (barrierIdx == -1) {
+ warning("No Barrier found for id %d", targetId);
+ return;
+ }
+
+ BarrierItem *barrier = Shared.getScene()->getResources()->getBarrierByIndex(barrierIdx);
+ GraphicResource *gra = new GraphicResource(_resPack, barrier->resId);
+
+ // FIXME
+ // The original actually grabs the current frame of the target
+ // barrier. I'm wondering if that's unnecessary since I'm assuming
+ // the dimensions of each frame should be the same.
+ // Investigate, though I don't think it'll be necessary since
+ // what we're trying to accomplish is a character rotation calclulation,
+ // and a size difference of a few pixels "shouldn't" affect this
+ // too much
+ GraphicFrame *fra = gra->getFrame(0);
+ delete gra;
+
+ newX2 = (fra->surface.w >> 1) + barrier->x; // TODO (x/y + 1704 * barrier) (not sure what this is pointing to)
+ newY2 = (fra->surface.h >> 1) + barrier->y; // Check .text:004088A2 for more details
+ }
+
+ printf("Calculating angle using x1(%d) x2(%d) y1(%d) y2(%d) newX(%d) newY(%d)\n", x1, x2, y1, y2, newX2, newY2);
+
+ // FIXME
+ // This just doesn't work. x1/y1 are ALWAYS -100, so I'm not sure where they're supposed
+ // to be updated.
+ int newAngle = Shared.getAngle(x2 + x1, y2 + y1, newX2, newY2);
+
+ printf("Angle calculated as %d\n", newAngle);
+
+ setDirection(newAngle);
+}
} // end of namespace Asylum
diff --git a/engines/asylum/actor.h b/engines/asylum/actor.h
index 3b7eedc662..f41ad7317e 100644
--- a/engines/asylum/actor.h
+++ b/engines/asylum/actor.h
@@ -144,6 +144,8 @@ public:
void setPostion(uint32 targetX, uint32 targetY);
void setDirection(int dir);
+ void faceTarget(int targetId, int targetType);
+
// FIXME
// I don't really like how this is used in the scene constructor
void setResourcePack(ResourcePack *res) { _resPack = res; }
diff --git a/engines/asylum/scene.cpp b/engines/asylum/scene.cpp
index ed2314f3bc..d3ad43f43f 100644
--- a/engines/asylum/scene.cpp
+++ b/engines/asylum/scene.cpp
@@ -216,9 +216,9 @@ int Scene::updateScene() {
WorldStats *worldStats = _sceneResource->getWorldStats();
// Mouse
- //startTick = Shared.getMillis();
- //updateMouse();
- //debugC(kDebugLevelScene, "UpdateMouse Time: %d", Shared.getMillis() - startTick);
+ startTick = Shared.getMillis();
+ updateMouse();
+ debugC(kDebugLevelScene, "UpdateMouse Time: %d", Shared.getMillis() - startTick);
// Actors
startTick = Shared.getMillis();
diff --git a/engines/asylum/scriptman.cpp b/engines/asylum/scriptman.cpp
index 7b62f2f0c1..a7f0bc54cf 100644
--- a/engines/asylum/scriptman.cpp
+++ b/engines/asylum/scriptman.cpp
@@ -202,7 +202,7 @@ int ScriptManager::setBarrierNextFrame(int barrierId, int barrierFlags) {
int newFlag = barrierFlags | 1 | barrier->flags;
barrier->flags |= barrierFlags | 1;
- if(newFlag & 0x10000) {
+ if (newFlag & 0x10000) {
barrier->frameIdx = barrier->frameCount - 1;
} else {
barrier->frameIdx = 0;
@@ -228,9 +228,19 @@ int ScriptManager::processActionList() {
ActionCommand *currentCommand = &_currentScript->commands[currentLine];
uint32 opcode = currentCommand->opcode;
+
+ // Execute command from function mapping
int cmdRet = function_map[opcode].function(currentCommand);
+
+ // Check function return
+ if (cmdRet == -1)
+ warning("Incomplete opcode %s (0x%02X) in Scene %d Line %d",
+ function_map[opcode].name,
+ currentCommand->opcode,
+ Shared.getScene()->getSceneIndex(),
+ currentLine);
if (cmdRet == -2)
- warning("Unhandled opcode %s (0x%02X) in Scene %d Line %d.",
+ warning("Unhandled opcode %s (0x%02X) in Scene %d Line %d",
function_map[opcode].name,
currentCommand->opcode,
Shared.getScene()->getSceneIndex(),
@@ -239,13 +249,16 @@ int ScriptManager::processActionList() {
currentLine += lineIncrement;
currentLoops++;
- } // end while
+ } // end while
if (done) {
currentLine = 0;
currentLoops = 0;
_currentScript = 0;
+ // XXX
+ // gameFlag 183 is the same as the
+ // processing flag, but is not being used
Shared.clearGameFlag(183);
}
}
@@ -390,7 +403,7 @@ int kShowCursor(ActionCommand *cmd) {
ScriptMan.allowInput = true;
// TODO clear_flag_01()
- return 0;
+ return -1;
}
int kPlayAnimation(ActionCommand *cmd) {
@@ -439,7 +452,7 @@ int kPlayAnimation(ActionCommand *cmd) {
}
}
- return 0;
+ return -1;
}
int kMoveScenePosition(ActionCommand *cmd) {
@@ -493,7 +506,7 @@ int kMoveScenePosition(ActionCommand *cmd) {
// TODO: reverse asm block
}
- return 0;
+ return -1;
}
int kHideActor(ActionCommand *cmd) {
@@ -572,7 +585,7 @@ int kDisableActor(ActionCommand *cmd) {
// TODO Finish implementing this function
Shared.getScene()->getActor()->disable(actorIndex);
- return 0;
+ return -1;
}
int kEnableActor(ActionCommand *cmd) {
@@ -622,7 +635,7 @@ int kEnableBarriers(ActionCommand *cmd) {
ScriptMan.processActionListSub02(ScriptMan.getScript(), cmd, v64);
}
- return 0;
+ return -1;
}
int kReturn(ActionCommand *cmd) {
@@ -701,7 +714,7 @@ int kJumpIfFlag2Bit0(ActionCommand *cmd) {
else
ScriptMan.done = (Shared.getScene()->getResources()->getWorldStats()->actors[cmd->param1].flags2 & 1) == 0;
- return 0;
+ return -1;
}
int kSetFlag2Bit0(ActionCommand *cmd) {
@@ -784,14 +797,14 @@ int kPlayMovie(ActionCommand *cmd) {
// TODO: add missing code here
ScriptMan.delayedVideoIndex = cmd->param1;
- return 0;
+ return -1;
}
int kStopAllBarriersSounds(ActionCommand *cmd) {
// TODO: do this for all barriers that have sfx playing
Shared.getSound()->stopSfx();
- return 0;
+ return -1;
}
int kSetActionFlag01(ActionCommand *cmd) {
@@ -838,7 +851,7 @@ int kRunBlowUpPuzzle(ActionCommand *cmd) {
Shared.getScene()->setBlowUpPuzzle(new BlowUpPuzzleVCR());
Shared.getScene()->getBlowUpPuzzle()->openBlowUp();
- return 0;
+ return -1;
}
int kJumpIfFlag2Bit3(ActionCommand *cmd) {
@@ -929,7 +942,7 @@ int kPlaySpeech(ActionCommand *cmd) {
Shared.getScene()->getSceneIndex(),
ScriptMan.currentLine);
- return 0;
+ return -1;
}
int k_unk42(ActionCommand *cmd) {
@@ -947,9 +960,17 @@ int kStartPaletteFadeThread(ActionCommand *cmd) {
int k_unk46(ActionCommand *cmd) {
return -2;
}
+
int kActorFaceObject(ActionCommand *cmd) {
- return -2;
+ // XXX
+ // Dropping param1, since it's the character index
+ // Investigate further if/when we have a scene with
+ // multiple characters in the actor[] array
+ Shared.getScene()->getActor()->faceTarget(cmd->param2, cmd->param3);
+
+ return -1;
}
+
int k_unk48_MATTE_01(ActionCommand *cmd) {
return -2;
}
@@ -975,7 +996,7 @@ int kChangeActorField40(ActionCommand *cmd) {
Shared.getScene()->getResources()->getWorldStats()->actors[actorIdx].field_40 = 4;
}
- return 0;
+ return -1;
}
int kStopSound(ActionCommand *cmd) {
@@ -1067,7 +1088,7 @@ int k_unk55(ActionCommand *cmd) {
else
ScriptMan.lineIncrement = cmd->param8;
- return 0;
+ return -1;
}
int k_unk56(ActionCommand *cmd) {
@@ -1144,7 +1165,7 @@ int k_unk61(ActionCommand *cmd) {
ScriptMan.lineIncrement = 1;
}
- return 0;
+ return -1;
}
int k_unk62_SHOW_OPTIONS_SCREEN(ActionCommand *cmd) {
Commit: 21dde9125ed13146e02793cba30c6984916ba905
https://github.com/scummvm/scummvm/commit/21dde9125ed13146e02793cba30c6984916ba905
Author: Alex Bevilacqua (alexbevi at gmail.com)
Date: 2021-05-17T15:35:46+02:00
Commit Message:
ASYLUM: Closer implementation of kSetActorStats. This actually initializes the characters x1/y1 values, which are needed by kActorFaceObject.
We REALLY need to fix the character code now though, as our initial implementation is making progress very difficult :P
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@331 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/actor.cpp
engines/asylum/actor.h
engines/asylum/scene.cpp
engines/asylum/scriptman.cpp
diff --git a/engines/asylum/actor.cpp b/engines/asylum/actor.cpp
index 406c3efa83..090d666ea4 100644
--- a/engines/asylum/actor.cpp
+++ b/engines/asylum/actor.cpp
@@ -34,7 +34,7 @@ namespace Asylum {
Actor::Actor() {
_graphic = 0;
- _currentAction = 0;
+ currentAction = 0;
_currentWalkArea = 0;
}
@@ -44,7 +44,7 @@ Actor::~Actor() {
// free _resources?
}
-void Actor::setPostion(uint32 targetX, uint32 targetY) {
+void Actor::setPosition(uint32 targetX, uint32 targetY) {
boundingRect.left = targetX;
boundingRect.top = targetY;
@@ -76,10 +76,10 @@ void Actor::setRawResources(uint8 *data) {
void Actor::setAction(int action) {
assert(_resPack);
- if (action == _currentAction)
+ if (action == currentAction)
return;
- _currentAction = action;
+ currentAction = action;
delete _graphic;
int act = (action < 100) ? action : action - 100;
@@ -87,22 +87,22 @@ void Actor::setAction(int action) {
_graphic = new GraphicResource(_resPack, _resources[act]);
// Flip horizontally if necessary
- if (_currentAction > 100) {
+ if (currentAction > 100) {
for (uint32 i = 0; i < _graphic->getFrameCount(); i++) {
GraphicFrame *frame = _graphic->getFrame(i);
byte *buffer = (byte *)frame->surface.pixels;
- for (int y = 0; y < frame->surface.h; y++) {
+ for (int tmpY = 0; tmpY < frame->surface.h; tmpY++) {
int w = frame->surface.w / 2;
- for (int x = 0; x < w; x++) {
- SWAP(buffer[y * frame->surface.pitch + x],
- buffer[y * frame->surface.pitch + frame->surface.w - 1 - x]);
+ for (int tmpX = 0; tmpX < w; tmpX++) {
+ SWAP(buffer[tmpY * frame->surface.pitch + tmpX],
+ buffer[tmpY * frame->surface.pitch + frame->surface.w - 1 - tmpX]);
}
}
}
}
- _currentFrame = 0;
+ frameNum = 0;
}
void Actor::setActionByIndex(int index) {
@@ -112,17 +112,17 @@ void Actor::setActionByIndex(int index) {
GraphicFrame *Actor::getFrame() {
assert(_graphic);
- GraphicFrame *frame = _graphic->getFrame(_currentFrame);
+ GraphicFrame *frame = _graphic->getFrame(frameNum);
- if (_currentFrame < _graphic->getFrameCount() - 1) {
- _currentFrame++;
+ if (frameNum < _graphic->getFrameCount() - 1) {
+ frameNum++;
}else{
- _currentFrame = 0;
+ frameNum = 0;
}
// HACK: frame 1 of the "walk west" animation is misplaced
- if ((_currentAction == kWalkW || _currentAction == kWalkE) && _currentFrame == 1)
- _currentFrame++;
+ if ((currentAction == kWalkW || currentAction == kWalkE) && frameNum == 1)
+ frameNum++;
return frame;
}
@@ -162,7 +162,7 @@ void Actor::setWalkArea(ActionArea *target) {
}
void Actor::walkTo(uint16 curX, uint16 curY) {
- int newAction = _currentAction;
+ int newAction = currentAction;
// step is the increment by which to move the
// actor in a given direction
@@ -190,9 +190,9 @@ void Actor::walkTo(uint16 curX, uint16 curY) {
// Walking up...
if (curY < y && !done) {
- if (newAction != _currentAction && newAction == kWalkW && x - curX > 30)
+ if (newAction != currentAction && newAction == kWalkW && x - curX > 30)
newAction = kWalkNW; // up left
- else if (newAction != _currentAction && newAction == kWalkE && curX - x > 30)
+ else if (newAction != currentAction && newAction == kWalkE && curX - x > 30)
newAction = kWalkNE; // up right
else
newAction = kWalkN;
@@ -202,9 +202,9 @@ void Actor::walkTo(uint16 curX, uint16 curY) {
// Walking down...
if (curY > y && !done) {
- if (newAction != _currentAction && newAction == kWalkW && x - curX > 30)
+ if (newAction != currentAction && newAction == kWalkW && x - curX > 30)
newAction = kWalkSW; // down left
- else if (newAction != _currentAction && newAction == kWalkE && curX - x > 30)
+ else if (newAction != currentAction && newAction == kWalkE && curX - x > 30)
newAction = kWalkSE; // down right
else
newAction = kWalkS;
@@ -287,6 +287,18 @@ void Actor::disable(int param) {
}
+void Actor::setPosition_40A260(uint32 newX, uint32 newY, int newDirection, int frame) {
+ x1 = newX - x2;
+ y1 = newY - y2;
+
+ if (direction != 8) {
+ // TODO implement the propert character_setDirection() functionality
+ setAction(newDirection);
+ }
+ if (frame > 0)
+ frameNum = frame;
+}
+
void Actor::faceTarget(int targetId, int targetType) {
int newX2, newY2;
@@ -338,11 +350,6 @@ void Actor::faceTarget(int targetId, int targetType) {
newY2 = (fra->surface.h >> 1) + barrier->y; // Check .text:004088A2 for more details
}
- printf("Calculating angle using x1(%d) x2(%d) y1(%d) y2(%d) newX(%d) newY(%d)\n", x1, x2, y1, y2, newX2, newY2);
-
- // FIXME
- // This just doesn't work. x1/y1 are ALWAYS -100, so I'm not sure where they're supposed
- // to be updated.
int newAngle = Shared.getAngle(x2 + x1, y2 + y1, newX2, newY2);
printf("Angle calculated as %d\n", newAngle);
diff --git a/engines/asylum/actor.h b/engines/asylum/actor.h
index f41ad7317e..73eb15c3b9 100644
--- a/engines/asylum/actor.h
+++ b/engines/asylum/actor.h
@@ -141,9 +141,15 @@ public:
bool visible() { return flags & 0x01; }
void visible(bool value);
- void setPostion(uint32 targetX, uint32 targetY);
+ void setPosition(uint32 targetX, uint32 targetY);
void setDirection(int dir);
+ /**
+ * Initialize the x1/y1 values of the actor, update the active animation frame
+ * and, if the current direction isn't 8, update the actor's direction
+ */
+ void setPosition_40A260(uint32 newX, uint32 newY, int newDirection, int frame);
+
void faceTarget(int targetId, int targetType);
// FIXME
@@ -151,7 +157,9 @@ public:
void setResourcePack(ResourcePack *res) { _resPack = res; }
// OLD METHODS
- void setWalkArea(ActionArea *target); // TODO depreciate
+ // TODO ALL of these need to be depreciated in favour
+ // of the proper functions from the original
+ void setWalkArea(ActionArea *target);
void setAction(int action);
void setActionByIndex(int index);
void drawActorAt(uint16 curX, uint16 curY);
@@ -159,7 +167,7 @@ public:
void walkTo(uint16 curX, uint16 curY);
void disable(int param);
- int getCurrentAction() { return _currentAction; }
+ int currentAction; // TODO depreciate
uint32 x;
uint32 y;
@@ -174,7 +182,7 @@ public:
Common::Rect boundingRect;
uint32 direction;
uint32 field_3C;
- uint32 field_40;
+ uint32 field_40; // XXX Character Id???
uint32 field_44;
uint32 field_48;
uint32 flags;
@@ -216,8 +224,6 @@ private:
ResourcePack *_resPack;
GraphicResource *_graphic;
uint32 _resources[61];
- uint8 _currentFrame;
- int _currentAction;
ActionArea *_currentWalkArea;
GraphicFrame *getFrame();
diff --git a/engines/asylum/scene.cpp b/engines/asylum/scene.cpp
index d3ad43f43f..39c2fe3c95 100644
--- a/engines/asylum/scene.cpp
+++ b/engines/asylum/scene.cpp
@@ -243,9 +243,13 @@ int Scene::updateScene() {
debugC(kDebugLevelScene, "UpdateMusic Time: %d", Shared.getMillis() - startTick);
// Adjust Screen
- startTick = Shared.getMillis();
- updateAdjustScreen();
- debugC(kDebugLevelScene, "AdjustScreenStart Time: %d", Shared.getMillis() - startTick);
+ //startTick = Shared.getMillis();
+ // FIXME
+ // Commented out the (incomplete) update screen code because once the
+ // actor's x1/y1 values are properly set, the temp code causes a crash
+ // Have to finish implementing the method I guess :P
+ //updateAdjustScreen();
+ //debugC(kDebugLevelScene, "AdjustScreenStart Time: %d", Shared.getMillis() - startTick);
if(ScriptMan.processActionList())
return 1;
@@ -390,39 +394,41 @@ void Scene::updateMouse() {
}
void Scene::updateActor(uint32 actorIdx) {
- WorldStats *worldStats = _sceneResource->getWorldStats();
- Actor *actor = getActor();
+ WorldStats *ws = _sceneResource->getWorldStats();
+ Actor *actor = getActor();
if (actor->visible()) {
+ //printf("Actor field_40 = 0x%02X\n", actor->field_40);
+
switch (actor->field_40) {
case 0x10:
- if (worldStats->numChapter == 2) {
+ if (ws->numChapter == 2) {
// TODO: updateCharacterSub14()
- } else if (worldStats->numChapter == 1) {
+ } else if (ws->numChapter == 1) {
if (_playerActorIdx == actorIdx) {
// TODO: updateActorSub21();
}
}
break;
case 0x11:
- if (worldStats->numChapter == 2) {
+ if (ws->numChapter == 2) {
// TODO: put code here
- } else if (worldStats->numChapter == 11) {
+ } else if (ws->numChapter == 11) {
if (_playerActorIdx == actorIdx) {
// TODO: put code here
}
}
break;
case 0xF:
- if (worldStats->numChapter == 2) {
+ if (ws->numChapter == 2) {
// TODO: put code here
- } else if (worldStats->numChapter == 11) {
+ } else if (ws->numChapter == 11) {
// TODO: put code here
}
break;
case 0x12:
- if (worldStats->numChapter == 2) {
+ if (ws->numChapter == 2) {
// TODO: put code here
}
break;
@@ -439,9 +445,9 @@ void Scene::updateActor(uint32 actorIdx) {
}
break;
case 0xC:
- if (worldStats->numChapter == 2) {
+ if (ws->numChapter == 2) {
// TODO: put code here
- } else if (worldStats->numChapter == 11) {
+ } else if (ws->numChapter == 11) {
// TODO: put code here
}
case 0x1:
@@ -678,6 +684,129 @@ void Scene::updateMusic() {
}
void Scene::updateAdjustScreen() {
+ WorldStats *ws = _sceneResource->getWorldStats();
+
+ int v5, v6, v7, v15, v16;
+ int v1 = -1;
+ int v0 = -1;
+
+ if (ws->motionStatus == 1) {
+ v5 = getActor()->x1 - ws->xLeft;
+ v7 = getActor()->y1 - ws->yTop;
+ if (v5 < ws->boundingRect.left || v5 > ws->boundingRect.right) {
+ v15 = ws->boundingRect.left - ws->boundingRect.right;
+ v1 = v15 + ws->xLeft;
+ ws->xLeft += v15;
+ }
+ if (v7 < ws->boundingRect.top || v7 > ws->boundingRect.bottom) {
+ v16 = v7 - ws->boundingRect.bottom;
+ v0 = v16 + ws->yTop;
+ ws->yTop += v16;
+ }
+ if (v1 < 0)
+ v1 = ws->xLeft = 0;
+ if (v1 > ws->width - 640) {
+ v1 = ws->width - 640;
+ ws->xLeft = v1;
+ }
+ if (v0 < 0)
+ v0 = ws->yTop = 0;
+ if (v0 > ws->height - 480) {
+ v0 = ws->height - 480;
+ ws->yTop = v0;
+ }
+ } else {
+ if (ws->motionStatus == 2 || ws->motionStatus == 5) {
+ if (ws->motionStatus != 3) {
+ // TODO
+ /*
+ __asm
+ {
+ fld flt_543514
+ fadd flt_543518
+ fstp flt_543514
+ fild scene.field_98
+ fsubr flt_54350C
+ fild scene.field_9C
+ fsubr flt_543510
+ }
+ v12 = abs(_ftol());
+ if ( v12 <= abs(_ftol()) )
+ {
+ v2 = scene.field_9C;
+ if ( scene.field_9C != scene.yTop )
+ {
+ __asm
+ {
+ fld flt_543514
+ fadd flt_54350C
+ }
+ v14 = _ftol();
+ v1 = v14;
+ scene.xLeft = v14;
+ }
+ v4 = scene.field_A0;
+ v0 += scene.field_A0;
+ scene.yTop = v0;
+ v3 = v0;
+ }
+ else
+ {
+ v2 = scene.field_98;
+ if ( scene.field_98 != scene.xLeft )
+ {
+ __asm
+ {
+ fld flt_543514
+ fadd flt_543510
+ }
+ v13 = _ftol();
+ v0 = v13;
+ scene.yTop = v13;
+ }
+ v4 = scene.field_A0;
+ v1 += scene.field_A0;
+ scene.xLeft = v1;
+ v3 = v1;
+ }
+ if ( abs(v3 - v2) <= abs(v4) )
+ {
+ scene.field_88 = 3;
+ scene.field_98 = -1;
+ }
+ }
+ */
+ }
+ }
+ }
+ /*
+ v9 = 16 * scene.sceneRectIndex;
+ if ( v1 < *(LONG *)((char *)&scene.sceneRects[0].left + v9) )
+ {
+ v1 = *(LONG *)((char *)&scene.sceneRects[0].left + v9);
+ scene.xLeft = *(LONG *)((char *)&scene.sceneRects[0].left + v9);
+ }
+ if ( v0 < *(LONG *)((char *)&scene.sceneRects[0].top + v9) )
+ {
+ v0 = *(LONG *)((char *)&scene.sceneRects[0].top + v9);
+ scene.yTop = *(LONG *)((char *)&scene.sceneRects[0].top + v9);
+ }
+ v10 = *(LONG *)((char *)&scene.sceneRects[0].right + v9);
+ if ( v1 + 639 > v10 )
+ {
+ v1 = v10 - 639;
+ scene.xLeft = v10 - 639;
+ }
+ result = *(LONG *)((char *)&scene.sceneRects[0].bottom + v9);
+ if ( v0 + 479 > result )
+ {
+ v0 = result - 479;
+ scene.yTop = result - 479;
+ }
+ if ( v17 != v1 || v18 != v0 )
+ dword_44E1EC = 2
+
+ */
}
@@ -704,9 +833,8 @@ void Scene::OLD_UPDATE(WorldStats *worldStats) {
// was released. If so, change the resource to one where he/she
// is standing still, facing the last active direction
if (_walking) {
- int currentAction = getActor()->getCurrentAction();
- if (currentAction > 0)
- getActor()->setAction(currentAction + 5);
+ if (getActor()->currentAction > 0)
+ getActor()->setAction(getActor()->currentAction + 5);
_walking = false;
}
getActor()->drawActor();
@@ -799,11 +927,14 @@ int Scene::drawScene() {
Shared.getScreen()->clearScreen();
} else {
// Draw scene background
- WorldStats *worldStats = _sceneResource->getWorldStats();
+ WorldStats *ws = _sceneResource->getWorldStats();
GraphicFrame *bg = _bgResource->getFrame(0);
Shared.getScreen()->copyToBackBuffer(
- ((byte *)bg->surface.pixels) + _startY * bg->surface.w + _startX, bg->surface.w, worldStats->xLeft,
- worldStats->yTop, 640, 480);
+ ((byte *)bg->surface.pixels) + _startY * bg->surface.w + _startX, bg->surface.w,
+ ws->xLeft,
+ ws->yTop,
+ 640,
+ 480);
// DEBUG
// Force the screen to scroll if the mouse approaches the edges
@@ -817,7 +948,7 @@ int Scene::drawScene() {
Shared.getScreen()->drawGraphicsInQueue();
// TODO: we must get rid of this
- OLD_UPDATE(worldStats);
+ OLD_UPDATE(ws);
}
return 1;
diff --git a/engines/asylum/scriptman.cpp b/engines/asylum/scriptman.cpp
index a7f0bc54cf..a12323e1ad 100644
--- a/engines/asylum/scriptman.cpp
+++ b/engines/asylum/scriptman.cpp
@@ -229,6 +229,10 @@ int ScriptManager::processActionList() {
uint32 opcode = currentCommand->opcode;
+ warning("Processing opcode %s (0x%02X)",
+ function_map[opcode].name,
+ currentCommand->opcode);
+
// Execute command from function mapping
int cmdRet = function_map[opcode].function(currentCommand);
@@ -548,24 +552,18 @@ int kShowActor(ActionCommand *cmd) {
}
int kSetActorStats(ActionCommand *cmd) {
- uint32 actorIndex = 0;
+ // TODO
+ // param1 == actorIndex. Implement when we've got more than one actor
- if (cmd->param1 == -1)
- ;//actorIndex = Shared.getScene()->getWorldStats()->playerActor;
- else
- actorIndex = cmd->param1;
+ // TODO This needs to be depreciated, but it's setting the actor's x/y
+ // and bounding rect top/left.
+ // This needs to be rolled into the proper place
+ Shared.getScene()->getActor()->setPosition(cmd->param2, cmd->param3);
- if ((actorIndex >= 0) && (actorIndex < Shared.getScene()->getResources()->getWorldStats()->numActors)) {
- Shared.getScene()->getActor()->setPostion(cmd->param2, cmd->param3);
- Shared.getScene()->getActor()->setAction(cmd->param4);
- } else
- debugC(kDebugLevelScripts,
- "Requested invalid actor ID:0x%02X in Scene %d Script %d Line %d.",
- cmd->param1,
- Shared.getScene()->getSceneIndex(),
- ScriptMan.currentLine);
+ Shared.getScene()->getActor()->setPosition_40A260(cmd->param2, cmd->param3, cmd->param4, cmd->param5);
- return 0;
+ // XXX Returning -1 since the setPosition logic isn't fully implemented
+ return -1;
}
int kSetSceneMotionStat(ActionCommand *cmd) {
Commit: bfec665d5019bfee8739d9c1f8f35fdfaaabca2d
https://github.com/scummvm/scummvm/commit/bfec665d5019bfee8739d9c1f8f35fdfaaabca2d
Author: Alex Bevilacqua (alexbevi at gmail.com)
Date: 2021-05-17T15:35:46+02:00
Commit Message:
ASYLUM: Renamed actor->disable() to actor->update_4072A0. Also added the assignment to field_40 at the end of that method (as in the original). Still a lot of work to do here though ;)
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@332 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/actor.cpp
engines/asylum/actor.h
engines/asylum/scene.cpp
engines/asylum/scriptman.cpp
diff --git a/engines/asylum/actor.cpp b/engines/asylum/actor.cpp
index 090d666ea4..81df4d50bb 100644
--- a/engines/asylum/actor.cpp
+++ b/engines/asylum/actor.cpp
@@ -272,7 +272,7 @@ void Actor::walkTo(uint16 curX, uint16 curY) {
drawActor();
}
-void Actor::disable(int param) {
+void Actor::update_4072A0(int param) {
switch (param) {
case 5:
@@ -285,6 +285,7 @@ void Actor::disable(int param) {
}
+ field_40 = param;
}
void Actor::setPosition_40A260(uint32 newX, uint32 newY, int newDirection, int frame) {
@@ -315,7 +316,7 @@ void Actor::faceTarget(int targetId, int targetType) {
uint32 polyIdx = Shared.getScene()->getResources()->getWorldStats()->actions[actionIdx].polyIdx;
PolyDefinitions *poly = &Shared.getScene()->getResources()->getGamePolygons()->polygons[polyIdx];
- newX2= poly->boundingRect.left + (poly->boundingRect.right - poly->boundingRect.left) / 2;
+ newX2 = poly->boundingRect.left + (poly->boundingRect.right - poly->boundingRect.left) / 2;
newY2 = poly->boundingRect.top + (poly->boundingRect.bottom - poly->boundingRect.top) / 2;
} else {
if (targetType == 2) {
diff --git a/engines/asylum/actor.h b/engines/asylum/actor.h
index 73eb15c3b9..9e07ff2b12 100644
--- a/engines/asylum/actor.h
+++ b/engines/asylum/actor.h
@@ -149,6 +149,7 @@ public:
* and, if the current direction isn't 8, update the actor's direction
*/
void setPosition_40A260(uint32 newX, uint32 newY, int newDirection, int frame);
+ void update_4072A0(int param);
void faceTarget(int targetId, int targetType);
@@ -165,7 +166,7 @@ public:
void drawActorAt(uint16 curX, uint16 curY);
void drawActor();
void walkTo(uint16 curX, uint16 curY);
- void disable(int param);
+
int currentAction; // TODO depreciate
diff --git a/engines/asylum/scene.cpp b/engines/asylum/scene.cpp
index 39c2fe3c95..aebe07f99e 100644
--- a/engines/asylum/scene.cpp
+++ b/engines/asylum/scene.cpp
@@ -222,9 +222,8 @@ int Scene::updateScene() {
// Actors
startTick = Shared.getMillis();
- for (uint32 a = 0; a < worldStats->numActors; a++) {
+ for (uint32 a = 0; a < worldStats->numActors; a++)
updateActor(a);
- }
debugC(kDebugLevelScene, "UpdateActors Time: %d", Shared.getMillis() - startTick);
// Barriers
@@ -398,7 +397,7 @@ void Scene::updateActor(uint32 actorIdx) {
Actor *actor = getActor();
if (actor->visible()) {
- //printf("Actor field_40 = 0x%02X\n", actor->field_40);
+ // printf("Actor field_40 = 0x%02X\n", actor->field_40);
switch (actor->field_40) {
diff --git a/engines/asylum/scriptman.cpp b/engines/asylum/scriptman.cpp
index a12323e1ad..c59be5a86a 100644
--- a/engines/asylum/scriptman.cpp
+++ b/engines/asylum/scriptman.cpp
@@ -581,7 +581,7 @@ int kDisableActor(ActionCommand *cmd) {
actorIndex = cmd->param1;
// TODO Finish implementing this function
- Shared.getScene()->getActor()->disable(actorIndex);
+ Shared.getScene()->getActor()->update_4072A0(actorIndex);
return -1;
}
Commit: 7c330b4b8a0f9c9e98895379d9774ec37ca102b8
https://github.com/scummvm/scummvm/commit/7c330b4b8a0f9c9e98895379d9774ec37ca102b8
Author: Alex Bevilacqua (alexbevi at gmail.com)
Date: 2021-05-17T15:35:46+02:00
Commit Message:
ASYLUM: Refactored BarrierItem into it's own class. Also moved the sound item structs into sound.h
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@333 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
A engines/asylum/barrier.cpp
A engines/asylum/barrier.h
engines/asylum/actor.cpp
engines/asylum/encounters.cpp
engines/asylum/module.mk
engines/asylum/scene.cpp
engines/asylum/sceneres.cpp
engines/asylum/sceneres.h
engines/asylum/scriptman.cpp
engines/asylum/sound.h
diff --git a/engines/asylum/actor.cpp b/engines/asylum/actor.cpp
index 81df4d50bb..0f3341b30a 100644
--- a/engines/asylum/actor.cpp
+++ b/engines/asylum/actor.cpp
@@ -333,7 +333,7 @@ void Actor::faceTarget(int targetId, int targetType) {
return;
}
- BarrierItem *barrier = Shared.getScene()->getResources()->getBarrierByIndex(barrierIdx);
+ Barrier *barrier = Shared.getScene()->getResources()->getBarrierByIndex(barrierIdx);
GraphicResource *gra = new GraphicResource(_resPack, barrier->resId);
// FIXME
diff --git a/engines/asylum/barrier.cpp b/engines/asylum/barrier.cpp
new file mode 100644
index 0000000000..d08c6c2bce
--- /dev/null
+++ b/engines/asylum/barrier.cpp
@@ -0,0 +1,83 @@
+/* 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.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#include "asylum/barrier.h"
+#include "asylum/shared.h"
+
+namespace Asylum {
+
+Barrier::Barrier() {
+ // TODO Auto-generated constructor stub
+
+}
+
+Barrier::~Barrier() {
+ // TODO Auto-generated destructor stub
+}
+
+bool Barrier::visible() {
+ if ((flags & 0xFF) & 1) {
+ for (int f = 0; f < 10; f++) {
+ bool isSet = false;
+ uint32 flag = gameFlags[f];
+
+ if (flag <= 0)
+ isSet = Shared.isGameFlagNotSet(flag); // -flag
+ else
+ isSet = Shared.isGameFlagSet(flag);
+
+ if(!isSet)
+ return false;
+ }
+ return true;
+ }
+ return false;
+}
+
+uint32 Barrier::getRandomId() {
+ int numRes = 0;
+ uint32 rndResId[5];
+ memset(&rndResId, 0, sizeof(rndResId));
+ for (int i = 0; i < 5; i++) {
+ if (field_68C[i]) {
+ rndResId[numRes] = field_68C[i];
+ numRes++;
+ }
+ }
+ if(numRes > 0)
+ return rndResId[rand() % numRes];
+
+ return resId;
+}
+
+bool Barrier::onscreen() {
+ WorldStats *ws = Shared.getScene()->getResources()->getWorldStats();
+ Common::Rect screenRect = Common::Rect(ws->xLeft, ws->yTop, ws->xLeft + 640, ws->yTop + 480);
+ Common::Rect barrierRect = boundingRect;
+ barrierRect.translate(x, y);
+ return visible() && (flags & 1) && screenRect.intersects(barrierRect);
+}
+
+} // end of namespace Asylum
diff --git a/engines/asylum/barrier.h b/engines/asylum/barrier.h
new file mode 100644
index 0000000000..5c9ff758e2
--- /dev/null
+++ b/engines/asylum/barrier.h
@@ -0,0 +1,83 @@
+/* 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.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#ifndef ASYLUM_BARRIER_H_
+#define ASYLUM_BARRIER_H_
+
+#include "asylum/sound.h"
+
+namespace Asylum {
+
+class Barrier {
+public:
+ Barrier();
+ virtual ~Barrier();
+
+ bool visible();
+ uint32 getRandomId(); // TODO Give this a better name?
+ bool onscreen();
+
+ uint32 id;
+ uint32 resId;
+ uint32 x;
+ uint32 y;
+ Common::Rect boundingRect;
+ uint32 field_20;
+ uint32 frameIdx;
+ uint32 frameCount;
+ uint32 field_2C;
+ uint32 field_30;
+ uint32 field_34;
+ uint32 flags;
+ uint32 field_3C;
+ uint8 name[52]; // field_40 till field_70;
+ uint32 field_74;
+ uint32 field_78;
+ uint32 field_7C;
+ uint32 field_80;
+ uint32 polyIdx;
+ uint32 flags2;
+ uint32 gameFlags[10];
+ uint32 field_B4;
+ uint32 tickCount;
+ uint32 tickCount2;
+ uint32 field_C0;
+ uint32 priority;
+ uint32 actionListIdx;
+ SoundItem soundItems[16];
+ FrameSoundItem frameSoundItems[50];
+ uint32 field_67C;
+ uint32 soundX;
+ uint32 soundY;
+ uint32 field_688;
+ uint32 field_68C[5];
+ uint32 soundResId;
+ uint32 field_6A4;
+
+}; // end of class Barrier
+
+} // end of namespace Asylum
+
+#endif /* ASYLUM_BARRIER_H_ */
diff --git a/engines/asylum/encounters.cpp b/engines/asylum/encounters.cpp
index de105d6bb8..42a40e3892 100644
--- a/engines/asylum/encounters.cpp
+++ b/engines/asylum/encounters.cpp
@@ -76,7 +76,7 @@ void Encounter::run(int encounterIdx, int barrierId1, int barrierId2, int charac
setVariable(1, 0);
setVariable(2, _currentEncounter->value);
- BarrierItem *b1 = _scene->getResources()->getBarrierById(barrierId1);
+ Barrier *b1 = _scene->getResources()->getBarrierById(barrierId1);
/*
int __cdecl runEncounter(int newMessageHandler, int encounterIndex, int objectId1, int objectId2, int characterIndex)
{
diff --git a/engines/asylum/module.mk b/engines/asylum/module.mk
index eb7fd4dbe5..6c70afa048 100644
--- a/engines/asylum/module.mk
+++ b/engines/asylum/module.mk
@@ -8,6 +8,7 @@ MODULE_OBJS := \
menu.o \
respack.o \
scene.o \
+ barrier.o \
sceneres.o \
screen.o \
sound.o \
diff --git a/engines/asylum/scene.cpp b/engines/asylum/scene.cpp
index aebe07f99e..2f51783e99 100644
--- a/engines/asylum/scene.cpp
+++ b/engines/asylum/scene.cpp
@@ -84,7 +84,7 @@ Scene::Scene(uint8 sceneIdx) {
if (worldStats->numBarriers > 0) {
uint32 priority = 0x0FFB;
for (uint32 b = 0; b < worldStats->numBarriers; b++) {
- BarrierItem *barrier = &worldStats->barriers[b];
+ Barrier *barrier = &worldStats->barriers[b];
barrier->priority = priority;
barrier->flags &= 0xFFFF3FFF;
priority -= 4;
@@ -490,52 +490,6 @@ void Scene::updateActor(uint32 actorIdx) {
}
}
-bool Scene::isBarrierVisible(BarrierItem *barrier) {
- if ((barrier->flags & 0xFF) & 1) {
- for (uint32 f = 0; f < 10; f++) {
- bool isSet = false;
- uint32 flag = barrier->gameFlags[f];
-
- if (flag <= 0) {
- isSet = Shared.isGameFlagNotSet(flag); // -flag
- } else {
- isSet = Shared.isGameFlagSet(flag);
- }
-
- if(!isSet) {
- return false;
- }
- }
-
- return true;
- }
- return false;
-}
-
-bool Scene::isBarrierOnScreen(BarrierItem *barrier) {
- WorldStats *worldStats = _sceneResource->getWorldStats();
- Common::Rect screenRect = Common::Rect(worldStats->xLeft, worldStats->yTop, worldStats->xLeft + 640, worldStats->yTop + 480);
- Common::Rect barrierRect = barrier->boundingRect;
- barrierRect.translate(barrier->x, barrier->y);
- return isBarrierVisible(barrier) && (barrier->flags & 1) && screenRect.intersects(barrierRect);
-}
-
-uint32 Scene::getRandomResId(BarrierItem *barrier) {
- int numRes = 0;
- uint32 rndResId[5];
- memset(&rndResId, 0, sizeof(rndResId));
- for (int i = 0; i < 5; i++) {
- if (barrier->field_68C[i]) {
- rndResId[numRes] = barrier->field_68C[i];
- numRes++;
- }
- }
- if(numRes > 0)
- return rndResId[rand() % numRes];
-
- return barrier->resId;
-}
-
void Scene::updateBarriers(WorldStats *worldStats) {
Screen *screen = Shared.getScreen();
@@ -545,10 +499,10 @@ void Scene::updateBarriers(WorldStats *worldStats) {
if (barriersCount > 0) {
for (uint32 b = 0; b < barriersCount; b++) {
- BarrierItem *barrier = &worldStats->barriers[b];
+ Barrier *barrier = &worldStats->barriers[b];
if (barrier->field_3C == 4) {
- if (isBarrierVisible(barrier)) {
+ if (barrier->visible()) {
uint32 flag = barrier->flags;
if (flag & 0x20) {
if (barrier->field_B4 && (Shared.getMillis() - barrier->tickCount >= 0x3E8 / barrier->field_B4)) {
@@ -567,7 +521,7 @@ void Scene::updateBarriers(WorldStats *worldStats) {
// TODO: fix this, and find a better way to get frame count
// Sometimes we get wrong random resource id
- barrier->resId = getRandomResId(barrier);
+ barrier->resId = barrier->getRandomId();
GraphicResource *gra = new GraphicResource(_resPack, barrier->resId);
barrier->frameCount = gra->getFrameCount();
delete gra;
@@ -852,7 +806,7 @@ void Scene::OLD_UPDATE(WorldStats *worldStats) {
// Check if we're within a barrier
for (uint32 p = 0; p < worldStats->numBarriers; p++) {
- BarrierItem b = worldStats->barriers[p];
+ Barrier b = worldStats->barriers[p];
if (b.flags & 0x20) {
if ((b.boundingRect.left + b.x <= _cursor->x() + _startX) &&
(_cursor->x() + _startX < b.boundingRect.right + b.x) &&
@@ -902,7 +856,7 @@ void Scene::OLD_UPDATE(WorldStats *worldStats) {
}
}
} else if (curBarrier >= 0) {
- BarrierItem b = worldStats->barriers[curBarrier];
+ Barrier b = worldStats->barriers[curBarrier];
debugC(kDebugLevelScripts, "%s: action(%d) sound(%d) flags(%d/%d)\n",
b.name,
b.actionListIdx,
@@ -959,10 +913,10 @@ int Scene::drawBarriers() {
if (barriersCount > 0) {
for (uint32 b = 0; b < barriersCount; b++) {
- BarrierItem *barrier = &worldStats->barriers[b];
+ Barrier *barrier = &worldStats->barriers[b];
if (!(barrier->flags & 4) && !((barrier->flags & 0xFF) & 0x40)) {
- if (isBarrierOnScreen(barrier)) {
+ if (barrier->onscreen()) {
//TODO: need to do something here yet
if (barrier->field_67C <= 0 || barrier->field_67C >= 4) { // TODO: still missing a condition for game quality config
@@ -1081,7 +1035,7 @@ void Scene::debugShowPolygons() {
void Scene::debugShowBarriers() {
for (uint32 p = 0; p < _sceneResource->getWorldStats()->numBarriers; p++) {
Graphics::Surface surface;
- BarrierItem b = _sceneResource->getWorldStats()->barriers[p];
+ Barrier b = _sceneResource->getWorldStats()->barriers[p];
if (b.flags & 0x20) {
surface.create(b.boundingRect.right - b.boundingRect.left + 1,
diff --git a/engines/asylum/sceneres.cpp b/engines/asylum/sceneres.cpp
index cd7ba67d76..ef0c9f749a 100644
--- a/engines/asylum/sceneres.cpp
+++ b/engines/asylum/sceneres.cpp
@@ -61,11 +61,11 @@ int SceneResource::getBarrierIndexById(uint32 id) {
return -1;
}
-BarrierItem* SceneResource::getBarrierById(uint32 id) {
+Barrier* SceneResource::getBarrierById(uint32 id) {
return &_worldStats->barriers[getBarrierIndexById(id)];
}
-BarrierItem* SceneResource::getBarrierByIndex(uint32 idx) {
+Barrier* SceneResource::getBarrierByIndex(uint32 idx) {
return &_worldStats->barriers[idx];
}
@@ -211,7 +211,7 @@ void SceneResource::loadWorldStats(Common::SeekableReadStream *stream) {
for (uint32 a = 0; a < _worldStats->numBarriers; a++) {
int i;
- BarrierItem barrier;
+ Barrier barrier;
barrier.id = stream->readUint32LE();
barrier.resId = stream->readUint32LE();
diff --git a/engines/asylum/sceneres.h b/engines/asylum/sceneres.h
index 9ae9b0f5e6..25cb0fc27d 100644
--- a/engines/asylum/sceneres.h
+++ b/engines/asylum/sceneres.h
@@ -31,6 +31,7 @@
#include "common/rect.h"
#include "asylum/actor.h"
+#include "asylum/barrier.h"
#include "asylum/screen.h"
#include "asylum/respack.h"
@@ -44,7 +45,6 @@ class AsylumEngine;
class WorldStats;
class GamePolygons;
class ActionList;
-struct BarrierItem;
struct ActionArea;
class SceneResource {
@@ -61,8 +61,8 @@ public:
int getBarrierIndexById(uint32 id);
int getActionAreaIndexById(uint32 id);
ActionArea* getActionAreaById(uint32 id);
- BarrierItem* getBarrierById(uint32 id);
- BarrierItem* getBarrierByIndex(uint32 idx);
+ Barrier* getBarrierById(uint32 id);
+ Barrier* getBarrierByIndex(uint32 idx);
private:
@@ -78,78 +78,6 @@ private:
}; // end of class Scene
-typedef struct SoundItem {
- uint32 resId;
- uint32 field_4;
- uint32 field_8;
- uint32 field_C;
-
-} SoundItem;
-
-typedef struct FrameSoundItem {
- uint32 resId;
- uint32 frameIdx;
- uint32 index;
- uint32 field_C;
- uint32 field_10;
- uint32 field_14;
-
-} FrameSoundItem;
-
-typedef struct AmbientSoundItem {
- uint32 field_0;
- uint32 flags;
- uint32 resId;
- uint32 field_C;
- uint32 field_10;
- uint32 field_14;
- uint32 flagNum[6];
- uint32 x;
- uint32 y;
-
-} AmbientSoundItem;
-
-// FIXME figure out unknown fields
-typedef struct BarrierItem {
- uint32 id;
- uint32 resId;
- uint32 x;
- uint32 y;
- Common::Rect boundingRect;
- uint32 field_20;
- uint32 frameIdx;
- uint32 frameCount;
- uint32 field_2C;
- uint32 field_30;
- uint32 field_34;
- uint32 flags;
- uint32 field_3C;
- uint8 name[52]; // field_40 till field_70;
- uint32 field_74;
- uint32 field_78;
- uint32 field_7C;
- uint32 field_80;
- uint32 polyIdx;
- uint32 flags2;
- uint32 gameFlags[10];
- uint32 field_B4;
- uint32 tickCount;
- uint32 tickCount2;
- uint32 field_C0;
- uint32 priority;
- uint32 actionListIdx;
- SoundItem soundItems[16];
- FrameSoundItem frameSoundItems[50];
- uint32 field_67C;
- uint32 soundX;
- uint32 soundY;
- uint32 field_688;
- uint32 field_68C[5];
- uint32 soundResId;
- uint32 field_6A4;
-
-} BarrierItem;
-
typedef struct CommonResources {
uint32 backgroundImage;
uint32 curScrollUp;
@@ -231,10 +159,10 @@ public:
// FIXME: Investigate if we need to actually reserve maxsize for this arrays.
// It always have that size under scene file and they are always save in savegames.
- Common::Array<BarrierItem> barriers; // maxsize 400
- Common::Array<Actor> actors; // maxsize 50
+ Common::Array<Barrier> barriers; // maxsize 400
+ Common::Array<Actor> actors; // maxsize 50
// TODO add rest fields
- Common::Array<ActionArea> actions; // maxsize 400
+ Common::Array<ActionArea> actions; // maxsize 400
// TODO add rest fields
uint32 field_E860C;
// TODO add rest fields
diff --git a/engines/asylum/scriptman.cpp b/engines/asylum/scriptman.cpp
index c59be5a86a..6673a9bc53 100644
--- a/engines/asylum/scriptman.cpp
+++ b/engines/asylum/scriptman.cpp
@@ -198,7 +198,7 @@ int ScriptManager::checkBarrierFlags(int barrierId) {
int ScriptManager::setBarrierNextFrame(int barrierId, int barrierFlags) {
int barrierIndex = Shared.getScene()->getResources()->getBarrierIndexById(barrierId);
- BarrierItem *barrier = Shared.getScene()->getResources()->getBarrierByIndex(barrierIndex);
+ Barrier *barrier = Shared.getScene()->getResources()->getBarrierByIndex(barrierIndex);
int newFlag = barrierFlags | 1 | barrier->flags;
barrier->flags |= barrierFlags | 1;
@@ -422,7 +422,7 @@ int kPlayAnimation(ActionCommand *cmd) {
ScriptMan.lineIncrement = 1;
} else {
int barrierIndex = Shared.getScene()->getResources()->getBarrierIndexById(barrierId);
- BarrierItem *barrier = Shared.getScene()->getResources()->getBarrierByIndex(barrierIndex);
+ Barrier *barrier = Shared.getScene()->getResources()->getBarrierByIndex(barrierIndex);
if (cmd->param4) { // RECHECK THIS
int newBarriedIndex = 213 * barrierIndex;
@@ -644,7 +644,7 @@ int kReturn(ActionCommand *cmd) {
}
int kDestroyBarrier(ActionCommand *cmd) {
- BarrierItem *barrier = Shared.getScene()->getResources()->getBarrierById(cmd->param1);
+ Barrier *barrier = Shared.getScene()->getResources()->getBarrierById(cmd->param1);
if (barrier) {
barrier->flags &= 0xFFFFFFFE;
@@ -674,7 +674,7 @@ int k_unk15(ActionCommand *cmd) {
}
int kResetAnimation(ActionCommand *cmd) {
- BarrierItem *barrier = Shared.getScene()->getResources()->getBarrierById(cmd->param1);
+ Barrier *barrier = Shared.getScene()->getResources()->getBarrierById(cmd->param1);
if ((barrier->flags & 0x10000) == 0)
barrier->frameIdx = 0;
@@ -685,7 +685,7 @@ int kResetAnimation(ActionCommand *cmd) {
}
int kClearFlag1Bit0(ActionCommand *cmd) {
- BarrierItem *barrier = Shared.getScene()->getResources()->getBarrierById(cmd->param1);
+ Barrier *barrier = Shared.getScene()->getResources()->getBarrierById(cmd->param1);
barrier->flags &= 0xFFFFFFFE;
@@ -879,7 +879,7 @@ int k_unk3C_CMP_VAL(ActionCommand *cmd) {
}
int kWaitUntilFramePlayed(ActionCommand *cmd) {
- BarrierItem *barrier = Shared.getScene()->getResources()->getBarrierById(cmd->param1);
+ Barrier *barrier = Shared.getScene()->getResources()->getBarrierById(cmd->param1);
if (barrier) {
uint32 frameNum = 0;
@@ -1016,7 +1016,7 @@ int kQuit(ActionCommand *cmd) {
}
int kJumpBarrierFrame(ActionCommand *cmd) {
- BarrierItem *barrier = Shared.getScene()->getResources()->getBarrierById(cmd->param1);
+ Barrier *barrier = Shared.getScene()->getResources()->getBarrierById(cmd->param1);
if (cmd->param2 == -1)
cmd->param2 = barrier->frameCount - 1;
@@ -1101,7 +1101,7 @@ int kSetResourcePalette(ActionCommand *cmd) {
}
int kSetBarrierFrameIdxFlaged(ActionCommand *cmd) {
- BarrierItem *barrier = Shared.getScene()->getResources()->getBarrierById(cmd->param1);
+ Barrier *barrier = Shared.getScene()->getResources()->getBarrierById(cmd->param1);
if (cmd->param3)
barrier->flags = 1 | barrier->flags;
@@ -1133,7 +1133,7 @@ int k_unk5E(ActionCommand *cmd) {
}
int kSetBarrierLastFrameIdx(ActionCommand *cmd) {
- BarrierItem *barrier = Shared.getScene()->getResources()->getBarrierById(cmd->param1);
+ Barrier *barrier = Shared.getScene()->getResources()->getBarrierById(cmd->param1);
if (barrier->frameIdx == barrier->frameCount - 1) {
ScriptMan.lineIncrement = 0;
diff --git a/engines/asylum/sound.h b/engines/asylum/sound.h
index 0ef54e07de..ab73ff7f83 100644
--- a/engines/asylum/sound.h
+++ b/engines/asylum/sound.h
@@ -31,6 +31,37 @@
namespace Asylum {
+typedef struct SoundItem {
+ uint32 resId;
+ uint32 field_4;
+ uint32 field_8;
+ uint32 field_C;
+
+} SoundItem;
+
+typedef struct FrameSoundItem {
+ uint32 resId;
+ uint32 frameIdx;
+ uint32 index;
+ uint32 field_C;
+ uint32 field_10;
+ uint32 field_14;
+
+} FrameSoundItem;
+
+typedef struct AmbientSoundItem {
+ uint32 field_0;
+ uint32 flags;
+ uint32 resId;
+ uint32 field_C;
+ uint32 field_10;
+ uint32 field_14;
+ uint32 flagNum[6];
+ uint32 x;
+ uint32 y;
+
+} AmbientSoundItem;
+
class Sound {
public:
Sound(Audio::Mixer *mixer);
Commit: 87b32eadd219931967b9e998f9339b0f9af49b4b
https://github.com/scummvm/scummvm/commit/87b32eadd219931967b9e998f9339b0f9af49b4b
Author: Alex Bevilacqua (alexbevi at gmail.com)
Date: 2021-05-17T15:35:46+02:00
Commit Message:
ASYLUM: added barrier.cpp/h to vcproj
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@334 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/asylum.vcproj
diff --git a/engines/asylum/asylum.vcproj b/engines/asylum/asylum.vcproj
index 1c8b5df3de..f2145beff7 100644
--- a/engines/asylum/asylum.vcproj
+++ b/engines/asylum/asylum.vcproj
@@ -17,9 +17,11 @@
</Configurations>
<Files>
<File RelativePath="..\..\engines\asylum\actor.cpp" />
- <File RelativePath="..\..\engines\asylum\actor.h" />
+ <File RelativePath="..\..\engines\asylum\actor.h" />
<File RelativePath="..\..\engines\asylum\asylum.cpp" />
<File RelativePath="..\..\engines\asylum\asylum.h" />
+ <File RelativePath="..\..\engines\asylum\barrier.cpp" />
+ <File RelativePath="..\..\engines\asylum\barrier.h" />
<File RelativePath="..\..\engines\asylum\blowuppuzzle.cpp" />
<File RelativePath="..\..\engines\asylum\blowuppuzzle.h" />
<File RelativePath="..\..\engines\asylum\console.cpp" />
Commit: 18733c4910531fea510f63ac64739608056cd778
https://github.com/scummvm/scummvm/commit/18733c4910531fea510f63ac64739608056cd778
Author: Alex Bevilacqua (alexbevi at gmail.com)
Date: 2021-05-17T15:35:46+02:00
Commit Message:
ASYLUM: fixed a valgrind warning
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@335 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/respack.cpp
diff --git a/engines/asylum/respack.cpp b/engines/asylum/respack.cpp
index cdb5670439..d9e0f81f8f 100644
--- a/engines/asylum/respack.cpp
+++ b/engines/asylum/respack.cpp
@@ -41,7 +41,7 @@ ResourcePack::ResourcePack(int resourceIndex) {
ResourcePack::~ResourcePack() {
for (uint32 i = 0; i < _resources.size(); i++) {
- delete _resources[i].data;
+ delete [] _resources[i].data;
}
_resources.clear();
Commit: 0002d520733fc19553f1f34cb87e369bd886f534
https://github.com/scummvm/scummvm/commit/0002d520733fc19553f1f34cb87e369bd886f534
Author: Alex Bevilacqua (alexbevi at gmail.com)
Date: 2021-05-17T15:35:46+02:00
Commit Message:
ASYLUM: minor cleanup
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@336 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/barrier.h
engines/asylum/respack.cpp
engines/asylum/respack.h
engines/asylum/scriptman.cpp
engines/asylum/video.h
diff --git a/engines/asylum/barrier.h b/engines/asylum/barrier.h
index 5c9ff758e2..76f91643c8 100644
--- a/engines/asylum/barrier.h
+++ b/engines/asylum/barrier.h
@@ -80,4 +80,4 @@ public:
} // end of namespace Asylum
-#endif /* ASYLUM_BARRIER_H_ */
+#endif
diff --git a/engines/asylum/respack.cpp b/engines/asylum/respack.cpp
index d9e0f81f8f..8fc540900c 100644
--- a/engines/asylum/respack.cpp
+++ b/engines/asylum/respack.cpp
@@ -40,12 +40,10 @@ ResourcePack::ResourcePack(int resourceIndex) {
}
ResourcePack::~ResourcePack() {
- for (uint32 i = 0; i < _resources.size(); i++) {
+ for (uint32 i = 0; i < _resources.size(); i++)
delete [] _resources[i].data;
- }
_resources.clear();
-
_packFile.close();
}
diff --git a/engines/asylum/respack.h b/engines/asylum/respack.h
index 425b4bc6fc..97c0c16066 100644
--- a/engines/asylum/respack.h
+++ b/engines/asylum/respack.h
@@ -32,7 +32,7 @@
namespace Asylum {
struct ResourceEntry {
- byte *data;
+ byte *data;
uint32 size;
uint32 offset;
};
diff --git a/engines/asylum/scriptman.cpp b/engines/asylum/scriptman.cpp
index 6673a9bc53..13fdb4e379 100644
--- a/engines/asylum/scriptman.cpp
+++ b/engines/asylum/scriptman.cpp
@@ -229,10 +229,6 @@ int ScriptManager::processActionList() {
uint32 opcode = currentCommand->opcode;
- warning("Processing opcode %s (0x%02X)",
- function_map[opcode].name,
- currentCommand->opcode);
-
// Execute command from function mapping
int cmdRet = function_map[opcode].function(currentCommand);
diff --git a/engines/asylum/video.h b/engines/asylum/video.h
index 8d5e52c40e..0d16dc838c 100644
--- a/engines/asylum/video.h
+++ b/engines/asylum/video.h
@@ -100,11 +100,10 @@ private:
GraphicResource *_fontResource;
ResourcePack *_textPack;
- uint8 _curFontFlags;
+ uint8 _curFontFlags;
}; // end of class VideoText
-
} // end of namespace Asylum
#endif
Commit: 82016e35e13df58c4495f346e0b3715dea36333a
https://github.com/scummvm/scummvm/commit/82016e35e13df58c4495f346e0b3715dea36333a
Author: Alexandre Fontoura (alexandrefontoura at gmail.com)
Date: 2021-05-17T15:35:46+02:00
Commit Message:
ASYLUM: Little compilation fix.
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@337 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/scriptman.cpp
diff --git a/engines/asylum/scriptman.cpp b/engines/asylum/scriptman.cpp
index 13fdb4e379..39e9e18684 100644
--- a/engines/asylum/scriptman.cpp
+++ b/engines/asylum/scriptman.cpp
@@ -545,6 +545,8 @@ int kShowActor(ActionCommand *cmd) {
cmd->param1,
Shared.getScene()->getSceneIndex(),
ScriptMan.currentLine);
+
+ return 0;
}
int kSetActorStats(ActionCommand *cmd) {
@@ -1110,7 +1112,7 @@ int kSetBarrierFrameIdxFlaged(ActionCommand *cmd) {
}
int k_unk59(ActionCommand *cmd) {
-
+ return -2;
}
int k_unk5A(ActionCommand *cmd) {
return -2;
Commit: 05e47b3d71966be381989ec59697419309c99b1b
https://github.com/scummvm/scummvm/commit/05e47b3d71966be381989ec59697419309c99b1b
Author: Alexandre Fontoura (alexandrefontoura at gmail.com)
Date: 2021-05-17T15:35:47+02:00
Commit Message:
ASYLUM: Fixed scene moving command. Still crashing with Path-Finding.
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@338 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/actor.cpp
engines/asylum/scene.cpp
engines/asylum/scene.h
engines/asylum/screen.cpp
engines/asylum/scriptman.cpp
engines/asylum/scriptman.h
diff --git a/engines/asylum/actor.cpp b/engines/asylum/actor.cpp
index 0f3341b30a..6838269413 100644
--- a/engines/asylum/actor.cpp
+++ b/engines/asylum/actor.cpp
@@ -130,11 +130,13 @@ GraphicFrame *Actor::getFrame() {
void Actor::drawActorAt(uint16 curX, uint16 curY) {
GraphicFrame *frame = getFrame();
+ WorldStats *ws = Shared.getScene()->getResources()->getWorldStats();
+
Shared.getScreen()->copyRectToScreenWithTransparency(
((byte *)frame->surface.pixels),
frame->surface.w,
- curX,
- curY,
+ curX - ws->targetX,
+ curY - ws->targetY,
frame->surface.w,
frame->surface.h );
x = curX;
@@ -143,12 +145,13 @@ void Actor::drawActorAt(uint16 curX, uint16 curY) {
void Actor::drawActor() {
GraphicFrame *frame = getFrame();
+ WorldStats *ws = Shared.getScene()->getResources()->getWorldStats();
Shared.getScreen()->copyToBackBufferWithTransparency(
((byte *)frame->surface.pixels),
frame->surface.w,
- x,
- y - frame->surface.h,
+ x - ws->targetX,
+ y - frame->surface.h - ws->targetY,
frame->surface.w,
frame->surface.h );
}
@@ -163,6 +166,7 @@ void Actor::setWalkArea(ActionArea *target) {
void Actor::walkTo(uint16 curX, uint16 curY) {
int newAction = currentAction;
+ WorldStats *ws = Shared.getScene()->getResources()->getWorldStats();
// step is the increment by which to move the
// actor in a given direction
@@ -225,7 +229,7 @@ void Actor::walkTo(uint16 curX, uint16 curY) {
rect.bottom = newY + 4;
surface.frameRect(rect, 0x33);
- Shared.getScreen()->copyRectToScreen((byte*)surface.pixels, 5, newX, newY, 5, 5);
+ Shared.getScreen()->copyRectToScreen((byte*)surface.pixels, 5, newX - ws->targetX, newY - ws->targetY, 5, 5);
surface.free();
@@ -239,15 +243,15 @@ void Actor::walkTo(uint16 curX, uint16 curY) {
ActionArea *area;
// Check what valid walk region(s) is/are currently available
- for (uint32 a = 0; a < Shared.getScene()->getResources()->getWorldStats()->numActions; a++) {
- if (Shared.getScene()->getResources()->getWorldStats()->actions[a].actionType == 0) {
- area = &Shared.getScene()->getResources()->getWorldStats()->actions[a];
+ for (uint32 a = 0; a < ws->numActions; a++) {
+ if (ws->actions[a].actionType == 0) {
+ area = &ws->actions[a];
PolyDefinitions poly = Shared.getScene()->getResources()->getGamePolygons()->polygons[area->polyIdx];
- if (Shared.pointInPoly(&poly, x, y)) {
+ if (Shared.pointInPoly(&poly, x, y)) {
availableAreas[areaPtr] = a;
areaPtr++;
- setWalkArea(&Shared.getScene()->getResources()->getWorldStats()->actions[a]);
+ setWalkArea(&ws->actions[a]);
if (areaPtr > 5)
error("More than 5 overlapping walk regions found. Increase buffer");
@@ -259,7 +263,7 @@ void Actor::walkTo(uint16 curX, uint16 curY) {
// Check that we can walk in the current direction within any of the available
// walkable regions
for (int i = 0; i < areaPtr; i++) {
- area = &Shared.getScene()->getResources()->getWorldStats()->actions[availableAreas[i]];
+ area = &ws->actions[availableAreas[i]];
PolyDefinitions *region = &Shared.getScene()->getResources()->getGamePolygons()->polygons[area->polyIdx];
if (Shared.pointInPoly(region, newX, newY)) {
x = newX;
diff --git a/engines/asylum/scene.cpp b/engines/asylum/scene.cpp
index 2f51783e99..cb7417545c 100644
--- a/engines/asylum/scene.cpp
+++ b/engines/asylum/scene.cpp
@@ -65,8 +65,8 @@ Scene::Scene(uint8 sceneIdx) {
_cursor = new Cursor(_resPack);
_background = 0;
- _startX = 0;
- _startY = 0;
+ //_startX = 0;
+ //_startY = 0;
_leftClick = false;
_rightButton = false;
_isActive = false;
@@ -115,10 +115,11 @@ Actor* Scene::getActor() {
}
void Scene::enterScene() {
- Shared.getScreen()->setPalette(_resPack, _sceneResource->getWorldStats()->commonRes.palette);
+ WorldStats *ws = _sceneResource->getWorldStats();
+ Shared.getScreen()->setPalette(_resPack, ws->commonRes.palette);
_background = _bgResource->getFrame(0);
Shared.getScreen()->copyToBackBuffer(
- ((byte *)_background->surface.pixels) + _startY * _background->surface.w + _startX, _background->surface.w,
+ ((byte *)_background->surface.pixels) + ws->targetY * _background->surface.w + ws->targetX, _background->surface.w,
0, 0, 640, 480);
_cursor->load(_sceneResource->getWorldStats()->commonRes.curMagnifyingGlass);
@@ -147,20 +148,23 @@ ActionDefinitions* Scene::getActionList(int actionListIndex) {
void Scene::setScenePosition(int x, int y)
{
+ WorldStats *ws = _sceneResource->getWorldStats();
GraphicFrame *bg = _bgResource->getFrame(0);
- _startX = x;
- _startY = y;
+ //_startX = x;
+ //_startY = y;
+ ws->targetX = x;
+ ws->targetY = y;
- if (_startX < 0)
- _startX = 0;
- if (_startX > (bg->surface.w - 640))
- _startX = bg->surface.w - 640;
+ if (ws->targetX < 0)
+ ws->targetX = 0;
+ if (ws->targetX > (bg->surface.w - 640))
+ ws->targetX = bg->surface.w - 640;
- if (_startX < 0)
- _startY = 0;
- if (_startX > (bg->surface.h - 480))
- _startY = bg->surface.h - 480;
+ if (ws->targetY < 0)
+ ws->targetY = 0;
+ if (ws->targetY > (bg->surface.h - 480))
+ ws->targetY = bg->surface.h - 480;
}
void Scene::handleEvent(Common::Event *event, bool doUpdate) {
@@ -808,10 +812,10 @@ void Scene::OLD_UPDATE(WorldStats *worldStats) {
for (uint32 p = 0; p < worldStats->numBarriers; p++) {
Barrier b = worldStats->barriers[p];
if (b.flags & 0x20) {
- if ((b.boundingRect.left + b.x <= _cursor->x() + _startX) &&
- (_cursor->x() + _startX < b.boundingRect.right + b.x) &&
- (b.boundingRect.top + b.y <= _cursor->y() + _startY) &&
- (_cursor->y() + _startY < b.boundingRect.bottom + b.y)) {
+ if ((b.boundingRect.left + b.x <= _cursor->x() + worldStats->targetX) &&
+ (_cursor->x() + worldStats->targetX < b.boundingRect.right + b.x) &&
+ (b.boundingRect.top + b.y <= _cursor->y() + worldStats->targetY) &&
+ (_cursor->y() + worldStats->targetY < b.boundingRect.bottom + b.y)) {
_cursor->animate();
curBarrier = (int32)p;
break;
@@ -828,8 +832,8 @@ void Scene::OLD_UPDATE(WorldStats *worldStats) {
// Update cursor if it's in a polygon hotspot
for (uint32 p = 0; p < _sceneResource->getGamePolygons()->numEntries; p++) {
PolyDefinitions poly = _sceneResource->getGamePolygons()->polygons[p];
- if (poly.boundingRect.contains(_cursor->x() + _startX, _cursor->y() + _startY)) {
- if (Shared.pointInPoly(&poly, _cursor->x() + _startX, _cursor->y() + _startY)) {
+ if (poly.boundingRect.contains(_cursor->x() + worldStats->targetX, _cursor->y() + worldStats->targetY)) {
+ if (Shared.pointInPoly(&poly, _cursor->x() + worldStats->targetX, _cursor->y() + worldStats->targetY)) {
curHotspot = (int32)p;
_cursor->animate();
break;
@@ -883,7 +887,7 @@ int Scene::drawScene() {
WorldStats *ws = _sceneResource->getWorldStats();
GraphicFrame *bg = _bgResource->getFrame(0);
Shared.getScreen()->copyToBackBuffer(
- ((byte *)bg->surface.pixels) + _startY * bg->surface.w + _startX, bg->surface.w,
+ ((byte *)bg->surface.pixels) + ws->targetY * bg->surface.w + ws->targetX, bg->surface.w,
ws->xLeft,
ws->yTop,
640,
@@ -940,21 +944,23 @@ int Scene::drawBarriers() {
// ----------------------------------
void Scene::copyToBackBufferClipped(Graphics::Surface *surface, int x, int y) {
- Common::Rect screenRect(_startX, _startY, _startX + 640, _startY + 480);
+ WorldStats *ws = Shared.getScene()->getResources()->getWorldStats();
+
+ Common::Rect screenRect(ws->targetX, ws->targetY, ws->targetX + 640, ws->targetY + 480);
Common::Rect animRect(x, y, x + surface->w, y + surface->h);
animRect.clip(screenRect);
if (!animRect.isEmpty()) {
// Translate anim rectangle
- animRect.translate(-_startX, -_startY);
+ animRect.translate(-ws->targetX, -ws->targetY);
int startX = animRect.right == 640 ? 0 : surface->w - animRect.width();
int startY = animRect.bottom == 480 ? 0 : surface->h - animRect.height();
if (surface->w > 640)
- startX = _startX;
+ startX = ws->targetX;
if (surface->h > 480)
- startY = _startY;
+ startY = ws->targetY;
Shared.getScreen()->copyToBackBufferWithTransparency(
((byte*)surface->pixels) +
@@ -973,17 +979,19 @@ void Scene::copyToBackBufferClipped(Graphics::Surface *surface, int x, int y) {
// ----------------------------------
void Scene::debugScreenScrolling(GraphicFrame *bg) {
+ WorldStats *ws = Shared.getScene()->getResources()->getWorldStats();
+
// Horizontal scrolling
- if (_cursor->x() < SCREEN_EDGES && _startX >= SCROLL_STEP)
- _startX -= SCROLL_STEP;
- else if (_cursor->x() > 640 - SCREEN_EDGES && _startX <= bg->surface.w - 640 - SCROLL_STEP)
- _startX += SCROLL_STEP;
+ if (_cursor->x() < SCREEN_EDGES && ws->targetX >= SCROLL_STEP)
+ ws->targetX -= SCROLL_STEP;
+ else if (_cursor->x() > 640 - SCREEN_EDGES && ws->targetX <= bg->surface.w - 640 - SCROLL_STEP)
+ ws->targetX += SCROLL_STEP;
// Vertical scrolling
- if (_cursor->y() < SCREEN_EDGES && _startY >= SCROLL_STEP)
- _startY -= SCROLL_STEP;
- else if (_cursor->y() > 480 - SCREEN_EDGES && _startY <= bg->surface.h - 480 - SCROLL_STEP)
- _startY += SCROLL_STEP;
+ if (_cursor->y() < SCREEN_EDGES && ws->targetY >= SCROLL_STEP)
+ ws->targetY -= SCROLL_STEP;
+ else if (_cursor->y() > 480 - SCREEN_EDGES && ws->targetY <= bg->surface.h - 480 - SCROLL_STEP)
+ ws->targetY += SCROLL_STEP;
}
// WALK REGION DEBUG
diff --git a/engines/asylum/scene.h b/engines/asylum/scene.h
index 112b7ece60..61178514a0 100644
--- a/engines/asylum/scene.h
+++ b/engines/asylum/scene.h
@@ -97,8 +97,8 @@ private:
GraphicFrame *_background;
bool _walking;
- int32 _startX;
- int32 _startY;
+ //int32 _startX;
+ //int32 _startY;
bool _leftClick;
bool _rightButton;
bool _isActive;
diff --git a/engines/asylum/screen.cpp b/engines/asylum/screen.cpp
index 42c7cf5d81..7b0359a02a 100644
--- a/engines/asylum/screen.cpp
+++ b/engines/asylum/screen.cpp
@@ -136,12 +136,13 @@ void Screen::addGraphicToQueue(GraphicQueueItem item) {
}
void Screen::drawGraphicsInQueue() {
+ WorldStats *ws = Shared.getScene()->getResources()->getWorldStats();
// sort by priority first
graphicsSelectionSort();
for(uint i = 0; i < _queueItems.size(); i++) {
GraphicResource *grRes = Shared.getScene()->getGraphicResource(_queueItems[i].resId);
GraphicFrame *fra = grRes->getFrame(_queueItems[i].frameIdx);
- copyRectToScreenWithTransparency((byte *)fra->surface.pixels, fra->surface.w, _queueItems[i].x, _queueItems[i].y, fra->surface.w, fra->surface.h);
+ copyRectToScreenWithTransparency((byte *)fra->surface.pixels, fra->surface.w, _queueItems[i].x - ws->targetX, _queueItems[i].y - ws->targetY, fra->surface.w, fra->surface.h);
delete grRes;
}
}
diff --git a/engines/asylum/scriptman.cpp b/engines/asylum/scriptman.cpp
index 39e9e18684..323fdec1d9 100644
--- a/engines/asylum/scriptman.cpp
+++ b/engines/asylum/scriptman.cpp
@@ -550,13 +550,15 @@ int kShowActor(ActionCommand *cmd) {
}
int kSetActorStats(ActionCommand *cmd) {
+ WorldStats *ws = Shared.getScene()->getResources()->getWorldStats();
+
// TODO
// param1 == actorIndex. Implement when we've got more than one actor
// TODO This needs to be depreciated, but it's setting the actor's x/y
// and bounding rect top/left.
// This needs to be rolled into the proper place
- Shared.getScene()->getActor()->setPosition(cmd->param2, cmd->param3);
+ Shared.getScene()->getActor()->setPosition(cmd->param2, cmd->param3);
Shared.getScene()->getActor()->setPosition_40A260(cmd->param2, cmd->param3, cmd->param4, cmd->param5);
diff --git a/engines/asylum/scriptman.h b/engines/asylum/scriptman.h
index 9ff384f534..1d73845ee5 100644
--- a/engines/asylum/scriptman.h
+++ b/engines/asylum/scriptman.h
@@ -33,6 +33,7 @@
namespace Asylum {
struct ActionCommand;
+class WorldStats;
class ScriptManager: public Common::Singleton<ScriptManager> {
public:
Commit: 7550fd1453f0d9178f26b9a74c477f3ed81868d5
https://github.com/scummvm/scummvm/commit/7550fd1453f0d9178f26b9a74c477f3ed81868d5
Author: Alex Bevilacqua (alexbevi at gmail.com)
Date: 2021-05-17T15:35:47+02:00
Commit Message:
ASYLUM: There's no need to access the scene's resources through Shared from within the scene itself
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@339 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/scene.cpp
diff --git a/engines/asylum/scene.cpp b/engines/asylum/scene.cpp
index cb7417545c..85e6db2d86 100644
--- a/engines/asylum/scene.cpp
+++ b/engines/asylum/scene.cpp
@@ -944,7 +944,7 @@ int Scene::drawBarriers() {
// ----------------------------------
void Scene::copyToBackBufferClipped(Graphics::Surface *surface, int x, int y) {
- WorldStats *ws = Shared.getScene()->getResources()->getWorldStats();
+ WorldStats *ws = _sceneResource->getWorldStats();
Common::Rect screenRect(ws->targetX, ws->targetY, ws->targetX + 640, ws->targetY + 480);
Common::Rect animRect(x, y, x + surface->w, y + surface->h);
@@ -979,7 +979,7 @@ void Scene::copyToBackBufferClipped(Graphics::Surface *surface, int x, int y) {
// ----------------------------------
void Scene::debugScreenScrolling(GraphicFrame *bg) {
- WorldStats *ws = Shared.getScene()->getResources()->getWorldStats();
+ WorldStats *ws = _sceneResource->getWorldStats();
// Horizontal scrolling
if (_cursor->x() < SCREEN_EDGES && ws->targetX >= SCROLL_STEP)
Commit: 4e7c4a478b822ba81f069f6faee65c0ba015dbe2
https://github.com/scummvm/scummvm/commit/4e7c4a478b822ba81f069f6faee65c0ba015dbe2
Author: Alex Bevilacqua (alexbevi at gmail.com)
Date: 2021-05-17T15:35:47+02:00
Commit Message:
ASYLUM: refactored polygon code out to seperate class
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@340 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
A engines/asylum/polygons.cpp
A engines/asylum/polygons.h
engines/asylum/actor.cpp
engines/asylum/asylum.vcproj
engines/asylum/module.mk
engines/asylum/scene.cpp
engines/asylum/sceneres.cpp
engines/asylum/sceneres.h
diff --git a/engines/asylum/actor.cpp b/engines/asylum/actor.cpp
index 6838269413..3b73a155a4 100644
--- a/engines/asylum/actor.cpp
+++ b/engines/asylum/actor.cpp
@@ -246,7 +246,7 @@ void Actor::walkTo(uint16 curX, uint16 curY) {
for (uint32 a = 0; a < ws->numActions; a++) {
if (ws->actions[a].actionType == 0) {
area = &ws->actions[a];
- PolyDefinitions poly = Shared.getScene()->getResources()->getGamePolygons()->polygons[area->polyIdx];
+ PolyDefinitions poly = Shared.getScene()->getResources()->getGamePolygons()->entries[area->polyIdx];
if (Shared.pointInPoly(&poly, x, y)) {
availableAreas[areaPtr] = a;
areaPtr++;
@@ -264,7 +264,7 @@ void Actor::walkTo(uint16 curX, uint16 curY) {
// walkable regions
for (int i = 0; i < areaPtr; i++) {
area = &ws->actions[availableAreas[i]];
- PolyDefinitions *region = &Shared.getScene()->getResources()->getGamePolygons()->polygons[area->polyIdx];
+ PolyDefinitions *region = &Shared.getScene()->getResources()->getGamePolygons()->entries[area->polyIdx];
if (Shared.pointInPoly(region, newX, newY)) {
x = newX;
y = newY;
@@ -318,7 +318,7 @@ void Actor::faceTarget(int targetId, int targetType) {
}
uint32 polyIdx = Shared.getScene()->getResources()->getWorldStats()->actions[actionIdx].polyIdx;
- PolyDefinitions *poly = &Shared.getScene()->getResources()->getGamePolygons()->polygons[polyIdx];
+ PolyDefinitions *poly = &Shared.getScene()->getResources()->getGamePolygons()->entries[polyIdx];
newX2 = poly->boundingRect.left + (poly->boundingRect.right - poly->boundingRect.left) / 2;
newY2 = poly->boundingRect.top + (poly->boundingRect.bottom - poly->boundingRect.top) / 2;
diff --git a/engines/asylum/asylum.vcproj b/engines/asylum/asylum.vcproj
index f2145beff7..6502f78740 100644
--- a/engines/asylum/asylum.vcproj
+++ b/engines/asylum/asylum.vcproj
@@ -17,7 +17,7 @@
</Configurations>
<Files>
<File RelativePath="..\..\engines\asylum\actor.cpp" />
- <File RelativePath="..\..\engines\asylum\actor.h" />
+ <File RelativePath="..\..\engines\asylum\actor.h" />
<File RelativePath="..\..\engines\asylum\asylum.cpp" />
<File RelativePath="..\..\engines\asylum\asylum.h" />
<File RelativePath="..\..\engines\asylum\barrier.cpp" />
@@ -33,6 +33,8 @@
<File RelativePath="..\..\engines\asylum\graphics.h" />
<File RelativePath="..\..\engines\asylum\menu.cpp" />
<File RelativePath="..\..\engines\asylum\menu.h" />
+ <File RelativePath="..\..\engines\asylum\polygons.cpp" />
+ <File RelativePath="..\..\engines\asylum\polygons.h" />
<File RelativePath="..\..\engines\asylum\respack.cpp" />
<File RelativePath="..\..\engines\asylum\respack.h" />
<File RelativePath="..\..\engines\asylum\scene.cpp" />
diff --git a/engines/asylum/module.mk b/engines/asylum/module.mk
index 6c70afa048..f1af8a6252 100644
--- a/engines/asylum/module.mk
+++ b/engines/asylum/module.mk
@@ -19,7 +19,8 @@ MODULE_OBJS := \
scriptman.o \
blowuppuzzle.o \
shared.o \
- cursor.o
+ cursor.o \
+ polygons.o
# This module can be built as a plugin
ifeq ($(ENABLE_ASYLUM), DYNAMIC_PLUGIN)
diff --git a/engines/asylum/polygons.cpp b/engines/asylum/polygons.cpp
new file mode 100644
index 0000000000..7a334d18c4
--- /dev/null
+++ b/engines/asylum/polygons.cpp
@@ -0,0 +1,21 @@
+/*
+ * Polygons.cpp
+ *
+ * Created on: Sep 18, 2009
+ * Author: alex
+ */
+
+#include "asylum/polygons.h"
+
+namespace Asylum {
+
+Polygons::Polygons() {
+ // TODO Auto-generated constructor stub
+
+}
+
+Polygons::~Polygons() {
+ entries.clear();
+}
+
+} // end of namespace Asylum
diff --git a/engines/asylum/polygons.h b/engines/asylum/polygons.h
new file mode 100644
index 0000000000..5ec3815bf7
--- /dev/null
+++ b/engines/asylum/polygons.h
@@ -0,0 +1,39 @@
+/*
+ * Polygons.h
+ *
+ * Created on: Sep 18, 2009
+ * Author: alex
+ */
+
+#ifndef ASYLUM_POLYGONS_H_
+#define ASYLUM_POLYGONS_H_
+
+#include "common/array.h"
+#include "common/rect.h"
+
+#define MAX_POLYGONS 200
+
+namespace Asylum {
+
+typedef struct PolyDefinitions {
+ uint32 numPoints;
+ Common::Point *points;
+ Common::Rect boundingRect;
+
+} PolyDefinitions;
+
+class Polygons {
+public:
+ Polygons();
+ virtual ~Polygons();
+
+ uint32 size;
+ uint32 numEntries;
+
+ Common::Array<PolyDefinitions> entries;
+
+}; // end of class Polygons
+
+} // end of namespace Asylum
+
+#endif
diff --git a/engines/asylum/scene.cpp b/engines/asylum/scene.cpp
index 85e6db2d86..2bed478b86 100644
--- a/engines/asylum/scene.cpp
+++ b/engines/asylum/scene.cpp
@@ -776,7 +776,7 @@ void Scene::OLD_UPDATE(WorldStats *worldStats) {
for (uint32 a = 0; a < worldStats->numActions; a++) {
if (worldStats->actions[a].actionType == 0) {
ActionArea *area = &worldStats->actions[a];
- PolyDefinitions poly = _sceneResource->getGamePolygons()->polygons[area->polyIdx];
+ PolyDefinitions poly = _sceneResource->getGamePolygons()->entries[area->polyIdx];
if (Shared.pointInPoly(&poly, getActor()->x, getActor()->y)) {
debugShowWalkRegion(&poly);
//break;
@@ -831,7 +831,7 @@ void Scene::OLD_UPDATE(WorldStats *worldStats) {
if (curBarrier < 0) {
// Update cursor if it's in a polygon hotspot
for (uint32 p = 0; p < _sceneResource->getGamePolygons()->numEntries; p++) {
- PolyDefinitions poly = _sceneResource->getGamePolygons()->polygons[p];
+ PolyDefinitions poly = _sceneResource->getGamePolygons()->entries[p];
if (poly.boundingRect.contains(_cursor->x() + worldStats->targetX, _cursor->y() + worldStats->targetY)) {
if (Shared.pointInPoly(&poly, _cursor->x() + worldStats->targetX, _cursor->y() + worldStats->targetY)) {
curHotspot = (int32)p;
@@ -1019,7 +1019,7 @@ void Scene::debugShowWalkRegion(PolyDefinitions *poly) {
void Scene::debugShowPolygons() {
for (uint32 p = 0; p < _sceneResource->getGamePolygons()->numEntries; p++) {
Graphics::Surface surface;
- PolyDefinitions poly = _sceneResource->getGamePolygons()->polygons[p];
+ PolyDefinitions poly = _sceneResource->getGamePolygons()->entries[p];
surface.create(poly.boundingRect.right - poly.boundingRect.left + 1,
poly.boundingRect.bottom - poly.boundingRect.top + 1,
1);
diff --git a/engines/asylum/sceneres.cpp b/engines/asylum/sceneres.cpp
index ef0c9f749a..17bf7b2403 100644
--- a/engines/asylum/sceneres.cpp
+++ b/engines/asylum/sceneres.cpp
@@ -35,7 +35,7 @@ SceneResource::~SceneResource() {
uint8 i;
for (i = 0; i < _gamePolygons->numEntries; i++)
- delete[] _gamePolygons->polygons[i].points;
+ delete[] _gamePolygons->entries[i].points;
delete _gamePolygons;
delete _actionList;
@@ -411,7 +411,7 @@ void SceneResource::loadWorldStats(Common::SeekableReadStream *stream) {
}
void SceneResource::loadGamePolygons(Common::SeekableReadStream *stream) {
- _gamePolygons = new GamePolygons;
+ _gamePolygons = new Polygons;
stream->seek(0xE8686); // jump to game Polygons data
@@ -429,14 +429,14 @@ void SceneResource::loadGamePolygons(Common::SeekableReadStream *stream) {
poly.points[i].x = stream->readUint32LE() & 0xFFFF;
poly.points[i].y = stream->readUint32LE() & 0xFFFF;
}
- stream->skip((Polygons_MAXSIZE - poly.numPoints) * 8);
+ stream->skip((MAX_POLYGONS - poly.numPoints) * 8);
poly.boundingRect.left = stream->readUint32LE() & 0xFFFF;
poly.boundingRect.top = stream->readUint32LE() & 0xFFFF;
poly.boundingRect.right = stream->readUint32LE() & 0xFFFF;
poly.boundingRect.bottom = stream->readUint32LE() & 0xFFFF;
- _gamePolygons->polygons.push_back(poly);
+ _gamePolygons->entries.push_back(poly);
}
}
diff --git a/engines/asylum/sceneres.h b/engines/asylum/sceneres.h
index 25cb0fc27d..3fb0dbd7fd 100644
--- a/engines/asylum/sceneres.h
+++ b/engines/asylum/sceneres.h
@@ -34,16 +34,15 @@
#include "asylum/barrier.h"
#include "asylum/screen.h"
#include "asylum/respack.h"
+#include "asylum/polygons.h"
#define SCENEMASK "scn.%03d"
-#define Polygons_MAXSIZE 200
#define Commands_MAXSIZE 161
namespace Asylum {
class AsylumEngine;
class WorldStats;
-class GamePolygons;
class ActionList;
struct ActionArea;
@@ -54,9 +53,9 @@ public:
bool load(uint8 sceneIdx);
- WorldStats* getWorldStats() { return _worldStats; }
- GamePolygons* getGamePolygons() { return _gamePolygons; }
- ActionList* getActionList() { return _actionList; }
+ WorldStats* getWorldStats() { return _worldStats; }
+ Polygons* getGamePolygons() { return _gamePolygons; }
+ ActionList* getActionList() { return _actionList; }
int getBarrierIndexById(uint32 id);
int getActionAreaIndexById(uint32 id);
@@ -66,9 +65,9 @@ public:
private:
- WorldStats *_worldStats;
- GamePolygons *_gamePolygons;
- ActionList *_actionList;
+ WorldStats *_worldStats;
+ Polygons *_gamePolygons;
+ ActionList *_actionList;
void loadWorldStats(Common::SeekableReadStream *stream);
void loadGamePolygons(Common::SeekableReadStream *stream);
@@ -168,27 +167,6 @@ public:
// TODO add rest fields
}; // end of class WorldStats
-typedef struct PolyDefinitions{
- uint32 numPoints;
- Common::Point *points; //[Polygons_MAXSIZE];
- Common::Rect boundingRect;
-
-} PolyDefinitions;
-
-class GamePolygons {
-public:
- GamePolygons() {};
- virtual ~GamePolygons() {
- polygons.clear();
- };
-
- uint32 size;
- uint32 numEntries;
-
- Common::Array<PolyDefinitions> polygons;
-
-}; // end of class GamePolygons
-
typedef struct ActionArea {
char name[52];
uint32 id;
Commit: 612d6021f7fb6dee5795ab664170dee04b4e9e24
https://github.com/scummvm/scummvm/commit/612d6021f7fb6dee5795ab664170dee04b4e9e24
Author: Alex Bevilacqua (alexbevi at gmail.com)
Date: 2021-05-17T15:35:47+02:00
Commit Message:
ASYLUM: * added proper source header to polygons.cpp/h
* refactored the pointInPoly method into the PolyDefinitions and renamed the method to "contains()"
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@341 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/actor.cpp
engines/asylum/polygons.cpp
engines/asylum/polygons.h
engines/asylum/scene.cpp
engines/asylum/shared.cpp
engines/asylum/shared.h
diff --git a/engines/asylum/actor.cpp b/engines/asylum/actor.cpp
index 3b73a155a4..8786c0274d 100644
--- a/engines/asylum/actor.cpp
+++ b/engines/asylum/actor.cpp
@@ -247,7 +247,7 @@ void Actor::walkTo(uint16 curX, uint16 curY) {
if (ws->actions[a].actionType == 0) {
area = &ws->actions[a];
PolyDefinitions poly = Shared.getScene()->getResources()->getGamePolygons()->entries[area->polyIdx];
- if (Shared.pointInPoly(&poly, x, y)) {
+ if (poly.contains(x, y)) {
availableAreas[areaPtr] = a;
areaPtr++;
@@ -265,7 +265,7 @@ void Actor::walkTo(uint16 curX, uint16 curY) {
for (int i = 0; i < areaPtr; i++) {
area = &ws->actions[availableAreas[i]];
PolyDefinitions *region = &Shared.getScene()->getResources()->getGamePolygons()->entries[area->polyIdx];
- if (Shared.pointInPoly(region, newX, newY)) {
+ if (region->contains(newX, newY)) {
x = newX;
y = newY;
break;
diff --git a/engines/asylum/polygons.cpp b/engines/asylum/polygons.cpp
index 7a334d18c4..aec4428cf7 100644
--- a/engines/asylum/polygons.cpp
+++ b/engines/asylum/polygons.cpp
@@ -1,8 +1,26 @@
-/*
- * Polygons.cpp
+/* 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.
+ *
+ * $URL$
+ * $Id$
*
- * Created on: Sep 18, 2009
- * Author: alex
*/
#include "asylum/polygons.h"
@@ -18,4 +36,33 @@ Polygons::~Polygons() {
entries.clear();
}
+bool PolyDefinitions::contains(int x, int y) {
+ // Copied from backends/vkeybd/polygon.cpp
+ int yflag0;
+ int yflag1;
+ bool inside_flag = false;
+ unsigned int pt;
+
+ Common::Point *vtx0 = &points[numPoints - 1];
+ Common::Point *vtx1 = &points[0];
+
+ yflag0 = (vtx0->y >= y);
+ for (pt = 0; pt < numPoints; pt++, vtx1++) {
+ yflag1 = (vtx1->y >= y);
+ if (yflag0 != yflag1) {
+ if (((vtx1->y - y) * (vtx0->x - vtx1->x) >=
+ (vtx1->x - x) * (vtx0->y - vtx1->y)) == yflag1) {
+ inside_flag = !inside_flag;
+ }
+ }
+ yflag0 = yflag1;
+ vtx0 = vtx1;
+ }
+
+ return inside_flag;
+
+
+
+}
+
} // end of namespace Asylum
diff --git a/engines/asylum/polygons.h b/engines/asylum/polygons.h
index 5ec3815bf7..a944e2baaf 100644
--- a/engines/asylum/polygons.h
+++ b/engines/asylum/polygons.h
@@ -1,8 +1,26 @@
-/*
- * Polygons.h
+/* 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.
+ *
+ * $URL$
+ * $Id$
*
- * Created on: Sep 18, 2009
- * Author: alex
*/
#ifndef ASYLUM_POLYGONS_H_
@@ -20,6 +38,14 @@ typedef struct PolyDefinitions {
Common::Point *points;
Common::Rect boundingRect;
+ /**
+ * Check if the x/y coordinates exist within
+ * the current polygon definition
+ *
+ * (was pointInPoly())
+ */
+ bool contains(int x, int y);
+
} PolyDefinitions;
class Polygons {
diff --git a/engines/asylum/scene.cpp b/engines/asylum/scene.cpp
index 2bed478b86..23cd353b70 100644
--- a/engines/asylum/scene.cpp
+++ b/engines/asylum/scene.cpp
@@ -777,7 +777,7 @@ void Scene::OLD_UPDATE(WorldStats *worldStats) {
if (worldStats->actions[a].actionType == 0) {
ActionArea *area = &worldStats->actions[a];
PolyDefinitions poly = _sceneResource->getGamePolygons()->entries[area->polyIdx];
- if (Shared.pointInPoly(&poly, getActor()->x, getActor()->y)) {
+ if (poly.contains(getActor()->x, getActor()->y)) {
debugShowWalkRegion(&poly);
//break;
}
@@ -833,7 +833,7 @@ void Scene::OLD_UPDATE(WorldStats *worldStats) {
for (uint32 p = 0; p < _sceneResource->getGamePolygons()->numEntries; p++) {
PolyDefinitions poly = _sceneResource->getGamePolygons()->entries[p];
if (poly.boundingRect.contains(_cursor->x() + worldStats->targetX, _cursor->y() + worldStats->targetY)) {
- if (Shared.pointInPoly(&poly, _cursor->x() + worldStats->targetX, _cursor->y() + worldStats->targetY)) {
+ if (poly.contains(_cursor->x() + worldStats->targetX, _cursor->y() + worldStats->targetY)) {
curHotspot = (int32)p;
_cursor->animate();
break;
diff --git a/engines/asylum/shared.cpp b/engines/asylum/shared.cpp
index 83a3f501df..10512d1e41 100644
--- a/engines/asylum/shared.cpp
+++ b/engines/asylum/shared.cpp
@@ -44,32 +44,6 @@ SharedResources::~SharedResources() {
g_initialized = false;
}
-bool SharedResources::pointInPoly(PolyDefinitions *poly, int x, int y) {
- // Copied from backends/vkeybd/polygon.cpp
- int yflag0;
- int yflag1;
- bool inside_flag = false;
- unsigned int pt;
-
- Common::Point *vtx0 = &poly->points[poly->numPoints - 1];
- Common::Point *vtx1 = &poly->points[0];
-
- yflag0 = (vtx0->y >= y);
- for (pt = 0; pt < poly->numPoints; pt++, vtx1++) {
- yflag1 = (vtx1->y >= y);
- if (yflag0 != yflag1) {
- if (((vtx1->y - y) * (vtx0->x - vtx1->x) >=
- (vtx1->x - x) * (vtx0->y - vtx1->y)) == yflag1) {
- inside_flag = !inside_flag;
- }
- }
- yflag0 = yflag1;
- vtx0 = vtx1;
- }
-
- return inside_flag;
-}
-
int SharedResources::getAngle(int x1, int y1, int x2, int y2) {
uint32 v5 = (x2 << 16) - (x1 << 16);
int v6 = 0;
diff --git a/engines/asylum/shared.h b/engines/asylum/shared.h
index bedd426911..c9db4be79c 100644
--- a/engines/asylum/shared.h
+++ b/engines/asylum/shared.h
@@ -62,7 +62,6 @@ public:
void setScene(Scene* scene) { _scene = scene; }
Scene* getScene() { return _scene; }
- bool pointInPoly(PolyDefinitions *poly, int x, int y);
int getAngle(int x1, int y1, int x2, int y2);
void setGameFlag(int flag);
Commit: d1234430c29aa8ef5cd3892875b2e115e361c17c
https://github.com/scummvm/scummvm/commit/d1234430c29aa8ef5cd3892875b2e115e361c17c
Author: Alex Bevilacqua (alexbevi at gmail.com)
Date: 2021-05-17T15:35:47+02:00
Commit Message:
ASYLUM: refactored actionlist into it's own class file
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@342 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
A engines/asylum/actionlist.cpp
A engines/asylum/actionlist.h
engines/asylum/asylum.vcproj
engines/asylum/module.mk
engines/asylum/scene.cpp
engines/asylum/sceneres.cpp
engines/asylum/sceneres.h
diff --git a/engines/asylum/actionlist.cpp b/engines/asylum/actionlist.cpp
new file mode 100644
index 0000000000..c76dd4f24b
--- /dev/null
+++ b/engines/asylum/actionlist.cpp
@@ -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.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#include "asylum/actionlist.h"
+
+namespace Asylum {
+
+ActionList::ActionList() {
+ // TODO Auto-generated constructor stub
+
+}
+
+ActionList::~ActionList() {
+ entries.clear();
+}
+
+} // end of namespace Asylum
diff --git a/engines/asylum/actionlist.h b/engines/asylum/actionlist.h
new file mode 100644
index 0000000000..d16503448f
--- /dev/null
+++ b/engines/asylum/actionlist.h
@@ -0,0 +1,72 @@
+/* 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.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#ifndef ASYLUM_ACTIONLIST_H_
+#define ASYLUM_ACTIONLIST_H_
+
+#include "common/array.h"
+
+namespace Asylum {
+
+#define MAX_ACTION_COMMANDS 161
+
+typedef struct ActionCommand {
+ uint32 numLines; // Only set on the first line of each script
+ uint32 opcode;
+ uint32 param1;
+ uint32 param2;
+ uint32 param3;
+ uint32 param4;
+ uint32 param5;
+ uint32 param6;
+ uint32 param7;
+ uint32 param8;
+ uint32 param9;
+
+} ActionCommand;
+
+typedef struct ActionDefinitions {
+ ActionCommand commands[MAX_ACTION_COMMANDS];
+ uint32 field_1BAC;
+ uint32 field_1BB0;
+ uint32 counter;
+
+} ActionDefinitions;
+
+class ActionList {
+public:
+ ActionList();
+ virtual ~ActionList();
+
+ uint32 size;
+ uint32 numEntries;
+
+ Common::Array<ActionDefinitions> entries;
+
+};
+
+} // end of namespace Asylum
+
+#endif
diff --git a/engines/asylum/asylum.vcproj b/engines/asylum/asylum.vcproj
index 6502f78740..c3a5822a27 100644
--- a/engines/asylum/asylum.vcproj
+++ b/engines/asylum/asylum.vcproj
@@ -16,6 +16,8 @@
<Configuration Name="Release|Win32" ConfigurationType="4" InheritedPropertySheets=".\ScummVM_Release.vsprops" />
</Configurations>
<Files>
+ <File RelativePath="..\..\engines\asylum\actionlist.cpp" />
+ <File RelativePath="..\..\engines\asylum\actionlist.h" />
<File RelativePath="..\..\engines\asylum\actor.cpp" />
<File RelativePath="..\..\engines\asylum\actor.h" />
<File RelativePath="..\..\engines\asylum\asylum.cpp" />
diff --git a/engines/asylum/module.mk b/engines/asylum/module.mk
index f1af8a6252..972f4af37f 100644
--- a/engines/asylum/module.mk
+++ b/engines/asylum/module.mk
@@ -20,7 +20,8 @@ MODULE_OBJS := \
blowuppuzzle.o \
shared.o \
cursor.o \
- polygons.o
+ polygons.o \
+ actionlist.o
# This module can be built as a plugin
ifeq ($(ENABLE_ASYLUM), DYNAMIC_PLUGIN)
diff --git a/engines/asylum/scene.cpp b/engines/asylum/scene.cpp
index 23cd353b70..a536bfecab 100644
--- a/engines/asylum/scene.cpp
+++ b/engines/asylum/scene.cpp
@@ -141,7 +141,7 @@ ActionDefinitions* Scene::getDefaultActionList() {
ActionDefinitions* Scene::getActionList(int actionListIndex) {
if ((actionListIndex >= 0) && (actionListIndex < (int)_sceneResource->getWorldStats()->numActions))
- return &_sceneResource->getActionList()->actions[actionListIndex];
+ return &_sceneResource->getActionList()->entries[actionListIndex];
else
return 0;
}
@@ -856,7 +856,7 @@ void Scene::OLD_UPDATE(WorldStats *worldStats) {
worldStats->actions[a].actionListIdx2,
worldStats->actions[a].actionType,
worldStats->actions[a].soundResId);
- ScriptMan.setScript(&_sceneResource->getActionList()->actions[worldStats->actions[a].actionListIdx1]);
+ ScriptMan.setScript(&_sceneResource->getActionList()->entries[worldStats->actions[a].actionListIdx1]);
}
}
} else if (curBarrier >= 0) {
diff --git a/engines/asylum/sceneres.cpp b/engines/asylum/sceneres.cpp
index 17bf7b2403..bf6baff2ef 100644
--- a/engines/asylum/sceneres.cpp
+++ b/engines/asylum/sceneres.cpp
@@ -452,7 +452,7 @@ void SceneResource::loadActionList(Common::SeekableReadStream *stream) {
ActionDefinitions action;
memset(&action, 0, sizeof(ActionDefinitions));
- for (uint32 c = 0; c < Commands_MAXSIZE; c++) {
+ for (uint32 c = 0; c < MAX_ACTION_COMMANDS; c++) {
ActionCommand command;
memset(&command, 0, sizeof(ActionCommand));
@@ -475,7 +475,7 @@ void SceneResource::loadActionList(Common::SeekableReadStream *stream) {
action.field_1BB0 = stream->readUint32LE();
action.counter = stream->readUint32LE();
- _actionList->actions.push_back(action);
+ _actionList->entries.push_back(action);
}
}
diff --git a/engines/asylum/sceneres.h b/engines/asylum/sceneres.h
index 3fb0dbd7fd..99405e62dc 100644
--- a/engines/asylum/sceneres.h
+++ b/engines/asylum/sceneres.h
@@ -35,15 +35,14 @@
#include "asylum/screen.h"
#include "asylum/respack.h"
#include "asylum/polygons.h"
+#include "asylum/actionlist.h"
-#define SCENEMASK "scn.%03d"
-#define Commands_MAXSIZE 161
+#define SCENEMASK "scn.%03d"
namespace Asylum {
class AsylumEngine;
class WorldStats;
-class ActionList;
struct ActionArea;
class SceneResource {
@@ -190,43 +189,6 @@ typedef struct ActionArea {
uint32 volume;
} ActionArea;
-typedef struct ActionCommand {
- uint32 numLines; // Only set on the first line of each script
- uint32 opcode;
- uint32 param1;
- uint32 param2;
- uint32 param3;
- uint32 param4;
- uint32 param5;
- uint32 param6;
- uint32 param7;
- uint32 param8;
- uint32 param9;
-
-} ActionCommand;
-
-typedef struct ActionDefinitions {
- ActionCommand commands[161];
- uint32 field_1BAC;
- uint32 field_1BB0;
- uint32 counter;
-
-} ActionDefinitions;
-
-class ActionList {
-public:
- ActionList() {};
- virtual ~ActionList() {
- actions.clear();
- };
-
- uint32 size;
- uint32 numEntries;
-
- Common::Array<ActionDefinitions> actions;
-
-}; // end of class ActionList
-
} // end of namespace Asylum
#endif
Commit: afff3e722206bcb386e2e73144e1398160bf2d8c
https://github.com/scummvm/scummvm/commit/afff3e722206bcb386e2e73144e1398160bf2d8c
Author: Alex Bevilacqua (alexbevi at gmail.com)
Date: 2021-05-17T15:35:47+02:00
Commit Message:
ASYLUM: refactored worldstats into it's own class file
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@343 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
A engines/asylum/worldstats.cpp
A engines/asylum/worldstats.h
engines/asylum/asylum.vcproj
engines/asylum/module.mk
engines/asylum/sceneres.h
diff --git a/engines/asylum/asylum.vcproj b/engines/asylum/asylum.vcproj
index c3a5822a27..0eb2634bbc 100644
--- a/engines/asylum/asylum.vcproj
+++ b/engines/asylum/asylum.vcproj
@@ -53,5 +53,7 @@
<File RelativePath="..\..\engines\asylum\text.h" />
<File RelativePath="..\..\engines\asylum\video.cpp" />
<File RelativePath="..\..\engines\asylum\video.h" />
+ <File RelativePath="..\..\engines\asylum\worldstats.cpp" />
+ <File RelativePath="..\..\engines\asylum\worldstats.h" />
</Files>
</VisualStudioProject>
diff --git a/engines/asylum/module.mk b/engines/asylum/module.mk
index 972f4af37f..d4607f5949 100644
--- a/engines/asylum/module.mk
+++ b/engines/asylum/module.mk
@@ -21,7 +21,8 @@ MODULE_OBJS := \
shared.o \
cursor.o \
polygons.o \
- actionlist.o
+ actionlist.o \
+ worldstats.o
# This module can be built as a plugin
ifeq ($(ENABLE_ASYLUM), DYNAMIC_PLUGIN)
diff --git a/engines/asylum/sceneres.h b/engines/asylum/sceneres.h
index 99405e62dc..698e2cdbe8 100644
--- a/engines/asylum/sceneres.h
+++ b/engines/asylum/sceneres.h
@@ -27,8 +27,6 @@
#define ASYLUM_SCENERESOURCE_H_
#include "common/file.h"
-#include "common/array.h"
-#include "common/rect.h"
#include "asylum/actor.h"
#include "asylum/barrier.h"
@@ -36,13 +34,13 @@
#include "asylum/respack.h"
#include "asylum/polygons.h"
#include "asylum/actionlist.h"
+#include "asylum/worldstats.h"
#define SCENEMASK "scn.%03d"
namespace Asylum {
class AsylumEngine;
-class WorldStats;
struct ActionArea;
class SceneResource {
@@ -76,119 +74,6 @@ private:
}; // end of class Scene
-typedef struct CommonResources {
- uint32 backgroundImage;
- uint32 curScrollUp;
- uint32 curScrollUpLeft;
- uint32 curScrollLeft;
- uint32 curScrollDownLeft;
- uint32 curScrollDown;
- uint32 curScrollDownRight;
- uint32 curScrollRight;
- uint32 curScrollUpRight;
- uint32 curHand;
- uint32 curMagnifyingGlass;
- uint32 curTalkNCP;
- uint32 curGrabPointer;
- uint32 curTalkNCP2;
- uint32 font1;
- uint32 font2;
- uint32 font3;
- uint32 palette;
- uint32 cellShadeMask1;
- uint32 cellShadeMask2;
- uint32 cellShadeMask3;
- uint32 unused;
- uint32 smallCurUp;
- uint32 smallCurDown;
- uint32 encounterFrameBg;
-
-} CommonResources;
-
-class WorldStats {
-public:
- WorldStats() {};
- virtual ~WorldStats() {
- barriers.clear();
- actors.clear();
- actions.clear();
- };
-
- uint32 size;
- uint32 numEntries;
- uint32 numChapter;
- uint32 xLeft; // scene start x position
- uint32 yTop; // scene start y position
- Common::Rect boundingRect;
- CommonResources commonRes; // field_1C till field_7C
- uint32 width; // field_80
- uint32 height;
- uint32 motionStatus;
- uint32 field_8C;
- uint32 numActions; // field_90
- uint32 numBarriers;
- uint32 targetX;
- uint32 targetY;
- uint32 field_A0;
- uint32 field_A4;
- uint32 field_A8;
- uint32 field_AC;
- uint32 field_B0;
- uint32 numActors; // Max and all other characters that have
- // own interactions
- uint32 stereoReversedFlag;
- Common::Rect sceneRects[6]; // including scene size rect
- uint8 sceneRectIdx;
- uint8 field_11D[3];
- uint32 field_120;
- uint32 actionListIdx; // actionList start index
- uint32 grResId[100];
- uint32 sceneTitleGrResId;
- uint32 sceneTitlePalResId;
- uint32 actorType;
- uint32 soundResId[50];
- AmbientSoundItem ambientSounds[15];
- uint32 numAmbientSound;
- uint32 musicStatus;
- uint32 musicCurrentResId;
- uint32 musicFlag;
- uint32 musicResId;
- uint32 musicStatusExt;
-
- // FIXME: Investigate if we need to actually reserve maxsize for this arrays.
- // It always have that size under scene file and they are always save in savegames.
- Common::Array<Barrier> barriers; // maxsize 400
- Common::Array<Actor> actors; // maxsize 50
- // TODO add rest fields
- Common::Array<ActionArea> actions; // maxsize 400
- // TODO add rest fields
- uint32 field_E860C;
- // TODO add rest fields
-}; // end of class WorldStats
-
-typedef struct ActionArea {
- char name[52];
- uint32 id;
- uint32 field01;
- uint32 field02;
- uint32 field_40;
- uint32 field_44;
- uint32 flags;
- uint32 actionListIdx1;
- uint32 actionListIdx2;
- uint32 actionType; // aka flags2: 0-none, 1-findwhat, 2-talk, 3-findwhat??, 4-grab
- uint32 flagNums[10];
- uint32 field_7C;
- uint32 polyIdx;
- uint32 field_84;
- uint32 field_88;
- uint32 soundResId;
- uint32 field_90;
- uint32 paletteValue;
- uint32 array[5];
- uint32 volume;
-} ActionArea;
-
} // end of namespace Asylum
#endif
diff --git a/engines/asylum/worldstats.cpp b/engines/asylum/worldstats.cpp
new file mode 100644
index 0000000000..449ec293aa
--- /dev/null
+++ b/engines/asylum/worldstats.cpp
@@ -0,0 +1,41 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#include "worldstats.h"
+
+namespace Asylum {
+
+WorldStats::WorldStats() {
+ // TODO Auto-generated constructor stub
+
+}
+
+WorldStats::~WorldStats() {
+ barriers.clear();
+ actors.clear();
+ actions.clear();
+}
+
+} // end of namespace Asylum
diff --git a/engines/asylum/worldstats.h b/engines/asylum/worldstats.h
new file mode 100644
index 0000000000..6cc69fd16e
--- /dev/null
+++ b/engines/asylum/worldstats.h
@@ -0,0 +1,151 @@
+/* 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.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#ifndef ASYLUM_WORLDSTATS_H_
+#define ASYLUM_WORLDSTATS_H_
+
+#include "common/rect.h"
+#include "common/array.h"
+
+#include "asylum/actor.h"
+#include "asylum/barrier.h"
+#include "asylum/sound.h"
+
+namespace Asylum {
+
+typedef struct CommonResources {
+ uint32 backgroundImage;
+ uint32 curScrollUp;
+ uint32 curScrollUpLeft;
+ uint32 curScrollLeft;
+ uint32 curScrollDownLeft;
+ uint32 curScrollDown;
+ uint32 curScrollDownRight;
+ uint32 curScrollRight;
+ uint32 curScrollUpRight;
+ uint32 curHand;
+ uint32 curMagnifyingGlass;
+ uint32 curTalkNCP;
+ uint32 curGrabPointer;
+ uint32 curTalkNCP2;
+ uint32 font1;
+ uint32 font2;
+ uint32 font3;
+ uint32 palette;
+ uint32 cellShadeMask1;
+ uint32 cellShadeMask2;
+ uint32 cellShadeMask3;
+ uint32 unused;
+ uint32 smallCurUp;
+ uint32 smallCurDown;
+ uint32 encounterFrameBg;
+
+} CommonResources;
+
+typedef struct ActionArea {
+ char name[52];
+ uint32 id;
+ uint32 field01;
+ uint32 field02;
+ uint32 field_40;
+ uint32 field_44;
+ uint32 flags;
+ uint32 actionListIdx1;
+ uint32 actionListIdx2;
+ uint32 actionType; // aka flags2: 0-none, 1-findwhat, 2-talk, 3-findwhat??, 4-grab
+ uint32 flagNums[10];
+ uint32 field_7C;
+ uint32 polyIdx;
+ uint32 field_84;
+ uint32 field_88;
+ uint32 soundResId;
+ uint32 field_90;
+ uint32 paletteValue;
+ uint32 array[5];
+ uint32 volume;
+
+} ActionArea;
+
+class WorldStats {
+public:
+ WorldStats();
+ virtual ~WorldStats();
+
+ uint32 size;
+ uint32 numEntries;
+ uint32 numChapter;
+ uint32 xLeft; // scene start x position
+ uint32 yTop; // scene start y position
+ Common::Rect boundingRect;
+ CommonResources commonRes; // field_1C till field_7C
+ uint32 width; // field_80
+ uint32 height;
+ uint32 motionStatus;
+ uint32 field_8C;
+ uint32 numActions; // field_90
+ uint32 numBarriers;
+ uint32 targetX;
+ uint32 targetY;
+ uint32 field_A0;
+ uint32 field_A4;
+ uint32 field_A8;
+ uint32 field_AC;
+ uint32 field_B0;
+ uint32 numActors; // Max and all other characters that have
+ // own interactions
+ uint32 stereoReversedFlag;
+ Common::Rect sceneRects[6]; // including scene size rect
+ uint8 sceneRectIdx;
+ uint8 field_11D[3];
+ uint32 field_120;
+ uint32 actionListIdx; // actionList start index
+ uint32 grResId[100];
+ uint32 sceneTitleGrResId;
+ uint32 sceneTitlePalResId;
+ uint32 actorType;
+ uint32 soundResId[50];
+ AmbientSoundItem ambientSounds[15];
+ uint32 numAmbientSound;
+ uint32 musicStatus;
+ uint32 musicCurrentResId;
+ uint32 musicFlag;
+ uint32 musicResId;
+ uint32 musicStatusExt;
+
+ // FIXME: Investigate if we need to actually reserve maxsize for this arrays.
+ // It always have that size under scene file and they are always save in savegames.
+ Common::Array<Barrier> barriers; // maxsize 400
+ Common::Array<Actor> actors; // maxsize 50
+ // TODO add rest fields
+ Common::Array<ActionArea> actions; // maxsize 400
+ // TODO add rest fields
+ uint32 field_E860C;
+ // TODO add rest fields
+
+};
+
+} // end of namespace Asylum
+
+#endif
Commit: dc50ebf55f9e0c8cd73ea867695a102a5bc74304
https://github.com/scummvm/scummvm/commit/dc50ebf55f9e0c8cd73ea867695a102a5bc74304
Author: Alex Bevilacqua (alexbevi at gmail.com)
Date: 2021-05-17T15:35:47+02:00
Commit Message:
ASYLUM: polygon point cleanup moved to polygons destructor
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@344 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/polygons.cpp
engines/asylum/sceneres.cpp
diff --git a/engines/asylum/polygons.cpp b/engines/asylum/polygons.cpp
index aec4428cf7..c40e5a61c9 100644
--- a/engines/asylum/polygons.cpp
+++ b/engines/asylum/polygons.cpp
@@ -33,6 +33,9 @@ Polygons::Polygons() {
}
Polygons::~Polygons() {
+ for (int i = 0; i < numEntries; i++)
+ delete[] entries[i].points;
+
entries.clear();
}
diff --git a/engines/asylum/sceneres.cpp b/engines/asylum/sceneres.cpp
index bf6baff2ef..c8f53239cd 100644
--- a/engines/asylum/sceneres.cpp
+++ b/engines/asylum/sceneres.cpp
@@ -32,11 +32,6 @@ SceneResource::SceneResource() {
SceneResource::~SceneResource() {
delete _worldStats;
-
- uint8 i;
- for (i = 0; i < _gamePolygons->numEntries; i++)
- delete[] _gamePolygons->entries[i].points;
-
delete _gamePolygons;
delete _actionList;
}
Commit: 103f2513f187cc4b5258df0073ef76f5e5e5dddb
https://github.com/scummvm/scummvm/commit/103f2513f187cc4b5258df0073ef76f5e5e5dddb
Author: Alex Bevilacqua (alexbevi at gmail.com)
Date: 2021-05-17T15:35:48+02:00
Commit Message:
ASYLUM: cleanup
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@345 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/polygons.cpp
diff --git a/engines/asylum/polygons.cpp b/engines/asylum/polygons.cpp
index c40e5a61c9..e1c99dd1bb 100644
--- a/engines/asylum/polygons.cpp
+++ b/engines/asylum/polygons.cpp
@@ -34,7 +34,7 @@ Polygons::Polygons() {
Polygons::~Polygons() {
for (int i = 0; i < numEntries; i++)
- delete[] entries[i].points;
+ delete[] entries[i].points;
entries.clear();
}
Commit: 779cac61a947525d50cae48158886017ac3b241c
https://github.com/scummvm/scummvm/commit/779cac61a947525d50cae48158886017ac3b241c
Author: Alex Bevilacqua (alexbevi at gmail.com)
Date: 2021-05-17T15:35:48+02:00
Commit Message:
ASYLUM: moved getActorX and getBarrierX from sceneres to worldstats
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@346 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/actor.cpp
engines/asylum/encounters.cpp
engines/asylum/sceneres.cpp
engines/asylum/sceneres.h
engines/asylum/scriptman.cpp
engines/asylum/worldstats.cpp
engines/asylum/worldstats.h
diff --git a/engines/asylum/actor.cpp b/engines/asylum/actor.cpp
index 8786c0274d..b6223af21a 100644
--- a/engines/asylum/actor.cpp
+++ b/engines/asylum/actor.cpp
@@ -311,7 +311,7 @@ void Actor::faceTarget(int targetId, int targetType) {
if (targetType) {
if (targetType == 1) {
- int actionIdx = Shared.getScene()->getResources()->getActionAreaIndexById(targetId);
+ int actionIdx = Shared.getScene()->getResources()->getWorldStats()->getActionAreaIndexById(targetId);
if (actionIdx == -1) {
warning("No ActionArea found for id %d", targetId);
return;
@@ -331,13 +331,13 @@ void Actor::faceTarget(int targetId, int targetType) {
}
}
} else {
- int barrierIdx = Shared.getScene()->getResources()->getBarrierIndexById(targetId);
+ int barrierIdx = Shared.getScene()->getResources()->getWorldStats()->getBarrierIndexById(targetId);
if (barrierIdx == -1) {
warning("No Barrier found for id %d", targetId);
return;
}
- Barrier *barrier = Shared.getScene()->getResources()->getBarrierByIndex(barrierIdx);
+ Barrier *barrier = Shared.getScene()->getResources()->getWorldStats()->getBarrierByIndex(barrierIdx);
GraphicResource *gra = new GraphicResource(_resPack, barrier->resId);
// FIXME
diff --git a/engines/asylum/encounters.cpp b/engines/asylum/encounters.cpp
index 42a40e3892..8943c1e2e2 100644
--- a/engines/asylum/encounters.cpp
+++ b/engines/asylum/encounters.cpp
@@ -76,7 +76,7 @@ void Encounter::run(int encounterIdx, int barrierId1, int barrierId2, int charac
setVariable(1, 0);
setVariable(2, _currentEncounter->value);
- Barrier *b1 = _scene->getResources()->getBarrierById(barrierId1);
+ Barrier *b1 = _scene->getResources()->getWorldStats()->getBarrierById(barrierId1);
/*
int __cdecl runEncounter(int newMessageHandler, int encounterIndex, int objectId1, int objectId2, int characterIndex)
{
diff --git a/engines/asylum/sceneres.cpp b/engines/asylum/sceneres.cpp
index c8f53239cd..24edced3bb 100644
--- a/engines/asylum/sceneres.cpp
+++ b/engines/asylum/sceneres.cpp
@@ -36,33 +36,6 @@ SceneResource::~SceneResource() {
delete _actionList;
}
-int SceneResource::getActionAreaIndexById(uint32 id) {
- for (uint32 i = 0; i < _worldStats->numActions; i++) {
- if (_worldStats->actions[i].id == id)
- return i;
- }
- return -1;
-}
-
-ActionArea* SceneResource::getActionAreaById(uint32 id) {
- return &_worldStats->actions[getActionAreaIndexById(id)];
-}
-
-int SceneResource::getBarrierIndexById(uint32 id) {
- for (uint32 i=0; i < _worldStats->numBarriers; i++) {
- if (_worldStats->barriers[i].id == id)
- return i;
- }
- return -1;
-}
-
-Barrier* SceneResource::getBarrierById(uint32 id) {
- return &_worldStats->barriers[getBarrierIndexById(id)];
-}
-
-Barrier* SceneResource::getBarrierByIndex(uint32 idx) {
- return &_worldStats->barriers[idx];
-}
bool SceneResource::load(uint8 sceneIdx) {
char sceneTag[6];
diff --git a/engines/asylum/sceneres.h b/engines/asylum/sceneres.h
index 698e2cdbe8..7068df8c30 100644
--- a/engines/asylum/sceneres.h
+++ b/engines/asylum/sceneres.h
@@ -53,12 +53,6 @@ public:
WorldStats* getWorldStats() { return _worldStats; }
Polygons* getGamePolygons() { return _gamePolygons; }
ActionList* getActionList() { return _actionList; }
-
- int getBarrierIndexById(uint32 id);
- int getActionAreaIndexById(uint32 id);
- ActionArea* getActionAreaById(uint32 id);
- Barrier* getBarrierById(uint32 id);
- Barrier* getBarrierByIndex(uint32 idx);
private:
diff --git a/engines/asylum/scriptman.cpp b/engines/asylum/scriptman.cpp
index 323fdec1d9..6343a043dd 100644
--- a/engines/asylum/scriptman.cpp
+++ b/engines/asylum/scriptman.cpp
@@ -191,14 +191,14 @@ void ScriptManager::setScriptIndex(uint32 index) {
}
int ScriptManager::checkBarrierFlags(int barrierId) {
- int flags = Shared.getScene()->getResources()->getBarrierById(barrierId)->flags;
+ int flags = Shared.getScene()->getResources()->getWorldStats()->getBarrierById(barrierId)->flags;
return flags & 1 && (flags & 8 || flags & 0x10000);
}
int ScriptManager::setBarrierNextFrame(int barrierId, int barrierFlags) {
- int barrierIndex = Shared.getScene()->getResources()->getBarrierIndexById(barrierId);
+ int barrierIndex = Shared.getScene()->getResources()->getWorldStats()->getBarrierIndexById(barrierId);
- Barrier *barrier = Shared.getScene()->getResources()->getBarrierByIndex(barrierIndex);
+ Barrier *barrier = Shared.getScene()->getResources()->getWorldStats()->getBarrierByIndex(barrierIndex);
int newFlag = barrierFlags | 1 | barrier->flags;
barrier->flags |= barrierFlags | 1;
@@ -280,7 +280,7 @@ void ScriptManager::processActionListSub02(ActionDefinitions* script, ActionComm
int v8 = command->param4;
for (int i = 7; i > 0; i--) {
- barrierIdx = Shared.getScene()->getResources()->getBarrierIndexById(v8);
+ barrierIdx = Shared.getScene()->getResources()->getWorldStats()->getBarrierIndexById(v8);
if (barrierIdx >= 0)
Shared.getScene()->getResources()->getWorldStats()->barriers[barrierIdx].field_67C = 0;
v8 += 4;
@@ -310,7 +310,7 @@ void ScriptManager::processActionListSub02(ActionDefinitions* script, ActionComm
int v13 = command->param4;
int v4 = script->counter / command->param2 + 4;
for (int i = 7; i > 0; i--) {
- barrierIdx = Shared.getScene()->getResources()->getBarrierIndexById(v13);
+ barrierIdx = Shared.getScene()->getResources()->getWorldStats()->getBarrierIndexById(v13);
if (barrierIdx >= 0)
Shared.getScene()->getResources()->getWorldStats()->barriers[barrierIdx].field_67C = v4;
v13 += 4;
@@ -417,13 +417,13 @@ int kPlayAnimation(ActionCommand *cmd) {
}
ScriptMan.lineIncrement = 1;
} else {
- int barrierIndex = Shared.getScene()->getResources()->getBarrierIndexById(barrierId);
- Barrier *barrier = Shared.getScene()->getResources()->getBarrierByIndex(barrierIndex);
+ int barrierIndex = Shared.getScene()->getResources()->getWorldStats()->getBarrierIndexById(barrierId);
+ Barrier *barrier = Shared.getScene()->getResources()->getWorldStats()->getBarrierByIndex(barrierIndex);
if (cmd->param4) { // RECHECK THIS
int newBarriedIndex = 213 * barrierIndex;
barrier->flags &= 0xFFFEF1C7;
- Shared.getScene()->getResources()->getBarrierByIndex(newBarriedIndex)->flags = barrier->flags | 0x20;
+ Shared.getScene()->getResources()->getWorldStats()->getBarrierByIndex(newBarriedIndex)->flags = barrier->flags | 0x20;
} else if (cmd->param3) {
barrier->flags &= 0xFFFEF1C7;
barrier->flags |= 0x10000;
@@ -601,7 +601,7 @@ int kEnableActor(ActionCommand *cmd) {
}
int kEnableBarriers(ActionCommand *cmd) {
- int barIdx = Shared.getScene()->getResources()->getBarrierIndexById(cmd->param1);
+ int barIdx = Shared.getScene()->getResources()->getWorldStats()->getBarrierIndexById(cmd->param1);
uint32 sndIdx = cmd->param3;
uint32 v59 = cmd->param2;
@@ -644,7 +644,7 @@ int kReturn(ActionCommand *cmd) {
}
int kDestroyBarrier(ActionCommand *cmd) {
- Barrier *barrier = Shared.getScene()->getResources()->getBarrierById(cmd->param1);
+ Barrier *barrier = Shared.getScene()->getResources()->getWorldStats()->getBarrierById(cmd->param1);
if (barrier) {
barrier->flags &= 0xFFFFFFFE;
@@ -674,7 +674,7 @@ int k_unk15(ActionCommand *cmd) {
}
int kResetAnimation(ActionCommand *cmd) {
- Barrier *barrier = Shared.getScene()->getResources()->getBarrierById(cmd->param1);
+ Barrier *barrier = Shared.getScene()->getResources()->getWorldStats()->getBarrierById(cmd->param1);
if ((barrier->flags & 0x10000) == 0)
barrier->frameIdx = 0;
@@ -685,7 +685,7 @@ int kResetAnimation(ActionCommand *cmd) {
}
int kClearFlag1Bit0(ActionCommand *cmd) {
- Barrier *barrier = Shared.getScene()->getResources()->getBarrierById(cmd->param1);
+ Barrier *barrier = Shared.getScene()->getResources()->getWorldStats()->getBarrierById(cmd->param1);
barrier->flags &= 0xFFFFFFFE;
@@ -705,10 +705,10 @@ int kJumpIfFlag2Bit0(ActionCommand *cmd) {
// look at the disassembly again
if (targetType <= 0)
- ScriptMan.done = (Shared.getScene()->getResources()->getBarrierById(cmd->param1)->flags2 & 1) == 0;
+ ScriptMan.done = (Shared.getScene()->getResources()->getWorldStats()->getBarrierById(cmd->param1)->flags2 & 1) == 0;
else
if (targetType == 1) // v4 == 1, so 1
- ScriptMan.done = (Shared.getScene()->getResources()->getActionAreaById(cmd->param1)->actionType & 1) == 0;
+ ScriptMan.done = (Shared.getScene()->getResources()->getWorldStats()->getActionAreaById(cmd->param1)->actionType & 1) == 0;
else
ScriptMan.done = (Shared.getScene()->getResources()->getWorldStats()->actors[cmd->param1].flags2 & 1) == 0;
@@ -722,9 +722,9 @@ int kSetFlag2Bit0(ActionCommand *cmd) {
Shared.getScene()->getResources()->getWorldStats()->actors[cmd->param1].flags2 |= 1;
else
if (targetType == 1)
- Shared.getScene()->getResources()->getActionAreaById(cmd->param1)->actionType |= 1;
+ Shared.getScene()->getResources()->getWorldStats()->getActionAreaById(cmd->param1)->actionType |= 1;
else
- Shared.getScene()->getResources()->getBarrierById(cmd->param1)->flags2 |= 1;
+ Shared.getScene()->getResources()->getWorldStats()->getBarrierById(cmd->param1)->flags2 |= 1;
return 0;
}
@@ -879,7 +879,7 @@ int k_unk3C_CMP_VAL(ActionCommand *cmd) {
}
int kWaitUntilFramePlayed(ActionCommand *cmd) {
- Barrier *barrier = Shared.getScene()->getResources()->getBarrierById(cmd->param1);
+ Barrier *barrier = Shared.getScene()->getResources()->getWorldStats()->getBarrierById(cmd->param1);
if (barrier) {
uint32 frameNum = 0;
@@ -1016,7 +1016,7 @@ int kQuit(ActionCommand *cmd) {
}
int kJumpBarrierFrame(ActionCommand *cmd) {
- Barrier *barrier = Shared.getScene()->getResources()->getBarrierById(cmd->param1);
+ Barrier *barrier = Shared.getScene()->getResources()->getWorldStats()->getBarrierById(cmd->param1);
if (cmd->param2 == -1)
cmd->param2 = barrier->frameCount - 1;
@@ -1101,7 +1101,7 @@ int kSetResourcePalette(ActionCommand *cmd) {
}
int kSetBarrierFrameIdxFlaged(ActionCommand *cmd) {
- Barrier *barrier = Shared.getScene()->getResources()->getBarrierById(cmd->param1);
+ Barrier *barrier = Shared.getScene()->getResources()->getWorldStats()->getBarrierById(cmd->param1);
if (cmd->param3)
barrier->flags = 1 | barrier->flags;
@@ -1133,7 +1133,7 @@ int k_unk5E(ActionCommand *cmd) {
}
int kSetBarrierLastFrameIdx(ActionCommand *cmd) {
- Barrier *barrier = Shared.getScene()->getResources()->getBarrierById(cmd->param1);
+ Barrier *barrier = Shared.getScene()->getResources()->getWorldStats()->getBarrierById(cmd->param1);
if (barrier->frameIdx == barrier->frameCount - 1) {
ScriptMan.lineIncrement = 0;
diff --git a/engines/asylum/worldstats.cpp b/engines/asylum/worldstats.cpp
index 449ec293aa..bd6f4d5679 100644
--- a/engines/asylum/worldstats.cpp
+++ b/engines/asylum/worldstats.cpp
@@ -38,4 +38,34 @@ WorldStats::~WorldStats() {
actions.clear();
}
+int WorldStats::getActionAreaIndexById(uint32 id) {
+ for (uint32 i = 0; i < numActions; i++) {
+ if (actions[i].id == id)
+ return i;
+ }
+
+ return -1;
+}
+
+ActionArea* WorldStats::getActionAreaById(uint32 id) {
+ return &actions[getActionAreaIndexById(id)];
+}
+
+int WorldStats::getBarrierIndexById(uint32 id) {
+ for (uint32 i = 0; i < numBarriers; i++) {
+ if (barriers[i].id == id)
+ return i;
+ }
+
+ return -1;
+}
+
+Barrier* WorldStats::getBarrierById(uint32 id) {
+ return &barriers[getBarrierIndexById(id)];
+}
+
+Barrier* WorldStats::getBarrierByIndex(uint32 idx) {
+ return &barriers[idx];
+}
+
} // end of namespace Asylum
diff --git a/engines/asylum/worldstats.h b/engines/asylum/worldstats.h
index 6cc69fd16e..40285cb7b1 100644
--- a/engines/asylum/worldstats.h
+++ b/engines/asylum/worldstats.h
@@ -144,6 +144,13 @@ public:
uint32 field_E860C;
// TODO add rest fields
+ int getActionAreaIndexById(uint32 id);
+ ActionArea* getActionAreaById(uint32 id);
+
+ int getBarrierIndexById(uint32 id);
+ Barrier* getBarrierById(uint32 id);
+ Barrier* getBarrierByIndex(uint32 idx);
+
};
} // end of namespace Asylum
Commit: 2cb80c6d8d1a90735ad4d327fa87e5feb48a1447
https://github.com/scummvm/scummvm/commit/2cb80c6d8d1a90735ad4d327fa87e5feb48a1447
Author: Alex Bevilacqua (alexbevi at gmail.com)
Date: 2021-05-17T15:35:48+02:00
Commit Message:
ASYLUM: Removed sceneres. Scene resource loading is now handled in the scene constructor, and the parsing of worldstats, polygons and actions is farmed out to the relevant classes.
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@347 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
R engines/asylum/sceneres.cpp
R engines/asylum/sceneres.h
engines/asylum/actionlist.cpp
engines/asylum/actionlist.h
engines/asylum/actor.cpp
engines/asylum/asylum.cpp
engines/asylum/asylum.vcproj
engines/asylum/barrier.cpp
engines/asylum/blowuppuzzle.cpp
engines/asylum/console.cpp
engines/asylum/cursor.h
engines/asylum/encounters.cpp
engines/asylum/module.mk
engines/asylum/polygons.cpp
engines/asylum/polygons.h
engines/asylum/scene.cpp
engines/asylum/scene.h
engines/asylum/screen.cpp
engines/asylum/scriptman.cpp
engines/asylum/scriptman.h
engines/asylum/shared.h
engines/asylum/worldstats.cpp
engines/asylum/worldstats.h
diff --git a/engines/asylum/actionlist.cpp b/engines/asylum/actionlist.cpp
index c76dd4f24b..ef479b0b95 100644
--- a/engines/asylum/actionlist.cpp
+++ b/engines/asylum/actionlist.cpp
@@ -27,13 +27,47 @@
namespace Asylum {
-ActionList::ActionList() {
- // TODO Auto-generated constructor stub
-
+ActionList::ActionList(Common::SeekableReadStream *stream) {
+ load(stream);
}
ActionList::~ActionList() {
entries.clear();
}
+void ActionList::load(Common::SeekableReadStream *stream) {
+ size = stream->readUint32LE();
+ numEntries = stream->readUint32LE();
+
+ for (uint32 a = 0; a < numEntries; a++) {
+ ActionDefinitions action;
+ memset(&action, 0, sizeof(ActionDefinitions));
+
+ for (uint32 c = 0; c < MAX_ACTION_COMMANDS; c++) {
+ ActionCommand command;
+ memset(&command, 0, sizeof(ActionCommand));
+
+ command.numLines = stream->readUint32LE();
+ command.opcode = stream->readUint32LE(); // command type
+ command.param1 = stream->readUint32LE(); // command parameters
+ command.param2 = stream->readUint32LE();
+ command.param3 = stream->readUint32LE();
+ command.param4 = stream->readUint32LE();
+ command.param5 = stream->readUint32LE();
+ command.param6 = stream->readUint32LE();
+ command.param7 = stream->readUint32LE();
+ command.param8 = stream->readUint32LE();
+ command.param9 = stream->readUint32LE();
+
+ action.commands[c] = command;
+ }
+
+ action.field_1BAC = stream->readUint32LE();
+ action.field_1BB0 = stream->readUint32LE();
+ action.counter = stream->readUint32LE();
+
+ entries.push_back(action);
+ }
+}
+
} // end of namespace Asylum
diff --git a/engines/asylum/actionlist.h b/engines/asylum/actionlist.h
index d16503448f..8c5f25d794 100644
--- a/engines/asylum/actionlist.h
+++ b/engines/asylum/actionlist.h
@@ -27,6 +27,7 @@
#define ASYLUM_ACTIONLIST_H_
#include "common/array.h"
+#include "common/stream.h"
namespace Asylum {
@@ -57,7 +58,7 @@ typedef struct ActionDefinitions {
class ActionList {
public:
- ActionList();
+ ActionList(Common::SeekableReadStream *stream);
virtual ~ActionList();
uint32 size;
@@ -65,6 +66,10 @@ public:
Common::Array<ActionDefinitions> entries;
+private:
+
+ void load(Common::SeekableReadStream *stream);
+
};
} // end of namespace Asylum
diff --git a/engines/asylum/actor.cpp b/engines/asylum/actor.cpp
index b6223af21a..8f2f0ce039 100644
--- a/engines/asylum/actor.cpp
+++ b/engines/asylum/actor.cpp
@@ -28,13 +28,12 @@
#include "asylum/actor.h"
#include "asylum/screen.h"
#include "asylum/shared.h"
-#include "asylum/sceneres.h"
namespace Asylum {
Actor::Actor() {
_graphic = 0;
- currentAction = 0;
+ currentAction = 0;
_currentWalkArea = 0;
}
@@ -130,7 +129,7 @@ GraphicFrame *Actor::getFrame() {
void Actor::drawActorAt(uint16 curX, uint16 curY) {
GraphicFrame *frame = getFrame();
- WorldStats *ws = Shared.getScene()->getResources()->getWorldStats();
+ WorldStats *ws = Shared.getScene()->worldstats();
Shared.getScreen()->copyRectToScreenWithTransparency(
((byte *)frame->surface.pixels),
@@ -145,7 +144,7 @@ void Actor::drawActorAt(uint16 curX, uint16 curY) {
void Actor::drawActor() {
GraphicFrame *frame = getFrame();
- WorldStats *ws = Shared.getScene()->getResources()->getWorldStats();
+ WorldStats *ws = Shared.getScene()->worldstats();
Shared.getScreen()->copyToBackBufferWithTransparency(
((byte *)frame->surface.pixels),
@@ -166,7 +165,7 @@ void Actor::setWalkArea(ActionArea *target) {
void Actor::walkTo(uint16 curX, uint16 curY) {
int newAction = currentAction;
- WorldStats *ws = Shared.getScene()->getResources()->getWorldStats();
+ WorldStats *ws = Shared.getScene()->worldstats();
// step is the increment by which to move the
// actor in a given direction
@@ -246,7 +245,7 @@ void Actor::walkTo(uint16 curX, uint16 curY) {
for (uint32 a = 0; a < ws->numActions; a++) {
if (ws->actions[a].actionType == 0) {
area = &ws->actions[a];
- PolyDefinitions poly = Shared.getScene()->getResources()->getGamePolygons()->entries[area->polyIdx];
+ PolyDefinitions poly = Shared.getScene()->polygons()->entries[area->polyIdx];
if (poly.contains(x, y)) {
availableAreas[areaPtr] = a;
areaPtr++;
@@ -264,7 +263,7 @@ void Actor::walkTo(uint16 curX, uint16 curY) {
// walkable regions
for (int i = 0; i < areaPtr; i++) {
area = &ws->actions[availableAreas[i]];
- PolyDefinitions *region = &Shared.getScene()->getResources()->getGamePolygons()->entries[area->polyIdx];
+ PolyDefinitions *region = &Shared.getScene()->polygons()->entries[area->polyIdx];
if (region->contains(newX, newY)) {
x = newX;
y = newY;
@@ -311,14 +310,14 @@ void Actor::faceTarget(int targetId, int targetType) {
if (targetType) {
if (targetType == 1) {
- int actionIdx = Shared.getScene()->getResources()->getWorldStats()->getActionAreaIndexById(targetId);
+ int actionIdx = Shared.getScene()->worldstats()->getActionAreaIndexById(targetId);
if (actionIdx == -1) {
warning("No ActionArea found for id %d", targetId);
return;
}
- uint32 polyIdx = Shared.getScene()->getResources()->getWorldStats()->actions[actionIdx].polyIdx;
- PolyDefinitions *poly = &Shared.getScene()->getResources()->getGamePolygons()->entries[polyIdx];
+ uint32 polyIdx = Shared.getScene()->worldstats()->actions[actionIdx].polyIdx;
+ PolyDefinitions *poly = &Shared.getScene()->polygons()->entries[polyIdx];
newX2 = poly->boundingRect.left + (poly->boundingRect.right - poly->boundingRect.left) / 2;
newY2 = poly->boundingRect.top + (poly->boundingRect.bottom - poly->boundingRect.top) / 2;
@@ -331,13 +330,13 @@ void Actor::faceTarget(int targetId, int targetType) {
}
}
} else {
- int barrierIdx = Shared.getScene()->getResources()->getWorldStats()->getBarrierIndexById(targetId);
+ int barrierIdx = Shared.getScene()->worldstats()->getBarrierIndexById(targetId);
if (barrierIdx == -1) {
warning("No Barrier found for id %d", targetId);
return;
}
- Barrier *barrier = Shared.getScene()->getResources()->getWorldStats()->getBarrierByIndex(barrierIdx);
+ Barrier *barrier = Shared.getScene()->worldstats()->getBarrierByIndex(barrierIdx);
GraphicResource *gra = new GraphicResource(_resPack, barrier->resId);
// FIXME
diff --git a/engines/asylum/asylum.cpp b/engines/asylum/asylum.cpp
index 461db83562..1710d5d9c8 100644
--- a/engines/asylum/asylum.cpp
+++ b/engines/asylum/asylum.cpp
@@ -154,9 +154,9 @@ void AsylumEngine::waitForTimer(int msec_delay) {
void AsylumEngine::playIntro() {
_video->playVideo(1, kSubtitlesOn);
- if (_scene->getResources()->getWorldStats()->musicCurrentResId != 0xFFFFFD66)
+ if (_scene->worldstats()->musicCurrentResId != 0xFFFFFD66)
_sound->playMusic(_scene->getMusicPack(),
- _scene->getResources()->getWorldStats()->musicCurrentResId);
+ _scene->worldstats()->musicCurrentResId);
_screen->clearScreen();
diff --git a/engines/asylum/asylum.vcproj b/engines/asylum/asylum.vcproj
index 0eb2634bbc..e4d408665c 100644
--- a/engines/asylum/asylum.vcproj
+++ b/engines/asylum/asylum.vcproj
@@ -40,9 +40,7 @@
<File RelativePath="..\..\engines\asylum\respack.cpp" />
<File RelativePath="..\..\engines\asylum\respack.h" />
<File RelativePath="..\..\engines\asylum\scene.cpp" />
- <File RelativePath="..\..\engines\asylum\scene.h" />
- <File RelativePath="..\..\engines\asylum\sceneres.cpp" />
- <File RelativePath="..\..\engines\asylum\sceneres.h" />
+ <File RelativePath="..\..\engines\asylum\scene.h" />
<File RelativePath="..\..\engines\asylum\screen.cpp" />
<File RelativePath="..\..\engines\asylum\screen.h" />
<File RelativePath="..\..\engines\asylum\scriptman.cpp" />
diff --git a/engines/asylum/barrier.cpp b/engines/asylum/barrier.cpp
index d08c6c2bce..93f230df33 100644
--- a/engines/asylum/barrier.cpp
+++ b/engines/asylum/barrier.cpp
@@ -73,7 +73,7 @@ uint32 Barrier::getRandomId() {
}
bool Barrier::onscreen() {
- WorldStats *ws = Shared.getScene()->getResources()->getWorldStats();
+ WorldStats *ws = Shared.getScene()->worldstats();
Common::Rect screenRect = Common::Rect(ws->xLeft, ws->yTop, ws->xLeft + 640, ws->yTop + 480);
Common::Rect barrierRect = boundingRect;
barrierRect.translate(x, y);
diff --git a/engines/asylum/blowuppuzzle.cpp b/engines/asylum/blowuppuzzle.cpp
index 3c03927355..7422fc52d4 100644
--- a/engines/asylum/blowuppuzzle.cpp
+++ b/engines/asylum/blowuppuzzle.cpp
@@ -43,7 +43,7 @@ BlowUpPuzzleVCR::BlowUpPuzzleVCR() {
_leftClickDown = false;
_rightClickDown = false;
_active = false;
- _bgResource = Shared.getScene()->getGraphicResource(Shared.getScene()->getResources()->getWorldStats()->grResId[0]);
+ _bgResource = Shared.getScene()->getGraphicResource(Shared.getScene()->worldstats()->grResId[0]);
_tvScreenAnimIdx = 0;
_isAccomplished = false;
@@ -68,14 +68,14 @@ void BlowUpPuzzleVCR::openBlowUp() {
//Shared.getSound()->stopSfx();
// Load the graphics palette
- Shared.getScreen()->setPalette(Shared.getScene()->getResourcePack(), Shared.getScene()->getResources()->getWorldStats()->grResId[29]);
+ Shared.getScreen()->setPalette(Shared.getScene()->getResourcePack(), Shared.getScene()->worldstats()->grResId[29]);
// show blow up puzzle BG
GraphicFrame *bg = _bgResource->getFrame(0);
Shared.getScreen()->copyToBackBuffer((byte *)bg->surface.pixels, bg->surface.w, 0, 0, bg->surface.w, bg->surface.h);
// Set mouse cursor
- _cursor->load(Shared.getScene()->getResources()->getWorldStats()->grResId[28]);
+ _cursor->load(Shared.getScene()->worldstats()->grResId[28]);
_cursor->show();
_leftClickUp = false;
@@ -149,8 +149,8 @@ void BlowUpPuzzleVCR::update() {
updateStopButton();
if(_buttonsState[kPower] == kON) {
- Shared.getScreen()->addGraphicToQueue(Shared.getScene()->getResources()->getWorldStats()->grResId[22], _tvScreenAnimIdx, 0, 37, 0, 0, 1);
- Shared.getScreen()->addGraphicToQueue(Shared.getScene()->getResources()->getWorldStats()->grResId[23], _tvScreenAnimIdx++, 238, 22, 0, 0, 1);
+ Shared.getScreen()->addGraphicToQueue(Shared.getScene()->worldstats()->grResId[22], _tvScreenAnimIdx, 0, 37, 0, 0, 1);
+ Shared.getScreen()->addGraphicToQueue(Shared.getScene()->worldstats()->grResId[23], _tvScreenAnimIdx++, 238, 22, 0, 0, 1);
_tvScreenAnimIdx %= 6;
}
@@ -183,7 +183,7 @@ GraphicQueueItem BlowUpPuzzleVCR::getGraphicJackItem(int resId) {
jackY = 356;
}
- jackItemOnHand.resId = Shared.getScene()->getResources()->getWorldStats()->grResId[resId];
+ jackItemOnHand.resId = Shared.getScene()->worldstats()->grResId[resId];
jackItemOnHand.frameIdx = 0;
jackItemOnHand.x = _cursor->x() - 114;
jackItemOnHand.y = jackY - 14;
@@ -199,7 +199,7 @@ GraphicQueueItem BlowUpPuzzleVCR::getGraphicShadowItem() {
if(_cursor->y() < 356) {
shadowY = 0;
}
- shadowItem.resId = Shared.getScene()->getResources()->getWorldStats()->grResId[30];
+ shadowItem.resId = Shared.getScene()->worldstats()->grResId[30];
shadowItem.frameIdx = 0;
shadowItem.x = _cursor->x() - shadowY;
shadowItem.y = 450;
@@ -213,28 +213,28 @@ void BlowUpPuzzleVCR::updateJack(Jack jack, VCRDrawInfo onTable, VCRDrawInfo plu
switch(_jacksState[jack]){
case kOnTable:
- item.resId = Shared.getScene()->getResources()->getWorldStats()->grResId[onTable.resId];
+ item.resId = Shared.getScene()->worldstats()->grResId[onTable.resId];
item.frameIdx = 0;
item.x = onTable.x;
item.y = onTable.y;
item.priority = 3;
break;
case kPluggedOnRed:
- item.resId = Shared.getScene()->getResources()->getWorldStats()->grResId[pluggedOnRed.resId];
+ item.resId = Shared.getScene()->worldstats()->grResId[pluggedOnRed.resId];
item.frameIdx = 0;
item.x = 329;
item.y = 407;
item.priority = 3;
break;
case kPluggedOnYellow:
- item.resId = Shared.getScene()->getResources()->getWorldStats()->grResId[pluggedOnYellow.resId];
+ item.resId = Shared.getScene()->worldstats()->grResId[pluggedOnYellow.resId];
item.frameIdx = 0;
item.x = 402;
item.y = 413;
item.priority = 3;
break;
case kPluggedOnBlack:
- item.resId = Shared.getScene()->getResources()->getWorldStats()->grResId[pluggedOnBlack.resId];
+ item.resId = Shared.getScene()->worldstats()->grResId[pluggedOnBlack.resId];
item.frameIdx = 0;
item.x = 477;
item.y = 418;
@@ -319,13 +319,13 @@ int BlowUpPuzzleVCR::setJackOnHole(int jackType, JackState plugged) {
if(_jacksState[jackType-1] == kOnHand) {
_jacksState[jackType-1] = plugged;
_holesState[plugged-1] = jackType; // set jack on red
- Shared.getSound()->playSfx(Shared.getScene()->getResourcePack(), Shared.getScene()->getResources()->getWorldStats()->grResId[44]);
+ Shared.getSound()->playSfx(Shared.getScene()->getResourcePack(), Shared.getScene()->worldstats()->grResId[44]);
}
} else if(jackType == 0) {
jackType = _holesState[plugged-1];
_jacksState[jackType-1] = kOnHand;
_holesState[plugged-1] = 0;
- Shared.getSound()->playSfx(Shared.getScene()->getResourcePack(), Shared.getScene()->getResources()->getWorldStats()->grResId[43]);
+ Shared.getSound()->playSfx(Shared.getScene()->getResourcePack(), Shared.getScene()->worldstats()->grResId[43]);
return 0;
}
return 1;
@@ -336,7 +336,7 @@ void BlowUpPuzzleVCR::updateButton(Button button, VCRDrawInfo btON, VCRDrawInfo
switch(_buttonsState[button]){
case kON:
- item.resId = Shared.getScene()->getResources()->getWorldStats()->grResId[btON.resId];
+ item.resId = Shared.getScene()->worldstats()->grResId[btON.resId];
item.frameIdx = 0;
item.x = btON.x;
item.y = btON.y;
@@ -344,7 +344,7 @@ void BlowUpPuzzleVCR::updateButton(Button button, VCRDrawInfo btON, VCRDrawInfo
break;
case kDownON:
case kDownOFF:
- item.resId = Shared.getScene()->getResources()->getWorldStats()->grResId[btDown.resId];
+ item.resId = Shared.getScene()->worldstats()->grResId[btDown.resId];
item.frameIdx = 0;
item.x = btDown.x;
item.y = btDown.y;
@@ -504,7 +504,7 @@ void BlowUpPuzzleVCR::handleMouseDown() {
if (_cursor->x() >= (uint32)BlowUpPuzzleVCRPolies[kBlackJack].left && _cursor->x() <= (uint32)BlowUpPuzzleVCRPolies[kYellowJack].right &&
_cursor->y() >= (uint32)BlowUpPuzzleVCRPolies[kBlackJack].top && _cursor->y() <= (uint32)BlowUpPuzzleVCRPolies[kYellowJack].bottom) {
_jacksState[jackType-1] = kOnTable;
- Shared.getSound()->playSfx(Shared.getScene()->getResourcePack(), Shared.getScene()->getResources()->getWorldStats()->grResId[50]);
+ Shared.getSound()->playSfx(Shared.getScene()->getResourcePack(), Shared.getScene()->worldstats()->grResId[50]);
_cursor->show();
}
return;
@@ -521,7 +521,7 @@ void BlowUpPuzzleVCR::handleMouseDown() {
// TODO: VCR button regions
if (inPolyRegion(_cursor->x(), _cursor->y(), kRewindButton)) {
- Shared.getSound()->playSfx(Shared.getScene()->getResourcePack(), Shared.getScene()->getResources()->getWorldStats()->grResId[39]);
+ Shared.getSound()->playSfx(Shared.getScene()->getResourcePack(), Shared.getScene()->worldstats()->grResId[39]);
if(!_buttonsState[kRewind]) {
_buttonsState[kRewind] = kDownON;
return;
@@ -531,7 +531,7 @@ void BlowUpPuzzleVCR::handleMouseDown() {
return;
}
} else if (inPolyRegion(_cursor->x(), _cursor->y(), kPlayButton)) {
- Shared.getSound()->playSfx(Shared.getScene()->getResourcePack(), Shared.getScene()->getResources()->getWorldStats()->grResId[39]);
+ Shared.getSound()->playSfx(Shared.getScene()->getResourcePack(), Shared.getScene()->worldstats()->grResId[39]);
if(!_buttonsState[kPlay]) {
_buttonsState[kPlay] = kDownON;
return;
@@ -541,7 +541,7 @@ void BlowUpPuzzleVCR::handleMouseDown() {
return;
}
} else if (inPolyRegion(_cursor->x(), _cursor->y(), kStopButton)) {
- Shared.getSound()->playSfx(Shared.getScene()->getResourcePack(), Shared.getScene()->getResources()->getWorldStats()->grResId[39]);
+ Shared.getSound()->playSfx(Shared.getScene()->getResourcePack(), Shared.getScene()->worldstats()->grResId[39]);
if(_buttonsState[kStop]) {
if(_buttonsState[kStop] == kON) {
_buttonsState[kStop] = kDownOFF;
@@ -552,7 +552,7 @@ void BlowUpPuzzleVCR::handleMouseDown() {
return;
}
} else if (inPolyRegion(_cursor->x(), _cursor->y(), kPowerButton)) {
- Shared.getSound()->playSfx(Shared.getScene()->getResourcePack(), Shared.getScene()->getResources()->getWorldStats()->grResId[39]);
+ Shared.getSound()->playSfx(Shared.getScene()->getResourcePack(), Shared.getScene()->worldstats()->grResId[39]);
if(!_buttonsState[kPower] && _holesState[kPluggedOnBlack-1] == kBlack+1 && _holesState[kPluggedOnRed-1] && _holesState[kPluggedOnYellow-1]) {
_buttonsState[kPower] = kDownON;
@@ -568,7 +568,7 @@ void BlowUpPuzzleVCR::handleMouseUp() {
if(_buttonsState[kPower] == kDownON) {
// TODO: check if next sound is already playing
- Shared.getSound()->playSfx(Shared.getScene()->getResourcePack(), Shared.getScene()->getResources()->getWorldStats()->grResId[47]);
+ Shared.getSound()->playSfx(Shared.getScene()->getResourcePack(), Shared.getScene()->worldstats()->grResId[47]);
_buttonsState[kPower] = kON;
_buttonsState[kStop] = kON;
_buttonsState[kPlay] = kON;
@@ -583,7 +583,7 @@ void BlowUpPuzzleVCR::handleMouseUp() {
if(_buttonsState[kRewind] == kDownOFF) {
_buttonsState[kRewind] = kON;
- Shared.getSound()->playSfx(Shared.getScene()->getResourcePack(), Shared.getScene()->getResources()->getWorldStats()->grResId[46]);
+ Shared.getSound()->playSfx(Shared.getScene()->getResourcePack(), Shared.getScene()->worldstats()->grResId[46]);
} else if(_buttonsState[kRewind] == kDownON) {
_buttonsState[kRewind] = kOFF;
}
diff --git a/engines/asylum/console.cpp b/engines/asylum/console.cpp
index 317dfbada3..f7ef89abd6 100644
--- a/engines/asylum/console.cpp
+++ b/engines/asylum/console.cpp
@@ -56,8 +56,8 @@ bool Console::cmdDumpActionArea(int argc, const char **argv) {
if (argc == 2) {
// TODO Get an action area by index/id
} else {
- for (uint32 i = 0; i < Shared.getScene()->getResources()->getWorldStats()->numActions; i++) {
- ActionArea *a = &Shared.getScene()->getResources()->getWorldStats()->actions[i];
+ for (uint32 i = 0; i < Shared.getScene()->worldstats()->numActions; i++) {
+ ActionArea *a = &Shared.getScene()->worldstats()->actions[i];
printActionAreaStats(a);
}
}
diff --git a/engines/asylum/cursor.h b/engines/asylum/cursor.h
index 59c2dac309..abb867b72f 100644
--- a/engines/asylum/cursor.h
+++ b/engines/asylum/cursor.h
@@ -26,7 +26,8 @@
#ifndef ASYLUM_CURSOR_H_
#define ASYLUM_CURSOR_H_
-#include "asylum/sceneres.h"
+#include "asylum/respack.h"
+#include "asylum/worldstats.h"
namespace Asylum {
diff --git a/engines/asylum/encounters.cpp b/engines/asylum/encounters.cpp
index 8943c1e2e2..4656104888 100644
--- a/engines/asylum/encounters.cpp
+++ b/engines/asylum/encounters.cpp
@@ -76,7 +76,7 @@ void Encounter::run(int encounterIdx, int barrierId1, int barrierId2, int charac
setVariable(1, 0);
setVariable(2, _currentEncounter->value);
- Barrier *b1 = _scene->getResources()->getWorldStats()->getBarrierById(barrierId1);
+ Barrier *b1 = _scene->worldstats()->getBarrierById(barrierId1);
/*
int __cdecl runEncounter(int newMessageHandler, int encounterIndex, int objectId1, int objectId2, int characterIndex)
{
diff --git a/engines/asylum/module.mk b/engines/asylum/module.mk
index d4607f5949..7a5fbbd9db 100644
--- a/engines/asylum/module.mk
+++ b/engines/asylum/module.mk
@@ -9,7 +9,6 @@ MODULE_OBJS := \
respack.o \
scene.o \
barrier.o \
- sceneres.o \
screen.o \
sound.o \
text.o \
diff --git a/engines/asylum/polygons.cpp b/engines/asylum/polygons.cpp
index e1c99dd1bb..c5678be153 100644
--- a/engines/asylum/polygons.cpp
+++ b/engines/asylum/polygons.cpp
@@ -27,9 +27,8 @@
namespace Asylum {
-Polygons::Polygons() {
- // TODO Auto-generated constructor stub
-
+Polygons::Polygons(Common::SeekableReadStream *stream) {
+ load(stream);
}
Polygons::~Polygons() {
@@ -63,9 +62,34 @@ bool PolyDefinitions::contains(int x, int y) {
}
return inside_flag;
+}
+
+void Polygons::load(Common::SeekableReadStream *stream) {
+ size = stream->readUint32LE();
+ numEntries = stream->readUint32LE();
+
+ for (uint32 g = 0; g < numEntries; g++) {
+ PolyDefinitions poly;
+ memset(&poly, 0, sizeof(PolyDefinitions));
+ poly.numPoints = stream->readUint32LE();
+ if (poly.numPoints > 0)
+ poly.points = new Common::Point[poly.numPoints];
+ for (uint32 i = 0; i < poly.numPoints; i++) {
+ poly.points[i].x = stream->readUint32LE() & 0xFFFF;
+ poly.points[i].y = stream->readUint32LE() & 0xFFFF;
+ }
+
+ stream->skip((MAX_POLYGONS - poly.numPoints) * 8);
+ poly.boundingRect.left = stream->readUint32LE() & 0xFFFF;
+ poly.boundingRect.top = stream->readUint32LE() & 0xFFFF;
+ poly.boundingRect.right = stream->readUint32LE() & 0xFFFF;
+ poly.boundingRect.bottom = stream->readUint32LE() & 0xFFFF;
+
+ entries.push_back(poly);
+ }
}
} // end of namespace Asylum
diff --git a/engines/asylum/polygons.h b/engines/asylum/polygons.h
index a944e2baaf..58fc5e996e 100644
--- a/engines/asylum/polygons.h
+++ b/engines/asylum/polygons.h
@@ -28,6 +28,7 @@
#include "common/array.h"
#include "common/rect.h"
+#include "common/stream.h"
#define MAX_POLYGONS 200
@@ -50,7 +51,7 @@ typedef struct PolyDefinitions {
class Polygons {
public:
- Polygons();
+ Polygons(Common::SeekableReadStream *stream);
virtual ~Polygons();
uint32 size;
@@ -58,6 +59,10 @@ public:
Common::Array<PolyDefinitions> entries;
+private:
+
+ void load(Common::SeekableReadStream *stream);
+
}; // end of class Polygons
} // end of namespace Asylum
diff --git a/engines/asylum/scene.cpp b/engines/asylum/scene.cpp
index a536bfecab..f54396bb51 100644
--- a/engines/asylum/scene.cpp
+++ b/engines/asylum/scene.cpp
@@ -37,36 +37,59 @@ int g_debugPolygons;
int g_debugBarriers;
Scene::Scene(uint8 sceneIdx) {
- _sceneIdx = sceneIdx;
- _sceneResource = new SceneResource;
+ _sceneIdx = sceneIdx;
- if (_sceneResource->load(_sceneIdx)) {
- _text = new Text(Shared.getScreen());
- _resPack = new ResourcePack(sceneIdx);
- _speechPack = new ResourcePack(3);
+ char filename[10];
+ sprintf(filename, SCENE_FILE_MASK, sceneIdx);
- // FIXME
- // Is there EVER more than one actor enabled for a scene? I can't
- // remember, so I guess a playthrough is in order :P
- // Either way, this is kinda dumb
- for (uint8 i = 0; i < _sceneResource->getWorldStats()->numActors; i++)
- _sceneResource->getWorldStats()->actors[i].setResourcePack(_resPack);
+ char sceneTag[6];
+ Common::File* fd = new Common::File;
- _text->loadFont(_resPack, _sceneResource->getWorldStats()->commonRes.font1);
+ if (!fd->exists(filename))
+ error("Scene file doesn't exist %s", filename);
- char musPackFileName[10];
- sprintf(musPackFileName, "mus.%03d", sceneIdx);
- _musPack = new ResourcePack(musPackFileName);
- _bgResource = new GraphicResource(_resPack, _sceneResource->getWorldStats()->commonRes.backgroundImage);
+ fd->open(filename);
- _blowUp = 0;
- }
+ if (!fd->isOpen())
+ error("Failed to load scene file %s", filename);
+
+ fd->read(sceneTag, 6);
+
+ if (Common::String(sceneTag,6) != "DFISCN")
+ error("The file isn't recognized as scene %s", filename);
+
+ _ws = new WorldStats(fd);
+ // jump to game polygons data
+ fd->seek(0xE8686);
+ _polygons = new Polygons(fd);
+ // jump to action list data
+ fd->seek(0xE868E + _polygons->size * _polygons->numEntries);
+ _actions = new ActionList(fd);
+
+ fd->close();
+ delete fd;
+
+ _text = new Text(Shared.getScreen());
+ _resPack = new ResourcePack(sceneIdx);
+ _speechPack = new ResourcePack(3); // FIXME are all scene speech packs the same?
+
+ // FIXME
+ // Is there EVER more than one actor enabled for a scene? I can't
+ // remember, so I guess a playthrough is in order :P
+ // Either way, this is kinda dumb
+ for (uint8 i = 0; i < _ws->numActors; i++)
+ _ws->actors[i].setResourcePack(_resPack);
- _cursor = new Cursor(_resPack);
+ _text->loadFont(_resPack, _ws->commonRes.font1);
+ char musPackFileName[10];
+ sprintf(musPackFileName, "mus.%03d", sceneIdx);
+ _musPack = new ResourcePack(musPackFileName);
+
+ _bgResource = new GraphicResource(_resPack, _ws->commonRes.backgroundImage);
+ _blowUp = 0;
+ _cursor = new Cursor(_resPack);
_background = 0;
- //_startX = 0;
- //_startY = 0;
_leftClick = false;
_rightButton = false;
_isActive = false;
@@ -78,51 +101,53 @@ Scene::Scene(uint8 sceneIdx) {
Shared.setGameFlag(183);
// TODO: do all the rest stuffs in sub at address 40E460
- WorldStats *worldStats = _sceneResource->getWorldStats();
_playerActorIdx = 0;
- if (worldStats->numBarriers > 0) {
+ if (_ws->numBarriers > 0) {
uint32 priority = 0x0FFB;
- for (uint32 b = 0; b < worldStats->numBarriers; b++) {
- Barrier *barrier = &worldStats->barriers[b];
+ for (uint32 b = 0; b < _ws->numBarriers; b++) {
+ Barrier *barrier = &_ws->barriers[b];
barrier->priority = priority;
barrier->flags &= 0xFFFF3FFF;
priority -= 4;
}
}
- worldStats->sceneRectIdx = 0;
+ _ws->sceneRectIdx = 0;
Shared.getScreen()->clearGraphicsInQueue();
- worldStats->motionStatus = 1;
+ _ws->motionStatus = 1;
// TODO: do some rect stuffs from player actor
// TODO: reset actors flags
}
Scene::~Scene() {
+ delete _ws;
+ delete _polygons;
+ delete _actions;
+
delete _cursor;
delete _bgResource;
delete _musPack;
delete _speechPack;
delete _resPack;
delete _text;
- delete _sceneResource;
delete _blowUp;
- }
+}
Actor* Scene::getActor() {
- return &_sceneResource->getWorldStats()->actors[_playerActorIdx];
+ return &_ws->actors[_playerActorIdx];
}
void Scene::enterScene() {
- WorldStats *ws = _sceneResource->getWorldStats();
+ WorldStats *ws = _ws;
Shared.getScreen()->setPalette(_resPack, ws->commonRes.palette);
_background = _bgResource->getFrame(0);
Shared.getScreen()->copyToBackBuffer(
((byte *)_background->surface.pixels) + ws->targetY * _background->surface.w + ws->targetX, _background->surface.w,
0, 0, 640, 480);
- _cursor->load(_sceneResource->getWorldStats()->commonRes.curMagnifyingGlass);
+ _cursor->load(_ws->commonRes.curMagnifyingGlass);
_cursor->show();
// Music testing: play the first music track
@@ -133,22 +158,19 @@ void Scene::enterScene() {
}
ActionDefinitions* Scene::getDefaultActionList() {
- if (_sceneResource)
- return getActionList(_sceneResource->getWorldStats()->actionListIdx);
- else
- return 0;
+ getActionList(_ws->actionListIdx);
}
ActionDefinitions* Scene::getActionList(int actionListIndex) {
- if ((actionListIndex >= 0) && (actionListIndex < (int)_sceneResource->getWorldStats()->numActions))
- return &_sceneResource->getActionList()->entries[actionListIndex];
+ if ((actionListIndex >= 0) && (actionListIndex < (int)_ws->numActions))
+ return &actions()->entries[actionListIndex];
else
return 0;
}
void Scene::setScenePosition(int x, int y)
{
- WorldStats *ws = _sceneResource->getWorldStats();
+ WorldStats *ws = _ws;
GraphicFrame *bg = _bgResource->getFrame(0);
//_startX = x;
//_startY = y;
@@ -186,7 +208,7 @@ void Scene::handleEvent(Common::Event *event, bool doUpdate) {
// TODO This isn't always going to be the magnifying glass
// Should check the current pointer region to identify the type
// of cursor to use
- _cursor->load(_sceneResource->getWorldStats()->commonRes.curMagnifyingGlass);
+ _cursor->load(_ws->commonRes.curMagnifyingGlass);
_rightButton = false;
}
break;
@@ -217,7 +239,7 @@ void Scene::update() {
int Scene::updateScene() {
uint32 startTick = 0;
- WorldStats *worldStats = _sceneResource->getWorldStats();
+ WorldStats *worldStats = _ws;
// Mouse
startTick = Shared.getMillis();
@@ -397,7 +419,7 @@ void Scene::updateMouse() {
}
void Scene::updateActor(uint32 actorIdx) {
- WorldStats *ws = _sceneResource->getWorldStats();
+ WorldStats *ws = _ws;
Actor *actor = getActor();
if (actor->visible()) {
@@ -641,7 +663,7 @@ void Scene::updateMusic() {
}
void Scene::updateAdjustScreen() {
- WorldStats *ws = _sceneResource->getWorldStats();
+ WorldStats *ws = _ws;
int v5, v6, v7, v15, v16;
int v1 = -1;
@@ -776,7 +798,7 @@ void Scene::OLD_UPDATE(WorldStats *worldStats) {
for (uint32 a = 0; a < worldStats->numActions; a++) {
if (worldStats->actions[a].actionType == 0) {
ActionArea *area = &worldStats->actions[a];
- PolyDefinitions poly = _sceneResource->getGamePolygons()->entries[area->polyIdx];
+ PolyDefinitions poly = _polygons->entries[area->polyIdx];
if (poly.contains(getActor()->x, getActor()->y)) {
debugShowWalkRegion(&poly);
//break;
@@ -785,7 +807,7 @@ void Scene::OLD_UPDATE(WorldStats *worldStats) {
}
if (!_rightButton) {
- if (_sceneResource->getWorldStats()->actors[0].flags & 0x01) { // TESTING - only draw if visible flag
+ if (_ws->actors[0].flags & 0x01) { // TESTING - only draw if visible flag
// Check if the character was walking before the right-button
// was released. If so, change the resource to one where he/she
// is standing still, facing the last active direction
@@ -800,7 +822,7 @@ void Scene::OLD_UPDATE(WorldStats *worldStats) {
_walking = true;
getActor()->walkTo(_cursor->x(), _cursor->y());
- _cursor->update(&_sceneResource->getWorldStats()->commonRes, getActor()->direction);
+ _cursor->update(&_ws->commonRes, getActor()->direction);
}
if (g_debugPolygons)
@@ -830,8 +852,8 @@ void Scene::OLD_UPDATE(WorldStats *worldStats) {
// of the barrier/polygon action scripts should be processed first
if (curBarrier < 0) {
// Update cursor if it's in a polygon hotspot
- for (uint32 p = 0; p < _sceneResource->getGamePolygons()->numEntries; p++) {
- PolyDefinitions poly = _sceneResource->getGamePolygons()->entries[p];
+ for (uint32 p = 0; p < _polygons->numEntries; p++) {
+ PolyDefinitions poly = _polygons->entries[p];
if (poly.boundingRect.contains(_cursor->x() + worldStats->targetX, _cursor->y() + worldStats->targetY)) {
if (poly.contains(_cursor->x() + worldStats->targetX, _cursor->y() + worldStats->targetY)) {
curHotspot = (int32)p;
@@ -856,7 +878,7 @@ void Scene::OLD_UPDATE(WorldStats *worldStats) {
worldStats->actions[a].actionListIdx2,
worldStats->actions[a].actionType,
worldStats->actions[a].soundResId);
- ScriptMan.setScript(&_sceneResource->getActionList()->entries[worldStats->actions[a].actionListIdx1]);
+ ScriptMan.setScript(&_actions->entries[worldStats->actions[a].actionListIdx1]);
}
}
} else if (curBarrier >= 0) {
@@ -884,7 +906,7 @@ int Scene::drawScene() {
Shared.getScreen()->clearScreen();
} else {
// Draw scene background
- WorldStats *ws = _sceneResource->getWorldStats();
+ WorldStats *ws = _ws;
GraphicFrame *bg = _bgResource->getFrame(0);
Shared.getScreen()->copyToBackBuffer(
((byte *)bg->surface.pixels) + ws->targetY * bg->surface.w + ws->targetX, bg->surface.w,
@@ -912,7 +934,7 @@ int Scene::drawScene() {
}
int Scene::drawBarriers() {
- WorldStats *worldStats = _sceneResource->getWorldStats();
+ WorldStats *worldStats = _ws;
uint barriersCount = worldStats->barriers.size();
if (barriersCount > 0) {
@@ -944,7 +966,7 @@ int Scene::drawBarriers() {
// ----------------------------------
void Scene::copyToBackBufferClipped(Graphics::Surface *surface, int x, int y) {
- WorldStats *ws = _sceneResource->getWorldStats();
+ WorldStats *ws = _ws;
Common::Rect screenRect(ws->targetX, ws->targetY, ws->targetX + 640, ws->targetY + 480);
Common::Rect animRect(x, y, x + surface->w, y + surface->h);
@@ -979,7 +1001,7 @@ void Scene::copyToBackBufferClipped(Graphics::Surface *surface, int x, int y) {
// ----------------------------------
void Scene::debugScreenScrolling(GraphicFrame *bg) {
- WorldStats *ws = _sceneResource->getWorldStats();
+ WorldStats *ws = _ws;
// Horizontal scrolling
if (_cursor->x() < SCREEN_EDGES && ws->targetX >= SCROLL_STEP)
@@ -1017,9 +1039,9 @@ void Scene::debugShowWalkRegion(PolyDefinitions *poly) {
// POLYGONS DEBUG
void Scene::debugShowPolygons() {
- for (uint32 p = 0; p < _sceneResource->getGamePolygons()->numEntries; p++) {
+ for (uint32 p = 0; p < _polygons->numEntries; p++) {
Graphics::Surface surface;
- PolyDefinitions poly = _sceneResource->getGamePolygons()->entries[p];
+ PolyDefinitions poly = _polygons->entries[p];
surface.create(poly.boundingRect.right - poly.boundingRect.left + 1,
poly.boundingRect.bottom - poly.boundingRect.top + 1,
1);
@@ -1041,9 +1063,9 @@ void Scene::debugShowPolygons() {
// BARRIER DEBUGGING
void Scene::debugShowBarriers() {
- for (uint32 p = 0; p < _sceneResource->getWorldStats()->numBarriers; p++) {
+ for (uint32 p = 0; p < _ws->numBarriers; p++) {
Graphics::Surface surface;
- Barrier b = _sceneResource->getWorldStats()->barriers[p];
+ Barrier b = _ws->barriers[p];
if (b.flags & 0x20) {
surface.create(b.boundingRect.right - b.boundingRect.left + 1,
diff --git a/engines/asylum/scene.h b/engines/asylum/scene.h
index 61178514a0..92885b3946 100644
--- a/engines/asylum/scene.h
+++ b/engines/asylum/scene.h
@@ -31,10 +31,13 @@
#include "asylum/asylum.h"
#include "asylum/respack.h"
#include "asylum/graphics.h"
+#include "asylum/worldstats.h"
+#include "asylum/polygons.h"
+#include "asylum/actionlist.h"
#include "asylum/text.h"
-#include "asylum/sceneres.h"
#include "asylum/cursor.h"
+#define SCENE_FILE_MASK "scn.%03d"
namespace Asylum {
@@ -43,15 +46,9 @@ class Sound;
class Video;
class Cursor;
class Text;
-class SceneResource;
-class WorldStats;
class BlowUpPuzzle;
-struct ActionDefinitions;
-struct PolyDefinitions;
struct BarrierItem;
-//uint32 playerTypeTable[16] = {0, 0, 0, 0, 1, 0, 2, 0, 3, 0, 1, 1, 3, 0, 0, 0};
-
class Scene {
public:
Scene(uint8 sceneIdx);
@@ -65,14 +62,13 @@ public:
bool isActive() { return _isActive; }
int getSceneIndex() { return _sceneIdx; }
+ // TODO roll into actionlist.cpp
ActionDefinitions* getDefaultActionList();
ActionDefinitions* getActionList(int actionListIndex);
-
Actor* getActor();
Cursor* getCursor() { return _cursor; }
- SceneResource* getResources() { return _sceneResource; }
ResourcePack* getResourcePack() { return _resPack; }
ResourcePack* getMusicPack() { return _musPack; }
ResourcePack* getSpeechPack() { return _speechPack; }
@@ -82,11 +78,17 @@ public:
void setBlowUpPuzzle(BlowUpPuzzle* puzzle) { _blowUp = puzzle; }
void setScenePosition(int x, int y);
+ WorldStats* worldstats() { return _ws; }
+ Polygons* polygons() { return _polygons; }
+ ActionList* actions() { return _actions; }
+
private:
- void copyToBackBufferClipped(Graphics::Surface *surface, int x, int y);
+ uint8 _sceneIdx;
+ WorldStats *_ws;
+ Polygons *_polygons;
+ ActionList *_actions;
+
Cursor *_cursor;
- uint8 _sceneIdx;
- SceneResource *_sceneResource;
ResourcePack *_resPack;
ResourcePack *_speechPack;
ResourcePack *_musPack;
@@ -97,8 +99,6 @@ private:
GraphicFrame *_background;
bool _walking;
- //int32 _startX;
- //int32 _startY;
bool _leftClick;
bool _rightButton;
bool _isActive;
@@ -119,6 +119,8 @@ private:
bool isBarrierOnScreen(BarrierItem *barrier);
uint32 getRandomResId(BarrierItem *barrier);
+ void copyToBackBufferClipped(Graphics::Surface *surface, int x, int y);
+
void debugScreenScrolling(GraphicFrame *bg);
void debugShowPolygons();
void debugShowBarriers();
diff --git a/engines/asylum/sceneres.cpp b/engines/asylum/sceneres.cpp
deleted file mode 100644
index 24edced3bb..0000000000
--- a/engines/asylum/sceneres.cpp
+++ /dev/null
@@ -1,457 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * $URL$
- * $Id$
- *
- */
-
-#include "asylum/sceneres.h"
-
-namespace Asylum {
-
-SceneResource::SceneResource() {
-}
-
-SceneResource::~SceneResource() {
- delete _worldStats;
- delete _gamePolygons;
- delete _actionList;
-}
-
-
-bool SceneResource::load(uint8 sceneIdx) {
- char sceneTag[6];
- Common::File* fd = new Common::File;
- Common::String filename = parseFilename(sceneIdx);
-
- if (!fd->exists(filename)) {
- warning("Scene file doesn't exist %s", filename.c_str());
- return false;
- }
-
- fd->open(filename);
-
- if (!fd->isOpen()) {
- warning("Failed to load scene file %s", filename.c_str());
- return false;
- }
-
- fd->read(sceneTag,6);
-
- if (Common::String(sceneTag,6) != "DFISCN") {
- warning("The file isn't recognized as scene %s", filename.c_str());
- return false;
- }
-
- loadWorldStats(fd);
- loadGamePolygons(fd);
- loadActionList(fd);
-
- fd->close();
- delete fd;
-
- return true;
-}
-
-// FIXME: load necessary World Stats content
-void SceneResource::loadWorldStats(Common::SeekableReadStream *stream) {
- _worldStats = new WorldStats;
-
- _worldStats->size = stream->readUint32LE();
- _worldStats->numEntries = stream->readUint32LE();
-
- _worldStats->numChapter = stream->readUint32LE();
- _worldStats->xLeft = stream->readUint32LE();
- _worldStats->yTop = stream->readUint32LE();
- _worldStats->boundingRect.left = stream->readUint32LE() & 0xFFFF;
- _worldStats->boundingRect.top = stream->readUint32LE() & 0xFFFF;
- _worldStats->boundingRect.right = stream->readUint32LE() & 0xFFFF;
- _worldStats->boundingRect.bottom = stream->readUint32LE() & 0xFFFF;
-
- // read common graphic resources
- _worldStats->commonRes.backgroundImage = stream->readUint32LE();
- _worldStats->commonRes.curScrollUp = stream->readUint32LE();
- _worldStats->commonRes.curScrollUpLeft = stream->readUint32LE();
- _worldStats->commonRes.curScrollLeft = stream->readUint32LE();
- _worldStats->commonRes.curScrollDownLeft = stream->readUint32LE();
- _worldStats->commonRes.curScrollDown = stream->readUint32LE();
- _worldStats->commonRes.curScrollDownRight = stream->readUint32LE();
- _worldStats->commonRes.curScrollRight = stream->readUint32LE();
- _worldStats->commonRes.curScrollUpRight = stream->readUint32LE();
- _worldStats->commonRes.curHand = stream->readUint32LE();
- _worldStats->commonRes.curMagnifyingGlass = stream->readUint32LE();
- _worldStats->commonRes.curTalkNCP = stream->readUint32LE();
- _worldStats->commonRes.curGrabPointer = stream->readUint32LE();
- _worldStats->commonRes.curTalkNCP2 = stream->readUint32LE();
- _worldStats->commonRes.font1 = stream->readUint32LE();
- _worldStats->commonRes.font2 = stream->readUint32LE();
- _worldStats->commonRes.font3 = stream->readUint32LE();
- _worldStats->commonRes.palette = stream->readUint32LE();
- _worldStats->commonRes.cellShadeMask1 = stream->readUint32LE();
- _worldStats->commonRes.cellShadeMask2 = stream->readUint32LE();
- _worldStats->commonRes.cellShadeMask3 = stream->readUint32LE();
- _worldStats->commonRes.unused = stream->readUint32LE();
- _worldStats->commonRes.smallCurUp = stream->readUint32LE();
- _worldStats->commonRes.smallCurDown = stream->readUint32LE();
- _worldStats->commonRes.encounterFrameBg = stream->readUint32LE();
-
- _worldStats->width = stream->readUint32LE();
- _worldStats->height = stream->readUint32LE();
- _worldStats->motionStatus = stream->readUint32LE();
- _worldStats->field_8C = stream->readUint32LE();
- _worldStats->numActions = stream->readUint32LE();
- _worldStats->numBarriers = stream->readUint32LE();
- _worldStats->targetX = stream->readUint32LE();
- _worldStats->targetY = stream->readUint32LE();
- _worldStats->field_A0 = stream->readUint32LE();
- _worldStats->field_A4 = stream->readUint32LE();
- _worldStats->field_A8 = stream->readUint32LE();
- _worldStats->field_AC = stream->readUint32LE();
- _worldStats->field_B0 = stream->readUint32LE();
- _worldStats->numActors = stream->readUint32LE();
- _worldStats->stereoReversedFlag = stream->readUint32LE();
-
- for (int r=0; r < 6; r++) {
- _worldStats->sceneRects[r].left = stream->readUint32LE() & 0xFFFF;
- _worldStats->sceneRects[r].top = stream->readUint32LE() & 0xFFFF;
- _worldStats->sceneRects[r].right = stream->readUint32LE() & 0xFFFF;
- _worldStats->sceneRects[r].bottom = stream->readUint32LE() & 0xFFFF;
- }
- _worldStats->sceneRectIdx = stream->readByte();
- _worldStats->field_11D[0] = stream->readByte();
- _worldStats->field_11D[1] = stream->readByte();
- _worldStats->field_11D[2] = stream->readByte();
-
- _worldStats->field_120 = stream->readUint32LE();
- _worldStats->actionListIdx = stream->readUint32LE();
-
- for (int gr=0; gr < 100; gr++) {
- _worldStats->grResId[gr] = stream->readUint32LE();
- }
-
- _worldStats->sceneTitleGrResId = stream->readUint32LE();
- _worldStats->sceneTitlePalResId = stream->readUint32LE();
- _worldStats->actorType = stream->readUint32LE();
-
- for(int s=0; s < 50; s++) {
- _worldStats->soundResId[s] = stream->readUint32LE();
- }
-
- for(int s=0; s < 15; s++) {
- _worldStats->ambientSounds[s].field_0 = stream->readUint32LE();
- _worldStats->ambientSounds[s].flags = stream->readUint32LE();
- _worldStats->ambientSounds[s].resId = stream->readUint32LE();
- _worldStats->ambientSounds[s].field_C = stream->readUint32LE();
- _worldStats->ambientSounds[s].field_10 = stream->readUint32LE();
- _worldStats->ambientSounds[s].field_14 = stream->readUint32LE();
-
- for(int i=0; i < 6; i++)
- _worldStats->ambientSounds[s].flagNum[i] = stream->readUint32LE();
-
- _worldStats->ambientSounds[s].x = stream->readUint32LE();
- _worldStats->ambientSounds[s].y = stream->readUint32LE();
- }
- _worldStats->numAmbientSound = stream->readUint32LE();
-
- _worldStats->musicStatus = stream->readUint32LE();
- _worldStats->musicCurrentResId = stream->readUint32LE();
- _worldStats->musicFlag = stream->readUint32LE();
- _worldStats->musicResId = stream->readUint32LE();
- _worldStats->musicStatusExt = stream->readUint32LE();
-
- for (uint32 a = 0; a < _worldStats->numBarriers; a++) {
- int i;
- Barrier barrier;
-
- barrier.id = stream->readUint32LE();
- barrier.resId = stream->readUint32LE();
- barrier.x = stream->readUint32LE();
- barrier.y = stream->readUint32LE();
-
- barrier.boundingRect.left = stream->readUint32LE() & 0xFFFF;
- barrier.boundingRect.top = stream->readUint32LE() & 0xFFFF;
- barrier.boundingRect.right = stream->readUint32LE() & 0xFFFF;
- barrier.boundingRect.bottom = stream->readUint32LE() & 0xFFFF;
-
- barrier.field_20 = stream->readUint32LE();
- barrier.frameIdx = stream->readUint32LE();
- barrier.frameCount = stream->readUint32LE();
- barrier.field_2C = stream->readUint32LE();
- barrier.field_30 = stream->readUint32LE();
- barrier.field_34 = stream->readUint32LE();
- barrier.flags = stream->readUint32LE();
- barrier.field_3C = stream->readUint32LE();
-
- stream->read(barrier.name, sizeof(barrier.name));
-
- barrier.field_74 = stream->readUint32LE();
- barrier.field_78 = stream->readUint32LE();
- barrier.field_7C = stream->readUint32LE();
- barrier.field_80 = stream->readUint32LE();
- barrier.polyIdx = stream->readUint32LE();
- barrier.flags2 = stream->readUint32LE();
-
- for (i = 0; i < 10; i++)
- barrier.gameFlags[i] = stream->readUint32LE();
-
- barrier.field_B4 = stream->readUint32LE();
- barrier.tickCount = stream->readUint32LE();
- barrier.tickCount2 = stream->readUint32LE();
- barrier.field_C0 = stream->readUint32LE();
- barrier.priority = stream->readUint32LE();
- barrier.actionListIdx = stream->readUint32LE();
-
- for (i = 0; i < 16; i++) {
- barrier.soundItems[i].resId = stream->readUint32LE();
- barrier.soundItems[i].field_4 = stream->readUint32LE();
- barrier.soundItems[i].field_8 = stream->readUint32LE();
- barrier.soundItems[i].field_C = stream->readUint32LE();
-
- }
-
- for (i = 0; i < 50; i++) {
- barrier.frameSoundItems[i].resId = stream->readUint32LE();
- barrier.frameSoundItems[i].frameIdx = stream->readUint32LE();
- barrier.frameSoundItems[i].index = stream->readUint32LE();
- barrier.frameSoundItems[i].field_C = stream->readUint32LE();
- barrier.frameSoundItems[i].field_10 = stream->readUint32LE();
- barrier.frameSoundItems[i].field_14 = stream->readUint32LE();
- }
-
- barrier.field_67C = stream->readUint32LE();
- barrier.soundX = stream->readUint32LE();
- barrier.soundY = stream->readUint32LE();
- barrier.field_688 = stream->readUint32LE();
-
- for (i = 0; i < 5; i++) {
- barrier.field_68C[i] = stream->readUint32LE();
- }
-
- barrier.soundResId = stream->readUint32LE();
- barrier.field_6A4 = stream->readUint32LE();
-
- _worldStats->barriers.push_back(barrier);
- }
-
- // need to jump all unused barriers data to where actors data start
- stream->seek(0xA6D7A);
-
- for (uint32 a = 0; a < _worldStats->numActors; a++) {
- int i;
- Actor actor;
-
- actor.x = stream->readUint32LE();
- actor.y = stream->readUint32LE();
- actor.grResId = stream->readUint32LE();
- actor.field_C = stream->readUint32LE();
- actor.frameNum = stream->readUint32LE();
- actor.frameCount = stream->readUint32LE();
- actor.x1 = stream->readUint32LE();
- actor.y1 = stream->readUint32LE();
- actor.x2 = stream->readUint32LE();
- actor.y2 = stream->readUint32LE();
-
- actor.boundingRect.left = stream->readUint32LE() & 0xFFFF;
- actor.boundingRect.top = stream->readUint32LE() & 0xFFFF;
- actor.boundingRect.right = stream->readUint32LE() & 0xFFFF;
- actor.boundingRect.bottom = stream->readUint32LE() & 0xFFFF;
-
- actor.direction = stream->readUint32LE();
- actor.field_3C = stream->readUint32LE();
- actor.field_40 = stream->readUint32LE();
- actor.field_44 = stream->readUint32LE();
- actor.field_48 = stream->readUint32LE();
- actor.flags = stream->readUint32LE();
- actor.field_50 = stream->readUint32LE();
- actor.field_54 = stream->readUint32LE();
- actor.field_58 = stream->readUint32LE();
- actor.field_5C = stream->readUint32LE();
- actor.field_60 = stream->readUint32LE();
- actor.actionIdx3 = stream->readUint32LE();
-
- // TODO skip field_68 till field_617
- stream->skip(0x5B0);
-
- for (i = 0; i < 8; i++)
- actor.reaction[i] = stream->readUint32LE();
-
- actor.field_638 = stream->readUint32LE();
- actor.walkingSound1 = stream->readUint32LE();
- actor.walkingSound2 = stream->readUint32LE();
- actor.walkingSound3 = stream->readUint32LE();
- actor.walkingSound4 = stream->readUint32LE();
- actor.field_64C = stream->readUint32LE();
- actor.field_650 = stream->readUint32LE();
-
- for (i = 0; i < 55; i++)
- actor.grResTable[i] = stream->readUint32LE();
-
- stream->read(actor.name, sizeof(actor.name));
-
- for (i = 0; i < 20; i++)
- actor.field_830[i] = stream->readUint32LE();
- for (i = 0; i < 20; i++)
- actor.field_880[i] = stream->readUint32LE();
- for (i = 0; i < 20; i++)
- actor.field_8D0[i] = stream->readUint32LE();
-
- actor.actionIdx2 = stream->readUint32LE();
- actor.field_924 = stream->readUint32LE();
- actor.tickValue1 = stream->readUint32LE();
- actor.field_92C = stream->readUint32LE();
- actor.flags2 = stream->readUint32LE();
- actor.field_934 = stream->readUint32LE();
- actor.field_938 = stream->readUint32LE();
- actor.soundResId = stream->readUint32LE();
-
- // TODO skip field_940 till field_978
- stream->skip(0x3C);
-
- actor.actionIdx1 = stream->readUint32LE();
-
- // TODO skip field_980 till field_9A0
- stream->skip(0x24);
-
- _worldStats->actors.push_back(actor);
- }
-
- // TODO Take this out, it shouldn't be here (TEST ONLY)
- stream->seek(0xA73B6);
-
- uint8 mainActorData[500];
- stream->read(mainActorData, 500);
-
- // FIXME
- // This is ONLY ever going to work for scenes where there's only
- // one actor in the worldStats->actors[] collection
- _worldStats->actors[0].setRawResources(mainActorData);
-
- stream->seek(0xD6B5A); // where action items start
-
- // FIXME Figure out all the actions items
- for (uint32 a = 0; a < _worldStats->numActions; a++) {
- ActionArea action;
- memset(&action, 0, sizeof(ActionArea));
-
- stream->read(action.name,52);
- action.id = stream->readUint32LE();
- action.field01 = stream->readUint32LE();
- action.field02 = stream->readUint32LE();
- action.field_40 = stream->readUint32LE();
- action.field_44 = stream->readUint32LE();
- action.flags = stream->readUint32LE();
- action.actionListIdx1 = stream->readUint32LE();
- action.actionListIdx2 = stream->readUint32LE();
- action.actionType = stream->readUint32LE();
- for (int aa1 = 0; aa1 < 10; aa1++)
- action.flagNums[aa1] = stream->readUint32LE();
- action.field_7C = stream->readUint32LE();
- action.polyIdx = stream->readUint32LE();
- action.field_84 = stream->readUint32LE();
- action.field_88 = stream->readUint32LE();
- action.soundResId = stream->readUint32LE();
- action.field_90 = stream->readUint32LE();
- action.paletteValue = stream->readUint32LE();
- for (int aa2 = 0; aa2 < 5; aa2++)
- action.array[aa2] = stream->readUint32LE();
- action.volume = stream->readUint32LE();
-
- _worldStats->actions.push_back(action);
- }
-}
-
-void SceneResource::loadGamePolygons(Common::SeekableReadStream *stream) {
- _gamePolygons = new Polygons;
-
- stream->seek(0xE8686); // jump to game Polygons data
-
- _gamePolygons->size = stream->readUint32LE();
- _gamePolygons->numEntries = stream->readUint32LE();
-
- for (uint32 g = 0; g < _gamePolygons->numEntries; g++) {
- PolyDefinitions poly;
- memset(&poly, 0, sizeof(PolyDefinitions));
-
- poly.numPoints = stream->readUint32LE();
- if (poly.numPoints > 0)
- poly.points = new Common::Point[poly.numPoints];
- for (uint32 i = 0; i < poly.numPoints; i++) {
- poly.points[i].x = stream->readUint32LE() & 0xFFFF;
- poly.points[i].y = stream->readUint32LE() & 0xFFFF;
- }
- stream->skip((MAX_POLYGONS - poly.numPoints) * 8);
-
- poly.boundingRect.left = stream->readUint32LE() & 0xFFFF;
- poly.boundingRect.top = stream->readUint32LE() & 0xFFFF;
- poly.boundingRect.right = stream->readUint32LE() & 0xFFFF;
- poly.boundingRect.bottom = stream->readUint32LE() & 0xFFFF;
-
- _gamePolygons->entries.push_back(poly);
- }
-}
-
-void SceneResource::loadActionList(Common::SeekableReadStream *stream) {
- _actionList = new ActionList;
-
- stream->seek(0xE868E + _gamePolygons->size * _gamePolygons->numEntries); // jump to action list data
-
- _actionList->size = stream->readUint32LE();
- _actionList->numEntries = stream->readUint32LE();
-
- for (uint32 a = 0; a < _actionList->numEntries; a++) {
- ActionDefinitions action;
- memset(&action, 0, sizeof(ActionDefinitions));
-
- for (uint32 c = 0; c < MAX_ACTION_COMMANDS; c++) {
- ActionCommand command;
- memset(&command, 0, sizeof(ActionCommand));
-
- command.numLines = stream->readUint32LE();
- command.opcode = stream->readUint32LE(); // command type
- command.param1 = stream->readUint32LE(); // command parameters
- command.param2 = stream->readUint32LE();
- command.param3 = stream->readUint32LE();
- command.param4 = stream->readUint32LE();
- command.param5 = stream->readUint32LE();
- command.param6 = stream->readUint32LE();
- command.param7 = stream->readUint32LE();
- command.param8 = stream->readUint32LE();
- command.param9 = stream->readUint32LE();
-
- action.commands[c] = command;
- }
-
- action.field_1BAC = stream->readUint32LE();
- action.field_1BB0 = stream->readUint32LE();
- action.counter = stream->readUint32LE();
-
- _actionList->entries.push_back(action);
- }
-}
-
-Common::String SceneResource::parseFilename(uint8 sceneIdx) {
- char filename[10];
- sprintf(filename, SCENEMASK, sceneIdx);
-
- return Common::String(filename);
-}
-
-} // end of namespace Asylum
diff --git a/engines/asylum/sceneres.h b/engines/asylum/sceneres.h
deleted file mode 100644
index 7068df8c30..0000000000
--- a/engines/asylum/sceneres.h
+++ /dev/null
@@ -1,73 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * $URL$
- * $Id$
- *
- */
-
-#ifndef ASYLUM_SCENERESOURCE_H_
-#define ASYLUM_SCENERESOURCE_H_
-
-#include "common/file.h"
-
-#include "asylum/actor.h"
-#include "asylum/barrier.h"
-#include "asylum/screen.h"
-#include "asylum/respack.h"
-#include "asylum/polygons.h"
-#include "asylum/actionlist.h"
-#include "asylum/worldstats.h"
-
-#define SCENEMASK "scn.%03d"
-
-namespace Asylum {
-
-class AsylumEngine;
-struct ActionArea;
-
-class SceneResource {
-public:
- SceneResource();
- virtual ~SceneResource();
-
- bool load(uint8 sceneIdx);
-
- WorldStats* getWorldStats() { return _worldStats; }
- Polygons* getGamePolygons() { return _gamePolygons; }
- ActionList* getActionList() { return _actionList; }
-
-private:
-
- WorldStats *_worldStats;
- Polygons *_gamePolygons;
- ActionList *_actionList;
-
- void loadWorldStats(Common::SeekableReadStream *stream);
- void loadGamePolygons(Common::SeekableReadStream *stream);
- void loadActionList(Common::SeekableReadStream *stream);
-
- Common::String parseFilename(uint8 sceneIdx);
-
-}; // end of class Scene
-
-} // end of namespace Asylum
-
-#endif
diff --git a/engines/asylum/screen.cpp b/engines/asylum/screen.cpp
index 7b0359a02a..61ffa803b4 100644
--- a/engines/asylum/screen.cpp
+++ b/engines/asylum/screen.cpp
@@ -136,12 +136,14 @@ void Screen::addGraphicToQueue(GraphicQueueItem item) {
}
void Screen::drawGraphicsInQueue() {
- WorldStats *ws = Shared.getScene()->getResources()->getWorldStats();
+ WorldStats *ws = Shared.getScene()->worldstats();
+
// sort by priority first
graphicsSelectionSort();
+
for(uint i = 0; i < _queueItems.size(); i++) {
GraphicResource *grRes = Shared.getScene()->getGraphicResource(_queueItems[i].resId);
- GraphicFrame *fra = grRes->getFrame(_queueItems[i].frameIdx);
+ GraphicFrame *fra = grRes->getFrame(_queueItems[i].frameIdx);
copyRectToScreenWithTransparency((byte *)fra->surface.pixels, fra->surface.w, _queueItems[i].x - ws->targetX, _queueItems[i].y - ws->targetY, fra->surface.w, fra->surface.h);
delete grRes;
}
diff --git a/engines/asylum/scriptman.cpp b/engines/asylum/scriptman.cpp
index 6343a043dd..1d1c65a4f9 100644
--- a/engines/asylum/scriptman.cpp
+++ b/engines/asylum/scriptman.cpp
@@ -191,14 +191,14 @@ void ScriptManager::setScriptIndex(uint32 index) {
}
int ScriptManager::checkBarrierFlags(int barrierId) {
- int flags = Shared.getScene()->getResources()->getWorldStats()->getBarrierById(barrierId)->flags;
+ int flags = Shared.getScene()->worldstats()->getBarrierById(barrierId)->flags;
return flags & 1 && (flags & 8 || flags & 0x10000);
}
int ScriptManager::setBarrierNextFrame(int barrierId, int barrierFlags) {
- int barrierIndex = Shared.getScene()->getResources()->getWorldStats()->getBarrierIndexById(barrierId);
+ int barrierIndex = Shared.getScene()->worldstats()->getBarrierIndexById(barrierId);
- Barrier *barrier = Shared.getScene()->getResources()->getWorldStats()->getBarrierByIndex(barrierIndex);
+ Barrier *barrier = Shared.getScene()->worldstats()->getBarrierByIndex(barrierIndex);
int newFlag = barrierFlags | 1 | barrier->flags;
barrier->flags |= barrierFlags | 1;
@@ -280,9 +280,9 @@ void ScriptManager::processActionListSub02(ActionDefinitions* script, ActionComm
int v8 = command->param4;
for (int i = 7; i > 0; i--) {
- barrierIdx = Shared.getScene()->getResources()->getWorldStats()->getBarrierIndexById(v8);
+ barrierIdx = Shared.getScene()->worldstats()->getBarrierIndexById(v8);
if (barrierIdx >= 0)
- Shared.getScene()->getResources()->getWorldStats()->barriers[barrierIdx].field_67C = 0;
+ Shared.getScene()->worldstats()->barriers[barrierIdx].field_67C = 0;
v8 += 4;
}
}
@@ -310,9 +310,9 @@ void ScriptManager::processActionListSub02(ActionDefinitions* script, ActionComm
int v13 = command->param4;
int v4 = script->counter / command->param2 + 4;
for (int i = 7; i > 0; i--) {
- barrierIdx = Shared.getScene()->getResources()->getWorldStats()->getBarrierIndexById(v13);
+ barrierIdx = Shared.getScene()->worldstats()->getBarrierIndexById(v13);
if (barrierIdx >= 0)
- Shared.getScene()->getResources()->getWorldStats()->barriers[barrierIdx].field_67C = v4;
+ Shared.getScene()->worldstats()->barriers[barrierIdx].field_67C = v4;
v13 += 4;
}
// TODO
@@ -417,13 +417,13 @@ int kPlayAnimation(ActionCommand *cmd) {
}
ScriptMan.lineIncrement = 1;
} else {
- int barrierIndex = Shared.getScene()->getResources()->getWorldStats()->getBarrierIndexById(barrierId);
- Barrier *barrier = Shared.getScene()->getResources()->getWorldStats()->getBarrierByIndex(barrierIndex);
+ int barrierIndex = Shared.getScene()->worldstats()->getBarrierIndexById(barrierId);
+ Barrier *barrier = Shared.getScene()->worldstats()->getBarrierByIndex(barrierIndex);
if (cmd->param4) { // RECHECK THIS
int newBarriedIndex = 213 * barrierIndex;
barrier->flags &= 0xFFFEF1C7;
- Shared.getScene()->getResources()->getWorldStats()->getBarrierByIndex(newBarriedIndex)->flags = barrier->flags | 0x20;
+ Shared.getScene()->worldstats()->getBarrierByIndex(newBarriedIndex)->flags = barrier->flags | 0x20;
} else if (cmd->param3) {
barrier->flags &= 0xFFFEF1C7;
barrier->flags |= 0x10000;
@@ -456,7 +456,7 @@ int kPlayAnimation(ActionCommand *cmd) {
}
int kMoveScenePosition(ActionCommand *cmd) {
- WorldStats *ws = Shared.getScene()->getResources()->getWorldStats();
+ WorldStats *ws = Shared.getScene()->worldstats();
Common::Rect *sr = &ws->sceneRects[ws->sceneRectIdx];
if (cmd->param3 < 1) {
@@ -517,7 +517,7 @@ int kHideActor(ActionCommand *cmd) {
else
actorIndex = cmd->param1;
- if ((actorIndex >= 0) && (actorIndex < Shared.getScene()->getResources()->getWorldStats()->numActors))
+ if ((actorIndex >= 0) && (actorIndex < Shared.getScene()->worldstats()->numActors))
Shared.getScene()->getActor()->visible(false);
else
debugC(kDebugLevelScripts,
@@ -537,7 +537,7 @@ int kShowActor(ActionCommand *cmd) {
else
actorIndex = cmd->param1;
- if ((actorIndex >= 0) && (actorIndex < Shared.getScene()->getResources()->getWorldStats()->numActors))
+ if ((actorIndex >= 0) && (actorIndex < Shared.getScene()->worldstats()->numActors))
Shared.getScene()->getActor()->visible(true);
else
debugC(kDebugLevelScripts,
@@ -550,7 +550,7 @@ int kShowActor(ActionCommand *cmd) {
}
int kSetActorStats(ActionCommand *cmd) {
- WorldStats *ws = Shared.getScene()->getResources()->getWorldStats();
+ WorldStats *ws = Shared.getScene()->worldstats();
// TODO
// param1 == actorIndex. Implement when we've got more than one actor
@@ -567,7 +567,7 @@ int kSetActorStats(ActionCommand *cmd) {
}
int kSetSceneMotionStat(ActionCommand *cmd) {
- Shared.getScene()->getResources()->getWorldStats()->motionStatus = cmd->param1;
+ Shared.getScene()->worldstats()->motionStatus = cmd->param1;
return 0;
}
@@ -594,14 +594,14 @@ int kEnableActor(ActionCommand *cmd) {
else
actorIndex = cmd->param1;
- if (Shared.getScene()->getResources()->getWorldStats()->actors[actorIndex].field_40 == 5)
+ if (Shared.getScene()->worldstats()->actors[actorIndex].field_40 == 5)
ScriptMan.enableActorSub(actorIndex, 4);
return 0;
}
int kEnableBarriers(ActionCommand *cmd) {
- int barIdx = Shared.getScene()->getResources()->getWorldStats()->getBarrierIndexById(cmd->param1);
+ int barIdx = Shared.getScene()->worldstats()->getBarrierIndexById(cmd->param1);
uint32 sndIdx = cmd->param3;
uint32 v59 = cmd->param2;
@@ -614,7 +614,7 @@ int kEnableBarriers(ActionCommand *cmd) {
if (ScriptMan.getScript()->counter >= 3 * v59 - 1) {
ScriptMan.getScript()->counter = 0;
- Shared.getScene()->getResources()->getWorldStats()->barriers[barIdx].field_67C = 0;
+ Shared.getScene()->worldstats()->barriers[barIdx].field_67C = 0;
ScriptMan.processActionListSub02(ScriptMan.getScript(), cmd, 2);
ScriptMan.currentLoops = 1; // v4 = 1;
} else {
@@ -624,10 +624,10 @@ int kEnableBarriers(ActionCommand *cmd) {
if (sndIdx) {
v64 = 1;
int v170 = 3 - v62 / v59;
- Shared.getScene()->getResources()->getWorldStats()->barriers[barIdx].field_67C = v170;
+ Shared.getScene()->worldstats()->barriers[barIdx].field_67C = v170;
} else {
v64 = 0;
- Shared.getScene()->getResources()->getWorldStats()->barriers[barIdx].field_67C = v62 / v59 + 1;
+ Shared.getScene()->worldstats()->barriers[barIdx].field_67C = v62 / v59 + 1;
}
ScriptMan.processActionListSub02(ScriptMan.getScript(), cmd, v64);
@@ -644,7 +644,7 @@ int kReturn(ActionCommand *cmd) {
}
int kDestroyBarrier(ActionCommand *cmd) {
- Barrier *barrier = Shared.getScene()->getResources()->getWorldStats()->getBarrierById(cmd->param1);
+ Barrier *barrier = Shared.getScene()->worldstats()->getBarrierById(cmd->param1);
if (barrier) {
barrier->flags &= 0xFFFFFFFE;
@@ -674,7 +674,7 @@ int k_unk15(ActionCommand *cmd) {
}
int kResetAnimation(ActionCommand *cmd) {
- Barrier *barrier = Shared.getScene()->getResources()->getWorldStats()->getBarrierById(cmd->param1);
+ Barrier *barrier = Shared.getScene()->worldstats()->getBarrierById(cmd->param1);
if ((barrier->flags & 0x10000) == 0)
barrier->frameIdx = 0;
@@ -685,7 +685,7 @@ int kResetAnimation(ActionCommand *cmd) {
}
int kClearFlag1Bit0(ActionCommand *cmd) {
- Barrier *barrier = Shared.getScene()->getResources()->getWorldStats()->getBarrierById(cmd->param1);
+ Barrier *barrier = Shared.getScene()->worldstats()->getBarrierById(cmd->param1);
barrier->flags &= 0xFFFFFFFE;
@@ -705,12 +705,12 @@ int kJumpIfFlag2Bit0(ActionCommand *cmd) {
// look at the disassembly again
if (targetType <= 0)
- ScriptMan.done = (Shared.getScene()->getResources()->getWorldStats()->getBarrierById(cmd->param1)->flags2 & 1) == 0;
+ ScriptMan.done = (Shared.getScene()->worldstats()->getBarrierById(cmd->param1)->flags2 & 1) == 0;
else
if (targetType == 1) // v4 == 1, so 1
- ScriptMan.done = (Shared.getScene()->getResources()->getWorldStats()->getActionAreaById(cmd->param1)->actionType & 1) == 0;
+ ScriptMan.done = (Shared.getScene()->worldstats()->getActionAreaById(cmd->param1)->actionType & 1) == 0;
else
- ScriptMan.done = (Shared.getScene()->getResources()->getWorldStats()->actors[cmd->param1].flags2 & 1) == 0;
+ ScriptMan.done = (Shared.getScene()->worldstats()->actors[cmd->param1].flags2 & 1) == 0;
return -1;
}
@@ -719,12 +719,12 @@ int kSetFlag2Bit0(ActionCommand *cmd) {
int targetType = cmd->param2;
if (targetType == 2)
- Shared.getScene()->getResources()->getWorldStats()->actors[cmd->param1].flags2 |= 1;
+ Shared.getScene()->worldstats()->actors[cmd->param1].flags2 |= 1;
else
if (targetType == 1)
- Shared.getScene()->getResources()->getWorldStats()->getActionAreaById(cmd->param1)->actionType |= 1;
+ Shared.getScene()->worldstats()->getActionAreaById(cmd->param1)->actionType |= 1;
else
- Shared.getScene()->getResources()->getWorldStats()->getBarrierById(cmd->param1)->flags2 |= 1;
+ Shared.getScene()->worldstats()->getBarrierById(cmd->param1)->flags2 |= 1;
return 0;
}
@@ -879,7 +879,7 @@ int k_unk3C_CMP_VAL(ActionCommand *cmd) {
}
int kWaitUntilFramePlayed(ActionCommand *cmd) {
- Barrier *barrier = Shared.getScene()->getResources()->getWorldStats()->getBarrierById(cmd->param1);
+ Barrier *barrier = Shared.getScene()->worldstats()->getBarrierById(cmd->param1);
if (barrier) {
uint32 frameNum = 0;
@@ -988,10 +988,10 @@ int kChangeActorField40(ActionCommand *cmd) {
int fieldType = cmd->param2;
if (fieldType) {
- if (Shared.getScene()->getResources()->getWorldStats()->actors[actorIdx].field_40 < 11)
- Shared.getScene()->getResources()->getWorldStats()->actors[actorIdx].field_40 = 14;
+ if (Shared.getScene()->worldstats()->actors[actorIdx].field_40 < 11)
+ Shared.getScene()->worldstats()->actors[actorIdx].field_40 = 14;
} else {
- Shared.getScene()->getResources()->getWorldStats()->actors[actorIdx].field_40 = 4;
+ Shared.getScene()->worldstats()->actors[actorIdx].field_40 = 4;
}
return -1;
@@ -1016,7 +1016,7 @@ int kQuit(ActionCommand *cmd) {
}
int kJumpBarrierFrame(ActionCommand *cmd) {
- Barrier *barrier = Shared.getScene()->getResources()->getWorldStats()->getBarrierById(cmd->param1);
+ Barrier *barrier = Shared.getScene()->worldstats()->getBarrierById(cmd->param1);
if (cmd->param2 == -1)
cmd->param2 = barrier->frameCount - 1;
@@ -1095,13 +1095,13 @@ int k_unk56(ActionCommand *cmd) {
int kSetResourcePalette(ActionCommand *cmd) {
if (cmd->param1 > 0)
- Shared.getScreen()->setPalette(Shared.getScene()->getResourcePack(), Shared.getScene()->getResources()->getWorldStats()->grResId[cmd->param1]);
+ Shared.getScreen()->setPalette(Shared.getScene()->getResourcePack(), Shared.getScene()->worldstats()->grResId[cmd->param1]);
return 0;
}
int kSetBarrierFrameIdxFlaged(ActionCommand *cmd) {
- Barrier *barrier = Shared.getScene()->getResources()->getWorldStats()->getBarrierById(cmd->param1);
+ Barrier *barrier = Shared.getScene()->worldstats()->getBarrierById(cmd->param1);
if (cmd->param3)
barrier->flags = 1 | barrier->flags;
@@ -1133,7 +1133,7 @@ int k_unk5E(ActionCommand *cmd) {
}
int kSetBarrierLastFrameIdx(ActionCommand *cmd) {
- Barrier *barrier = Shared.getScene()->getResources()->getWorldStats()->getBarrierById(cmd->param1);
+ Barrier *barrier = Shared.getScene()->worldstats()->getBarrierById(cmd->param1);
if (barrier->frameIdx == barrier->frameCount - 1) {
ScriptMan.lineIncrement = 0;
@@ -1151,7 +1151,7 @@ int k_unk60_SET_OR_CLR_ACTIONAREA_FLAG(ActionCommand *cmd) {
int k_unk61(ActionCommand *cmd) {
if (cmd->param2) {
- if (Shared.getScene()->getResources()->getWorldStats()->field_E860C == -1) {
+ if (Shared.getScene()->worldstats()->field_E860C == -1) {
ScriptMan.lineIncrement = 0;
cmd->param2 = 0;
} else {
diff --git a/engines/asylum/scriptman.h b/engines/asylum/scriptman.h
index 1d73845ee5..22a1f3c6f0 100644
--- a/engines/asylum/scriptman.h
+++ b/engines/asylum/scriptman.h
@@ -28,10 +28,11 @@
#include "common/singleton.h"
#include "asylum/scene.h"
-#include "asylum/sceneres.h"
namespace Asylum {
+class ActionList;
+struct ActionDefinitions;
struct ActionCommand;
class WorldStats;
diff --git a/engines/asylum/shared.h b/engines/asylum/shared.h
index c9db4be79c..f4dbf5f702 100644
--- a/engines/asylum/shared.h
+++ b/engines/asylum/shared.h
@@ -28,10 +28,14 @@
#include "common/singleton.h"
-#include "asylum/sceneres.h"
+#include "asylum/scene.h"
namespace Asylum {
+class Video;
+class Screen;
+class Sound;
+
/**
* Shared Resources are classes that are instantiated at the engine level.
* Binding them to this singleton simplifies implementation of new classes
diff --git a/engines/asylum/worldstats.cpp b/engines/asylum/worldstats.cpp
index bd6f4d5679..c927b76a65 100644
--- a/engines/asylum/worldstats.cpp
+++ b/engines/asylum/worldstats.cpp
@@ -27,9 +27,8 @@
namespace Asylum {
-WorldStats::WorldStats() {
- // TODO Auto-generated constructor stub
-
+WorldStats::WorldStats(Common::SeekableReadStream *stream) {
+ load(stream);
}
WorldStats::~WorldStats() {
@@ -68,4 +67,314 @@ Barrier* WorldStats::getBarrierByIndex(uint32 idx) {
return &barriers[idx];
}
+// FIXME: load necessary World Stats content
+void WorldStats::load(Common::SeekableReadStream *stream) {
+ size = stream->readUint32LE();
+ numEntries = stream->readUint32LE();
+
+ numChapter = stream->readUint32LE();
+ xLeft = stream->readUint32LE();
+ yTop = stream->readUint32LE();
+
+ boundingRect.left = stream->readUint32LE() & 0xFFFF;
+ boundingRect.top = stream->readUint32LE() & 0xFFFF;
+ boundingRect.right = stream->readUint32LE() & 0xFFFF;
+ boundingRect.bottom = stream->readUint32LE() & 0xFFFF;
+
+ // read common graphic resources
+ commonRes.backgroundImage = stream->readUint32LE();
+ commonRes.curScrollUp = stream->readUint32LE();
+ commonRes.curScrollUpLeft = stream->readUint32LE();
+ commonRes.curScrollLeft = stream->readUint32LE();
+ commonRes.curScrollDownLeft = stream->readUint32LE();
+ commonRes.curScrollDown = stream->readUint32LE();
+ commonRes.curScrollDownRight = stream->readUint32LE();
+ commonRes.curScrollRight = stream->readUint32LE();
+ commonRes.curScrollUpRight = stream->readUint32LE();
+ commonRes.curHand = stream->readUint32LE();
+ commonRes.curMagnifyingGlass = stream->readUint32LE();
+ commonRes.curTalkNCP = stream->readUint32LE();
+ commonRes.curGrabPointer = stream->readUint32LE();
+ commonRes.curTalkNCP2 = stream->readUint32LE();
+ commonRes.font1 = stream->readUint32LE();
+ commonRes.font2 = stream->readUint32LE();
+ commonRes.font3 = stream->readUint32LE();
+ commonRes.palette = stream->readUint32LE();
+ commonRes.cellShadeMask1 = stream->readUint32LE();
+ commonRes.cellShadeMask2 = stream->readUint32LE();
+ commonRes.cellShadeMask3 = stream->readUint32LE();
+ commonRes.unused = stream->readUint32LE();
+ commonRes.smallCurUp = stream->readUint32LE();
+ commonRes.smallCurDown = stream->readUint32LE();
+ commonRes.encounterFrameBg = stream->readUint32LE();
+
+ width = stream->readUint32LE();
+ height = stream->readUint32LE();
+ motionStatus = stream->readUint32LE();
+ field_8C = stream->readUint32LE();
+ numActions = stream->readUint32LE();
+ numBarriers = stream->readUint32LE();
+ targetX = stream->readUint32LE();
+ targetY = stream->readUint32LE();
+ field_A0 = stream->readUint32LE();
+ field_A4 = stream->readUint32LE();
+ field_A8 = stream->readUint32LE();
+ field_AC = stream->readUint32LE();
+ field_B0 = stream->readUint32LE();
+ numActors = stream->readUint32LE();
+
+ stereoReversedFlag = stream->readUint32LE();
+
+ for (int r=0; r < 6; r++) {
+ sceneRects[r].left = stream->readUint32LE() & 0xFFFF;
+ sceneRects[r].top = stream->readUint32LE() & 0xFFFF;
+ sceneRects[r].right = stream->readUint32LE() & 0xFFFF;
+ sceneRects[r].bottom = stream->readUint32LE() & 0xFFFF;
+ }
+
+ sceneRectIdx = stream->readByte();
+ field_11D[0] = stream->readByte();
+ field_11D[1] = stream->readByte();
+ field_11D[2] = stream->readByte();
+ field_120 = stream->readUint32LE();
+ actionListIdx = stream->readUint32LE();
+
+ for (int gr = 0; gr < 100; gr++)
+ grResId[gr] = stream->readUint32LE();
+
+ sceneTitleGrResId = stream->readUint32LE();
+ sceneTitlePalResId = stream->readUint32LE();
+ actorType = stream->readUint32LE();
+
+ for(int s = 0; s < 50; s++)
+ soundResId[s] = stream->readUint32LE();
+
+ for(int s=0; s < 15; s++) {
+ ambientSounds[s].field_0 = stream->readUint32LE();
+ ambientSounds[s].flags = stream->readUint32LE();
+ ambientSounds[s].resId = stream->readUint32LE();
+ ambientSounds[s].field_C = stream->readUint32LE();
+ ambientSounds[s].field_10 = stream->readUint32LE();
+ ambientSounds[s].field_14 = stream->readUint32LE();
+
+ for(int i = 0; i < 6; i++)
+ ambientSounds[s].flagNum[i] = stream->readUint32LE();
+
+ ambientSounds[s].x = stream->readUint32LE();
+ ambientSounds[s].y = stream->readUint32LE();
+ }
+
+ numAmbientSound = stream->readUint32LE();
+ musicStatus = stream->readUint32LE();
+ musicCurrentResId = stream->readUint32LE();
+ musicFlag = stream->readUint32LE();
+ musicResId = stream->readUint32LE();
+ musicStatusExt = stream->readUint32LE();
+
+ for (uint32 a = 0; a < numBarriers; a++) {
+ int i;
+ Barrier barrier;
+
+ barrier.id = stream->readUint32LE();
+ barrier.resId = stream->readUint32LE();
+ barrier.x = stream->readUint32LE();
+ barrier.y = stream->readUint32LE();
+
+ barrier.boundingRect.left = stream->readUint32LE() & 0xFFFF;
+ barrier.boundingRect.top = stream->readUint32LE() & 0xFFFF;
+ barrier.boundingRect.right = stream->readUint32LE() & 0xFFFF;
+ barrier.boundingRect.bottom = stream->readUint32LE() & 0xFFFF;
+
+ barrier.field_20 = stream->readUint32LE();
+ barrier.frameIdx = stream->readUint32LE();
+ barrier.frameCount = stream->readUint32LE();
+ barrier.field_2C = stream->readUint32LE();
+ barrier.field_30 = stream->readUint32LE();
+ barrier.field_34 = stream->readUint32LE();
+ barrier.flags = stream->readUint32LE();
+ barrier.field_3C = stream->readUint32LE();
+
+ stream->read(barrier.name, sizeof(barrier.name));
+
+ barrier.field_74 = stream->readUint32LE();
+ barrier.field_78 = stream->readUint32LE();
+ barrier.field_7C = stream->readUint32LE();
+ barrier.field_80 = stream->readUint32LE();
+ barrier.polyIdx = stream->readUint32LE();
+ barrier.flags2 = stream->readUint32LE();
+
+ for (i = 0; i < 10; i++)
+ barrier.gameFlags[i] = stream->readUint32LE();
+
+ barrier.field_B4 = stream->readUint32LE();
+ barrier.tickCount = stream->readUint32LE();
+ barrier.tickCount2 = stream->readUint32LE();
+ barrier.field_C0 = stream->readUint32LE();
+ barrier.priority = stream->readUint32LE();
+ barrier.actionListIdx = stream->readUint32LE();
+
+ for (i = 0; i < 16; i++) {
+ barrier.soundItems[i].resId = stream->readUint32LE();
+ barrier.soundItems[i].field_4 = stream->readUint32LE();
+ barrier.soundItems[i].field_8 = stream->readUint32LE();
+ barrier.soundItems[i].field_C = stream->readUint32LE();
+
+ }
+
+ for (i = 0; i < 50; i++) {
+ barrier.frameSoundItems[i].resId = stream->readUint32LE();
+ barrier.frameSoundItems[i].frameIdx = stream->readUint32LE();
+ barrier.frameSoundItems[i].index = stream->readUint32LE();
+ barrier.frameSoundItems[i].field_C = stream->readUint32LE();
+ barrier.frameSoundItems[i].field_10 = stream->readUint32LE();
+ barrier.frameSoundItems[i].field_14 = stream->readUint32LE();
+ }
+
+ barrier.field_67C = stream->readUint32LE();
+ barrier.soundX = stream->readUint32LE();
+ barrier.soundY = stream->readUint32LE();
+ barrier.field_688 = stream->readUint32LE();
+
+ for (i = 0; i < 5; i++)
+ barrier.field_68C[i] = stream->readUint32LE();
+
+ barrier.soundResId = stream->readUint32LE();
+ barrier.field_6A4 = stream->readUint32LE();
+
+ barriers.push_back(barrier);
+ }
+
+ // need to jump all unused barriers data to where actors data start
+ stream->seek(0xA6D7A);
+
+ for (uint32 a = 0; a < numActors; a++) {
+ int i;
+ Actor actor;
+
+ actor.x = stream->readUint32LE();
+ actor.y = stream->readUint32LE();
+ actor.grResId = stream->readUint32LE();
+ actor.field_C = stream->readUint32LE();
+ actor.frameNum = stream->readUint32LE();
+ actor.frameCount = stream->readUint32LE();
+ actor.x1 = stream->readUint32LE();
+ actor.y1 = stream->readUint32LE();
+ actor.x2 = stream->readUint32LE();
+ actor.y2 = stream->readUint32LE();
+
+ actor.boundingRect.left = stream->readUint32LE() & 0xFFFF;
+ actor.boundingRect.top = stream->readUint32LE() & 0xFFFF;
+ actor.boundingRect.right = stream->readUint32LE() & 0xFFFF;
+ actor.boundingRect.bottom = stream->readUint32LE() & 0xFFFF;
+
+ actor.direction = stream->readUint32LE();
+ actor.field_3C = stream->readUint32LE();
+ actor.field_40 = stream->readUint32LE();
+ actor.field_44 = stream->readUint32LE();
+ actor.field_48 = stream->readUint32LE();
+ actor.flags = stream->readUint32LE();
+ actor.field_50 = stream->readUint32LE();
+ actor.field_54 = stream->readUint32LE();
+ actor.field_58 = stream->readUint32LE();
+ actor.field_5C = stream->readUint32LE();
+ actor.field_60 = stream->readUint32LE();
+ actor.actionIdx3 = stream->readUint32LE();
+
+ // TODO skip field_68 till field_617
+ stream->skip(0x5B0);
+
+ for (i = 0; i < 8; i++)
+ actor.reaction[i] = stream->readUint32LE();
+
+ actor.field_638 = stream->readUint32LE();
+ actor.walkingSound1 = stream->readUint32LE();
+ actor.walkingSound2 = stream->readUint32LE();
+ actor.walkingSound3 = stream->readUint32LE();
+ actor.walkingSound4 = stream->readUint32LE();
+ actor.field_64C = stream->readUint32LE();
+ actor.field_650 = stream->readUint32LE();
+
+ for (i = 0; i < 55; i++)
+ actor.grResTable[i] = stream->readUint32LE();
+
+ stream->read(actor.name, sizeof(actor.name));
+
+ for (i = 0; i < 20; i++)
+ actor.field_830[i] = stream->readUint32LE();
+
+ for (i = 0; i < 20; i++)
+ actor.field_880[i] = stream->readUint32LE();
+
+ for (i = 0; i < 20; i++)
+ actor.field_8D0[i] = stream->readUint32LE();
+
+ actor.actionIdx2 = stream->readUint32LE();
+ actor.field_924 = stream->readUint32LE();
+ actor.tickValue1 = stream->readUint32LE();
+ actor.field_92C = stream->readUint32LE();
+ actor.flags2 = stream->readUint32LE();
+ actor.field_934 = stream->readUint32LE();
+ actor.field_938 = stream->readUint32LE();
+ actor.soundResId = stream->readUint32LE();
+
+ // TODO skip field_940 till field_978
+ stream->skip(0x3C);
+
+ actor.actionIdx1 = stream->readUint32LE();
+
+ // TODO skip field_980 till field_9A0
+ stream->skip(0x24);
+
+ actors.push_back(actor);
+ }
+
+ // TODO Take this out, it shouldn't be here (TEST ONLY)
+ stream->seek(0xA73B6);
+
+ uint8 mainActorData[500];
+ stream->read(mainActorData, 500);
+
+ // FIXME
+ // This is ONLY ever going to work for scenes where there's only
+ // one actor in the worldStats->actors[] collection
+ actors[0].setRawResources(mainActorData);
+
+ stream->seek(0xD6B5A); // where action items start
+
+ // FIXME Figure out all the actions items
+ for (uint32 a = 0; a < numActions; a++) {
+ ActionArea action;
+ memset(&action, 0, sizeof(ActionArea));
+
+ stream->read(action.name,52);
+ action.id = stream->readUint32LE();
+ action.field01 = stream->readUint32LE();
+ action.field02 = stream->readUint32LE();
+ action.field_40 = stream->readUint32LE();
+ action.field_44 = stream->readUint32LE();
+ action.flags = stream->readUint32LE();
+ action.actionListIdx1 = stream->readUint32LE();
+ action.actionListIdx2 = stream->readUint32LE();
+ action.actionType = stream->readUint32LE();
+
+ for (int aa1 = 0; aa1 < 10; aa1++)
+ action.flagNums[aa1] = stream->readUint32LE();
+
+ action.field_7C = stream->readUint32LE();
+ action.polyIdx = stream->readUint32LE();
+ action.field_84 = stream->readUint32LE();
+ action.field_88 = stream->readUint32LE();
+ action.soundResId = stream->readUint32LE();
+ action.field_90 = stream->readUint32LE();
+ action.paletteValue = stream->readUint32LE();
+
+ for (int aa2 = 0; aa2 < 5; aa2++)
+ action.array[aa2] = stream->readUint32LE();
+
+ action.volume = stream->readUint32LE();
+
+ actions.push_back(action);
+ }
+}
+
} // end of namespace Asylum
diff --git a/engines/asylum/worldstats.h b/engines/asylum/worldstats.h
index 40285cb7b1..7e83a33b5e 100644
--- a/engines/asylum/worldstats.h
+++ b/engines/asylum/worldstats.h
@@ -90,7 +90,7 @@ typedef struct ActionArea {
class WorldStats {
public:
- WorldStats();
+ WorldStats(Common::SeekableReadStream *stream);
virtual ~WorldStats();
uint32 size;
@@ -151,6 +151,10 @@ public:
Barrier* getBarrierById(uint32 id);
Barrier* getBarrierByIndex(uint32 idx);
+private:
+
+ void load(Common::SeekableReadStream *stream);
+
};
} // end of namespace Asylum
Commit: b4385f8e9ed82c5f43ab0483dea0833e925846e8
https://github.com/scummvm/scummvm/commit/b4385f8e9ed82c5f43ab0483dea0833e925846e8
Author: Alex Bevilacqua (alexbevi at gmail.com)
Date: 2021-05-17T15:35:48+02:00
Commit Message:
ASYLUM: Removed the ScriptManager. The singleton functionality is rolled into the actionlist class (where it belongs)
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@348 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
R engines/asylum/scriptman.cpp
R engines/asylum/scriptman.h
engines/asylum/actionlist.cpp
engines/asylum/actionlist.h
engines/asylum/actor.cpp
engines/asylum/asylum.cpp
engines/asylum/asylum.h
engines/asylum/asylum.vcproj
engines/asylum/console.cpp
engines/asylum/module.mk
engines/asylum/scene.cpp
engines/asylum/scene.h
diff --git a/engines/asylum/actionlist.cpp b/engines/asylum/actionlist.cpp
index ef479b0b95..78fe3ef30d 100644
--- a/engines/asylum/actionlist.cpp
+++ b/engines/asylum/actionlist.cpp
@@ -24,17 +24,315 @@
*/
#include "asylum/actionlist.h"
+#include "asylum/shared.h"
namespace Asylum {
-ActionList::ActionList(Common::SeekableReadStream *stream) {
+ActionList::ActionList(Common::SeekableReadStream *stream, Scene *scene)
+ : _scene(scene) {
load(stream);
+
+ currentLine = 0;
+ currentLoops = 0;
+ processing = false;
+ delayedSceneIndex = -1;
+ delayedVideoIndex = -1;
+ allowInput = true;
}
ActionList::~ActionList() {
entries.clear();
}
+typedef int AsylumFunc(ActionCommand *cmd, Scene *scn);
+
+struct AsylumFunction {
+ const char *name;
+ AsylumFunc *function;
+};
+
+#define MAPFUNC(name, func) {name, func}
+
+AsylumFunction function_map[] = {
+ /*0x00*/ MAPFUNC("kReturn0", kReturn0),
+ /*0x01*/ MAPFUNC("kSetGameFlag", kSetGameFlag),
+ /*0x02*/ MAPFUNC("kClearGameFlag", kClearGameFlag),
+ /*0x03*/ MAPFUNC("kToggleGameFlag", kToggleGameFlag),
+ /*0x04*/ MAPFUNC("kJumpIfGameFlag", kJumpIfGameFlag),
+ /*0x05*/ MAPFUNC("kHideCursor", kHideCursor),
+ /*0x06*/ MAPFUNC("kShowCursor", kShowCursor),
+ /*0x07*/ MAPFUNC("kPlayAnimation", kPlayAnimation),
+ /*0x08*/ MAPFUNC("kMoveScenePosition", kMoveScenePosition),
+ /*0x09*/ MAPFUNC("kHideActor", kHideActor),
+ /*0x0A*/ MAPFUNC("kShowActor", kShowActor),
+ /*0x0B*/ MAPFUNC("kSetActorStats", kSetActorStats),
+ /*0x0C*/ MAPFUNC("kSetSceneMotionStat", kSetSceneMotionStat),
+ /*0x0D*/ MAPFUNC("kDisableActor", kDisableActor),
+ /*0x0E*/ MAPFUNC("kEnableActor", kEnableActor),
+ /*0x0F*/ MAPFUNC("kEnableBarriers", kEnableBarriers),
+ /*0x10*/ MAPFUNC("kReturn", kReturn),
+ /*0x11*/ MAPFUNC("kDestroyBarrier", kDestroyBarrier),
+ /*0x12*/ MAPFUNC("k_unk12_JMP_WALK_ACTOR", k_unk12_JMP_WALK_ACTOR),
+ /*0x13*/ MAPFUNC("k_unk13_JMP_WALK_ACTOR", k_unk13_JMP_WALK_ACTOR),
+ /*0x14*/ MAPFUNC("k_unk14_JMP_WALK_ACTOR", k_unk14_JMP_WALK_ACTOR),
+ /*0x15*/ MAPFUNC("k_unk15", k_unk15),
+ /*0x16*/ MAPFUNC("kResetAnimation", kResetAnimation),
+ /*0x17*/ MAPFUNC("kClearFlag1Bit0", kClearFlag1Bit0),
+ /*0x18*/ MAPFUNC("k_unk18_PLAY_SND", k_unk18_PLAY_SND),
+ /*0x19*/ MAPFUNC("kJumpIfFlag2Bit0", kJumpIfFlag2Bit0),
+ /*0x1A*/ MAPFUNC("kSetFlag2Bit0", kSetFlag2Bit0),
+ /*0x1B*/ MAPFUNC("kClearFlag2Bit0", kClearFlag2Bit0),
+ /*0x1C*/ MAPFUNC("kJumpIfFlag2Bit2", kJumpIfFlag2Bit2),
+ /*0x1D*/ MAPFUNC("kSetFlag2Bit2", kSetFlag2Bit2),
+ /*0x1E*/ MAPFUNC("kClearFlag2Bit2", kClearFlag2Bit2),
+ /*0x1F*/ MAPFUNC("kJumpIfFlag2Bit1", kJumpIfFlag2Bit1),
+ /*0x20*/ MAPFUNC("kSetFlag2Bit1", kSetFlag2Bit1),
+ /*0x21*/ MAPFUNC("kClearFlag2Bit1", kClearFlag2Bit1),
+ /*0x22*/ MAPFUNC("k_unk22", k_unk22),
+ /*0x23*/ MAPFUNC("k_unk23", k_unk23),
+ /*0x24*/ MAPFUNC("k_unk24", k_unk24),
+ /*0x25*/ MAPFUNC("kRunEncounter", kRunEncounter),
+ /*0x26*/ MAPFUNC("kJumpIfFlag2Bit4", kJumpIfFlag2Bit4),
+ /*0x27*/ MAPFUNC("kSetFlag2Bit4", kSetFlag2Bit4),
+ /*0x28*/ MAPFUNC("kClearFlag2Bit4", kClearFlag2Bit4),
+ /*0x29*/ MAPFUNC("kSetActorField638", kSetActorField638),
+ /*0x2A*/ MAPFUNC("kJumpIfActorField638", kJumpIfActorField638),
+ /*0x2B*/ MAPFUNC("kChangeScene", kChangeScene),
+ /*0x2C*/ MAPFUNC("k_unk2C_ActorSub", k_unk2C_ActorSub),
+ /*0x2D*/ MAPFUNC("kPlayMovie", kPlayMovie),
+ /*0x2E*/ MAPFUNC("kStopAllBarriersSounds", kStopAllBarriersSounds),
+ /*0x2F*/ MAPFUNC("kSetActionFlag01", kSetActionFlag01),
+ /*0x30*/ MAPFUNC("kClearActionFlag01", kClearActionFlag01),
+ /*0x31*/ MAPFUNC("kResetSceneRect", kResetSceneRect),
+ /*0x32*/ MAPFUNC("kChangeMusicById", kChangeMusicById),
+ /*0x33*/ MAPFUNC("kStopMusic", kStopMusic),
+ /*0x34*/ MAPFUNC("k_unk34_Status", k_unk34_Status),
+ /*0x35*/ MAPFUNC("k_unk35", k_unk35),
+ /*0x36*/ MAPFUNC("k_unk36", k_unk36),
+ /*0x37*/ MAPFUNC("kRunBlowUpPuzzle", kRunBlowUpPuzzle),
+ /*0x38*/ MAPFUNC("kJumpIfFlag2Bit3", kJumpIfFlag2Bit3),
+ /*0x39*/ MAPFUNC("kSetFlag2Bit3", kSetFlag2Bit3),
+ /*0x3A*/ MAPFUNC("kClearFlag2Bit3", kClearFlag2Bit3),
+ /*0x3B*/ MAPFUNC("k_unk3B_PALETTE_MOD", k_unk3B_PALETTE_MOD),
+ /*0x3C*/ MAPFUNC("k_unk3C_CMP_VAL", k_unk3C_CMP_VAL),
+ /*0x3D*/ MAPFUNC("kWaitUntilFramePlayed", kWaitUntilFramePlayed),
+ /*0x3E*/ MAPFUNC("kUpdateWideScreen", kUpdateWideScreen),
+ /*0x3F*/ MAPFUNC("k_unk3F", k_unk3F),
+ /*0x40*/ MAPFUNC("k_unk40_SOUND", k_unk40_SOUND),
+ /*0x41*/ MAPFUNC("kPlaySpeech", kPlaySpeech),
+ /*0x42*/ MAPFUNC("k_unk42", k_unk42),
+ /*0x43*/ MAPFUNC("k_unk43", k_unk43),
+ /*0x44*/ MAPFUNC("kPaletteFade", kPaletteFade),
+ /*0x45*/ MAPFUNC("kStartPaletteFadeThread", kStartPaletteFadeThread),
+ /*0x46*/ MAPFUNC("k_unk46", k_unk46),
+ /*0x47*/ MAPFUNC("kActorFaceObject", kActorFaceObject),
+ /*0x48*/ MAPFUNC("k_unk48_MATTE_01", k_unk48_MATTE_01),
+ /*0x49*/ MAPFUNC("k_unk49_MATTE_90", k_unk49_MATTE_90),
+ /*0x4A*/ MAPFUNC("kJumpIfSoundPlaying", kJumpIfSoundPlaying),
+ /*0x4B*/ MAPFUNC("kChangePlayerCharacterIndex", kChangePlayerCharacterIndex),
+ /*0x4C*/ MAPFUNC("kChangeActorField40", kChangeActorField40),
+ /*0x4D*/ MAPFUNC("kStopSound", kStopSound),
+ /*0x4E*/ MAPFUNC("k_unk4E_RANDOM_COMMAND", k_unk4E_RANDOM_COMMAND),
+ /*0x4F*/ MAPFUNC("kClearScreen", kClearScreen),
+ /*0x50*/ MAPFUNC("kQuit", kQuit),
+ /*0x51*/ MAPFUNC("kJumpBarrierFrame", kJumpBarrierFrame),
+ /*0x52*/ MAPFUNC("k_unk52", k_unk52),
+ /*0x53*/ MAPFUNC("k_unk53", k_unk53),
+ /*0x54*/ MAPFUNC("k_unk54_SET_ACTIONLIST_6EC", k_unk54_SET_ACTIONLIST_6EC),
+ /*0x55*/ MAPFUNC("k_unk55", k_unk55),
+ /*0x56*/ MAPFUNC("k_unk56", k_unk56),
+ /*0x57*/ MAPFUNC("kSetResourcePalette", kSetResourcePalette),
+ /*0x58*/ MAPFUNC("kSetBarrierFrameIdxFlaged", kSetBarrierFrameIdxFlaged),
+ /*0x59*/ MAPFUNC("k_unk59", k_unk59),
+ /*0x5A*/ MAPFUNC("k_unk5A", k_unk5A),
+ /*0x5B*/ MAPFUNC("k_unk5B", k_unk5B),
+ /*0x5C*/ MAPFUNC("k_unk5C", k_unk5C),
+ /*0x5D*/ MAPFUNC("k_unk5D", k_unk5D),
+ /*0x5E*/ MAPFUNC("k_unk5E", k_unk5E),
+ /*0x5F*/ MAPFUNC("kSetBarrierLastFrameIdx", kSetBarrierLastFrameIdx),
+ /*0x60*/ MAPFUNC("k_unk60_SET_OR_CLR_ACTIONAREA_FLAG", k_unk60_SET_OR_CLR_ACTIONAREA_FLAG),
+ /*0x61*/ MAPFUNC("k_unk61", k_unk61),
+ /*0x62*/ MAPFUNC("k_unk62_SHOW_OPTIONS_SCREEN", k_unk62_SHOW_OPTIONS_SCREEN),
+ /*0x63*/ MAPFUNC("k_unk63", k_unk63)
+};
+
+void ActionList::setScriptByIndex(uint32 index) {
+ currentLine = 0;
+ _currentScript = &entries[index]; // TODO assert if out of bounds
+
+ if (kDebugLevelScripts) {
+ for (uint8 i = 0; i < _currentScript->commands[0].numLines; i++) {
+ debugC(kDebugLevelScripts,
+ "Line: %02d/%02d :: 0x%02X (%d, %d, %d, %d, %d, %d, %d, %d, %d)",
+ i,
+ _currentScript->commands[0].numLines - 1,
+ _currentScript->commands[i].opcode,
+ _currentScript->commands[i].param1,
+ _currentScript->commands[i].param2,
+ _currentScript->commands[i].param3,
+ _currentScript->commands[i].param4,
+ _currentScript->commands[i].param5,
+ _currentScript->commands[i].param6,
+ _currentScript->commands[i].param7,
+ _currentScript->commands[i].param8,
+ _currentScript->commands[i].param9);
+ }
+ }
+}
+
+int ActionList::checkBarrierFlags(int barrierId) {
+ int flags = _scene->worldstats()->getBarrierById(barrierId)->flags;
+ return flags & 1 && (flags & 8 || flags & 0x10000);
+}
+
+int ActionList::setBarrierNextFrame(int barrierId, int barrierFlags) {
+ int barrierIndex = _scene->worldstats()->getBarrierIndexById(barrierId);
+
+ Barrier *barrier = _scene->worldstats()->getBarrierByIndex(barrierIndex);
+ int newFlag = barrierFlags | 1 | barrier->flags;
+ barrier->flags |= barrierFlags | 1;
+
+ if (newFlag & 0x10000) {
+ barrier->frameIdx = barrier->frameCount - 1;
+ } else {
+ barrier->frameIdx = 0;
+ }
+
+ return barrierIndex;
+}
+
+void ActionList::processActionListSub02(ActionDefinitions* script, ActionCommand *command, int a4) {
+ int v4 = 0;
+ int result;
+ int barrierIdx = 0;
+ if (a4) {
+ if (a4 == 1) {
+ ;
+ } else {
+ result = a4 - 2;
+ int v8 = command->param4;
+
+ for (int i = 7; i > 0; i--) {
+ barrierIdx = _scene->worldstats()->getBarrierIndexById(v8);
+ if (barrierIdx >= 0)
+ _scene->worldstats()->barriers[barrierIdx].field_67C = 0;
+ v8 += 4;
+ }
+ }
+ // TODO
+ switch (_scene->getSceneIndex()) {
+ case 7:
+ warning("Scene 7 / v4 != 0 Not Implemented");
+ break;
+ case 6:
+ warning("Scene 6 / v4 != 0 Not Implemented");
+ break;
+ case 8:
+ warning("Scene 8 / v4 != 0 Not Implemented");
+ break;
+ case 3:
+ warning("Scene 3 / v4 != 0 Not Implemented");
+ break;
+ case 4:
+ warning("Scene 4 / v4 != 0 Not Implemented");
+ break;
+ default:
+ return;
+ }
+ } else {
+ int v13 = command->param4;
+ int v4 = script->counter / command->param2 + 4;
+ for (int i = 7; i > 0; i--) {
+ barrierIdx = _scene->worldstats()->getBarrierIndexById(v13);
+ if (barrierIdx >= 0)
+ _scene->worldstats()->barriers[barrierIdx].field_67C = v4;
+ v13 += 4;
+ }
+ // TODO
+ switch (_scene->getSceneIndex()) {
+ case 7:
+ warning("Scene 7 / v4 = 0 Not Implemented");
+ break;
+ case 6:
+ warning("Scene 6 / v4 = 0 Not Implemented");
+ break;
+ case 8:
+ warning("Scene 8 / v4 = 0 Not Implemented");
+ break;
+ case 3:
+ warning("Scene 3 / v4 = 0 Not Implemented");
+ break;
+ case 4:
+ warning("Scene 4 / v4 = 0 Not Implemented");
+ break;
+ default:
+ return;
+ }
+ }
+}
+
+void ActionList::enableActorSub(int actorIndex, int condition) {
+
+}
+
+
+int ActionList::process() {
+ done = false;
+ waitCycle = false;
+ lineIncrement = 1;
+ processing = true;
+
+ if (_currentScript) {
+ while (!done && !waitCycle) {
+ lineIncrement = 1; //Reset line increment value
+
+ if (currentLoops > 1000) {
+ //TODO - processActionLists has run too many iterations
+ }
+
+ ActionCommand *currentCommand = &_currentScript->commands[currentLine];
+
+ uint32 opcode = currentCommand->opcode;
+
+ // Execute command from function mapping
+ int cmdRet = function_map[opcode].function(currentCommand, _scene);
+
+ // Check function return
+ if (cmdRet == -1)
+ warning("Incomplete opcode %s (0x%02X) in Scene %d Line %d",
+ function_map[opcode].name,
+ currentCommand->opcode,
+ _scene->getSceneIndex(),
+ currentLine);
+ if (cmdRet == -2)
+ warning("Unhandled opcode %s (0x%02X) in Scene %d Line %d",
+ function_map[opcode].name,
+ currentCommand->opcode,
+ _scene->getSceneIndex(),
+ currentLine);
+
+ currentLine += lineIncrement;
+ currentLoops++;
+
+ } // end while
+
+ if (done) {
+ currentLine = 0;
+ currentLoops = 0;
+ _currentScript = 0;
+
+ // XXX
+ // gameFlag 183 is the same as the
+ // processing flag, but is not being used
+ Shared.clearGameFlag(183);
+ }
+ }
+
+ processing = false;
+
+ return 0;
+}
+
void ActionList::load(Common::SeekableReadStream *stream) {
size = stream->readUint32LE();
numEntries = stream->readUint32LE();
@@ -70,4 +368,835 @@ void ActionList::load(Common::SeekableReadStream *stream) {
}
}
+/* Opcode Functions */
+
+int kReturn0(ActionCommand *cmd, Scene *scn) {
+ scn->actions()->done = true;
+ scn->actions()->lineIncrement = 0;
+ return 0;
+}
+
+int kSetGameFlag(ActionCommand *cmd, Scene *scn) {
+ int flagNum = cmd->param1;
+
+ if (flagNum >= 0)
+ Shared.setGameFlag(flagNum);
+
+ return 0;
+}
+
+int kClearGameFlag(ActionCommand *cmd, Scene *scn) {
+ int flagNum = cmd->param1;
+
+ if (flagNum >= 0)
+ Shared.clearGameFlag(flagNum);
+
+ return 0;
+}
+
+int kToggleGameFlag(ActionCommand *cmd, Scene *scn) {
+ int flagNum = cmd->param1;
+
+ if (flagNum >= 0)
+ Shared.toggleGameFlag(flagNum);
+
+ return 0;
+}
+
+int kJumpIfGameFlag(ActionCommand *cmd, Scene *scn) {
+ int flagNum = cmd->param1;
+
+ if (flagNum) {
+ bool doJump = Shared.isGameFlagSet(flagNum);
+ if (cmd->param2)
+ doJump = Shared.isGameFlagNotSet(flagNum);
+ if (doJump)
+ scn->actions()->currentLine = cmd->param3;
+ }
+
+ return 0;
+}
+
+int kHideCursor(ActionCommand *cmd, Scene *scn) {
+ scn->getCursor()->hide();
+ scn->actions()->allowInput = false;
+
+ return 0;
+}
+
+int kShowCursor(ActionCommand *cmd, Scene *scn) {
+ scn->getCursor()->show();
+ scn->actions()->allowInput = true;
+
+ // TODO clear_flag_01()
+ return -1;
+}
+
+int kPlayAnimation(ActionCommand *cmd, Scene *scn) {
+ int barrierId = cmd->param1;
+
+ if (cmd->param2 == 2) {
+ if (!scn->actions()->checkBarrierFlags(barrierId)) {
+ cmd->param2 = 1;
+ // FIXME Not sure why this break was here
+ // break;
+ }
+ scn->actions()->lineIncrement = 1;
+ } else {
+ int barrierIndex = scn->worldstats()->getBarrierIndexById(barrierId);
+ Barrier *barrier = scn->worldstats()->getBarrierByIndex(barrierIndex);
+
+ if (cmd->param4) { // RECHECK THIS
+ int newBarriedIndex = 213 * barrierIndex;
+ barrier->flags &= 0xFFFEF1C7;
+ scn->worldstats()->getBarrierByIndex(newBarriedIndex)->flags = barrier->flags | 0x20;
+ } else if (cmd->param3) {
+ barrier->flags &= 0xFFFEF1C7;
+ barrier->flags |= 0x10000;
+ } else {
+ barrier->flags &= 0x10000;
+ if(barrier->flags == 0) {
+ barrier->flags &= 0x10E38;
+ if(barrier->flags == 0) {
+ barrier->flags |= 8;
+ }
+ } else {
+ barrier->flags |= 8;
+ barrier->flags &= 0xFFFEFFFF;
+ }
+ }
+
+ scn->actions()->setBarrierNextFrame(barrierId, barrier->flags);
+
+ if(barrier->field_688 == 1) {
+ // TODO: get barrier position
+ }
+
+ if(cmd->param2) {
+ cmd->param2 = 2;
+ scn->actions()->lineIncrement = 1;
+ }
+ }
+
+ return -1;
+}
+
+int kMoveScenePosition(ActionCommand *cmd, Scene *scn) {
+ WorldStats *ws = scn->worldstats();
+ Common::Rect *sr = &ws->sceneRects[ws->sceneRectIdx];
+
+ if (cmd->param3 < 1) {
+ ws->xLeft = cmd->param1;
+ ws->yTop = cmd->param2;
+ ws->motionStatus = 3;
+ } else if (!cmd->param4) {
+ ws->motionStatus = 5;
+ ws->targetX = cmd->param1;
+ ws->targetY = cmd->param2;
+ ws->field_A0 = cmd->param3;
+
+ if (ws->targetX < (uint32)sr->left)
+ ws->targetX = sr->left;
+ if (ws->targetY < (uint32)sr->top)
+ ws->targetY = sr->top;
+ if (ws->targetX + 640 > (uint32)sr->right)
+ ws->targetX = sr->right - 640;
+ if (ws->targetY + 480 > (uint32)sr->bottom)
+ ws->targetY = sr->bottom - 480;
+
+ // TODO: reverse asm block
+
+ } else if (cmd->param5) {
+ if (ws->motionStatus == 2)
+ scn->actions()->lineIncrement = 1;
+ else
+ cmd->param5 = 0;
+ } else {
+ cmd->param5 = 1;
+ ws->motionStatus = 2;
+ ws->targetX = cmd->param1;
+ ws->targetY = cmd->param2;
+ ws->field_A0 = cmd->param3;
+
+ if (ws->targetX + 640 > ws->width)
+ ws->targetX = ws->width - 640;
+ if (ws->targetX < (uint32)sr->left)
+ ws->targetX = sr->left;
+ if (ws->targetY < (uint32)sr->top)
+ ws->targetY = sr->top;
+ if (ws->targetX + 640 > (uint32)sr->right)
+ ws->targetX = sr->right - 640;
+ if (ws->targetY + 480 > (uint32)sr->bottom)
+ ws->targetY = sr->bottom - 480;
+
+ // TODO: reverse asm block
+ }
+
+ return -1;
+}
+
+int kHideActor(ActionCommand *cmd, Scene *scn) {
+ uint32 actorIndex = 0;
+
+ if (cmd->param1 == -1)
+ ;//actorIndex = scn->getWorldStats()->playerActor;
+ else
+ actorIndex = cmd->param1;
+
+ if ((actorIndex >= 0) && (actorIndex < scn->worldstats()->numActors))
+ scn->getActor()->visible(false);
+ else
+ debugC(kDebugLevelScripts,
+ "Requested invalid actor ID:0x%02X in Scene %d Line %d.",
+ cmd->param1,
+ scn->getSceneIndex(),
+ scn->actions()->currentLine);
+
+ return 0;
+}
+
+int kShowActor(ActionCommand *cmd, Scene *scn) {
+ uint32 actorIndex = 0;
+
+ if (cmd->param1 == -1)
+ ;//actorIndex = scn->getWorldStats()->playerActor;
+ else
+ actorIndex = cmd->param1;
+
+ if ((actorIndex >= 0) && (actorIndex < scn->worldstats()->numActors))
+ scn->getActor()->visible(true);
+ else
+ debugC(kDebugLevelScripts,
+ "Requested invalid actor ID:0x%02X in Scene %d Line %d.",
+ cmd->param1,
+ scn->getSceneIndex(),
+ scn->actions()->currentLine);
+
+ return 0;
+}
+
+int kSetActorStats(ActionCommand *cmd, Scene *scn) {
+ WorldStats *ws = scn->worldstats();
+
+ // TODO
+ // param1 == actorIndex. Implement when we've got more than one actor
+
+ // TODO This needs to be depreciated, but it's setting the actor's x/y
+ // and bounding rect top/left.
+ // This needs to be rolled into the proper place
+ scn->getActor()->setPosition(cmd->param2, cmd->param3);
+
+ scn->getActor()->setPosition_40A260(cmd->param2, cmd->param3, cmd->param4, cmd->param5);
+
+ // XXX Returning -1 since the setPosition logic isn't fully implemented
+ return -1;
+}
+
+int kSetSceneMotionStat(ActionCommand *cmd, Scene *scn) {
+ scn->worldstats()->motionStatus = cmd->param1;
+
+ return 0;
+}
+
+int kDisableActor(ActionCommand *cmd, Scene *scn) {
+ int actorIndex = 0;
+
+ if (cmd->param1 == -1)
+ ;//actorIndex = scn->getWorldStats()->playerActor;
+ else
+ actorIndex = cmd->param1;
+
+ // TODO Finish implementing this function
+ scn->getActor()->update_4072A0(actorIndex);
+
+ return -1;
+}
+
+int kEnableActor(ActionCommand *cmd, Scene *scn) {
+ int actorIndex = 0;
+
+ if (cmd->param1 == -1)
+ ;//actorIndex = scn->getWorldStats()->playerActor;
+ else
+ actorIndex = cmd->param1;
+
+ if (scn->worldstats()->actors[actorIndex].field_40 == 5)
+ scn->actions()->enableActorSub(actorIndex, 4);
+
+ return 0;
+}
+
+int kEnableBarriers(ActionCommand *cmd, Scene *scn) {
+ int barIdx = scn->worldstats()->getBarrierIndexById(cmd->param1);
+ uint32 sndIdx = cmd->param3;
+ uint32 v59 = cmd->param2;
+
+ if (!scn->actions()->getScript()->counter && scn->getSceneIndex() != 13 && sndIdx != 0) {
+ ResourcePack *sfx = new ResourcePack(18);
+ Shared.getSound()->playSfx(sfx, ((unsigned int)(sndIdx != 0) & 5) + 0x80120001);
+ delete sfx;
+ //Shared.getSound()->playSfx(scn->getSpeechPack(),sndIdx + 86);
+ }
+
+ if (scn->actions()->getScript()->counter >= 3 * v59 - 1) {
+ scn->actions()->getScript()->counter = 0;
+ scn->worldstats()->barriers[barIdx].field_67C = 0;
+ scn->actions()->processActionListSub02(scn->actions()->getScript(), cmd, 2);
+ scn->actions()->currentLoops = 1; // v4 = 1;
+ } else {
+ int v64;
+ int v62 = scn->actions()->getScript()->counter + 1;
+ scn->actions()->getScript()->counter = v62;
+ if (sndIdx) {
+ v64 = 1;
+ int v170 = 3 - v62 / v59;
+ scn->worldstats()->barriers[barIdx].field_67C = v170;
+ } else {
+ v64 = 0;
+ scn->worldstats()->barriers[barIdx].field_67C = v62 / v59 + 1;
+ }
+
+ scn->actions()->processActionListSub02(scn->actions()->getScript(), cmd, v64);
+ }
+
+ return -1;
+}
+
+int kReturn(ActionCommand *cmd, Scene *scn) {
+ scn->actions()->done = true;
+ scn->actions()->lineIncrement = 0;
+
+ return 0;
+}
+
+int kDestroyBarrier(ActionCommand *cmd, Scene *scn) {
+ Barrier *barrier = scn->worldstats()->getBarrierById(cmd->param1);
+
+ if (barrier) {
+ barrier->flags &= 0xFFFFFFFE;
+ barrier->flags |= 0x20000;
+ Shared.getScreen()->deleteGraphicFromQueue(barrier->resId);
+ } else
+ debugC(kDebugLevelScripts,
+ "Requested invalid object ID:0x%02X in Scene %d Line %d.",
+ cmd->param1,
+ scn->getSceneIndex(),
+ scn->actions()->currentLine);
+
+ return 0;
+}
+
+int k_unk12_JMP_WALK_ACTOR(ActionCommand *cmd, Scene *scn) {
+ return -2;
+}
+int k_unk13_JMP_WALK_ACTOR(ActionCommand *cmd, Scene *scn) {
+ return -2;
+}
+int k_unk14_JMP_WALK_ACTOR(ActionCommand *cmd, Scene *scn) {
+ return -2;
+}
+int k_unk15(ActionCommand *cmd, Scene *scn) {
+ return -2;
+}
+
+int kResetAnimation(ActionCommand *cmd, Scene *scn) {
+ Barrier *barrier = scn->worldstats()->getBarrierById(cmd->param1);
+
+ if ((barrier->flags & 0x10000) == 0)
+ barrier->frameIdx = 0;
+ else
+ barrier->frameIdx = barrier->frameCount - 1;
+
+ return 0;
+}
+
+int kClearFlag1Bit0(ActionCommand *cmd, Scene *scn) {
+ Barrier *barrier = scn->worldstats()->getBarrierById(cmd->param1);
+
+ barrier->flags &= 0xFFFFFFFE;
+
+ return 0;
+}
+
+int k_unk18_PLAY_SND(ActionCommand *cmd, Scene *scn) {
+ return -2;
+}
+
+int kJumpIfFlag2Bit0(ActionCommand *cmd, Scene *scn) {
+ int targetType = cmd->param2;
+
+ return 0;
+
+ // TODO targetType == 7 is trying to access an out of bounds actor
+ // look at the disassembly again
+
+ if (targetType <= 0)
+ scn->actions()->done = (scn->worldstats()->getBarrierById(cmd->param1)->flags2 & 1) == 0;
+ else
+ if (targetType == 1) // v4 == 1, so 1
+ scn->actions()->done = (scn->worldstats()->getActionAreaById(cmd->param1)->actionType & 1) == 0;
+ else
+ scn->actions()->done = (scn->worldstats()->actors[cmd->param1].flags2 & 1) == 0;
+
+ return -1;
+}
+
+int kSetFlag2Bit0(ActionCommand *cmd, Scene *scn) {
+ int targetType = cmd->param2;
+
+ if (targetType == 2)
+ scn->worldstats()->actors[cmd->param1].flags2 |= 1;
+ else
+ if (targetType == 1)
+ scn->worldstats()->getActionAreaById(cmd->param1)->actionType |= 1;
+ else
+ scn->worldstats()->getBarrierById(cmd->param1)->flags2 |= 1;
+
+ return 0;
+}
+
+int kClearFlag2Bit0(ActionCommand *cmd, Scene *scn) {
+ return -2;
+}
+int kJumpIfFlag2Bit2(ActionCommand *cmd, Scene *scn) {
+ return -2;
+}
+int kSetFlag2Bit2(ActionCommand *cmd, Scene *scn) {
+ return -2;
+}
+int kClearFlag2Bit2(ActionCommand *cmd, Scene *scn) {
+ return -2;
+}
+int kJumpIfFlag2Bit1(ActionCommand *cmd, Scene *scn) {
+ return -2;
+}
+int kSetFlag2Bit1(ActionCommand *cmd, Scene *scn) {
+ return -2;
+}
+int kClearFlag2Bit1(ActionCommand *cmd, Scene *scn) {
+ return -2;
+}
+int k_unk22(ActionCommand *cmd, Scene *scn) {
+ return -2;
+}
+int k_unk23(ActionCommand *cmd, Scene *scn) {
+ return -2;
+}
+int k_unk24(ActionCommand *cmd, Scene *scn) {
+ return -2;
+}
+int kRunEncounter(ActionCommand *cmd, Scene *scn) {
+ return -2;
+}
+int kJumpIfFlag2Bit4(ActionCommand *cmd, Scene *scn) {
+ return -2;
+}
+int kSetFlag2Bit4(ActionCommand *cmd, Scene *scn) {
+ return -2;
+}
+int kClearFlag2Bit4(ActionCommand *cmd, Scene *scn) {
+ return -2;
+}
+int kSetActorField638(ActionCommand *cmd, Scene *scn) {
+ return -2;
+}
+int kJumpIfActorField638(ActionCommand *cmd, Scene *scn) {
+ return -2;
+}
+
+int kChangeScene(ActionCommand *cmd, Scene *scn) {
+ scn->actions()->delayedSceneIndex = cmd->param1 + 4;
+ debug(kDebugLevelScripts,
+ "Queueing Scene Change to scene %d...",
+ scn->actions()->delayedSceneIndex);
+
+ return 0;
+}
+
+int k_unk2C_ActorSub(ActionCommand *cmd, Scene *scn) {
+ return -2;
+}
+
+int kPlayMovie(ActionCommand *cmd, Scene *scn) {
+ // TODO: add missing code here
+ scn->actions()->delayedVideoIndex = cmd->param1;
+
+ return -1;
+}
+
+int kStopAllBarriersSounds(ActionCommand *cmd, Scene *scn) {
+ // TODO: do this for all barriers that have sfx playing
+ Shared.getSound()->stopSfx();
+
+ return -1;
+}
+
+int kSetActionFlag01(ActionCommand *cmd, Scene *scn) {
+ return -2;
+}
+int kClearActionFlag01(ActionCommand *cmd, Scene *scn) {
+ return -2;
+}
+int kResetSceneRect(ActionCommand *cmd, Scene *scn) {
+ return -2;
+}
+int kChangeMusicById(ActionCommand *cmd, Scene *scn) {
+ return -2;
+}
+
+int kStopMusic(ActionCommand *cmd, Scene *scn) {
+ Shared.getSound()->stopMusic();
+
+ return 0;
+}
+
+int k_unk34_Status(ActionCommand *cmd, Scene *scn) {
+ if (cmd->param1 >= 2) {
+ cmd->param1 = 0;
+ } else {
+ cmd->param1++;
+ scn->actions()->lineIncrement = 1;
+ }
+
+ return 0;
+}
+
+int k_unk35(ActionCommand *cmd, Scene *scn) {
+ return -2;
+}
+int k_unk36(ActionCommand *cmd, Scene *scn) {
+ return -2;
+}
+
+int kRunBlowUpPuzzle(ActionCommand *cmd, Scene *scn) {
+ // FIXME: improve this to call other blowUpPuzzles than VCR
+ //int puzzleIdx = cmd->param1;
+
+ scn->setBlowUpPuzzle(new BlowUpPuzzleVCR());
+ scn->getBlowUpPuzzle()->openBlowUp();
+
+ return -1;
+}
+
+int kJumpIfFlag2Bit3(ActionCommand *cmd, Scene *scn) {
+ return -2;
+}
+int kSetFlag2Bit3(ActionCommand *cmd, Scene *scn) {
+ return -2;
+}
+int kClearFlag2Bit3(ActionCommand *cmd, Scene *scn) {
+ return -2;
+}
+int k_unk3B_PALETTE_MOD(ActionCommand *cmd, Scene *scn) {
+ return -2;
+}
+
+int k_unk3C_CMP_VAL(ActionCommand *cmd, Scene *scn) {
+ if (cmd->param1) {
+ if (cmd->param2 >= cmd->param1) {
+ cmd->param2 = 0;
+ } else {
+ cmd->param2++;
+ scn->actions()->lineIncrement = 1;
+ }
+ }
+
+ return 0;
+}
+
+int kWaitUntilFramePlayed(ActionCommand *cmd, Scene *scn) {
+ Barrier *barrier = scn->worldstats()->getBarrierById(cmd->param1);
+
+ if (barrier) {
+ uint32 frameNum = 0;
+ if (cmd->param2 == -1)
+ frameNum = barrier->frameCount - 1;
+ else
+ frameNum = cmd->param2;
+
+ if (barrier->frameIdx < frameNum) {
+ scn->actions()->lineIncrement = 0;
+ scn->actions()->waitCycle = true;
+ }
+ } else
+ debugC(kDebugLevelScripts,
+ "Requested invalid object ID:0x%02X in Scene %d Line %d.",
+ cmd->param1,
+ scn->getSceneIndex(),
+ scn->actions()->currentLine);
+
+ return 0;
+}
+
+int kUpdateWideScreen(ActionCommand *cmd, Scene *scn) {
+ int barSize = cmd->param1;
+
+ if (barSize >= 22) {
+ cmd->param1 = 0;
+ } else {
+ Shared.getScreen()->drawWideScreen(4 * barSize);
+ cmd->param1++;
+ }
+
+ return 0;
+}
+
+int k_unk3F(ActionCommand *cmd, Scene *scn) {
+ return -2;
+}
+int k_unk40_SOUND(ActionCommand *cmd, Scene *scn) {
+ return -2;
+}
+
+int kPlaySpeech(ActionCommand *cmd, Scene *scn) {
+ //TODO - Add support for other param options
+ uint32 sndIdx = cmd->param1;
+
+ if ((int)sndIdx >= 0) {
+ if (sndIdx >= 259) {
+ sndIdx -= 9;
+ Shared.getSound()->playSfx(scn->getSpeechPack(), sndIdx - 0x7FFD0000);
+ } else {
+ Shared.getSound()->playSfx(scn->getSpeechPack(), sndIdx);
+ }
+ } else
+ debugC(kDebugLevelScripts,
+ "Requested invalid sound ID:0x%02X in Scene %d Line %d.",
+ cmd->param1,
+ scn->getSceneIndex(),
+ scn->actions()->currentLine);
+
+ return -1;
+}
+
+int k_unk42(ActionCommand *cmd, Scene *scn) {
+ return -2;
+}
+int k_unk43(ActionCommand *cmd, Scene *scn) {
+ return -2;
+}
+int kPaletteFade(ActionCommand *cmd, Scene *scn) {
+ return -2;
+}
+int kStartPaletteFadeThread(ActionCommand *cmd, Scene *scn) {
+ return -2;
+}
+int k_unk46(ActionCommand *cmd, Scene *scn) {
+ return -2;
+}
+
+int kActorFaceObject(ActionCommand *cmd, Scene *scn) {
+ // XXX
+ // Dropping param1, since it's the character index
+ // Investigate further if/when we have a scene with
+ // multiple characters in the actor[] array
+ scn->getActor()->faceTarget(cmd->param2, cmd->param3);
+
+ return -1;
+}
+
+int k_unk48_MATTE_01(ActionCommand *cmd, Scene *scn) {
+ return -2;
+}
+int k_unk49_MATTE_90(ActionCommand *cmd, Scene *scn) {
+ return -2;
+}
+int kJumpIfSoundPlaying(ActionCommand *cmd, Scene *scn) {
+ return -2;
+}
+int kChangePlayerCharacterIndex(ActionCommand *cmd, Scene *scn) {
+ return -2;
+}
+
+int kChangeActorField40(ActionCommand *cmd, Scene *scn) {
+ // TODO: figure out what is this field and what values are set
+ int actorIdx = cmd->param1;
+ int fieldType = cmd->param2;
+
+ if (fieldType) {
+ if (scn->worldstats()->actors[actorIdx].field_40 < 11)
+ scn->worldstats()->actors[actorIdx].field_40 = 14;
+ } else {
+ scn->worldstats()->actors[actorIdx].field_40 = 4;
+ }
+
+ return -1;
+}
+
+int kStopSound(ActionCommand *cmd, Scene *scn) {
+ return -2;
+}
+int k_unk4E_RANDOM_COMMAND(ActionCommand *cmd, Scene *scn) {
+ return -2;
+}
+
+int kClearScreen(ActionCommand *cmd, Scene *scn) {
+ if (cmd->param1)
+ Shared.getScreen()->clearScreen();
+
+ return 0;
+}
+
+int kQuit(ActionCommand *cmd, Scene *scn) {
+ return -2;
+}
+
+int kJumpBarrierFrame(ActionCommand *cmd, Scene *scn) {
+ Barrier *barrier = scn->worldstats()->getBarrierById(cmd->param1);
+
+ if (cmd->param2 == -1)
+ cmd->param2 = barrier->frameCount - 1;
+
+ if (cmd->param3 && cmd->param2 == barrier->frameIdx) {
+ //break;
+ } else if (cmd->param4 && cmd->param2 < barrier->frameIdx) {
+ //break;
+ } else if (cmd->param5 && cmd->param2 > barrier->frameIdx) {
+ //break;
+ } else if (cmd->param6 && cmd->param2 <= barrier->frameIdx) {
+ //break;
+ } else if (cmd->param7 && cmd->param2 >= barrier->frameIdx) {
+ //break;
+ } else if (cmd->param8 && cmd->param2 != barrier->frameIdx) {
+ //break;
+ }
+
+ ActionCommand *nextCmd = &scn->actions()->getScript()->commands[cmd->param9];
+
+ // 0x10 == kReturn
+ if (nextCmd->opcode != 0x10 && nextCmd->opcode)
+ scn->actions()->done = true;
+
+ return 0;
+}
+
+int k_unk52(ActionCommand *cmd, Scene *scn) {
+ return -2;
+}
+int k_unk53(ActionCommand *cmd, Scene *scn) {
+ return -2;
+}
+
+int k_unk54_SET_ACTIONLIST_6EC(ActionCommand *cmd, Scene *scn) {
+ if (cmd->param2)
+ scn->actions()->getScript()->field_1BB0 = rand() % cmd->param1;
+ else
+ scn->actions()->getScript()->field_1BB0 = cmd->param1;
+
+ return 0;
+}
+
+int k_unk55(ActionCommand *cmd, Scene *scn) {
+ // TODO
+ /*
+ if (!cmd->param2) {
+ if (cmd->param3 && scn->actions()->getScript()->field_1BB0 < cmd->param1)
+ //break;
+ else if (cmd->param4 && scn->actions()->getScript()->field_1BB0 > cmd->param1)
+ //break;
+ else if (cmd->param5 && scn->actions()->getScript()->field_1BB0 <= cmd->param1)
+ //break;
+ else if (cmd->param6 && scn->actions()->getScript()->field_1BB0 >= cmd->param1)
+ //break;
+ else if (cmd->param7 && scn->actions()->getScript()->field_1BB0 != cmd->param1)
+ //break;
+ } else if(scn->actions()->getScript()->field_1BB0 == cmd->param1) {
+ //break;
+ }
+ */
+
+ ActionCommand *nextCmd = &scn->actions()->getScript()->commands[cmd->param8];
+
+ if (nextCmd->opcode != 0x10 && nextCmd->opcode)
+ scn->actions()->done = true;
+ else
+ scn->actions()->lineIncrement = cmd->param8;
+
+ return -1;
+}
+
+int k_unk56(ActionCommand *cmd, Scene *scn) {
+ return -2;
+}
+
+int kSetResourcePalette(ActionCommand *cmd, Scene *scn) {
+ if (cmd->param1 > 0)
+ Shared.getScreen()->setPalette(scn->getResourcePack(), scn->worldstats()->grResId[cmd->param1]);
+
+ return 0;
+}
+
+int kSetBarrierFrameIdxFlaged(ActionCommand *cmd, Scene *scn) {
+ Barrier *barrier = scn->worldstats()->getBarrierById(cmd->param1);
+
+ if (cmd->param3)
+ barrier->flags = 1 | barrier->flags;
+ else
+ barrier->flags = barrier->flags & 0xFFFFFFFE;
+
+ barrier->frameIdx = cmd->param2;
+
+ return 0;
+}
+
+int k_unk59(ActionCommand *cmd, Scene *scn) {
+ return -2;
+}
+int k_unk5A(ActionCommand *cmd, Scene *scn) {
+ return -2;
+}
+int k_unk5B(ActionCommand *cmd, Scene *scn) {
+ return -2;
+}
+int k_unk5C(ActionCommand *cmd, Scene *scn) {
+ return -2;
+}
+int k_unk5D(ActionCommand *cmd, Scene *scn) {
+ return -2;
+}
+int k_unk5E(ActionCommand *cmd, Scene *scn) {
+ return -2;
+}
+
+int kSetBarrierLastFrameIdx(ActionCommand *cmd, Scene *scn) {
+ Barrier *barrier = scn->worldstats()->getBarrierById(cmd->param1);
+
+ if (barrier->frameIdx == barrier->frameCount - 1) {
+ scn->actions()->lineIncrement = 0;
+ barrier->flags &= 0xFFFEF1C7;
+ } else {
+ scn->actions()->lineIncrement = 1;
+ }
+
+ return 0;
+}
+
+int k_unk60_SET_OR_CLR_ACTIONAREA_FLAG(ActionCommand *cmd, Scene *scn) {
+ return -2;
+}
+
+int k_unk61(ActionCommand *cmd, Scene *scn) {
+ if (cmd->param2) {
+ if (scn->worldstats()->field_E860C == -1) {
+ scn->actions()->lineIncrement = 0;
+ cmd->param2 = 0;
+ } else {
+ scn->actions()->lineIncrement = 1;
+ }
+ } else {
+ // TODO: do something for scene number 9
+ cmd->param2 = 1;
+ scn->actions()->lineIncrement = 1;
+ }
+
+ return -1;
+}
+
+int k_unk62_SHOW_OPTIONS_SCREEN(ActionCommand *cmd, Scene *scn) {
+ return -2;
+}
+int k_unk63(ActionCommand *cmd, Scene *scn) {
+ return -2;
+}
+
} // end of namespace Asylum
diff --git a/engines/asylum/actionlist.h b/engines/asylum/actionlist.h
index 8c5f25d794..454049f6a4 100644
--- a/engines/asylum/actionlist.h
+++ b/engines/asylum/actionlist.h
@@ -29,10 +29,14 @@
#include "common/array.h"
#include "common/stream.h"
+#include "asylum/scene.h"
+
namespace Asylum {
#define MAX_ACTION_COMMANDS 161
+class Scene;
+
typedef struct ActionCommand {
uint32 numLines; // Only set on the first line of each script
uint32 opcode;
@@ -58,7 +62,7 @@ typedef struct ActionDefinitions {
class ActionList {
public:
- ActionList(Common::SeekableReadStream *stream);
+ ActionList(Common::SeekableReadStream *stream, Scene *scene);
virtual ~ActionList();
uint32 size;
@@ -66,12 +70,140 @@ public:
Common::Array<ActionDefinitions> entries;
+ // FIXME
+ // Made all the internal control variables public and removed the getter/setter
+ // pairs for simplicity. This should be refactored later, once the function mapping
+ // is cleaned up properly
+ int currentLine;
+ int currentLoops;
+ int delayedSceneIndex;
+ int delayedVideoIndex;
+ bool allowInput;
+ bool processing;
+ int lineIncrement;
+ bool done;
+ bool waitCycle;
+
+ void setScriptByIndex(uint32 index);
+ ActionDefinitions* getScript() { return _currentScript; }
+ int process();
+
+ int checkBarrierFlags(int barrierId);
+ int setBarrierNextFrame(int barrierId, int barrierFlags);
+
+ void processActionListSub02(ActionDefinitions* script, ActionCommand* command, int a4);
+ void enableActorSub(int actorIndex, int condition);
+
private:
+ Scene *_scene;
+ ActionDefinitions *_currentScript;
void load(Common::SeekableReadStream *stream);
};
+// opcode functions
+int kReturn0(ActionCommand *cmd, Scene *scn);
+int kSetGameFlag(ActionCommand *cmd, Scene *scn);
+int kClearGameFlag(ActionCommand *cmd, Scene *scn);
+int kToggleGameFlag(ActionCommand *cmd, Scene *scn);
+int kJumpIfGameFlag(ActionCommand *cmd, Scene *scn);
+int kHideCursor(ActionCommand *cmd, Scene *scn);
+int kShowCursor(ActionCommand *cmd, Scene *scn);
+int kPlayAnimation(ActionCommand *cmd, Scene *scn);
+int kMoveScenePosition(ActionCommand *cmd, Scene *scn);
+int kHideActor(ActionCommand *cmd, Scene *scn);
+int kShowActor(ActionCommand *cmd, Scene *scn);
+int kSetActorStats(ActionCommand *cmd, Scene *scn);
+int kSetSceneMotionStat(ActionCommand *cmd, Scene *scn);
+int kDisableActor(ActionCommand *cmd, Scene *scn);
+int kEnableActor(ActionCommand *cmd, Scene *scn);
+int kEnableBarriers(ActionCommand *cmd, Scene *scn);
+int kReturn(ActionCommand *cmd, Scene *scn);
+int kDestroyBarrier(ActionCommand *cmd, Scene *scn);
+int k_unk12_JMP_WALK_ACTOR(ActionCommand *cmd, Scene *scn);
+int k_unk13_JMP_WALK_ACTOR(ActionCommand *cmd, Scene *scn);
+int k_unk14_JMP_WALK_ACTOR(ActionCommand *cmd, Scene *scn);
+int k_unk15(ActionCommand *cmd, Scene *scn);
+int kResetAnimation(ActionCommand *cmd, Scene *scn);
+int kClearFlag1Bit0(ActionCommand *cmd, Scene *scn);
+int k_unk18_PLAY_SND(ActionCommand *cmd, Scene *scn);
+int kJumpIfFlag2Bit0(ActionCommand *cmd, Scene *scn);
+int kSetFlag2Bit0(ActionCommand *cmd, Scene *scn);
+int kClearFlag2Bit0(ActionCommand *cmd, Scene *scn);
+int kJumpIfFlag2Bit2(ActionCommand *cmd, Scene *scn);
+int kSetFlag2Bit2(ActionCommand *cmd, Scene *scn);
+int kClearFlag2Bit2(ActionCommand *cmd, Scene *scn);
+int kJumpIfFlag2Bit1(ActionCommand *cmd, Scene *scn);
+int kSetFlag2Bit1(ActionCommand *cmd, Scene *scn);
+int kClearFlag2Bit1(ActionCommand *cmd, Scene *scn);
+int k_unk22(ActionCommand *cmd, Scene *scn);
+int k_unk23(ActionCommand *cmd, Scene *scn);
+int k_unk24(ActionCommand *cmd, Scene *scn);
+int kRunEncounter(ActionCommand *cmd, Scene *scn);
+int kJumpIfFlag2Bit4(ActionCommand *cmd, Scene *scn);
+int kSetFlag2Bit4(ActionCommand *cmd, Scene *scn);
+int kClearFlag2Bit4(ActionCommand *cmd, Scene *scn);
+int kSetActorField638(ActionCommand *cmd, Scene *scn);
+int kJumpIfActorField638(ActionCommand *cmd, Scene *scn);
+int kChangeScene(ActionCommand *cmd, Scene *scn);
+int k_unk2C_ActorSub(ActionCommand *cmd, Scene *scn);
+int kPlayMovie(ActionCommand *cmd, Scene *scn);
+int kStopAllBarriersSounds(ActionCommand *cmd, Scene *scn);
+int kSetActionFlag01(ActionCommand *cmd, Scene *scn);
+int kClearActionFlag01(ActionCommand *cmd, Scene *scn);
+int kResetSceneRect(ActionCommand *cmd, Scene *scn);
+int kChangeMusicById(ActionCommand *cmd, Scene *scn);
+int kStopMusic(ActionCommand *cmd, Scene *scn);
+int k_unk34_Status(ActionCommand *cmd, Scene *scn);
+int k_unk35(ActionCommand *cmd, Scene *scn);
+int k_unk36(ActionCommand *cmd, Scene *scn);
+int kRunBlowUpPuzzle(ActionCommand *cmd, Scene *scn);
+int kJumpIfFlag2Bit3(ActionCommand *cmd, Scene *scn);
+int kSetFlag2Bit3(ActionCommand *cmd, Scene *scn);
+int kClearFlag2Bit3(ActionCommand *cmd, Scene *scn);
+int k_unk3B_PALETTE_MOD(ActionCommand *cmd, Scene *scn);
+int k_unk3C_CMP_VAL(ActionCommand *cmd, Scene *scn);
+int kWaitUntilFramePlayed(ActionCommand *cmd, Scene *scn);
+int kUpdateWideScreen(ActionCommand *cmd, Scene *scn);
+int k_unk3F(ActionCommand *cmd, Scene *scn);
+int k_unk40_SOUND(ActionCommand *cmd, Scene *scn);
+int kPlaySpeech(ActionCommand *cmd, Scene *scn);
+int k_unk42(ActionCommand *cmd, Scene *scn);
+int k_unk43(ActionCommand *cmd, Scene *scn);
+int kPaletteFade(ActionCommand *cmd, Scene *scn);
+int kStartPaletteFadeThread(ActionCommand *cmd, Scene *scn);
+int k_unk46(ActionCommand *cmd, Scene *scn);
+int kActorFaceObject(ActionCommand *cmd, Scene *scn);
+int k_unk48_MATTE_01(ActionCommand *cmd, Scene *scn);
+int k_unk49_MATTE_90(ActionCommand *cmd, Scene *scn);
+int kJumpIfSoundPlaying(ActionCommand *cmd, Scene *scn);
+int kChangePlayerCharacterIndex(ActionCommand *cmd, Scene *scn);
+int kChangeActorField40(ActionCommand *cmd, Scene *scn);
+int kStopSound(ActionCommand *cmd, Scene *scn);
+int k_unk4E_RANDOM_COMMAND(ActionCommand *cmd, Scene *scn);
+int kClearScreen(ActionCommand *cmd, Scene *scn);
+int kQuit(ActionCommand *cmd, Scene *scn);
+int kJumpBarrierFrame(ActionCommand *cmd, Scene *scn);
+int k_unk52(ActionCommand *cmd, Scene *scn);
+int k_unk53(ActionCommand *cmd, Scene *scn);
+int k_unk54_SET_ACTIONLIST_6EC(ActionCommand *cmd, Scene *scn);
+int k_unk55(ActionCommand *cmd, Scene *scn);
+int k_unk56(ActionCommand *cmd, Scene *scn);
+int kSetResourcePalette(ActionCommand *cmd, Scene *scn);
+int kSetBarrierFrameIdxFlaged(ActionCommand *cmd, Scene *scn);
+int k_unk59(ActionCommand *cmd, Scene *scn);
+int k_unk5A(ActionCommand *cmd, Scene *scn);
+int k_unk5B(ActionCommand *cmd, Scene *scn);
+int k_unk5C(ActionCommand *cmd, Scene *scn);
+int k_unk5D(ActionCommand *cmd, Scene *scn);
+int k_unk5E(ActionCommand *cmd, Scene *scn);
+int kSetBarrierLastFrameIdx(ActionCommand *cmd, Scene *scn);
+int k_unk60_SET_OR_CLR_ACTIONAREA_FLAG(ActionCommand *cmd, Scene *scn);
+int k_unk61(ActionCommand *cmd, Scene *scn);
+int k_unk62_SHOW_OPTIONS_SCREEN(ActionCommand *cmd, Scene *scn);
+int k_unk63(ActionCommand *cmd, Scene *scn);
+
} // end of namespace Asylum
#endif
diff --git a/engines/asylum/actor.cpp b/engines/asylum/actor.cpp
index 8f2f0ce039..11e1bdfe58 100644
--- a/engines/asylum/actor.cpp
+++ b/engines/asylum/actor.cpp
@@ -157,7 +157,7 @@ void Actor::drawActor() {
void Actor::setWalkArea(ActionArea *target) {
if (_currentWalkArea != target) {
- ScriptMan.setScriptIndex(target->actionListIdx1);
+ Shared.getScene()->actions()->setScriptByIndex(target->actionListIdx1);
_currentWalkArea = target;
debugC(kDebugLevelScripts, "%s", target->name);
}
diff --git a/engines/asylum/asylum.cpp b/engines/asylum/asylum.cpp
index 1710d5d9c8..1236651f38 100644
--- a/engines/asylum/asylum.cpp
+++ b/engines/asylum/asylum.cpp
@@ -114,7 +114,7 @@ Common::Error AsylumEngine::go() {
// XXX This can probably also be rolled into the scene constructor.
// Investigate if this will fuck up the execution sequence though :P
- ScriptMan.setScript(_scene->getDefaultActionList());
+ _scene->actions()->setScriptByIndex(_scene->worldstats()->actionListIdx);
// Set up main menu
_mainMenu = new MainMenu();
@@ -260,12 +260,12 @@ void AsylumEngine::checkForEvent(bool doUpdate) { // k_sub_40AE30 (0040AE30)
void AsylumEngine::processDelayedEvents() {
// check for a delayed video
- int videoIdx = ScriptMan.delayedVideoIndex;
+ int videoIdx = _scene->actions()->delayedVideoIndex;
if (videoIdx >= 0) {
_sound->stopMusic();
_sound->stopSfx();
_video->playVideo(videoIdx, kSubtitlesOn);
- ScriptMan.delayedVideoIndex = -1;
+ _scene->actions()->delayedVideoIndex = -1;
if (_mainMenu->isActive())
_mainMenu->openMenu();
@@ -274,8 +274,8 @@ void AsylumEngine::processDelayedEvents() {
}
// check for a delayed scene change
- int sceneIdx = ScriptMan.delayedSceneIndex;
- if (sceneIdx >=0 && !ScriptMan.processing) {
+ int sceneIdx = _scene->actions()->delayedSceneIndex;
+ if (sceneIdx >=0 && !_scene->actions()->processing) {
_sound->stopMusic();
_sound->stopSfx();
@@ -286,8 +286,8 @@ void AsylumEngine::processDelayedEvents() {
Shared.setScene(_scene);
_scene->enterScene();
- ScriptMan.delayedSceneIndex = -1;
- ScriptMan.setScript(_scene->getDefaultActionList());
+ _scene->actions()->delayedSceneIndex = -1;
+ _scene->actions()->setScriptByIndex(_scene->worldstats()->actionListIdx);
}
}
diff --git a/engines/asylum/asylum.h b/engines/asylum/asylum.h
index e577fa754e..fbac27601b 100644
--- a/engines/asylum/asylum.h
+++ b/engines/asylum/asylum.h
@@ -34,7 +34,6 @@
#include "asylum/screen.h"
#include "asylum/sound.h"
#include "asylum/video.h"
-#include "asylum/scriptman.h"
#include "asylum/blowuppuzzle.h"
#include "asylum/encounters.h"
diff --git a/engines/asylum/asylum.vcproj b/engines/asylum/asylum.vcproj
index e4d408665c..151c15e466 100644
--- a/engines/asylum/asylum.vcproj
+++ b/engines/asylum/asylum.vcproj
@@ -42,9 +42,7 @@
<File RelativePath="..\..\engines\asylum\scene.cpp" />
<File RelativePath="..\..\engines\asylum\scene.h" />
<File RelativePath="..\..\engines\asylum\screen.cpp" />
- <File RelativePath="..\..\engines\asylum\screen.h" />
- <File RelativePath="..\..\engines\asylum\scriptman.cpp" />
- <File RelativePath="..\..\engines\asylum\scriptman.h" />
+ <File RelativePath="..\..\engines\asylum\screen.h" />
<File RelativePath="..\..\engines\asylum\sound.cpp" />
<File RelativePath="..\..\engines\asylum\sound.h" />
<File RelativePath="..\..\engines\asylum\text.cpp" />
diff --git a/engines/asylum/console.cpp b/engines/asylum/console.cpp
index f7ef89abd6..19244901c2 100644
--- a/engines/asylum/console.cpp
+++ b/engines/asylum/console.cpp
@@ -118,7 +118,7 @@ bool Console::cmdPlayVideo(int argc, const char **argv) {
return true;
}
- ScriptMan.delayedVideoIndex = atoi(argv[1]);
+ Shared.getScene()->actions()->delayedVideoIndex = atoi(argv[1]);
return false;
}
@@ -129,7 +129,7 @@ bool Console::cmdRunScript(int argc, const char **argv) {
return true;
}
- ScriptMan.setScriptIndex(atoi(argv[1]));
+ Shared.getScene()->actions()->setScriptByIndex(atoi(argv[1]));
return false;
}
@@ -145,8 +145,9 @@ bool Console::cmdChangeScene(int argc, const char **argv) {
return true;
}
- ScriptMan.delayedSceneIndex = atoi(argv[1]);
- ScriptMan.setScript(0);
+ Shared.getScene()->actions()->delayedSceneIndex = atoi(argv[1]);
+ Shared.getScene()->actions()->setScriptByIndex(0); // XXX is this right or should it be
+ // ws->actionListIdx???
return false;
}
diff --git a/engines/asylum/module.mk b/engines/asylum/module.mk
index 7a5fbbd9db..18556c7ed8 100644
--- a/engines/asylum/module.mk
+++ b/engines/asylum/module.mk
@@ -1,26 +1,25 @@
MODULE := engines/asylum
MODULE_OBJS := \
+ actionlist.o \
+ actor.o \
asylum.o \
+ barrier.o \
+ blowuppuzzle.o \
console.o \
+ cursor.o \
detection.o \
+ encounters.o \
graphics.o \
menu.o \
+ polygons.o \
respack.o \
scene.o \
- barrier.o \
screen.o \
+ shared.o \
sound.o \
text.o \
video.o \
- actor.o \
- encounters.o \
- scriptman.o \
- blowuppuzzle.o \
- shared.o \
- cursor.o \
- polygons.o \
- actionlist.o \
worldstats.o
# This module can be built as a plugin
diff --git a/engines/asylum/scene.cpp b/engines/asylum/scene.cpp
index f54396bb51..07719e9d3f 100644
--- a/engines/asylum/scene.cpp
+++ b/engines/asylum/scene.cpp
@@ -25,7 +25,6 @@
#include "asylum/scene.h"
#include "asylum/shared.h"
-#include "asylum/scriptman.h"
#include "asylum/actor.h"
namespace Asylum {
@@ -64,7 +63,7 @@ Scene::Scene(uint8 sceneIdx) {
_polygons = new Polygons(fd);
// jump to action list data
fd->seek(0xE868E + _polygons->size * _polygons->numEntries);
- _actions = new ActionList(fd);
+ _actions = new ActionList(fd, this);
fd->close();
delete fd;
@@ -157,17 +156,6 @@ void Scene::enterScene() {
_walking = false;
}
-ActionDefinitions* Scene::getDefaultActionList() {
- getActionList(_ws->actionListIdx);
-}
-
-ActionDefinitions* Scene::getActionList(int actionListIndex) {
- if ((actionListIndex >= 0) && (actionListIndex < (int)_ws->numActions))
- return &actions()->entries[actionListIndex];
- else
- return 0;
-}
-
void Scene::setScenePosition(int x, int y)
{
WorldStats *ws = _ws;
@@ -199,12 +187,12 @@ void Scene::handleEvent(Common::Event *event, bool doUpdate) {
break;
case Common::EVENT_LBUTTONUP:
- if (ScriptMan.allowInput)
+ if (_actions->allowInput)
_leftClick = true;
break;
case Common::EVENT_RBUTTONUP:
- if (ScriptMan.allowInput) {
+ if (_actions->allowInput) {
// TODO This isn't always going to be the magnifying glass
// Should check the current pointer region to identify the type
// of cursor to use
@@ -214,7 +202,7 @@ void Scene::handleEvent(Common::Event *event, bool doUpdate) {
break;
case Common::EVENT_RBUTTONDOWN:
- if (ScriptMan.allowInput)
+ if (_actions->allowInput)
_rightButton = true;
break;
}
@@ -276,7 +264,7 @@ int Scene::updateScene() {
//updateAdjustScreen();
//debugC(kDebugLevelScene, "AdjustScreenStart Time: %d", Shared.getMillis() - startTick);
- if(ScriptMan.processActionList())
+ if(_actions->process())
return 1;
return 0;
@@ -878,7 +866,7 @@ void Scene::OLD_UPDATE(WorldStats *worldStats) {
worldStats->actions[a].actionListIdx2,
worldStats->actions[a].actionType,
worldStats->actions[a].soundResId);
- ScriptMan.setScript(&_actions->entries[worldStats->actions[a].actionListIdx1]);
+ _actions->setScriptByIndex(_ws->actions[a].actionListIdx1);
}
}
} else if (curBarrier >= 0) {
@@ -889,7 +877,7 @@ void Scene::OLD_UPDATE(WorldStats *worldStats) {
b.soundResId,
b.flags,
b.flags2);
- ScriptMan.setScript(getActionList(b.actionListIdx));
+ _actions->setScriptByIndex(b.actionListIdx);
}
}
}
diff --git a/engines/asylum/scene.h b/engines/asylum/scene.h
index 92885b3946..14baf713c2 100644
--- a/engines/asylum/scene.h
+++ b/engines/asylum/scene.h
@@ -41,6 +41,7 @@
namespace Asylum {
+class ActionList;
class Screen;
class Sound;
class Video;
@@ -61,10 +62,6 @@ public:
void deactivate() { _isActive = false; }
bool isActive() { return _isActive; }
int getSceneIndex() { return _sceneIdx; }
-
- // TODO roll into actionlist.cpp
- ActionDefinitions* getDefaultActionList();
- ActionDefinitions* getActionList(int actionListIndex);
Actor* getActor();
diff --git a/engines/asylum/scriptman.cpp b/engines/asylum/scriptman.cpp
deleted file mode 100644
index 1d1c65a4f9..0000000000
--- a/engines/asylum/scriptman.cpp
+++ /dev/null
@@ -1,1176 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software { you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation { either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY { without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program { if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * $URL$
- * $Id$
- */
-
-#include "common/system.h"
-
-#include "asylum/scriptman.h"
-#include "asylum/shared.h"
-
-DECLARE_SINGLETON(Asylum::ScriptManager);
-
-namespace Asylum {
-
-static bool g_initialized = false;
-
-typedef int AsylumFunc(ActionCommand *cmd);
-
-struct AsylumFunction {
- const char *name;
- AsylumFunc *function;
-};
-
-#define MAPFUNC(name, func) {name, func}
-
-AsylumFunction function_map[] = {
- /*0x00*/ MAPFUNC("kReturn0", kReturn0),
- /*0x01*/ MAPFUNC("kSetGameFlag", kSetGameFlag),
- /*0x02*/ MAPFUNC("kClearGameFlag", kClearGameFlag),
- /*0x03*/ MAPFUNC("kToggleGameFlag", kToggleGameFlag),
- /*0x04*/ MAPFUNC("kJumpIfGameFlag", kJumpIfGameFlag),
- /*0x05*/ MAPFUNC("kHideCursor", kHideCursor),
- /*0x06*/ MAPFUNC("kShowCursor", kShowCursor),
- /*0x07*/ MAPFUNC("kPlayAnimation", kPlayAnimation),
- /*0x08*/ MAPFUNC("kMoveScenePosition", kMoveScenePosition),
- /*0x09*/ MAPFUNC("kHideActor", kHideActor),
- /*0x0A*/ MAPFUNC("kShowActor", kShowActor),
- /*0x0B*/ MAPFUNC("kSetActorStats", kSetActorStats),
- /*0x0C*/ MAPFUNC("kSetSceneMotionStat", kSetSceneMotionStat),
- /*0x0D*/ MAPFUNC("kDisableActor", kDisableActor),
- /*0x0E*/ MAPFUNC("kEnableActor", kEnableActor),
- /*0x0F*/ MAPFUNC("kEnableBarriers", kEnableBarriers),
- /*0x10*/ MAPFUNC("kReturn", kReturn),
- /*0x11*/ MAPFUNC("kDestroyBarrier", kDestroyBarrier),
- /*0x12*/ MAPFUNC("k_unk12_JMP_WALK_ACTOR", k_unk12_JMP_WALK_ACTOR),
- /*0x13*/ MAPFUNC("k_unk13_JMP_WALK_ACTOR", k_unk13_JMP_WALK_ACTOR),
- /*0x14*/ MAPFUNC("k_unk14_JMP_WALK_ACTOR", k_unk14_JMP_WALK_ACTOR),
- /*0x15*/ MAPFUNC("k_unk15", k_unk15),
- /*0x16*/ MAPFUNC("kResetAnimation", kResetAnimation),
- /*0x17*/ MAPFUNC("kClearFlag1Bit0", kClearFlag1Bit0),
- /*0x18*/ MAPFUNC("k_unk18_PLAY_SND", k_unk18_PLAY_SND),
- /*0x19*/ MAPFUNC("kJumpIfFlag2Bit0", kJumpIfFlag2Bit0),
- /*0x1A*/ MAPFUNC("kSetFlag2Bit0", kSetFlag2Bit0),
- /*0x1B*/ MAPFUNC("kClearFlag2Bit0", kClearFlag2Bit0),
- /*0x1C*/ MAPFUNC("kJumpIfFlag2Bit2", kJumpIfFlag2Bit2),
- /*0x1D*/ MAPFUNC("kSetFlag2Bit2", kSetFlag2Bit2),
- /*0x1E*/ MAPFUNC("kClearFlag2Bit2", kClearFlag2Bit2),
- /*0x1F*/ MAPFUNC("kJumpIfFlag2Bit1", kJumpIfFlag2Bit1),
- /*0x20*/ MAPFUNC("kSetFlag2Bit1", kSetFlag2Bit1),
- /*0x21*/ MAPFUNC("kClearFlag2Bit1", kClearFlag2Bit1),
- /*0x22*/ MAPFUNC("k_unk22", k_unk22),
- /*0x23*/ MAPFUNC("k_unk23", k_unk23),
- /*0x24*/ MAPFUNC("k_unk24", k_unk24),
- /*0x25*/ MAPFUNC("kRunEncounter", kRunEncounter),
- /*0x26*/ MAPFUNC("kJumpIfFlag2Bit4", kJumpIfFlag2Bit4),
- /*0x27*/ MAPFUNC("kSetFlag2Bit4", kSetFlag2Bit4),
- /*0x28*/ MAPFUNC("kClearFlag2Bit4", kClearFlag2Bit4),
- /*0x29*/ MAPFUNC("kSetActorField638", kSetActorField638),
- /*0x2A*/ MAPFUNC("kJumpIfActorField638", kJumpIfActorField638),
- /*0x2B*/ MAPFUNC("kChangeScene", kChangeScene),
- /*0x2C*/ MAPFUNC("k_unk2C_ActorSub", k_unk2C_ActorSub),
- /*0x2D*/ MAPFUNC("kPlayMovie", kPlayMovie),
- /*0x2E*/ MAPFUNC("kStopAllBarriersSounds", kStopAllBarriersSounds),
- /*0x2F*/ MAPFUNC("kSetActionFlag01", kSetActionFlag01),
- /*0x30*/ MAPFUNC("kClearActionFlag01", kClearActionFlag01),
- /*0x31*/ MAPFUNC("kResetSceneRect", kResetSceneRect),
- /*0x32*/ MAPFUNC("kChangeMusicById", kChangeMusicById),
- /*0x33*/ MAPFUNC("kStopMusic", kStopMusic),
- /*0x34*/ MAPFUNC("k_unk34_Status", k_unk34_Status),
- /*0x35*/ MAPFUNC("k_unk35", k_unk35),
- /*0x36*/ MAPFUNC("k_unk36", k_unk36),
- /*0x37*/ MAPFUNC("kRunBlowUpPuzzle", kRunBlowUpPuzzle),
- /*0x38*/ MAPFUNC("kJumpIfFlag2Bit3", kJumpIfFlag2Bit3),
- /*0x39*/ MAPFUNC("kSetFlag2Bit3", kSetFlag2Bit3),
- /*0x3A*/ MAPFUNC("kClearFlag2Bit3", kClearFlag2Bit3),
- /*0x3B*/ MAPFUNC("k_unk3B_PALETTE_MOD", k_unk3B_PALETTE_MOD),
- /*0x3C*/ MAPFUNC("k_unk3C_CMP_VAL", k_unk3C_CMP_VAL),
- /*0x3D*/ MAPFUNC("kWaitUntilFramePlayed", kWaitUntilFramePlayed),
- /*0x3E*/ MAPFUNC("kUpdateWideScreen", kUpdateWideScreen),
- /*0x3F*/ MAPFUNC("k_unk3F", k_unk3F),
- /*0x40*/ MAPFUNC("k_unk40_SOUND", k_unk40_SOUND),
- /*0x41*/ MAPFUNC("kPlaySpeech", kPlaySpeech),
- /*0x42*/ MAPFUNC("k_unk42", k_unk42),
- /*0x43*/ MAPFUNC("k_unk43", k_unk43),
- /*0x44*/ MAPFUNC("kPaletteFade", kPaletteFade),
- /*0x45*/ MAPFUNC("kStartPaletteFadeThread", kStartPaletteFadeThread),
- /*0x46*/ MAPFUNC("k_unk46", k_unk46),
- /*0x47*/ MAPFUNC("kActorFaceObject", kActorFaceObject),
- /*0x48*/ MAPFUNC("k_unk48_MATTE_01", k_unk48_MATTE_01),
- /*0x49*/ MAPFUNC("k_unk49_MATTE_90", k_unk49_MATTE_90),
- /*0x4A*/ MAPFUNC("kJumpIfSoundPlaying", kJumpIfSoundPlaying),
- /*0x4B*/ MAPFUNC("kChangePlayerCharacterIndex", kChangePlayerCharacterIndex),
- /*0x4C*/ MAPFUNC("kChangeActorField40", kChangeActorField40),
- /*0x4D*/ MAPFUNC("kStopSound", kStopSound),
- /*0x4E*/ MAPFUNC("k_unk4E_RANDOM_COMMAND", k_unk4E_RANDOM_COMMAND),
- /*0x4F*/ MAPFUNC("kClearScreen", kClearScreen),
- /*0x50*/ MAPFUNC("kQuit", kQuit),
- /*0x51*/ MAPFUNC("kJumpBarrierFrame", kJumpBarrierFrame),
- /*0x52*/ MAPFUNC("k_unk52", k_unk52),
- /*0x53*/ MAPFUNC("k_unk53", k_unk53),
- /*0x54*/ MAPFUNC("k_unk54_SET_ACTIONLIST_6EC", k_unk54_SET_ACTIONLIST_6EC),
- /*0x55*/ MAPFUNC("k_unk55", k_unk55),
- /*0x56*/ MAPFUNC("k_unk56", k_unk56),
- /*0x57*/ MAPFUNC("kSetResourcePalette", kSetResourcePalette),
- /*0x58*/ MAPFUNC("kSetBarrierFrameIdxFlaged", kSetBarrierFrameIdxFlaged),
- /*0x59*/ MAPFUNC("k_unk59", k_unk59),
- /*0x5A*/ MAPFUNC("k_unk5A", k_unk5A),
- /*0x5B*/ MAPFUNC("k_unk5B", k_unk5B),
- /*0x5C*/ MAPFUNC("k_unk5C", k_unk5C),
- /*0x5D*/ MAPFUNC("k_unk5D", k_unk5D),
- /*0x5E*/ MAPFUNC("k_unk5E", k_unk5E),
- /*0x5F*/ MAPFUNC("kSetBarrierLastFrameIdx", kSetBarrierLastFrameIdx),
- /*0x60*/ MAPFUNC("k_unk60_SET_OR_CLR_ACTIONAREA_FLAG", k_unk60_SET_OR_CLR_ACTIONAREA_FLAG),
- /*0x61*/ MAPFUNC("k_unk61", k_unk61),
- /*0x62*/ MAPFUNC("k_unk62_SHOW_OPTIONS_SCREEN", k_unk62_SHOW_OPTIONS_SCREEN),
- /*0x63*/ MAPFUNC("k_unk63", k_unk63)
-};
-
-ScriptManager::ScriptManager() {
- if (!g_initialized) {
- g_initialized = true;
- currentLine = 0;
- currentLoops = 0;
- processing = false;
- delayedSceneIndex = -1;
- delayedVideoIndex = -1;
- allowInput = true;
- }
-}
-
-ScriptManager::~ScriptManager() {
- // TODO Release function_map list
-}
-
-void ScriptManager::setScript(ActionDefinitions *action) {
- _currentScript = action;
-
- if (_currentScript) {
- for (uint8 i = 0; i < _currentScript->commands[0].numLines; i++) {
- debugC(kDebugLevelScripts,
- "Line: %02d/%02d :: 0x%02X (%d, %d, %d, %d, %d, %d, %d, %d, %d)",
- i,
- _currentScript->commands[0].numLines - 1,
- _currentScript->commands[i].opcode,
- _currentScript->commands[i].param1,
- _currentScript->commands[i].param2,
- _currentScript->commands[i].param3,
- _currentScript->commands[i].param4,
- _currentScript->commands[i].param5,
- _currentScript->commands[i].param6,
- _currentScript->commands[i].param7,
- _currentScript->commands[i].param8,
- _currentScript->commands[i].param9);
- }
- }
-}
-
-void ScriptManager::setScriptIndex(uint32 index) {
- _currentScript = 0;
- currentLine = 0;
- setScript(Shared.getScene()->getActionList(index));
-}
-
-int ScriptManager::checkBarrierFlags(int barrierId) {
- int flags = Shared.getScene()->worldstats()->getBarrierById(barrierId)->flags;
- return flags & 1 && (flags & 8 || flags & 0x10000);
-}
-
-int ScriptManager::setBarrierNextFrame(int barrierId, int barrierFlags) {
- int barrierIndex = Shared.getScene()->worldstats()->getBarrierIndexById(barrierId);
-
- Barrier *barrier = Shared.getScene()->worldstats()->getBarrierByIndex(barrierIndex);
- int newFlag = barrierFlags | 1 | barrier->flags;
- barrier->flags |= barrierFlags | 1;
-
- if (newFlag & 0x10000) {
- barrier->frameIdx = barrier->frameCount - 1;
- } else {
- barrier->frameIdx = 0;
- }
-
- return barrierIndex;
-}
-
-int ScriptManager::processActionList() {
- done = false;
- waitCycle = false;
- lineIncrement = 1;
- processing = true;
-
- if (_currentScript) {
- while (!done && !waitCycle) {
- lineIncrement = 1; //Reset line increment value
-
- if (currentLoops > 1000) {
- //TODO - processActionLists has run too many iterations
- }
-
- ActionCommand *currentCommand = &_currentScript->commands[currentLine];
-
- uint32 opcode = currentCommand->opcode;
-
- // Execute command from function mapping
- int cmdRet = function_map[opcode].function(currentCommand);
-
- // Check function return
- if (cmdRet == -1)
- warning("Incomplete opcode %s (0x%02X) in Scene %d Line %d",
- function_map[opcode].name,
- currentCommand->opcode,
- Shared.getScene()->getSceneIndex(),
- currentLine);
- if (cmdRet == -2)
- warning("Unhandled opcode %s (0x%02X) in Scene %d Line %d",
- function_map[opcode].name,
- currentCommand->opcode,
- Shared.getScene()->getSceneIndex(),
- currentLine);
-
- currentLine += lineIncrement;
- currentLoops++;
-
- } // end while
-
- if (done) {
- currentLine = 0;
- currentLoops = 0;
- _currentScript = 0;
-
- // XXX
- // gameFlag 183 is the same as the
- // processing flag, but is not being used
- Shared.clearGameFlag(183);
- }
- }
-
- processing = false;
-
- return 0;
-}
-
-void ScriptManager::processActionListSub02(ActionDefinitions* script, ActionCommand *command, int a4) {
- int v4 = 0;
- int result;
- int barrierIdx = 0;
- if (a4) {
- if (a4 == 1) {
- ;
- } else {
- result = a4 - 2;
- int v8 = command->param4;
-
- for (int i = 7; i > 0; i--) {
- barrierIdx = Shared.getScene()->worldstats()->getBarrierIndexById(v8);
- if (barrierIdx >= 0)
- Shared.getScene()->worldstats()->barriers[barrierIdx].field_67C = 0;
- v8 += 4;
- }
- }
- // TODO
- switch (Shared.getScene()->getSceneIndex()) {
- case 7:
- warning("Scene 7 / v4 != 0 Not Implemented");
- break;
- case 6:
- warning("Scene 6 / v4 != 0 Not Implemented");
- break;
- case 8:
- warning("Scene 8 / v4 != 0 Not Implemented");
- break;
- case 3:
- warning("Scene 3 / v4 != 0 Not Implemented");
- break;
- case 4:
- warning("Scene 4 / v4 != 0 Not Implemented");
- break;
- default:
- return;
- }
- } else {
- int v13 = command->param4;
- int v4 = script->counter / command->param2 + 4;
- for (int i = 7; i > 0; i--) {
- barrierIdx = Shared.getScene()->worldstats()->getBarrierIndexById(v13);
- if (barrierIdx >= 0)
- Shared.getScene()->worldstats()->barriers[barrierIdx].field_67C = v4;
- v13 += 4;
- }
- // TODO
- switch (Shared.getScene()->getSceneIndex()) {
- case 7:
- warning("Scene 7 / v4 = 0 Not Implemented");
- break;
- case 6:
- warning("Scene 6 / v4 = 0 Not Implemented");
- break;
- case 8:
- warning("Scene 8 / v4 = 0 Not Implemented");
- break;
- case 3:
- warning("Scene 3 / v4 = 0 Not Implemented");
- break;
- case 4:
- warning("Scene 4 / v4 = 0 Not Implemented");
- break;
- default:
- return;
- }
- }
-}
-
-void ScriptManager::enableActorSub(int actorIndex, int condition) {
-
-}
-
-/* Opcode Functions */
-
-int kReturn0(ActionCommand *cmd) {
- ScriptMan.done = true;
- ScriptMan.lineIncrement = 0;
- return 0;
-}
-
-int kSetGameFlag(ActionCommand *cmd) {
- int flagNum = cmd->param1;
-
- if (flagNum >= 0)
- Shared.setGameFlag(flagNum);
-
- return 0;
-}
-
-int kClearGameFlag(ActionCommand *cmd) {
- int flagNum = cmd->param1;
-
- if (flagNum >= 0)
- Shared.clearGameFlag(flagNum);
-
- return 0;
-}
-
-int kToggleGameFlag(ActionCommand *cmd) {
- int flagNum = cmd->param1;
-
- if (flagNum >= 0)
- Shared.toggleGameFlag(flagNum);
-
- return 0;
-}
-
-int kJumpIfGameFlag(ActionCommand *cmd) {
- int flagNum = cmd->param1;
-
- if (flagNum) {
- bool doJump = Shared.isGameFlagSet(flagNum);
- if (cmd->param2)
- doJump = Shared.isGameFlagNotSet(flagNum);
- if (doJump)
- ScriptMan.currentLine = cmd->param3;
- }
-
- return 0;
-}
-
-int kHideCursor(ActionCommand *cmd) {
- Shared.getScene()->getCursor()->hide();
- ScriptMan.allowInput = false;
-
- return 0;
-}
-
-int kShowCursor(ActionCommand *cmd) {
- Shared.getScene()->getCursor()->show();
- ScriptMan.allowInput = true;
-
- // TODO clear_flag_01()
- return -1;
-}
-
-int kPlayAnimation(ActionCommand *cmd) {
- int barrierId = cmd->param1;
-
- if (cmd->param2 == 2) {
- if (!ScriptMan.checkBarrierFlags(barrierId)) {
- cmd->param2 = 1;
- // FIXME Not sure why this break was here
- // break;
- }
- ScriptMan.lineIncrement = 1;
- } else {
- int barrierIndex = Shared.getScene()->worldstats()->getBarrierIndexById(barrierId);
- Barrier *barrier = Shared.getScene()->worldstats()->getBarrierByIndex(barrierIndex);
-
- if (cmd->param4) { // RECHECK THIS
- int newBarriedIndex = 213 * barrierIndex;
- barrier->flags &= 0xFFFEF1C7;
- Shared.getScene()->worldstats()->getBarrierByIndex(newBarriedIndex)->flags = barrier->flags | 0x20;
- } else if (cmd->param3) {
- barrier->flags &= 0xFFFEF1C7;
- barrier->flags |= 0x10000;
- } else {
- barrier->flags &= 0x10000;
- if(barrier->flags == 0) {
- barrier->flags &= 0x10E38;
- if(barrier->flags == 0) {
- barrier->flags |= 8;
- }
- } else {
- barrier->flags |= 8;
- barrier->flags &= 0xFFFEFFFF;
- }
- }
-
- ScriptMan.setBarrierNextFrame(barrierId, barrier->flags);
-
- if(barrier->field_688 == 1) {
- // TODO: get barrier position
- }
-
- if(cmd->param2) {
- cmd->param2 = 2;
- ScriptMan.lineIncrement = 1;
- }
- }
-
- return -1;
-}
-
-int kMoveScenePosition(ActionCommand *cmd) {
- WorldStats *ws = Shared.getScene()->worldstats();
- Common::Rect *sr = &ws->sceneRects[ws->sceneRectIdx];
-
- if (cmd->param3 < 1) {
- ws->xLeft = cmd->param1;
- ws->yTop = cmd->param2;
- ws->motionStatus = 3;
- } else if (!cmd->param4) {
- ws->motionStatus = 5;
- ws->targetX = cmd->param1;
- ws->targetY = cmd->param2;
- ws->field_A0 = cmd->param3;
-
- if (ws->targetX < (uint32)sr->left)
- ws->targetX = sr->left;
- if (ws->targetY < (uint32)sr->top)
- ws->targetY = sr->top;
- if (ws->targetX + 640 > (uint32)sr->right)
- ws->targetX = sr->right - 640;
- if (ws->targetY + 480 > (uint32)sr->bottom)
- ws->targetY = sr->bottom - 480;
-
- // TODO: reverse asm block
-
- } else if (cmd->param5) {
- if (ws->motionStatus == 2)
- ScriptMan.lineIncrement = 1;
- else
- cmd->param5 = 0;
- } else {
- cmd->param5 = 1;
- ws->motionStatus = 2;
- ws->targetX = cmd->param1;
- ws->targetY = cmd->param2;
- ws->field_A0 = cmd->param3;
-
- if (ws->targetX + 640 > ws->width)
- ws->targetX = ws->width - 640;
- if (ws->targetX < (uint32)sr->left)
- ws->targetX = sr->left;
- if (ws->targetY < (uint32)sr->top)
- ws->targetY = sr->top;
- if (ws->targetX + 640 > (uint32)sr->right)
- ws->targetX = sr->right - 640;
- if (ws->targetY + 480 > (uint32)sr->bottom)
- ws->targetY = sr->bottom - 480;
-
- // TODO: reverse asm block
- }
-
- return -1;
-}
-
-int kHideActor(ActionCommand *cmd) {
- uint32 actorIndex = 0;
-
- if (cmd->param1 == -1)
- ;//actorIndex = Shared.getScene()->getWorldStats()->playerActor;
- else
- actorIndex = cmd->param1;
-
- if ((actorIndex >= 0) && (actorIndex < Shared.getScene()->worldstats()->numActors))
- Shared.getScene()->getActor()->visible(false);
- else
- debugC(kDebugLevelScripts,
- "Requested invalid actor ID:0x%02X in Scene %d Line %d.",
- cmd->param1,
- Shared.getScene()->getSceneIndex(),
- ScriptMan.currentLine);
-
- return 0;
-}
-
-int kShowActor(ActionCommand *cmd) {
- uint32 actorIndex = 0;
-
- if (cmd->param1 == -1)
- ;//actorIndex = Shared.getScene()->getWorldStats()->playerActor;
- else
- actorIndex = cmd->param1;
-
- if ((actorIndex >= 0) && (actorIndex < Shared.getScene()->worldstats()->numActors))
- Shared.getScene()->getActor()->visible(true);
- else
- debugC(kDebugLevelScripts,
- "Requested invalid actor ID:0x%02X in Scene %d Line %d.",
- cmd->param1,
- Shared.getScene()->getSceneIndex(),
- ScriptMan.currentLine);
-
- return 0;
-}
-
-int kSetActorStats(ActionCommand *cmd) {
- WorldStats *ws = Shared.getScene()->worldstats();
-
- // TODO
- // param1 == actorIndex. Implement when we've got more than one actor
-
- // TODO This needs to be depreciated, but it's setting the actor's x/y
- // and bounding rect top/left.
- // This needs to be rolled into the proper place
- Shared.getScene()->getActor()->setPosition(cmd->param2, cmd->param3);
-
- Shared.getScene()->getActor()->setPosition_40A260(cmd->param2, cmd->param3, cmd->param4, cmd->param5);
-
- // XXX Returning -1 since the setPosition logic isn't fully implemented
- return -1;
-}
-
-int kSetSceneMotionStat(ActionCommand *cmd) {
- Shared.getScene()->worldstats()->motionStatus = cmd->param1;
-
- return 0;
-}
-
-int kDisableActor(ActionCommand *cmd) {
- int actorIndex = 0;
-
- if (cmd->param1 == -1)
- ;//actorIndex = Shared.getScene()->getWorldStats()->playerActor;
- else
- actorIndex = cmd->param1;
-
- // TODO Finish implementing this function
- Shared.getScene()->getActor()->update_4072A0(actorIndex);
-
- return -1;
-}
-
-int kEnableActor(ActionCommand *cmd) {
- int actorIndex = 0;
-
- if (cmd->param1 == -1)
- ;//actorIndex = Shared.getScene()->getWorldStats()->playerActor;
- else
- actorIndex = cmd->param1;
-
- if (Shared.getScene()->worldstats()->actors[actorIndex].field_40 == 5)
- ScriptMan.enableActorSub(actorIndex, 4);
-
- return 0;
-}
-
-int kEnableBarriers(ActionCommand *cmd) {
- int barIdx = Shared.getScene()->worldstats()->getBarrierIndexById(cmd->param1);
- uint32 sndIdx = cmd->param3;
- uint32 v59 = cmd->param2;
-
- if (!ScriptMan.getScript()->counter && Shared.getScene()->getSceneIndex() != 13 && sndIdx != 0) {
- ResourcePack *sfx = new ResourcePack(18);
- Shared.getSound()->playSfx(sfx, ((unsigned int)(sndIdx != 0) & 5) + 0x80120001);
- delete sfx;
- //Shared.getSound()->playSfx(Shared.getScene()->getSpeechPack(),sndIdx + 86);
- }
-
- if (ScriptMan.getScript()->counter >= 3 * v59 - 1) {
- ScriptMan.getScript()->counter = 0;
- Shared.getScene()->worldstats()->barriers[barIdx].field_67C = 0;
- ScriptMan.processActionListSub02(ScriptMan.getScript(), cmd, 2);
- ScriptMan.currentLoops = 1; // v4 = 1;
- } else {
- int v64;
- int v62 = ScriptMan.getScript()->counter + 1;
- ScriptMan.getScript()->counter = v62;
- if (sndIdx) {
- v64 = 1;
- int v170 = 3 - v62 / v59;
- Shared.getScene()->worldstats()->barriers[barIdx].field_67C = v170;
- } else {
- v64 = 0;
- Shared.getScene()->worldstats()->barriers[barIdx].field_67C = v62 / v59 + 1;
- }
-
- ScriptMan.processActionListSub02(ScriptMan.getScript(), cmd, v64);
- }
-
- return -1;
-}
-
-int kReturn(ActionCommand *cmd) {
- ScriptMan.done = true;
- ScriptMan.lineIncrement = 0;
-
- return 0;
-}
-
-int kDestroyBarrier(ActionCommand *cmd) {
- Barrier *barrier = Shared.getScene()->worldstats()->getBarrierById(cmd->param1);
-
- if (barrier) {
- barrier->flags &= 0xFFFFFFFE;
- barrier->flags |= 0x20000;
- Shared.getScreen()->deleteGraphicFromQueue(barrier->resId);
- } else
- debugC(kDebugLevelScripts,
- "Requested invalid object ID:0x%02X in Scene %d Line %d.",
- cmd->param1,
- Shared.getScene()->getSceneIndex(),
- ScriptMan.currentLine);
-
- return 0;
-}
-
-int k_unk12_JMP_WALK_ACTOR(ActionCommand *cmd) {
- return -2;
-}
-int k_unk13_JMP_WALK_ACTOR(ActionCommand *cmd) {
- return -2;
-}
-int k_unk14_JMP_WALK_ACTOR(ActionCommand *cmd) {
- return -2;
-}
-int k_unk15(ActionCommand *cmd) {
- return -2;
-}
-
-int kResetAnimation(ActionCommand *cmd) {
- Barrier *barrier = Shared.getScene()->worldstats()->getBarrierById(cmd->param1);
-
- if ((barrier->flags & 0x10000) == 0)
- barrier->frameIdx = 0;
- else
- barrier->frameIdx = barrier->frameCount - 1;
-
- return 0;
-}
-
-int kClearFlag1Bit0(ActionCommand *cmd) {
- Barrier *barrier = Shared.getScene()->worldstats()->getBarrierById(cmd->param1);
-
- barrier->flags &= 0xFFFFFFFE;
-
- return 0;
-}
-
-int k_unk18_PLAY_SND(ActionCommand *cmd) {
- return -2;
-}
-
-int kJumpIfFlag2Bit0(ActionCommand *cmd) {
- int targetType = cmd->param2;
-
- return 0;
-
- // TODO targetType == 7 is trying to access an out of bounds actor
- // look at the disassembly again
-
- if (targetType <= 0)
- ScriptMan.done = (Shared.getScene()->worldstats()->getBarrierById(cmd->param1)->flags2 & 1) == 0;
- else
- if (targetType == 1) // v4 == 1, so 1
- ScriptMan.done = (Shared.getScene()->worldstats()->getActionAreaById(cmd->param1)->actionType & 1) == 0;
- else
- ScriptMan.done = (Shared.getScene()->worldstats()->actors[cmd->param1].flags2 & 1) == 0;
-
- return -1;
-}
-
-int kSetFlag2Bit0(ActionCommand *cmd) {
- int targetType = cmd->param2;
-
- if (targetType == 2)
- Shared.getScene()->worldstats()->actors[cmd->param1].flags2 |= 1;
- else
- if (targetType == 1)
- Shared.getScene()->worldstats()->getActionAreaById(cmd->param1)->actionType |= 1;
- else
- Shared.getScene()->worldstats()->getBarrierById(cmd->param1)->flags2 |= 1;
-
- return 0;
-}
-
-int kClearFlag2Bit0(ActionCommand *cmd) {
- return -2;
-}
-int kJumpIfFlag2Bit2(ActionCommand *cmd) {
- return -2;
-}
-int kSetFlag2Bit2(ActionCommand *cmd) {
- return -2;
-}
-int kClearFlag2Bit2(ActionCommand *cmd) {
- return -2;
-}
-int kJumpIfFlag2Bit1(ActionCommand *cmd) {
- return -2;
-}
-int kSetFlag2Bit1(ActionCommand *cmd) {
- return -2;
-}
-int kClearFlag2Bit1(ActionCommand *cmd) {
- return -2;
-}
-int k_unk22(ActionCommand *cmd) {
- return -2;
-}
-int k_unk23(ActionCommand *cmd) {
- return -2;
-}
-int k_unk24(ActionCommand *cmd) {
- return -2;
-}
-int kRunEncounter(ActionCommand *cmd) {
- return -2;
-}
-int kJumpIfFlag2Bit4(ActionCommand *cmd) {
- return -2;
-}
-int kSetFlag2Bit4(ActionCommand *cmd) {
- return -2;
-}
-int kClearFlag2Bit4(ActionCommand *cmd) {
- return -2;
-}
-int kSetActorField638(ActionCommand *cmd) {
- return -2;
-}
-int kJumpIfActorField638(ActionCommand *cmd) {
- return -2;
-}
-
-int kChangeScene(ActionCommand *cmd) {
- ScriptMan.delayedSceneIndex = cmd->param1 + 4;
- debug(kDebugLevelScripts,
- "Queueing Scene Change to scene %d...",
- ScriptMan.delayedSceneIndex);
-
- return 0;
-}
-
-int k_unk2C_ActorSub(ActionCommand *cmd) {
- return -2;
-}
-
-int kPlayMovie(ActionCommand *cmd) {
- // TODO: add missing code here
- ScriptMan.delayedVideoIndex = cmd->param1;
-
- return -1;
-}
-
-int kStopAllBarriersSounds(ActionCommand *cmd) {
- // TODO: do this for all barriers that have sfx playing
- Shared.getSound()->stopSfx();
-
- return -1;
-}
-
-int kSetActionFlag01(ActionCommand *cmd) {
- return -2;
-}
-int kClearActionFlag01(ActionCommand *cmd) {
- return -2;
-}
-int kResetSceneRect(ActionCommand *cmd) {
- return -2;
-}
-int kChangeMusicById(ActionCommand *cmd) {
- return -2;
-}
-
-int kStopMusic(ActionCommand *cmd) {
- Shared.getSound()->stopMusic();
-
- return 0;
-}
-
-int k_unk34_Status(ActionCommand *cmd) {
- if (cmd->param1 >= 2) {
- cmd->param1 = 0;
- } else {
- cmd->param1++;
- ScriptMan.lineIncrement = 1;
- }
-
- return 0;
-}
-
-int k_unk35(ActionCommand *cmd) {
- return -2;
-}
-int k_unk36(ActionCommand *cmd) {
- return -2;
-}
-
-int kRunBlowUpPuzzle(ActionCommand *cmd) {
- // FIXME: improve this to call other blowUpPuzzles than VCR
- //int puzzleIdx = cmd->param1;
-
- Shared.getScene()->setBlowUpPuzzle(new BlowUpPuzzleVCR());
- Shared.getScene()->getBlowUpPuzzle()->openBlowUp();
-
- return -1;
-}
-
-int kJumpIfFlag2Bit3(ActionCommand *cmd) {
- return -2;
-}
-int kSetFlag2Bit3(ActionCommand *cmd) {
- return -2;
-}
-int kClearFlag2Bit3(ActionCommand *cmd) {
- return -2;
-}
-int k_unk3B_PALETTE_MOD(ActionCommand *cmd) {
- return -2;
-}
-
-int k_unk3C_CMP_VAL(ActionCommand *cmd) {
- if (cmd->param1) {
- if (cmd->param2 >= cmd->param1) {
- cmd->param2 = 0;
- } else {
- cmd->param2++;
- ScriptMan.lineIncrement = 1;
- }
- }
-
- return 0;
-}
-
-int kWaitUntilFramePlayed(ActionCommand *cmd) {
- Barrier *barrier = Shared.getScene()->worldstats()->getBarrierById(cmd->param1);
-
- if (barrier) {
- uint32 frameNum = 0;
- if (cmd->param2 == -1)
- frameNum = barrier->frameCount - 1;
- else
- frameNum = cmd->param2;
-
- if (barrier->frameIdx < frameNum) {
- ScriptMan.lineIncrement = 0;
- ScriptMan.waitCycle = true;
- }
- } else
- debugC(kDebugLevelScripts,
- "Requested invalid object ID:0x%02X in Scene %d Line %d.",
- cmd->param1,
- Shared.getScene()->getSceneIndex(),
- ScriptMan.currentLine);
-
- return 0;
-}
-
-int kUpdateWideScreen(ActionCommand *cmd) {
- int barSize = cmd->param1;
-
- if (barSize >= 22) {
- cmd->param1 = 0;
- } else {
- Shared.getScreen()->drawWideScreen(4 * barSize);
- cmd->param1++;
- }
-
- return 0;
-}
-
-int k_unk3F(ActionCommand *cmd) {
- return -2;
-}
-int k_unk40_SOUND(ActionCommand *cmd) {
- return -2;
-}
-
-int kPlaySpeech(ActionCommand *cmd) {
- //TODO - Add support for other param options
- uint32 sndIdx = cmd->param1;
-
- if ((int)sndIdx >= 0) {
- if (sndIdx >= 259) {
- sndIdx -= 9;
- Shared.getSound()->playSfx(Shared.getScene()->getSpeechPack(), sndIdx - 0x7FFD0000);
- } else {
- Shared.getSound()->playSfx(Shared.getScene()->getSpeechPack(), sndIdx);
- }
- } else
- debugC(kDebugLevelScripts,
- "Requested invalid sound ID:0x%02X in Scene %d Line %d.",
- cmd->param1,
- Shared.getScene()->getSceneIndex(),
- ScriptMan.currentLine);
-
- return -1;
-}
-
-int k_unk42(ActionCommand *cmd) {
- return -2;
-}
-int k_unk43(ActionCommand *cmd) {
- return -2;
-}
-int kPaletteFade(ActionCommand *cmd) {
- return -2;
-}
-int kStartPaletteFadeThread(ActionCommand *cmd) {
- return -2;
-}
-int k_unk46(ActionCommand *cmd) {
- return -2;
-}
-
-int kActorFaceObject(ActionCommand *cmd) {
- // XXX
- // Dropping param1, since it's the character index
- // Investigate further if/when we have a scene with
- // multiple characters in the actor[] array
- Shared.getScene()->getActor()->faceTarget(cmd->param2, cmd->param3);
-
- return -1;
-}
-
-int k_unk48_MATTE_01(ActionCommand *cmd) {
- return -2;
-}
-int k_unk49_MATTE_90(ActionCommand *cmd) {
- return -2;
-}
-int kJumpIfSoundPlaying(ActionCommand *cmd) {
- return -2;
-}
-int kChangePlayerCharacterIndex(ActionCommand *cmd) {
- return -2;
-}
-
-int kChangeActorField40(ActionCommand *cmd) {
- // TODO: figure out what is this field and what values are set
- int actorIdx = cmd->param1;
- int fieldType = cmd->param2;
-
- if (fieldType) {
- if (Shared.getScene()->worldstats()->actors[actorIdx].field_40 < 11)
- Shared.getScene()->worldstats()->actors[actorIdx].field_40 = 14;
- } else {
- Shared.getScene()->worldstats()->actors[actorIdx].field_40 = 4;
- }
-
- return -1;
-}
-
-int kStopSound(ActionCommand *cmd) {
- return -2;
-}
-int k_unk4E_RANDOM_COMMAND(ActionCommand *cmd) {
- return -2;
-}
-
-int kClearScreen(ActionCommand *cmd) {
- if (cmd->param1)
- Shared.getScreen()->clearScreen();
-
- return 0;
-}
-
-int kQuit(ActionCommand *cmd) {
- return -2;
-}
-
-int kJumpBarrierFrame(ActionCommand *cmd) {
- Barrier *barrier = Shared.getScene()->worldstats()->getBarrierById(cmd->param1);
-
- if (cmd->param2 == -1)
- cmd->param2 = barrier->frameCount - 1;
-
- if (cmd->param3 && cmd->param2 == barrier->frameIdx) {
- //break;
- } else if (cmd->param4 && cmd->param2 < barrier->frameIdx) {
- //break;
- } else if (cmd->param5 && cmd->param2 > barrier->frameIdx) {
- //break;
- } else if (cmd->param6 && cmd->param2 <= barrier->frameIdx) {
- //break;
- } else if (cmd->param7 && cmd->param2 >= barrier->frameIdx) {
- //break;
- } else if (cmd->param8 && cmd->param2 != barrier->frameIdx) {
- //break;
- }
-
- ActionCommand *nextCmd = &ScriptMan.getScript()->commands[cmd->param9];
-
- // 0x10 == kReturn
- if (nextCmd->opcode != 0x10 && nextCmd->opcode)
- ScriptMan.done = true;
-
- return 0;
-}
-
-int k_unk52(ActionCommand *cmd) {
- return -2;
-}
-int k_unk53(ActionCommand *cmd) {
- return -2;
-}
-
-int k_unk54_SET_ACTIONLIST_6EC(ActionCommand *cmd) {
- if (cmd->param2)
- ScriptMan.getScript()->field_1BB0 = rand() % cmd->param1;
- else
- ScriptMan.getScript()->field_1BB0 = cmd->param1;
-
- return 0;
-}
-
-int k_unk55(ActionCommand *cmd) {
- // TODO
- /*
- if (!cmd->param2) {
- if (cmd->param3 && ScriptMan.getScript()->field_1BB0 < cmd->param1)
- //break;
- else if (cmd->param4 && ScriptMan.getScript()->field_1BB0 > cmd->param1)
- //break;
- else if (cmd->param5 && ScriptMan.getScript()->field_1BB0 <= cmd->param1)
- //break;
- else if (cmd->param6 && ScriptMan.getScript()->field_1BB0 >= cmd->param1)
- //break;
- else if (cmd->param7 && ScriptMan.getScript()->field_1BB0 != cmd->param1)
- //break;
- } else if(ScriptMan.getScript()->field_1BB0 == cmd->param1) {
- //break;
- }
- */
-
- ActionCommand *nextCmd = &ScriptMan.getScript()->commands[cmd->param8];
-
- if (nextCmd->opcode != 0x10 && nextCmd->opcode)
- ScriptMan.done = true;
- else
- ScriptMan.lineIncrement = cmd->param8;
-
- return -1;
-}
-
-int k_unk56(ActionCommand *cmd) {
- return -2;
-}
-
-int kSetResourcePalette(ActionCommand *cmd) {
- if (cmd->param1 > 0)
- Shared.getScreen()->setPalette(Shared.getScene()->getResourcePack(), Shared.getScene()->worldstats()->grResId[cmd->param1]);
-
- return 0;
-}
-
-int kSetBarrierFrameIdxFlaged(ActionCommand *cmd) {
- Barrier *barrier = Shared.getScene()->worldstats()->getBarrierById(cmd->param1);
-
- if (cmd->param3)
- barrier->flags = 1 | barrier->flags;
- else
- barrier->flags = barrier->flags & 0xFFFFFFFE;
-
- barrier->frameIdx = cmd->param2;
-
- return 0;
-}
-
-int k_unk59(ActionCommand *cmd) {
- return -2;
-}
-int k_unk5A(ActionCommand *cmd) {
- return -2;
-}
-int k_unk5B(ActionCommand *cmd) {
- return -2;
-}
-int k_unk5C(ActionCommand *cmd) {
- return -2;
-}
-int k_unk5D(ActionCommand *cmd) {
- return -2;
-}
-int k_unk5E(ActionCommand *cmd) {
- return -2;
-}
-
-int kSetBarrierLastFrameIdx(ActionCommand *cmd) {
- Barrier *barrier = Shared.getScene()->worldstats()->getBarrierById(cmd->param1);
-
- if (barrier->frameIdx == barrier->frameCount - 1) {
- ScriptMan.lineIncrement = 0;
- barrier->flags &= 0xFFFEF1C7;
- } else {
- ScriptMan.lineIncrement = 1;
- }
-
- return 0;
-}
-
-int k_unk60_SET_OR_CLR_ACTIONAREA_FLAG(ActionCommand *cmd) {
- return -2;
-}
-
-int k_unk61(ActionCommand *cmd) {
- if (cmd->param2) {
- if (Shared.getScene()->worldstats()->field_E860C == -1) {
- ScriptMan.lineIncrement = 0;
- cmd->param2 = 0;
- } else {
- ScriptMan.lineIncrement = 1;
- }
- } else {
- // TODO: do something for scene number 9
- cmd->param2 = 1;
- ScriptMan.lineIncrement = 1;
- }
-
- return -1;
-}
-
-int k_unk62_SHOW_OPTIONS_SCREEN(ActionCommand *cmd) {
- return -2;
-}
-int k_unk63(ActionCommand *cmd) {
- return -2;
-}
-
-} // end of namespace Asylum
diff --git a/engines/asylum/scriptman.h b/engines/asylum/scriptman.h
deleted file mode 100644
index 22a1f3c6f0..0000000000
--- a/engines/asylum/scriptman.h
+++ /dev/null
@@ -1,186 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * $URL$
- * $Id$
- */
-
-#ifndef ASYLUM_SCRIPTMANAGER_H_
-#define ASYLUM_SCRIPTMANAGER_H_
-
-#include "common/singleton.h"
-
-#include "asylum/scene.h"
-
-namespace Asylum {
-
-class ActionList;
-struct ActionDefinitions;
-struct ActionCommand;
-class WorldStats;
-
-class ScriptManager: public Common::Singleton<ScriptManager> {
-public:
-
- int processActionList();
-
- void setScript(ActionDefinitions *action);
- void setScriptIndex(uint32 index);
- ActionDefinitions* getScript() { return _currentScript; }
-
- int checkBarrierFlags(int barrierId);
- int setBarrierNextFrame(int barrierId, int barrierFlags);
-
- void processActionListSub02(ActionDefinitions* script, ActionCommand* command, int a4);
- void enableActorSub(int actorIndex, int condition);
-
- // FIXME
- // Made all the internal control variables public and removed the getter/setter
- // pairs for simplicity. This should be refactored later, once the function mapping
- // is cleaned up properly
- int currentLine;
- int currentLoops;
- int delayedSceneIndex;
- int delayedVideoIndex;
- bool allowInput;
- bool processing;
- int lineIncrement;
- bool done;
- bool waitCycle;
-
-private:
- friend class Common::Singleton<SingletonBaseType>;
- ScriptManager();
- ~ScriptManager();
-
- ActionDefinitions *_currentScript;
-
- friend class Console;
-
-}; // end of class ScriptManager
-
-// opcode functions
-int kReturn0(ActionCommand *cmd);
-int kSetGameFlag(ActionCommand *cmd);
-int kClearGameFlag(ActionCommand *cmd);
-int kToggleGameFlag(ActionCommand *cmd);
-int kJumpIfGameFlag(ActionCommand *cmd);
-int kHideCursor(ActionCommand *cmd);
-int kShowCursor(ActionCommand *cmd);
-int kPlayAnimation(ActionCommand *cmd);
-int kMoveScenePosition(ActionCommand *cmd);
-int kHideActor(ActionCommand *cmd);
-int kShowActor(ActionCommand *cmd);
-int kSetActorStats(ActionCommand *cmd);
-int kSetSceneMotionStat(ActionCommand *cmd);
-int kDisableActor(ActionCommand *cmd);
-int kEnableActor(ActionCommand *cmd);
-int kEnableBarriers(ActionCommand *cmd);
-int kReturn(ActionCommand *cmd);
-int kDestroyBarrier(ActionCommand *cmd);
-int k_unk12_JMP_WALK_ACTOR(ActionCommand *cmd);
-int k_unk13_JMP_WALK_ACTOR(ActionCommand *cmd);
-int k_unk14_JMP_WALK_ACTOR(ActionCommand *cmd);
-int k_unk15(ActionCommand *cmd);
-int kResetAnimation(ActionCommand *cmd);
-int kClearFlag1Bit0(ActionCommand *cmd);
-int k_unk18_PLAY_SND(ActionCommand *cmd);
-int kJumpIfFlag2Bit0(ActionCommand *cmd);
-int kSetFlag2Bit0(ActionCommand *cmd);
-int kClearFlag2Bit0(ActionCommand *cmd);
-int kJumpIfFlag2Bit2(ActionCommand *cmd);
-int kSetFlag2Bit2(ActionCommand *cmd);
-int kClearFlag2Bit2(ActionCommand *cmd);
-int kJumpIfFlag2Bit1(ActionCommand *cmd);
-int kSetFlag2Bit1(ActionCommand *cmd);
-int kClearFlag2Bit1(ActionCommand *cmd);
-int k_unk22(ActionCommand *cmd);
-int k_unk23(ActionCommand *cmd);
-int k_unk24(ActionCommand *cmd);
-int kRunEncounter(ActionCommand *cmd);
-int kJumpIfFlag2Bit4(ActionCommand *cmd);
-int kSetFlag2Bit4(ActionCommand *cmd);
-int kClearFlag2Bit4(ActionCommand *cmd);
-int kSetActorField638(ActionCommand *cmd);
-int kJumpIfActorField638(ActionCommand *cmd);
-int kChangeScene(ActionCommand *cmd);
-int k_unk2C_ActorSub(ActionCommand *cmd);
-int kPlayMovie(ActionCommand *cmd);
-int kStopAllBarriersSounds(ActionCommand *cmd);
-int kSetActionFlag01(ActionCommand *cmd);
-int kClearActionFlag01(ActionCommand *cmd);
-int kResetSceneRect(ActionCommand *cmd);
-int kChangeMusicById(ActionCommand *cmd);
-int kStopMusic(ActionCommand *cmd);
-int k_unk34_Status(ActionCommand *cmd);
-int k_unk35(ActionCommand *cmd);
-int k_unk36(ActionCommand *cmd);
-int kRunBlowUpPuzzle(ActionCommand *cmd);
-int kJumpIfFlag2Bit3(ActionCommand *cmd);
-int kSetFlag2Bit3(ActionCommand *cmd);
-int kClearFlag2Bit3(ActionCommand *cmd);
-int k_unk3B_PALETTE_MOD(ActionCommand *cmd);
-int k_unk3C_CMP_VAL(ActionCommand *cmd);
-int kWaitUntilFramePlayed(ActionCommand *cmd);
-int kUpdateWideScreen(ActionCommand *cmd);
-int k_unk3F(ActionCommand *cmd);
-int k_unk40_SOUND(ActionCommand *cmd);
-int kPlaySpeech(ActionCommand *cmd);
-int k_unk42(ActionCommand *cmd);
-int k_unk43(ActionCommand *cmd);
-int kPaletteFade(ActionCommand *cmd);
-int kStartPaletteFadeThread(ActionCommand *cmd);
-int k_unk46(ActionCommand *cmd);
-int kActorFaceObject(ActionCommand *cmd);
-int k_unk48_MATTE_01(ActionCommand *cmd);
-int k_unk49_MATTE_90(ActionCommand *cmd);
-int kJumpIfSoundPlaying(ActionCommand *cmd);
-int kChangePlayerCharacterIndex(ActionCommand *cmd);
-int kChangeActorField40(ActionCommand *cmd);
-int kStopSound(ActionCommand *cmd);
-int k_unk4E_RANDOM_COMMAND(ActionCommand *cmd);
-int kClearScreen(ActionCommand *cmd);
-int kQuit(ActionCommand *cmd);
-int kJumpBarrierFrame(ActionCommand *cmd);
-int k_unk52(ActionCommand *cmd);
-int k_unk53(ActionCommand *cmd);
-int k_unk54_SET_ACTIONLIST_6EC(ActionCommand *cmd);
-int k_unk55(ActionCommand *cmd);
-int k_unk56(ActionCommand *cmd);
-int kSetResourcePalette(ActionCommand *cmd);
-int kSetBarrierFrameIdxFlaged(ActionCommand *cmd);
-int k_unk59(ActionCommand *cmd);
-int k_unk5A(ActionCommand *cmd);
-int k_unk5B(ActionCommand *cmd);
-int k_unk5C(ActionCommand *cmd);
-int k_unk5D(ActionCommand *cmd);
-int k_unk5E(ActionCommand *cmd);
-int kSetBarrierLastFrameIdx(ActionCommand *cmd);
-int k_unk60_SET_OR_CLR_ACTIONAREA_FLAG(ActionCommand *cmd);
-int k_unk61(ActionCommand *cmd);
-int k_unk62_SHOW_OPTIONS_SCREEN(ActionCommand *cmd);
-int k_unk63(ActionCommand *cmd);
-
-
-#define ScriptMan (::Asylum::ScriptManager::instance())
-
-} // end of namespace Asylum
-
-#endif
Commit: 4caee427b7913dd6ad03540f1549ca3a8f28c356
https://github.com/scummvm/scummvm/commit/4caee427b7913dd6ad03540f1549ca3a8f28c356
Author: Alex Bevilacqua (alexbevi at gmail.com)
Date: 2021-05-17T15:35:48+02:00
Commit Message:
ASYLUM: removed the flag assignment to 183 (process_action_list) from the scene constructor
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@349 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/scene.cpp
diff --git a/engines/asylum/scene.cpp b/engines/asylum/scene.cpp
index 07719e9d3f..247572dfcf 100644
--- a/engines/asylum/scene.cpp
+++ b/engines/asylum/scene.cpp
@@ -97,8 +97,6 @@ Scene::Scene(uint8 sceneIdx) {
g_debugPolygons = 0;
g_debugBarriers = 0;
- Shared.setGameFlag(183);
-
// TODO: do all the rest stuffs in sub at address 40E460
_playerActorIdx = 0;
Commit: 4c01ffb9e33b1ba29d817b0baf11d2c6121e12f2
https://github.com/scummvm/scummvm/commit/4c01ffb9e33b1ba29d817b0baf11d2c6121e12f2
Author: Alex Bevilacqua (alexbevi at gmail.com)
Date: 2021-05-17T15:35:48+02:00
Commit Message:
ASYLUM: moved the checkFlags() and setNextFrame() methods that relate directly to barriers into the barrier class (off of the actionlist)
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@350 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/actionlist.cpp
engines/asylum/actionlist.h
engines/asylum/barrier.cpp
engines/asylum/barrier.h
diff --git a/engines/asylum/actionlist.cpp b/engines/asylum/actionlist.cpp
index 78fe3ef30d..d57adcbff6 100644
--- a/engines/asylum/actionlist.cpp
+++ b/engines/asylum/actionlist.cpp
@@ -180,27 +180,6 @@ void ActionList::setScriptByIndex(uint32 index) {
}
}
-int ActionList::checkBarrierFlags(int barrierId) {
- int flags = _scene->worldstats()->getBarrierById(barrierId)->flags;
- return flags & 1 && (flags & 8 || flags & 0x10000);
-}
-
-int ActionList::setBarrierNextFrame(int barrierId, int barrierFlags) {
- int barrierIndex = _scene->worldstats()->getBarrierIndexById(barrierId);
-
- Barrier *barrier = _scene->worldstats()->getBarrierByIndex(barrierIndex);
- int newFlag = barrierFlags | 1 | barrier->flags;
- barrier->flags |= barrierFlags | 1;
-
- if (newFlag & 0x10000) {
- barrier->frameIdx = barrier->frameCount - 1;
- } else {
- barrier->frameIdx = 0;
- }
-
- return barrierIndex;
-}
-
void ActionList::processActionListSub02(ActionDefinitions* script, ActionCommand *command, int a4) {
int v4 = 0;
int result;
@@ -433,19 +412,18 @@ int kShowCursor(ActionCommand *cmd, Scene *scn) {
}
int kPlayAnimation(ActionCommand *cmd, Scene *scn) {
- int barrierId = cmd->param1;
+ int barrierId = cmd->param1;
+ int barrierIndex = scn->worldstats()->getBarrierIndexById(barrierId);
+ Barrier *barrier = scn->worldstats()->getBarrierByIndex(barrierIndex);
if (cmd->param2 == 2) {
- if (!scn->actions()->checkBarrierFlags(barrierId)) {
+ if (!barrier->checkFlags()) {
cmd->param2 = 1;
// FIXME Not sure why this break was here
// break;
}
scn->actions()->lineIncrement = 1;
} else {
- int barrierIndex = scn->worldstats()->getBarrierIndexById(barrierId);
- Barrier *barrier = scn->worldstats()->getBarrierByIndex(barrierIndex);
-
if (cmd->param4) { // RECHECK THIS
int newBarriedIndex = 213 * barrierIndex;
barrier->flags &= 0xFFFEF1C7;
@@ -466,7 +444,7 @@ int kPlayAnimation(ActionCommand *cmd, Scene *scn) {
}
}
- scn->actions()->setBarrierNextFrame(barrierId, barrier->flags);
+ barrier->setNextFrame(barrier->flags);
if(barrier->field_688 == 1) {
// TODO: get barrier position
diff --git a/engines/asylum/actionlist.h b/engines/asylum/actionlist.h
index 454049f6a4..50f1b07f06 100644
--- a/engines/asylum/actionlist.h
+++ b/engines/asylum/actionlist.h
@@ -88,9 +88,6 @@ public:
ActionDefinitions* getScript() { return _currentScript; }
int process();
- int checkBarrierFlags(int barrierId);
- int setBarrierNextFrame(int barrierId, int barrierFlags);
-
void processActionListSub02(ActionDefinitions* script, ActionCommand* command, int a4);
void enableActorSub(int actorIndex, int condition);
diff --git a/engines/asylum/barrier.cpp b/engines/asylum/barrier.cpp
index 93f230df33..867196f66d 100644
--- a/engines/asylum/barrier.cpp
+++ b/engines/asylum/barrier.cpp
@@ -80,4 +80,18 @@ bool Barrier::onscreen() {
return visible() && (flags & 1) && screenRect.intersects(barrierRect);
}
+int Barrier::checkFlags() {
+ return flags & 1 && (flags & 8 || flags & 0x10000);
+}
+
+void Barrier::setNextFrame(int targetFlags) {
+ int newFlag = targetFlags | 1 | flags;
+ flags |= targetFlags | 1;
+
+ if (newFlag & 0x10000)
+ frameIdx = frameCount - 1;
+ else
+ frameIdx = 0;
+}
+
} // end of namespace Asylum
diff --git a/engines/asylum/barrier.h b/engines/asylum/barrier.h
index 76f91643c8..e215e7ca6a 100644
--- a/engines/asylum/barrier.h
+++ b/engines/asylum/barrier.h
@@ -39,6 +39,11 @@ public:
uint32 getRandomId(); // TODO Give this a better name?
bool onscreen();
+ // TODO document this function
+ int checkFlags();
+ // TODO document this function
+ void setNextFrame(int flags);
+
uint32 id;
uint32 resId;
uint32 x;
Commit: badb49ed6d624f4b75d22b1da91d30a31b5be191
https://github.com/scummvm/scummvm/commit/badb49ed6d624f4b75d22b1da91d30a31b5be191
Author: Alex Bevilacqua (alexbevi at gmail.com)
Date: 2021-05-17T15:35:48+02:00
Commit Message:
ASYLUM: Moved the gameflags from SharedResources to the AsylumEngine. Also removed the OSystem member from the SharedResources (slowly phasing out the last singleton)
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@351 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/actionlist.cpp
engines/asylum/asylum.cpp
engines/asylum/asylum.h
engines/asylum/barrier.cpp
engines/asylum/console.cpp
engines/asylum/scene.cpp
engines/asylum/scene.h
engines/asylum/shared.cpp
engines/asylum/shared.h
diff --git a/engines/asylum/actionlist.cpp b/engines/asylum/actionlist.cpp
index d57adcbff6..b6fc86dede 100644
--- a/engines/asylum/actionlist.cpp
+++ b/engines/asylum/actionlist.cpp
@@ -303,7 +303,7 @@ int ActionList::process() {
// XXX
// gameFlag 183 is the same as the
// processing flag, but is not being used
- Shared.clearGameFlag(183);
+ _scene->vm()->clearGameFlag(183);
}
}
@@ -359,7 +359,7 @@ int kSetGameFlag(ActionCommand *cmd, Scene *scn) {
int flagNum = cmd->param1;
if (flagNum >= 0)
- Shared.setGameFlag(flagNum);
+ scn->vm()->setGameFlag(flagNum);
return 0;
}
@@ -368,7 +368,7 @@ int kClearGameFlag(ActionCommand *cmd, Scene *scn) {
int flagNum = cmd->param1;
if (flagNum >= 0)
- Shared.clearGameFlag(flagNum);
+ scn->vm()->clearGameFlag(flagNum);
return 0;
}
@@ -377,7 +377,7 @@ int kToggleGameFlag(ActionCommand *cmd, Scene *scn) {
int flagNum = cmd->param1;
if (flagNum >= 0)
- Shared.toggleGameFlag(flagNum);
+ scn->vm()->toggleGameFlag(flagNum);
return 0;
}
@@ -386,9 +386,9 @@ int kJumpIfGameFlag(ActionCommand *cmd, Scene *scn) {
int flagNum = cmd->param1;
if (flagNum) {
- bool doJump = Shared.isGameFlagSet(flagNum);
+ bool doJump = scn->vm()->isGameFlagSet(flagNum);
if (cmd->param2)
- doJump = Shared.isGameFlagNotSet(flagNum);
+ doJump = scn->vm()->isGameFlagNotSet(flagNum);
if (doJump)
scn->actions()->currentLine = cmd->param3;
}
diff --git a/engines/asylum/asylum.cpp b/engines/asylum/asylum.cpp
index 1236651f38..fd31c2751d 100644
--- a/engines/asylum/asylum.cpp
+++ b/engines/asylum/asylum.cpp
@@ -53,6 +53,8 @@ AsylumEngine::AsylumEngine(OSystem *system, Common::Language language)
Common::File::addDefaultDirectory(_gameDataDir.getChild("Music"));
g_eventRec.registerRandomSource(_rnd, "asylum");
+
+ memset(_gameFlags, 0, 1512);
}
AsylumEngine::~AsylumEngine() {
@@ -65,6 +67,8 @@ AsylumEngine::~AsylumEngine() {
delete _sound;
delete _screen;
delete _encounter;
+
+ free(_gameFlags);
}
Common::Error AsylumEngine::run() {
@@ -86,7 +90,6 @@ Common::Error AsylumEngine::init() {
_mainMenu = 0;
_scene = 0;
- Shared.setOSystem(_system);
Shared.setScreen(_screen);
Shared.setSound(_sound);
Shared.setVideo(_video);
@@ -103,7 +106,7 @@ Common::Error AsylumEngine::go() {
// TODO: if savegame exists on folder, than start NewGame()
// Set up the game's main scene
- _scene = new Scene(5);
+ _scene = new Scene(5, this);
Shared.setScene(_scene);
// XXX This is just here for testing purposes. It is also defined
@@ -130,8 +133,8 @@ Common::Error AsylumEngine::go() {
//playIntro();
// Enter first scene
- Shared.setGameFlag(4);
- Shared.setGameFlag(12);
+ setGameFlag(4);
+ setGameFlag(12);
_scene->enterScene();
while (!shouldQuit()) {
@@ -160,8 +163,8 @@ void AsylumEngine::playIntro() {
_screen->clearScreen();
- Shared.setGameFlag(4);
- Shared.setGameFlag(12);
+ setGameFlag(4);
+ setGameFlag(12);
ResourcePack *introRes = new ResourcePack(18);
@@ -282,7 +285,7 @@ void AsylumEngine::processDelayedEvents() {
if (_scene)
delete _scene;
- _scene = new Scene(sceneIdx);
+ _scene = new Scene(sceneIdx, this);
Shared.setScene(_scene);
_scene->enterScene();
@@ -291,4 +294,25 @@ void AsylumEngine::processDelayedEvents() {
}
}
+void AsylumEngine::setGameFlag(int flag) {
+ _gameFlags[flag / 32] |= 1 << flag % -32;
+}
+
+void AsylumEngine::clearGameFlag(int flag) {
+ _gameFlags[flag / 32] &= ~(1 << flag % -32);
+}
+
+void AsylumEngine::toggleGameFlag(int flag) {
+ _gameFlags[flag / 32] ^= 1 << flag % -32;
+}
+
+bool AsylumEngine::isGameFlagSet(int flag) {
+ return ((1 << flag % -32) & (unsigned int)_gameFlags[flag / 32]) >> flag % -32 != 0;
+}
+
+bool AsylumEngine::isGameFlagNotSet(int flag) {
+ return ((1 << flag % -32) & (unsigned int)_gameFlags[flag / 32]) >> flag % -32 == 0;
+}
+
+
} // namespace Asylum
diff --git a/engines/asylum/asylum.h b/engines/asylum/asylum.h
index fbac27601b..3f49a6d0d4 100644
--- a/engines/asylum/asylum.h
+++ b/engines/asylum/asylum.h
@@ -72,6 +72,12 @@ public:
virtual Common::Error run();
virtual bool hasFeature(EngineFeature f) const;
+ void setGameFlag(int flag);
+ void clearGameFlag(int flag);
+ void toggleGameFlag(int flag);
+ bool isGameFlagSet(int flag);
+ bool isGameFlagNotSet(int flag);
+
private:
void checkForEvent(bool doUpdate);
void waitForTimer(int msec_delay);
@@ -92,6 +98,8 @@ private:
Video *_video;
Encounter *_encounter;
+ int _gameFlags[1512];
+
friend class Console;
};
diff --git a/engines/asylum/barrier.cpp b/engines/asylum/barrier.cpp
index 867196f66d..c697a6cf80 100644
--- a/engines/asylum/barrier.cpp
+++ b/engines/asylum/barrier.cpp
@@ -44,9 +44,9 @@ bool Barrier::visible() {
uint32 flag = gameFlags[f];
if (flag <= 0)
- isSet = Shared.isGameFlagNotSet(flag); // -flag
+ isSet = Shared.getScene()->vm()->isGameFlagNotSet(flag); // -flag
else
- isSet = Shared.isGameFlagSet(flag);
+ isSet = Shared.getScene()->vm()->isGameFlagSet(flag);
if(!isSet)
return false;
diff --git a/engines/asylum/console.cpp b/engines/asylum/console.cpp
index 19244901c2..4a2113e374 100644
--- a/engines/asylum/console.cpp
+++ b/engines/asylum/console.cpp
@@ -93,7 +93,7 @@ void Console::printActionAreaStats(ActionArea *a) {
bool Console::cmdShowFlags(int argc, const char **argv) {
for (int i = 0; i < 1512; i++) {
- if (Shared.isGameFlagSet(i)) {
+ if (_vm->isGameFlagSet(i)) {
DebugPrintf("Game Flag %d is Active\n", i);
}
}
@@ -106,8 +106,8 @@ bool Console::cmdToggleFlag(int argc, const char **argv) {
DebugPrintf("Enter a value between 0 and 1512\n");
return true;
}
- Shared.toggleGameFlag(atoi(argv[1]));
- DebugPrintf("Flag %d == %d\n", atoi(argv[1]), Shared.isGameFlagSet(atoi(argv[1])));
+ _vm->toggleGameFlag(atoi(argv[1]));
+ DebugPrintf("Flag %d == %d\n", atoi(argv[1]), _vm->isGameFlagSet(atoi(argv[1])));
return true;
}
diff --git a/engines/asylum/scene.cpp b/engines/asylum/scene.cpp
index 247572dfcf..52aa0f07bb 100644
--- a/engines/asylum/scene.cpp
+++ b/engines/asylum/scene.cpp
@@ -35,7 +35,7 @@ namespace Asylum {
int g_debugPolygons;
int g_debugBarriers;
-Scene::Scene(uint8 sceneIdx) {
+Scene::Scene(uint8 sceneIdx, AsylumEngine *vm): _vm(vm) {
_sceneIdx = sceneIdx;
char filename[10];
@@ -228,39 +228,39 @@ int Scene::updateScene() {
WorldStats *worldStats = _ws;
// Mouse
- startTick = Shared.getMillis();
+ startTick = _vm->_system->getMillis();
updateMouse();
- debugC(kDebugLevelScene, "UpdateMouse Time: %d", Shared.getMillis() - startTick);
+ debugC(kDebugLevelScene, "UpdateMouse Time: %d", _vm->_system->getMillis() - startTick);
// Actors
- startTick = Shared.getMillis();
+ startTick = _vm->_system->getMillis();
for (uint32 a = 0; a < worldStats->numActors; a++)
updateActor(a);
- debugC(kDebugLevelScene, "UpdateActors Time: %d", Shared.getMillis() - startTick);
+ debugC(kDebugLevelScene, "UpdateActors Time: %d", _vm->_system->getMillis() - startTick);
// Barriers
- startTick = Shared.getMillis();
+ startTick = _vm->_system->getMillis();
updateBarriers(worldStats);
- debugC(kDebugLevelScene, "UpdateBarriers Time: %d", Shared.getMillis() - startTick);
+ debugC(kDebugLevelScene, "UpdateBarriers Time: %d", _vm->_system->getMillis() - startTick);
// Ambient Sounds
- startTick = Shared.getMillis();
+ startTick = _vm->_system->getMillis();
updateAmbientSounds();
- debugC(kDebugLevelScene, "UpdateAmbientSounds Time: %d", Shared.getMillis() - startTick);
+ debugC(kDebugLevelScene, "UpdateAmbientSounds Time: %d", _vm->_system->getMillis() - startTick);
// Music
- startTick = Shared.getMillis();
+ startTick = _vm->_system->getMillis();
updateMusic();
- debugC(kDebugLevelScene, "UpdateMusic Time: %d", Shared.getMillis() - startTick);
+ debugC(kDebugLevelScene, "UpdateMusic Time: %d", _vm->_system->getMillis() - startTick);
// Adjust Screen
- //startTick = Shared.getMillis();
+ //startTick = _vm->_system->getMillis();
// FIXME
// Commented out the (incomplete) update screen code because once the
// actor's x1/y1 values are properly set, the temp code causes a crash
// Have to finish implementing the method I guess :P
//updateAdjustScreen();
- //debugC(kDebugLevelScene, "AdjustScreenStart Time: %d", Shared.getMillis() - startTick);
+ //debugC(kDebugLevelScene, "AdjustScreenStart Time: %d", _vm->_system->getMillis() - startTick);
if(_actions->process())
return 1;
@@ -447,11 +447,11 @@ void Scene::updateActor(uint32 actorIdx) {
uint32 frameNum = actor->frameNum + 1;
actor->frameNum = frameNum % actor->frameCount;
- if (Shared.getMillis() - actor->tickValue1 > 300) {
+ if (_vm->_system->getMillis() - actor->tickValue1 > 300) {
if (rand() % 100 < 50) {
// TODO: check sound playing
}
- actor->tickValue1 = Shared.getMillis();
+ actor->tickValue1 = _vm->_system->getMillis();
}
}
break;
@@ -517,9 +517,9 @@ void Scene::updateBarriers(WorldStats *worldStats) {
if (barrier->visible()) {
uint32 flag = barrier->flags;
if (flag & 0x20) {
- if (barrier->field_B4 && (Shared.getMillis() - barrier->tickCount >= 0x3E8 / barrier->field_B4)) {
+ if (barrier->field_B4 && (_vm->_system->getMillis() - barrier->tickCount >= 0x3E8 / barrier->field_B4)) {
barrier->frameIdx = (barrier->frameIdx + 1) % barrier->frameCount;
- barrier->tickCount = Shared.getMillis();
+ barrier->tickCount = _vm->_system->getMillis();
canPlaySound = true;
}
} else if (flag & 0x10) {
@@ -527,7 +527,7 @@ void Scene::updateBarriers(WorldStats *worldStats) {
char equalZero = frameIdx == 0;
char lessZero = frameIdx < 0;
if (!frameIdx) {
- if (Shared.getMillis() - barrier->tickCount >= 1000 * barrier->tickCount2) {
+ if (_vm->_system->getMillis() - barrier->tickCount >= 1000 * barrier->tickCount2) {
if (rand() % barrier->field_C0 == 1) {
if (barrier->field_68C[0]) {
// TODO: fix this, and find a better way to get frame count
@@ -540,7 +540,7 @@ void Scene::updateBarriers(WorldStats *worldStats) {
}
barrier->frameIdx++;
}
- barrier->tickCount = Shared.getMillis();
+ barrier->tickCount = _vm->_system->getMillis();
canPlaySound = true;
}
frameIdx = barrier->frameIdx;
@@ -550,15 +550,15 @@ void Scene::updateBarriers(WorldStats *worldStats) {
if (!(lessZero ^ 0 | equalZero)) {
// FIXME: we shouldn't increment field_B4 (check why this value came zero sometimes)
- if (barrier->field_B4 && (Shared.getMillis() - barrier->tickCount >= 0x3E8 / barrier->field_B4)) {
+ if (barrier->field_B4 && (_vm->_system->getMillis() - barrier->tickCount >= 0x3E8 / barrier->field_B4)) {
barrier->frameIdx = (barrier->frameIdx + 1) % barrier->frameCount;
- barrier->tickCount = Shared.getMillis();
+ barrier->tickCount = _vm->_system->getMillis();
canPlaySound = true;
}
}
} else if (flag & 8) {
// FIXME: we shouldn't increment field_B4 (check why this value came zero sometimes)
- if (barrier->field_B4 && (Shared.getMillis() - barrier->tickCount >= 0x3E8 / barrier->field_B4)) {
+ if (barrier->field_B4 && (_vm->_system->getMillis() - barrier->tickCount >= 0x3E8 / barrier->field_B4)) {
uint32 frameIdx = barrier->frameIdx + 1;
if (frameIdx < barrier->frameCount - 1) {
if (barrier->field_688 == 1) {
@@ -573,30 +573,30 @@ void Scene::updateBarriers(WorldStats *worldStats) {
barrier->frameIdx = frameIdx;
}
} else if ((flag & 0xFF) & 8) { // check this
- if (Shared.getMillis() - barrier->tickCount >= 1000 * barrier->tickCount2) {
+ if (_vm->_system->getMillis() - barrier->tickCount >= 1000 * barrier->tickCount2) {
if (rand() % barrier->field_C0 == 1) { // TODO: THIS ISNT WORKING
barrier->frameIdx = (barrier->frameIdx + 1) % barrier->frameCount;
- barrier->tickCount = Shared.getMillis();
+ barrier->tickCount = _vm->_system->getMillis();
canPlaySound = true;
}
}
} else if (!((flag & 0xFFFF) & 6)) {
// FIXME: we shouldn't increment field_B4 (check why this value came zero sometimes)
- if (barrier->field_B4 && (Shared.getMillis() - barrier->tickCount >= 0x3E8 / barrier->field_B4) && (flag & 0x10000)) {
+ if (barrier->field_B4 && (_vm->_system->getMillis() - barrier->tickCount >= 0x3E8 / barrier->field_B4) && (flag & 0x10000)) {
uint32 frameIdx = barrier->frameIdx - 1;
if (frameIdx <= 0) {
barrier->flags &= 0xFFFEFFFF;
if (barrier->field_688 == 1) {
// TODO: reset global x, y positions
}
- barrier->tickCount = Shared.getMillis();
+ barrier->tickCount = _vm->_system->getMillis();
canPlaySound = true;
}
if (barrier->field_688 == 1) {
// TODO: get global x, y positions
}
barrier->frameIdx = frameIdx;
- } else if (barrier->field_B4 && (Shared.getMillis() - barrier->tickCount >= 0x3E8 / barrier->field_B4)) {
+ } else if (barrier->field_B4 && (_vm->_system->getMillis() - barrier->tickCount >= 0x3E8 / barrier->field_B4)) {
if ((flag & 0xFF) & 2) {
if (barrier->frameIdx == barrier->frameCount - 1) {
barrier->frameIdx--;
diff --git a/engines/asylum/scene.h b/engines/asylum/scene.h
index 14baf713c2..63cd2d55dd 100644
--- a/engines/asylum/scene.h
+++ b/engines/asylum/scene.h
@@ -52,7 +52,7 @@ struct BarrierItem;
class Scene {
public:
- Scene(uint8 sceneIdx);
+ Scene(uint8 sceneIdx, AsylumEngine *vm);
~Scene();
void handleEvent(Common::Event *event, bool doUpdate);
@@ -75,15 +75,17 @@ public:
void setBlowUpPuzzle(BlowUpPuzzle* puzzle) { _blowUp = puzzle; }
void setScenePosition(int x, int y);
- WorldStats* worldstats() { return _ws; }
- Polygons* polygons() { return _polygons; }
- ActionList* actions() { return _actions; }
+ AsylumEngine* vm() { return _vm; }
+ WorldStats* worldstats() { return _ws; }
+ Polygons* polygons() { return _polygons; }
+ ActionList* actions() { return _actions; }
private:
- uint8 _sceneIdx;
- WorldStats *_ws;
- Polygons *_polygons;
- ActionList *_actions;
+ AsylumEngine *_vm;
+ uint8 _sceneIdx;
+ WorldStats *_ws;
+ Polygons *_polygons;
+ ActionList *_actions;
Cursor *_cursor;
ResourcePack *_resPack;
diff --git a/engines/asylum/shared.cpp b/engines/asylum/shared.cpp
index 10512d1e41..7761b2a85f 100644
--- a/engines/asylum/shared.cpp
+++ b/engines/asylum/shared.cpp
@@ -37,7 +37,7 @@ SharedResources::SharedResources() {
if (!g_initialized) {
g_initialized = true;
}
- memset(_gameFlags, 0, 1512);
+
}
SharedResources::~SharedResources() {
@@ -130,24 +130,4 @@ int SharedResources::getAngle(int x1, int y1, int x2, int y2) {
return result;
}
-void SharedResources::setGameFlag(int flag) {
- _gameFlags[flag / 32] |= 1 << flag % -32;
-}
-
-void SharedResources::clearGameFlag(int flag) {
- _gameFlags[flag / 32] &= ~(1 << flag % -32);
-}
-
-void SharedResources::toggleGameFlag(int flag) {
- _gameFlags[flag / 32] ^= 1 << flag % -32;
-}
-
-bool SharedResources::isGameFlagSet(int flag) {
- return ((1 << flag % -32) & (unsigned int)_gameFlags[flag / 32]) >> flag % -32 != 0;
-}
-
-bool SharedResources::isGameFlagNotSet(int flag) {
- return ((1 << flag % -32) & (unsigned int)_gameFlags[flag / 32]) >> flag % -32 == 0;
-}
-
} // end of namespace Asylum
diff --git a/engines/asylum/shared.h b/engines/asylum/shared.h
index f4dbf5f702..d7f2dd0221 100644
--- a/engines/asylum/shared.h
+++ b/engines/asylum/shared.h
@@ -51,9 +51,6 @@ class Sound;
class SharedResources: public Common::Singleton<SharedResources> {
public:
- void setOSystem(OSystem* system) { _system = system; }
- uint32 getMillis() { return _system->getMillis(); }
-
void setVideo(Video* video) { _video = video; }
Video* getVideo() { return _video; }
@@ -68,25 +65,16 @@ public:
int getAngle(int x1, int y1, int x2, int y2);
- void setGameFlag(int flag);
- void clearGameFlag(int flag);
- void toggleGameFlag(int flag);
- bool isGameFlagSet(int flag);
- bool isGameFlagNotSet(int flag);
-
private:
friend class Common::Singleton<SingletonBaseType>;
SharedResources();
~SharedResources();
- OSystem *_system;
Video *_video;
Screen *_screen;
Sound *_sound;
Scene *_scene;
- int _gameFlags[1512];
-
}; // end of class SharedResources
// Angle Tables used by getAngle()
Commit: 9868f8c40a98dfc08457f0564a7317b15396ced3
https://github.com/scummvm/scummvm/commit/9868f8c40a98dfc08457f0564a7317b15396ced3
Author: Alex Bevilacqua (alexbevi at gmail.com)
Date: 2021-05-17T15:35:49+02:00
Commit Message:
ASYLUM: oops (fixed: *** glibc detected *** /home/alex/workspaces/cpp/scummvm/scummvm: double free or corruption (out): 0x093a2668 ***)
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@352 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/asylum.cpp
diff --git a/engines/asylum/asylum.cpp b/engines/asylum/asylum.cpp
index fd31c2751d..6fba8cfee7 100644
--- a/engines/asylum/asylum.cpp
+++ b/engines/asylum/asylum.cpp
@@ -67,8 +67,6 @@ AsylumEngine::~AsylumEngine() {
delete _sound;
delete _screen;
delete _encounter;
-
- free(_gameFlags);
}
Common::Error AsylumEngine::run() {
Commit: 9f39977ddd0d772ea3d52108e0a58adce2077b1c
https://github.com/scummvm/scummvm/commit/9f39977ddd0d772ea3d52108e0a58adce2077b1c
Author: Alex Bevilacqua (alexbevi at gmail.com)
Date: 2021-05-17T15:35:49+02:00
Commit Message:
ASYLUM: Removed Video reference from Shared
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@353 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/actionlist.cpp
engines/asylum/asylum.cpp
engines/asylum/asylum.h
engines/asylum/blowuppuzzle.cpp
engines/asylum/blowuppuzzle.h
engines/asylum/shared.h
diff --git a/engines/asylum/actionlist.cpp b/engines/asylum/actionlist.cpp
index b6fc86dede..92529eb8bf 100644
--- a/engines/asylum/actionlist.cpp
+++ b/engines/asylum/actionlist.cpp
@@ -850,7 +850,7 @@ int kRunBlowUpPuzzle(ActionCommand *cmd, Scene *scn) {
// FIXME: improve this to call other blowUpPuzzles than VCR
//int puzzleIdx = cmd->param1;
- scn->setBlowUpPuzzle(new BlowUpPuzzleVCR());
+ scn->setBlowUpPuzzle(new BlowUpPuzzleVCR(scn));
scn->getBlowUpPuzzle()->openBlowUp();
return -1;
diff --git a/engines/asylum/asylum.cpp b/engines/asylum/asylum.cpp
index 6fba8cfee7..0e32f0d14d 100644
--- a/engines/asylum/asylum.cpp
+++ b/engines/asylum/asylum.cpp
@@ -90,7 +90,6 @@ Common::Error AsylumEngine::init() {
Shared.setScreen(_screen);
Shared.setSound(_sound);
- Shared.setVideo(_video);
_introPlaying = false;
@@ -111,7 +110,7 @@ Common::Error AsylumEngine::go() {
// in the processActionList() method when the necessary action is fired.
// Once the blowup puzzle testing is removed from checkForEvent(), this
// can be removed as well.
- _scene->setBlowUpPuzzle(new BlowUpPuzzleVCR()); // this will be done by a Script command
+ _scene->setBlowUpPuzzle(new BlowUpPuzzleVCR(_scene));
// XXX This can probably also be rolled into the scene constructor.
// Investigate if this will fuck up the execution sequence though :P
diff --git a/engines/asylum/asylum.h b/engines/asylum/asylum.h
index 3f49a6d0d4..9a1bd6e949 100644
--- a/engines/asylum/asylum.h
+++ b/engines/asylum/asylum.h
@@ -78,6 +78,8 @@ public:
bool isGameFlagSet(int flag);
bool isGameFlagNotSet(int flag);
+ Video* video(){ return _video; }
+
private:
void checkForEvent(bool doUpdate);
void waitForTimer(int msec_delay);
diff --git a/engines/asylum/blowuppuzzle.cpp b/engines/asylum/blowuppuzzle.cpp
index 7422fc52d4..3605d62f25 100644
--- a/engines/asylum/blowuppuzzle.cpp
+++ b/engines/asylum/blowuppuzzle.cpp
@@ -30,7 +30,7 @@
namespace Asylum {
-BlowUpPuzzle::BlowUpPuzzle() {
+BlowUpPuzzle::BlowUpPuzzle(Scene *scene): _scene(scene) {
}
BlowUpPuzzle::~BlowUpPuzzle() {
@@ -38,7 +38,7 @@ BlowUpPuzzle::~BlowUpPuzzle() {
// BlowUp Puzzle VCR ---------------------------------------------------------------------------------------------
-BlowUpPuzzleVCR::BlowUpPuzzleVCR() {
+BlowUpPuzzleVCR::BlowUpPuzzleVCR(Scene *scene): BlowUpPuzzle(scene) {
_leftClickUp = false;
_leftClickDown = false;
_rightClickDown = false;
@@ -165,7 +165,7 @@ void BlowUpPuzzleVCR::update() {
// TODO: fade palette to grey
- Shared.getVideo()->playVideo(2, kSubtitlesOn);
+ _scene->vm()->video()->playVideo(2, kSubtitlesOn);
_isAccomplished = false;
_active = false;
diff --git a/engines/asylum/blowuppuzzle.h b/engines/asylum/blowuppuzzle.h
index 55a58330c4..ada5988d75 100644
--- a/engines/asylum/blowuppuzzle.h
+++ b/engines/asylum/blowuppuzzle.h
@@ -45,7 +45,7 @@ struct GraphicQueueItem;
class BlowUpPuzzle {
public:
- BlowUpPuzzle();
+ BlowUpPuzzle(Scene *scene);
virtual ~BlowUpPuzzle();
virtual void handleEvent(Common::Event *event, bool doUpdate){};
@@ -56,6 +56,7 @@ public:
protected:
Common::Event *_ev;
+ Scene *_scene;
Cursor *_cursor;
bool _leftClickUp;
bool _leftClickDown;
@@ -92,7 +93,7 @@ const Common::Rect BlowUpPuzzleVCRPolies[10] = {
class BlowUpPuzzleVCR : public BlowUpPuzzle {
public:
- BlowUpPuzzleVCR();
+ BlowUpPuzzleVCR(Scene *scene);
~BlowUpPuzzleVCR();
void handleEvent(Common::Event *event, bool doUpdate);
diff --git a/engines/asylum/shared.h b/engines/asylum/shared.h
index d7f2dd0221..e7929f2b2e 100644
--- a/engines/asylum/shared.h
+++ b/engines/asylum/shared.h
@@ -32,7 +32,6 @@
namespace Asylum {
-class Video;
class Screen;
class Sound;
@@ -50,10 +49,6 @@ class Sound;
*/
class SharedResources: public Common::Singleton<SharedResources> {
public:
-
- void setVideo(Video* video) { _video = video; }
- Video* getVideo() { return _video; }
-
void setScreen(Screen* screen) { _screen = screen; }
Screen* getScreen() { return _screen; }
@@ -70,7 +65,6 @@ private:
SharedResources();
~SharedResources();
- Video *_video;
Screen *_screen;
Sound *_sound;
Scene *_scene;
Commit: 72c1b3e3983c2661e9cbf7a7a25286a21c6c1bb9
https://github.com/scummvm/scummvm/commit/72c1b3e3983c2661e9cbf7a7a25286a21c6c1bb9
Author: Alex Bevilacqua (alexbevi at gmail.com)
Date: 2021-05-17T15:35:49+02:00
Commit Message:
ASYLUM: Removed Sound reference from Shared
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@354 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/actionlist.cpp
engines/asylum/asylum.cpp
engines/asylum/asylum.h
engines/asylum/blowuppuzzle.cpp
engines/asylum/menu.cpp
engines/asylum/menu.h
engines/asylum/scene.cpp
engines/asylum/shared.h
diff --git a/engines/asylum/actionlist.cpp b/engines/asylum/actionlist.cpp
index 92529eb8bf..1a0b70756c 100644
--- a/engines/asylum/actionlist.cpp
+++ b/engines/asylum/actionlist.cpp
@@ -611,9 +611,9 @@ int kEnableBarriers(ActionCommand *cmd, Scene *scn) {
if (!scn->actions()->getScript()->counter && scn->getSceneIndex() != 13 && sndIdx != 0) {
ResourcePack *sfx = new ResourcePack(18);
- Shared.getSound()->playSfx(sfx, ((unsigned int)(sndIdx != 0) & 5) + 0x80120001);
+ scn->vm()->sound()->playSfx(sfx, ((unsigned int)(sndIdx != 0) & 5) + 0x80120001);
delete sfx;
- //Shared.getSound()->playSfx(scn->getSpeechPack(),sndIdx + 86);
+ //scn->vm()->sound()->playSfx(scn->getSpeechPack(),sndIdx + 86);
}
if (scn->actions()->getScript()->counter >= 3 * v59 - 1) {
@@ -804,7 +804,7 @@ int kPlayMovie(ActionCommand *cmd, Scene *scn) {
int kStopAllBarriersSounds(ActionCommand *cmd, Scene *scn) {
// TODO: do this for all barriers that have sfx playing
- Shared.getSound()->stopSfx();
+ scn->vm()->sound()->stopSfx();
return -1;
}
@@ -823,7 +823,7 @@ int kChangeMusicById(ActionCommand *cmd, Scene *scn) {
}
int kStopMusic(ActionCommand *cmd, Scene *scn) {
- Shared.getSound()->stopMusic();
+ scn->vm()->sound()->stopMusic();
return 0;
}
@@ -933,9 +933,9 @@ int kPlaySpeech(ActionCommand *cmd, Scene *scn) {
if ((int)sndIdx >= 0) {
if (sndIdx >= 259) {
sndIdx -= 9;
- Shared.getSound()->playSfx(scn->getSpeechPack(), sndIdx - 0x7FFD0000);
+ scn->vm()->sound()->playSfx(scn->getSpeechPack(), sndIdx - 0x7FFD0000);
} else {
- Shared.getSound()->playSfx(scn->getSpeechPack(), sndIdx);
+ scn->vm()->sound()->playSfx(scn->getSpeechPack(), sndIdx);
}
} else
debugC(kDebugLevelScripts,
diff --git a/engines/asylum/asylum.cpp b/engines/asylum/asylum.cpp
index 0e32f0d14d..70802e4987 100644
--- a/engines/asylum/asylum.cpp
+++ b/engines/asylum/asylum.cpp
@@ -89,7 +89,6 @@ Common::Error AsylumEngine::init() {
_scene = 0;
Shared.setScreen(_screen);
- Shared.setSound(_sound);
_introPlaying = false;
@@ -117,7 +116,7 @@ Common::Error AsylumEngine::go() {
_scene->actions()->setScriptByIndex(_scene->worldstats()->actionListIdx);
// Set up main menu
- _mainMenu = new MainMenu();
+ _mainMenu = new MainMenu(this);
// XXX Testing
_encounter = new Encounter(_scene);
diff --git a/engines/asylum/asylum.h b/engines/asylum/asylum.h
index 9a1bd6e949..6879377f22 100644
--- a/engines/asylum/asylum.h
+++ b/engines/asylum/asylum.h
@@ -78,7 +78,8 @@ public:
bool isGameFlagSet(int flag);
bool isGameFlagNotSet(int flag);
- Video* video(){ return _video; }
+ Video* video() { return _video; }
+ Sound* sound() { return _sound; }
private:
void checkForEvent(bool doUpdate);
diff --git a/engines/asylum/blowuppuzzle.cpp b/engines/asylum/blowuppuzzle.cpp
index 3605d62f25..71120fc449 100644
--- a/engines/asylum/blowuppuzzle.cpp
+++ b/engines/asylum/blowuppuzzle.cpp
@@ -43,12 +43,12 @@ BlowUpPuzzleVCR::BlowUpPuzzleVCR(Scene *scene): BlowUpPuzzle(scene) {
_leftClickDown = false;
_rightClickDown = false;
_active = false;
- _bgResource = Shared.getScene()->getGraphicResource(Shared.getScene()->worldstats()->grResId[0]);
+ _bgResource = _scene->getGraphicResource(_scene->worldstats()->grResId[0]);
_tvScreenAnimIdx = 0;
_isAccomplished = false;
// setup cursor
- _cursor = new Cursor(Shared.getScene()->getResourcePack());
+ _cursor = new Cursor(_scene->getResourcePack());
// reset all states
memset(&_jacksState,0,sizeof(_jacksState));
@@ -63,19 +63,19 @@ BlowUpPuzzleVCR::~BlowUpPuzzleVCR() {
void BlowUpPuzzleVCR::openBlowUp() {
_active = true;
- Shared.getScene()->deactivate();
+ _scene->deactivate();
// FIXME: decomment this line when stopSfx works properly (it nows stop together SFX and Music
- //Shared.getSound()->stopSfx();
+ //_scene->vm()->sound()->stopSfx();
// Load the graphics palette
- Shared.getScreen()->setPalette(Shared.getScene()->getResourcePack(), Shared.getScene()->worldstats()->grResId[29]);
+ Shared.getScreen()->setPalette(_scene->getResourcePack(), _scene->worldstats()->grResId[29]);
// show blow up puzzle BG
GraphicFrame *bg = _bgResource->getFrame(0);
Shared.getScreen()->copyToBackBuffer((byte *)bg->surface.pixels, bg->surface.w, 0, 0, bg->surface.w, bg->surface.h);
// Set mouse cursor
- _cursor->load(Shared.getScene()->worldstats()->grResId[28]);
+ _cursor->load(_scene->worldstats()->grResId[28]);
_cursor->show();
_leftClickUp = false;
@@ -85,7 +85,7 @@ void BlowUpPuzzleVCR::openBlowUp() {
void BlowUpPuzzleVCR::closeBlowUp() {
_active = false;
- Shared.getScene()->activate();
+ _scene->activate();
}
void BlowUpPuzzleVCR::handleEvent(Common::Event *event, bool doUpdate) {
@@ -124,7 +124,7 @@ void BlowUpPuzzleVCR::update() {
_rightClickDown = false;
closeBlowUp();
// TODO: stop sound fx grResId[47] (TV On sfx)
- Shared.getScene()->enterScene();
+ _scene->enterScene();
}
if (_leftClickDown) {
@@ -149,8 +149,8 @@ void BlowUpPuzzleVCR::update() {
updateStopButton();
if(_buttonsState[kPower] == kON) {
- Shared.getScreen()->addGraphicToQueue(Shared.getScene()->worldstats()->grResId[22], _tvScreenAnimIdx, 0, 37, 0, 0, 1);
- Shared.getScreen()->addGraphicToQueue(Shared.getScene()->worldstats()->grResId[23], _tvScreenAnimIdx++, 238, 22, 0, 0, 1);
+ Shared.getScreen()->addGraphicToQueue(_scene->worldstats()->grResId[22], _tvScreenAnimIdx, 0, 37, 0, 0, 1);
+ Shared.getScreen()->addGraphicToQueue(_scene->worldstats()->grResId[23], _tvScreenAnimIdx++, 238, 22, 0, 0, 1);
_tvScreenAnimIdx %= 6;
}
@@ -169,7 +169,7 @@ void BlowUpPuzzleVCR::update() {
_isAccomplished = false;
_active = false;
- Shared.getScene()->enterScene();
+ _scene->enterScene();
} else {
Shared.getScreen()->drawGraphicsInQueue();
}
@@ -183,7 +183,7 @@ GraphicQueueItem BlowUpPuzzleVCR::getGraphicJackItem(int resId) {
jackY = 356;
}
- jackItemOnHand.resId = Shared.getScene()->worldstats()->grResId[resId];
+ jackItemOnHand.resId = _scene->worldstats()->grResId[resId];
jackItemOnHand.frameIdx = 0;
jackItemOnHand.x = _cursor->x() - 114;
jackItemOnHand.y = jackY - 14;
@@ -199,7 +199,7 @@ GraphicQueueItem BlowUpPuzzleVCR::getGraphicShadowItem() {
if(_cursor->y() < 356) {
shadowY = 0;
}
- shadowItem.resId = Shared.getScene()->worldstats()->grResId[30];
+ shadowItem.resId = _scene->worldstats()->grResId[30];
shadowItem.frameIdx = 0;
shadowItem.x = _cursor->x() - shadowY;
shadowItem.y = 450;
@@ -213,28 +213,28 @@ void BlowUpPuzzleVCR::updateJack(Jack jack, VCRDrawInfo onTable, VCRDrawInfo plu
switch(_jacksState[jack]){
case kOnTable:
- item.resId = Shared.getScene()->worldstats()->grResId[onTable.resId];
+ item.resId = _scene->worldstats()->grResId[onTable.resId];
item.frameIdx = 0;
item.x = onTable.x;
item.y = onTable.y;
item.priority = 3;
break;
case kPluggedOnRed:
- item.resId = Shared.getScene()->worldstats()->grResId[pluggedOnRed.resId];
+ item.resId = _scene->worldstats()->grResId[pluggedOnRed.resId];
item.frameIdx = 0;
item.x = 329;
item.y = 407;
item.priority = 3;
break;
case kPluggedOnYellow:
- item.resId = Shared.getScene()->worldstats()->grResId[pluggedOnYellow.resId];
+ item.resId = _scene->worldstats()->grResId[pluggedOnYellow.resId];
item.frameIdx = 0;
item.x = 402;
item.y = 413;
item.priority = 3;
break;
case kPluggedOnBlack:
- item.resId = Shared.getScene()->worldstats()->grResId[pluggedOnBlack.resId];
+ item.resId = _scene->worldstats()->grResId[pluggedOnBlack.resId];
item.frameIdx = 0;
item.x = 477;
item.y = 418;
@@ -319,13 +319,13 @@ int BlowUpPuzzleVCR::setJackOnHole(int jackType, JackState plugged) {
if(_jacksState[jackType-1] == kOnHand) {
_jacksState[jackType-1] = plugged;
_holesState[plugged-1] = jackType; // set jack on red
- Shared.getSound()->playSfx(Shared.getScene()->getResourcePack(), Shared.getScene()->worldstats()->grResId[44]);
+ _scene->vm()->sound()->playSfx(_scene->getResourcePack(), _scene->worldstats()->grResId[44]);
}
} else if(jackType == 0) {
jackType = _holesState[plugged-1];
_jacksState[jackType-1] = kOnHand;
_holesState[plugged-1] = 0;
- Shared.getSound()->playSfx(Shared.getScene()->getResourcePack(), Shared.getScene()->worldstats()->grResId[43]);
+ _scene->vm()->sound()->playSfx(_scene->getResourcePack(), _scene->worldstats()->grResId[43]);
return 0;
}
return 1;
@@ -336,7 +336,7 @@ void BlowUpPuzzleVCR::updateButton(Button button, VCRDrawInfo btON, VCRDrawInfo
switch(_buttonsState[button]){
case kON:
- item.resId = Shared.getScene()->worldstats()->grResId[btON.resId];
+ item.resId = _scene->worldstats()->grResId[btON.resId];
item.frameIdx = 0;
item.x = btON.x;
item.y = btON.y;
@@ -344,7 +344,7 @@ void BlowUpPuzzleVCR::updateButton(Button button, VCRDrawInfo btON, VCRDrawInfo
break;
case kDownON:
case kDownOFF:
- item.resId = Shared.getScene()->worldstats()->grResId[btDown.resId];
+ item.resId = _scene->worldstats()->grResId[btDown.resId];
item.frameIdx = 0;
item.x = btDown.x;
item.y = btDown.y;
@@ -504,7 +504,7 @@ void BlowUpPuzzleVCR::handleMouseDown() {
if (_cursor->x() >= (uint32)BlowUpPuzzleVCRPolies[kBlackJack].left && _cursor->x() <= (uint32)BlowUpPuzzleVCRPolies[kYellowJack].right &&
_cursor->y() >= (uint32)BlowUpPuzzleVCRPolies[kBlackJack].top && _cursor->y() <= (uint32)BlowUpPuzzleVCRPolies[kYellowJack].bottom) {
_jacksState[jackType-1] = kOnTable;
- Shared.getSound()->playSfx(Shared.getScene()->getResourcePack(), Shared.getScene()->worldstats()->grResId[50]);
+ _scene->vm()->sound()->playSfx(_scene->getResourcePack(), _scene->worldstats()->grResId[50]);
_cursor->show();
}
return;
@@ -521,7 +521,7 @@ void BlowUpPuzzleVCR::handleMouseDown() {
// TODO: VCR button regions
if (inPolyRegion(_cursor->x(), _cursor->y(), kRewindButton)) {
- Shared.getSound()->playSfx(Shared.getScene()->getResourcePack(), Shared.getScene()->worldstats()->grResId[39]);
+ _scene->vm()->sound()->playSfx(_scene->getResourcePack(), _scene->worldstats()->grResId[39]);
if(!_buttonsState[kRewind]) {
_buttonsState[kRewind] = kDownON;
return;
@@ -531,7 +531,7 @@ void BlowUpPuzzleVCR::handleMouseDown() {
return;
}
} else if (inPolyRegion(_cursor->x(), _cursor->y(), kPlayButton)) {
- Shared.getSound()->playSfx(Shared.getScene()->getResourcePack(), Shared.getScene()->worldstats()->grResId[39]);
+ _scene->vm()->sound()->playSfx(_scene->getResourcePack(), _scene->worldstats()->grResId[39]);
if(!_buttonsState[kPlay]) {
_buttonsState[kPlay] = kDownON;
return;
@@ -541,7 +541,7 @@ void BlowUpPuzzleVCR::handleMouseDown() {
return;
}
} else if (inPolyRegion(_cursor->x(), _cursor->y(), kStopButton)) {
- Shared.getSound()->playSfx(Shared.getScene()->getResourcePack(), Shared.getScene()->worldstats()->grResId[39]);
+ _scene->vm()->sound()->playSfx(_scene->getResourcePack(), _scene->worldstats()->grResId[39]);
if(_buttonsState[kStop]) {
if(_buttonsState[kStop] == kON) {
_buttonsState[kStop] = kDownOFF;
@@ -552,7 +552,7 @@ void BlowUpPuzzleVCR::handleMouseDown() {
return;
}
} else if (inPolyRegion(_cursor->x(), _cursor->y(), kPowerButton)) {
- Shared.getSound()->playSfx(Shared.getScene()->getResourcePack(), Shared.getScene()->worldstats()->grResId[39]);
+ _scene->vm()->sound()->playSfx(_scene->getResourcePack(), _scene->worldstats()->grResId[39]);
if(!_buttonsState[kPower] && _holesState[kPluggedOnBlack-1] == kBlack+1 && _holesState[kPluggedOnRed-1] && _holesState[kPluggedOnYellow-1]) {
_buttonsState[kPower] = kDownON;
@@ -568,7 +568,7 @@ void BlowUpPuzzleVCR::handleMouseUp() {
if(_buttonsState[kPower] == kDownON) {
// TODO: check if next sound is already playing
- Shared.getSound()->playSfx(Shared.getScene()->getResourcePack(), Shared.getScene()->worldstats()->grResId[47]);
+ _scene->vm()->sound()->playSfx(_scene->getResourcePack(), _scene->worldstats()->grResId[47]);
_buttonsState[kPower] = kON;
_buttonsState[kStop] = kON;
_buttonsState[kPlay] = kON;
@@ -583,7 +583,7 @@ void BlowUpPuzzleVCR::handleMouseUp() {
if(_buttonsState[kRewind] == kDownOFF) {
_buttonsState[kRewind] = kON;
- Shared.getSound()->playSfx(Shared.getScene()->getResourcePack(), Shared.getScene()->worldstats()->grResId[46]);
+ _scene->vm()->sound()->playSfx(_scene->getResourcePack(), _scene->worldstats()->grResId[46]);
} else if(_buttonsState[kRewind] == kDownON) {
_buttonsState[kRewind] = kOFF;
}
diff --git a/engines/asylum/menu.cpp b/engines/asylum/menu.cpp
index d91768f172..a745f4a6b3 100644
--- a/engines/asylum/menu.cpp
+++ b/engines/asylum/menu.cpp
@@ -33,7 +33,7 @@ namespace Asylum {
/** This fixes the menu icons text x position on screen */
const int MenuIconFixedXpos[12] = { 28, 128, 225, 320, 410, 528, 16, 115, 237, 310, 508, 419 };
-MainMenu::MainMenu() {
+MainMenu::MainMenu(AsylumEngine *vm): _vm(vm) {
_leftClick = false;
_activeIcon = -1;
_previousActiveIcon = -1;
@@ -90,11 +90,11 @@ void MainMenu::openMenu() {
_cursor->show();
// Stop all sounds
- Shared.getSound()->stopMusic();
- Shared.getSound()->stopSfx();
+ _vm->sound()->stopMusic();
+ _vm->sound()->stopSfx();
// Start playing music
- Shared.getSound()->playMusic(_resPack, 39);
+ _vm->sound()->playMusic(_resPack, 39);
_previousActiveIcon = _activeIcon = -1;
_leftClick = false;
@@ -106,8 +106,8 @@ void MainMenu::closeMenu() {
Shared.getScene()->activate();
// Stop menu sounds and menu music
- Shared.getSound()->stopSfx();
- Shared.getSound()->stopMusic();
+ _vm->sound()->stopSfx();
+ _vm->sound()->stopMusic();
}
void MainMenu::handleEvent(Common::Event *event, bool doUpdate) {
@@ -192,9 +192,9 @@ void MainMenu::update() {
// Set credits palette
Shared.getScreen()->setPalette(_resPack, 26);
// Stop all sounds
- Shared.getSound()->stopMusic();
+ _vm->sound()->stopMusic();
// Start playing music
- Shared.getSound()->playMusic(_resPack, 38);
+ _vm->sound()->playMusic(_resPack, 38);
break;
case kReturnToGame:
closeMenu();
@@ -285,8 +285,8 @@ void MainMenu::updateMainMenu() {
_text->drawResTextCentered(MenuIconFixedXpos[iconNum], iconFrame->y + 50, _text->getResTextWidth(iconNum + 1309), iconNum + 1309);
// Play creepy voice
- if (!Shared.getSound()->isSfxActive() && _activeIcon != _previousActiveIcon) {
- Shared.getSound()->playSfx(_resPack, iconNum + 44);
+ if (!_vm->sound()->isSfxActive() && _activeIcon != _previousActiveIcon) {
+ _vm->sound()->playSfx(_resPack, iconNum + 44);
_previousActiveIcon = _activeIcon;
}
@@ -611,9 +611,9 @@ void MainMenu::updateSubMenuShowCredits() {
// Restore palette
Shared.getScreen()->setPalette(_resPack, 17);
// Stop all sounds
- Shared.getSound()->stopMusic();
+ _vm->sound()->stopMusic();
// Start playing music
- Shared.getSound()->playMusic(_resPack, 39);
+ _vm->sound()->playMusic(_resPack, 39);
exitSubMenu();
}
}
diff --git a/engines/asylum/menu.h b/engines/asylum/menu.h
index 5aaac83e35..b62d764ff2 100644
--- a/engines/asylum/menu.h
+++ b/engines/asylum/menu.h
@@ -42,7 +42,7 @@ class Cursor;
class MainMenu {
public:
- MainMenu();
+ MainMenu(AsylumEngine *vm);
~MainMenu();
void handleEvent(Common::Event *event, bool doUpdate);
@@ -51,6 +51,7 @@ public:
void closeMenu();
private:
+ AsylumEngine *_vm;
enum EyesAnimation {
kEyesFront = 0,
diff --git a/engines/asylum/scene.cpp b/engines/asylum/scene.cpp
index 52aa0f07bb..68b7e09672 100644
--- a/engines/asylum/scene.cpp
+++ b/engines/asylum/scene.cpp
@@ -148,7 +148,7 @@ void Scene::enterScene() {
_cursor->show();
// Music testing: play the first music track
- Shared.getSound()->playMusic(_musPack, 0);
+ _vm->sound()->playMusic(_musPack, 0);
_isActive = true;
_walking = false;
diff --git a/engines/asylum/shared.h b/engines/asylum/shared.h
index e7929f2b2e..556c9ff82f 100644
--- a/engines/asylum/shared.h
+++ b/engines/asylum/shared.h
@@ -52,9 +52,6 @@ public:
void setScreen(Screen* screen) { _screen = screen; }
Screen* getScreen() { return _screen; }
- void setSound(Sound* sound) { _sound = sound; }
- Sound* getSound() { return _sound; }
-
void setScene(Scene* scene) { _scene = scene; }
Scene* getScene() { return _scene; }
@@ -66,7 +63,6 @@ private:
~SharedResources();
Screen *_screen;
- Sound *_sound;
Scene *_scene;
}; // end of class SharedResources
Commit: ddcb9beab262e4f1613cc29fc15804486e04fa38
https://github.com/scummvm/scummvm/commit/ddcb9beab262e4f1613cc29fc15804486e04fa38
Author: Alex Bevilacqua (alexbevi at gmail.com)
Date: 2021-05-17T15:35:49+02:00
Commit Message:
ASYLUM: Removed Shared singleton. Moved getAngle() to actor class (only place it's used so far). Added screen() and scene() getters to the engine for classes that need the references.
Moved a couple methods from the barrier class to worldstats (makes a bit more sense)
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@355 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
R engines/asylum/shared.cpp
R engines/asylum/shared.h
engines/asylum/actionlist.cpp
engines/asylum/actor.cpp
engines/asylum/actor.h
engines/asylum/asylum.cpp
engines/asylum/asylum.h
engines/asylum/barrier.cpp
engines/asylum/blowuppuzzle.cpp
engines/asylum/console.cpp
engines/asylum/menu.cpp
engines/asylum/module.mk
engines/asylum/scene.cpp
engines/asylum/scene.h
engines/asylum/screen.cpp
engines/asylum/screen.h
engines/asylum/worldstats.cpp
engines/asylum/worldstats.h
diff --git a/engines/asylum/actionlist.cpp b/engines/asylum/actionlist.cpp
index 1a0b70756c..a41d6e1de5 100644
--- a/engines/asylum/actionlist.cpp
+++ b/engines/asylum/actionlist.cpp
@@ -24,7 +24,6 @@
*/
#include "asylum/actionlist.h"
-#include "asylum/shared.h"
namespace Asylum {
@@ -653,7 +652,7 @@ int kDestroyBarrier(ActionCommand *cmd, Scene *scn) {
if (barrier) {
barrier->flags &= 0xFFFFFFFE;
barrier->flags |= 0x20000;
- Shared.getScreen()->deleteGraphicFromQueue(barrier->resId);
+ scn->vm()->screen()->deleteGraphicFromQueue(barrier->resId);
} else
debugC(kDebugLevelScripts,
"Requested invalid object ID:0x%02X in Scene %d Line %d.",
@@ -912,7 +911,7 @@ int kUpdateWideScreen(ActionCommand *cmd, Scene *scn) {
if (barSize >= 22) {
cmd->param1 = 0;
} else {
- Shared.getScreen()->drawWideScreen(4 * barSize);
+ scn->vm()->screen()->drawWideScreen(4 * barSize);
cmd->param1++;
}
@@ -1010,7 +1009,7 @@ int k_unk4E_RANDOM_COMMAND(ActionCommand *cmd, Scene *scn) {
int kClearScreen(ActionCommand *cmd, Scene *scn) {
if (cmd->param1)
- Shared.getScreen()->clearScreen();
+ scn->vm()->screen()->clearScreen();
return 0;
}
@@ -1099,7 +1098,7 @@ int k_unk56(ActionCommand *cmd, Scene *scn) {
int kSetResourcePalette(ActionCommand *cmd, Scene *scn) {
if (cmd->param1 > 0)
- Shared.getScreen()->setPalette(scn->getResourcePack(), scn->worldstats()->grResId[cmd->param1]);
+ scn->vm()->screen()->setPalette(scn->getResourcePack(), scn->worldstats()->grResId[cmd->param1]);
return 0;
}
diff --git a/engines/asylum/actor.cpp b/engines/asylum/actor.cpp
index 11e1bdfe58..3b15fcf6b0 100644
--- a/engines/asylum/actor.cpp
+++ b/engines/asylum/actor.cpp
@@ -27,7 +27,6 @@
#include "asylum/actor.h"
#include "asylum/screen.h"
-#include "asylum/shared.h"
namespace Asylum {
@@ -129,9 +128,9 @@ GraphicFrame *Actor::getFrame() {
void Actor::drawActorAt(uint16 curX, uint16 curY) {
GraphicFrame *frame = getFrame();
- WorldStats *ws = Shared.getScene()->worldstats();
+ WorldStats *ws = _scene->worldstats();
- Shared.getScreen()->copyRectToScreenWithTransparency(
+ _scene->vm()->screen()->copyRectToScreenWithTransparency(
((byte *)frame->surface.pixels),
frame->surface.w,
curX - ws->targetX,
@@ -144,9 +143,9 @@ void Actor::drawActorAt(uint16 curX, uint16 curY) {
void Actor::drawActor() {
GraphicFrame *frame = getFrame();
- WorldStats *ws = Shared.getScene()->worldstats();
+ WorldStats *ws = _scene->worldstats();
- Shared.getScreen()->copyToBackBufferWithTransparency(
+ _scene->vm()->screen()->copyToBackBufferWithTransparency(
((byte *)frame->surface.pixels),
frame->surface.w,
x - ws->targetX,
@@ -157,7 +156,7 @@ void Actor::drawActor() {
void Actor::setWalkArea(ActionArea *target) {
if (_currentWalkArea != target) {
- Shared.getScene()->actions()->setScriptByIndex(target->actionListIdx1);
+ _scene->actions()->setScriptByIndex(target->actionListIdx1);
_currentWalkArea = target;
debugC(kDebugLevelScripts, "%s", target->name);
}
@@ -165,7 +164,7 @@ void Actor::setWalkArea(ActionArea *target) {
void Actor::walkTo(uint16 curX, uint16 curY) {
int newAction = currentAction;
- WorldStats *ws = Shared.getScene()->worldstats();
+ WorldStats *ws = _scene->worldstats();
// step is the increment by which to move the
// actor in a given direction
@@ -228,7 +227,7 @@ void Actor::walkTo(uint16 curX, uint16 curY) {
rect.bottom = newY + 4;
surface.frameRect(rect, 0x33);
- Shared.getScreen()->copyRectToScreen((byte*)surface.pixels, 5, newX - ws->targetX, newY - ws->targetY, 5, 5);
+ _scene->vm()->screen()->copyRectToScreen((byte*)surface.pixels, 5, newX - ws->targetX, newY - ws->targetY, 5, 5);
surface.free();
@@ -245,7 +244,7 @@ void Actor::walkTo(uint16 curX, uint16 curY) {
for (uint32 a = 0; a < ws->numActions; a++) {
if (ws->actions[a].actionType == 0) {
area = &ws->actions[a];
- PolyDefinitions poly = Shared.getScene()->polygons()->entries[area->polyIdx];
+ PolyDefinitions poly = _scene->polygons()->entries[area->polyIdx];
if (poly.contains(x, y)) {
availableAreas[areaPtr] = a;
areaPtr++;
@@ -263,7 +262,7 @@ void Actor::walkTo(uint16 curX, uint16 curY) {
// walkable regions
for (int i = 0; i < areaPtr; i++) {
area = &ws->actions[availableAreas[i]];
- PolyDefinitions *region = &Shared.getScene()->polygons()->entries[area->polyIdx];
+ PolyDefinitions *region = &_scene->polygons()->entries[area->polyIdx];
if (region->contains(newX, newY)) {
x = newX;
y = newY;
@@ -310,14 +309,14 @@ void Actor::faceTarget(int targetId, int targetType) {
if (targetType) {
if (targetType == 1) {
- int actionIdx = Shared.getScene()->worldstats()->getActionAreaIndexById(targetId);
+ int actionIdx = _scene->worldstats()->getActionAreaIndexById(targetId);
if (actionIdx == -1) {
warning("No ActionArea found for id %d", targetId);
return;
}
- uint32 polyIdx = Shared.getScene()->worldstats()->actions[actionIdx].polyIdx;
- PolyDefinitions *poly = &Shared.getScene()->polygons()->entries[polyIdx];
+ uint32 polyIdx = _scene->worldstats()->actions[actionIdx].polyIdx;
+ PolyDefinitions *poly = &_scene->polygons()->entries[polyIdx];
newX2 = poly->boundingRect.left + (poly->boundingRect.right - poly->boundingRect.left) / 2;
newY2 = poly->boundingRect.top + (poly->boundingRect.bottom - poly->boundingRect.top) / 2;
@@ -330,13 +329,13 @@ void Actor::faceTarget(int targetId, int targetType) {
}
}
} else {
- int barrierIdx = Shared.getScene()->worldstats()->getBarrierIndexById(targetId);
+ int barrierIdx = _scene->worldstats()->getBarrierIndexById(targetId);
if (barrierIdx == -1) {
warning("No Barrier found for id %d", targetId);
return;
}
- Barrier *barrier = Shared.getScene()->worldstats()->getBarrierByIndex(barrierIdx);
+ Barrier *barrier = _scene->worldstats()->getBarrierByIndex(barrierIdx);
GraphicResource *gra = new GraphicResource(_resPack, barrier->resId);
// FIXME
@@ -354,11 +353,97 @@ void Actor::faceTarget(int targetId, int targetType) {
newY2 = (fra->surface.h >> 1) + barrier->y; // Check .text:004088A2 for more details
}
- int newAngle = Shared.getAngle(x2 + x1, y2 + y1, newX2, newY2);
+ int newAngle = getAngle(x2 + x1, y2 + y1, newX2, newY2);
printf("Angle calculated as %d\n", newAngle);
setDirection(newAngle);
}
+int Actor::getAngle(int ax1, int ay1, int ax2, int ay2) {
+ uint32 v5 = (ax2 << 16) - (ax1 << 16);
+ int v6 = 0;
+ int v4 = (ay1 << 16) - (ay2 << 16);
+
+ if (v5 < 0) {
+ v6 = 2;
+ v5 = -v5;
+ }
+
+ if (v4 < 0) {
+ v6 |= 1;
+ v4 = -v4;
+ }
+
+ int v7;
+ int v8 = -1;
+
+ if (v5) {
+ v7 = (v4 << 8) / v5;
+
+ if (v7 < 0x100)
+ v8 = angleTable01[v7];
+ if (v7 < 0x1000 && v8 < 0)
+ v8 = angleTable02[v7 >> 4];
+ if (v7 < 0x10000 && v8 < 0)
+ v8 = angleTable03[v7 >> 8];
+ } else {
+ v8 = 90;
+ }
+
+ switch (v6) {
+ case 1:
+ v8 = 360 - v8;
+ break;
+ case 2:
+ v8 = 180 - v8;
+ break;
+ case 3:
+ v8 += 180;
+ break;
+ }
+
+ if (v8 >= 360)
+ v8 -= 360;
+
+ int result;
+
+ if (v8 < 157 || v8 >= 202) {
+ if (v8 < 112 || v8 >= 157) {
+ if (v8 < 67 || v8 >= 112) {
+ if (v8 < 22 || v8 >= 67) {
+ if ((v8 < 0 || v8 >= 22) && (v8 < 337 || v8 > 359)) {
+ if (v8 < 292 || v8 >= 337) {
+ if (v8 < 247 || v8 >= 292) {
+ if (v8 < 202 || v8 >= 247) {
+ error("getAngle returned a bad angle: %d.", v8);
+ result = ax1;
+ } else {
+ result = 3;
+ }
+ } else {
+ result = 4;
+ }
+ } else {
+ result = 5;
+ }
+ } else {
+ result = 6;
+ }
+ } else {
+ result = 7;
+ }
+ } else {
+ result = 0;
+ }
+ } else {
+ result = 1;
+ }
+ } else {
+ result = 2;
+ }
+
+ return result;
+}
+
} // end of namespace Asylum
diff --git a/engines/asylum/actor.h b/engines/asylum/actor.h
index 9e07ff2b12..af8e72c778 100644
--- a/engines/asylum/actor.h
+++ b/engines/asylum/actor.h
@@ -31,6 +31,7 @@
namespace Asylum {
+class Scene;
class Screen;
struct ActionArea;
@@ -157,6 +158,10 @@ public:
// I don't really like how this is used in the scene constructor
void setResourcePack(ResourcePack *res) { _resPack = res; }
+ // XXX Hack to get a reference to the parent scene
+ // into the actor instance
+ void setScene(Scene *scene) { _scene = scene; }
+
// OLD METHODS
// TODO ALL of these need to be depreciated in favour
// of the proper functions from the original
@@ -222,15 +227,75 @@ public:
// TODO field_980 till field_9A0
private:
+ Scene *_scene;
ResourcePack *_resPack;
GraphicResource *_graphic;
uint32 _resources[61];
ActionArea *_currentWalkArea;
GraphicFrame *getFrame();
+ int getAngle(int ax1, int ay1, int ax2, int ay2);
}; // end of class MainActor
+// Angle Tables used by getAngle()
+const uint8 angleTable01[256] = {
+ 0x00,0x00,0x00,0x01,0x01,0x01,0x01,0x02,0x02,0x02,0x02,0x02,0x03,0x03,0x03,0x03,
+ 0x04,0x04,0x04,0x04,0x04,0x05,0x05,0x05,0x05,0x06,0x06,0x06,0x06,0x06,0x07,0x07,
+ 0x07,0x07,0x08,0x08,0x08,0x08,0x08,0x09,0x09,0x09,0x09,0x0A,0x0A,0x0A,0x0A,0x0A,
+ 0x0B,0x0B,0x0B,0x0B,0x0B,0x0C,0x0C,0x0C,0x0C,0x0D,0x0D,0x0D,0x0D,0x0D,0x0E,0x0E,
+ 0x0E,0x0E,0x0E,0x0F,0x0F,0x0F,0x0F,0x10,0x10,0x10,0x10,0x10,0x11,0x11,0x11,0x11,
+ 0x11,0x12,0x12,0x12,0x12,0x12,0x13,0x13,0x13,0x13,0x13,0x14,0x14,0x14,0x14,0x14,
+ 0x15,0x15,0x15,0x15,0x15,0x16,0x16,0x16,0x16,0x16,0x16,0x17,0x17,0x17,0x17,0x17,
+ 0x18,0x18,0x18,0x18,0x18,0x19,0x19,0x19,0x19,0x19,0x19,0x1A,0x1A,0x1A,0x1A,0x1A,
+ 0x1B,0x1B,0x1B,0x1B,0x1B,0x1B,0x1C,0x1C,0x1C,0x1C,0x1C,0x1D,0x1D,0x1D,0x1D,0x1D,
+ 0x1D,0x1E,0x1E,0x1E,0x1E,0x1E,0x1E,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x20,0x20,0x20,
+ 0x20,0x20,0x20,0x20,0x21,0x21,0x21,0x21,0x21,0x21,0x22,0x22,0x22,0x22,0x22,0x22,
+ 0x23,0x23,0x23,0x23,0x23,0x23,0x23,0x24,0x24,0x24,0x24,0x24,0x24,0x24,0x25,0x25,
+ 0x25,0x25,0x25,0x25,0x25,0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x27,0x27,0x27,0x27,
+ 0x27,0x27,0x27,0x27,0x28,0x28,0x28,0x28,0x28,0x28,0x28,0x29,0x29,0x29,0x29,0x29,
+ 0x29,0x29,0x29,0x2A,0x2A,0x2A,0x2A,0x2A,0x2A,0x2A,0x2A,0x2B,0x2B,0x2B,0x2B,0x2B,
+ 0x2B,0x2B,0x2B,0x2C,0x2C,0x2C,0x2C,0x2C,0x2C,0x2C,0x2C,0x2C,0x2D,0x2D,0x2D,0x2D
+};
+
+const uint8 angleTable02[256] = {
+ 0x00,0x04,0x07,0x0B,0x0E,0x11,0x15,0x18,0x1B,0x1D,0x20,0x23,0x25,0x27,0x29,0x2B,
+ 0x2D,0x2F,0x30,0x32,0x33,0x35,0x36,0x37,0x38,0x39,0x3A,0x3B,0x3C,0x3D,0x3E,0x3F,
+ 0x3F,0x40,0x41,0x41,0x42,0x43,0x43,0x44,0x44,0x45,0x45,0x46,0x46,0x46,0x47,0x47,
+ 0x48,0x48,0x48,0x49,0x49,0x49,0x49,0x4A,0x4A,0x4A,0x4B,0x4B,0x4B,0x4B,0x4C,0x4C,
+ 0x4C,0x4C,0x4C,0x4D,0x4D,0x4D,0x4D,0x4D,0x4D,0x4E,0x4E,0x4E,0x4E,0x4E,0x4E,0x4F,
+ 0x4F,0x4F,0x4F,0x4F,0x4F,0x4F,0x4F,0x50,0x50,0x50,0x50,0x50,0x50,0x50,0x50,0x50,
+ 0x51,0x51,0x51,0x51,0x51,0x51,0x51,0x51,0x51,0x51,0x51,0x51,0x52,0x52,0x52,0x52,
+ 0x52,0x52,0x52,0x52,0x52,0x52,0x52,0x52,0x52,0x52,0x53,0x53,0x53,0x53,0x53,0x53,
+ 0x53,0x53,0x53,0x53,0x53,0x53,0x53,0x53,0x53,0x53,0x53,0x53,0x53,0x54,0x54,0x54,
+ 0x54,0x54,0x54,0x54,0x54,0x54,0x54,0x54,0x54,0x54,0x54,0x54,0x54,0x54,0x54,0x54,
+ 0x54,0x54,0x54,0x54,0x54,0x54,0x54,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,
+ 0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,
+ 0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x56,0x56,0x56,0x56,
+ 0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,
+ 0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,
+ 0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56
+};
+
+const uint8 angleTable03[256] = {
+ 0x00,0x45,0x63,0x72,0x76,0x79,0x81,0x82,0x83,0x84,0x84,0x85,0x85,0x86,0x86,0x86,
+ 0x86,0x87,0x87,0x87,0x87,0x87,0x87,0x88,0x88,0x88,0x88,0x88,0x88,0x88,0x88,0x88,
+ 0x88,0x88,0x88,0x88,0x88,0x88,0x88,0x89,0x89,0x89,0x89,0x89,0x89,0x89,0x89,0x89,
+ 0x89,0x89,0x89,0x89,0x89,0x89,0x89,0x89,0x89,0x89,0x89,0x89,0x89,0x89,0x89,0x89,
+ 0x89,0x89,0x89,0x89,0x89,0x89,0x89,0x89,0x89,0x89,0x89,0x89,0x89,0x89,0x89,0x89,
+ 0x89,0x89,0x89,0x89,0x89,0x89,0x89,0x89,0x89,0x89,0x89,0x89,0x89,0x89,0x89,0x89,
+ 0x89,0x89,0x89,0x89,0x89,0x89,0x89,0x89,0x89,0x89,0x89,0x89,0x89,0x89,0x89,0x89,
+ 0x89,0x89,0x89,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,
+ 0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,
+ 0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,
+ 0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,
+ 0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,
+ 0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,
+ 0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,
+ 0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,
+ 0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90
+};
+
} // end of namespace Asylum
#endif
diff --git a/engines/asylum/asylum.cpp b/engines/asylum/asylum.cpp
index 70802e4987..d9af080da6 100644
--- a/engines/asylum/asylum.cpp
+++ b/engines/asylum/asylum.cpp
@@ -31,7 +31,6 @@
#include "asylum/asylum.h"
#include "asylum/respack.h"
-#include "asylum/shared.h"
namespace Asylum {
@@ -81,15 +80,13 @@ Common::Error AsylumEngine::run() {
Common::Error AsylumEngine::init() {
initGraphics(640, 480, true);
- _screen = new Screen(_system);
+ _screen = new Screen(this);
_sound = new Sound(_mixer);
_video = new Video(_mixer);
_console = new Console(this);
_mainMenu = 0;
_scene = 0;
- Shared.setScreen(_screen);
-
_introPlaying = false;
return Common::kNoError;
@@ -103,7 +100,6 @@ Common::Error AsylumEngine::go() {
// Set up the game's main scene
_scene = new Scene(5, this);
- Shared.setScene(_scene);
// XXX This is just here for testing purposes. It is also defined
// in the processActionList() method when the necessary action is fired.
@@ -282,7 +278,6 @@ void AsylumEngine::processDelayedEvents() {
delete _scene;
_scene = new Scene(sceneIdx, this);
- Shared.setScene(_scene);
_scene->enterScene();
_scene->actions()->delayedSceneIndex = -1;
diff --git a/engines/asylum/asylum.h b/engines/asylum/asylum.h
index 6879377f22..0bd6894603 100644
--- a/engines/asylum/asylum.h
+++ b/engines/asylum/asylum.h
@@ -78,8 +78,10 @@ public:
bool isGameFlagSet(int flag);
bool isGameFlagNotSet(int flag);
- Video* video() { return _video; }
- Sound* sound() { return _sound; }
+ Video* video() { return _video; }
+ Sound* sound() { return _sound; }
+ Screen* screen() { return _screen; }
+ Scene* scene() { return _scene; }
private:
void checkForEvent(bool doUpdate);
diff --git a/engines/asylum/barrier.cpp b/engines/asylum/barrier.cpp
index c697a6cf80..2597b08158 100644
--- a/engines/asylum/barrier.cpp
+++ b/engines/asylum/barrier.cpp
@@ -24,7 +24,6 @@
*/
#include "asylum/barrier.h"
-#include "asylum/shared.h"
namespace Asylum {
@@ -37,25 +36,6 @@ Barrier::~Barrier() {
// TODO Auto-generated destructor stub
}
-bool Barrier::visible() {
- if ((flags & 0xFF) & 1) {
- for (int f = 0; f < 10; f++) {
- bool isSet = false;
- uint32 flag = gameFlags[f];
-
- if (flag <= 0)
- isSet = Shared.getScene()->vm()->isGameFlagNotSet(flag); // -flag
- else
- isSet = Shared.getScene()->vm()->isGameFlagSet(flag);
-
- if(!isSet)
- return false;
- }
- return true;
- }
- return false;
-}
-
uint32 Barrier::getRandomId() {
int numRes = 0;
uint32 rndResId[5];
@@ -72,14 +52,6 @@ uint32 Barrier::getRandomId() {
return resId;
}
-bool Barrier::onscreen() {
- WorldStats *ws = Shared.getScene()->worldstats();
- Common::Rect screenRect = Common::Rect(ws->xLeft, ws->yTop, ws->xLeft + 640, ws->yTop + 480);
- Common::Rect barrierRect = boundingRect;
- barrierRect.translate(x, y);
- return visible() && (flags & 1) && screenRect.intersects(barrierRect);
-}
-
int Barrier::checkFlags() {
return flags & 1 && (flags & 8 || flags & 0x10000);
}
diff --git a/engines/asylum/blowuppuzzle.cpp b/engines/asylum/blowuppuzzle.cpp
index 71120fc449..d08ab616bd 100644
--- a/engines/asylum/blowuppuzzle.cpp
+++ b/engines/asylum/blowuppuzzle.cpp
@@ -26,7 +26,6 @@
#include "asylum/blowuppuzzle.h"
#include "asylum/respack.h"
#include "asylum/graphics.h"
-#include "asylum/shared.h"
namespace Asylum {
@@ -68,11 +67,11 @@ void BlowUpPuzzleVCR::openBlowUp() {
//_scene->vm()->sound()->stopSfx();
// Load the graphics palette
- Shared.getScreen()->setPalette(_scene->getResourcePack(), _scene->worldstats()->grResId[29]);
+ _scene->vm()->screen()->setPalette(_scene->getResourcePack(), _scene->worldstats()->grResId[29]);
// show blow up puzzle BG
GraphicFrame *bg = _bgResource->getFrame(0);
- Shared.getScreen()->copyToBackBuffer((byte *)bg->surface.pixels, bg->surface.w, 0, 0, bg->surface.w, bg->surface.h);
+ _scene->vm()->screen()->copyToBackBuffer((byte *)bg->surface.pixels, bg->surface.w, 0, 0, bg->surface.w, bg->surface.h);
// Set mouse cursor
_cursor->load(_scene->worldstats()->grResId[28]);
@@ -118,7 +117,7 @@ int BlowUpPuzzleVCR::inPolyRegion(int x, int y, int polyIdx) {
}
void BlowUpPuzzleVCR::update() {
- Shared.getScreen()->clearGraphicsInQueue();
+ _scene->vm()->screen()->clearGraphicsInQueue();
if (_rightClickDown) { // quits BlowUp Puzzle
_rightClickDown = false;
@@ -149,17 +148,17 @@ void BlowUpPuzzleVCR::update() {
updateStopButton();
if(_buttonsState[kPower] == kON) {
- Shared.getScreen()->addGraphicToQueue(_scene->worldstats()->grResId[22], _tvScreenAnimIdx, 0, 37, 0, 0, 1);
- Shared.getScreen()->addGraphicToQueue(_scene->worldstats()->grResId[23], _tvScreenAnimIdx++, 238, 22, 0, 0, 1);
+ _scene->vm()->screen()->addGraphicToQueue(_scene->worldstats()->grResId[22], _tvScreenAnimIdx, 0, 37, 0, 0, 1);
+ _scene->vm()->screen()->addGraphicToQueue(_scene->worldstats()->grResId[23], _tvScreenAnimIdx++, 238, 22, 0, 0, 1);
_tvScreenAnimIdx %= 6;
}
if(_isAccomplished) {
- Shared.getScreen()->drawGraphicsInQueue();
+ _scene->vm()->screen()->drawGraphicsInQueue();
int barSize = 0;
do {
- Shared.getScreen()->drawWideScreen(barSize);
+ _scene->vm()->screen()->drawWideScreen(barSize);
barSize += 4;
} while(barSize < 84);
@@ -171,7 +170,7 @@ void BlowUpPuzzleVCR::update() {
_active = false;
_scene->enterScene();
} else {
- Shared.getScreen()->drawGraphicsInQueue();
+ _scene->vm()->screen()->drawGraphicsInQueue();
}
}
@@ -242,7 +241,7 @@ void BlowUpPuzzleVCR::updateJack(Jack jack, VCRDrawInfo onTable, VCRDrawInfo plu
break;
case kOnHand: {
GraphicQueueItem jackItemOnHand = getGraphicJackItem(resIdOnHand);
- Shared.getScreen()->addGraphicToQueue(jackItemOnHand);
+ _scene->vm()->screen()->addGraphicToQueue(jackItemOnHand);
item = getGraphicShadowItem();
}
@@ -254,7 +253,7 @@ void BlowUpPuzzleVCR::updateJack(Jack jack, VCRDrawInfo onTable, VCRDrawInfo plu
if(item.resId != 0)
{
- Shared.getScreen()->addGraphicToQueue(item);
+ _scene->vm()->screen()->addGraphicToQueue(item);
}
}
@@ -356,9 +355,8 @@ void BlowUpPuzzleVCR::updateButton(Button button, VCRDrawInfo btON, VCRDrawInfo
}
if(item.resId != 0)
- {
- Shared.getScreen()->addGraphicToQueue(item);
- }
+ _scene->vm()->screen()->addGraphicToQueue(item);
+
}
void BlowUpPuzzleVCR::updatePowerButton() {
diff --git a/engines/asylum/console.cpp b/engines/asylum/console.cpp
index 4a2113e374..562e95b17f 100644
--- a/engines/asylum/console.cpp
+++ b/engines/asylum/console.cpp
@@ -27,7 +27,6 @@
#include "asylum/asylum.h"
#include "asylum/console.h"
-#include "asylum/shared.h"
namespace Asylum {
@@ -56,8 +55,8 @@ bool Console::cmdDumpActionArea(int argc, const char **argv) {
if (argc == 2) {
// TODO Get an action area by index/id
} else {
- for (uint32 i = 0; i < Shared.getScene()->worldstats()->numActions; i++) {
- ActionArea *a = &Shared.getScene()->worldstats()->actions[i];
+ for (uint32 i = 0; i < _vm->scene()->worldstats()->numActions; i++) {
+ ActionArea *a = &_vm->scene()->worldstats()->actions[i];
printActionAreaStats(a);
}
}
@@ -118,7 +117,7 @@ bool Console::cmdPlayVideo(int argc, const char **argv) {
return true;
}
- Shared.getScene()->actions()->delayedVideoIndex = atoi(argv[1]);
+ _vm->scene()->actions()->delayedVideoIndex = atoi(argv[1]);
return false;
}
@@ -129,7 +128,7 @@ bool Console::cmdRunScript(int argc, const char **argv) {
return true;
}
- Shared.getScene()->actions()->setScriptByIndex(atoi(argv[1]));
+ _vm->scene()->actions()->setScriptByIndex(atoi(argv[1]));
return false;
}
@@ -145,9 +144,9 @@ bool Console::cmdChangeScene(int argc, const char **argv) {
return true;
}
- Shared.getScene()->actions()->delayedSceneIndex = atoi(argv[1]);
- Shared.getScene()->actions()->setScriptByIndex(0); // XXX is this right or should it be
- // ws->actionListIdx???
+ _vm->scene()->actions()->delayedSceneIndex = atoi(argv[1]);
+ _vm->scene()->actions()->setScriptByIndex(0); // XXX is this right or should it be
+ // ws->actionListIdx???
return false;
}
diff --git a/engines/asylum/menu.cpp b/engines/asylum/menu.cpp
index a745f4a6b3..f71364ecef 100644
--- a/engines/asylum/menu.cpp
+++ b/engines/asylum/menu.cpp
@@ -26,7 +26,6 @@
#include "asylum/menu.h"
#include "asylum/respack.h"
#include "asylum/graphics.h"
-#include "asylum/shared.h"
namespace Asylum {
@@ -57,7 +56,7 @@ MainMenu::MainMenu(AsylumEngine *vm): _vm(vm) {
_creditsResource = 0;
_creditsFadeResource = 0;
- _text = new Text(Shared.getScreen());
+ _text = new Text(_vm->screen());
_text->loadFont(_resPack, 16); // 0x80010010, yellow font
}
@@ -74,16 +73,16 @@ MainMenu::~MainMenu() {
void MainMenu::openMenu() {
_active = true;
- Shared.getScene()->deactivate();
+ _vm->scene()->deactivate();
// yellow font
_text->loadFont(_resPack, 0x80010010);
// Load the graphics palette
- Shared.getScreen()->setPalette(_resPack, 17);
+ _vm->screen()->setPalette(_resPack, 17);
// Copy the bright background to the back buffer
GraphicFrame *bg = _bgResource->getFrame(1);
- Shared.getScreen()->copyToBackBuffer((byte *)bg->surface.pixels, bg->surface.w, 0, 0, bg->surface.w, bg->surface.h);
+ _vm->screen()->copyToBackBuffer((byte *)bg->surface.pixels, bg->surface.w, 0, 0, bg->surface.w, bg->surface.h);
// Set mouse cursor
_cursor->load(2);
@@ -103,7 +102,7 @@ void MainMenu::openMenu() {
void MainMenu::closeMenu() {
_active = false;
- Shared.getScene()->activate();
+ _vm->scene()->activate();
// Stop menu sounds and menu music
_vm->sound()->stopSfx();
@@ -144,7 +143,7 @@ void MainMenu::update() {
if (_activeIcon != -1) {
// Copy the dark background to the back buffer
GraphicFrame *bg = _bgResource->getFrame(0);
- Shared.getScreen()->copyToBackBuffer((byte *)bg->surface.pixels, bg->surface.w, 0, 0, bg->surface.w, bg->surface.h);
+ _vm->screen()->copyToBackBuffer((byte *)bg->surface.pixels, bg->surface.w, 0, 0, bg->surface.w, bg->surface.h);
_activeMenuScreen = (MenuScreen) _activeIcon;
// Set the cursor
@@ -190,7 +189,7 @@ void MainMenu::update() {
_creditsFadeResource = new GraphicResource(_resPack, 23);
_creditsTextScroll = 0x1E0 - 30;
// Set credits palette
- Shared.getScreen()->setPalette(_resPack, 26);
+ _vm->screen()->setPalette(_resPack, 26);
// Stop all sounds
_vm->sound()->stopMusic();
// Start playing music
@@ -198,7 +197,7 @@ void MainMenu::update() {
break;
case kReturnToGame:
closeMenu();
- Shared.getScene()->enterScene();
+ _vm->scene()->enterScene();
break;
}
}
@@ -234,7 +233,7 @@ void MainMenu::updateEyesAnimation() {
// TODO: kEyesCrossed state
GraphicFrame *eyeFrame = _eyeResource->getFrame(eyeFrameNum);
- Shared.getScreen()->copyRectToScreenWithTransparency((byte *)eyeFrame->surface.pixels, eyeFrame->surface.w, eyeFrame->x, eyeFrame->y, eyeFrame->surface.w, eyeFrame->surface.h);
+ _vm->screen()->copyRectToScreenWithTransparency((byte *)eyeFrame->surface.pixels, eyeFrame->surface.w, eyeFrame->x, eyeFrame->y, eyeFrame->surface.w, eyeFrame->surface.h);
}
void MainMenu::updateMainMenu() {
@@ -274,7 +273,7 @@ void MainMenu::updateMainMenu() {
}
GraphicFrame *iconFrame = _iconResource->getFrame(MIN<int>(_iconResource->getFrameCount() - 1, _curIconFrame));
- Shared.getScreen()->copyRectToScreenWithTransparency((byte *)iconFrame->surface.pixels, iconFrame->surface.w, iconFrame->x, iconFrame->y, iconFrame->surface.w, iconFrame->surface.h);
+ _vm->screen()->copyRectToScreenWithTransparency((byte *)iconFrame->surface.pixels, iconFrame->surface.w, iconFrame->x, iconFrame->y, iconFrame->surface.w, iconFrame->surface.h);
// Cycle icon frame
_curIconFrame++;
@@ -297,7 +296,7 @@ void MainMenu::updateMainMenu() {
void MainMenu::updateSubMenu() {
GraphicFrame *iconFrame = _iconResource->getFrame(MIN<int>(_iconResource->getFrameCount() - 1, _curIconFrame));
- Shared.getScreen()->copyRectToScreenWithTransparency((byte *)iconFrame->surface.pixels, iconFrame->surface.w, iconFrame->x, iconFrame->y, iconFrame->surface.w, iconFrame->surface.h);
+ _vm->screen()->copyRectToScreenWithTransparency((byte *)iconFrame->surface.pixels, iconFrame->surface.w, iconFrame->x, iconFrame->y, iconFrame->surface.w, iconFrame->surface.h);
// Cycle icon frame
_curIconFrame++;
@@ -565,10 +564,10 @@ void MainMenu::updateSubMenuShowCredits() {
int maxBound = 0;
GraphicFrame *creditsFadeFrame = _creditsFadeResource->getFrame(0);
- Shared.getScreen()->copyRectToScreenWithTransparency((byte *)creditsFadeFrame->surface.pixels, creditsFadeFrame->surface.w, creditsFadeFrame->x, creditsFadeFrame->y, creditsFadeFrame->surface.w, creditsFadeFrame->surface.h);
+ _vm->screen()->copyRectToScreenWithTransparency((byte *)creditsFadeFrame->surface.pixels, creditsFadeFrame->surface.w, creditsFadeFrame->x, creditsFadeFrame->y, creditsFadeFrame->surface.w, creditsFadeFrame->surface.h);
GraphicFrame *creditsFrame = _creditsResource->getFrame(MIN<int>(_creditsResource->getFrameCount() - 1, _creditsBgFrame));
- Shared.getScreen()->copyRectToScreenWithTransparency((byte *)creditsFrame->surface.pixels, creditsFrame->surface.w, creditsFrame->x, creditsFrame->y, creditsFrame->surface.w, creditsFrame->surface.h);
+ _vm->screen()->copyRectToScreenWithTransparency((byte *)creditsFrame->surface.pixels, creditsFrame->surface.w, creditsFrame->x, creditsFrame->y, creditsFrame->surface.w, creditsFrame->surface.h);
_creditsBgFrame++;
if (_creditsBgFrame >= _creditsResource->getFrameCount())
@@ -609,7 +608,7 @@ void MainMenu::updateSubMenuShowCredits() {
if (_leftClick) {
// Restore palette
- Shared.getScreen()->setPalette(_resPack, 17);
+ _vm->screen()->setPalette(_resPack, 17);
// Stop all sounds
_vm->sound()->stopMusic();
// Start playing music
@@ -624,7 +623,7 @@ void MainMenu::exitSubMenu() {
// Copy the bright background to the back buffer
GraphicFrame *bg = _bgResource->getFrame(1);
- Shared.getScreen()->copyToBackBuffer((byte *)bg->surface.pixels, bg->surface.w, 0, 0, bg->surface.w, bg->surface.h);
+ _vm->screen()->copyToBackBuffer((byte *)bg->surface.pixels, bg->surface.w, 0, 0, bg->surface.w, bg->surface.h);
// Set the cursor
_cursor->load(2);
diff --git a/engines/asylum/module.mk b/engines/asylum/module.mk
index 18556c7ed8..bd8733e3e7 100644
--- a/engines/asylum/module.mk
+++ b/engines/asylum/module.mk
@@ -16,7 +16,6 @@ MODULE_OBJS := \
respack.o \
scene.o \
screen.o \
- shared.o \
sound.o \
text.o \
video.o \
diff --git a/engines/asylum/scene.cpp b/engines/asylum/scene.cpp
index 68b7e09672..38be0c6759 100644
--- a/engines/asylum/scene.cpp
+++ b/engines/asylum/scene.cpp
@@ -24,7 +24,6 @@
*/
#include "asylum/scene.h"
-#include "asylum/shared.h"
#include "asylum/actor.h"
namespace Asylum {
@@ -57,7 +56,7 @@ Scene::Scene(uint8 sceneIdx, AsylumEngine *vm): _vm(vm) {
if (Common::String(sceneTag,6) != "DFISCN")
error("The file isn't recognized as scene %s", filename);
- _ws = new WorldStats(fd);
+ _ws = new WorldStats(fd, this);
// jump to game polygons data
fd->seek(0xE8686);
_polygons = new Polygons(fd);
@@ -68,7 +67,7 @@ Scene::Scene(uint8 sceneIdx, AsylumEngine *vm): _vm(vm) {
fd->close();
delete fd;
- _text = new Text(Shared.getScreen());
+ _text = new Text(_vm->screen());
_resPack = new ResourcePack(sceneIdx);
_speechPack = new ResourcePack(3); // FIXME are all scene speech packs the same?
@@ -76,8 +75,10 @@ Scene::Scene(uint8 sceneIdx, AsylumEngine *vm): _vm(vm) {
// Is there EVER more than one actor enabled for a scene? I can't
// remember, so I guess a playthrough is in order :P
// Either way, this is kinda dumb
- for (uint8 i = 0; i < _ws->numActors; i++)
+ for (uint8 i = 0; i < _ws->numActors; i++) {
_ws->actors[i].setResourcePack(_resPack);
+ _ws->actors[i].setScene(this);
+ }
_text->loadFont(_resPack, _ws->commonRes.font1);
@@ -111,7 +112,7 @@ Scene::Scene(uint8 sceneIdx, AsylumEngine *vm): _vm(vm) {
}
_ws->sceneRectIdx = 0;
- Shared.getScreen()->clearGraphicsInQueue();
+ _vm->screen()->clearGraphicsInQueue();
_ws->motionStatus = 1;
// TODO: do some rect stuffs from player actor
@@ -138,9 +139,9 @@ Actor* Scene::getActor() {
void Scene::enterScene() {
WorldStats *ws = _ws;
- Shared.getScreen()->setPalette(_resPack, ws->commonRes.palette);
+ _vm->screen()->setPalette(_resPack, ws->commonRes.palette);
_background = _bgResource->getFrame(0);
- Shared.getScreen()->copyToBackBuffer(
+ _vm->screen()->copyToBackBuffer(
((byte *)_background->surface.pixels) + ws->targetY * _background->surface.w + ws->targetX, _background->surface.w,
0, 0, 640, 480);
@@ -503,7 +504,7 @@ void Scene::updateActor(uint32 actorIdx) {
}
void Scene::updateBarriers(WorldStats *worldStats) {
- Screen *screen = Shared.getScreen();
+ Screen *screen = _vm->screen();
uint barriersCount = worldStats->barriers.size();
int startTickCount = 0;
@@ -514,7 +515,7 @@ void Scene::updateBarriers(WorldStats *worldStats) {
Barrier *barrier = &worldStats->barriers[b];
if (barrier->field_3C == 4) {
- if (barrier->visible()) {
+ if (_ws->isBarrierVisible(b)) {
uint32 flag = barrier->flags;
if (flag & 0x20) {
if (barrier->field_B4 && (_vm->_system->getMillis() - barrier->tickCount >= 0x3E8 / barrier->field_B4)) {
@@ -886,15 +887,15 @@ void Scene::OLD_UPDATE(WorldStats *worldStats) {
int Scene::drawScene() {
- Shared.getScreen()->clearGraphicsInQueue();
+ _vm->screen()->clearGraphicsInQueue();
if (_skipDrawScene) {
- Shared.getScreen()->clearScreen();
+ _vm->screen()->clearScreen();
} else {
// Draw scene background
WorldStats *ws = _ws;
GraphicFrame *bg = _bgResource->getFrame(0);
- Shared.getScreen()->copyToBackBuffer(
+ _vm->screen()->copyToBackBuffer(
((byte *)bg->surface.pixels) + ws->targetY * bg->surface.w + ws->targetX, bg->surface.w,
ws->xLeft,
ws->yTop,
@@ -910,7 +911,7 @@ int Scene::drawScene() {
drawBarriers();
// TODO: draw main actor stuff
- Shared.getScreen()->drawGraphicsInQueue();
+ _vm->screen()->drawGraphicsInQueue();
// TODO: we must get rid of this
OLD_UPDATE(ws);
@@ -928,15 +929,15 @@ int Scene::drawBarriers() {
Barrier *barrier = &worldStats->barriers[b];
if (!(barrier->flags & 4) && !((barrier->flags & 0xFF) & 0x40)) {
- if (barrier->onscreen()) {
+ if (_ws->isBarrierOnScreen(b)) {
//TODO: need to do something here yet
if (barrier->field_67C <= 0 || barrier->field_67C >= 4) { // TODO: still missing a condition for game quality config
- Shared.getScreen()->addGraphicToQueue(barrier->resId, barrier->frameIdx, barrier->x, barrier->y, (barrier->flags >> 11) & 2, barrier->field_67C - 3, barrier->priority);
+ _vm->screen()->addGraphicToQueue(barrier->resId, barrier->frameIdx, barrier->x, barrier->y, (barrier->flags >> 11) & 2, barrier->field_67C - 3, barrier->priority);
} else {
// TODO: Do Cross Fade
// parameters: barrier->resId, barrier->frameIdx, barrier->x, barrier->y, worldStats->commonRes.backgroundImage, worldStats->xLeft, worldStats->yTop, 0, 0, barrier->field_67C - 1
- Shared.getScreen()->addGraphicToQueue(barrier->resId, barrier->frameIdx, barrier->x, barrier->y, 0, 0, 0);
+ _vm->screen()->addGraphicToQueue(barrier->resId, barrier->frameIdx, barrier->x, barrier->y, 0, 0, 0);
}
}
}
@@ -970,7 +971,7 @@ void Scene::copyToBackBufferClipped(Graphics::Surface *surface, int x, int y) {
if (surface->h > 480)
startY = ws->targetY;
- Shared.getScreen()->copyToBackBufferWithTransparency(
+ _vm->screen()->copyToBackBufferWithTransparency(
((byte*)surface->pixels) +
startY * surface->pitch +
startX * surface->bytesPerPixel,
diff --git a/engines/asylum/scene.h b/engines/asylum/scene.h
index 63cd2d55dd..db9046ba5f 100644
--- a/engines/asylum/scene.h
+++ b/engines/asylum/scene.h
@@ -49,6 +49,7 @@ class Cursor;
class Text;
class BlowUpPuzzle;
struct BarrierItem;
+class WorldStats;
class Scene {
public:
diff --git a/engines/asylum/screen.cpp b/engines/asylum/screen.cpp
index 61ffa803b4..8416b76f37 100644
--- a/engines/asylum/screen.cpp
+++ b/engines/asylum/screen.cpp
@@ -24,11 +24,10 @@
*/
#include "asylum/screen.h"
-#include "asylum/shared.h"
namespace Asylum {
-Screen::Screen(OSystem *sys) : _sys(sys) {
+Screen::Screen(AsylumEngine *vm) : _vm(vm) {
_backBuffer.create(640, 480, 1);
}
@@ -37,7 +36,7 @@ Screen::~Screen() {
}
void Screen::copyBackBufferToScreen() {
- _sys->copyRectToScreen((byte *)_backBuffer.pixels, _backBuffer.w, 0, 0, _backBuffer.w, _backBuffer.h);
+ _vm->_system->copyRectToScreen((byte *)_backBuffer.pixels, _backBuffer.w, 0, 0, _backBuffer.w, _backBuffer.h);
}
void Screen::copyToBackBuffer(byte *buffer, int pitch, int x, int y, int width, int height) {
@@ -67,11 +66,11 @@ void Screen::copyToBackBufferWithTransparency(byte *buffer, int pitch, int x, in
}
void Screen::copyRectToScreen(byte *buffer, int pitch, int x, int y, int width, int height) {
- _sys->copyRectToScreen(buffer, pitch, x, y, width, height);
+ _vm->_system->copyRectToScreen(buffer, pitch, x, y, width, height);
}
void Screen::copyRectToScreenWithTransparency(byte *buffer, int pitch, int x, int y, int width, int height) {
- byte *screenBuffer = (byte *)_sys->lockScreen()->pixels;
+ byte *screenBuffer = (byte *)_vm->_system->lockScreen()->pixels;
for (int curY = 0; curY < height; curY++) {
for (int curX = 0; curX < width; curX++) {
@@ -81,7 +80,7 @@ void Screen::copyRectToScreenWithTransparency(byte *buffer, int pitch, int x, in
}
}
- _sys->unlockScreen();
+ _vm->_system->unlockScreen();
}
void Screen::setPalette(byte *rgbPalette) {
@@ -98,21 +97,21 @@ void Screen::setPalette(byte *rgbPalette) {
palette[i * 4 + 3] = 0;
}
- _sys->setPalette(palette, 0, 256);
+ _vm->_system->setPalette(palette, 0, 256);
}
void Screen::drawWideScreen(int16 barSize) {
if(barSize > 0) {
- _sys->lockScreen()->fillRect(Common::Rect(0, 0, 640, barSize), 0);
- _sys->unlockScreen();
- _sys->lockScreen()->fillRect(Common::Rect(0, 480 - barSize, 640, 480), 0);
- _sys->unlockScreen();
+ _vm->_system->lockScreen()->fillRect(Common::Rect(0, 0, 640, barSize), 0);
+ _vm->_system->unlockScreen();
+ _vm->_system->lockScreen()->fillRect(Common::Rect(0, 480 - barSize, 640, 480), 0);
+ _vm->_system->unlockScreen();
}
}
void Screen::clearScreen() {
- _sys->fillScreen(0);
+ _vm->_system->fillScreen(0);
}
void Screen::addGraphicToQueue(uint32 redId, uint32 frameIdx, uint32 x, uint32 y, uint32 flags, uint32 transTableNum, uint32 priority) {
@@ -136,13 +135,13 @@ void Screen::addGraphicToQueue(GraphicQueueItem item) {
}
void Screen::drawGraphicsInQueue() {
- WorldStats *ws = Shared.getScene()->worldstats();
+ WorldStats *ws = _vm->scene()->worldstats();
// sort by priority first
graphicsSelectionSort();
for(uint i = 0; i < _queueItems.size(); i++) {
- GraphicResource *grRes = Shared.getScene()->getGraphicResource(_queueItems[i].resId);
+ GraphicResource *grRes = _vm->scene()->getGraphicResource(_queueItems[i].resId);
GraphicFrame *fra = grRes->getFrame(_queueItems[i].frameIdx);
copyRectToScreenWithTransparency((byte *)fra->surface.pixels, fra->surface.w, _queueItems[i].x - ws->targetX, _queueItems[i].y - ws->targetY, fra->surface.w, fra->surface.h);
delete grRes;
diff --git a/engines/asylum/screen.h b/engines/asylum/screen.h
index 836ead8985..57694595ba 100644
--- a/engines/asylum/screen.h
+++ b/engines/asylum/screen.h
@@ -48,7 +48,7 @@ typedef struct GraphicQueueItem {
class Screen {
public:
- Screen(OSystem *sys);
+ Screen(AsylumEngine *_vm);
~Screen();
void copyToBackBuffer(byte *buffer, int pitch, int x, int y, int width, int height);
@@ -72,7 +72,7 @@ public:
private:
Graphics::Surface _backBuffer;
- OSystem *_sys;
+ AsylumEngine *_vm;
Common::Array<GraphicQueueItem> _queueItems;
};
diff --git a/engines/asylum/shared.cpp b/engines/asylum/shared.cpp
deleted file mode 100644
index 7761b2a85f..0000000000
--- a/engines/asylum/shared.cpp
+++ /dev/null
@@ -1,133 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * $URL$
- * $Id$
- *
- */
-
-#include "asylum/shared.h"
-
-#include "common/system.h"
-
-DECLARE_SINGLETON(Asylum::SharedResources);
-
-namespace Asylum {
-
-static bool g_initialized = false;
-
-SharedResources::SharedResources() {
- if (!g_initialized) {
- g_initialized = true;
- }
-
-}
-
-SharedResources::~SharedResources() {
- g_initialized = false;
-}
-
-int SharedResources::getAngle(int x1, int y1, int x2, int y2) {
- uint32 v5 = (x2 << 16) - (x1 << 16);
- int v6 = 0;
- int v4 = (y1 << 16) - (y2 << 16);
-
- if (v5 < 0) {
- v6 = 2;
- v5 = -v5;
- }
-
- if (v4 < 0) {
- v6 |= 1;
- v4 = -v4;
- }
-
- int v7;
- int v8 = -1;
-
- if (v5) {
- v7 = (v4 << 8) / v5;
-
- if (v7 < 0x100)
- v8 = angleTable01[v7];
- if (v7 < 0x1000 && v8 < 0)
- v8 = angleTable02[v7 >> 4];
- if (v7 < 0x10000 && v8 < 0)
- v8 = angleTable03[v7 >> 8];
- } else {
- v8 = 90;
- }
-
- switch (v6) {
- case 1:
- v8 = 360 - v8;
- break;
- case 2:
- v8 = 180 - v8;
- break;
- case 3:
- v8 += 180;
- break;
- }
-
- if (v8 >= 360)
- v8 -= 360;
-
- int result;
-
- if (v8 < 157 || v8 >= 202) {
- if (v8 < 112 || v8 >= 157) {
- if (v8 < 67 || v8 >= 112) {
- if (v8 < 22 || v8 >= 67) {
- if ((v8 < 0 || v8 >= 22) && (v8 < 337 || v8 > 359)) {
- if (v8 < 292 || v8 >= 337) {
- if (v8 < 247 || v8 >= 292) {
- if (v8 < 202 || v8 >= 247) {
- error("getAngle returned a bad angle: %d.", v8);
- result = x1;
- } else {
- result = 3;
- }
- } else {
- result = 4;
- }
- } else {
- result = 5;
- }
- } else {
- result = 6;
- }
- } else {
- result = 7;
- }
- } else {
- result = 0;
- }
- } else {
- result = 1;
- }
- } else {
- result = 2;
- }
-
- return result;
-}
-
-} // end of namespace Asylum
diff --git a/engines/asylum/shared.h b/engines/asylum/shared.h
deleted file mode 100644
index 556c9ff82f..0000000000
--- a/engines/asylum/shared.h
+++ /dev/null
@@ -1,132 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * $URL$
- * $Id$
- *
- */
-
-#ifndef ASYLUM_SHARED_H
-#define ASYLUM_SHARED_H_
-
-#include "common/singleton.h"
-
-#include "asylum/scene.h"
-
-namespace Asylum {
-
-class Screen;
-class Sound;
-
-/**
- * Shared Resources are classes that are instantiated at the engine level.
- * Binding them to this singleton simplifies implementation of new classes
- * that will require access to common interfaces and tools.
- *
- * A candidate for a shared resource would be any class that will be utilized
- * by one-to-many instances of another class, but will never need more than
- * one instance itself.
- *
- * Each component herin could technically be a singleton unto itself, but
- * by using this method, destruction can be handled by the engine.
- */
-class SharedResources: public Common::Singleton<SharedResources> {
-public:
- void setScreen(Screen* screen) { _screen = screen; }
- Screen* getScreen() { return _screen; }
-
- void setScene(Scene* scene) { _scene = scene; }
- Scene* getScene() { return _scene; }
-
- int getAngle(int x1, int y1, int x2, int y2);
-
-private:
- friend class Common::Singleton<SingletonBaseType>;
- SharedResources();
- ~SharedResources();
-
- Screen *_screen;
- Scene *_scene;
-
-}; // end of class SharedResources
-
- // Angle Tables used by getAngle()
- const uint8 angleTable01[256] = {
- 0x00,0x00,0x00,0x01,0x01,0x01,0x01,0x02,0x02,0x02,0x02,0x02,0x03,0x03,0x03,0x03,
- 0x04,0x04,0x04,0x04,0x04,0x05,0x05,0x05,0x05,0x06,0x06,0x06,0x06,0x06,0x07,0x07,
- 0x07,0x07,0x08,0x08,0x08,0x08,0x08,0x09,0x09,0x09,0x09,0x0A,0x0A,0x0A,0x0A,0x0A,
- 0x0B,0x0B,0x0B,0x0B,0x0B,0x0C,0x0C,0x0C,0x0C,0x0D,0x0D,0x0D,0x0D,0x0D,0x0E,0x0E,
- 0x0E,0x0E,0x0E,0x0F,0x0F,0x0F,0x0F,0x10,0x10,0x10,0x10,0x10,0x11,0x11,0x11,0x11,
- 0x11,0x12,0x12,0x12,0x12,0x12,0x13,0x13,0x13,0x13,0x13,0x14,0x14,0x14,0x14,0x14,
- 0x15,0x15,0x15,0x15,0x15,0x16,0x16,0x16,0x16,0x16,0x16,0x17,0x17,0x17,0x17,0x17,
- 0x18,0x18,0x18,0x18,0x18,0x19,0x19,0x19,0x19,0x19,0x19,0x1A,0x1A,0x1A,0x1A,0x1A,
- 0x1B,0x1B,0x1B,0x1B,0x1B,0x1B,0x1C,0x1C,0x1C,0x1C,0x1C,0x1D,0x1D,0x1D,0x1D,0x1D,
- 0x1D,0x1E,0x1E,0x1E,0x1E,0x1E,0x1E,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x20,0x20,0x20,
- 0x20,0x20,0x20,0x20,0x21,0x21,0x21,0x21,0x21,0x21,0x22,0x22,0x22,0x22,0x22,0x22,
- 0x23,0x23,0x23,0x23,0x23,0x23,0x23,0x24,0x24,0x24,0x24,0x24,0x24,0x24,0x25,0x25,
- 0x25,0x25,0x25,0x25,0x25,0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x27,0x27,0x27,0x27,
- 0x27,0x27,0x27,0x27,0x28,0x28,0x28,0x28,0x28,0x28,0x28,0x29,0x29,0x29,0x29,0x29,
- 0x29,0x29,0x29,0x2A,0x2A,0x2A,0x2A,0x2A,0x2A,0x2A,0x2A,0x2B,0x2B,0x2B,0x2B,0x2B,
- 0x2B,0x2B,0x2B,0x2C,0x2C,0x2C,0x2C,0x2C,0x2C,0x2C,0x2C,0x2C,0x2D,0x2D,0x2D,0x2D
- };
-
- const uint8 angleTable02[256] = {
- 0x00,0x04,0x07,0x0B,0x0E,0x11,0x15,0x18,0x1B,0x1D,0x20,0x23,0x25,0x27,0x29,0x2B,
- 0x2D,0x2F,0x30,0x32,0x33,0x35,0x36,0x37,0x38,0x39,0x3A,0x3B,0x3C,0x3D,0x3E,0x3F,
- 0x3F,0x40,0x41,0x41,0x42,0x43,0x43,0x44,0x44,0x45,0x45,0x46,0x46,0x46,0x47,0x47,
- 0x48,0x48,0x48,0x49,0x49,0x49,0x49,0x4A,0x4A,0x4A,0x4B,0x4B,0x4B,0x4B,0x4C,0x4C,
- 0x4C,0x4C,0x4C,0x4D,0x4D,0x4D,0x4D,0x4D,0x4D,0x4E,0x4E,0x4E,0x4E,0x4E,0x4E,0x4F,
- 0x4F,0x4F,0x4F,0x4F,0x4F,0x4F,0x4F,0x50,0x50,0x50,0x50,0x50,0x50,0x50,0x50,0x50,
- 0x51,0x51,0x51,0x51,0x51,0x51,0x51,0x51,0x51,0x51,0x51,0x51,0x52,0x52,0x52,0x52,
- 0x52,0x52,0x52,0x52,0x52,0x52,0x52,0x52,0x52,0x52,0x53,0x53,0x53,0x53,0x53,0x53,
- 0x53,0x53,0x53,0x53,0x53,0x53,0x53,0x53,0x53,0x53,0x53,0x53,0x53,0x54,0x54,0x54,
- 0x54,0x54,0x54,0x54,0x54,0x54,0x54,0x54,0x54,0x54,0x54,0x54,0x54,0x54,0x54,0x54,
- 0x54,0x54,0x54,0x54,0x54,0x54,0x54,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,
- 0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,
- 0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x56,0x56,0x56,0x56,
- 0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,
- 0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,
- 0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56
- };
-
- const uint8 angleTable03[256] = {
- 0x00,0x45,0x63,0x72,0x76,0x79,0x81,0x82,0x83,0x84,0x84,0x85,0x85,0x86,0x86,0x86,
- 0x86,0x87,0x87,0x87,0x87,0x87,0x87,0x88,0x88,0x88,0x88,0x88,0x88,0x88,0x88,0x88,
- 0x88,0x88,0x88,0x88,0x88,0x88,0x88,0x89,0x89,0x89,0x89,0x89,0x89,0x89,0x89,0x89,
- 0x89,0x89,0x89,0x89,0x89,0x89,0x89,0x89,0x89,0x89,0x89,0x89,0x89,0x89,0x89,0x89,
- 0x89,0x89,0x89,0x89,0x89,0x89,0x89,0x89,0x89,0x89,0x89,0x89,0x89,0x89,0x89,0x89,
- 0x89,0x89,0x89,0x89,0x89,0x89,0x89,0x89,0x89,0x89,0x89,0x89,0x89,0x89,0x89,0x89,
- 0x89,0x89,0x89,0x89,0x89,0x89,0x89,0x89,0x89,0x89,0x89,0x89,0x89,0x89,0x89,0x89,
- 0x89,0x89,0x89,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,
- 0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,
- 0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,
- 0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,
- 0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,
- 0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,
- 0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,
- 0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,
- 0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90
- };
-
-#define Shared (::Asylum::SharedResources::instance())
-
-} // end of namespace Asylum
-
-#endif
diff --git a/engines/asylum/worldstats.cpp b/engines/asylum/worldstats.cpp
index c927b76a65..76f6b31fe7 100644
--- a/engines/asylum/worldstats.cpp
+++ b/engines/asylum/worldstats.cpp
@@ -27,7 +27,8 @@
namespace Asylum {
-WorldStats::WorldStats(Common::SeekableReadStream *stream) {
+WorldStats::WorldStats(Common::SeekableReadStream *stream, Scene *scene)
+ : _scene(scene) {
load(stream);
}
@@ -67,6 +68,36 @@ Barrier* WorldStats::getBarrierByIndex(uint32 idx) {
return &barriers[idx];
}
+bool WorldStats::isBarrierOnScreen(uint32 idx) {
+ Barrier *b = getBarrierByIndex(idx);
+
+ Common::Rect screenRect = Common::Rect(xLeft, yTop, xLeft + 640, yTop + 480);
+ Common::Rect barrierRect = b->boundingRect;
+ barrierRect.translate(b->x, b->y);
+ return isBarrierVisible(idx) && (b->flags & 1) && screenRect.intersects(barrierRect);
+}
+
+bool WorldStats::isBarrierVisible(uint32 idx) {
+ Barrier *b = getBarrierByIndex(idx);
+
+ if ((b->flags & 0xFF) & 1) {
+ for (int f = 0; f < 10; f++) {
+ bool isSet = false;
+ uint32 flag = b->gameFlags[f];
+
+ if (flag <= 0)
+ isSet = _scene->vm()->isGameFlagNotSet(flag); // -flag
+ else
+ isSet = _scene->vm()->isGameFlagSet(flag);
+
+ if(!isSet)
+ return false;
+ }
+ return true;
+ }
+ return false;
+}
+
// FIXME: load necessary World Stats content
void WorldStats::load(Common::SeekableReadStream *stream) {
size = stream->readUint32LE();
diff --git a/engines/asylum/worldstats.h b/engines/asylum/worldstats.h
index 7e83a33b5e..de040be381 100644
--- a/engines/asylum/worldstats.h
+++ b/engines/asylum/worldstats.h
@@ -31,6 +31,7 @@
#include "asylum/actor.h"
#include "asylum/barrier.h"
+#include "asylum/scene.h"
#include "asylum/sound.h"
namespace Asylum {
@@ -90,7 +91,7 @@ typedef struct ActionArea {
class WorldStats {
public:
- WorldStats(Common::SeekableReadStream *stream);
+ WorldStats(Common::SeekableReadStream *stream, Scene *scene);
virtual ~WorldStats();
uint32 size;
@@ -151,7 +152,11 @@ public:
Barrier* getBarrierById(uint32 id);
Barrier* getBarrierByIndex(uint32 idx);
+ bool isBarrierOnScreen(uint32 idx);
+ bool isBarrierVisible(uint32 idx);
+
private:
+ Scene *_scene;
void load(Common::SeekableReadStream *stream);
Commit: 2c54ace443108e9ecfd0d8508a2dc8182eba4bdf
https://github.com/scummvm/scummvm/commit/2c54ace443108e9ecfd0d8508a2dc8182eba4bdf
Author: Alex Bevilacqua (alexbevi at gmail.com)
Date: 2021-05-17T15:35:49+02:00
Commit Message:
ASYLUM: make function_map[] static/const, and undefine the MAPFUNC macro after the function_map has been set.
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@356 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/actionlist.cpp
diff --git a/engines/asylum/actionlist.cpp b/engines/asylum/actionlist.cpp
index a41d6e1de5..8af389c0e2 100644
--- a/engines/asylum/actionlist.cpp
+++ b/engines/asylum/actionlist.cpp
@@ -52,7 +52,7 @@ struct AsylumFunction {
#define MAPFUNC(name, func) {name, func}
-AsylumFunction function_map[] = {
+static const AsylumFunction function_map[] = {
/*0x00*/ MAPFUNC("kReturn0", kReturn0),
/*0x01*/ MAPFUNC("kSetGameFlag", kSetGameFlag),
/*0x02*/ MAPFUNC("kClearGameFlag", kClearGameFlag),
@@ -155,6 +155,8 @@ AsylumFunction function_map[] = {
/*0x63*/ MAPFUNC("k_unk63", k_unk63)
};
+#undef MAPFUNC
+
void ActionList::setScriptByIndex(uint32 index) {
currentLine = 0;
_currentScript = &entries[index]; // TODO assert if out of bounds
Commit: 0a29c45b113c10572337c877ad90cd49671a268a
https://github.com/scummvm/scummvm/commit/0a29c45b113c10572337c877ad90cd49671a268a
Author: Alex Bevilacqua (alexbevi at gmail.com)
Date: 2021-05-17T15:35:49+02:00
Commit Message:
ASYLUM: properly check if the debugChannel is set :P
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@357 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/actionlist.cpp
diff --git a/engines/asylum/actionlist.cpp b/engines/asylum/actionlist.cpp
index 8af389c0e2..55e7dc7161 100644
--- a/engines/asylum/actionlist.cpp
+++ b/engines/asylum/actionlist.cpp
@@ -161,7 +161,7 @@ void ActionList::setScriptByIndex(uint32 index) {
currentLine = 0;
_currentScript = &entries[index]; // TODO assert if out of bounds
- if (kDebugLevelScripts) {
+ if (Common::isDebugChannelEnabled(kDebugLevelScripts)) {
for (uint8 i = 0; i < _currentScript->commands[0].numLines; i++) {
debugC(kDebugLevelScripts,
"Line: %02d/%02d :: 0x%02X (%d, %d, %d, %d, %d, %d, %d, %d, %d)",
Commit: cf58a8244c22fc749eb347a6f5ce0e3341ab66c7
https://github.com/scummvm/scummvm/commit/cf58a8244c22fc749eb347a6f5ce0e3341ab66c7
Author: Alex Bevilacqua (alexbevi at gmail.com)
Date: 2021-05-17T15:35:49+02:00
Commit Message:
ASYLUM: Fixed bug with cursor not being visible after the first script ran (hacked the fix and added a FIXME)
Removed all WorldStats reference variables from the scene class (redundant)
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@358 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/blowuppuzzle.cpp
engines/asylum/cursor.cpp
engines/asylum/scene.cpp
engines/asylum/scene.h
diff --git a/engines/asylum/blowuppuzzle.cpp b/engines/asylum/blowuppuzzle.cpp
index d08ab616bd..18669b7ea0 100644
--- a/engines/asylum/blowuppuzzle.cpp
+++ b/engines/asylum/blowuppuzzle.cpp
@@ -443,14 +443,12 @@ void BlowUpPuzzleVCR::updateCursorInPolyRegion() {
if(_cursor->currentFrame() != 2) { // reset cursor
_cursor->show();
_cursor->set(2);
- //_cursorStep = 1;
_cursor->animate();
}
} else {
if(_cursor->currentFrame() != 0) { // reset cursor
_cursor->show();
_cursor->set(0);
- //_cursorStep = 1;
_cursor->animate();
}
}
diff --git a/engines/asylum/cursor.cpp b/engines/asylum/cursor.cpp
index 84c962fe38..6abcb0ec26 100644
--- a/engines/asylum/cursor.cpp
+++ b/engines/asylum/cursor.cpp
@@ -63,10 +63,13 @@ void Cursor::set(byte *data, byte width, byte height) {
}
void Cursor::set(int frame) {
- GraphicFrame *mouseCursor = _cursorResource->getFrame(frame);
- set((byte *)mouseCursor->surface.pixels, mouseCursor->surface.w, mouseCursor->surface.h);
-
- _curFrame = frame;
+ if (frame >= 0) {
+ GraphicFrame *mouseCursor = _cursorResource->getFrame(frame);
+ set((byte *)mouseCursor->surface.pixels, mouseCursor->surface.w, mouseCursor->surface.h);
+ _curFrame = frame;
+ } else {
+ _cursorStep = 1;
+ }
}
void Cursor::setCoords(uint32 mouseX, uint32 mouseY) {
diff --git a/engines/asylum/scene.cpp b/engines/asylum/scene.cpp
index 38be0c6759..0341580a5f 100644
--- a/engines/asylum/scene.cpp
+++ b/engines/asylum/scene.cpp
@@ -138,14 +138,19 @@ Actor* Scene::getActor() {
}
void Scene::enterScene() {
- WorldStats *ws = _ws;
- _vm->screen()->setPalette(_resPack, ws->commonRes.palette);
+ _vm->screen()->setPalette(_resPack, _ws->commonRes.palette);
_background = _bgResource->getFrame(0);
_vm->screen()->copyToBackBuffer(
- ((byte *)_background->surface.pixels) + ws->targetY * _background->surface.w + ws->targetX, _background->surface.w,
+ ((byte *)_background->surface.pixels) + _ws->targetY * _background->surface.w + _ws->targetX, _background->surface.w,
0, 0, 640, 480);
+ // FIXME
+ // I don't know that this is the right way to initialize the cursor
+ // when the scene is started. Check against the original to see
+ // when the cursor is initalized, and then how it reacts to the
+ // show_cursor opcode
_cursor->load(_ws->commonRes.curMagnifyingGlass);
+ _cursor->set(0);
_cursor->show();
// Music testing: play the first music track
@@ -157,23 +162,22 @@ void Scene::enterScene() {
void Scene::setScenePosition(int x, int y)
{
- WorldStats *ws = _ws;
GraphicFrame *bg = _bgResource->getFrame(0);
//_startX = x;
//_startY = y;
- ws->targetX = x;
- ws->targetY = y;
+ _ws->targetX = x;
+ _ws->targetY = y;
- if (ws->targetX < 0)
- ws->targetX = 0;
- if (ws->targetX > (bg->surface.w - 640))
- ws->targetX = bg->surface.w - 640;
+ if (_ws->targetX < 0)
+ _ws->targetX = 0;
+ if (_ws->targetX > (bg->surface.w - 640))
+ _ws->targetX = bg->surface.w - 640;
- if (ws->targetY < 0)
- ws->targetY = 0;
- if (ws->targetY > (bg->surface.h - 480))
- ws->targetY = bg->surface.h - 480;
+ if (_ws->targetY < 0)
+ _ws->targetY = 0;
+ if (_ws->targetY > (bg->surface.h - 480))
+ _ws->targetY = bg->surface.h - 480;
}
void Scene::handleEvent(Common::Event *event, bool doUpdate) {
@@ -225,8 +229,7 @@ void Scene::update() {
}
int Scene::updateScene() {
- uint32 startTick = 0;
- WorldStats *worldStats = _ws;
+ uint32 startTick = 0;
// Mouse
startTick = _vm->_system->getMillis();
@@ -235,13 +238,13 @@ int Scene::updateScene() {
// Actors
startTick = _vm->_system->getMillis();
- for (uint32 a = 0; a < worldStats->numActors; a++)
+ for (uint32 a = 0; a < _ws->numActors; a++)
updateActor(a);
debugC(kDebugLevelScene, "UpdateActors Time: %d", _vm->_system->getMillis() - startTick);
// Barriers
startTick = _vm->_system->getMillis();
- updateBarriers(worldStats);
+ updateBarriers();
debugC(kDebugLevelScene, "UpdateBarriers Time: %d", _vm->_system->getMillis() - startTick);
// Ambient Sounds
@@ -406,8 +409,7 @@ void Scene::updateMouse() {
}
void Scene::updateActor(uint32 actorIdx) {
- WorldStats *ws = _ws;
- Actor *actor = getActor();
+ Actor *actor = getActor();
if (actor->visible()) {
// printf("Actor field_40 = 0x%02X\n", actor->field_40);
@@ -415,32 +417,32 @@ void Scene::updateActor(uint32 actorIdx) {
switch (actor->field_40) {
case 0x10:
- if (ws->numChapter == 2) {
+ if (_ws->numChapter == 2) {
// TODO: updateCharacterSub14()
- } else if (ws->numChapter == 1) {
+ } else if (_ws->numChapter == 1) {
if (_playerActorIdx == actorIdx) {
// TODO: updateActorSub21();
}
}
break;
case 0x11:
- if (ws->numChapter == 2) {
+ if (_ws->numChapter == 2) {
// TODO: put code here
- } else if (ws->numChapter == 11) {
+ } else if (_ws->numChapter == 11) {
if (_playerActorIdx == actorIdx) {
// TODO: put code here
}
}
break;
case 0xF:
- if (ws->numChapter == 2) {
+ if (_ws->numChapter == 2) {
// TODO: put code here
- } else if (ws->numChapter == 11) {
+ } else if (_ws->numChapter == 11) {
// TODO: put code here
}
break;
case 0x12:
- if (ws->numChapter == 2) {
+ if (_ws->numChapter == 2) {
// TODO: put code here
}
break;
@@ -457,9 +459,9 @@ void Scene::updateActor(uint32 actorIdx) {
}
break;
case 0xC:
- if (ws->numChapter == 2) {
+ if (_ws->numChapter == 2) {
// TODO: put code here
- } else if (ws->numChapter == 11) {
+ } else if (_ws->numChapter == 11) {
// TODO: put code here
}
case 0x1:
@@ -503,16 +505,16 @@ void Scene::updateActor(uint32 actorIdx) {
}
}
-void Scene::updateBarriers(WorldStats *worldStats) {
+void Scene::updateBarriers() {
Screen *screen = _vm->screen();
- uint barriersCount = worldStats->barriers.size();
+ uint barriersCount = _ws->barriers.size();
int startTickCount = 0;
bool canPlaySound = false;
if (barriersCount > 0) {
for (uint32 b = 0; b < barriersCount; b++) {
- Barrier *barrier = &worldStats->barriers[b];
+ Barrier *barrier = &_ws->barriers[b];
if (barrier->field_3C == 4) {
if (_ws->isBarrierVisible(b)) {
@@ -650,40 +652,38 @@ void Scene::updateMusic() {
}
void Scene::updateAdjustScreen() {
- WorldStats *ws = _ws;
-
int v5, v6, v7, v15, v16;
int v1 = -1;
int v0 = -1;
- if (ws->motionStatus == 1) {
- v5 = getActor()->x1 - ws->xLeft;
- v7 = getActor()->y1 - ws->yTop;
- if (v5 < ws->boundingRect.left || v5 > ws->boundingRect.right) {
- v15 = ws->boundingRect.left - ws->boundingRect.right;
- v1 = v15 + ws->xLeft;
- ws->xLeft += v15;
+ if (_ws->motionStatus == 1) {
+ v5 = getActor()->x1 - _ws->xLeft;
+ v7 = getActor()->y1 - _ws->yTop;
+ if (v5 < _ws->boundingRect.left || v5 > _ws->boundingRect.right) {
+ v15 = _ws->boundingRect.left - _ws->boundingRect.right;
+ v1 = v15 + _ws->xLeft;
+ _ws->xLeft += v15;
}
- if (v7 < ws->boundingRect.top || v7 > ws->boundingRect.bottom) {
- v16 = v7 - ws->boundingRect.bottom;
- v0 = v16 + ws->yTop;
- ws->yTop += v16;
+ if (v7 < _ws->boundingRect.top || v7 > _ws->boundingRect.bottom) {
+ v16 = v7 - _ws->boundingRect.bottom;
+ v0 = v16 + _ws->yTop;
+ _ws->yTop += v16;
}
if (v1 < 0)
- v1 = ws->xLeft = 0;
- if (v1 > ws->width - 640) {
- v1 = ws->width - 640;
- ws->xLeft = v1;
+ v1 = _ws->xLeft = 0;
+ if (v1 > _ws->width - 640) {
+ v1 = _ws->width - 640;
+ _ws->xLeft = v1;
}
if (v0 < 0)
- v0 = ws->yTop = 0;
- if (v0 > ws->height - 480) {
- v0 = ws->height - 480;
- ws->yTop = v0;
+ v0 = _ws->yTop = 0;
+ if (v0 > _ws->height - 480) {
+ v0 = _ws->height - 480;
+ _ws->yTop = v0;
}
} else {
- if (ws->motionStatus == 2 || ws->motionStatus == 5) {
- if (ws->motionStatus != 3) {
+ if (_ws->motionStatus == 2 || _ws->motionStatus == 5) {
+ if (_ws->motionStatus != 3) {
// TODO
/*
__asm
@@ -776,15 +776,15 @@ void Scene::updateAdjustScreen() {
}
-void Scene::OLD_UPDATE(WorldStats *worldStats) {
+void Scene::OLD_UPDATE() {
int32 curHotspot = -1;
int32 curBarrier = -1;
// DEBUGGING
// Check current walk region
- for (uint32 a = 0; a < worldStats->numActions; a++) {
- if (worldStats->actions[a].actionType == 0) {
- ActionArea *area = &worldStats->actions[a];
+ for (uint32 a = 0; a < _ws->numActions; a++) {
+ if (_ws->actions[a].actionType == 0) {
+ ActionArea *area = &_ws->actions[a];
PolyDefinitions poly = _polygons->entries[area->polyIdx];
if (poly.contains(getActor()->x, getActor()->y)) {
debugShowWalkRegion(&poly);
@@ -818,13 +818,13 @@ void Scene::OLD_UPDATE(WorldStats *worldStats) {
debugShowBarriers();
// Check if we're within a barrier
- for (uint32 p = 0; p < worldStats->numBarriers; p++) {
- Barrier b = worldStats->barriers[p];
+ for (uint32 p = 0; p < _ws->numBarriers; p++) {
+ Barrier b = _ws->barriers[p];
if (b.flags & 0x20) {
- if ((b.boundingRect.left + b.x <= _cursor->x() + worldStats->targetX) &&
- (_cursor->x() + worldStats->targetX < b.boundingRect.right + b.x) &&
- (b.boundingRect.top + b.y <= _cursor->y() + worldStats->targetY) &&
- (_cursor->y() + worldStats->targetY < b.boundingRect.bottom + b.y)) {
+ if ((b.boundingRect.left + b.x <= _cursor->x() + _ws->targetX) &&
+ (_cursor->x() + _ws->targetX < b.boundingRect.right + b.x) &&
+ (b.boundingRect.top + b.y <= _cursor->y() + _ws->targetY) &&
+ (_cursor->y() + _ws->targetY < b.boundingRect.bottom + b.y)) {
_cursor->animate();
curBarrier = (int32)p;
break;
@@ -841,8 +841,8 @@ void Scene::OLD_UPDATE(WorldStats *worldStats) {
// Update cursor if it's in a polygon hotspot
for (uint32 p = 0; p < _polygons->numEntries; p++) {
PolyDefinitions poly = _polygons->entries[p];
- if (poly.boundingRect.contains(_cursor->x() + worldStats->targetX, _cursor->y() + worldStats->targetY)) {
- if (poly.contains(_cursor->x() + worldStats->targetX, _cursor->y() + worldStats->targetY)) {
+ if (poly.boundingRect.contains(_cursor->x() + _ws->targetX, _cursor->y() + _ws->targetY)) {
+ if (poly.contains(_cursor->x() + _ws->targetX, _cursor->y() + _ws->targetY)) {
curHotspot = (int32)p;
_cursor->animate();
break;
@@ -855,21 +855,21 @@ void Scene::OLD_UPDATE(WorldStats *worldStats) {
_leftClick = false;
if (curHotspot >= 0) {
- for (uint32 a = 0; a < worldStats->numActions; a++) {
- if (worldStats->actions[a].polyIdx == (uint32)curHotspot) {
+ for (uint32 a = 0; a < _ws->numActions; a++) {
+ if (_ws->actions[a].polyIdx == (uint32)curHotspot) {
debugC(kDebugLevelScripts, "Hotspot: 0x%X - \"%s\", poly %d, action lists %d/%d, action type %d, sound res %d\n",
- worldStats->actions[a].id,
- worldStats->actions[a].name,
- worldStats->actions[a].polyIdx,
- worldStats->actions[a].actionListIdx1,
- worldStats->actions[a].actionListIdx2,
- worldStats->actions[a].actionType,
- worldStats->actions[a].soundResId);
+ _ws->actions[a].id,
+ _ws->actions[a].name,
+ _ws->actions[a].polyIdx,
+ _ws->actions[a].actionListIdx1,
+ _ws->actions[a].actionListIdx2,
+ _ws->actions[a].actionType,
+ _ws->actions[a].soundResId);
_actions->setScriptByIndex(_ws->actions[a].actionListIdx1);
}
}
} else if (curBarrier >= 0) {
- Barrier b = worldStats->barriers[curBarrier];
+ Barrier b = _ws->barriers[curBarrier];
debugC(kDebugLevelScripts, "%s: action(%d) sound(%d) flags(%d/%d)\n",
b.name,
b.actionListIdx,
@@ -893,12 +893,11 @@ int Scene::drawScene() {
_vm->screen()->clearScreen();
} else {
// Draw scene background
- WorldStats *ws = _ws;
GraphicFrame *bg = _bgResource->getFrame(0);
_vm->screen()->copyToBackBuffer(
- ((byte *)bg->surface.pixels) + ws->targetY * bg->surface.w + ws->targetX, bg->surface.w,
- ws->xLeft,
- ws->yTop,
+ ((byte *)bg->surface.pixels) + _ws->targetY * bg->surface.w + _ws->targetX, bg->surface.w,
+ _ws->xLeft,
+ _ws->yTop,
640,
480);
@@ -914,19 +913,18 @@ int Scene::drawScene() {
_vm->screen()->drawGraphicsInQueue();
// TODO: we must get rid of this
- OLD_UPDATE(ws);
+ OLD_UPDATE();
}
return 1;
}
int Scene::drawBarriers() {
- WorldStats *worldStats = _ws;
- uint barriersCount = worldStats->barriers.size();
+ uint barriersCount = _ws->barriers.size();
if (barriersCount > 0) {
for (uint32 b = 0; b < barriersCount; b++) {
- Barrier *barrier = &worldStats->barriers[b];
+ Barrier *barrier = &_ws->barriers[b];
if (!(barrier->flags & 4) && !((barrier->flags & 0xFF) & 0x40)) {
if (_ws->isBarrierOnScreen(b)) {
@@ -936,7 +934,7 @@ int Scene::drawBarriers() {
_vm->screen()->addGraphicToQueue(barrier->resId, barrier->frameIdx, barrier->x, barrier->y, (barrier->flags >> 11) & 2, barrier->field_67C - 3, barrier->priority);
} else {
// TODO: Do Cross Fade
- // parameters: barrier->resId, barrier->frameIdx, barrier->x, barrier->y, worldStats->commonRes.backgroundImage, worldStats->xLeft, worldStats->yTop, 0, 0, barrier->field_67C - 1
+ // parameters: barrier->resId, barrier->frameIdx, barrier->x, barrier->y, _ws->commonRes.backgroundImage, _ws->xLeft, _ws->yTop, 0, 0, barrier->field_67C - 1
_vm->screen()->addGraphicToQueue(barrier->resId, barrier->frameIdx, barrier->x, barrier->y, 0, 0, 0);
}
}
@@ -953,23 +951,21 @@ int Scene::drawBarriers() {
// ----------------------------------
void Scene::copyToBackBufferClipped(Graphics::Surface *surface, int x, int y) {
- WorldStats *ws = _ws;
-
- Common::Rect screenRect(ws->targetX, ws->targetY, ws->targetX + 640, ws->targetY + 480);
+ Common::Rect screenRect(_ws->targetX, _ws->targetY, _ws->targetX + 640, _ws->targetY + 480);
Common::Rect animRect(x, y, x + surface->w, y + surface->h);
animRect.clip(screenRect);
if (!animRect.isEmpty()) {
// Translate anim rectangle
- animRect.translate(-ws->targetX, -ws->targetY);
+ animRect.translate(-_ws->targetX, -_ws->targetY);
int startX = animRect.right == 640 ? 0 : surface->w - animRect.width();
int startY = animRect.bottom == 480 ? 0 : surface->h - animRect.height();
if (surface->w > 640)
- startX = ws->targetX;
+ startX = _ws->targetX;
if (surface->h > 480)
- startY = ws->targetY;
+ startY = _ws->targetY;
_vm->screen()->copyToBackBufferWithTransparency(
((byte*)surface->pixels) +
@@ -988,19 +984,17 @@ void Scene::copyToBackBufferClipped(Graphics::Surface *surface, int x, int y) {
// ----------------------------------
void Scene::debugScreenScrolling(GraphicFrame *bg) {
- WorldStats *ws = _ws;
-
- // Horizontal scrolling
- if (_cursor->x() < SCREEN_EDGES && ws->targetX >= SCROLL_STEP)
- ws->targetX -= SCROLL_STEP;
- else if (_cursor->x() > 640 - SCREEN_EDGES && ws->targetX <= bg->surface.w - 640 - SCROLL_STEP)
- ws->targetX += SCROLL_STEP;
+ // Horizontal scrolling
+ if (_cursor->x() < SCREEN_EDGES && _ws->targetX >= SCROLL_STEP)
+ _ws->targetX -= SCROLL_STEP;
+ else if (_cursor->x() > 640 - SCREEN_EDGES && _ws->targetX <= bg->surface.w - 640 - SCROLL_STEP)
+ _ws->targetX += SCROLL_STEP;
// Vertical scrolling
- if (_cursor->y() < SCREEN_EDGES && ws->targetY >= SCROLL_STEP)
- ws->targetY -= SCROLL_STEP;
- else if (_cursor->y() > 480 - SCREEN_EDGES && ws->targetY <= bg->surface.h - 480 - SCROLL_STEP)
- ws->targetY += SCROLL_STEP;
+ if (_cursor->y() < SCREEN_EDGES && _ws->targetY >= SCROLL_STEP)
+ _ws->targetY -= SCROLL_STEP;
+ else if (_cursor->y() > 480 - SCREEN_EDGES && _ws->targetY <= bg->surface.h - 480 - SCROLL_STEP)
+ _ws->targetY += SCROLL_STEP;
}
// WALK REGION DEBUG
diff --git a/engines/asylum/scene.h b/engines/asylum/scene.h
index db9046ba5f..85af266f95 100644
--- a/engines/asylum/scene.h
+++ b/engines/asylum/scene.h
@@ -109,7 +109,7 @@ private:
int updateScene();
void updateMouse();
void updateActor(uint32 actorIdx);
- void updateBarriers(WorldStats *worldStats);
+ void updateBarriers();
void updateAmbientSounds();
void updateMusic();
void updateAdjustScreen();
@@ -127,7 +127,7 @@ private:
void debugShowWalkRegion(PolyDefinitions *poly);
// TODO: get rid of this
- void OLD_UPDATE(WorldStats *worldStats);
+ void OLD_UPDATE();
}; // end of class Scene
Commit: d91d5e5e5f187a5a4f1ce4db123ddb01b461f840
https://github.com/scummvm/scummvm/commit/d91d5e5e5f187a5a4f1ce4db123ddb01b461f840
Author: Alexandre Fontoura (alexandrefontoura at gmail.com)
Date: 2021-05-17T15:35:50+02:00
Commit Message:
ASYLUM: Fixed some warnings.
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@359 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/actor.cpp
engines/asylum/actor.h
engines/asylum/polygons.cpp
engines/asylum/scene.cpp
diff --git a/engines/asylum/actor.cpp b/engines/asylum/actor.cpp
index 3b15fcf6b0..98eff43f9c 100644
--- a/engines/asylum/actor.cpp
+++ b/engines/asylum/actor.cpp
@@ -125,7 +125,7 @@ GraphicFrame *Actor::getFrame() {
return frame;
}
-void Actor::drawActorAt(uint16 curX, uint16 curY) {
+void Actor::drawActorAt(uint32 curX, uint32 curY) {
GraphicFrame *frame = getFrame();
WorldStats *ws = _scene->worldstats();
@@ -162,7 +162,7 @@ void Actor::setWalkArea(ActionArea *target) {
}
}
-void Actor::walkTo(uint16 curX, uint16 curY) {
+void Actor::walkTo(uint32 curX, uint32 curY) {
int newAction = currentAction;
WorldStats *ws = _scene->worldstats();
@@ -170,15 +170,15 @@ void Actor::walkTo(uint16 curX, uint16 curY) {
// actor in a given direction
int step = 2;
- uint16 newX = x;
- uint16 newY = y;
+ uint32 newX = x;
+ uint32 newY = y;
bool done = false;
// Walking left...
if (curX < x) {
newAction = kWalkW;
newX -= step;
- if (ABS(curY - y) <= 30)
+ if (ABS((int32)curY - (int32)y) <= 30)
done = true;
}
@@ -186,7 +186,7 @@ void Actor::walkTo(uint16 curX, uint16 curY) {
if (curX > x) {
newAction = kWalkE;
newX += step;
- if (ABS(curY - y) <= 30)
+ if (ABS((int32)curY - (int32)y) <= 30)
done = true;
}
@@ -361,7 +361,7 @@ void Actor::faceTarget(int targetId, int targetType) {
}
int Actor::getAngle(int ax1, int ay1, int ax2, int ay2) {
- uint32 v5 = (ax2 << 16) - (ax1 << 16);
+ int32 v5 = (ax2 << 16) - (ax1 << 16);
int v6 = 0;
int v4 = (ay1 << 16) - (ay2 << 16);
diff --git a/engines/asylum/actor.h b/engines/asylum/actor.h
index af8e72c778..ec5711faef 100644
--- a/engines/asylum/actor.h
+++ b/engines/asylum/actor.h
@@ -168,9 +168,9 @@ public:
void setWalkArea(ActionArea *target);
void setAction(int action);
void setActionByIndex(int index);
- void drawActorAt(uint16 curX, uint16 curY);
+ void drawActorAt(uint32 curX, uint32 curY);
void drawActor();
- void walkTo(uint16 curX, uint16 curY);
+ void walkTo(uint32 curX, uint32 curY);
int currentAction; // TODO depreciate
diff --git a/engines/asylum/polygons.cpp b/engines/asylum/polygons.cpp
index c5678be153..9eedc08b74 100644
--- a/engines/asylum/polygons.cpp
+++ b/engines/asylum/polygons.cpp
@@ -32,7 +32,7 @@ Polygons::Polygons(Common::SeekableReadStream *stream) {
}
Polygons::~Polygons() {
- for (int i = 0; i < numEntries; i++)
+ for (uint32 i = 0; i < numEntries; i++)
delete[] entries[i].points;
entries.clear();
diff --git a/engines/asylum/scene.cpp b/engines/asylum/scene.cpp
index 0341580a5f..5961c44165 100644
--- a/engines/asylum/scene.cpp
+++ b/engines/asylum/scene.cpp
@@ -170,13 +170,13 @@ void Scene::setScenePosition(int x, int y)
if (_ws->targetX < 0)
_ws->targetX = 0;
- if (_ws->targetX > (bg->surface.w - 640))
+ if (_ws->targetX > (uint32)(bg->surface.w - 640))
_ws->targetX = bg->surface.w - 640;
if (_ws->targetY < 0)
_ws->targetY = 0;
- if (_ws->targetY > (bg->surface.h - 480))
+ if (_ws->targetY > (uint32)(bg->surface.h - 480))
_ws->targetY = bg->surface.h - 480;
}
@@ -290,9 +290,9 @@ void Scene::updateMouse() {
int dir = -1;
bool done = false;
- if (_cursor->x() < actorPos.left) {
- if (_cursor->y() >= actorPos.top) {
- if (_cursor->y() > actorPos.bottom) {
+ if (_cursor->x() < (uint32)actorPos.left) {
+ if (_cursor->y() >= (uint32)actorPos.top) {
+ if (_cursor->y() > (uint32)actorPos.bottom) {
if (getActor()->direction == 2) {
if (_cursor->y() - actorPos.bottom > 10)
dir = 3;
@@ -333,9 +333,9 @@ void Scene::updateMouse() {
done = true;
}
- if (!done && _cursor->x() <= actorPos.right) {
- if (_cursor->y() >= actorPos.top) {
- if (_cursor->y() > actorPos.bottom) {
+ if (!done && _cursor->x() <= (uint32)actorPos.right) {
+ if (_cursor->y() >= (uint32)actorPos.top) {
+ if (_cursor->y() > (uint32)actorPos.bottom) {
if (getActor()->direction == 3) {
if (_cursor->x() - actorPos.left > 10)
dir = 4;
@@ -364,7 +364,7 @@ void Scene::updateMouse() {
done = true;
}
- if (!done && _cursor->y() < actorPos.top) {
+ if (!done && _cursor->y() < (uint32)actorPos.top) {
if (getActor()->direction) {
if (getActor()->direction == 6) {
if (actorPos.top - _cursor->y() > 10)
@@ -379,7 +379,7 @@ void Scene::updateMouse() {
done = true;
}
- if (!done && _cursor->y() <= actorPos.bottom) {
+ if (!done && _cursor->y() <= (uint32)actorPos.bottom) {
if (getActor()->direction == 5) {
if (actorPos.bottom - _cursor->y() > 10)
dir = 6;
@@ -652,7 +652,7 @@ void Scene::updateMusic() {
}
void Scene::updateAdjustScreen() {
- int v5, v6, v7, v15, v16;
+ int v5, v7, v15, v16; //, v6
int v1 = -1;
int v0 = -1;
@@ -671,13 +671,13 @@ void Scene::updateAdjustScreen() {
}
if (v1 < 0)
v1 = _ws->xLeft = 0;
- if (v1 > _ws->width - 640) {
+ if ((uint32)v1 > _ws->width - 640) {
v1 = _ws->width - 640;
_ws->xLeft = v1;
}
if (v0 < 0)
v0 = _ws->yTop = 0;
- if (v0 > _ws->height - 480) {
+ if ((uint32)v0 > _ws->height - 480) {
v0 = _ws->height - 480;
_ws->yTop = v0;
}
@@ -957,7 +957,7 @@ void Scene::copyToBackBufferClipped(Graphics::Surface *surface, int x, int y) {
if (!animRect.isEmpty()) {
// Translate anim rectangle
- animRect.translate(-_ws->targetX, -_ws->targetY);
+ animRect.translate(-(int16)_ws->targetX, -(int16)_ws->targetY);
int startX = animRect.right == 640 ? 0 : surface->w - animRect.width();
int startY = animRect.bottom == 480 ? 0 : surface->h - animRect.height();
@@ -987,13 +987,13 @@ void Scene::debugScreenScrolling(GraphicFrame *bg) {
// Horizontal scrolling
if (_cursor->x() < SCREEN_EDGES && _ws->targetX >= SCROLL_STEP)
_ws->targetX -= SCROLL_STEP;
- else if (_cursor->x() > 640 - SCREEN_EDGES && _ws->targetX <= bg->surface.w - 640 - SCROLL_STEP)
+ else if (_cursor->x() > 640 - SCREEN_EDGES && _ws->targetX <= (uint32)bg->surface.w - 640 - SCROLL_STEP)
_ws->targetX += SCROLL_STEP;
// Vertical scrolling
if (_cursor->y() < SCREEN_EDGES && _ws->targetY >= SCROLL_STEP)
_ws->targetY -= SCROLL_STEP;
- else if (_cursor->y() > 480 - SCREEN_EDGES && _ws->targetY <= bg->surface.h - 480 - SCROLL_STEP)
+ else if (_cursor->y() > 480 - SCREEN_EDGES && _ws->targetY <= (uint32)bg->surface.h - 480 - SCROLL_STEP)
_ws->targetY += SCROLL_STEP;
}
Commit: a422a0db00608003d89380b07d38f358e4e4f163
https://github.com/scummvm/scummvm/commit/a422a0db00608003d89380b07d38f358e4e4f163
Author: Alexandre Fontoura (alexandrefontoura at gmail.com)
Date: 2021-05-17T15:35:50+02:00
Commit Message:
ASYLUM: Scene actors init stuffs
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@360 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/actionlist.cpp
engines/asylum/actor.cpp
engines/asylum/actor.h
engines/asylum/scene.cpp
engines/asylum/worldstats.cpp
diff --git a/engines/asylum/actionlist.cpp b/engines/asylum/actionlist.cpp
index 55e7dc7161..d977bc8910 100644
--- a/engines/asylum/actionlist.cpp
+++ b/engines/asylum/actionlist.cpp
@@ -599,7 +599,7 @@ int kEnableActor(ActionCommand *cmd, Scene *scn) {
else
actorIndex = cmd->param1;
- if (scn->worldstats()->actors[actorIndex].field_40 == 5)
+ if (scn->worldstats()->actors[actorIndex].updateType == 5)
scn->actions()->enableActorSub(actorIndex, 4);
return 0;
@@ -993,10 +993,10 @@ int kChangeActorField40(ActionCommand *cmd, Scene *scn) {
int fieldType = cmd->param2;
if (fieldType) {
- if (scn->worldstats()->actors[actorIdx].field_40 < 11)
- scn->worldstats()->actors[actorIdx].field_40 = 14;
+ if (scn->worldstats()->actors[actorIdx].updateType < 11)
+ scn->worldstats()->actors[actorIdx].updateType = 14;
} else {
- scn->worldstats()->actors[actorIdx].field_40 = 4;
+ scn->worldstats()->actors[actorIdx].updateType = 4;
}
return -1;
diff --git a/engines/asylum/actor.cpp b/engines/asylum/actor.cpp
index 98eff43f9c..ec27854188 100644
--- a/engines/asylum/actor.cpp
+++ b/engines/asylum/actor.cpp
@@ -275,19 +275,39 @@ void Actor::walkTo(uint32 curX, uint32 curY) {
}
void Actor::update_4072A0(int param) {
+ int newGrId = 0;
+ int newDir = 0;
+
switch (param) {
+ case 4:
+ case 6:
+ case 14:
+ if(this->direction > 4)
+ newDir = 8 - this->direction;
+ else
+ newDir = this->direction;
+ newGrId = this->grResTable[newDir + 5];
+ break;
+
case 5:
- int dir = direction;
- if (dir > 4)
- direction = 8 - dir;
+ newDir = this->direction;
+ if (newDir > 4)
+ this->direction = 8 - newDir;
- setAction(dir + 5);
+ setAction(newDir + 5);
break;
}
- field_40 = param;
+ this->grResId = newGrId;
+
+ GraphicResource *gra = new GraphicResource(_resPack, this->grResId);
+ this->frameCount = gra->getFrameCount();
+ this->frameNum = 0;
+ delete gra;
+
+ this->updateType = param;
}
void Actor::setPosition_40A260(uint32 newX, uint32 newY, int newDirection, int frame) {
diff --git a/engines/asylum/actor.h b/engines/asylum/actor.h
index ec5711faef..ad020df7bf 100644
--- a/engines/asylum/actor.h
+++ b/engines/asylum/actor.h
@@ -188,7 +188,7 @@ public:
Common::Rect boundingRect;
uint32 direction;
uint32 field_3C;
- uint32 field_40; // XXX Character Id???
+ uint32 updateType;
uint32 field_44;
uint32 field_48;
uint32 flags;
diff --git a/engines/asylum/scene.cpp b/engines/asylum/scene.cpp
index 5961c44165..ed3128941b 100644
--- a/engines/asylum/scene.cpp
+++ b/engines/asylum/scene.cpp
@@ -115,8 +115,31 @@ Scene::Scene(uint8 sceneIdx, AsylumEngine *vm): _vm(vm) {
_vm->screen()->clearGraphicsInQueue();
_ws->motionStatus = 1;
- // TODO: do some rect stuffs from player actor
- // TODO: reset actors flags
+ _ws->actors[_playerActorIdx].boundingRect.bottom = _ws->actors[_playerActorIdx].y2;
+ _ws->actors[_playerActorIdx].boundingRect.right = 2 * _ws->actors[_playerActorIdx].x2;
+ _ws->boundingRect = Common::Rect(195, 115, 445 - _ws->actors[_playerActorIdx].boundingRect.right, 345 - _ws->actors[_playerActorIdx].boundingRect.bottom);
+
+ _ws->actors[_playerActorIdx].flags |= 1;
+ _ws->actors[_playerActorIdx].update_4072A0(4);
+
+ _ws->actors[_playerActorIdx].x1 -= _ws->actors[_playerActorIdx].x2;
+ _ws->actors[_playerActorIdx].y1 -= _ws->actors[_playerActorIdx].y2;
+
+ if(_ws->numActors > 1)
+ {
+ for (uint32 a = 1; a < _ws->numActors; a++) {
+ Actor *actor= &_ws->actors[a];
+ actor->flags |= 1;
+ actor->direction = 1;
+ actor->update_4072A0(4);
+ actor->x1 -= actor->x2;
+ actor->y1 -= actor->y2;
+ actor->boundingRect.bottom = actor->y2;
+ actor->boundingRect.right = 2 * actor->x2;
+ }
+ }
+
+ // TODO: init action list
}
Scene::~Scene() {
@@ -412,9 +435,9 @@ void Scene::updateActor(uint32 actorIdx) {
Actor *actor = getActor();
if (actor->visible()) {
- // printf("Actor field_40 = 0x%02X\n", actor->field_40);
+ // printf("Actor updateType = 0x%02X\n", actor->updateType);
- switch (actor->field_40) {
+ switch (actor->updateType) {
case 0x10:
if (_ws->numChapter == 2) {
diff --git a/engines/asylum/worldstats.cpp b/engines/asylum/worldstats.cpp
index 76f6b31fe7..aaae03f95a 100644
--- a/engines/asylum/worldstats.cpp
+++ b/engines/asylum/worldstats.cpp
@@ -300,7 +300,7 @@ void WorldStats::load(Common::SeekableReadStream *stream) {
actor.direction = stream->readUint32LE();
actor.field_3C = stream->readUint32LE();
- actor.field_40 = stream->readUint32LE();
+ actor.updateType = stream->readUint32LE();
actor.field_44 = stream->readUint32LE();
actor.field_48 = stream->readUint32LE();
actor.flags = stream->readUint32LE();
Commit: 461ddd8dd03f3d14f4b03b4735180fdd61118c7f
https://github.com/scummvm/scummvm/commit/461ddd8dd03f3d14f4b03b4735180fdd61118c7f
Author: Alexandre Fontoura (alexandrefontoura at gmail.com)
Date: 2021-05-17T15:35:50+02:00
Commit Message:
ASYLUM: First steps on drawing actors with priority.
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@361 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/actionlist.cpp
engines/asylum/actor.cpp
engines/asylum/actor.h
engines/asylum/scene.cpp
engines/asylum/scene.h
engines/asylum/screen.cpp
engines/asylum/screen.h
engines/asylum/worldstats.cpp
diff --git a/engines/asylum/actionlist.cpp b/engines/asylum/actionlist.cpp
index d977bc8910..747dfcc4b8 100644
--- a/engines/asylum/actionlist.cpp
+++ b/engines/asylum/actionlist.cpp
@@ -586,7 +586,7 @@ int kDisableActor(ActionCommand *cmd, Scene *scn) {
actorIndex = cmd->param1;
// TODO Finish implementing this function
- scn->getActor()->update_4072A0(actorIndex);
+ //scn->getActor()->update_4072A0(actorIndex);
return -1;
}
diff --git a/engines/asylum/actor.cpp b/engines/asylum/actor.cpp
index ec27854188..551b5e0660 100644
--- a/engines/asylum/actor.cpp
+++ b/engines/asylum/actor.cpp
@@ -43,8 +43,8 @@ Actor::~Actor() {
}
void Actor::setPosition(uint32 targetX, uint32 targetY) {
- boundingRect.left = targetX;
- boundingRect.top = targetY;
+ //boundingRect.left = targetX;
+ //boundingRect.top = targetY;
x = targetX;
y = targetY;
diff --git a/engines/asylum/actor.h b/engines/asylum/actor.h
index ad020df7bf..06c8b8e06f 100644
--- a/engines/asylum/actor.h
+++ b/engines/asylum/actor.h
@@ -190,7 +190,7 @@ public:
uint32 field_3C;
uint32 updateType;
uint32 field_44;
- uint32 field_48;
+ uint32 priority;
uint32 flags;
uint32 field_50;
uint32 field_54;
@@ -222,7 +222,19 @@ public:
uint32 soundResId; // field_93C
uint32 field_940;
uint32 field_944;
- // TODO field_948 till field_978
+ uint32 field_948;
+ uint32 field_94C;
+ uint32 field_950;
+ uint32 field_954;
+ uint32 field_958;
+ uint32 field_95C;
+ uint32 field_960;
+ uint32 field_964;
+ uint32 field_968;
+ uint32 field_96C;
+ uint32 field_970;
+ uint32 field_974;
+ uint32 field_978;
uint32 actionIdx1;
// TODO field_980 till field_9A0
diff --git a/engines/asylum/scene.cpp b/engines/asylum/scene.cpp
index ed3128941b..1aa2490464 100644
--- a/engines/asylum/scene.cpp
+++ b/engines/asylum/scene.cpp
@@ -929,7 +929,7 @@ int Scene::drawScene() {
//debugScreenScrolling(bg);
// TODO: prepare Actors and Barriers draw
- // TODO: draw actors
+ drawActors();
drawBarriers();
// TODO: draw main actor stuff
@@ -942,6 +942,45 @@ int Scene::drawScene() {
return 1;
}
+void Scene::getActorPosition(Actor *actor, Common::Point *pt) {
+ pt->x = actor->x1 - _ws->xLeft;
+ pt->y = actor->y1 - _ws->yTop;
+}
+
+int Scene::drawActors() {
+
+ if (_ws->numActors > 0)
+ {
+ Common::Point pt;
+ for (uint32 a = 0; a < _ws->numActors; a++) {
+ Actor *actor = &_ws->actors[a];
+
+ if ((actor->flags & 0xFF) & 1) { // check this mask
+ getActorPosition(actor, &pt);
+ //pt.x += actor->x;
+ //pt.y += actor->y;
+
+ uint32 frameNum = actor->frameNum;
+ if (actor->frameNum >= actor->frameCount) {
+ frameNum = 2 * actor->frameCount - actor->frameNum - 1;
+ }
+
+ if ((actor->flags & 0xFF) & 2) {
+ // TODO: sub_40AC10
+
+
+
+ } else {
+ // TODO: get flag value from character_DeadSarah_sub_40A140
+ _vm->screen()->addGraphicToQueue(actor->grResId, frameNum, pt.x, pt.y, ((actor->direction < 5) - 1) & 2, actor->field_96C, actor->priority);
+ }
+ }
+ }
+ }
+
+ return 1;
+}
+
int Scene::drawBarriers() {
uint barriersCount = _ws->barriers.size();
@@ -1083,4 +1122,22 @@ void Scene::debugShowBarriers() {
}
}
+// BARRIER DEBUGGING
+void Scene::debugShowActors() {
+ for (uint32 p = 0; p < _ws->numActors; p++) {
+ Graphics::Surface surface;
+ Actor a = _ws->actors[p];
+
+ if (a.flags & 2) {
+ surface.create(a.boundingRect.right - a.boundingRect.left + 1,
+ a.boundingRect.bottom - a.boundingRect.top + 1,
+ 1);
+ surface.frameRect(a.boundingRect, 0x22);
+ copyToBackBufferClipped(&surface, a.x, a.y);
+ }
+
+ surface.free();
+ }
+}
+
} // end of namespace Asylum
diff --git a/engines/asylum/scene.h b/engines/asylum/scene.h
index 85af266f95..d62548f2dc 100644
--- a/engines/asylum/scene.h
+++ b/engines/asylum/scene.h
@@ -114,16 +114,19 @@ private:
void updateMusic();
void updateAdjustScreen();
int drawScene();
+ int drawActors();
int drawBarriers();
bool isBarrierVisible(BarrierItem *barrier);
bool isBarrierOnScreen(BarrierItem *barrier);
uint32 getRandomResId(BarrierItem *barrier);
+ void getActorPosition(Actor *actor, Common::Point *pt);
void copyToBackBufferClipped(Graphics::Surface *surface, int x, int y);
void debugScreenScrolling(GraphicFrame *bg);
void debugShowPolygons();
void debugShowBarriers();
+ void debugShowActors();
void debugShowWalkRegion(PolyDefinitions *poly);
// TODO: get rid of this
diff --git a/engines/asylum/screen.cpp b/engines/asylum/screen.cpp
index 8416b76f37..613e09c3c7 100644
--- a/engines/asylum/screen.cpp
+++ b/engines/asylum/screen.cpp
@@ -114,19 +114,20 @@ void Screen::clearScreen() {
_vm->_system->fillScreen(0);
}
-void Screen::addGraphicToQueue(uint32 redId, uint32 frameIdx, uint32 x, uint32 y, uint32 flags, uint32 transTableNum, uint32 priority) {
+void Screen::addGraphicToQueue(uint32 resId, uint32 frameIdx, uint32 x, uint32 y, uint32 flags, uint32 transTableNum, uint32 priority) {
GraphicQueueItem item;
- item.resId = redId;
+ item.resId = resId;
item.x = x;
item.y = y;
item.frameIdx = frameIdx;
item.flags = flags;
+ item.transTableNum = transTableNum;
item.priority = priority;
_queueItems.push_back(item);
}
-void Screen::addCrossFadeGraphicToQueue(uint32 redId, uint32 frameIdx, uint32 x, uint32 y, uint32 redId2, uint32 x2, uint32 y2, uint32 flags, uint32 priority) {
+void Screen::addCrossFadeGraphicToQueue(uint32 resId, uint32 frameIdx, uint32 x, uint32 y, uint32 redId2, uint32 x2, uint32 y2, uint32 flags, uint32 priority) {
}
diff --git a/engines/asylum/screen.h b/engines/asylum/screen.h
index 57694595ba..9d05988466 100644
--- a/engines/asylum/screen.h
+++ b/engines/asylum/screen.h
@@ -61,8 +61,8 @@ public:
void drawWideScreen(int16 barSize);
void clearScreen();
- void addGraphicToQueue(uint32 redId, uint32 frameIdx, uint32 x, uint32 y, uint32 flags, uint32 transTableNum, uint32 priority);
- void addCrossFadeGraphicToQueue(uint32 redId, uint32 frameIdx, uint32 x, uint32 y, uint32 redId2, uint32 x2, uint32 y2, uint32 flags, uint32 priority);
+ void addGraphicToQueue(uint32 resId, uint32 frameIdx, uint32 x, uint32 y, uint32 flags, uint32 transTableNum, uint32 priority);
+ void addCrossFadeGraphicToQueue(uint32 resId, uint32 frameIdx, uint32 x, uint32 y, uint32 redId2, uint32 x2, uint32 y2, uint32 flags, uint32 priority);
void addGraphicToQueue(GraphicQueueItem item);
void drawGraphicsInQueue();
void clearGraphicsInQueue();
diff --git a/engines/asylum/worldstats.cpp b/engines/asylum/worldstats.cpp
index aaae03f95a..e4aac73808 100644
--- a/engines/asylum/worldstats.cpp
+++ b/engines/asylum/worldstats.cpp
@@ -281,7 +281,7 @@ void WorldStats::load(Common::SeekableReadStream *stream) {
for (uint32 a = 0; a < numActors; a++) {
int i;
Actor actor;
-
+
actor.x = stream->readUint32LE();
actor.y = stream->readUint32LE();
actor.grResId = stream->readUint32LE();
@@ -302,7 +302,7 @@ void WorldStats::load(Common::SeekableReadStream *stream) {
actor.field_3C = stream->readUint32LE();
actor.updateType = stream->readUint32LE();
actor.field_44 = stream->readUint32LE();
- actor.field_48 = stream->readUint32LE();
+ actor.priority = stream->readUint32LE();
actor.flags = stream->readUint32LE();
actor.field_50 = stream->readUint32LE();
actor.field_54 = stream->readUint32LE();
@@ -347,10 +347,21 @@ void WorldStats::load(Common::SeekableReadStream *stream) {
actor.field_934 = stream->readUint32LE();
actor.field_938 = stream->readUint32LE();
actor.soundResId = stream->readUint32LE();
-
- // TODO skip field_940 till field_978
- stream->skip(0x3C);
-
+ actor.field_940 = stream->readUint32LE();
+ actor.field_944 = stream->readUint32LE();
+ actor.field_948 = stream->readUint32LE();
+ actor.field_94C = stream->readUint32LE();
+ actor.field_950 = stream->readUint32LE();
+ actor.field_954 = stream->readUint32LE();
+ actor.field_958 = stream->readUint32LE();
+ actor.field_95C = stream->readUint32LE();
+ actor.field_960 = stream->readUint32LE();
+ actor.field_964 = stream->readUint32LE();
+ actor.field_968 = stream->readUint32LE();
+ actor.field_96C = stream->readUint32LE();
+ actor.field_970 = stream->readUint32LE();
+ actor.field_974 = stream->readUint32LE();
+ actor.field_978 = stream->readUint32LE();
actor.actionIdx1 = stream->readUint32LE();
// TODO skip field_980 till field_9A0
Commit: 52206f118933effa8ab8a7b465c76d97e985428f
https://github.com/scummvm/scummvm/commit/52206f118933effa8ab8a7b465c76d97e985428f
Author: Alex Bevilacqua (alexbevi at gmail.com)
Date: 2021-05-17T15:35:50+02:00
Commit Message:
ASYLUM: NEW SOUND SUBSYSTEM! This is still sort of WIP though because it's not a "true" implementation (direct from disassembly). It also doesn't really do anything with the new ambient sound queue, but the functionality's there for when we make more progress on the AmbientSoundItem initializations.
Also started to re-write updateBarriers(). The original is there as updateBarriers2() for the time being.
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@362 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/actionlist.cpp
engines/asylum/asylum.cpp
engines/asylum/asylum.h
engines/asylum/blowuppuzzle.cpp
engines/asylum/blowuppuzzle.h
engines/asylum/menu.cpp
engines/asylum/respack.cpp
engines/asylum/respack.h
engines/asylum/scene.cpp
engines/asylum/scene.h
engines/asylum/sound.cpp
engines/asylum/sound.h
engines/asylum/worldstats.cpp
engines/asylum/worldstats.h
diff --git a/engines/asylum/actionlist.cpp b/engines/asylum/actionlist.cpp
index 747dfcc4b8..a19bc67e90 100644
--- a/engines/asylum/actionlist.cpp
+++ b/engines/asylum/actionlist.cpp
@@ -611,10 +611,8 @@ int kEnableBarriers(ActionCommand *cmd, Scene *scn) {
uint32 v59 = cmd->param2;
if (!scn->actions()->getScript()->counter && scn->getSceneIndex() != 13 && sndIdx != 0) {
- ResourcePack *sfx = new ResourcePack(18);
- scn->vm()->sound()->playSfx(sfx, ((unsigned int)(sndIdx != 0) & 5) + 0x80120001);
- delete sfx;
- //scn->vm()->sound()->playSfx(scn->getSpeechPack(),sndIdx + 86);
+ scn->vm()->sound()->playSound(((sndIdx != 0) & 5) + 0x80120001,
+ false, scn->vm()->soundVolume(), 0);
}
if (scn->actions()->getScript()->counter >= 3 * v59 - 1) {
@@ -805,7 +803,7 @@ int kPlayMovie(ActionCommand *cmd, Scene *scn) {
int kStopAllBarriersSounds(ActionCommand *cmd, Scene *scn) {
// TODO: do this for all barriers that have sfx playing
- scn->vm()->sound()->stopSfx();
+ scn->vm()->sound()->stopAllSounds();
return -1;
}
@@ -934,9 +932,9 @@ int kPlaySpeech(ActionCommand *cmd, Scene *scn) {
if ((int)sndIdx >= 0) {
if (sndIdx >= 259) {
sndIdx -= 9;
- scn->vm()->sound()->playSfx(scn->getSpeechPack(), sndIdx - 0x7FFD0000);
+ scn->vm()->sound()->playSpeech(sndIdx - 0x7FFD0000);
} else {
- scn->vm()->sound()->playSfx(scn->getSpeechPack(), sndIdx);
+ scn->vm()->sound()->playSpeech(sndIdx);
}
} else
debugC(kDebugLevelScripts,
diff --git a/engines/asylum/asylum.cpp b/engines/asylum/asylum.cpp
index d9af080da6..08bf9bcf51 100644
--- a/engines/asylum/asylum.cpp
+++ b/engines/asylum/asylum.cpp
@@ -54,6 +54,10 @@ AsylumEngine::AsylumEngine(OSystem *system, Common::Language language)
g_eventRec.registerRandomSource(_rnd, "asylum");
memset(_gameFlags, 0, 1512);
+
+ // initialize default configuration
+ _ambientVolume = 0;
+ _soundVolume = 0;
}
AsylumEngine::~AsylumEngine() {
@@ -149,22 +153,18 @@ void AsylumEngine::waitForTimer(int msec_delay) {
void AsylumEngine::playIntro() {
_video->playVideo(1, kSubtitlesOn);
+
if (_scene->worldstats()->musicCurrentResId != 0xFFFFFD66)
- _sound->playMusic(_scene->getMusicPack(),
- _scene->worldstats()->musicCurrentResId);
+ _sound->playMusic(_scene->worldstats()->musicCurrentResId);
_screen->clearScreen();
setGameFlag(4);
setGameFlag(12);
- ResourcePack *introRes = new ResourcePack(18);
-
- _sound->playSfx(introRes, 7);
-
- _introPlaying = true;
-
- delete introRes;
+ // Play the intro sound sample (the screen is blacked out, you hear
+ // an alarm sounding and men talking about.
+ _sound->playSound(0x8012007, false, _soundVolume, 0);
}
void AsylumEngine::checkForEvent(bool doUpdate) { // k_sub_40AE30 (0040AE30)
@@ -178,7 +178,7 @@ void AsylumEngine::checkForEvent(bool doUpdate) { // k_sub_40AE30 (0040AE30)
// by moving the logic to the event loop and checking whether a flag is
// set to determine if control should be returned to the engine.
if (_introPlaying) {
- if (!_sound->isSfxActive()) {
+ if (!_sound->isPlaying(0x8012007)) {
_introPlaying = false;
// TODO Since we've currently only got one sfx handle to play with in
@@ -258,7 +258,7 @@ void AsylumEngine::processDelayedEvents() {
int videoIdx = _scene->actions()->delayedVideoIndex;
if (videoIdx >= 0) {
_sound->stopMusic();
- _sound->stopSfx();
+ _sound->stopAllSounds();
_video->playVideo(videoIdx, kSubtitlesOn);
_scene->actions()->delayedVideoIndex = -1;
@@ -272,7 +272,7 @@ void AsylumEngine::processDelayedEvents() {
int sceneIdx = _scene->actions()->delayedSceneIndex;
if (sceneIdx >=0 && !_scene->actions()->processing) {
_sound->stopMusic();
- _sound->stopSfx();
+ _sound->stopAllSounds();
if (_scene)
delete _scene;
diff --git a/engines/asylum/asylum.h b/engines/asylum/asylum.h
index 0bd6894603..00f75069fa 100644
--- a/engines/asylum/asylum.h
+++ b/engines/asylum/asylum.h
@@ -39,6 +39,17 @@
namespace Asylum {
+// XXX
+// I'm not sure if system endian-ness would have any
+// effect byte order of the data files, but I guess
+// it won't hurt to keep this here until we can test
+// on a big-endian system
+#ifndef SCUMM_BIG_ENDIAN
+#define LOBYTE(word) (word & 0xFF)
+#else
+#define LOBYTE(word) ((word >> 24) & 0xFF)
+#endif
+
class Console;
class Scene;
class MainMenu;
@@ -83,6 +94,9 @@ public:
Screen* screen() { return _screen; }
Scene* scene() { return _scene; }
+ int ambientVolume() { return _ambientVolume; }
+ int soundVolume() { return _soundVolume; }
+
private:
void checkForEvent(bool doUpdate);
void waitForTimer(int msec_delay);
@@ -93,6 +107,9 @@ private:
Common::Language _language;
Common::RandomSource _rnd;
+ int _ambientVolume;
+ int _soundVolume;
+
bool _introPlaying;
Console *_console;
diff --git a/engines/asylum/blowuppuzzle.cpp b/engines/asylum/blowuppuzzle.cpp
index 18669b7ea0..4611067a24 100644
--- a/engines/asylum/blowuppuzzle.cpp
+++ b/engines/asylum/blowuppuzzle.cpp
@@ -111,6 +111,12 @@ void BlowUpPuzzleVCR::handleEvent(Common::Event *event, bool doUpdate) {
update();
}
+void BlowUpPuzzle::playSound(uint resourceId) {
+ ResourceEntry *resource = _scene->getResourcePack()->getResource(resourceId);
+ int volume = _scene->vm()->soundVolume();
+ _scene->vm()->sound()->playSound(resource, false, volume, 0);
+}
+
int BlowUpPuzzleVCR::inPolyRegion(int x, int y, int polyIdx) {
return x >= BlowUpPuzzleVCRPolies[polyIdx].left && x <= BlowUpPuzzleVCRPolies[polyIdx].right &&
y >= BlowUpPuzzleVCRPolies[polyIdx].top && y <= BlowUpPuzzleVCRPolies[polyIdx].bottom;
@@ -318,13 +324,13 @@ int BlowUpPuzzleVCR::setJackOnHole(int jackType, JackState plugged) {
if(_jacksState[jackType-1] == kOnHand) {
_jacksState[jackType-1] = plugged;
_holesState[plugged-1] = jackType; // set jack on red
- _scene->vm()->sound()->playSfx(_scene->getResourcePack(), _scene->worldstats()->grResId[44]);
+ playSound(_scene->worldstats()->grResId[44]);
}
} else if(jackType == 0) {
jackType = _holesState[plugged-1];
_jacksState[jackType-1] = kOnHand;
_holesState[plugged-1] = 0;
- _scene->vm()->sound()->playSfx(_scene->getResourcePack(), _scene->worldstats()->grResId[43]);
+ playSound(_scene->worldstats()->grResId[43]);
return 0;
}
return 1;
@@ -500,7 +506,7 @@ void BlowUpPuzzleVCR::handleMouseDown() {
if (_cursor->x() >= (uint32)BlowUpPuzzleVCRPolies[kBlackJack].left && _cursor->x() <= (uint32)BlowUpPuzzleVCRPolies[kYellowJack].right &&
_cursor->y() >= (uint32)BlowUpPuzzleVCRPolies[kBlackJack].top && _cursor->y() <= (uint32)BlowUpPuzzleVCRPolies[kYellowJack].bottom) {
_jacksState[jackType-1] = kOnTable;
- _scene->vm()->sound()->playSfx(_scene->getResourcePack(), _scene->worldstats()->grResId[50]);
+ playSound(_scene->worldstats()->grResId[50]);
_cursor->show();
}
return;
@@ -517,7 +523,7 @@ void BlowUpPuzzleVCR::handleMouseDown() {
// TODO: VCR button regions
if (inPolyRegion(_cursor->x(), _cursor->y(), kRewindButton)) {
- _scene->vm()->sound()->playSfx(_scene->getResourcePack(), _scene->worldstats()->grResId[39]);
+ playSound(_scene->worldstats()->grResId[39]);
if(!_buttonsState[kRewind]) {
_buttonsState[kRewind] = kDownON;
return;
@@ -527,7 +533,7 @@ void BlowUpPuzzleVCR::handleMouseDown() {
return;
}
} else if (inPolyRegion(_cursor->x(), _cursor->y(), kPlayButton)) {
- _scene->vm()->sound()->playSfx(_scene->getResourcePack(), _scene->worldstats()->grResId[39]);
+ playSound(_scene->worldstats()->grResId[39]);
if(!_buttonsState[kPlay]) {
_buttonsState[kPlay] = kDownON;
return;
@@ -537,7 +543,7 @@ void BlowUpPuzzleVCR::handleMouseDown() {
return;
}
} else if (inPolyRegion(_cursor->x(), _cursor->y(), kStopButton)) {
- _scene->vm()->sound()->playSfx(_scene->getResourcePack(), _scene->worldstats()->grResId[39]);
+ playSound(_scene->worldstats()->grResId[39]);
if(_buttonsState[kStop]) {
if(_buttonsState[kStop] == kON) {
_buttonsState[kStop] = kDownOFF;
@@ -548,7 +554,7 @@ void BlowUpPuzzleVCR::handleMouseDown() {
return;
}
} else if (inPolyRegion(_cursor->x(), _cursor->y(), kPowerButton)) {
- _scene->vm()->sound()->playSfx(_scene->getResourcePack(), _scene->worldstats()->grResId[39]);
+ playSound(_scene->worldstats()->grResId[39]);
if(!_buttonsState[kPower] && _holesState[kPluggedOnBlack-1] == kBlack+1 && _holesState[kPluggedOnRed-1] && _holesState[kPluggedOnYellow-1]) {
_buttonsState[kPower] = kDownON;
@@ -564,7 +570,7 @@ void BlowUpPuzzleVCR::handleMouseUp() {
if(_buttonsState[kPower] == kDownON) {
// TODO: check if next sound is already playing
- _scene->vm()->sound()->playSfx(_scene->getResourcePack(), _scene->worldstats()->grResId[47]);
+ playSound(_scene->worldstats()->grResId[47]);
_buttonsState[kPower] = kON;
_buttonsState[kStop] = kON;
_buttonsState[kPlay] = kON;
@@ -579,7 +585,7 @@ void BlowUpPuzzleVCR::handleMouseUp() {
if(_buttonsState[kRewind] == kDownOFF) {
_buttonsState[kRewind] = kON;
- _scene->vm()->sound()->playSfx(_scene->getResourcePack(), _scene->worldstats()->grResId[46]);
+ playSound(_scene->worldstats()->grResId[46]);
} else if(_buttonsState[kRewind] == kDownON) {
_buttonsState[kRewind] = kOFF;
}
diff --git a/engines/asylum/blowuppuzzle.h b/engines/asylum/blowuppuzzle.h
index ada5988d75..01a100c18a 100644
--- a/engines/asylum/blowuppuzzle.h
+++ b/engines/asylum/blowuppuzzle.h
@@ -66,6 +66,7 @@ protected:
GraphicResource *_bgResource;
virtual void update() {};
+ void playSound(uint resourceId);
}; // end of class BlowUpPuzzle
diff --git a/engines/asylum/menu.cpp b/engines/asylum/menu.cpp
index f71364ecef..f085322d2f 100644
--- a/engines/asylum/menu.cpp
+++ b/engines/asylum/menu.cpp
@@ -82,7 +82,12 @@ void MainMenu::openMenu() {
_vm->screen()->setPalette(_resPack, 17);
// Copy the bright background to the back buffer
GraphicFrame *bg = _bgResource->getFrame(1);
- _vm->screen()->copyToBackBuffer((byte *)bg->surface.pixels, bg->surface.w, 0, 0, bg->surface.w, bg->surface.h);
+ _vm->screen()->copyToBackBuffer((byte *)bg->surface.pixels,
+ bg->surface.w,
+ 0,
+ 0,
+ bg->surface.w,
+ bg->surface.h);
// Set mouse cursor
_cursor->load(2);
@@ -90,7 +95,7 @@ void MainMenu::openMenu() {
// Stop all sounds
_vm->sound()->stopMusic();
- _vm->sound()->stopSfx();
+ _vm->sound()->stopSound();
// Start playing music
_vm->sound()->playMusic(_resPack, 39);
@@ -105,7 +110,7 @@ void MainMenu::closeMenu() {
_vm->scene()->activate();
// Stop menu sounds and menu music
- _vm->sound()->stopSfx();
+ _vm->sound()->stopSound();
_vm->sound()->stopMusic();
}
@@ -284,8 +289,8 @@ void MainMenu::updateMainMenu() {
_text->drawResTextCentered(MenuIconFixedXpos[iconNum], iconFrame->y + 50, _text->getResTextWidth(iconNum + 1309), iconNum + 1309);
// Play creepy voice
- if (!_vm->sound()->isSfxActive() && _activeIcon != _previousActiveIcon) {
- _vm->sound()->playSfx(_resPack, iconNum + 44);
+ if (_activeIcon != _previousActiveIcon) {
+ _vm->sound()->playSound(_resPack, iconNum + 44, _vm->soundVolume());
_previousActiveIcon = _activeIcon;
}
diff --git a/engines/asylum/respack.cpp b/engines/asylum/respack.cpp
index 8fc540900c..52e234d890 100644
--- a/engines/asylum/respack.cpp
+++ b/engines/asylum/respack.cpp
@@ -72,7 +72,7 @@ void ResourcePack::init(const char *resourceFile) {
}
ResourceEntry *ResourcePack::getResource(uint32 resourceId) {
- uint16 index = resourceId & 0xFFFF;
+ uint16 index = RESIDX(resourceId);
if (!_resources[index].data) {
// Load the requested resource if it's not loaded already
_packFile.seek(_resources[index].offset, SEEK_SET);
diff --git a/engines/asylum/respack.h b/engines/asylum/respack.h
index 97c0c16066..c7cabcdc5c 100644
--- a/engines/asylum/respack.h
+++ b/engines/asylum/respack.h
@@ -31,6 +31,9 @@
namespace Asylum {
+#define RESID(id) ((id >> 16) & 0x7FFF)
+#define RESIDX(id) (id & 0XFFFF)
+
struct ResourceEntry {
byte *data;
uint32 size;
diff --git a/engines/asylum/scene.cpp b/engines/asylum/scene.cpp
index 1aa2490464..f999838513 100644
--- a/engines/asylum/scene.cpp
+++ b/engines/asylum/scene.cpp
@@ -69,7 +69,6 @@ Scene::Scene(uint8 sceneIdx, AsylumEngine *vm): _vm(vm) {
_text = new Text(_vm->screen());
_resPack = new ResourcePack(sceneIdx);
- _speechPack = new ResourcePack(3); // FIXME are all scene speech packs the same?
// FIXME
// Is there EVER more than one actor enabled for a scene? I can't
@@ -139,6 +138,12 @@ Scene::Scene(uint8 sceneIdx, AsylumEngine *vm): _vm(vm) {
}
}
+ // XXX
+ // This is a hack for the moment to test out
+ // the new sound queuing functionality
+ for (uint i = 0; i < _ws->numAmbientSound; i++)
+ _vm->sound()->addToSoundBuffer(_ws->ambientSounds[i].resId);
+
// TODO: init action list
}
@@ -150,7 +155,6 @@ Scene::~Scene() {
delete _cursor;
delete _bgResource;
delete _musPack;
- delete _speechPack;
delete _resPack;
delete _text;
delete _blowUp;
@@ -267,7 +271,7 @@ int Scene::updateScene() {
// Barriers
startTick = _vm->_system->getMillis();
- updateBarriers();
+ updateBarriers2();
debugC(kDebugLevelScene, "UpdateBarriers Time: %d", _vm->_system->getMillis() - startTick);
// Ambient Sounds
@@ -528,7 +532,38 @@ void Scene::updateActor(uint32 actorIdx) {
}
}
+// XXX WIP
void Scene::updateBarriers() {
+ int v1, v0, v32, v33, v34, tickVal, tickVal05, tickVal06;
+ v1 = v0 = v32 = v33 = v34 = tickVal = tickVal05 = tickVal06 = 0;
+
+ uint32 start, v2, v31;
+ bool done = false;
+ //if (_ws->barriers.size() > 0);
+
+ v2 = _ws->barriers[0].tickCount2;
+ for (uint32 idx = 0; idx < _ws->numBarriers; idx++) {
+ Barrier *b = &_ws->barriers[idx];
+ start = _vm->_system->getMillis();
+
+ if (v2 - 32 != 4)
+ done = true;
+
+ if (!done && !_ws->checkBarrierFlagsCondition(idx)) {
+ v31 = _vm->_system->getMillis();
+ }
+
+ /*
+ * TODO
+ */
+
+ v2 += 426;
+ v1 = 0;
+ done = false;
+ }
+}
+
+void Scene::updateBarriers2() {
Screen *screen = _vm->screen();
uint barriersCount = _ws->barriers.size();
@@ -669,6 +704,95 @@ void Scene::updateBarriers() {
}
void Scene::updateAmbientSounds() {
+ // if (cfgGameQualityValue > 3)
+
+ int v2 = 1;
+ int v15, v11, v10, v16;
+
+ int panning, volume;
+
+ for (uint32 i = 0; i < _ws->numAmbientSound; i++) {
+ AmbientSoundItem *snd = &_ws->ambientSounds[i];
+ for (uint32 f = 0; f < 6; f++) {
+ uint gameFlag = snd->flagNum[f];
+ if (gameFlag >= 0) {
+ if (_vm->isGameFlagNotSet(gameFlag)) {
+ v2 = 0;
+ break;
+ }
+ } else {
+ if (_vm->isGameFlagSet(-gameFlag)) {
+ // XXX Looks like this just jumps back to
+ // the top of the loop, so not sure if this
+ // is somehow important
+ }
+ }
+ }
+ if (v2) {
+ if (_vm->sound()->isPlaying(snd->resId)) {
+ if (snd->field_0) {
+ ; // TODO volume calculation
+ }
+ } else {
+ if (snd->field_0) {
+ ; // TODO calculate panning at point
+ } else {
+ panning = 0;
+ }
+
+ if (snd->field_0 == 0) {
+ volume = -(snd->field_C ^ 2);
+ } else {
+ ; // TODO calculate volume increase
+ }
+
+ if (LOBYTE(snd->flags) & 2) {
+ if (rand() % 10000 < 10) {
+ if (snd->field_0) {
+ _vm->sound()->playSound(_resPack, snd->resId, false, _vm->ambientVolume() + volume, panning);
+ } else {
+ v15 = rand() % 500;
+ v11 = v15 * ((((rand() % 100 >= 50) - 1) & 2) - 1) + volume;
+ v10 = v11;
+ if ( v11 <= -10000 )
+ v10 = -10000;
+ if ( v10 >= 0 )
+ v11 = 0;
+ else
+ if ( v11 <= -10000 )
+ v11 = -10000;
+ v16 = rand();
+ _vm->sound()->playSound(_resPack, snd->resId, false, v11, v16 % 20001 - 10000);
+ }
+ } else {
+ if (LOBYTE(snd->flags) & 4) {
+ /*
+ if ( (unsigned int)*ambientPanningArray < getTickCount() )
+ {
+ if ( v1->field_14 >= 0 )
+ v12 = 60000 * v1->field_14 + getTickCount();
+ else
+ v12 = getTickCount() - 1000 * v1->field_14;
+ *ambientPanningArray = v12;
+ playSound(v7, 0, v9, panning);
+ }
+ */
+ } else {
+ if (LOBYTE(snd->flags) & 8) {
+ /*
+ if ( !*(ambientPanningArray - 15) )
+ {
+ playSound(v7, 0, v9, panning);
+ *(ambientPanningArray - 15) = 1;
+ }
+ */
+ }
+ }
+ }
+ }
+ }
+ }
+ }
}
void Scene::updateMusic() {
diff --git a/engines/asylum/scene.h b/engines/asylum/scene.h
index d62548f2dc..fb415716a1 100644
--- a/engines/asylum/scene.h
+++ b/engines/asylum/scene.h
@@ -69,7 +69,6 @@ public:
Cursor* getCursor() { return _cursor; }
ResourcePack* getResourcePack() { return _resPack; }
ResourcePack* getMusicPack() { return _musPack; }
- ResourcePack* getSpeechPack() { return _speechPack; }
GraphicResource* getGraphicResource(uint32 entry) { return new GraphicResource(_resPack, entry); }
BlowUpPuzzle* getBlowUpPuzzle() { return _blowUp; }
@@ -110,6 +109,7 @@ private:
void updateMouse();
void updateActor(uint32 actorIdx);
void updateBarriers();
+ void updateBarriers2(); // XXX Alexandre's version
void updateAmbientSounds();
void updateMusic();
void updateAdjustScreen();
diff --git a/engines/asylum/sound.cpp b/engines/asylum/sound.cpp
index 677e316946..7327a94aa6 100644
--- a/engines/asylum/sound.cpp
+++ b/engines/asylum/sound.cpp
@@ -24,32 +24,240 @@
*/
#include "asylum/sound.h"
+#include "asylum/asylum.h"
#include "common/stream.h"
+#include "sound/audiostream.h"
+#include "sound/adpcm.h"
#include "sound/wave.h"
namespace Asylum {
Sound::Sound(Audio::Mixer *mixer) : _mixer(mixer) {
+ _speechPack = new ResourcePack(3);
+ _soundPack = new ResourcePack(18);
}
Sound::~Sound() {
+ delete _speechPack;
+ delete _soundPack;
+
+ clearSoundBuffer();
+}
+
+// from engines/agos/sound.cpp
+void convertVolume(int &vol) {
+ // DirectSound was orginally used, which specifies volume
+ // and panning differently than ScummVM does, using a logarithmic scale
+ // rather than a linear one.
+ //
+ // Volume is a value between -10,000 and 0.
+ //
+ // In both cases, the -10,000 represents -100 dB. When panning, only
+ // one speaker's volume is affected - just like in ScummVM - with
+ // negative values affecting the left speaker, and positive values
+ // affecting the right speaker. Thus -10,000 means the left speaker is
+ // silent.
+
+ int v = CLIP(vol, -10000, 0);
+ if (v) {
+ vol = (int)((double)Audio::Mixer::kMaxChannelVolume * pow(10.0, (double)v / 2000.0) + 0.5);
+ } else {
+ vol = Audio::Mixer::kMaxChannelVolume;
+ }
+}
+
+// from engines/agos/sound.cpp
+void convertPan(int &pan) {
+ // DirectSound was orginally used, which specifies volume
+ // and panning differently than ScummVM does, using a logarithmic scale
+ // rather than a linear one.
+ //
+ // Panning is a value between -10,000 and 10,000.
+ //
+ // In both cases, the -10,000 represents -100 dB. When panning, only
+ // one speaker's volume is affected - just like in ScummVM - with
+ // negative values affecting the left speaker, and positive values
+ // affecting the right speaker. Thus -10,000 means the left speaker is
+ // silent.
+
+ int p = CLIP(pan, -10000, 10000);
+ if (p < 0) {
+ pan = (int)(255.0 * pow(10.0, (double)p / 2000.0) + 127.5);
+ } else if (p > 0) {
+ pan = (int)(255.0 * pow(10.0, (double)p / -2000.0) - 127.5);
+ } else {
+ pan = 0;
+ }
+}
+
+int Sound::getBufferPosition(uint32 resId) {
+ int pos = -1;
+
+ for (uint i = 0; i < _soundBuffer.size(); i++) {
+ if (resId == _soundBuffer[i].resId) {
+ pos = i;
+ break;
+ }
+ }
+
+ return pos;
+}
+
+bool Sound::addToSoundBuffer(uint resId) {
+ int exists = getBufferPosition(resId);
+
+ if (exists >= 0) {
+ SoundBufferItem sound;
+ sound.resId = resId;
+ _soundBuffer.push_back(sound);
+ }
+
+ return (exists < 0) ? true : false;
+}
+
+void Sound::clearSoundBuffer() {
+ _soundBuffer.clear();
+}
+
+bool Sound::isPlaying(uint resId) {
+ int pos = getBufferPosition(resId);
+
+ if (pos < 0) {
+ warning("isPlaying: resId %d not currently bufferred", resId);
+ } else {
+ SoundBufferItem snd = _soundBuffer[pos];
+ if (_mixer->isSoundHandleActive(snd.handle)) {
+ return true;
+ }
+ }
+
+ return false;
+}
+
+void Sound::playSound(ResourcePack *pack, uint resId, int volume, bool looping, int panning, bool overwrite) {
+ ResourceEntry *resource = pack->getResource(resId);
+ if (_mixer->isSoundHandleActive(_soundHandle)) {
+ if (overwrite) {
+ _mixer->stopHandle(_soundHandle);
+ playSound(resource, looping, volume, panning);
+ }
+ // if the current handle isn't active, play the sound
+ playSound(resource, looping, volume, panning);
+ }
+
+}
+
+void Sound::playSound(ResourceEntry *resource, bool looping, int volume, int panning) {
+ playSoundData(&_soundHandle, resource->data, resource->size, looping, volume, panning);
}
-void Sound::playSfx(byte *data, uint32 size) {
- Common::MemoryReadStream *mem = new Common::MemoryReadStream(data, size);
+void Sound::playSound(ResourcePack *pack, uint resId, bool looping, int volume, int panning) {
+ int pos = getBufferPosition(resId);
- // Now create the audio stream and play it (it's just a regular WAVE file)
- Audio::AudioStream *sfx = Audio::makeWAVStream(mem, true);
- _mixer->playInputStream(Audio::Mixer::kSFXSoundType, &_sfxHandle, sfx);
+ if (pos < 0) {
+ warning("isPlaying: resId %d not currently bufferred", resId);
+ } else {
+ SoundBufferItem snd = _soundBuffer[pos];
+ if (_mixer->isSoundHandleActive(snd.handle)) {
+ debugC(kDebugLevelSound, "playSound: handle for resId %d already active", resId);
+ } else {
+ ResourceEntry *ent = _soundPack->getResource(resId);
+ playSoundData(&snd.handle, ent->data, ent->size, looping, volume, panning);
+ }
+ }
+
+}
+
+void Sound::playSound(uint resId, bool looping, int volume, int panning, bool fromBuffer) {
+ if (fromBuffer) {
+ playSound(_soundPack, resId, looping, volume, panning);
+ } else {
+ if (_mixer->isSoundHandleActive(_soundHandle)) {
+ debugC(kDebugLevelSound, "playSound: temporary sound handle is active");
+ } else {
+ ResourceEntry *ent = _soundPack->getResource(resId);
+ playSound(ent, looping, volume, panning);
+ }
+ }
+}
+
+void Sound::stopSound() {
+ if (_mixer->isSoundHandleActive(_soundHandle))
+ _mixer->stopHandle(_soundHandle);
+}
+
+void Sound::stopSound(uint resId) {
+ int pos = getBufferPosition(resId);
+
+ if (pos < 0) {
+ warning("isPlaying: resId %d not currently bufferred", resId);
+ } else {
+ _mixer->stopHandle(_soundBuffer[pos].handle);
+ }
+}
+
+void Sound::stopAllSounds() {
+ _mixer->stopHandle(_soundHandle);
+
+ for (uint i = 0; i < _soundBuffer.size(); i++)
+ _mixer->stopHandle(_soundBuffer[i].handle);
+}
+
+void Sound::playSpeech(uint resId) {
+ ResourceEntry *ent = _speechPack->getResource(resId);
+
+ _mixer->stopHandle(_speechHandle);
+ playSoundData(&_speechHandle, ent->data, ent->size, false, 0, 0);
+}
+
+void Sound::playMusic(uint resId) {
+ stopMusic();
+
+ // TODO Play music :P
+}
+
+void Sound::playMusic(ResourcePack *pack, uint resId) {
+ stopMusic();
+
+ ResourceEntry *resource = pack->getResource(resId);
+ playSoundData(&_musicHandle, resource->data, resource->size, true, 0, 0);
}
-void Sound::playMusic(byte *data, uint32 size) {
- Common::MemoryReadStream *mem = new Common::MemoryReadStream(data, size);
+void Sound::stopMusic() {
+ _mixer->stopHandle(_musicHandle);
+}
+
+// from engines/agos/sound.cpp
+void Sound::playSoundData(Audio::SoundHandle *handle, byte *soundData, uint soundDataLength, bool loop, int vol, int pan) {
+ byte *buffer, flags;
+ uint16 compType;
+ int blockAlign, rate;
+
+ // TODO: Use makeWAVStream() in future, when makeADPCMStream() allows sound looping
+ int size = soundDataLength;
+ Common::MemoryReadStream stream(soundData, size);
+ if (!Audio::loadWAVFromStream(stream, size, rate, flags, &compType, &blockAlign))
+ error("playSound: Not valid WAV data");
+
+ convertVolume(vol);
+ convertPan(pan);
+
+ if (loop == true)
+ flags |= Audio::Mixer::FLAG_LOOP;
+
+ if (compType == 2) {
+ Audio::AudioStream *sndStream = Audio::makeADPCMStream(&stream, false, size, Audio::kADPCMMS, rate, (flags & Audio::Mixer::FLAG_STEREO) ? 2 : 1, blockAlign);
+ buffer = (byte *)malloc(size * 4);
+ size = sndStream->readBuffer((int16*)buffer, size * 2);
+ size *= 2; // 16bits.
+ delete sndStream;
+ } else {
+ buffer = (byte *)malloc(size);
+ memcpy(buffer, soundData + stream.pos(), size);
+ }
- // Now create the audio stream and play it (it's just a regular WAVE file)
- Audio::AudioStream *mus = Audio::makeWAVStream(mem, true);
- _mixer->playInputStream(Audio::Mixer::kMusicSoundType, &_musicHandle, mus);
+ _mixer->playRaw(Audio::Mixer::kSFXSoundType, handle, buffer, size, rate, flags | Audio::Mixer::FLAG_AUTOFREE, -1, vol, pan);
}
} // end of namespace Asylum
diff --git a/engines/asylum/sound.h b/engines/asylum/sound.h
index ab73ff7f83..768390ff93 100644
--- a/engines/asylum/sound.h
+++ b/engines/asylum/sound.h
@@ -27,6 +27,7 @@
#define ASYLUM_SOUND_H_
#include "sound/mixer.h"
+
#include "asylum/respack.h"
namespace Asylum {
@@ -62,35 +63,55 @@ typedef struct AmbientSoundItem {
} AmbientSoundItem;
+typedef struct SoundBufferItem {
+ uint32 resId;
+ Audio::SoundHandle handle;
+ uint32 unknown;
+} SoundBufferItem;
+
class Sound {
public:
Sound(Audio::Mixer *mixer);
~Sound();
- void playSfx(byte *data, uint32 size);
- void playSfx(ResourcePack *resPack, uint32 resourceId) {
- ResourceEntry *resEntry = resPack->getResource(resourceId);
- playSfx(resEntry->data, resEntry->size);
- }
- bool isSfxActive() { return _mixer->isSoundHandleActive(_sfxHandle); }
- void pauseSfx() { _mixer->pauseHandle(_sfxHandle, true); }
- void resumeSfx() { _mixer->pauseHandle(_sfxHandle, false); }
- void stopSfx() { _mixer->stopHandle(_sfxHandle); }
-
- void playMusic(byte *data, uint32 size);
- void playMusic(ResourcePack *resPack, uint32 resourceId) {
- ResourceEntry *resEntry = resPack->getResource(resourceId);
- playMusic(resEntry->data, resEntry->size);
- }
- bool isMusicActive() { return _mixer->isSoundHandleActive(_musicHandle); }
- void pauseMusic() { _mixer->pauseHandle(_musicHandle, true); }
- void resumeMusic() { _mixer->pauseHandle(_musicHandle, false); }
- void stopMusic() { _mixer->stopHandle(_musicHandle); }
+ bool addToSoundBuffer(uint resId);
+ void clearSoundBuffer();
+
+ /**
+ * Play a sound resource from the supplied resource pack.
+ *
+ * @param overwrite determine if _soundHandle should be overwritten if still active
+ */
+ void playSound(ResourcePack *pack, uint resId, int volume, bool looping = false, int panning = 0, bool overwrite = false);
+ void playSound(ResourcePack *pack, uint resId, bool looping, int volume, int panning);
+ void playSound(ResourceEntry *resource, bool looping, int volume, int panning);
+ void playSound(uint resId, bool looping, int volume, int panning, bool fromBuffer = false);
+ void stopSound(uint resId);
+ void stopSound();
+ void stopAllSounds();
+
+ void playSpeech(uint resId);
+
+ void playMusic(ResourcePack *pack, uint resId);
+ void playMusic(uint resId);
+ void stopMusic();
+
+ bool isPlaying(uint resId);
private:
- Audio::SoundHandle _sfxHandle;
- Audio::SoundHandle _musicHandle;
Audio::Mixer *_mixer;
+
+ Audio::SoundHandle _speechHandle;
+ Audio::SoundHandle _musicHandle;
+ Audio::SoundHandle _soundHandle;
+
+ ResourcePack *_speechPack;
+ ResourcePack *_soundPack;
+
+ Common::Array<SoundBufferItem> _soundBuffer;
+
+ int getBufferPosition(uint32 resId);
+ void playSoundData(Audio::SoundHandle *handle, byte *soundData, uint32 soundDataLength, bool loop = false, int vol = 0, int pan = 0);
};
} // end of namespace Asylum
diff --git a/engines/asylum/worldstats.cpp b/engines/asylum/worldstats.cpp
index e4aac73808..bfc1133480 100644
--- a/engines/asylum/worldstats.cpp
+++ b/engines/asylum/worldstats.cpp
@@ -98,6 +98,24 @@ bool WorldStats::isBarrierVisible(uint32 idx) {
return false;
}
+bool WorldStats::checkBarrierFlagsCondition(uint32 idx) {
+ Barrier *b = getBarrierByIndex(idx);
+ bool result;
+
+ if (LOBYTE(b->flags) & 1) {
+ for (int i = 0; i < 10; i++) {
+ result = _scene->vm()->isGameFlagSet(b->gameFlags[i]);
+ if (result)
+ return result;
+ }
+ result = true;
+ } else {
+ result = false;
+ }
+
+ return result;
+}
+
// FIXME: load necessary World Stats content
void WorldStats::load(Common::SeekableReadStream *stream) {
size = stream->readUint32LE();
diff --git a/engines/asylum/worldstats.h b/engines/asylum/worldstats.h
index de040be381..76d2baf866 100644
--- a/engines/asylum/worldstats.h
+++ b/engines/asylum/worldstats.h
@@ -154,7 +154,8 @@ public:
bool isBarrierOnScreen(uint32 idx);
bool isBarrierVisible(uint32 idx);
-
+ // TODO this needs a better name
+ bool checkBarrierFlagsCondition(uint32 idx);
private:
Scene *_scene;
Commit: a6d5a2a714ad2e74c7d715bbf5d55bf3244904bb
https://github.com/scummvm/scummvm/commit/a6d5a2a714ad2e74c7d715bbf5d55bf3244904bb
Author: Alex Bevilacqua (alexbevi at gmail.com)
Date: 2021-05-17T15:35:50+02:00
Commit Message:
ASYLUM: Cleanup and comments
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@363 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/sound.cpp
engines/asylum/sound.h
diff --git a/engines/asylum/sound.cpp b/engines/asylum/sound.cpp
index 7327a94aa6..fb23e2d9ed 100644
--- a/engines/asylum/sound.cpp
+++ b/engines/asylum/sound.cpp
@@ -156,7 +156,7 @@ void Sound::playSound(ResourcePack *pack, uint resId, bool looping, int volume,
int pos = getBufferPosition(resId);
if (pos < 0) {
- warning("isPlaying: resId %d not currently bufferred", resId);
+ warning("playSound: resId %d not currently bufferred", resId);
} else {
SoundBufferItem snd = _soundBuffer[pos];
if (_mixer->isSoundHandleActive(snd.handle)) {
@@ -191,7 +191,7 @@ void Sound::stopSound(uint resId) {
int pos = getBufferPosition(resId);
if (pos < 0) {
- warning("isPlaying: resId %d not currently bufferred", resId);
+ warning("stopSound: resId %d not currently bufferred", resId);
} else {
_mixer->stopHandle(_soundBuffer[pos].handle);
}
@@ -238,7 +238,7 @@ void Sound::playSoundData(Audio::SoundHandle *handle, byte *soundData, uint soun
int size = soundDataLength;
Common::MemoryReadStream stream(soundData, size);
if (!Audio::loadWAVFromStream(stream, size, rate, flags, &compType, &blockAlign))
- error("playSound: Not valid WAV data");
+ error("playSoundData: Not valid WAV data");
convertVolume(vol);
convertPan(pan);
@@ -257,6 +257,12 @@ void Sound::playSoundData(Audio::SoundHandle *handle, byte *soundData, uint soun
memcpy(buffer, soundData + stream.pos(), size);
}
+ // TODO
+ // All asylum audio data is being filtered through the playSoundData()
+ // method. As such, they're all using kSFXSoundType. There are also
+ // enums for kMusicSoundType and kSpeechSoundType.
+ //
+ // Investigate how this can effect ... anything :P
_mixer->playRaw(Audio::Mixer::kSFXSoundType, handle, buffer, size, rate, flags | Audio::Mixer::FLAG_AUTOFREE, -1, vol, pan);
}
diff --git a/engines/asylum/sound.h b/engines/asylum/sound.h
index 768390ff93..3633990e9f 100644
--- a/engines/asylum/sound.h
+++ b/engines/asylum/sound.h
@@ -96,6 +96,14 @@ public:
void playMusic(uint resId);
void stopMusic();
+ /**
+ * Check if the buffered sound sample that matches the provided id currently
+ * has an active handle.
+ *
+ * isPlaying() only manages sound samples, and not
+ * music or speech, as those resources aren't managed beyond simple
+ * start/stop requests.
+ */
bool isPlaying(uint resId);
private:
@@ -110,6 +118,10 @@ private:
Common::Array<SoundBufferItem> _soundBuffer;
+ /**
+ * Find the index within the _soundBuffer array of the
+ * sound sample with provided id.
+ */
int getBufferPosition(uint32 resId);
void playSoundData(Audio::SoundHandle *handle, byte *soundData, uint32 soundDataLength, bool loop = false, int vol = 0, int pan = 0);
};
Commit: 8a8ac36b214af15d00184831e86ac0e949929c47
https://github.com/scummvm/scummvm/commit/8a8ac36b214af15d00184831e86ac0e949929c47
Author: Alexandre Fontoura (alexandrefontoura at gmail.com)
Date: 2021-05-17T15:35:50+02:00
Commit Message:
ASYLUM: Finish missing sound parts from BlowUpPuzzleVCR. Still needs corrections in sound stop routines. After that, it should working well.
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@364 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/blowuppuzzle.cpp
engines/asylum/blowuppuzzle.h
diff --git a/engines/asylum/blowuppuzzle.cpp b/engines/asylum/blowuppuzzle.cpp
index 4611067a24..d81f46c388 100644
--- a/engines/asylum/blowuppuzzle.cpp
+++ b/engines/asylum/blowuppuzzle.cpp
@@ -63,8 +63,7 @@ BlowUpPuzzleVCR::~BlowUpPuzzleVCR() {
void BlowUpPuzzleVCR::openBlowUp() {
_active = true;
_scene->deactivate();
- // FIXME: decomment this line when stopSfx works properly (it nows stop together SFX and Music
- //_scene->vm()->sound()->stopSfx();
+ _scene->vm()->sound()->stopAllSounds();
// Load the graphics palette
_scene->vm()->screen()->setPalette(_scene->getResourcePack(), _scene->worldstats()->grResId[29]);
@@ -112,9 +111,13 @@ void BlowUpPuzzleVCR::handleEvent(Common::Event *event, bool doUpdate) {
}
void BlowUpPuzzle::playSound(uint resourceId) {
+ playSound(resourceId, false);
+}
+
+void BlowUpPuzzle::playSound(uint resourceId, bool looping) {
ResourceEntry *resource = _scene->getResourcePack()->getResource(resourceId);
int volume = _scene->vm()->soundVolume();
- _scene->vm()->sound()->playSound(resource, false, volume, 0);
+ _scene->vm()->sound()->playSound(resource, looping, volume, 0);
}
int BlowUpPuzzleVCR::inPolyRegion(int x, int y, int polyIdx) {
@@ -128,7 +131,7 @@ void BlowUpPuzzleVCR::update() {
if (_rightClickDown) { // quits BlowUp Puzzle
_rightClickDown = false;
closeBlowUp();
- // TODO: stop sound fx grResId[47] (TV On sfx)
+ _scene->vm()->sound()->stopSound(_scene->worldstats()->grResId[47]);
_scene->enterScene();
}
@@ -491,7 +494,7 @@ void BlowUpPuzzleVCR::handleMouseDown() {
}
if(inPolyRegion(_cursor->x(), _cursor->y(), kBlackHole)) {
if(!setJackOnHole(jackType, kPluggedOnBlack)) {
- if(_holesState[kBlackHole] != kPluggedOnYellow && _buttonsState[kPower] == 1) { // TODO: check this better
+ if(_holesState[kBlackHole] != kPluggedOnYellow && _buttonsState[kPower] == 1) {
_buttonsState[kPower] = kOFF;
_buttonsState[kStop] = kOFF;
_buttonsState[kPlay] = kOFF;
@@ -521,7 +524,7 @@ void BlowUpPuzzleVCR::handleMouseDown() {
_jacksState[kYellow] = kOnHand;
}
- // TODO: VCR button regions
+ // VCR button regions
if (inPolyRegion(_cursor->x(), _cursor->y(), kRewindButton)) {
playSound(_scene->worldstats()->grResId[39]);
if(!_buttonsState[kRewind]) {
@@ -569,8 +572,8 @@ void BlowUpPuzzleVCR::handleMouseUp() {
return;
if(_buttonsState[kPower] == kDownON) {
- // TODO: check if next sound is already playing
- playSound(_scene->worldstats()->grResId[47]);
+ if(!_scene->vm()->sound()->isPlaying(_scene->worldstats()->grResId[47]))
+ playSound(_scene->worldstats()->grResId[47], true);
_buttonsState[kPower] = kON;
_buttonsState[kStop] = kON;
_buttonsState[kPlay] = kON;
@@ -580,7 +583,7 @@ void BlowUpPuzzleVCR::handleMouseUp() {
_buttonsState[kStop] = kOFF;
_buttonsState[kPlay] = kOFF;
_buttonsState[kRewind] = kOFF;
- // TODO: stop sound grResId[47]
+ _scene->vm()->sound()->stopSound(_scene->worldstats()->grResId[47]);
}
if(_buttonsState[kRewind] == kDownOFF) {
@@ -593,7 +596,7 @@ void BlowUpPuzzleVCR::handleMouseUp() {
if(_buttonsState[kPlay] == kDownOFF) {
_buttonsState[kPlay] = kON;
if(_holesState[kPluggedOnRed-1] == kRed+1 && _holesState[kPluggedOnYellow-1] == kYellow+1 && _holesState[kPluggedOnBlack-1] == kBlack+1) {
- // TODO: set game flag 220
+ _scene->vm()->setGameFlag(220);
_isAccomplished = true;
}
} else if(_buttonsState[kPlay] == kDownON) {
diff --git a/engines/asylum/blowuppuzzle.h b/engines/asylum/blowuppuzzle.h
index 01a100c18a..996ac313a5 100644
--- a/engines/asylum/blowuppuzzle.h
+++ b/engines/asylum/blowuppuzzle.h
@@ -67,6 +67,7 @@ protected:
virtual void update() {};
void playSound(uint resourceId);
+ void playSound(uint resourceId, bool looping);
}; // end of class BlowUpPuzzle
Commit: 1142cd7286bd5e99e7c2e59e3326d054329e7c91
https://github.com/scummvm/scummvm/commit/1142cd7286bd5e99e7c2e59e3326d054329e7c91
Author: Alex Bevilacqua (alexbevi at gmail.com)
Date: 2021-05-17T15:35:50+02:00
Commit Message:
ASYLUM: stopAllSounds() now optionally stops speech/music playback.
Cleaned up the blowup puzzle sound handling
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@365 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/blowuppuzzle.cpp
engines/asylum/blowuppuzzle.h
engines/asylum/sound.cpp
engines/asylum/sound.h
diff --git a/engines/asylum/blowuppuzzle.cpp b/engines/asylum/blowuppuzzle.cpp
index d81f46c388..e7a879c221 100644
--- a/engines/asylum/blowuppuzzle.cpp
+++ b/engines/asylum/blowuppuzzle.cpp
@@ -63,7 +63,8 @@ BlowUpPuzzleVCR::~BlowUpPuzzleVCR() {
void BlowUpPuzzleVCR::openBlowUp() {
_active = true;
_scene->deactivate();
- _scene->vm()->sound()->stopAllSounds();
+
+ _scene->vm()->sound()->stopAllSounds(true);
// Load the graphics palette
_scene->vm()->screen()->setPalette(_scene->getResourcePack(), _scene->worldstats()->grResId[29]);
@@ -110,14 +111,9 @@ void BlowUpPuzzleVCR::handleEvent(Common::Event *event, bool doUpdate) {
update();
}
-void BlowUpPuzzle::playSound(uint resourceId) {
- playSound(resourceId, false);
-}
-
-void BlowUpPuzzle::playSound(uint resourceId, bool looping) {
- ResourceEntry *resource = _scene->getResourcePack()->getResource(resourceId);
+void BlowUpPuzzle::playSound(uint resourceId, bool loop) {
int volume = _scene->vm()->soundVolume();
- _scene->vm()->sound()->playSound(resource, looping, volume, 0);
+ _scene->vm()->sound()->playSound(_scene->getResourcePack(), resourceId, volume, loop, 0, true);
}
int BlowUpPuzzleVCR::inPolyRegion(int x, int y, int polyIdx) {
@@ -131,7 +127,7 @@ void BlowUpPuzzleVCR::update() {
if (_rightClickDown) { // quits BlowUp Puzzle
_rightClickDown = false;
closeBlowUp();
- _scene->vm()->sound()->stopSound(_scene->worldstats()->grResId[47]);
+ _scene->vm()->sound()->stopSound();
_scene->enterScene();
}
@@ -261,9 +257,7 @@ void BlowUpPuzzleVCR::updateJack(Jack jack, VCRDrawInfo onTable, VCRDrawInfo plu
}
if(item.resId != 0)
- {
_scene->vm()->screen()->addGraphicToQueue(item);
- }
}
void BlowUpPuzzleVCR::updateBlackJack() {
@@ -572,8 +566,7 @@ void BlowUpPuzzleVCR::handleMouseUp() {
return;
if(_buttonsState[kPower] == kDownON) {
- if(!_scene->vm()->sound()->isPlaying(_scene->worldstats()->grResId[47]))
- playSound(_scene->worldstats()->grResId[47], true);
+ playSound(_scene->worldstats()->grResId[47], true);
_buttonsState[kPower] = kON;
_buttonsState[kStop] = kON;
_buttonsState[kPlay] = kON;
@@ -583,7 +576,7 @@ void BlowUpPuzzleVCR::handleMouseUp() {
_buttonsState[kStop] = kOFF;
_buttonsState[kPlay] = kOFF;
_buttonsState[kRewind] = kOFF;
- _scene->vm()->sound()->stopSound(_scene->worldstats()->grResId[47]);
+ _scene->vm()->sound()->stopSound();
}
if(_buttonsState[kRewind] == kDownOFF) {
diff --git a/engines/asylum/blowuppuzzle.h b/engines/asylum/blowuppuzzle.h
index 996ac313a5..fd61ad5e09 100644
--- a/engines/asylum/blowuppuzzle.h
+++ b/engines/asylum/blowuppuzzle.h
@@ -66,8 +66,7 @@ protected:
GraphicResource *_bgResource;
virtual void update() {};
- void playSound(uint resourceId);
- void playSound(uint resourceId, bool looping);
+ void playSound(uint resourceId, bool loop = false);
}; // end of class BlowUpPuzzle
diff --git a/engines/asylum/sound.cpp b/engines/asylum/sound.cpp
index fb23e2d9ed..f9e0a025ee 100644
--- a/engines/asylum/sound.cpp
+++ b/engines/asylum/sound.cpp
@@ -142,10 +142,10 @@ void Sound::playSound(ResourcePack *pack, uint resId, int volume, bool looping,
_mixer->stopHandle(_soundHandle);
playSound(resource, looping, volume, panning);
}
+ } else {
// if the current handle isn't active, play the sound
playSound(resource, looping, volume, panning);
}
-
}
void Sound::playSound(ResourceEntry *resource, bool looping, int volume, int panning) {
@@ -197,9 +197,14 @@ void Sound::stopSound(uint resId) {
}
}
-void Sound::stopAllSounds() {
+void Sound::stopAllSounds(bool stopSpeechAndMusic) {
_mixer->stopHandle(_soundHandle);
+ if (stopSpeechAndMusic) {
+ _mixer->stopHandle(_speechHandle);
+ _mixer->stopHandle(_musicHandle);
+ }
+
for (uint i = 0; i < _soundBuffer.size(); i++)
_mixer->stopHandle(_soundBuffer[i].handle);
}
diff --git a/engines/asylum/sound.h b/engines/asylum/sound.h
index 3633990e9f..1b74768d8e 100644
--- a/engines/asylum/sound.h
+++ b/engines/asylum/sound.h
@@ -88,7 +88,7 @@ public:
void playSound(uint resId, bool looping, int volume, int panning, bool fromBuffer = false);
void stopSound(uint resId);
void stopSound();
- void stopAllSounds();
+ void stopAllSounds(bool stopSpeechAndMusic = false);
void playSpeech(uint resId);
@@ -106,6 +106,14 @@ public:
*/
bool isPlaying(uint resId);
+ /**
+ * Check if the unmanaged sound handle is in use
+ *
+ * This is useful for checking the active state of a sound
+ * in a blowuppuzzle
+ */
+ bool isPlaying() { return _mixer->isSoundHandleActive(_soundHandle); }
+
private:
Audio::Mixer *_mixer;
Commit: ab44e5c66b2ddc3833bc0fd49055efd4af5e2dcb
https://github.com/scummvm/scummvm/commit/ab44e5c66b2ddc3833bc0fd49055efd4af5e2dcb
Author: Alex Bevilacqua (alexbevi at gmail.com)
Date: 2021-05-17T15:35:51+02:00
Commit Message:
ASYLUM: Ran our engine through AStyle :P
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@366 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/actionlist.cpp
engines/asylum/actionlist.h
engines/asylum/actor.cpp
engines/asylum/actor.h
engines/asylum/asylum.cpp
engines/asylum/asylum.h
engines/asylum/barrier.cpp
engines/asylum/blowuppuzzle.cpp
engines/asylum/blowuppuzzle.h
engines/asylum/console.cpp
engines/asylum/console.h
engines/asylum/cursor.h
engines/asylum/detection.cpp
engines/asylum/encounters.cpp
engines/asylum/encounters.h
engines/asylum/graphics.cpp
engines/asylum/graphics.h
engines/asylum/menu.cpp
engines/asylum/menu.h
engines/asylum/polygons.cpp
engines/asylum/respack.h
engines/asylum/scene.cpp
engines/asylum/scene.h
engines/asylum/screen.cpp
engines/asylum/screen.h
engines/asylum/sound.h
engines/asylum/text.cpp
engines/asylum/video.cpp
engines/asylum/video.h
engines/asylum/worldstats.cpp
engines/asylum/worldstats.h
diff --git a/engines/asylum/actionlist.cpp b/engines/asylum/actionlist.cpp
index a19bc67e90..3e19014550 100644
--- a/engines/asylum/actionlist.cpp
+++ b/engines/asylum/actionlist.cpp
@@ -28,7 +28,7 @@
namespace Asylum {
ActionList::ActionList(Common::SeekableReadStream *stream, Scene *scene)
- : _scene(scene) {
+ : _scene(scene) {
load(stream);
currentLine = 0;
@@ -164,19 +164,19 @@ void ActionList::setScriptByIndex(uint32 index) {
if (Common::isDebugChannelEnabled(kDebugLevelScripts)) {
for (uint8 i = 0; i < _currentScript->commands[0].numLines; i++) {
debugC(kDebugLevelScripts,
- "Line: %02d/%02d :: 0x%02X (%d, %d, %d, %d, %d, %d, %d, %d, %d)",
- i,
- _currentScript->commands[0].numLines - 1,
- _currentScript->commands[i].opcode,
- _currentScript->commands[i].param1,
- _currentScript->commands[i].param2,
- _currentScript->commands[i].param3,
- _currentScript->commands[i].param4,
- _currentScript->commands[i].param5,
- _currentScript->commands[i].param6,
- _currentScript->commands[i].param7,
- _currentScript->commands[i].param8,
- _currentScript->commands[i].param9);
+ "Line: %02d/%02d :: 0x%02X (%d, %d, %d, %d, %d, %d, %d, %d, %d)",
+ i,
+ _currentScript->commands[0].numLines - 1,
+ _currentScript->commands[i].opcode,
+ _currentScript->commands[i].param1,
+ _currentScript->commands[i].param2,
+ _currentScript->commands[i].param3,
+ _currentScript->commands[i].param4,
+ _currentScript->commands[i].param5,
+ _currentScript->commands[i].param6,
+ _currentScript->commands[i].param7,
+ _currentScript->commands[i].param8,
+ _currentScript->commands[i].param9);
}
}
}
@@ -223,10 +223,10 @@ void ActionList::processActionListSub02(ActionDefinitions* script, ActionCommand
int v13 = command->param4;
int v4 = script->counter / command->param2 + 4;
for (int i = 7; i > 0; i--) {
- barrierIdx = _scene->worldstats()->getBarrierIndexById(v13);
- if (barrierIdx >= 0)
- _scene->worldstats()->barriers[barrierIdx].field_67C = v4;
- v13 += 4;
+ barrierIdx = _scene->worldstats()->getBarrierIndexById(v13);
+ if (barrierIdx >= 0)
+ _scene->worldstats()->barriers[barrierIdx].field_67C = v4;
+ v13 += 4;
}
// TODO
switch (_scene->getSceneIndex()) {
@@ -246,7 +246,7 @@ void ActionList::processActionListSub02(ActionDefinitions* script, ActionCommand
warning("Scene 4 / v4 = 0 Not Implemented");
break;
default:
- return;
+ return;
}
}
}
@@ -280,16 +280,16 @@ int ActionList::process() {
// Check function return
if (cmdRet == -1)
warning("Incomplete opcode %s (0x%02X) in Scene %d Line %d",
- function_map[opcode].name,
- currentCommand->opcode,
- _scene->getSceneIndex(),
- currentLine);
+ function_map[opcode].name,
+ currentCommand->opcode,
+ _scene->getSceneIndex(),
+ currentLine);
if (cmdRet == -2)
warning("Unhandled opcode %s (0x%02X) in Scene %d Line %d",
- function_map[opcode].name,
- currentCommand->opcode,
- _scene->getSceneIndex(),
- currentLine);
+ function_map[opcode].name,
+ currentCommand->opcode,
+ _scene->getSceneIndex(),
+ currentLine);
currentLine += lineIncrement;
currentLoops++;
@@ -434,9 +434,9 @@ int kPlayAnimation(ActionCommand *cmd, Scene *scn) {
barrier->flags |= 0x10000;
} else {
barrier->flags &= 0x10000;
- if(barrier->flags == 0) {
+ if (barrier->flags == 0) {
barrier->flags &= 0x10E38;
- if(barrier->flags == 0) {
+ if (barrier->flags == 0) {
barrier->flags |= 8;
}
} else {
@@ -447,11 +447,11 @@ int kPlayAnimation(ActionCommand *cmd, Scene *scn) {
barrier->setNextFrame(barrier->flags);
- if(barrier->field_688 == 1) {
+ if (barrier->field_688 == 1) {
// TODO: get barrier position
}
- if(cmd->param2) {
+ if (cmd->param2) {
cmd->param2 = 2;
scn->actions()->lineIncrement = 1;
}
@@ -526,10 +526,10 @@ int kHideActor(ActionCommand *cmd, Scene *scn) {
scn->getActor()->visible(false);
else
debugC(kDebugLevelScripts,
- "Requested invalid actor ID:0x%02X in Scene %d Line %d.",
- cmd->param1,
- scn->getSceneIndex(),
- scn->actions()->currentLine);
+ "Requested invalid actor ID:0x%02X in Scene %d Line %d.",
+ cmd->param1,
+ scn->getSceneIndex(),
+ scn->actions()->currentLine);
return 0;
}
@@ -546,16 +546,16 @@ int kShowActor(ActionCommand *cmd, Scene *scn) {
scn->getActor()->visible(true);
else
debugC(kDebugLevelScripts,
- "Requested invalid actor ID:0x%02X in Scene %d Line %d.",
- cmd->param1,
- scn->getSceneIndex(),
- scn->actions()->currentLine);
+ "Requested invalid actor ID:0x%02X in Scene %d Line %d.",
+ cmd->param1,
+ scn->getSceneIndex(),
+ scn->actions()->currentLine);
- return 0;
+ return 0;
}
int kSetActorStats(ActionCommand *cmd, Scene *scn) {
- WorldStats *ws = scn->worldstats();
+ WorldStats *ws = scn->worldstats();
// TODO
// param1 == actorIndex. Implement when we've got more than one actor
@@ -563,7 +563,7 @@ int kSetActorStats(ActionCommand *cmd, Scene *scn) {
// TODO This needs to be depreciated, but it's setting the actor's x/y
// and bounding rect top/left.
// This needs to be rolled into the proper place
- scn->getActor()->setPosition(cmd->param2, cmd->param3);
+ scn->getActor()->setPosition(cmd->param2, cmd->param3);
scn->getActor()->setPosition_40A260(cmd->param2, cmd->param3, cmd->param4, cmd->param5);
@@ -612,7 +612,7 @@ int kEnableBarriers(ActionCommand *cmd, Scene *scn) {
if (!scn->actions()->getScript()->counter && scn->getSceneIndex() != 13 && sndIdx != 0) {
scn->vm()->sound()->playSound(((sndIdx != 0) & 5) + 0x80120001,
- false, scn->vm()->soundVolume(), 0);
+ false, scn->vm()->soundVolume(), 0);
}
if (scn->actions()->getScript()->counter >= 3 * v59 - 1) {
@@ -625,12 +625,12 @@ int kEnableBarriers(ActionCommand *cmd, Scene *scn) {
int v62 = scn->actions()->getScript()->counter + 1;
scn->actions()->getScript()->counter = v62;
if (sndIdx) {
- v64 = 1;
- int v170 = 3 - v62 / v59;
- scn->worldstats()->barriers[barIdx].field_67C = v170;
+ v64 = 1;
+ int v170 = 3 - v62 / v59;
+ scn->worldstats()->barriers[barIdx].field_67C = v170;
} else {
- v64 = 0;
- scn->worldstats()->barriers[barIdx].field_67C = v62 / v59 + 1;
+ v64 = 0;
+ scn->worldstats()->barriers[barIdx].field_67C = v62 / v59 + 1;
}
scn->actions()->processActionListSub02(scn->actions()->getScript(), cmd, v64);
@@ -655,10 +655,10 @@ int kDestroyBarrier(ActionCommand *cmd, Scene *scn) {
scn->vm()->screen()->deleteGraphicFromQueue(barrier->resId);
} else
debugC(kDebugLevelScripts,
- "Requested invalid object ID:0x%02X in Scene %d Line %d.",
- cmd->param1,
- scn->getSceneIndex(),
- scn->actions()->currentLine);
+ "Requested invalid object ID:0x%02X in Scene %d Line %d.",
+ cmd->param1,
+ scn->getSceneIndex(),
+ scn->actions()->currentLine);
return 0;
}
@@ -784,8 +784,8 @@ int kJumpIfActorField638(ActionCommand *cmd, Scene *scn) {
int kChangeScene(ActionCommand *cmd, Scene *scn) {
scn->actions()->delayedSceneIndex = cmd->param1 + 4;
debug(kDebugLevelScripts,
- "Queueing Scene Change to scene %d...",
- scn->actions()->delayedSceneIndex);
+ "Queueing Scene Change to scene %d...",
+ scn->actions()->delayedSceneIndex);
return 0;
}
@@ -885,22 +885,22 @@ int kWaitUntilFramePlayed(ActionCommand *cmd, Scene *scn) {
Barrier *barrier = scn->worldstats()->getBarrierById(cmd->param1);
if (barrier) {
- uint32 frameNum = 0;
- if (cmd->param2 == -1)
- frameNum = barrier->frameCount - 1;
- else
- frameNum = cmd->param2;
-
- if (barrier->frameIdx < frameNum) {
- scn->actions()->lineIncrement = 0;
- scn->actions()->waitCycle = true;
- }
+ uint32 frameNum = 0;
+ if (cmd->param2 == -1)
+ frameNum = barrier->frameCount - 1;
+ else
+ frameNum = cmd->param2;
+
+ if (barrier->frameIdx < frameNum) {
+ scn->actions()->lineIncrement = 0;
+ scn->actions()->waitCycle = true;
+ }
} else
debugC(kDebugLevelScripts,
- "Requested invalid object ID:0x%02X in Scene %d Line %d.",
- cmd->param1,
- scn->getSceneIndex(),
- scn->actions()->currentLine);
+ "Requested invalid object ID:0x%02X in Scene %d Line %d.",
+ cmd->param1,
+ scn->getSceneIndex(),
+ scn->actions()->currentLine);
return 0;
}
@@ -926,7 +926,7 @@ int k_unk40_SOUND(ActionCommand *cmd, Scene *scn) {
}
int kPlaySpeech(ActionCommand *cmd, Scene *scn) {
- //TODO - Add support for other param options
+ //TODO - Add support for other param options
uint32 sndIdx = cmd->param1;
if ((int)sndIdx >= 0) {
@@ -938,10 +938,10 @@ int kPlaySpeech(ActionCommand *cmd, Scene *scn) {
}
} else
debugC(kDebugLevelScripts,
- "Requested invalid sound ID:0x%02X in Scene %d Line %d.",
- cmd->param1,
- scn->getSceneIndex(),
- scn->actions()->currentLine);
+ "Requested invalid sound ID:0x%02X in Scene %d Line %d.",
+ cmd->param1,
+ scn->getSceneIndex(),
+ scn->actions()->currentLine);
return -1;
}
@@ -1117,7 +1117,7 @@ int kSetBarrierFrameIdxFlaged(ActionCommand *cmd, Scene *scn) {
}
int k_unk59(ActionCommand *cmd, Scene *scn) {
- return -2;
+ return -2;
}
int k_unk5A(ActionCommand *cmd, Scene *scn) {
return -2;
diff --git a/engines/asylum/actionlist.h b/engines/asylum/actionlist.h
index 50f1b07f06..822487335b 100644
--- a/engines/asylum/actionlist.h
+++ b/engines/asylum/actionlist.h
@@ -85,7 +85,9 @@ public:
bool waitCycle;
void setScriptByIndex(uint32 index);
- ActionDefinitions* getScript() { return _currentScript; }
+ ActionDefinitions* getScript() {
+ return _currentScript;
+ }
int process();
void processActionListSub02(ActionDefinitions* script, ActionCommand* command, int a4);
diff --git a/engines/asylum/actor.cpp b/engines/asylum/actor.cpp
index 551b5e0660..b3b6cf8001 100644
--- a/engines/asylum/actor.cpp
+++ b/engines/asylum/actor.cpp
@@ -65,7 +65,7 @@ void Actor::setDirection(int dir) {
void Actor::setRawResources(uint8 *data) {
byte *dataPtr = data;
- for (uint32 i = 0; i < 60; i++){
+ for (uint32 i = 0; i < 60; i++) {
_resources[i] = READ_UINT32(dataPtr);
dataPtr += 4;
}
@@ -94,7 +94,7 @@ void Actor::setAction(int action) {
int w = frame->surface.w / 2;
for (int tmpX = 0; tmpX < w; tmpX++) {
SWAP(buffer[tmpY * frame->surface.pitch + tmpX],
- buffer[tmpY * frame->surface.pitch + frame->surface.w - 1 - tmpX]);
+ buffer[tmpY * frame->surface.pitch + frame->surface.w - 1 - tmpX]);
}
}
}
@@ -104,7 +104,7 @@ void Actor::setAction(int action) {
}
void Actor::setActionByIndex(int index) {
- setAction(_resources[index] & 0xFFFF);
+ setAction(_resources[index] & 0xFFFF);
}
GraphicFrame *Actor::getFrame() {
@@ -114,7 +114,7 @@ GraphicFrame *Actor::getFrame() {
if (frameNum < _graphic->getFrameCount() - 1) {
frameNum++;
- }else{
+ } else {
frameNum = 0;
}
@@ -128,30 +128,30 @@ GraphicFrame *Actor::getFrame() {
void Actor::drawActorAt(uint32 curX, uint32 curY) {
GraphicFrame *frame = getFrame();
- WorldStats *ws = _scene->worldstats();
+ WorldStats *ws = _scene->worldstats();
_scene->vm()->screen()->copyRectToScreenWithTransparency(
- ((byte *)frame->surface.pixels),
- frame->surface.w,
- curX - ws->targetX,
- curY - ws->targetY,
- frame->surface.w,
- frame->surface.h );
+ ((byte *)frame->surface.pixels),
+ frame->surface.w,
+ curX - ws->targetX,
+ curY - ws->targetY,
+ frame->surface.w,
+ frame->surface.h);
x = curX;
y = curY;
}
void Actor::drawActor() {
GraphicFrame *frame = getFrame();
- WorldStats *ws = _scene->worldstats();
+ WorldStats *ws = _scene->worldstats();
_scene->vm()->screen()->copyToBackBufferWithTransparency(
- ((byte *)frame->surface.pixels),
- frame->surface.w,
- x - ws->targetX,
- y - frame->surface.h - ws->targetY,
- frame->surface.w,
- frame->surface.h );
+ ((byte *)frame->surface.pixels),
+ frame->surface.w,
+ x - ws->targetX,
+ y - frame->surface.h - ws->targetY,
+ frame->surface.w,
+ frame->surface.h);
}
void Actor::setWalkArea(ActionArea *target) {
@@ -164,7 +164,7 @@ void Actor::setWalkArea(ActionArea *target) {
void Actor::walkTo(uint32 curX, uint32 curY) {
int newAction = currentAction;
- WorldStats *ws = _scene->worldstats();
+ WorldStats *ws = _scene->worldstats();
// step is the increment by which to move the
// actor in a given direction
@@ -227,7 +227,7 @@ void Actor::walkTo(uint32 curX, uint32 curY) {
rect.bottom = newY + 4;
surface.frameRect(rect, 0x33);
- _scene->vm()->screen()->copyRectToScreen((byte*)surface.pixels, 5, newX - ws->targetX, newY - ws->targetY, 5, 5);
+ _scene->vm()->screen()->copyRectToScreen((byte*)surface.pixels, 5, newX - ws->targetX, newY - ws->targetY, 5, 5);
surface.free();
@@ -245,7 +245,7 @@ void Actor::walkTo(uint32 curX, uint32 curY) {
if (ws->actions[a].actionType == 0) {
area = &ws->actions[a];
PolyDefinitions poly = _scene->polygons()->entries[area->polyIdx];
- if (poly.contains(x, y)) {
+ if (poly.contains(x, y)) {
availableAreas[areaPtr] = a;
areaPtr++;
@@ -275,20 +275,20 @@ void Actor::walkTo(uint32 curX, uint32 curY) {
}
void Actor::update_4072A0(int param) {
- int newGrId = 0;
- int newDir = 0;
+ int newGrId = 0;
+ int newDir = 0;
switch (param) {
- case 4:
- case 6:
- case 14:
- if(this->direction > 4)
- newDir = 8 - this->direction;
- else
- newDir = this->direction;
- newGrId = this->grResTable[newDir + 5];
- break;
+ case 4:
+ case 6:
+ case 14:
+ if (this->direction > 4)
+ newDir = 8 - this->direction;
+ else
+ newDir = this->direction;
+ newGrId = this->grResTable[newDir + 5];
+ break;
case 5:
newDir = this->direction;
@@ -300,12 +300,12 @@ void Actor::update_4072A0(int param) {
}
- this->grResId = newGrId;
+ this->grResId = newGrId;
- GraphicResource *gra = new GraphicResource(_resPack, this->grResId);
- this->frameCount = gra->getFrameCount();
- this->frameNum = 0;
- delete gra;
+ GraphicResource *gra = new GraphicResource(_resPack, this->grResId);
+ this->frameCount = gra->getFrameCount();
+ this->frameNum = 0;
+ delete gra;
this->updateType = param;
}
diff --git a/engines/asylum/actor.h b/engines/asylum/actor.h
index 06c8b8e06f..763a27ef8e 100644
--- a/engines/asylum/actor.h
+++ b/engines/asylum/actor.h
@@ -140,7 +140,9 @@ public:
*/
void setRawResources(uint8* data);
- bool visible() { return flags & 0x01; }
+ bool visible() {
+ return flags & 0x01;
+ }
void visible(bool value);
void setPosition(uint32 targetX, uint32 targetY);
void setDirection(int dir);
@@ -156,11 +158,15 @@ public:
// FIXME
// I don't really like how this is used in the scene constructor
- void setResourcePack(ResourcePack *res) { _resPack = res; }
+ void setResourcePack(ResourcePack *res) {
+ _resPack = res;
+ }
// XXX Hack to get a reference to the parent scene
// into the actor instance
- void setScene(Scene *scene) { _scene = scene; }
+ void setScene(Scene *scene) {
+ _scene = scene;
+ }
// OLD METHODS
// TODO ALL of these need to be depreciated in favour
@@ -222,19 +228,19 @@ public:
uint32 soundResId; // field_93C
uint32 field_940;
uint32 field_944;
- uint32 field_948;
- uint32 field_94C;
- uint32 field_950;
- uint32 field_954;
- uint32 field_958;
- uint32 field_95C;
- uint32 field_960;
- uint32 field_964;
- uint32 field_968;
- uint32 field_96C;
- uint32 field_970;
- uint32 field_974;
- uint32 field_978;
+ uint32 field_948;
+ uint32 field_94C;
+ uint32 field_950;
+ uint32 field_954;
+ uint32 field_958;
+ uint32 field_95C;
+ uint32 field_960;
+ uint32 field_964;
+ uint32 field_968;
+ uint32 field_96C;
+ uint32 field_970;
+ uint32 field_974;
+ uint32 field_978;
uint32 actionIdx1;
// TODO field_980 till field_9A0
@@ -252,60 +258,60 @@ private:
// Angle Tables used by getAngle()
const uint8 angleTable01[256] = {
- 0x00,0x00,0x00,0x01,0x01,0x01,0x01,0x02,0x02,0x02,0x02,0x02,0x03,0x03,0x03,0x03,
- 0x04,0x04,0x04,0x04,0x04,0x05,0x05,0x05,0x05,0x06,0x06,0x06,0x06,0x06,0x07,0x07,
- 0x07,0x07,0x08,0x08,0x08,0x08,0x08,0x09,0x09,0x09,0x09,0x0A,0x0A,0x0A,0x0A,0x0A,
- 0x0B,0x0B,0x0B,0x0B,0x0B,0x0C,0x0C,0x0C,0x0C,0x0D,0x0D,0x0D,0x0D,0x0D,0x0E,0x0E,
- 0x0E,0x0E,0x0E,0x0F,0x0F,0x0F,0x0F,0x10,0x10,0x10,0x10,0x10,0x11,0x11,0x11,0x11,
- 0x11,0x12,0x12,0x12,0x12,0x12,0x13,0x13,0x13,0x13,0x13,0x14,0x14,0x14,0x14,0x14,
- 0x15,0x15,0x15,0x15,0x15,0x16,0x16,0x16,0x16,0x16,0x16,0x17,0x17,0x17,0x17,0x17,
- 0x18,0x18,0x18,0x18,0x18,0x19,0x19,0x19,0x19,0x19,0x19,0x1A,0x1A,0x1A,0x1A,0x1A,
- 0x1B,0x1B,0x1B,0x1B,0x1B,0x1B,0x1C,0x1C,0x1C,0x1C,0x1C,0x1D,0x1D,0x1D,0x1D,0x1D,
- 0x1D,0x1E,0x1E,0x1E,0x1E,0x1E,0x1E,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x20,0x20,0x20,
- 0x20,0x20,0x20,0x20,0x21,0x21,0x21,0x21,0x21,0x21,0x22,0x22,0x22,0x22,0x22,0x22,
- 0x23,0x23,0x23,0x23,0x23,0x23,0x23,0x24,0x24,0x24,0x24,0x24,0x24,0x24,0x25,0x25,
- 0x25,0x25,0x25,0x25,0x25,0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x27,0x27,0x27,0x27,
- 0x27,0x27,0x27,0x27,0x28,0x28,0x28,0x28,0x28,0x28,0x28,0x29,0x29,0x29,0x29,0x29,
- 0x29,0x29,0x29,0x2A,0x2A,0x2A,0x2A,0x2A,0x2A,0x2A,0x2A,0x2B,0x2B,0x2B,0x2B,0x2B,
- 0x2B,0x2B,0x2B,0x2C,0x2C,0x2C,0x2C,0x2C,0x2C,0x2C,0x2C,0x2C,0x2D,0x2D,0x2D,0x2D
+ 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x03, 0x03, 0x03, 0x03,
+ 0x04, 0x04, 0x04, 0x04, 0x04, 0x05, 0x05, 0x05, 0x05, 0x06, 0x06, 0x06, 0x06, 0x06, 0x07, 0x07,
+ 0x07, 0x07, 0x08, 0x08, 0x08, 0x08, 0x08, 0x09, 0x09, 0x09, 0x09, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A,
+ 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0C, 0x0C, 0x0C, 0x0C, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0E, 0x0E,
+ 0x0E, 0x0E, 0x0E, 0x0F, 0x0F, 0x0F, 0x0F, 0x10, 0x10, 0x10, 0x10, 0x10, 0x11, 0x11, 0x11, 0x11,
+ 0x11, 0x12, 0x12, 0x12, 0x12, 0x12, 0x13, 0x13, 0x13, 0x13, 0x13, 0x14, 0x14, 0x14, 0x14, 0x14,
+ 0x15, 0x15, 0x15, 0x15, 0x15, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x17, 0x17, 0x17, 0x17, 0x17,
+ 0x18, 0x18, 0x18, 0x18, 0x18, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A,
+ 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1D, 0x1D, 0x1D, 0x1D, 0x1D,
+ 0x1D, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x21, 0x21, 0x21, 0x21, 0x21, 0x21, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22,
+ 0x23, 0x23, 0x23, 0x23, 0x23, 0x23, 0x23, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x25, 0x25,
+ 0x25, 0x25, 0x25, 0x25, 0x25, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x27, 0x27, 0x27, 0x27,
+ 0x27, 0x27, 0x27, 0x27, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, 0x29, 0x29, 0x29, 0x29, 0x29,
+ 0x29, 0x29, 0x29, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x2B, 0x2B, 0x2B, 0x2B, 0x2B,
+ 0x2B, 0x2B, 0x2B, 0x2C, 0x2C, 0x2C, 0x2C, 0x2C, 0x2C, 0x2C, 0x2C, 0x2C, 0x2D, 0x2D, 0x2D, 0x2D
};
const uint8 angleTable02[256] = {
- 0x00,0x04,0x07,0x0B,0x0E,0x11,0x15,0x18,0x1B,0x1D,0x20,0x23,0x25,0x27,0x29,0x2B,
- 0x2D,0x2F,0x30,0x32,0x33,0x35,0x36,0x37,0x38,0x39,0x3A,0x3B,0x3C,0x3D,0x3E,0x3F,
- 0x3F,0x40,0x41,0x41,0x42,0x43,0x43,0x44,0x44,0x45,0x45,0x46,0x46,0x46,0x47,0x47,
- 0x48,0x48,0x48,0x49,0x49,0x49,0x49,0x4A,0x4A,0x4A,0x4B,0x4B,0x4B,0x4B,0x4C,0x4C,
- 0x4C,0x4C,0x4C,0x4D,0x4D,0x4D,0x4D,0x4D,0x4D,0x4E,0x4E,0x4E,0x4E,0x4E,0x4E,0x4F,
- 0x4F,0x4F,0x4F,0x4F,0x4F,0x4F,0x4F,0x50,0x50,0x50,0x50,0x50,0x50,0x50,0x50,0x50,
- 0x51,0x51,0x51,0x51,0x51,0x51,0x51,0x51,0x51,0x51,0x51,0x51,0x52,0x52,0x52,0x52,
- 0x52,0x52,0x52,0x52,0x52,0x52,0x52,0x52,0x52,0x52,0x53,0x53,0x53,0x53,0x53,0x53,
- 0x53,0x53,0x53,0x53,0x53,0x53,0x53,0x53,0x53,0x53,0x53,0x53,0x53,0x54,0x54,0x54,
- 0x54,0x54,0x54,0x54,0x54,0x54,0x54,0x54,0x54,0x54,0x54,0x54,0x54,0x54,0x54,0x54,
- 0x54,0x54,0x54,0x54,0x54,0x54,0x54,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,
- 0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,
- 0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x56,0x56,0x56,0x56,
- 0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,
- 0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,
- 0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56
+ 0x00, 0x04, 0x07, 0x0B, 0x0E, 0x11, 0x15, 0x18, 0x1B, 0x1D, 0x20, 0x23, 0x25, 0x27, 0x29, 0x2B,
+ 0x2D, 0x2F, 0x30, 0x32, 0x33, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F,
+ 0x3F, 0x40, 0x41, 0x41, 0x42, 0x43, 0x43, 0x44, 0x44, 0x45, 0x45, 0x46, 0x46, 0x46, 0x47, 0x47,
+ 0x48, 0x48, 0x48, 0x49, 0x49, 0x49, 0x49, 0x4A, 0x4A, 0x4A, 0x4B, 0x4B, 0x4B, 0x4B, 0x4C, 0x4C,
+ 0x4C, 0x4C, 0x4C, 0x4D, 0x4D, 0x4D, 0x4D, 0x4D, 0x4D, 0x4E, 0x4E, 0x4E, 0x4E, 0x4E, 0x4E, 0x4F,
+ 0x4F, 0x4F, 0x4F, 0x4F, 0x4F, 0x4F, 0x4F, 0x50, 0x50, 0x50, 0x50, 0x50, 0x50, 0x50, 0x50, 0x50,
+ 0x51, 0x51, 0x51, 0x51, 0x51, 0x51, 0x51, 0x51, 0x51, 0x51, 0x51, 0x51, 0x52, 0x52, 0x52, 0x52,
+ 0x52, 0x52, 0x52, 0x52, 0x52, 0x52, 0x52, 0x52, 0x52, 0x52, 0x53, 0x53, 0x53, 0x53, 0x53, 0x53,
+ 0x53, 0x53, 0x53, 0x53, 0x53, 0x53, 0x53, 0x53, 0x53, 0x53, 0x53, 0x53, 0x53, 0x54, 0x54, 0x54,
+ 0x54, 0x54, 0x54, 0x54, 0x54, 0x54, 0x54, 0x54, 0x54, 0x54, 0x54, 0x54, 0x54, 0x54, 0x54, 0x54,
+ 0x54, 0x54, 0x54, 0x54, 0x54, 0x54, 0x54, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
+ 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
+ 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x56, 0x56, 0x56, 0x56,
+ 0x56, 0x56, 0x56, 0x56, 0x56, 0x56, 0x56, 0x56, 0x56, 0x56, 0x56, 0x56, 0x56, 0x56, 0x56, 0x56,
+ 0x56, 0x56, 0x56, 0x56, 0x56, 0x56, 0x56, 0x56, 0x56, 0x56, 0x56, 0x56, 0x56, 0x56, 0x56, 0x56,
+ 0x56, 0x56, 0x56, 0x56, 0x56, 0x56, 0x56, 0x56, 0x56, 0x56, 0x56, 0x56, 0x56, 0x56, 0x56, 0x56
};
const uint8 angleTable03[256] = {
- 0x00,0x45,0x63,0x72,0x76,0x79,0x81,0x82,0x83,0x84,0x84,0x85,0x85,0x86,0x86,0x86,
- 0x86,0x87,0x87,0x87,0x87,0x87,0x87,0x88,0x88,0x88,0x88,0x88,0x88,0x88,0x88,0x88,
- 0x88,0x88,0x88,0x88,0x88,0x88,0x88,0x89,0x89,0x89,0x89,0x89,0x89,0x89,0x89,0x89,
- 0x89,0x89,0x89,0x89,0x89,0x89,0x89,0x89,0x89,0x89,0x89,0x89,0x89,0x89,0x89,0x89,
- 0x89,0x89,0x89,0x89,0x89,0x89,0x89,0x89,0x89,0x89,0x89,0x89,0x89,0x89,0x89,0x89,
- 0x89,0x89,0x89,0x89,0x89,0x89,0x89,0x89,0x89,0x89,0x89,0x89,0x89,0x89,0x89,0x89,
- 0x89,0x89,0x89,0x89,0x89,0x89,0x89,0x89,0x89,0x89,0x89,0x89,0x89,0x89,0x89,0x89,
- 0x89,0x89,0x89,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,
- 0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,
- 0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,
- 0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,
- 0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,
- 0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,
- 0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,
- 0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,
- 0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90
+ 0x00, 0x45, 0x63, 0x72, 0x76, 0x79, 0x81, 0x82, 0x83, 0x84, 0x84, 0x85, 0x85, 0x86, 0x86, 0x86,
+ 0x86, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88,
+ 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89,
+ 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89,
+ 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89,
+ 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89,
+ 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89,
+ 0x89, 0x89, 0x89, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90,
+ 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90,
+ 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90,
+ 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90,
+ 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90,
+ 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90,
+ 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90,
+ 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90,
+ 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90
};
} // end of namespace Asylum
diff --git a/engines/asylum/asylum.cpp b/engines/asylum/asylum.cpp
index 08bf9bcf51..b8a20739ff 100644
--- a/engines/asylum/asylum.cpp
+++ b/engines/asylum/asylum.cpp
@@ -35,8 +35,8 @@
namespace Asylum {
AsylumEngine::AsylumEngine(OSystem *system, Common::Language language)
- : Engine(system) {
-
+ : Engine(system) {
+
Common::addDebugChannel(kDebugLevelMain, "Main", "Generic debug level");
Common::addDebugChannel(kDebugLevelResources, "Resources", "Resources debugging");
Common::addDebugChannel(kDebugLevelSprites, "Sprites", "Sprites debugging");
@@ -45,8 +45,8 @@ AsylumEngine::AsylumEngine(OSystem *system, Common::Language language)
Common::addDebugChannel(kDebugLevelScripts, "Scripts", "Scripts debugging");
Common::addDebugChannel(kDebugLevelSound, "Sound", "Sound debugging");
Common::addDebugChannel(kDebugLevelSavegame, "Savegame", "Saving & restoring game debugging");
- Common::addDebugChannel(kDebugLevelScene, "Scene", "Scene process and draw debugging");
-
+ Common::addDebugChannel(kDebugLevelScene, "Scene", "Scene process and draw debugging");
+
Common::File::addDefaultDirectory(_gameDataDir.getChild("Data"));
Common::File::addDefaultDirectory(_gameDataDir.getChild("Vids"));
Common::File::addDefaultDirectory(_gameDataDir.getChild("Music"));
@@ -76,7 +76,7 @@ Common::Error AsylumEngine::run() {
Common::Error err;
err = init();
if (err != Common::kNoError)
- return err;
+ return err;
return go();
}
@@ -109,7 +109,7 @@ Common::Error AsylumEngine::go() {
// in the processActionList() method when the necessary action is fired.
// Once the blowup puzzle testing is removed from checkForEvent(), this
// can be removed as well.
- _scene->setBlowUpPuzzle(new BlowUpPuzzleVCR(_scene));
+ _scene->setBlowUpPuzzle(new BlowUpPuzzleVCR(_scene));
// XXX This can probably also be rolled into the scene constructor.
// Investigate if this will fuck up the execution sequence though :P
@@ -207,19 +207,19 @@ void AsylumEngine::checkForEvent(bool doUpdate) { // k_sub_40AE30 (0040AE30)
_scene->enterScene();
} else if (_scene->isActive()) {
_mainMenu->openMenu();
- } else if (_scene->getBlowUpPuzzle()->isActive()) {
- _scene->getBlowUpPuzzle()->closeBlowUp();
- _scene->enterScene();
+ } else if (_scene->getBlowUpPuzzle()->isActive()) {
+ _scene->getBlowUpPuzzle()->closeBlowUp();
+ _scene->enterScene();
}
return;
}
- // XXX: TEST ONLY
- if (ev.kbd.keycode == Common::KEYCODE_b) {
- //_mainMenu->closeMenu();
- _scene->getBlowUpPuzzle()->openBlowUp();
- }
+ // XXX: TEST ONLY
+ if (ev.kbd.keycode == Common::KEYCODE_b) {
+ //_mainMenu->closeMenu();
+ _scene->getBlowUpPuzzle()->openBlowUp();
+ }
if (ev.kbd.flags == Common::KBD_CTRL) {
if (ev.kbd.keycode == Common::KEYCODE_d)
@@ -244,7 +244,7 @@ void AsylumEngine::checkForEvent(bool doUpdate) { // k_sub_40AE30 (0040AE30)
else if (_scene->isActive())
// Pass events to the game
_scene->handleEvent(&ev, doUpdate);
- else if (_scene->getBlowUpPuzzle()->isActive())
+ else if (_scene->getBlowUpPuzzle()->isActive())
// Pass events to BlowUp Puzzles
_scene->getBlowUpPuzzle()->handleEvent(&ev, doUpdate);
@@ -270,10 +270,10 @@ void AsylumEngine::processDelayedEvents() {
// check for a delayed scene change
int sceneIdx = _scene->actions()->delayedSceneIndex;
- if (sceneIdx >=0 && !_scene->actions()->processing) {
+ if (sceneIdx >= 0 && !_scene->actions()->processing) {
_sound->stopMusic();
_sound->stopAllSounds();
-
+
if (_scene)
delete _scene;
diff --git a/engines/asylum/asylum.h b/engines/asylum/asylum.h
index 00f75069fa..ebcd283118 100644
--- a/engines/asylum/asylum.h
+++ b/engines/asylum/asylum.h
@@ -68,7 +68,7 @@ enum kDebugLevels {
kDebugLevelScripts = 1 << 5,
kDebugLevelSound = 1 << 6,
kDebugLevelSavegame = 1 << 7,
- kDebugLevelScene = 1 << 8
+ kDebugLevelScene = 1 << 8
};
class AsylumEngine: public Engine {
@@ -83,19 +83,31 @@ public:
virtual Common::Error run();
virtual bool hasFeature(EngineFeature f) const;
- void setGameFlag(int flag);
- void clearGameFlag(int flag);
- void toggleGameFlag(int flag);
- bool isGameFlagSet(int flag);
- bool isGameFlagNotSet(int flag);
-
- Video* video() { return _video; }
- Sound* sound() { return _sound; }
- Screen* screen() { return _screen; }
- Scene* scene() { return _scene; }
-
- int ambientVolume() { return _ambientVolume; }
- int soundVolume() { return _soundVolume; }
+ void setGameFlag(int flag);
+ void clearGameFlag(int flag);
+ void toggleGameFlag(int flag);
+ bool isGameFlagSet(int flag);
+ bool isGameFlagNotSet(int flag);
+
+ Video* video() {
+ return _video;
+ }
+ Sound* sound() {
+ return _sound;
+ }
+ Screen* screen() {
+ return _screen;
+ }
+ Scene* scene() {
+ return _scene;
+ }
+
+ int ambientVolume() {
+ return _ambientVolume;
+ }
+ int soundVolume() {
+ return _soundVolume;
+ }
private:
void checkForEvent(bool doUpdate);
diff --git a/engines/asylum/barrier.cpp b/engines/asylum/barrier.cpp
index 2597b08158..0fcde03e76 100644
--- a/engines/asylum/barrier.cpp
+++ b/engines/asylum/barrier.cpp
@@ -46,7 +46,7 @@ uint32 Barrier::getRandomId() {
numRes++;
}
}
- if(numRes > 0)
+ if (numRes > 0)
return rndResId[rand() % numRes];
return resId;
diff --git a/engines/asylum/blowuppuzzle.cpp b/engines/asylum/blowuppuzzle.cpp
index e7a879c221..111fb7f862 100644
--- a/engines/asylum/blowuppuzzle.cpp
+++ b/engines/asylum/blowuppuzzle.cpp
@@ -39,25 +39,25 @@ BlowUpPuzzle::~BlowUpPuzzle() {
BlowUpPuzzleVCR::BlowUpPuzzleVCR(Scene *scene): BlowUpPuzzle(scene) {
_leftClickUp = false;
- _leftClickDown = false;
- _rightClickDown = false;
+ _leftClickDown = false;
+ _rightClickDown = false;
_active = false;
- _bgResource = _scene->getGraphicResource(_scene->worldstats()->grResId[0]);
- _tvScreenAnimIdx = 0;
- _isAccomplished = false;
+ _bgResource = _scene->getGraphicResource(_scene->worldstats()->grResId[0]);
+ _tvScreenAnimIdx = 0;
+ _isAccomplished = false;
- // setup cursor
- _cursor = new Cursor(_scene->getResourcePack());
+ // setup cursor
+ _cursor = new Cursor(_scene->getResourcePack());
- // reset all states
- memset(&_jacksState,0,sizeof(_jacksState));
- memset(&_holesState,0,sizeof(_holesState));
- memset(&_buttonsState,0,sizeof(_buttonsState));
+ // reset all states
+ memset(&_jacksState, 0, sizeof(_jacksState));
+ memset(&_holesState, 0, sizeof(_holesState));
+ memset(&_buttonsState, 0, sizeof(_buttonsState));
}
BlowUpPuzzleVCR::~BlowUpPuzzleVCR() {
delete _cursor;
- delete _bgResource;
+ delete _bgResource;
}
void BlowUpPuzzleVCR::openBlowUp() {
@@ -68,8 +68,8 @@ void BlowUpPuzzleVCR::openBlowUp() {
// Load the graphics palette
_scene->vm()->screen()->setPalette(_scene->getResourcePack(), _scene->worldstats()->grResId[29]);
-
- // show blow up puzzle BG
+
+ // show blow up puzzle BG
GraphicFrame *bg = _bgResource->getFrame(0);
_scene->vm()->screen()->copyToBackBuffer((byte *)bg->surface.pixels, bg->surface.w, 0, 0, bg->surface.w, bg->surface.h);
@@ -78,8 +78,8 @@ void BlowUpPuzzleVCR::openBlowUp() {
_cursor->show();
_leftClickUp = false;
- _leftClickDown = false;
- _rightClickDown = false;
+ _leftClickDown = false;
+ _rightClickDown = false;
}
void BlowUpPuzzleVCR::closeBlowUp() {
@@ -97,12 +97,12 @@ void BlowUpPuzzleVCR::handleEvent(Common::Event *event, bool doUpdate) {
case Common::EVENT_LBUTTONUP:
_leftClickUp = true;
break;
- case Common::EVENT_LBUTTONDOWN:
+ case Common::EVENT_LBUTTONDOWN:
_leftClickDown = true;
break;
- case Common::EVENT_RBUTTONDOWN:
+ case Common::EVENT_RBUTTONDOWN:
_rightClickDown = true;
- break;
+ break;
default:
break;
}
@@ -117,492 +117,492 @@ void BlowUpPuzzle::playSound(uint resourceId, bool loop) {
}
int BlowUpPuzzleVCR::inPolyRegion(int x, int y, int polyIdx) {
- return x >= BlowUpPuzzleVCRPolies[polyIdx].left && x <= BlowUpPuzzleVCRPolies[polyIdx].right &&
- y >= BlowUpPuzzleVCRPolies[polyIdx].top && y <= BlowUpPuzzleVCRPolies[polyIdx].bottom;
+ return x >= BlowUpPuzzleVCRPolies[polyIdx].left && x <= BlowUpPuzzleVCRPolies[polyIdx].right &&
+ y >= BlowUpPuzzleVCRPolies[polyIdx].top && y <= BlowUpPuzzleVCRPolies[polyIdx].bottom;
}
void BlowUpPuzzleVCR::update() {
- _scene->vm()->screen()->clearGraphicsInQueue();
+ _scene->vm()->screen()->clearGraphicsInQueue();
- if (_rightClickDown) { // quits BlowUp Puzzle
+ if (_rightClickDown) { // quits BlowUp Puzzle
_rightClickDown = false;
- closeBlowUp();
- _scene->vm()->sound()->stopSound();
- _scene->enterScene();
- }
+ closeBlowUp();
+ _scene->vm()->sound()->stopSound();
+ _scene->enterScene();
+ }
- if (_leftClickDown) {
+ if (_leftClickDown) {
_leftClickDown = false;
- handleMouseDown();
- }
+ handleMouseDown();
+ }
- if (_leftClickUp) {
+ if (_leftClickUp) {
_leftClickUp = false;
- handleMouseUp();
- }
-
- updateCursorInPolyRegion();
-
- updateBlackJack();
- updateRedJack();
- updateYellowJack();
-
- updatePowerButton();
- updateRewindButton();
- updatePlayButton();
- updateStopButton();
-
- if(_buttonsState[kPower] == kON) {
- _scene->vm()->screen()->addGraphicToQueue(_scene->worldstats()->grResId[22], _tvScreenAnimIdx, 0, 37, 0, 0, 1);
- _scene->vm()->screen()->addGraphicToQueue(_scene->worldstats()->grResId[23], _tvScreenAnimIdx++, 238, 22, 0, 0, 1);
- _tvScreenAnimIdx %= 6;
- }
-
- if(_isAccomplished) {
- _scene->vm()->screen()->drawGraphicsInQueue();
-
- int barSize = 0;
- do {
- _scene->vm()->screen()->drawWideScreen(barSize);
- barSize += 4;
- } while(barSize < 84);
-
- // TODO: fade palette to grey
-
- _scene->vm()->video()->playVideo(2, kSubtitlesOn);
-
- _isAccomplished = false;
- _active = false;
- _scene->enterScene();
- } else {
- _scene->vm()->screen()->drawGraphicsInQueue();
- }
+ handleMouseUp();
+ }
+
+ updateCursorInPolyRegion();
+
+ updateBlackJack();
+ updateRedJack();
+ updateYellowJack();
+
+ updatePowerButton();
+ updateRewindButton();
+ updatePlayButton();
+ updateStopButton();
+
+ if (_buttonsState[kPower] == kON) {
+ _scene->vm()->screen()->addGraphicToQueue(_scene->worldstats()->grResId[22], _tvScreenAnimIdx, 0, 37, 0, 0, 1);
+ _scene->vm()->screen()->addGraphicToQueue(_scene->worldstats()->grResId[23], _tvScreenAnimIdx++, 238, 22, 0, 0, 1);
+ _tvScreenAnimIdx %= 6;
+ }
+
+ if (_isAccomplished) {
+ _scene->vm()->screen()->drawGraphicsInQueue();
+
+ int barSize = 0;
+ do {
+ _scene->vm()->screen()->drawWideScreen(barSize);
+ barSize += 4;
+ } while (barSize < 84);
+
+ // TODO: fade palette to grey
+
+ _scene->vm()->video()->playVideo(2, kSubtitlesOn);
+
+ _isAccomplished = false;
+ _active = false;
+ _scene->enterScene();
+ } else {
+ _scene->vm()->screen()->drawGraphicsInQueue();
+ }
}
GraphicQueueItem BlowUpPuzzleVCR::getGraphicJackItem(int resId) {
- GraphicQueueItem jackItemOnHand;
-
- int jackY = _cursor->y();
- if(_cursor->y() < 356) {
- jackY = 356;
- }
-
- jackItemOnHand.resId = _scene->worldstats()->grResId[resId];
- jackItemOnHand.frameIdx = 0;
- jackItemOnHand.x = _cursor->x() - 114;
- jackItemOnHand.y = jackY - 14;
- jackItemOnHand.priority = 1;
-
- return jackItemOnHand;
+ GraphicQueueItem jackItemOnHand;
+
+ int jackY = _cursor->y();
+ if (_cursor->y() < 356) {
+ jackY = 356;
+ }
+
+ jackItemOnHand.resId = _scene->worldstats()->grResId[resId];
+ jackItemOnHand.frameIdx = 0;
+ jackItemOnHand.x = _cursor->x() - 114;
+ jackItemOnHand.y = jackY - 14;
+ jackItemOnHand.priority = 1;
+
+ return jackItemOnHand;
}
GraphicQueueItem BlowUpPuzzleVCR::getGraphicShadowItem() {
- GraphicQueueItem shadowItem;
-
- int shadowY = (_cursor->y() - 356) / 4;
- if(_cursor->y() < 356) {
- shadowY = 0;
- }
- shadowItem.resId = _scene->worldstats()->grResId[30];
- shadowItem.frameIdx = 0;
- shadowItem.x = _cursor->x() - shadowY;
- shadowItem.y = 450;
- shadowItem.priority = 2;
-
- return shadowItem;
+ GraphicQueueItem shadowItem;
+
+ int shadowY = (_cursor->y() - 356) / 4;
+ if (_cursor->y() < 356) {
+ shadowY = 0;
+ }
+ shadowItem.resId = _scene->worldstats()->grResId[30];
+ shadowItem.frameIdx = 0;
+ shadowItem.x = _cursor->x() - shadowY;
+ shadowItem.y = 450;
+ shadowItem.priority = 2;
+
+ return shadowItem;
}
void BlowUpPuzzleVCR::updateJack(Jack jack, VCRDrawInfo onTable, VCRDrawInfo pluggedOnRed, VCRDrawInfo pluggedOnYellow, VCRDrawInfo pluggedOnBlack, int resIdOnHand) {
- GraphicQueueItem item;
-
- switch(_jacksState[jack]){
- case kOnTable:
- item.resId = _scene->worldstats()->grResId[onTable.resId];
- item.frameIdx = 0;
- item.x = onTable.x;
- item.y = onTable.y;
- item.priority = 3;
- break;
- case kPluggedOnRed:
- item.resId = _scene->worldstats()->grResId[pluggedOnRed.resId];
- item.frameIdx = 0;
- item.x = 329;
- item.y = 407;
- item.priority = 3;
- break;
- case kPluggedOnYellow:
- item.resId = _scene->worldstats()->grResId[pluggedOnYellow.resId];
- item.frameIdx = 0;
- item.x = 402;
- item.y = 413;
- item.priority = 3;
- break;
- case kPluggedOnBlack:
- item.resId = _scene->worldstats()->grResId[pluggedOnBlack.resId];
- item.frameIdx = 0;
- item.x = 477;
- item.y = 418;
- item.priority = 3;
- break;
- case kOnHand: {
- GraphicQueueItem jackItemOnHand = getGraphicJackItem(resIdOnHand);
- _scene->vm()->screen()->addGraphicToQueue(jackItemOnHand);
-
- item = getGraphicShadowItem();
- }
- break;
- default:
- item.resId = 0;
- break;
- }
-
- if(item.resId != 0)
- _scene->vm()->screen()->addGraphicToQueue(item);
+ GraphicQueueItem item;
+
+ switch (_jacksState[jack]) {
+ case kOnTable:
+ item.resId = _scene->worldstats()->grResId[onTable.resId];
+ item.frameIdx = 0;
+ item.x = onTable.x;
+ item.y = onTable.y;
+ item.priority = 3;
+ break;
+ case kPluggedOnRed:
+ item.resId = _scene->worldstats()->grResId[pluggedOnRed.resId];
+ item.frameIdx = 0;
+ item.x = 329;
+ item.y = 407;
+ item.priority = 3;
+ break;
+ case kPluggedOnYellow:
+ item.resId = _scene->worldstats()->grResId[pluggedOnYellow.resId];
+ item.frameIdx = 0;
+ item.x = 402;
+ item.y = 413;
+ item.priority = 3;
+ break;
+ case kPluggedOnBlack:
+ item.resId = _scene->worldstats()->grResId[pluggedOnBlack.resId];
+ item.frameIdx = 0;
+ item.x = 477;
+ item.y = 418;
+ item.priority = 3;
+ break;
+ case kOnHand: {
+ GraphicQueueItem jackItemOnHand = getGraphicJackItem(resIdOnHand);
+ _scene->vm()->screen()->addGraphicToQueue(jackItemOnHand);
+
+ item = getGraphicShadowItem();
+ }
+ break;
+ default:
+ item.resId = 0;
+ break;
+ }
+
+ if (item.resId != 0)
+ _scene->vm()->screen()->addGraphicToQueue(item);
}
void BlowUpPuzzleVCR::updateBlackJack() {
- VCRDrawInfo onTable;
- onTable.resId = 1;
- onTable.x = 0;
- onTable.y = 411;
+ VCRDrawInfo onTable;
+ onTable.resId = 1;
+ onTable.x = 0;
+ onTable.y = 411;
- VCRDrawInfo pluggedOnRed;
- pluggedOnRed.resId = 5;
+ VCRDrawInfo pluggedOnRed;
+ pluggedOnRed.resId = 5;
- VCRDrawInfo pluggedOnYellow;
- pluggedOnYellow.resId = 8;
+ VCRDrawInfo pluggedOnYellow;
+ pluggedOnYellow.resId = 8;
- VCRDrawInfo pluggedOnBlack;
- pluggedOnBlack.resId = 11;
+ VCRDrawInfo pluggedOnBlack;
+ pluggedOnBlack.resId = 11;
- updateJack(kBlack, onTable, pluggedOnRed, pluggedOnYellow, pluggedOnBlack, 27);
+ updateJack(kBlack, onTable, pluggedOnRed, pluggedOnYellow, pluggedOnBlack, 27);
}
void BlowUpPuzzleVCR::updateRedJack() {
- VCRDrawInfo onTable;
- onTable.resId = 2;
- onTable.x = 76;
- onTable.y = 428;
+ VCRDrawInfo onTable;
+ onTable.resId = 2;
+ onTable.x = 76;
+ onTable.y = 428;
- VCRDrawInfo pluggedOnRed;
- pluggedOnRed.resId = 4;
+ VCRDrawInfo pluggedOnRed;
+ pluggedOnRed.resId = 4;
- VCRDrawInfo pluggedOnYellow;
- pluggedOnYellow.resId = 7;
+ VCRDrawInfo pluggedOnYellow;
+ pluggedOnYellow.resId = 7;
- VCRDrawInfo pluggedOnBlack;
- pluggedOnBlack.resId = 10;
+ VCRDrawInfo pluggedOnBlack;
+ pluggedOnBlack.resId = 10;
- updateJack(kRed, onTable, pluggedOnRed, pluggedOnYellow, pluggedOnBlack, 25);
+ updateJack(kRed, onTable, pluggedOnRed, pluggedOnYellow, pluggedOnBlack, 25);
}
void BlowUpPuzzleVCR::updateYellowJack() {
- VCRDrawInfo onTable;
- onTable.resId = 3;
- onTable.x = 187;
- onTable.y = 439;
+ VCRDrawInfo onTable;
+ onTable.resId = 3;
+ onTable.x = 187;
+ onTable.y = 439;
- VCRDrawInfo pluggedOnRed;
- pluggedOnRed.resId = 6;
+ VCRDrawInfo pluggedOnRed;
+ pluggedOnRed.resId = 6;
- VCRDrawInfo pluggedOnYellow;
- pluggedOnYellow.resId = 9;
+ VCRDrawInfo pluggedOnYellow;
+ pluggedOnYellow.resId = 9;
- VCRDrawInfo pluggedOnBlack;
- pluggedOnBlack.resId = 12;
+ VCRDrawInfo pluggedOnBlack;
+ pluggedOnBlack.resId = 12;
- updateJack(kYellow, onTable, pluggedOnRed, pluggedOnYellow, pluggedOnBlack, 26);
+ updateJack(kYellow, onTable, pluggedOnRed, pluggedOnYellow, pluggedOnBlack, 26);
}
// common function to set and unset the jack on holes for each type of jack
int BlowUpPuzzleVCR::setJackOnHole(int jackType, JackState plugged) {
- if(!_holesState[plugged-1]) {
- if(_jacksState[jackType-1] == kOnHand) {
- _jacksState[jackType-1] = plugged;
- _holesState[plugged-1] = jackType; // set jack on red
- playSound(_scene->worldstats()->grResId[44]);
- }
- } else if(jackType == 0) {
- jackType = _holesState[plugged-1];
- _jacksState[jackType-1] = kOnHand;
- _holesState[plugged-1] = 0;
- playSound(_scene->worldstats()->grResId[43]);
- return 0;
- }
- return 1;
+ if (!_holesState[plugged-1]) {
+ if (_jacksState[jackType-1] == kOnHand) {
+ _jacksState[jackType-1] = plugged;
+ _holesState[plugged-1] = jackType; // set jack on red
+ playSound(_scene->worldstats()->grResId[44]);
+ }
+ } else if (jackType == 0) {
+ jackType = _holesState[plugged-1];
+ _jacksState[jackType-1] = kOnHand;
+ _holesState[plugged-1] = 0;
+ playSound(_scene->worldstats()->grResId[43]);
+ return 0;
+ }
+ return 1;
}
void BlowUpPuzzleVCR::updateButton(Button button, VCRDrawInfo btON, VCRDrawInfo btDown) {
- GraphicQueueItem item;
-
- switch(_buttonsState[button]){
- case kON:
- item.resId = _scene->worldstats()->grResId[btON.resId];
- item.frameIdx = 0;
- item.x = btON.x;
- item.y = btON.y;
- item.priority = 3;
- break;
- case kDownON:
- case kDownOFF:
- item.resId = _scene->worldstats()->grResId[btDown.resId];
- item.frameIdx = 0;
- item.x = btDown.x;
- item.y = btDown.y;
- item.priority = 3;
- break;
- default:
- item.resId = 0;
- break;
- }
-
- if(item.resId != 0)
- _scene->vm()->screen()->addGraphicToQueue(item);
+ GraphicQueueItem item;
+
+ switch (_buttonsState[button]) {
+ case kON:
+ item.resId = _scene->worldstats()->grResId[btON.resId];
+ item.frameIdx = 0;
+ item.x = btON.x;
+ item.y = btON.y;
+ item.priority = 3;
+ break;
+ case kDownON:
+ case kDownOFF:
+ item.resId = _scene->worldstats()->grResId[btDown.resId];
+ item.frameIdx = 0;
+ item.x = btDown.x;
+ item.y = btDown.y;
+ item.priority = 3;
+ break;
+ default:
+ item.resId = 0;
+ break;
+ }
+
+ if (item.resId != 0)
+ _scene->vm()->screen()->addGraphicToQueue(item);
}
void BlowUpPuzzleVCR::updatePowerButton() {
- VCRDrawInfo btON;
- btON.resId = 17;
- btON.x = 512;
- btON.y = 347;
+ VCRDrawInfo btON;
+ btON.resId = 17;
+ btON.x = 512;
+ btON.y = 347;
- VCRDrawInfo btDown;
- btDown.resId = 21;
- btDown.x = 506;
- btDown.y = 343;
+ VCRDrawInfo btDown;
+ btDown.resId = 21;
+ btDown.x = 506;
+ btDown.y = 343;
- updateButton(kPower, btON, btDown);
+ updateButton(kPower, btON, btDown);
}
void BlowUpPuzzleVCR::updateRewindButton() {
- VCRDrawInfo btON;
- btON.resId = 14;
- btON.x = 248;
- btON.y = 347;
+ VCRDrawInfo btON;
+ btON.resId = 14;
+ btON.x = 248;
+ btON.y = 347;
- VCRDrawInfo btDown;
- btDown.resId = 18;
- btDown.x = 245;
- btDown.y = 344;
+ VCRDrawInfo btDown;
+ btDown.resId = 18;
+ btDown.x = 245;
+ btDown.y = 344;
- updateButton(kRewind, btON, btDown);
+ updateButton(kRewind, btON, btDown);
}
void BlowUpPuzzleVCR::updatePlayButton() {
- VCRDrawInfo btON;
- btON.resId = 16;
- btON.x = 401;
- btON.y = 359;
+ VCRDrawInfo btON;
+ btON.resId = 16;
+ btON.x = 401;
+ btON.y = 359;
- VCRDrawInfo btDown;
- btDown.resId = 20;
- btDown.x = 391;
- btDown.y = 355;
+ VCRDrawInfo btDown;
+ btDown.resId = 20;
+ btDown.x = 391;
+ btDown.y = 355;
- updateButton(kPlay, btON, btDown);
+ updateButton(kPlay, btON, btDown);
}
void BlowUpPuzzleVCR::updateStopButton() {
- VCRDrawInfo btON;
- btON.resId = 15;
- btON.x = 330;
- btON.y = 354;
+ VCRDrawInfo btON;
+ btON.resId = 15;
+ btON.x = 330;
+ btON.y = 354;
- VCRDrawInfo btDown;
- btDown.resId = 19;
- btDown.x = 326;
- btDown.y = 350;
+ VCRDrawInfo btDown;
+ btDown.resId = 19;
+ btDown.x = 326;
+ btDown.y = 350;
- updateButton(kStop, btON, btDown);
+ updateButton(kStop, btON, btDown);
}
void BlowUpPuzzleVCR::updateCursorInPolyRegion() {
- int showCursor = 0;
-
- if ( _jacksState[kBlack] == kOnHand ) {
- showCursor = kBlack+1;
- } else if ( _jacksState[kRed] == kOnHand ) {
- showCursor = kRed+1;
- } else {
- showCursor = ((_jacksState[kYellow] != kOnHand) - 1) & 3;
- }
-
- if(!showCursor) {
- if(inPolyRegion(_cursor->x(), _cursor->y(), kRewindButton)
- || inPolyRegion(_cursor->x(), _cursor->y(), kStopButton)
- || inPolyRegion(_cursor->x(), _cursor->y(), kPlayButton)
- || inPolyRegion(_cursor->x(), _cursor->y(), kPowerButton)
- || inPolyRegion(_cursor->x(), _cursor->y(), kBlackJack)
- || inPolyRegion(_cursor->x(), _cursor->y(), kRedJack)
- || inPolyRegion(_cursor->x(), _cursor->y(), kYellowJack)) {
- _cursor->animate();
- } else {
- if(inPolyRegion(_cursor->x(), _cursor->y(), kRedHole) && _holesState[kPluggedOnRed-1]
- || inPolyRegion(_cursor->x(), _cursor->y(), kYellowHole) && _holesState[kPluggedOnYellow-1]
- || inPolyRegion(_cursor->x(), _cursor->y(), kBlackHole) && _holesState[kPluggedOnBlack-1]) {
- if(_cursor->currentFrame() != 2) { // reset cursor
- _cursor->show();
- _cursor->set(2);
- _cursor->animate();
- }
- } else {
- if(_cursor->currentFrame() != 0) { // reset cursor
- _cursor->show();
- _cursor->set(0);
- _cursor->animate();
- }
- }
- }
- } else {
- _cursor->hide();
- }
+ int showCursor = 0;
+
+ if (_jacksState[kBlack] == kOnHand) {
+ showCursor = kBlack + 1;
+ } else if (_jacksState[kRed] == kOnHand) {
+ showCursor = kRed + 1;
+ } else {
+ showCursor = ((_jacksState[kYellow] != kOnHand) - 1) & 3;
+ }
+
+ if (!showCursor) {
+ if (inPolyRegion(_cursor->x(), _cursor->y(), kRewindButton)
+ || inPolyRegion(_cursor->x(), _cursor->y(), kStopButton)
+ || inPolyRegion(_cursor->x(), _cursor->y(), kPlayButton)
+ || inPolyRegion(_cursor->x(), _cursor->y(), kPowerButton)
+ || inPolyRegion(_cursor->x(), _cursor->y(), kBlackJack)
+ || inPolyRegion(_cursor->x(), _cursor->y(), kRedJack)
+ || inPolyRegion(_cursor->x(), _cursor->y(), kYellowJack)) {
+ _cursor->animate();
+ } else {
+ if (inPolyRegion(_cursor->x(), _cursor->y(), kRedHole) && _holesState[kPluggedOnRed-1]
+ || inPolyRegion(_cursor->x(), _cursor->y(), kYellowHole) && _holesState[kPluggedOnYellow-1]
+ || inPolyRegion(_cursor->x(), _cursor->y(), kBlackHole) && _holesState[kPluggedOnBlack-1]) {
+ if (_cursor->currentFrame() != 2) { // reset cursor
+ _cursor->show();
+ _cursor->set(2);
+ _cursor->animate();
+ }
+ } else {
+ if (_cursor->currentFrame() != 0) { // reset cursor
+ _cursor->show();
+ _cursor->set(0);
+ _cursor->animate();
+ }
+ }
+ }
+ } else {
+ _cursor->hide();
+ }
}
void BlowUpPuzzleVCR::handleMouseDown() {
- if(_isAccomplished)
- return;
-
- int jackType = 0;
- if(_jacksState[kBlack] == kOnHand) {
- jackType = kBlack+1;
- } else if(_jacksState[kRed] == kOnHand) {
- jackType = kRed+1;
- } else {
- jackType = ((_jacksState[kYellow] != kOnHand) - 1) & 3;
- }
-
- // Plug-in jacks
- if(inPolyRegion(_cursor->x(), _cursor->y(), kRedHole)) {
- if(!setJackOnHole(jackType, kPluggedOnRed)) {
- return;
- }
- }
- if(inPolyRegion(_cursor->x(), _cursor->y(), kYellowHole)) {
- if(!setJackOnHole(jackType, kPluggedOnYellow)) {
- return;
- }
- }
- if(inPolyRegion(_cursor->x(), _cursor->y(), kBlackHole)) {
- if(!setJackOnHole(jackType, kPluggedOnBlack)) {
- if(_holesState[kBlackHole] != kPluggedOnYellow && _buttonsState[kPower] == 1) {
- _buttonsState[kPower] = kOFF;
- _buttonsState[kStop] = kOFF;
- _buttonsState[kPlay] = kOFF;
- _buttonsState[kRewind] = kOFF;
- }
- return;
- }
- }
-
- // Put jacks on table --
- if(jackType) {
- if (_cursor->x() >= (uint32)BlowUpPuzzleVCRPolies[kBlackJack].left && _cursor->x() <= (uint32)BlowUpPuzzleVCRPolies[kYellowJack].right &&
- _cursor->y() >= (uint32)BlowUpPuzzleVCRPolies[kBlackJack].top && _cursor->y() <= (uint32)BlowUpPuzzleVCRPolies[kYellowJack].bottom) {
- _jacksState[jackType-1] = kOnTable;
- playSound(_scene->worldstats()->grResId[50]);
- _cursor->show();
- }
- return;
- }
-
- // Get Jacks from Table
- if (inPolyRegion(_cursor->x(), _cursor->y(), kBlackJack)) {
- _jacksState[kBlack] = kOnHand;
- } else if (inPolyRegion(_cursor->x(), _cursor->y(), kRedJack)) {
- _jacksState[kRed] = kOnHand;
- } else if (inPolyRegion(_cursor->x(), _cursor->y(), kYellowJack)) {
- _jacksState[kYellow] = kOnHand;
- }
-
- // VCR button regions
- if (inPolyRegion(_cursor->x(), _cursor->y(), kRewindButton)) {
- playSound(_scene->worldstats()->grResId[39]);
- if(!_buttonsState[kRewind]) {
- _buttonsState[kRewind] = kDownON;
- return;
- }
- if(_buttonsState[kRewind] == kON) {
- _buttonsState[kRewind] = kDownOFF;
- return;
- }
- } else if (inPolyRegion(_cursor->x(), _cursor->y(), kPlayButton)) {
- playSound(_scene->worldstats()->grResId[39]);
- if(!_buttonsState[kPlay]) {
- _buttonsState[kPlay] = kDownON;
- return;
- }
- if(_buttonsState[kPlay] == kON) {
- _buttonsState[kPlay] = kDownOFF;
- return;
- }
- } else if (inPolyRegion(_cursor->x(), _cursor->y(), kStopButton)) {
- playSound(_scene->worldstats()->grResId[39]);
- if(_buttonsState[kStop]) {
- if(_buttonsState[kStop] == kON) {
- _buttonsState[kStop] = kDownOFF;
- return;
- }
- } else {
- _buttonsState[kStop] = kDownON;
- return;
- }
- } else if (inPolyRegion(_cursor->x(), _cursor->y(), kPowerButton)) {
- playSound(_scene->worldstats()->grResId[39]);
-
- if(!_buttonsState[kPower] && _holesState[kPluggedOnBlack-1] == kBlack+1 && _holesState[kPluggedOnRed-1] && _holesState[kPluggedOnYellow-1]) {
- _buttonsState[kPower] = kDownON;
- } else {
- _buttonsState[kPower] = kDownOFF;
- }
- }
+ if (_isAccomplished)
+ return;
+
+ int jackType = 0;
+ if (_jacksState[kBlack] == kOnHand) {
+ jackType = kBlack + 1;
+ } else if (_jacksState[kRed] == kOnHand) {
+ jackType = kRed + 1;
+ } else {
+ jackType = ((_jacksState[kYellow] != kOnHand) - 1) & 3;
+ }
+
+ // Plug-in jacks
+ if (inPolyRegion(_cursor->x(), _cursor->y(), kRedHole)) {
+ if (!setJackOnHole(jackType, kPluggedOnRed)) {
+ return;
+ }
+ }
+ if (inPolyRegion(_cursor->x(), _cursor->y(), kYellowHole)) {
+ if (!setJackOnHole(jackType, kPluggedOnYellow)) {
+ return;
+ }
+ }
+ if (inPolyRegion(_cursor->x(), _cursor->y(), kBlackHole)) {
+ if (!setJackOnHole(jackType, kPluggedOnBlack)) {
+ if (_holesState[kBlackHole] != kPluggedOnYellow && _buttonsState[kPower] == 1) {
+ _buttonsState[kPower] = kOFF;
+ _buttonsState[kStop] = kOFF;
+ _buttonsState[kPlay] = kOFF;
+ _buttonsState[kRewind] = kOFF;
+ }
+ return;
+ }
+ }
+
+ // Put jacks on table --
+ if (jackType) {
+ if (_cursor->x() >= (uint32)BlowUpPuzzleVCRPolies[kBlackJack].left && _cursor->x() <= (uint32)BlowUpPuzzleVCRPolies[kYellowJack].right &&
+ _cursor->y() >= (uint32)BlowUpPuzzleVCRPolies[kBlackJack].top && _cursor->y() <= (uint32)BlowUpPuzzleVCRPolies[kYellowJack].bottom) {
+ _jacksState[jackType-1] = kOnTable;
+ playSound(_scene->worldstats()->grResId[50]);
+ _cursor->show();
+ }
+ return;
+ }
+
+ // Get Jacks from Table
+ if (inPolyRegion(_cursor->x(), _cursor->y(), kBlackJack)) {
+ _jacksState[kBlack] = kOnHand;
+ } else if (inPolyRegion(_cursor->x(), _cursor->y(), kRedJack)) {
+ _jacksState[kRed] = kOnHand;
+ } else if (inPolyRegion(_cursor->x(), _cursor->y(), kYellowJack)) {
+ _jacksState[kYellow] = kOnHand;
+ }
+
+ // VCR button regions
+ if (inPolyRegion(_cursor->x(), _cursor->y(), kRewindButton)) {
+ playSound(_scene->worldstats()->grResId[39]);
+ if (!_buttonsState[kRewind]) {
+ _buttonsState[kRewind] = kDownON;
+ return;
+ }
+ if (_buttonsState[kRewind] == kON) {
+ _buttonsState[kRewind] = kDownOFF;
+ return;
+ }
+ } else if (inPolyRegion(_cursor->x(), _cursor->y(), kPlayButton)) {
+ playSound(_scene->worldstats()->grResId[39]);
+ if (!_buttonsState[kPlay]) {
+ _buttonsState[kPlay] = kDownON;
+ return;
+ }
+ if (_buttonsState[kPlay] == kON) {
+ _buttonsState[kPlay] = kDownOFF;
+ return;
+ }
+ } else if (inPolyRegion(_cursor->x(), _cursor->y(), kStopButton)) {
+ playSound(_scene->worldstats()->grResId[39]);
+ if (_buttonsState[kStop]) {
+ if (_buttonsState[kStop] == kON) {
+ _buttonsState[kStop] = kDownOFF;
+ return;
+ }
+ } else {
+ _buttonsState[kStop] = kDownON;
+ return;
+ }
+ } else if (inPolyRegion(_cursor->x(), _cursor->y(), kPowerButton)) {
+ playSound(_scene->worldstats()->grResId[39]);
+
+ if (!_buttonsState[kPower] && _holesState[kPluggedOnBlack-1] == kBlack + 1 && _holesState[kPluggedOnRed-1] && _holesState[kPluggedOnYellow-1]) {
+ _buttonsState[kPower] = kDownON;
+ } else {
+ _buttonsState[kPower] = kDownOFF;
+ }
+ }
}
void BlowUpPuzzleVCR::handleMouseUp() {
- if(_isAccomplished)
- return;
-
- if(_buttonsState[kPower] == kDownON) {
- playSound(_scene->worldstats()->grResId[47], true);
- _buttonsState[kPower] = kON;
- _buttonsState[kStop] = kON;
- _buttonsState[kPlay] = kON;
- _buttonsState[kRewind] = kON;
- } else if(_buttonsState[kPower] == kDownOFF) {
- _buttonsState[kPower] = kOFF;
- _buttonsState[kStop] = kOFF;
- _buttonsState[kPlay] = kOFF;
- _buttonsState[kRewind] = kOFF;
- _scene->vm()->sound()->stopSound();
- }
-
- if(_buttonsState[kRewind] == kDownOFF) {
- _buttonsState[kRewind] = kON;
- playSound(_scene->worldstats()->grResId[46]);
- } else if(_buttonsState[kRewind] == kDownON) {
- _buttonsState[kRewind] = kOFF;
- }
-
- if(_buttonsState[kPlay] == kDownOFF) {
- _buttonsState[kPlay] = kON;
- if(_holesState[kPluggedOnRed-1] == kRed+1 && _holesState[kPluggedOnYellow-1] == kYellow+1 && _holesState[kPluggedOnBlack-1] == kBlack+1) {
- _scene->vm()->setGameFlag(220);
- _isAccomplished = true;
- }
- } else if(_buttonsState[kPlay] == kDownON) {
- _buttonsState[kPlay] = kOFF;
- }
-
- if(_buttonsState[kStop] == kDownOFF) {
- _buttonsState[kStop] = kON;
- return;
- }
- if(_buttonsState[kStop] == kDownON) {
- _buttonsState[kStop] = kOFF;
- }
+ if (_isAccomplished)
+ return;
+
+ if (_buttonsState[kPower] == kDownON) {
+ playSound(_scene->worldstats()->grResId[47], true);
+ _buttonsState[kPower] = kON;
+ _buttonsState[kStop] = kON;
+ _buttonsState[kPlay] = kON;
+ _buttonsState[kRewind] = kON;
+ } else if (_buttonsState[kPower] == kDownOFF) {
+ _buttonsState[kPower] = kOFF;
+ _buttonsState[kStop] = kOFF;
+ _buttonsState[kPlay] = kOFF;
+ _buttonsState[kRewind] = kOFF;
+ _scene->vm()->sound()->stopSound();
+ }
+
+ if (_buttonsState[kRewind] == kDownOFF) {
+ _buttonsState[kRewind] = kON;
+ playSound(_scene->worldstats()->grResId[46]);
+ } else if (_buttonsState[kRewind] == kDownON) {
+ _buttonsState[kRewind] = kOFF;
+ }
+
+ if (_buttonsState[kPlay] == kDownOFF) {
+ _buttonsState[kPlay] = kON;
+ if (_holesState[kPluggedOnRed-1] == kRed + 1 && _holesState[kPluggedOnYellow-1] == kYellow + 1 && _holesState[kPluggedOnBlack-1] == kBlack + 1) {
+ _scene->vm()->setGameFlag(220);
+ _isAccomplished = true;
+ }
+ } else if (_buttonsState[kPlay] == kDownON) {
+ _buttonsState[kPlay] = kOFF;
+ }
+
+ if (_buttonsState[kStop] == kDownOFF) {
+ _buttonsState[kStop] = kON;
+ return;
+ }
+ if (_buttonsState[kStop] == kDownON) {
+ _buttonsState[kStop] = kOFF;
+ }
}
} // end of namespace Asylum
diff --git a/engines/asylum/blowuppuzzle.h b/engines/asylum/blowuppuzzle.h
index fd61ad5e09..36eaf524c0 100644
--- a/engines/asylum/blowuppuzzle.h
+++ b/engines/asylum/blowuppuzzle.h
@@ -48,25 +48,27 @@ public:
BlowUpPuzzle(Scene *scene);
virtual ~BlowUpPuzzle();
- virtual void handleEvent(Common::Event *event, bool doUpdate){};
- virtual void openBlowUp(){};
- virtual void closeBlowUp(){};
+ virtual void handleEvent(Common::Event *event, bool doUpdate) {};
+ virtual void openBlowUp() {};
+ virtual void closeBlowUp() {};
- bool isActive() { return _active; }
+ bool isActive() {
+ return _active;
+ }
protected:
Common::Event *_ev;
Scene *_scene;
Cursor *_cursor;
bool _leftClickUp;
- bool _leftClickDown;
- bool _rightClickDown;
+ bool _leftClickDown;
+ bool _rightClickDown;
bool _active;
- GraphicResource *_bgResource;
+ GraphicResource *_bgResource;
- virtual void update() {};
- void playSound(uint resourceId, bool loop = false);
+ virtual void update() {};
+ void playSound(uint resourceId, bool loop = false);
}; // end of class BlowUpPuzzle
@@ -76,102 +78,102 @@ protected:
typedef struct VCRDrawInfo {
uint32 resId;
uint32 x;
- uint32 y;
+ uint32 y;
} VCRDrawInfo;
const Common::Rect BlowUpPuzzleVCRPolies[10] = {
- Common::Rect(0x0F7, 0x157, 0x13A, 0x183), // rewind button region
- Common::Rect(0x14B, 0x15C, 0x17B, 0x18B), // stop button region
- Common::Rect(0x18C, 0x161, 0x1D2, 0x18F), // play button region
- Common::Rect(0x1FB, 0x156, 0x233, 0x185), // rec button region
- Common::Rect(0x154, 0x196, 0x173, 0x1AF), // red jack hole region
- Common::Rect(0x19A, 0x19B, 0x1B9, 0x1B3), // yellow jack hole region
- Common::Rect(0x1E3, 0x1A0, 0x202, 0x1BC), // black jack hole region
- Common::Rect(0x0, 0x19B, 0x3C, 0x1E0), // black jack on table region
- Common::Rect(0x4C, 0x1AC, 0x0A0, 0x1E0), // red jack on table region
- Common::Rect(0x0BB, 0x1B7, 0x0F0, 0x1E0) // yellow jack on table region
+ Common::Rect(0x0F7, 0x157, 0x13A, 0x183), // rewind button region
+ Common::Rect(0x14B, 0x15C, 0x17B, 0x18B), // stop button region
+ Common::Rect(0x18C, 0x161, 0x1D2, 0x18F), // play button region
+ Common::Rect(0x1FB, 0x156, 0x233, 0x185), // rec button region
+ Common::Rect(0x154, 0x196, 0x173, 0x1AF), // red jack hole region
+ Common::Rect(0x19A, 0x19B, 0x1B9, 0x1B3), // yellow jack hole region
+ Common::Rect(0x1E3, 0x1A0, 0x202, 0x1BC), // black jack hole region
+ Common::Rect(0x0, 0x19B, 0x3C, 0x1E0), // black jack on table region
+ Common::Rect(0x4C, 0x1AC, 0x0A0, 0x1E0), // red jack on table region
+ Common::Rect(0x0BB, 0x1B7, 0x0F0, 0x1E0) // yellow jack on table region
};
class BlowUpPuzzleVCR : public BlowUpPuzzle {
public:
- BlowUpPuzzleVCR(Scene *scene);
+ BlowUpPuzzleVCR(Scene *scene);
~BlowUpPuzzleVCR();
void handleEvent(Common::Event *event, bool doUpdate);
void openBlowUp();
void closeBlowUp();
private:
- enum Jack {
+ enum Jack {
kBlack = 0,
kRed = 1,
kYellow = 2
};
- enum JackState {
+ enum JackState {
kOnTable = 0,
kPluggedOnRed = 1,
kPluggedOnYellow = 2,
kPluggedOnBlack = 3,
- kOnHand = 4
+ kOnHand = 4
};
- enum VCRRegions {
+ enum VCRRegions {
kRewindButton = 0,
kStopButton = 1,
kPlayButton = 2,
kPowerButton = 3,
- kRedHole = 4,
- kYellowHole = 5,
- kBlackHole = 6,
- kBlackJack = 7,
- kRedJack = 8,
- kYellowJack = 9
+ kRedHole = 4,
+ kYellowHole = 5,
+ kBlackHole = 6,
+ kBlackJack = 7,
+ kRedJack = 8,
+ kYellowJack = 9
};
- enum Button {
+ enum Button {
kRewind = 0,
kStop = 1,
kPlay = 2,
- kPower = 3
+ kPower = 3
};
- enum ButtonState {
+ enum ButtonState {
kOFF = 0,
kON = 1,
kDownON = 2,
- kDownOFF = 3
+ kDownOFF = 3
};
- int _jacksState[3];
- int _holesState[3];
- int _buttonsState[4];
- int _tvScreenAnimIdx;
- bool _isAccomplished;
+ int _jacksState[3];
+ int _holesState[3];
+ int _buttonsState[4];
+ int _tvScreenAnimIdx;
+ bool _isAccomplished;
- int inPolyRegion(int x, int y, int polyIdx);
+ int inPolyRegion(int x, int y, int polyIdx);
- void update();
+ void update();
- void updateCursorInPolyRegion();
+ void updateCursorInPolyRegion();
- GraphicQueueItem getGraphicJackItem(int resId);
- GraphicQueueItem getGraphicShadowItem();
- void updateJack(Jack jack, VCRDrawInfo onTable, VCRDrawInfo pluggedOnRed, VCRDrawInfo pluggedOnYellow, VCRDrawInfo pluggedOnBlack, int resIdOnHand);
- void updateBlackJack();
- void updateRedJack();
- void updateYellowJack();
- int setJackOnHole(int jackType, JackState plugged);
+ GraphicQueueItem getGraphicJackItem(int resId);
+ GraphicQueueItem getGraphicShadowItem();
+ void updateJack(Jack jack, VCRDrawInfo onTable, VCRDrawInfo pluggedOnRed, VCRDrawInfo pluggedOnYellow, VCRDrawInfo pluggedOnBlack, int resIdOnHand);
+ void updateBlackJack();
+ void updateRedJack();
+ void updateYellowJack();
+ int setJackOnHole(int jackType, JackState plugged);
- void updateButton(Button button, VCRDrawInfo btON, VCRDrawInfo btDown);
- void updatePowerButton();
- void updateRewindButton();
- void updatePlayButton();
- void updateStopButton();
+ void updateButton(Button button, VCRDrawInfo btON, VCRDrawInfo btDown);
+ void updatePowerButton();
+ void updateRewindButton();
+ void updatePlayButton();
+ void updateStopButton();
- void updateTVSync();
-
- void handleMouseDown();
- void handleMouseUp();
+ void updateTVSync();
+
+ void handleMouseDown();
+ void handleMouseUp();
}; // end of class BlowUpPuzzleVCR
} // end of namespace Asylum
diff --git a/engines/asylum/console.cpp b/engines/asylum/console.cpp
index 562e95b17f..f3da3f876b 100644
--- a/engines/asylum/console.cpp
+++ b/engines/asylum/console.cpp
@@ -66,28 +66,28 @@ bool Console::cmdDumpActionArea(int argc, const char **argv) {
void Console::printActionAreaStats(ActionArea *a) {
DebugPrintf("id[%d] name[%s] field01[%d] field02[%d] field40[%d] field44[%d] flags[%d] \n"
- "actionListIdx1[%d] actionListIdx2[%d] actionType[%d] field_7C[%d] polyIdx[%d]\n"
- "field_84[%d] field_88[%d] soundResId[%d] field_90[%d] palette[%d] volume[%d]\n\n",
- a->id,
- a->name,
- a->field01,
- a->field02,
- a->field_40,
- a->field_44,
- a->flags,
- a->actionListIdx1,
- a->actionListIdx2,
- a->actionType,
- //a->flagNums[10],
- a->field_7C,
- a->polyIdx,
- a->field_84,
- a->field_88,
- a->soundResId,
- a->field_90,
- a->paletteValue,
- //a->array[5],
- a->volume);
+ "actionListIdx1[%d] actionListIdx2[%d] actionType[%d] field_7C[%d] polyIdx[%d]\n"
+ "field_84[%d] field_88[%d] soundResId[%d] field_90[%d] palette[%d] volume[%d]\n\n",
+ a->id,
+ a->name,
+ a->field01,
+ a->field02,
+ a->field_40,
+ a->field_44,
+ a->flags,
+ a->actionListIdx1,
+ a->actionListIdx2,
+ a->actionType,
+ //a->flagNums[10],
+ a->field_7C,
+ a->polyIdx,
+ a->field_84,
+ a->field_88,
+ a->soundResId,
+ a->field_90,
+ a->paletteValue,
+ //a->array[5],
+ a->volume);
}
bool Console::cmdShowFlags(int argc, const char **argv) {
@@ -116,7 +116,7 @@ bool Console::cmdPlayVideo(int argc, const char **argv) {
DebugPrintf("Usage %s <video number>\n", argv[0]);
return true;
}
-
+
_vm->scene()->actions()->delayedVideoIndex = atoi(argv[1]);
return false;
@@ -138,7 +138,7 @@ bool Console::cmdChangeScene(int argc, const char **argv) {
DebugPrintf("Usage %s <scene number>\n", argv[0]);
return true;
}
-
+
if (atoi(argv[1]) - 4 < 1 || atoi(argv[1]) - 4 >= 15) {
DebugPrintf("Attempt to SetupStartingInfo(%d); Invalid world\n", atoi(argv[1]));
return true;
@@ -146,7 +146,7 @@ bool Console::cmdChangeScene(int argc, const char **argv) {
_vm->scene()->actions()->delayedSceneIndex = atoi(argv[1]);
_vm->scene()->actions()->setScriptByIndex(0); // XXX is this right or should it be
- // ws->actionListIdx???
+ // ws->actionListIdx???
return false;
}
diff --git a/engines/asylum/console.h b/engines/asylum/console.h
index 29d97e5c6a..4bcc95e135 100644
--- a/engines/asylum/console.h
+++ b/engines/asylum/console.h
@@ -23,7 +23,7 @@
*
*/
- // Console module header file
+// Console module header file
#ifndef ASYLUM_CONSOLE_H
#define ASYLUM_CONSOLE_H
diff --git a/engines/asylum/cursor.h b/engines/asylum/cursor.h
index abb867b72f..418a5e044e 100644
--- a/engines/asylum/cursor.h
+++ b/engines/asylum/cursor.h
@@ -81,16 +81,22 @@ public:
/**
* Get the X position of the cursor
*/
- uint32 x() { return _mouseX; }
+ uint32 x() {
+ return _mouseX;
+ }
/**
* get the Y position of the cursor
*/
- uint32 y() { return _mouseY; }
+ uint32 y() {
+ return _mouseY;
+ }
/**
* Get the current frame number of the
* loaded cursorResource
*/
- uint32 currentFrame() { return _curFrame; }
+ uint32 currentFrame() {
+ return _curFrame;
+ }
private:
void set(byte *data, byte width, byte height);
diff --git a/engines/asylum/detection.cpp b/engines/asylum/detection.cpp
index 10ad2a591c..b90af01455 100644
--- a/engines/asylum/detection.cpp
+++ b/engines/asylum/detection.cpp
@@ -92,17 +92,17 @@ public:
bool AsylumMetaEngine::hasFeature(MetaEngineFeature f) const {
return
- (f == kSupportsListSaves) ||
- (f == kSupportsLoadingDuringStartup) ||
- (f == kSupportsDeleteSave);
+ (f == kSupportsListSaves) ||
+ (f == kSupportsLoadingDuringStartup) ||
+ (f == kSupportsDeleteSave);
}
bool Asylum::AsylumEngine::hasFeature(EngineFeature f) const {
return
- (f == kSupportsRTL) ||
- (f == kSupportsLoadingDuringRuntime) ||
- (f == kSupportsSavingDuringRuntime) ||
- (f == kSupportsSubtitleOptions);
+ (f == kSupportsRTL) ||
+ (f == kSupportsLoadingDuringRuntime) ||
+ (f == kSupportsSavingDuringRuntime) ||
+ (f == kSupportsSubtitleOptions);
}
bool AsylumMetaEngine::createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const {
@@ -127,7 +127,7 @@ void AsylumMetaEngine::removeSaveState(const char *target, int slot) const {
}
#if PLUGIN_ENABLED_DYNAMIC(ASYLUM)
- REGISTER_PLUGIN_DYNAMIC(ASYLUM, PLUGIN_TYPE_ENGINE, AsylumMetaEngine);
+REGISTER_PLUGIN_DYNAMIC(ASYLUM, PLUGIN_TYPE_ENGINE, AsylumMetaEngine);
#else
- REGISTER_PLUGIN_STATIC(ASYLUM, PLUGIN_TYPE_ENGINE, AsylumMetaEngine);
+REGISTER_PLUGIN_STATIC(ASYLUM, PLUGIN_TYPE_ENGINE, AsylumMetaEngine);
#endif
diff --git a/engines/asylum/encounters.cpp b/engines/asylum/encounters.cpp
index 4656104888..b6d68c3883 100644
--- a/engines/asylum/encounters.cpp
+++ b/engines/asylum/encounters.cpp
@@ -77,53 +77,53 @@ void Encounter::run(int encounterIdx, int barrierId1, int barrierId2, int charac
setVariable(2, _currentEncounter->value);
Barrier *b1 = _scene->worldstats()->getBarrierById(barrierId1);
-/*
- int __cdecl runEncounter(int newMessageHandler, int encounterIndex, int objectId1, int objectId2, int characterIndex)
-{
- int result; // eax at 7
- EncounterItem *v6; // eax at 2
- int v7; // ST04_4 at 4
- int v8; // eax at 4
-
- if ( !encounterKeywordIndex )
- {
- v6 = getEncounterItem(0);
- encounterItem = v6;
- encounterKeywordIndex = *(_DWORD *)&v6->keywordIndex;
- }
- if ( encounterIndex < 0 )
- {
- result = 0;
- }
- else
- {
- encounter_newMessageHandler = newMessageHandler;
- encounterIndex = encounterIndex;
- encounterItem = getEncounterItem(encounterIndex);
- encounter_objectId01 = objectId1;
- v7 = characterIndex;
- encounter_objectId02 = objectId2;
- characterIndex2 = characterIndex;
- v8 = getObjectIndexById(objectId2);
- object_sound_sub_414C30(v8, v7);
- setEncounterVariable(1, 0);
- setEncounterVariable(2, encounterItem->value);
- if ( scene.characters[playerCharacterIndex].field_40 == 5 )
- {
- encounter_flag02 = 1;
- }
- else
- {
- encounter_flag02 = 0;
- character_sub_4072A0(playerCharacterIndex, 5);
- }
- flag04 = 0;
- switchMessageHandler((int (__cdecl *)(_DWORD, _DWORD, _DWORD))handleMessageEncounter);
- result = 1;
- }
- return result;
-}
- */
+ /*
+ int __cdecl runEncounter(int newMessageHandler, int encounterIndex, int objectId1, int objectId2, int characterIndex)
+ {
+ int result; // eax at 7
+ EncounterItem *v6; // eax at 2
+ int v7; // ST04_4 at 4
+ int v8; // eax at 4
+
+ if ( !encounterKeywordIndex )
+ {
+ v6 = getEncounterItem(0);
+ encounterItem = v6;
+ encounterKeywordIndex = *(_DWORD *)&v6->keywordIndex;
+ }
+ if ( encounterIndex < 0 )
+ {
+ result = 0;
+ }
+ else
+ {
+ encounter_newMessageHandler = newMessageHandler;
+ encounterIndex = encounterIndex;
+ encounterItem = getEncounterItem(encounterIndex);
+ encounter_objectId01 = objectId1;
+ v7 = characterIndex;
+ encounter_objectId02 = objectId2;
+ characterIndex2 = characterIndex;
+ v8 = getObjectIndexById(objectId2);
+ object_sound_sub_414C30(v8, v7);
+ setEncounterVariable(1, 0);
+ setEncounterVariable(2, encounterItem->value);
+ if ( scene.characters[playerCharacterIndex].field_40 == 5 )
+ {
+ encounter_flag02 = 1;
+ }
+ else
+ {
+ encounter_flag02 = 0;
+ character_sub_4072A0(playerCharacterIndex, 5);
+ }
+ flag04 = 0;
+ switchMessageHandler((int (__cdecl *)(_DWORD, _DWORD, _DWORD))handleMessageEncounter);
+ result = 1;
+ }
+ return result;
+ }
+ */
}
Encounter::~Encounter() {
diff --git a/engines/asylum/encounters.h b/engines/asylum/encounters.h
index 1f0dd1c753..9fe1e6e345 100644
--- a/engines/asylum/encounters.h
+++ b/engines/asylum/encounters.h
@@ -55,7 +55,9 @@ public:
Encounter(Scene *scene);
virtual ~Encounter();
- void setVariable(int idx, int value) { _variables[idx] = value; }
+ void setVariable(int idx, int value) {
+ _variables[idx] = value;
+ }
void run(int encounterIdx, int barrierId1, int barrierId2, int characterIdx);
private:
diff --git a/engines/asylum/graphics.cpp b/engines/asylum/graphics.cpp
index c500f01c35..9e03332479 100644
--- a/engines/asylum/graphics.cpp
+++ b/engines/asylum/graphics.cpp
@@ -51,22 +51,26 @@ void GraphicResource::init(byte *data, uint32 size) {
dataPtr += 4; // tag value
- _flags = READ_UINT32(dataPtr); dataPtr += 4;
+ _flags = READ_UINT32(dataPtr);
+ dataPtr += 4;
- contentOffset = READ_UINT32(dataPtr); dataPtr += 4;
+ contentOffset = READ_UINT32(dataPtr);
+ dataPtr += 4;
dataPtr += 4; // unknown
dataPtr += 4; // unknown
dataPtr += 4; // unknown
- frameCount = READ_UINT16(dataPtr); dataPtr += 2;
+ frameCount = READ_UINT16(dataPtr);
+ dataPtr += 2;
dataPtr += 2; // max width
_frames.resize(frameCount);
// Read frame offsets
- uint32 prevOffset = READ_UINT32(dataPtr) + contentOffset; dataPtr += 4;
+ uint32 prevOffset = READ_UINT32(dataPtr) + contentOffset;
+ dataPtr += 4;
uint32 nextOffset = 0;
for (i = 0; i < frameCount; i++) {
@@ -93,11 +97,15 @@ void GraphicResource::init(byte *data, uint32 size) {
dataPtr += 4; // size
dataPtr += 4; // flag
- _frames[i].x = READ_UINT16(dataPtr); dataPtr += 2;
- _frames[i].y = READ_UINT16(dataPtr); dataPtr += 2;
+ _frames[i].x = READ_UINT16(dataPtr);
+ dataPtr += 2;
+ _frames[i].y = READ_UINT16(dataPtr);
+ dataPtr += 2;
- uint16 height = READ_UINT16(dataPtr); dataPtr += 2;
- uint16 width = READ_UINT16(dataPtr); dataPtr += 2;
+ uint16 height = READ_UINT16(dataPtr);
+ dataPtr += 2;
+ uint16 width = READ_UINT16(dataPtr);
+ dataPtr += 2;
_frames[i].surface.create(width, height, 1);
diff --git a/engines/asylum/graphics.h b/engines/asylum/graphics.h
index 4a9dbfe27e..cd6c7fd91b 100644
--- a/engines/asylum/graphics.h
+++ b/engines/asylum/graphics.h
@@ -47,21 +47,29 @@ public:
GraphicResource(ResourcePack *resPack, int entry);
~GraphicResource();
- uint32 getFrameCount() { return _frames.size(); }
- GraphicFrame *getFrame(int frame) { return &_frames[frame]; }
- uint32 getFlags() { return _flags; }
+ uint32 getFrameCount() {
+ return _frames.size();
+ }
+ GraphicFrame *getFrame(int frame) {
+ return &_frames[frame];
+ }
+ uint32 getFlags() {
+ return _flags;
+ }
/**
* Copies an animation frame to the target buffer
- */
+ */
void copyFrameToDest(byte *dest, int frame);
/**
* Copies a sprite to the target buffer, with transparency
*/
void copySpriteToDest(byte *dest, int frame);
-
- uint32 getEntryNum() { return _entryNum; }
+
+ uint32 getEntryNum() {
+ return _entryNum;
+ }
private:
Common::Array <GraphicFrame> _frames;
diff --git a/engines/asylum/menu.cpp b/engines/asylum/menu.cpp
index f085322d2f..23f0366832 100644
--- a/engines/asylum/menu.cpp
+++ b/engines/asylum/menu.cpp
@@ -83,11 +83,11 @@ void MainMenu::openMenu() {
// Copy the bright background to the back buffer
GraphicFrame *bg = _bgResource->getFrame(1);
_vm->screen()->copyToBackBuffer((byte *)bg->surface.pixels,
- bg->surface.w,
- 0,
- 0,
- bg->surface.w,
- bg->surface.h);
+ bg->surface.w,
+ 0,
+ 0,
+ bg->surface.w,
+ bg->surface.h);
// Set mouse cursor
_cursor->load(2);
@@ -356,7 +356,7 @@ void MainMenu::updateSubMenuNewGame() {
_text->drawResTextCentered(10, 100, 620, 0x80000529);
// Yes
- if (_cursor->x() < 247 || _cursor->x() > 247 + _text->getResTextWidth(0x8000052A) || _cursor->y() < 273 || _cursor->y() > 273 + 24 )
+ if (_cursor->x() < 247 || _cursor->x() > 247 + _text->getResTextWidth(0x8000052A) || _cursor->y() < 273 || _cursor->y() > 273 + 24)
_text->loadFont(_resPack, 0x80010010); // yellow font
else
_text->loadFont(_resPack, 0x80010016); // blue font
@@ -364,7 +364,7 @@ void MainMenu::updateSubMenuNewGame() {
_text->drawResText(0x8000052A);
// No
- if (_cursor->x() < 369 || _cursor->x() > 369 + _text->getResTextWidth(0x8000052B) || _cursor->y() < 273 || _cursor->y() > 273 + 24 )
+ if (_cursor->x() < 369 || _cursor->x() > 369 + _text->getResTextWidth(0x8000052B) || _cursor->y() < 273 || _cursor->y() > 273 + 24)
_text->loadFont(_resPack, 0x80010010); // yellow font
else
_text->loadFont(_resPack, 0x80010016); // blue font
@@ -378,7 +378,7 @@ void MainMenu::updateSubMenuNewGame() {
_leftClick = false;
// TODO handle new game event
}
- // No
+ // No
if (_cursor->x() >= 369 && _cursor->x() <= 369 + 24 && _cursor->y() >= 273 && _cursor->y() <= 273 + _text->getResTextWidth(0x8000052B))
exitSubMenu();
}
@@ -421,14 +421,14 @@ void MainMenu::updateSubMenuSettings() {
_text->drawResTextAlignRight(320, 150, 0x80000599);
if (_cursor->x() < 350 || _cursor->x() > sizeMinus + 350 || _cursor->y() < 150 || _cursor->y() > 174)
_text->loadFont(_resPack, 0x80010010); // yellow font
- else
+ else
_text->loadFont(_resPack, 0x80010016); // blue font
_text->setTextPos(350, 150);
_text->drawText("-");
if (_cursor->x() < sizeMinus + 360 || _cursor->x() > sizeMinus + sizePlus + 360 || _cursor->y() < 150 || _cursor->y() > 174)
_text->loadFont(_resPack, 0x80010010); // yellow font
- else
+ else
_text->loadFont(_resPack, 0x80010016); // blue font
_text->setTextPos(sizeMinus + 360, 150);
_text->drawText("+");
@@ -436,8 +436,8 @@ void MainMenu::updateSubMenuSettings() {
_text->setTextPos(sizeMinus + sizePlus + 365, 150);
_text->loadFont(_resPack, 0x80010010);
if (_confGammaLevel) {
- for (uint32 i = 0; i < _confGammaLevel; i++ ) {
- _text->drawText("]");
+ for (uint32 i = 0; i < _confGammaLevel; i++) {
+ _text->drawText("]");
}
if (_confGammaLevel == 8)
_text->drawText("*");
@@ -449,25 +449,25 @@ void MainMenu::updateSubMenuSettings() {
_text->drawResTextAlignRight(320, 179, 0x8000059A);
if (_cursor->x() < 350 || _cursor->x() > sizeMinus + 350 || _cursor->y() < 179 || _cursor->y() > 203)
_text->loadFont(_resPack, 0x80010010); // yellow font
- else
+ else
_text->loadFont(_resPack, 0x80010016); // blue font
_text->setTextPos(350, 179);
_text->drawText("-");
if (_cursor->x() < sizeMinus + 360 || _cursor->x() > sizeMinus + sizePlus + 360 || _cursor->y() < 179 || _cursor->y() > 203)
_text->loadFont(_resPack, 0x80010010); // yellow font
- else
+ else
_text->loadFont(_resPack, 0x80010016); // blue font
_text->setTextPos(sizeMinus + 360, 179);
_text->drawText("+");
_text->setTextPos(sizeMinus + sizePlus + 365, 179);
_text->loadFont(_resPack, 0x80010010);
- if(_confGameQuality == 5) {
+ if (_confGameQuality == 5) {
_text->drawResText(0x8000059C);
} else {
- for (uint32 i = 5; i > _confGameQuality; --i ) {
- _text->drawText("]");
+ for (uint32 i = 5; i > _confGameQuality; --i) {
+ _text->drawText("]");
}
if (!_confGameQuality)
_text->drawText("*");
@@ -476,7 +476,7 @@ void MainMenu::updateSubMenuSettings() {
// back to main menu
if (_cursor->x() < 300 || _cursor->x() > 300 + sizeMainMenu || _cursor->y() < 340 || _cursor->y() > 340 + 24)
_text->loadFont(_resPack, 0x80010010); // yellow font
- else
+ else
_text->loadFont(_resPack, 0x80010016); // blue font
_text->setTextPos(300, 340);
_text->drawResText(0x8000059D);
@@ -491,14 +491,14 @@ void MainMenu::updateSubMenuSettings() {
// gamma level minus
if (_cursor->x() >= 350 && _cursor->x() <= sizeMinus + 350 && _cursor->y() >= 150 && _cursor->y() <= 174) {
- if(_confGammaLevel) {
+ if (_confGammaLevel) {
_confGammaLevel -= 1;
// TODO: setResGammaLevel(0x80010011, 0);
}
}
// gamma level plus
if (_cursor->x() >= sizeMinus + 360 && _cursor->x() <= sizeMinus + sizePlus + 360 && _cursor->y() >= 150 && _cursor->y() <= 174) {
- if(_confGammaLevel < 8) {
+ if (_confGammaLevel < 8) {
_confGammaLevel += 1;
// TODO: setResGammaLevel(0x80010011, 0);
}
@@ -506,14 +506,14 @@ void MainMenu::updateSubMenuSettings() {
// performance minus
if (_cursor->x() >= 350 && _cursor->x() <= sizeMinus + 350 && _cursor->y() >= 179 && _cursor->y() <= 203) {
- if(_confGameQuality) {
+ if (_confGameQuality) {
_confGameQuality -= 1;
// TODO: change quality settings
}
}
// performance plus
if (_cursor->x() >= sizeMinus + 360 && _cursor->x() <= sizeMinus + sizePlus + 360 && _cursor->y() >= 179 && _cursor->y() <= 203) {
- if(_confGameQuality < 5) {
+ if (_confGameQuality < 5) {
_confGameQuality += 1;
// TODO: change quality settings
}
@@ -529,7 +529,7 @@ void MainMenu::updateSubMenuQuitGame() {
_text->drawResTextCentered(10, 100, 620, 0x80000580);
// Yes
- if (_cursor->x() < 247 || _cursor->x() > 247 + _text->getResTextWidth(0x80000581) || _cursor->y() < 273 || _cursor->y() > 273 + 24 )
+ if (_cursor->x() < 247 || _cursor->x() > 247 + _text->getResTextWidth(0x80000581) || _cursor->y() < 273 || _cursor->y() > 273 + 24)
_text->loadFont(_resPack, 0x80010010); // yellow font
else
_text->loadFont(_resPack, 0x80010016); // blue font
@@ -537,7 +537,7 @@ void MainMenu::updateSubMenuQuitGame() {
_text->drawResText(0x80000581);
// No
- if (_cursor->x() < 369 || _cursor->x() > 369 + _text->getResTextWidth(0x80000582) || _cursor->y() < 273 || _cursor->y() > 273 + 24 )
+ if (_cursor->x() < 369 || _cursor->x() > 369 + _text->getResTextWidth(0x80000582) || _cursor->y() < 273 || _cursor->y() > 273 + 24)
_text->loadFont(_resPack, 0x80010010); // yellow font
else
_text->loadFont(_resPack, 0x80010016); // blue font
@@ -608,7 +608,7 @@ void MainMenu::updateSubMenuShowCredits() {
_creditsTextScroll -= 2;
// TODO: some palette stuffs
-
+
// TODO: if gameFlag=901 (finished game) and already play music 56, start music 40
if (_leftClick) {
diff --git a/engines/asylum/menu.h b/engines/asylum/menu.h
index b62d764ff2..633c139235 100644
--- a/engines/asylum/menu.h
+++ b/engines/asylum/menu.h
@@ -46,7 +46,9 @@ public:
~MainMenu();
void handleEvent(Common::Event *event, bool doUpdate);
- bool isActive() { return _active; }
+ bool isActive() {
+ return _active;
+ }
void openMenu();
void closeMenu();
diff --git a/engines/asylum/polygons.cpp b/engines/asylum/polygons.cpp
index 9eedc08b74..13a5101d53 100644
--- a/engines/asylum/polygons.cpp
+++ b/engines/asylum/polygons.cpp
@@ -53,7 +53,7 @@ bool PolyDefinitions::contains(int x, int y) {
yflag1 = (vtx1->y >= y);
if (yflag0 != yflag1) {
if (((vtx1->y - y) * (vtx0->x - vtx1->x) >=
- (vtx1->x - x) * (vtx0->y - vtx1->y)) == yflag1) {
+ (vtx1->x - x) * (vtx0->y - vtx1->y)) == yflag1) {
inside_flag = !inside_flag;
}
}
diff --git a/engines/asylum/respack.h b/engines/asylum/respack.h
index c7cabcdc5c..cfb33dc57b 100644
--- a/engines/asylum/respack.h
+++ b/engines/asylum/respack.h
@@ -47,8 +47,10 @@ public:
~ResourcePack();
ResourceEntry *getResource(uint32 resourceId);
- uint32 getResourceCount() { return _resources.size(); }
-
+ uint32 getResourceCount() {
+ return _resources.size();
+ }
+
private:
Common::Array <ResourceEntry> _resources;
Common::File _packFile;
diff --git a/engines/asylum/scene.cpp b/engines/asylum/scene.cpp
index f999838513..48dc0194e2 100644
--- a/engines/asylum/scene.cpp
+++ b/engines/asylum/scene.cpp
@@ -53,7 +53,7 @@ Scene::Scene(uint8 sceneIdx, AsylumEngine *vm): _vm(vm) {
fd->read(sceneTag, 6);
- if (Common::String(sceneTag,6) != "DFISCN")
+ if (Common::String(sceneTag, 6) != "DFISCN")
error("The file isn't recognized as scene %s", filename);
_ws = new WorldStats(fd, this);
@@ -92,59 +92,58 @@ Scene::Scene(uint8 sceneIdx, AsylumEngine *vm): _vm(vm) {
_leftClick = false;
_rightButton = false;
_isActive = false;
- _skipDrawScene = 0;
+ _skipDrawScene = 0;
g_debugPolygons = 0;
g_debugBarriers = 0;
- // TODO: do all the rest stuffs in sub at address 40E460
- _playerActorIdx = 0;
-
- if (_ws->numBarriers > 0) {
- uint32 priority = 0x0FFB;
- for (uint32 b = 0; b < _ws->numBarriers; b++) {
- Barrier *barrier = &_ws->barriers[b];
- barrier->priority = priority;
- barrier->flags &= 0xFFFF3FFF;
- priority -= 4;
- }
- }
-
- _ws->sceneRectIdx = 0;
- _vm->screen()->clearGraphicsInQueue();
- _ws->motionStatus = 1;
-
- _ws->actors[_playerActorIdx].boundingRect.bottom = _ws->actors[_playerActorIdx].y2;
- _ws->actors[_playerActorIdx].boundingRect.right = 2 * _ws->actors[_playerActorIdx].x2;
- _ws->boundingRect = Common::Rect(195, 115, 445 - _ws->actors[_playerActorIdx].boundingRect.right, 345 - _ws->actors[_playerActorIdx].boundingRect.bottom);
-
- _ws->actors[_playerActorIdx].flags |= 1;
- _ws->actors[_playerActorIdx].update_4072A0(4);
-
- _ws->actors[_playerActorIdx].x1 -= _ws->actors[_playerActorIdx].x2;
- _ws->actors[_playerActorIdx].y1 -= _ws->actors[_playerActorIdx].y2;
-
- if(_ws->numActors > 1)
- {
- for (uint32 a = 1; a < _ws->numActors; a++) {
- Actor *actor= &_ws->actors[a];
- actor->flags |= 1;
- actor->direction = 1;
- actor->update_4072A0(4);
- actor->x1 -= actor->x2;
- actor->y1 -= actor->y2;
- actor->boundingRect.bottom = actor->y2;
- actor->boundingRect.right = 2 * actor->x2;
- }
- }
-
- // XXX
- // This is a hack for the moment to test out
- // the new sound queuing functionality
- for (uint i = 0; i < _ws->numAmbientSound; i++)
- _vm->sound()->addToSoundBuffer(_ws->ambientSounds[i].resId);
-
- // TODO: init action list
+ // TODO: do all the rest stuffs in sub at address 40E460
+ _playerActorIdx = 0;
+
+ if (_ws->numBarriers > 0) {
+ uint32 priority = 0x0FFB;
+ for (uint32 b = 0; b < _ws->numBarriers; b++) {
+ Barrier *barrier = &_ws->barriers[b];
+ barrier->priority = priority;
+ barrier->flags &= 0xFFFF3FFF;
+ priority -= 4;
+ }
+ }
+
+ _ws->sceneRectIdx = 0;
+ _vm->screen()->clearGraphicsInQueue();
+ _ws->motionStatus = 1;
+
+ _ws->actors[_playerActorIdx].boundingRect.bottom = _ws->actors[_playerActorIdx].y2;
+ _ws->actors[_playerActorIdx].boundingRect.right = 2 * _ws->actors[_playerActorIdx].x2;
+ _ws->boundingRect = Common::Rect(195, 115, 445 - _ws->actors[_playerActorIdx].boundingRect.right, 345 - _ws->actors[_playerActorIdx].boundingRect.bottom);
+
+ _ws->actors[_playerActorIdx].flags |= 1;
+ _ws->actors[_playerActorIdx].update_4072A0(4);
+
+ _ws->actors[_playerActorIdx].x1 -= _ws->actors[_playerActorIdx].x2;
+ _ws->actors[_playerActorIdx].y1 -= _ws->actors[_playerActorIdx].y2;
+
+ if (_ws->numActors > 1) {
+ for (uint32 a = 1; a < _ws->numActors; a++) {
+ Actor *actor = &_ws->actors[a];
+ actor->flags |= 1;
+ actor->direction = 1;
+ actor->update_4072A0(4);
+ actor->x1 -= actor->x2;
+ actor->y1 -= actor->y2;
+ actor->boundingRect.bottom = actor->y2;
+ actor->boundingRect.right = 2 * actor->x2;
+ }
+ }
+
+ // XXX
+ // This is a hack for the moment to test out
+ // the new sound queuing functionality
+ for (uint i = 0; i < _ws->numAmbientSound; i++)
+ _vm->sound()->addToSoundBuffer(_ws->ambientSounds[i].resId);
+
+ // TODO: init action list
}
Scene::~Scene() {
@@ -157,7 +156,7 @@ Scene::~Scene() {
delete _musPack;
delete _resPack;
delete _text;
- delete _blowUp;
+ delete _blowUp;
}
Actor* Scene::getActor() {
@@ -168,8 +167,8 @@ void Scene::enterScene() {
_vm->screen()->setPalette(_resPack, _ws->commonRes.palette);
_background = _bgResource->getFrame(0);
_vm->screen()->copyToBackBuffer(
- ((byte *)_background->surface.pixels) + _ws->targetY * _background->surface.w + _ws->targetX, _background->surface.w,
- 0, 0, 640, 480);
+ ((byte *)_background->surface.pixels) + _ws->targetY * _background->surface.w + _ws->targetX, _background->surface.w,
+ 0, 0, 640, 480);
// FIXME
// I don't know that this is the right way to initialize the cursor
@@ -187,20 +186,19 @@ void Scene::enterScene() {
_walking = false;
}
-void Scene::setScenePosition(int x, int y)
-{
+void Scene::setScenePosition(int x, int y) {
GraphicFrame *bg = _bgResource->getFrame(0);
//_startX = x;
//_startY = y;
- _ws->targetX = x;
- _ws->targetY = y;
-
+ _ws->targetX = x;
+ _ws->targetY = y;
+
if (_ws->targetX < 0)
_ws->targetX = 0;
if (_ws->targetX > (uint32)(bg->surface.w - 640))
_ws->targetX = bg->surface.w - 640;
-
-
+
+
if (_ws->targetY < 0)
_ws->targetY = 0;
if (_ws->targetY > (uint32)(bg->surface.h - 480))
@@ -246,57 +244,57 @@ void Scene::handleEvent(Common::Event *event, bool doUpdate) {
// -------------------------------------------
void Scene::update() {
- if(updateScene())
- return;
+ if (updateScene())
+ return;
- // TODO: check game quality
- drawScene();
+ // TODO: check game quality
+ drawScene();
- //TODO: other process stuffs from sub 0040AE30
+ //TODO: other process stuffs from sub 0040AE30
}
int Scene::updateScene() {
uint32 startTick = 0;
-
- // Mouse
- startTick = _vm->_system->getMillis();
- updateMouse();
- debugC(kDebugLevelScene, "UpdateMouse Time: %d", _vm->_system->getMillis() - startTick);
-
- // Actors
- startTick = _vm->_system->getMillis();
- for (uint32 a = 0; a < _ws->numActors; a++)
- updateActor(a);
- debugC(kDebugLevelScene, "UpdateActors Time: %d", _vm->_system->getMillis() - startTick);
-
- // Barriers
- startTick = _vm->_system->getMillis();
- updateBarriers2();
- debugC(kDebugLevelScene, "UpdateBarriers Time: %d", _vm->_system->getMillis() - startTick);
-
- // Ambient Sounds
- startTick = _vm->_system->getMillis();
- updateAmbientSounds();
- debugC(kDebugLevelScene, "UpdateAmbientSounds Time: %d", _vm->_system->getMillis() - startTick);
-
- // Music
- startTick = _vm->_system->getMillis();
- updateMusic();
- debugC(kDebugLevelScene, "UpdateMusic Time: %d", _vm->_system->getMillis() - startTick);
-
- // Adjust Screen
- //startTick = _vm->_system->getMillis();
- // FIXME
- // Commented out the (incomplete) update screen code because once the
- // actor's x1/y1 values are properly set, the temp code causes a crash
- // Have to finish implementing the method I guess :P
- //updateAdjustScreen();
- //debugC(kDebugLevelScene, "AdjustScreenStart Time: %d", _vm->_system->getMillis() - startTick);
-
- if(_actions->process())
- return 1;
-
- return 0;
+
+ // Mouse
+ startTick = _vm->_system->getMillis();
+ updateMouse();
+ debugC(kDebugLevelScene, "UpdateMouse Time: %d", _vm->_system->getMillis() - startTick);
+
+ // Actors
+ startTick = _vm->_system->getMillis();
+ for (uint32 a = 0; a < _ws->numActors; a++)
+ updateActor(a);
+ debugC(kDebugLevelScene, "UpdateActors Time: %d", _vm->_system->getMillis() - startTick);
+
+ // Barriers
+ startTick = _vm->_system->getMillis();
+ updateBarriers2();
+ debugC(kDebugLevelScene, "UpdateBarriers Time: %d", _vm->_system->getMillis() - startTick);
+
+ // Ambient Sounds
+ startTick = _vm->_system->getMillis();
+ updateAmbientSounds();
+ debugC(kDebugLevelScene, "UpdateAmbientSounds Time: %d", _vm->_system->getMillis() - startTick);
+
+ // Music
+ startTick = _vm->_system->getMillis();
+ updateMusic();
+ debugC(kDebugLevelScene, "UpdateMusic Time: %d", _vm->_system->getMillis() - startTick);
+
+ // Adjust Screen
+ //startTick = _vm->_system->getMillis();
+ // FIXME
+ // Commented out the (incomplete) update screen code because once the
+ // actor's x1/y1 values are properly set, the temp code causes a crash
+ // Have to finish implementing the method I guess :P
+ //updateAdjustScreen();
+ //debugC(kDebugLevelScene, "AdjustScreenStart Time: %d", _vm->_system->getMillis() - startTick);
+
+ if (_actions->process())
+ return 1;
+
+ return 0;
}
void Scene::updateMouse() {
@@ -436,100 +434,100 @@ void Scene::updateMouse() {
}
void Scene::updateActor(uint32 actorIdx) {
- Actor *actor = getActor();
-
- if (actor->visible()) {
- // printf("Actor updateType = 0x%02X\n", actor->updateType);
-
- switch (actor->updateType) {
-
- case 0x10:
- if (_ws->numChapter == 2) {
- // TODO: updateCharacterSub14()
- } else if (_ws->numChapter == 1) {
- if (_playerActorIdx == actorIdx) {
- // TODO: updateActorSub21();
- }
- }
- break;
- case 0x11:
- if (_ws->numChapter == 2) {
- // TODO: put code here
- } else if (_ws->numChapter == 11) {
- if (_playerActorIdx == actorIdx) {
- // TODO: put code here
- }
- }
- break;
- case 0xF:
- if (_ws->numChapter == 2) {
- // TODO: put code here
- } else if (_ws->numChapter == 11) {
- // TODO: put code here
- }
- break;
- case 0x12:
- if (_ws->numChapter == 2) {
- // TODO: put code here
- }
- break;
- case 0x5: {
- uint32 frameNum = actor->frameNum + 1;
- actor->frameNum = frameNum % actor->frameCount;
-
- if (_vm->_system->getMillis() - actor->tickValue1 > 300) {
- if (rand() % 100 < 50) {
- // TODO: check sound playing
- }
- actor->tickValue1 = _vm->_system->getMillis();
- }
- }
- break;
- case 0xC:
- if (_ws->numChapter == 2) {
- // TODO: put code here
- } else if (_ws->numChapter == 11) {
- // TODO: put code here
- }
- case 0x1:
- // TODO: do actor direction
- break;
- case 0x2:
- case 0xD:
- // TODO: do actor direction
- break;
- case 0x3:
- case 0x13:
- // TODO: updateCharacterSub05();
- break;
- case 0x7:
- // TODO: something
- break;
- case 0x4:
- if (actor->field_944 != 5) {
- // TODO: updateCharacterSub01_sw(1, actorIdx);
- }
- break;
- case 0xE:
- // TODO: updateCharacterSub02(1, actorIdx);
- break;
- case 0x15:
- // TODO: updateCharacterSub06(1, actorIdx);
- break;
- case 0x9:
- // TODO: updateCharacterSub03(1, actorIdx);
- break;
- case 0x6:
- case 0xA:
- actor->frameNum = (actor->frameNum + 1) % actor->frameCount;
- break;
- case 0x8:
- // TODO: actor sound
- break;
- default:
- break;
- }
- }
+ Actor *actor = getActor();
+
+ if (actor->visible()) {
+ // printf("Actor updateType = 0x%02X\n", actor->updateType);
+
+ switch (actor->updateType) {
+
+ case 0x10:
+ if (_ws->numChapter == 2) {
+ // TODO: updateCharacterSub14()
+ } else if (_ws->numChapter == 1) {
+ if (_playerActorIdx == actorIdx) {
+ // TODO: updateActorSub21();
+ }
+ }
+ break;
+ case 0x11:
+ if (_ws->numChapter == 2) {
+ // TODO: put code here
+ } else if (_ws->numChapter == 11) {
+ if (_playerActorIdx == actorIdx) {
+ // TODO: put code here
+ }
+ }
+ break;
+ case 0xF:
+ if (_ws->numChapter == 2) {
+ // TODO: put code here
+ } else if (_ws->numChapter == 11) {
+ // TODO: put code here
+ }
+ break;
+ case 0x12:
+ if (_ws->numChapter == 2) {
+ // TODO: put code here
+ }
+ break;
+ case 0x5: {
+ uint32 frameNum = actor->frameNum + 1;
+ actor->frameNum = frameNum % actor->frameCount;
+
+ if (_vm->_system->getMillis() - actor->tickValue1 > 300) {
+ if (rand() % 100 < 50) {
+ // TODO: check sound playing
+ }
+ actor->tickValue1 = _vm->_system->getMillis();
+ }
+ }
+ break;
+ case 0xC:
+ if (_ws->numChapter == 2) {
+ // TODO: put code here
+ } else if (_ws->numChapter == 11) {
+ // TODO: put code here
+ }
+ case 0x1:
+ // TODO: do actor direction
+ break;
+ case 0x2:
+ case 0xD:
+ // TODO: do actor direction
+ break;
+ case 0x3:
+ case 0x13:
+ // TODO: updateCharacterSub05();
+ break;
+ case 0x7:
+ // TODO: something
+ break;
+ case 0x4:
+ if (actor->field_944 != 5) {
+ // TODO: updateCharacterSub01_sw(1, actorIdx);
+ }
+ break;
+ case 0xE:
+ // TODO: updateCharacterSub02(1, actorIdx);
+ break;
+ case 0x15:
+ // TODO: updateCharacterSub06(1, actorIdx);
+ break;
+ case 0x9:
+ // TODO: updateCharacterSub03(1, actorIdx);
+ break;
+ case 0x6:
+ case 0xA:
+ actor->frameNum = (actor->frameNum + 1) % actor->frameCount;
+ break;
+ case 0x8:
+ // TODO: actor sound
+ break;
+ default:
+ break;
+ }
+ }
}
// XXX WIP
@@ -564,143 +562,143 @@ void Scene::updateBarriers() {
}
void Scene::updateBarriers2() {
- Screen *screen = _vm->screen();
-
- uint barriersCount = _ws->barriers.size();
- int startTickCount = 0;
- bool canPlaySound = false;
-
- if (barriersCount > 0) {
- for (uint32 b = 0; b < barriersCount; b++) {
- Barrier *barrier = &_ws->barriers[b];
-
- if (barrier->field_3C == 4) {
- if (_ws->isBarrierVisible(b)) {
- uint32 flag = barrier->flags;
- if (flag & 0x20) {
- if (barrier->field_B4 && (_vm->_system->getMillis() - barrier->tickCount >= 0x3E8 / barrier->field_B4)) {
- barrier->frameIdx = (barrier->frameIdx + 1) % barrier->frameCount;
- barrier->tickCount = _vm->_system->getMillis();
- canPlaySound = true;
- }
- } else if (flag & 0x10) {
- uint32 frameIdx = barrier->frameIdx;
- char equalZero = frameIdx == 0;
- char lessZero = frameIdx < 0;
- if (!frameIdx) {
- if (_vm->_system->getMillis() - barrier->tickCount >= 1000 * barrier->tickCount2) {
- if (rand() % barrier->field_C0 == 1) {
- if (barrier->field_68C[0]) {
- // TODO: fix this, and find a better way to get frame count
- // Sometimes we get wrong random resource id
-
- barrier->resId = barrier->getRandomId();
- GraphicResource *gra = new GraphicResource(_resPack, barrier->resId);
- barrier->frameCount = gra->getFrameCount();
- delete gra;
- }
- barrier->frameIdx++;
- }
- barrier->tickCount = _vm->_system->getMillis();
- canPlaySound = true;
- }
- frameIdx = barrier->frameIdx;
- equalZero = frameIdx == 0;
- lessZero = frameIdx < 0;
- }
-
- if (!(lessZero ^ 0 | equalZero)) {
- // FIXME: we shouldn't increment field_B4 (check why this value came zero sometimes)
- if (barrier->field_B4 && (_vm->_system->getMillis() - barrier->tickCount >= 0x3E8 / barrier->field_B4)) {
- barrier->frameIdx = (barrier->frameIdx + 1) % barrier->frameCount;
- barrier->tickCount = _vm->_system->getMillis();
- canPlaySound = true;
- }
- }
- } else if (flag & 8) {
- // FIXME: we shouldn't increment field_B4 (check why this value came zero sometimes)
+ Screen *screen = _vm->screen();
+
+ uint barriersCount = _ws->barriers.size();
+ int startTickCount = 0;
+ bool canPlaySound = false;
+
+ if (barriersCount > 0) {
+ for (uint32 b = 0; b < barriersCount; b++) {
+ Barrier *barrier = &_ws->barriers[b];
+
+ if (barrier->field_3C == 4) {
+ if (_ws->isBarrierVisible(b)) {
+ uint32 flag = barrier->flags;
+ if (flag & 0x20) {
+ if (barrier->field_B4 && (_vm->_system->getMillis() - barrier->tickCount >= 0x3E8 / barrier->field_B4)) {
+ barrier->frameIdx = (barrier->frameIdx + 1) % barrier->frameCount;
+ barrier->tickCount = _vm->_system->getMillis();
+ canPlaySound = true;
+ }
+ } else if (flag & 0x10) {
+ uint32 frameIdx = barrier->frameIdx;
+ char equalZero = frameIdx == 0;
+ char lessZero = frameIdx < 0;
+ if (!frameIdx) {
+ if (_vm->_system->getMillis() - barrier->tickCount >= 1000 * barrier->tickCount2) {
+ if (rand() % barrier->field_C0 == 1) {
+ if (barrier->field_68C[0]) {
+ // TODO: fix this, and find a better way to get frame count
+ // Sometimes we get wrong random resource id
+
+ barrier->resId = barrier->getRandomId();
+ GraphicResource *gra = new GraphicResource(_resPack, barrier->resId);
+ barrier->frameCount = gra->getFrameCount();
+ delete gra;
+ }
+ barrier->frameIdx++;
+ }
+ barrier->tickCount = _vm->_system->getMillis();
+ canPlaySound = true;
+ }
+ frameIdx = barrier->frameIdx;
+ equalZero = frameIdx == 0;
+ lessZero = frameIdx < 0;
+ }
+
+ if (!(lessZero ^ 0 | equalZero)) {
+ // FIXME: we shouldn't increment field_B4 (check why this value came zero sometimes)
+ if (barrier->field_B4 && (_vm->_system->getMillis() - barrier->tickCount >= 0x3E8 / barrier->field_B4)) {
+ barrier->frameIdx = (barrier->frameIdx + 1) % barrier->frameCount;
+ barrier->tickCount = _vm->_system->getMillis();
+ canPlaySound = true;
+ }
+ }
+ } else if (flag & 8) {
+ // FIXME: we shouldn't increment field_B4 (check why this value came zero sometimes)
if (barrier->field_B4 && (_vm->_system->getMillis() - barrier->tickCount >= 0x3E8 / barrier->field_B4)) {
uint32 frameIdx = barrier->frameIdx + 1;
- if (frameIdx < barrier->frameCount - 1) {
- if (barrier->field_688 == 1) {
- // TODO: get global x, y positions
- }
- } else {
- barrier->flags &= 0xFFFFFFF7;
- if (barrier->field_688 == 1) {
- // TODO: reset global x, y positions
- }
- }
- barrier->frameIdx = frameIdx;
+ if (frameIdx < barrier->frameCount - 1) {
+ if (barrier->field_688 == 1) {
+ // TODO: get global x, y positions
+ }
+ } else {
+ barrier->flags &= 0xFFFFFFF7;
+ if (barrier->field_688 == 1) {
+ // TODO: reset global x, y positions
+ }
+ }
+ barrier->frameIdx = frameIdx;
}
- } else if ((flag & 0xFF) & 8) { // check this
- if (_vm->_system->getMillis() - barrier->tickCount >= 1000 * barrier->tickCount2) {
+ } else if ((flag & 0xFF) & 8) { // check this
+ if (_vm->_system->getMillis() - barrier->tickCount >= 1000 * barrier->tickCount2) {
if (rand() % barrier->field_C0 == 1) { // TODO: THIS ISNT WORKING
barrier->frameIdx = (barrier->frameIdx + 1) % barrier->frameCount;
- barrier->tickCount = _vm->_system->getMillis();
- canPlaySound = true;
+ barrier->tickCount = _vm->_system->getMillis();
+ canPlaySound = true;
}
- }
+ }
} else if (!((flag & 0xFFFF) & 6)) {
- // FIXME: we shouldn't increment field_B4 (check why this value came zero sometimes)
- if (barrier->field_B4 && (_vm->_system->getMillis() - barrier->tickCount >= 0x3E8 / barrier->field_B4) && (flag & 0x10000)) {
- uint32 frameIdx = barrier->frameIdx - 1;
- if (frameIdx <= 0) {
- barrier->flags &= 0xFFFEFFFF;
- if (barrier->field_688 == 1) {
- // TODO: reset global x, y positions
- }
- barrier->tickCount = _vm->_system->getMillis();
- canPlaySound = true;
- }
- if (barrier->field_688 == 1) {
- // TODO: get global x, y positions
- }
- barrier->frameIdx = frameIdx;
- } else if (barrier->field_B4 && (_vm->_system->getMillis() - barrier->tickCount >= 0x3E8 / barrier->field_B4)) {
- if ((flag & 0xFF) & 2) {
- if (barrier->frameIdx == barrier->frameCount - 1) {
- barrier->frameIdx--;
- barrier->flags = ((flag & 0xFF) & 0xFD) | 4;
- } else {
- barrier->frameIdx++;
- }
- } else if ((flag & 0xFF) & 4) {
- if (barrier->frameIdx) {
- barrier->frameIdx--;
- } else {
- barrier->frameIdx++;
- barrier->flags = ((flag & 0xFF) & 0xFB) | 2;
- }
- }
- }
- }
-
- flag = barrier->flags;
- flag &= 0x40000;
- if (flag != 0) {
- if (barrier->frameIdx == barrier->frameCount - 1) {
- if (barrier->field_B4 <= 15) {
- barrier->field_B4 -= 2;
- if (barrier->field_B4 < 0) // FIXME: check this
- barrier->field_B4 = 0;
- } else {
- barrier->field_B4 = 15;
- }
- if (!barrier->field_B4)
- barrier->flags &= 0xFFFEF1C7;
- }
- }
- }
-
- if (canPlaySound) {
- // TODO: play sounds
- }
-
- // TODO: get sound functions according with scene
- }
- }
- }
+ // FIXME: we shouldn't increment field_B4 (check why this value came zero sometimes)
+ if (barrier->field_B4 && (_vm->_system->getMillis() - barrier->tickCount >= 0x3E8 / barrier->field_B4) && (flag & 0x10000)) {
+ uint32 frameIdx = barrier->frameIdx - 1;
+ if (frameIdx <= 0) {
+ barrier->flags &= 0xFFFEFFFF;
+ if (barrier->field_688 == 1) {
+ // TODO: reset global x, y positions
+ }
+ barrier->tickCount = _vm->_system->getMillis();
+ canPlaySound = true;
+ }
+ if (barrier->field_688 == 1) {
+ // TODO: get global x, y positions
+ }
+ barrier->frameIdx = frameIdx;
+ } else if (barrier->field_B4 && (_vm->_system->getMillis() - barrier->tickCount >= 0x3E8 / barrier->field_B4)) {
+ if ((flag & 0xFF) & 2) {
+ if (barrier->frameIdx == barrier->frameCount - 1) {
+ barrier->frameIdx--;
+ barrier->flags = ((flag & 0xFF) & 0xFD) | 4;
+ } else {
+ barrier->frameIdx++;
+ }
+ } else if ((flag & 0xFF) & 4) {
+ if (barrier->frameIdx) {
+ barrier->frameIdx--;
+ } else {
+ barrier->frameIdx++;
+ barrier->flags = ((flag & 0xFF) & 0xFB) | 2;
+ }
+ }
+ }
+ }
+
+ flag = barrier->flags;
+ flag &= 0x40000;
+ if (flag != 0) {
+ if (barrier->frameIdx == barrier->frameCount - 1) {
+ if (barrier->field_B4 <= 15) {
+ barrier->field_B4 -= 2;
+ if (barrier->field_B4 < 0) // FIXME: check this
+ barrier->field_B4 = 0;
+ } else {
+ barrier->field_B4 = 15;
+ }
+ if (!barrier->field_B4)
+ barrier->flags &= 0xFFFEF1C7;
+ }
+ }
+ }
+
+ if (canPlaySound) {
+ // TODO: play sounds
+ }
+
+ // TODO: get sound functions according with scene
+ }
+ }
+ }
}
void Scene::updateAmbientSounds() {
@@ -754,39 +752,39 @@ void Scene::updateAmbientSounds() {
v15 = rand() % 500;
v11 = v15 * ((((rand() % 100 >= 50) - 1) & 2) - 1) + volume;
v10 = v11;
- if ( v11 <= -10000 )
- v10 = -10000;
- if ( v10 >= 0 )
- v11 = 0;
+ if (v11 <= -10000)
+ v10 = -10000;
+ if (v10 >= 0)
+ v11 = 0;
else
- if ( v11 <= -10000 )
- v11 = -10000;
+ if (v11 <= -10000)
+ v11 = -10000;
v16 = rand();
_vm->sound()->playSound(_resPack, snd->resId, false, v11, v16 % 20001 - 10000);
}
} else {
if (LOBYTE(snd->flags) & 4) {
- /*
- if ( (unsigned int)*ambientPanningArray < getTickCount() )
- {
- if ( v1->field_14 >= 0 )
- v12 = 60000 * v1->field_14 + getTickCount();
- else
- v12 = getTickCount() - 1000 * v1->field_14;
- *ambientPanningArray = v12;
- playSound(v7, 0, v9, panning);
- }
- */
- } else {
- if (LOBYTE(snd->flags) & 8) {
- /*
- if ( !*(ambientPanningArray - 15) )
+ /*
+ if ( (unsigned int)*ambientPanningArray < getTickCount() )
{
+ if ( v1->field_14 >= 0 )
+ v12 = 60000 * v1->field_14 + getTickCount();
+ else
+ v12 = getTickCount() - 1000 * v1->field_14;
+ *ambientPanningArray = v12;
playSound(v7, 0, v9, panning);
- *(ambientPanningArray - 15) = 1;
}
*/
- }
+ } else {
+ if (LOBYTE(snd->flags) & 8) {
+ /*
+ if ( !*(ambientPanningArray - 15) )
+ {
+ playSound(v7, 0, v9, panning);
+ *(ambientPanningArray - 15) = 1;
+ }
+ */
+ }
}
}
}
@@ -887,8 +885,8 @@ void Scene::updateAdjustScreen() {
scene.field_88 = 3;
scene.field_98 = -1;
}
- }
- */
+ }
+ */
}
}
}
@@ -968,10 +966,10 @@ void Scene::OLD_UPDATE() {
for (uint32 p = 0; p < _ws->numBarriers; p++) {
Barrier b = _ws->barriers[p];
if (b.flags & 0x20) {
- if ((b.boundingRect.left + b.x <= _cursor->x() + _ws->targetX) &&
- (_cursor->x() + _ws->targetX < b.boundingRect.right + b.x) &&
- (b.boundingRect.top + b.y <= _cursor->y() + _ws->targetY) &&
- (_cursor->y() + _ws->targetY < b.boundingRect.bottom + b.y)) {
+ if ((b.boundingRect.left + b.x <= _cursor->x() + _ws->targetX) &&
+ (_cursor->x() + _ws->targetX < b.boundingRect.right + b.x) &&
+ (b.boundingRect.top + b.y <= _cursor->y() + _ws->targetY) &&
+ (_cursor->y() + _ws->targetY < b.boundingRect.bottom + b.y)) {
_cursor->animate();
curBarrier = (int32)p;
break;
@@ -1005,24 +1003,24 @@ void Scene::OLD_UPDATE() {
for (uint32 a = 0; a < _ws->numActions; a++) {
if (_ws->actions[a].polyIdx == (uint32)curHotspot) {
debugC(kDebugLevelScripts, "Hotspot: 0x%X - \"%s\", poly %d, action lists %d/%d, action type %d, sound res %d\n",
- _ws->actions[a].id,
- _ws->actions[a].name,
- _ws->actions[a].polyIdx,
- _ws->actions[a].actionListIdx1,
- _ws->actions[a].actionListIdx2,
- _ws->actions[a].actionType,
- _ws->actions[a].soundResId);
+ _ws->actions[a].id,
+ _ws->actions[a].name,
+ _ws->actions[a].polyIdx,
+ _ws->actions[a].actionListIdx1,
+ _ws->actions[a].actionListIdx2,
+ _ws->actions[a].actionType,
+ _ws->actions[a].soundResId);
_actions->setScriptByIndex(_ws->actions[a].actionListIdx1);
}
}
} else if (curBarrier >= 0) {
Barrier b = _ws->barriers[curBarrier];
debugC(kDebugLevelScripts, "%s: action(%d) sound(%d) flags(%d/%d)\n",
- b.name,
- b.actionListIdx,
- b.soundResId,
- b.flags,
- b.flags2);
+ b.name,
+ b.actionListIdx,
+ b.soundResId,
+ b.flags,
+ b.flags2);
_actions->setScriptByIndex(b.actionListIdx);
}
}
@@ -1034,101 +1032,100 @@ void Scene::OLD_UPDATE() {
int Scene::drawScene() {
- _vm->screen()->clearGraphicsInQueue();
-
- if (_skipDrawScene) {
- _vm->screen()->clearScreen();
- } else {
- // Draw scene background
- GraphicFrame *bg = _bgResource->getFrame(0);
- _vm->screen()->copyToBackBuffer(
- ((byte *)bg->surface.pixels) + _ws->targetY * bg->surface.w + _ws->targetX, bg->surface.w,
- _ws->xLeft,
- _ws->yTop,
- 640,
- 480);
-
- // DEBUG
- // Force the screen to scroll if the mouse approaches the edges
- //debugScreenScrolling(bg);
-
- // TODO: prepare Actors and Barriers draw
- drawActors();
- drawBarriers();
- // TODO: draw main actor stuff
-
- _vm->screen()->drawGraphicsInQueue();
-
- // TODO: we must get rid of this
- OLD_UPDATE();
- }
-
- return 1;
+ _vm->screen()->clearGraphicsInQueue();
+
+ if (_skipDrawScene) {
+ _vm->screen()->clearScreen();
+ } else {
+ // Draw scene background
+ GraphicFrame *bg = _bgResource->getFrame(0);
+ _vm->screen()->copyToBackBuffer(
+ ((byte *)bg->surface.pixels) + _ws->targetY * bg->surface.w + _ws->targetX, bg->surface.w,
+ _ws->xLeft,
+ _ws->yTop,
+ 640,
+ 480);
+
+ // DEBUG
+ // Force the screen to scroll if the mouse approaches the edges
+ //debugScreenScrolling(bg);
+
+ // TODO: prepare Actors and Barriers draw
+ drawActors();
+ drawBarriers();
+ // TODO: draw main actor stuff
+
+ _vm->screen()->drawGraphicsInQueue();
+
+ // TODO: we must get rid of this
+ OLD_UPDATE();
+ }
+
+ return 1;
}
-void Scene::getActorPosition(Actor *actor, Common::Point *pt) {
- pt->x = actor->x1 - _ws->xLeft;
- pt->y = actor->y1 - _ws->yTop;
+void Scene::getActorPosition(Actor *actor, Common::Point *pt) {
+ pt->x = actor->x1 - _ws->xLeft;
+ pt->y = actor->y1 - _ws->yTop;
}
int Scene::drawActors() {
-
- if (_ws->numActors > 0)
- {
- Common::Point pt;
- for (uint32 a = 0; a < _ws->numActors; a++) {
- Actor *actor = &_ws->actors[a];
-
- if ((actor->flags & 0xFF) & 1) { // check this mask
- getActorPosition(actor, &pt);
- //pt.x += actor->x;
- //pt.y += actor->y;
-
- uint32 frameNum = actor->frameNum;
- if (actor->frameNum >= actor->frameCount) {
- frameNum = 2 * actor->frameCount - actor->frameNum - 1;
- }
-
- if ((actor->flags & 0xFF) & 2) {
- // TODO: sub_40AC10
-
-
-
- } else {
- // TODO: get flag value from character_DeadSarah_sub_40A140
- _vm->screen()->addGraphicToQueue(actor->grResId, frameNum, pt.x, pt.y, ((actor->direction < 5) - 1) & 2, actor->field_96C, actor->priority);
- }
- }
- }
- }
-
- return 1;
+
+ if (_ws->numActors > 0) {
+ Common::Point pt;
+ for (uint32 a = 0; a < _ws->numActors; a++) {
+ Actor *actor = &_ws->actors[a];
+
+ if ((actor->flags & 0xFF) & 1) { // check this mask
+ getActorPosition(actor, &pt);
+ //pt.x += actor->x;
+ //pt.y += actor->y;
+
+ uint32 frameNum = actor->frameNum;
+ if (actor->frameNum >= actor->frameCount) {
+ frameNum = 2 * actor->frameCount - actor->frameNum - 1;
+ }
+
+ if ((actor->flags & 0xFF) & 2) {
+ // TODO: sub_40AC10
+
+
+
+ } else {
+ // TODO: get flag value from character_DeadSarah_sub_40A140
+ _vm->screen()->addGraphicToQueue(actor->grResId, frameNum, pt.x, pt.y, ((actor->direction < 5) - 1) & 2, actor->field_96C, actor->priority);
+ }
+ }
+ }
+ }
+
+ return 1;
}
int Scene::drawBarriers() {
- uint barriersCount = _ws->barriers.size();
-
- if (barriersCount > 0) {
- for (uint32 b = 0; b < barriersCount; b++) {
- Barrier *barrier = &_ws->barriers[b];
-
- if (!(barrier->flags & 4) && !((barrier->flags & 0xFF) & 0x40)) {
- if (_ws->isBarrierOnScreen(b)) {
- //TODO: need to do something here yet
-
- if (barrier->field_67C <= 0 || barrier->field_67C >= 4) { // TODO: still missing a condition for game quality config
- _vm->screen()->addGraphicToQueue(barrier->resId, barrier->frameIdx, barrier->x, barrier->y, (barrier->flags >> 11) & 2, barrier->field_67C - 3, barrier->priority);
- } else {
- // TODO: Do Cross Fade
- // parameters: barrier->resId, barrier->frameIdx, barrier->x, barrier->y, _ws->commonRes.backgroundImage, _ws->xLeft, _ws->yTop, 0, 0, barrier->field_67C - 1
- _vm->screen()->addGraphicToQueue(barrier->resId, barrier->frameIdx, barrier->x, barrier->y, 0, 0, 0);
- }
- }
- }
- }
- }
-
- return 1;
+ uint barriersCount = _ws->barriers.size();
+
+ if (barriersCount > 0) {
+ for (uint32 b = 0; b < barriersCount; b++) {
+ Barrier *barrier = &_ws->barriers[b];
+
+ if (!(barrier->flags & 4) && !((barrier->flags & 0xFF) & 0x40)) {
+ if (_ws->isBarrierOnScreen(b)) {
+ //TODO: need to do something here yet
+
+ if (barrier->field_67C <= 0 || barrier->field_67C >= 4) { // TODO: still missing a condition for game quality config
+ _vm->screen()->addGraphicToQueue(barrier->resId, barrier->frameIdx, barrier->x, barrier->y, (barrier->flags >> 11) & 2, barrier->field_67C - 3, barrier->priority);
+ } else {
+ // TODO: Do Cross Fade
+ // parameters: barrier->resId, barrier->frameIdx, barrier->x, barrier->y, _ws->commonRes.backgroundImage, _ws->xLeft, _ws->yTop, 0, 0, barrier->field_67C - 1
+ _vm->screen()->addGraphicToQueue(barrier->resId, barrier->frameIdx, barrier->x, barrier->y, 0, 0, 0);
+ }
+ }
+ }
+ }
+ }
+
+ return 1;
}
@@ -1154,14 +1151,14 @@ void Scene::copyToBackBufferClipped(Graphics::Surface *surface, int x, int y) {
startY = _ws->targetY;
_vm->screen()->copyToBackBufferWithTransparency(
- ((byte*)surface->pixels) +
- startY * surface->pitch +
- startX * surface->bytesPerPixel,
- surface->pitch,
- animRect.left,
- animRect.top,
- animRect.width(),
- animRect.height());
+ ((byte*)surface->pixels) +
+ startY * surface->pitch +
+ startX * surface->bytesPerPixel,
+ surface->pitch,
+ animRect.left,
+ animRect.top,
+ animRect.width(),
+ animRect.height());
}
}
@@ -1170,7 +1167,7 @@ void Scene::copyToBackBufferClipped(Graphics::Surface *surface, int x, int y) {
// ----------------------------------
void Scene::debugScreenScrolling(GraphicFrame *bg) {
- // Horizontal scrolling
+ // Horizontal scrolling
if (_cursor->x() < SCREEN_EDGES && _ws->targetX >= SCROLL_STEP)
_ws->targetX -= SCROLL_STEP;
else if (_cursor->x() > 640 - SCREEN_EDGES && _ws->targetX <= (uint32)bg->surface.w - 640 - SCROLL_STEP)
@@ -1187,16 +1184,16 @@ void Scene::debugScreenScrolling(GraphicFrame *bg) {
void Scene::debugShowWalkRegion(PolyDefinitions *poly) {
Graphics::Surface surface;
surface.create(poly->boundingRect.right - poly->boundingRect.left + 1,
- poly->boundingRect.bottom - poly->boundingRect.top + 1,
- 1);
+ poly->boundingRect.bottom - poly->boundingRect.top + 1,
+ 1);
// Draw all lines in Polygon
- for (uint32 i=0; i < poly->numPoints; i++) {
+ for (uint32 i = 0; i < poly->numPoints; i++) {
surface.drawLine(
- poly->points[i].x - poly->boundingRect.left,
- poly->points[i].y - poly->boundingRect.top,
- poly->points[(i+1) % poly->numPoints].x - poly->boundingRect.left,
- poly->points[(i+1) % poly->numPoints].y - poly->boundingRect.top, 0x3A);
+ poly->points[i].x - poly->boundingRect.left,
+ poly->points[i].y - poly->boundingRect.top,
+ poly->points[(i+1) % poly->numPoints].x - poly->boundingRect.left,
+ poly->points[(i+1) % poly->numPoints].y - poly->boundingRect.top, 0x3A);
}
copyToBackBufferClipped(&surface, poly->boundingRect.left, poly->boundingRect.top);
@@ -1210,18 +1207,18 @@ void Scene::debugShowPolygons() {
Graphics::Surface surface;
PolyDefinitions poly = _polygons->entries[p];
surface.create(poly.boundingRect.right - poly.boundingRect.left + 1,
- poly.boundingRect.bottom - poly.boundingRect.top + 1,
- 1);
-
+ poly.boundingRect.bottom - poly.boundingRect.top + 1,
+ 1);
+
// Draw all lines in Polygon
- for (uint32 i=0; i < poly.numPoints; i++) {
+ for (uint32 i = 0; i < poly.numPoints; i++) {
surface.drawLine(
- poly.points[i].x - poly.boundingRect.left,
- poly.points[i].y - poly.boundingRect.top,
- poly.points[(i+1) % poly.numPoints].x - poly.boundingRect.left,
- poly.points[(i+1) % poly.numPoints].y - poly.boundingRect.top, 0xFF);
+ poly.points[i].x - poly.boundingRect.left,
+ poly.points[i].y - poly.boundingRect.top,
+ poly.points[(i+1) % poly.numPoints].x - poly.boundingRect.left,
+ poly.points[(i+1) % poly.numPoints].y - poly.boundingRect.top, 0xFF);
}
-
+
copyToBackBufferClipped(&surface, poly.boundingRect.left, poly.boundingRect.top);
surface.free();
@@ -1236,8 +1233,8 @@ void Scene::debugShowBarriers() {
if (b.flags & 0x20) {
surface.create(b.boundingRect.right - b.boundingRect.left + 1,
- b.boundingRect.bottom - b.boundingRect.top + 1,
- 1);
+ b.boundingRect.bottom - b.boundingRect.top + 1,
+ 1);
surface.frameRect(b.boundingRect, 0x22);
copyToBackBufferClipped(&surface, b.x, b.y);
}
@@ -1254,8 +1251,8 @@ void Scene::debugShowActors() {
if (a.flags & 2) {
surface.create(a.boundingRect.right - a.boundingRect.left + 1,
- a.boundingRect.bottom - a.boundingRect.top + 1,
- 1);
+ a.boundingRect.bottom - a.boundingRect.top + 1,
+ 1);
surface.frameRect(a.boundingRect, 0x22);
copyToBackBufferClipped(&surface, a.x, a.y);
}
diff --git a/engines/asylum/scene.h b/engines/asylum/scene.h
index fb415716a1..68ab799860 100644
--- a/engines/asylum/scene.h
+++ b/engines/asylum/scene.h
@@ -59,39 +59,67 @@ public:
void handleEvent(Common::Event *event, bool doUpdate);
void enterScene();
- void activate() { _isActive = true; }
- void deactivate() { _isActive = false; }
- bool isActive() { return _isActive; }
- int getSceneIndex() { return _sceneIdx; }
+ void activate() {
+ _isActive = true;
+ }
+ void deactivate() {
+ _isActive = false;
+ }
+ bool isActive() {
+ return _isActive;
+ }
+ int getSceneIndex() {
+ return _sceneIdx;
+ }
Actor* getActor();
- Cursor* getCursor() { return _cursor; }
- ResourcePack* getResourcePack() { return _resPack; }
- ResourcePack* getMusicPack() { return _musPack; }
- GraphicResource* getGraphicResource(uint32 entry) { return new GraphicResource(_resPack, entry); }
- BlowUpPuzzle* getBlowUpPuzzle() { return _blowUp; }
-
- void setBlowUpPuzzle(BlowUpPuzzle* puzzle) { _blowUp = puzzle; }
- void setScenePosition(int x, int y);
-
- AsylumEngine* vm() { return _vm; }
- WorldStats* worldstats() { return _ws; }
- Polygons* polygons() { return _polygons; }
- ActionList* actions() { return _actions; }
+ Cursor* getCursor() {
+ return _cursor;
+ }
+ ResourcePack* getResourcePack() {
+ return _resPack;
+ }
+ ResourcePack* getMusicPack() {
+ return _musPack;
+ }
+ GraphicResource* getGraphicResource(uint32 entry) {
+ return new GraphicResource(_resPack, entry);
+ }
+ BlowUpPuzzle* getBlowUpPuzzle() {
+ return _blowUp;
+ }
+
+ void setBlowUpPuzzle(BlowUpPuzzle* puzzle) {
+ _blowUp = puzzle;
+ }
+ void setScenePosition(int x, int y);
+
+ AsylumEngine* vm() {
+ return _vm;
+ }
+ WorldStats* worldstats() {
+ return _ws;
+ }
+ Polygons* polygons() {
+ return _polygons;
+ }
+ ActionList* actions() {
+ return _actions;
+ }
private:
- AsylumEngine *_vm;
- uint8 _sceneIdx;
+ AsylumEngine *_vm;
+ uint8 _sceneIdx;
WorldStats *_ws;
Polygons *_polygons;
ActionList *_actions;
Cursor *_cursor;
- ResourcePack *_resPack;
+ ResourcePack *_resPack;
ResourcePack *_speechPack;
ResourcePack *_musPack;
- BlowUpPuzzle *_blowUp;
+ BlowUpPuzzle *_blowUp;
Common::Event *_ev;
Text *_text;
GraphicResource *_bgResource;
@@ -101,37 +129,37 @@ private:
bool _leftClick;
bool _rightButton;
bool _isActive;
- bool _skipDrawScene;
- uint32 _playerActorIdx;
+ bool _skipDrawScene;
+ uint32 _playerActorIdx;
void update();
- int updateScene();
- void updateMouse();
- void updateActor(uint32 actorIdx);
- void updateBarriers();
- void updateBarriers2(); // XXX Alexandre's version
- void updateAmbientSounds();
- void updateMusic();
- void updateAdjustScreen();
- int drawScene();
- int drawActors();
- int drawBarriers();
- bool isBarrierVisible(BarrierItem *barrier);
- bool isBarrierOnScreen(BarrierItem *barrier);
- uint32 getRandomResId(BarrierItem *barrier);
- void getActorPosition(Actor *actor, Common::Point *pt);
+ int updateScene();
+ void updateMouse();
+ void updateActor(uint32 actorIdx);
+ void updateBarriers();
+ void updateBarriers2(); // XXX Alexandre's version
+ void updateAmbientSounds();
+ void updateMusic();
+ void updateAdjustScreen();
+ int drawScene();
+ int drawActors();
+ int drawBarriers();
+ bool isBarrierVisible(BarrierItem *barrier);
+ bool isBarrierOnScreen(BarrierItem *barrier);
+ uint32 getRandomResId(BarrierItem *barrier);
+ void getActorPosition(Actor *actor, Common::Point *pt);
void copyToBackBufferClipped(Graphics::Surface *surface, int x, int y);
void debugScreenScrolling(GraphicFrame *bg);
void debugShowPolygons();
void debugShowBarriers();
- void debugShowActors();
+ void debugShowActors();
void debugShowWalkRegion(PolyDefinitions *poly);
- // TODO: get rid of this
- void OLD_UPDATE();
-
+ // TODO: get rid of this
+ void OLD_UPDATE();
+
}; // end of class Scene
} // end of namespace Asylum
diff --git a/engines/asylum/screen.cpp b/engines/asylum/screen.cpp
index 613e09c3c7..8cb16814b2 100644
--- a/engines/asylum/screen.cpp
+++ b/engines/asylum/screen.cpp
@@ -75,7 +75,7 @@ void Screen::copyRectToScreenWithTransparency(byte *buffer, int pitch, int x, in
for (int curY = 0; curY < height; curY++) {
for (int curX = 0; curX < width; curX++) {
if (buffer[curX + curY * pitch] != 0 && (x + curX + (y + curY) * 640 <= 640*480)) {
- screenBuffer[x + curX + (y + curY) * 640] = buffer[curX + curY * pitch];
+ screenBuffer[x + curX + (y + curY) * 640] = buffer[curX + curY * pitch];
}
}
}
@@ -87,8 +87,9 @@ void Screen::setPalette(byte *rgbPalette) {
byte palette[256 * 4];
byte *p = rgbPalette;
- // skip first color and set it to black always.
- memset(palette, 0, 4); p+=3;
+ // skip first color and set it to black always.
+ memset(palette, 0, 4);
+ p += 3;
for (int i = 1; i < 256; i++) {
palette[i * 4 + 0] = *p++ << 2;
@@ -101,87 +102,87 @@ void Screen::setPalette(byte *rgbPalette) {
}
void Screen::drawWideScreen(int16 barSize) {
- if(barSize > 0) {
-
- _vm->_system->lockScreen()->fillRect(Common::Rect(0, 0, 640, barSize), 0);
- _vm->_system->unlockScreen();
- _vm->_system->lockScreen()->fillRect(Common::Rect(0, 480 - barSize, 640, 480), 0);
- _vm->_system->unlockScreen();
- }
+ if (barSize > 0) {
+
+ _vm->_system->lockScreen()->fillRect(Common::Rect(0, 0, 640, barSize), 0);
+ _vm->_system->unlockScreen();
+ _vm->_system->lockScreen()->fillRect(Common::Rect(0, 480 - barSize, 640, 480), 0);
+ _vm->_system->unlockScreen();
+ }
}
void Screen::clearScreen() {
- _vm->_system->fillScreen(0);
+ _vm->_system->fillScreen(0);
}
void Screen::addGraphicToQueue(uint32 resId, uint32 frameIdx, uint32 x, uint32 y, uint32 flags, uint32 transTableNum, uint32 priority) {
- GraphicQueueItem item;
- item.resId = resId;
- item.x = x;
- item.y = y;
- item.frameIdx = frameIdx;
- item.flags = flags;
- item.transTableNum = transTableNum;
- item.priority = priority;
+ GraphicQueueItem item;
+ item.resId = resId;
+ item.x = x;
+ item.y = y;
+ item.frameIdx = frameIdx;
+ item.flags = flags;
+ item.transTableNum = transTableNum;
+ item.priority = priority;
- _queueItems.push_back(item);
+ _queueItems.push_back(item);
}
void Screen::addCrossFadeGraphicToQueue(uint32 resId, uint32 frameIdx, uint32 x, uint32 y, uint32 redId2, uint32 x2, uint32 y2, uint32 flags, uint32 priority) {
-
+
}
void Screen::addGraphicToQueue(GraphicQueueItem item) {
- _queueItems.push_back(item);
+ _queueItems.push_back(item);
}
void Screen::drawGraphicsInQueue() {
- WorldStats *ws = _vm->scene()->worldstats();
+ WorldStats *ws = _vm->scene()->worldstats();
- // sort by priority first
- graphicsSelectionSort();
+ // sort by priority first
+ graphicsSelectionSort();
- for(uint i = 0; i < _queueItems.size(); i++) {
- GraphicResource *grRes = _vm->scene()->getGraphicResource(_queueItems[i].resId);
- GraphicFrame *fra = grRes->getFrame(_queueItems[i].frameIdx);
- copyRectToScreenWithTransparency((byte *)fra->surface.pixels, fra->surface.w, _queueItems[i].x - ws->targetX, _queueItems[i].y - ws->targetY, fra->surface.w, fra->surface.h);
- delete grRes;
- }
+ for (uint i = 0; i < _queueItems.size(); i++) {
+ GraphicResource *grRes = _vm->scene()->getGraphicResource(_queueItems[i].resId);
+ GraphicFrame *fra = grRes->getFrame(_queueItems[i].frameIdx);
+ copyRectToScreenWithTransparency((byte *)fra->surface.pixels, fra->surface.w, _queueItems[i].x - ws->targetX, _queueItems[i].y - ws->targetY, fra->surface.w, fra->surface.h);
+ delete grRes;
+ }
}
void Screen::clearGraphicsInQueue() {
- _queueItems.clear();
+ _queueItems.clear();
}
void Screen::graphicsSelectionSort() {
- uint minIdx;
+ uint minIdx;
- for (uint i = 0; i < _queueItems.size(); i++) {
- minIdx = i;
+ for (uint i = 0; i < _queueItems.size(); i++) {
+ minIdx = i;
- for (uint j = i + 1; j < _queueItems.size(); j++)
- if (_queueItems[j].priority > _queueItems[i].priority)
- minIdx = j;
+ for (uint j = i + 1; j < _queueItems.size(); j++)
+ if (_queueItems[j].priority > _queueItems[i].priority)
+ minIdx = j;
- if(i != minIdx)
- swapGraphicItem(i, minIdx);
- }
+ if (i != minIdx)
+ swapGraphicItem(i, minIdx);
+ }
}
void Screen::swapGraphicItem(int item1, int item2) {
- GraphicQueueItem temp;
- temp = _queueItems[item1];
- _queueItems[item1] = _queueItems[item2];
- _queueItems[item2] = temp;
+ GraphicQueueItem temp;
+ temp = _queueItems[item1];
+ _queueItems[item1] = _queueItems[item2];
+ _queueItems[item2] = temp;
}
void Screen::deleteGraphicFromQueue(uint32 resId) {
- for(uint i = 0; i < _queueItems.size(); i++) {
- if(_queueItems[i].resId == resId) {
- _queueItems.remove_at(i);
- break;
- }
- }
+ for (uint i = 0; i < _queueItems.size(); i++) {
+ if (_queueItems[i].resId == resId) {
+ _queueItems.remove_at(i);
+ break;
+ }
+ }
}
} // end of namespace Asylum
diff --git a/engines/asylum/screen.h b/engines/asylum/screen.h
index 9d05988466..c69ad5b497 100644
--- a/engines/asylum/screen.h
+++ b/engines/asylum/screen.h
@@ -42,7 +42,7 @@ typedef struct GraphicQueueItem {
uint32 y;
uint32 flags;
uint32 transTableNum;
- uint32 priority;
+ uint32 priority;
} GraphicQueueItem;
@@ -57,24 +57,26 @@ public:
void copyRectToScreen(byte *buffer, int pitch, int x, int y, int width, int height);
void copyRectToScreenWithTransparency(byte *buffer, int pitch, int x, int y, int width, int height);
void setPalette(byte *rgbPalette);
- void setPalette(ResourcePack *resPack, int entry) { setPalette(resPack->getResource(entry)->data + 32); }
- void drawWideScreen(int16 barSize);
- void clearScreen();
+ void setPalette(ResourcePack *resPack, int entry) {
+ setPalette(resPack->getResource(entry)->data + 32);
+ }
+ void drawWideScreen(int16 barSize);
+ void clearScreen();
- void addGraphicToQueue(uint32 resId, uint32 frameIdx, uint32 x, uint32 y, uint32 flags, uint32 transTableNum, uint32 priority);
- void addCrossFadeGraphicToQueue(uint32 resId, uint32 frameIdx, uint32 x, uint32 y, uint32 redId2, uint32 x2, uint32 y2, uint32 flags, uint32 priority);
- void addGraphicToQueue(GraphicQueueItem item);
- void drawGraphicsInQueue();
- void clearGraphicsInQueue();
- void graphicsSelectionSort();
- void swapGraphicItem(int item1, int item2);
- void deleteGraphicFromQueue(uint32 resId);
+ void addGraphicToQueue(uint32 resId, uint32 frameIdx, uint32 x, uint32 y, uint32 flags, uint32 transTableNum, uint32 priority);
+ void addCrossFadeGraphicToQueue(uint32 resId, uint32 frameIdx, uint32 x, uint32 y, uint32 redId2, uint32 x2, uint32 y2, uint32 flags, uint32 priority);
+ void addGraphicToQueue(GraphicQueueItem item);
+ void drawGraphicsInQueue();
+ void clearGraphicsInQueue();
+ void graphicsSelectionSort();
+ void swapGraphicItem(int item1, int item2);
+ void deleteGraphicFromQueue(uint32 resId);
private:
Graphics::Surface _backBuffer;
AsylumEngine *_vm;
- Common::Array<GraphicQueueItem> _queueItems;
+ Common::Array<GraphicQueueItem> _queueItems;
};
} // end of namespace Asylum
diff --git a/engines/asylum/sound.h b/engines/asylum/sound.h
index 1b74768d8e..d84439b290 100644
--- a/engines/asylum/sound.h
+++ b/engines/asylum/sound.h
@@ -112,7 +112,9 @@ public:
* This is useful for checking the active state of a sound
* in a blowuppuzzle
*/
- bool isPlaying() { return _mixer->isSoundHandleActive(_soundHandle); }
+ bool isPlaying() {
+ return _mixer->isSoundHandleActive(_soundHandle);
+ }
private:
Audio::Mixer *_mixer;
diff --git a/engines/asylum/text.cpp b/engines/asylum/text.cpp
index 11c43e52f6..3defc06269 100644
--- a/engines/asylum/text.cpp
+++ b/engines/asylum/text.cpp
@@ -53,10 +53,10 @@ void Text::loadFont(ResourcePack *resPack, uint32 resId) {
if (resId > 0) {
// load font flag data
- _curFontFlags = (_fontResource->getFlags() >> 4) & 0x0F;
+ _curFontFlags = (_fontResource->getFlags() >> 4) & 0x0F;
}
}
-
+
void Text::setTextPos(uint32 x, uint32 y) {
_posX = x;
_posY = y;
@@ -64,7 +64,7 @@ void Text::setTextPos(uint32 x, uint32 y) {
// getTextWidth at address 004357C0
uint32 Text::getTextWidth(char *text) {
- assert (_fontResource);
+ assert(_fontResource);
int width = 0;
uint8 character = *text;
@@ -84,7 +84,7 @@ uint32 Text::getResTextWidth(uint32 resId) {
}
void Text::drawChar(char character) {
- assert (_fontResource);
+ assert(_fontResource);
GraphicFrame *fontLetter = _fontResource->getFrame(character);
_screen->copyRectToScreenWithTransparency((byte *)fontLetter->surface.pixels, fontLetter->surface.w, _posX, _posY + fontLetter->y, fontLetter->surface.w, fontLetter->surface.h);
diff --git a/engines/asylum/video.cpp b/engines/asylum/video.cpp
index 87f02df024..63e9a4739c 100644
--- a/engines/asylum/video.cpp
+++ b/engines/asylum/video.cpp
@@ -27,8 +27,8 @@
namespace Asylum {
-VideoPlayer::VideoPlayer(Graphics::VideoDecoder *decoder) :
- Graphics::VideoPlayer(decoder) {
+VideoPlayer::VideoPlayer(Graphics::VideoDecoder *decoder) :
+ Graphics::VideoPlayer(decoder) {
_text = new VideoText();
ResourcePack *resPack = new ResourcePack(1);
_text->loadFont(resPack, 57); // video font
@@ -60,10 +60,11 @@ bool VideoPlayer::playVideoWithSubtitles(Common::List<Common::Event> &stopEvents
// The negative values aren't used in the code, they just make the table easier to
// understand.
int textRes[49] = { -1, 1088, 1279, 1122, 1286, 1132, 1133, 1134, 1135, 1136, // 0 - 9
- -1, -2, 1140, 1141, -2, -1, 1142, -1, -2, 1155, // 10 - 19
- 1157, 1159, 1162, 1164, -2, 1171, 1177, 1184, 1190, 1201, // 20 - 29
- -2, -2, -2, 1207, 1213, 1217, 1223, 1227, -2, 1228, // 30 - 39
- -2, 1244, 1247, 1250, 1256, 1120, 1127, -1, -1}; // 40 - 48
+ -1, -2, 1140, 1141, -2, -1, 1142, -1, -2, 1155, // 10 - 19
+ 1157, 1159, 1162, 1164, -2, 1171, 1177, 1184, 1190, 1201, // 20 - 29
+ -2, -2, -2, 1207, 1213, 1217, 1223, 1227, -2, 1228, // 30 - 39
+ -2, 1244, 1247, 1250, 1256, 1120, 1127, -1, -1
+ }; // 40 - 48
if (start) {
start += 20; // skip token, newline and "CAPTION = "
@@ -104,13 +105,13 @@ void VideoPlayer::performPostProcessing(byte *screen) {
for (uint32 i = 0; i < _subtitles.size(); i++) {
VideoSubtitle curSubtitle = _subtitles[i];
- if (curFrame >= curSubtitle.frameStart &&
- curFrame <= curSubtitle.frameEnd) {
+ if (curFrame >= curSubtitle.frameStart &&
+ curFrame <= curSubtitle.frameEnd) {
_text->drawMovieSubtitle(screen, curSubtitle.textRes);
break;
}
}
-
+
}
Video::Video(Audio::Mixer *mixer) {
@@ -167,7 +168,7 @@ void VideoText::loadFont(ResourcePack *resPack, uint32 resId) {
if (resId > 0) {
// load font flag data
- _curFontFlags = (_fontResource->getFlags() >> 4) & 0x0F;
+ _curFontFlags = (_fontResource->getFlags() >> 4) & 0x0F;
}
}
@@ -210,7 +211,7 @@ void VideoText::drawMovieSubtitle(byte *screenBuffer, uint32 resId) {
}
uint32 VideoText::getTextWidth(const char *text) {
- assert (_fontResource);
+ assert(_fontResource);
int width = 0;
uint8 character = *text;
@@ -226,7 +227,7 @@ uint32 VideoText::getTextWidth(const char *text) {
}
void VideoText::drawText(byte *screenBuffer, int x, int y, const char *text) {
- assert (_fontResource);
+ assert(_fontResource);
const byte *curChar = (byte *)text;
int curX = x;
diff --git a/engines/asylum/video.h b/engines/asylum/video.h
index 0d16dc838c..44ca0123c5 100644
--- a/engines/asylum/video.h
+++ b/engines/asylum/video.h
@@ -80,7 +80,7 @@ private:
VideoPlayer *_player;
}; // end of class Video
-// The VideoText class has some methods from the Text class,
+// The VideoText class has some methods from the Text class,
// but it differs from the text class: this class draws text
// to a predefined screen buffer, whereas the Text class draws
// text directly to the screen
diff --git a/engines/asylum/worldstats.cpp b/engines/asylum/worldstats.cpp
index bfc1133480..6d09fa2b93 100644
--- a/engines/asylum/worldstats.cpp
+++ b/engines/asylum/worldstats.cpp
@@ -28,7 +28,7 @@
namespace Asylum {
WorldStats::WorldStats(Common::SeekableReadStream *stream, Scene *scene)
- : _scene(scene) {
+ : _scene(scene) {
load(stream);
}
@@ -90,7 +90,7 @@ bool WorldStats::isBarrierVisible(uint32 idx) {
else
isSet = _scene->vm()->isGameFlagSet(flag);
- if(!isSet)
+ if (!isSet)
return false;
}
return true;
@@ -174,7 +174,7 @@ void WorldStats::load(Common::SeekableReadStream *stream) {
stereoReversedFlag = stream->readUint32LE();
- for (int r=0; r < 6; r++) {
+ for (int r = 0; r < 6; r++) {
sceneRects[r].left = stream->readUint32LE() & 0xFFFF;
sceneRects[r].top = stream->readUint32LE() & 0xFFFF;
sceneRects[r].right = stream->readUint32LE() & 0xFFFF;
@@ -195,10 +195,10 @@ void WorldStats::load(Common::SeekableReadStream *stream) {
sceneTitlePalResId = stream->readUint32LE();
actorType = stream->readUint32LE();
- for(int s = 0; s < 50; s++)
+ for (int s = 0; s < 50; s++)
soundResId[s] = stream->readUint32LE();
- for(int s=0; s < 15; s++) {
+ for (int s = 0; s < 15; s++) {
ambientSounds[s].field_0 = stream->readUint32LE();
ambientSounds[s].flags = stream->readUint32LE();
ambientSounds[s].resId = stream->readUint32LE();
@@ -206,7 +206,7 @@ void WorldStats::load(Common::SeekableReadStream *stream) {
ambientSounds[s].field_10 = stream->readUint32LE();
ambientSounds[s].field_14 = stream->readUint32LE();
- for(int i = 0; i < 6; i++)
+ for (int i = 0; i < 6; i++)
ambientSounds[s].flagNum[i] = stream->readUint32LE();
ambientSounds[s].x = stream->readUint32LE();
@@ -294,12 +294,12 @@ void WorldStats::load(Common::SeekableReadStream *stream) {
}
// need to jump all unused barriers data to where actors data start
- stream->seek(0xA6D7A);
+ stream->seek(0xA6D7A);
for (uint32 a = 0; a < numActors; a++) {
int i;
Actor actor;
-
+
actor.x = stream->readUint32LE();
actor.y = stream->readUint32LE();
actor.grResId = stream->readUint32LE();
@@ -365,21 +365,21 @@ void WorldStats::load(Common::SeekableReadStream *stream) {
actor.field_934 = stream->readUint32LE();
actor.field_938 = stream->readUint32LE();
actor.soundResId = stream->readUint32LE();
- actor.field_940 = stream->readUint32LE();
- actor.field_944 = stream->readUint32LE();
- actor.field_948 = stream->readUint32LE();
- actor.field_94C = stream->readUint32LE();
- actor.field_950 = stream->readUint32LE();
- actor.field_954 = stream->readUint32LE();
- actor.field_958 = stream->readUint32LE();
- actor.field_95C = stream->readUint32LE();
- actor.field_960 = stream->readUint32LE();
- actor.field_964 = stream->readUint32LE();
- actor.field_968 = stream->readUint32LE();
- actor.field_96C = stream->readUint32LE();
- actor.field_970 = stream->readUint32LE();
- actor.field_974 = stream->readUint32LE();
- actor.field_978 = stream->readUint32LE();
+ actor.field_940 = stream->readUint32LE();
+ actor.field_944 = stream->readUint32LE();
+ actor.field_948 = stream->readUint32LE();
+ actor.field_94C = stream->readUint32LE();
+ actor.field_950 = stream->readUint32LE();
+ actor.field_954 = stream->readUint32LE();
+ actor.field_958 = stream->readUint32LE();
+ actor.field_95C = stream->readUint32LE();
+ actor.field_960 = stream->readUint32LE();
+ actor.field_964 = stream->readUint32LE();
+ actor.field_968 = stream->readUint32LE();
+ actor.field_96C = stream->readUint32LE();
+ actor.field_970 = stream->readUint32LE();
+ actor.field_974 = stream->readUint32LE();
+ actor.field_978 = stream->readUint32LE();
actor.actionIdx1 = stream->readUint32LE();
// TODO skip field_980 till field_9A0
@@ -406,7 +406,7 @@ void WorldStats::load(Common::SeekableReadStream *stream) {
ActionArea action;
memset(&action, 0, sizeof(ActionArea));
- stream->read(action.name,52);
+ stream->read(action.name, 52);
action.id = stream->readUint32LE();
action.field01 = stream->readUint32LE();
action.field02 = stream->readUint32LE();
diff --git a/engines/asylum/worldstats.h b/engines/asylum/worldstats.h
index 76d2baf866..4630b53922 100644
--- a/engines/asylum/worldstats.h
+++ b/engines/asylum/worldstats.h
@@ -115,7 +115,7 @@ public:
uint32 field_AC;
uint32 field_B0;
uint32 numActors; // Max and all other characters that have
- // own interactions
+ // own interactions
uint32 stereoReversedFlag;
Common::Rect sceneRects[6]; // including scene size rect
uint8 sceneRectIdx;
Commit: d6c4926344aa759c361e6bd7dc7bde6426e0117d
https://github.com/scummvm/scummvm/commit/d6c4926344aa759c361e6bd7dc7bde6426e0117d
Author: Filippos Karapetis (md5 at scummvm.org)
Date: 2021-05-17T15:35:51+02:00
Commit Message:
ASYLUM: Sync with ScummVM revision #44266
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@367 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/asylum.cpp
diff --git a/engines/asylum/asylum.cpp b/engines/asylum/asylum.cpp
index b8a20739ff..1066b190eb 100644
--- a/engines/asylum/asylum.cpp
+++ b/engines/asylum/asylum.cpp
@@ -47,9 +47,9 @@ AsylumEngine::AsylumEngine(OSystem *system, Common::Language language)
Common::addDebugChannel(kDebugLevelSavegame, "Savegame", "Saving & restoring game debugging");
Common::addDebugChannel(kDebugLevelScene, "Scene", "Scene process and draw debugging");
- Common::File::addDefaultDirectory(_gameDataDir.getChild("Data"));
- Common::File::addDefaultDirectory(_gameDataDir.getChild("Vids"));
- Common::File::addDefaultDirectory(_gameDataDir.getChild("Music"));
+ SearchMan.addSubDirectoryMatching(_gameDataDir, "data");
+ SearchMan.addSubDirectoryMatching(_gameDataDir, "vids");
+ SearchMan.addSubDirectoryMatching(_gameDataDir, "music");
g_eventRec.registerRandomSource(_rnd, "asylum");
Commit: 94d40fcac585654f45a826bdfd6d5e4d87977582
https://github.com/scummvm/scummvm/commit/94d40fcac585654f45a826bdfd6d5e4d87977582
Author: Filippos Karapetis (md5 at scummvm.org)
Date: 2021-05-17T15:35:51+02:00
Commit Message:
ASYLUM: Added the missing cursor.* files to the MSVC project file
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@368 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/asylum.vcproj
diff --git a/engines/asylum/asylum.vcproj b/engines/asylum/asylum.vcproj
index 151c15e466..71dcd4f752 100644
--- a/engines/asylum/asylum.vcproj
+++ b/engines/asylum/asylum.vcproj
@@ -28,6 +28,8 @@
<File RelativePath="..\..\engines\asylum\blowuppuzzle.h" />
<File RelativePath="..\..\engines\asylum\console.cpp" />
<File RelativePath="..\..\engines\asylum\console.h" />
+ <File RelativePath="..\..\engines\asylum\cursor.cpp" />
+ <File RelativePath="..\..\engines\asylum\cursor.h" />
<File RelativePath="..\..\engines\asylum\detection.cpp" />
<File RelativePath="..\..\engines\asylum\encounters.cpp" />
<File RelativePath="..\..\engines\asylum\encounters.h" />
Commit: dae5c31a1088979f13368e5fbc5d9627d2a5da1c
https://github.com/scummvm/scummvm/commit/dae5c31a1088979f13368e5fbc5d9627d2a5da1c
Author: Filippos Karapetis (md5 at scummvm.org)
Date: 2021-05-17T15:35:51+02:00
Commit Message:
ASYLUM: Fixed two warnings, for now, and added 2 FIXME's
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@369 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/scene.cpp
diff --git a/engines/asylum/scene.cpp b/engines/asylum/scene.cpp
index 48dc0194e2..68ee95b9ec 100644
--- a/engines/asylum/scene.cpp
+++ b/engines/asylum/scene.cpp
@@ -719,7 +719,9 @@ void Scene::updateAmbientSounds() {
break;
}
} else {
- if (_vm->isGameFlagSet(-gameFlag)) {
+ // FIXME: Applying the minus operator to an unsigned type results
+ // in an unsigned type again. Casting gameFlag to int for now
+ if (_vm->isGameFlagSet(-(int)gameFlag)) {
// XXX Looks like this just jumps back to
// the top of the loop, so not sure if this
// is somehow important
@@ -739,7 +741,9 @@ void Scene::updateAmbientSounds() {
}
if (snd->field_0 == 0) {
- volume = -(snd->field_C ^ 2);
+ // FIXME: Applying the minus operator to an unsigned type results
+ // in an unsigned type again. Casting gameFlag to int32 for now
+ volume = -(int32)(snd->field_C ^ 2);
} else {
; // TODO calculate volume increase
}
Commit: 83b9d232fbe36a5dd69feafcbeba385c1d493425
https://github.com/scummvm/scummvm/commit/83b9d232fbe36a5dd69feafcbeba385c1d493425
Author: Filippos Karapetis (md5 at scummvm.org)
Date: 2021-05-17T15:35:51+02:00
Commit Message:
ASYLUM: Fixed another warning on an odd bit of code, and added a FIXME
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@370 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/actionlist.cpp
diff --git a/engines/asylum/actionlist.cpp b/engines/asylum/actionlist.cpp
index 3e19014550..5b6c5baabf 100644
--- a/engines/asylum/actionlist.cpp
+++ b/engines/asylum/actionlist.cpp
@@ -611,7 +611,11 @@ int kEnableBarriers(ActionCommand *cmd, Scene *scn) {
uint32 v59 = cmd->param2;
if (!scn->actions()->getScript()->counter && scn->getSceneIndex() != 13 && sndIdx != 0) {
- scn->vm()->sound()->playSound(((sndIdx != 0) & 5) + 0x80120001,
+ // FIXME: I really don't understand what (sndIdx != 0) & 5 is supposed to be doing here,
+ // but this is effectively trying to do a boolean AND operation on a boolean variable
+ // which is odd, and wrong. Changing it to (sndIdx & 5), for now
+ //scn->vm()->sound()->playSound(((sndIdx != 0) & 5) + 0x80120001,
+ scn->vm()->sound()->playSound((sndIdx & 5) + 0x80120001,
false, scn->vm()->soundVolume(), 0);
}
Commit: 800f24b81064b022650916458df16f769c0f8c5a
https://github.com/scummvm/scummvm/commit/800f24b81064b022650916458df16f769c0f8c5a
Author: Filippos Karapetis (md5 at scummvm.org)
Date: 2021-05-17T15:35:51+02:00
Commit Message:
ASYLUM: Commented out unused variables
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@371 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/actionlist.cpp
engines/asylum/encounters.cpp
engines/asylum/scene.cpp
diff --git a/engines/asylum/actionlist.cpp b/engines/asylum/actionlist.cpp
index 5b6c5baabf..37015d1b29 100644
--- a/engines/asylum/actionlist.cpp
+++ b/engines/asylum/actionlist.cpp
@@ -182,7 +182,7 @@ void ActionList::setScriptByIndex(uint32 index) {
}
void ActionList::processActionListSub02(ActionDefinitions* script, ActionCommand *command, int a4) {
- int v4 = 0;
+ //int v4 = 0;
int result;
int barrierIdx = 0;
if (a4) {
@@ -555,7 +555,7 @@ int kShowActor(ActionCommand *cmd, Scene *scn) {
}
int kSetActorStats(ActionCommand *cmd, Scene *scn) {
- WorldStats *ws = scn->worldstats();
+ //WorldStats *ws = scn->worldstats();
// TODO
// param1 == actorIndex. Implement when we've got more than one actor
diff --git a/engines/asylum/encounters.cpp b/engines/asylum/encounters.cpp
index b6d68c3883..ed1ce5210d 100644
--- a/engines/asylum/encounters.cpp
+++ b/engines/asylum/encounters.cpp
@@ -76,7 +76,7 @@ void Encounter::run(int encounterIdx, int barrierId1, int barrierId2, int charac
setVariable(1, 0);
setVariable(2, _currentEncounter->value);
- Barrier *b1 = _scene->worldstats()->getBarrierById(barrierId1);
+ //Barrier *b1 = _scene->worldstats()->getBarrierById(barrierId1);
/*
int __cdecl runEncounter(int newMessageHandler, int encounterIndex, int objectId1, int objectId2, int characterIndex)
{
diff --git a/engines/asylum/scene.cpp b/engines/asylum/scene.cpp
index 68ee95b9ec..2f53b23a10 100644
--- a/engines/asylum/scene.cpp
+++ b/engines/asylum/scene.cpp
@@ -541,7 +541,7 @@ void Scene::updateBarriers() {
v2 = _ws->barriers[0].tickCount2;
for (uint32 idx = 0; idx < _ws->numBarriers; idx++) {
- Barrier *b = &_ws->barriers[idx];
+ //Barrier *b = &_ws->barriers[idx];
start = _vm->_system->getMillis();
if (v2 - 32 != 4)
@@ -562,10 +562,10 @@ void Scene::updateBarriers() {
}
void Scene::updateBarriers2() {
- Screen *screen = _vm->screen();
+ //Screen *screen = _vm->screen();
uint barriersCount = _ws->barriers.size();
- int startTickCount = 0;
+ //int startTickCount = 0;
bool canPlaySound = false;
if (barriersCount > 0) {
Commit: b439e330216572c2b3d6797ef2fe6dabda9ff6ad
https://github.com/scummvm/scummvm/commit/b439e330216572c2b3d6797ef2fe6dabda9ff6ad
Author: Alex Bevilacqua (alexbevi at gmail.com)
Date: 2021-05-17T15:35:51+02:00
Commit Message:
ASYLUM: Emulate the title loader. I'm calling this emulation because we're not buffering resources the same way as the original (we don't load all scene assests prior to initialization).
This can be toggled by commenting out the SHOW_SCENE_LOADING macro to faciliate development ;)
I also unified access to the Text* instance by moving it to the engine level and adding a getter.
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@372 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/asylum.cpp
engines/asylum/asylum.h
engines/asylum/menu.cpp
engines/asylum/menu.h
engines/asylum/scene.cpp
engines/asylum/scene.h
diff --git a/engines/asylum/asylum.cpp b/engines/asylum/asylum.cpp
index 1066b190eb..c6593993cc 100644
--- a/engines/asylum/asylum.cpp
+++ b/engines/asylum/asylum.cpp
@@ -70,6 +70,7 @@ AsylumEngine::~AsylumEngine() {
delete _sound;
delete _screen;
delete _encounter;
+ delete _text;
}
Common::Error AsylumEngine::run() {
@@ -88,6 +89,7 @@ Common::Error AsylumEngine::init() {
_sound = new Sound(_mixer);
_video = new Video(_mixer);
_console = new Console(this);
+ _text = new Text(_screen);
_mainMenu = 0;
_scene = 0;
diff --git a/engines/asylum/asylum.h b/engines/asylum/asylum.h
index ebcd283118..70fd0db68a 100644
--- a/engines/asylum/asylum.h
+++ b/engines/asylum/asylum.h
@@ -39,6 +39,8 @@
namespace Asylum {
+#define SHOW_SCENE_LOADING
+
// XXX
// I'm not sure if system endian-ness would have any
// effect byte order of the data files, but I guess
@@ -101,6 +103,9 @@ public:
Scene* scene() {
return _scene;
}
+ Text* text() {
+ return _text;
+ }
int ambientVolume() {
return _ambientVolume;
@@ -130,6 +135,7 @@ private:
Screen *_screen;
Sound *_sound;
Video *_video;
+ Text *_text;
Encounter *_encounter;
int _gameFlags[1512];
diff --git a/engines/asylum/menu.cpp b/engines/asylum/menu.cpp
index 23f0366832..981a45a0ec 100644
--- a/engines/asylum/menu.cpp
+++ b/engines/asylum/menu.cpp
@@ -56,14 +56,12 @@ MainMenu::MainMenu(AsylumEngine *vm): _vm(vm) {
_creditsResource = 0;
_creditsFadeResource = 0;
- _text = new Text(_vm->screen());
- _text->loadFont(_resPack, 16); // 0x80010010, yellow font
+ _vm->text()->loadFont(_resPack, 16); // 0x80010010, yellow font
}
MainMenu::~MainMenu() {
delete _creditsResource;
delete _creditsFadeResource;
- delete _text;
delete _iconResource;
delete _eyeResource;
delete _cursor;
@@ -76,7 +74,7 @@ void MainMenu::openMenu() {
_vm->scene()->deactivate();
// yellow font
- _text->loadFont(_resPack, 0x80010010);
+ _vm->text()->loadFont(_resPack, 0x80010010);
// Load the graphics palette
_vm->screen()->setPalette(_resPack, 17);
@@ -256,7 +254,7 @@ void MainMenu::updateMainMenu() {
}
// yellow font
- _text->loadFont(_resPack, 0x80010010);
+ _vm->text()->loadFont(_resPack, 0x80010010);
// Icon animation
for (uint32 i = 0; i <= 5; i++) {
@@ -286,7 +284,10 @@ void MainMenu::updateMainMenu() {
_curIconFrame = 0;
// Show text
- _text->drawResTextCentered(MenuIconFixedXpos[iconNum], iconFrame->y + 50, _text->getResTextWidth(iconNum + 1309), iconNum + 1309);
+ _vm->text()->drawResTextCentered(MenuIconFixedXpos[iconNum],
+ iconFrame->y + 50,
+ _vm->text()->getResTextWidth(iconNum + 1309),
+ iconNum + 1309);
// Play creepy voice
if (_activeIcon != _previousActiveIcon) {
@@ -350,136 +351,136 @@ void MainMenu::updateSubMenu() {
void MainMenu::updateSubMenuNewGame() {
// yellow font
- _text->loadFont(_resPack, 0x80010010);
+ _vm->text()->loadFont(_resPack, 0x80010010);
// begin new game
- _text->drawResTextCentered(10, 100, 620, 0x80000529);
+ _vm->text()->drawResTextCentered(10, 100, 620, 0x80000529);
// Yes
- if (_cursor->x() < 247 || _cursor->x() > 247 + _text->getResTextWidth(0x8000052A) || _cursor->y() < 273 || _cursor->y() > 273 + 24)
- _text->loadFont(_resPack, 0x80010010); // yellow font
+ if (_cursor->x() < 247 || _cursor->x() > 247 + _vm->text()->getResTextWidth(0x8000052A) || _cursor->y() < 273 || _cursor->y() > 273 + 24)
+ _vm->text()->loadFont(_resPack, 0x80010010); // yellow font
else
- _text->loadFont(_resPack, 0x80010016); // blue font
- _text->setTextPos(247, 273);
- _text->drawResText(0x8000052A);
+ _vm->text()->loadFont(_resPack, 0x80010016); // blue font
+ _vm->text()->setTextPos(247, 273);
+ _vm->text()->drawResText(0x8000052A);
// No
- if (_cursor->x() < 369 || _cursor->x() > 369 + _text->getResTextWidth(0x8000052B) || _cursor->y() < 273 || _cursor->y() > 273 + 24)
- _text->loadFont(_resPack, 0x80010010); // yellow font
+ if (_cursor->x() < 369 || _cursor->x() > 369 + _vm->text()->getResTextWidth(0x8000052B) || _cursor->y() < 273 || _cursor->y() > 273 + 24)
+ _vm->text()->loadFont(_resPack, 0x80010010); // yellow font
else
- _text->loadFont(_resPack, 0x80010016); // blue font
- _text->setTextPos(369, 273);
- _text->drawResText(0x8000052B);
+ _vm->text()->loadFont(_resPack, 0x80010016); // blue font
+ _vm->text()->setTextPos(369, 273);
+ _vm->text()->drawResText(0x8000052B);
// action
if (_leftClick) {
// Yes
- if (_cursor->x() >= 247 && _cursor->x() <= 247 + 24 && _cursor->y() >= 273 && _cursor->y() <= 273 + _text->getResTextWidth(0x8000052A)) {
+ if (_cursor->x() >= 247 && _cursor->x() <= 247 + 24 && _cursor->y() >= 273 && _cursor->y() <= 273 + _vm->text()->getResTextWidth(0x8000052A)) {
_leftClick = false;
// TODO handle new game event
}
// No
- if (_cursor->x() >= 369 && _cursor->x() <= 369 + 24 && _cursor->y() >= 273 && _cursor->y() <= 273 + _text->getResTextWidth(0x8000052B))
+ if (_cursor->x() >= 369 && _cursor->x() <= 369 + 24 && _cursor->y() >= 273 && _cursor->y() <= 273 + _vm->text()->getResTextWidth(0x8000052B))
exitSubMenu();
}
}
void MainMenu::updateSubMenuCinematics() {
int currentCD = 1; // FIXME: dummy value
- _text->drawResTextWithValueCentered(10, 100, 620, 0x80000548, currentCD);
- _text->setTextPos(30, 340);
- _text->drawResText(0x80000549); // Prev Page
+ _vm->text()->drawResTextWithValueCentered(10, 100, 620, 0x80000548, currentCD);
+ _vm->text()->setTextPos(30, 340);
+ _vm->text()->drawResText(0x80000549); // Prev Page
if (_cursor->x() >= 280 && _cursor->x() <= 400 && _cursor->y() >= 340 && _cursor->y() <= 360) {
- _text->loadFont(_resPack, 0x80010016); // blue font
+ _vm->text()->loadFont(_resPack, 0x80010016); // blue font
if (_leftClick)
exitSubMenu();
} else {
- _text->loadFont(_resPack, 0x80010010); // yellow font
+ _vm->text()->loadFont(_resPack, 0x80010010); // yellow font
}
- _text->setTextPos(280, 340);
- _text->drawResText(0x8000054B); // Main Menu
+ _vm->text()->setTextPos(280, 340);
+ _vm->text()->drawResText(0x8000054B); // Main Menu
- _text->loadFont(_resPack, 0x80010010); // yellow font
+ _vm->text()->loadFont(_resPack, 0x80010010); // yellow font
- _text->setTextPos(500, 340);
- _text->drawResText(0x8000054A); // Next Page
+ _vm->text()->setTextPos(500, 340);
+ _vm->text()->drawResText(0x8000054A); // Next Page
}
void MainMenu::updateSubMenuSettings() {
- uint32 sizeMinus = _text->getTextWidth("-");
- uint32 sizePlus = _text->getTextWidth("+");
- uint32 sizeMainMenu = _text->getResTextWidth(0x8000059D);
+ uint32 sizeMinus = _vm->text()->getTextWidth("-");
+ uint32 sizePlus = _vm->text()->getTextWidth("+");
+ uint32 sizeMainMenu = _vm->text()->getResTextWidth(0x8000059D);
// yellow font
- _text->loadFont(_resPack, 0x80010010);
+ _vm->text()->loadFont(_resPack, 0x80010010);
// Settings
- _text->drawResTextCentered(10, 100, 620, 0x80000598);
+ _vm->text()->drawResTextCentered(10, 100, 620, 0x80000598);
// gamma correction
- _text->drawResTextAlignRight(320, 150, 0x80000599);
+ _vm->text()->drawResTextAlignRight(320, 150, 0x80000599);
if (_cursor->x() < 350 || _cursor->x() > sizeMinus + 350 || _cursor->y() < 150 || _cursor->y() > 174)
- _text->loadFont(_resPack, 0x80010010); // yellow font
+ _vm->text()->loadFont(_resPack, 0x80010010); // yellow font
else
- _text->loadFont(_resPack, 0x80010016); // blue font
- _text->setTextPos(350, 150);
- _text->drawText("-");
+ _vm->text()->loadFont(_resPack, 0x80010016); // blue font
+ _vm->text()->setTextPos(350, 150);
+ _vm->text()->drawText("-");
if (_cursor->x() < sizeMinus + 360 || _cursor->x() > sizeMinus + sizePlus + 360 || _cursor->y() < 150 || _cursor->y() > 174)
- _text->loadFont(_resPack, 0x80010010); // yellow font
+ _vm->text()->loadFont(_resPack, 0x80010010); // yellow font
else
- _text->loadFont(_resPack, 0x80010016); // blue font
- _text->setTextPos(sizeMinus + 360, 150);
- _text->drawText("+");
+ _vm->text()->loadFont(_resPack, 0x80010016); // blue font
+ _vm->text()->setTextPos(sizeMinus + 360, 150);
+ _vm->text()->drawText("+");
- _text->setTextPos(sizeMinus + sizePlus + 365, 150);
- _text->loadFont(_resPack, 0x80010010);
+ _vm->text()->setTextPos(sizeMinus + sizePlus + 365, 150);
+ _vm->text()->loadFont(_resPack, 0x80010010);
if (_confGammaLevel) {
for (uint32 i = 0; i < _confGammaLevel; i++) {
- _text->drawText("]");
+ _vm->text()->drawText("]");
}
if (_confGammaLevel == 8)
- _text->drawText("*");
+ _vm->text()->drawText("*");
} else
- _text->drawResText(0x8000059B);
+ _vm->text()->drawResText(0x8000059B);
// performance
- _text->loadFont(_resPack, 0x80010010);
- _text->drawResTextAlignRight(320, 179, 0x8000059A);
+ _vm->text()->loadFont(_resPack, 0x80010010);
+ _vm->text()->drawResTextAlignRight(320, 179, 0x8000059A);
if (_cursor->x() < 350 || _cursor->x() > sizeMinus + 350 || _cursor->y() < 179 || _cursor->y() > 203)
- _text->loadFont(_resPack, 0x80010010); // yellow font
+ _vm->text()->loadFont(_resPack, 0x80010010); // yellow font
else
- _text->loadFont(_resPack, 0x80010016); // blue font
- _text->setTextPos(350, 179);
- _text->drawText("-");
+ _vm->text()->loadFont(_resPack, 0x80010016); // blue font
+ _vm->text()->setTextPos(350, 179);
+ _vm->text()->drawText("-");
if (_cursor->x() < sizeMinus + 360 || _cursor->x() > sizeMinus + sizePlus + 360 || _cursor->y() < 179 || _cursor->y() > 203)
- _text->loadFont(_resPack, 0x80010010); // yellow font
+ _vm->text()->loadFont(_resPack, 0x80010010); // yellow font
else
- _text->loadFont(_resPack, 0x80010016); // blue font
- _text->setTextPos(sizeMinus + 360, 179);
- _text->drawText("+");
+ _vm->text()->loadFont(_resPack, 0x80010016); // blue font
+ _vm->text()->setTextPos(sizeMinus + 360, 179);
+ _vm->text()->drawText("+");
- _text->setTextPos(sizeMinus + sizePlus + 365, 179);
- _text->loadFont(_resPack, 0x80010010);
+ _vm->text()->setTextPos(sizeMinus + sizePlus + 365, 179);
+ _vm->text()->loadFont(_resPack, 0x80010010);
if (_confGameQuality == 5) {
- _text->drawResText(0x8000059C);
+ _vm->text()->drawResText(0x8000059C);
} else {
for (uint32 i = 5; i > _confGameQuality; --i) {
- _text->drawText("]");
+ _vm->text()->drawText("]");
}
if (!_confGameQuality)
- _text->drawText("*");
+ _vm->text()->drawText("*");
}
// back to main menu
if (_cursor->x() < 300 || _cursor->x() > 300 + sizeMainMenu || _cursor->y() < 340 || _cursor->y() > 340 + 24)
- _text->loadFont(_resPack, 0x80010010); // yellow font
+ _vm->text()->loadFont(_resPack, 0x80010010); // yellow font
else
- _text->loadFont(_resPack, 0x80010016); // blue font
- _text->setTextPos(300, 340);
- _text->drawResText(0x8000059D);
+ _vm->text()->loadFont(_resPack, 0x80010016); // blue font
+ _vm->text()->setTextPos(300, 340);
+ _vm->text()->drawResText(0x8000059D);
// action
if (_leftClick) {
@@ -523,31 +524,31 @@ void MainMenu::updateSubMenuSettings() {
void MainMenu::updateSubMenuQuitGame() {
// yellow font
- _text->loadFont(_resPack, 0x80010010);
+ _vm->text()->loadFont(_resPack, 0x80010010);
// begin new game
- _text->drawResTextCentered(10, 100, 620, 0x80000580);
+ _vm->text()->drawResTextCentered(10, 100, 620, 0x80000580);
// Yes
- if (_cursor->x() < 247 || _cursor->x() > 247 + _text->getResTextWidth(0x80000581) || _cursor->y() < 273 || _cursor->y() > 273 + 24)
- _text->loadFont(_resPack, 0x80010010); // yellow font
+ if (_cursor->x() < 247 || _cursor->x() > 247 + _vm->text()->getResTextWidth(0x80000581) || _cursor->y() < 273 || _cursor->y() > 273 + 24)
+ _vm->text()->loadFont(_resPack, 0x80010010); // yellow font
else
- _text->loadFont(_resPack, 0x80010016); // blue font
- _text->setTextPos(247, 273);
- _text->drawResText(0x80000581);
+ _vm->text()->loadFont(_resPack, 0x80010016); // blue font
+ _vm->text()->setTextPos(247, 273);
+ _vm->text()->drawResText(0x80000581);
// No
- if (_cursor->x() < 369 || _cursor->x() > 369 + _text->getResTextWidth(0x80000582) || _cursor->y() < 273 || _cursor->y() > 273 + 24)
- _text->loadFont(_resPack, 0x80010010); // yellow font
+ if (_cursor->x() < 369 || _cursor->x() > 369 + _vm->text()->getResTextWidth(0x80000582) || _cursor->y() < 273 || _cursor->y() > 273 + 24)
+ _vm->text()->loadFont(_resPack, 0x80010010); // yellow font
else
- _text->loadFont(_resPack, 0x80010016); // blue font
- _text->setTextPos(369, 273);
- _text->drawResText(0x80000582);
+ _vm->text()->loadFont(_resPack, 0x80010016); // blue font
+ _vm->text()->setTextPos(369, 273);
+ _vm->text()->drawResText(0x80000582);
// action
if (_leftClick) {
// Yes
- if (_cursor->x() >= 247 && _cursor->x() <= 247 + 24 && _cursor->y() >= 273 && _cursor->y() <= 273 + _text->getResTextWidth(0x80000581)) {
+ if (_cursor->x() >= 247 && _cursor->x() <= 247 + 24 && _cursor->y() >= 273 && _cursor->y() <= 273 + _vm->text()->getResTextWidth(0x80000581)) {
_leftClick = false;
// User clicked on quit, so push a quit event
@@ -556,7 +557,7 @@ void MainMenu::updateSubMenuQuitGame() {
g_system->getEventManager()->pushEvent(event);
}
// No
- if (_cursor->x() >= 369 && _cursor->x() <= 369 + 24 && _cursor->y() >= 273 && _cursor->y() <= 273 + _text->getResTextWidth(0x80000582))
+ if (_cursor->x() >= 369 && _cursor->x() <= 369 + 24 && _cursor->y() >= 273 && _cursor->y() <= 273 + _vm->text()->getResTextWidth(0x80000582))
exitSubMenu();
}
}
@@ -597,8 +598,8 @@ void MainMenu::updateSubMenuShowCredits() {
posY = _creditsTextScroll;
}
- _text->setTextPos(320, step + posY);
- _text->drawResText(resId - 2147482201);
+ _vm->text()->setTextPos(320, step + posY);
+ _vm->text()->drawResText(resId - 2147482201);
posY = _creditsTextScroll;
}
step += 24;
diff --git a/engines/asylum/menu.h b/engines/asylum/menu.h
index 633c139235..e457c27cf4 100644
--- a/engines/asylum/menu.h
+++ b/engines/asylum/menu.h
@@ -108,7 +108,6 @@ private:
GraphicResource *_iconResource;
GraphicResource *_creditsResource;
GraphicResource *_creditsFadeResource;
- Text *_text;
void updateEyesAnimation();
void updateMainMenu();
diff --git a/engines/asylum/scene.cpp b/engines/asylum/scene.cpp
index 2f53b23a10..fb734e2b3b 100644
--- a/engines/asylum/scene.cpp
+++ b/engines/asylum/scene.cpp
@@ -67,8 +67,7 @@ Scene::Scene(uint8 sceneIdx, AsylumEngine *vm): _vm(vm) {
fd->close();
delete fd;
- _text = new Text(_vm->screen());
- _resPack = new ResourcePack(sceneIdx);
+ _resPack = new ResourcePack(sceneIdx);
// FIXME
// Is there EVER more than one actor enabled for a scene? I can't
@@ -79,7 +78,10 @@ Scene::Scene(uint8 sceneIdx, AsylumEngine *vm): _vm(vm) {
_ws->actors[i].setScene(this);
}
- _text->loadFont(_resPack, _ws->commonRes.font1);
+ // TODO
+ // This will have to be re-initialized elsewhere due to
+ // the title screen overwriting the font
+ _vm->text()->loadFont(_resPack, _ws->commonRes.font1);
char musPackFileName[10];
sprintf(musPackFileName, "mus.%03d", sceneIdx);
@@ -144,6 +146,8 @@ Scene::Scene(uint8 sceneIdx, AsylumEngine *vm): _vm(vm) {
_vm->sound()->addToSoundBuffer(_ws->ambientSounds[i].resId);
// TODO: init action list
+
+ _titleLoaded = false;
}
Scene::~Scene() {
@@ -155,8 +159,14 @@ Scene::~Scene() {
delete _bgResource;
delete _musPack;
delete _resPack;
- delete _text;
delete _blowUp;
+
+ // TODO we can probably dispose of the title resource once the
+ // _titleLoaded flag has been set, as opposed to in the
+ // scene destructor
+#ifdef SHOW_SCENE_LOADING
+ delete _title;
+#endif
}
Actor* Scene::getActor() {
@@ -164,26 +174,35 @@ Actor* Scene::getActor() {
}
void Scene::enterScene() {
- _vm->screen()->setPalette(_resPack, _ws->commonRes.palette);
- _background = _bgResource->getFrame(0);
- _vm->screen()->copyToBackBuffer(
- ((byte *)_background->surface.pixels) + _ws->targetY * _background->surface.w + _ws->targetX, _background->surface.w,
- 0, 0, 640, 480);
-
- // FIXME
- // I don't know that this is the right way to initialize the cursor
- // when the scene is started. Check against the original to see
- // when the cursor is initalized, and then how it reacts to the
- // show_cursor opcode
- _cursor->load(_ws->commonRes.curMagnifyingGlass);
- _cursor->set(0);
- _cursor->show();
-
- // Music testing: play the first music track
- _vm->sound()->playMusic(_musPack, 0);
-
+#ifdef SHOW_SCENE_LOADING
+ if (!_titleLoaded) {
+ _title = new SceneTitle(this);
+ // disable input polling
+ _actions->allowInput = false;
+ } else {
+#endif
+ _vm->screen()->setPalette(_resPack, _ws->commonRes.palette);
+ _background = _bgResource->getFrame(0);
+ _vm->screen()->copyToBackBuffer(
+ ((byte *)_background->surface.pixels) + _ws->targetY * _background->surface.w + _ws->targetX, _background->surface.w,
+ 0, 0, 640, 480);
+
+ // FIXME
+ // I don't know that this is the right way to initialize the cursor
+ // when the scene is started. Check against the original to see
+ // when the cursor is initalized, and then how it reacts to the
+ // show_cursor opcode
+ _cursor->load(_ws->commonRes.curMagnifyingGlass);
+ _cursor->set(0);
+ _cursor->show();
+
+ // Music testing: play the first music track
+ _vm->sound()->playMusic(_musPack, 0);
+ _walking = false;
+#ifdef SHOW_SCENE_LOADING
+ }
+#endif
_isActive = true;
- _walking = false;
}
void Scene::setScenePosition(int x, int y) {
@@ -244,6 +263,16 @@ void Scene::handleEvent(Common::Event *event, bool doUpdate) {
// -------------------------------------------
void Scene::update() {
+#ifdef SHOW_SCENE_LOADING
+ if (!_titleLoaded) {
+ _title->update(_vm->_system->getMillis());
+ if (_title->loadingComplete()) {
+ _titleLoaded = true;
+ enterScene();
+ }
+ return;
+ }
+#endif
if (updateScene())
return;
@@ -1265,4 +1294,71 @@ void Scene::debugShowActors() {
}
}
+SceneTitle::SceneTitle(Scene *scene): _scene(scene) {
+ _start = _scene->vm()->_system->getMillis();
+
+ _bg = new GraphicResource(_scene->_resPack, _scene->_ws->sceneTitleGrResId);
+ _scene->vm()->screen()->setPalette(_scene->_resPack, _scene->_ws->sceneTitlePalResId);
+
+ ResourcePack *pack = new ResourcePack(0x12);
+ _progress = new GraphicResource(pack, 0x80120011);
+ _spinnerProgress = 0;
+ _spinnerFrame = 0;
+
+ _scene->vm()->text()->loadFont(pack, 0x80120012);
+
+ delete pack;
+
+ _done = false;
+}
+
+SceneTitle::~SceneTitle() {
+ delete _bg;
+ delete _progress;
+}
+
+void SceneTitle::update(uint32 tick) {
+
+ // XXX This is not from the original. It's just some
+ // arbitrary math to throttle the progress indicator.
+ // In the game, the scene loading progress indicated
+ // how far the engine had progressed in terms of buffering
+ // the various scene resource.
+ // Since we don't actually buffer content like the original,
+ // but load on demand from offset/length within a ResourcePack,
+ // the progress indicator is effectively useless.
+ // It's just in here as "eye candy" :P
+ if ((tick - _start) % 500 > 100)
+ _spinnerProgress += 20;
+
+ GraphicFrame *bgFrame = _bg->getFrame(0);
+
+ _scene->vm()->screen()->copyToBackBuffer(
+ ((byte *)bgFrame->surface.pixels),
+ bgFrame->surface.w,
+ 0, 0, 640, 480);
+
+ uint32 resId = _scene->getSceneIndex() - 4 + 1811;
+ uint32 resWidth = _scene->vm()->text()->getResTextWidth(resId);
+ _scene->vm()->text()->drawResTextCentered(320 - resWidth * 24, 30, resWidth, resId);
+
+ GraphicFrame *frame = _progress->getFrame(_spinnerFrame);
+
+ _scene->vm()->screen()->copyRectToScreenWithTransparency(
+ ((byte*)frame->surface.pixels),
+ frame->surface.w,
+ frame->x - 290 + _spinnerProgress,
+ frame->y,
+ frame->surface.w,
+ frame->surface.h);
+
+ _spinnerFrame++;
+
+ if (_spinnerFrame > _progress->getFrameCount() - 1)
+ _spinnerFrame = 0;
+
+ if (_spinnerProgress > 590)
+ _done = true;
+}
+
} // end of namespace Asylum
diff --git a/engines/asylum/scene.h b/engines/asylum/scene.h
index 68ab799860..b7ed497f1f 100644
--- a/engines/asylum/scene.h
+++ b/engines/asylum/scene.h
@@ -51,6 +51,29 @@ class BlowUpPuzzle;
struct BarrierItem;
class WorldStats;
+class SceneTitle {
+public:
+ SceneTitle(Scene *scene);
+ ~SceneTitle();
+
+ void update(uint32 tick);
+ bool loadingComplete() { return _done; }
+
+private:
+ Scene *_scene;
+ GraphicResource *_bg;
+ GraphicResource *_progress;
+
+
+ uint32 _start;
+ uint32 _ticks;
+ bool _done;
+ uint32 _spinnerFrame;
+ uint32 _spinnerProgress;
+
+}; // end of class SceneTitle
+
+
class Scene {
public:
Scene(uint8 sceneIdx, AsylumEngine *vm);
@@ -114,6 +137,7 @@ private:
WorldStats *_ws;
Polygons *_polygons;
ActionList *_actions;
+ SceneTitle *_title;
Cursor *_cursor;
ResourcePack *_resPack;
@@ -121,10 +145,10 @@ private:
ResourcePack *_musPack;
BlowUpPuzzle *_blowUp;
Common::Event *_ev;
- Text *_text;
GraphicResource *_bgResource;
GraphicFrame *_background;
+ bool _titleLoaded;
bool _walking;
bool _leftClick;
bool _rightButton;
@@ -160,6 +184,8 @@ private:
// TODO: get rid of this
void OLD_UPDATE();
+ friend class SceneTitle;
+
}; // end of class Scene
} // end of namespace Asylum
Commit: 1ea346e0640737a00a19c7dce281aa4f98b2c206
https://github.com/scummvm/scummvm/commit/1ea346e0640737a00a19c7dce281aa4f98b2c206
Author: Alex Bevilacqua (alexbevi at gmail.com)
Date: 2021-05-17T15:35:52+02:00
Commit Message:
ASYLUM: cleanup and comments
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@373 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/actor.cpp
engines/asylum/asylum.cpp
engines/asylum/asylum.h
engines/asylum/menu.h
diff --git a/engines/asylum/actor.cpp b/engines/asylum/actor.cpp
index b3b6cf8001..f778587322 100644
--- a/engines/asylum/actor.cpp
+++ b/engines/asylum/actor.cpp
@@ -55,6 +55,7 @@ void Actor::visible(bool value) {
flags |= 0x01;
else
flags &= 0xFFFFFFFE;
+ // TODO object_sound_sub_414c30
}
void Actor::setDirection(int dir) {
diff --git a/engines/asylum/asylum.cpp b/engines/asylum/asylum.cpp
index c6593993cc..02fdbf83c2 100644
--- a/engines/asylum/asylum.cpp
+++ b/engines/asylum/asylum.cpp
@@ -78,6 +78,7 @@ Common::Error AsylumEngine::run() {
err = init();
if (err != Common::kNoError)
return err;
+
return go();
}
@@ -85,13 +86,13 @@ Common::Error AsylumEngine::run() {
Common::Error AsylumEngine::init() {
initGraphics(640, 480, true);
- _screen = new Screen(this);
- _sound = new Sound(_mixer);
- _video = new Video(_mixer);
- _console = new Console(this);
- _text = new Text(_screen);
- _mainMenu = 0;
- _scene = 0;
+ _screen = new Screen(this);
+ _sound = new Sound(_mixer);
+ _video = new Video(_mixer);
+ _console = new Console(this);
+ _text = new Text(_screen);
+ _mainMenu = 0;
+ _scene = 0;
_introPlaying = false;
@@ -104,16 +105,18 @@ Common::Error AsylumEngine::go() {
// TODO: init unknown game stuffs (address 0040F430)
// TODO: if savegame exists on folder, than start NewGame()
- // Set up the game's main scene
+ // FIXME The scene shouldn't be created here, as we don't technically know
+ // how the scene is starting. This was put in for testing, but will eventually
+ // have to be removed once saveload is implemented
_scene = new Scene(5, this);
- // XXX This is just here for testing purposes. It is also defined
+ // FIXME This is just here for testing purposes. It is also defined
// in the processActionList() method when the necessary action is fired.
// Once the blowup puzzle testing is removed from checkForEvent(), this
// can be removed as well.
_scene->setBlowUpPuzzle(new BlowUpPuzzleVCR(_scene));
- // XXX This can probably also be rolled into the scene constructor.
+ // FIXME This can probably also be rolled into the scene constructor.
// Investigate if this will fuck up the execution sequence though :P
_scene->actions()->setScriptByIndex(_scene->worldstats()->actionListIdx);
diff --git a/engines/asylum/asylum.h b/engines/asylum/asylum.h
index 70fd0db68a..a1d5f7f3c5 100644
--- a/engines/asylum/asylum.h
+++ b/engines/asylum/asylum.h
@@ -39,11 +39,16 @@
namespace Asylum {
+// XXX
+// If defined, this will play the scene title loading
+// progress before the scene is entered. This is
+// just a convenience, as there's no need for the type
+// of pre-loading that was performed in the original
#define SHOW_SCENE_LOADING
// XXX
// I'm not sure if system endian-ness would have any
-// effect byte order of the data files, but I guess
+// effect on the byte order of the data files, but I guess
// it won't hurt to keep this here until we can test
// on a big-endian system
#ifndef SCUMM_BIG_ENDIAN
@@ -62,15 +67,15 @@ class Video;
class Encounter;
enum kDebugLevels {
- kDebugLevelMain = 1 << 0,
+ kDebugLevelMain = 1 << 0,
kDebugLevelResources = 1 << 1,
- kDebugLevelSprites = 1 << 2,
- kDebugLevelInput = 1 << 3,
- kDebugLevelMenu = 1 << 4,
- kDebugLevelScripts = 1 << 5,
- kDebugLevelSound = 1 << 6,
- kDebugLevelSavegame = 1 << 7,
- kDebugLevelScene = 1 << 8
+ kDebugLevelSprites = 1 << 2,
+ kDebugLevelInput = 1 << 3,
+ kDebugLevelMenu = 1 << 4,
+ kDebugLevelScripts = 1 << 5,
+ kDebugLevelSound = 1 << 6,
+ kDebugLevelSavegame = 1 << 7,
+ kDebugLevelScene = 1 << 8
};
class AsylumEngine: public Engine {
@@ -121,7 +126,7 @@ private:
void processDelayedEvents();
void playIntro();
- Common::Language _language;
+ Common::Language _language;
Common::RandomSource _rnd;
int _ambientVolume;
diff --git a/engines/asylum/menu.h b/engines/asylum/menu.h
index e457c27cf4..89bd458e9d 100644
--- a/engines/asylum/menu.h
+++ b/engines/asylum/menu.h
@@ -49,6 +49,7 @@ public:
bool isActive() {
return _active;
}
+
void openMenu();
void closeMenu();
@@ -56,32 +57,32 @@ private:
AsylumEngine *_vm;
enum EyesAnimation {
- kEyesFront = 0,
- kEyesLeft = 1,
- kEyesRight = 2,
- kEyesTop = 3,
- kEyesBottom = 4,
- kEyesTopLeft = 5,
- kEyesTopRight = 6,
- kEyesBottomLeft = 7,
+ kEyesFront = 0,
+ kEyesLeft = 1,
+ kEyesRight = 2,
+ kEyesTop = 3,
+ kEyesBottom = 4,
+ kEyesTopLeft = 5,
+ kEyesTopRight = 6,
+ kEyesBottomLeft = 7,
kEyesBottomRight = 8,
- kEyesCrossed = 9
+ kEyesCrossed = 9
};
enum MenuScreen {
- kNewGame = 0,
- kLoadGame = 1,
- kSaveGame = 2,
- kDeleteGame = 3,
- kViewCinematics = 4,
- kQuitGame = 5,
- kTextOptions = 6,
- kAudioOptions = 7,
- kSettings = 8,
- kKeyboardConfig = 9,
- kShowCredits = 10,
- kReturnToGame = 11,
- kMainMenu = 12
+ kNewGame = 0,
+ kLoadGame = 1,
+ kSaveGame = 2,
+ kDeleteGame = 3,
+ kViewCinematics = 4,
+ kQuitGame = 5,
+ kTextOptions = 6,
+ kAudioOptions = 7,
+ kSettings = 8,
+ kKeyboardConfig = 9,
+ kShowCredits = 10,
+ kReturnToGame = 11,
+ kMainMenu = 12
};
Common::Event *_ev;
@@ -101,8 +102,8 @@ private:
uint32 _confGammaLevel;
uint32 _confGameQuality;
- MenuScreen _activeMenuScreen;
- ResourcePack *_resPack;
+ MenuScreen _activeMenuScreen;
+ ResourcePack *_resPack;
GraphicResource *_bgResource;
GraphicResource *_eyeResource;
GraphicResource *_iconResource;
Commit: e60a1293cf601394762ddf4118a0113000b7f9f4
https://github.com/scummvm/scummvm/commit/e60a1293cf601394762ddf4118a0113000b7f9f4
Author: Alex Bevilacqua (alexbevi at gmail.com)
Date: 2021-05-17T15:35:52+02:00
Commit Message:
ASYLUM: created a configuration management singleton. I know I've made a few of these and then factored them out in the past, but I think common options are a good candidate for this pattern.
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@374 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
A engines/asylum/config.cpp
A engines/asylum/config.h
engines/asylum/actionlist.cpp
engines/asylum/asylum.cpp
engines/asylum/asylum.h
engines/asylum/blowuppuzzle.cpp
engines/asylum/menu.cpp
engines/asylum/module.mk
engines/asylum/scene.cpp
diff --git a/engines/asylum/actionlist.cpp b/engines/asylum/actionlist.cpp
index 37015d1b29..f72a865575 100644
--- a/engines/asylum/actionlist.cpp
+++ b/engines/asylum/actionlist.cpp
@@ -24,6 +24,7 @@
*/
#include "asylum/actionlist.h"
+#include "asylum/config.h"
namespace Asylum {
@@ -615,8 +616,7 @@ int kEnableBarriers(ActionCommand *cmd, Scene *scn) {
// but this is effectively trying to do a boolean AND operation on a boolean variable
// which is odd, and wrong. Changing it to (sndIdx & 5), for now
//scn->vm()->sound()->playSound(((sndIdx != 0) & 5) + 0x80120001,
- scn->vm()->sound()->playSound((sndIdx & 5) + 0x80120001,
- false, scn->vm()->soundVolume(), 0);
+ scn->vm()->sound()->playSound((sndIdx & 5) + 0x80120001, false, Config.sfxVolume, 0);
}
if (scn->actions()->getScript()->counter >= 3 * v59 - 1) {
diff --git a/engines/asylum/asylum.cpp b/engines/asylum/asylum.cpp
index 02fdbf83c2..4a70ac4818 100644
--- a/engines/asylum/asylum.cpp
+++ b/engines/asylum/asylum.cpp
@@ -31,6 +31,7 @@
#include "asylum/asylum.h"
#include "asylum/respack.h"
+#include "asylum/config.h"
namespace Asylum {
@@ -54,10 +55,6 @@ AsylumEngine::AsylumEngine(OSystem *system, Common::Language language)
g_eventRec.registerRandomSource(_rnd, "asylum");
memset(_gameFlags, 0, 1512);
-
- // initialize default configuration
- _ambientVolume = 0;
- _soundVolume = 0;
}
AsylumEngine::~AsylumEngine() {
@@ -169,7 +166,7 @@ void AsylumEngine::playIntro() {
// Play the intro sound sample (the screen is blacked out, you hear
// an alarm sounding and men talking about.
- _sound->playSound(0x8012007, false, _soundVolume, 0);
+ _sound->playSound(0x8012007, false, Config.sfxVolume, 0);
}
void AsylumEngine::checkForEvent(bool doUpdate) { // k_sub_40AE30 (0040AE30)
diff --git a/engines/asylum/asylum.h b/engines/asylum/asylum.h
index a1d5f7f3c5..cb797bb7ec 100644
--- a/engines/asylum/asylum.h
+++ b/engines/asylum/asylum.h
@@ -112,13 +112,6 @@ public:
return _text;
}
- int ambientVolume() {
- return _ambientVolume;
- }
- int soundVolume() {
- return _soundVolume;
- }
-
private:
void checkForEvent(bool doUpdate);
void waitForTimer(int msec_delay);
@@ -129,9 +122,6 @@ private:
Common::Language _language;
Common::RandomSource _rnd;
- int _ambientVolume;
- int _soundVolume;
-
bool _introPlaying;
Console *_console;
diff --git a/engines/asylum/blowuppuzzle.cpp b/engines/asylum/blowuppuzzle.cpp
index 111fb7f862..43d870e443 100644
--- a/engines/asylum/blowuppuzzle.cpp
+++ b/engines/asylum/blowuppuzzle.cpp
@@ -26,6 +26,7 @@
#include "asylum/blowuppuzzle.h"
#include "asylum/respack.h"
#include "asylum/graphics.h"
+#include "asylum/config.h"
namespace Asylum {
@@ -112,8 +113,7 @@ void BlowUpPuzzleVCR::handleEvent(Common::Event *event, bool doUpdate) {
}
void BlowUpPuzzle::playSound(uint resourceId, bool loop) {
- int volume = _scene->vm()->soundVolume();
- _scene->vm()->sound()->playSound(_scene->getResourcePack(), resourceId, volume, loop, 0, true);
+ _scene->vm()->sound()->playSound(_scene->getResourcePack(), resourceId, Config.sfxVolume, loop, 0, true);
}
int BlowUpPuzzleVCR::inPolyRegion(int x, int y, int polyIdx) {
diff --git a/engines/asylum/config.cpp b/engines/asylum/config.cpp
new file mode 100644
index 0000000000..f927c2a61a
--- /dev/null
+++ b/engines/asylum/config.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.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#include "asylum/config.h"
+
+namespace Asylum {
+
+DECLARE_SINGLETON(Asylum::ConfigurationManager);
+
+static bool g_config_initialized = false;
+
+ConfigurationManager::ConfigurationManager() {
+
+ if (!g_config_initialized) {
+ g_config_initialized = true;
+ }
+
+ // if the values don't currently exist within the
+ // configuration file, load the defaults
+
+ ambientVolume = 0;
+ movieVolume = 0;
+ musicVolume = 0;
+ sfxVolume = 0;
+
+}
+
+ConfigurationManager::~ConfigurationManager() {
+ // TODO Auto-generated destructor stub
+}
+
+} // end of namespace Asylum
diff --git a/engines/asylum/config.h b/engines/asylum/config.h
new file mode 100644
index 0000000000..f8cb9e6974
--- /dev/null
+++ b/engines/asylum/config.h
@@ -0,0 +1,96 @@
+/* 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.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#ifndef ASYLUM_CONFIGURATIONMANAGER_H_
+#define ASYLUM_CONFIGURATIONMANAGER_H_
+
+#include "common/array.h"
+#include "common/singleton.h"
+
+namespace Asylum {
+
+/**
+ * The ConfigurationManager is where the common configuration options used
+ * by the engine are bound.
+ *
+ * These options can be set through the main menu
+ */
+class ConfigurationManager: public Common::Singleton<ConfigurationManager> {
+public:
+
+ bool showMovieSubtitles;
+ Common::Array<int> movieSubtitles;
+ bool showEncounterSubtitles;
+ Common::Array<int> encounterSubtitles;
+ int musicVolume;
+ int ambientVolume;
+ int sfxVolume;
+ int voiceVolume;
+ int movieVolume;
+ bool musicStatus; // On or Off
+ bool reverseStereo;
+ int gammaLevel;
+
+ /**
+ * XXX The game's performance settings seem to only affect
+ * the sound quality.
+ *
+ * (performance > 0) ? 22050hz/16bit : 11025hz/8bit
+ */
+ int performance;
+ int versionKey;
+ int quickSaveKey;
+ int quickLoadKey;
+ int switchToSaraKey;
+ int switchToGrimwallKey;
+ int switchToOlmecKey;
+
+ /**
+ * Load a value from the configuration file
+ */
+ bool readValue(int target);
+
+ /**
+ * Save a value to the configuration file
+ *
+ * XXX Some values (like viewed cinematics) used to be written to
+ * the Windows registry, so we're going to handle this from the
+ * same file as other settings
+ */
+ bool writeValue(int target);
+
+private:
+ friend class Common::Singleton<SingletonBaseType>;
+
+ ConfigurationManager();
+ virtual ~ConfigurationManager();
+
+}; // end of class ConfigurationManager
+
+#define Config (::Asylum::ConfigurationManager::instance())
+
+} // end of namespace Asylum
+
+#endif
diff --git a/engines/asylum/menu.cpp b/engines/asylum/menu.cpp
index 981a45a0ec..02539924c0 100644
--- a/engines/asylum/menu.cpp
+++ b/engines/asylum/menu.cpp
@@ -26,6 +26,7 @@
#include "asylum/menu.h"
#include "asylum/respack.h"
#include "asylum/graphics.h"
+#include "asylum/config.h"
namespace Asylum {
@@ -291,7 +292,7 @@ void MainMenu::updateMainMenu() {
// Play creepy voice
if (_activeIcon != _previousActiveIcon) {
- _vm->sound()->playSound(_resPack, iconNum + 44, _vm->soundVolume());
+ _vm->sound()->playSound(_resPack, iconNum + 44, Config.sfxVolume);
_previousActiveIcon = _activeIcon;
}
diff --git a/engines/asylum/module.mk b/engines/asylum/module.mk
index bd8733e3e7..11408d6391 100644
--- a/engines/asylum/module.mk
+++ b/engines/asylum/module.mk
@@ -19,7 +19,8 @@ MODULE_OBJS := \
sound.o \
text.o \
video.o \
- worldstats.o
+ worldstats.o \
+ config.o
# This module can be built as a plugin
ifeq ($(ENABLE_ASYLUM), DYNAMIC_PLUGIN)
diff --git a/engines/asylum/scene.cpp b/engines/asylum/scene.cpp
index fb734e2b3b..9ea28b8d7d 100644
--- a/engines/asylum/scene.cpp
+++ b/engines/asylum/scene.cpp
@@ -25,6 +25,7 @@
#include "asylum/scene.h"
#include "asylum/actor.h"
+#include "asylum/config.h"
namespace Asylum {
@@ -780,7 +781,7 @@ void Scene::updateAmbientSounds() {
if (LOBYTE(snd->flags) & 2) {
if (rand() % 10000 < 10) {
if (snd->field_0) {
- _vm->sound()->playSound(_resPack, snd->resId, false, _vm->ambientVolume() + volume, panning);
+ _vm->sound()->playSound(_resPack, snd->resId, false, Config.sfxVolume + volume, panning);
} else {
v15 = rand() % 500;
v11 = v15 * ((((rand() % 100 >= 50) - 1) & 2) - 1) + volume;
Commit: f26c50461b10a5f2177b36e28a61d00b5108b968
https://github.com/scummvm/scummvm/commit/f26c50461b10a5f2177b36e28a61d00b5108b968
Author: Filippos Karapetis (md5 at scummvm.org)
Date: 2021-05-17T15:35:52+02:00
Commit Message:
ASYLUM: Updated the MSVC project file, and fixed compilation
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@375 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/asylum.vcproj
engines/asylum/config.cpp
diff --git a/engines/asylum/asylum.vcproj b/engines/asylum/asylum.vcproj
index 71dcd4f752..14ae01d2a5 100644
--- a/engines/asylum/asylum.vcproj
+++ b/engines/asylum/asylum.vcproj
@@ -26,6 +26,8 @@
<File RelativePath="..\..\engines\asylum\barrier.h" />
<File RelativePath="..\..\engines\asylum\blowuppuzzle.cpp" />
<File RelativePath="..\..\engines\asylum\blowuppuzzle.h" />
+ <File RelativePath="..\..\engines\asylum\config.cpp" />
+ <File RelativePath="..\..\engines\asylum\config.h" />
<File RelativePath="..\..\engines\asylum\console.cpp" />
<File RelativePath="..\..\engines\asylum\console.h" />
<File RelativePath="..\..\engines\asylum\cursor.cpp" />
diff --git a/engines/asylum/config.cpp b/engines/asylum/config.cpp
index f927c2a61a..638659fea9 100644
--- a/engines/asylum/config.cpp
+++ b/engines/asylum/config.cpp
@@ -25,10 +25,10 @@
#include "asylum/config.h"
-namespace Asylum {
-
DECLARE_SINGLETON(Asylum::ConfigurationManager);
+namespace Asylum {
+
static bool g_config_initialized = false;
ConfigurationManager::ConfigurationManager() {
Commit: ab96b43829cdb1d07294acde8e078567c5f2bbfc
https://github.com/scummvm/scummvm/commit/ab96b43829cdb1d07294acde8e078567c5f2bbfc
Author: Alex Bevilacqua (alexbevi at gmail.com)
Date: 2021-05-17T15:35:52+02:00
Commit Message:
ASYLUM: Alter detection routine slightly to check if the version of Sanitarium that is found is one that has had the Level 2 lockout patch applied
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@376 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/detection.cpp
diff --git a/engines/asylum/detection.cpp b/engines/asylum/detection.cpp
index b90af01455..ce1e090a1b 100644
--- a/engines/asylum/detection.cpp
+++ b/engines/asylum/detection.cpp
@@ -42,8 +42,27 @@ namespace Asylum {
static const ADGameDescription gameDescriptions[] = {
{
"asylum",
- 0,
- AD_ENTRY1s("SNTRM.DAT", "280b4a72f70f3073e9dbc9a9cfa25518", 8930),
+ "Unpatched",
+ {
+ {"SNTRM.DAT", 0, "7cfcc457c1f579fbf9878ac175d29374", 8930},
+ {"RES.000", 0, "4d13f1412f9e7dd3eaf0a58f0e00e662", 272057},
+ {"SCN.006", 0, "71a5f49cbda597a11e877589075e27b5", 2918330},
+ {0,0,0,0}
+ },
+ Common::EN_ANY,
+ Common::kPlatformPC,
+ ADGF_NO_FLAGS,
+ Common::GUIO_NONE
+ },
+ {
+ "asylum",
+ "Patched", // Level 2 Lockout Bug patch was applied
+ {
+ {"SNTRM.DAT", 0, "7cfcc457c1f579fbf9878ac175d29374", 8930},
+ {"RES.000", 0, "4d13f1412f9e7dd3eaf0a58f0e00e662", 272057},
+ {"SCN.006", 0, "3a5b54da08198012dc0614114782d5fb", 2918330},
+ {0,0,0,0}
+ },
Common::EN_ANY,
Common::kPlatformPC,
ADGF_NO_FLAGS,
@@ -62,7 +81,7 @@ static const ADFileBasedFallback fileBasedFallback[] = {
static const ADParams detectionParams = {
(const byte *)Asylum::gameDescriptions,
sizeof(ADGameDescription),
- 4096, // number of md5 bytes
+ 0, // number of md5 bytes
asylumGames,
0, // no obsolete targets data
"asylum",
Commit: fc33509d62e4194bfbc9847610480ff5650a769e
https://github.com/scummvm/scummvm/commit/fc33509d62e4194bfbc9847610480ff5650a769e
Author: Joseph Davies (deledrius at gmail.com)
Date: 2021-05-17T15:35:52+02:00
Commit Message:
ASYLUM: Some fixes for ambiguous data endianness causing segfaults on big-endian architectures.
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@377 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/actor.cpp
engines/asylum/graphics.cpp
diff --git a/engines/asylum/actor.cpp b/engines/asylum/actor.cpp
index f778587322..b1162ccc53 100644
--- a/engines/asylum/actor.cpp
+++ b/engines/asylum/actor.cpp
@@ -67,7 +67,7 @@ void Actor::setRawResources(uint8 *data) {
byte *dataPtr = data;
for (uint32 i = 0; i < 60; i++) {
- _resources[i] = READ_UINT32(dataPtr);
+ _resources[i] = READ_LE_UINT32(dataPtr);
dataPtr += 4;
}
}
diff --git a/engines/asylum/graphics.cpp b/engines/asylum/graphics.cpp
index 9e03332479..8ec95a2d05 100644
--- a/engines/asylum/graphics.cpp
+++ b/engines/asylum/graphics.cpp
@@ -51,17 +51,17 @@ void GraphicResource::init(byte *data, uint32 size) {
dataPtr += 4; // tag value
- _flags = READ_UINT32(dataPtr);
+ _flags = READ_LE_UINT32(dataPtr);
dataPtr += 4;
- contentOffset = READ_UINT32(dataPtr);
+ contentOffset = READ_LE_UINT32(dataPtr);
dataPtr += 4;
dataPtr += 4; // unknown
dataPtr += 4; // unknown
dataPtr += 4; // unknown
- frameCount = READ_UINT16(dataPtr);
+ frameCount = READ_LE_UINT16(dataPtr);
dataPtr += 2;
dataPtr += 2; // max width
@@ -69,7 +69,7 @@ void GraphicResource::init(byte *data, uint32 size) {
_frames.resize(frameCount);
// Read frame offsets
- uint32 prevOffset = READ_UINT32(dataPtr) + contentOffset;
+ uint32 prevOffset = READ_LE_UINT32(dataPtr) + contentOffset;
dataPtr += 4;
uint32 nextOffset = 0;
@@ -78,7 +78,7 @@ void GraphicResource::init(byte *data, uint32 size) {
frame.offset = prevOffset;
// Read the offset of the next entry to determine the size of this one
- nextOffset = (i < frameCount - 1) ? READ_UINT32(dataPtr) + contentOffset : size;
+ nextOffset = (i < frameCount - 1) ? READ_LE_UINT32(dataPtr) + contentOffset : size;
dataPtr += 4; // offset
frame.size = (nextOffset > 0) ? nextOffset - prevOffset : size - prevOffset;
@@ -97,14 +97,14 @@ void GraphicResource::init(byte *data, uint32 size) {
dataPtr += 4; // size
dataPtr += 4; // flag
- _frames[i].x = READ_UINT16(dataPtr);
+ _frames[i].x = READ_LE_UINT16(dataPtr);
dataPtr += 2;
- _frames[i].y = READ_UINT16(dataPtr);
+ _frames[i].y = READ_LE_UINT16(dataPtr);
dataPtr += 2;
- uint16 height = READ_UINT16(dataPtr);
+ uint16 height = READ_LE_UINT16(dataPtr);
dataPtr += 2;
- uint16 width = READ_UINT16(dataPtr);
+ uint16 width = READ_LE_UINT16(dataPtr);
dataPtr += 2;
_frames[i].surface.create(width, height, 1);
Commit: 005cfdcf5a63a9a77c3745e564eacfb7da95ee7a
https://github.com/scummvm/scummvm/commit/005cfdcf5a63a9a77c3745e564eacfb7da95ee7a
Author: Alex Bevilacqua (alexbevi at gmail.com)
Date: 2021-05-17T15:35:52+02:00
Commit Message:
ASYLUM: * changed some variable casting from uint32 to int
* force kDebugFlagScripts to be on by default (for now)
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@378 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/actionlist.cpp
engines/asylum/actionlist.h
engines/asylum/actor.cpp
engines/asylum/asylum.cpp
engines/asylum/asylum.h
engines/asylum/scene.cpp
engines/asylum/scene.h
engines/asylum/sound.h
diff --git a/engines/asylum/actionlist.cpp b/engines/asylum/actionlist.cpp
index f72a865575..c4be079b7b 100644
--- a/engines/asylum/actionlist.cpp
+++ b/engines/asylum/actionlist.cpp
@@ -53,6 +53,9 @@ struct AsylumFunction {
#define MAPFUNC(name, func) {name, func}
+// TODO I don't know that we're clearing this out
+// when the engine is disposed. Need to look into this
+// as a possible memory leak.
static const AsylumFunction function_map[] = {
/*0x00*/ MAPFUNC("kReturn0", kReturn0),
/*0x01*/ MAPFUNC("kSetGameFlag", kSetGameFlag),
@@ -587,6 +590,7 @@ int kDisableActor(ActionCommand *cmd, Scene *scn) {
actorIndex = cmd->param1;
// TODO Finish implementing this function
+
//scn->getActor()->update_4072A0(actorIndex);
return -1;
diff --git a/engines/asylum/actionlist.h b/engines/asylum/actionlist.h
index 822487335b..d5f771f0a8 100644
--- a/engines/asylum/actionlist.h
+++ b/engines/asylum/actionlist.h
@@ -40,15 +40,15 @@ class Scene;
typedef struct ActionCommand {
uint32 numLines; // Only set on the first line of each script
uint32 opcode;
- uint32 param1;
- uint32 param2;
- uint32 param3;
- uint32 param4;
- uint32 param5;
- uint32 param6;
- uint32 param7;
- uint32 param8;
- uint32 param9;
+ int param1;
+ int param2;
+ int param3;
+ int param4;
+ int param5;
+ int param6;
+ int param7;
+ int param8;
+ int param9;
} ActionCommand;
diff --git a/engines/asylum/actor.cpp b/engines/asylum/actor.cpp
index b1162ccc53..a763cb0f7a 100644
--- a/engines/asylum/actor.cpp
+++ b/engines/asylum/actor.cpp
@@ -280,7 +280,6 @@ void Actor::update_4072A0(int param) {
int newDir = 0;
switch (param) {
-
case 4:
case 6:
case 14:
@@ -298,7 +297,9 @@ void Actor::update_4072A0(int param) {
setAction(newDir + 5);
break;
-
+ default:
+ warning ("[update_4072A0] unimplemented case: %d", param);
+ break;
}
this->grResId = newGrId;
@@ -308,6 +309,11 @@ void Actor::update_4072A0(int param) {
this->frameNum = 0;
delete gra;
+ // TODO
+ // The update type can be different than the provided parameter
+ // depending on the switch case. Change this once a case handler
+ // is implemented that requires this ... namely:
+ // if (!v34) v3 = 4; // so updateType = 4
this->updateType = param;
}
diff --git a/engines/asylum/asylum.cpp b/engines/asylum/asylum.cpp
index 4a70ac4818..84649617f5 100644
--- a/engines/asylum/asylum.cpp
+++ b/engines/asylum/asylum.cpp
@@ -52,6 +52,8 @@ AsylumEngine::AsylumEngine(OSystem *system, Common::Language language)
SearchMan.addSubDirectoryMatching(_gameDataDir, "vids");
SearchMan.addSubDirectoryMatching(_gameDataDir, "music");
+ Common::enableDebugChannel("Scripts");
+
g_eventRec.registerRandomSource(_rnd, "asylum");
memset(_gameFlags, 0, 1512);
diff --git a/engines/asylum/asylum.h b/engines/asylum/asylum.h
index cb797bb7ec..962d4cfcd2 100644
--- a/engines/asylum/asylum.h
+++ b/engines/asylum/asylum.h
@@ -44,7 +44,7 @@ namespace Asylum {
// progress before the scene is entered. This is
// just a convenience, as there's no need for the type
// of pre-loading that was performed in the original
-#define SHOW_SCENE_LOADING
+//#define SHOW_SCENE_LOADING
// XXX
// I'm not sure if system endian-ness would have any
diff --git a/engines/asylum/scene.cpp b/engines/asylum/scene.cpp
index 9ea28b8d7d..da8079819e 100644
--- a/engines/asylum/scene.cpp
+++ b/engines/asylum/scene.cpp
@@ -85,7 +85,7 @@ Scene::Scene(uint8 sceneIdx, AsylumEngine *vm): _vm(vm) {
_vm->text()->loadFont(_resPack, _ws->commonRes.font1);
char musPackFileName[10];
- sprintf(musPackFileName, "mus.%03d", sceneIdx);
+ sprintf(musPackFileName, MUSIC_FILE_MASK, sceneIdx);
_musPack = new ResourcePack(musPackFileName);
_bgResource = new GraphicResource(_resPack, _ws->commonRes.backgroundImage);
@@ -299,7 +299,7 @@ int Scene::updateScene() {
// Barriers
startTick = _vm->_system->getMillis();
- updateBarriers2();
+ updateBarriers();
debugC(kDebugLevelScene, "UpdateBarriers Time: %d", _vm->_system->getMillis() - startTick);
// Ambient Sounds
@@ -560,38 +560,7 @@ void Scene::updateActor(uint32 actorIdx) {
}
}
-// XXX WIP
void Scene::updateBarriers() {
- int v1, v0, v32, v33, v34, tickVal, tickVal05, tickVal06;
- v1 = v0 = v32 = v33 = v34 = tickVal = tickVal05 = tickVal06 = 0;
-
- uint32 start, v2, v31;
- bool done = false;
- //if (_ws->barriers.size() > 0);
-
- v2 = _ws->barriers[0].tickCount2;
- for (uint32 idx = 0; idx < _ws->numBarriers; idx++) {
- //Barrier *b = &_ws->barriers[idx];
- start = _vm->_system->getMillis();
-
- if (v2 - 32 != 4)
- done = true;
-
- if (!done && !_ws->checkBarrierFlagsCondition(idx)) {
- v31 = _vm->_system->getMillis();
- }
-
- /*
- * TODO
- */
-
- v2 += 426;
- v1 = 0;
- done = false;
- }
-}
-
-void Scene::updateBarriers2() {
//Screen *screen = _vm->screen();
uint barriersCount = _ws->barriers.size();
@@ -732,6 +701,7 @@ void Scene::updateBarriers2() {
}
void Scene::updateAmbientSounds() {
+ // TODO
// if (cfgGameQualityValue > 3)
int v2 = 1;
@@ -742,15 +712,13 @@ void Scene::updateAmbientSounds() {
for (uint32 i = 0; i < _ws->numAmbientSound; i++) {
AmbientSoundItem *snd = &_ws->ambientSounds[i];
for (uint32 f = 0; f < 6; f++) {
- uint gameFlag = snd->flagNum[f];
+ int gameFlag = snd->flagNum[f];
if (gameFlag >= 0) {
if (_vm->isGameFlagNotSet(gameFlag)) {
v2 = 0;
break;
}
} else {
- // FIXME: Applying the minus operator to an unsigned type results
- // in an unsigned type again. Casting gameFlag to int for now
if (_vm->isGameFlagSet(-(int)gameFlag)) {
// XXX Looks like this just jumps back to
// the top of the loop, so not sure if this
diff --git a/engines/asylum/scene.h b/engines/asylum/scene.h
index b7ed497f1f..821a7d31b5 100644
--- a/engines/asylum/scene.h
+++ b/engines/asylum/scene.h
@@ -38,6 +38,7 @@
#include "asylum/cursor.h"
#define SCENE_FILE_MASK "scn.%03d"
+#define MUSIC_FILE_MASK "mus.%03d"
namespace Asylum {
@@ -161,7 +162,6 @@ private:
void updateMouse();
void updateActor(uint32 actorIdx);
void updateBarriers();
- void updateBarriers2(); // XXX Alexandre's version
void updateAmbientSounds();
void updateMusic();
void updateAdjustScreen();
diff --git a/engines/asylum/sound.h b/engines/asylum/sound.h
index d84439b290..4281252f92 100644
--- a/engines/asylum/sound.h
+++ b/engines/asylum/sound.h
@@ -57,7 +57,7 @@ typedef struct AmbientSoundItem {
uint32 field_C;
uint32 field_10;
uint32 field_14;
- uint32 flagNum[6];
+ int flagNum[6];
uint32 x;
uint32 y;
Commit: 99aa2737b3f9efa3bd07681d2ee416ebec45a6b2
https://github.com/scummvm/scummvm/commit/99aa2737b3f9efa3bd07681d2ee416ebec45a6b2
Author: Alex Bevilacqua (alexbevi at gmail.com)
Date: 2021-05-17T15:35:53+02:00
Commit Message:
ASYLUM: change command reads from Uint32 to Sint32
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@379 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/actionlist.cpp
diff --git a/engines/asylum/actionlist.cpp b/engines/asylum/actionlist.cpp
index c4be079b7b..7e69d94128 100644
--- a/engines/asylum/actionlist.cpp
+++ b/engines/asylum/actionlist.cpp
@@ -330,16 +330,16 @@ void ActionList::load(Common::SeekableReadStream *stream) {
memset(&command, 0, sizeof(ActionCommand));
command.numLines = stream->readUint32LE();
- command.opcode = stream->readUint32LE(); // command type
- command.param1 = stream->readUint32LE(); // command parameters
- command.param2 = stream->readUint32LE();
- command.param3 = stream->readUint32LE();
- command.param4 = stream->readUint32LE();
- command.param5 = stream->readUint32LE();
- command.param6 = stream->readUint32LE();
- command.param7 = stream->readUint32LE();
- command.param8 = stream->readUint32LE();
- command.param9 = stream->readUint32LE();
+ command.opcode = stream->readUint32LE();
+ command.param1 = stream->readSint32LE();
+ command.param2 = stream->readSint32LE();
+ command.param3 = stream->readSint32LE();
+ command.param4 = stream->readSint32LE();
+ command.param5 = stream->readSint32LE();
+ command.param6 = stream->readSint32LE();
+ command.param7 = stream->readSint32LE();
+ command.param8 = stream->readSint32LE();
+ command.param9 = stream->readSint32LE();
action.commands[c] = command;
}
Commit: b70ec657599a0efbf45a7d0e3e362efb1a6c432f
https://github.com/scummvm/scummvm/commit/b70ec657599a0efbf45a7d0e3e362efb1a6c432f
Author: Alex Bevilacqua (alexbevi at gmail.com)
Date: 2021-05-17T15:35:53+02:00
Commit Message:
ASYLUM: Commented out OLD_UPDATE on the scene for now, as I'm going to try to start implementing this properly (so things may be broken for a bit).
Added a changeOrientation() method to the actor class. Removed the old setDirection() method, as this was not properly done from the original disassembly.
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@380 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/actionlist.cpp
engines/asylum/actor.cpp
engines/asylum/actor.h
engines/asylum/config.h
engines/asylum/scene.cpp
diff --git a/engines/asylum/actionlist.cpp b/engines/asylum/actionlist.cpp
index 7e69d94128..5105072e86 100644
--- a/engines/asylum/actionlist.cpp
+++ b/engines/asylum/actionlist.cpp
@@ -582,16 +582,15 @@ int kSetSceneMotionStat(ActionCommand *cmd, Scene *scn) {
}
int kDisableActor(ActionCommand *cmd, Scene *scn) {
- int actorIndex = 0;
+ int actorIndex = cmd->param1;
+ Actor* actor;
- if (cmd->param1 == -1)
- ;//actorIndex = scn->getWorldStats()->playerActor;
+ if (actorIndex == -1)
+ actor = scn->getActor();
else
- actorIndex = cmd->param1;
-
- // TODO Finish implementing this function
+ actor = &scn->worldstats()->actors[actorIndex];
- //scn->getActor()->update_4072A0(actorIndex);
+ actor->changeOrientation(5);
return -1;
}
diff --git a/engines/asylum/actor.cpp b/engines/asylum/actor.cpp
index a763cb0f7a..1cdc1c4252 100644
--- a/engines/asylum/actor.cpp
+++ b/engines/asylum/actor.cpp
@@ -27,6 +27,7 @@
#include "asylum/actor.h"
#include "asylum/screen.h"
+#include "asylum/config.h"
namespace Asylum {
@@ -58,10 +59,12 @@ void Actor::visible(bool value) {
// TODO object_sound_sub_414c30
}
+/*
void Actor::setDirection(int dir) {
direction = dir;
setActionByIndex(dir);
}
+*/
void Actor::setRawResources(uint8 *data) {
byte *dataPtr = data;
@@ -275,38 +278,43 @@ void Actor::walkTo(uint32 curX, uint32 curY) {
drawActor();
}
-void Actor::update_4072A0(int param) {
+
+void Actor::changeOrientation(int param) {
int newGrId = 0;
- int newDir = 0;
+ int newDir = 0;
switch (param) {
case 4:
case 6:
case 14:
- if (this->direction > 4)
- newDir = 8 - this->direction;
+ if (direction > 4)
+ newDir = 8 - direction;
else
- newDir = this->direction;
- newGrId = this->grResTable[newDir + 5];
+ newDir = direction;
+ newGrId = grResTable[newDir + 5];
break;
case 5:
- newDir = this->direction;
+ newDir = direction;
if (newDir > 4)
- this->direction = 8 - newDir;
+ direction = 8 - newDir;
+
+ newGrId = grResTable[newDir + 5];
- setAction(newDir + 5);
+ // XXX This has something to do with screen updating
+ Config.word_446EE4 = -1;
break;
+
default:
warning ("[update_4072A0] unimplemented case: %d", param);
break;
}
- this->grResId = newGrId;
+ grResId = newGrId;
- GraphicResource *gra = new GraphicResource(_resPack, this->grResId);
- this->frameCount = gra->getFrameCount();
- this->frameNum = 0;
+ GraphicResource *gra = new GraphicResource(_resPack, grResId);
+ frameCount = gra->getFrameCount();
+ frameNum = 0;
delete gra;
// TODO
@@ -314,7 +322,7 @@ void Actor::update_4072A0(int param) {
// depending on the switch case. Change this once a case handler
// is implemented that requires this ... namely:
// if (!v34) v3 = 4; // so updateType = 4
- this->updateType = param;
+ updateType = param;
}
void Actor::setPosition_40A260(uint32 newX, uint32 newY, int newDirection, int frame) {
@@ -384,7 +392,8 @@ void Actor::faceTarget(int targetId, int targetType) {
printf("Angle calculated as %d\n", newAngle);
- setDirection(newAngle);
+ // TODO set player direction
+ //setDirection(newAngle);
}
int Actor::getAngle(int ax1, int ay1, int ax2, int ay2) {
diff --git a/engines/asylum/actor.h b/engines/asylum/actor.h
index 763a27ef8e..1bcfd852e0 100644
--- a/engines/asylum/actor.h
+++ b/engines/asylum/actor.h
@@ -143,16 +143,26 @@ public:
bool visible() {
return flags & 0x01;
}
+
void visible(bool value);
+
void setPosition(uint32 targetX, uint32 targetY);
- void setDirection(int dir);
/**
* Initialize the x1/y1 values of the actor, update the active animation frame
* and, if the current direction isn't 8, update the actor's direction
*/
void setPosition_40A260(uint32 newX, uint32 newY, int newDirection, int frame);
- void update_4072A0(int param);
+
+ /**
+ * Change the direction the actor's facing based
+ * on the supplied parament.
+ *
+ * Note that the parameter doesn't directly update the
+ * actor's direction, but it used as a lookup
+ * to determine the value
+ */
+ void changeOrientation(int param);
void faceTarget(int targetId, int targetType);
diff --git a/engines/asylum/config.h b/engines/asylum/config.h
index f8cb9e6974..a7e5263e1d 100644
--- a/engines/asylum/config.h
+++ b/engines/asylum/config.h
@@ -40,6 +40,10 @@ namespace Asylum {
class ConfigurationManager: public Common::Singleton<ConfigurationManager> {
public:
+ // XXX Throwing some globals in here until
+ // I know how to better handle them
+ int word_446EE4;
+
bool showMovieSubtitles;
Common::Array<int> movieSubtitles;
bool showEncounterSubtitles;
diff --git a/engines/asylum/scene.cpp b/engines/asylum/scene.cpp
index da8079819e..808e0a3de1 100644
--- a/engines/asylum/scene.cpp
+++ b/engines/asylum/scene.cpp
@@ -122,7 +122,7 @@ Scene::Scene(uint8 sceneIdx, AsylumEngine *vm): _vm(vm) {
_ws->boundingRect = Common::Rect(195, 115, 445 - _ws->actors[_playerActorIdx].boundingRect.right, 345 - _ws->actors[_playerActorIdx].boundingRect.bottom);
_ws->actors[_playerActorIdx].flags |= 1;
- _ws->actors[_playerActorIdx].update_4072A0(4);
+ _ws->actors[_playerActorIdx].changeOrientation(4);
_ws->actors[_playerActorIdx].x1 -= _ws->actors[_playerActorIdx].x2;
_ws->actors[_playerActorIdx].y1 -= _ws->actors[_playerActorIdx].y2;
@@ -132,7 +132,7 @@ Scene::Scene(uint8 sceneIdx, AsylumEngine *vm): _vm(vm) {
Actor *actor = &_ws->actors[a];
actor->flags |= 1;
actor->direction = 1;
- actor->update_4072A0(4);
+ actor->changeOrientation(4);
actor->x1 -= actor->x2;
actor->y1 -= actor->y2;
actor->boundingRect.bottom = actor->y2;
@@ -318,7 +318,7 @@ int Scene::updateScene() {
// Commented out the (incomplete) update screen code because once the
// actor's x1/y1 values are properly set, the temp code causes a crash
// Have to finish implementing the method I guess :P
- //updateAdjustScreen();
+ updateAdjustScreen();
//debugC(kDebugLevelScene, "AdjustScreenStart Time: %d", _vm->_system->getMillis() - startTick);
if (_actions->process())
@@ -1060,7 +1060,7 @@ int Scene::drawScene() {
_vm->screen()->drawGraphicsInQueue();
// TODO: we must get rid of this
- OLD_UPDATE();
+ //OLD_UPDATE();
}
return 1;
Commit: 0437c5d622455b8ddb1016b72ef4b6998a4ed8d2
https://github.com/scummvm/scummvm/commit/0437c5d622455b8ddb1016b72ef4b6998a4ed8d2
Author: Alex Bevilacqua (alexbevi at gmail.com)
Date: 2021-05-17T15:35:53+02:00
Commit Message:
ASYLUM: comment
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@381 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/actionlist.cpp
diff --git a/engines/asylum/actionlist.cpp b/engines/asylum/actionlist.cpp
index 5105072e86..7b483b64ed 100644
--- a/engines/asylum/actionlist.cpp
+++ b/engines/asylum/actionlist.cpp
@@ -585,6 +585,10 @@ int kDisableActor(ActionCommand *cmd, Scene *scn) {
int actorIndex = cmd->param1;
Actor* actor;
+ // TODO is this really efficient? Now that changeOrientation()
+ // is implemented, this opcode is effectively done, but I
+ // don't want to clear the incomplete flag until actor
+ // handling is better implemented.
if (actorIndex == -1)
actor = scn->getActor();
else
Commit: 0f3e70f32e60cd1581c5d02d4aff0ac1f2c077f8
https://github.com/scummvm/scummvm/commit/0f3e70f32e60cd1581c5d02d4aff0ac1f2c077f8
Author: Alex Bevilacqua (alexbevi at gmail.com)
Date: 2021-05-17T15:35:53+02:00
Commit Message:
ASYLUM: added new opcode return type that indicates that the opcode is implemented, but there are still some comments to address
fixed up some unsigned comparisson warnings
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@382 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/actionlist.cpp
diff --git a/engines/asylum/actionlist.cpp b/engines/asylum/actionlist.cpp
index 7b483b64ed..7318630ae9 100644
--- a/engines/asylum/actionlist.cpp
+++ b/engines/asylum/actionlist.cpp
@@ -295,6 +295,12 @@ int ActionList::process() {
_scene->getSceneIndex(),
currentLine);
+ if (cmdRet == -3)
+ warning("Flagged (see implemenation comments) opcode %s (0x%02X) in Scene %d Line %d",
+ function_map[opcode].name,
+ currentCommand->opcode,
+ _scene->getSceneIndex(),
+ currentLine);
currentLine += lineIncrement;
currentLoops++;
@@ -519,43 +525,31 @@ int kMoveScenePosition(ActionCommand *cmd, Scene *scn) {
}
int kHideActor(ActionCommand *cmd, Scene *scn) {
- uint32 actorIndex = 0;
+ Actor *actor = 0;
+ // TODO better default actor handling
if (cmd->param1 == -1)
- ;//actorIndex = scn->getWorldStats()->playerActor;
+ actor = scn->getActor();
else
- actorIndex = cmd->param1;
+ actor = &scn->worldstats()->actors[cmd->param1];
- if ((actorIndex >= 0) && (actorIndex < scn->worldstats()->numActors))
- scn->getActor()->visible(false);
- else
- debugC(kDebugLevelScripts,
- "Requested invalid actor ID:0x%02X in Scene %d Line %d.",
- cmd->param1,
- scn->getSceneIndex(),
- scn->actions()->currentLine);
+ actor->visible(false);
- return 0;
+ return -3;
}
int kShowActor(ActionCommand *cmd, Scene *scn) {
- uint32 actorIndex = 0;
+ Actor *actor = 0;
+ // TODO revisit when actor selection is cleaned up
if (cmd->param1 == -1)
- ;//actorIndex = scn->getWorldStats()->playerActor;
+ actor = scn->getActor();
else
- actorIndex = cmd->param1;
+ actor = &scn->worldstats()->actors[cmd->param1];
- if ((actorIndex >= 0) && (actorIndex < scn->worldstats()->numActors))
- scn->getActor()->visible(true);
- else
- debugC(kDebugLevelScripts,
- "Requested invalid actor ID:0x%02X in Scene %d Line %d.",
- cmd->param1,
- scn->getSceneIndex(),
- scn->actions()->currentLine);
+ actor->visible(true);
- return 0;
+ return -3;
}
int kSetActorStats(ActionCommand *cmd, Scene *scn) {
@@ -1031,21 +1025,22 @@ int kQuit(ActionCommand *cmd, Scene *scn) {
int kJumpBarrierFrame(ActionCommand *cmd, Scene *scn) {
Barrier *barrier = scn->worldstats()->getBarrierById(cmd->param1);
+ int idx = (int)barrier->frameIdx;
if (cmd->param2 == -1)
cmd->param2 = barrier->frameCount - 1;
- if (cmd->param3 && cmd->param2 == barrier->frameIdx) {
+ if (cmd->param3 && cmd->param2 == idx) {
//break;
- } else if (cmd->param4 && cmd->param2 < barrier->frameIdx) {
+ } else if (cmd->param4 && cmd->param2 < idx) {
//break;
- } else if (cmd->param5 && cmd->param2 > barrier->frameIdx) {
+ } else if (cmd->param5 && cmd->param2 > idx) {
//break;
- } else if (cmd->param6 && cmd->param2 <= barrier->frameIdx) {
+ } else if (cmd->param6 && cmd->param2 <= idx) {
//break;
- } else if (cmd->param7 && cmd->param2 >= barrier->frameIdx) {
+ } else if (cmd->param7 && cmd->param2 >= idx) {
//break;
- } else if (cmd->param8 && cmd->param2 != barrier->frameIdx) {
+ } else if (cmd->param8 && cmd->param2 != idx) {
//break;
}
Commit: 6354e0796935d910049a0c634bc4836e38a63a19
https://github.com/scummvm/scummvm/commit/6354e0796935d910049a0c634bc4836e38a63a19
Author: Alex Bevilacqua (alexbevi at gmail.com)
Date: 2021-05-17T15:35:53+02:00
Commit Message:
ASYLUM: started implementation of drawActorsAndBarriers()
this method is failing due to the actor's x1/y1 values not being set (this is supposed to happen in updateActor() case 0x04)
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@383 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/actor.h
engines/asylum/barrier.h
engines/asylum/scene.cpp
engines/asylum/scene.h
diff --git a/engines/asylum/actor.h b/engines/asylum/actor.h
index 1bcfd852e0..8c9703d426 100644
--- a/engines/asylum/actor.h
+++ b/engines/asylum/actor.h
@@ -194,7 +194,7 @@ public:
uint32 x;
uint32 y;
uint32 grResId;
- uint32 field_C;
+ uint32 field_C; // BarrierIndex? Mask index?
uint32 frameNum;
uint32 frameCount;
uint32 x1;
diff --git a/engines/asylum/barrier.h b/engines/asylum/barrier.h
index e215e7ca6a..146b7834db 100644
--- a/engines/asylum/barrier.h
+++ b/engines/asylum/barrier.h
@@ -57,11 +57,11 @@ public:
uint32 field_34;
uint32 flags;
uint32 field_3C;
- uint8 name[52]; // field_40 till field_70;
- uint32 field_74;
- uint32 field_78;
- uint32 field_7C;
- uint32 field_80;
+ uint8 name[52];
+ uint32 field_74; // XXX looks like fields
+ uint32 field_78; // 78 => 80 have something
+ uint32 field_7C; // to do with calculating
+ uint32 field_80; // actor intersection
uint32 polyIdx;
uint32 flags2;
uint32 gameFlags[10];
diff --git a/engines/asylum/scene.cpp b/engines/asylum/scene.cpp
index 808e0a3de1..c9db627294 100644
--- a/engines/asylum/scene.cpp
+++ b/engines/asylum/scene.cpp
@@ -1052,9 +1052,10 @@ int Scene::drawScene() {
// Force the screen to scroll if the mouse approaches the edges
//debugScreenScrolling(bg);
- // TODO: prepare Actors and Barriers draw
- drawActors();
- drawBarriers();
+ //drawActorsAndBarriers();
+ queueActorUpdates();
+ queueBarrierUpdates();
+
// TODO: draw main actor stuff
_vm->screen()->drawGraphicsInQueue();
@@ -1066,12 +1067,144 @@ int Scene::drawScene() {
return 1;
}
+void Scene::drawActorsAndBarriers() {
+ // TODO this is supposed to be looping through
+ // a collection of CharacterUpdateItems. Since
+ // we're only on scene 1 atm, and there is only one
+ // character, this will have to do :P
+ for (uint i = 0; i < _ws->numActors; i++) {
+ int actorRegPt = 0;
+ Actor *act = &_ws->actors[i];
+ Common::Point pt;
+
+ // XXX Since we're not using CharacterUpdateItems,
+ // the actor priority is never going to be changed.
+ // Need to investigate if this is an issue
+ /*
+ if (act->priority < 0)
+ act->priority = abs(act->priority);
+ continue;
+ */
+ act->priority = 3;
+ if (act->field_944 == 1 || act->field_944 == 4)
+ act->priority = 1;
+ else {
+ act->field_938 = 1;
+ act->field_934 = 0;
+ pt.x = act->x1 + act->x2;
+ pt.y = act->y1 + act->y2;
+
+ actorRegPt = act->boundingRect.bottom + act->boundingRect.right + 4;
+
+ // TODO special case for scene 11
+ // Not sure if we're checking the scene index
+ // or the scene number though :P
+ /*
+ if (_sceneIdx == 11) {
+ // FIXME this probably won't work
+ if (act != this->getActor())
+ actorRegPt += 20;
+ }
+ */
+
+ // XXX from .text:0040a4d1
+ for (uint barIdx = 0; barIdx < _ws->numBarriers; barIdx++) {
+ Barrier *bar = &_ws->barriers[barIdx];
+ bool actInBar = bar->boundingRect.contains(act->boundingRect);
+ bool intersects = false;
+
+ // TODO verify that my funky LOBYTE macro actually
+ // works the way I assume it should :P
+ if (!actInBar) {
+ if (LOBYTE(bar->flags) & 0x20)
+ if (!LOBYTE(bar->flags) & 0x80)
+ // XXX not sure if this will work, as it's
+ // supposed to set 0x40 to the lobyte...
+ bar->flags |= 0x40;
+ continue;
+ }
+
+ if (bar->flags & 2) {
+ // TODO refactor
+ if (bar->field_74 || bar->field_78 ||
+ bar->field_7C || bar->field_80)
+ intersects = (pt.y > bar->field_78 + (bar->field_80 - bar->field_78) * (pt.x - bar->field_74) / (bar->field_7C - bar->field_74)) == 0;
+ else
+ intersects = true;
+ } else {
+ if (bar->flags & 0x40) {
+ PolyDefinitions *poly = &_polygons->entries[bar->polyIdx];
+ intersects = poly->contains(pt.x, pt.y);
+ }
+ // XXX the original has an else case here that
+ // assigns intersects the value of the
+ // flags & 2 check, which doesn't make any sense since
+ // that path would never have been taken if code
+ // execution had made it's way here.
+ }
+ if (LOBYTE(bar->flags) & 0x80 || intersects) {
+ if (LOBYTE(bar->flags) & 0x20)
+ // XXX not sure if this will work, as it's
+ // supposed to set this value on the lobyte...
+ bar->flags &= 0xBF | 0x80;
+ else
+ // XXX another lobyte assignment...
+ bar->flags |= 0x40;
+ // TODO label jump up a few lines here. Investigate...
+ }
+ if (bar->flags & 4) {
+ if (intersects) {
+ if(act->flags & 2)
+ warning ("Assigning mask to masked character [%s]", bar->name);
+ else {
+ // TODO there's a call to sub_40ac10 that does
+ // a point calculation, but the result doesn't appear to
+ // ever be used, and the object passed in as a parameter
+ // isn't updated
+ act->field_3C = barIdx;
+ act->flags |= 2;
+ }
+ }
+ } else {
+ if (intersects) {
+ // XXX assuming the following:
+ // "if ( *(int *)((char *)&scene.characters[0].priority + v18) < *(v12_barrierPtr + 35) )"
+ // is the same as what I'm comparing :P
+ if (act->priority < bar->priority) {
+ act->field_934 = 1;
+ act->priority = bar->priority + 3;
+ // TODO there's a block of code here that seems
+ // to loop through the CharacterUpdateItems and do some
+ // priority adjustment. Since I'm not using CharacterUpdateItems as of yet,
+ // I'm not sure what to do here
+ // The loop seems to occur if:
+ // (a) there are still character items to process
+ // (b) sceneNumber != 2 && actor->field_944 != 1
+ }
+ } else {
+ if (act->priority > bar->priority || act->priority == 1) {
+ act->field_934 = 1;
+ act->priority = bar->priority - 1;
+ // TODO another character update loop
+ // This time it looks like there's another
+ // intersection test, and more updates
+ // to field_934 and field_944, then
+ // priority updates
+ }
+ }
+ }
+ } // end for (barriers)
+ }
+ } // end for (actors)
+
+}
+
void Scene::getActorPosition(Actor *actor, Common::Point *pt) {
pt->x = actor->x1 - _ws->xLeft;
pt->y = actor->y1 - _ws->yTop;
}
-int Scene::drawActors() {
+int Scene::queueActorUpdates() {
if (_ws->numActors > 0) {
Common::Point pt;
@@ -1104,7 +1237,7 @@ int Scene::drawActors() {
return 1;
}
-int Scene::drawBarriers() {
+int Scene::queueBarrierUpdates() {
uint barriersCount = _ws->barriers.size();
if (barriersCount > 0) {
diff --git a/engines/asylum/scene.h b/engines/asylum/scene.h
index 821a7d31b5..f7deee6e8c 100644
--- a/engines/asylum/scene.h
+++ b/engines/asylum/scene.h
@@ -166,8 +166,9 @@ private:
void updateMusic();
void updateAdjustScreen();
int drawScene();
- int drawActors();
- int drawBarriers();
+ void drawActorsAndBarriers();
+ int queueActorUpdates();
+ int queueBarrierUpdates();
bool isBarrierVisible(BarrierItem *barrier);
bool isBarrierOnScreen(BarrierItem *barrier);
uint32 getRandomResId(BarrierItem *barrier);
Commit: 27437d179651842ed774cf78f6abed993d692c10
https://github.com/scummvm/scummvm/commit/27437d179651842ed774cf78f6abed993d692c10
Author: Alex Bevilacqua (alexbevi at gmail.com)
Date: 2021-05-17T15:35:53+02:00
Commit Message:
ASYLUM: A bit more work and cleanup. This is not coming along very well though. I may have to start re-writing all the scene code from scratch just to get a better handle on what's supposed to be happeneing :(
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@384 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/actionlist.cpp
engines/asylum/actor.h
engines/asylum/asylum.h
engines/asylum/scene.cpp
engines/asylum/scene.h
engines/asylum/worldstats.cpp
engines/asylum/worldstats.h
diff --git a/engines/asylum/actionlist.cpp b/engines/asylum/actionlist.cpp
index 7318630ae9..0c0927eef6 100644
--- a/engines/asylum/actionlist.cpp
+++ b/engines/asylum/actionlist.cpp
@@ -548,8 +548,10 @@ int kShowActor(ActionCommand *cmd, Scene *scn) {
actor = &scn->worldstats()->actors[cmd->param1];
actor->visible(true);
+ // TODO character_sub_401320
+ actor->tickValue1 = scn->vm()->getTick();
- return -3;
+ return -2;
}
int kSetActorStats(ActionCommand *cmd, Scene *scn) {
diff --git a/engines/asylum/actor.h b/engines/asylum/actor.h
index 8c9703d426..a3e6edc43a 100644
--- a/engines/asylum/actor.h
+++ b/engines/asylum/actor.h
@@ -191,16 +191,16 @@ public:
int currentAction; // TODO depreciate
- uint32 x;
- uint32 y;
+ int32 x;
+ int32 y;
uint32 grResId;
uint32 field_C; // BarrierIndex? Mask index?
uint32 frameNum;
uint32 frameCount;
- uint32 x1;
- uint32 y1;
- uint32 x2;
- uint32 y2;
+ int32 x1;
+ int32 y1;
+ int32 x2;
+ int32 y2;
Common::Rect boundingRect;
uint32 direction;
uint32 field_3C;
diff --git a/engines/asylum/asylum.h b/engines/asylum/asylum.h
index 962d4cfcd2..f75c0f579e 100644
--- a/engines/asylum/asylum.h
+++ b/engines/asylum/asylum.h
@@ -96,6 +96,14 @@ public:
bool isGameFlagSet(int flag);
bool isGameFlagNotSet(int flag);
+ /**
+ * Wrapper function to the OSystem getMillis() method
+ */
+ uint32 getTick() { return _system->getMillis(); }
+
+ uint32 tempTick07;
+
+
Video* video() {
return _video;
}
diff --git a/engines/asylum/scene.cpp b/engines/asylum/scene.cpp
index c9db627294..90a1cbd59d 100644
--- a/engines/asylum/scene.cpp
+++ b/engines/asylum/scene.cpp
@@ -101,6 +101,8 @@ Scene::Scene(uint8 sceneIdx, AsylumEngine *vm): _vm(vm) {
g_debugBarriers = 0;
// TODO: do all the rest stuffs in sub at address 40E460
+ // XXX The player actor index is only ever changed again using
+ // changeCharacter()
_playerActorIdx = 0;
if (_ws->numBarriers > 0) {
@@ -117,26 +119,28 @@ Scene::Scene(uint8 sceneIdx, AsylumEngine *vm): _vm(vm) {
_vm->screen()->clearGraphicsInQueue();
_ws->motionStatus = 1;
- _ws->actors[_playerActorIdx].boundingRect.bottom = _ws->actors[_playerActorIdx].y2;
- _ws->actors[_playerActorIdx].boundingRect.right = 2 * _ws->actors[_playerActorIdx].x2;
- _ws->boundingRect = Common::Rect(195, 115, 445 - _ws->actors[_playerActorIdx].boundingRect.right, 345 - _ws->actors[_playerActorIdx].boundingRect.bottom);
+ Actor *actor = getActor();
+
+ actor->boundingRect.bottom = actor->y2;
+ actor->boundingRect.right = 2 * actor->x2;
+ _ws->boundingRect = Common::Rect(195, 115, 445 - actor->boundingRect.right, 345 - actor->boundingRect.bottom);
- _ws->actors[_playerActorIdx].flags |= 1;
- _ws->actors[_playerActorIdx].changeOrientation(4);
+ actor->flags |= 1;
+ actor->changeOrientation(4);
- _ws->actors[_playerActorIdx].x1 -= _ws->actors[_playerActorIdx].x2;
- _ws->actors[_playerActorIdx].y1 -= _ws->actors[_playerActorIdx].y2;
+ actor->x1 -= actor->x2;
+ actor->y1 -= actor->y2;
if (_ws->numActors > 1) {
for (uint32 a = 1; a < _ws->numActors; a++) {
- Actor *actor = &_ws->actors[a];
- actor->flags |= 1;
- actor->direction = 1;
- actor->changeOrientation(4);
- actor->x1 -= actor->x2;
- actor->y1 -= actor->y2;
- actor->boundingRect.bottom = actor->y2;
- actor->boundingRect.right = 2 * actor->x2;
+ Actor *act = &_ws->actors[a];
+ act->flags |= 1;
+ act->direction = 1;
+ act->changeOrientation(4);
+ act->x1 -= act->x2;
+ act->y1 -= act->y2;
+ act->boundingRect.bottom = act->y2;
+ act->boundingRect.right = 2 * act->x2;
}
}
@@ -215,13 +219,13 @@ void Scene::setScenePosition(int x, int y) {
if (_ws->targetX < 0)
_ws->targetX = 0;
- if (_ws->targetX > (uint32)(bg->surface.w - 640))
+ if (_ws->targetX > (bg->surface.w - 640))
_ws->targetX = bg->surface.w - 640;
if (_ws->targetY < 0)
_ws->targetY = 0;
- if (_ws->targetY > (uint32)(bg->surface.h - 480))
+ if (_ws->targetY > (bg->surface.h - 480))
_ws->targetY = bg->surface.h - 480;
}
@@ -266,7 +270,7 @@ void Scene::handleEvent(Common::Event *event, bool doUpdate) {
void Scene::update() {
#ifdef SHOW_SCENE_LOADING
if (!_titleLoaded) {
- _title->update(_vm->_system->getMillis());
+ _title->update(_vm->getTick());
if (_title->loadingComplete()) {
_titleLoaded = true;
enterScene();
@@ -287,39 +291,35 @@ int Scene::updateScene() {
uint32 startTick = 0;
// Mouse
- startTick = _vm->_system->getMillis();
+ startTick = _vm->getTick();
updateMouse();
- debugC(kDebugLevelScene, "UpdateMouse Time: %d", _vm->_system->getMillis() - startTick);
+ debugC(kDebugLevelScene, "UpdateMouse Time: %d", _vm->getTick() - startTick);
// Actors
- startTick = _vm->_system->getMillis();
+ startTick = _vm->getTick();
for (uint32 a = 0; a < _ws->numActors; a++)
updateActor(a);
- debugC(kDebugLevelScene, "UpdateActors Time: %d", _vm->_system->getMillis() - startTick);
+ debugC(kDebugLevelScene, "UpdateActors Time: %d", _vm->getTick() - startTick);
// Barriers
- startTick = _vm->_system->getMillis();
+ startTick = _vm->getTick();
updateBarriers();
- debugC(kDebugLevelScene, "UpdateBarriers Time: %d", _vm->_system->getMillis() - startTick);
+ debugC(kDebugLevelScene, "UpdateBarriers Time: %d", _vm->getTick() - startTick);
// Ambient Sounds
- startTick = _vm->_system->getMillis();
+ startTick = _vm->getTick();
updateAmbientSounds();
- debugC(kDebugLevelScene, "UpdateAmbientSounds Time: %d", _vm->_system->getMillis() - startTick);
+ debugC(kDebugLevelScene, "UpdateAmbientSounds Time: %d", _vm->getTick() - startTick);
// Music
- startTick = _vm->_system->getMillis();
+ startTick = _vm->getTick();
updateMusic();
- debugC(kDebugLevelScene, "UpdateMusic Time: %d", _vm->_system->getMillis() - startTick);
+ debugC(kDebugLevelScene, "UpdateMusic Time: %d", _vm->getTick() - startTick);
// Adjust Screen
- //startTick = _vm->_system->getMillis();
- // FIXME
- // Commented out the (incomplete) update screen code because once the
- // actor's x1/y1 values are properly set, the temp code causes a crash
- // Have to finish implementing the method I guess :P
+ startTick = _vm->getTick();
updateAdjustScreen();
- //debugC(kDebugLevelScene, "AdjustScreenStart Time: %d", _vm->_system->getMillis() - startTick);
+ debugC(kDebugLevelScene, "AdjustScreenStart Time: %d", _vm->getTick() - startTick);
if (_actions->process())
return 1;
@@ -505,11 +505,11 @@ void Scene::updateActor(uint32 actorIdx) {
uint32 frameNum = actor->frameNum + 1;
actor->frameNum = frameNum % actor->frameCount;
- if (_vm->_system->getMillis() - actor->tickValue1 > 300) {
+ if (_vm->getTick() - actor->tickValue1 > 300) {
if (rand() % 100 < 50) {
// TODO: check sound playing
}
- actor->tickValue1 = _vm->_system->getMillis();
+ actor->tickValue1 = _vm->getTick();
}
}
break;
@@ -535,7 +535,7 @@ void Scene::updateActor(uint32 actorIdx) {
break;
case 0x4:
if (actor->field_944 != 5) {
- // TODO: updateCharacterSub01_sw(1, actorIdx);
+ updateActorSub01(actor);
}
break;
case 0xE:
@@ -560,6 +560,49 @@ void Scene::updateActor(uint32 actorIdx) {
}
}
+void Scene::updateActorSub01(Actor *act) {
+ // TODO make sure this is right
+ act->frameNum = act->frameNum + 1 % act->frameCount;
+ if (_vm->getTick() - act->tickValue1 > 300) {
+ // TODO
+ // Check if the actor's name is "Crow"?
+ if (rand() % 100 < 50) {
+ // TODO
+ // Check if soundResId04 is assigned, and if so,
+ // if it's playing
+ // If true, check characterSub407260(10)
+ // and if that's true, do characterDirection(9)
+ }
+ }
+
+ // if act == getActor()
+ if (_vm->tempTick07) {
+ if (_vm->getTick() - _vm->tempTick07 > 500) {
+ if (_vm->isGameFlagNotSet(183)) { // processing action list
+ if (act->visible()) {
+ // if some_encounter_flag
+ // if !soundResId04
+ if (rand() % 100 < 50) {
+ if (_sceneIdx == 13) {
+ ; // sub414810(507)
+ } else {
+ ; // sub4146d0(4)
+ }
+ }
+ }
+ }
+ }
+ act->tickValue1 = _vm->getTick();
+ }
+ // else
+ // TODO now there's something to do with the
+ // character's name and "Big Crow", or "Crow".
+ // Quite a bit of work to do yet, but it only seems to
+ // take effect when the character index doesn't equal
+ // the currentPlayerIndex (so I'm guessing this is a
+ // one off situation).
+}
+
void Scene::updateBarriers() {
//Screen *screen = _vm->screen();
@@ -575,17 +618,17 @@ void Scene::updateBarriers() {
if (_ws->isBarrierVisible(b)) {
uint32 flag = barrier->flags;
if (flag & 0x20) {
- if (barrier->field_B4 && (_vm->_system->getMillis() - barrier->tickCount >= 0x3E8 / barrier->field_B4)) {
+ if (barrier->field_B4 && (_vm->getTick() - barrier->tickCount >= 0x3E8 / barrier->field_B4)) {
barrier->frameIdx = (barrier->frameIdx + 1) % barrier->frameCount;
- barrier->tickCount = _vm->_system->getMillis();
+ barrier->tickCount = _vm->getTick();
canPlaySound = true;
}
} else if (flag & 0x10) {
- uint32 frameIdx = barrier->frameIdx;
- char equalZero = frameIdx == 0;
- char lessZero = frameIdx < 0;
+ int frameIdx = barrier->frameIdx;
+ int equalZero = frameIdx == 0;
+ int lessZero = frameIdx < 0;
if (!frameIdx) {
- if (_vm->_system->getMillis() - barrier->tickCount >= 1000 * barrier->tickCount2) {
+ if (_vm->getTick() - barrier->tickCount >= 1000 * barrier->tickCount2) {
if (rand() % barrier->field_C0 == 1) {
if (barrier->field_68C[0]) {
// TODO: fix this, and find a better way to get frame count
@@ -598,7 +641,7 @@ void Scene::updateBarriers() {
}
barrier->frameIdx++;
}
- barrier->tickCount = _vm->_system->getMillis();
+ barrier->tickCount = _vm->getTick();
canPlaySound = true;
}
frameIdx = barrier->frameIdx;
@@ -606,17 +649,17 @@ void Scene::updateBarriers() {
lessZero = frameIdx < 0;
}
- if (!(lessZero ^ 0 | equalZero)) {
+ if (!((lessZero ^ 0) | equalZero)) {
// FIXME: we shouldn't increment field_B4 (check why this value came zero sometimes)
- if (barrier->field_B4 && (_vm->_system->getMillis() - barrier->tickCount >= 0x3E8 / barrier->field_B4)) {
+ if (barrier->field_B4 && (_vm->getTick() - barrier->tickCount >= 0x3E8 / barrier->field_B4)) {
barrier->frameIdx = (barrier->frameIdx + 1) % barrier->frameCount;
- barrier->tickCount = _vm->_system->getMillis();
+ barrier->tickCount = _vm->getTick();
canPlaySound = true;
}
}
} else if (flag & 8) {
// FIXME: we shouldn't increment field_B4 (check why this value came zero sometimes)
- if (barrier->field_B4 && (_vm->_system->getMillis() - barrier->tickCount >= 0x3E8 / barrier->field_B4)) {
+ if (barrier->field_B4 && (_vm->getTick() - barrier->tickCount >= 0x3E8 / barrier->field_B4)) {
uint32 frameIdx = barrier->frameIdx + 1;
if (frameIdx < barrier->frameCount - 1) {
if (barrier->field_688 == 1) {
@@ -631,30 +674,30 @@ void Scene::updateBarriers() {
barrier->frameIdx = frameIdx;
}
} else if ((flag & 0xFF) & 8) { // check this
- if (_vm->_system->getMillis() - barrier->tickCount >= 1000 * barrier->tickCount2) {
+ if (_vm->getTick() - barrier->tickCount >= 1000 * barrier->tickCount2) {
if (rand() % barrier->field_C0 == 1) { // TODO: THIS ISNT WORKING
barrier->frameIdx = (barrier->frameIdx + 1) % barrier->frameCount;
- barrier->tickCount = _vm->_system->getMillis();
+ barrier->tickCount = _vm->getTick();
canPlaySound = true;
}
}
} else if (!((flag & 0xFFFF) & 6)) {
// FIXME: we shouldn't increment field_B4 (check why this value came zero sometimes)
- if (barrier->field_B4 && (_vm->_system->getMillis() - barrier->tickCount >= 0x3E8 / barrier->field_B4) && (flag & 0x10000)) {
+ if (barrier->field_B4 && (_vm->getTick() - barrier->tickCount >= 0x3E8 / barrier->field_B4) && (flag & 0x10000)) {
uint32 frameIdx = barrier->frameIdx - 1;
if (frameIdx <= 0) {
barrier->flags &= 0xFFFEFFFF;
if (barrier->field_688 == 1) {
// TODO: reset global x, y positions
}
- barrier->tickCount = _vm->_system->getMillis();
+ barrier->tickCount = _vm->getTick();
canPlaySound = true;
}
if (barrier->field_688 == 1) {
// TODO: get global x, y positions
}
barrier->frameIdx = frameIdx;
- } else if (barrier->field_B4 && (_vm->_system->getMillis() - barrier->tickCount >= 0x3E8 / barrier->field_B4)) {
+ } else if (barrier->field_B4 && (_vm->getTick() - barrier->tickCount >= 0x3E8 / barrier->field_B4)) {
if ((flag & 0xFF) & 2) {
if (barrier->frameIdx == barrier->frameCount - 1) {
barrier->frameIdx--;
@@ -1052,7 +1095,7 @@ int Scene::drawScene() {
// Force the screen to scroll if the mouse approaches the edges
//debugScreenScrolling(bg);
- //drawActorsAndBarriers();
+ drawActorsAndBarriers();
queueActorUpdates();
queueBarrierUpdates();
@@ -1134,7 +1177,10 @@ void Scene::drawActorsAndBarriers() {
} else {
if (bar->flags & 0x40) {
PolyDefinitions *poly = &_polygons->entries[bar->polyIdx];
- intersects = poly->contains(pt.x, pt.y);
+ if (pt.x > 0 && pt.y > 0 && poly->numPoints > 0)
+ intersects = poly->contains(pt.x, pt.y);
+ else
+ warning ("[drawActorsAndBarriers] trying to find intersection of uninitialized point");
}
// XXX the original has an else case here that
// assigns intersects the value of the
diff --git a/engines/asylum/scene.h b/engines/asylum/scene.h
index f7deee6e8c..282d705369 100644
--- a/engines/asylum/scene.h
+++ b/engines/asylum/scene.h
@@ -161,6 +161,10 @@ private:
int updateScene();
void updateMouse();
void updateActor(uint32 actorIdx);
+ /**
+ * TODO give more meaningful name
+ */
+ void updateActorSub01(Actor *act);
void updateBarriers();
void updateAmbientSounds();
void updateMusic();
diff --git a/engines/asylum/worldstats.cpp b/engines/asylum/worldstats.cpp
index 6d09fa2b93..28c2acf471 100644
--- a/engines/asylum/worldstats.cpp
+++ b/engines/asylum/worldstats.cpp
@@ -300,16 +300,16 @@ void WorldStats::load(Common::SeekableReadStream *stream) {
int i;
Actor actor;
- actor.x = stream->readUint32LE();
- actor.y = stream->readUint32LE();
+ actor.x = stream->readSint32LE();
+ actor.y = stream->readSint32LE();
actor.grResId = stream->readUint32LE();
actor.field_C = stream->readUint32LE();
actor.frameNum = stream->readUint32LE();
actor.frameCount = stream->readUint32LE();
- actor.x1 = stream->readUint32LE();
- actor.y1 = stream->readUint32LE();
- actor.x2 = stream->readUint32LE();
- actor.y2 = stream->readUint32LE();
+ actor.x1 = stream->readSint32LE();
+ actor.y1 = stream->readSint32LE();
+ actor.x2 = stream->readSint32LE();
+ actor.y2 = stream->readSint32LE();
actor.boundingRect.left = stream->readUint32LE() & 0xFFFF;
actor.boundingRect.top = stream->readUint32LE() & 0xFFFF;
diff --git a/engines/asylum/worldstats.h b/engines/asylum/worldstats.h
index 4630b53922..b9eb10610d 100644
--- a/engines/asylum/worldstats.h
+++ b/engines/asylum/worldstats.h
@@ -107,8 +107,8 @@ public:
uint32 field_8C;
uint32 numActions; // field_90
uint32 numBarriers;
- uint32 targetX;
- uint32 targetY;
+ int targetX;
+ int targetY;
uint32 field_A0;
uint32 field_A4;
uint32 field_A8;
Commit: be1b96e4c0aed8c45b389e5b2604e7bb928c5568
https://github.com/scummvm/scummvm/commit/be1b96e4c0aed8c45b389e5b2604e7bb928c5568
Author: Alexandre Fontoura (alexandrefontoura at gmail.com)
Date: 2021-05-17T15:35:54+02:00
Commit Message:
ASYLUM: Little fix in Play Animation command.
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@385 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/actionlist.cpp
diff --git a/engines/asylum/actionlist.cpp b/engines/asylum/actionlist.cpp
index 0c0927eef6..efe2587805 100644
--- a/engines/asylum/actionlist.cpp
+++ b/engines/asylum/actionlist.cpp
@@ -430,15 +430,12 @@ int kPlayAnimation(ActionCommand *cmd, Scene *scn) {
if (cmd->param2 == 2) {
if (!barrier->checkFlags()) {
cmd->param2 = 1;
- // FIXME Not sure why this break was here
- // break;
}
scn->actions()->lineIncrement = 1;
} else {
if (cmd->param4) { // RECHECK THIS
- int newBarriedIndex = 213 * barrierIndex;
barrier->flags &= 0xFFFEF1C7;
- scn->worldstats()->getBarrierByIndex(newBarriedIndex)->flags = barrier->flags | 0x20;
+ barrier->flags |= 0x20;
} else if (cmd->param3) {
barrier->flags &= 0xFFFEF1C7;
barrier->flags |= 0x10000;
Commit: abf0365eaa0ca1a37c5eacaffde7e1fe81980f76
https://github.com/scummvm/scummvm/commit/abf0365eaa0ca1a37c5eacaffde7e1fe81980f76
Author: Alexandre Fontoura (alexandrefontoura at gmail.com)
Date: 2021-05-17T15:35:54+02:00
Commit Message:
ASYLUM: New player speech implementation.(Missing subtitles)
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@386 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
A engines/asylum/speech.cpp
A engines/asylum/speech.h
engines/asylum/actionlist.cpp
engines/asylum/actor.h
engines/asylum/asylum.vcproj
engines/asylum/module.mk
engines/asylum/scene.cpp
engines/asylum/scene.h
engines/asylum/text.cpp
engines/asylum/text.h
diff --git a/engines/asylum/actionlist.cpp b/engines/asylum/actionlist.cpp
index efe2587805..b9c4de9c5b 100644
--- a/engines/asylum/actionlist.cpp
+++ b/engines/asylum/actionlist.cpp
@@ -433,7 +433,7 @@ int kPlayAnimation(ActionCommand *cmd, Scene *scn) {
}
scn->actions()->lineIncrement = 1;
} else {
- if (cmd->param4) { // RECHECK THIS
+ if (cmd->param4) {
barrier->flags &= 0xFFFEF1C7;
barrier->flags |= 0x20;
} else if (cmd->param3) {
@@ -934,12 +934,45 @@ int kPlaySpeech(ActionCommand *cmd, Scene *scn) {
uint32 sndIdx = cmd->param1;
if ((int)sndIdx >= 0) {
- if (sndIdx >= 259) {
- sndIdx -= 9;
- scn->vm()->sound()->playSpeech(sndIdx - 0x7FFD0000);
- } else {
- scn->vm()->sound()->playSpeech(sndIdx);
- }
+ if (cmd->param4 != 2) {
+ uint32 resIdx = scn->speech()->play(sndIdx);
+ cmd->param5 = resIdx;
+
+ if (cmd->param2) {
+ scn->vm()->setGameFlag(183);
+ cmd->param4 = 2;
+ if (cmd->param6) {
+ // TODO: set flag 01
+ }
+ scn->actions()->lineIncrement = 1;
+ }
+
+ if (cmd->param3) {
+ if (!cmd->param6) {
+ scn->vm()->setGameFlag(219);
+ }
+ }
+ }
+
+ if (scn->vm()->sound()->isPlaying(cmd->param5)) {
+ scn->actions()->lineIncrement = 1;
+ }
+
+ scn->vm()->clearGameFlag(183);
+ cmd->param4 = 0;
+
+ if (cmd->param3) {
+ if (cmd->param6) {
+ // TODO: clear flag 01
+ }
+ scn->vm()->clearGameFlag(219);
+ }
+
+ if (!cmd->param6) {
+ cmd->param6 = 1;
+ }
+
+ // TODO: clear flag 01
} else
debugC(kDebugLevelScripts,
"Requested invalid sound ID:0x%02X in Scene %d Line %d.",
@@ -947,7 +980,7 @@ int kPlaySpeech(ActionCommand *cmd, Scene *scn) {
scn->getSceneIndex(),
scn->actions()->currentLine);
- return -1;
+ return 0;
}
int k_unk42(ActionCommand *cmd, Scene *scn) {
diff --git a/engines/asylum/actor.h b/engines/asylum/actor.h
index a3e6edc43a..fb2ff94ee8 100644
--- a/engines/asylum/actor.h
+++ b/engines/asylum/actor.h
@@ -35,6 +35,14 @@ class Scene;
class Screen;
struct ActionArea;
+enum ActorType {
+ kMax = 0,
+ // TODO: check if the names match the actor type
+ kSarah = 1,
+ kCyclops = 2,
+ kAztec = 3
+};
+
// TODO investigate other actor resources (from other
// scenes) to see if the unused blocks in the actor
// definition are in fact used elsewhere
diff --git a/engines/asylum/asylum.vcproj b/engines/asylum/asylum.vcproj
index 14ae01d2a5..459621470b 100644
--- a/engines/asylum/asylum.vcproj
+++ b/engines/asylum/asylum.vcproj
@@ -49,6 +49,8 @@
<File RelativePath="..\..\engines\asylum\screen.h" />
<File RelativePath="..\..\engines\asylum\sound.cpp" />
<File RelativePath="..\..\engines\asylum\sound.h" />
+ <File RelativePath="..\..\engines\asylum\speech.cpp" />
+ <File RelativePath="..\..\engines\asylum\speech.h" />
<File RelativePath="..\..\engines\asylum\text.cpp" />
<File RelativePath="..\..\engines\asylum\text.h" />
<File RelativePath="..\..\engines\asylum\video.cpp" />
diff --git a/engines/asylum/module.mk b/engines/asylum/module.mk
index 11408d6391..e444c8b8ca 100644
--- a/engines/asylum/module.mk
+++ b/engines/asylum/module.mk
@@ -20,6 +20,7 @@ MODULE_OBJS := \
text.o \
video.o \
worldstats.o \
+ speech.o \
config.o
# This module can be built as a plugin
diff --git a/engines/asylum/scene.cpp b/engines/asylum/scene.cpp
index 90a1cbd59d..59d84b0f9c 100644
--- a/engines/asylum/scene.cpp
+++ b/engines/asylum/scene.cpp
@@ -68,6 +68,7 @@ Scene::Scene(uint8 sceneIdx, AsylumEngine *vm): _vm(vm) {
fd->close();
delete fd;
+ _speech = new Speech(this);
_resPack = new ResourcePack(sceneIdx);
// FIXME
diff --git a/engines/asylum/scene.h b/engines/asylum/scene.h
index 282d705369..8386012506 100644
--- a/engines/asylum/scene.h
+++ b/engines/asylum/scene.h
@@ -36,6 +36,7 @@
#include "asylum/actionlist.h"
#include "asylum/text.h"
#include "asylum/cursor.h"
+#include "asylum/speech.h"
#define SCENE_FILE_MASK "scn.%03d"
#define MUSIC_FILE_MASK "mus.%03d"
@@ -51,6 +52,7 @@ class Text;
class BlowUpPuzzle;
struct BarrierItem;
class WorldStats;
+class Speech;
class SceneTitle {
public:
@@ -132,6 +134,10 @@ public:
return _actions;
}
+ Speech* speech() {
+ return _speech;
+ }
+
private:
AsylumEngine *_vm;
uint8 _sceneIdx;
@@ -139,10 +145,10 @@ private:
Polygons *_polygons;
ActionList *_actions;
SceneTitle *_title;
+ Speech *_speech;
Cursor *_cursor;
ResourcePack *_resPack;
- ResourcePack *_speechPack;
ResourcePack *_musPack;
BlowUpPuzzle *_blowUp;
Common::Event *_ev;
diff --git a/engines/asylum/speech.cpp b/engines/asylum/speech.cpp
new file mode 100644
index 0000000000..5a4d549981
--- /dev/null
+++ b/engines/asylum/speech.cpp
@@ -0,0 +1,145 @@
+/* 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.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#include "asylum/speech.h"
+#include "asylum/actor.h"
+#include "asylum/config.h"
+#include "asylum/text.h"
+
+namespace Asylum {
+
+Speech::Speech(Scene *scene): _scene(scene) {
+ _tick = _scene->vm()->getTick();
+ _soundResIdx = 0;
+ _textResIdx = 0;
+}
+
+Speech::~Speech() {
+ // TODO Auto-generated destructor stub
+}
+
+uint32 Speech::play(uint32 speechIdx) {
+ uint32 soundResIdx = 0;
+
+ switch (_scene->worldstats()->actorType) {
+ case kMax: {
+ uint32 soundResIdx2 = speechIdx;
+ uint32 textResIdx = speechIdx;
+
+ if (speechIdx >= 259) {
+ soundResIdx2 -= 9;
+ textResIdx -= 9;
+ }
+
+ soundResIdx = soundResIdx2 - 0x7FFD0000;
+ // setup the right index for sound and text
+ setPlayerSpeech(soundResIdx, textResIdx - 0x7FFFFFAD);
+ }
+ break;
+ // TODO: check if actor type is right for the following cases
+ case kSarah: {
+ soundResIdx = speechIdx - 0x7FFBF879;
+ setPlayerSpeech(soundResIdx, speechIdx - 0x7FFFFDB6);
+ }
+ break;
+ case kCyclops: {
+ soundResIdx = speechIdx - 0x7FFBF7DC;
+ setPlayerSpeech(soundResIdx, speechIdx - 0x7FFFFD19);
+ }
+ break;
+ case kAztec: {
+ soundResIdx = speechIdx - 0x7FFBF746;
+ setPlayerSpeech(soundResIdx, speechIdx - 0x7FFFFC83);
+ }
+ break;
+ default:
+ soundResIdx = 0;
+ break;
+ }
+
+ return soundResIdx;
+}
+
+void Speech::setPlayerSpeech(uint32 soundResIdx, uint32 textResIdx) {
+ if (soundResIdx) {
+ if (_scene->vm()->sound()->isPlaying(soundResIdx)) {
+ _scene->vm()->sound()->stopSound(soundResIdx);
+ }
+ }
+
+ _soundResIdx = soundResIdx;
+ _textResIdx = textResIdx;
+
+ prepareSpeech();
+}
+
+void Speech::prepareSpeech() {
+ uint32 startTick = _scene->vm()->getTick();
+
+ if (_soundResIdx) {
+ if (!_scene->vm()->sound()->isPlaying(_soundResIdx) || _tick && startTick >= _tick) {
+ processSpeech();
+ }
+
+ if (Config.showEncounterSubtitles) {
+ // TODO: get actors position and draw text on screen
+ }
+ }
+}
+
+void Speech::processSpeech() {
+ char * txt;
+ Text* text = _scene->vm()->text();
+
+ _tick = 0;
+
+ txt = text->getResText(_textResIdx);
+
+ if (*(txt + strlen((const char *)txt) - 2) == 1) {
+ _textResIdx = 0;
+ _textData = 0;
+ _textDataPos = 0;
+ } else {
+ if (*txt == '{') {
+ _textData = txt + 3;
+ _textDataPos = 0;
+
+ _scene->vm()->text()->loadFont(_scene->getResourcePack(), _scene->worldstats()->commonRes.font1);
+ _scene->vm()->sound()->playSpeech(_soundResIdx);
+ } else {
+ _textData = 0;
+ _textDataPos = txt;
+
+ if (*txt == '/') {
+ _textDataPos = txt + 2;
+ }
+
+ _scene->vm()->text()->loadFont(_scene->getResourcePack(), _scene->worldstats()->commonRes.font3);
+ _scene->vm()->sound()->playSpeech(_soundResIdx);
+ }
+ }
+}
+
+} // end of namespace Asylum
diff --git a/engines/asylum/speech.h b/engines/asylum/speech.h
new file mode 100644
index 0000000000..876da1849c
--- /dev/null
+++ b/engines/asylum/speech.h
@@ -0,0 +1,79 @@
+/* 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.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#ifndef ASYLUM_SPEECH_H_
+#define ASYLUM_SPEECH_H_
+
+#include "asylum/respack.h"
+#include "asylum/scene.h"
+
+namespace Asylum {
+
+class Speech {
+public:
+ Speech(Scene *scene);
+ virtual ~Speech();
+
+ /** .text:00414810
+ * Play player speech
+ * @param speechIdx speech index (used for sound and text resources)
+ * @return correct resourceId
+ */
+ uint32 play(uint32 speechIdx);
+
+ /** .text:004146D0
+ * Set speech for different player type
+ * @param soundResIdx sound resource id
+ * @param textResIdx text resource id
+ */
+ void setPlayerSpeech(uint32 soundResIdx, uint32 textResIdx);
+private:
+ Scene *_scene;
+
+ uint32 _tick;
+ uint32 _soundResIdx;
+ uint32 _textResIdx;
+
+ char * _textData;
+ char * _textDataPos;
+
+ /** .text:004144C0
+ * Prepare speech to play
+ * - Process sound speech and draws dialogue in screen
+ */
+ void prepareSpeech();
+
+ /** .text:00414580
+ */
+ void processSpeech();
+
+ // This function was cutoff since it doesn't make any sence using it. Its here for address information only
+ /** .text:00414630 void playSpeech(uint32 textResIdx, uint32 fontResIdx); */
+
+}; // end of class Speech
+
+} // end of namespace Asylum
+
+#endif
diff --git a/engines/asylum/text.cpp b/engines/asylum/text.cpp
index 3defc06269..8f800c9741 100644
--- a/engines/asylum/text.cpp
+++ b/engines/asylum/text.cpp
@@ -83,6 +83,11 @@ uint32 Text::getResTextWidth(uint32 resId) {
return getTextWidth((char*)textRes->data);
}
+char* Text::getResText(uint32 resId) {
+ ResourceEntry *textRes = _textPack->getResource(resId);
+ return (char*)textRes->data;
+}
+
void Text::drawChar(char character) {
assert(_fontResource);
diff --git a/engines/asylum/text.h b/engines/asylum/text.h
index 6dfac2d942..c1cc5bf071 100644
--- a/engines/asylum/text.h
+++ b/engines/asylum/text.h
@@ -43,6 +43,7 @@ public:
void setTextPos(uint32 x, uint32 y);
uint32 getTextWidth(char *text);
uint32 getResTextWidth(uint32 resId);
+ char * getResText(uint32 resId);
void drawChar(char character);
void drawText(char *text);
Commit: 1ca31867e85876103cb3bbd81e076b7f882e9fd3
https://github.com/scummvm/scummvm/commit/1ca31867e85876103cb3bbd81e076b7f882e9fd3
Author: Alexandre Fontoura (alexandrefontoura at gmail.com)
Date: 2021-05-17T15:35:54+02:00
Commit Message:
ASYLUM: PlayerSpeech showing Text. (Still need to fix Sound::isPlaying to display the text while speech is playing)
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@387 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/actionlist.cpp
engines/asylum/scene.cpp
engines/asylum/scene.h
engines/asylum/speech.cpp
engines/asylum/speech.h
engines/asylum/text.cpp
diff --git a/engines/asylum/actionlist.cpp b/engines/asylum/actionlist.cpp
index b9c4de9c5b..325e2f5744 100644
--- a/engines/asylum/actionlist.cpp
+++ b/engines/asylum/actionlist.cpp
@@ -268,7 +268,7 @@ int ActionList::process() {
if (_currentScript) {
while (!done && !waitCycle) {
- lineIncrement = 1; //Reset line increment value
+ lineIncrement = 0; //Reset line increment value
if (currentLoops > 1000) {
//TODO - processActionLists has run too many iterations
@@ -301,8 +301,11 @@ int ActionList::process() {
currentCommand->opcode,
_scene->getSceneIndex(),
currentLine);
- currentLine += lineIncrement;
- currentLoops++;
+
+ if (!lineIncrement) {
+ currentLine ++;
+ currentLoops++;
+ }
} // end while
@@ -889,14 +892,12 @@ int kWaitUntilFramePlayed(ActionCommand *cmd, Scene *scn) {
Barrier *barrier = scn->worldstats()->getBarrierById(cmd->param1);
if (barrier) {
- uint32 frameNum = 0;
+ uint32 frameNum = cmd->param2;
if (cmd->param2 == -1)
frameNum = barrier->frameCount - 1;
- else
- frameNum = cmd->param2;
- if (barrier->frameIdx < frameNum) {
- scn->actions()->lineIncrement = 0;
+ if (barrier->frameIdx != frameNum) {
+ scn->actions()->lineIncrement = 1;
scn->actions()->waitCycle = true;
}
} else
diff --git a/engines/asylum/scene.cpp b/engines/asylum/scene.cpp
index 59d84b0f9c..59d01f8e25 100644
--- a/engines/asylum/scene.cpp
+++ b/engines/asylum/scene.cpp
@@ -286,6 +286,16 @@ void Scene::update() {
drawScene();
//TODO: other process stuffs from sub 0040AE30
+
+ if (_speech->_soundResIdx != 0) {
+ if (_vm->sound()->isPlaying(_speech->_soundResIdx)) {
+ _speech->prepareSpeech();
+ } else {
+ _speech->_textResIdx = 0;
+ _speech->_soundResIdx = 0;
+ _vm->clearGameFlag(219);
+ }
+ }
}
int Scene::updateScene() {
diff --git a/engines/asylum/scene.h b/engines/asylum/scene.h
index 8386012506..3c5b460fb4 100644
--- a/engines/asylum/scene.h
+++ b/engines/asylum/scene.h
@@ -138,6 +138,8 @@ public:
return _speech;
}
+ void getActorPosition(Actor *actor, Common::Point *pt);
+
private:
AsylumEngine *_vm;
uint8 _sceneIdx;
@@ -181,8 +183,7 @@ private:
int queueBarrierUpdates();
bool isBarrierVisible(BarrierItem *barrier);
bool isBarrierOnScreen(BarrierItem *barrier);
- uint32 getRandomResId(BarrierItem *barrier);
- void getActorPosition(Actor *actor, Common::Point *pt);
+ uint32 getRandomResId(BarrierItem *barrier);
void copyToBackBufferClipped(Graphics::Surface *surface, int x, int y);
diff --git a/engines/asylum/speech.cpp b/engines/asylum/speech.cpp
index 5a4d549981..f489d889f3 100644
--- a/engines/asylum/speech.cpp
+++ b/engines/asylum/speech.cpp
@@ -99,23 +99,34 @@ void Speech::prepareSpeech() {
uint32 startTick = _scene->vm()->getTick();
if (_soundResIdx) {
- if (!_scene->vm()->sound()->isPlaying(_soundResIdx) || _tick && startTick >= _tick) {
+ if (!_scene->vm()->sound()->isPlaying(_soundResIdx)/* || _tick && startTick >= _tick*/) {
processSpeech();
}
if (Config.showEncounterSubtitles) {
- // TODO: get actors position and draw text on screen
+ int16 check = 0;
+ /*Common::Point *pt;
+ _scene->getActorPosition(_scene->getActor(), pt);
+
+ check = pt->y < 240;
+ check = pt->y >= 240;*/
+ uint32 posY = ((check - 1) & 0x118) + 40;
+
+ _scene->vm()->text()->loadFont(_scene->getResourcePack(), _scene->worldstats()->commonRes.font3);
+ _scene->vm()->text()->drawText(20, posY, _textDataPos);
+
+ _scene->vm()->text()->loadFont(_scene->getResourcePack(), _scene->worldstats()->commonRes.font1);
+ _scene->vm()->text()->drawText(20, posY, _textData);
}
}
}
void Speech::processSpeech() {
char * txt;
- Text* text = _scene->vm()->text();
_tick = 0;
- txt = text->getResText(_textResIdx);
+ txt = _scene->vm()->text()->getResText(_textResIdx);
if (*(txt + strlen((const char *)txt) - 2) == 1) {
_textResIdx = 0;
diff --git a/engines/asylum/speech.h b/engines/asylum/speech.h
index 876da1849c..946f235c25 100644
--- a/engines/asylum/speech.h
+++ b/engines/asylum/speech.h
@@ -36,6 +36,9 @@ public:
Speech(Scene *scene);
virtual ~Speech();
+ uint32 _soundResIdx;
+ uint32 _textResIdx;
+
/** .text:00414810
* Play player speech
* @param speechIdx speech index (used for sound and text resources)
@@ -49,22 +52,20 @@ public:
* @param textResIdx text resource id
*/
void setPlayerSpeech(uint32 soundResIdx, uint32 textResIdx);
+
+ /** .text:004144C0
+ * Prepare speech to play
+ * - Process sound speech and draws dialogue in screen
+ */
+ void prepareSpeech();
private:
Scene *_scene;
uint32 _tick;
- uint32 _soundResIdx;
- uint32 _textResIdx;
char * _textData;
char * _textDataPos;
- /** .text:004144C0
- * Prepare speech to play
- * - Process sound speech and draws dialogue in screen
- */
- void prepareSpeech();
-
/** .text:00414580
*/
void processSpeech();
diff --git a/engines/asylum/text.cpp b/engines/asylum/text.cpp
index 8f800c9741..aa13e38b5e 100644
--- a/engines/asylum/text.cpp
+++ b/engines/asylum/text.cpp
@@ -128,9 +128,11 @@ void Text::drawResTextCentered(uint32 x, uint32 y, uint32 width, uint32 resId) {
}
void Text::drawText(uint32 x, uint32 y, char *text) {
- int textWidth = getTextWidth(text);
- setTextPos(x - textWidth, y);
- drawText(text);
+ if (text) {
+ int textWidth = getTextWidth(text);
+ setTextPos(x - textWidth, y);
+ drawText(text);
+ }
}
void Text::drawResText(uint32 x, uint32 y, uint32 resId) {
Commit: 05f33c9a4c780475f315a8a64628584ef3d2c9e9
https://github.com/scummvm/scummvm/commit/05f33c9a4c780475f315a8a64628584ef3d2c9e9
Author: Alex Bevilacqua (alexbevi at gmail.com)
Date: 2021-05-17T15:35:54+02:00
Commit Message:
ASYLUM: More accurate implementation of updateActorDirection (40A2E0), updateActorDirectionDefault (407260), and defaultActorDirectionLoaded (407260).
These updates all occur on the scene, and not the actor as they rely heavily on the values in WorldStats.
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@388 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/actionlist.cpp
engines/asylum/actor.cpp
engines/asylum/actor.h
engines/asylum/scene.cpp
engines/asylum/scene.h
diff --git a/engines/asylum/actionlist.cpp b/engines/asylum/actionlist.cpp
index 325e2f5744..4f6bb8f5c5 100644
--- a/engines/asylum/actionlist.cpp
+++ b/engines/asylum/actionlist.cpp
@@ -579,20 +579,13 @@ int kSetSceneMotionStat(ActionCommand *cmd, Scene *scn) {
int kDisableActor(ActionCommand *cmd, Scene *scn) {
int actorIndex = cmd->param1;
- Actor* actor;
- // TODO is this really efficient? Now that changeOrientation()
- // is implemented, this opcode is effectively done, but I
- // don't want to clear the incomplete flag until actor
- // handling is better implemented.
if (actorIndex == -1)
- actor = scn->getActor();
- else
- actor = &scn->worldstats()->actors[actorIndex];
+ actorIndex = scn->getActorIndex();
- actor->changeOrientation(5);
+ scn->updateActorDirection(actorIndex, 5);
- return -1;
+ return 0;
}
int kEnableActor(ActionCommand *cmd, Scene *scn) {
diff --git a/engines/asylum/actor.cpp b/engines/asylum/actor.cpp
index 1cdc1c4252..3d54291a92 100644
--- a/engines/asylum/actor.cpp
+++ b/engines/asylum/actor.cpp
@@ -278,53 +278,6 @@ void Actor::walkTo(uint32 curX, uint32 curY) {
drawActor();
}
-
-void Actor::changeOrientation(int param) {
- int newGrId = 0;
- int newDir = 0;
-
- switch (param) {
- case 4:
- case 6:
- case 14:
- if (direction > 4)
- newDir = 8 - direction;
- else
- newDir = direction;
- newGrId = grResTable[newDir + 5];
- break;
-
- case 5:
- newDir = direction;
- if (newDir > 4)
- direction = 8 - newDir;
-
- newGrId = grResTable[newDir + 5];
-
- // XXX This has something to do with screen updating
- Config.word_446EE4 = -1;
- break;
-
- default:
- warning ("[update_4072A0] unimplemented case: %d", param);
- break;
- }
-
- grResId = newGrId;
-
- GraphicResource *gra = new GraphicResource(_resPack, grResId);
- frameCount = gra->getFrameCount();
- frameNum = 0;
- delete gra;
-
- // TODO
- // The update type can be different than the provided parameter
- // depending on the switch case. Change this once a case handler
- // is implemented that requires this ... namely:
- // if (!v34) v3 = 4; // so updateType = 4
- updateType = param;
-}
-
void Actor::setPosition_40A260(uint32 newX, uint32 newY, int newDirection, int frame) {
x1 = newX - x2;
y1 = newY - y2;
diff --git a/engines/asylum/actor.h b/engines/asylum/actor.h
index fb2ff94ee8..fa711384ae 100644
--- a/engines/asylum/actor.h
+++ b/engines/asylum/actor.h
@@ -162,16 +162,6 @@ public:
*/
void setPosition_40A260(uint32 newX, uint32 newY, int newDirection, int frame);
- /**
- * Change the direction the actor's facing based
- * on the supplied parament.
- *
- * Note that the parameter doesn't directly update the
- * actor's direction, but it used as a lookup
- * to determine the value
- */
- void changeOrientation(int param);
-
void faceTarget(int targetId, int targetType);
// FIXME
diff --git a/engines/asylum/scene.cpp b/engines/asylum/scene.cpp
index 59d01f8e25..ca3862404d 100644
--- a/engines/asylum/scene.cpp
+++ b/engines/asylum/scene.cpp
@@ -127,7 +127,7 @@ Scene::Scene(uint8 sceneIdx, AsylumEngine *vm): _vm(vm) {
_ws->boundingRect = Common::Rect(195, 115, 445 - actor->boundingRect.right, 345 - actor->boundingRect.bottom);
actor->flags |= 1;
- actor->changeOrientation(4);
+ updateActorDirectionDefault(_playerActorIdx);
actor->x1 -= actor->x2;
actor->y1 -= actor->y2;
@@ -137,7 +137,7 @@ Scene::Scene(uint8 sceneIdx, AsylumEngine *vm): _vm(vm) {
Actor *act = &_ws->actors[a];
act->flags |= 1;
act->direction = 1;
- act->changeOrientation(4);
+ updateActorDirectionDefault(a);
act->x1 -= act->x2;
act->y1 -= act->y2;
act->boundingRect.bottom = act->y2;
@@ -175,8 +175,167 @@ Scene::~Scene() {
#endif
}
-Actor* Scene::getActor() {
- return &_ws->actors[_playerActorIdx];
+Actor* Scene::getActor(int index) {
+ return &_ws->actors[(index != -1) ? index : _playerActorIdx];
+}
+
+void Scene::updateActorDirection(int actorIndex, int param) {
+ Actor *actor = getActor(actorIndex);
+ GraphicResource *gra;
+
+ switch (param) {
+ case 16:
+ actor->frameNum = 0;
+ if (actor->direction > 4)
+ actor->direction = 8 - actor->direction;
+ actor->grResId = actor->grResTable[15];
+ gra = new GraphicResource(_resPack, actor->grResId);
+ actor->frameCount = gra->getFrameCount();
+ delete gra;
+ break;
+ case 18:
+ if (_ws->numChapter > 2) {
+ actor->frameNum = 0;
+ if (actorIndex > 12)
+ actor->grResId = actor->grResTable[30];
+ if (_playerActorIdx == actorIndex) {
+ gra = new GraphicResource(_resPack, actor->grResId);
+ actor->frameNum = gra->getFrameCount() - 1;
+ delete gra;
+ }
+
+ if (actorIndex == 11) {
+ // TODO check a global variable (that likely
+ // relates to direction) to see if it's > 4,
+ // and if so, subtract it from 8. Then use this
+ // to set actor[11].grResId
+ }
+
+ // FIXME I know this seems wasteful, but it's how the
+ // original worked. I guess this is to set the framecount
+ // regardless of the actorIndex value, though it assumes
+ // the actor's grResId has been set.
+ gra = new GraphicResource(_resPack, actor->grResId);
+ actor->frameCount = gra->getFrameCount();
+ delete gra;
+ }
+ break;
+ case 15:
+ // TODO Refactor, because this is identical to case 16,
+ // other than a different grResTable index
+ actor->frameNum = 0;
+ if (actor->direction > 4)
+ actor->direction = 8 - actor->direction;
+ actor->grResId = actor->grResTable[10];
+ gra = new GraphicResource(_resPack, actor->grResId);
+ actor->frameCount = gra->getFrameCount();
+ delete gra;
+ break;
+ case 9:
+ // TODO Check if there is an encounter currently
+ // active (via the global at .data:00543504)
+ // FIXME skipping for now
+ if (0) {
+ if (rand() % -2 == 1 && defaultActorDirectionLoaded(actorIndex, 15)) {
+ actor->frameNum = 0;
+ if (actor->direction > 4)
+ actor->direction = 8 - actor->direction;
+ actor->grResId = actor->grResTable[15];
+ gra = new GraphicResource(_resPack, actor->grResId);
+ actor->frameCount = gra->getFrameCount();
+ delete gra;
+ } else {
+ actor->frameNum = 0;
+ if (actor->direction > 4)
+ actor->direction = 8 - actor->direction;
+ actor->grResId = actor->grResTable[10];
+ gra = new GraphicResource(_resPack, actor->grResId);
+ actor->frameCount = gra->getFrameCount();
+ delete gra;
+ }
+ }
+ break;
+ case 4:
+ case 6:
+ case 14:
+ actor->frameNum = 0;
+ if (actor->direction > 4)
+ actor->direction = 8 - actor->direction;
+ actor->grResId = actor->grResTable[15];
+ gra = new GraphicResource(_resPack, actor->grResId);
+ actor->frameCount = gra->getFrameCount();
+ delete gra;
+ break;
+ case 1:
+ case 12:
+ // TODO check if sceneNumber == 2 && actorIndex == _playerActorInde
+ // && actor->field_40 equals/doesn't equal a bunch of values,
+ // then set direction like other cases
+ break;
+ case 2:
+ case 13:
+ actor->frameNum = 0;
+ if (actor->direction > 4)
+ actor->direction = 8 - actor->direction;
+ actor->grResId = actor->grResTable[actor->direction];
+ gra = new GraphicResource(_resPack, actor->grResId);
+ actor->frameCount = gra->getFrameCount();
+ delete gra;
+ break;
+ case 5:
+ actor->frameNum = 0;
+ if (actor->direction > 4)
+ actor->direction = 8 - actor->direction;
+ actor->grResId = actor->grResTable[actor->direction];
+ gra = new GraphicResource(_resPack, actor->grResId);
+ actor->frameCount = gra->getFrameCount();
+ delete gra;
+ // TODO set word_446EE4 to -1. This global seems to
+ // be used with screen blitting
+ break;
+ case 3:
+ case 19:
+ // TODO check if the actor's name is equal to
+ // "Big Crow"???
+ break;
+ case 7:
+ if (_ws->numChapter == 2 && actorIndex == 10 && _vm->isGameFlagSet(279)) {
+ Actor *act0 = getActor(0);
+ act0->x1 = actor->x2 + actor->x1 - act0->x2;
+ act0->y1 = actor->y2 + actor->y1 - act0->y2;
+ act0->direction = 4;
+ _playerActorIdx = 0;
+ // TODO disableCharacterVisible(actorIndex)
+ // TODO enableActorVisible(0)
+ _vm->clearGameFlag(279);
+ // TODO some cursor update
+ }
+ break;
+ case 8:
+ case 10:
+ case 17:
+ actor->frameNum = 0;
+ if (actor->direction > 4)
+ actor->direction = 8 - actor->direction;
+ actor->grResId = actor->grResTable[20];
+ gra = new GraphicResource(_resPack, actor->grResId);
+ actor->frameCount = gra->getFrameCount();
+ delete gra;
+ break;
+ }
+
+ actor->updateType = param;
+}
+
+void Scene::updateActorDirectionDefault(int actorIndex) {
+ if (actorIndex == -1)
+ actorIndex = _playerActorIdx;
+ updateActorDirection(actorIndex, 4);
+}
+
+bool Scene::defaultActorDirectionLoaded(int actorIndex, int grResTableIdx) {
+ Actor *actor = getActor(actorIndex);
+ return actor->grResTable[grResTableIdx] != actor->grResTable[5];
}
void Scene::enterScene() {
diff --git a/engines/asylum/scene.h b/engines/asylum/scene.h
index 3c5b460fb4..a64cfe13a4 100644
--- a/engines/asylum/scene.h
+++ b/engines/asylum/scene.h
@@ -98,8 +98,6 @@ public:
return _sceneIdx;
}
- Actor* getActor();
-
Cursor* getCursor() {
return _cursor;
}
@@ -138,8 +136,35 @@ public:
return _speech;
}
- void getActorPosition(Actor *actor, Common::Point *pt);
-
+ void getActorPosition(Actor *actor, Common::Point *pt);
+
+ /**
+ * Return the index of the current player actor
+ */
+ int getActorIndex() { return _playerActorIdx; }
+ /**
+ * Get a reference to an actor object from the
+ * WorldStats actor list. Default parameter just
+ * gets the instance associated with _playerActorIdx
+ */
+ Actor* getActor(int index = -1);
+ /** .text:004072A0
+ * Based on the value of param, replace the actor
+ * graphic from the actor's grResTable
+ *
+ * TODO figure out exactly what param means
+ */
+ void updateActorDirection(int actorIndex, int param);
+ /** .text:0040A2E0
+ * If the actor index is invalid, load the default actor,
+ * then call updateActorDirection with a param of 4
+ */
+ void updateActorDirectionDefault(int actorIndex);
+ /** .text:00407260
+ * Check the actor at actorIndex to see if the currently loaded
+ * graphic resource matches the resource at grResTable[5]
+ */
+ bool defaultActorDirectionLoaded(int actorIndex, int grResTableIdx);
private:
AsylumEngine *_vm;
uint8 _sceneIdx;
Commit: 233812dee1f68bfbec056446aeb1057291fb95b0
https://github.com/scummvm/scummvm/commit/233812dee1f68bfbec056446aeb1057291fb95b0
Author: Alex Bevilacqua (alexbevi at gmail.com)
Date: 2021-05-17T15:35:54+02:00
Commit Message:
ASYLUM: Implement a more accurate scene initialization (40E460). Part of this involves setting the actor type, so the lookup table has been added to the scene as actorType[16]. We may want to break some of these static resources into a seperate header file at some point down the road ...
Also start converting some worldstats from uint32 to int32, as i think our signing is wrong for a lot of variables...
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@389 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/scene.cpp
engines/asylum/scene.h
engines/asylum/worldstats.cpp
engines/asylum/worldstats.h
diff --git a/engines/asylum/scene.cpp b/engines/asylum/scene.cpp
index ca3862404d..d6ab7d47be 100644
--- a/engines/asylum/scene.cpp
+++ b/engines/asylum/scene.cpp
@@ -35,7 +35,7 @@ namespace Asylum {
int g_debugPolygons;
int g_debugBarriers;
-Scene::Scene(uint8 sceneIdx, AsylumEngine *vm): _vm(vm) {
+Scene::Scene(uint8 sceneIdx, AsylumEngine *engine): _vm(engine) {
_sceneIdx = sceneIdx;
char filename[10];
@@ -71,15 +71,6 @@ Scene::Scene(uint8 sceneIdx, AsylumEngine *vm): _vm(vm) {
_speech = new Speech(this);
_resPack = new ResourcePack(sceneIdx);
- // FIXME
- // Is there EVER more than one actor enabled for a scene? I can't
- // remember, so I guess a playthrough is in order :P
- // Either way, this is kinda dumb
- for (uint8 i = 0; i < _ws->numActors; i++) {
- _ws->actors[i].setResourcePack(_resPack);
- _ws->actors[i].setScene(this);
- }
-
// TODO
// This will have to be re-initialized elsewhere due to
// the title screen overwriting the font
@@ -101,9 +92,37 @@ Scene::Scene(uint8 sceneIdx, AsylumEngine *vm): _vm(vm) {
g_debugPolygons = 0;
g_debugBarriers = 0;
- // TODO: do all the rest stuffs in sub at address 40E460
- // XXX The player actor index is only ever changed again using
- // changeCharacter()
+ // TODO figure out what field_120 is used for
+ _ws->field_120 = -1;
+
+ for (uint32 a = 0; a < _ws->numActors; a++) {
+ _ws->actors[a].tickValue1 = _vm->getTick();
+ // FIXME This is a hack just to get the current resource
+ // pack and scene into the actor instance(s)
+ _ws->actors[a].setResourcePack(_resPack);
+ _ws->actors[a].setScene(this);
+ }
+
+ // XXX initialize array dword_5433A8[15] to zero
+ // This array doesn't appear to be used anywhere afterwards
+ // though, so skipping this step.
+
+ initialize();
+
+ // XXX
+ // This is a hack for the moment to test out
+ // the new sound queuing functionality
+ for (uint i = 0; i < _ws->numAmbientSound; i++)
+ _vm->sound()->addToSoundBuffer(_ws->ambientSounds[i].resId);
+
+ // TODO: init action list
+
+ _titleLoaded = false;
+}
+
+void Scene::initialize() {
+ _vm->setGameFlag(183);
+
_playerActorIdx = 0;
if (_ws->numBarriers > 0) {
@@ -116,28 +135,32 @@ Scene::Scene(uint8 sceneIdx, AsylumEngine *vm): _vm(vm) {
}
}
+ _cursor->load(_ws->commonRes.curMagnifyingGlass);
+ _cursor->set(0);
+ _cursor->show();
+
_ws->sceneRectIdx = 0;
- _vm->screen()->clearGraphicsInQueue();
+ _vm->screen()->clearScreen();
_ws->motionStatus = 1;
Actor *actor = getActor();
-
actor->boundingRect.bottom = actor->y2;
- actor->boundingRect.right = 2 * actor->x2;
- _ws->boundingRect = Common::Rect(195, 115, 445 - actor->boundingRect.right, 345 - actor->boundingRect.bottom);
+ actor->boundingRect.right = actor->x2 * 2;
- actor->flags |= 1;
- updateActorDirectionDefault(_playerActorIdx);
+ _ws->boundingRect = Common::Rect(195,
+ 115,
+ 445 - actor->boundingRect.right,
+ 345 - actor->boundingRect.bottom);
- actor->x1 -= actor->x2;
- actor->y1 -= actor->y2;
+ actor->flags |= 1;
+ updateActorDirection(_playerActorIdx, 4);
if (_ws->numActors > 1) {
for (uint32 a = 1; a < _ws->numActors; a++) {
Actor *act = &_ws->actors[a];
act->flags |= 1;
act->direction = 1;
- updateActorDirectionDefault(a);
+ updateActorDirection(a, 4);
act->x1 -= act->x2;
act->y1 -= act->y2;
act->boundingRect.bottom = act->y2;
@@ -145,15 +168,30 @@ Scene::Scene(uint8 sceneIdx, AsylumEngine *vm): _vm(vm) {
}
}
- // XXX
- // This is a hack for the moment to test out
- // the new sound queuing functionality
- for (uint i = 0; i < _ws->numAmbientSound; i++)
- _vm->sound()->addToSoundBuffer(_ws->ambientSounds[i].resId);
-
- // TODO: init action list
-
- _titleLoaded = false;
+ // TODO initActionListArrayItem(idx, 0) .text:00401050
+ // XXX not sure why we need to do this again
+ _vm->screen()->clearScreen();
+ // TODO loadTransTables(3, field_64/68/7C)
+ // TODO setTransTable(1)
+ _vm->text()->loadFont(_resPack, _ws->commonRes.font1);
+ // TODO preloadGraphics() .text:00410F10
+ // TODO sound_sub(sceneNumber) .text:0040E750
+ _ws->actorType = actorType[_ws->numChapter];
+ // TODO musicCacheOk check as part of if
+ int musicId = 0;
+ if (_ws->musicCurrentResId != -666 && _ws->numChapter != 1)
+ musicId = _ws->musicResId - 0x7FFE0000;
+ // TODO playMusic(musicId, cfgMusicVolume);
+ _vm->tempTick07 = 1;
+ // TODO sceneRectChangedFlag = 1;
+ actor->tickValue1= _vm->getTick();
+ // XXX This initialization was already done earlier,
+ // so I'm not sure why we need to do it again. Investigate.
+ updateActorDirectionDefault(_playerActorIdx);
+ if (_ws->numChapter == 9) {
+ // TODO changeActorIndex(1); .text:00405140
+ _ws->field_E860C = -1;
+ }
}
Scene::~Scene() {
diff --git a/engines/asylum/scene.h b/engines/asylum/scene.h
index a64cfe13a4..2479ba43e1 100644
--- a/engines/asylum/scene.h
+++ b/engines/asylum/scene.h
@@ -79,7 +79,7 @@ private:
class Scene {
public:
- Scene(uint8 sceneIdx, AsylumEngine *vm);
+ Scene(uint8 sceneIdx, AsylumEngine *engine);
~Scene();
void handleEvent(Common::Event *event, bool doUpdate);
@@ -190,6 +190,11 @@ private:
bool _skipDrawScene;
uint32 _playerActorIdx;
+ /** .text:0040E460
+ * Initialize the current scene
+ */
+ void initialize();
+
void update();
int updateScene();
void updateMouse();
@@ -225,6 +230,8 @@ private:
}; // end of class Scene
+const int actorType[16] = {0, 0, 0, 0, 1, 0, 2, 0, 3, 0, 1, 1, 3, 0, 0, 0};
+
} // end of namespace Asylum
#endif
diff --git a/engines/asylum/worldstats.cpp b/engines/asylum/worldstats.cpp
index 28c2acf471..82514f7577 100644
--- a/engines/asylum/worldstats.cpp
+++ b/engines/asylum/worldstats.cpp
@@ -121,7 +121,7 @@ void WorldStats::load(Common::SeekableReadStream *stream) {
size = stream->readUint32LE();
numEntries = stream->readUint32LE();
- numChapter = stream->readUint32LE();
+ numChapter = stream->readSint32LE();
xLeft = stream->readUint32LE();
yTop = stream->readUint32LE();
@@ -215,9 +215,9 @@ void WorldStats::load(Common::SeekableReadStream *stream) {
numAmbientSound = stream->readUint32LE();
musicStatus = stream->readUint32LE();
- musicCurrentResId = stream->readUint32LE();
+ musicCurrentResId = stream->readSint32LE();
musicFlag = stream->readUint32LE();
- musicResId = stream->readUint32LE();
+ musicResId = stream->readSint32LE();
musicStatusExt = stream->readUint32LE();
for (uint32 a = 0; a < numBarriers; a++) {
diff --git a/engines/asylum/worldstats.h b/engines/asylum/worldstats.h
index b9eb10610d..c6953026de 100644
--- a/engines/asylum/worldstats.h
+++ b/engines/asylum/worldstats.h
@@ -96,7 +96,7 @@ public:
uint32 size;
uint32 numEntries;
- uint32 numChapter;
+ int numChapter;
uint32 xLeft; // scene start x position
uint32 yTop; // scene start y position
Common::Rect boundingRect;
@@ -130,9 +130,9 @@ public:
AmbientSoundItem ambientSounds[15];
uint32 numAmbientSound;
uint32 musicStatus;
- uint32 musicCurrentResId;
+ int musicCurrentResId;
uint32 musicFlag;
- uint32 musicResId;
+ int musicResId;
uint32 musicStatusExt;
// FIXME: Investigate if we need to actually reserve maxsize for this arrays.
Commit: b64ddddf9ee27be31369ebc06174d2ce84514a0d
https://github.com/scummvm/scummvm/commit/b64ddddf9ee27be31369ebc06174d2ce84514a0d
Author: Alex Bevilacqua (alexbevi at gmail.com)
Date: 2021-05-17T15:35:54+02:00
Commit Message:
ASYLUM: cleanup and comments
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@390 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/actor.h
engines/asylum/asylum.h
engines/asylum/scene.cpp
engines/asylum/scene.h
engines/asylum/worldstats.h
diff --git a/engines/asylum/actor.h b/engines/asylum/actor.h
index fa711384ae..95b21bfafc 100644
--- a/engines/asylum/actor.h
+++ b/engines/asylum/actor.h
@@ -35,10 +35,10 @@ class Scene;
class Screen;
struct ActionArea;
+// TODO: check if the names match the actor type
enum ActorType {
- kMax = 0,
- // TODO: check if the names match the actor type
- kSarah = 1,
+ kMax = 0,
+ kSarah = 1,
kCyclops = 2,
kAztec = 3
};
@@ -166,15 +166,11 @@ public:
// FIXME
// I don't really like how this is used in the scene constructor
- void setResourcePack(ResourcePack *res) {
- _resPack = res;
- }
+ void setResourcePack(ResourcePack *res) { _resPack = res; }
- // XXX Hack to get a reference to the parent scene
+ // FIXME Hack to get a reference to the parent scene
// into the actor instance
- void setScene(Scene *scene) {
- _scene = scene;
- }
+ void setScene(Scene *scene) { _scene = scene; }
// OLD METHODS
// TODO ALL of these need to be depreciated in favour
@@ -186,7 +182,6 @@ public:
void drawActor();
void walkTo(uint32 curX, uint32 curY);
-
int currentAction; // TODO depreciate
int32 x;
diff --git a/engines/asylum/asylum.h b/engines/asylum/asylum.h
index f75c0f579e..e2c887943d 100644
--- a/engines/asylum/asylum.h
+++ b/engines/asylum/asylum.h
@@ -101,24 +101,18 @@ public:
*/
uint32 getTick() { return _system->getMillis(); }
+ /**
+ * This is the global tick counter.
+ *
+ * TODO rename?
+ */
uint32 tempTick07;
-
- Video* video() {
- return _video;
- }
- Sound* sound() {
- return _sound;
- }
- Screen* screen() {
- return _screen;
- }
- Scene* scene() {
- return _scene;
- }
- Text* text() {
- return _text;
- }
+ Video* video() { return _video; }
+ Sound* sound() { return _sound; }
+ Screen* screen() { return _screen; }
+ Scene* scene() { return _scene;}
+ Text* text() { return _text; }
private:
void checkForEvent(bool doUpdate);
diff --git a/engines/asylum/scene.cpp b/engines/asylum/scene.cpp
index d6ab7d47be..38d3f3cbc9 100644
--- a/engines/asylum/scene.cpp
+++ b/engines/asylum/scene.cpp
@@ -140,7 +140,7 @@ void Scene::initialize() {
_cursor->show();
_ws->sceneRectIdx = 0;
- _vm->screen()->clearScreen();
+ _vm->screen()->clearScreen(); // XXX was clearGraphicsInQueue()
_ws->motionStatus = 1;
Actor *actor = getActor();
@@ -1651,7 +1651,7 @@ void Scene::debugShowActors() {
}
SceneTitle::SceneTitle(Scene *scene): _scene(scene) {
- _start = _scene->vm()->_system->getMillis();
+ _start = _scene->vm()->getTick();
_bg = new GraphicResource(_scene->_resPack, _scene->_ws->sceneTitleGrResId);
_scene->vm()->screen()->setPalette(_scene->_resPack, _scene->_ws->sceneTitlePalResId);
diff --git a/engines/asylum/scene.h b/engines/asylum/scene.h
index 2479ba43e1..b75d0a48e0 100644
--- a/engines/asylum/scene.h
+++ b/engines/asylum/scene.h
@@ -67,7 +67,6 @@ private:
GraphicResource *_bg;
GraphicResource *_progress;
-
uint32 _start;
uint32 _ticks;
bool _done;
@@ -85,56 +84,25 @@ public:
void handleEvent(Common::Event *event, bool doUpdate);
void enterScene();
- void activate() {
- _isActive = true;
- }
- void deactivate() {
- _isActive = false;
- }
- bool isActive() {
- return _isActive;
- }
- int getSceneIndex() {
- return _sceneIdx;
- }
-
- Cursor* getCursor() {
- return _cursor;
- }
- ResourcePack* getResourcePack() {
- return _resPack;
- }
- ResourcePack* getMusicPack() {
- return _musPack;
- }
- GraphicResource* getGraphicResource(uint32 entry) {
- return new GraphicResource(_resPack, entry);
- }
- BlowUpPuzzle* getBlowUpPuzzle() {
- return _blowUp;
- }
-
- void setBlowUpPuzzle(BlowUpPuzzle* puzzle) {
- _blowUp = puzzle;
- }
+
+ void activate() { _isActive = true; }
+ void deactivate() { _isActive = false; }
+ bool isActive() { return _isActive; }
+ int getSceneIndex() { return _sceneIdx; }
+
+ Cursor* getCursor() { return _cursor; }
+ ResourcePack* getResourcePack() { return _resPack; }
+ ResourcePack* getMusicPack() { return _musPack; }
+ GraphicResource* getGraphicResource(uint32 entry) { return new GraphicResource(_resPack, entry); }
+ BlowUpPuzzle* getBlowUpPuzzle() { return _blowUp;}
+ void setBlowUpPuzzle(BlowUpPuzzle* puzzle) { _blowUp = puzzle; }
void setScenePosition(int x, int y);
- AsylumEngine* vm() {
- return _vm;
- }
- WorldStats* worldstats() {
- return _ws;
- }
- Polygons* polygons() {
- return _polygons;
- }
- ActionList* actions() {
- return _actions;
- }
-
- Speech* speech() {
- return _speech;
- }
+ AsylumEngine* vm() { return _vm; }
+ WorldStats* worldstats() { return _ws; }
+ Polygons* polygons() { return _polygons; }
+ ActionList* actions() { return _actions; }
+ Speech* speech() { return _speech; }
void getActorPosition(Actor *actor, Common::Point *pt);
@@ -182,13 +150,13 @@ private:
GraphicResource *_bgResource;
GraphicFrame *_background;
- bool _titleLoaded;
- bool _walking;
- bool _leftClick;
- bool _rightButton;
- bool _isActive;
- bool _skipDrawScene;
- uint32 _playerActorIdx;
+ bool _titleLoaded;
+ bool _walking;
+ bool _leftClick;
+ bool _rightButton;
+ bool _isActive;
+ bool _skipDrawScene;
+ uint32 _playerActorIdx;
/** .text:0040E460
* Initialize the current scene
diff --git a/engines/asylum/worldstats.h b/engines/asylum/worldstats.h
index c6953026de..a0bc4815d8 100644
--- a/engines/asylum/worldstats.h
+++ b/engines/asylum/worldstats.h
@@ -114,8 +114,7 @@ public:
uint32 field_A8;
uint32 field_AC;
uint32 field_B0;
- uint32 numActors; // Max and all other characters that have
- // own interactions
+ uint32 numActors;
uint32 stereoReversedFlag;
Common::Rect sceneRects[6]; // including scene size rect
uint8 sceneRectIdx;
@@ -156,11 +155,11 @@ public:
bool isBarrierVisible(uint32 idx);
// TODO this needs a better name
bool checkBarrierFlagsCondition(uint32 idx);
+
private:
Scene *_scene;
void load(Common::SeekableReadStream *stream);
-
};
} // end of namespace Asylum
Commit: 3f34ce30305740f623fb35dd53a49a4b5858277e
https://github.com/scummvm/scummvm/commit/3f34ce30305740f623fb35dd53a49a4b5858277e
Author: Alex Bevilacqua (alexbevi at gmail.com)
Date: 2021-05-17T15:35:54+02:00
Commit Message:
ASYLUM: Moved some static resources into a new staticres header.
Simplified font switching in the menu code
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@391 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/actor.h
engines/asylum/asylum.h
engines/asylum/menu.cpp
engines/asylum/menu.h
engines/asylum/scene.h
diff --git a/engines/asylum/actor.h b/engines/asylum/actor.h
index 95b21bfafc..3394addfad 100644
--- a/engines/asylum/actor.h
+++ b/engines/asylum/actor.h
@@ -259,64 +259,6 @@ private:
}; // end of class MainActor
-// Angle Tables used by getAngle()
-const uint8 angleTable01[256] = {
- 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x03, 0x03, 0x03, 0x03,
- 0x04, 0x04, 0x04, 0x04, 0x04, 0x05, 0x05, 0x05, 0x05, 0x06, 0x06, 0x06, 0x06, 0x06, 0x07, 0x07,
- 0x07, 0x07, 0x08, 0x08, 0x08, 0x08, 0x08, 0x09, 0x09, 0x09, 0x09, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A,
- 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0C, 0x0C, 0x0C, 0x0C, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0E, 0x0E,
- 0x0E, 0x0E, 0x0E, 0x0F, 0x0F, 0x0F, 0x0F, 0x10, 0x10, 0x10, 0x10, 0x10, 0x11, 0x11, 0x11, 0x11,
- 0x11, 0x12, 0x12, 0x12, 0x12, 0x12, 0x13, 0x13, 0x13, 0x13, 0x13, 0x14, 0x14, 0x14, 0x14, 0x14,
- 0x15, 0x15, 0x15, 0x15, 0x15, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x17, 0x17, 0x17, 0x17, 0x17,
- 0x18, 0x18, 0x18, 0x18, 0x18, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A,
- 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1D, 0x1D, 0x1D, 0x1D, 0x1D,
- 0x1D, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x20, 0x20, 0x20,
- 0x20, 0x20, 0x20, 0x20, 0x21, 0x21, 0x21, 0x21, 0x21, 0x21, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22,
- 0x23, 0x23, 0x23, 0x23, 0x23, 0x23, 0x23, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x25, 0x25,
- 0x25, 0x25, 0x25, 0x25, 0x25, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x27, 0x27, 0x27, 0x27,
- 0x27, 0x27, 0x27, 0x27, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, 0x29, 0x29, 0x29, 0x29, 0x29,
- 0x29, 0x29, 0x29, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x2B, 0x2B, 0x2B, 0x2B, 0x2B,
- 0x2B, 0x2B, 0x2B, 0x2C, 0x2C, 0x2C, 0x2C, 0x2C, 0x2C, 0x2C, 0x2C, 0x2C, 0x2D, 0x2D, 0x2D, 0x2D
-};
-
-const uint8 angleTable02[256] = {
- 0x00, 0x04, 0x07, 0x0B, 0x0E, 0x11, 0x15, 0x18, 0x1B, 0x1D, 0x20, 0x23, 0x25, 0x27, 0x29, 0x2B,
- 0x2D, 0x2F, 0x30, 0x32, 0x33, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F,
- 0x3F, 0x40, 0x41, 0x41, 0x42, 0x43, 0x43, 0x44, 0x44, 0x45, 0x45, 0x46, 0x46, 0x46, 0x47, 0x47,
- 0x48, 0x48, 0x48, 0x49, 0x49, 0x49, 0x49, 0x4A, 0x4A, 0x4A, 0x4B, 0x4B, 0x4B, 0x4B, 0x4C, 0x4C,
- 0x4C, 0x4C, 0x4C, 0x4D, 0x4D, 0x4D, 0x4D, 0x4D, 0x4D, 0x4E, 0x4E, 0x4E, 0x4E, 0x4E, 0x4E, 0x4F,
- 0x4F, 0x4F, 0x4F, 0x4F, 0x4F, 0x4F, 0x4F, 0x50, 0x50, 0x50, 0x50, 0x50, 0x50, 0x50, 0x50, 0x50,
- 0x51, 0x51, 0x51, 0x51, 0x51, 0x51, 0x51, 0x51, 0x51, 0x51, 0x51, 0x51, 0x52, 0x52, 0x52, 0x52,
- 0x52, 0x52, 0x52, 0x52, 0x52, 0x52, 0x52, 0x52, 0x52, 0x52, 0x53, 0x53, 0x53, 0x53, 0x53, 0x53,
- 0x53, 0x53, 0x53, 0x53, 0x53, 0x53, 0x53, 0x53, 0x53, 0x53, 0x53, 0x53, 0x53, 0x54, 0x54, 0x54,
- 0x54, 0x54, 0x54, 0x54, 0x54, 0x54, 0x54, 0x54, 0x54, 0x54, 0x54, 0x54, 0x54, 0x54, 0x54, 0x54,
- 0x54, 0x54, 0x54, 0x54, 0x54, 0x54, 0x54, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
- 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
- 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x56, 0x56, 0x56, 0x56,
- 0x56, 0x56, 0x56, 0x56, 0x56, 0x56, 0x56, 0x56, 0x56, 0x56, 0x56, 0x56, 0x56, 0x56, 0x56, 0x56,
- 0x56, 0x56, 0x56, 0x56, 0x56, 0x56, 0x56, 0x56, 0x56, 0x56, 0x56, 0x56, 0x56, 0x56, 0x56, 0x56,
- 0x56, 0x56, 0x56, 0x56, 0x56, 0x56, 0x56, 0x56, 0x56, 0x56, 0x56, 0x56, 0x56, 0x56, 0x56, 0x56
-};
-
-const uint8 angleTable03[256] = {
- 0x00, 0x45, 0x63, 0x72, 0x76, 0x79, 0x81, 0x82, 0x83, 0x84, 0x84, 0x85, 0x85, 0x86, 0x86, 0x86,
- 0x86, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88,
- 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89,
- 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89,
- 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89,
- 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89,
- 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89,
- 0x89, 0x89, 0x89, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90,
- 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90,
- 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90,
- 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90,
- 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90,
- 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90,
- 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90,
- 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90,
- 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90
-};
-
} // end of namespace Asylum
#endif
diff --git a/engines/asylum/asylum.h b/engines/asylum/asylum.h
index e2c887943d..5e70617d28 100644
--- a/engines/asylum/asylum.h
+++ b/engines/asylum/asylum.h
@@ -28,6 +28,7 @@
#include "engines/engine.h"
+#include "asylum/staticres.h"
#include "asylum/console.h"
#include "asylum/scene.h"
#include "asylum/menu.h"
diff --git a/engines/asylum/menu.cpp b/engines/asylum/menu.cpp
index 02539924c0..ff54c05ff5 100644
--- a/engines/asylum/menu.cpp
+++ b/engines/asylum/menu.cpp
@@ -30,9 +30,6 @@
namespace Asylum {
-/** This fixes the menu icons text x position on screen */
-const int MenuIconFixedXpos[12] = { 28, 128, 225, 320, 410, 528, 16, 115, 237, 310, 508, 419 };
-
MainMenu::MainMenu(AsylumEngine *vm): _vm(vm) {
_leftClick = false;
_activeIcon = -1;
@@ -44,8 +41,9 @@ MainMenu::MainMenu(AsylumEngine *vm): _vm(vm) {
_creditsTextScroll = 0x1E0 - 30;
_activeMenuScreen = kMainMenu;
_active = false;
- _confGammaLevel = 2;
- _confGameQuality = 5;
+
+ Config.gammaLevel = 2;
+ Config.performance = 5;
_resPack = new ResourcePack(1);
_bgResource = new GraphicResource(_resPack, 0);
@@ -57,7 +55,7 @@ MainMenu::MainMenu(AsylumEngine *vm): _vm(vm) {
_creditsResource = 0;
_creditsFadeResource = 0;
- _vm->text()->loadFont(_resPack, 16); // 0x80010010, yellow font
+ loadFont(kFontYellow);
}
MainMenu::~MainMenu() {
@@ -70,12 +68,31 @@ MainMenu::~MainMenu() {
delete _resPack;
}
+void MainMenu::loadFont(Fonts font) {
+ switch (font) {
+ case kFontBlue:
+ _vm->text()->loadFont(_resPack, 0x80010016);
+ break;
+ case kFontYellow:
+ _vm->text()->loadFont(_resPack, 0x80010010);
+ break;
+ default:
+ error("Unknown Font Colour Specified");
+ }
+}
+
+void MainMenu::switchFont(bool condition) {
+ if (condition)
+ loadFont(kFontYellow);
+ else
+ loadFont(kFontBlue);
+}
+
void MainMenu::openMenu() {
_active = true;
_vm->scene()->deactivate();
- // yellow font
- _vm->text()->loadFont(_resPack, 0x80010010);
+ loadFont(kFontYellow);
// Load the graphics palette
_vm->screen()->setPalette(_resPack, 17);
@@ -254,8 +271,7 @@ void MainMenu::updateMainMenu() {
return;
}
- // yellow font
- _vm->text()->loadFont(_resPack, 0x80010010);
+ loadFont(kFontYellow);
// Icon animation
for (uint32 i = 0; i <= 5; i++) {
@@ -351,25 +367,18 @@ void MainMenu::updateSubMenu() {
}
void MainMenu::updateSubMenuNewGame() {
- // yellow font
- _vm->text()->loadFont(_resPack, 0x80010010);
+ loadFont(kFontYellow);
// begin new game
_vm->text()->drawResTextCentered(10, 100, 620, 0x80000529);
// Yes
- if (_cursor->x() < 247 || _cursor->x() > 247 + _vm->text()->getResTextWidth(0x8000052A) || _cursor->y() < 273 || _cursor->y() > 273 + 24)
- _vm->text()->loadFont(_resPack, 0x80010010); // yellow font
- else
- _vm->text()->loadFont(_resPack, 0x80010016); // blue font
+ switchFont(_cursor->x() < 247 || _cursor->x() > 247 + _vm->text()->getResTextWidth(0x8000052A) || _cursor->y() < 273 || _cursor->y() > 273 + 24);
_vm->text()->setTextPos(247, 273);
_vm->text()->drawResText(0x8000052A);
// No
- if (_cursor->x() < 369 || _cursor->x() > 369 + _vm->text()->getResTextWidth(0x8000052B) || _cursor->y() < 273 || _cursor->y() > 273 + 24)
- _vm->text()->loadFont(_resPack, 0x80010010); // yellow font
- else
- _vm->text()->loadFont(_resPack, 0x80010016); // blue font
+ switchFont(_cursor->x() < 369 || _cursor->x() > 369 + _vm->text()->getResTextWidth(0x8000052B) || _cursor->y() < 273 || _cursor->y() > 273 + 24);
_vm->text()->setTextPos(369, 273);
_vm->text()->drawResText(0x8000052B);
@@ -393,17 +402,17 @@ void MainMenu::updateSubMenuCinematics() {
_vm->text()->drawResText(0x80000549); // Prev Page
if (_cursor->x() >= 280 && _cursor->x() <= 400 && _cursor->y() >= 340 && _cursor->y() <= 360) {
- _vm->text()->loadFont(_resPack, 0x80010016); // blue font
+ loadFont(kFontBlue);
if (_leftClick)
exitSubMenu();
} else {
- _vm->text()->loadFont(_resPack, 0x80010010); // yellow font
+ loadFont(kFontYellow);
}
_vm->text()->setTextPos(280, 340);
_vm->text()->drawResText(0x8000054B); // Main Menu
- _vm->text()->loadFont(_resPack, 0x80010010); // yellow font
+ loadFont(kFontYellow);
_vm->text()->setTextPos(500, 340);
_vm->text()->drawResText(0x8000054A); // Next Page
@@ -414,72 +423,56 @@ void MainMenu::updateSubMenuSettings() {
uint32 sizePlus = _vm->text()->getTextWidth("+");
uint32 sizeMainMenu = _vm->text()->getResTextWidth(0x8000059D);
- // yellow font
- _vm->text()->loadFont(_resPack, 0x80010010);
+ loadFont(kFontYellow);
// Settings
_vm->text()->drawResTextCentered(10, 100, 620, 0x80000598);
// gamma correction
_vm->text()->drawResTextAlignRight(320, 150, 0x80000599);
- if (_cursor->x() < 350 || _cursor->x() > sizeMinus + 350 || _cursor->y() < 150 || _cursor->y() > 174)
- _vm->text()->loadFont(_resPack, 0x80010010); // yellow font
- else
- _vm->text()->loadFont(_resPack, 0x80010016); // blue font
+ switchFont(_cursor->x() < 350 || _cursor->x() > sizeMinus + 350 || _cursor->y() < 150 || _cursor->y() > 174);
_vm->text()->setTextPos(350, 150);
_vm->text()->drawText("-");
- if (_cursor->x() < sizeMinus + 360 || _cursor->x() > sizeMinus + sizePlus + 360 || _cursor->y() < 150 || _cursor->y() > 174)
- _vm->text()->loadFont(_resPack, 0x80010010); // yellow font
- else
- _vm->text()->loadFont(_resPack, 0x80010016); // blue font
+ switchFont(_cursor->x() < sizeMinus + 360 || _cursor->x() > sizeMinus + sizePlus + 360 || _cursor->y() < 150 || _cursor->y() > 174);
_vm->text()->setTextPos(sizeMinus + 360, 150);
_vm->text()->drawText("+");
_vm->text()->setTextPos(sizeMinus + sizePlus + 365, 150);
- _vm->text()->loadFont(_resPack, 0x80010010);
- if (_confGammaLevel) {
- for (uint32 i = 0; i < _confGammaLevel; i++) {
+ loadFont(kFontYellow);
+ if (Config.gammaLevel) {
+ for (uint32 i = 0; i < Config.gammaLevel; i++) {
_vm->text()->drawText("]");
}
- if (_confGammaLevel == 8)
+ if (Config.gammaLevel == 8)
_vm->text()->drawText("*");
} else
_vm->text()->drawResText(0x8000059B);
// performance
- _vm->text()->loadFont(_resPack, 0x80010010);
+ loadFont(kFontYellow);
_vm->text()->drawResTextAlignRight(320, 179, 0x8000059A);
- if (_cursor->x() < 350 || _cursor->x() > sizeMinus + 350 || _cursor->y() < 179 || _cursor->y() > 203)
- _vm->text()->loadFont(_resPack, 0x80010010); // yellow font
- else
- _vm->text()->loadFont(_resPack, 0x80010016); // blue font
+ switchFont(_cursor->x() < 350 || _cursor->x() > sizeMinus + 350 || _cursor->y() < 179 || _cursor->y() > 203);
_vm->text()->setTextPos(350, 179);
_vm->text()->drawText("-");
- if (_cursor->x() < sizeMinus + 360 || _cursor->x() > sizeMinus + sizePlus + 360 || _cursor->y() < 179 || _cursor->y() > 203)
- _vm->text()->loadFont(_resPack, 0x80010010); // yellow font
- else
- _vm->text()->loadFont(_resPack, 0x80010016); // blue font
+ switchFont(_cursor->x() < sizeMinus + 360 || _cursor->x() > sizeMinus + sizePlus + 360 || _cursor->y() < 179 || _cursor->y() > 203);
_vm->text()->setTextPos(sizeMinus + 360, 179);
_vm->text()->drawText("+");
_vm->text()->setTextPos(sizeMinus + sizePlus + 365, 179);
- _vm->text()->loadFont(_resPack, 0x80010010);
- if (_confGameQuality == 5) {
+ loadFont(kFontYellow);
+ if (Config.performance == 5) {
_vm->text()->drawResText(0x8000059C);
} else {
- for (uint32 i = 5; i > _confGameQuality; --i) {
+ for (uint32 i = 5; i > Config.performance; --i) {
_vm->text()->drawText("]");
}
- if (!_confGameQuality)
+ if (!Config.performance)
_vm->text()->drawText("*");
}
// back to main menu
- if (_cursor->x() < 300 || _cursor->x() > 300 + sizeMainMenu || _cursor->y() < 340 || _cursor->y() > 340 + 24)
- _vm->text()->loadFont(_resPack, 0x80010010); // yellow font
- else
- _vm->text()->loadFont(_resPack, 0x80010016); // blue font
+ switchFont(_cursor->x() < 300 || _cursor->x() > 300 + sizeMainMenu || _cursor->y() < 340 || _cursor->y() > 340 + 24);
_vm->text()->setTextPos(300, 340);
_vm->text()->drawResText(0x8000059D);
@@ -493,30 +486,30 @@ void MainMenu::updateSubMenuSettings() {
// gamma level minus
if (_cursor->x() >= 350 && _cursor->x() <= sizeMinus + 350 && _cursor->y() >= 150 && _cursor->y() <= 174) {
- if (_confGammaLevel) {
- _confGammaLevel -= 1;
+ if (Config.gammaLevel) {
+ Config.gammaLevel -= 1;
// TODO: setResGammaLevel(0x80010011, 0);
}
}
// gamma level plus
if (_cursor->x() >= sizeMinus + 360 && _cursor->x() <= sizeMinus + sizePlus + 360 && _cursor->y() >= 150 && _cursor->y() <= 174) {
- if (_confGammaLevel < 8) {
- _confGammaLevel += 1;
+ if (Config.gammaLevel < 8) {
+ Config.gammaLevel += 1;
// TODO: setResGammaLevel(0x80010011, 0);
}
}
// performance minus
if (_cursor->x() >= 350 && _cursor->x() <= sizeMinus + 350 && _cursor->y() >= 179 && _cursor->y() <= 203) {
- if (_confGameQuality) {
- _confGameQuality -= 1;
+ if (Config.performance) {
+ Config.performance -= 1;
// TODO: change quality settings
}
}
// performance plus
if (_cursor->x() >= sizeMinus + 360 && _cursor->x() <= sizeMinus + sizePlus + 360 && _cursor->y() >= 179 && _cursor->y() <= 203) {
- if (_confGameQuality < 5) {
- _confGameQuality += 1;
+ if (Config.performance < 5) {
+ Config.performance += 1;
// TODO: change quality settings
}
}
@@ -524,25 +517,18 @@ void MainMenu::updateSubMenuSettings() {
}
void MainMenu::updateSubMenuQuitGame() {
- // yellow font
- _vm->text()->loadFont(_resPack, 0x80010010);
+ loadFont(kFontYellow);
// begin new game
_vm->text()->drawResTextCentered(10, 100, 620, 0x80000580);
// Yes
- if (_cursor->x() < 247 || _cursor->x() > 247 + _vm->text()->getResTextWidth(0x80000581) || _cursor->y() < 273 || _cursor->y() > 273 + 24)
- _vm->text()->loadFont(_resPack, 0x80010010); // yellow font
- else
- _vm->text()->loadFont(_resPack, 0x80010016); // blue font
+ switchFont(_cursor->x() < 247 || _cursor->x() > 247 + _vm->text()->getResTextWidth(0x80000581) || _cursor->y() < 273 || _cursor->y() > 273 + 24);
_vm->text()->setTextPos(247, 273);
_vm->text()->drawResText(0x80000581);
// No
- if (_cursor->x() < 369 || _cursor->x() > 369 + _vm->text()->getResTextWidth(0x80000582) || _cursor->y() < 273 || _cursor->y() > 273 + 24)
- _vm->text()->loadFont(_resPack, 0x80010010); // yellow font
- else
- _vm->text()->loadFont(_resPack, 0x80010016); // blue font
+ switchFont(_cursor->x() < 369 || _cursor->x() > 369 + _vm->text()->getResTextWidth(0x80000582) || _cursor->y() < 273 || _cursor->y() > 273 + 24);
_vm->text()->setTextPos(369, 273);
_vm->text()->drawResText(0x80000582);
diff --git a/engines/asylum/menu.h b/engines/asylum/menu.h
index 89bd458e9d..2180b4a930 100644
--- a/engines/asylum/menu.h
+++ b/engines/asylum/menu.h
@@ -85,6 +85,11 @@ private:
kMainMenu = 12
};
+ enum Fonts {
+ kFontBlue,
+ kFontYellow
+ };
+
Common::Event *_ev;
Cursor *_cursor;
@@ -98,10 +103,6 @@ private:
bool _leftClick;
bool _active;
- // FIXME this shouldnt be here. Need a proper config place
- uint32 _confGammaLevel;
- uint32 _confGameQuality;
-
MenuScreen _activeMenuScreen;
ResourcePack *_resPack;
GraphicResource *_bgResource;
@@ -110,6 +111,13 @@ private:
GraphicResource *_creditsResource;
GraphicResource *_creditsFadeResource;
+ void loadFont(Fonts font);
+ /**
+ * Determine which font colour to use. If the condition is true,
+ * load kFontYellow, if false, load kFontBlue
+ */
+ void switchFont(bool condition);
+
void updateEyesAnimation();
void updateMainMenu();
diff --git a/engines/asylum/scene.h b/engines/asylum/scene.h
index b75d0a48e0..f6d1c03d16 100644
--- a/engines/asylum/scene.h
+++ b/engines/asylum/scene.h
@@ -198,8 +198,6 @@ private:
}; // end of class Scene
-const int actorType[16] = {0, 0, 0, 0, 1, 0, 2, 0, 3, 0, 1, 1, 3, 0, 0, 0};
-
} // end of namespace Asylum
#endif
Commit: 63b9cfeb0aad360da498290240cbd1ae98b93844
https://github.com/scummvm/scummvm/commit/63b9cfeb0aad360da498290240cbd1ae98b93844
Author: Alex Bevilacqua (alexbevi at gmail.com)
Date: 2021-05-17T15:35:55+02:00
Commit Message:
ASYLUM: commit staticres.h (forgot to do an svn add :P)
svn props for speech.cpp/h
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@392 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
A engines/asylum/staticres.h
engines/asylum/speech.cpp
engines/asylum/speech.h
diff --git a/engines/asylum/speech.cpp b/engines/asylum/speech.cpp
index f489d889f3..fe2f2b3f22 100644
--- a/engines/asylum/speech.cpp
+++ b/engines/asylum/speech.cpp
@@ -1,156 +1,156 @@
-/* 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.
- *
- * $URL$
- * $Id$
- *
- */
-
-#include "asylum/speech.h"
-#include "asylum/actor.h"
-#include "asylum/config.h"
-#include "asylum/text.h"
-
-namespace Asylum {
-
-Speech::Speech(Scene *scene): _scene(scene) {
- _tick = _scene->vm()->getTick();
- _soundResIdx = 0;
- _textResIdx = 0;
-}
-
-Speech::~Speech() {
- // TODO Auto-generated destructor stub
-}
-
-uint32 Speech::play(uint32 speechIdx) {
- uint32 soundResIdx = 0;
-
- switch (_scene->worldstats()->actorType) {
- case kMax: {
- uint32 soundResIdx2 = speechIdx;
- uint32 textResIdx = speechIdx;
-
- if (speechIdx >= 259) {
- soundResIdx2 -= 9;
- textResIdx -= 9;
- }
-
- soundResIdx = soundResIdx2 - 0x7FFD0000;
- // setup the right index for sound and text
- setPlayerSpeech(soundResIdx, textResIdx - 0x7FFFFFAD);
- }
- break;
- // TODO: check if actor type is right for the following cases
- case kSarah: {
- soundResIdx = speechIdx - 0x7FFBF879;
- setPlayerSpeech(soundResIdx, speechIdx - 0x7FFFFDB6);
- }
- break;
- case kCyclops: {
- soundResIdx = speechIdx - 0x7FFBF7DC;
- setPlayerSpeech(soundResIdx, speechIdx - 0x7FFFFD19);
- }
- break;
- case kAztec: {
- soundResIdx = speechIdx - 0x7FFBF746;
- setPlayerSpeech(soundResIdx, speechIdx - 0x7FFFFC83);
- }
- break;
- default:
- soundResIdx = 0;
- break;
- }
-
- return soundResIdx;
-}
-
-void Speech::setPlayerSpeech(uint32 soundResIdx, uint32 textResIdx) {
- if (soundResIdx) {
- if (_scene->vm()->sound()->isPlaying(soundResIdx)) {
- _scene->vm()->sound()->stopSound(soundResIdx);
- }
- }
-
- _soundResIdx = soundResIdx;
- _textResIdx = textResIdx;
-
- prepareSpeech();
-}
-
-void Speech::prepareSpeech() {
- uint32 startTick = _scene->vm()->getTick();
-
- if (_soundResIdx) {
- if (!_scene->vm()->sound()->isPlaying(_soundResIdx)/* || _tick && startTick >= _tick*/) {
- processSpeech();
- }
-
- if (Config.showEncounterSubtitles) {
- int16 check = 0;
- /*Common::Point *pt;
- _scene->getActorPosition(_scene->getActor(), pt);
-
- check = pt->y < 240;
- check = pt->y >= 240;*/
- uint32 posY = ((check - 1) & 0x118) + 40;
-
- _scene->vm()->text()->loadFont(_scene->getResourcePack(), _scene->worldstats()->commonRes.font3);
- _scene->vm()->text()->drawText(20, posY, _textDataPos);
-
- _scene->vm()->text()->loadFont(_scene->getResourcePack(), _scene->worldstats()->commonRes.font1);
- _scene->vm()->text()->drawText(20, posY, _textData);
- }
- }
-}
-
-void Speech::processSpeech() {
- char * txt;
-
- _tick = 0;
-
- txt = _scene->vm()->text()->getResText(_textResIdx);
-
- if (*(txt + strlen((const char *)txt) - 2) == 1) {
- _textResIdx = 0;
- _textData = 0;
- _textDataPos = 0;
- } else {
- if (*txt == '{') {
- _textData = txt + 3;
- _textDataPos = 0;
-
- _scene->vm()->text()->loadFont(_scene->getResourcePack(), _scene->worldstats()->commonRes.font1);
- _scene->vm()->sound()->playSpeech(_soundResIdx);
- } else {
- _textData = 0;
- _textDataPos = txt;
-
- if (*txt == '/') {
- _textDataPos = txt + 2;
- }
-
- _scene->vm()->text()->loadFont(_scene->getResourcePack(), _scene->worldstats()->commonRes.font3);
- _scene->vm()->sound()->playSpeech(_soundResIdx);
- }
- }
-}
-
-} // end of namespace Asylum
+/* 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.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#include "asylum/speech.h"
+#include "asylum/actor.h"
+#include "asylum/config.h"
+#include "asylum/text.h"
+
+namespace Asylum {
+
+Speech::Speech(Scene *scene): _scene(scene) {
+ _tick = _scene->vm()->getTick();
+ _soundResIdx = 0;
+ _textResIdx = 0;
+}
+
+Speech::~Speech() {
+ // TODO Auto-generated destructor stub
+}
+
+uint32 Speech::play(uint32 speechIdx) {
+ uint32 soundResIdx = 0;
+
+ switch (_scene->worldstats()->actorType) {
+ case kMax: {
+ uint32 soundResIdx2 = speechIdx;
+ uint32 textResIdx = speechIdx;
+
+ if (speechIdx >= 259) {
+ soundResIdx2 -= 9;
+ textResIdx -= 9;
+ }
+
+ soundResIdx = soundResIdx2 - 0x7FFD0000;
+ // setup the right index for sound and text
+ setPlayerSpeech(soundResIdx, textResIdx - 0x7FFFFFAD);
+ }
+ break;
+ // TODO: check if actor type is right for the following cases
+ case kSarah: {
+ soundResIdx = speechIdx - 0x7FFBF879;
+ setPlayerSpeech(soundResIdx, speechIdx - 0x7FFFFDB6);
+ }
+ break;
+ case kCyclops: {
+ soundResIdx = speechIdx - 0x7FFBF7DC;
+ setPlayerSpeech(soundResIdx, speechIdx - 0x7FFFFD19);
+ }
+ break;
+ case kAztec: {
+ soundResIdx = speechIdx - 0x7FFBF746;
+ setPlayerSpeech(soundResIdx, speechIdx - 0x7FFFFC83);
+ }
+ break;
+ default:
+ soundResIdx = 0;
+ break;
+ }
+
+ return soundResIdx;
+}
+
+void Speech::setPlayerSpeech(uint32 soundResIdx, uint32 textResIdx) {
+ if (soundResIdx) {
+ if (_scene->vm()->sound()->isPlaying(soundResIdx)) {
+ _scene->vm()->sound()->stopSound(soundResIdx);
+ }
+ }
+
+ _soundResIdx = soundResIdx;
+ _textResIdx = textResIdx;
+
+ prepareSpeech();
+}
+
+void Speech::prepareSpeech() {
+ uint32 startTick = _scene->vm()->getTick();
+
+ if (_soundResIdx) {
+ if (!_scene->vm()->sound()->isPlaying(_soundResIdx)/* || _tick && startTick >= _tick*/) {
+ processSpeech();
+ }
+
+ if (Config.showEncounterSubtitles) {
+ int16 check = 0;
+ /*Common::Point *pt;
+ _scene->getActorPosition(_scene->getActor(), pt);
+
+ check = pt->y < 240;
+ check = pt->y >= 240;*/
+ uint32 posY = ((check - 1) & 0x118) + 40;
+
+ _scene->vm()->text()->loadFont(_scene->getResourcePack(), _scene->worldstats()->commonRes.font3);
+ _scene->vm()->text()->drawText(20, posY, _textDataPos);
+
+ _scene->vm()->text()->loadFont(_scene->getResourcePack(), _scene->worldstats()->commonRes.font1);
+ _scene->vm()->text()->drawText(20, posY, _textData);
+ }
+ }
+}
+
+void Speech::processSpeech() {
+ char * txt;
+
+ _tick = 0;
+
+ txt = _scene->vm()->text()->getResText(_textResIdx);
+
+ if (*(txt + strlen((const char *)txt) - 2) == 1) {
+ _textResIdx = 0;
+ _textData = 0;
+ _textDataPos = 0;
+ } else {
+ if (*txt == '{') {
+ _textData = txt + 3;
+ _textDataPos = 0;
+
+ _scene->vm()->text()->loadFont(_scene->getResourcePack(), _scene->worldstats()->commonRes.font1);
+ _scene->vm()->sound()->playSpeech(_soundResIdx);
+ } else {
+ _textData = 0;
+ _textDataPos = txt;
+
+ if (*txt == '/') {
+ _textDataPos = txt + 2;
+ }
+
+ _scene->vm()->text()->loadFont(_scene->getResourcePack(), _scene->worldstats()->commonRes.font3);
+ _scene->vm()->sound()->playSpeech(_soundResIdx);
+ }
+ }
+}
+
+} // end of namespace Asylum
diff --git a/engines/asylum/speech.h b/engines/asylum/speech.h
index 946f235c25..ca149c37a7 100644
--- a/engines/asylum/speech.h
+++ b/engines/asylum/speech.h
@@ -1,80 +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.
- *
- * $URL$
- * $Id$
- *
- */
-
-#ifndef ASYLUM_SPEECH_H_
-#define ASYLUM_SPEECH_H_
-
-#include "asylum/respack.h"
-#include "asylum/scene.h"
-
-namespace Asylum {
-
-class Speech {
-public:
- Speech(Scene *scene);
- virtual ~Speech();
-
- uint32 _soundResIdx;
- uint32 _textResIdx;
-
- /** .text:00414810
- * Play player speech
- * @param speechIdx speech index (used for sound and text resources)
- * @return correct resourceId
- */
- uint32 play(uint32 speechIdx);
-
- /** .text:004146D0
- * Set speech for different player type
- * @param soundResIdx sound resource id
- * @param textResIdx text resource id
- */
- void setPlayerSpeech(uint32 soundResIdx, uint32 textResIdx);
-
- /** .text:004144C0
- * Prepare speech to play
- * - Process sound speech and draws dialogue in screen
- */
- void prepareSpeech();
-private:
- Scene *_scene;
-
- uint32 _tick;
-
- char * _textData;
- char * _textDataPos;
-
- /** .text:00414580
- */
- void processSpeech();
-
- // This function was cutoff since it doesn't make any sence using it. Its here for address information only
- /** .text:00414630 void playSpeech(uint32 textResIdx, uint32 fontResIdx); */
-
-}; // end of class Speech
-
-} // end of namespace Asylum
-
-#endif
+/* 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.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#ifndef ASYLUM_SPEECH_H_
+#define ASYLUM_SPEECH_H_
+
+#include "asylum/respack.h"
+#include "asylum/scene.h"
+
+namespace Asylum {
+
+class Speech {
+public:
+ Speech(Scene *scene);
+ virtual ~Speech();
+
+ uint32 _soundResIdx;
+ uint32 _textResIdx;
+
+ /** .text:00414810
+ * Play player speech
+ * @param speechIdx speech index (used for sound and text resources)
+ * @return correct resourceId
+ */
+ uint32 play(uint32 speechIdx);
+
+ /** .text:004146D0
+ * Set speech for different player type
+ * @param soundResIdx sound resource id
+ * @param textResIdx text resource id
+ */
+ void setPlayerSpeech(uint32 soundResIdx, uint32 textResIdx);
+
+ /** .text:004144C0
+ * Prepare speech to play
+ * - Process sound speech and draws dialogue in screen
+ */
+ void prepareSpeech();
+private:
+ Scene *_scene;
+
+ uint32 _tick;
+
+ char * _textData;
+ char * _textDataPos;
+
+ /** .text:00414580
+ */
+ void processSpeech();
+
+ // This function was cutoff since it doesn't make any sence using it. Its here for address information only
+ /** .text:00414630 void playSpeech(uint32 textResIdx, uint32 fontResIdx); */
+
+}; // end of class Speech
+
+} // end of namespace Asylum
+
+#endif
diff --git a/engines/asylum/staticres.h b/engines/asylum/staticres.h
new file mode 100644
index 0000000000..b9a0be7d03
--- /dev/null
+++ b/engines/asylum/staticres.h
@@ -0,0 +1,98 @@
+/* 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.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#ifndef ASYLUM_STATICRES_H_
+#define ASYLUM_STATICRES_H_
+
+namespace Asylum {
+
+/** This fixes the menu icons text x position on screen */
+const int MenuIconFixedXpos[12] = { 28, 128, 225, 320, 410, 528, 16, 115, 237, 310, 508, 419 };
+
+/** Default Actor Indices by Scene */
+const int actorType[16] = {0, 0, 0, 0, 1, 0, 2, 0, 3, 0, 1, 1, 3, 0, 0, 0};
+
+// Angle Tables used by getAngle()
+const uint8 angleTable01[256] = {
+ 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x03, 0x03, 0x03, 0x03,
+ 0x04, 0x04, 0x04, 0x04, 0x04, 0x05, 0x05, 0x05, 0x05, 0x06, 0x06, 0x06, 0x06, 0x06, 0x07, 0x07,
+ 0x07, 0x07, 0x08, 0x08, 0x08, 0x08, 0x08, 0x09, 0x09, 0x09, 0x09, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A,
+ 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0C, 0x0C, 0x0C, 0x0C, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0E, 0x0E,
+ 0x0E, 0x0E, 0x0E, 0x0F, 0x0F, 0x0F, 0x0F, 0x10, 0x10, 0x10, 0x10, 0x10, 0x11, 0x11, 0x11, 0x11,
+ 0x11, 0x12, 0x12, 0x12, 0x12, 0x12, 0x13, 0x13, 0x13, 0x13, 0x13, 0x14, 0x14, 0x14, 0x14, 0x14,
+ 0x15, 0x15, 0x15, 0x15, 0x15, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x17, 0x17, 0x17, 0x17, 0x17,
+ 0x18, 0x18, 0x18, 0x18, 0x18, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A,
+ 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1D, 0x1D, 0x1D, 0x1D, 0x1D,
+ 0x1D, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x21, 0x21, 0x21, 0x21, 0x21, 0x21, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22,
+ 0x23, 0x23, 0x23, 0x23, 0x23, 0x23, 0x23, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x25, 0x25,
+ 0x25, 0x25, 0x25, 0x25, 0x25, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x27, 0x27, 0x27, 0x27,
+ 0x27, 0x27, 0x27, 0x27, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, 0x29, 0x29, 0x29, 0x29, 0x29,
+ 0x29, 0x29, 0x29, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x2B, 0x2B, 0x2B, 0x2B, 0x2B,
+ 0x2B, 0x2B, 0x2B, 0x2C, 0x2C, 0x2C, 0x2C, 0x2C, 0x2C, 0x2C, 0x2C, 0x2C, 0x2D, 0x2D, 0x2D, 0x2D
+};
+
+const uint8 angleTable02[256] = {
+ 0x00, 0x04, 0x07, 0x0B, 0x0E, 0x11, 0x15, 0x18, 0x1B, 0x1D, 0x20, 0x23, 0x25, 0x27, 0x29, 0x2B,
+ 0x2D, 0x2F, 0x30, 0x32, 0x33, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F,
+ 0x3F, 0x40, 0x41, 0x41, 0x42, 0x43, 0x43, 0x44, 0x44, 0x45, 0x45, 0x46, 0x46, 0x46, 0x47, 0x47,
+ 0x48, 0x48, 0x48, 0x49, 0x49, 0x49, 0x49, 0x4A, 0x4A, 0x4A, 0x4B, 0x4B, 0x4B, 0x4B, 0x4C, 0x4C,
+ 0x4C, 0x4C, 0x4C, 0x4D, 0x4D, 0x4D, 0x4D, 0x4D, 0x4D, 0x4E, 0x4E, 0x4E, 0x4E, 0x4E, 0x4E, 0x4F,
+ 0x4F, 0x4F, 0x4F, 0x4F, 0x4F, 0x4F, 0x4F, 0x50, 0x50, 0x50, 0x50, 0x50, 0x50, 0x50, 0x50, 0x50,
+ 0x51, 0x51, 0x51, 0x51, 0x51, 0x51, 0x51, 0x51, 0x51, 0x51, 0x51, 0x51, 0x52, 0x52, 0x52, 0x52,
+ 0x52, 0x52, 0x52, 0x52, 0x52, 0x52, 0x52, 0x52, 0x52, 0x52, 0x53, 0x53, 0x53, 0x53, 0x53, 0x53,
+ 0x53, 0x53, 0x53, 0x53, 0x53, 0x53, 0x53, 0x53, 0x53, 0x53, 0x53, 0x53, 0x53, 0x54, 0x54, 0x54,
+ 0x54, 0x54, 0x54, 0x54, 0x54, 0x54, 0x54, 0x54, 0x54, 0x54, 0x54, 0x54, 0x54, 0x54, 0x54, 0x54,
+ 0x54, 0x54, 0x54, 0x54, 0x54, 0x54, 0x54, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
+ 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
+ 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x56, 0x56, 0x56, 0x56,
+ 0x56, 0x56, 0x56, 0x56, 0x56, 0x56, 0x56, 0x56, 0x56, 0x56, 0x56, 0x56, 0x56, 0x56, 0x56, 0x56,
+ 0x56, 0x56, 0x56, 0x56, 0x56, 0x56, 0x56, 0x56, 0x56, 0x56, 0x56, 0x56, 0x56, 0x56, 0x56, 0x56,
+ 0x56, 0x56, 0x56, 0x56, 0x56, 0x56, 0x56, 0x56, 0x56, 0x56, 0x56, 0x56, 0x56, 0x56, 0x56, 0x56
+};
+
+const uint8 angleTable03[256] = {
+ 0x00, 0x45, 0x63, 0x72, 0x76, 0x79, 0x81, 0x82, 0x83, 0x84, 0x84, 0x85, 0x85, 0x86, 0x86, 0x86,
+ 0x86, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88,
+ 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89,
+ 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89,
+ 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89,
+ 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89,
+ 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89,
+ 0x89, 0x89, 0x89, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90,
+ 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90,
+ 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90,
+ 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90,
+ 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90,
+ 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90,
+ 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90,
+ 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90,
+ 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90
+};
+
+
+} // end of namespace Asylum
+
+#endif /* ASYLUM_STATICRES_H_ */
Commit: a33b9e677acd7f31041ede33a7face36d5cb99bb
https://github.com/scummvm/scummvm/commit/a33b9e677acd7f31041ede33a7face36d5cb99bb
Author: Alex Bevilacqua (alexbevi at gmail.com)
Date: 2021-05-17T15:35:55+02:00
Commit Message:
ASYLUM: Added the ActionArray type. Slowly working on implementing this, but it looks to be what ties the actionlist to the character.
Also started implementing more standardized music handling.
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@393 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
A engines/asylum/actionarray.cpp
A engines/asylum/actionarray.h
engines/asylum/actionlist.cpp
engines/asylum/actionlist.h
engines/asylum/asylum.cpp
engines/asylum/asylum.h
engines/asylum/module.mk
engines/asylum/scene.cpp
engines/asylum/scene.h
engines/asylum/sound.cpp
engines/asylum/sound.h
diff --git a/engines/asylum/actionarray.cpp b/engines/asylum/actionarray.cpp
new file mode 100644
index 0000000000..a60e9816f7
--- /dev/null
+++ b/engines/asylum/actionarray.cpp
@@ -0,0 +1,76 @@
+/* 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.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#include "asylum/actionarray.h"
+
+namespace Asylum {
+
+ActionArray::ActionArray(AsylumEngine *engine): _vm(engine) {
+ _actionFlag = false;
+ reset();
+}
+
+ActionArray::~ActionArray() {
+
+}
+
+void ActionArray::reset() {
+ memset(&_items, 0, sizeof(ActionStruct));
+ for (int i = 0; i < 10; i++)
+ _items.entries[i].actionListIndex = -1;
+}
+
+void ActionArray::initItem(ActionDefinitions *command, int actionIndex, int actorIndex) {
+ // TODO properly define what actionFlag is actually for.
+ // It appears to remain false 99% of the time, so I'm guessing
+ // it's a "skip processing" flag.
+ if (!_actionFlag) {
+ int i;
+ // iterate through the availble entry slots to determine
+ // the next available slot
+ for (i = 1; i < 10; i++) {
+ if (_items.entries[i].actionListIndex == -1)
+ break;
+ }
+
+ command->counter = 0;
+
+ _items.entries[i].field_10 = 0;
+ _items.entries[i].field_C = 0;
+
+ if (_items.count) {
+ _items.entries[_items.field_CC].field_C = i ;
+ _items.entries[0].field_10 = _items.field_CC;
+ } else {
+ _items.count = i;
+ }
+ _items.field_CC = i;
+ _items.entries[0].actionListIndex = actionIndex;
+ _items.entries[0].actionListItemIndex = 0;
+ _items.entries[0].actorIndex = actorIndex;
+ }
+}
+
+} // end of namespace Asylum
diff --git a/engines/asylum/actionarray.h b/engines/asylum/actionarray.h
new file mode 100644
index 0000000000..38b6820f3b
--- /dev/null
+++ b/engines/asylum/actionarray.h
@@ -0,0 +1,83 @@
+/* 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.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#ifndef ASYLUM_ACTIONARRAY_H_
+#define ASYLUM_ACTIONARRAY_H_
+
+#include "asylum/asylum.h"
+#include "common/array.h"
+
+namespace Asylum {
+
+typedef struct ActionItem {
+ int actionListIndex;
+ int actionListItemIndex;
+ int actorIndex;
+ int field_C;
+ int field_10;
+
+} ActionItem;
+
+typedef struct ActionStruct {
+ ActionItem entries[10];
+ int count;
+ int field_CC;
+
+} ActionStruct;
+
+struct ActionDefinitions;
+
+class ActionArray {
+public:
+ ActionArray(AsylumEngine *engine);
+ virtual ~ActionArray();
+
+ /** .text:00401020
+ * Reset the _actionArray entries to their
+ * default values
+ */
+ void reset();
+
+ /** .text:00401050
+ * Initialize the script element at actionIndex to
+ * the actor at actorIndex
+ *
+ * FIXME passing in a reference to the command at actionIndex
+ * to do a quick update.
+ */
+ void initItem(ActionDefinitions *command, int actionIndex, int actorIndex);
+
+ void setActionFlag(bool value) { _actionFlag = value; }
+
+private:
+ bool _actionFlag;
+ ActionStruct _items;
+ AsylumEngine *_vm;
+
+}; // end of class ActionArray
+
+} // end of namespace Asylum
+
+#endif /* ASYLUM_ACTIONARRAY_H_ */
diff --git a/engines/asylum/actionlist.cpp b/engines/asylum/actionlist.cpp
index 4f6bb8f5c5..ebc6be8b46 100644
--- a/engines/asylum/actionlist.cpp
+++ b/engines/asylum/actionlist.cpp
@@ -104,8 +104,8 @@ static const AsylumFunction function_map[] = {
/*0x2C*/ MAPFUNC("k_unk2C_ActorSub", k_unk2C_ActorSub),
/*0x2D*/ MAPFUNC("kPlayMovie", kPlayMovie),
/*0x2E*/ MAPFUNC("kStopAllBarriersSounds", kStopAllBarriersSounds),
- /*0x2F*/ MAPFUNC("kSetActionFlag01", kSetActionFlag01),
- /*0x30*/ MAPFUNC("kClearActionFlag01", kClearActionFlag01),
+ /*0x2F*/ MAPFUNC("kSetActionFlag", kSetActionFlag),
+ /*0x30*/ MAPFUNC("kClearActionFlag", kClearActionFlag),
/*0x31*/ MAPFUNC("kResetSceneRect", kResetSceneRect),
/*0x32*/ MAPFUNC("kChangeMusicById", kChangeMusicById),
/*0x33*/ MAPFUNC("kStopMusic", kStopMusic),
@@ -808,11 +808,13 @@ int kStopAllBarriersSounds(ActionCommand *cmd, Scene *scn) {
return -1;
}
-int kSetActionFlag01(ActionCommand *cmd, Scene *scn) {
- return -2;
+int kSetActionFlag(ActionCommand *cmd, Scene *scn) {
+ scn->vm()->actionarray()->setActionFlag(true);
+ return 0;
}
-int kClearActionFlag01(ActionCommand *cmd, Scene *scn) {
- return -2;
+int kClearActionFlag(ActionCommand *cmd, Scene *scn) {
+ scn->vm()->actionarray()->setActionFlag(false);
+ return 0;
}
int kResetSceneRect(ActionCommand *cmd, Scene *scn) {
return -2;
diff --git a/engines/asylum/actionlist.h b/engines/asylum/actionlist.h
index d5f771f0a8..d8b2ae3983 100644
--- a/engines/asylum/actionlist.h
+++ b/engines/asylum/actionlist.h
@@ -57,7 +57,6 @@ typedef struct ActionDefinitions {
uint32 field_1BAC;
uint32 field_1BB0;
uint32 counter;
-
} ActionDefinitions;
class ActionList {
@@ -88,6 +87,10 @@ public:
ActionDefinitions* getScript() {
return _currentScript;
}
+
+ /** .text:00402120
+ * Process the current script
+ */
int process();
void processActionListSub02(ActionDefinitions* script, ActionCommand* command, int a4);
@@ -149,8 +152,8 @@ int kChangeScene(ActionCommand *cmd, Scene *scn);
int k_unk2C_ActorSub(ActionCommand *cmd, Scene *scn);
int kPlayMovie(ActionCommand *cmd, Scene *scn);
int kStopAllBarriersSounds(ActionCommand *cmd, Scene *scn);
-int kSetActionFlag01(ActionCommand *cmd, Scene *scn);
-int kClearActionFlag01(ActionCommand *cmd, Scene *scn);
+int kSetActionFlag(ActionCommand *cmd, Scene *scn);
+int kClearActionFlag(ActionCommand *cmd, Scene *scn);
int kResetSceneRect(ActionCommand *cmd, Scene *scn);
int kChangeMusicById(ActionCommand *cmd, Scene *scn);
int kStopMusic(ActionCommand *cmd, Scene *scn);
diff --git a/engines/asylum/asylum.cpp b/engines/asylum/asylum.cpp
index 84649617f5..6c084e3a32 100644
--- a/engines/asylum/asylum.cpp
+++ b/engines/asylum/asylum.cpp
@@ -55,8 +55,6 @@ AsylumEngine::AsylumEngine(OSystem *system, Common::Language language)
Common::enableDebugChannel("Scripts");
g_eventRec.registerRandomSource(_rnd, "asylum");
-
- memset(_gameFlags, 0, 1512);
}
AsylumEngine::~AsylumEngine() {
@@ -70,6 +68,7 @@ AsylumEngine::~AsylumEngine() {
delete _screen;
delete _encounter;
delete _text;
+ delete _actionArray;
}
Common::Error AsylumEngine::run() {
@@ -95,6 +94,9 @@ Common::Error AsylumEngine::init() {
_introPlaying = false;
+ memset(_gameFlags, 0, 1512);
+ _actionArray = new ActionArray(this);
+
return Common::kNoError;
}
diff --git a/engines/asylum/asylum.h b/engines/asylum/asylum.h
index 5e70617d28..5e8f08c01a 100644
--- a/engines/asylum/asylum.h
+++ b/engines/asylum/asylum.h
@@ -37,6 +37,7 @@
#include "asylum/video.h"
#include "asylum/blowuppuzzle.h"
#include "asylum/encounters.h"
+#include "asylum/actionarray.h"
namespace Asylum {
@@ -66,6 +67,7 @@ class Screen;
class Sound;
class Video;
class Encounter;
+class ActionArray;
enum kDebugLevels {
kDebugLevelMain = 1 << 0,
@@ -85,7 +87,9 @@ public:
AsylumEngine(OSystem *system, Common::Language language);
virtual ~AsylumEngine();
- // Engine APIs
+ /** .text:0040F430
+ * Initalize the game environment
+ */
Common::Error init();
Common::Error go();
virtual Common::Error run();
@@ -114,6 +118,7 @@ public:
Screen* screen() { return _screen; }
Scene* scene() { return _scene;}
Text* text() { return _text; }
+ ActionArray *actionarray() { return _actionArray; }
private:
void checkForEvent(bool doUpdate);
@@ -136,6 +141,8 @@ private:
Text *_text;
Encounter *_encounter;
+ ActionArray *_actionArray;
+
int _gameFlags[1512];
friend class Console;
diff --git a/engines/asylum/module.mk b/engines/asylum/module.mk
index e444c8b8ca..2d7b5150af 100644
--- a/engines/asylum/module.mk
+++ b/engines/asylum/module.mk
@@ -1,6 +1,7 @@
MODULE := engines/asylum
MODULE_OBJS := \
+ actionarray.o \
actionlist.o \
actor.o \
asylum.o \
diff --git a/engines/asylum/scene.cpp b/engines/asylum/scene.cpp
index 38d3f3cbc9..a1e4f0692a 100644
--- a/engines/asylum/scene.cpp
+++ b/engines/asylum/scene.cpp
@@ -168,6 +168,10 @@ void Scene::initialize() {
}
}
+ uint32 actionIdx = _ws->actionListIdx;
+ if (actionIdx)
+ _vm->actionarray()->initItem(&_actions->entries[actionIdx], actionIdx, 0);
+
// TODO initActionListArrayItem(idx, 0) .text:00401050
// XXX not sure why we need to do this again
_vm->screen()->clearScreen();
@@ -177,23 +181,33 @@ void Scene::initialize() {
// TODO preloadGraphics() .text:00410F10
// TODO sound_sub(sceneNumber) .text:0040E750
_ws->actorType = actorType[_ws->numChapter];
- // TODO musicCacheOk check as part of if
- int musicId = 0;
- if (_ws->musicCurrentResId != -666 && _ws->numChapter != 1)
- musicId = _ws->musicResId - 0x7FFE0000;
- // TODO playMusic(musicId, cfgMusicVolume);
+
+ startMusic();
+
_vm->tempTick07 = 1;
+
// TODO sceneRectChangedFlag = 1;
+
actor->tickValue1= _vm->getTick();
// XXX This initialization was already done earlier,
// so I'm not sure why we need to do it again. Investigate.
updateActorDirectionDefault(_playerActorIdx);
+
if (_ws->numChapter == 9) {
// TODO changeActorIndex(1); .text:00405140
_ws->field_E860C = -1;
}
}
+void Scene::startMusic() {
+ // TODO musicCacheOk check as part of if
+ int musicId = 0;
+ if (_ws->musicCurrentResId != -666 && _ws->numChapter != 1)
+ musicId = _ws->musicResId - 0x7FFE0000;
+ _vm->sound()->playMusic(_musPack, musicId);
+
+}
+
Scene::~Scene() {
delete _ws;
delete _polygons;
@@ -399,8 +413,8 @@ void Scene::enterScene() {
_cursor->set(0);
_cursor->show();
- // Music testing: play the first music track
- _vm->sound()->playMusic(_musPack, 0);
+ startMusic();
+
_walking = false;
#ifdef SHOW_SCENE_LOADING
}
@@ -1409,7 +1423,7 @@ void Scene::drawActorsAndBarriers() {
if (bar->flags & 4) {
if (intersects) {
if(act->flags & 2)
- warning ("Assigning mask to masked character [%s]", bar->name);
+ warning ("[drawActorsAndBarriers] Assigning mask to masked character [%s]", bar->name);
else {
// TODO there's a call to sub_40ac10 that does
// a point calculation, but the result doesn't appear to
@@ -1459,7 +1473,6 @@ void Scene::getActorPosition(Actor *actor, Common::Point *pt) {
}
int Scene::queueActorUpdates() {
-
if (_ws->numActors > 0) {
Common::Point pt;
for (uint32 a = 0; a < _ws->numActors; a++) {
diff --git a/engines/asylum/scene.h b/engines/asylum/scene.h
index f6d1c03d16..15b1d28182 100644
--- a/engines/asylum/scene.h
+++ b/engines/asylum/scene.h
@@ -163,17 +163,30 @@ private:
*/
void initialize();
- void update();
- int updateScene();
- void updateMouse();
- void updateActor(uint32 actorIdx);
+ void update();
+ void startMusic();
+
+ /** .text:0040B5B0
+ * Loop through the various update blocks (actors,
+ * barriers, mouse, music, sfx, screenPosition), then
+ * process the current action script
+ */
+ int updateScene();
+ /** .text:0040D190 */
+ void updateMouse();
+ /** .text:0040B740 */
+ void updateActor(uint32 actorIdx);
/**
* TODO give more meaningful name
*/
void updateActorSub01(Actor *act);
+ /** .text:0040CBD0 */
void updateBarriers();
+ /** .text:00409BA0 */
void updateAmbientSounds();
+ /** .text:00409EF0 */
void updateMusic();
+ /** .text:0040DAE0 */
void updateAdjustScreen();
int drawScene();
void drawActorsAndBarriers();
diff --git a/engines/asylum/sound.cpp b/engines/asylum/sound.cpp
index f9e0a025ee..ccdd6383c7 100644
--- a/engines/asylum/sound.cpp
+++ b/engines/asylum/sound.cpp
@@ -25,6 +25,7 @@
#include "asylum/sound.h"
#include "asylum/asylum.h"
+#include "asylum/config.h"
#include "common/stream.h"
#include "sound/audiostream.h"
@@ -36,6 +37,7 @@ namespace Asylum {
Sound::Sound(Audio::Mixer *mixer) : _mixer(mixer) {
_speechPack = new ResourcePack(3);
_soundPack = new ResourcePack(18);
+ _currentMusicResIndex = -666;
}
Sound::~Sound() {
@@ -226,7 +228,7 @@ void Sound::playMusic(ResourcePack *pack, uint resId) {
stopMusic();
ResourceEntry *resource = pack->getResource(resId);
- playSoundData(&_musicHandle, resource->data, resource->size, true, 0, 0);
+ playSoundData(&_musicHandle, resource->data, resource->size, true, Config.musicVolume, 0);
}
void Sound::stopMusic() {
diff --git a/engines/asylum/sound.h b/engines/asylum/sound.h
index 4281252f92..0d61cdadfe 100644
--- a/engines/asylum/sound.h
+++ b/engines/asylum/sound.h
@@ -128,6 +128,14 @@ private:
Common::Array<SoundBufferItem> _soundBuffer;
+ /**
+ * The resource pointer for the currently playing music file.
+ * This was originally a scene variable, but it makes more sense
+ * to track it uniquely, as this doesn't involve initializing the
+ * scene just to set a single variable
+ */
+ int _currentMusicResIndex;
+
/**
* Find the index within the _soundBuffer array of the
* sound sample with provided id.
Commit: d9aaf26c18e099a9f29e35bb5ac4176da0f7f9f7
https://github.com/scummvm/scummvm/commit/d9aaf26c18e099a9f29e35bb5ac4176da0f7f9f7
Author: Alex Bevilacqua (alexbevi at gmail.com)
Date: 2021-05-17T15:35:55+02:00
Commit Message:
ASYLUM: Removed the actionarray class and rolled it into actionlist (which makes way more sense).
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@394 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
R engines/asylum/actionarray.cpp
R engines/asylum/actionarray.h
engines/asylum/actionlist.cpp
engines/asylum/actionlist.h
engines/asylum/asylum.cpp
engines/asylum/asylum.h
engines/asylum/module.mk
engines/asylum/scene.cpp
diff --git a/engines/asylum/actionarray.cpp b/engines/asylum/actionarray.cpp
deleted file mode 100644
index a60e9816f7..0000000000
--- a/engines/asylum/actionarray.cpp
+++ /dev/null
@@ -1,76 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * $URL$
- * $Id$
- *
- */
-
-#include "asylum/actionarray.h"
-
-namespace Asylum {
-
-ActionArray::ActionArray(AsylumEngine *engine): _vm(engine) {
- _actionFlag = false;
- reset();
-}
-
-ActionArray::~ActionArray() {
-
-}
-
-void ActionArray::reset() {
- memset(&_items, 0, sizeof(ActionStruct));
- for (int i = 0; i < 10; i++)
- _items.entries[i].actionListIndex = -1;
-}
-
-void ActionArray::initItem(ActionDefinitions *command, int actionIndex, int actorIndex) {
- // TODO properly define what actionFlag is actually for.
- // It appears to remain false 99% of the time, so I'm guessing
- // it's a "skip processing" flag.
- if (!_actionFlag) {
- int i;
- // iterate through the availble entry slots to determine
- // the next available slot
- for (i = 1; i < 10; i++) {
- if (_items.entries[i].actionListIndex == -1)
- break;
- }
-
- command->counter = 0;
-
- _items.entries[i].field_10 = 0;
- _items.entries[i].field_C = 0;
-
- if (_items.count) {
- _items.entries[_items.field_CC].field_C = i ;
- _items.entries[0].field_10 = _items.field_CC;
- } else {
- _items.count = i;
- }
- _items.field_CC = i;
- _items.entries[0].actionListIndex = actionIndex;
- _items.entries[0].actionListItemIndex = 0;
- _items.entries[0].actorIndex = actorIndex;
- }
-}
-
-} // end of namespace Asylum
diff --git a/engines/asylum/actionarray.h b/engines/asylum/actionarray.h
deleted file mode 100644
index 38b6820f3b..0000000000
--- a/engines/asylum/actionarray.h
+++ /dev/null
@@ -1,83 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * $URL$
- * $Id$
- *
- */
-
-#ifndef ASYLUM_ACTIONARRAY_H_
-#define ASYLUM_ACTIONARRAY_H_
-
-#include "asylum/asylum.h"
-#include "common/array.h"
-
-namespace Asylum {
-
-typedef struct ActionItem {
- int actionListIndex;
- int actionListItemIndex;
- int actorIndex;
- int field_C;
- int field_10;
-
-} ActionItem;
-
-typedef struct ActionStruct {
- ActionItem entries[10];
- int count;
- int field_CC;
-
-} ActionStruct;
-
-struct ActionDefinitions;
-
-class ActionArray {
-public:
- ActionArray(AsylumEngine *engine);
- virtual ~ActionArray();
-
- /** .text:00401020
- * Reset the _actionArray entries to their
- * default values
- */
- void reset();
-
- /** .text:00401050
- * Initialize the script element at actionIndex to
- * the actor at actorIndex
- *
- * FIXME passing in a reference to the command at actionIndex
- * to do a quick update.
- */
- void initItem(ActionDefinitions *command, int actionIndex, int actorIndex);
-
- void setActionFlag(bool value) { _actionFlag = value; }
-
-private:
- bool _actionFlag;
- ActionStruct _items;
- AsylumEngine *_vm;
-
-}; // end of class ActionArray
-
-} // end of namespace Asylum
-
-#endif /* ASYLUM_ACTIONARRAY_H_ */
diff --git a/engines/asylum/actionlist.cpp b/engines/asylum/actionlist.cpp
index ebc6be8b46..f9c2be0b23 100644
--- a/engines/asylum/actionlist.cpp
+++ b/engines/asylum/actionlist.cpp
@@ -38,6 +38,8 @@ ActionList::ActionList(Common::SeekableReadStream *stream, Scene *scene)
delayedSceneIndex = -1;
delayedVideoIndex = -1;
allowInput = true;
+ _actionFlag = false;
+ reset();
}
ActionList::~ActionList() {
@@ -185,6 +187,43 @@ void ActionList::setScriptByIndex(uint32 index) {
}
}
+void ActionList::reset() {
+ memset(&_items, 0, sizeof(ActionStruct));
+ for (int i = 0; i < 10; i++)
+ _items.entries[i].actionListIndex = -1;
+}
+
+void ActionList::initItem(int actionIndex, int actorIndex) {
+ // TODO properly define what actionFlag is actually for.
+ // It appears to remain false 99% of the time, so I'm guessing
+ // it's a "skip processing" flag.
+ if (!_actionFlag) {
+ int i;
+ // iterate through the availble entry slots to determine
+ // the next available slot
+ for (i = 1; i < 10; i++) {
+ if (_items.entries[i].actionListIndex == -1)
+ break;
+ }
+
+ _scene->actions()->entries[actionIndex].counter = 0;
+
+ _items.entries[i].field_10 = 0;
+ _items.entries[i].field_C = 0;
+
+ if (_items.count) {
+ _items.entries[_items.field_CC].field_C = i ;
+ _items.entries[0].field_10 = _items.field_CC;
+ } else {
+ _items.count = i;
+ }
+ _items.field_CC = i;
+ _items.entries[0].actionListIndex = actionIndex;
+ _items.entries[0].actionListItemIndex = 0;
+ _items.entries[0].actorIndex = actorIndex;
+ }
+}
+
void ActionList::processActionListSub02(ActionDefinitions* script, ActionCommand *command, int a4) {
//int v4 = 0;
int result;
@@ -809,11 +848,11 @@ int kStopAllBarriersSounds(ActionCommand *cmd, Scene *scn) {
}
int kSetActionFlag(ActionCommand *cmd, Scene *scn) {
- scn->vm()->actionarray()->setActionFlag(true);
+ scn->actions()->setActionFlag(true);
return 0;
}
int kClearActionFlag(ActionCommand *cmd, Scene *scn) {
- scn->vm()->actionarray()->setActionFlag(false);
+ scn->actions()->setActionFlag(false);
return 0;
}
int kResetSceneRect(ActionCommand *cmd, Scene *scn) {
diff --git a/engines/asylum/actionlist.h b/engines/asylum/actionlist.h
index d8b2ae3983..460a35157e 100644
--- a/engines/asylum/actionlist.h
+++ b/engines/asylum/actionlist.h
@@ -38,7 +38,7 @@ namespace Asylum {
class Scene;
typedef struct ActionCommand {
- uint32 numLines; // Only set on the first line of each script
+ uint32 numLines; // Only set on the first line of each script
uint32 opcode;
int param1;
int param2;
@@ -59,6 +59,22 @@ typedef struct ActionDefinitions {
uint32 counter;
} ActionDefinitions;
+typedef struct ActionItem {
+ int actionListIndex;
+ int actionListItemIndex;
+ int actorIndex;
+ int field_C;
+ int field_10;
+
+} ActionItem;
+
+typedef struct ActionStruct {
+ ActionItem entries[10];
+ int count;
+ int field_CC;
+
+} ActionStruct;
+
class ActionList {
public:
ActionList(Common::SeekableReadStream *stream, Scene *scene);
@@ -83,15 +99,30 @@ public:
bool done;
bool waitCycle;
+ // TODO depreciate
void setScriptByIndex(uint32 index);
- ActionDefinitions* getScript() {
- return _currentScript;
- }
+ // TODO depreciate
+ ActionDefinitions* getScript() { return _currentScript; }
/** .text:00402120
* Process the current script
*/
- int process();
+ int process();
+ /** .text:00401020
+ * Reset the _actionArray entries to their
+ * default values
+ */
+ void reset();
+ /** .text:00401050
+ * Initialize the script element at actionIndex to
+ * the actor at actorIndex
+ */
+ void initItem(int actionIndex, int actorIndex);
+ /**
+ * Toggle the action queue processing flag
+ */
+ void setActionFlag(bool value) { _actionFlag = value; }
+
void processActionListSub02(ActionDefinitions* script, ActionCommand* command, int a4);
void enableActorSub(int actorIndex, int condition);
@@ -99,9 +130,10 @@ public:
private:
Scene *_scene;
ActionDefinitions *_currentScript;
+ bool _actionFlag;
+ ActionStruct _items;
void load(Common::SeekableReadStream *stream);
-
};
// opcode functions
diff --git a/engines/asylum/asylum.cpp b/engines/asylum/asylum.cpp
index 6c084e3a32..7c2ca228a2 100644
--- a/engines/asylum/asylum.cpp
+++ b/engines/asylum/asylum.cpp
@@ -68,7 +68,6 @@ AsylumEngine::~AsylumEngine() {
delete _screen;
delete _encounter;
delete _text;
- delete _actionArray;
}
Common::Error AsylumEngine::run() {
@@ -95,7 +94,6 @@ Common::Error AsylumEngine::init() {
_introPlaying = false;
memset(_gameFlags, 0, 1512);
- _actionArray = new ActionArray(this);
return Common::kNoError;
}
diff --git a/engines/asylum/asylum.h b/engines/asylum/asylum.h
index 5e8f08c01a..8c8707b0c5 100644
--- a/engines/asylum/asylum.h
+++ b/engines/asylum/asylum.h
@@ -37,7 +37,6 @@
#include "asylum/video.h"
#include "asylum/blowuppuzzle.h"
#include "asylum/encounters.h"
-#include "asylum/actionarray.h"
namespace Asylum {
@@ -67,7 +66,6 @@ class Screen;
class Sound;
class Video;
class Encounter;
-class ActionArray;
enum kDebugLevels {
kDebugLevelMain = 1 << 0,
@@ -118,7 +116,6 @@ public:
Screen* screen() { return _screen; }
Scene* scene() { return _scene;}
Text* text() { return _text; }
- ActionArray *actionarray() { return _actionArray; }
private:
void checkForEvent(bool doUpdate);
@@ -141,8 +138,6 @@ private:
Text *_text;
Encounter *_encounter;
- ActionArray *_actionArray;
-
int _gameFlags[1512];
friend class Console;
diff --git a/engines/asylum/module.mk b/engines/asylum/module.mk
index 2d7b5150af..e444c8b8ca 100644
--- a/engines/asylum/module.mk
+++ b/engines/asylum/module.mk
@@ -1,7 +1,6 @@
MODULE := engines/asylum
MODULE_OBJS := \
- actionarray.o \
actionlist.o \
actor.o \
asylum.o \
diff --git a/engines/asylum/scene.cpp b/engines/asylum/scene.cpp
index a1e4f0692a..e4bcd6bcbd 100644
--- a/engines/asylum/scene.cpp
+++ b/engines/asylum/scene.cpp
@@ -170,7 +170,7 @@ void Scene::initialize() {
uint32 actionIdx = _ws->actionListIdx;
if (actionIdx)
- _vm->actionarray()->initItem(&_actions->entries[actionIdx], actionIdx, 0);
+ _actions->initItem(actionIdx, 0);
// TODO initActionListArrayItem(idx, 0) .text:00401050
// XXX not sure why we need to do this again
Commit: 20184c848649ad9a73f8a1e474d771518ebb2e64
https://github.com/scummvm/scummvm/commit/20184c848649ad9a73f8a1e474d771518ebb2e64
Author: Alex Bevilacqua (alexbevi at gmail.com)
Date: 2021-05-17T15:35:55+02:00
Commit Message:
ASYLUM: Starting to implement proper actionlist processing using the scripts queue.
With this update, I've renamed all the structs within the actionlist, so be forewarned ;)
This update doesn't work 100% though, as the processing loop exits early when there is a kWaitForFrame command cycling. I'm checking this is so the rest of the team can see the direction (and hopefully fix these for me while I'm at work :P).
I've also removed the hard-setting of script indices within the actionlist in favour of pulling them from the script queue instead. This breaks console debugging compatibility for now, but can be easily re-instated by pushing a script into the queue, as opposed to just setting it directly.
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@395 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/actionlist.cpp
engines/asylum/actionlist.h
engines/asylum/actor.cpp
engines/asylum/asylum.cpp
engines/asylum/console.cpp
engines/asylum/scene.cpp
diff --git a/engines/asylum/actionlist.cpp b/engines/asylum/actionlist.cpp
index f9c2be0b23..f3869c4f2b 100644
--- a/engines/asylum/actionlist.cpp
+++ b/engines/asylum/actionlist.cpp
@@ -39,14 +39,14 @@ ActionList::ActionList(Common::SeekableReadStream *stream, Scene *scene)
delayedVideoIndex = -1;
allowInput = true;
_actionFlag = false;
- reset();
+ resetQueue();
}
ActionList::~ActionList() {
entries.clear();
}
-typedef int AsylumFunc(ActionCommand *cmd, Scene *scn);
+typedef int AsylumFunc(Script *script, ScriptEntry *cmd, Scene *scn);
struct AsylumFunction {
const char *name;
@@ -163,6 +163,7 @@ static const AsylumFunction function_map[] = {
#undef MAPFUNC
+/*
void ActionList::setScriptByIndex(uint32 index) {
currentLine = 0;
_currentScript = &entries[index]; // TODO assert if out of bounds
@@ -186,14 +187,15 @@ void ActionList::setScriptByIndex(uint32 index) {
}
}
}
+*/
-void ActionList::reset() {
- memset(&_items, 0, sizeof(ActionStruct));
+void ActionList::resetQueue() {
+ memset(&_scripts, 0, sizeof(ScriptQueue));
for (int i = 0; i < 10; i++)
- _items.entries[i].actionListIndex = -1;
+ _scripts.entries[i].actionListIndex = -1;
}
-void ActionList::initItem(int actionIndex, int actorIndex) {
+void ActionList::queueScript(int actionIndex, int actorIndex) {
// TODO properly define what actionFlag is actually for.
// It appears to remain false 99% of the time, so I'm guessing
// it's a "skip processing" flag.
@@ -202,29 +204,55 @@ void ActionList::initItem(int actionIndex, int actorIndex) {
// iterate through the availble entry slots to determine
// the next available slot
for (i = 1; i < 10; i++) {
- if (_items.entries[i].actionListIndex == -1)
+ if (_scripts.entries[i].actionListIndex == -1)
break;
}
_scene->actions()->entries[actionIndex].counter = 0;
- _items.entries[i].field_10 = 0;
- _items.entries[i].field_C = 0;
+ _scripts.entries[i].field_10 = 0;
+ _scripts.entries[i].field_C = 0;
- if (_items.count) {
- _items.entries[_items.field_CC].field_C = i ;
- _items.entries[0].field_10 = _items.field_CC;
+ if (_scripts.count) {
+ _scripts.entries[_scripts.field_CC].field_C = i ;
+ _scripts.entries[0].field_10 = _scripts.field_CC;
} else {
- _items.count = i;
+ _scripts.count = i;
}
- _items.field_CC = i;
- _items.entries[0].actionListIndex = actionIndex;
- _items.entries[0].actionListItemIndex = 0;
- _items.entries[0].actorIndex = actorIndex;
+ _scripts.field_CC = i;
+ _scripts.entries[0].actionListIndex = actionIndex;
+ _scripts.entries[0].actionListItemIndex = 0;
+ _scripts.entries[0].actorIndex = actorIndex;
}
}
-void ActionList::processActionListSub02(ActionDefinitions* script, ActionCommand *command, int a4) {
+void ActionList::updateQueue(int queueIndex) {
+ if (_scripts.count == _scripts.field_CC) {
+ _scripts.field_CC = 0;
+ _scripts.count = 0;
+ _scripts.entries[queueIndex].actionListIndex = -1;
+ } else {
+ if (_scripts.count == queueIndex) {
+ _scripts.count = _scripts.entries[queueIndex].field_C;
+ _scripts.entries[queueIndex].field_10 = 0;
+ _scripts.entries[queueIndex].actionListIndex = -1;
+ } else {
+ if (_scripts.field_CC == queueIndex) {
+ _scripts.field_CC = _scripts.entries[queueIndex].field_10;
+ _scripts.entries[queueIndex].field_C = 0;
+ _scripts.entries[queueIndex].actionListIndex = -1;
+ } else {
+ int tmp10 = _scripts.entries[queueIndex].field_10;
+ int tmpC = _scripts.entries[queueIndex].field_C;
+ _scripts.entries[tmp10].field_C = _scripts.entries[queueIndex].field_C;
+ _scripts.entries[tmpC].field_10 = _scripts.entries[queueIndex].field_10;
+ _scripts.entries[queueIndex].actionListIndex = -1;
+ }
+ }
+ }
+}
+
+void ActionList::processActionListSub02(Script* script, ScriptEntry *command, int a4) {
//int v4 = 0;
int result;
int barrierIdx = 0;
@@ -298,14 +326,15 @@ void ActionList::enableActorSub(int actorIndex, int condition) {
}
-
int ActionList::process() {
done = false;
waitCycle = false;
lineIncrement = 1;
processing = true;
- if (_currentScript) {
+ while (_scripts.count) {
+ Script *currentScript = &entries[_scripts.entries[_scripts.count - 1].actionListIndex];
+ currentLine = 0;
while (!done && !waitCycle) {
lineIncrement = 0; //Reset line increment value
@@ -313,12 +342,14 @@ int ActionList::process() {
//TODO - processActionLists has run too many iterations
}
- ActionCommand *currentCommand = &_currentScript->commands[currentLine];
+ ScriptEntry *currentCommand = ¤tScript->commands[currentLine];
uint32 opcode = currentCommand->opcode;
+ debugC(kDebugLevelScripts, "%s (0x%02d)", function_map[opcode].name, opcode);
+
// Execute command from function mapping
- int cmdRet = function_map[opcode].function(currentCommand, _scene);
+ int cmdRet = function_map[opcode].function(currentScript, currentCommand, _scene);
// Check function return
if (cmdRet == -1)
@@ -348,18 +379,18 @@ int ActionList::process() {
} // end while
+ updateQueue(_scripts.count);
+
if (done) {
- currentLine = 0;
- currentLoops = 0;
- _currentScript = 0;
-
- // XXX
- // gameFlag 183 is the same as the
- // processing flag, but is not being used
- _scene->vm()->clearGameFlag(183);
+ currentLine = 0;
+ currentLoops = 0;
}
}
+ // XXX
+ // gameFlag 183 is the same as the
+ // processing flag, but is not being used
+ _scene->vm()->clearGameFlag(183);
processing = false;
return 0;
@@ -370,12 +401,12 @@ void ActionList::load(Common::SeekableReadStream *stream) {
numEntries = stream->readUint32LE();
for (uint32 a = 0; a < numEntries; a++) {
- ActionDefinitions action;
- memset(&action, 0, sizeof(ActionDefinitions));
+ Script action;
+ memset(&action, 0, sizeof(Script));
for (uint32 c = 0; c < MAX_ACTION_COMMANDS; c++) {
- ActionCommand command;
- memset(&command, 0, sizeof(ActionCommand));
+ ScriptEntry command;
+ memset(&command, 0, sizeof(ScriptEntry));
command.numLines = stream->readUint32LE();
command.opcode = stream->readUint32LE();
@@ -402,13 +433,13 @@ void ActionList::load(Common::SeekableReadStream *stream) {
/* Opcode Functions */
-int kReturn0(ActionCommand *cmd, Scene *scn) {
+int kReturn0(Script *script, ScriptEntry *cmd, Scene *scn) {
scn->actions()->done = true;
scn->actions()->lineIncrement = 0;
return 0;
}
-int kSetGameFlag(ActionCommand *cmd, Scene *scn) {
+int kSetGameFlag(Script *script, ScriptEntry *cmd, Scene *scn) {
int flagNum = cmd->param1;
if (flagNum >= 0)
@@ -417,7 +448,7 @@ int kSetGameFlag(ActionCommand *cmd, Scene *scn) {
return 0;
}
-int kClearGameFlag(ActionCommand *cmd, Scene *scn) {
+int kClearGameFlag(Script *script, ScriptEntry *cmd, Scene *scn) {
int flagNum = cmd->param1;
if (flagNum >= 0)
@@ -426,7 +457,7 @@ int kClearGameFlag(ActionCommand *cmd, Scene *scn) {
return 0;
}
-int kToggleGameFlag(ActionCommand *cmd, Scene *scn) {
+int kToggleGameFlag(Script *script, ScriptEntry *cmd, Scene *scn) {
int flagNum = cmd->param1;
if (flagNum >= 0)
@@ -435,7 +466,7 @@ int kToggleGameFlag(ActionCommand *cmd, Scene *scn) {
return 0;
}
-int kJumpIfGameFlag(ActionCommand *cmd, Scene *scn) {
+int kJumpIfGameFlag(Script *script, ScriptEntry *cmd, Scene *scn) {
int flagNum = cmd->param1;
if (flagNum) {
@@ -449,14 +480,14 @@ int kJumpIfGameFlag(ActionCommand *cmd, Scene *scn) {
return 0;
}
-int kHideCursor(ActionCommand *cmd, Scene *scn) {
+int kHideCursor(Script *script, ScriptEntry *cmd, Scene *scn) {
scn->getCursor()->hide();
scn->actions()->allowInput = false;
return 0;
}
-int kShowCursor(ActionCommand *cmd, Scene *scn) {
+int kShowCursor(Script *script, ScriptEntry *cmd, Scene *scn) {
scn->getCursor()->show();
scn->actions()->allowInput = true;
@@ -464,7 +495,7 @@ int kShowCursor(ActionCommand *cmd, Scene *scn) {
return -1;
}
-int kPlayAnimation(ActionCommand *cmd, Scene *scn) {
+int kPlayAnimation(Script *script, ScriptEntry *cmd, Scene *scn) {
int barrierId = cmd->param1;
int barrierIndex = scn->worldstats()->getBarrierIndexById(barrierId);
Barrier *barrier = scn->worldstats()->getBarrierByIndex(barrierIndex);
@@ -509,7 +540,7 @@ int kPlayAnimation(ActionCommand *cmd, Scene *scn) {
return -1;
}
-int kMoveScenePosition(ActionCommand *cmd, Scene *scn) {
+int kMoveScenePosition(Script *script, ScriptEntry *cmd, Scene *scn) {
WorldStats *ws = scn->worldstats();
Common::Rect *sr = &ws->sceneRects[ws->sceneRectIdx];
@@ -563,7 +594,7 @@ int kMoveScenePosition(ActionCommand *cmd, Scene *scn) {
return -1;
}
-int kHideActor(ActionCommand *cmd, Scene *scn) {
+int kHideActor(Script *script, ScriptEntry *cmd, Scene *scn) {
Actor *actor = 0;
// TODO better default actor handling
@@ -577,7 +608,7 @@ int kHideActor(ActionCommand *cmd, Scene *scn) {
return -3;
}
-int kShowActor(ActionCommand *cmd, Scene *scn) {
+int kShowActor(Script *script, ScriptEntry *cmd, Scene *scn) {
Actor *actor = 0;
// TODO revisit when actor selection is cleaned up
@@ -593,7 +624,7 @@ int kShowActor(ActionCommand *cmd, Scene *scn) {
return -2;
}
-int kSetActorStats(ActionCommand *cmd, Scene *scn) {
+int kSetActorStats(Script *script, ScriptEntry *cmd, Scene *scn) {
//WorldStats *ws = scn->worldstats();
// TODO
@@ -610,13 +641,13 @@ int kSetActorStats(ActionCommand *cmd, Scene *scn) {
return -1;
}
-int kSetSceneMotionStat(ActionCommand *cmd, Scene *scn) {
+int kSetSceneMotionStat(Script *script, ScriptEntry *cmd, Scene *scn) {
scn->worldstats()->motionStatus = cmd->param1;
return 0;
}
-int kDisableActor(ActionCommand *cmd, Scene *scn) {
+int kDisableActor(Script *script, ScriptEntry *cmd, Scene *scn) {
int actorIndex = cmd->param1;
if (actorIndex == -1)
@@ -627,7 +658,7 @@ int kDisableActor(ActionCommand *cmd, Scene *scn) {
return 0;
}
-int kEnableActor(ActionCommand *cmd, Scene *scn) {
+int kEnableActor(Script *script, ScriptEntry *cmd, Scene *scn) {
int actorIndex = 0;
if (cmd->param1 == -1)
@@ -641,12 +672,12 @@ int kEnableActor(ActionCommand *cmd, Scene *scn) {
return 0;
}
-int kEnableBarriers(ActionCommand *cmd, Scene *scn) {
+int kEnableBarriers(Script *script, ScriptEntry *cmd, Scene *scn) {
int barIdx = scn->worldstats()->getBarrierIndexById(cmd->param1);
uint32 sndIdx = cmd->param3;
uint32 v59 = cmd->param2;
- if (!scn->actions()->getScript()->counter && scn->getSceneIndex() != 13 && sndIdx != 0) {
+ if (!script->counter && scn->getSceneIndex() != 13 && sndIdx != 0) {
// FIXME: I really don't understand what (sndIdx != 0) & 5 is supposed to be doing here,
// but this is effectively trying to do a boolean AND operation on a boolean variable
// which is odd, and wrong. Changing it to (sndIdx & 5), for now
@@ -654,15 +685,15 @@ int kEnableBarriers(ActionCommand *cmd, Scene *scn) {
scn->vm()->sound()->playSound((sndIdx & 5) + 0x80120001, false, Config.sfxVolume, 0);
}
- if (scn->actions()->getScript()->counter >= 3 * v59 - 1) {
- scn->actions()->getScript()->counter = 0;
+ if (script->counter >= 3 * v59 - 1) {
+ script->counter = 0;
scn->worldstats()->barriers[barIdx].field_67C = 0;
- scn->actions()->processActionListSub02(scn->actions()->getScript(), cmd, 2);
+ scn->actions()->processActionListSub02(script, cmd, 2);
scn->actions()->currentLoops = 1; // v4 = 1;
} else {
int v64;
- int v62 = scn->actions()->getScript()->counter + 1;
- scn->actions()->getScript()->counter = v62;
+ int v62 = script->counter + 1;
+ script->counter = v62;
if (sndIdx) {
v64 = 1;
int v170 = 3 - v62 / v59;
@@ -672,20 +703,20 @@ int kEnableBarriers(ActionCommand *cmd, Scene *scn) {
scn->worldstats()->barriers[barIdx].field_67C = v62 / v59 + 1;
}
- scn->actions()->processActionListSub02(scn->actions()->getScript(), cmd, v64);
+ scn->actions()->processActionListSub02(script, cmd, v64);
}
return -1;
}
-int kReturn(ActionCommand *cmd, Scene *scn) {
+int kReturn(Script *script, ScriptEntry *cmd, Scene *scn) {
scn->actions()->done = true;
scn->actions()->lineIncrement = 0;
return 0;
}
-int kDestroyBarrier(ActionCommand *cmd, Scene *scn) {
+int kDestroyBarrier(Script *script, ScriptEntry *cmd, Scene *scn) {
Barrier *barrier = scn->worldstats()->getBarrierById(cmd->param1);
if (barrier) {
@@ -702,20 +733,20 @@ int kDestroyBarrier(ActionCommand *cmd, Scene *scn) {
return 0;
}
-int k_unk12_JMP_WALK_ACTOR(ActionCommand *cmd, Scene *scn) {
+int k_unk12_JMP_WALK_ACTOR(Script *script, ScriptEntry *cmd, Scene *scn) {
return -2;
}
-int k_unk13_JMP_WALK_ACTOR(ActionCommand *cmd, Scene *scn) {
+int k_unk13_JMP_WALK_ACTOR(Script *script, ScriptEntry *cmd, Scene *scn) {
return -2;
}
-int k_unk14_JMP_WALK_ACTOR(ActionCommand *cmd, Scene *scn) {
+int k_unk14_JMP_WALK_ACTOR(Script *script, ScriptEntry *cmd, Scene *scn) {
return -2;
}
-int k_unk15(ActionCommand *cmd, Scene *scn) {
+int k_unk15(Script *script, ScriptEntry *cmd, Scene *scn) {
return -2;
}
-int kResetAnimation(ActionCommand *cmd, Scene *scn) {
+int kResetAnimation(Script *script, ScriptEntry *cmd, Scene *scn) {
Barrier *barrier = scn->worldstats()->getBarrierById(cmd->param1);
if ((barrier->flags & 0x10000) == 0)
@@ -726,7 +757,7 @@ int kResetAnimation(ActionCommand *cmd, Scene *scn) {
return 0;
}
-int kClearFlag1Bit0(ActionCommand *cmd, Scene *scn) {
+int kClearFlag1Bit0(Script *script, ScriptEntry *cmd, Scene *scn) {
Barrier *barrier = scn->worldstats()->getBarrierById(cmd->param1);
barrier->flags &= 0xFFFFFFFE;
@@ -734,11 +765,11 @@ int kClearFlag1Bit0(ActionCommand *cmd, Scene *scn) {
return 0;
}
-int k_unk18_PLAY_SND(ActionCommand *cmd, Scene *scn) {
+int k_unk18_PLAY_SND(Script *script, ScriptEntry *cmd, Scene *scn) {
return -2;
}
-int kJumpIfFlag2Bit0(ActionCommand *cmd, Scene *scn) {
+int kJumpIfFlag2Bit0(Script *script, ScriptEntry *cmd, Scene *scn) {
int targetType = cmd->param2;
return 0;
@@ -757,7 +788,7 @@ int kJumpIfFlag2Bit0(ActionCommand *cmd, Scene *scn) {
return -1;
}
-int kSetFlag2Bit0(ActionCommand *cmd, Scene *scn) {
+int kSetFlag2Bit0(Script *script, ScriptEntry *cmd, Scene *scn) {
int targetType = cmd->param2;
if (targetType == 2)
@@ -771,56 +802,56 @@ int kSetFlag2Bit0(ActionCommand *cmd, Scene *scn) {
return 0;
}
-int kClearFlag2Bit0(ActionCommand *cmd, Scene *scn) {
+int kClearFlag2Bit0(Script *script, ScriptEntry *cmd, Scene *scn) {
return -2;
}
-int kJumpIfFlag2Bit2(ActionCommand *cmd, Scene *scn) {
+int kJumpIfFlag2Bit2(Script *script, ScriptEntry *cmd, Scene *scn) {
return -2;
}
-int kSetFlag2Bit2(ActionCommand *cmd, Scene *scn) {
+int kSetFlag2Bit2(Script *script, ScriptEntry *cmd, Scene *scn) {
return -2;
}
-int kClearFlag2Bit2(ActionCommand *cmd, Scene *scn) {
+int kClearFlag2Bit2(Script *script, ScriptEntry *cmd, Scene *scn) {
return -2;
}
-int kJumpIfFlag2Bit1(ActionCommand *cmd, Scene *scn) {
+int kJumpIfFlag2Bit1(Script *script, ScriptEntry *cmd, Scene *scn) {
return -2;
}
-int kSetFlag2Bit1(ActionCommand *cmd, Scene *scn) {
+int kSetFlag2Bit1(Script *script, ScriptEntry *cmd, Scene *scn) {
return -2;
}
-int kClearFlag2Bit1(ActionCommand *cmd, Scene *scn) {
+int kClearFlag2Bit1(Script *script, ScriptEntry *cmd, Scene *scn) {
return -2;
}
-int k_unk22(ActionCommand *cmd, Scene *scn) {
+int k_unk22(Script *script, ScriptEntry *cmd, Scene *scn) {
return -2;
}
-int k_unk23(ActionCommand *cmd, Scene *scn) {
+int k_unk23(Script *script, ScriptEntry *cmd, Scene *scn) {
return -2;
}
-int k_unk24(ActionCommand *cmd, Scene *scn) {
+int k_unk24(Script *script, ScriptEntry *cmd, Scene *scn) {
return -2;
}
-int kRunEncounter(ActionCommand *cmd, Scene *scn) {
+int kRunEncounter(Script *script, ScriptEntry *cmd, Scene *scn) {
return -2;
}
-int kJumpIfFlag2Bit4(ActionCommand *cmd, Scene *scn) {
+int kJumpIfFlag2Bit4(Script *script, ScriptEntry *cmd, Scene *scn) {
return -2;
}
-int kSetFlag2Bit4(ActionCommand *cmd, Scene *scn) {
+int kSetFlag2Bit4(Script *script, ScriptEntry *cmd, Scene *scn) {
return -2;
}
-int kClearFlag2Bit4(ActionCommand *cmd, Scene *scn) {
+int kClearFlag2Bit4(Script *script, ScriptEntry *cmd, Scene *scn) {
return -2;
}
-int kSetActorField638(ActionCommand *cmd, Scene *scn) {
+int kSetActorField638(Script *script, ScriptEntry *cmd, Scene *scn) {
return -2;
}
-int kJumpIfActorField638(ActionCommand *cmd, Scene *scn) {
+int kJumpIfActorField638(Script *script, ScriptEntry *cmd, Scene *scn) {
return -2;
}
-int kChangeScene(ActionCommand *cmd, Scene *scn) {
+int kChangeScene(Script *script, ScriptEntry *cmd, Scene *scn) {
scn->actions()->delayedSceneIndex = cmd->param1 + 4;
debug(kDebugLevelScripts,
"Queueing Scene Change to scene %d...",
@@ -829,46 +860,46 @@ int kChangeScene(ActionCommand *cmd, Scene *scn) {
return 0;
}
-int k_unk2C_ActorSub(ActionCommand *cmd, Scene *scn) {
+int k_unk2C_ActorSub(Script *script, ScriptEntry *cmd, Scene *scn) {
return -2;
}
-int kPlayMovie(ActionCommand *cmd, Scene *scn) {
+int kPlayMovie(Script *script, ScriptEntry *cmd, Scene *scn) {
// TODO: add missing code here
scn->actions()->delayedVideoIndex = cmd->param1;
return -1;
}
-int kStopAllBarriersSounds(ActionCommand *cmd, Scene *scn) {
+int kStopAllBarriersSounds(Script *script, ScriptEntry *cmd, Scene *scn) {
// TODO: do this for all barriers that have sfx playing
scn->vm()->sound()->stopAllSounds();
return -1;
}
-int kSetActionFlag(ActionCommand *cmd, Scene *scn) {
+int kSetActionFlag(Script *script, ScriptEntry *cmd, Scene *scn) {
scn->actions()->setActionFlag(true);
return 0;
}
-int kClearActionFlag(ActionCommand *cmd, Scene *scn) {
+int kClearActionFlag(Script *script, ScriptEntry *cmd, Scene *scn) {
scn->actions()->setActionFlag(false);
return 0;
}
-int kResetSceneRect(ActionCommand *cmd, Scene *scn) {
+int kResetSceneRect(Script *script, ScriptEntry *cmd, Scene *scn) {
return -2;
}
-int kChangeMusicById(ActionCommand *cmd, Scene *scn) {
+int kChangeMusicById(Script *script, ScriptEntry *cmd, Scene *scn) {
return -2;
}
-int kStopMusic(ActionCommand *cmd, Scene *scn) {
+int kStopMusic(Script *script, ScriptEntry *cmd, Scene *scn) {
scn->vm()->sound()->stopMusic();
return 0;
}
-int k_unk34_Status(ActionCommand *cmd, Scene *scn) {
+int k_unk34_Status(Script *script, ScriptEntry *cmd, Scene *scn) {
if (cmd->param1 >= 2) {
cmd->param1 = 0;
} else {
@@ -879,14 +910,14 @@ int k_unk34_Status(ActionCommand *cmd, Scene *scn) {
return 0;
}
-int k_unk35(ActionCommand *cmd, Scene *scn) {
+int k_unk35(Script *script, ScriptEntry *cmd, Scene *scn) {
return -2;
}
-int k_unk36(ActionCommand *cmd, Scene *scn) {
+int k_unk36(Script *script, ScriptEntry *cmd, Scene *scn) {
return -2;
}
-int kRunBlowUpPuzzle(ActionCommand *cmd, Scene *scn) {
+int kRunBlowUpPuzzle(Script *script, ScriptEntry *cmd, Scene *scn) {
// FIXME: improve this to call other blowUpPuzzles than VCR
//int puzzleIdx = cmd->param1;
@@ -896,20 +927,20 @@ int kRunBlowUpPuzzle(ActionCommand *cmd, Scene *scn) {
return -1;
}
-int kJumpIfFlag2Bit3(ActionCommand *cmd, Scene *scn) {
+int kJumpIfFlag2Bit3(Script *script, ScriptEntry *cmd, Scene *scn) {
return -2;
}
-int kSetFlag2Bit3(ActionCommand *cmd, Scene *scn) {
+int kSetFlag2Bit3(Script *script, ScriptEntry *cmd, Scene *scn) {
return -2;
}
-int kClearFlag2Bit3(ActionCommand *cmd, Scene *scn) {
+int kClearFlag2Bit3(Script *script, ScriptEntry *cmd, Scene *scn) {
return -2;
}
-int k_unk3B_PALETTE_MOD(ActionCommand *cmd, Scene *scn) {
+int k_unk3B_PALETTE_MOD(Script *script, ScriptEntry *cmd, Scene *scn) {
return -2;
}
-int k_unk3C_CMP_VAL(ActionCommand *cmd, Scene *scn) {
+int k_unk3C_CMP_VAL(Script *script, ScriptEntry *cmd, Scene *scn) {
if (cmd->param1) {
if (cmd->param2 >= cmd->param1) {
cmd->param2 = 0;
@@ -922,7 +953,7 @@ int k_unk3C_CMP_VAL(ActionCommand *cmd, Scene *scn) {
return 0;
}
-int kWaitUntilFramePlayed(ActionCommand *cmd, Scene *scn) {
+int kWaitUntilFramePlayed(Script *script, ScriptEntry *cmd, Scene *scn) {
Barrier *barrier = scn->worldstats()->getBarrierById(cmd->param1);
if (barrier) {
@@ -944,7 +975,7 @@ int kWaitUntilFramePlayed(ActionCommand *cmd, Scene *scn) {
return 0;
}
-int kUpdateWideScreen(ActionCommand *cmd, Scene *scn) {
+int kUpdateWideScreen(Script *script, ScriptEntry *cmd, Scene *scn) {
int barSize = cmd->param1;
if (barSize >= 22) {
@@ -957,14 +988,14 @@ int kUpdateWideScreen(ActionCommand *cmd, Scene *scn) {
return 0;
}
-int k_unk3F(ActionCommand *cmd, Scene *scn) {
+int k_unk3F(Script *script, ScriptEntry *cmd, Scene *scn) {
return -2;
}
-int k_unk40_SOUND(ActionCommand *cmd, Scene *scn) {
+int k_unk40_SOUND(Script *script, ScriptEntry *cmd, Scene *scn) {
return -2;
}
-int kPlaySpeech(ActionCommand *cmd, Scene *scn) {
+int kPlaySpeech(Script *script, ScriptEntry *cmd, Scene *scn) {
//TODO - Add support for other param options
uint32 sndIdx = cmd->param1;
@@ -1018,23 +1049,23 @@ int kPlaySpeech(ActionCommand *cmd, Scene *scn) {
return 0;
}
-int k_unk42(ActionCommand *cmd, Scene *scn) {
+int k_unk42(Script *script, ScriptEntry *cmd, Scene *scn) {
return -2;
}
-int k_unk43(ActionCommand *cmd, Scene *scn) {
+int k_unk43(Script *script, ScriptEntry *cmd, Scene *scn) {
return -2;
}
-int kPaletteFade(ActionCommand *cmd, Scene *scn) {
+int kPaletteFade(Script *script, ScriptEntry *cmd, Scene *scn) {
return -2;
}
-int kStartPaletteFadeThread(ActionCommand *cmd, Scene *scn) {
+int kStartPaletteFadeThread(Script *script, ScriptEntry *cmd, Scene *scn) {
return -2;
}
-int k_unk46(ActionCommand *cmd, Scene *scn) {
+int k_unk46(Script *script, ScriptEntry *cmd, Scene *scn) {
return -2;
}
-int kActorFaceObject(ActionCommand *cmd, Scene *scn) {
+int kActorFaceObject(Script *script, ScriptEntry *cmd, Scene *scn) {
// XXX
// Dropping param1, since it's the character index
// Investigate further if/when we have a scene with
@@ -1044,20 +1075,20 @@ int kActorFaceObject(ActionCommand *cmd, Scene *scn) {
return -1;
}
-int k_unk48_MATTE_01(ActionCommand *cmd, Scene *scn) {
+int k_unk48_MATTE_01(Script *script, ScriptEntry *cmd, Scene *scn) {
return -2;
}
-int k_unk49_MATTE_90(ActionCommand *cmd, Scene *scn) {
+int k_unk49_MATTE_90(Script *script, ScriptEntry *cmd, Scene *scn) {
return -2;
}
-int kJumpIfSoundPlaying(ActionCommand *cmd, Scene *scn) {
+int kJumpIfSoundPlaying(Script *script, ScriptEntry *cmd, Scene *scn) {
return -2;
}
-int kChangePlayerCharacterIndex(ActionCommand *cmd, Scene *scn) {
+int kChangePlayerCharacterIndex(Script *script, ScriptEntry *cmd, Scene *scn) {
return -2;
}
-int kChangeActorField40(ActionCommand *cmd, Scene *scn) {
+int kChangeActorField40(Script *script, ScriptEntry *cmd, Scene *scn) {
// TODO: figure out what is this field and what values are set
int actorIdx = cmd->param1;
int fieldType = cmd->param2;
@@ -1072,25 +1103,25 @@ int kChangeActorField40(ActionCommand *cmd, Scene *scn) {
return -1;
}
-int kStopSound(ActionCommand *cmd, Scene *scn) {
+int kStopSound(Script *script, ScriptEntry *cmd, Scene *scn) {
return -2;
}
-int k_unk4E_RANDOM_COMMAND(ActionCommand *cmd, Scene *scn) {
+int k_unk4E_RANDOM_COMMAND(Script *script, ScriptEntry *cmd, Scene *scn) {
return -2;
}
-int kClearScreen(ActionCommand *cmd, Scene *scn) {
+int kClearScreen(Script *script, ScriptEntry *cmd, Scene *scn) {
if (cmd->param1)
scn->vm()->screen()->clearScreen();
return 0;
}
-int kQuit(ActionCommand *cmd, Scene *scn) {
+int kQuit(Script *script, ScriptEntry *cmd, Scene *scn) {
return -2;
}
-int kJumpBarrierFrame(ActionCommand *cmd, Scene *scn) {
+int kJumpBarrierFrame(Script *script, ScriptEntry *cmd, Scene *scn) {
Barrier *barrier = scn->worldstats()->getBarrierById(cmd->param1);
int idx = (int)barrier->frameIdx;
@@ -1111,7 +1142,7 @@ int kJumpBarrierFrame(ActionCommand *cmd, Scene *scn) {
//break;
}
- ActionCommand *nextCmd = &scn->actions()->getScript()->commands[cmd->param9];
+ ScriptEntry *nextCmd = &script->commands[cmd->param9];
// 0x10 == kReturn
if (nextCmd->opcode != 0x10 && nextCmd->opcode)
@@ -1120,42 +1151,42 @@ int kJumpBarrierFrame(ActionCommand *cmd, Scene *scn) {
return 0;
}
-int k_unk52(ActionCommand *cmd, Scene *scn) {
+int k_unk52(Script *script, ScriptEntry *cmd, Scene *scn) {
return -2;
}
-int k_unk53(ActionCommand *cmd, Scene *scn) {
+int k_unk53(Script *script, ScriptEntry *cmd, Scene *scn) {
return -2;
}
-int k_unk54_SET_ACTIONLIST_6EC(ActionCommand *cmd, Scene *scn) {
+int k_unk54_SET_ACTIONLIST_6EC(Script *script, ScriptEntry *cmd, Scene *scn) {
if (cmd->param2)
- scn->actions()->getScript()->field_1BB0 = rand() % cmd->param1;
+ script->field_1BB0 = rand() % cmd->param1;
else
- scn->actions()->getScript()->field_1BB0 = cmd->param1;
+ script->field_1BB0 = cmd->param1;
return 0;
}
-int k_unk55(ActionCommand *cmd, Scene *scn) {
+int k_unk55(Script *script, ScriptEntry *cmd, Scene *scn) {
// TODO
/*
if (!cmd->param2) {
- if (cmd->param3 && scn->actions()->getScript()->field_1BB0 < cmd->param1)
+ if (cmd->param3 && script->field_1BB0 < cmd->param1)
//break;
- else if (cmd->param4 && scn->actions()->getScript()->field_1BB0 > cmd->param1)
+ else if (cmd->param4 && script->field_1BB0 > cmd->param1)
//break;
- else if (cmd->param5 && scn->actions()->getScript()->field_1BB0 <= cmd->param1)
+ else if (cmd->param5 && script->field_1BB0 <= cmd->param1)
//break;
- else if (cmd->param6 && scn->actions()->getScript()->field_1BB0 >= cmd->param1)
+ else if (cmd->param6 && script->field_1BB0 >= cmd->param1)
//break;
- else if (cmd->param7 && scn->actions()->getScript()->field_1BB0 != cmd->param1)
+ else if (cmd->param7 && script->field_1BB0 != cmd->param1)
//break;
- } else if(scn->actions()->getScript()->field_1BB0 == cmd->param1) {
+ } else if(script->field_1BB0 == cmd->param1) {
//break;
}
*/
- ActionCommand *nextCmd = &scn->actions()->getScript()->commands[cmd->param8];
+ ScriptEntry *nextCmd = &script->commands[cmd->param8];
if (nextCmd->opcode != 0x10 && nextCmd->opcode)
scn->actions()->done = true;
@@ -1165,18 +1196,18 @@ int k_unk55(ActionCommand *cmd, Scene *scn) {
return -1;
}
-int k_unk56(ActionCommand *cmd, Scene *scn) {
+int k_unk56(Script *script, ScriptEntry *cmd, Scene *scn) {
return -2;
}
-int kSetResourcePalette(ActionCommand *cmd, Scene *scn) {
+int kSetResourcePalette(Script *script, ScriptEntry *cmd, Scene *scn) {
if (cmd->param1 > 0)
scn->vm()->screen()->setPalette(scn->getResourcePack(), scn->worldstats()->grResId[cmd->param1]);
return 0;
}
-int kSetBarrierFrameIdxFlaged(ActionCommand *cmd, Scene *scn) {
+int kSetBarrierFrameIdxFlaged(Script *script, ScriptEntry *cmd, Scene *scn) {
Barrier *barrier = scn->worldstats()->getBarrierById(cmd->param1);
if (cmd->param3)
@@ -1189,26 +1220,26 @@ int kSetBarrierFrameIdxFlaged(ActionCommand *cmd, Scene *scn) {
return 0;
}
-int k_unk59(ActionCommand *cmd, Scene *scn) {
+int k_unk59(Script *script, ScriptEntry *cmd, Scene *scn) {
return -2;
}
-int k_unk5A(ActionCommand *cmd, Scene *scn) {
+int k_unk5A(Script *script, ScriptEntry *cmd, Scene *scn) {
return -2;
}
-int k_unk5B(ActionCommand *cmd, Scene *scn) {
+int k_unk5B(Script *script, ScriptEntry *cmd, Scene *scn) {
return -2;
}
-int k_unk5C(ActionCommand *cmd, Scene *scn) {
+int k_unk5C(Script *script, ScriptEntry *cmd, Scene *scn) {
return -2;
}
-int k_unk5D(ActionCommand *cmd, Scene *scn) {
+int k_unk5D(Script *script, ScriptEntry *cmd, Scene *scn) {
return -2;
}
-int k_unk5E(ActionCommand *cmd, Scene *scn) {
+int k_unk5E(Script *script, ScriptEntry *cmd, Scene *scn) {
return -2;
}
-int kSetBarrierLastFrameIdx(ActionCommand *cmd, Scene *scn) {
+int kSetBarrierLastFrameIdx(Script *script, ScriptEntry *cmd, Scene *scn) {
Barrier *barrier = scn->worldstats()->getBarrierById(cmd->param1);
if (barrier->frameIdx == barrier->frameCount - 1) {
@@ -1221,11 +1252,11 @@ int kSetBarrierLastFrameIdx(ActionCommand *cmd, Scene *scn) {
return 0;
}
-int k_unk60_SET_OR_CLR_ACTIONAREA_FLAG(ActionCommand *cmd, Scene *scn) {
+int k_unk60_SET_OR_CLR_ACTIONAREA_FLAG(Script *script, ScriptEntry *cmd, Scene *scn) {
return -2;
}
-int k_unk61(ActionCommand *cmd, Scene *scn) {
+int k_unk61(Script *script, ScriptEntry *cmd, Scene *scn) {
if (cmd->param2) {
if (scn->worldstats()->field_E860C == -1) {
scn->actions()->lineIncrement = 0;
@@ -1242,10 +1273,10 @@ int k_unk61(ActionCommand *cmd, Scene *scn) {
return -1;
}
-int k_unk62_SHOW_OPTIONS_SCREEN(ActionCommand *cmd, Scene *scn) {
+int k_unk62_SHOW_OPTIONS_SCREEN(Script *script, ScriptEntry *cmd, Scene *scn) {
return -2;
}
-int k_unk63(ActionCommand *cmd, Scene *scn) {
+int k_unk63(Script *script, ScriptEntry *cmd, Scene *scn) {
return -2;
}
diff --git a/engines/asylum/actionlist.h b/engines/asylum/actionlist.h
index 460a35157e..a5140e8479 100644
--- a/engines/asylum/actionlist.h
+++ b/engines/asylum/actionlist.h
@@ -37,7 +37,7 @@ namespace Asylum {
class Scene;
-typedef struct ActionCommand {
+typedef struct ScriptEntry {
uint32 numLines; // Only set on the first line of each script
uint32 opcode;
int param1;
@@ -50,30 +50,30 @@ typedef struct ActionCommand {
int param8;
int param9;
-} ActionCommand;
+} ScriptEntry;
-typedef struct ActionDefinitions {
- ActionCommand commands[MAX_ACTION_COMMANDS];
+typedef struct Script {
+ ScriptEntry commands[MAX_ACTION_COMMANDS];
uint32 field_1BAC;
uint32 field_1BB0;
uint32 counter;
-} ActionDefinitions;
+} Script;
-typedef struct ActionItem {
+typedef struct ScriptQueueEntry {
int actionListIndex;
int actionListItemIndex;
int actorIndex;
int field_C;
int field_10;
-} ActionItem;
+} ScriptQueueEntry;
-typedef struct ActionStruct {
- ActionItem entries[10];
- int count;
- int field_CC;
+typedef struct ScriptQueue {
+ ScriptQueueEntry entries[10];
+ int count;
+ int field_CC;
-} ActionStruct;
+} ScriptQueue;
class ActionList {
public:
@@ -83,7 +83,7 @@ public:
uint32 size;
uint32 numEntries;
- Common::Array<ActionDefinitions> entries;
+ Common::Array<Script> entries;
// FIXME
// Made all the internal control variables public and removed the getter/setter
@@ -99,144 +99,141 @@ public:
bool done;
bool waitCycle;
- // TODO depreciate
- void setScriptByIndex(uint32 index);
- // TODO depreciate
- ActionDefinitions* getScript() { return _currentScript; }
-
/** .text:00402120
* Process the current script
*/
int process();
/** .text:00401020
- * Reset the _actionArray entries to their
- * default values
+ * Reset the _scripts entries to their default values
*/
- void reset();
+ void resetQueue();
/** .text:00401050
* Initialize the script element at actionIndex to
* the actor at actorIndex
*/
- void initItem(int actionIndex, int actorIndex);
+ void queueScript(int actionIndex, int actorIndex);
+ /** .text:00401100
+ * Update the queued scripts
+ */
+ void updateQueue(int queueIndex);
/**
* Toggle the action queue processing flag
*/
void setActionFlag(bool value) { _actionFlag = value; }
- void processActionListSub02(ActionDefinitions* script, ActionCommand* command, int a4);
+ void processActionListSub02(Script* script, ScriptEntry* command, int a4);
void enableActorSub(int actorIndex, int condition);
private:
Scene *_scene;
- ActionDefinitions *_currentScript;
- bool _actionFlag;
- ActionStruct _items;
+ bool _actionFlag;
+ ScriptQueue _scripts;
void load(Common::SeekableReadStream *stream);
};
// opcode functions
-int kReturn0(ActionCommand *cmd, Scene *scn);
-int kSetGameFlag(ActionCommand *cmd, Scene *scn);
-int kClearGameFlag(ActionCommand *cmd, Scene *scn);
-int kToggleGameFlag(ActionCommand *cmd, Scene *scn);
-int kJumpIfGameFlag(ActionCommand *cmd, Scene *scn);
-int kHideCursor(ActionCommand *cmd, Scene *scn);
-int kShowCursor(ActionCommand *cmd, Scene *scn);
-int kPlayAnimation(ActionCommand *cmd, Scene *scn);
-int kMoveScenePosition(ActionCommand *cmd, Scene *scn);
-int kHideActor(ActionCommand *cmd, Scene *scn);
-int kShowActor(ActionCommand *cmd, Scene *scn);
-int kSetActorStats(ActionCommand *cmd, Scene *scn);
-int kSetSceneMotionStat(ActionCommand *cmd, Scene *scn);
-int kDisableActor(ActionCommand *cmd, Scene *scn);
-int kEnableActor(ActionCommand *cmd, Scene *scn);
-int kEnableBarriers(ActionCommand *cmd, Scene *scn);
-int kReturn(ActionCommand *cmd, Scene *scn);
-int kDestroyBarrier(ActionCommand *cmd, Scene *scn);
-int k_unk12_JMP_WALK_ACTOR(ActionCommand *cmd, Scene *scn);
-int k_unk13_JMP_WALK_ACTOR(ActionCommand *cmd, Scene *scn);
-int k_unk14_JMP_WALK_ACTOR(ActionCommand *cmd, Scene *scn);
-int k_unk15(ActionCommand *cmd, Scene *scn);
-int kResetAnimation(ActionCommand *cmd, Scene *scn);
-int kClearFlag1Bit0(ActionCommand *cmd, Scene *scn);
-int k_unk18_PLAY_SND(ActionCommand *cmd, Scene *scn);
-int kJumpIfFlag2Bit0(ActionCommand *cmd, Scene *scn);
-int kSetFlag2Bit0(ActionCommand *cmd, Scene *scn);
-int kClearFlag2Bit0(ActionCommand *cmd, Scene *scn);
-int kJumpIfFlag2Bit2(ActionCommand *cmd, Scene *scn);
-int kSetFlag2Bit2(ActionCommand *cmd, Scene *scn);
-int kClearFlag2Bit2(ActionCommand *cmd, Scene *scn);
-int kJumpIfFlag2Bit1(ActionCommand *cmd, Scene *scn);
-int kSetFlag2Bit1(ActionCommand *cmd, Scene *scn);
-int kClearFlag2Bit1(ActionCommand *cmd, Scene *scn);
-int k_unk22(ActionCommand *cmd, Scene *scn);
-int k_unk23(ActionCommand *cmd, Scene *scn);
-int k_unk24(ActionCommand *cmd, Scene *scn);
-int kRunEncounter(ActionCommand *cmd, Scene *scn);
-int kJumpIfFlag2Bit4(ActionCommand *cmd, Scene *scn);
-int kSetFlag2Bit4(ActionCommand *cmd, Scene *scn);
-int kClearFlag2Bit4(ActionCommand *cmd, Scene *scn);
-int kSetActorField638(ActionCommand *cmd, Scene *scn);
-int kJumpIfActorField638(ActionCommand *cmd, Scene *scn);
-int kChangeScene(ActionCommand *cmd, Scene *scn);
-int k_unk2C_ActorSub(ActionCommand *cmd, Scene *scn);
-int kPlayMovie(ActionCommand *cmd, Scene *scn);
-int kStopAllBarriersSounds(ActionCommand *cmd, Scene *scn);
-int kSetActionFlag(ActionCommand *cmd, Scene *scn);
-int kClearActionFlag(ActionCommand *cmd, Scene *scn);
-int kResetSceneRect(ActionCommand *cmd, Scene *scn);
-int kChangeMusicById(ActionCommand *cmd, Scene *scn);
-int kStopMusic(ActionCommand *cmd, Scene *scn);
-int k_unk34_Status(ActionCommand *cmd, Scene *scn);
-int k_unk35(ActionCommand *cmd, Scene *scn);
-int k_unk36(ActionCommand *cmd, Scene *scn);
-int kRunBlowUpPuzzle(ActionCommand *cmd, Scene *scn);
-int kJumpIfFlag2Bit3(ActionCommand *cmd, Scene *scn);
-int kSetFlag2Bit3(ActionCommand *cmd, Scene *scn);
-int kClearFlag2Bit3(ActionCommand *cmd, Scene *scn);
-int k_unk3B_PALETTE_MOD(ActionCommand *cmd, Scene *scn);
-int k_unk3C_CMP_VAL(ActionCommand *cmd, Scene *scn);
-int kWaitUntilFramePlayed(ActionCommand *cmd, Scene *scn);
-int kUpdateWideScreen(ActionCommand *cmd, Scene *scn);
-int k_unk3F(ActionCommand *cmd, Scene *scn);
-int k_unk40_SOUND(ActionCommand *cmd, Scene *scn);
-int kPlaySpeech(ActionCommand *cmd, Scene *scn);
-int k_unk42(ActionCommand *cmd, Scene *scn);
-int k_unk43(ActionCommand *cmd, Scene *scn);
-int kPaletteFade(ActionCommand *cmd, Scene *scn);
-int kStartPaletteFadeThread(ActionCommand *cmd, Scene *scn);
-int k_unk46(ActionCommand *cmd, Scene *scn);
-int kActorFaceObject(ActionCommand *cmd, Scene *scn);
-int k_unk48_MATTE_01(ActionCommand *cmd, Scene *scn);
-int k_unk49_MATTE_90(ActionCommand *cmd, Scene *scn);
-int kJumpIfSoundPlaying(ActionCommand *cmd, Scene *scn);
-int kChangePlayerCharacterIndex(ActionCommand *cmd, Scene *scn);
-int kChangeActorField40(ActionCommand *cmd, Scene *scn);
-int kStopSound(ActionCommand *cmd, Scene *scn);
-int k_unk4E_RANDOM_COMMAND(ActionCommand *cmd, Scene *scn);
-int kClearScreen(ActionCommand *cmd, Scene *scn);
-int kQuit(ActionCommand *cmd, Scene *scn);
-int kJumpBarrierFrame(ActionCommand *cmd, Scene *scn);
-int k_unk52(ActionCommand *cmd, Scene *scn);
-int k_unk53(ActionCommand *cmd, Scene *scn);
-int k_unk54_SET_ACTIONLIST_6EC(ActionCommand *cmd, Scene *scn);
-int k_unk55(ActionCommand *cmd, Scene *scn);
-int k_unk56(ActionCommand *cmd, Scene *scn);
-int kSetResourcePalette(ActionCommand *cmd, Scene *scn);
-int kSetBarrierFrameIdxFlaged(ActionCommand *cmd, Scene *scn);
-int k_unk59(ActionCommand *cmd, Scene *scn);
-int k_unk5A(ActionCommand *cmd, Scene *scn);
-int k_unk5B(ActionCommand *cmd, Scene *scn);
-int k_unk5C(ActionCommand *cmd, Scene *scn);
-int k_unk5D(ActionCommand *cmd, Scene *scn);
-int k_unk5E(ActionCommand *cmd, Scene *scn);
-int kSetBarrierLastFrameIdx(ActionCommand *cmd, Scene *scn);
-int k_unk60_SET_OR_CLR_ACTIONAREA_FLAG(ActionCommand *cmd, Scene *scn);
-int k_unk61(ActionCommand *cmd, Scene *scn);
-int k_unk62_SHOW_OPTIONS_SCREEN(ActionCommand *cmd, Scene *scn);
-int k_unk63(ActionCommand *cmd, Scene *scn);
+int kReturn0(Script *script, ScriptEntry *cmd, Scene *scn);
+int kSetGameFlag(Script *script, ScriptEntry *cmd, Scene *scn);
+int kClearGameFlag(Script *script, ScriptEntry *cmd, Scene *scn);
+int kToggleGameFlag(Script *script, ScriptEntry *cmd, Scene *scn);
+int kJumpIfGameFlag(Script *script, ScriptEntry *cmd, Scene *scn);
+int kHideCursor(Script *script, ScriptEntry *cmd, Scene *scn);
+int kShowCursor(Script *script, ScriptEntry *cmd, Scene *scn);
+int kPlayAnimation(Script *script, ScriptEntry *cmd, Scene *scn);
+int kMoveScenePosition(Script *script, ScriptEntry *cmd, Scene *scn);
+int kHideActor(Script *script, ScriptEntry *cmd, Scene *scn);
+int kShowActor(Script *script, ScriptEntry *cmd, Scene *scn);
+int kSetActorStats(Script *script, ScriptEntry *cmd, Scene *scn);
+int kSetSceneMotionStat(Script *script, ScriptEntry *cmd, Scene *scn);
+int kDisableActor(Script *script, ScriptEntry *cmd, Scene *scn);
+int kEnableActor(Script *script, ScriptEntry *cmd, Scene *scn);
+int kEnableBarriers(Script *script, ScriptEntry *cmd, Scene *scn);
+int kReturn(Script *script, ScriptEntry *cmd, Scene *scn);
+int kDestroyBarrier(Script *script, ScriptEntry *cmd, Scene *scn);
+int k_unk12_JMP_WALK_ACTOR(Script *script, ScriptEntry *cmd, Scene *scn);
+int k_unk13_JMP_WALK_ACTOR(Script *script, ScriptEntry *cmd, Scene *scn);
+int k_unk14_JMP_WALK_ACTOR(Script *script, ScriptEntry *cmd, Scene *scn);
+int k_unk15(Script *script, ScriptEntry *cmd, Scene *scn);
+int kResetAnimation(Script *script, ScriptEntry *cmd, Scene *scn);
+int kClearFlag1Bit0(Script *script, ScriptEntry *cmd, Scene *scn);
+int k_unk18_PLAY_SND(Script *script, ScriptEntry *cmd, Scene *scn);
+int kJumpIfFlag2Bit0(Script *script, ScriptEntry *cmd, Scene *scn);
+int kSetFlag2Bit0(Script *script, ScriptEntry *cmd, Scene *scn);
+int kClearFlag2Bit0(Script *script, ScriptEntry *cmd, Scene *scn);
+int kJumpIfFlag2Bit2(Script *script, ScriptEntry *cmd, Scene *scn);
+int kSetFlag2Bit2(Script *script, ScriptEntry *cmd, Scene *scn);
+int kClearFlag2Bit2(Script *script, ScriptEntry *cmd, Scene *scn);
+int kJumpIfFlag2Bit1(Script *script, ScriptEntry *cmd, Scene *scn);
+int kSetFlag2Bit1(Script *script, ScriptEntry *cmd, Scene *scn);
+int kClearFlag2Bit1(Script *script, ScriptEntry *cmd, Scene *scn);
+int k_unk22(Script *script, ScriptEntry *cmd, Scene *scn);
+int k_unk23(Script *script, ScriptEntry *cmd, Scene *scn);
+int k_unk24(Script *script, ScriptEntry *cmd, Scene *scn);
+int kRunEncounter(Script *script, ScriptEntry *cmd, Scene *scn);
+int kJumpIfFlag2Bit4(Script *script, ScriptEntry *cmd, Scene *scn);
+int kSetFlag2Bit4(Script *script, ScriptEntry *cmd, Scene *scn);
+int kClearFlag2Bit4(Script *script, ScriptEntry *cmd, Scene *scn);
+int kSetActorField638(Script *script, ScriptEntry *cmd, Scene *scn);
+int kJumpIfActorField638(Script *script, ScriptEntry *cmd, Scene *scn);
+int kChangeScene(Script *script, ScriptEntry *cmd, Scene *scn);
+int k_unk2C_ActorSub(Script *script, ScriptEntry *cmd, Scene *scn);
+int kPlayMovie(Script *script, ScriptEntry *cmd, Scene *scn);
+int kStopAllBarriersSounds(Script *script, ScriptEntry *cmd, Scene *scn);
+int kSetActionFlag(Script *script, ScriptEntry *cmd, Scene *scn);
+int kClearActionFlag(Script *script, ScriptEntry *cmd, Scene *scn);
+int kResetSceneRect(Script *script, ScriptEntry *cmd, Scene *scn);
+int kChangeMusicById(Script *script, ScriptEntry *cmd, Scene *scn);
+int kStopMusic(Script *script, ScriptEntry *cmd, Scene *scn);
+int k_unk34_Status(Script *script, ScriptEntry *cmd, Scene *scn);
+int k_unk35(Script *script, ScriptEntry *cmd, Scene *scn);
+int k_unk36(Script *script, ScriptEntry *cmd, Scene *scn);
+int kRunBlowUpPuzzle(Script *script, ScriptEntry *cmd, Scene *scn);
+int kJumpIfFlag2Bit3(Script *script, ScriptEntry *cmd, Scene *scn);
+int kSetFlag2Bit3(Script *script, ScriptEntry *cmd, Scene *scn);
+int kClearFlag2Bit3(Script *script, ScriptEntry *cmd, Scene *scn);
+int k_unk3B_PALETTE_MOD(Script *script, ScriptEntry *cmd, Scene *scn);
+int k_unk3C_CMP_VAL(Script *script, ScriptEntry *cmd, Scene *scn);
+int kWaitUntilFramePlayed(Script *script, ScriptEntry *cmd, Scene *scn);
+int kUpdateWideScreen(Script *script, ScriptEntry *cmd, Scene *scn);
+int k_unk3F(Script *script, ScriptEntry *cmd, Scene *scn);
+int k_unk40_SOUND(Script *script, ScriptEntry *cmd, Scene *scn);
+int kPlaySpeech(Script *script, ScriptEntry *cmd, Scene *scn);
+int k_unk42(Script *script, ScriptEntry *cmd, Scene *scn);
+int k_unk43(Script *script, ScriptEntry *cmd, Scene *scn);
+int kPaletteFade(Script *script, ScriptEntry *cmd, Scene *scn);
+int kStartPaletteFadeThread(Script *script, ScriptEntry *cmd, Scene *scn);
+int k_unk46(Script *script, ScriptEntry *cmd, Scene *scn);
+int kActorFaceObject(Script *script, ScriptEntry *cmd, Scene *scn);
+int k_unk48_MATTE_01(Script *script, ScriptEntry *cmd, Scene *scn);
+int k_unk49_MATTE_90(Script *script, ScriptEntry *cmd, Scene *scn);
+int kJumpIfSoundPlaying(Script *script, ScriptEntry *cmd, Scene *scn);
+int kChangePlayerCharacterIndex(Script *script, ScriptEntry *cmd, Scene *scn);
+int kChangeActorField40(Script *script, ScriptEntry *cmd, Scene *scn);
+int kStopSound(Script *script, ScriptEntry *cmd, Scene *scn);
+int k_unk4E_RANDOM_COMMAND(Script *script, ScriptEntry *cmd, Scene *scn);
+int kClearScreen(Script *script, ScriptEntry *cmd, Scene *scn);
+int kQuit(Script *script, ScriptEntry *cmd, Scene *scn);
+int kJumpBarrierFrame(Script *script, ScriptEntry *cmd, Scene *scn);
+int k_unk52(Script *script, ScriptEntry *cmd, Scene *scn);
+int k_unk53(Script *script, ScriptEntry *cmd, Scene *scn);
+int k_unk54_SET_ACTIONLIST_6EC(Script *script, ScriptEntry *cmd, Scene *scn);
+int k_unk55(Script *script, ScriptEntry *cmd, Scene *scn);
+int k_unk56(Script *script, ScriptEntry *cmd, Scene *scn);
+int kSetResourcePalette(Script *script, ScriptEntry *cmd, Scene *scn);
+int kSetBarrierFrameIdxFlaged(Script *script, ScriptEntry *cmd, Scene *scn);
+int k_unk59(Script *script, ScriptEntry *cmd, Scene *scn);
+int k_unk5A(Script *script, ScriptEntry *cmd, Scene *scn);
+int k_unk5B(Script *script, ScriptEntry *cmd, Scene *scn);
+int k_unk5C(Script *script, ScriptEntry *cmd, Scene *scn);
+int k_unk5D(Script *script, ScriptEntry *cmd, Scene *scn);
+int k_unk5E(Script *script, ScriptEntry *cmd, Scene *scn);
+int kSetBarrierLastFrameIdx(Script *script, ScriptEntry *cmd, Scene *scn);
+int k_unk60_SET_OR_CLR_ACTIONAREA_FLAG(Script *script, ScriptEntry *cmd, Scene *scn);
+int k_unk61(Script *script, ScriptEntry *cmd, Scene *scn);
+int k_unk62_SHOW_OPTIONS_SCREEN(Script *script, ScriptEntry *cmd, Scene *scn);
+int k_unk63(Script *script, ScriptEntry *cmd, Scene *scn);
} // end of namespace Asylum
diff --git a/engines/asylum/actor.cpp b/engines/asylum/actor.cpp
index 3d54291a92..e265d47f98 100644
--- a/engines/asylum/actor.cpp
+++ b/engines/asylum/actor.cpp
@@ -160,7 +160,8 @@ void Actor::drawActor() {
void Actor::setWalkArea(ActionArea *target) {
if (_currentWalkArea != target) {
- _scene->actions()->setScriptByIndex(target->actionListIdx1);
+ // FIXME
+ //_scene->actions()->setScriptByIndex(target->actionListIdx1);
_currentWalkArea = target;
debugC(kDebugLevelScripts, "%s", target->name);
}
diff --git a/engines/asylum/asylum.cpp b/engines/asylum/asylum.cpp
index 7c2ca228a2..1d4cea1b63 100644
--- a/engines/asylum/asylum.cpp
+++ b/engines/asylum/asylum.cpp
@@ -115,10 +115,6 @@ Common::Error AsylumEngine::go() {
// can be removed as well.
_scene->setBlowUpPuzzle(new BlowUpPuzzleVCR(_scene));
- // FIXME This can probably also be rolled into the scene constructor.
- // Investigate if this will fuck up the execution sequence though :P
- _scene->actions()->setScriptByIndex(_scene->worldstats()->actionListIdx);
-
// Set up main menu
_mainMenu = new MainMenu(this);
@@ -285,7 +281,6 @@ void AsylumEngine::processDelayedEvents() {
_scene->enterScene();
_scene->actions()->delayedSceneIndex = -1;
- _scene->actions()->setScriptByIndex(_scene->worldstats()->actionListIdx);
}
}
diff --git a/engines/asylum/console.cpp b/engines/asylum/console.cpp
index f3da3f876b..7b0e3bfb73 100644
--- a/engines/asylum/console.cpp
+++ b/engines/asylum/console.cpp
@@ -127,8 +127,8 @@ bool Console::cmdRunScript(int argc, const char **argv) {
DebugPrintf("Usage %s <script number>\n", argv[0]);
return true;
}
-
- _vm->scene()->actions()->setScriptByIndex(atoi(argv[1]));
+ // FIXME push the script index into the script queue
+ //_vm->scene()->actions()->setScriptByIndex(atoi(argv[1]));
return false;
}
@@ -145,8 +145,9 @@ bool Console::cmdChangeScene(int argc, const char **argv) {
}
_vm->scene()->actions()->delayedSceneIndex = atoi(argv[1]);
- _vm->scene()->actions()->setScriptByIndex(0); // XXX is this right or should it be
- // ws->actionListIdx???
+ // FIXME push the script index into the script queue
+ // XXX is this right or should it be ws->actionListIdx???
+ //_vm->scene()->actions()->setScriptByIndex(0);
return false;
}
diff --git a/engines/asylum/scene.cpp b/engines/asylum/scene.cpp
index e4bcd6bcbd..d60d40d0e3 100644
--- a/engines/asylum/scene.cpp
+++ b/engines/asylum/scene.cpp
@@ -170,7 +170,7 @@ void Scene::initialize() {
uint32 actionIdx = _ws->actionListIdx;
if (actionIdx)
- _actions->initItem(actionIdx, 0);
+ _actions->queueScript(actionIdx, 0);
// TODO initActionListArrayItem(idx, 0) .text:00401050
// XXX not sure why we need to do this again
@@ -1277,7 +1277,7 @@ void Scene::OLD_UPDATE() {
_ws->actions[a].actionListIdx2,
_ws->actions[a].actionType,
_ws->actions[a].soundResId);
- _actions->setScriptByIndex(_ws->actions[a].actionListIdx1);
+ // FIXME _actions->setScriptByIndex(_ws->actions[a].actionListIdx1);
}
}
} else if (curBarrier >= 0) {
@@ -1288,7 +1288,7 @@ void Scene::OLD_UPDATE() {
b.soundResId,
b.flags,
b.flags2);
- _actions->setScriptByIndex(b.actionListIdx);
+ // FIXME _actions->setScriptByIndex(b.actionListIdx);
}
}
}
@@ -1402,7 +1402,7 @@ void Scene::drawActorsAndBarriers() {
if (pt.x > 0 && pt.y > 0 && poly->numPoints > 0)
intersects = poly->contains(pt.x, pt.y);
else
- warning ("[drawActorsAndBarriers] trying to find intersection of uninitialized point");
+ ;//warning ("[drawActorsAndBarriers] trying to find intersection of uninitialized point");
}
// XXX the original has an else case here that
// assigns intersects the value of the
@@ -1423,7 +1423,7 @@ void Scene::drawActorsAndBarriers() {
if (bar->flags & 4) {
if (intersects) {
if(act->flags & 2)
- warning ("[drawActorsAndBarriers] Assigning mask to masked character [%s]", bar->name);
+ ;//warning ("[drawActorsAndBarriers] Assigning mask to masked character [%s]", bar->name);
else {
// TODO there's a call to sub_40ac10 that does
// a point calculation, but the result doesn't appear to
Commit: d22a3cae67d63567a53c3e7f9a83e69392e65405
https://github.com/scummvm/scummvm/commit/d22a3cae67d63567a53c3e7f9a83e69392e65405
Author: Alex Bevilacqua (alexbevi at gmail.com)
Date: 2021-05-17T15:35:55+02:00
Commit Message:
ASYLUM: minor cleanup and silenced a couple warning
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@396 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/actionlist.cpp
engines/asylum/scene.cpp
engines/asylum/worldstats.h
diff --git a/engines/asylum/actionlist.cpp b/engines/asylum/actionlist.cpp
index f3869c4f2b..15f8fa8565 100644
--- a/engines/asylum/actionlist.cpp
+++ b/engines/asylum/actionlist.cpp
@@ -554,13 +554,13 @@ int kMoveScenePosition(Script *script, ScriptEntry *cmd, Scene *scn) {
ws->targetY = cmd->param2;
ws->field_A0 = cmd->param3;
- if (ws->targetX < (uint32)sr->left)
+ if (ws->targetX < sr->left)
ws->targetX = sr->left;
- if (ws->targetY < (uint32)sr->top)
+ if (ws->targetY < sr->top)
ws->targetY = sr->top;
- if (ws->targetX + 640 > (uint32)sr->right)
+ if (ws->targetX + 640 > sr->right)
ws->targetX = sr->right - 640;
- if (ws->targetY + 480 > (uint32)sr->bottom)
+ if (ws->targetY + 480 > sr->bottom)
ws->targetY = sr->bottom - 480;
// TODO: reverse asm block
@@ -577,15 +577,15 @@ int kMoveScenePosition(Script *script, ScriptEntry *cmd, Scene *scn) {
ws->targetY = cmd->param2;
ws->field_A0 = cmd->param3;
- if (ws->targetX + 640 > ws->width)
+ if (ws->targetX + 640 > (int)ws->width)
ws->targetX = ws->width - 640;
- if (ws->targetX < (uint32)sr->left)
+ if (ws->targetX < sr->left)
ws->targetX = sr->left;
- if (ws->targetY < (uint32)sr->top)
+ if (ws->targetY < sr->top)
ws->targetY = sr->top;
- if (ws->targetX + 640 > (uint32)sr->right)
+ if (ws->targetX + 640 > sr->right)
ws->targetX = sr->right - 640;
- if (ws->targetY + 480 > (uint32)sr->bottom)
+ if (ws->targetY + 480 > sr->bottom)
ws->targetY = sr->bottom - 480;
// TODO: reverse asm block
@@ -1046,7 +1046,7 @@ int kPlaySpeech(Script *script, ScriptEntry *cmd, Scene *scn) {
scn->getSceneIndex(),
scn->actions()->currentLine);
- return 0;
+ return -1;
}
int k_unk42(Script *script, ScriptEntry *cmd, Scene *scn) {
diff --git a/engines/asylum/scene.cpp b/engines/asylum/scene.cpp
index d60d40d0e3..049bf71dc9 100644
--- a/engines/asylum/scene.cpp
+++ b/engines/asylum/scene.cpp
@@ -172,7 +172,6 @@ void Scene::initialize() {
if (actionIdx)
_actions->queueScript(actionIdx, 0);
- // TODO initActionListArrayItem(idx, 0) .text:00401050
// XXX not sure why we need to do this again
_vm->screen()->clearScreen();
// TODO loadTransTables(3, field_64/68/7C)
diff --git a/engines/asylum/worldstats.h b/engines/asylum/worldstats.h
index a0bc4815d8..a1903c1343 100644
--- a/engines/asylum/worldstats.h
+++ b/engines/asylum/worldstats.h
@@ -141,7 +141,7 @@ public:
// TODO add rest fields
Common::Array<ActionArea> actions; // maxsize 400
// TODO add rest fields
- uint32 field_E860C;
+ int field_E860C;
// TODO add rest fields
int getActionAreaIndexById(uint32 id);
Commit: 84b6fde0d1a9a4c95d8f4e171d7d46d38d8757e1
https://github.com/scummvm/scummvm/commit/84b6fde0d1a9a4c95d8f4e171d7d46d38d8757e1
Author: Alex Bevilacqua (alexbevi at gmail.com)
Date: 2021-05-17T15:35:55+02:00
Commit Message:
ASYLUM: Trying out a stack-based script queue management system. This is what I assume is an optimized version of the original :P
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@397 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/actionlist.cpp
engines/asylum/actionlist.h
diff --git a/engines/asylum/actionlist.cpp b/engines/asylum/actionlist.cpp
index 15f8fa8565..aacd9fe4a1 100644
--- a/engines/asylum/actionlist.cpp
+++ b/engines/asylum/actionlist.cpp
@@ -163,36 +163,13 @@ static const AsylumFunction function_map[] = {
#undef MAPFUNC
-/*
-void ActionList::setScriptByIndex(uint32 index) {
- currentLine = 0;
- _currentScript = &entries[index]; // TODO assert if out of bounds
-
- if (Common::isDebugChannelEnabled(kDebugLevelScripts)) {
- for (uint8 i = 0; i < _currentScript->commands[0].numLines; i++) {
- debugC(kDebugLevelScripts,
- "Line: %02d/%02d :: 0x%02X (%d, %d, %d, %d, %d, %d, %d, %d, %d)",
- i,
- _currentScript->commands[0].numLines - 1,
- _currentScript->commands[i].opcode,
- _currentScript->commands[i].param1,
- _currentScript->commands[i].param2,
- _currentScript->commands[i].param3,
- _currentScript->commands[i].param4,
- _currentScript->commands[i].param5,
- _currentScript->commands[i].param6,
- _currentScript->commands[i].param7,
- _currentScript->commands[i].param8,
- _currentScript->commands[i].param9);
- }
- }
-}
-*/
-
void ActionList::resetQueue() {
+ /*
memset(&_scripts, 0, sizeof(ScriptQueue));
for (int i = 0; i < 10; i++)
_scripts.entries[i].actionListIndex = -1;
+ */
+ _scripts.clear();
}
void ActionList::queueScript(int actionIndex, int actorIndex) {
@@ -200,6 +177,8 @@ void ActionList::queueScript(int actionIndex, int actorIndex) {
// It appears to remain false 99% of the time, so I'm guessing
// it's a "skip processing" flag.
if (!_actionFlag) {
+
+ /*
int i;
// iterate through the availble entry slots to determine
// the next available slot
@@ -223,9 +202,25 @@ void ActionList::queueScript(int actionIndex, int actorIndex) {
_scripts.entries[0].actionListIndex = actionIndex;
_scripts.entries[0].actionListItemIndex = 0;
_scripts.entries[0].actorIndex = actorIndex;
+ */
+
+ ScriptQueueEntry entry;
+ entry.actionListIndex = actionIndex;
+ entry.actorIndex = actorIndex;
+
+ // If there's currently no script for the processor to run,
+ // assign it directly and skip the stack push. If however the
+ // current script is assigned, push the script to the stack
+ if (_currentScript)
+ _scripts.push(entry);
+ else {
+ _currentQueueEntry = entry;
+ _currentScript = &entries[entry.actionListIndex];
+ }
}
}
+/*
void ActionList::updateQueue(int queueIndex) {
if (_scripts.count == _scripts.field_CC) {
_scripts.field_CC = 0;
@@ -251,6 +246,7 @@ void ActionList::updateQueue(int queueIndex) {
}
}
}
+*/
void ActionList::processActionListSub02(Script* script, ScriptEntry *command, int a4) {
//int v4 = 0;
@@ -332,24 +328,31 @@ int ActionList::process() {
lineIncrement = 1;
processing = true;
- while (_scripts.count) {
- Script *currentScript = &entries[_scripts.entries[_scripts.count - 1].actionListIndex];
- currentLine = 0;
- while (!done && !waitCycle) {
- lineIncrement = 0; //Reset line increment value
+ _scene->vm()->setGameFlag(183);
- if (currentLoops > 1000) {
- //TODO - processActionLists has run too many iterations
- }
+ if (_currentScript)
+ while (!done && !waitCycle) {
+ lineIncrement = 0; //Reset line increment value
- ScriptEntry *currentCommand = ¤tScript->commands[currentLine];
+ ScriptEntry *currentCommand = &_currentScript->commands[currentLine];
uint32 opcode = currentCommand->opcode;
- debugC(kDebugLevelScripts, "%s (0x%02d)", function_map[opcode].name, opcode);
+ debugC(kDebugLevelScripts,
+ "[0x%02d] %s(%d, %d, %d, %d, %d, %d, %d, %d, %d)",
+ opcode,function_map[opcode].name,
+ currentCommand->param1,
+ currentCommand->param2,
+ currentCommand->param3,
+ currentCommand->param4,
+ currentCommand->param5,
+ currentCommand->param6,
+ currentCommand->param7,
+ currentCommand->param8,
+ currentCommand->param9);
// Execute command from function mapping
- int cmdRet = function_map[opcode].function(currentScript, currentCommand, _scene);
+ int cmdRet = function_map[opcode].function(_currentScript, currentCommand, _scene);
// Check function return
if (cmdRet == -1)
@@ -374,17 +377,19 @@ int ActionList::process() {
if (!lineIncrement) {
currentLine ++;
- currentLoops++;
}
} // end while
- updateQueue(_scripts.count);
-
if (done) {
currentLine = 0;
- currentLoops = 0;
+ if (!_scripts.empty()) {
+ _currentQueueEntry = _scripts.pop();
+ _currentScript = &entries[_currentQueueEntry.actionListIndex];
+ } else {
+ _currentScript = 0;
}
+
}
// XXX
diff --git a/engines/asylum/actionlist.h b/engines/asylum/actionlist.h
index a5140e8479..b9a3969169 100644
--- a/engines/asylum/actionlist.h
+++ b/engines/asylum/actionlist.h
@@ -27,6 +27,7 @@
#define ASYLUM_ACTIONLIST_H_
#include "common/array.h"
+#include "common/stack.h"
#include "common/stream.h"
#include "asylum/scene.h"
@@ -61,19 +62,21 @@ typedef struct Script {
typedef struct ScriptQueueEntry {
int actionListIndex;
- int actionListItemIndex;
+ //int actionListItemIndex;
int actorIndex;
- int field_C;
- int field_10;
+ //int field_C;
+ //int field_10;
} ScriptQueueEntry;
+/*
typedef struct ScriptQueue {
ScriptQueueEntry entries[10];
int count;
int field_CC;
} ScriptQueue;
+*/
class ActionList {
public:
@@ -115,7 +118,7 @@ public:
/** .text:00401100
* Update the queued scripts
*/
- void updateQueue(int queueIndex);
+ //void updateQueue(int queueIndex);
/**
* Toggle the action queue processing flag
*/
@@ -128,8 +131,10 @@ public:
private:
Scene *_scene;
bool _actionFlag;
- ScriptQueue _scripts;
-
+ //ScriptQueue _scripts;
+ Common::Stack<ScriptQueueEntry> _scripts;
+ Script *_currentScript;
+ ScriptQueueEntry _currentQueueEntry;
void load(Common::SeekableReadStream *stream);
};
Commit: 9cc79d0cea4baea936e2e0d876cd21c1dd021d13
https://github.com/scummvm/scummvm/commit/9cc79d0cea4baea936e2e0d876cd21c1dd021d13
Author: Alex Bevilacqua (alexbevi at gmail.com)
Date: 2021-05-17T15:35:56+02:00
Commit Message:
ASYLUM: remove "processing" flag and just check for flag 183
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@398 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/actionlist.cpp
engines/asylum/actionlist.h
engines/asylum/asylum.cpp
diff --git a/engines/asylum/actionlist.cpp b/engines/asylum/actionlist.cpp
index aacd9fe4a1..1e66b6aa1e 100644
--- a/engines/asylum/actionlist.cpp
+++ b/engines/asylum/actionlist.cpp
@@ -34,7 +34,6 @@ ActionList::ActionList(Common::SeekableReadStream *stream, Scene *scene)
currentLine = 0;
currentLoops = 0;
- processing = false;
delayedSceneIndex = -1;
delayedVideoIndex = -1;
allowInput = true;
@@ -44,6 +43,7 @@ ActionList::ActionList(Common::SeekableReadStream *stream, Scene *scene)
ActionList::~ActionList() {
entries.clear();
+ _scripts.clear();
}
typedef int AsylumFunc(Script *script, ScriptEntry *cmd, Scene *scn);
@@ -326,7 +326,6 @@ int ActionList::process() {
done = false;
waitCycle = false;
lineIncrement = 1;
- processing = true;
_scene->vm()->setGameFlag(183);
@@ -392,12 +391,7 @@ int ActionList::process() {
}
- // XXX
- // gameFlag 183 is the same as the
- // processing flag, but is not being used
_scene->vm()->clearGameFlag(183);
- processing = false;
-
return 0;
}
diff --git a/engines/asylum/actionlist.h b/engines/asylum/actionlist.h
index b9a3969169..bb1f9fde4e 100644
--- a/engines/asylum/actionlist.h
+++ b/engines/asylum/actionlist.h
@@ -97,7 +97,6 @@ public:
int delayedSceneIndex;
int delayedVideoIndex;
bool allowInput;
- bool processing;
int lineIncrement;
bool done;
bool waitCycle;
diff --git a/engines/asylum/asylum.cpp b/engines/asylum/asylum.cpp
index 1d4cea1b63..3f5c193a37 100644
--- a/engines/asylum/asylum.cpp
+++ b/engines/asylum/asylum.cpp
@@ -270,7 +270,9 @@ void AsylumEngine::processDelayedEvents() {
// check for a delayed scene change
int sceneIdx = _scene->actions()->delayedSceneIndex;
- if (sceneIdx >= 0 && !_scene->actions()->processing) {
+ // XXX Flag 183 indicates whether the actionlist is currently
+ // processing
+ if (sceneIdx >= 0 && isGameFlagNotSet(183)) {
_sound->stopMusic();
_sound->stopAllSounds();
Commit: 05ec1ccd5e21d1c81c85a9e1b89da23a003e7bd9
https://github.com/scummvm/scummvm/commit/05ec1ccd5e21d1c81c85a9e1b89da23a003e7bd9
Author: Alexandre Fontoura (alexandrefontoura at gmail.com)
Date: 2021-05-17T15:35:56+02:00
Commit Message:
ASYLUM: * Fixed proper _currentScript pointer initialization.
* Silent some warnings.
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@399 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/actionlist.cpp
engines/asylum/actor.cpp
engines/asylum/actor.h
engines/asylum/barrier.h
engines/asylum/menu.cpp
engines/asylum/scene.cpp
engines/asylum/scene.h
engines/asylum/worldstats.h
diff --git a/engines/asylum/actionlist.cpp b/engines/asylum/actionlist.cpp
index 1e66b6aa1e..d6540272a7 100644
--- a/engines/asylum/actionlist.cpp
+++ b/engines/asylum/actionlist.cpp
@@ -32,6 +32,7 @@ ActionList::ActionList(Common::SeekableReadStream *stream, Scene *scene)
: _scene(scene) {
load(stream);
+ _currentScript = 0;
currentLine = 0;
currentLoops = 0;
delayedSceneIndex = -1;
diff --git a/engines/asylum/actor.cpp b/engines/asylum/actor.cpp
index e265d47f98..1e98b413b9 100644
--- a/engines/asylum/actor.cpp
+++ b/engines/asylum/actor.cpp
@@ -167,7 +167,7 @@ void Actor::setWalkArea(ActionArea *target) {
}
}
-void Actor::walkTo(uint32 curX, uint32 curY) {
+void Actor::walkTo(int32 curX, int32 curY) {
int newAction = currentAction;
WorldStats *ws = _scene->worldstats();
diff --git a/engines/asylum/actor.h b/engines/asylum/actor.h
index 3394addfad..5020862c9d 100644
--- a/engines/asylum/actor.h
+++ b/engines/asylum/actor.h
@@ -180,7 +180,7 @@ public:
void setActionByIndex(int index);
void drawActorAt(uint32 curX, uint32 curY);
void drawActor();
- void walkTo(uint32 curX, uint32 curY);
+ void walkTo(int32 curX, int32 curY);
int currentAction; // TODO depreciate
diff --git a/engines/asylum/barrier.h b/engines/asylum/barrier.h
index 146b7834db..de8cdc001e 100644
--- a/engines/asylum/barrier.h
+++ b/engines/asylum/barrier.h
@@ -58,10 +58,10 @@ public:
uint32 flags;
uint32 field_3C;
uint8 name[52];
- uint32 field_74; // XXX looks like fields
- uint32 field_78; // 78 => 80 have something
- uint32 field_7C; // to do with calculating
- uint32 field_80; // actor intersection
+ int32 field_74; // XXX looks like fields
+ int32 field_78; // 78 => 80 have something
+ int32 field_7C; // to do with calculating
+ int32 field_80; // actor intersection
uint32 polyIdx;
uint32 flags2;
uint32 gameFlags[10];
diff --git a/engines/asylum/menu.cpp b/engines/asylum/menu.cpp
index ff54c05ff5..5d44b150cf 100644
--- a/engines/asylum/menu.cpp
+++ b/engines/asylum/menu.cpp
@@ -440,7 +440,7 @@ void MainMenu::updateSubMenuSettings() {
_vm->text()->setTextPos(sizeMinus + sizePlus + 365, 150);
loadFont(kFontYellow);
if (Config.gammaLevel) {
- for (uint32 i = 0; i < Config.gammaLevel; i++) {
+ for (int32 i = 0; i < Config.gammaLevel; i++) {
_vm->text()->drawText("]");
}
if (Config.gammaLevel == 8)
@@ -464,7 +464,7 @@ void MainMenu::updateSubMenuSettings() {
if (Config.performance == 5) {
_vm->text()->drawResText(0x8000059C);
} else {
- for (uint32 i = 5; i > Config.performance; --i) {
+ for (int32 i = 5; i > Config.performance; --i) {
_vm->text()->drawText("]");
}
if (!Config.performance)
diff --git a/engines/asylum/scene.cpp b/engines/asylum/scene.cpp
index 049bf71dc9..4be292d740 100644
--- a/engines/asylum/scene.cpp
+++ b/engines/asylum/scene.cpp
@@ -684,7 +684,7 @@ void Scene::updateMouse() {
//printf("Current Dir %d -- New Dir %d\n", actor->direction, dir);
}
-void Scene::updateActor(uint32 actorIdx) {
+void Scene::updateActor(int32 actorIdx) {
Actor *actor = getActor();
if (actor->visible()) {
@@ -1381,7 +1381,7 @@ void Scene::drawActorsAndBarriers() {
// works the way I assume it should :P
if (!actInBar) {
if (LOBYTE(bar->flags) & 0x20)
- if (!LOBYTE(bar->flags) & 0x80)
+ if (!(LOBYTE(bar->flags) & 0x80))
// XXX not sure if this will work, as it's
// supposed to set 0x40 to the lobyte...
bar->flags |= 0x40;
@@ -1571,13 +1571,13 @@ void Scene::debugScreenScrolling(GraphicFrame *bg) {
// Horizontal scrolling
if (_cursor->x() < SCREEN_EDGES && _ws->targetX >= SCROLL_STEP)
_ws->targetX -= SCROLL_STEP;
- else if (_cursor->x() > 640 - SCREEN_EDGES && _ws->targetX <= (uint32)bg->surface.w - 640 - SCROLL_STEP)
+ else if (_cursor->x() > 640 - SCREEN_EDGES && _ws->targetX <= bg->surface.w - 640 - SCROLL_STEP)
_ws->targetX += SCROLL_STEP;
// Vertical scrolling
if (_cursor->y() < SCREEN_EDGES && _ws->targetY >= SCROLL_STEP)
_ws->targetY -= SCROLL_STEP;
- else if (_cursor->y() > 480 - SCREEN_EDGES && _ws->targetY <= (uint32)bg->surface.h - 480 - SCROLL_STEP)
+ else if (_cursor->y() > 480 - SCREEN_EDGES && _ws->targetY <= bg->surface.h - 480 - SCROLL_STEP)
_ws->targetY += SCROLL_STEP;
}
diff --git a/engines/asylum/scene.h b/engines/asylum/scene.h
index 15b1d28182..f82a79d0e8 100644
--- a/engines/asylum/scene.h
+++ b/engines/asylum/scene.h
@@ -156,7 +156,7 @@ private:
bool _rightButton;
bool _isActive;
bool _skipDrawScene;
- uint32 _playerActorIdx;
+ int32 _playerActorIdx;
/** .text:0040E460
* Initialize the current scene
@@ -175,7 +175,7 @@ private:
/** .text:0040D190 */
void updateMouse();
/** .text:0040B740 */
- void updateActor(uint32 actorIdx);
+ void updateActor(int32 actorIdx);
/**
* TODO give more meaningful name
*/
@@ -189,6 +189,7 @@ private:
/** .text:0040DAE0 */
void updateAdjustScreen();
int drawScene();
+ /** .text:0040A3C0 */
void drawActorsAndBarriers();
int queueActorUpdates();
int queueBarrierUpdates();
diff --git a/engines/asylum/worldstats.h b/engines/asylum/worldstats.h
index a1903c1343..fd640119d9 100644
--- a/engines/asylum/worldstats.h
+++ b/engines/asylum/worldstats.h
@@ -119,7 +119,7 @@ public:
Common::Rect sceneRects[6]; // including scene size rect
uint8 sceneRectIdx;
uint8 field_11D[3];
- uint32 field_120;
+ int32 field_120;
uint32 actionListIdx; // actionList start index
uint32 grResId[100];
uint32 sceneTitleGrResId;
Commit: dcf0cce2c59c3d19927308ca90c36cf74fea3a65
https://github.com/scummvm/scummvm/commit/dcf0cce2c59c3d19927308ca90c36cf74fea3a65
Author: Alexandre Fontoura (alexandrefontoura at gmail.com)
Date: 2021-05-17T15:35:56+02:00
Commit Message:
ASYLUM: * Fixed Sound::isPlaying buffered handle.
* Fixed Intro play and display
* ConfigurationManager Config.showMovieSubtitles is now from type VideoSubtitles.
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@400 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/asylum.cpp
engines/asylum/config.h
engines/asylum/respack.h
engines/asylum/sound.cpp
engines/asylum/sound.h
engines/asylum/video.cpp
diff --git a/engines/asylum/asylum.cpp b/engines/asylum/asylum.cpp
index 3f5c193a37..ff28edb1f6 100644
--- a/engines/asylum/asylum.cpp
+++ b/engines/asylum/asylum.cpp
@@ -126,12 +126,15 @@ Common::Error AsylumEngine::go() {
// Also, this routine is used to set game flags 4 and 12, so if we're
// skipping the intro, but not loading a save file, those flags
// need to be set somewhere else.
- //playIntro();
+ playIntro();
- // Enter first scene
- setGameFlag(4);
- setGameFlag(12);
- _scene->enterScene();
+ // Enter first scene
+ if(!_introPlaying)
+ {
+ setGameFlag(4);
+ setGameFlag(12);
+ _scene->enterScene();
+ }
while (!shouldQuit()) {
checkForEvent(true);
@@ -152,7 +155,10 @@ void AsylumEngine::waitForTimer(int msec_delay) {
}
void AsylumEngine::playIntro() {
- _video->playVideo(1, kSubtitlesOn);
+ _introPlaying = true;
+ g_system->showMouse(false);
+
+ _video->playVideo(1, Config.showMovieSubtitles);
if (_scene->worldstats()->musicCurrentResId != 0xFFFFFD66)
_sound->playMusic(_scene->worldstats()->musicCurrentResId);
@@ -164,7 +170,7 @@ void AsylumEngine::playIntro() {
// Play the intro sound sample (the screen is blacked out, you hear
// an alarm sounding and men talking about.
- _sound->playSound(0x8012007, false, Config.sfxVolume, 0);
+ _sound->playSound(0x80120007, false, Config.sfxVolume, 0);
}
void AsylumEngine::checkForEvent(bool doUpdate) { // k_sub_40AE30 (0040AE30)
@@ -178,7 +184,7 @@ void AsylumEngine::checkForEvent(bool doUpdate) { // k_sub_40AE30 (0040AE30)
// by moving the logic to the event loop and checking whether a flag is
// set to determine if control should be returned to the engine.
if (_introPlaying) {
- if (!_sound->isPlaying(0x8012007)) {
+ if (!_sound->isPlaying(0x80120007)) {
_introPlaying = false;
// TODO Since we've currently only got one sfx handle to play with in
@@ -191,8 +197,6 @@ void AsylumEngine::checkForEvent(bool doUpdate) { // k_sub_40AE30 (0040AE30)
// especially when you examine isSoundinList() or isSoundPlaying())
_scene->enterScene();
- } else {
- return;
}
}
@@ -247,10 +251,6 @@ void AsylumEngine::checkForEvent(bool doUpdate) { // k_sub_40AE30 (0040AE30)
else if (_scene->getBlowUpPuzzle()->isActive())
// Pass events to BlowUp Puzzles
_scene->getBlowUpPuzzle()->handleEvent(&ev, doUpdate);
-
- if (_introPlaying) {
-
- }
}
void AsylumEngine::processDelayedEvents() {
diff --git a/engines/asylum/config.h b/engines/asylum/config.h
index a7e5263e1d..d9fd85dfee 100644
--- a/engines/asylum/config.h
+++ b/engines/asylum/config.h
@@ -31,6 +31,8 @@
namespace Asylum {
+enum VideoSubtitles;
+
/**
* The ConfigurationManager is where the common configuration options used
* by the engine are bound.
@@ -44,7 +46,7 @@ public:
// I know how to better handle them
int word_446EE4;
- bool showMovieSubtitles;
+ VideoSubtitles showMovieSubtitles;
Common::Array<int> movieSubtitles;
bool showEncounterSubtitles;
Common::Array<int> encounterSubtitles;
diff --git a/engines/asylum/respack.h b/engines/asylum/respack.h
index cfb33dc57b..587e9d14b2 100644
--- a/engines/asylum/respack.h
+++ b/engines/asylum/respack.h
@@ -32,7 +32,7 @@
namespace Asylum {
#define RESID(id) ((id >> 16) & 0x7FFF)
-#define RESIDX(id) (id & 0XFFFF)
+#define RESIDX(id) (id & 0xFFFF)
struct ResourceEntry {
byte *data;
diff --git a/engines/asylum/sound.cpp b/engines/asylum/sound.cpp
index ccdd6383c7..4d4a339635 100644
--- a/engines/asylum/sound.cpp
+++ b/engines/asylum/sound.cpp
@@ -109,15 +109,24 @@ int Sound::getBufferPosition(uint32 resId) {
bool Sound::addToSoundBuffer(uint resId) {
int exists = getBufferPosition(resId);
- if (exists >= 0) {
+ if (exists < 0) {
SoundBufferItem sound;
sound.resId = resId;
+ sound.handle = _soundHandle;
_soundBuffer.push_back(sound);
}
return (exists < 0) ? true : false;
}
+void Sound::removeFromSoundBuffer(uint resId) {
+ int pos = getBufferPosition(resId);
+
+ if (pos >= 0) {
+ _soundBuffer.remove_at(pos);
+ }
+}
+
void Sound::clearSoundBuffer() {
_soundBuffer.clear();
}
@@ -131,7 +140,9 @@ bool Sound::isPlaying(uint resId) {
SoundBufferItem snd = _soundBuffer[pos];
if (_mixer->isSoundHandleActive(snd.handle)) {
return true;
- }
+ } else {
+ removeFromSoundBuffer(resId);
+ }
}
return false;
@@ -166,6 +177,7 @@ void Sound::playSound(ResourcePack *pack, uint resId, bool looping, int volume,
} else {
ResourceEntry *ent = _soundPack->getResource(resId);
playSoundData(&snd.handle, ent->data, ent->size, looping, volume, panning);
+ addToSoundBuffer(resId);
}
}
@@ -180,6 +192,7 @@ void Sound::playSound(uint resId, bool looping, int volume, int panning, bool fr
} else {
ResourceEntry *ent = _soundPack->getResource(resId);
playSound(ent, looping, volume, panning);
+ addToSoundBuffer(resId);
}
}
}
diff --git a/engines/asylum/sound.h b/engines/asylum/sound.h
index 0d61cdadfe..51604b35bd 100644
--- a/engines/asylum/sound.h
+++ b/engines/asylum/sound.h
@@ -75,6 +75,7 @@ public:
~Sound();
bool addToSoundBuffer(uint resId);
+ void removeFromSoundBuffer(uint resId);
void clearSoundBuffer();
/**
diff --git a/engines/asylum/video.cpp b/engines/asylum/video.cpp
index 63e9a4739c..0a02d4a8b6 100644
--- a/engines/asylum/video.cpp
+++ b/engines/asylum/video.cpp
@@ -131,12 +131,14 @@ Video::~Video() {
}
bool Video::playVideo(int number, VideoSubtitles subtitles) {
- char filename[20];
+ bool lastMouseState = false;
+ char filename[20];
+
sprintf(filename, "mov%03d.smk", number);
bool result = _smkDecoder->loadFile(filename);
- g_system->showMouse(false);
+ lastMouseState = g_system->showMouse(false);
if (result) {
if (subtitles == kSubtitlesOff)
_player->playVideo(_stopEvents);
@@ -144,7 +146,7 @@ bool Video::playVideo(int number, VideoSubtitles subtitles) {
_player->playVideoWithSubtitles(_stopEvents, number);
}
_smkDecoder->closeFile();
- g_system->showMouse(true);
+ g_system->showMouse(lastMouseState);
return result;
}
Commit: 611e9e95823d2ca27be5b1954eda363f24dbfe70
https://github.com/scummvm/scummvm/commit/611e9e95823d2ca27be5b1954eda363f24dbfe70
Author: Alexandre Fontoura (alexandrefontoura at gmail.com)
Date: 2021-05-17T15:35:56+02:00
Commit Message:
ASYLUM: * Rework on game initially steps to build the real flow to start a new game. (Still missing SaveGame checks, New Game and Return to Game in main menu)
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@401 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/asylum.cpp
engines/asylum/asylum.h
engines/asylum/config.cpp
engines/asylum/config.h
engines/asylum/menu.cpp
engines/asylum/scene.cpp
engines/asylum/scene.h
diff --git a/engines/asylum/asylum.cpp b/engines/asylum/asylum.cpp
index ff28edb1f6..4a33704a42 100644
--- a/engines/asylum/asylum.cpp
+++ b/engines/asylum/asylum.cpp
@@ -99,41 +99,25 @@ Common::Error AsylumEngine::init() {
}
Common::Error AsylumEngine::go() {
- // TODO: save dialogue key codes into sntrm_k.txt (need to figure out why they use such thing)
- // TODO: load startup configurations (address 0041A970)
- // TODO: init unknown game stuffs (address 0040F430)
- // TODO: if savegame exists on folder, than start NewGame()
+ g_system->showMouse(true);
- // FIXME The scene shouldn't be created here, as we don't technically know
- // how the scene is starting. This was put in for testing, but will eventually
- // have to be removed once saveload is implemented
- _scene = new Scene(5, this);
+ // TODO: save dialogue key codes into sntrm_k.txt (need to figure out why they use such thing) (address 00411CD0)
+ // load startup configurations (.text:0041A970)
+ Config.read();
+ // TODO: init unknown game stuffs (.text:0040F430)
- // FIXME This is just here for testing purposes. It is also defined
- // in the processActionList() method when the necessary action is fired.
- // Once the blowup puzzle testing is removed from checkForEvent(), this
- // can be removed as well.
- _scene->setBlowUpPuzzle(new BlowUpPuzzleVCR(_scene));
+#ifndef SKIP_INTRO
+ _video->playVideo(0, Config.showMovieSubtitles);
+#endif
- // Set up main menu
+ // Set up main menu
_mainMenu = new MainMenu(this);
- // XXX Testing
- _encounter = new Encounter(_scene);
-
- // TODO you should be able to skip this if you want. The original
- // allows this through the /SKIP command line argument.
- // Also, this routine is used to set game flags 4 and 12, so if we're
- // skipping the intro, but not loading a save file, those flags
- // need to be set somewhere else.
- playIntro();
-
- // Enter first scene
- if(!_introPlaying)
- {
- setGameFlag(4);
- setGameFlag(12);
- _scene->enterScene();
+ // TODO: if savegame not exists on folder, than start game()
+ if(0) { //SearchMan.hasArchive
+ startGame();
+ } else {
+ _mainMenu->openMenu();
}
while (!shouldQuit()) {
@@ -149,11 +133,39 @@ void AsylumEngine::waitForTimer(int msec_delay) {
while (_system->getMillis() < start_time + msec_delay) {
checkForEvent(false);
- processDelayedEvents();
+ if (_scene) {
+ processDelayedEvents();
+ }
_system->updateScreen();
}
}
+void AsylumEngine::startGame() {
+ _scene = new Scene(5, this);
+ // TODO: reset what need to be reset for a new game
+#ifndef SKIP_INTRO
+ playIntro();
+#endif
+ _scene->initialize();
+
+ // FIXME This is just here for testing purposes. It is also defined
+ // in the processActionList() method when the necessary action is fired.
+ // Once the blowup puzzle testing is removed from checkForEvent(), this
+ // can be removed as well.
+ _scene->setBlowUpPuzzle(new BlowUpPuzzleVCR(_scene));
+
+ // XXX Testing
+ _encounter = new Encounter(_scene);
+
+ // Enter first scene
+ if(!_introPlaying)
+ {
+ setGameFlag(4);
+ setGameFlag(12);
+ _scene->enterScene();
+ }
+}
+
void AsylumEngine::playIntro() {
_introPlaying = true;
g_system->showMouse(false);
@@ -207,11 +219,13 @@ void AsylumEngine::checkForEvent(bool doUpdate) { // k_sub_40AE30 (0040AE30)
if (ev.kbd.keycode == Common::KEYCODE_ESCAPE) {
// Toggle menu
if (_mainMenu->isActive()) {
- _mainMenu->closeMenu();
- _scene->enterScene();
- } else if (_scene->isActive()) {
+ if (_scene) {
+ _mainMenu->closeMenu();
+ _scene->enterScene();
+ }
+ } else if (_scene && _scene->isActive()) {
_mainMenu->openMenu();
- } else if (_scene->getBlowUpPuzzle()->isActive()) {
+ } else if (_scene && _scene->getBlowUpPuzzle()->isActive()) {
_scene->getBlowUpPuzzle()->closeBlowUp();
_scene->enterScene();
}
@@ -221,8 +235,9 @@ void AsylumEngine::checkForEvent(bool doUpdate) { // k_sub_40AE30 (0040AE30)
// XXX: TEST ONLY
if (ev.kbd.keycode == Common::KEYCODE_b) {
- //_mainMenu->closeMenu();
- _scene->getBlowUpPuzzle()->openBlowUp();
+ if (_scene) {
+ _scene->getBlowUpPuzzle()->openBlowUp();
+ }
}
if (ev.kbd.flags == Common::KBD_CTRL) {
@@ -234,7 +249,7 @@ void AsylumEngine::checkForEvent(bool doUpdate) { // k_sub_40AE30 (0040AE30)
}
if (doUpdate) {
- if (_mainMenu->isActive() || _scene->isActive() || _scene->getBlowUpPuzzle()->isActive())
+ if (_mainMenu->isActive() || (_scene && _scene->isActive()) || (_scene && _scene->getBlowUpPuzzle()->isActive()))
// Copy background image
_screen->copyBackBufferToScreen();
@@ -245,10 +260,10 @@ void AsylumEngine::checkForEvent(bool doUpdate) { // k_sub_40AE30 (0040AE30)
if (_mainMenu->isActive())
// Main menu active, pass events to it
_mainMenu->handleEvent(&ev, doUpdate);
- else if (_scene->isActive())
+ else if (_scene && _scene->isActive())
// Pass events to the game
_scene->handleEvent(&ev, doUpdate);
- else if (_scene->getBlowUpPuzzle()->isActive())
+ else if (_scene && _scene->getBlowUpPuzzle()->isActive())
// Pass events to BlowUp Puzzles
_scene->getBlowUpPuzzle()->handleEvent(&ev, doUpdate);
}
diff --git a/engines/asylum/asylum.h b/engines/asylum/asylum.h
index 8c8707b0c5..7807acc3e4 100644
--- a/engines/asylum/asylum.h
+++ b/engines/asylum/asylum.h
@@ -89,10 +89,19 @@ public:
* Initalize the game environment
*/
Common::Error init();
+
+ /** .text:0041A500
+ * Start the game environment
+ */
Common::Error go();
virtual Common::Error run();
virtual bool hasFeature(EngineFeature f) const;
+ /** .text:00415830
+ * Start a new the game
+ */
+ void startGame();
+
void setGameFlag(int flag);
void clearGameFlag(int flag);
void toggleGameFlag(int flag);
@@ -122,6 +131,10 @@ private:
void waitForTimer(int msec_delay);
void updateMouseCursor();
void processDelayedEvents();
+
+ /** .text:0041B630
+ * Start a new the game
+ */
void playIntro();
Common::Language _language;
diff --git a/engines/asylum/config.cpp b/engines/asylum/config.cpp
index 638659fea9..1f072524c4 100644
--- a/engines/asylum/config.cpp
+++ b/engines/asylum/config.cpp
@@ -32,7 +32,6 @@ namespace Asylum {
static bool g_config_initialized = false;
ConfigurationManager::ConfigurationManager() {
-
if (!g_config_initialized) {
g_config_initialized = true;
}
@@ -44,11 +43,23 @@ ConfigurationManager::ConfigurationManager() {
movieVolume = 0;
musicVolume = 0;
sfxVolume = 0;
-
}
ConfigurationManager::~ConfigurationManager() {
- // TODO Auto-generated destructor stub
+}
+
+void ConfigurationManager::read() {
+ // TODO: read all necessary configuration settings
+ musicVolume = ConfMan.getInt("music_volume");
+ sfxVolume = ConfMan.getInt("sfx_volume");
+ voiceVolume = ConfMan.getInt("speech_volume");
+}
+
+void ConfigurationManager::write() {
+ // TODO: save all necessary configuration settings
+ ConfMan.setInt("music_volume", musicVolume);
+ ConfMan.setInt("sfx_volume", sfxVolume);
+ ConfMan.setInt("speech_volume", voiceVolume);
}
} // end of namespace Asylum
diff --git a/engines/asylum/config.h b/engines/asylum/config.h
index d9fd85dfee..a8c19cff37 100644
--- a/engines/asylum/config.h
+++ b/engines/asylum/config.h
@@ -28,6 +28,8 @@
#include "common/array.h"
#include "common/singleton.h"
+#include "common/config-manager.h"
+#include "video.h"
namespace Asylum {
@@ -49,8 +51,8 @@ public:
VideoSubtitles showMovieSubtitles;
Common::Array<int> movieSubtitles;
bool showEncounterSubtitles;
- Common::Array<int> encounterSubtitles;
- int musicVolume;
+ Common::Array<int> encounterSubtitles; // FIXME: take this out
+ int musicVolume;
int ambientVolume;
int sfxVolume;
int voiceVolume;
@@ -74,18 +76,14 @@ public:
int switchToOlmecKey;
/**
- * Load a value from the configuration file
+ * Load configuration file
*/
- bool readValue(int target);
+ void read();
/**
* Save a value to the configuration file
- *
- * XXX Some values (like viewed cinematics) used to be written to
- * the Windows registry, so we're going to handle this from the
- * same file as other settings
*/
- bool writeValue(int target);
+ void write();
private:
friend class Common::Singleton<SingletonBaseType>;
diff --git a/engines/asylum/menu.cpp b/engines/asylum/menu.cpp
index 5d44b150cf..f598edede1 100644
--- a/engines/asylum/menu.cpp
+++ b/engines/asylum/menu.cpp
@@ -90,7 +90,9 @@ void MainMenu::switchFont(bool condition) {
void MainMenu::openMenu() {
_active = true;
- _vm->scene()->deactivate();
+ if (_vm->scene()) {
+ _vm->scene()->deactivate();
+ }
loadFont(kFontYellow);
@@ -123,7 +125,9 @@ void MainMenu::openMenu() {
void MainMenu::closeMenu() {
_active = false;
- _vm->scene()->activate();
+ if (_vm->scene()) {
+ _vm->scene()->activate();
+ }
// Stop menu sounds and menu music
_vm->sound()->stopSound();
@@ -217,8 +221,10 @@ void MainMenu::update() {
_vm->sound()->playMusic(_resPack, 38);
break;
case kReturnToGame:
- closeMenu();
- _vm->scene()->enterScene();
+ if (_vm->scene()) { // FIXME: do this properly
+ closeMenu();
+ _vm->scene()->enterScene();
+ }
break;
}
}
diff --git a/engines/asylum/scene.cpp b/engines/asylum/scene.cpp
index 4be292d740..2cdc4a7892 100644
--- a/engines/asylum/scene.cpp
+++ b/engines/asylum/scene.cpp
@@ -103,18 +103,6 @@ Scene::Scene(uint8 sceneIdx, AsylumEngine *engine): _vm(engine) {
_ws->actors[a].setScene(this);
}
- // XXX initialize array dword_5433A8[15] to zero
- // This array doesn't appear to be used anywhere afterwards
- // though, so skipping this step.
-
- initialize();
-
- // XXX
- // This is a hack for the moment to test out
- // the new sound queuing functionality
- for (uint i = 0; i < _ws->numAmbientSound; i++)
- _vm->sound()->addToSoundBuffer(_ws->ambientSounds[i].resId);
-
// TODO: init action list
_titleLoaded = false;
@@ -137,7 +125,6 @@ void Scene::initialize() {
_cursor->load(_ws->commonRes.curMagnifyingGlass);
_cursor->set(0);
- _cursor->show();
_ws->sceneRectIdx = 0;
_vm->screen()->clearScreen(); // XXX was clearGraphicsInQueue()
@@ -1678,6 +1665,7 @@ SceneTitle::SceneTitle(Scene *scene): _scene(scene) {
delete pack;
_done = false;
+ _showMouseState = g_system->showMouse(false);
}
SceneTitle::~SceneTitle() {
@@ -1725,8 +1713,10 @@ void SceneTitle::update(uint32 tick) {
if (_spinnerFrame > _progress->getFrameCount() - 1)
_spinnerFrame = 0;
- if (_spinnerProgress > 590)
+ if (_spinnerProgress > 590) {
_done = true;
+ g_system->showMouse(_showMouseState);
+ }
}
} // end of namespace Asylum
diff --git a/engines/asylum/scene.h b/engines/asylum/scene.h
index f82a79d0e8..b99298ecd9 100644
--- a/engines/asylum/scene.h
+++ b/engines/asylum/scene.h
@@ -73,6 +73,8 @@ private:
uint32 _spinnerFrame;
uint32 _spinnerProgress;
+ bool _showMouseState;
+
}; // end of class SceneTitle
@@ -81,6 +83,11 @@ public:
Scene(uint8 sceneIdx, AsylumEngine *engine);
~Scene();
+ /** .text:0040E460
+ * Initialize the current scene
+ */
+ void initialize();
+
void handleEvent(Common::Event *event, bool doUpdate);
void enterScene();
@@ -158,11 +165,6 @@ private:
bool _skipDrawScene;
int32 _playerActorIdx;
- /** .text:0040E460
- * Initialize the current scene
- */
- void initialize();
-
void update();
void startMusic();
Commit: 817cdc8ce676f8c10de33bb6124c7a9692200f54
https://github.com/scummvm/scummvm/commit/817cdc8ce676f8c10de33bb6124c7a9692200f54
Author: Alexandre Fontoura (alexandrefontoura at gmail.com)
Date: 2021-05-17T15:35:56+02:00
Commit Message:
ASYLUM: * Implemented start New Game from MainMenu.
* Implemented MainMenu ReturnToGame screen when no game is loaded.
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@402 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/asylum.cpp
engines/asylum/menu.cpp
engines/asylum/menu.h
diff --git a/engines/asylum/asylum.cpp b/engines/asylum/asylum.cpp
index 4a33704a42..3cbfa8a8d8 100644
--- a/engines/asylum/asylum.cpp
+++ b/engines/asylum/asylum.cpp
@@ -83,13 +83,14 @@ Common::Error AsylumEngine::run() {
Common::Error AsylumEngine::init() {
initGraphics(640, 480, true);
- _screen = new Screen(this);
- _sound = new Sound(_mixer);
- _video = new Video(_mixer);
- _console = new Console(this);
- _text = new Text(_screen);
- _mainMenu = 0;
- _scene = 0;
+ _screen = new Screen(this);
+ _sound = new Sound(_mixer);
+ _video = new Video(_mixer);
+ _console = new Console(this);
+ _text = new Text(_screen);
+ _mainMenu = 0;
+ _scene = 0;
+ _encounter = 0;
_introPlaying = false;
@@ -114,7 +115,7 @@ Common::Error AsylumEngine::go() {
_mainMenu = new MainMenu(this);
// TODO: if savegame not exists on folder, than start game()
- if(0) { //SearchMan.hasArchive
+ if(1) { //SearchMan.hasArchive
startGame();
} else {
_mainMenu->openMenu();
@@ -141,8 +142,14 @@ void AsylumEngine::waitForTimer(int msec_delay) {
}
void AsylumEngine::startGame() {
- _scene = new Scene(5, this);
// TODO: reset what need to be reset for a new game
+
+ if (_scene) {
+ delete _scene;
+ }
+
+ _scene = new Scene(5, this);
+
#ifndef SKIP_INTRO
playIntro();
#endif
diff --git a/engines/asylum/menu.cpp b/engines/asylum/menu.cpp
index f598edede1..419360644d 100644
--- a/engines/asylum/menu.cpp
+++ b/engines/asylum/menu.cpp
@@ -367,7 +367,7 @@ void MainMenu::updateSubMenu() {
updateSubMenuShowCredits();
break;
case kReturnToGame:
- // TODO
+ updateSubMenuReturnToGame();
break;
}
}
@@ -393,7 +393,8 @@ void MainMenu::updateSubMenuNewGame() {
// Yes
if (_cursor->x() >= 247 && _cursor->x() <= 247 + 24 && _cursor->y() >= 273 && _cursor->y() <= 273 + _vm->text()->getResTextWidth(0x8000052A)) {
_leftClick = false;
- // TODO handle new game event
+ closeMenu();
+ _vm->startGame();
}
// No
if (_cursor->x() >= 369 && _cursor->x() <= 369 + 24 && _cursor->y() >= 273 && _cursor->y() <= 273 + _vm->text()->getResTextWidth(0x8000052B))
@@ -628,4 +629,23 @@ void MainMenu::exitSubMenu() {
_cursor->load(2);
}
+void MainMenu::updateSubMenuReturnToGame() {
+ loadFont(kFontYellow);
+
+ // no game loaded
+ _vm->text()->drawResTextCentered(10, 100, 620, 0x80000712);
+
+ // Main menu
+ switchFont(_cursor->x() < 285 || _cursor->x() > 285 + _vm->text()->getResTextWidth(0x80000713) || _cursor->y() < 273 || _cursor->y() > 273 + 24);
+ _vm->text()->setTextPos(285, 273);
+ _vm->text()->drawResText(0x80000713);
+
+ // action
+ if (_leftClick) {
+ // Main menu
+ if (_cursor->x() >= 285 && _cursor->x() <= 285 + _vm->text()->getResTextWidth(0x80000713) && _cursor->y() >= 273 && _cursor->y() <= 273 + 24)
+ exitSubMenu();
+ }
+}
+
} // end of namespace Asylum
diff --git a/engines/asylum/menu.h b/engines/asylum/menu.h
index 2180b4a930..81a083bd72 100644
--- a/engines/asylum/menu.h
+++ b/engines/asylum/menu.h
@@ -128,6 +128,7 @@ private:
void updateSubMenuSettings();
void updateSubMenuQuitGame();
void updateSubMenuShowCredits();
+ void updateSubMenuReturnToGame();
void update();
Commit: 9e2855fd813ce89eb682e86ed14e2195f2000732
https://github.com/scummvm/scummvm/commit/9e2855fd813ce89eb682e86ed14e2195f2000732
Author: Alex Bevilacqua (alexbevi at gmail.com)
Date: 2021-05-17T15:35:56+02:00
Commit Message:
ASYLUM: include and comment macro for skipping intro videos
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@403 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/asylum.h
diff --git a/engines/asylum/asylum.h b/engines/asylum/asylum.h
index 7807acc3e4..e1042383d9 100644
--- a/engines/asylum/asylum.h
+++ b/engines/asylum/asylum.h
@@ -47,6 +47,10 @@ namespace Asylum {
// of pre-loading that was performed in the original
//#define SHOW_SCENE_LOADING
+// XXX If defined, this flag will prevent the intro movies
+// from being played whenever the engine is started
+#define SKIP_INTRO
+
// XXX
// I'm not sure if system endian-ness would have any
// effect on the byte order of the data files, but I guess
Commit: cc43cc88a37a06fc73a0a0423ce8b692d3c3b1b1
https://github.com/scummvm/scummvm/commit/cc43cc88a37a06fc73a0a0423ce8b692d3c3b1b1
Author: Alex Bevilacqua (alexbevi at gmail.com)
Date: 2021-05-17T15:35:57+02:00
Commit Message:
ASYLUM: Major overhaul of data casting. Converted all uint32 member variables and fields to int32 (and uint16 to int16) and update the associated reads. There may be regressions as a result, but so far everything seems to be working as expected.
Also combed through the source and silenced 99% of the warnings that GCC was generating.
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@404 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/actionlist.cpp
engines/asylum/actionlist.h
engines/asylum/actor.cpp
engines/asylum/actor.h
engines/asylum/asylum.cpp
engines/asylum/asylum.h
engines/asylum/barrier.cpp
engines/asylum/barrier.h
engines/asylum/blowuppuzzle.cpp
engines/asylum/blowuppuzzle.h
engines/asylum/console.cpp
engines/asylum/console.h
engines/asylum/cursor.cpp
engines/asylum/cursor.h
engines/asylum/encounters.cpp
engines/asylum/encounters.h
engines/asylum/graphics.cpp
engines/asylum/graphics.h
engines/asylum/menu.cpp
engines/asylum/menu.h
engines/asylum/polygons.cpp
engines/asylum/polygons.h
engines/asylum/respack.cpp
engines/asylum/respack.h
engines/asylum/scene.cpp
engines/asylum/scene.h
engines/asylum/screen.cpp
engines/asylum/screen.h
engines/asylum/sound.cpp
engines/asylum/sound.h
engines/asylum/speech.cpp
engines/asylum/speech.h
engines/asylum/text.cpp
engines/asylum/text.h
engines/asylum/video.cpp
engines/asylum/video.h
engines/asylum/worldstats.cpp
engines/asylum/worldstats.h
diff --git a/engines/asylum/actionlist.cpp b/engines/asylum/actionlist.cpp
index d6540272a7..bcee251242 100644
--- a/engines/asylum/actionlist.cpp
+++ b/engines/asylum/actionlist.cpp
@@ -336,7 +336,7 @@ int ActionList::process() {
ScriptEntry *currentCommand = &_currentScript->commands[currentLine];
- uint32 opcode = currentCommand->opcode;
+ int32 opcode = currentCommand->opcode;
debugC(kDebugLevelScripts,
"[0x%02d] %s(%d, %d, %d, %d, %d, %d, %d, %d, %d)",
@@ -397,19 +397,19 @@ int ActionList::process() {
}
void ActionList::load(Common::SeekableReadStream *stream) {
- size = stream->readUint32LE();
- numEntries = stream->readUint32LE();
+ size = stream->readSint32LE();
+ numEntries = stream->readSint32LE();
- for (uint32 a = 0; a < numEntries; a++) {
+ for (int32 a = 0; a < numEntries; a++) {
Script action;
memset(&action, 0, sizeof(Script));
- for (uint32 c = 0; c < MAX_ACTION_COMMANDS; c++) {
+ for (int32 c = 0; c < MAX_ACTION_COMMANDS; c++) {
ScriptEntry command;
memset(&command, 0, sizeof(ScriptEntry));
- command.numLines = stream->readUint32LE();
- command.opcode = stream->readUint32LE();
+ command.numLines = stream->readSint32LE();
+ command.opcode = stream->readSint32LE();
command.param1 = stream->readSint32LE();
command.param2 = stream->readSint32LE();
command.param3 = stream->readSint32LE();
@@ -423,9 +423,9 @@ void ActionList::load(Common::SeekableReadStream *stream) {
action.commands[c] = command;
}
- action.field_1BAC = stream->readUint32LE();
- action.field_1BB0 = stream->readUint32LE();
- action.counter = stream->readUint32LE();
+ action.field_1BAC = stream->readSint32LE();
+ action.field_1BB0 = stream->readSint32LE();
+ action.counter = stream->readSint32LE();
entries.push_back(action);
}
@@ -674,8 +674,8 @@ int kEnableActor(Script *script, ScriptEntry *cmd, Scene *scn) {
int kEnableBarriers(Script *script, ScriptEntry *cmd, Scene *scn) {
int barIdx = scn->worldstats()->getBarrierIndexById(cmd->param1);
- uint32 sndIdx = cmd->param3;
- uint32 v59 = cmd->param2;
+ int32 sndIdx = cmd->param3;
+ int32 v59 = cmd->param2;
if (!script->counter && scn->getSceneIndex() != 13 && sndIdx != 0) {
// FIXME: I really don't understand what (sndIdx != 0) & 5 is supposed to be doing here,
@@ -957,7 +957,7 @@ int kWaitUntilFramePlayed(Script *script, ScriptEntry *cmd, Scene *scn) {
Barrier *barrier = scn->worldstats()->getBarrierById(cmd->param1);
if (barrier) {
- uint32 frameNum = cmd->param2;
+ int32 frameNum = cmd->param2;
if (cmd->param2 == -1)
frameNum = barrier->frameCount - 1;
@@ -997,11 +997,11 @@ int k_unk40_SOUND(Script *script, ScriptEntry *cmd, Scene *scn) {
int kPlaySpeech(Script *script, ScriptEntry *cmd, Scene *scn) {
//TODO - Add support for other param options
- uint32 sndIdx = cmd->param1;
+ int32 sndIdx = cmd->param1;
if ((int)sndIdx >= 0) {
if (cmd->param4 != 2) {
- uint32 resIdx = scn->speech()->play(sndIdx);
+ int32 resIdx = scn->speech()->play(sndIdx);
cmd->param5 = resIdx;
if (cmd->param2) {
diff --git a/engines/asylum/actionlist.h b/engines/asylum/actionlist.h
index bb1f9fde4e..f0029beda3 100644
--- a/engines/asylum/actionlist.h
+++ b/engines/asylum/actionlist.h
@@ -39,41 +39,41 @@ namespace Asylum {
class Scene;
typedef struct ScriptEntry {
- uint32 numLines; // Only set on the first line of each script
- uint32 opcode;
- int param1;
- int param2;
- int param3;
- int param4;
- int param5;
- int param6;
- int param7;
- int param8;
- int param9;
+ int32 numLines; // Only set on the first line of each script
+ int32 opcode;
+ int32 param1;
+ int32 param2;
+ int32 param3;
+ int32 param4;
+ int32 param5;
+ int32 param6;
+ int32 param7;
+ int32 param8;
+ int32 param9;
} ScriptEntry;
typedef struct Script {
ScriptEntry commands[MAX_ACTION_COMMANDS];
- uint32 field_1BAC;
- uint32 field_1BB0;
- uint32 counter;
+ int32 field_1BAC;
+ int32 field_1BB0;
+ int32 counter;
} Script;
typedef struct ScriptQueueEntry {
- int actionListIndex;
- //int actionListItemIndex;
- int actorIndex;
- //int field_C;
- //int field_10;
+ int32 actionListIndex;
+ //int32 actionListItemIndex;
+ int32 actorIndex;
+ //int32 field_C;
+ //int32 field_10;
} ScriptQueueEntry;
/*
typedef struct ScriptQueue {
ScriptQueueEntry entries[10];
- int count;
- int field_CC;
+ int32 count;
+ int32 field_CC;
} ScriptQueue;
*/
@@ -83,8 +83,8 @@ public:
ActionList(Common::SeekableReadStream *stream, Scene *scene);
virtual ~ActionList();
- uint32 size;
- uint32 numEntries;
+ int32 size;
+ int32 numEntries;
Common::Array<Script> entries;
@@ -92,19 +92,19 @@ public:
// Made all the internal control variables public and removed the getter/setter
// pairs for simplicity. This should be refactored later, once the function mapping
// is cleaned up properly
- int currentLine;
- int currentLoops;
- int delayedSceneIndex;
- int delayedVideoIndex;
+ int32 currentLine;
+ int32 currentLoops;
+ int32 delayedSceneIndex;
+ int32 delayedVideoIndex;
bool allowInput;
- int lineIncrement;
+ int32 lineIncrement;
bool done;
bool waitCycle;
/** .text:00402120
* Process the current script
*/
- int process();
+ int32 process();
/** .text:00401020
* Reset the _scripts entries to their default values
*/
@@ -113,19 +113,19 @@ public:
* Initialize the script element at actionIndex to
* the actor at actorIndex
*/
- void queueScript(int actionIndex, int actorIndex);
+ void queueScript(int32 actionIndex, int32 actorIndex);
/** .text:00401100
* Update the queued scripts
*/
- //void updateQueue(int queueIndex);
+ //void updateQueue(int32 queueIndex);
/**
* Toggle the action queue processing flag
*/
void setActionFlag(bool value) { _actionFlag = value; }
- void processActionListSub02(Script* script, ScriptEntry* command, int a4);
- void enableActorSub(int actorIndex, int condition);
+ void processActionListSub02(Script* script, ScriptEntry* command, int32 a4);
+ void enableActorSub(int32 actorIndex, int32 condition);
private:
Scene *_scene;
@@ -138,106 +138,106 @@ private:
};
// opcode functions
-int kReturn0(Script *script, ScriptEntry *cmd, Scene *scn);
-int kSetGameFlag(Script *script, ScriptEntry *cmd, Scene *scn);
-int kClearGameFlag(Script *script, ScriptEntry *cmd, Scene *scn);
-int kToggleGameFlag(Script *script, ScriptEntry *cmd, Scene *scn);
-int kJumpIfGameFlag(Script *script, ScriptEntry *cmd, Scene *scn);
-int kHideCursor(Script *script, ScriptEntry *cmd, Scene *scn);
-int kShowCursor(Script *script, ScriptEntry *cmd, Scene *scn);
-int kPlayAnimation(Script *script, ScriptEntry *cmd, Scene *scn);
-int kMoveScenePosition(Script *script, ScriptEntry *cmd, Scene *scn);
-int kHideActor(Script *script, ScriptEntry *cmd, Scene *scn);
-int kShowActor(Script *script, ScriptEntry *cmd, Scene *scn);
-int kSetActorStats(Script *script, ScriptEntry *cmd, Scene *scn);
-int kSetSceneMotionStat(Script *script, ScriptEntry *cmd, Scene *scn);
-int kDisableActor(Script *script, ScriptEntry *cmd, Scene *scn);
-int kEnableActor(Script *script, ScriptEntry *cmd, Scene *scn);
-int kEnableBarriers(Script *script, ScriptEntry *cmd, Scene *scn);
-int kReturn(Script *script, ScriptEntry *cmd, Scene *scn);
-int kDestroyBarrier(Script *script, ScriptEntry *cmd, Scene *scn);
-int k_unk12_JMP_WALK_ACTOR(Script *script, ScriptEntry *cmd, Scene *scn);
-int k_unk13_JMP_WALK_ACTOR(Script *script, ScriptEntry *cmd, Scene *scn);
-int k_unk14_JMP_WALK_ACTOR(Script *script, ScriptEntry *cmd, Scene *scn);
-int k_unk15(Script *script, ScriptEntry *cmd, Scene *scn);
-int kResetAnimation(Script *script, ScriptEntry *cmd, Scene *scn);
-int kClearFlag1Bit0(Script *script, ScriptEntry *cmd, Scene *scn);
-int k_unk18_PLAY_SND(Script *script, ScriptEntry *cmd, Scene *scn);
-int kJumpIfFlag2Bit0(Script *script, ScriptEntry *cmd, Scene *scn);
-int kSetFlag2Bit0(Script *script, ScriptEntry *cmd, Scene *scn);
-int kClearFlag2Bit0(Script *script, ScriptEntry *cmd, Scene *scn);
-int kJumpIfFlag2Bit2(Script *script, ScriptEntry *cmd, Scene *scn);
-int kSetFlag2Bit2(Script *script, ScriptEntry *cmd, Scene *scn);
-int kClearFlag2Bit2(Script *script, ScriptEntry *cmd, Scene *scn);
-int kJumpIfFlag2Bit1(Script *script, ScriptEntry *cmd, Scene *scn);
-int kSetFlag2Bit1(Script *script, ScriptEntry *cmd, Scene *scn);
-int kClearFlag2Bit1(Script *script, ScriptEntry *cmd, Scene *scn);
-int k_unk22(Script *script, ScriptEntry *cmd, Scene *scn);
-int k_unk23(Script *script, ScriptEntry *cmd, Scene *scn);
-int k_unk24(Script *script, ScriptEntry *cmd, Scene *scn);
-int kRunEncounter(Script *script, ScriptEntry *cmd, Scene *scn);
-int kJumpIfFlag2Bit4(Script *script, ScriptEntry *cmd, Scene *scn);
-int kSetFlag2Bit4(Script *script, ScriptEntry *cmd, Scene *scn);
-int kClearFlag2Bit4(Script *script, ScriptEntry *cmd, Scene *scn);
-int kSetActorField638(Script *script, ScriptEntry *cmd, Scene *scn);
-int kJumpIfActorField638(Script *script, ScriptEntry *cmd, Scene *scn);
-int kChangeScene(Script *script, ScriptEntry *cmd, Scene *scn);
-int k_unk2C_ActorSub(Script *script, ScriptEntry *cmd, Scene *scn);
-int kPlayMovie(Script *script, ScriptEntry *cmd, Scene *scn);
-int kStopAllBarriersSounds(Script *script, ScriptEntry *cmd, Scene *scn);
-int kSetActionFlag(Script *script, ScriptEntry *cmd, Scene *scn);
-int kClearActionFlag(Script *script, ScriptEntry *cmd, Scene *scn);
-int kResetSceneRect(Script *script, ScriptEntry *cmd, Scene *scn);
-int kChangeMusicById(Script *script, ScriptEntry *cmd, Scene *scn);
-int kStopMusic(Script *script, ScriptEntry *cmd, Scene *scn);
-int k_unk34_Status(Script *script, ScriptEntry *cmd, Scene *scn);
-int k_unk35(Script *script, ScriptEntry *cmd, Scene *scn);
-int k_unk36(Script *script, ScriptEntry *cmd, Scene *scn);
-int kRunBlowUpPuzzle(Script *script, ScriptEntry *cmd, Scene *scn);
-int kJumpIfFlag2Bit3(Script *script, ScriptEntry *cmd, Scene *scn);
-int kSetFlag2Bit3(Script *script, ScriptEntry *cmd, Scene *scn);
-int kClearFlag2Bit3(Script *script, ScriptEntry *cmd, Scene *scn);
-int k_unk3B_PALETTE_MOD(Script *script, ScriptEntry *cmd, Scene *scn);
-int k_unk3C_CMP_VAL(Script *script, ScriptEntry *cmd, Scene *scn);
-int kWaitUntilFramePlayed(Script *script, ScriptEntry *cmd, Scene *scn);
-int kUpdateWideScreen(Script *script, ScriptEntry *cmd, Scene *scn);
-int k_unk3F(Script *script, ScriptEntry *cmd, Scene *scn);
-int k_unk40_SOUND(Script *script, ScriptEntry *cmd, Scene *scn);
-int kPlaySpeech(Script *script, ScriptEntry *cmd, Scene *scn);
-int k_unk42(Script *script, ScriptEntry *cmd, Scene *scn);
-int k_unk43(Script *script, ScriptEntry *cmd, Scene *scn);
-int kPaletteFade(Script *script, ScriptEntry *cmd, Scene *scn);
-int kStartPaletteFadeThread(Script *script, ScriptEntry *cmd, Scene *scn);
-int k_unk46(Script *script, ScriptEntry *cmd, Scene *scn);
-int kActorFaceObject(Script *script, ScriptEntry *cmd, Scene *scn);
-int k_unk48_MATTE_01(Script *script, ScriptEntry *cmd, Scene *scn);
-int k_unk49_MATTE_90(Script *script, ScriptEntry *cmd, Scene *scn);
-int kJumpIfSoundPlaying(Script *script, ScriptEntry *cmd, Scene *scn);
-int kChangePlayerCharacterIndex(Script *script, ScriptEntry *cmd, Scene *scn);
-int kChangeActorField40(Script *script, ScriptEntry *cmd, Scene *scn);
-int kStopSound(Script *script, ScriptEntry *cmd, Scene *scn);
-int k_unk4E_RANDOM_COMMAND(Script *script, ScriptEntry *cmd, Scene *scn);
-int kClearScreen(Script *script, ScriptEntry *cmd, Scene *scn);
-int kQuit(Script *script, ScriptEntry *cmd, Scene *scn);
-int kJumpBarrierFrame(Script *script, ScriptEntry *cmd, Scene *scn);
-int k_unk52(Script *script, ScriptEntry *cmd, Scene *scn);
-int k_unk53(Script *script, ScriptEntry *cmd, Scene *scn);
-int k_unk54_SET_ACTIONLIST_6EC(Script *script, ScriptEntry *cmd, Scene *scn);
-int k_unk55(Script *script, ScriptEntry *cmd, Scene *scn);
-int k_unk56(Script *script, ScriptEntry *cmd, Scene *scn);
-int kSetResourcePalette(Script *script, ScriptEntry *cmd, Scene *scn);
-int kSetBarrierFrameIdxFlaged(Script *script, ScriptEntry *cmd, Scene *scn);
-int k_unk59(Script *script, ScriptEntry *cmd, Scene *scn);
-int k_unk5A(Script *script, ScriptEntry *cmd, Scene *scn);
-int k_unk5B(Script *script, ScriptEntry *cmd, Scene *scn);
-int k_unk5C(Script *script, ScriptEntry *cmd, Scene *scn);
-int k_unk5D(Script *script, ScriptEntry *cmd, Scene *scn);
-int k_unk5E(Script *script, ScriptEntry *cmd, Scene *scn);
-int kSetBarrierLastFrameIdx(Script *script, ScriptEntry *cmd, Scene *scn);
-int k_unk60_SET_OR_CLR_ACTIONAREA_FLAG(Script *script, ScriptEntry *cmd, Scene *scn);
-int k_unk61(Script *script, ScriptEntry *cmd, Scene *scn);
-int k_unk62_SHOW_OPTIONS_SCREEN(Script *script, ScriptEntry *cmd, Scene *scn);
-int k_unk63(Script *script, ScriptEntry *cmd, Scene *scn);
+int32 kReturn0(Script *script, ScriptEntry *cmd, Scene *scn);
+int32 kSetGameFlag(Script *script, ScriptEntry *cmd, Scene *scn);
+int32 kClearGameFlag(Script *script, ScriptEntry *cmd, Scene *scn);
+int32 kToggleGameFlag(Script *script, ScriptEntry *cmd, Scene *scn);
+int32 kJumpIfGameFlag(Script *script, ScriptEntry *cmd, Scene *scn);
+int32 kHideCursor(Script *script, ScriptEntry *cmd, Scene *scn);
+int32 kShowCursor(Script *script, ScriptEntry *cmd, Scene *scn);
+int32 kPlayAnimation(Script *script, ScriptEntry *cmd, Scene *scn);
+int32 kMoveScenePosition(Script *script, ScriptEntry *cmd, Scene *scn);
+int32 kHideActor(Script *script, ScriptEntry *cmd, Scene *scn);
+int32 kShowActor(Script *script, ScriptEntry *cmd, Scene *scn);
+int32 kSetActorStats(Script *script, ScriptEntry *cmd, Scene *scn);
+int32 kSetSceneMotionStat(Script *script, ScriptEntry *cmd, Scene *scn);
+int32 kDisableActor(Script *script, ScriptEntry *cmd, Scene *scn);
+int32 kEnableActor(Script *script, ScriptEntry *cmd, Scene *scn);
+int32 kEnableBarriers(Script *script, ScriptEntry *cmd, Scene *scn);
+int32 kReturn(Script *script, ScriptEntry *cmd, Scene *scn);
+int32 kDestroyBarrier(Script *script, ScriptEntry *cmd, Scene *scn);
+int32 k_unk12_JMP_WALK_ACTOR(Script *script, ScriptEntry *cmd, Scene *scn);
+int32 k_unk13_JMP_WALK_ACTOR(Script *script, ScriptEntry *cmd, Scene *scn);
+int32 k_unk14_JMP_WALK_ACTOR(Script *script, ScriptEntry *cmd, Scene *scn);
+int32 k_unk15(Script *script, ScriptEntry *cmd, Scene *scn);
+int32 kResetAnimation(Script *script, ScriptEntry *cmd, Scene *scn);
+int32 kClearFlag1Bit0(Script *script, ScriptEntry *cmd, Scene *scn);
+int32 k_unk18_PLAY_SND(Script *script, ScriptEntry *cmd, Scene *scn);
+int32 kJumpIfFlag2Bit0(Script *script, ScriptEntry *cmd, Scene *scn);
+int32 kSetFlag2Bit0(Script *script, ScriptEntry *cmd, Scene *scn);
+int32 kClearFlag2Bit0(Script *script, ScriptEntry *cmd, Scene *scn);
+int32 kJumpIfFlag2Bit2(Script *script, ScriptEntry *cmd, Scene *scn);
+int32 kSetFlag2Bit2(Script *script, ScriptEntry *cmd, Scene *scn);
+int32 kClearFlag2Bit2(Script *script, ScriptEntry *cmd, Scene *scn);
+int32 kJumpIfFlag2Bit1(Script *script, ScriptEntry *cmd, Scene *scn);
+int32 kSetFlag2Bit1(Script *script, ScriptEntry *cmd, Scene *scn);
+int32 kClearFlag2Bit1(Script *script, ScriptEntry *cmd, Scene *scn);
+int32 k_unk22(Script *script, ScriptEntry *cmd, Scene *scn);
+int32 k_unk23(Script *script, ScriptEntry *cmd, Scene *scn);
+int32 k_unk24(Script *script, ScriptEntry *cmd, Scene *scn);
+int32 kRunEncounter(Script *script, ScriptEntry *cmd, Scene *scn);
+int32 kJumpIfFlag2Bit4(Script *script, ScriptEntry *cmd, Scene *scn);
+int32 kSetFlag2Bit4(Script *script, ScriptEntry *cmd, Scene *scn);
+int32 kClearFlag2Bit4(Script *script, ScriptEntry *cmd, Scene *scn);
+int32 kSetActorField638(Script *script, ScriptEntry *cmd, Scene *scn);
+int32 kJumpIfActorField638(Script *script, ScriptEntry *cmd, Scene *scn);
+int32 kChangeScene(Script *script, ScriptEntry *cmd, Scene *scn);
+int32 k_unk2C_ActorSub(Script *script, ScriptEntry *cmd, Scene *scn);
+int32 kPlayMovie(Script *script, ScriptEntry *cmd, Scene *scn);
+int32 kStopAllBarriersSounds(Script *script, ScriptEntry *cmd, Scene *scn);
+int32 kSetActionFlag(Script *script, ScriptEntry *cmd, Scene *scn);
+int32 kClearActionFlag(Script *script, ScriptEntry *cmd, Scene *scn);
+int32 kResetSceneRect(Script *script, ScriptEntry *cmd, Scene *scn);
+int32 kChangeMusicById(Script *script, ScriptEntry *cmd, Scene *scn);
+int32 kStopMusic(Script *script, ScriptEntry *cmd, Scene *scn);
+int32 k_unk34_Status(Script *script, ScriptEntry *cmd, Scene *scn);
+int32 k_unk35(Script *script, ScriptEntry *cmd, Scene *scn);
+int32 k_unk36(Script *script, ScriptEntry *cmd, Scene *scn);
+int32 kRunBlowUpPuzzle(Script *script, ScriptEntry *cmd, Scene *scn);
+int32 kJumpIfFlag2Bit3(Script *script, ScriptEntry *cmd, Scene *scn);
+int32 kSetFlag2Bit3(Script *script, ScriptEntry *cmd, Scene *scn);
+int32 kClearFlag2Bit3(Script *script, ScriptEntry *cmd, Scene *scn);
+int32 k_unk3B_PALETTE_MOD(Script *script, ScriptEntry *cmd, Scene *scn);
+int32 k_unk3C_CMP_VAL(Script *script, ScriptEntry *cmd, Scene *scn);
+int32 kWaitUntilFramePlayed(Script *script, ScriptEntry *cmd, Scene *scn);
+int32 kUpdateWideScreen(Script *script, ScriptEntry *cmd, Scene *scn);
+int32 k_unk3F(Script *script, ScriptEntry *cmd, Scene *scn);
+int32 k_unk40_SOUND(Script *script, ScriptEntry *cmd, Scene *scn);
+int32 kPlaySpeech(Script *script, ScriptEntry *cmd, Scene *scn);
+int32 k_unk42(Script *script, ScriptEntry *cmd, Scene *scn);
+int32 k_unk43(Script *script, ScriptEntry *cmd, Scene *scn);
+int32 kPaletteFade(Script *script, ScriptEntry *cmd, Scene *scn);
+int32 kStartPaletteFadeThread(Script *script, ScriptEntry *cmd, Scene *scn);
+int32 k_unk46(Script *script, ScriptEntry *cmd, Scene *scn);
+int32 kActorFaceObject(Script *script, ScriptEntry *cmd, Scene *scn);
+int32 k_unk48_MATTE_01(Script *script, ScriptEntry *cmd, Scene *scn);
+int32 k_unk49_MATTE_90(Script *script, ScriptEntry *cmd, Scene *scn);
+int32 kJumpIfSoundPlaying(Script *script, ScriptEntry *cmd, Scene *scn);
+int32 kChangePlayerCharacterIndex(Script *script, ScriptEntry *cmd, Scene *scn);
+int32 kChangeActorField40(Script *script, ScriptEntry *cmd, Scene *scn);
+int32 kStopSound(Script *script, ScriptEntry *cmd, Scene *scn);
+int32 k_unk4E_RANDOM_COMMAND(Script *script, ScriptEntry *cmd, Scene *scn);
+int32 kClearScreen(Script *script, ScriptEntry *cmd, Scene *scn);
+int32 kQuit(Script *script, ScriptEntry *cmd, Scene *scn);
+int32 kJumpBarrierFrame(Script *script, ScriptEntry *cmd, Scene *scn);
+int32 k_unk52(Script *script, ScriptEntry *cmd, Scene *scn);
+int32 k_unk53(Script *script, ScriptEntry *cmd, Scene *scn);
+int32 k_unk54_SET_ACTIONLIST_6EC(Script *script, ScriptEntry *cmd, Scene *scn);
+int32 k_unk55(Script *script, ScriptEntry *cmd, Scene *scn);
+int32 k_unk56(Script *script, ScriptEntry *cmd, Scene *scn);
+int32 kSetResourcePalette(Script *script, ScriptEntry *cmd, Scene *scn);
+int32 kSetBarrierFrameIdxFlaged(Script *script, ScriptEntry *cmd, Scene *scn);
+int32 k_unk59(Script *script, ScriptEntry *cmd, Scene *scn);
+int32 k_unk5A(Script *script, ScriptEntry *cmd, Scene *scn);
+int32 k_unk5B(Script *script, ScriptEntry *cmd, Scene *scn);
+int32 k_unk5C(Script *script, ScriptEntry *cmd, Scene *scn);
+int32 k_unk5D(Script *script, ScriptEntry *cmd, Scene *scn);
+int32 k_unk5E(Script *script, ScriptEntry *cmd, Scene *scn);
+int32 kSetBarrierLastFrameIdx(Script *script, ScriptEntry *cmd, Scene *scn);
+int32 k_unk60_SET_OR_CLR_ACTIONAREA_FLAG(Script *script, ScriptEntry *cmd, Scene *scn);
+int32 k_unk61(Script *script, ScriptEntry *cmd, Scene *scn);
+int32 k_unk62_SHOW_OPTIONS_SCREEN(Script *script, ScriptEntry *cmd, Scene *scn);
+int32 k_unk63(Script *script, ScriptEntry *cmd, Scene *scn);
} // end of namespace Asylum
diff --git a/engines/asylum/actor.cpp b/engines/asylum/actor.cpp
index 1e98b413b9..59184f029d 100644
--- a/engines/asylum/actor.cpp
+++ b/engines/asylum/actor.cpp
@@ -43,7 +43,7 @@ Actor::~Actor() {
// free _resources?
}
-void Actor::setPosition(uint32 targetX, uint32 targetY) {
+void Actor::setPosition(int32 targetX, int32 targetY) {
//boundingRect.left = targetX;
//boundingRect.top = targetY;
@@ -60,7 +60,7 @@ void Actor::visible(bool value) {
}
/*
-void Actor::setDirection(int dir) {
+void Actor::setDirection(int32 dir) {
direction = dir;
setActionByIndex(dir);
}
@@ -69,13 +69,13 @@ void Actor::setDirection(int dir) {
void Actor::setRawResources(uint8 *data) {
byte *dataPtr = data;
- for (uint32 i = 0; i < 60; i++) {
- _resources[i] = READ_LE_UINT32(dataPtr);
+ for (int32 i = 0; i < 60; i++) {
+ _resources[i] = (int32)READ_LE_UINT32(dataPtr);
dataPtr += 4;
}
}
-void Actor::setAction(int action) {
+void Actor::setAction(int32 action) {
assert(_resPack);
if (action == currentAction)
@@ -84,19 +84,19 @@ void Actor::setAction(int action) {
currentAction = action;
delete _graphic;
- int act = (action < 100) ? action : action - 100;
+ int32 act = (action < 100) ? action : action - 100;
_graphic = new GraphicResource(_resPack, _resources[act]);
// Flip horizontally if necessary
if (currentAction > 100) {
- for (uint32 i = 0; i < _graphic->getFrameCount(); i++) {
+ for (int32 i = 0; i < _graphic->getFrameCount(); i++) {
GraphicFrame *frame = _graphic->getFrame(i);
byte *buffer = (byte *)frame->surface.pixels;
- for (int tmpY = 0; tmpY < frame->surface.h; tmpY++) {
- int w = frame->surface.w / 2;
- for (int tmpX = 0; tmpX < w; tmpX++) {
+ for (int32 tmpY = 0; tmpY < frame->surface.h; tmpY++) {
+ int32 w = frame->surface.w / 2;
+ for (int32 tmpX = 0; tmpX < w; tmpX++) {
SWAP(buffer[tmpY * frame->surface.pitch + tmpX],
buffer[tmpY * frame->surface.pitch + frame->surface.w - 1 - tmpX]);
}
@@ -107,7 +107,7 @@ void Actor::setAction(int action) {
frameNum = 0;
}
-void Actor::setActionByIndex(int index) {
+void Actor::setActionByIndex(int32 index) {
setAction(_resources[index] & 0xFFFF);
}
@@ -129,7 +129,7 @@ GraphicFrame *Actor::getFrame() {
return frame;
}
-void Actor::drawActorAt(uint32 curX, uint32 curY) {
+void Actor::drawActorAt(int32 curX, int32 curY) {
GraphicFrame *frame = getFrame();
WorldStats *ws = _scene->worldstats();
@@ -168,15 +168,15 @@ void Actor::setWalkArea(ActionArea *target) {
}
void Actor::walkTo(int32 curX, int32 curY) {
- int newAction = currentAction;
+ int32 newAction = currentAction;
WorldStats *ws = _scene->worldstats();
// step is the increment by which to move the
// actor in a given direction
- int step = 2;
+ int32 step = 2;
- uint32 newX = x;
- uint32 newY = y;
+ int32 newX = x;
+ int32 newY = y;
bool done = false;
// Walking left...
@@ -220,7 +220,7 @@ void Actor::walkTo(int32 curX, int32 curY) {
}
// DEBUGGING
- // Show registration point from which we're calculating the
+ // Show registration point32 from which we're calculating the
// actor's barrier hit-test
Graphics::Surface surface;
surface.create(5, 5, 1);
@@ -241,12 +241,12 @@ void Actor::walkTo(int32 curX, int32 curY) {
// the actor at the PERFECT spot to be able to intersect a walk region and move to
// the next one.
- int availableAreas[5];
- int areaPtr = 0;
+ int32 availableAreas[5];
+ int32 areaPtr = 0;
ActionArea *area;
// Check what valid walk region(s) is/are currently available
- for (uint32 a = 0; a < ws->numActions; a++) {
+ for (int32 a = 0; a < ws->numActions; a++) {
if (ws->actions[a].actionType == 0) {
area = &ws->actions[a];
PolyDefinitions poly = _scene->polygons()->entries[area->polyIdx];
@@ -265,7 +265,7 @@ void Actor::walkTo(int32 curX, int32 curY) {
// Check that we can walk in the current direction within any of the available
// walkable regions
- for (int i = 0; i < areaPtr; i++) {
+ for (int32 i = 0; i < areaPtr; i++) {
area = &ws->actions[availableAreas[i]];
PolyDefinitions *region = &_scene->polygons()->entries[area->polyIdx];
if (region->contains(newX, newY)) {
@@ -279,7 +279,7 @@ void Actor::walkTo(int32 curX, int32 curY) {
drawActor();
}
-void Actor::setPosition_40A260(uint32 newX, uint32 newY, int newDirection, int frame) {
+void Actor::setPosition_40A260(int32 newX, int32 newY, int32 newDirection, int32 frame) {
x1 = newX - x2;
y1 = newY - y2;
@@ -291,20 +291,20 @@ void Actor::setPosition_40A260(uint32 newX, uint32 newY, int newDirection, int f
frameNum = frame;
}
-void Actor::faceTarget(int targetId, int targetType) {
- int newX2, newY2;
+void Actor::faceTarget(int32 targetId, int32 targetType) {
+ int32 newX2, newY2;
printf("faceTarget: id %d type %d\n", targetId, targetType);
if (targetType) {
if (targetType == 1) {
- int actionIdx = _scene->worldstats()->getActionAreaIndexById(targetId);
+ int32 actionIdx = _scene->worldstats()->getActionAreaIndexById(targetId);
if (actionIdx == -1) {
warning("No ActionArea found for id %d", targetId);
return;
}
- uint32 polyIdx = _scene->worldstats()->actions[actionIdx].polyIdx;
+ int32 polyIdx = _scene->worldstats()->actions[actionIdx].polyIdx;
PolyDefinitions *poly = &_scene->polygons()->entries[polyIdx];
newX2 = poly->boundingRect.left + (poly->boundingRect.right - poly->boundingRect.left) / 2;
@@ -318,7 +318,7 @@ void Actor::faceTarget(int targetId, int targetType) {
}
}
} else {
- int barrierIdx = _scene->worldstats()->getBarrierIndexById(targetId);
+ int32 barrierIdx = _scene->worldstats()->getBarrierIndexById(targetId);
if (barrierIdx == -1) {
warning("No Barrier found for id %d", targetId);
return;
@@ -342,7 +342,7 @@ void Actor::faceTarget(int targetId, int targetType) {
newY2 = (fra->surface.h >> 1) + barrier->y; // Check .text:004088A2 for more details
}
- int newAngle = getAngle(x2 + x1, y2 + y1, newX2, newY2);
+ int32 newAngle = getAngle(x2 + x1, y2 + y1, newX2, newY2);
printf("Angle calculated as %d\n", newAngle);
@@ -350,10 +350,10 @@ void Actor::faceTarget(int targetId, int targetType) {
//setDirection(newAngle);
}
-int Actor::getAngle(int ax1, int ay1, int ax2, int ay2) {
+int32 Actor::getAngle(int32 ax1, int32 ay1, int32 ax2, int32 ay2) {
int32 v5 = (ax2 << 16) - (ax1 << 16);
- int v6 = 0;
- int v4 = (ay1 << 16) - (ay2 << 16);
+ int32 v6 = 0;
+ int32 v4 = (ay1 << 16) - (ay2 << 16);
if (v5 < 0) {
v6 = 2;
@@ -365,8 +365,8 @@ int Actor::getAngle(int ax1, int ay1, int ax2, int ay2) {
v4 = -v4;
}
- int v7;
- int v8 = -1;
+ int32 v7;
+ int32 v8 = -1;
if (v5) {
v7 = (v4 << 8) / v5;
@@ -396,7 +396,7 @@ int Actor::getAngle(int ax1, int ay1, int ax2, int ay2) {
if (v8 >= 360)
v8 -= 360;
- int result;
+ int32 result;
if (v8 < 157 || v8 >= 202) {
if (v8 < 112 || v8 >= 157) {
diff --git a/engines/asylum/actor.h b/engines/asylum/actor.h
index 5020862c9d..5f4b43fac5 100644
--- a/engines/asylum/actor.h
+++ b/engines/asylum/actor.h
@@ -154,15 +154,15 @@ public:
void visible(bool value);
- void setPosition(uint32 targetX, uint32 targetY);
+ void setPosition(int32 targetX, int32 targetY);
/**
* Initialize the x1/y1 values of the actor, update the active animation frame
* and, if the current direction isn't 8, update the actor's direction
*/
- void setPosition_40A260(uint32 newX, uint32 newY, int newDirection, int frame);
+ void setPosition_40A260(int32 newX, int32 newY, int32 newDirection, int32 frame);
- void faceTarget(int targetId, int targetType);
+ void faceTarget(int32 targetId, int32 targetType);
// FIXME
// I don't really like how this is used in the scene constructor
@@ -176,86 +176,86 @@ public:
// TODO ALL of these need to be depreciated in favour
// of the proper functions from the original
void setWalkArea(ActionArea *target);
- void setAction(int action);
- void setActionByIndex(int index);
- void drawActorAt(uint32 curX, uint32 curY);
+ void setAction(int32 action);
+ void setActionByIndex(int32 index);
+ void drawActorAt(int32 curX, int32 curY);
void drawActor();
void walkTo(int32 curX, int32 curY);
- int currentAction; // TODO depreciate
+ int32 currentAction; // TODO depreciate
int32 x;
int32 y;
- uint32 grResId;
- uint32 field_C; // BarrierIndex? Mask index?
- uint32 frameNum;
- uint32 frameCount;
+ int32 grResId;
+ int32 field_C; // BarrierIndex? Mask index?
+ int32 frameNum;
+ int32 frameCount;
int32 x1;
int32 y1;
int32 x2;
int32 y2;
Common::Rect boundingRect;
- uint32 direction;
- uint32 field_3C;
- uint32 updateType;
- uint32 field_44;
- uint32 priority;
- uint32 flags;
- uint32 field_50;
- uint32 field_54;
- uint32 field_58;
- uint32 field_5C;
- uint32 field_60;
- uint32 actionIdx3;
+ int32 direction;
+ int32 field_3C;
+ int32 updateType;
+ int32 field_44;
+ int32 priority;
+ int32 flags;
+ int32 field_50;
+ int32 field_54;
+ int32 field_58;
+ int32 field_5C;
+ int32 field_60;
+ int32 actionIdx3;
// TODO field_68 till field_617
- uint32 reaction[8];
- uint32 field_638;
- uint32 walkingSound1;
- uint32 walkingSound2;
- uint32 walkingSound3;
- uint32 walkingSound4;
- uint32 field_64C;
- uint32 field_650;
- uint32 grResTable[55];
+ int32 reaction[8];
+ int32 field_638;
+ int32 walkingSound1;
+ int32 walkingSound2;
+ int32 walkingSound3;
+ int32 walkingSound4;
+ int32 field_64C;
+ int32 field_650;
+ int32 grResTable[55];
char name[256];
- uint32 field_830[20];
- uint32 field_880[20];
- uint32 field_8D0[20];
- uint32 actionIdx2;
- uint32 field_924;
- uint32 tickValue1;
- uint32 field_92C;
- uint32 flags2;
- uint32 field_934;
- uint32 field_938;
- uint32 soundResId; // field_93C
- uint32 field_940;
- uint32 field_944;
- uint32 field_948;
- uint32 field_94C;
- uint32 field_950;
- uint32 field_954;
- uint32 field_958;
- uint32 field_95C;
- uint32 field_960;
- uint32 field_964;
- uint32 field_968;
- uint32 field_96C;
- uint32 field_970;
- uint32 field_974;
- uint32 field_978;
- uint32 actionIdx1;
+ int32 field_830[20];
+ int32 field_880[20];
+ int32 field_8D0[20];
+ int32 actionIdx2;
+ int32 field_924;
+ int32 tickValue1;
+ int32 field_92C;
+ int32 flags2;
+ int32 field_934;
+ int32 field_938;
+ int32 soundResId; // field_93C
+ int32 field_940;
+ int32 field_944;
+ int32 field_948;
+ int32 field_94C;
+ int32 field_950;
+ int32 field_954;
+ int32 field_958;
+ int32 field_95C;
+ int32 field_960;
+ int32 field_964;
+ int32 field_968;
+ int32 field_96C;
+ int32 field_970;
+ int32 field_974;
+ int32 field_978;
+ int32 actionIdx1;
// TODO field_980 till field_9A0
private:
Scene *_scene;
ResourcePack *_resPack;
GraphicResource *_graphic;
- uint32 _resources[61];
+ int32 _resources[61];
ActionArea *_currentWalkArea;
GraphicFrame *getFrame();
- int getAngle(int ax1, int ay1, int ax2, int ay2);
+ int32 getAngle(int32 ax1, int32 ay1, int32 ax2, int32 ay2);
}; // end of class MainActor
diff --git a/engines/asylum/asylum.cpp b/engines/asylum/asylum.cpp
index 3cbfa8a8d8..6775cc25b4 100644
--- a/engines/asylum/asylum.cpp
+++ b/engines/asylum/asylum.cpp
@@ -115,7 +115,7 @@ Common::Error AsylumEngine::go() {
_mainMenu = new MainMenu(this);
// TODO: if savegame not exists on folder, than start game()
- if(1) { //SearchMan.hasArchive
+ if(0) { //SearchMan.hasArchive
startGame();
} else {
_mainMenu->openMenu();
@@ -179,7 +179,7 @@ void AsylumEngine::playIntro() {
_video->playVideo(1, Config.showMovieSubtitles);
- if (_scene->worldstats()->musicCurrentResId != 0xFFFFFD66)
+ if (_scene->worldstats()->musicCurrentResId != -666)
_sound->playMusic(_scene->worldstats()->musicCurrentResId);
_screen->clearScreen();
diff --git a/engines/asylum/asylum.h b/engines/asylum/asylum.h
index e1042383d9..f7bd7db0cd 100644
--- a/engines/asylum/asylum.h
+++ b/engines/asylum/asylum.h
@@ -49,7 +49,7 @@ namespace Asylum {
// XXX If defined, this flag will prevent the intro movies
// from being played whenever the engine is started
-#define SKIP_INTRO
+// #define SKIP_INTRO
// XXX
// I'm not sure if system endian-ness would have any
@@ -115,7 +115,7 @@ public:
/**
* Wrapper function to the OSystem getMillis() method
*/
- uint32 getTick() { return _system->getMillis(); }
+ int32 getTick() { return (int32)_system->getMillis(); }
/**
* This is the global tick counter.
diff --git a/engines/asylum/barrier.cpp b/engines/asylum/barrier.cpp
index 0fcde03e76..90ade0d27c 100644
--- a/engines/asylum/barrier.cpp
+++ b/engines/asylum/barrier.cpp
@@ -36,11 +36,11 @@ Barrier::~Barrier() {
// TODO Auto-generated destructor stub
}
-uint32 Barrier::getRandomId() {
- int numRes = 0;
- uint32 rndResId[5];
+int32 Barrier::getRandomId() {
+ int32 numRes = 0;
+ int32 rndResId[5];
memset(&rndResId, 0, sizeof(rndResId));
- for (int i = 0; i < 5; i++) {
+ for (int32 i = 0; i < 5; i++) {
if (field_68C[i]) {
rndResId[numRes] = field_68C[i];
numRes++;
@@ -52,12 +52,12 @@ uint32 Barrier::getRandomId() {
return resId;
}
-int Barrier::checkFlags() {
+int32 Barrier::checkFlags() {
return flags & 1 && (flags & 8 || flags & 0x10000);
}
-void Barrier::setNextFrame(int targetFlags) {
- int newFlag = targetFlags | 1 | flags;
+void Barrier::setNextFrame(int32 targetFlags) {
+ int32 newFlag = targetFlags | 1 | flags;
flags |= targetFlags | 1;
if (newFlag & 0x10000)
diff --git a/engines/asylum/barrier.h b/engines/asylum/barrier.h
index de8cdc001e..f1a1e80f15 100644
--- a/engines/asylum/barrier.h
+++ b/engines/asylum/barrier.h
@@ -36,7 +36,7 @@ public:
virtual ~Barrier();
bool visible();
- uint32 getRandomId(); // TODO Give this a better name?
+ int32 getRandomId(); // TODO Give this a better name?
bool onscreen();
// TODO document this function
@@ -44,42 +44,42 @@ public:
// TODO document this function
void setNextFrame(int flags);
- uint32 id;
- uint32 resId;
- uint32 x;
- uint32 y;
+ int32 id;
+ int32 resId;
+ int32 x;
+ int32 y;
Common::Rect boundingRect;
- uint32 field_20;
- uint32 frameIdx;
- uint32 frameCount;
- uint32 field_2C;
- uint32 field_30;
- uint32 field_34;
- uint32 flags;
- uint32 field_3C;
+ int32 field_20;
+ int32 frameIdx;
+ int32 frameCount;
+ int32 field_2C;
+ int32 field_30;
+ int32 field_34;
+ int32 flags;
+ int32 field_3C;
uint8 name[52];
int32 field_74; // XXX looks like fields
int32 field_78; // 78 => 80 have something
int32 field_7C; // to do with calculating
int32 field_80; // actor intersection
- uint32 polyIdx;
- uint32 flags2;
- uint32 gameFlags[10];
- uint32 field_B4;
- uint32 tickCount;
- uint32 tickCount2;
- uint32 field_C0;
- uint32 priority;
- uint32 actionListIdx;
+ int32 polyIdx;
+ int32 flags2;
+ int32 gameFlags[10];
+ int32 field_B4;
+ int32 tickCount;
+ int32 tickCount2;
+ int32 field_C0;
+ int32 priority;
+ int32 actionListIdx;
SoundItem soundItems[16];
FrameSoundItem frameSoundItems[50];
- uint32 field_67C;
- uint32 soundX;
- uint32 soundY;
- uint32 field_688;
- uint32 field_68C[5];
- uint32 soundResId;
- uint32 field_6A4;
+ int32 field_67C;
+ int32 soundX;
+ int32 soundY;
+ int32 field_688;
+ int32 field_68C[5];
+ int32 soundResId;
+ int32 field_6A4;
}; // end of class Barrier
diff --git a/engines/asylum/blowuppuzzle.cpp b/engines/asylum/blowuppuzzle.cpp
index 43d870e443..7ac46f31eb 100644
--- a/engines/asylum/blowuppuzzle.cpp
+++ b/engines/asylum/blowuppuzzle.cpp
@@ -112,7 +112,7 @@ void BlowUpPuzzleVCR::handleEvent(Common::Event *event, bool doUpdate) {
update();
}
-void BlowUpPuzzle::playSound(uint resourceId, bool loop) {
+void BlowUpPuzzle::playSound(int32 resourceId, bool loop) {
_scene->vm()->sound()->playSound(_scene->getResourcePack(), resourceId, Config.sfxVolume, loop, 0, true);
}
@@ -440,9 +440,9 @@ void BlowUpPuzzleVCR::updateCursorInPolyRegion() {
|| inPolyRegion(_cursor->x(), _cursor->y(), kYellowJack)) {
_cursor->animate();
} else {
- if (inPolyRegion(_cursor->x(), _cursor->y(), kRedHole) && _holesState[kPluggedOnRed-1]
- || inPolyRegion(_cursor->x(), _cursor->y(), kYellowHole) && _holesState[kPluggedOnYellow-1]
- || inPolyRegion(_cursor->x(), _cursor->y(), kBlackHole) && _holesState[kPluggedOnBlack-1]) {
+ if ((inPolyRegion(_cursor->x(), _cursor->y(), kRedHole) && _holesState[kPluggedOnRed-1])
+ || (inPolyRegion(_cursor->x(), _cursor->y(), kYellowHole) && _holesState[kPluggedOnYellow-1])
+ || (inPolyRegion(_cursor->x(), _cursor->y(), kBlackHole) && _holesState[kPluggedOnBlack-1])) {
if (_cursor->currentFrame() != 2) { // reset cursor
_cursor->show();
_cursor->set(2);
@@ -500,8 +500,8 @@ void BlowUpPuzzleVCR::handleMouseDown() {
// Put jacks on table --
if (jackType) {
- if (_cursor->x() >= (uint32)BlowUpPuzzleVCRPolies[kBlackJack].left && _cursor->x() <= (uint32)BlowUpPuzzleVCRPolies[kYellowJack].right &&
- _cursor->y() >= (uint32)BlowUpPuzzleVCRPolies[kBlackJack].top && _cursor->y() <= (uint32)BlowUpPuzzleVCRPolies[kYellowJack].bottom) {
+ if (_cursor->x() >= (int32)BlowUpPuzzleVCRPolies[kBlackJack].left && _cursor->x() <= (int32)BlowUpPuzzleVCRPolies[kYellowJack].right &&
+ _cursor->y() >= (int32)BlowUpPuzzleVCRPolies[kBlackJack].top && _cursor->y() <= (int32)BlowUpPuzzleVCRPolies[kYellowJack].bottom) {
_jacksState[jackType-1] = kOnTable;
playSound(_scene->worldstats()->grResId[50]);
_cursor->show();
diff --git a/engines/asylum/blowuppuzzle.h b/engines/asylum/blowuppuzzle.h
index 36eaf524c0..a0aead668a 100644
--- a/engines/asylum/blowuppuzzle.h
+++ b/engines/asylum/blowuppuzzle.h
@@ -68,7 +68,7 @@ protected:
GraphicResource *_bgResource;
virtual void update() {};
- void playSound(uint resourceId, bool loop = false);
+ void playSound(int32 resourceId, bool loop = false);
}; // end of class BlowUpPuzzle
@@ -76,9 +76,9 @@ protected:
// ---- VCR -------------------
typedef struct VCRDrawInfo {
- uint32 resId;
- uint32 x;
- uint32 y;
+ int32 resId;
+ int32 x;
+ int32 y;
} VCRDrawInfo;
const Common::Rect BlowUpPuzzleVCRPolies[10] = {
diff --git a/engines/asylum/console.cpp b/engines/asylum/console.cpp
index 7b0e3bfb73..e6a3e186f5 100644
--- a/engines/asylum/console.cpp
+++ b/engines/asylum/console.cpp
@@ -30,8 +30,8 @@
namespace Asylum {
-extern int g_debugPolygons;
-extern int g_debugBarriers;
+extern int32 g_debugPolygons;
+extern int32 g_debugBarriers;
Console::Console(AsylumEngine *vm) : GUI::Debugger() {
_vm = vm;
@@ -50,12 +50,12 @@ Console::Console(AsylumEngine *vm) : GUI::Debugger() {
Console::~Console() {
}
-bool Console::cmdDumpActionArea(int argc, const char **argv) {
+bool Console::cmdDumpActionArea(int32 argc, const char **argv) {
if (argc == 2) {
// TODO Get an action area by index/id
} else {
- for (uint32 i = 0; i < _vm->scene()->worldstats()->numActions; i++) {
+ for (int32 i = 0; i < _vm->scene()->worldstats()->numActions; i++) {
ActionArea *a = &_vm->scene()->worldstats()->actions[i];
printActionAreaStats(a);
}
@@ -90,8 +90,8 @@ void Console::printActionAreaStats(ActionArea *a) {
a->volume);
}
-bool Console::cmdShowFlags(int argc, const char **argv) {
- for (int i = 0; i < 1512; i++) {
+bool Console::cmdShowFlags(int32 argc, const char **argv) {
+ for (int32 i = 0; i < 1512; i++) {
if (_vm->isGameFlagSet(i)) {
DebugPrintf("Game Flag %d is Active\n", i);
}
@@ -100,7 +100,7 @@ bool Console::cmdShowFlags(int argc, const char **argv) {
return true;
}
-bool Console::cmdToggleFlag(int argc, const char **argv) {
+bool Console::cmdToggleFlag(int32 argc, const char **argv) {
if (argc != 2 || atoi(argv[1]) > 1512 || atoi(argv[1]) < 0) {
DebugPrintf("Enter a value between 0 and 1512\n");
return true;
@@ -111,7 +111,7 @@ bool Console::cmdToggleFlag(int argc, const char **argv) {
return true;
}
-bool Console::cmdPlayVideo(int argc, const char **argv) {
+bool Console::cmdPlayVideo(int32 argc, const char **argv) {
if (argc != 2) {
DebugPrintf("Usage %s <video number>\n", argv[0]);
return true;
@@ -122,7 +122,7 @@ bool Console::cmdPlayVideo(int argc, const char **argv) {
return false;
}
-bool Console::cmdRunScript(int argc, const char **argv) {
+bool Console::cmdRunScript(int32 argc, const char **argv) {
if (argc != 2) {
DebugPrintf("Usage %s <script number>\n", argv[0]);
return true;
@@ -133,7 +133,7 @@ bool Console::cmdRunScript(int argc, const char **argv) {
return false;
}
-bool Console::cmdChangeScene(int argc, const char **argv) {
+bool Console::cmdChangeScene(int32 argc, const char **argv) {
if (argc != 2) {
DebugPrintf("Usage %s <scene number>\n", argv[0]);
return true;
diff --git a/engines/asylum/console.h b/engines/asylum/console.h
index 4bcc95e135..a299bf0933 100644
--- a/engines/asylum/console.h
+++ b/engines/asylum/console.h
@@ -41,12 +41,12 @@ public:
virtual ~Console(void);
private:
- bool cmdPlayVideo(int argc, const char **argv);
- bool cmdRunScript(int argc, const char **argv);
- bool cmdChangeScene(int argc, const char **argv);
- bool cmdShowFlags(int argc, const char **argv);
- bool cmdToggleFlag(int argc, const char **argv);
- bool cmdDumpActionArea(int argc, const char **argv);
+ bool cmdPlayVideo(int32 argc, const char **argv);
+ bool cmdRunScript(int32 argc, const char **argv);
+ bool cmdChangeScene(int32 argc, const char **argv);
+ bool cmdShowFlags(int32 argc, const char **argv);
+ bool cmdToggleFlag(int32 argc, const char **argv);
+ bool cmdDumpActionArea(int32 argc, const char **argv);
void printActionAreaStats(ActionArea *a);
diff --git a/engines/asylum/cursor.cpp b/engines/asylum/cursor.cpp
index 6abcb0ec26..ed1df0a29e 100644
--- a/engines/asylum/cursor.cpp
+++ b/engines/asylum/cursor.cpp
@@ -40,7 +40,7 @@ Cursor::~Cursor() {
delete _cursorResource;
}
-void Cursor::load(uint32 index) {
+void Cursor::load(int32 index) {
if (cursorLoaded)
delete _cursorResource;
@@ -62,7 +62,7 @@ void Cursor::set(byte *data, byte width, byte height) {
CursorMan.replaceCursor(data, width, height, 0, 0, 0);
}
-void Cursor::set(int frame) {
+void Cursor::set(int32 frame) {
if (frame >= 0) {
GraphicFrame *mouseCursor = _cursorResource->getFrame(frame);
set((byte *)mouseCursor->surface.pixels, mouseCursor->surface.w, mouseCursor->surface.h);
@@ -72,7 +72,7 @@ void Cursor::set(int frame) {
}
}
-void Cursor::setCoords(uint32 mouseX, uint32 mouseY) {
+void Cursor::setCoords(int32 mouseX, int32 mouseY) {
_mouseX = mouseX;
_mouseY = mouseY;
}
@@ -87,8 +87,8 @@ void Cursor::animate() {
set(_curFrame);
}
-void Cursor::update(CommonResources *cr, int currentAction) {
- uint32 newCursor = 0;
+void Cursor::update(CommonResources *cr, int32 currentAction) {
+ int32 newCursor = 0;
// Change cursor
switch (currentAction) {
diff --git a/engines/asylum/cursor.h b/engines/asylum/cursor.h
index 418a5e044e..8955c81786 100644
--- a/engines/asylum/cursor.h
+++ b/engines/asylum/cursor.h
@@ -53,16 +53,16 @@ public:
* Load a GraphicResource at the position specified by
* index from the buffered ResourcePack
*/
- void load(uint32 index);
+ void load(int32 index);
/**
* Set the current cursor to a specific frame
* within the loaded cursorResource
*/
- void set(int frame);
+ void set(int32 frame);
/**
* Set the x/y coordinates of the cursor
*/
- void setCoords(uint32 mouseX, uint32 mouseY);
+ void setCoords(int32 mouseX, int32 mouseY);
/**
* Scene-based update to the current cursor. This
* checks whether the cursor should be updated depending
@@ -71,7 +71,7 @@ public:
* TODO this probably doesn't belong here, but on the
* scene, where it originally was
*/
- void update(CommonResources *cr, int currentAction);
+ void update(CommonResources *cr, int32 currentAction);
/**
* Get the next logical frame from the currently loaded
* cursorResource and draw it
@@ -81,20 +81,20 @@ public:
/**
* Get the X position of the cursor
*/
- uint32 x() {
+ int32 x() {
return _mouseX;
}
/**
* get the Y position of the cursor
*/
- uint32 y() {
+ int32 y() {
return _mouseY;
}
/**
* Get the current frame number of the
* loaded cursorResource
*/
- uint32 currentFrame() {
+ int32 currentFrame() {
return _curFrame;
}
@@ -104,10 +104,10 @@ private:
ResourcePack *_resPack;
GraphicResource *_cursorResource;
bool cursorLoaded;
- uint32 _curFrame;
+ int32 _curFrame;
int32 _cursorStep;
- uint32 _mouseX;
- uint32 _mouseY;
+ int32 _mouseX;
+ int32 _mouseY;
}; // end of class Cursor
diff --git a/engines/asylum/encounters.cpp b/engines/asylum/encounters.cpp
index ed1ce5210d..23a206b3cf 100644
--- a/engines/asylum/encounters.cpp
+++ b/engines/asylum/encounters.cpp
@@ -35,29 +35,29 @@ Encounter::Encounter(Scene *scene) {
// TODO error checks
file.open("sntrm.dat");
- uint16 _count = file.readUint16LE();
+ int16 _count = file.readSint16LE();
- _variables = (uint16*)malloc(_count);
+ _variables = (int16*)malloc(_count);
file.read(_variables, _count);
file.seek(2 + _count * 2, SEEK_SET);
// TODO assert if true
- _anvilStyleFlag = file.readUint16LE();
+ _anvilStyleFlag = file.readSint16LE();
- uint16 _dataCount = file.readUint16LE();
+ int16 _dataCount = file.readSint16LE();
for (uint8 i = 0; i < _dataCount; i++) {
EncounterItem item;
memset(&item, 0, sizeof(EncounterItem));
- item.keywordIndex = file.readUint32LE();
- item.field2 = file.readUint32LE();
- item.scriptResId = file.readUint32LE();
+ item.keywordIndex = file.readSint32LE();
+ item.field2 = file.readSint32LE();
+ item.scriptResId = file.readSint32LE();
for (uint8 j = 0; j < 50; j++) {
- item.array[j] = file.readUint32LE();
+ item.array[j] = file.readSint32LE();
}
- item.value = file.readUint16LE();
+ item.value = file.readSint16LE();
_items.push_back(item);
}
@@ -67,7 +67,7 @@ Encounter::Encounter(Scene *scene) {
_scene = scene;
}
-void Encounter::run(int encounterIdx, int barrierId1, int barrierId2, int characterIdx) {
+void Encounter::run(int32 encounterIdx, int32 barrierId1, int32 barrierId2, int32 characterIdx) {
// Line: 12/15 :: 0x25 (1, 1584, 1584, 0, 0, 0, 0, 0, 0) // First Encounter
//debugC(kDebugLevelEncounter, "Running Encounter %d", encounterIdx);
@@ -78,12 +78,12 @@ void Encounter::run(int encounterIdx, int barrierId1, int barrierId2, int charac
//Barrier *b1 = _scene->worldstats()->getBarrierById(barrierId1);
/*
- int __cdecl runEncounter(int newMessageHandler, int encounterIndex, int objectId1, int objectId2, int characterIndex)
+ int32 __cdecl runEncounter(int32 newMessageHandler, int32 encounterIndex, int32 objectId1, int32 objectId2, int32 characterIndex)
{
- int result; // eax at 7
+ int32 result; // eax at 7
EncounterItem *v6; // eax at 2
- int v7; // ST04_4 at 4
- int v8; // eax at 4
+ int32 v7; // ST04_4 at 4
+ int32 v8; // eax at 4
if ( !encounterKeywordIndex )
{
@@ -118,7 +118,7 @@ void Encounter::run(int encounterIdx, int barrierId1, int barrierId2, int charac
character_sub_4072A0(playerCharacterIndex, 5);
}
flag04 = 0;
- switchMessageHandler((int (__cdecl *)(_DWORD, _DWORD, _DWORD))handleMessageEncounter);
+ switchMessageHandler((int32 (__cdecl *)(_DWORD, _DWORD, _DWORD))handleMessageEncounter);
result = 1;
}
return result;
diff --git a/engines/asylum/encounters.h b/engines/asylum/encounters.h
index 9fe1e6e345..e91161148b 100644
--- a/engines/asylum/encounters.h
+++ b/engines/asylum/encounters.h
@@ -32,22 +32,22 @@
namespace Asylum {
typedef struct EncounterItem {
- uint32 keywordIndex;
- uint32 field2;
- uint32 scriptResId;
- uint32 array[50];
- uint16 value;
+ int32 keywordIndex;
+ int32 field2;
+ int32 scriptResId;
+ int32 array[50];
+ int16 value;
} EncounterItem;
typedef struct EncounterStruct {
- uint32 x1;
- uint32 y1;
- uint32 x2;
- uint32 y2;
- uint32 frameNum;
- uint32 transTableNum;
- uint32 status;
- uint32 grResId;
+ int32 x1;
+ int32 y1;
+ int32 x2;
+ int32 y2;
+ int32 frameNum;
+ int32 transTableNum;
+ int32 status;
+ int32 grResId;
} EncounterStruct;
class Encounter {
@@ -55,14 +55,14 @@ public:
Encounter(Scene *scene);
virtual ~Encounter();
- void setVariable(int idx, int value) {
+ void setVariable(int32 idx, int32 value) {
_variables[idx] = value;
}
- void run(int encounterIdx, int barrierId1, int barrierId2, int characterIdx);
+ void run(int32 encounterIdx, int32 barrierId1, int32 barrierId2, int32 characterIdx);
private:
- uint16 *_variables;
- uint16 _anvilStyleFlag;
+ int16 *_variables;
+ int16 _anvilStyleFlag;
EncounterItem *_currentEncounter;
Common::Array<EncounterItem> _items;
diff --git a/engines/asylum/graphics.cpp b/engines/asylum/graphics.cpp
index 8ec95a2d05..de71390887 100644
--- a/engines/asylum/graphics.cpp
+++ b/engines/asylum/graphics.cpp
@@ -28,7 +28,7 @@
namespace Asylum {
-GraphicResource::GraphicResource(ResourcePack *resPack, int entry) {
+GraphicResource::GraphicResource(ResourcePack *resPack, int32 entry) {
ResourceEntry *resEntry = resPack->getResource(entry);
_entryNum = entry;
init(resEntry->data, resEntry->size);
@@ -42,19 +42,19 @@ GraphicResource::~GraphicResource() {
_frames.clear();
}
-void GraphicResource::init(byte *data, uint32 size) {
+void GraphicResource::init(byte *data, int32 size) {
byte *dataPtr = data;
- uint32 contentOffset = 0;
- uint32 frameCount = 0;
+ int32 contentOffset = 0;
+ int16 frameCount = 0;
- uint32 i = 0;
+ int32 i = 0;
dataPtr += 4; // tag value
- _flags = READ_LE_UINT32(dataPtr);
+ _flags = (int32)READ_LE_UINT32(dataPtr);
dataPtr += 4;
- contentOffset = READ_LE_UINT32(dataPtr);
+ contentOffset = (int32)READ_LE_UINT32(dataPtr);
dataPtr += 4;
dataPtr += 4; // unknown
@@ -69,16 +69,16 @@ void GraphicResource::init(byte *data, uint32 size) {
_frames.resize(frameCount);
// Read frame offsets
- uint32 prevOffset = READ_LE_UINT32(dataPtr) + contentOffset;
+ int32 prevOffset = (int32)READ_LE_UINT32(dataPtr) + contentOffset;
dataPtr += 4;
- uint32 nextOffset = 0;
+ int32 nextOffset = 0;
for (i = 0; i < frameCount; i++) {
GraphicFrame frame;
frame.offset = prevOffset;
// Read the offset of the next entry to determine the size of this one
- nextOffset = (i < frameCount - 1) ? READ_LE_UINT32(dataPtr) + contentOffset : size;
+ nextOffset = (i < frameCount - 1) ? (int32)READ_LE_UINT32(dataPtr) + contentOffset : size;
dataPtr += 4; // offset
frame.size = (nextOffset > 0) ? nextOffset - prevOffset : size - prevOffset;
@@ -97,14 +97,14 @@ void GraphicResource::init(byte *data, uint32 size) {
dataPtr += 4; // size
dataPtr += 4; // flag
- _frames[i].x = READ_LE_UINT16(dataPtr);
+ _frames[i].x = (int16)READ_LE_UINT16(dataPtr);
dataPtr += 2;
- _frames[i].y = READ_LE_UINT16(dataPtr);
+ _frames[i].y = (int16)READ_LE_UINT16(dataPtr);
dataPtr += 2;
- uint16 height = READ_LE_UINT16(dataPtr);
+ int16 height = (int16)READ_LE_UINT16(dataPtr);
dataPtr += 2;
- uint16 width = READ_LE_UINT16(dataPtr);
+ int16 width = (int16)READ_LE_UINT16(dataPtr);
dataPtr += 2;
_frames[i].surface.create(width, height, 1);
diff --git a/engines/asylum/graphics.h b/engines/asylum/graphics.h
index cd6c7fd91b..14d2edb5c5 100644
--- a/engines/asylum/graphics.h
+++ b/engines/asylum/graphics.h
@@ -33,50 +33,50 @@
namespace Asylum {
struct GraphicFrame {
- uint32 size;
- uint32 offset;
+ int32 size;
+ int32 offset;
- uint16 x;
- uint16 y;
+ int16 x;
+ int16 y;
Graphics::Surface surface;
};
// Graphic resources can be sprites or images, with multiple frames
class GraphicResource {
public:
- GraphicResource(ResourcePack *resPack, int entry);
+ GraphicResource(ResourcePack *resPack, int32 entry);
~GraphicResource();
- uint32 getFrameCount() {
+ int32 getFrameCount() {
return _frames.size();
}
- GraphicFrame *getFrame(int frame) {
+ GraphicFrame *getFrame(int32 frame) {
return &_frames[frame];
}
- uint32 getFlags() {
+ int32 getFlags() {
return _flags;
}
/**
* Copies an animation frame to the target buffer
*/
- void copyFrameToDest(byte *dest, int frame);
+ void copyFrameToDest(byte *dest, int32 frame);
/**
* Copies a sprite to the target buffer, with transparency
*/
- void copySpriteToDest(byte *dest, int frame);
+ void copySpriteToDest(byte *dest, int32 frame);
- uint32 getEntryNum() {
+ int32 getEntryNum() {
return _entryNum;
}
private:
Common::Array <GraphicFrame> _frames;
- uint32 _flags;
- uint32 _entryNum;
+ int32 _flags;
+ int32 _entryNum;
- void init(byte *data, uint32 size);
+ void init(byte *data, int32 size);
};
} // end of namespace Asylum
diff --git a/engines/asylum/menu.cpp b/engines/asylum/menu.cpp
index 419360644d..44f719442a 100644
--- a/engines/asylum/menu.cpp
+++ b/engines/asylum/menu.cpp
@@ -233,7 +233,7 @@ void MainMenu::update() {
void MainMenu::updateEyesAnimation() {
// Eyes animation
// Get the appropriate eye resource depending on the mouse position
- int eyeFrameNum = kEyesFront;
+ int32 eyeFrameNum = kEyesFront;
if (_cursor->x() <= 200) {
if (_cursor->y() <= 160)
@@ -264,7 +264,7 @@ void MainMenu::updateEyesAnimation() {
}
void MainMenu::updateMainMenu() {
- int rowId = 0;
+ int32 rowId = 0;
if (_cursor->y() >= 20 && _cursor->y() <= 20 + 48) {
rowId = 0; // Top row
@@ -280,10 +280,10 @@ void MainMenu::updateMainMenu() {
loadFont(kFontYellow);
// Icon animation
- for (uint32 i = 0; i <= 5; i++) {
- uint32 curX = 40 + i * 100;
+ for (int32 i = 0; i <= 5; i++) {
+ int32 curX = 40 + i * 100;
if (_cursor->x() >= curX && _cursor->x() <= curX + 55) {
- int iconNum = i + 6 * rowId;
+ int32 iconNum = i + 6 * rowId;
_activeIcon = iconNum;
// The last 2 icons are swapped
@@ -403,7 +403,7 @@ void MainMenu::updateSubMenuNewGame() {
}
void MainMenu::updateSubMenuCinematics() {
- int currentCD = 1; // FIXME: dummy value
+ int32 currentCD = 1; // FIXME: dummy value
_vm->text()->drawResTextWithValueCentered(10, 100, 620, 0x80000548, currentCD);
_vm->text()->setTextPos(30, 340);
_vm->text()->drawResText(0x80000549); // Prev Page
@@ -426,9 +426,9 @@ void MainMenu::updateSubMenuCinematics() {
}
void MainMenu::updateSubMenuSettings() {
- uint32 sizeMinus = _vm->text()->getTextWidth("-");
- uint32 sizePlus = _vm->text()->getTextWidth("+");
- uint32 sizeMainMenu = _vm->text()->getResTextWidth(0x8000059D);
+ int32 sizeMinus = _vm->text()->getTextWidth("-");
+ int32 sizePlus = _vm->text()->getTextWidth("+");
+ int32 sizeMainMenu = _vm->text()->getResTextWidth(0x8000059D);
loadFont(kFontYellow);
// Settings
@@ -557,11 +557,11 @@ void MainMenu::updateSubMenuQuitGame() {
}
void MainMenu::updateSubMenuShowCredits() {
- int posY = _creditsTextScroll;
- int resId = 0;
- int step = 0;
- int minBound = 0;
- int maxBound = 0;
+ int32 posY = _creditsTextScroll;
+ int32 resId = 0;
+ int32 step = 0;
+ int32 minBound = 0;
+ int32 maxBound = 0;
GraphicFrame *creditsFadeFrame = _creditsFadeResource->getFrame(0);
_vm->screen()->copyRectToScreenWithTransparency((byte *)creditsFadeFrame->surface.pixels, creditsFadeFrame->surface.w, creditsFadeFrame->x, creditsFadeFrame->y, creditsFadeFrame->surface.w, creditsFadeFrame->surface.h);
diff --git a/engines/asylum/menu.h b/engines/asylum/menu.h
index 81a083bd72..070b4d11ce 100644
--- a/engines/asylum/menu.h
+++ b/engines/asylum/menu.h
@@ -95,11 +95,11 @@ private:
Cursor *_cursor;
int32 _activeIcon;
int32 _previousActiveIcon;
- uint32 _curIconFrame;
- uint32 _curMouseCursor;
+ int32 _curIconFrame;
+ int32 _curMouseCursor;
int32 _cursorStep;
- uint32 _creditsBgFrame;
- uint32 _creditsTextScroll;
+ int32 _creditsBgFrame;
+ int32 _creditsTextScroll;
bool _leftClick;
bool _active;
diff --git a/engines/asylum/polygons.cpp b/engines/asylum/polygons.cpp
index 13a5101d53..4356265113 100644
--- a/engines/asylum/polygons.cpp
+++ b/engines/asylum/polygons.cpp
@@ -32,18 +32,18 @@ Polygons::Polygons(Common::SeekableReadStream *stream) {
}
Polygons::~Polygons() {
- for (uint32 i = 0; i < numEntries; i++)
+ for (int32 i = 0; i < numEntries; i++)
delete[] entries[i].points;
entries.clear();
}
-bool PolyDefinitions::contains(int x, int y) {
+bool PolyDefinitions::contains(int16 x, int16 y) {
// Copied from backends/vkeybd/polygon.cpp
- int yflag0;
- int yflag1;
+ int32 yflag0;
+ int32 yflag1;
bool inside_flag = false;
- unsigned int pt;
+ int32 pt;
Common::Point *vtx0 = &points[numPoints - 1];
Common::Point *vtx1 = &points[0];
@@ -65,28 +65,28 @@ bool PolyDefinitions::contains(int x, int y) {
}
void Polygons::load(Common::SeekableReadStream *stream) {
- size = stream->readUint32LE();
- numEntries = stream->readUint32LE();
+ size = stream->readSint32LE();
+ numEntries = stream->readSint32LE();
- for (uint32 g = 0; g < numEntries; g++) {
+ for (int32 g = 0; g < numEntries; g++) {
PolyDefinitions poly;
memset(&poly, 0, sizeof(PolyDefinitions));
- poly.numPoints = stream->readUint32LE();
+ poly.numPoints = stream->readSint32LE();
if (poly.numPoints > 0)
poly.points = new Common::Point[poly.numPoints];
- for (uint32 i = 0; i < poly.numPoints; i++) {
- poly.points[i].x = stream->readUint32LE() & 0xFFFF;
- poly.points[i].y = stream->readUint32LE() & 0xFFFF;
+ for (int32 i = 0; i < poly.numPoints; i++) {
+ poly.points[i].x = stream->readSint32LE() & 0xFFFF;
+ poly.points[i].y = stream->readSint32LE() & 0xFFFF;
}
stream->skip((MAX_POLYGONS - poly.numPoints) * 8);
- poly.boundingRect.left = stream->readUint32LE() & 0xFFFF;
- poly.boundingRect.top = stream->readUint32LE() & 0xFFFF;
- poly.boundingRect.right = stream->readUint32LE() & 0xFFFF;
- poly.boundingRect.bottom = stream->readUint32LE() & 0xFFFF;
+ poly.boundingRect.left = stream->readSint32LE() & 0xFFFF;
+ poly.boundingRect.top = stream->readSint32LE() & 0xFFFF;
+ poly.boundingRect.right = stream->readSint32LE() & 0xFFFF;
+ poly.boundingRect.bottom = stream->readSint32LE() & 0xFFFF;
entries.push_back(poly);
}
diff --git a/engines/asylum/polygons.h b/engines/asylum/polygons.h
index 58fc5e996e..8231e6df38 100644
--- a/engines/asylum/polygons.h
+++ b/engines/asylum/polygons.h
@@ -35,7 +35,7 @@
namespace Asylum {
typedef struct PolyDefinitions {
- uint32 numPoints;
+ int32 numPoints;
Common::Point *points;
Common::Rect boundingRect;
@@ -45,7 +45,7 @@ typedef struct PolyDefinitions {
*
* (was pointInPoly())
*/
- bool contains(int x, int y);
+ bool contains(int16 x, int16 y);
} PolyDefinitions;
@@ -54,8 +54,8 @@ public:
Polygons(Common::SeekableReadStream *stream);
virtual ~Polygons();
- uint32 size;
- uint32 numEntries;
+ int32 size;
+ int32 numEntries;
Common::Array<PolyDefinitions> entries;
diff --git a/engines/asylum/respack.cpp b/engines/asylum/respack.cpp
index 52e234d890..3766311f41 100644
--- a/engines/asylum/respack.cpp
+++ b/engines/asylum/respack.cpp
@@ -31,7 +31,7 @@ ResourcePack::ResourcePack(const char *resourceFile) {
init(resourceFile);
}
-ResourcePack::ResourcePack(int resourceIndex) {
+ResourcePack::ResourcePack(int32 resourceIndex) {
// We don't use the file number part of resource IDs
//uint32 fileNum = (resourceID >> 16) & 0x7FFF;
char filename[20];
diff --git a/engines/asylum/respack.h b/engines/asylum/respack.h
index 587e9d14b2..96cd32a31e 100644
--- a/engines/asylum/respack.h
+++ b/engines/asylum/respack.h
@@ -43,7 +43,7 @@ struct ResourceEntry {
class ResourcePack {
public:
ResourcePack(const char *resourceFile);
- ResourcePack(int resourceIndex);
+ ResourcePack(int32 resourceIndex);
~ResourcePack();
ResourceEntry *getResource(uint32 resourceId);
diff --git a/engines/asylum/scene.cpp b/engines/asylum/scene.cpp
index 2cdc4a7892..bea3af5446 100644
--- a/engines/asylum/scene.cpp
+++ b/engines/asylum/scene.cpp
@@ -95,7 +95,7 @@ Scene::Scene(uint8 sceneIdx, AsylumEngine *engine): _vm(engine) {
// TODO figure out what field_120 is used for
_ws->field_120 = -1;
- for (uint32 a = 0; a < _ws->numActors; a++) {
+ for (int32 a = 0; a < _ws->numActors; a++) {
_ws->actors[a].tickValue1 = _vm->getTick();
// FIXME This is a hack just to get the current resource
// pack and scene into the actor instance(s)
@@ -114,8 +114,8 @@ void Scene::initialize() {
_playerActorIdx = 0;
if (_ws->numBarriers > 0) {
- uint32 priority = 0x0FFB;
- for (uint32 b = 0; b < _ws->numBarriers; b++) {
+ int32 priority = 0x0FFB;
+ for (int32 b = 0; b < _ws->numBarriers; b++) {
Barrier *barrier = &_ws->barriers[b];
barrier->priority = priority;
barrier->flags &= 0xFFFF3FFF;
@@ -143,7 +143,7 @@ void Scene::initialize() {
updateActorDirection(_playerActorIdx, 4);
if (_ws->numActors > 1) {
- for (uint32 a = 1; a < _ws->numActors; a++) {
+ for (int32 a = 1; a < _ws->numActors; a++) {
Actor *act = &_ws->actors[a];
act->flags |= 1;
act->direction = 1;
@@ -155,7 +155,7 @@ void Scene::initialize() {
}
}
- uint32 actionIdx = _ws->actionListIdx;
+ int32 actionIdx = _ws->actionListIdx;
if (actionIdx)
_actions->queueScript(actionIdx, 0);
@@ -496,7 +496,7 @@ void Scene::update() {
}
int Scene::updateScene() {
- uint32 startTick = 0;
+ int32 startTick = 0;
// Mouse
startTick = _vm->getTick();
@@ -505,7 +505,7 @@ int Scene::updateScene() {
// Actors
startTick = _vm->getTick();
- for (uint32 a = 0; a < _ws->numActors; a++)
+ for (int32 a = 0; a < _ws->numActors; a++)
updateActor(a);
debugC(kDebugLevelScene, "UpdateActors Time: %d", _vm->getTick() - startTick);
@@ -553,9 +553,9 @@ void Scene::updateMouse() {
int dir = -1;
bool done = false;
- if (_cursor->x() < (uint32)actorPos.left) {
- if (_cursor->y() >= (uint32)actorPos.top) {
- if (_cursor->y() > (uint32)actorPos.bottom) {
+ if (_cursor->x() < actorPos.left) {
+ if (_cursor->y() >= actorPos.top) {
+ if (_cursor->y() > actorPos.bottom) {
if (getActor()->direction == 2) {
if (_cursor->y() - actorPos.bottom > 10)
dir = 3;
@@ -596,9 +596,9 @@ void Scene::updateMouse() {
done = true;
}
- if (!done && _cursor->x() <= (uint32)actorPos.right) {
- if (_cursor->y() >= (uint32)actorPos.top) {
- if (_cursor->y() > (uint32)actorPos.bottom) {
+ if (!done && _cursor->x() <= actorPos.right) {
+ if (_cursor->y() >= actorPos.top) {
+ if (_cursor->y() > actorPos.bottom) {
if (getActor()->direction == 3) {
if (_cursor->x() - actorPos.left > 10)
dir = 4;
@@ -627,7 +627,7 @@ void Scene::updateMouse() {
done = true;
}
- if (!done && _cursor->y() < (uint32)actorPos.top) {
+ if (!done && _cursor->y() < actorPos.top) {
if (getActor()->direction) {
if (getActor()->direction == 6) {
if (actorPos.top - _cursor->y() > 10)
@@ -642,7 +642,7 @@ void Scene::updateMouse() {
done = true;
}
- if (!done && _cursor->y() <= (uint32)actorPos.bottom) {
+ if (!done && _cursor->y() <= actorPos.bottom) {
if (getActor()->direction == 5) {
if (actorPos.bottom - _cursor->y() > 10)
dir = 6;
@@ -710,7 +710,7 @@ void Scene::updateActor(int32 actorIdx) {
}
break;
case 0x5: {
- uint32 frameNum = actor->frameNum + 1;
+ int32 frameNum = actor->frameNum + 1;
actor->frameNum = frameNum % actor->frameCount;
if (_vm->getTick() - actor->tickValue1 > 300) {
@@ -814,17 +814,17 @@ void Scene::updateActorSub01(Actor *act) {
void Scene::updateBarriers() {
//Screen *screen = _vm->screen();
- uint barriersCount = _ws->barriers.size();
+ int32 barriersCount = (int32)_ws->barriers.size();
//int startTickCount = 0;
bool canPlaySound = false;
if (barriersCount > 0) {
- for (uint32 b = 0; b < barriersCount; b++) {
+ for (int32 b = 0; b < barriersCount; b++) {
Barrier *barrier = &_ws->barriers[b];
if (barrier->field_3C == 4) {
if (_ws->isBarrierVisible(b)) {
- uint32 flag = barrier->flags;
+ int32 flag = barrier->flags;
if (flag & 0x20) {
if (barrier->field_B4 && (_vm->getTick() - barrier->tickCount >= 0x3E8 / barrier->field_B4)) {
barrier->frameIdx = (barrier->frameIdx + 1) % barrier->frameCount;
@@ -868,7 +868,7 @@ void Scene::updateBarriers() {
} else if (flag & 8) {
// FIXME: we shouldn't increment field_B4 (check why this value came zero sometimes)
if (barrier->field_B4 && (_vm->getTick() - barrier->tickCount >= 0x3E8 / barrier->field_B4)) {
- uint32 frameIdx = barrier->frameIdx + 1;
+ int32 frameIdx = barrier->frameIdx + 1;
if (frameIdx < barrier->frameCount - 1) {
if (barrier->field_688 == 1) {
// TODO: get global x, y positions
@@ -892,7 +892,7 @@ void Scene::updateBarriers() {
} else if (!((flag & 0xFFFF) & 6)) {
// FIXME: we shouldn't increment field_B4 (check why this value came zero sometimes)
if (barrier->field_B4 && (_vm->getTick() - barrier->tickCount >= 0x3E8 / barrier->field_B4) && (flag & 0x10000)) {
- uint32 frameIdx = barrier->frameIdx - 1;
+ int32 frameIdx = barrier->frameIdx - 1;
if (frameIdx <= 0) {
barrier->flags &= 0xFFFEFFFF;
if (barrier->field_688 == 1) {
@@ -960,9 +960,9 @@ void Scene::updateAmbientSounds() {
int panning, volume;
- for (uint32 i = 0; i < _ws->numAmbientSound; i++) {
+ for (int32 i = 0; i < _ws->numAmbientSound; i++) {
AmbientSoundItem *snd = &_ws->ambientSounds[i];
- for (uint32 f = 0; f < 6; f++) {
+ for (int32 f = 0; f < 6; f++) {
int gameFlag = snd->flagNum[f];
if (gameFlag >= 0) {
if (_vm->isGameFlagNotSet(gameFlag)) {
@@ -1069,13 +1069,13 @@ void Scene::updateAdjustScreen() {
}
if (v1 < 0)
v1 = _ws->xLeft = 0;
- if ((uint32)v1 > _ws->width - 640) {
+ if (v1 > _ws->width - 640) {
v1 = _ws->width - 640;
_ws->xLeft = v1;
}
if (v0 < 0)
v0 = _ws->yTop = 0;
- if ((uint32)v0 > _ws->height - 480) {
+ if (v0 > _ws->height - 480) {
v0 = _ws->height - 480;
_ws->yTop = v0;
}
@@ -1180,7 +1180,7 @@ void Scene::OLD_UPDATE() {
// DEBUGGING
// Check current walk region
- for (uint32 a = 0; a < _ws->numActions; a++) {
+ for (int32 a = 0; a < _ws->numActions; a++) {
if (_ws->actions[a].actionType == 0) {
ActionArea *area = &_ws->actions[a];
PolyDefinitions poly = _polygons->entries[area->polyIdx];
@@ -1216,7 +1216,7 @@ void Scene::OLD_UPDATE() {
debugShowBarriers();
// Check if we're within a barrier
- for (uint32 p = 0; p < _ws->numBarriers; p++) {
+ for (int32 p = 0; p < _ws->numBarriers; p++) {
Barrier b = _ws->barriers[p];
if (b.flags & 0x20) {
if ((b.boundingRect.left + b.x <= _cursor->x() + _ws->targetX) &&
@@ -1237,7 +1237,7 @@ void Scene::OLD_UPDATE() {
// of the barrier/polygon action scripts should be processed first
if (curBarrier < 0) {
// Update cursor if it's in a polygon hotspot
- for (uint32 p = 0; p < _polygons->numEntries; p++) {
+ for (int32 p = 0; p < _polygons->numEntries; p++) {
PolyDefinitions poly = _polygons->entries[p];
if (poly.boundingRect.contains(_cursor->x() + _ws->targetX, _cursor->y() + _ws->targetY)) {
if (poly.contains(_cursor->x() + _ws->targetX, _cursor->y() + _ws->targetY)) {
@@ -1253,8 +1253,8 @@ void Scene::OLD_UPDATE() {
_leftClick = false;
if (curHotspot >= 0) {
- for (uint32 a = 0; a < _ws->numActions; a++) {
- if (_ws->actions[a].polyIdx == (uint32)curHotspot) {
+ for (int32 a = 0; a < _ws->numActions; a++) {
+ if (_ws->actions[a].polyIdx == curHotspot) {
debugC(kDebugLevelScripts, "Hotspot: 0x%X - \"%s\", poly %d, action lists %d/%d, action type %d, sound res %d\n",
_ws->actions[a].id,
_ws->actions[a].name,
@@ -1323,7 +1323,7 @@ void Scene::drawActorsAndBarriers() {
// a collection of CharacterUpdateItems. Since
// we're only on scene 1 atm, and there is only one
// character, this will have to do :P
- for (uint i = 0; i < _ws->numActors; i++) {
+ for (int32 i = 0; i < _ws->numActors; i++) {
int actorRegPt = 0;
Actor *act = &_ws->actors[i];
Common::Point pt;
@@ -1359,7 +1359,7 @@ void Scene::drawActorsAndBarriers() {
*/
// XXX from .text:0040a4d1
- for (uint barIdx = 0; barIdx < _ws->numBarriers; barIdx++) {
+ for (int32 barIdx = 0; barIdx < _ws->numBarriers; barIdx++) {
Barrier *bar = &_ws->barriers[barIdx];
bool actInBar = bar->boundingRect.contains(act->boundingRect);
bool intersects = false;
@@ -1461,7 +1461,7 @@ void Scene::getActorPosition(Actor *actor, Common::Point *pt) {
int Scene::queueActorUpdates() {
if (_ws->numActors > 0) {
Common::Point pt;
- for (uint32 a = 0; a < _ws->numActors; a++) {
+ for (int32 a = 0; a < _ws->numActors; a++) {
Actor *actor = &_ws->actors[a];
if ((actor->flags & 0xFF) & 1) { // check this mask
@@ -1469,7 +1469,7 @@ int Scene::queueActorUpdates() {
//pt.x += actor->x;
//pt.y += actor->y;
- uint32 frameNum = actor->frameNum;
+ int32 frameNum = actor->frameNum;
if (actor->frameNum >= actor->frameCount) {
frameNum = 2 * actor->frameCount - actor->frameNum - 1;
}
@@ -1491,10 +1491,10 @@ int Scene::queueActorUpdates() {
}
int Scene::queueBarrierUpdates() {
- uint barriersCount = _ws->barriers.size();
+ int32 barriersCount = (int32)_ws->barriers.size();
if (barriersCount > 0) {
- for (uint32 b = 0; b < barriersCount; b++) {
+ for (int32 b = 0; b < barriersCount; b++) {
Barrier *barrier = &_ws->barriers[b];
if (!(barrier->flags & 4) && !((barrier->flags & 0xFF) & 0x40)) {
@@ -1576,7 +1576,7 @@ void Scene::debugShowWalkRegion(PolyDefinitions *poly) {
1);
// Draw all lines in Polygon
- for (uint32 i = 0; i < poly->numPoints; i++) {
+ for (int32 i = 0; i < poly->numPoints; i++) {
surface.drawLine(
poly->points[i].x - poly->boundingRect.left,
poly->points[i].y - poly->boundingRect.top,
@@ -1591,7 +1591,7 @@ void Scene::debugShowWalkRegion(PolyDefinitions *poly) {
// POLYGONS DEBUG
void Scene::debugShowPolygons() {
- for (uint32 p = 0; p < _polygons->numEntries; p++) {
+ for (int32 p = 0; p < _polygons->numEntries; p++) {
Graphics::Surface surface;
PolyDefinitions poly = _polygons->entries[p];
surface.create(poly.boundingRect.right - poly.boundingRect.left + 1,
@@ -1599,7 +1599,7 @@ void Scene::debugShowPolygons() {
1);
// Draw all lines in Polygon
- for (uint32 i = 0; i < poly.numPoints; i++) {
+ for (int32 i = 0; i < poly.numPoints; i++) {
surface.drawLine(
poly.points[i].x - poly.boundingRect.left,
poly.points[i].y - poly.boundingRect.top,
@@ -1615,7 +1615,7 @@ void Scene::debugShowPolygons() {
// BARRIER DEBUGGING
void Scene::debugShowBarriers() {
- for (uint32 p = 0; p < _ws->numBarriers; p++) {
+ for (int32 p = 0; p < _ws->numBarriers; p++) {
Graphics::Surface surface;
Barrier b = _ws->barriers[p];
@@ -1633,7 +1633,7 @@ void Scene::debugShowBarriers() {
// BARRIER DEBUGGING
void Scene::debugShowActors() {
- for (uint32 p = 0; p < _ws->numActors; p++) {
+ for (int32 p = 0; p < _ws->numActors; p++) {
Graphics::Surface surface;
Actor a = _ws->actors[p];
@@ -1673,7 +1673,7 @@ SceneTitle::~SceneTitle() {
delete _progress;
}
-void SceneTitle::update(uint32 tick) {
+void SceneTitle::update(int32 tick) {
// XXX This is not from the original. It's just some
// arbitrary math to throttle the progress indicator.
@@ -1694,8 +1694,8 @@ void SceneTitle::update(uint32 tick) {
bgFrame->surface.w,
0, 0, 640, 480);
- uint32 resId = _scene->getSceneIndex() - 4 + 1811;
- uint32 resWidth = _scene->vm()->text()->getResTextWidth(resId);
+ int32 resId = _scene->getSceneIndex() - 4 + 1811;
+ int32 resWidth = _scene->vm()->text()->getResTextWidth(resId);
_scene->vm()->text()->drawResTextCentered(320 - resWidth * 24, 30, resWidth, resId);
GraphicFrame *frame = _progress->getFrame(_spinnerFrame);
diff --git a/engines/asylum/scene.h b/engines/asylum/scene.h
index b99298ecd9..b6e92294ef 100644
--- a/engines/asylum/scene.h
+++ b/engines/asylum/scene.h
@@ -59,7 +59,7 @@ public:
SceneTitle(Scene *scene);
~SceneTitle();
- void update(uint32 tick);
+ void update(int32 tick);
bool loadingComplete() { return _done; }
private:
@@ -67,11 +67,11 @@ private:
GraphicResource *_bg;
GraphicResource *_progress;
- uint32 _start;
- uint32 _ticks;
+ int32 _start;
+ int32 _ticks;
bool _done;
- uint32 _spinnerFrame;
- uint32 _spinnerProgress;
+ int32 _spinnerFrame;
+ int32 _spinnerProgress;
bool _showMouseState;
@@ -100,7 +100,7 @@ public:
Cursor* getCursor() { return _cursor; }
ResourcePack* getResourcePack() { return _resPack; }
ResourcePack* getMusicPack() { return _musPack; }
- GraphicResource* getGraphicResource(uint32 entry) { return new GraphicResource(_resPack, entry); }
+ GraphicResource* getGraphicResource(int32 entry) { return new GraphicResource(_resPack, entry); }
BlowUpPuzzle* getBlowUpPuzzle() { return _blowUp;}
void setBlowUpPuzzle(BlowUpPuzzle* puzzle) { _blowUp = puzzle; }
void setScenePosition(int x, int y);
@@ -197,7 +197,7 @@ private:
int queueBarrierUpdates();
bool isBarrierVisible(BarrierItem *barrier);
bool isBarrierOnScreen(BarrierItem *barrier);
- uint32 getRandomResId(BarrierItem *barrier);
+ int32 getRandomResId(BarrierItem *barrier);
void copyToBackBufferClipped(Graphics::Surface *surface, int x, int y);
diff --git a/engines/asylum/screen.cpp b/engines/asylum/screen.cpp
index 8cb16814b2..dfb443bf41 100644
--- a/engines/asylum/screen.cpp
+++ b/engines/asylum/screen.cpp
@@ -39,9 +39,9 @@ void Screen::copyBackBufferToScreen() {
_vm->_system->copyRectToScreen((byte *)_backBuffer.pixels, _backBuffer.w, 0, 0, _backBuffer.w, _backBuffer.h);
}
-void Screen::copyToBackBuffer(byte *buffer, int pitch, int x, int y, int width, int height) {
- int h = height;
- int w = width;
+void Screen::copyToBackBuffer(byte *buffer, int32 pitch, int32 x, int32 y, int32 width, int32 height) {
+ int32 h = height;
+ int32 w = width;
byte *dest = (byte *)_backBuffer.pixels;
while (h--) {
@@ -51,13 +51,13 @@ void Screen::copyToBackBuffer(byte *buffer, int pitch, int x, int y, int width,
}
}
-void Screen::copyToBackBufferWithTransparency(byte *buffer, int pitch, int x, int y, int width, int height) {
- // int h = height;
- // int w = width;
+void Screen::copyToBackBufferWithTransparency(byte *buffer, int32 pitch, int32 x, int32 y, int32 width, int32 height) {
+ // int32 h = height;
+ // int32 w = width;
byte *dest = (byte *)_backBuffer.pixels;
- for (int curY = 0; curY < height; curY++) {
- for (int curX = 0; curX < width; curX++) {
+ for (int32 curY = 0; curY < height; curY++) {
+ for (int32 curX = 0; curX < width; curX++) {
if (buffer[curX + curY * pitch] != 0) {
dest[x + curX + (y + curY) * 640] = buffer[curX + curY * pitch];
}
@@ -65,15 +65,15 @@ void Screen::copyToBackBufferWithTransparency(byte *buffer, int pitch, int x, in
}
}
-void Screen::copyRectToScreen(byte *buffer, int pitch, int x, int y, int width, int height) {
+void Screen::copyRectToScreen(byte *buffer, int32 pitch, int32 x, int32 y, int32 width, int32 height) {
_vm->_system->copyRectToScreen(buffer, pitch, x, y, width, height);
}
-void Screen::copyRectToScreenWithTransparency(byte *buffer, int pitch, int x, int y, int width, int height) {
+void Screen::copyRectToScreenWithTransparency(byte *buffer, int32 pitch, int32 x, int32 y, int32 width, int32 height) {
byte *screenBuffer = (byte *)_vm->_system->lockScreen()->pixels;
- for (int curY = 0; curY < height; curY++) {
- for (int curX = 0; curX < width; curX++) {
+ for (int32 curY = 0; curY < height; curY++) {
+ for (int32 curX = 0; curX < width; curX++) {
if (buffer[curX + curY * pitch] != 0 && (x + curX + (y + curY) * 640 <= 640*480)) {
screenBuffer[x + curX + (y + curY) * 640] = buffer[curX + curY * pitch];
}
@@ -91,7 +91,7 @@ void Screen::setPalette(byte *rgbPalette) {
memset(palette, 0, 4);
p += 3;
- for (int i = 1; i < 256; i++) {
+ for (int32 i = 1; i < 256; i++) {
palette[i * 4 + 0] = *p++ << 2;
palette[i * 4 + 1] = *p++ << 2;
palette[i * 4 + 2] = *p++ << 2;
@@ -115,7 +115,7 @@ void Screen::clearScreen() {
_vm->_system->fillScreen(0);
}
-void Screen::addGraphicToQueue(uint32 resId, uint32 frameIdx, uint32 x, uint32 y, uint32 flags, uint32 transTableNum, uint32 priority) {
+void Screen::addGraphicToQueue(int32 resId, int32 frameIdx, int32 x, int32 y, int32 flags, int32 transTableNum, int32 priority) {
GraphicQueueItem item;
item.resId = resId;
item.x = x;
@@ -128,7 +128,7 @@ void Screen::addGraphicToQueue(uint32 resId, uint32 frameIdx, uint32 x, uint32 y
_queueItems.push_back(item);
}
-void Screen::addCrossFadeGraphicToQueue(uint32 resId, uint32 frameIdx, uint32 x, uint32 y, uint32 redId2, uint32 x2, uint32 y2, uint32 flags, uint32 priority) {
+void Screen::addCrossFadeGraphicToQueue(int32 resId, int32 frameIdx, int32 x, int32 y, int32 redId2, int32 x2, int32 y2, int32 flags, int32 priority) {
}
@@ -142,7 +142,7 @@ void Screen::drawGraphicsInQueue() {
// sort by priority first
graphicsSelectionSort();
- for (uint i = 0; i < _queueItems.size(); i++) {
+ for (uint32 i = 0; i < _queueItems.size(); i++) {
GraphicResource *grRes = _vm->scene()->getGraphicResource(_queueItems[i].resId);
GraphicFrame *fra = grRes->getFrame(_queueItems[i].frameIdx);
copyRectToScreenWithTransparency((byte *)fra->surface.pixels, fra->surface.w, _queueItems[i].x - ws->targetX, _queueItems[i].y - ws->targetY, fra->surface.w, fra->surface.h);
@@ -155,12 +155,12 @@ void Screen::clearGraphicsInQueue() {
}
void Screen::graphicsSelectionSort() {
- uint minIdx;
+ uint32 minIdx;
- for (uint i = 0; i < _queueItems.size(); i++) {
+ for (uint32 i = 0; i < _queueItems.size(); i++) {
minIdx = i;
- for (uint j = i + 1; j < _queueItems.size(); j++)
+ for (uint32 j = i + 1; j < _queueItems.size(); j++)
if (_queueItems[j].priority > _queueItems[i].priority)
minIdx = j;
@@ -169,15 +169,15 @@ void Screen::graphicsSelectionSort() {
}
}
-void Screen::swapGraphicItem(int item1, int item2) {
+void Screen::swapGraphicItem(int32 item1, int32 item2) {
GraphicQueueItem temp;
temp = _queueItems[item1];
_queueItems[item1] = _queueItems[item2];
_queueItems[item2] = temp;
}
-void Screen::deleteGraphicFromQueue(uint32 resId) {
- for (uint i = 0; i < _queueItems.size(); i++) {
+void Screen::deleteGraphicFromQueue(int32 resId) {
+ for (uint32 i = 0; i < _queueItems.size(); i++) {
if (_queueItems[i].resId == resId) {
_queueItems.remove_at(i);
break;
diff --git a/engines/asylum/screen.h b/engines/asylum/screen.h
index c69ad5b497..35f85fc974 100644
--- a/engines/asylum/screen.h
+++ b/engines/asylum/screen.h
@@ -36,13 +36,13 @@
namespace Asylum {
typedef struct GraphicQueueItem {
- uint32 resId;
- uint32 frameIdx;
- uint32 x;
- uint32 y;
- uint32 flags;
- uint32 transTableNum;
- uint32 priority;
+ int32 resId;
+ int32 frameIdx;
+ int32 x;
+ int32 y;
+ int32 flags;
+ int32 transTableNum;
+ int32 priority;
} GraphicQueueItem;
@@ -51,26 +51,26 @@ public:
Screen(AsylumEngine *_vm);
~Screen();
- void copyToBackBuffer(byte *buffer, int pitch, int x, int y, int width, int height);
- void copyToBackBufferWithTransparency(byte *buffer, int pitch, int x, int y, int width, int height);
+ void copyToBackBuffer(byte *buffer, int32 pitch, int32 x, int32 y, int32 width, int32 height);
+ void copyToBackBufferWithTransparency(byte *buffer, int32 pitch, int32 x, int32 y, int32 width, int32 height);
void copyBackBufferToScreen();
- void copyRectToScreen(byte *buffer, int pitch, int x, int y, int width, int height);
- void copyRectToScreenWithTransparency(byte *buffer, int pitch, int x, int y, int width, int height);
+ void copyRectToScreen(byte *buffer, int32 pitch, int32 x, int32 y, int32 width, int32 height);
+ void copyRectToScreenWithTransparency(byte *buffer, int32 pitch, int32 x, int32 y, int32 width, int32 height);
void setPalette(byte *rgbPalette);
- void setPalette(ResourcePack *resPack, int entry) {
+ void setPalette(ResourcePack *resPack, int32 entry) {
setPalette(resPack->getResource(entry)->data + 32);
}
void drawWideScreen(int16 barSize);
void clearScreen();
- void addGraphicToQueue(uint32 resId, uint32 frameIdx, uint32 x, uint32 y, uint32 flags, uint32 transTableNum, uint32 priority);
- void addCrossFadeGraphicToQueue(uint32 resId, uint32 frameIdx, uint32 x, uint32 y, uint32 redId2, uint32 x2, uint32 y2, uint32 flags, uint32 priority);
+ void addGraphicToQueue(int32 resId, int32 frameIdx, int32 x, int32 y, int32 flags, int32 transTableNum, int32 priority);
+ void addCrossFadeGraphicToQueue(int32 resId, int32 frameIdx, int32 x, int32 y, int32 redId2, int32 x2, int32 y2, int32 flags, int32 priority);
void addGraphicToQueue(GraphicQueueItem item);
void drawGraphicsInQueue();
void clearGraphicsInQueue();
void graphicsSelectionSort();
- void swapGraphicItem(int item1, int item2);
- void deleteGraphicFromQueue(uint32 resId);
+ void swapGraphicItem(int32 item1, int32 item2);
+ void deleteGraphicFromQueue(int32 resId);
private:
Graphics::Surface _backBuffer;
diff --git a/engines/asylum/sound.cpp b/engines/asylum/sound.cpp
index 4d4a339635..b3751905ee 100644
--- a/engines/asylum/sound.cpp
+++ b/engines/asylum/sound.cpp
@@ -48,7 +48,7 @@ Sound::~Sound() {
}
// from engines/agos/sound.cpp
-void convertVolume(int &vol) {
+void convertVolume(int32 &vol) {
// DirectSound was orginally used, which specifies volume
// and panning differently than ScummVM does, using a logarithmic scale
// rather than a linear one.
@@ -61,7 +61,7 @@ void convertVolume(int &vol) {
// affecting the right speaker. Thus -10,000 means the left speaker is
// silent.
- int v = CLIP(vol, -10000, 0);
+ int32 v = CLIP(vol, -10000, 0);
if (v) {
vol = (int)((double)Audio::Mixer::kMaxChannelVolume * pow(10.0, (double)v / 2000.0) + 0.5);
} else {
@@ -70,7 +70,7 @@ void convertVolume(int &vol) {
}
// from engines/agos/sound.cpp
-void convertPan(int &pan) {
+void convertPan(int32 &pan) {
// DirectSound was orginally used, which specifies volume
// and panning differently than ScummVM does, using a logarithmic scale
// rather than a linear one.
@@ -83,7 +83,7 @@ void convertPan(int &pan) {
// affecting the right speaker. Thus -10,000 means the left speaker is
// silent.
- int p = CLIP(pan, -10000, 10000);
+ int32 p = CLIP(pan, -10000, 10000);
if (p < 0) {
pan = (int)(255.0 * pow(10.0, (double)p / 2000.0) + 127.5);
} else if (p > 0) {
@@ -93,10 +93,10 @@ void convertPan(int &pan) {
}
}
-int Sound::getBufferPosition(uint32 resId) {
- int pos = -1;
+int32 Sound::getBufferPosition(int32 resId) {
+ int32 pos = -1;
- for (uint i = 0; i < _soundBuffer.size(); i++) {
+ for (uint32 i = 0; i < _soundBuffer.size(); i++) {
if (resId == _soundBuffer[i].resId) {
pos = i;
break;
@@ -106,8 +106,8 @@ int Sound::getBufferPosition(uint32 resId) {
return pos;
}
-bool Sound::addToSoundBuffer(uint resId) {
- int exists = getBufferPosition(resId);
+bool Sound::addToSoundBuffer(int32 resId) {
+ int32 exists = getBufferPosition(resId);
if (exists < 0) {
SoundBufferItem sound;
@@ -119,8 +119,8 @@ bool Sound::addToSoundBuffer(uint resId) {
return (exists < 0) ? true : false;
}
-void Sound::removeFromSoundBuffer(uint resId) {
- int pos = getBufferPosition(resId);
+void Sound::removeFromSoundBuffer(int32 resId) {
+ int32 pos = getBufferPosition(resId);
if (pos >= 0) {
_soundBuffer.remove_at(pos);
@@ -131,8 +131,8 @@ void Sound::clearSoundBuffer() {
_soundBuffer.clear();
}
-bool Sound::isPlaying(uint resId) {
- int pos = getBufferPosition(resId);
+bool Sound::isPlaying(int32 resId) {
+ int32 pos = getBufferPosition(resId);
if (pos < 0) {
warning("isPlaying: resId %d not currently bufferred", resId);
@@ -148,7 +148,7 @@ bool Sound::isPlaying(uint resId) {
return false;
}
-void Sound::playSound(ResourcePack *pack, uint resId, int volume, bool looping, int panning, bool overwrite) {
+void Sound::playSound(ResourcePack *pack, int32 resId, int32 volume, bool looping, int32 panning, bool overwrite) {
ResourceEntry *resource = pack->getResource(resId);
if (_mixer->isSoundHandleActive(_soundHandle)) {
if (overwrite) {
@@ -161,12 +161,12 @@ void Sound::playSound(ResourcePack *pack, uint resId, int volume, bool looping,
}
}
-void Sound::playSound(ResourceEntry *resource, bool looping, int volume, int panning) {
+void Sound::playSound(ResourceEntry *resource, bool looping, int32 volume, int32 panning) {
playSoundData(&_soundHandle, resource->data, resource->size, looping, volume, panning);
}
-void Sound::playSound(ResourcePack *pack, uint resId, bool looping, int volume, int panning) {
- int pos = getBufferPosition(resId);
+void Sound::playSound(ResourcePack *pack, int32 resId, bool looping, int32 volume, int32 panning) {
+ int32 pos = getBufferPosition(resId);
if (pos < 0) {
warning("playSound: resId %d not currently bufferred", resId);
@@ -183,7 +183,7 @@ void Sound::playSound(ResourcePack *pack, uint resId, bool looping, int volume,
}
-void Sound::playSound(uint resId, bool looping, int volume, int panning, bool fromBuffer) {
+void Sound::playSound(int32 resId, bool looping, int32 volume, int32 panning, bool fromBuffer) {
if (fromBuffer) {
playSound(_soundPack, resId, looping, volume, panning);
} else {
@@ -202,8 +202,8 @@ void Sound::stopSound() {
_mixer->stopHandle(_soundHandle);
}
-void Sound::stopSound(uint resId) {
- int pos = getBufferPosition(resId);
+void Sound::stopSound(int32 resId) {
+ int32 pos = getBufferPosition(resId);
if (pos < 0) {
warning("stopSound: resId %d not currently bufferred", resId);
@@ -220,24 +220,24 @@ void Sound::stopAllSounds(bool stopSpeechAndMusic) {
_mixer->stopHandle(_musicHandle);
}
- for (uint i = 0; i < _soundBuffer.size(); i++)
+ for (uint32 i = 0; i < _soundBuffer.size(); i++)
_mixer->stopHandle(_soundBuffer[i].handle);
}
-void Sound::playSpeech(uint resId) {
+void Sound::playSpeech(int32 resId) {
ResourceEntry *ent = _speechPack->getResource(resId);
_mixer->stopHandle(_speechHandle);
playSoundData(&_speechHandle, ent->data, ent->size, false, 0, 0);
}
-void Sound::playMusic(uint resId) {
+void Sound::playMusic(int32 resId) {
stopMusic();
// TODO Play music :P
}
-void Sound::playMusic(ResourcePack *pack, uint resId) {
+void Sound::playMusic(ResourcePack *pack, int32 resId) {
stopMusic();
ResourceEntry *resource = pack->getResource(resId);
@@ -249,13 +249,13 @@ void Sound::stopMusic() {
}
// from engines/agos/sound.cpp
-void Sound::playSoundData(Audio::SoundHandle *handle, byte *soundData, uint soundDataLength, bool loop, int vol, int pan) {
+void Sound::playSoundData(Audio::SoundHandle *handle, byte *soundData, int32 soundDataLength, bool loop, int32 vol, int32 pan) {
byte *buffer, flags;
uint16 compType;
- int blockAlign, rate;
+ int32 blockAlign, rate;
// TODO: Use makeWAVStream() in future, when makeADPCMStream() allows sound looping
- int size = soundDataLength;
+ int32 size = soundDataLength;
Common::MemoryReadStream stream(soundData, size);
if (!Audio::loadWAVFromStream(stream, size, rate, flags, &compType, &blockAlign))
error("playSoundData: Not valid WAV data");
diff --git a/engines/asylum/sound.h b/engines/asylum/sound.h
index 51604b35bd..006aaaf9ba 100644
--- a/engines/asylum/sound.h
+++ b/engines/asylum/sound.h
@@ -33,40 +33,40 @@
namespace Asylum {
typedef struct SoundItem {
- uint32 resId;
- uint32 field_4;
- uint32 field_8;
- uint32 field_C;
+ int32 resId;
+ int32 field_4;
+ int32 field_8;
+ int32 field_C;
} SoundItem;
typedef struct FrameSoundItem {
- uint32 resId;
- uint32 frameIdx;
- uint32 index;
- uint32 field_C;
- uint32 field_10;
- uint32 field_14;
+ int32 resId;
+ int32 frameIdx;
+ int32 index;
+ int32 field_C;
+ int32 field_10;
+ int32 field_14;
} FrameSoundItem;
typedef struct AmbientSoundItem {
- uint32 field_0;
- uint32 flags;
- uint32 resId;
- uint32 field_C;
- uint32 field_10;
- uint32 field_14;
- int flagNum[6];
- uint32 x;
- uint32 y;
+ int32 field_0;
+ int32 flags;
+ int32 resId;
+ int32 field_C;
+ int32 field_10;
+ int32 field_14;
+ int32 flagNum[6];
+ int32 x;
+ int32 y;
} AmbientSoundItem;
typedef struct SoundBufferItem {
- uint32 resId;
+ int32 resId;
Audio::SoundHandle handle;
- uint32 unknown;
+ int32 unknown;
} SoundBufferItem;
class Sound {
@@ -74,8 +74,8 @@ public:
Sound(Audio::Mixer *mixer);
~Sound();
- bool addToSoundBuffer(uint resId);
- void removeFromSoundBuffer(uint resId);
+ bool addToSoundBuffer(int32 resId);
+ void removeFromSoundBuffer(int32 resId);
void clearSoundBuffer();
/**
@@ -83,18 +83,18 @@ public:
*
* @param overwrite determine if _soundHandle should be overwritten if still active
*/
- void playSound(ResourcePack *pack, uint resId, int volume, bool looping = false, int panning = 0, bool overwrite = false);
- void playSound(ResourcePack *pack, uint resId, bool looping, int volume, int panning);
- void playSound(ResourceEntry *resource, bool looping, int volume, int panning);
- void playSound(uint resId, bool looping, int volume, int panning, bool fromBuffer = false);
- void stopSound(uint resId);
+ void playSound(ResourcePack *pack, int32 resId, int32 volume, bool looping = false, int32 panning = 0, bool overwrite = false);
+ void playSound(ResourcePack *pack, int32 resId, bool looping, int32 volume, int32 panning);
+ void playSound(ResourceEntry *resource, bool looping, int32 volume, int32 panning);
+ void playSound(int32 resId, bool looping, int32 volume, int32 panning, bool fromBuffer = false);
+ void stopSound(int32 resId);
void stopSound();
void stopAllSounds(bool stopSpeechAndMusic = false);
- void playSpeech(uint resId);
+ void playSpeech(int32 resId);
- void playMusic(ResourcePack *pack, uint resId);
- void playMusic(uint resId);
+ void playMusic(ResourcePack *pack, int32 resId);
+ void playMusic(int32 resId);
void stopMusic();
/**
@@ -105,7 +105,7 @@ public:
* music or speech, as those resources aren't managed beyond simple
* start/stop requests.
*/
- bool isPlaying(uint resId);
+ bool isPlaying(int32 resId);
/**
* Check if the unmanaged sound handle is in use
@@ -113,9 +113,7 @@ public:
* This is useful for checking the active state of a sound
* in a blowuppuzzle
*/
- bool isPlaying() {
- return _mixer->isSoundHandleActive(_soundHandle);
- }
+ bool isPlaying() { return _mixer->isSoundHandleActive(_soundHandle); }
private:
Audio::Mixer *_mixer;
@@ -135,14 +133,14 @@ private:
* to track it uniquely, as this doesn't involve initializing the
* scene just to set a single variable
*/
- int _currentMusicResIndex;
+ int32 _currentMusicResIndex;
/**
* Find the index within the _soundBuffer array of the
* sound sample with provided id.
*/
- int getBufferPosition(uint32 resId);
- void playSoundData(Audio::SoundHandle *handle, byte *soundData, uint32 soundDataLength, bool loop = false, int vol = 0, int pan = 0);
+ int32 getBufferPosition(int32 resId);
+ void playSoundData(Audio::SoundHandle *handle, byte *soundData, int32 soundDataLength, bool loop = false, int32 vol = 0, int32 pan = 0);
};
} // end of namespace Asylum
diff --git a/engines/asylum/speech.cpp b/engines/asylum/speech.cpp
index fe2f2b3f22..470064e9d3 100644
--- a/engines/asylum/speech.cpp
+++ b/engines/asylum/speech.cpp
@@ -40,13 +40,13 @@ Speech::~Speech() {
// TODO Auto-generated destructor stub
}
-uint32 Speech::play(uint32 speechIdx) {
- uint32 soundResIdx = 0;
+int32 Speech::play(int32 speechIdx) {
+ int32 soundResIdx = 0;
switch (_scene->worldstats()->actorType) {
case kMax: {
- uint32 soundResIdx2 = speechIdx;
- uint32 textResIdx = speechIdx;
+ int32 soundResIdx2 = speechIdx;
+ int32 textResIdx = speechIdx;
if (speechIdx >= 259) {
soundResIdx2 -= 9;
@@ -82,7 +82,7 @@ uint32 Speech::play(uint32 speechIdx) {
return soundResIdx;
}
-void Speech::setPlayerSpeech(uint32 soundResIdx, uint32 textResIdx) {
+void Speech::setPlayerSpeech(int32 soundResIdx, int32 textResIdx) {
if (soundResIdx) {
if (_scene->vm()->sound()->isPlaying(soundResIdx)) {
_scene->vm()->sound()->stopSound(soundResIdx);
@@ -96,7 +96,7 @@ void Speech::setPlayerSpeech(uint32 soundResIdx, uint32 textResIdx) {
}
void Speech::prepareSpeech() {
- uint32 startTick = _scene->vm()->getTick();
+ //int32 startTick = _scene->vm()->getTick();
if (_soundResIdx) {
if (!_scene->vm()->sound()->isPlaying(_soundResIdx)/* || _tick && startTick >= _tick*/) {
@@ -110,7 +110,7 @@ void Speech::prepareSpeech() {
check = pt->y < 240;
check = pt->y >= 240;*/
- uint32 posY = ((check - 1) & 0x118) + 40;
+ int32 posY = ((check - 1) & 0x118) + 40;
_scene->vm()->text()->loadFont(_scene->getResourcePack(), _scene->worldstats()->commonRes.font3);
_scene->vm()->text()->drawText(20, posY, _textDataPos);
diff --git a/engines/asylum/speech.h b/engines/asylum/speech.h
index ca149c37a7..39e327f088 100644
--- a/engines/asylum/speech.h
+++ b/engines/asylum/speech.h
@@ -36,22 +36,22 @@ public:
Speech(Scene *scene);
virtual ~Speech();
- uint32 _soundResIdx;
- uint32 _textResIdx;
+ int32 _soundResIdx;
+ int32 _textResIdx;
/** .text:00414810
* Play player speech
* @param speechIdx speech index (used for sound and text resources)
* @return correct resourceId
*/
- uint32 play(uint32 speechIdx);
+ int32 play(int32 speechIdx);
/** .text:004146D0
* Set speech for different player type
* @param soundResIdx sound resource id
* @param textResIdx text resource id
*/
- void setPlayerSpeech(uint32 soundResIdx, uint32 textResIdx);
+ void setPlayerSpeech(int32 soundResIdx, int32 textResIdx);
/** .text:004144C0
* Prepare speech to play
@@ -61,7 +61,7 @@ public:
private:
Scene *_scene;
- uint32 _tick;
+ int32 _tick;
char * _textData;
char * _textDataPos;
@@ -71,7 +71,7 @@ private:
void processSpeech();
// This function was cutoff since it doesn't make any sence using it. Its here for address information only
- /** .text:00414630 void playSpeech(uint32 textResIdx, uint32 fontResIdx); */
+ /** .text:00414630 void playSpeech(int32 textResIdx, int32 fontResIdx); */
}; // end of class Speech
diff --git a/engines/asylum/text.cpp b/engines/asylum/text.cpp
index aa13e38b5e..c6d4830aa6 100644
--- a/engines/asylum/text.cpp
+++ b/engines/asylum/text.cpp
@@ -43,7 +43,7 @@ Text::~Text() {
}
// loadFont at address 00435640
-void Text::loadFont(ResourcePack *resPack, uint32 resId) {
+void Text::loadFont(ResourcePack *resPack, int32 resId) {
if (_fontResource && resId == _fontResource->getEntryNum())
return;
@@ -57,16 +57,16 @@ void Text::loadFont(ResourcePack *resPack, uint32 resId) {
}
}
-void Text::setTextPos(uint32 x, uint32 y) {
+void Text::setTextPos(int32 x, int32 y) {
_posX = x;
_posY = y;
}
// getTextWidth at address 004357C0
-uint32 Text::getTextWidth(char *text) {
+int32 Text::getTextWidth(const char *text) {
assert(_fontResource);
- int width = 0;
+ int32 width = 0;
uint8 character = *text;
while (character) {
GraphicFrame *font = _fontResource->getFrame(character);
@@ -78,12 +78,12 @@ uint32 Text::getTextWidth(char *text) {
return width;
}
-uint32 Text::getResTextWidth(uint32 resId) {
+int32 Text::getResTextWidth(int32 resId) {
ResourceEntry *textRes = _textPack->getResource(resId);
return getTextWidth((char*)textRes->data);
}
-char* Text::getResText(uint32 resId) {
+char* Text::getResText(int32 resId) {
ResourceEntry *textRes = _textPack->getResource(resId);
return (char*)textRes->data;
}
@@ -96,25 +96,25 @@ void Text::drawChar(char character) {
_posX += fontLetter->surface.w + fontLetter->x - _curFontFlags;
}
-void Text::drawText(char *text) {
+void Text::drawText(const char *text) {
while (*text) {
drawChar(*text);
text++;
}
}
-void Text::drawResText(uint32 resId) {
+void Text::drawResText(int32 resId) {
ResourceEntry *textRes = _textPack->getResource(resId);
drawText((char*)textRes->data);
}
-void Text::drawTextCentered(uint32 x, uint32 y, uint32 width, char *text) {
- int textWidth = getTextWidth(text);
+void Text::drawTextCentered(int32 x, int32 y, int32 width, const char *text) {
+ int32 textWidth = getTextWidth(text);
setTextPos(x + (width - textWidth) / 2, y);
drawText(text);
}
-void Text::drawResTextWithValueCentered(uint32 x, uint32 y, uint32 width, uint32 resId, uint32 value) {
+void Text::drawResTextWithValueCentered(int32 x, int32 y, int32 width, int32 resId, int32 value) {
ResourceEntry *textRes = _textPack->getResource(resId);
char *text = (char *)textRes->data;
char txt[100];
@@ -122,31 +122,31 @@ void Text::drawResTextWithValueCentered(uint32 x, uint32 y, uint32 width, uint32
drawTextCentered(x, y, width, txt);
}
-void Text::drawResTextCentered(uint32 x, uint32 y, uint32 width, uint32 resId) {
+void Text::drawResTextCentered(int32 x, int32 y, int32 width, int32 resId) {
ResourceEntry *textRes = _textPack->getResource(resId);
drawTextCentered(x, y, width, (char *)textRes->data);
}
-void Text::drawText(uint32 x, uint32 y, char *text) {
+void Text::drawText(int32 x, int32 y, const char *text) {
if (text) {
- int textWidth = getTextWidth(text);
+ int32 textWidth = getTextWidth(text);
setTextPos(x - textWidth, y);
drawText(text);
}
}
-void Text::drawResText(uint32 x, uint32 y, uint32 resId) {
+void Text::drawResText(int32 x, int32 y, int32 resId) {
ResourceEntry *textRes = _textPack->getResource(resId);
drawText(x, y, (char *)textRes->data);
}
-void Text::drawTextAlignRight(uint32 x, uint32 y, char *text) {
- int textWidth = getTextWidth(text);
+void Text::drawTextAlignRight(int32 x, int32 y, const char *text) {
+ int32 textWidth = getTextWidth(text);
setTextPos(x - textWidth, y);
drawText(text);
}
-void Text::drawResTextAlignRight(uint32 x, uint32 y, uint32 resId) {
+void Text::drawResTextAlignRight(int32 x, int32 y, int32 resId) {
ResourceEntry *textRes = _textPack->getResource(resId);
drawTextAlignRight(x, y, (char *)textRes->data);
}
diff --git a/engines/asylum/text.h b/engines/asylum/text.h
index c1cc5bf071..ec4605b1c9 100644
--- a/engines/asylum/text.h
+++ b/engines/asylum/text.h
@@ -38,33 +38,33 @@ public:
Text(Screen *screen);
~Text();
- void loadFont(ResourcePack *resPack, uint32 resId);
+ void loadFont(ResourcePack *resPack, int32 resId);
- void setTextPos(uint32 x, uint32 y);
- uint32 getTextWidth(char *text);
- uint32 getResTextWidth(uint32 resId);
- char * getResText(uint32 resId);
+ void setTextPos(int32 x, int32 y);
+ int32 getTextWidth(const char *text);
+ int32 getResTextWidth(int32 resId);
+ char * getResText(int32 resId);
- void drawChar(char character);
- void drawText(char *text);
- void drawText(uint32 x, uint32 y, char *text);
- void drawResText(uint32 resId);
- void drawResText(uint32 x, uint32 y, uint32 resId);
+ void drawChar(const char character);
+ void drawText(const char *text);
+ void drawText(int32 x, int32 y, const char *text);
+ void drawResText(int32 resId);
+ void drawResText(int32 x, int32 y, int32 resId);
- void drawTextCentered(uint32 x, uint32 y, uint32 width, char *text);
- void drawResTextCentered(uint32 x, uint32 y, uint32 width, uint32 resId);
- void drawResTextWithValueCentered(uint32 x, uint32 y, uint32 width, uint32 resId, uint32 value);
+ void drawTextCentered(int32 x, int32 y, int32 width, const char *text);
+ void drawResTextCentered(int32 x, int32 y, int32 width, int32 resId);
+ void drawResTextWithValueCentered(int32 x, int32 y, int32 width, int32 resId, int32 value);
- void drawTextAlignRight(uint32 x, uint32 y, char *text);
- void drawResTextAlignRight(uint32 x, uint32 y, uint32 resId);
+ void drawTextAlignRight(int32 x, int32 y, const char *text);
+ void drawResTextAlignRight(int32 x, int32 y, int32 resId);
private:
Screen *_screen;
GraphicResource *_fontResource;
ResourcePack *_textPack;
- uint32 _posX;
- uint32 _posY;
+ int32 _posX;
+ int32 _posY;
uint8 _curFontFlags;
}; // end of class Text
diff --git a/engines/asylum/video.cpp b/engines/asylum/video.cpp
index 0a02d4a8b6..de7fad3d04 100644
--- a/engines/asylum/video.cpp
+++ b/engines/asylum/video.cpp
@@ -39,7 +39,7 @@ VideoPlayer::~VideoPlayer() {
delete _text;
}
-bool VideoPlayer::playVideoWithSubtitles(Common::List<Common::Event> &stopEvents, int videoNumber) {
+bool VideoPlayer::playVideoWithSubtitles(Common::List<Common::Event> &stopEvents, int32 videoNumber) {
// Read vids.cap
char movieToken[10];
sprintf(movieToken, "[MOV%03d]", videoNumber);
@@ -59,7 +59,7 @@ bool VideoPlayer::playVideoWithSubtitles(Common::List<Common::Event> &stopEvents
// -1 means that the video has no subtitles, -2 that it doesn't exist
// The negative values aren't used in the code, they just make the table easier to
// understand.
- int textRes[49] = { -1, 1088, 1279, 1122, 1286, 1132, 1133, 1134, 1135, 1136, // 0 - 9
+ int32 textRes[49] = { -1, 1088, 1279, 1122, 1286, 1132, 1133, 1134, 1135, 1136, // 0 - 9
-1, -2, 1140, 1141, -2, -1, 1142, -1, -2, 1155, // 10 - 19
1157, 1159, 1162, 1164, -2, 1171, 1177, 1184, 1190, 1201, // 20 - 29
-2, -2, -2, 1207, 1213, 1217, 1223, 1227, -2, 1228, // 30 - 39
@@ -69,7 +69,7 @@ bool VideoPlayer::playVideoWithSubtitles(Common::List<Common::Event> &stopEvents
if (start) {
start += 20; // skip token, newline and "CAPTION = "
- int count = strcspn(start, "\r\n");
+ int32 count = strcspn(start, "\r\n");
line = new char[count + 1];
strncpy(line, start, count);
@@ -98,7 +98,7 @@ bool VideoPlayer::playVideoWithSubtitles(Common::List<Common::Event> &stopEvents
}
void VideoPlayer::performPostProcessing(byte *screen) {
- int curFrame = _decoder->getCurFrame();
+ int32 curFrame = _decoder->getCurFrame();
// Reset subtitle area, by filling it with zeroes
memset(screen + 640 * 400, 0, 640 * 80);
@@ -130,7 +130,7 @@ Video::~Video() {
delete _smkDecoder;
}
-bool Video::playVideo(int number, VideoSubtitles subtitles) {
+bool Video::playVideo(int32 number, VideoSubtitles subtitles) {
bool lastMouseState = false;
char filename[20];
@@ -163,7 +163,7 @@ VideoText::~VideoText() {
delete _fontResource;
}
-void VideoText::loadFont(ResourcePack *resPack, uint32 resId) {
+void VideoText::loadFont(ResourcePack *resPack, int32 resId) {
delete _fontResource;
_fontResource = new GraphicResource(resPack, resId);
@@ -174,15 +174,15 @@ void VideoText::loadFont(ResourcePack *resPack, uint32 resId) {
}
}
-void VideoText::drawMovieSubtitle(byte *screenBuffer, uint32 resId) {
+void VideoText::drawMovieSubtitle(byte *screenBuffer, int32 resId) {
Common::String textLine[4];
Common::String tmpLine;
- int curLine = 0;
+ int32 curLine = 0;
ResourceEntry *textRes = _textPack->getResource(resId);
char *text = strdup((const char *)textRes->data); // for strtok
char *tok = strtok(text, " ");
- int startY = 420; // starting y for up to 2 subtitles
- int spacing = 30; // spacing for up to 2 subtitles
+ int32 startY = 420; // starting y for up to 2 subtitles
+ int32 spacing = 30; // spacing for up to 2 subtitles
// Videos can have up to 4 lines of text
while (tok) {
@@ -204,18 +204,18 @@ void VideoText::drawMovieSubtitle(byte *screenBuffer, uint32 resId) {
tok = strtok(NULL, " ");
}
- for (int i = 0; i < curLine + 1; i++) {
- int textWidth = getTextWidth(textLine[i].c_str());
+ for (int32 i = 0; i < curLine + 1; i++) {
+ int32 textWidth = getTextWidth(textLine[i].c_str());
drawText(screenBuffer, 0 + (640 - textWidth) / 2, startY + i * spacing, textLine[i].c_str());
}
free(text);
}
-uint32 VideoText::getTextWidth(const char *text) {
+int32 VideoText::getTextWidth(const char *text) {
assert(_fontResource);
- int width = 0;
+ int32 width = 0;
uint8 character = *text;
const char *curChar = text;
while (character) {
@@ -228,10 +228,10 @@ uint32 VideoText::getTextWidth(const char *text) {
return width;
}
-void VideoText::drawText(byte *screenBuffer, int x, int y, const char *text) {
+void VideoText::drawText(byte *screenBuffer, int16 x, int16 y, const char *text) {
assert(_fontResource);
const byte *curChar = (byte *)text;
- int curX = x;
+ int16 curX = x;
while (*curChar) {
GraphicFrame *fontLetter = _fontResource->getFrame(*curChar);
@@ -241,10 +241,10 @@ void VideoText::drawText(byte *screenBuffer, int x, int y, const char *text) {
}
}
-void VideoText::copyToVideoFrame(byte *screenBuffer, GraphicFrame *frame, int x, int y) {
- int h = frame->surface.h;
- int w = frame->surface.w;
- int screenBufferPitch = 640;
+void VideoText::copyToVideoFrame(byte *screenBuffer, GraphicFrame *frame, int32 x, int32 y) {
+ uint16 h = frame->surface.h;
+ uint16 w = frame->surface.w;
+ int32 screenBufferPitch = 640;
byte *buffer = (byte *)frame->surface.pixels;
byte *dest = screenBuffer + y * screenBufferPitch + x;
diff --git a/engines/asylum/video.h b/engines/asylum/video.h
index 44ca0123c5..4ecc0db33a 100644
--- a/engines/asylum/video.h
+++ b/engines/asylum/video.h
@@ -89,13 +89,13 @@ public:
VideoText();
~VideoText();
- void loadFont(ResourcePack *resPack, uint32 resId);
- void drawMovieSubtitle(byte *screenBuffer, uint32 resId);
+ void loadFont(ResourcePack *resPack, int32 resId);
+ void drawMovieSubtitle(byte *screenBuffer, int32 resId);
private:
- uint32 getTextWidth(const char *text);
+ int32 getTextWidth(const char *text);
- void drawText(byte *screenBuffer, int x, int y, const char *text);
+ void drawText(byte *screenBuffer, int16 x, int16 y, const char *text);
void copyToVideoFrame(byte *screenBuffer, GraphicFrame *frame, int x, int y);
GraphicResource *_fontResource;
diff --git a/engines/asylum/worldstats.cpp b/engines/asylum/worldstats.cpp
index 82514f7577..741086b5d0 100644
--- a/engines/asylum/worldstats.cpp
+++ b/engines/asylum/worldstats.cpp
@@ -38,8 +38,8 @@ WorldStats::~WorldStats() {
actions.clear();
}
-int WorldStats::getActionAreaIndexById(uint32 id) {
- for (uint32 i = 0; i < numActions; i++) {
+int32 WorldStats::getActionAreaIndexById(int32 id) {
+ for (int32 i = 0; i < numActions; i++) {
if (actions[i].id == id)
return i;
}
@@ -47,12 +47,12 @@ int WorldStats::getActionAreaIndexById(uint32 id) {
return -1;
}
-ActionArea* WorldStats::getActionAreaById(uint32 id) {
+ActionArea* WorldStats::getActionAreaById(int32 id) {
return &actions[getActionAreaIndexById(id)];
}
-int WorldStats::getBarrierIndexById(uint32 id) {
- for (uint32 i = 0; i < numBarriers; i++) {
+int32 WorldStats::getBarrierIndexById(int32 id) {
+ for (int32 i = 0; i < numBarriers; i++) {
if (barriers[i].id == id)
return i;
}
@@ -60,15 +60,15 @@ int WorldStats::getBarrierIndexById(uint32 id) {
return -1;
}
-Barrier* WorldStats::getBarrierById(uint32 id) {
+Barrier* WorldStats::getBarrierById(int32 id) {
return &barriers[getBarrierIndexById(id)];
}
-Barrier* WorldStats::getBarrierByIndex(uint32 idx) {
+Barrier* WorldStats::getBarrierByIndex(int32 idx) {
return &barriers[idx];
}
-bool WorldStats::isBarrierOnScreen(uint32 idx) {
+bool WorldStats::isBarrierOnScreen(int32 idx) {
Barrier *b = getBarrierByIndex(idx);
Common::Rect screenRect = Common::Rect(xLeft, yTop, xLeft + 640, yTop + 480);
@@ -77,13 +77,13 @@ bool WorldStats::isBarrierOnScreen(uint32 idx) {
return isBarrierVisible(idx) && (b->flags & 1) && screenRect.intersects(barrierRect);
}
-bool WorldStats::isBarrierVisible(uint32 idx) {
+bool WorldStats::isBarrierVisible(int32 idx) {
Barrier *b = getBarrierByIndex(idx);
if ((b->flags & 0xFF) & 1) {
- for (int f = 0; f < 10; f++) {
+ for (int32 f = 0; f < 10; f++) {
bool isSet = false;
- uint32 flag = b->gameFlags[f];
+ int32 flag = b->gameFlags[f];
if (flag <= 0)
isSet = _scene->vm()->isGameFlagNotSet(flag); // -flag
@@ -98,12 +98,12 @@ bool WorldStats::isBarrierVisible(uint32 idx) {
return false;
}
-bool WorldStats::checkBarrierFlagsCondition(uint32 idx) {
+bool WorldStats::checkBarrierFlagsCondition(int32 idx) {
Barrier *b = getBarrierByIndex(idx);
bool result;
if (LOBYTE(b->flags) & 1) {
- for (int i = 0; i < 10; i++) {
+ for (int32 i = 0; i < 10; i++) {
result = _scene->vm()->isGameFlagSet(b->gameFlags[i]);
if (result)
return result;
@@ -118,177 +118,177 @@ bool WorldStats::checkBarrierFlagsCondition(uint32 idx) {
// FIXME: load necessary World Stats content
void WorldStats::load(Common::SeekableReadStream *stream) {
- size = stream->readUint32LE();
- numEntries = stream->readUint32LE();
+ size = stream->readSint32LE();
+ numEntries = stream->readSint32LE();
numChapter = stream->readSint32LE();
- xLeft = stream->readUint32LE();
- yTop = stream->readUint32LE();
+ xLeft = stream->readSint32LE();
+ yTop = stream->readSint32LE();
- boundingRect.left = stream->readUint32LE() & 0xFFFF;
- boundingRect.top = stream->readUint32LE() & 0xFFFF;
- boundingRect.right = stream->readUint32LE() & 0xFFFF;
- boundingRect.bottom = stream->readUint32LE() & 0xFFFF;
+ boundingRect.left = stream->readSint32LE() & 0xFFFF;
+ boundingRect.top = stream->readSint32LE() & 0xFFFF;
+ boundingRect.right = stream->readSint32LE() & 0xFFFF;
+ boundingRect.bottom = stream->readSint32LE() & 0xFFFF;
// read common graphic resources
- commonRes.backgroundImage = stream->readUint32LE();
- commonRes.curScrollUp = stream->readUint32LE();
- commonRes.curScrollUpLeft = stream->readUint32LE();
- commonRes.curScrollLeft = stream->readUint32LE();
- commonRes.curScrollDownLeft = stream->readUint32LE();
- commonRes.curScrollDown = stream->readUint32LE();
- commonRes.curScrollDownRight = stream->readUint32LE();
- commonRes.curScrollRight = stream->readUint32LE();
- commonRes.curScrollUpRight = stream->readUint32LE();
- commonRes.curHand = stream->readUint32LE();
- commonRes.curMagnifyingGlass = stream->readUint32LE();
- commonRes.curTalkNCP = stream->readUint32LE();
- commonRes.curGrabPointer = stream->readUint32LE();
- commonRes.curTalkNCP2 = stream->readUint32LE();
- commonRes.font1 = stream->readUint32LE();
- commonRes.font2 = stream->readUint32LE();
- commonRes.font3 = stream->readUint32LE();
- commonRes.palette = stream->readUint32LE();
- commonRes.cellShadeMask1 = stream->readUint32LE();
- commonRes.cellShadeMask2 = stream->readUint32LE();
- commonRes.cellShadeMask3 = stream->readUint32LE();
- commonRes.unused = stream->readUint32LE();
- commonRes.smallCurUp = stream->readUint32LE();
- commonRes.smallCurDown = stream->readUint32LE();
- commonRes.encounterFrameBg = stream->readUint32LE();
-
- width = stream->readUint32LE();
- height = stream->readUint32LE();
- motionStatus = stream->readUint32LE();
- field_8C = stream->readUint32LE();
- numActions = stream->readUint32LE();
- numBarriers = stream->readUint32LE();
- targetX = stream->readUint32LE();
- targetY = stream->readUint32LE();
- field_A0 = stream->readUint32LE();
- field_A4 = stream->readUint32LE();
- field_A8 = stream->readUint32LE();
- field_AC = stream->readUint32LE();
- field_B0 = stream->readUint32LE();
- numActors = stream->readUint32LE();
-
- stereoReversedFlag = stream->readUint32LE();
-
- for (int r = 0; r < 6; r++) {
- sceneRects[r].left = stream->readUint32LE() & 0xFFFF;
- sceneRects[r].top = stream->readUint32LE() & 0xFFFF;
- sceneRects[r].right = stream->readUint32LE() & 0xFFFF;
- sceneRects[r].bottom = stream->readUint32LE() & 0xFFFF;
+ commonRes.backgroundImage = stream->readSint32LE();
+ commonRes.curScrollUp = stream->readSint32LE();
+ commonRes.curScrollUpLeft = stream->readSint32LE();
+ commonRes.curScrollLeft = stream->readSint32LE();
+ commonRes.curScrollDownLeft = stream->readSint32LE();
+ commonRes.curScrollDown = stream->readSint32LE();
+ commonRes.curScrollDownRight = stream->readSint32LE();
+ commonRes.curScrollRight = stream->readSint32LE();
+ commonRes.curScrollUpRight = stream->readSint32LE();
+ commonRes.curHand = stream->readSint32LE();
+ commonRes.curMagnifyingGlass = stream->readSint32LE();
+ commonRes.curTalkNCP = stream->readSint32LE();
+ commonRes.curGrabPointer = stream->readSint32LE();
+ commonRes.curTalkNCP2 = stream->readSint32LE();
+ commonRes.font1 = stream->readSint32LE();
+ commonRes.font2 = stream->readSint32LE();
+ commonRes.font3 = stream->readSint32LE();
+ commonRes.palette = stream->readSint32LE();
+ commonRes.cellShadeMask1 = stream->readSint32LE();
+ commonRes.cellShadeMask2 = stream->readSint32LE();
+ commonRes.cellShadeMask3 = stream->readSint32LE();
+ commonRes.unused = stream->readSint32LE();
+ commonRes.smallCurUp = stream->readSint32LE();
+ commonRes.smallCurDown = stream->readSint32LE();
+ commonRes.encounterFrameBg = stream->readSint32LE();
+
+ width = stream->readSint32LE();
+ height = stream->readSint32LE();
+ motionStatus = stream->readSint32LE();
+ field_8C = stream->readSint32LE();
+ numActions = stream->readSint32LE();
+ numBarriers = stream->readSint32LE();
+ targetX = stream->readSint32LE();
+ targetY = stream->readSint32LE();
+ field_A0 = stream->readSint32LE();
+ field_A4 = stream->readSint32LE();
+ field_A8 = stream->readSint32LE();
+ field_AC = stream->readSint32LE();
+ field_B0 = stream->readSint32LE();
+ numActors = stream->readSint32LE();
+
+ stereoReversedFlag = stream->readSint32LE();
+
+ for (int32 r = 0; r < 6; r++) {
+ sceneRects[r].left = stream->readSint32LE() & 0xFFFF;
+ sceneRects[r].top = stream->readSint32LE() & 0xFFFF;
+ sceneRects[r].right = stream->readSint32LE() & 0xFFFF;
+ sceneRects[r].bottom = stream->readSint32LE() & 0xFFFF;
}
sceneRectIdx = stream->readByte();
field_11D[0] = stream->readByte();
field_11D[1] = stream->readByte();
field_11D[2] = stream->readByte();
- field_120 = stream->readUint32LE();
- actionListIdx = stream->readUint32LE();
+ field_120 = stream->readSint32LE();
+ actionListIdx = stream->readSint32LE();
- for (int gr = 0; gr < 100; gr++)
- grResId[gr] = stream->readUint32LE();
+ for (int32 gr = 0; gr < 100; gr++)
+ grResId[gr] = stream->readSint32LE();
- sceneTitleGrResId = stream->readUint32LE();
- sceneTitlePalResId = stream->readUint32LE();
- actorType = stream->readUint32LE();
+ sceneTitleGrResId = stream->readSint32LE();
+ sceneTitlePalResId = stream->readSint32LE();
+ actorType = stream->readSint32LE();
- for (int s = 0; s < 50; s++)
- soundResId[s] = stream->readUint32LE();
+ for (int32 s = 0; s < 50; s++)
+ soundResId[s] = stream->readSint32LE();
- for (int s = 0; s < 15; s++) {
- ambientSounds[s].field_0 = stream->readUint32LE();
- ambientSounds[s].flags = stream->readUint32LE();
- ambientSounds[s].resId = stream->readUint32LE();
- ambientSounds[s].field_C = stream->readUint32LE();
- ambientSounds[s].field_10 = stream->readUint32LE();
- ambientSounds[s].field_14 = stream->readUint32LE();
+ for (int32 s = 0; s < 15; s++) {
+ ambientSounds[s].field_0 = stream->readSint32LE();
+ ambientSounds[s].flags = stream->readSint32LE();
+ ambientSounds[s].resId = stream->readSint32LE();
+ ambientSounds[s].field_C = stream->readSint32LE();
+ ambientSounds[s].field_10 = stream->readSint32LE();
+ ambientSounds[s].field_14 = stream->readSint32LE();
- for (int i = 0; i < 6; i++)
- ambientSounds[s].flagNum[i] = stream->readUint32LE();
+ for (int32 i = 0; i < 6; i++)
+ ambientSounds[s].flagNum[i] = stream->readSint32LE();
- ambientSounds[s].x = stream->readUint32LE();
- ambientSounds[s].y = stream->readUint32LE();
+ ambientSounds[s].x = stream->readSint32LE();
+ ambientSounds[s].y = stream->readSint32LE();
}
- numAmbientSound = stream->readUint32LE();
- musicStatus = stream->readUint32LE();
+ numAmbientSound = stream->readSint32LE();
+ musicStatus = stream->readSint32LE();
musicCurrentResId = stream->readSint32LE();
- musicFlag = stream->readUint32LE();
+ musicFlag = stream->readSint32LE();
musicResId = stream->readSint32LE();
- musicStatusExt = stream->readUint32LE();
+ musicStatusExt = stream->readSint32LE();
- for (uint32 a = 0; a < numBarriers; a++) {
- int i;
+ for (int32 a = 0; a < numBarriers; a++) {
+ int32 i;
Barrier barrier;
- barrier.id = stream->readUint32LE();
- barrier.resId = stream->readUint32LE();
- barrier.x = stream->readUint32LE();
- barrier.y = stream->readUint32LE();
-
- barrier.boundingRect.left = stream->readUint32LE() & 0xFFFF;
- barrier.boundingRect.top = stream->readUint32LE() & 0xFFFF;
- barrier.boundingRect.right = stream->readUint32LE() & 0xFFFF;
- barrier.boundingRect.bottom = stream->readUint32LE() & 0xFFFF;
-
- barrier.field_20 = stream->readUint32LE();
- barrier.frameIdx = stream->readUint32LE();
- barrier.frameCount = stream->readUint32LE();
- barrier.field_2C = stream->readUint32LE();
- barrier.field_30 = stream->readUint32LE();
- barrier.field_34 = stream->readUint32LE();
- barrier.flags = stream->readUint32LE();
- barrier.field_3C = stream->readUint32LE();
+ barrier.id = stream->readSint32LE();
+ barrier.resId = stream->readSint32LE();
+ barrier.x = stream->readSint32LE();
+ barrier.y = stream->readSint32LE();
+
+ barrier.boundingRect.left = stream->readSint32LE() & 0xFFFF;
+ barrier.boundingRect.top = stream->readSint32LE() & 0xFFFF;
+ barrier.boundingRect.right = stream->readSint32LE() & 0xFFFF;
+ barrier.boundingRect.bottom = stream->readSint32LE() & 0xFFFF;
+
+ barrier.field_20 = stream->readSint32LE();
+ barrier.frameIdx = stream->readSint32LE();
+ barrier.frameCount = stream->readSint32LE();
+ barrier.field_2C = stream->readSint32LE();
+ barrier.field_30 = stream->readSint32LE();
+ barrier.field_34 = stream->readSint32LE();
+ barrier.flags = stream->readSint32LE();
+ barrier.field_3C = stream->readSint32LE();
stream->read(barrier.name, sizeof(barrier.name));
- barrier.field_74 = stream->readUint32LE();
- barrier.field_78 = stream->readUint32LE();
- barrier.field_7C = stream->readUint32LE();
- barrier.field_80 = stream->readUint32LE();
- barrier.polyIdx = stream->readUint32LE();
- barrier.flags2 = stream->readUint32LE();
+ barrier.field_74 = stream->readSint32LE();
+ barrier.field_78 = stream->readSint32LE();
+ barrier.field_7C = stream->readSint32LE();
+ barrier.field_80 = stream->readSint32LE();
+ barrier.polyIdx = stream->readSint32LE();
+ barrier.flags2 = stream->readSint32LE();
for (i = 0; i < 10; i++)
- barrier.gameFlags[i] = stream->readUint32LE();
+ barrier.gameFlags[i] = stream->readSint32LE();
- barrier.field_B4 = stream->readUint32LE();
- barrier.tickCount = stream->readUint32LE();
- barrier.tickCount2 = stream->readUint32LE();
- barrier.field_C0 = stream->readUint32LE();
- barrier.priority = stream->readUint32LE();
- barrier.actionListIdx = stream->readUint32LE();
+ barrier.field_B4 = stream->readSint32LE();
+ barrier.tickCount = stream->readSint32LE();
+ barrier.tickCount2 = stream->readSint32LE();
+ barrier.field_C0 = stream->readSint32LE();
+ barrier.priority = stream->readSint32LE();
+ barrier.actionListIdx = stream->readSint32LE();
for (i = 0; i < 16; i++) {
- barrier.soundItems[i].resId = stream->readUint32LE();
- barrier.soundItems[i].field_4 = stream->readUint32LE();
- barrier.soundItems[i].field_8 = stream->readUint32LE();
- barrier.soundItems[i].field_C = stream->readUint32LE();
+ barrier.soundItems[i].resId = stream->readSint32LE();
+ barrier.soundItems[i].field_4 = stream->readSint32LE();
+ barrier.soundItems[i].field_8 = stream->readSint32LE();
+ barrier.soundItems[i].field_C = stream->readSint32LE();
}
for (i = 0; i < 50; i++) {
- barrier.frameSoundItems[i].resId = stream->readUint32LE();
- barrier.frameSoundItems[i].frameIdx = stream->readUint32LE();
- barrier.frameSoundItems[i].index = stream->readUint32LE();
- barrier.frameSoundItems[i].field_C = stream->readUint32LE();
- barrier.frameSoundItems[i].field_10 = stream->readUint32LE();
- barrier.frameSoundItems[i].field_14 = stream->readUint32LE();
+ barrier.frameSoundItems[i].resId = stream->readSint32LE();
+ barrier.frameSoundItems[i].frameIdx = stream->readSint32LE();
+ barrier.frameSoundItems[i].index = stream->readSint32LE();
+ barrier.frameSoundItems[i].field_C = stream->readSint32LE();
+ barrier.frameSoundItems[i].field_10 = stream->readSint32LE();
+ barrier.frameSoundItems[i].field_14 = stream->readSint32LE();
}
- barrier.field_67C = stream->readUint32LE();
- barrier.soundX = stream->readUint32LE();
- barrier.soundY = stream->readUint32LE();
- barrier.field_688 = stream->readUint32LE();
+ barrier.field_67C = stream->readSint32LE();
+ barrier.soundX = stream->readSint32LE();
+ barrier.soundY = stream->readSint32LE();
+ barrier.field_688 = stream->readSint32LE();
for (i = 0; i < 5; i++)
- barrier.field_68C[i] = stream->readUint32LE();
+ barrier.field_68C[i] = stream->readSint32LE();
- barrier.soundResId = stream->readUint32LE();
- barrier.field_6A4 = stream->readUint32LE();
+ barrier.soundResId = stream->readSint32LE();
+ barrier.field_6A4 = stream->readSint32LE();
barriers.push_back(barrier);
}
@@ -296,91 +296,91 @@ void WorldStats::load(Common::SeekableReadStream *stream) {
// need to jump all unused barriers data to where actors data start
stream->seek(0xA6D7A);
- for (uint32 a = 0; a < numActors; a++) {
- int i;
+ for (int32 a = 0; a < numActors; a++) {
+ int32 i;
Actor actor;
actor.x = stream->readSint32LE();
actor.y = stream->readSint32LE();
- actor.grResId = stream->readUint32LE();
- actor.field_C = stream->readUint32LE();
- actor.frameNum = stream->readUint32LE();
- actor.frameCount = stream->readUint32LE();
+ actor.grResId = stream->readSint32LE();
+ actor.field_C = stream->readSint32LE();
+ actor.frameNum = stream->readSint32LE();
+ actor.frameCount = stream->readSint32LE();
actor.x1 = stream->readSint32LE();
actor.y1 = stream->readSint32LE();
actor.x2 = stream->readSint32LE();
actor.y2 = stream->readSint32LE();
- actor.boundingRect.left = stream->readUint32LE() & 0xFFFF;
- actor.boundingRect.top = stream->readUint32LE() & 0xFFFF;
- actor.boundingRect.right = stream->readUint32LE() & 0xFFFF;
- actor.boundingRect.bottom = stream->readUint32LE() & 0xFFFF;
-
- actor.direction = stream->readUint32LE();
- actor.field_3C = stream->readUint32LE();
- actor.updateType = stream->readUint32LE();
- actor.field_44 = stream->readUint32LE();
- actor.priority = stream->readUint32LE();
- actor.flags = stream->readUint32LE();
- actor.field_50 = stream->readUint32LE();
- actor.field_54 = stream->readUint32LE();
- actor.field_58 = stream->readUint32LE();
- actor.field_5C = stream->readUint32LE();
- actor.field_60 = stream->readUint32LE();
- actor.actionIdx3 = stream->readUint32LE();
+ actor.boundingRect.left = stream->readSint32LE() & 0xFFFF;
+ actor.boundingRect.top = stream->readSint32LE() & 0xFFFF;
+ actor.boundingRect.right = stream->readSint32LE() & 0xFFFF;
+ actor.boundingRect.bottom = stream->readSint32LE() & 0xFFFF;
+
+ actor.direction = stream->readSint32LE();
+ actor.field_3C = stream->readSint32LE();
+ actor.updateType = stream->readSint32LE();
+ actor.field_44 = stream->readSint32LE();
+ actor.priority = stream->readSint32LE();
+ actor.flags = stream->readSint32LE();
+ actor.field_50 = stream->readSint32LE();
+ actor.field_54 = stream->readSint32LE();
+ actor.field_58 = stream->readSint32LE();
+ actor.field_5C = stream->readSint32LE();
+ actor.field_60 = stream->readSint32LE();
+ actor.actionIdx3 = stream->readSint32LE();
// TODO skip field_68 till field_617
stream->skip(0x5B0);
for (i = 0; i < 8; i++)
- actor.reaction[i] = stream->readUint32LE();
+ actor.reaction[i] = stream->readSint32LE();
- actor.field_638 = stream->readUint32LE();
- actor.walkingSound1 = stream->readUint32LE();
- actor.walkingSound2 = stream->readUint32LE();
- actor.walkingSound3 = stream->readUint32LE();
- actor.walkingSound4 = stream->readUint32LE();
- actor.field_64C = stream->readUint32LE();
- actor.field_650 = stream->readUint32LE();
+ actor.field_638 = stream->readSint32LE();
+ actor.walkingSound1 = stream->readSint32LE();
+ actor.walkingSound2 = stream->readSint32LE();
+ actor.walkingSound3 = stream->readSint32LE();
+ actor.walkingSound4 = stream->readSint32LE();
+ actor.field_64C = stream->readSint32LE();
+ actor.field_650 = stream->readSint32LE();
for (i = 0; i < 55; i++)
- actor.grResTable[i] = stream->readUint32LE();
+ actor.grResTable[i] = stream->readSint32LE();
stream->read(actor.name, sizeof(actor.name));
for (i = 0; i < 20; i++)
- actor.field_830[i] = stream->readUint32LE();
+ actor.field_830[i] = stream->readSint32LE();
for (i = 0; i < 20; i++)
- actor.field_880[i] = stream->readUint32LE();
+ actor.field_880[i] = stream->readSint32LE();
for (i = 0; i < 20; i++)
- actor.field_8D0[i] = stream->readUint32LE();
-
- actor.actionIdx2 = stream->readUint32LE();
- actor.field_924 = stream->readUint32LE();
- actor.tickValue1 = stream->readUint32LE();
- actor.field_92C = stream->readUint32LE();
- actor.flags2 = stream->readUint32LE();
- actor.field_934 = stream->readUint32LE();
- actor.field_938 = stream->readUint32LE();
- actor.soundResId = stream->readUint32LE();
- actor.field_940 = stream->readUint32LE();
- actor.field_944 = stream->readUint32LE();
- actor.field_948 = stream->readUint32LE();
- actor.field_94C = stream->readUint32LE();
- actor.field_950 = stream->readUint32LE();
- actor.field_954 = stream->readUint32LE();
- actor.field_958 = stream->readUint32LE();
- actor.field_95C = stream->readUint32LE();
- actor.field_960 = stream->readUint32LE();
- actor.field_964 = stream->readUint32LE();
- actor.field_968 = stream->readUint32LE();
- actor.field_96C = stream->readUint32LE();
- actor.field_970 = stream->readUint32LE();
- actor.field_974 = stream->readUint32LE();
- actor.field_978 = stream->readUint32LE();
- actor.actionIdx1 = stream->readUint32LE();
+ actor.field_8D0[i] = stream->readSint32LE();
+
+ actor.actionIdx2 = stream->readSint32LE();
+ actor.field_924 = stream->readSint32LE();
+ actor.tickValue1 = stream->readSint32LE();
+ actor.field_92C = stream->readSint32LE();
+ actor.flags2 = stream->readSint32LE();
+ actor.field_934 = stream->readSint32LE();
+ actor.field_938 = stream->readSint32LE();
+ actor.soundResId = stream->readSint32LE();
+ actor.field_940 = stream->readSint32LE();
+ actor.field_944 = stream->readSint32LE();
+ actor.field_948 = stream->readSint32LE();
+ actor.field_94C = stream->readSint32LE();
+ actor.field_950 = stream->readSint32LE();
+ actor.field_954 = stream->readSint32LE();
+ actor.field_958 = stream->readSint32LE();
+ actor.field_95C = stream->readSint32LE();
+ actor.field_960 = stream->readSint32LE();
+ actor.field_964 = stream->readSint32LE();
+ actor.field_968 = stream->readSint32LE();
+ actor.field_96C = stream->readSint32LE();
+ actor.field_970 = stream->readSint32LE();
+ actor.field_974 = stream->readSint32LE();
+ actor.field_978 = stream->readSint32LE();
+ actor.actionIdx1 = stream->readSint32LE();
// TODO skip field_980 till field_9A0
stream->skip(0x24);
@@ -402,36 +402,36 @@ void WorldStats::load(Common::SeekableReadStream *stream) {
stream->seek(0xD6B5A); // where action items start
// FIXME Figure out all the actions items
- for (uint32 a = 0; a < numActions; a++) {
+ for (int32 a = 0; a < numActions; a++) {
ActionArea action;
memset(&action, 0, sizeof(ActionArea));
stream->read(action.name, 52);
- action.id = stream->readUint32LE();
- action.field01 = stream->readUint32LE();
- action.field02 = stream->readUint32LE();
- action.field_40 = stream->readUint32LE();
- action.field_44 = stream->readUint32LE();
- action.flags = stream->readUint32LE();
- action.actionListIdx1 = stream->readUint32LE();
- action.actionListIdx2 = stream->readUint32LE();
- action.actionType = stream->readUint32LE();
-
- for (int aa1 = 0; aa1 < 10; aa1++)
- action.flagNums[aa1] = stream->readUint32LE();
-
- action.field_7C = stream->readUint32LE();
- action.polyIdx = stream->readUint32LE();
- action.field_84 = stream->readUint32LE();
- action.field_88 = stream->readUint32LE();
- action.soundResId = stream->readUint32LE();
- action.field_90 = stream->readUint32LE();
- action.paletteValue = stream->readUint32LE();
-
- for (int aa2 = 0; aa2 < 5; aa2++)
- action.array[aa2] = stream->readUint32LE();
-
- action.volume = stream->readUint32LE();
+ action.id = stream->readSint32LE();
+ action.field01 = stream->readSint32LE();
+ action.field02 = stream->readSint32LE();
+ action.field_40 = stream->readSint32LE();
+ action.field_44 = stream->readSint32LE();
+ action.flags = stream->readSint32LE();
+ action.actionListIdx1 = stream->readSint32LE();
+ action.actionListIdx2 = stream->readSint32LE();
+ action.actionType = stream->readSint32LE();
+
+ for (int32 aa1 = 0; aa1 < 10; aa1++)
+ action.flagNums[aa1] = stream->readSint32LE();
+
+ action.field_7C = stream->readSint32LE();
+ action.polyIdx = stream->readSint32LE();
+ action.field_84 = stream->readSint32LE();
+ action.field_88 = stream->readSint32LE();
+ action.soundResId = stream->readSint32LE();
+ action.field_90 = stream->readSint32LE();
+ action.paletteValue = stream->readSint32LE();
+
+ for (int32 aa2 = 0; aa2 < 5; aa2++)
+ action.array[aa2] = stream->readSint32LE();
+
+ action.volume = stream->readSint32LE();
actions.push_back(action);
}
diff --git a/engines/asylum/worldstats.h b/engines/asylum/worldstats.h
index fd640119d9..1c9505b35b 100644
--- a/engines/asylum/worldstats.h
+++ b/engines/asylum/worldstats.h
@@ -37,55 +37,55 @@
namespace Asylum {
typedef struct CommonResources {
- uint32 backgroundImage;
- uint32 curScrollUp;
- uint32 curScrollUpLeft;
- uint32 curScrollLeft;
- uint32 curScrollDownLeft;
- uint32 curScrollDown;
- uint32 curScrollDownRight;
- uint32 curScrollRight;
- uint32 curScrollUpRight;
- uint32 curHand;
- uint32 curMagnifyingGlass;
- uint32 curTalkNCP;
- uint32 curGrabPointer;
- uint32 curTalkNCP2;
- uint32 font1;
- uint32 font2;
- uint32 font3;
- uint32 palette;
- uint32 cellShadeMask1;
- uint32 cellShadeMask2;
- uint32 cellShadeMask3;
- uint32 unused;
- uint32 smallCurUp;
- uint32 smallCurDown;
- uint32 encounterFrameBg;
+ int32 backgroundImage;
+ int32 curScrollUp;
+ int32 curScrollUpLeft;
+ int32 curScrollLeft;
+ int32 curScrollDownLeft;
+ int32 curScrollDown;
+ int32 curScrollDownRight;
+ int32 curScrollRight;
+ int32 curScrollUpRight;
+ int32 curHand;
+ int32 curMagnifyingGlass;
+ int32 curTalkNCP;
+ int32 curGrabPointer;
+ int32 curTalkNCP2;
+ int32 font1;
+ int32 font2;
+ int32 font3;
+ int32 palette;
+ int32 cellShadeMask1;
+ int32 cellShadeMask2;
+ int32 cellShadeMask3;
+ int32 unused;
+ int32 smallCurUp;
+ int32 smallCurDown;
+ int32 encounterFrameBg;
} CommonResources;
typedef struct ActionArea {
char name[52];
- uint32 id;
- uint32 field01;
- uint32 field02;
- uint32 field_40;
- uint32 field_44;
- uint32 flags;
- uint32 actionListIdx1;
- uint32 actionListIdx2;
- uint32 actionType; // aka flags2: 0-none, 1-findwhat, 2-talk, 3-findwhat??, 4-grab
- uint32 flagNums[10];
- uint32 field_7C;
- uint32 polyIdx;
- uint32 field_84;
- uint32 field_88;
- uint32 soundResId;
- uint32 field_90;
- uint32 paletteValue;
- uint32 array[5];
- uint32 volume;
+ int32 id;
+ int32 field01;
+ int32 field02;
+ int32 field_40;
+ int32 field_44;
+ int32 flags;
+ int32 actionListIdx1;
+ int32 actionListIdx2;
+ int32 actionType; // aka flags2: 0-none, 1-findwhat, 2-talk, 3-findwhat??, 4-grab
+ int32 flagNums[10];
+ int32 field_7C;
+ int32 polyIdx;
+ int32 field_84;
+ int32 field_88;
+ int32 soundResId;
+ int32 field_90;
+ int32 paletteValue;
+ int32 array[5];
+ int32 volume;
} ActionArea;
@@ -94,45 +94,45 @@ public:
WorldStats(Common::SeekableReadStream *stream, Scene *scene);
virtual ~WorldStats();
- uint32 size;
- uint32 numEntries;
- int numChapter;
- uint32 xLeft; // scene start x position
- uint32 yTop; // scene start y position
+ int32 size;
+ int32 numEntries;
+ int32 numChapter;
+ int32 xLeft; // scene start x position
+ int32 yTop; // scene start y position
Common::Rect boundingRect;
CommonResources commonRes; // field_1C till field_7C
- uint32 width; // field_80
- uint32 height;
- uint32 motionStatus;
- uint32 field_8C;
- uint32 numActions; // field_90
- uint32 numBarriers;
- int targetX;
- int targetY;
- uint32 field_A0;
- uint32 field_A4;
- uint32 field_A8;
- uint32 field_AC;
- uint32 field_B0;
- uint32 numActors;
- uint32 stereoReversedFlag;
- Common::Rect sceneRects[6]; // including scene size rect
- uint8 sceneRectIdx;
- uint8 field_11D[3];
- int32 field_120;
- uint32 actionListIdx; // actionList start index
- uint32 grResId[100];
- uint32 sceneTitleGrResId;
- uint32 sceneTitlePalResId;
- uint32 actorType;
- uint32 soundResId[50];
+ int32 width; // field_80
+ int32 height;
+ int32 motionStatus;
+ int32 field_8C;
+ int32 numActions; // field_90
+ int32 numBarriers;
+ int32 targetX;
+ int32 targetY;
+ int32 field_A0;
+ int32 field_A4;
+ int32 field_A8;
+ int32 field_AC;
+ int32 field_B0;
+ int32 numActors;
+ int32 stereoReversedFlag;
+ Common::Rect sceneRects[6]; // including scene size rect
+ uint8 sceneRectIdx;
+ uint8 field_11D[3];
+ int32 field_120;
+ int32 actionListIdx; // actionList start index
+ int32 grResId[100];
+ int32 sceneTitleGrResId;
+ int32 sceneTitlePalResId;
+ int32 actorType;
+ int32 soundResId[50];
AmbientSoundItem ambientSounds[15];
- uint32 numAmbientSound;
- uint32 musicStatus;
- int musicCurrentResId;
- uint32 musicFlag;
- int musicResId;
- uint32 musicStatusExt;
+ int32 numAmbientSound;
+ int32 musicStatus;
+ int32 musicCurrentResId;
+ int32 musicFlag;
+ int32 musicResId;
+ int32 musicStatusExt;
// FIXME: Investigate if we need to actually reserve maxsize for this arrays.
// It always have that size under scene file and they are always save in savegames.
@@ -141,20 +141,20 @@ public:
// TODO add rest fields
Common::Array<ActionArea> actions; // maxsize 400
// TODO add rest fields
- int field_E860C;
+ int32 field_E860C;
// TODO add rest fields
- int getActionAreaIndexById(uint32 id);
- ActionArea* getActionAreaById(uint32 id);
+ int32 getActionAreaIndexById(int32 id);
+ ActionArea* getActionAreaById(int32 id);
- int getBarrierIndexById(uint32 id);
- Barrier* getBarrierById(uint32 id);
- Barrier* getBarrierByIndex(uint32 idx);
+ int32 getBarrierIndexById(int32 id);
+ Barrier* getBarrierById(int32 id);
+ Barrier* getBarrierByIndex(int32 idx);
- bool isBarrierOnScreen(uint32 idx);
- bool isBarrierVisible(uint32 idx);
+ bool isBarrierOnScreen(int32 idx);
+ bool isBarrierVisible(int32 idx);
// TODO this needs a better name
- bool checkBarrierFlagsCondition(uint32 idx);
+ bool checkBarrierFlagsCondition(int32 idx);
private:
Scene *_scene;
Commit: 9e8cd4c50250d045b25278efae713431d032b33c
https://github.com/scummvm/scummvm/commit/9e8cd4c50250d045b25278efae713431d032b33c
Author: Alex Bevilacqua (alexbevi at gmail.com)
Date: 2021-05-17T15:35:57+02:00
Commit Message:
ASYLUM: move video subtitle resource lookup table to staticres
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@405 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/staticres.h
engines/asylum/video.cpp
diff --git a/engines/asylum/staticres.h b/engines/asylum/staticres.h
index b9a0be7d03..cb23bbee58 100644
--- a/engines/asylum/staticres.h
+++ b/engines/asylum/staticres.h
@@ -34,6 +34,20 @@ const int MenuIconFixedXpos[12] = { 28, 128, 225, 320, 410, 528, 16, 115, 237, 3
/** Default Actor Indices by Scene */
const int actorType[16] = {0, 0, 0, 0, 1, 0, 2, 0, 3, 0, 1, 1, 3, 0, 0, 0};
+// We hardcode all the text resources here. It makes the resulting code easier,
+// otherwise we'll have to read the text resources in the same obscure way they're stored
+// in vids.cap
+// -1 means that the video has no subtitles, -2 that it doesn't exist
+// The negative values aren't used in the code, they just make the table easier to
+// understand.
+const int32 video_subtitle_resourceIds[49] = {
+ -1, 1088, 1279, 1122, 1286, 1132, 1133, 1134, 1135, 1136, // 0 - 9
+ -1, -2, 1140, 1141, -2, -1, 1142, -1, -2, 1155, // 10 - 19
+ 1157, 1159, 1162, 1164, -2, 1171, 1177, 1184, 1190, 1201, // 20 - 29
+ -2, -2, -2, 1207, 1213, 1217, 1223, 1227, -2, 1228, // 30 - 39
+ -2, 1244, 1247, 1250, 1256, 1120, 1127, -1, -1 }; // 40 - 48
+
+
// Angle Tables used by getAngle()
const uint8 angleTable01[256] = {
0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x03, 0x03, 0x03, 0x03,
diff --git a/engines/asylum/video.cpp b/engines/asylum/video.cpp
index de7fad3d04..2007f3b4a6 100644
--- a/engines/asylum/video.cpp
+++ b/engines/asylum/video.cpp
@@ -53,21 +53,8 @@ bool VideoPlayer::playVideoWithSubtitles(Common::List<Common::Event> &stopEvents
char *start = strstr(buffer, movieToken);
char *line = 0;
- // We hardcode all the text resources here. It makes the resulting code easier,
- // otherwise we'll have to read the text resources in the same obscure way they're stored
- // in vids.cap
- // -1 means that the video has no subtitles, -2 that it doesn't exist
- // The negative values aren't used in the code, they just make the table easier to
- // understand.
- int32 textRes[49] = { -1, 1088, 1279, 1122, 1286, 1132, 1133, 1134, 1135, 1136, // 0 - 9
- -1, -2, 1140, 1141, -2, -1, 1142, -1, -2, 1155, // 10 - 19
- 1157, 1159, 1162, 1164, -2, 1171, 1177, 1184, 1190, 1201, // 20 - 29
- -2, -2, -2, 1207, 1213, 1217, 1223, 1227, -2, 1228, // 30 - 39
- -2, 1244, 1247, 1250, 1256, 1120, 1127, -1, -1
- }; // 40 - 48
-
if (start) {
- start += 20; // skip token, newline and "CAPTION = "
+ start += 20; // skip token, newline and "CAPTION = "
int32 count = strcspn(start, "\r\n");
line = new char[count + 1];
@@ -83,7 +70,7 @@ bool VideoPlayer::playVideoWithSubtitles(Common::List<Common::Event> &stopEvents
tok = strtok(NULL, " ");
newSubtitle.frameEnd = atoi(tok);
tok = strtok(NULL, " ");
- newSubtitle.textRes = atoi(tok) + textRes[videoNumber];
+ newSubtitle.textRes = atoi(tok) + video_subtitle_resourceIds[videoNumber];
tok = strtok(NULL, " ");
_subtitles.push_back(newSubtitle);
@@ -111,7 +98,6 @@ void VideoPlayer::performPostProcessing(byte *screen) {
break;
}
}
-
}
Video::Video(Audio::Mixer *mixer) {
@@ -121,8 +107,8 @@ Video::Video(Audio::Mixer *mixer) {
stopEvent.kbd = Common::KEYCODE_ESCAPE;
_stopEvents.push_back(stopEvent);
- _smkDecoder = new Graphics::SmackerDecoder(mixer);
- _player = new VideoPlayer(_smkDecoder);
+ _smkDecoder = new Graphics::SmackerDecoder(mixer);
+ _player = new VideoPlayer(_smkDecoder);
}
Video::~Video() {
@@ -180,9 +166,9 @@ void VideoText::drawMovieSubtitle(byte *screenBuffer, int32 resId) {
int32 curLine = 0;
ResourceEntry *textRes = _textPack->getResource(resId);
char *text = strdup((const char *)textRes->data); // for strtok
- char *tok = strtok(text, " ");
- int32 startY = 420; // starting y for up to 2 subtitles
- int32 spacing = 30; // spacing for up to 2 subtitles
+ char *tok = strtok(text, " ");
+ int32 startY = 420; // starting y for up to 2 subtitles
+ int32 spacing = 30; // spacing for up to 2 subtitles
// Videos can have up to 4 lines of text
while (tok) {
@@ -192,11 +178,11 @@ void VideoText::drawMovieSubtitle(byte *screenBuffer, int32 resId) {
tmpLine = tok;
curLine++;
if (curLine >= 2) {
- startY = 410; // starting Y for 3 subtitles
- spacing = 20; // spacing for 3-4 subtitles
+ startY = 410; // starting Y for 3 subtitles
+ spacing = 20; // spacing for 3-4 subtitles
}
if (curLine >= 3) {
- startY = 402; // starting Y for 4 subtitles
+ startY = 402; // starting Y for 4 subtitles
}
}
textLine[curLine] += tok;
@@ -218,6 +204,7 @@ int32 VideoText::getTextWidth(const char *text) {
int32 width = 0;
uint8 character = *text;
const char *curChar = text;
+
while (character) {
GraphicFrame *font = _fontResource->getFrame(character);
width += font->surface.w + font->x - _curFontFlags;
@@ -246,11 +233,11 @@ void VideoText::copyToVideoFrame(byte *screenBuffer, GraphicFrame *frame, int32
uint16 w = frame->surface.w;
int32 screenBufferPitch = 640;
byte *buffer = (byte *)frame->surface.pixels;
- byte *dest = screenBuffer + y * screenBufferPitch + x;
+ byte *dest = screenBuffer + y * screenBufferPitch + x;
while (h--) {
memcpy(dest, buffer, w);
- dest += screenBufferPitch;
+ dest += screenBufferPitch;
buffer += frame->surface.w;
}
}
Commit: 7506f2d4704a896d3475d08b81feacd5473f4de6
https://github.com/scummvm/scummvm/commit/7506f2d4704a896d3475d08b81feacd5473f4de6
Author: Alex Bevilacqua (alexbevi at gmail.com)
Date: 2021-05-17T15:35:57+02:00
Commit Message:
ASYLUM: minor whitespace cleanup
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@406 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/staticres.h
diff --git a/engines/asylum/staticres.h b/engines/asylum/staticres.h
index cb23bbee58..caa61f3c52 100644
--- a/engines/asylum/staticres.h
+++ b/engines/asylum/staticres.h
@@ -41,9 +41,9 @@ const int actorType[16] = {0, 0, 0, 0, 1, 0, 2, 0, 3, 0, 1, 1, 3, 0, 0, 0};
// The negative values aren't used in the code, they just make the table easier to
// understand.
const int32 video_subtitle_resourceIds[49] = {
- -1, 1088, 1279, 1122, 1286, 1132, 1133, 1134, 1135, 1136, // 0 - 9
- -1, -2, 1140, 1141, -2, -1, 1142, -1, -2, 1155, // 10 - 19
- 1157, 1159, 1162, 1164, -2, 1171, 1177, 1184, 1190, 1201, // 20 - 29
+ -1, 1088, 1279, 1122, 1286, 1132, 1133, 1134, 1135, 1136, // 0 - 9
+ -1, -2, 1140, 1141, -2, -1, 1142, -1, -2, 1155, // 10 - 19
+ 1157, 1159, 1162, 1164, -2, 1171, 1177, 1184, 1190, 1201, // 20 - 29
-2, -2, -2, 1207, 1213, 1217, 1223, 1227, -2, 1228, // 30 - 39
-2, 1244, 1247, 1250, 1256, 1120, 1127, -1, -1 }; // 40 - 48
@@ -106,7 +106,6 @@ const uint8 angleTable03[256] = {
0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90
};
-
} // end of namespace Asylum
#endif /* ASYLUM_STATICRES_H_ */
Commit: 7485e6ad7f1064390acd08678748d5c87ec5e3bd
https://github.com/scummvm/scummvm/commit/7485e6ad7f1064390acd08678748d5c87ec5e3bd
Author: Alex Bevilacqua (alexbevi at gmail.com)
Date: 2021-05-17T15:35:57+02:00
Commit Message:
ASYLUM: a little more formatting
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@407 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/staticres.h
diff --git a/engines/asylum/staticres.h b/engines/asylum/staticres.h
index caa61f3c52..6a12db3aa9 100644
--- a/engines/asylum/staticres.h
+++ b/engines/asylum/staticres.h
@@ -35,11 +35,11 @@ const int MenuIconFixedXpos[12] = { 28, 128, 225, 320, 410, 528, 16, 115, 237, 3
const int actorType[16] = {0, 0, 0, 0, 1, 0, 2, 0, 3, 0, 1, 1, 3, 0, 0, 0};
// We hardcode all the text resources here. It makes the resulting code easier,
-// otherwise we'll have to read the text resources in the same obscure way they're stored
-// in vids.cap
-// -1 means that the video has no subtitles, -2 that it doesn't exist
-// The negative values aren't used in the code, they just make the table easier to
-// understand.
+// otherwise we'll have to read the text resources in the same obscure way
+// they're stored in VIDS.CAP.
+// A value of -1 means that the video has no subtitles, -2 that it doesn't exist.
+// The negative values aren't used in the code, they just make the table
+// easier to understand.
const int32 video_subtitle_resourceIds[49] = {
-1, 1088, 1279, 1122, 1286, 1132, 1133, 1134, 1135, 1136, // 0 - 9
-1, -2, 1140, 1141, -2, -1, 1142, -1, -2, 1155, // 10 - 19
@@ -47,7 +47,6 @@ const int32 video_subtitle_resourceIds[49] = {
-2, -2, -2, 1207, 1213, 1217, 1223, 1227, -2, 1228, // 30 - 39
-2, 1244, 1247, 1250, 1256, 1120, 1127, -1, -1 }; // 40 - 48
-
// Angle Tables used by getAngle()
const uint8 angleTable01[256] = {
0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x03, 0x03, 0x03, 0x03,
Commit: 878182c7040d2d647ac0f92fcc8192c37a2aa770
https://github.com/scummvm/scummvm/commit/878182c7040d2d647ac0f92fcc8192c37a2aa770
Author: Alex Bevilacqua (alexbevi at gmail.com)
Date: 2021-05-17T15:35:57+02:00
Commit Message:
ASYLUM: starting to unwind Scene::updateAmbientSounds a bit further
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@408 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/asylum.cpp
engines/asylum/asylum.h
engines/asylum/scene.cpp
engines/asylum/scene.h
diff --git a/engines/asylum/asylum.cpp b/engines/asylum/asylum.cpp
index 6775cc25b4..46f5f1e2ca 100644
--- a/engines/asylum/asylum.cpp
+++ b/engines/asylum/asylum.cpp
@@ -94,6 +94,9 @@ Common::Error AsylumEngine::init() {
_introPlaying = false;
+ g_object_x = -1;
+ g_object_y = -1;
+
memset(_gameFlags, 0, 1512);
return Common::kNoError;
diff --git a/engines/asylum/asylum.h b/engines/asylum/asylum.h
index f7bd7db0cd..47bec07d8d 100644
--- a/engines/asylum/asylum.h
+++ b/engines/asylum/asylum.h
@@ -40,6 +40,9 @@
namespace Asylum {
+static int32 g_object_x;
+static int32 g_object_y;
+
// XXX
// If defined, this will play the scene title loading
// progress before the scene is entered. This is
@@ -49,7 +52,7 @@ namespace Asylum {
// XXX If defined, this flag will prevent the intro movies
// from being played whenever the engine is started
-// #define SKIP_INTRO
+//#define SKIP_INTRO
// XXX
// I'm not sure if system endian-ness would have any
diff --git a/engines/asylum/scene.cpp b/engines/asylum/scene.cpp
index bea3af5446..50add9f38d 100644
--- a/engines/asylum/scene.cpp
+++ b/engines/asylum/scene.cpp
@@ -952,37 +952,46 @@ void Scene::updateBarriers() {
}
void Scene::updateAmbientSounds() {
- // TODO
- // if (cfgGameQualityValue > 3)
-
- int v2 = 1;
- int v15, v11, v10, v16;
-
- int panning, volume;
+ if (Config.performance <= 3)
+ return;
for (int32 i = 0; i < _ws->numAmbientSound; i++) {
+ bool processSound = true;
+ int panning = 0;
+ int volume = 0;
AmbientSoundItem *snd = &_ws->ambientSounds[i];
+
for (int32 f = 0; f < 6; f++) {
int gameFlag = snd->flagNum[f];
if (gameFlag >= 0) {
if (_vm->isGameFlagNotSet(gameFlag)) {
- v2 = 0;
+ processSound = false;
break;
}
} else {
- if (_vm->isGameFlagSet(-(int)gameFlag)) {
- // XXX Looks like this just jumps back to
- // the top of the loop, so not sure if this
- // is somehow important
+ if (_vm->isGameFlagSet(-gameFlag)) {
+ processSound = false;
+ break;
}
}
}
- if (v2) {
+ if (processSound) {
if (_vm->sound()->isPlaying(snd->resId)) {
if (snd->field_0) {
- ; // TODO volume calculation
+ // TODO optimize
+ // This adjustment only uses the actor at
+ // index zero, but it's supposed to loop through
+ // all available actors as well (I think)
+ volume = calculateVolumeAdjustment(snd, getActor(0));
+ if (volume <= 0) {
+ if (volume < -10000)
+ volume = -10000;
+ // TODO setSoundVolume(snd->resId, volume);
+ } else
+ ; // TODO setSoundVolume(snd->resId, 0);
}
} else {
+ int loflag = LOBYTE(snd->flags);
if (snd->field_0) {
; // TODO calculate panning at point
} else {
@@ -996,7 +1005,7 @@ void Scene::updateAmbientSounds() {
} else {
; // TODO calculate volume increase
}
-
+ /*
if (LOBYTE(snd->flags) & 2) {
if (rand() % 10000 < 10) {
if (snd->field_0) {
@@ -1017,7 +1026,7 @@ void Scene::updateAmbientSounds() {
}
} else {
if (LOBYTE(snd->flags) & 4) {
- /*
+
if ( (unsigned int)*ambientPanningArray < getTickCount() )
{
if ( v1->field_14 >= 0 )
@@ -1027,22 +1036,56 @@ void Scene::updateAmbientSounds() {
*ambientPanningArray = v12;
playSound(v7, 0, v9, panning);
}
- */
+
} else {
if (LOBYTE(snd->flags) & 8) {
- /*
+
if ( !*(ambientPanningArray - 15) )
{
playSound(v7, 0, v9, panning);
*(ambientPanningArray - 15) = 1;
}
- */
+
}
}
}
- }
+ } */
}
+ } else {
+ if (_vm->sound()->isPlaying(snd->resId))
+ _vm->sound()->stopSound(snd->resId);
+ }
+ }
+}
+
+int32 Scene::calculateVolumeAdjustment(AmbientSoundItem *snd, Actor *act) {
+ int32 x, y;
+ if (snd->field_10) {
+ if (g_object_x == -1) {
+ x = snd->x - act->x1 - act->x2;
+ y = snd->y - act->y1 - act->y2;
+ } else {
+ x = snd->x - g_object_x;
+ y = snd->y - g_object_y;
}
+
+ // FIXME vol = sub_432CA0(x ^ 2 + y ^ 2);
+ // Just assigning an arbitrary value for the
+ // time being
+ int vol = 5000;
+ if (100 / snd->field_C)
+ vol = vol / (100 / snd->field_C);
+ else
+ vol = snd->field_C;
+ vol = (vol - snd->field_C) ^ 2;
+ if (vol <= 10000)
+ vol = -vol;
+ else
+ vol = -10000;
+
+ return vol;
+ } else {
+ return -(snd->field_C ^ 2);
}
}
diff --git a/engines/asylum/scene.h b/engines/asylum/scene.h
index b6e92294ef..38ae7588a0 100644
--- a/engines/asylum/scene.h
+++ b/engines/asylum/scene.h
@@ -140,6 +140,12 @@ public:
* graphic resource matches the resource at grResTable[5]
*/
bool defaultActorDirectionLoaded(int actorIndex, int grResTableIdx);
+
+ /** .text:004094c0
+ * Determine the amount to increase the supplied sound
+ * sample's volume based on the actor's position
+ */
+ int32 calculateVolumeAdjustment(AmbientSoundItem *snd, Actor *act);
private:
AsylumEngine *_vm;
uint8 _sceneIdx;
Commit: 15e2aad8c8ca49fb119ce876e781455e56ae363c
https://github.com/scummvm/scummvm/commit/15e2aad8c8ca49fb119ce876e781455e56ae363c
Author: Alex Bevilacqua (alexbevi at gmail.com)
Date: 2021-05-17T15:35:57+02:00
Commit Message:
ASYLUM: a little more work on volume calculation for ambient sound update
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@409 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/scene.cpp
diff --git a/engines/asylum/scene.cpp b/engines/asylum/scene.cpp
index 50add9f38d..40bfaacad8 100644
--- a/engines/asylum/scene.cpp
+++ b/engines/asylum/scene.cpp
@@ -997,59 +997,34 @@ void Scene::updateAmbientSounds() {
} else {
panning = 0;
}
-
if (snd->field_0 == 0) {
- // FIXME: Applying the minus operator to an unsigned type results
- // in an unsigned type again. Casting gameFlag to int32 for now
- volume = -(int32)(snd->field_C ^ 2);
+ volume = -(snd->field_C ^ 2);
} else {
- ; // TODO calculate volume increase
+ volume = calculateVolumeAdjustment(snd, getActor(0));
+ volume += Config.ambientVolume;
}
- /*
- if (LOBYTE(snd->flags) & 2) {
- if (rand() % 10000 < 10) {
+ if (loflag & 2) {
+ int tmpVol = volume;
+ if (rand() % 10000 < 10)
if (snd->field_0) {
- _vm->sound()->playSound(_resPack, snd->resId, false, Config.sfxVolume + volume, panning);
+ _vm->sound()->playSound(snd->resId, false, volume, panning, false);
} else {
- v15 = rand() % 500;
- v11 = v15 * ((((rand() % 100 >= 50) - 1) & 2) - 1) + volume;
- v10 = v11;
- if (v11 <= -10000)
- v10 = -10000;
- if (v10 >= 0)
- v11 = 0;
+ // FIXME will this even work?
+ tmpVol += (rand() % 500) * (((rand() % 100 >= 50) - 1) & 2) - 1;
+ if (tmpVol <= -10000)
+ volume = -10000;
+ if (volume >= 0)
+ tmpVol = 0;
else
- if (v11 <= -10000)
- v11 = -10000;
- v16 = rand();
- _vm->sound()->playSound(_resPack, snd->resId, false, v11, v16 % 20001 - 10000);
- }
- } else {
- if (LOBYTE(snd->flags) & 4) {
-
- if ( (unsigned int)*ambientPanningArray < getTickCount() )
- {
- if ( v1->field_14 >= 0 )
- v12 = 60000 * v1->field_14 + getTickCount();
- else
- v12 = getTickCount() - 1000 * v1->field_14;
- *ambientPanningArray = v12;
- playSound(v7, 0, v9, panning);
- }
-
- } else {
- if (LOBYTE(snd->flags) & 8) {
-
- if ( !*(ambientPanningArray - 15) )
- {
- playSound(v7, 0, v9, panning);
- *(ambientPanningArray - 15) = 1;
- }
-
- }
+ if (tmpVol <= -10000)
+ tmpVol = -10000;
+ _vm->sound()->playSound(snd->resId, 0, tmpVol, rand() % 20001 - 10000);
}
+ } else {
+ if (loflag & 4) {
+ // TODO panning array stuff
}
- } */
+ }
}
} else {
if (_vm->sound()->isPlaying(snd->resId))
Commit: 6629b1baf524f2d8e6f73a0af5648ed1f4a1fe1d
https://github.com/scummvm/scummvm/commit/6629b1baf524f2d8e6f73a0af5648ed1f4a1fe1d
Author: Alexandre Fontoura (alexandrefontoura at gmail.com)
Date: 2021-05-17T15:35:57+02:00
Commit Message:
ASYLUM: * Fixed Update Barriers. Now all barriers should be visible.
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@410 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/scene.cpp
diff --git a/engines/asylum/scene.cpp b/engines/asylum/scene.cpp
index 40bfaacad8..ffe025220a 100644
--- a/engines/asylum/scene.cpp
+++ b/engines/asylum/scene.cpp
@@ -826,7 +826,7 @@ void Scene::updateBarriers() {
if (_ws->isBarrierVisible(b)) {
int32 flag = barrier->flags;
if (flag & 0x20) {
- if (barrier->field_B4 && (_vm->getTick() - barrier->tickCount >= 0x3E8 / barrier->field_B4)) {
+ if (_vm->getTick() - barrier->tickCount >= 0x3E8 / barrier->field_B4) {
barrier->frameIdx = (barrier->frameIdx + 1) % barrier->frameCount;
barrier->tickCount = _vm->getTick();
canPlaySound = true;
@@ -858,16 +858,14 @@ void Scene::updateBarriers() {
}
if (!((lessZero ^ 0) | equalZero)) {
- // FIXME: we shouldn't increment field_B4 (check why this value came zero sometimes)
- if (barrier->field_B4 && (_vm->getTick() - barrier->tickCount >= 0x3E8 / barrier->field_B4)) {
+ if (_vm->getTick() - barrier->tickCount >= 0x3E8 / barrier->field_B4) {
barrier->frameIdx = (barrier->frameIdx + 1) % barrier->frameCount;
barrier->tickCount = _vm->getTick();
canPlaySound = true;
}
}
} else if (flag & 8) {
- // FIXME: we shouldn't increment field_B4 (check why this value came zero sometimes)
- if (barrier->field_B4 && (_vm->getTick() - barrier->tickCount >= 0x3E8 / barrier->field_B4)) {
+ if (_vm->getTick() - barrier->tickCount >= 0x3E8 / barrier->field_B4) {
int32 frameIdx = barrier->frameIdx + 1;
if (frameIdx < barrier->frameCount - 1) {
if (barrier->field_688 == 1) {
@@ -890,8 +888,7 @@ void Scene::updateBarriers() {
}
}
} else if (!((flag & 0xFFFF) & 6)) {
- // FIXME: we shouldn't increment field_B4 (check why this value came zero sometimes)
- if (barrier->field_B4 && (_vm->getTick() - barrier->tickCount >= 0x3E8 / barrier->field_B4) && (flag & 0x10000)) {
+ if (_vm->getTick() - barrier->tickCount >= 0x3E8 / barrier->field_B4 && (flag & 0x10000)) {
int32 frameIdx = barrier->frameIdx - 1;
if (frameIdx <= 0) {
barrier->flags &= 0xFFFEFFFF;
@@ -905,7 +902,7 @@ void Scene::updateBarriers() {
// TODO: get global x, y positions
}
barrier->frameIdx = frameIdx;
- } else if (barrier->field_B4 && (_vm->getTick() - barrier->tickCount >= 0x3E8 / barrier->field_B4)) {
+ } else if (_vm->getTick() - barrier->tickCount >= 0x3E8 / barrier->field_B4) {
if ((flag & 0xFF) & 2) {
if (barrier->frameIdx == barrier->frameCount - 1) {
barrier->frameIdx--;
@@ -930,7 +927,7 @@ void Scene::updateBarriers() {
if (barrier->frameIdx == barrier->frameCount - 1) {
if (barrier->field_B4 <= 15) {
barrier->field_B4 -= 2;
- if (barrier->field_B4 < 0) // FIXME: check this
+ if (barrier->field_B4 < 0)
barrier->field_B4 = 0;
} else {
barrier->field_B4 = 15;
Commit: 003fe3e9ade9dcd4f43b82d2e6873147578b6466
https://github.com/scummvm/scummvm/commit/003fe3e9ade9dcd4f43b82d2e6873147578b6466
Author: Alex Bevilacqua (alexbevi at gmail.com)
Date: 2021-05-17T15:35:58+02:00
Commit Message:
ASYLUM: cleanup
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@411 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/scene.h
diff --git a/engines/asylum/scene.h b/engines/asylum/scene.h
index 38ae7588a0..b91729ef9d 100644
--- a/engines/asylum/scene.h
+++ b/engines/asylum/scene.h
@@ -63,17 +63,17 @@ public:
bool loadingComplete() { return _done; }
private:
- Scene *_scene;
+ Scene *_scene;
+
GraphicResource *_bg;
GraphicResource *_progress;
int32 _start;
int32 _ticks;
- bool _done;
+ bool _done;
int32 _spinnerFrame;
int32 _spinnerProgress;
-
- bool _showMouseState;
+ bool _showMouseState;
}; // end of class SceneTitle
@@ -109,67 +109,67 @@ public:
WorldStats* worldstats() { return _ws; }
Polygons* polygons() { return _polygons; }
ActionList* actions() { return _actions; }
- Speech* speech() { return _speech; }
-
- void getActorPosition(Actor *actor, Common::Point *pt);
-
- /**
- * Return the index of the current player actor
- */
- int getActorIndex() { return _playerActorIdx; }
- /**
- * Get a reference to an actor object from the
- * WorldStats actor list. Default parameter just
- * gets the instance associated with _playerActorIdx
- */
- Actor* getActor(int index = -1);
- /** .text:004072A0
- * Based on the value of param, replace the actor
- * graphic from the actor's grResTable
- *
- * TODO figure out exactly what param means
- */
- void updateActorDirection(int actorIndex, int param);
- /** .text:0040A2E0
- * If the actor index is invalid, load the default actor,
- * then call updateActorDirection with a param of 4
- */
- void updateActorDirectionDefault(int actorIndex);
- /** .text:00407260
- * Check the actor at actorIndex to see if the currently loaded
- * graphic resource matches the resource at grResTable[5]
- */
- bool defaultActorDirectionLoaded(int actorIndex, int grResTableIdx);
-
- /** .text:004094c0
- * Determine the amount to increase the supplied sound
- * sample's volume based on the actor's position
- */
- int32 calculateVolumeAdjustment(AmbientSoundItem *snd, Actor *act);
+ Speech* speech() { return _speech; }
+
+ void getActorPosition(Actor *actor, Common::Point *pt);
+ /**
+ * Return the index of the current player actor
+ */
+ int getActorIndex() { return _playerActorIdx; }
+ /**
+ * Get a reference to an actor object from the
+ * WorldStats actor list. Default parameter just
+ * gets the instance associated with _playerActorIdx
+ */
+ Actor* getActor(int index = -1);
+ /** .text:004072A0
+ * Based on the value of param, replace the actor
+ * graphic from the actor's grResTable
+ *
+ * TODO figure out exactly what param means
+ */
+ void updateActorDirection(int actorIndex, int param);
+ /** .text:0040A2E0
+ * If the actor index is invalid, load the default actor,
+ * then call updateActorDirection with a param of 4
+ */
+ void updateActorDirectionDefault(int actorIndex);
+ /** .text:00407260
+ * Check the actor at actorIndex to see if the currently loaded
+ * graphic resource matches the resource at grResTable[5]
+ */
+ bool defaultActorDirectionLoaded(int actorIndex, int grResTableIdx);
+ /** .text:004094c0
+ * Determine the amount to increase the supplied sound
+ * sample's volume based on the actor's position
+ */
+ int32 calculateVolumeAdjustment(AmbientSoundItem *snd, Actor *act);
+
private:
- AsylumEngine *_vm;
- uint8 _sceneIdx;
+ AsylumEngine *_vm;
+ Common::Event *_ev;
+
+ uint8 _sceneIdx;
+ int32 _playerActorIdx;
+ bool _titleLoaded;
+ bool _walking;
+ bool _leftClick;
+ bool _rightButton;
+ bool _isActive;
+ bool _skipDrawScene;
+
WorldStats *_ws;
Polygons *_polygons;
ActionList *_actions;
SceneTitle *_title;
- Speech *_speech;
+ Speech *_speech;
+ Cursor *_cursor;
+ ResourcePack *_resPack;
+ ResourcePack *_musPack;
+ BlowUpPuzzle *_blowUp;
- Cursor *_cursor;
- ResourcePack *_resPack;
- ResourcePack *_musPack;
- BlowUpPuzzle *_blowUp;
- Common::Event *_ev;
GraphicResource *_bgResource;
- GraphicFrame *_background;
-
- bool _titleLoaded;
- bool _walking;
- bool _leftClick;
- bool _rightButton;
- bool _isActive;
- bool _skipDrawScene;
- int32 _playerActorIdx;
+ GraphicFrame *_background;
void update();
void startMusic();
@@ -180,29 +180,43 @@ private:
* process the current action script
*/
int updateScene();
- /** .text:0040D190 */
+ /** .text:0040D190
+ * TODO add description
+ */
void updateMouse();
- /** .text:0040B740 */
+ /** .text:0040B740
+ * TODO add description
+ */
void updateActor(int32 actorIdx);
/**
* TODO give more meaningful name
*/
- void updateActorSub01(Actor *act);
- /** .text:0040CBD0 */
- void updateBarriers();
- /** .text:00409BA0 */
- void updateAmbientSounds();
- /** .text:00409EF0 */
- void updateMusic();
- /** .text:0040DAE0 */
- void updateAdjustScreen();
- int drawScene();
- /** .text:0040A3C0 */
- void drawActorsAndBarriers();
- int queueActorUpdates();
- int queueBarrierUpdates();
- bool isBarrierVisible(BarrierItem *barrier);
- bool isBarrierOnScreen(BarrierItem *barrier);
+ void updateActorSub01(Actor *act);
+ /** .text:0040CBD0
+ * TODO add description
+ */
+ void updateBarriers();
+ /** .text:00409BA0
+ * TODO add description
+ */
+ void updateAmbientSounds();
+ /** .text:00409EF0
+ * TODO add description
+ */
+ void updateMusic();
+ /** .text:0040DAE0
+ * TODO add description
+ */
+ void updateAdjustScreen();
+ int drawScene();
+ /** .text:0040A3C0
+ * TODO add description
+ */
+ void drawActorsAndBarriers();
+ int queueActorUpdates();
+ int queueBarrierUpdates();
+ bool isBarrierVisible(BarrierItem *barrier);
+ bool isBarrierOnScreen(BarrierItem *barrier);
int32 getRandomResId(BarrierItem *barrier);
void copyToBackBufferClipped(Graphics::Surface *surface, int x, int y);
Commit: df377b52b4f9b472ca87a20c88088fa5f09e7fea
https://github.com/scummvm/scummvm/commit/df377b52b4f9b472ca87a20c88088fa5f09e7fea
Author: Alex Bevilacqua (alexbevi at gmail.com)
Date: 2021-05-17T15:35:58+02:00
Commit Message:
ASYLUM: minor cleanup
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@412 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/scene.h
engines/asylum/speech.cpp
engines/asylum/speech.h
diff --git a/engines/asylum/scene.h b/engines/asylum/scene.h
index b91729ef9d..0b6c693eca 100644
--- a/engines/asylum/scene.h
+++ b/engines/asylum/scene.h
@@ -92,15 +92,15 @@ public:
void enterScene();
- void activate() { _isActive = true; }
+ void activate() { _isActive = true; }
void deactivate() { _isActive = false; }
- bool isActive() { return _isActive; }
+ bool isActive() { return _isActive; }
int getSceneIndex() { return _sceneIdx; }
Cursor* getCursor() { return _cursor; }
ResourcePack* getResourcePack() { return _resPack; }
ResourcePack* getMusicPack() { return _musPack; }
- GraphicResource* getGraphicResource(int32 entry) { return new GraphicResource(_resPack, entry); }
+ GraphicResource* getGraphicResource(int32 entry) { return new GraphicResource(_resPack, entry); }
BlowUpPuzzle* getBlowUpPuzzle() { return _blowUp;}
void setBlowUpPuzzle(BlowUpPuzzle* puzzle) { _blowUp = puzzle; }
void setScenePosition(int x, int y);
@@ -108,7 +108,7 @@ public:
AsylumEngine* vm() { return _vm; }
WorldStats* worldstats() { return _ws; }
Polygons* polygons() { return _polygons; }
- ActionList* actions() { return _actions; }
+ ActionList* actions() { return _actions; }
Speech* speech() { return _speech; }
void getActorPosition(Actor *actor, Common::Point *pt);
diff --git a/engines/asylum/speech.cpp b/engines/asylum/speech.cpp
index 470064e9d3..5cf5477a96 100644
--- a/engines/asylum/speech.cpp
+++ b/engines/asylum/speech.cpp
@@ -31,9 +31,9 @@
namespace Asylum {
Speech::Speech(Scene *scene): _scene(scene) {
- _tick = _scene->vm()->getTick();
- _soundResIdx = 0;
- _textResIdx = 0;
+ _tick = _scene->vm()->getTick();
+ _soundResIdx = 0;
+ _textResIdx = 0;
}
Speech::~Speech() {
@@ -41,116 +41,116 @@ Speech::~Speech() {
}
int32 Speech::play(int32 speechIdx) {
- int32 soundResIdx = 0;
-
- switch (_scene->worldstats()->actorType) {
- case kMax: {
- int32 soundResIdx2 = speechIdx;
- int32 textResIdx = speechIdx;
-
- if (speechIdx >= 259) {
- soundResIdx2 -= 9;
- textResIdx -= 9;
- }
-
- soundResIdx = soundResIdx2 - 0x7FFD0000;
- // setup the right index for sound and text
- setPlayerSpeech(soundResIdx, textResIdx - 0x7FFFFFAD);
- }
- break;
- // TODO: check if actor type is right for the following cases
- case kSarah: {
- soundResIdx = speechIdx - 0x7FFBF879;
- setPlayerSpeech(soundResIdx, speechIdx - 0x7FFFFDB6);
- }
- break;
- case kCyclops: {
- soundResIdx = speechIdx - 0x7FFBF7DC;
- setPlayerSpeech(soundResIdx, speechIdx - 0x7FFFFD19);
- }
- break;
- case kAztec: {
- soundResIdx = speechIdx - 0x7FFBF746;
- setPlayerSpeech(soundResIdx, speechIdx - 0x7FFFFC83);
- }
- break;
- default:
- soundResIdx = 0;
- break;
- }
-
- return soundResIdx;
+ int32 soundResIdx = 0;
+
+ switch (_scene->worldstats()->actorType) {
+ case kMax: {
+ int32 soundResIdx2 = speechIdx;
+ int32 textResIdx = speechIdx;
+
+ if (speechIdx >= 259) {
+ soundResIdx2 -= 9;
+ textResIdx -= 9;
+ }
+
+ soundResIdx = soundResIdx2 - 0x7FFD0000;
+ // setup the right index for sound and text
+ setPlayerSpeech(soundResIdx, textResIdx - 0x7FFFFFAD);
+ }
+ break;
+ // TODO: check if actor type is right for the following cases
+ case kSarah: {
+ soundResIdx = speechIdx - 0x7FFBF879;
+ setPlayerSpeech(soundResIdx, speechIdx - 0x7FFFFDB6);
+ }
+ break;
+ case kCyclops: {
+ soundResIdx = speechIdx - 0x7FFBF7DC;
+ setPlayerSpeech(soundResIdx, speechIdx - 0x7FFFFD19);
+ }
+ break;
+ case kAztec: {
+ soundResIdx = speechIdx - 0x7FFBF746;
+ setPlayerSpeech(soundResIdx, speechIdx - 0x7FFFFC83);
+ }
+ break;
+ default:
+ soundResIdx = 0;
+ break;
+ }
+
+ return soundResIdx;
}
void Speech::setPlayerSpeech(int32 soundResIdx, int32 textResIdx) {
- if (soundResIdx) {
- if (_scene->vm()->sound()->isPlaying(soundResIdx)) {
- _scene->vm()->sound()->stopSound(soundResIdx);
- }
- }
+ if (soundResIdx) {
+ if (_scene->vm()->sound()->isPlaying(soundResIdx)) {
+ _scene->vm()->sound()->stopSound(soundResIdx);
+ }
+ }
- _soundResIdx = soundResIdx;
- _textResIdx = textResIdx;
+ _soundResIdx = soundResIdx;
+ _textResIdx = textResIdx;
- prepareSpeech();
+ prepareSpeech();
}
void Speech::prepareSpeech() {
- //int32 startTick = _scene->vm()->getTick();
-
- if (_soundResIdx) {
- if (!_scene->vm()->sound()->isPlaying(_soundResIdx)/* || _tick && startTick >= _tick*/) {
- processSpeech();
- }
-
- if (Config.showEncounterSubtitles) {
- int16 check = 0;
- /*Common::Point *pt;
- _scene->getActorPosition(_scene->getActor(), pt);
-
- check = pt->y < 240;
- check = pt->y >= 240;*/
- int32 posY = ((check - 1) & 0x118) + 40;
-
- _scene->vm()->text()->loadFont(_scene->getResourcePack(), _scene->worldstats()->commonRes.font3);
- _scene->vm()->text()->drawText(20, posY, _textDataPos);
-
- _scene->vm()->text()->loadFont(_scene->getResourcePack(), _scene->worldstats()->commonRes.font1);
- _scene->vm()->text()->drawText(20, posY, _textData);
- }
- }
+ //int32 startTick = _scene->vm()->getTick();
+
+ if (_soundResIdx) {
+ if (!_scene->vm()->sound()->isPlaying(_soundResIdx)/* || _tick && startTick >= _tick*/) {
+ processSpeech();
+ }
+
+ if (Config.showEncounterSubtitles) {
+ int16 check = 0;
+ /*Common::Point *pt;
+ _scene->getActorPosition(_scene->getActor(), pt);
+
+ check = pt->y < 240;
+ check = pt->y >= 240;*/
+ int32 posY = ((check - 1) & 0x118) + 40;
+
+ _scene->vm()->text()->loadFont(_scene->getResourcePack(), _scene->worldstats()->commonRes.font3);
+ _scene->vm()->text()->drawText(20, posY, _textDataPos);
+
+ _scene->vm()->text()->loadFont(_scene->getResourcePack(), _scene->worldstats()->commonRes.font1);
+ _scene->vm()->text()->drawText(20, posY, _textData);
+ }
+ }
}
void Speech::processSpeech() {
- char * txt;
-
- _tick = 0;
-
- txt = _scene->vm()->text()->getResText(_textResIdx);
-
- if (*(txt + strlen((const char *)txt) - 2) == 1) {
- _textResIdx = 0;
- _textData = 0;
- _textDataPos = 0;
- } else {
- if (*txt == '{') {
- _textData = txt + 3;
- _textDataPos = 0;
-
- _scene->vm()->text()->loadFont(_scene->getResourcePack(), _scene->worldstats()->commonRes.font1);
- _scene->vm()->sound()->playSpeech(_soundResIdx);
- } else {
- _textData = 0;
- _textDataPos = txt;
-
- if (*txt == '/') {
- _textDataPos = txt + 2;
- }
-
- _scene->vm()->text()->loadFont(_scene->getResourcePack(), _scene->worldstats()->commonRes.font3);
- _scene->vm()->sound()->playSpeech(_soundResIdx);
- }
- }
+ char * txt;
+
+ _tick = 0;
+
+ txt = _scene->vm()->text()->getResText(_textResIdx);
+
+ if (*(txt + strlen((const char *)txt) - 2) == 1) {
+ _textResIdx = 0;
+ _textData = 0;
+ _textDataPos = 0;
+ } else {
+ if (*txt == '{') {
+ _textData = txt + 3;
+ _textDataPos = 0;
+
+ _scene->vm()->text()->loadFont(_scene->getResourcePack(), _scene->worldstats()->commonRes.font1);
+ _scene->vm()->sound()->playSpeech(_soundResIdx);
+ } else {
+ _textData = 0;
+ _textDataPos = txt;
+
+ if (*txt == '/') {
+ _textDataPos = txt + 2;
+ }
+
+ _scene->vm()->text()->loadFont(_scene->getResourcePack(), _scene->worldstats()->commonRes.font3);
+ _scene->vm()->sound()->playSpeech(_soundResIdx);
+ }
+ }
}
} // end of namespace Asylum
diff --git a/engines/asylum/speech.h b/engines/asylum/speech.h
index 39e327f088..fe61202be6 100644
--- a/engines/asylum/speech.h
+++ b/engines/asylum/speech.h
@@ -33,45 +33,44 @@ namespace Asylum {
class Speech {
public:
- Speech(Scene *scene);
- virtual ~Speech();
+ Speech(Scene *scene);
+ virtual ~Speech();
+
+ int32 _soundResIdx;
+ int32 _textResIdx;
+
+ /** .text:00414810
+ * Play player speech
+ * @param speechIdx speech index (used for sound and text resources)
+ * @return correct resourceId
+ */
+ int32 play(int32 speechIdx);
+ /** .text:004146D0
+ * Set speech for different player type
+ * @param soundResIdx sound resource id
+ * @param textResIdx text resource id
+ */
+ void setPlayerSpeech(int32 soundResIdx, int32 textResIdx);
+ /** .text:004144C0
+ * Prepare speech to play
+ * - Process sound speech and draws dialogue in screen
+ */
+ void prepareSpeech();
- int32 _soundResIdx;
- int32 _textResIdx;
-
- /** .text:00414810
- * Play player speech
- * @param speechIdx speech index (used for sound and text resources)
- * @return correct resourceId
- */
- int32 play(int32 speechIdx);
-
- /** .text:004146D0
- * Set speech for different player type
- * @param soundResIdx sound resource id
- * @param textResIdx text resource id
- */
- void setPlayerSpeech(int32 soundResIdx, int32 textResIdx);
-
- /** .text:004144C0
- * Prepare speech to play
- * - Process sound speech and draws dialogue in screen
- */
- void prepareSpeech();
private:
- Scene *_scene;
-
- int32 _tick;
+ Scene *_scene;
- char * _textData;
- char * _textDataPos;
+ int32 _tick;
+ char * _textData;
+ char * _textDataPos;
- /** .text:00414580
- */
- void processSpeech();
+ /** .text:00414580
+ * TODO add description
+ */
+ void processSpeech();
- // This function was cutoff since it doesn't make any sence using it. Its here for address information only
- /** .text:00414630 void playSpeech(int32 textResIdx, int32 fontResIdx); */
+ // This function was cutoff since it doesn't make any sense using it. Its here for address information only
+ /** .text:00414630 void playSpeech(int32 textResIdx, int32 fontResIdx); */
}; // end of class Speech
Commit: 5b36ee78b5eb631e509ac9b7b3c0eda55a9bb6ca
https://github.com/scummvm/scummvm/commit/5b36ee78b5eb631e509ac9b7b3c0eda55a9bb6ca
Author: Alexandre Fontoura (alexandrefontoura at gmail.com)
Date: 2021-05-17T15:35:58+02:00
Commit Message:
ASYLUM: * Fixed scene/barriers drawing positions. We can now see all Barriers active in scene.
* Add mouse scrolling debug be activated in Console (still have a bug in barriers positions while scrolling)
(CAREFUL: while scrolling in debug, the engine could crash due to incomplete code)
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@413 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/console.cpp
engines/asylum/scene.cpp
engines/asylum/screen.cpp
diff --git a/engines/asylum/console.cpp b/engines/asylum/console.cpp
index e6a3e186f5..0fe424e3a7 100644
--- a/engines/asylum/console.cpp
+++ b/engines/asylum/console.cpp
@@ -32,6 +32,7 @@ namespace Asylum {
extern int32 g_debugPolygons;
extern int32 g_debugBarriers;
+extern int32 g_debugScrolling;
Console::Console(AsylumEngine *vm) : GUI::Debugger() {
_vm = vm;
@@ -45,6 +46,7 @@ Console::Console(AsylumEngine *vm) : GUI::Debugger() {
DVar_Register("showpolygons", &g_debugPolygons, DVAR_INT, 0);
DVar_Register("showbarriers", &g_debugBarriers, DVAR_INT, 0);
+ DVar_Register("use_scrolling", &g_debugScrolling, DVAR_INT, 0);
}
Console::~Console() {
diff --git a/engines/asylum/scene.cpp b/engines/asylum/scene.cpp
index ffe025220a..3856df1051 100644
--- a/engines/asylum/scene.cpp
+++ b/engines/asylum/scene.cpp
@@ -34,6 +34,7 @@ namespace Asylum {
int g_debugPolygons;
int g_debugBarriers;
+int g_debugScrolling;
Scene::Scene(uint8 sceneIdx, AsylumEngine *engine): _vm(engine) {
_sceneIdx = sceneIdx;
@@ -89,8 +90,9 @@ Scene::Scene(uint8 sceneIdx, AsylumEngine *engine): _vm(engine) {
_isActive = false;
_skipDrawScene = 0;
- g_debugPolygons = 0;
- g_debugBarriers = 0;
+ g_debugPolygons = 0;
+ g_debugBarriers = 0;
+ g_debugScrolling = 0;
// TODO figure out what field_120 is used for
_ws->field_120 = -1;
@@ -387,7 +389,7 @@ void Scene::enterScene() {
_vm->screen()->setPalette(_resPack, _ws->commonRes.palette);
_background = _bgResource->getFrame(0);
_vm->screen()->copyToBackBuffer(
- ((byte *)_background->surface.pixels) + _ws->targetY * _background->surface.w + _ws->targetX, _background->surface.w,
+ ((byte *)_background->surface.pixels) + _ws->yTop * _background->surface.w + _ws->xLeft, _background->surface.w,
0, 0, 640, 480);
// FIXME
@@ -526,9 +528,20 @@ int Scene::updateScene() {
// Adjust Screen
startTick = _vm->getTick();
- updateAdjustScreen();
+
+ if (g_debugScrolling) { // DEBUG ScreenScrolling
+ debugScreenScrolling(_bgResource->getFrame(0));
+ } else {
+ updateAdjustScreen();
+ }
debugC(kDebugLevelScene, "AdjustScreenStart Time: %d", _vm->getTick() - startTick);
+ // Update Debug
+ if (g_debugPolygons)
+ debugShowPolygons();
+ if (g_debugBarriers)
+ debugShowBarriers();
+
if (_actions->process())
return 1;
@@ -1225,10 +1238,7 @@ void Scene::OLD_UPDATE() {
_cursor->update(&_ws->commonRes, getActor()->direction);
}
- if (g_debugPolygons)
- debugShowPolygons();
- if (g_debugBarriers)
- debugShowBarriers();
+
// Check if we're within a barrier
for (int32 p = 0; p < _ws->numBarriers; p++) {
@@ -1307,17 +1317,14 @@ int Scene::drawScene() {
} else {
// Draw scene background
GraphicFrame *bg = _bgResource->getFrame(0);
+
_vm->screen()->copyToBackBuffer(
- ((byte *)bg->surface.pixels) + _ws->targetY * bg->surface.w + _ws->targetX, bg->surface.w,
- _ws->xLeft,
- _ws->yTop,
+ ((byte *)bg->surface.pixels) + _ws->yTop * bg->surface.w + _ws->xLeft, bg->surface.w,
+ 0,
+ 0,
640,
480);
- // DEBUG
- // Force the screen to scroll if the mouse approaches the edges
- //debugScreenScrolling(bg);
-
drawActorsAndBarriers();
queueActorUpdates();
queueBarrierUpdates();
@@ -1537,21 +1544,21 @@ int Scene::queueBarrierUpdates() {
// ----------------------------------
void Scene::copyToBackBufferClipped(Graphics::Surface *surface, int x, int y) {
- Common::Rect screenRect(_ws->targetX, _ws->targetY, _ws->targetX + 640, _ws->targetY + 480);
+ Common::Rect screenRect(_ws->xLeft, _ws->yTop, _ws->xLeft + 640, _ws->yTop + 480);
Common::Rect animRect(x, y, x + surface->w, y + surface->h);
animRect.clip(screenRect);
if (!animRect.isEmpty()) {
// Translate anim rectangle
- animRect.translate(-(int16)_ws->targetX, -(int16)_ws->targetY);
+ animRect.translate(-(int16)_ws->xLeft, -(int16)_ws->yTop);
int startX = animRect.right == 640 ? 0 : surface->w - animRect.width();
int startY = animRect.bottom == 480 ? 0 : surface->h - animRect.height();
if (surface->w > 640)
- startX = _ws->targetX;
+ startX = _ws->xLeft;
if (surface->h > 480)
- startY = _ws->targetY;
+ startY = _ws->yTop;
_vm->screen()->copyToBackBufferWithTransparency(
((byte*)surface->pixels) +
@@ -1571,16 +1578,16 @@ void Scene::copyToBackBufferClipped(Graphics::Surface *surface, int x, int y) {
void Scene::debugScreenScrolling(GraphicFrame *bg) {
// Horizontal scrolling
- if (_cursor->x() < SCREEN_EDGES && _ws->targetX >= SCROLL_STEP)
- _ws->targetX -= SCROLL_STEP;
- else if (_cursor->x() > 640 - SCREEN_EDGES && _ws->targetX <= bg->surface.w - 640 - SCROLL_STEP)
- _ws->targetX += SCROLL_STEP;
+ if (_cursor->x() < SCREEN_EDGES && _ws->xLeft >= SCROLL_STEP)
+ _ws->xLeft -= SCROLL_STEP;
+ else if (_cursor->x() > 640 - SCREEN_EDGES && _ws->xLeft <= bg->surface.w - 640 - SCROLL_STEP)
+ _ws->xLeft += SCROLL_STEP;
// Vertical scrolling
- if (_cursor->y() < SCREEN_EDGES && _ws->targetY >= SCROLL_STEP)
- _ws->targetY -= SCROLL_STEP;
- else if (_cursor->y() > 480 - SCREEN_EDGES && _ws->targetY <= bg->surface.h - 480 - SCROLL_STEP)
- _ws->targetY += SCROLL_STEP;
+ if (_cursor->y() < SCREEN_EDGES && _ws->yTop >= SCROLL_STEP)
+ _ws->yTop -= SCROLL_STEP;
+ else if (_cursor->y() > 480 - SCREEN_EDGES && _ws->yTop <= bg->surface.h - 480 - SCROLL_STEP)
+ _ws->yTop += SCROLL_STEP;
}
// WALK REGION DEBUG
diff --git a/engines/asylum/screen.cpp b/engines/asylum/screen.cpp
index dfb443bf41..9d0caa8f74 100644
--- a/engines/asylum/screen.cpp
+++ b/engines/asylum/screen.cpp
@@ -145,7 +145,7 @@ void Screen::drawGraphicsInQueue() {
for (uint32 i = 0; i < _queueItems.size(); i++) {
GraphicResource *grRes = _vm->scene()->getGraphicResource(_queueItems[i].resId);
GraphicFrame *fra = grRes->getFrame(_queueItems[i].frameIdx);
- copyRectToScreenWithTransparency((byte *)fra->surface.pixels, fra->surface.w, _queueItems[i].x - ws->targetX, _queueItems[i].y - ws->targetY, fra->surface.w, fra->surface.h);
+ copyRectToScreenWithTransparency((byte *)fra->surface.pixels, fra->surface.w, _queueItems[i].x - ws->xLeft, _queueItems[i].y - ws->yTop, fra->surface.w, fra->surface.h);
delete grRes;
}
}
Commit: b23f2c8cece82f7856cad935e132f3358fcf4e44
https://github.com/scummvm/scummvm/commit/b23f2c8cece82f7856cad935e132f3358fcf4e44
Author: Alexandre Fontoura (alexandrefontoura at gmail.com)
Date: 2021-05-17T15:35:58+02:00
Commit Message:
ASYLUM: * Fixed issue6 (unsigned characters for multi-language support) - revert signed to unsigned in resId, frameId, frameCount and draw characters.
* Add support for French Version.
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@414 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/actionlist.cpp
engines/asylum/actor.cpp
engines/asylum/actor.h
engines/asylum/barrier.h
engines/asylum/cursor.cpp
engines/asylum/cursor.h
engines/asylum/detection.cpp
engines/asylum/graphics.cpp
engines/asylum/graphics.h
engines/asylum/menu.h
engines/asylum/scene.cpp
engines/asylum/scene.h
engines/asylum/text.cpp
engines/asylum/text.h
diff --git a/engines/asylum/actionlist.cpp b/engines/asylum/actionlist.cpp
index bcee251242..e032f619fc 100644
--- a/engines/asylum/actionlist.cpp
+++ b/engines/asylum/actionlist.cpp
@@ -957,7 +957,7 @@ int kWaitUntilFramePlayed(Script *script, ScriptEntry *cmd, Scene *scn) {
Barrier *barrier = scn->worldstats()->getBarrierById(cmd->param1);
if (barrier) {
- int32 frameNum = cmd->param2;
+ uint32 frameNum = cmd->param2;
if (cmd->param2 == -1)
frameNum = barrier->frameCount - 1;
diff --git a/engines/asylum/actor.cpp b/engines/asylum/actor.cpp
index 59184f029d..5054de15c4 100644
--- a/engines/asylum/actor.cpp
+++ b/engines/asylum/actor.cpp
@@ -90,7 +90,7 @@ void Actor::setAction(int32 action) {
// Flip horizontally if necessary
if (currentAction > 100) {
- for (int32 i = 0; i < _graphic->getFrameCount(); i++) {
+ for (uint32 i = 0; i < _graphic->getFrameCount(); i++) {
GraphicFrame *frame = _graphic->getFrame(i);
byte *buffer = (byte *)frame->surface.pixels;
diff --git a/engines/asylum/actor.h b/engines/asylum/actor.h
index 5f4b43fac5..1888eaeab0 100644
--- a/engines/asylum/actor.h
+++ b/engines/asylum/actor.h
@@ -186,10 +186,10 @@ public:
int32 x;
int32 y;
- int32 grResId;
+ uint32 grResId;
int32 field_C; // BarrierIndex? Mask index?
- int32 frameNum;
- int32 frameCount;
+ uint32 frameNum;
+ uint32 frameCount;
int32 x1;
int32 y1;
int32 x2;
diff --git a/engines/asylum/barrier.h b/engines/asylum/barrier.h
index f1a1e80f15..4eadc03c66 100644
--- a/engines/asylum/barrier.h
+++ b/engines/asylum/barrier.h
@@ -45,13 +45,13 @@ public:
void setNextFrame(int flags);
int32 id;
- int32 resId;
+ uint32 resId;
int32 x;
int32 y;
Common::Rect boundingRect;
int32 field_20;
- int32 frameIdx;
- int32 frameCount;
+ uint32 frameIdx;
+ uint32 frameCount;
int32 field_2C;
int32 field_30;
int32 field_34;
diff --git a/engines/asylum/cursor.cpp b/engines/asylum/cursor.cpp
index ed1df0a29e..a758367705 100644
--- a/engines/asylum/cursor.cpp
+++ b/engines/asylum/cursor.cpp
@@ -88,7 +88,7 @@ void Cursor::animate() {
}
void Cursor::update(CommonResources *cr, int32 currentAction) {
- int32 newCursor = 0;
+ uint32 newCursor = 0;
// Change cursor
switch (currentAction) {
diff --git a/engines/asylum/cursor.h b/engines/asylum/cursor.h
index 8955c81786..35dd20cf5c 100644
--- a/engines/asylum/cursor.h
+++ b/engines/asylum/cursor.h
@@ -94,7 +94,7 @@ public:
* Get the current frame number of the
* loaded cursorResource
*/
- int32 currentFrame() {
+ uint32 currentFrame() {
return _curFrame;
}
@@ -104,7 +104,7 @@ private:
ResourcePack *_resPack;
GraphicResource *_cursorResource;
bool cursorLoaded;
- int32 _curFrame;
+ uint32 _curFrame;
int32 _cursorStep;
int32 _mouseX;
int32 _mouseY;
diff --git a/engines/asylum/detection.cpp b/engines/asylum/detection.cpp
index ce1e090a1b..6e8623c5bb 100644
--- a/engines/asylum/detection.cpp
+++ b/engines/asylum/detection.cpp
@@ -68,6 +68,20 @@ static const ADGameDescription gameDescriptions[] = {
ADGF_NO_FLAGS,
Common::GUIO_NONE
},
+ {
+ "asylum",
+ "French Version",
+ {
+ {"SNTRM.DAT", 0, "e09a12543c6ede1727c8ecffb74e7fd2", 8930},
+ {"RES.000", 0, "2a4677ee3fd7bfa3161e16cd59371238", 277931},
+ {"SCN.006", 0, "3a5b54da08198012dc0614114782d5fb", 2918330},
+ {0,0,0,0}
+ },
+ Common::FR_FRA,
+ Common::kPlatformPC,
+ ADGF_NO_FLAGS,
+ Common::GUIO_NONE
+ },
AD_TABLE_END_MARKER
};
diff --git a/engines/asylum/graphics.cpp b/engines/asylum/graphics.cpp
index de71390887..3660e72e33 100644
--- a/engines/asylum/graphics.cpp
+++ b/engines/asylum/graphics.cpp
@@ -28,7 +28,7 @@
namespace Asylum {
-GraphicResource::GraphicResource(ResourcePack *resPack, int32 entry) {
+GraphicResource::GraphicResource(ResourcePack *resPack, uint32 entry) {
ResourceEntry *resEntry = resPack->getResource(entry);
_entryNum = entry;
init(resEntry->data, resEntry->size);
@@ -45,7 +45,7 @@ GraphicResource::~GraphicResource() {
void GraphicResource::init(byte *data, int32 size) {
byte *dataPtr = data;
int32 contentOffset = 0;
- int16 frameCount = 0;
+ uint16 frameCount = 0;
int32 i = 0;
diff --git a/engines/asylum/graphics.h b/engines/asylum/graphics.h
index 14d2edb5c5..37e80739c0 100644
--- a/engines/asylum/graphics.h
+++ b/engines/asylum/graphics.h
@@ -44,13 +44,13 @@ struct GraphicFrame {
// Graphic resources can be sprites or images, with multiple frames
class GraphicResource {
public:
- GraphicResource(ResourcePack *resPack, int32 entry);
+ GraphicResource(ResourcePack *resPack, uint32 entry);
~GraphicResource();
- int32 getFrameCount() {
+ uint32 getFrameCount() {
return _frames.size();
}
- GraphicFrame *getFrame(int32 frame) {
+ GraphicFrame *getFrame(uint32 frame) {
return &_frames[frame];
}
int32 getFlags() {
@@ -60,21 +60,21 @@ public:
/**
* Copies an animation frame to the target buffer
*/
- void copyFrameToDest(byte *dest, int32 frame);
+ void copyFrameToDest(byte *dest, uint32 frame);
/**
* Copies a sprite to the target buffer, with transparency
*/
- void copySpriteToDest(byte *dest, int32 frame);
+ void copySpriteToDest(byte *dest, uint32 frame);
- int32 getEntryNum() {
+ uint32 getEntryNum() {
return _entryNum;
}
private:
Common::Array <GraphicFrame> _frames;
int32 _flags;
- int32 _entryNum;
+ uint32 _entryNum;
void init(byte *data, int32 size);
};
diff --git a/engines/asylum/menu.h b/engines/asylum/menu.h
index 070b4d11ce..4d3727cfe6 100644
--- a/engines/asylum/menu.h
+++ b/engines/asylum/menu.h
@@ -95,10 +95,10 @@ private:
Cursor *_cursor;
int32 _activeIcon;
int32 _previousActiveIcon;
- int32 _curIconFrame;
+ uint32 _curIconFrame;
int32 _curMouseCursor;
int32 _cursorStep;
- int32 _creditsBgFrame;
+ uint32 _creditsBgFrame;
int32 _creditsTextScroll;
bool _leftClick;
bool _active;
diff --git a/engines/asylum/scene.cpp b/engines/asylum/scene.cpp
index 3856df1051..a382becd02 100644
--- a/engines/asylum/scene.cpp
+++ b/engines/asylum/scene.cpp
@@ -845,7 +845,7 @@ void Scene::updateBarriers() {
canPlaySound = true;
}
} else if (flag & 0x10) {
- int frameIdx = barrier->frameIdx;
+ uint32 frameIdx = barrier->frameIdx;
int equalZero = frameIdx == 0;
int lessZero = frameIdx < 0;
if (!frameIdx) {
@@ -879,7 +879,7 @@ void Scene::updateBarriers() {
}
} else if (flag & 8) {
if (_vm->getTick() - barrier->tickCount >= 0x3E8 / barrier->field_B4) {
- int32 frameIdx = barrier->frameIdx + 1;
+ uint32 frameIdx = barrier->frameIdx + 1;
if (frameIdx < barrier->frameCount - 1) {
if (barrier->field_688 == 1) {
// TODO: get global x, y positions
@@ -902,7 +902,7 @@ void Scene::updateBarriers() {
}
} else if (!((flag & 0xFFFF) & 6)) {
if (_vm->getTick() - barrier->tickCount >= 0x3E8 / barrier->field_B4 && (flag & 0x10000)) {
- int32 frameIdx = barrier->frameIdx - 1;
+ uint32 frameIdx = barrier->frameIdx - 1;
if (frameIdx <= 0) {
barrier->flags &= 0xFFFEFFFF;
if (barrier->field_688 == 1) {
diff --git a/engines/asylum/scene.h b/engines/asylum/scene.h
index 0b6c693eca..ac84c64425 100644
--- a/engines/asylum/scene.h
+++ b/engines/asylum/scene.h
@@ -71,7 +71,7 @@ private:
int32 _start;
int32 _ticks;
bool _done;
- int32 _spinnerFrame;
+ uint32 _spinnerFrame;
int32 _spinnerProgress;
bool _showMouseState;
diff --git a/engines/asylum/text.cpp b/engines/asylum/text.cpp
index c6d4830aa6..3ea4298b6f 100644
--- a/engines/asylum/text.cpp
+++ b/engines/asylum/text.cpp
@@ -43,7 +43,7 @@ Text::~Text() {
}
// loadFont at address 00435640
-void Text::loadFont(ResourcePack *resPack, int32 resId) {
+void Text::loadFont(ResourcePack *resPack, uint32 resId) {
if (_fontResource && resId == _fontResource->getEntryNum())
return;
@@ -78,17 +78,17 @@ int32 Text::getTextWidth(const char *text) {
return width;
}
-int32 Text::getResTextWidth(int32 resId) {
+int32 Text::getResTextWidth(uint32 resId) {
ResourceEntry *textRes = _textPack->getResource(resId);
return getTextWidth((char*)textRes->data);
}
-char* Text::getResText(int32 resId) {
+char* Text::getResText(uint32 resId) {
ResourceEntry *textRes = _textPack->getResource(resId);
return (char*)textRes->data;
}
-void Text::drawChar(char character) {
+void Text::drawChar(unsigned char character) {
assert(_fontResource);
GraphicFrame *fontLetter = _fontResource->getFrame(character);
@@ -98,12 +98,12 @@ void Text::drawChar(char character) {
void Text::drawText(const char *text) {
while (*text) {
- drawChar(*text);
+ drawChar(*((unsigned char *)text));
text++;
}
}
-void Text::drawResText(int32 resId) {
+void Text::drawResText(uint32 resId) {
ResourceEntry *textRes = _textPack->getResource(resId);
drawText((char*)textRes->data);
}
@@ -114,7 +114,7 @@ void Text::drawTextCentered(int32 x, int32 y, int32 width, const char *text) {
drawText(text);
}
-void Text::drawResTextWithValueCentered(int32 x, int32 y, int32 width, int32 resId, int32 value) {
+void Text::drawResTextWithValueCentered(int32 x, int32 y, int32 width, uint32 resId, int32 value) {
ResourceEntry *textRes = _textPack->getResource(resId);
char *text = (char *)textRes->data;
char txt[100];
@@ -122,7 +122,7 @@ void Text::drawResTextWithValueCentered(int32 x, int32 y, int32 width, int32 res
drawTextCentered(x, y, width, txt);
}
-void Text::drawResTextCentered(int32 x, int32 y, int32 width, int32 resId) {
+void Text::drawResTextCentered(int32 x, int32 y, int32 width, uint32 resId) {
ResourceEntry *textRes = _textPack->getResource(resId);
drawTextCentered(x, y, width, (char *)textRes->data);
}
@@ -135,7 +135,7 @@ void Text::drawText(int32 x, int32 y, const char *text) {
}
}
-void Text::drawResText(int32 x, int32 y, int32 resId) {
+void Text::drawResText(int32 x, int32 y, uint32 resId) {
ResourceEntry *textRes = _textPack->getResource(resId);
drawText(x, y, (char *)textRes->data);
}
@@ -146,7 +146,7 @@ void Text::drawTextAlignRight(int32 x, int32 y, const char *text) {
drawText(text);
}
-void Text::drawResTextAlignRight(int32 x, int32 y, int32 resId) {
+void Text::drawResTextAlignRight(int32 x, int32 y, uint32 resId) {
ResourceEntry *textRes = _textPack->getResource(resId);
drawTextAlignRight(x, y, (char *)textRes->data);
}
diff --git a/engines/asylum/text.h b/engines/asylum/text.h
index ec4605b1c9..32c5a44113 100644
--- a/engines/asylum/text.h
+++ b/engines/asylum/text.h
@@ -38,25 +38,25 @@ public:
Text(Screen *screen);
~Text();
- void loadFont(ResourcePack *resPack, int32 resId);
+ void loadFont(ResourcePack *resPack, uint32 resId);
void setTextPos(int32 x, int32 y);
int32 getTextWidth(const char *text);
- int32 getResTextWidth(int32 resId);
- char * getResText(int32 resId);
+ int32 getResTextWidth(uint32 resId);
+ char * getResText(uint32 resId);
- void drawChar(const char character);
+ void drawChar(unsigned char character);
void drawText(const char *text);
void drawText(int32 x, int32 y, const char *text);
- void drawResText(int32 resId);
- void drawResText(int32 x, int32 y, int32 resId);
+ void drawResText(uint32 resId);
+ void drawResText(int32 x, int32 y, uint32 resId);
void drawTextCentered(int32 x, int32 y, int32 width, const char *text);
- void drawResTextCentered(int32 x, int32 y, int32 width, int32 resId);
- void drawResTextWithValueCentered(int32 x, int32 y, int32 width, int32 resId, int32 value);
+ void drawResTextCentered(int32 x, int32 y, int32 width, uint32 resId);
+ void drawResTextWithValueCentered(int32 x, int32 y, int32 width, uint32 resId, int32 value);
void drawTextAlignRight(int32 x, int32 y, const char *text);
- void drawResTextAlignRight(int32 x, int32 y, int32 resId);
+ void drawResTextAlignRight(int32 x, int32 y, uint32 resId);
private:
Screen *_screen;
Commit: 7963bd8aef3554e9f79c7571105e032c9464b565
https://github.com/scummvm/scummvm/commit/7963bd8aef3554e9f79c7571105e032c9464b565
Author: Arthur Blot (arthur.blot78 at gmail.com)
Date: 2021-05-17T15:35:58+02:00
Commit Message:
ASYLUM: Remove GCC warnings
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@415 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/blowuppuzzle.cpp
engines/asylum/scene.cpp
diff --git a/engines/asylum/blowuppuzzle.cpp b/engines/asylum/blowuppuzzle.cpp
index 7ac46f31eb..ab1b5de9a9 100644
--- a/engines/asylum/blowuppuzzle.cpp
+++ b/engines/asylum/blowuppuzzle.cpp
@@ -488,6 +488,7 @@ void BlowUpPuzzleVCR::handleMouseDown() {
}
if (inPolyRegion(_cursor->x(), _cursor->y(), kBlackHole)) {
if (!setJackOnHole(jackType, kPluggedOnBlack)) {
+ // TODO: this will probably segfault!
if (_holesState[kBlackHole] != kPluggedOnYellow && _buttonsState[kPower] == 1) {
_buttonsState[kPower] = kOFF;
_buttonsState[kStop] = kOFF;
diff --git a/engines/asylum/scene.cpp b/engines/asylum/scene.cpp
index a382becd02..79fb5b95f5 100644
--- a/engines/asylum/scene.cpp
+++ b/engines/asylum/scene.cpp
@@ -457,6 +457,10 @@ void Scene::handleEvent(Common::Event *event, bool doUpdate) {
if (_actions->allowInput)
_rightButton = true;
break;
+
+ default:
+ break;
+
}
if (doUpdate || _leftClick)
@@ -847,7 +851,6 @@ void Scene::updateBarriers() {
} else if (flag & 0x10) {
uint32 frameIdx = barrier->frameIdx;
int equalZero = frameIdx == 0;
- int lessZero = frameIdx < 0;
if (!frameIdx) {
if (_vm->getTick() - barrier->tickCount >= 1000 * barrier->tickCount2) {
if (rand() % barrier->field_C0 == 1) {
@@ -867,10 +870,9 @@ void Scene::updateBarriers() {
}
frameIdx = barrier->frameIdx;
equalZero = frameIdx == 0;
- lessZero = frameIdx < 0;
}
- if (!((lessZero ^ 0) | equalZero)) {
+ if (!equalZero) {
if (_vm->getTick() - barrier->tickCount >= 0x3E8 / barrier->field_B4) {
barrier->frameIdx = (barrier->frameIdx + 1) % barrier->frameCount;
barrier->tickCount = _vm->getTick();
@@ -1015,7 +1017,7 @@ void Scene::updateAmbientSounds() {
}
if (loflag & 2) {
int tmpVol = volume;
- if (rand() % 10000 < 10)
+ if (rand() % 10000 < 10) {
if (snd->field_0) {
_vm->sound()->playSound(snd->resId, false, volume, panning, false);
} else {
@@ -1030,6 +1032,7 @@ void Scene::updateAmbientSounds() {
tmpVol = -10000;
_vm->sound()->playSound(snd->resId, 0, tmpVol, rand() % 20001 - 10000);
}
+ }
} else {
if (loflag & 4) {
// TODO panning array stuff
Commit: 9c17b66fa8199380a1f799aecfe461576ab334d5
https://github.com/scummvm/scummvm/commit/9c17b66fa8199380a1f799aecfe461576ab334d5
Author: Filippos Karapetis (md5 at scummvm.org)
Date: 2021-05-17T15:35:58+02:00
Commit Message:
ASYLUM: Silenced a (very) annoying warning
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@416 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/sound.cpp
diff --git a/engines/asylum/sound.cpp b/engines/asylum/sound.cpp
index b3751905ee..674298bb10 100644
--- a/engines/asylum/sound.cpp
+++ b/engines/asylum/sound.cpp
@@ -135,7 +135,7 @@ bool Sound::isPlaying(int32 resId) {
int32 pos = getBufferPosition(resId);
if (pos < 0) {
- warning("isPlaying: resId %d not currently bufferred", resId);
+ //warning("isPlaying: resId %d not currently bufferred", resId);
} else {
SoundBufferItem snd = _soundBuffer[pos];
if (_mixer->isSoundHandleActive(snd.handle)) {
Commit: cb90401e0dbb3640476d283bc88de6986d12c9f9
https://github.com/scummvm/scummvm/commit/cb90401e0dbb3640476d283bc88de6986d12c9f9
Author: Alex Bevilacqua (alexbevi at gmail.com)
Date: 2021-05-17T15:35:59+02:00
Commit Message:
ASYLUM: This commit is to checkin the changes I've made in relation to Scene::update::updateMouse. It doesn't really work yet, but there has been a lot of work done on the various hit tests that may help in other's efforts.
Right now, I think one of the hit tests isn't properly implemented, as I'm always getting the same result when moving the cursor over anything.
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@417 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/actor.h
engines/asylum/cursor.h
engines/asylum/scene.cpp
engines/asylum/scene.h
engines/asylum/worldstats.cpp
engines/asylum/worldstats.h
diff --git a/engines/asylum/actor.h b/engines/asylum/actor.h
index 1888eaeab0..f66dad6546 100644
--- a/engines/asylum/actor.h
+++ b/engines/asylum/actor.h
@@ -184,75 +184,76 @@ public:
int32 currentAction; // TODO depreciate
- int32 x;
- int32 y;
- uint32 grResId;
- int32 field_C; // BarrierIndex? Mask index?
- uint32 frameNum;
- uint32 frameCount;
- int32 x1;
- int32 y1;
- int32 x2;
- int32 y2;
+ int32 x;
+ int32 y;
+ uint32 grResId;
+ int32 field_C; // BarrierIndex? Mask index?
+ uint32 frameNum;
+ uint32 frameCount;
+ int32 x1;
+ int32 y1;
+ int32 x2;
+ int32 y2;
Common::Rect boundingRect;
- int32 direction;
- int32 field_3C;
- int32 updateType;
- int32 field_44;
- int32 priority;
- int32 flags;
- int32 field_50;
- int32 field_54;
- int32 field_58;
- int32 field_5C;
- int32 field_60;
- int32 actionIdx3;
+ int32 direction;
+ int32 field_3C;
+ int32 updateType;
+ int32 field_44;
+ int32 priority;
+ int32 flags;
+ int32 field_50;
+ int32 field_54;
+ int32 field_58;
+ int32 field_5C;
+ int32 field_60;
+ int32 actionIdx3;
// TODO field_68 till field_617
- int32 reaction[8];
- int32 field_638;
- int32 walkingSound1;
- int32 walkingSound2;
- int32 walkingSound3;
- int32 walkingSound4;
- int32 field_64C;
- int32 field_650;
- int32 grResTable[55];
- char name[256];
- int32 field_830[20];
- int32 field_880[20];
- int32 field_8D0[20];
- int32 actionIdx2;
- int32 field_924;
- int32 tickValue1;
- int32 field_92C;
- int32 flags2;
- int32 field_934;
- int32 field_938;
- int32 soundResId; // field_93C
- int32 field_940;
- int32 field_944;
- int32 field_948;
- int32 field_94C;
- int32 field_950;
- int32 field_954;
- int32 field_958;
- int32 field_95C;
- int32 field_960;
- int32 field_964;
- int32 field_968;
- int32 field_96C;
- int32 field_970;
- int32 field_974;
- int32 field_978;
- int32 actionIdx1;
+ int32 reaction[8];
+ int32 field_638;
+ int32 walkingSound1;
+ int32 walkingSound2;
+ int32 walkingSound3;
+ int32 walkingSound4;
+ int32 field_64C;
+ int32 field_650;
+ int32 grResTable[55];
+ char name[256];
+ int32 field_830[20];
+ int32 field_880[20];
+ int32 field_8D0[20];
+ int32 actionIdx2;
+ int32 field_924;
+ int32 tickValue1;
+ int32 field_92C;
+ int32 flags2;
+ int32 field_934;
+ int32 field_938;
+ int32 soundResId; // field_93C
+ int32 field_940;
+ int32 field_944;
+ int32 field_948;
+ int32 field_94C;
+ int32 field_950;
+ int32 field_954;
+ int32 field_958;
+ int32 field_95C;
+ int32 field_960;
+ int32 field_964;
+ int32 field_968;
+ int32 field_96C;
+ int32 field_970;
+ int32 field_974;
+ int32 field_978;
+ int32 actionIdx1;
// TODO field_980 till field_9A0
private:
- Scene *_scene;
+ Scene *_scene;
+ int32 _resources[61];
+
ResourcePack *_resPack;
GraphicResource *_graphic;
- int32 _resources[61];
- ActionArea *_currentWalkArea;
+ ActionArea *_currentWalkArea;
GraphicFrame *getFrame();
int32 getAngle(int32 ax1, int32 ay1, int32 ax2, int32 ay2);
diff --git a/engines/asylum/cursor.h b/engines/asylum/cursor.h
index 35dd20cf5c..e84ef3e729 100644
--- a/engines/asylum/cursor.h
+++ b/engines/asylum/cursor.h
@@ -98,6 +98,21 @@ public:
return _curFrame;
}
+
+ // NOTE
+ // .text:00435060 contains a function that assigns global variables to a
+ // struct associated with cursor graphics info. Since this functionality only
+ // ever seems to be used to reference cursor info, the struct members
+ // may as well be class members in order to simplify the logic a bit
+
+ // typedef struct CursorInfo {
+ int32 grResId;
+ int32 field_4;
+ int32 frameCount;
+ int32 field_C;
+ byte flags;
+ byte field_11;
+ // } CursorInfo;
private:
void set(byte *data, byte width, byte height);
diff --git a/engines/asylum/scene.cpp b/engines/asylum/scene.cpp
index 79fb5b95f5..c107d16d2e 100644
--- a/engines/asylum/scene.cpp
+++ b/engines/asylum/scene.cpp
@@ -128,6 +128,9 @@ void Scene::initialize() {
_cursor->load(_ws->commonRes.curMagnifyingGlass);
_cursor->set(0);
+ // FIXME this is just here for testing
+ _cursor->grResId = _ws->commonRes.curMagnifyingGlass;
+
_ws->sceneRectIdx = 0;
_vm->screen()->clearScreen(); // XXX was clearGraphicsInQueue()
_ws->motionStatus = 1;
@@ -506,7 +509,7 @@ int Scene::updateScene() {
// Mouse
startTick = _vm->getTick();
- updateMouse();
+ // updateMouse();
debugC(kDebugLevelScene, "UpdateMouse Time: %d", _vm->getTick() - startTick);
// Actors
@@ -553,18 +556,27 @@ int Scene::updateScene() {
}
void Scene::updateMouse() {
- Common::Rect actorPos;
+ Common::Rect actorPos;
+ Common::Point pt;
+ Actor *act = getActor();
+
+ // The code below was from
+ // .text:0040A1B0 getCharacterScreenPosition()
+ // which was only ever called at this point, so
+ // inlining it for simplicity
+ pt.x = act->x1 -_ws->xLeft;
+ pt.y = act->y1 -_ws->yTop;
if (_sceneIdx != 2 || _playerActorIdx != 10) {
- actorPos.top = getActor()->y;
- actorPos.left = getActor()->x + 20;
- actorPos.right = getActor()->x + 2 + getActor()->x2;
- actorPos.bottom = getActor()->y + getActor()->y2;
+ actorPos.left = pt.x + 20;
+ actorPos.top = pt.y;
+ actorPos.right = pt.x + 2 * act->x2;
+ actorPos.bottom = pt.y + act->y2;
} else {
- actorPos.top = getActor()->y + 60;
- actorPos.left = getActor()->x + 50;
- actorPos.right = getActor()->x + getActor()->x2 + 10;
- actorPos.bottom = getActor()->y + getActor()->y2 - 20;
+ actorPos.left = pt.x + 50;
+ actorPos.top = pt.y + 60;
+ actorPos.right = pt.x + getActor(10)->x2 + 10;
+ actorPos.bottom = pt.y + getActor(10)->y2 - 20;
}
int dir = -1;
@@ -573,11 +585,11 @@ void Scene::updateMouse() {
if (_cursor->x() < actorPos.left) {
if (_cursor->y() >= actorPos.top) {
if (_cursor->y() > actorPos.bottom) {
- if (getActor()->direction == 2) {
+ if (act->direction == 2) {
if (_cursor->y() - actorPos.bottom > 10)
dir = 3;
} else {
- if (getActor()->direction == 4) {
+ if (act->direction == 4) {
if (actorPos.left - _cursor->x() > 10)
dir = 3;
} else {
@@ -585,11 +597,11 @@ void Scene::updateMouse() {
}
}
} else {
- if (getActor()->direction == 1) {
+ if (act->direction == 1) {
if (_cursor->y() - actorPos.top > 10)
dir = 2;
} else {
- if (getActor()->direction == 3) {
+ if (act->direction == 3) {
if (actorPos.bottom - _cursor->y() > 10)
dir = 2;
} else {
@@ -598,8 +610,8 @@ void Scene::updateMouse() {
}
}
} else {
- if (getActor()->direction) {
- if (getActor()->direction == 2) {
+ if (act->direction) {
+ if (act->direction == 2) {
if (actorPos.top - _cursor->y() > 10)
dir = 1;
} else {
@@ -616,11 +628,11 @@ void Scene::updateMouse() {
if (!done && _cursor->x() <= actorPos.right) {
if (_cursor->y() >= actorPos.top) {
if (_cursor->y() > actorPos.bottom) {
- if (getActor()->direction == 3) {
+ if (act->direction == 3) {
if (_cursor->x() - actorPos.left > 10)
dir = 4;
} else {
- if (getActor()->direction == 5) {
+ if (act->direction == 5) {
if (actorPos.right - _cursor->x() > 10)
dir = 4;
} else {
@@ -629,11 +641,11 @@ void Scene::updateMouse() {
}
}
} else {
- if (getActor()->direction == 1) {
+ if (act->direction == 1) {
if (_cursor->x() - actorPos.left > 10)
dir = 0;
} else {
- if (getActor()->direction == 7) {
+ if (act->direction == 7) {
if (actorPos.right - _cursor->x() > 10)
dir = 0;
} else {
@@ -645,8 +657,8 @@ void Scene::updateMouse() {
}
if (!done && _cursor->y() < actorPos.top) {
- if (getActor()->direction) {
- if (getActor()->direction == 6) {
+ if (act->direction) {
+ if (act->direction == 6) {
if (actorPos.top - _cursor->y() > 10)
dir = 7;
} else {
@@ -660,11 +672,11 @@ void Scene::updateMouse() {
}
if (!done && _cursor->y() <= actorPos.bottom) {
- if (getActor()->direction == 5) {
+ if (act->direction == 5) {
if (actorPos.bottom - _cursor->y() > 10)
dir = 6;
} else {
- if (getActor()->direction == 7) {
+ if (act->direction == 7) {
if (_cursor->y() - actorPos.top > 10)
dir = 6;
} else {
@@ -674,20 +686,296 @@ void Scene::updateMouse() {
done = true;
}
- if (!done && getActor()->direction == 4) {
+ if (!done && act->direction == 4) {
if (_cursor->x() - actorPos.right <= 10)
done = true;
if (!done)
dir = 5;
}
- if (!done && (getActor()->direction != 6 || _cursor->y() - actorPos.bottom > 10)) {
+ if (!done && (act->direction != 6 || _cursor->y() - actorPos.bottom > 10))
dir = 5;
+
+ handleMouseUpdate(dir, actorPos);
+ if (dir >= 0) {
+ if (act->updateType == 1 || act->updateType == 12)
+ setActorDirection(act, dir);
}
//printf("Current Dir %d -- New Dir %d\n", actor->direction, dir);
}
+void Scene::setActorDirection(Actor *act, int direction) {
+ act->direction = (direction > 4) ? 8 - direction : direction;
+ int32 grResId;
+
+ if (act->field_944 != 5) {
+ switch (act->updateType) {
+ case 0x04:
+ case 0x05:
+ case 0x0E: {
+ grResId = act->grResTable[act->direction + 5];
+ // FIXME this seems kind of wasteful just to grab a frame count
+ GraphicResource *gra = new GraphicResource(_resPack, grResId);
+ act->grResId = grResId;
+ act->frameCount = gra->getFrameCount();
+ delete gra;
+ }
+ break;
+ case 0x12:
+ if (_ws->numChapter == 2) {
+ if (_playerActorIdx == 11) {
+ // NOTE this is supposed to explicitely point to the actor 11 reference,
+ // (_ws->actors[11])
+ // but I'm assuming if control drops through to here, getActor() would
+ // pull the right object because the _playerActorIndex should == 11
+ if (act->direction > 4)
+ act->grResId = act->grResTable[8 - act->direction];
+ else
+ act->grResId = act->grResTable[act->direction];
+ }
+ }
+ break;
+ case 0x01:
+ case 0x02:
+ case 0x0C:
+ // TODO verify that this is correct
+ grResId = act->grResTable[act->direction];
+ break;
+ case 0x08:
+ // TODO verify that this is correct
+ grResId = act->grResTable[act->direction + 20];
+ break;
+ default:
+ warning ("[setActorDirection] default case hit with updateType of %d", act->updateType);
+ }
+ }
+}
+
+void Scene::handleMouseUpdate(int direction, Common::Rect rect) {
+ int16 rlimit = rect.right - 10;
+ int32 newGrResId;
+ HitType type = kHitNone;
+
+ // TODO if encounter_flag03
+ if (0 && _cursor->grResId != _ws->commonRes.curTalkNPC) {
+ // TODO setMouseCursor(_ws->commonRes.curTalkNPC);
+ }
+
+ Actor *act = getActor(); // get the player actor reference
+
+ if (_cursor->field_11 & 2) {
+ if (act->updateType == 1 || act->updateType == 12) {
+ if (direction >= 0) {
+ newGrResId = _ws->commonRes.curScrollUp + direction;
+ if (_cursor->grResId != newGrResId) {
+ // TODO setMouseCursor(newGrResId);
+ warning("%d", newGrResId);
+ }
+ }
+ }
+ }
+
+ if (act->updateType == 6 || act->updateType == 10) {
+ newGrResId = _ws->commonRes.curHand;
+ if (_cursor->grResId != newGrResId) {
+ // TODO setMouseCursor(newGrResId);
+ warning("%d", newGrResId);
+ }
+ } else {
+ if (act->field_638) {
+ if (_cursor->x() >= rect.left && _cursor->x() <= rlimit &&
+ _cursor->y() >= rect.top && _cursor->y() <= rect.bottom &&
+ hitTestActor(_cursor->x(), _cursor->y())) {
+ // TODO LOTS of work here, because apparently we need to use
+ // field_638 as an index into _ws->field_D6AC8, which is not
+ // yet defined as part of worldstats, but according to IDA, is:
+ // 000D6A88 field_D6A88 dd 16 dup(?)
+ // so this is an array that is initialized as part of the scene
+ // loading process. Need to investigate further ...
+ warning("Something...");
+ } else {
+ // TODO pass a reference to hitType so it can be populated by
+ // hitTestScene
+ newGrResId = hitTestScene(_cursor->x(), _cursor->y(), type);
+ if (newGrResId != -1) {
+ warning ("Can't set mouse cursor, field_D6AC8 not handled ... yet");
+ // TODO
+ // check if _ws->field_D6AC8[act->field_638] != newGrResId
+ // if false, set mouse cursor
+ } else {
+ // TODO _ws->field_D6B08 stuff, then set cursor
+ warning ("Can't set mouse cursor, field_D6B08 not handled ... yet");
+ }
+ }
+ return; // return result;
+ }
+ newGrResId = hitTest(_cursor->x(), _cursor->y(), type);
+ if (_cursor->x() >= rect.left && _cursor->x() <= rlimit &&
+ _cursor->y() >= rect.top && _cursor->y() <= rect.bottom &&
+ hitTestActor(_cursor->x(), _cursor->y())) {
+ if (act->reaction[0]) {
+ if (_cursor->grResId != _ws->commonRes.curGrabPointer) {
+ warning ("Changing Cursor to curGrabPointer");
+ // TODO setMouseCursor
+ }
+ return;
+ }
+ }
+ if (newGrResId != -1) {
+ if (_ws->numChapter != 2 || _playerActorIdx != 10) {
+ if (_cursor->grResId != _ws->commonRes.curMagnifyingGlass) { // TODO || _cursor->flags)
+ warning ("Changing Cursor to curMagnifying Glass");
+ // TODO setMouseCursor
+ }
+ } else {
+ if (_cursor->grResId != _ws->commonRes.curTalkNPC2) { // TODO || _cursor->flags)
+ warning ("Changing Cursor to curTalkNPC2");
+ // TODO setMouseCursor
+ }
+ }
+ } else {
+ switch (type) {
+ case kHitActionArea:
+ warning ("Cursor = kHitActionArea");
+ break;
+ case kHitBarrier:
+ warning ("Cursor = kHitBarrier");
+ break;
+ case kHitActor:
+ warning ("Cursor = kHitActor");
+ break;
+ default:
+ // TODO LOBYTE(hitType)
+ break;
+ }
+
+ // TODO
+ // Handle the various switches and change the mouse cursor
+ // accordingly. I'm not 100% sure that this can't be done
+ // directly in each case, as the disassembly shows the need
+ // to compare the lobyte first, then take the appropriate action
+ }
+ }
+
+
+}
+
+int32 Scene::hitTestBarrier(int32 x, int32 y) {
+ int32 targetIdx = -1;
+ for (int32 i = 0; i < _ws->numBarriers; i++) {
+ Barrier b = _ws->barriers[i];
+ if (_ws->isBarrierOnScreen(i))
+ if (b.polyIdx)
+ if (hitTestPixel(b.resId, b.frameIdx, x, y, b.flags & 0x1000)) {
+ targetIdx = i;
+ break;
+ }
+ }
+ return targetIdx;
+}
+
+int32 Scene::hitTest(int32 x, int32 y, HitType &type) {
+ type = kHitNone;
+ int32 targetIdx = hitTestBarrier(x, y);
+ if (targetIdx == -1) {
+ targetIdx = hitTestActionArea(x, y);
+ if (targetIdx == -1) {
+ targetIdx = hitTestActor(x, y);
+ if (targetIdx != -1)
+ type = kHitActor;
+ } else {
+ type = kHitActionArea;
+ }
+ } else {
+ type = kHitBarrier;
+ }
+ return targetIdx;
+}
+
+int32 Scene::hitTestActionArea(int32 x, int32 y) {
+ int32 targetIdx = findActionArea(_ws->xLeft + x, _ws->yTop + y);
+
+ // TODO
+ // if ( result == -1 || !(LOBYTE(scene.actionAreas[result].flags2) & 0x17) )
+ // targetIdx = -1
+ // This won't work becase I can't remember what flags2 is at the moment :P
+
+ return targetIdx;
+}
+
+int32 Scene::findActionArea(int32 pointX, int32 pointY) {
+ // TODO
+ // This is a VERY loose implementation of the target
+ // function, as this doesn't do any of the flag checking
+ // the original did
+ int32 targetIdx = -1;
+ for (int32 i = 0; i < _ws->numActions; i++) {
+ ActionArea a = _ws->actions[i];
+ PolyDefinitions p = _polygons->entries[a.polyIdx];
+ if (p.contains(pointX, pointY)) {
+ targetIdx = i;
+ break;
+ }
+ }
+ return targetIdx;
+}
+
+int32 Scene::hitTestScene(int16 x, int16 y, HitType &type) {
+ int32 top = x + _ws->xLeft;
+ int32 left = y + _ws->yTop;
+ type = kHitNone;
+
+ int32 result = findActionArea(top, left);
+
+ if (result != -1) {
+ if (LOBYTE(_ws->actions[result].actionType) & 8) {
+ type = kHitActionArea;
+ return result;
+ }
+ }
+
+ // TODO barrier and actor checks
+
+ return result;
+}
+
+bool Scene::hitTestActor(int16 x, int16 y) {
+ Actor *act = getActor();
+ Common::Point pt;
+ getActorPosition(act, &pt);
+
+ int32 hitFrame;
+ if (act->frameNum >= act->frameCount)
+ hitFrame = 2 * act->frameNum - act->frameCount - 1;
+ else
+ hitFrame = act->frameNum;
+
+ return hitTestPixel(act->grResId,
+ hitFrame,
+ x - act->x - pt.x,
+ y - act->y - pt.y,
+ (act->direction >= 0));
+}
+
+bool Scene::hitTestPixel(int32 grResId, int32 frame, int16 x, int16 y, bool flipped) {
+ GraphicResource *gra = new GraphicResource(_resPack, grResId);
+ GraphicFrame *fra = gra->getFrame(frame);
+
+ // TODO this gets a bit funky with the "flipped" calculations for x intersection
+ // The below is a pretty basic intersection test for proof of concept
+
+ Common::Rect rect;
+ rect.top = fra->x;
+ rect.left = fra->y;
+ rect.right = fra->x + fra->surface.w;
+ rect.bottom = fra->y + fra->surface.h;
+
+ delete gra;
+
+ return rect.contains(x, y);
+}
+
void Scene::updateActor(int32 actorIdx) {
Actor *actor = getActor();
diff --git a/engines/asylum/scene.h b/engines/asylum/scene.h
index ac84c64425..acc477fd93 100644
--- a/engines/asylum/scene.h
+++ b/engines/asylum/scene.h
@@ -54,6 +54,13 @@ struct BarrierItem;
class WorldStats;
class Speech;
+enum HitType {
+ kHitNone = -1,
+ kHitActionArea = 2,
+ kHitBarrier = 3,
+ kHitActor = 4
+};
+
class SceneTitle {
public:
SceneTitle(Scene *scene);
@@ -111,6 +118,10 @@ public:
ActionList* actions() { return _actions; }
Speech* speech() { return _speech; }
+ /** .text:0040A1B0
+ * Get the supplied actor's position relative to the
+ * current scene's xLeft and yTop
+ */
void getActorPosition(Actor *actor, Common::Point *pt);
/**
* Return the index of the current player actor
@@ -139,12 +150,53 @@ public:
* graphic resource matches the resource at grResTable[5]
*/
bool defaultActorDirectionLoaded(int actorIndex, int grResTableIdx);
+ /** .text:00407A00
+ * TODO
+ */
+ void setActorDirection(Actor *act, int direction);
+
/** .text:004094c0
* Determine the amount to increase the supplied sound
* sample's volume based on the actor's position
*/
int32 calculateVolumeAdjustment(AmbientSoundItem *snd, Actor *act);
+protected:
+ /** .text:0040EA50
+ * Run various hit tests and return the index,
+ * and a reference to the located type
+ */
+ int32 hitTest(int32 x, int32 y, HitType &type);
+ /** .text:0040F010
+ * TODO
+ */
+ int32 hitTestActionArea(int32 x, int32 y);
+ /** .text:0040E7F0
+ * Check if the mouse cursor is currently intersecting
+ * the currently active actor
+ */
+ bool hitTestActor(int16 x, int16 y);
+ /** .text:004341E0
+ * Check if the mouse cursor is currently intersecting
+ * a graphic resource at the supplied coordinates
+ */
+ bool hitTestPixel(int32 grResId, int32 frame, int16 x, int16 y, bool flipped);
+ /** .text:0040E8A0
+ * Checks if the supplied coordinates are inside an action area, barrier or
+ * actor, and returns -1 if nothing was found, or the type of hit if found
+ */
+ int32 hitTestScene(int16 x, int16 y, HitType &type);
+ /** .text:00408980
+ * Determine if the supplied point intersects
+ * an action area's active region
+ */
+ int32 findActionArea(int32 pointX, int32 pointY);
+ /** .text:0040EAA0
+ * Check if a barrier exist at the supplied coordinates.
+ * If so, return it's index within the barriers array, if not,
+ * return -1
+ */
+ int32 hitTestBarrier(int32 x, int32 y);
private:
AsylumEngine *_vm;
Common::Event *_ev;
@@ -184,6 +236,10 @@ private:
* TODO add description
*/
void updateMouse();
+ /** .text:0040D580
+ * TODO
+ */
+ void handleMouseUpdate(int direction, Common::Rect rect);
/** .text:0040B740
* TODO add description
*/
diff --git a/engines/asylum/worldstats.cpp b/engines/asylum/worldstats.cpp
index 741086b5d0..b4e714b9d0 100644
--- a/engines/asylum/worldstats.cpp
+++ b/engines/asylum/worldstats.cpp
@@ -142,9 +142,9 @@ void WorldStats::load(Common::SeekableReadStream *stream) {
commonRes.curScrollUpRight = stream->readSint32LE();
commonRes.curHand = stream->readSint32LE();
commonRes.curMagnifyingGlass = stream->readSint32LE();
- commonRes.curTalkNCP = stream->readSint32LE();
+ commonRes.curTalkNPC = stream->readSint32LE();
commonRes.curGrabPointer = stream->readSint32LE();
- commonRes.curTalkNCP2 = stream->readSint32LE();
+ commonRes.curTalkNPC2 = stream->readSint32LE();
commonRes.font1 = stream->readSint32LE();
commonRes.font2 = stream->readSint32LE();
commonRes.font3 = stream->readSint32LE();
diff --git a/engines/asylum/worldstats.h b/engines/asylum/worldstats.h
index 1c9505b35b..44b0f3a0cf 100644
--- a/engines/asylum/worldstats.h
+++ b/engines/asylum/worldstats.h
@@ -48,9 +48,9 @@ typedef struct CommonResources {
int32 curScrollUpRight;
int32 curHand;
int32 curMagnifyingGlass;
- int32 curTalkNCP;
+ int32 curTalkNPC;
int32 curGrabPointer;
- int32 curTalkNCP2;
+ int32 curTalkNPC2;
int32 font1;
int32 font2;
int32 font3;
@@ -97,15 +97,15 @@ public:
int32 size;
int32 numEntries;
int32 numChapter;
- int32 xLeft; // scene start x position
- int32 yTop; // scene start y position
+ int32 xLeft; // scene start x position
+ int32 yTop; // scene start y position
Common::Rect boundingRect;
- CommonResources commonRes; // field_1C till field_7C
- int32 width; // field_80
+ CommonResources commonRes; // field_1C till field_7C
+ int32 width; // field_80
int32 height;
int32 motionStatus;
int32 field_8C;
- int32 numActions; // field_90
+ int32 numActions; // field_90
int32 numBarriers;
int32 targetX;
int32 targetY;
@@ -116,7 +116,7 @@ public:
int32 field_B0;
int32 numActors;
int32 stereoReversedFlag;
- Common::Rect sceneRects[6]; // including scene size rect
+ Common::Rect sceneRects[6]; // including scene size rect
uint8 sceneRectIdx;
uint8 field_11D[3];
int32 field_120;
Commit: efa59ec92a02eb2d9d2d40abdf46de7ec2612d89
https://github.com/scummvm/scummvm/commit/efa59ec92a02eb2d9d2d40abdf46de7ec2612d89
Author: Alex Bevilacqua (alexbevi at gmail.com)
Date: 2021-05-17T15:35:59+02:00
Commit Message:
ASYLUM: Removed the commonRes struct from Worldstats, as there's really no need for it to be an entity unto itself. Rolled those struct members into worldstats where they belong.
Also split actionarea out into it's own class. This is just for logical seperation at the moment.
Finally, deleted the OLD_UPDATE from the scene. There's also a bug in the update() logic where left-clicking causes the barrier animations to referesh when they shouldn't (added a comment for now).
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@418 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
A engines/asylum/actionarea.cpp
A engines/asylum/actionarea.h
engines/asylum/asylum.vcproj
engines/asylum/cursor.cpp
engines/asylum/cursor.h
engines/asylum/module.mk
engines/asylum/scene.cpp
engines/asylum/scene.h
engines/asylum/speech.cpp
engines/asylum/worldstats.cpp
engines/asylum/worldstats.h
diff --git a/engines/asylum/actionarea.cpp b/engines/asylum/actionarea.cpp
new file mode 100644
index 0000000000..2c18b7e701
--- /dev/null
+++ b/engines/asylum/actionarea.cpp
@@ -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.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#include "asylum/actionarea.h"
+
+namespace Asylum {
+
+ActionArea::ActionArea() {
+ // TODO Auto-generated constructor stub
+
+}
+
+ActionArea::~ActionArea() {
+ // TODO Auto-generated destructor stub
+}
+
+} // end of namespace Asylum
diff --git a/engines/asylum/actionarea.h b/engines/asylum/actionarea.h
new file mode 100644
index 0000000000..22dd07bf11
--- /dev/null
+++ b/engines/asylum/actionarea.h
@@ -0,0 +1,63 @@
+/* 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.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#ifndef ASYLUM_ACTIONAREA_H_
+#define ASYLUM_ACTIONAREA_H_
+
+#include "common/array.h"
+
+namespace Asylum {
+
+class ActionArea {
+public:
+ ActionArea();
+ virtual ~ActionArea();
+
+ char name[52];
+ int32 id;
+ int32 field01;
+ int32 field02;
+ int32 field_40;
+ int32 field_44;
+ int32 flags;
+ int32 actionListIdx1;
+ int32 actionListIdx2;
+ int32 actionType; // aka flags2: 0-none, 1-findwhat, 2-talk, 3-findwhat??, 4-grab
+ int32 flagNums[10];
+ int32 field_7C;
+ int32 polyIdx;
+ int32 field_84;
+ int32 field_88;
+ int32 soundResId;
+ int32 field_90;
+ int32 paletteValue;
+ int32 array[5];
+ int32 volume;
+
+}; // end of class ActionArea
+
+} // end of namespace Asylum
+
+#endif /* ASYLUM_ACTIONAREA_H_ */
diff --git a/engines/asylum/asylum.vcproj b/engines/asylum/asylum.vcproj
index 459621470b..8bd62c3427 100644
--- a/engines/asylum/asylum.vcproj
+++ b/engines/asylum/asylum.vcproj
@@ -16,6 +16,8 @@
<Configuration Name="Release|Win32" ConfigurationType="4" InheritedPropertySheets=".\ScummVM_Release.vsprops" />
</Configurations>
<Files>
+ <File RelativePath="..\..\engines\asylum\actionarea.cpp" />
+ <File RelativePath="..\..\engines\asylum\actionarea.h" />
<File RelativePath="..\..\engines\asylum\actionlist.cpp" />
<File RelativePath="..\..\engines\asylum\actionlist.h" />
<File RelativePath="..\..\engines\asylum\actor.cpp" />
diff --git a/engines/asylum/cursor.cpp b/engines/asylum/cursor.cpp
index a758367705..ae6bbdc654 100644
--- a/engines/asylum/cursor.cpp
+++ b/engines/asylum/cursor.cpp
@@ -28,6 +28,8 @@
namespace Asylum {
+const uint32 CURSOR_UPDATE_TICKS = 100;
+
Cursor::Cursor(ResourcePack *res) {
_resPack = res;
_mouseX = 0;
@@ -87,34 +89,34 @@ void Cursor::animate() {
set(_curFrame);
}
-void Cursor::update(CommonResources *cr, int32 currentAction) {
+void Cursor::update(WorldStats *ws, int32 currentAction) {
uint32 newCursor = 0;
// Change cursor
switch (currentAction) {
case kWalkN:
- newCursor = cr->curScrollUp;
+ newCursor = ws->curScrollUp;
break;
case kWalkNE:
- newCursor = cr->curScrollUpRight;
+ newCursor = ws->curScrollUpRight;
break;
case kWalkNW:
- newCursor = cr->curScrollUpLeft;
+ newCursor = ws->curScrollUpLeft;
break;
case kWalkS:
- newCursor = cr->curScrollDown;
+ newCursor = ws->curScrollDown;
break;
case kWalkSE:
- newCursor = cr->curScrollDownRight;
+ newCursor = ws->curScrollDownRight;
break;
case kWalkSW:
- newCursor = cr->curScrollDownLeft;
+ newCursor = ws->curScrollDownLeft;
break;
case kWalkW:
- newCursor = cr->curScrollLeft;
+ newCursor = ws->curScrollLeft;
break;
case kWalkE:
- newCursor = cr->curScrollRight;
+ newCursor = ws->curScrollRight;
break;
}
diff --git a/engines/asylum/cursor.h b/engines/asylum/cursor.h
index e84ef3e729..d74da89e86 100644
--- a/engines/asylum/cursor.h
+++ b/engines/asylum/cursor.h
@@ -31,7 +31,7 @@
namespace Asylum {
-struct CommonResources;
+class WorldStats;
/**
* Asylum cursors are GraphicResources, and are stored in
@@ -71,7 +71,7 @@ public:
* TODO this probably doesn't belong here, but on the
* scene, where it originally was
*/
- void update(CommonResources *cr, int32 currentAction);
+ void update(WorldStats *ws, int32 currentAction);
/**
* Get the next logical frame from the currently loaded
* cursorResource and draw it
@@ -124,6 +124,10 @@ private:
int32 _mouseX;
int32 _mouseY;
+ // The number of millis between
+ // cursor gfx updates
+ uint32 _cursorTicks;
+
}; // end of class Cursor
} // end of namespace Asylum
diff --git a/engines/asylum/module.mk b/engines/asylum/module.mk
index e444c8b8ca..cb6a2dab1d 100644
--- a/engines/asylum/module.mk
+++ b/engines/asylum/module.mk
@@ -1,6 +1,7 @@
MODULE := engines/asylum
MODULE_OBJS := \
+ actionarea.o \
actionlist.o \
actor.o \
asylum.o \
diff --git a/engines/asylum/scene.cpp b/engines/asylum/scene.cpp
index c107d16d2e..b4b936efb7 100644
--- a/engines/asylum/scene.cpp
+++ b/engines/asylum/scene.cpp
@@ -75,13 +75,13 @@ Scene::Scene(uint8 sceneIdx, AsylumEngine *engine): _vm(engine) {
// TODO
// This will have to be re-initialized elsewhere due to
// the title screen overwriting the font
- _vm->text()->loadFont(_resPack, _ws->commonRes.font1);
+ _vm->text()->loadFont(_resPack, _ws->font1);
char musPackFileName[10];
sprintf(musPackFileName, MUSIC_FILE_MASK, sceneIdx);
_musPack = new ResourcePack(musPackFileName);
- _bgResource = new GraphicResource(_resPack, _ws->commonRes.backgroundImage);
+ _bgResource = new GraphicResource(_resPack, _ws->backgroundImage);
_blowUp = 0;
_cursor = new Cursor(_resPack);
_background = 0;
@@ -125,11 +125,11 @@ void Scene::initialize() {
}
}
- _cursor->load(_ws->commonRes.curMagnifyingGlass);
+ _cursor->load(_ws->curMagnifyingGlass);
_cursor->set(0);
// FIXME this is just here for testing
- _cursor->grResId = _ws->commonRes.curMagnifyingGlass;
+ _cursor->grResId = _ws->curMagnifyingGlass;
_ws->sceneRectIdx = 0;
_vm->screen()->clearScreen(); // XXX was clearGraphicsInQueue()
@@ -168,7 +168,7 @@ void Scene::initialize() {
_vm->screen()->clearScreen();
// TODO loadTransTables(3, field_64/68/7C)
// TODO setTransTable(1)
- _vm->text()->loadFont(_resPack, _ws->commonRes.font1);
+ _vm->text()->loadFont(_resPack, _ws->font1);
// TODO preloadGraphics() .text:00410F10
// TODO sound_sub(sceneNumber) .text:0040E750
_ws->actorType = actorType[_ws->numChapter];
@@ -389,7 +389,7 @@ void Scene::enterScene() {
_actions->allowInput = false;
} else {
#endif
- _vm->screen()->setPalette(_resPack, _ws->commonRes.palette);
+ _vm->screen()->setPalette(_resPack, _ws->palette);
_background = _bgResource->getFrame(0);
_vm->screen()->copyToBackBuffer(
((byte *)_background->surface.pixels) + _ws->yTop * _background->surface.w + _ws->xLeft, _background->surface.w,
@@ -400,7 +400,7 @@ void Scene::enterScene() {
// when the scene is started. Check against the original to see
// when the cursor is initalized, and then how it reacts to the
// show_cursor opcode
- _cursor->load(_ws->commonRes.curMagnifyingGlass);
+ _cursor->load(_ws->curMagnifyingGlass);
_cursor->set(0);
_cursor->show();
@@ -451,7 +451,7 @@ void Scene::handleEvent(Common::Event *event, bool doUpdate) {
// TODO This isn't always going to be the magnifying glass
// Should check the current pointer region to identify the type
// of cursor to use
- _cursor->load(_ws->commonRes.curMagnifyingGlass);
+ _cursor->load(_ws->curMagnifyingGlass);
_rightButton = false;
}
break;
@@ -466,7 +466,10 @@ void Scene::handleEvent(Common::Event *event, bool doUpdate) {
}
- if (doUpdate || _leftClick)
+ // FIXME just updating because a left click event
+ // is caught causes animation speeds to change. This needs
+ // to be addressed
+ if (doUpdate) // || _leftClick)
update();
}
@@ -493,15 +496,15 @@ void Scene::update() {
//TODO: other process stuffs from sub 0040AE30
- if (_speech->_soundResIdx != 0) {
- if (_vm->sound()->isPlaying(_speech->_soundResIdx)) {
- _speech->prepareSpeech();
- } else {
- _speech->_textResIdx = 0;
- _speech->_soundResIdx = 0;
- _vm->clearGameFlag(219);
- }
- }
+ if (_speech->_soundResIdx != 0) {
+ if (_vm->sound()->isPlaying(_speech->_soundResIdx)) {
+ _speech->prepareSpeech();
+ } else {
+ _speech->_textResIdx = 0;
+ _speech->_soundResIdx = 0;
+ _vm->clearGameFlag(219);
+ }
+}
}
int Scene::updateScene() {
@@ -758,8 +761,8 @@ void Scene::handleMouseUpdate(int direction, Common::Rect rect) {
HitType type = kHitNone;
// TODO if encounter_flag03
- if (0 && _cursor->grResId != _ws->commonRes.curTalkNPC) {
- // TODO setMouseCursor(_ws->commonRes.curTalkNPC);
+ if (0 && _cursor->grResId != _ws->curTalkNPC) {
+ // TODO setMouseCursor(_ws->curTalkNPC);
}
Actor *act = getActor(); // get the player actor reference
@@ -767,7 +770,7 @@ void Scene::handleMouseUpdate(int direction, Common::Rect rect) {
if (_cursor->field_11 & 2) {
if (act->updateType == 1 || act->updateType == 12) {
if (direction >= 0) {
- newGrResId = _ws->commonRes.curScrollUp + direction;
+ newGrResId = _ws->curScrollUp + direction;
if (_cursor->grResId != newGrResId) {
// TODO setMouseCursor(newGrResId);
warning("%d", newGrResId);
@@ -777,7 +780,7 @@ void Scene::handleMouseUpdate(int direction, Common::Rect rect) {
}
if (act->updateType == 6 || act->updateType == 10) {
- newGrResId = _ws->commonRes.curHand;
+ newGrResId = _ws->curHand;
if (_cursor->grResId != newGrResId) {
// TODO setMouseCursor(newGrResId);
warning("%d", newGrResId);
@@ -815,7 +818,7 @@ void Scene::handleMouseUpdate(int direction, Common::Rect rect) {
_cursor->y() >= rect.top && _cursor->y() <= rect.bottom &&
hitTestActor(_cursor->x(), _cursor->y())) {
if (act->reaction[0]) {
- if (_cursor->grResId != _ws->commonRes.curGrabPointer) {
+ if (_cursor->grResId != _ws->curGrabPointer) {
warning ("Changing Cursor to curGrabPointer");
// TODO setMouseCursor
}
@@ -824,12 +827,12 @@ void Scene::handleMouseUpdate(int direction, Common::Rect rect) {
}
if (newGrResId != -1) {
if (_ws->numChapter != 2 || _playerActorIdx != 10) {
- if (_cursor->grResId != _ws->commonRes.curMagnifyingGlass) { // TODO || _cursor->flags)
+ if (_cursor->grResId != _ws->curMagnifyingGlass) { // TODO || _cursor->flags)
warning ("Changing Cursor to curMagnifying Glass");
// TODO setMouseCursor
}
} else {
- if (_cursor->grResId != _ws->commonRes.curTalkNPC2) { // TODO || _cursor->flags)
+ if (_cursor->grResId != _ws->curTalkNPC2) { // TODO || _cursor->flags)
warning ("Changing Cursor to curTalkNPC2");
// TODO setMouseCursor
}
@@ -1492,109 +1495,6 @@ void Scene::updateAdjustScreen() {
*/
}
-
-void Scene::OLD_UPDATE() {
- int32 curHotspot = -1;
- int32 curBarrier = -1;
-
- // DEBUGGING
- // Check current walk region
- for (int32 a = 0; a < _ws->numActions; a++) {
- if (_ws->actions[a].actionType == 0) {
- ActionArea *area = &_ws->actions[a];
- PolyDefinitions poly = _polygons->entries[area->polyIdx];
- if (poly.contains(getActor()->x, getActor()->y)) {
- debugShowWalkRegion(&poly);
- //break;
- }
- }
- }
-
- if (!_rightButton) {
- if (_ws->actors[0].flags & 0x01) { // TESTING - only draw if visible flag
- // Check if the character was walking before the right-button
- // was released. If so, change the resource to one where he/she
- // is standing still, facing the last active direction
- if (_walking) {
- if (getActor()->currentAction > 0)
- getActor()->setAction(getActor()->currentAction + 5);
- _walking = false;
- }
- getActor()->drawActor();
- }
- } else {
- _walking = true;
-
- getActor()->walkTo(_cursor->x(), _cursor->y());
- _cursor->update(&_ws->commonRes, getActor()->direction);
- }
-
-
-
- // Check if we're within a barrier
- for (int32 p = 0; p < _ws->numBarriers; p++) {
- Barrier b = _ws->barriers[p];
- if (b.flags & 0x20) {
- if ((b.boundingRect.left + b.x <= _cursor->x() + _ws->targetX) &&
- (_cursor->x() + _ws->targetX < b.boundingRect.right + b.x) &&
- (b.boundingRect.top + b.y <= _cursor->y() + _ws->targetY) &&
- (_cursor->y() + _ws->targetY < b.boundingRect.bottom + b.y)) {
- _cursor->animate();
- curBarrier = (int32)p;
- break;
- }
- }
- }
-
- // FIXME? I'm assigning a higher priority to barriers than polygons. I'm assuming
- // that barriers that overlap polygons will have actions associated with them, and
- // the polygon will be part of a walk/look region (so it's accessible elsewhere).
- // This could be completely wrong, and if so, we just have to check to see which
- // of the barrier/polygon action scripts should be processed first
- if (curBarrier < 0) {
- // Update cursor if it's in a polygon hotspot
- for (int32 p = 0; p < _polygons->numEntries; p++) {
- PolyDefinitions poly = _polygons->entries[p];
- if (poly.boundingRect.contains(_cursor->x() + _ws->targetX, _cursor->y() + _ws->targetY)) {
- if (poly.contains(_cursor->x() + _ws->targetX, _cursor->y() + _ws->targetY)) {
- curHotspot = (int32)p;
- _cursor->animate();
- break;
- }
- }
- }
- }
-
- if (_leftClick) {
- _leftClick = false;
-
- if (curHotspot >= 0) {
- for (int32 a = 0; a < _ws->numActions; a++) {
- if (_ws->actions[a].polyIdx == curHotspot) {
- debugC(kDebugLevelScripts, "Hotspot: 0x%X - \"%s\", poly %d, action lists %d/%d, action type %d, sound res %d\n",
- _ws->actions[a].id,
- _ws->actions[a].name,
- _ws->actions[a].polyIdx,
- _ws->actions[a].actionListIdx1,
- _ws->actions[a].actionListIdx2,
- _ws->actions[a].actionType,
- _ws->actions[a].soundResId);
- // FIXME _actions->setScriptByIndex(_ws->actions[a].actionListIdx1);
- }
- }
- } else if (curBarrier >= 0) {
- Barrier b = _ws->barriers[curBarrier];
- debugC(kDebugLevelScripts, "%s: action(%d) sound(%d) flags(%d/%d)\n",
- b.name,
- b.actionListIdx,
- b.soundResId,
- b.flags,
- b.flags2);
- // FIXME _actions->setScriptByIndex(b.actionListIdx);
- }
- }
-}
-
// ----------------------------------
// ---------- DRAW REGION -----------
// ----------------------------------
@@ -1610,11 +1510,11 @@ int Scene::drawScene() {
GraphicFrame *bg = _bgResource->getFrame(0);
_vm->screen()->copyToBackBuffer(
- ((byte *)bg->surface.pixels) + _ws->yTop * bg->surface.w + _ws->xLeft, bg->surface.w,
- 0,
- 0,
- 640,
- 480);
+ ((byte *)bg->surface.pixels) + _ws->yTop * bg->surface.w + _ws->xLeft, bg->surface.w,
+ 0,
+ 0,
+ 640,
+ 480);
drawActorsAndBarriers();
queueActorUpdates();
@@ -1623,9 +1523,6 @@ int Scene::drawScene() {
// TODO: draw main actor stuff
_vm->screen()->drawGraphicsInQueue();
-
- // TODO: we must get rid of this
- //OLD_UPDATE();
}
return 1;
@@ -1818,7 +1715,7 @@ int Scene::queueBarrierUpdates() {
_vm->screen()->addGraphicToQueue(barrier->resId, barrier->frameIdx, barrier->x, barrier->y, (barrier->flags >> 11) & 2, barrier->field_67C - 3, barrier->priority);
} else {
// TODO: Do Cross Fade
- // parameters: barrier->resId, barrier->frameIdx, barrier->x, barrier->y, _ws->commonRes.backgroundImage, _ws->xLeft, _ws->yTop, 0, 0, barrier->field_67C - 1
+ // parameters: barrier->resId, barrier->frameIdx, barrier->x, barrier->y, _ws->backgroundImage, _ws->xLeft, _ws->yTop, 0, 0, barrier->field_67C - 1
_vm->screen()->addGraphicToQueue(barrier->resId, barrier->frameIdx, barrier->x, barrier->y, 0, 0, 0);
}
}
diff --git a/engines/asylum/scene.h b/engines/asylum/scene.h
index acc477fd93..448b927e1c 100644
--- a/engines/asylum/scene.h
+++ b/engines/asylum/scene.h
@@ -75,12 +75,12 @@ private:
GraphicResource *_bg;
GraphicResource *_progress;
- int32 _start;
- int32 _ticks;
- bool _done;
+ int32 _start;
+ int32 _ticks;
+ bool _done;
uint32 _spinnerFrame;
- int32 _spinnerProgress;
- bool _showMouseState;
+ int32 _spinnerProgress;
+ bool _showMouseState;
}; // end of class SceneTitle
@@ -283,9 +283,6 @@ private:
void debugShowActors();
void debugShowWalkRegion(PolyDefinitions *poly);
- // TODO: get rid of this
- void OLD_UPDATE();
-
friend class SceneTitle;
}; // end of class Scene
diff --git a/engines/asylum/speech.cpp b/engines/asylum/speech.cpp
index 5cf5477a96..b61b51a13f 100644
--- a/engines/asylum/speech.cpp
+++ b/engines/asylum/speech.cpp
@@ -112,10 +112,10 @@ void Speech::prepareSpeech() {
check = pt->y >= 240;*/
int32 posY = ((check - 1) & 0x118) + 40;
- _scene->vm()->text()->loadFont(_scene->getResourcePack(), _scene->worldstats()->commonRes.font3);
+ _scene->vm()->text()->loadFont(_scene->getResourcePack(), _scene->worldstats()->font3);
_scene->vm()->text()->drawText(20, posY, _textDataPos);
- _scene->vm()->text()->loadFont(_scene->getResourcePack(), _scene->worldstats()->commonRes.font1);
+ _scene->vm()->text()->loadFont(_scene->getResourcePack(), _scene->worldstats()->font1);
_scene->vm()->text()->drawText(20, posY, _textData);
}
}
@@ -137,7 +137,7 @@ void Speech::processSpeech() {
_textData = txt + 3;
_textDataPos = 0;
- _scene->vm()->text()->loadFont(_scene->getResourcePack(), _scene->worldstats()->commonRes.font1);
+ _scene->vm()->text()->loadFont(_scene->getResourcePack(), _scene->worldstats()->font1);
_scene->vm()->sound()->playSpeech(_soundResIdx);
} else {
_textData = 0;
@@ -147,7 +147,7 @@ void Speech::processSpeech() {
_textDataPos = txt + 2;
}
- _scene->vm()->text()->loadFont(_scene->getResourcePack(), _scene->worldstats()->commonRes.font3);
+ _scene->vm()->text()->loadFont(_scene->getResourcePack(), _scene->worldstats()->font3);
_scene->vm()->sound()->playSpeech(_soundResIdx);
}
}
diff --git a/engines/asylum/worldstats.cpp b/engines/asylum/worldstats.cpp
index b4e714b9d0..b3d84f8157 100644
--- a/engines/asylum/worldstats.cpp
+++ b/engines/asylum/worldstats.cpp
@@ -131,31 +131,31 @@ void WorldStats::load(Common::SeekableReadStream *stream) {
boundingRect.bottom = stream->readSint32LE() & 0xFFFF;
// read common graphic resources
- commonRes.backgroundImage = stream->readSint32LE();
- commonRes.curScrollUp = stream->readSint32LE();
- commonRes.curScrollUpLeft = stream->readSint32LE();
- commonRes.curScrollLeft = stream->readSint32LE();
- commonRes.curScrollDownLeft = stream->readSint32LE();
- commonRes.curScrollDown = stream->readSint32LE();
- commonRes.curScrollDownRight = stream->readSint32LE();
- commonRes.curScrollRight = stream->readSint32LE();
- commonRes.curScrollUpRight = stream->readSint32LE();
- commonRes.curHand = stream->readSint32LE();
- commonRes.curMagnifyingGlass = stream->readSint32LE();
- commonRes.curTalkNPC = stream->readSint32LE();
- commonRes.curGrabPointer = stream->readSint32LE();
- commonRes.curTalkNPC2 = stream->readSint32LE();
- commonRes.font1 = stream->readSint32LE();
- commonRes.font2 = stream->readSint32LE();
- commonRes.font3 = stream->readSint32LE();
- commonRes.palette = stream->readSint32LE();
- commonRes.cellShadeMask1 = stream->readSint32LE();
- commonRes.cellShadeMask2 = stream->readSint32LE();
- commonRes.cellShadeMask3 = stream->readSint32LE();
- commonRes.unused = stream->readSint32LE();
- commonRes.smallCurUp = stream->readSint32LE();
- commonRes.smallCurDown = stream->readSint32LE();
- commonRes.encounterFrameBg = stream->readSint32LE();
+ backgroundImage = stream->readSint32LE();
+ curScrollUp = stream->readSint32LE();
+ curScrollUpLeft = stream->readSint32LE();
+ curScrollLeft = stream->readSint32LE();
+ curScrollDownLeft = stream->readSint32LE();
+ curScrollDown = stream->readSint32LE();
+ curScrollDownRight = stream->readSint32LE();
+ curScrollRight = stream->readSint32LE();
+ curScrollUpRight = stream->readSint32LE();
+ curHand = stream->readSint32LE();
+ curMagnifyingGlass = stream->readSint32LE();
+ curTalkNPC = stream->readSint32LE();
+ curGrabPointer = stream->readSint32LE();
+ curTalkNPC2 = stream->readSint32LE();
+ font1 = stream->readSint32LE();
+ font2 = stream->readSint32LE();
+ font3 = stream->readSint32LE();
+ palette = stream->readSint32LE();
+ cellShadeMask1 = stream->readSint32LE();
+ cellShadeMask2 = stream->readSint32LE();
+ cellShadeMask3 = stream->readSint32LE();
+ unused = stream->readSint32LE();
+ smallCurUp = stream->readSint32LE();
+ smallCurDown = stream->readSint32LE();
+ encounterFrameBg = stream->readSint32LE();
width = stream->readSint32LE();
height = stream->readSint32LE();
@@ -404,7 +404,6 @@ void WorldStats::load(Common::SeekableReadStream *stream) {
// FIXME Figure out all the actions items
for (int32 a = 0; a < numActions; a++) {
ActionArea action;
- memset(&action, 0, sizeof(ActionArea));
stream->read(action.name, 52);
action.id = stream->readSint32LE();
diff --git a/engines/asylum/worldstats.h b/engines/asylum/worldstats.h
index 44b0f3a0cf..25d6d09768 100644
--- a/engines/asylum/worldstats.h
+++ b/engines/asylum/worldstats.h
@@ -31,12 +31,23 @@
#include "asylum/actor.h"
#include "asylum/barrier.h"
+#include "asylum/actionarea.h"
#include "asylum/scene.h"
#include "asylum/sound.h"
namespace Asylum {
-typedef struct CommonResources {
+class WorldStats {
+public:
+ WorldStats(Common::SeekableReadStream *stream, Scene *scene);
+ virtual ~WorldStats();
+
+ int32 size;
+ int32 numEntries;
+ int32 numChapter;
+ int32 xLeft; // scene start x position
+ int32 yTop; // scene start y position
+ Common::Rect boundingRect;
int32 backgroundImage;
int32 curScrollUp;
int32 curScrollUpLeft;
@@ -62,45 +73,6 @@ typedef struct CommonResources {
int32 smallCurUp;
int32 smallCurDown;
int32 encounterFrameBg;
-
-} CommonResources;
-
-typedef struct ActionArea {
- char name[52];
- int32 id;
- int32 field01;
- int32 field02;
- int32 field_40;
- int32 field_44;
- int32 flags;
- int32 actionListIdx1;
- int32 actionListIdx2;
- int32 actionType; // aka flags2: 0-none, 1-findwhat, 2-talk, 3-findwhat??, 4-grab
- int32 flagNums[10];
- int32 field_7C;
- int32 polyIdx;
- int32 field_84;
- int32 field_88;
- int32 soundResId;
- int32 field_90;
- int32 paletteValue;
- int32 array[5];
- int32 volume;
-
-} ActionArea;
-
-class WorldStats {
-public:
- WorldStats(Common::SeekableReadStream *stream, Scene *scene);
- virtual ~WorldStats();
-
- int32 size;
- int32 numEntries;
- int32 numChapter;
- int32 xLeft; // scene start x position
- int32 yTop; // scene start y position
- Common::Rect boundingRect;
- CommonResources commonRes; // field_1C till field_7C
int32 width; // field_80
int32 height;
int32 motionStatus;
Commit: c0e8a9532e2422f513ad55f7af55da9f7f81b36f
https://github.com/scummvm/scummvm/commit/c0e8a9532e2422f513ad55f7af55da9f7f81b36f
Author: Filippos Karapetis (md5 at scummvm.org)
Date: 2021-05-17T15:35:59+02:00
Commit Message:
ASYLUM: ActionArea is a class, not a struct
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@419 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/actor.h
engines/asylum/console.h
diff --git a/engines/asylum/actor.h b/engines/asylum/actor.h
index f66dad6546..daf87fd59c 100644
--- a/engines/asylum/actor.h
+++ b/engines/asylum/actor.h
@@ -33,7 +33,7 @@ namespace Asylum {
class Scene;
class Screen;
-struct ActionArea;
+class ActionArea;
// TODO: check if the names match the actor type
enum ActorType {
diff --git a/engines/asylum/console.h b/engines/asylum/console.h
index a299bf0933..9df1a3445f 100644
--- a/engines/asylum/console.h
+++ b/engines/asylum/console.h
@@ -33,7 +33,7 @@
namespace Asylum {
class AsylumEngine;
-struct ActionArea;
+class ActionArea;
class Console : public GUI::Debugger {
public:
Commit: fadb6681e44385f404f69cd288bf165041837156
https://github.com/scummvm/scummvm/commit/fadb6681e44385f404f69cd288bf165041837156
Author: Alex Bevilacqua (alexbevi at gmail.com)
Date: 2021-05-17T15:35:59+02:00
Commit Message:
ASYLUM: updates to kDisableActor and kHideActor. Disabled kRunBlowUpPuzzle for now.
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@420 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/actionlist.cpp
diff --git a/engines/asylum/actionlist.cpp b/engines/asylum/actionlist.cpp
index e032f619fc..d62b1184bc 100644
--- a/engines/asylum/actionlist.cpp
+++ b/engines/asylum/actionlist.cpp
@@ -32,7 +32,7 @@ ActionList::ActionList(Common::SeekableReadStream *stream, Scene *scene)
: _scene(scene) {
load(stream);
- _currentScript = 0;
+ _currentScript = 0;
currentLine = 0;
currentLoops = 0;
delayedSceneIndex = -1;
@@ -375,9 +375,9 @@ int ActionList::process() {
_scene->getSceneIndex(),
currentLine);
- if (!lineIncrement) {
- currentLine ++;
- }
+ if (!lineIncrement) {
+ currentLine ++;
+ }
} // end while
@@ -596,16 +596,14 @@ int kMoveScenePosition(Script *script, ScriptEntry *cmd, Scene *scn) {
int kHideActor(Script *script, ScriptEntry *cmd, Scene *scn) {
Actor *actor = 0;
-
- // TODO better default actor handling
- if (cmd->param1 == -1)
- actor = scn->getActor();
- else
- actor = &scn->worldstats()->actors[cmd->param1];
+ actor = (cmd->param1 == -1) ?
+ scn->getActor() :
+ &scn->worldstats()->actors[cmd->param1];
actor->visible(false);
+ // TODO character_sub_401320(actor)
- return -3;
+ return -2;
}
int kShowActor(Script *script, ScriptEntry *cmd, Scene *scn) {
@@ -648,14 +646,36 @@ int kSetSceneMotionStat(Script *script, ScriptEntry *cmd, Scene *scn) {
}
int kDisableActor(Script *script, ScriptEntry *cmd, Scene *scn) {
- int actorIndex = cmd->param1;
-
- if (actorIndex == -1)
- actorIndex = scn->getActorIndex();
-
- scn->updateActorDirection(actorIndex, 5);
+ int32 actorIndex = (cmd->param1 == -1) ? 0 : cmd->param1;
+ Actor *act = scn->getActor(actorIndex);
+
+ if (cmd->param5 != 2) {
+ if (act->updateType != 2 && act->updateType != 13) {
+ if (cmd->param2 != -1 || cmd->param3 != -1)
+ scn->updateActorDirection(actorIndex, cmd->param4);
+ else {
+ if ((act->x1 + act->x2) != cmd->param2 ||
+ (act->y1 + act->y2) != cmd->param3) {
+ ; // TODO updatecharacter_sub_408910
+ // TODO if (cmd->param5)
+ // cmd->param5 = 2
+ // v245 = true
+ } else
+ scn->updateActorDirection(actorIndex, cmd->param4);
+ }
+ }
+ return -1;
+ }
- return 0;
+ if (act->updateType != 2 && act->updateType != 13) {
+ cmd->param5 = 1;
+ // v245 = false
+ if ((act->x1 + act->x2) != cmd->param2 ||
+ (act->y1 + act->y2) != cmd->param3) {
+ scn->updateActorDirection(actorIndex, cmd->param4);
+ }
+ }
+ return -1;
}
int kEnableActor(Script *script, ScriptEntry *cmd, Scene *scn) {
@@ -920,9 +940,9 @@ int k_unk36(Script *script, ScriptEntry *cmd, Scene *scn) {
int kRunBlowUpPuzzle(Script *script, ScriptEntry *cmd, Scene *scn) {
// FIXME: improve this to call other blowUpPuzzles than VCR
//int puzzleIdx = cmd->param1;
-
- scn->setBlowUpPuzzle(new BlowUpPuzzleVCR(scn));
- scn->getBlowUpPuzzle()->openBlowUp();
+ warning("kRunBlowUpPuzzle not implemented");
+ //scn->setBlowUpPuzzle(new BlowUpPuzzleVCR(scn));
+ //scn->getBlowUpPuzzle()->openBlowUp();
return -1;
}
Commit: d396b0daaebf98ceb9fbf35fd305e9c63133f745
https://github.com/scummvm/scummvm/commit/d396b0daaebf98ceb9fbf35fd305e9c63133f745
Author: Alex Bevilacqua (alexbevi at gmail.com)
Date: 2021-05-17T15:35:59+02:00
Commit Message:
ASYLUM: added updateSoundItems (from 0040D0E0)
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@421 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/barrier.cpp
engines/asylum/barrier.h
diff --git a/engines/asylum/barrier.cpp b/engines/asylum/barrier.cpp
index 90ade0d27c..b6509b5070 100644
--- a/engines/asylum/barrier.cpp
+++ b/engines/asylum/barrier.cpp
@@ -66,4 +66,21 @@ void Barrier::setNextFrame(int32 targetFlags) {
frameIdx = 0;
}
+void Barrier::updateSoundItems(Sound *snd) {
+ for (int32 i = 0; i < 16; i++) {
+ SoundItem *item = &soundItems[i];
+ if (snd->isPlaying(item->resId)) {
+ if (item->field_4) {
+ snd->stopSound(item->resId);
+ item->resId = 0;
+ item->field_4 = 0;
+ }
+ }
+ }
+
+ // FIXME Barrier::updateSoundItems needs to be followed by a
+ // call to Scene::stopSound(barIdx, 0). Since there aren't that
+ // many calls to this method, I'm leaving this comment as a reminder
+ // until all dependant methods are implemented
+}
} // end of namespace Asylum
diff --git a/engines/asylum/barrier.h b/engines/asylum/barrier.h
index 4eadc03c66..0b5ee4c5d0 100644
--- a/engines/asylum/barrier.h
+++ b/engines/asylum/barrier.h
@@ -44,6 +44,12 @@ public:
// TODO document this function
void setNextFrame(int flags);
+ /** .text:0040D0E0
+ * Check if any items in the barrier sound array are playing,
+ * and based on their flag values, stop them accordingly
+ */
+ void updateSoundItems(Sound *snd);
+
int32 id;
uint32 resId;
int32 x;
@@ -59,7 +65,7 @@ public:
int32 field_3C;
uint8 name[52];
int32 field_74; // XXX looks like fields
- int32 field_78; // 78 => 80 have something
+ int32 field_78; // 74 => 80 have something
int32 field_7C; // to do with calculating
int32 field_80; // actor intersection
int32 polyIdx;
Commit: a56c334e953c5715228de67a7c157eb71ad969a9
https://github.com/scummvm/scummvm/commit/a56c334e953c5715228de67a7c157eb71ad969a9
Author: Alex Bevilacqua (alexbevi at gmail.com)
Date: 2021-05-17T15:35:59+02:00
Commit Message:
ASYLUM: Implemented an unknown opcode (kClearActorField970). Also added stub for a kHideActor update that is not going to be used until a call to action 0x5D is necessary.
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@422 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/actionlist.cpp
engines/asylum/actionlist.h
engines/asylum/actor.cpp
engines/asylum/actor.h
diff --git a/engines/asylum/actionlist.cpp b/engines/asylum/actionlist.cpp
index d62b1184bc..3dfc4a20c4 100644
--- a/engines/asylum/actionlist.cpp
+++ b/engines/asylum/actionlist.cpp
@@ -154,7 +154,7 @@ static const AsylumFunction function_map[] = {
/*0x5B*/ MAPFUNC("k_unk5B", k_unk5B),
/*0x5C*/ MAPFUNC("k_unk5C", k_unk5C),
/*0x5D*/ MAPFUNC("k_unk5D", k_unk5D),
- /*0x5E*/ MAPFUNC("k_unk5E", k_unk5E),
+ /*0x5E*/ MAPFUNC("kClearActorField970", kClearActorField970),
/*0x5F*/ MAPFUNC("kSetBarrierLastFrameIdx", kSetBarrierLastFrameIdx),
/*0x60*/ MAPFUNC("k_unk60_SET_OR_CLR_ACTIONAREA_FLAG", k_unk60_SET_OR_CLR_ACTIONAREA_FLAG),
/*0x61*/ MAPFUNC("k_unk61", k_unk61),
@@ -601,9 +601,9 @@ int kHideActor(Script *script, ScriptEntry *cmd, Scene *scn) {
&scn->worldstats()->actors[cmd->param1];
actor->visible(false);
- // TODO character_sub_401320(actor)
+ actor->updateActor_401320();
- return -2;
+ return -1;
}
int kShowActor(Script *script, ScriptEntry *cmd, Scene *scn) {
@@ -1255,8 +1255,12 @@ int k_unk5C(Script *script, ScriptEntry *cmd, Scene *scn) {
int k_unk5D(Script *script, ScriptEntry *cmd, Scene *scn) {
return -2;
}
-int k_unk5E(Script *script, ScriptEntry *cmd, Scene *scn) {
- return -2;
+
+int kClearActorField970(Script *script, ScriptEntry *cmd, Scene *scn) {
+ Actor *act = scn->getActor(cmd->param1);
+ act->field_970 = 0;
+
+ return 0;
}
int kSetBarrierLastFrameIdx(Script *script, ScriptEntry *cmd, Scene *scn) {
diff --git a/engines/asylum/actionlist.h b/engines/asylum/actionlist.h
index f0029beda3..f1e785b615 100644
--- a/engines/asylum/actionlist.h
+++ b/engines/asylum/actionlist.h
@@ -232,7 +232,7 @@ int32 k_unk5A(Script *script, ScriptEntry *cmd, Scene *scn);
int32 k_unk5B(Script *script, ScriptEntry *cmd, Scene *scn);
int32 k_unk5C(Script *script, ScriptEntry *cmd, Scene *scn);
int32 k_unk5D(Script *script, ScriptEntry *cmd, Scene *scn);
-int32 k_unk5E(Script *script, ScriptEntry *cmd, Scene *scn);
+int32 kClearActorField970(Script *script, ScriptEntry *cmd, Scene *scn);
int32 kSetBarrierLastFrameIdx(Script *script, ScriptEntry *cmd, Scene *scn);
int32 k_unk60_SET_OR_CLR_ACTIONAREA_FLAG(Script *script, ScriptEntry *cmd, Scene *scn);
int32 k_unk61(Script *script, ScriptEntry *cmd, Scene *scn);
diff --git a/engines/asylum/actor.cpp b/engines/asylum/actor.cpp
index 5054de15c4..53959bc042 100644
--- a/engines/asylum/actor.cpp
+++ b/engines/asylum/actor.cpp
@@ -436,4 +436,14 @@ int32 Actor::getAngle(int32 ax1, int32 ay1, int32 ax2, int32 ay2) {
return result;
}
+void Actor::updateActor_401320() {
+ if(field_970) {
+ // TODO
+ // This update is only ever done if action script 0x5D is called, and
+ // the resulting switch sets field_970. Investigate 401A30 for further
+ // details
+ warning("[updateActor_401320] logic not implemented");
+ }
+}
+
} // end of namespace Asylum
diff --git a/engines/asylum/actor.h b/engines/asylum/actor.h
index daf87fd59c..d34f769bd1 100644
--- a/engines/asylum/actor.h
+++ b/engines/asylum/actor.h
@@ -164,6 +164,12 @@ public:
void faceTarget(int32 targetId, int32 targetType);
+ /** .text:00401320
+ * TODO
+ */
+ void updateActor_401320();
+
+
// FIXME
// I don't really like how this is used in the scene constructor
void setResourcePack(ResourcePack *res) { _resPack = res; }
Commit: d50801e0137a24ae94dff636945c0380318ac9d5
https://github.com/scummvm/scummvm/commit/d50801e0137a24ae94dff636945c0380318ac9d5
Author: Alex Bevilacqua (alexbevi at gmail.com)
Date: 2021-05-17T15:35:59+02:00
Commit Message:
ASYLUM: somewhat simplified kEnableBarriers
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@423 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/actionlist.cpp
diff --git a/engines/asylum/actionlist.cpp b/engines/asylum/actionlist.cpp
index 3dfc4a20c4..7393c1f9e6 100644
--- a/engines/asylum/actionlist.cpp
+++ b/engines/asylum/actionlist.cpp
@@ -693,9 +693,9 @@ int kEnableActor(Script *script, ScriptEntry *cmd, Scene *scn) {
}
int kEnableBarriers(Script *script, ScriptEntry *cmd, Scene *scn) {
- int barIdx = scn->worldstats()->getBarrierIndexById(cmd->param1);
+ int32 barIdx = scn->worldstats()->getBarrierIndexById(cmd->param1);
+ Barrier *bar = &scn->worldstats()->barriers[barIdx];
int32 sndIdx = cmd->param3;
- int32 v59 = cmd->param2;
if (!script->counter && scn->getSceneIndex() != 13 && sndIdx != 0) {
// FIXME: I really don't understand what (sndIdx != 0) & 5 is supposed to be doing here,
@@ -705,22 +705,19 @@ int kEnableBarriers(Script *script, ScriptEntry *cmd, Scene *scn) {
scn->vm()->sound()->playSound((sndIdx & 5) + 0x80120001, false, Config.sfxVolume, 0);
}
- if (script->counter >= 3 * v59 - 1) {
+ if (script->counter >= (3 * cmd->param2 - 1)) {
script->counter = 0;
- scn->worldstats()->barriers[barIdx].field_67C = 0;
+ bar->field_67C = 0;
scn->actions()->processActionListSub02(script, cmd, 2);
- scn->actions()->currentLoops = 1; // v4 = 1;
} else {
- int v64;
- int v62 = script->counter + 1;
- script->counter = v62;
+ int v64; // XXX rename when processActionListSub02 is better implemented
+ script->counter += 1;
if (sndIdx) {
v64 = 1;
- int v170 = 3 - v62 / v59;
- scn->worldstats()->barriers[barIdx].field_67C = v170;
+ bar->field_67C = 3 - script->counter / cmd->param2;
} else {
v64 = 0;
- scn->worldstats()->barriers[barIdx].field_67C = v62 / v59 + 1;
+ bar->field_67C = script->counter / cmd->param2 + 1;
}
scn->actions()->processActionListSub02(script, cmd, v64);
Commit: 1c5c6401c9ae157c5177cdee9cc50ec009bb6d18
https://github.com/scummvm/scummvm/commit/1c5c6401c9ae157c5177cdee9cc50ec009bb6d18
Author: Alex Bevilacqua (alexbevi at gmail.com)
Date: 2021-05-17T15:36:00+02:00
Commit Message:
ASYLUM: make kShowActor as complete since we now have a stub for function 401320 (which, like in previous cases, depends of field_970, which has yet to be set)
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@424 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/actionlist.cpp
diff --git a/engines/asylum/actionlist.cpp b/engines/asylum/actionlist.cpp
index 7393c1f9e6..26d1ea47d1 100644
--- a/engines/asylum/actionlist.cpp
+++ b/engines/asylum/actionlist.cpp
@@ -616,10 +616,10 @@ int kShowActor(Script *script, ScriptEntry *cmd, Scene *scn) {
actor = &scn->worldstats()->actors[cmd->param1];
actor->visible(true);
- // TODO character_sub_401320
+ actor->updateActor_401320();
actor->tickValue1 = scn->vm()->getTick();
- return -2;
+ return 0;
}
int kSetActorStats(Script *script, ScriptEntry *cmd, Scene *scn) {
Commit: 823d5417e1163027a1fd2db7a5738dabea26cee9
https://github.com/scummvm/scummvm/commit/823d5417e1163027a1fd2db7a5738dabea26cee9
Author: Alex Bevilacqua (alexbevi at gmail.com)
Date: 2021-05-17T15:36:00+02:00
Commit Message:
ASYLUM: renamed kSetActorStats to kSetActorPosition and cleaned up a bit
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@425 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/actionlist.cpp
engines/asylum/actionlist.h
diff --git a/engines/asylum/actionlist.cpp b/engines/asylum/actionlist.cpp
index 26d1ea47d1..b2da2b6740 100644
--- a/engines/asylum/actionlist.cpp
+++ b/engines/asylum/actionlist.cpp
@@ -71,7 +71,7 @@ static const AsylumFunction function_map[] = {
/*0x08*/ MAPFUNC("kMoveScenePosition", kMoveScenePosition),
/*0x09*/ MAPFUNC("kHideActor", kHideActor),
/*0x0A*/ MAPFUNC("kShowActor", kShowActor),
- /*0x0B*/ MAPFUNC("kSetActorStats", kSetActorStats),
+ /*0x0B*/ MAPFUNC("kSetActorPosition", kSetActorPosition),
/*0x0C*/ MAPFUNC("kSetSceneMotionStat", kSetSceneMotionStat),
/*0x0D*/ MAPFUNC("kDisableActor", kDisableActor),
/*0x0E*/ MAPFUNC("kEnableActor", kEnableActor),
@@ -622,21 +622,11 @@ int kShowActor(Script *script, ScriptEntry *cmd, Scene *scn) {
return 0;
}
-int kSetActorStats(Script *script, ScriptEntry *cmd, Scene *scn) {
- //WorldStats *ws = scn->worldstats();
-
- // TODO
- // param1 == actorIndex. Implement when we've got more than one actor
-
- // TODO This needs to be depreciated, but it's setting the actor's x/y
- // and bounding rect top/left.
- // This needs to be rolled into the proper place
- scn->getActor()->setPosition(cmd->param2, cmd->param3);
-
- scn->getActor()->setPosition_40A260(cmd->param2, cmd->param3, cmd->param4, cmd->param5);
+int kSetActorPosition(Script *script, ScriptEntry *cmd, Scene *scn) {
+ Actor *act = scn->getActor(cmd->param1);
+ act->setPosition(cmd->param2, cmd->param3, cmd->param4, cmd->param5);
- // XXX Returning -1 since the setPosition logic isn't fully implemented
- return -1;
+ return 0;
}
int kSetSceneMotionStat(Script *script, ScriptEntry *cmd, Scene *scn) {
diff --git a/engines/asylum/actionlist.h b/engines/asylum/actionlist.h
index f1e785b615..d1da9f5824 100644
--- a/engines/asylum/actionlist.h
+++ b/engines/asylum/actionlist.h
@@ -149,7 +149,7 @@ int32 kPlayAnimation(Script *script, ScriptEntry *cmd, Scene *scn);
int32 kMoveScenePosition(Script *script, ScriptEntry *cmd, Scene *scn);
int32 kHideActor(Script *script, ScriptEntry *cmd, Scene *scn);
int32 kShowActor(Script *script, ScriptEntry *cmd, Scene *scn);
-int32 kSetActorStats(Script *script, ScriptEntry *cmd, Scene *scn);
+int32 kSetActorPosition(Script *script, ScriptEntry *cmd, Scene *scn);
int32 kSetSceneMotionStat(Script *script, ScriptEntry *cmd, Scene *scn);
int32 kDisableActor(Script *script, ScriptEntry *cmd, Scene *scn);
int32 kEnableActor(Script *script, ScriptEntry *cmd, Scene *scn);
Commit: fdf91af171f887eb3114ce76eccabb776e4893dc
https://github.com/scummvm/scummvm/commit/fdf91af171f887eb3114ce76eccabb776e4893dc
Author: Alex Bevilacqua (alexbevi at gmail.com)
Date: 2021-05-17T15:36:00+02:00
Commit Message:
ASYLUM: Forgot this from r425. This removes the old setPosition and replaces it with the more appropriate one.
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@426 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/actor.cpp
engines/asylum/actor.h
diff --git a/engines/asylum/actor.cpp b/engines/asylum/actor.cpp
index 53959bc042..8aaff33412 100644
--- a/engines/asylum/actor.cpp
+++ b/engines/asylum/actor.cpp
@@ -43,14 +43,6 @@ Actor::~Actor() {
// free _resources?
}
-void Actor::setPosition(int32 targetX, int32 targetY) {
- //boundingRect.left = targetX;
- //boundingRect.top = targetY;
-
- x = targetX;
- y = targetY;
-}
-
void Actor::visible(bool value) {
if (value) // TODO - enums for flags (0x01 is visible)
flags |= 0x01;
@@ -279,7 +271,7 @@ void Actor::walkTo(int32 curX, int32 curY) {
drawActor();
}
-void Actor::setPosition_40A260(int32 newX, int32 newY, int32 newDirection, int32 frame) {
+void Actor::setPosition(int32 newX, int32 newY, int32 newDirection, int32 frame) {
x1 = newX - x2;
y1 = newY - y2;
diff --git a/engines/asylum/actor.h b/engines/asylum/actor.h
index d34f769bd1..043e8a51d1 100644
--- a/engines/asylum/actor.h
+++ b/engines/asylum/actor.h
@@ -154,13 +154,11 @@ public:
void visible(bool value);
- void setPosition(int32 targetX, int32 targetY);
-
- /**
+ /** .text:0040A260
* Initialize the x1/y1 values of the actor, update the active animation frame
* and, if the current direction isn't 8, update the actor's direction
*/
- void setPosition_40A260(int32 newX, int32 newY, int32 newDirection, int32 frame);
+ void setPosition(int32 newX, int32 newY, int32 newDirection, int32 frame);
void faceTarget(int32 targetId, int32 targetType);
Commit: da61880d8ec58c2b3acc1577ee8ddf24be28de0f
https://github.com/scummvm/scummvm/commit/da61880d8ec58c2b3acc1577ee8ddf24be28de0f
Author: Alex Bevilacqua (alexbevi at gmail.com)
Date: 2021-05-17T15:36:00+02:00
Commit Message:
ASYLUM: This commit breaks A LOT of existing functionality. It also introduces a slew of new functions (namely hittests). For the time being, I'm disabling Menus, Encounters and BlowupPuzzles, as these were all implemented with incorrect cursor handling.
Feel free to revert to a previous version if you want to try something out, but for the next little while (as I get cursors working more accurately), these features will be unavailable.
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@427 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/asylum.cpp
engines/asylum/asylum.h
engines/asylum/cursor.cpp
engines/asylum/cursor.h
engines/asylum/module.mk
engines/asylum/scene.cpp
engines/asylum/scene.h
diff --git a/engines/asylum/asylum.cpp b/engines/asylum/asylum.cpp
index 46f5f1e2ca..7b0ce75317 100644
--- a/engines/asylum/asylum.cpp
+++ b/engines/asylum/asylum.cpp
@@ -62,11 +62,11 @@ AsylumEngine::~AsylumEngine() {
delete _console;
delete _scene;
- delete _mainMenu;
+ //delete _mainMenu;
delete _video;
delete _sound;
delete _screen;
- delete _encounter;
+ //delete _encounter;
delete _text;
}
@@ -88,9 +88,9 @@ Common::Error AsylumEngine::init() {
_video = new Video(_mixer);
_console = new Console(this);
_text = new Text(_screen);
- _mainMenu = 0;
+ //_mainMenu = 0;
_scene = 0;
- _encounter = 0;
+ //_encounter = 0;
_introPlaying = false;
@@ -115,14 +115,14 @@ Common::Error AsylumEngine::go() {
#endif
// Set up main menu
- _mainMenu = new MainMenu(this);
+ //_mainMenu = new MainMenu(this);
// TODO: if savegame not exists on folder, than start game()
- if(0) { //SearchMan.hasArchive
+ //if(0) { //SearchMan.hasArchive
startGame();
- } else {
- _mainMenu->openMenu();
- }
+ //} else {
+ // _mainMenu->openMenu();
+ //}
while (!shouldQuit()) {
checkForEvent(true);
@@ -162,10 +162,10 @@ void AsylumEngine::startGame() {
// in the processActionList() method when the necessary action is fired.
// Once the blowup puzzle testing is removed from checkForEvent(), this
// can be removed as well.
- _scene->setBlowUpPuzzle(new BlowUpPuzzleVCR(_scene));
+ //_scene->setBlowUpPuzzle(new BlowUpPuzzleVCR(_scene));
// XXX Testing
- _encounter = new Encounter(_scene);
+ //_encounter = new Encounter(_scene);
// Enter first scene
if(!_introPlaying)
@@ -228,6 +228,7 @@ void AsylumEngine::checkForEvent(bool doUpdate) { // k_sub_40AE30 (0040AE30)
if (ev.type == Common::EVENT_KEYDOWN) {
if (ev.kbd.keycode == Common::KEYCODE_ESCAPE) {
// Toggle menu
+ /* FIXME reimplement later
if (_mainMenu->isActive()) {
if (_scene) {
_mainMenu->closeMenu();
@@ -239,17 +240,18 @@ void AsylumEngine::checkForEvent(bool doUpdate) { // k_sub_40AE30 (0040AE30)
_scene->getBlowUpPuzzle()->closeBlowUp();
_scene->enterScene();
}
-
+ */
return;
}
// XXX: TEST ONLY
+ /*
if (ev.kbd.keycode == Common::KEYCODE_b) {
if (_scene) {
_scene->getBlowUpPuzzle()->openBlowUp();
}
}
-
+ */
if (ev.kbd.flags == Common::KBD_CTRL) {
if (ev.kbd.keycode == Common::KEYCODE_d)
_console->attach();
@@ -259,7 +261,8 @@ void AsylumEngine::checkForEvent(bool doUpdate) { // k_sub_40AE30 (0040AE30)
}
if (doUpdate) {
- if (_mainMenu->isActive() || (_scene && _scene->isActive()) || (_scene && _scene->getBlowUpPuzzle()->isActive()))
+ if (_scene && _scene->isActive())
+ //if (_mainMenu->isActive() || (_scene && _scene->isActive()) || (_scene && _scene->getBlowUpPuzzle()->isActive()))
// Copy background image
_screen->copyBackBufferToScreen();
@@ -267,6 +270,7 @@ void AsylumEngine::checkForEvent(bool doUpdate) { // k_sub_40AE30 (0040AE30)
_console->onFrame();
}
+ /* FIXME reimplement
if (_mainMenu->isActive())
// Main menu active, pass events to it
_mainMenu->handleEvent(&ev, doUpdate);
@@ -276,6 +280,10 @@ void AsylumEngine::checkForEvent(bool doUpdate) { // k_sub_40AE30 (0040AE30)
else if (_scene && _scene->getBlowUpPuzzle()->isActive())
// Pass events to BlowUp Puzzles
_scene->getBlowUpPuzzle()->handleEvent(&ev, doUpdate);
+ */
+ if (_scene && _scene->isActive())
+ // Pass events to the game
+ _scene->handleEvent(&ev, doUpdate);
}
void AsylumEngine::processDelayedEvents() {
@@ -287,10 +295,14 @@ void AsylumEngine::processDelayedEvents() {
_video->playVideo(videoIdx, kSubtitlesOn);
_scene->actions()->delayedVideoIndex = -1;
+ /* FIXME reimplement
if (_mainMenu->isActive())
_mainMenu->openMenu();
else if (_scene->isActive())
_scene->enterScene();
+ */
+ if (_scene->isActive())
+ _scene->enterScene();
}
// check for a delayed scene change
diff --git a/engines/asylum/asylum.h b/engines/asylum/asylum.h
index 47bec07d8d..b448fb659d 100644
--- a/engines/asylum/asylum.h
+++ b/engines/asylum/asylum.h
@@ -31,12 +31,13 @@
#include "asylum/staticres.h"
#include "asylum/console.h"
#include "asylum/scene.h"
-#include "asylum/menu.h"
+//#include "asylum/menu.h"
#include "asylum/screen.h"
#include "asylum/sound.h"
#include "asylum/video.h"
-#include "asylum/blowuppuzzle.h"
-#include "asylum/encounters.h"
+//#include "asylum/blowuppuzzle.h"
+//#include "asylum/encounters.h"
+#include "asylum/text.h"
namespace Asylum {
@@ -44,15 +45,15 @@ static int32 g_object_x;
static int32 g_object_y;
// XXX
-// If defined, this will play the scene title loading
+// If defined, this will play the scene title loading up
// progress before the scene is entered. This is
// just a convenience, as there's no need for the type
// of pre-loading that was performed in the original
-//#define SHOW_SCENE_LOADING
+// #define SHOW_SCENE_LOADING
// XXX If defined, this flag will prevent the intro movies
// from being played whenever the engine is started
-//#define SKIP_INTRO
+#define SKIP_INTRO
// XXX
// I'm not sure if system endian-ness would have any
@@ -67,7 +68,7 @@ static int32 g_object_y;
class Console;
class Scene;
-class MainMenu;
+//class MainMenu;
class Scene;
class Screen;
class Sound;
@@ -151,12 +152,12 @@ private:
Console *_console;
Scene *_scene;
- MainMenu *_mainMenu;
+ //MainMenu *_mainMenu;
Screen *_screen;
Sound *_sound;
Video *_video;
Text *_text;
- Encounter *_encounter;
+ //Encounter *_encounter;
int _gameFlags[1512];
diff --git a/engines/asylum/cursor.cpp b/engines/asylum/cursor.cpp
index ae6bbdc654..cad2dab7e1 100644
--- a/engines/asylum/cursor.cpp
+++ b/engines/asylum/cursor.cpp
@@ -30,18 +30,25 @@ namespace Asylum {
const uint32 CURSOR_UPDATE_TICKS = 100;
-Cursor::Cursor(ResourcePack *res) {
- _resPack = res;
- _mouseX = 0;
- _mouseY = 0;
- cursorLoaded = false;
+Cursor::Cursor() {
+ _pos.x = 0;
+ _pos.y = 0;
+ _cursorRes = 0;
+}
+
+Cursor::Cursor(ResourcePack *pack) {
+ _pack = pack;
+ _pos.x = 0;
+ _pos.y = 0;
+ _cursorRes = 0;
}
Cursor::~Cursor() {
- if (cursorLoaded)
- delete _cursorResource;
+ if (_cursorRes)
+ delete _cursorRes;
}
+/*
void Cursor::load(int32 index) {
if (cursorLoaded)
delete _cursorResource;
@@ -51,6 +58,24 @@ void Cursor::load(int32 index) {
_curFrame = 0;
cursorLoaded = true;
}
+*/
+
+void Cursor::create(Cursor *&cursor, ResourcePack *pack, uint32 id) {
+ // If the current cursor resource is already assigned
+ // to the id value we're sending, just return
+ // TODO this simplifies a lot of additional validation calls
+ // in Scene::handleMouseUpdate, but there may be a scenario
+ // where we WANT to reset the curor to the id supplied, even
+ // if it's the same as what's assigned ... investigate
+ if (cursor) {
+ if (cursor->grResId != id)
+ delete cursor;
+ else
+ return;
+ }
+ cursor = new Cursor(pack);
+ cursor->set(id, 0, 0);
+}
void Cursor::hide() {
CursorMan.showMouse(false);
@@ -60,6 +85,33 @@ void Cursor::show() {
CursorMan.showMouse(true);
}
+void Cursor::set(uint32 resId, int32 counter, int32 flags, int32 frames) {
+ if (_cursorRes)
+ delete _cursorRes;
+
+ _cursorRes = new GraphicResource(_pack, resId);
+
+ if (frames >= 0)
+ frameCount = frames;
+ else
+ frameCount = _cursorRes->getFrameCount();
+ this->flags = flags;
+ this->counter = counter;
+ currentFrame = 0;
+ _cursor_byte_45756C = 1;
+
+ update();
+}
+
+void Cursor::update() {
+ GraphicFrame *fra = _cursorRes->getFrame(currentFrame);
+ CursorMan.replaceCursor((byte *)fra->surface.pixels,
+ fra->surface.w,
+ fra->surface.h,
+ 0, 0, 0);
+}
+
+/*
void Cursor::set(byte *data, byte width, byte height) {
CursorMan.replaceCursor(data, width, height, 0, 0, 0);
}
@@ -73,12 +125,14 @@ void Cursor::set(int32 frame) {
_cursorStep = 1;
}
}
+*/
-void Cursor::setCoords(int32 mouseX, int32 mouseY) {
- _mouseX = mouseX;
- _mouseY = mouseY;
+void Cursor::move(int16 x, int16 y) {
+ _pos.x = x;
+ _pos.y = y;
}
+/*
void Cursor::animate() {
_curFrame += _cursorStep;
if (_curFrame == 0)
@@ -88,7 +142,9 @@ void Cursor::animate() {
set(_curFrame);
}
+*/
+/*
void Cursor::update(WorldStats *ws, int32 currentAction) {
uint32 newCursor = 0;
@@ -125,5 +181,6 @@ void Cursor::update(WorldStats *ws, int32 currentAction) {
if (_cursorResource->getEntryNum() != newCursor && newCursor > 0)
load(newCursor);
}
+*/
} // end of namespace Asylum
diff --git a/engines/asylum/cursor.h b/engines/asylum/cursor.h
index d74da89e86..ff35593966 100644
--- a/engines/asylum/cursor.h
+++ b/engines/asylum/cursor.h
@@ -26,43 +26,49 @@
#ifndef ASYLUM_CURSOR_H_
#define ASYLUM_CURSOR_H_
-#include "asylum/respack.h"
-#include "asylum/worldstats.h"
+#include "asylum/graphics.h"
namespace Asylum {
-class WorldStats;
-
/**
* Asylum cursors are GraphicResources, and are stored in
* ResourcePacks, as are all game assets.
*/
class Cursor {
public:
- Cursor(ResourcePack *res);
+ Cursor();
+ Cursor(ResourcePack *pack);
+
virtual ~Cursor();
+
+ /**
+ * Generate a new cursor instance from the resource id
+ * within the resource pack provided.
+ */
+ static void create(Cursor *&cursor, ResourcePack *pack, uint32 id);
+
/**
* Show the current cursor
*/
void show();
+
/**
* Hide the current cursor
*/
void hide();
- /**
- * Load a GraphicResource at the position specified by
- * index from the buffered ResourcePack
- */
- void load(int32 index);
- /**
- * Set the current cursor to a specific frame
- * within the loaded cursorResource
+
+ /** .text:00435400
+ * Set the current cursor instance to the graphic resource provide.
+ * The frames parameter defaults to -1, which in this case means that the
+ * frame count should be derived from the graphic resource as opposed to being
+ * explicitely set.
*/
- void set(int32 frame);
+ void set(uint32 resId, int32 counter, int32 flags, int32 frames = -1);
/**
* Set the x/y coordinates of the cursor
*/
- void setCoords(int32 mouseX, int32 mouseY);
+ void move(int16 x, int16 y);
+
/**
* Scene-based update to the current cursor. This
* checks whether the cursor should be updated depending
@@ -71,33 +77,19 @@ public:
* TODO this probably doesn't belong here, but on the
* scene, where it originally was
*/
- void update(WorldStats *ws, int32 currentAction);
+ //void update(WorldStats *ws, int32 currentAction);
/**
* Get the next logical frame from the currently loaded
* cursorResource and draw it
*/
- void animate();
+ //void animate();
+
+ void update();
/**
- * Get the X position of the cursor
- */
- int32 x() {
- return _mouseX;
- }
- /**
- * get the Y position of the cursor
- */
- int32 y() {
- return _mouseY;
- }
- /**
- * Get the current frame number of the
- * loaded cursorResource
+ * Return the cursor's position on the screen
*/
- uint32 currentFrame() {
- return _curFrame;
- }
-
+ Common::Point position() const { return _pos; }
// NOTE
// .text:00435060 contains a function that assigns global variables to a
@@ -107,27 +99,29 @@ public:
// typedef struct CursorInfo {
int32 grResId;
- int32 field_4;
+ int32 currentFrame; // assuming field_4c is the current frame pointer
+ // since it's generally initialized to zero
int32 frameCount;
- int32 field_C;
+ int32 counter; // cursor counter
byte flags;
byte field_11;
// } CursorInfo;
+
private:
- void set(byte *data, byte width, byte height);
+ ResourcePack *_pack;
+ GraphicResource *_cursorRes;
+
+ /** the point on the screen the cursor is at */
+ Common::Point _pos;
- ResourcePack *_resPack;
- GraphicResource *_cursorResource;
- bool cursorLoaded;
- uint32 _curFrame;
- int32 _cursorStep;
- int32 _mouseX;
- int32 _mouseY;
+ /** the point of the cursor that triggers click hits */
+ Common::Point _hotspot;
// The number of millis between
// cursor gfx updates
uint32 _cursorTicks;
+ byte _cursor_byte_45756C;
}; // end of class Cursor
} // end of namespace Asylum
diff --git a/engines/asylum/module.mk b/engines/asylum/module.mk
index cb6a2dab1d..f895f44063 100644
--- a/engines/asylum/module.mk
+++ b/engines/asylum/module.mk
@@ -6,13 +6,10 @@ MODULE_OBJS := \
actor.o \
asylum.o \
barrier.o \
- blowuppuzzle.o \
console.o \
cursor.o \
detection.o \
- encounters.o \
graphics.o \
- menu.o \
polygons.o \
respack.o \
scene.o \
diff --git a/engines/asylum/scene.cpp b/engines/asylum/scene.cpp
index b4b936efb7..c8bfd70d6e 100644
--- a/engines/asylum/scene.cpp
+++ b/engines/asylum/scene.cpp
@@ -69,7 +69,7 @@ Scene::Scene(uint8 sceneIdx, AsylumEngine *engine): _vm(engine) {
fd->close();
delete fd;
- _speech = new Speech(this);
+ _speech = new Speech(this);
_resPack = new ResourcePack(sceneIdx);
// TODO
@@ -82,8 +82,8 @@ Scene::Scene(uint8 sceneIdx, AsylumEngine *engine): _vm(engine) {
_musPack = new ResourcePack(musPackFileName);
_bgResource = new GraphicResource(_resPack, _ws->backgroundImage);
- _blowUp = 0;
- _cursor = new Cursor(_resPack);
+ //_blowUp = 0;
+ _cursor = 0;
_background = 0;
_leftClick = false;
_rightButton = false;
@@ -125,11 +125,7 @@ void Scene::initialize() {
}
}
- _cursor->load(_ws->curMagnifyingGlass);
- _cursor->set(0);
-
- // FIXME this is just here for testing
- _cursor->grResId = _ws->curMagnifyingGlass;
+ Cursor::create(_cursor, _resPack, _ws->curMagnifyingGlass);
_ws->sceneRectIdx = 0;
_vm->screen()->clearScreen(); // XXX was clearGraphicsInQueue()
@@ -208,7 +204,7 @@ Scene::~Scene() {
delete _bgResource;
delete _musPack;
delete _resPack;
- delete _blowUp;
+ //delete _blowUp;
// TODO we can probably dispose of the title resource once the
// _titleLoaded flag has been set, as opposed to in the
@@ -400,8 +396,7 @@ void Scene::enterScene() {
// when the scene is started. Check against the original to see
// when the cursor is initalized, and then how it reacts to the
// show_cursor opcode
- _cursor->load(_ws->curMagnifyingGlass);
- _cursor->set(0);
+ Cursor::create(_cursor, _resPack, _ws->curMagnifyingGlass);
_cursor->show();
startMusic();
@@ -438,7 +433,8 @@ void Scene::handleEvent(Common::Event *event, bool doUpdate) {
switch (_ev->type) {
case Common::EVENT_MOUSEMOVE:
- _cursor->setCoords(_ev->mouse.x, _ev->mouse.y);
+ if (_cursor)
+ _cursor->move(_ev->mouse.x, _ev->mouse.y);
break;
case Common::EVENT_LBUTTONUP:
@@ -451,7 +447,7 @@ void Scene::handleEvent(Common::Event *event, bool doUpdate) {
// TODO This isn't always going to be the magnifying glass
// Should check the current pointer region to identify the type
// of cursor to use
- _cursor->load(_ws->curMagnifyingGlass);
+ Cursor::create(_cursor, _resPack, _ws->curMagnifyingGlass);
_rightButton = false;
}
break;
@@ -512,7 +508,7 @@ int Scene::updateScene() {
// Mouse
startTick = _vm->getTick();
- // updateMouse();
+ updateMouse();
debugC(kDebugLevelScene, "UpdateMouse Time: %d", _vm->getTick() - startTick);
// Actors
@@ -585,15 +581,15 @@ void Scene::updateMouse() {
int dir = -1;
bool done = false;
- if (_cursor->x() < actorPos.left) {
- if (_cursor->y() >= actorPos.top) {
- if (_cursor->y() > actorPos.bottom) {
+ if (_cursor->position().x < actorPos.left) {
+ if (_cursor->position().y >= actorPos.top) {
+ if (_cursor->position().y > actorPos.bottom) {
if (act->direction == 2) {
- if (_cursor->y() - actorPos.bottom > 10)
+ if (_cursor->position().y - actorPos.bottom > 10)
dir = 3;
} else {
if (act->direction == 4) {
- if (actorPos.left - _cursor->x() > 10)
+ if (actorPos.left - _cursor->position().x > 10)
dir = 3;
} else {
dir = 3;
@@ -601,11 +597,11 @@ void Scene::updateMouse() {
}
} else {
if (act->direction == 1) {
- if (_cursor->y() - actorPos.top > 10)
+ if (_cursor->position().y - actorPos.top > 10)
dir = 2;
} else {
if (act->direction == 3) {
- if (actorPos.bottom - _cursor->y() > 10)
+ if (actorPos.bottom - _cursor->position().y > 10)
dir = 2;
} else {
dir = 2;
@@ -615,28 +611,28 @@ void Scene::updateMouse() {
} else {
if (act->direction) {
if (act->direction == 2) {
- if (actorPos.top - _cursor->y() > 10)
+ if (actorPos.top - _cursor->position().y > 10)
dir = 1;
} else {
dir = 1;
}
} else {
- if (actorPos.left - _cursor->x() > 10)
+ if (actorPos.left - _cursor->position().x > 10)
dir = 1;
}
}
done = true;
}
- if (!done && _cursor->x() <= actorPos.right) {
- if (_cursor->y() >= actorPos.top) {
- if (_cursor->y() > actorPos.bottom) {
+ if (!done && _cursor->position().x <= actorPos.right) {
+ if (_cursor->position().y >= actorPos.top) {
+ if (_cursor->position().y > actorPos.bottom) {
if (act->direction == 3) {
- if (_cursor->x() - actorPos.left > 10)
+ if (_cursor->position().x - actorPos.left > 10)
dir = 4;
} else {
if (act->direction == 5) {
- if (actorPos.right - _cursor->x() > 10)
+ if (actorPos.right - _cursor->position().x > 10)
dir = 4;
} else {
dir = 4;
@@ -645,11 +641,11 @@ void Scene::updateMouse() {
}
} else {
if (act->direction == 1) {
- if (_cursor->x() - actorPos.left > 10)
+ if (_cursor->position().x - actorPos.left > 10)
dir = 0;
} else {
if (act->direction == 7) {
- if (actorPos.right - _cursor->x() > 10)
+ if (actorPos.right - _cursor->position().x > 10)
dir = 0;
} else {
dir = 0;
@@ -659,28 +655,28 @@ void Scene::updateMouse() {
done = true;
}
- if (!done && _cursor->y() < actorPos.top) {
+ if (!done && _cursor->position().y < actorPos.top) {
if (act->direction) {
if (act->direction == 6) {
- if (actorPos.top - _cursor->y() > 10)
+ if (actorPos.top - _cursor->position().y > 10)
dir = 7;
} else {
dir = 7;
}
} else {
- if (_cursor->x() - actorPos.right > 10)
+ if (_cursor->position().x - actorPos.right > 10)
dir = 7;
}
done = true;
}
- if (!done && _cursor->y() <= actorPos.bottom) {
+ if (!done && _cursor->position().y <= actorPos.bottom) {
if (act->direction == 5) {
- if (actorPos.bottom - _cursor->y() > 10)
+ if (actorPos.bottom - _cursor->position().y > 10)
dir = 6;
} else {
if (act->direction == 7) {
- if (_cursor->y() - actorPos.top > 10)
+ if (_cursor->position().y - actorPos.top > 10)
dir = 6;
} else {
dir = 6;
@@ -690,22 +686,21 @@ void Scene::updateMouse() {
}
if (!done && act->direction == 4) {
- if (_cursor->x() - actorPos.right <= 10)
+ if (_cursor->position().x - actorPos.right <= 10)
done = true;
if (!done)
dir = 5;
}
- if (!done && (act->direction != 6 || _cursor->y() - actorPos.bottom > 10))
+ if (!done && (act->direction != 6 || _cursor->position().y - actorPos.bottom > 10))
dir = 5;
handleMouseUpdate(dir, actorPos);
+
if (dir >= 0) {
if (act->updateType == 1 || act->updateType == 12)
setActorDirection(act, dir);
}
-
- //printf("Current Dir %d -- New Dir %d\n", actor->direction, dir);
}
void Scene::setActorDirection(Actor *act, int direction) {
@@ -742,12 +737,10 @@ void Scene::setActorDirection(Actor *act, int direction) {
case 0x01:
case 0x02:
case 0x0C:
- // TODO verify that this is correct
- grResId = act->grResTable[act->direction];
+ act->grResId = act->grResTable[act->direction];
break;
case 0x08:
- // TODO verify that this is correct
- grResId = act->grResTable[act->direction + 20];
+ act->grResId = act->grResTable[act->direction + 20];
break;
default:
warning ("[setActorDirection] default case hit with updateType of %d", act->updateType);
@@ -761,35 +754,31 @@ void Scene::handleMouseUpdate(int direction, Common::Rect rect) {
HitType type = kHitNone;
// TODO if encounter_flag03
- if (0 && _cursor->grResId != _ws->curTalkNPC) {
- // TODO setMouseCursor(_ws->curTalkNPC);
- }
+ if (0 && _cursor->grResId != _ws->curTalkNPC)
+ _cursor->set(_ws->curTalkNPC, 0, 2);
Actor *act = getActor(); // get the player actor reference
+ // XXX field_11 seems to have something to do with
+ // whether the event manager is handling a right mouse down
+ // event
if (_cursor->field_11 & 2) {
if (act->updateType == 1 || act->updateType == 12) {
if (direction >= 0) {
newGrResId = _ws->curScrollUp + direction;
- if (_cursor->grResId != newGrResId) {
- // TODO setMouseCursor(newGrResId);
- warning("%d", newGrResId);
- }
+ _cursor->set(newGrResId, 0, 2);
}
}
}
if (act->updateType == 6 || act->updateType == 10) {
newGrResId = _ws->curHand;
- if (_cursor->grResId != newGrResId) {
- // TODO setMouseCursor(newGrResId);
- warning("%d", newGrResId);
- }
+ _cursor->set(newGrResId, 0, 2);
} else {
if (act->field_638) {
- if (_cursor->x() >= rect.left && _cursor->x() <= rlimit &&
- _cursor->y() >= rect.top && _cursor->y() <= rect.bottom &&
- hitTestActor(_cursor->x(), _cursor->y())) {
+ if (_cursor->position().x >= rect.left && _cursor->position().x <= rlimit &&
+ _cursor->position().y >= rect.top && _cursor->position().y <= rect.bottom &&
+ hitTestActor(_cursor->position())) {
// TODO LOTS of work here, because apparently we need to use
// field_638 as an index into _ws->field_D6AC8, which is not
// yet defined as part of worldstats, but according to IDA, is:
@@ -800,7 +789,7 @@ void Scene::handleMouseUpdate(int direction, Common::Rect rect) {
} else {
// TODO pass a reference to hitType so it can be populated by
// hitTestScene
- newGrResId = hitTestScene(_cursor->x(), _cursor->y(), type);
+ newGrResId = hitTestScene(_cursor->position(), type);
if (newGrResId != -1) {
warning ("Can't set mouse cursor, field_D6AC8 not handled ... yet");
// TODO
@@ -813,64 +802,77 @@ void Scene::handleMouseUpdate(int direction, Common::Rect rect) {
}
return; // return result;
}
- newGrResId = hitTest(_cursor->x(), _cursor->y(), type);
- if (_cursor->x() >= rect.left && _cursor->x() <= rlimit &&
- _cursor->y() >= rect.top && _cursor->y() <= rect.bottom &&
- hitTestActor(_cursor->x(), _cursor->y())) {
+ int32 targetIdx = hitTest(_cursor->position(), type);
+
+ //printf ("Mouse X(%d)/Y(%d) = %d\n", _cursor->position().x, _cursor->position().y, type);
+ if (_cursor->position().x >= rect.left && _cursor->position().x <= rlimit &&
+ _cursor->position().y >= rect.top && _cursor->position().y <= rect.bottom &&
+ hitTestActor(_cursor->position())) {
if (act->reaction[0]) {
- if (_cursor->grResId != _ws->curGrabPointer) {
- warning ("Changing Cursor to curGrabPointer");
- // TODO setMouseCursor
- }
+ _cursor->set(_ws->curGrabPointer, 0, 2);
return;
}
}
- if (newGrResId != -1) {
+ if (targetIdx == -1) {
if (_ws->numChapter != 2 || _playerActorIdx != 10) {
- if (_cursor->grResId != _ws->curMagnifyingGlass) { // TODO || _cursor->flags)
- warning ("Changing Cursor to curMagnifying Glass");
- // TODO setMouseCursor
- }
+ if (_cursor->flags)
+ _cursor->set(_ws->curMagnifyingGlass, 0, 2);
} else {
- if (_cursor->grResId != _ws->curTalkNPC2) { // TODO || _cursor->flags)
- warning ("Changing Cursor to curTalkNPC2");
- // TODO setMouseCursor
- }
+ if (_cursor->flags)
+ _cursor->set(_ws->curTalkNPC2, 0, 2);
}
} else {
+ int32 targetUpdateType;
switch (type) {
case kHitActionArea:
- warning ("Cursor = kHitActionArea");
+ targetUpdateType = _ws->actions[targetIdx].actionType;
break;
case kHitBarrier:
- warning ("Cursor = kHitBarrier");
+ targetUpdateType = _ws->barriers[targetIdx].flags2;
break;
case kHitActor:
- warning ("Cursor = kHitActor");
+ targetUpdateType = getActor(targetIdx)->updateType;
break;
default:
// TODO LOBYTE(hitType)
break;
}
- // TODO
- // Handle the various switches and change the mouse cursor
- // accordingly. I'm not 100% sure that this can't be done
- // directly in each case, as the disassembly shows the need
- // to compare the lobyte first, then take the appropriate action
+ if (targetUpdateType & 1 && _cursor->flags != 2) {
+ _cursor->set(_ws->curMagnifyingGlass, 0, 2);
+ } else {
+ if (targetUpdateType & 4) {
+ _cursor->set(_ws->curHand, 0, 2);
+ } else {
+ if (targetUpdateType & 2) {
+ _cursor->set(_ws->curTalkNPC, 0, 2);
+ } else {
+ if (targetUpdateType & 0x10 && _cursor->flags != 2) {
+ _cursor->set(_ws->curTalkNPC2, 0, 2);
+ } else {
+ if (_ws->numChapter != 2 && _playerActorIdx != 10) {
+ _cursor->set(_ws->curMagnifyingGlass, 0, 0);
+ } else {
+ if (_cursor->flags)
+ _cursor->set(_ws->curTalkNPC2, 0, 2);
+ }
+ }
+ }
+ }
+ }
}
}
}
-int32 Scene::hitTestBarrier(int32 x, int32 y) {
+int32 Scene::hitTestBarrier(const Common::Point pt) {
int32 targetIdx = -1;
for (int32 i = 0; i < _ws->numBarriers; i++) {
Barrier b = _ws->barriers[i];
if (_ws->isBarrierOnScreen(i))
if (b.polyIdx)
- if (hitTestPixel(b.resId, b.frameIdx, x, y, b.flags & 0x1000)) {
+ if (hitTestPixel(b.resId, b.frameIdx, pt.x, pt.y, b.flags & 0x1000)) {
targetIdx = i;
break;
}
@@ -878,13 +880,13 @@ int32 Scene::hitTestBarrier(int32 x, int32 y) {
return targetIdx;
}
-int32 Scene::hitTest(int32 x, int32 y, HitType &type) {
+int32 Scene::hitTest(const Common::Point pt, HitType &type) {
type = kHitNone;
- int32 targetIdx = hitTestBarrier(x, y);
+ int32 targetIdx = hitTestBarrier(pt);
if (targetIdx == -1) {
- targetIdx = hitTestActionArea(x, y);
+ targetIdx = hitTestActionArea(pt);
if (targetIdx == -1) {
- targetIdx = hitTestActor(x, y);
+ targetIdx = hitTestActor(pt);
if (targetIdx != -1)
type = kHitActor;
} else {
@@ -896,18 +898,16 @@ int32 Scene::hitTest(int32 x, int32 y, HitType &type) {
return targetIdx;
}
-int32 Scene::hitTestActionArea(int32 x, int32 y) {
- int32 targetIdx = findActionArea(_ws->xLeft + x, _ws->yTop + y);
+int32 Scene::hitTestActionArea(const Common::Point pt) {
+ int32 targetIdx = findActionArea(Common::Point(_ws->xLeft + pt.x, _ws->yTop + pt.y));
- // TODO
- // if ( result == -1 || !(LOBYTE(scene.actionAreas[result].flags2) & 0x17) )
- // targetIdx = -1
- // This won't work becase I can't remember what flags2 is at the moment :P
+ if ( targetIdx == -1 || !(_ws->actions[targetIdx].actionType & 0x17))
+ targetIdx = -1;
return targetIdx;
}
-int32 Scene::findActionArea(int32 pointX, int32 pointY) {
+int32 Scene::findActionArea(const Common::Point pt) {
// TODO
// This is a VERY loose implementation of the target
// function, as this doesn't do any of the flag checking
@@ -916,7 +916,7 @@ int32 Scene::findActionArea(int32 pointX, int32 pointY) {
for (int32 i = 0; i < _ws->numActions; i++) {
ActionArea a = _ws->actions[i];
PolyDefinitions p = _polygons->entries[a.polyIdx];
- if (p.contains(pointX, pointY)) {
+ if (p.contains(pt.x, pt.y)) {
targetIdx = i;
break;
}
@@ -924,12 +924,12 @@ int32 Scene::findActionArea(int32 pointX, int32 pointY) {
return targetIdx;
}
-int32 Scene::hitTestScene(int16 x, int16 y, HitType &type) {
- int32 top = x + _ws->xLeft;
- int32 left = y + _ws->yTop;
+int32 Scene::hitTestScene(const Common::Point pt, HitType &type) {
+ int32 top = pt.x + _ws->xLeft;
+ int32 left = pt.y + _ws->yTop;
type = kHitNone;
- int32 result = findActionArea(top, left);
+ int32 result = findActionArea(Common::Point(top, left));
if (result != -1) {
if (LOBYTE(_ws->actions[result].actionType) & 8) {
@@ -943,10 +943,10 @@ int32 Scene::hitTestScene(int16 x, int16 y, HitType &type) {
return result;
}
-bool Scene::hitTestActor(int16 x, int16 y) {
+bool Scene::hitTestActor(const Common::Point pt) {
Actor *act = getActor();
- Common::Point pt;
- getActorPosition(act, &pt);
+ Common::Point actPos;
+ getActorPosition(act, &actPos);
int32 hitFrame;
if (act->frameNum >= act->frameCount)
@@ -956,8 +956,8 @@ bool Scene::hitTestActor(int16 x, int16 y) {
return hitTestPixel(act->grResId,
hitFrame,
- x - act->x - pt.x,
- y - act->y - pt.y,
+ pt.x - act->x - actPos.x,
+ pt.y - act->y - actPos.y,
(act->direction >= 0));
}
@@ -1119,6 +1119,21 @@ void Scene::updateActorSub01(Actor *act) {
// one off situation).
}
+void Scene::stopSound(int32 barrierIndex, int32 actorIndex) {
+ int32 sndResId = 0;
+
+ if (actorIndex) {
+ sndResId = getActor(actorIndex)->soundResId;
+ } else {
+ if (barrierIndex) {
+ sndResId = _ws->barriers[barrierIndex].soundResId;
+ }
+ }
+
+ if (_vm->sound()->isPlaying(sndResId)) {
+ _vm->sound()->stopSound(sndResId);
+ }
+}
void Scene::updateBarriers() {
//Screen *screen = _vm->screen();
@@ -1245,7 +1260,8 @@ void Scene::updateBarriers() {
}
if (canPlaySound) {
- // TODO: play sounds
+ barrier->updateSoundItems(_vm->sound());
+ stopSound(b, 0);
}
// TODO: get sound functions according with scene
@@ -1766,15 +1782,15 @@ void Scene::copyToBackBufferClipped(Graphics::Surface *surface, int x, int y) {
void Scene::debugScreenScrolling(GraphicFrame *bg) {
// Horizontal scrolling
- if (_cursor->x() < SCREEN_EDGES && _ws->xLeft >= SCROLL_STEP)
+ if (_cursor->position().x < SCREEN_EDGES && _ws->xLeft >= SCROLL_STEP)
_ws->xLeft -= SCROLL_STEP;
- else if (_cursor->x() > 640 - SCREEN_EDGES && _ws->xLeft <= bg->surface.w - 640 - SCROLL_STEP)
+ else if (_cursor->position().x > 640 - SCREEN_EDGES && _ws->xLeft <= bg->surface.w - 640 - SCROLL_STEP)
_ws->xLeft += SCROLL_STEP;
// Vertical scrolling
- if (_cursor->y() < SCREEN_EDGES && _ws->yTop >= SCROLL_STEP)
+ if (_cursor->position().y < SCREEN_EDGES && _ws->yTop >= SCROLL_STEP)
_ws->yTop -= SCROLL_STEP;
- else if (_cursor->y() > 480 - SCREEN_EDGES && _ws->yTop <= bg->surface.h - 480 - SCROLL_STEP)
+ else if (_cursor->position().y > 480 - SCREEN_EDGES && _ws->yTop <= bg->surface.h - 480 - SCROLL_STEP)
_ws->yTop += SCROLL_STEP;
}
diff --git a/engines/asylum/scene.h b/engines/asylum/scene.h
index 448b927e1c..64a9a9aabf 100644
--- a/engines/asylum/scene.h
+++ b/engines/asylum/scene.h
@@ -49,7 +49,7 @@ class Sound;
class Video;
class Cursor;
class Text;
-class BlowUpPuzzle;
+//class BlowUpPuzzle;
struct BarrierItem;
class WorldStats;
class Speech;
@@ -108,8 +108,8 @@ public:
ResourcePack* getResourcePack() { return _resPack; }
ResourcePack* getMusicPack() { return _musPack; }
GraphicResource* getGraphicResource(int32 entry) { return new GraphicResource(_resPack, entry); }
- BlowUpPuzzle* getBlowUpPuzzle() { return _blowUp;}
- void setBlowUpPuzzle(BlowUpPuzzle* puzzle) { _blowUp = puzzle; }
+ //BlowUpPuzzle* getBlowUpPuzzle() { return _blowUp;}
+ //void setBlowUpPuzzle(BlowUpPuzzle* puzzle) { _blowUp = puzzle; }
void setScenePosition(int x, int y);
AsylumEngine* vm() { return _vm; }
@@ -150,11 +150,22 @@ public:
* graphic resource matches the resource at grResTable[5]
*/
bool defaultActorDirectionLoaded(int actorIndex, int grResTableIdx);
+
/** .text:00407A00
* TODO
*/
void setActorDirection(Actor *act, int direction);
-
+ /** .text:00414C30
+ * Check if a sound resource is playing for the barrier,
+ * or actor that is specified, and if so, stop playing the
+ * sample.
+ *
+ * NOTE this method was originally called from within
+ * Barrier::updateSoundItems(), but that would require
+ * the barrier class to have some knowledge about actors,
+ * which seems a bit wonky.
+ */
+ void stopSound(int32 barrierIndex, int32 actorIndex);
/** .text:004094c0
* Determine the amount to increase the supplied sound
* sample's volume based on the actor's position
@@ -166,16 +177,16 @@ protected:
* Run various hit tests and return the index,
* and a reference to the located type
*/
- int32 hitTest(int32 x, int32 y, HitType &type);
+ int32 hitTest(const Common::Point pt, HitType &type);
/** .text:0040F010
* TODO
*/
- int32 hitTestActionArea(int32 x, int32 y);
+ int32 hitTestActionArea(const Common::Point pt);
/** .text:0040E7F0
* Check if the mouse cursor is currently intersecting
* the currently active actor
*/
- bool hitTestActor(int16 x, int16 y);
+ bool hitTestActor(const Common::Point pt);
/** .text:004341E0
* Check if the mouse cursor is currently intersecting
* a graphic resource at the supplied coordinates
@@ -185,18 +196,18 @@ protected:
* Checks if the supplied coordinates are inside an action area, barrier or
* actor, and returns -1 if nothing was found, or the type of hit if found
*/
- int32 hitTestScene(int16 x, int16 y, HitType &type);
+ int32 hitTestScene(const Common::Point pt, HitType &type);
/** .text:00408980
* Determine if the supplied point intersects
* an action area's active region
*/
- int32 findActionArea(int32 pointX, int32 pointY);
+ int32 findActionArea(const Common::Point pt);
/** .text:0040EAA0
* Check if a barrier exist at the supplied coordinates.
* If so, return it's index within the barriers array, if not,
* return -1
*/
- int32 hitTestBarrier(int32 x, int32 y);
+ int32 hitTestBarrier(const Common::Point pt);
private:
AsylumEngine *_vm;
Common::Event *_ev;
@@ -218,7 +229,7 @@ private:
Cursor *_cursor;
ResourcePack *_resPack;
ResourcePack *_musPack;
- BlowUpPuzzle *_blowUp;
+ //BlowUpPuzzle *_blowUp;
GraphicResource *_bgResource;
GraphicFrame *_background;
Commit: 9d72b587bd2a1fda05c0e4c2d5506fa736bd6319
https://github.com/scummvm/scummvm/commit/9d72b587bd2a1fda05c0e4c2d5506fa736bd6319
Author: Alex Bevilacqua (alexbevi at gmail.com)
Date: 2021-05-17T15:36:00+02:00
Commit Message:
ASYLUM: read the rest of the actor struct out of the res file
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@428 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/actor.h
engines/asylum/worldstats.cpp
diff --git a/engines/asylum/actor.h b/engines/asylum/actor.h
index 043e8a51d1..6fba4542bb 100644
--- a/engines/asylum/actor.h
+++ b/engines/asylum/actor.h
@@ -233,15 +233,15 @@ public:
int32 field_934;
int32 field_938;
int32 soundResId; // field_93C
- int32 field_940;
+ int32 numberValue01;
int32 field_944;
int32 field_948;
int32 field_94C;
- int32 field_950;
+ int32 numberFlag01;
int32 field_954;
int32 field_958;
int32 field_95C;
- int32 field_960;
+ char numberString01[8];
int32 field_964;
int32 field_968;
int32 field_96C;
@@ -249,7 +249,15 @@ public:
int32 field_974;
int32 field_978;
int32 actionIdx1;
- // TODO field_980 till field_9A0
+ int32 field_980;
+ int32 field_984;
+ int32 field_988;
+ int32 field_98C;
+ int32 field_990;
+ int32 field_994;
+ int32 field_998;
+ int32 field_99C;
+ int32 field_9A0;
private:
Scene *_scene;
diff --git a/engines/asylum/worldstats.cpp b/engines/asylum/worldstats.cpp
index b3d84f8157..6374be91ff 100644
--- a/engines/asylum/worldstats.cpp
+++ b/engines/asylum/worldstats.cpp
@@ -365,15 +365,15 @@ void WorldStats::load(Common::SeekableReadStream *stream) {
actor.field_934 = stream->readSint32LE();
actor.field_938 = stream->readSint32LE();
actor.soundResId = stream->readSint32LE();
- actor.field_940 = stream->readSint32LE();
+ actor.numberValue01 = stream->readSint32LE();
actor.field_944 = stream->readSint32LE();
actor.field_948 = stream->readSint32LE();
actor.field_94C = stream->readSint32LE();
- actor.field_950 = stream->readSint32LE();
+ actor.numberFlag01 = stream->readSint32LE();
actor.field_954 = stream->readSint32LE();
actor.field_958 = stream->readSint32LE();
actor.field_95C = stream->readSint32LE();
- actor.field_960 = stream->readSint32LE();
+ stream->read(actor.numberString01, sizeof(actor.numberString01));
actor.field_964 = stream->readSint32LE();
actor.field_968 = stream->readSint32LE();
actor.field_96C = stream->readSint32LE();
@@ -381,6 +381,15 @@ void WorldStats::load(Common::SeekableReadStream *stream) {
actor.field_974 = stream->readSint32LE();
actor.field_978 = stream->readSint32LE();
actor.actionIdx1 = stream->readSint32LE();
+ actor.field_980 = stream->readSint32LE();
+ actor.field_984 = stream->readSint32LE();
+ actor.field_988 = stream->readSint32LE();
+ actor.field_98C = stream->readSint32LE();
+ actor.field_990 = stream->readSint32LE();
+ actor.field_994 = stream->readSint32LE();
+ actor.field_998 = stream->readSint32LE();
+ actor.field_99C = stream->readSint32LE();
+ actor.field_9A0 = stream->readSint32LE();
// TODO skip field_980 till field_9A0
stream->skip(0x24);
Commit: 97e1f0ea7c464939fd5b11987e8d105cf8980407
https://github.com/scummvm/scummvm/commit/97e1f0ea7c464939fd5b11987e8d105cf8980407
Author: Alex Bevilacqua (alexbevi at gmail.com)
Date: 2021-05-17T15:36:00+02:00
Commit Message:
ASYLUM: fix _mixer->playRaw to work with latest ScummVM trunk
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@429 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/sound.cpp
diff --git a/engines/asylum/sound.cpp b/engines/asylum/sound.cpp
index 674298bb10..ea4faa5b75 100644
--- a/engines/asylum/sound.cpp
+++ b/engines/asylum/sound.cpp
@@ -283,7 +283,7 @@ void Sound::playSoundData(Audio::SoundHandle *handle, byte *soundData, int32 sou
// enums for kMusicSoundType and kSpeechSoundType.
//
// Investigate how this can effect ... anything :P
- _mixer->playRaw(Audio::Mixer::kSFXSoundType, handle, buffer, size, rate, flags | Audio::Mixer::FLAG_AUTOFREE, -1, vol, pan);
+ _mixer->playRaw(Audio::Mixer::kSFXSoundType, handle, buffer, size, DisposeAfterUse::YES, rate, flags, -1, vol, pan);
}
} // end of namespace Asylum
Commit: a9b15453b72578023ea4e7302471b3df726dfe57
https://github.com/scummvm/scummvm/commit/a9b15453b72578023ea4e7302471b3df726dfe57
Author: Alex Bevilacqua (alexbevi at gmail.com)
Date: 2021-05-17T15:36:01+02:00
Commit Message:
ASYLUM: fixed the _mixer calls again since playRaw has recently been removed from trunk. Also added a FIXME since we'll eventually have to clip the panning/volume values to use them properly
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@430 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/sound.cpp
engines/asylum/sound.h
diff --git a/engines/asylum/sound.cpp b/engines/asylum/sound.cpp
index ea4faa5b75..50b710c383 100644
--- a/engines/asylum/sound.cpp
+++ b/engines/asylum/sound.cpp
@@ -162,7 +162,7 @@ void Sound::playSound(ResourcePack *pack, int32 resId, int32 volume, bool loopin
}
void Sound::playSound(ResourceEntry *resource, bool looping, int32 volume, int32 panning) {
- playSoundData(&_soundHandle, resource->data, resource->size, looping, volume, panning);
+ playSoundData(Audio::Mixer::kSFXSoundType, &_soundHandle, resource->data, resource->size, looping, volume, panning);
}
void Sound::playSound(ResourcePack *pack, int32 resId, bool looping, int32 volume, int32 panning) {
@@ -176,7 +176,7 @@ void Sound::playSound(ResourcePack *pack, int32 resId, bool looping, int32 volum
debugC(kDebugLevelSound, "playSound: handle for resId %d already active", resId);
} else {
ResourceEntry *ent = _soundPack->getResource(resId);
- playSoundData(&snd.handle, ent->data, ent->size, looping, volume, panning);
+ playSoundData(Audio::Mixer::kSFXSoundType, &snd.handle, ent->data, ent->size, looping, volume, panning);
addToSoundBuffer(resId);
}
}
@@ -228,7 +228,7 @@ void Sound::playSpeech(int32 resId) {
ResourceEntry *ent = _speechPack->getResource(resId);
_mixer->stopHandle(_speechHandle);
- playSoundData(&_speechHandle, ent->data, ent->size, false, 0, 0);
+ playSoundData(Audio::Mixer::kSpeechSoundType, &_speechHandle, ent->data, ent->size, false, 0, 0);
}
void Sound::playMusic(int32 resId) {
@@ -241,7 +241,7 @@ void Sound::playMusic(ResourcePack *pack, int32 resId) {
stopMusic();
ResourceEntry *resource = pack->getResource(resId);
- playSoundData(&_musicHandle, resource->data, resource->size, true, Config.musicVolume, 0);
+ playSoundData(Audio::Mixer::kMusicSoundType, &_musicHandle, resource->data, resource->size, true, Config.musicVolume, 0);
}
void Sound::stopMusic() {
@@ -249,41 +249,14 @@ void Sound::stopMusic() {
}
// from engines/agos/sound.cpp
-void Sound::playSoundData(Audio::SoundHandle *handle, byte *soundData, int32 soundDataLength, bool loop, int32 vol, int32 pan) {
- byte *buffer, flags;
- uint16 compType;
- int32 blockAlign, rate;
-
- // TODO: Use makeWAVStream() in future, when makeADPCMStream() allows sound looping
- int32 size = soundDataLength;
- Common::MemoryReadStream stream(soundData, size);
- if (!Audio::loadWAVFromStream(stream, size, rate, flags, &compType, &blockAlign))
- error("playSoundData: Not valid WAV data");
-
- convertVolume(vol);
- convertPan(pan);
-
- if (loop == true)
- flags |= Audio::Mixer::FLAG_LOOP;
-
- if (compType == 2) {
- Audio::AudioStream *sndStream = Audio::makeADPCMStream(&stream, false, size, Audio::kADPCMMS, rate, (flags & Audio::Mixer::FLAG_STEREO) ? 2 : 1, blockAlign);
- buffer = (byte *)malloc(size * 4);
- size = sndStream->readBuffer((int16*)buffer, size * 2);
- size *= 2; // 16bits.
- delete sndStream;
- } else {
- buffer = (byte *)malloc(size);
- memcpy(buffer, soundData + stream.pos(), size);
- }
+void Sound::playSoundData(Audio::Mixer::SoundType type, Audio::SoundHandle *handle, byte *soundData, int32 soundDataLength, bool loop, int32 vol, int32 pan) {
+ Common::MemoryReadStream *stream = new Common::MemoryReadStream(soundData, soundDataLength);
+ Audio::RewindableAudioStream *sndStream = Audio::makeWAVStream(stream, DisposeAfterUse::YES);
- // TODO
- // All asylum audio data is being filtered through the playSoundData()
- // method. As such, they're all using kSFXSoundType. There are also
- // enums for kMusicSoundType and kSpeechSoundType.
- //
- // Investigate how this can effect ... anything :P
- _mixer->playRaw(Audio::Mixer::kSFXSoundType, handle, buffer, size, DisposeAfterUse::YES, rate, flags, -1, vol, pan);
+ // FIXME need to convert the volume properly
+ vol = Audio::Mixer::kMaxChannelVolume;
+
+ _mixer->playInputStream(type, handle, Audio::makeLoopingAudioStream(sndStream, loop ? 0 : 1), -1, vol, pan);
}
} // end of namespace Asylum
diff --git a/engines/asylum/sound.h b/engines/asylum/sound.h
index 006aaaf9ba..3ddfdaf172 100644
--- a/engines/asylum/sound.h
+++ b/engines/asylum/sound.h
@@ -140,7 +140,7 @@ private:
* sound sample with provided id.
*/
int32 getBufferPosition(int32 resId);
- void playSoundData(Audio::SoundHandle *handle, byte *soundData, int32 soundDataLength, bool loop = false, int32 vol = 0, int32 pan = 0);
+ void playSoundData(Audio::Mixer::SoundType type, Audio::SoundHandle *handle, byte *soundData, int32 soundDataLength, bool loop = false, int32 vol = 0, int32 pan = 0);
};
} // end of namespace Asylum
Commit: 4665c8c55ed7f79ef48c74773c10c369be16375b
https://github.com/scummvm/scummvm/commit/4665c8c55ed7f79ef48c74773c10c369be16375b
Author: Joseph Davies (deledrius at gmail.com)
Date: 2021-05-17T15:36:01+02:00
Commit Message:
ASYLUM: Syncing with more ScummVM audio changes in trunk.
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@431 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/sound.cpp
diff --git a/engines/asylum/sound.cpp b/engines/asylum/sound.cpp
index 50b710c383..e84a3d7b04 100644
--- a/engines/asylum/sound.cpp
+++ b/engines/asylum/sound.cpp
@@ -29,8 +29,8 @@
#include "common/stream.h"
#include "sound/audiostream.h"
-#include "sound/adpcm.h"
-#include "sound/wave.h"
+#include "sound/decoders/adpcm.h"
+#include "sound/decoders/wave.h"
namespace Asylum {
Commit: 21b7c50021ad8c14b7755813a110ef3d58675fb2
https://github.com/scummvm/scummvm/commit/21b7c50021ad8c14b7755813a110ef3d58675fb2
Author: Alex Bevilacqua (alexbevi at gmail.com)
Date: 2021-05-17T15:36:01+02:00
Commit Message:
ASYLUM: identified a couple more actor object properties
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@432 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/actor.h
engines/asylum/worldstats.cpp
diff --git a/engines/asylum/actor.h b/engines/asylum/actor.h
index 6fba4542bb..c71b274d2a 100644
--- a/engines/asylum/actor.h
+++ b/engines/asylum/actor.h
@@ -238,9 +238,9 @@ public:
int32 field_948;
int32 field_94C;
int32 numberFlag01;
- int32 field_954;
- int32 field_958;
- int32 field_95C;
+ int32 numberStringWidth;
+ int32 numberStringX;
+ int32 numberStringY;
char numberString01[8];
int32 field_964;
int32 field_968;
diff --git a/engines/asylum/worldstats.cpp b/engines/asylum/worldstats.cpp
index 6374be91ff..0ef30a523a 100644
--- a/engines/asylum/worldstats.cpp
+++ b/engines/asylum/worldstats.cpp
@@ -370,9 +370,9 @@ void WorldStats::load(Common::SeekableReadStream *stream) {
actor.field_948 = stream->readSint32LE();
actor.field_94C = stream->readSint32LE();
actor.numberFlag01 = stream->readSint32LE();
- actor.field_954 = stream->readSint32LE();
- actor.field_958 = stream->readSint32LE();
- actor.field_95C = stream->readSint32LE();
+ actor.numberStringWidth = stream->readSint32LE();
+ actor.numberStringX = stream->readSint32LE();
+ actor.numberStringY = stream->readSint32LE();
stream->read(actor.numberString01, sizeof(actor.numberString01));
actor.field_964 = stream->readSint32LE();
actor.field_968 = stream->readSint32LE();
Commit: 81a5094f20b7858368c7cf7767fe512ec819e3a7
https://github.com/scummvm/scummvm/commit/81a5094f20b7858368c7cf7767fe512ec819e3a7
Author: Alex Bevilacqua (alexbevi at gmail.com)
Date: 2021-05-17T15:36:01+02:00
Commit Message:
ASYLUM: formatting
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@433 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/screen.cpp
diff --git a/engines/asylum/screen.cpp b/engines/asylum/screen.cpp
index 9d0caa8f74..71931a9963 100644
--- a/engines/asylum/screen.cpp
+++ b/engines/asylum/screen.cpp
@@ -145,7 +145,13 @@ void Screen::drawGraphicsInQueue() {
for (uint32 i = 0; i < _queueItems.size(); i++) {
GraphicResource *grRes = _vm->scene()->getGraphicResource(_queueItems[i].resId);
GraphicFrame *fra = grRes->getFrame(_queueItems[i].frameIdx);
- copyRectToScreenWithTransparency((byte *)fra->surface.pixels, fra->surface.w, _queueItems[i].x - ws->xLeft, _queueItems[i].y - ws->yTop, fra->surface.w, fra->surface.h);
+
+ copyRectToScreenWithTransparency((byte *)fra->surface.pixels,
+ fra->surface.w,
+ _queueItems[i].x - ws->xLeft, _queueItems[i].y - ws->yTop,
+ fra->surface.w,
+ fra->surface.h);
+
delete grRes;
}
}
Commit: bc43a2bfd5981f3cb6ab36a41eda85b5148cfe4d
https://github.com/scummvm/scummvm/commit/bc43a2bfd5981f3cb6ab36a41eda85b5148cfe4d
Author: Alex Bevilacqua (alexbevi at gmail.com)
Date: 2021-05-17T15:36:01+02:00
Commit Message:
ASYLUM: remove global_x/y (find a better way ... and actually finish it :P)
cleanup adjustScreen() a bit
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@434 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/asylum.cpp
engines/asylum/asylum.h
engines/asylum/scene.cpp
diff --git a/engines/asylum/asylum.cpp b/engines/asylum/asylum.cpp
index 7b0ce75317..578193a7bd 100644
--- a/engines/asylum/asylum.cpp
+++ b/engines/asylum/asylum.cpp
@@ -94,8 +94,9 @@ Common::Error AsylumEngine::init() {
_introPlaying = false;
- g_object_x = -1;
- g_object_y = -1;
+ // TODO
+ //g_object_x = -1;
+ //g_object_y = -1;
memset(_gameFlags, 0, 1512);
diff --git a/engines/asylum/asylum.h b/engines/asylum/asylum.h
index b448fb659d..bdfbf86104 100644
--- a/engines/asylum/asylum.h
+++ b/engines/asylum/asylum.h
@@ -41,9 +41,6 @@
namespace Asylum {
-static int32 g_object_x;
-static int32 g_object_y;
-
// XXX
// If defined, this will play the scene title loading up
// progress before the scene is entered. This is
diff --git a/engines/asylum/scene.cpp b/engines/asylum/scene.cpp
index c8bfd70d6e..f5208036a3 100644
--- a/engines/asylum/scene.cpp
+++ b/engines/asylum/scene.cpp
@@ -1354,8 +1354,9 @@ void Scene::updateAmbientSounds() {
}
int32 Scene::calculateVolumeAdjustment(AmbientSoundItem *snd, Actor *act) {
- int32 x, y;
+ //int32 x, y;
if (snd->field_10) {
+ /* FIXME properly handle global x/y
if (g_object_x == -1) {
x = snd->x - act->x1 - act->x2;
y = snd->y - act->y1 - act->y2;
@@ -1363,6 +1364,7 @@ int32 Scene::calculateVolumeAdjustment(AmbientSoundItem *snd, Actor *act) {
x = snd->x - g_object_x;
y = snd->y - g_object_y;
}
+ */
// FIXME vol = sub_432CA0(x ^ 2 + y ^ 2);
// Just assigning an arbitrary value for the
@@ -1388,127 +1390,57 @@ void Scene::updateMusic() {
}
void Scene::updateAdjustScreen() {
- int v5, v7, v15, v16; //, v6
- int v1 = -1;
- int v0 = -1;
+ Actor *act = getActor();
+ int32 newXLeft = -1;
+ int32 newYTop = -1;
+ Common::Rect b = _ws->boundingRect;
if (_ws->motionStatus == 1) {
- v5 = getActor()->x1 - _ws->xLeft;
- v7 = getActor()->y1 - _ws->yTop;
- if (v5 < _ws->boundingRect.left || v5 > _ws->boundingRect.right) {
- v15 = _ws->boundingRect.left - _ws->boundingRect.right;
- v1 = v15 + _ws->xLeft;
- _ws->xLeft += v15;
- }
- if (v7 < _ws->boundingRect.top || v7 > _ws->boundingRect.bottom) {
- v16 = v7 - _ws->boundingRect.bottom;
- v0 = v16 + _ws->yTop;
- _ws->yTop += v16;
- }
- if (v1 < 0)
- v1 = _ws->xLeft = 0;
- if (v1 > _ws->width - 640) {
- v1 = _ws->width - 640;
- _ws->xLeft = v1;
+ int32 posX = act->x1 - _ws->xLeft;
+ int32 posY = act->y1 - _ws->yTop;
+
+ if (posX < b.left || posX > b.right) {
+ int32 newRBounds = posX - b.right;
+ newXLeft = newRBounds + _ws->xLeft;
+ _ws->xLeft += newRBounds;
}
- if (v0 < 0)
- v0 = _ws->yTop = 0;
- if (v0 > _ws->height - 480) {
- v0 = _ws->height - 480;
- _ws->yTop = v0;
+
+ if (posY < b.top || posY > b.bottom) {
+ int32 newBBounds = posY - b.bottom;
+ newYTop = newBBounds + _ws->yTop;
+ _ws->yTop += newBBounds;
}
+
+ if (newXLeft < 0)
+ newXLeft = _ws->xLeft = 0;
+
+ if (newXLeft > _ws->width - 640)
+ newXLeft = _ws->xLeft = _ws->width - 640;
+
+ if (newYTop < 0)
+ newYTop = _ws->yTop = 0;
+
+ if (newYTop > _ws->height - 480)
+ newYTop = _ws->yTop = _ws->height - 480;
} else {
- if (_ws->motionStatus == 2 || _ws->motionStatus == 5) {
- if (_ws->motionStatus != 3) {
- // TODO
- /*
- __asm
- {
- fld flt_543514
- fadd flt_543518
- fstp flt_543514
- fild scene.field_98
- fsubr flt_54350C
- fild scene.field_9C
- fsubr flt_543510
- }
- v12 = abs(_ftol());
- if ( v12 <= abs(_ftol()) )
- {
- v2 = scene.field_9C;
- if ( scene.field_9C != scene.yTop )
- {
- __asm
- {
- fld flt_543514
- fadd flt_54350C
- }
- v14 = _ftol();
- v1 = v14;
- scene.xLeft = v14;
- }
- v4 = scene.field_A0;
- v0 += scene.field_A0;
- scene.yTop = v0;
- v3 = v0;
- }
- else
- {
- v2 = scene.field_98;
- if ( scene.field_98 != scene.xLeft )
- {
- __asm
- {
- fld flt_543514
- fadd flt_543510
- }
- v13 = _ftol();
- v0 = v13;
- scene.yTop = v13;
- }
- v4 = scene.field_A0;
- v1 += scene.field_A0;
- scene.xLeft = v1;
- v3 = v1;
- }
- if ( abs(v3 - v2) <= abs(v4) )
- {
- scene.field_88 = 3;
- scene.field_98 = -1;
- }
- }
- */
- }
- }
- }
- /*
- v9 = 16 * scene.sceneRectIndex;
- if ( v1 < *(LONG *)((char *)&scene.sceneRects[0].left + v9) )
- {
- v1 = *(LONG *)((char *)&scene.sceneRects[0].left + v9);
- scene.xLeft = *(LONG *)((char *)&scene.sceneRects[0].left + v9);
- }
- if ( v0 < *(LONG *)((char *)&scene.sceneRects[0].top + v9) )
- {
- v0 = *(LONG *)((char *)&scene.sceneRects[0].top + v9);
- scene.yTop = *(LONG *)((char *)&scene.sceneRects[0].top + v9);
- }
- v10 = *(LONG *)((char *)&scene.sceneRects[0].right + v9);
- if ( v1 + 639 > v10 )
- {
- v1 = v10 - 639;
- scene.xLeft = v10 - 639;
- }
- result = *(LONG *)((char *)&scene.sceneRects[0].bottom + v9);
- if ( v0 + 479 > result )
- {
- v0 = result - 479;
- scene.yTop = result - 479;
+ // TODO
}
- if ( v17 != v1 || v18 != v0 )
- dword_44E1EC = 2
- */
+ uint8 rectIndex = _ws->sceneRectIdx;
+ b = _ws->sceneRects[rectIndex];
+
+ if (newXLeft < b.left)
+ newXLeft = _ws->xLeft = b.left;
+
+ if (newYTop < b.top)
+ newYTop = _ws->yTop = b.top;
+
+ if (newXLeft + 639 > b.right)
+ newXLeft = _ws->xLeft = b.right - 639;
+
+ if (newYTop + 479 > b.bottom)
+ newYTop = _ws->yTop = b.bottom - 479;
+
}
// ----------------------------------
@@ -1526,7 +1458,8 @@ int Scene::drawScene() {
GraphicFrame *bg = _bgResource->getFrame(0);
_vm->screen()->copyToBackBuffer(
- ((byte *)bg->surface.pixels) + _ws->yTop * bg->surface.w + _ws->xLeft, bg->surface.w,
+ ((byte *)bg->surface.pixels) + _ws->yTop * bg->surface.w + _ws->xLeft,
+ bg->surface.w,
0,
0,
640,
Commit: 36f4a64535916aae1bd6b01fce2b35c0a115d8e9
https://github.com/scummvm/scummvm/commit/36f4a64535916aae1bd6b01fce2b35c0a115d8e9
Author: Alex Bevilacqua (alexbevi at gmail.com)
Date: 2021-05-17T15:36:01+02:00
Commit Message:
ASYLUM: fix warning (extra ;)
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@435 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/config.cpp
diff --git a/engines/asylum/config.cpp b/engines/asylum/config.cpp
index 1f072524c4..f331192d2d 100644
--- a/engines/asylum/config.cpp
+++ b/engines/asylum/config.cpp
@@ -25,7 +25,7 @@
#include "asylum/config.h"
-DECLARE_SINGLETON(Asylum::ConfigurationManager);
+DECLARE_SINGLETON(Asylum::ConfigurationManager)
namespace Asylum {
Commit: 784ee55823269f65bf99ad680d7e2e2122f248e2
https://github.com/scummvm/scummvm/commit/784ee55823269f65bf99ad680d7e2e2122f248e2
Author: Alex Bevilacqua (alexbevi at gmail.com)
Date: 2021-05-17T15:36:02+02:00
Commit Message:
ASYLUM: clean up
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@436 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/actionlist.cpp
engines/asylum/actionlist.h
diff --git a/engines/asylum/actionlist.cpp b/engines/asylum/actionlist.cpp
index b2da2b6740..67a67a61bf 100644
--- a/engines/asylum/actionlist.cpp
+++ b/engines/asylum/actionlist.cpp
@@ -165,11 +165,6 @@ static const AsylumFunction function_map[] = {
#undef MAPFUNC
void ActionList::resetQueue() {
- /*
- memset(&_scripts, 0, sizeof(ScriptQueue));
- for (int i = 0; i < 10; i++)
- _scripts.entries[i].actionListIndex = -1;
- */
_scripts.clear();
}
@@ -178,33 +173,6 @@ void ActionList::queueScript(int actionIndex, int actorIndex) {
// It appears to remain false 99% of the time, so I'm guessing
// it's a "skip processing" flag.
if (!_actionFlag) {
-
- /*
- int i;
- // iterate through the availble entry slots to determine
- // the next available slot
- for (i = 1; i < 10; i++) {
- if (_scripts.entries[i].actionListIndex == -1)
- break;
- }
-
- _scene->actions()->entries[actionIndex].counter = 0;
-
- _scripts.entries[i].field_10 = 0;
- _scripts.entries[i].field_C = 0;
-
- if (_scripts.count) {
- _scripts.entries[_scripts.field_CC].field_C = i ;
- _scripts.entries[0].field_10 = _scripts.field_CC;
- } else {
- _scripts.count = i;
- }
- _scripts.field_CC = i;
- _scripts.entries[0].actionListIndex = actionIndex;
- _scripts.entries[0].actionListItemIndex = 0;
- _scripts.entries[0].actorIndex = actorIndex;
- */
-
ScriptQueueEntry entry;
entry.actionListIndex = actionIndex;
entry.actorIndex = actorIndex;
@@ -221,108 +189,6 @@ void ActionList::queueScript(int actionIndex, int actorIndex) {
}
}
-/*
-void ActionList::updateQueue(int queueIndex) {
- if (_scripts.count == _scripts.field_CC) {
- _scripts.field_CC = 0;
- _scripts.count = 0;
- _scripts.entries[queueIndex].actionListIndex = -1;
- } else {
- if (_scripts.count == queueIndex) {
- _scripts.count = _scripts.entries[queueIndex].field_C;
- _scripts.entries[queueIndex].field_10 = 0;
- _scripts.entries[queueIndex].actionListIndex = -1;
- } else {
- if (_scripts.field_CC == queueIndex) {
- _scripts.field_CC = _scripts.entries[queueIndex].field_10;
- _scripts.entries[queueIndex].field_C = 0;
- _scripts.entries[queueIndex].actionListIndex = -1;
- } else {
- int tmp10 = _scripts.entries[queueIndex].field_10;
- int tmpC = _scripts.entries[queueIndex].field_C;
- _scripts.entries[tmp10].field_C = _scripts.entries[queueIndex].field_C;
- _scripts.entries[tmpC].field_10 = _scripts.entries[queueIndex].field_10;
- _scripts.entries[queueIndex].actionListIndex = -1;
- }
- }
- }
-}
-*/
-
-void ActionList::processActionListSub02(Script* script, ScriptEntry *command, int a4) {
- //int v4 = 0;
- int result;
- int barrierIdx = 0;
- if (a4) {
- if (a4 == 1) {
- ;
- } else {
- result = a4 - 2;
- int v8 = command->param4;
-
- for (int i = 7; i > 0; i--) {
- barrierIdx = _scene->worldstats()->getBarrierIndexById(v8);
- if (barrierIdx >= 0)
- _scene->worldstats()->barriers[barrierIdx].field_67C = 0;
- v8 += 4;
- }
- }
- // TODO
- switch (_scene->getSceneIndex()) {
- case 7:
- warning("Scene 7 / v4 != 0 Not Implemented");
- break;
- case 6:
- warning("Scene 6 / v4 != 0 Not Implemented");
- break;
- case 8:
- warning("Scene 8 / v4 != 0 Not Implemented");
- break;
- case 3:
- warning("Scene 3 / v4 != 0 Not Implemented");
- break;
- case 4:
- warning("Scene 4 / v4 != 0 Not Implemented");
- break;
- default:
- return;
- }
- } else {
- int v13 = command->param4;
- int v4 = script->counter / command->param2 + 4;
- for (int i = 7; i > 0; i--) {
- barrierIdx = _scene->worldstats()->getBarrierIndexById(v13);
- if (barrierIdx >= 0)
- _scene->worldstats()->barriers[barrierIdx].field_67C = v4;
- v13 += 4;
- }
- // TODO
- switch (_scene->getSceneIndex()) {
- case 7:
- warning("Scene 7 / v4 = 0 Not Implemented");
- break;
- case 6:
- warning("Scene 6 / v4 = 0 Not Implemented");
- break;
- case 8:
- warning("Scene 8 / v4 = 0 Not Implemented");
- break;
- case 3:
- warning("Scene 3 / v4 = 0 Not Implemented");
- break;
- case 4:
- warning("Scene 4 / v4 = 0 Not Implemented");
- break;
- default:
- return;
- }
- }
-}
-
-void ActionList::enableActorSub(int actorIndex, int condition) {
-
-}
-
int ActionList::process() {
done = false;
waitCycle = false;
@@ -339,7 +205,7 @@ int ActionList::process() {
int32 opcode = currentCommand->opcode;
debugC(kDebugLevelScripts,
- "[0x%02d] %s(%d, %d, %d, %d, %d, %d, %d, %d, %d)",
+ "[0x%02X] %s(%d, %d, %d, %d, %d, %d, %d, %d, %d)",
opcode,function_map[opcode].name,
currentCommand->param1,
currentCommand->param2,
@@ -356,20 +222,22 @@ int ActionList::process() {
// Check function return
if (cmdRet == -1)
- warning("Incomplete opcode %s (0x%02X) in Scene %d Line %d",
- function_map[opcode].name,
- currentCommand->opcode,
- _scene->getSceneIndex(),
- currentLine);
+ debugC(kDebugLevelScripts,
+ "Incomplete opcode %s (0x%02X) in Scene %d Line %d",
+ function_map[opcode].name,
+ currentCommand->opcode,
+ _scene->getSceneIndex(),
+ currentLine);
if (cmdRet == -2)
- warning("Unhandled opcode %s (0x%02X) in Scene %d Line %d",
- function_map[opcode].name,
- currentCommand->opcode,
- _scene->getSceneIndex(),
- currentLine);
-
+ debugC(kDebugLevelScripts,
+ "Unhandled opcode %s (0x%02X) in Scene %d Line %d",
+ function_map[opcode].name,
+ currentCommand->opcode,
+ _scene->getSceneIndex(),
+ currentLine);
if (cmdRet == -3)
- warning("Flagged (see implemenation comments) opcode %s (0x%02X) in Scene %d Line %d",
+ debugC(kDebugLevelScripts,
+ "Flagged (see implementation comments) opcode %s (0x%02X) in Scene %d Line %d",
function_map[opcode].name,
currentCommand->opcode,
_scene->getSceneIndex(),
@@ -676,10 +544,12 @@ int kEnableActor(Script *script, ScriptEntry *cmd, Scene *scn) {
else
actorIndex = cmd->param1;
+ /* TODO implement enableActorSub()
if (scn->worldstats()->actors[actorIndex].updateType == 5)
scn->actions()->enableActorSub(actorIndex, 4);
+ */
- return 0;
+ return -1;
}
int kEnableBarriers(Script *script, ScriptEntry *cmd, Scene *scn) {
@@ -698,7 +568,7 @@ int kEnableBarriers(Script *script, ScriptEntry *cmd, Scene *scn) {
if (script->counter >= (3 * cmd->param2 - 1)) {
script->counter = 0;
bar->field_67C = 0;
- scn->actions()->processActionListSub02(script, cmd, 2);
+ // TODO scn->actions()->processActionListSub02(script, cmd, 2);
} else {
int v64; // XXX rename when processActionListSub02 is better implemented
script->counter += 1;
@@ -710,7 +580,7 @@ int kEnableBarriers(Script *script, ScriptEntry *cmd, Scene *scn) {
bar->field_67C = script->counter / cmd->param2 + 1;
}
- scn->actions()->processActionListSub02(script, cmd, v64);
+ // TODO scn->actions()->processActionListSub02(script, cmd, v64);
}
return -1;
diff --git a/engines/asylum/actionlist.h b/engines/asylum/actionlist.h
index d1da9f5824..03e5508f5b 100644
--- a/engines/asylum/actionlist.h
+++ b/engines/asylum/actionlist.h
@@ -55,29 +55,16 @@ typedef struct ScriptEntry {
typedef struct Script {
ScriptEntry commands[MAX_ACTION_COMMANDS];
- int32 field_1BAC;
- int32 field_1BB0;
- int32 counter;
+ int32 field_1BAC;
+ int32 field_1BB0;
+ int32 counter;
} Script;
typedef struct ScriptQueueEntry {
int32 actionListIndex;
- //int32 actionListItemIndex;
int32 actorIndex;
- //int32 field_C;
- //int32 field_10;
-
} ScriptQueueEntry;
-/*
-typedef struct ScriptQueue {
- ScriptQueueEntry entries[10];
- int32 count;
- int32 field_CC;
-
-} ScriptQueue;
-*/
-
class ActionList {
public:
ActionList(Common::SeekableReadStream *stream, Scene *scene);
@@ -96,10 +83,10 @@ public:
int32 currentLoops;
int32 delayedSceneIndex;
int32 delayedVideoIndex;
- bool allowInput;
+ bool allowInput;
int32 lineIncrement;
- bool done;
- bool waitCycle;
+ bool done;
+ bool waitCycle;
/** .text:00402120
* Process the current script
@@ -114,28 +101,20 @@ public:
* the actor at actorIndex
*/
void queueScript(int32 actionIndex, int32 actorIndex);
- /** .text:00401100
- * Update the queued scripts
- */
- //void updateQueue(int32 queueIndex);
/**
* Toggle the action queue processing flag
*/
void setActionFlag(bool value) { _actionFlag = value; }
-
- void processActionListSub02(Script* script, ScriptEntry* command, int32 a4);
- void enableActorSub(int32 actorIndex, int32 condition);
-
private:
Scene *_scene;
bool _actionFlag;
- //ScriptQueue _scripts;
Common::Stack<ScriptQueueEntry> _scripts;
Script *_currentScript;
ScriptQueueEntry _currentQueueEntry;
void load(Common::SeekableReadStream *stream);
-};
+
+}; // end of class ActionList
// opcode functions
int32 kReturn0(Script *script, ScriptEntry *cmd, Scene *scn);
Commit: 0194e07fcc1af65d53afa710f1102be59fdf4969
https://github.com/scummvm/scummvm/commit/0194e07fcc1af65d53afa710f1102be59fdf4969
Author: Alex Bevilacqua (alexbevi at gmail.com)
Date: 2021-05-17T15:36:02+02:00
Commit Message:
ASYLUM: added detection entry for version from gog.com
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@437 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/detection.cpp
diff --git a/engines/asylum/detection.cpp b/engines/asylum/detection.cpp
index 6e8623c5bb..6be15e3155 100644
--- a/engines/asylum/detection.cpp
+++ b/engines/asylum/detection.cpp
@@ -68,6 +68,20 @@ static const ADGameDescription gameDescriptions[] = {
ADGF_NO_FLAGS,
Common::GUIO_NONE
},
+ {
+ "asylum",
+ "GOG.com",
+ {
+ {"SNTRM.DAT", 0, "7cfcc457c1f579fbf9878ac175d29374", 8930},
+ {"RES.000", 0, "f58f8dc3e63663f174977d359e11132c", 272057},
+ {"SCN.006", 0, "3a5b54da08198012dc0614114782d5fb", 2918330},
+ {0,0,0,0}
+ },
+ Common::EN_ANY,
+ Common::kPlatformPC,
+ ADGF_NO_FLAGS,
+ Common::GUIO_NONE
+ },
{
"asylum",
"French Version",
Commit: 748960b9b6e4ec2b7c53a366a34230c1c95dcb32
https://github.com/scummvm/scummvm/commit/748960b9b6e4ec2b7c53a366a34230c1c95dcb32
Author: Alex Bevilacqua (alexbevi at gmail.com)
Date: 2021-05-17T15:36:02+02:00
Commit Message:
ASYLUM: new debug level for barriers
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@438 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/asylum.cpp
engines/asylum/asylum.h
diff --git a/engines/asylum/asylum.cpp b/engines/asylum/asylum.cpp
index 578193a7bd..30f9934c3e 100644
--- a/engines/asylum/asylum.cpp
+++ b/engines/asylum/asylum.cpp
@@ -47,12 +47,14 @@ AsylumEngine::AsylumEngine(OSystem *system, Common::Language language)
Common::addDebugChannel(kDebugLevelSound, "Sound", "Sound debugging");
Common::addDebugChannel(kDebugLevelSavegame, "Savegame", "Saving & restoring game debugging");
Common::addDebugChannel(kDebugLevelScene, "Scene", "Scene process and draw debugging");
+ Common::addDebugChannel(kDebugLevelBarriers, "Barriers", "Debug Barrier Objects");
SearchMan.addSubDirectoryMatching(_gameDataDir, "data");
SearchMan.addSubDirectoryMatching(_gameDataDir, "vids");
SearchMan.addSubDirectoryMatching(_gameDataDir, "music");
Common::enableDebugChannel("Scripts");
+ Common::enableDebugChannel("Barriers");
g_eventRec.registerRandomSource(_rnd, "asylum");
}
diff --git a/engines/asylum/asylum.h b/engines/asylum/asylum.h
index bdfbf86104..0a2b2e45b1 100644
--- a/engines/asylum/asylum.h
+++ b/engines/asylum/asylum.h
@@ -81,7 +81,8 @@ enum kDebugLevels {
kDebugLevelScripts = 1 << 5,
kDebugLevelSound = 1 << 6,
kDebugLevelSavegame = 1 << 7,
- kDebugLevelScene = 1 << 8
+ kDebugLevelScene = 1 << 8,
+ kDebugLevelBarriers = 1 << 9
};
class AsylumEngine: public Engine {
Commit: 63941ec0c5a0d7e365ca169ee80853aa36565a32
https://github.com/scummvm/scummvm/commit/63941ec0c5a0d7e365ca169ee80853aa36565a32
Author: Alex Bevilacqua (alexbevi at gmail.com)
Date: 2021-05-17T15:36:02+02:00
Commit Message:
ASYLUM: include "common/random.h"
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@439 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/asylum.h
diff --git a/engines/asylum/asylum.h b/engines/asylum/asylum.h
index 0a2b2e45b1..010353fa93 100644
--- a/engines/asylum/asylum.h
+++ b/engines/asylum/asylum.h
@@ -26,6 +26,8 @@
#ifndef ASYLUM_ENGINE_H
#define ASYLUM_ENGINE_H
+#include "common/random.h"
+
#include "engines/engine.h"
#include "asylum/staticres.h"
Commit: 8ffc46acb2be81aed9eef9c7517e2eeed10e5b70
https://github.com/scummvm/scummvm/commit/8ffc46acb2be81aed9eef9c7517e2eeed10e5b70
Author: Alex Bevilacqua (alexbevi at gmail.com)
Date: 2021-05-17T15:36:02+02:00
Commit Message:
ASYLUM: fix compile with latest trunk
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@440 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/sound.cpp
diff --git a/engines/asylum/sound.cpp b/engines/asylum/sound.cpp
index e84a3d7b04..4801d8de59 100644
--- a/engines/asylum/sound.cpp
+++ b/engines/asylum/sound.cpp
@@ -256,7 +256,7 @@ void Sound::playSoundData(Audio::Mixer::SoundType type, Audio::SoundHandle *hand
// FIXME need to convert the volume properly
vol = Audio::Mixer::kMaxChannelVolume;
- _mixer->playInputStream(type, handle, Audio::makeLoopingAudioStream(sndStream, loop ? 0 : 1), -1, vol, pan);
+ _mixer->playStream(type, handle, Audio::makeLoopingAudioStream(sndStream, loop ? 0 : 1), -1, vol, pan);
}
} // end of namespace Asylum
Commit: ed378d586c1faf2203ab3ee0a3b2425681b92196
https://github.com/scummvm/scummvm/commit/ed378d586c1faf2203ab3ee0a3b2425681b92196
Author: Joseph Davies (deledrius at gmail.com)
Date: 2021-05-17T15:36:02+02:00
Commit Message:
ASYLUM: Fixed clipping (Issue #5). Fixed sprite delay when scrolling by using backbuffer.
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@441 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/screen.cpp
diff --git a/engines/asylum/screen.cpp b/engines/asylum/screen.cpp
index 71931a9963..35b7d4de95 100644
--- a/engines/asylum/screen.cpp
+++ b/engines/asylum/screen.cpp
@@ -52,13 +52,16 @@ void Screen::copyToBackBuffer(byte *buffer, int32 pitch, int32 x, int32 y, int32
}
void Screen::copyToBackBufferWithTransparency(byte *buffer, int32 pitch, int32 x, int32 y, int32 width, int32 height) {
- // int32 h = height;
- // int32 w = width;
byte *dest = (byte *)_backBuffer.pixels;
-
- for (int32 curY = 0; curY < height; curY++) {
- for (int32 curX = 0; curX < width; curX++) {
- if (buffer[curX + curY * pitch] != 0) {
+
+ int32 left = (x < 0) ? -x : 0;
+ int32 top = (y < 0) ? -y : 0;
+ int32 right = (x + width > 640) ? 640 - abs(x) : width;
+ int32 bottom = (y + height > 480) ? 480 - abs(y) : height;
+
+ for (int32 curY = top; curY < bottom; curY++) {
+ for (int32 curX = left; curX < right; curX++) {
+ if (buffer[curX + curY * pitch] != 0 ) {
dest[x + curX + (y + curY) * 640] = buffer[curX + curY * pitch];
}
}
@@ -71,10 +74,15 @@ void Screen::copyRectToScreen(byte *buffer, int32 pitch, int32 x, int32 y, int32
void Screen::copyRectToScreenWithTransparency(byte *buffer, int32 pitch, int32 x, int32 y, int32 width, int32 height) {
byte *screenBuffer = (byte *)_vm->_system->lockScreen()->pixels;
-
- for (int32 curY = 0; curY < height; curY++) {
- for (int32 curX = 0; curX < width; curX++) {
- if (buffer[curX + curY * pitch] != 0 && (x + curX + (y + curY) * 640 <= 640*480)) {
+
+ int32 left = (x < 0) ? -x : 0;
+ int32 top = (y < 0) ? -y : 0;
+ int32 right = (x + width > 640) ? 640 - abs(x) : width;
+ int32 bottom = (y + height > 480) ? 480 - abs(y) : height;
+
+ for (int32 curY = top; curY < bottom; curY++) {
+ for (int32 curX = left; curX < right; curX++) {
+ if (buffer[curX + curY * pitch] != 0) {
screenBuffer[x + curX + (y + curY) * 640] = buffer[curX + curY * pitch];
}
}
@@ -144,9 +152,9 @@ void Screen::drawGraphicsInQueue() {
for (uint32 i = 0; i < _queueItems.size(); i++) {
GraphicResource *grRes = _vm->scene()->getGraphicResource(_queueItems[i].resId);
- GraphicFrame *fra = grRes->getFrame(_queueItems[i].frameIdx);
-
- copyRectToScreenWithTransparency((byte *)fra->surface.pixels,
+ GraphicFrame *fra = grRes->getFrame(_queueItems[i].frameIdx);
+
+ copyToBackBufferWithTransparency((byte *)fra->surface.pixels,
fra->surface.w,
_queueItems[i].x - ws->xLeft, _queueItems[i].y - ws->yTop,
fra->surface.w,
Commit: 6a94eee3c201d344853c5bcaaca129e1072e30c1
https://github.com/scummvm/scummvm/commit/6a94eee3c201d344853c5bcaaca129e1072e30c1
Author: Joseph Davies (deledrius at gmail.com)
Date: 2021-05-17T15:36:03+02:00
Commit Message:
ASYLUM: Changed uses of rand() to utilize AsylumeEngine::_rnd instead (Issue #4).
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@442 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/actionlist.cpp
engines/asylum/asylum.h
engines/asylum/scene.cpp
diff --git a/engines/asylum/actionlist.cpp b/engines/asylum/actionlist.cpp
index 67a67a61bf..b2de311cf9 100644
--- a/engines/asylum/actionlist.cpp
+++ b/engines/asylum/actionlist.cpp
@@ -1037,7 +1037,7 @@ int k_unk53(Script *script, ScriptEntry *cmd, Scene *scn) {
int k_unk54_SET_ACTIONLIST_6EC(Script *script, ScriptEntry *cmd, Scene *scn) {
if (cmd->param2)
- script->field_1BB0 = rand() % cmd->param1;
+ script->field_1BB0 = scn->vm()->_rnd.getRandomNumber(cmd->param1);
else
script->field_1BB0 = cmd->param1;
diff --git a/engines/asylum/asylum.h b/engines/asylum/asylum.h
index 010353fa93..edead17ce3 100644
--- a/engines/asylum/asylum.h
+++ b/engines/asylum/asylum.h
@@ -133,6 +133,8 @@ public:
Screen* screen() { return _screen; }
Scene* scene() { return _scene;}
Text* text() { return _text; }
+
+ Common::RandomSource _rnd;
private:
void checkForEvent(bool doUpdate);
@@ -146,7 +148,6 @@ private:
void playIntro();
Common::Language _language;
- Common::RandomSource _rnd;
bool _introPlaying;
diff --git a/engines/asylum/scene.cpp b/engines/asylum/scene.cpp
index f5208036a3..87a9dcfa10 100644
--- a/engines/asylum/scene.cpp
+++ b/engines/asylum/scene.cpp
@@ -275,7 +275,7 @@ void Scene::updateActorDirection(int actorIndex, int param) {
// active (via the global at .data:00543504)
// FIXME skipping for now
if (0) {
- if (rand() % -2 == 1 && defaultActorDirectionLoaded(actorIndex, 15)) {
+ if (vm()->_rnd.getRandomNumber(-2) == 1 && defaultActorDirectionLoaded(actorIndex, 15)) {
actor->frameNum = 0;
if (actor->direction > 4)
actor->direction = 8 - actor->direction;
@@ -1022,7 +1022,7 @@ void Scene::updateActor(int32 actorIdx) {
actor->frameNum = frameNum % actor->frameCount;
if (_vm->getTick() - actor->tickValue1 > 300) {
- if (rand() % 100 < 50) {
+ if (vm()->_rnd.getRandomNumber(100) < 50) {
// TODO: check sound playing
}
actor->tickValue1 = _vm->getTick();
@@ -1082,7 +1082,7 @@ void Scene::updateActorSub01(Actor *act) {
if (_vm->getTick() - act->tickValue1 > 300) {
// TODO
// Check if the actor's name is "Crow"?
- if (rand() % 100 < 50) {
+ if (vm()->_rnd.getRandomNumber(100) < 50) {
// TODO
// Check if soundResId04 is assigned, and if so,
// if it's playing
@@ -1098,7 +1098,7 @@ void Scene::updateActorSub01(Actor *act) {
if (act->visible()) {
// if some_encounter_flag
// if !soundResId04
- if (rand() % 100 < 50) {
+ if (vm()->_rnd.getRandomNumber(100) < 50) {
if (_sceneIdx == 13) {
; // sub414810(507)
} else {
@@ -1159,7 +1159,7 @@ void Scene::updateBarriers() {
int equalZero = frameIdx == 0;
if (!frameIdx) {
if (_vm->getTick() - barrier->tickCount >= 1000 * barrier->tickCount2) {
- if (rand() % barrier->field_C0 == 1) {
+ if (vm()->_rnd.getRandomNumber(barrier->field_C0) == 1) {
if (barrier->field_68C[0]) {
// TODO: fix this, and find a better way to get frame count
// Sometimes we get wrong random resource id
@@ -1202,7 +1202,7 @@ void Scene::updateBarriers() {
}
} else if ((flag & 0xFF) & 8) { // check this
if (_vm->getTick() - barrier->tickCount >= 1000 * barrier->tickCount2) {
- if (rand() % barrier->field_C0 == 1) { // TODO: THIS ISNT WORKING
+ if (vm()->_rnd.getRandomNumber(barrier->field_C0) == 1) { // TODO: THIS ISNT WORKING
barrier->frameIdx = (barrier->frameIdx + 1) % barrier->frameCount;
barrier->tickCount = _vm->getTick();
canPlaySound = true;
@@ -1324,12 +1324,12 @@ void Scene::updateAmbientSounds() {
}
if (loflag & 2) {
int tmpVol = volume;
- if (rand() % 10000 < 10) {
+ if (vm()->_rnd.getRandomNumber(10000) < 10) {
if (snd->field_0) {
_vm->sound()->playSound(snd->resId, false, volume, panning, false);
} else {
// FIXME will this even work?
- tmpVol += (rand() % 500) * (((rand() % 100 >= 50) - 1) & 2) - 1;
+ tmpVol += (vm()->_rnd.getRandomNumber(500)) * (((vm()->_rnd.getRandomNumber(100) >= 50) - 1) & 2) - 1;
if (tmpVol <= -10000)
volume = -10000;
if (volume >= 0)
@@ -1337,7 +1337,7 @@ void Scene::updateAmbientSounds() {
else
if (tmpVol <= -10000)
tmpVol = -10000;
- _vm->sound()->playSound(snd->resId, 0, tmpVol, rand() % 20001 - 10000);
+ _vm->sound()->playSound(snd->resId, 0, tmpVol, vm()->_rnd.getRandomNumber(20001) - 10000);
}
}
} else {
Commit: c31a0d39c88ebb9ad8058770f68e9345e65ece9d
https://github.com/scummvm/scummvm/commit/c31a0d39c88ebb9ad8058770f68e9345e65ece9d
Author: Joseph Davies (deledrius at gmail.com)
Date: 2021-05-17T15:36:03+02:00
Commit Message:
ASYLUM: Fix warning introduced by r442.
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@443 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/scene.cpp
diff --git a/engines/asylum/scene.cpp b/engines/asylum/scene.cpp
index 87a9dcfa10..47f799adea 100644
--- a/engines/asylum/scene.cpp
+++ b/engines/asylum/scene.cpp
@@ -275,7 +275,7 @@ void Scene::updateActorDirection(int actorIndex, int param) {
// active (via the global at .data:00543504)
// FIXME skipping for now
if (0) {
- if (vm()->_rnd.getRandomNumber(-2) == 1 && defaultActorDirectionLoaded(actorIndex, 15)) {
+ if (vm()->_rnd.getRandomBit() == 1 && defaultActorDirectionLoaded(actorIndex, 15)) {
actor->frameNum = 0;
if (actor->direction > 4)
actor->direction = 8 - actor->direction;
Commit: 3fdd3ab5b9e5fa55bb384f4bff5631c29d6cd957
https://github.com/scummvm/scummvm/commit/3fdd3ab5b9e5fa55bb384f4bff5631c29d6cd957
Author: Alex Bevilacqua (alexbevi at gmail.com)
Date: 2021-05-17T15:36:03+02:00
Commit Message:
ASYLUM: silenced a couple gcc warnings
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@444 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/cursor.cpp
engines/asylum/cursor.h
diff --git a/engines/asylum/cursor.cpp b/engines/asylum/cursor.cpp
index cad2dab7e1..81dac67f09 100644
--- a/engines/asylum/cursor.cpp
+++ b/engines/asylum/cursor.cpp
@@ -18,8 +18,8 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * $URL$
- * $Id$
+ * $URL: https://asylumengine.googlecode.com/svn/trunk/cursor.cpp $
+ * $Id: cursor.cpp 427 2010-01-13 11:53:51Z alexbevi $
*
*/
@@ -60,7 +60,7 @@ void Cursor::load(int32 index) {
}
*/
-void Cursor::create(Cursor *&cursor, ResourcePack *pack, uint32 id) {
+void Cursor::create(Cursor *&cursor, ResourcePack *pack, int32 id) {
// If the current cursor resource is already assigned
// to the id value we're sending, just return
// TODO this simplifies a lot of additional validation calls
@@ -85,7 +85,7 @@ void Cursor::show() {
CursorMan.showMouse(true);
}
-void Cursor::set(uint32 resId, int32 counter, int32 flags, int32 frames) {
+void Cursor::set(uint32 resId, int32 cntr, int32 flgs, int32 frames) {
if (_cursorRes)
delete _cursorRes;
@@ -95,8 +95,8 @@ void Cursor::set(uint32 resId, int32 counter, int32 flags, int32 frames) {
frameCount = frames;
else
frameCount = _cursorRes->getFrameCount();
- this->flags = flags;
- this->counter = counter;
+ this->flags = flgs;
+ this->counter = cntr;
currentFrame = 0;
_cursor_byte_45756C = 1;
diff --git a/engines/asylum/cursor.h b/engines/asylum/cursor.h
index ff35593966..6d83dededf 100644
--- a/engines/asylum/cursor.h
+++ b/engines/asylum/cursor.h
@@ -18,8 +18,8 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * $URL$
- * $Id$
+ * $URL: https://asylumengine.googlecode.com/svn/trunk/cursor.h $
+ * $Id: cursor.h 427 2010-01-13 11:53:51Z alexbevi $
*
*/
@@ -45,7 +45,7 @@ public:
* Generate a new cursor instance from the resource id
* within the resource pack provided.
*/
- static void create(Cursor *&cursor, ResourcePack *pack, uint32 id);
+ static void create(Cursor *&cursor, ResourcePack *pack, int32 id);
/**
* Show the current cursor
@@ -63,7 +63,7 @@ public:
* frame count should be derived from the graphic resource as opposed to being
* explicitely set.
*/
- void set(uint32 resId, int32 counter, int32 flags, int32 frames = -1);
+ void set(uint32 resId, int32 cntr, int32 flgs, int32 frames = -1);
/**
* Set the x/y coordinates of the cursor
*/
Commit: 17fec87f91213de8d95beba9c9cd5c2ece07b45e
https://github.com/scummvm/scummvm/commit/17fec87f91213de8d95beba9c9cd5c2ece07b45e
Author: Alex Bevilacqua (alexbevi at gmail.com)
Date: 2021-05-17T15:36:03+02:00
Commit Message:
ASYLUM: fixed cppcheck warning (Mismatching allocation and deallocation)
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@445 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/video.cpp
diff --git a/engines/asylum/video.cpp b/engines/asylum/video.cpp
index 2007f3b4a6..554348e8c9 100644
--- a/engines/asylum/video.cpp
+++ b/engines/asylum/video.cpp
@@ -76,10 +76,10 @@ bool VideoPlayer::playVideoWithSubtitles(Common::List<Common::Event> &stopEvents
_subtitles.push_back(newSubtitle);
}
- delete line;
+ delete [] line;
}
- delete buffer;
+ delete [] buffer;
return playVideo(stopEvents);
}
Commit: d467701cc779b2fbe265f68c88534cad37d79185
https://github.com/scummvm/scummvm/commit/d467701cc779b2fbe265f68c88534cad37d79185
Author: Alex Bevilacqua (alexbevi at gmail.com)
Date: 2021-05-17T15:36:03+02:00
Commit Message:
ASYLUM: set svn props
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@446 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/cursor.cpp
engines/asylum/cursor.h
diff --git a/engines/asylum/cursor.cpp b/engines/asylum/cursor.cpp
index 81dac67f09..6a344734eb 100644
--- a/engines/asylum/cursor.cpp
+++ b/engines/asylum/cursor.cpp
@@ -18,8 +18,8 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * $URL: https://asylumengine.googlecode.com/svn/trunk/cursor.cpp $
- * $Id: cursor.cpp 427 2010-01-13 11:53:51Z alexbevi $
+ * $URL$
+ * $Id$
*
*/
diff --git a/engines/asylum/cursor.h b/engines/asylum/cursor.h
index 6d83dededf..aa3ee372c9 100644
--- a/engines/asylum/cursor.h
+++ b/engines/asylum/cursor.h
@@ -18,8 +18,8 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * $URL: https://asylumengine.googlecode.com/svn/trunk/cursor.h $
- * $Id: cursor.h 427 2010-01-13 11:53:51Z alexbevi $
+ * $URL$
+ * $Id$
*
*/
Commit: 362cce9b63df178de5be165a3a31b2f73bd6096b
https://github.com/scummvm/scummvm/commit/362cce9b63df178de5be165a3a31b2f73bd6096b
Author: Joseph Davies (deledrius at gmail.com)
Date: 2021-05-17T15:36:03+02:00
Commit Message:
ASYLUM: Changes for Debug Manager in trunk.
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@447 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/asylum.cpp
diff --git a/engines/asylum/asylum.cpp b/engines/asylum/asylum.cpp
index 30f9934c3e..7e8f2030df 100644
--- a/engines/asylum/asylum.cpp
+++ b/engines/asylum/asylum.cpp
@@ -38,29 +38,29 @@ namespace Asylum {
AsylumEngine::AsylumEngine(OSystem *system, Common::Language language)
: Engine(system) {
- Common::addDebugChannel(kDebugLevelMain, "Main", "Generic debug level");
- Common::addDebugChannel(kDebugLevelResources, "Resources", "Resources debugging");
- Common::addDebugChannel(kDebugLevelSprites, "Sprites", "Sprites debugging");
- Common::addDebugChannel(kDebugLevelInput, "Input", "Input events debugging");
- Common::addDebugChannel(kDebugLevelMenu, "Menu", "Menu debugging");
- Common::addDebugChannel(kDebugLevelScripts, "Scripts", "Scripts debugging");
- Common::addDebugChannel(kDebugLevelSound, "Sound", "Sound debugging");
- Common::addDebugChannel(kDebugLevelSavegame, "Savegame", "Saving & restoring game debugging");
- Common::addDebugChannel(kDebugLevelScene, "Scene", "Scene process and draw debugging");
- Common::addDebugChannel(kDebugLevelBarriers, "Barriers", "Debug Barrier Objects");
+ DebugMan.addDebugChannel(kDebugLevelMain, "Main", "Generic debug level");
+ DebugMan.addDebugChannel(kDebugLevelResources, "Resources", "Resources debugging");
+ DebugMan.addDebugChannel(kDebugLevelSprites, "Sprites", "Sprites debugging");
+ DebugMan.addDebugChannel(kDebugLevelInput, "Input", "Input events debugging");
+ DebugMan.addDebugChannel(kDebugLevelMenu, "Menu", "Menu debugging");
+ DebugMan.addDebugChannel(kDebugLevelScripts, "Scripts", "Scripts debugging");
+ DebugMan.addDebugChannel(kDebugLevelSound, "Sound", "Sound debugging");
+ DebugMan.addDebugChannel(kDebugLevelSavegame, "Savegame", "Saving & restoring game debugging");
+ DebugMan.addDebugChannel(kDebugLevelScene, "Scene", "Scene process and draw debugging");
+ DebugMan.addDebugChannel(kDebugLevelBarriers, "Barriers", "Debug Barrier Objects");
SearchMan.addSubDirectoryMatching(_gameDataDir, "data");
SearchMan.addSubDirectoryMatching(_gameDataDir, "vids");
SearchMan.addSubDirectoryMatching(_gameDataDir, "music");
- Common::enableDebugChannel("Scripts");
- Common::enableDebugChannel("Barriers");
+ DebugMan.enableDebugChannel("Scripts");
+ DebugMan.enableDebugChannel("Barriers");
g_eventRec.registerRandomSource(_rnd, "asylum");
}
AsylumEngine::~AsylumEngine() {
- Common::clearAllDebugChannels();
+ DebugMan.clearAllDebugChannels();
delete _console;
delete _scene;
Commit: e5beddf490b2e78953f1e3eed6aef9cd6e400606
https://github.com/scummvm/scummvm/commit/e5beddf490b2e78953f1e3eed6aef9cd6e400606
Author: Filippos Karapetis (md5 at scummvm.org)
Date: 2021-05-17T15:36:04+02:00
Commit Message:
ASYLUM: Fixed compilation
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@448 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/asylum.cpp
diff --git a/engines/asylum/asylum.cpp b/engines/asylum/asylum.cpp
index 7e8f2030df..c5bc725ee7 100644
--- a/engines/asylum/asylum.cpp
+++ b/engines/asylum/asylum.cpp
@@ -24,11 +24,15 @@
*/
#include "common/config-manager.h"
+#include "common/debug-channels.h"
#include "common/events.h"
#include "common/system.h"
#include "common/file.h"
#include "common/EventRecorder.h"
+#include "engines/advancedDetector.h"
+#include "engines/util.h"
+
#include "asylum/asylum.h"
#include "asylum/respack.h"
#include "asylum/config.h"
@@ -49,9 +53,11 @@ AsylumEngine::AsylumEngine(OSystem *system, Common::Language language)
DebugMan.addDebugChannel(kDebugLevelScene, "Scene", "Scene process and draw debugging");
DebugMan.addDebugChannel(kDebugLevelBarriers, "Barriers", "Debug Barrier Objects");
- SearchMan.addSubDirectoryMatching(_gameDataDir, "data");
- SearchMan.addSubDirectoryMatching(_gameDataDir, "vids");
- SearchMan.addSubDirectoryMatching(_gameDataDir, "music");
+ const Common::FSNode gameDataDir(ConfMan.get("path"));
+
+ SearchMan.addSubDirectoryMatching(gameDataDir, "data");
+ SearchMan.addSubDirectoryMatching(gameDataDir, "vids");
+ SearchMan.addSubDirectoryMatching(gameDataDir, "music");
DebugMan.enableDebugChannel("Scripts");
DebugMan.enableDebugChannel("Barriers");
Commit: 92ebb5af97fe81aa6f0e82e4e6f4959a12eb1ccf
https://github.com/scummvm/scummvm/commit/92ebb5af97fe81aa6f0e82e4e6f4959a12eb1ccf
Author: Filippos Karapetis (md5 at scummvm.org)
Date: 2021-05-17T15:36:04+02:00
Commit Message:
ASYLUM: Silenced a warning
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@449 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/scene.cpp
diff --git a/engines/asylum/scene.cpp b/engines/asylum/scene.cpp
index 47f799adea..2539f8e3ab 100644
--- a/engines/asylum/scene.cpp
+++ b/engines/asylum/scene.cpp
@@ -822,7 +822,7 @@ void Scene::handleMouseUpdate(int direction, Common::Rect rect) {
_cursor->set(_ws->curTalkNPC2, 0, 2);
}
} else {
- int32 targetUpdateType;
+ int32 targetUpdateType = 0;
switch (type) {
case kHitActionArea:
targetUpdateType = _ws->actions[targetIdx].actionType;
Commit: a2fcb22eeda70c3bb909289fd878d08acf6853a6
https://github.com/scummvm/scummvm/commit/a2fcb22eeda70c3bb909289fd878d08acf6853a6
Author: Joseph Davies (deledrius at gmail.com)
Date: 2021-05-17T15:36:04+02:00
Commit Message:
ASYLUM: Add support for subtitles configuration option.
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@450 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/config.cpp
diff --git a/engines/asylum/config.cpp b/engines/asylum/config.cpp
index f331192d2d..87a173091b 100644
--- a/engines/asylum/config.cpp
+++ b/engines/asylum/config.cpp
@@ -53,6 +53,7 @@ void ConfigurationManager::read() {
musicVolume = ConfMan.getInt("music_volume");
sfxVolume = ConfMan.getInt("sfx_volume");
voiceVolume = ConfMan.getInt("speech_volume");
+ showMovieSubtitles = (VideoSubtitles)ConfMan.getBool("subtitles");
}
void ConfigurationManager::write() {
@@ -60,6 +61,7 @@ void ConfigurationManager::write() {
ConfMan.setInt("music_volume", musicVolume);
ConfMan.setInt("sfx_volume", sfxVolume);
ConfMan.setInt("speech_volume", voiceVolume);
+ ConfMan.setBool("subtitles", (bool)showMovieSubtitles);
}
} // end of namespace Asylum
Commit: 8b8a843282457082d44598e0c59e486ea65df6fd
https://github.com/scummvm/scummvm/commit/8b8a843282457082d44598e0c59e486ea65df6fd
Author: Joseph Davies (deledrius at gmail.com)
Date: 2021-05-17T15:36:04+02:00
Commit Message:
ASYLUM: Changes for VideoDecoder in trunk.
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@451 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/video.cpp
engines/asylum/video.h
diff --git a/engines/asylum/video.cpp b/engines/asylum/video.cpp
index 554348e8c9..d26d24dcbc 100644
--- a/engines/asylum/video.cpp
+++ b/engines/asylum/video.cpp
@@ -26,21 +26,94 @@
#include "asylum/video.h"
namespace Asylum {
+
+Video::Video(Audio::Mixer *mixer): _skipVideo(false) {
+ Common::Event stopEvent;
+ _stopEvents.clear();
+ stopEvent.type = Common::EVENT_KEYDOWN;
+ stopEvent.kbd.keycode = Common::KEYCODE_ESCAPE;
+ _stopEvents.push_back(stopEvent);
-VideoPlayer::VideoPlayer(Graphics::VideoDecoder *decoder) :
- Graphics::VideoPlayer(decoder) {
+ _smkDecoder = new Graphics::SmackerDecoder(mixer);
+
_text = new VideoText();
ResourcePack *resPack = new ResourcePack(1);
_text->loadFont(resPack, 57); // video font
delete resPack;
}
-VideoPlayer::~VideoPlayer() {
+Video::~Video() {
+ delete _smkDecoder;
delete _text;
}
-bool VideoPlayer::playVideoWithSubtitles(Common::List<Common::Event> &stopEvents, int32 videoNumber) {
+bool Video::playVideo(int32 videoNumber, VideoSubtitles subtitles) {
+ bool lastMouseState = false;
+ char filename[20];
+
+ sprintf(filename, "mov%03d.smk", videoNumber);
+
+ bool result = _smkDecoder->loadFile(filename);
+
+ lastMouseState = g_system->showMouse(false);
+ if (result) {
+ _skipVideo = false;
+ if(subtitles == kSubtitlesOn) {
+ loadSubtitles(videoNumber);
+ }
+
+ uint16 x = (g_system->getWidth() - _smkDecoder->getWidth()) / 2;
+ uint16 y = (g_system->getHeight() - _smkDecoder->getHeight()) / 2;
+
+ while (!_smkDecoder->endOfVideo() && !_skipVideo) {
+ processVideoEvents();
+ if (_smkDecoder->needsUpdate()) {
+ Graphics::Surface *frame = _smkDecoder->decodeNextFrame();
+
+ if (frame) {
+ g_system->copyRectToScreen((byte *)frame->pixels, frame->pitch, x, y, frame->w, frame->h);
+
+ if(subtitles) {
+ Graphics::Surface *screen = g_system->lockScreen();
+ performPostProcessing((byte *)screen->pixels);
+ g_system->unlockScreen();
+ }
+
+ if (_smkDecoder->hasDirtyPalette())
+ _smkDecoder->setSystemPalette();
+
+ g_system->updateScreen();
+ }
+ }
+ g_system->delayMillis(10);
+ }
+ }
+ _smkDecoder->close();
+ _subtitles.clear();
+ g_system->showMouse(lastMouseState);
+
+ return result;
+}
+
+void Video::performPostProcessing(byte *screen) {
+ int32 curFrame = _smkDecoder->getCurFrame();
+
+ // Reset subtitle area, by filling it with zeroes
+ memset(screen + 640 * 400, 0, 640 * 80);
+
+ for (uint32 i = 0; i < _subtitles.size(); i++) {
+ VideoSubtitle curSubtitle = _subtitles[i];
+ if (curFrame >= curSubtitle.frameStart &&
+ curFrame <= curSubtitle.frameEnd) {
+ _text->drawMovieSubtitle(screen, curSubtitle.textRes);
+ break;
+ }
+ }
+}
+
+void Video::loadSubtitles(int32 videoNumber) {
// Read vids.cap
+
char movieToken[10];
sprintf(movieToken, "[MOV%03d]", videoNumber);
@@ -80,62 +153,31 @@ bool VideoPlayer::playVideoWithSubtitles(Common::List<Common::Event> &stopEvents
}
delete [] buffer;
-
- return playVideo(stopEvents);
}
-void VideoPlayer::performPostProcessing(byte *screen) {
- int32 curFrame = _decoder->getCurFrame();
-
- // Reset subtitle area, by filling it with zeroes
- memset(screen + 640 * 400, 0, 640 * 80);
-
- for (uint32 i = 0; i < _subtitles.size(); i++) {
- VideoSubtitle curSubtitle = _subtitles[i];
- if (curFrame >= curSubtitle.frameStart &&
- curFrame <= curSubtitle.frameEnd) {
- _text->drawMovieSubtitle(screen, curSubtitle.textRes);
- break;
+void Video::processVideoEvents() {
+ Common::Event curEvent;
+ while (g_system->getEventManager()->pollEvent(curEvent)) {
+ if (curEvent.type == Common::EVENT_RTL || curEvent.type == Common::EVENT_QUIT) {
+ _skipVideo = true;
+ }
+
+ for (Common::List<Common::Event>::const_iterator iter = _stopEvents.begin(); iter != _stopEvents.end(); ++iter) {
+ if (curEvent.type == iter->type) {
+ if (iter->type == Common::EVENT_KEYDOWN || iter->type == Common::EVENT_KEYUP) {
+ if (curEvent.kbd.keycode == iter->kbd.keycode) {
+ _skipVideo = true;
+ break;
+ }
+ } else {
+ _skipVideo = true;
+ break;
+ }
+ }
}
}
}
-Video::Video(Audio::Mixer *mixer) {
- Common::Event stopEvent;
- _stopEvents.clear();
- stopEvent.type = Common::EVENT_KEYDOWN;
- stopEvent.kbd = Common::KEYCODE_ESCAPE;
- _stopEvents.push_back(stopEvent);
-
- _smkDecoder = new Graphics::SmackerDecoder(mixer);
- _player = new VideoPlayer(_smkDecoder);
-}
-
-Video::~Video() {
- delete _player;
- delete _smkDecoder;
-}
-
-bool Video::playVideo(int32 number, VideoSubtitles subtitles) {
- bool lastMouseState = false;
- char filename[20];
-
- sprintf(filename, "mov%03d.smk", number);
-
- bool result = _smkDecoder->loadFile(filename);
-
- lastMouseState = g_system->showMouse(false);
- if (result) {
- if (subtitles == kSubtitlesOff)
- _player->playVideo(_stopEvents);
- else
- _player->playVideoWithSubtitles(_stopEvents, number);
- }
- _smkDecoder->closeFile();
- g_system->showMouse(lastMouseState);
-
- return result;
-}
VideoText::VideoText() {
_curFontFlags = 0;
diff --git a/engines/asylum/video.h b/engines/asylum/video.h
index 4ecc0db33a..edb44e5328 100644
--- a/engines/asylum/video.h
+++ b/engines/asylum/video.h
@@ -29,7 +29,6 @@
#include "sound/mixer.h"
#include "graphics/surface.h"
#include "graphics/video/smk_decoder.h"
-#include "graphics/video/video_player.h"
#include "common/array.h"
#include "common/events.h"
@@ -53,31 +52,23 @@ enum VideoSubtitles {
class VideoText;
-class VideoPlayer : public Graphics::VideoPlayer {
-public:
- VideoPlayer(Graphics::VideoDecoder* decoder);
- virtual ~VideoPlayer();
-
- bool playVideoWithSubtitles(Common::List<Common::Event> &stopEvents, int videoNumber);
-
-private:
- void performPostProcessing(byte *screen);
-
- VideoText *_text;
- Common::Array<VideoSubtitle> _subtitles;
-};
-
class Video {
public:
Video(Audio::Mixer *mixer);
virtual ~Video();
- bool playVideo(int number, VideoSubtitles subtitles);
-
+ bool playVideo(int32 videoNumber, VideoSubtitles subtitles);
+
private:
+ void performPostProcessing(byte *screen);
+ void loadSubtitles(int32 videoNumber);
+ void processVideoEvents();
+
+ bool _skipVideo;
+ VideoText *_text;
+ Graphics::SmackerDecoder *_smkDecoder;
Common::List<Common::Event> _stopEvents;
- Graphics::SmackerDecoder *_smkDecoder;
- VideoPlayer *_player;
+ Common::Array<VideoSubtitle> _subtitles;
}; // end of class Video
// The VideoText class has some methods from the Text class,
Commit: 53a233697d4b9f0b63ca36b9a494f9694ebd87ae
https://github.com/scummvm/scummvm/commit/53a233697d4b9f0b63ca36b9a494f9694ebd87ae
Author: Alex Bevilacqua (alexbevi at gmail.com)
Date: 2021-05-17T15:36:04+02:00
Commit Message:
ASYLUM: pass actor index to updateActor (as opposed to just grabbing the default actor each time)
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@452 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/asylum.cpp
diff --git a/engines/asylum/asylum.cpp b/engines/asylum/asylum.cpp
index c5bc725ee7..e224ebab6a 100644
--- a/engines/asylum/asylum.cpp
+++ b/engines/asylum/asylum.cpp
@@ -59,9 +59,6 @@ AsylumEngine::AsylumEngine(OSystem *system, Common::Language language)
SearchMan.addSubDirectoryMatching(gameDataDir, "vids");
SearchMan.addSubDirectoryMatching(gameDataDir, "music");
- DebugMan.enableDebugChannel("Scripts");
- DebugMan.enableDebugChannel("Barriers");
-
g_eventRec.registerRandomSource(_rnd, "asylum");
}
Commit: 6119be865dca5b84021a355f1529380d3b98e73b
https://github.com/scummvm/scummvm/commit/6119be865dca5b84021a355f1529380d3b98e73b
Author: Alex Bevilacqua (alexbevi at gmail.com)
Date: 2021-05-17T15:36:04+02:00
Commit Message:
ASYLUM: change isAttached to isActive for console debugger check
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@453 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/asylum.cpp
diff --git a/engines/asylum/asylum.cpp b/engines/asylum/asylum.cpp
index e224ebab6a..47c996264f 100644
--- a/engines/asylum/asylum.cpp
+++ b/engines/asylum/asylum.cpp
@@ -272,7 +272,7 @@ void AsylumEngine::checkForEvent(bool doUpdate) { // k_sub_40AE30 (0040AE30)
// Copy background image
_screen->copyBackBufferToScreen();
- if (_console->isAttached())
+ if (_console->isActive())
_console->onFrame();
}
Commit: 16d01549c0bac6eee399e46cd81ab07472ae7217
https://github.com/scummvm/scummvm/commit/16d01549c0bac6eee399e46cd81ab07472ae7217
Author: Alex Bevilacqua (alexbevi at gmail.com)
Date: 2021-05-17T15:36:04+02:00
Commit Message:
ASYLUM: whitespace cleanup
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@454 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/menu.cpp
engines/asylum/worldstats.cpp
diff --git a/engines/asylum/menu.cpp b/engines/asylum/menu.cpp
index 44f719442a..0f88bb9d14 100644
--- a/engines/asylum/menu.cpp
+++ b/engines/asylum/menu.cpp
@@ -31,28 +31,28 @@
namespace Asylum {
MainMenu::MainMenu(AsylumEngine *vm): _vm(vm) {
- _leftClick = false;
- _activeIcon = -1;
+ _leftClick = false;
+ _activeIcon = -1;
_previousActiveIcon = -1;
- _curIconFrame = 0;
- _curMouseCursor = 0;
- _cursorStep = 1;
- _creditsBgFrame = 0;
- _creditsTextScroll = 0x1E0 - 30;
- _activeMenuScreen = kMainMenu;
- _active = false;
+ _curIconFrame = 0;
+ _curMouseCursor = 0;
+ _cursorStep = 1;
+ _creditsBgFrame = 0;
+ _creditsTextScroll = 0x1E0 - 30;
+ _activeMenuScreen = kMainMenu;
+ _active = false;
Config.gammaLevel = 2;
Config.performance = 5;
- _resPack = new ResourcePack(1);
- _bgResource = new GraphicResource(_resPack, 0);
- _eyeResource = new GraphicResource(_resPack, 1);
+ _resPack = new ResourcePack(1);
+ _bgResource = new GraphicResource(_resPack, 0);
+ _eyeResource = new GraphicResource(_resPack, 1);
_cursor = new Cursor(_resPack);
- _iconResource = 0;
- _creditsResource = 0;
+ _iconResource = 0;
+ _creditsResource = 0;
_creditsFadeResource = 0;
loadFont(kFontYellow);
@@ -82,17 +82,15 @@ void MainMenu::loadFont(Fonts font) {
}
void MainMenu::switchFont(bool condition) {
- if (condition)
- loadFont(kFontYellow);
- else
- loadFont(kFontBlue);
+ loadFont((condition) ? kFontYellow : kFontBlue);
}
void MainMenu::openMenu() {
_active = true;
- if (_vm->scene()) {
- _vm->scene()->deactivate();
- }
+
+ if (_vm->scene()) {
+ _vm->scene()->deactivate();
+ }
loadFont(kFontYellow);
@@ -221,10 +219,10 @@ void MainMenu::update() {
_vm->sound()->playMusic(_resPack, 38);
break;
case kReturnToGame:
- if (_vm->scene()) { // FIXME: do this properly
- closeMenu();
- _vm->scene()->enterScene();
- }
+ if (_vm->scene()) { // FIXME: do this properly
+ closeMenu();
+ _vm->scene()->enterScene();
+ }
break;
}
}
diff --git a/engines/asylum/worldstats.cpp b/engines/asylum/worldstats.cpp
index 0ef30a523a..af2163bda5 100644
--- a/engines/asylum/worldstats.cpp
+++ b/engines/asylum/worldstats.cpp
@@ -147,7 +147,7 @@ void WorldStats::load(Common::SeekableReadStream *stream) {
curTalkNPC2 = stream->readSint32LE();
font1 = stream->readSint32LE();
font2 = stream->readSint32LE();
- font3 = stream->readSint32LE();
+ font3 = stream->readSint32LE();
palette = stream->readSint32LE();
cellShadeMask1 = stream->readSint32LE();
cellShadeMask2 = stream->readSint32LE();
Commit: 5d48974ebd34f7a7f3f9817932b9a3023739a58b
https://github.com/scummvm/scummvm/commit/5d48974ebd34f7a7f3f9817932b9a3023739a58b
Author: Alex Bevilacqua (alexbevi at gmail.com)
Date: 2021-05-17T15:36:05+02:00
Commit Message:
ASYLUM: reimplement main menu
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@455 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/asylum.cpp
engines/asylum/asylum.h
engines/asylum/cursor.cpp
engines/asylum/cursor.h
engines/asylum/menu.cpp
engines/asylum/menu.h
engines/asylum/module.mk
diff --git a/engines/asylum/asylum.cpp b/engines/asylum/asylum.cpp
index 47c996264f..a4f64f993f 100644
--- a/engines/asylum/asylum.cpp
+++ b/engines/asylum/asylum.cpp
@@ -67,7 +67,7 @@ AsylumEngine::~AsylumEngine() {
delete _console;
delete _scene;
- //delete _mainMenu;
+ delete _mainMenu;
delete _video;
delete _sound;
delete _screen;
@@ -93,7 +93,7 @@ Common::Error AsylumEngine::init() {
_video = new Video(_mixer);
_console = new Console(this);
_text = new Text(_screen);
- //_mainMenu = 0;
+ _mainMenu = 0;
_scene = 0;
//_encounter = 0;
@@ -120,15 +120,15 @@ Common::Error AsylumEngine::go() {
_video->playVideo(0, Config.showMovieSubtitles);
#endif
- // Set up main menu
- //_mainMenu = new MainMenu(this);
+ // Set up main menu
+ _mainMenu = new MainMenu(this);
// TODO: if savegame not exists on folder, than start game()
- //if(0) { //SearchMan.hasArchive
- startGame();
- //} else {
- // _mainMenu->openMenu();
- //}
+ //if(0) { //SearchMan.hasArchive
+ startGame();
+ //} else {
+ // _mainMenu->openMenu();
+ //}
while (!shouldQuit()) {
checkForEvent(true);
@@ -143,26 +143,26 @@ void AsylumEngine::waitForTimer(int msec_delay) {
while (_system->getMillis() < start_time + msec_delay) {
checkForEvent(false);
- if (_scene) {
- processDelayedEvents();
- }
+ if (_scene) {
+ processDelayedEvents();
+ }
_system->updateScreen();
}
}
void AsylumEngine::startGame() {
- // TODO: reset what need to be reset for a new game
-
- if (_scene) {
- delete _scene;
- }
-
- _scene = new Scene(5, this);
-
+ // TODO: reset what need to be reset for a new game
+
+ if (_scene) {
+ delete _scene;
+ }
+
+ _scene = new Scene(5, this);
+
#ifndef SKIP_INTRO
- playIntro();
+ playIntro();
#endif
- _scene->initialize();
+ _scene->initialize();
// FIXME This is just here for testing purposes. It is also defined
// in the processActionList() method when the necessary action is fired.
@@ -173,18 +173,18 @@ void AsylumEngine::startGame() {
// XXX Testing
//_encounter = new Encounter(_scene);
- // Enter first scene
- if(!_introPlaying)
- {
+ // Enter first scene
+ if(!_introPlaying)
+ {
setGameFlag(4);
- setGameFlag(12);
- _scene->enterScene();
- }
+ setGameFlag(12);
+ _scene->enterScene();
+ }
}
void AsylumEngine::playIntro() {
- _introPlaying = true;
- g_system->showMouse(false);
+ _introPlaying = true;
+ g_system->showMouse(false);
_video->playVideo(1, Config.showMovieSubtitles);
@@ -234,14 +234,15 @@ void AsylumEngine::checkForEvent(bool doUpdate) { // k_sub_40AE30 (0040AE30)
if (ev.type == Common::EVENT_KEYDOWN) {
if (ev.kbd.keycode == Common::KEYCODE_ESCAPE) {
// Toggle menu
- /* FIXME reimplement later
if (_mainMenu->isActive()) {
- if (_scene) {
- _mainMenu->closeMenu();
- _scene->enterScene();
- }
+ if (_scene) {
+ _mainMenu->closeMenu();
+ _scene->enterScene();
+ }
} else if (_scene && _scene->isActive()) {
_mainMenu->openMenu();
+ }
+ /* FIXME
} else if (_scene && _scene->getBlowUpPuzzle()->isActive()) {
_scene->getBlowUpPuzzle()->closeBlowUp();
_scene->enterScene();
@@ -253,9 +254,9 @@ void AsylumEngine::checkForEvent(bool doUpdate) { // k_sub_40AE30 (0040AE30)
// XXX: TEST ONLY
/*
if (ev.kbd.keycode == Common::KEYCODE_b) {
- if (_scene) {
- _scene->getBlowUpPuzzle()->openBlowUp();
- }
+ if (_scene) {
+ _scene->getBlowUpPuzzle()->openBlowUp();
+ }
}
*/
if (ev.kbd.flags == Common::KBD_CTRL) {
@@ -267,8 +268,8 @@ void AsylumEngine::checkForEvent(bool doUpdate) { // k_sub_40AE30 (0040AE30)
}
if (doUpdate) {
- if (_scene && _scene->isActive())
- //if (_mainMenu->isActive() || (_scene && _scene->isActive()) || (_scene && _scene->getBlowUpPuzzle()->isActive()))
+ if (_mainMenu->isActive() ||
+ (_scene && _scene->isActive())) //|| (_scene && _scene->getBlowUpPuzzle()->isActive()))
// Copy background image
_screen->copyBackBufferToScreen();
@@ -276,20 +277,18 @@ void AsylumEngine::checkForEvent(bool doUpdate) { // k_sub_40AE30 (0040AE30)
_console->onFrame();
}
- /* FIXME reimplement
+
if (_mainMenu->isActive())
// Main menu active, pass events to it
_mainMenu->handleEvent(&ev, doUpdate);
else if (_scene && _scene->isActive())
// Pass events to the game
_scene->handleEvent(&ev, doUpdate);
+ /* FIXME reimplement
else if (_scene && _scene->getBlowUpPuzzle()->isActive())
// Pass events to BlowUp Puzzles
_scene->getBlowUpPuzzle()->handleEvent(&ev, doUpdate);
*/
- if (_scene && _scene->isActive())
- // Pass events to the game
- _scene->handleEvent(&ev, doUpdate);
}
void AsylumEngine::processDelayedEvents() {
@@ -301,14 +300,11 @@ void AsylumEngine::processDelayedEvents() {
_video->playVideo(videoIdx, kSubtitlesOn);
_scene->actions()->delayedVideoIndex = -1;
- /* FIXME reimplement
+
if (_mainMenu->isActive())
_mainMenu->openMenu();
else if (_scene->isActive())
_scene->enterScene();
- */
- if (_scene->isActive())
- _scene->enterScene();
}
// check for a delayed scene change
diff --git a/engines/asylum/asylum.h b/engines/asylum/asylum.h
index edead17ce3..8c12bdc25d 100644
--- a/engines/asylum/asylum.h
+++ b/engines/asylum/asylum.h
@@ -33,7 +33,7 @@
#include "asylum/staticres.h"
#include "asylum/console.h"
#include "asylum/scene.h"
-//#include "asylum/menu.h"
+#include "asylum/menu.h"
#include "asylum/screen.h"
#include "asylum/sound.h"
#include "asylum/video.h"
@@ -67,7 +67,7 @@ namespace Asylum {
class Console;
class Scene;
-//class MainMenu;
+class MainMenu;
class Scene;
class Screen;
class Sound;
@@ -97,18 +97,18 @@ public:
* Initalize the game environment
*/
Common::Error init();
-
- /** .text:0041A500
+
+ /** .text:0041A500
* Start the game environment
*/
Common::Error go();
virtual Common::Error run();
virtual bool hasFeature(EngineFeature f) const;
- /** .text:00415830
+ /** .text:00415830
* Start a new the game
*/
- void startGame();
+ void startGame();
void setGameFlag(int flag);
void clearGameFlag(int flag);
@@ -133,8 +133,8 @@ public:
Screen* screen() { return _screen; }
Scene* scene() { return _scene;}
Text* text() { return _text; }
-
- Common::RandomSource _rnd;
+
+ Common::RandomSource _rnd;
private:
void checkForEvent(bool doUpdate);
@@ -142,18 +142,18 @@ private:
void updateMouseCursor();
void processDelayedEvents();
- /** .text:0041B630
+ /** .text:0041B630
* Start a new the game
*/
void playIntro();
- Common::Language _language;
+ Common::Language _language;
bool _introPlaying;
Console *_console;
Scene *_scene;
- //MainMenu *_mainMenu;
+ MainMenu *_mainMenu;
Screen *_screen;
Sound *_sound;
Video *_video;
diff --git a/engines/asylum/cursor.cpp b/engines/asylum/cursor.cpp
index 6a344734eb..0ab9be6346 100644
--- a/engines/asylum/cursor.cpp
+++ b/engines/asylum/cursor.cpp
@@ -132,8 +132,9 @@ void Cursor::move(int16 x, int16 y) {
_pos.y = y;
}
-/*
+
void Cursor::animate() {
+ /*
_curFrame += _cursorStep;
if (_curFrame == 0)
_cursorStep = 1;
@@ -141,8 +142,8 @@ void Cursor::animate() {
_cursorStep = -1;
set(_curFrame);
+ */
}
-*/
/*
void Cursor::update(WorldStats *ws, int32 currentAction) {
diff --git a/engines/asylum/cursor.h b/engines/asylum/cursor.h
index aa3ee372c9..1023b3863f 100644
--- a/engines/asylum/cursor.h
+++ b/engines/asylum/cursor.h
@@ -78,11 +78,12 @@ public:
* scene, where it originally was
*/
//void update(WorldStats *ws, int32 currentAction);
+
/**
* Get the next logical frame from the currently loaded
* cursorResource and draw it
*/
- //void animate();
+ void animate();
void update();
diff --git a/engines/asylum/menu.cpp b/engines/asylum/menu.cpp
index 0f88bb9d14..a21dc57a05 100644
--- a/engines/asylum/menu.cpp
+++ b/engines/asylum/menu.cpp
@@ -106,7 +106,7 @@ void MainMenu::openMenu() {
bg->surface.h);
// Set mouse cursor
- _cursor->load(2);
+ Cursor::create(_cursor, _resPack, 2);
_cursor->show();
// Stop all sounds
@@ -137,7 +137,7 @@ void MainMenu::handleEvent(Common::Event *event, bool doUpdate) {
switch (_ev->type) {
case Common::EVENT_MOUSEMOVE:
- _cursor->setCoords(_ev->mouse.x, _ev->mouse.y);
+ _cursor->move(_ev->mouse.x, _ev->mouse.y);
break;
case Common::EVENT_LBUTTONUP:
_leftClick = true;
@@ -170,7 +170,7 @@ void MainMenu::update() {
_activeMenuScreen = (MenuScreen) _activeIcon;
// Set the cursor
- _cursor->load(3);
+ Cursor::create(_cursor, _resPack, 3);
}
switch (_activeIcon) {
@@ -233,24 +233,24 @@ void MainMenu::updateEyesAnimation() {
// Get the appropriate eye resource depending on the mouse position
int32 eyeFrameNum = kEyesFront;
- if (_cursor->x() <= 200) {
- if (_cursor->y() <= 160)
+ if (_cursor->position().x <= 200) {
+ if (_cursor->position().y <= 160)
eyeFrameNum = kEyesTopLeft;
- else if (_cursor->y() > 160 && _cursor->y() <= 320)
+ else if (_cursor->position().y > 160 && _cursor->position().y <= 320)
eyeFrameNum = kEyesLeft;
else
eyeFrameNum = kEyesBottomLeft;
- } else if (_cursor->x() > 200 && _cursor->x() <= 400) {
- if (_cursor->y() <= 160)
+ } else if (_cursor->position().x > 200 && _cursor->position().x <= 400) {
+ if (_cursor->position().y <= 160)
eyeFrameNum = kEyesTop;
- else if (_cursor->y() > 160 && _cursor->y() <= 320)
+ else if (_cursor->position().y > 160 && _cursor->position().y <= 320)
eyeFrameNum = kEyesFront;
else
eyeFrameNum = kEyesBottom;
- } else if (_cursor->x() > 400) {
- if (_cursor->y() <= 160)
+ } else if (_cursor->position().x > 400) {
+ if (_cursor->position().y <= 160)
eyeFrameNum = kEyesTopRight;
- else if (_cursor->y() > 160 && _cursor->y() <= 320)
+ else if (_cursor->position().y > 160 && _cursor->position().y <= 320)
eyeFrameNum = kEyesRight;
else
eyeFrameNum = kEyesBottomRight;
@@ -264,9 +264,9 @@ void MainMenu::updateEyesAnimation() {
void MainMenu::updateMainMenu() {
int32 rowId = 0;
- if (_cursor->y() >= 20 && _cursor->y() <= 20 + 48) {
+ if (_cursor->position().y >= 20 && _cursor->position().y <= 20 + 48) {
rowId = 0; // Top row
- } else if (_cursor->y() >= 400 && _cursor->y() <= 400 + 48) {
+ } else if (_cursor->position().y >= 400 && _cursor->position().y <= 400 + 48) {
rowId = 1; // Bottom row
} else {
// No row selected
@@ -280,7 +280,7 @@ void MainMenu::updateMainMenu() {
// Icon animation
for (int32 i = 0; i <= 5; i++) {
int32 curX = 40 + i * 100;
- if (_cursor->x() >= curX && _cursor->x() <= curX + 55) {
+ if (_cursor->position().x >= curX && _cursor->position().x <= curX + 55) {
int32 iconNum = i + 6 * rowId;
_activeIcon = iconNum;
@@ -377,25 +377,25 @@ void MainMenu::updateSubMenuNewGame() {
_vm->text()->drawResTextCentered(10, 100, 620, 0x80000529);
// Yes
- switchFont(_cursor->x() < 247 || _cursor->x() > 247 + _vm->text()->getResTextWidth(0x8000052A) || _cursor->y() < 273 || _cursor->y() > 273 + 24);
+ switchFont(_cursor->position().x < 247 || _cursor->position().x > 247 + _vm->text()->getResTextWidth(0x8000052A) || _cursor->position().y < 273 || _cursor->position().y > 273 + 24);
_vm->text()->setTextPos(247, 273);
_vm->text()->drawResText(0x8000052A);
// No
- switchFont(_cursor->x() < 369 || _cursor->x() > 369 + _vm->text()->getResTextWidth(0x8000052B) || _cursor->y() < 273 || _cursor->y() > 273 + 24);
+ switchFont(_cursor->position().x < 369 || _cursor->position().x > 369 + _vm->text()->getResTextWidth(0x8000052B) || _cursor->position().y < 273 || _cursor->position().y > 273 + 24);
_vm->text()->setTextPos(369, 273);
_vm->text()->drawResText(0x8000052B);
// action
if (_leftClick) {
// Yes
- if (_cursor->x() >= 247 && _cursor->x() <= 247 + 24 && _cursor->y() >= 273 && _cursor->y() <= 273 + _vm->text()->getResTextWidth(0x8000052A)) {
+ if (_cursor->position().x >= 247 && _cursor->position().x <= 247 + 24 && _cursor->position().y >= 273 && _cursor->position().y <= 273 + _vm->text()->getResTextWidth(0x8000052A)) {
_leftClick = false;
closeMenu();
_vm->startGame();
}
// No
- if (_cursor->x() >= 369 && _cursor->x() <= 369 + 24 && _cursor->y() >= 273 && _cursor->y() <= 273 + _vm->text()->getResTextWidth(0x8000052B))
+ if (_cursor->position().x >= 369 && _cursor->position().x <= 369 + 24 && _cursor->position().y >= 273 && _cursor->position().y <= 273 + _vm->text()->getResTextWidth(0x8000052B))
exitSubMenu();
}
}
@@ -406,7 +406,7 @@ void MainMenu::updateSubMenuCinematics() {
_vm->text()->setTextPos(30, 340);
_vm->text()->drawResText(0x80000549); // Prev Page
- if (_cursor->x() >= 280 && _cursor->x() <= 400 && _cursor->y() >= 340 && _cursor->y() <= 360) {
+ if (_cursor->position().x >= 280 && _cursor->position().x <= 400 && _cursor->position().y >= 340 && _cursor->position().y <= 360) {
loadFont(kFontBlue);
if (_leftClick)
exitSubMenu();
@@ -434,11 +434,11 @@ void MainMenu::updateSubMenuSettings() {
// gamma correction
_vm->text()->drawResTextAlignRight(320, 150, 0x80000599);
- switchFont(_cursor->x() < 350 || _cursor->x() > sizeMinus + 350 || _cursor->y() < 150 || _cursor->y() > 174);
+ switchFont(_cursor->position().x < 350 || _cursor->position().x > sizeMinus + 350 || _cursor->position().y < 150 || _cursor->position().y > 174);
_vm->text()->setTextPos(350, 150);
_vm->text()->drawText("-");
- switchFont(_cursor->x() < sizeMinus + 360 || _cursor->x() > sizeMinus + sizePlus + 360 || _cursor->y() < 150 || _cursor->y() > 174);
+ switchFont(_cursor->position().x < sizeMinus + 360 || _cursor->position().x > sizeMinus + sizePlus + 360 || _cursor->position().y < 150 || _cursor->position().y > 174);
_vm->text()->setTextPos(sizeMinus + 360, 150);
_vm->text()->drawText("+");
@@ -456,11 +456,11 @@ void MainMenu::updateSubMenuSettings() {
// performance
loadFont(kFontYellow);
_vm->text()->drawResTextAlignRight(320, 179, 0x8000059A);
- switchFont(_cursor->x() < 350 || _cursor->x() > sizeMinus + 350 || _cursor->y() < 179 || _cursor->y() > 203);
+ switchFont(_cursor->position().x < 350 || _cursor->position().x > sizeMinus + 350 || _cursor->position().y < 179 || _cursor->position().y > 203);
_vm->text()->setTextPos(350, 179);
_vm->text()->drawText("-");
- switchFont(_cursor->x() < sizeMinus + 360 || _cursor->x() > sizeMinus + sizePlus + 360 || _cursor->y() < 179 || _cursor->y() > 203);
+ switchFont(_cursor->position().x < sizeMinus + 360 || _cursor->position().x > sizeMinus + sizePlus + 360 || _cursor->position().y < 179 || _cursor->position().y > 203);
_vm->text()->setTextPos(sizeMinus + 360, 179);
_vm->text()->drawText("+");
@@ -477,27 +477,27 @@ void MainMenu::updateSubMenuSettings() {
}
// back to main menu
- switchFont(_cursor->x() < 300 || _cursor->x() > 300 + sizeMainMenu || _cursor->y() < 340 || _cursor->y() > 340 + 24);
+ switchFont(_cursor->position().x < 300 || _cursor->position().x > 300 + sizeMainMenu || _cursor->position().y < 340 || _cursor->position().y > 340 + 24);
_vm->text()->setTextPos(300, 340);
_vm->text()->drawResText(0x8000059D);
// action
if (_leftClick) {
// back to main menu
- if (_cursor->x() >= 300 && _cursor->x() <= 300 + sizeMainMenu && _cursor->y() >= 340 && _cursor->y() <= 340 + 24) {
+ if (_cursor->position().x >= 300 && _cursor->position().x <= 300 + sizeMainMenu && _cursor->position().y >= 340 && _cursor->position().y <= 340 + 24) {
// TODO: save new configurations
exitSubMenu();
}
// gamma level minus
- if (_cursor->x() >= 350 && _cursor->x() <= sizeMinus + 350 && _cursor->y() >= 150 && _cursor->y() <= 174) {
+ if (_cursor->position().x >= 350 && _cursor->position().x <= sizeMinus + 350 && _cursor->position().y >= 150 && _cursor->position().y <= 174) {
if (Config.gammaLevel) {
Config.gammaLevel -= 1;
// TODO: setResGammaLevel(0x80010011, 0);
}
}
// gamma level plus
- if (_cursor->x() >= sizeMinus + 360 && _cursor->x() <= sizeMinus + sizePlus + 360 && _cursor->y() >= 150 && _cursor->y() <= 174) {
+ if (_cursor->position().x >= sizeMinus + 360 && _cursor->position().x <= sizeMinus + sizePlus + 360 && _cursor->position().y >= 150 && _cursor->position().y <= 174) {
if (Config.gammaLevel < 8) {
Config.gammaLevel += 1;
// TODO: setResGammaLevel(0x80010011, 0);
@@ -505,14 +505,14 @@ void MainMenu::updateSubMenuSettings() {
}
// performance minus
- if (_cursor->x() >= 350 && _cursor->x() <= sizeMinus + 350 && _cursor->y() >= 179 && _cursor->y() <= 203) {
+ if (_cursor->position().x >= 350 && _cursor->position().x <= sizeMinus + 350 && _cursor->position().y >= 179 && _cursor->position().y <= 203) {
if (Config.performance) {
Config.performance -= 1;
// TODO: change quality settings
}
}
// performance plus
- if (_cursor->x() >= sizeMinus + 360 && _cursor->x() <= sizeMinus + sizePlus + 360 && _cursor->y() >= 179 && _cursor->y() <= 203) {
+ if (_cursor->position().x >= sizeMinus + 360 && _cursor->position().x <= sizeMinus + sizePlus + 360 && _cursor->position().y >= 179 && _cursor->position().y <= 203) {
if (Config.performance < 5) {
Config.performance += 1;
// TODO: change quality settings
@@ -528,19 +528,19 @@ void MainMenu::updateSubMenuQuitGame() {
_vm->text()->drawResTextCentered(10, 100, 620, 0x80000580);
// Yes
- switchFont(_cursor->x() < 247 || _cursor->x() > 247 + _vm->text()->getResTextWidth(0x80000581) || _cursor->y() < 273 || _cursor->y() > 273 + 24);
+ switchFont(_cursor->position().x < 247 || _cursor->position().x > 247 + _vm->text()->getResTextWidth(0x80000581) || _cursor->position().y < 273 || _cursor->position().y > 273 + 24);
_vm->text()->setTextPos(247, 273);
_vm->text()->drawResText(0x80000581);
// No
- switchFont(_cursor->x() < 369 || _cursor->x() > 369 + _vm->text()->getResTextWidth(0x80000582) || _cursor->y() < 273 || _cursor->y() > 273 + 24);
+ switchFont(_cursor->position().x < 369 || _cursor->position().x > 369 + _vm->text()->getResTextWidth(0x80000582) || _cursor->position().y < 273 || _cursor->position().y > 273 + 24);
_vm->text()->setTextPos(369, 273);
_vm->text()->drawResText(0x80000582);
// action
if (_leftClick) {
// Yes
- if (_cursor->x() >= 247 && _cursor->x() <= 247 + 24 && _cursor->y() >= 273 && _cursor->y() <= 273 + _vm->text()->getResTextWidth(0x80000581)) {
+ if (_cursor->position().x >= 247 && _cursor->position().x <= 247 + 24 && _cursor->position().y >= 273 && _cursor->position().y <= 273 + _vm->text()->getResTextWidth(0x80000581)) {
_leftClick = false;
// User clicked on quit, so push a quit event
@@ -549,7 +549,7 @@ void MainMenu::updateSubMenuQuitGame() {
g_system->getEventManager()->pushEvent(event);
}
// No
- if (_cursor->x() >= 369 && _cursor->x() <= 369 + 24 && _cursor->y() >= 273 && _cursor->y() <= 273 + _vm->text()->getResTextWidth(0x80000582))
+ if (_cursor->position().x >= 369 && _cursor->position().x <= 369 + 24 && _cursor->position().y >= 273 && _cursor->position().y <= 273 + _vm->text()->getResTextWidth(0x80000582))
exitSubMenu();
}
}
@@ -624,24 +624,24 @@ void MainMenu::exitSubMenu() {
_vm->screen()->copyToBackBuffer((byte *)bg->surface.pixels, bg->surface.w, 0, 0, bg->surface.w, bg->surface.h);
// Set the cursor
- _cursor->load(2);
+ Cursor::create(_cursor, _resPack, 2);
}
void MainMenu::updateSubMenuReturnToGame() {
- loadFont(kFontYellow);
+ loadFont(kFontYellow);
// no game loaded
_vm->text()->drawResTextCentered(10, 100, 620, 0x80000712);
- // Main menu
- switchFont(_cursor->x() < 285 || _cursor->x() > 285 + _vm->text()->getResTextWidth(0x80000713) || _cursor->y() < 273 || _cursor->y() > 273 + 24);
+ // Main menu
+ switchFont(_cursor->position().x < 285 || _cursor->position().x > 285 + _vm->text()->getResTextWidth(0x80000713) || _cursor->position().y < 273 || _cursor->position().y > 273 + 24);
_vm->text()->setTextPos(285, 273);
_vm->text()->drawResText(0x80000713);
- // action
+ // action
if (_leftClick) {
- // Main menu
- if (_cursor->x() >= 285 && _cursor->x() <= 285 + _vm->text()->getResTextWidth(0x80000713) && _cursor->y() >= 273 && _cursor->y() <= 273 + 24)
+ // Main menu
+ if (_cursor->position().x >= 285 && _cursor->position().x <= 285 + _vm->text()->getResTextWidth(0x80000713) && _cursor->position().y >= 273 && _cursor->position().y <= 273 + 24)
exitSubMenu();
}
}
diff --git a/engines/asylum/menu.h b/engines/asylum/menu.h
index 4d3727cfe6..dbd611078e 100644
--- a/engines/asylum/menu.h
+++ b/engines/asylum/menu.h
@@ -128,7 +128,7 @@ private:
void updateSubMenuSettings();
void updateSubMenuQuitGame();
void updateSubMenuShowCredits();
- void updateSubMenuReturnToGame();
+ void updateSubMenuReturnToGame();
void update();
diff --git a/engines/asylum/module.mk b/engines/asylum/module.mk
index f895f44063..13e576ab63 100644
--- a/engines/asylum/module.mk
+++ b/engines/asylum/module.mk
@@ -10,6 +10,7 @@ MODULE_OBJS := \
cursor.o \
detection.o \
graphics.o \
+ menu.o \
polygons.o \
respack.o \
scene.o \
Commit: afb4a6a3b545f52b69097db6e5368ae1aeef7a0b
https://github.com/scummvm/scummvm/commit/afb4a6a3b545f52b69097db6e5368ae1aeef7a0b
Author: Alex Bevilacqua (alexbevi at gmail.com)
Date: 2021-05-17T15:36:05+02:00
Commit Message:
ASYLUM: re-organize trunk
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@456 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
A engines/asylum/resources/actionarea.cpp
A engines/asylum/resources/actionarea.h
A engines/asylum/resources/actionlist.cpp
A engines/asylum/resources/actionlist.h
A engines/asylum/resources/actor.cpp
A engines/asylum/resources/actor.h
A engines/asylum/resources/barrier.cpp
A engines/asylum/resources/barrier.h
A engines/asylum/resources/encounters.cpp
A engines/asylum/resources/encounters.h
A engines/asylum/resources/polygons.cpp
A engines/asylum/resources/polygons.h
A engines/asylum/resources/worldstats.cpp
A engines/asylum/resources/worldstats.h
A engines/asylum/system/config.cpp
A engines/asylum/system/config.h
A engines/asylum/system/cursor.cpp
A engines/asylum/system/cursor.h
A engines/asylum/system/graphics.cpp
A engines/asylum/system/graphics.h
A engines/asylum/system/screen.cpp
A engines/asylum/system/screen.h
A engines/asylum/system/sound.cpp
A engines/asylum/system/sound.h
A engines/asylum/system/speech.cpp
A engines/asylum/system/speech.h
A engines/asylum/system/text.cpp
A engines/asylum/system/text.h
A engines/asylum/system/video.cpp
A engines/asylum/system/video.h
A engines/asylum/views/blowuppuzzle.cpp
A engines/asylum/views/blowuppuzzle.h
A engines/asylum/views/menu.cpp
A engines/asylum/views/menu.h
A engines/asylum/views/scene.cpp
A engines/asylum/views/scene.h
R engines/asylum/actionarea.cpp
R engines/asylum/actionarea.h
R engines/asylum/actionlist.cpp
R engines/asylum/actionlist.h
R engines/asylum/actor.cpp
R engines/asylum/actor.h
R engines/asylum/asylum.vcproj
R engines/asylum/barrier.cpp
R engines/asylum/barrier.h
R engines/asylum/blowuppuzzle.cpp
R engines/asylum/blowuppuzzle.h
R engines/asylum/config.cpp
R engines/asylum/config.h
R engines/asylum/cursor.cpp
R engines/asylum/cursor.h
R engines/asylum/encounters.cpp
R engines/asylum/encounters.h
R engines/asylum/graphics.cpp
R engines/asylum/graphics.h
R engines/asylum/menu.cpp
R engines/asylum/menu.h
R engines/asylum/polygons.cpp
R engines/asylum/polygons.h
R engines/asylum/scene.cpp
R engines/asylum/scene.h
R engines/asylum/screen.cpp
R engines/asylum/screen.h
R engines/asylum/sound.cpp
R engines/asylum/sound.h
R engines/asylum/speech.cpp
R engines/asylum/speech.h
R engines/asylum/text.cpp
R engines/asylum/text.h
R engines/asylum/video.cpp
R engines/asylum/video.h
R engines/asylum/worldstats.cpp
R engines/asylum/worldstats.h
engines/asylum/asylum.cpp
engines/asylum/asylum.h
engines/asylum/module.mk
diff --git a/engines/asylum/asylum.cpp b/engines/asylum/asylum.cpp
index a4f64f993f..1321bb1faf 100644
--- a/engines/asylum/asylum.cpp
+++ b/engines/asylum/asylum.cpp
@@ -35,7 +35,7 @@
#include "asylum/asylum.h"
#include "asylum/respack.h"
-#include "asylum/config.h"
+#include "asylum/system/config.h"
namespace Asylum {
diff --git a/engines/asylum/asylum.h b/engines/asylum/asylum.h
index 8c12bdc25d..6a9e627fa7 100644
--- a/engines/asylum/asylum.h
+++ b/engines/asylum/asylum.h
@@ -32,14 +32,14 @@
#include "asylum/staticres.h"
#include "asylum/console.h"
-#include "asylum/scene.h"
-#include "asylum/menu.h"
-#include "asylum/screen.h"
-#include "asylum/sound.h"
-#include "asylum/video.h"
+#include "asylum/views/scene.h"
+#include "asylum/views/menu.h"
+#include "asylum/system/screen.h"
+#include "asylum/system/sound.h"
+#include "asylum/system/video.h"
//#include "asylum/blowuppuzzle.h"
//#include "asylum/encounters.h"
-#include "asylum/text.h"
+#include "asylum/system/text.h"
namespace Asylum {
diff --git a/engines/asylum/asylum.vcproj b/engines/asylum/asylum.vcproj
deleted file mode 100644
index 8bd62c3427..0000000000
--- a/engines/asylum/asylum.vcproj
+++ /dev/null
@@ -1,63 +0,0 @@
-<?xml version="1.0" encoding="windows-1252"?>
-<VisualStudioProject
- ProjectType="Visual C++"
- Version="9,00"
- Name="asylum"
- ProjectGUID="{BE400CB0-5712-11DE-8A39-0800200C9A66}"
- RootNamespace="asylum"
- Keyword="Win32Proj"
- TargetFrameworkVersion="131072"
- >
- <Platforms>
- <Platform Name="Win32" />
- </Platforms>
- <Configurations>
- <Configuration Name="Debug|Win32" ConfigurationType="4" InheritedPropertySheets=".\ScummVM_Debug.vsprops" />
- <Configuration Name="Release|Win32" ConfigurationType="4" InheritedPropertySheets=".\ScummVM_Release.vsprops" />
- </Configurations>
- <Files>
- <File RelativePath="..\..\engines\asylum\actionarea.cpp" />
- <File RelativePath="..\..\engines\asylum\actionarea.h" />
- <File RelativePath="..\..\engines\asylum\actionlist.cpp" />
- <File RelativePath="..\..\engines\asylum\actionlist.h" />
- <File RelativePath="..\..\engines\asylum\actor.cpp" />
- <File RelativePath="..\..\engines\asylum\actor.h" />
- <File RelativePath="..\..\engines\asylum\asylum.cpp" />
- <File RelativePath="..\..\engines\asylum\asylum.h" />
- <File RelativePath="..\..\engines\asylum\barrier.cpp" />
- <File RelativePath="..\..\engines\asylum\barrier.h" />
- <File RelativePath="..\..\engines\asylum\blowuppuzzle.cpp" />
- <File RelativePath="..\..\engines\asylum\blowuppuzzle.h" />
- <File RelativePath="..\..\engines\asylum\config.cpp" />
- <File RelativePath="..\..\engines\asylum\config.h" />
- <File RelativePath="..\..\engines\asylum\console.cpp" />
- <File RelativePath="..\..\engines\asylum\console.h" />
- <File RelativePath="..\..\engines\asylum\cursor.cpp" />
- <File RelativePath="..\..\engines\asylum\cursor.h" />
- <File RelativePath="..\..\engines\asylum\detection.cpp" />
- <File RelativePath="..\..\engines\asylum\encounters.cpp" />
- <File RelativePath="..\..\engines\asylum\encounters.h" />
- <File RelativePath="..\..\engines\asylum\graphics.cpp" />
- <File RelativePath="..\..\engines\asylum\graphics.h" />
- <File RelativePath="..\..\engines\asylum\menu.cpp" />
- <File RelativePath="..\..\engines\asylum\menu.h" />
- <File RelativePath="..\..\engines\asylum\polygons.cpp" />
- <File RelativePath="..\..\engines\asylum\polygons.h" />
- <File RelativePath="..\..\engines\asylum\respack.cpp" />
- <File RelativePath="..\..\engines\asylum\respack.h" />
- <File RelativePath="..\..\engines\asylum\scene.cpp" />
- <File RelativePath="..\..\engines\asylum\scene.h" />
- <File RelativePath="..\..\engines\asylum\screen.cpp" />
- <File RelativePath="..\..\engines\asylum\screen.h" />
- <File RelativePath="..\..\engines\asylum\sound.cpp" />
- <File RelativePath="..\..\engines\asylum\sound.h" />
- <File RelativePath="..\..\engines\asylum\speech.cpp" />
- <File RelativePath="..\..\engines\asylum\speech.h" />
- <File RelativePath="..\..\engines\asylum\text.cpp" />
- <File RelativePath="..\..\engines\asylum\text.h" />
- <File RelativePath="..\..\engines\asylum\video.cpp" />
- <File RelativePath="..\..\engines\asylum\video.h" />
- <File RelativePath="..\..\engines\asylum\worldstats.cpp" />
- <File RelativePath="..\..\engines\asylum\worldstats.h" />
- </Files>
-</VisualStudioProject>
diff --git a/engines/asylum/module.mk b/engines/asylum/module.mk
index 13e576ab63..90e75a970d 100644
--- a/engines/asylum/module.mk
+++ b/engines/asylum/module.mk
@@ -1,26 +1,26 @@
MODULE := engines/asylum
MODULE_OBJS := \
- actionarea.o \
- actionlist.o \
- actor.o \
+ resources/actionarea.o \
+ resources/actionlist.o \
+ resources/actor.o \
+ resources/barrier.o \
+ resources/polygons.o \
+ resources/worldstats.o \
+ system/config.o \
+ system/cursor.o \
+ system/graphics.o \
+ system/screen.o \
+ system/sound.o \
+ system/speech.o \
+ system/text.o \
+ system/video.o \
+ views/menu.o \
+ views/scene.o \
asylum.o \
- barrier.o \
- console.o \
- cursor.o \
detection.o \
- graphics.o \
- menu.o \
- polygons.o \
- respack.o \
- scene.o \
- screen.o \
- sound.o \
- text.o \
- video.o \
- worldstats.o \
- speech.o \
- config.o
+ console.o \
+ respack.o
# This module can be built as a plugin
ifeq ($(ENABLE_ASYLUM), DYNAMIC_PLUGIN)
diff --git a/engines/asylum/actionarea.cpp b/engines/asylum/resources/actionarea.cpp
similarity index 96%
rename from engines/asylum/actionarea.cpp
rename to engines/asylum/resources/actionarea.cpp
index 2c18b7e701..7c542c199a 100644
--- a/engines/asylum/actionarea.cpp
+++ b/engines/asylum/resources/actionarea.cpp
@@ -23,7 +23,7 @@
*
*/
-#include "asylum/actionarea.h"
+#include "asylum/resources/actionarea.h"
namespace Asylum {
diff --git a/engines/asylum/actionarea.h b/engines/asylum/resources/actionarea.h
similarity index 100%
rename from engines/asylum/actionarea.h
rename to engines/asylum/resources/actionarea.h
diff --git a/engines/asylum/actionlist.cpp b/engines/asylum/resources/actionlist.cpp
similarity index 99%
rename from engines/asylum/actionlist.cpp
rename to engines/asylum/resources/actionlist.cpp
index b2de311cf9..f57416dfbe 100644
--- a/engines/asylum/actionlist.cpp
+++ b/engines/asylum/resources/actionlist.cpp
@@ -23,8 +23,8 @@
*
*/
-#include "asylum/actionlist.h"
-#include "asylum/config.h"
+#include "asylum/resources/actionlist.h"
+#include "asylum/system/config.h"
namespace Asylum {
diff --git a/engines/asylum/actionlist.h b/engines/asylum/resources/actionlist.h
similarity index 99%
rename from engines/asylum/actionlist.h
rename to engines/asylum/resources/actionlist.h
index 03e5508f5b..481c21c33f 100644
--- a/engines/asylum/actionlist.h
+++ b/engines/asylum/resources/actionlist.h
@@ -30,7 +30,7 @@
#include "common/stack.h"
#include "common/stream.h"
-#include "asylum/scene.h"
+#include "asylum/views/scene.h"
namespace Asylum {
diff --git a/engines/asylum/actor.cpp b/engines/asylum/resources/actor.cpp
similarity index 99%
rename from engines/asylum/actor.cpp
rename to engines/asylum/resources/actor.cpp
index 8aaff33412..1069039f85 100644
--- a/engines/asylum/actor.cpp
+++ b/engines/asylum/resources/actor.cpp
@@ -25,9 +25,9 @@
#include "common/endian.h"
-#include "asylum/actor.h"
-#include "asylum/screen.h"
-#include "asylum/config.h"
+#include "asylum/resources/actor.h"
+#include "asylum/system/screen.h"
+#include "asylum/system/config.h"
namespace Asylum {
diff --git a/engines/asylum/actor.h b/engines/asylum/resources/actor.h
similarity index 99%
rename from engines/asylum/actor.h
rename to engines/asylum/resources/actor.h
index c71b274d2a..04ac008ca0 100644
--- a/engines/asylum/actor.h
+++ b/engines/asylum/resources/actor.h
@@ -27,7 +27,7 @@
#define ASYLUM_ACTOR_H_
#include "asylum/respack.h"
-#include "asylum/graphics.h"
+#include "asylum/system/graphics.h"
namespace Asylum {
diff --git a/engines/asylum/barrier.cpp b/engines/asylum/resources/barrier.cpp
similarity index 98%
rename from engines/asylum/barrier.cpp
rename to engines/asylum/resources/barrier.cpp
index b6509b5070..c405410354 100644
--- a/engines/asylum/barrier.cpp
+++ b/engines/asylum/resources/barrier.cpp
@@ -23,7 +23,7 @@
*
*/
-#include "asylum/barrier.h"
+#include "asylum/resources/barrier.h"
namespace Asylum {
diff --git a/engines/asylum/barrier.h b/engines/asylum/resources/barrier.h
similarity index 98%
rename from engines/asylum/barrier.h
rename to engines/asylum/resources/barrier.h
index 0b5ee4c5d0..a0b1f3b42f 100644
--- a/engines/asylum/barrier.h
+++ b/engines/asylum/resources/barrier.h
@@ -26,7 +26,7 @@
#ifndef ASYLUM_BARRIER_H_
#define ASYLUM_BARRIER_H_
-#include "asylum/sound.h"
+#include "asylum/system/sound.h"
namespace Asylum {
diff --git a/engines/asylum/encounters.cpp b/engines/asylum/resources/encounters.cpp
similarity index 100%
rename from engines/asylum/encounters.cpp
rename to engines/asylum/resources/encounters.cpp
diff --git a/engines/asylum/encounters.h b/engines/asylum/resources/encounters.h
similarity index 100%
rename from engines/asylum/encounters.h
rename to engines/asylum/resources/encounters.h
diff --git a/engines/asylum/polygons.cpp b/engines/asylum/resources/polygons.cpp
similarity index 98%
rename from engines/asylum/polygons.cpp
rename to engines/asylum/resources/polygons.cpp
index 4356265113..7dbbb75aed 100644
--- a/engines/asylum/polygons.cpp
+++ b/engines/asylum/resources/polygons.cpp
@@ -23,7 +23,7 @@
*
*/
-#include "asylum/polygons.h"
+#include "asylum/resources/polygons.h"
namespace Asylum {
diff --git a/engines/asylum/polygons.h b/engines/asylum/resources/polygons.h
similarity index 100%
rename from engines/asylum/polygons.h
rename to engines/asylum/resources/polygons.h
diff --git a/engines/asylum/worldstats.cpp b/engines/asylum/resources/worldstats.cpp
similarity index 100%
rename from engines/asylum/worldstats.cpp
rename to engines/asylum/resources/worldstats.cpp
diff --git a/engines/asylum/worldstats.h b/engines/asylum/resources/worldstats.h
similarity index 95%
rename from engines/asylum/worldstats.h
rename to engines/asylum/resources/worldstats.h
index 25d6d09768..80e29caa91 100644
--- a/engines/asylum/worldstats.h
+++ b/engines/asylum/resources/worldstats.h
@@ -29,11 +29,11 @@
#include "common/rect.h"
#include "common/array.h"
-#include "asylum/actor.h"
-#include "asylum/barrier.h"
-#include "asylum/actionarea.h"
-#include "asylum/scene.h"
-#include "asylum/sound.h"
+#include "asylum/resources/actor.h"
+#include "asylum/resources/barrier.h"
+#include "asylum/resources/actionarea.h"
+#include "asylum/views/scene.h"
+#include "asylum/system/sound.h"
namespace Asylum {
diff --git a/engines/asylum/config.cpp b/engines/asylum/system/config.cpp
similarity index 98%
rename from engines/asylum/config.cpp
rename to engines/asylum/system/config.cpp
index 87a173091b..ed2d529129 100644
--- a/engines/asylum/config.cpp
+++ b/engines/asylum/system/config.cpp
@@ -23,7 +23,7 @@
*
*/
-#include "asylum/config.h"
+#include "asylum/system/config.h"
DECLARE_SINGLETON(Asylum::ConfigurationManager)
diff --git a/engines/asylum/config.h b/engines/asylum/system/config.h
similarity index 100%
rename from engines/asylum/config.h
rename to engines/asylum/system/config.h
diff --git a/engines/asylum/cursor.cpp b/engines/asylum/system/cursor.cpp
similarity index 99%
rename from engines/asylum/cursor.cpp
rename to engines/asylum/system/cursor.cpp
index 0ab9be6346..9873c57ce0 100644
--- a/engines/asylum/cursor.cpp
+++ b/engines/asylum/system/cursor.cpp
@@ -24,7 +24,8 @@
*/
#include "graphics/cursorman.h"
-#include "asylum/cursor.h"
+
+#include "asylum/system/cursor.h"
namespace Asylum {
diff --git a/engines/asylum/cursor.h b/engines/asylum/system/cursor.h
similarity index 98%
rename from engines/asylum/cursor.h
rename to engines/asylum/system/cursor.h
index 1023b3863f..bdf0f369ed 100644
--- a/engines/asylum/cursor.h
+++ b/engines/asylum/system/cursor.h
@@ -26,7 +26,7 @@
#ifndef ASYLUM_CURSOR_H_
#define ASYLUM_CURSOR_H_
-#include "asylum/graphics.h"
+#include "asylum/system/graphics.h"
namespace Asylum {
diff --git a/engines/asylum/graphics.cpp b/engines/asylum/system/graphics.cpp
similarity index 98%
rename from engines/asylum/graphics.cpp
rename to engines/asylum/system/graphics.cpp
index 3660e72e33..b954b460f4 100644
--- a/engines/asylum/graphics.cpp
+++ b/engines/asylum/system/graphics.cpp
@@ -23,7 +23,8 @@
*
*/
-#include "asylum/graphics.h"
+#include "asylum/system/graphics.h"
+
#include "common/endian.h"
namespace Asylum {
diff --git a/engines/asylum/graphics.h b/engines/asylum/system/graphics.h
similarity index 100%
rename from engines/asylum/graphics.h
rename to engines/asylum/system/graphics.h
diff --git a/engines/asylum/screen.cpp b/engines/asylum/system/screen.cpp
similarity index 99%
rename from engines/asylum/screen.cpp
rename to engines/asylum/system/screen.cpp
index 35b7d4de95..a4b11ebcf3 100644
--- a/engines/asylum/screen.cpp
+++ b/engines/asylum/system/screen.cpp
@@ -23,7 +23,7 @@
*
*/
-#include "asylum/screen.h"
+#include "asylum/system/screen.h"
namespace Asylum {
diff --git a/engines/asylum/screen.h b/engines/asylum/system/screen.h
similarity index 98%
rename from engines/asylum/screen.h
rename to engines/asylum/system/screen.h
index 35f85fc974..beeb0838df 100644
--- a/engines/asylum/screen.h
+++ b/engines/asylum/system/screen.h
@@ -27,8 +27,8 @@
#define ASYLUM_SCREEN_H_
#include "asylum/asylum.h"
-#include "asylum/graphics.h"
#include "asylum/respack.h"
+#include "asylum/system/graphics.h"
#include "common/system.h" // for OSystem
#include "graphics/surface.h"
diff --git a/engines/asylum/sound.cpp b/engines/asylum/system/sound.cpp
similarity index 99%
rename from engines/asylum/sound.cpp
rename to engines/asylum/system/sound.cpp
index 4801d8de59..708f363278 100644
--- a/engines/asylum/sound.cpp
+++ b/engines/asylum/system/sound.cpp
@@ -23,11 +23,12 @@
*
*/
-#include "asylum/sound.h"
#include "asylum/asylum.h"
-#include "asylum/config.h"
+#include "asylum/system/config.h"
+#include "asylum/system/sound.h"
#include "common/stream.h"
+
#include "sound/audiostream.h"
#include "sound/decoders/adpcm.h"
#include "sound/decoders/wave.h"
diff --git a/engines/asylum/sound.h b/engines/asylum/system/sound.h
similarity index 100%
rename from engines/asylum/sound.h
rename to engines/asylum/system/sound.h
diff --git a/engines/asylum/speech.cpp b/engines/asylum/system/speech.cpp
similarity index 96%
rename from engines/asylum/speech.cpp
rename to engines/asylum/system/speech.cpp
index b61b51a13f..f5072ec935 100644
--- a/engines/asylum/speech.cpp
+++ b/engines/asylum/system/speech.cpp
@@ -23,10 +23,10 @@
*
*/
-#include "asylum/speech.h"
-#include "asylum/actor.h"
-#include "asylum/config.h"
-#include "asylum/text.h"
+#include "asylum/resources/actor.h"
+#include "asylum/system/speech.h"
+#include "asylum/system/config.h"
+#include "asylum/system/text.h"
namespace Asylum {
diff --git a/engines/asylum/speech.h b/engines/asylum/system/speech.h
similarity index 98%
rename from engines/asylum/speech.h
rename to engines/asylum/system/speech.h
index fe61202be6..c4a54d2551 100644
--- a/engines/asylum/speech.h
+++ b/engines/asylum/system/speech.h
@@ -27,7 +27,7 @@
#define ASYLUM_SPEECH_H_
#include "asylum/respack.h"
-#include "asylum/scene.h"
+#include "asylum/views/scene.h"
namespace Asylum {
diff --git a/engines/asylum/text.cpp b/engines/asylum/system/text.cpp
similarity index 99%
rename from engines/asylum/text.cpp
rename to engines/asylum/system/text.cpp
index 3ea4298b6f..01807cc9c2 100644
--- a/engines/asylum/text.cpp
+++ b/engines/asylum/system/text.cpp
@@ -23,7 +23,8 @@
*
*/
-#include "asylum/text.h"
+#include "asylum/system/text.h"
+
#include "common/endian.h"
namespace Asylum {
diff --git a/engines/asylum/text.h b/engines/asylum/system/text.h
similarity index 98%
rename from engines/asylum/text.h
rename to engines/asylum/system/text.h
index 32c5a44113..3eda099cc8 100644
--- a/engines/asylum/text.h
+++ b/engines/asylum/system/text.h
@@ -26,7 +26,7 @@
#ifndef ASYLUM_TEXT_H_
#define ASYLUM_TEXT_H_
-#include "asylum/screen.h"
+#include "asylum/system/screen.h"
#include "asylum/respack.h"
namespace Asylum {
diff --git a/engines/asylum/video.cpp b/engines/asylum/system/video.cpp
similarity index 99%
rename from engines/asylum/video.cpp
rename to engines/asylum/system/video.cpp
index d26d24dcbc..cd91f0d487 100644
--- a/engines/asylum/video.cpp
+++ b/engines/asylum/system/video.cpp
@@ -23,7 +23,7 @@
*
*/
-#include "asylum/video.h"
+#include "asylum/system/video.h"
namespace Asylum {
diff --git a/engines/asylum/video.h b/engines/asylum/system/video.h
similarity index 100%
rename from engines/asylum/video.h
rename to engines/asylum/system/video.h
diff --git a/engines/asylum/blowuppuzzle.cpp b/engines/asylum/views/blowuppuzzle.cpp
similarity index 100%
rename from engines/asylum/blowuppuzzle.cpp
rename to engines/asylum/views/blowuppuzzle.cpp
diff --git a/engines/asylum/blowuppuzzle.h b/engines/asylum/views/blowuppuzzle.h
similarity index 100%
rename from engines/asylum/blowuppuzzle.h
rename to engines/asylum/views/blowuppuzzle.h
diff --git a/engines/asylum/menu.cpp b/engines/asylum/views/menu.cpp
similarity index 99%
rename from engines/asylum/menu.cpp
rename to engines/asylum/views/menu.cpp
index a21dc57a05..7a283ca04c 100644
--- a/engines/asylum/menu.cpp
+++ b/engines/asylum/views/menu.cpp
@@ -23,10 +23,10 @@
*
*/
-#include "asylum/menu.h"
#include "asylum/respack.h"
-#include "asylum/graphics.h"
-#include "asylum/config.h"
+#include "asylum/views/menu.h"
+#include "asylum/system/graphics.h"
+#include "asylum/system/config.h"
namespace Asylum {
diff --git a/engines/asylum/menu.h b/engines/asylum/views/menu.h
similarity index 95%
rename from engines/asylum/menu.h
rename to engines/asylum/views/menu.h
index dbd611078e..cea13e5870 100644
--- a/engines/asylum/menu.h
+++ b/engines/asylum/views/menu.h
@@ -30,10 +30,10 @@
#include "asylum/asylum.h"
#include "asylum/respack.h"
-#include "asylum/scene.h"
-#include "asylum/graphics.h"
-#include "asylum/text.h"
-#include "asylum/cursor.h"
+#include "asylum/views/scene.h"
+#include "asylum/system/graphics.h"
+#include "asylum/system/text.h"
+#include "asylum/system/cursor.h"
namespace Asylum {
diff --git a/engines/asylum/scene.cpp b/engines/asylum/views/scene.cpp
similarity index 99%
rename from engines/asylum/scene.cpp
rename to engines/asylum/views/scene.cpp
index 2539f8e3ab..27946fb875 100644
--- a/engines/asylum/scene.cpp
+++ b/engines/asylum/views/scene.cpp
@@ -23,9 +23,9 @@
*
*/
-#include "asylum/scene.h"
-#include "asylum/actor.h"
-#include "asylum/config.h"
+#include "asylum/views/scene.h"
+#include "asylum/resources/actor.h"
+#include "asylum/system/config.h"
namespace Asylum {
diff --git a/engines/asylum/scene.h b/engines/asylum/views/scene.h
similarity index 96%
rename from engines/asylum/scene.h
rename to engines/asylum/views/scene.h
index 64a9a9aabf..4b73b23eb3 100644
--- a/engines/asylum/scene.h
+++ b/engines/asylum/views/scene.h
@@ -30,13 +30,13 @@
#include "asylum/asylum.h"
#include "asylum/respack.h"
-#include "asylum/graphics.h"
-#include "asylum/worldstats.h"
-#include "asylum/polygons.h"
-#include "asylum/actionlist.h"
-#include "asylum/text.h"
-#include "asylum/cursor.h"
-#include "asylum/speech.h"
+#include "asylum/system/graphics.h"
+#include "asylum/resources/worldstats.h"
+#include "asylum/resources/polygons.h"
+#include "asylum/resources/actionlist.h"
+#include "asylum/system/text.h"
+#include "asylum/system/cursor.h"
+#include "asylum/system/speech.h"
#define SCENE_FILE_MASK "scn.%03d"
#define MUSIC_FILE_MASK "mus.%03d"
Commit: 36d4208beb7aa6da04b7b748f89c06963b6a4aea
https://github.com/scummvm/scummvm/commit/36d4208beb7aa6da04b7b748f89c06963b6a4aea
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:05+02:00
Commit Message:
ASYLUM: Refactor ActionList class
- Construct script opcode array at runtime
- Make all opcode functions methods of the ActionList class
- Rename _actionFlag to _skipProcessing (and update opcode name)
- Make class variables private and add a couple accessors
- Remove debug opcode return code
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@459 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/asylum.cpp
engines/asylum/console.cpp
engines/asylum/resources/actionlist.cpp
engines/asylum/resources/actionlist.h
engines/asylum/views/scene.cpp
diff --git a/engines/asylum/asylum.cpp b/engines/asylum/asylum.cpp
index 1321bb1faf..13f5a7469d 100644
--- a/engines/asylum/asylum.cpp
+++ b/engines/asylum/asylum.cpp
@@ -293,12 +293,12 @@ void AsylumEngine::checkForEvent(bool doUpdate) { // k_sub_40AE30 (0040AE30)
void AsylumEngine::processDelayedEvents() {
// check for a delayed video
- int videoIdx = _scene->actions()->delayedVideoIndex;
+ int videoIdx = _scene->actions()->getDelayedVideoIndex();
if (videoIdx >= 0) {
_sound->stopMusic();
_sound->stopAllSounds();
_video->playVideo(videoIdx, kSubtitlesOn);
- _scene->actions()->delayedVideoIndex = -1;
+ _scene->actions()->setDelayedVideoIndex(-1);
if (_mainMenu->isActive())
@@ -308,7 +308,7 @@ void AsylumEngine::processDelayedEvents() {
}
// check for a delayed scene change
- int sceneIdx = _scene->actions()->delayedSceneIndex;
+ int sceneIdx = _scene->actions()->getDelayedSceneIndex();
// XXX Flag 183 indicates whether the actionlist is currently
// processing
if (sceneIdx >= 0 && isGameFlagNotSet(183)) {
@@ -321,7 +321,7 @@ void AsylumEngine::processDelayedEvents() {
_scene = new Scene(sceneIdx, this);
_scene->enterScene();
- _scene->actions()->delayedSceneIndex = -1;
+ _scene->actions()->setDelayedSceneIndex(-1);
}
}
diff --git a/engines/asylum/console.cpp b/engines/asylum/console.cpp
index 0fe424e3a7..e6235ab6e9 100644
--- a/engines/asylum/console.cpp
+++ b/engines/asylum/console.cpp
@@ -119,7 +119,7 @@ bool Console::cmdPlayVideo(int32 argc, const char **argv) {
return true;
}
- _vm->scene()->actions()->delayedVideoIndex = atoi(argv[1]);
+ _vm->scene()->actions()->setDelayedVideoIndex(atoi(argv[1]));
return false;
}
@@ -146,7 +146,7 @@ bool Console::cmdChangeScene(int32 argc, const char **argv) {
return true;
}
- _vm->scene()->actions()->delayedSceneIndex = atoi(argv[1]);
+ _vm->scene()->actions()->setDelayedSceneIndex(atoi(argv[1]));
// FIXME push the script index into the script queue
// XXX is this right or should it be ws->actionListIdx???
//_vm->scene()->actions()->setScriptByIndex(0);
diff --git a/engines/asylum/resources/actionlist.cpp b/engines/asylum/resources/actionlist.cpp
index f57416dfbe..e544c68849 100644
--- a/engines/asylum/resources/actionlist.cpp
+++ b/engines/asylum/resources/actionlist.cpp
@@ -24,189 +24,180 @@
*/
#include "asylum/resources/actionlist.h"
+
#include "asylum/system/config.h"
namespace Asylum {
ActionList::ActionList(Common::SeekableReadStream *stream, Scene *scene)
: _scene(scene) {
+
+ // Build list of opcodes
+ ADD_OPCODE(Return);
+ ADD_OPCODE(SetGameFlag);
+ ADD_OPCODE(ClearGameFlag);
+ ADD_OPCODE(ToggleGameFlag);
+ ADD_OPCODE(JumpIfGameFlag);
+ ADD_OPCODE(HideCursor);
+ ADD_OPCODE(ShowCursor);
+ ADD_OPCODE(PlayAnimation);
+ ADD_OPCODE(MoveScenePosition);
+ ADD_OPCODE(HideActor);
+ ADD_OPCODE(ShowActor);
+ ADD_OPCODE(SetActorPosition);
+ ADD_OPCODE(SetSceneMotionStatus);
+ ADD_OPCODE(DisableActor);
+ ADD_OPCODE(EnableActor);
+ ADD_OPCODE(EnableBarriers);
+ ADD_OPCODE(Return);
+ ADD_OPCODE(DestroyBarrier);
+ ADD_OPCODE(_unk12_JMP_WALK_ACTOR);
+ ADD_OPCODE(_unk13_JMP_WALK_ACTOR);
+ ADD_OPCODE(_unk14_JMP_WALK_ACTOR);
+ ADD_OPCODE(_unk15);
+ ADD_OPCODE(ResetAnimation);
+ ADD_OPCODE(ClearFlag1Bit0);
+ ADD_OPCODE(_unk18_PLAY_SND);
+ ADD_OPCODE(JumpIfFlag2Bit0);
+ ADD_OPCODE(SetFlag2Bit0);
+ ADD_OPCODE(ClearFlag2Bit0);
+ ADD_OPCODE(JumpIfFlag2Bit2);
+ ADD_OPCODE(SetFlag2Bit2);
+ ADD_OPCODE(ClearFlag2Bit2);
+ ADD_OPCODE(JumpIfFlag2Bit1);
+ ADD_OPCODE(SetFlag2Bit1);
+ ADD_OPCODE(ClearFlag2Bit1);
+ ADD_OPCODE(_unk22);
+ ADD_OPCODE(_unk23);
+ ADD_OPCODE(_unk24);
+ ADD_OPCODE(RunEncounter);
+ ADD_OPCODE(JumpIfFlag2Bit4);
+ ADD_OPCODE(SetFlag2Bit4);
+ ADD_OPCODE(ClearFlag2Bit4);
+ ADD_OPCODE(SetActorField638);
+ ADD_OPCODE(JumpIfActorField638);
+ ADD_OPCODE(ChangeScene);
+ ADD_OPCODE(_unk2C_ActorSub);
+ ADD_OPCODE(PlayMovie);
+ ADD_OPCODE(StopAllBarriersSounds);
+ ADD_OPCODE(StopProcessing);
+ ADD_OPCODE(ResumeProcessing);
+ ADD_OPCODE(ResetSceneRect);
+ ADD_OPCODE(ChangeMusicById);
+ ADD_OPCODE(StopMusic);
+ ADD_OPCODE(_unk34_Status);
+ ADD_OPCODE(_unk35);
+ ADD_OPCODE(_unk36);
+ ADD_OPCODE(RunBlowUpPuzzle);
+ ADD_OPCODE(JumpIfFlag2Bit3);
+ ADD_OPCODE(SetFlag2Bit3);
+ ADD_OPCODE(ClearFlag2Bit3);
+ ADD_OPCODE(_unk3B_PALETTE_MOD);
+ ADD_OPCODE(_unk3C_CMP_VAL);
+ ADD_OPCODE(WaitUntilFramePlayed);
+ ADD_OPCODE(UpdateWideScreen);
+ ADD_OPCODE(_unk3F);
+ ADD_OPCODE(_unk40_SOUND);
+ ADD_OPCODE(PlaySpeech);
+ ADD_OPCODE(_unk42);
+ ADD_OPCODE(_unk43);
+ ADD_OPCODE(PaletteFade);
+ ADD_OPCODE(StartPaletteFadeThread);
+ ADD_OPCODE(_unk46);
+ ADD_OPCODE(ActorFaceObject);
+ ADD_OPCODE(_unk48_MATTE_01);
+ ADD_OPCODE(_unk49_MATTE_90);
+ ADD_OPCODE(JumpIfSoundPlaying);
+ ADD_OPCODE(ChangePlayerCharacterIndex);
+ ADD_OPCODE(ChangeActorField40);
+ ADD_OPCODE(StopSound);
+ ADD_OPCODE(_unk4E_RANDOM_COMMAND);
+ ADD_OPCODE(ClearScreen);
+ ADD_OPCODE(Quit);
+ ADD_OPCODE(JumpBarrierFrame);
+ ADD_OPCODE(_unk52);
+ ADD_OPCODE(_unk53);
+ ADD_OPCODE(_unk54_SET_ACTIONLIST_6EC);
+ ADD_OPCODE(_unk55);
+ ADD_OPCODE(_unk56);
+ ADD_OPCODE(SetResourcePalette);
+ ADD_OPCODE(SetBarrierFrameIdxFlaged);
+ ADD_OPCODE(_unk59);
+ ADD_OPCODE(_unk5A);
+ ADD_OPCODE(_unk5B);
+ ADD_OPCODE(_unk5C);
+ ADD_OPCODE(_unk5D);
+ ADD_OPCODE(ClearActorField970);
+ ADD_OPCODE(SetBarrierLastFrameIdx);
+ ADD_OPCODE(_unk60_SET_OR_CLR_ACTIONAREA_FLAG);
+ ADD_OPCODE(_unk61);
+ ADD_OPCODE(_unk62_SHOW_OPTIONS_SCREEN);
+ ADD_OPCODE(_unk63);
+
load(stream);
_currentScript = 0;
- currentLine = 0;
- currentLoops = 0;
- delayedSceneIndex = -1;
- delayedVideoIndex = -1;
- allowInput = true;
- _actionFlag = false;
- resetQueue();
+ _currentLine = 0;
+ _currentLoops = 0;
+ _delayedSceneIndex = -1;
+ _delayedVideoIndex = -1;
+ _allowInput = true;
+ _skipProcessing = false;
+
+ // Reset script queue
+ _scripts.clear();
}
ActionList::~ActionList() {
- entries.clear();
- _scripts.clear();
-}
+ for (int i = 0; i < (int)_actions.size(); i++)
+ delete _actions[i];
-typedef int AsylumFunc(Script *script, ScriptEntry *cmd, Scene *scn);
-
-struct AsylumFunction {
- const char *name;
- AsylumFunc *function;
-};
-
-#define MAPFUNC(name, func) {name, func}
-
-// TODO I don't know that we're clearing this out
-// when the engine is disposed. Need to look into this
-// as a possible memory leak.
-static const AsylumFunction function_map[] = {
- /*0x00*/ MAPFUNC("kReturn0", kReturn0),
- /*0x01*/ MAPFUNC("kSetGameFlag", kSetGameFlag),
- /*0x02*/ MAPFUNC("kClearGameFlag", kClearGameFlag),
- /*0x03*/ MAPFUNC("kToggleGameFlag", kToggleGameFlag),
- /*0x04*/ MAPFUNC("kJumpIfGameFlag", kJumpIfGameFlag),
- /*0x05*/ MAPFUNC("kHideCursor", kHideCursor),
- /*0x06*/ MAPFUNC("kShowCursor", kShowCursor),
- /*0x07*/ MAPFUNC("kPlayAnimation", kPlayAnimation),
- /*0x08*/ MAPFUNC("kMoveScenePosition", kMoveScenePosition),
- /*0x09*/ MAPFUNC("kHideActor", kHideActor),
- /*0x0A*/ MAPFUNC("kShowActor", kShowActor),
- /*0x0B*/ MAPFUNC("kSetActorPosition", kSetActorPosition),
- /*0x0C*/ MAPFUNC("kSetSceneMotionStat", kSetSceneMotionStat),
- /*0x0D*/ MAPFUNC("kDisableActor", kDisableActor),
- /*0x0E*/ MAPFUNC("kEnableActor", kEnableActor),
- /*0x0F*/ MAPFUNC("kEnableBarriers", kEnableBarriers),
- /*0x10*/ MAPFUNC("kReturn", kReturn),
- /*0x11*/ MAPFUNC("kDestroyBarrier", kDestroyBarrier),
- /*0x12*/ MAPFUNC("k_unk12_JMP_WALK_ACTOR", k_unk12_JMP_WALK_ACTOR),
- /*0x13*/ MAPFUNC("k_unk13_JMP_WALK_ACTOR", k_unk13_JMP_WALK_ACTOR),
- /*0x14*/ MAPFUNC("k_unk14_JMP_WALK_ACTOR", k_unk14_JMP_WALK_ACTOR),
- /*0x15*/ MAPFUNC("k_unk15", k_unk15),
- /*0x16*/ MAPFUNC("kResetAnimation", kResetAnimation),
- /*0x17*/ MAPFUNC("kClearFlag1Bit0", kClearFlag1Bit0),
- /*0x18*/ MAPFUNC("k_unk18_PLAY_SND", k_unk18_PLAY_SND),
- /*0x19*/ MAPFUNC("kJumpIfFlag2Bit0", kJumpIfFlag2Bit0),
- /*0x1A*/ MAPFUNC("kSetFlag2Bit0", kSetFlag2Bit0),
- /*0x1B*/ MAPFUNC("kClearFlag2Bit0", kClearFlag2Bit0),
- /*0x1C*/ MAPFUNC("kJumpIfFlag2Bit2", kJumpIfFlag2Bit2),
- /*0x1D*/ MAPFUNC("kSetFlag2Bit2", kSetFlag2Bit2),
- /*0x1E*/ MAPFUNC("kClearFlag2Bit2", kClearFlag2Bit2),
- /*0x1F*/ MAPFUNC("kJumpIfFlag2Bit1", kJumpIfFlag2Bit1),
- /*0x20*/ MAPFUNC("kSetFlag2Bit1", kSetFlag2Bit1),
- /*0x21*/ MAPFUNC("kClearFlag2Bit1", kClearFlag2Bit1),
- /*0x22*/ MAPFUNC("k_unk22", k_unk22),
- /*0x23*/ MAPFUNC("k_unk23", k_unk23),
- /*0x24*/ MAPFUNC("k_unk24", k_unk24),
- /*0x25*/ MAPFUNC("kRunEncounter", kRunEncounter),
- /*0x26*/ MAPFUNC("kJumpIfFlag2Bit4", kJumpIfFlag2Bit4),
- /*0x27*/ MAPFUNC("kSetFlag2Bit4", kSetFlag2Bit4),
- /*0x28*/ MAPFUNC("kClearFlag2Bit4", kClearFlag2Bit4),
- /*0x29*/ MAPFUNC("kSetActorField638", kSetActorField638),
- /*0x2A*/ MAPFUNC("kJumpIfActorField638", kJumpIfActorField638),
- /*0x2B*/ MAPFUNC("kChangeScene", kChangeScene),
- /*0x2C*/ MAPFUNC("k_unk2C_ActorSub", k_unk2C_ActorSub),
- /*0x2D*/ MAPFUNC("kPlayMovie", kPlayMovie),
- /*0x2E*/ MAPFUNC("kStopAllBarriersSounds", kStopAllBarriersSounds),
- /*0x2F*/ MAPFUNC("kSetActionFlag", kSetActionFlag),
- /*0x30*/ MAPFUNC("kClearActionFlag", kClearActionFlag),
- /*0x31*/ MAPFUNC("kResetSceneRect", kResetSceneRect),
- /*0x32*/ MAPFUNC("kChangeMusicById", kChangeMusicById),
- /*0x33*/ MAPFUNC("kStopMusic", kStopMusic),
- /*0x34*/ MAPFUNC("k_unk34_Status", k_unk34_Status),
- /*0x35*/ MAPFUNC("k_unk35", k_unk35),
- /*0x36*/ MAPFUNC("k_unk36", k_unk36),
- /*0x37*/ MAPFUNC("kRunBlowUpPuzzle", kRunBlowUpPuzzle),
- /*0x38*/ MAPFUNC("kJumpIfFlag2Bit3", kJumpIfFlag2Bit3),
- /*0x39*/ MAPFUNC("kSetFlag2Bit3", kSetFlag2Bit3),
- /*0x3A*/ MAPFUNC("kClearFlag2Bit3", kClearFlag2Bit3),
- /*0x3B*/ MAPFUNC("k_unk3B_PALETTE_MOD", k_unk3B_PALETTE_MOD),
- /*0x3C*/ MAPFUNC("k_unk3C_CMP_VAL", k_unk3C_CMP_VAL),
- /*0x3D*/ MAPFUNC("kWaitUntilFramePlayed", kWaitUntilFramePlayed),
- /*0x3E*/ MAPFUNC("kUpdateWideScreen", kUpdateWideScreen),
- /*0x3F*/ MAPFUNC("k_unk3F", k_unk3F),
- /*0x40*/ MAPFUNC("k_unk40_SOUND", k_unk40_SOUND),
- /*0x41*/ MAPFUNC("kPlaySpeech", kPlaySpeech),
- /*0x42*/ MAPFUNC("k_unk42", k_unk42),
- /*0x43*/ MAPFUNC("k_unk43", k_unk43),
- /*0x44*/ MAPFUNC("kPaletteFade", kPaletteFade),
- /*0x45*/ MAPFUNC("kStartPaletteFadeThread", kStartPaletteFadeThread),
- /*0x46*/ MAPFUNC("k_unk46", k_unk46),
- /*0x47*/ MAPFUNC("kActorFaceObject", kActorFaceObject),
- /*0x48*/ MAPFUNC("k_unk48_MATTE_01", k_unk48_MATTE_01),
- /*0x49*/ MAPFUNC("k_unk49_MATTE_90", k_unk49_MATTE_90),
- /*0x4A*/ MAPFUNC("kJumpIfSoundPlaying", kJumpIfSoundPlaying),
- /*0x4B*/ MAPFUNC("kChangePlayerCharacterIndex", kChangePlayerCharacterIndex),
- /*0x4C*/ MAPFUNC("kChangeActorField40", kChangeActorField40),
- /*0x4D*/ MAPFUNC("kStopSound", kStopSound),
- /*0x4E*/ MAPFUNC("k_unk4E_RANDOM_COMMAND", k_unk4E_RANDOM_COMMAND),
- /*0x4F*/ MAPFUNC("kClearScreen", kClearScreen),
- /*0x50*/ MAPFUNC("kQuit", kQuit),
- /*0x51*/ MAPFUNC("kJumpBarrierFrame", kJumpBarrierFrame),
- /*0x52*/ MAPFUNC("k_unk52", k_unk52),
- /*0x53*/ MAPFUNC("k_unk53", k_unk53),
- /*0x54*/ MAPFUNC("k_unk54_SET_ACTIONLIST_6EC", k_unk54_SET_ACTIONLIST_6EC),
- /*0x55*/ MAPFUNC("k_unk55", k_unk55),
- /*0x56*/ MAPFUNC("k_unk56", k_unk56),
- /*0x57*/ MAPFUNC("kSetResourcePalette", kSetResourcePalette),
- /*0x58*/ MAPFUNC("kSetBarrierFrameIdxFlaged", kSetBarrierFrameIdxFlaged),
- /*0x59*/ MAPFUNC("k_unk59", k_unk59),
- /*0x5A*/ MAPFUNC("k_unk5A", k_unk5A),
- /*0x5B*/ MAPFUNC("k_unk5B", k_unk5B),
- /*0x5C*/ MAPFUNC("k_unk5C", k_unk5C),
- /*0x5D*/ MAPFUNC("k_unk5D", k_unk5D),
- /*0x5E*/ MAPFUNC("kClearActorField970", kClearActorField970),
- /*0x5F*/ MAPFUNC("kSetBarrierLastFrameIdx", kSetBarrierLastFrameIdx),
- /*0x60*/ MAPFUNC("k_unk60_SET_OR_CLR_ACTIONAREA_FLAG", k_unk60_SET_OR_CLR_ACTIONAREA_FLAG),
- /*0x61*/ MAPFUNC("k_unk61", k_unk61),
- /*0x62*/ MAPFUNC("k_unk62_SHOW_OPTIONS_SCREEN", k_unk62_SHOW_OPTIONS_SCREEN),
- /*0x63*/ MAPFUNC("k_unk63", k_unk63)
-};
-
-#undef MAPFUNC
-
-void ActionList::resetQueue() {
+ _entries.clear();
_scripts.clear();
+
+ // Zero-out passed pointers
+ _scene = NULL;
}
void ActionList::queueScript(int actionIndex, int actorIndex) {
- // TODO properly define what actionFlag is actually for.
- // It appears to remain false 99% of the time, so I'm guessing
- // it's a "skip processing" flag.
- if (!_actionFlag) {
- ScriptQueueEntry entry;
- entry.actionListIndex = actionIndex;
- entry.actorIndex = actorIndex;
-
- // If there's currently no script for the processor to run,
- // assign it directly and skip the stack push. If however the
- // current script is assigned, push the script to the stack
- if (_currentScript)
- _scripts.push(entry);
- else {
- _currentQueueEntry = entry;
- _currentScript = &entries[entry.actionListIndex];
- }
+ // When the skipProcessing flag is set, do not queue any more scripts
+ if (_skipProcessing)
+ return;
+
+ ScriptQueueEntry entry;
+ entry.actionListIndex = actionIndex;
+ entry.actorIndex = actorIndex;
+
+ // If there's currently no script for the processor to run,
+ // assign it directly and skip the stack push. If however the
+ // current script is assigned, push the script to the stack
+ if (_currentScript)
+ _scripts.push(entry);
+ else {
+ _currentQueueEntry = entry;
+ _currentScript = &_entries[entry.actionListIndex];
}
}
-int ActionList::process() {
- done = false;
- waitCycle = false;
- lineIncrement = 1;
+bool ActionList::process() {
+ _done = false;
+ _waitCycle = false;
+ _lineIncrement = 1;
_scene->vm()->setGameFlag(183);
if (_currentScript)
- while (!done && !waitCycle) {
- lineIncrement = 0; //Reset line increment value
+ while (!_done && !_waitCycle) {
+ _lineIncrement = 0; //Reset line increment value
- ScriptEntry *currentCommand = &_currentScript->commands[currentLine];
+ ScriptEntry *currentCommand = &_currentScript->commands[_currentLine];
int32 opcode = currentCommand->opcode;
debugC(kDebugLevelScripts,
"[0x%02X] %s(%d, %d, %d, %d, %d, %d, %d, %d, %d)",
- opcode,function_map[opcode].name,
+ opcode,
+ _actions[opcode]->name,
currentCommand->param1,
currentCommand->param2,
currentCommand->param3,
@@ -217,56 +208,33 @@ int ActionList::process() {
currentCommand->param8,
currentCommand->param9);
- // Execute command from function mapping
- int cmdRet = function_map[opcode].function(_currentScript, currentCommand, _scene);
-
- // Check function return
- if (cmdRet == -1)
- debugC(kDebugLevelScripts,
- "Incomplete opcode %s (0x%02X) in Scene %d Line %d",
- function_map[opcode].name,
- currentCommand->opcode,
- _scene->getSceneIndex(),
- currentLine);
- if (cmdRet == -2)
- debugC(kDebugLevelScripts,
- "Unhandled opcode %s (0x%02X) in Scene %d Line %d",
- function_map[opcode].name,
- currentCommand->opcode,
- _scene->getSceneIndex(),
- currentLine);
- if (cmdRet == -3)
- debugC(kDebugLevelScripts,
- "Flagged (see implementation comments) opcode %s (0x%02X) in Scene %d Line %d",
- function_map[opcode].name,
- currentCommand->opcode,
- _scene->getSceneIndex(),
- currentLine);
-
- if (!lineIncrement) {
- currentLine ++;
- }
+ // Execute opcode
+ (*_actions[opcode]->func)(currentCommand);
- } // end while
+ if (!_lineIncrement)
+ _currentLine ++;
+
+ }
+
+ if (_done) {
+ _currentLine = 0;
- if (done) {
- currentLine = 0;
if (!_scripts.empty()) {
_currentQueueEntry = _scripts.pop();
- _currentScript = &entries[_currentQueueEntry.actionListIndex];
+ _currentScript = &_entries[_currentQueueEntry.actionListIndex];
} else {
_currentScript = 0;
}
-
}
_scene->vm()->clearGameFlag(183);
- return 0;
+
+ return false;
}
void ActionList::load(Common::SeekableReadStream *stream) {
- size = stream->readSint32LE();
- numEntries = stream->readSint32LE();
+ stream->readSint32LE(); // size
+ int32 numEntries = stream->readSint32LE();
for (int32 a = 0; a < numEntries; a++) {
Script action;
@@ -295,84 +263,92 @@ void ActionList::load(Common::SeekableReadStream *stream) {
action.field_1BB0 = stream->readSint32LE();
action.counter = stream->readSint32LE();
- entries.push_back(action);
+ _entries.push_back(action);
}
}
-/* Opcode Functions */
-int kReturn0(Script *script, ScriptEntry *cmd, Scene *scn) {
- scn->actions()->done = true;
- scn->actions()->lineIncrement = 0;
- return 0;
+//////////////////////////////////////////////////////////////////////////
+// Opcode Functions
+//////////////////////////////////////////////////////////////////////////
+
+//////////////////////////////////////////////////////////////////////////
+// Opcode 0x00
+IMPLEMENT_OPCODE(Return) {
+ _done = true;
+ _lineIncrement = 0;
}
-int kSetGameFlag(Script *script, ScriptEntry *cmd, Scene *scn) {
+//////////////////////////////////////////////////////////////////////////
+// Opcode 0x01
+IMPLEMENT_OPCODE(SetGameFlag) {
int flagNum = cmd->param1;
if (flagNum >= 0)
- scn->vm()->setGameFlag(flagNum);
-
- return 0;
+ _scene->vm()->setGameFlag(flagNum);
}
-int kClearGameFlag(Script *script, ScriptEntry *cmd, Scene *scn) {
+//////////////////////////////////////////////////////////////////////////
+// Opcode 0x02
+IMPLEMENT_OPCODE(ClearGameFlag) {
int flagNum = cmd->param1;
if (flagNum >= 0)
- scn->vm()->clearGameFlag(flagNum);
-
- return 0;
+ _scene->vm()->clearGameFlag(flagNum);
}
-int kToggleGameFlag(Script *script, ScriptEntry *cmd, Scene *scn) {
+//////////////////////////////////////////////////////////////////////////
+// Opcode 0x03
+IMPLEMENT_OPCODE(ToggleGameFlag) {
int flagNum = cmd->param1;
if (flagNum >= 0)
- scn->vm()->toggleGameFlag(flagNum);
-
- return 0;
+ _scene->vm()->toggleGameFlag(flagNum);
}
-int kJumpIfGameFlag(Script *script, ScriptEntry *cmd, Scene *scn) {
+//////////////////////////////////////////////////////////////////////////
+// Opcode 0x04
+IMPLEMENT_OPCODE(JumpIfGameFlag) {
int flagNum = cmd->param1;
if (flagNum) {
- bool doJump = scn->vm()->isGameFlagSet(flagNum);
+ bool doJump = _scene->vm()->isGameFlagSet(flagNum);
if (cmd->param2)
- doJump = scn->vm()->isGameFlagNotSet(flagNum);
+ doJump = _scene->vm()->isGameFlagNotSet(flagNum);
if (doJump)
- scn->actions()->currentLine = cmd->param3;
+ _currentLine = cmd->param3;
}
-
- return 0;
}
-int kHideCursor(Script *script, ScriptEntry *cmd, Scene *scn) {
- scn->getCursor()->hide();
- scn->actions()->allowInput = false;
-
- return 0;
+//////////////////////////////////////////////////////////////////////////
+// Opcode 0x05
+IMPLEMENT_OPCODE(HideCursor) {
+ _scene->getCursor()->hide();
+ _allowInput = false;
}
-int kShowCursor(Script *script, ScriptEntry *cmd, Scene *scn) {
- scn->getCursor()->show();
- scn->actions()->allowInput = true;
+//////////////////////////////////////////////////////////////////////////
+// Opcode 0x06
+IMPLEMENT_OPCODE(ShowCursor) {
+ _scene->getCursor()->show();
+ _allowInput = true;
// TODO clear_flag_01()
- return -1;
+ error("Incomplete opcode %s (0x%02X) in Scene %d Line %d", _actions[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
}
-int kPlayAnimation(Script *script, ScriptEntry *cmd, Scene *scn) {
+//////////////////////////////////////////////////////////////////////////
+// Opcode 0x07
+IMPLEMENT_OPCODE(PlayAnimation) {
int barrierId = cmd->param1;
- int barrierIndex = scn->worldstats()->getBarrierIndexById(barrierId);
- Barrier *barrier = scn->worldstats()->getBarrierByIndex(barrierIndex);
+ int barrierIndex = _scene->worldstats()->getBarrierIndexById(barrierId);
+ Barrier *barrier = _scene->worldstats()->getBarrierByIndex(barrierIndex);
if (cmd->param2 == 2) {
if (!barrier->checkFlags()) {
cmd->param2 = 1;
}
- scn->actions()->lineIncrement = 1;
+ _lineIncrement = 1;
} else {
if (cmd->param4) {
barrier->flags &= 0xFFFEF1C7;
@@ -401,15 +377,17 @@ int kPlayAnimation(Script *script, ScriptEntry *cmd, Scene *scn) {
if (cmd->param2) {
cmd->param2 = 2;
- scn->actions()->lineIncrement = 1;
+ _lineIncrement = 1;
}
}
- return -1;
+ error("Incomplete opcode %s (0x%02X) in Scene %d Line %d", _actions[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
}
-int kMoveScenePosition(Script *script, ScriptEntry *cmd, Scene *scn) {
- WorldStats *ws = scn->worldstats();
+//////////////////////////////////////////////////////////////////////////
+// Opcode 0x08
+IMPLEMENT_OPCODE(MoveScenePosition) {
+ WorldStats *ws = _scene->worldstats();
Common::Rect *sr = &ws->sceneRects[ws->sceneRectIdx];
if (cmd->param3 < 1) {
@@ -435,7 +413,7 @@ int kMoveScenePosition(Script *script, ScriptEntry *cmd, Scene *scn) {
} else if (cmd->param5) {
if (ws->motionStatus == 2)
- scn->actions()->lineIncrement = 1;
+ _lineIncrement = 1;
else
cmd->param5 = 0;
} else {
@@ -459,58 +437,62 @@ int kMoveScenePosition(Script *script, ScriptEntry *cmd, Scene *scn) {
// TODO: reverse asm block
}
- return -1;
+ error("Incomplete opcode %s (0x%02X) in Scene %d Line %d", _actions[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
}
-int kHideActor(Script *script, ScriptEntry *cmd, Scene *scn) {
+//////////////////////////////////////////////////////////////////////////
+// Opcode 0x09
+IMPLEMENT_OPCODE(HideActor) {
Actor *actor = 0;
actor = (cmd->param1 == -1) ?
- scn->getActor() :
- &scn->worldstats()->actors[cmd->param1];
+ _scene->getActor() :
+ &_scene->worldstats()->actors[cmd->param1];
actor->visible(false);
actor->updateActor_401320();
- return -1;
+ error("Incomplete opcode %s (0x%02X) in Scene %d Line %d", _actions[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
}
-int kShowActor(Script *script, ScriptEntry *cmd, Scene *scn) {
+//////////////////////////////////////////////////////////////////////////
+// Opcode 0x0A
+IMPLEMENT_OPCODE(ShowActor) {
Actor *actor = 0;
// TODO revisit when actor selection is cleaned up
if (cmd->param1 == -1)
- actor = scn->getActor();
+ actor = _scene->getActor();
else
- actor = &scn->worldstats()->actors[cmd->param1];
+ actor = &_scene->worldstats()->actors[cmd->param1];
actor->visible(true);
actor->updateActor_401320();
- actor->tickValue1 = scn->vm()->getTick();
-
- return 0;
+ actor->tickValue1 = _scene->vm()->getTick();
}
-int kSetActorPosition(Script *script, ScriptEntry *cmd, Scene *scn) {
- Actor *act = scn->getActor(cmd->param1);
+//////////////////////////////////////////////////////////////////////////
+// Opcode 0x0B
+IMPLEMENT_OPCODE(SetActorPosition) {
+ Actor *act = _scene->getActor(cmd->param1);
act->setPosition(cmd->param2, cmd->param3, cmd->param4, cmd->param5);
-
- return 0;
}
-int kSetSceneMotionStat(Script *script, ScriptEntry *cmd, Scene *scn) {
- scn->worldstats()->motionStatus = cmd->param1;
-
- return 0;
+//////////////////////////////////////////////////////////////////////////
+// Opcode 0x0C
+IMPLEMENT_OPCODE(SetSceneMotionStatus) {
+ _scene->worldstats()->motionStatus = cmd->param1;
}
-int kDisableActor(Script *script, ScriptEntry *cmd, Scene *scn) {
+//////////////////////////////////////////////////////////////////////////
+// Opcode 0x0D
+IMPLEMENT_OPCODE(DisableActor) {
int32 actorIndex = (cmd->param1 == -1) ? 0 : cmd->param1;
- Actor *act = scn->getActor(actorIndex);
+ Actor *act = _scene->getActor(actorIndex);
if (cmd->param5 != 2) {
if (act->updateType != 2 && act->updateType != 13) {
if (cmd->param2 != -1 || cmd->param3 != -1)
- scn->updateActorDirection(actorIndex, cmd->param4);
+ _scene->updateActorDirection(actorIndex, cmd->param4);
else {
if ((act->x1 + act->x2) != cmd->param2 ||
(act->y1 + act->y2) != cmd->param3) {
@@ -519,10 +501,10 @@ int kDisableActor(Script *script, ScriptEntry *cmd, Scene *scn) {
// cmd->param5 = 2
// v245 = true
} else
- scn->updateActorDirection(actorIndex, cmd->param4);
+ _scene->updateActorDirection(actorIndex, cmd->param4);
}
}
- return -1;
+ error("Incomplete opcode %s (0x%02X) in Scene %d Line %d", _actions[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
}
if (act->updateType != 2 && act->updateType != 13) {
@@ -530,387 +512,480 @@ int kDisableActor(Script *script, ScriptEntry *cmd, Scene *scn) {
// v245 = false
if ((act->x1 + act->x2) != cmd->param2 ||
(act->y1 + act->y2) != cmd->param3) {
- scn->updateActorDirection(actorIndex, cmd->param4);
+ _scene->updateActorDirection(actorIndex, cmd->param4);
}
}
- return -1;
+ error("Incomplete opcode %s (0x%02X) in Scene %d Line %d", _actions[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
}
-int kEnableActor(Script *script, ScriptEntry *cmd, Scene *scn) {
+//////////////////////////////////////////////////////////////////////////
+// Opcode 0x0E
+IMPLEMENT_OPCODE(EnableActor) {
int actorIndex = 0;
if (cmd->param1 == -1)
- ;//actorIndex = scn->getWorldStats()->playerActor;
+ ;//actorIndex = _scene->getWorldStats()->playerActor;
else
actorIndex = cmd->param1;
/* TODO implement enableActorSub()
- if (scn->worldstats()->actors[actorIndex].updateType == 5)
- scn->actions()->enableActorSub(actorIndex, 4);
+ if (_scene->worldstats()->actors[actorIndex].updateType == 5)
+ enableActorSub(actorIndex, 4);
*/
- return -1;
+ error("Incomplete opcode %s (0x%02X) in Scene %d Line %d", _actions[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
}
-int kEnableBarriers(Script *script, ScriptEntry *cmd, Scene *scn) {
- int32 barIdx = scn->worldstats()->getBarrierIndexById(cmd->param1);
- Barrier *bar = &scn->worldstats()->barriers[barIdx];
+//////////////////////////////////////////////////////////////////////////
+// Opcode 0x0F
+IMPLEMENT_OPCODE(EnableBarriers) {
+ int32 barIdx = _scene->worldstats()->getBarrierIndexById(cmd->param1);
+ Barrier *bar = &_scene->worldstats()->barriers[barIdx];
int32 sndIdx = cmd->param3;
- if (!script->counter && scn->getSceneIndex() != 13 && sndIdx != 0) {
+ if (!_currentScript->counter && _scene->getSceneIndex() != 13 && sndIdx != 0) {
// FIXME: I really don't understand what (sndIdx != 0) & 5 is supposed to be doing here,
// but this is effectively trying to do a boolean AND operation on a boolean variable
// which is odd, and wrong. Changing it to (sndIdx & 5), for now
- //scn->vm()->sound()->playSound(((sndIdx != 0) & 5) + 0x80120001,
- scn->vm()->sound()->playSound((sndIdx & 5) + 0x80120001, false, Config.sfxVolume, 0);
+ //_scene->vm()->sound()->playSound(((sndIdx != 0) & 5) + 0x80120001,
+ _scene->vm()->sound()->playSound((sndIdx & 5) + 0x80120001, false, Config.sfxVolume, 0);
}
- if (script->counter >= (3 * cmd->param2 - 1)) {
- script->counter = 0;
+ if (_currentScript->counter >= (3 * cmd->param2 - 1)) {
+ _currentScript->counter = 0;
bar->field_67C = 0;
- // TODO scn->actions()->processActionListSub02(script, cmd, 2);
+ // TODO processActionListSub02(_currentScript, cmd, 2);
} else {
int v64; // XXX rename when processActionListSub02 is better implemented
- script->counter += 1;
+ _currentScript->counter += 1;
if (sndIdx) {
v64 = 1;
- bar->field_67C = 3 - script->counter / cmd->param2;
+ bar->field_67C = 3 - _currentScript->counter / cmd->param2;
} else {
v64 = 0;
- bar->field_67C = script->counter / cmd->param2 + 1;
+ bar->field_67C = _currentScript->counter / cmd->param2 + 1;
}
- // TODO scn->actions()->processActionListSub02(script, cmd, v64);
+ // TODO processActionListSub02(_currentScript, cmd, v64);
}
- return -1;
+ error("Incomplete opcode %s (0x%02X) in Scene %d Line %d", _actions[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
}
-int kReturn(Script *script, ScriptEntry *cmd, Scene *scn) {
- scn->actions()->done = true;
- scn->actions()->lineIncrement = 0;
+//////////////////////////////////////////////////////////////////////////
+// Opcode 0x10 : Identical to opcode 0x00
- return 0;
-}
+//////////////////////////////////////////////////////////////////////////
+// Opcode 0x11
+IMPLEMENT_OPCODE(DestroyBarrier) {
+ Barrier *barrier = _scene->worldstats()->getBarrierById(cmd->param1);
-int kDestroyBarrier(Script *script, ScriptEntry *cmd, Scene *scn) {
- Barrier *barrier = scn->worldstats()->getBarrierById(cmd->param1);
+ if (!barrier)
+ error("ActionList::kDestroyBarrier: Requested invalid object ID:0x%02X in Scene %d Line %d.", cmd->param1, _scene->getSceneIndex(),_currentLine);
- if (barrier) {
- barrier->flags &= 0xFFFFFFFE;
- barrier->flags |= 0x20000;
- scn->vm()->screen()->deleteGraphicFromQueue(barrier->resId);
- } else
- debugC(kDebugLevelScripts,
- "Requested invalid object ID:0x%02X in Scene %d Line %d.",
- cmd->param1,
- scn->getSceneIndex(),
- scn->actions()->currentLine);
-
- return 0;
+ barrier->flags &= 0xFFFFFFFE;
+ barrier->flags |= 0x20000;
+ _scene->vm()->screen()->deleteGraphicFromQueue(barrier->resId);
}
-int k_unk12_JMP_WALK_ACTOR(Script *script, ScriptEntry *cmd, Scene *scn) {
- return -2;
+//////////////////////////////////////////////////////////////////////////
+// Opcode 0x12
+IMPLEMENT_OPCODE(_unk12_JMP_WALK_ACTOR) {
+ error("Unhandled opcode %s (0x%02X) in Scene %d Line %d", _actions[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
}
-int k_unk13_JMP_WALK_ACTOR(Script *script, ScriptEntry *cmd, Scene *scn) {
- return -2;
+
+//////////////////////////////////////////////////////////////////////////
+// Opcode 0x13
+IMPLEMENT_OPCODE(_unk13_JMP_WALK_ACTOR) {
+ error("Unhandled opcode %s (0x%02X) in Scene %d Line %d", _actions[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
}
-int k_unk14_JMP_WALK_ACTOR(Script *script, ScriptEntry *cmd, Scene *scn) {
- return -2;
+
+//////////////////////////////////////////////////////////////////////////
+// Opcode 0x14
+IMPLEMENT_OPCODE(_unk14_JMP_WALK_ACTOR) {
+ error("Unhandled opcode %s (0x%02X) in Scene %d Line %d", _actions[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
}
-int k_unk15(Script *script, ScriptEntry *cmd, Scene *scn) {
- return -2;
+
+//////////////////////////////////////////////////////////////////////////
+// Opcode 0x15
+IMPLEMENT_OPCODE(_unk15) {
+ error("Unhandled opcode %s (0x%02X) in Scene %d Line %d", _actions[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
}
-int kResetAnimation(Script *script, ScriptEntry *cmd, Scene *scn) {
- Barrier *barrier = scn->worldstats()->getBarrierById(cmd->param1);
+//////////////////////////////////////////////////////////////////////////
+// Opcode 0x16
+IMPLEMENT_OPCODE(ResetAnimation) {
+ Barrier *barrier = _scene->worldstats()->getBarrierById(cmd->param1);
if ((barrier->flags & 0x10000) == 0)
barrier->frameIdx = 0;
else
barrier->frameIdx = barrier->frameCount - 1;
-
- return 0;
}
-int kClearFlag1Bit0(Script *script, ScriptEntry *cmd, Scene *scn) {
- Barrier *barrier = scn->worldstats()->getBarrierById(cmd->param1);
+//////////////////////////////////////////////////////////////////////////
+// Opcode 0x17
+IMPLEMENT_OPCODE(ClearFlag1Bit0) {
+ Barrier *barrier = _scene->worldstats()->getBarrierById(cmd->param1);
barrier->flags &= 0xFFFFFFFE;
-
- return 0;
}
-int k_unk18_PLAY_SND(Script *script, ScriptEntry *cmd, Scene *scn) {
- return -2;
+//////////////////////////////////////////////////////////////////////////
+// Opcode 0x18
+IMPLEMENT_OPCODE(_unk18_PLAY_SND) {
+ error("Unhandled opcode %s (0x%02X) in Scene %d Line %d", _actions[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
}
-int kJumpIfFlag2Bit0(Script *script, ScriptEntry *cmd, Scene *scn) {
+//////////////////////////////////////////////////////////////////////////
+// Opcode 0x19
+IMPLEMENT_OPCODE(JumpIfFlag2Bit0) {
int targetType = cmd->param2;
- return 0;
-
+ error("Incomplete opcode %s (0x%02X) in Scene %d Line %d", _actions[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
// TODO targetType == 7 is trying to access an out of bounds actor
// look at the disassembly again
if (targetType <= 0)
- scn->actions()->done = (scn->worldstats()->getBarrierById(cmd->param1)->flags2 & 1) == 0;
+ _done = (_scene->worldstats()->getBarrierById(cmd->param1)->flags2 & 1) == 0;
else
if (targetType == 1) // v4 == 1, so 1
- scn->actions()->done = (scn->worldstats()->getActionAreaById(cmd->param1)->actionType & 1) == 0;
+ _done = (_scene->worldstats()->getActionAreaById(cmd->param1)->actionType & 1) == 0;
else
- scn->actions()->done = (scn->worldstats()->actors[cmd->param1].flags2 & 1) == 0;
-
- return -1;
+ _done = (_scene->worldstats()->actors[cmd->param1].flags2 & 1) == 0;
}
-int kSetFlag2Bit0(Script *script, ScriptEntry *cmd, Scene *scn) {
+//////////////////////////////////////////////////////////////////////////
+// Opcode 0x1A
+IMPLEMENT_OPCODE(SetFlag2Bit0) {
int targetType = cmd->param2;
if (targetType == 2)
- scn->worldstats()->actors[cmd->param1].flags2 |= 1;
+ _scene->worldstats()->actors[cmd->param1].flags2 |= 1;
else
if (targetType == 1)
- scn->worldstats()->getActionAreaById(cmd->param1)->actionType |= 1;
+ _scene->worldstats()->getActionAreaById(cmd->param1)->actionType |= 1;
else
- scn->worldstats()->getBarrierById(cmd->param1)->flags2 |= 1;
-
- return 0;
+ _scene->worldstats()->getBarrierById(cmd->param1)->flags2 |= 1;
}
-int kClearFlag2Bit0(Script *script, ScriptEntry *cmd, Scene *scn) {
- return -2;
+//////////////////////////////////////////////////////////////////////////
+// Opcode 0x1B
+IMPLEMENT_OPCODE(ClearFlag2Bit0) {
+ error("Unhandled opcode %s (0x%02X) in Scene %d Line %d", _actions[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
}
-int kJumpIfFlag2Bit2(Script *script, ScriptEntry *cmd, Scene *scn) {
- return -2;
+
+//////////////////////////////////////////////////////////////////////////
+// Opcode 0x1C
+IMPLEMENT_OPCODE(JumpIfFlag2Bit2) {
+ error("Unhandled opcode %s (0x%02X) in Scene %d Line %d", _actions[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
}
-int kSetFlag2Bit2(Script *script, ScriptEntry *cmd, Scene *scn) {
- return -2;
+
+//////////////////////////////////////////////////////////////////////////
+// Opcode 0x1D
+IMPLEMENT_OPCODE(SetFlag2Bit2) {
+ error("Unhandled opcode %s (0x%02X) in Scene %d Line %d", _actions[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
}
-int kClearFlag2Bit2(Script *script, ScriptEntry *cmd, Scene *scn) {
- return -2;
+
+//////////////////////////////////////////////////////////////////////////
+// Opcode 0x1E
+IMPLEMENT_OPCODE(ClearFlag2Bit2) {
+ error("Unhandled opcode %s (0x%02X) in Scene %d Line %d", _actions[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
}
-int kJumpIfFlag2Bit1(Script *script, ScriptEntry *cmd, Scene *scn) {
- return -2;
+
+//////////////////////////////////////////////////////////////////////////
+// Opcode 0x1F
+IMPLEMENT_OPCODE(JumpIfFlag2Bit1) {
+ error("Unhandled opcode %s (0x%02X) in Scene %d Line %d", _actions[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
}
-int kSetFlag2Bit1(Script *script, ScriptEntry *cmd, Scene *scn) {
- return -2;
+
+//////////////////////////////////////////////////////////////////////////
+// Opcode 0x20
+IMPLEMENT_OPCODE(SetFlag2Bit1) {
+ error("Unhandled opcode %s (0x%02X) in Scene %d Line %d", _actions[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
}
-int kClearFlag2Bit1(Script *script, ScriptEntry *cmd, Scene *scn) {
- return -2;
+
+//////////////////////////////////////////////////////////////////////////
+// Opcode 0x21
+IMPLEMENT_OPCODE(ClearFlag2Bit1) {
+ error("Unhandled opcode %s (0x%02X) in Scene %d Line %d", _actions[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
}
-int k_unk22(Script *script, ScriptEntry *cmd, Scene *scn) {
- return -2;
+
+//////////////////////////////////////////////////////////////////////////
+// Opcode 0x22
+IMPLEMENT_OPCODE(_unk22) {
+ error("Unhandled opcode %s (0x%02X) in Scene %d Line %d", _actions[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
}
-int k_unk23(Script *script, ScriptEntry *cmd, Scene *scn) {
- return -2;
+
+//////////////////////////////////////////////////////////////////////////
+// Opcode 0x23
+IMPLEMENT_OPCODE(_unk23) {
+ error("Unhandled opcode %s (0x%02X) in Scene %d Line %d", _actions[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
}
-int k_unk24(Script *script, ScriptEntry *cmd, Scene *scn) {
- return -2;
+
+//////////////////////////////////////////////////////////////////////////
+// Opcode 0x24
+IMPLEMENT_OPCODE(_unk24) {
+ error("Unhandled opcode %s (0x%02X) in Scene %d Line %d", _actions[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
}
-int kRunEncounter(Script *script, ScriptEntry *cmd, Scene *scn) {
- return -2;
+
+//////////////////////////////////////////////////////////////////////////
+// Opcode 0x25
+IMPLEMENT_OPCODE(RunEncounter) {
+ error("Unhandled opcode %s (0x%02X) in Scene %d Line %d", _actions[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
}
-int kJumpIfFlag2Bit4(Script *script, ScriptEntry *cmd, Scene *scn) {
- return -2;
+
+//////////////////////////////////////////////////////////////////////////
+// Opcode 0x26
+IMPLEMENT_OPCODE(JumpIfFlag2Bit4) {
+ error("Unhandled opcode %s (0x%02X) in Scene %d Line %d", _actions[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
}
-int kSetFlag2Bit4(Script *script, ScriptEntry *cmd, Scene *scn) {
- return -2;
+
+//////////////////////////////////////////////////////////////////////////
+// Opcode 0x27
+IMPLEMENT_OPCODE(SetFlag2Bit4) {
+ error("Unhandled opcode %s (0x%02X) in Scene %d Line %d", _actions[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
}
-int kClearFlag2Bit4(Script *script, ScriptEntry *cmd, Scene *scn) {
- return -2;
+
+//////////////////////////////////////////////////////////////////////////
+// Opcode 0x28
+IMPLEMENT_OPCODE(ClearFlag2Bit4) {
+ error("Unhandled opcode %s (0x%02X) in Scene %d Line %d", _actions[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
}
-int kSetActorField638(Script *script, ScriptEntry *cmd, Scene *scn) {
- return -2;
+
+//////////////////////////////////////////////////////////////////////////
+// Opcode 0x29
+IMPLEMENT_OPCODE(SetActorField638) {
+ error("Unhandled opcode %s (0x%02X) in Scene %d Line %d", _actions[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
}
-int kJumpIfActorField638(Script *script, ScriptEntry *cmd, Scene *scn) {
- return -2;
+
+//////////////////////////////////////////////////////////////////////////
+// Opcode 0x2A
+IMPLEMENT_OPCODE(JumpIfActorField638) {
+ error("Unhandled opcode %s (0x%02X) in Scene %d Line %d", _actions[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
}
-int kChangeScene(Script *script, ScriptEntry *cmd, Scene *scn) {
- scn->actions()->delayedSceneIndex = cmd->param1 + 4;
+//////////////////////////////////////////////////////////////////////////
+// Opcode 0x2B
+IMPLEMENT_OPCODE(ChangeScene) {
+ _delayedSceneIndex = cmd->param1 + 4;
debug(kDebugLevelScripts,
"Queueing Scene Change to scene %d...",
- scn->actions()->delayedSceneIndex);
-
- return 0;
+ _delayedSceneIndex);
}
-int k_unk2C_ActorSub(Script *script, ScriptEntry *cmd, Scene *scn) {
- return -2;
+//////////////////////////////////////////////////////////////////////////
+// Opcode 0x2C
+IMPLEMENT_OPCODE(_unk2C_ActorSub) {
+ error("Unhandled opcode %s (0x%02X) in Scene %d Line %d", _actions[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
}
-int kPlayMovie(Script *script, ScriptEntry *cmd, Scene *scn) {
+//////////////////////////////////////////////////////////////////////////
+// Opcode 0x2D
+IMPLEMENT_OPCODE(PlayMovie) {
// TODO: add missing code here
- scn->actions()->delayedVideoIndex = cmd->param1;
+ _delayedVideoIndex = cmd->param1;
- return -1;
+ error("Incomplete opcode %s (0x%02X) in Scene %d Line %d", _actions[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
}
-int kStopAllBarriersSounds(Script *script, ScriptEntry *cmd, Scene *scn) {
+//////////////////////////////////////////////////////////////////////////
+// Opcode 0x2E
+IMPLEMENT_OPCODE(StopAllBarriersSounds) {
// TODO: do this for all barriers that have sfx playing
- scn->vm()->sound()->stopAllSounds();
+ _scene->vm()->sound()->stopAllSounds();
- return -1;
+ error("Incomplete opcode %s (0x%02X) in Scene %d Line %d", _actions[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
}
-int kSetActionFlag(Script *script, ScriptEntry *cmd, Scene *scn) {
- scn->actions()->setActionFlag(true);
- return 0;
-}
-int kClearActionFlag(Script *script, ScriptEntry *cmd, Scene *scn) {
- scn->actions()->setActionFlag(false);
- return 0;
+//////////////////////////////////////////////////////////////////////////
+// Opcode 0x2F
+IMPLEMENT_OPCODE(StopProcessing) {
+ _skipProcessing = true;
}
-int kResetSceneRect(Script *script, ScriptEntry *cmd, Scene *scn) {
- return -2;
+
+//////////////////////////////////////////////////////////////////////////
+// Opcode 0x30
+IMPLEMENT_OPCODE(ResumeProcessing) {
+ _skipProcessing = false;
}
-int kChangeMusicById(Script *script, ScriptEntry *cmd, Scene *scn) {
- return -2;
+
+//////////////////////////////////////////////////////////////////////////
+// Opcode 0x31
+IMPLEMENT_OPCODE(ResetSceneRect) {
+ error("Unhandled opcode %s (0x%02X) in Scene %d Line %d", _actions[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
}
-int kStopMusic(Script *script, ScriptEntry *cmd, Scene *scn) {
- scn->vm()->sound()->stopMusic();
+//////////////////////////////////////////////////////////////////////////
+// Opcode 0x32
+IMPLEMENT_OPCODE(ChangeMusicById) {
+ error("Unhandled opcode %s (0x%02X) in Scene %d Line %d", _actions[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
+}
- return 0;
+//////////////////////////////////////////////////////////////////////////
+// Opcode 0x33
+IMPLEMENT_OPCODE(StopMusic) {
+ _scene->vm()->sound()->stopMusic();
}
-int k_unk34_Status(Script *script, ScriptEntry *cmd, Scene *scn) {
+//////////////////////////////////////////////////////////////////////////
+// Opcode 0x34
+IMPLEMENT_OPCODE(_unk34_Status) {
if (cmd->param1 >= 2) {
cmd->param1 = 0;
} else {
cmd->param1++;
- scn->actions()->lineIncrement = 1;
+ _lineIncrement = 1;
}
-
- return 0;
}
-int k_unk35(Script *script, ScriptEntry *cmd, Scene *scn) {
- return -2;
+//////////////////////////////////////////////////////////////////////////
+// Opcode 0x35
+IMPLEMENT_OPCODE(_unk35) {
+ error("Unhandled opcode %s (0x%02X) in Scene %d Line %d", _actions[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
}
-int k_unk36(Script *script, ScriptEntry *cmd, Scene *scn) {
- return -2;
+
+//////////////////////////////////////////////////////////////////////////
+// Opcode 0x36
+IMPLEMENT_OPCODE(_unk36) {
+ error("Unhandled opcode %s (0x%02X) in Scene %d Line %d", _actions[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
}
-int kRunBlowUpPuzzle(Script *script, ScriptEntry *cmd, Scene *scn) {
+//////////////////////////////////////////////////////////////////////////
+// Opcode 0x37
+IMPLEMENT_OPCODE(RunBlowUpPuzzle) {
// FIXME: improve this to call other blowUpPuzzles than VCR
//int puzzleIdx = cmd->param1;
warning("kRunBlowUpPuzzle not implemented");
- //scn->setBlowUpPuzzle(new BlowUpPuzzleVCR(scn));
- //scn->getBlowUpPuzzle()->openBlowUp();
+ //_scene->setBlowUpPuzzle(new BlowUpPuzzleVCR(scn));
+ //_scene->getBlowUpPuzzle()->openBlowUp();
- return -1;
+ error("Incomplete opcode %s (0x%02X) in Scene %d Line %d", _actions[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
}
-int kJumpIfFlag2Bit3(Script *script, ScriptEntry *cmd, Scene *scn) {
- return -2;
+//////////////////////////////////////////////////////////////////////////
+// Opcode 0x38
+IMPLEMENT_OPCODE(JumpIfFlag2Bit3) {
+ error("Unhandled opcode %s (0x%02X) in Scene %d Line %d", _actions[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
}
-int kSetFlag2Bit3(Script *script, ScriptEntry *cmd, Scene *scn) {
- return -2;
+
+//////////////////////////////////////////////////////////////////////////
+// Opcode 0x39
+IMPLEMENT_OPCODE(SetFlag2Bit3) {
+ error("Unhandled opcode %s (0x%02X) in Scene %d Line %d", _actions[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
}
-int kClearFlag2Bit3(Script *script, ScriptEntry *cmd, Scene *scn) {
- return -2;
+
+//////////////////////////////////////////////////////////////////////////
+// Opcode 0x3A
+IMPLEMENT_OPCODE(ClearFlag2Bit3) {
+ error("Unhandled opcode %s (0x%02X) in Scene %d Line %d", _actions[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
}
-int k_unk3B_PALETTE_MOD(Script *script, ScriptEntry *cmd, Scene *scn) {
- return -2;
+
+//////////////////////////////////////////////////////////////////////////
+// Opcode 0x3B
+IMPLEMENT_OPCODE(_unk3B_PALETTE_MOD) {
+ error("Unhandled opcode %s (0x%02X) in Scene %d Line %d", _actions[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
}
-int k_unk3C_CMP_VAL(Script *script, ScriptEntry *cmd, Scene *scn) {
+//////////////////////////////////////////////////////////////////////////
+// Opcode 0x3C
+IMPLEMENT_OPCODE(_unk3C_CMP_VAL) {
if (cmd->param1) {
if (cmd->param2 >= cmd->param1) {
cmd->param2 = 0;
} else {
cmd->param2++;
- scn->actions()->lineIncrement = 1;
+ _lineIncrement = 1;
}
}
-
- return 0;
}
-int kWaitUntilFramePlayed(Script *script, ScriptEntry *cmd, Scene *scn) {
- Barrier *barrier = scn->worldstats()->getBarrierById(cmd->param1);
+//////////////////////////////////////////////////////////////////////////
+// Opcode 0x3D
+IMPLEMENT_OPCODE(WaitUntilFramePlayed) {
+ Barrier *barrier = _scene->worldstats()->getBarrierById(cmd->param1);
- if (barrier) {
- uint32 frameNum = cmd->param2;
- if (cmd->param2 == -1)
- frameNum = barrier->frameCount - 1;
+ if (!barrier)
+ error("ActionList::WaitUntilFramePlayed: Requested invalid object ID:0x%02X in Scene %d Line %d.", cmd->param1, _scene->getSceneIndex(),_currentLine);
- if (barrier->frameIdx != frameNum) {
- scn->actions()->lineIncrement = 1;
- scn->actions()->waitCycle = true;
- }
- } else
- debugC(kDebugLevelScripts,
- "Requested invalid object ID:0x%02X in Scene %d Line %d.",
- cmd->param1,
- scn->getSceneIndex(),
- scn->actions()->currentLine);
+ uint32 frameNum = cmd->param2;
+ if (cmd->param2 == -1)
+ frameNum = barrier->frameCount - 1;
- return 0;
+ if (barrier->frameIdx != frameNum) {
+ _lineIncrement = 1;
+ _waitCycle = true;
+ }
}
-int kUpdateWideScreen(Script *script, ScriptEntry *cmd, Scene *scn) {
+
+//////////////////////////////////////////////////////////////////////////
+// Opcode 0x3E
+IMPLEMENT_OPCODE(UpdateWideScreen) {
int barSize = cmd->param1;
if (barSize >= 22) {
cmd->param1 = 0;
} else {
- scn->vm()->screen()->drawWideScreen(4 * barSize);
+ _scene->vm()->screen()->drawWideScreen(4 * barSize);
cmd->param1++;
}
-
- return 0;
}
-int k_unk3F(Script *script, ScriptEntry *cmd, Scene *scn) {
- return -2;
+
+//////////////////////////////////////////////////////////////////////////
+// Opcode 0x3F
+IMPLEMENT_OPCODE(_unk3F) {
+ error("Unhandled opcode %s (0x%02X) in Scene %d Line %d", _actions[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
}
-int k_unk40_SOUND(Script *script, ScriptEntry *cmd, Scene *scn) {
- return -2;
+
+//////////////////////////////////////////////////////////////////////////
+// Opcode 0x40
+IMPLEMENT_OPCODE(_unk40_SOUND) {
+ error("Unhandled opcode %s (0x%02X) in Scene %d Line %d", _actions[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
}
-int kPlaySpeech(Script *script, ScriptEntry *cmd, Scene *scn) {
+//////////////////////////////////////////////////////////////////////////
+// Opcode 0x41
+IMPLEMENT_OPCODE(PlaySpeech) {
//TODO - Add support for other param options
int32 sndIdx = cmd->param1;
if ((int)sndIdx >= 0) {
if (cmd->param4 != 2) {
- int32 resIdx = scn->speech()->play(sndIdx);
+ int32 resIdx = _scene->speech()->play(sndIdx);
cmd->param5 = resIdx;
if (cmd->param2) {
- scn->vm()->setGameFlag(183);
+ _scene->vm()->setGameFlag(183);
cmd->param4 = 2;
if (cmd->param6) {
// TODO: set flag 01
}
- scn->actions()->lineIncrement = 1;
+ _lineIncrement = 1;
}
if (cmd->param3) {
if (!cmd->param6) {
- scn->vm()->setGameFlag(219);
+ _scene->vm()->setGameFlag(219);
}
}
}
-
- if (scn->vm()->sound()->isPlaying(cmd->param5)) {
- scn->actions()->lineIncrement = 1;
+
+ if (_scene->vm()->sound()->isPlaying(cmd->param5)) {
+ _lineIncrement = 1;
}
- scn->vm()->clearGameFlag(183);
+ _scene->vm()->clearGameFlag(183);
cmd->param4 = 0;
-
+
if (cmd->param3) {
if (cmd->param6) {
// TODO: clear flag 01
}
- scn->vm()->clearGameFlag(219);
+ _scene->vm()->clearGameFlag(219);
}
-
+
if (!cmd->param6) {
cmd->param6 = 1;
}
@@ -920,86 +995,124 @@ int kPlaySpeech(Script *script, ScriptEntry *cmd, Scene *scn) {
debugC(kDebugLevelScripts,
"Requested invalid sound ID:0x%02X in Scene %d Line %d.",
cmd->param1,
- scn->getSceneIndex(),
- scn->actions()->currentLine);
+ _scene->getSceneIndex(),
+ _currentLine);
- return -1;
+ error("Incomplete opcode %s (0x%02X) in Scene %d Line %d", _actions[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
}
-int k_unk42(Script *script, ScriptEntry *cmd, Scene *scn) {
- return -2;
+//////////////////////////////////////////////////////////////////////////
+// Opcode 0x42
+IMPLEMENT_OPCODE(_unk42) {
+ error("Unhandled opcode %s (0x%02X) in Scene %d Line %d", _actions[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
}
-int k_unk43(Script *script, ScriptEntry *cmd, Scene *scn) {
- return -2;
+
+//////////////////////////////////////////////////////////////////////////
+// Opcode 0x43
+IMPLEMENT_OPCODE(_unk43) {
+ error("Unhandled opcode %s (0x%02X) in Scene %d Line %d", _actions[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
}
-int kPaletteFade(Script *script, ScriptEntry *cmd, Scene *scn) {
- return -2;
+
+//////////////////////////////////////////////////////////////////////////
+// Opcode 0x44
+IMPLEMENT_OPCODE(PaletteFade) {
+ error("Unhandled opcode %s (0x%02X) in Scene %d Line %d", _actions[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
}
-int kStartPaletteFadeThread(Script *script, ScriptEntry *cmd, Scene *scn) {
- return -2;
+
+//////////////////////////////////////////////////////////////////////////
+// Opcode 0x45
+IMPLEMENT_OPCODE(StartPaletteFadeThread) {
+ error("Unhandled opcode %s (0x%02X) in Scene %d Line %d", _actions[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
}
-int k_unk46(Script *script, ScriptEntry *cmd, Scene *scn) {
- return -2;
+
+//////////////////////////////////////////////////////////////////////////
+// Opcode 0x46
+IMPLEMENT_OPCODE(_unk46) {
+ error("Unhandled opcode %s (0x%02X) in Scene %d Line %d", _actions[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
}
-int kActorFaceObject(Script *script, ScriptEntry *cmd, Scene *scn) {
+//////////////////////////////////////////////////////////////////////////
+// Opcode 0x47
+IMPLEMENT_OPCODE(ActorFaceObject) {
// XXX
// Dropping param1, since it's the character index
// Investigate further if/when we have a scene with
// multiple characters in the actor[] array
- scn->getActor()->faceTarget(cmd->param2, cmd->param3);
+ _scene->getActor()->faceTarget(cmd->param2, cmd->param3);
- return -1;
+ error("Incomplete opcode %s (0x%02X) in Scene %d Line %d", _actions[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
}
-int k_unk48_MATTE_01(Script *script, ScriptEntry *cmd, Scene *scn) {
- return -2;
+//////////////////////////////////////////////////////////////////////////
+// Opcode 0x48
+IMPLEMENT_OPCODE(_unk48_MATTE_01) {
+ error("Unhandled opcode %s (0x%02X) in Scene %d Line %d", _actions[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
}
-int k_unk49_MATTE_90(Script *script, ScriptEntry *cmd, Scene *scn) {
- return -2;
+
+//////////////////////////////////////////////////////////////////////////
+// Opcode 0x49
+IMPLEMENT_OPCODE(_unk49_MATTE_90) {
+ error("Unhandled opcode %s (0x%02X) in Scene %d Line %d", _actions[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
}
-int kJumpIfSoundPlaying(Script *script, ScriptEntry *cmd, Scene *scn) {
- return -2;
+
+//////////////////////////////////////////////////////////////////////////
+// Opcode 0x4A
+IMPLEMENT_OPCODE(JumpIfSoundPlaying) {
+ error("Unhandled opcode %s (0x%02X) in Scene %d Line %d", _actions[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
}
-int kChangePlayerCharacterIndex(Script *script, ScriptEntry *cmd, Scene *scn) {
- return -2;
+
+//////////////////////////////////////////////////////////////////////////
+// Opcode 0x4B
+IMPLEMENT_OPCODE(ChangePlayerCharacterIndex) {
+ error("Unhandled opcode %s (0x%02X) in Scene %d Line %d", _actions[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
}
-int kChangeActorField40(Script *script, ScriptEntry *cmd, Scene *scn) {
+//////////////////////////////////////////////////////////////////////////
+// Opcode 0x4C
+IMPLEMENT_OPCODE(ChangeActorField40) {
// TODO: figure out what is this field and what values are set
int actorIdx = cmd->param1;
int fieldType = cmd->param2;
if (fieldType) {
- if (scn->worldstats()->actors[actorIdx].updateType < 11)
- scn->worldstats()->actors[actorIdx].updateType = 14;
+ if (_scene->worldstats()->actors[actorIdx].updateType < 11)
+ _scene->worldstats()->actors[actorIdx].updateType = 14;
} else {
- scn->worldstats()->actors[actorIdx].updateType = 4;
+ _scene->worldstats()->actors[actorIdx].updateType = 4;
}
- return -1;
+ error("Incomplete opcode %s (0x%02X) in Scene %d Line %d", _actions[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
}
-int kStopSound(Script *script, ScriptEntry *cmd, Scene *scn) {
- return -2;
+//////////////////////////////////////////////////////////////////////////
+// Opcode 0x4D
+IMPLEMENT_OPCODE(StopSound) {
+ error("Unhandled opcode %s (0x%02X) in Scene %d Line %d", _actions[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
}
-int k_unk4E_RANDOM_COMMAND(Script *script, ScriptEntry *cmd, Scene *scn) {
- return -2;
+
+//////////////////////////////////////////////////////////////////////////
+// Opcode 0x4E
+IMPLEMENT_OPCODE(_unk4E_RANDOM_COMMAND) {
+ error("Unhandled opcode %s (0x%02X) in Scene %d Line %d", _actions[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
}
-int kClearScreen(Script *script, ScriptEntry *cmd, Scene *scn) {
+//////////////////////////////////////////////////////////////////////////
+// Opcode 0x4F
+IMPLEMENT_OPCODE(ClearScreen) {
if (cmd->param1)
- scn->vm()->screen()->clearScreen();
-
- return 0;
+ _scene->vm()->screen()->clearScreen();
}
-int kQuit(Script *script, ScriptEntry *cmd, Scene *scn) {
- return -2;
+//////////////////////////////////////////////////////////////////////////
+// Opcode 0x50
+IMPLEMENT_OPCODE(Quit) {
+ error("Unhandled opcode %s (0x%02X) in Scene %d Line %d", _actions[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
}
-int kJumpBarrierFrame(Script *script, ScriptEntry *cmd, Scene *scn) {
- Barrier *barrier = scn->worldstats()->getBarrierById(cmd->param1);
+//////////////////////////////////////////////////////////////////////////
+// Opcode 0x51
+IMPLEMENT_OPCODE(JumpBarrierFrame) {
+ Barrier *barrier = _scene->worldstats()->getBarrierById(cmd->param1);
int idx = (int)barrier->frameIdx;
if (cmd->param2 == -1)
@@ -1019,73 +1132,82 @@ int kJumpBarrierFrame(Script *script, ScriptEntry *cmd, Scene *scn) {
//break;
}
- ScriptEntry *nextCmd = &script->commands[cmd->param9];
+ ScriptEntry *nextCmd = &_currentScript->commands[cmd->param9];
// 0x10 == kReturn
if (nextCmd->opcode != 0x10 && nextCmd->opcode)
- scn->actions()->done = true;
-
- return 0;
+ _done = true;
}
-int k_unk52(Script *script, ScriptEntry *cmd, Scene *scn) {
- return -2;
+//////////////////////////////////////////////////////////////////////////
+// Opcode 0x52
+IMPLEMENT_OPCODE(_unk52) {
+ error("Unhandled opcode %s (0x%02X) in Scene %d Line %d", _actions[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
}
-int k_unk53(Script *script, ScriptEntry *cmd, Scene *scn) {
- return -2;
+
+//////////////////////////////////////////////////////////////////////////
+// Opcode 0x53
+IMPLEMENT_OPCODE(_unk53) {
+ error("Unhandled opcode %s (0x%02X) in Scene %d Line %d", _actions[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
}
-int k_unk54_SET_ACTIONLIST_6EC(Script *script, ScriptEntry *cmd, Scene *scn) {
+//////////////////////////////////////////////////////////////////////////
+// Opcode 0x54
+IMPLEMENT_OPCODE(_unk54_SET_ACTIONLIST_6EC) {
if (cmd->param2)
- script->field_1BB0 = scn->vm()->_rnd.getRandomNumber(cmd->param1);
+ _currentScript->field_1BB0 = _scene->vm()->_rnd.getRandomNumber(cmd->param1);
else
- script->field_1BB0 = cmd->param1;
-
- return 0;
+ _currentScript->field_1BB0 = cmd->param1;
}
-int k_unk55(Script *script, ScriptEntry *cmd, Scene *scn) {
+//////////////////////////////////////////////////////////////////////////
+// Opcode 0x55
+IMPLEMENT_OPCODE(_unk55) {
// TODO
/*
if (!cmd->param2) {
- if (cmd->param3 && script->field_1BB0 < cmd->param1)
+ if (cmd->param3 && _currentScript->field_1BB0 < cmd->param1)
//break;
- else if (cmd->param4 && script->field_1BB0 > cmd->param1)
+ else if (cmd->param4 && _currentScript->field_1BB0 > cmd->param1)
//break;
- else if (cmd->param5 && script->field_1BB0 <= cmd->param1)
+ else if (cmd->param5 && _currentScript->field_1BB0 <= cmd->param1)
//break;
- else if (cmd->param6 && script->field_1BB0 >= cmd->param1)
+ else if (cmd->param6 && _currentScript->field_1BB0 >= cmd->param1)
//break;
- else if (cmd->param7 && script->field_1BB0 != cmd->param1)
+ else if (cmd->param7 && _currentScript->field_1BB0 != cmd->param1)
//break;
- } else if(script->field_1BB0 == cmd->param1) {
+ } else if(_currentScript->field_1BB0 == cmd->param1) {
//break;
}
*/
- ScriptEntry *nextCmd = &script->commands[cmd->param8];
+ ScriptEntry *nextCmd = &_currentScript->commands[cmd->param8];
if (nextCmd->opcode != 0x10 && nextCmd->opcode)
- scn->actions()->done = true;
+ _done = true;
else
- scn->actions()->lineIncrement = cmd->param8;
+ _lineIncrement = cmd->param8;
- return -1;
+ error("Incomplete opcode %s (0x%02X) in Scene %d Line %d", _actions[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
}
-int k_unk56(Script *script, ScriptEntry *cmd, Scene *scn) {
- return -2;
+//////////////////////////////////////////////////////////////////////////
+// Opcode 0x56
+IMPLEMENT_OPCODE(_unk56) {
+ error("Unhandled opcode %s (0x%02X) in Scene %d Line %d", _actions[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
}
-int kSetResourcePalette(Script *script, ScriptEntry *cmd, Scene *scn) {
+//////////////////////////////////////////////////////////////////////////
+// Opcode 0x57
+IMPLEMENT_OPCODE(SetResourcePalette) {
if (cmd->param1 > 0)
- scn->vm()->screen()->setPalette(scn->getResourcePack(), scn->worldstats()->grResId[cmd->param1]);
-
- return 0;
+ _scene->vm()->screen()->setPalette(_scene->getResourcePack(), _scene->worldstats()->grResId[cmd->param1]);
}
-int kSetBarrierFrameIdxFlaged(Script *script, ScriptEntry *cmd, Scene *scn) {
- Barrier *barrier = scn->worldstats()->getBarrierById(cmd->param1);
+//////////////////////////////////////////////////////////////////////////
+// Opcode 0x58
+IMPLEMENT_OPCODE(SetBarrierFrameIdxFlaged) {
+ Barrier *barrier = _scene->worldstats()->getBarrierById(cmd->param1);
if (cmd->param3)
barrier->flags = 1 | barrier->flags;
@@ -1093,72 +1215,93 @@ int kSetBarrierFrameIdxFlaged(Script *script, ScriptEntry *cmd, Scene *scn) {
barrier->flags = barrier->flags & 0xFFFFFFFE;
barrier->frameIdx = cmd->param2;
-
- return 0;
}
-int k_unk59(Script *script, ScriptEntry *cmd, Scene *scn) {
- return -2;
+//////////////////////////////////////////////////////////////////////////
+// Opcode 0x59
+IMPLEMENT_OPCODE(_unk59) {
+ error("Unhandled opcode %s (0x%02X) in Scene %d Line %d", _actions[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
}
-int k_unk5A(Script *script, ScriptEntry *cmd, Scene *scn) {
- return -2;
+
+//////////////////////////////////////////////////////////////////////////
+// Opcode 0x5A
+IMPLEMENT_OPCODE(_unk5A) {
+ error("Unhandled opcode %s (0x%02X) in Scene %d Line %d", _actions[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
}
-int k_unk5B(Script *script, ScriptEntry *cmd, Scene *scn) {
- return -2;
+
+//////////////////////////////////////////////////////////////////////////
+// Opcode 0x5B
+IMPLEMENT_OPCODE(_unk5B) {
+ error("Unhandled opcode %s (0x%02X) in Scene %d Line %d", _actions[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
}
-int k_unk5C(Script *script, ScriptEntry *cmd, Scene *scn) {
- return -2;
+
+//////////////////////////////////////////////////////////////////////////
+// Opcode 0x5C
+IMPLEMENT_OPCODE(_unk5C) {
+ error("Unhandled opcode %s (0x%02X) in Scene %d Line %d", _actions[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
}
-int k_unk5D(Script *script, ScriptEntry *cmd, Scene *scn) {
- return -2;
+
+//////////////////////////////////////////////////////////////////////////
+// Opcode 0x5D
+IMPLEMENT_OPCODE(_unk5D) {
+ error("Unhandled opcode %s (0x%02X) in Scene %d Line %d", _actions[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
}
-int kClearActorField970(Script *script, ScriptEntry *cmd, Scene *scn) {
- Actor *act = scn->getActor(cmd->param1);
+//////////////////////////////////////////////////////////////////////////
+// Opcode 0x5E
+IMPLEMENT_OPCODE(ClearActorField970) {
+ Actor *act = _scene->getActor(cmd->param1);
act->field_970 = 0;
-
- return 0;
}
-int kSetBarrierLastFrameIdx(Script *script, ScriptEntry *cmd, Scene *scn) {
- Barrier *barrier = scn->worldstats()->getBarrierById(cmd->param1);
+//////////////////////////////////////////////////////////////////////////
+// Opcode 0x5F
+IMPLEMENT_OPCODE(SetBarrierLastFrameIdx) {
+ Barrier *barrier = _scene->worldstats()->getBarrierById(cmd->param1);
if (barrier->frameIdx == barrier->frameCount - 1) {
- scn->actions()->lineIncrement = 0;
+ _lineIncrement = 0;
barrier->flags &= 0xFFFEF1C7;
} else {
- scn->actions()->lineIncrement = 1;
+ _lineIncrement = 1;
}
-
- return 0;
}
-int k_unk60_SET_OR_CLR_ACTIONAREA_FLAG(Script *script, ScriptEntry *cmd, Scene *scn) {
- return -2;
+//////////////////////////////////////////////////////////////////////////
+// Opcode 0x60
+IMPLEMENT_OPCODE(_unk60_SET_OR_CLR_ACTIONAREA_FLAG) {
+ error("Unhandled opcode %s (0x%02X) in Scene %d Line %d", _actions[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
}
-int k_unk61(Script *script, ScriptEntry *cmd, Scene *scn) {
+//////////////////////////////////////////////////////////////////////////
+// Opcode 0x61
+IMPLEMENT_OPCODE(_unk61) {
if (cmd->param2) {
- if (scn->worldstats()->field_E860C == -1) {
- scn->actions()->lineIncrement = 0;
+ if (_scene->worldstats()->field_E860C == -1) {
+ _lineIncrement = 0;
cmd->param2 = 0;
} else {
- scn->actions()->lineIncrement = 1;
+ _lineIncrement = 1;
}
} else {
// TODO: do something for scene number 9
cmd->param2 = 1;
- scn->actions()->lineIncrement = 1;
+ _lineIncrement = 1;
}
- return -1;
+ error("Incomplete opcode %s (0x%02X) in Scene %d Line %d", _actions[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
}
-int k_unk62_SHOW_OPTIONS_SCREEN(Script *script, ScriptEntry *cmd, Scene *scn) {
- return -2;
+//////////////////////////////////////////////////////////////////////////
+// Opcode 0x62
+IMPLEMENT_OPCODE(_unk62_SHOW_OPTIONS_SCREEN) {
+ error("Unhandled opcode %s (0x%02X) in Scene %d Line %d", _actions[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
}
-int k_unk63(Script *script, ScriptEntry *cmd, Scene *scn) {
- return -2;
+
+//////////////////////////////////////////////////////////////////////////
+// Opcode 0x63
+IMPLEMENT_OPCODE(_unk63) {
+ error("Unhandled opcode %s (0x%02X) in Scene %d Line %d", _actions[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
}
} // end of namespace Asylum
diff --git a/engines/asylum/resources/actionlist.h b/engines/asylum/resources/actionlist.h
index 481c21c33f..a4a5b04349 100644
--- a/engines/asylum/resources/actionlist.h
+++ b/engines/asylum/resources/actionlist.h
@@ -23,201 +23,229 @@
*
*/
-#ifndef ASYLUM_ACTIONLIST_H_
-#define ASYLUM_ACTIONLIST_H_
+#ifndef ASYLUM_ACTIONLIST_H
+#define ASYLUM_ACTIONLIST_H
+
+#include "asylum/views/scene.h"
#include "common/array.h"
+#include "common/func.h"
#include "common/stack.h"
#include "common/stream.h"
-#include "asylum/views/scene.h"
-
namespace Asylum {
#define MAX_ACTION_COMMANDS 161
-class Scene;
+#define DECLARE_OPCODE(name) \
+ void k##name(ScriptEntry *cmd)
+
+#define IMPLEMENT_OPCODE(name) \
+ void ActionList::k##name(ScriptEntry *cmd)
-typedef struct ScriptEntry {
- int32 numLines; // Only set on the first line of each script
- int32 opcode;
- int32 param1;
- int32 param2;
- int32 param3;
- int32 param4;
- int32 param5;
- int32 param6;
- int32 param7;
- int32 param8;
- int32 param9;
-
-} ScriptEntry;
-
-typedef struct Script {
- ScriptEntry commands[MAX_ACTION_COMMANDS];
- int32 field_1BAC;
- int32 field_1BB0;
- int32 counter;
-} Script;
-
-typedef struct ScriptQueueEntry {
- int32 actionListIndex;
- int32 actorIndex;
-} ScriptQueueEntry;
+#define ADD_OPCODE(name) { \
+ Opcode *func = new Opcode(#name, new Common::Functor1Mem<ScriptEntry *, void, ActionList>(this, &ActionList::k##name)); \
+ _actions.push_back(func); \
+}
+
+class Scene;
class ActionList {
public:
ActionList(Common::SeekableReadStream *stream, Scene *scene);
virtual ~ActionList();
- int32 size;
- int32 numEntries;
-
- Common::Array<Script> entries;
-
- // FIXME
- // Made all the internal control variables public and removed the getter/setter
- // pairs for simplicity. This should be refactored later, once the function mapping
- // is cleaned up properly
- int32 currentLine;
- int32 currentLoops;
- int32 delayedSceneIndex;
- int32 delayedVideoIndex;
- bool allowInput;
- int32 lineIncrement;
- bool done;
- bool waitCycle;
-
- /** .text:00402120
+ /**
* Process the current script
*/
- int32 process();
- /** .text:00401020
- * Reset the _scripts entries to their default values
- */
- void resetQueue();
- /** .text:00401050
+ bool process();
+
+ /**
* Initialize the script element at actionIndex to
* the actor at actorIndex
*/
void queueScript(int32 actionIndex, int32 actorIndex);
- /**
- * Toggle the action queue processing flag
- */
- void setActionFlag(bool value) { _actionFlag = value; }
+
+ // Accessors
+ bool doesAllowInput() { return _allowInput; }
+ int32 getDelayedVideoIndex() const { return _delayedVideoIndex; }
+ void setDelayedVideoIndex(int32 val) { _delayedVideoIndex = val; }
+ int32 getDelayedSceneIndex() const { return _delayedSceneIndex; }
+ void setDelayedSceneIndex(int32 val) { _delayedSceneIndex = val; }
private:
+ typedef struct ScriptEntry {
+ int32 numLines; // Only set on the first line of each script
+ int32 opcode;
+ int32 param1;
+ int32 param2;
+ int32 param3;
+ int32 param4;
+ int32 param5;
+ int32 param6;
+ int32 param7;
+ int32 param8;
+ int32 param9;
+
+ } ScriptEntry;
+
+ typedef struct Script {
+ ScriptEntry commands[MAX_ACTION_COMMANDS];
+ int32 field_1BAC;
+ int32 field_1BB0;
+ int32 counter;
+ } Script;
+
+ typedef struct ScriptQueueEntry {
+ int32 actionListIndex;
+ int32 actorIndex;
+ } ScriptQueueEntry;
+
+ typedef Common::Functor1<ScriptEntry *, void> ActionFunctor;
+
+ struct Opcode {
+ const char *name;
+ ActionFunctor *func;
+
+ Opcode(const char* funcName, ActionFunctor *function) {
+ name = funcName;
+ func = function;
+ }
+
+ ~Opcode() {
+ delete func;
+ }
+ };
+
Scene *_scene;
- bool _actionFlag;
+
+ // Script data
+ Common::Array<Script> _entries;
Common::Stack<ScriptQueueEntry> _scripts;
- Script *_currentScript;
- ScriptQueueEntry _currentQueueEntry;
+ Common::Array<Opcode *> _actions;
+
+ bool _skipProcessing;
+ bool _allowInput;
+ int32 _currentLine;
+ int32 _currentLoops;
+ Script *_currentScript;
+ ScriptQueueEntry _currentQueueEntry;
+ int32 _delayedSceneIndex;
+ int32 _delayedVideoIndex;
+ bool _done;
+ int32 _lineIncrement;
+ bool _waitCycle;
+
+ /**
+ * Loads the script entries
+ *
+ * @param stream the script data stream
+ */
void load(Common::SeekableReadStream *stream);
-}; // end of class ActionList
+ // Opcode functions
+ DECLARE_OPCODE(Return);
+ DECLARE_OPCODE(SetGameFlag);
+ DECLARE_OPCODE(ClearGameFlag);
+ DECLARE_OPCODE(ToggleGameFlag);
+ DECLARE_OPCODE(JumpIfGameFlag);
+ DECLARE_OPCODE(HideCursor);
+ DECLARE_OPCODE(ShowCursor);
+ DECLARE_OPCODE(PlayAnimation);
+ DECLARE_OPCODE(MoveScenePosition);
+ DECLARE_OPCODE(HideActor);
+ DECLARE_OPCODE(ShowActor);
+ DECLARE_OPCODE(SetActorPosition);
+ DECLARE_OPCODE(SetSceneMotionStatus);
+ DECLARE_OPCODE(DisableActor);
+ DECLARE_OPCODE(EnableActor);
+ DECLARE_OPCODE(EnableBarriers);
+ DECLARE_OPCODE(DestroyBarrier);
+ DECLARE_OPCODE(_unk12_JMP_WALK_ACTOR);
+ DECLARE_OPCODE(_unk13_JMP_WALK_ACTOR);
+ DECLARE_OPCODE(_unk14_JMP_WALK_ACTOR);
+ DECLARE_OPCODE(_unk15);
+ DECLARE_OPCODE(ResetAnimation);
+ DECLARE_OPCODE(ClearFlag1Bit0);
+ DECLARE_OPCODE(_unk18_PLAY_SND);
+ DECLARE_OPCODE(JumpIfFlag2Bit0);
+ DECLARE_OPCODE(SetFlag2Bit0);
+ DECLARE_OPCODE(ClearFlag2Bit0);
+ DECLARE_OPCODE(JumpIfFlag2Bit2);
+ DECLARE_OPCODE(SetFlag2Bit2);
+ DECLARE_OPCODE(ClearFlag2Bit2);
+ DECLARE_OPCODE(JumpIfFlag2Bit1);
+ DECLARE_OPCODE(SetFlag2Bit1);
+ DECLARE_OPCODE(ClearFlag2Bit1);
+ DECLARE_OPCODE(_unk22);
+ DECLARE_OPCODE(_unk23);
+ DECLARE_OPCODE(_unk24);
+ DECLARE_OPCODE(RunEncounter);
+ DECLARE_OPCODE(JumpIfFlag2Bit4);
+ DECLARE_OPCODE(SetFlag2Bit4);
+ DECLARE_OPCODE(ClearFlag2Bit4);
+ DECLARE_OPCODE(SetActorField638);
+ DECLARE_OPCODE(JumpIfActorField638);
+ DECLARE_OPCODE(ChangeScene);
+ DECLARE_OPCODE(_unk2C_ActorSub);
+ DECLARE_OPCODE(PlayMovie);
+ DECLARE_OPCODE(StopAllBarriersSounds);
+ DECLARE_OPCODE(StopProcessing);
+ DECLARE_OPCODE(ResumeProcessing);
+ DECLARE_OPCODE(ResetSceneRect);
+ DECLARE_OPCODE(ChangeMusicById);
+ DECLARE_OPCODE(StopMusic);
+ DECLARE_OPCODE(_unk34_Status);
+ DECLARE_OPCODE(_unk35);
+ DECLARE_OPCODE(_unk36);
+ DECLARE_OPCODE(RunBlowUpPuzzle);
+ DECLARE_OPCODE(JumpIfFlag2Bit3);
+ DECLARE_OPCODE(SetFlag2Bit3);
+ DECLARE_OPCODE(ClearFlag2Bit3);
+ DECLARE_OPCODE(_unk3B_PALETTE_MOD);
+ DECLARE_OPCODE(_unk3C_CMP_VAL);
+ DECLARE_OPCODE(WaitUntilFramePlayed);
+ DECLARE_OPCODE(UpdateWideScreen);
+ DECLARE_OPCODE(_unk3F);
+ DECLARE_OPCODE(_unk40_SOUND);
+ DECLARE_OPCODE(PlaySpeech);
+ DECLARE_OPCODE(_unk42);
+ DECLARE_OPCODE(_unk43);
+ DECLARE_OPCODE(PaletteFade);
+ DECLARE_OPCODE(StartPaletteFadeThread);
+ DECLARE_OPCODE(_unk46);
+ DECLARE_OPCODE(ActorFaceObject);
+ DECLARE_OPCODE(_unk48_MATTE_01);
+ DECLARE_OPCODE(_unk49_MATTE_90);
+ DECLARE_OPCODE(JumpIfSoundPlaying);
+ DECLARE_OPCODE(ChangePlayerCharacterIndex);
+ DECLARE_OPCODE(ChangeActorField40);
+ DECLARE_OPCODE(StopSound);
+ DECLARE_OPCODE(_unk4E_RANDOM_COMMAND);
+ DECLARE_OPCODE(ClearScreen);
+ DECLARE_OPCODE(Quit);
+ DECLARE_OPCODE(JumpBarrierFrame);
+ DECLARE_OPCODE(_unk52);
+ DECLARE_OPCODE(_unk53);
+ DECLARE_OPCODE(_unk54_SET_ACTIONLIST_6EC);
+ DECLARE_OPCODE(_unk55);
+ DECLARE_OPCODE(_unk56);
+ DECLARE_OPCODE(SetResourcePalette);
+ DECLARE_OPCODE(SetBarrierFrameIdxFlaged);
+ DECLARE_OPCODE(_unk59);
+ DECLARE_OPCODE(_unk5A);
+ DECLARE_OPCODE(_unk5B);
+ DECLARE_OPCODE(_unk5C);
+ DECLARE_OPCODE(_unk5D);
+ DECLARE_OPCODE(ClearActorField970);
+ DECLARE_OPCODE(SetBarrierLastFrameIdx);
+ DECLARE_OPCODE(_unk60_SET_OR_CLR_ACTIONAREA_FLAG);
+ DECLARE_OPCODE(_unk61);
+ DECLARE_OPCODE(_unk62_SHOW_OPTIONS_SCREEN);
+ DECLARE_OPCODE(_unk63);
-// opcode functions
-int32 kReturn0(Script *script, ScriptEntry *cmd, Scene *scn);
-int32 kSetGameFlag(Script *script, ScriptEntry *cmd, Scene *scn);
-int32 kClearGameFlag(Script *script, ScriptEntry *cmd, Scene *scn);
-int32 kToggleGameFlag(Script *script, ScriptEntry *cmd, Scene *scn);
-int32 kJumpIfGameFlag(Script *script, ScriptEntry *cmd, Scene *scn);
-int32 kHideCursor(Script *script, ScriptEntry *cmd, Scene *scn);
-int32 kShowCursor(Script *script, ScriptEntry *cmd, Scene *scn);
-int32 kPlayAnimation(Script *script, ScriptEntry *cmd, Scene *scn);
-int32 kMoveScenePosition(Script *script, ScriptEntry *cmd, Scene *scn);
-int32 kHideActor(Script *script, ScriptEntry *cmd, Scene *scn);
-int32 kShowActor(Script *script, ScriptEntry *cmd, Scene *scn);
-int32 kSetActorPosition(Script *script, ScriptEntry *cmd, Scene *scn);
-int32 kSetSceneMotionStat(Script *script, ScriptEntry *cmd, Scene *scn);
-int32 kDisableActor(Script *script, ScriptEntry *cmd, Scene *scn);
-int32 kEnableActor(Script *script, ScriptEntry *cmd, Scene *scn);
-int32 kEnableBarriers(Script *script, ScriptEntry *cmd, Scene *scn);
-int32 kReturn(Script *script, ScriptEntry *cmd, Scene *scn);
-int32 kDestroyBarrier(Script *script, ScriptEntry *cmd, Scene *scn);
-int32 k_unk12_JMP_WALK_ACTOR(Script *script, ScriptEntry *cmd, Scene *scn);
-int32 k_unk13_JMP_WALK_ACTOR(Script *script, ScriptEntry *cmd, Scene *scn);
-int32 k_unk14_JMP_WALK_ACTOR(Script *script, ScriptEntry *cmd, Scene *scn);
-int32 k_unk15(Script *script, ScriptEntry *cmd, Scene *scn);
-int32 kResetAnimation(Script *script, ScriptEntry *cmd, Scene *scn);
-int32 kClearFlag1Bit0(Script *script, ScriptEntry *cmd, Scene *scn);
-int32 k_unk18_PLAY_SND(Script *script, ScriptEntry *cmd, Scene *scn);
-int32 kJumpIfFlag2Bit0(Script *script, ScriptEntry *cmd, Scene *scn);
-int32 kSetFlag2Bit0(Script *script, ScriptEntry *cmd, Scene *scn);
-int32 kClearFlag2Bit0(Script *script, ScriptEntry *cmd, Scene *scn);
-int32 kJumpIfFlag2Bit2(Script *script, ScriptEntry *cmd, Scene *scn);
-int32 kSetFlag2Bit2(Script *script, ScriptEntry *cmd, Scene *scn);
-int32 kClearFlag2Bit2(Script *script, ScriptEntry *cmd, Scene *scn);
-int32 kJumpIfFlag2Bit1(Script *script, ScriptEntry *cmd, Scene *scn);
-int32 kSetFlag2Bit1(Script *script, ScriptEntry *cmd, Scene *scn);
-int32 kClearFlag2Bit1(Script *script, ScriptEntry *cmd, Scene *scn);
-int32 k_unk22(Script *script, ScriptEntry *cmd, Scene *scn);
-int32 k_unk23(Script *script, ScriptEntry *cmd, Scene *scn);
-int32 k_unk24(Script *script, ScriptEntry *cmd, Scene *scn);
-int32 kRunEncounter(Script *script, ScriptEntry *cmd, Scene *scn);
-int32 kJumpIfFlag2Bit4(Script *script, ScriptEntry *cmd, Scene *scn);
-int32 kSetFlag2Bit4(Script *script, ScriptEntry *cmd, Scene *scn);
-int32 kClearFlag2Bit4(Script *script, ScriptEntry *cmd, Scene *scn);
-int32 kSetActorField638(Script *script, ScriptEntry *cmd, Scene *scn);
-int32 kJumpIfActorField638(Script *script, ScriptEntry *cmd, Scene *scn);
-int32 kChangeScene(Script *script, ScriptEntry *cmd, Scene *scn);
-int32 k_unk2C_ActorSub(Script *script, ScriptEntry *cmd, Scene *scn);
-int32 kPlayMovie(Script *script, ScriptEntry *cmd, Scene *scn);
-int32 kStopAllBarriersSounds(Script *script, ScriptEntry *cmd, Scene *scn);
-int32 kSetActionFlag(Script *script, ScriptEntry *cmd, Scene *scn);
-int32 kClearActionFlag(Script *script, ScriptEntry *cmd, Scene *scn);
-int32 kResetSceneRect(Script *script, ScriptEntry *cmd, Scene *scn);
-int32 kChangeMusicById(Script *script, ScriptEntry *cmd, Scene *scn);
-int32 kStopMusic(Script *script, ScriptEntry *cmd, Scene *scn);
-int32 k_unk34_Status(Script *script, ScriptEntry *cmd, Scene *scn);
-int32 k_unk35(Script *script, ScriptEntry *cmd, Scene *scn);
-int32 k_unk36(Script *script, ScriptEntry *cmd, Scene *scn);
-int32 kRunBlowUpPuzzle(Script *script, ScriptEntry *cmd, Scene *scn);
-int32 kJumpIfFlag2Bit3(Script *script, ScriptEntry *cmd, Scene *scn);
-int32 kSetFlag2Bit3(Script *script, ScriptEntry *cmd, Scene *scn);
-int32 kClearFlag2Bit3(Script *script, ScriptEntry *cmd, Scene *scn);
-int32 k_unk3B_PALETTE_MOD(Script *script, ScriptEntry *cmd, Scene *scn);
-int32 k_unk3C_CMP_VAL(Script *script, ScriptEntry *cmd, Scene *scn);
-int32 kWaitUntilFramePlayed(Script *script, ScriptEntry *cmd, Scene *scn);
-int32 kUpdateWideScreen(Script *script, ScriptEntry *cmd, Scene *scn);
-int32 k_unk3F(Script *script, ScriptEntry *cmd, Scene *scn);
-int32 k_unk40_SOUND(Script *script, ScriptEntry *cmd, Scene *scn);
-int32 kPlaySpeech(Script *script, ScriptEntry *cmd, Scene *scn);
-int32 k_unk42(Script *script, ScriptEntry *cmd, Scene *scn);
-int32 k_unk43(Script *script, ScriptEntry *cmd, Scene *scn);
-int32 kPaletteFade(Script *script, ScriptEntry *cmd, Scene *scn);
-int32 kStartPaletteFadeThread(Script *script, ScriptEntry *cmd, Scene *scn);
-int32 k_unk46(Script *script, ScriptEntry *cmd, Scene *scn);
-int32 kActorFaceObject(Script *script, ScriptEntry *cmd, Scene *scn);
-int32 k_unk48_MATTE_01(Script *script, ScriptEntry *cmd, Scene *scn);
-int32 k_unk49_MATTE_90(Script *script, ScriptEntry *cmd, Scene *scn);
-int32 kJumpIfSoundPlaying(Script *script, ScriptEntry *cmd, Scene *scn);
-int32 kChangePlayerCharacterIndex(Script *script, ScriptEntry *cmd, Scene *scn);
-int32 kChangeActorField40(Script *script, ScriptEntry *cmd, Scene *scn);
-int32 kStopSound(Script *script, ScriptEntry *cmd, Scene *scn);
-int32 k_unk4E_RANDOM_COMMAND(Script *script, ScriptEntry *cmd, Scene *scn);
-int32 kClearScreen(Script *script, ScriptEntry *cmd, Scene *scn);
-int32 kQuit(Script *script, ScriptEntry *cmd, Scene *scn);
-int32 kJumpBarrierFrame(Script *script, ScriptEntry *cmd, Scene *scn);
-int32 k_unk52(Script *script, ScriptEntry *cmd, Scene *scn);
-int32 k_unk53(Script *script, ScriptEntry *cmd, Scene *scn);
-int32 k_unk54_SET_ACTIONLIST_6EC(Script *script, ScriptEntry *cmd, Scene *scn);
-int32 k_unk55(Script *script, ScriptEntry *cmd, Scene *scn);
-int32 k_unk56(Script *script, ScriptEntry *cmd, Scene *scn);
-int32 kSetResourcePalette(Script *script, ScriptEntry *cmd, Scene *scn);
-int32 kSetBarrierFrameIdxFlaged(Script *script, ScriptEntry *cmd, Scene *scn);
-int32 k_unk59(Script *script, ScriptEntry *cmd, Scene *scn);
-int32 k_unk5A(Script *script, ScriptEntry *cmd, Scene *scn);
-int32 k_unk5B(Script *script, ScriptEntry *cmd, Scene *scn);
-int32 k_unk5C(Script *script, ScriptEntry *cmd, Scene *scn);
-int32 k_unk5D(Script *script, ScriptEntry *cmd, Scene *scn);
-int32 kClearActorField970(Script *script, ScriptEntry *cmd, Scene *scn);
-int32 kSetBarrierLastFrameIdx(Script *script, ScriptEntry *cmd, Scene *scn);
-int32 k_unk60_SET_OR_CLR_ACTIONAREA_FLAG(Script *script, ScriptEntry *cmd, Scene *scn);
-int32 k_unk61(Script *script, ScriptEntry *cmd, Scene *scn);
-int32 k_unk62_SHOW_OPTIONS_SCREEN(Script *script, ScriptEntry *cmd, Scene *scn);
-int32 k_unk63(Script *script, ScriptEntry *cmd, Scene *scn);
+}; // end of class ActionList
} // end of namespace Asylum
-#endif
+#endif // ASYLUM_ACTIONLIST_H
diff --git a/engines/asylum/views/scene.cpp b/engines/asylum/views/scene.cpp
index 27946fb875..2f9e180f3b 100644
--- a/engines/asylum/views/scene.cpp
+++ b/engines/asylum/views/scene.cpp
@@ -382,7 +382,7 @@ void Scene::enterScene() {
if (!_titleLoaded) {
_title = new SceneTitle(this);
// disable input polling
- _actions->allowInput = false;
+ _actions->_allowInput = false;
} else {
#endif
_vm->screen()->setPalette(_resPack, _ws->palette);
@@ -438,12 +438,12 @@ void Scene::handleEvent(Common::Event *event, bool doUpdate) {
break;
case Common::EVENT_LBUTTONUP:
- if (_actions->allowInput)
+ if (_actions->doesAllowInput())
_leftClick = true;
break;
case Common::EVENT_RBUTTONUP:
- if (_actions->allowInput) {
+ if (_actions->doesAllowInput()) {
// TODO This isn't always going to be the magnifying glass
// Should check the current pointer region to identify the type
// of cursor to use
@@ -453,13 +453,13 @@ void Scene::handleEvent(Common::Event *event, bool doUpdate) {
break;
case Common::EVENT_RBUTTONDOWN:
- if (_actions->allowInput)
+ if (_actions->doesAllowInput())
_rightButton = true;
break;
default:
break;
-
+
}
// FIXME just updating because a left click event
@@ -534,7 +534,7 @@ int Scene::updateScene() {
// Adjust Screen
startTick = _vm->getTick();
-
+
if (g_debugScrolling) { // DEBUG ScreenScrolling
debugScreenScrolling(_bgResource->getFrame(0));
} else {
Commit: 44b58d8437c7d687505ab6b5e5296782bd41add3
https://github.com/scummvm/scummvm/commit/44b58d8437c7d687505ab6b5e5296782bd41add3
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:05+02:00
Commit Message:
ASYLUM: Refactor Asylum engine class
- Properly register Debugger
- Change constructor to take an ADGameDescription* parameter
- Reduce header interdependencies
- Cleanup members variables and methods
- Add engine namespace description
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@460 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/asylum.cpp
engines/asylum/asylum.h
engines/asylum/console.cpp
engines/asylum/console.h
engines/asylum/detection.cpp
engines/asylum/resources/actionlist.cpp
engines/asylum/resources/actor.cpp
engines/asylum/system/screen.cpp
engines/asylum/system/video.cpp
engines/asylum/system/video.h
engines/asylum/views/menu.cpp
engines/asylum/views/scene.cpp
diff --git a/engines/asylum/asylum.cpp b/engines/asylum/asylum.cpp
index 13f5a7469d..fa78689d81 100644
--- a/engines/asylum/asylum.cpp
+++ b/engines/asylum/asylum.cpp
@@ -23,25 +23,37 @@
*
*/
+#include "asylum/asylum.h"
+
+#include "asylum/system/config.h"
+#include "asylum/system/screen.h"
+#include "asylum/system/sound.h"
+#include "asylum/system/text.h"
+
+#include "asylum/views/scene.h"
+#include "asylum/views/menu.h"
+
+#include "asylum/console.h"
+#include "asylum/respack.h"
+
#include "common/config-manager.h"
#include "common/debug-channels.h"
#include "common/events.h"
-#include "common/system.h"
-#include "common/file.h"
#include "common/EventRecorder.h"
-#include "engines/advancedDetector.h"
#include "engines/util.h"
-#include "asylum/asylum.h"
-#include "asylum/respack.h"
-#include "asylum/system/config.h"
-
namespace Asylum {
-AsylumEngine::AsylumEngine(OSystem *system, Common::Language language)
- : Engine(system) {
+AsylumEngine::AsylumEngine(OSystem *system, const ADGameDescription *gd) : Engine(system), _gameDescription(gd) {
+
+ // Add default search directories
+ const Common::FSNode gameDataDir(ConfMan.get("path"));
+ SearchMan.addSubDirectoryMatching(gameDataDir, "data");
+ SearchMan.addSubDirectoryMatching(gameDataDir, "vids");
+ SearchMan.addSubDirectoryMatching(gameDataDir, "music");
+ // Initialize custom debug levels
DebugMan.addDebugChannel(kDebugLevelMain, "Main", "Generic debug level");
DebugMan.addDebugChannel(kDebugLevelResources, "Resources", "Resources debugging");
DebugMan.addDebugChannel(kDebugLevelSprites, "Sprites", "Sprites debugging");
@@ -53,45 +65,35 @@ AsylumEngine::AsylumEngine(OSystem *system, Common::Language language)
DebugMan.addDebugChannel(kDebugLevelScene, "Scene", "Scene process and draw debugging");
DebugMan.addDebugChannel(kDebugLevelBarriers, "Barriers", "Debug Barrier Objects");
- const Common::FSNode gameDataDir(ConfMan.get("path"));
-
- SearchMan.addSubDirectoryMatching(gameDataDir, "data");
- SearchMan.addSubDirectoryMatching(gameDataDir, "vids");
- SearchMan.addSubDirectoryMatching(gameDataDir, "music");
-
+ // Initialize random number source
g_eventRec.registerRandomSource(_rnd, "asylum");
}
AsylumEngine::~AsylumEngine() {
- DebugMan.clearAllDebugChannels();
-
delete _console;
- delete _scene;
+ //delete _encounter;
delete _mainMenu;
- delete _video;
- delete _sound;
+ delete _scene;
delete _screen;
- //delete _encounter;
+ delete _sound;
delete _text;
-}
-
-Common::Error AsylumEngine::run() {
- Common::Error err;
- err = init();
- if (err != Common::kNoError)
- return err;
+ delete _video;
- return go();
+ // Zero passed pointers
+ _gameDescription = NULL;
}
-// Will do the same as subroutine at address 0041A500
-Common::Error AsylumEngine::init() {
+Common::Error AsylumEngine::run() {
+ // Initialize the graphics
initGraphics(640, 480, true);
+ // Create debugger. It requires GFX to be initialized
+ _console = new Console(this);
+
+ // Create all manager classes
_screen = new Screen(this);
_sound = new Sound(_mixer);
_video = new Video(_mixer);
- _console = new Console(this);
_text = new Text(_screen);
_mainMenu = 0;
_scene = 0;
@@ -105,10 +107,7 @@ Common::Error AsylumEngine::init() {
memset(_gameFlags, 0, 1512);
- return Common::kNoError;
-}
-
-Common::Error AsylumEngine::go() {
+ // Start the game
g_system->showMouse(true);
// TODO: save dialogue key codes into sntrm_k.txt (need to figure out why they use such thing) (address 00411CD0)
@@ -131,7 +130,7 @@ Common::Error AsylumEngine::go() {
//}
while (!shouldQuit()) {
- checkForEvent(true);
+ handleEvents(true);
waitForTimer(55);
}
@@ -142,7 +141,7 @@ void AsylumEngine::waitForTimer(int msec_delay) {
uint32 start_time = _system->getMillis();
while (_system->getMillis() < start_time + msec_delay) {
- checkForEvent(false);
+ handleEvents(false);
if (_scene) {
processDelayedEvents();
}
@@ -152,10 +151,8 @@ void AsylumEngine::waitForTimer(int msec_delay) {
void AsylumEngine::startGame() {
// TODO: reset what need to be reset for a new game
-
- if (_scene) {
+ if (_scene)
delete _scene;
- }
_scene = new Scene(5, this);
@@ -201,7 +198,13 @@ void AsylumEngine::playIntro() {
_sound->playSound(0x80120007, false, Config.sfxVolume, 0);
}
-void AsylumEngine::checkForEvent(bool doUpdate) { // k_sub_40AE30 (0040AE30)
+void AsylumEngine::handleEvents(bool doUpdate) { // k_sub_40AE30 (0040AE30)
+ // Make sure the debugger is present
+ if (!_console)
+ error("AsylumEngine::handleEvents: called before the required subsystems have been initialized!");
+
+ // Show the debugger if required
+ _console->onFrame();
// NOTE
// In the original version of Sanitarium, the control loop for the sound
@@ -230,8 +233,15 @@ void AsylumEngine::checkForEvent(bool doUpdate) { // k_sub_40AE30 (0040AE30)
Common::Event ev;
- if (_system->getEventManager()->pollEvent(ev)) {
- if (ev.type == Common::EVENT_KEYDOWN) {
+ if (_eventMan->pollEvent(ev)) {
+ switch (ev.type) {
+ default:
+ break;
+
+ case Common::EVENT_KEYDOWN:
+ if ((ev.kbd.flags & Common::KBD_CTRL) && ev.kbd.keycode == Common::KEYCODE_d)
+ _console->attach();
+
if (ev.kbd.keycode == Common::KEYCODE_ESCAPE) {
// Toggle menu
if (_mainMenu->isActive()) {
@@ -259,11 +269,7 @@ void AsylumEngine::checkForEvent(bool doUpdate) { // k_sub_40AE30 (0040AE30)
}
}
*/
- if (ev.kbd.flags == Common::KBD_CTRL) {
- if (ev.kbd.keycode == Common::KEYCODE_d)
- _console->attach();
- }
-
+ break;
}
}
@@ -272,9 +278,6 @@ void AsylumEngine::checkForEvent(bool doUpdate) { // k_sub_40AE30 (0040AE30)
(_scene && _scene->isActive())) //|| (_scene && _scene->getBlowUpPuzzle()->isActive()))
// Copy background image
_screen->copyBackBufferToScreen();
-
- if (_console->isActive())
- _console->onFrame();
}
@@ -300,7 +303,6 @@ void AsylumEngine::processDelayedEvents() {
_video->playVideo(videoIdx, kSubtitlesOn);
_scene->actions()->setDelayedVideoIndex(-1);
-
if (_mainMenu->isActive())
_mainMenu->openMenu();
else if (_scene->isActive())
@@ -325,6 +327,9 @@ void AsylumEngine::processDelayedEvents() {
}
}
+//////////////////////////////////////////////////////////////////////////
+// Game flags
+//////////////////////////////////////////////////////////////////////////
void AsylumEngine::setGameFlag(int flag) {
_gameFlags[flag / 32] |= 1 << flag % -32;
}
@@ -345,5 +350,4 @@ bool AsylumEngine::isGameFlagNotSet(int flag) {
return ((1 << flag % -32) & (unsigned int)_gameFlags[flag / 32]) >> flag % -32 == 0;
}
-
} // namespace Asylum
diff --git a/engines/asylum/asylum.h b/engines/asylum/asylum.h
index 6a9e627fa7..4d25670451 100644
--- a/engines/asylum/asylum.h
+++ b/engines/asylum/asylum.h
@@ -26,21 +26,35 @@
#ifndef ASYLUM_ENGINE_H
#define ASYLUM_ENGINE_H
+#include "asylum/console.h"
+
#include "common/random.h"
+#include "common/scummsys.h"
+#include "common/system.h"
+#include "engines/advancedDetector.h"
#include "engines/engine.h"
-#include "asylum/staticres.h"
-#include "asylum/console.h"
-#include "asylum/views/scene.h"
-#include "asylum/views/menu.h"
-#include "asylum/system/screen.h"
-#include "asylum/system/sound.h"
-#include "asylum/system/video.h"
-//#include "asylum/blowuppuzzle.h"
-//#include "asylum/encounters.h"
-#include "asylum/system/text.h"
-
+/**
+ * This is the namespace of the Asylum engine.
+ *
+ * Status of this engine:
+ * - Code for scrolling and showing up objects and actors (properly clipped) is present
+ * - A preliminary script interpreter is implemented, and game scripts are read and partially parsed,
+ * actors are now drawn in the scene, and there is some interaction with the environment (e.g. "examine" actions).
+ * - Movie code is almost complete
+ * - Scene information is partially read, and the scene hotspots are created correctly.
+ * - Mouse cursor is initialized and animated properly
+ * - Game texts and game fonts are read correctly
+ * - Preliminary code for walking around with the mouse.
+ * - Some of the menu screens are working (like, for example, the credits screen)
+ *
+ * Maintainers:
+ * alexbevi, alexandrefontoura, bluegr
+ *
+ * Supported games:
+ * - Sanitarium
+ */
namespace Asylum {
// XXX
@@ -65,57 +79,31 @@ namespace Asylum {
#define LOBYTE(word) ((word >> 24) & 0xFF)
#endif
-class Console;
-class Scene;
+class Encounter;
class MainMenu;
class Scene;
class Screen;
class Sound;
+class Text;
class Video;
-class Encounter;
-
-enum kDebugLevels {
- kDebugLevelMain = 1 << 0,
- kDebugLevelResources = 1 << 1,
- kDebugLevelSprites = 1 << 2,
- kDebugLevelInput = 1 << 3,
- kDebugLevelMenu = 1 << 4,
- kDebugLevelScripts = 1 << 5,
- kDebugLevelSound = 1 << 6,
- kDebugLevelSavegame = 1 << 7,
- kDebugLevelScene = 1 << 8,
- kDebugLevelBarriers = 1 << 9
-};
class AsylumEngine: public Engine {
-public:
-
- AsylumEngine(OSystem *system, Common::Language language);
- virtual ~AsylumEngine();
-
- /** .text:0040F430
- * Initalize the game environment
- */
- Common::Error init();
-
- /** .text:0041A500
- * Start the game environment
- */
- Common::Error go();
+protected:
+ // Engine APIs
virtual Common::Error run();
+ virtual void errorString(const char *buf_input, char *buf_output, int buf_output_size);
virtual bool hasFeature(EngineFeature f) const;
+ virtual GUI::Debugger *getDebugger() { return _console; }
+
+public:
+ AsylumEngine(OSystem *system, const ADGameDescription *gd);
+ virtual ~AsylumEngine();
- /** .text:00415830
+ /**
* Start a new the game
*/
void startGame();
- void setGameFlag(int flag);
- void clearGameFlag(int flag);
- void toggleGameFlag(int flag);
- bool isGameFlagSet(int flag);
- bool isGameFlagNotSet(int flag);
-
/**
* Wrapper function to the OSystem getMillis() method
*/
@@ -128,40 +116,53 @@ public:
*/
uint32 tempTick07;
- Video* video() { return _video; }
- Sound* sound() { return _sound; }
+ // Game
+ Video* video() { return _video; }
+ Sound* sound() { return _sound; }
Screen* screen() { return _screen; }
- Scene* scene() { return _scene;}
- Text* text() { return _text; }
+ Scene* scene() { return _scene;}
+ Text* text() { return _text; }
- Common::RandomSource _rnd;
-
-private:
- void checkForEvent(bool doUpdate);
- void waitForTimer(int msec_delay);
- void updateMouseCursor();
- void processDelayedEvents();
+ // Flags
+ void setGameFlag(int flag);
+ void clearGameFlag(int flag);
+ void toggleGameFlag(int flag);
+ bool isGameFlagSet(int flag);
+ bool isGameFlagNotSet(int flag);
- /** .text:0041B630
- * Start a new the game
- */
- void playIntro();
+ // Misc
+ uint getRandom(uint max) { return _rnd.getRandomNumber(max); }
+ uint getRandomBit() { return _rnd.getRandomBit(); }
- Common::Language _language;
+private:
+ const ADGameDescription *_gameDescription;
- bool _introPlaying;
+ // Misc
+ Console *_console;
+ Common::RandomSource _rnd;
- Console *_console;
- Scene *_scene;
+ // Game
+ //Encounter *_encounter;
MainMenu *_mainMenu;
+ Scene *_scene;
Screen *_screen;
Sound *_sound;
- Video *_video;
Text *_text;
- //Encounter *_encounter;
+ Video *_video;
+ bool _introPlaying;
int _gameFlags[1512];
+ void handleEvents(bool doUpdate);
+ void waitForTimer(int msec_delay);
+ void updateMouseCursor();
+ void processDelayedEvents();
+
+ /**
+ * Play the intro
+ */
+ void playIntro();
+
friend class Console;
};
diff --git a/engines/asylum/console.cpp b/engines/asylum/console.cpp
index e6235ab6e9..19195c8e49 100644
--- a/engines/asylum/console.cpp
+++ b/engines/asylum/console.cpp
@@ -23,10 +23,15 @@
*
*/
-// Console module
+#include "asylum/console.h"
+
+#include "asylum/resources/actionarea.h"
+
+#include "asylum/views/scene.h"
#include "asylum/asylum.h"
-#include "asylum/console.h"
+
+#include "common/debug-channels.h"
namespace Asylum {
@@ -34,7 +39,7 @@ extern int32 g_debugPolygons;
extern int32 g_debugBarriers;
extern int32 g_debugScrolling;
-Console::Console(AsylumEngine *vm) : GUI::Debugger() {
+Console::Console(AsylumEngine *vm) {
_vm = vm;
DCmd_Register("video", WRAP_METHOD(Console, cmdPlayVideo));
@@ -50,6 +55,7 @@ Console::Console(AsylumEngine *vm) : GUI::Debugger() {
}
Console::~Console() {
+ DebugMan.clearAllDebugChannels();
}
bool Console::cmdDumpActionArea(int32 argc, const char **argv) {
diff --git a/engines/asylum/console.h b/engines/asylum/console.h
index 9df1a3445f..497e666214 100644
--- a/engines/asylum/console.h
+++ b/engines/asylum/console.h
@@ -32,6 +32,19 @@
namespace Asylum {
+enum kDebugLevels {
+ kDebugLevelMain = 1 << 0,
+ kDebugLevelResources = 1 << 1,
+ kDebugLevelSprites = 1 << 2,
+ kDebugLevelInput = 1 << 3,
+ kDebugLevelMenu = 1 << 4,
+ kDebugLevelScripts = 1 << 5,
+ kDebugLevelSound = 1 << 6,
+ kDebugLevelSavegame = 1 << 7,
+ kDebugLevelScene = 1 << 8,
+ kDebugLevelBarriers = 1 << 9
+};
+
class AsylumEngine;
class ActionArea;
diff --git a/engines/asylum/detection.cpp b/engines/asylum/detection.cpp
index 6be15e3155..27b04c88e5 100644
--- a/engines/asylum/detection.cpp
+++ b/engines/asylum/detection.cpp
@@ -152,9 +152,13 @@ bool Asylum::AsylumEngine::hasFeature(EngineFeature f) const {
(f == kSupportsSubtitleOptions);
}
+void Asylum::AsylumEngine::errorString(const char *buf_input, char *buf_output, int buf_output_size) {
+ snprintf(buf_output, (uint)buf_output_size, "%s", buf_input);
+}
+
bool AsylumMetaEngine::createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const {
if (desc) {
- *engine = new Asylum::AsylumEngine(syst, desc->language);
+ *engine = new Asylum::AsylumEngine(syst, desc);
}
return desc != 0;
}
diff --git a/engines/asylum/resources/actionlist.cpp b/engines/asylum/resources/actionlist.cpp
index e544c68849..25bb9e1afd 100644
--- a/engines/asylum/resources/actionlist.cpp
+++ b/engines/asylum/resources/actionlist.cpp
@@ -1155,7 +1155,7 @@ IMPLEMENT_OPCODE(_unk53) {
// Opcode 0x54
IMPLEMENT_OPCODE(_unk54_SET_ACTIONLIST_6EC) {
if (cmd->param2)
- _currentScript->field_1BB0 = _scene->vm()->_rnd.getRandomNumber(cmd->param1);
+ _currentScript->field_1BB0 = _scene->vm()->getRandom(cmd->param1);
else
_currentScript->field_1BB0 = cmd->param1;
}
diff --git a/engines/asylum/resources/actor.cpp b/engines/asylum/resources/actor.cpp
index 1069039f85..a153234db6 100644
--- a/engines/asylum/resources/actor.cpp
+++ b/engines/asylum/resources/actor.cpp
@@ -23,12 +23,16 @@
*
*/
-#include "common/endian.h"
-
#include "asylum/resources/actor.h"
+#include "asylum/resources/worldstats.h"
+
#include "asylum/system/screen.h"
#include "asylum/system/config.h"
+#include "asylum/staticres.h"
+
+#include "common/endian.h"
+
namespace Asylum {
Actor::Actor() {
diff --git a/engines/asylum/system/screen.cpp b/engines/asylum/system/screen.cpp
index a4b11ebcf3..dc340b8293 100644
--- a/engines/asylum/system/screen.cpp
+++ b/engines/asylum/system/screen.cpp
@@ -25,6 +25,8 @@
#include "asylum/system/screen.h"
+#include "asylum/resources/worldstats.h"
+
namespace Asylum {
Screen::Screen(AsylumEngine *vm) : _vm(vm) {
@@ -53,7 +55,7 @@ void Screen::copyToBackBuffer(byte *buffer, int32 pitch, int32 x, int32 y, int32
void Screen::copyToBackBufferWithTransparency(byte *buffer, int32 pitch, int32 x, int32 y, int32 width, int32 height) {
byte *dest = (byte *)_backBuffer.pixels;
-
+
int32 left = (x < 0) ? -x : 0;
int32 top = (y < 0) ? -y : 0;
int32 right = (x + width > 640) ? 640 - abs(x) : width;
@@ -74,12 +76,12 @@ void Screen::copyRectToScreen(byte *buffer, int32 pitch, int32 x, int32 y, int32
void Screen::copyRectToScreenWithTransparency(byte *buffer, int32 pitch, int32 x, int32 y, int32 width, int32 height) {
byte *screenBuffer = (byte *)_vm->_system->lockScreen()->pixels;
-
+
int32 left = (x < 0) ? -x : 0;
int32 top = (y < 0) ? -y : 0;
int32 right = (x + width > 640) ? 640 - abs(x) : width;
int32 bottom = (y + height > 480) ? 480 - abs(y) : height;
-
+
for (int32 curY = top; curY < bottom; curY++) {
for (int32 curX = left; curX < right; curX++) {
if (buffer[curX + curY * pitch] != 0) {
@@ -152,8 +154,8 @@ void Screen::drawGraphicsInQueue() {
for (uint32 i = 0; i < _queueItems.size(); i++) {
GraphicResource *grRes = _vm->scene()->getGraphicResource(_queueItems[i].resId);
- GraphicFrame *fra = grRes->getFrame(_queueItems[i].frameIdx);
-
+ GraphicFrame *fra = grRes->getFrame(_queueItems[i].frameIdx);
+
copyToBackBufferWithTransparency((byte *)fra->surface.pixels,
fra->surface.w,
_queueItems[i].x - ws->xLeft, _queueItems[i].y - ws->yTop,
diff --git a/engines/asylum/system/video.cpp b/engines/asylum/system/video.cpp
index cd91f0d487..b05b59bbf2 100644
--- a/engines/asylum/system/video.cpp
+++ b/engines/asylum/system/video.cpp
@@ -25,8 +25,13 @@
#include "asylum/system/video.h"
+#include "asylum/system//graphics.h"
+#include "asylum/system/text.h"
+
+#include "asylum/staticres.h"
+
namespace Asylum {
-
+
Video::Video(Audio::Mixer *mixer): _skipVideo(false) {
Common::Event stopEvent;
_stopEvents.clear();
@@ -35,7 +40,7 @@ Video::Video(Audio::Mixer *mixer): _skipVideo(false) {
_stopEvents.push_back(stopEvent);
_smkDecoder = new Graphics::SmackerDecoder(mixer);
-
+
_text = new VideoText();
ResourcePack *resPack = new ResourcePack(1);
_text->loadFont(resPack, 57); // video font
@@ -61,27 +66,27 @@ bool Video::playVideo(int32 videoNumber, VideoSubtitles subtitles) {
if(subtitles == kSubtitlesOn) {
loadSubtitles(videoNumber);
}
-
+
uint16 x = (g_system->getWidth() - _smkDecoder->getWidth()) / 2;
uint16 y = (g_system->getHeight() - _smkDecoder->getHeight()) / 2;
-
+
while (!_smkDecoder->endOfVideo() && !_skipVideo) {
processVideoEvents();
if (_smkDecoder->needsUpdate()) {
Graphics::Surface *frame = _smkDecoder->decodeNextFrame();
-
+
if (frame) {
g_system->copyRectToScreen((byte *)frame->pixels, frame->pitch, x, y, frame->w, frame->h);
-
+
if(subtitles) {
Graphics::Surface *screen = g_system->lockScreen();
performPostProcessing((byte *)screen->pixels);
g_system->unlockScreen();
}
-
+
if (_smkDecoder->hasDirtyPalette())
_smkDecoder->setSystemPalette();
-
+
g_system->updateScreen();
}
}
@@ -113,7 +118,7 @@ void Video::performPostProcessing(byte *screen) {
void Video::loadSubtitles(int32 videoNumber) {
// Read vids.cap
-
+
char movieToken[10];
sprintf(movieToken, "[MOV%03d]", videoNumber);
@@ -161,7 +166,7 @@ void Video::processVideoEvents() {
if (curEvent.type == Common::EVENT_RTL || curEvent.type == Common::EVENT_QUIT) {
_skipVideo = true;
}
-
+
for (Common::List<Common::Event>::const_iterator iter = _stopEvents.begin(); iter != _stopEvents.end(); ++iter) {
if (curEvent.type == iter->type) {
if (iter->type == Common::EVENT_KEYDOWN || iter->type == Common::EVENT_KEYUP) {
diff --git a/engines/asylum/system/video.h b/engines/asylum/system/video.h
index edb44e5328..fa33fe5b77 100644
--- a/engines/asylum/system/video.h
+++ b/engines/asylum/system/video.h
@@ -39,6 +39,10 @@
namespace Asylum {
+struct GraphicFrame;
+class GraphicResource;
+class ResourcePack;
+
struct VideoSubtitle {
int frameStart;
int frameEnd;
@@ -58,12 +62,12 @@ public:
virtual ~Video();
bool playVideo(int32 videoNumber, VideoSubtitles subtitles);
-
+
private:
void performPostProcessing(byte *screen);
void loadSubtitles(int32 videoNumber);
void processVideoEvents();
-
+
bool _skipVideo;
VideoText *_text;
Graphics::SmackerDecoder *_smkDecoder;
diff --git a/engines/asylum/views/menu.cpp b/engines/asylum/views/menu.cpp
index 7a283ca04c..b23e291934 100644
--- a/engines/asylum/views/menu.cpp
+++ b/engines/asylum/views/menu.cpp
@@ -23,11 +23,14 @@
*
*/
-#include "asylum/respack.h"
#include "asylum/views/menu.h"
+
#include "asylum/system/graphics.h"
#include "asylum/system/config.h"
+#include "asylum/respack.h"
+#include "asylum/staticres.h"
+
namespace Asylum {
MainMenu::MainMenu(AsylumEngine *vm): _vm(vm) {
@@ -639,7 +642,7 @@ void MainMenu::updateSubMenuReturnToGame() {
_vm->text()->drawResText(0x80000713);
// action
- if (_leftClick) {
+ if (_leftClick) {
// Main menu
if (_cursor->position().x >= 285 && _cursor->position().x <= 285 + _vm->text()->getResTextWidth(0x80000713) && _cursor->position().y >= 273 && _cursor->position().y <= 273 + 24)
exitSubMenu();
diff --git a/engines/asylum/views/scene.cpp b/engines/asylum/views/scene.cpp
index 2f9e180f3b..3be8b9a762 100644
--- a/engines/asylum/views/scene.cpp
+++ b/engines/asylum/views/scene.cpp
@@ -24,9 +24,13 @@
*/
#include "asylum/views/scene.h"
+
#include "asylum/resources/actor.h"
+
#include "asylum/system/config.h"
+#include "asylum/staticres.h"
+
namespace Asylum {
#define SCREEN_EDGES 40
@@ -275,7 +279,7 @@ void Scene::updateActorDirection(int actorIndex, int param) {
// active (via the global at .data:00543504)
// FIXME skipping for now
if (0) {
- if (vm()->_rnd.getRandomBit() == 1 && defaultActorDirectionLoaded(actorIndex, 15)) {
+ if (vm()->getRandomBit() == 1 && defaultActorDirectionLoaded(actorIndex, 15)) {
actor->frameNum = 0;
if (actor->direction > 4)
actor->direction = 8 - actor->direction;
@@ -1022,7 +1026,7 @@ void Scene::updateActor(int32 actorIdx) {
actor->frameNum = frameNum % actor->frameCount;
if (_vm->getTick() - actor->tickValue1 > 300) {
- if (vm()->_rnd.getRandomNumber(100) < 50) {
+ if (vm()->getRandom(100) < 50) {
// TODO: check sound playing
}
actor->tickValue1 = _vm->getTick();
@@ -1082,7 +1086,7 @@ void Scene::updateActorSub01(Actor *act) {
if (_vm->getTick() - act->tickValue1 > 300) {
// TODO
// Check if the actor's name is "Crow"?
- if (vm()->_rnd.getRandomNumber(100) < 50) {
+ if (vm()->getRandom(100) < 50) {
// TODO
// Check if soundResId04 is assigned, and if so,
// if it's playing
@@ -1098,7 +1102,7 @@ void Scene::updateActorSub01(Actor *act) {
if (act->visible()) {
// if some_encounter_flag
// if !soundResId04
- if (vm()->_rnd.getRandomNumber(100) < 50) {
+ if (vm()->getRandom(100) < 50) {
if (_sceneIdx == 13) {
; // sub414810(507)
} else {
@@ -1159,7 +1163,7 @@ void Scene::updateBarriers() {
int equalZero = frameIdx == 0;
if (!frameIdx) {
if (_vm->getTick() - barrier->tickCount >= 1000 * barrier->tickCount2) {
- if (vm()->_rnd.getRandomNumber(barrier->field_C0) == 1) {
+ if (vm()->getRandom(barrier->field_C0) == 1) {
if (barrier->field_68C[0]) {
// TODO: fix this, and find a better way to get frame count
// Sometimes we get wrong random resource id
@@ -1202,7 +1206,7 @@ void Scene::updateBarriers() {
}
} else if ((flag & 0xFF) & 8) { // check this
if (_vm->getTick() - barrier->tickCount >= 1000 * barrier->tickCount2) {
- if (vm()->_rnd.getRandomNumber(barrier->field_C0) == 1) { // TODO: THIS ISNT WORKING
+ if (vm()->getRandom(barrier->field_C0) == 1) { // TODO: THIS ISNT WORKING
barrier->frameIdx = (barrier->frameIdx + 1) % barrier->frameCount;
barrier->tickCount = _vm->getTick();
canPlaySound = true;
@@ -1324,12 +1328,12 @@ void Scene::updateAmbientSounds() {
}
if (loflag & 2) {
int tmpVol = volume;
- if (vm()->_rnd.getRandomNumber(10000) < 10) {
+ if (vm()->getRandom(10000) < 10) {
if (snd->field_0) {
_vm->sound()->playSound(snd->resId, false, volume, panning, false);
} else {
// FIXME will this even work?
- tmpVol += (vm()->_rnd.getRandomNumber(500)) * (((vm()->_rnd.getRandomNumber(100) >= 50) - 1) & 2) - 1;
+ tmpVol += (vm()->getRandom(500)) * (((vm()->getRandom(100) >= 50) - 1) & 2) - 1;
if (tmpVol <= -10000)
volume = -10000;
if (volume >= 0)
@@ -1337,7 +1341,7 @@ void Scene::updateAmbientSounds() {
else
if (tmpVol <= -10000)
tmpVol = -10000;
- _vm->sound()->playSound(snd->resId, 0, tmpVol, vm()->_rnd.getRandomNumber(20001) - 10000);
+ _vm->sound()->playSound(snd->resId, 0, tmpVol, vm()->getRandom(20001) - 10000);
}
}
} else {
Commit: 589fdc3196e5e872b9ba24ea365362882b1fba66
https://github.com/scummvm/scummvm/commit/589fdc3196e5e872b9ba24ea365362882b1fba66
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:05+02:00
Commit Message:
ASYLUM: Implement more opcodes logic
- Update PlayAnimation, Hide/Show/Enable/DisableActor, UpdateActorStatus
- Implement StopSound
- Add enums for actor members status & direction
- Move actor related methods from Scene to Actor
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@461 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/resources/actionlist.cpp
engines/asylum/resources/actionlist.h
engines/asylum/resources/actor.cpp
engines/asylum/resources/actor.h
engines/asylum/resources/barrier.cpp
engines/asylum/resources/worldstats.cpp
engines/asylum/views/scene.cpp
engines/asylum/views/scene.h
diff --git a/engines/asylum/resources/actionlist.cpp b/engines/asylum/resources/actionlist.cpp
index 25bb9e1afd..70f4467555 100644
--- a/engines/asylum/resources/actionlist.cpp
+++ b/engines/asylum/resources/actionlist.cpp
@@ -109,7 +109,7 @@ ActionList::ActionList(Common::SeekableReadStream *stream, Scene *scene)
ADD_OPCODE(_unk49_MATTE_90);
ADD_OPCODE(JumpIfSoundPlaying);
ADD_OPCODE(ChangePlayerCharacterIndex);
- ADD_OPCODE(ChangeActorField40);
+ ADD_OPCODE(ChangeActorStatus);
ADD_OPCODE(StopSound);
ADD_OPCODE(_unk4E_RANDOM_COMMAND);
ADD_OPCODE(ClearScreen);
@@ -340,48 +340,61 @@ IMPLEMENT_OPCODE(ShowCursor) {
//////////////////////////////////////////////////////////////////////////
// Opcode 0x07
IMPLEMENT_OPCODE(PlayAnimation) {
- int barrierId = cmd->param1;
- int barrierIndex = _scene->worldstats()->getBarrierIndexById(barrierId);
- Barrier *barrier = _scene->worldstats()->getBarrierByIndex(barrierIndex);
+ Barrier *barrier = _scene->worldstats()->getBarrierById(cmd->param1);
if (cmd->param2 == 2) {
- if (!barrier->checkFlags()) {
+ if (!barrier->checkFlags())
cmd->param2 = 1;
- }
+
_lineIncrement = 1;
+
+ return;
+ }
+
+ // Update flags
+ if (cmd->param4) {
+ barrier->flags &= 0xFFFEF1C7;
+ barrier->flags |= 0x20;
+ } else if (cmd->param3) {
+ barrier->flags &= 0xFFFEF1C7;
+ barrier->flags |= 0x10000;
+ // FIXME: This should be the correct code but this causes a regression
+ // Investigate barrier drawing to see if there is some wrong code there
+ //} else if (barrier->flags & 0x10000) {
+ // barrier->flags |= 8;
+ // barrier->flags &= 0xFFFEFFFF;
+ //} else if (!(barrier->flags & 0x10E38)) {
+ // barrier->flags |= 8;
+ //}
} else {
- if (cmd->param4) {
- barrier->flags &= 0xFFFEF1C7;
- barrier->flags |= 0x20;
- } else if (cmd->param3) {
- barrier->flags &= 0xFFFEF1C7;
- barrier->flags |= 0x10000;
- } else {
- barrier->flags &= 0x10000;
+ barrier->flags &= 0x10000;
+ if (barrier->flags == 0) {
+ barrier->flags &= 0x10E38;
if (barrier->flags == 0) {
- barrier->flags &= 0x10E38;
- if (barrier->flags == 0) {
- barrier->flags |= 8;
- }
- } else {
barrier->flags |= 8;
- barrier->flags &= 0xFFFEFFFF;
}
+ } else {
+ barrier->flags |= 8;
+ barrier->flags &= 0xFFFEFFFF;
}
+ }
- barrier->setNextFrame(barrier->flags);
+ barrier->setNextFrame(barrier->flags);
- if (barrier->field_688 == 1) {
+ if (barrier->field_688 == 1) {
+ if (barrier->flags & 4) {
+ _scene->setGlobalX(barrier->x);
+ _scene->setGlobalY(barrier->y);
+ } else {
// TODO: get barrier position
- }
-
- if (cmd->param2) {
- cmd->param2 = 2;
- _lineIncrement = 1;
+ error("Incomplete opcode %s (0x%02X) in Scene %d Line %d", _actions[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
}
}
- error("Incomplete opcode %s (0x%02X) in Scene %d Line %d", _actions[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
+ if (cmd->param2) {
+ cmd->param2 = 2;
+ _lineIncrement = 1;
+ }
}
//////////////////////////////////////////////////////////////////////////
@@ -443,38 +456,28 @@ IMPLEMENT_OPCODE(MoveScenePosition) {
//////////////////////////////////////////////////////////////////////////
// Opcode 0x09
IMPLEMENT_OPCODE(HideActor) {
- Actor *actor = 0;
- actor = (cmd->param1 == -1) ?
- _scene->getActor() :
- &_scene->worldstats()->actors[cmd->param1];
+ Actor *actor = (cmd->param1 == -1) ? _scene->getActor() : &_scene->worldstats()->actors[cmd->param1];
actor->visible(false);
- actor->updateActor_401320();
-
- error("Incomplete opcode %s (0x%02X) in Scene %d Line %d", _actions[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
+ actor->updateDirection();
}
//////////////////////////////////////////////////////////////////////////
// Opcode 0x0A
IMPLEMENT_OPCODE(ShowActor) {
- Actor *actor = 0;
-
- // TODO revisit when actor selection is cleaned up
- if (cmd->param1 == -1)
- actor = _scene->getActor();
- else
- actor = &_scene->worldstats()->actors[cmd->param1];
+ GET_ACTOR();
actor->visible(true);
- actor->updateActor_401320();
+ actor->updateDirection();
actor->tickValue1 = _scene->vm()->getTick();
}
//////////////////////////////////////////////////////////////////////////
// Opcode 0x0B
IMPLEMENT_OPCODE(SetActorPosition) {
- Actor *act = _scene->getActor(cmd->param1);
- act->setPosition(cmd->param2, cmd->param3, cmd->param4, cmd->param5);
+ Actor *actor = _scene->getActor(cmd->param1);
+
+ actor->setPosition(cmd->param2, cmd->param3, cmd->param4, cmd->param5);
}
//////////////////////////////////////////////////////////////////////////
@@ -486,54 +489,46 @@ IMPLEMENT_OPCODE(SetSceneMotionStatus) {
//////////////////////////////////////////////////////////////////////////
// Opcode 0x0D
IMPLEMENT_OPCODE(DisableActor) {
- int32 actorIndex = (cmd->param1 == -1) ? 0 : cmd->param1;
- Actor *act = _scene->getActor(actorIndex);
-
- if (cmd->param5 != 2) {
- if (act->updateType != 2 && act->updateType != 13) {
- if (cmd->param2 != -1 || cmd->param3 != -1)
- _scene->updateActorDirection(actorIndex, cmd->param4);
- else {
- if ((act->x1 + act->x2) != cmd->param2 ||
- (act->y1 + act->y2) != cmd->param3) {
- ; // TODO updatecharacter_sub_408910
- // TODO if (cmd->param5)
- // cmd->param5 = 2
- // v245 = true
- } else
- _scene->updateActorDirection(actorIndex, cmd->param4);
- }
- }
- error("Incomplete opcode %s (0x%02X) in Scene %d Line %d", _actions[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
- }
-
- if (act->updateType != 2 && act->updateType != 13) {
- cmd->param5 = 1;
- // v245 = false
- if ((act->x1 + act->x2) != cmd->param2 ||
- (act->y1 + act->y2) != cmd->param3) {
- _scene->updateActorDirection(actorIndex, cmd->param4);
- }
- }
- error("Incomplete opcode %s (0x%02X) in Scene %d Line %d", _actions[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
+ GET_ACTOR();
+
+ actor->updateStatus(kActorStatusDisabled);
+
+ //if (cmd->param5 != 2) {
+ // if (act->updateType != 2 && act->updateType != 13) {
+ // if (cmd->param2 != -1 || cmd->param3 != -1)
+ // _scene->updateActorDirection(actorIndex, cmd->param4);
+ // else {
+ // if ((act->x1 + act->x2) != cmd->param2 ||
+ // (act->y1 + act->y2) != cmd->param3) {
+ // ; // TODO updatecharacter_sub_408910
+ // // TODO if (cmd->param5)
+ // // cmd->param5 = 2
+ // // v245 = true
+ // } else
+ // _scene->updateActorDirection(actorIndex, cmd->param4);
+ // }
+ // }
+ // error("Incomplete opcode %s (0x%02X) in Scene %d Line %d", _actions[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
+ //}
+
+ //if (act->updateType != 2 && act->updateType != 13) {
+ // cmd->param5 = 1;
+ // // v245 = false
+ // if ((act->x1 + act->x2) != cmd->param2 ||
+ // (act->y1 + act->y2) != cmd->param3) {
+ // _scene->updateActorDirection(actorIndex, cmd->param4);
+ // }
+ //}
+ //error("Incomplete opcode %s (0x%02X) in Scene %d Line %d", _actions[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
}
//////////////////////////////////////////////////////////////////////////
// Opcode 0x0E
IMPLEMENT_OPCODE(EnableActor) {
- int actorIndex = 0;
-
- if (cmd->param1 == -1)
- ;//actorIndex = _scene->getWorldStats()->playerActor;
- else
- actorIndex = cmd->param1;
+ GET_ACTOR();
- /* TODO implement enableActorSub()
- if (_scene->worldstats()->actors[actorIndex].updateType == 5)
- enableActorSub(actorIndex, 4);
- */
-
- error("Incomplete opcode %s (0x%02X) in Scene %d Line %d", _actions[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
+ if (actor->status == kActorStatusDisabled)
+ actor->updateStatus(kActorStatusEnabled);
}
//////////////////////////////////////////////////////////////////////////
@@ -1069,25 +1064,22 @@ IMPLEMENT_OPCODE(ChangePlayerCharacterIndex) {
//////////////////////////////////////////////////////////////////////////
// Opcode 0x4C
-IMPLEMENT_OPCODE(ChangeActorField40) {
- // TODO: figure out what is this field and what values are set
- int actorIdx = cmd->param1;
- int fieldType = cmd->param2;
-
- if (fieldType) {
- if (_scene->worldstats()->actors[actorIdx].updateType < 11)
- _scene->worldstats()->actors[actorIdx].updateType = 14;
+IMPLEMENT_OPCODE(ChangeActorStatus) {
+ ActorIndex actorIdx = cmd->param1;
+
+ if (cmd->param2) {
+ if (_scene->worldstats()->actors[actorIdx].status < kActorStatus11)
+ _scene->worldstats()->actors[actorIdx].status = kActorStatus14;
} else {
- _scene->worldstats()->actors[actorIdx].updateType = 4;
+ _scene->worldstats()->actors[actorIdx].status = kActorStatusEnabled;
}
-
- error("Incomplete opcode %s (0x%02X) in Scene %d Line %d", _actions[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
}
//////////////////////////////////////////////////////////////////////////
// Opcode 0x4D
IMPLEMENT_OPCODE(StopSound) {
- error("Unhandled opcode %s (0x%02X) in Scene %d Line %d", _actions[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
+ if (_scene->vm()->sound()->isPlaying(cmd->param1))
+ _scene->vm()->sound()->stopSound(cmd->param1);
}
//////////////////////////////////////////////////////////////////////////
diff --git a/engines/asylum/resources/actionlist.h b/engines/asylum/resources/actionlist.h
index a4a5b04349..9860613a74 100644
--- a/engines/asylum/resources/actionlist.h
+++ b/engines/asylum/resources/actionlist.h
@@ -48,6 +48,9 @@ namespace Asylum {
_actions.push_back(func); \
}
+#define GET_ACTOR() \
+ Actor *actor = (cmd->param1 == -1) ? _scene->getActor() : &_scene->worldstats()->actors[cmd->param1];
+
class Scene;
class ActionList {
@@ -219,7 +222,7 @@ private:
DECLARE_OPCODE(_unk49_MATTE_90);
DECLARE_OPCODE(JumpIfSoundPlaying);
DECLARE_OPCODE(ChangePlayerCharacterIndex);
- DECLARE_OPCODE(ChangeActorField40);
+ DECLARE_OPCODE(ChangeActorStatus);
DECLARE_OPCODE(StopSound);
DECLARE_OPCODE(_unk4E_RANDOM_COMMAND);
DECLARE_OPCODE(ClearScreen);
diff --git a/engines/asylum/resources/actor.cpp b/engines/asylum/resources/actor.cpp
index a153234db6..e783f906ea 100644
--- a/engines/asylum/resources/actor.cpp
+++ b/engines/asylum/resources/actor.cpp
@@ -52,7 +52,8 @@ void Actor::visible(bool value) {
flags |= 0x01;
else
flags &= 0xFFFFFFFE;
- // TODO object_sound_sub_414c30
+
+ stopSound();
}
/*
@@ -275,6 +276,11 @@ void Actor::walkTo(int32 curX, int32 curY) {
drawActor();
}
+void Actor::stopSound() {
+ if (soundResId && _scene->vm()->sound()->isPlaying(soundResId))
+ _scene->vm()->sound()->stopSound(soundResId);
+}
+
void Actor::setPosition(int32 newX, int32 newY, int32 newDirection, int32 frame) {
x1 = newX - x2;
y1 = newY - y2;
@@ -432,14 +438,305 @@ int32 Actor::getAngle(int32 ax1, int32 ay1, int32 ax2, int32 ay2) {
return result;
}
-void Actor::updateActor_401320() {
+void Actor::updateDirection() {
if(field_970) {
// TODO
// This update is only ever done if action script 0x5D is called, and
// the resulting switch sets field_970. Investigate 401A30 for further
// details
- warning("[updateActor_401320] logic not implemented");
+ error("[Actor::updateDirection] logic not implemented");
+ }
+}
+
+void Actor::updateStatus(ActorStatus actorStatus) {
+ GraphicResource *gra;
+
+ switch (actorStatus) {
+ case kActorStatus16:
+ frameNum = 0;
+ if (direction > 4)
+ direction = 8 - direction;
+ grResId = grResTable[15];
+ gra = new GraphicResource(_resPack, grResId);
+ frameCount = gra->getFrameCount();
+ delete gra;
+ break;
+ case kActorStatus18:
+ if (_scene->worldstats()->numChapter > 2) {
+ frameNum = 0;
+ if (_index > 12)
+ grResId = grResTable[30];
+ if (_scene->getActorIndex() == _index) {
+ gra = new GraphicResource(_resPack, grResId);
+ frameNum = gra->getFrameCount() - 1;
+ delete gra;
+ }
+
+ if (_index == 11) {
+ // TODO check a global variable (that likely
+ // relates to direction) to see if it's > 4,
+ // and if so, subtract it from 8. Then use this
+ // to set actor[11].grResId
+ }
+
+ // FIXME I know this seems wasteful, but it's how the
+ // original worked. I guess this is to set the framecount
+ // regardless of the actorIndex value, though it assumes
+ // the actor's grResId has been set.
+ gra = new GraphicResource(_resPack, grResId);
+ frameCount = gra->getFrameCount();
+ delete gra;
+ }
+ break;
+ case kActorStatus15:
+ // TODO Refactor, because this is identical to case 16,
+ // other than a different grResTable index
+ frameNum = 0;
+ if (direction > 4)
+ direction = 8 - direction;
+ grResId = grResTable[10];
+ gra = new GraphicResource(_resPack, grResId);
+ frameCount = gra->getFrameCount();
+ delete gra;
+ break;
+ case kActorStatus9:
+ // TODO Check if there is an encounter currently
+ // active (via the global at .data:00543504)
+ // FIXME skipping for now
+ if (0) {
+ if (_scene->vm()->getRandomBit() == 1 && defaultDirectionLoaded(15)) {
+ frameNum = 0;
+ if (direction > 4)
+ direction = 8 - direction;
+ grResId = grResTable[15];
+ gra = new GraphicResource(_resPack, grResId);
+ frameCount = gra->getFrameCount();
+ delete gra;
+ } else {
+ frameNum = 0;
+ if (direction > 4)
+ direction = 8 - direction;
+ grResId = grResTable[10];
+ gra = new GraphicResource(_resPack, grResId);
+ frameCount = gra->getFrameCount();
+ delete gra;
+ }
+ }
+ break;
+ case kActorStatusEnabled:
+ case kActorStatus6:
+ case kActorStatus14:
+ frameNum = 0;
+ if (direction > 4)
+ direction = 8 - direction;
+ grResId = grResTable[15];
+ gra = new GraphicResource(_resPack, grResId);
+ frameCount = gra->getFrameCount();
+ delete gra;
+ break;
+ case kActorStatus1:
+ case kActorStatus12:
+ // TODO check if sceneNumber == 2 && actorIndex == _playerActorInde
+ // && field_40 equals/doesn't equal a bunch of values,
+ // then set direction like other cases
+ break;
+ case kActorStatus2:
+ case kActorStatus13:
+ frameNum = 0;
+ if (direction > 4)
+ direction = 8 - direction;
+ grResId = grResTable[direction];
+ gra = new GraphicResource(_resPack, grResId);
+ frameCount = gra->getFrameCount();
+ delete gra;
+ break;
+ case kActorStatusDisabled:
+ frameNum = 0;
+ if (direction > 4)
+ direction = 8 - direction;
+ grResId = grResTable[direction];
+ gra = new GraphicResource(_resPack, grResId);
+ frameCount = gra->getFrameCount();
+ delete gra;
+ // TODO set word_446EE4 to -1. This global seems to
+ // be used with screen blitting
+ break;
+ case kActorStatus3:
+ case kActorStatus19:
+ // TODO check if the actor's name is equal to
+ // "Big Crow"???
+ break;
+ case kActorStatus7:
+ if (_scene->worldstats()->numChapter == 2 && _index == 10 && _scene->vm()->isGameFlagSet(279)) {
+ Actor *act0 = _scene->getActor(0);
+ act0->x1 = x2 + x1 - act0->x2;
+ act0->y1 = y2 + y1 - act0->y2;
+ act0->direction = 4;
+ _scene->setActorIndex(0);
+ // TODO disableCharacterVisible(actorIndex)
+ // TODO enableActorVisible(0)
+ _scene->vm()->clearGameFlag(279);
+ // TODO some cursor update
+ }
+ break;
+ case kActorStatus8:
+ case kActorStatus10:
+ case kActorStatus17:
+ frameNum = 0;
+ if (direction > 4)
+ direction = 8 - direction;
+ grResId = grResTable[20];
+ gra = new GraphicResource(_resPack, grResId);
+ frameCount = gra->getFrameCount();
+ delete gra;
+ break;
+ }
+
+ status = actorStatus;
+}
+
+void Actor::setDirection(int actorDirection) {
+ direction = (actorDirection > 4) ? 8 - actorDirection : actorDirection;
+ int32 grResId;
+
+ if (field_944 != 5) {
+ switch (status) {
+ case 0x04:
+ case 0x05:
+ case 0x0E: {
+ grResId = grResTable[direction + 5];
+ // FIXME this seems kind of wasteful just to grab a frame count
+ GraphicResource *gra = new GraphicResource(_resPack, grResId);
+ grResId = grResId;
+ frameCount = gra->getFrameCount();
+ delete gra;
+ }
+ break;
+ case 0x12:
+ if (_scene->worldstats()->numChapter == 2) {
+ if (_scene->getActorIndex() == 11) {
+ // NOTE this is supposed to explicitely point to the actor 11 reference,
+ // (_ws->actors[11])
+ // but I'm assuming if control drops through to here, getActor() would
+ // pull the right object because the _playerActorIndex should == 11
+ if (direction > 4)
+ grResId = grResTable[8 - direction];
+ else
+ grResId = grResTable[direction];
+ }
+ }
+ break;
+ case 0x01:
+ case 0x02:
+ case 0x0C:
+ grResId = grResTable[direction];
+ break;
+ case 0x08:
+ grResId = grResTable[direction + 20];
+ break;
+ default:
+ warning ("[setActorDirection] default case hit with status of %d", status);
+ }
+ }
+}
+
+void Actor::update() {
+ if (visible()) {
+ // printf("Actor updateType = 0x%02X\n", actor->updateType);
+
+ switch (status) {
+
+ case 0x10:
+ if (_scene->worldstats()->numChapter == 2) {
+ // TODO: updateCharacterSub14()
+ } else if (_scene->worldstats()->numChapter == 1) {
+ if (_scene->getActorIndex() == _index) {
+ // TODO: updateActorSub21();
+ }
+ }
+ break;
+ case 0x11:
+ if (_scene->worldstats()->numChapter == 2) {
+ // TODO: put code here
+ } else if (_scene->worldstats()->numChapter == 11) {
+ if (_scene->getActorIndex() == _index) {
+ // TODO: put code here
+ }
+ }
+ break;
+ case 0xF:
+ if (_scene->worldstats()->numChapter == 2) {
+ // TODO: put code here
+ } else if (_scene->worldstats()->numChapter == 11) {
+ // TODO: put code here
+ }
+ break;
+ case 0x12:
+ if (_scene->worldstats()->numChapter == 2) {
+ // TODO: put code here
+ }
+ break;
+ case 0x5: {
+ frameNum = (frameNum + 1) % frameCount;
+
+ if (_scene->vm()->getTick() - tickValue1 > 300) {
+ if (_scene->vm()->getRandom(100) < 50) {
+ // TODO: check sound playing
+ }
+ tickValue1 = _scene->vm()->getTick();
+ }
+ }
+ break;
+ case 0xC:
+ if (_scene->worldstats()->numChapter == 2) {
+ // TODO: put code here
+ } else if (_scene->worldstats()->numChapter == 11) {
+ // TODO: put code here
+ }
+ case 0x1:
+ // TODO: do actor direction
+ break;
+ case 0x2:
+ case 0xD:
+ // TODO: do actor direction
+ break;
+ case 0x3:
+ case 0x13:
+ // TODO: updateCharacterSub05();
+ break;
+ case 0x7:
+ // TODO: something
+ break;
+ case 0x4:
+ if (field_944 != 5) {
+ //updateActorSub01(actor);
+ }
+ break;
+ case 0xE:
+ // TODO: updateCharacterSub02(1, actorIdx);
+ break;
+ case 0x15:
+ // TODO: updateCharacterSub06(1, actorIdx);
+ break;
+ case 0x9:
+ // TODO: updateCharacterSub03(1, actorIdx);
+ break;
+ case 0x6:
+ case 0xA:
+ frameNum = (frameNum + 1) % frameCount;
+ break;
+ case 0x8:
+ // TODO: actor sound
+ break;
+ default:
+ break;
+ }
}
}
+
+bool Actor::defaultDirectionLoaded(int grResTableIdx) {
+ return grResTable[grResTableIdx] != grResTable[5];
+}
+
} // end of namespace Asylum
diff --git a/engines/asylum/resources/actor.h b/engines/asylum/resources/actor.h
index 04ac008ca0..ae0465594b 100644
--- a/engines/asylum/resources/actor.h
+++ b/engines/asylum/resources/actor.h
@@ -23,18 +23,47 @@
*
*/
-#ifndef ASYLUM_ACTOR_H_
-#define ASYLUM_ACTOR_H_
+#ifndef ASYLUM_ACTOR_H
+#define ASYLUM_ACTOR_H
-#include "asylum/respack.h"
#include "asylum/system/graphics.h"
+#include "asylum/respack.h"
+
namespace Asylum {
class Scene;
class Screen;
class ActionArea;
+typedef int ActorIndex;
+
+enum ActorStatus {
+ kActorStatus1 = 1,
+ kActorStatus2,
+ kActorStatus3,
+ kActorStatusEnabled,
+ kActorStatusDisabled,
+ kActorStatus6,
+ kActorStatus7,
+ kActorStatus8,
+ kActorStatus9,
+ kActorStatus10,
+ kActorStatus11,
+ kActorStatus12,
+ kActorStatus13,
+ kActorStatus14,
+ kActorStatus15,
+ kActorStatus16,
+ kActorStatus17,
+ kActorStatus18,
+ kActorStatus19,
+ kActorStatus20,
+ kActorStatus21
+};
+
+typedef int ActorDirection;
+
// TODO: check if the names match the actor type
enum ActorType {
kMax = 0,
@@ -162,11 +191,17 @@ public:
void faceTarget(int32 targetId, int32 targetType);
+ void update();
+
/** .text:00401320
* TODO
*/
- void updateActor_401320();
+ void updateDirection();
+ void setDirection(ActorDirection direction);
+
+ void updateStatus(ActorStatus status);
+ bool defaultDirectionLoaded(int grResTableIdx);
// FIXME
// I don't really like how this is used in the scene constructor
@@ -186,6 +221,9 @@ public:
void drawActor();
void walkTo(int32 curX, int32 curY);
+
+ void stopSound();
+
int32 currentAction; // TODO depreciate
int32 x;
@@ -199,9 +237,9 @@ public:
int32 x2;
int32 y2;
Common::Rect boundingRect;
- int32 direction;
+ ActorDirection direction;
int32 field_3C;
- int32 updateType;
+ ActorStatus status;
int32 field_44;
int32 priority;
int32 flags;
@@ -267,6 +305,9 @@ private:
GraphicResource *_graphic;
ActionArea *_currentWalkArea;
+ // Our current index
+ ActorIndex _index;
+
GraphicFrame *getFrame();
int32 getAngle(int32 ax1, int32 ay1, int32 ax2, int32 ay2);
diff --git a/engines/asylum/resources/barrier.cpp b/engines/asylum/resources/barrier.cpp
index c405410354..4657ef121e 100644
--- a/engines/asylum/resources/barrier.cpp
+++ b/engines/asylum/resources/barrier.cpp
@@ -53,7 +53,7 @@ int32 Barrier::getRandomId() {
}
int32 Barrier::checkFlags() {
- return flags & 1 && (flags & 8 || flags & 0x10000);
+ return (flags & 1) && (flags & 8 || flags & 0x10000);
}
void Barrier::setNextFrame(int32 targetFlags) {
diff --git a/engines/asylum/resources/worldstats.cpp b/engines/asylum/resources/worldstats.cpp
index af2163bda5..3e0b5c5df1 100644
--- a/engines/asylum/resources/worldstats.cpp
+++ b/engines/asylum/resources/worldstats.cpp
@@ -318,7 +318,7 @@ void WorldStats::load(Common::SeekableReadStream *stream) {
actor.direction = stream->readSint32LE();
actor.field_3C = stream->readSint32LE();
- actor.updateType = stream->readSint32LE();
+ actor.status = (ActorStatus)stream->readSint32LE();
actor.field_44 = stream->readSint32LE();
actor.priority = stream->readSint32LE();
actor.flags = stream->readSint32LE();
diff --git a/engines/asylum/views/scene.cpp b/engines/asylum/views/scene.cpp
index 3be8b9a762..5ee744f834 100644
--- a/engines/asylum/views/scene.cpp
+++ b/engines/asylum/views/scene.cpp
@@ -98,6 +98,8 @@ Scene::Scene(uint8 sceneIdx, AsylumEngine *engine): _vm(engine) {
g_debugBarriers = 0;
g_debugScrolling = 0;
+ _globalX = _globalY = 0;
+
// TODO figure out what field_120 is used for
_ws->field_120 = -1;
@@ -145,14 +147,14 @@ void Scene::initialize() {
345 - actor->boundingRect.bottom);
actor->flags |= 1;
- updateActorDirection(_playerActorIdx, 4);
+ actor->updateStatus(kActorStatusEnabled);
if (_ws->numActors > 1) {
for (int32 a = 1; a < _ws->numActors; a++) {
Actor *act = &_ws->actors[a];
act->flags |= 1;
act->direction = 1;
- updateActorDirection(a, 4);
+ getActor(a)->updateStatus(kActorStatusEnabled);
act->x1 -= act->x2;
act->y1 -= act->y2;
act->boundingRect.bottom = act->y2;
@@ -182,7 +184,7 @@ void Scene::initialize() {
actor->tickValue1= _vm->getTick();
// XXX This initialization was already done earlier,
// so I'm not sure why we need to do it again. Investigate.
- updateActorDirectionDefault(_playerActorIdx);
+ actor->updateDirection();
if (_ws->numChapter == 9) {
// TODO changeActorIndex(1); .text:00405140
@@ -222,165 +224,6 @@ Actor* Scene::getActor(int index) {
return &_ws->actors[(index != -1) ? index : _playerActorIdx];
}
-void Scene::updateActorDirection(int actorIndex, int param) {
- Actor *actor = getActor(actorIndex);
- GraphicResource *gra;
-
- switch (param) {
- case 16:
- actor->frameNum = 0;
- if (actor->direction > 4)
- actor->direction = 8 - actor->direction;
- actor->grResId = actor->grResTable[15];
- gra = new GraphicResource(_resPack, actor->grResId);
- actor->frameCount = gra->getFrameCount();
- delete gra;
- break;
- case 18:
- if (_ws->numChapter > 2) {
- actor->frameNum = 0;
- if (actorIndex > 12)
- actor->grResId = actor->grResTable[30];
- if (_playerActorIdx == actorIndex) {
- gra = new GraphicResource(_resPack, actor->grResId);
- actor->frameNum = gra->getFrameCount() - 1;
- delete gra;
- }
-
- if (actorIndex == 11) {
- // TODO check a global variable (that likely
- // relates to direction) to see if it's > 4,
- // and if so, subtract it from 8. Then use this
- // to set actor[11].grResId
- }
-
- // FIXME I know this seems wasteful, but it's how the
- // original worked. I guess this is to set the framecount
- // regardless of the actorIndex value, though it assumes
- // the actor's grResId has been set.
- gra = new GraphicResource(_resPack, actor->grResId);
- actor->frameCount = gra->getFrameCount();
- delete gra;
- }
- break;
- case 15:
- // TODO Refactor, because this is identical to case 16,
- // other than a different grResTable index
- actor->frameNum = 0;
- if (actor->direction > 4)
- actor->direction = 8 - actor->direction;
- actor->grResId = actor->grResTable[10];
- gra = new GraphicResource(_resPack, actor->grResId);
- actor->frameCount = gra->getFrameCount();
- delete gra;
- break;
- case 9:
- // TODO Check if there is an encounter currently
- // active (via the global at .data:00543504)
- // FIXME skipping for now
- if (0) {
- if (vm()->getRandomBit() == 1 && defaultActorDirectionLoaded(actorIndex, 15)) {
- actor->frameNum = 0;
- if (actor->direction > 4)
- actor->direction = 8 - actor->direction;
- actor->grResId = actor->grResTable[15];
- gra = new GraphicResource(_resPack, actor->grResId);
- actor->frameCount = gra->getFrameCount();
- delete gra;
- } else {
- actor->frameNum = 0;
- if (actor->direction > 4)
- actor->direction = 8 - actor->direction;
- actor->grResId = actor->grResTable[10];
- gra = new GraphicResource(_resPack, actor->grResId);
- actor->frameCount = gra->getFrameCount();
- delete gra;
- }
- }
- break;
- case 4:
- case 6:
- case 14:
- actor->frameNum = 0;
- if (actor->direction > 4)
- actor->direction = 8 - actor->direction;
- actor->grResId = actor->grResTable[15];
- gra = new GraphicResource(_resPack, actor->grResId);
- actor->frameCount = gra->getFrameCount();
- delete gra;
- break;
- case 1:
- case 12:
- // TODO check if sceneNumber == 2 && actorIndex == _playerActorInde
- // && actor->field_40 equals/doesn't equal a bunch of values,
- // then set direction like other cases
- break;
- case 2:
- case 13:
- actor->frameNum = 0;
- if (actor->direction > 4)
- actor->direction = 8 - actor->direction;
- actor->grResId = actor->grResTable[actor->direction];
- gra = new GraphicResource(_resPack, actor->grResId);
- actor->frameCount = gra->getFrameCount();
- delete gra;
- break;
- case 5:
- actor->frameNum = 0;
- if (actor->direction > 4)
- actor->direction = 8 - actor->direction;
- actor->grResId = actor->grResTable[actor->direction];
- gra = new GraphicResource(_resPack, actor->grResId);
- actor->frameCount = gra->getFrameCount();
- delete gra;
- // TODO set word_446EE4 to -1. This global seems to
- // be used with screen blitting
- break;
- case 3:
- case 19:
- // TODO check if the actor's name is equal to
- // "Big Crow"???
- break;
- case 7:
- if (_ws->numChapter == 2 && actorIndex == 10 && _vm->isGameFlagSet(279)) {
- Actor *act0 = getActor(0);
- act0->x1 = actor->x2 + actor->x1 - act0->x2;
- act0->y1 = actor->y2 + actor->y1 - act0->y2;
- act0->direction = 4;
- _playerActorIdx = 0;
- // TODO disableCharacterVisible(actorIndex)
- // TODO enableActorVisible(0)
- _vm->clearGameFlag(279);
- // TODO some cursor update
- }
- break;
- case 8:
- case 10:
- case 17:
- actor->frameNum = 0;
- if (actor->direction > 4)
- actor->direction = 8 - actor->direction;
- actor->grResId = actor->grResTable[20];
- gra = new GraphicResource(_resPack, actor->grResId);
- actor->frameCount = gra->getFrameCount();
- delete gra;
- break;
- }
-
- actor->updateType = param;
-}
-
-void Scene::updateActorDirectionDefault(int actorIndex) {
- if (actorIndex == -1)
- actorIndex = _playerActorIdx;
- updateActorDirection(actorIndex, 4);
-}
-
-bool Scene::defaultActorDirectionLoaded(int actorIndex, int grResTableIdx) {
- Actor *actor = getActor(actorIndex);
- return actor->grResTable[grResTableIdx] != actor->grResTable[5];
-}
-
void Scene::enterScene() {
#ifdef SHOW_SCENE_LOADING
if (!_titleLoaded) {
@@ -513,28 +356,28 @@ int Scene::updateScene() {
// Mouse
startTick = _vm->getTick();
updateMouse();
- debugC(kDebugLevelScene, "UpdateMouse Time: %d", _vm->getTick() - startTick);
+ //debugC(kDebugLevelScene, "UpdateMouse Time: %d", _vm->getTick() - startTick);
// Actors
startTick = _vm->getTick();
for (int32 a = 0; a < _ws->numActors; a++)
- updateActor(a);
- debugC(kDebugLevelScene, "UpdateActors Time: %d", _vm->getTick() - startTick);
+ getActor(a)->update();
+ //debugC(kDebugLevelScene, "UpdateActors Time: %d", _vm->getTick() - startTick);
// Barriers
startTick = _vm->getTick();
updateBarriers();
- debugC(kDebugLevelScene, "UpdateBarriers Time: %d", _vm->getTick() - startTick);
+ //debugC(kDebugLevelScene, "UpdateBarriers Time: %d", _vm->getTick() - startTick);
// Ambient Sounds
startTick = _vm->getTick();
updateAmbientSounds();
- debugC(kDebugLevelScene, "UpdateAmbientSounds Time: %d", _vm->getTick() - startTick);
+ //debugC(kDebugLevelScene, "UpdateAmbientSounds Time: %d", _vm->getTick() - startTick);
// Music
startTick = _vm->getTick();
updateMusic();
- debugC(kDebugLevelScene, "UpdateMusic Time: %d", _vm->getTick() - startTick);
+ //debugC(kDebugLevelScene, "UpdateMusic Time: %d", _vm->getTick() - startTick);
// Adjust Screen
startTick = _vm->getTick();
@@ -544,7 +387,7 @@ int Scene::updateScene() {
} else {
updateAdjustScreen();
}
- debugC(kDebugLevelScene, "AdjustScreenStart Time: %d", _vm->getTick() - startTick);
+ //debugC(kDebugLevelScene, "AdjustScreenStart Time: %d", _vm->getTick() - startTick);
// Update Debug
if (g_debugPolygons)
@@ -702,53 +545,8 @@ void Scene::updateMouse() {
handleMouseUpdate(dir, actorPos);
if (dir >= 0) {
- if (act->updateType == 1 || act->updateType == 12)
- setActorDirection(act, dir);
- }
-}
-
-void Scene::setActorDirection(Actor *act, int direction) {
- act->direction = (direction > 4) ? 8 - direction : direction;
- int32 grResId;
-
- if (act->field_944 != 5) {
- switch (act->updateType) {
- case 0x04:
- case 0x05:
- case 0x0E: {
- grResId = act->grResTable[act->direction + 5];
- // FIXME this seems kind of wasteful just to grab a frame count
- GraphicResource *gra = new GraphicResource(_resPack, grResId);
- act->grResId = grResId;
- act->frameCount = gra->getFrameCount();
- delete gra;
- }
- break;
- case 0x12:
- if (_ws->numChapter == 2) {
- if (_playerActorIdx == 11) {
- // NOTE this is supposed to explicitely point to the actor 11 reference,
- // (_ws->actors[11])
- // but I'm assuming if control drops through to here, getActor() would
- // pull the right object because the _playerActorIndex should == 11
- if (act->direction > 4)
- act->grResId = act->grResTable[8 - act->direction];
- else
- act->grResId = act->grResTable[act->direction];
- }
- }
- break;
- case 0x01:
- case 0x02:
- case 0x0C:
- act->grResId = act->grResTable[act->direction];
- break;
- case 0x08:
- act->grResId = act->grResTable[act->direction + 20];
- break;
- default:
- warning ("[setActorDirection] default case hit with updateType of %d", act->updateType);
- }
+ if (act->status == 1 || act->status == 12)
+ act->setDirection(dir);
}
}
@@ -767,7 +565,7 @@ void Scene::handleMouseUpdate(int direction, Common::Rect rect) {
// whether the event manager is handling a right mouse down
// event
if (_cursor->field_11 & 2) {
- if (act->updateType == 1 || act->updateType == 12) {
+ if (act->status == 1 || act->status == 12) {
if (direction >= 0) {
newGrResId = _ws->curScrollUp + direction;
_cursor->set(newGrResId, 0, 2);
@@ -775,7 +573,7 @@ void Scene::handleMouseUpdate(int direction, Common::Rect rect) {
}
}
- if (act->updateType == 6 || act->updateType == 10) {
+ if (act->status == 6 || act->status == 10) {
newGrResId = _ws->curHand;
_cursor->set(newGrResId, 0, 2);
} else {
@@ -835,7 +633,7 @@ void Scene::handleMouseUpdate(int direction, Common::Rect rect) {
targetUpdateType = _ws->barriers[targetIdx].flags2;
break;
case kHitActor:
- targetUpdateType = getActor(targetIdx)->updateType;
+ targetUpdateType = getActor(targetIdx)->status;
break;
default:
// TODO LOBYTE(hitType)
@@ -983,103 +781,6 @@ bool Scene::hitTestPixel(int32 grResId, int32 frame, int16 x, int16 y, bool flip
return rect.contains(x, y);
}
-void Scene::updateActor(int32 actorIdx) {
- Actor *actor = getActor();
-
- if (actor->visible()) {
- // printf("Actor updateType = 0x%02X\n", actor->updateType);
-
- switch (actor->updateType) {
-
- case 0x10:
- if (_ws->numChapter == 2) {
- // TODO: updateCharacterSub14()
- } else if (_ws->numChapter == 1) {
- if (_playerActorIdx == actorIdx) {
- // TODO: updateActorSub21();
- }
- }
- break;
- case 0x11:
- if (_ws->numChapter == 2) {
- // TODO: put code here
- } else if (_ws->numChapter == 11) {
- if (_playerActorIdx == actorIdx) {
- // TODO: put code here
- }
- }
- break;
- case 0xF:
- if (_ws->numChapter == 2) {
- // TODO: put code here
- } else if (_ws->numChapter == 11) {
- // TODO: put code here
- }
- break;
- case 0x12:
- if (_ws->numChapter == 2) {
- // TODO: put code here
- }
- break;
- case 0x5: {
- int32 frameNum = actor->frameNum + 1;
- actor->frameNum = frameNum % actor->frameCount;
-
- if (_vm->getTick() - actor->tickValue1 > 300) {
- if (vm()->getRandom(100) < 50) {
- // TODO: check sound playing
- }
- actor->tickValue1 = _vm->getTick();
- }
- }
- break;
- case 0xC:
- if (_ws->numChapter == 2) {
- // TODO: put code here
- } else if (_ws->numChapter == 11) {
- // TODO: put code here
- }
- case 0x1:
- // TODO: do actor direction
- break;
- case 0x2:
- case 0xD:
- // TODO: do actor direction
- break;
- case 0x3:
- case 0x13:
- // TODO: updateCharacterSub05();
- break;
- case 0x7:
- // TODO: something
- break;
- case 0x4:
- if (actor->field_944 != 5) {
- updateActorSub01(actor);
- }
- break;
- case 0xE:
- // TODO: updateCharacterSub02(1, actorIdx);
- break;
- case 0x15:
- // TODO: updateCharacterSub06(1, actorIdx);
- break;
- case 0x9:
- // TODO: updateCharacterSub03(1, actorIdx);
- break;
- case 0x6:
- case 0xA:
- actor->frameNum = (actor->frameNum + 1) % actor->frameCount;
- break;
- case 0x8:
- // TODO: actor sound
- break;
- default:
- break;
- }
- }
-}
-
void Scene::updateActorSub01(Actor *act) {
// TODO make sure this is right
act->frameNum = act->frameNum + 1 % act->frameCount;
diff --git a/engines/asylum/views/scene.h b/engines/asylum/views/scene.h
index 4b73b23eb3..dcb4ce3f38 100644
--- a/engines/asylum/views/scene.h
+++ b/engines/asylum/views/scene.h
@@ -126,35 +126,23 @@ public:
/**
* Return the index of the current player actor
*/
- int getActorIndex() { return _playerActorIdx; }
+ ActorIndex getActorIndex() { return _playerActorIdx; }
+
+ void setActorIndex(ActorIndex index) { _playerActorIdx = index; }
+
/**
* Get a reference to an actor object from the
* WorldStats actor list. Default parameter just
* gets the instance associated with _playerActorIdx
*/
- Actor* getActor(int index = -1);
- /** .text:004072A0
- * Based on the value of param, replace the actor
- * graphic from the actor's grResTable
- *
- * TODO figure out exactly what param means
- */
- void updateActorDirection(int actorIndex, int param);
- /** .text:0040A2E0
- * If the actor index is invalid, load the default actor,
- * then call updateActorDirection with a param of 4
- */
- void updateActorDirectionDefault(int actorIndex);
+ Actor* getActor(ActorIndex index = -1);
+
/** .text:00407260
* Check the actor at actorIndex to see if the currently loaded
* graphic resource matches the resource at grResTable[5]
*/
bool defaultActorDirectionLoaded(int actorIndex, int grResTableIdx);
- /** .text:00407A00
- * TODO
- */
- void setActorDirection(Actor *act, int direction);
/** .text:00414C30
* Check if a sound resource is playing for the barrier,
* or actor that is specified, and if so, stop playing the
@@ -172,6 +160,13 @@ public:
*/
int32 calculateVolumeAdjustment(AmbientSoundItem *snd, Actor *act);
+
+ // Global coordinates
+ uint32 getGlobalX() const { return _globalX; }
+ void setGlobalX(uint32 val) { _globalX = val; }
+ uint32 getGlobalY() const { return _globalY; }
+ void setGlobalY(uint32 val) { _globalY = val; }
+
protected:
/** .text:0040EA50
* Run various hit tests and return the index,
@@ -234,6 +229,9 @@ private:
GraphicResource *_bgResource;
GraphicFrame *_background;
+ uint32 _globalX;
+ uint32 _globalY;
+
void update();
void startMusic();
@@ -251,10 +249,7 @@ private:
* TODO
*/
void handleMouseUpdate(int direction, Common::Rect rect);
- /** .text:0040B740
- * TODO add description
- */
- void updateActor(int32 actorIdx);
+
/**
* TODO give more meaningful name
*/
Commit: 4a3e37e814e9be5b6b38d625a9446e0e60970994
https://github.com/scummvm/scummvm/commit/4a3e37e814e9be5b6b38d625a9446e0e60970994
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:05+02:00
Commit Message:
ASYLUM: Finish implementing kPlaySpeech opcode
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@462 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/asylum.cpp
engines/asylum/asylum.h
engines/asylum/resources/actionlist.cpp
diff --git a/engines/asylum/asylum.cpp b/engines/asylum/asylum.cpp
index fa78689d81..2938618412 100644
--- a/engines/asylum/asylum.cpp
+++ b/engines/asylum/asylum.cpp
@@ -350,4 +350,11 @@ bool AsylumEngine::isGameFlagNotSet(int flag) {
return ((1 << flag % -32) & (unsigned int)_gameFlags[flag / 32]) >> flag % -32 == 0;
}
+void AsylumEngine::setFlag(FlagType flag, bool isSet) {
+ if (flag > ARRAYSIZE(_flags))
+ error("[AsylumEngine::setFlag] Invalid flag type (was: %d, max: %d", flag, ARRAYSIZE(_flags));
+
+ _flags[flag] = isSet;
+}
+
} // namespace Asylum
diff --git a/engines/asylum/asylum.h b/engines/asylum/asylum.h
index 4d25670451..08bb000d1e 100644
--- a/engines/asylum/asylum.h
+++ b/engines/asylum/asylum.h
@@ -57,6 +57,11 @@
*/
namespace Asylum {
+enum FlagType {
+ kFlagType1 = 0,
+ kFlagType2
+};
+
// XXX
// If defined, this will play the scene title loading up
// progress before the scene is entered. This is
@@ -134,6 +139,10 @@ public:
uint getRandom(uint max) { return _rnd.getRandomNumber(max); }
uint getRandomBit() { return _rnd.getRandomBit(); }
+ // Flags
+ void setFlag(FlagType flag) { setFlag(flag, true); }
+ void clearFlag(FlagType flag) { setFlag(flag, false); }
+
private:
const ADGameDescription *_gameDescription;
@@ -152,6 +161,7 @@ private:
bool _introPlaying;
int _gameFlags[1512];
+ bool _flags[2];
void handleEvents(bool doUpdate);
void waitForTimer(int msec_delay);
@@ -163,6 +173,8 @@ private:
*/
void playIntro();
+ void setFlag(FlagType flag, bool isSet);
+
friend class Console;
};
diff --git a/engines/asylum/resources/actionlist.cpp b/engines/asylum/resources/actionlist.cpp
index 70f4467555..1fa20e77e2 100644
--- a/engines/asylum/resources/actionlist.cpp
+++ b/engines/asylum/resources/actionlist.cpp
@@ -943,57 +943,48 @@ IMPLEMENT_OPCODE(_unk40_SOUND) {
//////////////////////////////////////////////////////////////////////////
// Opcode 0x41
IMPLEMENT_OPCODE(PlaySpeech) {
- //TODO - Add support for other param options
- int32 sndIdx = cmd->param1;
-
- if ((int)sndIdx >= 0) {
- if (cmd->param4 != 2) {
- int32 resIdx = _scene->speech()->play(sndIdx);
- cmd->param5 = resIdx;
-
- if (cmd->param2) {
- _scene->vm()->setGameFlag(183);
- cmd->param4 = 2;
- if (cmd->param6) {
- // TODO: set flag 01
- }
- _lineIncrement = 1;
- }
-
- if (cmd->param3) {
- if (!cmd->param6) {
- _scene->vm()->setGameFlag(219);
- }
- }
- }
-
- if (_scene->vm()->sound()->isPlaying(cmd->param5)) {
- _lineIncrement = 1;
- }
-
- _scene->vm()->clearGameFlag(183);
- cmd->param4 = 0;
-
- if (cmd->param3) {
- if (cmd->param6) {
- // TODO: clear flag 01
- }
- _scene->vm()->clearGameFlag(219);
- }
-
- if (!cmd->param6) {
- cmd->param6 = 1;
- }
-
- // TODO: clear flag 01
- } else
- debugC(kDebugLevelScripts,
- "Requested invalid sound ID:0x%02X in Scene %d Line %d.",
- cmd->param1,
- _scene->getSceneIndex(),
- _currentLine);
+ if (cmd->param1 < 0)
+ return;
- error("Incomplete opcode %s (0x%02X) in Scene %d Line %d", _actions[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
+ if (cmd->param4 != 2) {
+ cmd->param5 = _scene->speech()->play(cmd->param1);
+
+ if (cmd->param2) {
+ _scene->vm()->setGameFlag(183);
+ cmd->param4 = 2;
+ if (cmd->param6) {
+ _scene->vm()->setFlag(kFlagType1);
+ _scene->vm()->setFlag(kFlagType2);
+ }
+ _lineIncrement = 1;
+ }
+
+ if (cmd->param3 && !cmd->param6)
+ _scene->vm()->setGameFlag(219);
+ }
+
+ if (_scene->vm()->sound()->isPlaying(cmd->param5)) {
+ _lineIncrement = 1;
+ }
+
+ _scene->vm()->clearGameFlag(183);
+ cmd->param4 = 0;
+
+ if (cmd->param3) {
+ if (cmd->param6) {
+ _scene->vm()->clearFlag(kFlagType1);
+ _scene->vm()->clearFlag(kFlagType2);
+ } else {
+ _scene->vm()->clearGameFlag(219);
+ }
+ }
+
+ if (!cmd->param6) {
+ cmd->param6 = 1;
+ } else {
+ _scene->vm()->clearFlag(kFlagType1);
+ _scene->vm()->clearFlag(kFlagType2);
+ }
}
//////////////////////////////////////////////////////////////////////////
Commit: 6958752a3f1843391822689d60c00860caeedc21
https://github.com/scummvm/scummvm/commit/6958752a3f1843391822689d60c00860caeedc21
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:06+02:00
Commit Message:
ASYLUM: Enhance Actor class
- Finish implementation of updateStatus
- Move updateActorSub01 from Scene to Actor
- Allow reloading of GraphicResource data
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@463 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/resources/actionlist.cpp
engines/asylum/resources/actor.cpp
engines/asylum/resources/actor.h
engines/asylum/system/graphics.cpp
engines/asylum/system/graphics.h
engines/asylum/views/scene.cpp
engines/asylum/views/scene.h
diff --git a/engines/asylum/resources/actionlist.cpp b/engines/asylum/resources/actionlist.cpp
index 1fa20e77e2..d9a62c0551 100644
--- a/engines/asylum/resources/actionlist.cpp
+++ b/engines/asylum/resources/actionlist.cpp
@@ -492,34 +492,6 @@ IMPLEMENT_OPCODE(DisableActor) {
GET_ACTOR();
actor->updateStatus(kActorStatusDisabled);
-
- //if (cmd->param5 != 2) {
- // if (act->updateType != 2 && act->updateType != 13) {
- // if (cmd->param2 != -1 || cmd->param3 != -1)
- // _scene->updateActorDirection(actorIndex, cmd->param4);
- // else {
- // if ((act->x1 + act->x2) != cmd->param2 ||
- // (act->y1 + act->y2) != cmd->param3) {
- // ; // TODO updatecharacter_sub_408910
- // // TODO if (cmd->param5)
- // // cmd->param5 = 2
- // // v245 = true
- // } else
- // _scene->updateActorDirection(actorIndex, cmd->param4);
- // }
- // }
- // error("Incomplete opcode %s (0x%02X) in Scene %d Line %d", _actions[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
- //}
-
- //if (act->updateType != 2 && act->updateType != 13) {
- // cmd->param5 = 1;
- // // v245 = false
- // if ((act->x1 + act->x2) != cmd->param2 ||
- // (act->y1 + act->y2) != cmd->param3) {
- // _scene->updateActorDirection(actorIndex, cmd->param4);
- // }
- //}
- //error("Incomplete opcode %s (0x%02X) in Scene %d Line %d", _actions[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
}
//////////////////////////////////////////////////////////////////////////
diff --git a/engines/asylum/resources/actor.cpp b/engines/asylum/resources/actor.cpp
index e783f906ea..49bb44c0ac 100644
--- a/engines/asylum/resources/actor.cpp
+++ b/engines/asylum/resources/actor.cpp
@@ -449,152 +449,121 @@ void Actor::updateDirection() {
}
void Actor::updateStatus(ActorStatus actorStatus) {
- GraphicResource *gra;
-
switch (actorStatus) {
- case kActorStatus16:
- frameNum = 0;
- if (direction > 4)
- direction = 8 - direction;
- grResId = grResTable[15];
- gra = new GraphicResource(_resPack, grResId);
- frameCount = gra->getFrameCount();
- delete gra;
+ default:
break;
- case kActorStatus18:
- if (_scene->worldstats()->numChapter > 2) {
- frameNum = 0;
- if (_index > 12)
- grResId = grResTable[30];
- if (_scene->getActorIndex() == _index) {
- gra = new GraphicResource(_resPack, grResId);
- frameNum = gra->getFrameCount() - 1;
- delete gra;
- }
- if (_index == 11) {
- // TODO check a global variable (that likely
- // relates to direction) to see if it's > 4,
- // and if so, subtract it from 8. Then use this
- // to set actor[11].grResId
- }
-
- // FIXME I know this seems wasteful, but it's how the
- // original worked. I guess this is to set the framecount
- // regardless of the actorIndex value, though it assumes
- // the actor's grResId has been set.
- gra = new GraphicResource(_resPack, grResId);
- frameCount = gra->getFrameCount();
- delete gra;
- }
- break;
- case kActorStatus15:
- // TODO Refactor, because this is identical to case 16,
- // other than a different grResTable index
- frameNum = 0;
- if (direction > 4)
- direction = 8 - direction;
- grResId = grResTable[10];
- gra = new GraphicResource(_resPack, grResId);
- frameCount = gra->getFrameCount();
- delete gra;
- break;
- case kActorStatus9:
- // TODO Check if there is an encounter currently
- // active (via the global at .data:00543504)
- // FIXME skipping for now
- if (0) {
- if (_scene->vm()->getRandomBit() == 1 && defaultDirectionLoaded(15)) {
- frameNum = 0;
- if (direction > 4)
- direction = 8 - direction;
- grResId = grResTable[15];
- gra = new GraphicResource(_resPack, grResId);
- frameCount = gra->getFrameCount();
- delete gra;
- } else {
- frameNum = 0;
- if (direction > 4)
- direction = 8 - direction;
- grResId = grResTable[10];
- gra = new GraphicResource(_resPack, grResId);
- frameCount = gra->getFrameCount();
- delete gra;
- }
- }
- break;
- case kActorStatusEnabled:
- case kActorStatus6:
- case kActorStatus14:
- frameNum = 0;
- if (direction > 4)
- direction = 8 - direction;
- grResId = grResTable[15];
- gra = new GraphicResource(_resPack, grResId);
- frameCount = gra->getFrameCount();
- delete gra;
- break;
case kActorStatus1:
case kActorStatus12:
+ error("[Actor::updateStatus] not implemented for statuses 1 & 12");
// TODO check if sceneNumber == 2 && actorIndex == _playerActorInde
// && field_40 equals/doesn't equal a bunch of values,
// then set direction like other cases
break;
+
case kActorStatus2:
case kActorStatus13:
- frameNum = 0;
- if (direction > 4)
- direction = 8 - direction;
- grResId = grResTable[direction];
- gra = new GraphicResource(_resPack, grResId);
- frameCount = gra->getFrameCount();
- delete gra;
- break;
- case kActorStatusDisabled:
- frameNum = 0;
- if (direction > 4)
- direction = 8 - direction;
- grResId = grResTable[direction];
- gra = new GraphicResource(_resPack, grResId);
- frameCount = gra->getFrameCount();
- delete gra;
- // TODO set word_446EE4 to -1. This global seems to
- // be used with screen blitting
+ updateGraphicData(0);
break;
+
case kActorStatus3:
case kActorStatus19:
- // TODO check if the actor's name is equal to
- // "Big Crow"???
+ if (!strcmp(name, "Big Crow"))
+ status = kActorStatusEnabled;
+ break;
+
+ case kActorStatusEnabled:
+ case kActorStatus6:
+ case kActorStatus14:
+ updateGraphicData(5);
+ break;
+
+ case kActorStatusDisabled:
+ updateGraphicData(15);
+ grResId = grResTable[(direction > 4 ? 8 - direction : direction) + 15];
+
+ // TODO set word_446EE4 to -1. This global seems to be used with screen blitting
break;
+
case kActorStatus7:
if (_scene->worldstats()->numChapter == 2 && _index == 10 && _scene->vm()->isGameFlagSet(279)) {
- Actor *act0 = _scene->getActor(0);
- act0->x1 = x2 + x1 - act0->x2;
- act0->y1 = y2 + y1 - act0->y2;
- act0->direction = 4;
+ Actor *actor = _scene->getActor(0);
+ actor->x1 = x2 + x1 - actor->x2;
+ actor->y1 = y2 + y1 - actor->y2;
+ actor->direction = 4;
+
_scene->setActorIndex(0);
- // TODO disableCharacterVisible(actorIndex)
- // TODO enableActorVisible(0)
+
+ // Hide this actor and the show the other one
+ visible(false);
+ actor->visible(true);
+
_scene->vm()->clearGameFlag(279);
- // TODO some cursor update
+
+ _scene->getCursor()->show();
}
break;
+
case kActorStatus8:
case kActorStatus10:
case kActorStatus17:
- frameNum = 0;
- if (direction > 4)
- direction = 8 - direction;
- grResId = grResTable[20];
- gra = new GraphicResource(_resPack, grResId);
- frameCount = gra->getFrameCount();
- delete gra;
+ updateGraphicData(20);
+ break;
+
+ case kActorStatus9:
+ error("[Actor::updateStatus] Encounter check missing for status 9");
+ //if (_scene->vm()->encounter()->getFlag(kFlagEncounter3)
+ // return;
+
+ if (_scene->vm()->getRandomBit() == 1 && defaultDirectionLoaded(15))
+ updateGraphicData(15);
+ else
+ updateGraphicData(10);
+ break;
+
+ case kActorStatus15:
+ case kActorStatus16:
+ updateGraphicData(actorStatus == kActorStatus15 ? 10 : 15);
+ break;
+
+ case kActorStatus18:
+ if (_scene->worldstats()->numChapter == 2) {
+ GraphicResource *gra = new GraphicResource();
+ frameNum = 0;
+
+ if (_index > 12)
+ grResId = grResTable[direction + 30];
+
+ if (_scene->getActorIndex() == _index) {
+ gra->load(_resPack, grResId);
+ frameNum = gra->getFrameCount() - 1;
+ }
+
+ if (_index == 11)
+ grResId = grResTable[_scene->getGlobalDirection() > 4 ? 8 - _scene->getGlobalDirection() : _scene->getGlobalDirection()];
+
+ // Reload the graphic resource if the resource ID has changed
+ if (gra->getEntryNum() != grResId)
+ gra->load(_resPack, grResId);
+
+ frameCount = gra->getFrameCount();
+ }
break;
}
status = actorStatus;
}
+void Actor::updateGraphicData(uint32 offset) {
+ grResId = grResTable[(direction > 4 ? 8 - direction : direction) + offset];
+
+ GraphicResource *gra = new GraphicResource(_resPack, grResId);
+ frameCount = gra->getFrameCount();
+ delete gra;
+
+ frameNum = 0;
+}
+
void Actor::setDirection(int actorDirection) {
direction = (actorDirection > 4) ? 8 - actorDirection : actorDirection;
int32 grResId;
@@ -709,7 +678,7 @@ void Actor::update() {
break;
case 0x4:
if (field_944 != 5) {
- //updateActorSub01(actor);
+ updateActorSub01();
}
break;
case 0xE:
@@ -734,6 +703,49 @@ void Actor::update() {
}
}
+void Actor::updateActorSub01() {
+ // TODO make sure this is right
+ frameNum = (frameNum + 1) % frameCount;
+ if (_scene->vm()->getTick() - tickValue1 > 300) {
+ // TODO
+ // Check if the actor's name is "Crow"?
+ if (_scene->vm()->getRandom(100) < 50) {
+ // TODO
+ // Check if soundResId04 is assigned, and if so,
+ // if it's playing
+ // If true, check characterSub407260(10)
+ // and if that's true, do characterDirection(9)
+ }
+ }
+
+ // if act == getActor()
+ if (_scene->vm()->tempTick07) {
+ if (_scene->vm()->getTick() - _scene->vm()->tempTick07 > 500) {
+ if (_scene->vm()->isGameFlagNotSet(183)) { // processing action list
+ if (visible()) {
+ // if some_encounter_flag
+ // if !soundResId04
+ if (_scene->vm()->getRandom(100) < 50) {
+ if (_scene->getSceneIndex() == 13) {
+ ; // sub414810(507)
+ } else {
+ ; // sub4146d0(4)
+ }
+ }
+ }
+ }
+ }
+ tickValue1 = _scene->vm()->getTick();
+ }
+ // else
+ // TODO now there's something to do with the
+ // character's name and "Big Crow", or "Crow".
+ // Quite a bit of work to do yet, but it only seems to
+ // take effect when the character index doesn't equal
+ // the currentPlayerIndex (so I'm guessing this is a
+ // one off situation).
+}
+
bool Actor::defaultDirectionLoaded(int grResTableIdx) {
return grResTable[grResTableIdx] != grResTable[5];
diff --git a/engines/asylum/resources/actor.h b/engines/asylum/resources/actor.h
index ae0465594b..a1853102fd 100644
--- a/engines/asylum/resources/actor.h
+++ b/engines/asylum/resources/actor.h
@@ -311,6 +311,13 @@ private:
GraphicFrame *getFrame();
int32 getAngle(int32 ax1, int32 ay1, int32 ax2, int32 ay2);
+ void updateGraphicData(uint32 offset);
+
+ /**
+ * TODO give more meaningful name
+ */
+ void updateActorSub01();
+
}; // end of class MainActor
} // end of namespace Asylum
diff --git a/engines/asylum/system/graphics.cpp b/engines/asylum/system/graphics.cpp
index b954b460f4..347abf7eb5 100644
--- a/engines/asylum/system/graphics.cpp
+++ b/engines/asylum/system/graphics.cpp
@@ -30,12 +30,23 @@
namespace Asylum {
GraphicResource::GraphicResource(ResourcePack *resPack, uint32 entry) {
+ load(resPack, entry);
+}
+
+void GraphicResource::load(ResourcePack *resPack, uint32 entry) {
+ // Clear previously loaded data
+ clear();
+
ResourceEntry *resEntry = resPack->getResource(entry);
_entryNum = entry;
init(resEntry->data, resEntry->size);
}
GraphicResource::~GraphicResource() {
+ clear();
+}
+
+void GraphicResource::clear() {
for (uint32 i = 0; i < _frames.size(); i++) {
_frames[i].surface.free();
}
@@ -43,6 +54,13 @@ GraphicResource::~GraphicResource() {
_frames.clear();
}
+GraphicFrame *GraphicResource::getFrame(uint32 frame) {
+ if (frame > _frames.size())
+ error("[GraphicResource::getFrame] Invalid frame index (was: %d, max:%d)", frame, _frames.size());
+
+ return &_frames[frame];
+}
+
void GraphicResource::init(byte *data, int32 size) {
byte *dataPtr = data;
int32 contentOffset = 0;
diff --git a/engines/asylum/system/graphics.h b/engines/asylum/system/graphics.h
index 37e80739c0..970a1d764a 100644
--- a/engines/asylum/system/graphics.h
+++ b/engines/asylum/system/graphics.h
@@ -44,18 +44,12 @@ struct GraphicFrame {
// Graphic resources can be sprites or images, with multiple frames
class GraphicResource {
public:
+
+ GraphicResource() {}
GraphicResource(ResourcePack *resPack, uint32 entry);
~GraphicResource();
- uint32 getFrameCount() {
- return _frames.size();
- }
- GraphicFrame *getFrame(uint32 frame) {
- return &_frames[frame];
- }
- int32 getFlags() {
- return _flags;
- }
+ void load(ResourcePack *resPack, uint32 entry);
/**
* Copies an animation frame to the target buffer
@@ -67,9 +61,10 @@ public:
*/
void copySpriteToDest(byte *dest, uint32 frame);
- uint32 getEntryNum() {
- return _entryNum;
- }
+ GraphicFrame *getFrame(uint32 frame);
+ uint32 getEntryNum() { return _entryNum; }
+ int32 getFlags() { return _flags; }
+ uint32 getFrameCount() { return _frames.size(); }
private:
Common::Array <GraphicFrame> _frames;
@@ -77,6 +72,7 @@ private:
uint32 _entryNum;
void init(byte *data, int32 size);
+ void clear();
};
} // end of namespace Asylum
diff --git a/engines/asylum/views/scene.cpp b/engines/asylum/views/scene.cpp
index 5ee744f834..8f84aead8c 100644
--- a/engines/asylum/views/scene.cpp
+++ b/engines/asylum/views/scene.cpp
@@ -781,48 +781,6 @@ bool Scene::hitTestPixel(int32 grResId, int32 frame, int16 x, int16 y, bool flip
return rect.contains(x, y);
}
-void Scene::updateActorSub01(Actor *act) {
- // TODO make sure this is right
- act->frameNum = act->frameNum + 1 % act->frameCount;
- if (_vm->getTick() - act->tickValue1 > 300) {
- // TODO
- // Check if the actor's name is "Crow"?
- if (vm()->getRandom(100) < 50) {
- // TODO
- // Check if soundResId04 is assigned, and if so,
- // if it's playing
- // If true, check characterSub407260(10)
- // and if that's true, do characterDirection(9)
- }
- }
-
- // if act == getActor()
- if (_vm->tempTick07) {
- if (_vm->getTick() - _vm->tempTick07 > 500) {
- if (_vm->isGameFlagNotSet(183)) { // processing action list
- if (act->visible()) {
- // if some_encounter_flag
- // if !soundResId04
- if (vm()->getRandom(100) < 50) {
- if (_sceneIdx == 13) {
- ; // sub414810(507)
- } else {
- ; // sub4146d0(4)
- }
- }
- }
- }
- }
- act->tickValue1 = _vm->getTick();
- }
- // else
- // TODO now there's something to do with the
- // character's name and "Big Crow", or "Crow".
- // Quite a bit of work to do yet, but it only seems to
- // take effect when the character index doesn't equal
- // the currentPlayerIndex (so I'm guessing this is a
- // one off situation).
-}
void Scene::stopSound(int32 barrierIndex, int32 actorIndex) {
int32 sndResId = 0;
diff --git a/engines/asylum/views/scene.h b/engines/asylum/views/scene.h
index dcb4ce3f38..1d5e8cac13 100644
--- a/engines/asylum/views/scene.h
+++ b/engines/asylum/views/scene.h
@@ -161,12 +161,14 @@ public:
int32 calculateVolumeAdjustment(AmbientSoundItem *snd, Actor *act);
- // Global coordinates
+ // Shared global Data
uint32 getGlobalX() const { return _globalX; }
void setGlobalX(uint32 val) { _globalX = val; }
uint32 getGlobalY() const { return _globalY; }
void setGlobalY(uint32 val) { _globalY = val; }
+ ActorDirection getGlobalDirection() { return _globalDirection; }
+
protected:
/** .text:0040EA50
* Run various hit tests and return the index,
@@ -203,6 +205,7 @@ protected:
* return -1
*/
int32 hitTestBarrier(const Common::Point pt);
+
private:
AsylumEngine *_vm;
Common::Event *_ev;
@@ -215,6 +218,7 @@ private:
bool _rightButton;
bool _isActive;
bool _skipDrawScene;
+ ActorDirection _globalDirection;
WorldStats *_ws;
Polygons *_polygons;
@@ -250,10 +254,6 @@ private:
*/
void handleMouseUpdate(int direction, Common::Rect rect);
- /**
- * TODO give more meaningful name
- */
- void updateActorSub01(Actor *act);
/** .text:0040CBD0
* TODO add description
*/
Commit: 7f7f332bacee0e14a2c3707b5a4ca65b989cf141
https://github.com/scummvm/scummvm/commit/7f7f332bacee0e14a2c3707b5a4ca65b989cf141
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:06+02:00
Commit Message:
ASYLUM: Add macro to encapsulate ticks logging in updateScene and disable by default
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@464 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/asylum.h
engines/asylum/views/scene.cpp
engines/asylum/views/scene.h
diff --git a/engines/asylum/asylum.h b/engines/asylum/asylum.h
index 08bb000d1e..282ed158d6 100644
--- a/engines/asylum/asylum.h
+++ b/engines/asylum/asylum.h
@@ -69,6 +69,8 @@ enum FlagType {
// of pre-loading that was performed in the original
// #define SHOW_SCENE_LOADING
+//#define SHOW_SCENE_TIMES
+
// XXX If defined, this flag will prevent the intro movies
// from being played whenever the engine is started
#define SKIP_INTRO
diff --git a/engines/asylum/views/scene.cpp b/engines/asylum/views/scene.cpp
index 8f84aead8c..abd84ff2c9 100644
--- a/engines/asylum/views/scene.cpp
+++ b/engines/asylum/views/scene.cpp
@@ -351,43 +351,23 @@ void Scene::update() {
}
int Scene::updateScene() {
- int32 startTick = 0;
-
- // Mouse
- startTick = _vm->getTick();
- updateMouse();
- //debugC(kDebugLevelScene, "UpdateMouse Time: %d", _vm->getTick() - startTick);
-
- // Actors
- startTick = _vm->getTick();
- for (int32 a = 0; a < _ws->numActors; a++)
- getActor(a)->update();
- //debugC(kDebugLevelScene, "UpdateActors Time: %d", _vm->getTick() - startTick);
-
- // Barriers
- startTick = _vm->getTick();
- updateBarriers();
- //debugC(kDebugLevelScene, "UpdateBarriers Time: %d", _vm->getTick() - startTick);
-
- // Ambient Sounds
- startTick = _vm->getTick();
- updateAmbientSounds();
- //debugC(kDebugLevelScene, "UpdateAmbientSounds Time: %d", _vm->getTick() - startTick);
-
- // Music
- startTick = _vm->getTick();
- updateMusic();
- //debugC(kDebugLevelScene, "UpdateMusic Time: %d", _vm->getTick() - startTick);
+#ifdef SHOW_SCENE_TIMES
+#define MESURE_TICKS(func) { \
+ int32 startTick =_vm->getTick(); \
+ func(); \
+ debugC(kDebugLevelScene, #func " Time: %d", _vm->getTick() - startTick); \
+}
+#else
+#define MESURE_TICKS(func) func();
+#endif
- // Adjust Screen
- startTick = _vm->getTick();
-
- if (g_debugScrolling) { // DEBUG ScreenScrolling
- debugScreenScrolling(_bgResource->getFrame(0));
- } else {
- updateAdjustScreen();
- }
- //debugC(kDebugLevelScene, "AdjustScreenStart Time: %d", _vm->getTick() - startTick);
+ // Update each part of the scene
+ MESURE_TICKS(updateMouse);
+ MESURE_TICKS(updateActors);
+ MESURE_TICKS(updateBarriers);
+ MESURE_TICKS(updateAmbientSounds);
+ MESURE_TICKS(updateMusic);
+ MESURE_TICKS(updateScreen);
// Update Debug
if (g_debugPolygons)
@@ -797,6 +777,12 @@ void Scene::stopSound(int32 barrierIndex, int32 actorIndex) {
_vm->sound()->stopSound(sndResId);
}
}
+
+void Scene::updateActors() {
+ for (int32 a = 0; a < _ws->numActors; a++)
+ getActor(a)->update();
+}
+
void Scene::updateBarriers() {
//Screen *screen = _vm->screen();
@@ -1052,6 +1038,14 @@ int32 Scene::calculateVolumeAdjustment(AmbientSoundItem *snd, Actor *act) {
void Scene::updateMusic() {
}
+void Scene::updateScreen() {
+ if (g_debugScrolling) { // DEBUG ScreenScrolling
+ debugScreenScrolling(_bgResource->getFrame(0));
+ } else {
+ updateAdjustScreen();
+ }
+}
+
void Scene::updateAdjustScreen() {
Actor *act = getActor();
int32 newXLeft = -1;
diff --git a/engines/asylum/views/scene.h b/engines/asylum/views/scene.h
index 1d5e8cac13..a9a1fea9c2 100644
--- a/engines/asylum/views/scene.h
+++ b/engines/asylum/views/scene.h
@@ -254,6 +254,8 @@ private:
*/
void handleMouseUpdate(int direction, Common::Rect rect);
+ void updateActors();
+
/** .text:0040CBD0
* TODO add description
*/
@@ -270,6 +272,9 @@ private:
* TODO add description
*/
void updateAdjustScreen();
+
+ void updateScreen();
+
int drawScene();
/** .text:0040A3C0
* TODO add description
Commit: 744b1c1a802b9253a51c92407e3747045b0fd4ee
https://github.com/scummvm/scummvm/commit/744b1c1a802b9253a51c92407e3747045b0fd4ee
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:06+02:00
Commit Message:
ASYLUM: Introduce GameFlag enumeration
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@465 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
A engines/asylum/shared.h
engines/asylum/asylum.cpp
engines/asylum/asylum.h
engines/asylum/console.cpp
engines/asylum/resources/actionarea.h
engines/asylum/resources/actionlist.cpp
engines/asylum/resources/actor.cpp
engines/asylum/resources/barrier.h
engines/asylum/resources/encounters.h
engines/asylum/resources/polygons.h
engines/asylum/resources/worldstats.cpp
engines/asylum/resources/worldstats.h
engines/asylum/respack.h
engines/asylum/staticres.h
engines/asylum/system/config.h
engines/asylum/system/cursor.h
engines/asylum/system/graphics.h
engines/asylum/system/screen.h
engines/asylum/system/sound.h
engines/asylum/system/speech.h
engines/asylum/system/text.h
engines/asylum/system/video.h
engines/asylum/views/blowuppuzzle.h
engines/asylum/views/menu.h
engines/asylum/views/scene.cpp
engines/asylum/views/scene.h
diff --git a/engines/asylum/asylum.cpp b/engines/asylum/asylum.cpp
index 2938618412..b0867f5940 100644
--- a/engines/asylum/asylum.cpp
+++ b/engines/asylum/asylum.cpp
@@ -173,8 +173,8 @@ void AsylumEngine::startGame() {
// Enter first scene
if(!_introPlaying)
{
- setGameFlag(4);
- setGameFlag(12);
+ setGameFlag(kGameFlag4);
+ setGameFlag(kGameFlag12);
_scene->enterScene();
}
}
@@ -190,8 +190,8 @@ void AsylumEngine::playIntro() {
_screen->clearScreen();
- setGameFlag(4);
- setGameFlag(12);
+ setGameFlag(kGameFlag4);
+ setGameFlag(kGameFlag12);
// Play the intro sound sample (the screen is blacked out, you hear
// an alarm sounding and men talking about.
@@ -313,7 +313,7 @@ void AsylumEngine::processDelayedEvents() {
int sceneIdx = _scene->actions()->getDelayedSceneIndex();
// XXX Flag 183 indicates whether the actionlist is currently
// processing
- if (sceneIdx >= 0 && isGameFlagNotSet(183)) {
+ if (sceneIdx >= 0 && isGameFlagNotSet(kGameFlagScriptProcessing)) {
_sound->stopMusic();
_sound->stopAllSounds();
@@ -330,23 +330,23 @@ void AsylumEngine::processDelayedEvents() {
//////////////////////////////////////////////////////////////////////////
// Game flags
//////////////////////////////////////////////////////////////////////////
-void AsylumEngine::setGameFlag(int flag) {
+void AsylumEngine::setGameFlag(GameFlag flag) {
_gameFlags[flag / 32] |= 1 << flag % -32;
}
-void AsylumEngine::clearGameFlag(int flag) {
+void AsylumEngine::clearGameFlag(GameFlag flag) {
_gameFlags[flag / 32] &= ~(1 << flag % -32);
}
-void AsylumEngine::toggleGameFlag(int flag) {
+void AsylumEngine::toggleGameFlag(GameFlag flag) {
_gameFlags[flag / 32] ^= 1 << flag % -32;
}
-bool AsylumEngine::isGameFlagSet(int flag) {
+bool AsylumEngine::isGameFlagSet(GameFlag flag) {
return ((1 << flag % -32) & (unsigned int)_gameFlags[flag / 32]) >> flag % -32 != 0;
}
-bool AsylumEngine::isGameFlagNotSet(int flag) {
+bool AsylumEngine::isGameFlagNotSet(GameFlag flag) {
return ((1 << flag % -32) & (unsigned int)_gameFlags[flag / 32]) >> flag % -32 == 0;
}
diff --git a/engines/asylum/asylum.h b/engines/asylum/asylum.h
index 282ed158d6..cad3d77a74 100644
--- a/engines/asylum/asylum.h
+++ b/engines/asylum/asylum.h
@@ -27,6 +27,7 @@
#define ASYLUM_ENGINE_H
#include "asylum/console.h"
+#include "asylum/shared.h"
#include "common/random.h"
#include "common/scummsys.h"
@@ -57,11 +58,6 @@
*/
namespace Asylum {
-enum FlagType {
- kFlagType1 = 0,
- kFlagType2
-};
-
// XXX
// If defined, this will play the scene title loading up
// progress before the scene is entered. This is
@@ -86,6 +82,13 @@ enum FlagType {
#define LOBYTE(word) ((word >> 24) & 0xFF)
#endif
+//////////////////////////////////////////////////////////////////////////
+// Flags
+enum FlagType {
+ kFlagType1 = 0,
+ kFlagType2
+};
+
class Encounter;
class MainMenu;
class Scene;
@@ -131,11 +134,11 @@ public:
Text* text() { return _text; }
// Flags
- void setGameFlag(int flag);
- void clearGameFlag(int flag);
- void toggleGameFlag(int flag);
- bool isGameFlagSet(int flag);
- bool isGameFlagNotSet(int flag);
+ void setGameFlag(GameFlag flag);
+ void clearGameFlag(GameFlag flag);
+ void toggleGameFlag(GameFlag flag);
+ bool isGameFlagSet(GameFlag flag);
+ bool isGameFlagNotSet(GameFlag flag);
// Misc
uint getRandom(uint max) { return _rnd.getRandomNumber(max); }
diff --git a/engines/asylum/console.cpp b/engines/asylum/console.cpp
index 19195c8e49..b3bf547d39 100644
--- a/engines/asylum/console.cpp
+++ b/engines/asylum/console.cpp
@@ -100,7 +100,7 @@ void Console::printActionAreaStats(ActionArea *a) {
bool Console::cmdShowFlags(int32 argc, const char **argv) {
for (int32 i = 0; i < 1512; i++) {
- if (_vm->isGameFlagSet(i)) {
+ if (_vm->isGameFlagSet((GameFlag)i)) {
DebugPrintf("Game Flag %d is Active\n", i);
}
}
@@ -113,8 +113,8 @@ bool Console::cmdToggleFlag(int32 argc, const char **argv) {
DebugPrintf("Enter a value between 0 and 1512\n");
return true;
}
- _vm->toggleGameFlag(atoi(argv[1]));
- DebugPrintf("Flag %d == %d\n", atoi(argv[1]), _vm->isGameFlagSet(atoi(argv[1])));
+ _vm->toggleGameFlag((GameFlag)atoi(argv[1]));
+ DebugPrintf("Flag %d == %d\n", atoi(argv[1]), _vm->isGameFlagSet((GameFlag)atoi(argv[1])));
return true;
}
diff --git a/engines/asylum/resources/actionarea.h b/engines/asylum/resources/actionarea.h
index 22dd07bf11..d263d67c61 100644
--- a/engines/asylum/resources/actionarea.h
+++ b/engines/asylum/resources/actionarea.h
@@ -23,8 +23,8 @@
*
*/
-#ifndef ASYLUM_ACTIONAREA_H_
-#define ASYLUM_ACTIONAREA_H_
+#ifndef ASYLUM_ACTIONAREA_H
+#define ASYLUM_ACTIONAREA_H
#include "common/array.h"
@@ -60,4 +60,4 @@ public:
} // end of namespace Asylum
-#endif /* ASYLUM_ACTIONAREA_H_ */
+#endif /* ASYLUM_ACTIONAREA_H */
diff --git a/engines/asylum/resources/actionlist.cpp b/engines/asylum/resources/actionlist.cpp
index d9a62c0551..5447fb85e0 100644
--- a/engines/asylum/resources/actionlist.cpp
+++ b/engines/asylum/resources/actionlist.cpp
@@ -184,7 +184,7 @@ bool ActionList::process() {
_waitCycle = false;
_lineIncrement = 1;
- _scene->vm()->setGameFlag(183);
+ _scene->vm()->setGameFlag(kGameFlagScriptProcessing);
if (_currentScript)
while (!_done && !_waitCycle) {
@@ -227,7 +227,7 @@ bool ActionList::process() {
}
}
- _scene->vm()->clearGameFlag(183);
+ _scene->vm()->clearGameFlag(kGameFlagScriptProcessing);
return false;
}
@@ -282,7 +282,7 @@ IMPLEMENT_OPCODE(Return) {
//////////////////////////////////////////////////////////////////////////
// Opcode 0x01
IMPLEMENT_OPCODE(SetGameFlag) {
- int flagNum = cmd->param1;
+ GameFlag flagNum = (GameFlag)cmd->param1;
if (flagNum >= 0)
_scene->vm()->setGameFlag(flagNum);
@@ -291,7 +291,7 @@ IMPLEMENT_OPCODE(SetGameFlag) {
//////////////////////////////////////////////////////////////////////////
// Opcode 0x02
IMPLEMENT_OPCODE(ClearGameFlag) {
- int flagNum = cmd->param1;
+ GameFlag flagNum = (GameFlag)cmd->param1;
if (flagNum >= 0)
_scene->vm()->clearGameFlag(flagNum);
@@ -300,7 +300,7 @@ IMPLEMENT_OPCODE(ClearGameFlag) {
//////////////////////////////////////////////////////////////////////////
// Opcode 0x03
IMPLEMENT_OPCODE(ToggleGameFlag) {
- int flagNum = cmd->param1;
+ GameFlag flagNum = (GameFlag)cmd->param1;
if (flagNum >= 0)
_scene->vm()->toggleGameFlag(flagNum);
@@ -309,7 +309,7 @@ IMPLEMENT_OPCODE(ToggleGameFlag) {
//////////////////////////////////////////////////////////////////////////
// Opcode 0x04
IMPLEMENT_OPCODE(JumpIfGameFlag) {
- int flagNum = cmd->param1;
+ GameFlag flagNum = (GameFlag)cmd->param1;
if (flagNum) {
bool doJump = _scene->vm()->isGameFlagSet(flagNum);
@@ -922,7 +922,7 @@ IMPLEMENT_OPCODE(PlaySpeech) {
cmd->param5 = _scene->speech()->play(cmd->param1);
if (cmd->param2) {
- _scene->vm()->setGameFlag(183);
+ _scene->vm()->setGameFlag(kGameFlagScriptProcessing);
cmd->param4 = 2;
if (cmd->param6) {
_scene->vm()->setFlag(kFlagType1);
@@ -932,14 +932,14 @@ IMPLEMENT_OPCODE(PlaySpeech) {
}
if (cmd->param3 && !cmd->param6)
- _scene->vm()->setGameFlag(219);
+ _scene->vm()->setGameFlag(kGameFlag219);
}
if (_scene->vm()->sound()->isPlaying(cmd->param5)) {
_lineIncrement = 1;
}
- _scene->vm()->clearGameFlag(183);
+ _scene->vm()->clearGameFlag(kGameFlagScriptProcessing);
cmd->param4 = 0;
if (cmd->param3) {
@@ -947,7 +947,7 @@ IMPLEMENT_OPCODE(PlaySpeech) {
_scene->vm()->clearFlag(kFlagType1);
_scene->vm()->clearFlag(kFlagType2);
} else {
- _scene->vm()->clearGameFlag(219);
+ _scene->vm()->clearGameFlag(kGameFlag219);
}
}
diff --git a/engines/asylum/resources/actor.cpp b/engines/asylum/resources/actor.cpp
index 49bb44c0ac..5aa6dadb06 100644
--- a/engines/asylum/resources/actor.cpp
+++ b/engines/asylum/resources/actor.cpp
@@ -486,7 +486,7 @@ void Actor::updateStatus(ActorStatus actorStatus) {
break;
case kActorStatus7:
- if (_scene->worldstats()->numChapter == 2 && _index == 10 && _scene->vm()->isGameFlagSet(279)) {
+ if (_scene->worldstats()->numChapter == 2 && _index == 10 && _scene->vm()->isGameFlagSet(kGameFlag279)) {
Actor *actor = _scene->getActor(0);
actor->x1 = x2 + x1 - actor->x2;
actor->y1 = y2 + y1 - actor->y2;
@@ -498,7 +498,7 @@ void Actor::updateStatus(ActorStatus actorStatus) {
visible(false);
actor->visible(true);
- _scene->vm()->clearGameFlag(279);
+ _scene->vm()->clearGameFlag(kGameFlag279);
_scene->getCursor()->show();
}
@@ -721,7 +721,7 @@ void Actor::updateActorSub01() {
// if act == getActor()
if (_scene->vm()->tempTick07) {
if (_scene->vm()->getTick() - _scene->vm()->tempTick07 > 500) {
- if (_scene->vm()->isGameFlagNotSet(183)) { // processing action list
+ if (_scene->vm()->isGameFlagNotSet(kGameFlagScriptProcessing)) { // processing action list
if (visible()) {
// if some_encounter_flag
// if !soundResId04
diff --git a/engines/asylum/resources/barrier.h b/engines/asylum/resources/barrier.h
index a0b1f3b42f..5e602fddfc 100644
--- a/engines/asylum/resources/barrier.h
+++ b/engines/asylum/resources/barrier.h
@@ -23,11 +23,13 @@
*
*/
-#ifndef ASYLUM_BARRIER_H_
-#define ASYLUM_BARRIER_H_
+#ifndef ASYLUM_BARRIER_H
+#define ASYLUM_BARRIER_H
#include "asylum/system/sound.h"
+#include "asylum/shared.h"
+
namespace Asylum {
class Barrier {
@@ -70,7 +72,7 @@ public:
int32 field_80; // actor intersection
int32 polyIdx;
int32 flags2;
- int32 gameFlags[10];
+ GameFlag gameFlags[10];
int32 field_B4;
int32 tickCount;
int32 tickCount2;
diff --git a/engines/asylum/resources/encounters.h b/engines/asylum/resources/encounters.h
index e91161148b..2857a79dc7 100644
--- a/engines/asylum/resources/encounters.h
+++ b/engines/asylum/resources/encounters.h
@@ -23,8 +23,8 @@
*
*/
-#ifndef ASYLUM_ENCOUNTERS_H_
-#define ASYLUM_ENCOUNTERS_H_
+#ifndef ASYLUM_ENCOUNTERS_H
+#define ASYLUM_ENCOUNTERS_H
#include "common/array.h"
#include "asylum/scene.h"
diff --git a/engines/asylum/resources/polygons.h b/engines/asylum/resources/polygons.h
index 8231e6df38..e7f30f9e3f 100644
--- a/engines/asylum/resources/polygons.h
+++ b/engines/asylum/resources/polygons.h
@@ -23,8 +23,8 @@
*
*/
-#ifndef ASYLUM_POLYGONS_H_
-#define ASYLUM_POLYGONS_H_
+#ifndef ASYLUM_POLYGONS_H
+#define ASYLUM_POLYGONS_H
#include "common/array.h"
#include "common/rect.h"
diff --git a/engines/asylum/resources/worldstats.cpp b/engines/asylum/resources/worldstats.cpp
index 3e0b5c5df1..657d4bf3a4 100644
--- a/engines/asylum/resources/worldstats.cpp
+++ b/engines/asylum/resources/worldstats.cpp
@@ -83,7 +83,7 @@ bool WorldStats::isBarrierVisible(int32 idx) {
if ((b->flags & 0xFF) & 1) {
for (int32 f = 0; f < 10; f++) {
bool isSet = false;
- int32 flag = b->gameFlags[f];
+ GameFlag flag = b->gameFlags[f];
if (flag <= 0)
isSet = _scene->vm()->isGameFlagNotSet(flag); // -flag
@@ -207,7 +207,7 @@ void WorldStats::load(Common::SeekableReadStream *stream) {
ambientSounds[s].field_14 = stream->readSint32LE();
for (int32 i = 0; i < 6; i++)
- ambientSounds[s].flagNum[i] = stream->readSint32LE();
+ ambientSounds[s].flagNum[i] = (GameFlag)stream->readSint32LE();
ambientSounds[s].x = stream->readSint32LE();
ambientSounds[s].y = stream->readSint32LE();
@@ -253,7 +253,7 @@ void WorldStats::load(Common::SeekableReadStream *stream) {
barrier.flags2 = stream->readSint32LE();
for (i = 0; i < 10; i++)
- barrier.gameFlags[i] = stream->readSint32LE();
+ barrier.gameFlags[i] = (GameFlag)stream->readSint32LE();
barrier.field_B4 = stream->readSint32LE();
barrier.tickCount = stream->readSint32LE();
diff --git a/engines/asylum/resources/worldstats.h b/engines/asylum/resources/worldstats.h
index 80e29caa91..3258fa322e 100644
--- a/engines/asylum/resources/worldstats.h
+++ b/engines/asylum/resources/worldstats.h
@@ -23,8 +23,8 @@
*
*/
-#ifndef ASYLUM_WORLDSTATS_H_
-#define ASYLUM_WORLDSTATS_H_
+#ifndef ASYLUM_WORLDSTATS_H
+#define ASYLUM_WORLDSTATS_H
#include "common/rect.h"
#include "common/array.h"
diff --git a/engines/asylum/respack.h b/engines/asylum/respack.h
index 96cd32a31e..84eaab1451 100644
--- a/engines/asylum/respack.h
+++ b/engines/asylum/respack.h
@@ -23,8 +23,8 @@
*
*/
-#ifndef ASYLUM_RESOURCEPACK_H_
-#define ASYLUM_RESOURCEPACK_H_
+#ifndef ASYLUM_RESOURCEPACK_H
+#define ASYLUM_RESOURCEPACK_H
#include "common/array.h"
#include "common/file.h"
diff --git a/engines/asylum/shared.h b/engines/asylum/shared.h
new file mode 100644
index 0000000000..a31ea8d9bb
--- /dev/null
+++ b/engines/asylum/shared.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.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#ifndef ASYLUM_SHARED_H
+#define ASYLUM_SHARED_H
+
+namespace Asylum {
+
+enum GameFlag {
+ kGameFlag4 = 4,
+ kGameFlag12 = 12,
+ kGameFlagScriptProcessing = 183,
+ kGameFlagCommentLeavingCell = 214,
+ kGameFlag219 = 219,
+ kGameFlagSolveVCRBlowUpPuzzle = 220,
+ kGameFlag279 = 279,
+ kGameFlagFinishGame = 901
+};
+
+} // End of namespace Asylum
+
+#endif // ASYLUM_SHARED_H
diff --git a/engines/asylum/staticres.h b/engines/asylum/staticres.h
index 6a12db3aa9..d79e49f80e 100644
--- a/engines/asylum/staticres.h
+++ b/engines/asylum/staticres.h
@@ -23,8 +23,8 @@
*
*/
-#ifndef ASYLUM_STATICRES_H_
-#define ASYLUM_STATICRES_H_
+#ifndef ASYLUM_STATICRES_H
+#define ASYLUM_STATICRES_H
namespace Asylum {
@@ -107,4 +107,4 @@ const uint8 angleTable03[256] = {
} // end of namespace Asylum
-#endif /* ASYLUM_STATICRES_H_ */
+#endif /* ASYLUM_STATICRES_H */
diff --git a/engines/asylum/system/config.h b/engines/asylum/system/config.h
index a8c19cff37..beb1eb117d 100644
--- a/engines/asylum/system/config.h
+++ b/engines/asylum/system/config.h
@@ -23,8 +23,8 @@
*
*/
-#ifndef ASYLUM_CONFIGURATIONMANAGER_H_
-#define ASYLUM_CONFIGURATIONMANAGER_H_
+#ifndef ASYLUM_CONFIGURATIONMANAGER_H
+#define ASYLUM_CONFIGURATIONMANAGER_H
#include "common/array.h"
#include "common/singleton.h"
diff --git a/engines/asylum/system/cursor.h b/engines/asylum/system/cursor.h
index bdf0f369ed..28f09f330d 100644
--- a/engines/asylum/system/cursor.h
+++ b/engines/asylum/system/cursor.h
@@ -23,8 +23,8 @@
*
*/
-#ifndef ASYLUM_CURSOR_H_
-#define ASYLUM_CURSOR_H_
+#ifndef ASYLUM_CURSOR_H
+#define ASYLUM_CURSOR_H
#include "asylum/system/graphics.h"
diff --git a/engines/asylum/system/graphics.h b/engines/asylum/system/graphics.h
index 970a1d764a..fa3a98981d 100644
--- a/engines/asylum/system/graphics.h
+++ b/engines/asylum/system/graphics.h
@@ -23,8 +23,8 @@
*
*/
-#ifndef ASYLUM_GRAPHICS_H_
-#define ASYLUM_GRAPHICS_H_
+#ifndef ASYLUM_GRAPHICS_H
+#define ASYLUM_GRAPHICS_H
#include "common/array.h"
#include "graphics/surface.h"
diff --git a/engines/asylum/system/screen.h b/engines/asylum/system/screen.h
index beeb0838df..8149a2e300 100644
--- a/engines/asylum/system/screen.h
+++ b/engines/asylum/system/screen.h
@@ -23,8 +23,8 @@
*
*/
-#ifndef ASYLUM_SCREEN_H_
-#define ASYLUM_SCREEN_H_
+#ifndef ASYLUM_SCREEN_H
+#define ASYLUM_SCREEN_H
#include "asylum/asylum.h"
#include "asylum/respack.h"
diff --git a/engines/asylum/system/sound.h b/engines/asylum/system/sound.h
index 3ddfdaf172..fecf91273a 100644
--- a/engines/asylum/system/sound.h
+++ b/engines/asylum/system/sound.h
@@ -23,12 +23,13 @@
*
*/
-#ifndef ASYLUM_SOUND_H_
-#define ASYLUM_SOUND_H_
-
-#include "sound/mixer.h"
+#ifndef ASYLUM_SOUND_H
+#define ASYLUM_SOUND_H
#include "asylum/respack.h"
+#include "asylum/shared.h"
+
+#include "sound/mixer.h"
namespace Asylum {
@@ -57,7 +58,7 @@ typedef struct AmbientSoundItem {
int32 field_C;
int32 field_10;
int32 field_14;
- int32 flagNum[6];
+ GameFlag flagNum[6];
int32 x;
int32 y;
diff --git a/engines/asylum/system/speech.h b/engines/asylum/system/speech.h
index c4a54d2551..f80711a74b 100644
--- a/engines/asylum/system/speech.h
+++ b/engines/asylum/system/speech.h
@@ -23,8 +23,8 @@
*
*/
-#ifndef ASYLUM_SPEECH_H_
-#define ASYLUM_SPEECH_H_
+#ifndef ASYLUM_SPEECH_H
+#define ASYLUM_SPEECH_H
#include "asylum/respack.h"
#include "asylum/views/scene.h"
diff --git a/engines/asylum/system/text.h b/engines/asylum/system/text.h
index 3eda099cc8..2d458e3520 100644
--- a/engines/asylum/system/text.h
+++ b/engines/asylum/system/text.h
@@ -23,8 +23,8 @@
*
*/
-#ifndef ASYLUM_TEXT_H_
-#define ASYLUM_TEXT_H_
+#ifndef ASYLUM_TEXT_H
+#define ASYLUM_TEXT_H
#include "asylum/system/screen.h"
#include "asylum/respack.h"
diff --git a/engines/asylum/system/video.h b/engines/asylum/system/video.h
index fa33fe5b77..c13333a06f 100644
--- a/engines/asylum/system/video.h
+++ b/engines/asylum/system/video.h
@@ -23,8 +23,8 @@
*
*/
-#ifndef ASYLUM_VIDEO_H_
-#define ASYLUM_VIDEO_H_
+#ifndef ASYLUM_VIDEO_H
+#define ASYLUM_VIDEO_H
#include "sound/mixer.h"
#include "graphics/surface.h"
diff --git a/engines/asylum/views/blowuppuzzle.h b/engines/asylum/views/blowuppuzzle.h
index a0aead668a..edf02dc099 100644
--- a/engines/asylum/views/blowuppuzzle.h
+++ b/engines/asylum/views/blowuppuzzle.h
@@ -23,8 +23,8 @@
*
*/
-#ifndef ASYLUM_BLOWUPPUZZLE_H_
-#define ASYLUM_BLOWUPPUZZLE_H_
+#ifndef ASYLUM_BLOWUPPUZZLE_H
+#define ASYLUM_BLOWUPPUZZLE_H
#include "common/events.h"
#include "common/rect.h"
diff --git a/engines/asylum/views/menu.h b/engines/asylum/views/menu.h
index cea13e5870..5c83de4a93 100644
--- a/engines/asylum/views/menu.h
+++ b/engines/asylum/views/menu.h
@@ -23,8 +23,8 @@
*
*/
-#ifndef ASYLUM_MENU_H_
-#define ASYLUM_MENU_H_
+#ifndef ASYLUM_MENU_H
+#define ASYLUM_MENU_H
#include "common/events.h"
diff --git a/engines/asylum/views/scene.cpp b/engines/asylum/views/scene.cpp
index abd84ff2c9..b6ee2c1ef9 100644
--- a/engines/asylum/views/scene.cpp
+++ b/engines/asylum/views/scene.cpp
@@ -117,7 +117,7 @@ Scene::Scene(uint8 sceneIdx, AsylumEngine *engine): _vm(engine) {
}
void Scene::initialize() {
- _vm->setGameFlag(183);
+ _vm->setGameFlag(kGameFlagScriptProcessing);
_playerActorIdx = 0;
@@ -345,7 +345,7 @@ void Scene::update() {
} else {
_speech->_textResIdx = 0;
_speech->_soundResIdx = 0;
- _vm->clearGameFlag(219);
+ _vm->clearGameFlag(kGameFlag219);
}
}
}
@@ -930,14 +930,14 @@ void Scene::updateAmbientSounds() {
AmbientSoundItem *snd = &_ws->ambientSounds[i];
for (int32 f = 0; f < 6; f++) {
- int gameFlag = snd->flagNum[f];
+ GameFlag gameFlag = snd->flagNum[f];
if (gameFlag >= 0) {
if (_vm->isGameFlagNotSet(gameFlag)) {
processSound = false;
break;
}
} else {
- if (_vm->isGameFlagSet(-gameFlag)) {
+ if (_vm->isGameFlagSet((GameFlag)-gameFlag)) {
processSound = false;
break;
}
diff --git a/engines/asylum/views/scene.h b/engines/asylum/views/scene.h
index a9a1fea9c2..dd6b73e52a 100644
--- a/engines/asylum/views/scene.h
+++ b/engines/asylum/views/scene.h
@@ -23,8 +23,8 @@
*
*/
-#ifndef ASYLUM_SCENE_H_
-#define ASYLUM_SCENE_H_
+#ifndef ASYLUM_SCENE_H
+#define ASYLUM_SCENE_H
#include "common/events.h"
Commit: bf064f37888fa772de2c559999c2a2ebbfe9e4eb
https://github.com/scummvm/scummvm/commit/bf064f37888fa772de2c559999c2a2ebbfe9e4eb
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:06+02:00
Commit Message:
ASYLUM: Cleanup some actor-related opcodes
- Add enum for Actor visibility flags
- Get rid of GET_ACTOR macro (a call to Scene::getActor() is enough)
- Misc cleanups
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@466 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/asylum.h
engines/asylum/resources/actionlist.cpp
engines/asylum/resources/actionlist.h
engines/asylum/resources/actor.cpp
engines/asylum/resources/actor.h
engines/asylum/resources/barrier.cpp
engines/asylum/resources/barrier.h
engines/asylum/resources/worldstats.cpp
engines/asylum/views/scene.cpp
diff --git a/engines/asylum/asylum.h b/engines/asylum/asylum.h
index cad3d77a74..4ad134ad8e 100644
--- a/engines/asylum/asylum.h
+++ b/engines/asylum/asylum.h
@@ -127,11 +127,11 @@ public:
uint32 tempTick07;
// Game
- Video* video() { return _video; }
- Sound* sound() { return _sound; }
- Screen* screen() { return _screen; }
- Scene* scene() { return _scene;}
- Text* text() { return _text; }
+ Video* video() { return _video; }
+ Sound* sound() { return _sound; }
+ Screen* screen() { return _screen; }
+ Scene* scene() { return _scene; }
+ Text* text() { return _text; }
// Flags
void setGameFlag(GameFlag flag);
diff --git a/engines/asylum/resources/actionlist.cpp b/engines/asylum/resources/actionlist.cpp
index 5447fb85e0..f35b0e9791 100644
--- a/engines/asylum/resources/actionlist.cpp
+++ b/engines/asylum/resources/actionlist.cpp
@@ -186,34 +186,24 @@ bool ActionList::process() {
_scene->vm()->setGameFlag(kGameFlagScriptProcessing);
- if (_currentScript)
+ if (_currentScript) {
while (!_done && !_waitCycle) {
_lineIncrement = 0; //Reset line increment value
- ScriptEntry *currentCommand = &_currentScript->commands[_currentLine];
+ ScriptEntry *cmd = &_currentScript->commands[_currentLine];
- int32 opcode = currentCommand->opcode;
+ int32 opcode = cmd->opcode;
- debugC(kDebugLevelScripts,
- "[0x%02X] %s(%d, %d, %d, %d, %d, %d, %d, %d, %d)",
- opcode,
- _actions[opcode]->name,
- currentCommand->param1,
- currentCommand->param2,
- currentCommand->param3,
- currentCommand->param4,
- currentCommand->param5,
- currentCommand->param6,
- currentCommand->param7,
- currentCommand->param8,
- currentCommand->param9);
+ debugC(kDebugLevelScripts, "[0x%02X] %s(%d, %d, %d, %d, %d, %d, %d, %d, %d)",
+ opcode, _actions[opcode]->name,
+ cmd->param1, cmd->param2, cmd->param3, cmd->param4, cmd->param5,
+ cmd->param6, cmd->param7, cmd->param8, cmd->param9);
// Execute opcode
- (*_actions[opcode]->func)(currentCommand);
+ (*_actions[opcode]->func)(cmd);
if (!_lineIncrement)
_currentLine ++;
-
}
if (_done) {
@@ -224,6 +214,7 @@ bool ActionList::process() {
_currentScript = &_entries[_currentQueueEntry.actionListIndex];
} else {
_currentScript = 0;
+ }
}
}
@@ -333,8 +324,7 @@ IMPLEMENT_OPCODE(ShowCursor) {
_scene->getCursor()->show();
_allowInput = true;
- // TODO clear_flag_01()
- error("Incomplete opcode %s (0x%02X) in Scene %d Line %d", _actions[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
+ _scene->vm()->clearFlag(kFlagType1);
}
//////////////////////////////////////////////////////////////////////////
@@ -456,18 +446,18 @@ IMPLEMENT_OPCODE(MoveScenePosition) {
//////////////////////////////////////////////////////////////////////////
// Opcode 0x09
IMPLEMENT_OPCODE(HideActor) {
- Actor *actor = (cmd->param1 == -1) ? _scene->getActor() : &_scene->worldstats()->actors[cmd->param1];
+ Actor *actor = _scene->getActor(cmd->param1);
- actor->visible(false);
+ actor->setVisible(false);
actor->updateDirection();
}
//////////////////////////////////////////////////////////////////////////
// Opcode 0x0A
IMPLEMENT_OPCODE(ShowActor) {
- GET_ACTOR();
+ Actor *actor = _scene->getActor(cmd->param1);
- actor->visible(true);
+ actor->setVisible(true);
actor->updateDirection();
actor->tickValue1 = _scene->vm()->getTick();
}
@@ -489,7 +479,7 @@ IMPLEMENT_OPCODE(SetSceneMotionStatus) {
//////////////////////////////////////////////////////////////////////////
// Opcode 0x0D
IMPLEMENT_OPCODE(DisableActor) {
- GET_ACTOR();
+ Actor *actor = _scene->getActor(cmd->param1);
actor->updateStatus(kActorStatusDisabled);
}
@@ -497,7 +487,7 @@ IMPLEMENT_OPCODE(DisableActor) {
//////////////////////////////////////////////////////////////////////////
// Opcode 0x0E
IMPLEMENT_OPCODE(EnableActor) {
- GET_ACTOR();
+ Actor *actor = _scene->getActor(cmd->param1);
if (actor->status == kActorStatusDisabled)
actor->updateStatus(kActorStatusEnabled);
@@ -546,12 +536,12 @@ IMPLEMENT_OPCODE(EnableBarriers) {
// Opcode 0x11
IMPLEMENT_OPCODE(DestroyBarrier) {
Barrier *barrier = _scene->worldstats()->getBarrierById(cmd->param1);
-
if (!barrier)
- error("ActionList::kDestroyBarrier: Requested invalid object ID:0x%02X in Scene %d Line %d.", cmd->param1, _scene->getSceneIndex(),_currentLine);
+ error("[ActionList::kDestroyBarrier] Requested invalid object ID:0x%02X in Scene %d Line %d.", cmd->param1, _scene->getSceneIndex(),_currentLine);
- barrier->flags &= 0xFFFFFFFE;
+ barrier->destroy();
barrier->flags |= 0x20000;
+
_scene->vm()->screen()->deleteGraphicFromQueue(barrier->resId);
}
@@ -735,10 +725,9 @@ IMPLEMENT_OPCODE(JumpIfActorField638) {
//////////////////////////////////////////////////////////////////////////
// Opcode 0x2B
IMPLEMENT_OPCODE(ChangeScene) {
+ debug(kDebugLevelScripts, "Queueing Scene Change to scene %d...", _delayedSceneIndex);
+
_delayedSceneIndex = cmd->param1 + 4;
- debug(kDebugLevelScripts,
- "Queueing Scene Change to scene %d...",
- _delayedSceneIndex);
}
//////////////////////////////////////////////////////////////////////////
@@ -1181,7 +1170,7 @@ IMPLEMENT_OPCODE(_unk59) {
//////////////////////////////////////////////////////////////////////////
// Opcode 0x5A
IMPLEMENT_OPCODE(_unk5A) {
- error("Unhandled opcode %s (0x%02X) in Scene %d Line %d", _actions[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
+ _scene->getActor(cmd->param1)->actionIdx2 = cmd->param2;
}
//////////////////////////////////////////////////////////////////////////
@@ -1206,6 +1195,7 @@ IMPLEMENT_OPCODE(_unk5D) {
// Opcode 0x5E
IMPLEMENT_OPCODE(ClearActorField970) {
Actor *act = _scene->getActor(cmd->param1);
+
act->field_970 = 0;
}
diff --git a/engines/asylum/resources/actionlist.h b/engines/asylum/resources/actionlist.h
index 9860613a74..9caefe2943 100644
--- a/engines/asylum/resources/actionlist.h
+++ b/engines/asylum/resources/actionlist.h
@@ -48,9 +48,6 @@ namespace Asylum {
_actions.push_back(func); \
}
-#define GET_ACTOR() \
- Actor *actor = (cmd->param1 == -1) ? _scene->getActor() : &_scene->worldstats()->actors[cmd->param1];
-
class Scene;
class ActionList {
diff --git a/engines/asylum/resources/actor.cpp b/engines/asylum/resources/actor.cpp
index 5aa6dadb06..82e9a9464b 100644
--- a/engines/asylum/resources/actor.cpp
+++ b/engines/asylum/resources/actor.cpp
@@ -35,10 +35,10 @@
namespace Asylum {
-Actor::Actor() {
- _graphic = 0;
+Actor::Actor() : _currentWalkArea(NULL), _graphic(NULL), _resPack(NULL) {
currentAction = 0;
- _currentWalkArea = 0;
+
+ // TODO initialize other class variables
}
Actor::~Actor() {
@@ -47,11 +47,11 @@ Actor::~Actor() {
// free _resources?
}
-void Actor::visible(bool value) {
- if (value) // TODO - enums for flags (0x01 is visible)
- flags |= 0x01;
+void Actor::setVisible(bool value) {
+ if (value)
+ flags |= kVisible;
else
- flags &= 0xFFFFFFFE;
+ flags &= kHidden;
stopSound();
}
@@ -480,7 +480,7 @@ void Actor::updateStatus(ActorStatus actorStatus) {
case kActorStatusDisabled:
updateGraphicData(15);
- grResId = grResTable[(direction > 4 ? 8 - direction : direction) + 15];
+ graphicResourceId = grResTable[(direction > 4 ? 8 - direction : direction) + 15];
// TODO set word_446EE4 to -1. This global seems to be used with screen blitting
break;
@@ -495,8 +495,8 @@ void Actor::updateStatus(ActorStatus actorStatus) {
_scene->setActorIndex(0);
// Hide this actor and the show the other one
- visible(false);
- actor->visible(true);
+ setVisible(false);
+ actor->setVisible(true);
_scene->vm()->clearGameFlag(kGameFlag279);
@@ -528,25 +528,25 @@ void Actor::updateStatus(ActorStatus actorStatus) {
case kActorStatus18:
if (_scene->worldstats()->numChapter == 2) {
- GraphicResource *gra = new GraphicResource();
+ GraphicResource *resource = new GraphicResource();
frameNum = 0;
if (_index > 12)
- grResId = grResTable[direction + 30];
+ graphicResourceId = grResTable[direction + 30];
if (_scene->getActorIndex() == _index) {
- gra->load(_resPack, grResId);
- frameNum = gra->getFrameCount() - 1;
+ resource->load(_resPack, graphicResourceId);
+ frameNum = resource->getFrameCount() - 1;
}
if (_index == 11)
- grResId = grResTable[_scene->getGlobalDirection() > 4 ? 8 - _scene->getGlobalDirection() : _scene->getGlobalDirection()];
+ graphicResourceId = grResTable[_scene->getGlobalDirection() > 4 ? 8 - _scene->getGlobalDirection() : _scene->getGlobalDirection()];
// Reload the graphic resource if the resource ID has changed
- if (gra->getEntryNum() != grResId)
- gra->load(_resPack, grResId);
+ if (resource->getEntryNum() != graphicResourceId)
+ resource->load(_resPack, graphicResourceId);
- frameCount = gra->getFrameCount();
+ frameCount = resource->getFrameCount();
}
break;
}
@@ -555,11 +555,11 @@ void Actor::updateStatus(ActorStatus actorStatus) {
}
void Actor::updateGraphicData(uint32 offset) {
- grResId = grResTable[(direction > 4 ? 8 - direction : direction) + offset];
+ graphicResourceId = grResTable[(direction > 4 ? 8 - direction : direction) + offset];
- GraphicResource *gra = new GraphicResource(_resPack, grResId);
- frameCount = gra->getFrameCount();
- delete gra;
+ GraphicResource *resource = new GraphicResource(_resPack, graphicResourceId);
+ frameCount = resource->getFrameCount();
+ delete resource;
frameNum = 0;
}
@@ -610,7 +610,7 @@ void Actor::setDirection(int actorDirection) {
}
void Actor::update() {
- if (visible()) {
+ if (isVisible()) {
// printf("Actor updateType = 0x%02X\n", actor->updateType);
switch (status) {
@@ -722,7 +722,7 @@ void Actor::updateActorSub01() {
if (_scene->vm()->tempTick07) {
if (_scene->vm()->getTick() - _scene->vm()->tempTick07 > 500) {
if (_scene->vm()->isGameFlagNotSet(kGameFlagScriptProcessing)) { // processing action list
- if (visible()) {
+ if (isVisible()) {
// if some_encounter_flag
// if !soundResId04
if (_scene->vm()->getRandom(100) < 50) {
diff --git a/engines/asylum/resources/actor.h b/engines/asylum/resources/actor.h
index a1853102fd..3bde35cfc6 100644
--- a/engines/asylum/resources/actor.h
+++ b/engines/asylum/resources/actor.h
@@ -72,6 +72,11 @@ enum ActorType {
kAztec = 3
};
+enum ActorFlags {
+ kVisible = 0x01,
+ kHidden = 0xFFFFFFFE
+};
+
// TODO investigate other actor resources (from other
// scenes) to see if the unused blocks in the actor
// definition are in fact used elsewhere
@@ -177,11 +182,9 @@ public:
*/
void setRawResources(uint8* data);
- bool visible() {
- return flags & 0x01;
- }
-
- void visible(bool value);
+ // Visibility
+ bool isVisible() { return flags & kVisible; }
+ void setVisible(bool value);
/** .text:0040A260
* Initialize the x1/y1 values of the actor, update the active animation frame
@@ -228,7 +231,7 @@ public:
int32 x;
int32 y;
- uint32 grResId;
+ uint32 graphicResourceId;
int32 field_C; // BarrierIndex? Mask index?
uint32 frameNum;
uint32 frameCount;
@@ -301,9 +304,9 @@ private:
Scene *_scene;
int32 _resources[61];
- ResourcePack *_resPack;
- GraphicResource *_graphic;
ActionArea *_currentWalkArea;
+ GraphicResource *_graphic;
+ ResourcePack *_resPack;
// Our current index
ActorIndex _index;
diff --git a/engines/asylum/resources/barrier.cpp b/engines/asylum/resources/barrier.cpp
index 4657ef121e..03363047db 100644
--- a/engines/asylum/resources/barrier.cpp
+++ b/engines/asylum/resources/barrier.cpp
@@ -36,6 +36,10 @@ Barrier::~Barrier() {
// TODO Auto-generated destructor stub
}
+void Barrier::destroy() {
+ flags &= 0xFFFFFFFE;
+}
+
int32 Barrier::getRandomId() {
int32 numRes = 0;
int32 rndResId[5];
diff --git a/engines/asylum/resources/barrier.h b/engines/asylum/resources/barrier.h
index 5e602fddfc..84045b2563 100644
--- a/engines/asylum/resources/barrier.h
+++ b/engines/asylum/resources/barrier.h
@@ -37,6 +37,8 @@ public:
Barrier();
virtual ~Barrier();
+ void destroy();
+
bool visible();
int32 getRandomId(); // TODO Give this a better name?
bool onscreen();
diff --git a/engines/asylum/resources/worldstats.cpp b/engines/asylum/resources/worldstats.cpp
index 657d4bf3a4..942509ceb2 100644
--- a/engines/asylum/resources/worldstats.cpp
+++ b/engines/asylum/resources/worldstats.cpp
@@ -302,7 +302,7 @@ void WorldStats::load(Common::SeekableReadStream *stream) {
actor.x = stream->readSint32LE();
actor.y = stream->readSint32LE();
- actor.grResId = stream->readSint32LE();
+ actor.graphicResourceId = stream->readSint32LE();
actor.field_C = stream->readSint32LE();
actor.frameNum = stream->readSint32LE();
actor.frameCount = stream->readSint32LE();
diff --git a/engines/asylum/views/scene.cpp b/engines/asylum/views/scene.cpp
index b6ee2c1ef9..29f589575b 100644
--- a/engines/asylum/views/scene.cpp
+++ b/engines/asylum/views/scene.cpp
@@ -736,7 +736,7 @@ bool Scene::hitTestActor(const Common::Point pt) {
else
hitFrame = act->frameNum;
- return hitTestPixel(act->grResId,
+ return hitTestPixel(act->graphicResourceId,
hitFrame,
pt.x - act->x - actPos.x,
pt.y - act->y - actPos.y,
@@ -1297,7 +1297,7 @@ int Scene::queueActorUpdates() {
} else {
// TODO: get flag value from character_DeadSarah_sub_40A140
- _vm->screen()->addGraphicToQueue(actor->grResId, frameNum, pt.x, pt.y, ((actor->direction < 5) - 1) & 2, actor->field_96C, actor->priority);
+ _vm->screen()->addGraphicToQueue(actor->graphicResourceId, frameNum, pt.x, pt.y, ((actor->direction < 5) - 1) & 2, actor->field_96C, actor->priority);
}
}
}
Commit: 3935d274fa17cd37e7644136083e2f96279d6c6b
https://github.com/scummvm/scummvm/commit/3935d274fa17cd37e7644136083e2f96279d6c6b
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:06+02:00
Commit Message:
ASYLUM: Cleanup ActionList and implement more opcodes
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@467 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/asylum.h
engines/asylum/console.cpp
engines/asylum/resources/actionarea.h
engines/asylum/resources/actionlist.cpp
engines/asylum/resources/actionlist.h
engines/asylum/resources/actor.cpp
engines/asylum/resources/actor.h
engines/asylum/resources/barrier.cpp
engines/asylum/resources/barrier.h
engines/asylum/resources/worldstats.cpp
engines/asylum/resources/worldstats.h
engines/asylum/shared.h
engines/asylum/system/graphics.h
engines/asylum/system/screen.cpp
engines/asylum/system/screen.h
engines/asylum/system/sound.cpp
engines/asylum/system/sound.h
engines/asylum/views/scene.cpp
engines/asylum/views/scene.h
diff --git a/engines/asylum/asylum.h b/engines/asylum/asylum.h
index 4ad134ad8e..b017bdccd5 100644
--- a/engines/asylum/asylum.h
+++ b/engines/asylum/asylum.h
@@ -86,7 +86,9 @@ namespace Asylum {
// Flags
enum FlagType {
kFlagType1 = 0,
- kFlagType2
+ kFlagType2,
+ kFlagTypeSkipDraw,
+ kFlagTypeSceneRectChanged
};
class Encounter;
@@ -166,7 +168,7 @@ private:
bool _introPlaying;
int _gameFlags[1512];
- bool _flags[2];
+ bool _flags[4];
void handleEvents(bool doUpdate);
void waitForTimer(int msec_delay);
diff --git a/engines/asylum/console.cpp b/engines/asylum/console.cpp
index b3bf547d39..87af0f8832 100644
--- a/engines/asylum/console.cpp
+++ b/engines/asylum/console.cpp
@@ -64,7 +64,7 @@ bool Console::cmdDumpActionArea(int32 argc, const char **argv) {
// TODO Get an action area by index/id
} else {
for (int32 i = 0; i < _vm->scene()->worldstats()->numActions; i++) {
- ActionArea *a = &_vm->scene()->worldstats()->actions[i];
+ ActionArea *a = _vm->scene()->worldstats()->actions[i];
printActionAreaStats(a);
}
}
@@ -83,7 +83,7 @@ void Console::printActionAreaStats(ActionArea *a) {
a->field_40,
a->field_44,
a->flags,
- a->actionListIdx1,
+ a->scriptIndex,
a->actionListIdx2,
a->actionType,
//a->flagNums[10],
diff --git a/engines/asylum/resources/actionarea.h b/engines/asylum/resources/actionarea.h
index d263d67c61..aa872b9dd0 100644
--- a/engines/asylum/resources/actionarea.h
+++ b/engines/asylum/resources/actionarea.h
@@ -42,7 +42,7 @@ public:
int32 field_40;
int32 field_44;
int32 flags;
- int32 actionListIdx1;
+ int32 scriptIndex;
int32 actionListIdx2;
int32 actionType; // aka flags2: 0-none, 1-findwhat, 2-talk, 3-findwhat??, 4-grab
int32 flagNums[10];
diff --git a/engines/asylum/resources/actionlist.cpp b/engines/asylum/resources/actionlist.cpp
index f35b0e9791..f79942900e 100644
--- a/engines/asylum/resources/actionlist.cpp
+++ b/engines/asylum/resources/actionlist.cpp
@@ -27,11 +27,11 @@
#include "asylum/system/config.h"
-namespace Asylum {
+#include "common/rational.h"
-ActionList::ActionList(Common::SeekableReadStream *stream, Scene *scene)
- : _scene(scene) {
+namespace Asylum {
+ActionList::ActionList(Common::SeekableReadStream *stream, Scene *scene) : _scene(scene) {
// Build list of opcodes
ADD_OPCODE(Return);
ADD_OPCODE(SetGameFlag);
@@ -86,21 +86,21 @@ ActionList::ActionList(Common::SeekableReadStream *stream, Scene *scene)
ADD_OPCODE(ChangeMusicById);
ADD_OPCODE(StopMusic);
ADD_OPCODE(_unk34_Status);
- ADD_OPCODE(_unk35);
- ADD_OPCODE(_unk36);
+ ADD_OPCODE(SetVolume);
+ ADD_OPCODE(Jump);
ADD_OPCODE(RunBlowUpPuzzle);
ADD_OPCODE(JumpIfFlag2Bit3);
ADD_OPCODE(SetFlag2Bit3);
ADD_OPCODE(ClearFlag2Bit3);
ADD_OPCODE(_unk3B_PALETTE_MOD);
- ADD_OPCODE(_unk3C_CMP_VAL);
+ ADD_OPCODE(IncrementParam2);
ADD_OPCODE(WaitUntilFramePlayed);
ADD_OPCODE(UpdateWideScreen);
- ADD_OPCODE(_unk3F);
+ ADD_OPCODE(JumpIfActor);
ADD_OPCODE(_unk40_SOUND);
ADD_OPCODE(PlaySpeech);
ADD_OPCODE(_unk42);
- ADD_OPCODE(_unk43);
+ ADD_OPCODE(MoveScenePositionFromActor);
ADD_OPCODE(PaletteFade);
ADD_OPCODE(StartPaletteFadeThread);
ADD_OPCODE(_unk46);
@@ -108,15 +108,15 @@ ActionList::ActionList(Common::SeekableReadStream *stream, Scene *scene)
ADD_OPCODE(_unk48_MATTE_01);
ADD_OPCODE(_unk49_MATTE_90);
ADD_OPCODE(JumpIfSoundPlaying);
- ADD_OPCODE(ChangePlayerCharacterIndex);
+ ADD_OPCODE(ChangePlayerActorIndex);
ADD_OPCODE(ChangeActorStatus);
ADD_OPCODE(StopSound);
ADD_OPCODE(_unk4E_RANDOM_COMMAND);
ADD_OPCODE(ClearScreen);
ADD_OPCODE(Quit);
ADD_OPCODE(JumpBarrierFrame);
- ADD_OPCODE(_unk52);
- ADD_OPCODE(_unk53);
+ ADD_OPCODE(DeleteGraphics);
+ ADD_OPCODE(DeleteGraphics);
ADD_OPCODE(_unk54_SET_ACTIONLIST_6EC);
ADD_OPCODE(_unk55);
ADD_OPCODE(_unk56);
@@ -125,7 +125,7 @@ ActionList::ActionList(Common::SeekableReadStream *stream, Scene *scene)
ADD_OPCODE(_unk59);
ADD_OPCODE(_unk5A);
ADD_OPCODE(_unk5B);
- ADD_OPCODE(_unk5C);
+ ADD_OPCODE(QueueScript);
ADD_OPCODE(_unk5D);
ADD_OPCODE(ClearActorField970);
ADD_OPCODE(SetBarrierLastFrameIdx);
@@ -134,53 +134,62 @@ ActionList::ActionList(Common::SeekableReadStream *stream, Scene *scene)
ADD_OPCODE(_unk62_SHOW_OPTIONS_SCREEN);
ADD_OPCODE(_unk63);
+ // Reset script queue
+ resetQueue();
+
+ // Load data
load(stream);
- _currentScript = 0;
+ _skipProcessing = false;
_currentLine = 0;
_currentLoops = 0;
+ _currentScript = NULL;
_delayedSceneIndex = -1;
_delayedVideoIndex = -1;
- _allowInput = true;
- _skipProcessing = false;
-
- // Reset script queue
- _scripts.clear();
+ _done = false;
+ _exit = false;
+ _lineIncrement = 0;
+ _waitCycle = false;
}
ActionList::~ActionList() {
- for (int i = 0; i < (int)_actions.size(); i++)
- delete _actions[i];
+ for (int i = 0; i < (int)_opcodes.size(); i++)
+ delete _opcodes[i];
- _entries.clear();
_scripts.clear();
+ _queue.clear();
// Zero-out passed pointers
_scene = NULL;
}
-void ActionList::queueScript(int actionIndex, int actorIndex) {
+void ActionList::resetQueue() {
+ _queue.clear();
+}
+
+void ActionList::queueScript(int scriptIndex, ActorIndex actorIndex) {
// When the skipProcessing flag is set, do not queue any more scripts
if (_skipProcessing)
return;
ScriptQueueEntry entry;
- entry.actionListIndex = actionIndex;
- entry.actorIndex = actorIndex;
+ entry.scriptIndex = scriptIndex;
+ entry.actorIndex = actorIndex;
// If there's currently no script for the processor to run,
// assign it directly and skip the stack push. If however the
// current script is assigned, push the script to the stack
if (_currentScript)
- _scripts.push(entry);
+ _queue.push(entry);
else {
_currentQueueEntry = entry;
- _currentScript = &_entries[entry.actionListIndex];
+ _currentScript = &_scripts[entry.scriptIndex];
}
}
bool ActionList::process() {
_done = false;
+ _exit = false;
_waitCycle = false;
_lineIncrement = 1;
@@ -195,12 +204,15 @@ bool ActionList::process() {
int32 opcode = cmd->opcode;
debugC(kDebugLevelScripts, "[0x%02X] %s(%d, %d, %d, %d, %d, %d, %d, %d, %d)",
- opcode, _actions[opcode]->name,
+ opcode, _opcodes[opcode]->name,
cmd->param1, cmd->param2, cmd->param3, cmd->param4, cmd->param5,
cmd->param6, cmd->param7, cmd->param8, cmd->param9);
// Execute opcode
- (*_actions[opcode]->func)(cmd);
+ (*_opcodes[opcode]->func)(cmd);
+
+ if (_exit)
+ return true;
if (!_lineIncrement)
_currentLine ++;
@@ -209,11 +221,11 @@ bool ActionList::process() {
if (_done) {
_currentLine = 0;
- if (!_scripts.empty()) {
- _currentQueueEntry = _scripts.pop();
- _currentScript = &_entries[_currentQueueEntry.actionListIndex];
+ if (!_queue.empty()) {
+ _currentQueueEntry = _queue.pop();
+ _currentScript = &_scripts[_currentQueueEntry.scriptIndex];
} else {
- _currentScript = 0;
+ _currentScript = NULL;
}
}
}
@@ -228,8 +240,8 @@ void ActionList::load(Common::SeekableReadStream *stream) {
int32 numEntries = stream->readSint32LE();
for (int32 a = 0; a < numEntries; a++) {
- Script action;
- memset(&action, 0, sizeof(Script));
+ Script script;
+ memset(&script, 0, sizeof(Script));
for (int32 c = 0; c < MAX_ACTION_COMMANDS; c++) {
ScriptEntry command;
@@ -247,14 +259,14 @@ void ActionList::load(Common::SeekableReadStream *stream) {
command.param8 = stream->readSint32LE();
command.param9 = stream->readSint32LE();
- action.commands[c] = command;
+ script.commands[c] = command;
}
- action.field_1BAC = stream->readSint32LE();
- action.field_1BB0 = stream->readSint32LE();
- action.counter = stream->readSint32LE();
+ script.field_1BAC = stream->readSint32LE();
+ script.field_1BB0 = stream->readSint32LE();
+ script.counter = stream->readSint32LE();
- _entries.push_back(action);
+ _scripts.push_back(script);
}
}
@@ -300,29 +312,32 @@ IMPLEMENT_OPCODE(ToggleGameFlag) {
//////////////////////////////////////////////////////////////////////////
// Opcode 0x04
IMPLEMENT_OPCODE(JumpIfGameFlag) {
- GameFlag flagNum = (GameFlag)cmd->param1;
+ if (cmd->param1 < 0)
+ return;
- if (flagNum) {
- bool doJump = _scene->vm()->isGameFlagSet(flagNum);
- if (cmd->param2)
- doJump = _scene->vm()->isGameFlagNotSet(flagNum);
- if (doJump)
- _currentLine = cmd->param3;
+ bool doJump = (cmd->param2) ? _scene->vm()->isGameFlagSet((GameFlag)cmd->param1) : _scene->vm()->isGameFlagNotSet((GameFlag)cmd->param1);
+ if (!doJump)
+ return;
+
+ int32 nextOpcode = _currentScript->commands[_currentLine].opcode;
+ if (nextOpcode != 0x10 && nextOpcode != 0) {
+ error("Incomplete opcode %s (0x%02X) in Scene %d Line %d", _opcodes[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
+ return;
}
+
+ _currentLine = cmd->param3;
}
//////////////////////////////////////////////////////////////////////////
// Opcode 0x05
IMPLEMENT_OPCODE(HideCursor) {
_scene->getCursor()->hide();
- _allowInput = false;
}
//////////////////////////////////////////////////////////////////////////
// Opcode 0x06
IMPLEMENT_OPCODE(ShowCursor) {
_scene->getCursor()->show();
- _allowInput = true;
_scene->vm()->clearFlag(kFlagType1);
}
@@ -333,51 +348,42 @@ IMPLEMENT_OPCODE(PlayAnimation) {
Barrier *barrier = _scene->worldstats()->getBarrierById(cmd->param1);
if (cmd->param2 == 2) {
- if (!barrier->checkFlags())
+ if (barrier->checkFlags())
+ _lineIncrement = 1;
+ else
cmd->param2 = 1;
- _lineIncrement = 1;
-
return;
}
// Update flags
if (cmd->param4) {
- barrier->flags &= 0xFFFEF1C7;
- barrier->flags |= 0x20;
+ barrier->flags &= kBarrierFlagFFFEF1C7;
+ barrier->flags |= kBarrierFlag20;
} else if (cmd->param3) {
- barrier->flags &= 0xFFFEF1C7;
- barrier->flags |= 0x10000;
- // FIXME: This should be the correct code but this causes a regression
- // Investigate barrier drawing to see if there is some wrong code there
- //} else if (barrier->flags & 0x10000) {
- // barrier->flags |= 8;
- // barrier->flags &= 0xFFFEFFFF;
- //} else if (!(barrier->flags & 0x10E38)) {
- // barrier->flags |= 8;
- //}
- } else {
- barrier->flags &= 0x10000;
- if (barrier->flags == 0) {
- barrier->flags &= 0x10E38;
- if (barrier->flags == 0) {
- barrier->flags |= 8;
- }
- } else {
- barrier->flags |= 8;
- barrier->flags &= 0xFFFEFFFF;
- }
+ barrier->flags &= kBarrierFlagFFFEF1C7;
+ barrier->flags |= kBarrierFlag10000;
+ } else if (barrier->flags & kBarrierFlag10000) {
+ barrier->flags |= kBarrierFlag8;
+ barrier->flags &= kBarrierFlagFFFEFFFF;
+ } else if (!(barrier->flags & kBarrierFlag10E38)) {
+ barrier->flags |= kBarrierFlag8;
}
barrier->setNextFrame(barrier->flags);
if (barrier->field_688 == 1) {
- if (barrier->flags & 4) {
+ if (barrier->flags & kBarrierFlag4) {
_scene->setGlobalX(barrier->x);
_scene->setGlobalY(barrier->y);
} else {
- // TODO: get barrier position
- error("Incomplete opcode %s (0x%02X) in Scene %d Line %d", _actions[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
+ GraphicResource *res = new GraphicResource(_scene->getResourcePack(), barrier->resId);
+ GraphicFrame *frame = res->getFrame(barrier->frameIdx);
+
+ _scene->setGlobalX(frame->x + (frame->getWidth() >> 1) + barrier->x);
+ _scene->setGlobalY(frame->y + (frame->getHeight() >> 1) + barrier->y);
+
+ delete res;
}
}
@@ -390,57 +396,34 @@ IMPLEMENT_OPCODE(PlayAnimation) {
//////////////////////////////////////////////////////////////////////////
// Opcode 0x08
IMPLEMENT_OPCODE(MoveScenePosition) {
- WorldStats *ws = _scene->worldstats();
- Common::Rect *sr = &ws->sceneRects[ws->sceneRectIdx];
-
if (cmd->param3 < 1) {
- ws->xLeft = cmd->param1;
- ws->yTop = cmd->param2;
- ws->motionStatus = 3;
+ _scene->worldstats()->xLeft = cmd->param1;
+ _scene->worldstats()->yTop = cmd->param2;
+ _scene->worldstats()->motionStatus = 3;
+
} else if (!cmd->param4) {
- ws->motionStatus = 5;
- ws->targetX = cmd->param1;
- ws->targetY = cmd->param2;
- ws->field_A0 = cmd->param3;
-
- if (ws->targetX < sr->left)
- ws->targetX = sr->left;
- if (ws->targetY < sr->top)
- ws->targetY = sr->top;
- if (ws->targetX + 640 > sr->right)
- ws->targetX = sr->right - 640;
- if (ws->targetY + 480 > sr->bottom)
- ws->targetY = sr->bottom - 480;
-
- // TODO: reverse asm block
+ _scene->worldstats()->motionStatus = 5;
+
+ _scene->updateSceneCoordinates(cmd->param1,
+ cmd->param2,
+ cmd->param3);
} else if (cmd->param5) {
- if (ws->motionStatus == 2)
+ if (_scene->worldstats()->motionStatus == 2)
_lineIncrement = 1;
else
cmd->param5 = 0;
} else {
cmd->param5 = 1;
- ws->motionStatus = 2;
- ws->targetX = cmd->param1;
- ws->targetY = cmd->param2;
- ws->field_A0 = cmd->param3;
-
- if (ws->targetX + 640 > (int)ws->width)
- ws->targetX = ws->width - 640;
- if (ws->targetX < sr->left)
- ws->targetX = sr->left;
- if (ws->targetY < sr->top)
- ws->targetY = sr->top;
- if (ws->targetX + 640 > sr->right)
- ws->targetX = sr->right - 640;
- if (ws->targetY + 480 > sr->bottom)
- ws->targetY = sr->bottom - 480;
-
- // TODO: reverse asm block
- }
+ _scene->worldstats()->motionStatus = 2;
- error("Incomplete opcode %s (0x%02X) in Scene %d Line %d", _actions[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
+ _scene->updateSceneCoordinates(cmd->param1,
+ cmd->param2,
+ cmd->param3,
+ true);
+
+ _lineIncrement = 1;
+ }
}
//////////////////////////////////////////////////////////////////////////
@@ -459,7 +442,7 @@ IMPLEMENT_OPCODE(ShowActor) {
actor->setVisible(true);
actor->updateDirection();
- actor->tickValue1 = _scene->vm()->getTick();
+ actor->tickValue = _scene->vm()->getTick();
}
//////////////////////////////////////////////////////////////////////////
@@ -496,37 +479,27 @@ IMPLEMENT_OPCODE(EnableActor) {
//////////////////////////////////////////////////////////////////////////
// Opcode 0x0F
IMPLEMENT_OPCODE(EnableBarriers) {
- int32 barIdx = _scene->worldstats()->getBarrierIndexById(cmd->param1);
- Barrier *bar = &_scene->worldstats()->barriers[barIdx];
- int32 sndIdx = cmd->param3;
-
- if (!_currentScript->counter && _scene->getSceneIndex() != 13 && sndIdx != 0) {
- // FIXME: I really don't understand what (sndIdx != 0) & 5 is supposed to be doing here,
- // but this is effectively trying to do a boolean AND operation on a boolean variable
- // which is odd, and wrong. Changing it to (sndIdx & 5), for now
- //_scene->vm()->sound()->playSound(((sndIdx != 0) & 5) + 0x80120001,
- _scene->vm()->sound()->playSound((sndIdx & 5) + 0x80120001, false, Config.sfxVolume, 0);
- }
+ Barrier *barrier = _scene->worldstats()->getBarrierById(cmd->param1);
+
+ if (!_currentScript->counter && _scene->worldstats()->numChapter != 13)
+ _scene->vm()->sound()->playSound(cmd->param3 ? kResourceSound_80120006 : kResourceSound_80120001, false, Config.sfxVolume, 0);
if (_currentScript->counter >= (3 * cmd->param2 - 1)) {
_currentScript->counter = 0;
- bar->field_67C = 0;
- // TODO processActionListSub02(_currentScript, cmd, 2);
+ barrier->field_67C = 0;
+ enableBarrier(cmd, kBarrierEnableType2);
} else {
- int v64; // XXX rename when processActionListSub02 is better implemented
- _currentScript->counter += 1;
- if (sndIdx) {
- v64 = 1;
- bar->field_67C = 3 - _currentScript->counter / cmd->param2;
+ ++_currentScript->counter;
+ if (cmd->param3) {
+ barrier->field_67C = 3 - _currentScript->counter / cmd->param2;
+ enableBarrier(cmd, kBarrierEnableType1);
} else {
- v64 = 0;
- bar->field_67C = _currentScript->counter / cmd->param2 + 1;
+ barrier->field_67C = _currentScript->counter / cmd->param2 + 1;
+ enableBarrier(cmd, kBarrierEnableType0);
}
- // TODO processActionListSub02(_currentScript, cmd, v64);
+ _lineIncrement = 1;
}
-
- error("Incomplete opcode %s (0x%02X) in Scene %d Line %d", _actions[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
}
//////////////////////////////////////////////////////////////////////////
@@ -535,38 +508,36 @@ IMPLEMENT_OPCODE(EnableBarriers) {
//////////////////////////////////////////////////////////////////////////
// Opcode 0x11
IMPLEMENT_OPCODE(DestroyBarrier) {
- Barrier *barrier = _scene->worldstats()->getBarrierById(cmd->param1);
- if (!barrier)
- error("[ActionList::kDestroyBarrier] Requested invalid object ID:0x%02X in Scene %d Line %d.", cmd->param1, _scene->getSceneIndex(),_currentLine);
+ if (!cmd->param1)
+ return;
- barrier->destroy();
- barrier->flags |= 0x20000;
+ Barrier *barrier = _scene->worldstats()->getBarrierById(cmd->param1);
- _scene->vm()->screen()->deleteGraphicFromQueue(barrier->resId);
+ barrier->destroyAndRemoveFromQueue();
}
//////////////////////////////////////////////////////////////////////////
// Opcode 0x12
IMPLEMENT_OPCODE(_unk12_JMP_WALK_ACTOR) {
- error("Unhandled opcode %s (0x%02X) in Scene %d Line %d", _actions[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
+ error("Unhandled opcode %s (0x%02X) in Scene %d Line %d", _opcodes[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
}
//////////////////////////////////////////////////////////////////////////
// Opcode 0x13
IMPLEMENT_OPCODE(_unk13_JMP_WALK_ACTOR) {
- error("Unhandled opcode %s (0x%02X) in Scene %d Line %d", _actions[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
+ error("Unhandled opcode %s (0x%02X) in Scene %d Line %d", _opcodes[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
}
//////////////////////////////////////////////////////////////////////////
// Opcode 0x14
IMPLEMENT_OPCODE(_unk14_JMP_WALK_ACTOR) {
- error("Unhandled opcode %s (0x%02X) in Scene %d Line %d", _actions[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
+ error("Unhandled opcode %s (0x%02X) in Scene %d Line %d", _opcodes[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
}
//////////////////////////////////////////////////////////////////////////
// Opcode 0x15
IMPLEMENT_OPCODE(_unk15) {
- error("Unhandled opcode %s (0x%02X) in Scene %d Line %d", _actions[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
+ error("Unhandled opcode %s (0x%02X) in Scene %d Line %d", _opcodes[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
}
//////////////////////////////////////////////////////////////////////////
@@ -591,7 +562,7 @@ IMPLEMENT_OPCODE(ClearFlag1Bit0) {
//////////////////////////////////////////////////////////////////////////
// Opcode 0x18
IMPLEMENT_OPCODE(_unk18_PLAY_SND) {
- error("Unhandled opcode %s (0x%02X) in Scene %d Line %d", _actions[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
+ error("Unhandled opcode %s (0x%02X) in Scene %d Line %d", _opcodes[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
}
//////////////////////////////////////////////////////////////////////////
@@ -599,7 +570,7 @@ IMPLEMENT_OPCODE(_unk18_PLAY_SND) {
IMPLEMENT_OPCODE(JumpIfFlag2Bit0) {
int targetType = cmd->param2;
- error("Incomplete opcode %s (0x%02X) in Scene %d Line %d", _actions[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
+ error("Incomplete opcode %s (0x%02X) in Scene %d Line %d", _opcodes[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
// TODO targetType == 7 is trying to access an out of bounds actor
// look at the disassembly again
@@ -609,7 +580,7 @@ IMPLEMENT_OPCODE(JumpIfFlag2Bit0) {
if (targetType == 1) // v4 == 1, so 1
_done = (_scene->worldstats()->getActionAreaById(cmd->param1)->actionType & 1) == 0;
else
- _done = (_scene->worldstats()->actors[cmd->param1].flags2 & 1) == 0;
+ _done = (_scene->worldstats()->actors[cmd->param1]->flags2 & 1) == 0;
}
//////////////////////////////////////////////////////////////////////////
@@ -618,7 +589,7 @@ IMPLEMENT_OPCODE(SetFlag2Bit0) {
int targetType = cmd->param2;
if (targetType == 2)
- _scene->worldstats()->actors[cmd->param1].flags2 |= 1;
+ _scene->worldstats()->actors[cmd->param1]->flags2 |= 1;
else
if (targetType == 1)
_scene->worldstats()->getActionAreaById(cmd->param1)->actionType |= 1;
@@ -629,97 +600,97 @@ IMPLEMENT_OPCODE(SetFlag2Bit0) {
//////////////////////////////////////////////////////////////////////////
// Opcode 0x1B
IMPLEMENT_OPCODE(ClearFlag2Bit0) {
- error("Unhandled opcode %s (0x%02X) in Scene %d Line %d", _actions[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
+ error("Unhandled opcode %s (0x%02X) in Scene %d Line %d", _opcodes[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
}
//////////////////////////////////////////////////////////////////////////
// Opcode 0x1C
IMPLEMENT_OPCODE(JumpIfFlag2Bit2) {
- error("Unhandled opcode %s (0x%02X) in Scene %d Line %d", _actions[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
+ error("Unhandled opcode %s (0x%02X) in Scene %d Line %d", _opcodes[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
}
//////////////////////////////////////////////////////////////////////////
// Opcode 0x1D
IMPLEMENT_OPCODE(SetFlag2Bit2) {
- error("Unhandled opcode %s (0x%02X) in Scene %d Line %d", _actions[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
+ error("Unhandled opcode %s (0x%02X) in Scene %d Line %d", _opcodes[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
}
//////////////////////////////////////////////////////////////////////////
// Opcode 0x1E
IMPLEMENT_OPCODE(ClearFlag2Bit2) {
- error("Unhandled opcode %s (0x%02X) in Scene %d Line %d", _actions[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
+ error("Unhandled opcode %s (0x%02X) in Scene %d Line %d", _opcodes[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
}
//////////////////////////////////////////////////////////////////////////
// Opcode 0x1F
IMPLEMENT_OPCODE(JumpIfFlag2Bit1) {
- error("Unhandled opcode %s (0x%02X) in Scene %d Line %d", _actions[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
+ error("Unhandled opcode %s (0x%02X) in Scene %d Line %d", _opcodes[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
}
//////////////////////////////////////////////////////////////////////////
// Opcode 0x20
IMPLEMENT_OPCODE(SetFlag2Bit1) {
- error("Unhandled opcode %s (0x%02X) in Scene %d Line %d", _actions[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
+ error("Unhandled opcode %s (0x%02X) in Scene %d Line %d", _opcodes[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
}
//////////////////////////////////////////////////////////////////////////
// Opcode 0x21
IMPLEMENT_OPCODE(ClearFlag2Bit1) {
- error("Unhandled opcode %s (0x%02X) in Scene %d Line %d", _actions[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
+ error("Unhandled opcode %s (0x%02X) in Scene %d Line %d", _opcodes[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
}
//////////////////////////////////////////////////////////////////////////
// Opcode 0x22
IMPLEMENT_OPCODE(_unk22) {
- error("Unhandled opcode %s (0x%02X) in Scene %d Line %d", _actions[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
+ error("Unhandled opcode %s (0x%02X) in Scene %d Line %d", _opcodes[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
}
//////////////////////////////////////////////////////////////////////////
// Opcode 0x23
IMPLEMENT_OPCODE(_unk23) {
- error("Unhandled opcode %s (0x%02X) in Scene %d Line %d", _actions[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
+ error("Unhandled opcode %s (0x%02X) in Scene %d Line %d", _opcodes[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
}
//////////////////////////////////////////////////////////////////////////
// Opcode 0x24
IMPLEMENT_OPCODE(_unk24) {
- error("Unhandled opcode %s (0x%02X) in Scene %d Line %d", _actions[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
+ error("Unhandled opcode %s (0x%02X) in Scene %d Line %d", _opcodes[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
}
//////////////////////////////////////////////////////////////////////////
// Opcode 0x25
IMPLEMENT_OPCODE(RunEncounter) {
- error("Unhandled opcode %s (0x%02X) in Scene %d Line %d", _actions[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
+ error("Unhandled opcode %s (0x%02X) in Scene %d Line %d", _opcodes[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
}
//////////////////////////////////////////////////////////////////////////
// Opcode 0x26
IMPLEMENT_OPCODE(JumpIfFlag2Bit4) {
- error("Unhandled opcode %s (0x%02X) in Scene %d Line %d", _actions[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
+ error("Unhandled opcode %s (0x%02X) in Scene %d Line %d", _opcodes[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
}
//////////////////////////////////////////////////////////////////////////
// Opcode 0x27
IMPLEMENT_OPCODE(SetFlag2Bit4) {
- error("Unhandled opcode %s (0x%02X) in Scene %d Line %d", _actions[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
+ error("Unhandled opcode %s (0x%02X) in Scene %d Line %d", _opcodes[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
}
//////////////////////////////////////////////////////////////////////////
// Opcode 0x28
IMPLEMENT_OPCODE(ClearFlag2Bit4) {
- error("Unhandled opcode %s (0x%02X) in Scene %d Line %d", _actions[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
+ error("Unhandled opcode %s (0x%02X) in Scene %d Line %d", _opcodes[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
}
//////////////////////////////////////////////////////////////////////////
// Opcode 0x29
IMPLEMENT_OPCODE(SetActorField638) {
- error("Unhandled opcode %s (0x%02X) in Scene %d Line %d", _actions[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
+ error("Unhandled opcode %s (0x%02X) in Scene %d Line %d", _opcodes[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
}
//////////////////////////////////////////////////////////////////////////
// Opcode 0x2A
IMPLEMENT_OPCODE(JumpIfActorField638) {
- error("Unhandled opcode %s (0x%02X) in Scene %d Line %d", _actions[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
+ error("Unhandled opcode %s (0x%02X) in Scene %d Line %d", _opcodes[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
}
//////////////////////////////////////////////////////////////////////////
@@ -727,13 +698,15 @@ IMPLEMENT_OPCODE(JumpIfActorField638) {
IMPLEMENT_OPCODE(ChangeScene) {
debug(kDebugLevelScripts, "Queueing Scene Change to scene %d...", _delayedSceneIndex);
+ error("Unhandled opcode %s (0x%02X) in Scene %d Line %d", _opcodes[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
+
_delayedSceneIndex = cmd->param1 + 4;
}
//////////////////////////////////////////////////////////////////////////
// Opcode 0x2C
IMPLEMENT_OPCODE(_unk2C_ActorSub) {
- error("Unhandled opcode %s (0x%02X) in Scene %d Line %d", _actions[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
+ error("Unhandled opcode %s (0x%02X) in Scene %d Line %d", _opcodes[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
}
//////////////////////////////////////////////////////////////////////////
@@ -742,7 +715,7 @@ IMPLEMENT_OPCODE(PlayMovie) {
// TODO: add missing code here
_delayedVideoIndex = cmd->param1;
- error("Incomplete opcode %s (0x%02X) in Scene %d Line %d", _actions[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
+ error("Incomplete opcode %s (0x%02X) in Scene %d Line %d", _opcodes[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
}
//////////////////////////////////////////////////////////////////////////
@@ -751,7 +724,7 @@ IMPLEMENT_OPCODE(StopAllBarriersSounds) {
// TODO: do this for all barriers that have sfx playing
_scene->vm()->sound()->stopAllSounds();
- error("Incomplete opcode %s (0x%02X) in Scene %d Line %d", _actions[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
+ error("Incomplete opcode %s (0x%02X) in Scene %d Line %d", _opcodes[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
}
//////////////////////////////////////////////////////////////////////////
@@ -769,13 +742,18 @@ IMPLEMENT_OPCODE(ResumeProcessing) {
//////////////////////////////////////////////////////////////////////////
// Opcode 0x31
IMPLEMENT_OPCODE(ResetSceneRect) {
- error("Unhandled opcode %s (0x%02X) in Scene %d Line %d", _actions[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
+ _scene->worldstats()->sceneRectIdx = LOBYTE(cmd->param1);
+ _scene->vm()->screen()->palFade(0, 25, 10);
+ _scene->vm()->setFlag(kFlagTypeSceneRectChanged);
+
+ _scene->worldstats()->xLeft = _scene->worldstats()->sceneRects[_scene->worldstats()->sceneRectIdx].left;
+ _scene->worldstats()->yTop = _scene->worldstats()->sceneRects[_scene->worldstats()->sceneRectIdx].top;
}
//////////////////////////////////////////////////////////////////////////
// Opcode 0x32
IMPLEMENT_OPCODE(ChangeMusicById) {
- error("Unhandled opcode %s (0x%02X) in Scene %d Line %d", _actions[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
+ error("Unhandled opcode %s (0x%02X) in Scene %d Line %d", _opcodes[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
}
//////////////////////////////////////////////////////////////////////////
@@ -797,55 +775,67 @@ IMPLEMENT_OPCODE(_unk34_Status) {
//////////////////////////////////////////////////////////////////////////
// Opcode 0x35
-IMPLEMENT_OPCODE(_unk35) {
- error("Unhandled opcode %s (0x%02X) in Scene %d Line %d", _actions[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
+IMPLEMENT_OPCODE(SetVolume) {
+ AmbientSoundItem item = _scene->worldstats()->ambientSounds[cmd->param1];
+ int var = cmd->param2 + item.field_C;
+
+ double volume = -((Config.sfxVolume + var) * (Config.ambientVolume + var));
+
+ if (volume < 0) {
+ if (volume < -10000)
+ volume = -10000;
+ } else {
+ volume = 0;
+ }
+
+ _scene->vm()->sound()->setVolume(item.resId, volume);
}
//////////////////////////////////////////////////////////////////////////
// Opcode 0x36
-IMPLEMENT_OPCODE(_unk36) {
- error("Unhandled opcode %s (0x%02X) in Scene %d Line %d", _actions[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
+IMPLEMENT_OPCODE(Jump) {
+ _currentLine = cmd->param1 - 1;
}
//////////////////////////////////////////////////////////////////////////
// Opcode 0x37
IMPLEMENT_OPCODE(RunBlowUpPuzzle) {
- // FIXME: improve this to call other blowUpPuzzles than VCR
- //int puzzleIdx = cmd->param1;
- warning("kRunBlowUpPuzzle not implemented");
- //_scene->setBlowUpPuzzle(new BlowUpPuzzleVCR(scn));
- //_scene->getBlowUpPuzzle()->openBlowUp();
+ _scene->vm()->screen()->clearScreen();
+ error("Incomplete opcode %s (0x%02X) in Scene %d Line %d", _opcodes[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
+ //_scene->vm()->screen()->clearDrawStruct(4096, 2049, &drawStruct);
+ //_scene->vm()->switchMessageHandler(_scene->vm()->getMessageHandler(cmd->param1));
+ _currentLine++;
- error("Incomplete opcode %s (0x%02X) in Scene %d Line %d", _actions[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
+ _exit = true;
}
//////////////////////////////////////////////////////////////////////////
// Opcode 0x38
IMPLEMENT_OPCODE(JumpIfFlag2Bit3) {
- error("Unhandled opcode %s (0x%02X) in Scene %d Line %d", _actions[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
+ error("Unhandled opcode %s (0x%02X) in Scene %d Line %d", _opcodes[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
}
//////////////////////////////////////////////////////////////////////////
// Opcode 0x39
IMPLEMENT_OPCODE(SetFlag2Bit3) {
- error("Unhandled opcode %s (0x%02X) in Scene %d Line %d", _actions[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
+ error("Unhandled opcode %s (0x%02X) in Scene %d Line %d", _opcodes[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
}
//////////////////////////////////////////////////////////////////////////
// Opcode 0x3A
IMPLEMENT_OPCODE(ClearFlag2Bit3) {
- error("Unhandled opcode %s (0x%02X) in Scene %d Line %d", _actions[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
+ error("Unhandled opcode %s (0x%02X) in Scene %d Line %d", _opcodes[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
}
//////////////////////////////////////////////////////////////////////////
// Opcode 0x3B
IMPLEMENT_OPCODE(_unk3B_PALETTE_MOD) {
- error("Unhandled opcode %s (0x%02X) in Scene %d Line %d", _actions[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
+ error("Unhandled opcode %s (0x%02X) in Scene %d Line %d", _opcodes[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
}
//////////////////////////////////////////////////////////////////////////
// Opcode 0x3C
-IMPLEMENT_OPCODE(_unk3C_CMP_VAL) {
+IMPLEMENT_OPCODE(IncrementParam2) {
if (cmd->param1) {
if (cmd->param2 >= cmd->param1) {
cmd->param2 = 0;
@@ -891,14 +881,17 @@ IMPLEMENT_OPCODE(UpdateWideScreen) {
//////////////////////////////////////////////////////////////////////////
// Opcode 0x3F
-IMPLEMENT_OPCODE(_unk3F) {
- error("Unhandled opcode %s (0x%02X) in Scene %d Line %d", _actions[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
+IMPLEMENT_OPCODE(JumpIfActor) {
+ ActorIndex index = (cmd->param1 == -1) ? _scene->getPlayerActorIndex() : cmd->param1;
+
+ if (_currentQueueEntry.actorIndex != index)
+ _currentLine = cmd->param2 - 1;
}
//////////////////////////////////////////////////////////////////////////
// Opcode 0x40
IMPLEMENT_OPCODE(_unk40_SOUND) {
- error("Unhandled opcode %s (0x%02X) in Scene %d Line %d", _actions[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
+ error("Unhandled opcode %s (0x%02X) in Scene %d Line %d", _opcodes[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
}
//////////////////////////////////////////////////////////////////////////
@@ -924,9 +917,8 @@ IMPLEMENT_OPCODE(PlaySpeech) {
_scene->vm()->setGameFlag(kGameFlag219);
}
- if (_scene->vm()->sound()->isPlaying(cmd->param5)) {
+ if (_scene->vm()->sound()->isPlaying((ResourceId)cmd->param5))
_lineIncrement = 1;
- }
_scene->vm()->clearGameFlag(kGameFlagScriptProcessing);
cmd->param4 = 0;
@@ -951,31 +943,58 @@ IMPLEMENT_OPCODE(PlaySpeech) {
//////////////////////////////////////////////////////////////////////////
// Opcode 0x42
IMPLEMENT_OPCODE(_unk42) {
- error("Unhandled opcode %s (0x%02X) in Scene %d Line %d", _actions[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
+ error("Unhandled opcode %s (0x%02X) in Scene %d Line %d", _opcodes[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
}
//////////////////////////////////////////////////////////////////////////
// Opcode 0x43
-IMPLEMENT_OPCODE(_unk43) {
- error("Unhandled opcode %s (0x%02X) in Scene %d Line %d", _actions[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
+IMPLEMENT_OPCODE(MoveScenePositionFromActor) {
+ Actor *actor = _scene->getActor();
+
+ if (!cmd->param3) {
+ _scene->worldstats()->motionStatus = 5;
+
+ _scene->updateSceneCoordinates(actor->x1 + Common::Rational(actor->x2, 2).toInt() - 320,
+ actor->y1 + Common::Rational(actor->y2, 2).toInt() - 240,
+ cmd->param2);
+ } else if (cmd->param6) {
+ if (_scene->worldstats()->motionStatus == 2) {
+ _lineIncrement = 1;
+ } else {
+ cmd->param6 = 0;
+ _scene->worldstats()->targetX = -1;
+ }
+ } else {
+ cmd->param6 = 1;
+ _scene->worldstats()->motionStatus = 2;
+
+ if (_scene->updateSceneCoordinates(actor->x1 + Common::Rational(actor->x2, 2).toInt() - 320,
+ actor->y1 + Common::Rational(actor->y2, 2).toInt() - 240,
+ cmd->param2,
+ true,
+ &cmd->param6))
+ _lineIncrement = 0;
+ else
+ _lineIncrement = 1;
+ }
}
//////////////////////////////////////////////////////////////////////////
// Opcode 0x44
IMPLEMENT_OPCODE(PaletteFade) {
- error("Unhandled opcode %s (0x%02X) in Scene %d Line %d", _actions[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
+ error("Unhandled opcode %s (0x%02X) in Scene %d Line %d", _opcodes[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
}
//////////////////////////////////////////////////////////////////////////
// Opcode 0x45
IMPLEMENT_OPCODE(StartPaletteFadeThread) {
- error("Unhandled opcode %s (0x%02X) in Scene %d Line %d", _actions[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
+ error("Unhandled opcode %s (0x%02X) in Scene %d Line %d", _opcodes[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
}
//////////////////////////////////////////////////////////////////////////
// Opcode 0x46
IMPLEMENT_OPCODE(_unk46) {
- error("Unhandled opcode %s (0x%02X) in Scene %d Line %d", _actions[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
+ error("Unhandled opcode %s (0x%02X) in Scene %d Line %d", _opcodes[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
}
//////////////////////////////////////////////////////////////////////////
@@ -987,70 +1006,74 @@ IMPLEMENT_OPCODE(ActorFaceObject) {
// multiple characters in the actor[] array
_scene->getActor()->faceTarget(cmd->param2, cmd->param3);
- error("Incomplete opcode %s (0x%02X) in Scene %d Line %d", _actions[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
+ error("Incomplete opcode %s (0x%02X) in Scene %d Line %d", _opcodes[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
}
//////////////////////////////////////////////////////////////////////////
// Opcode 0x48
IMPLEMENT_OPCODE(_unk48_MATTE_01) {
- error("Unhandled opcode %s (0x%02X) in Scene %d Line %d", _actions[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
+ error("Unhandled opcode %s (0x%02X) in Scene %d Line %d", _opcodes[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
}
//////////////////////////////////////////////////////////////////////////
// Opcode 0x49
IMPLEMENT_OPCODE(_unk49_MATTE_90) {
- error("Unhandled opcode %s (0x%02X) in Scene %d Line %d", _actions[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
+ error("Unhandled opcode %s (0x%02X) in Scene %d Line %d", _opcodes[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
}
//////////////////////////////////////////////////////////////////////////
// Opcode 0x4A
IMPLEMENT_OPCODE(JumpIfSoundPlaying) {
- error("Unhandled opcode %s (0x%02X) in Scene %d Line %d", _actions[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
+ error("Unhandled opcode %s (0x%02X) in Scene %d Line %d", _opcodes[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
}
//////////////////////////////////////////////////////////////////////////
// Opcode 0x4B
-IMPLEMENT_OPCODE(ChangePlayerCharacterIndex) {
- error("Unhandled opcode %s (0x%02X) in Scene %d Line %d", _actions[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
+IMPLEMENT_OPCODE(ChangePlayerActorIndex) {
+ _scene->changePlayerActorIndex(cmd->param1);
}
//////////////////////////////////////////////////////////////////////////
// Opcode 0x4C
IMPLEMENT_OPCODE(ChangeActorStatus) {
- ActorIndex actorIdx = cmd->param1;
+ Actor *actor = _scene->getActor(cmd->param1);
if (cmd->param2) {
- if (_scene->worldstats()->actors[actorIdx].status < kActorStatus11)
- _scene->worldstats()->actors[actorIdx].status = kActorStatus14;
+ if (actor->status < kActorStatus11)
+ actor->status = kActorStatus14;
} else {
- _scene->worldstats()->actors[actorIdx].status = kActorStatusEnabled;
+ actor->status = kActorStatusEnabled;
}
}
//////////////////////////////////////////////////////////////////////////
// Opcode 0x4D
IMPLEMENT_OPCODE(StopSound) {
- if (_scene->vm()->sound()->isPlaying(cmd->param1))
- _scene->vm()->sound()->stopSound(cmd->param1);
+ if (_scene->vm()->sound()->isPlaying((ResourceId)cmd->param1))
+ _scene->vm()->sound()->stopSound((ResourceId)cmd->param1);
}
//////////////////////////////////////////////////////////////////////////
// Opcode 0x4E
IMPLEMENT_OPCODE(_unk4E_RANDOM_COMMAND) {
- error("Unhandled opcode %s (0x%02X) in Scene %d Line %d", _actions[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
+ error("Unhandled opcode %s (0x%02X) in Scene %d Line %d", _opcodes[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
}
//////////////////////////////////////////////////////////////////////////
// Opcode 0x4F
IMPLEMENT_OPCODE(ClearScreen) {
- if (cmd->param1)
+ if (cmd->param1) {
_scene->vm()->screen()->clearScreen();
+ _scene->vm()->setFlag(kFlagTypeSkipDraw);
+ } else {
+ _scene->vm()->clearFlag(kFlagTypeSkipDraw);
+ }
}
//////////////////////////////////////////////////////////////////////////
// Opcode 0x50
IMPLEMENT_OPCODE(Quit) {
- error("Unhandled opcode %s (0x%02X) in Scene %d Line %d", _actions[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
+ error("Unhandled opcode %s (0x%02X) in Scene %d Line %d", _opcodes[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
}
//////////////////////////////////////////////////////////////////////////
@@ -1085,14 +1108,17 @@ IMPLEMENT_OPCODE(JumpBarrierFrame) {
//////////////////////////////////////////////////////////////////////////
// Opcode 0x52
-IMPLEMENT_OPCODE(_unk52) {
- error("Unhandled opcode %s (0x%02X) in Scene %d Line %d", _actions[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
+IMPLEMENT_OPCODE(DeleteGraphics) {
+ for (uint i = 0; i < 55; i++)
+ _scene->vm()->screen()->deleteGraphicFromQueue(_scene->getActor(cmd->param1)->grResTable[cmd->param1]);
}
//////////////////////////////////////////////////////////////////////////
// Opcode 0x53
-IMPLEMENT_OPCODE(_unk53) {
- error("Unhandled opcode %s (0x%02X) in Scene %d Line %d", _actions[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
+IMPLEMENT_OPCODE(SetActorField944) {
+ Actor *actor = _scene->getActor(cmd->param1);
+
+ actor->field_944 = cmd->param2;
}
//////////////////////////////////////////////////////////////////////////
@@ -1132,20 +1158,46 @@ IMPLEMENT_OPCODE(_unk55) {
else
_lineIncrement = cmd->param8;
- error("Incomplete opcode %s (0x%02X) in Scene %d Line %d", _actions[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
+ error("Incomplete opcode %s (0x%02X) in Scene %d Line %d", _opcodes[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
}
//////////////////////////////////////////////////////////////////////////
// Opcode 0x56
IMPLEMENT_OPCODE(_unk56) {
- error("Unhandled opcode %s (0x%02X) in Scene %d Line %d", _actions[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
+ Actor *actor = _scene->getActor(cmd->param2 == 2 ? -1 : cmd->param1);
+
+ if (actor->status == kActorStatus2 || actor->status == kActorStatus13) {
+ if (cmd->param2 == 2)
+ _lineIncrement = 1;
+
+ return;
+ }
+
+ if (cmd->param2 == 2) {
+ cmd->param2 = 1;
+ _lineIncrement = 0;
+
+ if ((actor->x1 + actor->x2 == cmd->param6) && (actor->y1 + actor->y2 == cmd->param7)) {
+ actor->setDirectionFrom(cmd->param1, kDirectionFromActor);
+ _scene->getActor(cmd->param1)->setDirection((actor->direction + 4) & 7);
+ } else {
+ _currentLine = cmd->param3;
+ }
+ } else {
+ error("Unhandled opcode %s (0x%02X) in Scene %d Line %d", _opcodes[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
+ }
}
//////////////////////////////////////////////////////////////////////////
// Opcode 0x57
IMPLEMENT_OPCODE(SetResourcePalette) {
- if (cmd->param1 > 0)
- _scene->vm()->screen()->setPalette(_scene->getResourcePack(), _scene->worldstats()->grResId[cmd->param1]);
+ if (cmd->param1 < 0)
+ error("Invalid resource id in opcode %s (0x%02X) in Scene %d Line %d", _opcodes[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
+
+ _scene->worldstats()->currentPaletteId = _scene->worldstats()->grResId[cmd->param1];
+
+ _scene->vm()->screen()->setPalette(_scene->getResourcePack(), _scene->worldstats()->currentPaletteId);
+ _scene->vm()->screen()->setGammaLevel(_scene->getResourcePack(), _scene->worldstats()->currentPaletteId, 0);
}
//////////////////////////////////////////////////////////////////////////
@@ -1156,7 +1208,7 @@ IMPLEMENT_OPCODE(SetBarrierFrameIdxFlaged) {
if (cmd->param3)
barrier->flags = 1 | barrier->flags;
else
- barrier->flags = barrier->flags & 0xFFFFFFFE;
+ barrier->flags &= kBarrierFlagDestroyed;
barrier->frameIdx = cmd->param2;
}
@@ -1164,7 +1216,7 @@ IMPLEMENT_OPCODE(SetBarrierFrameIdxFlaged) {
//////////////////////////////////////////////////////////////////////////
// Opcode 0x59
IMPLEMENT_OPCODE(_unk59) {
- error("Unhandled opcode %s (0x%02X) in Scene %d Line %d", _actions[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
+ error("Unhandled opcode %s (0x%02X) in Scene %d Line %d", _opcodes[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
}
//////////////////////////////////////////////////////////////////////////
@@ -1176,19 +1228,20 @@ IMPLEMENT_OPCODE(_unk5A) {
//////////////////////////////////////////////////////////////////////////
// Opcode 0x5B
IMPLEMENT_OPCODE(_unk5B) {
- error("Unhandled opcode %s (0x%02X) in Scene %d Line %d", _actions[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
+ error("Unhandled opcode %s (0x%02X) in Scene %d Line %d", _opcodes[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
}
//////////////////////////////////////////////////////////////////////////
// Opcode 0x5C
-IMPLEMENT_OPCODE(_unk5C) {
- error("Unhandled opcode %s (0x%02X) in Scene %d Line %d", _actions[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
+IMPLEMENT_OPCODE(QueueScript) {
+ queueScript( _scene->worldstats()->getActionAreaById(cmd->param1)->scriptIndex, cmd->param2);
}
//////////////////////////////////////////////////////////////////////////
// Opcode 0x5D
IMPLEMENT_OPCODE(_unk5D) {
- error("Unhandled opcode %s (0x%02X) in Scene %d Line %d", _actions[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
+
+ error("Unhandled opcode %s (0x%02X) in Scene %d Line %d", _opcodes[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
}
//////////////////////////////////////////////////////////////////////////
@@ -1206,7 +1259,7 @@ IMPLEMENT_OPCODE(SetBarrierLastFrameIdx) {
if (barrier->frameIdx == barrier->frameCount - 1) {
_lineIncrement = 0;
- barrier->flags &= 0xFFFEF1C7;
+ barrier->flags &= kBarrierFlagFFFEF1C7;
} else {
_lineIncrement = 1;
}
@@ -1215,7 +1268,7 @@ IMPLEMENT_OPCODE(SetBarrierLastFrameIdx) {
//////////////////////////////////////////////////////////////////////////
// Opcode 0x60
IMPLEMENT_OPCODE(_unk60_SET_OR_CLR_ACTIONAREA_FLAG) {
- error("Unhandled opcode %s (0x%02X) in Scene %d Line %d", _actions[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
+ error("Unhandled opcode %s (0x%02X) in Scene %d Line %d", _opcodes[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
}
//////////////////////////////////////////////////////////////////////////
@@ -1234,19 +1287,27 @@ IMPLEMENT_OPCODE(_unk61) {
_lineIncrement = 1;
}
- error("Incomplete opcode %s (0x%02X) in Scene %d Line %d", _actions[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
+ error("Incomplete opcode %s (0x%02X) in Scene %d Line %d", _opcodes[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
}
//////////////////////////////////////////////////////////////////////////
// Opcode 0x62
IMPLEMENT_OPCODE(_unk62_SHOW_OPTIONS_SCREEN) {
- error("Unhandled opcode %s (0x%02X) in Scene %d Line %d", _actions[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
+ error("Unhandled opcode %s (0x%02X) in Scene %d Line %d", _opcodes[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
}
//////////////////////////////////////////////////////////////////////////
// Opcode 0x63
IMPLEMENT_OPCODE(_unk63) {
- error("Unhandled opcode %s (0x%02X) in Scene %d Line %d", _actions[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
+ error("Unhandled opcode %s (0x%02X) in Scene %d Line %d", _opcodes[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
+}
+
+//////////////////////////////////////////////////////////////////////////
+// Opcode Helper functions
+//////////////////////////////////////////////////////////////////////////
+
+void ActionList::enableBarrier(ScriptEntry *cmd, BarrierEnableType type) {
+ error("[ActionList::enableBarrier] not implemented!");
}
} // end of namespace Asylum
diff --git a/engines/asylum/resources/actionlist.h b/engines/asylum/resources/actionlist.h
index 9caefe2943..e0176ae277 100644
--- a/engines/asylum/resources/actionlist.h
+++ b/engines/asylum/resources/actionlist.h
@@ -45,7 +45,7 @@ namespace Asylum {
#define ADD_OPCODE(name) { \
Opcode *func = new Opcode(#name, new Common::Functor1Mem<ScriptEntry *, void, ActionList>(this, &ActionList::k##name)); \
- _actions.push_back(func); \
+ _opcodes.push_back(func); \
}
class Scene;
@@ -64,16 +64,21 @@ public:
* Initialize the script element at actionIndex to
* the actor at actorIndex
*/
- void queueScript(int32 actionIndex, int32 actorIndex);
+ void queueScript(int32 scriptIndex, ActorIndex actorIndex);
// Accessors
- bool doesAllowInput() { return _allowInput; }
int32 getDelayedVideoIndex() const { return _delayedVideoIndex; }
void setDelayedVideoIndex(int32 val) { _delayedVideoIndex = val; }
int32 getDelayedSceneIndex() const { return _delayedSceneIndex; }
void setDelayedSceneIndex(int32 val) { _delayedSceneIndex = val; }
private:
+ enum BarrierEnableType {
+ kBarrierEnableType0,
+ kBarrierEnableType1,
+ kBarrierEnableType2
+ };
+
typedef struct ScriptEntry {
int32 numLines; // Only set on the first line of each script
int32 opcode;
@@ -86,7 +91,6 @@ private:
int32 param7;
int32 param8;
int32 param9;
-
} ScriptEntry;
typedef struct Script {
@@ -97,19 +101,20 @@ private:
} Script;
typedef struct ScriptQueueEntry {
- int32 actionListIndex;
- int32 actorIndex;
+ int32 scriptIndex;
+ ActorIndex actorIndex;
} ScriptQueueEntry;
- typedef Common::Functor1<ScriptEntry *, void> ActionFunctor;
+ // Opcodes
+ typedef Common::Functor1<ScriptEntry *, void> OpcodeFunctor;
struct Opcode {
- const char *name;
- ActionFunctor *func;
+ const char *name;
+ OpcodeFunctor *func;
- Opcode(const char* funcName, ActionFunctor *function) {
- name = funcName;
- func = function;
+ Opcode(const char* opcodeName, OpcodeFunctor *functor) {
+ name = opcodeName;
+ func = functor;
}
~Opcode() {
@@ -117,15 +122,15 @@ private:
}
};
+ // Parent
Scene *_scene;
- // Script data
- Common::Array<Script> _entries;
- Common::Stack<ScriptQueueEntry> _scripts;
- Common::Array<Opcode *> _actions;
+ // Script queue and data
+ Common::Array<Opcode *> _opcodes;
+ Common::Stack<ScriptQueueEntry> _queue;
+ Common::Array<Script> _scripts;
bool _skipProcessing;
- bool _allowInput;
int32 _currentLine;
int32 _currentLoops;
Script *_currentScript;
@@ -133,6 +138,7 @@ private:
int32 _delayedSceneIndex;
int32 _delayedVideoIndex;
bool _done;
+ bool _exit;
int32 _lineIncrement;
bool _waitCycle;
@@ -143,6 +149,13 @@ private:
*/
void load(Common::SeekableReadStream *stream);
+ /**
+ * Resets the queue.
+ */
+ void resetQueue();
+
+ void enableBarrier(ScriptEntry *cmd, BarrierEnableType type);
+
// Opcode functions
DECLARE_OPCODE(Return);
DECLARE_OPCODE(SetGameFlag);
@@ -196,21 +209,21 @@ private:
DECLARE_OPCODE(ChangeMusicById);
DECLARE_OPCODE(StopMusic);
DECLARE_OPCODE(_unk34_Status);
- DECLARE_OPCODE(_unk35);
- DECLARE_OPCODE(_unk36);
+ DECLARE_OPCODE(SetVolume);
+ DECLARE_OPCODE(Jump);
DECLARE_OPCODE(RunBlowUpPuzzle);
DECLARE_OPCODE(JumpIfFlag2Bit3);
DECLARE_OPCODE(SetFlag2Bit3);
DECLARE_OPCODE(ClearFlag2Bit3);
DECLARE_OPCODE(_unk3B_PALETTE_MOD);
- DECLARE_OPCODE(_unk3C_CMP_VAL);
+ DECLARE_OPCODE(IncrementParam2);
DECLARE_OPCODE(WaitUntilFramePlayed);
DECLARE_OPCODE(UpdateWideScreen);
- DECLARE_OPCODE(_unk3F);
+ DECLARE_OPCODE(JumpIfActor);
DECLARE_OPCODE(_unk40_SOUND);
DECLARE_OPCODE(PlaySpeech);
DECLARE_OPCODE(_unk42);
- DECLARE_OPCODE(_unk43);
+ DECLARE_OPCODE(MoveScenePositionFromActor);
DECLARE_OPCODE(PaletteFade);
DECLARE_OPCODE(StartPaletteFadeThread);
DECLARE_OPCODE(_unk46);
@@ -218,15 +231,15 @@ private:
DECLARE_OPCODE(_unk48_MATTE_01);
DECLARE_OPCODE(_unk49_MATTE_90);
DECLARE_OPCODE(JumpIfSoundPlaying);
- DECLARE_OPCODE(ChangePlayerCharacterIndex);
+ DECLARE_OPCODE(ChangePlayerActorIndex);
DECLARE_OPCODE(ChangeActorStatus);
DECLARE_OPCODE(StopSound);
DECLARE_OPCODE(_unk4E_RANDOM_COMMAND);
DECLARE_OPCODE(ClearScreen);
DECLARE_OPCODE(Quit);
DECLARE_OPCODE(JumpBarrierFrame);
- DECLARE_OPCODE(_unk52);
- DECLARE_OPCODE(_unk53);
+ DECLARE_OPCODE(DeleteGraphics);
+ DECLARE_OPCODE(SetActorField944);
DECLARE_OPCODE(_unk54_SET_ACTIONLIST_6EC);
DECLARE_OPCODE(_unk55);
DECLARE_OPCODE(_unk56);
@@ -235,7 +248,7 @@ private:
DECLARE_OPCODE(_unk59);
DECLARE_OPCODE(_unk5A);
DECLARE_OPCODE(_unk5B);
- DECLARE_OPCODE(_unk5C);
+ DECLARE_OPCODE(QueueScript);
DECLARE_OPCODE(_unk5D);
DECLARE_OPCODE(ClearActorField970);
DECLARE_OPCODE(SetBarrierLastFrameIdx);
@@ -243,7 +256,6 @@ private:
DECLARE_OPCODE(_unk61);
DECLARE_OPCODE(_unk62_SHOW_OPTIONS_SCREEN);
DECLARE_OPCODE(_unk63);
-
}; // end of class ActionList
} // end of namespace Asylum
diff --git a/engines/asylum/resources/actor.cpp b/engines/asylum/resources/actor.cpp
index 82e9a9464b..4bf31ae5c7 100644
--- a/engines/asylum/resources/actor.cpp
+++ b/engines/asylum/resources/actor.cpp
@@ -35,7 +35,7 @@
namespace Asylum {
-Actor::Actor() : _currentWalkArea(NULL), _graphic(NULL), _resPack(NULL) {
+Actor::Actor(Scene *scene) : _scene(scene), _currentWalkArea(NULL), _graphic(NULL) {
currentAction = 0;
// TODO initialize other class variables
@@ -73,8 +73,6 @@ void Actor::setRawResources(uint8 *data) {
}
void Actor::setAction(int32 action) {
- assert(_resPack);
-
if (action == currentAction)
return;
@@ -83,7 +81,7 @@ void Actor::setAction(int32 action) {
delete _graphic;
int32 act = (action < 100) ? action : action - 100;
- _graphic = new GraphicResource(_resPack, _resources[act]);
+ _graphic = new GraphicResource(_scene->getResourcePack(), _resources[act]);
// Flip horizontally if necessary
if (currentAction > 100) {
@@ -244,14 +242,14 @@ void Actor::walkTo(int32 curX, int32 curY) {
// Check what valid walk region(s) is/are currently available
for (int32 a = 0; a < ws->numActions; a++) {
- if (ws->actions[a].actionType == 0) {
- area = &ws->actions[a];
+ if (ws->actions[a]->actionType == 0) {
+ area = ws->actions[a];
PolyDefinitions poly = _scene->polygons()->entries[area->polyIdx];
if (poly.contains(x, y)) {
availableAreas[areaPtr] = a;
areaPtr++;
- setWalkArea(&ws->actions[a]);
+ setWalkArea(ws->actions[a]);
if (areaPtr > 5)
error("More than 5 overlapping walk regions found. Increase buffer");
@@ -263,7 +261,7 @@ void Actor::walkTo(int32 curX, int32 curY) {
// Check that we can walk in the current direction within any of the available
// walkable regions
for (int32 i = 0; i < areaPtr; i++) {
- area = &ws->actions[availableAreas[i]];
+ area = ws->actions[availableAreas[i]];
PolyDefinitions *region = &_scene->polygons()->entries[area->polyIdx];
if (region->contains(newX, newY)) {
x = newX;
@@ -306,7 +304,7 @@ void Actor::faceTarget(int32 targetId, int32 targetType) {
return;
}
- int32 polyIdx = _scene->worldstats()->actions[actionIdx].polyIdx;
+ int32 polyIdx = _scene->worldstats()->actions[actionIdx]->polyIdx;
PolyDefinitions *poly = &_scene->polygons()->entries[polyIdx];
newX2 = poly->boundingRect.left + (poly->boundingRect.right - poly->boundingRect.left) / 2;
@@ -327,7 +325,7 @@ void Actor::faceTarget(int32 targetId, int32 targetType) {
}
Barrier *barrier = _scene->worldstats()->getBarrierByIndex(barrierIdx);
- GraphicResource *gra = new GraphicResource(_resPack, barrier->resId);
+ GraphicResource *gra = new GraphicResource(_scene->getResourcePack(), barrier->resId);
// FIXME
// The original actually grabs the current frame of the target
@@ -492,7 +490,7 @@ void Actor::updateStatus(ActorStatus actorStatus) {
actor->y1 = y2 + y1 - actor->y2;
actor->direction = 4;
- _scene->setActorIndex(0);
+ _scene->setPlayerActorIndex(0);
// Hide this actor and the show the other one
setVisible(false);
@@ -534,8 +532,8 @@ void Actor::updateStatus(ActorStatus actorStatus) {
if (_index > 12)
graphicResourceId = grResTable[direction + 30];
- if (_scene->getActorIndex() == _index) {
- resource->load(_resPack, graphicResourceId);
+ if (_scene->getPlayerActorIndex() == _index) {
+ resource->load(_scene->getResourcePack(), graphicResourceId);
frameNum = resource->getFrameCount() - 1;
}
@@ -544,7 +542,7 @@ void Actor::updateStatus(ActorStatus actorStatus) {
// Reload the graphic resource if the resource ID has changed
if (resource->getEntryNum() != graphicResourceId)
- resource->load(_resPack, graphicResourceId);
+ resource->load(_scene->getResourcePack(), graphicResourceId);
frameCount = resource->getFrameCount();
}
@@ -557,13 +555,17 @@ void Actor::updateStatus(ActorStatus actorStatus) {
void Actor::updateGraphicData(uint32 offset) {
graphicResourceId = grResTable[(direction > 4 ? 8 - direction : direction) + offset];
- GraphicResource *resource = new GraphicResource(_resPack, graphicResourceId);
+ GraphicResource *resource = new GraphicResource(_scene->getResourcePack(), graphicResourceId);
frameCount = resource->getFrameCount();
delete resource;
frameNum = 0;
}
+void Actor::setDirectionFrom(uint32 parameter, DirectionFrom from) {
+ error("[Actor::setDirectionFrom] not implemented");
+}
+
void Actor::setDirection(int actorDirection) {
direction = (actorDirection > 4) ? 8 - actorDirection : actorDirection;
int32 grResId;
@@ -575,15 +577,16 @@ void Actor::setDirection(int actorDirection) {
case 0x0E: {
grResId = grResTable[direction + 5];
// FIXME this seems kind of wasteful just to grab a frame count
- GraphicResource *gra = new GraphicResource(_resPack, grResId);
+ GraphicResource *gra = new GraphicResource(_scene->getResourcePack(), grResId);
grResId = grResId;
frameCount = gra->getFrameCount();
delete gra;
- }
- break;
+ }
+ break;
+
case 0x12:
if (_scene->worldstats()->numChapter == 2) {
- if (_scene->getActorIndex() == 11) {
+ if (_scene->getPlayerActorIndex() == 11) {
// NOTE this is supposed to explicitely point to the actor 11 reference,
// (_ws->actors[11])
// but I'm assuming if control drops through to here, getActor() would
@@ -618,85 +621,118 @@ void Actor::update() {
case 0x10:
if (_scene->worldstats()->numChapter == 2) {
// TODO: updateCharacterSub14()
+ error("[Actor::update] not implemented");
} else if (_scene->worldstats()->numChapter == 1) {
- if (_scene->getActorIndex() == _index) {
+ if (_scene->getPlayerActorIndex() == _index) {
// TODO: updateActorSub21();
+ error("[Actor::update] not implemented");
}
}
break;
+
case 0x11:
if (_scene->worldstats()->numChapter == 2) {
// TODO: put code here
+ error("[Actor::update] not implemented");
} else if (_scene->worldstats()->numChapter == 11) {
- if (_scene->getActorIndex() == _index) {
+ if (_scene->getPlayerActorIndex() == _index) {
// TODO: put code here
+ error("[Actor::update] not implemented");
}
}
break;
+
case 0xF:
if (_scene->worldstats()->numChapter == 2) {
// TODO: put code here
+ error("[Actor::update] not implemented");
} else if (_scene->worldstats()->numChapter == 11) {
// TODO: put code here
+ error("[Actor::update] not implemented");
}
break;
+
case 0x12:
if (_scene->worldstats()->numChapter == 2) {
// TODO: put code here
+ error("[Actor::update] not implemented");
}
break;
- case 0x5: {
+
+ case 0x5:
frameNum = (frameNum + 1) % frameCount;
- if (_scene->vm()->getTick() - tickValue1 > 300) {
+ if (_scene->vm()->getTick() - tickValue > 300) {
if (_scene->vm()->getRandom(100) < 50) {
// TODO: check sound playing
+ error("[Actor::update] not implemented");
}
- tickValue1 = _scene->vm()->getTick();
+ tickValue = _scene->vm()->getTick();
}
- }
- break;
+ break;
+
case 0xC:
if (_scene->worldstats()->numChapter == 2) {
// TODO: put code here
+ error("[Actor::update] not implemented");
} else if (_scene->worldstats()->numChapter == 11) {
// TODO: put code here
+ error("[Actor::update] not implemented");
}
+ //FIXME Missing break?
case 0x1:
// TODO: do actor direction
+ error("[Actor::update] not implemented");
break;
+
case 0x2:
case 0xD:
// TODO: do actor direction
+ error("[Actor::update] not implemented");
break;
+
case 0x3:
case 0x13:
// TODO: updateCharacterSub05();
+ error("[Actor::update] not implemented");
break;
+
case 0x7:
// TODO: something
+ error("[Actor::update] not implemented");
break;
+
case 0x4:
if (field_944 != 5) {
updateActorSub01();
}
break;
+
case 0xE:
// TODO: updateCharacterSub02(1, actorIdx);
+ error("[Actor::update] not implemented");
break;
+
case 0x15:
// TODO: updateCharacterSub06(1, actorIdx);
+ error("[Actor::update] not implemented");
break;
+
case 0x9:
// TODO: updateCharacterSub03(1, actorIdx);
+ error("[Actor::update] not implemented");
break;
+
case 0x6:
case 0xA:
frameNum = (frameNum + 1) % frameCount;
break;
+
case 0x8:
// TODO: actor sound
+ error("[Actor::update] not implemented");
break;
+
default:
break;
}
@@ -706,7 +742,7 @@ void Actor::update() {
void Actor::updateActorSub01() {
// TODO make sure this is right
frameNum = (frameNum + 1) % frameCount;
- if (_scene->vm()->getTick() - tickValue1 > 300) {
+ if (_scene->vm()->getTick() - tickValue > 300) {
// TODO
// Check if the actor's name is "Crow"?
if (_scene->vm()->getRandom(100) < 50) {
@@ -735,7 +771,7 @@ void Actor::updateActorSub01() {
}
}
}
- tickValue1 = _scene->vm()->getTick();
+ tickValue = _scene->vm()->getTick();
}
// else
// TODO now there's something to do with the
diff --git a/engines/asylum/resources/actor.h b/engines/asylum/resources/actor.h
index 3bde35cfc6..992e7f5e05 100644
--- a/engines/asylum/resources/actor.h
+++ b/engines/asylum/resources/actor.h
@@ -29,6 +29,7 @@
#include "asylum/system/graphics.h"
#include "asylum/respack.h"
+#include "asylum/shared.h"
namespace Asylum {
@@ -77,6 +78,13 @@ enum ActorFlags {
kHidden = 0xFFFFFFFE
};
+enum DirectionFrom {
+ kDirectionFromBarrier = 0,
+ kDirectionFromPolygons = 1,
+ kDirectionFromActor = 2,
+ kDirectionFromParameters = 3
+};
+
// TODO investigate other actor resources (from other
// scenes) to see if the unused blocks in the actor
// definition are in fact used elsewhere
@@ -171,7 +179,7 @@ enum ActorResources {
class Actor {
public:
- Actor();
+ Actor(Scene *scene);
virtual ~Actor();
/**
@@ -201,19 +209,12 @@ public:
*/
void updateDirection();
void setDirection(ActorDirection direction);
+ void setDirectionFrom(uint32 parameter, DirectionFrom from);
void updateStatus(ActorStatus status);
bool defaultDirectionLoaded(int grResTableIdx);
- // FIXME
- // I don't really like how this is used in the scene constructor
- void setResourcePack(ResourcePack *res) { _resPack = res; }
-
- // FIXME Hack to get a reference to the parent scene
- // into the actor instance
- void setScene(Scene *scene) { _scene = scene; }
-
// OLD METHODS
// TODO ALL of these need to be depreciated in favour
// of the proper functions from the original
@@ -268,12 +269,12 @@ public:
int32 field_8D0[20];
int32 actionIdx2;
int32 field_924;
- int32 tickValue1;
+ int32 tickValue;
int32 field_92C;
int32 flags2;
int32 field_934;
int32 field_938;
- int32 soundResId; // field_93C
+ ResourceId soundResId; // field_93C
int32 numberValue01;
int32 field_944;
int32 field_948;
@@ -306,7 +307,6 @@ private:
ActionArea *_currentWalkArea;
GraphicResource *_graphic;
- ResourcePack *_resPack;
// Our current index
ActorIndex _index;
diff --git a/engines/asylum/resources/barrier.cpp b/engines/asylum/resources/barrier.cpp
index 03363047db..3c02c8e942 100644
--- a/engines/asylum/resources/barrier.cpp
+++ b/engines/asylum/resources/barrier.cpp
@@ -25,11 +25,11 @@
#include "asylum/resources/barrier.h"
-namespace Asylum {
+#include "asylum/views/scene.h"
-Barrier::Barrier() {
- // TODO Auto-generated constructor stub
+namespace Asylum {
+Barrier::Barrier(Scene *scene) : _scene(scene) {
}
Barrier::~Barrier() {
@@ -37,7 +37,14 @@ Barrier::~Barrier() {
}
void Barrier::destroy() {
- flags &= 0xFFFFFFFE;
+ flags &= kBarrierFlagDestroyed;
+}
+
+void Barrier::destroyAndRemoveFromQueue() {
+ destroy();
+ flags|= kBarrierFlag20000;
+
+ _scene->vm()->screen()->deleteGraphicFromQueue(resId);
}
int32 Barrier::getRandomId() {
@@ -87,4 +94,10 @@ void Barrier::updateSoundItems(Sound *snd) {
// many calls to this method, I'm leaving this comment as a reminder
// until all dependant methods are implemented
}
+
+void Barrier::stopSound() {
+ if (_scene->vm()->sound()->isPlaying(soundResId))
+ _scene->vm()->sound()->stopSound(soundResId);
+}
+
} // end of namespace Asylum
diff --git a/engines/asylum/resources/barrier.h b/engines/asylum/resources/barrier.h
index 84045b2563..b29ad5d9d6 100644
--- a/engines/asylum/resources/barrier.h
+++ b/engines/asylum/resources/barrier.h
@@ -32,12 +32,27 @@
namespace Asylum {
+enum BarrierFlag {
+ kBarrierFlag4 = 0x4,
+ kBarrierFlag8 = 0x8,
+ kBarrierFlag20 = 0x20,
+ kBarrierFlag10000 = 0x10000,
+ kBarrierFlag10E38 = 0x10E38,
+ kBarrierFlag20000 = 0x20000,
+ kBarrierFlagFFFEF1C7 = 0xFFFEF1C7,
+ kBarrierFlagFFFEFFFF = 0xFFFEFFFF,
+ kBarrierFlagDestroyed = 0xFFFFFFFE
+};
+
+class Scene;
+
class Barrier {
public:
- Barrier();
+ Barrier(Scene *scene);
virtual ~Barrier();
void destroy();
+ void destroyAndRemoveFromQueue();
bool visible();
int32 getRandomId(); // TODO Give this a better name?
@@ -54,6 +69,8 @@ public:
*/
void updateSoundItems(Sound *snd);
+ void stopSound();
+
int32 id;
uint32 resId;
int32 x;
@@ -91,6 +108,9 @@ public:
int32 soundResId;
int32 field_6A4;
+private:
+ Scene *_scene;
+
}; // end of class Barrier
} // end of namespace Asylum
diff --git a/engines/asylum/resources/worldstats.cpp b/engines/asylum/resources/worldstats.cpp
index 942509ceb2..7cb0ec9343 100644
--- a/engines/asylum/resources/worldstats.cpp
+++ b/engines/asylum/resources/worldstats.cpp
@@ -33,14 +33,14 @@ WorldStats::WorldStats(Common::SeekableReadStream *stream, Scene *scene)
}
WorldStats::~WorldStats() {
- barriers.clear();
- actors.clear();
- actions.clear();
+ CLEAR_ARRAY(Barrier, barriers);
+ CLEAR_ARRAY(Actor, actors);
+ CLEAR_ARRAY(ActionArea, actions);
}
int32 WorldStats::getActionAreaIndexById(int32 id) {
for (int32 i = 0; i < numActions; i++) {
- if (actions[i].id == id)
+ if (actions[i]->id == id)
return i;
}
@@ -48,12 +48,16 @@ int32 WorldStats::getActionAreaIndexById(int32 id) {
}
ActionArea* WorldStats::getActionAreaById(int32 id) {
- return &actions[getActionAreaIndexById(id)];
+ int index = getActionAreaIndexById(id);
+ if (index == -1)
+ error("[WorldStats::getActionAreaById] action id is invalid");
+
+ return actions[index];
}
int32 WorldStats::getBarrierIndexById(int32 id) {
for (int32 i = 0; i < numBarriers; i++) {
- if (barriers[i].id == id)
+ if (barriers[i]->id == id)
return i;
}
@@ -61,11 +65,11 @@ int32 WorldStats::getBarrierIndexById(int32 id) {
}
Barrier* WorldStats::getBarrierById(int32 id) {
- return &barriers[getBarrierIndexById(id)];
+ return barriers[getBarrierIndexById(id)];
}
Barrier* WorldStats::getBarrierByIndex(int32 idx) {
- return &barriers[idx];
+ return barriers[idx];
}
bool WorldStats::isBarrierOnScreen(int32 idx) {
@@ -148,7 +152,7 @@ void WorldStats::load(Common::SeekableReadStream *stream) {
font1 = stream->readSint32LE();
font2 = stream->readSint32LE();
font3 = stream->readSint32LE();
- palette = stream->readSint32LE();
+ currentPaletteId = stream->readSint32LE();
cellShadeMask1 = stream->readSint32LE();
cellShadeMask2 = stream->readSint32LE();
cellShadeMask3 = stream->readSint32LE();
@@ -222,73 +226,73 @@ void WorldStats::load(Common::SeekableReadStream *stream) {
for (int32 a = 0; a < numBarriers; a++) {
int32 i;
- Barrier barrier;
-
- barrier.id = stream->readSint32LE();
- barrier.resId = stream->readSint32LE();
- barrier.x = stream->readSint32LE();
- barrier.y = stream->readSint32LE();
-
- barrier.boundingRect.left = stream->readSint32LE() & 0xFFFF;
- barrier.boundingRect.top = stream->readSint32LE() & 0xFFFF;
- barrier.boundingRect.right = stream->readSint32LE() & 0xFFFF;
- barrier.boundingRect.bottom = stream->readSint32LE() & 0xFFFF;
-
- barrier.field_20 = stream->readSint32LE();
- barrier.frameIdx = stream->readSint32LE();
- barrier.frameCount = stream->readSint32LE();
- barrier.field_2C = stream->readSint32LE();
- barrier.field_30 = stream->readSint32LE();
- barrier.field_34 = stream->readSint32LE();
- barrier.flags = stream->readSint32LE();
- barrier.field_3C = stream->readSint32LE();
-
- stream->read(barrier.name, sizeof(barrier.name));
-
- barrier.field_74 = stream->readSint32LE();
- barrier.field_78 = stream->readSint32LE();
- barrier.field_7C = stream->readSint32LE();
- barrier.field_80 = stream->readSint32LE();
- barrier.polyIdx = stream->readSint32LE();
- barrier.flags2 = stream->readSint32LE();
+ Barrier *barrier = new Barrier(_scene);
+
+ barrier->id = stream->readSint32LE();
+ barrier->resId = stream->readSint32LE();
+ barrier->x = stream->readSint32LE();
+ barrier->y = stream->readSint32LE();
+
+ barrier->boundingRect.left = stream->readSint32LE() & 0xFFFF;
+ barrier->boundingRect.top = stream->readSint32LE() & 0xFFFF;
+ barrier->boundingRect.right = stream->readSint32LE() & 0xFFFF;
+ barrier->boundingRect.bottom = stream->readSint32LE() & 0xFFFF;
+
+ barrier->field_20 = stream->readSint32LE();
+ barrier->frameIdx = stream->readSint32LE();
+ barrier->frameCount = stream->readSint32LE();
+ barrier->field_2C = stream->readSint32LE();
+ barrier->field_30 = stream->readSint32LE();
+ barrier->field_34 = stream->readSint32LE();
+ barrier->flags = stream->readSint32LE();
+ barrier->field_3C = stream->readSint32LE();
+
+ stream->read(barrier->name, sizeof(barrier->name));
+
+ barrier->field_74 = stream->readSint32LE();
+ barrier->field_78 = stream->readSint32LE();
+ barrier->field_7C = stream->readSint32LE();
+ barrier->field_80 = stream->readSint32LE();
+ barrier->polyIdx = stream->readSint32LE();
+ barrier->flags2 = stream->readSint32LE();
for (i = 0; i < 10; i++)
- barrier.gameFlags[i] = (GameFlag)stream->readSint32LE();
+ barrier->gameFlags[i] = (GameFlag)stream->readSint32LE();
- barrier.field_B4 = stream->readSint32LE();
- barrier.tickCount = stream->readSint32LE();
- barrier.tickCount2 = stream->readSint32LE();
- barrier.field_C0 = stream->readSint32LE();
- barrier.priority = stream->readSint32LE();
- barrier.actionListIdx = stream->readSint32LE();
+ barrier->field_B4 = stream->readSint32LE();
+ barrier->tickCount = stream->readSint32LE();
+ barrier->tickCount2 = stream->readSint32LE();
+ barrier->field_C0 = stream->readSint32LE();
+ barrier->priority = stream->readSint32LE();
+ barrier->actionListIdx = stream->readSint32LE();
for (i = 0; i < 16; i++) {
- barrier.soundItems[i].resId = stream->readSint32LE();
- barrier.soundItems[i].field_4 = stream->readSint32LE();
- barrier.soundItems[i].field_8 = stream->readSint32LE();
- barrier.soundItems[i].field_C = stream->readSint32LE();
+ barrier->soundItems[i].resId = stream->readSint32LE();
+ barrier->soundItems[i].field_4 = stream->readSint32LE();
+ barrier->soundItems[i].field_8 = stream->readSint32LE();
+ barrier->soundItems[i].field_C = stream->readSint32LE();
}
for (i = 0; i < 50; i++) {
- barrier.frameSoundItems[i].resId = stream->readSint32LE();
- barrier.frameSoundItems[i].frameIdx = stream->readSint32LE();
- barrier.frameSoundItems[i].index = stream->readSint32LE();
- barrier.frameSoundItems[i].field_C = stream->readSint32LE();
- barrier.frameSoundItems[i].field_10 = stream->readSint32LE();
- barrier.frameSoundItems[i].field_14 = stream->readSint32LE();
+ barrier->frameSoundItems[i].resId = stream->readSint32LE();
+ barrier->frameSoundItems[i].frameIdx = stream->readSint32LE();
+ barrier->frameSoundItems[i].index = stream->readSint32LE();
+ barrier->frameSoundItems[i].field_C = stream->readSint32LE();
+ barrier->frameSoundItems[i].field_10 = stream->readSint32LE();
+ barrier->frameSoundItems[i].field_14 = stream->readSint32LE();
}
- barrier.field_67C = stream->readSint32LE();
- barrier.soundX = stream->readSint32LE();
- barrier.soundY = stream->readSint32LE();
- barrier.field_688 = stream->readSint32LE();
+ barrier->field_67C = stream->readSint32LE();
+ barrier->soundX = stream->readSint32LE();
+ barrier->soundY = stream->readSint32LE();
+ barrier->field_688 = stream->readSint32LE();
for (i = 0; i < 5; i++)
- barrier.field_68C[i] = stream->readSint32LE();
+ barrier->field_68C[i] = stream->readSint32LE();
- barrier.soundResId = stream->readSint32LE();
- barrier.field_6A4 = stream->readSint32LE();
+ barrier->soundResId = stream->readSint32LE();
+ barrier->field_6A4 = stream->readSint32LE();
barriers.push_back(barrier);
}
@@ -298,98 +302,98 @@ void WorldStats::load(Common::SeekableReadStream *stream) {
for (int32 a = 0; a < numActors; a++) {
int32 i;
- Actor actor;
-
- actor.x = stream->readSint32LE();
- actor.y = stream->readSint32LE();
- actor.graphicResourceId = stream->readSint32LE();
- actor.field_C = stream->readSint32LE();
- actor.frameNum = stream->readSint32LE();
- actor.frameCount = stream->readSint32LE();
- actor.x1 = stream->readSint32LE();
- actor.y1 = stream->readSint32LE();
- actor.x2 = stream->readSint32LE();
- actor.y2 = stream->readSint32LE();
-
- actor.boundingRect.left = stream->readSint32LE() & 0xFFFF;
- actor.boundingRect.top = stream->readSint32LE() & 0xFFFF;
- actor.boundingRect.right = stream->readSint32LE() & 0xFFFF;
- actor.boundingRect.bottom = stream->readSint32LE() & 0xFFFF;
-
- actor.direction = stream->readSint32LE();
- actor.field_3C = stream->readSint32LE();
- actor.status = (ActorStatus)stream->readSint32LE();
- actor.field_44 = stream->readSint32LE();
- actor.priority = stream->readSint32LE();
- actor.flags = stream->readSint32LE();
- actor.field_50 = stream->readSint32LE();
- actor.field_54 = stream->readSint32LE();
- actor.field_58 = stream->readSint32LE();
- actor.field_5C = stream->readSint32LE();
- actor.field_60 = stream->readSint32LE();
- actor.actionIdx3 = stream->readSint32LE();
+ Actor *actor = new Actor(_scene);
+
+ actor->x = stream->readSint32LE();
+ actor->y = stream->readSint32LE();
+ actor->graphicResourceId = stream->readSint32LE();
+ actor->field_C = stream->readSint32LE();
+ actor->frameNum = stream->readSint32LE();
+ actor->frameCount = stream->readSint32LE();
+ actor->x1 = stream->readSint32LE();
+ actor->y1 = stream->readSint32LE();
+ actor->x2 = stream->readSint32LE();
+ actor->y2 = stream->readSint32LE();
+
+ actor->boundingRect.left = stream->readSint32LE() & 0xFFFF;
+ actor->boundingRect.top = stream->readSint32LE() & 0xFFFF;
+ actor->boundingRect.right = stream->readSint32LE() & 0xFFFF;
+ actor->boundingRect.bottom = stream->readSint32LE() & 0xFFFF;
+
+ actor->direction = stream->readSint32LE();
+ actor->field_3C = stream->readSint32LE();
+ actor->status = (ActorStatus)stream->readSint32LE();
+ actor->field_44 = stream->readSint32LE();
+ actor->priority = stream->readSint32LE();
+ actor->flags = stream->readSint32LE();
+ actor->field_50 = stream->readSint32LE();
+ actor->field_54 = stream->readSint32LE();
+ actor->field_58 = stream->readSint32LE();
+ actor->field_5C = stream->readSint32LE();
+ actor->field_60 = stream->readSint32LE();
+ actor->actionIdx3 = stream->readSint32LE();
// TODO skip field_68 till field_617
stream->skip(0x5B0);
for (i = 0; i < 8; i++)
- actor.reaction[i] = stream->readSint32LE();
+ actor->reaction[i] = stream->readSint32LE();
- actor.field_638 = stream->readSint32LE();
- actor.walkingSound1 = stream->readSint32LE();
- actor.walkingSound2 = stream->readSint32LE();
- actor.walkingSound3 = stream->readSint32LE();
- actor.walkingSound4 = stream->readSint32LE();
- actor.field_64C = stream->readSint32LE();
- actor.field_650 = stream->readSint32LE();
+ actor->field_638 = stream->readSint32LE();
+ actor->walkingSound1 = stream->readSint32LE();
+ actor->walkingSound2 = stream->readSint32LE();
+ actor->walkingSound3 = stream->readSint32LE();
+ actor->walkingSound4 = stream->readSint32LE();
+ actor->field_64C = stream->readSint32LE();
+ actor->field_650 = stream->readSint32LE();
for (i = 0; i < 55; i++)
- actor.grResTable[i] = stream->readSint32LE();
+ actor->grResTable[i] = stream->readSint32LE();
- stream->read(actor.name, sizeof(actor.name));
+ stream->read(actor->name, sizeof(actor->name));
for (i = 0; i < 20; i++)
- actor.field_830[i] = stream->readSint32LE();
+ actor->field_830[i] = stream->readSint32LE();
for (i = 0; i < 20; i++)
- actor.field_880[i] = stream->readSint32LE();
+ actor->field_880[i] = stream->readSint32LE();
for (i = 0; i < 20; i++)
- actor.field_8D0[i] = stream->readSint32LE();
-
- actor.actionIdx2 = stream->readSint32LE();
- actor.field_924 = stream->readSint32LE();
- actor.tickValue1 = stream->readSint32LE();
- actor.field_92C = stream->readSint32LE();
- actor.flags2 = stream->readSint32LE();
- actor.field_934 = stream->readSint32LE();
- actor.field_938 = stream->readSint32LE();
- actor.soundResId = stream->readSint32LE();
- actor.numberValue01 = stream->readSint32LE();
- actor.field_944 = stream->readSint32LE();
- actor.field_948 = stream->readSint32LE();
- actor.field_94C = stream->readSint32LE();
- actor.numberFlag01 = stream->readSint32LE();
- actor.numberStringWidth = stream->readSint32LE();
- actor.numberStringX = stream->readSint32LE();
- actor.numberStringY = stream->readSint32LE();
- stream->read(actor.numberString01, sizeof(actor.numberString01));
- actor.field_964 = stream->readSint32LE();
- actor.field_968 = stream->readSint32LE();
- actor.field_96C = stream->readSint32LE();
- actor.field_970 = stream->readSint32LE();
- actor.field_974 = stream->readSint32LE();
- actor.field_978 = stream->readSint32LE();
- actor.actionIdx1 = stream->readSint32LE();
- actor.field_980 = stream->readSint32LE();
- actor.field_984 = stream->readSint32LE();
- actor.field_988 = stream->readSint32LE();
- actor.field_98C = stream->readSint32LE();
- actor.field_990 = stream->readSint32LE();
- actor.field_994 = stream->readSint32LE();
- actor.field_998 = stream->readSint32LE();
- actor.field_99C = stream->readSint32LE();
- actor.field_9A0 = stream->readSint32LE();
+ actor->field_8D0[i] = stream->readSint32LE();
+
+ actor->actionIdx2 = stream->readSint32LE();
+ actor->field_924 = stream->readSint32LE();
+ actor->tickValue = stream->readSint32LE();
+ actor->field_92C = stream->readSint32LE();
+ actor->flags2 = stream->readSint32LE();
+ actor->field_934 = stream->readSint32LE();
+ actor->field_938 = stream->readSint32LE();
+ actor->soundResId = stream->readSint32LE();
+ actor->numberValue01 = stream->readSint32LE();
+ actor->field_944 = stream->readSint32LE();
+ actor->field_948 = stream->readSint32LE();
+ actor->field_94C = stream->readSint32LE();
+ actor->numberFlag01 = stream->readSint32LE();
+ actor->numberStringWidth = stream->readSint32LE();
+ actor->numberStringX = stream->readSint32LE();
+ actor->numberStringY = stream->readSint32LE();
+ stream->read(actor->numberString01, sizeof(actor->numberString01));
+ actor->field_964 = stream->readSint32LE();
+ actor->field_968 = stream->readSint32LE();
+ actor->field_96C = stream->readSint32LE();
+ actor->field_970 = stream->readSint32LE();
+ actor->field_974 = stream->readSint32LE();
+ actor->field_978 = stream->readSint32LE();
+ actor->actionIdx1 = stream->readSint32LE();
+ actor->field_980 = stream->readSint32LE();
+ actor->field_984 = stream->readSint32LE();
+ actor->field_988 = stream->readSint32LE();
+ actor->field_98C = stream->readSint32LE();
+ actor->field_990 = stream->readSint32LE();
+ actor->field_994 = stream->readSint32LE();
+ actor->field_998 = stream->readSint32LE();
+ actor->field_99C = stream->readSint32LE();
+ actor->field_9A0 = stream->readSint32LE();
// TODO skip field_980 till field_9A0
stream->skip(0x24);
@@ -406,40 +410,40 @@ void WorldStats::load(Common::SeekableReadStream *stream) {
// FIXME
// This is ONLY ever going to work for scenes where there's only
// one actor in the worldStats->actors[] collection
- actors[0].setRawResources(mainActorData);
+ actors[0]->setRawResources(mainActorData);
stream->seek(0xD6B5A); // where action items start
// FIXME Figure out all the actions items
for (int32 a = 0; a < numActions; a++) {
- ActionArea action;
-
- stream->read(action.name, 52);
- action.id = stream->readSint32LE();
- action.field01 = stream->readSint32LE();
- action.field02 = stream->readSint32LE();
- action.field_40 = stream->readSint32LE();
- action.field_44 = stream->readSint32LE();
- action.flags = stream->readSint32LE();
- action.actionListIdx1 = stream->readSint32LE();
- action.actionListIdx2 = stream->readSint32LE();
- action.actionType = stream->readSint32LE();
+ ActionArea *action = new ActionArea();
+
+ stream->read(action->name, 52);
+ action->id = stream->readSint32LE();
+ action->field01 = stream->readSint32LE();
+ action->field02 = stream->readSint32LE();
+ action->field_40 = stream->readSint32LE();
+ action->field_44 = stream->readSint32LE();
+ action->flags = stream->readSint32LE();
+ action->scriptIndex = stream->readSint32LE();
+ action->actionListIdx2 = stream->readSint32LE();
+ action->actionType = stream->readSint32LE();
for (int32 aa1 = 0; aa1 < 10; aa1++)
- action.flagNums[aa1] = stream->readSint32LE();
+ action->flagNums[aa1] = stream->readSint32LE();
- action.field_7C = stream->readSint32LE();
- action.polyIdx = stream->readSint32LE();
- action.field_84 = stream->readSint32LE();
- action.field_88 = stream->readSint32LE();
- action.soundResId = stream->readSint32LE();
- action.field_90 = stream->readSint32LE();
- action.paletteValue = stream->readSint32LE();
+ action->field_7C = stream->readSint32LE();
+ action->polyIdx = stream->readSint32LE();
+ action->field_84 = stream->readSint32LE();
+ action->field_88 = stream->readSint32LE();
+ action->soundResId = stream->readSint32LE();
+ action->field_90 = stream->readSint32LE();
+ action->paletteValue = stream->readSint32LE();
for (int32 aa2 = 0; aa2 < 5; aa2++)
- action.array[aa2] = stream->readSint32LE();
+ action->array[aa2] = stream->readSint32LE();
- action.volume = stream->readSint32LE();
+ action->volume = stream->readSint32LE();
actions.push_back(action);
}
diff --git a/engines/asylum/resources/worldstats.h b/engines/asylum/resources/worldstats.h
index 3258fa322e..d57dace8ff 100644
--- a/engines/asylum/resources/worldstats.h
+++ b/engines/asylum/resources/worldstats.h
@@ -65,7 +65,7 @@ public:
int32 font1;
int32 font2;
int32 font3;
- int32 palette;
+ int32 currentPaletteId;
int32 cellShadeMask1;
int32 cellShadeMask2;
int32 cellShadeMask3;
@@ -97,21 +97,21 @@ public:
int32 sceneTitleGrResId;
int32 sceneTitlePalResId;
int32 actorType;
- int32 soundResId[50];
+ ResourceId soundResId[50];
AmbientSoundItem ambientSounds[15];
int32 numAmbientSound;
int32 musicStatus;
- int32 musicCurrentResId;
+ ResourceId musicCurrentResId;
int32 musicFlag;
- int32 musicResId;
+ ResourceId musicResId;
int32 musicStatusExt;
// FIXME: Investigate if we need to actually reserve maxsize for this arrays.
// It always have that size under scene file and they are always save in savegames.
- Common::Array<Barrier> barriers; // maxsize 400
- Common::Array<Actor> actors; // maxsize 50
+ Common::Array<Barrier*> barriers; // maxsize 400
+ Common::Array<Actor*> actors; // maxsize 50
// TODO add rest fields
- Common::Array<ActionArea> actions; // maxsize 400
+ Common::Array<ActionArea*> actions; // maxsize 400
// TODO add rest fields
int32 field_E860C;
// TODO add rest fields
diff --git a/engines/asylum/shared.h b/engines/asylum/shared.h
index a31ea8d9bb..4362c8efcd 100644
--- a/engines/asylum/shared.h
+++ b/engines/asylum/shared.h
@@ -39,6 +39,23 @@ enum GameFlag {
kGameFlagFinishGame = 901
};
+typedef int32 ResourceId;
+
+enum ResourceIdEnum {
+ kResourceSound_80120001 = 0x80120001,
+ kResourceSound_80120006 = 0x80120006
+};
+
+//////////////////////////////////////////////////////////////////////////
+// Helpers
+#define CLEAR_ARRAY(type, name) { \
+ for (Common::Array<type *>::iterator it = name.begin(); it != name.end(); it++) {\
+ delete *it; \
+ *it = NULL; \
+ } \
+ name.clear(); \
+}
+
} // End of namespace Asylum
#endif // ASYLUM_SHARED_H
diff --git a/engines/asylum/system/graphics.h b/engines/asylum/system/graphics.h
index fa3a98981d..f7a848000d 100644
--- a/engines/asylum/system/graphics.h
+++ b/engines/asylum/system/graphics.h
@@ -39,6 +39,9 @@ struct GraphicFrame {
int16 x;
int16 y;
Graphics::Surface surface;
+
+ uint16 getWidth() { return surface.w; }
+ uint16 getHeight() { return surface.h; }
};
// Graphic resources can be sprites or images, with multiple frames
diff --git a/engines/asylum/system/screen.cpp b/engines/asylum/system/screen.cpp
index dc340b8293..ba45a76730 100644
--- a/engines/asylum/system/screen.cpp
+++ b/engines/asylum/system/screen.cpp
@@ -111,6 +111,10 @@ void Screen::setPalette(byte *rgbPalette) {
_vm->_system->setPalette(palette, 0, 256);
}
+void Screen::setGammaLevel(ResourcePack *resPack, int32 entry, int32 val) {
+ error("[Screen::setGammaLevel] not implemented");
+}
+
void Screen::drawWideScreen(int16 barSize) {
if (barSize > 0) {
@@ -125,6 +129,10 @@ void Screen::clearScreen() {
_vm->_system->fillScreen(0);
}
+void Screen::palFade(uint32 red, int32 milliseconds, int32 param) {
+ error("[Screen::palFade] not implemented");
+}
+
void Screen::addGraphicToQueue(int32 resId, int32 frameIdx, int32 x, int32 y, int32 flags, int32 transTableNum, int32 priority) {
GraphicQueueItem item;
item.resId = resId;
@@ -139,7 +147,7 @@ void Screen::addGraphicToQueue(int32 resId, int32 frameIdx, int32 x, int32 y, in
}
void Screen::addCrossFadeGraphicToQueue(int32 resId, int32 frameIdx, int32 x, int32 y, int32 redId2, int32 x2, int32 y2, int32 flags, int32 priority) {
-
+ error("[Screen::addCrossFadeGraphicToQueue] not implemented");
}
void Screen::addGraphicToQueue(GraphicQueueItem item) {
diff --git a/engines/asylum/system/screen.h b/engines/asylum/system/screen.h
index 8149a2e300..18bd930242 100644
--- a/engines/asylum/system/screen.h
+++ b/engines/asylum/system/screen.h
@@ -60,9 +60,14 @@ public:
void setPalette(ResourcePack *resPack, int32 entry) {
setPalette(resPack->getResource(entry)->data + 32);
}
+
+ void setGammaLevel(ResourcePack *resPack, int32 entry, int32 val);
+
void drawWideScreen(int16 barSize);
void clearScreen();
+ void palFade(uint32 red, int32 milliseconds, int32 param);
+
void addGraphicToQueue(int32 resId, int32 frameIdx, int32 x, int32 y, int32 flags, int32 transTableNum, int32 priority);
void addCrossFadeGraphicToQueue(int32 resId, int32 frameIdx, int32 x, int32 y, int32 redId2, int32 x2, int32 y2, int32 flags, int32 priority);
void addGraphicToQueue(GraphicQueueItem item);
diff --git a/engines/asylum/system/sound.cpp b/engines/asylum/system/sound.cpp
index 708f363278..ea514d1288 100644
--- a/engines/asylum/system/sound.cpp
+++ b/engines/asylum/system/sound.cpp
@@ -72,7 +72,7 @@ void convertVolume(int32 &vol) {
// from engines/agos/sound.cpp
void convertPan(int32 &pan) {
- // DirectSound was orginally used, which specifies volume
+ // DirectSound was originally used, which specifies volume
// and panning differently than ScummVM does, using a logarithmic scale
// rather than a linear one.
//
@@ -94,6 +94,10 @@ void convertPan(int32 &pan) {
}
}
+void Sound::setVolume(int32 resId, double volume) {
+ error("[Sound::setVolume] not implemented");
+}
+
int32 Sound::getBufferPosition(int32 resId) {
int32 pos = -1;
@@ -149,7 +153,7 @@ bool Sound::isPlaying(int32 resId) {
return false;
}
-void Sound::playSound(ResourcePack *pack, int32 resId, int32 volume, bool looping, int32 panning, bool overwrite) {
+void Sound::playSound(ResourcePack *pack, ResourceId resId, int32 volume, bool looping, int32 panning, bool overwrite) {
ResourceEntry *resource = pack->getResource(resId);
if (_mixer->isSoundHandleActive(_soundHandle)) {
if (overwrite) {
@@ -184,7 +188,7 @@ void Sound::playSound(ResourcePack *pack, int32 resId, bool looping, int32 volum
}
-void Sound::playSound(int32 resId, bool looping, int32 volume, int32 panning, bool fromBuffer) {
+void Sound::playSound(ResourceId resId, bool looping, int32 volume, int32 panning, bool fromBuffer) {
if (fromBuffer) {
playSound(_soundPack, resId, looping, volume, panning);
} else {
@@ -236,6 +240,7 @@ void Sound::playMusic(int32 resId) {
stopMusic();
// TODO Play music :P
+ error("[Sound::playMusic] not implemented");
}
void Sound::playMusic(ResourcePack *pack, int32 resId) {
diff --git a/engines/asylum/system/sound.h b/engines/asylum/system/sound.h
index fecf91273a..7b9cf08b90 100644
--- a/engines/asylum/system/sound.h
+++ b/engines/asylum/system/sound.h
@@ -34,7 +34,7 @@
namespace Asylum {
typedef struct SoundItem {
- int32 resId;
+ ResourceId resId;
int32 field_4;
int32 field_8;
int32 field_C;
@@ -42,7 +42,7 @@ typedef struct SoundItem {
} SoundItem;
typedef struct FrameSoundItem {
- int32 resId;
+ ResourceId resId;
int32 frameIdx;
int32 index;
int32 field_C;
@@ -54,7 +54,7 @@ typedef struct FrameSoundItem {
typedef struct AmbientSoundItem {
int32 field_0;
int32 flags;
- int32 resId;
+ ResourceId resId;
int32 field_C;
int32 field_10;
int32 field_14;
@@ -65,7 +65,7 @@ typedef struct AmbientSoundItem {
} AmbientSoundItem;
typedef struct SoundBufferItem {
- int32 resId;
+ ResourceId resId;
Audio::SoundHandle handle;
int32 unknown;
} SoundBufferItem;
@@ -75,8 +75,8 @@ public:
Sound(Audio::Mixer *mixer);
~Sound();
- bool addToSoundBuffer(int32 resId);
- void removeFromSoundBuffer(int32 resId);
+ bool addToSoundBuffer(ResourceId resId);
+ void removeFromSoundBuffer(ResourceId resId);
void clearSoundBuffer();
/**
@@ -84,20 +84,22 @@ public:
*
* @param overwrite determine if _soundHandle should be overwritten if still active
*/
- void playSound(ResourcePack *pack, int32 resId, int32 volume, bool looping = false, int32 panning = 0, bool overwrite = false);
- void playSound(ResourcePack *pack, int32 resId, bool looping, int32 volume, int32 panning);
+ void playSound(ResourcePack *pack, ResourceId resId, int32 volume, bool looping = false, int32 panning = 0, bool overwrite = false);
+ void playSound(ResourcePack *pack, ResourceId resId, bool looping, int32 volume, int32 panning);
void playSound(ResourceEntry *resource, bool looping, int32 volume, int32 panning);
- void playSound(int32 resId, bool looping, int32 volume, int32 panning, bool fromBuffer = false);
- void stopSound(int32 resId);
+ void playSound(ResourceId resId, bool looping, int32 volume, int32 panning, bool fromBuffer = false);
+ void stopSound(ResourceId resId);
void stopSound();
void stopAllSounds(bool stopSpeechAndMusic = false);
- void playSpeech(int32 resId);
+ void playSpeech(ResourceId resId);
- void playMusic(ResourcePack *pack, int32 resId);
- void playMusic(int32 resId);
+ void playMusic(ResourcePack *pack, ResourceId resId);
+ void playMusic(ResourceId resId);
void stopMusic();
+ void setVolume(ResourceId resId, double volume);
+
/**
* Check if the buffered sound sample that matches the provided id currently
* has an active handle.
@@ -106,7 +108,7 @@ public:
* music or speech, as those resources aren't managed beyond simple
* start/stop requests.
*/
- bool isPlaying(int32 resId);
+ bool isPlaying(ResourceId resId);
/**
* Check if the unmanaged sound handle is in use
diff --git a/engines/asylum/views/scene.cpp b/engines/asylum/views/scene.cpp
index 29f589575b..a002bf4d5d 100644
--- a/engines/asylum/views/scene.cpp
+++ b/engines/asylum/views/scene.cpp
@@ -103,13 +103,8 @@ Scene::Scene(uint8 sceneIdx, AsylumEngine *engine): _vm(engine) {
// TODO figure out what field_120 is used for
_ws->field_120 = -1;
- for (int32 a = 0; a < _ws->numActors; a++) {
- _ws->actors[a].tickValue1 = _vm->getTick();
- // FIXME This is a hack just to get the current resource
- // pack and scene into the actor instance(s)
- _ws->actors[a].setResourcePack(_resPack);
- _ws->actors[a].setScene(this);
- }
+ for (int32 a = 0; a < _ws->numActors; a++)
+ _ws->actors[a]->tickValue = _vm->getTick();
// TODO: init action list
@@ -124,7 +119,7 @@ void Scene::initialize() {
if (_ws->numBarriers > 0) {
int32 priority = 0x0FFB;
for (int32 b = 0; b < _ws->numBarriers; b++) {
- Barrier *barrier = &_ws->barriers[b];
+ Barrier *barrier = _ws->barriers[b];
barrier->priority = priority;
barrier->flags &= 0xFFFF3FFF;
priority -= 4;
@@ -151,7 +146,7 @@ void Scene::initialize() {
if (_ws->numActors > 1) {
for (int32 a = 1; a < _ws->numActors; a++) {
- Actor *act = &_ws->actors[a];
+ Actor *act = _ws->actors[a];
act->flags |= 1;
act->direction = 1;
getActor(a)->updateStatus(kActorStatusEnabled);
@@ -181,7 +176,7 @@ void Scene::initialize() {
// TODO sceneRectChangedFlag = 1;
- actor->tickValue1= _vm->getTick();
+ actor->tickValue= _vm->getTick();
// XXX This initialization was already done earlier,
// so I'm not sure why we need to do it again. Investigate.
actor->updateDirection();
@@ -221,7 +216,7 @@ Scene::~Scene() {
}
Actor* Scene::getActor(int index) {
- return &_ws->actors[(index != -1) ? index : _playerActorIdx];
+ return _ws->actors[(index != -1) ? index : _playerActorIdx];
}
void Scene::enterScene() {
@@ -232,7 +227,7 @@ void Scene::enterScene() {
_actions->_allowInput = false;
} else {
#endif
- _vm->screen()->setPalette(_resPack, _ws->palette);
+ _vm->screen()->setPalette(_resPack, _ws->currentPaletteId);
_background = _bgResource->getFrame(0);
_vm->screen()->copyToBackBuffer(
((byte *)_background->surface.pixels) + _ws->yTop * _background->surface.w + _ws->xLeft, _background->surface.w,
@@ -241,7 +236,7 @@ void Scene::enterScene() {
// FIXME
// I don't know that this is the right way to initialize the cursor
// when the scene is started. Check against the original to see
- // when the cursor is initalized, and then how it reacts to the
+ // when the cursor is initialized, and then how it reacts to the
// show_cursor opcode
Cursor::create(_cursor, _resPack, _ws->curMagnifyingGlass);
_cursor->show();
@@ -285,22 +280,22 @@ void Scene::handleEvent(Common::Event *event, bool doUpdate) {
break;
case Common::EVENT_LBUTTONUP:
- if (_actions->doesAllowInput())
+ //if (_actions->doesAllowInput())
_leftClick = true;
break;
case Common::EVENT_RBUTTONUP:
- if (_actions->doesAllowInput()) {
+ //if (_actions->doesAllowInput()) {
// TODO This isn't always going to be the magnifying glass
// Should check the current pointer region to identify the type
// of cursor to use
Cursor::create(_cursor, _resPack, _ws->curMagnifyingGlass);
_rightButton = false;
- }
+ //}
break;
case Common::EVENT_RBUTTONDOWN:
- if (_actions->doesAllowInput())
+ //if (_actions->doesAllowInput())
_rightButton = true;
break;
@@ -607,10 +602,10 @@ void Scene::handleMouseUpdate(int direction, Common::Rect rect) {
int32 targetUpdateType = 0;
switch (type) {
case kHitActionArea:
- targetUpdateType = _ws->actions[targetIdx].actionType;
+ targetUpdateType = _ws->actions[targetIdx]->actionType;
break;
case kHitBarrier:
- targetUpdateType = _ws->barriers[targetIdx].flags2;
+ targetUpdateType = _ws->barriers[targetIdx]->flags2;
break;
case kHitActor:
targetUpdateType = getActor(targetIdx)->status;
@@ -651,10 +646,10 @@ void Scene::handleMouseUpdate(int direction, Common::Rect rect) {
int32 Scene::hitTestBarrier(const Common::Point pt) {
int32 targetIdx = -1;
for (int32 i = 0; i < _ws->numBarriers; i++) {
- Barrier b = _ws->barriers[i];
+ Barrier *b = _ws->barriers[i];
if (_ws->isBarrierOnScreen(i))
- if (b.polyIdx)
- if (hitTestPixel(b.resId, b.frameIdx, pt.x, pt.y, b.flags & 0x1000)) {
+ if (b->polyIdx)
+ if (hitTestPixel(b->resId, b->frameIdx, pt.x, pt.y, b->flags & 0x1000)) {
targetIdx = i;
break;
}
@@ -683,7 +678,7 @@ int32 Scene::hitTest(const Common::Point pt, HitType &type) {
int32 Scene::hitTestActionArea(const Common::Point pt) {
int32 targetIdx = findActionArea(Common::Point(_ws->xLeft + pt.x, _ws->yTop + pt.y));
- if ( targetIdx == -1 || !(_ws->actions[targetIdx].actionType & 0x17))
+ if ( targetIdx == -1 || !(_ws->actions[targetIdx]->actionType & 0x17))
targetIdx = -1;
return targetIdx;
@@ -696,8 +691,8 @@ int32 Scene::findActionArea(const Common::Point pt) {
// the original did
int32 targetIdx = -1;
for (int32 i = 0; i < _ws->numActions; i++) {
- ActionArea a = _ws->actions[i];
- PolyDefinitions p = _polygons->entries[a.polyIdx];
+ ActionArea *a = _ws->actions[i];
+ PolyDefinitions p = _polygons->entries[a->polyIdx];
if (p.contains(pt.x, pt.y)) {
targetIdx = i;
break;
@@ -714,7 +709,7 @@ int32 Scene::hitTestScene(const Common::Point pt, HitType &type) {
int32 result = findActionArea(Common::Point(top, left));
if (result != -1) {
- if (LOBYTE(_ws->actions[result].actionType) & 8) {
+ if (LOBYTE(_ws->actions[result]->actionType) & 8) {
type = kHitActionArea;
return result;
}
@@ -761,21 +756,8 @@ bool Scene::hitTestPixel(int32 grResId, int32 frame, int16 x, int16 y, bool flip
return rect.contains(x, y);
}
-
-void Scene::stopSound(int32 barrierIndex, int32 actorIndex) {
- int32 sndResId = 0;
-
- if (actorIndex) {
- sndResId = getActor(actorIndex)->soundResId;
- } else {
- if (barrierIndex) {
- sndResId = _ws->barriers[barrierIndex].soundResId;
- }
- }
-
- if (_vm->sound()->isPlaying(sndResId)) {
- _vm->sound()->stopSound(sndResId);
- }
+void Scene::changePlayerActorIndex(ActorIndex index) {
+ error("[Scene::changePlayerActorIndex] not implemented");
}
void Scene::updateActors() {
@@ -792,7 +774,7 @@ void Scene::updateBarriers() {
if (barriersCount > 0) {
for (int32 b = 0; b < barriersCount; b++) {
- Barrier *barrier = &_ws->barriers[b];
+ Barrier *barrier = _ws->barriers[b];
if (barrier->field_3C == 4) {
if (_ws->isBarrierVisible(b)) {
@@ -910,7 +892,7 @@ void Scene::updateBarriers() {
if (canPlaySound) {
barrier->updateSoundItems(_vm->sound());
- stopSound(b, 0);
+ barrier->stopSound();
}
// TODO: get sound functions according with scene
@@ -1100,6 +1082,69 @@ void Scene::updateAdjustScreen() {
}
+bool Scene::updateSceneCoordinates(int32 targetX, int32 targetY, int32 A0, bool checkSceneCoords, int32 *param) {
+ Common::Rect *sr = &_ws->sceneRects[_ws->sceneRectIdx];
+
+ _ws->targetX = targetX;
+ _ws->targetY = targetY;
+
+ _ws->field_A0 = A0;
+
+ // Adjust coordinates
+ if (checkSceneCoords)
+ if (_ws->targetX + 640 > _ws->width)
+ _ws->targetX = _ws->width - 640;
+
+ if (_ws->targetX < sr->left)
+ _ws->targetX = sr->left;
+
+ if (_ws->targetY < sr->top)
+ _ws->targetY = sr->top;
+
+ if (_ws->targetX + 640 > sr->right)
+ _ws->targetX = sr->right - 640;
+
+ if (_ws->targetY + 480 < sr->bottom)
+ _ws->targetY = sr->bottom - 480;
+
+ if (checkSceneCoords)
+ if (_ws->targetY + 480 > _ws->height)
+ _ws->targetY = _ws->height - 480;
+
+ // Adjust scene offsets & coordinates
+ _sceneOffset = 0;
+ _sceneXLeft = _ws->xLeft;
+ _sceneYTop = _ws->yTop;
+
+ int32 diffX = _ws->targetX - _ws->xLeft;
+ int32 diffY = _ws->targetY - _ws->yTop;
+
+ if (abs(diffX) <= abs(diffY)) {
+ if (_ws->yTop > _ws->targetY)
+ _ws->field_A0 = -_ws->field_A0;
+
+ _sceneOffsetAdd = Common::Rational(_ws->field_A0, diffY) * diffX;
+
+ if (param != NULL && abs(diffY) <= abs(_ws->field_A0)) {
+ _ws->targetX = -1;
+ *param = 0;
+ return true;
+ }
+ } else {
+ if (_ws->xLeft > _ws->targetX)
+ _ws->field_A0 = -_ws->field_A0;
+
+ _sceneOffsetAdd = Common::Rational(_ws->field_A0, diffX) * diffY;
+
+ if (param != NULL && abs(diffX) <= abs(_ws->field_A0)) {
+ _ws->targetX = -1;
+ return true;
+ }
+ }
+
+ return false;
+}
+
// ----------------------------------
// ---------- DRAW REGION -----------
// ----------------------------------
@@ -1141,7 +1186,7 @@ void Scene::drawActorsAndBarriers() {
// character, this will have to do :P
for (int32 i = 0; i < _ws->numActors; i++) {
int actorRegPt = 0;
- Actor *act = &_ws->actors[i];
+ Actor *act = _ws->actors[i];
Common::Point pt;
// XXX Since we're not using CharacterUpdateItems,
@@ -1176,7 +1221,7 @@ void Scene::drawActorsAndBarriers() {
// XXX from .text:0040a4d1
for (int32 barIdx = 0; barIdx < _ws->numBarriers; barIdx++) {
- Barrier *bar = &_ws->barriers[barIdx];
+ Barrier *bar = _ws->barriers[barIdx];
bool actInBar = bar->boundingRect.contains(act->boundingRect);
bool intersects = false;
@@ -1278,7 +1323,7 @@ int Scene::queueActorUpdates() {
if (_ws->numActors > 0) {
Common::Point pt;
for (int32 a = 0; a < _ws->numActors; a++) {
- Actor *actor = &_ws->actors[a];
+ Actor *actor = _ws->actors[a];
if ((actor->flags & 0xFF) & 1) { // check this mask
getActorPosition(actor, &pt);
@@ -1311,7 +1356,7 @@ int Scene::queueBarrierUpdates() {
if (barriersCount > 0) {
for (int32 b = 0; b < barriersCount; b++) {
- Barrier *barrier = &_ws->barriers[b];
+ Barrier *barrier = _ws->barriers[b];
if (!(barrier->flags & 4) && !((barrier->flags & 0xFF) & 0x40)) {
if (_ws->isBarrierOnScreen(b)) {
@@ -1433,14 +1478,14 @@ void Scene::debugShowPolygons() {
void Scene::debugShowBarriers() {
for (int32 p = 0; p < _ws->numBarriers; p++) {
Graphics::Surface surface;
- Barrier b = _ws->barriers[p];
+ Barrier *b = _ws->barriers[p];
- if (b.flags & 0x20) {
- surface.create(b.boundingRect.right - b.boundingRect.left + 1,
- b.boundingRect.bottom - b.boundingRect.top + 1,
+ if (b->flags & 0x20) {
+ surface.create(b->boundingRect.right - b->boundingRect.left + 1,
+ b->boundingRect.bottom - b->boundingRect.top + 1,
1);
- surface.frameRect(b.boundingRect, 0x22);
- copyToBackBufferClipped(&surface, b.x, b.y);
+ surface.frameRect(b->boundingRect, 0x22);
+ copyToBackBufferClipped(&surface, b->x, b->y);
}
surface.free();
@@ -1451,14 +1496,14 @@ void Scene::debugShowBarriers() {
void Scene::debugShowActors() {
for (int32 p = 0; p < _ws->numActors; p++) {
Graphics::Surface surface;
- Actor a = _ws->actors[p];
+ Actor *a = _ws->actors[p];
- if (a.flags & 2) {
- surface.create(a.boundingRect.right - a.boundingRect.left + 1,
- a.boundingRect.bottom - a.boundingRect.top + 1,
+ if (a->flags & 2) {
+ surface.create(a->boundingRect.right - a->boundingRect.left + 1,
+ a->boundingRect.bottom - a->boundingRect.top + 1,
1);
- surface.frameRect(a.boundingRect, 0x22);
- copyToBackBufferClipped(&surface, a.x, a.y);
+ surface.frameRect(a->boundingRect, 0x22);
+ copyToBackBufferClipped(&surface, a->x, a->y);
}
surface.free();
diff --git a/engines/asylum/views/scene.h b/engines/asylum/views/scene.h
index dd6b73e52a..e6758e0d25 100644
--- a/engines/asylum/views/scene.h
+++ b/engines/asylum/views/scene.h
@@ -26,8 +26,6 @@
#ifndef ASYLUM_SCENE_H
#define ASYLUM_SCENE_H
-#include "common/events.h"
-
#include "asylum/asylum.h"
#include "asylum/respack.h"
#include "asylum/system/graphics.h"
@@ -38,6 +36,9 @@
#include "asylum/system/cursor.h"
#include "asylum/system/speech.h"
+#include "common/events.h"
+#include "common/rational.h"
+
#define SCENE_FILE_MASK "scn.%03d"
#define MUSIC_FILE_MASK "mus.%03d"
@@ -126,9 +127,11 @@ public:
/**
* Return the index of the current player actor
*/
- ActorIndex getActorIndex() { return _playerActorIdx; }
+ ActorIndex getPlayerActorIndex() { return _playerActorIdx; }
- void setActorIndex(ActorIndex index) { _playerActorIdx = index; }
+ void setPlayerActorIndex(ActorIndex index) { _playerActorIdx = index; }
+
+ void changePlayerActorIndex(ActorIndex index);
/**
* Get a reference to an actor object from the
@@ -143,17 +146,6 @@ public:
*/
bool defaultActorDirectionLoaded(int actorIndex, int grResTableIdx);
- /** .text:00414C30
- * Check if a sound resource is playing for the barrier,
- * or actor that is specified, and if so, stop playing the
- * sample.
- *
- * NOTE this method was originally called from within
- * Barrier::updateSoundItems(), but that would require
- * the barrier class to have some knowledge about actors,
- * which seems a bit wonky.
- */
- void stopSound(int32 barrierIndex, int32 actorIndex);
/** .text:004094c0
* Determine the amount to increase the supplied sound
* sample's volume based on the actor's position
@@ -169,6 +161,8 @@ public:
ActorDirection getGlobalDirection() { return _globalDirection; }
+ bool updateSceneCoordinates(int32 targetX, int32 targetY, int32 val, bool checkSceneCoords = false, int32 *param = NULL);
+
protected:
/** .text:0040EA50
* Run various hit tests and return the index,
@@ -235,6 +229,10 @@ private:
uint32 _globalX;
uint32 _globalY;
+ int32 _sceneOffset;
+ int32 _sceneXLeft;
+ int32 _sceneYTop;
+ Common::Rational _sceneOffsetAdd;
void update();
void startMusic();
Commit: ffddfcd8db935935292e3121167b1a1723bfe5c5
https://github.com/scummvm/scummvm/commit/ffddfcd8db935935292e3121167b1a1723bfe5c5
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:06+02:00
Commit Message:
ASYLUM: Use typed resource ID
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@468 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/asylum.cpp
engines/asylum/console.cpp
engines/asylum/module.mk
engines/asylum/resources/actionarea.h
engines/asylum/resources/actionlist.cpp
engines/asylum/resources/actor.cpp
engines/asylum/resources/actor.h
engines/asylum/resources/barrier.cpp
engines/asylum/resources/barrier.h
engines/asylum/resources/encounters.cpp
engines/asylum/resources/encounters.h
engines/asylum/resources/worldstats.cpp
engines/asylum/resources/worldstats.h
engines/asylum/respack.cpp
engines/asylum/respack.h
engines/asylum/shared.h
engines/asylum/system/cursor.cpp
engines/asylum/system/cursor.h
engines/asylum/system/graphics.cpp
engines/asylum/system/graphics.h
engines/asylum/system/screen.cpp
engines/asylum/system/screen.h
engines/asylum/system/sound.cpp
engines/asylum/system/sound.h
engines/asylum/system/speech.cpp
engines/asylum/system/speech.h
engines/asylum/system/text.cpp
engines/asylum/system/text.h
engines/asylum/system/video.cpp
engines/asylum/system/video.h
engines/asylum/views/blowuppuzzle.cpp
engines/asylum/views/blowuppuzzle.h
engines/asylum/views/menu.cpp
engines/asylum/views/scene.cpp
engines/asylum/views/scene.h
diff --git a/engines/asylum/asylum.cpp b/engines/asylum/asylum.cpp
index b0867f5940..1bf3488320 100644
--- a/engines/asylum/asylum.cpp
+++ b/engines/asylum/asylum.cpp
@@ -185,8 +185,8 @@ void AsylumEngine::playIntro() {
_video->playVideo(1, Config.showMovieSubtitles);
- if (_scene->worldstats()->musicCurrentResId != -666)
- _sound->playMusic(_scene->worldstats()->musicCurrentResId);
+ if (_scene->worldstats()->musicCurrentResourceId != -666)
+ _sound->playMusic(_scene->worldstats()->musicCurrentResourceId);
_screen->clearScreen();
@@ -224,7 +224,7 @@ void AsylumEngine::handleEvents(bool doUpdate) { // k_sub_40AE30 (0040AE30)
// the alarm by flipping the switch. The sound class needs to be extended
// to be able to handle multiple handles.
// The currently active sound resources can probably also be buffered into
- // the scene's soundResId[] array (seems that's the way the original worked,
+ // the scene's soundResourceId[] array (seems that's the way the original worked,
// especially when you examine isSoundinList() or isSoundPlaying())
_scene->enterScene();
diff --git a/engines/asylum/console.cpp b/engines/asylum/console.cpp
index 87af0f8832..927c906890 100644
--- a/engines/asylum/console.cpp
+++ b/engines/asylum/console.cpp
@@ -74,8 +74,8 @@ bool Console::cmdDumpActionArea(int32 argc, const char **argv) {
void Console::printActionAreaStats(ActionArea *a) {
DebugPrintf("id[%d] name[%s] field01[%d] field02[%d] field40[%d] field44[%d] flags[%d] \n"
- "actionListIdx1[%d] actionListIdx2[%d] actionType[%d] field_7C[%d] polyIdx[%d]\n"
- "field_84[%d] field_88[%d] soundResId[%d] field_90[%d] palette[%d] volume[%d]\n\n",
+ "scriptIndex[%d] actionListIdx2[%d] actionType[%d] field_7C[%d] polyIdx[%d]\n"
+ "field_84[%d] field_88[%d] soundResourceId[%d] field_90[%d] paletteValue[%d] volume[%d]\n\n",
a->id,
a->name,
a->field01,
@@ -91,7 +91,7 @@ void Console::printActionAreaStats(ActionArea *a) {
a->polyIdx,
a->field_84,
a->field_88,
- a->soundResId,
+ a->soundResourceId,
a->field_90,
a->paletteValue,
//a->array[5],
diff --git a/engines/asylum/module.mk b/engines/asylum/module.mk
index 90e75a970d..bfd0b28593 100644
--- a/engines/asylum/module.mk
+++ b/engines/asylum/module.mk
@@ -5,6 +5,7 @@ MODULE_OBJS := \
resources/actionlist.o \
resources/actor.o \
resources/barrier.o \
+ resources/encounters.o \
resources/polygons.o \
resources/worldstats.o \
system/config.o \
@@ -15,12 +16,13 @@ MODULE_OBJS := \
system/speech.o \
system/text.o \
system/video.o \
+ views/blowuppuzzle.o \
views/menu.o \
views/scene.o \
asylum.o \
- detection.o \
console.o \
- respack.o
+ detection.o \
+ respack.o
# This module can be built as a plugin
ifeq ($(ENABLE_ASYLUM), DYNAMIC_PLUGIN)
diff --git a/engines/asylum/resources/actionarea.h b/engines/asylum/resources/actionarea.h
index aa872b9dd0..cf92af8eaf 100644
--- a/engines/asylum/resources/actionarea.h
+++ b/engines/asylum/resources/actionarea.h
@@ -26,6 +26,8 @@
#ifndef ASYLUM_ACTIONAREA_H
#define ASYLUM_ACTIONAREA_H
+#include "asylum/shared.h"
+
#include "common/array.h"
namespace Asylum {
@@ -50,7 +52,7 @@ public:
int32 polyIdx;
int32 field_84;
int32 field_88;
- int32 soundResId;
+ ResourceId soundResourceId;
int32 field_90;
int32 paletteValue;
int32 array[5];
diff --git a/engines/asylum/resources/actionlist.cpp b/engines/asylum/resources/actionlist.cpp
index f79942900e..0416a72d84 100644
--- a/engines/asylum/resources/actionlist.cpp
+++ b/engines/asylum/resources/actionlist.cpp
@@ -377,7 +377,7 @@ IMPLEMENT_OPCODE(PlayAnimation) {
_scene->setGlobalX(barrier->x);
_scene->setGlobalY(barrier->y);
} else {
- GraphicResource *res = new GraphicResource(_scene->getResourcePack(), barrier->resId);
+ GraphicResource *res = new GraphicResource(_scene->getResourcePack(), barrier->resourceId);
GraphicFrame *frame = res->getFrame(barrier->frameIdx);
_scene->setGlobalX(frame->x + (frame->getWidth() >> 1) + barrier->x);
@@ -788,7 +788,7 @@ IMPLEMENT_OPCODE(SetVolume) {
volume = 0;
}
- _scene->vm()->sound()->setVolume(item.resId, volume);
+ _scene->vm()->sound()->setVolume(item.resourceId, volume);
}
//////////////////////////////////////////////////////////////////////////
@@ -1110,7 +1110,7 @@ IMPLEMENT_OPCODE(JumpBarrierFrame) {
// Opcode 0x52
IMPLEMENT_OPCODE(DeleteGraphics) {
for (uint i = 0; i < 55; i++)
- _scene->vm()->screen()->deleteGraphicFromQueue(_scene->getActor(cmd->param1)->grResTable[cmd->param1]);
+ _scene->vm()->screen()->deleteGraphicFromQueue(_scene->getActor(cmd->param1)->graphicResourceIds[cmd->param1]);
}
//////////////////////////////////////////////////////////////////////////
@@ -1194,7 +1194,7 @@ IMPLEMENT_OPCODE(SetResourcePalette) {
if (cmd->param1 < 0)
error("Invalid resource id in opcode %s (0x%02X) in Scene %d Line %d", _opcodes[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
- _scene->worldstats()->currentPaletteId = _scene->worldstats()->grResId[cmd->param1];
+ _scene->worldstats()->currentPaletteId = _scene->worldstats()->graphicResourceIds[cmd->param1];
_scene->vm()->screen()->setPalette(_scene->getResourcePack(), _scene->worldstats()->currentPaletteId);
_scene->vm()->screen()->setGammaLevel(_scene->getResourcePack(), _scene->worldstats()->currentPaletteId, 0);
diff --git a/engines/asylum/resources/actor.cpp b/engines/asylum/resources/actor.cpp
index 4bf31ae5c7..a194a4ad2f 100644
--- a/engines/asylum/resources/actor.cpp
+++ b/engines/asylum/resources/actor.cpp
@@ -275,8 +275,8 @@ void Actor::walkTo(int32 curX, int32 curY) {
}
void Actor::stopSound() {
- if (soundResId && _scene->vm()->sound()->isPlaying(soundResId))
- _scene->vm()->sound()->stopSound(soundResId);
+ if (soundResourceId && _scene->vm()->sound()->isPlaying(soundResourceId))
+ _scene->vm()->sound()->stopSound(soundResourceId);
}
void Actor::setPosition(int32 newX, int32 newY, int32 newDirection, int32 frame) {
@@ -325,7 +325,7 @@ void Actor::faceTarget(int32 targetId, int32 targetType) {
}
Barrier *barrier = _scene->worldstats()->getBarrierByIndex(barrierIdx);
- GraphicResource *gra = new GraphicResource(_scene->getResourcePack(), barrier->resId);
+ GraphicResource *gra = new GraphicResource(_scene->getResourcePack(), barrier->resourceId);
// FIXME
// The original actually grabs the current frame of the target
@@ -478,7 +478,7 @@ void Actor::updateStatus(ActorStatus actorStatus) {
case kActorStatusDisabled:
updateGraphicData(15);
- graphicResourceId = grResTable[(direction > 4 ? 8 - direction : direction) + 15];
+ graphicResourceId = graphicResourceIds[(direction > 4 ? 8 - direction : direction) + 15];
// TODO set word_446EE4 to -1. This global seems to be used with screen blitting
break;
@@ -530,7 +530,7 @@ void Actor::updateStatus(ActorStatus actorStatus) {
frameNum = 0;
if (_index > 12)
- graphicResourceId = grResTable[direction + 30];
+ graphicResourceId = graphicResourceIds[direction + 30];
if (_scene->getPlayerActorIndex() == _index) {
resource->load(_scene->getResourcePack(), graphicResourceId);
@@ -538,10 +538,10 @@ void Actor::updateStatus(ActorStatus actorStatus) {
}
if (_index == 11)
- graphicResourceId = grResTable[_scene->getGlobalDirection() > 4 ? 8 - _scene->getGlobalDirection() : _scene->getGlobalDirection()];
+ graphicResourceId = graphicResourceIds[_scene->getGlobalDirection() > 4 ? 8 - _scene->getGlobalDirection() : _scene->getGlobalDirection()];
// Reload the graphic resource if the resource ID has changed
- if (resource->getEntryNum() != graphicResourceId)
+ if (resource->getResourceId() != graphicResourceId)
resource->load(_scene->getResourcePack(), graphicResourceId);
frameCount = resource->getFrameCount();
@@ -553,7 +553,7 @@ void Actor::updateStatus(ActorStatus actorStatus) {
}
void Actor::updateGraphicData(uint32 offset) {
- graphicResourceId = grResTable[(direction > 4 ? 8 - direction : direction) + offset];
+ graphicResourceId = graphicResourceIds[(direction > 4 ? 8 - direction : direction) + offset];
GraphicResource *resource = new GraphicResource(_scene->getResourcePack(), graphicResourceId);
frameCount = resource->getFrameCount();
@@ -568,17 +568,17 @@ void Actor::setDirectionFrom(uint32 parameter, DirectionFrom from) {
void Actor::setDirection(int actorDirection) {
direction = (actorDirection > 4) ? 8 - actorDirection : actorDirection;
- int32 grResId;
+ ResourceId resourceId;
if (field_944 != 5) {
switch (status) {
case 0x04:
case 0x05:
case 0x0E: {
- grResId = grResTable[direction + 5];
+ resourceId = graphicResourceIds[direction + 5];
// FIXME this seems kind of wasteful just to grab a frame count
- GraphicResource *gra = new GraphicResource(_scene->getResourcePack(), grResId);
- grResId = grResId;
+ GraphicResource *gra = new GraphicResource(_scene->getResourcePack(), resourceId);
+ resourceId = resourceId;
frameCount = gra->getFrameCount();
delete gra;
}
@@ -592,19 +592,19 @@ void Actor::setDirection(int actorDirection) {
// but I'm assuming if control drops through to here, getActor() would
// pull the right object because the _playerActorIndex should == 11
if (direction > 4)
- grResId = grResTable[8 - direction];
+ resourceId = graphicResourceIds[8 - direction];
else
- grResId = grResTable[direction];
+ resourceId = graphicResourceIds[direction];
}
}
break;
case 0x01:
case 0x02:
case 0x0C:
- grResId = grResTable[direction];
+ resourceId = graphicResourceIds[direction];
break;
case 0x08:
- grResId = grResTable[direction + 20];
+ resourceId = graphicResourceIds[direction + 20];
break;
default:
warning ("[setActorDirection] default case hit with status of %d", status);
@@ -747,7 +747,7 @@ void Actor::updateActorSub01() {
// Check if the actor's name is "Crow"?
if (_scene->vm()->getRandom(100) < 50) {
// TODO
- // Check if soundResId04 is assigned, and if so,
+ // Check if soundResourceId04 is assigned, and if so,
// if it's playing
// If true, check characterSub407260(10)
// and if that's true, do characterDirection(9)
@@ -760,7 +760,7 @@ void Actor::updateActorSub01() {
if (_scene->vm()->isGameFlagNotSet(kGameFlagScriptProcessing)) { // processing action list
if (isVisible()) {
// if some_encounter_flag
- // if !soundResId04
+ // if !soundResourceId04
if (_scene->vm()->getRandom(100) < 50) {
if (_scene->getSceneIndex() == 13) {
; // sub414810(507)
@@ -784,7 +784,7 @@ void Actor::updateActorSub01() {
bool Actor::defaultDirectionLoaded(int grResTableIdx) {
- return grResTable[grResTableIdx] != grResTable[5];
+ return graphicResourceIds[grResTableIdx] != graphicResourceIds[5];
}
} // end of namespace Asylum
diff --git a/engines/asylum/resources/actor.h b/engines/asylum/resources/actor.h
index 992e7f5e05..95a5f5f317 100644
--- a/engines/asylum/resources/actor.h
+++ b/engines/asylum/resources/actor.h
@@ -232,7 +232,7 @@ public:
int32 x;
int32 y;
- uint32 graphicResourceId;
+ ResourceId graphicResourceId;
int32 field_C; // BarrierIndex? Mask index?
uint32 frameNum;
uint32 frameCount;
@@ -262,7 +262,7 @@ public:
int32 walkingSound4;
int32 field_64C;
int32 field_650;
- int32 grResTable[55];
+ ResourceId graphicResourceIds[55];
char name[256];
int32 field_830[20];
int32 field_880[20];
@@ -274,7 +274,7 @@ public:
int32 flags2;
int32 field_934;
int32 field_938;
- ResourceId soundResId; // field_93C
+ ResourceId soundResourceId; // field_93C
int32 numberValue01;
int32 field_944;
int32 field_948;
diff --git a/engines/asylum/resources/barrier.cpp b/engines/asylum/resources/barrier.cpp
index 3c02c8e942..a60e1daa26 100644
--- a/engines/asylum/resources/barrier.cpp
+++ b/engines/asylum/resources/barrier.cpp
@@ -44,23 +44,24 @@ void Barrier::destroyAndRemoveFromQueue() {
destroy();
flags|= kBarrierFlag20000;
- _scene->vm()->screen()->deleteGraphicFromQueue(resId);
+ _scene->vm()->screen()->deleteGraphicFromQueue(resourceId);
}
int32 Barrier::getRandomId() {
int32 numRes = 0;
- int32 rndResId[5];
- memset(&rndResId, 0, sizeof(rndResId));
+ ResourceId randomResourceIds[5];
+ memset(&randomResourceIds, 0, sizeof(randomResourceIds));
for (int32 i = 0; i < 5; i++) {
if (field_68C[i]) {
- rndResId[numRes] = field_68C[i];
+ randomResourceIds[numRes] = field_68C[i];
numRes++;
}
}
+
if (numRes > 0)
- return rndResId[rand() % numRes];
+ return randomResourceIds[rand() % numRes];
- return resId;
+ return resourceId;
}
int32 Barrier::checkFlags() {
@@ -80,10 +81,10 @@ void Barrier::setNextFrame(int32 targetFlags) {
void Barrier::updateSoundItems(Sound *snd) {
for (int32 i = 0; i < 16; i++) {
SoundItem *item = &soundItems[i];
- if (snd->isPlaying(item->resId)) {
+ if (snd->isPlaying(item->resourceId)) {
if (item->field_4) {
- snd->stopSound(item->resId);
- item->resId = 0;
+ snd->stopSound(item->resourceId);
+ item->resourceId = 0;
item->field_4 = 0;
}
}
@@ -96,8 +97,8 @@ void Barrier::updateSoundItems(Sound *snd) {
}
void Barrier::stopSound() {
- if (_scene->vm()->sound()->isPlaying(soundResId))
- _scene->vm()->sound()->stopSound(soundResId);
+ if (_scene->vm()->sound()->isPlaying(soundResourceId))
+ _scene->vm()->sound()->stopSound(soundResourceId);
}
} // end of namespace Asylum
diff --git a/engines/asylum/resources/barrier.h b/engines/asylum/resources/barrier.h
index b29ad5d9d6..0c8ef52164 100644
--- a/engines/asylum/resources/barrier.h
+++ b/engines/asylum/resources/barrier.h
@@ -72,7 +72,7 @@ public:
void stopSound();
int32 id;
- uint32 resId;
+ ResourceId resourceId;
int32 x;
int32 y;
Common::Rect boundingRect;
@@ -105,7 +105,7 @@ public:
int32 soundY;
int32 field_688;
int32 field_68C[5];
- int32 soundResId;
+ ResourceId soundResourceId;
int32 field_6A4;
private:
diff --git a/engines/asylum/resources/encounters.cpp b/engines/asylum/resources/encounters.cpp
index 23a206b3cf..d9175a9a2c 100644
--- a/engines/asylum/resources/encounters.cpp
+++ b/engines/asylum/resources/encounters.cpp
@@ -23,9 +23,9 @@
*
*/
-#include "common/file.h"
+#include "asylum/resources/encounters.h"
-#include "asylum/encounters.h"
+#include "common/file.h"
namespace Asylum {
@@ -53,7 +53,7 @@ Encounter::Encounter(Scene *scene) {
item.keywordIndex = file.readSint32LE();
item.field2 = file.readSint32LE();
- item.scriptResId = file.readSint32LE();
+ item.scriptResourceId = file.readSint32LE();
for (uint8 j = 0; j < 50; j++) {
item.array[j] = file.readSint32LE();
}
diff --git a/engines/asylum/resources/encounters.h b/engines/asylum/resources/encounters.h
index 2857a79dc7..1b66942567 100644
--- a/engines/asylum/resources/encounters.h
+++ b/engines/asylum/resources/encounters.h
@@ -26,15 +26,18 @@
#ifndef ASYLUM_ENCOUNTERS_H
#define ASYLUM_ENCOUNTERS_H
+#include "asylum/shared.h"
+
#include "common/array.h"
-#include "asylum/scene.h"
namespace Asylum {
+class Scene;
+
typedef struct EncounterItem {
int32 keywordIndex;
int32 field2;
- int32 scriptResId;
+ ResourceId scriptResourceId;
int32 array[50];
int16 value;
} EncounterItem;
@@ -47,7 +50,7 @@ typedef struct EncounterStruct {
int32 frameNum;
int32 transTableNum;
int32 status;
- int32 grResId;
+ ResourceId graphicResourceId;
} EncounterStruct;
class Encounter {
diff --git a/engines/asylum/resources/worldstats.cpp b/engines/asylum/resources/worldstats.cpp
index 7cb0ec9343..f928782b43 100644
--- a/engines/asylum/resources/worldstats.cpp
+++ b/engines/asylum/resources/worldstats.cpp
@@ -193,19 +193,19 @@ void WorldStats::load(Common::SeekableReadStream *stream) {
actionListIdx = stream->readSint32LE();
for (int32 gr = 0; gr < 100; gr++)
- grResId[gr] = stream->readSint32LE();
+ graphicResourceIds[gr] = stream->readSint32LE();
- sceneTitleGrResId = stream->readSint32LE();
- sceneTitlePalResId = stream->readSint32LE();
+ sceneTitleGraphicResourceId = stream->readSint32LE();
+ sceneTitlePaletteResourceId = stream->readSint32LE();
actorType = stream->readSint32LE();
for (int32 s = 0; s < 50; s++)
- soundResId[s] = stream->readSint32LE();
+ soundResourceIds[s] = stream->readSint32LE();
for (int32 s = 0; s < 15; s++) {
ambientSounds[s].field_0 = stream->readSint32LE();
ambientSounds[s].flags = stream->readSint32LE();
- ambientSounds[s].resId = stream->readSint32LE();
+ ambientSounds[s].resourceId = stream->readSint32LE();
ambientSounds[s].field_C = stream->readSint32LE();
ambientSounds[s].field_10 = stream->readSint32LE();
ambientSounds[s].field_14 = stream->readSint32LE();
@@ -219,9 +219,9 @@ void WorldStats::load(Common::SeekableReadStream *stream) {
numAmbientSound = stream->readSint32LE();
musicStatus = stream->readSint32LE();
- musicCurrentResId = stream->readSint32LE();
+ musicCurrentResourceId = stream->readSint32LE();
musicFlag = stream->readSint32LE();
- musicResId = stream->readSint32LE();
+ musicResourceId = stream->readSint32LE();
musicStatusExt = stream->readSint32LE();
for (int32 a = 0; a < numBarriers; a++) {
@@ -229,7 +229,7 @@ void WorldStats::load(Common::SeekableReadStream *stream) {
Barrier *barrier = new Barrier(_scene);
barrier->id = stream->readSint32LE();
- barrier->resId = stream->readSint32LE();
+ barrier->resourceId = stream->readSint32LE();
barrier->x = stream->readSint32LE();
barrier->y = stream->readSint32LE();
@@ -267,7 +267,7 @@ void WorldStats::load(Common::SeekableReadStream *stream) {
barrier->actionListIdx = stream->readSint32LE();
for (i = 0; i < 16; i++) {
- barrier->soundItems[i].resId = stream->readSint32LE();
+ barrier->soundItems[i].resourceId = stream->readSint32LE();
barrier->soundItems[i].field_4 = stream->readSint32LE();
barrier->soundItems[i].field_8 = stream->readSint32LE();
barrier->soundItems[i].field_C = stream->readSint32LE();
@@ -275,7 +275,7 @@ void WorldStats::load(Common::SeekableReadStream *stream) {
}
for (i = 0; i < 50; i++) {
- barrier->frameSoundItems[i].resId = stream->readSint32LE();
+ barrier->frameSoundItems[i].resourceId = stream->readSint32LE();
barrier->frameSoundItems[i].frameIdx = stream->readSint32LE();
barrier->frameSoundItems[i].index = stream->readSint32LE();
barrier->frameSoundItems[i].field_C = stream->readSint32LE();
@@ -291,7 +291,7 @@ void WorldStats::load(Common::SeekableReadStream *stream) {
for (i = 0; i < 5; i++)
barrier->field_68C[i] = stream->readSint32LE();
- barrier->soundResId = stream->readSint32LE();
+ barrier->soundResourceId = stream->readSint32LE();
barrier->field_6A4 = stream->readSint32LE();
barriers.push_back(barrier);
@@ -348,7 +348,7 @@ void WorldStats::load(Common::SeekableReadStream *stream) {
actor->field_650 = stream->readSint32LE();
for (i = 0; i < 55; i++)
- actor->grResTable[i] = stream->readSint32LE();
+ actor->graphicResourceIds[i] = stream->readSint32LE();
stream->read(actor->name, sizeof(actor->name));
@@ -368,7 +368,7 @@ void WorldStats::load(Common::SeekableReadStream *stream) {
actor->flags2 = stream->readSint32LE();
actor->field_934 = stream->readSint32LE();
actor->field_938 = stream->readSint32LE();
- actor->soundResId = stream->readSint32LE();
+ actor->soundResourceId = stream->readSint32LE();
actor->numberValue01 = stream->readSint32LE();
actor->field_944 = stream->readSint32LE();
actor->field_948 = stream->readSint32LE();
@@ -436,7 +436,7 @@ void WorldStats::load(Common::SeekableReadStream *stream) {
action->polyIdx = stream->readSint32LE();
action->field_84 = stream->readSint32LE();
action->field_88 = stream->readSint32LE();
- action->soundResId = stream->readSint32LE();
+ action->soundResourceId = stream->readSint32LE();
action->field_90 = stream->readSint32LE();
action->paletteValue = stream->readSint32LE();
diff --git a/engines/asylum/resources/worldstats.h b/engines/asylum/resources/worldstats.h
index d57dace8ff..4dcf191450 100644
--- a/engines/asylum/resources/worldstats.h
+++ b/engines/asylum/resources/worldstats.h
@@ -93,17 +93,17 @@ public:
uint8 field_11D[3];
int32 field_120;
int32 actionListIdx; // actionList start index
- int32 grResId[100];
- int32 sceneTitleGrResId;
- int32 sceneTitlePalResId;
+ ResourceId graphicResourceIds[100];
+ ResourceId sceneTitleGraphicResourceId;
+ ResourceId sceneTitlePaletteResourceId;
int32 actorType;
- ResourceId soundResId[50];
+ ResourceId soundResourceIds[50];
AmbientSoundItem ambientSounds[15];
int32 numAmbientSound;
int32 musicStatus;
- ResourceId musicCurrentResId;
+ ResourceId musicCurrentResourceId;
int32 musicFlag;
- ResourceId musicResId;
+ ResourceId musicResourceId;
int32 musicStatusExt;
// FIXME: Investigate if we need to actually reserve maxsize for this arrays.
diff --git a/engines/asylum/respack.cpp b/engines/asylum/respack.cpp
index 3766311f41..87e377128c 100644
--- a/engines/asylum/respack.cpp
+++ b/engines/asylum/respack.cpp
@@ -71,8 +71,8 @@ void ResourcePack::init(const char *resourceFile) {
}
}
-ResourceEntry *ResourcePack::getResource(uint32 resourceId) {
- uint16 index = RESIDX(resourceId);
+ResourceEntry *ResourcePack::getResource(ResourceId resourceId) {
+ uint16 index = resourceId & 0xFFFF;
if (!_resources[index].data) {
// Load the requested resource if it's not loaded already
_packFile.seek(_resources[index].offset, SEEK_SET);
diff --git a/engines/asylum/respack.h b/engines/asylum/respack.h
index 84eaab1451..285382f0e5 100644
--- a/engines/asylum/respack.h
+++ b/engines/asylum/respack.h
@@ -26,18 +26,17 @@
#ifndef ASYLUM_RESOURCEPACK_H
#define ASYLUM_RESOURCEPACK_H
+#include "asylum/shared.h"
+
#include "common/array.h"
#include "common/file.h"
namespace Asylum {
-#define RESID(id) ((id >> 16) & 0x7FFF)
-#define RESIDX(id) (id & 0xFFFF)
-
struct ResourceEntry {
byte *data;
- uint32 size;
- uint32 offset;
+ uint32 size;
+ uint32 offset;
};
class ResourcePack {
@@ -46,7 +45,7 @@ public:
ResourcePack(int32 resourceIndex);
~ResourcePack();
- ResourceEntry *getResource(uint32 resourceId);
+ ResourceEntry *getResource(ResourceId resourceId);
uint32 getResourceCount() {
return _resources.size();
}
diff --git a/engines/asylum/shared.h b/engines/asylum/shared.h
index 4362c8efcd..a7f48f570a 100644
--- a/engines/asylum/shared.h
+++ b/engines/asylum/shared.h
@@ -39,7 +39,7 @@ enum GameFlag {
kGameFlagFinishGame = 901
};
-typedef int32 ResourceId;
+typedef int ResourceId;
enum ResourceIdEnum {
kResourceSound_80120001 = 0x80120001,
diff --git a/engines/asylum/system/cursor.cpp b/engines/asylum/system/cursor.cpp
index 9873c57ce0..c289b58f92 100644
--- a/engines/asylum/system/cursor.cpp
+++ b/engines/asylum/system/cursor.cpp
@@ -61,7 +61,7 @@ void Cursor::load(int32 index) {
}
*/
-void Cursor::create(Cursor *&cursor, ResourcePack *pack, int32 id) {
+void Cursor::create(Cursor *&cursor, ResourcePack *pack, ResourceId id) {
// If the current cursor resource is already assigned
// to the id value we're sending, just return
// TODO this simplifies a lot of additional validation calls
@@ -69,7 +69,7 @@ void Cursor::create(Cursor *&cursor, ResourcePack *pack, int32 id) {
// where we WANT to reset the curor to the id supplied, even
// if it's the same as what's assigned ... investigate
if (cursor) {
- if (cursor->grResId != id)
+ if (cursor->graphicResourceId != id)
delete cursor;
else
return;
@@ -86,11 +86,11 @@ void Cursor::show() {
CursorMan.showMouse(true);
}
-void Cursor::set(uint32 resId, int32 cntr, int32 flgs, int32 frames) {
+void Cursor::set(ResourceId resourceId, int32 cntr, int32 flgs, int32 frames) {
if (_cursorRes)
delete _cursorRes;
- _cursorRes = new GraphicResource(_pack, resId);
+ _cursorRes = new GraphicResource(_pack, resourceId);
if (frames >= 0)
frameCount = frames;
diff --git a/engines/asylum/system/cursor.h b/engines/asylum/system/cursor.h
index 28f09f330d..7256adbf26 100644
--- a/engines/asylum/system/cursor.h
+++ b/engines/asylum/system/cursor.h
@@ -28,6 +28,8 @@
#include "asylum/system/graphics.h"
+#include "asylum/shared.h"
+
namespace Asylum {
/**
@@ -45,7 +47,7 @@ public:
* Generate a new cursor instance from the resource id
* within the resource pack provided.
*/
- static void create(Cursor *&cursor, ResourcePack *pack, int32 id);
+ static void create(Cursor *&cursor, ResourcePack *pack, ResourceId id);
/**
* Show the current cursor
@@ -63,7 +65,7 @@ public:
* frame count should be derived from the graphic resource as opposed to being
* explicitely set.
*/
- void set(uint32 resId, int32 cntr, int32 flgs, int32 frames = -1);
+ void set(ResourceId resourceId, int32 cntr, int32 flgs, int32 frames = -1);
/**
* Set the x/y coordinates of the cursor
*/
@@ -99,7 +101,7 @@ public:
// may as well be class members in order to simplify the logic a bit
// typedef struct CursorInfo {
- int32 grResId;
+ ResourceId graphicResourceId;
int32 currentFrame; // assuming field_4c is the current frame pointer
// since it's generally initialized to zero
int32 frameCount;
diff --git a/engines/asylum/system/graphics.cpp b/engines/asylum/system/graphics.cpp
index 347abf7eb5..11512b9c8e 100644
--- a/engines/asylum/system/graphics.cpp
+++ b/engines/asylum/system/graphics.cpp
@@ -29,16 +29,16 @@
namespace Asylum {
-GraphicResource::GraphicResource(ResourcePack *resPack, uint32 entry) {
- load(resPack, entry);
+GraphicResource::GraphicResource(ResourcePack *resPack, ResourceId id) {
+ load(resPack, id);
}
-void GraphicResource::load(ResourcePack *resPack, uint32 entry) {
+void GraphicResource::load(ResourcePack *resPack, ResourceId id) {
// Clear previously loaded data
clear();
- ResourceEntry *resEntry = resPack->getResource(entry);
- _entryNum = entry;
+ ResourceEntry *resEntry = resPack->getResource(id);
+ _resourceId = id;
init(resEntry->data, resEntry->size);
}
diff --git a/engines/asylum/system/graphics.h b/engines/asylum/system/graphics.h
index f7a848000d..530261aadf 100644
--- a/engines/asylum/system/graphics.h
+++ b/engines/asylum/system/graphics.h
@@ -26,9 +26,12 @@
#ifndef ASYLUM_GRAPHICS_H
#define ASYLUM_GRAPHICS_H
-#include "common/array.h"
-#include "graphics/surface.h"
#include "asylum/respack.h"
+#include "asylum/shared.h"
+
+#include "graphics/surface.h"
+
+#include "common/array.h"
namespace Asylum {
@@ -49,10 +52,10 @@ class GraphicResource {
public:
GraphicResource() {}
- GraphicResource(ResourcePack *resPack, uint32 entry);
+ GraphicResource(ResourcePack *resPack, ResourceId id);
~GraphicResource();
- void load(ResourcePack *resPack, uint32 entry);
+ void load(ResourcePack *resPack, ResourceId id);
/**
* Copies an animation frame to the target buffer
@@ -65,14 +68,14 @@ public:
void copySpriteToDest(byte *dest, uint32 frame);
GraphicFrame *getFrame(uint32 frame);
- uint32 getEntryNum() { return _entryNum; }
+ ResourceId getResourceId() { return _resourceId; }
int32 getFlags() { return _flags; }
uint32 getFrameCount() { return _frames.size(); }
private:
Common::Array <GraphicFrame> _frames;
int32 _flags;
- uint32 _entryNum;
+ ResourceId _resourceId;
void init(byte *data, int32 size);
void clear();
diff --git a/engines/asylum/system/screen.cpp b/engines/asylum/system/screen.cpp
index ba45a76730..68e4bc19f6 100644
--- a/engines/asylum/system/screen.cpp
+++ b/engines/asylum/system/screen.cpp
@@ -111,7 +111,7 @@ void Screen::setPalette(byte *rgbPalette) {
_vm->_system->setPalette(palette, 0, 256);
}
-void Screen::setGammaLevel(ResourcePack *resPack, int32 entry, int32 val) {
+void Screen::setGammaLevel(ResourcePack *resPack, ResourceId id, int32 val) {
error("[Screen::setGammaLevel] not implemented");
}
@@ -133,9 +133,9 @@ void Screen::palFade(uint32 red, int32 milliseconds, int32 param) {
error("[Screen::palFade] not implemented");
}
-void Screen::addGraphicToQueue(int32 resId, int32 frameIdx, int32 x, int32 y, int32 flags, int32 transTableNum, int32 priority) {
+void Screen::addGraphicToQueue(ResourceId resourceId, int32 frameIdx, int32 x, int32 y, int32 flags, int32 transTableNum, int32 priority) {
GraphicQueueItem item;
- item.resId = resId;
+ item.resourceId = resourceId;
item.x = x;
item.y = y;
item.frameIdx = frameIdx;
@@ -146,7 +146,7 @@ void Screen::addGraphicToQueue(int32 resId, int32 frameIdx, int32 x, int32 y, in
_queueItems.push_back(item);
}
-void Screen::addCrossFadeGraphicToQueue(int32 resId, int32 frameIdx, int32 x, int32 y, int32 redId2, int32 x2, int32 y2, int32 flags, int32 priority) {
+void Screen::addCrossFadeGraphicToQueue(ResourceId resourceId, int32 frameIdx, int32 x, int32 y, int32 redId2, int32 x2, int32 y2, int32 flags, int32 priority) {
error("[Screen::addCrossFadeGraphicToQueue] not implemented");
}
@@ -161,7 +161,7 @@ void Screen::drawGraphicsInQueue() {
graphicsSelectionSort();
for (uint32 i = 0; i < _queueItems.size(); i++) {
- GraphicResource *grRes = _vm->scene()->getGraphicResource(_queueItems[i].resId);
+ GraphicResource *grRes = _vm->scene()->getGraphicResource(_queueItems[i].resourceId);
GraphicFrame *fra = grRes->getFrame(_queueItems[i].frameIdx);
copyToBackBufferWithTransparency((byte *)fra->surface.pixels,
@@ -200,9 +200,9 @@ void Screen::swapGraphicItem(int32 item1, int32 item2) {
_queueItems[item2] = temp;
}
-void Screen::deleteGraphicFromQueue(int32 resId) {
+void Screen::deleteGraphicFromQueue(ResourceId resourceId) {
for (uint32 i = 0; i < _queueItems.size(); i++) {
- if (_queueItems[i].resId == resId) {
+ if (_queueItems[i].resourceId == resourceId) {
_queueItems.remove_at(i);
break;
}
diff --git a/engines/asylum/system/screen.h b/engines/asylum/system/screen.h
index 18bd930242..f1790e94b2 100644
--- a/engines/asylum/system/screen.h
+++ b/engines/asylum/system/screen.h
@@ -36,7 +36,7 @@
namespace Asylum {
typedef struct GraphicQueueItem {
- int32 resId;
+ ResourceId resourceId;
int32 frameIdx;
int32 x;
int32 y;
@@ -57,25 +57,25 @@ public:
void copyRectToScreen(byte *buffer, int32 pitch, int32 x, int32 y, int32 width, int32 height);
void copyRectToScreenWithTransparency(byte *buffer, int32 pitch, int32 x, int32 y, int32 width, int32 height);
void setPalette(byte *rgbPalette);
- void setPalette(ResourcePack *resPack, int32 entry) {
- setPalette(resPack->getResource(entry)->data + 32);
+ void setPalette(ResourcePack *resPack, ResourceId id) {
+ setPalette(resPack->getResource(id)->data + 32);
}
- void setGammaLevel(ResourcePack *resPack, int32 entry, int32 val);
+ void setGammaLevel(ResourcePack *resPack, ResourceId id, int32 val);
void drawWideScreen(int16 barSize);
void clearScreen();
void palFade(uint32 red, int32 milliseconds, int32 param);
- void addGraphicToQueue(int32 resId, int32 frameIdx, int32 x, int32 y, int32 flags, int32 transTableNum, int32 priority);
- void addCrossFadeGraphicToQueue(int32 resId, int32 frameIdx, int32 x, int32 y, int32 redId2, int32 x2, int32 y2, int32 flags, int32 priority);
+ void addGraphicToQueue(ResourceId resourceId, int32 frameIdx, int32 x, int32 y, int32 flags, int32 transTableNum, int32 priority);
+ void addCrossFadeGraphicToQueue(ResourceId resourceId, int32 frameIdx, int32 x, int32 y, int32 redId2, int32 x2, int32 y2, int32 flags, int32 priority);
void addGraphicToQueue(GraphicQueueItem item);
void drawGraphicsInQueue();
void clearGraphicsInQueue();
void graphicsSelectionSort();
void swapGraphicItem(int32 item1, int32 item2);
- void deleteGraphicFromQueue(int32 resId);
+ void deleteGraphicFromQueue(ResourceId resourceId);
private:
Graphics::Surface _backBuffer;
diff --git a/engines/asylum/system/sound.cpp b/engines/asylum/system/sound.cpp
index ea514d1288..f2a6676591 100644
--- a/engines/asylum/system/sound.cpp
+++ b/engines/asylum/system/sound.cpp
@@ -94,15 +94,15 @@ void convertPan(int32 &pan) {
}
}
-void Sound::setVolume(int32 resId, double volume) {
+void Sound::setVolume(ResourceId resourceId, double volume) {
error("[Sound::setVolume] not implemented");
}
-int32 Sound::getBufferPosition(int32 resId) {
+int32 Sound::getBufferPosition(ResourceId resourceId) {
int32 pos = -1;
for (uint32 i = 0; i < _soundBuffer.size(); i++) {
- if (resId == _soundBuffer[i].resId) {
+ if (resourceId == _soundBuffer[i].resourceId) {
pos = i;
break;
}
@@ -111,12 +111,12 @@ int32 Sound::getBufferPosition(int32 resId) {
return pos;
}
-bool Sound::addToSoundBuffer(int32 resId) {
- int32 exists = getBufferPosition(resId);
+bool Sound::addToSoundBuffer(ResourceId resourceId) {
+ int32 exists = getBufferPosition(resourceId);
if (exists < 0) {
SoundBufferItem sound;
- sound.resId = resId;
+ sound.resourceId = resourceId;
sound.handle = _soundHandle;
_soundBuffer.push_back(sound);
}
@@ -124,8 +124,8 @@ bool Sound::addToSoundBuffer(int32 resId) {
return (exists < 0) ? true : false;
}
-void Sound::removeFromSoundBuffer(int32 resId) {
- int32 pos = getBufferPosition(resId);
+void Sound::removeFromSoundBuffer(ResourceId resourceId) {
+ int32 pos = getBufferPosition(resourceId);
if (pos >= 0) {
_soundBuffer.remove_at(pos);
@@ -136,25 +136,25 @@ void Sound::clearSoundBuffer() {
_soundBuffer.clear();
}
-bool Sound::isPlaying(int32 resId) {
- int32 pos = getBufferPosition(resId);
+bool Sound::isPlaying(ResourceId resourceId) {
+ int32 pos = getBufferPosition(resourceId);
if (pos < 0) {
- //warning("isPlaying: resId %d not currently bufferred", resId);
+ //warning("isPlaying: resource %d not currently buffered", resourceId);
} else {
SoundBufferItem snd = _soundBuffer[pos];
if (_mixer->isSoundHandleActive(snd.handle)) {
return true;
} else {
- removeFromSoundBuffer(resId);
+ removeFromSoundBuffer(resourceId);
}
}
return false;
}
-void Sound::playSound(ResourcePack *pack, ResourceId resId, int32 volume, bool looping, int32 panning, bool overwrite) {
- ResourceEntry *resource = pack->getResource(resId);
+void Sound::playSound(ResourcePack *pack, ResourceId resourceId, int32 volume, bool looping, int32 panning, bool overwrite) {
+ ResourceEntry *resource = pack->getResource(resourceId);
if (_mixer->isSoundHandleActive(_soundHandle)) {
if (overwrite) {
_mixer->stopHandle(_soundHandle);
@@ -170,34 +170,34 @@ void Sound::playSound(ResourceEntry *resource, bool looping, int32 volume, int32
playSoundData(Audio::Mixer::kSFXSoundType, &_soundHandle, resource->data, resource->size, looping, volume, panning);
}
-void Sound::playSound(ResourcePack *pack, int32 resId, bool looping, int32 volume, int32 panning) {
- int32 pos = getBufferPosition(resId);
+void Sound::playSound(ResourcePack *pack, ResourceId resourceId, bool looping, int32 volume, int32 panning) {
+ int32 pos = getBufferPosition(resourceId);
if (pos < 0) {
- warning("playSound: resId %d not currently bufferred", resId);
+ warning("playSound: resource %d not currently bufferred", resourceId);
} else {
SoundBufferItem snd = _soundBuffer[pos];
if (_mixer->isSoundHandleActive(snd.handle)) {
- debugC(kDebugLevelSound, "playSound: handle for resId %d already active", resId);
+ debugC(kDebugLevelSound, "playSound: handle for resource %d already active", resourceId);
} else {
- ResourceEntry *ent = _soundPack->getResource(resId);
+ ResourceEntry *ent = _soundPack->getResource(resourceId);
playSoundData(Audio::Mixer::kSFXSoundType, &snd.handle, ent->data, ent->size, looping, volume, panning);
- addToSoundBuffer(resId);
+ addToSoundBuffer(resourceId);
}
}
}
-void Sound::playSound(ResourceId resId, bool looping, int32 volume, int32 panning, bool fromBuffer) {
+void Sound::playSound(ResourceId resourceId, bool looping, int32 volume, int32 panning, bool fromBuffer) {
if (fromBuffer) {
- playSound(_soundPack, resId, looping, volume, panning);
+ playSound(_soundPack, resourceId, looping, volume, panning);
} else {
if (_mixer->isSoundHandleActive(_soundHandle)) {
debugC(kDebugLevelSound, "playSound: temporary sound handle is active");
} else {
- ResourceEntry *ent = _soundPack->getResource(resId);
+ ResourceEntry *ent = _soundPack->getResource(resourceId);
playSound(ent, looping, volume, panning);
- addToSoundBuffer(resId);
+ addToSoundBuffer(resourceId);
}
}
}
@@ -207,11 +207,11 @@ void Sound::stopSound() {
_mixer->stopHandle(_soundHandle);
}
-void Sound::stopSound(int32 resId) {
- int32 pos = getBufferPosition(resId);
+void Sound::stopSound(ResourceId resourceId) {
+ int32 pos = getBufferPosition(resourceId);
if (pos < 0) {
- warning("stopSound: resId %d not currently bufferred", resId);
+ warning("stopSound: resource %d not currently bufferred", resourceId);
} else {
_mixer->stopHandle(_soundBuffer[pos].handle);
}
@@ -229,24 +229,24 @@ void Sound::stopAllSounds(bool stopSpeechAndMusic) {
_mixer->stopHandle(_soundBuffer[i].handle);
}
-void Sound::playSpeech(int32 resId) {
- ResourceEntry *ent = _speechPack->getResource(resId);
+void Sound::playSpeech(ResourceId resourceId) {
+ ResourceEntry *ent = _speechPack->getResource(resourceId);
_mixer->stopHandle(_speechHandle);
playSoundData(Audio::Mixer::kSpeechSoundType, &_speechHandle, ent->data, ent->size, false, 0, 0);
}
-void Sound::playMusic(int32 resId) {
+void Sound::playMusic(ResourceId resourceId) {
stopMusic();
// TODO Play music :P
error("[Sound::playMusic] not implemented");
}
-void Sound::playMusic(ResourcePack *pack, int32 resId) {
+void Sound::playMusic(ResourcePack *pack, ResourceId resourceId) {
stopMusic();
- ResourceEntry *resource = pack->getResource(resId);
+ ResourceEntry *resource = pack->getResource(resourceId);
playSoundData(Audio::Mixer::kMusicSoundType, &_musicHandle, resource->data, resource->size, true, Config.musicVolume, 0);
}
diff --git a/engines/asylum/system/sound.h b/engines/asylum/system/sound.h
index 7b9cf08b90..5933a99e59 100644
--- a/engines/asylum/system/sound.h
+++ b/engines/asylum/system/sound.h
@@ -34,7 +34,7 @@
namespace Asylum {
typedef struct SoundItem {
- ResourceId resId;
+ ResourceId resourceId;
int32 field_4;
int32 field_8;
int32 field_C;
@@ -42,7 +42,7 @@ typedef struct SoundItem {
} SoundItem;
typedef struct FrameSoundItem {
- ResourceId resId;
+ ResourceId resourceId;
int32 frameIdx;
int32 index;
int32 field_C;
@@ -54,7 +54,7 @@ typedef struct FrameSoundItem {
typedef struct AmbientSoundItem {
int32 field_0;
int32 flags;
- ResourceId resId;
+ ResourceId resourceId;
int32 field_C;
int32 field_10;
int32 field_14;
@@ -65,7 +65,7 @@ typedef struct AmbientSoundItem {
} AmbientSoundItem;
typedef struct SoundBufferItem {
- ResourceId resId;
+ ResourceId resourceId;
Audio::SoundHandle handle;
int32 unknown;
} SoundBufferItem;
@@ -75,8 +75,8 @@ public:
Sound(Audio::Mixer *mixer);
~Sound();
- bool addToSoundBuffer(ResourceId resId);
- void removeFromSoundBuffer(ResourceId resId);
+ bool addToSoundBuffer(ResourceId resourceId);
+ void removeFromSoundBuffer(ResourceId resourceId);
void clearSoundBuffer();
/**
@@ -84,21 +84,21 @@ public:
*
* @param overwrite determine if _soundHandle should be overwritten if still active
*/
- void playSound(ResourcePack *pack, ResourceId resId, int32 volume, bool looping = false, int32 panning = 0, bool overwrite = false);
- void playSound(ResourcePack *pack, ResourceId resId, bool looping, int32 volume, int32 panning);
+ void playSound(ResourcePack *pack, ResourceId resourceId, int32 volume, bool looping = false, int32 panning = 0, bool overwrite = false);
+ void playSound(ResourcePack *pack, ResourceId resourceId, bool looping, int32 volume, int32 panning);
void playSound(ResourceEntry *resource, bool looping, int32 volume, int32 panning);
- void playSound(ResourceId resId, bool looping, int32 volume, int32 panning, bool fromBuffer = false);
- void stopSound(ResourceId resId);
+ void playSound(ResourceId resourceId, bool looping, int32 volume, int32 panning, bool fromBuffer = false);
+ void stopSound(ResourceId resourceId);
void stopSound();
void stopAllSounds(bool stopSpeechAndMusic = false);
- void playSpeech(ResourceId resId);
+ void playSpeech(ResourceId resourceId);
- void playMusic(ResourcePack *pack, ResourceId resId);
- void playMusic(ResourceId resId);
+ void playMusic(ResourcePack *pack, ResourceId resourceId);
+ void playMusic(ResourceId resourceId);
void stopMusic();
- void setVolume(ResourceId resId, double volume);
+ void setVolume(ResourceId resourceId, double volume);
/**
* Check if the buffered sound sample that matches the provided id currently
@@ -108,7 +108,7 @@ public:
* music or speech, as those resources aren't managed beyond simple
* start/stop requests.
*/
- bool isPlaying(ResourceId resId);
+ bool isPlaying(ResourceId resourceId);
/**
* Check if the unmanaged sound handle is in use
@@ -116,7 +116,7 @@ public:
* This is useful for checking the active state of a sound
* in a blowuppuzzle
*/
- bool isPlaying() { return _mixer->isSoundHandleActive(_soundHandle); }
+ bool isPlaying() { return _mixer->isSoundHandleActive(_soundHandle); }
private:
Audio::Mixer *_mixer;
@@ -142,7 +142,7 @@ private:
* Find the index within the _soundBuffer array of the
* sound sample with provided id.
*/
- int32 getBufferPosition(int32 resId);
+ int32 getBufferPosition(ResourceId resourceId);
void playSoundData(Audio::Mixer::SoundType type, Audio::SoundHandle *handle, byte *soundData, int32 soundDataLength, bool loop = false, int32 vol = 0, int32 pan = 0);
};
diff --git a/engines/asylum/system/speech.cpp b/engines/asylum/system/speech.cpp
index f5072ec935..cd0c77df57 100644
--- a/engines/asylum/system/speech.cpp
+++ b/engines/asylum/system/speech.cpp
@@ -32,65 +32,65 @@ namespace Asylum {
Speech::Speech(Scene *scene): _scene(scene) {
_tick = _scene->vm()->getTick();
- _soundResIdx = 0;
- _textResIdx = 0;
+ _soundResourceId = 0;
+ _textResourceId = 0;
}
Speech::~Speech() {
// TODO Auto-generated destructor stub
}
-int32 Speech::play(int32 speechIdx) {
- int32 soundResIdx = 0;
+int32 Speech::play(ResourceId speechResourceId) {
+ int32 soundResourceId = 0;
switch (_scene->worldstats()->actorType) {
case kMax: {
- int32 soundResIdx2 = speechIdx;
- int32 textResIdx = speechIdx;
+ int32 soundResourceId2 = speechResourceId;
+ int32 textResourceId = speechResourceId;
- if (speechIdx >= 259) {
- soundResIdx2 -= 9;
- textResIdx -= 9;
+ if (speechResourceId >= 259) {
+ soundResourceId2 -= 9;
+ textResourceId -= 9;
}
- soundResIdx = soundResIdx2 - 0x7FFD0000;
+ soundResourceId = soundResourceId2 - 0x7FFD0000;
// setup the right index for sound and text
- setPlayerSpeech(soundResIdx, textResIdx - 0x7FFFFFAD);
+ setPlayerSpeech(soundResourceId, textResourceId - 0x7FFFFFAD);
}
break;
// TODO: check if actor type is right for the following cases
case kSarah: {
- soundResIdx = speechIdx - 0x7FFBF879;
- setPlayerSpeech(soundResIdx, speechIdx - 0x7FFFFDB6);
+ soundResourceId = speechResourceId - 0x7FFBF879;
+ setPlayerSpeech(soundResourceId, speechResourceId - 0x7FFFFDB6);
}
break;
case kCyclops: {
- soundResIdx = speechIdx - 0x7FFBF7DC;
- setPlayerSpeech(soundResIdx, speechIdx - 0x7FFFFD19);
+ soundResourceId = speechResourceId - 0x7FFBF7DC;
+ setPlayerSpeech(soundResourceId, speechResourceId - 0x7FFFFD19);
}
break;
case kAztec: {
- soundResIdx = speechIdx - 0x7FFBF746;
- setPlayerSpeech(soundResIdx, speechIdx - 0x7FFFFC83);
+ soundResourceId = speechResourceId - 0x7FFBF746;
+ setPlayerSpeech(soundResourceId, speechResourceId - 0x7FFFFC83);
}
break;
default:
- soundResIdx = 0;
+ soundResourceId = 0;
break;
}
- return soundResIdx;
+ return soundResourceId;
}
-void Speech::setPlayerSpeech(int32 soundResIdx, int32 textResIdx) {
- if (soundResIdx) {
- if (_scene->vm()->sound()->isPlaying(soundResIdx)) {
- _scene->vm()->sound()->stopSound(soundResIdx);
+void Speech::setPlayerSpeech(ResourceId soundResourceId, ResourceId textResourceId) {
+ if (soundResourceId) {
+ if (_scene->vm()->sound()->isPlaying(soundResourceId)) {
+ _scene->vm()->sound()->stopSound(soundResourceId);
}
}
- _soundResIdx = soundResIdx;
- _textResIdx = textResIdx;
+ _soundResourceId = soundResourceId;
+ _textResourceId = textResourceId;
prepareSpeech();
}
@@ -98,8 +98,8 @@ void Speech::setPlayerSpeech(int32 soundResIdx, int32 textResIdx) {
void Speech::prepareSpeech() {
//int32 startTick = _scene->vm()->getTick();
- if (_soundResIdx) {
- if (!_scene->vm()->sound()->isPlaying(_soundResIdx)/* || _tick && startTick >= _tick*/) {
+ if (_soundResourceId) {
+ if (!_scene->vm()->sound()->isPlaying(_soundResourceId)/* || _tick && startTick >= _tick*/) {
processSpeech();
}
@@ -126,10 +126,10 @@ void Speech::processSpeech() {
_tick = 0;
- txt = _scene->vm()->text()->getResText(_textResIdx);
+ txt = _scene->vm()->text()->getResText(_textResourceId);
if (*(txt + strlen((const char *)txt) - 2) == 1) {
- _textResIdx = 0;
+ _textResourceId = 0;
_textData = 0;
_textDataPos = 0;
} else {
@@ -138,7 +138,7 @@ void Speech::processSpeech() {
_textDataPos = 0;
_scene->vm()->text()->loadFont(_scene->getResourcePack(), _scene->worldstats()->font1);
- _scene->vm()->sound()->playSpeech(_soundResIdx);
+ _scene->vm()->sound()->playSpeech(_soundResourceId);
} else {
_textData = 0;
_textDataPos = txt;
@@ -148,7 +148,7 @@ void Speech::processSpeech() {
}
_scene->vm()->text()->loadFont(_scene->getResourcePack(), _scene->worldstats()->font3);
- _scene->vm()->sound()->playSpeech(_soundResIdx);
+ _scene->vm()->sound()->playSpeech(_soundResourceId);
}
}
}
diff --git a/engines/asylum/system/speech.h b/engines/asylum/system/speech.h
index f80711a74b..b2651c7407 100644
--- a/engines/asylum/system/speech.h
+++ b/engines/asylum/system/speech.h
@@ -36,21 +36,21 @@ public:
Speech(Scene *scene);
virtual ~Speech();
- int32 _soundResIdx;
- int32 _textResIdx;
+ ResourceId _soundResourceId;
+ ResourceId _textResourceId;
/** .text:00414810
* Play player speech
* @param speechIdx speech index (used for sound and text resources)
* @return correct resourceId
*/
- int32 play(int32 speechIdx);
+ int32 play(ResourceId speechResourceId);
/** .text:004146D0
* Set speech for different player type
- * @param soundResIdx sound resource id
- * @param textResIdx text resource id
+ * @param soundResourceId sound resource id
+ * @param textResourceId text resource id
*/
- void setPlayerSpeech(int32 soundResIdx, int32 textResIdx);
+ void setPlayerSpeech(ResourceId soundResourceId, ResourceId textResourceId);
/** .text:004144C0
* Prepare speech to play
* - Process sound speech and draws dialogue in screen
@@ -60,9 +60,9 @@ public:
private:
Scene *_scene;
- int32 _tick;
- char * _textData;
- char * _textDataPos;
+ int32 _tick;
+ char *_textData;
+ char *_textDataPos;
/** .text:00414580
* TODO add description
@@ -70,7 +70,7 @@ private:
void processSpeech();
// This function was cutoff since it doesn't make any sense using it. Its here for address information only
- /** .text:00414630 void playSpeech(int32 textResIdx, int32 fontResIdx); */
+ /** .text:00414630 void playSpeech(ResourceId textResourceId, ResourceId fontResourceId); */
}; // end of class Speech
diff --git a/engines/asylum/system/text.cpp b/engines/asylum/system/text.cpp
index 01807cc9c2..affff0a446 100644
--- a/engines/asylum/system/text.cpp
+++ b/engines/asylum/system/text.cpp
@@ -44,15 +44,15 @@ Text::~Text() {
}
// loadFont at address 00435640
-void Text::loadFont(ResourcePack *resPack, uint32 resId) {
- if (_fontResource && resId == _fontResource->getEntryNum())
+void Text::loadFont(ResourcePack *resPack, ResourceId resourceId) {
+ if (_fontResource && resourceId == _fontResource->getResourceId())
return;
delete _fontResource;
- _fontResource = new GraphicResource(resPack, resId);
+ _fontResource = new GraphicResource(resPack, resourceId);
- if (resId > 0) {
+ if (resourceId > 0) {
// load font flag data
_curFontFlags = (_fontResource->getFlags() >> 4) & 0x0F;
}
@@ -79,13 +79,13 @@ int32 Text::getTextWidth(const char *text) {
return width;
}
-int32 Text::getResTextWidth(uint32 resId) {
- ResourceEntry *textRes = _textPack->getResource(resId);
+int32 Text::getResTextWidth(ResourceId resourceId) {
+ ResourceEntry *textRes = _textPack->getResource(resourceId);
return getTextWidth((char*)textRes->data);
}
-char* Text::getResText(uint32 resId) {
- ResourceEntry *textRes = _textPack->getResource(resId);
+char* Text::getResText(ResourceId resourceId) {
+ ResourceEntry *textRes = _textPack->getResource(resourceId);
return (char*)textRes->data;
}
@@ -104,8 +104,8 @@ void Text::drawText(const char *text) {
}
}
-void Text::drawResText(uint32 resId) {
- ResourceEntry *textRes = _textPack->getResource(resId);
+void Text::drawResText(ResourceId resourceId) {
+ ResourceEntry *textRes = _textPack->getResource(resourceId);
drawText((char*)textRes->data);
}
@@ -115,16 +115,16 @@ void Text::drawTextCentered(int32 x, int32 y, int32 width, const char *text) {
drawText(text);
}
-void Text::drawResTextWithValueCentered(int32 x, int32 y, int32 width, uint32 resId, int32 value) {
- ResourceEntry *textRes = _textPack->getResource(resId);
+void Text::drawResTextWithValueCentered(int32 x, int32 y, int32 width, ResourceId resourceId, int32 value) {
+ ResourceEntry *textRes = _textPack->getResource(resourceId);
char *text = (char *)textRes->data;
char txt[100];
sprintf(txt, text, value);
drawTextCentered(x, y, width, txt);
}
-void Text::drawResTextCentered(int32 x, int32 y, int32 width, uint32 resId) {
- ResourceEntry *textRes = _textPack->getResource(resId);
+void Text::drawResTextCentered(int32 x, int32 y, int32 width, ResourceId resourceId) {
+ ResourceEntry *textRes = _textPack->getResource(resourceId);
drawTextCentered(x, y, width, (char *)textRes->data);
}
@@ -136,8 +136,8 @@ void Text::drawText(int32 x, int32 y, const char *text) {
}
}
-void Text::drawResText(int32 x, int32 y, uint32 resId) {
- ResourceEntry *textRes = _textPack->getResource(resId);
+void Text::drawResText(int32 x, int32 y, ResourceId resourceId) {
+ ResourceEntry *textRes = _textPack->getResource(resourceId);
drawText(x, y, (char *)textRes->data);
}
@@ -147,8 +147,8 @@ void Text::drawTextAlignRight(int32 x, int32 y, const char *text) {
drawText(text);
}
-void Text::drawResTextAlignRight(int32 x, int32 y, uint32 resId) {
- ResourceEntry *textRes = _textPack->getResource(resId);
+void Text::drawResTextAlignRight(int32 x, int32 y, ResourceId resourceId) {
+ ResourceEntry *textRes = _textPack->getResource(resourceId);
drawTextAlignRight(x, y, (char *)textRes->data);
}
diff --git a/engines/asylum/system/text.h b/engines/asylum/system/text.h
index 2d458e3520..5cab9307b7 100644
--- a/engines/asylum/system/text.h
+++ b/engines/asylum/system/text.h
@@ -38,25 +38,25 @@ public:
Text(Screen *screen);
~Text();
- void loadFont(ResourcePack *resPack, uint32 resId);
+ void loadFont(ResourcePack *resPack, ResourceId resourceId);
void setTextPos(int32 x, int32 y);
int32 getTextWidth(const char *text);
- int32 getResTextWidth(uint32 resId);
- char * getResText(uint32 resId);
+ int32 getResTextWidth(ResourceId resourceId);
+ char * getResText(ResourceId resourceId);
void drawChar(unsigned char character);
void drawText(const char *text);
void drawText(int32 x, int32 y, const char *text);
- void drawResText(uint32 resId);
- void drawResText(int32 x, int32 y, uint32 resId);
+ void drawResText(ResourceId resourceId);
+ void drawResText(int32 x, int32 y, ResourceId resourceId);
void drawTextCentered(int32 x, int32 y, int32 width, const char *text);
- void drawResTextCentered(int32 x, int32 y, int32 width, uint32 resId);
- void drawResTextWithValueCentered(int32 x, int32 y, int32 width, uint32 resId, int32 value);
+ void drawResTextCentered(int32 x, int32 y, int32 width, ResourceId resourceId);
+ void drawResTextWithValueCentered(int32 x, int32 y, int32 width, ResourceId resourceId, int32 value);
void drawTextAlignRight(int32 x, int32 y, const char *text);
- void drawResTextAlignRight(int32 x, int32 y, uint32 resId);
+ void drawResTextAlignRight(int32 x, int32 y, ResourceId resourceId);
private:
Screen *_screen;
diff --git a/engines/asylum/system/video.cpp b/engines/asylum/system/video.cpp
index b05b59bbf2..be2b2b35bb 100644
--- a/engines/asylum/system/video.cpp
+++ b/engines/asylum/system/video.cpp
@@ -196,22 +196,22 @@ VideoText::~VideoText() {
delete _fontResource;
}
-void VideoText::loadFont(ResourcePack *resPack, int32 resId) {
+void VideoText::loadFont(ResourcePack *resPack, ResourceId resourceId) {
delete _fontResource;
- _fontResource = new GraphicResource(resPack, resId);
+ _fontResource = new GraphicResource(resPack, resourceId);
- if (resId > 0) {
+ if (resourceId > 0) {
// load font flag data
_curFontFlags = (_fontResource->getFlags() >> 4) & 0x0F;
}
}
-void VideoText::drawMovieSubtitle(byte *screenBuffer, int32 resId) {
+void VideoText::drawMovieSubtitle(byte *screenBuffer, ResourceId resourceId) {
Common::String textLine[4];
Common::String tmpLine;
int32 curLine = 0;
- ResourceEntry *textRes = _textPack->getResource(resId);
+ ResourceEntry *textRes = _textPack->getResource(resourceId);
char *text = strdup((const char *)textRes->data); // for strtok
char *tok = strtok(text, " ");
int32 startY = 420; // starting y for up to 2 subtitles
diff --git a/engines/asylum/system/video.h b/engines/asylum/system/video.h
index c13333a06f..9eece2cc8b 100644
--- a/engines/asylum/system/video.h
+++ b/engines/asylum/system/video.h
@@ -84,8 +84,8 @@ public:
VideoText();
~VideoText();
- void loadFont(ResourcePack *resPack, int32 resId);
- void drawMovieSubtitle(byte *screenBuffer, int32 resId);
+ void loadFont(ResourcePack *resPack, ResourceId resourceId);
+ void drawMovieSubtitle(byte *screenBuffer, ResourceId resourceId);
private:
int32 getTextWidth(const char *text);
diff --git a/engines/asylum/views/blowuppuzzle.cpp b/engines/asylum/views/blowuppuzzle.cpp
index ab1b5de9a9..a38330e3c3 100644
--- a/engines/asylum/views/blowuppuzzle.cpp
+++ b/engines/asylum/views/blowuppuzzle.cpp
@@ -23,10 +23,15 @@
*
*/
-#include "asylum/blowuppuzzle.h"
+#include "asylum/views/blowuppuzzle.h"
+
+#include "asylum/views/scene.h"
+
+#include "asylum/system/config.h"
+#include "asylum/system/graphics.h"
+
#include "asylum/respack.h"
-#include "asylum/graphics.h"
-#include "asylum/config.h"
+#include "asylum/shared.h"
namespace Asylum {
@@ -43,7 +48,7 @@ BlowUpPuzzleVCR::BlowUpPuzzleVCR(Scene *scene): BlowUpPuzzle(scene) {
_leftClickDown = false;
_rightClickDown = false;
_active = false;
- _bgResource = _scene->getGraphicResource(_scene->worldstats()->grResId[0]);
+ _bgResource = _scene->getGraphicResource(_scene->worldstats()->graphicResourceIds[0]);
_tvScreenAnimIdx = 0;
_isAccomplished = false;
@@ -68,14 +73,14 @@ void BlowUpPuzzleVCR::openBlowUp() {
_scene->vm()->sound()->stopAllSounds(true);
// Load the graphics palette
- _scene->vm()->screen()->setPalette(_scene->getResourcePack(), _scene->worldstats()->grResId[29]);
+ _scene->vm()->screen()->setPalette(_scene->getResourcePack(), _scene->worldstats()->graphicResourceIds[29]);
// show blow up puzzle BG
GraphicFrame *bg = _bgResource->getFrame(0);
_scene->vm()->screen()->copyToBackBuffer((byte *)bg->surface.pixels, bg->surface.w, 0, 0, bg->surface.w, bg->surface.h);
// Set mouse cursor
- _cursor->load(_scene->worldstats()->grResId[28]);
+ _cursor->set(_scene->worldstats()->graphicResourceIds[28], 0, 2);
_cursor->show();
_leftClickUp = false;
@@ -93,7 +98,7 @@ void BlowUpPuzzleVCR::handleEvent(Common::Event *event, bool doUpdate) {
switch (_ev->type) {
case Common::EVENT_MOUSEMOVE:
- _cursor->setCoords(_ev->mouse.x, _ev->mouse.y);
+ _cursor->move(_ev->mouse.x, _ev->mouse.y);
break;
case Common::EVENT_LBUTTONUP:
_leftClickUp = true;
@@ -112,7 +117,7 @@ void BlowUpPuzzleVCR::handleEvent(Common::Event *event, bool doUpdate) {
update();
}
-void BlowUpPuzzle::playSound(int32 resourceId, bool loop) {
+void BlowUpPuzzle::playSound(ResourceId resourceId, bool loop) {
_scene->vm()->sound()->playSound(_scene->getResourcePack(), resourceId, Config.sfxVolume, loop, 0, true);
}
@@ -153,8 +158,8 @@ void BlowUpPuzzleVCR::update() {
updateStopButton();
if (_buttonsState[kPower] == kON) {
- _scene->vm()->screen()->addGraphicToQueue(_scene->worldstats()->grResId[22], _tvScreenAnimIdx, 0, 37, 0, 0, 1);
- _scene->vm()->screen()->addGraphicToQueue(_scene->worldstats()->grResId[23], _tvScreenAnimIdx++, 238, 22, 0, 0, 1);
+ _scene->vm()->screen()->addGraphicToQueue(_scene->worldstats()->graphicResourceIds[22], _tvScreenAnimIdx, 0, 37, 0, 0, 1);
+ _scene->vm()->screen()->addGraphicToQueue(_scene->worldstats()->graphicResourceIds[23], _tvScreenAnimIdx++, 238, 22, 0, 0, 1);
_tvScreenAnimIdx %= 6;
}
@@ -179,17 +184,17 @@ void BlowUpPuzzleVCR::update() {
}
}
-GraphicQueueItem BlowUpPuzzleVCR::getGraphicJackItem(int resId) {
+GraphicQueueItem BlowUpPuzzleVCR::getGraphicJackItem(ResourceId resourceId) {
GraphicQueueItem jackItemOnHand;
- int jackY = _cursor->y();
- if (_cursor->y() < 356) {
+ int jackY = _cursor->position().y;
+ if (_cursor->position().y < 356) {
jackY = 356;
}
- jackItemOnHand.resId = _scene->worldstats()->grResId[resId];
+ jackItemOnHand.resourceId = _scene->worldstats()->graphicResourceIds[resourceId];
jackItemOnHand.frameIdx = 0;
- jackItemOnHand.x = _cursor->x() - 114;
+ jackItemOnHand.x = _cursor->position().x - 114;
jackItemOnHand.y = jackY - 14;
jackItemOnHand.priority = 1;
@@ -199,117 +204,117 @@ GraphicQueueItem BlowUpPuzzleVCR::getGraphicJackItem(int resId) {
GraphicQueueItem BlowUpPuzzleVCR::getGraphicShadowItem() {
GraphicQueueItem shadowItem;
- int shadowY = (_cursor->y() - 356) / 4;
- if (_cursor->y() < 356) {
+ int shadowY = (_cursor->position().y - 356) / 4;
+ if (_cursor->position().y < 356) {
shadowY = 0;
}
- shadowItem.resId = _scene->worldstats()->grResId[30];
+ shadowItem.resourceId = _scene->worldstats()->graphicResourceIds[30];
shadowItem.frameIdx = 0;
- shadowItem.x = _cursor->x() - shadowY;
+ shadowItem.x = _cursor->position().x - shadowY;
shadowItem.y = 450;
shadowItem.priority = 2;
return shadowItem;
}
-void BlowUpPuzzleVCR::updateJack(Jack jack, VCRDrawInfo onTable, VCRDrawInfo pluggedOnRed, VCRDrawInfo pluggedOnYellow, VCRDrawInfo pluggedOnBlack, int resIdOnHand) {
+void BlowUpPuzzleVCR::updateJack(Jack jack, VCRDrawInfo onTable, VCRDrawInfo pluggedOnRed, VCRDrawInfo pluggedOnYellow, VCRDrawInfo pluggedOnBlack, ResourceId resourceIdOnHand) {
GraphicQueueItem item;
switch (_jacksState[jack]) {
case kOnTable:
- item.resId = _scene->worldstats()->grResId[onTable.resId];
+ item.resourceId = _scene->worldstats()->graphicResourceIds[onTable.resourceId];
item.frameIdx = 0;
item.x = onTable.x;
item.y = onTable.y;
item.priority = 3;
break;
case kPluggedOnRed:
- item.resId = _scene->worldstats()->grResId[pluggedOnRed.resId];
+ item.resourceId = _scene->worldstats()->graphicResourceIds[pluggedOnRed.resourceId];
item.frameIdx = 0;
item.x = 329;
item.y = 407;
item.priority = 3;
break;
case kPluggedOnYellow:
- item.resId = _scene->worldstats()->grResId[pluggedOnYellow.resId];
+ item.resourceId = _scene->worldstats()->graphicResourceIds[pluggedOnYellow.resourceId];
item.frameIdx = 0;
item.x = 402;
item.y = 413;
item.priority = 3;
break;
case kPluggedOnBlack:
- item.resId = _scene->worldstats()->grResId[pluggedOnBlack.resId];
+ item.resourceId = _scene->worldstats()->graphicResourceIds[pluggedOnBlack.resourceId];
item.frameIdx = 0;
item.x = 477;
item.y = 418;
item.priority = 3;
break;
case kOnHand: {
- GraphicQueueItem jackItemOnHand = getGraphicJackItem(resIdOnHand);
+ GraphicQueueItem jackItemOnHand = getGraphicJackItem(resourceIdOnHand);
_scene->vm()->screen()->addGraphicToQueue(jackItemOnHand);
item = getGraphicShadowItem();
}
break;
default:
- item.resId = 0;
+ item.resourceId = 0;
break;
}
- if (item.resId != 0)
+ if (item.resourceId != 0)
_scene->vm()->screen()->addGraphicToQueue(item);
}
void BlowUpPuzzleVCR::updateBlackJack() {
VCRDrawInfo onTable;
- onTable.resId = 1;
+ onTable.resourceId = 1;
onTable.x = 0;
onTable.y = 411;
VCRDrawInfo pluggedOnRed;
- pluggedOnRed.resId = 5;
+ pluggedOnRed.resourceId = 5;
VCRDrawInfo pluggedOnYellow;
- pluggedOnYellow.resId = 8;
+ pluggedOnYellow.resourceId = 8;
VCRDrawInfo pluggedOnBlack;
- pluggedOnBlack.resId = 11;
+ pluggedOnBlack.resourceId = 11;
updateJack(kBlack, onTable, pluggedOnRed, pluggedOnYellow, pluggedOnBlack, 27);
}
void BlowUpPuzzleVCR::updateRedJack() {
VCRDrawInfo onTable;
- onTable.resId = 2;
+ onTable.resourceId = 2;
onTable.x = 76;
onTable.y = 428;
VCRDrawInfo pluggedOnRed;
- pluggedOnRed.resId = 4;
+ pluggedOnRed.resourceId = 4;
VCRDrawInfo pluggedOnYellow;
- pluggedOnYellow.resId = 7;
+ pluggedOnYellow.resourceId = 7;
VCRDrawInfo pluggedOnBlack;
- pluggedOnBlack.resId = 10;
+ pluggedOnBlack.resourceId = 10;
updateJack(kRed, onTable, pluggedOnRed, pluggedOnYellow, pluggedOnBlack, 25);
}
void BlowUpPuzzleVCR::updateYellowJack() {
VCRDrawInfo onTable;
- onTable.resId = 3;
+ onTable.resourceId = 3;
onTable.x = 187;
onTable.y = 439;
VCRDrawInfo pluggedOnRed;
- pluggedOnRed.resId = 6;
+ pluggedOnRed.resourceId = 6;
VCRDrawInfo pluggedOnYellow;
- pluggedOnYellow.resId = 9;
+ pluggedOnYellow.resourceId = 9;
VCRDrawInfo pluggedOnBlack;
- pluggedOnBlack.resId = 12;
+ pluggedOnBlack.resourceId = 12;
updateJack(kYellow, onTable, pluggedOnRed, pluggedOnYellow, pluggedOnBlack, 26);
}
@@ -321,13 +326,13 @@ int BlowUpPuzzleVCR::setJackOnHole(int jackType, JackState plugged) {
if (_jacksState[jackType-1] == kOnHand) {
_jacksState[jackType-1] = plugged;
_holesState[plugged-1] = jackType; // set jack on red
- playSound(_scene->worldstats()->grResId[44]);
+ playSound(_scene->worldstats()->graphicResourceIds[44]);
}
} else if (jackType == 0) {
jackType = _holesState[plugged-1];
_jacksState[jackType-1] = kOnHand;
_holesState[plugged-1] = 0;
- playSound(_scene->worldstats()->grResId[43]);
+ playSound(_scene->worldstats()->graphicResourceIds[43]);
return 0;
}
return 1;
@@ -338,7 +343,7 @@ void BlowUpPuzzleVCR::updateButton(Button button, VCRDrawInfo btON, VCRDrawInfo
switch (_buttonsState[button]) {
case kON:
- item.resId = _scene->worldstats()->grResId[btON.resId];
+ item.resourceId = _scene->worldstats()->graphicResourceIds[btON.resourceId];
item.frameIdx = 0;
item.x = btON.x;
item.y = btON.y;
@@ -346,30 +351,30 @@ void BlowUpPuzzleVCR::updateButton(Button button, VCRDrawInfo btON, VCRDrawInfo
break;
case kDownON:
case kDownOFF:
- item.resId = _scene->worldstats()->grResId[btDown.resId];
+ item.resourceId = _scene->worldstats()->graphicResourceIds[btDown.resourceId];
item.frameIdx = 0;
item.x = btDown.x;
item.y = btDown.y;
item.priority = 3;
break;
default:
- item.resId = 0;
+ item.resourceId = 0;
break;
}
- if (item.resId != 0)
+ if (item.resourceId != 0)
_scene->vm()->screen()->addGraphicToQueue(item);
}
void BlowUpPuzzleVCR::updatePowerButton() {
VCRDrawInfo btON;
- btON.resId = 17;
+ btON.resourceId = 17;
btON.x = 512;
btON.y = 347;
VCRDrawInfo btDown;
- btDown.resId = 21;
+ btDown.resourceId = 21;
btDown.x = 506;
btDown.y = 343;
@@ -378,12 +383,12 @@ void BlowUpPuzzleVCR::updatePowerButton() {
void BlowUpPuzzleVCR::updateRewindButton() {
VCRDrawInfo btON;
- btON.resId = 14;
+ btON.resourceId = 14;
btON.x = 248;
btON.y = 347;
VCRDrawInfo btDown;
- btDown.resId = 18;
+ btDown.resourceId = 18;
btDown.x = 245;
btDown.y = 344;
@@ -392,12 +397,12 @@ void BlowUpPuzzleVCR::updateRewindButton() {
void BlowUpPuzzleVCR::updatePlayButton() {
VCRDrawInfo btON;
- btON.resId = 16;
+ btON.resourceId = 16;
btON.x = 401;
btON.y = 359;
VCRDrawInfo btDown;
- btDown.resId = 20;
+ btDown.resourceId = 20;
btDown.x = 391;
btDown.y = 355;
@@ -406,12 +411,12 @@ void BlowUpPuzzleVCR::updatePlayButton() {
void BlowUpPuzzleVCR::updateStopButton() {
VCRDrawInfo btON;
- btON.resId = 15;
+ btON.resourceId = 15;
btON.x = 330;
btON.y = 354;
VCRDrawInfo btDown;
- btDown.resId = 19;
+ btDown.resourceId = 19;
btDown.x = 326;
btDown.y = 350;
@@ -431,27 +436,27 @@ void BlowUpPuzzleVCR::updateCursorInPolyRegion() {
}
if (!showCursor) {
- if (inPolyRegion(_cursor->x(), _cursor->y(), kRewindButton)
- || inPolyRegion(_cursor->x(), _cursor->y(), kStopButton)
- || inPolyRegion(_cursor->x(), _cursor->y(), kPlayButton)
- || inPolyRegion(_cursor->x(), _cursor->y(), kPowerButton)
- || inPolyRegion(_cursor->x(), _cursor->y(), kBlackJack)
- || inPolyRegion(_cursor->x(), _cursor->y(), kRedJack)
- || inPolyRegion(_cursor->x(), _cursor->y(), kYellowJack)) {
+ if (inPolyRegion(_cursor->position().x, _cursor->position().y, kRewindButton)
+ || inPolyRegion(_cursor->position().x, _cursor->position().y, kStopButton)
+ || inPolyRegion(_cursor->position().x, _cursor->position().y, kPlayButton)
+ || inPolyRegion(_cursor->position().x, _cursor->position().y, kPowerButton)
+ || inPolyRegion(_cursor->position().x, _cursor->position().y, kBlackJack)
+ || inPolyRegion(_cursor->position().x, _cursor->position().y, kRedJack)
+ || inPolyRegion(_cursor->position().x, _cursor->position().y, kYellowJack)) {
_cursor->animate();
} else {
- if ((inPolyRegion(_cursor->x(), _cursor->y(), kRedHole) && _holesState[kPluggedOnRed-1])
- || (inPolyRegion(_cursor->x(), _cursor->y(), kYellowHole) && _holesState[kPluggedOnYellow-1])
- || (inPolyRegion(_cursor->x(), _cursor->y(), kBlackHole) && _holesState[kPluggedOnBlack-1])) {
- if (_cursor->currentFrame() != 2) { // reset cursor
+ if ((inPolyRegion(_cursor->position().x, _cursor->position().y, kRedHole) && _holesState[kPluggedOnRed-1])
+ || (inPolyRegion(_cursor->position().x, _cursor->position().y, kYellowHole) && _holesState[kPluggedOnYellow-1])
+ || (inPolyRegion(_cursor->position().x, _cursor->position().y, kBlackHole) && _holesState[kPluggedOnBlack-1])) {
+ if (_cursor->currentFrame != 2) { // reset cursor
_cursor->show();
- _cursor->set(2);
+ _cursor->set(2, 0, 2);
_cursor->animate();
}
} else {
- if (_cursor->currentFrame() != 0) { // reset cursor
+ if (_cursor->currentFrame != 0) { // reset cursor
_cursor->show();
- _cursor->set(0);
+ _cursor->set(0, 0, 2);
_cursor->animate();
}
}
@@ -476,17 +481,17 @@ void BlowUpPuzzleVCR::handleMouseDown() {
}
// Plug-in jacks
- if (inPolyRegion(_cursor->x(), _cursor->y(), kRedHole)) {
+ if (inPolyRegion(_cursor->position().x, _cursor->position().y, kRedHole)) {
if (!setJackOnHole(jackType, kPluggedOnRed)) {
return;
}
}
- if (inPolyRegion(_cursor->x(), _cursor->y(), kYellowHole)) {
+ if (inPolyRegion(_cursor->position().x, _cursor->position().y, kYellowHole)) {
if (!setJackOnHole(jackType, kPluggedOnYellow)) {
return;
}
}
- if (inPolyRegion(_cursor->x(), _cursor->y(), kBlackHole)) {
+ if (inPolyRegion(_cursor->position().x, _cursor->position().y, kBlackHole)) {
if (!setJackOnHole(jackType, kPluggedOnBlack)) {
// TODO: this will probably segfault!
if (_holesState[kBlackHole] != kPluggedOnYellow && _buttonsState[kPower] == 1) {
@@ -501,27 +506,27 @@ void BlowUpPuzzleVCR::handleMouseDown() {
// Put jacks on table --
if (jackType) {
- if (_cursor->x() >= (int32)BlowUpPuzzleVCRPolies[kBlackJack].left && _cursor->x() <= (int32)BlowUpPuzzleVCRPolies[kYellowJack].right &&
- _cursor->y() >= (int32)BlowUpPuzzleVCRPolies[kBlackJack].top && _cursor->y() <= (int32)BlowUpPuzzleVCRPolies[kYellowJack].bottom) {
+ if (_cursor->position().x >= (int32)BlowUpPuzzleVCRPolies[kBlackJack].left && _cursor->position().x <= (int32)BlowUpPuzzleVCRPolies[kYellowJack].right &&
+ _cursor->position().y >= (int32)BlowUpPuzzleVCRPolies[kBlackJack].top && _cursor->position().y <= (int32)BlowUpPuzzleVCRPolies[kYellowJack].bottom) {
_jacksState[jackType-1] = kOnTable;
- playSound(_scene->worldstats()->grResId[50]);
+ playSound(_scene->worldstats()->graphicResourceIds[50]);
_cursor->show();
}
return;
}
// Get Jacks from Table
- if (inPolyRegion(_cursor->x(), _cursor->y(), kBlackJack)) {
+ if (inPolyRegion(_cursor->position().x, _cursor->position().y, kBlackJack)) {
_jacksState[kBlack] = kOnHand;
- } else if (inPolyRegion(_cursor->x(), _cursor->y(), kRedJack)) {
+ } else if (inPolyRegion(_cursor->position().x, _cursor->position().y, kRedJack)) {
_jacksState[kRed] = kOnHand;
- } else if (inPolyRegion(_cursor->x(), _cursor->y(), kYellowJack)) {
+ } else if (inPolyRegion(_cursor->position().x, _cursor->position().y, kYellowJack)) {
_jacksState[kYellow] = kOnHand;
}
// VCR button regions
- if (inPolyRegion(_cursor->x(), _cursor->y(), kRewindButton)) {
- playSound(_scene->worldstats()->grResId[39]);
+ if (inPolyRegion(_cursor->position().x, _cursor->position().y, kRewindButton)) {
+ playSound(_scene->worldstats()->graphicResourceIds[39]);
if (!_buttonsState[kRewind]) {
_buttonsState[kRewind] = kDownON;
return;
@@ -530,8 +535,8 @@ void BlowUpPuzzleVCR::handleMouseDown() {
_buttonsState[kRewind] = kDownOFF;
return;
}
- } else if (inPolyRegion(_cursor->x(), _cursor->y(), kPlayButton)) {
- playSound(_scene->worldstats()->grResId[39]);
+ } else if (inPolyRegion(_cursor->position().x, _cursor->position().y, kPlayButton)) {
+ playSound(_scene->worldstats()->graphicResourceIds[39]);
if (!_buttonsState[kPlay]) {
_buttonsState[kPlay] = kDownON;
return;
@@ -540,8 +545,8 @@ void BlowUpPuzzleVCR::handleMouseDown() {
_buttonsState[kPlay] = kDownOFF;
return;
}
- } else if (inPolyRegion(_cursor->x(), _cursor->y(), kStopButton)) {
- playSound(_scene->worldstats()->grResId[39]);
+ } else if (inPolyRegion(_cursor->position().x, _cursor->position().y, kStopButton)) {
+ playSound(_scene->worldstats()->graphicResourceIds[39]);
if (_buttonsState[kStop]) {
if (_buttonsState[kStop] == kON) {
_buttonsState[kStop] = kDownOFF;
@@ -551,8 +556,8 @@ void BlowUpPuzzleVCR::handleMouseDown() {
_buttonsState[kStop] = kDownON;
return;
}
- } else if (inPolyRegion(_cursor->x(), _cursor->y(), kPowerButton)) {
- playSound(_scene->worldstats()->grResId[39]);
+ } else if (inPolyRegion(_cursor->position().x, _cursor->position().y, kPowerButton)) {
+ playSound(_scene->worldstats()->graphicResourceIds[39]);
if (!_buttonsState[kPower] && _holesState[kPluggedOnBlack-1] == kBlack + 1 && _holesState[kPluggedOnRed-1] && _holesState[kPluggedOnYellow-1]) {
_buttonsState[kPower] = kDownON;
@@ -567,7 +572,7 @@ void BlowUpPuzzleVCR::handleMouseUp() {
return;
if (_buttonsState[kPower] == kDownON) {
- playSound(_scene->worldstats()->grResId[47], true);
+ playSound(_scene->worldstats()->graphicResourceIds[47], true);
_buttonsState[kPower] = kON;
_buttonsState[kStop] = kON;
_buttonsState[kPlay] = kON;
@@ -582,7 +587,7 @@ void BlowUpPuzzleVCR::handleMouseUp() {
if (_buttonsState[kRewind] == kDownOFF) {
_buttonsState[kRewind] = kON;
- playSound(_scene->worldstats()->grResId[46]);
+ playSound(_scene->worldstats()->graphicResourceIds[46]);
} else if (_buttonsState[kRewind] == kDownON) {
_buttonsState[kRewind] = kOFF;
}
@@ -590,7 +595,7 @@ void BlowUpPuzzleVCR::handleMouseUp() {
if (_buttonsState[kPlay] == kDownOFF) {
_buttonsState[kPlay] = kON;
if (_holesState[kPluggedOnRed-1] == kRed + 1 && _holesState[kPluggedOnYellow-1] == kYellow + 1 && _holesState[kPluggedOnBlack-1] == kBlack + 1) {
- _scene->vm()->setGameFlag(220);
+ _scene->vm()->setGameFlag(kGameFlagSolveVCRBlowUpPuzzle);
_isAccomplished = true;
}
} else if (_buttonsState[kPlay] == kDownON) {
diff --git a/engines/asylum/views/blowuppuzzle.h b/engines/asylum/views/blowuppuzzle.h
index edf02dc099..2ba0608203 100644
--- a/engines/asylum/views/blowuppuzzle.h
+++ b/engines/asylum/views/blowuppuzzle.h
@@ -26,14 +26,11 @@
#ifndef ASYLUM_BLOWUPPUZZLE_H
#define ASYLUM_BLOWUPPUZZLE_H
+#include "asylum/shared.h"
+
#include "common/events.h"
#include "common/rect.h"
-#include "asylum/asylum.h"
-#include "asylum/respack.h"
-#include "asylum/graphics.h"
-#include "asylum/cursor.h"
-
namespace Asylum {
class Scene;
@@ -41,6 +38,7 @@ class Screen;
class Sound;
class Video;
class Cursor;
+class GraphicResource;
struct GraphicQueueItem;
class BlowUpPuzzle {
@@ -68,7 +66,7 @@ protected:
GraphicResource *_bgResource;
virtual void update() {};
- void playSound(int32 resourceId, bool loop = false);
+ void playSound(ResourceId resourceId, bool loop = false);
}; // end of class BlowUpPuzzle
@@ -76,7 +74,7 @@ protected:
// ---- VCR -------------------
typedef struct VCRDrawInfo {
- int32 resId;
+ ResourceId resourceId;
int32 x;
int32 y;
} VCRDrawInfo;
@@ -156,9 +154,9 @@ private:
void updateCursorInPolyRegion();
- GraphicQueueItem getGraphicJackItem(int resId);
+ GraphicQueueItem getGraphicJackItem(ResourceId resourceId);
GraphicQueueItem getGraphicShadowItem();
- void updateJack(Jack jack, VCRDrawInfo onTable, VCRDrawInfo pluggedOnRed, VCRDrawInfo pluggedOnYellow, VCRDrawInfo pluggedOnBlack, int resIdOnHand);
+ void updateJack(Jack jack, VCRDrawInfo onTable, VCRDrawInfo pluggedOnRed, VCRDrawInfo pluggedOnYellow, VCRDrawInfo pluggedOnBlack, ResourceId resourceIdOnHand);
void updateBlackJack();
void updateRedJack();
void updateYellowJack();
diff --git a/engines/asylum/views/menu.cpp b/engines/asylum/views/menu.cpp
index b23e291934..7d1893426e 100644
--- a/engines/asylum/views/menu.cpp
+++ b/engines/asylum/views/menu.cpp
@@ -559,7 +559,7 @@ void MainMenu::updateSubMenuQuitGame() {
void MainMenu::updateSubMenuShowCredits() {
int32 posY = _creditsTextScroll;
- int32 resId = 0;
+ ResourceId resourceId = 0;
int32 step = 0;
int32 minBound = 0;
int32 maxBound = 0;
@@ -594,11 +594,11 @@ void MainMenu::updateSubMenuShowCredits() {
}
_vm->text()->setTextPos(320, step + posY);
- _vm->text()->drawResText(resId - 2147482201);
+ _vm->text()->drawResText(resourceId - 2147482201);
posY = _creditsTextScroll;
}
step += 24;
- ++resId;
+ ++resourceId;
} while (step < 0x21F0);
_creditsTextScroll -= 2;
diff --git a/engines/asylum/views/scene.cpp b/engines/asylum/views/scene.cpp
index a002bf4d5d..486543c39c 100644
--- a/engines/asylum/views/scene.cpp
+++ b/engines/asylum/views/scene.cpp
@@ -190,8 +190,8 @@ void Scene::initialize() {
void Scene::startMusic() {
// TODO musicCacheOk check as part of if
int musicId = 0;
- if (_ws->musicCurrentResId != -666 && _ws->numChapter != 1)
- musicId = _ws->musicResId - 0x7FFE0000;
+ if (_ws->musicCurrentResourceId != -666 && _ws->numChapter != 1)
+ musicId = _ws->musicResourceId - 0x7FFE0000;
_vm->sound()->playMusic(_musPack, musicId);
}
@@ -334,12 +334,12 @@ void Scene::update() {
//TODO: other process stuffs from sub 0040AE30
- if (_speech->_soundResIdx != 0) {
- if (_vm->sound()->isPlaying(_speech->_soundResIdx)) {
+ if (_speech->_soundResourceId != 0) {
+ if (_vm->sound()->isPlaying(_speech->_soundResourceId)) {
_speech->prepareSpeech();
} else {
- _speech->_textResIdx = 0;
- _speech->_soundResIdx = 0;
+ _speech->_textResourceId = 0;
+ _speech->_soundResourceId = 0;
_vm->clearGameFlag(kGameFlag219);
}
}
@@ -527,11 +527,11 @@ void Scene::updateMouse() {
void Scene::handleMouseUpdate(int direction, Common::Rect rect) {
int16 rlimit = rect.right - 10;
- int32 newGrResId;
+ ResourceId newGraphicResourceId;
HitType type = kHitNone;
// TODO if encounter_flag03
- if (0 && _cursor->grResId != _ws->curTalkNPC)
+ if (0 && _cursor->graphicResourceId != _ws->curTalkNPC)
_cursor->set(_ws->curTalkNPC, 0, 2);
Actor *act = getActor(); // get the player actor reference
@@ -542,15 +542,15 @@ void Scene::handleMouseUpdate(int direction, Common::Rect rect) {
if (_cursor->field_11 & 2) {
if (act->status == 1 || act->status == 12) {
if (direction >= 0) {
- newGrResId = _ws->curScrollUp + direction;
- _cursor->set(newGrResId, 0, 2);
+ newGraphicResourceId = _ws->curScrollUp + direction;
+ _cursor->set(newGraphicResourceId, 0, 2);
}
}
}
if (act->status == 6 || act->status == 10) {
- newGrResId = _ws->curHand;
- _cursor->set(newGrResId, 0, 2);
+ newGraphicResourceId = _ws->curHand;
+ _cursor->set(newGraphicResourceId, 0, 2);
} else {
if (act->field_638) {
if (_cursor->position().x >= rect.left && _cursor->position().x <= rlimit &&
@@ -566,11 +566,11 @@ void Scene::handleMouseUpdate(int direction, Common::Rect rect) {
} else {
// TODO pass a reference to hitType so it can be populated by
// hitTestScene
- newGrResId = hitTestScene(_cursor->position(), type);
- if (newGrResId != -1) {
+ newGraphicResourceId = hitTestScene(_cursor->position(), type);
+ if (newGraphicResourceId != -1) {
warning ("Can't set mouse cursor, field_D6AC8 not handled ... yet");
// TODO
- // check if _ws->field_D6AC8[act->field_638] != newGrResId
+ // check if _ws->field_D6AC8[act->field_638] != newGraphicResourceId
// if false, set mouse cursor
} else {
// TODO _ws->field_D6B08 stuff, then set cursor
@@ -649,7 +649,7 @@ int32 Scene::hitTestBarrier(const Common::Point pt) {
Barrier *b = _ws->barriers[i];
if (_ws->isBarrierOnScreen(i))
if (b->polyIdx)
- if (hitTestPixel(b->resId, b->frameIdx, pt.x, pt.y, b->flags & 0x1000)) {
+ if (hitTestPixel(b->resourceId, b->frameIdx, pt.x, pt.y, b->flags & 0x1000)) {
targetIdx = i;
break;
}
@@ -738,8 +738,8 @@ bool Scene::hitTestActor(const Common::Point pt) {
(act->direction >= 0));
}
-bool Scene::hitTestPixel(int32 grResId, int32 frame, int16 x, int16 y, bool flipped) {
- GraphicResource *gra = new GraphicResource(_resPack, grResId);
+bool Scene::hitTestPixel(ResourceId resourceId, int32 frame, int16 x, int16 y, bool flipped) {
+ GraphicResource *gra = new GraphicResource(_resPack, resourceId);
GraphicFrame *fra = gra->getFrame(frame);
// TODO this gets a bit funky with the "flipped" calculations for x intersection
@@ -795,8 +795,8 @@ void Scene::updateBarriers() {
// TODO: fix this, and find a better way to get frame count
// Sometimes we get wrong random resource id
- barrier->resId = barrier->getRandomId();
- GraphicResource *gra = new GraphicResource(_resPack, barrier->resId);
+ barrier->resourceId = barrier->getRandomId();
+ GraphicResource *gra = new GraphicResource(_resPack, barrier->resourceId);
barrier->frameCount = gra->getFrameCount();
delete gra;
}
@@ -926,7 +926,7 @@ void Scene::updateAmbientSounds() {
}
}
if (processSound) {
- if (_vm->sound()->isPlaying(snd->resId)) {
+ if (_vm->sound()->isPlaying(snd->resourceId)) {
if (snd->field_0) {
// TODO optimize
// This adjustment only uses the actor at
@@ -936,9 +936,9 @@ void Scene::updateAmbientSounds() {
if (volume <= 0) {
if (volume < -10000)
volume = -10000;
- // TODO setSoundVolume(snd->resId, volume);
+ // TODO setSoundVolume(snd->resourceId, volume);
} else
- ; // TODO setSoundVolume(snd->resId, 0);
+ ; // TODO setSoundVolume(snd->resourceId, 0);
}
} else {
int loflag = LOBYTE(snd->flags);
@@ -957,7 +957,7 @@ void Scene::updateAmbientSounds() {
int tmpVol = volume;
if (vm()->getRandom(10000) < 10) {
if (snd->field_0) {
- _vm->sound()->playSound(snd->resId, false, volume, panning, false);
+ _vm->sound()->playSound(snd->resourceId, false, volume, panning, false);
} else {
// FIXME will this even work?
tmpVol += (vm()->getRandom(500)) * (((vm()->getRandom(100) >= 50) - 1) & 2) - 1;
@@ -968,7 +968,7 @@ void Scene::updateAmbientSounds() {
else
if (tmpVol <= -10000)
tmpVol = -10000;
- _vm->sound()->playSound(snd->resId, 0, tmpVol, vm()->getRandom(20001) - 10000);
+ _vm->sound()->playSound(snd->resourceId, 0, tmpVol, vm()->getRandom(20001) - 10000);
}
}
} else {
@@ -978,8 +978,8 @@ void Scene::updateAmbientSounds() {
}
}
} else {
- if (_vm->sound()->isPlaying(snd->resId))
- _vm->sound()->stopSound(snd->resId);
+ if (_vm->sound()->isPlaying(snd->resourceId))
+ _vm->sound()->stopSound(snd->resourceId);
}
}
}
@@ -1363,11 +1363,11 @@ int Scene::queueBarrierUpdates() {
//TODO: need to do something here yet
if (barrier->field_67C <= 0 || barrier->field_67C >= 4) { // TODO: still missing a condition for game quality config
- _vm->screen()->addGraphicToQueue(barrier->resId, barrier->frameIdx, barrier->x, barrier->y, (barrier->flags >> 11) & 2, barrier->field_67C - 3, barrier->priority);
+ _vm->screen()->addGraphicToQueue(barrier->resourceId, barrier->frameIdx, barrier->x, barrier->y, (barrier->flags >> 11) & 2, barrier->field_67C - 3, barrier->priority);
} else {
// TODO: Do Cross Fade
- // parameters: barrier->resId, barrier->frameIdx, barrier->x, barrier->y, _ws->backgroundImage, _ws->xLeft, _ws->yTop, 0, 0, barrier->field_67C - 1
- _vm->screen()->addGraphicToQueue(barrier->resId, barrier->frameIdx, barrier->x, barrier->y, 0, 0, 0);
+ // parameters: barrier->resourceId, barrier->frameIdx, barrier->x, barrier->y, _ws->backgroundImage, _ws->xLeft, _ws->yTop, 0, 0, barrier->field_67C - 1
+ _vm->screen()->addGraphicToQueue(barrier->resourceId, barrier->frameIdx, barrier->x, barrier->y, 0, 0, 0);
}
}
}
@@ -1513,8 +1513,8 @@ void Scene::debugShowActors() {
SceneTitle::SceneTitle(Scene *scene): _scene(scene) {
_start = _scene->vm()->getTick();
- _bg = new GraphicResource(_scene->_resPack, _scene->_ws->sceneTitleGrResId);
- _scene->vm()->screen()->setPalette(_scene->_resPack, _scene->_ws->sceneTitlePalResId);
+ _bg = new GraphicResource(_scene->_resPack, _scene->_ws->sceneTitleGraphicResourceId);
+ _scene->vm()->screen()->setPalette(_scene->_resPack, _scene->_ws->sceneTitlePaletteResourceId);
ResourcePack *pack = new ResourcePack(0x12);
_progress = new GraphicResource(pack, 0x80120011);
@@ -1555,9 +1555,9 @@ void SceneTitle::update(int32 tick) {
bgFrame->surface.w,
0, 0, 640, 480);
- int32 resId = _scene->getSceneIndex() - 4 + 1811;
- int32 resWidth = _scene->vm()->text()->getResTextWidth(resId);
- _scene->vm()->text()->drawResTextCentered(320 - resWidth * 24, 30, resWidth, resId);
+ ResourceId resourceId = _scene->getSceneIndex() - 4 + 1811;
+ int32 resWidth = _scene->vm()->text()->getResTextWidth(resourceId);
+ _scene->vm()->text()->drawResTextCentered(320 - resWidth * 24, 30, resWidth, resourceId);
GraphicFrame *frame = _progress->getFrame(_spinnerFrame);
diff --git a/engines/asylum/views/scene.h b/engines/asylum/views/scene.h
index e6758e0d25..904f43f8b9 100644
--- a/engines/asylum/views/scene.h
+++ b/engines/asylum/views/scene.h
@@ -182,7 +182,7 @@ protected:
* Check if the mouse cursor is currently intersecting
* a graphic resource at the supplied coordinates
*/
- bool hitTestPixel(int32 grResId, int32 frame, int16 x, int16 y, bool flipped);
+ bool hitTestPixel(ResourceId resourceId, int32 frame, int16 x, int16 y, bool flipped);
/** .text:0040E8A0
* Checks if the supplied coordinates are inside an action area, barrier or
* actor, and returns -1 if nothing was found, or the type of hit if found
@@ -282,7 +282,6 @@ private:
int queueBarrierUpdates();
bool isBarrierVisible(BarrierItem *barrier);
bool isBarrierOnScreen(BarrierItem *barrier);
- int32 getRandomResId(BarrierItem *barrier);
void copyToBackBufferClipped(Graphics::Surface *surface, int x, int y);
Commit: df74fd7a7c30972141d12048582d0d9c51666a07
https://github.com/scummvm/scummvm/commit/df74fd7a7c30972141d12048582d0d9c51666a07
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:06+02:00
Commit Message:
ASYLUM: Implement Set/Clear/JumpIfActionType opcodes
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@469 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/resources/actionlist.cpp
engines/asylum/resources/actionlist.h
engines/asylum/resources/actor.cpp
engines/asylum/resources/actor.h
engines/asylum/resources/barrier.h
engines/asylum/resources/worldstats.cpp
engines/asylum/shared.h
engines/asylum/views/scene.cpp
diff --git a/engines/asylum/resources/actionlist.cpp b/engines/asylum/resources/actionlist.cpp
index 0416a72d84..6889e449de 100644
--- a/engines/asylum/resources/actionlist.cpp
+++ b/engines/asylum/resources/actionlist.cpp
@@ -53,20 +53,20 @@ ActionList::ActionList(Common::SeekableReadStream *stream, Scene *scene) : _scen
ADD_OPCODE(DestroyBarrier);
ADD_OPCODE(_unk12_JMP_WALK_ACTOR);
ADD_OPCODE(_unk13_JMP_WALK_ACTOR);
- ADD_OPCODE(_unk14_JMP_WALK_ACTOR);
+ ADD_OPCODE(JumpIfActorCoordinates);
ADD_OPCODE(_unk15);
ADD_OPCODE(ResetAnimation);
- ADD_OPCODE(ClearFlag1Bit0);
+ ADD_OPCODE(SetBarrierDestroyed);
ADD_OPCODE(_unk18_PLAY_SND);
- ADD_OPCODE(JumpIfFlag2Bit0);
- ADD_OPCODE(SetFlag2Bit0);
- ADD_OPCODE(ClearFlag2Bit0);
- ADD_OPCODE(JumpIfFlag2Bit2);
- ADD_OPCODE(SetFlag2Bit2);
- ADD_OPCODE(ClearFlag2Bit2);
- ADD_OPCODE(JumpIfFlag2Bit1);
- ADD_OPCODE(SetFlag2Bit1);
- ADD_OPCODE(ClearFlag2Bit1);
+ ADD_OPCODE(JumpIfActionFind);
+ ADD_OPCODE(SetActionFind);
+ ADD_OPCODE(clearActionFind);
+ ADD_OPCODE(JumpIfActionGrab);
+ ADD_OPCODE(SetActionGrab);
+ ADD_OPCODE(ClearActionGrab);
+ ADD_OPCODE(JumpIfActionTalk);
+ ADD_OPCODE(SetActionTalk);
+ ADD_OPCODE(ClearActionTalk);
ADD_OPCODE(_unk22);
ADD_OPCODE(_unk23);
ADD_OPCODE(_unk24);
@@ -358,14 +358,14 @@ IMPLEMENT_OPCODE(PlayAnimation) {
// Update flags
if (cmd->param4) {
- barrier->flags &= kBarrierFlagFFFEF1C7;
+ barrier->flags &= ~kBarrierFlag10E38;
barrier->flags |= kBarrierFlag20;
} else if (cmd->param3) {
- barrier->flags &= kBarrierFlagFFFEF1C7;
+ barrier->flags &= ~kBarrierFlag10E38;
barrier->flags |= kBarrierFlag10000;
} else if (barrier->flags & kBarrierFlag10000) {
barrier->flags |= kBarrierFlag8;
- barrier->flags &= kBarrierFlagFFFEFFFF;
+ barrier->flags &= ~kBarrierFlag10000;
} else if (!(barrier->flags & kBarrierFlag10E38)) {
barrier->flags |= kBarrierFlag8;
}
@@ -519,19 +519,57 @@ IMPLEMENT_OPCODE(DestroyBarrier) {
//////////////////////////////////////////////////////////////////////////
// Opcode 0x12
IMPLEMENT_OPCODE(_unk12_JMP_WALK_ACTOR) {
- error("Unhandled opcode %s (0x%02X) in Scene %d Line %d", _opcodes[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
+ Actor *actor = _scene->getActor();
+
+ if (actor->process(cmd->param2, cmd->param3))
+ return;
+
+ _currentLine = cmd->param4;
+
+ if (cmd->param5)
+ actor->speech(1);
}
//////////////////////////////////////////////////////////////////////////
// Opcode 0x13
IMPLEMENT_OPCODE(_unk13_JMP_WALK_ACTOR) {
- error("Unhandled opcode %s (0x%02X) in Scene %d Line %d", _opcodes[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
+ Actor *actor = _scene->getActor();
+
+ if (actor->status != kActorStatus2 && actor->status != kActorStatus13) {
+ if (cmd->param5 != 2) {
+
+ if (cmd->param2 == -1 || cmd->param3 == -1) {
+ actor->setDirection(cmd->param4);
+ } else if ((actor->x1 + actor->x2) == cmd->param2 && (actor->y1 + actor->y2) == cmd->param3) {
+ actor->setDirection(cmd->param4);
+ } else {
+ actor->processStatus(cmd->param2, cmd->param3, cmd->param4);
+
+ if (cmd->param5 == 1) {
+ cmd->param5 = 2;
+ _lineIncrement = 1;
+ }
+ }
+ } else {
+ cmd->param5 = 1;
+ _lineIncrement = 0;
+
+ if ((actor->x1 + actor->x2) == cmd->param2 && (actor->y1 + actor->y2) == cmd->param3)
+ actor->setDirection(cmd->param4);
+ }
+ } else {
+ if (cmd->param5 == 2)
+ _lineIncrement = 1;
+ }
}
//////////////////////////////////////////////////////////////////////////
// Opcode 0x14
-IMPLEMENT_OPCODE(_unk14_JMP_WALK_ACTOR) {
- error("Unhandled opcode %s (0x%02X) in Scene %d Line %d", _opcodes[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
+IMPLEMENT_OPCODE(JumpIfActorCoordinates) {
+ Actor *actor = _scene->getActor();
+
+ if ((actor->x1 + actor->x2) != cmd->param2 || (actor->y1 + actor->y2) != cmd->param3)
+ _lineIncrement = cmd->param4;
}
//////////////////////////////////////////////////////////////////////////
@@ -545,18 +583,18 @@ IMPLEMENT_OPCODE(_unk15) {
IMPLEMENT_OPCODE(ResetAnimation) {
Barrier *barrier = _scene->worldstats()->getBarrierById(cmd->param1);
- if ((barrier->flags & 0x10000) == 0)
- barrier->frameIdx = 0;
- else
+ if (barrier->flags & kBarrierFlag10000)
barrier->frameIdx = barrier->frameCount - 1;
+ else
+ barrier->frameIdx = 0;
}
//////////////////////////////////////////////////////////////////////////
// Opcode 0x17
-IMPLEMENT_OPCODE(ClearFlag1Bit0) {
+IMPLEMENT_OPCODE(SetBarrierDestroyed) {
Barrier *barrier = _scene->worldstats()->getBarrierById(cmd->param1);
- barrier->flags &= 0xFFFFFFFE;
+ barrier->flags &= kBarrierFlagDestroyed;
}
//////////////////////////////////////////////////////////////////////////
@@ -567,76 +605,56 @@ IMPLEMENT_OPCODE(_unk18_PLAY_SND) {
//////////////////////////////////////////////////////////////////////////
// Opcode 0x19
-IMPLEMENT_OPCODE(JumpIfFlag2Bit0) {
- int targetType = cmd->param2;
-
- error("Incomplete opcode %s (0x%02X) in Scene %d Line %d", _opcodes[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
- // TODO targetType == 7 is trying to access an out of bounds actor
- // look at the disassembly again
-
- if (targetType <= 0)
- _done = (_scene->worldstats()->getBarrierById(cmd->param1)->flags2 & 1) == 0;
- else
- if (targetType == 1) // v4 == 1, so 1
- _done = (_scene->worldstats()->getActionAreaById(cmd->param1)->actionType & 1) == 0;
- else
- _done = (_scene->worldstats()->actors[cmd->param1]->flags2 & 1) == 0;
+IMPLEMENT_OPCODE(JumpIfActionFind) {
+ jumpIfActionFlag(cmd, kActionTypeFind);
}
//////////////////////////////////////////////////////////////////////////
// Opcode 0x1A
-IMPLEMENT_OPCODE(SetFlag2Bit0) {
- int targetType = cmd->param2;
-
- if (targetType == 2)
- _scene->worldstats()->actors[cmd->param1]->flags2 |= 1;
- else
- if (targetType == 1)
- _scene->worldstats()->getActionAreaById(cmd->param1)->actionType |= 1;
- else
- _scene->worldstats()->getBarrierById(cmd->param1)->flags2 |= 1;
+IMPLEMENT_OPCODE(SetActionFind) {
+ setActionFlag(cmd, kActionTypeFind);
}
//////////////////////////////////////////////////////////////////////////
// Opcode 0x1B
-IMPLEMENT_OPCODE(ClearFlag2Bit0) {
- error("Unhandled opcode %s (0x%02X) in Scene %d Line %d", _opcodes[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
+IMPLEMENT_OPCODE(clearActionFind) {
+ clearActionFlag(cmd, kActionTypeFind);
}
//////////////////////////////////////////////////////////////////////////
// Opcode 0x1C
-IMPLEMENT_OPCODE(JumpIfFlag2Bit2) {
- error("Unhandled opcode %s (0x%02X) in Scene %d Line %d", _opcodes[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
+IMPLEMENT_OPCODE(JumpIfActionGrab) {
+ jumpIfActionFlag(cmd, kActionTypeGrab);
}
//////////////////////////////////////////////////////////////////////////
// Opcode 0x1D
-IMPLEMENT_OPCODE(SetFlag2Bit2) {
- error("Unhandled opcode %s (0x%02X) in Scene %d Line %d", _opcodes[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
+IMPLEMENT_OPCODE(SetActionGrab) {
+ setActionFlag(cmd, kActionTypeGrab);
}
//////////////////////////////////////////////////////////////////////////
// Opcode 0x1E
-IMPLEMENT_OPCODE(ClearFlag2Bit2) {
- error("Unhandled opcode %s (0x%02X) in Scene %d Line %d", _opcodes[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
+IMPLEMENT_OPCODE(ClearActionGrab) {
+ clearActionFlag(cmd, kActionTypeGrab);
}
//////////////////////////////////////////////////////////////////////////
// Opcode 0x1F
-IMPLEMENT_OPCODE(JumpIfFlag2Bit1) {
- error("Unhandled opcode %s (0x%02X) in Scene %d Line %d", _opcodes[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
+IMPLEMENT_OPCODE(JumpIfActionTalk) {
+ jumpIfActionFlag(cmd, kActionTypeTalk);
}
//////////////////////////////////////////////////////////////////////////
// Opcode 0x20
-IMPLEMENT_OPCODE(SetFlag2Bit1) {
- error("Unhandled opcode %s (0x%02X) in Scene %d Line %d", _opcodes[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
+IMPLEMENT_OPCODE(SetActionTalk) {
+ setActionFlag(cmd, kActionTypeTalk);
}
//////////////////////////////////////////////////////////////////////////
// Opcode 0x21
-IMPLEMENT_OPCODE(ClearFlag2Bit1) {
- error("Unhandled opcode %s (0x%02X) in Scene %d Line %d", _opcodes[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
+IMPLEMENT_OPCODE(ClearActionTalk) {
+ clearActionFlag(cmd, kActionTypeTalk);
}
//////////////////////////////////////////////////////////////////////////
@@ -1259,7 +1277,7 @@ IMPLEMENT_OPCODE(SetBarrierLastFrameIdx) {
if (barrier->frameIdx == barrier->frameCount - 1) {
_lineIncrement = 0;
- barrier->flags &= kBarrierFlagFFFEF1C7;
+ barrier->flags &= ~kBarrierFlag10E38;
} else {
_lineIncrement = 1;
}
@@ -1310,4 +1328,63 @@ void ActionList::enableBarrier(ScriptEntry *cmd, BarrierEnableType type) {
error("[ActionList::enableBarrier] not implemented!");
}
+void ActionList::setActionFlag(ScriptEntry *cmd, ActionType flag) {
+ switch (cmd->param2) {
+ default:
+ _scene->worldstats()->getBarrierById(cmd->param1)->actionType |= flag;
+ break;
+
+ case 1:
+ _scene->worldstats()->getActionAreaById(cmd->param1)->actionType |= flag;
+ break;
+
+ case 2:
+ _scene->worldstats()->actors[cmd->param1]->actionType |= flag;
+ break;
+ }
+}
+
+void ActionList::clearActionFlag(ScriptEntry *cmd, ActionType flag) {
+ switch (cmd->param2) {
+ default:
+ _scene->worldstats()->getBarrierById(cmd->param1)->actionType &= ~flag;
+ break;
+
+ case 1:
+ _scene->worldstats()->getActionAreaById(cmd->param1)->actionType &= ~flag;
+ break;
+
+ case 2:
+ _scene->worldstats()->actors[cmd->param1]->actionType &= ~flag;
+ break;
+ }
+}
+
+void ActionList::jumpIfActionFlag(ScriptEntry *cmd, ActionType flag) {
+ bool done = false;
+
+ switch (cmd->param3) {
+ default:
+ done = (_scene->worldstats()->actors[cmd->param1]->actionType & flag) == 0;
+ break;
+
+ case 0:
+ done = (_scene->worldstats()->getBarrierById(cmd->param1)->actionType & flag) == 0;
+ break;
+
+ case 1:
+ done = (_scene->worldstats()->getActionAreaById(cmd->param1)->actionType & flag) == 0;
+ break;
+ }
+
+ if (!done)
+ return;
+
+ int32 opcode = _currentScript->commands[cmd->param2].opcode;
+ if (opcode == 0x10 || opcode == 0) { // Return
+ _currentLine = cmd->param2;
+ } else {
+ _done = true;
+ }
+}
} // end of namespace Asylum
diff --git a/engines/asylum/resources/actionlist.h b/engines/asylum/resources/actionlist.h
index e0176ae277..f45d9c8823 100644
--- a/engines/asylum/resources/actionlist.h
+++ b/engines/asylum/resources/actionlist.h
@@ -155,7 +155,11 @@ private:
void resetQueue();
void enableBarrier(ScriptEntry *cmd, BarrierEnableType type);
+ void setActionFlag(ScriptEntry *cmd, ActionType flag); //|
+ void clearActionFlag(ScriptEntry *cmd, ActionType flag); //&
+ void jumpIfActionFlag(ScriptEntry *cmd, ActionType flag);
+ //////////////////////////////////////////////////////////////////////////
// Opcode functions
DECLARE_OPCODE(Return);
DECLARE_OPCODE(SetGameFlag);
@@ -176,20 +180,20 @@ private:
DECLARE_OPCODE(DestroyBarrier);
DECLARE_OPCODE(_unk12_JMP_WALK_ACTOR);
DECLARE_OPCODE(_unk13_JMP_WALK_ACTOR);
- DECLARE_OPCODE(_unk14_JMP_WALK_ACTOR);
+ DECLARE_OPCODE(JumpIfActorCoordinates);
DECLARE_OPCODE(_unk15);
DECLARE_OPCODE(ResetAnimation);
- DECLARE_OPCODE(ClearFlag1Bit0);
+ DECLARE_OPCODE(SetBarrierDestroyed);
DECLARE_OPCODE(_unk18_PLAY_SND);
- DECLARE_OPCODE(JumpIfFlag2Bit0);
- DECLARE_OPCODE(SetFlag2Bit0);
- DECLARE_OPCODE(ClearFlag2Bit0);
- DECLARE_OPCODE(JumpIfFlag2Bit2);
- DECLARE_OPCODE(SetFlag2Bit2);
- DECLARE_OPCODE(ClearFlag2Bit2);
- DECLARE_OPCODE(JumpIfFlag2Bit1);
- DECLARE_OPCODE(SetFlag2Bit1);
- DECLARE_OPCODE(ClearFlag2Bit1);
+ DECLARE_OPCODE(JumpIfActionFind);
+ DECLARE_OPCODE(SetActionFind);
+ DECLARE_OPCODE(clearActionFind);
+ DECLARE_OPCODE(JumpIfActionGrab);
+ DECLARE_OPCODE(SetActionGrab);
+ DECLARE_OPCODE(ClearActionGrab);
+ DECLARE_OPCODE(JumpIfActionTalk);
+ DECLARE_OPCODE(SetActionTalk);
+ DECLARE_OPCODE(ClearActionTalk);
DECLARE_OPCODE(_unk22);
DECLARE_OPCODE(_unk23);
DECLARE_OPCODE(_unk24);
diff --git a/engines/asylum/resources/actor.cpp b/engines/asylum/resources/actor.cpp
index a194a4ad2f..6a94c13c45 100644
--- a/engines/asylum/resources/actor.cpp
+++ b/engines/asylum/resources/actor.cpp
@@ -35,7 +35,7 @@
namespace Asylum {
-Actor::Actor(Scene *scene) : _scene(scene), _currentWalkArea(NULL), _graphic(NULL) {
+Actor::Actor(Scene *scene, ActorIndex index) : _scene(scene), _index(index), _currentWalkArea(NULL), _graphic(NULL) {
currentAction = 0;
// TODO initialize other class variables
@@ -49,9 +49,9 @@ Actor::~Actor() {
void Actor::setVisible(bool value) {
if (value)
- flags |= kVisible;
+ flags |= kActorFlagVisible;
else
- flags &= kHidden;
+ flags &= ~kActorFlagVisible;
stopSound();
}
@@ -787,4 +787,23 @@ bool Actor::defaultDirectionLoaded(int grResTableIdx) {
return graphicResourceIds[grResTableIdx] != graphicResourceIds[5];
}
+bool Actor::process(int32 x, int32 y) {
+ error("[Actor::process] not implemented!");
+}
+
+void Actor::processStatus(int32 x, int32 y, bool doSpeech) {
+ if (process(x, y)) {
+ if (status < kActorStatus11)
+ updateStatus(kActorStatus2);
+ else
+ updateStatus(kActorStatus13);
+ } else if (doSpeech) {
+ speech(1);
+ }
+}
+
+void Actor::speech(int32 a1) {
+ error("[Actor::speech] not implemented!");
+}
+
} // end of namespace Asylum
diff --git a/engines/asylum/resources/actor.h b/engines/asylum/resources/actor.h
index 95a5f5f317..4267564965 100644
--- a/engines/asylum/resources/actor.h
+++ b/engines/asylum/resources/actor.h
@@ -74,8 +74,7 @@ enum ActorType {
};
enum ActorFlags {
- kVisible = 0x01,
- kHidden = 0xFFFFFFFE
+ kActorFlagVisible = 1
};
enum DirectionFrom {
@@ -179,7 +178,7 @@ enum ActorResources {
class Actor {
public:
- Actor(Scene *scene);
+ Actor(Scene *scene, ActorIndex index);
virtual ~Actor();
/**
@@ -191,7 +190,7 @@ public:
void setRawResources(uint8* data);
// Visibility
- bool isVisible() { return flags & kVisible; }
+ bool isVisible() { return flags & kActorFlagVisible; }
void setVisible(bool value);
/** .text:0040A260
@@ -215,6 +214,13 @@ public:
bool defaultDirectionLoaded(int grResTableIdx);
+ void stopSound();
+ bool process(int32 x, int32 y);
+ void processStatus(int32 x, int32 y, bool doSpeech);
+
+ void speech(int32 a1);
+
+ //////////////////////////////////////////////////////////////////////////
// OLD METHODS
// TODO ALL of these need to be depreciated in favour
// of the proper functions from the original
@@ -224,9 +230,9 @@ public:
void drawActorAt(int32 curX, int32 curY);
void drawActor();
void walkTo(int32 curX, int32 curY);
+ //////////////////////////////////////////////////////////////////////////
- void stopSound();
int32 currentAction; // TODO depreciate
@@ -271,7 +277,7 @@ public:
int32 field_924;
int32 tickValue;
int32 field_92C;
- int32 flags2;
+ int32 actionType;
int32 field_934;
int32 field_938;
ResourceId soundResourceId; // field_93C
diff --git a/engines/asylum/resources/barrier.h b/engines/asylum/resources/barrier.h
index 0c8ef52164..34653159b7 100644
--- a/engines/asylum/resources/barrier.h
+++ b/engines/asylum/resources/barrier.h
@@ -33,15 +33,14 @@
namespace Asylum {
enum BarrierFlag {
+ kBarrierFlagDestroyed = -2,
kBarrierFlag4 = 0x4,
kBarrierFlag8 = 0x8,
kBarrierFlag20 = 0x20,
+ kBarrierFlagC000 = 0xC000,
kBarrierFlag10000 = 0x10000,
kBarrierFlag10E38 = 0x10E38,
- kBarrierFlag20000 = 0x20000,
- kBarrierFlagFFFEF1C7 = 0xFFFEF1C7,
- kBarrierFlagFFFEFFFF = 0xFFFEFFFF,
- kBarrierFlagDestroyed = 0xFFFFFFFE
+ kBarrierFlag20000 = 0x20000
};
class Scene;
@@ -90,7 +89,7 @@ public:
int32 field_7C; // to do with calculating
int32 field_80; // actor intersection
int32 polyIdx;
- int32 flags2;
+ int32 actionType;
GameFlag gameFlags[10];
int32 field_B4;
int32 tickCount;
diff --git a/engines/asylum/resources/worldstats.cpp b/engines/asylum/resources/worldstats.cpp
index f928782b43..84558294c1 100644
--- a/engines/asylum/resources/worldstats.cpp
+++ b/engines/asylum/resources/worldstats.cpp
@@ -254,7 +254,7 @@ void WorldStats::load(Common::SeekableReadStream *stream) {
barrier->field_7C = stream->readSint32LE();
barrier->field_80 = stream->readSint32LE();
barrier->polyIdx = stream->readSint32LE();
- barrier->flags2 = stream->readSint32LE();
+ barrier->actionType = stream->readSint32LE();
for (i = 0; i < 10; i++)
barrier->gameFlags[i] = (GameFlag)stream->readSint32LE();
@@ -300,9 +300,8 @@ void WorldStats::load(Common::SeekableReadStream *stream) {
// need to jump all unused barriers data to where actors data start
stream->seek(0xA6D7A);
- for (int32 a = 0; a < numActors; a++) {
- int32 i;
- Actor *actor = new Actor(_scene);
+ for (ActorIndex index = 0; index < numActors; index++) {
+ Actor *actor = new Actor(_scene, index);
actor->x = stream->readSint32LE();
actor->y = stream->readSint32LE();
@@ -336,7 +335,7 @@ void WorldStats::load(Common::SeekableReadStream *stream) {
// TODO skip field_68 till field_617
stream->skip(0x5B0);
- for (i = 0; i < 8; i++)
+ for (int32 i = 0; i < 8; i++)
actor->reaction[i] = stream->readSint32LE();
actor->field_638 = stream->readSint32LE();
@@ -347,25 +346,25 @@ void WorldStats::load(Common::SeekableReadStream *stream) {
actor->field_64C = stream->readSint32LE();
actor->field_650 = stream->readSint32LE();
- for (i = 0; i < 55; i++)
+ for (int32 i = 0; i < 55; i++)
actor->graphicResourceIds[i] = stream->readSint32LE();
stream->read(actor->name, sizeof(actor->name));
- for (i = 0; i < 20; i++)
+ for (int32 i = 0; i < 20; i++)
actor->field_830[i] = stream->readSint32LE();
- for (i = 0; i < 20; i++)
+ for (int32 i = 0; i < 20; i++)
actor->field_880[i] = stream->readSint32LE();
- for (i = 0; i < 20; i++)
+ for (int32 i = 0; i < 20; i++)
actor->field_8D0[i] = stream->readSint32LE();
actor->actionIdx2 = stream->readSint32LE();
actor->field_924 = stream->readSint32LE();
actor->tickValue = stream->readSint32LE();
actor->field_92C = stream->readSint32LE();
- actor->flags2 = stream->readSint32LE();
+ actor->actionType = stream->readSint32LE();
actor->field_934 = stream->readSint32LE();
actor->field_938 = stream->readSint32LE();
actor->soundResourceId = stream->readSint32LE();
diff --git a/engines/asylum/shared.h b/engines/asylum/shared.h
index a7f48f570a..55739fd8a1 100644
--- a/engines/asylum/shared.h
+++ b/engines/asylum/shared.h
@@ -46,6 +46,14 @@ enum ResourceIdEnum {
kResourceSound_80120006 = 0x80120006
};
+enum ActionType {
+ kActionTypeNone = 0,
+ kActionTypeFind = 1,
+ kActionTypeTalk = 2,
+ kActionType3 = 3,
+ kActionTypeGrab = 4
+};
+
//////////////////////////////////////////////////////////////////////////
// Helpers
#define CLEAR_ARRAY(type, name) { \
diff --git a/engines/asylum/views/scene.cpp b/engines/asylum/views/scene.cpp
index 486543c39c..cf96ddf9b7 100644
--- a/engines/asylum/views/scene.cpp
+++ b/engines/asylum/views/scene.cpp
@@ -121,7 +121,7 @@ void Scene::initialize() {
for (int32 b = 0; b < _ws->numBarriers; b++) {
Barrier *barrier = _ws->barriers[b];
barrier->priority = priority;
- barrier->flags &= 0xFFFF3FFF;
+ barrier->flags &= ~kBarrierFlagC000;
priority -= 4;
}
}
@@ -605,7 +605,7 @@ void Scene::handleMouseUpdate(int direction, Common::Rect rect) {
targetUpdateType = _ws->actions[targetIdx]->actionType;
break;
case kHitBarrier:
- targetUpdateType = _ws->barriers[targetIdx]->flags2;
+ targetUpdateType = _ws->barriers[targetIdx]->actionType;
break;
case kHitActor:
targetUpdateType = getActor(targetIdx)->status;
@@ -824,7 +824,7 @@ void Scene::updateBarriers() {
// TODO: get global x, y positions
}
} else {
- barrier->flags &= 0xFFFFFFF7;
+ barrier->flags &= ~kBarrierFlag8;
if (barrier->field_688 == 1) {
// TODO: reset global x, y positions
}
@@ -843,7 +843,7 @@ void Scene::updateBarriers() {
if (_vm->getTick() - barrier->tickCount >= 0x3E8 / barrier->field_B4 && (flag & 0x10000)) {
uint32 frameIdx = barrier->frameIdx - 1;
if (frameIdx <= 0) {
- barrier->flags &= 0xFFFEFFFF;
+ barrier->flags &= ~kBarrierFlag10000;
if (barrier->field_688 == 1) {
// TODO: reset global x, y positions
}
Commit: f0c46d5e7ccd18fbfa59cf9b47b85580d330a117
https://github.com/scummvm/scummvm/commit/f0c46d5e7ccd18fbfa59cf9b47b85580d330a117
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:07+02:00
Commit Message:
ASYLUM: Implement remaining opcodes
- Add relevant needed stubs in Actor/Sound/Scene/Screen/Engine classes
- Have Encounter & BlowUpPuzzle compile again
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@470 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/asylum.cpp
engines/asylum/asylum.h
engines/asylum/resources/actionlist.cpp
engines/asylum/resources/actionlist.h
engines/asylum/resources/actor.cpp
engines/asylum/resources/actor.h
engines/asylum/resources/barrier.h
engines/asylum/resources/encounters.cpp
engines/asylum/resources/encounters.h
engines/asylum/resources/worldstats.h
engines/asylum/shared.h
engines/asylum/staticres.h
engines/asylum/system/screen.cpp
engines/asylum/system/screen.h
engines/asylum/system/sound.cpp
engines/asylum/system/sound.h
engines/asylum/views/menu.cpp
engines/asylum/views/menu.h
engines/asylum/views/scene.cpp
engines/asylum/views/scene.h
diff --git a/engines/asylum/asylum.cpp b/engines/asylum/asylum.cpp
index 1bf3488320..f50a699244 100644
--- a/engines/asylum/asylum.cpp
+++ b/engines/asylum/asylum.cpp
@@ -25,6 +25,8 @@
#include "asylum/asylum.h"
+#include "asylum/resources/encounters.h"
+
#include "asylum/system/config.h"
#include "asylum/system/screen.h"
#include "asylum/system/sound.h"
@@ -71,7 +73,7 @@ AsylumEngine::AsylumEngine(OSystem *system, const ADGameDescription *gd) : Engin
AsylumEngine::~AsylumEngine() {
delete _console;
- //delete _encounter;
+ delete _encounter;
delete _mainMenu;
delete _scene;
delete _screen;
@@ -95,16 +97,11 @@ Common::Error AsylumEngine::run() {
_sound = new Sound(_mixer);
_video = new Video(_mixer);
_text = new Text(_screen);
- _mainMenu = 0;
- _scene = 0;
- //_encounter = 0;
+ _scene = NULL;
+ _encounter = NULL;
_introPlaying = false;
- // TODO
- //g_object_x = -1;
- //g_object_y = -1;
-
memset(_gameFlags, 0, 1512);
// Start the game
@@ -168,7 +165,7 @@ void AsylumEngine::startGame() {
//_scene->setBlowUpPuzzle(new BlowUpPuzzleVCR(_scene));
// XXX Testing
- //_encounter = new Encounter(_scene);
+ _encounter = new Encounter(_scene);
// Enter first scene
if(!_introPlaying)
@@ -185,8 +182,8 @@ void AsylumEngine::playIntro() {
_video->playVideo(1, Config.showMovieSubtitles);
- if (_scene->worldstats()->musicCurrentResourceId != -666)
- _sound->playMusic(_scene->worldstats()->musicCurrentResourceId);
+ if (_scene->worldstats()->musicCurrentResourceId != kResourceMusic_FFFFFD66)
+ _sound->playMusic(_scene->getResourcePack(), _scene->worldstats()->musicCurrentResourceId);
_screen->clearScreen();
@@ -195,7 +192,7 @@ void AsylumEngine::playIntro() {
// Play the intro sound sample (the screen is blacked out, you hear
// an alarm sounding and men talking about.
- _sound->playSound(0x80120007, false, Config.sfxVolume, 0);
+ _sound->playSound(kResourceSoundIntro, false, Config.sfxVolume, 0);
}
void AsylumEngine::handleEvents(bool doUpdate) { // k_sub_40AE30 (0040AE30)
@@ -327,6 +324,17 @@ void AsylumEngine::processDelayedEvents() {
}
}
+//////////////////////////////////////////////////////////////////////////
+// Message handlers
+//////////////////////////////////////////////////////////////////////////
+void AsylumEngine::switchMessageHandler(MessageHandler *handler) {
+ error("[AsylumEngine::switchMessageHandler] not implemented");
+}
+
+AsylumEngine::MessageHandler *AsylumEngine::getMessageHandler(uint32 index) {
+ error("[AsylumEngine::getMessageHandler] not implemented");
+}
+
//////////////////////////////////////////////////////////////////////////
// Game flags
//////////////////////////////////////////////////////////////////////////
diff --git a/engines/asylum/asylum.h b/engines/asylum/asylum.h
index b017bdccd5..5225f70bd4 100644
--- a/engines/asylum/asylum.h
+++ b/engines/asylum/asylum.h
@@ -108,6 +108,8 @@ protected:
virtual GUI::Debugger *getDebugger() { return _console; }
public:
+ typedef Common::Functor1<Common::Event &, void> MessageHandler;
+
AsylumEngine(OSystem *system, const ADGameDescription *gd);
virtual ~AsylumEngine();
@@ -129,11 +131,13 @@ public:
uint32 tempTick07;
// Game
- Video* video() { return _video; }
- Sound* sound() { return _sound; }
- Screen* screen() { return _screen; }
- Scene* scene() { return _scene; }
- Text* text() { return _text; }
+ Encounter *encouter() { return _encounter; }
+ MainMenu *menu() { return _mainMenu; }
+ Scene *scene() { return _scene; }
+ Screen *screen() { return _screen; }
+ Sound *sound() { return _sound; }
+ Text *text() { return _text; }
+ Video *video() { return _video; }
// Flags
void setGameFlag(GameFlag flag);
@@ -150,6 +154,10 @@ public:
void setFlag(FlagType flag) { setFlag(flag, true); }
void clearFlag(FlagType flag) { setFlag(flag, false); }
+ // Message handler
+ void switchMessageHandler(MessageHandler *handler);
+ MessageHandler *getMessageHandler(uint32 index);
+
private:
const ADGameDescription *_gameDescription;
@@ -158,7 +166,7 @@ private:
Common::RandomSource _rnd;
// Game
- //Encounter *_encounter;
+ Encounter *_encounter;
MainMenu *_mainMenu;
Scene *_scene;
Screen *_screen;
diff --git a/engines/asylum/resources/actionlist.cpp b/engines/asylum/resources/actionlist.cpp
index 6889e449de..3a99217e97 100644
--- a/engines/asylum/resources/actionlist.cpp
+++ b/engines/asylum/resources/actionlist.cpp
@@ -25,8 +25,15 @@
#include "asylum/resources/actionlist.h"
+#include "asylum/resources/encounters.h"
+
#include "asylum/system/config.h"
+#include "asylum/views/menu.h"
+#include "asylum/views/scene.h"
+
+#include "asylum/staticres.h"
+
#include "common/rational.h"
namespace Asylum {
@@ -51,16 +58,16 @@ ActionList::ActionList(Common::SeekableReadStream *stream, Scene *scene) : _scen
ADD_OPCODE(EnableBarriers);
ADD_OPCODE(Return);
ADD_OPCODE(DestroyBarrier);
- ADD_OPCODE(_unk12_JMP_WALK_ACTOR);
- ADD_OPCODE(_unk13_JMP_WALK_ACTOR);
+ ADD_OPCODE(JumpActorSpeech);
+ ADD_OPCODE(JumpAndSetDirection);
ADD_OPCODE(JumpIfActorCoordinates);
- ADD_OPCODE(_unk15);
+ ADD_OPCODE(Nop);
ADD_OPCODE(ResetAnimation);
ADD_OPCODE(SetBarrierDestroyed);
- ADD_OPCODE(_unk18_PLAY_SND);
+ ADD_OPCODE(JumpIfSoundPlayingAndPlaySound);
ADD_OPCODE(JumpIfActionFind);
ADD_OPCODE(SetActionFind);
- ADD_OPCODE(clearActionFind);
+ ADD_OPCODE(ClearActionFind);
ADD_OPCODE(JumpIfActionGrab);
ADD_OPCODE(SetActionGrab);
ADD_OPCODE(ClearActionGrab);
@@ -71,9 +78,9 @@ ActionList::ActionList(Common::SeekableReadStream *stream, Scene *scene) : _scen
ADD_OPCODE(_unk23);
ADD_OPCODE(_unk24);
ADD_OPCODE(RunEncounter);
- ADD_OPCODE(JumpIfFlag2Bit4);
- ADD_OPCODE(SetFlag2Bit4);
- ADD_OPCODE(ClearFlag2Bit4);
+ ADD_OPCODE(JumpIfAction16);
+ ADD_OPCODE(SetAction16);
+ ADD_OPCODE(ClearAction16);
ADD_OPCODE(SetActorField638);
ADD_OPCODE(JumpIfActorField638);
ADD_OPCODE(ChangeScene);
@@ -89,17 +96,17 @@ ActionList::ActionList(Common::SeekableReadStream *stream, Scene *scene) : _scen
ADD_OPCODE(SetVolume);
ADD_OPCODE(Jump);
ADD_OPCODE(RunBlowUpPuzzle);
- ADD_OPCODE(JumpIfFlag2Bit3);
- ADD_OPCODE(SetFlag2Bit3);
- ADD_OPCODE(ClearFlag2Bit3);
+ ADD_OPCODE(JumpIfAction8);
+ ADD_OPCODE(SetAction8);
+ ADD_OPCODE(ClearAction8);
ADD_OPCODE(_unk3B_PALETTE_MOD);
ADD_OPCODE(IncrementParam2);
ADD_OPCODE(WaitUntilFramePlayed);
ADD_OPCODE(UpdateWideScreen);
ADD_OPCODE(JumpIfActor);
- ADD_OPCODE(_unk40_SOUND);
+ ADD_OPCODE(PlaySpeechScene);
ADD_OPCODE(PlaySpeech);
- ADD_OPCODE(_unk42);
+ ADD_OPCODE(PlaySpeechScene2);
ADD_OPCODE(MoveScenePositionFromActor);
ADD_OPCODE(PaletteFade);
ADD_OPCODE(StartPaletteFadeThread);
@@ -111,7 +118,7 @@ ActionList::ActionList(Common::SeekableReadStream *stream, Scene *scene) : _scen
ADD_OPCODE(ChangePlayerActorIndex);
ADD_OPCODE(ChangeActorStatus);
ADD_OPCODE(StopSound);
- ADD_OPCODE(_unk4E_RANDOM_COMMAND);
+ ADD_OPCODE(JumpRandom);
ADD_OPCODE(ClearScreen);
ADD_OPCODE(Quit);
ADD_OPCODE(JumpBarrierFrame);
@@ -127,11 +134,11 @@ ActionList::ActionList(Common::SeekableReadStream *stream, Scene *scene) : _scen
ADD_OPCODE(_unk5B);
ADD_OPCODE(QueueScript);
ADD_OPCODE(_unk5D);
- ADD_OPCODE(ClearActorField970);
+ ADD_OPCODE(ClearActorFields);
ADD_OPCODE(SetBarrierLastFrameIdx);
ADD_OPCODE(_unk60_SET_OR_CLR_ACTIONAREA_FLAG);
ADD_OPCODE(_unk61);
- ADD_OPCODE(_unk62_SHOW_OPTIONS_SCREEN);
+ ADD_OPCODE(ShowOptionsScreen);
ADD_OPCODE(_unk63);
// Reset script queue
@@ -270,7 +277,6 @@ void ActionList::load(Common::SeekableReadStream *stream) {
}
}
-
//////////////////////////////////////////////////////////////////////////
// Opcode Functions
//////////////////////////////////////////////////////////////////////////
@@ -319,13 +325,7 @@ IMPLEMENT_OPCODE(JumpIfGameFlag) {
if (!doJump)
return;
- int32 nextOpcode = _currentScript->commands[_currentLine].opcode;
- if (nextOpcode != 0x10 && nextOpcode != 0) {
- error("Incomplete opcode %s (0x%02X) in Scene %d Line %d", _opcodes[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
- return;
- }
-
- _currentLine = cmd->param3;
+ setNextLine(cmd->param3);
}
//////////////////////////////////////////////////////////////////////////
@@ -518,8 +518,8 @@ IMPLEMENT_OPCODE(DestroyBarrier) {
//////////////////////////////////////////////////////////////////////////
// Opcode 0x12
-IMPLEMENT_OPCODE(_unk12_JMP_WALK_ACTOR) {
- Actor *actor = _scene->getActor();
+IMPLEMENT_OPCODE(JumpActorSpeech) {
+ Actor *actor = _scene->getActor(cmd->param1);
if (actor->process(cmd->param2, cmd->param3))
return;
@@ -527,13 +527,13 @@ IMPLEMENT_OPCODE(_unk12_JMP_WALK_ACTOR) {
_currentLine = cmd->param4;
if (cmd->param5)
- actor->speech(1);
+ _scene->playSpeech(1);
}
//////////////////////////////////////////////////////////////////////////
// Opcode 0x13
-IMPLEMENT_OPCODE(_unk13_JMP_WALK_ACTOR) {
- Actor *actor = _scene->getActor();
+IMPLEMENT_OPCODE(JumpAndSetDirection) {
+ Actor *actor = _scene->getActor(cmd->param1);
if (actor->status != kActorStatus2 && actor->status != kActorStatus13) {
if (cmd->param5 != 2) {
@@ -566,7 +566,7 @@ IMPLEMENT_OPCODE(_unk13_JMP_WALK_ACTOR) {
//////////////////////////////////////////////////////////////////////////
// Opcode 0x14
IMPLEMENT_OPCODE(JumpIfActorCoordinates) {
- Actor *actor = _scene->getActor();
+ Actor *actor = _scene->getActor(cmd->param1);
if ((actor->x1 + actor->x2) != cmd->param2 || (actor->y1 + actor->y2) != cmd->param3)
_lineIncrement = cmd->param4;
@@ -574,8 +574,8 @@ IMPLEMENT_OPCODE(JumpIfActorCoordinates) {
//////////////////////////////////////////////////////////////////////////
// Opcode 0x15
-IMPLEMENT_OPCODE(_unk15) {
- error("Unhandled opcode %s (0x%02X) in Scene %d Line %d", _opcodes[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
+IMPLEMENT_OPCODE(Nop) {
+ // Nothing to do
}
//////////////////////////////////////////////////////////////////////////
@@ -599,8 +599,21 @@ IMPLEMENT_OPCODE(SetBarrierDestroyed) {
//////////////////////////////////////////////////////////////////////////
// Opcode 0x18
-IMPLEMENT_OPCODE(_unk18_PLAY_SND) {
- error("Unhandled opcode %s (0x%02X) in Scene %d Line %d", _opcodes[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
+IMPLEMENT_OPCODE(JumpIfSoundPlayingAndPlaySound) {
+ if (cmd->param2 == 2) {
+ if (_scene->vm()->sound()->isPlaying(cmd->param1))
+ _lineIncrement = 1;
+ else
+ cmd->param2 = 1;
+ } else if (!_scene->vm()->sound()->isPlaying(cmd->param1)) {
+ int32 vol = _scene->vm()->sound()->getAdjustedVolume(abs(Config.sfxVolume));
+ _scene->vm()->sound()->playSound(cmd->param1, cmd->param4, -((abs(cmd->param3) + vol) * (abs(cmd->param3) + vol)), 0);
+
+ if (cmd->param2 == 1) {
+ cmd->param2 = 2;
+ _lineIncrement= 1;
+ }
+ }
}
//////////////////////////////////////////////////////////////////////////
@@ -617,7 +630,7 @@ IMPLEMENT_OPCODE(SetActionFind) {
//////////////////////////////////////////////////////////////////////////
// Opcode 0x1B
-IMPLEMENT_OPCODE(clearActionFind) {
+IMPLEMENT_OPCODE(ClearActionFind) {
clearActionFlag(cmd, kActionTypeFind);
}
@@ -660,89 +673,231 @@ IMPLEMENT_OPCODE(ClearActionTalk) {
//////////////////////////////////////////////////////////////////////////
// Opcode 0x22
IMPLEMENT_OPCODE(_unk22) {
- error("Unhandled opcode %s (0x%02X) in Scene %d Line %d", _opcodes[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
+ Actor *actor = _scene->getActor(cmd->param3 ? cmd->param3 : _currentQueueEntry.actorIndex);
+
+ actor->process_41BC00(cmd->param1, cmd->param2);
}
//////////////////////////////////////////////////////////////////////////
// Opcode 0x23
IMPLEMENT_OPCODE(_unk23) {
- error("Unhandled opcode %s (0x%02X) in Scene %d Line %d", _opcodes[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
+ Actor *actor = _scene->getActor(cmd->param3 ? cmd->param3 : _currentQueueEntry.actorIndex);
+
+ actor->process_41BCC0(cmd->param1, cmd->param2);
}
//////////////////////////////////////////////////////////////////////////
// Opcode 0x24
IMPLEMENT_OPCODE(_unk24) {
- error("Unhandled opcode %s (0x%02X) in Scene %d Line %d", _opcodes[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
+ Actor *actor = _scene->getActor(cmd->param4 ? cmd->param4 : _currentQueueEntry.actorIndex);
+
+ actor->process_41BDB0(cmd->param1, cmd->param3);
}
//////////////////////////////////////////////////////////////////////////
// Opcode 0x25
IMPLEMENT_OPCODE(RunEncounter) {
- error("Unhandled opcode %s (0x%02X) in Scene %d Line %d", _opcodes[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
+ Encounter *encounter = _scene->vm()->encouter();
+
+ encounter->setFlag(kEncounterFlag5, cmd->param5);
+
+ if (cmd->param6) {
+ if (encounter->getFlag(kEncounterFlag2))
+ _lineIncrement = 1;
+ else
+ cmd->param6 = 0;
+ } else {
+ encounter->run(cmd->param1, cmd->param2, cmd->param3, cmd->param4);
+
+ cmd->param6 = 2;
+ _lineIncrement = 1;
+ }
}
//////////////////////////////////////////////////////////////////////////
// Opcode 0x26
-IMPLEMENT_OPCODE(JumpIfFlag2Bit4) {
- error("Unhandled opcode %s (0x%02X) in Scene %d Line %d", _opcodes[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
+IMPLEMENT_OPCODE(JumpIfAction16) {
+ jumpIfActionFlag(cmd, kActionType16);
}
//////////////////////////////////////////////////////////////////////////
// Opcode 0x27
-IMPLEMENT_OPCODE(SetFlag2Bit4) {
- error("Unhandled opcode %s (0x%02X) in Scene %d Line %d", _opcodes[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
+IMPLEMENT_OPCODE(SetAction16) {
+ setActionFlag(cmd, kActionType16);
}
//////////////////////////////////////////////////////////////////////////
// Opcode 0x28
-IMPLEMENT_OPCODE(ClearFlag2Bit4) {
- error("Unhandled opcode %s (0x%02X) in Scene %d Line %d", _opcodes[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
+IMPLEMENT_OPCODE(ClearAction16) {
+ clearActionFlag(cmd, kActionType16);
}
//////////////////////////////////////////////////////////////////////////
// Opcode 0x29
IMPLEMENT_OPCODE(SetActorField638) {
- error("Unhandled opcode %s (0x%02X) in Scene %d Line %d", _opcodes[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
+ Actor *actor = _scene->getActor(cmd->param1);
+
+ actor->field_638 = cmd->param2;
}
//////////////////////////////////////////////////////////////////////////
// Opcode 0x2A
IMPLEMENT_OPCODE(JumpIfActorField638) {
- error("Unhandled opcode %s (0x%02X) in Scene %d Line %d", _opcodes[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
+ Actor *actor = _scene->getActor(cmd->param1);
+
+ if (actor->field_638)
+ _currentLine = cmd->param3;
}
//////////////////////////////////////////////////////////////////////////
// Opcode 0x2B
IMPLEMENT_OPCODE(ChangeScene) {
- debug(kDebugLevelScripts, "Queueing Scene Change to scene %d...", _delayedSceneIndex);
+ _scene->getActor(0)->updateStatus(kActorStatusDisabled);
+ resetQueue();
+
+ // Fade screen to black
+ _scene->vm()->screen()->paletteFade(0, 75, 8);
+ _scene->vm()->screen()->clearScreen();
- error("Unhandled opcode %s (0x%02X) in Scene %d Line %d", _opcodes[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
+ // Stop all sounds & music
+ _scene->vm()->sound()->stopAllSounds(true);
+ // Change the scene number
_delayedSceneIndex = cmd->param1 + 4;
+
+ _exit = true;
}
//////////////////////////////////////////////////////////////////////////
// Opcode 0x2C
IMPLEMENT_OPCODE(_unk2C_ActorSub) {
- error("Unhandled opcode %s (0x%02X) in Scene %d Line %d", _opcodes[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
+ Actor *player = _scene->getActor(kActorPlayer);
+ Actor *actor = _scene->getActor(_currentQueueEntry.actorIndex);
+ Common::Point playerPoint(player->x1 + player->x2, player->y1 + player->y2);
+ ActorDirection direction = (cmd->param2 == 8) ? player->direction : cmd->param2;
+
+ if (cmd->param2 == 8)
+ cmd->param2 = player->direction;
+
+ if (cmd->param3 == 2) {
+ switch (actor->status) {
+ default:
+ _lineIncrement = 1;
+ return;
+
+ case kActorStatus7:
+ actor->updateStatus(kActorStatusEnabled);
+ break;
+
+ case kActorStatus16:
+ // We want to continue processing and not go into the default case
+ break;
+
+ case kActorStatus20:
+ actor->updateStatus(kActorStatus14);
+ }
+
+ cmd->param3 = 0;
+
+ if (cmd->param1 == 2) {
+ Common::Point point(playerPoint);
+
+ if (player->process_408B20(&point, (player->direction + 4) % 8, 3, false)) {
+
+ point.x += 3 * deltaPointsArray[(player->direction + 4) % 8].x;
+ point.x += 3 * deltaPointsArray[(player->direction + 4) % 8].y;
+
+ player->setPosition(point.x, point.y, actor->direction, 0);
+ }
+ }
+
+ } else if (cmd->param1 != 2 || player->process_408B20(&playerPoint, (player->direction + 4) % 8, 3, false)) {
+ ResourceId id = 0;
+ if (direction >= 5)
+ id = actor->graphicResourceIds[5 * cmd->param1 - direction + 38];
+ else
+ id = actor->graphicResourceIds[5 * cmd->param1 + direction + 30];
+
+ GraphicResource *res = new GraphicResource(_scene->getResourcePack(), id);
+ actor->graphicResourceId = id;
+ actor->frameCount = res->getFrameCount();
+ actor->frameNum = 0;
+ actor->direction = direction;
+ actor->updateStatus(actor->status <= kActorStatus11 ? kActorStatus3 : kActorStatus19);
+ delete res;
+
+ cmd->param3 = 2;
+ _lineIncrement = 1;
+ }
}
//////////////////////////////////////////////////////////////////////////
// Opcode 0x2D
IMPLEMENT_OPCODE(PlayMovie) {
- // TODO: add missing code here
- _delayedVideoIndex = cmd->param1;
+ if (_scene->matteBarHeight < 170) {
+ _lineIncrement = 1;
+
+ if (!_scene->matteBarHeight) {
+ _scene->getCursor()->hide();
+ _scene->makeGreyPalette();
+ _scene->matteVar1 = 1;
+ _scene->matteBarHeight = 1;
+ _scene->matteVar2 = 0;
+ _scene->mattePlaySound = (cmd->param3 == 0);
+ _scene->matteInitialized = (cmd->param2 == 0);
+ _delayedVideoIndex = cmd->param1;
+ }
+
+ return;
+ }
+
+ bool check = false;
+ ActionArea *area = _scene->worldstats()->actions[_scene->getActor()->actionIdx3];
+ if (area->paletteValue) {
+ _scene->vm()->screen()->setPalette(_scene->getResourcePack(), area->paletteValue);
+ _scene->vm()->screen()->setGammaLevel(_scene->getResourcePack(), area->paletteValue, 0);
+ } else {
+ _scene->vm()->screen()->setPalette(_scene->getResourcePack(), _scene->worldstats()->currentPaletteId);
+ _scene->vm()->screen()->setGammaLevel(_scene->getResourcePack(), _scene->worldstats()->currentPaletteId, 0);
+ }
+
+ _scene->matteBarHeight = 0;
+ _lineIncrement = 0;
+
+ if (!_scene->mattePlaySound && _currentScript->commands[0].numLines != 0) {
+ bool found = true;
+ int index = 0;
- error("Incomplete opcode %s (0x%02X) in Scene %d Line %d", _opcodes[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
+
+ while (_currentScript->commands[index].opcode != 0x2B) { // ChangeScene
+ ++index;
+
+ if (index >= _currentScript->commands[0].numLines) {
+ found = false;
+ break;
+ }
+ }
+
+ if (found)
+ check = true;
+ }
+
+ if (!check && _scene->matteVar2 == 0 && _scene->worldstats()->musicCurrentResourceId != kResourceMusic_FFFFFD66)
+ if (_scene->vm()->sound()->isCacheOk())
+ _scene->vm()->sound()->playMusic(_scene->getResourcePack(), _scene->worldstats()->musicCurrentResourceId + kResourceMusic_80020000);
+
+ _scene->getCursor()->show();
+ _scene->matteVar2 = 0;
}
//////////////////////////////////////////////////////////////////////////
// Opcode 0x2E
IMPLEMENT_OPCODE(StopAllBarriersSounds) {
- // TODO: do this for all barriers that have sfx playing
- _scene->vm()->sound()->stopAllSounds();
+ Barrier *barrier = _scene->worldstats()->getBarrierById(cmd->param1);
- error("Incomplete opcode %s (0x%02X) in Scene %d Line %d", _opcodes[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
+ for (int i = 0; i < ARRAYSIZE(barrier->soundItems); i++)
+ if (barrier->soundItems[i].resourceId)
+ _scene->vm()->sound()->stopSound(barrier->soundItems[i].resourceId);
}
//////////////////////////////////////////////////////////////////////////
@@ -761,7 +916,7 @@ IMPLEMENT_OPCODE(ResumeProcessing) {
// Opcode 0x31
IMPLEMENT_OPCODE(ResetSceneRect) {
_scene->worldstats()->sceneRectIdx = LOBYTE(cmd->param1);
- _scene->vm()->screen()->palFade(0, 25, 10);
+ _scene->vm()->screen()->paletteFade(0, 25, 10);
_scene->vm()->setFlag(kFlagTypeSceneRectChanged);
_scene->worldstats()->xLeft = _scene->worldstats()->sceneRects[_scene->worldstats()->sceneRectIdx].left;
@@ -771,13 +926,13 @@ IMPLEMENT_OPCODE(ResetSceneRect) {
//////////////////////////////////////////////////////////////////////////
// Opcode 0x32
IMPLEMENT_OPCODE(ChangeMusicById) {
- error("Unhandled opcode %s (0x%02X) in Scene %d Line %d", _opcodes[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
+ _scene->vm()->sound()->changeMusic(_scene->getResourcePack(), cmd->param1, cmd->param2 ? 2 : 1);
}
//////////////////////////////////////////////////////////////////////////
// Opcode 0x33
IMPLEMENT_OPCODE(StopMusic) {
- _scene->vm()->sound()->stopMusic();
+ _scene->vm()->sound()->changeMusic(_scene->getResourcePack(), kResourceMusic_FFFFFD66, 0);
}
//////////////////////////////////////////////////////////////////////////
@@ -819,9 +974,10 @@ IMPLEMENT_OPCODE(Jump) {
// Opcode 0x37
IMPLEMENT_OPCODE(RunBlowUpPuzzle) {
_scene->vm()->screen()->clearScreen();
- error("Incomplete opcode %s (0x%02X) in Scene %d Line %d", _opcodes[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
- //_scene->vm()->screen()->clearDrawStruct(4096, 2049, &drawStruct);
- //_scene->vm()->switchMessageHandler(_scene->vm()->getMessageHandler(cmd->param1));
+ _scene->vm()->screen()->clearGraphicsInQueue();
+
+ _scene->vm()->switchMessageHandler(_scene->vm()->getMessageHandler(cmd->param1));
+
_currentLine++;
_exit = true;
@@ -829,26 +985,47 @@ IMPLEMENT_OPCODE(RunBlowUpPuzzle) {
//////////////////////////////////////////////////////////////////////////
// Opcode 0x38
-IMPLEMENT_OPCODE(JumpIfFlag2Bit3) {
- error("Unhandled opcode %s (0x%02X) in Scene %d Line %d", _opcodes[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
+IMPLEMENT_OPCODE(JumpIfAction8) {
+ jumpIfActionFlag(cmd, kActionType8);
}
//////////////////////////////////////////////////////////////////////////
// Opcode 0x39
-IMPLEMENT_OPCODE(SetFlag2Bit3) {
- error("Unhandled opcode %s (0x%02X) in Scene %d Line %d", _opcodes[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
+IMPLEMENT_OPCODE(SetAction8) {
+ setActionFlag(cmd, kActionType8);
}
//////////////////////////////////////////////////////////////////////////
// Opcode 0x3A
-IMPLEMENT_OPCODE(ClearFlag2Bit3) {
- error("Unhandled opcode %s (0x%02X) in Scene %d Line %d", _opcodes[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
+IMPLEMENT_OPCODE(ClearAction8) {
+ clearActionFlag(cmd, kActionType8);
}
//////////////////////////////////////////////////////////////////////////
// Opcode 0x3B
IMPLEMENT_OPCODE(_unk3B_PALETTE_MOD) {
- error("Unhandled opcode %s (0x%02X) in Scene %d Line %d", _opcodes[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
+ if (!cmd->param2) {
+ _scene->makeGreyPalette();
+ cmd->param2 = 1;
+ }
+
+ if (cmd->param1 >= 22) {
+ _scene->vm()->screen()->clearScreen();
+
+ cmd->param1 = 0;
+ cmd->param2 = 0;
+ _currentLine++;
+
+ _scene->vm()->screen()->clearGraphicsInQueue();
+
+ _exit = true;
+ return;
+ }
+
+ _scene->updatePalette(cmd->param1);
+
+ _lineIncrement = 1;
+ ++cmd->param1;
}
//////////////////////////////////////////////////////////////////////////
@@ -858,7 +1035,7 @@ IMPLEMENT_OPCODE(IncrementParam2) {
if (cmd->param2 >= cmd->param1) {
cmd->param2 = 0;
} else {
- cmd->param2++;
+ ++cmd->param2;
_lineIncrement = 1;
}
}
@@ -869,11 +1046,8 @@ IMPLEMENT_OPCODE(IncrementParam2) {
IMPLEMENT_OPCODE(WaitUntilFramePlayed) {
Barrier *barrier = _scene->worldstats()->getBarrierById(cmd->param1);
- if (!barrier)
- error("ActionList::WaitUntilFramePlayed: Requested invalid object ID:0x%02X in Scene %d Line %d.", cmd->param1, _scene->getSceneIndex(),_currentLine);
-
uint32 frameNum = cmd->param2;
- if (cmd->param2 == -1)
+ if (frameNum == -1)
frameNum = barrier->frameCount - 1;
if (barrier->frameIdx != frameNum) {
@@ -890,9 +1064,14 @@ IMPLEMENT_OPCODE(UpdateWideScreen) {
if (barSize >= 22) {
cmd->param1 = 0;
+ _lineIncrement = 0;
+
+ _scene->matteBarHeight = 0;
} else {
_scene->vm()->screen()->drawWideScreen(4 * barSize);
- cmd->param1++;
+
+ _lineIncrement = 1;
+ ++cmd->param1;
}
}
@@ -908,8 +1087,54 @@ IMPLEMENT_OPCODE(JumpIfActor) {
//////////////////////////////////////////////////////////////////////////
// Opcode 0x40
-IMPLEMENT_OPCODE(_unk40_SOUND) {
- error("Unhandled opcode %s (0x%02X) in Scene %d Line %d", _opcodes[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
+IMPLEMENT_OPCODE(PlaySpeechScene) {
+ if (cmd->param1 < 0 || cmd->param1 >= 5)
+ return;
+
+ if (cmd->param4 != 2) {
+ cmd->param5 = _scene->playSpeech(cmd->param1);
+
+ if (cmd->param2) {
+ _scene->vm()->setGameFlag(kGameFlagScriptProcessing);
+ cmd->param4 = 2;
+ if (cmd->param6) {
+ _scene->vm()->setFlag(kFlagType1);
+ _scene->vm()->setFlag(kFlagType2);
+ }
+ _lineIncrement = 1;
+ }
+
+ if (cmd->param3 && !cmd->param6)
+ _scene->vm()->setGameFlag(kGameFlag219);
+
+ return;
+ }
+
+ if (_scene->vm()->sound()->isPlaying((ResourceId)cmd->param5)) {
+ _lineIncrement = 1;
+ return;
+ }
+
+ _scene->vm()->clearGameFlag(kGameFlagScriptProcessing);
+ cmd->param4 = 0;
+
+ if (cmd->param3) {
+ if (cmd->param6) {
+ _scene->vm()->clearFlag(kFlagType1);
+ _scene->vm()->clearFlag(kFlagType2);
+
+ return;
+ } else {
+ _scene->vm()->clearGameFlag(kGameFlag219);
+ }
+ }
+
+ if (!cmd->param6) {
+ cmd->param6 = 1;
+ } else {
+ _scene->vm()->clearFlag(kFlagType1);
+ _scene->vm()->clearFlag(kFlagType2);
+ }
}
//////////////////////////////////////////////////////////////////////////
@@ -933,10 +1158,14 @@ IMPLEMENT_OPCODE(PlaySpeech) {
if (cmd->param3 && !cmd->param6)
_scene->vm()->setGameFlag(kGameFlag219);
+
+ return;
}
- if (_scene->vm()->sound()->isPlaying((ResourceId)cmd->param5))
+ if (_scene->vm()->sound()->isPlaying((ResourceId)cmd->param5)) {
_lineIncrement = 1;
+ return;
+ }
_scene->vm()->clearGameFlag(kGameFlagScriptProcessing);
cmd->param4 = 0;
@@ -945,6 +1174,8 @@ IMPLEMENT_OPCODE(PlaySpeech) {
if (cmd->param6) {
_scene->vm()->clearFlag(kFlagType1);
_scene->vm()->clearFlag(kFlagType2);
+
+ return;
} else {
_scene->vm()->clearGameFlag(kGameFlag219);
}
@@ -960,14 +1191,59 @@ IMPLEMENT_OPCODE(PlaySpeech) {
//////////////////////////////////////////////////////////////////////////
// Opcode 0x42
-IMPLEMENT_OPCODE(_unk42) {
- error("Unhandled opcode %s (0x%02X) in Scene %d Line %d", _opcodes[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
+IMPLEMENT_OPCODE(PlaySpeechScene2) {
+ if (cmd->param1 < 0 || cmd->param1 >= 20 || cmd->param2 < 0)
+ return;
+
+ if (cmd->param5 == 2) {
+ if (_scene->vm()->sound()->isPlaying(cmd->param6)) {
+ _lineIncrement = 1;
+ return;
+ }
+
+ _scene->vm()->clearGameFlag(kGameFlagScriptProcessing);
+
+ cmd->param5 = 0;
+
+ if (!cmd->param4) {
+ if (!cmd->param7) {
+ cmd->param7 = 1;
+ return;
+ }
+ } if (!cmd->param7) {
+ _scene->vm()->clearGameFlag(kGameFlag219);
+ cmd->param7 = 1;
+ return;
+ }
+
+ _scene->vm()->clearFlag(kFlagType1);
+ _scene->vm()->clearFlag(kFlagType2);
+ return;
+ }
+
+ cmd->param6 = _scene->playSpeech(cmd->param1, cmd->param2);
+
+ if (cmd->param3) {
+ _scene->vm()->setGameFlag(kGameFlagScriptProcessing);
+
+ cmd->param5 = 2;
+
+ if (cmd->param7) {
+ _scene->vm()->clearFlag(kFlagType1);
+ _scene->vm()->clearFlag(kFlagType2);
+ }
+
+ _lineIncrement = 1;
+ }
+
+ if (cmd->param4 && !cmd->param7)
+ _scene->vm()->setGameFlag(kGameFlag219);
}
//////////////////////////////////////////////////////////////////////////
// Opcode 0x43
IMPLEMENT_OPCODE(MoveScenePositionFromActor) {
- Actor *actor = _scene->getActor();
+ Actor *actor = _scene->getActor(cmd->param1);
if (!cmd->param3) {
_scene->worldstats()->motionStatus = 5;
@@ -1000,49 +1276,115 @@ IMPLEMENT_OPCODE(MoveScenePositionFromActor) {
//////////////////////////////////////////////////////////////////////////
// Opcode 0x44
IMPLEMENT_OPCODE(PaletteFade) {
- error("Unhandled opcode %s (0x%02X) in Scene %d Line %d", _opcodes[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
+ _scene->vm()->screen()->paletteFade(0, cmd->param1, cmd->param2);
}
//////////////////////////////////////////////////////////////////////////
// Opcode 0x45
IMPLEMENT_OPCODE(StartPaletteFadeThread) {
- error("Unhandled opcode %s (0x%02X) in Scene %d Line %d", _opcodes[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
+ _scene->vm()->screen()->startPaletteFade(_scene->worldstats()->currentPaletteId, cmd->param1, cmd->param2);
}
//////////////////////////////////////////////////////////////////////////
// Opcode 0x46
IMPLEMENT_OPCODE(_unk46) {
- error("Unhandled opcode %s (0x%02X) in Scene %d Line %d", _opcodes[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
+ if (cmd->param6) {
+ if (_scene->vm()->sound()->isPlaying(_scene->vm()->sound()->soundResourceId)) {
+ _lineIncrement = 1;
+ } else {
+ cmd->param6 = 0;
+ if (cmd->param5) {
+ _scene->getActor(cmd->param5)->updateStatus(kActorStatusEnabled);
+ } else if (cmd->param4 != cmd->param3 && cmd->param4) {
+ _scene->worldstats()->getBarrierById(cmd->param3)->destroy();
+ _scene->worldstats()->getBarrierById(cmd->param4)->setNextFrame(_scene->worldstats()->getBarrierById(cmd->param4)->flags);
+ }
+
+ _scene->vm()->clearGameFlag(kGameFlagScriptProcessing);
+
+ _scene->vm()->sound()->soundResourceId = 0;
+ _scene->vm()->sound()->speechTextResourceId = 0;
+ }
+ } else {
+ _scene->vm()->setGameFlag(kGameFlagScriptProcessing);
+ _scene->vm()->sound()->setSpeech(cmd->param1 + kResourceSound_80030203, cmd->param1 + kResourceSpeech_8000050A);
+
+ if (cmd->param2) {
+ _scene->getActor(cmd->param5)->updateStatus(kActorStatus8);
+ cmd->param6 = 1;
+ _lineIncrement = 1;
+ } else {
+ if (cmd->param4 != cmd->param3) {
+ if (cmd->param4)
+ _scene->worldstats()->getBarrierById(cmd->param4)->destroy();
+
+ if (cmd->param3)
+ _scene->worldstats()->getBarrierById(cmd->param3)->setNextFrame(_scene->worldstats()->getBarrierById(cmd->param4)->flags);
+ }
+
+ cmd->param6 = 1;
+ _lineIncrement = 1;
+ }
+ }
}
//////////////////////////////////////////////////////////////////////////
// Opcode 0x47
IMPLEMENT_OPCODE(ActorFaceObject) {
- // XXX
- // Dropping param1, since it's the character index
- // Investigate further if/when we have a scene with
- // multiple characters in the actor[] array
- _scene->getActor()->faceTarget(cmd->param2, cmd->param3);
-
- error("Incomplete opcode %s (0x%02X) in Scene %d Line %d", _opcodes[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
+ _scene->getActor(cmd->param1)->faceTarget(cmd->param2, (DirectionFrom)cmd->param3);
}
//////////////////////////////////////////////////////////////////////////
// Opcode 0x48
IMPLEMENT_OPCODE(_unk48_MATTE_01) {
- error("Unhandled opcode %s (0x%02X) in Scene %d Line %d", _opcodes[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
+ _scene->matteVar1 = 0;
+ _scene->matteInitialized = true;
+
+ if (_scene->matteBarHeight >= 170) {
+ _scene->matteBarHeight = 0;
+ _lineIncrement = 0;
+ _scene->getCursor()->show();
+ } else {
+ _lineIncrement = 1;
+
+ if (!_scene->matteBarHeight) {
+ _scene->getCursor()->hide();
+ _scene->matteBarHeight = 1;
+ }
+ }
}
//////////////////////////////////////////////////////////////////////////
// Opcode 0x49
IMPLEMENT_OPCODE(_unk49_MATTE_90) {
- error("Unhandled opcode %s (0x%02X) in Scene %d Line %d", _opcodes[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
+ _scene->matteVar1 = 0;
+ _scene->matteInitialized = true;
+ _scene->mattePlaySound = true;
+
+ if (_scene->matteBarHeight >= 170) {
+ _scene->matteBarHeight = 0;
+ _lineIncrement = 0;
+ _scene->getCursor()->show();
+ } else {
+ _lineIncrement = 1;
+
+ if (!_scene->matteBarHeight) {
+ _scene->getCursor()->hide();
+ _scene->matteBarHeight = 90;
+ }
+ }
}
//////////////////////////////////////////////////////////////////////////
// Opcode 0x4A
IMPLEMENT_OPCODE(JumpIfSoundPlaying) {
- error("Unhandled opcode %s (0x%02X) in Scene %d Line %d", _opcodes[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
+ if (cmd->param3 == 1) {
+ if (_scene->vm()->sound()->isPlaying(cmd->param1)) {
+ _currentLine = cmd->param2;
+ }
+ } else if (!_scene->vm()->sound()->isPlaying(cmd->param1)) {
+ _currentLine = cmd->param2;
+ }
}
//////////////////////////////////////////////////////////////////////////
@@ -1067,14 +1409,17 @@ IMPLEMENT_OPCODE(ChangeActorStatus) {
//////////////////////////////////////////////////////////////////////////
// Opcode 0x4D
IMPLEMENT_OPCODE(StopSound) {
- if (_scene->vm()->sound()->isPlaying((ResourceId)cmd->param1))
- _scene->vm()->sound()->stopSound((ResourceId)cmd->param1);
+ if (_scene->vm()->sound()->isPlaying(cmd->param1))
+ _scene->vm()->sound()->stopSound(cmd->param1);
}
//////////////////////////////////////////////////////////////////////////
// Opcode 0x4E
-IMPLEMENT_OPCODE(_unk4E_RANDOM_COMMAND) {
- error("Unhandled opcode %s (0x%02X) in Scene %d Line %d", _opcodes[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
+IMPLEMENT_OPCODE(JumpRandom) {
+ if (_scene->vm()->getRandom(cmd->param1) < (uint32)cmd->param2)
+ return;
+
+ setNextLine(cmd->param3);
}
//////////////////////////////////////////////////////////////////////////
@@ -1091,37 +1436,41 @@ IMPLEMENT_OPCODE(ClearScreen) {
//////////////////////////////////////////////////////////////////////////
// Opcode 0x50
IMPLEMENT_OPCODE(Quit) {
- error("Unhandled opcode %s (0x%02X) in Scene %d Line %d", _opcodes[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
+ _scene->vm()->screen()->clearScreen();
+ _scene->vm()->quitGame();
+
+ // We need to exit the interpreter loop so we get back to the event loop and get the quit message
+ _exit = true;
}
//////////////////////////////////////////////////////////////////////////
// Opcode 0x51
IMPLEMENT_OPCODE(JumpBarrierFrame) {
Barrier *barrier = _scene->worldstats()->getBarrierById(cmd->param1);
- int idx = (int)barrier->frameIdx;
if (cmd->param2 == -1)
cmd->param2 = barrier->frameCount - 1;
- if (cmd->param3 && cmd->param2 == idx) {
- //break;
- } else if (cmd->param4 && cmd->param2 < idx) {
- //break;
- } else if (cmd->param5 && cmd->param2 > idx) {
- //break;
- } else if (cmd->param6 && cmd->param2 <= idx) {
- //break;
- } else if (cmd->param7 && cmd->param2 >= idx) {
- //break;
- } else if (cmd->param8 && cmd->param2 != idx) {
- //break;
+ if (cmd->param3)
+ if(barrier->frameIdx == (uint32)cmd->param2) {
+ return;
+ } else if (cmd->param4)
+ if (barrier->frameIdx < (uint32)cmd->param2) {
+ return;
+ } else if (cmd->param5)
+ if (barrier->frameIdx > (uint32)cmd->param2) {
+ return;
+ } else if (cmd->param6)
+ if (barrier->frameIdx <= (uint32)cmd->param2) {
+ return;
+ } else if (cmd->param7)
+ if (barrier->frameIdx >= (uint32)cmd->param2) {
+ return;
+ } else if (!cmd->param8 || barrier->frameIdx != (uint32)cmd->param2) {
+ return;
}
- ScriptEntry *nextCmd = &_currentScript->commands[cmd->param9];
-
- // 0x10 == kReturn
- if (nextCmd->opcode != 0x10 && nextCmd->opcode)
- _done = true;
+ setNextLine(cmd->param9);
}
//////////////////////////////////////////////////////////////////////////
@@ -1151,32 +1500,33 @@ IMPLEMENT_OPCODE(_unk54_SET_ACTIONLIST_6EC) {
//////////////////////////////////////////////////////////////////////////
// Opcode 0x55
IMPLEMENT_OPCODE(_unk55) {
- // TODO
- /*
- if (!cmd->param2) {
- if (cmd->param3 && _currentScript->field_1BB0 < cmd->param1)
- //break;
- else if (cmd->param4 && _currentScript->field_1BB0 > cmd->param1)
- //break;
- else if (cmd->param5 && _currentScript->field_1BB0 <= cmd->param1)
- //break;
- else if (cmd->param6 && _currentScript->field_1BB0 >= cmd->param1)
- //break;
- else if (cmd->param7 && _currentScript->field_1BB0 != cmd->param1)
- //break;
- } else if(_currentScript->field_1BB0 == cmd->param1) {
- //break;
- }
- */
- ScriptEntry *nextCmd = &_currentScript->commands[cmd->param8];
+ if (cmd->param2) {
+ if (_currentScript->field_1BB0 == cmd->param1)
+ return;
+ } else {
- if (nextCmd->opcode != 0x10 && nextCmd->opcode)
- _done = true;
- else
- _lineIncrement = cmd->param8;
+ if (cmd->param3) {
+ if (_currentScript->field_1BB0 < cmd->param1)
+ return;
+ } else if (cmd->param4) {
+ if (_currentScript->field_1BB0 > cmd->param1)
+ return;
+ } else if (!cmd->param5) {
+ if (cmd->param6) {
+ if (_currentScript->field_1BB0 >= cmd->param1)
+ return;
+ } else {
+ if (!cmd->param7 || _currentScript->field_1BB0 != cmd->param1)
+ return;
+ }
+ } else {
+ if (_currentScript->field_1BB0 <= cmd->param1)
+ return;
+ }
+ }
- error("Incomplete opcode %s (0x%02X) in Scene %d Line %d", _opcodes[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
+ setNextLine(cmd->param8);
}
//////////////////////////////////////////////////////////////////////////
@@ -1196,24 +1546,37 @@ IMPLEMENT_OPCODE(_unk56) {
_lineIncrement = 0;
if ((actor->x1 + actor->x2 == cmd->param6) && (actor->y1 + actor->y2 == cmd->param7)) {
- actor->setDirectionFrom(cmd->param1, kDirectionFromActor);
- _scene->getActor(cmd->param1)->setDirection((actor->direction + 4) & 7);
+ _scene->getActor(kActorPlayer)->faceTarget(cmd->param1, kDirectionFromActor);
+ actor->setDirection((actor->direction + 4) & 7);
} else {
_currentLine = cmd->param3;
}
} else {
- error("Unhandled opcode %s (0x%02X) in Scene %d Line %d", _opcodes[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
+ int32 x = 0;
+ int32 y = 0; // FIXME: is is set somewhere else?
+
+ if (_scene->processActor(&x, &cmd->param4) == 1) {
+ _scene->getActor(kActorPlayer)->processStatus(x, y, cmd->param4);
+ cmd->param6 = x;
+ cmd->param7 = y;
+
+ if (cmd->param2 == 1) {
+ cmd->param2 = 2;
+ _lineIncrement = 1;
+ }
+ } else {
+ if (cmd->param4)
+ _scene->playSpeech(1);
+
+ _currentLine = cmd->param3;
+ }
}
}
//////////////////////////////////////////////////////////////////////////
// Opcode 0x57
IMPLEMENT_OPCODE(SetResourcePalette) {
- if (cmd->param1 < 0)
- error("Invalid resource id in opcode %s (0x%02X) in Scene %d Line %d", _opcodes[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
-
_scene->worldstats()->currentPaletteId = _scene->worldstats()->graphicResourceIds[cmd->param1];
-
_scene->vm()->screen()->setPalette(_scene->getResourcePack(), _scene->worldstats()->currentPaletteId);
_scene->vm()->screen()->setGammaLevel(_scene->getResourcePack(), _scene->worldstats()->currentPaletteId, 0);
}
@@ -1234,7 +1597,16 @@ IMPLEMENT_OPCODE(SetBarrierFrameIdxFlaged) {
//////////////////////////////////////////////////////////////////////////
// Opcode 0x59
IMPLEMENT_OPCODE(_unk59) {
- error("Unhandled opcode %s (0x%02X) in Scene %d Line %d", _opcodes[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
+ Barrier *barrier = _scene->worldstats()->getBarrierById(cmd->param1);
+
+ if (cmd->param2) {
+ barrier->flags |= kBarrierFlag40000;
+ } else {
+ barrier->flags &= ~kBarrierFlag10E38;
+ }
+
+ if (cmd->param3 && (barrier->flags & kBarrierFlag10E38))
+ _lineIncrement = 1;
}
//////////////////////////////////////////////////////////////////////////
@@ -1246,7 +1618,18 @@ IMPLEMENT_OPCODE(_unk5A) {
//////////////////////////////////////////////////////////////////////////
// Opcode 0x5B
IMPLEMENT_OPCODE(_unk5B) {
- error("Unhandled opcode %s (0x%02X) in Scene %d Line %d", _opcodes[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
+ if (cmd->param2 >= 0 && cmd->param2 <= 3) {
+ if (cmd->param1) {
+ Barrier *barrier = _scene->worldstats()->getBarrierById(cmd->param1);
+
+ barrier->field_67C = cmd->param2;
+
+ if (barrier->field_67C)
+ barrier->field_67C += 3;
+ } else {
+ _scene->getActor(cmd->param3)->field_96C = cmd->param2;
+ }
+ }
}
//////////////////////////////////////////////////////////////////////////
@@ -1258,16 +1641,18 @@ IMPLEMENT_OPCODE(QueueScript) {
//////////////////////////////////////////////////////////////////////////
// Opcode 0x5D
IMPLEMENT_OPCODE(_unk5D) {
+ Actor *actor = _scene->getActor(cmd->param1);
- error("Unhandled opcode %s (0x%02X) in Scene %d Line %d", _opcodes[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
+ actor->process_401830(cmd->param2, cmd->param3, cmd->param4, cmd->param5, cmd->param6, cmd->param7, cmd->param8, cmd->param9);
}
//////////////////////////////////////////////////////////////////////////
// Opcode 0x5E
-IMPLEMENT_OPCODE(ClearActorField970) {
- Actor *act = _scene->getActor(cmd->param1);
+IMPLEMENT_OPCODE(ClearActorFields) {
+ Actor *actor = _scene->getActor(cmd->param1);
- act->field_970 = 0;
+ // Clear fields starting from field_970
+ memset(&actor->field_970, 0, 52);
}
//////////////////////////////////////////////////////////////////////////
@@ -1286,7 +1671,12 @@ IMPLEMENT_OPCODE(SetBarrierLastFrameIdx) {
//////////////////////////////////////////////////////////////////////////
// Opcode 0x60
IMPLEMENT_OPCODE(_unk60_SET_OR_CLR_ACTIONAREA_FLAG) {
- error("Unhandled opcode %s (0x%02X) in Scene %d Line %d", _opcodes[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
+ ActionArea *area = _scene->worldstats()->getActionAreaById(cmd->param1);
+
+ if (cmd->param2)
+ area->flags |= 1;
+ else
+ area->flags &= ~1;
}
//////////////////////////////////////////////////////////////////////////
@@ -1295,29 +1685,37 @@ IMPLEMENT_OPCODE(_unk61) {
if (cmd->param2) {
if (_scene->worldstats()->field_E860C == -1) {
_lineIncrement = 0;
- cmd->param2 = 0;
+ cmd->param2 = 0;
} else {
_lineIncrement = 1;
}
} else {
- // TODO: do something for scene number 9
+ _scene->updatePlayerChapter9(cmd->param1);
cmd->param2 = 1;
_lineIncrement = 1;
}
-
- error("Incomplete opcode %s (0x%02X) in Scene %d Line %d", _opcodes[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
}
//////////////////////////////////////////////////////////////////////////
// Opcode 0x62
-IMPLEMENT_OPCODE(_unk62_SHOW_OPTIONS_SCREEN) {
- error("Unhandled opcode %s (0x%02X) in Scene %d Line %d", _opcodes[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
+IMPLEMENT_OPCODE(ShowOptionsScreen) {
+ _scene->vm()->menu()->showOptions();
}
//////////////////////////////////////////////////////////////////////////
// Opcode 0x63
IMPLEMENT_OPCODE(_unk63) {
- error("Unhandled opcode %s (0x%02X) in Scene %d Line %d", _opcodes[cmd->opcode]->name, cmd->opcode, _scene->getSceneIndex(), _currentLine);
+ if (cmd->param1) {
+ _scene->vm()->setFlag(kFlagType1);
+ _scene->vm()->setFlag(kFlagType2);
+ }
+
+ if (_scene->vm()->sound()->isPlaying(_scene->vm()->sound()->soundResourceId)) {
+ _lineIncrement = 1;
+ return;
+ } else if (!cmd->param1) {
+ cmd->param1 = 1;
+ }
}
//////////////////////////////////////////////////////////////////////////
@@ -1380,11 +1778,16 @@ void ActionList::jumpIfActionFlag(ScriptEntry *cmd, ActionType flag) {
if (!done)
return;
- int32 opcode = _currentScript->commands[cmd->param2].opcode;
+ setNextLine(cmd->param2);
+}
+
+void ActionList::setNextLine(int32 line) {
+ int32 opcode = _currentScript->commands[line].opcode;
if (opcode == 0x10 || opcode == 0) { // Return
- _currentLine = cmd->param2;
+ _currentLine = line;
} else {
_done = true;
}
}
+
} // end of namespace Asylum
diff --git a/engines/asylum/resources/actionlist.h b/engines/asylum/resources/actionlist.h
index f45d9c8823..4a5cbfd918 100644
--- a/engines/asylum/resources/actionlist.h
+++ b/engines/asylum/resources/actionlist.h
@@ -26,7 +26,7 @@
#ifndef ASYLUM_ACTIONLIST_H
#define ASYLUM_ACTIONLIST_H
-#include "asylum/views/scene.h"
+#include "asylum/resources/actor.h"
#include "common/array.h"
#include "common/func.h"
@@ -154,10 +154,12 @@ private:
*/
void resetQueue();
+ // Opcode helper functions
void enableBarrier(ScriptEntry *cmd, BarrierEnableType type);
void setActionFlag(ScriptEntry *cmd, ActionType flag); //|
void clearActionFlag(ScriptEntry *cmd, ActionType flag); //&
void jumpIfActionFlag(ScriptEntry *cmd, ActionType flag);
+ void setNextLine(int32 line);
//////////////////////////////////////////////////////////////////////////
// Opcode functions
@@ -178,16 +180,16 @@ private:
DECLARE_OPCODE(EnableActor);
DECLARE_OPCODE(EnableBarriers);
DECLARE_OPCODE(DestroyBarrier);
- DECLARE_OPCODE(_unk12_JMP_WALK_ACTOR);
- DECLARE_OPCODE(_unk13_JMP_WALK_ACTOR);
+ DECLARE_OPCODE(JumpActorSpeech);
+ DECLARE_OPCODE(JumpAndSetDirection);
DECLARE_OPCODE(JumpIfActorCoordinates);
- DECLARE_OPCODE(_unk15);
+ DECLARE_OPCODE(Nop);
DECLARE_OPCODE(ResetAnimation);
DECLARE_OPCODE(SetBarrierDestroyed);
- DECLARE_OPCODE(_unk18_PLAY_SND);
+ DECLARE_OPCODE(JumpIfSoundPlayingAndPlaySound);
DECLARE_OPCODE(JumpIfActionFind);
DECLARE_OPCODE(SetActionFind);
- DECLARE_OPCODE(clearActionFind);
+ DECLARE_OPCODE(ClearActionFind);
DECLARE_OPCODE(JumpIfActionGrab);
DECLARE_OPCODE(SetActionGrab);
DECLARE_OPCODE(ClearActionGrab);
@@ -198,9 +200,9 @@ private:
DECLARE_OPCODE(_unk23);
DECLARE_OPCODE(_unk24);
DECLARE_OPCODE(RunEncounter);
- DECLARE_OPCODE(JumpIfFlag2Bit4);
- DECLARE_OPCODE(SetFlag2Bit4);
- DECLARE_OPCODE(ClearFlag2Bit4);
+ DECLARE_OPCODE(JumpIfAction16);
+ DECLARE_OPCODE(SetAction16);
+ DECLARE_OPCODE(ClearAction16);
DECLARE_OPCODE(SetActorField638);
DECLARE_OPCODE(JumpIfActorField638);
DECLARE_OPCODE(ChangeScene);
@@ -216,17 +218,17 @@ private:
DECLARE_OPCODE(SetVolume);
DECLARE_OPCODE(Jump);
DECLARE_OPCODE(RunBlowUpPuzzle);
- DECLARE_OPCODE(JumpIfFlag2Bit3);
- DECLARE_OPCODE(SetFlag2Bit3);
- DECLARE_OPCODE(ClearFlag2Bit3);
+ DECLARE_OPCODE(JumpIfAction8);
+ DECLARE_OPCODE(SetAction8);
+ DECLARE_OPCODE(ClearAction8);
DECLARE_OPCODE(_unk3B_PALETTE_MOD);
DECLARE_OPCODE(IncrementParam2);
DECLARE_OPCODE(WaitUntilFramePlayed);
DECLARE_OPCODE(UpdateWideScreen);
DECLARE_OPCODE(JumpIfActor);
- DECLARE_OPCODE(_unk40_SOUND);
+ DECLARE_OPCODE(PlaySpeechScene);
DECLARE_OPCODE(PlaySpeech);
- DECLARE_OPCODE(_unk42);
+ DECLARE_OPCODE(PlaySpeechScene2);
DECLARE_OPCODE(MoveScenePositionFromActor);
DECLARE_OPCODE(PaletteFade);
DECLARE_OPCODE(StartPaletteFadeThread);
@@ -238,7 +240,7 @@ private:
DECLARE_OPCODE(ChangePlayerActorIndex);
DECLARE_OPCODE(ChangeActorStatus);
DECLARE_OPCODE(StopSound);
- DECLARE_OPCODE(_unk4E_RANDOM_COMMAND);
+ DECLARE_OPCODE(JumpRandom);
DECLARE_OPCODE(ClearScreen);
DECLARE_OPCODE(Quit);
DECLARE_OPCODE(JumpBarrierFrame);
@@ -254,11 +256,11 @@ private:
DECLARE_OPCODE(_unk5B);
DECLARE_OPCODE(QueueScript);
DECLARE_OPCODE(_unk5D);
- DECLARE_OPCODE(ClearActorField970);
+ DECLARE_OPCODE(ClearActorFields);
DECLARE_OPCODE(SetBarrierLastFrameIdx);
DECLARE_OPCODE(_unk60_SET_OR_CLR_ACTIONAREA_FLAG);
DECLARE_OPCODE(_unk61);
- DECLARE_OPCODE(_unk62_SHOW_OPTIONS_SCREEN);
+ DECLARE_OPCODE(ShowOptionsScreen);
DECLARE_OPCODE(_unk63);
}; // end of class ActionList
diff --git a/engines/asylum/resources/actor.cpp b/engines/asylum/resources/actor.cpp
index 6a94c13c45..586b108d70 100644
--- a/engines/asylum/resources/actor.cpp
+++ b/engines/asylum/resources/actor.cpp
@@ -291,7 +291,7 @@ void Actor::setPosition(int32 newX, int32 newY, int32 newDirection, int32 frame)
frameNum = frame;
}
-void Actor::faceTarget(int32 targetId, int32 targetType) {
+void Actor::faceTarget(int32 targetId, DirectionFrom targetType) {
int32 newX2, newY2;
printf("faceTarget: id %d type %d\n", targetId, targetType);
@@ -562,10 +562,6 @@ void Actor::updateGraphicData(uint32 offset) {
frameNum = 0;
}
-void Actor::setDirectionFrom(uint32 parameter, DirectionFrom from) {
- error("[Actor::setDirectionFrom] not implemented");
-}
-
void Actor::setDirection(int actorDirection) {
direction = (actorDirection > 4) ? 8 - actorDirection : actorDirection;
ResourceId resourceId;
@@ -798,12 +794,32 @@ void Actor::processStatus(int32 x, int32 y, bool doSpeech) {
else
updateStatus(kActorStatus13);
} else if (doSpeech) {
- speech(1);
+ _scene->playSpeech(1);
}
}
-void Actor::speech(int32 a1) {
- error("[Actor::speech] not implemented!");
+//////////////////////////////////////////////////////////////////////////
+// Unknown methods
+//////////////////////////////////////////////////////////////////////////
+
+void Actor::process_401830(int32 field980, int32 actionAreaId, int32 field978, int field98C, int32 field990, int32 field974, int32 param8, int32 param9) {
+ error("[Actor::process_401830] not implemented!");
+}
+
+bool Actor::process_408B20(Common::Point *point, ActorDirection direction, int count, bool hasDelta) {
+ error("[Actor::process_408B20] not implemented!");
+}
+
+void Actor::process_41BC00(int32 reactionIndex, int32 numberValue01Add) {
+ error("[Actor::process_41BC00] not implemented!");
+}
+
+void Actor::process_41BCC0(int32 reactionIndex, int32 numberValue01Substract) {
+ error("[Actor::process_41BC00] not implemented!");
+}
+
+bool Actor::process_41BDB0(int32 reactionIndex, bool testNumberValue01) {
+ error("[Actor::process_41BC00] not implemented!");
}
} // end of namespace Asylum
diff --git a/engines/asylum/resources/actor.h b/engines/asylum/resources/actor.h
index 4267564965..b9ef0a3f47 100644
--- a/engines/asylum/resources/actor.h
+++ b/engines/asylum/resources/actor.h
@@ -39,6 +39,10 @@ class ActionArea;
typedef int ActorIndex;
+enum ActorIndexes {
+ kActorPlayer = -1
+};
+
enum ActorStatus {
kActorStatus1 = 1,
kActorStatus2,
@@ -199,7 +203,7 @@ public:
*/
void setPosition(int32 newX, int32 newY, int32 newDirection, int32 frame);
- void faceTarget(int32 targetId, int32 targetType);
+ void faceTarget(int32 targetId, DirectionFrom targetType);
void update();
@@ -208,7 +212,6 @@ public:
*/
void updateDirection();
void setDirection(ActorDirection direction);
- void setDirectionFrom(uint32 parameter, DirectionFrom from);
void updateStatus(ActorStatus status);
@@ -218,7 +221,12 @@ public:
bool process(int32 x, int32 y);
void processStatus(int32 x, int32 y, bool doSpeech);
- void speech(int32 a1);
+ // Unknown methods
+ void process_401830(int32 field980, int32 actionAreaId, int32 field978, int field98C, int32 field990, int32 field974, int32 param8, int32 param9);
+ bool process_408B20(Common::Point *point, ActorDirection direction, int count, bool hasDelta);
+ void process_41BC00(int32 reactionIndex, int32 numberValue01Add);
+ void process_41BCC0(int32 reactionIndex, int32 numberValue01Substract);
+ bool process_41BDB0(int32 reactionIndex, bool testNumberValue01);
//////////////////////////////////////////////////////////////////////////
// OLD METHODS
diff --git a/engines/asylum/resources/barrier.h b/engines/asylum/resources/barrier.h
index 34653159b7..5eb4fc5b03 100644
--- a/engines/asylum/resources/barrier.h
+++ b/engines/asylum/resources/barrier.h
@@ -40,7 +40,8 @@ enum BarrierFlag {
kBarrierFlagC000 = 0xC000,
kBarrierFlag10000 = 0x10000,
kBarrierFlag10E38 = 0x10E38,
- kBarrierFlag20000 = 0x20000
+ kBarrierFlag20000 = 0x20000,
+ kBarrierFlag40000 = 0x40000
};
class Scene;
diff --git a/engines/asylum/resources/encounters.cpp b/engines/asylum/resources/encounters.cpp
index d9175a9a2c..8f941ce05c 100644
--- a/engines/asylum/resources/encounters.cpp
+++ b/engines/asylum/resources/encounters.cpp
@@ -67,6 +67,23 @@ Encounter::Encounter(Scene *scene) {
_scene = scene;
}
+//////////////////////////////////////////////////////////////////////////
+// Flags
+
+int32 Encounter::getFlag(EncounterFlag flag) {
+ if (flag > ARRAYSIZE(_flags))
+ error("[Encounter::getFlag] Invalid flag index!");
+
+ return _flags[flag];
+}
+
+void Encounter::setFlag(EncounterFlag flag, int32 val) {
+ if (flag > ARRAYSIZE(_flags))
+ error("[Encounter::getFlag] Invalid flag index!");
+
+ _flags[flag] = val;
+}
+
void Encounter::run(int32 encounterIdx, int32 barrierId1, int32 barrierId2, int32 characterIdx) {
// Line: 12/15 :: 0x25 (1, 1584, 1584, 0, 0, 0, 0, 0, 0) // First Encounter
diff --git a/engines/asylum/resources/encounters.h b/engines/asylum/resources/encounters.h
index 1b66942567..e38ec8459a 100644
--- a/engines/asylum/resources/encounters.h
+++ b/engines/asylum/resources/encounters.h
@@ -34,6 +34,11 @@ namespace Asylum {
class Scene;
+enum EncounterFlag{
+ kEncounterFlag2 = 2,
+ kEncounterFlag5 = 5
+};
+
typedef struct EncounterItem {
int32 keywordIndex;
int32 field2;
@@ -63,6 +68,9 @@ public:
}
void run(int32 encounterIdx, int32 barrierId1, int32 barrierId2, int32 characterIdx);
+ int32 getFlag(EncounterFlag flag);
+ void setFlag(EncounterFlag flag, int32 val);
+
private:
int16 *_variables;
int16 _anvilStyleFlag;
@@ -71,6 +79,8 @@ private:
Common::Array<EncounterItem> _items;
Scene *_scene;
+ int32 _flags[5];
+
}; // end of class Encounter
} // end of namespace Asylum
diff --git a/engines/asylum/resources/worldstats.h b/engines/asylum/resources/worldstats.h
index 4dcf191450..7fcb01420b 100644
--- a/engines/asylum/resources/worldstats.h
+++ b/engines/asylum/resources/worldstats.h
@@ -65,7 +65,7 @@ public:
int32 font1;
int32 font2;
int32 font3;
- int32 currentPaletteId;
+ ResourceId currentPaletteId;
int32 cellShadeMask1;
int32 cellShadeMask2;
int32 cellShadeMask3;
diff --git a/engines/asylum/shared.h b/engines/asylum/shared.h
index 55739fd8a1..9d244fef42 100644
--- a/engines/asylum/shared.h
+++ b/engines/asylum/shared.h
@@ -42,8 +42,13 @@ enum GameFlag {
typedef int ResourceId;
enum ResourceIdEnum {
- kResourceSound_80120001 = 0x80120001,
- kResourceSound_80120006 = 0x80120006
+ kResourceSpeech_8000050A = 0x8000050A,
+ kResourceMusic_80020000 = 0x80020000,
+ kResourceSound_80030203 = 0x80030203,
+ kResourceSound_80120001 = 0x80120001,
+ kResourceSound_80120006 = 0x80120006,
+ kResourceSoundIntro = 0x80120007,
+ kResourceMusic_FFFFFD66 = 0xFFFFFD66
};
enum ActionType {
@@ -51,7 +56,9 @@ enum ActionType {
kActionTypeFind = 1,
kActionTypeTalk = 2,
kActionType3 = 3,
- kActionTypeGrab = 4
+ kActionTypeGrab = 4,
+ kActionType8 = 8,
+ kActionType16 = 16
};
//////////////////////////////////////////////////////////////////////////
diff --git a/engines/asylum/staticres.h b/engines/asylum/staticres.h
index d79e49f80e..da180e02db 100644
--- a/engines/asylum/staticres.h
+++ b/engines/asylum/staticres.h
@@ -34,6 +34,21 @@ const int MenuIconFixedXpos[12] = { 28, 128, 225, 320, 410, 528, 16, 115, 237, 3
/** Default Actor Indices by Scene */
const int actorType[16] = {0, 0, 0, 0, 1, 0, 2, 0, 3, 0, 1, 1, 3, 0, 0, 0};
+// Delta array for points
+static const struct {
+ int x;
+ int y;
+} deltaPointsArray[8] = {
+ {0, 0xFFFFFFFF},
+ {0xFFFFFFFF, 0xFFFFFFFF},
+ {0xFFFFFFFF, 0},
+ {0xFFFFFFFF, 1},
+ {0, 1},
+ {1, 1},
+ {1, 0},
+ {1, 0xFFFFFFFF}
+};
+
// We hardcode all the text resources here. It makes the resulting code easier,
// otherwise we'll have to read the text resources in the same obscure way
// they're stored in VIDS.CAP.
diff --git a/engines/asylum/system/screen.cpp b/engines/asylum/system/screen.cpp
index 68e4bc19f6..d24611f170 100644
--- a/engines/asylum/system/screen.cpp
+++ b/engines/asylum/system/screen.cpp
@@ -129,10 +129,14 @@ void Screen::clearScreen() {
_vm->_system->fillScreen(0);
}
-void Screen::palFade(uint32 red, int32 milliseconds, int32 param) {
+void Screen::paletteFade(uint32 red, int32 milliseconds, int32 param) {
error("[Screen::palFade] not implemented");
}
+void Screen::startPaletteFade(ResourceId resourceId, int32 milliseconds, int32 param) {
+ error("[Screen::startPaletteFade] not implemented");
+}
+
void Screen::addGraphicToQueue(ResourceId resourceId, int32 frameIdx, int32 x, int32 y, int32 flags, int32 transTableNum, int32 priority) {
GraphicQueueItem item;
item.resourceId = resourceId;
diff --git a/engines/asylum/system/screen.h b/engines/asylum/system/screen.h
index f1790e94b2..dc6fcd9052 100644
--- a/engines/asylum/system/screen.h
+++ b/engines/asylum/system/screen.h
@@ -66,7 +66,8 @@ public:
void drawWideScreen(int16 barSize);
void clearScreen();
- void palFade(uint32 red, int32 milliseconds, int32 param);
+ void paletteFade(uint32 red, int32 milliseconds, int32 param);
+ void startPaletteFade(ResourceId resourceId, int32 milliseconds, int32 param);
void addGraphicToQueue(ResourceId resourceId, int32 frameIdx, int32 x, int32 y, int32 flags, int32 transTableNum, int32 priority);
void addCrossFadeGraphicToQueue(ResourceId resourceId, int32 frameIdx, int32 x, int32 y, int32 redId2, int32 x2, int32 y2, int32 flags, int32 priority);
diff --git a/engines/asylum/system/sound.cpp b/engines/asylum/system/sound.cpp
index f2a6676591..060321200f 100644
--- a/engines/asylum/system/sound.cpp
+++ b/engines/asylum/system/sound.cpp
@@ -98,6 +98,10 @@ void Sound::setVolume(ResourceId resourceId, double volume) {
error("[Sound::setVolume] not implemented");
}
+int32 Sound::getAdjustedVolume(int32 volume) {
+ error("[Sound::getAdjustedVolume] not implemented");
+}
+
int32 Sound::getBufferPosition(ResourceId resourceId) {
int32 pos = -1;
@@ -236,18 +240,19 @@ void Sound::playSpeech(ResourceId resourceId) {
playSoundData(Audio::Mixer::kSpeechSoundType, &_speechHandle, ent->data, ent->size, false, 0, 0);
}
-void Sound::playMusic(ResourceId resourceId) {
- stopMusic();
-
- // TODO Play music :P
- error("[Sound::playMusic] not implemented");
+void Sound::setSpeech(ResourceId sound, ResourceId speechText) {
+ error("[Sound::setSpeech] not implemented!");
}
-void Sound::playMusic(ResourcePack *pack, ResourceId resourceId) {
+void Sound::playMusic(ResourcePack *pack, ResourceId resourceId, int32 volume) {
stopMusic();
ResourceEntry *resource = pack->getResource(resourceId);
- playSoundData(Audio::Mixer::kMusicSoundType, &_musicHandle, resource->data, resource->size, true, Config.musicVolume, 0);
+ playSoundData(Audio::Mixer::kMusicSoundType, &_musicHandle, resource->data, resource->size, true, volume, 0);
+}
+
+void Sound::changeMusic(ResourcePack *pack, ResourceId resourceId, int32 musicStatusExt) {
+ error("[Sound::changeMusic] not implemented!");
}
void Sound::stopMusic() {
diff --git a/engines/asylum/system/sound.h b/engines/asylum/system/sound.h
index 5933a99e59..6df84c3ac0 100644
--- a/engines/asylum/system/sound.h
+++ b/engines/asylum/system/sound.h
@@ -26,6 +26,8 @@
#ifndef ASYLUM_SOUND_H
#define ASYLUM_SOUND_H
+#include "asylum/system/config.h"
+
#include "asylum/respack.h"
#include "asylum/shared.h"
@@ -93,12 +95,14 @@ public:
void stopAllSounds(bool stopSpeechAndMusic = false);
void playSpeech(ResourceId resourceId);
+ void setSpeech(ResourceId sound, ResourceId speechText);
- void playMusic(ResourcePack *pack, ResourceId resourceId);
- void playMusic(ResourceId resourceId);
+ void playMusic(ResourcePack *pack, ResourceId resourceId, int32 volume = Config.musicVolume);
+ void changeMusic(ResourcePack *pack, ResourceId resourceId, int32 musicStatusExt);
void stopMusic();
void setVolume(ResourceId resourceId, double volume);
+ int32 getAdjustedVolume(int32 volume);
/**
* Check if the buffered sound sample that matches the provided id currently
@@ -118,6 +122,13 @@ public:
*/
bool isPlaying() { return _mixer->isSoundHandleActive(_soundHandle); }
+ // TODO Make sure this is needed
+ bool isCacheOk() { error("[Sound::isCacheOk] not implemented!"); }
+
+ // Global resources ids
+ ResourceId soundResourceId;
+ ResourceId speechTextResourceId;
+
private:
Audio::Mixer *_mixer;
diff --git a/engines/asylum/views/menu.cpp b/engines/asylum/views/menu.cpp
index 7d1893426e..bbabf351e4 100644
--- a/engines/asylum/views/menu.cpp
+++ b/engines/asylum/views/menu.cpp
@@ -135,6 +135,10 @@ void MainMenu::closeMenu() {
_vm->sound()->stopMusic();
}
+void MainMenu::showOptions() {
+ error("[MainMenu::showOptions] : not implemented!");
+}
+
void MainMenu::handleEvent(Common::Event *event, bool doUpdate) {
_ev = event;
diff --git a/engines/asylum/views/menu.h b/engines/asylum/views/menu.h
index 5c83de4a93..5fb87bcd74 100644
--- a/engines/asylum/views/menu.h
+++ b/engines/asylum/views/menu.h
@@ -53,6 +53,8 @@ public:
void openMenu();
void closeMenu();
+ void showOptions();
+
private:
AsylumEngine *_vm;
diff --git a/engines/asylum/views/scene.cpp b/engines/asylum/views/scene.cpp
index cf96ddf9b7..19b64e7c4f 100644
--- a/engines/asylum/views/scene.cpp
+++ b/engines/asylum/views/scene.cpp
@@ -1510,6 +1510,33 @@ void Scene::debugShowActors() {
}
}
+void Scene::updatePlayerChapter9(int32 param) {
+ error("[Scene::updatePlayerChapter9] not implemented!");
+}
+
+ResourceId Scene::playSpeech(int32 a1) {
+ error("[Scene::playSpeech] not implemented!");
+}
+
+ResourceId Scene::playSpeech(int32 a1, int32 a2) {
+ error("[Scene::playSpeech] not implemented!");
+}
+
+int Scene::processActor(int *x, int *param) {
+ error("[Scene::processActor] not implemented!");
+}
+
+void Scene::updatePalette(int32 param) {
+ error("[Scene::updatePalette] not implemented!");
+}
+
+void Scene::makeGreyPalette() {
+ error("[Scene::makeGreyPalette] not implemented!");
+}
+
+//////////////////////////////////////////////////////////////////////////
+// SceneTitle
+//////////////////////////////////////////////////////////////////////////
SceneTitle::SceneTitle(Scene *scene): _scene(scene) {
_start = _scene->vm()->getTick();
diff --git a/engines/asylum/views/scene.h b/engines/asylum/views/scene.h
index 904f43f8b9..54f58b9e09 100644
--- a/engines/asylum/views/scene.h
+++ b/engines/asylum/views/scene.h
@@ -130,7 +130,6 @@ public:
ActorIndex getPlayerActorIndex() { return _playerActorIdx; }
void setPlayerActorIndex(ActorIndex index) { _playerActorIdx = index; }
-
void changePlayerActorIndex(ActorIndex index);
/**
@@ -138,7 +137,7 @@ public:
* WorldStats actor list. Default parameter just
* gets the instance associated with _playerActorIdx
*/
- Actor* getActor(ActorIndex index = -1);
+ Actor* getActor(ActorIndex index = kActorPlayer);
/** .text:00407260
* Check the actor at actorIndex to see if the currently loaded
@@ -163,6 +162,23 @@ public:
bool updateSceneCoordinates(int32 targetX, int32 targetY, int32 val, bool checkSceneCoords = false, int32 *param = NULL);
+
+ void updatePlayerChapter9(int32 param);
+
+ // TODO: make sure it is the right place and make private
+ ResourceId playSpeech(int32 a1);
+ ResourceId playSpeech(int32 a1, int32 id);
+
+ int processActor(int *x, int *param);
+
+ void updatePalette(int32 param);
+ void makeGreyPalette();
+ int matteBarHeight;
+ int matteVar1;
+ int matteVar2;
+ bool mattePlaySound;
+ bool matteInitialized;
+
protected:
/** .text:0040EA50
* Run various hit tests and return the index,
Commit: e808235ae32f5880d2af0d6128b2b5450c0c31f2
https://github.com/scummvm/scummvm/commit/e808235ae32f5880d2af0d6128b2b5450c0c31f2
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:07+02:00
Commit Message:
ASYLUM: Disable obsolete Actor methods
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@471 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/resources/actor.cpp
engines/asylum/resources/actor.h
diff --git a/engines/asylum/resources/actor.cpp b/engines/asylum/resources/actor.cpp
index 586b108d70..714dc93065 100644
--- a/engines/asylum/resources/actor.cpp
+++ b/engines/asylum/resources/actor.cpp
@@ -71,40 +71,40 @@ void Actor::setRawResources(uint8 *data) {
dataPtr += 4;
}
}
-
-void Actor::setAction(int32 action) {
- if (action == currentAction)
- return;
-
- currentAction = action;
-
- delete _graphic;
- int32 act = (action < 100) ? action : action - 100;
-
- _graphic = new GraphicResource(_scene->getResourcePack(), _resources[act]);
-
- // Flip horizontally if necessary
- if (currentAction > 100) {
- for (uint32 i = 0; i < _graphic->getFrameCount(); i++) {
- GraphicFrame *frame = _graphic->getFrame(i);
- byte *buffer = (byte *)frame->surface.pixels;
-
- for (int32 tmpY = 0; tmpY < frame->surface.h; tmpY++) {
- int32 w = frame->surface.w / 2;
- for (int32 tmpX = 0; tmpX < w; tmpX++) {
- SWAP(buffer[tmpY * frame->surface.pitch + tmpX],
- buffer[tmpY * frame->surface.pitch + frame->surface.w - 1 - tmpX]);
- }
- }
- }
- }
-
- frameNum = 0;
-}
-
-void Actor::setActionByIndex(int32 index) {
- setAction(_resources[index] & 0xFFFF);
-}
+//
+//void Actor::setAction(int32 action) {
+// if (action == currentAction)
+// return;
+//
+// currentAction = action;
+//
+// delete _graphic;
+// int32 act = (action < 100) ? action : action - 100;
+//
+// _graphic = new GraphicResource(_scene->getResourcePack(), _resources[act]);
+//
+// // Flip horizontally if necessary
+// if (currentAction > 100) {
+// for (uint32 i = 0; i < _graphic->getFrameCount(); i++) {
+// GraphicFrame *frame = _graphic->getFrame(i);
+// byte *buffer = (byte *)frame->surface.pixels;
+//
+// for (int32 tmpY = 0; tmpY < frame->surface.h; tmpY++) {
+// int32 w = frame->surface.w / 2;
+// for (int32 tmpX = 0; tmpX < w; tmpX++) {
+// SWAP(buffer[tmpY * frame->surface.pitch + tmpX],
+// buffer[tmpY * frame->surface.pitch + frame->surface.w - 1 - tmpX]);
+// }
+// }
+// }
+// }
+//
+// frameNum = 0;
+//}
+//
+//void Actor::setActionByIndex(int32 index) {
+// setAction(_resources[index] & 0xFFFF);
+//}
GraphicFrame *Actor::getFrame() {
assert(_graphic);
@@ -123,156 +123,156 @@ GraphicFrame *Actor::getFrame() {
return frame;
}
-
-void Actor::drawActorAt(int32 curX, int32 curY) {
- GraphicFrame *frame = getFrame();
-
- WorldStats *ws = _scene->worldstats();
-
- _scene->vm()->screen()->copyRectToScreenWithTransparency(
- ((byte *)frame->surface.pixels),
- frame->surface.w,
- curX - ws->targetX,
- curY - ws->targetY,
- frame->surface.w,
- frame->surface.h);
- x = curX;
- y = curY;
-}
-
-void Actor::drawActor() {
- GraphicFrame *frame = getFrame();
- WorldStats *ws = _scene->worldstats();
-
- _scene->vm()->screen()->copyToBackBufferWithTransparency(
- ((byte *)frame->surface.pixels),
- frame->surface.w,
- x - ws->targetX,
- y - frame->surface.h - ws->targetY,
- frame->surface.w,
- frame->surface.h);
-}
-
-void Actor::setWalkArea(ActionArea *target) {
- if (_currentWalkArea != target) {
- // FIXME
- //_scene->actions()->setScriptByIndex(target->actionListIdx1);
- _currentWalkArea = target;
- debugC(kDebugLevelScripts, "%s", target->name);
- }
-}
-
-void Actor::walkTo(int32 curX, int32 curY) {
- int32 newAction = currentAction;
- WorldStats *ws = _scene->worldstats();
-
- // step is the increment by which to move the
- // actor in a given direction
- int32 step = 2;
-
- int32 newX = x;
- int32 newY = y;
- bool done = false;
-
- // Walking left...
- if (curX < x) {
- newAction = kWalkW;
- newX -= step;
- if (ABS((int32)curY - (int32)y) <= 30)
- done = true;
- }
-
- // Walking right...
- if (curX > x) {
- newAction = kWalkE;
- newX += step;
- if (ABS((int32)curY - (int32)y) <= 30)
- done = true;
- }
-
- // Walking up...
- if (curY < y && !done) {
- if (newAction != currentAction && newAction == kWalkW && x - curX > 30)
- newAction = kWalkNW; // up left
- else if (newAction != currentAction && newAction == kWalkE && curX - x > 30)
- newAction = kWalkNE; // up right
- else
- newAction = kWalkN;
-
- newY -= step;
- }
-
- // Walking down...
- if (curY > y && !done) {
- if (newAction != currentAction && newAction == kWalkW && x - curX > 30)
- newAction = kWalkSW; // down left
- else if (newAction != currentAction && newAction == kWalkE && curX - x > 30)
- newAction = kWalkSE; // down right
- else
- newAction = kWalkS;
-
- newY += step;
- }
-
- // DEBUGGING
- // Show registration point32 from which we're calculating the
- // actor's barrier hit-test
- Graphics::Surface surface;
- surface.create(5, 5, 1);
- Common::Rect rect;
-
- rect.top = newY;
- rect.left = newX;
- rect.right = newX;
- rect.bottom = newY + 4;
- surface.frameRect(rect, 0x33);
-
- _scene->vm()->screen()->copyRectToScreen((byte*)surface.pixels, 5, newX - ws->targetX, newY - ws->targetY, 5, 5);
-
- surface.free();
-
- // TODO Basic pathfinding implementation is done. Now it needs to be refined to
- // actuallcurY make it playable. The logic is currently VERY rigid, so you have to have
- // the actor at the PERFECT spot to be able to intersect a walk region and move to
- // the next one.
-
- int32 availableAreas[5];
- int32 areaPtr = 0;
- ActionArea *area;
-
- // Check what valid walk region(s) is/are currently available
- for (int32 a = 0; a < ws->numActions; a++) {
- if (ws->actions[a]->actionType == 0) {
- area = ws->actions[a];
- PolyDefinitions poly = _scene->polygons()->entries[area->polyIdx];
- if (poly.contains(x, y)) {
- availableAreas[areaPtr] = a;
- areaPtr++;
-
- setWalkArea(ws->actions[a]);
-
- if (areaPtr > 5)
- error("More than 5 overlapping walk regions found. Increase buffer");
-
- }
- }
- }
-
- // Check that we can walk in the current direction within any of the available
- // walkable regions
- for (int32 i = 0; i < areaPtr; i++) {
- area = ws->actions[availableAreas[i]];
- PolyDefinitions *region = &_scene->polygons()->entries[area->polyIdx];
- if (region->contains(newX, newY)) {
- x = newX;
- y = newY;
- break;
- }
- }
-
- setAction(newAction);
- drawActor();
-}
+//
+//void Actor::drawActorAt(int32 curX, int32 curY) {
+// GraphicFrame *frame = getFrame();
+//
+// WorldStats *ws = _scene->worldstats();
+//
+// _scene->vm()->screen()->copyRectToScreenWithTransparency(
+// ((byte *)frame->surface.pixels),
+// frame->surface.w,
+// curX - ws->targetX,
+// curY - ws->targetY,
+// frame->surface.w,
+// frame->surface.h);
+// x = curX;
+// y = curY;
+//}
+//
+//void Actor::drawActor() {
+// GraphicFrame *frame = getFrame();
+// WorldStats *ws = _scene->worldstats();
+//
+// _scene->vm()->screen()->copyToBackBufferWithTransparency(
+// ((byte *)frame->surface.pixels),
+// frame->surface.w,
+// x - ws->targetX,
+// y - frame->surface.h - ws->targetY,
+// frame->surface.w,
+// frame->surface.h);
+//}
+//
+//void Actor::setWalkArea(ActionArea *target) {
+// if (_currentWalkArea != target) {
+// // FIXME
+// //_scene->actions()->setScriptByIndex(target->actionListIdx1);
+// _currentWalkArea = target;
+// debugC(kDebugLevelScripts, "%s", target->name);
+// }
+//}
+//
+//void Actor::walkTo(int32 curX, int32 curY) {
+// int32 newAction = currentAction;
+// WorldStats *ws = _scene->worldstats();
+//
+// // step is the increment by which to move the
+// // actor in a given direction
+// int32 step = 2;
+//
+// int32 newX = x;
+// int32 newY = y;
+// bool done = false;
+//
+// // Walking left...
+// if (curX < x) {
+// newAction = kWalkW;
+// newX -= step;
+// if (ABS((int32)curY - (int32)y) <= 30)
+// done = true;
+// }
+//
+// // Walking right...
+// if (curX > x) {
+// newAction = kWalkE;
+// newX += step;
+// if (ABS((int32)curY - (int32)y) <= 30)
+// done = true;
+// }
+//
+// // Walking up...
+// if (curY < y && !done) {
+// if (newAction != currentAction && newAction == kWalkW && x - curX > 30)
+// newAction = kWalkNW; // up left
+// else if (newAction != currentAction && newAction == kWalkE && curX - x > 30)
+// newAction = kWalkNE; // up right
+// else
+// newAction = kWalkN;
+//
+// newY -= step;
+// }
+//
+// // Walking down...
+// if (curY > y && !done) {
+// if (newAction != currentAction && newAction == kWalkW && x - curX > 30)
+// newAction = kWalkSW; // down left
+// else if (newAction != currentAction && newAction == kWalkE && curX - x > 30)
+// newAction = kWalkSE; // down right
+// else
+// newAction = kWalkS;
+//
+// newY += step;
+// }
+//
+// // DEBUGGING
+// // Show registration point32 from which we're calculating the
+// // actor's barrier hit-test
+// Graphics::Surface surface;
+// surface.create(5, 5, 1);
+// Common::Rect rect;
+//
+// rect.top = newY;
+// rect.left = newX;
+// rect.right = newX;
+// rect.bottom = newY + 4;
+// surface.frameRect(rect, 0x33);
+//
+// _scene->vm()->screen()->copyRectToScreen((byte*)surface.pixels, 5, newX - ws->targetX, newY - ws->targetY, 5, 5);
+//
+// surface.free();
+//
+// // TODO Basic pathfinding implementation is done. Now it needs to be refined to
+// // actuallcurY make it playable. The logic is currently VERY rigid, so you have to have
+// // the actor at the PERFECT spot to be able to intersect a walk region and move to
+// // the next one.
+//
+// int32 availableAreas[5];
+// int32 areaPtr = 0;
+// ActionArea *area;
+//
+// // Check what valid walk region(s) is/are currently available
+// for (int32 a = 0; a < ws->numActions; a++) {
+// if (ws->actions[a]->actionType == 0) {
+// area = ws->actions[a];
+// PolyDefinitions poly = _scene->polygons()->entries[area->polyIdx];
+// if (poly.contains(x, y)) {
+// availableAreas[areaPtr] = a;
+// areaPtr++;
+//
+// setWalkArea(ws->actions[a]);
+//
+// if (areaPtr > 5)
+// error("More than 5 overlapping walk regions found. Increase buffer");
+//
+// }
+// }
+// }
+//
+// // Check that we can walk in the current direction within any of the available
+// // walkable regions
+// for (int32 i = 0; i < areaPtr; i++) {
+// area = ws->actions[availableAreas[i]];
+// PolyDefinitions *region = &_scene->polygons()->entries[area->polyIdx];
+// if (region->contains(newX, newY)) {
+// x = newX;
+// y = newY;
+// break;
+// }
+// }
+//
+// setAction(newAction);
+// drawActor();
+//}
void Actor::stopSound() {
if (soundResourceId && _scene->vm()->sound()->isPlaying(soundResourceId))
@@ -285,7 +285,7 @@ void Actor::setPosition(int32 newX, int32 newY, int32 newDirection, int32 frame)
if (direction != 8) {
// TODO implement the propert character_setDirection() functionality
- setAction(newDirection);
+ setDirection(newDirection);
}
if (frame > 0)
frameNum = frame;
diff --git a/engines/asylum/resources/actor.h b/engines/asylum/resources/actor.h
index b9ef0a3f47..07abfaa091 100644
--- a/engines/asylum/resources/actor.h
+++ b/engines/asylum/resources/actor.h
@@ -232,12 +232,12 @@ public:
// OLD METHODS
// TODO ALL of these need to be depreciated in favour
// of the proper functions from the original
- void setWalkArea(ActionArea *target);
- void setAction(int32 action);
- void setActionByIndex(int32 index);
- void drawActorAt(int32 curX, int32 curY);
- void drawActor();
- void walkTo(int32 curX, int32 curY);
+ //void setWalkArea(ActionArea *target);
+ //void setAction(int32 action);
+ //void setActionByIndex(int32 index);
+ //void drawActorAt(int32 curX, int32 curY);
+ //void drawActor();
+ //void walkTo(int32 curX, int32 curY);
//////////////////////////////////////////////////////////////////////////
Commit: 0f13d7dc3f8d135195f144254b19da258a63ae80
https://github.com/scummvm/scummvm/commit/0f13d7dc3f8d135195f144254b19da258a63ae80
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:07+02:00
Commit Message:
ASYLUM: Refactor and cleanup Actor class
- Reorganize methods
- Make most variables private
- Finish implementation of updateFromDirection, updateStatus
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@472 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/asylum.h
engines/asylum/console.h
engines/asylum/resources/actionlist.cpp
engines/asylum/resources/actor.cpp
engines/asylum/resources/actor.h
engines/asylum/resources/worldstats.cpp
engines/asylum/shared.h
engines/asylum/system/sound.cpp
engines/asylum/system/sound.h
engines/asylum/system/speech.cpp
engines/asylum/views/scene.cpp
engines/asylum/views/scene.h
diff --git a/engines/asylum/asylum.h b/engines/asylum/asylum.h
index 5225f70bd4..cf1e08cfc3 100644
--- a/engines/asylum/asylum.h
+++ b/engines/asylum/asylum.h
@@ -131,13 +131,13 @@ public:
uint32 tempTick07;
// Game
- Encounter *encouter() { return _encounter; }
- MainMenu *menu() { return _mainMenu; }
- Scene *scene() { return _scene; }
- Screen *screen() { return _screen; }
- Sound *sound() { return _sound; }
- Text *text() { return _text; }
- Video *video() { return _video; }
+ Encounter *encounter() { return _encounter; }
+ MainMenu *menu() { return _mainMenu; }
+ Scene *scene() { return _scene; }
+ Screen *screen() { return _screen; }
+ Sound *sound() { return _sound; }
+ Text *text() { return _text; }
+ Video *video() { return _video; }
// Flags
void setGameFlag(GameFlag flag);
diff --git a/engines/asylum/console.h b/engines/asylum/console.h
index 497e666214..df91e80758 100644
--- a/engines/asylum/console.h
+++ b/engines/asylum/console.h
@@ -42,7 +42,8 @@ enum kDebugLevels {
kDebugLevelSound = 1 << 6,
kDebugLevelSavegame = 1 << 7,
kDebugLevelScene = 1 << 8,
- kDebugLevelBarriers = 1 << 9
+ kDebugLevelBarriers = 1 << 9,
+ kDebugLevelActor = 1 << 10
};
class AsylumEngine;
diff --git a/engines/asylum/resources/actionlist.cpp b/engines/asylum/resources/actionlist.cpp
index 3a99217e97..dcad5f27c5 100644
--- a/engines/asylum/resources/actionlist.cpp
+++ b/engines/asylum/resources/actionlist.cpp
@@ -442,7 +442,7 @@ IMPLEMENT_OPCODE(ShowActor) {
actor->setVisible(true);
actor->updateDirection();
- actor->tickValue = _scene->vm()->getTick();
+ actor->setTickValue(_scene->vm()->getTick());
}
//////////////////////////////////////////////////////////////////////////
@@ -472,7 +472,7 @@ IMPLEMENT_OPCODE(DisableActor) {
IMPLEMENT_OPCODE(EnableActor) {
Actor *actor = _scene->getActor(cmd->param1);
- if (actor->status == kActorStatusDisabled)
+ if (actor->getStatus() == kActorStatusDisabled)
actor->updateStatus(kActorStatusEnabled);
}
@@ -535,13 +535,13 @@ IMPLEMENT_OPCODE(JumpActorSpeech) {
IMPLEMENT_OPCODE(JumpAndSetDirection) {
Actor *actor = _scene->getActor(cmd->param1);
- if (actor->status != kActorStatus2 && actor->status != kActorStatus13) {
+ if (actor->getStatus() != kActorStatus2 && actor->getStatus() != kActorStatus13) {
if (cmd->param5 != 2) {
if (cmd->param2 == -1 || cmd->param3 == -1) {
- actor->setDirection(cmd->param4);
+ actor->updateFromDirection(cmd->param4);
} else if ((actor->x1 + actor->x2) == cmd->param2 && (actor->y1 + actor->y2) == cmd->param3) {
- actor->setDirection(cmd->param4);
+ actor->updateFromDirection(cmd->param4);
} else {
actor->processStatus(cmd->param2, cmd->param3, cmd->param4);
@@ -555,7 +555,7 @@ IMPLEMENT_OPCODE(JumpAndSetDirection) {
_lineIncrement = 0;
if ((actor->x1 + actor->x2) == cmd->param2 && (actor->y1 + actor->y2) == cmd->param3)
- actor->setDirection(cmd->param4);
+ actor->updateFromDirection(cmd->param4);
}
} else {
if (cmd->param5 == 2)
@@ -697,7 +697,7 @@ IMPLEMENT_OPCODE(_unk24) {
//////////////////////////////////////////////////////////////////////////
// Opcode 0x25
IMPLEMENT_OPCODE(RunEncounter) {
- Encounter *encounter = _scene->vm()->encouter();
+ Encounter *encounter = _scene->vm()->encounter();
encounter->setFlag(kEncounterFlag5, cmd->param5);
@@ -737,7 +737,7 @@ IMPLEMENT_OPCODE(ClearAction16) {
IMPLEMENT_OPCODE(SetActorField638) {
Actor *actor = _scene->getActor(cmd->param1);
- actor->field_638 = cmd->param2;
+ actor->setField638(cmd->param2);
}
//////////////////////////////////////////////////////////////////////////
@@ -745,7 +745,7 @@ IMPLEMENT_OPCODE(SetActorField638) {
IMPLEMENT_OPCODE(JumpIfActorField638) {
Actor *actor = _scene->getActor(cmd->param1);
- if (actor->field_638)
+ if (actor->getField638())
_currentLine = cmd->param3;
}
@@ -771,16 +771,16 @@ IMPLEMENT_OPCODE(ChangeScene) {
//////////////////////////////////////////////////////////////////////////
// Opcode 0x2C
IMPLEMENT_OPCODE(_unk2C_ActorSub) {
- Actor *player = _scene->getActor(kActorPlayer);
+ Actor *player = _scene->getActor();
Actor *actor = _scene->getActor(_currentQueueEntry.actorIndex);
Common::Point playerPoint(player->x1 + player->x2, player->y1 + player->y2);
- ActorDirection direction = (cmd->param2 == 8) ? player->direction : cmd->param2;
+ ActorDirection direction = (cmd->param2 == 8) ? player->getDirection() : cmd->param2;
if (cmd->param2 == 8)
- cmd->param2 = player->direction;
+ cmd->param2 = player->getDirection();
if (cmd->param3 == 2) {
- switch (actor->status) {
+ switch (actor->getStatus()) {
default:
_lineIncrement = 1;
return;
@@ -802,28 +802,30 @@ IMPLEMENT_OPCODE(_unk2C_ActorSub) {
if (cmd->param1 == 2) {
Common::Point point(playerPoint);
- if (player->process_408B20(&point, (player->direction + 4) % 8, 3, false)) {
+ int32 index = (player->getDirection() + 4) % 8;
- point.x += 3 * deltaPointsArray[(player->direction + 4) % 8].x;
- point.x += 3 * deltaPointsArray[(player->direction + 4) % 8].y;
+ if (player->process_408B20(&point, index, 3, false)) {
- player->setPosition(point.x, point.y, actor->direction, 0);
+ point.x += 3 * deltaPointsArray[index].x;
+ point.x += 3 * deltaPointsArray[index].y;
+
+ player->setPosition(point.x, point.y, actor->getDirection(), 0);
}
}
- } else if (cmd->param1 != 2 || player->process_408B20(&playerPoint, (player->direction + 4) % 8, 3, false)) {
+ } else if (cmd->param1 != 2 || player->process_408B20(&playerPoint, (player->getDirection() + 4) % 8, 3, false)) {
ResourceId id = 0;
if (direction >= 5)
- id = actor->graphicResourceIds[5 * cmd->param1 - direction + 38];
+ id = actor->getResourcesId(5 * cmd->param1 - direction + 38);
else
- id = actor->graphicResourceIds[5 * cmd->param1 + direction + 30];
+ id = actor->getResourcesId(5 * cmd->param1 + direction + 30);
GraphicResource *res = new GraphicResource(_scene->getResourcePack(), id);
- actor->graphicResourceId = id;
- actor->frameCount = res->getFrameCount();
- actor->frameNum = 0;
- actor->direction = direction;
- actor->updateStatus(actor->status <= kActorStatus11 ? kActorStatus3 : kActorStatus19);
+ actor->setResourceId(id);
+ actor->setFrameCount(res->getFrameCount());
+ actor->setFrameNumber(0);
+ actor->setDirection(direction);
+ actor->updateStatus(actor->getStatus() <= kActorStatus11 ? kActorStatus3 : kActorStatus19);
delete res;
cmd->param3 = 2;
@@ -852,7 +854,7 @@ IMPLEMENT_OPCODE(PlayMovie) {
}
bool check = false;
- ActionArea *area = _scene->worldstats()->actions[_scene->getActor()->actionIdx3];
+ ActionArea *area = _scene->worldstats()->actions[_scene->getActor()->getActionIndex3()];
if (area->paletteValue) {
_scene->vm()->screen()->setPalette(_scene->getResourcePack(), area->paletteValue);
_scene->vm()->screen()->setGammaLevel(_scene->getResourcePack(), area->paletteValue, 0);
@@ -1399,10 +1401,10 @@ IMPLEMENT_OPCODE(ChangeActorStatus) {
Actor *actor = _scene->getActor(cmd->param1);
if (cmd->param2) {
- if (actor->status < kActorStatus11)
- actor->status = kActorStatus14;
+ if (actor->getStatus() < kActorStatus11)
+ actor->setStatus(kActorStatus14);
} else {
- actor->status = kActorStatusEnabled;
+ actor->setStatus(kActorStatusEnabled);
}
}
@@ -1477,7 +1479,7 @@ IMPLEMENT_OPCODE(JumpBarrierFrame) {
// Opcode 0x52
IMPLEMENT_OPCODE(DeleteGraphics) {
for (uint i = 0; i < 55; i++)
- _scene->vm()->screen()->deleteGraphicFromQueue(_scene->getActor(cmd->param1)->graphicResourceIds[cmd->param1]);
+ _scene->vm()->screen()->deleteGraphicFromQueue(_scene->getActor(cmd->param1)->getResourcesId(cmd->param1));
}
//////////////////////////////////////////////////////////////////////////
@@ -1485,7 +1487,7 @@ IMPLEMENT_OPCODE(DeleteGraphics) {
IMPLEMENT_OPCODE(SetActorField944) {
Actor *actor = _scene->getActor(cmd->param1);
- actor->field_944 = cmd->param2;
+ actor->setField944(cmd->param2);
}
//////////////////////////////////////////////////////////////////////////
@@ -1534,7 +1536,7 @@ IMPLEMENT_OPCODE(_unk55) {
IMPLEMENT_OPCODE(_unk56) {
Actor *actor = _scene->getActor(cmd->param2 == 2 ? -1 : cmd->param1);
- if (actor->status == kActorStatus2 || actor->status == kActorStatus13) {
+ if (actor->getStatus() == kActorStatus2 || actor->getStatus() == kActorStatus13) {
if (cmd->param2 == 2)
_lineIncrement = 1;
@@ -1546,8 +1548,8 @@ IMPLEMENT_OPCODE(_unk56) {
_lineIncrement = 0;
if ((actor->x1 + actor->x2 == cmd->param6) && (actor->y1 + actor->y2 == cmd->param7)) {
- _scene->getActor(kActorPlayer)->faceTarget(cmd->param1, kDirectionFromActor);
- actor->setDirection((actor->direction + 4) & 7);
+ _scene->getActor()->faceTarget(cmd->param1, kDirectionFromActor);
+ actor->updateFromDirection((actor->getDirection() + 4) & 7);
} else {
_currentLine = cmd->param3;
}
@@ -1556,7 +1558,7 @@ IMPLEMENT_OPCODE(_unk56) {
int32 y = 0; // FIXME: is is set somewhere else?
if (_scene->processActor(&x, &cmd->param4) == 1) {
- _scene->getActor(kActorPlayer)->processStatus(x, y, cmd->param4);
+ _scene->getActor()->processStatus(x, y, cmd->param4);
cmd->param6 = x;
cmd->param7 = y;
@@ -1612,7 +1614,7 @@ IMPLEMENT_OPCODE(_unk59) {
//////////////////////////////////////////////////////////////////////////
// Opcode 0x5A
IMPLEMENT_OPCODE(_unk5A) {
- _scene->getActor(cmd->param1)->actionIdx2 = cmd->param2;
+ _scene->getActor(cmd->param1)->setActionIndex2(cmd->param2);
}
//////////////////////////////////////////////////////////////////////////
@@ -1627,7 +1629,7 @@ IMPLEMENT_OPCODE(_unk5B) {
if (barrier->field_67C)
barrier->field_67C += 3;
} else {
- _scene->getActor(cmd->param3)->field_96C = cmd->param2;
+ _scene->getActor(cmd->param3)->setField96C(cmd->param2);
}
}
}
@@ -1652,7 +1654,7 @@ IMPLEMENT_OPCODE(ClearActorFields) {
Actor *actor = _scene->getActor(cmd->param1);
// Clear fields starting from field_970
- memset(&actor->field_970, 0, 52);
+ actor->clearFields();
}
//////////////////////////////////////////////////////////////////////////
diff --git a/engines/asylum/resources/actor.cpp b/engines/asylum/resources/actor.cpp
index 714dc93065..3b4972b063 100644
--- a/engines/asylum/resources/actor.cpp
+++ b/engines/asylum/resources/actor.cpp
@@ -24,6 +24,7 @@
*/
#include "asylum/resources/actor.h"
+#include "asylum/resources/encounters.h"
#include "asylum/resources/worldstats.h"
#include "asylum/system/screen.h"
@@ -35,18 +36,125 @@
namespace Asylum {
-Actor::Actor(Scene *scene, ActorIndex index) : _scene(scene), _index(index), _currentWalkArea(NULL), _graphic(NULL) {
- currentAction = 0;
+Actor::Actor(Scene *scene, ActorIndex index) : _scene(scene), _index(index) {
- // TODO initialize other class variables
+ // Update private variables
+ _actorUpdateCounter = 0;
+ _enableFromStatus7 = false;
}
Actor::~Actor() {
- delete _graphic;
- // free _resources?
+
+ // Zero passed pointers
+ _scene = NULL;
+}
+
+/////////////////////////////////////////////////////////////////////////
+// Loading
+//////////////////////////////////////////////////////////////////////////
+void Actor::load(Common::SeekableReadStream *stream) {
+ if (!stream)
+ error("[Actor::load] invalid stream");
+
+ x = stream->readSint32LE();
+ y = stream->readSint32LE();
+ _resourceId = stream->readSint32LE();
+ _field_C = stream->readSint32LE();
+ _frameNumber = stream->readSint32LE();
+ _frameCount = stream->readSint32LE();
+ x1 = stream->readSint32LE();
+ y1 = stream->readSint32LE();
+ x2 = stream->readSint32LE();
+ y2 = stream->readSint32LE();
+
+ _boundingRect.left = stream->readSint32LE() & 0xFFFF;
+ _boundingRect.top = stream->readSint32LE() & 0xFFFF;
+ _boundingRect.right = stream->readSint32LE() & 0xFFFF;
+ _boundingRect.bottom = stream->readSint32LE() & 0xFFFF;
+
+ _direction = stream->readSint32LE();
+ _field_3C = stream->readSint32LE();
+ _status = (ActorStatus)stream->readSint32LE();
+ _field_44 = stream->readSint32LE();
+ _priority = stream->readSint32LE();
+ flags = stream->readSint32LE();
+ _field_50 = stream->readSint32LE();
+ _field_54 = stream->readSint32LE();
+ _field_58 = stream->readSint32LE();
+ _field_5C = stream->readSint32LE();
+ _field_60 = stream->readSint32LE();
+ _actionIdx3 = stream->readSint32LE();
+
+ // TODO skip field_68 till field_617
+ stream->skip(0x5B0);
+
+ for (int32 i = 0; i < 8; i++)
+ _reaction[i] = stream->readSint32LE();
+
+ _field_638 = stream->readSint32LE();
+ _walkingSound1 = stream->readSint32LE();
+ _walkingSound2 = stream->readSint32LE();
+ _walkingSound3 = stream->readSint32LE();
+ _walkingSound4 = stream->readSint32LE();
+ _field_64C = stream->readSint32LE();
+ _field_650 = stream->readSint32LE();
+
+ for (int32 i = 0; i < 55; i++)
+ _graphicResourceIds[i] = stream->readSint32LE();
+
+ stream->read(_name, sizeof(_name));
+
+ for (int32 i = 0; i < 20; i++)
+ _field_830[i] = stream->readSint32LE();
+
+ for (int32 i = 0; i < 20; i++)
+ _field_880[i] = stream->readSint32LE();
+
+ for (int32 i = 0; i < 20; i++)
+ _field_8D0[i] = stream->readSint32LE();
+
+ _actionIdx2 = stream->readSint32LE();
+ _field_924 = stream->readSint32LE();
+ _tickValue = stream->readSint32LE();
+ _field_92C = stream->readSint32LE();
+ actionType = stream->readSint32LE();
+ _field_934 = stream->readSint32LE();
+ _field_938 = stream->readSint32LE();
+ _soundResourceId = stream->readSint32LE();
+ _numberValue01 = stream->readSint32LE();
+ _field_944 = stream->readSint32LE();
+ _field_948 = stream->readSint32LE();
+ _field_94C = stream->readSint32LE();
+ _numberFlag01 = stream->readSint32LE();
+ _numberStringWidth = stream->readSint32LE();
+ _numberStringX = stream->readSint32LE();
+ _numberStringY = stream->readSint32LE();
+ stream->read(_numberString01, sizeof(_numberString01));
+ _field_964 = stream->readSint32LE();
+ _field_968 = stream->readSint32LE();
+ _field_96C = stream->readSint32LE();
+ _field_970 = stream->readSint32LE();
+ _field_974 = stream->readSint32LE();
+ _field_978 = stream->readSint32LE();
+ _actionIdx1 = stream->readSint32LE();
+ _field_980 = stream->readSint32LE();
+ _field_984 = stream->readSint32LE();
+ _field_988 = stream->readSint32LE();
+ _field_98C = stream->readSint32LE();
+ _field_990 = stream->readSint32LE();
+ _field_994 = stream->readSint32LE();
+ _field_998 = stream->readSint32LE();
+ _field_99C = stream->readSint32LE();
+ _field_9A0 = stream->readSint32LE();
+
+ // TODO skip field_980 till field_9A0
+ stream->skip(0x24);
}
+/////////////////////////////////////////////////////////////////////////
+// Visibility
+//////////////////////////////////////////////////////////////////////////
void Actor::setVisible(bool value) {
if (value)
flags |= kActorFlagVisible;
@@ -56,396 +164,275 @@ void Actor::setVisible(bool value) {
stopSound();
}
-/*
-void Actor::setDirection(int32 dir) {
- direction = dir;
- setActionByIndex(dir);
-}
-*/
+/////////////////////////////////////////////////////////////////////////
+// Update & status
+//////////////////////////////////////////////////////////////////////////
-void Actor::setRawResources(uint8 *data) {
- byte *dataPtr = data;
- for (int32 i = 0; i < 60; i++) {
- _resources[i] = (int32)READ_LE_UINT32(dataPtr);
- dataPtr += 4;
- }
-}
-//
-//void Actor::setAction(int32 action) {
-// if (action == currentAction)
-// return;
-//
-// currentAction = action;
-//
-// delete _graphic;
-// int32 act = (action < 100) ? action : action - 100;
-//
-// _graphic = new GraphicResource(_scene->getResourcePack(), _resources[act]);
-//
-// // Flip horizontally if necessary
-// if (currentAction > 100) {
-// for (uint32 i = 0; i < _graphic->getFrameCount(); i++) {
-// GraphicFrame *frame = _graphic->getFrame(i);
-// byte *buffer = (byte *)frame->surface.pixels;
-//
-// for (int32 tmpY = 0; tmpY < frame->surface.h; tmpY++) {
-// int32 w = frame->surface.w / 2;
-// for (int32 tmpX = 0; tmpX < w; tmpX++) {
-// SWAP(buffer[tmpY * frame->surface.pitch + tmpX],
-// buffer[tmpY * frame->surface.pitch + frame->surface.w - 1 - tmpX]);
-// }
-// }
-// }
-// }
-//
-// frameNum = 0;
-//}
-//
-//void Actor::setActionByIndex(int32 index) {
-// setAction(_resources[index] & 0xFFFF);
-//}
-
-GraphicFrame *Actor::getFrame() {
- assert(_graphic);
-
- GraphicFrame *frame = _graphic->getFrame(frameNum);
-
- if (frameNum < _graphic->getFrameCount() - 1) {
- frameNum++;
- } else {
- frameNum = 0;
- }
+void Actor::update() {
+ if (!isVisible())
+ return;
- // HACK: frame 1 of the "walk west" animation is misplaced
- if ((currentAction == kWalkW || currentAction == kWalkE) && frameNum == 1)
- frameNum++;
-
- return frame;
-}
-//
-//void Actor::drawActorAt(int32 curX, int32 curY) {
-// GraphicFrame *frame = getFrame();
-//
-// WorldStats *ws = _scene->worldstats();
-//
-// _scene->vm()->screen()->copyRectToScreenWithTransparency(
-// ((byte *)frame->surface.pixels),
-// frame->surface.w,
-// curX - ws->targetX,
-// curY - ws->targetY,
-// frame->surface.w,
-// frame->surface.h);
-// x = curX;
-// y = curY;
-//}
-//
-//void Actor::drawActor() {
-// GraphicFrame *frame = getFrame();
-// WorldStats *ws = _scene->worldstats();
-//
-// _scene->vm()->screen()->copyToBackBufferWithTransparency(
-// ((byte *)frame->surface.pixels),
-// frame->surface.w,
-// x - ws->targetX,
-// y - frame->surface.h - ws->targetY,
-// frame->surface.w,
-// frame->surface.h);
-//}
-//
-//void Actor::setWalkArea(ActionArea *target) {
-// if (_currentWalkArea != target) {
-// // FIXME
-// //_scene->actions()->setScriptByIndex(target->actionListIdx1);
-// _currentWalkArea = target;
-// debugC(kDebugLevelScripts, "%s", target->name);
-// }
-//}
-//
-//void Actor::walkTo(int32 curX, int32 curY) {
-// int32 newAction = currentAction;
-// WorldStats *ws = _scene->worldstats();
-//
-// // step is the increment by which to move the
-// // actor in a given direction
-// int32 step = 2;
-//
-// int32 newX = x;
-// int32 newY = y;
-// bool done = false;
-//
-// // Walking left...
-// if (curX < x) {
-// newAction = kWalkW;
-// newX -= step;
-// if (ABS((int32)curY - (int32)y) <= 30)
-// done = true;
-// }
-//
-// // Walking right...
-// if (curX > x) {
-// newAction = kWalkE;
-// newX += step;
-// if (ABS((int32)curY - (int32)y) <= 30)
-// done = true;
-// }
-//
-// // Walking up...
-// if (curY < y && !done) {
-// if (newAction != currentAction && newAction == kWalkW && x - curX > 30)
-// newAction = kWalkNW; // up left
-// else if (newAction != currentAction && newAction == kWalkE && curX - x > 30)
-// newAction = kWalkNE; // up right
-// else
-// newAction = kWalkN;
-//
-// newY -= step;
-// }
-//
-// // Walking down...
-// if (curY > y && !done) {
-// if (newAction != currentAction && newAction == kWalkW && x - curX > 30)
-// newAction = kWalkSW; // down left
-// else if (newAction != currentAction && newAction == kWalkE && curX - x > 30)
-// newAction = kWalkSE; // down right
-// else
-// newAction = kWalkS;
-//
-// newY += step;
-// }
-//
-// // DEBUGGING
-// // Show registration point32 from which we're calculating the
-// // actor's barrier hit-test
-// Graphics::Surface surface;
-// surface.create(5, 5, 1);
-// Common::Rect rect;
-//
-// rect.top = newY;
-// rect.left = newX;
-// rect.right = newX;
-// rect.bottom = newY + 4;
-// surface.frameRect(rect, 0x33);
-//
-// _scene->vm()->screen()->copyRectToScreen((byte*)surface.pixels, 5, newX - ws->targetX, newY - ws->targetY, 5, 5);
-//
-// surface.free();
-//
-// // TODO Basic pathfinding implementation is done. Now it needs to be refined to
-// // actuallcurY make it playable. The logic is currently VERY rigid, so you have to have
-// // the actor at the PERFECT spot to be able to intersect a walk region and move to
-// // the next one.
-//
-// int32 availableAreas[5];
-// int32 areaPtr = 0;
-// ActionArea *area;
-//
-// // Check what valid walk region(s) is/are currently available
-// for (int32 a = 0; a < ws->numActions; a++) {
-// if (ws->actions[a]->actionType == 0) {
-// area = ws->actions[a];
-// PolyDefinitions poly = _scene->polygons()->entries[area->polyIdx];
-// if (poly.contains(x, y)) {
-// availableAreas[areaPtr] = a;
-// areaPtr++;
-//
-// setWalkArea(ws->actions[a]);
-//
-// if (areaPtr > 5)
-// error("More than 5 overlapping walk regions found. Increase buffer");
-//
-// }
-// }
-// }
-//
-// // Check that we can walk in the current direction within any of the available
-// // walkable regions
-// for (int32 i = 0; i < areaPtr; i++) {
-// area = ws->actions[availableAreas[i]];
-// PolyDefinitions *region = &_scene->polygons()->entries[area->polyIdx];
-// if (region->contains(newX, newY)) {
-// x = newX;
-// y = newY;
-// break;
-// }
-// }
-//
-// setAction(newAction);
-// drawActor();
-//}
+ switch (_status) {
+ default:
+ break;
-void Actor::stopSound() {
- if (soundResourceId && _scene->vm()->sound()->isPlaying(soundResourceId))
- _scene->vm()->sound()->stopSound(soundResourceId);
-}
+ case kActorStatus16:
+ if (_scene->worldstats()->numChapter == 2) {
+ updateStatus16_Chapter2();
+ } else if (_scene->worldstats()->numChapter == 11 && _index == _scene->getPlayerActorIndex()) {
+ updateStatus16_Chapter11();
+ }
+ break;
-void Actor::setPosition(int32 newX, int32 newY, int32 newDirection, int32 frame) {
- x1 = newX - x2;
- y1 = newY - y2;
+ case kActorStatus17:
+ if (_scene->worldstats()->numChapter == 2) {
+ if (_index > 12) {
+ if (_frameNumber <= _frameCount - 1) {
+ ++_frameNumber;
+ } else {
+ setVisible(false);
+ _scene->getActor(_index + 9)->setVisible(false);
+ }
+ }
- if (direction != 8) {
- // TODO implement the propert character_setDirection() functionality
- setDirection(newDirection);
- }
- if (frame > 0)
- frameNum = frame;
-}
+ if (_index == 11) {
+ if (_frameNumber <= _frameCount - 1) {
+ // Looks like a simple check using the counter, since it doesn't seem to be used anywhere else
+ if (_actorUpdateCounter <= 0) {
+ ++_actorUpdateCounter;
+ } else {
+ _actorUpdateCounter = 0;
+ ++_frameNumber;
+ }
+ } else {
+ if (_scene->vm()->isGameFlagSet(kGameFlag556)) {
+ Sound *sound = _scene->vm()->sound();
+ Actor *player = _scene->getActor();
-void Actor::faceTarget(int32 targetId, DirectionFrom targetType) {
- int32 newX2, newY2;
+ sound->playSpeech(kResourceSpeech_453);
+ setVisible(false);
- printf("faceTarget: id %d type %d\n", targetId, targetType);
+ player->updateStatus(kActorStatus3);
+ player->setResourceId(player->getResourcesId(35));
+ player->setDirection(4);
+ GraphicResource *resource = new GraphicResource(_scene->getResourcePack(), player->getResourceId());
+ player->setFrameCount(resource->getFrameCount());
+ delete resource;
- if (targetType) {
- if (targetType == 1) {
- int32 actionIdx = _scene->worldstats()->getActionAreaIndexById(targetId);
- if (actionIdx == -1) {
- warning("No ActionArea found for id %d", targetId);
- return;
+ _scene->getCursor()->hide();
+ _scene->getActor(0)->updateFromDirection(4);
+
+ // Queue script
+ _scene->actions()->queueScript(_scene->worldstats()->getActionAreaById(2696)->scriptIndex, _scene->getPlayerActorIndex());
+
+ _scene->vm()->setGameFlag(kGameFlag279);
+ _scene->vm()->setGameFlag(kGameFlag368);
+
+ player->setFrameNumber(0);
+ _scene->getActor(0)->setTickValue(_scene->vm()->getTick());
+
+ if (sound->isCacheOk())
+ sound->playMusic(_scene->getResourcePack(), kResourceMusic_80020001);
+
+ _scene->worldstats()->musicCurrentResourceId = 1;
+
+ if (sound->isPlaying(_scene->worldstats()->soundResourceIds[7]))
+ sound->stopSound(_scene->worldstats()->soundResourceIds[7]);
+
+ if (sound->isPlaying(_scene->worldstats()->soundResourceIds[6]))
+ sound->stopSound(_scene->worldstats()->soundResourceIds[6]);
+
+ if (sound->isPlaying(_scene->worldstats()->soundResourceIds[5]))
+ sound->stopSound(_scene->worldstats()->soundResourceIds[5]);
+
+ _scene->vm()->setGameFlag(kGameFlag1131);
+ } else {
+ updateGraphicData(25);
+ _scene->vm()->setGameFlag(kGameFlag556);
+ }
+ }
}
- int32 polyIdx = _scene->worldstats()->actions[actionIdx]->polyIdx;
- PolyDefinitions *poly = &_scene->polygons()->entries[polyIdx];
+ if (_index == _scene->getPlayerActorIndex()) {
+ if (_frameNumber <= _frameCount - 1) {
+ ++_frameNumber;
+ } else {
+ _scene->vm()->clearGameFlag(kGameFlag239);
+ _scene->getActor(10)->updateStatus(kActorStatus14);
+ setVisible(false);
+ _scene->vm()->setGameFlag(kGameFlag238);
- newX2 = poly->boundingRect.left + (poly->boundingRect.right - poly->boundingRect.left) / 2;
- newY2 = poly->boundingRect.top + (poly->boundingRect.bottom - poly->boundingRect.top) / 2;
- } else {
- if (targetType == 2) {
- newX2 = x2 + x1;
- newY2 = y2 + y1;
- } else {
- newX2 = newY2 = targetId;
+ // Queue script
+ _scene->actions()->queueScript(_scene->worldstats()->getActionAreaById(1000)->scriptIndex, _scene->getPlayerActorIndex());
+ }
}
+
+ } else if (_scene->worldstats()->numChapter == 11) {
+ if (_index == _scene->getPlayerActorIndex()) {
+ if (_frameNumber <= _frameCount - 1)
+ ++_frameNumber;
+ else
+ _scene->resetActor0();
+ }
+
+ if (_index >= 10)
+ updateStatus17_Chapter2();
}
- } else {
- int32 barrierIdx = _scene->worldstats()->getBarrierIndexById(targetId);
- if (barrierIdx == -1) {
- warning("No Barrier found for id %d", targetId);
- return;
+ break;
+
+ case kActorStatus15:
+ if (_scene->worldstats()->numChapter == 2) {
+ if (_index > 12)
+ updateStatus15_Chapter2();
+
+ if (_index == _scene->getPlayerActorIndex())
+ updateStatus15_Chapter2_Player();
+
+ if (_index == 11)
+ updateStatus15_Chapter2_Actor11();
+
+ } else if (_scene->worldstats()->numChapter == 11) {
+ if (_index >= 10 && _index < 16)
+ updateStatus15_Chapter11();
+
+ if (_index == _scene->getPlayerActorIndex())
+ updateStatus15_Chapter11_Player();
}
+ break;
- Barrier *barrier = _scene->worldstats()->getBarrierByIndex(barrierIdx);
- GraphicResource *gra = new GraphicResource(_scene->getResourcePack(), barrier->resourceId);
-
- // FIXME
- // The original actually grabs the current frame of the target
- // barrier. I'm wondering if that's unnecessary since I'm assuming
- // the dimensions of each frame should be the same.
- // Investigate, though I don't think it'll be necessary since
- // what we're trying to accomplish is a character rotation calclulation,
- // and a size difference of a few pixels "shouldn't" affect this
- // too much
- GraphicFrame *fra = gra->getFrame(0);
- delete gra;
+ case kActorStatus18:
+ if (_scene->worldstats()->numChapter == 2) {
+ if (_index > 12)
+ updateStatus18_Chapter2();
- newX2 = (fra->surface.w >> 1) + barrier->x; // TODO (x/y + 1704 * barrier) (not sure what this is pointing to)
- newY2 = (fra->surface.h >> 1) + barrier->y; // Check .text:004088A2 for more details
- }
+ if (_index == 11)
+ updateStatus18_Chapter2_Actor11();
+ }
+ break;
- int32 newAngle = getAngle(x2 + x1, y2 + y1, newX2, newY2);
+ case kActorStatusDisabled:
+ _frameNumber = (_frameNumber + 1) % _frameCount;
- printf("Angle calculated as %d\n", newAngle);
+ if (_scene->vm()->getTick() - _tickValue > 300) {
+ if (_scene->vm()->getRandom(100) < 50) {
+ if (!_scene->vm()->sound()->soundResourceId || !_scene->vm()->sound()->isPlaying(_scene->vm()->sound()->soundResourceId)) {
+ if (isDefaultDirection(10))
+ updateStatus(kActorStatus9);
+ }
+ }
+ _tickValue = _scene->vm()->getTick();
+ }
+ break;
- // TODO set player direction
- //setDirection(newAngle);
-}
+ case kActorStatus12:
+ if (_scene->worldstats()->numChapter == 2) {
+ if (_index > 12)
+ updateStatus12_Chapter2();
-int32 Actor::getAngle(int32 ax1, int32 ay1, int32 ax2, int32 ay2) {
- int32 v5 = (ax2 << 16) - (ax1 << 16);
- int32 v6 = 0;
- int32 v4 = (ay1 << 16) - (ay2 << 16);
+ if (_index == 11)
+ updateStatus12_Chapter2_Actor11();
- if (v5 < 0) {
- v6 = 2;
- v5 = -v5;
- }
+ return;
+ } else if (_scene->worldstats()->numChapter == 11) {
+ switch (_index) {
+ default:
+ break;
- if (v4 < 0) {
- v6 |= 1;
- v4 = -v4;
- }
+ case 1:
+ updateStatus12_Chapter11_Actor1();
+ return;
- int32 v7;
- int32 v8 = -1;
+ case 10:
+ case 11:
+ case 12:
+ case 13:
+ case 14:
+ case 15:
+ updateStatus12_Chapter11();
+ return;
- if (v5) {
- v7 = (v4 << 8) / v5;
+ case 2:
+ case 3:
+ case 4:
+ case 5:
+ case 6:
+ case 7:
+ case 8:
+ return;
+ }
+ }
+ // Fallback to next case
- if (v7 < 0x100)
- v8 = angleTable01[v7];
- if (v7 < 0x1000 && v8 < 0)
- v8 = angleTable02[v7 >> 4];
- if (v7 < 0x10000 && v8 < 0)
- v8 = angleTable03[v7 >> 8];
- } else {
- v8 = 90;
- }
+ case kActorStatus1:
+ error("[Actor::update] kActorStatus1 / kActorStatus12 case not implemented");
+ break;
- switch (v6) {
- case 1:
- v8 = 360 - v8;
+ case kActorStatus2:
+ case kActorStatus13:
+ // TODO: do actor direction
+ error("[Actor::update] kActorStatus2 / kActorStatus13 case not implemented");
break;
- case 2:
- v8 = 180 - v8;
+
+ case kActorStatus3:
+ case kActorStatus19:
+ updateStatus3_19();
break;
- case 3:
- v8 += 180;
+
+ case kActorStatus7:
+ if (_enableFromStatus7) {
+ _enableFromStatus7 = false;
+ updateStatus(kActorStatusEnabled);
+ }
break;
- }
- if (v8 >= 360)
- v8 -= 360;
+ case kActorStatusEnabled:
+ if (_field_944 != 5)
+ updateStatusEnabled();
+ break;
- int32 result;
+ case kActorStatus14:
+ void updateStatus14();
+ break;
- if (v8 < 157 || v8 >= 202) {
- if (v8 < 112 || v8 >= 157) {
- if (v8 < 67 || v8 >= 112) {
- if (v8 < 22 || v8 >= 67) {
- if ((v8 < 0 || v8 >= 22) && (v8 < 337 || v8 > 359)) {
- if (v8 < 292 || v8 >= 337) {
- if (v8 < 247 || v8 >= 292) {
- if (v8 < 202 || v8 >= 247) {
- error("getAngle returned a bad angle: %d.", v8);
- result = ax1;
- } else {
- result = 3;
- }
- } else {
- result = 4;
- }
- } else {
- result = 5;
- }
- } else {
- result = 6;
- }
- } else {
- result = 7;
- }
- } else {
- result = 0;
- }
+ case kActorStatus21:
+ void updateStatus21();
+ break;
+
+ case kActorStatus9:
+ void updateStatus9();
+ break;
+
+ case kActorStatus6:
+ case kActorStatus10:
+ _frameNumber = (_frameNumber + 1) % _frameCount;
+ break;
+
+ case kActorStatus8:
+ if (_scene->vm()->encounter()->getFlag(kEncounterFlag2)
+ || !_soundResourceId
+ || _scene->vm()->sound()->isPlaying(_soundResourceId)) {
+ _frameNumber = (_frameNumber + 1) % _frameCount;
} else {
- result = 1;
+ updateStatus(kActorStatusEnabled);
+ _soundResourceId = kResourceNone;
}
- } else {
- result = 2;
+ break;
}
- return result;
-}
+ if (_soundResourceId && _scene->vm()->sound()->isPlaying(_soundResourceId))
+ setVolume();
-void Actor::updateDirection() {
- if(field_970) {
- // TODO
- // This update is only ever done if action script 0x5D is called, and
- // the resulting switch sets field_970. Investigate 401A30 for further
- // details
- error("[Actor::updateDirection] logic not implemented");
- }
+ if (_index != _scene->getPlayerActorIndex() && _scene->worldstats()->numChapter != 9)
+ error("[Actor::update] call to actor sound functions missing!");
+
+ updateDirection();
+
+ if (_field_944 != 5)
+ updateFinish();
}
+
void Actor::updateStatus(ActorStatus actorStatus) {
switch (actorStatus) {
default:
@@ -453,10 +440,18 @@ void Actor::updateStatus(ActorStatus actorStatus) {
case kActorStatus1:
case kActorStatus12:
- error("[Actor::updateStatus] not implemented for statuses 1 & 12");
- // TODO check if sceneNumber == 2 && actorIndex == _playerActorInde
- // && field_40 equals/doesn't equal a bunch of values,
- // then set direction like other cases
+ if ((_scene->worldstats()->numChapter == 2
+ && _index == _scene->getPlayerActorIndex() && (_status == kActorStatus18 || _status == kActorStatus16 || kActorStatus17))
+ || (_status != kActorStatusEnabled && _status != kActorStatus9 && _status != kActorStatus14 && _status != kActorStatus15 && _status != kActorStatus18))
+ return;
+
+ updateGraphicData(0);
+
+ // Force status in some cases
+ if (_status == kActorStatus14 || _status == kActorStatus15 || _status == kActorStatus18) {
+ _status = kActorStatus12;
+ return;
+ }
break;
case kActorStatus2:
@@ -466,8 +461,8 @@ void Actor::updateStatus(ActorStatus actorStatus) {
case kActorStatus3:
case kActorStatus19:
- if (!strcmp(name, "Big Crow"))
- status = kActorStatusEnabled;
+ if (!strcmp(_name, "Big Crow"))
+ _status = kActorStatusEnabled;
break;
case kActorStatusEnabled:
@@ -478,7 +473,7 @@ void Actor::updateStatus(ActorStatus actorStatus) {
case kActorStatusDisabled:
updateGraphicData(15);
- graphicResourceId = graphicResourceIds[(direction > 4 ? 8 - direction : direction) + 15];
+ _resourceId = _graphicResourceIds[(_direction > 4 ? 8 - _direction : _direction) + 15];
// TODO set word_446EE4 to -1. This global seems to be used with screen blitting
break;
@@ -488,7 +483,7 @@ void Actor::updateStatus(ActorStatus actorStatus) {
Actor *actor = _scene->getActor(0);
actor->x1 = x2 + x1 - actor->x2;
actor->y1 = y2 + y1 - actor->y2;
- actor->direction = 4;
+ actor->setDirection(4);
_scene->setPlayerActorIndex(0);
@@ -509,11 +504,10 @@ void Actor::updateStatus(ActorStatus actorStatus) {
break;
case kActorStatus9:
- error("[Actor::updateStatus] Encounter check missing for status 9");
- //if (_scene->vm()->encounter()->getFlag(kFlagEncounter3)
- // return;
+ if (_scene->vm()->encounter()->getFlag(kEncounterFlag2))
+ return;
- if (_scene->vm()->getRandomBit() == 1 && defaultDirectionLoaded(15))
+ if (_scene->vm()->getRandomBit() == 1 && isDefaultDirection(15))
updateGraphicData(15);
else
updateGraphicData(10);
@@ -527,218 +521,228 @@ void Actor::updateStatus(ActorStatus actorStatus) {
case kActorStatus18:
if (_scene->worldstats()->numChapter == 2) {
GraphicResource *resource = new GraphicResource();
- frameNum = 0;
+ _frameNumber = 0;
if (_index > 12)
- graphicResourceId = graphicResourceIds[direction + 30];
+ _resourceId = _graphicResourceIds[_direction + 30];
if (_scene->getPlayerActorIndex() == _index) {
- resource->load(_scene->getResourcePack(), graphicResourceId);
- frameNum = resource->getFrameCount() - 1;
+ resource->load(_scene->getResourcePack(), _resourceId);
+ _frameNumber = resource->getFrameCount() - 1;
}
if (_index == 11)
- graphicResourceId = graphicResourceIds[_scene->getGlobalDirection() > 4 ? 8 - _scene->getGlobalDirection() : _scene->getGlobalDirection()];
+ _resourceId = _graphicResourceIds[_scene->getGlobalDirection() > 4 ? 8 - _scene->getGlobalDirection() : _scene->getGlobalDirection()];
// Reload the graphic resource if the resource ID has changed
- if (resource->getResourceId() != graphicResourceId)
- resource->load(_scene->getResourcePack(), graphicResourceId);
+ if (resource->getResourceId() != _resourceId)
+ resource->load(_scene->getResourcePack(), _resourceId);
- frameCount = resource->getFrameCount();
+ _frameCount = resource->getFrameCount();
}
break;
}
- status = actorStatus;
+ _status = actorStatus;
}
-void Actor::updateGraphicData(uint32 offset) {
- graphicResourceId = graphicResourceIds[(direction > 4 ? 8 - direction : direction) + offset];
-
- GraphicResource *resource = new GraphicResource(_scene->getResourcePack(), graphicResourceId);
- frameCount = resource->getFrameCount();
- delete resource;
+/////////////////////////////////////////////////////////////////////////
+// Direction & position
+//////////////////////////////////////////////////////////////////////////
- frameNum = 0;
+void Actor::updateDirection() {
+ if(_field_970) {
+ // TODO
+ // This update is only ever done if action script 0x5D is called, and
+ // the resulting switch sets field_970. Investigate 401A30 for further
+ // details
+ error("[Actor::updateDirection] logic not implemented");
+ }
}
-void Actor::setDirection(int actorDirection) {
- direction = (actorDirection > 4) ? 8 - actorDirection : actorDirection;
- ResourceId resourceId;
+void Actor::updateFromDirection(ActorDirection actorDirection) {
+ _direction = actorDirection;
+
+ if (_field_944 == 5)
+ return;
+
+ switch (_status) {
+ default:
+ break;
+
+ case kActorStatusDisabled:
+ case kActorStatusEnabled:
+ case kActorStatus14: {
+ _resourceId = _graphicResourceIds[(actorDirection > 4 ? 8 - actorDirection : actorDirection) + 5];
- if (field_944 != 5) {
- switch (status) {
- case 0x04:
- case 0x05:
- case 0x0E: {
- resourceId = graphicResourceIds[direction + 5];
- // FIXME this seems kind of wasteful just to grab a frame count
- GraphicResource *gra = new GraphicResource(_scene->getResourcePack(), resourceId);
- resourceId = resourceId;
- frameCount = gra->getFrameCount();
- delete gra;
+ // FIXME this seems kind of wasteful just to grab a frame count
+ GraphicResource *gra = new GraphicResource(_scene->getResourcePack(), _resourceId);
+ _frameCount = gra->getFrameCount();
+ delete gra;
}
break;
- case 0x12:
- if (_scene->worldstats()->numChapter == 2) {
- if (_scene->getPlayerActorIndex() == 11) {
- // NOTE this is supposed to explicitely point to the actor 11 reference,
- // (_ws->actors[11])
- // but I'm assuming if control drops through to here, getActor() would
- // pull the right object because the _playerActorIndex should == 11
- if (direction > 4)
- resourceId = graphicResourceIds[8 - direction];
- else
- resourceId = graphicResourceIds[direction];
- }
+ case kActorStatus18:
+ if (_scene->worldstats()->numChapter == 2) {
+ if (_index == 11) { // we are actor 11
+ if (actorDirection > 4)
+ _resourceId = _graphicResourceIds[8 - actorDirection];
+ else
+ _resourceId = _graphicResourceIds[actorDirection];
}
- break;
- case 0x01:
- case 0x02:
- case 0x0C:
- resourceId = graphicResourceIds[direction];
- break;
- case 0x08:
- resourceId = graphicResourceIds[direction + 20];
- break;
- default:
- warning ("[setActorDirection] default case hit with status of %d", status);
}
+ break;
+
+ case kActorStatus1:
+ case kActorStatus2:
+ case kActorStatus12:
+ _resourceId = _graphicResourceIds[(actorDirection > 4 ? 8 - actorDirection : actorDirection)];
+ break;
+
+ case kActorStatus8:
+ _resourceId = _graphicResourceIds[(actorDirection > 4 ? 8 - actorDirection : actorDirection) + 20];
+ break;
}
}
-void Actor::update() {
- if (isVisible()) {
- // printf("Actor updateType = 0x%02X\n", actor->updateType);
-
- switch (status) {
-
- case 0x10:
- if (_scene->worldstats()->numChapter == 2) {
- // TODO: updateCharacterSub14()
- error("[Actor::update] not implemented");
- } else if (_scene->worldstats()->numChapter == 1) {
- if (_scene->getPlayerActorIndex() == _index) {
- // TODO: updateActorSub21();
- error("[Actor::update] not implemented");
- }
- }
- break;
-
- case 0x11:
- if (_scene->worldstats()->numChapter == 2) {
- // TODO: put code here
- error("[Actor::update] not implemented");
- } else if (_scene->worldstats()->numChapter == 11) {
- if (_scene->getPlayerActorIndex() == _index) {
- // TODO: put code here
- error("[Actor::update] not implemented");
- }
- }
- break;
-
- case 0xF:
- if (_scene->worldstats()->numChapter == 2) {
- // TODO: put code here
- error("[Actor::update] not implemented");
- } else if (_scene->worldstats()->numChapter == 11) {
- // TODO: put code here
- error("[Actor::update] not implemented");
- }
- break;
+void Actor::faceTarget(int32 targetId, DirectionFrom from) {
+ debugC(kDebugLevelActor, "[Actor::faceTarget] Facing target %d using direction from %d", targetId, from);
- case 0x12:
- if (_scene->worldstats()->numChapter == 2) {
- // TODO: put code here
- error("[Actor::update] not implemented");
- }
- break;
+ int32 newX, newY;
- case 0x5:
- frameNum = (frameNum + 1) % frameCount;
+ switch (from) {
+ default:
+ error("[Actor::faceTarget] Invalid direction input: %d (should be 0-3)", from);
+ return;
- if (_scene->vm()->getTick() - tickValue > 300) {
- if (_scene->vm()->getRandom(100) < 50) {
- // TODO: check sound playing
- error("[Actor::update] not implemented");
- }
- tickValue = _scene->vm()->getTick();
- }
- break;
-
- case 0xC:
- if (_scene->worldstats()->numChapter == 2) {
- // TODO: put code here
- error("[Actor::update] not implemented");
- } else if (_scene->worldstats()->numChapter == 11) {
- // TODO: put code here
- error("[Actor::update] not implemented");
- }
- //FIXME Missing break?
- case 0x1:
- // TODO: do actor direction
- error("[Actor::update] not implemented");
- break;
-
- case 0x2:
- case 0xD:
- // TODO: do actor direction
- error("[Actor::update] not implemented");
- break;
-
- case 0x3:
- case 0x13:
- // TODO: updateCharacterSub05();
- error("[Actor::update] not implemented");
- break;
-
- case 0x7:
- // TODO: something
- error("[Actor::update] not implemented");
- break;
-
- case 0x4:
- if (field_944 != 5) {
- updateActorSub01();
- }
- break;
-
- case 0xE:
- // TODO: updateCharacterSub02(1, actorIdx);
- error("[Actor::update] not implemented");
- break;
-
- case 0x15:
- // TODO: updateCharacterSub06(1, actorIdx);
- error("[Actor::update] not implemented");
- break;
-
- case 0x9:
- // TODO: updateCharacterSub03(1, actorIdx);
- error("[Actor::update] not implemented");
- break;
-
- case 0x6:
- case 0xA:
- frameNum = (frameNum + 1) % frameCount;
- break;
-
- case 0x8:
- // TODO: actor sound
- error("[Actor::update] not implemented");
- break;
-
- default:
- break;
+ case kDirectionFromBarrier: {
+ int32 barrierIndex = _scene->worldstats()->getBarrierIndexById(targetId);
+ if (barrierIndex == -1) {
+ warning("[Actor::faceTarget] No Barrier found for id %d", targetId);
+ return;
+ }
+
+ Barrier *barrier = _scene->worldstats()->getBarrierByIndex(barrierIndex);
+
+ GraphicResource *resource = new GraphicResource(_scene->getResourcePack(), barrier->resourceId);
+ GraphicFrame *frame = resource->getFrame(barrier->frameIdx);
+
+ newX = (frame->surface.w >> 1) + barrier->x;
+ newY = (frame->surface.h >> 1) + barrier->y;
+
+ delete resource;
+ }
+ break;
+
+ case kDirectionFromPolygons: {
+ int32 actionIndex = _scene->worldstats()->getActionAreaIndexById(targetId);
+ if (actionIndex == -1) {
+ warning("[Actor::faceTarget] No ActionArea found for id %d", targetId);
+ return;
}
+
+ PolyDefinitions *polygon = &_scene->polygons()->entries[_scene->worldstats()->actions[actionIndex]->polyIdx];
+
+ newX = polygon->boundingRect.left + (polygon->boundingRect.right - polygon->boundingRect.left) / 2;
+ newY = polygon->boundingRect.top + (polygon->boundingRect.bottom - polygon->boundingRect.top) / 2;
+ }
+ break;
+
+ case kDirectionFromActor:
+ newX = x2 + x1;
+ newY = y2 + y1;
+ break;
+
+ case kDirectionFromParameters:
+ newX = newY = targetId;
+ break;
+ }
+
+ updateFromDirection(getDirection(x2 + x1, y2 + y1, newX, newY));
+}
+
+void Actor::setPosition(int32 newX, int32 newY, int32 newDirection, int32 frame) {
+ x1 = newX - x2;
+ y1 = newY - y2;
+
+ if (_direction != 8)
+ updateFromDirection(newDirection);
+
+ if (frame > 0)
+ _frameNumber = frame;
+}
+
+
+/////////////////////////////////////////////////////////////////////////
+// Misc
+//////////////////////////////////////////////////////////////////////////
+void Actor::stopSound() {
+ if (_soundResourceId && _scene->vm()->sound()->isPlaying(_soundResourceId))
+ _scene->vm()->sound()->stopSound(_soundResourceId);
+}
+
+void Actor::setRawResources(uint8 *data) {
+ byte *dataPtr = data;
+
+ for (int32 i = 0; i < 60; i++) {
+ _resources[i] = (int32)READ_LE_UINT32(dataPtr);
+ dataPtr += 4;
}
}
-void Actor::updateActorSub01() {
+//////////////////////////////////////////////////////////////////////////
+// Unknown methods
+//////////////////////////////////////////////////////////////////////////
+
+bool Actor::process(int32 x, int32 y) {
+ error("[Actor::process] not implemented!");
+}
+
+void Actor::processStatus(int32 x, int32 y, bool doSpeech) {
+ if (process(x, y)) {
+ if (_status <= kActorStatus11)
+ updateStatus(kActorStatus2);
+ else
+ updateStatus(kActorStatus13);
+ } else if (doSpeech) {
+ _scene->playSpeech(1);
+ }
+}
+
+void Actor::process_401830(int32 field980, int32 actionAreaId, int32 field978, int field98C, int32 field990, int32 field974, int32 param8, int32 param9) {
+ error("[Actor::process_401830] not implemented!");
+}
+
+bool Actor::process_408B20(Common::Point *point, ActorDirection direction, int count, bool hasDelta) {
+ error("[Actor::process_408B20] not implemented!");
+}
+
+void Actor::process_41BC00(int32 reactionIndex, int32 numberValue01Add) {
+ error("[Actor::process_41BC00] not implemented!");
+}
+
+void Actor::process_41BCC0(int32 reactionIndex, int32 numberValue01Substract) {
+ error("[Actor::process_41BC00] not implemented!");
+}
+
+bool Actor::process_41BDB0(int32 reactionIndex, bool testNumberValue01) {
+ error("[Actor::process_41BC00] not implemented!");
+}
+
+
+
+//////////////////////////////////////////////////////////////////////////
+// Update methods
+//////////////////////////////////////////////////////////////////////////
+
+void Actor::updateStatus3_19() {
+ error("[Actor::updateStatus3_19] not implemented!");
+}
+
+void Actor::updateStatusEnabled() {
// TODO make sure this is right
- frameNum = (frameNum + 1) % frameCount;
- if (_scene->vm()->getTick() - tickValue > 300) {
+ _frameNumber = (_frameNumber + 1) % _frameCount;
+ if (_scene->vm()->getTick() - _tickValue > 300) {
// TODO
// Check if the actor's name is "Crow"?
if (_scene->vm()->getRandom(100) < 50) {
@@ -767,7 +771,7 @@ void Actor::updateActorSub01() {
}
}
}
- tickValue = _scene->vm()->getTick();
+ _tickValue = _scene->vm()->getTick();
}
// else
// TODO now there's something to do with the
@@ -778,48 +782,194 @@ void Actor::updateActorSub01() {
// one off situation).
}
+void Actor::updateStatus9() {
+ error("[Actor::updateStatus9] not implemented!");
+}
-bool Actor::defaultDirectionLoaded(int grResTableIdx) {
- return graphicResourceIds[grResTableIdx] != graphicResourceIds[5];
+void Actor::updateStatus12_Chapter2() {
+ error("[Actor::updateStatus12_Chapter2] not implemented!");
}
-bool Actor::process(int32 x, int32 y) {
- error("[Actor::process] not implemented!");
+void Actor::updateStatus12_Chapter2_Actor11() {
+ error("[Actor::updateStatus12_Chapter2_Actor11] not implemented!");
}
-void Actor::processStatus(int32 x, int32 y, bool doSpeech) {
- if (process(x, y)) {
- if (status < kActorStatus11)
- updateStatus(kActorStatus2);
- else
- updateStatus(kActorStatus13);
- } else if (doSpeech) {
- _scene->playSpeech(1);
- }
+void Actor::updateStatus12_Chapter11_Actor1() {
+ error("[Actor::updateStatus12_Chapter11_Actor1] not implemented!");
+}
+
+void Actor::updateStatus12_Chapter11() {
+ error("[Actor::updateStatus12_Chapter11] not implemented!");
+}
+
+void Actor::updateStatus14() {
+ error("[Actor::updateStatus14] not implemented!");
+}
+
+void Actor::updateStatus15_Chapter2() {
+ error("[Actor::updateStatus15_Chapter2] not implemented!");
+}
+
+void Actor::updateStatus15_Chapter2_Player() {
+ error("[Actor::updateStatus15_Chapter2_Player] not implemented!");
+}
+
+void Actor::updateStatus15_Chapter2_Actor11() {
+ error("[Actor::updateStatus15_Chapter2_Actor11] not implemented!");
+}
+
+void Actor::updateStatus15_Chapter11() {
+ error("[Actor::updateStatus15_Chapter11] not implemented!");
+}
+
+void Actor::updateStatus15_Chapter11_Player() {
+ error("[Actor::updateStatus15_Chapter11_Player] not implemented!");
+}
+
+void Actor::updateStatus16_Chapter2() {
+ error("[Actor::updateStatus16_Chapter2] not implemented!");
+}
+
+void Actor::updateStatus16_Chapter11() {
+ error("[Actor::updateStatus16_Chapter11] not implemented!");
+}
+
+void Actor::updateStatus17_Chapter2() {
+ error("[Actor::updateStatus17_Chapter2] not implemented!");
+}
+
+void Actor::updateStatus18_Chapter2() {
+ error("[Actor::updateStatus18_Chapter2] not implemented!");
+}
+
+void Actor::updateStatus18_Chapter2_Actor11() {
+ error("[Actor::updateStatus18_Chapter2_Actor11] not implemented!");
+}
+
+void Actor::updateStatus21() {
+ error("[Actor::updateStatus21] not implemented!");
+}
+
+void Actor::updateFinish() {
+ error("[Actor::updateFinish] not implemented!");
}
//////////////////////////////////////////////////////////////////////////
-// Unknown methods
+// Misc
//////////////////////////////////////////////////////////////////////////
+void Actor::setVolume() {
+ if (!_soundResourceId || !_scene->vm()->sound()->isPlaying(_soundResourceId))
+ return;
-void Actor::process_401830(int32 field980, int32 actionAreaId, int32 field978, int field98C, int32 field990, int32 field974, int32 param8, int32 param9) {
- error("[Actor::process_401830] not implemented!");
-}
+ // Compute volume
+ int32 volume = Config.voiceVolume + _scene->vm()->sound()->calculateVolume(x2 + x1, y2 + y1, _field_968, 0);
+ if (volume < -10000)
+ volume = -10000;
-bool Actor::process_408B20(Common::Point *point, ActorDirection direction, int count, bool hasDelta) {
- error("[Actor::process_408B20] not implemented!");
+ _scene->vm()->sound()->setVolume(_soundResourceId, volume);
}
-void Actor::process_41BC00(int32 reactionIndex, int32 numberValue01Add) {
- error("[Actor::process_41BC00] not implemented!");
+//////////////////////////////////////////////////////////////////////////
+// Helper methods
+//////////////////////////////////////////////////////////////////////////
+
+ActorDirection Actor::getDirection(int32 ax1, int32 ay1, int32 ax2, int32 ay2) {
+ int32 v5 = (ax2 << 16) - (ax1 << 16);
+ int32 v6 = 0;
+ int32 v4 = (ay1 << 16) - (ay2 << 16);
+
+ if (v5 < 0) {
+ v6 = 2;
+ v5 = -v5;
+ }
+
+ if (v4 < 0) {
+ v6 |= 1;
+ v4 = -v4;
+ }
+
+ int32 v7;
+ int32 v8 = -1;
+
+ if (v5) {
+ v7 = (v4 << 8) / v5;
+
+ if (v7 < 0x100)
+ v8 = angleTable01[v7];
+ if (v7 < 0x1000 && v8 < 0)
+ v8 = angleTable02[v7 >> 4];
+ if (v7 < 0x10000 && v8 < 0)
+ v8 = angleTable03[v7 >> 8];
+ } else {
+ v8 = 90;
+ }
+
+ switch (v6) {
+ case 1:
+ v8 = 360 - v8;
+ break;
+ case 2:
+ v8 = 180 - v8;
+ break;
+ case 3:
+ v8 += 180;
+ break;
+ }
+
+ if (v8 >= 360)
+ v8 -= 360;
+
+ int32 result;
+
+ if (v8 < 157 || v8 >= 202) {
+ if (v8 < 112 || v8 >= 157) {
+ if (v8 < 67 || v8 >= 112) {
+ if (v8 < 22 || v8 >= 67) {
+ if ((v8 < 0 || v8 >= 22) && (v8 < 337 || v8 > 359)) {
+ if (v8 < 292 || v8 >= 337) {
+ if (v8 < 247 || v8 >= 292) {
+ if (v8 < 202 || v8 >= 247) {
+ error("getAngle returned a bad angle: %d.", v8);
+ } else {
+ result = 3;
+ }
+ } else {
+ result = 4;
+ }
+ } else {
+ result = 5;
+ }
+ } else {
+ result = 6;
+ }
+ } else {
+ result = 7;
+ }
+ } else {
+ result = 0;
+ }
+ } else {
+ result = 1;
+ }
+ } else {
+ result = 2;
+ }
+
+ return result;
}
-void Actor::process_41BCC0(int32 reactionIndex, int32 numberValue01Substract) {
- error("[Actor::process_41BC00] not implemented!");
+void Actor::updateGraphicData(uint32 offset) {
+ _resourceId = _graphicResourceIds[(_direction > 4 ? 8 - _direction : _direction) + offset];
+
+ GraphicResource *resource = new GraphicResource(_scene->getResourcePack(), _resourceId);
+ _frameCount = resource->getFrameCount();
+ delete resource;
+
+ _frameNumber = 0;
}
-bool Actor::process_41BDB0(int32 reactionIndex, bool testNumberValue01) {
- error("[Actor::process_41BC00] not implemented!");
+bool Actor::isDefaultDirection(int index) {
+ return _graphicResourceIds[index] != _graphicResourceIds[5];
}
} // end of namespace Asylum
diff --git a/engines/asylum/resources/actor.h b/engines/asylum/resources/actor.h
index 07abfaa091..7e6f545331 100644
--- a/engines/asylum/resources/actor.h
+++ b/engines/asylum/resources/actor.h
@@ -26,314 +26,315 @@
#ifndef ASYLUM_ACTOR_H
#define ASYLUM_ACTOR_H
-#include "asylum/system/graphics.h"
-
#include "asylum/respack.h"
#include "asylum/shared.h"
+#include "common/rect.h"
+
namespace Asylum {
+class ActionArea;
+struct GraphicFrame;
+class GraphicResource;
class Scene;
class Screen;
-class ActionArea;
-
-typedef int ActorIndex;
-
-enum ActorIndexes {
- kActorPlayer = -1
-};
-
-enum ActorStatus {
- kActorStatus1 = 1,
- kActorStatus2,
- kActorStatus3,
- kActorStatusEnabled,
- kActorStatusDisabled,
- kActorStatus6,
- kActorStatus7,
- kActorStatus8,
- kActorStatus9,
- kActorStatus10,
- kActorStatus11,
- kActorStatus12,
- kActorStatus13,
- kActorStatus14,
- kActorStatus15,
- kActorStatus16,
- kActorStatus17,
- kActorStatus18,
- kActorStatus19,
- kActorStatus20,
- kActorStatus21
-};
-
-typedef int ActorDirection;
-
-// TODO: check if the names match the actor type
-enum ActorType {
- kMax = 0,
- kSarah = 1,
- kCyclops = 2,
- kAztec = 3
-};
-
-enum ActorFlags {
- kActorFlagVisible = 1
-};
-
-enum DirectionFrom {
- kDirectionFromBarrier = 0,
- kDirectionFromPolygons = 1,
- kDirectionFromActor = 2,
- kDirectionFromParameters = 3
-};
-
-// TODO investigate other actor resources (from other
-// scenes) to see if the unused blocks in the actor
-// definition are in fact used elsewhere
-enum ActorResources {
- kSound1 = 0,
- kSound2 = 1,
- kSound3 = 2,
- kSound4 = 3,
- //kUnused = 4, // 0
- kFlags = 5,
-
- kWalkN = 6,
- kWalkNW = 7,
- kWalkW = 8,
- kWalkSW = 9,
- kWalkS = 10,
-
- kFaceN = 11,
- kFaceNW = 12,
- kFaceW = 13,
- kFaceSW = 14,
- kFaceS = 15,
-
- kFaceAndShakeN = 16,
- kFaceAndShakeNW = 17,
- kFaceAndShakeW = 18,
- kFaceAndShakeSW = 19,
- kFaceAndShakeS = 20,
-
- kStretchN = 21,
- kStretchNW = 22,
- kStretchW = 23,
- kStretchSW = 24,
- kStretchS = 25,
-
- kFidgetN = 26,
- kFidgetNW = 27,
- kFidgetW = 28,
- kFidgetSW = 29,
- kFidgetS = 30,
-
- // These are 0
- /*
- kUnknown1 = 31,
- kUnknown2 = 32,
- kUnknown3 = 33,
- kUnknown4 = 34,
- kUnknown5 = 35,
- */
-
- kPickupN = 36,
- kPickupNW = 37,
- kPickupW = 38,
- kPickupSW = 39,
- kPickupS = 40,
-
- kOperateN = 41,
- kOperateNW = 42,
- kOperateW = 43,
- kOperateSW = 44,
- kOperateS = 45,
-
- kOperate2N = 46,
- kOperate2NW = 47,
- kOperate2W = 48,
- kOperate2SW = 49,
- kOperate2S = 50,
-
- // These are 0
- /*
- kUnknown6 = 51,
- kUnknown7 = 52,
- kUnknown8 = 53,
- kUnknown9 = 54,
- kUnknown10 = 55,
- kUnknown11 = 56,
- kUnknown12 = 57,
- kUnknown13 = 58,
- kUnknown14 = 59
- */
-
- // Horizontally flipped animations (100 + regular anim Id)
- kWalkNE = 107,
- kWalkE = 108,
- kWalkSE = 109,
-
- kFaceNE = 112,
- kFaceE = 113,
- kFaceSE = 114
- // TODO: finish these
-};
class Actor {
public:
Actor(Scene *scene, ActorIndex index);
virtual ~Actor();
+ //////////////////////////////////////////////////////////////////////////
+ // Public variables & accessors
+ //////////////////////////////////////////////////////////////////////////
+ int32 x;
+ int32 y;
+ int32 x1;
+ int32 y1;
+ int32 x2;
+ int32 y2;
+ int32 flags;
+ int32 actionType; // ActionType enum value
+
+
+ void setActionIndex2(int32 index) { _actionIdx2 = index; }
+ void setBarrierIndex(int32 index) { _field_3C = index; }
+ void setDirection(ActorDirection direction) { _direction = direction; }
+ void setFrameCount(int32 count) { _frameCount = count; }
+ void setFrameNumber(int32 number) { _frameNumber = number; }
+ void setPriority(int32 priority) { _priority = priority; }
+ void setResourceId(ResourceId id) { _resourceId = id; }
+ void setStatus(ActorStatus status) { _status = status; }
+ void setTickValue(int32 tick) { _tickValue = tick; }
+
+ void setField638(int32 val) { _field_638 = val; }
+ void setField934(int32 val) { _field_934 = val; }
+ void setField938(int32 val) { _field_938 = val; }
+ void setField944(int32 val) { _field_944 = val; }
+ void setField96C(int32 val) { _field_96C = val; }
+
+ int32 getActionIndex3() { return _actionIdx3; }
+ Common::Rect *getBoundingRect() { return &_boundingRect; }
+ ActorDirection getDirection() { return _direction; }
+ int32 getFrameCount() { return _frameCount; }
+ int32 getFrameNum() { return _frameNumber; }
+ int32 getReaction(uint32 index) { return _reaction[index]; }
+ ResourceId getResourceId() { return _resourceId; }
+ ResourceId getResourcesId(uint32 index) { return _graphicResourceIds[index]; }
+ ActorStatus getStatus() { return _status; }
+
+ int32 getField638() { return _field_638; }
+ int32 getField944() { return _field_944; }
+ int32 getField96C() { return _field_96C; }
+ int32 getPriority() { return _priority; }
+
+ /////////////////////////////////////////////////////////////////////////
+ // Data
+ /////////////////////////////////////////////////////////////////////////
+ void load(Common::SeekableReadStream *stream);
+
+ /////////////////////////////////////////////////////////////////////////
+ // Visibility
+ /////////////////////////////////////////////////////////////////////////
+
/**
- * Initialize the 500 byte resource index from the scene
- * file (at offset 0xA73B6).
+ * Query if this actor is visible.
*
- * TODO remove this or add it in the right place
+ * @return true if visible, false if not.
*/
- void setRawResources(uint8* data);
-
- // Visibility
bool isVisible() { return flags & kActorFlagVisible; }
- void setVisible(bool value);
- /** .text:0040A260
- * Initialize the x1/y1 values of the actor, update the active animation frame
- * and, if the current direction isn't 8, update the actor's direction
+ /**
+ * Sets actor visibility
+ *
+ * @param value true to set to visible, false to set to hidden.
*/
- void setPosition(int32 newX, int32 newY, int32 newDirection, int32 frame);
+ void setVisible(bool value);
- void faceTarget(int32 targetId, DirectionFrom targetType);
+ /////////////////////////////////////////////////////////////////////////
+ // Update & status
+ //////////////////////////////////////////////////////////////////////////
+ /**
+ * Updates the actor.
+ */
void update();
- /** .text:00401320
- * TODO
+ /**
+ * Updates the actor status.
+ *
+ * @param status The status.
+ */
+ void updateStatus(ActorStatus status);
+
+ /////////////////////////////////////////////////////////////////////////
+ // Direction & position
+ /////////////////////////////////////////////////////////////////////////
+
+ /**
+ * Updates the actor direction.
*/
void updateDirection();
- void setDirection(ActorDirection direction);
- void updateStatus(ActorStatus status);
+ /**
+ * Updates resource Id using the actor direction.
+ *
+ * @param direction The direction.
+ */
+ void updateFromDirection(ActorDirection direction);
- bool defaultDirectionLoaded(int grResTableIdx);
+ /**
+ * Face a target from a certain direction
+ *
+ * @param target Identifier for the target.
+ * @param from direction to face from.
+ */
+ void faceTarget(int32 target, DirectionFrom from);
+
+ /**
+ * Initialize the x1/y1 values of the actor, update the active animation frame and, if the current direction isn't 8, update the actor's direction.
+ *
+ * @param newX The new x coordinate.
+ * @param newY The new y coordinate.
+ * @param newDirection The new direction.
+ * @param frame The frame.
+ */
+ void setPosition(int32 newX, int32 newY, int32 newDirection, int32 frame);
+
+ /////////////////////////////////////////////////////////////////////////
+ // Misc
+ /////////////////////////////////////////////////////////////////////////
+ /**
+ * Stop the actor related sounds
+ */
void stopSound();
- bool process(int32 x, int32 y);
- void processStatus(int32 x, int32 y, bool doSpeech);
+
+ /**
+ * Clears actor data fields (TODO what are those fields?)
+ */
+ void clearFields() { memset(&_field_970, 0, 52); }
+
+ /**
+ * TEMPORARY: Initialize the 500 byte resource index from the scene
+ * file (at offset 0xA73B6).
+ *
+ * TODO remove this or add it in the right place
+ */
+ void setRawResources(uint8* data);
// Unknown methods
+ bool process(int32 x, int32 y);
+ void processStatus(int32 x, int32 y, bool doSpeech);
void process_401830(int32 field980, int32 actionAreaId, int32 field978, int field98C, int32 field990, int32 field974, int32 param8, int32 param9);
bool process_408B20(Common::Point *point, ActorDirection direction, int count, bool hasDelta);
void process_41BC00(int32 reactionIndex, int32 numberValue01Add);
void process_41BCC0(int32 reactionIndex, int32 numberValue01Substract);
bool process_41BDB0(int32 reactionIndex, bool testNumberValue01);
- //////////////////////////////////////////////////////////////////////////
- // OLD METHODS
- // TODO ALL of these need to be depreciated in favour
- // of the proper functions from the original
- //void setWalkArea(ActionArea *target);
- //void setAction(int32 action);
- //void setActionByIndex(int32 index);
- //void drawActorAt(int32 curX, int32 curY);
- //void drawActor();
- //void walkTo(int32 curX, int32 curY);
- //////////////////////////////////////////////////////////////////////////
-
-
+private:
+ Scene *_scene;
+ // Our current index
+ ActorIndex _index;
- int32 currentAction; // TODO depreciate
+ // Temporary raw resources
+ int32 _resources[61];
- int32 x;
- int32 y;
- ResourceId graphicResourceId;
- int32 field_C; // BarrierIndex? Mask index?
- uint32 frameNum;
- uint32 frameCount;
- int32 x1;
- int32 y1;
- int32 x2;
- int32 y2;
- Common::Rect boundingRect;
- ActorDirection direction;
- int32 field_3C;
- ActorStatus status;
- int32 field_44;
- int32 priority;
- int32 flags;
- int32 field_50;
- int32 field_54;
- int32 field_58;
- int32 field_5C;
- int32 field_60;
- int32 actionIdx3;
+ //////////////////////////////////////////////////////////////////////////
+ // Data
+
+ ResourceId _resourceId;
+ int32 _field_C; // BarrierIndex? Mask index?
+ uint32 _frameNumber;
+ uint32 _frameCount;
+ // x1, y1, x2, y2
+ Common::Rect _boundingRect;
+ ActorDirection _direction;
+ int32 _field_3C;
+ ActorStatus _status;
+ int32 _field_44;
+ int32 _priority;
+ //flags
+ int32 _field_50;
+ int32 _field_54;
+ int32 _field_58;
+ int32 _field_5C;
+ int32 _field_60;
+ int32 _actionIdx3;
// TODO field_68 till field_617
- int32 reaction[8];
- int32 field_638;
- int32 walkingSound1;
- int32 walkingSound2;
- int32 walkingSound3;
- int32 walkingSound4;
- int32 field_64C;
- int32 field_650;
- ResourceId graphicResourceIds[55];
- char name[256];
- int32 field_830[20];
- int32 field_880[20];
- int32 field_8D0[20];
- int32 actionIdx2;
- int32 field_924;
- int32 tickValue;
- int32 field_92C;
- int32 actionType;
- int32 field_934;
- int32 field_938;
- ResourceId soundResourceId; // field_93C
- int32 numberValue01;
- int32 field_944;
- int32 field_948;
- int32 field_94C;
- int32 numberFlag01;
- int32 numberStringWidth;
- int32 numberStringX;
- int32 numberStringY;
- char numberString01[8];
- int32 field_964;
- int32 field_968;
- int32 field_96C;
- int32 field_970;
- int32 field_974;
- int32 field_978;
- int32 actionIdx1;
- int32 field_980;
- int32 field_984;
- int32 field_988;
- int32 field_98C;
- int32 field_990;
- int32 field_994;
- int32 field_998;
- int32 field_99C;
- int32 field_9A0;
+ int32 _reaction[8];
+ int32 _field_638;
+ int32 _walkingSound1;
+ int32 _walkingSound2;
+ int32 _walkingSound3;
+ int32 _walkingSound4;
+ int32 _field_64C;
+ int32 _field_650;
+ ResourceId _graphicResourceIds[55];
+ char _name[256];
+ int32 _field_830[20];
+ int32 _field_880[20];
+ int32 _field_8D0[20];
+ int32 _actionIdx2;
+ int32 _field_924;
+ int32 _tickValue;
+ int32 _field_92C;
+ //actionType
+ int32 _field_934;
+ int32 _field_938;
+ ResourceId _soundResourceId; // field_93C
+ int32 _numberValue01;
+ int32 _field_944;
+ int32 _field_948;
+ int32 _field_94C;
+ int32 _numberFlag01;
+ int32 _numberStringWidth;
+ int32 _numberStringX;
+ int32 _numberStringY;
+ char _numberString01[8];
+ int32 _field_964;
+ int32 _field_968;
+ int32 _field_96C;
+ int32 _field_970;
+ int32 _field_974;
+ int32 _field_978;
+ int32 _actionIdx1;
+ int32 _field_980;
+ int32 _field_984;
+ int32 _field_988;
+ int32 _field_98C;
+ int32 _field_990;
+ int32 _field_994;
+ int32 _field_998;
+ int32 _field_99C;
+ int32 _field_9A0;
-private:
- Scene *_scene;
- int32 _resources[61];
+ //////////////////////////////////////////////////////////////////////////
+ // Update methods
+ //////////////////////////////////////////////////////////////////////////
+ int32 _actorUpdateCounter;
+ bool _enableFromStatus7;
+
+ void updateStatus3_19();
+ void updateStatusEnabled();
+ void updateStatus9();
+ void updateStatus12_Chapter2();
+ void updateStatus12_Chapter2_Actor11();
+ void updateStatus12_Chapter11_Actor1();
+ void updateStatus12_Chapter11();
+ void updateStatus14();
+ void updateStatus15_Chapter2();
+ void updateStatus15_Chapter2_Player();
+ void updateStatus15_Chapter2_Actor11();
+ void updateStatus15_Chapter11();
+ void updateStatus15_Chapter11_Player();
+ void updateStatus16_Chapter2();
+ void updateStatus16_Chapter11();
+ void updateStatus17_Chapter2();
+ void updateStatus18_Chapter2();
+ void updateStatus18_Chapter2_Actor11();
+ void updateStatus21();
+
+ void updateFinish();
- ActionArea *_currentWalkArea;
- GraphicResource *_graphic;
+ //////////////////////////////////////////////////////////////////////////
+ // Misc
+ //////////////////////////////////////////////////////////////////////////
+ void setVolume();
- // Our current index
- ActorIndex _index;
+ //////////////////////////////////////////////////////////////////////////
+ // Helper methods
+ //////////////////////////////////////////////////////////////////////////
- GraphicFrame *getFrame();
- int32 getAngle(int32 ax1, int32 ay1, int32 ax2, int32 ay2);
+ /**
+ * Gets a direction using the angle between the two points
+ *
+ * @param ax1 The first ax.
+ * @param ay1 The first ay.
+ * @param ax2 The second ax.
+ * @param ay2 The second ay.
+ *
+ * @return The angle.
+ */
+ ActorDirection getDirection(int32 ax1, int32 ay1, int32 ax2, int32 ay2);
+ /**
+ * Updates the actor graphic information
+ *
+ * @param offset The offset used to get the id from the _graphicResourceIds table
+ */
void updateGraphicData(uint32 offset);
/**
- * TODO give more meaningful name
+ * Query if the passed direction is default direction.
+ *
+ * @param index Zero-based index of the graphic resource.
+ *
+ * @return true if default direction, false if not.
*/
- void updateActorSub01();
+ bool isDefaultDirection(int index);
+
+
}; // end of class MainActor
diff --git a/engines/asylum/resources/worldstats.cpp b/engines/asylum/resources/worldstats.cpp
index 84558294c1..b3370a5d5b 100644
--- a/engines/asylum/resources/worldstats.cpp
+++ b/engines/asylum/resources/worldstats.cpp
@@ -302,100 +302,7 @@ void WorldStats::load(Common::SeekableReadStream *stream) {
for (ActorIndex index = 0; index < numActors; index++) {
Actor *actor = new Actor(_scene, index);
-
- actor->x = stream->readSint32LE();
- actor->y = stream->readSint32LE();
- actor->graphicResourceId = stream->readSint32LE();
- actor->field_C = stream->readSint32LE();
- actor->frameNum = stream->readSint32LE();
- actor->frameCount = stream->readSint32LE();
- actor->x1 = stream->readSint32LE();
- actor->y1 = stream->readSint32LE();
- actor->x2 = stream->readSint32LE();
- actor->y2 = stream->readSint32LE();
-
- actor->boundingRect.left = stream->readSint32LE() & 0xFFFF;
- actor->boundingRect.top = stream->readSint32LE() & 0xFFFF;
- actor->boundingRect.right = stream->readSint32LE() & 0xFFFF;
- actor->boundingRect.bottom = stream->readSint32LE() & 0xFFFF;
-
- actor->direction = stream->readSint32LE();
- actor->field_3C = stream->readSint32LE();
- actor->status = (ActorStatus)stream->readSint32LE();
- actor->field_44 = stream->readSint32LE();
- actor->priority = stream->readSint32LE();
- actor->flags = stream->readSint32LE();
- actor->field_50 = stream->readSint32LE();
- actor->field_54 = stream->readSint32LE();
- actor->field_58 = stream->readSint32LE();
- actor->field_5C = stream->readSint32LE();
- actor->field_60 = stream->readSint32LE();
- actor->actionIdx3 = stream->readSint32LE();
-
- // TODO skip field_68 till field_617
- stream->skip(0x5B0);
-
- for (int32 i = 0; i < 8; i++)
- actor->reaction[i] = stream->readSint32LE();
-
- actor->field_638 = stream->readSint32LE();
- actor->walkingSound1 = stream->readSint32LE();
- actor->walkingSound2 = stream->readSint32LE();
- actor->walkingSound3 = stream->readSint32LE();
- actor->walkingSound4 = stream->readSint32LE();
- actor->field_64C = stream->readSint32LE();
- actor->field_650 = stream->readSint32LE();
-
- for (int32 i = 0; i < 55; i++)
- actor->graphicResourceIds[i] = stream->readSint32LE();
-
- stream->read(actor->name, sizeof(actor->name));
-
- for (int32 i = 0; i < 20; i++)
- actor->field_830[i] = stream->readSint32LE();
-
- for (int32 i = 0; i < 20; i++)
- actor->field_880[i] = stream->readSint32LE();
-
- for (int32 i = 0; i < 20; i++)
- actor->field_8D0[i] = stream->readSint32LE();
-
- actor->actionIdx2 = stream->readSint32LE();
- actor->field_924 = stream->readSint32LE();
- actor->tickValue = stream->readSint32LE();
- actor->field_92C = stream->readSint32LE();
- actor->actionType = stream->readSint32LE();
- actor->field_934 = stream->readSint32LE();
- actor->field_938 = stream->readSint32LE();
- actor->soundResourceId = stream->readSint32LE();
- actor->numberValue01 = stream->readSint32LE();
- actor->field_944 = stream->readSint32LE();
- actor->field_948 = stream->readSint32LE();
- actor->field_94C = stream->readSint32LE();
- actor->numberFlag01 = stream->readSint32LE();
- actor->numberStringWidth = stream->readSint32LE();
- actor->numberStringX = stream->readSint32LE();
- actor->numberStringY = stream->readSint32LE();
- stream->read(actor->numberString01, sizeof(actor->numberString01));
- actor->field_964 = stream->readSint32LE();
- actor->field_968 = stream->readSint32LE();
- actor->field_96C = stream->readSint32LE();
- actor->field_970 = stream->readSint32LE();
- actor->field_974 = stream->readSint32LE();
- actor->field_978 = stream->readSint32LE();
- actor->actionIdx1 = stream->readSint32LE();
- actor->field_980 = stream->readSint32LE();
- actor->field_984 = stream->readSint32LE();
- actor->field_988 = stream->readSint32LE();
- actor->field_98C = stream->readSint32LE();
- actor->field_990 = stream->readSint32LE();
- actor->field_994 = stream->readSint32LE();
- actor->field_998 = stream->readSint32LE();
- actor->field_99C = stream->readSint32LE();
- actor->field_9A0 = stream->readSint32LE();
-
- // TODO skip field_980 till field_9A0
- stream->skip(0x24);
+ actor->load(stream);
actors.push_back(actor);
}
diff --git a/engines/asylum/shared.h b/engines/asylum/shared.h
index 9d244fef42..d19aae1d14 100644
--- a/engines/asylum/shared.h
+++ b/engines/asylum/shared.h
@@ -28,6 +28,10 @@
namespace Asylum {
+//////////////////////////////////////////////////////////////////////////
+// Global
+//////////////////////////////////////////////////////////////////////////
+
enum GameFlag {
kGameFlag4 = 4,
kGameFlag12 = 12,
@@ -35,15 +39,27 @@ enum GameFlag {
kGameFlagCommentLeavingCell = 214,
kGameFlag219 = 219,
kGameFlagSolveVCRBlowUpPuzzle = 220,
+ kGameFlag238 = 238,
+ kGameFlag239 = 239,
kGameFlag279 = 279,
- kGameFlagFinishGame = 901
+ kGameFlag368 = 368,
+ kGameFlag556 = 556,
+ kGameFlagFinishGame = 901,
+ kGameFlag1131 = 1131
};
+//////////////////////////////////////////////////////////////////////////
+// Resources
+//////////////////////////////////////////////////////////////////////////
+
typedef int ResourceId;
enum ResourceIdEnum {
+ kResourceNone = 0,
+ kResourceSpeech_453 = 0x1C5,
kResourceSpeech_8000050A = 0x8000050A,
kResourceMusic_80020000 = 0x80020000,
+ kResourceMusic_80020001 = 0x80020001,
kResourceSound_80030203 = 0x80030203,
kResourceSound_80120001 = 0x80120001,
kResourceSound_80120006 = 0x80120006,
@@ -51,16 +67,163 @@ enum ResourceIdEnum {
kResourceMusic_FFFFFD66 = 0xFFFFFD66
};
+//////////////////////////////////////////////////////////////////////////
+// Actions
+//////////////////////////////////////////////////////////////////////////
+
enum ActionType {
kActionTypeNone = 0,
kActionTypeFind = 1,
kActionTypeTalk = 2,
- kActionType3 = 3,
kActionTypeGrab = 4,
kActionType8 = 8,
kActionType16 = 16
};
+//////////////////////////////////////////////////////////////////////////
+// Actor
+//////////////////////////////////////////////////////////////////////////
+
+typedef int ActorIndex;
+
+enum ActorIndexes {
+ kActorPlayer = -1,
+ // TODO: check if the names match the actor type
+ kActorMax = 0,
+ kActorSarah = 1,
+ kActorCyclops = 2,
+ kActorAztec = 3
+};
+
+enum ActorStatus {
+ kActorStatus1 = 1,
+ kActorStatus2,
+ kActorStatus3,
+ kActorStatusEnabled,
+ kActorStatusDisabled,
+ kActorStatus6,
+ kActorStatus7,
+ kActorStatus8,
+ kActorStatus9,
+ kActorStatus10,
+ kActorStatus11,
+ kActorStatus12,
+ kActorStatus13,
+ kActorStatus14,
+ kActorStatus15,
+ kActorStatus16,
+ kActorStatus17,
+ kActorStatus18,
+ kActorStatus19,
+ kActorStatus20,
+ kActorStatus21
+};
+
+typedef int ActorDirection;
+
+enum ActorFlags {
+ kActorFlagVisible = 1
+};
+
+enum DirectionFrom {
+ kDirectionFromBarrier = 0,
+ kDirectionFromPolygons = 1,
+ kDirectionFromActor = 2,
+ kDirectionFromParameters = 3
+};
+
+// TODO investigate other actor resources (from other
+// scenes) to see if the unused blocks in the actor
+// definition are in fact used elsewhere
+enum ActorResources {
+ kSound1 = 0,
+ kSound2 = 1,
+ kSound3 = 2,
+ kSound4 = 3,
+ //kUnused = 4, // 0
+ kFlags = 5,
+
+ kWalkN = 6,
+ kWalkNW = 7,
+ kWalkW = 8,
+ kWalkSW = 9,
+ kWalkS = 10,
+
+ kFaceN = 11,
+ kFaceNW = 12,
+ kFaceW = 13,
+ kFaceSW = 14,
+ kFaceS = 15,
+
+ kFaceAndShakeN = 16,
+ kFaceAndShakeNW = 17,
+ kFaceAndShakeW = 18,
+ kFaceAndShakeSW = 19,
+ kFaceAndShakeS = 20,
+
+ kStretchN = 21,
+ kStretchNW = 22,
+ kStretchW = 23,
+ kStretchSW = 24,
+ kStretchS = 25,
+
+ kFidgetN = 26,
+ kFidgetNW = 27,
+ kFidgetW = 28,
+ kFidgetSW = 29,
+ kFidgetS = 30,
+
+ // These are 0
+ /*
+ kUnknown1 = 31,
+ kUnknown2 = 32,
+ kUnknown3 = 33,
+ kUnknown4 = 34,
+ kUnknown5 = 35,
+ */
+
+ kPickupN = 36,
+ kPickupNW = 37,
+ kPickupW = 38,
+ kPickupSW = 39,
+ kPickupS = 40,
+
+ kOperateN = 41,
+ kOperateNW = 42,
+ kOperateW = 43,
+ kOperateSW = 44,
+ kOperateS = 45,
+
+ kOperate2N = 46,
+ kOperate2NW = 47,
+ kOperate2W = 48,
+ kOperate2SW = 49,
+ kOperate2S = 50,
+
+ // These are 0
+ /*
+ kUnknown6 = 51,
+ kUnknown7 = 52,
+ kUnknown8 = 53,
+ kUnknown9 = 54,
+ kUnknown10 = 55,
+ kUnknown11 = 56,
+ kUnknown12 = 57,
+ kUnknown13 = 58,
+ kUnknown14 = 59
+ */
+
+ // Horizontally flipped animations (100 + regular anim Id)
+ kWalkNE = 107,
+ kWalkE = 108,
+ kWalkSE = 109,
+
+ kFaceNE = 112,
+ kFaceE = 113,
+ kFaceSE = 114
+ // TODO: finish these
+};
+
//////////////////////////////////////////////////////////////////////////
// Helpers
#define CLEAR_ARRAY(type, name) { \
diff --git a/engines/asylum/system/sound.cpp b/engines/asylum/system/sound.cpp
index 060321200f..919a81de25 100644
--- a/engines/asylum/system/sound.cpp
+++ b/engines/asylum/system/sound.cpp
@@ -102,6 +102,10 @@ int32 Sound::getAdjustedVolume(int32 volume) {
error("[Sound::getAdjustedVolume] not implemented");
}
+int32 Sound::calculateVolume(int32 x, int32 y, int32 a5, int32 a6) {
+ error("[Sound::calculateVolume] not implemented");
+}
+
int32 Sound::getBufferPosition(ResourceId resourceId) {
int32 pos = -1;
diff --git a/engines/asylum/system/sound.h b/engines/asylum/system/sound.h
index 6df84c3ac0..b0bd6962bb 100644
--- a/engines/asylum/system/sound.h
+++ b/engines/asylum/system/sound.h
@@ -104,6 +104,8 @@ public:
void setVolume(ResourceId resourceId, double volume);
int32 getAdjustedVolume(int32 volume);
+ int32 calculateVolume(int32 x, int32 y, int32 a5, int32 a6);
+
/**
* Check if the buffered sound sample that matches the provided id currently
* has an active handle.
diff --git a/engines/asylum/system/speech.cpp b/engines/asylum/system/speech.cpp
index cd0c77df57..d00be662a5 100644
--- a/engines/asylum/system/speech.cpp
+++ b/engines/asylum/system/speech.cpp
@@ -44,7 +44,7 @@ int32 Speech::play(ResourceId speechResourceId) {
int32 soundResourceId = 0;
switch (_scene->worldstats()->actorType) {
- case kMax: {
+ case kActorMax: {
int32 soundResourceId2 = speechResourceId;
int32 textResourceId = speechResourceId;
@@ -59,17 +59,17 @@ int32 Speech::play(ResourceId speechResourceId) {
}
break;
// TODO: check if actor type is right for the following cases
- case kSarah: {
+ case kActorSarah: {
soundResourceId = speechResourceId - 0x7FFBF879;
setPlayerSpeech(soundResourceId, speechResourceId - 0x7FFFFDB6);
}
break;
- case kCyclops: {
+ case kActorCyclops: {
soundResourceId = speechResourceId - 0x7FFBF7DC;
setPlayerSpeech(soundResourceId, speechResourceId - 0x7FFFFD19);
}
break;
- case kAztec: {
+ case kActorAztec: {
soundResourceId = speechResourceId - 0x7FFBF746;
setPlayerSpeech(soundResourceId, speechResourceId - 0x7FFFFC83);
}
diff --git a/engines/asylum/views/scene.cpp b/engines/asylum/views/scene.cpp
index 19b64e7c4f..fa889d69ba 100644
--- a/engines/asylum/views/scene.cpp
+++ b/engines/asylum/views/scene.cpp
@@ -104,7 +104,7 @@ Scene::Scene(uint8 sceneIdx, AsylumEngine *engine): _vm(engine) {
_ws->field_120 = -1;
for (int32 a = 0; a < _ws->numActors; a++)
- _ws->actors[a]->tickValue = _vm->getTick();
+ _ws->actors[a]->setTickValue(_vm->getTick());
// TODO: init action list
@@ -133,13 +133,14 @@ void Scene::initialize() {
_ws->motionStatus = 1;
Actor *actor = getActor();
- actor->boundingRect.bottom = actor->y2;
- actor->boundingRect.right = actor->x2 * 2;
+ Common::Rect *boundinRect = actor->getBoundingRect();
+ boundinRect->bottom = actor->y2;
+ boundinRect->right = actor->x2 * 2;
_ws->boundingRect = Common::Rect(195,
115,
- 445 - actor->boundingRect.right,
- 345 - actor->boundingRect.bottom);
+ 445 - boundinRect->right,
+ 345 - boundinRect->bottom);
actor->flags |= 1;
actor->updateStatus(kActorStatusEnabled);
@@ -148,12 +149,12 @@ void Scene::initialize() {
for (int32 a = 1; a < _ws->numActors; a++) {
Actor *act = _ws->actors[a];
act->flags |= 1;
- act->direction = 1;
+ act->setDirection(1);
getActor(a)->updateStatus(kActorStatusEnabled);
act->x1 -= act->x2;
act->y1 -= act->y2;
- act->boundingRect.bottom = act->y2;
- act->boundingRect.right = 2 * act->x2;
+ boundinRect->bottom = act->y2;
+ boundinRect->right = 2 * act->x2;
}
}
@@ -176,7 +177,7 @@ void Scene::initialize() {
// TODO sceneRectChangedFlag = 1;
- actor->tickValue= _vm->getTick();
+ actor->setTickValue(_vm->getTick());
// XXX This initialization was already done earlier,
// so I'm not sure why we need to do it again. Investigate.
actor->updateDirection();
@@ -406,11 +407,11 @@ void Scene::updateMouse() {
if (_cursor->position().x < actorPos.left) {
if (_cursor->position().y >= actorPos.top) {
if (_cursor->position().y > actorPos.bottom) {
- if (act->direction == 2) {
+ if (act->getDirection() == 2) {
if (_cursor->position().y - actorPos.bottom > 10)
dir = 3;
} else {
- if (act->direction == 4) {
+ if (act->getDirection() == 4) {
if (actorPos.left - _cursor->position().x > 10)
dir = 3;
} else {
@@ -418,11 +419,11 @@ void Scene::updateMouse() {
}
}
} else {
- if (act->direction == 1) {
+ if (act->getDirection() == 1) {
if (_cursor->position().y - actorPos.top > 10)
dir = 2;
} else {
- if (act->direction == 3) {
+ if (act->getDirection() == 3) {
if (actorPos.bottom - _cursor->position().y > 10)
dir = 2;
} else {
@@ -431,8 +432,8 @@ void Scene::updateMouse() {
}
}
} else {
- if (act->direction) {
- if (act->direction == 2) {
+ if (act->getDirection()) {
+ if (act->getDirection() == 2) {
if (actorPos.top - _cursor->position().y > 10)
dir = 1;
} else {
@@ -449,11 +450,11 @@ void Scene::updateMouse() {
if (!done && _cursor->position().x <= actorPos.right) {
if (_cursor->position().y >= actorPos.top) {
if (_cursor->position().y > actorPos.bottom) {
- if (act->direction == 3) {
+ if (act->getDirection() == 3) {
if (_cursor->position().x - actorPos.left > 10)
dir = 4;
} else {
- if (act->direction == 5) {
+ if (act->getDirection() == 5) {
if (actorPos.right - _cursor->position().x > 10)
dir = 4;
} else {
@@ -462,11 +463,11 @@ void Scene::updateMouse() {
}
}
} else {
- if (act->direction == 1) {
+ if (act->getDirection() == 1) {
if (_cursor->position().x - actorPos.left > 10)
dir = 0;
} else {
- if (act->direction == 7) {
+ if (act->getDirection() == 7) {
if (actorPos.right - _cursor->position().x > 10)
dir = 0;
} else {
@@ -478,8 +479,8 @@ void Scene::updateMouse() {
}
if (!done && _cursor->position().y < actorPos.top) {
- if (act->direction) {
- if (act->direction == 6) {
+ if (act->getDirection()) {
+ if (act->getDirection() == 6) {
if (actorPos.top - _cursor->position().y > 10)
dir = 7;
} else {
@@ -493,11 +494,11 @@ void Scene::updateMouse() {
}
if (!done && _cursor->position().y <= actorPos.bottom) {
- if (act->direction == 5) {
+ if (act->getDirection() == 5) {
if (actorPos.bottom - _cursor->position().y > 10)
dir = 6;
} else {
- if (act->direction == 7) {
+ if (act->getDirection() == 7) {
if (_cursor->position().y - actorPos.top > 10)
dir = 6;
} else {
@@ -507,20 +508,20 @@ void Scene::updateMouse() {
done = true;
}
- if (!done && act->direction == 4) {
+ if (!done && act->getDirection() == 4) {
if (_cursor->position().x - actorPos.right <= 10)
done = true;
if (!done)
dir = 5;
}
- if (!done && (act->direction != 6 || _cursor->position().y - actorPos.bottom > 10))
+ if (!done && (act->getDirection() != 6 || _cursor->position().y - actorPos.bottom > 10))
dir = 5;
handleMouseUpdate(dir, actorPos);
if (dir >= 0) {
- if (act->status == 1 || act->status == 12)
+ if (act->getStatus() == 1 || act->getStatus() == 12)
act->setDirection(dir);
}
}
@@ -540,7 +541,7 @@ void Scene::handleMouseUpdate(int direction, Common::Rect rect) {
// whether the event manager is handling a right mouse down
// event
if (_cursor->field_11 & 2) {
- if (act->status == 1 || act->status == 12) {
+ if (act->getStatus() == 1 || act->getStatus() == 12) {
if (direction >= 0) {
newGraphicResourceId = _ws->curScrollUp + direction;
_cursor->set(newGraphicResourceId, 0, 2);
@@ -548,11 +549,11 @@ void Scene::handleMouseUpdate(int direction, Common::Rect rect) {
}
}
- if (act->status == 6 || act->status == 10) {
+ if (act->getStatus() == 6 || act->getStatus() == 10) {
newGraphicResourceId = _ws->curHand;
_cursor->set(newGraphicResourceId, 0, 2);
} else {
- if (act->field_638) {
+ if (act->getField638()) {
if (_cursor->position().x >= rect.left && _cursor->position().x <= rlimit &&
_cursor->position().y >= rect.top && _cursor->position().y <= rect.bottom &&
hitTestActor(_cursor->position())) {
@@ -585,7 +586,7 @@ void Scene::handleMouseUpdate(int direction, Common::Rect rect) {
if (_cursor->position().x >= rect.left && _cursor->position().x <= rlimit &&
_cursor->position().y >= rect.top && _cursor->position().y <= rect.bottom &&
hitTestActor(_cursor->position())) {
- if (act->reaction[0]) {
+ if (act->getReaction(0)) {
_cursor->set(_ws->curGrabPointer, 0, 2);
return;
}
@@ -608,7 +609,7 @@ void Scene::handleMouseUpdate(int direction, Common::Rect rect) {
targetUpdateType = _ws->barriers[targetIdx]->actionType;
break;
case kHitActor:
- targetUpdateType = getActor(targetIdx)->status;
+ targetUpdateType = getActor(targetIdx)->getStatus();
break;
default:
// TODO LOBYTE(hitType)
@@ -726,16 +727,16 @@ bool Scene::hitTestActor(const Common::Point pt) {
getActorPosition(act, &actPos);
int32 hitFrame;
- if (act->frameNum >= act->frameCount)
- hitFrame = 2 * act->frameNum - act->frameCount - 1;
+ if (act->getFrameNum() >= act->getFrameCount())
+ hitFrame = 2 * act->getFrameNum() - act->getFrameCount() - 1;
else
- hitFrame = act->frameNum;
+ hitFrame = act->getFrameNum();
- return hitTestPixel(act->graphicResourceId,
+ return hitTestPixel(act->getResourceId(),
hitFrame,
pt.x - act->x - actPos.x,
pt.y - act->y - actPos.y,
- (act->direction >= 0));
+ (act->getDirection() >= 0));
}
bool Scene::hitTestPixel(ResourceId resourceId, int32 frame, int16 x, int16 y, bool flipped) {
@@ -1197,16 +1198,16 @@ void Scene::drawActorsAndBarriers() {
act->priority = abs(act->priority);
continue;
*/
- act->priority = 3;
- if (act->field_944 == 1 || act->field_944 == 4)
- act->priority = 1;
+ act->setPriority(3);
+ if (act->getField944() == 1 || act->getField944() == 4)
+ act->setPriority(1);
else {
- act->field_938 = 1;
- act->field_934 = 0;
+ act->setField938(1);
+ act->setField934(0);
pt.x = act->x1 + act->x2;
pt.y = act->y1 + act->y2;
- actorRegPt = act->boundingRect.bottom + act->boundingRect.right + 4;
+ actorRegPt = act->getBoundingRect()->bottom + act->getBoundingRect()->right + 4;
// TODO special case for scene 11
// Not sure if we're checking the scene index
@@ -1222,7 +1223,7 @@ void Scene::drawActorsAndBarriers() {
// XXX from .text:0040a4d1
for (int32 barIdx = 0; barIdx < _ws->numBarriers; barIdx++) {
Barrier *bar = _ws->barriers[barIdx];
- bool actInBar = bar->boundingRect.contains(act->boundingRect);
+ bool actInBar = bar->boundingRect.contains(*act->getBoundingRect());
bool intersects = false;
// TODO verify that my funky LOBYTE macro actually
@@ -1276,7 +1277,7 @@ void Scene::drawActorsAndBarriers() {
// a point calculation, but the result doesn't appear to
// ever be used, and the object passed in as a parameter
// isn't updated
- act->field_3C = barIdx;
+ act->setBarrierIndex(barIdx);
act->flags |= 2;
}
}
@@ -1285,9 +1286,9 @@ void Scene::drawActorsAndBarriers() {
// XXX assuming the following:
// "if ( *(int *)((char *)&scene.characters[0].priority + v18) < *(v12_barrierPtr + 35) )"
// is the same as what I'm comparing :P
- if (act->priority < bar->priority) {
- act->field_934 = 1;
- act->priority = bar->priority + 3;
+ if (act->getPriority() < bar->priority) {
+ act->setField934(1);
+ act->setPriority(bar->priority + 3);
// TODO there's a block of code here that seems
// to loop through the CharacterUpdateItems and do some
// priority adjustment. Since I'm not using CharacterUpdateItems as of yet,
@@ -1297,9 +1298,9 @@ void Scene::drawActorsAndBarriers() {
// (b) sceneNumber != 2 && actor->field_944 != 1
}
} else {
- if (act->priority > bar->priority || act->priority == 1) {
- act->field_934 = 1;
- act->priority = bar->priority - 1;
+ if (act->getPriority() > bar->priority || act->getPriority() == 1) {
+ act->setField934(1);
+ act->setPriority(bar->priority - 1);
// TODO another character update loop
// This time it looks like there's another
// intersection test, and more updates
@@ -1330,9 +1331,9 @@ int Scene::queueActorUpdates() {
//pt.x += actor->x;
//pt.y += actor->y;
- int32 frameNum = actor->frameNum;
- if (actor->frameNum >= actor->frameCount) {
- frameNum = 2 * actor->frameCount - actor->frameNum - 1;
+ int32 frameNum = actor->getFrameNum();
+ if (actor->getFrameNum() >= actor->getFrameCount()) {
+ frameNum = 2 * actor->getFrameCount() - actor->getFrameNum() - 1;
}
if ((actor->flags & 0xFF) & 2) {
@@ -1342,7 +1343,7 @@ int Scene::queueActorUpdates() {
} else {
// TODO: get flag value from character_DeadSarah_sub_40A140
- _vm->screen()->addGraphicToQueue(actor->graphicResourceId, frameNum, pt.x, pt.y, ((actor->direction < 5) - 1) & 2, actor->field_96C, actor->priority);
+ _vm->screen()->addGraphicToQueue(actor->getResourceId(), frameNum, pt.x, pt.y, ((actor->getDirection() < 5) - 1) & 2, actor->getField96C(), actor->getPriority());
}
}
}
@@ -1499,10 +1500,10 @@ void Scene::debugShowActors() {
Actor *a = _ws->actors[p];
if (a->flags & 2) {
- surface.create(a->boundingRect.right - a->boundingRect.left + 1,
- a->boundingRect.bottom - a->boundingRect.top + 1,
+ surface.create(a->getBoundingRect()->right - a->getBoundingRect()->left + 1,
+ a->getBoundingRect()->bottom - a->getBoundingRect()->top + 1,
1);
- surface.frameRect(a->boundingRect, 0x22);
+ surface.frameRect(*a->getBoundingRect(), 0x22);
copyToBackBufferClipped(&surface, a->x, a->y);
}
@@ -1534,6 +1535,10 @@ void Scene::makeGreyPalette() {
error("[Scene::makeGreyPalette] not implemented!");
}
+void Scene::resetActor0() {
+ error("[Scene::resetActor0] not implemented!");
+}
+
//////////////////////////////////////////////////////////////////////////
// SceneTitle
//////////////////////////////////////////////////////////////////////////
diff --git a/engines/asylum/views/scene.h b/engines/asylum/views/scene.h
index 54f58b9e09..71bb416de1 100644
--- a/engines/asylum/views/scene.h
+++ b/engines/asylum/views/scene.h
@@ -179,6 +179,9 @@ public:
bool mattePlaySound;
bool matteInitialized;
+ // Shared methods
+ void resetActor0();
+
protected:
/** .text:0040EA50
* Run various hit tests and return the index,
Commit: 4d08eeae4d48800c37336fed428574e94a35b247
https://github.com/scummvm/scummvm/commit/4d08eeae4d48800c37336fed428574e94a35b247
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:07+02:00
Commit Message:
ASYLUM: Implement Actor::updateStatusEnabled() && Actor::updateFinish()
- Fix uses of the global tick value
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@473 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/asylum.h
engines/asylum/resources/actionlist.h
engines/asylum/resources/actor.cpp
engines/asylum/shared.h
engines/asylum/views/scene.cpp
engines/asylum/views/scene.h
diff --git a/engines/asylum/asylum.h b/engines/asylum/asylum.h
index cf1e08cfc3..8766ecd805 100644
--- a/engines/asylum/asylum.h
+++ b/engines/asylum/asylum.h
@@ -125,10 +125,9 @@ public:
/**
* This is the global tick counter.
- *
- * TODO rename?
*/
- uint32 tempTick07;
+ uint32 globalTickValue;
+ uint32 globalTickValue_2;
// Game
Encounter *encounter() { return _encounter; }
diff --git a/engines/asylum/resources/actionlist.h b/engines/asylum/resources/actionlist.h
index 4a5cbfd918..7cb81b6a90 100644
--- a/engines/asylum/resources/actionlist.h
+++ b/engines/asylum/resources/actionlist.h
@@ -72,6 +72,8 @@ public:
int32 getDelayedSceneIndex() const { return _delayedSceneIndex; }
void setDelayedSceneIndex(int32 val) { _delayedSceneIndex = val; }
+ bool isProcessingSkipped() { return _skipProcessing; }
+
private:
enum BarrierEnableType {
kBarrierEnableType0,
diff --git a/engines/asylum/resources/actor.cpp b/engines/asylum/resources/actor.cpp
index 3b4972b063..8a7537af5c 100644
--- a/engines/asylum/resources/actor.cpp
+++ b/engines/asylum/resources/actor.cpp
@@ -37,14 +37,15 @@
namespace Asylum {
Actor::Actor(Scene *scene, ActorIndex index) : _scene(scene), _index(index) {
+ // TODO Init all variables
- // Update private variables
+ // update-related variables
_actorUpdateCounter = 0;
_enableFromStatus7 = false;
}
Actor::~Actor() {
-
+ // TODO destroy data
// Zero passed pointers
_scene = NULL;
@@ -207,10 +208,9 @@ void Actor::update() {
}
} else {
if (_scene->vm()->isGameFlagSet(kGameFlag556)) {
- Sound *sound = _scene->vm()->sound();
Actor *player = _scene->getActor();
- sound->playSpeech(kResourceSpeech_453);
+ _scene->speech()->play(453);
setVisible(false);
player->updateStatus(kActorStatus3);
@@ -232,6 +232,7 @@ void Actor::update() {
player->setFrameNumber(0);
_scene->getActor(0)->setTickValue(_scene->vm()->getTick());
+ Sound *sound = _scene->vm()->sound();
if (sound->isCacheOk())
sound->playMusic(_scene->getResourcePack(), kResourceMusic_80020001);
@@ -314,14 +315,14 @@ void Actor::update() {
case kActorStatusDisabled:
_frameNumber = (_frameNumber + 1) % _frameCount;
- if (_scene->vm()->getTick() - _tickValue > 300) {
+ if (_scene->vm()->globalTickValue - _tickValue > 300) {
if (_scene->vm()->getRandom(100) < 50) {
if (!_scene->vm()->sound()->soundResourceId || !_scene->vm()->sound()->isPlaying(_scene->vm()->sound()->soundResourceId)) {
if (isDefaultDirection(10))
updateStatus(kActorStatus9);
}
}
- _tickValue = _scene->vm()->getTick();
+ _tickValue = _scene->vm()->globalTickValue;
}
break;
@@ -740,46 +741,75 @@ void Actor::updateStatus3_19() {
}
void Actor::updateStatusEnabled() {
- // TODO make sure this is right
_frameNumber = (_frameNumber + 1) % _frameCount;
- if (_scene->vm()->getTick() - _tickValue > 300) {
- // TODO
- // Check if the actor's name is "Crow"?
- if (_scene->vm()->getRandom(100) < 50) {
- // TODO
- // Check if soundResourceId04 is assigned, and if so,
- // if it's playing
- // If true, check characterSub407260(10)
- // and if that's true, do characterDirection(9)
+
+ // Actor: Crow
+ if (_scene->vm()->globalTickValue - _tickValue > 300) {
+ if (strcmp(_name, "Crow")) {
+ if (_scene->vm()->getRandom(100) < 50
+ && (!_scene->vm()->sound()->soundResourceId || !_scene->vm()->sound()->isPlaying(_scene->vm()->sound()->soundResourceId))
+ && isDefaultDirection(10))
+ updateStatus(kActorStatus9);
+
+ _tickValue = _scene->vm()->globalTickValue;
}
}
- // if act == getActor()
- if (_scene->vm()->tempTick07) {
- if (_scene->vm()->getTick() - _scene->vm()->tempTick07 > 500) {
- if (_scene->vm()->isGameFlagNotSet(kGameFlagScriptProcessing)) { // processing action list
- if (isVisible()) {
- // if some_encounter_flag
- // if !soundResourceId04
- if (_scene->vm()->getRandom(100) < 50) {
- if (_scene->getSceneIndex() == 13) {
- ; // sub414810(507)
- } else {
- ; // sub4146d0(4)
- }
- }
+ // Actor: Player
+ if (_index == _scene->getPlayerActorIndex()) {
+ if (_scene->vm()->globalTickValue_2 && (_scene->vm()->globalTickValue - _scene->vm()->globalTickValue_2) > 500) {
+
+ if (_scene->vm()->isGameFlagNotSet(kGameFlagScriptProcessing)
+ && isVisible()
+ && !_scene->vm()->encounter()->getFlag(kEncounterFlag2)
+ && !_scene->vm()->sound()->soundResourceId) {
+ if (_scene->vm()->getRandom(100) < 50) {
+ if (_scene->worldstats()->numChapter == 13)
+ _scene->speech()->play(507);
+ else
+ _scene->playSpeech(4);
}
}
+ _tickValue = _scene->vm()->globalTickValue;
+ _scene->vm()->globalTickValue_2 = _scene->vm()->globalTickValue;
+ }
+
+ return;
+ }
+
+ // Actor:: BigCrow
+ if (strcmp(_name, "Big Crow")) {
+ error("[Actor::updateStatusEnabled] Big Crow logic not implemented!");
+ return;
+ }
+
+ // All other actors
+ if (_scene->vm()->getRandom(10) < 5) {
+ switch (_scene->vm()->getRandom(4)) {
+ default:
+ break;
+
+ case 0:
+ setPosition(10, 1350, 0, 0);
+ processStatus(1460, -100, false);
+ break;
+
+ case 1:
+ setPosition(300, 0, 0, 0);
+ processStatus(1700, 1400, false);
+ break;
+
+ case 2:
+ setPosition(1560, -100, 0, 0);
+ processStatus(-300, 1470, false);
+ break;
+
+ case 3:
+ setPosition(1150, 1400, 0, 0);
+ processStatus(-250, 0, false);
+ break;
}
- _tickValue = _scene->vm()->getTick();
}
- // else
- // TODO now there's something to do with the
- // character's name and "Big Crow", or "Crow".
- // Quite a bit of work to do yet, but it only seems to
- // take effect when the character index doesn't equal
- // the currentPlayerIndex (so I'm guessing this is a
- // one off situation).
}
void Actor::updateStatus9() {
@@ -851,7 +881,29 @@ void Actor::updateStatus21() {
}
void Actor::updateFinish() {
- error("[Actor::updateFinish] not implemented!");
+ if (_field_944 == 4 || !isVisible())
+ return;
+
+ int32 areaIndex = _scene->findActionArea(Common::Point(x2 + x1, y2 + y1));
+ if (areaIndex == _actionIdx3 || areaIndex == -1)
+ return;
+
+ ActionArea *area = _scene->worldstats()->actions[areaIndex];
+ ActionArea *actorArea = _scene->worldstats()->actions[_actionIdx3];
+ if (!_scene->actions()->isProcessingSkipped()) {
+ _scene->actions()->queueScript(actorArea->actionListIdx2, _index);
+ _scene->actions()->queueScript(area->scriptIndex, _index);
+ }
+
+ if (!area->paletteValue || area->paletteValue == actorArea->paletteValue || _index) {
+ if (area->paletteValue != actorArea->paletteValue && !_index)
+ _scene->vm()->screen()->startPaletteFade(area->paletteValue, 50, 3);
+
+ _actionIdx3 = areaIndex;
+ } else {
+ _scene->vm()->screen()->startPaletteFade(area->paletteValue, 50, 3);
+ _actionIdx3 = areaIndex;
+ }
}
//////////////////////////////////////////////////////////////////////////
diff --git a/engines/asylum/shared.h b/engines/asylum/shared.h
index d19aae1d14..e902506c39 100644
--- a/engines/asylum/shared.h
+++ b/engines/asylum/shared.h
@@ -56,7 +56,6 @@ typedef int ResourceId;
enum ResourceIdEnum {
kResourceNone = 0,
- kResourceSpeech_453 = 0x1C5,
kResourceSpeech_8000050A = 0x8000050A,
kResourceMusic_80020000 = 0x80020000,
kResourceMusic_80020001 = 0x80020001,
diff --git a/engines/asylum/views/scene.cpp b/engines/asylum/views/scene.cpp
index fa889d69ba..36e2ba0253 100644
--- a/engines/asylum/views/scene.cpp
+++ b/engines/asylum/views/scene.cpp
@@ -173,7 +173,7 @@ void Scene::initialize() {
startMusic();
- _vm->tempTick07 = 1;
+ _vm->globalTickValue = 1;
// TODO sceneRectChangedFlag = 1;
diff --git a/engines/asylum/views/scene.h b/engines/asylum/views/scene.h
index 71bb416de1..657d61c36e 100644
--- a/engines/asylum/views/scene.h
+++ b/engines/asylum/views/scene.h
@@ -182,6 +182,13 @@ public:
// Shared methods
void resetActor0();
+
+ /** .text:00408980
+ * Determine if the supplied point intersects
+ * an action area's active region
+ */
+ int32 findActionArea(const Common::Point pt);
+
protected:
/** .text:0040EA50
* Run various hit tests and return the index,
@@ -207,11 +214,7 @@ protected:
* actor, and returns -1 if nothing was found, or the type of hit if found
*/
int32 hitTestScene(const Common::Point pt, HitType &type);
- /** .text:00408980
- * Determine if the supplied point intersects
- * an action area's active region
- */
- int32 findActionArea(const Common::Point pt);
+
/** .text:0040EAA0
* Check if a barrier exist at the supplied coordinates.
* If so, return it's index within the barriers array, if not,
Commit: 3a64ce802a0268868171f99c04992de4dfcf648b
https://github.com/scummvm/scummvm/commit/3a64ce802a0268868171f99c04992de4dfcf648b
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:07+02:00
Commit Message:
ASYLUM: Add helper macros for access to engine subsystems
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@474 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/resources/actor.cpp
engines/asylum/resources/actor.h
engines/asylum/resources/worldstats.cpp
engines/asylum/shared.h
diff --git a/engines/asylum/resources/actor.cpp b/engines/asylum/resources/actor.cpp
index 8a7537af5c..60d5fd5b36 100644
--- a/engines/asylum/resources/actor.cpp
+++ b/engines/asylum/resources/actor.cpp
@@ -36,7 +36,7 @@
namespace Asylum {
-Actor::Actor(Scene *scene, ActorIndex index) : _scene(scene), _index(index) {
+Actor::Actor(AsylumEngine *engine, ActorIndex index) : _vm(engine), _index(index) {
// TODO Init all variables
// update-related variables
@@ -48,7 +48,7 @@ Actor::~Actor() {
// TODO destroy data
// Zero passed pointers
- _scene = NULL;
+ _vm = NULL;
}
/////////////////////////////////////////////////////////////////////////
@@ -179,21 +179,21 @@ void Actor::update() {
break;
case kActorStatus16:
- if (_scene->worldstats()->numChapter == 2) {
+ if (getWorld()->numChapter == 2) {
updateStatus16_Chapter2();
- } else if (_scene->worldstats()->numChapter == 11 && _index == _scene->getPlayerActorIndex()) {
+ } else if (getWorld()->numChapter == 11 && _index == getScene()->getPlayerActorIndex()) {
updateStatus16_Chapter11();
}
break;
case kActorStatus17:
- if (_scene->worldstats()->numChapter == 2) {
+ if (getWorld()->numChapter == 2) {
if (_index > 12) {
if (_frameNumber <= _frameCount - 1) {
++_frameNumber;
} else {
setVisible(false);
- _scene->getActor(_index + 9)->setVisible(false);
+ getScene()->getActor(_index + 9)->setVisible(false);
}
}
@@ -207,74 +207,74 @@ void Actor::update() {
++_frameNumber;
}
} else {
- if (_scene->vm()->isGameFlagSet(kGameFlag556)) {
- Actor *player = _scene->getActor();
+ if (_vm->isGameFlagSet(kGameFlag556)) {
+ Actor *player = getScene()->getActor();
- _scene->speech()->play(453);
+ getScene()->speech()->play(453);
setVisible(false);
player->updateStatus(kActorStatus3);
player->setResourceId(player->getResourcesId(35));
player->setDirection(4);
- GraphicResource *resource = new GraphicResource(_scene->getResourcePack(), player->getResourceId());
+ GraphicResource *resource = new GraphicResource(getScene()->getResourcePack(), player->getResourceId());
player->setFrameCount(resource->getFrameCount());
delete resource;
- _scene->getCursor()->hide();
- _scene->getActor(0)->updateFromDirection(4);
+ getScene()->getCursor()->hide();
+ getScene()->getActor(0)->updateFromDirection(4);
// Queue script
- _scene->actions()->queueScript(_scene->worldstats()->getActionAreaById(2696)->scriptIndex, _scene->getPlayerActorIndex());
+ getScene()->actions()->queueScript(getWorld()->getActionAreaById(2696)->scriptIndex, getScene()->getPlayerActorIndex());
- _scene->vm()->setGameFlag(kGameFlag279);
- _scene->vm()->setGameFlag(kGameFlag368);
+ _vm->setGameFlag(kGameFlag279);
+ _vm->setGameFlag(kGameFlag368);
player->setFrameNumber(0);
- _scene->getActor(0)->setTickValue(_scene->vm()->getTick());
+ getScene()->getActor(0)->setTickValue(_vm->getTick());
- Sound *sound = _scene->vm()->sound();
+ Sound *sound = _vm->sound();
if (sound->isCacheOk())
- sound->playMusic(_scene->getResourcePack(), kResourceMusic_80020001);
+ sound->playMusic(getScene()->getResourcePack(), kResourceMusic_80020001);
- _scene->worldstats()->musicCurrentResourceId = 1;
+ getWorld()->musicCurrentResourceId = 1;
- if (sound->isPlaying(_scene->worldstats()->soundResourceIds[7]))
- sound->stopSound(_scene->worldstats()->soundResourceIds[7]);
+ if (sound->isPlaying(getWorld()->soundResourceIds[7]))
+ sound->stopSound(getWorld()->soundResourceIds[7]);
- if (sound->isPlaying(_scene->worldstats()->soundResourceIds[6]))
- sound->stopSound(_scene->worldstats()->soundResourceIds[6]);
+ if (sound->isPlaying(getWorld()->soundResourceIds[6]))
+ sound->stopSound(getWorld()->soundResourceIds[6]);
- if (sound->isPlaying(_scene->worldstats()->soundResourceIds[5]))
- sound->stopSound(_scene->worldstats()->soundResourceIds[5]);
+ if (sound->isPlaying(getWorld()->soundResourceIds[5]))
+ sound->stopSound(getWorld()->soundResourceIds[5]);
- _scene->vm()->setGameFlag(kGameFlag1131);
+ _vm->setGameFlag(kGameFlag1131);
} else {
updateGraphicData(25);
- _scene->vm()->setGameFlag(kGameFlag556);
+ _vm->setGameFlag(kGameFlag556);
}
}
}
- if (_index == _scene->getPlayerActorIndex()) {
+ if (_index == getScene()->getPlayerActorIndex()) {
if (_frameNumber <= _frameCount - 1) {
++_frameNumber;
} else {
- _scene->vm()->clearGameFlag(kGameFlag239);
- _scene->getActor(10)->updateStatus(kActorStatus14);
+ _vm->clearGameFlag(kGameFlag239);
+ getScene()->getActor(10)->updateStatus(kActorStatus14);
setVisible(false);
- _scene->vm()->setGameFlag(kGameFlag238);
+ _vm->setGameFlag(kGameFlag238);
// Queue script
- _scene->actions()->queueScript(_scene->worldstats()->getActionAreaById(1000)->scriptIndex, _scene->getPlayerActorIndex());
+ getScene()->actions()->queueScript(getWorld()->getActionAreaById(1000)->scriptIndex, getScene()->getPlayerActorIndex());
}
}
- } else if (_scene->worldstats()->numChapter == 11) {
- if (_index == _scene->getPlayerActorIndex()) {
+ } else if (getWorld()->numChapter == 11) {
+ if (_index == getScene()->getPlayerActorIndex()) {
if (_frameNumber <= _frameCount - 1)
++_frameNumber;
else
- _scene->resetActor0();
+ getScene()->resetActor0();
}
if (_index >= 10)
@@ -283,27 +283,27 @@ void Actor::update() {
break;
case kActorStatus15:
- if (_scene->worldstats()->numChapter == 2) {
+ if (getWorld()->numChapter == 2) {
if (_index > 12)
updateStatus15_Chapter2();
- if (_index == _scene->getPlayerActorIndex())
+ if (_index == getScene()->getPlayerActorIndex())
updateStatus15_Chapter2_Player();
if (_index == 11)
updateStatus15_Chapter2_Actor11();
- } else if (_scene->worldstats()->numChapter == 11) {
+ } else if (getWorld()->numChapter == 11) {
if (_index >= 10 && _index < 16)
updateStatus15_Chapter11();
- if (_index == _scene->getPlayerActorIndex())
+ if (_index == getScene()->getPlayerActorIndex())
updateStatus15_Chapter11_Player();
}
break;
case kActorStatus18:
- if (_scene->worldstats()->numChapter == 2) {
+ if (getWorld()->numChapter == 2) {
if (_index > 12)
updateStatus18_Chapter2();
@@ -315,19 +315,19 @@ void Actor::update() {
case kActorStatusDisabled:
_frameNumber = (_frameNumber + 1) % _frameCount;
- if (_scene->vm()->globalTickValue - _tickValue > 300) {
- if (_scene->vm()->getRandom(100) < 50) {
- if (!_scene->vm()->sound()->soundResourceId || !_scene->vm()->sound()->isPlaying(_scene->vm()->sound()->soundResourceId)) {
+ if (_vm->globalTickValue - _tickValue > 300) {
+ if (_vm->getRandom(100) < 50) {
+ if (!getSound()->soundResourceId || !getSound()->isPlaying(getSound()->soundResourceId)) {
if (isDefaultDirection(10))
updateStatus(kActorStatus9);
}
}
- _tickValue = _scene->vm()->globalTickValue;
+ _tickValue = _vm->globalTickValue;
}
break;
case kActorStatus12:
- if (_scene->worldstats()->numChapter == 2) {
+ if (getWorld()->numChapter == 2) {
if (_index > 12)
updateStatus12_Chapter2();
@@ -335,7 +335,7 @@ void Actor::update() {
updateStatus12_Chapter2_Actor11();
return;
- } else if (_scene->worldstats()->numChapter == 11) {
+ } else if (getWorld()->numChapter == 11) {
switch (_index) {
default:
break;
@@ -410,9 +410,9 @@ void Actor::update() {
break;
case kActorStatus8:
- if (_scene->vm()->encounter()->getFlag(kEncounterFlag2)
+ if (_vm->encounter()->getFlag(kEncounterFlag2)
|| !_soundResourceId
- || _scene->vm()->sound()->isPlaying(_soundResourceId)) {
+ || getSound()->isPlaying(_soundResourceId)) {
_frameNumber = (_frameNumber + 1) % _frameCount;
} else {
updateStatus(kActorStatusEnabled);
@@ -421,10 +421,10 @@ void Actor::update() {
break;
}
- if (_soundResourceId && _scene->vm()->sound()->isPlaying(_soundResourceId))
+ if (_soundResourceId && getSound()->isPlaying(_soundResourceId))
setVolume();
- if (_index != _scene->getPlayerActorIndex() && _scene->worldstats()->numChapter != 9)
+ if (_index != getScene()->getPlayerActorIndex() && getWorld()->numChapter != 9)
error("[Actor::update] call to actor sound functions missing!");
updateDirection();
@@ -441,8 +441,8 @@ void Actor::updateStatus(ActorStatus actorStatus) {
case kActorStatus1:
case kActorStatus12:
- if ((_scene->worldstats()->numChapter == 2
- && _index == _scene->getPlayerActorIndex() && (_status == kActorStatus18 || _status == kActorStatus16 || kActorStatus17))
+ if ((getWorld()->numChapter == 2
+ && _index == getScene()->getPlayerActorIndex() && (_status == kActorStatus18 || _status == kActorStatus16 || kActorStatus17))
|| (_status != kActorStatusEnabled && _status != kActorStatus9 && _status != kActorStatus14 && _status != kActorStatus15 && _status != kActorStatus18))
return;
@@ -480,21 +480,21 @@ void Actor::updateStatus(ActorStatus actorStatus) {
break;
case kActorStatus7:
- if (_scene->worldstats()->numChapter == 2 && _index == 10 && _scene->vm()->isGameFlagSet(kGameFlag279)) {
- Actor *actor = _scene->getActor(0);
+ if (getWorld()->numChapter == 2 && _index == 10 && _vm->isGameFlagSet(kGameFlag279)) {
+ Actor *actor = getScene()->getActor(0);
actor->x1 = x2 + x1 - actor->x2;
actor->y1 = y2 + y1 - actor->y2;
actor->setDirection(4);
- _scene->setPlayerActorIndex(0);
+ getScene()->setPlayerActorIndex(0);
// Hide this actor and the show the other one
setVisible(false);
actor->setVisible(true);
- _scene->vm()->clearGameFlag(kGameFlag279);
+ _vm->clearGameFlag(kGameFlag279);
- _scene->getCursor()->show();
+ getScene()->getCursor()->show();
}
break;
@@ -505,10 +505,10 @@ void Actor::updateStatus(ActorStatus actorStatus) {
break;
case kActorStatus9:
- if (_scene->vm()->encounter()->getFlag(kEncounterFlag2))
+ if (_vm->encounter()->getFlag(kEncounterFlag2))
return;
- if (_scene->vm()->getRandomBit() == 1 && isDefaultDirection(15))
+ if (_vm->getRandomBit() == 1 && isDefaultDirection(15))
updateGraphicData(15);
else
updateGraphicData(10);
@@ -520,24 +520,24 @@ void Actor::updateStatus(ActorStatus actorStatus) {
break;
case kActorStatus18:
- if (_scene->worldstats()->numChapter == 2) {
+ if (getWorld()->numChapter == 2) {
GraphicResource *resource = new GraphicResource();
_frameNumber = 0;
if (_index > 12)
_resourceId = _graphicResourceIds[_direction + 30];
- if (_scene->getPlayerActorIndex() == _index) {
- resource->load(_scene->getResourcePack(), _resourceId);
+ if (getScene()->getPlayerActorIndex() == _index) {
+ resource->load(getScene()->getResourcePack(), _resourceId);
_frameNumber = resource->getFrameCount() - 1;
}
if (_index == 11)
- _resourceId = _graphicResourceIds[_scene->getGlobalDirection() > 4 ? 8 - _scene->getGlobalDirection() : _scene->getGlobalDirection()];
+ _resourceId = _graphicResourceIds[getScene()->getGlobalDirection() > 4 ? 8 - getScene()->getGlobalDirection() : getScene()->getGlobalDirection()];
// Reload the graphic resource if the resource ID has changed
if (resource->getResourceId() != _resourceId)
- resource->load(_scene->getResourcePack(), _resourceId);
+ resource->load(getScene()->getResourcePack(), _resourceId);
_frameCount = resource->getFrameCount();
}
@@ -577,14 +577,14 @@ void Actor::updateFromDirection(ActorDirection actorDirection) {
_resourceId = _graphicResourceIds[(actorDirection > 4 ? 8 - actorDirection : actorDirection) + 5];
// FIXME this seems kind of wasteful just to grab a frame count
- GraphicResource *gra = new GraphicResource(_scene->getResourcePack(), _resourceId);
+ GraphicResource *gra = new GraphicResource(getScene()->getResourcePack(), _resourceId);
_frameCount = gra->getFrameCount();
delete gra;
}
break;
case kActorStatus18:
- if (_scene->worldstats()->numChapter == 2) {
+ if (getWorld()->numChapter == 2) {
if (_index == 11) { // we are actor 11
if (actorDirection > 4)
_resourceId = _graphicResourceIds[8 - actorDirection];
@@ -617,15 +617,15 @@ void Actor::faceTarget(int32 targetId, DirectionFrom from) {
return;
case kDirectionFromBarrier: {
- int32 barrierIndex = _scene->worldstats()->getBarrierIndexById(targetId);
+ int32 barrierIndex = getWorld()->getBarrierIndexById(targetId);
if (barrierIndex == -1) {
warning("[Actor::faceTarget] No Barrier found for id %d", targetId);
return;
}
- Barrier *barrier = _scene->worldstats()->getBarrierByIndex(barrierIndex);
+ Barrier *barrier = getWorld()->getBarrierByIndex(barrierIndex);
- GraphicResource *resource = new GraphicResource(_scene->getResourcePack(), barrier->resourceId);
+ GraphicResource *resource = new GraphicResource(getScene()->getResourcePack(), barrier->resourceId);
GraphicFrame *frame = resource->getFrame(barrier->frameIdx);
newX = (frame->surface.w >> 1) + barrier->x;
@@ -636,13 +636,13 @@ void Actor::faceTarget(int32 targetId, DirectionFrom from) {
break;
case kDirectionFromPolygons: {
- int32 actionIndex = _scene->worldstats()->getActionAreaIndexById(targetId);
+ int32 actionIndex = getWorld()->getActionAreaIndexById(targetId);
if (actionIndex == -1) {
warning("[Actor::faceTarget] No ActionArea found for id %d", targetId);
return;
}
- PolyDefinitions *polygon = &_scene->polygons()->entries[_scene->worldstats()->actions[actionIndex]->polyIdx];
+ PolyDefinitions *polygon = &getScene()->polygons()->entries[getWorld()->actions[actionIndex]->polyIdx];
newX = polygon->boundingRect.left + (polygon->boundingRect.right - polygon->boundingRect.left) / 2;
newY = polygon->boundingRect.top + (polygon->boundingRect.bottom - polygon->boundingRect.top) / 2;
@@ -678,8 +678,8 @@ void Actor::setPosition(int32 newX, int32 newY, int32 newDirection, int32 frame)
// Misc
//////////////////////////////////////////////////////////////////////////
void Actor::stopSound() {
- if (_soundResourceId && _scene->vm()->sound()->isPlaying(_soundResourceId))
- _scene->vm()->sound()->stopSound(_soundResourceId);
+ if (_soundResourceId && getSound()->isPlaying(_soundResourceId))
+ getSound()->stopSound(_soundResourceId);
}
void Actor::setRawResources(uint8 *data) {
@@ -706,7 +706,7 @@ void Actor::processStatus(int32 x, int32 y, bool doSpeech) {
else
updateStatus(kActorStatus13);
} else if (doSpeech) {
- _scene->playSpeech(1);
+ getScene()->playSpeech(1);
}
}
@@ -744,34 +744,34 @@ void Actor::updateStatusEnabled() {
_frameNumber = (_frameNumber + 1) % _frameCount;
// Actor: Crow
- if (_scene->vm()->globalTickValue - _tickValue > 300) {
+ if (_vm->globalTickValue - _tickValue > 300) {
if (strcmp(_name, "Crow")) {
- if (_scene->vm()->getRandom(100) < 50
- && (!_scene->vm()->sound()->soundResourceId || !_scene->vm()->sound()->isPlaying(_scene->vm()->sound()->soundResourceId))
+ if (_vm->getRandom(100) < 50
+ && (!getSound()->soundResourceId || !getSound()->isPlaying(getSound()->soundResourceId))
&& isDefaultDirection(10))
updateStatus(kActorStatus9);
- _tickValue = _scene->vm()->globalTickValue;
+ _tickValue = _vm->globalTickValue;
}
}
// Actor: Player
- if (_index == _scene->getPlayerActorIndex()) {
- if (_scene->vm()->globalTickValue_2 && (_scene->vm()->globalTickValue - _scene->vm()->globalTickValue_2) > 500) {
+ if (_index == getScene()->getPlayerActorIndex()) {
+ if (_vm->globalTickValue_2 && (_vm->globalTickValue - _vm->globalTickValue_2) > 500) {
- if (_scene->vm()->isGameFlagNotSet(kGameFlagScriptProcessing)
+ if (_vm->isGameFlagNotSet(kGameFlagScriptProcessing)
&& isVisible()
- && !_scene->vm()->encounter()->getFlag(kEncounterFlag2)
- && !_scene->vm()->sound()->soundResourceId) {
- if (_scene->vm()->getRandom(100) < 50) {
- if (_scene->worldstats()->numChapter == 13)
- _scene->speech()->play(507);
+ && !_vm->encounter()->getFlag(kEncounterFlag2)
+ && !getSound()->soundResourceId) {
+ if (_vm->getRandom(100) < 50) {
+ if (getWorld()->numChapter == 13)
+ getScene()->speech()->play(507);
else
- _scene->playSpeech(4);
+ getScene()->playSpeech(4);
}
}
- _tickValue = _scene->vm()->globalTickValue;
- _scene->vm()->globalTickValue_2 = _scene->vm()->globalTickValue;
+ _tickValue = _vm->globalTickValue;
+ _vm->globalTickValue_2 = _vm->globalTickValue;
}
return;
@@ -784,8 +784,8 @@ void Actor::updateStatusEnabled() {
}
// All other actors
- if (_scene->vm()->getRandom(10) < 5) {
- switch (_scene->vm()->getRandom(4)) {
+ if (_vm->getRandom(10) < 5) {
+ switch (_vm->getRandom(4)) {
default:
break;
@@ -884,24 +884,24 @@ void Actor::updateFinish() {
if (_field_944 == 4 || !isVisible())
return;
- int32 areaIndex = _scene->findActionArea(Common::Point(x2 + x1, y2 + y1));
+ int32 areaIndex = getScene()->findActionArea(Common::Point(x2 + x1, y2 + y1));
if (areaIndex == _actionIdx3 || areaIndex == -1)
return;
- ActionArea *area = _scene->worldstats()->actions[areaIndex];
- ActionArea *actorArea = _scene->worldstats()->actions[_actionIdx3];
- if (!_scene->actions()->isProcessingSkipped()) {
- _scene->actions()->queueScript(actorArea->actionListIdx2, _index);
- _scene->actions()->queueScript(area->scriptIndex, _index);
+ ActionArea *area = getWorld()->actions[areaIndex];
+ ActionArea *actorArea = getWorld()->actions[_actionIdx3];
+ if (!getScene()->actions()->isProcessingSkipped()) {
+ getScene()->actions()->queueScript(actorArea->actionListIdx2, _index);
+ getScene()->actions()->queueScript(area->scriptIndex, _index);
}
if (!area->paletteValue || area->paletteValue == actorArea->paletteValue || _index) {
if (area->paletteValue != actorArea->paletteValue && !_index)
- _scene->vm()->screen()->startPaletteFade(area->paletteValue, 50, 3);
+ _vm->screen()->startPaletteFade(area->paletteValue, 50, 3);
_actionIdx3 = areaIndex;
} else {
- _scene->vm()->screen()->startPaletteFade(area->paletteValue, 50, 3);
+ _vm->screen()->startPaletteFade(area->paletteValue, 50, 3);
_actionIdx3 = areaIndex;
}
}
@@ -910,15 +910,15 @@ void Actor::updateFinish() {
// Misc
//////////////////////////////////////////////////////////////////////////
void Actor::setVolume() {
- if (!_soundResourceId || !_scene->vm()->sound()->isPlaying(_soundResourceId))
+ if (!_soundResourceId || !getSound()->isPlaying(_soundResourceId))
return;
// Compute volume
- int32 volume = Config.voiceVolume + _scene->vm()->sound()->calculateVolume(x2 + x1, y2 + y1, _field_968, 0);
+ int32 volume = Config.voiceVolume + getSound()->calculateVolume(x2 + x1, y2 + y1, _field_968, 0);
if (volume < -10000)
volume = -10000;
- _scene->vm()->sound()->setVolume(_soundResourceId, volume);
+ getSound()->setVolume(_soundResourceId, volume);
}
//////////////////////////////////////////////////////////////////////////
@@ -1013,7 +1013,7 @@ ActorDirection Actor::getDirection(int32 ax1, int32 ay1, int32 ax2, int32 ay2) {
void Actor::updateGraphicData(uint32 offset) {
_resourceId = _graphicResourceIds[(_direction > 4 ? 8 - _direction : _direction) + offset];
- GraphicResource *resource = new GraphicResource(_scene->getResourcePack(), _resourceId);
+ GraphicResource *resource = new GraphicResource(getScene()->getResourcePack(), _resourceId);
_frameCount = resource->getFrameCount();
delete resource;
diff --git a/engines/asylum/resources/actor.h b/engines/asylum/resources/actor.h
index 7e6f545331..9a4efb0815 100644
--- a/engines/asylum/resources/actor.h
+++ b/engines/asylum/resources/actor.h
@@ -34,14 +34,14 @@
namespace Asylum {
class ActionArea;
+class AsylumEngine;
struct GraphicFrame;
class GraphicResource;
-class Scene;
class Screen;
class Actor {
public:
- Actor(Scene *scene, ActorIndex index);
+ Actor(AsylumEngine *engine, ActorIndex index);
virtual ~Actor();
//////////////////////////////////////////////////////////////////////////
@@ -193,7 +193,8 @@ public:
bool process_41BDB0(int32 reactionIndex, bool testNumberValue01);
private:
- Scene *_scene;
+ AsylumEngine *_vm;
+
// Our current index
ActorIndex _index;
diff --git a/engines/asylum/resources/worldstats.cpp b/engines/asylum/resources/worldstats.cpp
index b3370a5d5b..1c4928e162 100644
--- a/engines/asylum/resources/worldstats.cpp
+++ b/engines/asylum/resources/worldstats.cpp
@@ -301,7 +301,7 @@ void WorldStats::load(Common::SeekableReadStream *stream) {
stream->seek(0xA6D7A);
for (ActorIndex index = 0; index < numActors; index++) {
- Actor *actor = new Actor(_scene, index);
+ Actor *actor = new Actor(_scene->vm(), index);
actor->load(stream);
actors.push_back(actor);
diff --git a/engines/asylum/shared.h b/engines/asylum/shared.h
index e902506c39..2c25bde543 100644
--- a/engines/asylum/shared.h
+++ b/engines/asylum/shared.h
@@ -225,6 +225,7 @@ enum ActorResources {
//////////////////////////////////////////////////////////////////////////
// Helpers
+//////////////////////////////////////////////////////////////////////////
#define CLEAR_ARRAY(type, name) { \
for (Common::Array<type *>::iterator it = name.begin(); it != name.end(); it++) {\
delete *it; \
@@ -233,6 +234,21 @@ enum ActorResources {
name.clear(); \
}
+//////////////////////////////////////////////////////////////////////////
+// Macros
+//////////////////////////////////////////////////////////////////////////
+
+// Misc
+#define rnd(val) _vm->getRandom(val)
+
+// Engine subclasses
+#define getSound() _vm->sound()
+#define getScene() _vm->scene()
+#define getWorld() _vm->scene()->worldstats()
+
+
+
+
} // End of namespace Asylum
#endif // ASYLUM_SHARED_H
Commit: 1e04f736edce8acc188535ef8c5e35fe1471ae58
https://github.com/scummvm/scummvm/commit/1e04f736edce8acc188535ef8c5e35fe1471ae58
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:08+02:00
Commit Message:
ASYLUM: Refactor Barrier class
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@475 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/asylum.h
engines/asylum/resources/actionlist.cpp
engines/asylum/resources/actor.cpp
engines/asylum/resources/actor.h
engines/asylum/resources/barrier.cpp
engines/asylum/resources/barrier.h
engines/asylum/resources/worldstats.cpp
engines/asylum/resources/worldstats.h
engines/asylum/shared.h
engines/asylum/system/sound.h
engines/asylum/views/scene.cpp
diff --git a/engines/asylum/asylum.h b/engines/asylum/asylum.h
index 8766ecd805..2ee54edad2 100644
--- a/engines/asylum/asylum.h
+++ b/engines/asylum/asylum.h
@@ -63,7 +63,7 @@ namespace Asylum {
// progress before the scene is entered. This is
// just a convenience, as there's no need for the type
// of pre-loading that was performed in the original
-// #define SHOW_SCENE_LOADING
+#define SHOW_SCENE_LOADING
//#define SHOW_SCENE_TIMES
diff --git a/engines/asylum/resources/actionlist.cpp b/engines/asylum/resources/actionlist.cpp
index dcad5f27c5..3eac70bacf 100644
--- a/engines/asylum/resources/actionlist.cpp
+++ b/engines/asylum/resources/actionlist.cpp
@@ -372,13 +372,13 @@ IMPLEMENT_OPCODE(PlayAnimation) {
barrier->setNextFrame(barrier->flags);
- if (barrier->field_688 == 1) {
+ if (barrier->getField688() == 1) {
if (barrier->flags & kBarrierFlag4) {
_scene->setGlobalX(barrier->x);
_scene->setGlobalY(barrier->y);
} else {
- GraphicResource *res = new GraphicResource(_scene->getResourcePack(), barrier->resourceId);
- GraphicFrame *frame = res->getFrame(barrier->frameIdx);
+ GraphicResource *res = new GraphicResource(_scene->getResourcePack(), barrier->getResourceId());
+ GraphicFrame *frame = res->getFrame(barrier->getFrameIndex());
_scene->setGlobalX(frame->x + (frame->getWidth() >> 1) + barrier->x);
_scene->setGlobalY(frame->y + (frame->getHeight() >> 1) + barrier->y);
@@ -486,15 +486,15 @@ IMPLEMENT_OPCODE(EnableBarriers) {
if (_currentScript->counter >= (3 * cmd->param2 - 1)) {
_currentScript->counter = 0;
- barrier->field_67C = 0;
+ barrier->setField67C(0);
enableBarrier(cmd, kBarrierEnableType2);
} else {
++_currentScript->counter;
if (cmd->param3) {
- barrier->field_67C = 3 - _currentScript->counter / cmd->param2;
+ barrier->setField67C(3 - _currentScript->counter / cmd->param2);
enableBarrier(cmd, kBarrierEnableType1);
} else {
- barrier->field_67C = _currentScript->counter / cmd->param2 + 1;
+ barrier->setField67C(_currentScript->counter / cmd->param2 + 1);
enableBarrier(cmd, kBarrierEnableType0);
}
@@ -584,9 +584,9 @@ IMPLEMENT_OPCODE(ResetAnimation) {
Barrier *barrier = _scene->worldstats()->getBarrierById(cmd->param1);
if (barrier->flags & kBarrierFlag10000)
- barrier->frameIdx = barrier->frameCount - 1;
+ barrier->setFrameIndex(barrier->getFrameCount() - 1);
else
- barrier->frameIdx = 0;
+ barrier->setFrameIndex(0);
}
//////////////////////////////////////////////////////////////////////////
@@ -897,9 +897,7 @@ IMPLEMENT_OPCODE(PlayMovie) {
IMPLEMENT_OPCODE(StopAllBarriersSounds) {
Barrier *barrier = _scene->worldstats()->getBarrierById(cmd->param1);
- for (int i = 0; i < ARRAYSIZE(barrier->soundItems); i++)
- if (barrier->soundItems[i].resourceId)
- _scene->vm()->sound()->stopSound(barrier->soundItems[i].resourceId);
+ barrier->stopAllSounds();
}
//////////////////////////////////////////////////////////////////////////
@@ -1050,9 +1048,9 @@ IMPLEMENT_OPCODE(WaitUntilFramePlayed) {
uint32 frameNum = cmd->param2;
if (frameNum == -1)
- frameNum = barrier->frameCount - 1;
+ frameNum = barrier->getFrameCount() - 1;
- if (barrier->frameIdx != frameNum) {
+ if (barrier->getFrameIndex() != frameNum) {
_lineIncrement = 1;
_waitCycle = true;
}
@@ -1451,24 +1449,24 @@ IMPLEMENT_OPCODE(JumpBarrierFrame) {
Barrier *barrier = _scene->worldstats()->getBarrierById(cmd->param1);
if (cmd->param2 == -1)
- cmd->param2 = barrier->frameCount - 1;
+ cmd->param2 = barrier->getFrameCount() - 1;
if (cmd->param3)
- if(barrier->frameIdx == (uint32)cmd->param2) {
+ if(barrier->getFrameIndex() == (uint32)cmd->param2) {
return;
} else if (cmd->param4)
- if (barrier->frameIdx < (uint32)cmd->param2) {
+ if (barrier->getFrameIndex() < (uint32)cmd->param2) {
return;
} else if (cmd->param5)
- if (barrier->frameIdx > (uint32)cmd->param2) {
+ if (barrier->getFrameIndex() > (uint32)cmd->param2) {
return;
} else if (cmd->param6)
- if (barrier->frameIdx <= (uint32)cmd->param2) {
+ if (barrier->getFrameIndex() <= (uint32)cmd->param2) {
return;
} else if (cmd->param7)
- if (barrier->frameIdx >= (uint32)cmd->param2) {
+ if (barrier->getFrameIndex() >= (uint32)cmd->param2) {
return;
- } else if (!cmd->param8 || barrier->frameIdx != (uint32)cmd->param2) {
+ } else if (!cmd->param8 || barrier->getFrameIndex() != (uint32)cmd->param2) {
return;
}
@@ -1593,7 +1591,7 @@ IMPLEMENT_OPCODE(SetBarrierFrameIdxFlaged) {
else
barrier->flags &= kBarrierFlagDestroyed;
- barrier->frameIdx = cmd->param2;
+ barrier->setFrameIndex(cmd->param2);
}
//////////////////////////////////////////////////////////////////////////
@@ -1624,10 +1622,10 @@ IMPLEMENT_OPCODE(_unk5B) {
if (cmd->param1) {
Barrier *barrier = _scene->worldstats()->getBarrierById(cmd->param1);
- barrier->field_67C = cmd->param2;
+ barrier->setField67C(cmd->param2);
- if (barrier->field_67C)
- barrier->field_67C += 3;
+ if (barrier->getField67C())
+ barrier->setField67C(barrier->getField67C() + 3);
} else {
_scene->getActor(cmd->param3)->setField96C(cmd->param2);
}
@@ -1662,7 +1660,7 @@ IMPLEMENT_OPCODE(ClearActorFields) {
IMPLEMENT_OPCODE(SetBarrierLastFrameIdx) {
Barrier *barrier = _scene->worldstats()->getBarrierById(cmd->param1);
- if (barrier->frameIdx == barrier->frameCount - 1) {
+ if (barrier->getFrameIndex() == barrier->getFrameCount() - 1) {
_lineIncrement = 0;
barrier->flags &= ~kBarrierFlag10E38;
} else {
diff --git a/engines/asylum/resources/actor.cpp b/engines/asylum/resources/actor.cpp
index 60d5fd5b36..155f424526 100644
--- a/engines/asylum/resources/actor.cpp
+++ b/engines/asylum/resources/actor.cpp
@@ -617,16 +617,16 @@ void Actor::faceTarget(int32 targetId, DirectionFrom from) {
return;
case kDirectionFromBarrier: {
- int32 barrierIndex = getWorld()->getBarrierIndexById(targetId);
- if (barrierIndex == -1) {
+ Barrier *barrier = getWorld()->getBarrierById(targetId);
+ if (!barrier) {
warning("[Actor::faceTarget] No Barrier found for id %d", targetId);
return;
}
- Barrier *barrier = getWorld()->getBarrierByIndex(barrierIndex);
- GraphicResource *resource = new GraphicResource(getScene()->getResourcePack(), barrier->resourceId);
- GraphicFrame *frame = resource->getFrame(barrier->frameIdx);
+
+ GraphicResource *resource = new GraphicResource(getScene()->getResourcePack(), barrier->getResourceId());
+ GraphicFrame *frame = resource->getFrame(barrier->getFrameIndex());
newX = (frame->surface.w >> 1) + barrier->x;
newY = (frame->surface.h >> 1) + barrier->y;
diff --git a/engines/asylum/resources/actor.h b/engines/asylum/resources/actor.h
index 9a4efb0815..20ffc9ec89 100644
--- a/engines/asylum/resources/actor.h
+++ b/engines/asylum/resources/actor.h
@@ -76,8 +76,8 @@ public:
int32 getActionIndex3() { return _actionIdx3; }
Common::Rect *getBoundingRect() { return &_boundingRect; }
ActorDirection getDirection() { return _direction; }
- int32 getFrameCount() { return _frameCount; }
- int32 getFrameNum() { return _frameNumber; }
+ uint32 getFrameCount() { return _frameCount; }
+ uint32 getFrameNum() { return _frameNumber; }
int32 getReaction(uint32 index) { return _reaction[index]; }
ResourceId getResourceId() { return _resourceId; }
ResourceId getResourcesId(uint32 index) { return _graphicResourceIds[index]; }
@@ -91,6 +91,12 @@ public:
/////////////////////////////////////////////////////////////////////////
// Data
/////////////////////////////////////////////////////////////////////////
+
+ /**
+ * Loads the actor data
+ *
+ * @param stream If non-null, the Common::SeekableReadStream to load from
+ */
void load(Common::SeekableReadStream *stream);
/////////////////////////////////////////////////////////////////////////
@@ -203,7 +209,7 @@ private:
//////////////////////////////////////////////////////////////////////////
// Data
-
+ //////////////////////////////////////////////////////////////////////////
ResourceId _resourceId;
int32 _field_C; // BarrierIndex? Mask index?
uint32 _frameNumber;
diff --git a/engines/asylum/resources/barrier.cpp b/engines/asylum/resources/barrier.cpp
index a60e1daa26..c6120b7943 100644
--- a/engines/asylum/resources/barrier.cpp
+++ b/engines/asylum/resources/barrier.cpp
@@ -25,17 +25,90 @@
#include "asylum/resources/barrier.h"
+#include "asylum/resources/actor.h"
+
#include "asylum/views/scene.h"
namespace Asylum {
-Barrier::Barrier(Scene *scene) : _scene(scene) {
+Barrier::Barrier(AsylumEngine *engine) : _vm(engine) {
}
Barrier::~Barrier() {
- // TODO Auto-generated destructor stub
}
+/////////////////////////////////////////////////////////////////////////
+// Loading & destroying
+/////////////////////////////////////////////////////////////////////////
+void Barrier::load(Common::SeekableReadStream *stream) {
+ _id = stream->readSint32LE();
+ _resourceId = stream->readSint32LE();
+ x = stream->readSint32LE();
+ y = stream->readSint32LE();
+
+ _boundingRect.left = stream->readSint32LE() & 0xFFFF;
+ _boundingRect.top = stream->readSint32LE() & 0xFFFF;
+ _boundingRect.right = stream->readSint32LE() & 0xFFFF;
+ _boundingRect.bottom = stream->readSint32LE() & 0xFFFF;
+
+ _field_20 = stream->readSint32LE();
+ _frameIndex = stream->readSint32LE();
+ _frameCount = stream->readSint32LE();
+ _field_2C = stream->readSint32LE();
+ _field_30 = stream->readSint32LE();
+ _field_34 = stream->readSint32LE();
+ flags = stream->readSint32LE();
+ _field_3C = stream->readSint32LE();
+
+ stream->read(_name, sizeof(_name));
+
+ _field_74 = stream->readSint32LE();
+ _field_78 = stream->readSint32LE();
+ _field_7C = stream->readSint32LE();
+ _field_80 = stream->readSint32LE();
+ _polygonIndex = stream->readSint32LE();
+ actionType = stream->readSint32LE();
+
+ for (int i = 0; i < 10; i++)
+ _gameFlags[i] = (GameFlag)stream->readSint32LE();
+
+ _field_B4 = stream->readSint32LE();
+ _tickCount = stream->readSint32LE();
+ _tickCount2 = stream->readSint32LE();
+ _field_C0 = stream->readSint32LE();
+ _priority = stream->readSint32LE();
+ _actionListIdx = stream->readSint32LE();
+
+ for (int i = 0; i < 16; i++) {
+ _soundItems[i].resourceId = stream->readSint32LE();
+ _soundItems[i].field_4 = stream->readSint32LE();
+ _soundItems[i].field_8 = stream->readSint32LE();
+ _soundItems[i].field_C = stream->readSint32LE();
+
+ }
+
+ for (int i = 0; i < 50; i++) {
+ _frameSoundItems[i].resourceId = stream->readSint32LE();
+ _frameSoundItems[i].frameIdx = stream->readSint32LE();
+ _frameSoundItems[i].index = stream->readSint32LE();
+ _frameSoundItems[i].field_C = stream->readSint32LE();
+ _frameSoundItems[i].field_10 = stream->readSint32LE();
+ _frameSoundItems[i].field_14 = stream->readSint32LE();
+ }
+
+ _field_67C = stream->readSint32LE();
+ _soundX = stream->readSint32LE();
+ _soundY = stream->readSint32LE();
+ _field_688 = stream->readSint32LE();
+
+ for (int i = 0; i < 5; i++)
+ _field_68C[i] = stream->readSint32LE();
+
+ _soundResourceId = stream->readSint32LE();
+ _field_6A4 = stream->readSint32LE();
+}
+
+
void Barrier::destroy() {
flags &= kBarrierFlagDestroyed;
}
@@ -44,28 +117,254 @@ void Barrier::destroyAndRemoveFromQueue() {
destroy();
flags|= kBarrierFlag20000;
- _scene->vm()->screen()->deleteGraphicFromQueue(resourceId);
+ getScreen()->deleteGraphicFromQueue(_resourceId);
}
-int32 Barrier::getRandomId() {
- int32 numRes = 0;
- ResourceId randomResourceIds[5];
- memset(&randomResourceIds, 0, sizeof(randomResourceIds));
- for (int32 i = 0; i < 5; i++) {
- if (field_68C[i]) {
- randomResourceIds[numRes] = field_68C[i];
- numRes++;
+/////////////////////////////////////////////////////////////////////////
+// Visibility
+//////////////////////////////////////////////////////////////////////////
+bool Barrier::isOnScreen() {
+ Common::Rect screenRect = Common::Rect(getWorld()->xLeft, getWorld()->yTop, getWorld()->xLeft + 640, getWorld()->yTop + 480);
+ Common::Rect barrierRect = Common::Rect(_boundingRect);
+
+ barrierRect.translate(x, y);
+
+ return isVisible() && (flags & 1) && screenRect.intersects(barrierRect);
+}
+
+bool Barrier::isVisible() {
+ if ((flags & 0xFF) & 1) {
+ for (int32 f = 0; f < 10; f++) {
+ bool isSet = false;
+ GameFlag flag = _gameFlags[f];
+
+ if (flag <= 0)
+ isSet = _vm->isGameFlagNotSet(flag);
+ else
+ isSet = _vm->isGameFlagSet(flag);
+
+ if (!isSet)
+ return false;
}
+ return true;
}
+ return false;
+}
- if (numRes > 0)
- return randomResourceIds[rand() % numRes];
+/////////////////////////////////////////////////////////////////////////
+// Update
+//////////////////////////////////////////////////////////////////////////
+void Barrier::draw(Actor *actor, Common::Point &pt) {
+ bool actInBar = _boundingRect.contains(*actor->getBoundingRect());
+ bool intersects = false;
+
+ // TODO verify that my funky LOBYTE macro actually
+ // works the way I assume it should :P
+ if (!actInBar) {
+ if (LOBYTE(flags) & 0x20)
+ if (!(LOBYTE(flags) & 0x80))
+ // XXX not sure if this will work, as it's
+ // supposed to set 0x40 to the lobyte...
+ flags |= 0x40;
+ return;
+ }
- return resourceId;
+ if (flags & 2) {
+ // TODO refactor
+ if (_field_74 || _field_78 ||
+ _field_7C || _field_80)
+ intersects = (pt.y > _field_78 + (_field_80 - _field_78) * (pt.x - _field_74) / (_field_7C - _field_74)) == 0;
+ else
+ intersects = true;
+ } else {
+ if (flags & 0x40) {
+ PolyDefinitions *poly = &getScene()->polygons()->entries[_polygonIndex];
+ if (pt.x > 0 && pt.y > 0 && poly->numPoints > 0)
+ intersects = poly->contains(pt.x, pt.y);
+ else
+ ;//warning ("[drawActorsAndBarriers] trying to find intersection of uninitialized point");
+ }
+ // XXX the original has an else case here that
+ // assigns intersects the value of the
+ // flags & 2 check, which doesn't make any sense since
+ // that path would never have been taken if code
+ // execution had made it's way here.
+ }
+ if (LOBYTE(flags) & 0x80 || intersects) {
+ if (LOBYTE(flags) & 0x20)
+ // XXX not sure if this will work, as it's
+ // supposed to set this value on the lobyte...
+ flags &= 0xBF | 0x80;
+ else
+ // XXX another lobyte assignment...
+ flags |= 0x40;
+ // TODO label jump up a few lines here. Investigate...
+ }
+ if (flags & 4) {
+ if (intersects) {
+ if(actor->flags & 2)
+ ;//warning ("[drawActorsAndBarriers] Assigning mask to masked character [%s]", _name);
+ else {
+ // TODO there's a call to sub_40ac10 that does
+ // a point calculation, but the result doesn't appear to
+ // ever be used, and the object passed in as a parameter
+ // isn't updated
+ actor->setBarrierIndex(getWorld()->getBarrierIndexById(_id));
+ actor->flags |= 2;
+ }
+ }
+ } else {
+ if (intersects) {
+ // XXX assuming the following:
+ // "if ( *(int *)((char *)&scene.characters[0].priority + v18) < *(v12_barrierPtr + 35) )"
+ // is the same as what I'm comparing :P
+ if (actor->getPriority() < _priority) {
+ actor->setField934(1);
+ actor->setPriority(_priority + 3);
+ // TODO there's a block of code here that seems
+ // to loop through the CharacterUpdateItems and do some
+ // priority adjustment. Since I'm not using CharacterUpdateItems as of yet,
+ // I'm not sure what to do here
+ // The loop seems to occur if:
+ // (a) there are still character items to process
+ // (b) sceneNumber != 2 && actor->field_944 != 1
+ }
+ } else {
+ if (actor->getPriority() > _priority || actor->getPriority() == 1) {
+ actor->setField934(1);
+ actor->setPriority(_priority - 1);
+ // TODO another character update loop
+ // This time it looks like there's another
+ // intersection test, and more updates
+ // to field_934 and field_944, then
+ // priority updates
+ }
+ }
+ }
}
-int32 Barrier::checkFlags() {
- return (flags & 1) && (flags & 8 || flags & 0x10000);
+void Barrier::update() {
+ bool canPlaySound = false;
+ if (_field_3C == 4) {
+ if (isVisible()) {
+ int32 flag = flags;
+ if (flag & 0x20) {
+ if (_vm->getTick() - _tickCount >= 0x3E8 / _field_B4) {
+ _frameIndex =((_frameIndex + 1) % _frameCount);
+ _tickCount = _vm->getTick();
+ canPlaySound = true;
+ }
+ } else if (flag & 0x10) {
+ uint32 frameIdx = _frameIndex;
+ int equalZero = frameIdx == 0;
+ if (!frameIdx) {
+ if (_vm->getTick() - _tickCount >= 1000 * _tickCount2) {
+ if (_vm->getRandom(_field_C0) == 1) {
+ if (_field_68C[0]) {
+ // TODO: fix this, and find a better way to get frame count
+ // Sometimes we get wrong random resource id
+
+ _resourceId = getRandomId();
+ GraphicResource *gra = new GraphicResource(getScene()->getResourcePack(), _resourceId);
+ _frameCount = gra->getFrameCount();
+ delete gra;
+ }
+ _frameIndex++;
+ }
+ _tickCount = _vm->getTick();
+ canPlaySound = true;
+ }
+ frameIdx = _frameIndex;
+ equalZero = frameIdx == 0;
+ }
+
+ if (!equalZero) {
+ if (_vm->getTick() - _tickCount >= 0x3E8 / _field_B4) {
+ _frameIndex = (_frameIndex + 1) % _frameCount;
+ _tickCount = _vm->getTick();
+ canPlaySound = true;
+ }
+ }
+ } else if (flag & 8) {
+ if (_vm->getTick() - _tickCount >= 0x3E8 / _field_B4) {
+ uint32 frameIdx = _frameIndex + 1;
+ if (frameIdx < _frameCount - 1) {
+ if (_field_688 == 1) {
+ // TODO: get global x, y positions
+ }
+ } else {
+ flags &= ~kBarrierFlag8;
+ if (_field_688 == 1) {
+ // TODO: reset global x, y positions
+ }
+ }
+ _frameIndex = frameIdx;
+ }
+ } else if ((flag & 0xFF) & 8) { // check this
+ if (_vm->getTick() - _tickCount >= 1000 * _tickCount2) {
+ if (_vm->getRandom(_field_C0) == 1) { // TODO: THIS ISNT WORKING
+ _frameIndex = (_frameIndex + 1) % _frameCount;
+ _tickCount = _vm->getTick();
+ canPlaySound = true;
+ }
+ }
+ } else if (!((flag & 0xFFFF) & 6)) {
+ if (_vm->getTick() - _tickCount >= 0x3E8 / _field_B4 && (flag & 0x10000)) {
+ uint32 frameIdx = _frameIndex - 1;
+ if (frameIdx <= 0) {
+ flags &= ~kBarrierFlag10000;
+ if (_field_688 == 1) {
+ // TODO: reset global x, y positions
+ }
+ _tickCount = _vm->getTick();
+ canPlaySound = true;
+ }
+ if (_field_688 == 1) {
+ // TODO: get global x, y positions
+ }
+ _frameIndex = frameIdx;
+ } else if (_vm->getTick() - _tickCount >= 0x3E8 / _field_B4) {
+ if ((flag & 0xFF) & 2) {
+ if (_frameIndex == _frameCount - 1) {
+ _frameIndex--;
+ flags = ((flag & 0xFF) & 0xFD) | 4;
+ } else {
+ _frameIndex++;
+ }
+ } else if ((flag & 0xFF) & 4) {
+ if (_frameIndex) {
+ _frameIndex--;
+ } else {
+ _frameIndex++;
+ flags = ((flag & 0xFF) & 0xFB) | 2;
+ }
+ }
+ }
+ }
+
+ flag = flags;
+ flag &= 0x40000;
+ if (flag != 0) {
+ if (_frameIndex == _frameCount - 1) {
+ if (_field_B4 <= 15) {
+ _field_B4 -= 2;
+ if (_field_B4 < 0)
+ _field_B4 = 0;
+ } else {
+ _field_B4 = 15;
+ }
+ if (!_field_B4)
+ flags &= 0xFFFEF1C7;
+ }
+ }
+ }
+
+ if (canPlaySound) {
+ updateSoundItems(_vm->sound());
+ stopSound();
+ }
+ }
+ // TODO: get sound functions according with scene
}
void Barrier::setNextFrame(int32 targetFlags) {
@@ -73,14 +372,17 @@ void Barrier::setNextFrame(int32 targetFlags) {
flags |= targetFlags | 1;
if (newFlag & 0x10000)
- frameIdx = frameCount - 1;
+ _frameIndex = _frameCount - 1;
else
- frameIdx = 0;
+ _frameIndex = 0;
}
+/////////////////////////////////////////////////////////////////////////
+// Misc
+/////////////////////////////////////////////////////////////////////////
void Barrier::updateSoundItems(Sound *snd) {
for (int32 i = 0; i < 16; i++) {
- SoundItem *item = &soundItems[i];
+ SoundItem *item = &_soundItems[i];
if (snd->isPlaying(item->resourceId)) {
if (item->field_4) {
snd->stopSound(item->resourceId);
@@ -90,15 +392,53 @@ void Barrier::updateSoundItems(Sound *snd) {
}
}
- // FIXME Barrier::updateSoundItems needs to be followed by a
- // call to Scene::stopSound(barIdx, 0). Since there aren't that
- // many calls to this method, I'm leaving this comment as a reminder
- // until all dependant methods are implemented
+ stopSound();
}
void Barrier::stopSound() {
- if (_scene->vm()->sound()->isPlaying(soundResourceId))
- _scene->vm()->sound()->stopSound(soundResourceId);
+ if (getSound()->isPlaying(_soundResourceId))
+ getSound()->stopSound(_soundResourceId);
+}
+
+void Barrier::stopAllSounds() {
+ for (int i = 0; i < ARRAYSIZE(_soundItems); i++)
+ if (_soundItems[i].resourceId)
+ getSound()->stopSound(_soundItems[i].resourceId);
+}
+
+
+int32 Barrier::getRandomId() {
+ int32 numRes = 0;
+ ResourceId randomResourceIds[5];
+ memset(&randomResourceIds, 0, sizeof(randomResourceIds));
+ for (int32 i = 0; i < 5; i++) {
+ if (_field_68C[i]) {
+ randomResourceIds[numRes] = _field_68C[i];
+ numRes++;
+ }
+ }
+
+ if (numRes > 0)
+ return randomResourceIds[rand() % numRes];
+
+ return _resourceId;
+}
+
+bool Barrier::checkFlags() {
+ return (flags & 1) && (flags & 8 || flags & 0x10000);
+}
+
+bool Barrier::checkGameFlags() {
+ if (LOBYTE(flags) & 1) {
+ for (int32 i = 0; i < 10; i++) {
+ if (_vm->isGameFlagSet(_gameFlags[i]))
+ return true;
+ }
+
+ return true;
+ }
+
+ return false;
}
} // end of namespace Asylum
diff --git a/engines/asylum/resources/barrier.h b/engines/asylum/resources/barrier.h
index 5eb4fc5b03..d5a58685a3 100644
--- a/engines/asylum/resources/barrier.h
+++ b/engines/asylum/resources/barrier.h
@@ -26,90 +26,177 @@
#ifndef ASYLUM_BARRIER_H
#define ASYLUM_BARRIER_H
+#include "asylum/shared.h"
+
#include "asylum/system/sound.h"
-#include "asylum/shared.h"
+#include "common/rect.h"
+#include "common/stream.h"
namespace Asylum {
-enum BarrierFlag {
- kBarrierFlagDestroyed = -2,
- kBarrierFlag4 = 0x4,
- kBarrierFlag8 = 0x8,
- kBarrierFlag20 = 0x20,
- kBarrierFlagC000 = 0xC000,
- kBarrierFlag10000 = 0x10000,
- kBarrierFlag10E38 = 0x10E38,
- kBarrierFlag20000 = 0x20000,
- kBarrierFlag40000 = 0x40000
-};
-
-class Scene;
+class Actor;
+class AsylumEngine;
class Barrier {
public:
- Barrier(Scene *scene);
+ Barrier(AsylumEngine *engine);
virtual ~Barrier();
+ //////////////////////////////////////////////////////////////////////////
+ // Public variables & accessors
+ //////////////////////////////////////////////////////////////////////////
+ int32 x;
+ int32 y;
+ int32 flags;
+ int32 actionType;
+
+ void setFrameIndex(int32 index) { _frameIndex = index; }
+ void setPriority(int32 priority) { _priority = priority; }
+ void setResourceId(ResourceId id) { _resourceId = id; }
+
+ void setField67C(int32 val) { _field_67C = val; }
+
+ Common::Rect *getBoundingRect() { return &_boundingRect; }
+ uint32 getFrameIndex() { return _frameIndex; }
+ uint32 getFrameCount() { return _frameCount; }
+ int32 getId() { return _id; }
+ int32 getPolygonIndex() { return _polygonIndex; }
+ int32 getPriority() { return _priority; }
+ ResourceId getResourceId() { return _resourceId; }
+
+ int32 getField67C() { return _field_67C; }
+ int32 getField688() { return _field_688; }
+
+ /////////////////////////////////////////////////////////////////////////
+ // Loading & destroying
+ /////////////////////////////////////////////////////////////////////////
+
+ /**
+ * Loads the barrier data
+ *
+ * @param stream If non-null, the Common::SeekableReadStream to load from
+ */
+ void load(Common::SeekableReadStream *stream);
+
+ /**
+ * Sets the barrier destroyed flag
+ */
void destroy();
+
+ /**
+ * Sets the barrier destroyed flag and remove this barrier from the graphics queue
+ */
void destroyAndRemoveFromQueue();
- bool visible();
- int32 getRandomId(); // TODO Give this a better name?
- bool onscreen();
+ /////////////////////////////////////////////////////////////////////////
+ // Visibility
+ //////////////////////////////////////////////////////////////////////////
+
+ /**
+ * Query if this barrier is on screen.
+ *
+ * @return true if on screen, false if not.
+ */
+ bool isOnScreen();
+
+ /**
+ * Query if this barrier is visible.
+ *
+ * @return true if visible, false if not.
+ */
+ bool isVisible();
- // TODO document this function
- int checkFlags();
- // TODO document this function
+ /////////////////////////////////////////////////////////////////////////
+ // Drawing & update
+ //////////////////////////////////////////////////////////////////////////
+
+ /**
+ * Draws the barrier
+ */
+ void draw(Actor *actor, Common::Point &pt);
+
+ /**
+ * Updates the barrier.
+ */
+ void update();
+
+ /**
+ * Sets the next frame.
+ *
+ * @param flags The flags.
+ */
void setNextFrame(int flags);
- /** .text:0040D0E0
+ /////////////////////////////////////////////////////////////////////////
+ // Misc
+ ////////////////////////////////////////////////////////////////////////
+
+ /**
* Check if any items in the barrier sound array are playing,
* and based on their flag values, stop them accordingly
*/
void updateSoundItems(Sound *snd);
+ /**
+ * Stop the barrier related sounds
+ */
void stopSound();
- int32 id;
- ResourceId resourceId;
- int32 x;
- int32 y;
- Common::Rect boundingRect;
- int32 field_20;
- uint32 frameIdx;
- uint32 frameCount;
- int32 field_2C;
- int32 field_30;
- int32 field_34;
- int32 flags;
- int32 field_3C;
- uint8 name[52];
- int32 field_74; // XXX looks like fields
- int32 field_78; // 74 => 80 have something
- int32 field_7C; // to do with calculating
- int32 field_80; // actor intersection
- int32 polyIdx;
- int32 actionType;
- GameFlag gameFlags[10];
- int32 field_B4;
- int32 tickCount;
- int32 tickCount2;
- int32 field_C0;
- int32 priority;
- int32 actionListIdx;
- SoundItem soundItems[16];
- FrameSoundItem frameSoundItems[50];
- int32 field_67C;
- int32 soundX;
- int32 soundY;
- int32 field_688;
- int32 field_68C[5];
- ResourceId soundResourceId;
- int32 field_6A4;
+ /**
+ * Stop all barrier sounds.
+ */
+ void stopAllSounds();
+
+ bool checkFlags();
+
+ bool checkGameFlags();
+
+ int32 getRandomId(); // TODO Give this a better name?
private:
- Scene *_scene;
+ AsylumEngine *_vm;
+
+ int32 _index; ///< our index
+
+ //////////////////////////////////////////////////////////////////////////
+ // Data
+ //////////////////////////////////////////////////////////////////////////
+ int32 _id;
+ ResourceId _resourceId;
+ // x, y
+ Common::Rect _boundingRect;
+ int32 _field_20;
+ uint32 _frameIndex;
+ uint32 _frameCount;
+ int32 _field_2C;
+ int32 _field_30;
+ int32 _field_34;
+ // flags
+ int32 _field_3C;
+ uint8 _name[52];
+ int32 _field_74; // XXX looks like fields
+ int32 _field_78; // 74 => 80 have something
+ int32 _field_7C; // to do with calculating
+ int32 _field_80; // actor intersection
+ int32 _polygonIndex;
+ // actionType
+ GameFlag _gameFlags[10];
+ int32 _field_B4;
+ int32 _tickCount;
+ int32 _tickCount2;
+ int32 _field_C0;
+ int32 _priority;
+ int32 _actionListIdx;
+ SoundItem _soundItems[16];
+ FrameSoundItem _frameSoundItems[50];
+ int32 _field_67C;
+ int32 _soundX;
+ int32 _soundY;
+ int32 _field_688;
+ int32 _field_68C[5];
+ ResourceId _soundResourceId;
+ int32 _field_6A4;
}; // end of class Barrier
diff --git a/engines/asylum/resources/worldstats.cpp b/engines/asylum/resources/worldstats.cpp
index 1c4928e162..b96f7f5f7d 100644
--- a/engines/asylum/resources/worldstats.cpp
+++ b/engines/asylum/resources/worldstats.cpp
@@ -57,7 +57,7 @@ ActionArea* WorldStats::getActionAreaById(int32 id) {
int32 WorldStats::getBarrierIndexById(int32 id) {
for (int32 i = 0; i < numBarriers; i++) {
- if (barriers[i]->id == id)
+ if (barriers[i]->getId() == id)
return i;
}
@@ -68,58 +68,6 @@ Barrier* WorldStats::getBarrierById(int32 id) {
return barriers[getBarrierIndexById(id)];
}
-Barrier* WorldStats::getBarrierByIndex(int32 idx) {
- return barriers[idx];
-}
-
-bool WorldStats::isBarrierOnScreen(int32 idx) {
- Barrier *b = getBarrierByIndex(idx);
-
- Common::Rect screenRect = Common::Rect(xLeft, yTop, xLeft + 640, yTop + 480);
- Common::Rect barrierRect = b->boundingRect;
- barrierRect.translate(b->x, b->y);
- return isBarrierVisible(idx) && (b->flags & 1) && screenRect.intersects(barrierRect);
-}
-
-bool WorldStats::isBarrierVisible(int32 idx) {
- Barrier *b = getBarrierByIndex(idx);
-
- if ((b->flags & 0xFF) & 1) {
- for (int32 f = 0; f < 10; f++) {
- bool isSet = false;
- GameFlag flag = b->gameFlags[f];
-
- if (flag <= 0)
- isSet = _scene->vm()->isGameFlagNotSet(flag); // -flag
- else
- isSet = _scene->vm()->isGameFlagSet(flag);
-
- if (!isSet)
- return false;
- }
- return true;
- }
- return false;
-}
-
-bool WorldStats::checkBarrierFlagsCondition(int32 idx) {
- Barrier *b = getBarrierByIndex(idx);
- bool result;
-
- if (LOBYTE(b->flags) & 1) {
- for (int32 i = 0; i < 10; i++) {
- result = _scene->vm()->isGameFlagSet(b->gameFlags[i]);
- if (result)
- return result;
- }
- result = true;
- } else {
- result = false;
- }
-
- return result;
-}
-
// FIXME: load necessary World Stats content
void WorldStats::load(Common::SeekableReadStream *stream) {
size = stream->readSint32LE();
@@ -225,74 +173,8 @@ void WorldStats::load(Common::SeekableReadStream *stream) {
musicStatusExt = stream->readSint32LE();
for (int32 a = 0; a < numBarriers; a++) {
- int32 i;
- Barrier *barrier = new Barrier(_scene);
-
- barrier->id = stream->readSint32LE();
- barrier->resourceId = stream->readSint32LE();
- barrier->x = stream->readSint32LE();
- barrier->y = stream->readSint32LE();
-
- barrier->boundingRect.left = stream->readSint32LE() & 0xFFFF;
- barrier->boundingRect.top = stream->readSint32LE() & 0xFFFF;
- barrier->boundingRect.right = stream->readSint32LE() & 0xFFFF;
- barrier->boundingRect.bottom = stream->readSint32LE() & 0xFFFF;
-
- barrier->field_20 = stream->readSint32LE();
- barrier->frameIdx = stream->readSint32LE();
- barrier->frameCount = stream->readSint32LE();
- barrier->field_2C = stream->readSint32LE();
- barrier->field_30 = stream->readSint32LE();
- barrier->field_34 = stream->readSint32LE();
- barrier->flags = stream->readSint32LE();
- barrier->field_3C = stream->readSint32LE();
-
- stream->read(barrier->name, sizeof(barrier->name));
-
- barrier->field_74 = stream->readSint32LE();
- barrier->field_78 = stream->readSint32LE();
- barrier->field_7C = stream->readSint32LE();
- barrier->field_80 = stream->readSint32LE();
- barrier->polyIdx = stream->readSint32LE();
- barrier->actionType = stream->readSint32LE();
-
- for (i = 0; i < 10; i++)
- barrier->gameFlags[i] = (GameFlag)stream->readSint32LE();
-
- barrier->field_B4 = stream->readSint32LE();
- barrier->tickCount = stream->readSint32LE();
- barrier->tickCount2 = stream->readSint32LE();
- barrier->field_C0 = stream->readSint32LE();
- barrier->priority = stream->readSint32LE();
- barrier->actionListIdx = stream->readSint32LE();
-
- for (i = 0; i < 16; i++) {
- barrier->soundItems[i].resourceId = stream->readSint32LE();
- barrier->soundItems[i].field_4 = stream->readSint32LE();
- barrier->soundItems[i].field_8 = stream->readSint32LE();
- barrier->soundItems[i].field_C = stream->readSint32LE();
-
- }
-
- for (i = 0; i < 50; i++) {
- barrier->frameSoundItems[i].resourceId = stream->readSint32LE();
- barrier->frameSoundItems[i].frameIdx = stream->readSint32LE();
- barrier->frameSoundItems[i].index = stream->readSint32LE();
- barrier->frameSoundItems[i].field_C = stream->readSint32LE();
- barrier->frameSoundItems[i].field_10 = stream->readSint32LE();
- barrier->frameSoundItems[i].field_14 = stream->readSint32LE();
- }
-
- barrier->field_67C = stream->readSint32LE();
- barrier->soundX = stream->readSint32LE();
- barrier->soundY = stream->readSint32LE();
- barrier->field_688 = stream->readSint32LE();
-
- for (i = 0; i < 5; i++)
- barrier->field_68C[i] = stream->readSint32LE();
-
- barrier->soundResourceId = stream->readSint32LE();
- barrier->field_6A4 = stream->readSint32LE();
+ Barrier *barrier = new Barrier(_scene->vm());
+ barrier->load(stream);
barriers.push_back(barrier);
}
diff --git a/engines/asylum/resources/worldstats.h b/engines/asylum/resources/worldstats.h
index 7fcb01420b..a9154c9393 100644
--- a/engines/asylum/resources/worldstats.h
+++ b/engines/asylum/resources/worldstats.h
@@ -121,12 +121,6 @@ public:
int32 getBarrierIndexById(int32 id);
Barrier* getBarrierById(int32 id);
- Barrier* getBarrierByIndex(int32 idx);
-
- bool isBarrierOnScreen(int32 idx);
- bool isBarrierVisible(int32 idx);
- // TODO this needs a better name
- bool checkBarrierFlagsCondition(int32 idx);
private:
Scene *_scene;
diff --git a/engines/asylum/shared.h b/engines/asylum/shared.h
index 2c25bde543..2c103a3d46 100644
--- a/engines/asylum/shared.h
+++ b/engines/asylum/shared.h
@@ -31,7 +31,6 @@ namespace Asylum {
//////////////////////////////////////////////////////////////////////////
// Global
//////////////////////////////////////////////////////////////////////////
-
enum GameFlag {
kGameFlag4 = 4,
kGameFlag12 = 12,
@@ -223,6 +222,21 @@ enum ActorResources {
// TODO: finish these
};
+//////////////////////////////////////////////////////////////////////////
+// Barrier
+//////////////////////////////////////////////////////////////////////////
+enum BarrierFlag {
+ kBarrierFlagDestroyed = -2,
+ kBarrierFlag4 = 0x4,
+ kBarrierFlag8 = 0x8,
+ kBarrierFlag20 = 0x20,
+ kBarrierFlagC000 = 0xC000,
+ kBarrierFlag10000 = 0x10000,
+ kBarrierFlag10E38 = 0x10E38,
+ kBarrierFlag20000 = 0x20000,
+ kBarrierFlag40000 = 0x40000
+};
+
//////////////////////////////////////////////////////////////////////////
// Helpers
//////////////////////////////////////////////////////////////////////////
@@ -242,9 +256,10 @@ enum ActorResources {
#define rnd(val) _vm->getRandom(val)
// Engine subclasses
-#define getSound() _vm->sound()
-#define getScene() _vm->scene()
-#define getWorld() _vm->scene()->worldstats()
+#define getSound() _vm->sound()
+#define getScene() _vm->scene()
+#define getScreen() _vm->screen()
+#define getWorld() _vm->scene()->worldstats()
diff --git a/engines/asylum/system/sound.h b/engines/asylum/system/sound.h
index b0bd6962bb..7c6f8e8809 100644
--- a/engines/asylum/system/sound.h
+++ b/engines/asylum/system/sound.h
@@ -35,15 +35,15 @@
namespace Asylum {
-typedef struct SoundItem {
+struct SoundItem {
ResourceId resourceId;
int32 field_4;
int32 field_8;
int32 field_C;
-} SoundItem;
+};
-typedef struct FrameSoundItem {
+struct FrameSoundItem {
ResourceId resourceId;
int32 frameIdx;
int32 index;
@@ -51,9 +51,9 @@ typedef struct FrameSoundItem {
int32 field_10;
int32 field_14;
-} FrameSoundItem;
+};
-typedef struct AmbientSoundItem {
+struct AmbientSoundItem {
int32 field_0;
int32 flags;
ResourceId resourceId;
@@ -64,13 +64,13 @@ typedef struct AmbientSoundItem {
int32 x;
int32 y;
-} AmbientSoundItem;
+};
-typedef struct SoundBufferItem {
+struct SoundBufferItem {
ResourceId resourceId;
Audio::SoundHandle handle;
int32 unknown;
-} SoundBufferItem;
+};
class Sound {
public:
diff --git a/engines/asylum/views/scene.cpp b/engines/asylum/views/scene.cpp
index 36e2ba0253..b8cf0efdcc 100644
--- a/engines/asylum/views/scene.cpp
+++ b/engines/asylum/views/scene.cpp
@@ -120,7 +120,7 @@ void Scene::initialize() {
int32 priority = 0x0FFB;
for (int32 b = 0; b < _ws->numBarriers; b++) {
Barrier *barrier = _ws->barriers[b];
- barrier->priority = priority;
+ barrier->setPriority(priority);
barrier->flags &= ~kBarrierFlagC000;
priority -= 4;
}
@@ -225,7 +225,7 @@ void Scene::enterScene() {
if (!_titleLoaded) {
_title = new SceneTitle(this);
// disable input polling
- _actions->_allowInput = false;
+ //_actions->_allowInput = false;
} else {
#endif
_vm->screen()->setPalette(_resPack, _ws->currentPaletteId);
@@ -647,10 +647,10 @@ void Scene::handleMouseUpdate(int direction, Common::Rect rect) {
int32 Scene::hitTestBarrier(const Common::Point pt) {
int32 targetIdx = -1;
for (int32 i = 0; i < _ws->numBarriers; i++) {
- Barrier *b = _ws->barriers[i];
- if (_ws->isBarrierOnScreen(i))
- if (b->polyIdx)
- if (hitTestPixel(b->resourceId, b->frameIdx, pt.x, pt.y, b->flags & 0x1000)) {
+ Barrier *barrier = _ws->barriers[i];
+ if (barrier->isOnScreen())
+ if (barrier->getPolygonIndex())
+ if (hitTestPixel(barrier->getResourceId(), barrier->getFrameIndex(), pt.x, pt.y, barrier->flags & 0x1000)) {
targetIdx = i;
break;
}
@@ -762,144 +762,13 @@ void Scene::changePlayerActorIndex(ActorIndex index) {
}
void Scene::updateActors() {
- for (int32 a = 0; a < _ws->numActors; a++)
- getActor(a)->update();
+ for (uint32 i = 0; i < _ws->actors.size(); i++)
+ _ws->actors[i]->update();
}
void Scene::updateBarriers() {
- //Screen *screen = _vm->screen();
-
- int32 barriersCount = (int32)_ws->barriers.size();
- //int startTickCount = 0;
- bool canPlaySound = false;
-
- if (barriersCount > 0) {
- for (int32 b = 0; b < barriersCount; b++) {
- Barrier *barrier = _ws->barriers[b];
-
- if (barrier->field_3C == 4) {
- if (_ws->isBarrierVisible(b)) {
- int32 flag = barrier->flags;
- if (flag & 0x20) {
- if (_vm->getTick() - barrier->tickCount >= 0x3E8 / barrier->field_B4) {
- barrier->frameIdx = (barrier->frameIdx + 1) % barrier->frameCount;
- barrier->tickCount = _vm->getTick();
- canPlaySound = true;
- }
- } else if (flag & 0x10) {
- uint32 frameIdx = barrier->frameIdx;
- int equalZero = frameIdx == 0;
- if (!frameIdx) {
- if (_vm->getTick() - barrier->tickCount >= 1000 * barrier->tickCount2) {
- if (vm()->getRandom(barrier->field_C0) == 1) {
- if (barrier->field_68C[0]) {
- // TODO: fix this, and find a better way to get frame count
- // Sometimes we get wrong random resource id
-
- barrier->resourceId = barrier->getRandomId();
- GraphicResource *gra = new GraphicResource(_resPack, barrier->resourceId);
- barrier->frameCount = gra->getFrameCount();
- delete gra;
- }
- barrier->frameIdx++;
- }
- barrier->tickCount = _vm->getTick();
- canPlaySound = true;
- }
- frameIdx = barrier->frameIdx;
- equalZero = frameIdx == 0;
- }
-
- if (!equalZero) {
- if (_vm->getTick() - barrier->tickCount >= 0x3E8 / barrier->field_B4) {
- barrier->frameIdx = (barrier->frameIdx + 1) % barrier->frameCount;
- barrier->tickCount = _vm->getTick();
- canPlaySound = true;
- }
- }
- } else if (flag & 8) {
- if (_vm->getTick() - barrier->tickCount >= 0x3E8 / barrier->field_B4) {
- uint32 frameIdx = barrier->frameIdx + 1;
- if (frameIdx < barrier->frameCount - 1) {
- if (barrier->field_688 == 1) {
- // TODO: get global x, y positions
- }
- } else {
- barrier->flags &= ~kBarrierFlag8;
- if (barrier->field_688 == 1) {
- // TODO: reset global x, y positions
- }
- }
- barrier->frameIdx = frameIdx;
- }
- } else if ((flag & 0xFF) & 8) { // check this
- if (_vm->getTick() - barrier->tickCount >= 1000 * barrier->tickCount2) {
- if (vm()->getRandom(barrier->field_C0) == 1) { // TODO: THIS ISNT WORKING
- barrier->frameIdx = (barrier->frameIdx + 1) % barrier->frameCount;
- barrier->tickCount = _vm->getTick();
- canPlaySound = true;
- }
- }
- } else if (!((flag & 0xFFFF) & 6)) {
- if (_vm->getTick() - barrier->tickCount >= 0x3E8 / barrier->field_B4 && (flag & 0x10000)) {
- uint32 frameIdx = barrier->frameIdx - 1;
- if (frameIdx <= 0) {
- barrier->flags &= ~kBarrierFlag10000;
- if (barrier->field_688 == 1) {
- // TODO: reset global x, y positions
- }
- barrier->tickCount = _vm->getTick();
- canPlaySound = true;
- }
- if (barrier->field_688 == 1) {
- // TODO: get global x, y positions
- }
- barrier->frameIdx = frameIdx;
- } else if (_vm->getTick() - barrier->tickCount >= 0x3E8 / barrier->field_B4) {
- if ((flag & 0xFF) & 2) {
- if (barrier->frameIdx == barrier->frameCount - 1) {
- barrier->frameIdx--;
- barrier->flags = ((flag & 0xFF) & 0xFD) | 4;
- } else {
- barrier->frameIdx++;
- }
- } else if ((flag & 0xFF) & 4) {
- if (barrier->frameIdx) {
- barrier->frameIdx--;
- } else {
- barrier->frameIdx++;
- barrier->flags = ((flag & 0xFF) & 0xFB) | 2;
- }
- }
- }
- }
-
- flag = barrier->flags;
- flag &= 0x40000;
- if (flag != 0) {
- if (barrier->frameIdx == barrier->frameCount - 1) {
- if (barrier->field_B4 <= 15) {
- barrier->field_B4 -= 2;
- if (barrier->field_B4 < 0)
- barrier->field_B4 = 0;
- } else {
- barrier->field_B4 = 15;
- }
- if (!barrier->field_B4)
- barrier->flags &= 0xFFFEF1C7;
- }
- }
- }
-
- if (canPlaySound) {
- barrier->updateSoundItems(_vm->sound());
- barrier->stopSound();
- }
-
- // TODO: get sound functions according with scene
- }
- }
- }
+ for (uint32 i = 0; i < _ws->barriers.size(); i++)
+ _ws->barriers[i]->update();
}
void Scene::updateAmbientSounds() {
@@ -1222,93 +1091,7 @@ void Scene::drawActorsAndBarriers() {
// XXX from .text:0040a4d1
for (int32 barIdx = 0; barIdx < _ws->numBarriers; barIdx++) {
- Barrier *bar = _ws->barriers[barIdx];
- bool actInBar = bar->boundingRect.contains(*act->getBoundingRect());
- bool intersects = false;
-
- // TODO verify that my funky LOBYTE macro actually
- // works the way I assume it should :P
- if (!actInBar) {
- if (LOBYTE(bar->flags) & 0x20)
- if (!(LOBYTE(bar->flags) & 0x80))
- // XXX not sure if this will work, as it's
- // supposed to set 0x40 to the lobyte...
- bar->flags |= 0x40;
- continue;
- }
-
- if (bar->flags & 2) {
- // TODO refactor
- if (bar->field_74 || bar->field_78 ||
- bar->field_7C || bar->field_80)
- intersects = (pt.y > bar->field_78 + (bar->field_80 - bar->field_78) * (pt.x - bar->field_74) / (bar->field_7C - bar->field_74)) == 0;
- else
- intersects = true;
- } else {
- if (bar->flags & 0x40) {
- PolyDefinitions *poly = &_polygons->entries[bar->polyIdx];
- if (pt.x > 0 && pt.y > 0 && poly->numPoints > 0)
- intersects = poly->contains(pt.x, pt.y);
- else
- ;//warning ("[drawActorsAndBarriers] trying to find intersection of uninitialized point");
- }
- // XXX the original has an else case here that
- // assigns intersects the value of the
- // flags & 2 check, which doesn't make any sense since
- // that path would never have been taken if code
- // execution had made it's way here.
- }
- if (LOBYTE(bar->flags) & 0x80 || intersects) {
- if (LOBYTE(bar->flags) & 0x20)
- // XXX not sure if this will work, as it's
- // supposed to set this value on the lobyte...
- bar->flags &= 0xBF | 0x80;
- else
- // XXX another lobyte assignment...
- bar->flags |= 0x40;
- // TODO label jump up a few lines here. Investigate...
- }
- if (bar->flags & 4) {
- if (intersects) {
- if(act->flags & 2)
- ;//warning ("[drawActorsAndBarriers] Assigning mask to masked character [%s]", bar->name);
- else {
- // TODO there's a call to sub_40ac10 that does
- // a point calculation, but the result doesn't appear to
- // ever be used, and the object passed in as a parameter
- // isn't updated
- act->setBarrierIndex(barIdx);
- act->flags |= 2;
- }
- }
- } else {
- if (intersects) {
- // XXX assuming the following:
- // "if ( *(int *)((char *)&scene.characters[0].priority + v18) < *(v12_barrierPtr + 35) )"
- // is the same as what I'm comparing :P
- if (act->getPriority() < bar->priority) {
- act->setField934(1);
- act->setPriority(bar->priority + 3);
- // TODO there's a block of code here that seems
- // to loop through the CharacterUpdateItems and do some
- // priority adjustment. Since I'm not using CharacterUpdateItems as of yet,
- // I'm not sure what to do here
- // The loop seems to occur if:
- // (a) there are still character items to process
- // (b) sceneNumber != 2 && actor->field_944 != 1
- }
- } else {
- if (act->getPriority() > bar->priority || act->getPriority() == 1) {
- act->setField934(1);
- act->setPriority(bar->priority - 1);
- // TODO another character update loop
- // This time it looks like there's another
- // intersection test, and more updates
- // to field_934 and field_944, then
- // priority updates
- }
- }
- }
+ _ws->barriers[barIdx]->draw(act, pt);
} // end for (barriers)
}
} // end for (actors)
@@ -1360,15 +1143,15 @@ int Scene::queueBarrierUpdates() {
Barrier *barrier = _ws->barriers[b];
if (!(barrier->flags & 4) && !((barrier->flags & 0xFF) & 0x40)) {
- if (_ws->isBarrierOnScreen(b)) {
+ if (barrier->isOnScreen()) {
//TODO: need to do something here yet
- if (barrier->field_67C <= 0 || barrier->field_67C >= 4) { // TODO: still missing a condition for game quality config
- _vm->screen()->addGraphicToQueue(barrier->resourceId, barrier->frameIdx, barrier->x, barrier->y, (barrier->flags >> 11) & 2, barrier->field_67C - 3, barrier->priority);
+ if (barrier->getField67C() <= 0 || barrier->getField67C() >= 4) { // TODO: still missing a condition for game quality config
+ _vm->screen()->addGraphicToQueue(barrier->getResourceId(), barrier->getFrameIndex(), barrier->x, barrier->y, (barrier->flags >> 11) & 2, barrier->getField67C() - 3, barrier->getPriority());
} else {
// TODO: Do Cross Fade
// parameters: barrier->resourceId, barrier->frameIdx, barrier->x, barrier->y, _ws->backgroundImage, _ws->xLeft, _ws->yTop, 0, 0, barrier->field_67C - 1
- _vm->screen()->addGraphicToQueue(barrier->resourceId, barrier->frameIdx, barrier->x, barrier->y, 0, 0, 0);
+ _vm->screen()->addGraphicToQueue(barrier->getResourceId(), barrier->getFrameIndex(), barrier->x, barrier->y, 0, 0, 0);
}
}
}
@@ -1479,14 +1262,14 @@ void Scene::debugShowPolygons() {
void Scene::debugShowBarriers() {
for (int32 p = 0; p < _ws->numBarriers; p++) {
Graphics::Surface surface;
- Barrier *b = _ws->barriers[p];
+ Barrier *barrier = _ws->barriers[p];
- if (b->flags & 0x20) {
- surface.create(b->boundingRect.right - b->boundingRect.left + 1,
- b->boundingRect.bottom - b->boundingRect.top + 1,
+ if (barrier->flags & 0x20) {
+ surface.create(barrier->getBoundingRect()->right - barrier->getBoundingRect()->left + 1,
+ barrier->getBoundingRect()->bottom - barrier->getBoundingRect()->top + 1,
1);
- surface.frameRect(b->boundingRect, 0x22);
- copyToBackBufferClipped(&surface, b->x, b->y);
+ surface.frameRect(*barrier->getBoundingRect(), 0x22);
+ copyToBackBufferClipped(&surface, barrier->x, barrier->y);
}
surface.free();
Commit: 051ea98d5e0dbc8599a0b0044758e6486c8ff501
https://github.com/scummvm/scummvm/commit/051ea98d5e0dbc8599a0b0044758e6486c8ff501
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:08+02:00
Commit Message:
ASYLUM: Update ConfigManager
- Added registration and loading/reading engine-related config options
- Make showing intro & scene loading config options
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@476 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/asylum.cpp
engines/asylum/asylum.h
engines/asylum/system/config.cpp
engines/asylum/system/config.h
engines/asylum/system/video.cpp
engines/asylum/system/video.h
engines/asylum/views/blowuppuzzle.cpp
engines/asylum/views/scene.cpp
engines/asylum/views/scene.h
diff --git a/engines/asylum/asylum.cpp b/engines/asylum/asylum.cpp
index f50a699244..2547cbedf7 100644
--- a/engines/asylum/asylum.cpp
+++ b/engines/asylum/asylum.cpp
@@ -112,9 +112,8 @@ Common::Error AsylumEngine::run() {
Config.read();
// TODO: init unknown game stuffs (.text:0040F430)
-#ifndef SKIP_INTRO
- _video->playVideo(0, Config.showMovieSubtitles);
-#endif
+ if (Config.showIntro)
+ _video->playVideo(0, Config.showMovieSubtitles);
// Set up main menu
_mainMenu = new MainMenu(this);
@@ -153,9 +152,9 @@ void AsylumEngine::startGame() {
_scene = new Scene(5, this);
-#ifndef SKIP_INTRO
- playIntro();
-#endif
+ if (Config.showIntro)
+ playIntro();
+
_scene->initialize();
// FIXME This is just here for testing purposes. It is also defined
@@ -182,8 +181,8 @@ void AsylumEngine::playIntro() {
_video->playVideo(1, Config.showMovieSubtitles);
- if (_scene->worldstats()->musicCurrentResourceId != kResourceMusic_FFFFFD66)
- _sound->playMusic(_scene->getResourcePack(), _scene->worldstats()->musicCurrentResourceId);
+ /*if (_scene->worldstats()->musicCurrentResourceId != kResourceMusic_FFFFFD66)
+ _sound->playMusic(_scene->getResourcePack(), _scene->worldstats()->musicCurrentResourceId);*/
_screen->clearScreen();
@@ -297,7 +296,7 @@ void AsylumEngine::processDelayedEvents() {
if (videoIdx >= 0) {
_sound->stopMusic();
_sound->stopAllSounds();
- _video->playVideo(videoIdx, kSubtitlesOn);
+ _video->playVideo(videoIdx, true);
_scene->actions()->setDelayedVideoIndex(-1);
if (_mainMenu->isActive())
diff --git a/engines/asylum/asylum.h b/engines/asylum/asylum.h
index 2ee54edad2..037d95bef3 100644
--- a/engines/asylum/asylum.h
+++ b/engines/asylum/asylum.h
@@ -58,18 +58,8 @@
*/
namespace Asylum {
-// XXX
-// If defined, this will play the scene title loading up
-// progress before the scene is entered. This is
-// just a convenience, as there's no need for the type
-// of pre-loading that was performed in the original
-#define SHOW_SCENE_LOADING
-
-//#define SHOW_SCENE_TIMES
-
-// XXX If defined, this flag will prevent the intro movies
-// from being played whenever the engine is started
-#define SKIP_INTRO
+// If defined, will show the scene update times on the debugger output
+//#define DEBUG_SCENE_TIMES
// XXX
// I'm not sure if system endian-ness would have any
diff --git a/engines/asylum/system/config.cpp b/engines/asylum/system/config.cpp
index ed2d529129..ea647ea619 100644
--- a/engines/asylum/system/config.cpp
+++ b/engines/asylum/system/config.cpp
@@ -36,32 +36,82 @@ ConfigurationManager::ConfigurationManager() {
g_config_initialized = true;
}
- // if the values don't currently exist within the
- // configuration file, load the defaults
+ // Register engine-specific options
+ ConfMan.registerDefault("show_encounter_subtitles", true);
+ ConfMan.registerDefault("gamma_level", 0);
+ ConfMan.registerDefault("ambient_volume", 0);
+ ConfMan.registerDefault("movie_volume", 0);
+ ConfMan.registerDefault("music_status", true);
+ ConfMan.registerDefault("reverse_stereo", false);
+ ConfMan.registerDefault("performance", 5);
+ //ConfMan.registerDefault("versionKey", );
+ //ConfMan.registerDefault("quicksave_key", );
+ //ConfMan.registerDefault("quickload_key", );
+ //ConfMan.registerDefault("switch_to_sara_key", );
+ //ConfMan.registerDefault("switch_to_grimwall_key", );
+ //ConfMan.registerDefault("switch_to_olmec_key", );
- ambientVolume = 0;
- movieVolume = 0;
+ ConfMan.registerDefault("show_scene_loading", false);
+ ConfMan.registerDefault("show_intro", true);
+
+ // Init values
musicVolume = 0;
sfxVolume = 0;
+ voiceVolume = 0;
+ showMovieSubtitles = false;
+
+ showEncounterSubtitles = true;
+ gammaLevel = 0;
+ ambientVolume = 0;
+ movieVolume = 0;
+ musicStatus = true;
+ reverseStereo = false;
+ performance = 5;
}
ConfigurationManager::~ConfigurationManager() {
}
void ConfigurationManager::read() {
- // TODO: read all necessary configuration settings
+ // Default options
musicVolume = ConfMan.getInt("music_volume");
sfxVolume = ConfMan.getInt("sfx_volume");
voiceVolume = ConfMan.getInt("speech_volume");
- showMovieSubtitles = (VideoSubtitles)ConfMan.getBool("subtitles");
+ showMovieSubtitles = ConfMan.getBool("subtitles");
+
+ // Engine options
+ showEncounterSubtitles = ConfMan.getBool("show_encounter_subtitles");
+ gammaLevel = ConfMan.getInt("gamma_level");
+ ambientVolume = ConfMan.getInt("ambient_volume");;
+ movieVolume = ConfMan.getInt("movie_volume");
+ musicStatus = ConfMan.getBool("music_status");
+ reverseStereo = ConfMan.getBool("reverse_stereo");
+ performance = ConfMan.getInt("performance");
+
+ // Misc options
+ showSceneLoading = ConfMan.getBool("show_scene_loading");
+ showIntro = ConfMan.getBool("show_intro");
}
void ConfigurationManager::write() {
- // TODO: save all necessary configuration settings
+ // Default options
ConfMan.setInt("music_volume", musicVolume);
ConfMan.setInt("sfx_volume", sfxVolume);
ConfMan.setInt("speech_volume", voiceVolume);
- ConfMan.setBool("subtitles", (bool)showMovieSubtitles);
+ ConfMan.setBool("subtitles", showMovieSubtitles);
+
+ // Engine options
+ ConfMan.setBool("show_encounter_subtitles", showEncounterSubtitles);
+ ConfMan.setInt("gamma_level", gammaLevel);
+ ConfMan.setInt("ambient_volume", ambientVolume);
+ ConfMan.setInt("movie_volume", movieVolume);
+ ConfMan.setBool("music_status", musicStatus);
+ ConfMan.setBool("reverse_stereo", reverseStereo);
+ ConfMan.setInt("performance", performance);
+
+ // Misc Options
+ ConfMan.setBool("show_scene_loading", showSceneLoading);
+ ConfMan.setBool("show_intro", showIntro);
}
} // end of namespace Asylum
diff --git a/engines/asylum/system/config.h b/engines/asylum/system/config.h
index beb1eb117d..780faaff93 100644
--- a/engines/asylum/system/config.h
+++ b/engines/asylum/system/config.h
@@ -33,8 +33,6 @@
namespace Asylum {
-enum VideoSubtitles;
-
/**
* The ConfigurationManager is where the common configuration options used
* by the engine are bound.
@@ -44,36 +42,53 @@ enum VideoSubtitles;
class ConfigurationManager: public Common::Singleton<ConfigurationManager> {
public:
- // XXX Throwing some globals in here until
- // I know how to better handle them
- int word_446EE4;
+ //////////////////////////////////////////////////////////////////////////
+ // Normal configuration
+ //////////////////////////////////////////////////////////////////////////
- VideoSubtitles showMovieSubtitles;
- Common::Array<int> movieSubtitles;
- bool showEncounterSubtitles;
- Common::Array<int> encounterSubtitles; // FIXME: take this out
- int musicVolume;
- int ambientVolume;
+ // Default options
+ int musicVolume;
int sfxVolume;
int voiceVolume;
+ bool showMovieSubtitles;
+
+ // Engine options
+ bool showEncounterSubtitles;
+ int gammaLevel;
+ int ambientVolume;
int movieVolume;
bool musicStatus; // On or Off
bool reverseStereo;
- int gammaLevel;
+ int performance; ///< performance only affects sound: perf > 0 ? 22050hz/16bit : 11025hz/8bit
+ int versionKey;
+ int quickSaveKey;
+ int quickLoadKey;
+ int switchToSaraKey;
+ int switchToGrimwallKey;
+ int switchToOlmecKey;
+
+ //////////////////////////////////////////////////////////////////////////
+ // Misc configuration options (not shown in GUI)
+ //////////////////////////////////////////////////////////////////////////
+
+ // This will play the scene title loading up progress before the scene is entered.
+ // This is just a convenience, as there's no need for the type of pre-loading that
+ // was performed in the original
+ bool showSceneLoading;
+
+ // This option will prevent the intro movies from being played whenever the engine is started
+ bool showIntro;
+
+ //////////////////////////////////////////////////////////////////////////
+ // TO REMOVE ??
+ //////////////////////////////////////////////////////////////////////////
+ // XXX Throwing some globals in here until
+ // I know how to better handle them
+ int word_446EE4;
- /**
- * XXX The game's performance settings seem to only affect
- * the sound quality.
- *
- * (performance > 0) ? 22050hz/16bit : 11025hz/8bit
- */
- int performance;
- int versionKey;
- int quickSaveKey;
- int quickLoadKey;
- int switchToSaraKey;
- int switchToGrimwallKey;
- int switchToOlmecKey;
+ Common::Array<int> movieSubtitles;
+ Common::Array<int> encounterSubtitles; // FIXME: take this out
+ //////////////////////////////////////////////////////////////////////////
/**
* Load configuration file
@@ -91,10 +106,10 @@ private:
ConfigurationManager();
virtual ~ConfigurationManager();
-}; // end of class ConfigurationManager
+};
#define Config (::Asylum::ConfigurationManager::instance())
} // end of namespace Asylum
-#endif
+#endif // ASYLUM_CONFIGURATIONMANAGER_H
diff --git a/engines/asylum/system/video.cpp b/engines/asylum/system/video.cpp
index be2b2b35bb..1ff6aac290 100644
--- a/engines/asylum/system/video.cpp
+++ b/engines/asylum/system/video.cpp
@@ -52,7 +52,7 @@ Video::~Video() {
delete _text;
}
-bool Video::playVideo(int32 videoNumber, VideoSubtitles subtitles) {
+bool Video::playVideo(int32 videoNumber, bool showSubtitles) {
bool lastMouseState = false;
char filename[20];
@@ -63,9 +63,9 @@ bool Video::playVideo(int32 videoNumber, VideoSubtitles subtitles) {
lastMouseState = g_system->showMouse(false);
if (result) {
_skipVideo = false;
- if(subtitles == kSubtitlesOn) {
+
+ if (showSubtitles)
loadSubtitles(videoNumber);
- }
uint16 x = (g_system->getWidth() - _smkDecoder->getWidth()) / 2;
uint16 y = (g_system->getHeight() - _smkDecoder->getHeight()) / 2;
@@ -78,7 +78,7 @@ bool Video::playVideo(int32 videoNumber, VideoSubtitles subtitles) {
if (frame) {
g_system->copyRectToScreen((byte *)frame->pixels, frame->pitch, x, y, frame->w, frame->h);
- if(subtitles) {
+ if(showSubtitles) {
Graphics::Surface *screen = g_system->lockScreen();
performPostProcessing((byte *)screen->pixels);
g_system->unlockScreen();
diff --git a/engines/asylum/system/video.h b/engines/asylum/system/video.h
index 9eece2cc8b..0c007254ba 100644
--- a/engines/asylum/system/video.h
+++ b/engines/asylum/system/video.h
@@ -49,11 +49,6 @@ struct VideoSubtitle {
int textRes;
};
-enum VideoSubtitles {
- kSubtitlesOff = 0,
- kSubtitlesOn = 1
-};
-
class VideoText;
class Video {
@@ -61,7 +56,7 @@ public:
Video(Audio::Mixer *mixer);
virtual ~Video();
- bool playVideo(int32 videoNumber, VideoSubtitles subtitles);
+ bool playVideo(int32 videoNumber, bool showSubtitles);
private:
void performPostProcessing(byte *screen);
diff --git a/engines/asylum/views/blowuppuzzle.cpp b/engines/asylum/views/blowuppuzzle.cpp
index a38330e3c3..5ee4626b3f 100644
--- a/engines/asylum/views/blowuppuzzle.cpp
+++ b/engines/asylum/views/blowuppuzzle.cpp
@@ -174,7 +174,7 @@ void BlowUpPuzzleVCR::update() {
// TODO: fade palette to grey
- _scene->vm()->video()->playVideo(2, kSubtitlesOn);
+ _scene->vm()->video()->playVideo(2, true);
_isAccomplished = false;
_active = false;
diff --git a/engines/asylum/views/scene.cpp b/engines/asylum/views/scene.cpp
index b8cf0efdcc..0289dcbb3e 100644
--- a/engines/asylum/views/scene.cpp
+++ b/engines/asylum/views/scene.cpp
@@ -108,6 +108,7 @@ Scene::Scene(uint8 sceneIdx, AsylumEngine *engine): _vm(engine) {
// TODO: init action list
+ _title = new SceneTitle(this);
_titleLoaded = false;
}
@@ -208,12 +209,7 @@ Scene::~Scene() {
delete _resPack;
//delete _blowUp;
- // TODO we can probably dispose of the title resource once the
- // _titleLoaded flag has been set, as opposed to in the
- // scene destructor
-#ifdef SHOW_SCENE_LOADING
delete _title;
-#endif
}
Actor* Scene::getActor(int index) {
@@ -221,13 +217,11 @@ Actor* Scene::getActor(int index) {
}
void Scene::enterScene() {
-#ifdef SHOW_SCENE_LOADING
- if (!_titleLoaded) {
- _title = new SceneTitle(this);
+ if (Config.showSceneLoading && !_titleLoaded) {
+ _title->load();
// disable input polling
//_actions->_allowInput = false;
} else {
-#endif
_vm->screen()->setPalette(_resPack, _ws->currentPaletteId);
_background = _bgResource->getFrame(0);
_vm->screen()->copyToBackBuffer(
@@ -245,9 +239,8 @@ void Scene::enterScene() {
startMusic();
_walking = false;
-#ifdef SHOW_SCENE_LOADING
}
-#endif
+
_isActive = true;
}
@@ -317,16 +310,17 @@ void Scene::handleEvent(Common::Event *event, bool doUpdate) {
// -------------------------------------------
void Scene::update() {
-#ifdef SHOW_SCENE_LOADING
- if (!_titleLoaded) {
- _title->update(_vm->getTick());
- if (_title->loadingComplete()) {
- _titleLoaded = true;
- enterScene();
+ if (Config.showSceneLoading) {
+ if (!_titleLoaded) {
+ _title->update(_vm->getTick());
+ if (_title->loadingComplete()) {
+ _titleLoaded = true;
+ enterScene();
+ }
+ return;
}
- return;
}
-#endif
+
if (updateScene())
return;
@@ -347,7 +341,7 @@ void Scene::update() {
}
int Scene::updateScene() {
-#ifdef SHOW_SCENE_TIMES
+#ifdef DEBUG_SCENE_TIMES
#define MESURE_TICKS(func) { \
int32 startTick =_vm->getTick(); \
func(); \
@@ -1326,6 +1320,16 @@ void Scene::resetActor0() {
// SceneTitle
//////////////////////////////////////////////////////////////////////////
SceneTitle::SceneTitle(Scene *scene): _scene(scene) {
+ _bg = NULL;
+ _progress = NULL;
+}
+
+SceneTitle::~SceneTitle() {
+ delete _bg;
+ delete _progress;
+}
+
+void SceneTitle::load() {
_start = _scene->vm()->getTick();
_bg = new GraphicResource(_scene->_resPack, _scene->_ws->sceneTitleGraphicResourceId);
@@ -1341,12 +1345,7 @@ SceneTitle::SceneTitle(Scene *scene): _scene(scene) {
delete pack;
_done = false;
- _showMouseState = g_system->showMouse(false);
-}
-
-SceneTitle::~SceneTitle() {
- delete _bg;
- delete _progress;
+ _showMouseState = g_system->showMouse(false);
}
void SceneTitle::update(int32 tick) {
diff --git a/engines/asylum/views/scene.h b/engines/asylum/views/scene.h
index 657d61c36e..000e906fe8 100644
--- a/engines/asylum/views/scene.h
+++ b/engines/asylum/views/scene.h
@@ -67,6 +67,8 @@ public:
SceneTitle(Scene *scene);
~SceneTitle();
+ void load();
+
void update(int32 tick);
bool loadingComplete() { return _done; }
Commit: 29d47c54cc4bd2a1d749f53baa51d49a8f9913e3
https://github.com/scummvm/scummvm/commit/29d47c54cc4bd2a1d749f53baa51d49a8f9913e3
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:08+02:00
Commit Message:
ASYLUM: Update scene drawing implementation
- Finish implementation of Actor::draw() & Barrier::draw()
- Add Scene::buildUpdateList
- Misc cleanup to Barrier functions
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@477 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/asylum.h
engines/asylum/resources/actionlist.cpp
engines/asylum/resources/actionlist.h
engines/asylum/resources/actor.cpp
engines/asylum/resources/actor.h
engines/asylum/resources/barrier.cpp
engines/asylum/resources/barrier.h
engines/asylum/shared.h
engines/asylum/system/screen.cpp
engines/asylum/system/screen.h
engines/asylum/views/scene.cpp
engines/asylum/views/scene.h
diff --git a/engines/asylum/asylum.h b/engines/asylum/asylum.h
index 037d95bef3..3fc64c9538 100644
--- a/engines/asylum/asylum.h
+++ b/engines/asylum/asylum.h
@@ -61,17 +61,6 @@ namespace Asylum {
// If defined, will show the scene update times on the debugger output
//#define DEBUG_SCENE_TIMES
-// XXX
-// I'm not sure if system endian-ness would have any
-// effect on the byte order of the data files, but I guess
-// it won't hurt to keep this here until we can test
-// on a big-endian system
-#ifndef SCUMM_BIG_ENDIAN
-#define LOBYTE(word) (word & 0xFF)
-#else
-#define LOBYTE(word) ((word >> 24) & 0xFF)
-#endif
-
//////////////////////////////////////////////////////////////////////////
// Flags
enum FlagType {
diff --git a/engines/asylum/resources/actionlist.cpp b/engines/asylum/resources/actionlist.cpp
index 3eac70bacf..d37ad02f4e 100644
--- a/engines/asylum/resources/actionlist.cpp
+++ b/engines/asylum/resources/actionlist.cpp
@@ -57,13 +57,13 @@ ActionList::ActionList(Common::SeekableReadStream *stream, Scene *scene) : _scen
ADD_OPCODE(EnableActor);
ADD_OPCODE(EnableBarriers);
ADD_OPCODE(Return);
- ADD_OPCODE(DestroyBarrier);
+ ADD_OPCODE(RemoveBarrier);
ADD_OPCODE(JumpActorSpeech);
ADD_OPCODE(JumpAndSetDirection);
ADD_OPCODE(JumpIfActorCoordinates);
ADD_OPCODE(Nop);
ADD_OPCODE(ResetAnimation);
- ADD_OPCODE(SetBarrierDestroyed);
+ ADD_OPCODE(DisableBarrier);
ADD_OPCODE(JumpIfSoundPlayingAndPlaySound);
ADD_OPCODE(JumpIfActionFind);
ADD_OPCODE(SetActionFind);
@@ -507,13 +507,13 @@ IMPLEMENT_OPCODE(EnableBarriers) {
//////////////////////////////////////////////////////////////////////////
// Opcode 0x11
-IMPLEMENT_OPCODE(DestroyBarrier) {
+IMPLEMENT_OPCODE(RemoveBarrier) {
if (!cmd->param1)
return;
Barrier *barrier = _scene->worldstats()->getBarrierById(cmd->param1);
- barrier->destroyAndRemoveFromQueue();
+ barrier->disableAndRemoveFromQueue();
}
//////////////////////////////////////////////////////////////////////////
@@ -591,10 +591,10 @@ IMPLEMENT_OPCODE(ResetAnimation) {
//////////////////////////////////////////////////////////////////////////
// Opcode 0x17
-IMPLEMENT_OPCODE(SetBarrierDestroyed) {
+IMPLEMENT_OPCODE(DisableBarrier) {
Barrier *barrier = _scene->worldstats()->getBarrierById(cmd->param1);
- barrier->flags &= kBarrierFlagDestroyed;
+ barrier->disable();
}
//////////////////////////////////////////////////////////////////////////
@@ -823,7 +823,7 @@ IMPLEMENT_OPCODE(_unk2C_ActorSub) {
GraphicResource *res = new GraphicResource(_scene->getResourcePack(), id);
actor->setResourceId(id);
actor->setFrameCount(res->getFrameCount());
- actor->setFrameNumber(0);
+ actor->setFrameIndex(0);
actor->setDirection(direction);
actor->updateStatus(actor->getStatus() <= kActorStatus11 ? kActorStatus3 : kActorStatus19);
delete res;
@@ -915,7 +915,7 @@ IMPLEMENT_OPCODE(ResumeProcessing) {
//////////////////////////////////////////////////////////////////////////
// Opcode 0x31
IMPLEMENT_OPCODE(ResetSceneRect) {
- _scene->worldstats()->sceneRectIdx = LOBYTE(cmd->param1);
+ _scene->worldstats()->sceneRectIdx = LO_BYTE(cmd->param1);
_scene->vm()->screen()->paletteFade(0, 25, 10);
_scene->vm()->setFlag(kFlagTypeSceneRectChanged);
@@ -1296,7 +1296,7 @@ IMPLEMENT_OPCODE(_unk46) {
if (cmd->param5) {
_scene->getActor(cmd->param5)->updateStatus(kActorStatusEnabled);
} else if (cmd->param4 != cmd->param3 && cmd->param4) {
- _scene->worldstats()->getBarrierById(cmd->param3)->destroy();
+ _scene->worldstats()->getBarrierById(cmd->param3)->disable();
_scene->worldstats()->getBarrierById(cmd->param4)->setNextFrame(_scene->worldstats()->getBarrierById(cmd->param4)->flags);
}
@@ -1316,7 +1316,7 @@ IMPLEMENT_OPCODE(_unk46) {
} else {
if (cmd->param4 != cmd->param3) {
if (cmd->param4)
- _scene->worldstats()->getBarrierById(cmd->param4)->destroy();
+ _scene->worldstats()->getBarrierById(cmd->param4)->disable();
if (cmd->param3)
_scene->worldstats()->getBarrierById(cmd->param3)->setNextFrame(_scene->worldstats()->getBarrierById(cmd->param4)->flags);
@@ -1589,7 +1589,7 @@ IMPLEMENT_OPCODE(SetBarrierFrameIdxFlaged) {
if (cmd->param3)
barrier->flags = 1 | barrier->flags;
else
- barrier->flags &= kBarrierFlagDestroyed;
+ barrier->flags &= ~kBarrierFlagEnabled;
barrier->setFrameIndex(cmd->param2);
}
diff --git a/engines/asylum/resources/actionlist.h b/engines/asylum/resources/actionlist.h
index 7cb81b6a90..1bfcae5c77 100644
--- a/engines/asylum/resources/actionlist.h
+++ b/engines/asylum/resources/actionlist.h
@@ -181,13 +181,13 @@ private:
DECLARE_OPCODE(DisableActor);
DECLARE_OPCODE(EnableActor);
DECLARE_OPCODE(EnableBarriers);
- DECLARE_OPCODE(DestroyBarrier);
+ DECLARE_OPCODE(RemoveBarrier);
DECLARE_OPCODE(JumpActorSpeech);
DECLARE_OPCODE(JumpAndSetDirection);
DECLARE_OPCODE(JumpIfActorCoordinates);
DECLARE_OPCODE(Nop);
DECLARE_OPCODE(ResetAnimation);
- DECLARE_OPCODE(SetBarrierDestroyed);
+ DECLARE_OPCODE(DisableBarrier);
DECLARE_OPCODE(JumpIfSoundPlayingAndPlaySound);
DECLARE_OPCODE(JumpIfActionFind);
DECLARE_OPCODE(SetActionFind);
diff --git a/engines/asylum/resources/actor.cpp b/engines/asylum/resources/actor.cpp
index 155f424526..0f0c08712d 100644
--- a/engines/asylum/resources/actor.cpp
+++ b/engines/asylum/resources/actor.cpp
@@ -61,8 +61,8 @@ void Actor::load(Common::SeekableReadStream *stream) {
x = stream->readSint32LE();
y = stream->readSint32LE();
_resourceId = stream->readSint32LE();
- _field_C = stream->readSint32LE();
- _frameNumber = stream->readSint32LE();
+ _barrierIndex = stream->readSint32LE();
+ _frameIndex = stream->readSint32LE();
_frameCount = stream->readSint32LE();
x1 = stream->readSint32LE();
y1 = stream->readSint32LE();
@@ -168,7 +168,32 @@ void Actor::setVisible(bool value) {
/////////////////////////////////////////////////////////////////////////
// Update & status
//////////////////////////////////////////////////////////////////////////
+void Actor::draw() {
+ if (!isVisible())
+ return;
+
+ // Draw the actor
+ Common::Point point;
+ getScene()->adjustCoordinates(x + x1, y + y1, &point);
+
+ // Compute frame index
+ int32 frameIndex = _frameIndex;
+ if (_frameIndex >= _frameCount)
+ frameIndex = 2 * _frameCount - _frameIndex - 1;
+ if (HI_BYTE(flags) & kActorFlag2) {
+ Barrier *barrier = getWorld()->barriers[_barrierIndex];
+ getScene()->adjustCoordinates(barrier->x, barrier->y, &point);
+
+ error("[Actor::draw] Cross fade not implemented!");
+ //getScreen()->addGraphicToQueue(_resourceId, frameIndex, point.x, point.y, barrier->_resourceId, point.x, point.y, getGraphicsFlags(), _priority);
+
+ // Update flags
+ flags &= ~kActorFlag2;
+ } else {
+ getScreen()->addGraphicToQueue(_resourceId, frameIndex, point.x, point.y, getGraphicsFlags(), _field_96C, _priority);
+ }
+}
void Actor::update() {
if (!isVisible())
@@ -189,8 +214,8 @@ void Actor::update() {
case kActorStatus17:
if (getWorld()->numChapter == 2) {
if (_index > 12) {
- if (_frameNumber <= _frameCount - 1) {
- ++_frameNumber;
+ if (_frameIndex <= _frameCount - 1) {
+ ++_frameIndex;
} else {
setVisible(false);
getScene()->getActor(_index + 9)->setVisible(false);
@@ -198,13 +223,13 @@ void Actor::update() {
}
if (_index == 11) {
- if (_frameNumber <= _frameCount - 1) {
+ if (_frameIndex <= _frameCount - 1) {
// Looks like a simple check using the counter, since it doesn't seem to be used anywhere else
if (_actorUpdateCounter <= 0) {
++_actorUpdateCounter;
} else {
_actorUpdateCounter = 0;
- ++_frameNumber;
+ ++_frameIndex;
}
} else {
if (_vm->isGameFlagSet(kGameFlag556)) {
@@ -229,7 +254,7 @@ void Actor::update() {
_vm->setGameFlag(kGameFlag279);
_vm->setGameFlag(kGameFlag368);
- player->setFrameNumber(0);
+ player->setFrameIndex(0);
getScene()->getActor(0)->setTickValue(_vm->getTick());
Sound *sound = _vm->sound();
@@ -256,8 +281,8 @@ void Actor::update() {
}
if (_index == getScene()->getPlayerActorIndex()) {
- if (_frameNumber <= _frameCount - 1) {
- ++_frameNumber;
+ if (_frameIndex <= _frameCount - 1) {
+ ++_frameIndex;
} else {
_vm->clearGameFlag(kGameFlag239);
getScene()->getActor(10)->updateStatus(kActorStatus14);
@@ -271,8 +296,8 @@ void Actor::update() {
} else if (getWorld()->numChapter == 11) {
if (_index == getScene()->getPlayerActorIndex()) {
- if (_frameNumber <= _frameCount - 1)
- ++_frameNumber;
+ if (_frameIndex <= _frameCount - 1)
+ ++_frameIndex;
else
getScene()->resetActor0();
}
@@ -313,7 +338,7 @@ void Actor::update() {
break;
case kActorStatusDisabled:
- _frameNumber = (_frameNumber + 1) % _frameCount;
+ _frameIndex = (_frameIndex + 1) % _frameCount;
if (_vm->globalTickValue - _tickValue > 300) {
if (_vm->getRandom(100) < 50) {
@@ -406,14 +431,14 @@ void Actor::update() {
case kActorStatus6:
case kActorStatus10:
- _frameNumber = (_frameNumber + 1) % _frameCount;
+ _frameIndex = (_frameIndex + 1) % _frameCount;
break;
case kActorStatus8:
if (_vm->encounter()->getFlag(kEncounterFlag2)
|| !_soundResourceId
|| getSound()->isPlaying(_soundResourceId)) {
- _frameNumber = (_frameNumber + 1) % _frameCount;
+ _frameIndex = (_frameIndex + 1) % _frameCount;
} else {
updateStatus(kActorStatusEnabled);
_soundResourceId = kResourceNone;
@@ -522,14 +547,14 @@ void Actor::updateStatus(ActorStatus actorStatus) {
case kActorStatus18:
if (getWorld()->numChapter == 2) {
GraphicResource *resource = new GraphicResource();
- _frameNumber = 0;
+ _frameIndex = 0;
if (_index > 12)
_resourceId = _graphicResourceIds[_direction + 30];
if (getScene()->getPlayerActorIndex() == _index) {
resource->load(getScene()->getResourcePack(), _resourceId);
- _frameNumber = resource->getFrameCount() - 1;
+ _frameIndex = resource->getFrameCount() - 1;
}
if (_index == 11)
@@ -670,7 +695,7 @@ void Actor::setPosition(int32 newX, int32 newY, int32 newDirection, int32 frame)
updateFromDirection(newDirection);
if (frame > 0)
- _frameNumber = frame;
+ _frameIndex = frame;
}
@@ -730,7 +755,9 @@ bool Actor::process_41BDB0(int32 reactionIndex, bool testNumberValue01) {
error("[Actor::process_41BC00] not implemented!");
}
-
+void Actor::update_40DE20() {
+ error("[Actor::update_40DE20] not implemented!");
+}
//////////////////////////////////////////////////////////////////////////
// Update methods
@@ -741,7 +768,7 @@ void Actor::updateStatus3_19() {
}
void Actor::updateStatusEnabled() {
- _frameNumber = (_frameNumber + 1) % _frameCount;
+ _frameIndex = (_frameIndex + 1) % _frameCount;
// Actor: Crow
if (_vm->globalTickValue - _tickValue > 300) {
@@ -1017,11 +1044,23 @@ void Actor::updateGraphicData(uint32 offset) {
_frameCount = resource->getFrameCount();
delete resource;
- _frameNumber = 0;
+ _frameIndex = 0;
}
bool Actor::isDefaultDirection(int index) {
return _graphicResourceIds[index] != _graphicResourceIds[5];
}
+int32 Actor::getGraphicsFlags() {
+ if (getWorld()->numChapter == 11) {
+ int res = strcmp((char *)&_name, "Dead Sarah");
+
+ if (res == 0)
+ return res;
+ }
+
+ // TODO replace by readable version
+ return ((_direction < 5) - 1) & 2;
+}
+
} // end of namespace Asylum
diff --git a/engines/asylum/resources/actor.h b/engines/asylum/resources/actor.h
index 20ffc9ec89..ab5fcc73ee 100644
--- a/engines/asylum/resources/actor.h
+++ b/engines/asylum/resources/actor.h
@@ -61,7 +61,8 @@ public:
void setBarrierIndex(int32 index) { _field_3C = index; }
void setDirection(ActorDirection direction) { _direction = direction; }
void setFrameCount(int32 count) { _frameCount = count; }
- void setFrameNumber(int32 number) { _frameNumber = number; }
+ void setFrameIndex(int32 number) { _frameIndex = number; }
+ void setNumberFlag01(int32 number) { _numberFlag01 = number; }
void setPriority(int32 priority) { _priority = priority; }
void setResourceId(ResourceId id) { _resourceId = id; }
void setStatus(ActorStatus status) { _status = status; }
@@ -77,7 +78,7 @@ public:
Common::Rect *getBoundingRect() { return &_boundingRect; }
ActorDirection getDirection() { return _direction; }
uint32 getFrameCount() { return _frameCount; }
- uint32 getFrameNum() { return _frameNumber; }
+ uint32 getFrameIndex() { return _frameIndex; }
int32 getReaction(uint32 index) { return _reaction[index]; }
ResourceId getResourceId() { return _resourceId; }
ResourceId getResourcesId(uint32 index) { return _graphicResourceIds[index]; }
@@ -118,9 +119,14 @@ public:
void setVisible(bool value);
/////////////////////////////////////////////////////////////////////////
- // Update & status
+ // Drawing & update
//////////////////////////////////////////////////////////////////////////
+ /**
+ * Draws the actor
+ */
+ void draw();
+
/**
* Updates the actor.
*/
@@ -197,6 +203,7 @@ public:
void process_41BC00(int32 reactionIndex, int32 numberValue01Add);
void process_41BCC0(int32 reactionIndex, int32 numberValue01Substract);
bool process_41BDB0(int32 reactionIndex, bool testNumberValue01);
+ void update_40DE20();
private:
AsylumEngine *_vm;
@@ -211,8 +218,8 @@ private:
// Data
//////////////////////////////////////////////////////////////////////////
ResourceId _resourceId;
- int32 _field_C; // BarrierIndex? Mask index?
- uint32 _frameNumber;
+ int32 _barrierIndex;
+ uint32 _frameIndex;
uint32 _frameCount;
// x1, y1, x2, y2
Common::Rect _boundingRect;
@@ -341,6 +348,12 @@ private:
*/
bool isDefaultDirection(int index);
+ /**
+ * Gets the graphics flags for queuing the actor graphics
+ *
+ * @return The graphics flags.
+ */
+ int32 getGraphicsFlags();
}; // end of class MainActor
diff --git a/engines/asylum/resources/barrier.cpp b/engines/asylum/resources/barrier.cpp
index c6120b7943..1dac08e9ae 100644
--- a/engines/asylum/resources/barrier.cpp
+++ b/engines/asylum/resources/barrier.cpp
@@ -109,13 +109,14 @@ void Barrier::load(Common::SeekableReadStream *stream) {
}
-void Barrier::destroy() {
- flags &= kBarrierFlagDestroyed;
+void Barrier::disable() {
+ flags &= ~kBarrierFlagEnabled;
}
-void Barrier::destroyAndRemoveFromQueue() {
- destroy();
- flags|= kBarrierFlag20000;
+void Barrier::disableAndRemoveFromQueue() {
+ disable();
+
+ flags |= kBarrierFlag20000;
getScreen()->deleteGraphicFromQueue(_resourceId);
}
@@ -129,120 +130,61 @@ bool Barrier::isOnScreen() {
barrierRect.translate(x, y);
- return isVisible() && (flags & 1) && screenRect.intersects(barrierRect);
+ return isVisible() && (flags & kBarrierFlagEnabled) && screenRect.intersects(barrierRect);
}
bool Barrier::isVisible() {
- if ((flags & 0xFF) & 1) {
- for (int32 f = 0; f < 10; f++) {
- bool isSet = false;
- GameFlag flag = _gameFlags[f];
+ if (flags & kBarrierFlagEnabled) {
+
+ // Check each game flag
+ for (int32 i = 0; i < 10; i++) {
+ GameFlag flag = _gameFlags[i];
+ bool ok = false;
if (flag <= 0)
- isSet = _vm->isGameFlagNotSet(flag);
+ ok = _vm->isGameFlagNotSet((GameFlag)-flag);
else
- isSet = _vm->isGameFlagSet(flag);
+ ok = _vm->isGameFlagSet(flag);
- if (!isSet)
+ if (!ok)
return false;
}
+
+ // All flags were ok, we are done!
return true;
}
+
return false;
}
/////////////////////////////////////////////////////////////////////////
// Update
//////////////////////////////////////////////////////////////////////////
-void Barrier::draw(Actor *actor, Common::Point &pt) {
- bool actInBar = _boundingRect.contains(*actor->getBoundingRect());
- bool intersects = false;
-
- // TODO verify that my funky LOBYTE macro actually
- // works the way I assume it should :P
- if (!actInBar) {
- if (LOBYTE(flags) & 0x20)
- if (!(LOBYTE(flags) & 0x80))
- // XXX not sure if this will work, as it's
- // supposed to set 0x40 to the lobyte...
- flags |= 0x40;
+void Barrier::draw() {
+ if (LO_BYTE(flags) & kBarrierFlag4)
return;
- }
- if (flags & 2) {
- // TODO refactor
- if (_field_74 || _field_78 ||
- _field_7C || _field_80)
- intersects = (pt.y > _field_78 + (_field_80 - _field_78) * (pt.x - _field_74) / (_field_7C - _field_74)) == 0;
- else
- intersects = true;
- } else {
- if (flags & 0x40) {
- PolyDefinitions *poly = &getScene()->polygons()->entries[_polygonIndex];
- if (pt.x > 0 && pt.y > 0 && poly->numPoints > 0)
- intersects = poly->contains(pt.x, pt.y);
- else
- ;//warning ("[drawActorsAndBarriers] trying to find intersection of uninitialized point");
- }
- // XXX the original has an else case here that
- // assigns intersects the value of the
- // flags & 2 check, which doesn't make any sense since
- // that path would never have been taken if code
- // execution had made it's way here.
- }
- if (LOBYTE(flags) & 0x80 || intersects) {
- if (LOBYTE(flags) & 0x20)
- // XXX not sure if this will work, as it's
- // supposed to set this value on the lobyte...
- flags &= 0xBF | 0x80;
- else
- // XXX another lobyte assignment...
- flags |= 0x40;
- // TODO label jump up a few lines here. Investigate...
- }
- if (flags & 4) {
- if (intersects) {
- if(actor->flags & 2)
- ;//warning ("[drawActorsAndBarriers] Assigning mask to masked character [%s]", _name);
- else {
- // TODO there's a call to sub_40ac10 that does
- // a point calculation, but the result doesn't appear to
- // ever be used, and the object passed in as a parameter
- // isn't updated
- actor->setBarrierIndex(getWorld()->getBarrierIndexById(_id));
- actor->flags |= 2;
- }
- }
- } else {
- if (intersects) {
- // XXX assuming the following:
- // "if ( *(int *)((char *)&scene.characters[0].priority + v18) < *(v12_barrierPtr + 35) )"
- // is the same as what I'm comparing :P
- if (actor->getPriority() < _priority) {
- actor->setField934(1);
- actor->setPriority(_priority + 3);
- // TODO there's a block of code here that seems
- // to loop through the CharacterUpdateItems and do some
- // priority adjustment. Since I'm not using CharacterUpdateItems as of yet,
- // I'm not sure what to do here
- // The loop seems to occur if:
- // (a) there are still character items to process
- // (b) sceneNumber != 2 && actor->field_944 != 1
- }
- } else {
- if (actor->getPriority() > _priority || actor->getPriority() == 1) {
- actor->setField934(1);
- actor->setPriority(_priority - 1);
- // TODO another character update loop
- // This time it looks like there's another
- // intersection test, and more updates
- // to field_934 and field_944, then
- // priority updates
- }
- }
+ if (HI_BYTE(flags) & kBarrierFlag40)
+ return;
+
+ if (!isOnScreen())
+ return;
+
+ // Draw the barrier
+ Common::Point point;
+ getScene()->adjustCoordinates(x, y, &point);
+
+ if (_field_67C <= 0 || _field_67C >= 4 || Config.performance <= 1)
+ getScreen()->addGraphicToQueue(_resourceId, _frameIndex, x, y, (flags >> 11) & kBarrierFlag2, _field_67C - 3, _priority);
+ else {
+ // TODO: Do Cross Fade
+ //getScreen()->addGraphicToQueue(_resourceId, _frameIndex, x, y, getWorld()->backgroundImage, getWorld()->xLeft, getWorld()->yTop, 0, 0, _field_67C - 1);
+ error("[Barrier::draw] Crossfade not implemented!");
}
}
+
+
void Barrier::update() {
bool canPlaySound = false;
if (_field_3C == 4) {
@@ -360,7 +302,7 @@ void Barrier::update() {
}
if (canPlaySound) {
- updateSoundItems(_vm->sound());
+ updateSoundItems();
stopSound();
}
}
@@ -368,10 +310,9 @@ void Barrier::update() {
}
void Barrier::setNextFrame(int32 targetFlags) {
- int32 newFlag = targetFlags | 1 | flags;
- flags |= targetFlags | 1;
+ flags |= targetFlags | kBarrierFlagEnabled;
- if (newFlag & 0x10000)
+ if (flags & kBarrierFlag10000)
_frameIndex = _frameCount - 1;
else
_frameIndex = 0;
@@ -380,13 +321,15 @@ void Barrier::setNextFrame(int32 targetFlags) {
/////////////////////////////////////////////////////////////////////////
// Misc
/////////////////////////////////////////////////////////////////////////
-void Barrier::updateSoundItems(Sound *snd) {
- for (int32 i = 0; i < 16; i++) {
+void Barrier::updateSoundItems() {
+ for (int32 i = 0; i < ARRAYSIZE(_soundItems); i++) {
+
SoundItem *item = &_soundItems[i];
- if (snd->isPlaying(item->resourceId)) {
+
+ if (getSound()->isPlaying(item->resourceId)) {
if (item->field_4) {
- snd->stopSound(item->resourceId);
- item->resourceId = 0;
+ getSound()->stopSound(item->resourceId);
+ item->resourceId = kResourceNone;
item->field_4 = 0;
}
}
@@ -402,11 +345,12 @@ void Barrier::stopSound() {
void Barrier::stopAllSounds() {
for (int i = 0; i < ARRAYSIZE(_soundItems); i++)
- if (_soundItems[i].resourceId)
+ if (_soundItems[i].resourceId) {
getSound()->stopSound(_soundItems[i].resourceId);
+ _soundItems[i].resourceId = kResourceNone;
+ }
}
-
int32 Barrier::getRandomId() {
int32 numRes = 0;
ResourceId randomResourceIds[5];
@@ -425,20 +369,7 @@ int32 Barrier::getRandomId() {
}
bool Barrier::checkFlags() {
- return (flags & 1) && (flags & 8 || flags & 0x10000);
-}
-
-bool Barrier::checkGameFlags() {
- if (LOBYTE(flags) & 1) {
- for (int32 i = 0; i < 10; i++) {
- if (_vm->isGameFlagSet(_gameFlags[i]))
- return true;
- }
-
- return true;
- }
-
- return false;
+ return (flags & kBarrierFlagEnabled) && (flags & kBarrierFlag8 || flags & kBarrierFlag10000);
}
} // end of namespace Asylum
diff --git a/engines/asylum/resources/barrier.h b/engines/asylum/resources/barrier.h
index d5a58685a3..38be806aca 100644
--- a/engines/asylum/resources/barrier.h
+++ b/engines/asylum/resources/barrier.h
@@ -65,11 +65,15 @@ public:
int32 getPriority() { return _priority; }
ResourceId getResourceId() { return _resourceId; }
+ int32 getField74() { return _field_74; }
+ int32 getField78() { return _field_78; }
+ int32 getField7C() { return _field_7C; }
+ int32 getField80() { return _field_80; }
int32 getField67C() { return _field_67C; }
int32 getField688() { return _field_688; }
/////////////////////////////////////////////////////////////////////////
- // Loading & destroying
+ // Loading & disabling
/////////////////////////////////////////////////////////////////////////
/**
@@ -80,14 +84,14 @@ public:
void load(Common::SeekableReadStream *stream);
/**
- * Sets the barrier destroyed flag
+ * Sets the barrier disabled flag
*/
- void destroy();
+ void disable();
/**
* Sets the barrier destroyed flag and remove this barrier from the graphics queue
*/
- void destroyAndRemoveFromQueue();
+ void disableAndRemoveFromQueue();
/////////////////////////////////////////////////////////////////////////
// Visibility
@@ -114,7 +118,7 @@ public:
/**
* Draws the barrier
*/
- void draw(Actor *actor, Common::Point &pt);
+ void draw();
/**
* Updates the barrier.
@@ -136,7 +140,7 @@ public:
* Check if any items in the barrier sound array are playing,
* and based on their flag values, stop them accordingly
*/
- void updateSoundItems(Sound *snd);
+ void updateSoundItems();
/**
* Stop the barrier related sounds
@@ -144,14 +148,12 @@ public:
void stopSound();
/**
- * Stop all barrier sounds.
+ * Stop all barrier sounds (called from scripts)
*/
void stopAllSounds();
bool checkFlags();
- bool checkGameFlags();
-
int32 getRandomId(); // TODO Give this a better name?
private:
diff --git a/engines/asylum/shared.h b/engines/asylum/shared.h
index 2c103a3d46..f1de5784c9 100644
--- a/engines/asylum/shared.h
+++ b/engines/asylum/shared.h
@@ -120,7 +120,8 @@ enum ActorStatus {
typedef int ActorDirection;
enum ActorFlags {
- kActorFlagVisible = 1
+ kActorFlagVisible = 1,
+ kActorFlag2 = 2
};
enum DirectionFrom {
@@ -226,10 +227,12 @@ enum ActorResources {
// Barrier
//////////////////////////////////////////////////////////////////////////
enum BarrierFlag {
- kBarrierFlagDestroyed = -2,
+ kBarrierFlagEnabled = 0x1,
+ kBarrierFlag2 = 0x2,
kBarrierFlag4 = 0x4,
kBarrierFlag8 = 0x8,
kBarrierFlag20 = 0x20,
+ kBarrierFlag40 = 0x40,
kBarrierFlagC000 = 0xC000,
kBarrierFlag10000 = 0x10000,
kBarrierFlag10E38 = 0x10E38,
@@ -262,6 +265,12 @@ enum BarrierFlag {
#define getWorld() _vm->scene()->worldstats()
+//////////////////////////////////////////////////////////////////////////
+// Sub-integer partial access macros
+//////////////////////////////////////////////////////////////////////////
+#define LO_BYTE(d) (*((char*)&(d)))
+#define HI_BYTE(d) (*((char*)&(d)+1))
+
} // End of namespace Asylum
diff --git a/engines/asylum/system/screen.cpp b/engines/asylum/system/screen.cpp
index d24611f170..a7a8195699 100644
--- a/engines/asylum/system/screen.cpp
+++ b/engines/asylum/system/screen.cpp
@@ -37,6 +37,19 @@ Screen::~Screen() {
_backBuffer.free();
}
+void Screen::draw(GraphicResource *resource, uint32 frameIndex, int32 x, int32 y, int32 flags) {
+
+ // Get the frame to draw
+ GraphicFrame *frame = resource->getFrame(frameIndex);
+
+ copyToBackBuffer(((byte *)frame->surface.pixels) - y * frame->surface.w - x,
+ frame->surface.w,
+ 0,
+ 0,
+ 640,
+ 480);
+}
+
void Screen::copyBackBufferToScreen() {
_vm->_system->copyRectToScreen((byte *)_backBuffer.pixels, _backBuffer.w, 0, 0, _backBuffer.w, _backBuffer.h);
}
diff --git a/engines/asylum/system/screen.h b/engines/asylum/system/screen.h
index dc6fcd9052..ef929d69e4 100644
--- a/engines/asylum/system/screen.h
+++ b/engines/asylum/system/screen.h
@@ -51,6 +51,8 @@ public:
Screen(AsylumEngine *_vm);
~Screen();
+ void draw(GraphicResource *resource, uint32 frameIndex, int32 x, int32 y, int32 flags);
+
void copyToBackBuffer(byte *buffer, int32 pitch, int32 x, int32 y, int32 width, int32 height);
void copyToBackBufferWithTransparency(byte *buffer, int32 pitch, int32 x, int32 y, int32 width, int32 height);
void copyBackBufferToScreen();
diff --git a/engines/asylum/views/scene.cpp b/engines/asylum/views/scene.cpp
index 0289dcbb3e..5e9931c0f4 100644
--- a/engines/asylum/views/scene.cpp
+++ b/engines/asylum/views/scene.cpp
@@ -704,7 +704,7 @@ int32 Scene::hitTestScene(const Common::Point pt, HitType &type) {
int32 result = findActionArea(Common::Point(top, left));
if (result != -1) {
- if (LOBYTE(_ws->actions[result]->actionType) & 8) {
+ if (LO_BYTE(_ws->actions[result]->actionType) & 8) {
type = kHitActionArea;
return result;
}
@@ -721,10 +721,10 @@ bool Scene::hitTestActor(const Common::Point pt) {
getActorPosition(act, &actPos);
int32 hitFrame;
- if (act->getFrameNum() >= act->getFrameCount())
- hitFrame = 2 * act->getFrameNum() - act->getFrameCount() - 1;
+ if (act->getFrameIndex() >= act->getFrameCount())
+ hitFrame = 2 * act->getFrameIndex() - act->getFrameCount() - 1;
else
- hitFrame = act->getFrameNum();
+ hitFrame = act->getFrameIndex();
return hitTestPixel(act->getResourceId(),
hitFrame,
@@ -805,7 +805,7 @@ void Scene::updateAmbientSounds() {
; // TODO setSoundVolume(snd->resourceId, 0);
}
} else {
- int loflag = LOBYTE(snd->flags);
+ int loflag = LO_BYTE(snd->flags);
if (snd->field_0) {
; // TODO calculate panning at point
} else {
@@ -1009,33 +1009,45 @@ bool Scene::updateSceneCoordinates(int32 targetX, int32 targetY, int32 A0, bool
return false;
}
-// ----------------------------------
-// ---------- DRAW REGION -----------
-// ----------------------------------
+void Scene::adjustCoordinates(int32 x, int32 y, Common::Point *point) {
+ if (!point)
+ error("[Scene::adjustCoordinates] Invalid point parameter!");
-int Scene::drawScene() {
+ point->x = x - _ws->xLeft;
+ point->y = y - _ws->yTop;
+}
+//////////////////////////////////////////////////////////////////////////
+// Scene drawing
+//////////////////////////////////////////////////////////////////////////
+int Scene::drawScene() {
_vm->screen()->clearGraphicsInQueue();
if (_skipDrawScene) {
_vm->screen()->clearScreen();
} else {
// Draw scene background
- GraphicFrame *bg = _bgResource->getFrame(0);
+ _vm->screen()->draw(_bgResource, 0, -_ws->xLeft, -_ws->yTop, 0);
- _vm->screen()->copyToBackBuffer(
- ((byte *)bg->surface.pixels) + _ws->yTop * bg->surface.w + _ws->xLeft,
- bg->surface.w,
- 0,
- 0,
- 640,
- 480);
+ // Draw actors on the update list
+ buildUpdateList();
+ drawUpdateList();
+
+ if (_ws->numChapter == 11)
+ checkVisibleActorsPriority();
- drawActorsAndBarriers();
- queueActorUpdates();
- queueBarrierUpdates();
+ // Queue updates
+ for (uint32 i = 0; i < _ws->actors.size(); i++)
+ _ws->actors[i]->draw();
- // TODO: draw main actor stuff
+ for (uint32 i = 0; i < _ws->barriers.size(); i++)
+ _ws->barriers[i]->draw();
+
+ Actor *player = getActor();
+ if (player->getStatus() == kActorStatus6 || player->getStatus() == kActorStatus10)
+ player->update_40DE20();
+ else
+ player->setNumberFlag01(0);
_vm->screen()->drawGraphicsInQueue();
}
@@ -1043,7 +1055,38 @@ int Scene::drawScene() {
return 1;
}
-void Scene::drawActorsAndBarriers() {
+bool Scene::updateListCompare(const UpdateItem &item1, const UpdateItem &item2) {
+ return item1.priority - item2.priority;
+}
+
+void Scene::checkVisibleActorsPriority() {
+ error("[Scene::checkVisibleActorsPriority] not implemented");
+}
+
+void Scene::adjustActorPriority(ActorIndex index) {
+ error("[Scene::adjustActorPriority] not implemented");
+}
+
+void Scene::buildUpdateList() {
+ _updateList.clear();
+
+ for (uint32 i = 0; i < _ws->actors.size(); i++) {
+ Actor *actor = _ws->actors[i];
+
+ if (actor->isVisible()) {
+ UpdateItem item;
+ item.index = i;
+ item.priority = actor->y1 + actor->y2;
+
+ _updateList.push_back(item);
+ }
+ }
+
+ // Sort the list (the original uses qsort, so we may have to revert to that if our sort isn't behaving the same)
+ Common::sort(_updateList.begin(), _updateList.end(), &Scene::updateListCompare);
+}
+
+void Scene::drawUpdateList() {
// TODO this is supposed to be looping through
// a collection of CharacterUpdateItems. Since
// we're only on scene 1 atm, and there is only one
@@ -1085,77 +1128,103 @@ void Scene::drawActorsAndBarriers() {
// XXX from .text:0040a4d1
for (int32 barIdx = 0; barIdx < _ws->numBarriers; barIdx++) {
- _ws->barriers[barIdx]->draw(act, pt);
- } // end for (barriers)
- }
- } // end for (actors)
-
-}
-
-void Scene::getActorPosition(Actor *actor, Common::Point *pt) {
- pt->x = actor->x1 - _ws->xLeft;
- pt->y = actor->y1 - _ws->yTop;
-}
-
-int Scene::queueActorUpdates() {
- if (_ws->numActors > 0) {
- Common::Point pt;
- for (int32 a = 0; a < _ws->numActors; a++) {
- Actor *actor = _ws->actors[a];
-
- if ((actor->flags & 0xFF) & 1) { // check this mask
- getActorPosition(actor, &pt);
- //pt.x += actor->x;
- //pt.y += actor->y;
-
- int32 frameNum = actor->getFrameNum();
- if (actor->getFrameNum() >= actor->getFrameCount()) {
- frameNum = 2 * actor->getFrameCount() - actor->getFrameNum() - 1;
+ Barrier *bar = _ws->barriers[barIdx];
+ bool actInBar = bar->getBoundingRect()->contains(*act->getBoundingRect());
+ bool intersects = false;
+
+ // TODO verify that my funky LOBYTE macro actually
+ // works the way I assume it should :P
+ if (!actInBar) {
+ if (LO_BYTE(bar->flags) & 0x20)
+ if (!(LO_BYTE(bar->flags) & 0x80))
+ // XXX not sure if this will work, as it's
+ // supposed to set 0x40 to the lobyte...
+ bar->flags |= 0x40;
+ continue;
}
- if ((actor->flags & 0xFF) & 2) {
- // TODO: sub_40AC10
-
-
-
+ if (bar->flags & 2) {
+ // TODO refactor
+ if (bar->getField74() || bar->getField78() ||
+ bar->getField7C() || bar->getField80())
+ intersects = (pt.y > bar->getField78() + (bar->getField80() - bar->getField78()) * (pt.x - bar->getField74()) / (bar->getField7C() - bar->getField74())) == 0;
+ else
+ intersects = true;
} else {
- // TODO: get flag value from character_DeadSarah_sub_40A140
- _vm->screen()->addGraphicToQueue(actor->getResourceId(), frameNum, pt.x, pt.y, ((actor->getDirection() < 5) - 1) & 2, actor->getField96C(), actor->getPriority());
+ if (bar->flags & 0x40) {
+ PolyDefinitions *poly = &_polygons->entries[bar->getPolygonIndex()];
+ if (pt.x > 0 && pt.y > 0 && poly->numPoints > 0)
+ intersects = poly->contains(pt.x, pt.y);
+ else
+ ;//warning ("[drawActorsAndBarriers] trying to find intersection of uninitialized point");
+ }
+ // XXX the original has an else case here that
+ // assigns intersects the value of the
+ // flags & 2 check, which doesn't make any sense since
+ // that path would never have been taken if code
+ // execution had made it's way here.
}
- }
- }
- }
-
- return 1;
-}
-
-int Scene::queueBarrierUpdates() {
- int32 barriersCount = (int32)_ws->barriers.size();
-
- if (barriersCount > 0) {
- for (int32 b = 0; b < barriersCount; b++) {
- Barrier *barrier = _ws->barriers[b];
-
- if (!(barrier->flags & 4) && !((barrier->flags & 0xFF) & 0x40)) {
- if (barrier->isOnScreen()) {
- //TODO: need to do something here yet
-
- if (barrier->getField67C() <= 0 || barrier->getField67C() >= 4) { // TODO: still missing a condition for game quality config
- _vm->screen()->addGraphicToQueue(barrier->getResourceId(), barrier->getFrameIndex(), barrier->x, barrier->y, (barrier->flags >> 11) & 2, barrier->getField67C() - 3, barrier->getPriority());
+ if (LO_BYTE(bar->flags) & 0x80 || intersects) {
+ if (LO_BYTE(bar->flags) & 0x20)
+ // XXX not sure if this will work, as it's
+ // supposed to set this value on the lobyte...
+ bar->flags &= 0xBF | 0x80;
+ else
+ // XXX another lobyte assignment...
+ bar->flags |= 0x40;
+ // TODO label jump up a few lines here. Investigate...
+ }
+ if (bar->flags & 4) {
+ if (intersects) {
+ if(act->flags & 2)
+ ;//warning ("[drawActorsAndBarriers] Assigning mask to masked character [%s]", bar->name);
+ else {
+ // TODO there's a call to sub_40ac10 that does
+ // a point calculation, but the result doesn't appear to
+ // ever be used, and the object passed in as a parameter
+ // isn't updated
+ act->setBarrierIndex(barIdx);
+ act->flags |= 2;
+ }
+ }
+ } else {
+ if (intersects) {
+ // XXX assuming the following:
+ // "if ( *(int *)((char *)&scene.characters[0].priority + v18) < *(v12_barrierPtr + 35) )"
+ // is the same as what I'm comparing :P
+ if (act->getPriority() < bar->getPriority()) {
+ act->setField934(1);
+ act->setPriority(bar->getPriority() + 3);
+ // TODO there's a block of code here that seems
+ // to loop through the CharacterUpdateItems and do some
+ // priority adjustment. Since I'm not using CharacterUpdateItems as of yet,
+ // I'm not sure what to do here
+ // The loop seems to occur if:
+ // (a) there are still character items to process
+ // (b) sceneNumber != 2 && actor->field_944 != 1
+ }
} else {
- // TODO: Do Cross Fade
- // parameters: barrier->resourceId, barrier->frameIdx, barrier->x, barrier->y, _ws->backgroundImage, _ws->xLeft, _ws->yTop, 0, 0, barrier->field_67C - 1
- _vm->screen()->addGraphicToQueue(barrier->getResourceId(), barrier->getFrameIndex(), barrier->x, barrier->y, 0, 0, 0);
+ if (act->getPriority() > bar->getPriority() || act->getPriority() == 1) {
+ act->setField934(1);
+ act->setPriority(bar->getPriority() - 1);
+ // TODO another character update loop
+ // This time it looks like there's another
+ // intersection test, and more updates
+ // to field_934 and field_944, then
+ // priority updates
+ }
}
}
- }
+ } // end for (barriers)
}
- }
+ } // end for (actors)
- return 1;
}
-
+void Scene::getActorPosition(Actor *actor, Common::Point *pt) {
+ pt->x = actor->x1 - _ws->xLeft;
+ pt->y = actor->y1 - _ws->yTop;
+}
// ----------------------------------
// ---------- SCREEN REGION -----------
// ----------------------------------
diff --git a/engines/asylum/views/scene.h b/engines/asylum/views/scene.h
index 000e906fe8..27d7465ab0 100644
--- a/engines/asylum/views/scene.h
+++ b/engines/asylum/views/scene.h
@@ -164,6 +164,7 @@ public:
bool updateSceneCoordinates(int32 targetX, int32 targetY, int32 val, bool checkSceneCoords = false, int32 *param = NULL);
+ void adjustCoordinates(int32 x, int32 y, Common::Point *point);
void updatePlayerChapter9(int32 param);
@@ -258,6 +259,13 @@ private:
int32 _sceneYTop;
Common::Rational _sceneOffsetAdd;
+ struct UpdateItem {
+ ActorIndex index;
+ int32 priority;
+ };
+
+ Common::Array<UpdateItem> _updateList;
+
void update();
void startMusic();
@@ -297,16 +305,22 @@ private:
void updateScreen();
+
+ //////////////////////////////////////////////////////////////////////////
+ // Scene drawing
+ //////////////////////////////////////////////////////////////////////////
int drawScene();
- /** .text:0040A3C0
- * TODO add description
- */
- void drawActorsAndBarriers();
- int queueActorUpdates();
- int queueBarrierUpdates();
- bool isBarrierVisible(BarrierItem *barrier);
- bool isBarrierOnScreen(BarrierItem *barrier);
+ void buildUpdateList();
+ void drawUpdateList();
+ static bool updateListCompare(const UpdateItem &item1, const UpdateItem &item2);
+
+ void checkVisibleActorsPriority();
+ void adjustActorPriority(ActorIndex index);
+
+ //////////////////////////////////////////////////////////////////////////
+ // Scene debugging
+ //////////////////////////////////////////////////////////////////////////
void copyToBackBufferClipped(Graphics::Surface *surface, int x, int y);
void debugScreenScrolling(GraphicFrame *bg);
Commit: d569216ea43e63aa8ec56955a05b944faaf471a9
https://github.com/scummvm/scummvm/commit/d569216ea43e63aa8ec56955a05b944faaf471a9
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:08+02:00
Commit Message:
ASYLUM: Implement processUpdateList
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@478 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/resources/actionlist.cpp
engines/asylum/resources/actor.cpp
engines/asylum/resources/actor.h
engines/asylum/resources/barrier.cpp
engines/asylum/resources/barrier.h
engines/asylum/resources/polygons.h
engines/asylum/shared.h
engines/asylum/views/scene.cpp
engines/asylum/views/scene.h
diff --git a/engines/asylum/resources/actionlist.cpp b/engines/asylum/resources/actionlist.cpp
index d37ad02f4e..7df1fba9ab 100644
--- a/engines/asylum/resources/actionlist.cpp
+++ b/engines/asylum/resources/actionlist.cpp
@@ -915,7 +915,7 @@ IMPLEMENT_OPCODE(ResumeProcessing) {
//////////////////////////////////////////////////////////////////////////
// Opcode 0x31
IMPLEMENT_OPCODE(ResetSceneRect) {
- _scene->worldstats()->sceneRectIdx = LO_BYTE(cmd->param1);
+ _scene->worldstats()->sceneRectIdx = LOBYTE(cmd->param1);
_scene->vm()->screen()->paletteFade(0, 25, 10);
_scene->vm()->setFlag(kFlagTypeSceneRectChanged);
diff --git a/engines/asylum/resources/actor.cpp b/engines/asylum/resources/actor.cpp
index 0f0c08712d..71bd33de60 100644
--- a/engines/asylum/resources/actor.cpp
+++ b/engines/asylum/resources/actor.cpp
@@ -181,7 +181,7 @@ void Actor::draw() {
if (_frameIndex >= _frameCount)
frameIndex = 2 * _frameCount - _frameIndex - 1;
- if (HI_BYTE(flags) & kActorFlag2) {
+ if (LOBYTE(flags) & kActorFlagMasked) {
Barrier *barrier = getWorld()->barriers[_barrierIndex];
getScene()->adjustCoordinates(barrier->x, barrier->y, &point);
@@ -189,7 +189,7 @@ void Actor::draw() {
//getScreen()->addGraphicToQueue(_resourceId, frameIndex, point.x, point.y, barrier->_resourceId, point.x, point.y, getGraphicsFlags(), _priority);
// Update flags
- flags &= ~kActorFlag2;
+ flags &= ~kActorFlagMasked;
} else {
getScreen()->addGraphicToQueue(_resourceId, frameIndex, point.x, point.y, getGraphicsFlags(), _field_96C, _priority);
}
diff --git a/engines/asylum/resources/actor.h b/engines/asylum/resources/actor.h
index ab5fcc73ee..3d18d3a5cc 100644
--- a/engines/asylum/resources/actor.h
+++ b/engines/asylum/resources/actor.h
@@ -58,7 +58,7 @@ public:
void setActionIndex2(int32 index) { _actionIdx2 = index; }
- void setBarrierIndex(int32 index) { _field_3C = index; }
+ void setBarrierIndex(int32 index) { _barrierIndex = index; }
void setDirection(ActorDirection direction) { _direction = direction; }
void setFrameCount(int32 count) { _frameCount = count; }
void setFrameIndex(int32 number) { _frameIndex = number; }
@@ -79,14 +79,19 @@ public:
ActorDirection getDirection() { return _direction; }
uint32 getFrameCount() { return _frameCount; }
uint32 getFrameIndex() { return _frameIndex; }
+ char *getName() { return (char *)&_name; }
+ int32 getNumberValue01() { return _numberValue01; }
int32 getReaction(uint32 index) { return _reaction[index]; }
ResourceId getResourceId() { return _resourceId; }
ResourceId getResourcesId(uint32 index) { return _graphicResourceIds[index]; }
ActorStatus getStatus() { return _status; }
int32 getField638() { return _field_638; }
+ int32 getField934() { return _field_934; }
int32 getField944() { return _field_944; }
int32 getField96C() { return _field_96C; }
+ int32 getField974() { return _field_974; }
+ int32 getField980() { return _field_980; }
int32 getPriority() { return _priority; }
/////////////////////////////////////////////////////////////////////////
@@ -351,7 +356,7 @@ private:
/**
* Gets the graphics flags for queuing the actor graphics
*
- * @return The graphics flags.
+ * @return The graphics flags.
*/
int32 getGraphicsFlags();
diff --git a/engines/asylum/resources/barrier.cpp b/engines/asylum/resources/barrier.cpp
index 1dac08e9ae..26e187bbe0 100644
--- a/engines/asylum/resources/barrier.cpp
+++ b/engines/asylum/resources/barrier.cpp
@@ -62,10 +62,10 @@ void Barrier::load(Common::SeekableReadStream *stream) {
stream->read(_name, sizeof(_name));
- _field_74 = stream->readSint32LE();
- _field_78 = stream->readSint32LE();
- _field_7C = stream->readSint32LE();
- _field_80 = stream->readSint32LE();
+ _rect.left = stream->readSint32LE();
+ _rect.top = stream->readSint32LE();
+ _rect.right = stream->readSint32LE();
+ _rect.bottom = stream->readSint32LE();
_polygonIndex = stream->readSint32LE();
actionType = stream->readSint32LE();
@@ -161,10 +161,10 @@ bool Barrier::isVisible() {
// Update
//////////////////////////////////////////////////////////////////////////
void Barrier::draw() {
- if (LO_BYTE(flags) & kBarrierFlag4)
+ if (LOBYTE(flags) & kBarrierFlag4)
return;
- if (HI_BYTE(flags) & kBarrierFlag40)
+ if (BYTE1(flags) & kBarrierFlag40)
return;
if (!isOnScreen())
diff --git a/engines/asylum/resources/barrier.h b/engines/asylum/resources/barrier.h
index 38be806aca..9e287142c5 100644
--- a/engines/asylum/resources/barrier.h
+++ b/engines/asylum/resources/barrier.h
@@ -65,10 +65,7 @@ public:
int32 getPriority() { return _priority; }
ResourceId getResourceId() { return _resourceId; }
- int32 getField74() { return _field_74; }
- int32 getField78() { return _field_78; }
- int32 getField7C() { return _field_7C; }
- int32 getField80() { return _field_80; }
+ Common::Rect *getRect() { return &_rect; }
int32 getField67C() { return _field_67C; }
int32 getField688() { return _field_688; }
@@ -177,10 +174,7 @@ private:
// flags
int32 _field_3C;
uint8 _name[52];
- int32 _field_74; // XXX looks like fields
- int32 _field_78; // 74 => 80 have something
- int32 _field_7C; // to do with calculating
- int32 _field_80; // actor intersection
+ Common::Rect _rect;
int32 _polygonIndex;
// actionType
GameFlag _gameFlags[10];
diff --git a/engines/asylum/resources/polygons.h b/engines/asylum/resources/polygons.h
index e7f30f9e3f..9a93d4e299 100644
--- a/engines/asylum/resources/polygons.h
+++ b/engines/asylum/resources/polygons.h
@@ -47,6 +47,10 @@ typedef struct PolyDefinitions {
*/
bool contains(int16 x, int16 y);
+ bool contains(Common::Point point) {
+ return contains(point.x, point.y);
+ }
+
} PolyDefinitions;
class Polygons {
diff --git a/engines/asylum/shared.h b/engines/asylum/shared.h
index f1de5784c9..584fb7783c 100644
--- a/engines/asylum/shared.h
+++ b/engines/asylum/shared.h
@@ -121,7 +121,7 @@ typedef int ActorDirection;
enum ActorFlags {
kActorFlagVisible = 1,
- kActorFlag2 = 2
+ kActorFlagMasked = 2
};
enum DirectionFrom {
@@ -233,6 +233,7 @@ enum BarrierFlag {
kBarrierFlag8 = 0x8,
kBarrierFlag20 = 0x20,
kBarrierFlag40 = 0x40,
+ kBarrierFlag80 = 0x80,
kBarrierFlagC000 = 0xC000,
kBarrierFlag10000 = 0x10000,
kBarrierFlag10E38 = 0x10E38,
@@ -268,8 +269,8 @@ enum BarrierFlag {
//////////////////////////////////////////////////////////////////////////
// Sub-integer partial access macros
//////////////////////////////////////////////////////////////////////////
-#define LO_BYTE(d) (*((char*)&(d)))
-#define HI_BYTE(d) (*((char*)&(d)+1))
+#define LOBYTE(d) (*((char*)&(d)))
+#define BYTE1(d) (*((char*)&(d)+1)) // Same as HIBYTE()
diff --git a/engines/asylum/views/scene.cpp b/engines/asylum/views/scene.cpp
index 5e9931c0f4..bbd99e55cb 100644
--- a/engines/asylum/views/scene.cpp
+++ b/engines/asylum/views/scene.cpp
@@ -704,7 +704,7 @@ int32 Scene::hitTestScene(const Common::Point pt, HitType &type) {
int32 result = findActionArea(Common::Point(top, left));
if (result != -1) {
- if (LO_BYTE(_ws->actions[result]->actionType) & 8) {
+ if (LOBYTE(_ws->actions[result]->actionType) & 8) {
type = kHitActionArea;
return result;
}
@@ -805,7 +805,7 @@ void Scene::updateAmbientSounds() {
; // TODO setSoundVolume(snd->resourceId, 0);
}
} else {
- int loflag = LO_BYTE(snd->flags);
+ int loflag = BYTE1(snd->flags);
if (snd->field_0) {
; // TODO calculate panning at point
} else {
@@ -1031,7 +1031,7 @@ int Scene::drawScene() {
// Draw actors on the update list
buildUpdateList();
- drawUpdateList();
+ processUpdateList();
if (_ws->numChapter == 11)
checkVisibleActorsPriority();
@@ -1086,139 +1086,180 @@ void Scene::buildUpdateList() {
Common::sort(_updateList.begin(), _updateList.end(), &Scene::updateListCompare);
}
-void Scene::drawUpdateList() {
- // TODO this is supposed to be looping through
- // a collection of CharacterUpdateItems. Since
- // we're only on scene 1 atm, and there is only one
- // character, this will have to do :P
- for (int32 i = 0; i < _ws->numActors; i++) {
- int actorRegPt = 0;
- Actor *act = _ws->actors[i];
- Common::Point pt;
-
- // XXX Since we're not using CharacterUpdateItems,
- // the actor priority is never going to be changed.
- // Need to investigate if this is an issue
- /*
- if (act->priority < 0)
- act->priority = abs(act->priority);
+void Scene::processUpdateList() {
+ for (uint32 i = 0; i < _updateList.size(); i++) {
+ Actor *actor = getActor(_updateList[i].index);
+ int32 priority = _updateList[i].priority;
+ Common::Point point;
+
+ // Check priority
+ if (priority < 0) {
+ actor->setPriority(abs(priority));
continue;
- */
- act->setPriority(3);
- if (act->getField944() == 1 || act->getField944() == 4)
- act->setPriority(1);
- else {
- act->setField938(1);
- act->setField934(0);
- pt.x = act->x1 + act->x2;
- pt.y = act->y1 + act->y2;
-
- actorRegPt = act->getBoundingRect()->bottom + act->getBoundingRect()->right + 4;
-
- // TODO special case for scene 11
- // Not sure if we're checking the scene index
- // or the scene number though :P
- /*
- if (_sceneIdx == 11) {
- // FIXME this probably won't work
- if (act != this->getActor())
- actorRegPt += 20;
- }
- */
+ }
- // XXX from .text:0040a4d1
- for (int32 barIdx = 0; barIdx < _ws->numBarriers; barIdx++) {
- Barrier *bar = _ws->barriers[barIdx];
- bool actInBar = bar->getBoundingRect()->contains(*act->getBoundingRect());
- bool intersects = false;
+ actor->setPriority(3);
+
+ if (actor->getField944() == 1 || actor->getField944() == 4) {
+ actor->setPriority(1);
+ } else {
+ actor->setField938(1);
+ actor->setField934(0);
+ point.x = actor->x1 + actor->x2;
+ point.y = actor->y1 + actor->y2;
+
+ int32 bottomRight = actor->getBoundingRect()->bottom + actor->y1 + 4;
+
+ if (_ws->numChapter == 11 && _updateList[i].index != getPlayerActorIndex())
+ bottomRight += 20;
+
+ // Our actor rect
+ Common::Rect actorRect(actor->x1, actor->y1, actor->x1 + actor->getBoundingRect()->right, bottomRight);
+
+ // Process barriers
+ for (int32 j = 0; j < _ws->numBarriers; j++) {
+ Barrier *barrier = _ws->barriers[i];
+
+ // Skip hidden barriers
+ if (!barrier->isOnScreen())
+ continue;
+
+ // Rect for the barrier
+ Common::Rect barrierRect(barrier->x, barrier->y, barrier->x + barrier->getBoundingRect()->right, barrier->y + barrier->getBoundingRect()->bottom);
- // TODO verify that my funky LOBYTE macro actually
- // works the way I assume it should :P
- if (!actInBar) {
- if (LO_BYTE(bar->flags) & 0x20)
- if (!(LO_BYTE(bar->flags) & 0x80))
- // XXX not sure if this will work, as it's
- // supposed to set 0x40 to the lobyte...
- bar->flags |= 0x40;
+ // Check that the rects are contained
+ if (!barrierRect.contains(actorRect)) {
+ if (BYTE1(barrier->flags) & kBarrierFlag20)
+ if (!(BYTE1(barrier->flags) & kBarrierFlag80))
+ barrier->flags = BYTE1(barrier->flags) | kBarrierFlag40;
continue;
}
- if (bar->flags & 2) {
- // TODO refactor
- if (bar->getField74() || bar->getField78() ||
- bar->getField7C() || bar->getField80())
- intersects = (pt.y > bar->getField78() + (bar->getField80() - bar->getField78()) * (pt.x - bar->getField74()) / (bar->getField7C() - bar->getField74())) == 0;
- else
- intersects = true;
+ // Check if it intersects with either the barrier rect or the related polygon
+ bool intersects = false;
+ if (barrier->flags & kBarrierFlag2) {
+ intersects = pointIntersectsRect(point, *barrier->getRect());
} else {
- if (bar->flags & 0x40) {
- PolyDefinitions *poly = &_polygons->entries[bar->getPolygonIndex()];
- if (pt.x > 0 && pt.y > 0 && poly->numPoints > 0)
- intersects = poly->contains(pt.x, pt.y);
+ if (barrier->flags & kBarrierFlag40) {
+ PolyDefinitions *poly = &_polygons->entries[barrier->getPolygonIndex()];
+ if (point.x > 0 && point.y > 0 && poly->numPoints > 0)
+ intersects = poly->contains(point);
else
- ;//warning ("[drawActorsAndBarriers] trying to find intersection of uninitialized point");
+ warning ("[drawActorsAndBarriers] trying to find intersection of uninitialized point");
}
- // XXX the original has an else case here that
- // assigns intersects the value of the
- // flags & 2 check, which doesn't make any sense since
- // that path would never have been taken if code
- // execution had made it's way here.
}
- if (LO_BYTE(bar->flags) & 0x80 || intersects) {
- if (LO_BYTE(bar->flags) & 0x20)
- // XXX not sure if this will work, as it's
- // supposed to set this value on the lobyte...
- bar->flags &= 0xBF | 0x80;
- else
- // XXX another lobyte assignment...
- bar->flags |= 0x40;
- // TODO label jump up a few lines here. Investigate...
+
+ // Adjust barrier flags
+ if (BYTE1(barrier->flags) & kBarrierFlag80 || intersects) {
+ if (BYTE1(barrier->flags) & kBarrierFlag20)
+ barrier->flags = BYTE1(barrier->flags) & 0xBF | kBarrierFlag80;
+ } else {
+ if (BYTE1(barrier->flags) & kBarrierFlag20) {
+ barrier->flags = BYTE1(barrier->flags) | kBarrierFlag40;
+ }
}
- if (bar->flags & 4) {
- if (intersects) {
- if(act->flags & 2)
- ;//warning ("[drawActorsAndBarriers] Assigning mask to masked character [%s]", bar->name);
- else {
- // TODO there's a call to sub_40ac10 that does
- // a point calculation, but the result doesn't appear to
- // ever be used, and the object passed in as a parameter
- // isn't updated
- act->setBarrierIndex(barIdx);
- act->flags |= 2;
- }
+
+ if (barrier->flags & kBarrierFlag4) {
+ if (intersects && LOBYTE(actor->flags) & kActorFlagMasked) {
+ error("[Scene::processUpdateList] Assigning mask to masked character [%s]", actor->getName());
+ } else {
+ adjustCoordinates(barrier->x, barrier->y, &point);
+ actor->setBarrierIndex(j);
+ actor->flags |= kActorFlagMasked;
}
} else {
if (intersects) {
- // XXX assuming the following:
- // "if ( *(int *)((char *)&scene.characters[0].priority + v18) < *(v12_barrierPtr + 35) )"
- // is the same as what I'm comparing :P
- if (act->getPriority() < bar->getPriority()) {
- act->setField934(1);
- act->setPriority(bar->getPriority() + 3);
- // TODO there's a block of code here that seems
- // to loop through the CharacterUpdateItems and do some
- // priority adjustment. Since I'm not using CharacterUpdateItems as of yet,
- // I'm not sure what to do here
- // The loop seems to occur if:
- // (a) there are still character items to process
- // (b) sceneNumber != 2 && actor->field_944 != 1
+ if (actor->getPriority() < barrier->getPriority()) {
+ actor->setField934(1);
+ actor->setPriority(barrier->getPriority() + 3);
+
+ if (_updateList[i].index > _updateList[0].index) {
+ error("[Scene::processUpdateList] list update not implemented!");
+ }
}
} else {
- if (act->getPriority() > bar->getPriority() || act->getPriority() == 1) {
- act->setField934(1);
- act->setPriority(bar->getPriority() - 1);
- // TODO another character update loop
- // This time it looks like there's another
- // intersection test, and more updates
- // to field_934 and field_944, then
- // priority updates
+ if (actor->getPriority() > barrier->getPriority() || actor->getPriority() == 1) {
+ actor->setField934(1);
+ actor->setPriority(barrier->getPriority() - 1);
+
+ if (_updateList[i].index > _updateList[0].index) {
+ error("[Scene::processUpdateList] list update not implemented!");
+ }
}
}
}
- } // end for (barriers)
+ } // end processing barriers
+
+ // Update all other actors
+ for (uint32 k = 0; k < _updateList.size(); k++) {
+ Actor *actor2 = getActor(_updateList[k].index);
+
+ if (actor2->isVisible() && actor2->getField944() != 1 && actor2->getField944() != 4 && _updateList[k].index != _updateList[i].index) {
+
+ Common::Rect actor2Rect(actor2->x1, actor2->y1, actor2->x1 + actor2->getBoundingRect()->right, actor2->y1 + actor2->getBoundingRect()->bottom);
+
+ if (actor2Rect.contains(actorRect)) {
+
+ // Inferior
+ if ((actor2->y1 + actor2->y2) > (actor->y1 + actor->y2)) {
+ if (actor->getPriority() <= actor2->getPriority()) {
+ if (actor->getField934() || actor2->getNumberValue01()) {
+ if (!actor2->getNumberValue01())
+ actor2->setPriority(actor->getPriority() - 1);
+ } else {
+ actor->setPriority(actor2->getPriority() + 1);
+ }
+ }
+ }
+
+ // Superior
+ if ((actor2->y1 + actor2->y2) < (actor->y1 + actor->y2)) {
+ if (actor->getPriority() >= actor2->getPriority()) {
+ if (actor->getField934() || actor2->getNumberValue01()) {
+ if (!actor2->getNumberValue01())
+ actor2->setPriority(actor->getPriority() + 1);
+ } else {
+ actor->setPriority(actor2->getPriority() - 1);
+ }
+ }
+ }
+ }
+ }
+ }
+
+ if (actor->getField974())
+ getActor(actor->getField980())->setPriority(-actor->getPriority());
}
- } // end for (actors)
+ } // end processing actors
+
+
+ // Go through the list from the end
+ if (_updateList.size() > 1) {
+ for (int i = _ws->actors.size() - 1; i >= 0; --i) {
+ Actor *actor = _ws->actors[i];
+
+ // Skip hidden actors
+ if (!actor->isVisible())
+ continue;
+
+ if (actor->getField944() != 1 && actor->getField944() != 4) {
+ error("[Scene::processUpdateList] list update not implemented!");
+ }
+ }
+ }
+}
+
+//////////////////////////////////////////////////////////////////////////
+// Helpers
+//////////////////////////////////////////////////////////////////////////
+bool Scene::pointIntersectsRect(Common::Point point, Common::Rect rect) {
+ if (rect.top || rect.left || rect.bottom || rect.right) {
+ Common::Rational res((rect.bottom - rect.top) * (point.x - rect.left), rect.right - rect.left);
+
+ return (bool)(point.y > rect.top ? 1 + res.toInt() : res.toInt());
+ }
+ return true;
}
void Scene::getActorPosition(Actor *actor, Common::Point *pt) {
diff --git a/engines/asylum/views/scene.h b/engines/asylum/views/scene.h
index 27d7465ab0..938dfe5ff6 100644
--- a/engines/asylum/views/scene.h
+++ b/engines/asylum/views/scene.h
@@ -312,12 +312,17 @@ private:
int drawScene();
void buildUpdateList();
- void drawUpdateList();
+ void processUpdateList();
static bool updateListCompare(const UpdateItem &item1, const UpdateItem &item2);
void checkVisibleActorsPriority();
void adjustActorPriority(ActorIndex index);
+ //////////////////////////////////////////////////////////////////////////
+ // Helpers
+ //////////////////////////////////////////////////////////////////////////
+ bool pointIntersectsRect(Common::Point point, Common::Rect rect);
+
//////////////////////////////////////////////////////////////////////////
// Scene debugging
//////////////////////////////////////////////////////////////////////////
Commit: cf7c7ed9f6dac2daeff3d471720900524ba9ec58
https://github.com/scummvm/scummvm/commit/cf7c7ed9f6dac2daeff3d471720900524ba9ec58
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:08+02:00
Commit Message:
ASYLUM: Cleanup Barrier::update
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@479 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/asylum.h
engines/asylum/resources/actionlist.cpp
engines/asylum/resources/actor.cpp
engines/asylum/resources/actor.h
engines/asylum/resources/barrier.cpp
engines/asylum/resources/barrier.h
engines/asylum/shared.h
engines/asylum/views/scene.cpp
engines/asylum/views/scene.h
diff --git a/engines/asylum/asylum.h b/engines/asylum/asylum.h
index 3fc64c9538..dbae8072bb 100644
--- a/engines/asylum/asylum.h
+++ b/engines/asylum/asylum.h
@@ -105,7 +105,7 @@ public:
/**
* This is the global tick counter.
*/
- uint32 globalTickValue;
+ uint32 screenUpdatesCount;
uint32 globalTickValue_2;
// Game
diff --git a/engines/asylum/resources/actionlist.cpp b/engines/asylum/resources/actionlist.cpp
index 7df1fba9ab..38fb302837 100644
--- a/engines/asylum/resources/actionlist.cpp
+++ b/engines/asylum/resources/actionlist.cpp
@@ -442,7 +442,7 @@ IMPLEMENT_OPCODE(ShowActor) {
actor->setVisible(true);
actor->updateDirection();
- actor->setTickValue(_scene->vm()->getTick());
+ actor->setLastScreenUpdate(_scene->vm()->getTick());
}
//////////////////////////////////////////////////////////////////////////
diff --git a/engines/asylum/resources/actor.cpp b/engines/asylum/resources/actor.cpp
index 71bd33de60..3915a8dd89 100644
--- a/engines/asylum/resources/actor.cpp
+++ b/engines/asylum/resources/actor.cpp
@@ -117,7 +117,7 @@ void Actor::load(Common::SeekableReadStream *stream) {
_actionIdx2 = stream->readSint32LE();
_field_924 = stream->readSint32LE();
- _tickValue = stream->readSint32LE();
+ _lastScreenUpdate = stream->readSint32LE();
_field_92C = stream->readSint32LE();
actionType = stream->readSint32LE();
_field_934 = stream->readSint32LE();
@@ -255,7 +255,7 @@ void Actor::update() {
_vm->setGameFlag(kGameFlag368);
player->setFrameIndex(0);
- getScene()->getActor(0)->setTickValue(_vm->getTick());
+ getScene()->getActor(0)->setLastScreenUpdate(_vm->getTick());
Sound *sound = _vm->sound();
if (sound->isCacheOk())
@@ -340,14 +340,14 @@ void Actor::update() {
case kActorStatusDisabled:
_frameIndex = (_frameIndex + 1) % _frameCount;
- if (_vm->globalTickValue - _tickValue > 300) {
+ if (_vm->screenUpdatesCount - _lastScreenUpdate > 300) {
if (_vm->getRandom(100) < 50) {
if (!getSound()->soundResourceId || !getSound()->isPlaying(getSound()->soundResourceId)) {
if (isDefaultDirection(10))
updateStatus(kActorStatus9);
}
}
- _tickValue = _vm->globalTickValue;
+ _lastScreenUpdate = _vm->screenUpdatesCount;
}
break;
@@ -771,20 +771,20 @@ void Actor::updateStatusEnabled() {
_frameIndex = (_frameIndex + 1) % _frameCount;
// Actor: Crow
- if (_vm->globalTickValue - _tickValue > 300) {
+ if (_vm->screenUpdatesCount - _lastScreenUpdate > 300) {
if (strcmp(_name, "Crow")) {
if (_vm->getRandom(100) < 50
&& (!getSound()->soundResourceId || !getSound()->isPlaying(getSound()->soundResourceId))
&& isDefaultDirection(10))
updateStatus(kActorStatus9);
- _tickValue = _vm->globalTickValue;
+ _lastScreenUpdate = _vm->screenUpdatesCount;
}
}
// Actor: Player
if (_index == getScene()->getPlayerActorIndex()) {
- if (_vm->globalTickValue_2 && (_vm->globalTickValue - _vm->globalTickValue_2) > 500) {
+ if (_vm->globalTickValue_2 && (_vm->screenUpdatesCount - _vm->globalTickValue_2) > 500) {
if (_vm->isGameFlagNotSet(kGameFlagScriptProcessing)
&& isVisible()
@@ -797,8 +797,8 @@ void Actor::updateStatusEnabled() {
getScene()->playSpeech(4);
}
}
- _tickValue = _vm->globalTickValue;
- _vm->globalTickValue_2 = _vm->globalTickValue;
+ _lastScreenUpdate = _vm->screenUpdatesCount;
+ _vm->globalTickValue_2 = _vm->screenUpdatesCount;
}
return;
diff --git a/engines/asylum/resources/actor.h b/engines/asylum/resources/actor.h
index 3d18d3a5cc..9c33103179 100644
--- a/engines/asylum/resources/actor.h
+++ b/engines/asylum/resources/actor.h
@@ -66,7 +66,7 @@ public:
void setPriority(int32 priority) { _priority = priority; }
void setResourceId(ResourceId id) { _resourceId = id; }
void setStatus(ActorStatus status) { _status = status; }
- void setTickValue(int32 tick) { _tickValue = tick; }
+ void setLastScreenUpdate(int32 tick) { _lastScreenUpdate = tick; }
void setField638(int32 val) { _field_638 = val; }
void setField934(int32 val) { _field_934 = val; }
@@ -256,7 +256,7 @@ private:
int32 _field_8D0[20];
int32 _actionIdx2;
int32 _field_924;
- int32 _tickValue;
+ int32 _lastScreenUpdate;
int32 _field_92C;
//actionType
int32 _field_934;
diff --git a/engines/asylum/resources/barrier.cpp b/engines/asylum/resources/barrier.cpp
index 26e187bbe0..92bff470e3 100644
--- a/engines/asylum/resources/barrier.cpp
+++ b/engines/asylum/resources/barrier.cpp
@@ -102,7 +102,7 @@ void Barrier::load(Common::SeekableReadStream *stream) {
_field_688 = stream->readSint32LE();
for (int i = 0; i < 5; i++)
- _field_68C[i] = stream->readSint32LE();
+ _randomResourceIds[i] = stream->readSint32LE();
_soundResourceId = stream->readSint32LE();
_field_6A4 = stream->readSint32LE();
@@ -183,130 +183,146 @@ void Barrier::draw() {
}
}
+void Barrier::update() {
+ bool doPlaySounds = false;
+ if (_field_3C != 4)
+ return;
-void Barrier::update() {
- bool canPlaySound = false;
- if (_field_3C == 4) {
- if (isVisible()) {
- int32 flag = flags;
- if (flag & 0x20) {
- if (_vm->getTick() - _tickCount >= 0x3E8 / _field_B4) {
- _frameIndex =((_frameIndex + 1) % _frameCount);
- _tickCount = _vm->getTick();
- canPlaySound = true;
- }
- } else if (flag & 0x10) {
- uint32 frameIdx = _frameIndex;
- int equalZero = frameIdx == 0;
- if (!frameIdx) {
- if (_vm->getTick() - _tickCount >= 1000 * _tickCount2) {
- if (_vm->getRandom(_field_C0) == 1) {
- if (_field_68C[0]) {
- // TODO: fix this, and find a better way to get frame count
- // Sometimes we get wrong random resource id
-
- _resourceId = getRandomId();
- GraphicResource *gra = new GraphicResource(getScene()->getResourcePack(), _resourceId);
- _frameCount = gra->getFrameCount();
- delete gra;
- }
- _frameIndex++;
- }
- _tickCount = _vm->getTick();
- canPlaySound = true;
- }
- frameIdx = _frameIndex;
- equalZero = frameIdx == 0;
- }
+ if (!isVisible()) {
+ updateSoundItems();
+ return;
+ }
- if (!equalZero) {
- if (_vm->getTick() - _tickCount >= 0x3E8 / _field_B4) {
- _frameIndex = (_frameIndex + 1) % _frameCount;
- _tickCount = _vm->getTick();
- canPlaySound = true;
- }
- }
- } else if (flag & 8) {
- if (_vm->getTick() - _tickCount >= 0x3E8 / _field_B4) {
- uint32 frameIdx = _frameIndex + 1;
- if (frameIdx < _frameCount - 1) {
- if (_field_688 == 1) {
- // TODO: get global x, y positions
- }
- } else {
- flags &= ~kBarrierFlag8;
- if (_field_688 == 1) {
- // TODO: reset global x, y positions
- }
+ // Examine flags
+ if (flags & kBarrierFlag20) {
+ if (_vm->getTick() - _tickCount >= Common::Rational(1000, _field_B4).toInt()) {
+ _frameIndex =((_frameIndex + 1) % _frameCount);
+ _tickCount = _vm->getTick();
+ doPlaySounds = true;
+ }
+ } else if (flags & kBarrierFlag10) {
+
+ bool isFirstFrame = (_frameIndex == 0);
+
+ if (!_frameIndex) {
+ if (_vm->getTick() - _tickCount >= 1000 * _tickCount2) {
+ if (_vm->getRandom(_field_C0) == 1) {
+ if (_randomResourceIds[0]) {
+ _resourceId = getRandomResourceId();
+ GraphicResource *gra = new GraphicResource(getScene()->getResourcePack(), _resourceId);
+ _frameCount = gra->getFrameCount();
+ delete gra;
}
- _frameIndex = frameIdx;
+ _frameIndex++;
}
- } else if ((flag & 0xFF) & 8) { // check this
- if (_vm->getTick() - _tickCount >= 1000 * _tickCount2) {
- if (_vm->getRandom(_field_C0) == 1) { // TODO: THIS ISNT WORKING
- _frameIndex = (_frameIndex + 1) % _frameCount;
- _tickCount = _vm->getTick();
- canPlaySound = true;
- }
+ _tickCount = _vm->getTick();
+ doPlaySounds = true;
+ }
+
+ isFirstFrame = (_frameIndex == 0);
+ }
+
+ if (!isFirstFrame) {
+ if (_vm->getTick() - _tickCount >= Common::Rational(1000, _field_B4).toInt()) {
+ _frameIndex =((_frameIndex + 1) % _frameCount);
+ _tickCount = _vm->getTick();
+ doPlaySounds = true;
+ }
+ }
+ } else if (BYTE1(flags) & kBarrierFlag8) {
+ if (_vm->getTick() - _tickCount >= 1000 * _tickCount2) {
+ if (_vm->getRandom(_field_C0) == 1)
+ _frameIndex =((_frameIndex + 1) % _frameCount);
+
+ _tickCount = _vm->getTick();
+ doPlaySounds = true;
+ }
+ } else if (flags & kBarrierFlag8) {
+
+ if (_vm->getTick() - _tickCount >= Common::Rational(1000, _field_B4).toInt()) {
+
+ ++_frameIndex;
+
+ if (_frameIndex < _frameCount - 1) {
+ if (_field_688 == 1) {
+ GraphicResource *gra = new GraphicResource(getScene()->getResourcePack(), _resourceId);
+ GraphicFrame *frame = gra->getFrame(_frameIndex);
+ getScene()->setGlobalX(x + frame->x + (frame->getWidth() >> 1));
+ getScene()->setGlobalY(y + frame->y + (frame->getHeight() >> 1));
+ delete gra;
}
- } else if (!((flag & 0xFFFF) & 6)) {
- if (_vm->getTick() - _tickCount >= 0x3E8 / _field_B4 && (flag & 0x10000)) {
- uint32 frameIdx = _frameIndex - 1;
- if (frameIdx <= 0) {
- flags &= ~kBarrierFlag10000;
- if (_field_688 == 1) {
- // TODO: reset global x, y positions
- }
- _tickCount = _vm->getTick();
- canPlaySound = true;
- }
- if (_field_688 == 1) {
- // TODO: get global x, y positions
- }
- _frameIndex = frameIdx;
- } else if (_vm->getTick() - _tickCount >= 0x3E8 / _field_B4) {
- if ((flag & 0xFF) & 2) {
- if (_frameIndex == _frameCount - 1) {
- _frameIndex--;
- flags = ((flag & 0xFF) & 0xFD) | 4;
- } else {
- _frameIndex++;
- }
- } else if ((flag & 0xFF) & 4) {
- if (_frameIndex) {
- _frameIndex--;
- } else {
- _frameIndex++;
- flags = ((flag & 0xFF) & 0xFB) | 2;
- }
- }
+ } else {
+ flags &= ~kBarrierFlag8;
+ if (_field_688 == 1) {
+ getScene()->setGlobalX(-1);
+ getScene()->setGlobalY(-1);
}
}
+ _tickCount = _vm->getTick();
+ doPlaySounds = true;
+ }
+ } else if (!(BYTE1(flags) & kBarrierFlag6)) {
- flag = flags;
- flag &= 0x40000;
- if (flag != 0) {
- if (_frameIndex == _frameCount - 1) {
- if (_field_B4 <= 15) {
- _field_B4 -= 2;
- if (_field_B4 < 0)
- _field_B4 = 0;
- } else {
- _field_B4 = 15;
- }
- if (!_field_B4)
- flags &= 0xFFFEF1C7;
+ if ((flags & kBarrierFlag10000) && (_vm->getTick() - _tickCount >= Common::Rational(1000, _field_B4).toInt())) {
+
+ ++_frameIndex;
+
+ if (_frameIndex <= 0) {
+ flags &= ~kBarrierFlag10000;
+ if (_field_688 == 1) {
+ getScene()->setGlobalX(-1);
+ getScene()->setGlobalY(-1);
}
+ } else if (_field_688 == 1) {
+ GraphicResource *gra = new GraphicResource(getScene()->getResourcePack(), _resourceId);
+ GraphicFrame *frame = gra->getFrame(_frameIndex);
+ getScene()->setGlobalX(x + frame->x + (frame->getWidth() >> 1));
+ getScene()->setGlobalY(y + frame->y + (frame->getHeight() >> 1));
+ delete gra;
}
+
+ _tickCount = _vm->getTick();
+ doPlaySounds = true;
}
+ } else if (_vm->getTick() - _tickCount >= Common::Rational(1000, _field_B4).toInt()) {
+ if (BYTE1(flags) & kBarrierFlag2) {
+ if (_frameIndex == _frameCount - 1) {
+ _frameIndex--;
+ flags = BYTE1(flags) & 0xFD | kBarrierFlag4;
+ } else {
+ _frameIndex++;
+ }
+ } else if (BYTE1(flags) & kBarrierFlag4) {
+ if (_frameIndex) {
+ _frameIndex--;
+ } else {
+ _frameIndex++;
+ flags = BYTE1(flags) & 0xFB | kBarrierFlag2;
+ }
+ }
+ }
+
+ if (flags & kBarrierFlag40000) {
+ if (_frameIndex == _frameCount - 1) {
+ if (_field_B4 <= 15) {
+ _field_B4 -= 2;
+
+ if (_field_B4 < 0)
+ _field_B4 = 0;
+ } else {
+ _field_B4 = 15;
+ }
- if (canPlaySound) {
- updateSoundItems();
- stopSound();
+ if (!_field_B4)
+ flags &= ~kBarrierFlag10E38;
}
}
- // TODO: get sound functions according with scene
+
+ if (doPlaySounds)
+ playSounds();
+
+ getScene()->callSpecFunction(this, -1);
}
void Barrier::setNextFrame(int32 targetFlags) {
@@ -321,6 +337,10 @@ void Barrier::setNextFrame(int32 targetFlags) {
/////////////////////////////////////////////////////////////////////////
// Misc
/////////////////////////////////////////////////////////////////////////
+void Barrier::playSounds() {
+ error("[Barrier::playSounds] not implemented!");
+}
+
void Barrier::updateSoundItems() {
for (int32 i = 0; i < ARRAYSIZE(_soundItems); i++) {
@@ -351,21 +371,23 @@ void Barrier::stopAllSounds() {
}
}
-int32 Barrier::getRandomId() {
- int32 numRes = 0;
- ResourceId randomResourceIds[5];
- memset(&randomResourceIds, 0, sizeof(randomResourceIds));
+int32 Barrier::getRandomResourceId() {
+ // Initialize random resource id array
+ ResourceId shuffle[5];
+ memset(&shuffle, 0, sizeof(shuffle));
+ int32 count = 0;
+
for (int32 i = 0; i < 5; i++) {
- if (_field_68C[i]) {
- randomResourceIds[numRes] = _field_68C[i];
- numRes++;
+ if (_randomResourceIds[i]) {
+ shuffle[count] = _randomResourceIds[i];
+ count++;
}
}
- if (numRes > 0)
- return randomResourceIds[rand() % numRes];
+ if (count == 0)
+ error("[Barrier::getRandomId] Could not get a random resource Id");
- return _resourceId;
+ return shuffle[_vm->getRandom(count)];
}
bool Barrier::checkFlags() {
diff --git a/engines/asylum/resources/barrier.h b/engines/asylum/resources/barrier.h
index 9e287142c5..0c8b3baa3f 100644
--- a/engines/asylum/resources/barrier.h
+++ b/engines/asylum/resources/barrier.h
@@ -53,7 +53,6 @@ public:
void setFrameIndex(int32 index) { _frameIndex = index; }
void setPriority(int32 priority) { _priority = priority; }
- void setResourceId(ResourceId id) { _resourceId = id; }
void setField67C(int32 val) { _field_67C = val; }
@@ -101,13 +100,6 @@ public:
*/
bool isOnScreen();
- /**
- * Query if this barrier is visible.
- *
- * @return true if visible, false if not.
- */
- bool isVisible();
-
/////////////////////////////////////////////////////////////////////////
// Drawing & update
//////////////////////////////////////////////////////////////////////////
@@ -133,26 +125,18 @@ public:
// Misc
////////////////////////////////////////////////////////////////////////
- /**
- * Check if any items in the barrier sound array are playing,
- * and based on their flag values, stop them accordingly
- */
- void updateSoundItems();
-
- /**
- * Stop the barrier related sounds
- */
- void stopSound();
-
/**
* Stop all barrier sounds (called from scripts)
*/
void stopAllSounds();
+ /**
+ * Checks the barrier flags
+ *
+ * @return true if it succeeds, false if it fails.
+ */
bool checkFlags();
- int32 getRandomId(); // TODO Give this a better name?
-
private:
AsylumEngine *_vm;
@@ -190,10 +174,40 @@ private:
int32 _soundX;
int32 _soundY;
int32 _field_688;
- int32 _field_68C[5];
+ int32 _randomResourceIds[5];
ResourceId _soundResourceId;
int32 _field_6A4;
+ /**
+ * Query if this barrier is visible.
+ *
+ * @return true if visible, false if not.
+ */
+ bool isVisible();
+
+ /**
+ * Play barrier sounds
+ */
+ void playSounds();
+
+ /**
+ * Check if any items in the barrier sound array are playing,
+ * and based on their flag values, stop them accordingly
+ */
+ void updateSoundItems();
+
+ /**
+ * Stop the barrier related sounds
+ */
+ void stopSound();
+
+ /**
+ * Gets a random resource identifier for this barrier (using the list in _randomResourceIds)
+ *
+ * @return The random resource identifier.
+ */
+ int32 getRandomResourceId();
+
}; // end of class Barrier
} // end of namespace Asylum
diff --git a/engines/asylum/shared.h b/engines/asylum/shared.h
index 584fb7783c..7433079812 100644
--- a/engines/asylum/shared.h
+++ b/engines/asylum/shared.h
@@ -230,7 +230,9 @@ enum BarrierFlag {
kBarrierFlagEnabled = 0x1,
kBarrierFlag2 = 0x2,
kBarrierFlag4 = 0x4,
+ kBarrierFlag6 = 0x6,
kBarrierFlag8 = 0x8,
+ kBarrierFlag10 = 0x10,
kBarrierFlag20 = 0x20,
kBarrierFlag40 = 0x40,
kBarrierFlag80 = 0x80,
@@ -265,12 +267,11 @@ enum BarrierFlag {
#define getScreen() _vm->screen()
#define getWorld() _vm->scene()->worldstats()
-
//////////////////////////////////////////////////////////////////////////
// Sub-integer partial access macros
//////////////////////////////////////////////////////////////////////////
#define LOBYTE(d) (*((char*)&(d)))
-#define BYTE1(d) (*((char*)&(d)+1)) // Same as HIBYTE()
+#define BYTE1(d) (*((char*)&(d)+1)) // Same as HIBYTE()
diff --git a/engines/asylum/views/scene.cpp b/engines/asylum/views/scene.cpp
index bbd99e55cb..75eec7d3aa 100644
--- a/engines/asylum/views/scene.cpp
+++ b/engines/asylum/views/scene.cpp
@@ -104,7 +104,7 @@ Scene::Scene(uint8 sceneIdx, AsylumEngine *engine): _vm(engine) {
_ws->field_120 = -1;
for (int32 a = 0; a < _ws->numActors; a++)
- _ws->actors[a]->setTickValue(_vm->getTick());
+ _ws->actors[a]->setLastScreenUpdate(_vm->getTick());
// TODO: init action list
@@ -118,7 +118,7 @@ void Scene::initialize() {
_playerActorIdx = 0;
if (_ws->numBarriers > 0) {
- int32 priority = 0x0FFB;
+ int32 priority = 4091;
for (int32 b = 0; b < _ws->numBarriers; b++) {
Barrier *barrier = _ws->barriers[b];
barrier->setPriority(priority);
@@ -174,11 +174,11 @@ void Scene::initialize() {
startMusic();
- _vm->globalTickValue = 1;
+ _vm->screenUpdatesCount = 1;
// TODO sceneRectChangedFlag = 1;
- actor->setTickValue(_vm->getTick());
+ actor->setLastScreenUpdate(_vm->getTick());
// XXX This initialization was already done earlier,
// so I'm not sure why we need to do it again. Investigate.
actor->updateDirection();
@@ -1426,6 +1426,10 @@ void Scene::resetActor0() {
error("[Scene::resetActor0] not implemented!");
}
+void Scene::callSpecFunction(Barrier* barrier, ActorIndex index) {
+ error("[Scene::callSpecFunction] not implemented!");
+}
+
//////////////////////////////////////////////////////////////////////////
// SceneTitle
//////////////////////////////////////////////////////////////////////////
diff --git a/engines/asylum/views/scene.h b/engines/asylum/views/scene.h
index 938dfe5ff6..236c66ec02 100644
--- a/engines/asylum/views/scene.h
+++ b/engines/asylum/views/scene.h
@@ -155,10 +155,10 @@ public:
// Shared global Data
- uint32 getGlobalX() const { return _globalX; }
- void setGlobalX(uint32 val) { _globalX = val; }
- uint32 getGlobalY() const { return _globalY; }
- void setGlobalY(uint32 val) { _globalY = val; }
+ int32 getGlobalX() const { return _globalX; }
+ void setGlobalX(int32 val) { _globalX = val; }
+ int32 getGlobalY() const { return _globalY; }
+ void setGlobalY(int32 val) { _globalY = val; }
ActorDirection getGlobalDirection() { return _globalDirection; }
@@ -185,6 +185,7 @@ public:
// Shared methods
void resetActor0();
+ void callSpecFunction(Barrier* barrier, ActorIndex index);
/** .text:00408980
* Determine if the supplied point intersects
@@ -252,8 +253,8 @@ private:
GraphicResource *_bgResource;
GraphicFrame *_background;
- uint32 _globalX;
- uint32 _globalY;
+ int32 _globalX;
+ int32 _globalY;
int32 _sceneOffset;
int32 _sceneXLeft;
int32 _sceneYTop;
Commit: c62108194e94ac27a0a0b8f813d9aedf6350c0f8
https://github.com/scummvm/scummvm/commit/c62108194e94ac27a0a0b8f813d9aedf6350c0f8
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:08+02:00
Commit Message:
ASYLUM: Implement Scene spec function for Chapter 1
- Implement parts of Barrier::playSounds
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@480 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/resources/actor.cpp
engines/asylum/resources/actor.h
engines/asylum/resources/barrier.cpp
engines/asylum/resources/barrier.h
engines/asylum/shared.h
engines/asylum/system/graphics.cpp
engines/asylum/system/graphics.h
engines/asylum/system/sound.cpp
engines/asylum/system/sound.h
engines/asylum/views/scene.cpp
engines/asylum/views/scene.h
diff --git a/engines/asylum/resources/actor.cpp b/engines/asylum/resources/actor.cpp
index 3915a8dd89..820acd44bd 100644
--- a/engines/asylum/resources/actor.cpp
+++ b/engines/asylum/resources/actor.cpp
@@ -941,7 +941,7 @@ void Actor::setVolume() {
return;
// Compute volume
- int32 volume = Config.voiceVolume + getSound()->calculateVolume(x2 + x1, y2 + y1, _field_968, 0);
+ int32 volume = Config.voiceVolume + getSound()->calculateVolumeAdjustement(x2 + x1, y2 + y1, _field_968, 0);
if (volume < -10000)
volume = -10000;
diff --git a/engines/asylum/resources/actor.h b/engines/asylum/resources/actor.h
index 9c33103179..6f1c7ddcda 100644
--- a/engines/asylum/resources/actor.h
+++ b/engines/asylum/resources/actor.h
@@ -62,11 +62,11 @@ public:
void setDirection(ActorDirection direction) { _direction = direction; }
void setFrameCount(int32 count) { _frameCount = count; }
void setFrameIndex(int32 number) { _frameIndex = number; }
+ void setLastScreenUpdate(int32 tick) { _lastScreenUpdate = tick; }
void setNumberFlag01(int32 number) { _numberFlag01 = number; }
void setPriority(int32 priority) { _priority = priority; }
void setResourceId(ResourceId id) { _resourceId = id; }
void setStatus(ActorStatus status) { _status = status; }
- void setLastScreenUpdate(int32 tick) { _lastScreenUpdate = tick; }
void setField638(int32 val) { _field_638 = val; }
void setField934(int32 val) { _field_934 = val; }
@@ -84,6 +84,7 @@ public:
int32 getReaction(uint32 index) { return _reaction[index]; }
ResourceId getResourceId() { return _resourceId; }
ResourceId getResourcesId(uint32 index) { return _graphicResourceIds[index]; }
+ ResourceId getSoundResourceId() { return _soundResourceId; }
ActorStatus getStatus() { return _status; }
int32 getField638() { return _field_638; }
diff --git a/engines/asylum/resources/barrier.cpp b/engines/asylum/resources/barrier.cpp
index 92bff470e3..4592397915 100644
--- a/engines/asylum/resources/barrier.cpp
+++ b/engines/asylum/resources/barrier.cpp
@@ -338,7 +338,58 @@ void Barrier::setNextFrame(int32 targetFlags) {
// Misc
/////////////////////////////////////////////////////////////////////////
void Barrier::playSounds() {
- error("[Barrier::playSounds] not implemented!");
+ int32 soundX = 0;
+ int32 soundY = 0;
+
+ if (_soundX || _soundY) {
+ soundX = _soundX;
+ soundY = _soundY;
+ } else {
+ GraphicResource *resource = new GraphicResource(getScene()->getResourcePack(), _resourceId);
+
+ if (LOBYTE(flags) & kBarrierFlag4) {
+ soundX = x + (resource->getFlags() >> 1);
+ soundY = y + (resource->getFlags2() >> 1);
+ } else {
+ // TODO _frameIndex here seems to be == _frameCount so something wrong somewhere!
+ /*GraphicFrame *frame = resource->getFrame(_frameIndex);
+
+ soundX = x + (frame->getWidth() >> 1);
+ soundY = x + (frame->getHeight() >> 1);*/
+ }
+
+ delete resource;
+ }
+
+ for (int i = 0; i < ARRAYSIZE(_soundItems); i++) {
+ SoundItem *item = &_soundItems[i];
+
+ if (item->resourceId == kResourceNone)
+ continue;
+
+ if (item->field_4 && !getSound()->isPlaying(item->resourceId)) {
+ int32 volume = Config.sfxVolume + getSound()->calculateVolumeAdjustement(soundX, soundY, item->field_8, item->field_C);
+
+ if (volume > -5000)
+ getSound()->playSound(item->resourceId, true, volume, getSound()->calculatePanningAtPoint(soundX, soundY));
+ }
+
+ if (getSound()->isPlaying(item->resourceId)) {
+ int32 volume = Config.sfxVolume + getSound()->calculateVolumeAdjustement(soundX, soundY, item->field_8, item->field_C);
+
+ if (volume > -5000) {
+ if (volume > 0)
+ volume = 0;
+
+ getSound()->setPanning(item->resourceId, getSound()->calculatePanningAtPoint(soundX, soundY));
+ getSound()->setVolume(item->resourceId, volume);
+ } else {
+ getSound()->stopSound(item->resourceId);
+ }
+ }
+ }
+
+ //warning("[Barrier::playSounds] not implemented!");
}
void Barrier::updateSoundItems() {
diff --git a/engines/asylum/resources/barrier.h b/engines/asylum/resources/barrier.h
index 0c8b3baa3f..8bce7521f0 100644
--- a/engines/asylum/resources/barrier.h
+++ b/engines/asylum/resources/barrier.h
@@ -56,17 +56,19 @@ public:
void setField67C(int32 val) { _field_67C = val; }
- Common::Rect *getBoundingRect() { return &_boundingRect; }
- uint32 getFrameIndex() { return _frameIndex; }
- uint32 getFrameCount() { return _frameCount; }
- int32 getId() { return _id; }
- int32 getPolygonIndex() { return _polygonIndex; }
- int32 getPriority() { return _priority; }
- ResourceId getResourceId() { return _resourceId; }
-
- Common::Rect *getRect() { return &_rect; }
- int32 getField67C() { return _field_67C; }
- int32 getField688() { return _field_688; }
+ Common::Rect *getBoundingRect() { return &_boundingRect; }
+ uint32 getFrameIndex() { return _frameIndex; }
+ uint32 getFrameCount() { return _frameCount; }
+ FrameSoundItem *getFrameSoundItem(uint32 index) { assert(index < ARRAYSIZE(_frameSoundItems)); return &_frameSoundItems[index]; }
+ int32 getId() { return _id; }
+ int32 getPolygonIndex() { return _polygonIndex; }
+ int32 getPriority() { return _priority; }
+ ResourceId getResourceId() { return _resourceId; }
+ ResourceId getSoundResourceId() { return _soundResourceId; }
+
+ Common::Rect *getRect() { return &_rect; }
+ int32 getField67C() { return _field_67C; }
+ int32 getField688() { return _field_688; }
/////////////////////////////////////////////////////////////////////////
// Loading & disabling
diff --git a/engines/asylum/shared.h b/engines/asylum/shared.h
index 7433079812..cad3371509 100644
--- a/engines/asylum/shared.h
+++ b/engines/asylum/shared.h
@@ -265,6 +265,7 @@ enum BarrierFlag {
#define getSound() _vm->sound()
#define getScene() _vm->scene()
#define getScreen() _vm->screen()
+#define getSpeech() _vm->scene()->speech()
#define getWorld() _vm->scene()->worldstats()
//////////////////////////////////////////////////////////////////////////
diff --git a/engines/asylum/system/graphics.cpp b/engines/asylum/system/graphics.cpp
index 11512b9c8e..00380a44d0 100644
--- a/engines/asylum/system/graphics.cpp
+++ b/engines/asylum/system/graphics.cpp
@@ -55,8 +55,8 @@ void GraphicResource::clear() {
}
GraphicFrame *GraphicResource::getFrame(uint32 frame) {
- if (frame > _frames.size())
- error("[GraphicResource::getFrame] Invalid frame index (was: %d, max:%d)", frame, _frames.size());
+ if (frame >= _frames.size())
+ error("[GraphicResource::getFrame] Invalid frame index (was: %d, max:%d)", frame, _frames.size() - 1);
return &_frames[frame];
}
@@ -70,8 +70,9 @@ void GraphicResource::init(byte *data, int32 size) {
dataPtr += 4; // tag value
- _flags = (int32)READ_LE_UINT32(dataPtr);
+ _flags = (int32)READ_LE_UINT32(dataPtr);
dataPtr += 4;
+ //_flags2 = (int32)READ_LE_UINT32(dataPtr);
contentOffset = (int32)READ_LE_UINT32(dataPtr);
dataPtr += 4;
diff --git a/engines/asylum/system/graphics.h b/engines/asylum/system/graphics.h
index 530261aadf..e7e4e70bf4 100644
--- a/engines/asylum/system/graphics.h
+++ b/engines/asylum/system/graphics.h
@@ -70,11 +70,13 @@ public:
GraphicFrame *getFrame(uint32 frame);
ResourceId getResourceId() { return _resourceId; }
int32 getFlags() { return _flags; }
+ int32 getFlags2() { return _flags2; }
uint32 getFrameCount() { return _frames.size(); }
private:
Common::Array <GraphicFrame> _frames;
int32 _flags;
+ int32 _flags2;
ResourceId _resourceId;
void init(byte *data, int32 size);
diff --git a/engines/asylum/system/sound.cpp b/engines/asylum/system/sound.cpp
index 919a81de25..97cb7c17c5 100644
--- a/engines/asylum/system/sound.cpp
+++ b/engines/asylum/system/sound.cpp
@@ -102,10 +102,18 @@ int32 Sound::getAdjustedVolume(int32 volume) {
error("[Sound::getAdjustedVolume] not implemented");
}
-int32 Sound::calculateVolume(int32 x, int32 y, int32 a5, int32 a6) {
+int32 Sound::calculateVolumeAdjustement(int32 x, int32 y, int32 a5, int32 a6) {
error("[Sound::calculateVolume] not implemented");
}
+void Sound::setPanning(ResourceId resourceId, int32 panning) {
+ error("[Sound::setPanning] not implemented");
+}
+
+int32 Sound::calculatePanningAtPoint(int32 x, int32 y) {
+ error("[Sound::calculatePanningAtPoint] not implemented");
+}
+
int32 Sound::getBufferPosition(ResourceId resourceId) {
int32 pos = -1;
diff --git a/engines/asylum/system/sound.h b/engines/asylum/system/sound.h
index 7c6f8e8809..ecd5cdb885 100644
--- a/engines/asylum/system/sound.h
+++ b/engines/asylum/system/sound.h
@@ -90,6 +90,7 @@ public:
void playSound(ResourcePack *pack, ResourceId resourceId, bool looping, int32 volume, int32 panning);
void playSound(ResourceEntry *resource, bool looping, int32 volume, int32 panning);
void playSound(ResourceId resourceId, bool looping, int32 volume, int32 panning, bool fromBuffer = false);
+
void stopSound(ResourceId resourceId);
void stopSound();
void stopAllSounds(bool stopSpeechAndMusic = false);
@@ -104,7 +105,14 @@ public:
void setVolume(ResourceId resourceId, double volume);
int32 getAdjustedVolume(int32 volume);
- int32 calculateVolume(int32 x, int32 y, int32 a5, int32 a6);
+ void setPanning(ResourceId resourceId, int32 panning);
+ int32 calculatePanningAtPoint(int32 x, int32 y);
+
+ /**
+ * Determine the amount to increase the supplied sound
+ * sample's volume based on the position
+ */
+ int32 calculateVolumeAdjustement(int32 x, int32 y, int32 a5, int32 a6);
/**
* Check if the buffered sound sample that matches the provided id currently
diff --git a/engines/asylum/views/scene.cpp b/engines/asylum/views/scene.cpp
index 75eec7d3aa..957ddc9cc5 100644
--- a/engines/asylum/views/scene.cpp
+++ b/engines/asylum/views/scene.cpp
@@ -26,6 +26,7 @@
#include "asylum/views/scene.h"
#include "asylum/resources/actor.h"
+#include "asylum/resources/encounters.h"
#include "asylum/system/config.h"
@@ -1059,13 +1060,7 @@ bool Scene::updateListCompare(const UpdateItem &item1, const UpdateItem &item2)
return item1.priority - item2.priority;
}
-void Scene::checkVisibleActorsPriority() {
- error("[Scene::checkVisibleActorsPriority] not implemented");
-}
-void Scene::adjustActorPriority(ActorIndex index) {
- error("[Scene::adjustActorPriority] not implemented");
-}
void Scene::buildUpdateList() {
_updateList.clear();
@@ -1249,6 +1244,52 @@ void Scene::processUpdateList() {
}
}
+void Scene::checkVisibleActorsPriority() {
+ error("[Scene::checkVisibleActorsPriority] not implemented");
+}
+
+void Scene::adjustActorPriority(ActorIndex index) {
+ error("[Scene::adjustActorPriority] not implemented");
+}
+
+//////////////////////////////////////////////////////////////////////////
+// Spec functions
+//////////////////////////////////////////////////////////////////////////
+void Scene::specChapter1(Barrier *barrier, ActorIndex actorIndex) {
+ if (actorIndex == -1 && barrier == NULL)
+ error("[Scene::specChapter1] Both arguments cannot be empty!");
+
+ ResourceId id = (actorIndex == -1) ? barrier->getSoundResourceId() : getActor(actorIndex)->getSoundResourceId();
+
+ if (!_vm->encounter()->getFlag(kEncounterFlag2)) {
+ if (!id || !getSound()->isPlaying(id))
+ if (Config.performance > 2)
+ error("[Scene::specChapter1] Sound function not implemented!");
+ }
+
+ if (actorIndex == -1) {
+ switch (barrier->getId()) {
+ default:
+ break;
+
+ case 101:
+ if (barrier->getFrameIndex() == 2)
+ barrier->getFrameSoundItem(0)->resourceId = _ws->graphicResourceIds[rnd(2) ? 37 : 38];
+ break;
+
+ case 112:
+ if (barrier->getFrameIndex() == 5)
+ getSpeech()->play(81);
+ break;
+
+ case 434:
+ if (barrier->getFrameIndex() == 23)
+ getSpeech()->play(82);
+ break;
+ }
+ }
+}
+
//////////////////////////////////////////////////////////////////////////
// Helpers
//////////////////////////////////////////////////////////////////////////
@@ -1427,7 +1468,30 @@ void Scene::resetActor0() {
}
void Scene::callSpecFunction(Barrier* barrier, ActorIndex index) {
- error("[Scene::callSpecFunction] not implemented!");
+ // The original uses a function array, we just use switch for now there is only 11 entries
+ switch (_ws->numChapter) {
+ default:
+ error("[Scene::callSpecFunction] Invalid chapter");
+
+ case 0:
+ // Nothing to do here
+ break;
+
+ case 1:
+ break;
+
+ case 2:
+ case 3:
+ case 4:
+ case 5:
+ case 6:
+ case 7:
+ case 8:
+ case 9:
+ case 10:
+ error("[Scene::callSpecFunction] No implemented!");
+ break;
+ }
}
//////////////////////////////////////////////////////////////////////////
diff --git a/engines/asylum/views/scene.h b/engines/asylum/views/scene.h
index 236c66ec02..73d0d8768d 100644
--- a/engines/asylum/views/scene.h
+++ b/engines/asylum/views/scene.h
@@ -319,6 +319,11 @@ private:
void checkVisibleActorsPriority();
void adjustActorPriority(ActorIndex index);
+ //////////////////////////////////////////////////////////////////////////
+ // Spec functions
+ //////////////////////////////////////////////////////////////////////////
+ void specChapter1(Barrier *barrier, ActorIndex actorIndex);
+
//////////////////////////////////////////////////////////////////////////
// Helpers
//////////////////////////////////////////////////////////////////////////
Commit: 7f7a8d4a262894e4ef9ee48b8d0c9e171610453d
https://github.com/scummvm/scummvm/commit/7f7a8d4a262894e4ef9ee48b8d0c9e171610453d
Author: Alex Bevilacqua (alexbevi at gmail.com)
Date: 2021-05-17T15:36:08+02:00
Commit Message:
ASYLUM: silenced GCC warnings
- also added svn:ignore on .deps (seems like I keep doing this :P)
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@481 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/resources/actionlist.cpp
engines/asylum/resources/barrier.cpp
diff --git a/engines/asylum/resources/actionlist.cpp b/engines/asylum/resources/actionlist.cpp
index 38fb302837..1389bd3ba5 100644
--- a/engines/asylum/resources/actionlist.cpp
+++ b/engines/asylum/resources/actionlist.cpp
@@ -884,7 +884,10 @@ IMPLEMENT_OPCODE(PlayMovie) {
check = true;
}
- if (!check && _scene->matteVar2 == 0 && _scene->worldstats()->musicCurrentResourceId != kResourceMusic_FFFFFD66)
+ // XXX casting kResourceMusic_FFFFFD66 to silence a GCC warning
+ if (!check &&
+ _scene->matteVar2 == 0 &&
+ _scene->worldstats()->musicCurrentResourceId != (int)kResourceMusic_FFFFFD66)
if (_scene->vm()->sound()->isCacheOk())
_scene->vm()->sound()->playMusic(_scene->getResourcePack(), _scene->worldstats()->musicCurrentResourceId + kResourceMusic_80020000);
@@ -1046,11 +1049,11 @@ IMPLEMENT_OPCODE(IncrementParam2) {
IMPLEMENT_OPCODE(WaitUntilFramePlayed) {
Barrier *barrier = _scene->worldstats()->getBarrierById(cmd->param1);
- uint32 frameNum = cmd->param2;
+ int32 frameNum = cmd->param2;
if (frameNum == -1)
frameNum = barrier->getFrameCount() - 1;
- if (barrier->getFrameIndex() != frameNum) {
+ if ((int32)barrier->getFrameIndex() != frameNum) {
_lineIncrement = 1;
_waitCycle = true;
}
@@ -1451,20 +1454,20 @@ IMPLEMENT_OPCODE(JumpBarrierFrame) {
if (cmd->param2 == -1)
cmd->param2 = barrier->getFrameCount() - 1;
- if (cmd->param3)
- if(barrier->getFrameIndex() == (uint32)cmd->param2) {
+ if (cmd->param3) {
+ if(barrier->getFrameIndex() == (uint32)cmd->param2)
return;
- } else if (cmd->param4)
- if (barrier->getFrameIndex() < (uint32)cmd->param2) {
+ } else if (cmd->param4) {
+ if (barrier->getFrameIndex() < (uint32)cmd->param2)
return;
- } else if (cmd->param5)
- if (barrier->getFrameIndex() > (uint32)cmd->param2) {
+ } else if (cmd->param5) {
+ if (barrier->getFrameIndex() > (uint32)cmd->param2)
return;
- } else if (cmd->param6)
- if (barrier->getFrameIndex() <= (uint32)cmd->param2) {
+ } else if (cmd->param6) {
+ if (barrier->getFrameIndex() <= (uint32)cmd->param2)
return;
- } else if (cmd->param7)
- if (barrier->getFrameIndex() >= (uint32)cmd->param2) {
+ } else if (cmd->param7) {
+ if (barrier->getFrameIndex() >= (uint32)cmd->param2)
return;
} else if (!cmd->param8 || barrier->getFrameIndex() != (uint32)cmd->param2) {
return;
diff --git a/engines/asylum/resources/barrier.cpp b/engines/asylum/resources/barrier.cpp
index 4592397915..297a7177f8 100644
--- a/engines/asylum/resources/barrier.cpp
+++ b/engines/asylum/resources/barrier.cpp
@@ -289,7 +289,7 @@ void Barrier::update() {
if (BYTE1(flags) & kBarrierFlag2) {
if (_frameIndex == _frameCount - 1) {
_frameIndex--;
- flags = BYTE1(flags) & 0xFD | kBarrierFlag4;
+ flags = (BYTE1(flags) & 0xFD) | kBarrierFlag4;
} else {
_frameIndex++;
}
@@ -298,7 +298,7 @@ void Barrier::update() {
_frameIndex--;
} else {
_frameIndex++;
- flags = BYTE1(flags) & 0xFB | kBarrierFlag2;
+ flags = (BYTE1(flags) & 0xFB) | kBarrierFlag2;
}
}
}
Commit: 3dfab1cc46c4c257164faa2de6eadb3a740bb5a6
https://github.com/scummvm/scummvm/commit/3dfab1cc46c4c257164faa2de6eadb3a740bb5a6
Author: Alex Bevilacqua (alexbevi at gmail.com)
Date: 2021-05-17T15:36:09+02:00
Commit Message:
ASYLUM: fix more GCC warnings (overflow in implicit constant conversion)
- minor whitespace cleanup as well
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@482 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/asylum.cpp
engines/asylum/resources/actionlist.cpp
engines/asylum/resources/actor.cpp
engines/asylum/system/sound.cpp
engines/asylum/system/sound.h
diff --git a/engines/asylum/asylum.cpp b/engines/asylum/asylum.cpp
index 2547cbedf7..16a9d452c1 100644
--- a/engines/asylum/asylum.cpp
+++ b/engines/asylum/asylum.cpp
@@ -191,7 +191,7 @@ void AsylumEngine::playIntro() {
// Play the intro sound sample (the screen is blacked out, you hear
// an alarm sounding and men talking about.
- _sound->playSound(kResourceSoundIntro, false, Config.sfxVolume, 0);
+ _sound->playSound((int)kResourceSoundIntro);
}
void AsylumEngine::handleEvents(bool doUpdate) { // k_sub_40AE30 (0040AE30)
diff --git a/engines/asylum/resources/actionlist.cpp b/engines/asylum/resources/actionlist.cpp
index 1389bd3ba5..dc24e9c6c3 100644
--- a/engines/asylum/resources/actionlist.cpp
+++ b/engines/asylum/resources/actionlist.cpp
@@ -935,7 +935,7 @@ IMPLEMENT_OPCODE(ChangeMusicById) {
//////////////////////////////////////////////////////////////////////////
// Opcode 0x33
IMPLEMENT_OPCODE(StopMusic) {
- _scene->vm()->sound()->changeMusic(_scene->getResourcePack(), kResourceMusic_FFFFFD66, 0);
+ _scene->vm()->sound()->changeMusic(_scene->getResourcePack(), (int)kResourceMusic_FFFFFD66, 0);
}
//////////////////////////////////////////////////////////////////////////
diff --git a/engines/asylum/resources/actor.cpp b/engines/asylum/resources/actor.cpp
index 820acd44bd..6ed4d1b86b 100644
--- a/engines/asylum/resources/actor.cpp
+++ b/engines/asylum/resources/actor.cpp
@@ -259,7 +259,7 @@ void Actor::update() {
Sound *sound = _vm->sound();
if (sound->isCacheOk())
- sound->playMusic(getScene()->getResourcePack(), kResourceMusic_80020001);
+ sound->playMusic(getScene()->getResourcePack(), (int)kResourceMusic_80020001);
getWorld()->musicCurrentResourceId = 1;
diff --git a/engines/asylum/system/sound.cpp b/engines/asylum/system/sound.cpp
index 97cb7c17c5..822a42dbc4 100644
--- a/engines/asylum/system/sound.cpp
+++ b/engines/asylum/system/sound.cpp
@@ -133,7 +133,7 @@ bool Sound::addToSoundBuffer(ResourceId resourceId) {
if (exists < 0) {
SoundBufferItem sound;
sound.resourceId = resourceId;
- sound.handle = _soundHandle;
+ sound.handle = _soundHandle;
_soundBuffer.push_back(sound);
}
@@ -141,7 +141,7 @@ bool Sound::addToSoundBuffer(ResourceId resourceId) {
}
void Sound::removeFromSoundBuffer(ResourceId resourceId) {
- int32 pos = getBufferPosition(resourceId);
+ int32 pos = getBufferPosition(resourceId);
if (pos >= 0) {
_soundBuffer.remove_at(pos);
@@ -161,9 +161,9 @@ bool Sound::isPlaying(ResourceId resourceId) {
SoundBufferItem snd = _soundBuffer[pos];
if (_mixer->isSoundHandleActive(snd.handle)) {
return true;
- } else {
- removeFromSoundBuffer(resourceId);
- }
+ } else {
+ removeFromSoundBuffer(resourceId);
+ }
}
return false;
@@ -198,7 +198,7 @@ void Sound::playSound(ResourcePack *pack, ResourceId resourceId, bool looping, i
} else {
ResourceEntry *ent = _soundPack->getResource(resourceId);
playSoundData(Audio::Mixer::kSFXSoundType, &snd.handle, ent->data, ent->size, looping, volume, panning);
- addToSoundBuffer(resourceId);
+ addToSoundBuffer(resourceId);
}
}
@@ -213,7 +213,7 @@ void Sound::playSound(ResourceId resourceId, bool looping, int32 volume, int32 p
} else {
ResourceEntry *ent = _soundPack->getResource(resourceId);
playSound(ent, looping, volume, panning);
- addToSoundBuffer(resourceId);
+ addToSoundBuffer(resourceId);
}
}
}
diff --git a/engines/asylum/system/sound.h b/engines/asylum/system/sound.h
index ecd5cdb885..4ac3cfda74 100644
--- a/engines/asylum/system/sound.h
+++ b/engines/asylum/system/sound.h
@@ -89,7 +89,7 @@ public:
void playSound(ResourcePack *pack, ResourceId resourceId, int32 volume, bool looping = false, int32 panning = 0, bool overwrite = false);
void playSound(ResourcePack *pack, ResourceId resourceId, bool looping, int32 volume, int32 panning);
void playSound(ResourceEntry *resource, bool looping, int32 volume, int32 panning);
- void playSound(ResourceId resourceId, bool looping, int32 volume, int32 panning, bool fromBuffer = false);
+ void playSound(ResourceId resourceId, bool looping = false, int32 volume = Config.sfxVolume, int32 panning = 0, bool fromBuffer = false);
void stopSound(ResourceId resourceId);
void stopSound();
Commit: 7170f10f7b3af4ad1e9f016f8e36aeaee62e184a
https://github.com/scummvm/scummvm/commit/7170f10f7b3af4ad1e9f016f8e36aeaee62e184a
Author: Alex Bevilacqua (alexbevi at gmail.com)
Date: 2021-05-17T15:36:09+02:00
Commit Message:
ASYLUM: even more GCC warnings silenced
- shadow declarations of x/y in actor class
- suggest parentheses around arithmetic in operand of â|â
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@483 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/resources/actor.cpp
engines/asylum/resources/actor.h
engines/asylum/views/scene.cpp
diff --git a/engines/asylum/resources/actor.cpp b/engines/asylum/resources/actor.cpp
index 6ed4d1b86b..d3980d6105 100644
--- a/engines/asylum/resources/actor.cpp
+++ b/engines/asylum/resources/actor.cpp
@@ -720,12 +720,12 @@ void Actor::setRawResources(uint8 *data) {
// Unknown methods
//////////////////////////////////////////////////////////////////////////
-bool Actor::process(int32 x, int32 y) {
+bool Actor::process(int32 actorX, int32 actorY) {
error("[Actor::process] not implemented!");
}
-void Actor::processStatus(int32 x, int32 y, bool doSpeech) {
- if (process(x, y)) {
+void Actor::processStatus(int32 actorX, int32 actorY, bool doSpeech) {
+ if (process(actorX, actorY)) {
if (_status <= kActorStatus11)
updateStatus(kActorStatus2);
else
diff --git a/engines/asylum/resources/actor.h b/engines/asylum/resources/actor.h
index 6f1c7ddcda..6c9f4e3f25 100644
--- a/engines/asylum/resources/actor.h
+++ b/engines/asylum/resources/actor.h
@@ -202,8 +202,8 @@ public:
void setRawResources(uint8* data);
// Unknown methods
- bool process(int32 x, int32 y);
- void processStatus(int32 x, int32 y, bool doSpeech);
+ bool process(int32 actorX, int32 actorY);
+ void processStatus(int32 actorX, int32 actorY, bool doSpeech);
void process_401830(int32 field980, int32 actionAreaId, int32 field978, int field98C, int32 field990, int32 field974, int32 param8, int32 param9);
bool process_408B20(Common::Point *point, ActorDirection direction, int count, bool hasDelta);
void process_41BC00(int32 reactionIndex, int32 numberValue01Add);
diff --git a/engines/asylum/views/scene.cpp b/engines/asylum/views/scene.cpp
index 957ddc9cc5..ace7a0d53f 100644
--- a/engines/asylum/views/scene.cpp
+++ b/engines/asylum/views/scene.cpp
@@ -1147,7 +1147,7 @@ void Scene::processUpdateList() {
// Adjust barrier flags
if (BYTE1(barrier->flags) & kBarrierFlag80 || intersects) {
if (BYTE1(barrier->flags) & kBarrierFlag20)
- barrier->flags = BYTE1(barrier->flags) & 0xBF | kBarrierFlag80;
+ barrier->flags = (BYTE1(barrier->flags) & 0xBF) | kBarrierFlag80;
} else {
if (BYTE1(barrier->flags) & kBarrierFlag20) {
barrier->flags = BYTE1(barrier->flags) | kBarrierFlag40;
Commit: 66b12b324fa278b2dd39a12eb00be6bbd86e4da4
https://github.com/scummvm/scummvm/commit/66b12b324fa278b2dd39a12eb00be6bbd86e4da4
Author: Alex Bevilacqua (alexbevi at gmail.com)
Date: 2021-05-17T15:36:09+02:00
Commit Message:
ASYLUM: add missing ADParams initializers
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@484 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/detection.cpp
diff --git a/engines/asylum/detection.cpp b/engines/asylum/detection.cpp
index 27b04c88e5..b08b778f14 100644
--- a/engines/asylum/detection.cpp
+++ b/engines/asylum/detection.cpp
@@ -109,13 +109,24 @@ static const ADFileBasedFallback fileBasedFallback[] = {
static const ADParams detectionParams = {
(const byte *)Asylum::gameDescriptions,
sizeof(ADGameDescription),
- 0, // number of md5 bytes
+ // number of md5 bytes
+ 0,
+ // List of all engine targets
asylumGames,
- 0, // no obsolete targets data
+ // no obsolete targets data
+ 0,
+ // Name of single gameid (optional)
"asylum",
- Asylum::fileBasedFallback, // file-based detection data to enable not yet known versions to start
+ // file-based detection data to enable not yet known versions to start
+ Asylum::fileBasedFallback,
+ // Flags
kADFlagPrintWarningOnFileBasedFallback,
- Common::GUIO_NONE
+ // Additional GUI options (for every game}
+ Common::GUIO_NONE,
+ // Maximum directory depth
+ 1,
+ // List of directory globs
+ 0
};
class AsylumMetaEngine : public AdvancedMetaEngine {
Commit: 0eb39da8842ad35402b0a68594b7ac82d3274130
https://github.com/scummvm/scummvm/commit/0eb39da8842ad35402b0a68594b7ac82d3274130
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:09+02:00
Commit Message:
ASYLUM: Enhance Debug console
- Add actors & objects debug commands for showing Actor and Object info (only name & id for now)
- Add ls command to list the engine files
- Add option to show only set/unset flags
- Add option to show action per index
- Add better help output
- Check validity of video index in video command
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@485 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/console.cpp
engines/asylum/console.h
engines/asylum/resources/actionarea.cpp
engines/asylum/resources/actionarea.h
engines/asylum/resources/actor.cpp
engines/asylum/resources/actor.h
engines/asylum/resources/barrier.cpp
engines/asylum/resources/barrier.h
engines/asylum/resources/worldstats.cpp
engines/asylum/system/video.cpp
engines/asylum/system/video.h
diff --git a/engines/asylum/console.cpp b/engines/asylum/console.cpp
index 927c906890..d13fdb9e2a 100644
--- a/engines/asylum/console.cpp
+++ b/engines/asylum/console.cpp
@@ -39,100 +39,232 @@ extern int32 g_debugPolygons;
extern int32 g_debugBarriers;
extern int32 g_debugScrolling;
-Console::Console(AsylumEngine *vm) {
- _vm = vm;
-
- DCmd_Register("video", WRAP_METHOD(Console, cmdPlayVideo));
- DCmd_Register("script", WRAP_METHOD(Console, cmdRunScript));
- DCmd_Register("scene", WRAP_METHOD(Console, cmdChangeScene));
- DCmd_Register("flags", WRAP_METHOD(Console, cmdShowFlags));
- DCmd_Register("toggle_flag", WRAP_METHOD(Console, cmdToggleFlag));
- DCmd_Register("dump_action", WRAP_METHOD(Console, cmdDumpActionArea));
-
- DVar_Register("showpolygons", &g_debugPolygons, DVAR_INT, 0);
- DVar_Register("showbarriers", &g_debugBarriers, DVAR_INT, 0);
+Console::Console(AsylumEngine *engine) : _vm(engine) {
+ // Commands
+ DCmd_Register("help", WRAP_METHOD(Console, cmdHelp));
+
+ DCmd_Register("ls", WRAP_METHOD(Console, cmdListFiles));
+
+ DCmd_Register("actions", WRAP_METHOD(Console, cmdListActions));
+ DCmd_Register("actors", WRAP_METHOD(Console, cmdListActors));
+ DCmd_Register("flags", WRAP_METHOD(Console, cmdListFlags));
+ DCmd_Register("objects", WRAP_METHOD(Console, cmdListObjects));
+
+ DCmd_Register("video", WRAP_METHOD(Console, cmdPlayVideo));
+ DCmd_Register("script", WRAP_METHOD(Console, cmdRunScript));
+ DCmd_Register("scene", WRAP_METHOD(Console, cmdChangeScene));
+
+ DCmd_Register("toggle_flag", WRAP_METHOD(Console, cmdToggleFlag));
+
+ // Variables
+ DVar_Register("show_polygons", &g_debugPolygons, DVAR_INT, 0);
+ DVar_Register("show_objects", &g_debugBarriers, DVAR_INT, 0);
DVar_Register("use_scrolling", &g_debugScrolling, DVAR_INT, 0);
}
Console::~Console() {
DebugMan.clearAllDebugChannels();
+
+ // Zero passed pointers
+ _vm = NULL;
+}
+
+//////////////////////////////////////////////////////////////////////////
+// Help
+//////////////////////////////////////////////////////////////////////////
+bool Console::cmdHelp(int, const char **) {
+ DebugPrintf("Debug flags\n");
+ DebugPrintf("-----------\n");
+ DebugPrintf(" debugflag_list - Lists the available debug flags and their status\n");
+ DebugPrintf(" debugflag_enable - Enables a debug flag\n");
+ DebugPrintf(" debugflag_disable - Disables a debug flag\n");
+ DebugPrintf(" show_polygons - Show polygons\n");
+ DebugPrintf(" show_barriers - Show objects\n");
+ DebugPrintf(" use_scrolling - Use scrolling\n");
+ DebugPrintf("\n");
+ DebugPrintf("Commands\n");
+ DebugPrintf("--------\n");
+ DebugPrintf(" ls - list engine files\n");
+ DebugPrintf("\n");
+ DebugPrintf(" actors - show actors information\n");
+ DebugPrintf(" action - show action information\n");
+ DebugPrintf(" flags - show flags\n");
+ DebugPrintf(" objects - show objects information\n");
+ DebugPrintf("\n");
+ DebugPrintf(" video - play a video\n");
+ DebugPrintf(" script - run a script\n");
+ DebugPrintf(" scene - change the scene\n");
+ DebugPrintf("\n");
+ DebugPrintf(" toggle_flag - toggle a flag\n");
+ DebugPrintf("\n");
+
+ return true;
+}
+
+//////////////////////////////////////////////////////////////////////////
+// List commands
+//////////////////////////////////////////////////////////////////////////
+bool Console::cmdListFiles(int argc, const char **argv) {
+ if (argc != 2) {
+ DebugPrintf("Syntax: %s <filter> (use * for all)\n", argv[0]);
+ return true;
+ }
+
+ Common::String filter(const_cast<char *>(argv[1]));
+
+ Common::ArchiveMemberList list;
+ int count = SearchMan.listMatchingMembers(list, filter);
+
+ DebugPrintf("Number of matches: %d\n", count);
+ for (Common::ArchiveMemberList::iterator it = list.begin(); it != list.end(); ++it)
+ DebugPrintf(" %s\n", (*it)->getName().c_str());
+
+ return true;
}
-bool Console::cmdDumpActionArea(int32 argc, const char **argv) {
+bool Console::cmdListActions(int32 argc, const char **argv) {
+ if (argc != 1 && argc != 2) {
+ DebugPrintf("Syntax: %s <index> (use nothing for all)\n", argv[0]);
+ return true;
+ }
+
+ if (argc == 1) {
+ for (uint32 i = 0; i < getWorld()->actions.size(); i++)
+ DebugPrintf("%s\n", getWorld()->actions[i]->toString().c_str());
- if (argc == 2) {
- // TODO Get an action area by index/id
} else {
- for (int32 i = 0; i < _vm->scene()->worldstats()->numActions; i++) {
- ActionArea *a = _vm->scene()->worldstats()->actions[i];
- printActionAreaStats(a);
+ int index = atoi(argv[1]);
+ int maxIndex = getWorld()->actions.size() - 1;
+
+ if (index < 0 || index > maxIndex) {
+ DebugPrintf("[error] index should be between 0 and %d\n", maxIndex);
+ return true;
}
+
+ DebugPrintf("%s\n", getWorld()->actions[index]->toString().c_str());
}
return true;
}
-void Console::printActionAreaStats(ActionArea *a) {
- DebugPrintf("id[%d] name[%s] field01[%d] field02[%d] field40[%d] field44[%d] flags[%d] \n"
- "scriptIndex[%d] actionListIdx2[%d] actionType[%d] field_7C[%d] polyIdx[%d]\n"
- "field_84[%d] field_88[%d] soundResourceId[%d] field_90[%d] paletteValue[%d] volume[%d]\n\n",
- a->id,
- a->name,
- a->field01,
- a->field02,
- a->field_40,
- a->field_44,
- a->flags,
- a->scriptIndex,
- a->actionListIdx2,
- a->actionType,
- //a->flagNums[10],
- a->field_7C,
- a->polyIdx,
- a->field_84,
- a->field_88,
- a->soundResourceId,
- a->field_90,
- a->paletteValue,
- //a->array[5],
- a->volume);
+bool Console::cmdListActors(int32 argc, const char **argv) {
+ if (argc != 1 && argc != 2) {
+ DebugPrintf("Syntax: %s <index> (use nothing for all)\n", argv[0]);
+ return true;
+ }
+
+ if (argc == 1) {
+ for (uint32 i = 0; i < getWorld()->actors.size(); i++)
+ DebugPrintf("%s\n", getWorld()->actors[i]->toString().c_str());
+
+ } else {
+ int index = atoi(argv[1]);
+ int maxIndex = getWorld()->actors.size() - 1;
+
+ if (index < 0 || index > maxIndex) {
+ DebugPrintf("[error] index should be between 0 and %d\n", maxIndex);
+ return true;
+ }
+
+ DebugPrintf("%s\n", getWorld()->actors[index]->toString().c_str());
+ }
+
+ return true;
}
-bool Console::cmdShowFlags(int32 argc, const char **argv) {
- for (int32 i = 0; i < 1512; i++) {
- if (_vm->isGameFlagSet((GameFlag)i)) {
- DebugPrintf("Game Flag %d is Active\n", i);
+bool Console::cmdListFlags(int32 argc, const char **argv) {
+ if (argc != 1 && argc != 2) {
+ DebugPrintf("Syntax: %s <type> (nothing: all - 1: show set flags - 0: show unset flags)\n", argv[0]);
+ return true;
+ }
+
+ // Show all flags
+ if (argc == 1) {
+ for (int32 i = 0; i < 1512; i++) {
+ DebugPrintf("%04d: %d ", i, _vm->isGameFlagSet((GameFlag)i));
+
+ if ((i + 1) % 10 == 0)
+ DebugPrintf("\n");
+ }
+ DebugPrintf("\n");
+ } else {
+ bool type = atoi(argv[1]);
+
+ if (type != 0 && type != 1) {
+ DebugPrintf("Syntax: %s <type> (nothing: all - 1: show set flags - 0: show unset flags)\n", argv[0]);
+ return true;
+ }
+
+ // Show only set/unset flags
+ int count = 0;
+ for (int32 i = 0; i < 1512; i++) {
+ if (_vm->isGameFlagSet((GameFlag)i) == type) {
+ DebugPrintf("%04d: %d ", i, _vm->isGameFlagSet((GameFlag)i));
+ ++count;
+ }
+
+ if ((count + 1) % 10 == 0)
+ DebugPrintf("\n");
}
+ DebugPrintf("\n\n%s flags: %d\n", (type ? "Set" : "Unset"), count);
}
return true;
}
-bool Console::cmdToggleFlag(int32 argc, const char **argv) {
- if (argc != 2 || atoi(argv[1]) > 1512 || atoi(argv[1]) < 0) {
- DebugPrintf("Enter a value between 0 and 1512\n");
+bool Console::cmdListObjects(int32 argc, const char **argv) {
+ if (argc != 1 && argc != 2) {
+ DebugPrintf("Syntax: %s <index> (use nothing for all)\n", argv[0]);
return true;
}
- _vm->toggleGameFlag((GameFlag)atoi(argv[1]));
- DebugPrintf("Flag %d == %d\n", atoi(argv[1]), _vm->isGameFlagSet((GameFlag)atoi(argv[1])));
+
+ if (argc == 1) {
+ for (uint32 i = 0; i < getWorld()->barriers.size(); i++)
+ DebugPrintf("%s\n", getWorld()->barriers[i]->toString().c_str());
+
+ } else {
+ int index = atoi(argv[1]);
+ int maxIndex = getWorld()->barriers.size() - 1;
+
+ if (index < 0 || index > maxIndex) {
+ DebugPrintf("[error] index should be between 0 and %d\n", maxIndex);
+ return true;
+ }
+
+ DebugPrintf("%s\n", getWorld()->barriers[index]->toString().c_str());
+ }
return true;
}
+//////////////////////////////////////////////////////////////////////////
+// Video / Scene / Script commands
+//////////////////////////////////////////////////////////////////////////
bool Console::cmdPlayVideo(int32 argc, const char **argv) {
if (argc != 2) {
- DebugPrintf("Usage %s <video number>\n", argv[0]);
+ DebugPrintf("Syntax: %s <video number>\n", argv[0]);
return true;
}
- _vm->scene()->actions()->setDelayedVideoIndex(atoi(argv[1]));
+ int index = atoi(argv[1]);
+
+ // Check if the video exists
+ char filename[20];
+ sprintf(filename, "mov%03d.smk", index);
+ if (!SearchMan.hasFile(filename)) {
+ DebugPrintf("[Error] Movie %d does not exists\n", index);
+ return true;
+ }
+
+ getScreen()->clearScreen();
+ getScene()->actions()->setDelayedVideoIndex(index);
return false;
}
bool Console::cmdRunScript(int32 argc, const char **argv) {
if (argc != 2) {
- DebugPrintf("Usage %s <script number>\n", argv[0]);
+ DebugPrintf("Syntax: %s <script number>\n", argv[0]);
return true;
}
// FIXME push the script index into the script queue
@@ -143,12 +275,12 @@ bool Console::cmdRunScript(int32 argc, const char **argv) {
bool Console::cmdChangeScene(int32 argc, const char **argv) {
if (argc != 2) {
- DebugPrintf("Usage %s <scene number>\n", argv[0]);
+ DebugPrintf("Syntax: %s <scene number>\n", argv[0]);
return true;
}
if (atoi(argv[1]) - 4 < 1 || atoi(argv[1]) - 4 >= 15) {
- DebugPrintf("Attempt to SetupStartingInfo(%d); Invalid world\n", atoi(argv[1]));
+ DebugPrintf("[Error] Invalid world: %d\n", atoi(argv[1]));
return true;
}
@@ -160,5 +292,19 @@ bool Console::cmdChangeScene(int32 argc, const char **argv) {
return false;
}
+//////////////////////////////////////////////////////////////////////////
+// Flags commands
+//////////////////////////////////////////////////////////////////////////
+bool Console::cmdToggleFlag(int32 argc, const char **argv) {
+ if (argc != 2 || atoi(argv[1]) > 1512 || atoi(argv[1]) < 0) {
+ DebugPrintf("Syntax: <value> between 0 and 1512\n");
+ return true;
+ }
+
+ _vm->toggleGameFlag((GameFlag)atoi(argv[1]));
+ DebugPrintf("Flag %d == %d\n", atoi(argv[1]), _vm->isGameFlagSet((GameFlag)atoi(argv[1])));
+
+ return true;
+}
} // End of namespace Asulym
diff --git a/engines/asylum/console.h b/engines/asylum/console.h
index df91e80758..421b88a376 100644
--- a/engines/asylum/console.h
+++ b/engines/asylum/console.h
@@ -55,17 +55,22 @@ public:
virtual ~Console(void);
private:
+ AsylumEngine *_vm;
+
+ bool cmdHelp(int argc, const char **argv);
+
+ bool cmdListFiles(int argc, const char **argv);
+
+ bool cmdListActions(int32 argc, const char **argv);
+ bool cmdListActors(int32 argc, const char **argv);
+ bool cmdListFlags(int32 argc, const char **argv);
+ bool cmdListObjects(int32 argc, const char **argv);
+
bool cmdPlayVideo(int32 argc, const char **argv);
bool cmdRunScript(int32 argc, const char **argv);
bool cmdChangeScene(int32 argc, const char **argv);
- bool cmdShowFlags(int32 argc, const char **argv);
- bool cmdToggleFlag(int32 argc, const char **argv);
- bool cmdDumpActionArea(int32 argc, const char **argv);
-
- void printActionAreaStats(ActionArea *a);
-private:
- AsylumEngine *_vm;
+ bool cmdToggleFlag(int32 argc, const char **argv);
};
} // End of namespace Asylum
diff --git a/engines/asylum/resources/actionarea.cpp b/engines/asylum/resources/actionarea.cpp
index 7c542c199a..a4674be1b6 100644
--- a/engines/asylum/resources/actionarea.cpp
+++ b/engines/asylum/resources/actionarea.cpp
@@ -27,13 +27,16 @@
namespace Asylum {
-ActionArea::ActionArea() {
- // TODO Auto-generated constructor stub
+Common::String ActionArea::toString() {
+ Common::String output;
-}
+ output += Common::String::format("Action %d: %s\n", id, name);
+ output += Common::String::format(" flags=%d scriptIndex=%d scriptIndex2=%d type=%d\n", flags, scriptIndex, actionType, polyIdx);
+ output += Common::String::format(" sound=%d polygon=%d palette=%d volume=%d\n", soundResourceId, scriptIndex2, paletteValue, volume);
+ output += Common::String::format(" field01=%d field02=%d field40=%d field44=%d\n", field01, field02, field_40, field_44);
+ output += Common::String::format(" field7C=%d field84=%d field88=%d field90=%d\n", field_7C, field_84, field_88, field_90);
-ActionArea::~ActionArea() {
- // TODO Auto-generated destructor stub
+ return output;
}
} // end of namespace Asylum
diff --git a/engines/asylum/resources/actionarea.h b/engines/asylum/resources/actionarea.h
index cf92af8eaf..85a9a2c490 100644
--- a/engines/asylum/resources/actionarea.h
+++ b/engines/asylum/resources/actionarea.h
@@ -34,8 +34,8 @@ namespace Asylum {
class ActionArea {
public:
- ActionArea();
- virtual ~ActionArea();
+ ActionArea() {}
+ virtual ~ActionArea() {}
char name[52];
int32 id;
@@ -45,7 +45,7 @@ public:
int32 field_44;
int32 flags;
int32 scriptIndex;
- int32 actionListIdx2;
+ int32 scriptIndex2;
int32 actionType; // aka flags2: 0-none, 1-findwhat, 2-talk, 3-findwhat??, 4-grab
int32 flagNums[10];
int32 field_7C;
@@ -58,6 +58,8 @@ public:
int32 array[5];
int32 volume;
+ Common::String toString();
+
}; // end of class ActionArea
} // end of namespace Asylum
diff --git a/engines/asylum/resources/actor.cpp b/engines/asylum/resources/actor.cpp
index d3980d6105..65be886067 100644
--- a/engines/asylum/resources/actor.cpp
+++ b/engines/asylum/resources/actor.cpp
@@ -707,6 +707,14 @@ void Actor::stopSound() {
getSound()->stopSound(_soundResourceId);
}
+Common::String Actor::toString() {
+ Common::String output;
+
+ output += Common::String::format("Actor %d: %s\n", _index, _name);
+
+ return output;
+}
+
void Actor::setRawResources(uint8 *data) {
byte *dataPtr = data;
@@ -918,7 +926,7 @@ void Actor::updateFinish() {
ActionArea *area = getWorld()->actions[areaIndex];
ActionArea *actorArea = getWorld()->actions[_actionIdx3];
if (!getScene()->actions()->isProcessingSkipped()) {
- getScene()->actions()->queueScript(actorArea->actionListIdx2, _index);
+ getScene()->actions()->queueScript(actorArea->scriptIndex2, _index);
getScene()->actions()->queueScript(area->scriptIndex, _index);
}
diff --git a/engines/asylum/resources/actor.h b/engines/asylum/resources/actor.h
index 6c9f4e3f25..6bfa4d7404 100644
--- a/engines/asylum/resources/actor.h
+++ b/engines/asylum/resources/actor.h
@@ -188,11 +188,19 @@ public:
*/
void stopSound();
+ /**
+ * Convert this object into a string representation.
+ *
+ * @return A string representation of this object.
+ */
+ Common::String toString();
+
/**
* Clears actor data fields (TODO what are those fields?)
*/
void clearFields() { memset(&_field_970, 0, 52); }
+
/**
* TEMPORARY: Initialize the 500 byte resource index from the scene
* file (at offset 0xA73B6).
diff --git a/engines/asylum/resources/barrier.cpp b/engines/asylum/resources/barrier.cpp
index 297a7177f8..0808ba0b14 100644
--- a/engines/asylum/resources/barrier.cpp
+++ b/engines/asylum/resources/barrier.cpp
@@ -445,4 +445,12 @@ bool Barrier::checkFlags() {
return (flags & kBarrierFlagEnabled) && (flags & kBarrierFlag8 || flags & kBarrierFlag10000);
}
+Common::String Barrier::toString() {
+ Common::String output;
+
+ output += Common::String::format("Barrier %d: %s\n", _id, _name);
+
+ return output;
+}
+
} // end of namespace Asylum
diff --git a/engines/asylum/resources/barrier.h b/engines/asylum/resources/barrier.h
index 8bce7521f0..3188c71db0 100644
--- a/engines/asylum/resources/barrier.h
+++ b/engines/asylum/resources/barrier.h
@@ -139,6 +139,13 @@ public:
*/
bool checkFlags();
+ /**
+ * Convert this object into a string representation.
+ *
+ * @return A string representation of this object.
+ */
+ Common::String toString();
+
private:
AsylumEngine *_vm;
diff --git a/engines/asylum/resources/worldstats.cpp b/engines/asylum/resources/worldstats.cpp
index b96f7f5f7d..e70c66bd91 100644
--- a/engines/asylum/resources/worldstats.cpp
+++ b/engines/asylum/resources/worldstats.cpp
@@ -214,7 +214,7 @@ void WorldStats::load(Common::SeekableReadStream *stream) {
action->field_44 = stream->readSint32LE();
action->flags = stream->readSint32LE();
action->scriptIndex = stream->readSint32LE();
- action->actionListIdx2 = stream->readSint32LE();
+ action->scriptIndex2 = stream->readSint32LE();
action->actionType = stream->readSint32LE();
for (int32 aa1 = 0; aa1 < 10; aa1++)
diff --git a/engines/asylum/system/video.cpp b/engines/asylum/system/video.cpp
index 1ff6aac290..6f7b5b540e 100644
--- a/engines/asylum/system/video.cpp
+++ b/engines/asylum/system/video.cpp
@@ -52,52 +52,52 @@ Video::~Video() {
delete _text;
}
-bool Video::playVideo(int32 videoNumber, bool showSubtitles) {
- bool lastMouseState = false;
+void Video::playVideo(int32 videoNumber, bool showSubtitles) {
char filename[20];
-
sprintf(filename, "mov%03d.smk", videoNumber);
- bool result = _smkDecoder->loadFile(filename);
+ if (!_smkDecoder->loadFile(filename)) {
+ _smkDecoder->close();
- lastMouseState = g_system->showMouse(false);
- if (result) {
- _skipVideo = false;
+ error("[Video::playVideo] Invalid video index (%d)", videoNumber);
+ }
- if (showSubtitles)
- loadSubtitles(videoNumber);
+ bool lastMouseState = g_system->showMouse(false);
+ _skipVideo = false;
- uint16 x = (g_system->getWidth() - _smkDecoder->getWidth()) / 2;
- uint16 y = (g_system->getHeight() - _smkDecoder->getHeight()) / 2;
+ if (showSubtitles)
+ loadSubtitles(videoNumber);
- while (!_smkDecoder->endOfVideo() && !_skipVideo) {
- processVideoEvents();
- if (_smkDecoder->needsUpdate()) {
- Graphics::Surface *frame = _smkDecoder->decodeNextFrame();
+ uint16 x = (g_system->getWidth() - _smkDecoder->getWidth()) / 2;
+ uint16 y = (g_system->getHeight() - _smkDecoder->getHeight()) / 2;
- if (frame) {
- g_system->copyRectToScreen((byte *)frame->pixels, frame->pitch, x, y, frame->w, frame->h);
+ while (!_smkDecoder->endOfVideo() && !_skipVideo) {
+ processVideoEvents();
+ if (_smkDecoder->needsUpdate()) {
+ Graphics::Surface *frame = _smkDecoder->decodeNextFrame();
- if(showSubtitles) {
- Graphics::Surface *screen = g_system->lockScreen();
- performPostProcessing((byte *)screen->pixels);
- g_system->unlockScreen();
- }
+ if (frame) {
+ g_system->copyRectToScreen((byte *)frame->pixels, frame->pitch, x, y, frame->w, frame->h);
- if (_smkDecoder->hasDirtyPalette())
- _smkDecoder->setSystemPalette();
-
- g_system->updateScreen();
+ if(showSubtitles) {
+ Graphics::Surface *screen = g_system->lockScreen();
+ performPostProcessing((byte *)screen->pixels);
+ g_system->unlockScreen();
}
+
+ if (_smkDecoder->hasDirtyPalette())
+ _smkDecoder->setSystemPalette();
+
+ g_system->updateScreen();
}
- g_system->delayMillis(10);
}
+ g_system->delayMillis(10);
}
+
+
_smkDecoder->close();
_subtitles.clear();
g_system->showMouse(lastMouseState);
-
- return result;
}
void Video::performPostProcessing(byte *screen) {
diff --git a/engines/asylum/system/video.h b/engines/asylum/system/video.h
index 0c007254ba..7c9bc1092e 100644
--- a/engines/asylum/system/video.h
+++ b/engines/asylum/system/video.h
@@ -56,7 +56,7 @@ public:
Video(Audio::Mixer *mixer);
virtual ~Video();
- bool playVideo(int32 videoNumber, bool showSubtitles);
+ void playVideo(int32 videoNumber, bool showSubtitles);
private:
void performPostProcessing(byte *screen);
Commit: ce330b1a450e19708f5048410dde6c6053a5fe95
https://github.com/scummvm/scummvm/commit/ce330b1a450e19708f5048410dde6c6053a5fe95
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:09+02:00
Commit Message:
ASYLUM: Rename Barrier to Object
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@486 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
A engines/asylum/resources/object.cpp
A engines/asylum/resources/object.h
R engines/asylum/resources/barrier.cpp
R engines/asylum/resources/barrier.h
engines/asylum/asylum.cpp
engines/asylum/console.cpp
engines/asylum/console.h
engines/asylum/module.mk
engines/asylum/resources/actionlist.cpp
engines/asylum/resources/actionlist.h
engines/asylum/resources/actor.cpp
engines/asylum/resources/actor.h
engines/asylum/resources/encounters.cpp
engines/asylum/resources/encounters.h
engines/asylum/resources/worldstats.cpp
engines/asylum/resources/worldstats.h
engines/asylum/shared.h
engines/asylum/views/scene.cpp
engines/asylum/views/scene.h
diff --git a/engines/asylum/asylum.cpp b/engines/asylum/asylum.cpp
index 16a9d452c1..9f9e0a9b26 100644
--- a/engines/asylum/asylum.cpp
+++ b/engines/asylum/asylum.cpp
@@ -65,7 +65,7 @@ AsylumEngine::AsylumEngine(OSystem *system, const ADGameDescription *gd) : Engin
DebugMan.addDebugChannel(kDebugLevelSound, "Sound", "Sound debugging");
DebugMan.addDebugChannel(kDebugLevelSavegame, "Savegame", "Saving & restoring game debugging");
DebugMan.addDebugChannel(kDebugLevelScene, "Scene", "Scene process and draw debugging");
- DebugMan.addDebugChannel(kDebugLevelBarriers, "Barriers", "Debug Barrier Objects");
+ DebugMan.addDebugChannel(kDebugLevelObjects, "Objects", "Debug Object Objects");
// Initialize random number source
g_eventRec.registerRandomSource(_rnd, "asylum");
diff --git a/engines/asylum/console.cpp b/engines/asylum/console.cpp
index d13fdb9e2a..97acf75a2c 100644
--- a/engines/asylum/console.cpp
+++ b/engines/asylum/console.cpp
@@ -36,7 +36,7 @@
namespace Asylum {
extern int32 g_debugPolygons;
-extern int32 g_debugBarriers;
+extern int32 g_debugObjects;
extern int32 g_debugScrolling;
Console::Console(AsylumEngine *engine) : _vm(engine) {
@@ -58,7 +58,7 @@ Console::Console(AsylumEngine *engine) : _vm(engine) {
// Variables
DVar_Register("show_polygons", &g_debugPolygons, DVAR_INT, 0);
- DVar_Register("show_objects", &g_debugBarriers, DVAR_INT, 0);
+ DVar_Register("show_objects", &g_debugObjects, DVAR_INT, 0);
DVar_Register("use_scrolling", &g_debugScrolling, DVAR_INT, 0);
}
@@ -79,7 +79,7 @@ bool Console::cmdHelp(int, const char **) {
DebugPrintf(" debugflag_enable - Enables a debug flag\n");
DebugPrintf(" debugflag_disable - Disables a debug flag\n");
DebugPrintf(" show_polygons - Show polygons\n");
- DebugPrintf(" show_barriers - Show objects\n");
+ DebugPrintf(" show_objects - Show objects\n");
DebugPrintf(" use_scrolling - Use scrolling\n");
DebugPrintf("\n");
DebugPrintf("Commands\n");
@@ -219,19 +219,19 @@ bool Console::cmdListObjects(int32 argc, const char **argv) {
}
if (argc == 1) {
- for (uint32 i = 0; i < getWorld()->barriers.size(); i++)
- DebugPrintf("%s\n", getWorld()->barriers[i]->toString().c_str());
+ for (uint32 i = 0; i < getWorld()->objects.size(); i++)
+ DebugPrintf("%s\n", getWorld()->objects[i]->toString().c_str());
} else {
int index = atoi(argv[1]);
- int maxIndex = getWorld()->barriers.size() - 1;
+ int maxIndex = getWorld()->objects.size() - 1;
if (index < 0 || index > maxIndex) {
DebugPrintf("[error] index should be between 0 and %d\n", maxIndex);
return true;
}
- DebugPrintf("%s\n", getWorld()->barriers[index]->toString().c_str());
+ DebugPrintf("%s\n", getWorld()->objects[index]->toString().c_str());
}
return true;
diff --git a/engines/asylum/console.h b/engines/asylum/console.h
index 421b88a376..6c26ee40fb 100644
--- a/engines/asylum/console.h
+++ b/engines/asylum/console.h
@@ -42,7 +42,7 @@ enum kDebugLevels {
kDebugLevelSound = 1 << 6,
kDebugLevelSavegame = 1 << 7,
kDebugLevelScene = 1 << 8,
- kDebugLevelBarriers = 1 << 9,
+ kDebugLevelObjects = 1 << 9,
kDebugLevelActor = 1 << 10
};
diff --git a/engines/asylum/module.mk b/engines/asylum/module.mk
index bfd0b28593..a7501882a3 100644
--- a/engines/asylum/module.mk
+++ b/engines/asylum/module.mk
@@ -4,7 +4,7 @@ MODULE_OBJS := \
resources/actionarea.o \
resources/actionlist.o \
resources/actor.o \
- resources/barrier.o \
+ resources/object.o \
resources/encounters.o \
resources/polygons.o \
resources/worldstats.o \
diff --git a/engines/asylum/resources/actionlist.cpp b/engines/asylum/resources/actionlist.cpp
index dc24e9c6c3..ce0f181206 100644
--- a/engines/asylum/resources/actionlist.cpp
+++ b/engines/asylum/resources/actionlist.cpp
@@ -55,15 +55,15 @@ ActionList::ActionList(Common::SeekableReadStream *stream, Scene *scene) : _scen
ADD_OPCODE(SetSceneMotionStatus);
ADD_OPCODE(DisableActor);
ADD_OPCODE(EnableActor);
- ADD_OPCODE(EnableBarriers);
+ ADD_OPCODE(EnableObjects);
ADD_OPCODE(Return);
- ADD_OPCODE(RemoveBarrier);
+ ADD_OPCODE(RemoveObject);
ADD_OPCODE(JumpActorSpeech);
ADD_OPCODE(JumpAndSetDirection);
ADD_OPCODE(JumpIfActorCoordinates);
ADD_OPCODE(Nop);
ADD_OPCODE(ResetAnimation);
- ADD_OPCODE(DisableBarrier);
+ ADD_OPCODE(DisableObject);
ADD_OPCODE(JumpIfSoundPlayingAndPlaySound);
ADD_OPCODE(JumpIfActionFind);
ADD_OPCODE(SetActionFind);
@@ -86,7 +86,7 @@ ActionList::ActionList(Common::SeekableReadStream *stream, Scene *scene) : _scen
ADD_OPCODE(ChangeScene);
ADD_OPCODE(_unk2C_ActorSub);
ADD_OPCODE(PlayMovie);
- ADD_OPCODE(StopAllBarriersSounds);
+ ADD_OPCODE(StopAllObjectsSounds);
ADD_OPCODE(StopProcessing);
ADD_OPCODE(ResumeProcessing);
ADD_OPCODE(ResetSceneRect);
@@ -121,21 +121,21 @@ ActionList::ActionList(Common::SeekableReadStream *stream, Scene *scene) : _scen
ADD_OPCODE(JumpRandom);
ADD_OPCODE(ClearScreen);
ADD_OPCODE(Quit);
- ADD_OPCODE(JumpBarrierFrame);
+ ADD_OPCODE(JumpObjectFrame);
ADD_OPCODE(DeleteGraphics);
ADD_OPCODE(DeleteGraphics);
ADD_OPCODE(_unk54_SET_ACTIONLIST_6EC);
ADD_OPCODE(_unk55);
ADD_OPCODE(_unk56);
ADD_OPCODE(SetResourcePalette);
- ADD_OPCODE(SetBarrierFrameIdxFlaged);
+ ADD_OPCODE(SetObjectFrameIdxFlaged);
ADD_OPCODE(_unk59);
ADD_OPCODE(_unk5A);
ADD_OPCODE(_unk5B);
ADD_OPCODE(QueueScript);
ADD_OPCODE(_unk5D);
ADD_OPCODE(ClearActorFields);
- ADD_OPCODE(SetBarrierLastFrameIdx);
+ ADD_OPCODE(SetObjectLastFrameIdx);
ADD_OPCODE(_unk60_SET_OR_CLR_ACTIONAREA_FLAG);
ADD_OPCODE(_unk61);
ADD_OPCODE(ShowOptionsScreen);
@@ -345,10 +345,10 @@ IMPLEMENT_OPCODE(ShowCursor) {
//////////////////////////////////////////////////////////////////////////
// Opcode 0x07
IMPLEMENT_OPCODE(PlayAnimation) {
- Barrier *barrier = _scene->worldstats()->getBarrierById(cmd->param1);
+ Object *object = _scene->worldstats()->getObjectById(cmd->param1);
if (cmd->param2 == 2) {
- if (barrier->checkFlags())
+ if (object->checkFlags())
_lineIncrement = 1;
else
cmd->param2 = 1;
@@ -358,30 +358,30 @@ IMPLEMENT_OPCODE(PlayAnimation) {
// Update flags
if (cmd->param4) {
- barrier->flags &= ~kBarrierFlag10E38;
- barrier->flags |= kBarrierFlag20;
+ object->flags &= ~kObjectFlag10E38;
+ object->flags |= kObjectFlag20;
} else if (cmd->param3) {
- barrier->flags &= ~kBarrierFlag10E38;
- barrier->flags |= kBarrierFlag10000;
- } else if (barrier->flags & kBarrierFlag10000) {
- barrier->flags |= kBarrierFlag8;
- barrier->flags &= ~kBarrierFlag10000;
- } else if (!(barrier->flags & kBarrierFlag10E38)) {
- barrier->flags |= kBarrierFlag8;
+ object->flags &= ~kObjectFlag10E38;
+ object->flags |= kObjectFlag10000;
+ } else if (object->flags & kObjectFlag10000) {
+ object->flags |= kObjectFlag8;
+ object->flags &= ~kObjectFlag10000;
+ } else if (!(object->flags & kObjectFlag10E38)) {
+ object->flags |= kObjectFlag8;
}
- barrier->setNextFrame(barrier->flags);
+ object->setNextFrame(object->flags);
- if (barrier->getField688() == 1) {
- if (barrier->flags & kBarrierFlag4) {
- _scene->setGlobalX(barrier->x);
- _scene->setGlobalY(barrier->y);
+ if (object->getField688() == 1) {
+ if (object->flags & kObjectFlag4) {
+ _scene->setGlobalX(object->x);
+ _scene->setGlobalY(object->y);
} else {
- GraphicResource *res = new GraphicResource(_scene->getResourcePack(), barrier->getResourceId());
- GraphicFrame *frame = res->getFrame(barrier->getFrameIndex());
+ GraphicResource *res = new GraphicResource(_scene->getResourcePack(), object->getResourceId());
+ GraphicFrame *frame = res->getFrame(object->getFrameIndex());
- _scene->setGlobalX(frame->x + (frame->getWidth() >> 1) + barrier->x);
- _scene->setGlobalY(frame->y + (frame->getHeight() >> 1) + barrier->y);
+ _scene->setGlobalX(frame->x + (frame->getWidth() >> 1) + object->x);
+ _scene->setGlobalY(frame->y + (frame->getHeight() >> 1) + object->y);
delete res;
}
@@ -478,24 +478,24 @@ IMPLEMENT_OPCODE(EnableActor) {
//////////////////////////////////////////////////////////////////////////
// Opcode 0x0F
-IMPLEMENT_OPCODE(EnableBarriers) {
- Barrier *barrier = _scene->worldstats()->getBarrierById(cmd->param1);
+IMPLEMENT_OPCODE(EnableObjects) {
+ Object *object = _scene->worldstats()->getObjectById(cmd->param1);
if (!_currentScript->counter && _scene->worldstats()->numChapter != 13)
_scene->vm()->sound()->playSound(cmd->param3 ? kResourceSound_80120006 : kResourceSound_80120001, false, Config.sfxVolume, 0);
if (_currentScript->counter >= (3 * cmd->param2 - 1)) {
_currentScript->counter = 0;
- barrier->setField67C(0);
- enableBarrier(cmd, kBarrierEnableType2);
+ object->setField67C(0);
+ enableObject(cmd, kObjectEnableType2);
} else {
++_currentScript->counter;
if (cmd->param3) {
- barrier->setField67C(3 - _currentScript->counter / cmd->param2);
- enableBarrier(cmd, kBarrierEnableType1);
+ object->setField67C(3 - _currentScript->counter / cmd->param2);
+ enableObject(cmd, kObjectEnableType1);
} else {
- barrier->setField67C(_currentScript->counter / cmd->param2 + 1);
- enableBarrier(cmd, kBarrierEnableType0);
+ object->setField67C(_currentScript->counter / cmd->param2 + 1);
+ enableObject(cmd, kObjectEnableType0);
}
_lineIncrement = 1;
@@ -507,13 +507,13 @@ IMPLEMENT_OPCODE(EnableBarriers) {
//////////////////////////////////////////////////////////////////////////
// Opcode 0x11
-IMPLEMENT_OPCODE(RemoveBarrier) {
+IMPLEMENT_OPCODE(RemoveObject) {
if (!cmd->param1)
return;
- Barrier *barrier = _scene->worldstats()->getBarrierById(cmd->param1);
+ Object *object = _scene->worldstats()->getObjectById(cmd->param1);
- barrier->disableAndRemoveFromQueue();
+ object->disableAndRemoveFromQueue();
}
//////////////////////////////////////////////////////////////////////////
@@ -581,20 +581,20 @@ IMPLEMENT_OPCODE(Nop) {
//////////////////////////////////////////////////////////////////////////
// Opcode 0x16
IMPLEMENT_OPCODE(ResetAnimation) {
- Barrier *barrier = _scene->worldstats()->getBarrierById(cmd->param1);
+ Object *object = _scene->worldstats()->getObjectById(cmd->param1);
- if (barrier->flags & kBarrierFlag10000)
- barrier->setFrameIndex(barrier->getFrameCount() - 1);
+ if (object->flags & kObjectFlag10000)
+ object->setFrameIndex(object->getFrameCount() - 1);
else
- barrier->setFrameIndex(0);
+ object->setFrameIndex(0);
}
//////////////////////////////////////////////////////////////////////////
// Opcode 0x17
-IMPLEMENT_OPCODE(DisableBarrier) {
- Barrier *barrier = _scene->worldstats()->getBarrierById(cmd->param1);
+IMPLEMENT_OPCODE(DisableObject) {
+ Object *object = _scene->worldstats()->getObjectById(cmd->param1);
- barrier->disable();
+ object->disable();
}
//////////////////////////////////////////////////////////////////////////
@@ -897,10 +897,10 @@ IMPLEMENT_OPCODE(PlayMovie) {
//////////////////////////////////////////////////////////////////////////
// Opcode 0x2E
-IMPLEMENT_OPCODE(StopAllBarriersSounds) {
- Barrier *barrier = _scene->worldstats()->getBarrierById(cmd->param1);
+IMPLEMENT_OPCODE(StopAllObjectsSounds) {
+ Object *object = _scene->worldstats()->getObjectById(cmd->param1);
- barrier->stopAllSounds();
+ object->stopAllSounds();
}
//////////////////////////////////////////////////////////////////////////
@@ -1047,13 +1047,13 @@ IMPLEMENT_OPCODE(IncrementParam2) {
//////////////////////////////////////////////////////////////////////////
// Opcode 0x3D
IMPLEMENT_OPCODE(WaitUntilFramePlayed) {
- Barrier *barrier = _scene->worldstats()->getBarrierById(cmd->param1);
+ Object *object = _scene->worldstats()->getObjectById(cmd->param1);
int32 frameNum = cmd->param2;
if (frameNum == -1)
- frameNum = barrier->getFrameCount() - 1;
+ frameNum = object->getFrameCount() - 1;
- if ((int32)barrier->getFrameIndex() != frameNum) {
+ if ((int32)object->getFrameIndex() != frameNum) {
_lineIncrement = 1;
_waitCycle = true;
}
@@ -1299,8 +1299,8 @@ IMPLEMENT_OPCODE(_unk46) {
if (cmd->param5) {
_scene->getActor(cmd->param5)->updateStatus(kActorStatusEnabled);
} else if (cmd->param4 != cmd->param3 && cmd->param4) {
- _scene->worldstats()->getBarrierById(cmd->param3)->disable();
- _scene->worldstats()->getBarrierById(cmd->param4)->setNextFrame(_scene->worldstats()->getBarrierById(cmd->param4)->flags);
+ _scene->worldstats()->getObjectById(cmd->param3)->disable();
+ _scene->worldstats()->getObjectById(cmd->param4)->setNextFrame(_scene->worldstats()->getObjectById(cmd->param4)->flags);
}
_scene->vm()->clearGameFlag(kGameFlagScriptProcessing);
@@ -1319,10 +1319,10 @@ IMPLEMENT_OPCODE(_unk46) {
} else {
if (cmd->param4 != cmd->param3) {
if (cmd->param4)
- _scene->worldstats()->getBarrierById(cmd->param4)->disable();
+ _scene->worldstats()->getObjectById(cmd->param4)->disable();
if (cmd->param3)
- _scene->worldstats()->getBarrierById(cmd->param3)->setNextFrame(_scene->worldstats()->getBarrierById(cmd->param4)->flags);
+ _scene->worldstats()->getObjectById(cmd->param3)->setNextFrame(_scene->worldstats()->getObjectById(cmd->param4)->flags);
}
cmd->param6 = 1;
@@ -1448,28 +1448,28 @@ IMPLEMENT_OPCODE(Quit) {
//////////////////////////////////////////////////////////////////////////
// Opcode 0x51
-IMPLEMENT_OPCODE(JumpBarrierFrame) {
- Barrier *barrier = _scene->worldstats()->getBarrierById(cmd->param1);
+IMPLEMENT_OPCODE(JumpObjectFrame) {
+ Object *object = _scene->worldstats()->getObjectById(cmd->param1);
if (cmd->param2 == -1)
- cmd->param2 = barrier->getFrameCount() - 1;
+ cmd->param2 = object->getFrameCount() - 1;
if (cmd->param3) {
- if(barrier->getFrameIndex() == (uint32)cmd->param2)
+ if(object->getFrameIndex() == (uint32)cmd->param2)
return;
} else if (cmd->param4) {
- if (barrier->getFrameIndex() < (uint32)cmd->param2)
+ if (object->getFrameIndex() < (uint32)cmd->param2)
return;
} else if (cmd->param5) {
- if (barrier->getFrameIndex() > (uint32)cmd->param2)
+ if (object->getFrameIndex() > (uint32)cmd->param2)
return;
} else if (cmd->param6) {
- if (barrier->getFrameIndex() <= (uint32)cmd->param2)
+ if (object->getFrameIndex() <= (uint32)cmd->param2)
return;
} else if (cmd->param7) {
- if (barrier->getFrameIndex() >= (uint32)cmd->param2)
+ if (object->getFrameIndex() >= (uint32)cmd->param2)
return;
- } else if (!cmd->param8 || barrier->getFrameIndex() != (uint32)cmd->param2) {
+ } else if (!cmd->param8 || object->getFrameIndex() != (uint32)cmd->param2) {
return;
}
@@ -1586,29 +1586,29 @@ IMPLEMENT_OPCODE(SetResourcePalette) {
//////////////////////////////////////////////////////////////////////////
// Opcode 0x58
-IMPLEMENT_OPCODE(SetBarrierFrameIdxFlaged) {
- Barrier *barrier = _scene->worldstats()->getBarrierById(cmd->param1);
+IMPLEMENT_OPCODE(SetObjectFrameIdxFlaged) {
+ Object *object = _scene->worldstats()->getObjectById(cmd->param1);
if (cmd->param3)
- barrier->flags = 1 | barrier->flags;
+ object->flags = 1 | object->flags;
else
- barrier->flags &= ~kBarrierFlagEnabled;
+ object->flags &= ~kObjectFlagEnabled;
- barrier->setFrameIndex(cmd->param2);
+ object->setFrameIndex(cmd->param2);
}
//////////////////////////////////////////////////////////////////////////
// Opcode 0x59
IMPLEMENT_OPCODE(_unk59) {
- Barrier *barrier = _scene->worldstats()->getBarrierById(cmd->param1);
+ Object *object = _scene->worldstats()->getObjectById(cmd->param1);
if (cmd->param2) {
- barrier->flags |= kBarrierFlag40000;
+ object->flags |= kObjectFlag40000;
} else {
- barrier->flags &= ~kBarrierFlag10E38;
+ object->flags &= ~kObjectFlag10E38;
}
- if (cmd->param3 && (barrier->flags & kBarrierFlag10E38))
+ if (cmd->param3 && (object->flags & kObjectFlag10E38))
_lineIncrement = 1;
}
@@ -1623,12 +1623,12 @@ IMPLEMENT_OPCODE(_unk5A) {
IMPLEMENT_OPCODE(_unk5B) {
if (cmd->param2 >= 0 && cmd->param2 <= 3) {
if (cmd->param1) {
- Barrier *barrier = _scene->worldstats()->getBarrierById(cmd->param1);
+ Object *object = _scene->worldstats()->getObjectById(cmd->param1);
- barrier->setField67C(cmd->param2);
+ object->setField67C(cmd->param2);
- if (barrier->getField67C())
- barrier->setField67C(barrier->getField67C() + 3);
+ if (object->getField67C())
+ object->setField67C(object->getField67C() + 3);
} else {
_scene->getActor(cmd->param3)->setField96C(cmd->param2);
}
@@ -1660,12 +1660,12 @@ IMPLEMENT_OPCODE(ClearActorFields) {
//////////////////////////////////////////////////////////////////////////
// Opcode 0x5F
-IMPLEMENT_OPCODE(SetBarrierLastFrameIdx) {
- Barrier *barrier = _scene->worldstats()->getBarrierById(cmd->param1);
+IMPLEMENT_OPCODE(SetObjectLastFrameIdx) {
+ Object *object = _scene->worldstats()->getObjectById(cmd->param1);
- if (barrier->getFrameIndex() == barrier->getFrameCount() - 1) {
+ if (object->getFrameIndex() == object->getFrameCount() - 1) {
_lineIncrement = 0;
- barrier->flags &= ~kBarrierFlag10E38;
+ object->flags &= ~kObjectFlag10E38;
} else {
_lineIncrement = 1;
}
@@ -1725,14 +1725,14 @@ IMPLEMENT_OPCODE(_unk63) {
// Opcode Helper functions
//////////////////////////////////////////////////////////////////////////
-void ActionList::enableBarrier(ScriptEntry *cmd, BarrierEnableType type) {
- error("[ActionList::enableBarrier] not implemented!");
+void ActionList::enableObject(ScriptEntry *cmd, ObjectEnableType type) {
+ error("[ActionList::enableObject] not implemented!");
}
void ActionList::setActionFlag(ScriptEntry *cmd, ActionType flag) {
switch (cmd->param2) {
default:
- _scene->worldstats()->getBarrierById(cmd->param1)->actionType |= flag;
+ _scene->worldstats()->getObjectById(cmd->param1)->actionType |= flag;
break;
case 1:
@@ -1748,7 +1748,7 @@ void ActionList::setActionFlag(ScriptEntry *cmd, ActionType flag) {
void ActionList::clearActionFlag(ScriptEntry *cmd, ActionType flag) {
switch (cmd->param2) {
default:
- _scene->worldstats()->getBarrierById(cmd->param1)->actionType &= ~flag;
+ _scene->worldstats()->getObjectById(cmd->param1)->actionType &= ~flag;
break;
case 1:
@@ -1770,7 +1770,7 @@ void ActionList::jumpIfActionFlag(ScriptEntry *cmd, ActionType flag) {
break;
case 0:
- done = (_scene->worldstats()->getBarrierById(cmd->param1)->actionType & flag) == 0;
+ done = (_scene->worldstats()->getObjectById(cmd->param1)->actionType & flag) == 0;
break;
case 1:
diff --git a/engines/asylum/resources/actionlist.h b/engines/asylum/resources/actionlist.h
index 1bfcae5c77..3acb979abe 100644
--- a/engines/asylum/resources/actionlist.h
+++ b/engines/asylum/resources/actionlist.h
@@ -75,10 +75,10 @@ public:
bool isProcessingSkipped() { return _skipProcessing; }
private:
- enum BarrierEnableType {
- kBarrierEnableType0,
- kBarrierEnableType1,
- kBarrierEnableType2
+ enum ObjectEnableType {
+ kObjectEnableType0,
+ kObjectEnableType1,
+ kObjectEnableType2
};
typedef struct ScriptEntry {
@@ -157,7 +157,7 @@ private:
void resetQueue();
// Opcode helper functions
- void enableBarrier(ScriptEntry *cmd, BarrierEnableType type);
+ void enableObject(ScriptEntry *cmd, ObjectEnableType type);
void setActionFlag(ScriptEntry *cmd, ActionType flag); //|
void clearActionFlag(ScriptEntry *cmd, ActionType flag); //&
void jumpIfActionFlag(ScriptEntry *cmd, ActionType flag);
@@ -180,14 +180,14 @@ private:
DECLARE_OPCODE(SetSceneMotionStatus);
DECLARE_OPCODE(DisableActor);
DECLARE_OPCODE(EnableActor);
- DECLARE_OPCODE(EnableBarriers);
- DECLARE_OPCODE(RemoveBarrier);
+ DECLARE_OPCODE(EnableObjects);
+ DECLARE_OPCODE(RemoveObject);
DECLARE_OPCODE(JumpActorSpeech);
DECLARE_OPCODE(JumpAndSetDirection);
DECLARE_OPCODE(JumpIfActorCoordinates);
DECLARE_OPCODE(Nop);
DECLARE_OPCODE(ResetAnimation);
- DECLARE_OPCODE(DisableBarrier);
+ DECLARE_OPCODE(DisableObject);
DECLARE_OPCODE(JumpIfSoundPlayingAndPlaySound);
DECLARE_OPCODE(JumpIfActionFind);
DECLARE_OPCODE(SetActionFind);
@@ -210,7 +210,7 @@ private:
DECLARE_OPCODE(ChangeScene);
DECLARE_OPCODE(_unk2C_ActorSub);
DECLARE_OPCODE(PlayMovie);
- DECLARE_OPCODE(StopAllBarriersSounds);
+ DECLARE_OPCODE(StopAllObjectsSounds);
DECLARE_OPCODE(StopProcessing);
DECLARE_OPCODE(ResumeProcessing);
DECLARE_OPCODE(ResetSceneRect);
@@ -245,21 +245,21 @@ private:
DECLARE_OPCODE(JumpRandom);
DECLARE_OPCODE(ClearScreen);
DECLARE_OPCODE(Quit);
- DECLARE_OPCODE(JumpBarrierFrame);
+ DECLARE_OPCODE(JumpObjectFrame);
DECLARE_OPCODE(DeleteGraphics);
DECLARE_OPCODE(SetActorField944);
DECLARE_OPCODE(_unk54_SET_ACTIONLIST_6EC);
DECLARE_OPCODE(_unk55);
DECLARE_OPCODE(_unk56);
DECLARE_OPCODE(SetResourcePalette);
- DECLARE_OPCODE(SetBarrierFrameIdxFlaged);
+ DECLARE_OPCODE(SetObjectFrameIdxFlaged);
DECLARE_OPCODE(_unk59);
DECLARE_OPCODE(_unk5A);
DECLARE_OPCODE(_unk5B);
DECLARE_OPCODE(QueueScript);
DECLARE_OPCODE(_unk5D);
DECLARE_OPCODE(ClearActorFields);
- DECLARE_OPCODE(SetBarrierLastFrameIdx);
+ DECLARE_OPCODE(SetObjectLastFrameIdx);
DECLARE_OPCODE(_unk60_SET_OR_CLR_ACTIONAREA_FLAG);
DECLARE_OPCODE(_unk61);
DECLARE_OPCODE(ShowOptionsScreen);
diff --git a/engines/asylum/resources/actor.cpp b/engines/asylum/resources/actor.cpp
index 65be886067..62042db92b 100644
--- a/engines/asylum/resources/actor.cpp
+++ b/engines/asylum/resources/actor.cpp
@@ -61,7 +61,7 @@ void Actor::load(Common::SeekableReadStream *stream) {
x = stream->readSint32LE();
y = stream->readSint32LE();
_resourceId = stream->readSint32LE();
- _barrierIndex = stream->readSint32LE();
+ _objectIndex = stream->readSint32LE();
_frameIndex = stream->readSint32LE();
_frameCount = stream->readSint32LE();
x1 = stream->readSint32LE();
@@ -182,11 +182,11 @@ void Actor::draw() {
frameIndex = 2 * _frameCount - _frameIndex - 1;
if (LOBYTE(flags) & kActorFlagMasked) {
- Barrier *barrier = getWorld()->barriers[_barrierIndex];
- getScene()->adjustCoordinates(barrier->x, barrier->y, &point);
+ Object *object = getWorld()->objects[_objectIndex];
+ getScene()->adjustCoordinates(object->x, object->y, &point);
error("[Actor::draw] Cross fade not implemented!");
- //getScreen()->addGraphicToQueue(_resourceId, frameIndex, point.x, point.y, barrier->_resourceId, point.x, point.y, getGraphicsFlags(), _priority);
+ //getScreen()->addGraphicToQueue(_resourceId, frameIndex, point.x, point.y, object->_resourceId, point.x, point.y, getGraphicsFlags(), _priority);
// Update flags
flags &= ~kActorFlagMasked;
@@ -641,20 +641,20 @@ void Actor::faceTarget(int32 targetId, DirectionFrom from) {
error("[Actor::faceTarget] Invalid direction input: %d (should be 0-3)", from);
return;
- case kDirectionFromBarrier: {
- Barrier *barrier = getWorld()->getBarrierById(targetId);
- if (!barrier) {
- warning("[Actor::faceTarget] No Barrier found for id %d", targetId);
+ case kDirectionFromObject: {
+ Object *object = getWorld()->getObjectById(targetId);
+ if (!object) {
+ warning("[Actor::faceTarget] No Object found for id %d", targetId);
return;
}
- GraphicResource *resource = new GraphicResource(getScene()->getResourcePack(), barrier->getResourceId());
- GraphicFrame *frame = resource->getFrame(barrier->getFrameIndex());
+ GraphicResource *resource = new GraphicResource(getScene()->getResourcePack(), object->getResourceId());
+ GraphicFrame *frame = resource->getFrame(object->getFrameIndex());
- newX = (frame->surface.w >> 1) + barrier->x;
- newY = (frame->surface.h >> 1) + barrier->y;
+ newX = (frame->surface.w >> 1) + object->x;
+ newY = (frame->surface.h >> 1) + object->y;
delete resource;
}
diff --git a/engines/asylum/resources/actor.h b/engines/asylum/resources/actor.h
index 6bfa4d7404..765f6492ff 100644
--- a/engines/asylum/resources/actor.h
+++ b/engines/asylum/resources/actor.h
@@ -58,7 +58,7 @@ public:
void setActionIndex2(int32 index) { _actionIdx2 = index; }
- void setBarrierIndex(int32 index) { _barrierIndex = index; }
+ void setObjectIndex(int32 index) { _objectIndex = index; }
void setDirection(ActorDirection direction) { _direction = direction; }
void setFrameCount(int32 count) { _frameCount = count; }
void setFrameIndex(int32 number) { _frameIndex = number; }
@@ -232,7 +232,7 @@ private:
// Data
//////////////////////////////////////////////////////////////////////////
ResourceId _resourceId;
- int32 _barrierIndex;
+ int32 _objectIndex;
uint32 _frameIndex;
uint32 _frameCount;
// x1, y1, x2, y2
diff --git a/engines/asylum/resources/encounters.cpp b/engines/asylum/resources/encounters.cpp
index 8f941ce05c..0c6e6e59d3 100644
--- a/engines/asylum/resources/encounters.cpp
+++ b/engines/asylum/resources/encounters.cpp
@@ -84,7 +84,7 @@ void Encounter::setFlag(EncounterFlag flag, int32 val) {
_flags[flag] = val;
}
-void Encounter::run(int32 encounterIdx, int32 barrierId1, int32 barrierId2, int32 characterIdx) {
+void Encounter::run(int32 encounterIdx, int32 objectId1, int32 objectId2, int32 characterIdx) {
// Line: 12/15 :: 0x25 (1, 1584, 1584, 0, 0, 0, 0, 0, 0) // First Encounter
//debugC(kDebugLevelEncounter, "Running Encounter %d", encounterIdx);
@@ -93,7 +93,7 @@ void Encounter::run(int32 encounterIdx, int32 barrierId1, int32 barrierId2, int3
setVariable(1, 0);
setVariable(2, _currentEncounter->value);
- //Barrier *b1 = _scene->worldstats()->getBarrierById(barrierId1);
+ //Object *b1 = _scene->worldstats()->getObjectById(objectId1);
/*
int32 __cdecl runEncounter(int32 newMessageHandler, int32 encounterIndex, int32 objectId1, int32 objectId2, int32 characterIndex)
{
diff --git a/engines/asylum/resources/encounters.h b/engines/asylum/resources/encounters.h
index e38ec8459a..1141ed3ecb 100644
--- a/engines/asylum/resources/encounters.h
+++ b/engines/asylum/resources/encounters.h
@@ -66,7 +66,7 @@ public:
void setVariable(int32 idx, int32 value) {
_variables[idx] = value;
}
- void run(int32 encounterIdx, int32 barrierId1, int32 barrierId2, int32 characterIdx);
+ void run(int32 encounterIdx, int32 objectId1, int32 objectId2, int32 characterIdx);
int32 getFlag(EncounterFlag flag);
void setFlag(EncounterFlag flag, int32 val);
diff --git a/engines/asylum/resources/barrier.cpp b/engines/asylum/resources/object.cpp
similarity index 83%
rename from engines/asylum/resources/barrier.cpp
rename to engines/asylum/resources/object.cpp
index 0808ba0b14..15b465fa00 100644
--- a/engines/asylum/resources/barrier.cpp
+++ b/engines/asylum/resources/object.cpp
@@ -23,7 +23,7 @@
*
*/
-#include "asylum/resources/barrier.h"
+#include "asylum/resources/object.h"
#include "asylum/resources/actor.h"
@@ -31,16 +31,16 @@
namespace Asylum {
-Barrier::Barrier(AsylumEngine *engine) : _vm(engine) {
+Object::Object(AsylumEngine *engine) : _vm(engine) {
}
-Barrier::~Barrier() {
+Object::~Object() {
}
/////////////////////////////////////////////////////////////////////////
// Loading & destroying
/////////////////////////////////////////////////////////////////////////
-void Barrier::load(Common::SeekableReadStream *stream) {
+void Object::load(Common::SeekableReadStream *stream) {
_id = stream->readSint32LE();
_resourceId = stream->readSint32LE();
x = stream->readSint32LE();
@@ -109,14 +109,14 @@ void Barrier::load(Common::SeekableReadStream *stream) {
}
-void Barrier::disable() {
- flags &= ~kBarrierFlagEnabled;
+void Object::disable() {
+ flags &= ~kObjectFlagEnabled;
}
-void Barrier::disableAndRemoveFromQueue() {
+void Object::disableAndRemoveFromQueue() {
disable();
- flags |= kBarrierFlag20000;
+ flags |= kObjectFlag20000;
getScreen()->deleteGraphicFromQueue(_resourceId);
}
@@ -124,17 +124,17 @@ void Barrier::disableAndRemoveFromQueue() {
/////////////////////////////////////////////////////////////////////////
// Visibility
//////////////////////////////////////////////////////////////////////////
-bool Barrier::isOnScreen() {
+bool Object::isOnScreen() {
Common::Rect screenRect = Common::Rect(getWorld()->xLeft, getWorld()->yTop, getWorld()->xLeft + 640, getWorld()->yTop + 480);
- Common::Rect barrierRect = Common::Rect(_boundingRect);
+ Common::Rect objectRect = Common::Rect(_boundingRect);
- barrierRect.translate(x, y);
+ objectRect.translate(x, y);
- return isVisible() && (flags & kBarrierFlagEnabled) && screenRect.intersects(barrierRect);
+ return isVisible() && (flags & kObjectFlagEnabled) && screenRect.intersects(objectRect);
}
-bool Barrier::isVisible() {
- if (flags & kBarrierFlagEnabled) {
+bool Object::isVisible() {
+ if (flags & kObjectFlagEnabled) {
// Check each game flag
for (int32 i = 0; i < 10; i++) {
@@ -160,30 +160,30 @@ bool Barrier::isVisible() {
/////////////////////////////////////////////////////////////////////////
// Update
//////////////////////////////////////////////////////////////////////////
-void Barrier::draw() {
- if (LOBYTE(flags) & kBarrierFlag4)
+void Object::draw() {
+ if (LOBYTE(flags) & kObjectFlag4)
return;
- if (BYTE1(flags) & kBarrierFlag40)
+ if (BYTE1(flags) & kObjectFlag40)
return;
if (!isOnScreen())
return;
- // Draw the barrier
+ // Draw the object
Common::Point point;
getScene()->adjustCoordinates(x, y, &point);
if (_field_67C <= 0 || _field_67C >= 4 || Config.performance <= 1)
- getScreen()->addGraphicToQueue(_resourceId, _frameIndex, x, y, (flags >> 11) & kBarrierFlag2, _field_67C - 3, _priority);
+ getScreen()->addGraphicToQueue(_resourceId, _frameIndex, x, y, (flags >> 11) & kObjectFlag2, _field_67C - 3, _priority);
else {
// TODO: Do Cross Fade
//getScreen()->addGraphicToQueue(_resourceId, _frameIndex, x, y, getWorld()->backgroundImage, getWorld()->xLeft, getWorld()->yTop, 0, 0, _field_67C - 1);
- error("[Barrier::draw] Crossfade not implemented!");
+ error("[Object::draw] Crossfade not implemented!");
}
}
-void Barrier::update() {
+void Object::update() {
bool doPlaySounds = false;
if (_field_3C != 4)
@@ -195,13 +195,13 @@ void Barrier::update() {
}
// Examine flags
- if (flags & kBarrierFlag20) {
+ if (flags & kObjectFlag20) {
if (_vm->getTick() - _tickCount >= Common::Rational(1000, _field_B4).toInt()) {
_frameIndex =((_frameIndex + 1) % _frameCount);
_tickCount = _vm->getTick();
doPlaySounds = true;
}
- } else if (flags & kBarrierFlag10) {
+ } else if (flags & kObjectFlag10) {
bool isFirstFrame = (_frameIndex == 0);
@@ -230,7 +230,7 @@ void Barrier::update() {
doPlaySounds = true;
}
}
- } else if (BYTE1(flags) & kBarrierFlag8) {
+ } else if (BYTE1(flags) & kObjectFlag8) {
if (_vm->getTick() - _tickCount >= 1000 * _tickCount2) {
if (_vm->getRandom(_field_C0) == 1)
_frameIndex =((_frameIndex + 1) % _frameCount);
@@ -238,7 +238,7 @@ void Barrier::update() {
_tickCount = _vm->getTick();
doPlaySounds = true;
}
- } else if (flags & kBarrierFlag8) {
+ } else if (flags & kObjectFlag8) {
if (_vm->getTick() - _tickCount >= Common::Rational(1000, _field_B4).toInt()) {
@@ -253,7 +253,7 @@ void Barrier::update() {
delete gra;
}
} else {
- flags &= ~kBarrierFlag8;
+ flags &= ~kObjectFlag8;
if (_field_688 == 1) {
getScene()->setGlobalX(-1);
getScene()->setGlobalY(-1);
@@ -262,14 +262,14 @@ void Barrier::update() {
_tickCount = _vm->getTick();
doPlaySounds = true;
}
- } else if (!(BYTE1(flags) & kBarrierFlag6)) {
+ } else if (!(BYTE1(flags) & kObjectFlag6)) {
- if ((flags & kBarrierFlag10000) && (_vm->getTick() - _tickCount >= Common::Rational(1000, _field_B4).toInt())) {
+ if ((flags & kObjectFlag10000) && (_vm->getTick() - _tickCount >= Common::Rational(1000, _field_B4).toInt())) {
++_frameIndex;
if (_frameIndex <= 0) {
- flags &= ~kBarrierFlag10000;
+ flags &= ~kObjectFlag10000;
if (_field_688 == 1) {
getScene()->setGlobalX(-1);
getScene()->setGlobalY(-1);
@@ -286,24 +286,24 @@ void Barrier::update() {
doPlaySounds = true;
}
} else if (_vm->getTick() - _tickCount >= Common::Rational(1000, _field_B4).toInt()) {
- if (BYTE1(flags) & kBarrierFlag2) {
+ if (BYTE1(flags) & kObjectFlag2) {
if (_frameIndex == _frameCount - 1) {
_frameIndex--;
- flags = (BYTE1(flags) & 0xFD) | kBarrierFlag4;
+ flags = (BYTE1(flags) & 0xFD) | kObjectFlag4;
} else {
_frameIndex++;
}
- } else if (BYTE1(flags) & kBarrierFlag4) {
+ } else if (BYTE1(flags) & kObjectFlag4) {
if (_frameIndex) {
_frameIndex--;
} else {
_frameIndex++;
- flags = (BYTE1(flags) & 0xFB) | kBarrierFlag2;
+ flags = (BYTE1(flags) & 0xFB) | kObjectFlag2;
}
}
}
- if (flags & kBarrierFlag40000) {
+ if (flags & kObjectFlag40000) {
if (_frameIndex == _frameCount - 1) {
if (_field_B4 <= 15) {
_field_B4 -= 2;
@@ -315,7 +315,7 @@ void Barrier::update() {
}
if (!_field_B4)
- flags &= ~kBarrierFlag10E38;
+ flags &= ~kObjectFlag10E38;
}
}
@@ -325,10 +325,10 @@ void Barrier::update() {
getScene()->callSpecFunction(this, -1);
}
-void Barrier::setNextFrame(int32 targetFlags) {
- flags |= targetFlags | kBarrierFlagEnabled;
+void Object::setNextFrame(int32 targetFlags) {
+ flags |= targetFlags | kObjectFlagEnabled;
- if (flags & kBarrierFlag10000)
+ if (flags & kObjectFlag10000)
_frameIndex = _frameCount - 1;
else
_frameIndex = 0;
@@ -337,7 +337,7 @@ void Barrier::setNextFrame(int32 targetFlags) {
/////////////////////////////////////////////////////////////////////////
// Misc
/////////////////////////////////////////////////////////////////////////
-void Barrier::playSounds() {
+void Object::playSounds() {
int32 soundX = 0;
int32 soundY = 0;
@@ -347,7 +347,7 @@ void Barrier::playSounds() {
} else {
GraphicResource *resource = new GraphicResource(getScene()->getResourcePack(), _resourceId);
- if (LOBYTE(flags) & kBarrierFlag4) {
+ if (LOBYTE(flags) & kObjectFlag4) {
soundX = x + (resource->getFlags() >> 1);
soundY = y + (resource->getFlags2() >> 1);
} else {
@@ -389,10 +389,10 @@ void Barrier::playSounds() {
}
}
- //warning("[Barrier::playSounds] not implemented!");
+ //warning("[Object::playSounds] not implemented!");
}
-void Barrier::updateSoundItems() {
+void Object::updateSoundItems() {
for (int32 i = 0; i < ARRAYSIZE(_soundItems); i++) {
SoundItem *item = &_soundItems[i];
@@ -409,12 +409,12 @@ void Barrier::updateSoundItems() {
stopSound();
}
-void Barrier::stopSound() {
+void Object::stopSound() {
if (getSound()->isPlaying(_soundResourceId))
getSound()->stopSound(_soundResourceId);
}
-void Barrier::stopAllSounds() {
+void Object::stopAllSounds() {
for (int i = 0; i < ARRAYSIZE(_soundItems); i++)
if (_soundItems[i].resourceId) {
getSound()->stopSound(_soundItems[i].resourceId);
@@ -422,7 +422,7 @@ void Barrier::stopAllSounds() {
}
}
-int32 Barrier::getRandomResourceId() {
+int32 Object::getRandomResourceId() {
// Initialize random resource id array
ResourceId shuffle[5];
memset(&shuffle, 0, sizeof(shuffle));
@@ -436,19 +436,19 @@ int32 Barrier::getRandomResourceId() {
}
if (count == 0)
- error("[Barrier::getRandomId] Could not get a random resource Id");
+ error("[Object::getRandomId] Could not get a random resource Id");
return shuffle[_vm->getRandom(count)];
}
-bool Barrier::checkFlags() {
- return (flags & kBarrierFlagEnabled) && (flags & kBarrierFlag8 || flags & kBarrierFlag10000);
+bool Object::checkFlags() {
+ return (flags & kObjectFlagEnabled) && (flags & kObjectFlag8 || flags & kObjectFlag10000);
}
-Common::String Barrier::toString() {
+Common::String Object::toString() {
Common::String output;
- output += Common::String::format("Barrier %d: %s\n", _id, _name);
+ output += Common::String::format("Object %d: %s\n", _id, _name);
return output;
}
diff --git a/engines/asylum/resources/barrier.h b/engines/asylum/resources/object.h
similarity index 87%
rename from engines/asylum/resources/barrier.h
rename to engines/asylum/resources/object.h
index 3188c71db0..109e8844be 100644
--- a/engines/asylum/resources/barrier.h
+++ b/engines/asylum/resources/object.h
@@ -23,8 +23,8 @@
*
*/
-#ifndef ASYLUM_BARRIER_H
-#define ASYLUM_BARRIER_H
+#ifndef ASYLUM_OBJECT_H
+#define ASYLUM_OBJECT_H
#include "asylum/shared.h"
@@ -38,10 +38,10 @@ namespace Asylum {
class Actor;
class AsylumEngine;
-class Barrier {
+class Object {
public:
- Barrier(AsylumEngine *engine);
- virtual ~Barrier();
+ Object(AsylumEngine *engine);
+ virtual ~Object();
//////////////////////////////////////////////////////////////////////////
// Public variables & accessors
@@ -75,19 +75,19 @@ public:
/////////////////////////////////////////////////////////////////////////
/**
- * Loads the barrier data
+ * Loads the object data
*
* @param stream If non-null, the Common::SeekableReadStream to load from
*/
void load(Common::SeekableReadStream *stream);
/**
- * Sets the barrier disabled flag
+ * Sets the object disabled flag
*/
void disable();
/**
- * Sets the barrier destroyed flag and remove this barrier from the graphics queue
+ * Sets the object destroyed flag and remove this object from the graphics queue
*/
void disableAndRemoveFromQueue();
@@ -96,7 +96,7 @@ public:
//////////////////////////////////////////////////////////////////////////
/**
- * Query if this barrier is on screen.
+ * Query if this object is on screen.
*
* @return true if on screen, false if not.
*/
@@ -107,12 +107,12 @@ public:
//////////////////////////////////////////////////////////////////////////
/**
- * Draws the barrier
+ * Draws the object
*/
void draw();
/**
- * Updates the barrier.
+ * Updates the object.
*/
void update();
@@ -128,12 +128,12 @@ public:
////////////////////////////////////////////////////////////////////////
/**
- * Stop all barrier sounds (called from scripts)
+ * Stop all object sounds (called from scripts)
*/
void stopAllSounds();
/**
- * Checks the barrier flags
+ * Checks the object flags
*
* @return true if it succeeds, false if it fails.
*/
@@ -188,37 +188,37 @@ private:
int32 _field_6A4;
/**
- * Query if this barrier is visible.
+ * Query if this object is visible.
*
* @return true if visible, false if not.
*/
bool isVisible();
/**
- * Play barrier sounds
+ * Play object sounds
*/
void playSounds();
/**
- * Check if any items in the barrier sound array are playing,
+ * Check if any items in the object sound array are playing,
* and based on their flag values, stop them accordingly
*/
void updateSoundItems();
/**
- * Stop the barrier related sounds
+ * Stop the object related sounds
*/
void stopSound();
/**
- * Gets a random resource identifier for this barrier (using the list in _randomResourceIds)
+ * Gets a random resource identifier for this object (using the list in _randomResourceIds)
*
* @return The random resource identifier.
*/
int32 getRandomResourceId();
-}; // end of class Barrier
+}; // end of class Object
} // end of namespace Asylum
-#endif
+#endif // ASYLUM_OBJECT_H
diff --git a/engines/asylum/resources/worldstats.cpp b/engines/asylum/resources/worldstats.cpp
index e70c66bd91..b62c394bdc 100644
--- a/engines/asylum/resources/worldstats.cpp
+++ b/engines/asylum/resources/worldstats.cpp
@@ -33,7 +33,7 @@ WorldStats::WorldStats(Common::SeekableReadStream *stream, Scene *scene)
}
WorldStats::~WorldStats() {
- CLEAR_ARRAY(Barrier, barriers);
+ CLEAR_ARRAY(Object, objects);
CLEAR_ARRAY(Actor, actors);
CLEAR_ARRAY(ActionArea, actions);
}
@@ -55,17 +55,17 @@ ActionArea* WorldStats::getActionAreaById(int32 id) {
return actions[index];
}
-int32 WorldStats::getBarrierIndexById(int32 id) {
- for (int32 i = 0; i < numBarriers; i++) {
- if (barriers[i]->getId() == id)
+int32 WorldStats::getObjectIndexById(int32 id) {
+ for (int32 i = 0; i < numObjects; i++) {
+ if (objects[i]->getId() == id)
return i;
}
return -1;
}
-Barrier* WorldStats::getBarrierById(int32 id) {
- return barriers[getBarrierIndexById(id)];
+Object* WorldStats::getObjectById(int32 id) {
+ return objects[getObjectIndexById(id)];
}
// FIXME: load necessary World Stats content
@@ -114,7 +114,7 @@ void WorldStats::load(Common::SeekableReadStream *stream) {
motionStatus = stream->readSint32LE();
field_8C = stream->readSint32LE();
numActions = stream->readSint32LE();
- numBarriers = stream->readSint32LE();
+ numObjects = stream->readSint32LE();
targetX = stream->readSint32LE();
targetY = stream->readSint32LE();
field_A0 = stream->readSint32LE();
@@ -172,14 +172,14 @@ void WorldStats::load(Common::SeekableReadStream *stream) {
musicResourceId = stream->readSint32LE();
musicStatusExt = stream->readSint32LE();
- for (int32 a = 0; a < numBarriers; a++) {
- Barrier *barrier = new Barrier(_scene->vm());
- barrier->load(stream);
+ for (int32 a = 0; a < numObjects; a++) {
+ Object *object = new Object(_scene->vm());
+ object->load(stream);
- barriers.push_back(barrier);
+ objects.push_back(object);
}
- // need to jump all unused barriers data to where actors data start
+ // need to jump all unused objects data to where actors data start
stream->seek(0xA6D7A);
for (ActorIndex index = 0; index < numActors; index++) {
diff --git a/engines/asylum/resources/worldstats.h b/engines/asylum/resources/worldstats.h
index a9154c9393..611c5a3413 100644
--- a/engines/asylum/resources/worldstats.h
+++ b/engines/asylum/resources/worldstats.h
@@ -30,7 +30,7 @@
#include "common/array.h"
#include "asylum/resources/actor.h"
-#include "asylum/resources/barrier.h"
+#include "asylum/resources/object.h"
#include "asylum/resources/actionarea.h"
#include "asylum/views/scene.h"
#include "asylum/system/sound.h"
@@ -78,7 +78,7 @@ public:
int32 motionStatus;
int32 field_8C;
int32 numActions; // field_90
- int32 numBarriers;
+ int32 numObjects;
int32 targetX;
int32 targetY;
int32 field_A0;
@@ -108,7 +108,7 @@ public:
// FIXME: Investigate if we need to actually reserve maxsize for this arrays.
// It always have that size under scene file and they are always save in savegames.
- Common::Array<Barrier*> barriers; // maxsize 400
+ Common::Array<Object*> objects; // maxsize 400
Common::Array<Actor*> actors; // maxsize 50
// TODO add rest fields
Common::Array<ActionArea*> actions; // maxsize 400
@@ -119,8 +119,8 @@ public:
int32 getActionAreaIndexById(int32 id);
ActionArea* getActionAreaById(int32 id);
- int32 getBarrierIndexById(int32 id);
- Barrier* getBarrierById(int32 id);
+ int32 getObjectIndexById(int32 id);
+ Object* getObjectById(int32 id);
private:
Scene *_scene;
diff --git a/engines/asylum/shared.h b/engines/asylum/shared.h
index cad3371509..bbee5278fc 100644
--- a/engines/asylum/shared.h
+++ b/engines/asylum/shared.h
@@ -125,7 +125,7 @@ enum ActorFlags {
};
enum DirectionFrom {
- kDirectionFromBarrier = 0,
+ kDirectionFromObject = 0,
kDirectionFromPolygons = 1,
kDirectionFromActor = 2,
kDirectionFromParameters = 3
@@ -224,23 +224,23 @@ enum ActorResources {
};
//////////////////////////////////////////////////////////////////////////
-// Barrier
+// Object
//////////////////////////////////////////////////////////////////////////
-enum BarrierFlag {
- kBarrierFlagEnabled = 0x1,
- kBarrierFlag2 = 0x2,
- kBarrierFlag4 = 0x4,
- kBarrierFlag6 = 0x6,
- kBarrierFlag8 = 0x8,
- kBarrierFlag10 = 0x10,
- kBarrierFlag20 = 0x20,
- kBarrierFlag40 = 0x40,
- kBarrierFlag80 = 0x80,
- kBarrierFlagC000 = 0xC000,
- kBarrierFlag10000 = 0x10000,
- kBarrierFlag10E38 = 0x10E38,
- kBarrierFlag20000 = 0x20000,
- kBarrierFlag40000 = 0x40000
+enum ObjectFlag {
+ kObjectFlagEnabled = 0x1,
+ kObjectFlag2 = 0x2,
+ kObjectFlag4 = 0x4,
+ kObjectFlag6 = 0x6,
+ kObjectFlag8 = 0x8,
+ kObjectFlag10 = 0x10,
+ kObjectFlag20 = 0x20,
+ kObjectFlag40 = 0x40,
+ kObjectFlag80 = 0x80,
+ kObjectFlagC000 = 0xC000,
+ kObjectFlag10000 = 0x10000,
+ kObjectFlag10E38 = 0x10E38,
+ kObjectFlag20000 = 0x20000,
+ kObjectFlag40000 = 0x40000
};
//////////////////////////////////////////////////////////////////////////
diff --git a/engines/asylum/views/scene.cpp b/engines/asylum/views/scene.cpp
index ace7a0d53f..a6c3241525 100644
--- a/engines/asylum/views/scene.cpp
+++ b/engines/asylum/views/scene.cpp
@@ -38,7 +38,7 @@ namespace Asylum {
#define SCROLL_STEP 10
int g_debugPolygons;
-int g_debugBarriers;
+int g_debugObjects;
int g_debugScrolling;
Scene::Scene(uint8 sceneIdx, AsylumEngine *engine): _vm(engine) {
@@ -96,7 +96,7 @@ Scene::Scene(uint8 sceneIdx, AsylumEngine *engine): _vm(engine) {
_skipDrawScene = 0;
g_debugPolygons = 0;
- g_debugBarriers = 0;
+ g_debugObjects = 0;
g_debugScrolling = 0;
_globalX = _globalY = 0;
@@ -118,12 +118,12 @@ void Scene::initialize() {
_playerActorIdx = 0;
- if (_ws->numBarriers > 0) {
+ if (_ws->numObjects > 0) {
int32 priority = 4091;
- for (int32 b = 0; b < _ws->numBarriers; b++) {
- Barrier *barrier = _ws->barriers[b];
- barrier->setPriority(priority);
- barrier->flags &= ~kBarrierFlagC000;
+ for (int32 b = 0; b < _ws->numObjects; b++) {
+ Object *object = _ws->objects[b];
+ object->setPriority(priority);
+ object->flags &= ~kObjectFlagC000;
priority -= 4;
}
}
@@ -355,7 +355,7 @@ int Scene::updateScene() {
// Update each part of the scene
MESURE_TICKS(updateMouse);
MESURE_TICKS(updateActors);
- MESURE_TICKS(updateBarriers);
+ MESURE_TICKS(updateObjects);
MESURE_TICKS(updateAmbientSounds);
MESURE_TICKS(updateMusic);
MESURE_TICKS(updateScreen);
@@ -363,8 +363,8 @@ int Scene::updateScene() {
// Update Debug
if (g_debugPolygons)
debugShowPolygons();
- if (g_debugBarriers)
- debugShowBarriers();
+ if (g_debugObjects)
+ debugShowObjects();
if (_actions->process())
return 1;
@@ -600,8 +600,8 @@ void Scene::handleMouseUpdate(int direction, Common::Rect rect) {
case kHitActionArea:
targetUpdateType = _ws->actions[targetIdx]->actionType;
break;
- case kHitBarrier:
- targetUpdateType = _ws->barriers[targetIdx]->actionType;
+ case kHitObject:
+ targetUpdateType = _ws->objects[targetIdx]->actionType;
break;
case kHitActor:
targetUpdateType = getActor(targetIdx)->getStatus();
@@ -639,13 +639,13 @@ void Scene::handleMouseUpdate(int direction, Common::Rect rect) {
}
-int32 Scene::hitTestBarrier(const Common::Point pt) {
+int32 Scene::hitTestObject(const Common::Point pt) {
int32 targetIdx = -1;
- for (int32 i = 0; i < _ws->numBarriers; i++) {
- Barrier *barrier = _ws->barriers[i];
- if (barrier->isOnScreen())
- if (barrier->getPolygonIndex())
- if (hitTestPixel(barrier->getResourceId(), barrier->getFrameIndex(), pt.x, pt.y, barrier->flags & 0x1000)) {
+ for (int32 i = 0; i < _ws->numObjects; i++) {
+ Object *object = _ws->objects[i];
+ if (object->isOnScreen())
+ if (object->getPolygonIndex())
+ if (hitTestPixel(object->getResourceId(), object->getFrameIndex(), pt.x, pt.y, object->flags & 0x1000)) {
targetIdx = i;
break;
}
@@ -655,7 +655,7 @@ int32 Scene::hitTestBarrier(const Common::Point pt) {
int32 Scene::hitTest(const Common::Point pt, HitType &type) {
type = kHitNone;
- int32 targetIdx = hitTestBarrier(pt);
+ int32 targetIdx = hitTestObject(pt);
if (targetIdx == -1) {
targetIdx = hitTestActionArea(pt);
if (targetIdx == -1) {
@@ -666,7 +666,7 @@ int32 Scene::hitTest(const Common::Point pt, HitType &type) {
type = kHitActionArea;
}
} else {
- type = kHitBarrier;
+ type = kHitObject;
}
return targetIdx;
}
@@ -711,7 +711,7 @@ int32 Scene::hitTestScene(const Common::Point pt, HitType &type) {
}
}
- // TODO barrier and actor checks
+ // TODO object and actor checks
return result;
}
@@ -761,9 +761,9 @@ void Scene::updateActors() {
_ws->actors[i]->update();
}
-void Scene::updateBarriers() {
- for (uint32 i = 0; i < _ws->barriers.size(); i++)
- _ws->barriers[i]->update();
+void Scene::updateObjects() {
+ for (uint32 i = 0; i < _ws->objects.size(); i++)
+ _ws->objects[i]->update();
}
void Scene::updateAmbientSounds() {
@@ -1041,8 +1041,8 @@ int Scene::drawScene() {
for (uint32 i = 0; i < _ws->actors.size(); i++)
_ws->actors[i]->draw();
- for (uint32 i = 0; i < _ws->barriers.size(); i++)
- _ws->barriers[i]->draw();
+ for (uint32 i = 0; i < _ws->objects.size(); i++)
+ _ws->objects[i]->draw();
Actor *player = getActor();
if (player->getStatus() == kActorStatus6 || player->getStatus() == kActorStatus10)
@@ -1111,71 +1111,71 @@ void Scene::processUpdateList() {
// Our actor rect
Common::Rect actorRect(actor->x1, actor->y1, actor->x1 + actor->getBoundingRect()->right, bottomRight);
- // Process barriers
- for (int32 j = 0; j < _ws->numBarriers; j++) {
- Barrier *barrier = _ws->barriers[i];
+ // Process objects
+ for (int32 j = 0; j < _ws->numObjects; j++) {
+ Object *object = _ws->objects[i];
- // Skip hidden barriers
- if (!barrier->isOnScreen())
+ // Skip hidden objects
+ if (!object->isOnScreen())
continue;
- // Rect for the barrier
- Common::Rect barrierRect(barrier->x, barrier->y, barrier->x + barrier->getBoundingRect()->right, barrier->y + barrier->getBoundingRect()->bottom);
+ // Rect for the object
+ Common::Rect objectRect(object->x, object->y, object->x + object->getBoundingRect()->right, object->y + object->getBoundingRect()->bottom);
// Check that the rects are contained
- if (!barrierRect.contains(actorRect)) {
- if (BYTE1(barrier->flags) & kBarrierFlag20)
- if (!(BYTE1(barrier->flags) & kBarrierFlag80))
- barrier->flags = BYTE1(barrier->flags) | kBarrierFlag40;
+ if (!objectRect.contains(actorRect)) {
+ if (BYTE1(object->flags) & kObjectFlag20)
+ if (!(BYTE1(object->flags) & kObjectFlag80))
+ object->flags = BYTE1(object->flags) | kObjectFlag40;
continue;
}
- // Check if it intersects with either the barrier rect or the related polygon
+ // Check if it intersects with either the object rect or the related polygon
bool intersects = false;
- if (barrier->flags & kBarrierFlag2) {
- intersects = pointIntersectsRect(point, *barrier->getRect());
+ if (object->flags & kObjectFlag2) {
+ intersects = pointIntersectsRect(point, *object->getRect());
} else {
- if (barrier->flags & kBarrierFlag40) {
- PolyDefinitions *poly = &_polygons->entries[barrier->getPolygonIndex()];
+ if (object->flags & kObjectFlag40) {
+ PolyDefinitions *poly = &_polygons->entries[object->getPolygonIndex()];
if (point.x > 0 && point.y > 0 && poly->numPoints > 0)
intersects = poly->contains(point);
else
- warning ("[drawActorsAndBarriers] trying to find intersection of uninitialized point");
+ warning ("[drawActorsAndObjects] trying to find intersection of uninitialized point");
}
}
- // Adjust barrier flags
- if (BYTE1(barrier->flags) & kBarrierFlag80 || intersects) {
- if (BYTE1(barrier->flags) & kBarrierFlag20)
- barrier->flags = (BYTE1(barrier->flags) & 0xBF) | kBarrierFlag80;
+ // Adjust object flags
+ if (BYTE1(object->flags) & kObjectFlag80 || intersects) {
+ if (BYTE1(object->flags) & kObjectFlag20)
+ object->flags = (BYTE1(object->flags) & 0xBF) | kObjectFlag80;
} else {
- if (BYTE1(barrier->flags) & kBarrierFlag20) {
- barrier->flags = BYTE1(barrier->flags) | kBarrierFlag40;
+ if (BYTE1(object->flags) & kObjectFlag20) {
+ object->flags = BYTE1(object->flags) | kObjectFlag40;
}
}
- if (barrier->flags & kBarrierFlag4) {
+ if (object->flags & kObjectFlag4) {
if (intersects && LOBYTE(actor->flags) & kActorFlagMasked) {
error("[Scene::processUpdateList] Assigning mask to masked character [%s]", actor->getName());
} else {
- adjustCoordinates(barrier->x, barrier->y, &point);
- actor->setBarrierIndex(j);
+ adjustCoordinates(object->x, object->y, &point);
+ actor->setObjectIndex(j);
actor->flags |= kActorFlagMasked;
}
} else {
if (intersects) {
- if (actor->getPriority() < barrier->getPriority()) {
+ if (actor->getPriority() < object->getPriority()) {
actor->setField934(1);
- actor->setPriority(barrier->getPriority() + 3);
+ actor->setPriority(object->getPriority() + 3);
if (_updateList[i].index > _updateList[0].index) {
error("[Scene::processUpdateList] list update not implemented!");
}
}
} else {
- if (actor->getPriority() > barrier->getPriority() || actor->getPriority() == 1) {
+ if (actor->getPriority() > object->getPriority() || actor->getPriority() == 1) {
actor->setField934(1);
- actor->setPriority(barrier->getPriority() - 1);
+ actor->setPriority(object->getPriority() - 1);
if (_updateList[i].index > _updateList[0].index) {
error("[Scene::processUpdateList] list update not implemented!");
@@ -1183,7 +1183,7 @@ void Scene::processUpdateList() {
}
}
}
- } // end processing barriers
+ } // end processing objects
// Update all other actors
for (uint32 k = 0; k < _updateList.size(); k++) {
@@ -1255,11 +1255,11 @@ void Scene::adjustActorPriority(ActorIndex index) {
//////////////////////////////////////////////////////////////////////////
// Spec functions
//////////////////////////////////////////////////////////////////////////
-void Scene::specChapter1(Barrier *barrier, ActorIndex actorIndex) {
- if (actorIndex == -1 && barrier == NULL)
+void Scene::specChapter1(Object *object, ActorIndex actorIndex) {
+ if (actorIndex == -1 && object == NULL)
error("[Scene::specChapter1] Both arguments cannot be empty!");
- ResourceId id = (actorIndex == -1) ? barrier->getSoundResourceId() : getActor(actorIndex)->getSoundResourceId();
+ ResourceId id = (actorIndex == -1) ? object->getSoundResourceId() : getActor(actorIndex)->getSoundResourceId();
if (!_vm->encounter()->getFlag(kEncounterFlag2)) {
if (!id || !getSound()->isPlaying(id))
@@ -1268,22 +1268,22 @@ void Scene::specChapter1(Barrier *barrier, ActorIndex actorIndex) {
}
if (actorIndex == -1) {
- switch (barrier->getId()) {
+ switch (object->getId()) {
default:
break;
case 101:
- if (barrier->getFrameIndex() == 2)
- barrier->getFrameSoundItem(0)->resourceId = _ws->graphicResourceIds[rnd(2) ? 37 : 38];
+ if (object->getFrameIndex() == 2)
+ object->getFrameSoundItem(0)->resourceId = _ws->graphicResourceIds[rnd(2) ? 37 : 38];
break;
case 112:
- if (barrier->getFrameIndex() == 5)
+ if (object->getFrameIndex() == 5)
getSpeech()->play(81);
break;
case 434:
- if (barrier->getFrameIndex() == 23)
+ if (object->getFrameIndex() == 23)
getSpeech()->play(82);
break;
}
@@ -1403,25 +1403,25 @@ void Scene::debugShowPolygons() {
}
}
-// BARRIER DEBUGGING
-void Scene::debugShowBarriers() {
- for (int32 p = 0; p < _ws->numBarriers; p++) {
+// OBJECT DEBUGGING
+void Scene::debugShowObjects() {
+ for (int32 p = 0; p < _ws->numObjects; p++) {
Graphics::Surface surface;
- Barrier *barrier = _ws->barriers[p];
+ Object *object = _ws->objects[p];
- if (barrier->flags & 0x20) {
- surface.create(barrier->getBoundingRect()->right - barrier->getBoundingRect()->left + 1,
- barrier->getBoundingRect()->bottom - barrier->getBoundingRect()->top + 1,
+ if (object->flags & 0x20) {
+ surface.create(object->getBoundingRect()->right - object->getBoundingRect()->left + 1,
+ object->getBoundingRect()->bottom - object->getBoundingRect()->top + 1,
1);
- surface.frameRect(*barrier->getBoundingRect(), 0x22);
- copyToBackBufferClipped(&surface, barrier->x, barrier->y);
+ surface.frameRect(*object->getBoundingRect(), 0x22);
+ copyToBackBufferClipped(&surface, object->x, object->y);
}
surface.free();
}
}
-// BARRIER DEBUGGING
+// ACTOR DEBUGGING
void Scene::debugShowActors() {
for (int32 p = 0; p < _ws->numActors; p++) {
Graphics::Surface surface;
@@ -1467,7 +1467,7 @@ void Scene::resetActor0() {
error("[Scene::resetActor0] not implemented!");
}
-void Scene::callSpecFunction(Barrier* barrier, ActorIndex index) {
+void Scene::callSpecFunction(Object* object, ActorIndex index) {
// The original uses a function array, we just use switch for now there is only 11 entries
switch (_ws->numChapter) {
default:
diff --git a/engines/asylum/views/scene.h b/engines/asylum/views/scene.h
index 73d0d8768d..0330e7d095 100644
--- a/engines/asylum/views/scene.h
+++ b/engines/asylum/views/scene.h
@@ -51,14 +51,14 @@ class Video;
class Cursor;
class Text;
//class BlowUpPuzzle;
-struct BarrierItem;
+struct ObjectItem;
class WorldStats;
class Speech;
enum HitType {
kHitNone = -1,
kHitActionArea = 2,
- kHitBarrier = 3,
+ kHitObject = 3,
kHitActor = 4
};
@@ -185,7 +185,7 @@ public:
// Shared methods
void resetActor0();
- void callSpecFunction(Barrier* barrier, ActorIndex index);
+ void callSpecFunction(Object* object, ActorIndex index);
/** .text:00408980
* Determine if the supplied point intersects
@@ -214,17 +214,17 @@ protected:
*/
bool hitTestPixel(ResourceId resourceId, int32 frame, int16 x, int16 y, bool flipped);
/** .text:0040E8A0
- * Checks if the supplied coordinates are inside an action area, barrier or
+ * Checks if the supplied coordinates are inside an action area, object or
* actor, and returns -1 if nothing was found, or the type of hit if found
*/
int32 hitTestScene(const Common::Point pt, HitType &type);
/** .text:0040EAA0
- * Check if a barrier exist at the supplied coordinates.
- * If so, return it's index within the barriers array, if not,
+ * Check if a object exist at the supplied coordinates.
+ * If so, return it's index within the objects array, if not,
* return -1
*/
- int32 hitTestBarrier(const Common::Point pt);
+ int32 hitTestObject(const Common::Point pt);
private:
AsylumEngine *_vm;
@@ -272,7 +272,7 @@ private:
/** .text:0040B5B0
* Loop through the various update blocks (actors,
- * barriers, mouse, music, sfx, screenPosition), then
+ * objects, mouse, music, sfx, screenPosition), then
* process the current action script
*/
int updateScene();
@@ -290,7 +290,7 @@ private:
/** .text:0040CBD0
* TODO add description
*/
- void updateBarriers();
+ void updateObjects();
/** .text:00409BA0
* TODO add description
*/
@@ -322,7 +322,7 @@ private:
//////////////////////////////////////////////////////////////////////////
// Spec functions
//////////////////////////////////////////////////////////////////////////
- void specChapter1(Barrier *barrier, ActorIndex actorIndex);
+ void specChapter1(Object *object, ActorIndex actorIndex);
//////////////////////////////////////////////////////////////////////////
// Helpers
@@ -336,7 +336,7 @@ private:
void debugScreenScrolling(GraphicFrame *bg);
void debugShowPolygons();
- void debugShowBarriers();
+ void debugShowObjects();
void debugShowActors();
void debugShowWalkRegion(PolyDefinitions *poly);
Commit: fecb700e694422b0230fb749ab183f9bf5be865b
https://github.com/scummvm/scummvm/commit/fecb700e694422b0230fb749ab183f9bf5be865b
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:09+02:00
Commit Message:
ASYLUM: Update shared enumerations
- Add ObjectId enumeration
- Add some missing game flags
- Add macros for access to more subsystems
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@487 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/shared.h
diff --git a/engines/asylum/shared.h b/engines/asylum/shared.h
index bbee5278fc..ec9a254e93 100644
--- a/engines/asylum/shared.h
+++ b/engines/asylum/shared.h
@@ -42,9 +42,19 @@ enum GameFlag {
kGameFlag239 = 239,
kGameFlag279 = 279,
kGameFlag368 = 368,
+ kGameFlag371 = 371,
+ kGameFlag447 = 447,
+ kGameFlag448 = 448,
+ kGameFlag450 = 450,
+ kGameFlag451 = 451,
+ kGameFlag452 = 452,
+ kGameFlag453 = 453,
+ kGameFlag454 = 454,
+ kGameFlag455 = 455,
kGameFlag556 = 556,
kGameFlagFinishGame = 901,
- kGameFlag1131 = 1131
+ kGameFlag1131 = 1131,
+ kGameFlag1137 = 1137
};
//////////////////////////////////////////////////////////////////////////
@@ -98,7 +108,7 @@ enum ActorStatus {
kActorStatus2,
kActorStatus3,
kActorStatusEnabled,
- kActorStatusDisabled,
+ kActorStatusDisabled, // 5
kActorStatus6,
kActorStatus7,
kActorStatus8,
@@ -226,6 +236,25 @@ enum ActorResources {
//////////////////////////////////////////////////////////////////////////
// Object
//////////////////////////////////////////////////////////////////////////
+enum ObjectId {
+ kObjectInvalid = -1,
+ kObjectNone = 0,
+ kObjectHeadBanger = 101,
+ kObjectAngelFlares = 112,
+ kObjectGuyFalls = 434,
+ kObjectOpeningGate = 485,
+ kObjectNPC033StartEnc = 1338,
+ kObjectNPC033GetBook = 1343,
+ kObjectCrow1FlysAway = 1485,
+ kObjectCrow1Pecks = 1486,
+ kObjectCrow2AmbientPecks = 1495,
+ kObjectCrow2FlysAway = 1500,
+ kObjectCrow3FlysAway = 1502,
+ kObjectCrow3Pecks = 1503,
+ kObjectCrow4FlysAway = 1506,
+ kObjectCrow4Pecks = 1507
+};
+
enum ObjectFlag {
kObjectFlagEnabled = 0x1,
kObjectFlag2 = 0x2,
@@ -262,11 +291,12 @@ enum ObjectFlag {
#define rnd(val) _vm->getRandom(val)
// Engine subclasses
-#define getSound() _vm->sound()
-#define getScene() _vm->scene()
-#define getScreen() _vm->screen()
-#define getSpeech() _vm->scene()->speech()
-#define getWorld() _vm->scene()->worldstats()
+#define getEncounter() _vm->encounter()
+#define getSound() _vm->sound()
+#define getScene() _vm->scene()
+#define getScreen() _vm->screen()
+#define getSpeech() _vm->scene()->speech()
+#define getWorld() _vm->scene()->worldstats()
//////////////////////////////////////////////////////////////////////////
// Sub-integer partial access macros
Commit: 582794ff1296b56525019866f5857403e0fff61c
https://github.com/scummvm/scummvm/commit/582794ff1296b56525019866f5857403e0fff61c
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:10+02:00
Commit Message:
ASYLUM: Implement special logic for chapters 1, parts of 2, 3, 4 and 6
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@488 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
A engines/asylum/resources/special.cpp
A engines/asylum/resources/special.h
engines/asylum/asylum.cpp
engines/asylum/console.cpp
engines/asylum/module.mk
engines/asylum/resources/actionlist.cpp
engines/asylum/resources/actor.cpp
engines/asylum/resources/actor.h
engines/asylum/resources/object.cpp
engines/asylum/resources/object.h
engines/asylum/resources/worldstats.cpp
engines/asylum/resources/worldstats.h
engines/asylum/shared.h
engines/asylum/views/scene.cpp
engines/asylum/views/scene.h
diff --git a/engines/asylum/asylum.cpp b/engines/asylum/asylum.cpp
index 9f9e0a9b26..4fc6fed96b 100644
--- a/engines/asylum/asylum.cpp
+++ b/engines/asylum/asylum.cpp
@@ -25,6 +25,7 @@
#include "asylum/asylum.h"
+#include "asylum/resources/actionlist.h"
#include "asylum/resources/encounters.h"
#include "asylum/system/config.h"
diff --git a/engines/asylum/console.cpp b/engines/asylum/console.cpp
index 97acf75a2c..a8a813760b 100644
--- a/engines/asylum/console.cpp
+++ b/engines/asylum/console.cpp
@@ -26,6 +26,7 @@
#include "asylum/console.h"
#include "asylum/resources/actionarea.h"
+#include "asylum/resources/actionlist.h"
#include "asylum/views/scene.h"
diff --git a/engines/asylum/module.mk b/engines/asylum/module.mk
index a7501882a3..ca6dfdd96d 100644
--- a/engines/asylum/module.mk
+++ b/engines/asylum/module.mk
@@ -7,6 +7,7 @@ MODULE_OBJS := \
resources/object.o \
resources/encounters.o \
resources/polygons.o \
+ resources/special.o \
resources/worldstats.o \
system/config.o \
system/cursor.o \
diff --git a/engines/asylum/resources/actionlist.cpp b/engines/asylum/resources/actionlist.cpp
index ce0f181206..722b184ea8 100644
--- a/engines/asylum/resources/actionlist.cpp
+++ b/engines/asylum/resources/actionlist.cpp
@@ -345,7 +345,7 @@ IMPLEMENT_OPCODE(ShowCursor) {
//////////////////////////////////////////////////////////////////////////
// Opcode 0x07
IMPLEMENT_OPCODE(PlayAnimation) {
- Object *object = _scene->worldstats()->getObjectById(cmd->param1);
+ Object *object = _scene->worldstats()->getObjectById((ObjectId)cmd->param1);
if (cmd->param2 == 2) {
if (object->checkFlags())
@@ -479,7 +479,7 @@ IMPLEMENT_OPCODE(EnableActor) {
//////////////////////////////////////////////////////////////////////////
// Opcode 0x0F
IMPLEMENT_OPCODE(EnableObjects) {
- Object *object = _scene->worldstats()->getObjectById(cmd->param1);
+ Object *object = _scene->worldstats()->getObjectById((ObjectId)cmd->param1);
if (!_currentScript->counter && _scene->worldstats()->numChapter != 13)
_scene->vm()->sound()->playSound(cmd->param3 ? kResourceSound_80120006 : kResourceSound_80120001, false, Config.sfxVolume, 0);
@@ -511,7 +511,7 @@ IMPLEMENT_OPCODE(RemoveObject) {
if (!cmd->param1)
return;
- Object *object = _scene->worldstats()->getObjectById(cmd->param1);
+ Object *object = _scene->worldstats()->getObjectById((ObjectId)cmd->param1);
object->disableAndRemoveFromQueue();
}
@@ -581,7 +581,7 @@ IMPLEMENT_OPCODE(Nop) {
//////////////////////////////////////////////////////////////////////////
// Opcode 0x16
IMPLEMENT_OPCODE(ResetAnimation) {
- Object *object = _scene->worldstats()->getObjectById(cmd->param1);
+ Object *object = _scene->worldstats()->getObjectById((ObjectId)cmd->param1);
if (object->flags & kObjectFlag10000)
object->setFrameIndex(object->getFrameCount() - 1);
@@ -592,7 +592,7 @@ IMPLEMENT_OPCODE(ResetAnimation) {
//////////////////////////////////////////////////////////////////////////
// Opcode 0x17
IMPLEMENT_OPCODE(DisableObject) {
- Object *object = _scene->worldstats()->getObjectById(cmd->param1);
+ Object *object = _scene->worldstats()->getObjectById((ObjectId)cmd->param1);
object->disable();
}
@@ -898,7 +898,7 @@ IMPLEMENT_OPCODE(PlayMovie) {
//////////////////////////////////////////////////////////////////////////
// Opcode 0x2E
IMPLEMENT_OPCODE(StopAllObjectsSounds) {
- Object *object = _scene->worldstats()->getObjectById(cmd->param1);
+ Object *object = _scene->worldstats()->getObjectById((ObjectId)cmd->param1);
object->stopAllSounds();
}
@@ -1047,7 +1047,7 @@ IMPLEMENT_OPCODE(IncrementParam2) {
//////////////////////////////////////////////////////////////////////////
// Opcode 0x3D
IMPLEMENT_OPCODE(WaitUntilFramePlayed) {
- Object *object = _scene->worldstats()->getObjectById(cmd->param1);
+ Object *object = _scene->worldstats()->getObjectById((ObjectId)cmd->param1);
int32 frameNum = cmd->param2;
if (frameNum == -1)
@@ -1082,7 +1082,7 @@ IMPLEMENT_OPCODE(UpdateWideScreen) {
//////////////////////////////////////////////////////////////////////////
// Opcode 0x3F
IMPLEMENT_OPCODE(JumpIfActor) {
- ActorIndex index = (cmd->param1 == -1) ? _scene->getPlayerActorIndex() : cmd->param1;
+ ActorIndex index = (cmd->param1 == kActorNone) ? _scene->getPlayerActorIndex() : cmd->param1;
if (_currentQueueEntry.actorIndex != index)
_currentLine = cmd->param2 - 1;
@@ -1299,8 +1299,10 @@ IMPLEMENT_OPCODE(_unk46) {
if (cmd->param5) {
_scene->getActor(cmd->param5)->updateStatus(kActorStatusEnabled);
} else if (cmd->param4 != cmd->param3 && cmd->param4) {
- _scene->worldstats()->getObjectById(cmd->param3)->disable();
- _scene->worldstats()->getObjectById(cmd->param4)->setNextFrame(_scene->worldstats()->getObjectById(cmd->param4)->flags);
+ _scene->worldstats()->getObjectById((ObjectId)cmd->param3)->disable();
+
+ Object *object = _scene->worldstats()->getObjectById((ObjectId)cmd->param4);
+ object->setNextFrame(object->flags);
}
_scene->vm()->clearGameFlag(kGameFlagScriptProcessing);
@@ -1319,10 +1321,10 @@ IMPLEMENT_OPCODE(_unk46) {
} else {
if (cmd->param4 != cmd->param3) {
if (cmd->param4)
- _scene->worldstats()->getObjectById(cmd->param4)->disable();
+ _scene->worldstats()->getObjectById((ObjectId)cmd->param4)->disable();
if (cmd->param3)
- _scene->worldstats()->getObjectById(cmd->param3)->setNextFrame(_scene->worldstats()->getObjectById(cmd->param4)->flags);
+ _scene->worldstats()->getObjectById((ObjectId)cmd->param3)->setNextFrame(_scene->worldstats()->getObjectById((ObjectId)cmd->param4)->flags);
}
cmd->param6 = 1;
@@ -1334,7 +1336,7 @@ IMPLEMENT_OPCODE(_unk46) {
//////////////////////////////////////////////////////////////////////////
// Opcode 0x47
IMPLEMENT_OPCODE(ActorFaceObject) {
- _scene->getActor(cmd->param1)->faceTarget(cmd->param2, (DirectionFrom)cmd->param3);
+ _scene->getActor(cmd->param1)->faceTarget((ObjectId)cmd->param2, (DirectionFrom)cmd->param3);
}
//////////////////////////////////////////////////////////////////////////
@@ -1449,7 +1451,7 @@ IMPLEMENT_OPCODE(Quit) {
//////////////////////////////////////////////////////////////////////////
// Opcode 0x51
IMPLEMENT_OPCODE(JumpObjectFrame) {
- Object *object = _scene->worldstats()->getObjectById(cmd->param1);
+ Object *object = _scene->worldstats()->getObjectById((ObjectId)cmd->param1);
if (cmd->param2 == -1)
cmd->param2 = object->getFrameCount() - 1;
@@ -1535,7 +1537,7 @@ IMPLEMENT_OPCODE(_unk55) {
//////////////////////////////////////////////////////////////////////////
// Opcode 0x56
IMPLEMENT_OPCODE(_unk56) {
- Actor *actor = _scene->getActor(cmd->param2 == 2 ? -1 : cmd->param1);
+ Actor *actor = _scene->getActor(cmd->param2 == 2 ? kActorNone : cmd->param1);
if (actor->getStatus() == kActorStatus2 || actor->getStatus() == kActorStatus13) {
if (cmd->param2 == 2)
@@ -1549,7 +1551,7 @@ IMPLEMENT_OPCODE(_unk56) {
_lineIncrement = 0;
if ((actor->x1 + actor->x2 == cmd->param6) && (actor->y1 + actor->y2 == cmd->param7)) {
- _scene->getActor()->faceTarget(cmd->param1, kDirectionFromActor);
+ _scene->getActor()->faceTarget((ObjectId)cmd->param1, kDirectionFromActor);
actor->updateFromDirection((actor->getDirection() + 4) & 7);
} else {
_currentLine = cmd->param3;
@@ -1587,7 +1589,7 @@ IMPLEMENT_OPCODE(SetResourcePalette) {
//////////////////////////////////////////////////////////////////////////
// Opcode 0x58
IMPLEMENT_OPCODE(SetObjectFrameIdxFlaged) {
- Object *object = _scene->worldstats()->getObjectById(cmd->param1);
+ Object *object = _scene->worldstats()->getObjectById((ObjectId)cmd->param1);
if (cmd->param3)
object->flags = 1 | object->flags;
@@ -1600,7 +1602,7 @@ IMPLEMENT_OPCODE(SetObjectFrameIdxFlaged) {
//////////////////////////////////////////////////////////////////////////
// Opcode 0x59
IMPLEMENT_OPCODE(_unk59) {
- Object *object = _scene->worldstats()->getObjectById(cmd->param1);
+ Object *object = _scene->worldstats()->getObjectById((ObjectId)cmd->param1);
if (cmd->param2) {
object->flags |= kObjectFlag40000;
@@ -1623,7 +1625,7 @@ IMPLEMENT_OPCODE(_unk5A) {
IMPLEMENT_OPCODE(_unk5B) {
if (cmd->param2 >= 0 && cmd->param2 <= 3) {
if (cmd->param1) {
- Object *object = _scene->worldstats()->getObjectById(cmd->param1);
+ Object *object = _scene->worldstats()->getObjectById((ObjectId)cmd->param1);
object->setField67C(cmd->param2);
@@ -1661,7 +1663,7 @@ IMPLEMENT_OPCODE(ClearActorFields) {
//////////////////////////////////////////////////////////////////////////
// Opcode 0x5F
IMPLEMENT_OPCODE(SetObjectLastFrameIdx) {
- Object *object = _scene->worldstats()->getObjectById(cmd->param1);
+ Object *object = _scene->worldstats()->getObjectById((ObjectId)cmd->param1);
if (object->getFrameIndex() == object->getFrameCount() - 1) {
_lineIncrement = 0;
@@ -1732,7 +1734,7 @@ void ActionList::enableObject(ScriptEntry *cmd, ObjectEnableType type) {
void ActionList::setActionFlag(ScriptEntry *cmd, ActionType flag) {
switch (cmd->param2) {
default:
- _scene->worldstats()->getObjectById(cmd->param1)->actionType |= flag;
+ _scene->worldstats()->getObjectById((ObjectId)cmd->param1)->actionType |= flag;
break;
case 1:
@@ -1748,7 +1750,7 @@ void ActionList::setActionFlag(ScriptEntry *cmd, ActionType flag) {
void ActionList::clearActionFlag(ScriptEntry *cmd, ActionType flag) {
switch (cmd->param2) {
default:
- _scene->worldstats()->getObjectById(cmd->param1)->actionType &= ~flag;
+ _scene->worldstats()->getObjectById((ObjectId)cmd->param1)->actionType &= ~flag;
break;
case 1:
@@ -1770,7 +1772,7 @@ void ActionList::jumpIfActionFlag(ScriptEntry *cmd, ActionType flag) {
break;
case 0:
- done = (_scene->worldstats()->getObjectById(cmd->param1)->actionType & flag) == 0;
+ done = (_scene->worldstats()->getObjectById((ObjectId)cmd->param1)->actionType & flag) == 0;
break;
case 1:
diff --git a/engines/asylum/resources/actor.cpp b/engines/asylum/resources/actor.cpp
index 62042db92b..0200227d22 100644
--- a/engines/asylum/resources/actor.cpp
+++ b/engines/asylum/resources/actor.cpp
@@ -24,6 +24,8 @@
*/
#include "asylum/resources/actor.h"
+
+#include "asylum/resources/actionlist.h"
#include "asylum/resources/encounters.h"
#include "asylum/resources/worldstats.h"
@@ -631,8 +633,8 @@ void Actor::updateFromDirection(ActorDirection actorDirection) {
}
}
-void Actor::faceTarget(int32 targetId, DirectionFrom from) {
- debugC(kDebugLevelActor, "[Actor::faceTarget] Facing target %d using direction from %d", targetId, from);
+void Actor::faceTarget(ObjectId id, DirectionFrom from) {
+ debugC(kDebugLevelActor, "[Actor::faceTarget] Facing target %d using direction from %d", id, from);
int32 newX, newY;
@@ -642,9 +644,9 @@ void Actor::faceTarget(int32 targetId, DirectionFrom from) {
return;
case kDirectionFromObject: {
- Object *object = getWorld()->getObjectById(targetId);
+ Object *object = getWorld()->getObjectById(id);
if (!object) {
- warning("[Actor::faceTarget] No Object found for id %d", targetId);
+ warning("[Actor::faceTarget] No Object found for id %d", id);
return;
}
@@ -661,9 +663,9 @@ void Actor::faceTarget(int32 targetId, DirectionFrom from) {
break;
case kDirectionFromPolygons: {
- int32 actionIndex = getWorld()->getActionAreaIndexById(targetId);
+ int32 actionIndex = getWorld()->getActionAreaIndexById(id);
if (actionIndex == -1) {
- warning("[Actor::faceTarget] No ActionArea found for id %d", targetId);
+ warning("[Actor::faceTarget] No ActionArea found for id %d", id);
return;
}
@@ -680,7 +682,7 @@ void Actor::faceTarget(int32 targetId, DirectionFrom from) {
break;
case kDirectionFromParameters:
- newX = newY = targetId;
+ newX = newY = id;
break;
}
diff --git a/engines/asylum/resources/actor.h b/engines/asylum/resources/actor.h
index 765f6492ff..91e2b29c25 100644
--- a/engines/asylum/resources/actor.h
+++ b/engines/asylum/resources/actor.h
@@ -167,7 +167,7 @@ public:
* @param target Identifier for the target.
* @param from direction to face from.
*/
- void faceTarget(int32 target, DirectionFrom from);
+ void faceTarget(ObjectId target, DirectionFrom from);
/**
* Initialize the x1/y1 values of the actor, update the active animation frame and, if the current direction isn't 8, update the actor's direction.
diff --git a/engines/asylum/resources/object.cpp b/engines/asylum/resources/object.cpp
index 15b465fa00..1245822808 100644
--- a/engines/asylum/resources/object.cpp
+++ b/engines/asylum/resources/object.cpp
@@ -26,6 +26,7 @@
#include "asylum/resources/object.h"
#include "asylum/resources/actor.h"
+#include "asylum/resources/special.h"
#include "asylum/views/scene.h"
@@ -41,7 +42,7 @@ Object::~Object() {
// Loading & destroying
/////////////////////////////////////////////////////////////////////////
void Object::load(Common::SeekableReadStream *stream) {
- _id = stream->readSint32LE();
+ _id = (ObjectId)stream->readSint32LE();
_resourceId = stream->readSint32LE();
x = stream->readSint32LE();
y = stream->readSint32LE();
@@ -322,7 +323,7 @@ void Object::update() {
if (doPlaySounds)
playSounds();
- getScene()->callSpecFunction(this, -1);
+ getScene()->special()->run(this, -1);
}
void Object::setNextFrame(int32 targetFlags) {
@@ -448,6 +449,8 @@ bool Object::checkFlags() {
Common::String Object::toString() {
Common::String output;
+ debugC(kDebugLevelObjects, "kObject%s = %d,", _name, _id);
+
output += Common::String::format("Object %d: %s\n", _id, _name);
return output;
diff --git a/engines/asylum/resources/object.h b/engines/asylum/resources/object.h
index 109e8844be..3be142675c 100644
--- a/engines/asylum/resources/object.h
+++ b/engines/asylum/resources/object.h
@@ -60,13 +60,14 @@ public:
uint32 getFrameIndex() { return _frameIndex; }
uint32 getFrameCount() { return _frameCount; }
FrameSoundItem *getFrameSoundItem(uint32 index) { assert(index < ARRAYSIZE(_frameSoundItems)); return &_frameSoundItems[index]; }
- int32 getId() { return _id; }
+ ObjectId getId() { return _id; }
int32 getPolygonIndex() { return _polygonIndex; }
int32 getPriority() { return _priority; }
ResourceId getResourceId() { return _resourceId; }
ResourceId getSoundResourceId() { return _soundResourceId; }
Common::Rect *getRect() { return &_rect; }
+ int32 getSoundY() { return _soundY; }
int32 getField67C() { return _field_67C; }
int32 getField688() { return _field_688; }
@@ -154,7 +155,7 @@ private:
//////////////////////////////////////////////////////////////////////////
// Data
//////////////////////////////////////////////////////////////////////////
- int32 _id;
+ ObjectId _id;
ResourceId _resourceId;
// x, y
Common::Rect _boundingRect;
diff --git a/engines/asylum/resources/special.cpp b/engines/asylum/resources/special.cpp
new file mode 100644
index 0000000000..fa88c55886
--- /dev/null
+++ b/engines/asylum/resources/special.cpp
@@ -0,0 +1,440 @@
+/* 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.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#include "asylum/resources/special.h"
+
+#include "asylum/resources/actor.h"
+#include "asylum/resources/object.h"
+#include "asylum/resources/encounters.h"
+
+#include "asylum/views/scene.h"
+
+#include "asylum/asylum.h"
+
+namespace Asylum {
+
+Special::Special(AsylumEngine *engine) : _vm(engine) {
+
+ // Counters
+ _chapter2Counter = 0;
+}
+
+Special::~Special() {}
+
+
+void Special::run(Object* object, ActorIndex index) {
+ //debugC(kDebugLevelSound, "[SPEC] Running special function for chapter %d",getWorld()->numChapter);
+
+ switch (getWorld()->numChapter) {
+ default:
+ error("[Special::runSpecial] Invalid chapter");
+
+ case kChapterNone:
+ // Nothing to do here
+ break;
+
+ case kChapter1:
+ chapter1(object, index);
+ break;
+
+ case kChapter2:
+ chapter2(object, index);
+ break;
+
+ case kChapter3:
+ chapter3(object, index);
+ break;
+
+ case kChapter4:
+ chapter4(object, index);
+ break;
+
+ case kChapter5:
+ chapter5(object, index);
+ break;
+
+ case kChapter6:
+ chapter6(object, index);
+ break;
+
+ case kChapter7:
+ chapter7(object, index);
+ break;
+
+ case kChapter8:
+ chapter8(object, index);
+ break;
+
+ case kChapter9:
+ chapter9(object, index);
+ break;
+ }
+}
+
+//////////////////////////////////////////////////////////////////////////
+// Update methods
+//////////////////////////////////////////////////////////////////////////
+void Special::updateActors_41FDF0() {
+ error("[Special::updateActors_41FDF0] not implemented!");
+}
+
+//////////////////////////////////////////////////////////////////////////
+// Spec functions
+//////////////////////////////////////////////////////////////////////////
+void Special::chapter1(Object *object, ActorIndex actorIndex) {
+ // Play chapter sound
+ playChapterSound(object, actorIndex);
+
+ if (actorIndex == kActorNone) {
+ switch (object->getId()) {
+ default:
+ break;
+
+ case kObjectHeadBanger:
+ if (object->getFrameIndex() == 2)
+ object->getFrameSoundItem(0)->resourceId = getWorld()->graphicResourceIds[rnd(2) ? 37 : 38];
+ break;
+
+ case kObjectAngelFlares:
+ if (object->getFrameIndex() == 5)
+ getSpeech()->play(81);
+ break;
+
+ case kObjectGuyFalls:
+ if (object->getFrameIndex() == 23)
+ getSpeech()->play(82);
+ break;
+ }
+ }
+}
+
+void Special::chapter2(Object *object, ActorIndex actorIndex) {
+ // Check objects
+ if (actorIndex == kActorNone) {
+ switch (object->getId()) {
+ default:
+ break;
+
+ case kObjectOpeningGate:
+ if (_vm->isGameFlagSet(kGameFlag1137)) {
+ _vm->clearGameFlag(kGameFlag1137);
+ updateActors_41FDF0();
+ }
+
+ if (_vm->isGameFlagSet(kGameFlag1131) && !getSound()->isPlaying(getSound()->soundResourceId)) {
+ _vm->clearGameFlag(kGameFlag219);
+ _vm->setGameFlag(kGameFlag1131);
+ }
+ break;
+
+ case kObjectCrow1FlysAway:
+ if (rnd(75) < 3)
+ checkOtherObject(object, kObjectCrow1Pecks, kGameFlag447, kGameFlag448);
+ break;
+
+ case kObjectCrow1Pecks:
+ checkObject(object, kGameFlag447, kGameFlag448, kObjectNone);
+ break;
+
+ case kObjectCrow2AmbientPecks:
+ checkObject(object, kGameFlag450, kGameFlag451);
+
+ case kObjectCrow2FlysAway:
+ if (rnd(50) < 3)
+ checkOtherObject(object, kObjectCrow2AmbientPecks, kGameFlag450, kGameFlag451);
+ break;
+
+ case kObjectCrow3FlysAway:
+ if (rnd(50) < 3)
+ checkOtherObject(object, kObjectCrow3Pecks, kGameFlag452, kGameFlag453);
+ break;
+
+ case kObjectCrow3Pecks:
+ checkObject(object, kGameFlag452, kGameFlag453);
+ break;
+
+ case kObjectCrow4FlysAway:
+ if (rnd(50) < 3)
+ checkOtherObject(object, kObjectCrow4Pecks, kGameFlag454, kGameFlag455);
+ break;
+
+ case kObjectCrow4Pecks:
+ checkObject(object, kGameFlag454, kGameFlag455);
+ }
+ }
+
+ // Check flags
+ if (_vm->isGameFlagSet(kGameFlag371)) {
+ _vm->clearGameFlag(kGameFlag371);
+
+ for (int i = 13; i < 22; i++) {
+ if (getScene()->getActor(i)->isVisible()) {
+ getScene()->setActorUpdateFlag(2);
+ break;
+ }
+ }
+
+ for (int i = 13; i < 22; i++)
+ getScene()->getActor(i)->updateStatus(kActorStatus15);
+ }
+
+ // Play chapter sound
+ playChapterSound(object, actorIndex);
+
+ // Check actors
+ Actor *actor = getScene()->getActor(actorIndex);
+ switch (actorIndex) {
+ default:
+ break;
+
+ case 13:
+ case 15:
+ case 17:
+ case 18:
+ if (actor->getStatus() == kActorStatus1) {
+ ++_chapter2Counter;
+
+ if (_chapter2Counter >= 5) {
+ _chapter2Counter = 0;
+ actor->updateFromDirection((actor->getDirection() + 1) % ~7); // TODO check
+ }
+ } else if (actor->getStatus() == kActorStatusEnabled) {
+ actor->updateStatus(kActorStatus1);
+ }
+ break;
+
+ case 22:
+ case 23:
+ case 24:
+ case 25:
+ case 26:
+ case 27:
+ case 28:
+ case 29:
+ if (actor->isVisible()) {
+ Object *obj386 = getWorld()->objects[386];
+
+ actor->x1 = obj386->getSoundY();
+ //actor->y1 = obj386->getField688() + ;
+
+
+ error("[Special::chapter2] Logic for actors 22-29 not implemented!");
+ }
+ break;
+
+ case 38:
+ case 39:
+ if (actor->getFrameIndex() == 9) {
+ actor->x1 = -1000;
+ actor->setFrameIndex(0);
+ }
+ break;
+
+ case 40:
+ if (actor->getFrameIndex() == 9) {
+ actor->x1 = -1000;
+ actor->setFrameIndex(0);
+
+ if (actor->isVisible())
+ if (getScene()->getActorUpdateFlag2() < 7)
+ getSpeech()->play(452);
+
+ _vm->setGameFlag(kGameFlag219);
+
+ actor->setVisible(false);
+ }
+ break;
+ }
+}
+
+void Special::chapter3(Object *object, ActorIndex actorIndex) {
+ playChapterSound(object, actorIndex);
+}
+
+void Special::chapter4(Object *object, ActorIndex actorIndex) {
+
+}
+
+void Special::chapter5(Object *object, ActorIndex actorIndex) {
+ playChapterSound(object, actorIndex);
+
+ if (actorIndex == kActorNone) {
+ switch (object->getId()) {
+ default:
+ break;
+
+ case kObjectNPC033StartEnc:
+ if (object->getFrameIndex() == 15)
+ _vm->setGameFlag(kGameFlag387);
+ break;
+
+ case kObjectNPC033GetBook:
+ if (object->getFrameIndex() == 6)
+ _vm->clearGameFlag(kGameFlag387);
+ break;
+ }
+ }
+}
+
+void Special::chapter6(Object *object, ActorIndex actorIndex) {
+ playChapterSound(object, actorIndex);
+
+ if (actorIndex == 2 || actorIndex == 3) {
+ Actor *actor = getScene()->getActor(actorIndex);
+
+ getWorld()->ambientSounds[0].x = actor->x2 + actor->x1;
+ getWorld()->ambientSounds[0].y = actor->y2 + actor->y1;
+ }
+}
+
+void Special::chapter7(Object *object, ActorIndex actorIndex) {
+
+}
+
+void Special::chapter8(Object *object, ActorIndex actorIndex) {
+
+}
+
+void Special::chapter9(Object *object, ActorIndex actorIndex) {
+
+}
+
+//////////////////////////////////////////////////////////////////////////
+// Sound logic
+//////////////////////////////////////////////////////////////////////////
+void Special::playChapterSound(Object *object, ActorIndex actorIndex) {
+ ResourceId id = getResourceId(object, actorIndex);
+
+ if (getEncounter()->getFlag(kEncounterFlag2) != 0)
+ return;
+
+ if (id != kResourceNone && getSound()->isPlaying(id))
+ return;
+
+ if (Config.performance <= 2)
+ return;
+
+ switch (getWorld()->numChapter) {
+ default:
+ error("[Special::playChapterSound] Invalid chapter");
+
+ case kChapterNone:
+ case kChapter5:
+ case kChapter9:
+ case kChapter10:
+ // Nothing to do here
+ break;
+
+ case kChapter1:
+ playSoundChapter1(object, actorIndex);
+ break;
+
+ case kChapter2:
+ playSoundChapter2(object, actorIndex);
+ break;
+
+ case kChapter3:
+ playSoundChapter3(object, actorIndex);
+ break;
+
+ case kChapter4:
+ playSoundChapter4(object, actorIndex);
+ break;
+
+ case kChapter6:
+ playSoundChapter6(object, actorIndex);
+ break;
+
+ case kChapter7:
+ playSoundChapter7(object, actorIndex);
+ break;
+
+ case kChapter8:
+ playSoundChapter8(object, actorIndex);
+ break;
+ }
+}
+
+void Special::playSoundChapter1(Object *object, ActorIndex actorIndex) {
+ error("[Special::playSoundChapter2] Not implemented!");
+}
+
+void Special::playSoundChapter2(Object *object, ActorIndex actorIndex) {
+ error("[Special::playSoundChapter2] Not implemented!");
+}
+
+void Special::playSoundChapter3(Object *object, ActorIndex actorIndex) {
+ error("[Special::playSoundChapter2] Not implemented!");
+}
+
+void Special::playSoundChapter4(Object *object, ActorIndex actorIndex) {
+ error("[Special::playSoundChapter2] Not implemented!");
+}
+
+void Special::playSoundChapter6(Object *object, ActorIndex actorIndex) {
+ error("[Special::playSoundChapter2] Not implemented!");
+}
+
+void Special::playSoundChapter7(Object *object, ActorIndex actorIndex) {
+ error("[Special::playSoundChapter2] Not implemented!");
+}
+
+void Special::playSoundChapter8(Object *object, ActorIndex actorIndex) {
+ error("[Special::playSoundChapter2] Not implemented!");
+}
+
+//////////////////////////////////////////////////////////////////////////
+// Helpers
+//////////////////////////////////////////////////////////////////////////
+ResourceId Special::getResourceId(Object *object, ActorIndex actorIndex) {
+ if (actorIndex == kActorNone && object == NULL)
+ error("[Special::getResourceId] Both arguments cannot be NULL/empty!");
+
+ return (actorIndex == kActorNone) ? object->getSoundResourceId() : getScene()->getActor(actorIndex)->getSoundResourceId();
+}
+
+void Special::checkObject(Object *object, GameFlag flagToSet, GameFlag flagToClear, ObjectId objectId) {
+ if (object->getFrameIndex() == 15) {
+ _vm->setGameFlag(flagToSet);
+ _vm->clearGameFlag(flagToClear);
+
+ if (objectId != kActorNone)
+ getWorld()->getObjectById(objectId)->setFrameIndex(0);
+ else
+ object->setFrameIndex(0);
+ }
+}
+
+void Special::checkOtherObject(Object *object, ObjectId otherObjectId, GameFlag flagToClear, GameFlag flagToSet) {
+ Object *otherObject = getWorld()->getObjectById(otherObjectId);
+
+ if (!otherObject->getFrameIndex() && !object->getFrameIndex()) {
+ _vm->clearGameFlag(flagToClear);
+ _vm->setGameFlag(flagToSet);
+ otherObject->setNextFrame(kObjectFlag8);
+ }
+}
+
+} // End of namespace Asylum
diff --git a/engines/asylum/resources/special.h b/engines/asylum/resources/special.h
new file mode 100644
index 0000000000..3faaf6766a
--- /dev/null
+++ b/engines/asylum/resources/special.h
@@ -0,0 +1,93 @@
+/* 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.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#ifndef ASYLUM_SPECIAL_H
+#define ASYLUM_SPECIAL_H
+
+#include "asylum/shared.h"
+
+#include "common/scummsys.h"
+
+namespace Asylum {
+
+class AsylumEngine;
+class Object;
+
+class Special {
+public:
+
+ Special(AsylumEngine *engine);
+ virtual ~Special();
+
+ void run(Object* object, ActorIndex index);
+
+ //////////////////////////////////////////////////////////////////////////
+ // Update methods
+ //////////////////////////////////////////////////////////////////////////
+ void updateActors_41FDF0();
+
+private:
+ AsylumEngine* _vm;
+
+ // Counters
+ int32 _chapter2Counter;
+
+ //////////////////////////////////////////////////////////////////////////
+ // Spec functions
+ //////////////////////////////////////////////////////////////////////////
+ void chapter1(Object *object, ActorIndex actorIndex);
+ void chapter2(Object *object, ActorIndex actorIndex);
+ void chapter3(Object *object, ActorIndex actorIndex);
+ void chapter4(Object *object, ActorIndex actorIndex);
+ void chapter5(Object *object, ActorIndex actorIndex);
+ void chapter6(Object *object, ActorIndex actorIndex);
+ void chapter7(Object *object, ActorIndex actorIndex);
+ void chapter8(Object *object, ActorIndex actorIndex);
+ void chapter9(Object *object, ActorIndex actorIndex);
+
+ //////////////////////////////////////////////////////////////////////////
+ // Sound logic
+ //////////////////////////////////////////////////////////////////////////
+ void playChapterSound(Object *object, ActorIndex actorIndex);
+ void playSoundChapter1(Object *object, ActorIndex actorIndex);
+ void playSoundChapter2(Object *object, ActorIndex actorIndex);
+ void playSoundChapter3(Object *object, ActorIndex actorIndex);
+ void playSoundChapter4(Object *object, ActorIndex actorIndex);
+ void playSoundChapter6(Object *object, ActorIndex actorIndex);
+ void playSoundChapter7(Object *object, ActorIndex actorIndex);
+ void playSoundChapter8(Object *object, ActorIndex actorIndex);
+
+ //////////////////////////////////////////////////////////////////////////
+ // Helpers
+ //////////////////////////////////////////////////////////////////////////
+ ResourceId getResourceId(Object *object, ActorIndex actorIndex);
+
+ void checkObject(Object *object, GameFlag flagToSet, GameFlag flagToClear, ObjectId objectId = kObjectInvalid);
+ void checkOtherObject(Object *object, ObjectId otherObjectId, GameFlag flagToClear, GameFlag flagToSet);
+};
+
+} // End of namespace Asylum
+
+#endif // ASYLUM_SPECIAL_H
diff --git a/engines/asylum/resources/worldstats.cpp b/engines/asylum/resources/worldstats.cpp
index b62c394bdc..55adc521be 100644
--- a/engines/asylum/resources/worldstats.cpp
+++ b/engines/asylum/resources/worldstats.cpp
@@ -55,17 +55,12 @@ ActionArea* WorldStats::getActionAreaById(int32 id) {
return actions[index];
}
-int32 WorldStats::getObjectIndexById(int32 id) {
- for (int32 i = 0; i < numObjects; i++) {
+Object* WorldStats::getObjectById(ObjectId id) {
+ for (int32 i = 0; i < numObjects; i++)
if (objects[i]->getId() == id)
- return i;
- }
-
- return -1;
-}
+ return objects[i];
-Object* WorldStats::getObjectById(int32 id) {
- return objects[getObjectIndexById(id)];
+ return NULL;
}
// FIXME: load necessary World Stats content
diff --git a/engines/asylum/resources/worldstats.h b/engines/asylum/resources/worldstats.h
index 611c5a3413..2cab4166ac 100644
--- a/engines/asylum/resources/worldstats.h
+++ b/engines/asylum/resources/worldstats.h
@@ -119,8 +119,7 @@ public:
int32 getActionAreaIndexById(int32 id);
ActionArea* getActionAreaById(int32 id);
- int32 getObjectIndexById(int32 id);
- Object* getObjectById(int32 id);
+ Object* getObjectById(ObjectId id);
private:
Scene *_scene;
diff --git a/engines/asylum/shared.h b/engines/asylum/shared.h
index ec9a254e93..3d1e40832b 100644
--- a/engines/asylum/shared.h
+++ b/engines/asylum/shared.h
@@ -43,6 +43,7 @@ enum GameFlag {
kGameFlag279 = 279,
kGameFlag368 = 368,
kGameFlag371 = 371,
+ kGameFlag387 = 387,
kGameFlag447 = 447,
kGameFlag448 = 448,
kGameFlag450 = 450,
@@ -57,6 +58,20 @@ enum GameFlag {
kGameFlag1137 = 1137
};
+enum ChapterIndex {
+ kChapterNone = 0,
+ kChapter1,
+ kChapter2,
+ kChapter3,
+ kChapter4,
+ kChapter5,
+ kChapter6,
+ kChapter7,
+ kChapter8,
+ kChapter9,
+ kChapter10
+};
+
//////////////////////////////////////////////////////////////////////////
// Resources
//////////////////////////////////////////////////////////////////////////
@@ -95,7 +110,7 @@ enum ActionType {
typedef int ActorIndex;
enum ActorIndexes {
- kActorPlayer = -1,
+ kActorNone = -1,
// TODO: check if the names match the actor type
kActorMax = 0,
kActorSarah = 1,
diff --git a/engines/asylum/views/scene.cpp b/engines/asylum/views/scene.cpp
index a6c3241525..553570801c 100644
--- a/engines/asylum/views/scene.cpp
+++ b/engines/asylum/views/scene.cpp
@@ -25,8 +25,10 @@
#include "asylum/views/scene.h"
+#include "asylum/resources/actionlist.h"
#include "asylum/resources/actor.h"
#include "asylum/resources/encounters.h"
+#include "asylum/resources/special.h"
#include "asylum/system/config.h"
@@ -111,6 +113,11 @@ Scene::Scene(uint8 sceneIdx, AsylumEngine *engine): _vm(engine) {
_title = new SceneTitle(this);
_titleLoaded = false;
+
+ _special = new Special(_vm);
+
+ _actorUpdateFlag = 0;
+ _actorUpdateFlag2 = 0;
}
void Scene::initialize() {
@@ -213,8 +220,13 @@ Scene::~Scene() {
delete _title;
}
-Actor* Scene::getActor(int index) {
- return _ws->actors[(index != -1) ? index : _playerActorIdx];
+Actor* Scene::getActor(ActorIndex index) {
+ ActorIndex computedIndex = (index != -1) ? index : _playerActorIdx;
+
+ if (computedIndex < 0 || computedIndex >= (int)_ws->actors.size())
+ error("[Scene::getActor] Invalid actor index: %d ([0-%d] allowed)", computedIndex, _ws->actors.size() - 1);
+
+ return _ws->actors[computedIndex];
}
void Scene::enterScene() {
@@ -1252,44 +1264,6 @@ void Scene::adjustActorPriority(ActorIndex index) {
error("[Scene::adjustActorPriority] not implemented");
}
-//////////////////////////////////////////////////////////////////////////
-// Spec functions
-//////////////////////////////////////////////////////////////////////////
-void Scene::specChapter1(Object *object, ActorIndex actorIndex) {
- if (actorIndex == -1 && object == NULL)
- error("[Scene::specChapter1] Both arguments cannot be empty!");
-
- ResourceId id = (actorIndex == -1) ? object->getSoundResourceId() : getActor(actorIndex)->getSoundResourceId();
-
- if (!_vm->encounter()->getFlag(kEncounterFlag2)) {
- if (!id || !getSound()->isPlaying(id))
- if (Config.performance > 2)
- error("[Scene::specChapter1] Sound function not implemented!");
- }
-
- if (actorIndex == -1) {
- switch (object->getId()) {
- default:
- break;
-
- case 101:
- if (object->getFrameIndex() == 2)
- object->getFrameSoundItem(0)->resourceId = _ws->graphicResourceIds[rnd(2) ? 37 : 38];
- break;
-
- case 112:
- if (object->getFrameIndex() == 5)
- getSpeech()->play(81);
- break;
-
- case 434:
- if (object->getFrameIndex() == 23)
- getSpeech()->play(82);
- break;
- }
- }
-}
-
//////////////////////////////////////////////////////////////////////////
// Helpers
//////////////////////////////////////////////////////////////////////////
@@ -1467,33 +1441,6 @@ void Scene::resetActor0() {
error("[Scene::resetActor0] not implemented!");
}
-void Scene::callSpecFunction(Object* object, ActorIndex index) {
- // The original uses a function array, we just use switch for now there is only 11 entries
- switch (_ws->numChapter) {
- default:
- error("[Scene::callSpecFunction] Invalid chapter");
-
- case 0:
- // Nothing to do here
- break;
-
- case 1:
- break;
-
- case 2:
- case 3:
- case 4:
- case 5:
- case 6:
- case 7:
- case 8:
- case 9:
- case 10:
- error("[Scene::callSpecFunction] No implemented!");
- break;
- }
-}
-
//////////////////////////////////////////////////////////////////////////
// SceneTitle
//////////////////////////////////////////////////////////////////////////
diff --git a/engines/asylum/views/scene.h b/engines/asylum/views/scene.h
index 0330e7d095..2016f207ff 100644
--- a/engines/asylum/views/scene.h
+++ b/engines/asylum/views/scene.h
@@ -31,7 +31,6 @@
#include "asylum/system/graphics.h"
#include "asylum/resources/worldstats.h"
#include "asylum/resources/polygons.h"
-#include "asylum/resources/actionlist.h"
#include "asylum/system/text.h"
#include "asylum/system/cursor.h"
#include "asylum/system/speech.h"
@@ -45,15 +44,17 @@
namespace Asylum {
class ActionList;
+//class BlowUpPuzzle;
+class Cursor;
class Screen;
+class Special;
+class Speech;
class Sound;
-class Video;
-class Cursor;
class Text;
-//class BlowUpPuzzle;
-struct ObjectItem;
+class Video;
class WorldStats;
-class Speech;
+
+struct ObjectItem;
enum HitType {
kHitNone = -1,
@@ -116,6 +117,7 @@ public:
void setScenePosition(int x, int y);
AsylumEngine* vm() { return _vm; }
+ Special *special() { return _special; }
WorldStats* worldstats() { return _ws; }
Polygons* polygons() { return _polygons; }
ActionList* actions() { return _actions; }
@@ -139,7 +141,7 @@ public:
* WorldStats actor list. Default parameter just
* gets the instance associated with _playerActorIdx
*/
- Actor* getActor(ActorIndex index = kActorPlayer);
+ Actor* getActor(ActorIndex index = kActorNone);
/** .text:00407260
* Check the actor at actorIndex to see if the currently loaded
@@ -185,9 +187,15 @@ public:
// Shared methods
void resetActor0();
- void callSpecFunction(Object* object, ActorIndex index);
+ int32 getActorUpdateFlag() { return _actorUpdateFlag; }
+ void setActorUpdateFlag(int32 val) { _actorUpdateFlag = val; }
+
+ int32 getActorUpdateFlag2() { return _actorUpdateFlag2; }
+ void setActorUpdateFlag2(int32 val) { _actorUpdateFlag2 = val; }
+
+ ResourceId savedResourceIds[11]; // TODO are those really resource ids?
- /** .text:00408980
+ /** .text:00408980
* Determine if the supplied point intersects
* an action area's active region
*/
@@ -248,6 +256,7 @@ private:
Cursor *_cursor;
ResourcePack *_resPack;
ResourcePack *_musPack;
+ Special *_special;
//BlowUpPuzzle *_blowUp;
GraphicResource *_bgResource;
@@ -267,6 +276,9 @@ private:
Common::Array<UpdateItem> _updateList;
+ int32 _actorUpdateFlag;
+ int32 _actorUpdateFlag2;
+
void update();
void startMusic();
@@ -319,11 +331,6 @@ private:
void checkVisibleActorsPriority();
void adjustActorPriority(ActorIndex index);
- //////////////////////////////////////////////////////////////////////////
- // Spec functions
- //////////////////////////////////////////////////////////////////////////
- void specChapter1(Object *object, ActorIndex actorIndex);
-
//////////////////////////////////////////////////////////////////////////
// Helpers
//////////////////////////////////////////////////////////////////////////
Commit: 9249130d59a6605e8a5755fdb13d5b7de70176a1
https://github.com/scummvm/scummvm/commit/9249130d59a6605e8a5755fdb13d5b7de70176a1
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:10+02:00
Commit Message:
ASYLUM: Check that a scene exists before trying to load it
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@489 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/asylum.cpp
engines/asylum/console.cpp
diff --git a/engines/asylum/asylum.cpp b/engines/asylum/asylum.cpp
index 4fc6fed96b..e418716c45 100644
--- a/engines/asylum/asylum.cpp
+++ b/engines/asylum/asylum.cpp
@@ -311,6 +311,10 @@ void AsylumEngine::processDelayedEvents() {
// XXX Flag 183 indicates whether the actionlist is currently
// processing
if (sceneIdx >= 0 && isGameFlagNotSet(kGameFlagScriptProcessing)) {
+
+ // Reset delayed scene
+ _scene->actions()->setDelayedSceneIndex(-1);
+
_sound->stopMusic();
_sound->stopAllSounds();
@@ -319,8 +323,6 @@ void AsylumEngine::processDelayedEvents() {
_scene = new Scene(sceneIdx, this);
_scene->enterScene();
-
- _scene->actions()->setDelayedSceneIndex(-1);
}
}
diff --git a/engines/asylum/console.cpp b/engines/asylum/console.cpp
index a8a813760b..09252a6ddf 100644
--- a/engines/asylum/console.cpp
+++ b/engines/asylum/console.cpp
@@ -280,12 +280,17 @@ bool Console::cmdChangeScene(int32 argc, const char **argv) {
return true;
}
- if (atoi(argv[1]) - 4 < 1 || atoi(argv[1]) - 4 >= 15) {
- DebugPrintf("[Error] Invalid world: %d\n", atoi(argv[1]));
+ int index = atoi(argv[1]);
+
+ // Check if the scene exists
+ char filename[20];
+ sprintf(filename, "scn.%03d", index);
+ if (!SearchMan.hasFile(filename)) {
+ DebugPrintf("[Error] Scene %d does not exists\n", index);
return true;
}
- _vm->scene()->actions()->setDelayedSceneIndex(atoi(argv[1]));
+ _vm->scene()->actions()->setDelayedSceneIndex(index);
// FIXME push the script index into the script queue
// XXX is this right or should it be ws->actionListIdx???
//_vm->scene()->actions()->setScriptByIndex(0);
Commit: 9eb5d19d3b0b96cce7ebc0c197734435a8fef375
https://github.com/scummvm/scummvm/commit/9eb5d19d3b0b96cce7ebc0c197734435a8fef375
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:10+02:00
Commit Message:
ASYLUM: Implement Object::setVolume()
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@490 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/resources/object.cpp
engines/asylum/resources/object.h
diff --git a/engines/asylum/resources/object.cpp b/engines/asylum/resources/object.cpp
index 1245822808..093142d4b6 100644
--- a/engines/asylum/resources/object.cpp
+++ b/engines/asylum/resources/object.cpp
@@ -390,7 +390,7 @@ void Object::playSounds() {
}
}
- //warning("[Object::playSounds] not implemented!");
+ setVolume();
}
void Object::updateSoundItems() {
@@ -423,6 +423,21 @@ void Object::stopAllSounds() {
}
}
+void Object::setVolume() {
+ if (!_soundResourceId || !getSound()->isPlaying(_soundResourceId))
+ return;
+
+ GraphicResource *resource = new GraphicResource(getScene()->getResourcePack(), _resourceId);
+ GraphicFrame *frame = resource->getFrame(_frameIndex);
+
+ // Compute volume
+ int32 volume = Config.voiceVolume + getSound()->calculateVolumeAdjustement((frame->getWidth() >> 1) + x, (frame->getHeight() >> 1) + y, _field_6A4, 0);
+ if (volume < -10000)
+ volume = -10000;
+
+ getSound()->setVolume(_soundResourceId, volume);
+}
+
int32 Object::getRandomResourceId() {
// Initialize random resource id array
ResourceId shuffle[5];
diff --git a/engines/asylum/resources/object.h b/engines/asylum/resources/object.h
index 3be142675c..f6f64f4e5e 100644
--- a/engines/asylum/resources/object.h
+++ b/engines/asylum/resources/object.h
@@ -211,6 +211,11 @@ private:
*/
void stopSound();
+ /**
+ * Sets the volume.
+ */
+ void setVolume();
+
/**
* Gets a random resource identifier for this object (using the list in _randomResourceIds)
*
Commit: dd6afe7523b7e01ef3274ae2bc98562914cb9999
https://github.com/scummvm/scummvm/commit/dd6afe7523b7e01ef3274ae2bc98562914cb9999
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:10+02:00
Commit Message:
ASYLUM: Use subsystems access macros in ActionList
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@491 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/resources/actionlist.cpp
engines/asylum/resources/actionlist.h
engines/asylum/resources/actor.cpp
engines/asylum/shared.h
engines/asylum/views/scene.cpp
engines/asylum/views/scene.h
diff --git a/engines/asylum/resources/actionlist.cpp b/engines/asylum/resources/actionlist.cpp
index 722b184ea8..a86eb38755 100644
--- a/engines/asylum/resources/actionlist.cpp
+++ b/engines/asylum/resources/actionlist.cpp
@@ -38,7 +38,7 @@
namespace Asylum {
-ActionList::ActionList(Common::SeekableReadStream *stream, Scene *scene) : _scene(scene) {
+ActionList::ActionList(AsylumEngine *engine) : _vm(engine) {
// Build list of opcodes
ADD_OPCODE(Return);
ADD_OPCODE(SetGameFlag);
@@ -141,12 +141,59 @@ ActionList::ActionList(Common::SeekableReadStream *stream, Scene *scene) : _scen
ADD_OPCODE(ShowOptionsScreen);
ADD_OPCODE(_unk63);
+ reset();
+}
+
+ActionList::~ActionList() {
+ for (int i = 0; i < (int)_opcodes.size(); i++)
+ delete _opcodes[i];
+
+ _scripts.clear();
+ _queue.clear();
+
+ // Zero-out passed pointers
+ _vm = NULL;
+}
+
+void ActionList::load(Common::SeekableReadStream *stream) {
+ stream->readSint32LE(); // size
+ int32 numEntries = stream->readSint32LE();
+
+ for (int32 a = 0; a < numEntries; a++) {
+ Script script;
+ memset(&script, 0, sizeof(Script));
+
+ for (int32 c = 0; c < MAX_ACTION_COMMANDS; c++) {
+ ScriptEntry command;
+ memset(&command, 0, sizeof(ScriptEntry));
+
+ command.numLines = stream->readSint32LE();
+ command.opcode = stream->readSint32LE();
+ command.param1 = stream->readSint32LE();
+ command.param2 = stream->readSint32LE();
+ command.param3 = stream->readSint32LE();
+ command.param4 = stream->readSint32LE();
+ command.param5 = stream->readSint32LE();
+ command.param6 = stream->readSint32LE();
+ command.param7 = stream->readSint32LE();
+ command.param8 = stream->readSint32LE();
+ command.param9 = stream->readSint32LE();
+
+ script.commands[c] = command;
+ }
+
+ script.field_1BAC = stream->readSint32LE();
+ script.field_1BB0 = stream->readSint32LE();
+ script.counter = stream->readSint32LE();
+
+ _scripts.push_back(script);
+ }
+}
+
+void ActionList::reset() {
// Reset script queue
resetQueue();
- // Load data
- load(stream);
-
_skipProcessing = false;
_currentLine = 0;
_currentLoops = 0;
@@ -159,17 +206,6 @@ ActionList::ActionList(Common::SeekableReadStream *stream, Scene *scene) : _scen
_waitCycle = false;
}
-ActionList::~ActionList() {
- for (int i = 0; i < (int)_opcodes.size(); i++)
- delete _opcodes[i];
-
- _scripts.clear();
- _queue.clear();
-
- // Zero-out passed pointers
- _scene = NULL;
-}
-
void ActionList::resetQueue() {
_queue.clear();
}
@@ -200,7 +236,7 @@ bool ActionList::process() {
_waitCycle = false;
_lineIncrement = 1;
- _scene->vm()->setGameFlag(kGameFlagScriptProcessing);
+ _vm->setGameFlag(kGameFlagScriptProcessing);
if (_currentScript) {
while (!_done && !_waitCycle) {
@@ -237,46 +273,11 @@ bool ActionList::process() {
}
}
- _scene->vm()->clearGameFlag(kGameFlagScriptProcessing);
+ _vm->clearGameFlag(kGameFlagScriptProcessing);
return false;
}
-void ActionList::load(Common::SeekableReadStream *stream) {
- stream->readSint32LE(); // size
- int32 numEntries = stream->readSint32LE();
-
- for (int32 a = 0; a < numEntries; a++) {
- Script script;
- memset(&script, 0, sizeof(Script));
-
- for (int32 c = 0; c < MAX_ACTION_COMMANDS; c++) {
- ScriptEntry command;
- memset(&command, 0, sizeof(ScriptEntry));
-
- command.numLines = stream->readSint32LE();
- command.opcode = stream->readSint32LE();
- command.param1 = stream->readSint32LE();
- command.param2 = stream->readSint32LE();
- command.param3 = stream->readSint32LE();
- command.param4 = stream->readSint32LE();
- command.param5 = stream->readSint32LE();
- command.param6 = stream->readSint32LE();
- command.param7 = stream->readSint32LE();
- command.param8 = stream->readSint32LE();
- command.param9 = stream->readSint32LE();
-
- script.commands[c] = command;
- }
-
- script.field_1BAC = stream->readSint32LE();
- script.field_1BB0 = stream->readSint32LE();
- script.counter = stream->readSint32LE();
-
- _scripts.push_back(script);
- }
-}
-
//////////////////////////////////////////////////////////////////////////
// Opcode Functions
//////////////////////////////////////////////////////////////////////////
@@ -294,7 +295,7 @@ IMPLEMENT_OPCODE(SetGameFlag) {
GameFlag flagNum = (GameFlag)cmd->param1;
if (flagNum >= 0)
- _scene->vm()->setGameFlag(flagNum);
+ _vm->setGameFlag(flagNum);
}
//////////////////////////////////////////////////////////////////////////
@@ -303,7 +304,7 @@ IMPLEMENT_OPCODE(ClearGameFlag) {
GameFlag flagNum = (GameFlag)cmd->param1;
if (flagNum >= 0)
- _scene->vm()->clearGameFlag(flagNum);
+ _vm->clearGameFlag(flagNum);
}
//////////////////////////////////////////////////////////////////////////
@@ -312,7 +313,7 @@ IMPLEMENT_OPCODE(ToggleGameFlag) {
GameFlag flagNum = (GameFlag)cmd->param1;
if (flagNum >= 0)
- _scene->vm()->toggleGameFlag(flagNum);
+ _vm->toggleGameFlag(flagNum);
}
//////////////////////////////////////////////////////////////////////////
@@ -321,7 +322,7 @@ IMPLEMENT_OPCODE(JumpIfGameFlag) {
if (cmd->param1 < 0)
return;
- bool doJump = (cmd->param2) ? _scene->vm()->isGameFlagSet((GameFlag)cmd->param1) : _scene->vm()->isGameFlagNotSet((GameFlag)cmd->param1);
+ bool doJump = (cmd->param2) ? _vm->isGameFlagSet((GameFlag)cmd->param1) : _vm->isGameFlagNotSet((GameFlag)cmd->param1);
if (!doJump)
return;
@@ -331,21 +332,21 @@ IMPLEMENT_OPCODE(JumpIfGameFlag) {
//////////////////////////////////////////////////////////////////////////
// Opcode 0x05
IMPLEMENT_OPCODE(HideCursor) {
- _scene->getCursor()->hide();
+ getCursor()->hide();
}
//////////////////////////////////////////////////////////////////////////
// Opcode 0x06
IMPLEMENT_OPCODE(ShowCursor) {
- _scene->getCursor()->show();
+ getCursor()->show();
- _scene->vm()->clearFlag(kFlagType1);
+ _vm->clearFlag(kFlagType1);
}
//////////////////////////////////////////////////////////////////////////
// Opcode 0x07
IMPLEMENT_OPCODE(PlayAnimation) {
- Object *object = _scene->worldstats()->getObjectById((ObjectId)cmd->param1);
+ Object *object = getWorld()->getObjectById((ObjectId)cmd->param1);
if (cmd->param2 == 2) {
if (object->checkFlags())
@@ -374,14 +375,14 @@ IMPLEMENT_OPCODE(PlayAnimation) {
if (object->getField688() == 1) {
if (object->flags & kObjectFlag4) {
- _scene->setGlobalX(object->x);
- _scene->setGlobalY(object->y);
+ getScene()->setGlobalX(object->x);
+ getScene()->setGlobalY(object->y);
} else {
- GraphicResource *res = new GraphicResource(_scene->getResourcePack(), object->getResourceId());
+ GraphicResource *res = new GraphicResource(getScene()->getResourcePack(), object->getResourceId());
GraphicFrame *frame = res->getFrame(object->getFrameIndex());
- _scene->setGlobalX(frame->x + (frame->getWidth() >> 1) + object->x);
- _scene->setGlobalY(frame->y + (frame->getHeight() >> 1) + object->y);
+ getScene()->setGlobalX(frame->x + (frame->getWidth() >> 1) + object->x);
+ getScene()->setGlobalY(frame->y + (frame->getHeight() >> 1) + object->y);
delete res;
}
@@ -397,27 +398,27 @@ IMPLEMENT_OPCODE(PlayAnimation) {
// Opcode 0x08
IMPLEMENT_OPCODE(MoveScenePosition) {
if (cmd->param3 < 1) {
- _scene->worldstats()->xLeft = cmd->param1;
- _scene->worldstats()->yTop = cmd->param2;
- _scene->worldstats()->motionStatus = 3;
+ getWorld()->xLeft = cmd->param1;
+ getWorld()->yTop = cmd->param2;
+ getWorld()->motionStatus = 3;
} else if (!cmd->param4) {
- _scene->worldstats()->motionStatus = 5;
+ getWorld()->motionStatus = 5;
- _scene->updateSceneCoordinates(cmd->param1,
+ getScene()->updateSceneCoordinates(cmd->param1,
cmd->param2,
cmd->param3);
} else if (cmd->param5) {
- if (_scene->worldstats()->motionStatus == 2)
+ if (getWorld()->motionStatus == 2)
_lineIncrement = 1;
else
cmd->param5 = 0;
} else {
cmd->param5 = 1;
- _scene->worldstats()->motionStatus = 2;
+ getWorld()->motionStatus = 2;
- _scene->updateSceneCoordinates(cmd->param1,
+ getScene()->updateSceneCoordinates(cmd->param1,
cmd->param2,
cmd->param3,
true);
@@ -429,7 +430,7 @@ IMPLEMENT_OPCODE(MoveScenePosition) {
//////////////////////////////////////////////////////////////////////////
// Opcode 0x09
IMPLEMENT_OPCODE(HideActor) {
- Actor *actor = _scene->getActor(cmd->param1);
+ Actor *actor = getScene()->getActor(cmd->param1);
actor->setVisible(false);
actor->updateDirection();
@@ -438,17 +439,17 @@ IMPLEMENT_OPCODE(HideActor) {
//////////////////////////////////////////////////////////////////////////
// Opcode 0x0A
IMPLEMENT_OPCODE(ShowActor) {
- Actor *actor = _scene->getActor(cmd->param1);
+ Actor *actor = getScene()->getActor(cmd->param1);
actor->setVisible(true);
actor->updateDirection();
- actor->setLastScreenUpdate(_scene->vm()->getTick());
+ actor->setLastScreenUpdate(_vm->getTick());
}
//////////////////////////////////////////////////////////////////////////
// Opcode 0x0B
IMPLEMENT_OPCODE(SetActorPosition) {
- Actor *actor = _scene->getActor(cmd->param1);
+ Actor *actor = getScene()->getActor(cmd->param1);
actor->setPosition(cmd->param2, cmd->param3, cmd->param4, cmd->param5);
}
@@ -456,13 +457,13 @@ IMPLEMENT_OPCODE(SetActorPosition) {
//////////////////////////////////////////////////////////////////////////
// Opcode 0x0C
IMPLEMENT_OPCODE(SetSceneMotionStatus) {
- _scene->worldstats()->motionStatus = cmd->param1;
+ getWorld()->motionStatus = cmd->param1;
}
//////////////////////////////////////////////////////////////////////////
// Opcode 0x0D
IMPLEMENT_OPCODE(DisableActor) {
- Actor *actor = _scene->getActor(cmd->param1);
+ Actor *actor = getScene()->getActor(cmd->param1);
actor->updateStatus(kActorStatusDisabled);
}
@@ -470,7 +471,7 @@ IMPLEMENT_OPCODE(DisableActor) {
//////////////////////////////////////////////////////////////////////////
// Opcode 0x0E
IMPLEMENT_OPCODE(EnableActor) {
- Actor *actor = _scene->getActor(cmd->param1);
+ Actor *actor = getScene()->getActor(cmd->param1);
if (actor->getStatus() == kActorStatusDisabled)
actor->updateStatus(kActorStatusEnabled);
@@ -479,10 +480,10 @@ IMPLEMENT_OPCODE(EnableActor) {
//////////////////////////////////////////////////////////////////////////
// Opcode 0x0F
IMPLEMENT_OPCODE(EnableObjects) {
- Object *object = _scene->worldstats()->getObjectById((ObjectId)cmd->param1);
+ Object *object = getWorld()->getObjectById((ObjectId)cmd->param1);
- if (!_currentScript->counter && _scene->worldstats()->numChapter != 13)
- _scene->vm()->sound()->playSound(cmd->param3 ? kResourceSound_80120006 : kResourceSound_80120001, false, Config.sfxVolume, 0);
+ if (!_currentScript->counter && getWorld()->numChapter != 13)
+ _vm->sound()->playSound(cmd->param3 ? kResourceSound_80120006 : kResourceSound_80120001, false, Config.sfxVolume, 0);
if (_currentScript->counter >= (3 * cmd->param2 - 1)) {
_currentScript->counter = 0;
@@ -511,7 +512,7 @@ IMPLEMENT_OPCODE(RemoveObject) {
if (!cmd->param1)
return;
- Object *object = _scene->worldstats()->getObjectById((ObjectId)cmd->param1);
+ Object *object = getWorld()->getObjectById((ObjectId)cmd->param1);
object->disableAndRemoveFromQueue();
}
@@ -519,7 +520,7 @@ IMPLEMENT_OPCODE(RemoveObject) {
//////////////////////////////////////////////////////////////////////////
// Opcode 0x12
IMPLEMENT_OPCODE(JumpActorSpeech) {
- Actor *actor = _scene->getActor(cmd->param1);
+ Actor *actor = getScene()->getActor(cmd->param1);
if (actor->process(cmd->param2, cmd->param3))
return;
@@ -527,13 +528,13 @@ IMPLEMENT_OPCODE(JumpActorSpeech) {
_currentLine = cmd->param4;
if (cmd->param5)
- _scene->playSpeech(1);
+ getScene()->playSpeech(1);
}
//////////////////////////////////////////////////////////////////////////
// Opcode 0x13
IMPLEMENT_OPCODE(JumpAndSetDirection) {
- Actor *actor = _scene->getActor(cmd->param1);
+ Actor *actor = getScene()->getActor(cmd->param1);
if (actor->getStatus() != kActorStatus2 && actor->getStatus() != kActorStatus13) {
if (cmd->param5 != 2) {
@@ -566,7 +567,7 @@ IMPLEMENT_OPCODE(JumpAndSetDirection) {
//////////////////////////////////////////////////////////////////////////
// Opcode 0x14
IMPLEMENT_OPCODE(JumpIfActorCoordinates) {
- Actor *actor = _scene->getActor(cmd->param1);
+ Actor *actor = getScene()->getActor(cmd->param1);
if ((actor->x1 + actor->x2) != cmd->param2 || (actor->y1 + actor->y2) != cmd->param3)
_lineIncrement = cmd->param4;
@@ -581,7 +582,7 @@ IMPLEMENT_OPCODE(Nop) {
//////////////////////////////////////////////////////////////////////////
// Opcode 0x16
IMPLEMENT_OPCODE(ResetAnimation) {
- Object *object = _scene->worldstats()->getObjectById((ObjectId)cmd->param1);
+ Object *object = getWorld()->getObjectById((ObjectId)cmd->param1);
if (object->flags & kObjectFlag10000)
object->setFrameIndex(object->getFrameCount() - 1);
@@ -592,7 +593,7 @@ IMPLEMENT_OPCODE(ResetAnimation) {
//////////////////////////////////////////////////////////////////////////
// Opcode 0x17
IMPLEMENT_OPCODE(DisableObject) {
- Object *object = _scene->worldstats()->getObjectById((ObjectId)cmd->param1);
+ Object *object = getWorld()->getObjectById((ObjectId)cmd->param1);
object->disable();
}
@@ -601,13 +602,13 @@ IMPLEMENT_OPCODE(DisableObject) {
// Opcode 0x18
IMPLEMENT_OPCODE(JumpIfSoundPlayingAndPlaySound) {
if (cmd->param2 == 2) {
- if (_scene->vm()->sound()->isPlaying(cmd->param1))
+ if (_vm->sound()->isPlaying(cmd->param1))
_lineIncrement = 1;
else
cmd->param2 = 1;
- } else if (!_scene->vm()->sound()->isPlaying(cmd->param1)) {
- int32 vol = _scene->vm()->sound()->getAdjustedVolume(abs(Config.sfxVolume));
- _scene->vm()->sound()->playSound(cmd->param1, cmd->param4, -((abs(cmd->param3) + vol) * (abs(cmd->param3) + vol)), 0);
+ } else if (!_vm->sound()->isPlaying(cmd->param1)) {
+ int32 vol = _vm->sound()->getAdjustedVolume(abs(Config.sfxVolume));
+ _vm->sound()->playSound(cmd->param1, cmd->param4, -((abs(cmd->param3) + vol) * (abs(cmd->param3) + vol)), 0);
if (cmd->param2 == 1) {
cmd->param2 = 2;
@@ -673,7 +674,7 @@ IMPLEMENT_OPCODE(ClearActionTalk) {
//////////////////////////////////////////////////////////////////////////
// Opcode 0x22
IMPLEMENT_OPCODE(_unk22) {
- Actor *actor = _scene->getActor(cmd->param3 ? cmd->param3 : _currentQueueEntry.actorIndex);
+ Actor *actor = getScene()->getActor(cmd->param3 ? cmd->param3 : _currentQueueEntry.actorIndex);
actor->process_41BC00(cmd->param1, cmd->param2);
}
@@ -681,7 +682,7 @@ IMPLEMENT_OPCODE(_unk22) {
//////////////////////////////////////////////////////////////////////////
// Opcode 0x23
IMPLEMENT_OPCODE(_unk23) {
- Actor *actor = _scene->getActor(cmd->param3 ? cmd->param3 : _currentQueueEntry.actorIndex);
+ Actor *actor = getScene()->getActor(cmd->param3 ? cmd->param3 : _currentQueueEntry.actorIndex);
actor->process_41BCC0(cmd->param1, cmd->param2);
}
@@ -689,7 +690,7 @@ IMPLEMENT_OPCODE(_unk23) {
//////////////////////////////////////////////////////////////////////////
// Opcode 0x24
IMPLEMENT_OPCODE(_unk24) {
- Actor *actor = _scene->getActor(cmd->param4 ? cmd->param4 : _currentQueueEntry.actorIndex);
+ Actor *actor = getScene()->getActor(cmd->param4 ? cmd->param4 : _currentQueueEntry.actorIndex);
actor->process_41BDB0(cmd->param1, cmd->param3);
}
@@ -697,7 +698,7 @@ IMPLEMENT_OPCODE(_unk24) {
//////////////////////////////////////////////////////////////////////////
// Opcode 0x25
IMPLEMENT_OPCODE(RunEncounter) {
- Encounter *encounter = _scene->vm()->encounter();
+ Encounter *encounter = _vm->encounter();
encounter->setFlag(kEncounterFlag5, cmd->param5);
@@ -735,7 +736,7 @@ IMPLEMENT_OPCODE(ClearAction16) {
//////////////////////////////////////////////////////////////////////////
// Opcode 0x29
IMPLEMENT_OPCODE(SetActorField638) {
- Actor *actor = _scene->getActor(cmd->param1);
+ Actor *actor = getScene()->getActor(cmd->param1);
actor->setField638(cmd->param2);
}
@@ -743,7 +744,7 @@ IMPLEMENT_OPCODE(SetActorField638) {
//////////////////////////////////////////////////////////////////////////
// Opcode 0x2A
IMPLEMENT_OPCODE(JumpIfActorField638) {
- Actor *actor = _scene->getActor(cmd->param1);
+ Actor *actor = getScene()->getActor(cmd->param1);
if (actor->getField638())
_currentLine = cmd->param3;
@@ -752,15 +753,15 @@ IMPLEMENT_OPCODE(JumpIfActorField638) {
//////////////////////////////////////////////////////////////////////////
// Opcode 0x2B
IMPLEMENT_OPCODE(ChangeScene) {
- _scene->getActor(0)->updateStatus(kActorStatusDisabled);
+ getScene()->getActor(0)->updateStatus(kActorStatusDisabled);
resetQueue();
// Fade screen to black
- _scene->vm()->screen()->paletteFade(0, 75, 8);
- _scene->vm()->screen()->clearScreen();
+ getScreen()->paletteFade(0, 75, 8);
+ getScreen()->clearScreen();
// Stop all sounds & music
- _scene->vm()->sound()->stopAllSounds(true);
+ _vm->sound()->stopAllSounds(true);
// Change the scene number
_delayedSceneIndex = cmd->param1 + 4;
@@ -771,8 +772,8 @@ IMPLEMENT_OPCODE(ChangeScene) {
//////////////////////////////////////////////////////////////////////////
// Opcode 0x2C
IMPLEMENT_OPCODE(_unk2C_ActorSub) {
- Actor *player = _scene->getActor();
- Actor *actor = _scene->getActor(_currentQueueEntry.actorIndex);
+ Actor *player = getScene()->getActor();
+ Actor *actor = getScene()->getActor(_currentQueueEntry.actorIndex);
Common::Point playerPoint(player->x1 + player->x2, player->y1 + player->y2);
ActorDirection direction = (cmd->param2 == 8) ? player->getDirection() : cmd->param2;
@@ -820,7 +821,7 @@ IMPLEMENT_OPCODE(_unk2C_ActorSub) {
else
id = actor->getResourcesId(5 * cmd->param1 + direction + 30);
- GraphicResource *res = new GraphicResource(_scene->getResourcePack(), id);
+ GraphicResource *res = new GraphicResource(getScene()->getResourcePack(), id);
actor->setResourceId(id);
actor->setFrameCount(res->getFrameCount());
actor->setFrameIndex(0);
@@ -836,17 +837,17 @@ IMPLEMENT_OPCODE(_unk2C_ActorSub) {
//////////////////////////////////////////////////////////////////////////
// Opcode 0x2D
IMPLEMENT_OPCODE(PlayMovie) {
- if (_scene->matteBarHeight < 170) {
+ if (getScene()->matteBarHeight < 170) {
_lineIncrement = 1;
- if (!_scene->matteBarHeight) {
- _scene->getCursor()->hide();
- _scene->makeGreyPalette();
- _scene->matteVar1 = 1;
- _scene->matteBarHeight = 1;
- _scene->matteVar2 = 0;
- _scene->mattePlaySound = (cmd->param3 == 0);
- _scene->matteInitialized = (cmd->param2 == 0);
+ if (!getScene()->matteBarHeight) {
+ getCursor()->hide();
+ getScene()->makeGreyPalette();
+ getScene()->matteVar1 = 1;
+ getScene()->matteBarHeight = 1;
+ getScene()->matteVar2 = 0;
+ getScene()->mattePlaySound = (cmd->param3 == 0);
+ getScene()->matteInitialized = (cmd->param2 == 0);
_delayedVideoIndex = cmd->param1;
}
@@ -854,19 +855,19 @@ IMPLEMENT_OPCODE(PlayMovie) {
}
bool check = false;
- ActionArea *area = _scene->worldstats()->actions[_scene->getActor()->getActionIndex3()];
+ ActionArea *area = getWorld()->actions[getScene()->getActor()->getActionIndex3()];
if (area->paletteValue) {
- _scene->vm()->screen()->setPalette(_scene->getResourcePack(), area->paletteValue);
- _scene->vm()->screen()->setGammaLevel(_scene->getResourcePack(), area->paletteValue, 0);
+ getScreen()->setPalette(getScene()->getResourcePack(), area->paletteValue);
+ getScreen()->setGammaLevel(getScene()->getResourcePack(), area->paletteValue, 0);
} else {
- _scene->vm()->screen()->setPalette(_scene->getResourcePack(), _scene->worldstats()->currentPaletteId);
- _scene->vm()->screen()->setGammaLevel(_scene->getResourcePack(), _scene->worldstats()->currentPaletteId, 0);
+ getScreen()->setPalette(getScene()->getResourcePack(), getWorld()->currentPaletteId);
+ getScreen()->setGammaLevel(getScene()->getResourcePack(), getWorld()->currentPaletteId, 0);
}
- _scene->matteBarHeight = 0;
+ getScene()->matteBarHeight = 0;
_lineIncrement = 0;
- if (!_scene->mattePlaySound && _currentScript->commands[0].numLines != 0) {
+ if (!getScene()->mattePlaySound && _currentScript->commands[0].numLines != 0) {
bool found = true;
int index = 0;
@@ -886,19 +887,19 @@ IMPLEMENT_OPCODE(PlayMovie) {
// XXX casting kResourceMusic_FFFFFD66 to silence a GCC warning
if (!check &&
- _scene->matteVar2 == 0 &&
- _scene->worldstats()->musicCurrentResourceId != (int)kResourceMusic_FFFFFD66)
- if (_scene->vm()->sound()->isCacheOk())
- _scene->vm()->sound()->playMusic(_scene->getResourcePack(), _scene->worldstats()->musicCurrentResourceId + kResourceMusic_80020000);
+ getScene()->matteVar2 == 0 &&
+ getWorld()->musicCurrentResourceId != (int)kResourceMusic_FFFFFD66)
+ if (_vm->sound()->isCacheOk())
+ _vm->sound()->playMusic(getScene()->getResourcePack(), getWorld()->musicCurrentResourceId + kResourceMusic_80020000);
- _scene->getCursor()->show();
- _scene->matteVar2 = 0;
+ getCursor()->show();
+ getScene()->matteVar2 = 0;
}
//////////////////////////////////////////////////////////////////////////
// Opcode 0x2E
IMPLEMENT_OPCODE(StopAllObjectsSounds) {
- Object *object = _scene->worldstats()->getObjectById((ObjectId)cmd->param1);
+ Object *object = getWorld()->getObjectById((ObjectId)cmd->param1);
object->stopAllSounds();
}
@@ -918,24 +919,24 @@ IMPLEMENT_OPCODE(ResumeProcessing) {
//////////////////////////////////////////////////////////////////////////
// Opcode 0x31
IMPLEMENT_OPCODE(ResetSceneRect) {
- _scene->worldstats()->sceneRectIdx = LOBYTE(cmd->param1);
- _scene->vm()->screen()->paletteFade(0, 25, 10);
- _scene->vm()->setFlag(kFlagTypeSceneRectChanged);
+ getWorld()->sceneRectIdx = LOBYTE(cmd->param1);
+ getScreen()->paletteFade(0, 25, 10);
+ _vm->setFlag(kFlagTypeSceneRectChanged);
- _scene->worldstats()->xLeft = _scene->worldstats()->sceneRects[_scene->worldstats()->sceneRectIdx].left;
- _scene->worldstats()->yTop = _scene->worldstats()->sceneRects[_scene->worldstats()->sceneRectIdx].top;
+ getWorld()->xLeft = getWorld()->sceneRects[getWorld()->sceneRectIdx].left;
+ getWorld()->yTop = getWorld()->sceneRects[getWorld()->sceneRectIdx].top;
}
//////////////////////////////////////////////////////////////////////////
// Opcode 0x32
IMPLEMENT_OPCODE(ChangeMusicById) {
- _scene->vm()->sound()->changeMusic(_scene->getResourcePack(), cmd->param1, cmd->param2 ? 2 : 1);
+ _vm->sound()->changeMusic(getScene()->getResourcePack(), cmd->param1, cmd->param2 ? 2 : 1);
}
//////////////////////////////////////////////////////////////////////////
// Opcode 0x33
IMPLEMENT_OPCODE(StopMusic) {
- _scene->vm()->sound()->changeMusic(_scene->getResourcePack(), (int)kResourceMusic_FFFFFD66, 0);
+ _vm->sound()->changeMusic(getScene()->getResourcePack(), (int)kResourceMusic_FFFFFD66, 0);
}
//////////////////////////////////////////////////////////////////////////
@@ -952,7 +953,7 @@ IMPLEMENT_OPCODE(_unk34_Status) {
//////////////////////////////////////////////////////////////////////////
// Opcode 0x35
IMPLEMENT_OPCODE(SetVolume) {
- AmbientSoundItem item = _scene->worldstats()->ambientSounds[cmd->param1];
+ AmbientSoundItem item = getWorld()->ambientSounds[cmd->param1];
int var = cmd->param2 + item.field_C;
double volume = -((Config.sfxVolume + var) * (Config.ambientVolume + var));
@@ -964,7 +965,7 @@ IMPLEMENT_OPCODE(SetVolume) {
volume = 0;
}
- _scene->vm()->sound()->setVolume(item.resourceId, volume);
+ _vm->sound()->setVolume(item.resourceId, volume);
}
//////////////////////////////////////////////////////////////////////////
@@ -976,10 +977,10 @@ IMPLEMENT_OPCODE(Jump) {
//////////////////////////////////////////////////////////////////////////
// Opcode 0x37
IMPLEMENT_OPCODE(RunBlowUpPuzzle) {
- _scene->vm()->screen()->clearScreen();
- _scene->vm()->screen()->clearGraphicsInQueue();
+ getScreen()->clearScreen();
+ getScreen()->clearGraphicsInQueue();
- _scene->vm()->switchMessageHandler(_scene->vm()->getMessageHandler(cmd->param1));
+ _vm->switchMessageHandler(_vm->getMessageHandler(cmd->param1));
_currentLine++;
@@ -1008,24 +1009,24 @@ IMPLEMENT_OPCODE(ClearAction8) {
// Opcode 0x3B
IMPLEMENT_OPCODE(_unk3B_PALETTE_MOD) {
if (!cmd->param2) {
- _scene->makeGreyPalette();
+ getScene()->makeGreyPalette();
cmd->param2 = 1;
}
if (cmd->param1 >= 22) {
- _scene->vm()->screen()->clearScreen();
+ getScreen()->clearScreen();
cmd->param1 = 0;
cmd->param2 = 0;
_currentLine++;
- _scene->vm()->screen()->clearGraphicsInQueue();
+ getScreen()->clearGraphicsInQueue();
_exit = true;
return;
}
- _scene->updatePalette(cmd->param1);
+ getScene()->updatePalette(cmd->param1);
_lineIncrement = 1;
++cmd->param1;
@@ -1047,7 +1048,7 @@ IMPLEMENT_OPCODE(IncrementParam2) {
//////////////////////////////////////////////////////////////////////////
// Opcode 0x3D
IMPLEMENT_OPCODE(WaitUntilFramePlayed) {
- Object *object = _scene->worldstats()->getObjectById((ObjectId)cmd->param1);
+ Object *object = getWorld()->getObjectById((ObjectId)cmd->param1);
int32 frameNum = cmd->param2;
if (frameNum == -1)
@@ -1069,9 +1070,9 @@ IMPLEMENT_OPCODE(UpdateWideScreen) {
cmd->param1 = 0;
_lineIncrement = 0;
- _scene->matteBarHeight = 0;
+ getScene()->matteBarHeight = 0;
} else {
- _scene->vm()->screen()->drawWideScreen(4 * barSize);
+ getScreen()->drawWideScreen(4 * barSize);
_lineIncrement = 1;
++cmd->param1;
@@ -1082,7 +1083,7 @@ IMPLEMENT_OPCODE(UpdateWideScreen) {
//////////////////////////////////////////////////////////////////////////
// Opcode 0x3F
IMPLEMENT_OPCODE(JumpIfActor) {
- ActorIndex index = (cmd->param1 == kActorNone) ? _scene->getPlayerActorIndex() : cmd->param1;
+ ActorIndex index = (cmd->param1 == kActorNone) ? getScene()->getPlayerActorIndex() : cmd->param1;
if (_currentQueueEntry.actorIndex != index)
_currentLine = cmd->param2 - 1;
@@ -1095,48 +1096,48 @@ IMPLEMENT_OPCODE(PlaySpeechScene) {
return;
if (cmd->param4 != 2) {
- cmd->param5 = _scene->playSpeech(cmd->param1);
+ cmd->param5 = getScene()->playSpeech(cmd->param1);
if (cmd->param2) {
- _scene->vm()->setGameFlag(kGameFlagScriptProcessing);
+ _vm->setGameFlag(kGameFlagScriptProcessing);
cmd->param4 = 2;
if (cmd->param6) {
- _scene->vm()->setFlag(kFlagType1);
- _scene->vm()->setFlag(kFlagType2);
+ _vm->setFlag(kFlagType1);
+ _vm->setFlag(kFlagType2);
}
_lineIncrement = 1;
}
if (cmd->param3 && !cmd->param6)
- _scene->vm()->setGameFlag(kGameFlag219);
+ _vm->setGameFlag(kGameFlag219);
return;
}
- if (_scene->vm()->sound()->isPlaying((ResourceId)cmd->param5)) {
+ if (_vm->sound()->isPlaying((ResourceId)cmd->param5)) {
_lineIncrement = 1;
return;
}
- _scene->vm()->clearGameFlag(kGameFlagScriptProcessing);
+ _vm->clearGameFlag(kGameFlagScriptProcessing);
cmd->param4 = 0;
if (cmd->param3) {
if (cmd->param6) {
- _scene->vm()->clearFlag(kFlagType1);
- _scene->vm()->clearFlag(kFlagType2);
+ _vm->clearFlag(kFlagType1);
+ _vm->clearFlag(kFlagType2);
return;
} else {
- _scene->vm()->clearGameFlag(kGameFlag219);
+ _vm->clearGameFlag(kGameFlag219);
}
}
if (!cmd->param6) {
cmd->param6 = 1;
} else {
- _scene->vm()->clearFlag(kFlagType1);
- _scene->vm()->clearFlag(kFlagType2);
+ _vm->clearFlag(kFlagType1);
+ _vm->clearFlag(kFlagType2);
}
}
@@ -1147,48 +1148,48 @@ IMPLEMENT_OPCODE(PlaySpeech) {
return;
if (cmd->param4 != 2) {
- cmd->param5 = _scene->speech()->play(cmd->param1);
+ cmd->param5 = getScene()->speech()->play(cmd->param1);
if (cmd->param2) {
- _scene->vm()->setGameFlag(kGameFlagScriptProcessing);
+ _vm->setGameFlag(kGameFlagScriptProcessing);
cmd->param4 = 2;
if (cmd->param6) {
- _scene->vm()->setFlag(kFlagType1);
- _scene->vm()->setFlag(kFlagType2);
+ _vm->setFlag(kFlagType1);
+ _vm->setFlag(kFlagType2);
}
_lineIncrement = 1;
}
if (cmd->param3 && !cmd->param6)
- _scene->vm()->setGameFlag(kGameFlag219);
+ _vm->setGameFlag(kGameFlag219);
return;
}
- if (_scene->vm()->sound()->isPlaying((ResourceId)cmd->param5)) {
+ if (_vm->sound()->isPlaying((ResourceId)cmd->param5)) {
_lineIncrement = 1;
return;
}
- _scene->vm()->clearGameFlag(kGameFlagScriptProcessing);
+ _vm->clearGameFlag(kGameFlagScriptProcessing);
cmd->param4 = 0;
if (cmd->param3) {
if (cmd->param6) {
- _scene->vm()->clearFlag(kFlagType1);
- _scene->vm()->clearFlag(kFlagType2);
+ _vm->clearFlag(kFlagType1);
+ _vm->clearFlag(kFlagType2);
return;
} else {
- _scene->vm()->clearGameFlag(kGameFlag219);
+ _vm->clearGameFlag(kGameFlag219);
}
}
if (!cmd->param6) {
cmd->param6 = 1;
} else {
- _scene->vm()->clearFlag(kFlagType1);
- _scene->vm()->clearFlag(kFlagType2);
+ _vm->clearFlag(kFlagType1);
+ _vm->clearFlag(kFlagType2);
}
}
@@ -1199,12 +1200,12 @@ IMPLEMENT_OPCODE(PlaySpeechScene2) {
return;
if (cmd->param5 == 2) {
- if (_scene->vm()->sound()->isPlaying(cmd->param6)) {
+ if (_vm->sound()->isPlaying(cmd->param6)) {
_lineIncrement = 1;
return;
}
- _scene->vm()->clearGameFlag(kGameFlagScriptProcessing);
+ _vm->clearGameFlag(kGameFlagScriptProcessing);
cmd->param5 = 0;
@@ -1214,58 +1215,58 @@ IMPLEMENT_OPCODE(PlaySpeechScene2) {
return;
}
} if (!cmd->param7) {
- _scene->vm()->clearGameFlag(kGameFlag219);
+ _vm->clearGameFlag(kGameFlag219);
cmd->param7 = 1;
return;
}
- _scene->vm()->clearFlag(kFlagType1);
- _scene->vm()->clearFlag(kFlagType2);
+ _vm->clearFlag(kFlagType1);
+ _vm->clearFlag(kFlagType2);
return;
}
- cmd->param6 = _scene->playSpeech(cmd->param1, cmd->param2);
+ cmd->param6 = getScene()->playSpeech(cmd->param1, cmd->param2);
if (cmd->param3) {
- _scene->vm()->setGameFlag(kGameFlagScriptProcessing);
+ _vm->setGameFlag(kGameFlagScriptProcessing);
cmd->param5 = 2;
if (cmd->param7) {
- _scene->vm()->clearFlag(kFlagType1);
- _scene->vm()->clearFlag(kFlagType2);
+ _vm->clearFlag(kFlagType1);
+ _vm->clearFlag(kFlagType2);
}
_lineIncrement = 1;
}
if (cmd->param4 && !cmd->param7)
- _scene->vm()->setGameFlag(kGameFlag219);
+ _vm->setGameFlag(kGameFlag219);
}
//////////////////////////////////////////////////////////////////////////
// Opcode 0x43
IMPLEMENT_OPCODE(MoveScenePositionFromActor) {
- Actor *actor = _scene->getActor(cmd->param1);
+ Actor *actor = getScene()->getActor(cmd->param1);
if (!cmd->param3) {
- _scene->worldstats()->motionStatus = 5;
+ getWorld()->motionStatus = 5;
- _scene->updateSceneCoordinates(actor->x1 + Common::Rational(actor->x2, 2).toInt() - 320,
+ getScene()->updateSceneCoordinates(actor->x1 + Common::Rational(actor->x2, 2).toInt() - 320,
actor->y1 + Common::Rational(actor->y2, 2).toInt() - 240,
cmd->param2);
} else if (cmd->param6) {
- if (_scene->worldstats()->motionStatus == 2) {
+ if (getWorld()->motionStatus == 2) {
_lineIncrement = 1;
} else {
cmd->param6 = 0;
- _scene->worldstats()->targetX = -1;
+ getWorld()->targetX = -1;
}
} else {
cmd->param6 = 1;
- _scene->worldstats()->motionStatus = 2;
+ getWorld()->motionStatus = 2;
- if (_scene->updateSceneCoordinates(actor->x1 + Common::Rational(actor->x2, 2).toInt() - 320,
+ if (getScene()->updateSceneCoordinates(actor->x1 + Common::Rational(actor->x2, 2).toInt() - 320,
actor->y1 + Common::Rational(actor->y2, 2).toInt() - 240,
cmd->param2,
true,
@@ -1279,52 +1280,52 @@ IMPLEMENT_OPCODE(MoveScenePositionFromActor) {
//////////////////////////////////////////////////////////////////////////
// Opcode 0x44
IMPLEMENT_OPCODE(PaletteFade) {
- _scene->vm()->screen()->paletteFade(0, cmd->param1, cmd->param2);
+ getScreen()->paletteFade(0, cmd->param1, cmd->param2);
}
//////////////////////////////////////////////////////////////////////////
// Opcode 0x45
IMPLEMENT_OPCODE(StartPaletteFadeThread) {
- _scene->vm()->screen()->startPaletteFade(_scene->worldstats()->currentPaletteId, cmd->param1, cmd->param2);
+ getScreen()->startPaletteFade(getWorld()->currentPaletteId, cmd->param1, cmd->param2);
}
//////////////////////////////////////////////////////////////////////////
// Opcode 0x46
IMPLEMENT_OPCODE(_unk46) {
if (cmd->param6) {
- if (_scene->vm()->sound()->isPlaying(_scene->vm()->sound()->soundResourceId)) {
+ if (_vm->sound()->isPlaying(_vm->sound()->soundResourceId)) {
_lineIncrement = 1;
} else {
cmd->param6 = 0;
if (cmd->param5) {
- _scene->getActor(cmd->param5)->updateStatus(kActorStatusEnabled);
+ getScene()->getActor(cmd->param5)->updateStatus(kActorStatusEnabled);
} else if (cmd->param4 != cmd->param3 && cmd->param4) {
- _scene->worldstats()->getObjectById((ObjectId)cmd->param3)->disable();
+ getWorld()->getObjectById((ObjectId)cmd->param3)->disable();
- Object *object = _scene->worldstats()->getObjectById((ObjectId)cmd->param4);
+ Object *object = getWorld()->getObjectById((ObjectId)cmd->param4);
object->setNextFrame(object->flags);
}
- _scene->vm()->clearGameFlag(kGameFlagScriptProcessing);
+ _vm->clearGameFlag(kGameFlagScriptProcessing);
- _scene->vm()->sound()->soundResourceId = 0;
- _scene->vm()->sound()->speechTextResourceId = 0;
+ _vm->sound()->soundResourceId = 0;
+ _vm->sound()->speechTextResourceId = 0;
}
} else {
- _scene->vm()->setGameFlag(kGameFlagScriptProcessing);
- _scene->vm()->sound()->setSpeech(cmd->param1 + kResourceSound_80030203, cmd->param1 + kResourceSpeech_8000050A);
+ _vm->setGameFlag(kGameFlagScriptProcessing);
+ _vm->sound()->setSpeech(cmd->param1 + kResourceSound_80030203, cmd->param1 + kResourceSpeech_8000050A);
if (cmd->param2) {
- _scene->getActor(cmd->param5)->updateStatus(kActorStatus8);
+ getScene()->getActor(cmd->param5)->updateStatus(kActorStatus8);
cmd->param6 = 1;
_lineIncrement = 1;
} else {
if (cmd->param4 != cmd->param3) {
if (cmd->param4)
- _scene->worldstats()->getObjectById((ObjectId)cmd->param4)->disable();
+ getWorld()->getObjectById((ObjectId)cmd->param4)->disable();
if (cmd->param3)
- _scene->worldstats()->getObjectById((ObjectId)cmd->param3)->setNextFrame(_scene->worldstats()->getObjectById((ObjectId)cmd->param4)->flags);
+ getWorld()->getObjectById((ObjectId)cmd->param3)->setNextFrame(getWorld()->getObjectById((ObjectId)cmd->param4)->flags);
}
cmd->param6 = 1;
@@ -1336,25 +1337,25 @@ IMPLEMENT_OPCODE(_unk46) {
//////////////////////////////////////////////////////////////////////////
// Opcode 0x47
IMPLEMENT_OPCODE(ActorFaceObject) {
- _scene->getActor(cmd->param1)->faceTarget((ObjectId)cmd->param2, (DirectionFrom)cmd->param3);
+ getScene()->getActor(cmd->param1)->faceTarget((ObjectId)cmd->param2, (DirectionFrom)cmd->param3);
}
//////////////////////////////////////////////////////////////////////////
// Opcode 0x48
IMPLEMENT_OPCODE(_unk48_MATTE_01) {
- _scene->matteVar1 = 0;
- _scene->matteInitialized = true;
+ getScene()->matteVar1 = 0;
+ getScene()->matteInitialized = true;
- if (_scene->matteBarHeight >= 170) {
- _scene->matteBarHeight = 0;
+ if (getScene()->matteBarHeight >= 170) {
+ getScene()->matteBarHeight = 0;
_lineIncrement = 0;
- _scene->getCursor()->show();
+ getCursor()->show();
} else {
_lineIncrement = 1;
- if (!_scene->matteBarHeight) {
- _scene->getCursor()->hide();
- _scene->matteBarHeight = 1;
+ if (!getScene()->matteBarHeight) {
+ getCursor()->hide();
+ getScene()->matteBarHeight = 1;
}
}
}
@@ -1362,20 +1363,20 @@ IMPLEMENT_OPCODE(_unk48_MATTE_01) {
//////////////////////////////////////////////////////////////////////////
// Opcode 0x49
IMPLEMENT_OPCODE(_unk49_MATTE_90) {
- _scene->matteVar1 = 0;
- _scene->matteInitialized = true;
- _scene->mattePlaySound = true;
+ getScene()->matteVar1 = 0;
+ getScene()->matteInitialized = true;
+ getScene()->mattePlaySound = true;
- if (_scene->matteBarHeight >= 170) {
- _scene->matteBarHeight = 0;
+ if (getScene()->matteBarHeight >= 170) {
+ getScene()->matteBarHeight = 0;
_lineIncrement = 0;
- _scene->getCursor()->show();
+ getCursor()->show();
} else {
_lineIncrement = 1;
- if (!_scene->matteBarHeight) {
- _scene->getCursor()->hide();
- _scene->matteBarHeight = 90;
+ if (!getScene()->matteBarHeight) {
+ getCursor()->hide();
+ getScene()->matteBarHeight = 90;
}
}
}
@@ -1384,10 +1385,10 @@ IMPLEMENT_OPCODE(_unk49_MATTE_90) {
// Opcode 0x4A
IMPLEMENT_OPCODE(JumpIfSoundPlaying) {
if (cmd->param3 == 1) {
- if (_scene->vm()->sound()->isPlaying(cmd->param1)) {
+ if (_vm->sound()->isPlaying(cmd->param1)) {
_currentLine = cmd->param2;
}
- } else if (!_scene->vm()->sound()->isPlaying(cmd->param1)) {
+ } else if (!_vm->sound()->isPlaying(cmd->param1)) {
_currentLine = cmd->param2;
}
}
@@ -1395,13 +1396,13 @@ IMPLEMENT_OPCODE(JumpIfSoundPlaying) {
//////////////////////////////////////////////////////////////////////////
// Opcode 0x4B
IMPLEMENT_OPCODE(ChangePlayerActorIndex) {
- _scene->changePlayerActorIndex(cmd->param1);
+ getScene()->changePlayerActorIndex(cmd->param1);
}
//////////////////////////////////////////////////////////////////////////
// Opcode 0x4C
IMPLEMENT_OPCODE(ChangeActorStatus) {
- Actor *actor = _scene->getActor(cmd->param1);
+ Actor *actor = getScene()->getActor(cmd->param1);
if (cmd->param2) {
if (actor->getStatus() < kActorStatus11)
@@ -1414,14 +1415,14 @@ IMPLEMENT_OPCODE(ChangeActorStatus) {
//////////////////////////////////////////////////////////////////////////
// Opcode 0x4D
IMPLEMENT_OPCODE(StopSound) {
- if (_scene->vm()->sound()->isPlaying(cmd->param1))
- _scene->vm()->sound()->stopSound(cmd->param1);
+ if (_vm->sound()->isPlaying(cmd->param1))
+ _vm->sound()->stopSound(cmd->param1);
}
//////////////////////////////////////////////////////////////////////////
// Opcode 0x4E
IMPLEMENT_OPCODE(JumpRandom) {
- if (_scene->vm()->getRandom(cmd->param1) < (uint32)cmd->param2)
+ if (_vm->getRandom(cmd->param1) < (uint32)cmd->param2)
return;
setNextLine(cmd->param3);
@@ -1431,18 +1432,18 @@ IMPLEMENT_OPCODE(JumpRandom) {
// Opcode 0x4F
IMPLEMENT_OPCODE(ClearScreen) {
if (cmd->param1) {
- _scene->vm()->screen()->clearScreen();
- _scene->vm()->setFlag(kFlagTypeSkipDraw);
+ getScreen()->clearScreen();
+ _vm->setFlag(kFlagTypeSkipDraw);
} else {
- _scene->vm()->clearFlag(kFlagTypeSkipDraw);
+ _vm->clearFlag(kFlagTypeSkipDraw);
}
}
//////////////////////////////////////////////////////////////////////////
// Opcode 0x50
IMPLEMENT_OPCODE(Quit) {
- _scene->vm()->screen()->clearScreen();
- _scene->vm()->quitGame();
+ getScreen()->clearScreen();
+ _vm->quitGame();
// We need to exit the interpreter loop so we get back to the event loop and get the quit message
_exit = true;
@@ -1451,7 +1452,7 @@ IMPLEMENT_OPCODE(Quit) {
//////////////////////////////////////////////////////////////////////////
// Opcode 0x51
IMPLEMENT_OPCODE(JumpObjectFrame) {
- Object *object = _scene->worldstats()->getObjectById((ObjectId)cmd->param1);
+ Object *object = getWorld()->getObjectById((ObjectId)cmd->param1);
if (cmd->param2 == -1)
cmd->param2 = object->getFrameCount() - 1;
@@ -1482,13 +1483,13 @@ IMPLEMENT_OPCODE(JumpObjectFrame) {
// Opcode 0x52
IMPLEMENT_OPCODE(DeleteGraphics) {
for (uint i = 0; i < 55; i++)
- _scene->vm()->screen()->deleteGraphicFromQueue(_scene->getActor(cmd->param1)->getResourcesId(cmd->param1));
+ getScreen()->deleteGraphicFromQueue(getScene()->getActor(cmd->param1)->getResourcesId(cmd->param1));
}
//////////////////////////////////////////////////////////////////////////
// Opcode 0x53
IMPLEMENT_OPCODE(SetActorField944) {
- Actor *actor = _scene->getActor(cmd->param1);
+ Actor *actor = getScene()->getActor(cmd->param1);
actor->setField944(cmd->param2);
}
@@ -1497,7 +1498,7 @@ IMPLEMENT_OPCODE(SetActorField944) {
// Opcode 0x54
IMPLEMENT_OPCODE(_unk54_SET_ACTIONLIST_6EC) {
if (cmd->param2)
- _currentScript->field_1BB0 = _scene->vm()->getRandom(cmd->param1);
+ _currentScript->field_1BB0 = _vm->getRandom(cmd->param1);
else
_currentScript->field_1BB0 = cmd->param1;
}
@@ -1537,7 +1538,7 @@ IMPLEMENT_OPCODE(_unk55) {
//////////////////////////////////////////////////////////////////////////
// Opcode 0x56
IMPLEMENT_OPCODE(_unk56) {
- Actor *actor = _scene->getActor(cmd->param2 == 2 ? kActorNone : cmd->param1);
+ Actor *actor = getScene()->getActor(cmd->param2 == 2 ? kActorNone : cmd->param1);
if (actor->getStatus() == kActorStatus2 || actor->getStatus() == kActorStatus13) {
if (cmd->param2 == 2)
@@ -1551,7 +1552,7 @@ IMPLEMENT_OPCODE(_unk56) {
_lineIncrement = 0;
if ((actor->x1 + actor->x2 == cmd->param6) && (actor->y1 + actor->y2 == cmd->param7)) {
- _scene->getActor()->faceTarget((ObjectId)cmd->param1, kDirectionFromActor);
+ getScene()->getActor()->faceTarget((ObjectId)cmd->param1, kDirectionFromActor);
actor->updateFromDirection((actor->getDirection() + 4) & 7);
} else {
_currentLine = cmd->param3;
@@ -1560,8 +1561,8 @@ IMPLEMENT_OPCODE(_unk56) {
int32 x = 0;
int32 y = 0; // FIXME: is is set somewhere else?
- if (_scene->processActor(&x, &cmd->param4) == 1) {
- _scene->getActor()->processStatus(x, y, cmd->param4);
+ if (getScene()->processActor(&x, &cmd->param4) == 1) {
+ getScene()->getActor()->processStatus(x, y, cmd->param4);
cmd->param6 = x;
cmd->param7 = y;
@@ -1571,7 +1572,7 @@ IMPLEMENT_OPCODE(_unk56) {
}
} else {
if (cmd->param4)
- _scene->playSpeech(1);
+ getScene()->playSpeech(1);
_currentLine = cmd->param3;
}
@@ -1581,15 +1582,15 @@ IMPLEMENT_OPCODE(_unk56) {
//////////////////////////////////////////////////////////////////////////
// Opcode 0x57
IMPLEMENT_OPCODE(SetResourcePalette) {
- _scene->worldstats()->currentPaletteId = _scene->worldstats()->graphicResourceIds[cmd->param1];
- _scene->vm()->screen()->setPalette(_scene->getResourcePack(), _scene->worldstats()->currentPaletteId);
- _scene->vm()->screen()->setGammaLevel(_scene->getResourcePack(), _scene->worldstats()->currentPaletteId, 0);
+ getWorld()->currentPaletteId = getWorld()->graphicResourceIds[cmd->param1];
+ getScreen()->setPalette(getScene()->getResourcePack(), getWorld()->currentPaletteId);
+ getScreen()->setGammaLevel(getScene()->getResourcePack(), getWorld()->currentPaletteId, 0);
}
//////////////////////////////////////////////////////////////////////////
// Opcode 0x58
IMPLEMENT_OPCODE(SetObjectFrameIdxFlaged) {
- Object *object = _scene->worldstats()->getObjectById((ObjectId)cmd->param1);
+ Object *object = getWorld()->getObjectById((ObjectId)cmd->param1);
if (cmd->param3)
object->flags = 1 | object->flags;
@@ -1602,7 +1603,7 @@ IMPLEMENT_OPCODE(SetObjectFrameIdxFlaged) {
//////////////////////////////////////////////////////////////////////////
// Opcode 0x59
IMPLEMENT_OPCODE(_unk59) {
- Object *object = _scene->worldstats()->getObjectById((ObjectId)cmd->param1);
+ Object *object = getWorld()->getObjectById((ObjectId)cmd->param1);
if (cmd->param2) {
object->flags |= kObjectFlag40000;
@@ -1617,7 +1618,7 @@ IMPLEMENT_OPCODE(_unk59) {
//////////////////////////////////////////////////////////////////////////
// Opcode 0x5A
IMPLEMENT_OPCODE(_unk5A) {
- _scene->getActor(cmd->param1)->setActionIndex2(cmd->param2);
+ getScene()->getActor(cmd->param1)->setActionIndex2(cmd->param2);
}
//////////////////////////////////////////////////////////////////////////
@@ -1625,14 +1626,14 @@ IMPLEMENT_OPCODE(_unk5A) {
IMPLEMENT_OPCODE(_unk5B) {
if (cmd->param2 >= 0 && cmd->param2 <= 3) {
if (cmd->param1) {
- Object *object = _scene->worldstats()->getObjectById((ObjectId)cmd->param1);
+ Object *object = getWorld()->getObjectById((ObjectId)cmd->param1);
object->setField67C(cmd->param2);
if (object->getField67C())
object->setField67C(object->getField67C() + 3);
} else {
- _scene->getActor(cmd->param3)->setField96C(cmd->param2);
+ getScene()->getActor(cmd->param3)->setField96C(cmd->param2);
}
}
}
@@ -1640,13 +1641,13 @@ IMPLEMENT_OPCODE(_unk5B) {
//////////////////////////////////////////////////////////////////////////
// Opcode 0x5C
IMPLEMENT_OPCODE(QueueScript) {
- queueScript( _scene->worldstats()->getActionAreaById(cmd->param1)->scriptIndex, cmd->param2);
+ queueScript( getWorld()->getActionAreaById(cmd->param1)->scriptIndex, cmd->param2);
}
//////////////////////////////////////////////////////////////////////////
// Opcode 0x5D
IMPLEMENT_OPCODE(_unk5D) {
- Actor *actor = _scene->getActor(cmd->param1);
+ Actor *actor = getScene()->getActor(cmd->param1);
actor->process_401830(cmd->param2, cmd->param3, cmd->param4, cmd->param5, cmd->param6, cmd->param7, cmd->param8, cmd->param9);
}
@@ -1654,7 +1655,7 @@ IMPLEMENT_OPCODE(_unk5D) {
//////////////////////////////////////////////////////////////////////////
// Opcode 0x5E
IMPLEMENT_OPCODE(ClearActorFields) {
- Actor *actor = _scene->getActor(cmd->param1);
+ Actor *actor = getScene()->getActor(cmd->param1);
// Clear fields starting from field_970
actor->clearFields();
@@ -1663,7 +1664,7 @@ IMPLEMENT_OPCODE(ClearActorFields) {
//////////////////////////////////////////////////////////////////////////
// Opcode 0x5F
IMPLEMENT_OPCODE(SetObjectLastFrameIdx) {
- Object *object = _scene->worldstats()->getObjectById((ObjectId)cmd->param1);
+ Object *object = getWorld()->getObjectById((ObjectId)cmd->param1);
if (object->getFrameIndex() == object->getFrameCount() - 1) {
_lineIncrement = 0;
@@ -1676,7 +1677,7 @@ IMPLEMENT_OPCODE(SetObjectLastFrameIdx) {
//////////////////////////////////////////////////////////////////////////
// Opcode 0x60
IMPLEMENT_OPCODE(_unk60_SET_OR_CLR_ACTIONAREA_FLAG) {
- ActionArea *area = _scene->worldstats()->getActionAreaById(cmd->param1);
+ ActionArea *area = getWorld()->getActionAreaById(cmd->param1);
if (cmd->param2)
area->flags |= 1;
@@ -1688,14 +1689,14 @@ IMPLEMENT_OPCODE(_unk60_SET_OR_CLR_ACTIONAREA_FLAG) {
// Opcode 0x61
IMPLEMENT_OPCODE(_unk61) {
if (cmd->param2) {
- if (_scene->worldstats()->field_E860C == -1) {
+ if (getWorld()->field_E860C == -1) {
_lineIncrement = 0;
cmd->param2 = 0;
} else {
_lineIncrement = 1;
}
} else {
- _scene->updatePlayerChapter9(cmd->param1);
+ getScene()->updatePlayerChapter9(cmd->param1);
cmd->param2 = 1;
_lineIncrement = 1;
}
@@ -1704,18 +1705,18 @@ IMPLEMENT_OPCODE(_unk61) {
//////////////////////////////////////////////////////////////////////////
// Opcode 0x62
IMPLEMENT_OPCODE(ShowOptionsScreen) {
- _scene->vm()->menu()->showOptions();
+ _vm->menu()->showOptions();
}
//////////////////////////////////////////////////////////////////////////
// Opcode 0x63
IMPLEMENT_OPCODE(_unk63) {
if (cmd->param1) {
- _scene->vm()->setFlag(kFlagType1);
- _scene->vm()->setFlag(kFlagType2);
+ _vm->setFlag(kFlagType1);
+ _vm->setFlag(kFlagType2);
}
- if (_scene->vm()->sound()->isPlaying(_scene->vm()->sound()->soundResourceId)) {
+ if (_vm->sound()->isPlaying(_vm->sound()->soundResourceId)) {
_lineIncrement = 1;
return;
} else if (!cmd->param1) {
@@ -1734,15 +1735,15 @@ void ActionList::enableObject(ScriptEntry *cmd, ObjectEnableType type) {
void ActionList::setActionFlag(ScriptEntry *cmd, ActionType flag) {
switch (cmd->param2) {
default:
- _scene->worldstats()->getObjectById((ObjectId)cmd->param1)->actionType |= flag;
+ getWorld()->getObjectById((ObjectId)cmd->param1)->actionType |= flag;
break;
case 1:
- _scene->worldstats()->getActionAreaById(cmd->param1)->actionType |= flag;
+ getWorld()->getActionAreaById(cmd->param1)->actionType |= flag;
break;
case 2:
- _scene->worldstats()->actors[cmd->param1]->actionType |= flag;
+ getWorld()->actors[cmd->param1]->actionType |= flag;
break;
}
}
@@ -1750,15 +1751,15 @@ void ActionList::setActionFlag(ScriptEntry *cmd, ActionType flag) {
void ActionList::clearActionFlag(ScriptEntry *cmd, ActionType flag) {
switch (cmd->param2) {
default:
- _scene->worldstats()->getObjectById((ObjectId)cmd->param1)->actionType &= ~flag;
+ getWorld()->getObjectById((ObjectId)cmd->param1)->actionType &= ~flag;
break;
case 1:
- _scene->worldstats()->getActionAreaById(cmd->param1)->actionType &= ~flag;
+ getWorld()->getActionAreaById(cmd->param1)->actionType &= ~flag;
break;
case 2:
- _scene->worldstats()->actors[cmd->param1]->actionType &= ~flag;
+ getWorld()->actors[cmd->param1]->actionType &= ~flag;
break;
}
}
@@ -1768,15 +1769,15 @@ void ActionList::jumpIfActionFlag(ScriptEntry *cmd, ActionType flag) {
switch (cmd->param3) {
default:
- done = (_scene->worldstats()->actors[cmd->param1]->actionType & flag) == 0;
+ done = (getWorld()->actors[cmd->param1]->actionType & flag) == 0;
break;
case 0:
- done = (_scene->worldstats()->getObjectById((ObjectId)cmd->param1)->actionType & flag) == 0;
+ done = (getWorld()->getObjectById((ObjectId)cmd->param1)->actionType & flag) == 0;
break;
case 1:
- done = (_scene->worldstats()->getActionAreaById(cmd->param1)->actionType & flag) == 0;
+ done = (getWorld()->getActionAreaById(cmd->param1)->actionType & flag) == 0;
break;
}
diff --git a/engines/asylum/resources/actionlist.h b/engines/asylum/resources/actionlist.h
index 3acb979abe..48999acd13 100644
--- a/engines/asylum/resources/actionlist.h
+++ b/engines/asylum/resources/actionlist.h
@@ -26,7 +26,7 @@
#ifndef ASYLUM_ACTIONLIST_H
#define ASYLUM_ACTIONLIST_H
-#include "asylum/resources/actor.h"
+#include "asylum/shared.h"
#include "common/array.h"
#include "common/func.h"
@@ -48,13 +48,22 @@ namespace Asylum {
_opcodes.push_back(func); \
}
+class Actor;
+class AsylumEngine;
class Scene;
class ActionList {
public:
- ActionList(Common::SeekableReadStream *stream, Scene *scene);
+ ActionList(AsylumEngine *engine);
virtual ~ActionList();
+ /**
+ * Loads the script entries
+ *
+ * @param stream the script data stream
+ */
+ void load(Common::SeekableReadStream *stream);
+
/**
* Process the current script
*/
@@ -124,8 +133,8 @@ private:
}
};
- // Parent
- Scene *_scene;
+ // Engine
+ AsylumEngine *_vm;
// Script queue and data
Common::Array<Opcode *> _opcodes;
@@ -145,16 +154,14 @@ private:
bool _waitCycle;
/**
- * Loads the script entries
- *
- * @param stream the script data stream
+ * Resets the queue.
*/
- void load(Common::SeekableReadStream *stream);
+ void resetQueue();
/**
- * Resets the queue.
+ * Resets the queue and local variables
*/
- void resetQueue();
+ void reset();
// Opcode helper functions
void enableObject(ScriptEntry *cmd, ObjectEnableType type);
diff --git a/engines/asylum/resources/actor.cpp b/engines/asylum/resources/actor.cpp
index 0200227d22..02367204c5 100644
--- a/engines/asylum/resources/actor.cpp
+++ b/engines/asylum/resources/actor.cpp
@@ -247,7 +247,7 @@ void Actor::update() {
player->setFrameCount(resource->getFrameCount());
delete resource;
- getScene()->getCursor()->hide();
+ getCursor()->hide();
getScene()->getActor(0)->updateFromDirection(4);
// Queue script
@@ -521,7 +521,7 @@ void Actor::updateStatus(ActorStatus actorStatus) {
_vm->clearGameFlag(kGameFlag279);
- getScene()->getCursor()->show();
+ getCursor()->show();
}
break;
diff --git a/engines/asylum/shared.h b/engines/asylum/shared.h
index 3d1e40832b..def7badba3 100644
--- a/engines/asylum/shared.h
+++ b/engines/asylum/shared.h
@@ -307,6 +307,7 @@ enum ObjectFlag {
// Engine subclasses
#define getEncounter() _vm->encounter()
+#define getCursor() _vm->scene()->cursor()
#define getSound() _vm->sound()
#define getScene() _vm->scene()
#define getScreen() _vm->screen()
diff --git a/engines/asylum/views/scene.cpp b/engines/asylum/views/scene.cpp
index 553570801c..44ec7bccbe 100644
--- a/engines/asylum/views/scene.cpp
+++ b/engines/asylum/views/scene.cpp
@@ -71,7 +71,8 @@ Scene::Scene(uint8 sceneIdx, AsylumEngine *engine): _vm(engine) {
_polygons = new Polygons(fd);
// jump to action list data
fd->seek(0xE868E + _polygons->size * _polygons->numEntries);
- _actions = new ActionList(fd, this);
+ _actions = new ActionList(_vm);
+ _actions->load(fd);
fd->close();
delete fd;
diff --git a/engines/asylum/views/scene.h b/engines/asylum/views/scene.h
index 2016f207ff..d103ce171c 100644
--- a/engines/asylum/views/scene.h
+++ b/engines/asylum/views/scene.h
@@ -108,7 +108,6 @@ public:
bool isActive() { return _isActive; }
int getSceneIndex() { return _sceneIdx; }
- Cursor* getCursor() { return _cursor; }
ResourcePack* getResourcePack() { return _resPack; }
ResourcePack* getMusicPack() { return _musPack; }
GraphicResource* getGraphicResource(int32 entry) { return new GraphicResource(_resPack, entry); }
@@ -117,11 +116,13 @@ public:
void setScenePosition(int x, int y);
AsylumEngine* vm() { return _vm; }
- Special *special() { return _special; }
- WorldStats* worldstats() { return _ws; }
- Polygons* polygons() { return _polygons; }
- ActionList* actions() { return _actions; }
- Speech* speech() { return _speech; }
+
+ ActionList *actions() { return _actions; }
+ Cursor *cursor() { return _cursor; }
+ Polygons *polygons() { return _polygons; }
+ Special *special() { return _special; }
+ Speech *speech() { return _speech; }
+ WorldStats *worldstats() { return _ws; }
/** .text:0040A1B0
* Get the supplied actor's position relative to the
Commit: 96878fef6e7fc2b924c545ce815bff7bf8183a1e
https://github.com/scummvm/scummvm/commit/96878fef6e7fc2b924c545ce815bff7bf8183a1e
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:10+02:00
Commit Message:
ASYLUM: Implement special logic for Chapter 7
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@492 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/resources/actionlist.cpp
engines/asylum/resources/actor.cpp
engines/asylum/resources/actor.h
engines/asylum/resources/special.cpp
engines/asylum/shared.h
engines/asylum/views/scene.h
diff --git a/engines/asylum/resources/actionlist.cpp b/engines/asylum/resources/actionlist.cpp
index a86eb38755..d2515e9116 100644
--- a/engines/asylum/resources/actionlist.cpp
+++ b/engines/asylum/resources/actionlist.cpp
@@ -432,7 +432,7 @@ IMPLEMENT_OPCODE(MoveScenePosition) {
IMPLEMENT_OPCODE(HideActor) {
Actor *actor = getScene()->getActor(cmd->param1);
- actor->setVisible(false);
+ actor->hide();
actor->updateDirection();
}
@@ -441,7 +441,7 @@ IMPLEMENT_OPCODE(HideActor) {
IMPLEMENT_OPCODE(ShowActor) {
Actor *actor = getScene()->getActor(cmd->param1);
- actor->setVisible(true);
+ actor->show();
actor->updateDirection();
actor->setLastScreenUpdate(_vm->getTick());
}
@@ -1083,7 +1083,7 @@ IMPLEMENT_OPCODE(UpdateWideScreen) {
//////////////////////////////////////////////////////////////////////////
// Opcode 0x3F
IMPLEMENT_OPCODE(JumpIfActor) {
- ActorIndex index = (cmd->param1 == kActorNone) ? getScene()->getPlayerActorIndex() : cmd->param1;
+ ActorIndex index = (cmd->param1 == kActorInvalid) ? getScene()->getPlayerActorIndex() : cmd->param1;
if (_currentQueueEntry.actorIndex != index)
_currentLine = cmd->param2 - 1;
@@ -1538,7 +1538,7 @@ IMPLEMENT_OPCODE(_unk55) {
//////////////////////////////////////////////////////////////////////////
// Opcode 0x56
IMPLEMENT_OPCODE(_unk56) {
- Actor *actor = getScene()->getActor(cmd->param2 == 2 ? kActorNone : cmd->param1);
+ Actor *actor = getScene()->getActor(cmd->param2 == 2 ? kActorInvalid : cmd->param1);
if (actor->getStatus() == kActorStatus2 || actor->getStatus() == kActorStatus13) {
if (cmd->param2 == 2)
diff --git a/engines/asylum/resources/actor.cpp b/engines/asylum/resources/actor.cpp
index 02367204c5..8a2b364dde 100644
--- a/engines/asylum/resources/actor.cpp
+++ b/engines/asylum/resources/actor.cpp
@@ -219,8 +219,8 @@ void Actor::update() {
if (_frameIndex <= _frameCount - 1) {
++_frameIndex;
} else {
- setVisible(false);
- getScene()->getActor(_index + 9)->setVisible(false);
+ hide();
+ getScene()->getActor(_index + 9)->hide();
}
}
@@ -238,7 +238,7 @@ void Actor::update() {
Actor *player = getScene()->getActor();
getScene()->speech()->play(453);
- setVisible(false);
+ hide();
player->updateStatus(kActorStatus3);
player->setResourceId(player->getResourcesId(35));
@@ -288,7 +288,7 @@ void Actor::update() {
} else {
_vm->clearGameFlag(kGameFlag239);
getScene()->getActor(10)->updateStatus(kActorStatus14);
- setVisible(false);
+ hide();
_vm->setGameFlag(kGameFlag238);
// Queue script
@@ -516,8 +516,8 @@ void Actor::updateStatus(ActorStatus actorStatus) {
getScene()->setPlayerActorIndex(0);
// Hide this actor and the show the other one
- setVisible(false);
- actor->setVisible(true);
+ hide();
+ actor->show();
_vm->clearGameFlag(kGameFlag279);
diff --git a/engines/asylum/resources/actor.h b/engines/asylum/resources/actor.h
index 91e2b29c25..e0ea594a5d 100644
--- a/engines/asylum/resources/actor.h
+++ b/engines/asylum/resources/actor.h
@@ -118,11 +118,14 @@ public:
bool isVisible() { return flags & kActorFlagVisible; }
/**
- * Sets actor visibility
- *
- * @param value true to set to visible, false to set to hidden.
+ * Shows this actor.
*/
- void setVisible(bool value);
+ void show() { setVisible(true); }
+
+ /**
+ * Hides this actor.
+ */
+ void hide() { setVisible(false); }
/////////////////////////////////////////////////////////////////////////
// Drawing & update
@@ -328,6 +331,17 @@ private:
//////////////////////////////////////////////////////////////////////////
// Misc
//////////////////////////////////////////////////////////////////////////
+
+ /**
+ * Sets actor visibility
+ *
+ * @param value true to set to visible, false to set to hidden.
+ */
+ void setVisible(bool value);
+
+ /**
+ * Sets the volume.
+ */
void setVolume();
//////////////////////////////////////////////////////////////////////////
diff --git a/engines/asylum/resources/special.cpp b/engines/asylum/resources/special.cpp
index fa88c55886..11602d3d2f 100644
--- a/engines/asylum/resources/special.cpp
+++ b/engines/asylum/resources/special.cpp
@@ -25,6 +25,7 @@
#include "asylum/resources/special.h"
+#include "asylum/resources/actionlist.h"
#include "asylum/resources/actor.h"
#include "asylum/resources/object.h"
#include "asylum/resources/encounters.h"
@@ -107,7 +108,7 @@ void Special::chapter1(Object *object, ActorIndex actorIndex) {
// Play chapter sound
playChapterSound(object, actorIndex);
- if (actorIndex == kActorNone) {
+ if (actorIndex == kActorInvalid) {
switch (object->getId()) {
default:
break;
@@ -132,7 +133,7 @@ void Special::chapter1(Object *object, ActorIndex actorIndex) {
void Special::chapter2(Object *object, ActorIndex actorIndex) {
// Check objects
- if (actorIndex == kActorNone) {
+ if (actorIndex == kActorInvalid) {
switch (object->getId()) {
default:
break;
@@ -263,7 +264,7 @@ void Special::chapter2(Object *object, ActorIndex actorIndex) {
_vm->setGameFlag(kGameFlag219);
- actor->setVisible(false);
+ actor->hide();
}
break;
}
@@ -280,7 +281,7 @@ void Special::chapter4(Object *object, ActorIndex actorIndex) {
void Special::chapter5(Object *object, ActorIndex actorIndex) {
playChapterSound(object, actorIndex);
- if (actorIndex == kActorNone) {
+ if (actorIndex == kActorInvalid) {
switch (object->getId()) {
default:
break;
@@ -310,7 +311,99 @@ void Special::chapter6(Object *object, ActorIndex actorIndex) {
}
void Special::chapter7(Object *object, ActorIndex actorIndex) {
+ playChapterSound(object, actorIndex);
+
+ if (actorIndex == kActorInvalid) {
+ switch (object->getId()) {
+ default:
+ break;
+
+ case kObjectGlobe:
+ if (!getSound()->isPlaying(getSound()->soundResourceId)) {
+ _vm->clearGameFlag(kGameFlag1009);
+ getCursor()->show();
+ }
+ break;
+
+ case kObjectFreezerHallInterior:
+ Actor *player = getScene()->getActor();
+
+ if (_vm->isGameFlagSet(kGameFlag1021)) {
+ if (player->getReaction(0)) {
+
+ if (player->getStatus() == kActorStatus6 || player->getStatus() == kActorStatus10) {
+ getSound()->playSound(kResourceSound_80120002);
+ player->updateStatus(kActorStatusEnabled);
+ } else {
+ getSound()->playSound(kResourceSound_80120005);
+ player->updateStatus(kActorStatus6);
+ }
+
+ _vm->setGameFlag(kGameFlag1023);
+ } else {
+ _vm->setGameFlag(kGameFlag1022);
+ }
+
+ _vm->clearGameFlag(kGameFlag1021);
+ }
+
+ if (_vm->isGameFlagSet(kGameFlag1023)) {
+ if (player->getField638()) {
+ getScript()->queueScript(getWorld()->actions[getWorld()->getActionAreaIndexById(player->getField638() == 3 ? 2447 : 2448)]->scriptIndex,
+ getScene()->getPlayerActorIndex());
+ _vm->clearGameFlag(kGameFlag1023);
+ } else if (player->getStatus() != kActorStatus6) {
+ _vm->clearGameFlag(kGameFlag1023);
+ _vm->setGameFlag(kGameFlag1022);
+ }
+ }
+ if (_vm->isGameFlagSet(kGameFlag1022)) {
+ _vm->clearGameFlag(kGameFlag1022);
+ getScript()->queueScript(getWorld()->actions[getWorld()->getActionAreaIndexById(2445)]->scriptIndex,
+ getScene()->getPlayerActorIndex());
+ }
+ break;
+ }
+ } else {
+ if (_vm->isGameFlagSet(kGameFlag1108))
+ return;
+
+ Actor *actor0 = getScene()->getActor(0);
+ Actor *actor1 = getScene()->getActor(1);
+ Actor *actor2 = getScene()->getActor(2);
+
+ switch (actorIndex) {
+ default:
+ break;
+
+ case 1:
+ if (actor0->getDirection() < 2 || actor0->getDirection() == 7) {
+ actor1->hide();
+ actor2->show();
+ } else if (actor0->getDirection() == 2 || actor0->getDirection() == 3) {
+ actor1->x1 = actor0->x1;
+ actor1->y1 = actor0->y1 - 15;
+ } else if (actor0->getDirection() == 5 || actor0->getDirection() == 6) {
+ actor1->x1 = actor0->x1 + 20;
+ actor1->y1 = actor0->y1 - 15;
+ } else {
+ actor1->x1 = actor0->x1 + 5;
+ actor1->y1 = actor0->y1 - 10;
+ }
+ break;
+
+ case 2:
+ if (actor0->getDirection() <= 2 || actor0->getDirection() >= 7) {
+ actor2->x1 = actor0->x1 + 10;
+ actor2->y1 = actor0->y1 - 10;
+ } else {
+ actor2->hide();
+ actor1->show();
+ }
+ break;
+ }
+ }
}
void Special::chapter8(Object *object, ActorIndex actorIndex) {
@@ -409,10 +502,10 @@ void Special::playSoundChapter8(Object *object, ActorIndex actorIndex) {
// Helpers
//////////////////////////////////////////////////////////////////////////
ResourceId Special::getResourceId(Object *object, ActorIndex actorIndex) {
- if (actorIndex == kActorNone && object == NULL)
+ if (actorIndex == kActorInvalid && object == NULL)
error("[Special::getResourceId] Both arguments cannot be NULL/empty!");
- return (actorIndex == kActorNone) ? object->getSoundResourceId() : getScene()->getActor(actorIndex)->getSoundResourceId();
+ return (actorIndex == kActorInvalid) ? object->getSoundResourceId() : getScene()->getActor(actorIndex)->getSoundResourceId();
}
void Special::checkObject(Object *object, GameFlag flagToSet, GameFlag flagToClear, ObjectId objectId) {
@@ -420,7 +513,7 @@ void Special::checkObject(Object *object, GameFlag flagToSet, GameFlag flagToCle
_vm->setGameFlag(flagToSet);
_vm->clearGameFlag(flagToClear);
- if (objectId != kActorNone)
+ if (objectId != kObjectNone)
getWorld()->getObjectById(objectId)->setFrameIndex(0);
else
object->setFrameIndex(0);
diff --git a/engines/asylum/shared.h b/engines/asylum/shared.h
index def7badba3..52cad67b13 100644
--- a/engines/asylum/shared.h
+++ b/engines/asylum/shared.h
@@ -54,6 +54,11 @@ enum GameFlag {
kGameFlag455 = 455,
kGameFlag556 = 556,
kGameFlagFinishGame = 901,
+ kGameFlag1009 = 1009,
+ kGameFlag1021 = 1021,
+ kGameFlag1022 = 1022,
+ kGameFlag1023 = 1023,
+ kGameFlag1108 = 1108,
kGameFlag1131 = 1131,
kGameFlag1137 = 1137
};
@@ -84,7 +89,10 @@ enum ResourceIdEnum {
kResourceMusic_80020000 = 0x80020000,
kResourceMusic_80020001 = 0x80020001,
kResourceSound_80030203 = 0x80030203,
+ // Base resource 0x80120000
kResourceSound_80120001 = 0x80120001,
+ kResourceSound_80120002 = 0x80120002,
+ kResourceSound_80120005 = 0x80120005,
kResourceSound_80120006 = 0x80120006,
kResourceSoundIntro = 0x80120007,
kResourceMusic_FFFFFD66 = 0xFFFFFD66
@@ -110,7 +118,7 @@ enum ActionType {
typedef int ActorIndex;
enum ActorIndexes {
- kActorNone = -1,
+ kActorInvalid = -1,
// TODO: check if the names match the actor type
kActorMax = 0,
kActorSarah = 1,
@@ -258,6 +266,8 @@ enum ObjectId {
kObjectAngelFlares = 112,
kObjectGuyFalls = 434,
kObjectOpeningGate = 485,
+ kObjectGlobe = 1261,
+ kObjectFreezerHallInterior = 1337,
kObjectNPC033StartEnc = 1338,
kObjectNPC033GetBook = 1343,
kObjectCrow1FlysAway = 1485,
@@ -311,6 +321,7 @@ enum ObjectFlag {
#define getSound() _vm->sound()
#define getScene() _vm->scene()
#define getScreen() _vm->screen()
+#define getScript() _vm->scene()->actions()
#define getSpeech() _vm->scene()->speech()
#define getWorld() _vm->scene()->worldstats()
diff --git a/engines/asylum/views/scene.h b/engines/asylum/views/scene.h
index d103ce171c..80589fe4bf 100644
--- a/engines/asylum/views/scene.h
+++ b/engines/asylum/views/scene.h
@@ -142,7 +142,7 @@ public:
* WorldStats actor list. Default parameter just
* gets the instance associated with _playerActorIdx
*/
- Actor* getActor(ActorIndex index = kActorNone);
+ Actor* getActor(ActorIndex index = kActorInvalid);
/** .text:00407260
* Check the actor at actorIndex to see if the currently loaded
Commit: 4b449a14c25f3c635e48e5120e1b0f02e78e8df5
https://github.com/scummvm/scummvm/commit/4b449a14c25f3c635e48e5120e1b0f02e78e8df5
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:10+02:00
Commit Message:
ASYLUM: Treat ResourceId as an unsigned int
This should hopefully fix the overflow warnings until we convert
all callers to use the enum.
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@493 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/asylum.cpp
engines/asylum/resources/actionlist.cpp
engines/asylum/resources/actor.cpp
engines/asylum/resources/worldstats.h
engines/asylum/shared.h
diff --git a/engines/asylum/asylum.cpp b/engines/asylum/asylum.cpp
index e418716c45..d8fed5b5e8 100644
--- a/engines/asylum/asylum.cpp
+++ b/engines/asylum/asylum.cpp
@@ -192,7 +192,7 @@ void AsylumEngine::playIntro() {
// Play the intro sound sample (the screen is blacked out, you hear
// an alarm sounding and men talking about.
- _sound->playSound((int)kResourceSoundIntro);
+ _sound->playSound(kResourceSoundIntro);
}
void AsylumEngine::handleEvents(bool doUpdate) { // k_sub_40AE30 (0040AE30)
diff --git a/engines/asylum/resources/actionlist.cpp b/engines/asylum/resources/actionlist.cpp
index d2515e9116..6f1f6315d6 100644
--- a/engines/asylum/resources/actionlist.cpp
+++ b/engines/asylum/resources/actionlist.cpp
@@ -936,7 +936,7 @@ IMPLEMENT_OPCODE(ChangeMusicById) {
//////////////////////////////////////////////////////////////////////////
// Opcode 0x33
IMPLEMENT_OPCODE(StopMusic) {
- _vm->sound()->changeMusic(getScene()->getResourcePack(), (int)kResourceMusic_FFFFFD66, 0);
+ _vm->sound()->changeMusic(getScene()->getResourcePack(), kResourceMusic_FFFFFD66, 0);
}
//////////////////////////////////////////////////////////////////////////
diff --git a/engines/asylum/resources/actor.cpp b/engines/asylum/resources/actor.cpp
index 8a2b364dde..b1ee37c7e9 100644
--- a/engines/asylum/resources/actor.cpp
+++ b/engines/asylum/resources/actor.cpp
@@ -261,7 +261,7 @@ void Actor::update() {
Sound *sound = _vm->sound();
if (sound->isCacheOk())
- sound->playMusic(getScene()->getResourcePack(), (int)kResourceMusic_80020001);
+ sound->playMusic(getScene()->getResourcePack(), kResourceMusic_80020001);
getWorld()->musicCurrentResourceId = 1;
diff --git a/engines/asylum/resources/worldstats.h b/engines/asylum/resources/worldstats.h
index 2cab4166ac..2986560bdb 100644
--- a/engines/asylum/resources/worldstats.h
+++ b/engines/asylum/resources/worldstats.h
@@ -59,7 +59,7 @@ public:
int32 curScrollUpRight;
int32 curHand;
int32 curMagnifyingGlass;
- int32 curTalkNPC;
+ ResourceId curTalkNPC;
int32 curGrabPointer;
int32 curTalkNPC2;
int32 font1;
diff --git a/engines/asylum/shared.h b/engines/asylum/shared.h
index 52cad67b13..c7f0a468ff 100644
--- a/engines/asylum/shared.h
+++ b/engines/asylum/shared.h
@@ -81,7 +81,7 @@ enum ChapterIndex {
// Resources
//////////////////////////////////////////////////////////////////////////
-typedef int ResourceId;
+typedef unsigned int ResourceId;
enum ResourceIdEnum {
kResourceNone = 0,
Commit: 659a3e281ece09a0e7c534030370fb77e4194f05
https://github.com/scummvm/scummvm/commit/659a3e281ece09a0e7c534030370fb77e4194f05
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:10+02:00
Commit Message:
ASYLUM: Reduce header inter-dependency
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@494 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
R engines/asylum/resources/actionarea.cpp
R engines/asylum/resources/actionarea.h
engines/asylum/asylum.cpp
engines/asylum/console.cpp
engines/asylum/console.h
engines/asylum/module.mk
engines/asylum/resources/actionlist.cpp
engines/asylum/resources/actionlist.h
engines/asylum/resources/actor.cpp
engines/asylum/resources/actor.h
engines/asylum/resources/object.cpp
engines/asylum/resources/object.h
engines/asylum/resources/special.cpp
engines/asylum/resources/worldstats.cpp
engines/asylum/resources/worldstats.h
engines/asylum/system/config.h
engines/asylum/system/cursor.cpp
engines/asylum/system/cursor.h
engines/asylum/system/graphics.cpp
engines/asylum/system/graphics.h
engines/asylum/system/screen.cpp
engines/asylum/system/screen.h
engines/asylum/system/sound.cpp
engines/asylum/system/sound.h
engines/asylum/system/speech.cpp
engines/asylum/system/speech.h
engines/asylum/system/text.cpp
engines/asylum/system/text.h
engines/asylum/system/video.cpp
engines/asylum/system/video.h
engines/asylum/views/blowuppuzzle.cpp
engines/asylum/views/menu.cpp
engines/asylum/views/menu.h
engines/asylum/views/scene.cpp
engines/asylum/views/scene.h
diff --git a/engines/asylum/asylum.cpp b/engines/asylum/asylum.cpp
index d8fed5b5e8..c1981d14cd 100644
--- a/engines/asylum/asylum.cpp
+++ b/engines/asylum/asylum.cpp
@@ -32,6 +32,7 @@
#include "asylum/system/screen.h"
#include "asylum/system/sound.h"
#include "asylum/system/text.h"
+#include "asylum/system/video.h"
#include "asylum/views/scene.h"
#include "asylum/views/menu.h"
diff --git a/engines/asylum/console.cpp b/engines/asylum/console.cpp
index 09252a6ddf..35be0bab60 100644
--- a/engines/asylum/console.cpp
+++ b/engines/asylum/console.cpp
@@ -25,8 +25,12 @@
#include "asylum/console.h"
-#include "asylum/resources/actionarea.h"
#include "asylum/resources/actionlist.h"
+#include "asylum/resources/actor.h"
+#include "asylum/resources/object.h"
+#include "asylum/resources/worldstats.h"
+
+#include "asylum/system/screen.h"
#include "asylum/views/scene.h"
diff --git a/engines/asylum/console.h b/engines/asylum/console.h
index 6c26ee40fb..7827eb7b9f 100644
--- a/engines/asylum/console.h
+++ b/engines/asylum/console.h
@@ -47,7 +47,8 @@ enum kDebugLevels {
};
class AsylumEngine;
-class ActionArea;
+
+struct ActionArea;
class Console : public GUI::Debugger {
public:
diff --git a/engines/asylum/module.mk b/engines/asylum/module.mk
index ca6dfdd96d..0bc74b7bfc 100644
--- a/engines/asylum/module.mk
+++ b/engines/asylum/module.mk
@@ -1,7 +1,6 @@
MODULE := engines/asylum
MODULE_OBJS := \
- resources/actionarea.o \
resources/actionlist.o \
resources/actor.o \
resources/object.o \
diff --git a/engines/asylum/resources/actionarea.cpp b/engines/asylum/resources/actionarea.cpp
deleted file mode 100644
index a4674be1b6..0000000000
--- a/engines/asylum/resources/actionarea.cpp
+++ /dev/null
@@ -1,42 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * $URL$
- * $Id$
- *
- */
-
-#include "asylum/resources/actionarea.h"
-
-namespace Asylum {
-
-Common::String ActionArea::toString() {
- Common::String output;
-
- output += Common::String::format("Action %d: %s\n", id, name);
- output += Common::String::format(" flags=%d scriptIndex=%d scriptIndex2=%d type=%d\n", flags, scriptIndex, actionType, polyIdx);
- output += Common::String::format(" sound=%d polygon=%d palette=%d volume=%d\n", soundResourceId, scriptIndex2, paletteValue, volume);
- output += Common::String::format(" field01=%d field02=%d field40=%d field44=%d\n", field01, field02, field_40, field_44);
- output += Common::String::format(" field7C=%d field84=%d field88=%d field90=%d\n", field_7C, field_84, field_88, field_90);
-
- return output;
-}
-
-} // end of namespace Asylum
diff --git a/engines/asylum/resources/actionarea.h b/engines/asylum/resources/actionarea.h
deleted file mode 100644
index 85a9a2c490..0000000000
--- a/engines/asylum/resources/actionarea.h
+++ /dev/null
@@ -1,67 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * $URL$
- * $Id$
- *
- */
-
-#ifndef ASYLUM_ACTIONAREA_H
-#define ASYLUM_ACTIONAREA_H
-
-#include "asylum/shared.h"
-
-#include "common/array.h"
-
-namespace Asylum {
-
-class ActionArea {
-public:
- ActionArea() {}
- virtual ~ActionArea() {}
-
- char name[52];
- int32 id;
- int32 field01;
- int32 field02;
- int32 field_40;
- int32 field_44;
- int32 flags;
- int32 scriptIndex;
- int32 scriptIndex2;
- int32 actionType; // aka flags2: 0-none, 1-findwhat, 2-talk, 3-findwhat??, 4-grab
- int32 flagNums[10];
- int32 field_7C;
- int32 polyIdx;
- int32 field_84;
- int32 field_88;
- ResourceId soundResourceId;
- int32 field_90;
- int32 paletteValue;
- int32 array[5];
- int32 volume;
-
- Common::String toString();
-
-}; // end of class ActionArea
-
-} // end of namespace Asylum
-
-#endif /* ASYLUM_ACTIONAREA_H */
diff --git a/engines/asylum/resources/actionlist.cpp b/engines/asylum/resources/actionlist.cpp
index 6f1f6315d6..f6a1e32780 100644
--- a/engines/asylum/resources/actionlist.cpp
+++ b/engines/asylum/resources/actionlist.cpp
@@ -25,13 +25,21 @@
#include "asylum/resources/actionlist.h"
+#include "asylum/resources/actor.h"
#include "asylum/resources/encounters.h"
+#include "asylum/resources/object.h"
+#include "asylum/resources/worldstats.h"
#include "asylum/system/config.h"
+#include "asylum/system/cursor.h"
+#include "asylum/system/graphics.h"
+#include "asylum/system/screen.h"
+#include "asylum/system/speech.h"
#include "asylum/views/menu.h"
#include "asylum/views/scene.h"
+#include "asylum/asylum.h"
#include "asylum/staticres.h"
#include "common/rational.h"
diff --git a/engines/asylum/resources/actionlist.h b/engines/asylum/resources/actionlist.h
index 48999acd13..10cfda24d4 100644
--- a/engines/asylum/resources/actionlist.h
+++ b/engines/asylum/resources/actionlist.h
@@ -52,6 +52,41 @@ class Actor;
class AsylumEngine;
class Scene;
+struct ActionArea {
+ char name[52];
+ int32 id;
+ int32 field01;
+ int32 field02;
+ int32 field_40;
+ int32 field_44;
+ int32 flags;
+ int32 scriptIndex;
+ int32 scriptIndex2;
+ int32 actionType; ///< flag (see ActionType enumeration)
+ int32 flagNums[10];
+ int32 field_7C;
+ int32 polyIdx;
+ int32 field_84;
+ int32 field_88;
+ ResourceId soundResourceId;
+ int32 field_90;
+ int32 paletteValue;
+ int32 array[5];
+ int32 volume;
+
+ Common::String toString() {
+ Common::String output;
+
+ output += Common::String::format("Action %d: %s\n", id, name);
+ output += Common::String::format(" flags=%d scriptIndex=%d scriptIndex2=%d type=%d\n", flags, scriptIndex, actionType, polyIdx);
+ output += Common::String::format(" sound=%d polygon=%d palette=%d volume=%d\n", soundResourceId, scriptIndex2, paletteValue, volume);
+ output += Common::String::format(" field01=%d field02=%d field40=%d field44=%d\n", field01, field02, field_40, field_44);
+ output += Common::String::format(" field7C=%d field84=%d field88=%d field90=%d\n", field_7C, field_84, field_88, field_90);
+
+ return output;
+ }
+};
+
class ActionList {
public:
ActionList(AsylumEngine *engine);
diff --git a/engines/asylum/resources/actor.cpp b/engines/asylum/resources/actor.cpp
index b1ee37c7e9..d3b8961719 100644
--- a/engines/asylum/resources/actor.cpp
+++ b/engines/asylum/resources/actor.cpp
@@ -27,11 +27,19 @@
#include "asylum/resources/actionlist.h"
#include "asylum/resources/encounters.h"
+#include "asylum/resources/object.h"
+#include "asylum/resources/polygons.h"
#include "asylum/resources/worldstats.h"
-#include "asylum/system/screen.h"
#include "asylum/system/config.h"
+#include "asylum/system/cursor.h"
+#include "asylum/system/graphics.h"
+#include "asylum/system/screen.h"
+#include "asylum/system/speech.h"
+
+#include "asylum/views/scene.h"
+#include "asylum/asylum.h"
#include "asylum/staticres.h"
#include "common/endian.h"
diff --git a/engines/asylum/resources/actor.h b/engines/asylum/resources/actor.h
index e0ea594a5d..c6ec5c1ab8 100644
--- a/engines/asylum/resources/actor.h
+++ b/engines/asylum/resources/actor.h
@@ -26,19 +26,20 @@
#ifndef ASYLUM_ACTOR_H
#define ASYLUM_ACTOR_H
-#include "asylum/respack.h"
#include "asylum/shared.h"
#include "common/rect.h"
+#include "common/stream.h"
namespace Asylum {
-class ActionArea;
class AsylumEngine;
-struct GraphicFrame;
class GraphicResource;
class Screen;
+struct ActionArea;
+struct GraphicFrame;
+
class Actor {
public:
Actor(AsylumEngine *engine, ActorIndex index);
diff --git a/engines/asylum/resources/object.cpp b/engines/asylum/resources/object.cpp
index 093142d4b6..baa4ddf143 100644
--- a/engines/asylum/resources/object.cpp
+++ b/engines/asylum/resources/object.cpp
@@ -27,9 +27,15 @@
#include "asylum/resources/actor.h"
#include "asylum/resources/special.h"
+#include "asylum/resources/worldstats.h"
+
+#include "asylum/system/graphics.h"
+#include "asylum/system/screen.h"
#include "asylum/views/scene.h"
+#include "asylum/asylum.h"
+
namespace Asylum {
Object::Object(AsylumEngine *engine) : _vm(engine) {
@@ -85,7 +91,6 @@ void Object::load(Common::SeekableReadStream *stream) {
_soundItems[i].field_4 = stream->readSint32LE();
_soundItems[i].field_8 = stream->readSint32LE();
_soundItems[i].field_C = stream->readSint32LE();
-
}
for (int i = 0; i < 50; i++) {
diff --git a/engines/asylum/resources/object.h b/engines/asylum/resources/object.h
index f6f64f4e5e..e13c7d7951 100644
--- a/engines/asylum/resources/object.h
+++ b/engines/asylum/resources/object.h
@@ -212,7 +212,7 @@ private:
void stopSound();
/**
- * Sets the volume.
+ * Sets the volume.
*/
void setVolume();
diff --git a/engines/asylum/resources/special.cpp b/engines/asylum/resources/special.cpp
index 11602d3d2f..b3e1288306 100644
--- a/engines/asylum/resources/special.cpp
+++ b/engines/asylum/resources/special.cpp
@@ -29,6 +29,10 @@
#include "asylum/resources/actor.h"
#include "asylum/resources/object.h"
#include "asylum/resources/encounters.h"
+#include "asylum/resources/worldstats.h"
+
+#include "asylum/system/cursor.h"
+#include "asylum/system/speech.h"
#include "asylum/views/scene.h"
diff --git a/engines/asylum/resources/worldstats.cpp b/engines/asylum/resources/worldstats.cpp
index 55adc521be..69878a3114 100644
--- a/engines/asylum/resources/worldstats.cpp
+++ b/engines/asylum/resources/worldstats.cpp
@@ -23,7 +23,13 @@
*
*/
-#include "worldstats.h"
+#include "asylum/resources/worldstats.h"
+
+#include "asylum/resources/actionlist.h"
+#include "asylum/resources/actor.h"
+#include "asylum/resources/object.h"
+
+#include "asylum/views/scene.h"
namespace Asylum {
diff --git a/engines/asylum/resources/worldstats.h b/engines/asylum/resources/worldstats.h
index 2986560bdb..40fe14ecfb 100644
--- a/engines/asylum/resources/worldstats.h
+++ b/engines/asylum/resources/worldstats.h
@@ -26,17 +26,19 @@
#ifndef ASYLUM_WORLDSTATS_H
#define ASYLUM_WORLDSTATS_H
+#include "asylum/system/sound.h"
+
#include "common/rect.h"
#include "common/array.h"
-#include "asylum/resources/actor.h"
-#include "asylum/resources/object.h"
-#include "asylum/resources/actionarea.h"
-#include "asylum/views/scene.h"
-#include "asylum/system/sound.h"
-
namespace Asylum {
+class Actor;
+class Object;
+class Scene;
+
+struct ActionArea;
+
class WorldStats {
public:
WorldStats(Common::SeekableReadStream *stream, Scene *scene);
diff --git a/engines/asylum/system/config.h b/engines/asylum/system/config.h
index 780faaff93..7c9b82ffc4 100644
--- a/engines/asylum/system/config.h
+++ b/engines/asylum/system/config.h
@@ -29,7 +29,6 @@
#include "common/array.h"
#include "common/singleton.h"
#include "common/config-manager.h"
-#include "video.h"
namespace Asylum {
diff --git a/engines/asylum/system/cursor.cpp b/engines/asylum/system/cursor.cpp
index c289b58f92..796b92e6c2 100644
--- a/engines/asylum/system/cursor.cpp
+++ b/engines/asylum/system/cursor.cpp
@@ -23,10 +23,12 @@
*
*/
-#include "graphics/cursorman.h"
-
#include "asylum/system/cursor.h"
+#include "asylum/system/graphics.h"
+
+#include "graphics/cursorman.h"
+
namespace Asylum {
const uint32 CURSOR_UPDATE_TICKS = 100;
diff --git a/engines/asylum/system/cursor.h b/engines/asylum/system/cursor.h
index 7256adbf26..7ddb0f0b5c 100644
--- a/engines/asylum/system/cursor.h
+++ b/engines/asylum/system/cursor.h
@@ -26,12 +26,15 @@
#ifndef ASYLUM_CURSOR_H
#define ASYLUM_CURSOR_H
-#include "asylum/system/graphics.h"
-
#include "asylum/shared.h"
+#include "common/rect.h"
+
namespace Asylum {
+class GraphicResource;
+class ResourcePack;
+
/**
* Asylum cursors are GraphicResources, and are stored in
* ResourcePacks, as are all game assets.
diff --git a/engines/asylum/system/graphics.cpp b/engines/asylum/system/graphics.cpp
index 00380a44d0..6dbea2156f 100644
--- a/engines/asylum/system/graphics.cpp
+++ b/engines/asylum/system/graphics.cpp
@@ -25,6 +25,8 @@
#include "asylum/system/graphics.h"
+#include "asylum/respack.h"
+
#include "common/endian.h"
namespace Asylum {
diff --git a/engines/asylum/system/graphics.h b/engines/asylum/system/graphics.h
index e7e4e70bf4..4a9c12b998 100644
--- a/engines/asylum/system/graphics.h
+++ b/engines/asylum/system/graphics.h
@@ -26,7 +26,6 @@
#ifndef ASYLUM_GRAPHICS_H
#define ASYLUM_GRAPHICS_H
-#include "asylum/respack.h"
#include "asylum/shared.h"
#include "graphics/surface.h"
@@ -35,6 +34,8 @@
namespace Asylum {
+class ResourcePack;
+
struct GraphicFrame {
int32 size;
int32 offset;
diff --git a/engines/asylum/system/screen.cpp b/engines/asylum/system/screen.cpp
index a7a8195699..62dd9939f4 100644
--- a/engines/asylum/system/screen.cpp
+++ b/engines/asylum/system/screen.cpp
@@ -27,6 +27,13 @@
#include "asylum/resources/worldstats.h"
+#include "asylum/system/graphics.h"
+
+#include "asylum/views/scene.h"
+
+#include "asylum/asylum.h"
+#include "asylum/respack.h"
+
namespace Asylum {
Screen::Screen(AsylumEngine *vm) : _vm(vm) {
@@ -106,6 +113,10 @@ void Screen::copyRectToScreenWithTransparency(byte *buffer, int32 pitch, int32 x
_vm->_system->unlockScreen();
}
+void Screen::setPalette(ResourcePack *resPack, ResourceId id) {
+ setPalette(resPack->getResource(id)->data + 32);
+}
+
void Screen::setPalette(byte *rgbPalette) {
byte palette[256 * 4];
byte *p = rgbPalette;
diff --git a/engines/asylum/system/screen.h b/engines/asylum/system/screen.h
index ef929d69e4..a715680ae2 100644
--- a/engines/asylum/system/screen.h
+++ b/engines/asylum/system/screen.h
@@ -26,15 +26,18 @@
#ifndef ASYLUM_SCREEN_H
#define ASYLUM_SCREEN_H
-#include "asylum/asylum.h"
-#include "asylum/respack.h"
-#include "asylum/system/graphics.h"
+#include "asylum/shared.h"
+
+#include "common/array.h"
-#include "common/system.h" // for OSystem
#include "graphics/surface.h"
namespace Asylum {
+class AsylumEngine;
+class GraphicResource;
+class ResourcePack;
+
typedef struct GraphicQueueItem {
ResourceId resourceId;
int32 frameIdx;
@@ -59,9 +62,7 @@ public:
void copyRectToScreen(byte *buffer, int32 pitch, int32 x, int32 y, int32 width, int32 height);
void copyRectToScreenWithTransparency(byte *buffer, int32 pitch, int32 x, int32 y, int32 width, int32 height);
void setPalette(byte *rgbPalette);
- void setPalette(ResourcePack *resPack, ResourceId id) {
- setPalette(resPack->getResource(id)->data + 32);
- }
+ void setPalette(ResourcePack *resPack, ResourceId id);
void setGammaLevel(ResourcePack *resPack, ResourceId id, int32 val);
diff --git a/engines/asylum/system/sound.cpp b/engines/asylum/system/sound.cpp
index 822a42dbc4..68010f792f 100644
--- a/engines/asylum/system/sound.cpp
+++ b/engines/asylum/system/sound.cpp
@@ -23,10 +23,13 @@
*
*/
-#include "asylum/asylum.h"
+
#include "asylum/system/config.h"
#include "asylum/system/sound.h"
+#include "asylum/asylum.h"
+#include "asylum/respack.h"
+
#include "common/stream.h"
#include "sound/audiostream.h"
diff --git a/engines/asylum/system/sound.h b/engines/asylum/system/sound.h
index 4ac3cfda74..a11ae1ef79 100644
--- a/engines/asylum/system/sound.h
+++ b/engines/asylum/system/sound.h
@@ -28,13 +28,18 @@
#include "asylum/system/config.h"
-#include "asylum/respack.h"
#include "asylum/shared.h"
+#include "common/array.h"
+
#include "sound/mixer.h"
namespace Asylum {
+class ResourcePack;
+
+struct ResourceEntry;
+
struct SoundItem {
ResourceId resourceId;
int32 field_4;
diff --git a/engines/asylum/system/speech.cpp b/engines/asylum/system/speech.cpp
index d00be662a5..489866a735 100644
--- a/engines/asylum/system/speech.cpp
+++ b/engines/asylum/system/speech.cpp
@@ -23,11 +23,18 @@
*
*/
-#include "asylum/resources/actor.h"
#include "asylum/system/speech.h"
+
+#include "asylum/resources/actor.h"
+#include "asylum/resources/worldstats.h"
+
#include "asylum/system/config.h"
#include "asylum/system/text.h"
+#include "asylum/views/scene.h"
+
+#include "asylum/asylum.h"
+
namespace Asylum {
Speech::Speech(Scene *scene): _scene(scene) {
diff --git a/engines/asylum/system/speech.h b/engines/asylum/system/speech.h
index b2651c7407..d025742d4e 100644
--- a/engines/asylum/system/speech.h
+++ b/engines/asylum/system/speech.h
@@ -26,11 +26,14 @@
#ifndef ASYLUM_SPEECH_H
#define ASYLUM_SPEECH_H
-#include "asylum/respack.h"
-#include "asylum/views/scene.h"
+#include "asylum/shared.h"
+
+#include "common/scummsys.h"
namespace Asylum {
+class Scene;
+
class Speech {
public:
Speech(Scene *scene);
diff --git a/engines/asylum/system/text.cpp b/engines/asylum/system/text.cpp
index affff0a446..a27c1327e5 100644
--- a/engines/asylum/system/text.cpp
+++ b/engines/asylum/system/text.cpp
@@ -25,6 +25,11 @@
#include "asylum/system/text.h"
+#include "asylum/system/graphics.h"
+#include "asylum/system/screen.h"
+
+#include "asylum/respack.h"
+
#include "common/endian.h"
namespace Asylum {
diff --git a/engines/asylum/system/text.h b/engines/asylum/system/text.h
index 5cab9307b7..daae8d7bf2 100644
--- a/engines/asylum/system/text.h
+++ b/engines/asylum/system/text.h
@@ -26,11 +26,14 @@
#ifndef ASYLUM_TEXT_H
#define ASYLUM_TEXT_H
-#include "asylum/system/screen.h"
-#include "asylum/respack.h"
+#include "asylum/shared.h"
+
+#include "common/scummsys.h"
namespace Asylum {
+class GraphicResource;
+class ResourcePack;
class Screen;
class Text {
diff --git a/engines/asylum/system/video.cpp b/engines/asylum/system/video.cpp
index 6f7b5b540e..aebf34271b 100644
--- a/engines/asylum/system/video.cpp
+++ b/engines/asylum/system/video.cpp
@@ -25,9 +25,10 @@
#include "asylum/system/video.h"
-#include "asylum/system//graphics.h"
+#include "asylum/system/graphics.h"
#include "asylum/system/text.h"
+#include "asylum/respack.h"
#include "asylum/staticres.h"
namespace Asylum {
diff --git a/engines/asylum/system/video.h b/engines/asylum/system/video.h
index 7c9bc1092e..8c67dce23b 100644
--- a/engines/asylum/system/video.h
+++ b/engines/asylum/system/video.h
@@ -26,16 +26,17 @@
#ifndef ASYLUM_VIDEO_H
#define ASYLUM_VIDEO_H
-#include "sound/mixer.h"
-#include "graphics/surface.h"
-#include "graphics/video/smk_decoder.h"
+#include "asylum/shared.h"
#include "common/array.h"
#include "common/events.h"
#include "common/system.h"
#include "common/list.h"
-#include "asylum/asylum.h"
+#include "graphics/surface.h"
+#include "graphics/video/smk_decoder.h"
+
+#include "sound/mixer.h"
namespace Asylum {
diff --git a/engines/asylum/views/blowuppuzzle.cpp b/engines/asylum/views/blowuppuzzle.cpp
index 5ee4626b3f..a800c35416 100644
--- a/engines/asylum/views/blowuppuzzle.cpp
+++ b/engines/asylum/views/blowuppuzzle.cpp
@@ -25,11 +25,17 @@
#include "asylum/views/blowuppuzzle.h"
-#include "asylum/views/scene.h"
+#include "asylum/resources/worldstats.h"
#include "asylum/system/config.h"
+#include "asylum/system/cursor.h"
#include "asylum/system/graphics.h"
+#include "asylum/system/screen.h"
+#include "asylum/system/video.h"
+
+#include "asylum/views/scene.h"
+#include "asylum/asylum.h"
#include "asylum/respack.h"
#include "asylum/shared.h"
diff --git a/engines/asylum/views/menu.cpp b/engines/asylum/views/menu.cpp
index bbabf351e4..09dc64ca41 100644
--- a/engines/asylum/views/menu.cpp
+++ b/engines/asylum/views/menu.cpp
@@ -25,12 +25,20 @@
#include "asylum/views/menu.h"
-#include "asylum/system/graphics.h"
#include "asylum/system/config.h"
+#include "asylum/system/cursor.h"
+#include "asylum/system/graphics.h"
+#include "asylum/system/screen.h"
+#include "asylum/system/sound.h"
+#include "asylum/system/text.h"
+
+#include "asylum/views/scene.h"
#include "asylum/respack.h"
#include "asylum/staticres.h"
+#include "asylum/asylum.h"
+
namespace Asylum {
MainMenu::MainMenu(AsylumEngine *vm): _vm(vm) {
diff --git a/engines/asylum/views/menu.h b/engines/asylum/views/menu.h
index 5fb87bcd74..9bea1071ed 100644
--- a/engines/asylum/views/menu.h
+++ b/engines/asylum/views/menu.h
@@ -28,17 +28,14 @@
#include "common/events.h"
-#include "asylum/asylum.h"
-#include "asylum/respack.h"
-#include "asylum/views/scene.h"
-#include "asylum/system/graphics.h"
-#include "asylum/system/text.h"
-#include "asylum/system/cursor.h"
-
namespace Asylum {
-class Text;
+class AsylumEngine;
class Cursor;
+class GraphicResource;
+class ResourcePack;
+class Scene;
+class Text;
class MainMenu {
public:
diff --git a/engines/asylum/views/scene.cpp b/engines/asylum/views/scene.cpp
index 44ec7bccbe..7e60dce147 100644
--- a/engines/asylum/views/scene.cpp
+++ b/engines/asylum/views/scene.cpp
@@ -28,12 +28,24 @@
#include "asylum/resources/actionlist.h"
#include "asylum/resources/actor.h"
#include "asylum/resources/encounters.h"
+#include "asylum/resources/object.h"
+#include "asylum/resources/polygons.h"
#include "asylum/resources/special.h"
+#include "asylum/resources/worldstats.h"
#include "asylum/system/config.h"
-
+#include "asylum/system/cursor.h"
+#include "asylum/system/graphics.h"
+#include "asylum/system/screen.h"
+#include "asylum/system/speech.h"
+#include "asylum/system/text.h"
+
+#include "asylum/asylum.h"
+#include "asylum/respack.h"
#include "asylum/staticres.h"
+#include "common/file.h"
+
namespace Asylum {
#define SCREEN_EDGES 40
@@ -198,6 +210,10 @@ void Scene::initialize() {
}
}
+GraphicResource* Scene::getGraphicResource(int32 entry) {
+ return new GraphicResource(_resPack, entry);
+}
+
void Scene::startMusic() {
// TODO musicCacheOk check as part of if
int musicId = 0;
diff --git a/engines/asylum/views/scene.h b/engines/asylum/views/scene.h
index 80589fe4bf..cf1df356df 100644
--- a/engines/asylum/views/scene.h
+++ b/engines/asylum/views/scene.h
@@ -26,17 +26,12 @@
#ifndef ASYLUM_SCENE_H
#define ASYLUM_SCENE_H
-#include "asylum/asylum.h"
-#include "asylum/respack.h"
-#include "asylum/system/graphics.h"
-#include "asylum/resources/worldstats.h"
-#include "asylum/resources/polygons.h"
-#include "asylum/system/text.h"
-#include "asylum/system/cursor.h"
-#include "asylum/system/speech.h"
+#include "asylum/shared.h"
+#include "common/array.h"
#include "common/events.h"
#include "common/rational.h"
+#include "graphics/surface.h"
#define SCENE_FILE_MASK "scn.%03d"
#define MUSIC_FILE_MASK "mus.%03d"
@@ -44,8 +39,14 @@
namespace Asylum {
class ActionList;
+class Actor;
+class AsylumEngine;
//class BlowUpPuzzle;
class Cursor;
+class GraphicResource;
+class Polygons;
+class ResourcePack;
+class Scene;
class Screen;
class Special;
class Speech;
@@ -54,7 +55,10 @@ class Text;
class Video;
class WorldStats;
+struct AmbientSoundItem;
+struct GraphicFrame;
struct ObjectItem;
+struct PolyDefinitions;
enum HitType {
kHitNone = -1,
@@ -110,7 +114,7 @@ public:
ResourcePack* getResourcePack() { return _resPack; }
ResourcePack* getMusicPack() { return _musPack; }
- GraphicResource* getGraphicResource(int32 entry) { return new GraphicResource(_resPack, entry); }
+ GraphicResource* getGraphicResource(int32 entry);
//BlowUpPuzzle* getBlowUpPuzzle() { return _blowUp;}
//void setBlowUpPuzzle(BlowUpPuzzle* puzzle) { _blowUp = puzzle; }
void setScenePosition(int x, int y);
Commit: 62305021da2e0acfb5856543d05890c64c864de8
https://github.com/scummvm/scummvm/commit/62305021da2e0acfb5856543d05890c64c864de8
Author: Alex Bevilacqua (alexbevi at gmail.com)
Date: 2021-05-17T15:36:11+02:00
Commit Message:
ASYLUM: fix object disable (actor is now no longer hidden after the first script runs)
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@495 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/resources/object.cpp
engines/asylum/shared.h
diff --git a/engines/asylum/resources/object.cpp b/engines/asylum/resources/object.cpp
index baa4ddf143..c6d7e750ed 100644
--- a/engines/asylum/resources/object.cpp
+++ b/engines/asylum/resources/object.cpp
@@ -116,7 +116,7 @@ void Object::load(Common::SeekableReadStream *stream) {
void Object::disable() {
- flags &= ~kObjectFlagEnabled;
+ flags &= kObjectFlagDisabled;
}
void Object::disableAndRemoveFromQueue() {
diff --git a/engines/asylum/shared.h b/engines/asylum/shared.h
index c7f0a468ff..328e4e6b64 100644
--- a/engines/asylum/shared.h
+++ b/engines/asylum/shared.h
@@ -294,7 +294,8 @@ enum ObjectFlag {
kObjectFlag10000 = 0x10000,
kObjectFlag10E38 = 0x10E38,
kObjectFlag20000 = 0x20000,
- kObjectFlag40000 = 0x40000
+ kObjectFlag40000 = 0x40000,
+ kObjectFlagDisabled = 0xFFFFFFFF
};
//////////////////////////////////////////////////////////////////////////
Commit: d8457b0bc287b5eb4b40251af482c2aa34d5a922
https://github.com/scummvm/scummvm/commit/d8457b0bc287b5eb4b40251af482c2aa34d5a922
Author: Alex Bevilacqua (alexbevi at gmail.com)
Date: 2021-05-17T15:36:11+02:00
Commit Message:
ASYLUM: enhance "objects" console command
this command now takes a format option of "idx" or "id" so you can look up an object entry by its internal id as well as it's physical location within the objects array.
Also enhanced Objects::toString with an optional formatting parameter that displays a short dump or a long dump.
sample usage:
objects idx 51 // summary view of object at array index 51
objects id 1258 // detail view of object with id of 1258
objects // show all objects (summary list)
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@496 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/console.cpp
engines/asylum/resources/object.cpp
engines/asylum/resources/object.h
diff --git a/engines/asylum/console.cpp b/engines/asylum/console.cpp
index 35be0bab60..d1a970e934 100644
--- a/engines/asylum/console.cpp
+++ b/engines/asylum/console.cpp
@@ -218,25 +218,38 @@ bool Console::cmdListFlags(int32 argc, const char **argv) {
}
bool Console::cmdListObjects(int32 argc, const char **argv) {
- if (argc != 1 && argc != 2) {
- DebugPrintf("Syntax: %s <index> (use nothing for all)\n", argv[0]);
+ if (argc != 1 && argc != 3) {
+ DebugPrintf("Syntax: %s [id|idx] <value> (use nothing for all)\n", argv[0]);
return true;
}
- if (argc == 1) {
- for (uint32 i = 0; i < getWorld()->objects.size(); i++)
- DebugPrintf("%s\n", getWorld()->objects[i]->toString().c_str());
+ if (argc == 3) {
+ if (Common::String(argv[1]) == "id") {
+ int id = atoi(argv[2]);
+ for (uint32 i = 0; i < getWorld()->objects.size(); i++) {
+ if (getWorld()->objects[i]->getId() == id) {
+ DebugPrintf("%s\n", getWorld()->objects[i]->toString(false).c_str());
+ return true;
+ }
+ }
+ DebugPrintf("No object with id %d found\n", id);
+ } else if (Common::String(argv[1]) == "idx") {
+ int index = atoi(argv[2]);
+ int maxIndex = getWorld()->objects.size() - 1;
+
+ if (index < 0 || index > maxIndex) {
+ DebugPrintf("[error] index should be between 0 and %d\n", maxIndex);
+ return true;
+ }
- } else {
- int index = atoi(argv[1]);
- int maxIndex = getWorld()->objects.size() - 1;
+ DebugPrintf("%s\n", getWorld()->objects[index]->toString().c_str());
- if (index < 0 || index > maxIndex) {
- DebugPrintf("[error] index should be between 0 and %d\n", maxIndex);
- return true;
+ } else {
+ DebugPrintf("[error] valid options are 'id' and 'idx'\n");
}
-
- DebugPrintf("%s\n", getWorld()->objects[index]->toString().c_str());
+ } else {
+ for (uint32 i = 0; i < getWorld()->objects.size(); i++)
+ DebugPrintf("%s\n", getWorld()->objects[i]->toString().c_str());
}
return true;
diff --git a/engines/asylum/resources/object.cpp b/engines/asylum/resources/object.cpp
index c6d7e750ed..6c15f0110e 100644
--- a/engines/asylum/resources/object.cpp
+++ b/engines/asylum/resources/object.cpp
@@ -466,13 +466,44 @@ bool Object::checkFlags() {
return (flags & kObjectFlagEnabled) && (flags & kObjectFlag8 || flags & kObjectFlag10000);
}
-Common::String Object::toString() {
+Common::String Object::toString(bool shortString) {
Common::String output;
debugC(kDebugLevelObjects, "kObject%s = %d,", _name, _id);
output += Common::String::format("Object %d: %s\n", _id, _name);
+ if (!shortString) {
+ output += Common::String::format(" resourceId: %u (0x%X)\n", _resourceId, _resourceId);
+ output += Common::String::format(" x: %d\n", x);
+ output += Common::String::format(" y: %d\n", y);
+ output += Common::String::format(" flags: %d\n", flags);
+ output += Common::String::format(" actionType: %d\n", actionType);
+ output += Common::String::format(" boundingRect: top[%d], left[%d], right[%d], bottom[%d]\n", _boundingRect.top, _boundingRect.left, _boundingRect.right, _boundingRect.bottom);
+ output += Common::String::format(" field_20: %d\n", _field_20);
+ output += Common::String::format(" frameIndex: %u\n", _frameIndex);
+ output += Common::String::format(" frameCount: %u\n", _frameCount);
+ output += Common::String::format(" field_2C: %d\n", _field_2C);
+ output += Common::String::format(" field_30: %d\n", _field_30);
+ output += Common::String::format(" field_34: %d\n", _field_34);
+ output += Common::String::format(" field_3C: %d\n", _field_3C);
+ output += Common::String::format(" rect: top[%d], left[%d], right[%d], bottom[%d]\n", _rect.top, _rect.left, _rect.right, _rect.bottom);
+ output += Common::String::format(" polygonIndex: %d\n", _polygonIndex);
+ output += Common::String::format(" field_B4: %d\n", _field_B4);
+ output += Common::String::format(" tickCount: %d\n", _tickCount);
+ output += Common::String::format(" tickCount2: %d\n", _tickCount2);
+ output += Common::String::format(" field_C0: %d\n", _field_C0);
+ output += Common::String::format(" priority: %d\n", _priority);
+ output += Common::String::format(" actionListIdx: %d\n", _actionListIdx);
+ output += Common::String::format(" field_67C: %d\n", _field_67C);
+ output += Common::String::format(" soundX: %d\n", _soundX);
+ output += Common::String::format(" soundY: %d\n", _soundY);
+ output += Common::String::format(" field_688: %d\n", _field_688);
+ output += Common::String::format(" soundResourceId: %d\n", _soundResourceId);
+ output += Common::String::format(" field_6A4: %d\n", _field_6A4);
+
+ }
+
return output;
}
diff --git a/engines/asylum/resources/object.h b/engines/asylum/resources/object.h
index e13c7d7951..0c9e42717e 100644
--- a/engines/asylum/resources/object.h
+++ b/engines/asylum/resources/object.h
@@ -143,9 +143,11 @@ public:
/**
* Convert this object into a string representation.
*
+ * @param shortString toggle for displaying the full dump or just a
+ * short summary string
* @return A string representation of this object.
*/
- Common::String toString();
+ Common::String toString(bool shortString = true);
private:
AsylumEngine *_vm;
Commit: e10ad80b88778902420d5d3f9fed1c56d1889ab5
https://github.com/scummvm/scummvm/commit/e10ad80b88778902420d5d3f9fed1c56d1889ab5
Author: Alex Bevilacqua (alexbevi at gmail.com)
Date: 2021-05-17T15:36:11+02:00
Commit Message:
ASYLUM: added 'object' console command and an onscreen param for 'objects'
Inspecting a particular object is now done via the 'object' console command. Also, listing all objects is done by using 'objects *'.
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@497 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/console.cpp
engines/asylum/console.h
diff --git a/engines/asylum/console.cpp b/engines/asylum/console.cpp
index d1a970e934..54c4471066 100644
--- a/engines/asylum/console.cpp
+++ b/engines/asylum/console.cpp
@@ -53,6 +53,7 @@ Console::Console(AsylumEngine *engine) : _vm(engine) {
DCmd_Register("actions", WRAP_METHOD(Console, cmdListActions));
DCmd_Register("actors", WRAP_METHOD(Console, cmdListActors));
DCmd_Register("flags", WRAP_METHOD(Console, cmdListFlags));
+ DCmd_Register("object", WRAP_METHOD(Console, cmdShowObject));
DCmd_Register("objects", WRAP_METHOD(Console, cmdListObjects));
DCmd_Register("video", WRAP_METHOD(Console, cmdPlayVideo));
@@ -94,6 +95,7 @@ bool Console::cmdHelp(int, const char **) {
DebugPrintf(" actors - show actors information\n");
DebugPrintf(" action - show action information\n");
DebugPrintf(" flags - show flags\n");
+ DebugPrintf(" object - inspect a particular object\n");
DebugPrintf(" objects - show objects information\n");
DebugPrintf("\n");
DebugPrintf(" video - play a video\n");
@@ -217,18 +219,18 @@ bool Console::cmdListFlags(int32 argc, const char **argv) {
return true;
}
-bool Console::cmdListObjects(int32 argc, const char **argv) {
- if (argc != 1 && argc != 3) {
- DebugPrintf("Syntax: %s [id|idx] <value> (use nothing for all)\n", argv[0]);
+bool Console::cmdShowObject(int32 argc, const char **argv) {
+ if (argc != 3) {
+ DebugPrintf("Syntax: %s [id|idx] <target>\n", argv[0]);
return true;
}
- if (argc == 3) {
+ if (argc == 2) {
if (Common::String(argv[1]) == "id") {
int id = atoi(argv[2]);
for (uint32 i = 0; i < getWorld()->objects.size(); i++) {
if (getWorld()->objects[i]->getId() == id) {
- DebugPrintf("%s\n", getWorld()->objects[i]->toString(false).c_str());
+ DebugPrintf("%s", getWorld()->objects[i]->toString(false).c_str());
return true;
}
}
@@ -242,14 +244,35 @@ bool Console::cmdListObjects(int32 argc, const char **argv) {
return true;
}
- DebugPrintf("%s\n", getWorld()->objects[index]->toString().c_str());
+ DebugPrintf("%s", getWorld()->objects[index]->toString().c_str());
} else {
DebugPrintf("[error] valid options are 'id' and 'idx'\n");
}
- } else {
- for (uint32 i = 0; i < getWorld()->objects.size(); i++)
- DebugPrintf("%s\n", getWorld()->objects[i]->toString().c_str());
+ }
+
+ return true;
+}
+
+bool Console::cmdListObjects(int32 argc, const char **argv) {
+ if (argc != 2) {
+ DebugPrintf("Syntax: %s [onscreen|*]\n", argv[0]);
+ return true;
+ }
+
+ if (argc == 2) {
+ if (Common::String(argv[1]) == "onscreen") {
+ for (uint32 i = 0; i < getWorld()->objects.size(); i++) {
+ if (getWorld()->objects[i]->isOnScreen()) {
+ DebugPrintf("%s", getWorld()->objects[i]->toString().c_str());
+ }
+ }
+ } else if (Common::String(argv[1]) == "*"){
+ for (uint32 i = 0; i < getWorld()->objects.size(); i++)
+ DebugPrintf("%s", getWorld()->objects[i]->toString().c_str());
+ } else {
+ DebugPrintf("[error] valid options are 'onscreen' and '*'\n");
+ }
}
return true;
diff --git a/engines/asylum/console.h b/engines/asylum/console.h
index 7827eb7b9f..22a624a9b5 100644
--- a/engines/asylum/console.h
+++ b/engines/asylum/console.h
@@ -65,6 +65,7 @@ private:
bool cmdListActions(int32 argc, const char **argv);
bool cmdListActors(int32 argc, const char **argv);
bool cmdListFlags(int32 argc, const char **argv);
+ bool cmdShowObject(int32 argc, const char **argv);
bool cmdListObjects(int32 argc, const char **argv);
bool cmdPlayVideo(int32 argc, const char **argv);
Commit: eae999fed460f229187caf69b15880dcba210f30
https://github.com/scummvm/scummvm/commit/eae999fed460f229187caf69b15880dcba210f30
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:11+02:00
Commit Message:
ASYLUM: Implement special logic for chapter 2 (remaining part), 5 & 9
- Fix graphic resource leak in Actor & Object
- Replace WorldStats targetX, targetY and following variables into
a coordinate array.
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@498 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/resources/actionlist.cpp
engines/asylum/resources/actor.cpp
engines/asylum/resources/object.cpp
engines/asylum/resources/object.h
engines/asylum/resources/special.cpp
engines/asylum/resources/special.h
engines/asylum/resources/worldstats.cpp
engines/asylum/resources/worldstats.h
engines/asylum/shared.h
engines/asylum/system/sound.h
engines/asylum/views/scene.cpp
diff --git a/engines/asylum/resources/actionlist.cpp b/engines/asylum/resources/actionlist.cpp
index f6a1e32780..1ed33d1039 100644
--- a/engines/asylum/resources/actionlist.cpp
+++ b/engines/asylum/resources/actionlist.cpp
@@ -1268,7 +1268,7 @@ IMPLEMENT_OPCODE(MoveScenePositionFromActor) {
_lineIncrement = 1;
} else {
cmd->param6 = 0;
- getWorld()->targetX = -1;
+ getWorld()->coordinates[0] = -1;
}
} else {
cmd->param6 = 1;
diff --git a/engines/asylum/resources/actor.cpp b/engines/asylum/resources/actor.cpp
index d3b8961719..0d6639912b 100644
--- a/engines/asylum/resources/actor.cpp
+++ b/engines/asylum/resources/actor.cpp
@@ -575,6 +575,8 @@ void Actor::updateStatus(ActorStatus actorStatus) {
resource->load(getScene()->getResourcePack(), _resourceId);
_frameCount = resource->getFrameCount();
+
+ delete resource;
}
break;
}
diff --git a/engines/asylum/resources/object.cpp b/engines/asylum/resources/object.cpp
index 6c15f0110e..c26a927169 100644
--- a/engines/asylum/resources/object.cpp
+++ b/engines/asylum/resources/object.cpp
@@ -95,7 +95,7 @@ void Object::load(Common::SeekableReadStream *stream) {
for (int i = 0; i < 50; i++) {
_frameSoundItems[i].resourceId = stream->readSint32LE();
- _frameSoundItems[i].frameIdx = stream->readSint32LE();
+ _frameSoundItems[i].frameIndex = stream->readSint32LE();
_frameSoundItems[i].index = stream->readSint32LE();
_frameSoundItems[i].field_C = stream->readSint32LE();
_frameSoundItems[i].field_10 = stream->readSint32LE();
@@ -440,6 +440,8 @@ void Object::setVolume() {
if (volume < -10000)
volume = -10000;
+ delete resource;
+
getSound()->setVolume(_soundResourceId, volume);
}
diff --git a/engines/asylum/resources/object.h b/engines/asylum/resources/object.h
index 0c9e42717e..acc4233af2 100644
--- a/engines/asylum/resources/object.h
+++ b/engines/asylum/resources/object.h
@@ -70,6 +70,7 @@ public:
int32 getSoundY() { return _soundY; }
int32 getField67C() { return _field_67C; }
int32 getField688() { return _field_688; }
+ int32 getField6A4() { return _field_6A4; }
/////////////////////////////////////////////////////////////////////////
// Loading & disabling
diff --git a/engines/asylum/resources/special.cpp b/engines/asylum/resources/special.cpp
index b3e1288306..3c5ca27f87 100644
--- a/engines/asylum/resources/special.cpp
+++ b/engines/asylum/resources/special.cpp
@@ -242,10 +242,16 @@ void Special::chapter2(Object *object, ActorIndex actorIndex) {
Object *obj386 = getWorld()->objects[386];
actor->x1 = obj386->getSoundY();
- //actor->y1 = obj386->getField688() + ;
+ actor->y1 = obj386->getField688() + getWorld()->coordinates[22 - actorIndex];
+ actor->setFrameIndex(obj386->getField67C());
+ actor->setDirection(obj386->getField6A4());
+ // Get the resource Id
+ Actor *actor0 = getScene()->getActor(0);
+ Actor *actor13 = getScene()->getActor(13);
+ ResourceId id = actor0->getResourcesId(actor13->getDirection() > 4 ? 8 - actor13->getDirection() : actor13->getDirection());
- error("[Special::chapter2] Logic for actors 22-29 not implemented!");
+ actor->setResourceId(id);
}
break;
@@ -279,27 +285,125 @@ void Special::chapter3(Object *object, ActorIndex actorIndex) {
}
void Special::chapter4(Object *object, ActorIndex actorIndex) {
+ playChapterSound(object, actorIndex);
+
+ if (actorIndex != kActorInvalid)
+ return;
+
+ switch (object->getId()) {
+ default:
+ break;
+
+ case kObjectNPC033StartEnc:
+ if (object->getFrameIndex() == 15)
+ _vm->setGameFlag(kGameFlag387);
+ break;
+ case kObjectNPC033GetBook:
+ if (object->getFrameIndex() == 6)
+ _vm->clearGameFlag(kGameFlag387);
+ break;
+ }
}
void Special::chapter5(Object *object, ActorIndex actorIndex) {
+ setPaletteGamma(kResourcePalette_8001003B, getWorld()->currentPaletteId);
+
playChapterSound(object, actorIndex);
- if (actorIndex == kActorInvalid) {
- switch (object->getId()) {
- default:
- break;
+ if (actorIndex != kActorInvalid)
+ return;
- case kObjectNPC033StartEnc:
- if (object->getFrameIndex() == 15)
- _vm->setGameFlag(kGameFlag387);
- break;
+ switch (object->getId()) {
+ default:
+ break;
- case kObjectNPC033GetBook:
- if (object->getFrameIndex() == 6)
- _vm->clearGameFlag(kGameFlag387);
- break;
+ case kObjectBubbles:
+ if (_vm->isGameFlagSet(kGameFlag244)) {
+ if (object->getFrameIndex() == object->getFrameCount() - 1) {
+ _vm->clearGameFlag(kGameFlag244);
+ _vm->setGameFlag(kGameFlag245);
+
+ Object *glow = getWorld()->getObjectById(kObjectGlow);
+ glow->setNextFrame(glow->flags);
+ }
+ }
+ break;
+
+ case kObjectGlow:
+ if (_vm->isGameFlagSet(kGameFlag245)) {
+ if (object->getFrameIndex() == object->getFrameCount() - 1) {
+ _vm->clearGameFlag(kGameFlag245);
+ _vm->setGameFlag(kGameFlag246);
+
+ Object *dome = getWorld()->getObjectById(kObjectDome);
+ dome->setNextFrame(dome->flags);
+ }
+ } else {
+ if (object->getFrameIndex() == 1) {
+ FrameSoundItem *item = object->getFrameSoundItem(0);
+
+ item->resourceId = kResourceNone;
+ item->frameIndex = 0;
+ item->index = 0;
+ }
+ }
+ break;
+
+ case kObjectDome:
+ if (_vm->isGameFlagSet(kGameFlag246)) {
+ if (object->getFrameIndex() == object->getFrameCount() - 1) {
+ _vm->clearGameFlag(kGameFlag246);
+ _vm->setGameFlag(kGameFlag247);
+
+ Object *redlight = getWorld()->getObjectById(kObjectRedLight);
+ redlight->setNextFrame(redlight->flags);
+ }
+ }
+ break;
+
+ case kObjectRedLight:
+ if (_vm->isGameFlagSet(kGameFlag247)) {
+ if (object->getFrameIndex() == object->getFrameCount() - 1) {
+ _vm->clearGameFlag(kGameFlag247);
+ _vm->setGameFlag(kGameFlag248);
+
+ Object *ring = getWorld()->getObjectById(kObjectRing);
+ ring->setNextFrame(ring->flags);
+ }
+ }
+ break;
+
+ case kObjectRing:
+ if (_vm->isGameFlagSet(kGameFlag248)) {
+ if (object->getFrameIndex() == object->getFrameCount() - 1) {
+ _vm->clearGameFlag(kGameFlag248);
+
+ Object *ball = getWorld()->getObjectById(kObjectBallMovesUpright);
+ ball->setNextFrame(ball->flags);
+ }
+ }
+ break;
+
+ case kObjectBallMovesUpright:
+ if (object->getFrameIndex() == 7) {
+ Object *gears = getWorld()->getObjectById(kObjectGearsLightUp);
+ gears->setNextFrame(gears->flags);
+ } else {
+ if (object->getFrameIndex() == 1) {
+ FrameSoundItem *item = object->getFrameSoundItem(0);
+
+ item->resourceId = kResourceNone;
+ item->frameIndex = 0;
+ item->index = 0;
+ }
}
+ break;
+
+ case kObjectGearsLightUp:
+ if (object->getFrameIndex() == object->getFrameCount() - 1)
+ _vm->setGameFlag(kGameFlag243);
+ break;
}
}
@@ -415,7 +519,63 @@ void Special::chapter8(Object *object, ActorIndex actorIndex) {
}
void Special::chapter9(Object *object, ActorIndex actorIndex) {
+ playChapterSound(object, actorIndex);
+
+ if (actorIndex != kActorInvalid)
+ return;
+
+ switch(object->getId()) {
+ default:
+ break;
+
+ case kObjectBodySlides1:
+ case kObjectBodySlides2:
+ case kObjectBodySlides3:
+ case kObjectBodySlides4:
+ case kObjectBodySlides5:
+ case kObjectBodySlides6:
+ if (object->getFrameIndex() == 3) {
+ int counter = 0;
+
+ for (int i = 0; i < 6; ++i)
+ if (_vm->isGameFlagSet((GameFlag)(kGameFlag776 + i)))
+ ++counter;
+
+ switch (counter) {
+ default:
+ break;
+
+ case 0:
+ getScript()->queueScript(getWorld()->actions[getWorld()->getActionAreaIndexById(2524)]->scriptIndex, kActorMax);
+ break;
+
+ case 1:
+ getScript()->queueScript(getWorld()->actions[getWorld()->getActionAreaIndexById(2518)]->scriptIndex, kActorMax);
+ break;
+
+ case 2:
+ getScript()->queueScript(getWorld()->actions[getWorld()->getActionAreaIndexById(2519)]->scriptIndex, kActorMax);
+ break;
+
+ case 3:
+ getScript()->queueScript(getWorld()->actions[getWorld()->getActionAreaIndexById(2520)]->scriptIndex, kActorMax);
+ break;
+
+ case 4:
+ getScript()->queueScript(getWorld()->actions[getWorld()->getActionAreaIndexById(2521)]->scriptIndex, kActorMax);
+ break;
+
+ case 5:
+ getScript()->queueScript(getWorld()->actions[getWorld()->getActionAreaIndexById(2522)]->scriptIndex, kActorMax);
+ break;
+ case 6:
+ getScript()->queueScript(getWorld()->actions[getWorld()->getActionAreaIndexById(2523)]->scriptIndex, kActorMax);
+ break;
+ }
+ }
+ break;
+ }
}
//////////////////////////////////////////////////////////////////////////
@@ -502,6 +662,13 @@ void Special::playSoundChapter8(Object *object, ActorIndex actorIndex) {
error("[Special::playSoundChapter2] Not implemented!");
}
+//////////////////////////////////////////////////////////////////////////
+// Misc
+//////////////////////////////////////////////////////////////////////////
+void Special::setPaletteGamma(ResourceId palette1, ResourceId palette2) {
+ error("[Special::setPaletteGamma] Not implemented!");
+}
+
//////////////////////////////////////////////////////////////////////////
// Helpers
//////////////////////////////////////////////////////////////////////////
diff --git a/engines/asylum/resources/special.h b/engines/asylum/resources/special.h
index 3faaf6766a..727949d1c6 100644
--- a/engines/asylum/resources/special.h
+++ b/engines/asylum/resources/special.h
@@ -79,6 +79,11 @@ private:
void playSoundChapter7(Object *object, ActorIndex actorIndex);
void playSoundChapter8(Object *object, ActorIndex actorIndex);
+ //////////////////////////////////////////////////////////////////////////
+ // Misc
+ //////////////////////////////////////////////////////////////////////////
+ void setPaletteGamma(ResourceId palette1, ResourceId palette2);
+
//////////////////////////////////////////////////////////////////////////
// Helpers
//////////////////////////////////////////////////////////////////////////
diff --git a/engines/asylum/resources/worldstats.cpp b/engines/asylum/resources/worldstats.cpp
index 69878a3114..b0bb038db8 100644
--- a/engines/asylum/resources/worldstats.cpp
+++ b/engines/asylum/resources/worldstats.cpp
@@ -116,13 +116,10 @@ void WorldStats::load(Common::SeekableReadStream *stream) {
field_8C = stream->readSint32LE();
numActions = stream->readSint32LE();
numObjects = stream->readSint32LE();
- targetX = stream->readSint32LE();
- targetY = stream->readSint32LE();
- field_A0 = stream->readSint32LE();
- field_A4 = stream->readSint32LE();
- field_A8 = stream->readSint32LE();
- field_AC = stream->readSint32LE();
- field_B0 = stream->readSint32LE();
+
+ for (int32 c = 0; c < 7; c++)
+ coordinates[c] = stream->readSint32LE();
+
numActors = stream->readSint32LE();
stereoReversedFlag = stream->readSint32LE();
diff --git a/engines/asylum/resources/worldstats.h b/engines/asylum/resources/worldstats.h
index 40fe14ecfb..5f46384008 100644
--- a/engines/asylum/resources/worldstats.h
+++ b/engines/asylum/resources/worldstats.h
@@ -81,13 +81,13 @@ public:
int32 field_8C;
int32 numActions; // field_90
int32 numObjects;
- int32 targetX;
- int32 targetY;
- int32 field_A0;
- int32 field_A4;
- int32 field_A8;
- int32 field_AC;
- int32 field_B0;
+ int32 coordinates[7];
+ //int32 targetY;
+ //int32 field_A0;
+ //int32 field_A4;
+ //int32 field_A8;
+ //int32 field_AC;
+ //int32 field_B0;
int32 numActors;
int32 stereoReversedFlag;
Common::Rect sceneRects[6]; // including scene size rect
diff --git a/engines/asylum/shared.h b/engines/asylum/shared.h
index 328e4e6b64..a085d34456 100644
--- a/engines/asylum/shared.h
+++ b/engines/asylum/shared.h
@@ -40,6 +40,12 @@ enum GameFlag {
kGameFlagSolveVCRBlowUpPuzzle = 220,
kGameFlag238 = 238,
kGameFlag239 = 239,
+ kGameFlag243 = 243,
+ kGameFlag244 = 244,
+ kGameFlag245 = 245,
+ kGameFlag246 = 246,
+ kGameFlag247 = 247,
+ kGameFlag248 = 248,
kGameFlag279 = 279,
kGameFlag368 = 368,
kGameFlag371 = 371,
@@ -53,6 +59,7 @@ enum GameFlag {
kGameFlag454 = 454,
kGameFlag455 = 455,
kGameFlag556 = 556,
+ kGameFlag776 = 776,
kGameFlagFinishGame = 901,
kGameFlag1009 = 1009,
kGameFlag1021 = 1021,
@@ -84,18 +91,19 @@ enum ChapterIndex {
typedef unsigned int ResourceId;
enum ResourceIdEnum {
- kResourceNone = 0,
- kResourceSpeech_8000050A = 0x8000050A,
- kResourceMusic_80020000 = 0x80020000,
- kResourceMusic_80020001 = 0x80020001,
- kResourceSound_80030203 = 0x80030203,
+ kResourceNone = 0,
+ kResourceSpeech_8000050A = 0x8000050A,
+ kResourcePalette_8001003B = 0x8001003B,
+ kResourceMusic_80020000 = 0x80020000,
+ kResourceMusic_80020001 = 0x80020001,
+ kResourceSound_80030203 = 0x80030203,
// Base resource 0x80120000
- kResourceSound_80120001 = 0x80120001,
- kResourceSound_80120002 = 0x80120002,
- kResourceSound_80120005 = 0x80120005,
- kResourceSound_80120006 = 0x80120006,
- kResourceSoundIntro = 0x80120007,
- kResourceMusic_FFFFFD66 = 0xFFFFFD66
+ kResourceSound_80120001 = 0x80120001,
+ kResourceSound_80120002 = 0x80120002,
+ kResourceSound_80120005 = 0x80120005,
+ kResourceSound_80120006 = 0x80120006,
+ kResourceSoundIntro = 0x80120007,
+ kResourceMusic_FFFFFD66 = 0xFFFFFD66
};
//////////////////////////////////////////////////////////////////////////
@@ -266,6 +274,13 @@ enum ObjectId {
kObjectAngelFlares = 112,
kObjectGuyFalls = 434,
kObjectOpeningGate = 485,
+ kObjectBubbles = 1185,
+ kObjectGlow = 1186,
+ kObjectDome = 1187,
+ kObjectRedLight = 1188,
+ kObjectRing = 1189,
+ kObjectBallMovesUpright = 1190,
+ kObjectGearsLightUp = 1191,
kObjectGlobe = 1261,
kObjectFreezerHallInterior = 1337,
kObjectNPC033StartEnc = 1338,
@@ -277,7 +292,13 @@ enum ObjectId {
kObjectCrow3FlysAway = 1502,
kObjectCrow3Pecks = 1503,
kObjectCrow4FlysAway = 1506,
- kObjectCrow4Pecks = 1507
+ kObjectCrow4Pecks = 1507,
+ kObjectBodySlides1 = 2514,
+ kObjectBodySlides2 = 2515,
+ kObjectBodySlides3 = 2516,
+ kObjectBodySlides4 = 2517,
+ kObjectBodySlides5 = 2518,
+ kObjectBodySlides6 = 2519,
};
enum ObjectFlag {
diff --git a/engines/asylum/system/sound.h b/engines/asylum/system/sound.h
index a11ae1ef79..0f2a8450e4 100644
--- a/engines/asylum/system/sound.h
+++ b/engines/asylum/system/sound.h
@@ -50,7 +50,7 @@ struct SoundItem {
struct FrameSoundItem {
ResourceId resourceId;
- int32 frameIdx;
+ int32 frameIndex;
int32 index;
int32 field_C;
int32 field_10;
diff --git a/engines/asylum/views/scene.cpp b/engines/asylum/views/scene.cpp
index 7e60dce147..75da32b77b 100644
--- a/engines/asylum/views/scene.cpp
+++ b/engines/asylum/views/scene.cpp
@@ -278,19 +278,23 @@ void Scene::setScenePosition(int x, int y) {
GraphicFrame *bg = _bgResource->getFrame(0);
//_startX = x;
//_startY = y;
- _ws->targetX = x;
- _ws->targetY = y;
- if (_ws->targetX < 0)
- _ws->targetX = 0;
- if (_ws->targetX > (bg->surface.w - 640))
- _ws->targetX = bg->surface.w - 640;
+ int32 *targetX = &_ws->coordinates[0];
+ int32 *targetY = &_ws->coordinates[1];
+ *targetX = x;
+ *targetY = y;
- if (_ws->targetY < 0)
- _ws->targetY = 0;
- if (_ws->targetY > (bg->surface.h - 480))
- _ws->targetY = bg->surface.h - 480;
+ if (*targetX < 0)
+ *targetX = 0;
+ if (*targetX > (bg->surface.w - 640))
+ *targetX = bg->surface.w - 640;
+
+
+ if (*targetY < 0)
+ *targetY = 0;
+ if (*targetY > (bg->surface.h - 480))
+ *targetY = bg->surface.h - 480;
}
void Scene::handleEvent(Common::Event *event, bool doUpdate) {
@@ -976,62 +980,66 @@ void Scene::updateAdjustScreen() {
}
-bool Scene::updateSceneCoordinates(int32 targetX, int32 targetY, int32 A0, bool checkSceneCoords, int32 *param) {
+bool Scene::updateSceneCoordinates(int32 tX, int32 tY, int32 A0, bool checkSceneCoords, int32 *param) {
Common::Rect *sr = &_ws->sceneRects[_ws->sceneRectIdx];
- _ws->targetX = targetX;
- _ws->targetY = targetY;
+ int32 *targetX = &_ws->coordinates[0];
+ int32 *targetY = &_ws->coordinates[1];
+ int32 *coord3 = &_ws->coordinates[2];
+
+ *targetX = tX;
+ *targetY = tY;
- _ws->field_A0 = A0;
+ *coord3 = A0;
// Adjust coordinates
if (checkSceneCoords)
- if (_ws->targetX + 640 > _ws->width)
- _ws->targetX = _ws->width - 640;
+ if (*targetX + 640 > _ws->width)
+ *targetX = _ws->width - 640;
- if (_ws->targetX < sr->left)
- _ws->targetX = sr->left;
+ if (*targetX < sr->left)
+ *targetX = sr->left;
- if (_ws->targetY < sr->top)
- _ws->targetY = sr->top;
+ if (*targetY < sr->top)
+ *targetY = sr->top;
- if (_ws->targetX + 640 > sr->right)
- _ws->targetX = sr->right - 640;
+ if (*targetX + 640 > sr->right)
+ *targetX = sr->right - 640;
- if (_ws->targetY + 480 < sr->bottom)
- _ws->targetY = sr->bottom - 480;
+ if (*targetY + 480 < sr->bottom)
+ *targetY = sr->bottom - 480;
if (checkSceneCoords)
- if (_ws->targetY + 480 > _ws->height)
- _ws->targetY = _ws->height - 480;
+ if (*targetY + 480 > _ws->height)
+ *targetY = _ws->height - 480;
// Adjust scene offsets & coordinates
_sceneOffset = 0;
_sceneXLeft = _ws->xLeft;
_sceneYTop = _ws->yTop;
- int32 diffX = _ws->targetX - _ws->xLeft;
- int32 diffY = _ws->targetY - _ws->yTop;
+ int32 diffX = *targetX - _ws->xLeft;
+ int32 diffY = *targetY - _ws->yTop;
if (abs(diffX) <= abs(diffY)) {
- if (_ws->yTop > _ws->targetY)
- _ws->field_A0 = -_ws->field_A0;
+ if (_ws->yTop > *targetY)
+ *coord3 = -*coord3;
- _sceneOffsetAdd = Common::Rational(_ws->field_A0, diffY) * diffX;
+ _sceneOffsetAdd = Common::Rational(*coord3, diffY) * diffX;
- if (param != NULL && abs(diffY) <= abs(_ws->field_A0)) {
- _ws->targetX = -1;
+ if (param != NULL && abs(diffY) <= abs(*coord3)) {
+ *targetX = -1;
*param = 0;
return true;
}
} else {
- if (_ws->xLeft > _ws->targetX)
- _ws->field_A0 = -_ws->field_A0;
+ if (_ws->xLeft > *targetX)
+ *coord3 = -*coord3;
- _sceneOffsetAdd = Common::Rational(_ws->field_A0, diffX) * diffY;
+ _sceneOffsetAdd = Common::Rational(*coord3, diffX) * diffY;
- if (param != NULL && abs(diffX) <= abs(_ws->field_A0)) {
- _ws->targetX = -1;
+ if (param != NULL && abs(diffX) <= abs(*coord3)) {
+ *targetX = -1;
return true;
}
}
Commit: a821f1a58332534a2dfe52cfe91652073a18dfd4
https://github.com/scummvm/scummvm/commit/a821f1a58332534a2dfe52cfe91652073a18dfd4
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:11+02:00
Commit Message:
ASYLUM: Fix ClearScreen opcode
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@499 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/resources/actionlist.cpp
engines/asylum/resources/worldstats.h
engines/asylum/views/scene.h
diff --git a/engines/asylum/resources/actionlist.cpp b/engines/asylum/resources/actionlist.cpp
index 1ed33d1039..37dee632ee 100644
--- a/engines/asylum/resources/actionlist.cpp
+++ b/engines/asylum/resources/actionlist.cpp
@@ -1439,12 +1439,10 @@ IMPLEMENT_OPCODE(JumpRandom) {
//////////////////////////////////////////////////////////////////////////
// Opcode 0x4F
IMPLEMENT_OPCODE(ClearScreen) {
- if (cmd->param1) {
+ getScene()->setSkipDrawScene(cmd->param1);
+
+ if (cmd->param1)
getScreen()->clearScreen();
- _vm->setFlag(kFlagTypeSkipDraw);
- } else {
- _vm->clearFlag(kFlagTypeSkipDraw);
- }
}
//////////////////////////////////////////////////////////////////////////
diff --git a/engines/asylum/resources/worldstats.h b/engines/asylum/resources/worldstats.h
index 5f46384008..71ce36315d 100644
--- a/engines/asylum/resources/worldstats.h
+++ b/engines/asylum/resources/worldstats.h
@@ -82,12 +82,6 @@ public:
int32 numActions; // field_90
int32 numObjects;
int32 coordinates[7];
- //int32 targetY;
- //int32 field_A0;
- //int32 field_A4;
- //int32 field_A8;
- //int32 field_AC;
- //int32 field_B0;
int32 numActors;
int32 stereoReversedFlag;
Common::Rect sceneRects[6]; // including scene size rect
diff --git a/engines/asylum/views/scene.h b/engines/asylum/views/scene.h
index cf1df356df..2c641d8c7f 100644
--- a/engines/asylum/views/scene.h
+++ b/engines/asylum/views/scene.h
@@ -118,6 +118,7 @@ public:
//BlowUpPuzzle* getBlowUpPuzzle() { return _blowUp;}
//void setBlowUpPuzzle(BlowUpPuzzle* puzzle) { _blowUp = puzzle; }
void setScenePosition(int x, int y);
+ void setSkipDrawScene(bool skip) { _skipDrawScene = skip; }
AsylumEngine* vm() { return _vm; }
Commit: 88dab248d1d16575536a1b4946c052ada76fbe59
https://github.com/scummvm/scummvm/commit/88dab248d1d16575536a1b4946c052ada76fbe59
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:12+02:00
Commit Message:
ASYLUM: Implement enableActorsChapter2
- Moved from Special class to Actor (as a static function)
- Added TODO for update of shared data
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@500 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/resources/actor.cpp
engines/asylum/resources/actor.h
engines/asylum/resources/special.cpp
engines/asylum/resources/special.h
engines/asylum/shared.h
diff --git a/engines/asylum/resources/actor.cpp b/engines/asylum/resources/actor.cpp
index 0d6639912b..44ebb74031 100644
--- a/engines/asylum/resources/actor.cpp
+++ b/engines/asylum/resources/actor.cpp
@@ -779,6 +779,51 @@ void Actor::update_40DE20() {
error("[Actor::update_40DE20] not implemented!");
}
+//////////////////////////////////////////////////////////////////////////
+// Static update methods
+//////////////////////////////////////////////////////////////////////////
+void Actor::enableActorsChapter2(AsylumEngine *_vm) {
+ _vm->clearGameFlag(kGameFlag438);
+ _vm->clearGameFlag(kGameFlag439);
+ _vm->clearGameFlag(kGameFlag440);
+ _vm->clearGameFlag(kGameFlag441);
+ _vm->clearGameFlag(kGameFlag442);
+
+ // Update shared data
+ for (int i = 0; i < 9; i++) {
+ // TODO find out which data is updated
+ }
+
+ getScene()->getActor(13)->updateStatus(kActorStatusEnabled);
+ getScene()->getActor(13)->processStatus(2300, 71, false);
+
+ getScene()->getActor(14)->updateStatus(kActorStatusEnabled);
+ getScene()->getActor(14)->processStatus(2600, 1300, false);
+
+ getScene()->getActor(15)->updateStatus(kActorStatusEnabled);
+ getScene()->getActor(15)->processStatus(2742, 615, false);
+
+ getScene()->getActor(16)->updateStatus(kActorStatusEnabled);
+ getScene()->getActor(16)->processStatus(2700, 1200, false);
+
+ getScene()->getActor(17)->updateStatus(kActorStatusEnabled);
+ getScene()->getActor(17)->processStatus(2751, 347, false);
+
+ getScene()->getActor(18)->updateStatus(kActorStatusEnabled);
+ getScene()->getActor(18)->processStatus(2420, 284, false);
+
+ getScene()->getActor(19)->updateStatus(kActorStatusEnabled);
+ getScene()->getActor(19)->processStatus(2800, 370, false);
+
+ getScene()->getActor(20)->updateStatus(kActorStatusEnabled);
+ getScene()->getActor(20)->processStatus(1973, 1, false);
+
+ getScene()->getActor(21)->updateStatus(kActorStatusEnabled);
+ getScene()->getActor(21)->processStatus(2541, 40, false);
+
+ error("[Actor::enableActorsChapter2] Missing update shared data part!");
+}
+
//////////////////////////////////////////////////////////////////////////
// Update methods
//////////////////////////////////////////////////////////////////////////
diff --git a/engines/asylum/resources/actor.h b/engines/asylum/resources/actor.h
index c6ec5c1ab8..5e390cb55c 100644
--- a/engines/asylum/resources/actor.h
+++ b/engines/asylum/resources/actor.h
@@ -223,6 +223,11 @@ public:
bool process_41BDB0(int32 reactionIndex, bool testNumberValue01);
void update_40DE20();
+ //////////////////////////////////////////////////////////////////////////
+ // Static update methods
+ //////////////////////////////////////////////////////////////////////////
+ static void enableActorsChapter2(AsylumEngine *engine);
+
private:
AsylumEngine *_vm;
diff --git a/engines/asylum/resources/special.cpp b/engines/asylum/resources/special.cpp
index 3c5ca27f87..382f602539 100644
--- a/engines/asylum/resources/special.cpp
+++ b/engines/asylum/resources/special.cpp
@@ -98,13 +98,6 @@ void Special::run(Object* object, ActorIndex index) {
}
}
-//////////////////////////////////////////////////////////////////////////
-// Update methods
-//////////////////////////////////////////////////////////////////////////
-void Special::updateActors_41FDF0() {
- error("[Special::updateActors_41FDF0] not implemented!");
-}
-
//////////////////////////////////////////////////////////////////////////
// Spec functions
//////////////////////////////////////////////////////////////////////////
@@ -145,7 +138,7 @@ void Special::chapter2(Object *object, ActorIndex actorIndex) {
case kObjectOpeningGate:
if (_vm->isGameFlagSet(kGameFlag1137)) {
_vm->clearGameFlag(kGameFlag1137);
- updateActors_41FDF0();
+ Actor::enableActorsChapter2(_vm);
}
if (_vm->isGameFlagSet(kGameFlag1131) && !getSound()->isPlaying(getSound()->soundResourceId)) {
diff --git a/engines/asylum/resources/special.h b/engines/asylum/resources/special.h
index 727949d1c6..f4d7479b17 100644
--- a/engines/asylum/resources/special.h
+++ b/engines/asylum/resources/special.h
@@ -43,11 +43,6 @@ public:
void run(Object* object, ActorIndex index);
- //////////////////////////////////////////////////////////////////////////
- // Update methods
- //////////////////////////////////////////////////////////////////////////
- void updateActors_41FDF0();
-
private:
AsylumEngine* _vm;
diff --git a/engines/asylum/shared.h b/engines/asylum/shared.h
index a085d34456..915573dd90 100644
--- a/engines/asylum/shared.h
+++ b/engines/asylum/shared.h
@@ -50,6 +50,11 @@ enum GameFlag {
kGameFlag368 = 368,
kGameFlag371 = 371,
kGameFlag387 = 387,
+ kGameFlag438 = 438,
+ kGameFlag439 = 439,
+ kGameFlag440 = 440,
+ kGameFlag441 = 441,
+ kGameFlag442 = 442,
kGameFlag447 = 447,
kGameFlag448 = 448,
kGameFlag450 = 450,
Commit: 8eafe1b9110ef29ea08c57633cb2c9b423bae3b5
https://github.com/scummvm/scummvm/commit/8eafe1b9110ef29ea08c57633cb2c9b423bae3b5
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:12+02:00
Commit Message:
ASYLUM: Backed out revision 495 (fix object disable)
The flag update was done properly and the same as in the original.
The change prevented objects from being disabled and they would
stay on screen all the time.
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@501 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/resources/object.cpp
engines/asylum/shared.h
diff --git a/engines/asylum/resources/object.cpp b/engines/asylum/resources/object.cpp
index c26a927169..b9d0879bd7 100644
--- a/engines/asylum/resources/object.cpp
+++ b/engines/asylum/resources/object.cpp
@@ -116,7 +116,7 @@ void Object::load(Common::SeekableReadStream *stream) {
void Object::disable() {
- flags &= kObjectFlagDisabled;
+ flags &= ~kObjectFlagEnabled;
}
void Object::disableAndRemoveFromQueue() {
diff --git a/engines/asylum/shared.h b/engines/asylum/shared.h
index 915573dd90..a2541f6212 100644
--- a/engines/asylum/shared.h
+++ b/engines/asylum/shared.h
@@ -320,8 +320,7 @@ enum ObjectFlag {
kObjectFlag10000 = 0x10000,
kObjectFlag10E38 = 0x10E38,
kObjectFlag20000 = 0x20000,
- kObjectFlag40000 = 0x40000,
- kObjectFlagDisabled = 0xFFFFFFFF
+ kObjectFlag40000 = 0x40000
};
//////////////////////////////////////////////////////////////////////////
Commit: 43805ab2d81b2196cbde4632fa945a506e134228
https://github.com/scummvm/scummvm/commit/43805ab2d81b2196cbde4632fa945a506e134228
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:12+02:00
Commit Message:
ASYLUM: Fix some problems with the Actor code
- Fix typos that prevented updateStatus functions from being called
- Initalize the encounter flags properly
- Update error strings for not yet implemented special sound functions
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@502 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/resources/actor.cpp
engines/asylum/resources/encounters.cpp
engines/asylum/resources/object.cpp
engines/asylum/resources/special.cpp
diff --git a/engines/asylum/resources/actor.cpp b/engines/asylum/resources/actor.cpp
index 44ebb74031..80523993e2 100644
--- a/engines/asylum/resources/actor.cpp
+++ b/engines/asylum/resources/actor.cpp
@@ -428,15 +428,15 @@ void Actor::update() {
break;
case kActorStatus14:
- void updateStatus14();
+ updateStatus14();
break;
case kActorStatus21:
- void updateStatus21();
+ updateStatus21();
break;
case kActorStatus9:
- void updateStatus9();
+ updateStatus9();
break;
case kActorStatus6:
@@ -837,7 +837,7 @@ void Actor::updateStatusEnabled() {
// Actor: Crow
if (_vm->screenUpdatesCount - _lastScreenUpdate > 300) {
- if (strcmp(_name, "Crow")) {
+ if (strcmp((char *)&_name, "Crow")) {
if (_vm->getRandom(100) < 50
&& (!getSound()->soundResourceId || !getSound()->isPlaying(getSound()->soundResourceId))
&& isDefaultDirection(10))
diff --git a/engines/asylum/resources/encounters.cpp b/engines/asylum/resources/encounters.cpp
index 0c6e6e59d3..ad26e8607f 100644
--- a/engines/asylum/resources/encounters.cpp
+++ b/engines/asylum/resources/encounters.cpp
@@ -30,6 +30,8 @@
namespace Asylum {
Encounter::Encounter(Scene *scene) {
+ memset(_flags, 0, sizeof(_flags));
+
Common::File file;
// TODO error checks
diff --git a/engines/asylum/resources/object.cpp b/engines/asylum/resources/object.cpp
index b9d0879bd7..2464a54136 100644
--- a/engines/asylum/resources/object.cpp
+++ b/engines/asylum/resources/object.cpp
@@ -180,9 +180,9 @@ void Object::draw() {
Common::Point point;
getScene()->adjustCoordinates(x, y, &point);
- if (_field_67C <= 0 || _field_67C >= 4 || Config.performance <= 1)
+ if (_field_67C <= 0 || _field_67C >= 4 || Config.performance <= 1) {
getScreen()->addGraphicToQueue(_resourceId, _frameIndex, x, y, (flags >> 11) & kObjectFlag2, _field_67C - 3, _priority);
- else {
+ } else {
// TODO: Do Cross Fade
//getScreen()->addGraphicToQueue(_resourceId, _frameIndex, x, y, getWorld()->backgroundImage, getWorld()->xLeft, getWorld()->yTop, 0, 0, _field_67C - 1);
error("[Object::draw] Crossfade not implemented!");
diff --git a/engines/asylum/resources/special.cpp b/engines/asylum/resources/special.cpp
index 382f602539..37ed032e9a 100644
--- a/engines/asylum/resources/special.cpp
+++ b/engines/asylum/resources/special.cpp
@@ -628,7 +628,7 @@ void Special::playChapterSound(Object *object, ActorIndex actorIndex) {
}
void Special::playSoundChapter1(Object *object, ActorIndex actorIndex) {
- error("[Special::playSoundChapter2] Not implemented!");
+ //error("[Special::playSoundChapter1] Not implemented!");
}
void Special::playSoundChapter2(Object *object, ActorIndex actorIndex) {
@@ -636,23 +636,23 @@ void Special::playSoundChapter2(Object *object, ActorIndex actorIndex) {
}
void Special::playSoundChapter3(Object *object, ActorIndex actorIndex) {
- error("[Special::playSoundChapter2] Not implemented!");
+ error("[Special::playSoundChapter3] Not implemented!");
}
void Special::playSoundChapter4(Object *object, ActorIndex actorIndex) {
- error("[Special::playSoundChapter2] Not implemented!");
+ error("[Special::playSoundChapter4] Not implemented!");
}
void Special::playSoundChapter6(Object *object, ActorIndex actorIndex) {
- error("[Special::playSoundChapter2] Not implemented!");
+ error("[Special::playSoundChapter6] Not implemented!");
}
void Special::playSoundChapter7(Object *object, ActorIndex actorIndex) {
- error("[Special::playSoundChapter2] Not implemented!");
+ error("[Special::playSoundChapter7] Not implemented!");
}
void Special::playSoundChapter8(Object *object, ActorIndex actorIndex) {
- error("[Special::playSoundChapter2] Not implemented!");
+ error("[Special::playSoundChapter8] Not implemented!");
}
//////////////////////////////////////////////////////////////////////////
Commit: 9b7e72932d8153428e956ec4cf4339e2fb8b834a
https://github.com/scummvm/scummvm/commit/9b7e72932d8153428e956ec4cf4339e2fb8b834a
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:12+02:00
Commit Message:
ASYLUM: Fix object debug command
- Remove debug output in Object::toString()
- Added pack id & resource index to full output
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@503 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/console.cpp
engines/asylum/resources/object.cpp
diff --git a/engines/asylum/console.cpp b/engines/asylum/console.cpp
index 54c4471066..a52bb823e6 100644
--- a/engines/asylum/console.cpp
+++ b/engines/asylum/console.cpp
@@ -225,30 +225,28 @@ bool Console::cmdShowObject(int32 argc, const char **argv) {
return true;
}
- if (argc == 2) {
- if (Common::String(argv[1]) == "id") {
- int id = atoi(argv[2]);
- for (uint32 i = 0; i < getWorld()->objects.size(); i++) {
- if (getWorld()->objects[i]->getId() == id) {
- DebugPrintf("%s", getWorld()->objects[i]->toString(false).c_str());
- return true;
- }
- }
- DebugPrintf("No object with id %d found\n", id);
- } else if (Common::String(argv[1]) == "idx") {
- int index = atoi(argv[2]);
- int maxIndex = getWorld()->objects.size() - 1;
-
- if (index < 0 || index > maxIndex) {
- DebugPrintf("[error] index should be between 0 and %d\n", maxIndex);
+ if (Common::String(argv[1]) == "id") {
+ int id = atoi(argv[2]);
+ for (uint32 i = 0; i < getWorld()->objects.size(); i++) {
+ if (getWorld()->objects[i]->getId() == id) {
+ DebugPrintf("%s", getWorld()->objects[i]->toString(false).c_str());
return true;
}
+ }
+ DebugPrintf("No object with id %d found\n", id);
+ } else if (Common::String(argv[1]) == "idx") {
+ int index = atoi(argv[2]);
+ int maxIndex = getWorld()->objects.size() - 1;
- DebugPrintf("%s", getWorld()->objects[index]->toString().c_str());
-
- } else {
- DebugPrintf("[error] valid options are 'id' and 'idx'\n");
+ if (index < 0 || index > maxIndex) {
+ DebugPrintf("[error] index should be between 0 and %d\n", maxIndex);
+ return true;
}
+
+ DebugPrintf("%s", getWorld()->objects[index]->toString(false).c_str());
+
+ } else {
+ DebugPrintf("[error] valid options are 'id' and 'idx'\n");
}
return true;
diff --git a/engines/asylum/resources/object.cpp b/engines/asylum/resources/object.cpp
index 2464a54136..e24f427738 100644
--- a/engines/asylum/resources/object.cpp
+++ b/engines/asylum/resources/object.cpp
@@ -471,12 +471,10 @@ bool Object::checkFlags() {
Common::String Object::toString(bool shortString) {
Common::String output;
- debugC(kDebugLevelObjects, "kObject%s = %d,", _name, _id);
-
output += Common::String::format("Object %d: %s\n", _id, _name);
if (!shortString) {
- output += Common::String::format(" resourceId: %u (0x%X)\n", _resourceId, _resourceId);
+ output += Common::String::format(" resourceId: %u (0x%X) - (pack %d - index %d)\n", _resourceId, _resourceId, (_resourceId >> 16) & 0x7FFF, (int16)_resourceId);
output += Common::String::format(" x: %d\n", x);
output += Common::String::format(" y: %d\n", y);
output += Common::String::format(" flags: %d\n", flags);
Commit: 03bac323a6fe9deddb705ab7ab942e28d4b852ee
https://github.com/scummvm/scummvm/commit/03bac323a6fe9deddb705ab7ab942e28d4b852ee
Author: Alex Bevilacqua (alexbevi at gmail.com)
Date: 2021-05-17T15:36:12+02:00
Commit Message:
ASYLUM: silence warning and minor cleanup
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@504 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/resources/actionlist.cpp
engines/asylum/shared.h
diff --git a/engines/asylum/resources/actionlist.cpp b/engines/asylum/resources/actionlist.cpp
index 37dee632ee..9f8e7f69ed 100644
--- a/engines/asylum/resources/actionlist.cpp
+++ b/engines/asylum/resources/actionlist.cpp
@@ -254,7 +254,7 @@ bool ActionList::process() {
int32 opcode = cmd->opcode;
- debugC(kDebugLevelScripts, "[0x%02X] %s(%d, %d, %d, %d, %d, %d, %d, %d, %d)",
+ debugC(kDebugLevelScripts, "[0x%02X] %s (%d, %d, %d, %d, %d, %d, %d, %d, %d)",
opcode, _opcodes[opcode]->name,
cmd->param1, cmd->param2, cmd->param3, cmd->param4, cmd->param5,
cmd->param6, cmd->param7, cmd->param8, cmd->param9);
@@ -491,7 +491,7 @@ IMPLEMENT_OPCODE(EnableObjects) {
Object *object = getWorld()->getObjectById((ObjectId)cmd->param1);
if (!_currentScript->counter && getWorld()->numChapter != 13)
- _vm->sound()->playSound(cmd->param3 ? kResourceSound_80120006 : kResourceSound_80120001, false, Config.sfxVolume, 0);
+ _vm->sound()->playSound(cmd->param3 ? kResourceSound_80120006 : kResourceSound_80120001);
if (_currentScript->counter >= (3 * cmd->param2 - 1)) {
_currentScript->counter = 0;
@@ -896,7 +896,7 @@ IMPLEMENT_OPCODE(PlayMovie) {
// XXX casting kResourceMusic_FFFFFD66 to silence a GCC warning
if (!check &&
getScene()->matteVar2 == 0 &&
- getWorld()->musicCurrentResourceId != (int)kResourceMusic_FFFFFD66)
+ getWorld()->musicCurrentResourceId != kResourceMusic_FFFFFD66)
if (_vm->sound()->isCacheOk())
_vm->sound()->playMusic(getScene()->getResourcePack(), getWorld()->musicCurrentResourceId + kResourceMusic_80020000);
@@ -1451,7 +1451,8 @@ IMPLEMENT_OPCODE(Quit) {
getScreen()->clearScreen();
_vm->quitGame();
- // We need to exit the interpreter loop so we get back to the event loop and get the quit message
+ // We need to exit the interpreter loop so we get back to the event loop
+ // and get the quit message
_exit = true;
}
@@ -1647,7 +1648,7 @@ IMPLEMENT_OPCODE(_unk5B) {
//////////////////////////////////////////////////////////////////////////
// Opcode 0x5C
IMPLEMENT_OPCODE(QueueScript) {
- queueScript( getWorld()->getActionAreaById(cmd->param1)->scriptIndex, cmd->param2);
+ queueScript(getWorld()->getActionAreaById(cmd->param1)->scriptIndex, cmd->param2);
}
//////////////////////////////////////////////////////////////////////////
diff --git a/engines/asylum/shared.h b/engines/asylum/shared.h
index a2541f6212..71a44c898a 100644
--- a/engines/asylum/shared.h
+++ b/engines/asylum/shared.h
@@ -303,7 +303,7 @@ enum ObjectId {
kObjectBodySlides3 = 2516,
kObjectBodySlides4 = 2517,
kObjectBodySlides5 = 2518,
- kObjectBodySlides6 = 2519,
+ kObjectBodySlides6 = 2519
};
enum ObjectFlag {
Commit: 66982f21af13c5dba4d7cf741608cf506e7176b3
https://github.com/scummvm/scummvm/commit/66982f21af13c5dba4d7cf741608cf506e7176b3
Author: Alex Bevilacqua (alexbevi at gmail.com)
Date: 2021-05-17T15:36:12+02:00
Commit Message:
ASYLUM: remove unnecessary comment
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@505 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/resources/actionlist.cpp
diff --git a/engines/asylum/resources/actionlist.cpp b/engines/asylum/resources/actionlist.cpp
index 9f8e7f69ed..d1e49bf911 100644
--- a/engines/asylum/resources/actionlist.cpp
+++ b/engines/asylum/resources/actionlist.cpp
@@ -893,7 +893,6 @@ IMPLEMENT_OPCODE(PlayMovie) {
check = true;
}
- // XXX casting kResourceMusic_FFFFFD66 to silence a GCC warning
if (!check &&
getScene()->matteVar2 == 0 &&
getWorld()->musicCurrentResourceId != kResourceMusic_FFFFFD66)
Commit: 51b9a95e510343ea9ed20f56b152a400bfe731f8
https://github.com/scummvm/scummvm/commit/51b9a95e510343ea9ed20f56b152a400bfe731f8
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:12+02:00
Commit Message:
ASYLUM: Get rid of numActors/Objects/Actions
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@506 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/console.cpp
engines/asylum/resources/worldstats.cpp
engines/asylum/resources/worldstats.h
engines/asylum/views/scene.cpp
diff --git a/engines/asylum/console.cpp b/engines/asylum/console.cpp
index a52bb823e6..35a51e4ed9 100644
--- a/engines/asylum/console.cpp
+++ b/engines/asylum/console.cpp
@@ -265,9 +265,15 @@ bool Console::cmdListObjects(int32 argc, const char **argv) {
DebugPrintf("%s", getWorld()->objects[i]->toString().c_str());
}
}
+
+ DebugPrintf("Total: %d\n", getWorld()->objects.size());
+
} else if (Common::String(argv[1]) == "*"){
for (uint32 i = 0; i < getWorld()->objects.size(); i++)
DebugPrintf("%s", getWorld()->objects[i]->toString().c_str());
+
+ DebugPrintf("Total: %d\n", getWorld()->objects.size());
+
} else {
DebugPrintf("[error] valid options are 'onscreen' and '*'\n");
}
diff --git a/engines/asylum/resources/worldstats.cpp b/engines/asylum/resources/worldstats.cpp
index b0bb038db8..2ae65c6234 100644
--- a/engines/asylum/resources/worldstats.cpp
+++ b/engines/asylum/resources/worldstats.cpp
@@ -45,7 +45,7 @@ WorldStats::~WorldStats() {
}
int32 WorldStats::getActionAreaIndexById(int32 id) {
- for (int32 i = 0; i < numActions; i++) {
+ for (uint32 i = 0; i < actions.size(); i++) {
if (actions[i]->id == id)
return i;
}
@@ -62,7 +62,7 @@ ActionArea* WorldStats::getActionAreaById(int32 id) {
}
Object* WorldStats::getObjectById(ObjectId id) {
- for (int32 i = 0; i < numObjects; i++)
+ for (uint32 i = 0; i < objects.size(); i++)
if (objects[i]->getId() == id)
return objects[i];
@@ -114,13 +114,13 @@ void WorldStats::load(Common::SeekableReadStream *stream) {
height = stream->readSint32LE();
motionStatus = stream->readSint32LE();
field_8C = stream->readSint32LE();
- numActions = stream->readSint32LE();
- numObjects = stream->readSint32LE();
+ uint32 numActions = stream->readUint32LE();
+ uint32 numObjects = stream->readUint32LE();
for (int32 c = 0; c < 7; c++)
coordinates[c] = stream->readSint32LE();
- numActors = stream->readSint32LE();
+ uint32 numActors = stream->readUint32LE();
stereoReversedFlag = stream->readSint32LE();
@@ -143,7 +143,7 @@ void WorldStats::load(Common::SeekableReadStream *stream) {
sceneTitleGraphicResourceId = stream->readSint32LE();
sceneTitlePaletteResourceId = stream->readSint32LE();
- actorType = stream->readSint32LE();
+ actorType = stream->readUint32LE();
for (int32 s = 0; s < 50; s++)
soundResourceIds[s] = stream->readSint32LE();
@@ -170,25 +170,25 @@ void WorldStats::load(Common::SeekableReadStream *stream) {
musicResourceId = stream->readSint32LE();
musicStatusExt = stream->readSint32LE();
- for (int32 a = 0; a < numObjects; a++) {
+ for (uint32 a = 0; a < numObjects; a++) {
Object *object = new Object(_scene->vm());
object->load(stream);
objects.push_back(object);
}
- // need to jump all unused objects data to where actors data start
- stream->seek(0xA6D7A);
+ // Jump over unused objects
+ stream->seek((OBJECTS_MAX_COUNT - numObjects) * OBJECTS_SIZE, SEEK_CUR);
- for (ActorIndex index = 0; index < numActors; index++) {
+ for (ActorIndex index = 0; index < (int)numActors; index++) {
Actor *actor = new Actor(_scene->vm(), index);
actor->load(stream);
actors.push_back(actor);
}
- // TODO Take this out, it shouldn't be here (TEST ONLY)
- stream->seek(0xA73B6);
+ // Jump over unused actors
+ stream->seek((ACTORS_MAX_COUNT - numActors) * ACTORS_SIZE, SEEK_CUR);
uint8 mainActorData[500];
stream->read(mainActorData, 500);
@@ -201,7 +201,7 @@ void WorldStats::load(Common::SeekableReadStream *stream) {
stream->seek(0xD6B5A); // where action items start
// FIXME Figure out all the actions items
- for (int32 a = 0; a < numActions; a++) {
+ for (uint32 a = 0; a < numActions; a++) {
ActionArea *action = new ActionArea();
stream->read(action->name, 52);
@@ -233,6 +233,9 @@ void WorldStats::load(Common::SeekableReadStream *stream) {
actions.push_back(action);
}
+
+ // Jump over unused actions
+ stream->seek((ACTIONS_MAX_COUNT - numActions) * ACTIONS_SIZE, SEEK_CUR);
}
} // end of namespace Asylum
diff --git a/engines/asylum/resources/worldstats.h b/engines/asylum/resources/worldstats.h
index 71ce36315d..d17307c7f2 100644
--- a/engines/asylum/resources/worldstats.h
+++ b/engines/asylum/resources/worldstats.h
@@ -33,6 +33,14 @@
namespace Asylum {
+#define ACTORS_MAX_COUNT 50
+#define OBJECTS_MAX_COUNT 400
+#define ACTIONS_MAX_COUNT 400
+
+#define ACTORS_SIZE 2468
+#define OBJECTS_SIZE 1704
+#define ACTIONS_SIZE 180
+
class Actor;
class Object;
class Scene;
@@ -79,10 +87,10 @@ public:
int32 height;
int32 motionStatus;
int32 field_8C;
- int32 numActions; // field_90
- int32 numObjects;
+ //uint32 numActions;
+ //uint32 numObjects;
int32 coordinates[7];
- int32 numActors;
+ //uint32 numActors;
int32 stereoReversedFlag;
Common::Rect sceneRects[6]; // including scene size rect
uint8 sceneRectIdx;
diff --git a/engines/asylum/views/scene.cpp b/engines/asylum/views/scene.cpp
index 75da32b77b..ae1174965b 100644
--- a/engines/asylum/views/scene.cpp
+++ b/engines/asylum/views/scene.cpp
@@ -119,7 +119,7 @@ Scene::Scene(uint8 sceneIdx, AsylumEngine *engine): _vm(engine) {
// TODO figure out what field_120 is used for
_ws->field_120 = -1;
- for (int32 a = 0; a < _ws->numActors; a++)
+ for (uint32 a = 0; a < _ws->actors.size(); a++)
_ws->actors[a]->setLastScreenUpdate(_vm->getTick());
// TODO: init action list
@@ -138,9 +138,9 @@ void Scene::initialize() {
_playerActorIdx = 0;
- if (_ws->numObjects > 0) {
+ if (_ws->objects.size() > 0) {
int32 priority = 4091;
- for (int32 b = 0; b < _ws->numObjects; b++) {
+ for (uint32 b = 0; b < _ws->objects.size(); b++) {
Object *object = _ws->objects[b];
object->setPriority(priority);
object->flags &= ~kObjectFlagC000;
@@ -167,8 +167,8 @@ void Scene::initialize() {
actor->flags |= 1;
actor->updateStatus(kActorStatusEnabled);
- if (_ws->numActors > 1) {
- for (int32 a = 1; a < _ws->numActors; a++) {
+ if (_ws->actors.size() > 1) {
+ for (uint32 a = 1; a < _ws->actors.size(); a++) {
Actor *act = _ws->actors[a];
act->flags |= 1;
act->setDirection(1);
@@ -674,7 +674,7 @@ void Scene::handleMouseUpdate(int direction, Common::Rect rect) {
int32 Scene::hitTestObject(const Common::Point pt) {
int32 targetIdx = -1;
- for (int32 i = 0; i < _ws->numObjects; i++) {
+ for (uint32 i = 0; i < _ws->objects.size(); i++) {
Object *object = _ws->objects[i];
if (object->isOnScreen())
if (object->getPolygonIndex())
@@ -719,7 +719,7 @@ int32 Scene::findActionArea(const Common::Point pt) {
// function, as this doesn't do any of the flag checking
// the original did
int32 targetIdx = -1;
- for (int32 i = 0; i < _ws->numActions; i++) {
+ for (uint32 i = 0; i < _ws->actions.size(); i++) {
ActionArea *a = _ws->actions[i];
PolyDefinitions p = _polygons->entries[a->polyIdx];
if (p.contains(pt.x, pt.y)) {
@@ -1149,7 +1149,7 @@ void Scene::processUpdateList() {
Common::Rect actorRect(actor->x1, actor->y1, actor->x1 + actor->getBoundingRect()->right, bottomRight);
// Process objects
- for (int32 j = 0; j < _ws->numObjects; j++) {
+ for (uint32 j = 0; j < _ws->objects.size(); j++) {
Object *object = _ws->objects[i];
// Skip hidden objects
@@ -1404,7 +1404,7 @@ void Scene::debugShowPolygons() {
// OBJECT DEBUGGING
void Scene::debugShowObjects() {
- for (int32 p = 0; p < _ws->numObjects; p++) {
+ for (uint32 p = 0; p < _ws->objects.size(); p++) {
Graphics::Surface surface;
Object *object = _ws->objects[p];
@@ -1422,7 +1422,7 @@ void Scene::debugShowObjects() {
// ACTOR DEBUGGING
void Scene::debugShowActors() {
- for (int32 p = 0; p < _ws->numActors; p++) {
+ for (uint32 p = 0; p < _ws->actors.size(); p++) {
Graphics::Surface surface;
Actor *a = _ws->actors[p];
Commit: de67e921e2cba3d016a59895b5619a9bfb6ea269
https://github.com/scummvm/scummvm/commit/de67e921e2cba3d016a59895b5619a9bfb6ea269
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:13+02:00
Commit Message:
ASYLUM: Do not try to play music with an empty ResourceId
This fixes part of scene loading
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@507 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/system/sound.cpp
diff --git a/engines/asylum/system/sound.cpp b/engines/asylum/system/sound.cpp
index 68010f792f..0ea3e54c2e 100644
--- a/engines/asylum/system/sound.cpp
+++ b/engines/asylum/system/sound.cpp
@@ -260,6 +260,9 @@ void Sound::setSpeech(ResourceId sound, ResourceId speechText) {
}
void Sound::playMusic(ResourcePack *pack, ResourceId resourceId, int32 volume) {
+ if (resourceId == kResourceNone)
+ return;
+
stopMusic();
ResourceEntry *resource = pack->getResource(resourceId);
Commit: fdb53b6b1337e6a4410244b1703f734b7fd4c671
https://github.com/scummvm/scummvm/commit/fdb53b6b1337e6a4410244b1703f734b7fd4c671
Author: Alex Bevilacqua (alexbevi at gmail.com)
Date: 2021-05-17T15:36:13+02:00
Commit Message:
ASYLUM: expand Actor::toString to show a more detailed view when examining a particular actor
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@508 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/console.cpp
engines/asylum/resources/actor.cpp
engines/asylum/resources/actor.h
diff --git a/engines/asylum/console.cpp b/engines/asylum/console.cpp
index 35a51e4ed9..a890717d5e 100644
--- a/engines/asylum/console.cpp
+++ b/engines/asylum/console.cpp
@@ -173,7 +173,7 @@ bool Console::cmdListActors(int32 argc, const char **argv) {
return true;
}
- DebugPrintf("%s\n", getWorld()->actors[index]->toString().c_str());
+ DebugPrintf("%s\n", getWorld()->actors[index]->toString(false).c_str());
}
return true;
diff --git a/engines/asylum/resources/actor.cpp b/engines/asylum/resources/actor.cpp
index 80523993e2..ce56e35e62 100644
--- a/engines/asylum/resources/actor.cpp
+++ b/engines/asylum/resources/actor.cpp
@@ -719,10 +719,30 @@ void Actor::stopSound() {
getSound()->stopSound(_soundResourceId);
}
-Common::String Actor::toString() {
+Common::String Actor::toString(bool shortString) {
Common::String output;
output += Common::String::format("Actor %d: %s\n", _index, _name);
+ if (!shortString) {
+ output += Common::String::format("resourceId: %d (0x%X): \n", _resourceId, _resourceId);
+ output += Common::String::format("objectIndex: %d: \n", _objectIndex);
+ output += Common::String::format("frameIndex: %d: \n", _frameIndex);
+ output += Common::String::format("frameCount: %d: \n", _frameCount);
+ output += Common::String::format("x: %d: \n", x);
+ output += Common::String::format("y: %d: \n", y);
+ output += Common::String::format("x1: %d: \n", x1);
+ output += Common::String::format("y1: %d: \n", y1);
+ output += Common::String::format("x2: %d: \n", x2);
+ output += Common::String::format("y2: %d: \n", y2);
+ output += Common::String::format("flags: %d: \n", flags);
+ output += Common::String::format("actionType: %d: \n", actionType);
+ output += Common::String::format("boundingRect: top[%d] left[%d] right[%d] bottom[%d]: \n", _boundingRect.top, _boundingRect.left, _boundingRect.right, _boundingRect.bottom);
+ output += Common::String::format("direction: %d: \n", _direction);
+ output += Common::String::format("field_3C: %d: \n", _field_3C);
+ output += Common::String::format("status: %d: \n", _status);
+ output += Common::String::format("field_44: %d: \n", _field_44);
+ output += Common::String::format("priority: %d: \n", _priority);
+ }
return output;
}
diff --git a/engines/asylum/resources/actor.h b/engines/asylum/resources/actor.h
index 5e390cb55c..da4e968288 100644
--- a/engines/asylum/resources/actor.h
+++ b/engines/asylum/resources/actor.h
@@ -195,9 +195,11 @@ public:
/**
* Convert this object into a string representation.
*
+ * @param shortString toggle whether to output a summary or
+ * detailed view of the actor object
* @return A string representation of this object.
*/
- Common::String toString();
+ Common::String toString(bool shortString = true);
/**
* Clears actor data fields (TODO what are those fields?)
Commit: 20754d9dd9cb671e36bedd8dc275ad7c4553f76b
https://github.com/scummvm/scummvm/commit/20754d9dd9cb671e36bedd8dc275ad7c4553f76b
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:13+02:00
Commit Message:
ASYLUM: Initialize scene before entering it
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@509 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/asylum.cpp
diff --git a/engines/asylum/asylum.cpp b/engines/asylum/asylum.cpp
index c1981d14cd..24d03634ad 100644
--- a/engines/asylum/asylum.cpp
+++ b/engines/asylum/asylum.cpp
@@ -323,6 +323,7 @@ void AsylumEngine::processDelayedEvents() {
delete _scene;
_scene = new Scene(sceneIdx, this);
+ _scene->initialize();
_scene->enterScene();
}
}
Commit: fd534e562eed9860d8fa7bf2d2238652c0b3502b
https://github.com/scummvm/scummvm/commit/fd534e562eed9860d8fa7bf2d2238652c0b3502b
Author: Alex Bevilacqua (alexbevi at gmail.com)
Date: 2021-05-17T15:36:13+02:00
Commit Message:
ASYLUM: implement Actor::updateStatus9()
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@510 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/resources/actor.cpp
engines/asylum/resources/actor.h
diff --git a/engines/asylum/resources/actor.cpp b/engines/asylum/resources/actor.cpp
index ce56e35e62..32eb73f1fc 100644
--- a/engines/asylum/resources/actor.cpp
+++ b/engines/asylum/resources/actor.cpp
@@ -924,8 +924,67 @@ void Actor::updateStatusEnabled() {
}
}
+ResourceId Actor::getResourceFromTable() {
+ ResourceId id = kResourceNone;
+
+ if (_status == kActorStatus9) {
+ for (int i = 10; i <= 20; i++)
+ if (_resourceId == _graphicResourceIds[i])
+ return _graphicResourceIds[i];
+ }
+
+ return id;
+
+ /* TODO Here's the disassembly if someone could verify my implementation ;)
+ int __cdecl character_sub_4093D0(int characterIndex)
+ {
+ int result; // eax at 1
+ int v2; // edx at 1
+ char *_grResTableEntry; // edx at 2
+ signed int v4; // ecx at 2
+ int _grResId; // esi at 2
+
+ result = 0;
+ v2 = 2468 * characterIndex;
+ if ( scene.characters[characterIndex].status == 9 )
+ {
+ _grResId = *(int *)((char *)&scene.characters[0].grResId + v2);
+ v4 = 10;
+ _grResTableEntry = (char *)&scene.characters[0].grResTable[10] + v2;
+ while ( *(_DWORD *)_grResTableEntry != _grResId )
+ {
+ ++v4;
+ _grResTableEntry += 4;
+ if ( v4 >= 20 )
+ return result;
+ }
+ result = v4 < 15;
+ LOBYTE(result) = v4 >= 15;
+ }
+ return result;
+ }
+ */
+}
+
void Actor::updateStatus9() {
- error("[Actor::updateStatus9] not implemented!");
+ if (getWorld()->numChapter != 9 && getWorld()->actorType == 0 && _frameIndex == 0) {
+ // FIXME I don't really understand why this check would be necessary here
+ // since we're not really doing anything with the result, and it doesn't
+ // really matter whether it's missing or not ....
+ if (getResourceFromTable() != kResourceNone) {
+ Sound *snd = getSound();
+ if (!snd->soundResourceId || !snd->isPlaying(snd->soundResourceId)) {
+ snd->playSpeech(13);
+ }
+ }
+ }
+
+ _frameIndex++;
+
+ if (_frameIndex == _frameCount) {
+ updateStatus(kActorStatusEnabled);
+ _lastScreenUpdate = _vm->screenUpdatesCount;
+ }
}
void Actor::updateStatus12_Chapter2() {
diff --git a/engines/asylum/resources/actor.h b/engines/asylum/resources/actor.h
index da4e968288..84fb10d4e8 100644
--- a/engines/asylum/resources/actor.h
+++ b/engines/asylum/resources/actor.h
@@ -215,6 +215,14 @@ public:
*/
void setRawResources(uint8* data);
+ /**
+ * Get an entry from the graphicsResourceTable between indices 10 and 20 if
+ * it matches the current resourceId value
+ *
+ * TODO This whole method probably isn't required
+ */
+ ResourceId getResourceFromTable();
+
// Unknown methods
bool process(int32 actorX, int32 actorY);
void processStatus(int32 actorX, int32 actorY, bool doSpeech);
Commit: ef1ebc55da8bc53312afa7f54558a9a5902abcf8
https://github.com/scummvm/scummvm/commit/ef1ebc55da8bc53312afa7f54558a9a5902abcf8
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:13+02:00
Commit Message:
ASYLUM: Extract SceneTitle to its own file
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@511 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
A engines/asylum/views/scenetitle.cpp
A engines/asylum/views/scenetitle.h
engines/asylum/module.mk
engines/asylum/shared.h
engines/asylum/views/scene.cpp
engines/asylum/views/scene.h
diff --git a/engines/asylum/module.mk b/engines/asylum/module.mk
index 0bc74b7bfc..bd8b6f545b 100644
--- a/engines/asylum/module.mk
+++ b/engines/asylum/module.mk
@@ -19,6 +19,7 @@ MODULE_OBJS := \
views/blowuppuzzle.o \
views/menu.o \
views/scene.o \
+ views/scenetitle.o \
asylum.o \
console.o \
detection.o \
diff --git a/engines/asylum/shared.h b/engines/asylum/shared.h
index 71a44c898a..45faf93271 100644
--- a/engines/asylum/shared.h
+++ b/engines/asylum/shared.h
@@ -349,6 +349,7 @@ enum ObjectFlag {
#define getScreen() _vm->screen()
#define getScript() _vm->scene()->actions()
#define getSpeech() _vm->scene()->speech()
+#define getText() _vm->text()
#define getWorld() _vm->scene()->worldstats()
//////////////////////////////////////////////////////////////////////////
diff --git a/engines/asylum/views/scene.cpp b/engines/asylum/views/scene.cpp
index ae1174965b..18116df60f 100644
--- a/engines/asylum/views/scene.cpp
+++ b/engines/asylum/views/scene.cpp
@@ -40,6 +40,8 @@
#include "asylum/system/speech.h"
#include "asylum/system/text.h"
+#include "asylum/views/scenetitle.h"
+
#include "asylum/asylum.h"
#include "asylum/respack.h"
#include "asylum/staticres.h"
@@ -124,7 +126,7 @@ Scene::Scene(uint8 sceneIdx, AsylumEngine *engine): _vm(engine) {
// TODO: init action list
- _title = new SceneTitle(this);
+ _title = new SceneTitle(_vm);
_titleLoaded = false;
_special = new Special(_vm);
@@ -1466,82 +1468,4 @@ void Scene::resetActor0() {
error("[Scene::resetActor0] not implemented!");
}
-//////////////////////////////////////////////////////////////////////////
-// SceneTitle
-//////////////////////////////////////////////////////////////////////////
-SceneTitle::SceneTitle(Scene *scene): _scene(scene) {
- _bg = NULL;
- _progress = NULL;
-}
-
-SceneTitle::~SceneTitle() {
- delete _bg;
- delete _progress;
-}
-
-void SceneTitle::load() {
- _start = _scene->vm()->getTick();
-
- _bg = new GraphicResource(_scene->_resPack, _scene->_ws->sceneTitleGraphicResourceId);
- _scene->vm()->screen()->setPalette(_scene->_resPack, _scene->_ws->sceneTitlePaletteResourceId);
-
- ResourcePack *pack = new ResourcePack(0x12);
- _progress = new GraphicResource(pack, 0x80120011);
- _spinnerProgress = 0;
- _spinnerFrame = 0;
-
- _scene->vm()->text()->loadFont(pack, 0x80120012);
-
- delete pack;
-
- _done = false;
- _showMouseState = g_system->showMouse(false);
-}
-
-void SceneTitle::update(int32 tick) {
-
- // XXX This is not from the original. It's just some
- // arbitrary math to throttle the progress indicator.
- // In the game, the scene loading progress indicated
- // how far the engine had progressed in terms of buffering
- // the various scene resource.
- // Since we don't actually buffer content like the original,
- // but load on demand from offset/length within a ResourcePack,
- // the progress indicator is effectively useless.
- // It's just in here as "eye candy" :P
- if ((tick - _start) % 500 > 100)
- _spinnerProgress += 20;
-
- GraphicFrame *bgFrame = _bg->getFrame(0);
-
- _scene->vm()->screen()->copyToBackBuffer(
- ((byte *)bgFrame->surface.pixels),
- bgFrame->surface.w,
- 0, 0, 640, 480);
-
- ResourceId resourceId = _scene->getSceneIndex() - 4 + 1811;
- int32 resWidth = _scene->vm()->text()->getResTextWidth(resourceId);
- _scene->vm()->text()->drawResTextCentered(320 - resWidth * 24, 30, resWidth, resourceId);
-
- GraphicFrame *frame = _progress->getFrame(_spinnerFrame);
-
- _scene->vm()->screen()->copyRectToScreenWithTransparency(
- ((byte*)frame->surface.pixels),
- frame->surface.w,
- frame->x - 290 + _spinnerProgress,
- frame->y,
- frame->surface.w,
- frame->surface.h);
-
- _spinnerFrame++;
-
- if (_spinnerFrame > _progress->getFrameCount() - 1)
- _spinnerFrame = 0;
-
- if (_spinnerProgress > 590) {
- _done = true;
- g_system->showMouse(_showMouseState);
- }
-}
-
} // end of namespace Asylum
diff --git a/engines/asylum/views/scene.h b/engines/asylum/views/scene.h
index 2c641d8c7f..61876b54cc 100644
--- a/engines/asylum/views/scene.h
+++ b/engines/asylum/views/scene.h
@@ -41,12 +41,12 @@ namespace Asylum {
class ActionList;
class Actor;
class AsylumEngine;
-//class BlowUpPuzzle;
+class BlowUpPuzzle;
class Cursor;
class GraphicResource;
class Polygons;
class ResourcePack;
-class Scene;
+class SceneTitle;
class Screen;
class Special;
class Speech;
@@ -67,32 +67,6 @@ enum HitType {
kHitActor = 4
};
-class SceneTitle {
-public:
- SceneTitle(Scene *scene);
- ~SceneTitle();
-
- void load();
-
- void update(int32 tick);
- bool loadingComplete() { return _done; }
-
-private:
- Scene *_scene;
-
- GraphicResource *_bg;
- GraphicResource *_progress;
-
- int32 _start;
- int32 _ticks;
- bool _done;
- uint32 _spinnerFrame;
- int32 _spinnerProgress;
- bool _showMouseState;
-
-}; // end of class SceneTitle
-
-
class Scene {
public:
Scene(uint8 sceneIdx, AsylumEngine *engine);
diff --git a/engines/asylum/views/scenetitle.cpp b/engines/asylum/views/scenetitle.cpp
new file mode 100644
index 0000000000..10aaa7a545
--- /dev/null
+++ b/engines/asylum/views/scenetitle.cpp
@@ -0,0 +1,112 @@
+/* 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.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#include "asylum/views/scenetitle.h"
+
+#include "asylum/resources/worldstats.h"
+
+#include "asylum/system/graphics.h"
+#include "asylum/system/screen.h"
+#include "asylum/system/text.h"
+
+#include "asylum/views/scene.h"
+
+#include "asylum/asylum.h"
+#include "asylum/respack.h"
+
+namespace Asylum {
+
+SceneTitle::SceneTitle(AsylumEngine *engine): _vm(engine), _bg(NULL), _progress(NULL) {
+}
+
+SceneTitle::~SceneTitle() {
+ delete _bg;
+ delete _progress;
+
+ // Zero passed pointers
+ _vm = NULL;
+}
+
+void SceneTitle::load() {
+ _start = _vm->getTick();
+
+ _bg = new GraphicResource(getScene()->getResourcePack(), getWorld()->sceneTitleGraphicResourceId);
+ getScreen()->setPalette(getScene()->getResourcePack(), getWorld()->sceneTitlePaletteResourceId);
+
+ ResourcePack *pack = new ResourcePack(0x12);
+ _progress = new GraphicResource(pack, 0x80120011);
+ _spinnerProgress = 0;
+ _spinnerFrame = 0;
+
+ getText()->loadFont(pack, 0x80120012);
+
+ delete pack;
+
+ _done = false;
+ _showMouseState = g_system->showMouse(false);
+}
+
+void SceneTitle::update(int32 tick) {
+
+ // This is not from the original. It's just some arbitrary math to throttle the progress indicator.
+ //
+ // In the game, the scene loading progress indicated how far the engine had progressed in terms
+ // of buffering the various scene resource. Since we don't actually buffer content like the original,
+ // but load on demand from offset/length within a ResourcePack, the progress indicator is effectively
+ // useless. It's just in here as "eye candy" :P
+ if ((tick - _start) % 500 > 100)
+ _spinnerProgress += 20;
+
+ GraphicFrame *bgFrame = _bg->getFrame(0);
+
+ getScreen()->copyToBackBuffer(((byte *)bgFrame->surface.pixels),
+ bgFrame->surface.w,
+ 0, 0, 640, 480);
+
+ ResourceId resourceId = getScene()->getSceneIndex() - 4 + 1811;
+ int32 resWidth = getText()->getResTextWidth(resourceId);
+ getText()->drawResTextCentered(320 - resWidth * 24, 30, resWidth, resourceId);
+
+ GraphicFrame *frame = _progress->getFrame(_spinnerFrame);
+
+ getScreen()->copyRectToScreenWithTransparency(((byte*)frame->surface.pixels),
+ frame->surface.w,
+ frame->x - 290 + _spinnerProgress,
+ frame->y,
+ frame->surface.w,
+ frame->surface.h);
+
+ _spinnerFrame++;
+
+ if (_spinnerFrame > _progress->getFrameCount() - 1)
+ _spinnerFrame = 0;
+
+ if (_spinnerProgress > 590) {
+ _done = true;
+ g_system->showMouse(_showMouseState);
+ }
+}
+
+} // End of namespace Asylum
diff --git a/engines/asylum/views/scenetitle.h b/engines/asylum/views/scenetitle.h
new file mode 100644
index 0000000000..4ef38e8c0a
--- /dev/null
+++ b/engines/asylum/views/scenetitle.h
@@ -0,0 +1,63 @@
+/* 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.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#ifndef ASYLUM_SCENETITLE_H
+#define ASYLUM_SCENETITLE_H
+
+#include "common/scummsys.h"
+
+namespace Asylum {
+
+class AsylumEngine;
+class GraphicResource;
+
+class SceneTitle {
+public:
+ SceneTitle(AsylumEngine *engine);
+ ~SceneTitle();
+
+ void load();
+
+ void update(int32 tick);
+ bool loadingComplete() { return _done; }
+
+private:
+ AsylumEngine *_vm;
+
+ GraphicResource *_bg;
+ GraphicResource *_progress;
+
+ int32 _start;
+ int32 _ticks;
+ bool _done;
+ uint32 _spinnerFrame;
+ int32 _spinnerProgress;
+ bool _showMouseState;
+
+};
+
+} // End of namespace Asylum
+
+#endif // ASYLUM_SCENETITLE_H
Commit: ee438adbdce7112c30d0363b29535a22051de35b
https://github.com/scummvm/scummvm/commit/ee438adbdce7112c30d0363b29535a22051de35b
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:13+02:00
Commit Message:
ASYLUM: Introduce ResourcePackId
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@512 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/asylum.cpp
engines/asylum/console.cpp
engines/asylum/resources/actionlist.cpp
engines/asylum/resources/actionlist.h
engines/asylum/respack.cpp
engines/asylum/respack.h
engines/asylum/shared.h
engines/asylum/system/sound.cpp
engines/asylum/system/text.cpp
engines/asylum/system/video.cpp
engines/asylum/views/menu.cpp
engines/asylum/views/scene.cpp
engines/asylum/views/scene.h
engines/asylum/views/scenetitle.cpp
diff --git a/engines/asylum/asylum.cpp b/engines/asylum/asylum.cpp
index 24d03634ad..c20a888ad2 100644
--- a/engines/asylum/asylum.cpp
+++ b/engines/asylum/asylum.cpp
@@ -152,7 +152,7 @@ void AsylumEngine::startGame() {
if (_scene)
delete _scene;
- _scene = new Scene(5, this);
+ _scene = new Scene(kResourcePackTowerCells, this);
if (Config.showIntro)
playIntro();
@@ -308,13 +308,13 @@ void AsylumEngine::processDelayedEvents() {
}
// check for a delayed scene change
- int sceneIdx = _scene->actions()->getDelayedSceneIndex();
+ ResourcePackId packId = _scene->actions()->getDelayedSceneIndex();
// XXX Flag 183 indicates whether the actionlist is currently
// processing
- if (sceneIdx >= 0 && isGameFlagNotSet(kGameFlagScriptProcessing)) {
+ if (packId >= 0 && isGameFlagNotSet(kGameFlagScriptProcessing)) {
// Reset delayed scene
- _scene->actions()->setDelayedSceneIndex(-1);
+ _scene->actions()->setDelayedSceneIndex(kResourcePackInvalid);
_sound->stopMusic();
_sound->stopAllSounds();
@@ -322,7 +322,7 @@ void AsylumEngine::processDelayedEvents() {
if (_scene)
delete _scene;
- _scene = new Scene(sceneIdx, this);
+ _scene = new Scene(packId, this);
_scene->initialize();
_scene->enterScene();
}
diff --git a/engines/asylum/console.cpp b/engines/asylum/console.cpp
index a890717d5e..4b080eba39 100644
--- a/engines/asylum/console.cpp
+++ b/engines/asylum/console.cpp
@@ -324,7 +324,7 @@ bool Console::cmdChangeScene(int32 argc, const char **argv) {
return true;
}
- int index = atoi(argv[1]);
+ ResourcePackId index = (ResourcePackId)atoi(argv[1]);
// Check if the scene exists
char filename[20];
diff --git a/engines/asylum/resources/actionlist.cpp b/engines/asylum/resources/actionlist.cpp
index d1e49bf911..4b1a848ab1 100644
--- a/engines/asylum/resources/actionlist.cpp
+++ b/engines/asylum/resources/actionlist.cpp
@@ -206,7 +206,7 @@ void ActionList::reset() {
_currentLine = 0;
_currentLoops = 0;
_currentScript = NULL;
- _delayedSceneIndex = -1;
+ _delayedSceneIndex = kResourcePackInvalid;
_delayedVideoIndex = -1;
_done = false;
_exit = false;
@@ -772,7 +772,7 @@ IMPLEMENT_OPCODE(ChangeScene) {
_vm->sound()->stopAllSounds(true);
// Change the scene number
- _delayedSceneIndex = cmd->param1 + 4;
+ _delayedSceneIndex = (ResourcePackId)(cmd->param1 + 4);
_exit = true;
}
diff --git a/engines/asylum/resources/actionlist.h b/engines/asylum/resources/actionlist.h
index 10cfda24d4..67b6973f21 100644
--- a/engines/asylum/resources/actionlist.h
+++ b/engines/asylum/resources/actionlist.h
@@ -113,8 +113,8 @@ public:
// Accessors
int32 getDelayedVideoIndex() const { return _delayedVideoIndex; }
void setDelayedVideoIndex(int32 val) { _delayedVideoIndex = val; }
- int32 getDelayedSceneIndex() const { return _delayedSceneIndex; }
- void setDelayedSceneIndex(int32 val) { _delayedSceneIndex = val; }
+ ResourcePackId getDelayedSceneIndex() const { return _delayedSceneIndex; }
+ void setDelayedSceneIndex(ResourcePackId id) { _delayedSceneIndex = id; }
bool isProcessingSkipped() { return _skipProcessing; }
@@ -181,7 +181,7 @@ private:
int32 _currentLoops;
Script *_currentScript;
ScriptQueueEntry _currentQueueEntry;
- int32 _delayedSceneIndex;
+ ResourcePackId _delayedSceneIndex;
int32 _delayedVideoIndex;
bool _done;
bool _exit;
diff --git a/engines/asylum/respack.cpp b/engines/asylum/respack.cpp
index 87e377128c..d45e861b3d 100644
--- a/engines/asylum/respack.cpp
+++ b/engines/asylum/respack.cpp
@@ -31,11 +31,11 @@ ResourcePack::ResourcePack(const char *resourceFile) {
init(resourceFile);
}
-ResourcePack::ResourcePack(int32 resourceIndex) {
+ResourcePack::ResourcePack(ResourcePackId id) {
// We don't use the file number part of resource IDs
//uint32 fileNum = (resourceID >> 16) & 0x7FFF;
char filename[20];
- sprintf(filename, "res.%03d", resourceIndex);
+ sprintf(filename, "res.%03d", id);
init(filename);
}
diff --git a/engines/asylum/respack.h b/engines/asylum/respack.h
index 285382f0e5..31614b7757 100644
--- a/engines/asylum/respack.h
+++ b/engines/asylum/respack.h
@@ -42,7 +42,7 @@ struct ResourceEntry {
class ResourcePack {
public:
ResourcePack(const char *resourceFile);
- ResourcePack(int32 resourceIndex);
+ ResourcePack(ResourcePackId id);
~ResourcePack();
ResourceEntry *getResource(ResourceId resourceId);
diff --git a/engines/asylum/shared.h b/engines/asylum/shared.h
index 45faf93271..4547ec3f75 100644
--- a/engines/asylum/shared.h
+++ b/engines/asylum/shared.h
@@ -93,6 +93,33 @@ enum ChapterIndex {
// Resources
//////////////////////////////////////////////////////////////////////////
+enum ResourcePackId {
+ kResourcePackInvalid = -1,
+ kResourcePackText = 0,
+ kResourcePackShared = 1,
+ // No resource pack 2
+ kResourcePackSpeech = 3,
+ // No resource pack 4
+ kResourcePackTowerCells = 5,
+ kResourcePackInnocentAbandoned = 6,
+ kResourcePackCourtyardAndChapel = 7,
+ kResourcePackCircusOfFools = 8,
+ kResourcePackCave = 9,
+ kResourcePackMansion = 10,
+ kResourcePackLaboratory = 11,
+ kResourcePackHive = 12,
+ kResourcePackMorgueAndCementary = 13,
+ kResourcePackLostVillage = 14,
+ kResourcePackMaze = 15,
+ kResourcePackGauntlet = 16,
+ kResourcePackMorgansLastGame = 17,
+ kResourcePackSound = 18,
+ kResourcePack104 = 104,
+ kResourcePack204 = 204,
+ kResourcePack304 = 304
+};
+
+
typedef unsigned int ResourceId;
enum ResourceIdEnum {
diff --git a/engines/asylum/system/sound.cpp b/engines/asylum/system/sound.cpp
index 0ea3e54c2e..a95bc54d29 100644
--- a/engines/asylum/system/sound.cpp
+++ b/engines/asylum/system/sound.cpp
@@ -39,8 +39,8 @@
namespace Asylum {
Sound::Sound(Audio::Mixer *mixer) : _mixer(mixer) {
- _speechPack = new ResourcePack(3);
- _soundPack = new ResourcePack(18);
+ _speechPack = new ResourcePack(kResourcePackSpeech);
+ _soundPack = new ResourcePack(kResourcePackSound);
_currentMusicResIndex = -666;
}
diff --git a/engines/asylum/system/text.cpp b/engines/asylum/system/text.cpp
index a27c1327e5..55bd94b59a 100644
--- a/engines/asylum/system/text.cpp
+++ b/engines/asylum/system/text.cpp
@@ -40,7 +40,7 @@ Text::Text(Screen *screen) : _screen(screen) {
_curFontFlags = 0;
_fontResource = 0;
- _textPack = new ResourcePack(0);
+ _textPack = new ResourcePack(kResourcePackText);
}
Text::~Text() {
diff --git a/engines/asylum/system/video.cpp b/engines/asylum/system/video.cpp
index aebf34271b..0761c4d8a6 100644
--- a/engines/asylum/system/video.cpp
+++ b/engines/asylum/system/video.cpp
@@ -43,7 +43,7 @@ Video::Video(Audio::Mixer *mixer): _skipVideo(false) {
_smkDecoder = new Graphics::SmackerDecoder(mixer);
_text = new VideoText();
- ResourcePack *resPack = new ResourcePack(1);
+ ResourcePack *resPack = new ResourcePack(kResourcePackShared);
_text->loadFont(resPack, 57); // video font
delete resPack;
}
@@ -189,7 +189,7 @@ VideoText::VideoText() {
_curFontFlags = 0;
_fontResource = 0;
- _textPack = new ResourcePack(0);
+ _textPack = new ResourcePack(kResourcePackText);
}
VideoText::~VideoText() {
diff --git a/engines/asylum/views/menu.cpp b/engines/asylum/views/menu.cpp
index 09dc64ca41..d5a818bdb9 100644
--- a/engines/asylum/views/menu.cpp
+++ b/engines/asylum/views/menu.cpp
@@ -56,7 +56,7 @@ MainMenu::MainMenu(AsylumEngine *vm): _vm(vm) {
Config.gammaLevel = 2;
Config.performance = 5;
- _resPack = new ResourcePack(1);
+ _resPack = new ResourcePack(kResourcePackShared);
_bgResource = new GraphicResource(_resPack, 0);
_eyeResource = new GraphicResource(_resPack, 1);
diff --git a/engines/asylum/views/scene.cpp b/engines/asylum/views/scene.cpp
index 18116df60f..c19f72ae03 100644
--- a/engines/asylum/views/scene.cpp
+++ b/engines/asylum/views/scene.cpp
@@ -57,11 +57,11 @@ int g_debugPolygons;
int g_debugObjects;
int g_debugScrolling;
-Scene::Scene(uint8 sceneIdx, AsylumEngine *engine): _vm(engine) {
- _sceneIdx = sceneIdx;
+Scene::Scene(ResourcePackId packId, AsylumEngine *engine): _vm(engine) {
+ _packId = packId;
char filename[10];
- sprintf(filename, SCENE_FILE_MASK, sceneIdx);
+ sprintf(filename, SCENE_FILE_MASK, _packId);
char sceneTag[6];
Common::File* fd = new Common::File;
@@ -92,7 +92,7 @@ Scene::Scene(uint8 sceneIdx, AsylumEngine *engine): _vm(engine) {
delete fd;
_speech = new Speech(this);
- _resPack = new ResourcePack(sceneIdx);
+ _resPack = new ResourcePack(_packId);
// TODO
// This will have to be re-initialized elsewhere due to
@@ -100,7 +100,7 @@ Scene::Scene(uint8 sceneIdx, AsylumEngine *engine): _vm(engine) {
_vm->text()->loadFont(_resPack, _ws->font1);
char musPackFileName[10];
- sprintf(musPackFileName, MUSIC_FILE_MASK, sceneIdx);
+ sprintf(musPackFileName, MUSIC_FILE_MASK, packId);
_musPack = new ResourcePack(musPackFileName);
_bgResource = new GraphicResource(_resPack, _ws->backgroundImage);
@@ -174,7 +174,7 @@ void Scene::initialize() {
Actor *act = _ws->actors[a];
act->flags |= 1;
act->setDirection(1);
- getActor(a)->updateStatus(kActorStatusEnabled);
+ act->updateStatus(kActorStatusEnabled);
act->x1 -= act->x2;
act->y1 -= act->y2;
boundinRect->bottom = act->y2;
@@ -419,7 +419,7 @@ void Scene::updateMouse() {
pt.x = act->x1 -_ws->xLeft;
pt.y = act->y1 -_ws->yTop;
- if (_sceneIdx != 2 || _playerActorIdx != 10) {
+ if (_packId != 2 || _playerActorIdx != 10) {
actorPos.left = pt.x + 20;
actorPos.top = pt.y;
actorPos.right = pt.x + 2 * act->x2;
diff --git a/engines/asylum/views/scene.h b/engines/asylum/views/scene.h
index 61876b54cc..fe2a0ddd04 100644
--- a/engines/asylum/views/scene.h
+++ b/engines/asylum/views/scene.h
@@ -69,7 +69,7 @@ enum HitType {
class Scene {
public:
- Scene(uint8 sceneIdx, AsylumEngine *engine);
+ Scene(ResourcePackId packId, AsylumEngine *engine);
~Scene();
/** .text:0040E460
@@ -84,7 +84,7 @@ public:
void activate() { _isActive = true; }
void deactivate() { _isActive = false; }
bool isActive() { return _isActive; }
- int getSceneIndex() { return _sceneIdx; }
+ ResourcePackId getPackId() { return _packId; }
ResourcePack* getResourcePack() { return _resPack; }
ResourcePack* getMusicPack() { return _musPack; }
@@ -218,7 +218,7 @@ private:
AsylumEngine *_vm;
Common::Event *_ev;
- uint8 _sceneIdx;
+ ResourcePackId _packId;
int32 _playerActorIdx;
bool _titleLoaded;
bool _walking;
diff --git a/engines/asylum/views/scenetitle.cpp b/engines/asylum/views/scenetitle.cpp
index 10aaa7a545..d7bed596c0 100644
--- a/engines/asylum/views/scenetitle.cpp
+++ b/engines/asylum/views/scenetitle.cpp
@@ -55,7 +55,7 @@ void SceneTitle::load() {
_bg = new GraphicResource(getScene()->getResourcePack(), getWorld()->sceneTitleGraphicResourceId);
getScreen()->setPalette(getScene()->getResourcePack(), getWorld()->sceneTitlePaletteResourceId);
- ResourcePack *pack = new ResourcePack(0x12);
+ ResourcePack *pack = new ResourcePack(kResourcePackSound);
_progress = new GraphicResource(pack, 0x80120011);
_spinnerProgress = 0;
_spinnerFrame = 0;
@@ -85,7 +85,7 @@ void SceneTitle::update(int32 tick) {
bgFrame->surface.w,
0, 0, 640, 480);
- ResourceId resourceId = getScene()->getSceneIndex() - 4 + 1811;
+ ResourceId resourceId = getScene()->getPackId() - 4 + 1811;
int32 resWidth = getText()->getResTextWidth(resourceId);
getText()->drawResTextCentered(320 - resWidth * 24, 30, resWidth, resourceId);
Commit: d7c22354a66ac59945ca79ddcf51f7eee27855a3
https://github.com/scummvm/scummvm/commit/d7c22354a66ac59945ca79ddcf51f7eee27855a3
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:13+02:00
Commit Message:
ASYLUM: Add ResourceManager class
It will keep track of opened resource files and simplify handling of resource packs
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@513 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/asylum.cpp
engines/asylum/asylum.h
engines/asylum/resources/actionlist.cpp
engines/asylum/resources/actionlist.h
engines/asylum/resources/actor.cpp
engines/asylum/resources/encounters.cpp
engines/asylum/resources/object.cpp
engines/asylum/resources/object.h
engines/asylum/resources/special.cpp
engines/asylum/resources/worldstats.cpp
engines/asylum/resources/worldstats.h
engines/asylum/respack.cpp
engines/asylum/respack.h
engines/asylum/shared.h
engines/asylum/system/cursor.cpp
engines/asylum/system/cursor.h
engines/asylum/system/graphics.cpp
engines/asylum/system/graphics.h
engines/asylum/system/screen.cpp
engines/asylum/system/screen.h
engines/asylum/system/sound.cpp
engines/asylum/system/sound.h
engines/asylum/system/speech.cpp
engines/asylum/system/speech.h
engines/asylum/system/text.cpp
engines/asylum/system/text.h
engines/asylum/system/video.cpp
engines/asylum/system/video.h
engines/asylum/views/blowuppuzzle.cpp
engines/asylum/views/blowuppuzzle.h
engines/asylum/views/menu.cpp
engines/asylum/views/scene.cpp
engines/asylum/views/scene.h
engines/asylum/views/scenetitle.cpp
diff --git a/engines/asylum/asylum.cpp b/engines/asylum/asylum.cpp
index c20a888ad2..b5e9214dfd 100644
--- a/engines/asylum/asylum.cpp
+++ b/engines/asylum/asylum.cpp
@@ -49,7 +49,9 @@
namespace Asylum {
-AsylumEngine::AsylumEngine(OSystem *system, const ADGameDescription *gd) : Engine(system), _gameDescription(gd) {
+AsylumEngine::AsylumEngine(OSystem *system, const ADGameDescription *gd) : Engine(system), _gameDescription(gd),
+ _console(NULL), _encounter(NULL), _resource(NULL), _mainMenu(NULL), _scene(NULL), _screen(NULL),
+ _sound(NULL), _text(NULL), _video(NULL) {
// Add default search directories
const Common::FSNode gameDataDir(ConfMan.get("path"));
@@ -58,16 +60,16 @@ AsylumEngine::AsylumEngine(OSystem *system, const ADGameDescription *gd) : Engin
SearchMan.addSubDirectoryMatching(gameDataDir, "music");
// Initialize custom debug levels
- DebugMan.addDebugChannel(kDebugLevelMain, "Main", "Generic debug level");
+ DebugMan.addDebugChannel(kDebugLevelMain, "Main", "Generic debug level");
DebugMan.addDebugChannel(kDebugLevelResources, "Resources", "Resources debugging");
- DebugMan.addDebugChannel(kDebugLevelSprites, "Sprites", "Sprites debugging");
- DebugMan.addDebugChannel(kDebugLevelInput, "Input", "Input events debugging");
- DebugMan.addDebugChannel(kDebugLevelMenu, "Menu", "Menu debugging");
- DebugMan.addDebugChannel(kDebugLevelScripts, "Scripts", "Scripts debugging");
- DebugMan.addDebugChannel(kDebugLevelSound, "Sound", "Sound debugging");
- DebugMan.addDebugChannel(kDebugLevelSavegame, "Savegame", "Saving & restoring game debugging");
- DebugMan.addDebugChannel(kDebugLevelScene, "Scene", "Scene process and draw debugging");
- DebugMan.addDebugChannel(kDebugLevelObjects, "Objects", "Debug Object Objects");
+ DebugMan.addDebugChannel(kDebugLevelSprites, "Sprites", "Sprites debugging");
+ DebugMan.addDebugChannel(kDebugLevelInput, "Input", "Input events debugging");
+ DebugMan.addDebugChannel(kDebugLevelMenu, "Menu", "Menu debugging");
+ DebugMan.addDebugChannel(kDebugLevelScripts, "Scripts", "Scripts debugging");
+ DebugMan.addDebugChannel(kDebugLevelSound, "Sound", "Sound debugging");
+ DebugMan.addDebugChannel(kDebugLevelSavegame, "Savegame", "Saving & restoring game debugging");
+ DebugMan.addDebugChannel(kDebugLevelScene, "Scene", "Scene process and draw debugging");
+ DebugMan.addDebugChannel(kDebugLevelObjects, "Objects", "Debug Object Objects");
// Initialize random number source
g_eventRec.registerRandomSource(_rnd, "asylum");
@@ -76,6 +78,7 @@ AsylumEngine::AsylumEngine(OSystem *system, const ADGameDescription *gd) : Engin
AsylumEngine::~AsylumEngine() {
delete _console;
delete _encounter;
+ delete _resource;
delete _mainMenu;
delete _scene;
delete _screen;
@@ -95,10 +98,11 @@ Common::Error AsylumEngine::run() {
_console = new Console(this);
// Create all manager classes
+ _resource = new ResourceManager();
_screen = new Screen(this);
- _sound = new Sound(_mixer);
- _video = new Video(_mixer);
- _text = new Text(_screen);
+ _sound = new Sound(this, _mixer);
+ _video = new Video(this, _mixer);
+ _text = new Text(this);
_scene = NULL;
_encounter = NULL;
@@ -193,7 +197,7 @@ void AsylumEngine::playIntro() {
// Play the intro sound sample (the screen is blacked out, you hear
// an alarm sounding and men talking about.
- _sound->playSound(kResourceSoundIntro);
+ _sound->playSound(MAKE_RESOURCE(kResourcePackSound, 7));
}
void AsylumEngine::handleEvents(bool doUpdate) { // k_sub_40AE30 (0040AE30)
@@ -213,7 +217,7 @@ void AsylumEngine::handleEvents(bool doUpdate) { // k_sub_40AE30 (0040AE30)
// by moving the logic to the event loop and checking whether a flag is
// set to determine if control should be returned to the engine.
if (_introPlaying) {
- if (!_sound->isPlaying(0x80120007)) {
+ if (!_sound->isPlaying(MAKE_RESOURCE(kResourcePackSound, 7))) {
_introPlaying = false;
// TODO Since we've currently only got one sfx handle to play with in
diff --git a/engines/asylum/asylum.h b/engines/asylum/asylum.h
index dbae8072bb..3bbfdf015d 100644
--- a/engines/asylum/asylum.h
+++ b/engines/asylum/asylum.h
@@ -72,6 +72,7 @@ enum FlagType {
class Encounter;
class MainMenu;
+class ResourceManager;
class Scene;
class Screen;
class Sound;
@@ -109,13 +110,14 @@ public:
uint32 globalTickValue_2;
// Game
- Encounter *encounter() { return _encounter; }
- MainMenu *menu() { return _mainMenu; }
- Scene *scene() { return _scene; }
- Screen *screen() { return _screen; }
- Sound *sound() { return _sound; }
- Text *text() { return _text; }
- Video *video() { return _video; }
+ Encounter *encounter() { return _encounter; }
+ MainMenu *menu() { return _mainMenu; }
+ ResourceManager *resource() { return _resource; }
+ Scene *scene() { return _scene; }
+ Screen *screen() { return _screen; }
+ Sound *sound() { return _sound; }
+ Text *text() { return _text; }
+ Video *video() { return _video; }
// Flags
void setGameFlag(GameFlag flag);
@@ -144,13 +146,14 @@ private:
Common::RandomSource _rnd;
// Game
- Encounter *_encounter;
- MainMenu *_mainMenu;
- Scene *_scene;
- Screen *_screen;
- Sound *_sound;
- Text *_text;
- Video *_video;
+ Encounter *_encounter;
+ MainMenu *_mainMenu;
+ ResourceManager *_resource;
+ Scene *_scene;
+ Screen *_screen;
+ Sound *_sound;
+ Text *_text;
+ Video *_video;
bool _introPlaying;
int _gameFlags[1512];
diff --git a/engines/asylum/resources/actionlist.cpp b/engines/asylum/resources/actionlist.cpp
index 4b1a848ab1..709a63ec11 100644
--- a/engines/asylum/resources/actionlist.cpp
+++ b/engines/asylum/resources/actionlist.cpp
@@ -386,7 +386,7 @@ IMPLEMENT_OPCODE(PlayAnimation) {
getScene()->setGlobalX(object->x);
getScene()->setGlobalY(object->y);
} else {
- GraphicResource *res = new GraphicResource(getScene()->getResourcePack(), object->getResourceId());
+ GraphicResource *res = new GraphicResource(_vm, object->getResourceId());
GraphicFrame *frame = res->getFrame(object->getFrameIndex());
getScene()->setGlobalX(frame->x + (frame->getWidth() >> 1) + object->x);
@@ -490,8 +490,8 @@ IMPLEMENT_OPCODE(EnableActor) {
IMPLEMENT_OPCODE(EnableObjects) {
Object *object = getWorld()->getObjectById((ObjectId)cmd->param1);
- if (!_currentScript->counter && getWorld()->numChapter != 13)
- _vm->sound()->playSound(cmd->param3 ? kResourceSound_80120006 : kResourceSound_80120001);
+ if (!_currentScript->counter && getWorld()->chapter != 13)
+ _vm->sound()->playSound(cmd->param3 ? MAKE_RESOURCE(kResourcePackSound, 6) : MAKE_RESOURCE(kResourcePackSound, 1));
if (_currentScript->counter >= (3 * cmd->param2 - 1)) {
_currentScript->counter = 0;
@@ -610,13 +610,13 @@ IMPLEMENT_OPCODE(DisableObject) {
// Opcode 0x18
IMPLEMENT_OPCODE(JumpIfSoundPlayingAndPlaySound) {
if (cmd->param2 == 2) {
- if (_vm->sound()->isPlaying(cmd->param1))
+ if (getSound()->isPlaying((ResourceId)cmd->param1))
_lineIncrement = 1;
else
cmd->param2 = 1;
- } else if (!_vm->sound()->isPlaying(cmd->param1)) {
- int32 vol = _vm->sound()->getAdjustedVolume(abs(Config.sfxVolume));
- _vm->sound()->playSound(cmd->param1, cmd->param4, -((abs(cmd->param3) + vol) * (abs(cmd->param3) + vol)), 0);
+ } else if (!_vm->sound()->isPlaying((ResourceId)cmd->param1)) {
+ int32 vol = getSound()->getAdjustedVolume(abs(Config.sfxVolume));
+ getSound()->playSound((ResourceId)cmd->param1, cmd->param4, -((abs(cmd->param3) + vol) * (abs(cmd->param3) + vol)), 0);
if (cmd->param2 == 1) {
cmd->param2 = 2;
@@ -823,13 +823,13 @@ IMPLEMENT_OPCODE(_unk2C_ActorSub) {
}
} else if (cmd->param1 != 2 || player->process_408B20(&playerPoint, (player->getDirection() + 4) % 8, 3, false)) {
- ResourceId id = 0;
+ ResourceId id = kResourceNone;
if (direction >= 5)
id = actor->getResourcesId(5 * cmd->param1 - direction + 38);
else
id = actor->getResourcesId(5 * cmd->param1 + direction + 30);
- GraphicResource *res = new GraphicResource(getScene()->getResourcePack(), id);
+ GraphicResource *res = new GraphicResource(_vm, id);
actor->setResourceId(id);
actor->setFrameCount(res->getFrameCount());
actor->setFrameIndex(0);
@@ -864,12 +864,12 @@ IMPLEMENT_OPCODE(PlayMovie) {
bool check = false;
ActionArea *area = getWorld()->actions[getScene()->getActor()->getActionIndex3()];
- if (area->paletteValue) {
- getScreen()->setPalette(getScene()->getResourcePack(), area->paletteValue);
- getScreen()->setGammaLevel(getScene()->getResourcePack(), area->paletteValue, 0);
+ if (area->paletteResourceId) {
+ getScreen()->setPalette(area->paletteResourceId);
+ getScreen()->setGammaLevel(area->paletteResourceId, 0);
} else {
- getScreen()->setPalette(getScene()->getResourcePack(), getWorld()->currentPaletteId);
- getScreen()->setGammaLevel(getScene()->getResourcePack(), getWorld()->currentPaletteId, 0);
+ getScreen()->setPalette(getWorld()->currentPaletteId);
+ getScreen()->setGammaLevel(getWorld()->currentPaletteId, 0);
}
getScene()->matteBarHeight = 0;
@@ -893,11 +893,9 @@ IMPLEMENT_OPCODE(PlayMovie) {
check = true;
}
- if (!check &&
- getScene()->matteVar2 == 0 &&
- getWorld()->musicCurrentResourceId != kResourceMusic_FFFFFD66)
+ if (!check && getScene()->matteVar2 == 0 && getWorld()->musicCurrentResourceIndex != kResourceMusicStopped)
if (_vm->sound()->isCacheOk())
- _vm->sound()->playMusic(getScene()->getResourcePack(), getWorld()->musicCurrentResourceId + kResourceMusic_80020000);
+ _vm->sound()->playMusic(MAKE_RESOURCE(kResourcePackMusic, getWorld()->musicCurrentResourceIndex));
getCursor()->show();
getScene()->matteVar2 = 0;
@@ -937,13 +935,13 @@ IMPLEMENT_OPCODE(ResetSceneRect) {
//////////////////////////////////////////////////////////////////////////
// Opcode 0x32
IMPLEMENT_OPCODE(ChangeMusicById) {
- _vm->sound()->changeMusic(getScene()->getResourcePack(), cmd->param1, cmd->param2 ? 2 : 1);
+ _vm->sound()->changeMusic((ResourceId)cmd->param1, cmd->param2 ? 2 : 1);
}
//////////////////////////////////////////////////////////////////////////
// Opcode 0x33
IMPLEMENT_OPCODE(StopMusic) {
- _vm->sound()->changeMusic(getScene()->getResourcePack(), kResourceMusic_FFFFFD66, 0);
+ _vm->sound()->changeMusic(kResourceMusicStopped, 0);
}
//////////////////////////////////////////////////////////////////////////
@@ -1155,7 +1153,7 @@ IMPLEMENT_OPCODE(PlaySpeech) {
return;
if (cmd->param4 != 2) {
- cmd->param5 = getScene()->speech()->play(cmd->param1);
+ cmd->param5 = getSpeech()->play((ResourceId)cmd->param1);
if (cmd->param2) {
_vm->setGameFlag(kGameFlagScriptProcessing);
@@ -1207,7 +1205,7 @@ IMPLEMENT_OPCODE(PlaySpeechScene2) {
return;
if (cmd->param5 == 2) {
- if (_vm->sound()->isPlaying(cmd->param6)) {
+ if (getSound()->isPlaying((ResourceId)cmd->param6)) {
_lineIncrement = 1;
return;
}
@@ -1315,12 +1313,12 @@ IMPLEMENT_OPCODE(_unk46) {
_vm->clearGameFlag(kGameFlagScriptProcessing);
- _vm->sound()->soundResourceId = 0;
- _vm->sound()->speechTextResourceId = 0;
+ _vm->sound()->soundResourceId = kResourceNone;
+ _vm->sound()->speechTextResourceId = kResourceNone;
}
} else {
_vm->setGameFlag(kGameFlagScriptProcessing);
- _vm->sound()->setSpeech(cmd->param1 + kResourceSound_80030203, cmd->param1 + kResourceSpeech_8000050A);
+ getSpeech()->setPlayerSpeech(MAKE_RESOURCE(kResourcePackSpeech, 515 + cmd->param1), MAKE_RESOURCE(kResourcePackShared, 1290 + cmd->param1));
if (cmd->param2) {
getScene()->getActor(cmd->param5)->updateStatus(kActorStatus8);
@@ -1392,10 +1390,10 @@ IMPLEMENT_OPCODE(_unk49_MATTE_90) {
// Opcode 0x4A
IMPLEMENT_OPCODE(JumpIfSoundPlaying) {
if (cmd->param3 == 1) {
- if (_vm->sound()->isPlaying(cmd->param1)) {
+ if (_vm->sound()->isPlaying((ResourceId)cmd->param1)) {
_currentLine = cmd->param2;
}
- } else if (!_vm->sound()->isPlaying(cmd->param1)) {
+ } else if (!_vm->sound()->isPlaying((ResourceId)cmd->param1)) {
_currentLine = cmd->param2;
}
}
@@ -1422,8 +1420,8 @@ IMPLEMENT_OPCODE(ChangeActorStatus) {
//////////////////////////////////////////////////////////////////////////
// Opcode 0x4D
IMPLEMENT_OPCODE(StopSound) {
- if (_vm->sound()->isPlaying(cmd->param1))
- _vm->sound()->stopSound(cmd->param1);
+ if (_vm->sound()->isPlaying((ResourceId)cmd->param1))
+ _vm->sound()->stopSound((ResourceId)cmd->param1);
}
//////////////////////////////////////////////////////////////////////////
@@ -1589,8 +1587,8 @@ IMPLEMENT_OPCODE(_unk56) {
// Opcode 0x57
IMPLEMENT_OPCODE(SetResourcePalette) {
getWorld()->currentPaletteId = getWorld()->graphicResourceIds[cmd->param1];
- getScreen()->setPalette(getScene()->getResourcePack(), getWorld()->currentPaletteId);
- getScreen()->setGammaLevel(getScene()->getResourcePack(), getWorld()->currentPaletteId, 0);
+ getScreen()->setPalette(getWorld()->currentPaletteId);
+ getScreen()->setGammaLevel(getWorld()->currentPaletteId, 0);
}
//////////////////////////////////////////////////////////////////////////
diff --git a/engines/asylum/resources/actionlist.h b/engines/asylum/resources/actionlist.h
index 67b6973f21..6f7068f2ef 100644
--- a/engines/asylum/resources/actionlist.h
+++ b/engines/asylum/resources/actionlist.h
@@ -70,7 +70,7 @@ struct ActionArea {
int32 field_88;
ResourceId soundResourceId;
int32 field_90;
- int32 paletteValue;
+ ResourceId paletteResourceId;
int32 array[5];
int32 volume;
@@ -79,7 +79,7 @@ struct ActionArea {
output += Common::String::format("Action %d: %s\n", id, name);
output += Common::String::format(" flags=%d scriptIndex=%d scriptIndex2=%d type=%d\n", flags, scriptIndex, actionType, polyIdx);
- output += Common::String::format(" sound=%d polygon=%d palette=%d volume=%d\n", soundResourceId, scriptIndex2, paletteValue, volume);
+ output += Common::String::format(" sound=%d polygon=%d palette=%d volume=%d\n", soundResourceId, scriptIndex2, paletteResourceId, volume);
output += Common::String::format(" field01=%d field02=%d field40=%d field44=%d\n", field01, field02, field_40, field_44);
output += Common::String::format(" field7C=%d field84=%d field88=%d field90=%d\n", field_7C, field_84, field_88, field_90);
diff --git a/engines/asylum/resources/actor.cpp b/engines/asylum/resources/actor.cpp
index 32eb73f1fc..1f3886e686 100644
--- a/engines/asylum/resources/actor.cpp
+++ b/engines/asylum/resources/actor.cpp
@@ -70,7 +70,7 @@ void Actor::load(Common::SeekableReadStream *stream) {
x = stream->readSint32LE();
y = stream->readSint32LE();
- _resourceId = stream->readSint32LE();
+ _resourceId = (ResourceId)stream->readSint32LE();
_objectIndex = stream->readSint32LE();
_frameIndex = stream->readSint32LE();
_frameCount = stream->readSint32LE();
@@ -112,7 +112,7 @@ void Actor::load(Common::SeekableReadStream *stream) {
_field_650 = stream->readSint32LE();
for (int32 i = 0; i < 55; i++)
- _graphicResourceIds[i] = stream->readSint32LE();
+ _graphicResourceIds[i] = (ResourceId)stream->readSint32LE();
stream->read(_name, sizeof(_name));
@@ -132,7 +132,7 @@ void Actor::load(Common::SeekableReadStream *stream) {
actionType = stream->readSint32LE();
_field_934 = stream->readSint32LE();
_field_938 = stream->readSint32LE();
- _soundResourceId = stream->readSint32LE();
+ _soundResourceId = (ResourceId)stream->readSint32LE();
_numberValue01 = stream->readSint32LE();
_field_944 = stream->readSint32LE();
_field_948 = stream->readSint32LE();
@@ -214,15 +214,15 @@ void Actor::update() {
break;
case kActorStatus16:
- if (getWorld()->numChapter == 2) {
+ if (getWorld()->chapter == 2) {
updateStatus16_Chapter2();
- } else if (getWorld()->numChapter == 11 && _index == getScene()->getPlayerActorIndex()) {
+ } else if (getWorld()->chapter == 11 && _index == getScene()->getPlayerActorIndex()) {
updateStatus16_Chapter11();
}
break;
case kActorStatus17:
- if (getWorld()->numChapter == 2) {
+ if (getWorld()->chapter == kChapter2) {
if (_index > 12) {
if (_frameIndex <= _frameCount - 1) {
++_frameIndex;
@@ -245,13 +245,13 @@ void Actor::update() {
if (_vm->isGameFlagSet(kGameFlag556)) {
Actor *player = getScene()->getActor();
- getScene()->speech()->play(453);
+ getSpeech()->play(MAKE_RESOURCE(getScene()->getPackId(), 453));
hide();
player->updateStatus(kActorStatus3);
player->setResourceId(player->getResourcesId(35));
player->setDirection(4);
- GraphicResource *resource = new GraphicResource(getScene()->getResourcePack(), player->getResourceId());
+ GraphicResource *resource = new GraphicResource(_vm, player->getResourceId());
player->setFrameCount(resource->getFrameCount());
delete resource;
@@ -269,9 +269,9 @@ void Actor::update() {
Sound *sound = _vm->sound();
if (sound->isCacheOk())
- sound->playMusic(getScene()->getResourcePack(), kResourceMusic_80020001);
+ sound->playMusic(MAKE_RESOURCE(kResourcePackMusic, 1));
- getWorld()->musicCurrentResourceId = 1;
+ getWorld()->musicCurrentResourceIndex = 1;
if (sound->isPlaying(getWorld()->soundResourceIds[7]))
sound->stopSound(getWorld()->soundResourceIds[7]);
@@ -304,7 +304,7 @@ void Actor::update() {
}
}
- } else if (getWorld()->numChapter == 11) {
+ } else if (getWorld()->chapter == kChapter11) {
if (_index == getScene()->getPlayerActorIndex()) {
if (_frameIndex <= _frameCount - 1)
++_frameIndex;
@@ -318,7 +318,7 @@ void Actor::update() {
break;
case kActorStatus15:
- if (getWorld()->numChapter == 2) {
+ if (getWorld()->chapter == kChapter2) {
if (_index > 12)
updateStatus15_Chapter2();
@@ -328,7 +328,7 @@ void Actor::update() {
if (_index == 11)
updateStatus15_Chapter2_Actor11();
- } else if (getWorld()->numChapter == 11) {
+ } else if (getWorld()->chapter == kChapter11) {
if (_index >= 10 && _index < 16)
updateStatus15_Chapter11();
@@ -338,7 +338,7 @@ void Actor::update() {
break;
case kActorStatus18:
- if (getWorld()->numChapter == 2) {
+ if (getWorld()->chapter == kChapter2) {
if (_index > 12)
updateStatus18_Chapter2();
@@ -362,7 +362,7 @@ void Actor::update() {
break;
case kActorStatus12:
- if (getWorld()->numChapter == 2) {
+ if (getWorld()->chapter == kChapter2) {
if (_index > 12)
updateStatus12_Chapter2();
@@ -370,7 +370,7 @@ void Actor::update() {
updateStatus12_Chapter2_Actor11();
return;
- } else if (getWorld()->numChapter == 11) {
+ } else if (getWorld()->chapter == kChapter11) {
switch (_index) {
default:
break;
@@ -459,7 +459,7 @@ void Actor::update() {
if (_soundResourceId && getSound()->isPlaying(_soundResourceId))
setVolume();
- if (_index != getScene()->getPlayerActorIndex() && getWorld()->numChapter != 9)
+ if (_index != getScene()->getPlayerActorIndex() && getWorld()->chapter != kChapter9)
error("[Actor::update] call to actor sound functions missing!");
updateDirection();
@@ -476,7 +476,7 @@ void Actor::updateStatus(ActorStatus actorStatus) {
case kActorStatus1:
case kActorStatus12:
- if ((getWorld()->numChapter == 2
+ if ((getWorld()->chapter == kChapter2
&& _index == getScene()->getPlayerActorIndex() && (_status == kActorStatus18 || _status == kActorStatus16 || kActorStatus17))
|| (_status != kActorStatusEnabled && _status != kActorStatus9 && _status != kActorStatus14 && _status != kActorStatus15 && _status != kActorStatus18))
return;
@@ -515,7 +515,7 @@ void Actor::updateStatus(ActorStatus actorStatus) {
break;
case kActorStatus7:
- if (getWorld()->numChapter == 2 && _index == 10 && _vm->isGameFlagSet(kGameFlag279)) {
+ if (getWorld()->chapter == kChapter2 && _index == 10 && _vm->isGameFlagSet(kGameFlag279)) {
Actor *actor = getScene()->getActor(0);
actor->x1 = x2 + x1 - actor->x2;
actor->y1 = y2 + y1 - actor->y2;
@@ -555,15 +555,15 @@ void Actor::updateStatus(ActorStatus actorStatus) {
break;
case kActorStatus18:
- if (getWorld()->numChapter == 2) {
- GraphicResource *resource = new GraphicResource();
+ if (getWorld()->chapter == kChapter2) {
+ GraphicResource *resource = new GraphicResource(_vm);
_frameIndex = 0;
if (_index > 12)
_resourceId = _graphicResourceIds[_direction + 30];
if (getScene()->getPlayerActorIndex() == _index) {
- resource->load(getScene()->getResourcePack(), _resourceId);
+ resource->load(_resourceId);
_frameIndex = resource->getFrameCount() - 1;
}
@@ -572,7 +572,7 @@ void Actor::updateStatus(ActorStatus actorStatus) {
// Reload the graphic resource if the resource ID has changed
if (resource->getResourceId() != _resourceId)
- resource->load(getScene()->getResourcePack(), _resourceId);
+ resource->load(_resourceId);
_frameCount = resource->getFrameCount();
@@ -614,14 +614,14 @@ void Actor::updateFromDirection(ActorDirection actorDirection) {
_resourceId = _graphicResourceIds[(actorDirection > 4 ? 8 - actorDirection : actorDirection) + 5];
// FIXME this seems kind of wasteful just to grab a frame count
- GraphicResource *gra = new GraphicResource(getScene()->getResourcePack(), _resourceId);
+ GraphicResource *gra = new GraphicResource(_vm, _resourceId);
_frameCount = gra->getFrameCount();
delete gra;
}
break;
case kActorStatus18:
- if (getWorld()->numChapter == 2) {
+ if (getWorld()->chapter == kChapter2) {
if (_index == 11) { // we are actor 11
if (actorDirection > 4)
_resourceId = _graphicResourceIds[8 - actorDirection];
@@ -662,7 +662,7 @@ void Actor::faceTarget(ObjectId id, DirectionFrom from) {
- GraphicResource *resource = new GraphicResource(getScene()->getResourcePack(), object->getResourceId());
+ GraphicResource *resource = new GraphicResource(_vm, object->getResourceId());
GraphicFrame *frame = resource->getFrame(object->getFrameIndex());
newX = (frame->surface.w >> 1) + object->x;
@@ -876,10 +876,10 @@ void Actor::updateStatusEnabled() {
&& !_vm->encounter()->getFlag(kEncounterFlag2)
&& !getSound()->soundResourceId) {
if (_vm->getRandom(100) < 50) {
- if (getWorld()->numChapter == 13)
- getScene()->speech()->play(507);
+ if (getWorld()->chapter == kChapter13)
+ getSpeech()->play(MAKE_RESOURCE(getScene()->getPackId(), 507));
else
- getScene()->playSpeech(4);
+ getSpeech()->play(MAKE_RESOURCE(getScene()->getPackId(), 4));
}
}
_lastScreenUpdate = _vm->screenUpdatesCount;
@@ -1066,13 +1066,13 @@ void Actor::updateFinish() {
getScene()->actions()->queueScript(area->scriptIndex, _index);
}
- if (!area->paletteValue || area->paletteValue == actorArea->paletteValue || _index) {
- if (area->paletteValue != actorArea->paletteValue && !_index)
- _vm->screen()->startPaletteFade(area->paletteValue, 50, 3);
+ if (!area->paletteResourceId || area->paletteResourceId == actorArea->paletteResourceId || _index) {
+ if (area->paletteResourceId != actorArea->paletteResourceId && !_index)
+ _vm->screen()->startPaletteFade(area->paletteResourceId, 50, 3);
_actionIdx3 = areaIndex;
} else {
- _vm->screen()->startPaletteFade(area->paletteValue, 50, 3);
+ _vm->screen()->startPaletteFade(area->paletteResourceId, 50, 3);
_actionIdx3 = areaIndex;
}
}
@@ -1184,7 +1184,7 @@ ActorDirection Actor::getDirection(int32 ax1, int32 ay1, int32 ax2, int32 ay2) {
void Actor::updateGraphicData(uint32 offset) {
_resourceId = _graphicResourceIds[(_direction > 4 ? 8 - _direction : _direction) + offset];
- GraphicResource *resource = new GraphicResource(getScene()->getResourcePack(), _resourceId);
+ GraphicResource *resource = new GraphicResource(_vm, _resourceId);
_frameCount = resource->getFrameCount();
delete resource;
@@ -1196,7 +1196,7 @@ bool Actor::isDefaultDirection(int index) {
}
int32 Actor::getGraphicsFlags() {
- if (getWorld()->numChapter == 11) {
+ if (getWorld()->chapter == kChapter11) {
int res = strcmp((char *)&_name, "Dead Sarah");
if (res == 0)
diff --git a/engines/asylum/resources/encounters.cpp b/engines/asylum/resources/encounters.cpp
index ad26e8607f..3070e57834 100644
--- a/engines/asylum/resources/encounters.cpp
+++ b/engines/asylum/resources/encounters.cpp
@@ -55,7 +55,7 @@ Encounter::Encounter(Scene *scene) {
item.keywordIndex = file.readSint32LE();
item.field2 = file.readSint32LE();
- item.scriptResourceId = file.readSint32LE();
+ item.scriptResourceId = (ResourceId)file.readSint32LE();
for (uint8 j = 0; j < 50; j++) {
item.array[j] = file.readSint32LE();
}
diff --git a/engines/asylum/resources/object.cpp b/engines/asylum/resources/object.cpp
index e24f427738..98acd2e866 100644
--- a/engines/asylum/resources/object.cpp
+++ b/engines/asylum/resources/object.cpp
@@ -49,7 +49,7 @@ Object::~Object() {
/////////////////////////////////////////////////////////////////////////
void Object::load(Common::SeekableReadStream *stream) {
_id = (ObjectId)stream->readSint32LE();
- _resourceId = stream->readSint32LE();
+ _resourceId = (ResourceId)stream->readSint32LE();
x = stream->readSint32LE();
y = stream->readSint32LE();
@@ -87,14 +87,14 @@ void Object::load(Common::SeekableReadStream *stream) {
_actionListIdx = stream->readSint32LE();
for (int i = 0; i < 16; i++) {
- _soundItems[i].resourceId = stream->readSint32LE();
+ _soundItems[i].resourceId = (ResourceId)stream->readSint32LE();
_soundItems[i].field_4 = stream->readSint32LE();
_soundItems[i].field_8 = stream->readSint32LE();
_soundItems[i].field_C = stream->readSint32LE();
}
for (int i = 0; i < 50; i++) {
- _frameSoundItems[i].resourceId = stream->readSint32LE();
+ _frameSoundItems[i].resourceId = (ResourceId)stream->readSint32LE();
_frameSoundItems[i].frameIndex = stream->readSint32LE();
_frameSoundItems[i].index = stream->readSint32LE();
_frameSoundItems[i].field_C = stream->readSint32LE();
@@ -108,9 +108,9 @@ void Object::load(Common::SeekableReadStream *stream) {
_field_688 = stream->readSint32LE();
for (int i = 0; i < 5; i++)
- _randomResourceIds[i] = stream->readSint32LE();
+ _randomResourceIds[i] = (ResourceId)stream->readSint32LE();
- _soundResourceId = stream->readSint32LE();
+ _soundResourceId = (ResourceId)stream->readSint32LE();
_field_6A4 = stream->readSint32LE();
}
@@ -216,7 +216,7 @@ void Object::update() {
if (_vm->getRandom(_field_C0) == 1) {
if (_randomResourceIds[0]) {
_resourceId = getRandomResourceId();
- GraphicResource *gra = new GraphicResource(getScene()->getResourcePack(), _resourceId);
+ GraphicResource *gra = new GraphicResource(_vm, _resourceId);
_frameCount = gra->getFrameCount();
delete gra;
}
@@ -252,7 +252,7 @@ void Object::update() {
if (_frameIndex < _frameCount - 1) {
if (_field_688 == 1) {
- GraphicResource *gra = new GraphicResource(getScene()->getResourcePack(), _resourceId);
+ GraphicResource *gra = new GraphicResource(_vm, _resourceId);
GraphicFrame *frame = gra->getFrame(_frameIndex);
getScene()->setGlobalX(x + frame->x + (frame->getWidth() >> 1));
getScene()->setGlobalY(y + frame->y + (frame->getHeight() >> 1));
@@ -281,7 +281,7 @@ void Object::update() {
getScene()->setGlobalY(-1);
}
} else if (_field_688 == 1) {
- GraphicResource *gra = new GraphicResource(getScene()->getResourcePack(), _resourceId);
+ GraphicResource *gra = new GraphicResource(_vm, _resourceId);
GraphicFrame *frame = gra->getFrame(_frameIndex);
getScene()->setGlobalX(x + frame->x + (frame->getWidth() >> 1));
getScene()->setGlobalY(y + frame->y + (frame->getHeight() >> 1));
@@ -351,7 +351,7 @@ void Object::playSounds() {
soundX = _soundX;
soundY = _soundY;
} else {
- GraphicResource *resource = new GraphicResource(getScene()->getResourcePack(), _resourceId);
+ GraphicResource *resource = new GraphicResource(_vm, _resourceId);
if (LOBYTE(flags) & kObjectFlag4) {
soundX = x + (resource->getFlags() >> 1);
@@ -432,7 +432,7 @@ void Object::setVolume() {
if (!_soundResourceId || !getSound()->isPlaying(_soundResourceId))
return;
- GraphicResource *resource = new GraphicResource(getScene()->getResourcePack(), _resourceId);
+ GraphicResource *resource = new GraphicResource(_vm, _resourceId);
GraphicFrame *frame = resource->getFrame(_frameIndex);
// Compute volume
@@ -445,7 +445,7 @@ void Object::setVolume() {
getSound()->setVolume(_soundResourceId, volume);
}
-int32 Object::getRandomResourceId() {
+ResourceId Object::getRandomResourceId() {
// Initialize random resource id array
ResourceId shuffle[5];
memset(&shuffle, 0, sizeof(shuffle));
@@ -459,9 +459,13 @@ int32 Object::getRandomResourceId() {
}
if (count == 0)
- error("[Object::getRandomId] Could not get a random resource Id");
+ error("[Object::getRandomId] Could not get a random resource id!");
- return shuffle[_vm->getRandom(count)];
+ ResourceId id = shuffle[_vm->getRandom(count - 1)];
+ if (id == kResourceNone)
+ error("[Object::getRandomId] Got an empty resource id!");
+
+ return id;
}
bool Object::checkFlags() {
diff --git a/engines/asylum/resources/object.h b/engines/asylum/resources/object.h
index acc4233af2..1063ea973f 100644
--- a/engines/asylum/resources/object.h
+++ b/engines/asylum/resources/object.h
@@ -187,7 +187,7 @@ private:
int32 _soundX;
int32 _soundY;
int32 _field_688;
- int32 _randomResourceIds[5];
+ ResourceId _randomResourceIds[5];
ResourceId _soundResourceId;
int32 _field_6A4;
@@ -224,7 +224,7 @@ private:
*
* @return The random resource identifier.
*/
- int32 getRandomResourceId();
+ ResourceId getRandomResourceId();
}; // end of class Object
diff --git a/engines/asylum/resources/special.cpp b/engines/asylum/resources/special.cpp
index 37ed032e9a..916f81cf10 100644
--- a/engines/asylum/resources/special.cpp
+++ b/engines/asylum/resources/special.cpp
@@ -52,7 +52,7 @@ Special::~Special() {}
void Special::run(Object* object, ActorIndex index) {
//debugC(kDebugLevelSound, "[SPEC] Running special function for chapter %d",getWorld()->numChapter);
- switch (getWorld()->numChapter) {
+ switch (getWorld()->chapter) {
default:
error("[Special::runSpecial] Invalid chapter");
@@ -117,12 +117,12 @@ void Special::chapter1(Object *object, ActorIndex actorIndex) {
case kObjectAngelFlares:
if (object->getFrameIndex() == 5)
- getSpeech()->play(81);
+ getSpeech()->play(MAKE_RESOURCE(getScene()->getPackId(), 81));
break;
case kObjectGuyFalls:
if (object->getFrameIndex() == 23)
- getSpeech()->play(82);
+ getSpeech()->play(MAKE_RESOURCE(getScene()->getPackId(), 82));
break;
}
}
@@ -263,7 +263,7 @@ void Special::chapter2(Object *object, ActorIndex actorIndex) {
if (actor->isVisible())
if (getScene()->getActorUpdateFlag2() < 7)
- getSpeech()->play(452);
+ getSpeech()->play(MAKE_RESOURCE(getScene()->getPackId(), 452));
_vm->setGameFlag(kGameFlag219);
@@ -300,7 +300,7 @@ void Special::chapter4(Object *object, ActorIndex actorIndex) {
}
void Special::chapter5(Object *object, ActorIndex actorIndex) {
- setPaletteGamma(kResourcePalette_8001003B, getWorld()->currentPaletteId);
+ setPaletteGamma(MAKE_RESOURCE(kResourcePackShared, 19), getWorld()->currentPaletteId);
playChapterSound(object, actorIndex);
@@ -433,10 +433,10 @@ void Special::chapter7(Object *object, ActorIndex actorIndex) {
if (player->getReaction(0)) {
if (player->getStatus() == kActorStatus6 || player->getStatus() == kActorStatus10) {
- getSound()->playSound(kResourceSound_80120002);
+ getSound()->playSound(MAKE_RESOURCE(kResourcePackSound, 2));
player->updateStatus(kActorStatusEnabled);
} else {
- getSound()->playSound(kResourceSound_80120005);
+ getSound()->playSound(MAKE_RESOURCE(kResourcePackSound, 5));
player->updateStatus(kActorStatus6);
}
@@ -586,7 +586,7 @@ void Special::playChapterSound(Object *object, ActorIndex actorIndex) {
if (Config.performance <= 2)
return;
- switch (getWorld()->numChapter) {
+ switch (getWorld()->chapter) {
default:
error("[Special::playChapterSound] Invalid chapter");
diff --git a/engines/asylum/resources/worldstats.cpp b/engines/asylum/resources/worldstats.cpp
index 2ae65c6234..c114eb16dc 100644
--- a/engines/asylum/resources/worldstats.cpp
+++ b/engines/asylum/resources/worldstats.cpp
@@ -74,7 +74,7 @@ void WorldStats::load(Common::SeekableReadStream *stream) {
size = stream->readSint32LE();
numEntries = stream->readSint32LE();
- numChapter = stream->readSint32LE();
+ chapter = (ChapterIndex)stream->readSint32LE();
xLeft = stream->readSint32LE();
yTop = stream->readSint32LE();
@@ -84,24 +84,24 @@ void WorldStats::load(Common::SeekableReadStream *stream) {
boundingRect.bottom = stream->readSint32LE() & 0xFFFF;
// read common graphic resources
- backgroundImage = stream->readSint32LE();
- curScrollUp = stream->readSint32LE();
- curScrollUpLeft = stream->readSint32LE();
- curScrollLeft = stream->readSint32LE();
- curScrollDownLeft = stream->readSint32LE();
- curScrollDown = stream->readSint32LE();
- curScrollDownRight = stream->readSint32LE();
- curScrollRight = stream->readSint32LE();
- curScrollUpRight = stream->readSint32LE();
- curHand = stream->readSint32LE();
- curMagnifyingGlass = stream->readSint32LE();
- curTalkNPC = stream->readSint32LE();
- curGrabPointer = stream->readSint32LE();
- curTalkNPC2 = stream->readSint32LE();
- font1 = stream->readSint32LE();
- font2 = stream->readSint32LE();
- font3 = stream->readSint32LE();
- currentPaletteId = stream->readSint32LE();
+ backgroundImage = (ResourceId)stream->readSint32LE();
+ curScrollUp = (ResourceId)stream->readSint32LE();
+ curScrollUpLeft = (ResourceId)stream->readSint32LE();
+ curScrollLeft = (ResourceId)stream->readSint32LE();
+ curScrollDownLeft = (ResourceId)stream->readSint32LE();
+ curScrollDown = (ResourceId)stream->readSint32LE();
+ curScrollDownRight = (ResourceId)stream->readSint32LE();
+ curScrollRight = (ResourceId)stream->readSint32LE();
+ curScrollUpRight = (ResourceId)stream->readSint32LE();
+ curHand = (ResourceId)stream->readSint32LE();
+ curMagnifyingGlass = (ResourceId)stream->readSint32LE();
+ curTalkNPC = (ResourceId)stream->readSint32LE();
+ curGrabPointer = (ResourceId)stream->readSint32LE();
+ curTalkNPC2 = (ResourceId)stream->readSint32LE();
+ font1 = (ResourceId)stream->readSint32LE();
+ font2 = (ResourceId)stream->readSint32LE();
+ font3 = (ResourceId)stream->readSint32LE();
+ currentPaletteId = (ResourceId)stream->readSint32LE();
cellShadeMask1 = stream->readSint32LE();
cellShadeMask2 = stream->readSint32LE();
cellShadeMask3 = stream->readSint32LE();
@@ -139,19 +139,19 @@ void WorldStats::load(Common::SeekableReadStream *stream) {
actionListIdx = stream->readSint32LE();
for (int32 gr = 0; gr < 100; gr++)
- graphicResourceIds[gr] = stream->readSint32LE();
+ graphicResourceIds[gr] = (ResourceId)stream->readSint32LE();
- sceneTitleGraphicResourceId = stream->readSint32LE();
- sceneTitlePaletteResourceId = stream->readSint32LE();
+ sceneTitleGraphicResourceId = (ResourceId)stream->readSint32LE();
+ sceneTitlePaletteResourceId = (ResourceId)stream->readSint32LE();
actorType = stream->readUint32LE();
for (int32 s = 0; s < 50; s++)
- soundResourceIds[s] = stream->readSint32LE();
+ soundResourceIds[s] = (ResourceId)stream->readSint32LE();
for (int32 s = 0; s < 15; s++) {
ambientSounds[s].field_0 = stream->readSint32LE();
ambientSounds[s].flags = stream->readSint32LE();
- ambientSounds[s].resourceId = stream->readSint32LE();
+ ambientSounds[s].resourceId = (ResourceId)stream->readSint32LE();
ambientSounds[s].field_C = stream->readSint32LE();
ambientSounds[s].field_10 = stream->readSint32LE();
ambientSounds[s].field_14 = stream->readSint32LE();
@@ -165,9 +165,9 @@ void WorldStats::load(Common::SeekableReadStream *stream) {
numAmbientSound = stream->readSint32LE();
musicStatus = stream->readSint32LE();
- musicCurrentResourceId = stream->readSint32LE();
+ musicCurrentResourceIndex = stream->readSint32LE();
musicFlag = stream->readSint32LE();
- musicResourceId = stream->readSint32LE();
+ musicResourceId = (ResourceId)stream->readSint32LE();
musicStatusExt = stream->readSint32LE();
for (uint32 a = 0; a < numObjects; a++) {
@@ -222,9 +222,9 @@ void WorldStats::load(Common::SeekableReadStream *stream) {
action->polyIdx = stream->readSint32LE();
action->field_84 = stream->readSint32LE();
action->field_88 = stream->readSint32LE();
- action->soundResourceId = stream->readSint32LE();
+ action->soundResourceId = (ResourceId)stream->readSint32LE();
action->field_90 = stream->readSint32LE();
- action->paletteValue = stream->readSint32LE();
+ action->paletteResourceId = (ResourceId)stream->readSint32LE();
for (int32 aa2 = 0; aa2 < 5; aa2++)
action->array[aa2] = stream->readSint32LE();
diff --git a/engines/asylum/resources/worldstats.h b/engines/asylum/resources/worldstats.h
index d17307c7f2..4857830de4 100644
--- a/engines/asylum/resources/worldstats.h
+++ b/engines/asylum/resources/worldstats.h
@@ -54,27 +54,27 @@ public:
int32 size;
int32 numEntries;
- int32 numChapter;
+ ChapterIndex chapter;
int32 xLeft; // scene start x position
int32 yTop; // scene start y position
Common::Rect boundingRect;
- int32 backgroundImage;
- int32 curScrollUp;
- int32 curScrollUpLeft;
- int32 curScrollLeft;
- int32 curScrollDownLeft;
- int32 curScrollDown;
- int32 curScrollDownRight;
- int32 curScrollRight;
- int32 curScrollUpRight;
- int32 curHand;
- int32 curMagnifyingGlass;
+ ResourceId backgroundImage;
+ ResourceId curScrollUp;
+ ResourceId curScrollUpLeft;
+ ResourceId curScrollLeft;
+ ResourceId curScrollDownLeft;
+ ResourceId curScrollDown;
+ ResourceId curScrollDownRight;
+ ResourceId curScrollRight;
+ ResourceId curScrollUpRight;
+ ResourceId curHand;
+ ResourceId curMagnifyingGlass;
ResourceId curTalkNPC;
- int32 curGrabPointer;
- int32 curTalkNPC2;
- int32 font1;
- int32 font2;
- int32 font3;
+ ResourceId curGrabPointer;
+ ResourceId curTalkNPC2;
+ ResourceId font1;
+ ResourceId font2;
+ ResourceId font3;
ResourceId currentPaletteId;
int32 cellShadeMask1;
int32 cellShadeMask2;
@@ -105,7 +105,7 @@ public:
AmbientSoundItem ambientSounds[15];
int32 numAmbientSound;
int32 musicStatus;
- ResourceId musicCurrentResourceId;
+ int32 musicCurrentResourceIndex;
int32 musicFlag;
ResourceId musicResourceId;
int32 musicStatusExt;
diff --git a/engines/asylum/respack.cpp b/engines/asylum/respack.cpp
index d45e861b3d..7d5c7d40ae 100644
--- a/engines/asylum/respack.cpp
+++ b/engines/asylum/respack.cpp
@@ -27,18 +27,42 @@
namespace Asylum {
-ResourcePack::ResourcePack(const char *resourceFile) {
- init(resourceFile);
+//////////////////////////////////////////////////////////////////////////
+// ResourceManager
+//////////////////////////////////////////////////////////////////////////
+ResourceEntry *ResourceManager::get(ResourceId id) {
+ ResourcePackId packId = (ResourcePackId)((id >> 16) & 0x7FFF);
+ uint16 index = (uint16)id;
+
+ // Check if we need to load a music pack
+ ResourceCache *cache = (packId == kResourcePackMusic) ? &_music : &_resources;
+
+ // Try getting the resource pack
+ if (!cache->contains(packId)) {
+ ResourcePack *pack = new ResourcePack(Common::String::format((packId == kResourcePackMusic) ? "mus.%03d" : "res.%03d", packId));
+
+ cache->setVal(packId, pack);
+ }
+
+ return cache->getVal(packId)->get(index);
}
-ResourcePack::ResourcePack(ResourcePackId id) {
- // We don't use the file number part of resource IDs
- //uint32 fileNum = (resourceID >> 16) & 0x7FFF;
- char filename[20];
- sprintf(filename, "res.%03d", id);
+
+//////////////////////////////////////////////////////////////////////////
+// ResourcePack
+//////////////////////////////////////////////////////////////////////////
+ResourcePack::ResourcePack(Common::String filename) {
init(filename);
}
+//ResourcePack::ResourcePack(ResourcePackId id) {
+// // We don't use the file number part of resource IDs
+// //uint32 fileNum = (resourceID >> 16) & 0x7FFF;
+// char filename[20];
+// sprintf(filename, "res.%03d", id);
+// init(filename);
+//}
+
ResourcePack::~ResourcePack() {
for (uint32 i = 0; i < _resources.size(); i++)
delete [] _resources[i].data;
@@ -47,8 +71,8 @@ ResourcePack::~ResourcePack() {
_packFile.close();
}
-void ResourcePack::init(const char *resourceFile) {
- _packFile.open(resourceFile);
+void ResourcePack::init(Common::String filename) {
+ _packFile.open(filename);
uint32 entryCount = _packFile.readUint32LE();
_resources.resize(entryCount);
@@ -71,8 +95,7 @@ void ResourcePack::init(const char *resourceFile) {
}
}
-ResourceEntry *ResourcePack::getResource(ResourceId resourceId) {
- uint16 index = resourceId & 0xFFFF;
+ResourceEntry *ResourcePack::get(uint16 index) {
if (!_resources[index].data) {
// Load the requested resource if it's not loaded already
_packFile.seek(_resources[index].offset, SEEK_SET);
diff --git a/engines/asylum/respack.h b/engines/asylum/respack.h
index 31614b7757..f3b95586d3 100644
--- a/engines/asylum/respack.h
+++ b/engines/asylum/respack.h
@@ -30,9 +30,12 @@
#include "common/array.h"
#include "common/file.h"
+#include "common/hashmap.h"
namespace Asylum {
+class ResourceManager;
+
struct ResourceEntry {
byte *data;
uint32 size;
@@ -41,20 +44,47 @@ struct ResourceEntry {
class ResourcePack {
public:
- ResourcePack(const char *resourceFile);
- ResourcePack(ResourcePackId id);
- ~ResourcePack();
+ ResourceEntry *get(uint16 index);
+ int count();
- ResourceEntry *getResource(ResourceId resourceId);
- uint32 getResourceCount() {
- return _resources.size();
- }
+protected:
+ ResourcePack(Common::String filename);
+ ~ResourcePack();
private:
- Common::Array <ResourceEntry> _resources;
+ Common::Array<ResourceEntry> _resources;
Common::File _packFile;
- void init(const char *resourceFile);
+ void init(Common::String filename);
+
+ friend ResourceManager;
+};
+
+class ResourceManager {
+public:
+ ResourceManager() {}
+ virtual ~ResourceManager() {}
+
+ //void load(ResourcePackId id);
+
+ ResourceEntry *get(ResourceId id);
+ //int count(ResourceId id);
+
+ //void unload(ResourcePackId id);
+
+private:
+ struct ResourcePackId_EqualTo {
+ bool operator()(const ResourcePackId &x, const ResourcePackId &y) const { return x == y; }
+ };
+
+ struct ResourcePackId_Hash {
+ uint operator()(const ResourcePackId &x) const { return x; }
+ };
+
+ typedef Common::HashMap<ResourcePackId, ResourcePack*, ResourcePackId_Hash, ResourcePackId_EqualTo> ResourceCache;
+
+ ResourceCache _resources;
+ ResourceCache _music;
};
} // end of namespace Asylum
diff --git a/engines/asylum/shared.h b/engines/asylum/shared.h
index 4547ec3f75..27c7054f90 100644
--- a/engines/asylum/shared.h
+++ b/engines/asylum/shared.h
@@ -86,7 +86,10 @@ enum ChapterIndex {
kChapter7,
kChapter8,
kChapter9,
- kChapter10
+ kChapter10,
+ kChapter11,
+ kChapter12,
+ kChapter13
};
//////////////////////////////////////////////////////////////////////////
@@ -97,7 +100,7 @@ enum ResourcePackId {
kResourcePackInvalid = -1,
kResourcePackText = 0,
kResourcePackShared = 1,
- // No resource pack 2
+ kResourcePackMusic = 2, // Special case: will load from mus* resources
kResourcePackSpeech = 3,
// No resource pack 4
kResourcePackTowerCells = 5,
@@ -119,23 +122,11 @@ enum ResourcePackId {
kResourcePack304 = 304
};
+#define MAKE_RESOURCE(pack, index) (ResourceId)((0x80000000 + ((pack) << 16)) + (index))
-typedef unsigned int ResourceId;
-
-enum ResourceIdEnum {
- kResourceNone = 0,
- kResourceSpeech_8000050A = 0x8000050A,
- kResourcePalette_8001003B = 0x8001003B,
- kResourceMusic_80020000 = 0x80020000,
- kResourceMusic_80020001 = 0x80020001,
- kResourceSound_80030203 = 0x80030203,
- // Base resource 0x80120000
- kResourceSound_80120001 = 0x80120001,
- kResourceSound_80120002 = 0x80120002,
- kResourceSound_80120005 = 0x80120005,
- kResourceSound_80120006 = 0x80120006,
- kResourceSoundIntro = 0x80120007,
- kResourceMusic_FFFFFD66 = 0xFFFFFD66
+enum ResourceId {
+ kResourceNone = 0,
+ kResourceMusicStopped = 0xFFFFFD66 // -666
};
//////////////////////////////////////////////////////////////////////////
@@ -371,12 +362,14 @@ enum ObjectFlag {
// Engine subclasses
#define getEncounter() _vm->encounter()
#define getCursor() _vm->scene()->cursor()
+#define getResource() _vm->resource()
#define getSound() _vm->sound()
#define getScene() _vm->scene()
#define getScreen() _vm->screen()
#define getScript() _vm->scene()->actions()
#define getSpeech() _vm->scene()->speech()
#define getText() _vm->text()
+#define getVideo() _vm->video()
#define getWorld() _vm->scene()->worldstats()
//////////////////////////////////////////////////////////////////////////
diff --git a/engines/asylum/system/cursor.cpp b/engines/asylum/system/cursor.cpp
index 796b92e6c2..5f03ad04c3 100644
--- a/engines/asylum/system/cursor.cpp
+++ b/engines/asylum/system/cursor.cpp
@@ -33,14 +33,7 @@ namespace Asylum {
const uint32 CURSOR_UPDATE_TICKS = 100;
-Cursor::Cursor() {
- _pos.x = 0;
- _pos.y = 0;
- _cursorRes = 0;
-}
-
-Cursor::Cursor(ResourcePack *pack) {
- _pack = pack;
+Cursor::Cursor(AsylumEngine *engine) : _vm(engine) {
_pos.x = 0;
_pos.y = 0;
_cursorRes = 0;
@@ -56,14 +49,14 @@ void Cursor::load(int32 index) {
if (cursorLoaded)
delete _cursorResource;
- _cursorResource = new GraphicResource(_resPack, index);
+ _cursorResource = new GraphicResource(_vm, index);
_cursorStep = 1;
_curFrame = 0;
cursorLoaded = true;
}
*/
-void Cursor::create(Cursor *&cursor, ResourcePack *pack, ResourceId id) {
+void Cursor::create(AsylumEngine *engine, Cursor *&cursor, ResourceId id) {
// If the current cursor resource is already assigned
// to the id value we're sending, just return
// TODO this simplifies a lot of additional validation calls
@@ -76,7 +69,7 @@ void Cursor::create(Cursor *&cursor, ResourcePack *pack, ResourceId id) {
else
return;
}
- cursor = new Cursor(pack);
+ cursor = new Cursor(engine);
cursor->set(id, 0, 0);
}
@@ -92,7 +85,7 @@ void Cursor::set(ResourceId resourceId, int32 cntr, int32 flgs, int32 frames) {
if (_cursorRes)
delete _cursorRes;
- _cursorRes = new GraphicResource(_pack, resourceId);
+ _cursorRes = new GraphicResource(_vm, resourceId);
if (frames >= 0)
frameCount = frames;
diff --git a/engines/asylum/system/cursor.h b/engines/asylum/system/cursor.h
index 7ddb0f0b5c..3431694248 100644
--- a/engines/asylum/system/cursor.h
+++ b/engines/asylum/system/cursor.h
@@ -32,8 +32,8 @@
namespace Asylum {
+class AsylumEngine;
class GraphicResource;
-class ResourcePack;
/**
* Asylum cursors are GraphicResources, and are stored in
@@ -41,16 +41,14 @@ class ResourcePack;
*/
class Cursor {
public:
- Cursor();
- Cursor(ResourcePack *pack);
-
+ Cursor(AsylumEngine *engine);
virtual ~Cursor();
/**
* Generate a new cursor instance from the resource id
* within the resource pack provided.
*/
- static void create(Cursor *&cursor, ResourcePack *pack, ResourceId id);
+ static void create(AsylumEngine *engine, Cursor *&cursor, ResourceId id);
/**
* Show the current cursor
@@ -114,7 +112,9 @@ public:
// } CursorInfo;
private:
- ResourcePack *_pack;
+ AsylumEngine *_vm;
+
+ // Cursor resource
GraphicResource *_cursorRes;
/** the point on the screen the cursor is at */
diff --git a/engines/asylum/system/graphics.cpp b/engines/asylum/system/graphics.cpp
index 6dbea2156f..ca04e41328 100644
--- a/engines/asylum/system/graphics.cpp
+++ b/engines/asylum/system/graphics.cpp
@@ -25,27 +25,31 @@
#include "asylum/system/graphics.h"
+#include "asylum/asylum.h"
#include "asylum/respack.h"
#include "common/endian.h"
namespace Asylum {
-GraphicResource::GraphicResource(ResourcePack *resPack, ResourceId id) {
- load(resPack, id);
+GraphicResource::GraphicResource(AsylumEngine *engine, ResourceId id) : _vm(engine) {
+ load(id);
}
-void GraphicResource::load(ResourcePack *resPack, ResourceId id) {
- // Clear previously loaded data
+GraphicResource::~GraphicResource() {
clear();
- ResourceEntry *resEntry = resPack->getResource(id);
- _resourceId = id;
- init(resEntry->data, resEntry->size);
+ // Zero passed pointers
+ _vm = NULL;
}
-GraphicResource::~GraphicResource() {
+void GraphicResource::load(ResourceId id) {
+ // Clear previously loaded data
clear();
+
+ ResourceEntry *resEntry = getResource()->get(id);
+ _resourceId = id;
+ init(resEntry->data, resEntry->size);
}
void GraphicResource::clear() {
diff --git a/engines/asylum/system/graphics.h b/engines/asylum/system/graphics.h
index 4a9c12b998..cf39064fff 100644
--- a/engines/asylum/system/graphics.h
+++ b/engines/asylum/system/graphics.h
@@ -34,7 +34,7 @@
namespace Asylum {
-class ResourcePack;
+class AsylumEngine;
struct GraphicFrame {
int32 size;
@@ -52,11 +52,11 @@ struct GraphicFrame {
class GraphicResource {
public:
- GraphicResource() {}
- GraphicResource(ResourcePack *resPack, ResourceId id);
+ GraphicResource(AsylumEngine *engine) {}
+ GraphicResource(AsylumEngine *engine, ResourceId id);
~GraphicResource();
- void load(ResourcePack *resPack, ResourceId id);
+ void load(ResourceId id);
/**
* Copies an animation frame to the target buffer
@@ -75,6 +75,8 @@ public:
uint32 getFrameCount() { return _frames.size(); }
private:
+ AsylumEngine *_vm;
+
Common::Array <GraphicFrame> _frames;
int32 _flags;
int32 _flags2;
diff --git a/engines/asylum/system/screen.cpp b/engines/asylum/system/screen.cpp
index 62dd9939f4..381a1cc00e 100644
--- a/engines/asylum/system/screen.cpp
+++ b/engines/asylum/system/screen.cpp
@@ -113,8 +113,8 @@ void Screen::copyRectToScreenWithTransparency(byte *buffer, int32 pitch, int32 x
_vm->_system->unlockScreen();
}
-void Screen::setPalette(ResourcePack *resPack, ResourceId id) {
- setPalette(resPack->getResource(id)->data + 32);
+void Screen::setPalette(ResourceId id) {
+ setPalette(getResource()->get(id)->data + 32);
}
void Screen::setPalette(byte *rgbPalette) {
@@ -135,7 +135,7 @@ void Screen::setPalette(byte *rgbPalette) {
_vm->_system->setPalette(palette, 0, 256);
}
-void Screen::setGammaLevel(ResourcePack *resPack, ResourceId id, int32 val) {
+void Screen::setGammaLevel(ResourceId id, int32 val) {
error("[Screen::setGammaLevel] not implemented");
}
@@ -183,18 +183,16 @@ void Screen::addGraphicToQueue(GraphicQueueItem item) {
}
void Screen::drawGraphicsInQueue() {
- WorldStats *ws = _vm->scene()->worldstats();
-
// sort by priority first
graphicsSelectionSort();
for (uint32 i = 0; i < _queueItems.size(); i++) {
- GraphicResource *grRes = _vm->scene()->getGraphicResource(_queueItems[i].resourceId);
+ GraphicResource *grRes = new GraphicResource(_vm, _queueItems[i].resourceId);
GraphicFrame *fra = grRes->getFrame(_queueItems[i].frameIdx);
copyToBackBufferWithTransparency((byte *)fra->surface.pixels,
fra->surface.w,
- _queueItems[i].x - ws->xLeft, _queueItems[i].y - ws->yTop,
+ _queueItems[i].x - getWorld()->xLeft, _queueItems[i].y - getWorld()->yTop,
fra->surface.w,
fra->surface.h);
diff --git a/engines/asylum/system/screen.h b/engines/asylum/system/screen.h
index a715680ae2..7742d74d52 100644
--- a/engines/asylum/system/screen.h
+++ b/engines/asylum/system/screen.h
@@ -62,9 +62,9 @@ public:
void copyRectToScreen(byte *buffer, int32 pitch, int32 x, int32 y, int32 width, int32 height);
void copyRectToScreenWithTransparency(byte *buffer, int32 pitch, int32 x, int32 y, int32 width, int32 height);
void setPalette(byte *rgbPalette);
- void setPalette(ResourcePack *resPack, ResourceId id);
+ void setPalette(ResourceId id);
- void setGammaLevel(ResourcePack *resPack, ResourceId id, int32 val);
+ void setGammaLevel(ResourceId id, int32 val);
void drawWideScreen(int16 barSize);
void clearScreen();
diff --git a/engines/asylum/system/sound.cpp b/engines/asylum/system/sound.cpp
index a95bc54d29..d70817107c 100644
--- a/engines/asylum/system/sound.cpp
+++ b/engines/asylum/system/sound.cpp
@@ -38,16 +38,11 @@
namespace Asylum {
-Sound::Sound(Audio::Mixer *mixer) : _mixer(mixer) {
- _speechPack = new ResourcePack(kResourcePackSpeech);
- _soundPack = new ResourcePack(kResourcePackSound);
- _currentMusicResIndex = -666;
+Sound::Sound(AsylumEngine *engine, Audio::Mixer *mixer) : _vm(engine), _mixer(mixer) {
+ _currentMusicResIndex = kResourceMusicStopped;
}
Sound::~Sound() {
- delete _speechPack;
- delete _soundPack;
-
clearSoundBuffer();
}
@@ -172,24 +167,24 @@ bool Sound::isPlaying(ResourceId resourceId) {
return false;
}
-void Sound::playSound(ResourcePack *pack, ResourceId resourceId, int32 volume, bool looping, int32 panning, bool overwrite) {
- ResourceEntry *resource = pack->getResource(resourceId);
- if (_mixer->isSoundHandleActive(_soundHandle)) {
- if (overwrite) {
- _mixer->stopHandle(_soundHandle);
- playSound(resource, looping, volume, panning);
- }
- } else {
- // if the current handle isn't active, play the sound
- playSound(resource, looping, volume, panning);
- }
-}
-
-void Sound::playSound(ResourceEntry *resource, bool looping, int32 volume, int32 panning) {
- playSoundData(Audio::Mixer::kSFXSoundType, &_soundHandle, resource->data, resource->size, looping, volume, panning);
-}
-
-void Sound::playSound(ResourcePack *pack, ResourceId resourceId, bool looping, int32 volume, int32 panning) {
+//void Sound::playSound(ResourceId resourceId, int32 volume, bool looping, int32 panning, bool overwrite) {
+// ResourceEntry *resource = getResource()->get(resourceId);
+// if (_mixer->isSoundHandleActive(_soundHandle)) {
+// if (overwrite) {
+// _mixer->stopHandle(_soundHandle);
+// playSound(resource, looping, volume, panning);
+// }
+// } else {
+// // if the current handle isn't active, play the sound
+// playSound(resource, looping, volume, panning);
+// }
+//}
+//
+//void Sound::playSound(ResourceEntry *resource, bool looping, int32 volume, int32 panning) {
+// playSoundData(Audio::Mixer::kSFXSoundType, &_soundHandle, resource->data, resource->size, looping, volume, panning);
+//}
+
+void Sound::playSound(ResourceId resourceId, bool looping, int32 volume, int32 panning) {
int32 pos = getBufferPosition(resourceId);
if (pos < 0) {
@@ -199,7 +194,7 @@ void Sound::playSound(ResourcePack *pack, ResourceId resourceId, bool looping, i
if (_mixer->isSoundHandleActive(snd.handle)) {
debugC(kDebugLevelSound, "playSound: handle for resource %d already active", resourceId);
} else {
- ResourceEntry *ent = _soundPack->getResource(resourceId);
+ ResourceEntry *ent = getResource()->get(resourceId);
playSoundData(Audio::Mixer::kSFXSoundType, &snd.handle, ent->data, ent->size, looping, volume, panning);
addToSoundBuffer(resourceId);
}
@@ -207,19 +202,19 @@ void Sound::playSound(ResourcePack *pack, ResourceId resourceId, bool looping, i
}
-void Sound::playSound(ResourceId resourceId, bool looping, int32 volume, int32 panning, bool fromBuffer) {
- if (fromBuffer) {
- playSound(_soundPack, resourceId, looping, volume, panning);
- } else {
- if (_mixer->isSoundHandleActive(_soundHandle)) {
- debugC(kDebugLevelSound, "playSound: temporary sound handle is active");
- } else {
- ResourceEntry *ent = _soundPack->getResource(resourceId);
- playSound(ent, looping, volume, panning);
- addToSoundBuffer(resourceId);
- }
- }
-}
+//void Sound::playSound(ResourceId resourceId, bool looping, int32 volume, int32 panning, bool fromBuffer) {
+// if (fromBuffer) {
+// playSound(resourceId, looping, volume, panning);
+// } else {
+// if (_mixer->isSoundHandleActive(_soundHandle)) {
+// debugC(kDebugLevelSound, "playSound: temporary sound handle is active");
+// } else {
+// ResourceEntry *ent = getResource()->get(resourceId);
+// playSound(resourceId, looping, volume, panning);
+// addToSoundBuffer(resourceId);
+// }
+// }
+//}
void Sound::stopSound() {
if (_mixer->isSoundHandleActive(_soundHandle))
@@ -249,7 +244,7 @@ void Sound::stopAllSounds(bool stopSpeechAndMusic) {
}
void Sound::playSpeech(ResourceId resourceId) {
- ResourceEntry *ent = _speechPack->getResource(resourceId);
+ ResourceEntry *ent = getResource()->get(resourceId);
_mixer->stopHandle(_speechHandle);
playSoundData(Audio::Mixer::kSpeechSoundType, &_speechHandle, ent->data, ent->size, false, 0, 0);
@@ -259,17 +254,17 @@ void Sound::setSpeech(ResourceId sound, ResourceId speechText) {
error("[Sound::setSpeech] not implemented!");
}
-void Sound::playMusic(ResourcePack *pack, ResourceId resourceId, int32 volume) {
+void Sound::playMusic(ResourceId resourceId, int32 volume) {
if (resourceId == kResourceNone)
return;
stopMusic();
- ResourceEntry *resource = pack->getResource(resourceId);
+ ResourceEntry *resource = getResource()->get(resourceId);
playSoundData(Audio::Mixer::kMusicSoundType, &_musicHandle, resource->data, resource->size, true, volume, 0);
}
-void Sound::changeMusic(ResourcePack *pack, ResourceId resourceId, int32 musicStatusExt) {
+void Sound::changeMusic(ResourceId resourceId, int32 musicStatusExt) {
error("[Sound::changeMusic] not implemented!");
}
diff --git a/engines/asylum/system/sound.h b/engines/asylum/system/sound.h
index 0f2a8450e4..1433d557b6 100644
--- a/engines/asylum/system/sound.h
+++ b/engines/asylum/system/sound.h
@@ -36,7 +36,7 @@
namespace Asylum {
-class ResourcePack;
+class AsylumEngine;
struct ResourceEntry;
@@ -79,7 +79,7 @@ struct SoundBufferItem {
class Sound {
public:
- Sound(Audio::Mixer *mixer);
+ Sound(AsylumEngine *engine, Audio::Mixer *mixer);
~Sound();
bool addToSoundBuffer(ResourceId resourceId);
@@ -91,10 +91,10 @@ public:
*
* @param overwrite determine if _soundHandle should be overwritten if still active
*/
- void playSound(ResourcePack *pack, ResourceId resourceId, int32 volume, bool looping = false, int32 panning = 0, bool overwrite = false);
- void playSound(ResourcePack *pack, ResourceId resourceId, bool looping, int32 volume, int32 panning);
- void playSound(ResourceEntry *resource, bool looping, int32 volume, int32 panning);
- void playSound(ResourceId resourceId, bool looping = false, int32 volume = Config.sfxVolume, int32 panning = 0, bool fromBuffer = false);
+ //void playSound(ResourceId resourceId, int32 volume, bool looping = false, int32 panning = 0, bool overwrite = false);
+ //void playSound(ResourceId resourceId, bool looping = false, int32 volume = Config.sfxVolume, int32 panning = 0, bool fromBuffer = false);
+ void playSound(ResourceId resourceId, bool looping = false, int32 volume = Config.sfxVolume, int32 panning = 0);
+ //void playSound(ResourceEntry *resource, bool looping, int32 volume, int32 panning);
void stopSound(ResourceId resourceId);
void stopSound();
@@ -103,8 +103,8 @@ public:
void playSpeech(ResourceId resourceId);
void setSpeech(ResourceId sound, ResourceId speechText);
- void playMusic(ResourcePack *pack, ResourceId resourceId, int32 volume = Config.musicVolume);
- void changeMusic(ResourcePack *pack, ResourceId resourceId, int32 musicStatusExt);
+ void playMusic(ResourceId resourceId, int32 volume = Config.musicVolume);
+ void changeMusic(ResourceId resourceId, int32 musicStatusExt);
void stopMusic();
void setVolume(ResourceId resourceId, double volume);
@@ -145,15 +145,14 @@ public:
ResourceId speechTextResourceId;
private:
+ AsylumEngine *_vm;
+
Audio::Mixer *_mixer;
Audio::SoundHandle _speechHandle;
Audio::SoundHandle _musicHandle;
Audio::SoundHandle _soundHandle;
- ResourcePack *_speechPack;
- ResourcePack *_soundPack;
-
Common::Array<SoundBufferItem> _soundBuffer;
/**
@@ -162,7 +161,7 @@ private:
* to track it uniquely, as this doesn't involve initializing the
* scene just to set a single variable
*/
- int32 _currentMusicResIndex;
+ uint32 _currentMusicResIndex;
/**
* Find the index within the _soundBuffer array of the
diff --git a/engines/asylum/system/speech.cpp b/engines/asylum/system/speech.cpp
index 489866a735..c15de1afb5 100644
--- a/engines/asylum/system/speech.cpp
+++ b/engines/asylum/system/speech.cpp
@@ -37,10 +37,10 @@
namespace Asylum {
-Speech::Speech(Scene *scene): _scene(scene) {
- _tick = _scene->vm()->getTick();
- _soundResourceId = 0;
- _textResourceId = 0;
+Speech::Speech(AsylumEngine *engine): _vm(engine) {
+ _tick = _vm->getTick();
+ _soundResourceId = kResourceNone;
+ _textResourceId = kResourceNone;
}
Speech::~Speech() {
@@ -48,9 +48,9 @@ Speech::~Speech() {
}
int32 Speech::play(ResourceId speechResourceId) {
- int32 soundResourceId = 0;
+ ResourceId soundResourceId = kResourceNone;
- switch (_scene->worldstats()->actorType) {
+ switch (getWorld()->actorType) {
case kActorMax: {
int32 soundResourceId2 = speechResourceId;
int32 textResourceId = speechResourceId;
@@ -60,29 +60,29 @@ int32 Speech::play(ResourceId speechResourceId) {
textResourceId -= 9;
}
- soundResourceId = soundResourceId2 - 0x7FFD0000;
+ soundResourceId = (ResourceId)(soundResourceId2 - 0x7FFD0000);
// setup the right index for sound and text
- setPlayerSpeech(soundResourceId, textResourceId - 0x7FFFFFAD);
+ setPlayerSpeech(soundResourceId, (ResourceId)(textResourceId - 0x7FFFFFAD));
}
break;
// TODO: check if actor type is right for the following cases
case kActorSarah: {
- soundResourceId = speechResourceId - 0x7FFBF879;
- setPlayerSpeech(soundResourceId, speechResourceId - 0x7FFFFDB6);
+ soundResourceId = (ResourceId)(speechResourceId - 0x7FFBF879);
+ setPlayerSpeech(soundResourceId, (ResourceId)(speechResourceId - 0x7FFFFDB6));
}
break;
case kActorCyclops: {
- soundResourceId = speechResourceId - 0x7FFBF7DC;
- setPlayerSpeech(soundResourceId, speechResourceId - 0x7FFFFD19);
+ soundResourceId = (ResourceId)(speechResourceId - 0x7FFBF7DC);
+ setPlayerSpeech(soundResourceId, (ResourceId)(speechResourceId - 0x7FFFFD19));
}
break;
case kActorAztec: {
- soundResourceId = speechResourceId - 0x7FFBF746;
- setPlayerSpeech(soundResourceId, speechResourceId - 0x7FFFFC83);
+ soundResourceId = (ResourceId)(speechResourceId - 0x7FFBF746);
+ setPlayerSpeech(soundResourceId, (ResourceId)(speechResourceId - 0x7FFFFC83));
}
break;
default:
- soundResourceId = 0;
+ soundResourceId = kResourceNone;
break;
}
@@ -91,8 +91,8 @@ int32 Speech::play(ResourceId speechResourceId) {
void Speech::setPlayerSpeech(ResourceId soundResourceId, ResourceId textResourceId) {
if (soundResourceId) {
- if (_scene->vm()->sound()->isPlaying(soundResourceId)) {
- _scene->vm()->sound()->stopSound(soundResourceId);
+ if (getSound()->isPlaying(soundResourceId)) {
+ getSound()->stopSound(soundResourceId);
}
}
@@ -106,7 +106,7 @@ void Speech::prepareSpeech() {
//int32 startTick = _scene->vm()->getTick();
if (_soundResourceId) {
- if (!_scene->vm()->sound()->isPlaying(_soundResourceId)/* || _tick && startTick >= _tick*/) {
+ if (!getSound()->isPlaying(_soundResourceId)/* || _tick && startTick >= _tick*/) {
processSpeech();
}
@@ -119,11 +119,11 @@ void Speech::prepareSpeech() {
check = pt->y >= 240;*/
int32 posY = ((check - 1) & 0x118) + 40;
- _scene->vm()->text()->loadFont(_scene->getResourcePack(), _scene->worldstats()->font3);
- _scene->vm()->text()->drawText(20, posY, _textDataPos);
+ getText()->loadFont(getWorld()->font3);
+ getText()->drawText(20, posY, _textDataPos);
- _scene->vm()->text()->loadFont(_scene->getResourcePack(), _scene->worldstats()->font1);
- _scene->vm()->text()->drawText(20, posY, _textData);
+ getText()->loadFont(getWorld()->font1);
+ getText()->drawText(20, posY, _textData);
}
}
}
@@ -133,10 +133,10 @@ void Speech::processSpeech() {
_tick = 0;
- txt = _scene->vm()->text()->getResText(_textResourceId);
+ txt = getText()->getResText(_textResourceId);
if (*(txt + strlen((const char *)txt) - 2) == 1) {
- _textResourceId = 0;
+ _textResourceId = kResourceNone;
_textData = 0;
_textDataPos = 0;
} else {
@@ -144,8 +144,8 @@ void Speech::processSpeech() {
_textData = txt + 3;
_textDataPos = 0;
- _scene->vm()->text()->loadFont(_scene->getResourcePack(), _scene->worldstats()->font1);
- _scene->vm()->sound()->playSpeech(_soundResourceId);
+ getText()->loadFont(getWorld()->font1);
+ getSound()->playSpeech(_soundResourceId);
} else {
_textData = 0;
_textDataPos = txt;
@@ -154,8 +154,8 @@ void Speech::processSpeech() {
_textDataPos = txt + 2;
}
- _scene->vm()->text()->loadFont(_scene->getResourcePack(), _scene->worldstats()->font3);
- _scene->vm()->sound()->playSpeech(_soundResourceId);
+ getText()->loadFont(getWorld()->font3);
+ getSound()->playSpeech(_soundResourceId);
}
}
}
diff --git a/engines/asylum/system/speech.h b/engines/asylum/system/speech.h
index d025742d4e..f0905dadbf 100644
--- a/engines/asylum/system/speech.h
+++ b/engines/asylum/system/speech.h
@@ -32,11 +32,11 @@
namespace Asylum {
-class Scene;
+class AsylumEngine;
class Speech {
public:
- Speech(Scene *scene);
+ Speech(AsylumEngine *engine);
virtual ~Speech();
ResourceId _soundResourceId;
@@ -61,7 +61,7 @@ public:
void prepareSpeech();
private:
- Scene *_scene;
+ AsylumEngine *_vm;
int32 _tick;
char *_textData;
diff --git a/engines/asylum/system/text.cpp b/engines/asylum/system/text.cpp
index 55bd94b59a..3e81bd7c30 100644
--- a/engines/asylum/system/text.cpp
+++ b/engines/asylum/system/text.cpp
@@ -28,34 +28,32 @@
#include "asylum/system/graphics.h"
#include "asylum/system/screen.h"
+#include "asylum/asylum.h"
#include "asylum/respack.h"
#include "common/endian.h"
namespace Asylum {
-Text::Text(Screen *screen) : _screen(screen) {
+Text::Text(AsylumEngine *engine) : _vm(engine) {
_posX = 0;
_posY = 0;
_curFontFlags = 0;
_fontResource = 0;
-
- _textPack = new ResourcePack(kResourcePackText);
}
Text::~Text() {
- delete _textPack;
delete _fontResource;
}
// loadFont at address 00435640
-void Text::loadFont(ResourcePack *resPack, ResourceId resourceId) {
+void Text::loadFont(ResourceId resourceId) {
if (_fontResource && resourceId == _fontResource->getResourceId())
return;
delete _fontResource;
- _fontResource = new GraphicResource(resPack, resourceId);
+ _fontResource = new GraphicResource(_vm, resourceId);
if (resourceId > 0) {
// load font flag data
@@ -85,12 +83,12 @@ int32 Text::getTextWidth(const char *text) {
}
int32 Text::getResTextWidth(ResourceId resourceId) {
- ResourceEntry *textRes = _textPack->getResource(resourceId);
+ ResourceEntry *textRes = getResource()->get(resourceId);
return getTextWidth((char*)textRes->data);
}
char* Text::getResText(ResourceId resourceId) {
- ResourceEntry *textRes = _textPack->getResource(resourceId);
+ ResourceEntry *textRes = getResource()->get(resourceId);
return (char*)textRes->data;
}
@@ -98,7 +96,7 @@ void Text::drawChar(unsigned char character) {
assert(_fontResource);
GraphicFrame *fontLetter = _fontResource->getFrame(character);
- _screen->copyRectToScreenWithTransparency((byte *)fontLetter->surface.pixels, fontLetter->surface.w, _posX, _posY + fontLetter->y, fontLetter->surface.w, fontLetter->surface.h);
+ getScreen()->copyRectToScreenWithTransparency((byte *)fontLetter->surface.pixels, fontLetter->surface.w, _posX, _posY + fontLetter->y, fontLetter->surface.w, fontLetter->surface.h);
_posX += fontLetter->surface.w + fontLetter->x - _curFontFlags;
}
@@ -110,7 +108,7 @@ void Text::drawText(const char *text) {
}
void Text::drawResText(ResourceId resourceId) {
- ResourceEntry *textRes = _textPack->getResource(resourceId);
+ ResourceEntry *textRes = getResource()->get(resourceId);
drawText((char*)textRes->data);
}
@@ -121,7 +119,7 @@ void Text::drawTextCentered(int32 x, int32 y, int32 width, const char *text) {
}
void Text::drawResTextWithValueCentered(int32 x, int32 y, int32 width, ResourceId resourceId, int32 value) {
- ResourceEntry *textRes = _textPack->getResource(resourceId);
+ ResourceEntry *textRes = getResource()->get(resourceId);
char *text = (char *)textRes->data;
char txt[100];
sprintf(txt, text, value);
@@ -129,7 +127,7 @@ void Text::drawResTextWithValueCentered(int32 x, int32 y, int32 width, ResourceI
}
void Text::drawResTextCentered(int32 x, int32 y, int32 width, ResourceId resourceId) {
- ResourceEntry *textRes = _textPack->getResource(resourceId);
+ ResourceEntry *textRes = getResource()->get(resourceId);
drawTextCentered(x, y, width, (char *)textRes->data);
}
@@ -142,7 +140,7 @@ void Text::drawText(int32 x, int32 y, const char *text) {
}
void Text::drawResText(int32 x, int32 y, ResourceId resourceId) {
- ResourceEntry *textRes = _textPack->getResource(resourceId);
+ ResourceEntry *textRes = getResource()->get(resourceId);
drawText(x, y, (char *)textRes->data);
}
@@ -153,7 +151,7 @@ void Text::drawTextAlignRight(int32 x, int32 y, const char *text) {
}
void Text::drawResTextAlignRight(int32 x, int32 y, ResourceId resourceId) {
- ResourceEntry *textRes = _textPack->getResource(resourceId);
+ ResourceEntry *textRes = getResource()->get(resourceId);
drawTextAlignRight(x, y, (char *)textRes->data);
}
diff --git a/engines/asylum/system/text.h b/engines/asylum/system/text.h
index daae8d7bf2..af27516780 100644
--- a/engines/asylum/system/text.h
+++ b/engines/asylum/system/text.h
@@ -32,16 +32,16 @@
namespace Asylum {
+class AsylumEngine;
class GraphicResource;
class ResourcePack;
-class Screen;
class Text {
public:
- Text(Screen *screen);
+ Text(AsylumEngine *engine);
~Text();
- void loadFont(ResourcePack *resPack, ResourceId resourceId);
+ void loadFont(ResourceId resourceId);
void setTextPos(int32 x, int32 y);
int32 getTextWidth(const char *text);
@@ -62,9 +62,9 @@ public:
void drawResTextAlignRight(int32 x, int32 y, ResourceId resourceId);
private:
- Screen *_screen;
+ AsylumEngine *_vm;
+
GraphicResource *_fontResource;
- ResourcePack *_textPack;
int32 _posX;
int32 _posY;
diff --git a/engines/asylum/system/video.cpp b/engines/asylum/system/video.cpp
index 0761c4d8a6..6790d41c4d 100644
--- a/engines/asylum/system/video.cpp
+++ b/engines/asylum/system/video.cpp
@@ -28,12 +28,13 @@
#include "asylum/system/graphics.h"
#include "asylum/system/text.h"
+#include "asylum/asylum.h"
#include "asylum/respack.h"
#include "asylum/staticres.h"
namespace Asylum {
-Video::Video(Audio::Mixer *mixer): _skipVideo(false) {
+Video::Video(AsylumEngine *engine, Audio::Mixer *mixer): _skipVideo(false) {
Common::Event stopEvent;
_stopEvents.clear();
stopEvent.type = Common::EVENT_KEYDOWN;
@@ -42,10 +43,8 @@ Video::Video(Audio::Mixer *mixer): _skipVideo(false) {
_smkDecoder = new Graphics::SmackerDecoder(mixer);
- _text = new VideoText();
- ResourcePack *resPack = new ResourcePack(kResourcePackShared);
- _text->loadFont(resPack, 57); // video font
- delete resPack;
+ _text = new VideoText(engine);
+ _text->loadFont(MAKE_RESOURCE(kResourcePackShared, 57)); // video font
}
Video::~Video() {
@@ -111,7 +110,7 @@ void Video::performPostProcessing(byte *screen) {
VideoSubtitle curSubtitle = _subtitles[i];
if (curFrame >= curSubtitle.frameStart &&
curFrame <= curSubtitle.frameEnd) {
- _text->drawMovieSubtitle(screen, curSubtitle.textRes);
+ _text->drawMovieSubtitle(screen, curSubtitle.textResourceId);
break;
}
}
@@ -149,7 +148,7 @@ void Video::loadSubtitles(int32 videoNumber) {
tok = strtok(NULL, " ");
newSubtitle.frameEnd = atoi(tok);
tok = strtok(NULL, " ");
- newSubtitle.textRes = atoi(tok) + video_subtitle_resourceIds[videoNumber];
+ newSubtitle.textResourceId = (ResourceId)(atoi(tok) + video_subtitle_resourceIds[videoNumber]);
tok = strtok(NULL, " ");
_subtitles.push_back(newSubtitle);
@@ -185,22 +184,19 @@ void Video::processVideoEvents() {
}
-VideoText::VideoText() {
+VideoText::VideoText(AsylumEngine *engine) : _vm(engine) {
_curFontFlags = 0;
- _fontResource = 0;
-
- _textPack = new ResourcePack(kResourcePackText);
+ _fontResource = NULL;
}
VideoText::~VideoText() {
- delete _textPack;
delete _fontResource;
}
-void VideoText::loadFont(ResourcePack *resPack, ResourceId resourceId) {
+void VideoText::loadFont(ResourceId resourceId) {
delete _fontResource;
- _fontResource = new GraphicResource(resPack, resourceId);
+ _fontResource = new GraphicResource(_vm, resourceId);
if (resourceId > 0) {
// load font flag data
@@ -212,7 +208,7 @@ void VideoText::drawMovieSubtitle(byte *screenBuffer, ResourceId resourceId) {
Common::String textLine[4];
Common::String tmpLine;
int32 curLine = 0;
- ResourceEntry *textRes = _textPack->getResource(resourceId);
+ ResourceEntry *textRes = getResource()->get(resourceId);
char *text = strdup((const char *)textRes->data); // for strtok
char *tok = strtok(text, " ");
int32 startY = 420; // starting y for up to 2 subtitles
diff --git a/engines/asylum/system/video.h b/engines/asylum/system/video.h
index 8c67dce23b..be7ed13afc 100644
--- a/engines/asylum/system/video.h
+++ b/engines/asylum/system/video.h
@@ -40,21 +40,20 @@
namespace Asylum {
-struct GraphicFrame;
+class AsylumEngine;
class GraphicResource;
-class ResourcePack;
+class VideoText;
+struct GraphicFrame;
struct VideoSubtitle {
int frameStart;
int frameEnd;
- int textRes;
+ ResourceId textResourceId;
};
-class VideoText;
-
class Video {
public:
- Video(Audio::Mixer *mixer);
+ Video(AsylumEngine *engine, Audio::Mixer *mixer);
virtual ~Video();
void playVideo(int32 videoNumber, bool showSubtitles);
@@ -77,20 +76,21 @@ private:
// text directly to the screen
class VideoText {
public:
- VideoText();
+ VideoText(AsylumEngine *engine);
~VideoText();
- void loadFont(ResourcePack *resPack, ResourceId resourceId);
+ void loadFont(ResourceId resourceId);
void drawMovieSubtitle(byte *screenBuffer, ResourceId resourceId);
private:
+ AsylumEngine *_vm;
+
int32 getTextWidth(const char *text);
void drawText(byte *screenBuffer, int16 x, int16 y, const char *text);
void copyToVideoFrame(byte *screenBuffer, GraphicFrame *frame, int x, int y);
GraphicResource *_fontResource;
- ResourcePack *_textPack;
uint8 _curFontFlags;
}; // end of class VideoText
diff --git a/engines/asylum/views/blowuppuzzle.cpp b/engines/asylum/views/blowuppuzzle.cpp
index a800c35416..78bbdc8cb0 100644
--- a/engines/asylum/views/blowuppuzzle.cpp
+++ b/engines/asylum/views/blowuppuzzle.cpp
@@ -41,29 +41,30 @@
namespace Asylum {
-BlowUpPuzzle::BlowUpPuzzle(Scene *scene): _scene(scene) {
+BlowUpPuzzle::BlowUpPuzzle(AsylumEngine *engine): _vm(engine) {
}
+
BlowUpPuzzle::~BlowUpPuzzle() {
}
// BlowUp Puzzle VCR ---------------------------------------------------------------------------------------------
-BlowUpPuzzleVCR::BlowUpPuzzleVCR(Scene *scene): BlowUpPuzzle(scene) {
+BlowUpPuzzleVCR::BlowUpPuzzleVCR(AsylumEngine *engine): BlowUpPuzzle(engine) {
_leftClickUp = false;
_leftClickDown = false;
_rightClickDown = false;
_active = false;
- _bgResource = _scene->getGraphicResource(_scene->worldstats()->graphicResourceIds[0]);
+ _bgResource = new GraphicResource(_vm, getWorld()->graphicResourceIds[0]);
_tvScreenAnimIdx = 0;
_isAccomplished = false;
// setup cursor
- _cursor = new Cursor(_scene->getResourcePack());
+ _cursor = new Cursor(_vm);
// reset all states
- memset(&_jacksState, 0, sizeof(_jacksState));
- memset(&_holesState, 0, sizeof(_holesState));
+ memset(&_jacksState, 0, sizeof(_jacksState));
+ memset(&_holesState, 0, sizeof(_holesState));
memset(&_buttonsState, 0, sizeof(_buttonsState));
}
@@ -74,19 +75,19 @@ BlowUpPuzzleVCR::~BlowUpPuzzleVCR() {
void BlowUpPuzzleVCR::openBlowUp() {
_active = true;
- _scene->deactivate();
+ getScene()->deactivate();
- _scene->vm()->sound()->stopAllSounds(true);
+ getSound()->stopAllSounds(true);
// Load the graphics palette
- _scene->vm()->screen()->setPalette(_scene->getResourcePack(), _scene->worldstats()->graphicResourceIds[29]);
+ getScreen()->setPalette(getWorld()->graphicResourceIds[29]);
// show blow up puzzle BG
GraphicFrame *bg = _bgResource->getFrame(0);
- _scene->vm()->screen()->copyToBackBuffer((byte *)bg->surface.pixels, bg->surface.w, 0, 0, bg->surface.w, bg->surface.h);
+ getScreen()->copyToBackBuffer((byte *)bg->surface.pixels, bg->surface.w, 0, 0, bg->surface.w, bg->surface.h);
// Set mouse cursor
- _cursor->set(_scene->worldstats()->graphicResourceIds[28], 0, 2);
+ _cursor->set(getWorld()->graphicResourceIds[28], 0, 2);
_cursor->show();
_leftClickUp = false;
@@ -96,7 +97,7 @@ void BlowUpPuzzleVCR::openBlowUp() {
void BlowUpPuzzleVCR::closeBlowUp() {
_active = false;
- _scene->activate();
+ getScene()->activate();
}
void BlowUpPuzzleVCR::handleEvent(Common::Event *event, bool doUpdate) {
@@ -124,7 +125,7 @@ void BlowUpPuzzleVCR::handleEvent(Common::Event *event, bool doUpdate) {
}
void BlowUpPuzzle::playSound(ResourceId resourceId, bool loop) {
- _scene->vm()->sound()->playSound(_scene->getResourcePack(), resourceId, Config.sfxVolume, loop, 0, true);
+ getSound()->playSound(resourceId, Config.sfxVolume, loop, 0/*, true*/);
}
int BlowUpPuzzleVCR::inPolyRegion(int x, int y, int polyIdx) {
@@ -133,13 +134,13 @@ int BlowUpPuzzleVCR::inPolyRegion(int x, int y, int polyIdx) {
}
void BlowUpPuzzleVCR::update() {
- _scene->vm()->screen()->clearGraphicsInQueue();
+ getScreen()->clearGraphicsInQueue();
if (_rightClickDown) { // quits BlowUp Puzzle
_rightClickDown = false;
closeBlowUp();
- _scene->vm()->sound()->stopSound();
- _scene->enterScene();
+ getSound()->stopSound();
+ getScene()->enterScene();
}
if (_leftClickDown) {
@@ -164,33 +165,33 @@ void BlowUpPuzzleVCR::update() {
updateStopButton();
if (_buttonsState[kPower] == kON) {
- _scene->vm()->screen()->addGraphicToQueue(_scene->worldstats()->graphicResourceIds[22], _tvScreenAnimIdx, 0, 37, 0, 0, 1);
- _scene->vm()->screen()->addGraphicToQueue(_scene->worldstats()->graphicResourceIds[23], _tvScreenAnimIdx++, 238, 22, 0, 0, 1);
+ getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[22], _tvScreenAnimIdx, 0, 37, 0, 0, 1);
+ getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[23], _tvScreenAnimIdx++, 238, 22, 0, 0, 1);
_tvScreenAnimIdx %= 6;
}
if (_isAccomplished) {
- _scene->vm()->screen()->drawGraphicsInQueue();
+ getScreen()->drawGraphicsInQueue();
int barSize = 0;
do {
- _scene->vm()->screen()->drawWideScreen(barSize);
+ getScreen()->drawWideScreen(barSize);
barSize += 4;
} while (barSize < 84);
// TODO: fade palette to grey
- _scene->vm()->video()->playVideo(2, true);
+ getVideo()->playVideo(2, true);
_isAccomplished = false;
_active = false;
- _scene->enterScene();
+ getScene()->enterScene();
} else {
- _scene->vm()->screen()->drawGraphicsInQueue();
+ getScreen()->drawGraphicsInQueue();
}
}
-GraphicQueueItem BlowUpPuzzleVCR::getGraphicJackItem(ResourceId resourceId) {
+GraphicQueueItem BlowUpPuzzleVCR::getGraphicJackItem(int32 index) {
GraphicQueueItem jackItemOnHand;
int jackY = _cursor->position().y;
@@ -198,7 +199,7 @@ GraphicQueueItem BlowUpPuzzleVCR::getGraphicJackItem(ResourceId resourceId) {
jackY = 356;
}
- jackItemOnHand.resourceId = _scene->worldstats()->graphicResourceIds[resourceId];
+ jackItemOnHand.resourceId = getWorld()->graphicResourceIds[index];
jackItemOnHand.frameIdx = 0;
jackItemOnHand.x = _cursor->position().x - 114;
jackItemOnHand.y = jackY - 14;
@@ -214,7 +215,7 @@ GraphicQueueItem BlowUpPuzzleVCR::getGraphicShadowItem() {
if (_cursor->position().y < 356) {
shadowY = 0;
}
- shadowItem.resourceId = _scene->worldstats()->graphicResourceIds[30];
+ shadowItem.resourceId = getWorld()->graphicResourceIds[30];
shadowItem.frameIdx = 0;
shadowItem.x = _cursor->position().x - shadowY;
shadowItem.y = 450;
@@ -223,52 +224,52 @@ GraphicQueueItem BlowUpPuzzleVCR::getGraphicShadowItem() {
return shadowItem;
}
-void BlowUpPuzzleVCR::updateJack(Jack jack, VCRDrawInfo onTable, VCRDrawInfo pluggedOnRed, VCRDrawInfo pluggedOnYellow, VCRDrawInfo pluggedOnBlack, ResourceId resourceIdOnHand) {
+void BlowUpPuzzleVCR::updateJack(Jack jack, VCRDrawInfo onTable, VCRDrawInfo pluggedOnRed, VCRDrawInfo pluggedOnYellow, VCRDrawInfo pluggedOnBlack, int32 resourceOnHandIndex) {
GraphicQueueItem item;
switch (_jacksState[jack]) {
case kOnTable:
- item.resourceId = _scene->worldstats()->graphicResourceIds[onTable.resourceId];
+ item.resourceId = getWorld()->graphicResourceIds[onTable.resourceId];
item.frameIdx = 0;
item.x = onTable.x;
item.y = onTable.y;
item.priority = 3;
break;
case kPluggedOnRed:
- item.resourceId = _scene->worldstats()->graphicResourceIds[pluggedOnRed.resourceId];
+ item.resourceId = getWorld()->graphicResourceIds[pluggedOnRed.resourceId];
item.frameIdx = 0;
item.x = 329;
item.y = 407;
item.priority = 3;
break;
case kPluggedOnYellow:
- item.resourceId = _scene->worldstats()->graphicResourceIds[pluggedOnYellow.resourceId];
+ item.resourceId = getWorld()->graphicResourceIds[pluggedOnYellow.resourceId];
item.frameIdx = 0;
item.x = 402;
item.y = 413;
item.priority = 3;
break;
case kPluggedOnBlack:
- item.resourceId = _scene->worldstats()->graphicResourceIds[pluggedOnBlack.resourceId];
+ item.resourceId = getWorld()->graphicResourceIds[pluggedOnBlack.resourceId];
item.frameIdx = 0;
item.x = 477;
item.y = 418;
item.priority = 3;
break;
case kOnHand: {
- GraphicQueueItem jackItemOnHand = getGraphicJackItem(resourceIdOnHand);
- _scene->vm()->screen()->addGraphicToQueue(jackItemOnHand);
+ GraphicQueueItem jackItemOnHand = getGraphicJackItem(resourceOnHandIndex);
+ getScreen()->addGraphicToQueue(jackItemOnHand);
item = getGraphicShadowItem();
}
break;
default:
- item.resourceId = 0;
+ item.resourceId = kResourceNone;
break;
}
if (item.resourceId != 0)
- _scene->vm()->screen()->addGraphicToQueue(item);
+ getScreen()->addGraphicToQueue(item);
}
void BlowUpPuzzleVCR::updateBlackJack() {
@@ -332,13 +333,13 @@ int BlowUpPuzzleVCR::setJackOnHole(int jackType, JackState plugged) {
if (_jacksState[jackType-1] == kOnHand) {
_jacksState[jackType-1] = plugged;
_holesState[plugged-1] = jackType; // set jack on red
- playSound(_scene->worldstats()->graphicResourceIds[44]);
+ playSound(getWorld()->graphicResourceIds[44]);
}
} else if (jackType == 0) {
jackType = _holesState[plugged-1];
_jacksState[jackType-1] = kOnHand;
_holesState[plugged-1] = 0;
- playSound(_scene->worldstats()->graphicResourceIds[43]);
+ playSound(getWorld()->graphicResourceIds[43]);
return 0;
}
return 1;
@@ -349,7 +350,7 @@ void BlowUpPuzzleVCR::updateButton(Button button, VCRDrawInfo btON, VCRDrawInfo
switch (_buttonsState[button]) {
case kON:
- item.resourceId = _scene->worldstats()->graphicResourceIds[btON.resourceId];
+ item.resourceId = getWorld()->graphicResourceIds[btON.resourceId];
item.frameIdx = 0;
item.x = btON.x;
item.y = btON.y;
@@ -357,19 +358,19 @@ void BlowUpPuzzleVCR::updateButton(Button button, VCRDrawInfo btON, VCRDrawInfo
break;
case kDownON:
case kDownOFF:
- item.resourceId = _scene->worldstats()->graphicResourceIds[btDown.resourceId];
+ item.resourceId = getWorld()->graphicResourceIds[btDown.resourceId];
item.frameIdx = 0;
item.x = btDown.x;
item.y = btDown.y;
item.priority = 3;
break;
default:
- item.resourceId = 0;
+ item.resourceId = kResourceNone;
break;
}
if (item.resourceId != 0)
- _scene->vm()->screen()->addGraphicToQueue(item);
+ getScreen()->addGraphicToQueue(item);
}
@@ -443,26 +444,26 @@ void BlowUpPuzzleVCR::updateCursorInPolyRegion() {
if (!showCursor) {
if (inPolyRegion(_cursor->position().x, _cursor->position().y, kRewindButton)
- || inPolyRegion(_cursor->position().x, _cursor->position().y, kStopButton)
- || inPolyRegion(_cursor->position().x, _cursor->position().y, kPlayButton)
- || inPolyRegion(_cursor->position().x, _cursor->position().y, kPowerButton)
- || inPolyRegion(_cursor->position().x, _cursor->position().y, kBlackJack)
- || inPolyRegion(_cursor->position().x, _cursor->position().y, kRedJack)
- || inPolyRegion(_cursor->position().x, _cursor->position().y, kYellowJack)) {
+ || inPolyRegion(_cursor->position().x, _cursor->position().y, kStopButton)
+ || inPolyRegion(_cursor->position().x, _cursor->position().y, kPlayButton)
+ || inPolyRegion(_cursor->position().x, _cursor->position().y, kPowerButton)
+ || inPolyRegion(_cursor->position().x, _cursor->position().y, kBlackJack)
+ || inPolyRegion(_cursor->position().x, _cursor->position().y, kRedJack)
+ || inPolyRegion(_cursor->position().x, _cursor->position().y, kYellowJack)) {
_cursor->animate();
} else {
if ((inPolyRegion(_cursor->position().x, _cursor->position().y, kRedHole) && _holesState[kPluggedOnRed-1])
- || (inPolyRegion(_cursor->position().x, _cursor->position().y, kYellowHole) && _holesState[kPluggedOnYellow-1])
- || (inPolyRegion(_cursor->position().x, _cursor->position().y, kBlackHole) && _holesState[kPluggedOnBlack-1])) {
+ || (inPolyRegion(_cursor->position().x, _cursor->position().y, kYellowHole) && _holesState[kPluggedOnYellow-1])
+ || (inPolyRegion(_cursor->position().x, _cursor->position().y, kBlackHole) && _holesState[kPluggedOnBlack-1])) {
if (_cursor->currentFrame != 2) { // reset cursor
_cursor->show();
- _cursor->set(2, 0, 2);
+ _cursor->set(MAKE_RESOURCE(kResourcePackShared, 2), 0, 2);
_cursor->animate();
}
} else {
if (_cursor->currentFrame != 0) { // reset cursor
_cursor->show();
- _cursor->set(0, 0, 2);
+ _cursor->set(MAKE_RESOURCE(kResourcePackShared, 0), 0, 2);
_cursor->animate();
}
}
@@ -512,10 +513,11 @@ void BlowUpPuzzleVCR::handleMouseDown() {
// Put jacks on table --
if (jackType) {
- if (_cursor->position().x >= (int32)BlowUpPuzzleVCRPolies[kBlackJack].left && _cursor->position().x <= (int32)BlowUpPuzzleVCRPolies[kYellowJack].right &&
- _cursor->position().y >= (int32)BlowUpPuzzleVCRPolies[kBlackJack].top && _cursor->position().y <= (int32)BlowUpPuzzleVCRPolies[kYellowJack].bottom) {
+ if (_cursor->position().x >= (int32)BlowUpPuzzleVCRPolies[kBlackJack].left && _cursor->position().x <= (int32)BlowUpPuzzleVCRPolies[kYellowJack].right
+ && _cursor->position().y >= (int32)BlowUpPuzzleVCRPolies[kBlackJack].top && _cursor->position().y <= (int32)BlowUpPuzzleVCRPolies[kYellowJack].bottom) {
+
_jacksState[jackType-1] = kOnTable;
- playSound(_scene->worldstats()->graphicResourceIds[50]);
+ playSound(getWorld()->graphicResourceIds[50]);
_cursor->show();
}
return;
@@ -532,7 +534,7 @@ void BlowUpPuzzleVCR::handleMouseDown() {
// VCR button regions
if (inPolyRegion(_cursor->position().x, _cursor->position().y, kRewindButton)) {
- playSound(_scene->worldstats()->graphicResourceIds[39]);
+ playSound(getWorld()->graphicResourceIds[39]);
if (!_buttonsState[kRewind]) {
_buttonsState[kRewind] = kDownON;
return;
@@ -542,7 +544,7 @@ void BlowUpPuzzleVCR::handleMouseDown() {
return;
}
} else if (inPolyRegion(_cursor->position().x, _cursor->position().y, kPlayButton)) {
- playSound(_scene->worldstats()->graphicResourceIds[39]);
+ playSound(getWorld()->graphicResourceIds[39]);
if (!_buttonsState[kPlay]) {
_buttonsState[kPlay] = kDownON;
return;
@@ -552,7 +554,7 @@ void BlowUpPuzzleVCR::handleMouseDown() {
return;
}
} else if (inPolyRegion(_cursor->position().x, _cursor->position().y, kStopButton)) {
- playSound(_scene->worldstats()->graphicResourceIds[39]);
+ playSound(getWorld()->graphicResourceIds[39]);
if (_buttonsState[kStop]) {
if (_buttonsState[kStop] == kON) {
_buttonsState[kStop] = kDownOFF;
@@ -563,7 +565,7 @@ void BlowUpPuzzleVCR::handleMouseDown() {
return;
}
} else if (inPolyRegion(_cursor->position().x, _cursor->position().y, kPowerButton)) {
- playSound(_scene->worldstats()->graphicResourceIds[39]);
+ playSound(getWorld()->graphicResourceIds[39]);
if (!_buttonsState[kPower] && _holesState[kPluggedOnBlack-1] == kBlack + 1 && _holesState[kPluggedOnRed-1] && _holesState[kPluggedOnYellow-1]) {
_buttonsState[kPower] = kDownON;
@@ -578,7 +580,7 @@ void BlowUpPuzzleVCR::handleMouseUp() {
return;
if (_buttonsState[kPower] == kDownON) {
- playSound(_scene->worldstats()->graphicResourceIds[47], true);
+ playSound(getWorld()->graphicResourceIds[47], true);
_buttonsState[kPower] = kON;
_buttonsState[kStop] = kON;
_buttonsState[kPlay] = kON;
@@ -588,12 +590,12 @@ void BlowUpPuzzleVCR::handleMouseUp() {
_buttonsState[kStop] = kOFF;
_buttonsState[kPlay] = kOFF;
_buttonsState[kRewind] = kOFF;
- _scene->vm()->sound()->stopSound();
+ getSound()->stopSound();
}
if (_buttonsState[kRewind] == kDownOFF) {
_buttonsState[kRewind] = kON;
- playSound(_scene->worldstats()->graphicResourceIds[46]);
+ playSound(getWorld()->graphicResourceIds[46]);
} else if (_buttonsState[kRewind] == kDownON) {
_buttonsState[kRewind] = kOFF;
}
@@ -601,7 +603,7 @@ void BlowUpPuzzleVCR::handleMouseUp() {
if (_buttonsState[kPlay] == kDownOFF) {
_buttonsState[kPlay] = kON;
if (_holesState[kPluggedOnRed-1] == kRed + 1 && _holesState[kPluggedOnYellow-1] == kYellow + 1 && _holesState[kPluggedOnBlack-1] == kBlack + 1) {
- _scene->vm()->setGameFlag(kGameFlagSolveVCRBlowUpPuzzle);
+ _vm->setGameFlag(kGameFlagSolveVCRBlowUpPuzzle);
_isAccomplished = true;
}
} else if (_buttonsState[kPlay] == kDownON) {
diff --git a/engines/asylum/views/blowuppuzzle.h b/engines/asylum/views/blowuppuzzle.h
index 2ba0608203..089a2d19e0 100644
--- a/engines/asylum/views/blowuppuzzle.h
+++ b/engines/asylum/views/blowuppuzzle.h
@@ -33,7 +33,7 @@
namespace Asylum {
-class Scene;
+class AsylumEngine;
class Screen;
class Sound;
class Video;
@@ -43,20 +43,20 @@ struct GraphicQueueItem;
class BlowUpPuzzle {
public:
- BlowUpPuzzle(Scene *scene);
+ BlowUpPuzzle(AsylumEngine *engine);
virtual ~BlowUpPuzzle();
virtual void handleEvent(Common::Event *event, bool doUpdate) {};
virtual void openBlowUp() {};
virtual void closeBlowUp() {};
- bool isActive() {
- return _active;
- }
+ bool isActive() { return _active; }
+
protected:
+ AsylumEngine *_vm;
+
Common::Event *_ev;
- Scene *_scene;
Cursor *_cursor;
bool _leftClickUp;
bool _leftClickDown;
@@ -74,7 +74,7 @@ protected:
// ---- VCR -------------------
typedef struct VCRDrawInfo {
- ResourceId resourceId;
+ int32 resourceId;
int32 x;
int32 y;
} VCRDrawInfo;
@@ -94,7 +94,7 @@ const Common::Rect BlowUpPuzzleVCRPolies[10] = {
class BlowUpPuzzleVCR : public BlowUpPuzzle {
public:
- BlowUpPuzzleVCR(Scene *scene);
+ BlowUpPuzzleVCR(AsylumEngine *engine);
~BlowUpPuzzleVCR();
void handleEvent(Common::Event *event, bool doUpdate);
@@ -154,9 +154,9 @@ private:
void updateCursorInPolyRegion();
- GraphicQueueItem getGraphicJackItem(ResourceId resourceId);
+ GraphicQueueItem getGraphicJackItem(int32 index);
GraphicQueueItem getGraphicShadowItem();
- void updateJack(Jack jack, VCRDrawInfo onTable, VCRDrawInfo pluggedOnRed, VCRDrawInfo pluggedOnYellow, VCRDrawInfo pluggedOnBlack, ResourceId resourceIdOnHand);
+ void updateJack(Jack jack, VCRDrawInfo onTable, VCRDrawInfo pluggedOnRed, VCRDrawInfo pluggedOnYellow, VCRDrawInfo pluggedOnBlack, int32 resourceOnHandIndex);
void updateBlackJack();
void updateRedJack();
void updateYellowJack();
diff --git a/engines/asylum/views/menu.cpp b/engines/asylum/views/menu.cpp
index d5a818bdb9..7b88658ced 100644
--- a/engines/asylum/views/menu.cpp
+++ b/engines/asylum/views/menu.cpp
@@ -56,11 +56,10 @@ MainMenu::MainMenu(AsylumEngine *vm): _vm(vm) {
Config.gammaLevel = 2;
Config.performance = 5;
- _resPack = new ResourcePack(kResourcePackShared);
- _bgResource = new GraphicResource(_resPack, 0);
- _eyeResource = new GraphicResource(_resPack, 1);
+ _bgResource = new GraphicResource(_vm, MAKE_RESOURCE(kResourcePackShared, 0));
+ _eyeResource = new GraphicResource(_vm, MAKE_RESOURCE(kResourcePackShared, 1));
- _cursor = new Cursor(_resPack);
+ _cursor = new Cursor(_vm);
_iconResource = 0;
_creditsResource = 0;
@@ -76,19 +75,20 @@ MainMenu::~MainMenu() {
delete _eyeResource;
delete _cursor;
delete _bgResource;
- delete _resPack;
}
void MainMenu::loadFont(Fonts font) {
switch (font) {
+ default:
+ error("[MainMenu::loadFont] Unknown font color specified!");
+
case kFontBlue:
- _vm->text()->loadFont(_resPack, 0x80010016);
+ getText()->loadFont(MAKE_RESOURCE(kResourcePackShared, 22));
break;
+
case kFontYellow:
- _vm->text()->loadFont(_resPack, 0x80010010);
+ getText()->loadFont(MAKE_RESOURCE(kResourcePackShared, 16));
break;
- default:
- error("Unknown Font Colour Specified");
}
}
@@ -106,18 +106,18 @@ void MainMenu::openMenu() {
loadFont(kFontYellow);
// Load the graphics palette
- _vm->screen()->setPalette(_resPack, 17);
+ getScreen()->setPalette(MAKE_RESOURCE(kResourcePackShared, 17));
// Copy the bright background to the back buffer
GraphicFrame *bg = _bgResource->getFrame(1);
- _vm->screen()->copyToBackBuffer((byte *)bg->surface.pixels,
- bg->surface.w,
- 0,
- 0,
- bg->surface.w,
- bg->surface.h);
+ getScreen()->copyToBackBuffer((byte *)bg->surface.pixels,
+ bg->surface.w,
+ 0,
+ 0,
+ bg->surface.w,
+ bg->surface.h);
// Set mouse cursor
- Cursor::create(_cursor, _resPack, 2);
+ Cursor::create(_vm, _cursor, MAKE_RESOURCE(kResourcePackShared, 2));
_cursor->show();
// Stop all sounds
@@ -125,7 +125,7 @@ void MainMenu::openMenu() {
_vm->sound()->stopSound();
// Start playing music
- _vm->sound()->playMusic(_resPack, 39);
+ _vm->sound()->playMusic(MAKE_RESOURCE(kResourcePackShared, 39));
_previousActiveIcon = _activeIcon = -1;
_leftClick = false;
@@ -181,11 +181,11 @@ void MainMenu::update() {
if (_activeIcon != -1) {
// Copy the dark background to the back buffer
GraphicFrame *bg = _bgResource->getFrame(0);
- _vm->screen()->copyToBackBuffer((byte *)bg->surface.pixels, bg->surface.w, 0, 0, bg->surface.w, bg->surface.h);
+ getScreen()->copyToBackBuffer((byte *)bg->surface.pixels, bg->surface.w, 0, 0, bg->surface.w, bg->surface.h);
_activeMenuScreen = (MenuScreen) _activeIcon;
// Set the cursor
- Cursor::create(_cursor, _resPack, 3);
+ Cursor::create(_vm, _cursor, MAKE_RESOURCE(kResourcePackShared, 3));
}
switch (_activeIcon) {
@@ -222,16 +222,16 @@ void MainMenu::update() {
case kShowCredits:
// TODO if game finished (gameFlag=901) then show resource image 33 and music 56 and than music 40
if (!_creditsResource)
- _creditsResource = new GraphicResource(_resPack, 24);
+ _creditsResource = new GraphicResource(_vm, MAKE_RESOURCE(kResourcePackShared, 24));
if (!_creditsFadeResource)
- _creditsFadeResource = new GraphicResource(_resPack, 23);
+ _creditsFadeResource = new GraphicResource(_vm, MAKE_RESOURCE(kResourcePackShared, 23));
_creditsTextScroll = 0x1E0 - 30;
// Set credits palette
- _vm->screen()->setPalette(_resPack, 26);
+ getScreen()->setPalette(MAKE_RESOURCE(kResourcePackShared, 26));
// Stop all sounds
- _vm->sound()->stopMusic();
+ getSound()->stopMusic();
// Start playing music
- _vm->sound()->playMusic(_resPack, 38);
+ getSound()->playMusic(MAKE_RESOURCE(kResourcePackShared, 38));
break;
case kReturnToGame:
if (_vm->scene()) { // FIXME: do this properly
@@ -308,7 +308,7 @@ void MainMenu::updateMainMenu() {
// Get the current icon animation
if (!_iconResource || _activeIcon != _previousActiveIcon) {
delete _iconResource;
- _iconResource = new GraphicResource(_resPack, iconNum + 4);
+ _iconResource = new GraphicResource(_vm, MAKE_RESOURCE(kResourcePackShared, iconNum + 4));
}
GraphicFrame *iconFrame = _iconResource->getFrame(MIN<int>(_iconResource->getFrameCount() - 1, _curIconFrame));
@@ -322,12 +322,12 @@ void MainMenu::updateMainMenu() {
// Show text
_vm->text()->drawResTextCentered(MenuIconFixedXpos[iconNum],
iconFrame->y + 50,
- _vm->text()->getResTextWidth(iconNum + 1309),
- iconNum + 1309);
+ getText()->getResTextWidth(MAKE_RESOURCE(kResourcePackText, iconNum + 1309)),
+ MAKE_RESOURCE(kResourcePackText, iconNum + 1309));
// Play creepy voice
if (_activeIcon != _previousActiveIcon) {
- _vm->sound()->playSound(_resPack, iconNum + 44, Config.sfxVolume);
+ getSound()->playSound(MAKE_RESOURCE(kResourcePackShared, iconNum + 44), Config.sfxVolume);
_previousActiveIcon = _activeIcon;
}
@@ -389,37 +389,37 @@ void MainMenu::updateSubMenuNewGame() {
loadFont(kFontYellow);
// begin new game
- _vm->text()->drawResTextCentered(10, 100, 620, 0x80000529);
+ _vm->text()->drawResTextCentered(10, 100, 620, MAKE_RESOURCE(kResourcePackText, 529));
// Yes
- switchFont(_cursor->position().x < 247 || _cursor->position().x > 247 + _vm->text()->getResTextWidth(0x8000052A) || _cursor->position().y < 273 || _cursor->position().y > 273 + 24);
+ switchFont(_cursor->position().x < 247 || _cursor->position().x > 247 + _vm->text()->getResTextWidth(MAKE_RESOURCE(kResourcePackText, 1322)) || _cursor->position().y < 273 || _cursor->position().y > 273 + 24);
_vm->text()->setTextPos(247, 273);
- _vm->text()->drawResText(0x8000052A);
+ _vm->text()->drawResText(MAKE_RESOURCE(kResourcePackText, 1322));
// No
- switchFont(_cursor->position().x < 369 || _cursor->position().x > 369 + _vm->text()->getResTextWidth(0x8000052B) || _cursor->position().y < 273 || _cursor->position().y > 273 + 24);
+ switchFont(_cursor->position().x < 369 || _cursor->position().x > 369 + _vm->text()->getResTextWidth(MAKE_RESOURCE(kResourcePackText, 1323)) || _cursor->position().y < 273 || _cursor->position().y > 273 + 24);
_vm->text()->setTextPos(369, 273);
- _vm->text()->drawResText(0x8000052B);
+ _vm->text()->drawResText(MAKE_RESOURCE(kResourcePackText, 1323));
// action
if (_leftClick) {
// Yes
- if (_cursor->position().x >= 247 && _cursor->position().x <= 247 + 24 && _cursor->position().y >= 273 && _cursor->position().y <= 273 + _vm->text()->getResTextWidth(0x8000052A)) {
+ if (_cursor->position().x >= 247 && _cursor->position().x <= 247 + 24 && _cursor->position().y >= 273 && _cursor->position().y <= 273 + _vm->text()->getResTextWidth(MAKE_RESOURCE(kResourcePackText, 1322))) {
_leftClick = false;
closeMenu();
_vm->startGame();
}
// No
- if (_cursor->position().x >= 369 && _cursor->position().x <= 369 + 24 && _cursor->position().y >= 273 && _cursor->position().y <= 273 + _vm->text()->getResTextWidth(0x8000052B))
+ if (_cursor->position().x >= 369 && _cursor->position().x <= 369 + 24 && _cursor->position().y >= 273 && _cursor->position().y <= 273 + _vm->text()->getResTextWidth(MAKE_RESOURCE(kResourcePackText, 1323)))
exitSubMenu();
}
}
void MainMenu::updateSubMenuCinematics() {
int32 currentCD = 1; // FIXME: dummy value
- _vm->text()->drawResTextWithValueCentered(10, 100, 620, 0x80000548, currentCD);
+ _vm->text()->drawResTextWithValueCentered(10, 100, 620, MAKE_RESOURCE(kResourcePackText, 1352), currentCD);
_vm->text()->setTextPos(30, 340);
- _vm->text()->drawResText(0x80000549); // Prev Page
+ _vm->text()->drawResText(MAKE_RESOURCE(kResourcePackText, 1353)); // Prev Page
if (_cursor->position().x >= 280 && _cursor->position().x <= 400 && _cursor->position().y >= 340 && _cursor->position().y <= 360) {
loadFont(kFontBlue);
@@ -430,25 +430,25 @@ void MainMenu::updateSubMenuCinematics() {
}
_vm->text()->setTextPos(280, 340);
- _vm->text()->drawResText(0x8000054B); // Main Menu
+ _vm->text()->drawResText(MAKE_RESOURCE(kResourcePackText, 1355)); // Main Menu
loadFont(kFontYellow);
_vm->text()->setTextPos(500, 340);
- _vm->text()->drawResText(0x8000054A); // Next Page
+ _vm->text()->drawResText(MAKE_RESOURCE(kResourcePackText, 1354)); // Next Page
}
void MainMenu::updateSubMenuSettings() {
int32 sizeMinus = _vm->text()->getTextWidth("-");
int32 sizePlus = _vm->text()->getTextWidth("+");
- int32 sizeMainMenu = _vm->text()->getResTextWidth(0x8000059D);
+ int32 sizeMainMenu = _vm->text()->getResTextWidth(MAKE_RESOURCE(kResourcePackText, 1437));
loadFont(kFontYellow);
// Settings
- _vm->text()->drawResTextCentered(10, 100, 620, 0x80000598);
+ _vm->text()->drawResTextCentered(10, 100, 620, MAKE_RESOURCE(kResourcePackText, 1432));
// gamma correction
- _vm->text()->drawResTextAlignRight(320, 150, 0x80000599);
+ _vm->text()->drawResTextAlignRight(320, 150, MAKE_RESOURCE(kResourcePackText, 1433));
switchFont(_cursor->position().x < 350 || _cursor->position().x > sizeMinus + 350 || _cursor->position().y < 150 || _cursor->position().y > 174);
_vm->text()->setTextPos(350, 150);
_vm->text()->drawText("-");
@@ -466,11 +466,11 @@ void MainMenu::updateSubMenuSettings() {
if (Config.gammaLevel == 8)
_vm->text()->drawText("*");
} else
- _vm->text()->drawResText(0x8000059B);
+ _vm->text()->drawResText(MAKE_RESOURCE(kResourcePackText, 1435));
// performance
loadFont(kFontYellow);
- _vm->text()->drawResTextAlignRight(320, 179, 0x8000059A);
+ _vm->text()->drawResTextAlignRight(320, 179, MAKE_RESOURCE(kResourcePackText, 1434));
switchFont(_cursor->position().x < 350 || _cursor->position().x > sizeMinus + 350 || _cursor->position().y < 179 || _cursor->position().y > 203);
_vm->text()->setTextPos(350, 179);
_vm->text()->drawText("-");
@@ -482,7 +482,7 @@ void MainMenu::updateSubMenuSettings() {
_vm->text()->setTextPos(sizeMinus + sizePlus + 365, 179);
loadFont(kFontYellow);
if (Config.performance == 5) {
- _vm->text()->drawResText(0x8000059C);
+ _vm->text()->drawResText(MAKE_RESOURCE(kResourcePackText, 1436));
} else {
for (int32 i = 5; i > Config.performance; --i) {
_vm->text()->drawText("]");
@@ -494,7 +494,7 @@ void MainMenu::updateSubMenuSettings() {
// back to main menu
switchFont(_cursor->position().x < 300 || _cursor->position().x > 300 + sizeMainMenu || _cursor->position().y < 340 || _cursor->position().y > 340 + 24);
_vm->text()->setTextPos(300, 340);
- _vm->text()->drawResText(0x8000059D);
+ _vm->text()->drawResText(MAKE_RESOURCE(kResourcePackText, 1437));
// action
if (_leftClick) {
@@ -540,22 +540,22 @@ void MainMenu::updateSubMenuQuitGame() {
loadFont(kFontYellow);
// begin new game
- _vm->text()->drawResTextCentered(10, 100, 620, 0x80000580);
+ _vm->text()->drawResTextCentered(10, 100, 620, MAKE_RESOURCE(kResourcePackText, 1408));
// Yes
- switchFont(_cursor->position().x < 247 || _cursor->position().x > 247 + _vm->text()->getResTextWidth(0x80000581) || _cursor->position().y < 273 || _cursor->position().y > 273 + 24);
+ switchFont(_cursor->position().x < 247 || _cursor->position().x > 247 + _vm->text()->getResTextWidth(MAKE_RESOURCE(kResourcePackText, 581)) || _cursor->position().y < 273 || _cursor->position().y > 273 + 24);
_vm->text()->setTextPos(247, 273);
- _vm->text()->drawResText(0x80000581);
+ _vm->text()->drawResText(MAKE_RESOURCE(kResourcePackText, 1409));
// No
- switchFont(_cursor->position().x < 369 || _cursor->position().x > 369 + _vm->text()->getResTextWidth(0x80000582) || _cursor->position().y < 273 || _cursor->position().y > 273 + 24);
+ switchFont(_cursor->position().x < 369 || _cursor->position().x > 369 + _vm->text()->getResTextWidth(MAKE_RESOURCE(kResourcePackText, 582)) || _cursor->position().y < 273 || _cursor->position().y > 273 + 24);
_vm->text()->setTextPos(369, 273);
- _vm->text()->drawResText(0x80000582);
+ _vm->text()->drawResText(MAKE_RESOURCE(kResourcePackText, 1410));
// action
if (_leftClick) {
// Yes
- if (_cursor->position().x >= 247 && _cursor->position().x <= 247 + 24 && _cursor->position().y >= 273 && _cursor->position().y <= 273 + _vm->text()->getResTextWidth(0x80000581)) {
+ if (_cursor->position().x >= 247 && _cursor->position().x <= 247 + 24 && _cursor->position().y >= 273 && _cursor->position().y <= 273 + _vm->text()->getResTextWidth(MAKE_RESOURCE(kResourcePackText, 1409))) {
_leftClick = false;
// User clicked on quit, so push a quit event
@@ -564,14 +564,14 @@ void MainMenu::updateSubMenuQuitGame() {
g_system->getEventManager()->pushEvent(event);
}
// No
- if (_cursor->position().x >= 369 && _cursor->position().x <= 369 + 24 && _cursor->position().y >= 273 && _cursor->position().y <= 273 + _vm->text()->getResTextWidth(0x80000582))
+ if (_cursor->position().x >= 369 && _cursor->position().x <= 369 + 24 && _cursor->position().y >= 273 && _cursor->position().y <= 273 + _vm->text()->getResTextWidth(MAKE_RESOURCE(kResourcePackText, 1410)))
exitSubMenu();
}
}
void MainMenu::updateSubMenuShowCredits() {
int32 posY = _creditsTextScroll;
- ResourceId resourceId = 0;
+ ResourceId resourceId = kResourceNone;
int32 step = 0;
int32 minBound = 0;
int32 maxBound = 0;
@@ -606,11 +606,11 @@ void MainMenu::updateSubMenuShowCredits() {
}
_vm->text()->setTextPos(320, step + posY);
- _vm->text()->drawResText(resourceId - 2147482201);
+ _vm->text()->drawResText((ResourceId)(resourceId - 2147482201));
posY = _creditsTextScroll;
}
step += 24;
- ++resourceId;
+ resourceId = (ResourceId)(resourceId + 1);
} while (step < 0x21F0);
_creditsTextScroll -= 2;
@@ -621,11 +621,11 @@ void MainMenu::updateSubMenuShowCredits() {
if (_leftClick) {
// Restore palette
- _vm->screen()->setPalette(_resPack, 17);
+ _vm->screen()->setPalette(MAKE_RESOURCE(kResourcePackShared, 17));
// Stop all sounds
_vm->sound()->stopMusic();
// Start playing music
- _vm->sound()->playMusic(_resPack, 39);
+ _vm->sound()->playMusic(MAKE_RESOURCE(kResourcePackShared, 39));
exitSubMenu();
}
}
@@ -639,24 +639,24 @@ void MainMenu::exitSubMenu() {
_vm->screen()->copyToBackBuffer((byte *)bg->surface.pixels, bg->surface.w, 0, 0, bg->surface.w, bg->surface.h);
// Set the cursor
- Cursor::create(_cursor, _resPack, 2);
+ Cursor::create(_vm, _cursor, MAKE_RESOURCE(kResourcePackShared, 2));
}
void MainMenu::updateSubMenuReturnToGame() {
loadFont(kFontYellow);
// no game loaded
- _vm->text()->drawResTextCentered(10, 100, 620, 0x80000712);
+ _vm->text()->drawResTextCentered(10, 100, 620, MAKE_RESOURCE(kResourcePackText, 712));
// Main menu
- switchFont(_cursor->position().x < 285 || _cursor->position().x > 285 + _vm->text()->getResTextWidth(0x80000713) || _cursor->position().y < 273 || _cursor->position().y > 273 + 24);
+ switchFont(_cursor->position().x < 285 || _cursor->position().x > 285 + _vm->text()->getResTextWidth(MAKE_RESOURCE(kResourcePackText, 713)) || _cursor->position().y < 273 || _cursor->position().y > 273 + 24);
_vm->text()->setTextPos(285, 273);
- _vm->text()->drawResText(0x80000713);
+ _vm->text()->drawResText(MAKE_RESOURCE(kResourcePackText, 713));
// action
if (_leftClick) {
// Main menu
- if (_cursor->position().x >= 285 && _cursor->position().x <= 285 + _vm->text()->getResTextWidth(0x80000713) && _cursor->position().y >= 273 && _cursor->position().y <= 273 + 24)
+ if (_cursor->position().x >= 285 && _cursor->position().x <= 285 + _vm->text()->getResTextWidth(MAKE_RESOURCE(kResourcePackText, 713)) && _cursor->position().y >= 273 && _cursor->position().y <= 273 + 24)
exitSubMenu();
}
}
diff --git a/engines/asylum/views/scene.cpp b/engines/asylum/views/scene.cpp
index c19f72ae03..ff258eb794 100644
--- a/engines/asylum/views/scene.cpp
+++ b/engines/asylum/views/scene.cpp
@@ -91,19 +91,18 @@ Scene::Scene(ResourcePackId packId, AsylumEngine *engine): _vm(engine) {
fd->close();
delete fd;
- _speech = new Speech(this);
- _resPack = new ResourcePack(_packId);
+ _speech = new Speech(_vm);
// TODO
// This will have to be re-initialized elsewhere due to
// the title screen overwriting the font
- _vm->text()->loadFont(_resPack, _ws->font1);
+ _vm->text()->loadFont(_ws->font1);
- char musPackFileName[10];
- sprintf(musPackFileName, MUSIC_FILE_MASK, packId);
- _musPack = new ResourcePack(musPackFileName);
+ //char musPackFileName[10];
+ //sprintf(musPackFileName, MUSIC_FILE_MASK, packId);
+ ////_musPack = new ResourcePack(musPackFileName);
- _bgResource = new GraphicResource(_resPack, _ws->backgroundImage);
+ _bgResource = new GraphicResource(_vm, _ws->backgroundImage);
//_blowUp = 0;
_cursor = 0;
_background = 0;
@@ -150,7 +149,7 @@ void Scene::initialize() {
}
}
- Cursor::create(_cursor, _resPack, _ws->curMagnifyingGlass);
+ Cursor::create(_vm, _cursor, _ws->curMagnifyingGlass);
_ws->sceneRectIdx = 0;
_vm->screen()->clearScreen(); // XXX was clearGraphicsInQueue()
@@ -190,10 +189,10 @@ void Scene::initialize() {
_vm->screen()->clearScreen();
// TODO loadTransTables(3, field_64/68/7C)
// TODO setTransTable(1)
- _vm->text()->loadFont(_resPack, _ws->font1);
+ _vm->text()->loadFont(_ws->font1);
// TODO preloadGraphics() .text:00410F10
// TODO sound_sub(sceneNumber) .text:0040E750
- _ws->actorType = actorType[_ws->numChapter];
+ _ws->actorType = actorType[_ws->chapter];
startMusic();
@@ -206,23 +205,18 @@ void Scene::initialize() {
// so I'm not sure why we need to do it again. Investigate.
actor->updateDirection();
- if (_ws->numChapter == 9) {
+ if (_ws->chapter == kChapter9) {
// TODO changeActorIndex(1); .text:00405140
_ws->field_E860C = -1;
}
}
-GraphicResource* Scene::getGraphicResource(int32 entry) {
- return new GraphicResource(_resPack, entry);
-}
-
void Scene::startMusic() {
- // TODO musicCacheOk check as part of if
- int musicId = 0;
- if (_ws->musicCurrentResourceId != -666 && _ws->numChapter != 1)
- musicId = _ws->musicResourceId - 0x7FFE0000;
- _vm->sound()->playMusic(_musPack, musicId);
+ ResourceId musicId = kResourceNone;
+ if (_ws->musicCurrentResourceIndex != kResourceMusicStopped && _ws->chapter != kChapter1 && getSound()->isCacheOk())
+ musicId = MAKE_RESOURCE(kResourcePackMusic, _ws->musicCurrentResourceIndex);
+ getSound()->playMusic(musicId);
}
Scene::~Scene() {
@@ -232,8 +226,6 @@ Scene::~Scene() {
delete _cursor;
delete _bgResource;
- delete _musPack;
- delete _resPack;
//delete _blowUp;
delete _title;
@@ -254,7 +246,7 @@ void Scene::enterScene() {
// disable input polling
//_actions->_allowInput = false;
} else {
- _vm->screen()->setPalette(_resPack, _ws->currentPaletteId);
+ _vm->screen()->setPalette(_ws->currentPaletteId);
_background = _bgResource->getFrame(0);
_vm->screen()->copyToBackBuffer(
((byte *)_background->surface.pixels) + _ws->yTop * _background->surface.w + _ws->xLeft, _background->surface.w,
@@ -265,7 +257,7 @@ void Scene::enterScene() {
// when the scene is started. Check against the original to see
// when the cursor is initialized, and then how it reacts to the
// show_cursor opcode
- Cursor::create(_cursor, _resPack, _ws->curMagnifyingGlass);
+ Cursor::create(_vm, _cursor, _ws->curMagnifyingGlass);
_cursor->show();
startMusic();
@@ -319,7 +311,7 @@ void Scene::handleEvent(Common::Event *event, bool doUpdate) {
// TODO This isn't always going to be the magnifying glass
// Should check the current pointer region to identify the type
// of cursor to use
- Cursor::create(_cursor, _resPack, _ws->curMagnifyingGlass);
+ Cursor::create(_vm, _cursor, _ws->curMagnifyingGlass);
_rightButton = false;
//}
break;
@@ -369,8 +361,8 @@ void Scene::update() {
if (_vm->sound()->isPlaying(_speech->_soundResourceId)) {
_speech->prepareSpeech();
} else {
- _speech->_textResourceId = 0;
- _speech->_soundResourceId = 0;
+ _speech->_textResourceId = kResourceNone;
+ _speech->_soundResourceId = kResourceNone;
_vm->clearGameFlag(kGameFlag219);
}
}
@@ -573,7 +565,7 @@ void Scene::handleMouseUpdate(int direction, Common::Rect rect) {
if (_cursor->field_11 & 2) {
if (act->getStatus() == 1 || act->getStatus() == 12) {
if (direction >= 0) {
- newGraphicResourceId = _ws->curScrollUp + direction;
+ newGraphicResourceId = (ResourceId)(_ws->curScrollUp + direction);
_cursor->set(newGraphicResourceId, 0, 2);
}
}
@@ -622,7 +614,7 @@ void Scene::handleMouseUpdate(int direction, Common::Rect rect) {
}
}
if (targetIdx == -1) {
- if (_ws->numChapter != 2 || _playerActorIdx != 10) {
+ if (_ws->chapter != kChapter2 || _playerActorIdx != 10) {
if (_cursor->flags)
_cursor->set(_ws->curMagnifyingGlass, 0, 2);
} else {
@@ -658,7 +650,7 @@ void Scene::handleMouseUpdate(int direction, Common::Rect rect) {
if (targetUpdateType & 0x10 && _cursor->flags != 2) {
_cursor->set(_ws->curTalkNPC2, 0, 2);
} else {
- if (_ws->numChapter != 2 && _playerActorIdx != 10) {
+ if (_ws->chapter != kChapter2 && _playerActorIdx != 10) {
_cursor->set(_ws->curMagnifyingGlass, 0, 0);
} else {
if (_cursor->flags)
@@ -732,12 +724,12 @@ int32 Scene::findActionArea(const Common::Point pt) {
return targetIdx;
}
-int32 Scene::hitTestScene(const Common::Point pt, HitType &type) {
+ResourceId Scene::hitTestScene(const Common::Point pt, HitType &type) {
int32 top = pt.x + _ws->xLeft;
int32 left = pt.y + _ws->yTop;
type = kHitNone;
- int32 result = findActionArea(Common::Point(top, left));
+ ResourceId result = (ResourceId)findActionArea(Common::Point(top, left));
if (result != -1) {
if (LOBYTE(_ws->actions[result]->actionType) & 8) {
@@ -770,7 +762,7 @@ bool Scene::hitTestActor(const Common::Point pt) {
}
bool Scene::hitTestPixel(ResourceId resourceId, int32 frame, int16 x, int16 y, bool flipped) {
- GraphicResource *gra = new GraphicResource(_resPack, resourceId);
+ GraphicResource *gra = new GraphicResource(_vm, resourceId);
GraphicFrame *fra = gra->getFrame(frame);
// TODO this gets a bit funky with the "flipped" calculations for x intersection
@@ -857,7 +849,7 @@ void Scene::updateAmbientSounds() {
int tmpVol = volume;
if (vm()->getRandom(10000) < 10) {
if (snd->field_0) {
- _vm->sound()->playSound(snd->resourceId, false, volume, panning, false);
+ _vm->sound()->playSound(snd->resourceId, false, volume, panning);
} else {
// FIXME will this even work?
tmpVol += (vm()->getRandom(500)) * (((vm()->getRandom(100) >= 50) - 1) & 2) - 1;
@@ -868,7 +860,7 @@ void Scene::updateAmbientSounds() {
else
if (tmpVol <= -10000)
tmpVol = -10000;
- _vm->sound()->playSound(snd->resourceId, 0, tmpVol, vm()->getRandom(20001) - 10000);
+ getSound()->playSound(snd->resourceId, 0, tmpVol, vm()->getRandom(20001) - 10000);
}
}
} else {
@@ -1073,7 +1065,7 @@ int Scene::drawScene() {
buildUpdateList();
processUpdateList();
- if (_ws->numChapter == 11)
+ if (_ws->chapter == kChapter11)
checkVisibleActorsPriority();
// Queue updates
@@ -1144,7 +1136,7 @@ void Scene::processUpdateList() {
int32 bottomRight = actor->getBoundingRect()->bottom + actor->y1 + 4;
- if (_ws->numChapter == 11 && _updateList[i].index != getPlayerActorIndex())
+ if (_ws->chapter == kChapter11 && _updateList[i].index != getPlayerActorIndex())
bottomRight += 20;
// Our actor rect
diff --git a/engines/asylum/views/scene.h b/engines/asylum/views/scene.h
index fe2a0ddd04..9517a680af 100644
--- a/engines/asylum/views/scene.h
+++ b/engines/asylum/views/scene.h
@@ -86,9 +86,6 @@ public:
bool isActive() { return _isActive; }
ResourcePackId getPackId() { return _packId; }
- ResourcePack* getResourcePack() { return _resPack; }
- ResourcePack* getMusicPack() { return _musPack; }
- GraphicResource* getGraphicResource(int32 entry);
//BlowUpPuzzle* getBlowUpPuzzle() { return _blowUp;}
//void setBlowUpPuzzle(BlowUpPuzzle* puzzle) { _blowUp = puzzle; }
void setScenePosition(int x, int y);
@@ -205,7 +202,7 @@ protected:
* Checks if the supplied coordinates are inside an action area, object or
* actor, and returns -1 if nothing was found, or the type of hit if found
*/
- int32 hitTestScene(const Common::Point pt, HitType &type);
+ ResourceId hitTestScene(const Common::Point pt, HitType &type);
/** .text:0040EAA0
* Check if a object exist at the supplied coordinates.
@@ -234,8 +231,6 @@ private:
SceneTitle *_title;
Speech *_speech;
Cursor *_cursor;
- ResourcePack *_resPack;
- ResourcePack *_musPack;
Special *_special;
//BlowUpPuzzle *_blowUp;
diff --git a/engines/asylum/views/scenetitle.cpp b/engines/asylum/views/scenetitle.cpp
index d7bed596c0..4b0de8bee8 100644
--- a/engines/asylum/views/scenetitle.cpp
+++ b/engines/asylum/views/scenetitle.cpp
@@ -52,17 +52,14 @@ SceneTitle::~SceneTitle() {
void SceneTitle::load() {
_start = _vm->getTick();
- _bg = new GraphicResource(getScene()->getResourcePack(), getWorld()->sceneTitleGraphicResourceId);
- getScreen()->setPalette(getScene()->getResourcePack(), getWorld()->sceneTitlePaletteResourceId);
+ _bg = new GraphicResource(_vm, getWorld()->sceneTitleGraphicResourceId);
+ getScreen()->setPalette(getWorld()->sceneTitlePaletteResourceId);
- ResourcePack *pack = new ResourcePack(kResourcePackSound);
- _progress = new GraphicResource(pack, 0x80120011);
+ _progress = new GraphicResource(_vm, MAKE_RESOURCE(kResourcePackSound, 17));
_spinnerProgress = 0;
_spinnerFrame = 0;
- getText()->loadFont(pack, 0x80120012);
-
- delete pack;
+ getText()->loadFont(MAKE_RESOURCE(kResourcePackSound, 18));
_done = false;
_showMouseState = g_system->showMouse(false);
@@ -85,7 +82,7 @@ void SceneTitle::update(int32 tick) {
bgFrame->surface.w,
0, 0, 640, 480);
- ResourceId resourceId = getScene()->getPackId() - 4 + 1811;
+ ResourceId resourceId = MAKE_RESOURCE(getScene()->getPackId(), 1797);
int32 resWidth = getText()->getResTextWidth(resourceId);
getText()->drawResTextCentered(320 - resWidth * 24, 30, resWidth, resourceId);
Commit: 2532fcd021a52118e69414b9c5aee376297f945e
https://github.com/scummvm/scummvm/commit/2532fcd021a52118e69414b9c5aee376297f945e
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:14+02:00
Commit Message:
ASYLUM: Refactor game start and scene loading
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@514 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/asylum.cpp
engines/asylum/asylum.h
engines/asylum/resources/actionlist.cpp
engines/asylum/resources/encounters.cpp
engines/asylum/resources/encounters.h
engines/asylum/resources/worldstats.cpp
engines/asylum/resources/worldstats.h
engines/asylum/shared.h
engines/asylum/system/cursor.cpp
engines/asylum/system/cursor.h
engines/asylum/views/blowuppuzzle.cpp
engines/asylum/views/menu.cpp
engines/asylum/views/scene.cpp
engines/asylum/views/scene.h
diff --git a/engines/asylum/asylum.cpp b/engines/asylum/asylum.cpp
index b5e9214dfd..8fe086f5ee 100644
--- a/engines/asylum/asylum.cpp
+++ b/engines/asylum/asylum.cpp
@@ -29,6 +29,7 @@
#include "asylum/resources/encounters.h"
#include "asylum/system/config.h"
+#include "asylum/system/cursor.h"
#include "asylum/system/screen.h"
#include "asylum/system/sound.h"
#include "asylum/system/text.h"
@@ -53,6 +54,9 @@ AsylumEngine::AsylumEngine(OSystem *system, const ADGameDescription *gd) : Engin
_console(NULL), _encounter(NULL), _resource(NULL), _mainMenu(NULL), _scene(NULL), _screen(NULL),
_sound(NULL), _text(NULL), _video(NULL) {
+ // Reset flags
+ memset(_gameFlags, 0, 1512);
+
// Add default search directories
const Common::FSNode gameDataDir(ConfMan.get("path"));
SearchMan.addSubDirectoryMatching(gameDataDir, "data");
@@ -97,39 +101,35 @@ Common::Error AsylumEngine::run() {
// Create debugger. It requires GFX to be initialized
_console = new Console(this);
- // Create all manager classes
+ // Create resource manager
_resource = new ResourceManager();
+
+ // Create all game classes
+ _encounter = new Encounter(this);
+ _cursor = new Cursor(this);
_screen = new Screen(this);
_sound = new Sound(this, _mixer);
- _video = new Video(this, _mixer);
_text = new Text(this);
- _scene = NULL;
- _encounter = NULL;
-
- _introPlaying = false;
+ _video = new Video(this, _mixer);
- memset(_gameFlags, 0, 1512);
+ // Create main menu
+ _mainMenu = new MainMenu(this);
- // Start the game
- g_system->showMouse(true);
+ // FIXME: remove
+ _introPlaying = false;
// TODO: save dialogue key codes into sntrm_k.txt (need to figure out why they use such thing) (address 00411CD0)
// load startup configurations (.text:0041A970)
Config.read();
// TODO: init unknown game stuffs (.text:0040F430)
- if (Config.showIntro)
- _video->playVideo(0, Config.showMovieSubtitles);
-
- // Set up main menu
- _mainMenu = new MainMenu(this);
-
// TODO: if savegame not exists on folder, than start game()
//if(0) { //SearchMan.hasArchive
- startGame();
+ startGame(kResourcePackTowerCells, kStartGamePlayIntro);
//} else {
// _mainMenu->openMenu();
//}
+ //
while (!shouldQuit()) {
handleEvents(true);
@@ -151,33 +151,39 @@ void AsylumEngine::waitForTimer(int msec_delay) {
}
}
-void AsylumEngine::startGame() {
- // TODO: reset what need to be reset for a new game
- if (_scene)
- delete _scene;
+void AsylumEngine::startGame(ResourcePackId sceneId, StartGameType type) {
+ // Load the default mouse cursor
+ _cursor->set(MAKE_RESOURCE(kResourcePackSound, 14));
+ _cursor->hide();
- _scene = new Scene(kResourcePackTowerCells, this);
+ // Clear the graphic list
+ _screen->clearGraphicsInQueue();
+
+ // Reset scene
+ delete _scene;
+ _scene = new Scene(this);
+
+ switch (type) {
+ default:
+ error("[AsylumEngine::startGame] Invalid start game type!");
+
+ case kStartGamePlayIntro:
+ _scene->enter(sceneId);
- if (Config.showIntro)
playIntro();
- _scene->initialize();
+ _cursor->show();
+ break;
- // FIXME This is just here for testing purposes. It is also defined
- // in the processActionList() method when the necessary action is fired.
- // Once the blowup puzzle testing is removed from checkForEvent(), this
- // can be removed as well.
- //_scene->setBlowUpPuzzle(new BlowUpPuzzleVCR(_scene));
+ case kStartGameLoad:
+ error("[AsylumEngine::startGame] kStartGameLoad not implemented!");
+ break;
- // XXX Testing
- _encounter = new Encounter(_scene);
+ case kStartGameScene:
+ _scene->enter(sceneId);
- // Enter first scene
- if(!_introPlaying)
- {
- setGameFlag(kGameFlag4);
- setGameFlag(kGameFlag12);
- _scene->enterScene();
+ _cursor->show();
+ break;
}
}
@@ -185,8 +191,8 @@ void AsylumEngine::playIntro() {
_introPlaying = true;
g_system->showMouse(false);
- _video->playVideo(1, Config.showMovieSubtitles);
-
+ if (Config.showIntro)
+ _video->playVideo(1, Config.showMovieSubtitles);
/*if (_scene->worldstats()->musicCurrentResourceId != kResourceMusic_FFFFFD66)
_sound->playMusic(_scene->getResourcePack(), _scene->worldstats()->musicCurrentResourceId);*/
@@ -229,7 +235,7 @@ void AsylumEngine::handleEvents(bool doUpdate) { // k_sub_40AE30 (0040AE30)
// the scene's soundResourceId[] array (seems that's the way the original worked,
// especially when you examine isSoundinList() or isSoundPlaying())
- _scene->enterScene();
+ //_scene->enterScene();
}
}
@@ -249,7 +255,7 @@ void AsylumEngine::handleEvents(bool doUpdate) { // k_sub_40AE30 (0040AE30)
if (_mainMenu->isActive()) {
if (_scene) {
_mainMenu->closeMenu();
- _scene->enterScene();
+ // FIXME _scene->enterScene();
}
} else if (_scene && _scene->isActive()) {
_mainMenu->openMenu();
@@ -307,8 +313,8 @@ void AsylumEngine::processDelayedEvents() {
if (_mainMenu->isActive())
_mainMenu->openMenu();
- else if (_scene->isActive())
- _scene->enterScene();
+ // FIXME else if (_scene->isActive())
+ // FIXME _scene->enterScene();
}
// check for a delayed scene change
@@ -326,9 +332,8 @@ void AsylumEngine::processDelayedEvents() {
if (_scene)
delete _scene;
- _scene = new Scene(packId, this);
- _scene->initialize();
- _scene->enterScene();
+ _scene = new Scene(this);
+ _scene->enter(packId);
}
}
diff --git a/engines/asylum/asylum.h b/engines/asylum/asylum.h
index 3bbfdf015d..d505b4c21b 100644
--- a/engines/asylum/asylum.h
+++ b/engines/asylum/asylum.h
@@ -70,6 +70,7 @@ enum FlagType {
kFlagTypeSceneRectChanged
};
+class Cursor;
class Encounter;
class MainMenu;
class ResourceManager;
@@ -88,6 +89,12 @@ protected:
virtual GUI::Debugger *getDebugger() { return _console; }
public:
+ enum StartGameType {
+ kStartGamePlayIntro,
+ kStartGameLoad,
+ kStartGameScene
+ };
+
typedef Common::Functor1<Common::Event &, void> MessageHandler;
AsylumEngine(OSystem *system, const ADGameDescription *gd);
@@ -96,7 +103,14 @@ public:
/**
* Start a new the game
*/
- void startGame();
+ void startGame(ResourcePackId sceneId, StartGameType type);
+
+ /**
+ * Switch to a new scene
+ *
+ * @param sceneId ResourcePack for the scene
+ */
+ void switchScene(ResourcePackId sceneId) { startGame(sceneId, kStartGameScene); }
/**
* Wrapper function to the OSystem getMillis() method
@@ -110,6 +124,7 @@ public:
uint32 globalTickValue_2;
// Game
+ Cursor *cursor() { return _cursor; }
Encounter *encounter() { return _encounter; }
MainMenu *menu() { return _mainMenu; }
ResourceManager *resource() { return _resource; }
@@ -146,6 +161,7 @@ private:
Common::RandomSource _rnd;
// Game
+ Cursor *_cursor;
Encounter *_encounter;
MainMenu *_mainMenu;
ResourceManager *_resource;
@@ -156,7 +172,7 @@ private:
Video *_video;
bool _introPlaying;
- int _gameFlags[1512];
+ int _gameFlags[1512];
bool _flags[4];
void handleEvents(bool doUpdate);
diff --git a/engines/asylum/resources/actionlist.cpp b/engines/asylum/resources/actionlist.cpp
index 709a63ec11..7d10eeb22f 100644
--- a/engines/asylum/resources/actionlist.cpp
+++ b/engines/asylum/resources/actionlist.cpp
@@ -1401,7 +1401,7 @@ IMPLEMENT_OPCODE(JumpIfSoundPlaying) {
//////////////////////////////////////////////////////////////////////////
// Opcode 0x4B
IMPLEMENT_OPCODE(ChangePlayerActorIndex) {
- getScene()->changePlayerActorIndex(cmd->param1);
+ getScene()->changePlayer(cmd->param1);
}
//////////////////////////////////////////////////////////////////////////
diff --git a/engines/asylum/resources/encounters.cpp b/engines/asylum/resources/encounters.cpp
index 3070e57834..b7386285b6 100644
--- a/engines/asylum/resources/encounters.cpp
+++ b/engines/asylum/resources/encounters.cpp
@@ -25,11 +25,13 @@
#include "asylum/resources/encounters.h"
+#include "asylum/asylum.h"
+
#include "common/file.h"
namespace Asylum {
-Encounter::Encounter(Scene *scene) {
+Encounter::Encounter(AsylumEngine *engine) : _vm(engine) {
memset(_flags, 0, sizeof(_flags));
Common::File file;
@@ -65,8 +67,6 @@ Encounter::Encounter(Scene *scene) {
}
file.close();
-
- _scene = scene;
}
//////////////////////////////////////////////////////////////////////////
diff --git a/engines/asylum/resources/encounters.h b/engines/asylum/resources/encounters.h
index 1141ed3ecb..64e4c7ee83 100644
--- a/engines/asylum/resources/encounters.h
+++ b/engines/asylum/resources/encounters.h
@@ -32,7 +32,7 @@
namespace Asylum {
-class Scene;
+class AsylumEngine;
enum EncounterFlag{
kEncounterFlag2 = 2,
@@ -60,7 +60,7 @@ typedef struct EncounterStruct {
class Encounter {
public:
- Encounter(Scene *scene);
+ Encounter(AsylumEngine *engine);
virtual ~Encounter();
void setVariable(int32 idx, int32 value) {
@@ -72,12 +72,13 @@ public:
void setFlag(EncounterFlag flag, int32 val);
private:
+ AsylumEngine *_vm;
+
int16 *_variables;
int16 _anvilStyleFlag;
EncounterItem *_currentEncounter;
Common::Array<EncounterItem> _items;
- Scene *_scene;
int32 _flags[5];
diff --git a/engines/asylum/resources/worldstats.cpp b/engines/asylum/resources/worldstats.cpp
index c114eb16dc..107a015922 100644
--- a/engines/asylum/resources/worldstats.cpp
+++ b/engines/asylum/resources/worldstats.cpp
@@ -136,7 +136,7 @@ void WorldStats::load(Common::SeekableReadStream *stream) {
field_11D[1] = stream->readByte();
field_11D[2] = stream->readByte();
field_120 = stream->readSint32LE();
- actionListIdx = stream->readSint32LE();
+ scriptIndex = stream->readSint32LE();
for (int32 gr = 0; gr < 100; gr++)
graphicResourceIds[gr] = (ResourceId)stream->readSint32LE();
diff --git a/engines/asylum/resources/worldstats.h b/engines/asylum/resources/worldstats.h
index 4857830de4..02701a74fb 100644
--- a/engines/asylum/resources/worldstats.h
+++ b/engines/asylum/resources/worldstats.h
@@ -96,7 +96,7 @@ public:
uint8 sceneRectIdx;
uint8 field_11D[3];
int32 field_120;
- int32 actionListIdx; // actionList start index
+ int32 scriptIndex; // actionList start index
ResourceId graphicResourceIds[100];
ResourceId sceneTitleGraphicResourceId;
ResourceId sceneTitlePaletteResourceId;
diff --git a/engines/asylum/shared.h b/engines/asylum/shared.h
index 27c7054f90..c63ebe9fe1 100644
--- a/engines/asylum/shared.h
+++ b/engines/asylum/shared.h
@@ -361,7 +361,7 @@ enum ObjectFlag {
// Engine subclasses
#define getEncounter() _vm->encounter()
-#define getCursor() _vm->scene()->cursor()
+#define getCursor() _vm->cursor()
#define getResource() _vm->resource()
#define getSound() _vm->sound()
#define getScene() _vm->scene()
diff --git a/engines/asylum/system/cursor.cpp b/engines/asylum/system/cursor.cpp
index 5f03ad04c3..cb6abef7bc 100644
--- a/engines/asylum/system/cursor.cpp
+++ b/engines/asylum/system/cursor.cpp
@@ -56,23 +56,6 @@ void Cursor::load(int32 index) {
}
*/
-void Cursor::create(AsylumEngine *engine, Cursor *&cursor, ResourceId id) {
- // If the current cursor resource is already assigned
- // to the id value we're sending, just return
- // TODO this simplifies a lot of additional validation calls
- // in Scene::handleMouseUpdate, but there may be a scenario
- // where we WANT to reset the curor to the id supplied, even
- // if it's the same as what's assigned ... investigate
- if (cursor) {
- if (cursor->graphicResourceId != id)
- delete cursor;
- else
- return;
- }
- cursor = new Cursor(engine);
- cursor->set(id, 0, 0);
-}
-
void Cursor::hide() {
CursorMan.showMouse(false);
}
diff --git a/engines/asylum/system/cursor.h b/engines/asylum/system/cursor.h
index 3431694248..ce981ccfca 100644
--- a/engines/asylum/system/cursor.h
+++ b/engines/asylum/system/cursor.h
@@ -44,12 +44,6 @@ public:
Cursor(AsylumEngine *engine);
virtual ~Cursor();
- /**
- * Generate a new cursor instance from the resource id
- * within the resource pack provided.
- */
- static void create(AsylumEngine *engine, Cursor *&cursor, ResourceId id);
-
/**
* Show the current cursor
*/
@@ -60,13 +54,14 @@ public:
*/
void hide();
- /** .text:00435400
+ /**
* Set the current cursor instance to the graphic resource provide.
* The frames parameter defaults to -1, which in this case means that the
* frame count should be derived from the graphic resource as opposed to being
- * explicitely set.
+ * explicitly set.
*/
- void set(ResourceId resourceId, int32 cntr, int32 flgs, int32 frames = -1);
+ void set(ResourceId resourceId, int32 cntr = 0, int32 flgs = 0, int32 frames = -1);
+
/**
* Set the x/y coordinates of the cursor
*/
diff --git a/engines/asylum/views/blowuppuzzle.cpp b/engines/asylum/views/blowuppuzzle.cpp
index 78bbdc8cb0..a05437c095 100644
--- a/engines/asylum/views/blowuppuzzle.cpp
+++ b/engines/asylum/views/blowuppuzzle.cpp
@@ -140,7 +140,7 @@ void BlowUpPuzzleVCR::update() {
_rightClickDown = false;
closeBlowUp();
getSound()->stopSound();
- getScene()->enterScene();
+ // FIXME getScene()->enterScene();
}
if (_leftClickDown) {
@@ -185,7 +185,7 @@ void BlowUpPuzzleVCR::update() {
_isAccomplished = false;
_active = false;
- getScene()->enterScene();
+ // FIXME getScene()->enterScene();
} else {
getScreen()->drawGraphicsInQueue();
}
diff --git a/engines/asylum/views/menu.cpp b/engines/asylum/views/menu.cpp
index 7b88658ced..301bef58cd 100644
--- a/engines/asylum/views/menu.cpp
+++ b/engines/asylum/views/menu.cpp
@@ -117,7 +117,7 @@ void MainMenu::openMenu() {
bg->surface.h);
// Set mouse cursor
- Cursor::create(_vm, _cursor, MAKE_RESOURCE(kResourcePackShared, 2));
+ _cursor->set(MAKE_RESOURCE(kResourcePackShared, 2));
_cursor->show();
// Stop all sounds
@@ -185,7 +185,7 @@ void MainMenu::update() {
_activeMenuScreen = (MenuScreen) _activeIcon;
// Set the cursor
- Cursor::create(_vm, _cursor, MAKE_RESOURCE(kResourcePackShared, 3));
+ _cursor->set(MAKE_RESOURCE(kResourcePackShared, 3));
}
switch (_activeIcon) {
@@ -236,7 +236,7 @@ void MainMenu::update() {
case kReturnToGame:
if (_vm->scene()) { // FIXME: do this properly
closeMenu();
- _vm->scene()->enterScene();
+ // FIXME _vm->scene()->enterScene();
}
break;
}
@@ -407,7 +407,7 @@ void MainMenu::updateSubMenuNewGame() {
if (_cursor->position().x >= 247 && _cursor->position().x <= 247 + 24 && _cursor->position().y >= 273 && _cursor->position().y <= 273 + _vm->text()->getResTextWidth(MAKE_RESOURCE(kResourcePackText, 1322))) {
_leftClick = false;
closeMenu();
- _vm->startGame();
+ _vm->startGame(kResourcePackTowerCells, AsylumEngine::kStartGamePlayIntro);
}
// No
if (_cursor->position().x >= 369 && _cursor->position().x <= 369 + 24 && _cursor->position().y >= 273 && _cursor->position().y <= 273 + _vm->text()->getResTextWidth(MAKE_RESOURCE(kResourcePackText, 1323)))
@@ -639,7 +639,7 @@ void MainMenu::exitSubMenu() {
_vm->screen()->copyToBackBuffer((byte *)bg->surface.pixels, bg->surface.w, 0, 0, bg->surface.w, bg->surface.h);
// Set the cursor
- Cursor::create(_vm, _cursor, MAKE_RESOURCE(kResourcePackShared, 2));
+ _cursor->set(MAKE_RESOURCE(kResourcePackShared, 2));
}
void MainMenu::updateSubMenuReturnToGame() {
diff --git a/engines/asylum/views/scene.cpp b/engines/asylum/views/scene.cpp
index ff258eb794..ac2e85e3c6 100644
--- a/engines/asylum/views/scene.cpp
+++ b/engines/asylum/views/scene.cpp
@@ -57,7 +57,142 @@ int g_debugPolygons;
int g_debugObjects;
int g_debugScrolling;
-Scene::Scene(ResourcePackId packId, AsylumEngine *engine): _vm(engine) {
+Scene::Scene(AsylumEngine *engine): _vm(engine) {
+ // TODO Initialize data
+}
+
+Scene::~Scene() {
+ delete _ws;
+ delete _polygons;
+ delete _actions;
+
+ delete _bgResource;
+ //delete _blowUp;
+
+ delete _title;
+}
+
+void Scene::enter(ResourcePackId packId) {
+ _vm->setGameFlag(kGameFlagScriptProcessing);
+
+ getCursor()->hide();
+
+ _playerActorIdx = 0;
+
+ // Load the scene data
+ load(packId);
+
+ // Set wheel indices
+ setWheelObjectIndices();
+
+ // Adjust object priority
+ if (_ws->objects.size() > 0) {
+ int32 priority = 4091;
+
+ for (uint32 i = 0; i < _ws->objects.size(); i++) {
+ Object *object = _ws->objects[i];
+ object->setPriority(priority);
+ object->flags &= ~kObjectFlagC000;
+ priority -= 4;
+ }
+ }
+
+ // Set the cursor to magnifying glass
+ getCursor()->set(_ws->curMagnifyingGlass);
+ getCursor()->show();
+
+ // Clear the graphic queue
+ getScreen()->clearGraphicsInQueue();
+
+ _ws->sceneRectIdx = 0;
+ _ws->motionStatus = 1;
+
+ // Update current player bounding rectangle
+ Actor *player = getActor();
+ Common::Rect *boundingRect = player->getBoundingRect();
+ boundingRect->bottom = player->y2;
+ boundingRect->right = player->x2 * 2;
+
+ // Adjust scene bounding rect
+ _ws->boundingRect = Common::Rect(195, 115, 445 - boundingRect->right, 345 - boundingRect->bottom);
+
+ // Hide actor
+ player->hide();
+ player->updateStatus(kActorStatusEnabled);
+
+ // Update current player coordinates
+ player->x1 -= player->x2;
+ player->y1 -= player->y2;
+
+ // Update all other actors
+ if (_ws->actors.size() > 1) {
+ for (uint32 i = 1; i < _ws->actors.size(); i++) {
+ Actor *actor = _ws->actors[i];
+
+ actor->hide();
+ actor->setDirection(1);
+ actor->updateStatus(kActorStatusEnabled);
+
+ actor->x1 -= actor->x2;
+ actor->y1 -= actor->y2;
+
+ actor->getBoundingRect()->bottom = actor->y2;
+ actor->getBoundingRect()->right = 2 * actor->x2;
+ }
+ }
+
+ // Queue scene script
+ if (_ws->scriptIndex)
+ _actions->queueScript(_ws->scriptIndex, 0);
+
+ // Clear the graphic queue (FIXME: not sure why we need to do this again)
+ getScreen()->clearGraphicsInQueue();
+
+ // Load trans tables
+ // TODO loadTransTables(3, field_64/68/7C)
+ // TODO setTransTable(1)
+ warning("[Scene::enter] missing transtable init!");
+
+ // Setup font
+ getText()->loadFont(_ws->font1);
+
+ // Play scene intro dialog
+ playIntroSpeech();
+
+ // Set actor type
+ _ws->actorType = actorType[_ws->chapter];
+
+ // Play intro music
+ ResourceId musicId = kResourceNone;
+ if (_ws->musicCurrentResourceIndex != kResourceMusicStopped && _ws->chapter != kChapter1 && getSound()->isCacheOk())
+ musicId = MAKE_RESOURCE(kResourcePackMusic, _ws->musicCurrentResourceIndex);
+
+ getSound()->playMusic(musicId);
+
+ // Update global values
+ _vm->globalTickValue_2 = 1;
+ _vm->screenUpdatesCount = 1;
+
+ player->setLastScreenUpdate(_vm->getTick());
+ player->updateStatus(kActorStatusEnabled);
+
+ if (_ws->chapter == kChapter9) {
+ changePlayer(1);
+ _ws->field_E860C = -1;
+ }
+
+
+ //////////////////////////////////////////////////////////////////////////
+ // FIXME: get rid of this
+ _isActive = true;
+ getScreen()->setPalette(_ws->currentPaletteId);
+ _background = _bgResource->getFrame(0);
+ _vm->screen()->copyToBackBuffer(
+ ((byte *)_background->surface.pixels) + _ws->yTop * _background->surface.w + _ws->xLeft, _background->surface.w,
+ 0, 0, 640, 480);
+}
+
+void Scene::load(ResourcePackId packId) {
_packId = packId;
char filename[10];
@@ -98,13 +233,8 @@ Scene::Scene(ResourcePackId packId, AsylumEngine *engine): _vm(engine) {
// the title screen overwriting the font
_vm->text()->loadFont(_ws->font1);
- //char musPackFileName[10];
- //sprintf(musPackFileName, MUSIC_FILE_MASK, packId);
- ////_musPack = new ResourcePack(musPackFileName);
-
_bgResource = new GraphicResource(_vm, _ws->backgroundImage);
//_blowUp = 0;
- _cursor = 0;
_background = 0;
_leftClick = false;
_rightButton = false;
@@ -134,103 +264,6 @@ Scene::Scene(ResourcePackId packId, AsylumEngine *engine): _vm(engine) {
_actorUpdateFlag2 = 0;
}
-void Scene::initialize() {
- _vm->setGameFlag(kGameFlagScriptProcessing);
-
- _playerActorIdx = 0;
-
- if (_ws->objects.size() > 0) {
- int32 priority = 4091;
- for (uint32 b = 0; b < _ws->objects.size(); b++) {
- Object *object = _ws->objects[b];
- object->setPriority(priority);
- object->flags &= ~kObjectFlagC000;
- priority -= 4;
- }
- }
-
- Cursor::create(_vm, _cursor, _ws->curMagnifyingGlass);
-
- _ws->sceneRectIdx = 0;
- _vm->screen()->clearScreen(); // XXX was clearGraphicsInQueue()
- _ws->motionStatus = 1;
-
- Actor *actor = getActor();
- Common::Rect *boundinRect = actor->getBoundingRect();
- boundinRect->bottom = actor->y2;
- boundinRect->right = actor->x2 * 2;
-
- _ws->boundingRect = Common::Rect(195,
- 115,
- 445 - boundinRect->right,
- 345 - boundinRect->bottom);
-
- actor->flags |= 1;
- actor->updateStatus(kActorStatusEnabled);
-
- if (_ws->actors.size() > 1) {
- for (uint32 a = 1; a < _ws->actors.size(); a++) {
- Actor *act = _ws->actors[a];
- act->flags |= 1;
- act->setDirection(1);
- act->updateStatus(kActorStatusEnabled);
- act->x1 -= act->x2;
- act->y1 -= act->y2;
- boundinRect->bottom = act->y2;
- boundinRect->right = 2 * act->x2;
- }
- }
-
- int32 actionIdx = _ws->actionListIdx;
- if (actionIdx)
- _actions->queueScript(actionIdx, 0);
-
- // XXX not sure why we need to do this again
- _vm->screen()->clearScreen();
- // TODO loadTransTables(3, field_64/68/7C)
- // TODO setTransTable(1)
- _vm->text()->loadFont(_ws->font1);
- // TODO preloadGraphics() .text:00410F10
- // TODO sound_sub(sceneNumber) .text:0040E750
- _ws->actorType = actorType[_ws->chapter];
-
- startMusic();
-
- _vm->screenUpdatesCount = 1;
-
- // TODO sceneRectChangedFlag = 1;
-
- actor->setLastScreenUpdate(_vm->getTick());
- // XXX This initialization was already done earlier,
- // so I'm not sure why we need to do it again. Investigate.
- actor->updateDirection();
-
- if (_ws->chapter == kChapter9) {
- // TODO changeActorIndex(1); .text:00405140
- _ws->field_E860C = -1;
- }
-}
-
-void Scene::startMusic() {
- ResourceId musicId = kResourceNone;
- if (_ws->musicCurrentResourceIndex != kResourceMusicStopped && _ws->chapter != kChapter1 && getSound()->isCacheOk())
- musicId = MAKE_RESOURCE(kResourcePackMusic, _ws->musicCurrentResourceIndex);
-
- getSound()->playMusic(musicId);
-}
-
-Scene::~Scene() {
- delete _ws;
- delete _polygons;
- delete _actions;
-
- delete _cursor;
- delete _bgResource;
- //delete _blowUp;
-
- delete _title;
-}
-
Actor* Scene::getActor(ActorIndex index) {
ActorIndex computedIndex = (index != -1) ? index : _playerActorIdx;
@@ -240,34 +273,6 @@ Actor* Scene::getActor(ActorIndex index) {
return _ws->actors[computedIndex];
}
-void Scene::enterScene() {
- if (Config.showSceneLoading && !_titleLoaded) {
- _title->load();
- // disable input polling
- //_actions->_allowInput = false;
- } else {
- _vm->screen()->setPalette(_ws->currentPaletteId);
- _background = _bgResource->getFrame(0);
- _vm->screen()->copyToBackBuffer(
- ((byte *)_background->surface.pixels) + _ws->yTop * _background->surface.w + _ws->xLeft, _background->surface.w,
- 0, 0, 640, 480);
-
- // FIXME
- // I don't know that this is the right way to initialize the cursor
- // when the scene is started. Check against the original to see
- // when the cursor is initialized, and then how it reacts to the
- // show_cursor opcode
- Cursor::create(_vm, _cursor, _ws->curMagnifyingGlass);
- _cursor->show();
-
- startMusic();
-
- _walking = false;
- }
-
- _isActive = true;
-}
-
void Scene::setScenePosition(int x, int y) {
GraphicFrame *bg = _bgResource->getFrame(0);
//_startX = x;
@@ -297,8 +302,8 @@ void Scene::handleEvent(Common::Event *event, bool doUpdate) {
switch (_ev->type) {
case Common::EVENT_MOUSEMOVE:
- if (_cursor)
- _cursor->move(_ev->mouse.x, _ev->mouse.y);
+ if (getCursor())
+ getCursor()->move(_ev->mouse.x, _ev->mouse.y);
break;
case Common::EVENT_LBUTTONUP:
@@ -311,7 +316,7 @@ void Scene::handleEvent(Common::Event *event, bool doUpdate) {
// TODO This isn't always going to be the magnifying glass
// Should check the current pointer region to identify the type
// of cursor to use
- Cursor::create(_vm, _cursor, _ws->curMagnifyingGlass);
+ getCursor()->set(_ws->curMagnifyingGlass);
_rightButton = false;
//}
break;
@@ -343,7 +348,7 @@ void Scene::update() {
_title->update(_vm->getTick());
if (_title->loadingComplete()) {
_titleLoaded = true;
- enterScene();
+ // FIXME enterScene();
}
return;
}
@@ -426,15 +431,15 @@ void Scene::updateMouse() {
int dir = -1;
bool done = false;
- if (_cursor->position().x < actorPos.left) {
- if (_cursor->position().y >= actorPos.top) {
- if (_cursor->position().y > actorPos.bottom) {
+ if (getCursor()->position().x < actorPos.left) {
+ if (getCursor()->position().y >= actorPos.top) {
+ if (getCursor()->position().y > actorPos.bottom) {
if (act->getDirection() == 2) {
- if (_cursor->position().y - actorPos.bottom > 10)
+ if (getCursor()->position().y - actorPos.bottom > 10)
dir = 3;
} else {
if (act->getDirection() == 4) {
- if (actorPos.left - _cursor->position().x > 10)
+ if (actorPos.left - getCursor()->position().x > 10)
dir = 3;
} else {
dir = 3;
@@ -442,11 +447,11 @@ void Scene::updateMouse() {
}
} else {
if (act->getDirection() == 1) {
- if (_cursor->position().y - actorPos.top > 10)
+ if (getCursor()->position().y - actorPos.top > 10)
dir = 2;
} else {
if (act->getDirection() == 3) {
- if (actorPos.bottom - _cursor->position().y > 10)
+ if (actorPos.bottom - getCursor()->position().y > 10)
dir = 2;
} else {
dir = 2;
@@ -456,28 +461,28 @@ void Scene::updateMouse() {
} else {
if (act->getDirection()) {
if (act->getDirection() == 2) {
- if (actorPos.top - _cursor->position().y > 10)
+ if (actorPos.top - getCursor()->position().y > 10)
dir = 1;
} else {
dir = 1;
}
} else {
- if (actorPos.left - _cursor->position().x > 10)
+ if (actorPos.left - getCursor()->position().x > 10)
dir = 1;
}
}
done = true;
}
- if (!done && _cursor->position().x <= actorPos.right) {
- if (_cursor->position().y >= actorPos.top) {
- if (_cursor->position().y > actorPos.bottom) {
+ if (!done && getCursor()->position().x <= actorPos.right) {
+ if (getCursor()->position().y >= actorPos.top) {
+ if (getCursor()->position().y > actorPos.bottom) {
if (act->getDirection() == 3) {
- if (_cursor->position().x - actorPos.left > 10)
+ if (getCursor()->position().x - actorPos.left > 10)
dir = 4;
} else {
if (act->getDirection() == 5) {
- if (actorPos.right - _cursor->position().x > 10)
+ if (actorPos.right - getCursor()->position().x > 10)
dir = 4;
} else {
dir = 4;
@@ -486,11 +491,11 @@ void Scene::updateMouse() {
}
} else {
if (act->getDirection() == 1) {
- if (_cursor->position().x - actorPos.left > 10)
+ if (getCursor()->position().x - actorPos.left > 10)
dir = 0;
} else {
if (act->getDirection() == 7) {
- if (actorPos.right - _cursor->position().x > 10)
+ if (actorPos.right - getCursor()->position().x > 10)
dir = 0;
} else {
dir = 0;
@@ -500,28 +505,28 @@ void Scene::updateMouse() {
done = true;
}
- if (!done && _cursor->position().y < actorPos.top) {
+ if (!done && getCursor()->position().y < actorPos.top) {
if (act->getDirection()) {
if (act->getDirection() == 6) {
- if (actorPos.top - _cursor->position().y > 10)
+ if (actorPos.top - getCursor()->position().y > 10)
dir = 7;
} else {
dir = 7;
}
} else {
- if (_cursor->position().x - actorPos.right > 10)
+ if (getCursor()->position().x - actorPos.right > 10)
dir = 7;
}
done = true;
}
- if (!done && _cursor->position().y <= actorPos.bottom) {
+ if (!done && getCursor()->position().y <= actorPos.bottom) {
if (act->getDirection() == 5) {
- if (actorPos.bottom - _cursor->position().y > 10)
+ if (actorPos.bottom - getCursor()->position().y > 10)
dir = 6;
} else {
if (act->getDirection() == 7) {
- if (_cursor->position().y - actorPos.top > 10)
+ if (getCursor()->position().y - actorPos.top > 10)
dir = 6;
} else {
dir = 6;
@@ -531,13 +536,13 @@ void Scene::updateMouse() {
}
if (!done && act->getDirection() == 4) {
- if (_cursor->position().x - actorPos.right <= 10)
+ if (getCursor()->position().x - actorPos.right <= 10)
done = true;
if (!done)
dir = 5;
}
- if (!done && (act->getDirection() != 6 || _cursor->position().y - actorPos.bottom > 10))
+ if (!done && (act->getDirection() != 6 || getCursor()->position().y - actorPos.bottom > 10))
dir = 5;
handleMouseUpdate(dir, actorPos);
@@ -554,31 +559,31 @@ void Scene::handleMouseUpdate(int direction, Common::Rect rect) {
HitType type = kHitNone;
// TODO if encounter_flag03
- if (0 && _cursor->graphicResourceId != _ws->curTalkNPC)
- _cursor->set(_ws->curTalkNPC, 0, 2);
+ if (0 && getCursor()->graphicResourceId != _ws->curTalkNPC)
+ getCursor()->set(_ws->curTalkNPC, 0, 2);
Actor *act = getActor(); // get the player actor reference
// XXX field_11 seems to have something to do with
// whether the event manager is handling a right mouse down
// event
- if (_cursor->field_11 & 2) {
+ if (getCursor()->field_11 & 2) {
if (act->getStatus() == 1 || act->getStatus() == 12) {
if (direction >= 0) {
newGraphicResourceId = (ResourceId)(_ws->curScrollUp + direction);
- _cursor->set(newGraphicResourceId, 0, 2);
+ getCursor()->set(newGraphicResourceId, 0, 2);
}
}
}
if (act->getStatus() == 6 || act->getStatus() == 10) {
newGraphicResourceId = _ws->curHand;
- _cursor->set(newGraphicResourceId, 0, 2);
+ getCursor()->set(newGraphicResourceId, 0, 2);
} else {
if (act->getField638()) {
- if (_cursor->position().x >= rect.left && _cursor->position().x <= rlimit &&
- _cursor->position().y >= rect.top && _cursor->position().y <= rect.bottom &&
- hitTestActor(_cursor->position())) {
+ if (getCursor()->position().x >= rect.left && getCursor()->position().x <= rlimit &&
+ getCursor()->position().y >= rect.top && getCursor()->position().y <= rect.bottom &&
+ hitTestActor(getCursor()->position())) {
// TODO LOTS of work here, because apparently we need to use
// field_638 as an index into _ws->field_D6AC8, which is not
// yet defined as part of worldstats, but according to IDA, is:
@@ -589,7 +594,7 @@ void Scene::handleMouseUpdate(int direction, Common::Rect rect) {
} else {
// TODO pass a reference to hitType so it can be populated by
// hitTestScene
- newGraphicResourceId = hitTestScene(_cursor->position(), type);
+ newGraphicResourceId = hitTestScene(getCursor()->position(), type);
if (newGraphicResourceId != -1) {
warning ("Can't set mouse cursor, field_D6AC8 not handled ... yet");
// TODO
@@ -602,24 +607,24 @@ void Scene::handleMouseUpdate(int direction, Common::Rect rect) {
}
return; // return result;
}
- int32 targetIdx = hitTest(_cursor->position(), type);
+ int32 targetIdx = hitTest(getCursor()->position(), type);
- //printf ("Mouse X(%d)/Y(%d) = %d\n", _cursor->position().x, _cursor->position().y, type);
- if (_cursor->position().x >= rect.left && _cursor->position().x <= rlimit &&
- _cursor->position().y >= rect.top && _cursor->position().y <= rect.bottom &&
- hitTestActor(_cursor->position())) {
+ //printf ("Mouse X(%d)/Y(%d) = %d\n", getCursor()->position().x, getCursor()->position().y, type);
+ if (getCursor()->position().x >= rect.left && getCursor()->position().x <= rlimit &&
+ getCursor()->position().y >= rect.top && getCursor()->position().y <= rect.bottom &&
+ hitTestActor(getCursor()->position())) {
if (act->getReaction(0)) {
- _cursor->set(_ws->curGrabPointer, 0, 2);
+ getCursor()->set(_ws->curGrabPointer, 0, 2);
return;
}
}
if (targetIdx == -1) {
if (_ws->chapter != kChapter2 || _playerActorIdx != 10) {
- if (_cursor->flags)
- _cursor->set(_ws->curMagnifyingGlass, 0, 2);
+ if (getCursor()->flags)
+ getCursor()->set(_ws->curMagnifyingGlass, 0, 2);
} else {
- if (_cursor->flags)
- _cursor->set(_ws->curTalkNPC2, 0, 2);
+ if (getCursor()->flags)
+ getCursor()->set(_ws->curTalkNPC2, 0, 2);
}
} else {
int32 targetUpdateType = 0;
@@ -638,23 +643,23 @@ void Scene::handleMouseUpdate(int direction, Common::Rect rect) {
break;
}
- if (targetUpdateType & 1 && _cursor->flags != 2) {
- _cursor->set(_ws->curMagnifyingGlass, 0, 2);
+ if (targetUpdateType & 1 && getCursor()->flags != 2) {
+ getCursor()->set(_ws->curMagnifyingGlass, 0, 2);
} else {
if (targetUpdateType & 4) {
- _cursor->set(_ws->curHand, 0, 2);
+ getCursor()->set(_ws->curHand, 0, 2);
} else {
if (targetUpdateType & 2) {
- _cursor->set(_ws->curTalkNPC, 0, 2);
+ getCursor()->set(_ws->curTalkNPC, 0, 2);
} else {
- if (targetUpdateType & 0x10 && _cursor->flags != 2) {
- _cursor->set(_ws->curTalkNPC2, 0, 2);
+ if (targetUpdateType & 0x10 && getCursor()->flags != 2) {
+ getCursor()->set(_ws->curTalkNPC2, 0, 2);
} else {
if (_ws->chapter != kChapter2 && _playerActorIdx != 10) {
- _cursor->set(_ws->curMagnifyingGlass, 0, 0);
+ getCursor()->set(_ws->curMagnifyingGlass, 0, 0);
} else {
- if (_cursor->flags)
- _cursor->set(_ws->curTalkNPC2, 0, 2);
+ if (getCursor()->flags)
+ getCursor()->set(_ws->curTalkNPC2, 0, 2);
}
}
}
@@ -779,7 +784,7 @@ bool Scene::hitTestPixel(ResourceId resourceId, int32 frame, int16 x, int16 y, b
return rect.contains(x, y);
}
-void Scene::changePlayerActorIndex(ActorIndex index) {
+void Scene::changePlayer(ActorIndex index) {
error("[Scene::changePlayerActorIndex] not implemented");
}
@@ -920,6 +925,14 @@ void Scene::updateScreen() {
}
}
+void Scene::setWheelObjectIndices() {
+ warning("[Scene::setWheelObjectIndices] not implemented!");
+}
+
+void Scene::playIntroSpeech() {
+ warning("[Scene::playIntroSpeech] not implemented!");
+}
+
void Scene::updateAdjustScreen() {
Actor *act = getActor();
int32 newXLeft = -1;
@@ -1091,8 +1104,6 @@ bool Scene::updateListCompare(const UpdateItem &item1, const UpdateItem &item2)
return item1.priority - item2.priority;
}
-
-
void Scene::buildUpdateList() {
_updateList.clear();
@@ -1339,15 +1350,15 @@ void Scene::copyToBackBufferClipped(Graphics::Surface *surface, int x, int y) {
void Scene::debugScreenScrolling(GraphicFrame *bg) {
// Horizontal scrolling
- if (_cursor->position().x < SCREEN_EDGES && _ws->xLeft >= SCROLL_STEP)
+ if (getCursor()->position().x < SCREEN_EDGES && _ws->xLeft >= SCROLL_STEP)
_ws->xLeft -= SCROLL_STEP;
- else if (_cursor->position().x > 640 - SCREEN_EDGES && _ws->xLeft <= bg->surface.w - 640 - SCROLL_STEP)
+ else if (getCursor()->position().x > 640 - SCREEN_EDGES && _ws->xLeft <= bg->surface.w - 640 - SCROLL_STEP)
_ws->xLeft += SCROLL_STEP;
// Vertical scrolling
- if (_cursor->position().y < SCREEN_EDGES && _ws->yTop >= SCROLL_STEP)
+ if (getCursor()->position().y < SCREEN_EDGES && _ws->yTop >= SCROLL_STEP)
_ws->yTop -= SCROLL_STEP;
- else if (_cursor->position().y > 480 - SCREEN_EDGES && _ws->yTop <= bg->surface.h - 480 - SCROLL_STEP)
+ else if (getCursor()->position().y > 480 - SCREEN_EDGES && _ws->yTop <= bg->surface.h - 480 - SCROLL_STEP)
_ws->yTop += SCROLL_STEP;
}
diff --git a/engines/asylum/views/scene.h b/engines/asylum/views/scene.h
index 9517a680af..1529bf9532 100644
--- a/engines/asylum/views/scene.h
+++ b/engines/asylum/views/scene.h
@@ -69,17 +69,26 @@ enum HitType {
class Scene {
public:
- Scene(ResourcePackId packId, AsylumEngine *engine);
+ Scene(AsylumEngine *engine);
~Scene();
- /** .text:0040E460
- * Initialize the current scene
+ /**
+ * Enter a scene
+ *
+ * @param packId Package id for the scene.
*/
- void initialize();
+ void enter(ResourcePackId packId);
+
+ /**
+ * Load the scene data
+ * @param packId Package id for the scene.
+ */
+ void load(ResourcePackId packId);
- void handleEvent(Common::Event *event, bool doUpdate);
- void enterScene();
+
+
+ void handleEvent(Common::Event *event, bool doUpdate);
void activate() { _isActive = true; }
void deactivate() { _isActive = false; }
@@ -94,7 +103,6 @@ public:
AsylumEngine* vm() { return _vm; }
ActionList *actions() { return _actions; }
- Cursor *cursor() { return _cursor; }
Polygons *polygons() { return _polygons; }
Special *special() { return _special; }
Speech *speech() { return _speech; }
@@ -111,7 +119,7 @@ public:
ActorIndex getPlayerActorIndex() { return _playerActorIdx; }
void setPlayerActorIndex(ActorIndex index) { _playerActorIdx = index; }
- void changePlayerActorIndex(ActorIndex index);
+ void changePlayer(ActorIndex index);
/**
* Get a reference to an actor object from the
@@ -230,7 +238,6 @@ private:
ActionList *_actions;
SceneTitle *_title;
Speech *_speech;
- Cursor *_cursor;
Special *_special;
//BlowUpPuzzle *_blowUp;
@@ -255,7 +262,6 @@ private:
int32 _actorUpdateFlag2;
void update();
- void startMusic();
/** .text:0040B5B0
* Loop through the various update blocks (actors,
@@ -293,6 +299,10 @@ private:
void updateScreen();
+ void setWheelObjectIndices();
+
+ void playIntroSpeech();
+
//////////////////////////////////////////////////////////////////////////
// Scene drawing
Commit: 46d1acac794deb8d3754121bc97f18681ff2acd4
https://github.com/scummvm/scummvm/commit/46d1acac794deb8d3754121bc97f18681ff2acd4
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:14+02:00
Commit Message:
ASYLUM: Small correction to Actor::updateStatus9
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@515 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/resources/actor.cpp
engines/asylum/resources/actor.h
diff --git a/engines/asylum/resources/actor.cpp b/engines/asylum/resources/actor.cpp
index 1f3886e686..affb141a33 100644
--- a/engines/asylum/resources/actor.cpp
+++ b/engines/asylum/resources/actor.cpp
@@ -760,6 +760,19 @@ void Actor::setRawResources(uint8 *data) {
// Unknown methods
//////////////////////////////////////////////////////////////////////////
+bool Actor::isResourcePresent() {
+ if (_status != kActorStatus9)
+ return false;
+
+ int index = 10;
+ for (index = 10; index < 20; index++) {
+ if (_graphicResourceIds[index] == _resourceId)
+ break;
+ }
+
+ return (index >= 15);
+}
+
bool Actor::process(int32 actorX, int32 actorY) {
error("[Actor::process] not implemented!");
}
@@ -924,63 +937,17 @@ void Actor::updateStatusEnabled() {
}
}
-ResourceId Actor::getResourceFromTable() {
- ResourceId id = kResourceNone;
-
- if (_status == kActorStatus9) {
- for (int i = 10; i <= 20; i++)
- if (_resourceId == _graphicResourceIds[i])
- return _graphicResourceIds[i];
- }
-
- return id;
-
- /* TODO Here's the disassembly if someone could verify my implementation ;)
- int __cdecl character_sub_4093D0(int characterIndex)
- {
- int result; // eax at 1
- int v2; // edx at 1
- char *_grResTableEntry; // edx at 2
- signed int v4; // ecx at 2
- int _grResId; // esi at 2
-
- result = 0;
- v2 = 2468 * characterIndex;
- if ( scene.characters[characterIndex].status == 9 )
- {
- _grResId = *(int *)((char *)&scene.characters[0].grResId + v2);
- v4 = 10;
- _grResTableEntry = (char *)&scene.characters[0].grResTable[10] + v2;
- while ( *(_DWORD *)_grResTableEntry != _grResId )
- {
- ++v4;
- _grResTableEntry += 4;
- if ( v4 >= 20 )
- return result;
- }
- result = v4 < 15;
- LOBYTE(result) = v4 >= 15;
- }
- return result;
- }
- */
-}
-
void Actor::updateStatus9() {
- if (getWorld()->numChapter != 9 && getWorld()->actorType == 0 && _frameIndex == 0) {
- // FIXME I don't really understand why this check would be necessary here
- // since we're not really doing anything with the result, and it doesn't
- // really matter whether it's missing or not ....
- if (getResourceFromTable() != kResourceNone) {
- Sound *snd = getSound();
- if (!snd->soundResourceId || !snd->isPlaying(snd->soundResourceId)) {
- snd->playSpeech(13);
- }
- }
+ if (_index == getScene()->getPlayerActorIndex()
+ && getWorld()->chapter != kChapter9
+ && getWorld()->actorType == 0
+ && _frameIndex == 0
+ && isResourcePresent()) {
+ if (!getSpeech()->getSoundResourceId() || !getSound()->isPlaying(getSpeech()->getSoundResourceId()))
+ getSpeech()->playPlayer(13);
}
- _frameIndex++;
-
+ ++_frameIndex;
if (_frameIndex == _frameCount) {
updateStatus(kActorStatusEnabled);
_lastScreenUpdate = _vm->screenUpdatesCount;
diff --git a/engines/asylum/resources/actor.h b/engines/asylum/resources/actor.h
index 84fb10d4e8..96d1b34d89 100644
--- a/engines/asylum/resources/actor.h
+++ b/engines/asylum/resources/actor.h
@@ -215,14 +215,6 @@ public:
*/
void setRawResources(uint8* data);
- /**
- * Get an entry from the graphicsResourceTable between indices 10 and 20 if
- * it matches the current resourceId value
- *
- * TODO This whole method probably isn't required
- */
- ResourceId getResourceFromTable();
-
// Unknown methods
bool process(int32 actorX, int32 actorY);
void processStatus(int32 actorX, int32 actorY, bool doSpeech);
@@ -233,6 +225,13 @@ public:
bool process_41BDB0(int32 reactionIndex, bool testNumberValue01);
void update_40DE20();
+ /**
+ * Query if the object resource is present in the resource table between indices 10 & 20
+ *
+ * @return true if resource present between 15 & 20, false if not.
+ */
+ bool isResourcePresent();
+
//////////////////////////////////////////////////////////////////////////
// Static update methods
//////////////////////////////////////////////////////////////////////////
Commit: 32f3eed36ca5ab678e5427578824131a6621ef41
https://github.com/scummvm/scummvm/commit/32f3eed36ca5ab678e5427578824131a6621ef41
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:14+02:00
Commit Message:
ASYLUM: Refactor Speech class
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@516 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/resources/actionlist.cpp
engines/asylum/resources/actor.cpp
engines/asylum/resources/special.cpp
engines/asylum/shared.h
engines/asylum/system/sound.cpp
engines/asylum/system/sound.h
engines/asylum/system/speech.cpp
engines/asylum/system/speech.h
engines/asylum/system/text.cpp
engines/asylum/system/text.h
engines/asylum/views/menu.cpp
engines/asylum/views/scene.cpp
engines/asylum/views/scene.h
engines/asylum/views/scenetitle.cpp
diff --git a/engines/asylum/resources/actionlist.cpp b/engines/asylum/resources/actionlist.cpp
index 7d10eeb22f..3a3eff6e57 100644
--- a/engines/asylum/resources/actionlist.cpp
+++ b/engines/asylum/resources/actionlist.cpp
@@ -536,7 +536,7 @@ IMPLEMENT_OPCODE(JumpActorSpeech) {
_currentLine = cmd->param4;
if (cmd->param5)
- getScene()->playSpeech(1);
+ getSpeech()->playIndexed(1);
}
//////////////////////////////////////////////////////////////////////////
@@ -1101,7 +1101,7 @@ IMPLEMENT_OPCODE(PlaySpeechScene) {
return;
if (cmd->param4 != 2) {
- cmd->param5 = getScene()->playSpeech(cmd->param1);
+ cmd->param5 = getSpeech()->playIndexed(cmd->param1);
if (cmd->param2) {
_vm->setGameFlag(kGameFlagScriptProcessing);
@@ -1153,7 +1153,7 @@ IMPLEMENT_OPCODE(PlaySpeech) {
return;
if (cmd->param4 != 2) {
- cmd->param5 = getSpeech()->play((ResourceId)cmd->param1);
+ cmd->param5 = getSpeech()->playPlayer((ResourceId)cmd->param1);
if (cmd->param2) {
_vm->setGameFlag(kGameFlagScriptProcessing);
@@ -1230,7 +1230,7 @@ IMPLEMENT_OPCODE(PlaySpeechScene2) {
return;
}
- cmd->param6 = getScene()->playSpeech(cmd->param1, cmd->param2);
+ cmd->param6 = getSpeech()->playScene(cmd->param1, cmd->param2);
if (cmd->param3) {
_vm->setGameFlag(kGameFlagScriptProcessing);
@@ -1298,7 +1298,7 @@ IMPLEMENT_OPCODE(StartPaletteFadeThread) {
// Opcode 0x46
IMPLEMENT_OPCODE(_unk46) {
if (cmd->param6) {
- if (_vm->sound()->isPlaying(_vm->sound()->soundResourceId)) {
+ if (getSound()->isPlaying(getSpeech()->getSoundResourceId())) {
_lineIncrement = 1;
} else {
cmd->param6 = 0;
@@ -1313,12 +1313,11 @@ IMPLEMENT_OPCODE(_unk46) {
_vm->clearGameFlag(kGameFlagScriptProcessing);
- _vm->sound()->soundResourceId = kResourceNone;
- _vm->sound()->speechTextResourceId = kResourceNone;
+ getSpeech()->resetResourceIds();
}
} else {
_vm->setGameFlag(kGameFlagScriptProcessing);
- getSpeech()->setPlayerSpeech(MAKE_RESOURCE(kResourcePackSpeech, 515 + cmd->param1), MAKE_RESOURCE(kResourcePackShared, 1290 + cmd->param1));
+ getSpeech()->play(MAKE_RESOURCE(kResourcePackSpeech, 515 + cmd->param1), MAKE_RESOURCE(kResourcePackShared, 1290 + cmd->param1));
if (cmd->param2) {
getScene()->getActor(cmd->param5)->updateStatus(kActorStatus8);
@@ -1576,7 +1575,7 @@ IMPLEMENT_OPCODE(_unk56) {
}
} else {
if (cmd->param4)
- getScene()->playSpeech(1);
+ getSpeech()->playIndexed(1);
_currentLine = cmd->param3;
}
@@ -1720,7 +1719,7 @@ IMPLEMENT_OPCODE(_unk63) {
_vm->setFlag(kFlagType2);
}
- if (_vm->sound()->isPlaying(_vm->sound()->soundResourceId)) {
+ if (_vm->sound()->isPlaying(getSpeech()->getSoundResourceId())) {
_lineIncrement = 1;
return;
} else if (!cmd->param1) {
diff --git a/engines/asylum/resources/actor.cpp b/engines/asylum/resources/actor.cpp
index affb141a33..bbd283286d 100644
--- a/engines/asylum/resources/actor.cpp
+++ b/engines/asylum/resources/actor.cpp
@@ -245,7 +245,7 @@ void Actor::update() {
if (_vm->isGameFlagSet(kGameFlag556)) {
Actor *player = getScene()->getActor();
- getSpeech()->play(MAKE_RESOURCE(getScene()->getPackId(), 453));
+ getSpeech()->playPlayer(453);
hide();
player->updateStatus(kActorStatus3);
@@ -352,7 +352,7 @@ void Actor::update() {
if (_vm->screenUpdatesCount - _lastScreenUpdate > 300) {
if (_vm->getRandom(100) < 50) {
- if (!getSound()->soundResourceId || !getSound()->isPlaying(getSound()->soundResourceId)) {
+ if (!getSpeech()->getSoundResourceId() || !getSound()->isPlaying(getSpeech()->getSoundResourceId())) {
if (isDefaultDirection(10))
updateStatus(kActorStatus9);
}
@@ -784,7 +784,7 @@ void Actor::processStatus(int32 actorX, int32 actorY, bool doSpeech) {
else
updateStatus(kActorStatus13);
} else if (doSpeech) {
- getScene()->playSpeech(1);
+ getSpeech()->playIndexed(1);
}
}
@@ -872,7 +872,7 @@ void Actor::updateStatusEnabled() {
if (_vm->screenUpdatesCount - _lastScreenUpdate > 300) {
if (strcmp((char *)&_name, "Crow")) {
if (_vm->getRandom(100) < 50
- && (!getSound()->soundResourceId || !getSound()->isPlaying(getSound()->soundResourceId))
+ && (!getSpeech()->getSoundResourceId() || !getSound()->isPlaying(getSpeech()->getSoundResourceId()))
&& isDefaultDirection(10))
updateStatus(kActorStatus9);
@@ -887,12 +887,12 @@ void Actor::updateStatusEnabled() {
if (_vm->isGameFlagNotSet(kGameFlagScriptProcessing)
&& isVisible()
&& !_vm->encounter()->getFlag(kEncounterFlag2)
- && !getSound()->soundResourceId) {
+ && !getSpeech()->getSoundResourceId()) {
if (_vm->getRandom(100) < 50) {
if (getWorld()->chapter == kChapter13)
- getSpeech()->play(MAKE_RESOURCE(getScene()->getPackId(), 507));
+ getSpeech()->playPlayer(507);
else
- getSpeech()->play(MAKE_RESOURCE(getScene()->getPackId(), 4));
+ getSpeech()->playIndexed(4);
}
}
_lastScreenUpdate = _vm->screenUpdatesCount;
diff --git a/engines/asylum/resources/special.cpp b/engines/asylum/resources/special.cpp
index 916f81cf10..6ff5746570 100644
--- a/engines/asylum/resources/special.cpp
+++ b/engines/asylum/resources/special.cpp
@@ -117,12 +117,12 @@ void Special::chapter1(Object *object, ActorIndex actorIndex) {
case kObjectAngelFlares:
if (object->getFrameIndex() == 5)
- getSpeech()->play(MAKE_RESOURCE(getScene()->getPackId(), 81));
+ getSpeech()->playPlayer(81);
break;
case kObjectGuyFalls:
if (object->getFrameIndex() == 23)
- getSpeech()->play(MAKE_RESOURCE(getScene()->getPackId(), 82));
+ getSpeech()->playPlayer(82);
break;
}
}
@@ -141,7 +141,7 @@ void Special::chapter2(Object *object, ActorIndex actorIndex) {
Actor::enableActorsChapter2(_vm);
}
- if (_vm->isGameFlagSet(kGameFlag1131) && !getSound()->isPlaying(getSound()->soundResourceId)) {
+ if (_vm->isGameFlagSet(kGameFlag1131) && !getSound()->isPlaying(getSpeech()->getSoundResourceId())) {
_vm->clearGameFlag(kGameFlag219);
_vm->setGameFlag(kGameFlag1131);
}
@@ -263,7 +263,7 @@ void Special::chapter2(Object *object, ActorIndex actorIndex) {
if (actor->isVisible())
if (getScene()->getActorUpdateFlag2() < 7)
- getSpeech()->play(MAKE_RESOURCE(getScene()->getPackId(), 452));
+ getSpeech()->playPlayer(452);
_vm->setGameFlag(kGameFlag219);
@@ -420,7 +420,7 @@ void Special::chapter7(Object *object, ActorIndex actorIndex) {
break;
case kObjectGlobe:
- if (!getSound()->isPlaying(getSound()->soundResourceId)) {
+ if (!getSound()->isPlaying(getSpeech()->getSoundResourceId())) {
_vm->clearGameFlag(kGameFlag1009);
getCursor()->show();
}
diff --git a/engines/asylum/shared.h b/engines/asylum/shared.h
index c63ebe9fe1..1d12ee5e8f 100644
--- a/engines/asylum/shared.h
+++ b/engines/asylum/shared.h
@@ -102,7 +102,7 @@ enum ResourcePackId {
kResourcePackShared = 1,
kResourcePackMusic = 2, // Special case: will load from mus* resources
kResourcePackSpeech = 3,
- // No resource pack 4
+ kResourcePackSpeechOther = 4,
kResourcePackTowerCells = 5,
kResourcePackInnocentAbandoned = 6,
kResourcePackCourtyardAndChapel = 7,
diff --git a/engines/asylum/system/sound.cpp b/engines/asylum/system/sound.cpp
index d70817107c..621b1a1a74 100644
--- a/engines/asylum/system/sound.cpp
+++ b/engines/asylum/system/sound.cpp
@@ -250,10 +250,6 @@ void Sound::playSpeech(ResourceId resourceId) {
playSoundData(Audio::Mixer::kSpeechSoundType, &_speechHandle, ent->data, ent->size, false, 0, 0);
}
-void Sound::setSpeech(ResourceId sound, ResourceId speechText) {
- error("[Sound::setSpeech] not implemented!");
-}
-
void Sound::playMusic(ResourceId resourceId, int32 volume) {
if (resourceId == kResourceNone)
return;
diff --git a/engines/asylum/system/sound.h b/engines/asylum/system/sound.h
index 1433d557b6..8be89806aa 100644
--- a/engines/asylum/system/sound.h
+++ b/engines/asylum/system/sound.h
@@ -100,8 +100,12 @@ public:
void stopSound();
void stopAllSounds(bool stopSpeechAndMusic = false);
+ /**
+ * Play speech by resourceId
+ *
+ * @param resourceId Identifier for the sound resource.
+ */
void playSpeech(ResourceId resourceId);
- void setSpeech(ResourceId sound, ResourceId speechText);
void playMusic(ResourceId resourceId, int32 volume = Config.musicVolume);
void changeMusic(ResourceId resourceId, int32 musicStatusExt);
@@ -140,10 +144,6 @@ public:
// TODO Make sure this is needed
bool isCacheOk() { error("[Sound::isCacheOk] not implemented!"); }
- // Global resources ids
- ResourceId soundResourceId;
- ResourceId speechTextResourceId;
-
private:
AsylumEngine *_vm;
diff --git a/engines/asylum/system/speech.cpp b/engines/asylum/system/speech.cpp
index c15de1afb5..01f9bc3511 100644
--- a/engines/asylum/system/speech.cpp
+++ b/engines/asylum/system/speech.cpp
@@ -44,80 +44,196 @@ Speech::Speech(AsylumEngine *engine): _vm(engine) {
}
Speech::~Speech() {
- // TODO Auto-generated destructor stub
}
-int32 Speech::play(ResourceId speechResourceId) {
- ResourceId soundResourceId = kResourceNone;
+ResourceId Speech::play(ResourceId soundResourceId, ResourceId textResourceId) {
+ if (soundResourceId)
+ if (getSound()->isPlaying(soundResourceId))
+ getSound()->stopSound(soundResourceId);
- switch (getWorld()->actorType) {
- case kActorMax: {
- int32 soundResourceId2 = speechResourceId;
- int32 textResourceId = speechResourceId;
+ _soundResourceId = soundResourceId;
+ _textResourceId = textResourceId;
+
+ prepareSpeech();
+
+ return soundResourceId;
+}
- if (speechResourceId >= 259) {
- soundResourceId2 -= 9;
- textResourceId -= 9;
+ResourceId Speech::playIndexed(int32 index) {
+ int processedIndex = 0;
+
+ if (getWorld()->actorType || index != -1) {
+
+ } else {
+ switch(_vm->getRandom(3)) {
+ default:
+ case 0:
+ processedIndex = 23;
+ break;
+
+ case 1:
+ processedIndex = 400;
+ break;
+
+ case 2:
+ processedIndex = 401;
+ break;
+
+ case 3:
+ processedIndex = index;
+ break;
}
- soundResourceId = (ResourceId)(soundResourceId2 - 0x7FFD0000);
- // setup the right index for sound and text
- setPlayerSpeech(soundResourceId, (ResourceId)(textResourceId - 0x7FFFFFAD));
- }
- break;
- // TODO: check if actor type is right for the following cases
- case kActorSarah: {
- soundResourceId = (ResourceId)(speechResourceId - 0x7FFBF879);
- setPlayerSpeech(soundResourceId, (ResourceId)(speechResourceId - 0x7FFFFDB6));
- }
- break;
- case kActorCyclops: {
- soundResourceId = (ResourceId)(speechResourceId - 0x7FFBF7DC);
- setPlayerSpeech(soundResourceId, (ResourceId)(speechResourceId - 0x7FFFFD19));
+ if (processedIndex >= 259)
+ processedIndex -=9;
}
+
+ switch (getWorld()->actorType) {
+ default:
break;
- case kActorAztec: {
- soundResourceId = (ResourceId)(speechResourceId - 0x7FFBF746);
- setPlayerSpeech(soundResourceId, (ResourceId)(speechResourceId - 0x7FFFFC83));
+
+ case kActorMax:
+ return play(MAKE_RESOURCE(kResourcePackSpeech, index), MAKE_RESOURCE(kResourcePackText, index + 83));
+
+ case kActorSarah:
+ return play(MAKE_RESOURCE(kResourcePackSpeechOther, index + 1927), MAKE_RESOURCE(kResourcePackText, index + 586));
+
+ case kActorCyclops:
+ return play(MAKE_RESOURCE(kResourcePackSpeechOther, index + 2084), MAKE_RESOURCE(kResourcePackText, index + 743));
+
+ case kActorAztec:
+ return play(MAKE_RESOURCE(kResourcePackSpeechOther, index + 2234), MAKE_RESOURCE(kResourcePackText, index + 893));
}
- break;
+
+ return kResourceNone;
+}
+
+ResourceId Speech::playScene(int32 type, int32 index) {
+ switch (type) {
default:
- soundResourceId = kResourceNone;
+ play(kResourceNone, kResourceNone);
break;
+
+ case 0:
+ return play(MAKE_RESOURCE(kResourcePackSpeechOther, index + 2363), MAKE_RESOURCE(kResourcePackText, index + 1022));
+
+ case 1:
+ return play(MAKE_RESOURCE(kResourcePackSpeechOther, index + 2366), MAKE_RESOURCE(kResourcePackText, index + 1025));
+
+ case 2:
+ return play(MAKE_RESOURCE(kResourcePackSpeechOther, index + 2371), MAKE_RESOURCE(kResourcePackText, index + 1030));
+
+ case 3:
+ return play(MAKE_RESOURCE(kResourcePackSpeechOther, index + 2398), MAKE_RESOURCE(kResourcePackText, index + 1057));
+
+ case 4:
+ return play(MAKE_RESOURCE(kResourcePackSpeech, index + 503), MAKE_RESOURCE(kResourcePackText, index + 1060));
+
+ case 5:
+ return play(MAKE_RESOURCE(kResourcePackSpeechOther, index + 2401), MAKE_RESOURCE(kResourcePackText, index + 1068));
+
+ case 6:
+ return play(MAKE_RESOURCE(kResourcePackSpeechOther, index + 2409), MAKE_RESOURCE(kResourcePackText, index + 1076));
+
+ case 7:
+ return play(MAKE_RESOURCE(kResourcePackSpeechOther, index + 2415), MAKE_RESOURCE(kResourcePackText, index + 1082));
+
+ case 8:
+ return play(MAKE_RESOURCE(kResourcePackSpeech, index + 511), MAKE_RESOURCE(kResourcePackText, index + 1084));
+
+ case 9:
+ return play(MAKE_RESOURCE(kResourcePackSpeechOther, index + 2417), MAKE_RESOURCE(kResourcePackText, index + 1088));
+
+ case 10:
+ return play(MAKE_RESOURCE(kResourcePackSpeechOther, index + 2417), MAKE_RESOURCE(kResourcePackText, index + 1093));
+
+ case 11:
+ return play(MAKE_RESOURCE(kResourcePackSpeechOther, index + 2424), MAKE_RESOURCE(kResourcePackText, index + 1100));
+
+ case 12:
+ return play(MAKE_RESOURCE(kResourcePackSpeechOther, index + 2424), MAKE_RESOURCE(kResourcePackText, index + 1102));
+
+ case 13:
+ return play(MAKE_RESOURCE(kResourcePackSpeechOther, index + 2430), MAKE_RESOURCE(kResourcePackText, index + 1108));
+
+ case 14:
+ return play(MAKE_RESOURCE(kResourcePackSpeechOther, index + 2432), MAKE_RESOURCE(kResourcePackText, index + 1110));
+
+ case 15:
+ return play(MAKE_RESOURCE(kResourcePackSpeechOther, index + 2434), MAKE_RESOURCE(kResourcePackText, index + 1112));
+
+ case 16:
+ return play(MAKE_RESOURCE(kResourcePackSpeechOther, index + 2435), MAKE_RESOURCE(kResourcePackText, index + 1113));
+
+ case 17:
+ return play(MAKE_RESOURCE(kResourcePackSpeechOther, index + 2436), MAKE_RESOURCE(kResourcePackText, index + 1114));
+
+ case 18:
+ return play(MAKE_RESOURCE(kResourcePackSpeechOther, index + 2438), MAKE_RESOURCE(kResourcePackText, index + 1116));
+
+ case 19:
+ return play(MAKE_RESOURCE(kResourcePackSpeechOther, index + 2439), MAKE_RESOURCE(kResourcePackText, index + 1117));
}
- return soundResourceId;
+ return kResourceNone;
}
-void Speech::setPlayerSpeech(ResourceId soundResourceId, ResourceId textResourceId) {
- if (soundResourceId) {
- if (getSound()->isPlaying(soundResourceId)) {
- getSound()->stopSound(soundResourceId);
+ResourceId Speech::playPlayer(int32 index) {
+ switch (getWorld()->actorType) {
+ default:
+ break;
+
+ case kActorMax: {
+ int32 soundResourceIndex = index;
+ int32 textResourceIndex = index;
+
+ if (index >= 259) {
+ soundResourceIndex -= 9;
+ textResourceIndex -= 9;
}
+
+ ResourceId soundResourceId = MAKE_RESOURCE(kResourcePackSpeech, soundResourceIndex);
+
+ return play(soundResourceId, MAKE_RESOURCE(kResourcePackText, textResourceIndex + 83));
+ }
+ break;
+
+ case kActorSarah:
+ return play(MAKE_RESOURCE(kResourcePackSpeechOther, index + 1927), MAKE_RESOURCE(kResourcePackText, index + 586));
+
+ case kActorCyclops:
+ return play(MAKE_RESOURCE(kResourcePackSpeechOther, index + 2084), MAKE_RESOURCE(kResourcePackText, index + 743));
+
+ case kActorAztec:
+ return play(MAKE_RESOURCE(kResourcePackSpeechOther, index + 2234), MAKE_RESOURCE(kResourcePackText, index + 893));
}
- _soundResourceId = soundResourceId;
- _textResourceId = textResourceId;
+ return kResourceNone;
+}
- prepareSpeech();
+void Speech::resetResourceIds() {
+ _soundResourceId = kResourceNone;
+ _textResourceId = kResourceNone;
}
+//////////////////////////////////////////////////////////////////////////
+// Private methods
+//////////////////////////////////////////////////////////////////////////
+
void Speech::prepareSpeech() {
- //int32 startTick = _scene->vm()->getTick();
+ int32 startTick = _vm->getTick();
if (_soundResourceId) {
- if (!getSound()->isPlaying(_soundResourceId)/* || _tick && startTick >= _tick*/) {
- processSpeech();
- }
+ if (!getSound()->isPlaying(_soundResourceId) || (_tick && startTick >= _tick))
+ process();
if (Config.showEncounterSubtitles) {
- int16 check = 0;
- /*Common::Point *pt;
- _scene->getActorPosition(_scene->getActor(), pt);
+ Common::Point point;
+ Actor *actor = getScene()->getActor();
- check = pt->y < 240;
- check = pt->y >= 240;*/
- int32 posY = ((check - 1) & 0x118) + 40;
+ getScene()->adjustCoordinates(actor->x1, actor->y1, &point);
+
+ int32 posY = (((point.y >= 240) - 1) & 280) + 40;
getText()->loadFont(getWorld()->font3);
getText()->drawText(20, posY, _textDataPos);
@@ -128,35 +244,32 @@ void Speech::prepareSpeech() {
}
}
-void Speech::processSpeech() {
- char * txt;
+void Speech::process() {
_tick = 0;
- txt = getText()->getResText(_textResourceId);
+ char *txt = getText()->get(_textResourceId);
if (*(txt + strlen((const char *)txt) - 2) == 1) {
_textResourceId = kResourceNone;
_textData = 0;
_textDataPos = 0;
- } else {
- if (*txt == '{') {
- _textData = txt + 3;
- _textDataPos = 0;
-
- getText()->loadFont(getWorld()->font1);
- getSound()->playSpeech(_soundResourceId);
- } else {
- _textData = 0;
- _textDataPos = txt;
+ } else if (*txt == '{') {
+ _textData = txt + 3;
+ _textDataPos = 0;
- if (*txt == '/') {
- _textDataPos = txt + 2;
- }
+ getText()->loadFont(getWorld()->font1);
+ getSound()->playSpeech(_soundResourceId);
+ } else {
+ _textData = 0;
+ _textDataPos = txt;
- getText()->loadFont(getWorld()->font3);
- getSound()->playSpeech(_soundResourceId);
+ if (*txt == '/') {
+ _textDataPos = txt + 2;
}
+
+ getText()->loadFont(getWorld()->font3);
+ getSound()->playSpeech(_soundResourceId);
}
}
diff --git a/engines/asylum/system/speech.h b/engines/asylum/system/speech.h
index f0905dadbf..7a24476c6c 100644
--- a/engines/asylum/system/speech.h
+++ b/engines/asylum/system/speech.h
@@ -39,27 +39,60 @@ public:
Speech(AsylumEngine *engine);
virtual ~Speech();
- ResourceId _soundResourceId;
- ResourceId _textResourceId;
-
- /** .text:00414810
- * Play player speech
- * @param speechIdx speech index (used for sound and text resources)
- * @return correct resourceId
+ /**
+ * Play speech
+ *
+ * @param soundResourceId The sound resource id.
+ * @param textResourceId The text resource id.
*/
- int32 play(ResourceId speechResourceId);
- /** .text:004146D0
- * Set speech for different player type
- * @param soundResourceId sound resource id
- * @param textResourceId text resource id
- */
- void setPlayerSpeech(ResourceId soundResourceId, ResourceId textResourceId);
- /** .text:004144C0
+ ResourceId play(ResourceId soundResourceId, ResourceId textResourceId);
+
+ /**
* Prepare speech to play
* - Process sound speech and draws dialogue in screen
*/
void prepareSpeech();
+ /**
+ * Play speech by index offset.
+ *
+ * @param index The index offset.
+ *
+ * @return the ResourceId for the sound played
+ */
+ ResourceId playIndexed(int32 index);
+
+ /**
+ * Play scene speech.
+ *
+ * @param type The type of speech to play.
+ * @param index The index offset.
+ *
+ * @return the ResourceId for the sound played
+ */
+ ResourceId playScene(int32 type, int32 index);
+
+ /**
+ * Play speech by index offset (based on player type)
+ *
+ * @param index The index offset.
+ *
+ * @return the ResourceId for the sound played
+ */
+ ResourceId playPlayer(int32 index);
+
+ /**
+ * Resets the resource identifiers.
+ */
+ void resetResourceIds();
+
+ /**
+ * Gets the sound resource identifier.
+ *
+ * @return The sound resource identifier.
+ */
+ ResourceId getSoundResourceId() const { return _soundResourceId; }
+
private:
AsylumEngine *_vm;
@@ -67,13 +100,13 @@ private:
char *_textData;
char *_textDataPos;
- /** .text:00414580
- * TODO add description
- */
- void processSpeech();
+ ResourceId _soundResourceId;
+ ResourceId _textResourceId;
- // This function was cutoff since it doesn't make any sense using it. Its here for address information only
- /** .text:00414630 void playSpeech(ResourceId textResourceId, ResourceId fontResourceId); */
+ /**
+ * Process speech and prepare for display
+ */
+ void process();
}; // end of class Speech
diff --git a/engines/asylum/system/text.cpp b/engines/asylum/system/text.cpp
index 3e81bd7c30..451d02ec52 100644
--- a/engines/asylum/system/text.cpp
+++ b/engines/asylum/system/text.cpp
@@ -61,13 +61,13 @@ void Text::loadFont(ResourceId resourceId) {
}
}
-void Text::setTextPos(int32 x, int32 y) {
+void Text::setPosition(int32 x, int32 y) {
_posX = x;
_posY = y;
}
// getTextWidth at address 004357C0
-int32 Text::getTextWidth(const char *text) {
+int32 Text::getWidth(const char *text) {
assert(_fontResource);
int32 width = 0;
@@ -82,12 +82,12 @@ int32 Text::getTextWidth(const char *text) {
return width;
}
-int32 Text::getResTextWidth(ResourceId resourceId) {
+int32 Text::getWidth(ResourceId resourceId) {
ResourceEntry *textRes = getResource()->get(resourceId);
- return getTextWidth((char*)textRes->data);
+ return getWidth((char*)textRes->data);
}
-char* Text::getResText(ResourceId resourceId) {
+char* Text::get(ResourceId resourceId) {
ResourceEntry *textRes = getResource()->get(resourceId);
return (char*)textRes->data;
}
@@ -113,8 +113,8 @@ void Text::drawResText(ResourceId resourceId) {
}
void Text::drawTextCentered(int32 x, int32 y, int32 width, const char *text) {
- int32 textWidth = getTextWidth(text);
- setTextPos(x + (width - textWidth) / 2, y);
+ int32 textWidth = getWidth(text);
+ setPosition(x + (width - textWidth) / 2, y);
drawText(text);
}
@@ -133,8 +133,8 @@ void Text::drawResTextCentered(int32 x, int32 y, int32 width, ResourceId resourc
void Text::drawText(int32 x, int32 y, const char *text) {
if (text) {
- int32 textWidth = getTextWidth(text);
- setTextPos(x - textWidth, y);
+ int32 textWidth = getWidth(text);
+ setPosition(x - textWidth, y);
drawText(text);
}
}
@@ -145,8 +145,8 @@ void Text::drawResText(int32 x, int32 y, ResourceId resourceId) {
}
void Text::drawTextAlignRight(int32 x, int32 y, const char *text) {
- int32 textWidth = getTextWidth(text);
- setTextPos(x - textWidth, y);
+ int32 textWidth = getWidth(text);
+ setPosition(x - textWidth, y);
drawText(text);
}
diff --git a/engines/asylum/system/text.h b/engines/asylum/system/text.h
index af27516780..7b34c53257 100644
--- a/engines/asylum/system/text.h
+++ b/engines/asylum/system/text.h
@@ -43,10 +43,10 @@ public:
void loadFont(ResourceId resourceId);
- void setTextPos(int32 x, int32 y);
- int32 getTextWidth(const char *text);
- int32 getResTextWidth(ResourceId resourceId);
- char * getResText(ResourceId resourceId);
+ void setPosition(int32 x, int32 y);
+ int32 getWidth(const char *text);
+ int32 getWidth(ResourceId resourceId);
+ char *get(ResourceId resourceId);
void drawChar(unsigned char character);
void drawText(const char *text);
diff --git a/engines/asylum/views/menu.cpp b/engines/asylum/views/menu.cpp
index 301bef58cd..e4dc2af996 100644
--- a/engines/asylum/views/menu.cpp
+++ b/engines/asylum/views/menu.cpp
@@ -322,7 +322,7 @@ void MainMenu::updateMainMenu() {
// Show text
_vm->text()->drawResTextCentered(MenuIconFixedXpos[iconNum],
iconFrame->y + 50,
- getText()->getResTextWidth(MAKE_RESOURCE(kResourcePackText, iconNum + 1309)),
+ getText()->getWidth(MAKE_RESOURCE(kResourcePackText, iconNum + 1309)),
MAKE_RESOURCE(kResourcePackText, iconNum + 1309));
// Play creepy voice
@@ -392,25 +392,25 @@ void MainMenu::updateSubMenuNewGame() {
_vm->text()->drawResTextCentered(10, 100, 620, MAKE_RESOURCE(kResourcePackText, 529));
// Yes
- switchFont(_cursor->position().x < 247 || _cursor->position().x > 247 + _vm->text()->getResTextWidth(MAKE_RESOURCE(kResourcePackText, 1322)) || _cursor->position().y < 273 || _cursor->position().y > 273 + 24);
- _vm->text()->setTextPos(247, 273);
+ switchFont(_cursor->position().x < 247 || _cursor->position().x > 247 + _vm->text()->getWidth(MAKE_RESOURCE(kResourcePackText, 1322)) || _cursor->position().y < 273 || _cursor->position().y > 273 + 24);
+ _vm->text()->setPosition(247, 273);
_vm->text()->drawResText(MAKE_RESOURCE(kResourcePackText, 1322));
// No
- switchFont(_cursor->position().x < 369 || _cursor->position().x > 369 + _vm->text()->getResTextWidth(MAKE_RESOURCE(kResourcePackText, 1323)) || _cursor->position().y < 273 || _cursor->position().y > 273 + 24);
- _vm->text()->setTextPos(369, 273);
+ switchFont(_cursor->position().x < 369 || _cursor->position().x > 369 + _vm->text()->getWidth(MAKE_RESOURCE(kResourcePackText, 1323)) || _cursor->position().y < 273 || _cursor->position().y > 273 + 24);
+ _vm->text()->setPosition(369, 273);
_vm->text()->drawResText(MAKE_RESOURCE(kResourcePackText, 1323));
// action
if (_leftClick) {
// Yes
- if (_cursor->position().x >= 247 && _cursor->position().x <= 247 + 24 && _cursor->position().y >= 273 && _cursor->position().y <= 273 + _vm->text()->getResTextWidth(MAKE_RESOURCE(kResourcePackText, 1322))) {
+ if (_cursor->position().x >= 247 && _cursor->position().x <= 247 + 24 && _cursor->position().y >= 273 && _cursor->position().y <= 273 + _vm->text()->getWidth(MAKE_RESOURCE(kResourcePackText, 1322))) {
_leftClick = false;
closeMenu();
_vm->startGame(kResourcePackTowerCells, AsylumEngine::kStartGamePlayIntro);
}
// No
- if (_cursor->position().x >= 369 && _cursor->position().x <= 369 + 24 && _cursor->position().y >= 273 && _cursor->position().y <= 273 + _vm->text()->getResTextWidth(MAKE_RESOURCE(kResourcePackText, 1323)))
+ if (_cursor->position().x >= 369 && _cursor->position().x <= 369 + 24 && _cursor->position().y >= 273 && _cursor->position().y <= 273 + _vm->text()->getWidth(MAKE_RESOURCE(kResourcePackText, 1323)))
exitSubMenu();
}
}
@@ -418,7 +418,7 @@ void MainMenu::updateSubMenuNewGame() {
void MainMenu::updateSubMenuCinematics() {
int32 currentCD = 1; // FIXME: dummy value
_vm->text()->drawResTextWithValueCentered(10, 100, 620, MAKE_RESOURCE(kResourcePackText, 1352), currentCD);
- _vm->text()->setTextPos(30, 340);
+ _vm->text()->setPosition(30, 340);
_vm->text()->drawResText(MAKE_RESOURCE(kResourcePackText, 1353)); // Prev Page
if (_cursor->position().x >= 280 && _cursor->position().x <= 400 && _cursor->position().y >= 340 && _cursor->position().y <= 360) {
@@ -429,19 +429,19 @@ void MainMenu::updateSubMenuCinematics() {
loadFont(kFontYellow);
}
- _vm->text()->setTextPos(280, 340);
+ _vm->text()->setPosition(280, 340);
_vm->text()->drawResText(MAKE_RESOURCE(kResourcePackText, 1355)); // Main Menu
loadFont(kFontYellow);
- _vm->text()->setTextPos(500, 340);
+ _vm->text()->setPosition(500, 340);
_vm->text()->drawResText(MAKE_RESOURCE(kResourcePackText, 1354)); // Next Page
}
void MainMenu::updateSubMenuSettings() {
- int32 sizeMinus = _vm->text()->getTextWidth("-");
- int32 sizePlus = _vm->text()->getTextWidth("+");
- int32 sizeMainMenu = _vm->text()->getResTextWidth(MAKE_RESOURCE(kResourcePackText, 1437));
+ int32 sizeMinus = _vm->text()->getWidth("-");
+ int32 sizePlus = _vm->text()->getWidth("+");
+ int32 sizeMainMenu = _vm->text()->getWidth(MAKE_RESOURCE(kResourcePackText, 1437));
loadFont(kFontYellow);
// Settings
@@ -450,14 +450,14 @@ void MainMenu::updateSubMenuSettings() {
// gamma correction
_vm->text()->drawResTextAlignRight(320, 150, MAKE_RESOURCE(kResourcePackText, 1433));
switchFont(_cursor->position().x < 350 || _cursor->position().x > sizeMinus + 350 || _cursor->position().y < 150 || _cursor->position().y > 174);
- _vm->text()->setTextPos(350, 150);
+ _vm->text()->setPosition(350, 150);
_vm->text()->drawText("-");
switchFont(_cursor->position().x < sizeMinus + 360 || _cursor->position().x > sizeMinus + sizePlus + 360 || _cursor->position().y < 150 || _cursor->position().y > 174);
- _vm->text()->setTextPos(sizeMinus + 360, 150);
+ _vm->text()->setPosition(sizeMinus + 360, 150);
_vm->text()->drawText("+");
- _vm->text()->setTextPos(sizeMinus + sizePlus + 365, 150);
+ _vm->text()->setPosition(sizeMinus + sizePlus + 365, 150);
loadFont(kFontYellow);
if (Config.gammaLevel) {
for (int32 i = 0; i < Config.gammaLevel; i++) {
@@ -472,14 +472,14 @@ void MainMenu::updateSubMenuSettings() {
loadFont(kFontYellow);
_vm->text()->drawResTextAlignRight(320, 179, MAKE_RESOURCE(kResourcePackText, 1434));
switchFont(_cursor->position().x < 350 || _cursor->position().x > sizeMinus + 350 || _cursor->position().y < 179 || _cursor->position().y > 203);
- _vm->text()->setTextPos(350, 179);
+ _vm->text()->setPosition(350, 179);
_vm->text()->drawText("-");
switchFont(_cursor->position().x < sizeMinus + 360 || _cursor->position().x > sizeMinus + sizePlus + 360 || _cursor->position().y < 179 || _cursor->position().y > 203);
- _vm->text()->setTextPos(sizeMinus + 360, 179);
+ _vm->text()->setPosition(sizeMinus + 360, 179);
_vm->text()->drawText("+");
- _vm->text()->setTextPos(sizeMinus + sizePlus + 365, 179);
+ _vm->text()->setPosition(sizeMinus + sizePlus + 365, 179);
loadFont(kFontYellow);
if (Config.performance == 5) {
_vm->text()->drawResText(MAKE_RESOURCE(kResourcePackText, 1436));
@@ -493,7 +493,7 @@ void MainMenu::updateSubMenuSettings() {
// back to main menu
switchFont(_cursor->position().x < 300 || _cursor->position().x > 300 + sizeMainMenu || _cursor->position().y < 340 || _cursor->position().y > 340 + 24);
- _vm->text()->setTextPos(300, 340);
+ _vm->text()->setPosition(300, 340);
_vm->text()->drawResText(MAKE_RESOURCE(kResourcePackText, 1437));
// action
@@ -543,19 +543,19 @@ void MainMenu::updateSubMenuQuitGame() {
_vm->text()->drawResTextCentered(10, 100, 620, MAKE_RESOURCE(kResourcePackText, 1408));
// Yes
- switchFont(_cursor->position().x < 247 || _cursor->position().x > 247 + _vm->text()->getResTextWidth(MAKE_RESOURCE(kResourcePackText, 581)) || _cursor->position().y < 273 || _cursor->position().y > 273 + 24);
- _vm->text()->setTextPos(247, 273);
+ switchFont(_cursor->position().x < 247 || _cursor->position().x > 247 + _vm->text()->getWidth(MAKE_RESOURCE(kResourcePackText, 581)) || _cursor->position().y < 273 || _cursor->position().y > 273 + 24);
+ _vm->text()->setPosition(247, 273);
_vm->text()->drawResText(MAKE_RESOURCE(kResourcePackText, 1409));
// No
- switchFont(_cursor->position().x < 369 || _cursor->position().x > 369 + _vm->text()->getResTextWidth(MAKE_RESOURCE(kResourcePackText, 582)) || _cursor->position().y < 273 || _cursor->position().y > 273 + 24);
- _vm->text()->setTextPos(369, 273);
+ switchFont(_cursor->position().x < 369 || _cursor->position().x > 369 + _vm->text()->getWidth(MAKE_RESOURCE(kResourcePackText, 582)) || _cursor->position().y < 273 || _cursor->position().y > 273 + 24);
+ _vm->text()->setPosition(369, 273);
_vm->text()->drawResText(MAKE_RESOURCE(kResourcePackText, 1410));
// action
if (_leftClick) {
// Yes
- if (_cursor->position().x >= 247 && _cursor->position().x <= 247 + 24 && _cursor->position().y >= 273 && _cursor->position().y <= 273 + _vm->text()->getResTextWidth(MAKE_RESOURCE(kResourcePackText, 1409))) {
+ if (_cursor->position().x >= 247 && _cursor->position().x <= 247 + 24 && _cursor->position().y >= 273 && _cursor->position().y <= 273 + _vm->text()->getWidth(MAKE_RESOURCE(kResourcePackText, 1409))) {
_leftClick = false;
// User clicked on quit, so push a quit event
@@ -564,7 +564,7 @@ void MainMenu::updateSubMenuQuitGame() {
g_system->getEventManager()->pushEvent(event);
}
// No
- if (_cursor->position().x >= 369 && _cursor->position().x <= 369 + 24 && _cursor->position().y >= 273 && _cursor->position().y <= 273 + _vm->text()->getResTextWidth(MAKE_RESOURCE(kResourcePackText, 1410)))
+ if (_cursor->position().x >= 369 && _cursor->position().x <= 369 + 24 && _cursor->position().y >= 273 && _cursor->position().y <= 273 + _vm->text()->getWidth(MAKE_RESOURCE(kResourcePackText, 1410)))
exitSubMenu();
}
}
@@ -605,7 +605,7 @@ void MainMenu::updateSubMenuShowCredits() {
posY = _creditsTextScroll;
}
- _vm->text()->setTextPos(320, step + posY);
+ _vm->text()->setPosition(320, step + posY);
_vm->text()->drawResText((ResourceId)(resourceId - 2147482201));
posY = _creditsTextScroll;
}
@@ -649,14 +649,14 @@ void MainMenu::updateSubMenuReturnToGame() {
_vm->text()->drawResTextCentered(10, 100, 620, MAKE_RESOURCE(kResourcePackText, 712));
// Main menu
- switchFont(_cursor->position().x < 285 || _cursor->position().x > 285 + _vm->text()->getResTextWidth(MAKE_RESOURCE(kResourcePackText, 713)) || _cursor->position().y < 273 || _cursor->position().y > 273 + 24);
- _vm->text()->setTextPos(285, 273);
+ switchFont(_cursor->position().x < 285 || _cursor->position().x > 285 + _vm->text()->getWidth(MAKE_RESOURCE(kResourcePackText, 713)) || _cursor->position().y < 273 || _cursor->position().y > 273 + 24);
+ _vm->text()->setPosition(285, 273);
_vm->text()->drawResText(MAKE_RESOURCE(kResourcePackText, 713));
// action
if (_leftClick) {
// Main menu
- if (_cursor->position().x >= 285 && _cursor->position().x <= 285 + _vm->text()->getResTextWidth(MAKE_RESOURCE(kResourcePackText, 713)) && _cursor->position().y >= 273 && _cursor->position().y <= 273 + 24)
+ if (_cursor->position().x >= 285 && _cursor->position().x <= 285 + _vm->text()->getWidth(MAKE_RESOURCE(kResourcePackText, 713)) && _cursor->position().y >= 273 && _cursor->position().y <= 273 + 24)
exitSubMenu();
}
}
diff --git a/engines/asylum/views/scene.cpp b/engines/asylum/views/scene.cpp
index ac2e85e3c6..ca68ad81bc 100644
--- a/engines/asylum/views/scene.cpp
+++ b/engines/asylum/views/scene.cpp
@@ -334,15 +334,9 @@ void Scene::handleEvent(Common::Event *event, bool doUpdate) {
// FIXME just updating because a left click event
// is caught causes animation speeds to change. This needs
// to be addressed
- if (doUpdate) // || _leftClick)
- update();
-}
-
-// -------------------------------------------
-// ---------- PROCESS SCENE REGION -----------
-// -------------------------------------------
+ if (!doUpdate)
+ return;
-void Scene::update() {
if (Config.showSceneLoading) {
if (!_titleLoaded) {
_title->update(_vm->getTick());
@@ -354,7 +348,7 @@ void Scene::update() {
}
}
- if (updateScene())
+ if (update())
return;
// TODO: check game quality
@@ -362,18 +356,18 @@ void Scene::update() {
//TODO: other process stuffs from sub 0040AE30
- if (_speech->_soundResourceId != 0) {
- if (_vm->sound()->isPlaying(_speech->_soundResourceId)) {
+
+ if (_speech->getSoundResourceId() != 0) {
+ if (_vm->sound()->isPlaying(_speech->getSoundResourceId())) {
_speech->prepareSpeech();
} else {
- _speech->_textResourceId = kResourceNone;
- _speech->_soundResourceId = kResourceNone;
+ _speech->resetResourceIds();
_vm->clearGameFlag(kGameFlag219);
}
-}
+ }
}
-int Scene::updateScene() {
+int Scene::update() {
#ifdef DEBUG_SCENE_TIMES
#define MESURE_TICKS(func) { \
int32 startTick =_vm->getTick(); \
@@ -1447,14 +1441,6 @@ void Scene::updatePlayerChapter9(int32 param) {
error("[Scene::updatePlayerChapter9] not implemented!");
}
-ResourceId Scene::playSpeech(int32 a1) {
- error("[Scene::playSpeech] not implemented!");
-}
-
-ResourceId Scene::playSpeech(int32 a1, int32 a2) {
- error("[Scene::playSpeech] not implemented!");
-}
-
int Scene::processActor(int *x, int *param) {
error("[Scene::processActor] not implemented!");
}
diff --git a/engines/asylum/views/scene.h b/engines/asylum/views/scene.h
index 1529bf9532..3b406dfef4 100644
--- a/engines/asylum/views/scene.h
+++ b/engines/asylum/views/scene.h
@@ -155,10 +155,6 @@ public:
void updatePlayerChapter9(int32 param);
- // TODO: make sure it is the right place and make private
- ResourceId playSpeech(int32 a1);
- ResourceId playSpeech(int32 a1, int32 id);
-
int processActor(int *x, int *param);
void updatePalette(int32 param);
@@ -261,14 +257,12 @@ private:
int32 _actorUpdateFlag;
int32 _actorUpdateFlag2;
- void update();
-
/** .text:0040B5B0
* Loop through the various update blocks (actors,
* objects, mouse, music, sfx, screenPosition), then
* process the current action script
*/
- int updateScene();
+ int update();
/** .text:0040D190
* TODO add description
*/
diff --git a/engines/asylum/views/scenetitle.cpp b/engines/asylum/views/scenetitle.cpp
index 4b0de8bee8..c811dfda93 100644
--- a/engines/asylum/views/scenetitle.cpp
+++ b/engines/asylum/views/scenetitle.cpp
@@ -83,7 +83,7 @@ void SceneTitle::update(int32 tick) {
0, 0, 640, 480);
ResourceId resourceId = MAKE_RESOURCE(getScene()->getPackId(), 1797);
- int32 resWidth = getText()->getResTextWidth(resourceId);
+ int32 resWidth = getText()->getWidth(resourceId);
getText()->drawResTextCentered(320 - resWidth * 24, 30, resWidth, resourceId);
GraphicFrame *frame = _progress->getFrame(_spinnerFrame);
Commit: 25fac6195de51eb42d96009b81e6f0bfd6dfecd6
https://github.com/scummvm/scummvm/commit/25fac6195de51eb42d96009b81e6f0bfd6dfecd6
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:14+02:00
Commit Message:
ASYLUM: Rename some methods of Text class
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@517 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/system/speech.cpp
engines/asylum/system/text.cpp
engines/asylum/system/text.h
engines/asylum/views/menu.cpp
engines/asylum/views/scenetitle.cpp
diff --git a/engines/asylum/system/speech.cpp b/engines/asylum/system/speech.cpp
index 01f9bc3511..8f06b06be8 100644
--- a/engines/asylum/system/speech.cpp
+++ b/engines/asylum/system/speech.cpp
@@ -236,10 +236,10 @@ void Speech::prepareSpeech() {
int32 posY = (((point.y >= 240) - 1) & 280) + 40;
getText()->loadFont(getWorld()->font3);
- getText()->drawText(20, posY, _textDataPos);
+ getText()->draw(20, posY, _textDataPos);
getText()->loadFont(getWorld()->font1);
- getText()->drawText(20, posY, _textData);
+ getText()->draw(20, posY, _textData);
}
}
}
diff --git a/engines/asylum/system/text.cpp b/engines/asylum/system/text.cpp
index 451d02ec52..022a24cd19 100644
--- a/engines/asylum/system/text.cpp
+++ b/engines/asylum/system/text.cpp
@@ -46,7 +46,6 @@ Text::~Text() {
delete _fontResource;
}
-// loadFont at address 00435640
void Text::loadFont(ResourceId resourceId) {
if (_fontResource && resourceId == _fontResource->getResourceId())
return;
@@ -66,7 +65,6 @@ void Text::setPosition(int32 x, int32 y) {
_posY = y;
}
-// getTextWidth at address 004357C0
int32 Text::getWidth(const char *text) {
assert(_fontResource);
@@ -100,59 +98,59 @@ void Text::drawChar(unsigned char character) {
_posX += fontLetter->surface.w + fontLetter->x - _curFontFlags;
}
-void Text::drawText(const char *text) {
+void Text::draw(const char *text) {
while (*text) {
drawChar(*((unsigned char *)text));
text++;
}
}
-void Text::drawResText(ResourceId resourceId) {
+void Text::draw(ResourceId resourceId) {
ResourceEntry *textRes = getResource()->get(resourceId);
- drawText((char*)textRes->data);
+ draw((char*)textRes->data);
}
-void Text::drawTextCentered(int32 x, int32 y, int32 width, const char *text) {
+void Text::drawCentered(int32 x, int32 y, int32 width, const char *text) {
int32 textWidth = getWidth(text);
setPosition(x + (width - textWidth) / 2, y);
- drawText(text);
+ draw(text);
}
-void Text::drawResTextWithValueCentered(int32 x, int32 y, int32 width, ResourceId resourceId, int32 value) {
+void Text::drawCentered(int32 x, int32 y, int32 width, ResourceId resourceId, int32 value) {
ResourceEntry *textRes = getResource()->get(resourceId);
char *text = (char *)textRes->data;
char txt[100];
sprintf(txt, text, value);
- drawTextCentered(x, y, width, txt);
+ drawCentered(x, y, width, txt);
}
-void Text::drawResTextCentered(int32 x, int32 y, int32 width, ResourceId resourceId) {
+void Text::drawCentered(int32 x, int32 y, int32 width, ResourceId resourceId) {
ResourceEntry *textRes = getResource()->get(resourceId);
- drawTextCentered(x, y, width, (char *)textRes->data);
+ drawCentered(x, y, width, (char *)textRes->data);
}
-void Text::drawText(int32 x, int32 y, const char *text) {
+void Text::draw(int32 x, int32 y, const char *text) {
if (text) {
int32 textWidth = getWidth(text);
setPosition(x - textWidth, y);
- drawText(text);
+ draw(text);
}
}
-void Text::drawResText(int32 x, int32 y, ResourceId resourceId) {
+void Text::draw(int32 x, int32 y, ResourceId resourceId) {
ResourceEntry *textRes = getResource()->get(resourceId);
- drawText(x, y, (char *)textRes->data);
+ draw(x, y, (char *)textRes->data);
}
-void Text::drawTextAlignRight(int32 x, int32 y, const char *text) {
+void Text::drawAlignedRight(int32 x, int32 y, const char *text) {
int32 textWidth = getWidth(text);
setPosition(x - textWidth, y);
- drawText(text);
+ draw(text);
}
-void Text::drawResTextAlignRight(int32 x, int32 y, ResourceId resourceId) {
+void Text::drawAlignedRight(int32 x, int32 y, ResourceId resourceId) {
ResourceEntry *textRes = getResource()->get(resourceId);
- drawTextAlignRight(x, y, (char *)textRes->data);
+ drawAlignedRight(x, y, (char *)textRes->data);
}
} // end of namespace Asylum
diff --git a/engines/asylum/system/text.h b/engines/asylum/system/text.h
index 7b34c53257..13b81be309 100644
--- a/engines/asylum/system/text.h
+++ b/engines/asylum/system/text.h
@@ -43,23 +43,23 @@ public:
void loadFont(ResourceId resourceId);
- void setPosition(int32 x, int32 y);
- int32 getWidth(const char *text);
- int32 getWidth(ResourceId resourceId);
- char *get(ResourceId resourceId);
+ void setPosition(int32 x, int32 y);
+ int32 getWidth(const char *text);
+ int32 getWidth(ResourceId resourceId);
+ char *get(ResourceId resourceId);
void drawChar(unsigned char character);
- void drawText(const char *text);
- void drawText(int32 x, int32 y, const char *text);
- void drawResText(ResourceId resourceId);
- void drawResText(int32 x, int32 y, ResourceId resourceId);
+ void draw(const char *text);
+ void draw(int32 x, int32 y, const char *text);
+ void draw(ResourceId resourceId);
+ void draw(int32 x, int32 y, ResourceId resourceId);
- void drawTextCentered(int32 x, int32 y, int32 width, const char *text);
- void drawResTextCentered(int32 x, int32 y, int32 width, ResourceId resourceId);
- void drawResTextWithValueCentered(int32 x, int32 y, int32 width, ResourceId resourceId, int32 value);
+ void drawCentered(int32 x, int32 y, int32 width, const char *text);
+ void drawCentered(int32 x, int32 y, int32 width, ResourceId resourceId);
+ void drawCentered(int32 x, int32 y, int32 width, ResourceId resourceId, int32 value);
- void drawTextAlignRight(int32 x, int32 y, const char *text);
- void drawResTextAlignRight(int32 x, int32 y, ResourceId resourceId);
+ void drawAlignedRight(int32 x, int32 y, const char *text);
+ void drawAlignedRight(int32 x, int32 y, ResourceId resourceId);
private:
AsylumEngine *_vm;
@@ -68,9 +68,9 @@ private:
int32 _posX;
int32 _posY;
- uint8 _curFontFlags;
+ uint8 _curFontFlags;
-}; // end of class Text
+};
} // end of namespace Asylum
diff --git a/engines/asylum/views/menu.cpp b/engines/asylum/views/menu.cpp
index e4dc2af996..dbc7c6defe 100644
--- a/engines/asylum/views/menu.cpp
+++ b/engines/asylum/views/menu.cpp
@@ -320,7 +320,7 @@ void MainMenu::updateMainMenu() {
_curIconFrame = 0;
// Show text
- _vm->text()->drawResTextCentered(MenuIconFixedXpos[iconNum],
+ _vm->text()->drawCentered(MenuIconFixedXpos[iconNum],
iconFrame->y + 50,
getText()->getWidth(MAKE_RESOURCE(kResourcePackText, iconNum + 1309)),
MAKE_RESOURCE(kResourcePackText, iconNum + 1309));
@@ -389,17 +389,17 @@ void MainMenu::updateSubMenuNewGame() {
loadFont(kFontYellow);
// begin new game
- _vm->text()->drawResTextCentered(10, 100, 620, MAKE_RESOURCE(kResourcePackText, 529));
+ _vm->text()->drawCentered(10, 100, 620, MAKE_RESOURCE(kResourcePackText, 529));
// Yes
switchFont(_cursor->position().x < 247 || _cursor->position().x > 247 + _vm->text()->getWidth(MAKE_RESOURCE(kResourcePackText, 1322)) || _cursor->position().y < 273 || _cursor->position().y > 273 + 24);
_vm->text()->setPosition(247, 273);
- _vm->text()->drawResText(MAKE_RESOURCE(kResourcePackText, 1322));
+ _vm->text()->draw(MAKE_RESOURCE(kResourcePackText, 1322));
// No
switchFont(_cursor->position().x < 369 || _cursor->position().x > 369 + _vm->text()->getWidth(MAKE_RESOURCE(kResourcePackText, 1323)) || _cursor->position().y < 273 || _cursor->position().y > 273 + 24);
_vm->text()->setPosition(369, 273);
- _vm->text()->drawResText(MAKE_RESOURCE(kResourcePackText, 1323));
+ _vm->text()->draw(MAKE_RESOURCE(kResourcePackText, 1323));
// action
if (_leftClick) {
@@ -417,9 +417,9 @@ void MainMenu::updateSubMenuNewGame() {
void MainMenu::updateSubMenuCinematics() {
int32 currentCD = 1; // FIXME: dummy value
- _vm->text()->drawResTextWithValueCentered(10, 100, 620, MAKE_RESOURCE(kResourcePackText, 1352), currentCD);
+ _vm->text()->drawCentered(10, 100, 620, MAKE_RESOURCE(kResourcePackText, 1352), currentCD);
_vm->text()->setPosition(30, 340);
- _vm->text()->drawResText(MAKE_RESOURCE(kResourcePackText, 1353)); // Prev Page
+ _vm->text()->draw(MAKE_RESOURCE(kResourcePackText, 1353)); // Prev Page
if (_cursor->position().x >= 280 && _cursor->position().x <= 400 && _cursor->position().y >= 340 && _cursor->position().y <= 360) {
loadFont(kFontBlue);
@@ -430,12 +430,12 @@ void MainMenu::updateSubMenuCinematics() {
}
_vm->text()->setPosition(280, 340);
- _vm->text()->drawResText(MAKE_RESOURCE(kResourcePackText, 1355)); // Main Menu
+ _vm->text()->draw(MAKE_RESOURCE(kResourcePackText, 1355)); // Main Menu
loadFont(kFontYellow);
_vm->text()->setPosition(500, 340);
- _vm->text()->drawResText(MAKE_RESOURCE(kResourcePackText, 1354)); // Next Page
+ _vm->text()->draw(MAKE_RESOURCE(kResourcePackText, 1354)); // Next Page
}
void MainMenu::updateSubMenuSettings() {
@@ -445,56 +445,56 @@ void MainMenu::updateSubMenuSettings() {
loadFont(kFontYellow);
// Settings
- _vm->text()->drawResTextCentered(10, 100, 620, MAKE_RESOURCE(kResourcePackText, 1432));
+ _vm->text()->drawCentered(10, 100, 620, MAKE_RESOURCE(kResourcePackText, 1432));
// gamma correction
- _vm->text()->drawResTextAlignRight(320, 150, MAKE_RESOURCE(kResourcePackText, 1433));
+ _vm->text()->drawAlignedRight(320, 150, MAKE_RESOURCE(kResourcePackText, 1433));
switchFont(_cursor->position().x < 350 || _cursor->position().x > sizeMinus + 350 || _cursor->position().y < 150 || _cursor->position().y > 174);
_vm->text()->setPosition(350, 150);
- _vm->text()->drawText("-");
+ _vm->text()->draw("-");
switchFont(_cursor->position().x < sizeMinus + 360 || _cursor->position().x > sizeMinus + sizePlus + 360 || _cursor->position().y < 150 || _cursor->position().y > 174);
_vm->text()->setPosition(sizeMinus + 360, 150);
- _vm->text()->drawText("+");
+ _vm->text()->draw("+");
_vm->text()->setPosition(sizeMinus + sizePlus + 365, 150);
loadFont(kFontYellow);
if (Config.gammaLevel) {
for (int32 i = 0; i < Config.gammaLevel; i++) {
- _vm->text()->drawText("]");
+ _vm->text()->draw("]");
}
if (Config.gammaLevel == 8)
- _vm->text()->drawText("*");
+ _vm->text()->draw("*");
} else
- _vm->text()->drawResText(MAKE_RESOURCE(kResourcePackText, 1435));
+ _vm->text()->draw(MAKE_RESOURCE(kResourcePackText, 1435));
// performance
loadFont(kFontYellow);
- _vm->text()->drawResTextAlignRight(320, 179, MAKE_RESOURCE(kResourcePackText, 1434));
+ _vm->text()->drawAlignedRight(320, 179, MAKE_RESOURCE(kResourcePackText, 1434));
switchFont(_cursor->position().x < 350 || _cursor->position().x > sizeMinus + 350 || _cursor->position().y < 179 || _cursor->position().y > 203);
_vm->text()->setPosition(350, 179);
- _vm->text()->drawText("-");
+ _vm->text()->draw("-");
switchFont(_cursor->position().x < sizeMinus + 360 || _cursor->position().x > sizeMinus + sizePlus + 360 || _cursor->position().y < 179 || _cursor->position().y > 203);
_vm->text()->setPosition(sizeMinus + 360, 179);
- _vm->text()->drawText("+");
+ _vm->text()->draw("+");
_vm->text()->setPosition(sizeMinus + sizePlus + 365, 179);
loadFont(kFontYellow);
if (Config.performance == 5) {
- _vm->text()->drawResText(MAKE_RESOURCE(kResourcePackText, 1436));
+ _vm->text()->draw(MAKE_RESOURCE(kResourcePackText, 1436));
} else {
for (int32 i = 5; i > Config.performance; --i) {
- _vm->text()->drawText("]");
+ _vm->text()->draw("]");
}
if (!Config.performance)
- _vm->text()->drawText("*");
+ _vm->text()->draw("*");
}
// back to main menu
switchFont(_cursor->position().x < 300 || _cursor->position().x > 300 + sizeMainMenu || _cursor->position().y < 340 || _cursor->position().y > 340 + 24);
_vm->text()->setPosition(300, 340);
- _vm->text()->drawResText(MAKE_RESOURCE(kResourcePackText, 1437));
+ _vm->text()->draw(MAKE_RESOURCE(kResourcePackText, 1437));
// action
if (_leftClick) {
@@ -540,17 +540,17 @@ void MainMenu::updateSubMenuQuitGame() {
loadFont(kFontYellow);
// begin new game
- _vm->text()->drawResTextCentered(10, 100, 620, MAKE_RESOURCE(kResourcePackText, 1408));
+ _vm->text()->drawCentered(10, 100, 620, MAKE_RESOURCE(kResourcePackText, 1408));
// Yes
switchFont(_cursor->position().x < 247 || _cursor->position().x > 247 + _vm->text()->getWidth(MAKE_RESOURCE(kResourcePackText, 581)) || _cursor->position().y < 273 || _cursor->position().y > 273 + 24);
_vm->text()->setPosition(247, 273);
- _vm->text()->drawResText(MAKE_RESOURCE(kResourcePackText, 1409));
+ _vm->text()->draw(MAKE_RESOURCE(kResourcePackText, 1409));
// No
switchFont(_cursor->position().x < 369 || _cursor->position().x > 369 + _vm->text()->getWidth(MAKE_RESOURCE(kResourcePackText, 582)) || _cursor->position().y < 273 || _cursor->position().y > 273 + 24);
_vm->text()->setPosition(369, 273);
- _vm->text()->drawResText(MAKE_RESOURCE(kResourcePackText, 1410));
+ _vm->text()->draw(MAKE_RESOURCE(kResourcePackText, 1410));
// action
if (_leftClick) {
@@ -606,7 +606,7 @@ void MainMenu::updateSubMenuShowCredits() {
}
_vm->text()->setPosition(320, step + posY);
- _vm->text()->drawResText((ResourceId)(resourceId - 2147482201));
+ _vm->text()->draw((ResourceId)(resourceId - 2147482201));
posY = _creditsTextScroll;
}
step += 24;
@@ -646,12 +646,12 @@ void MainMenu::updateSubMenuReturnToGame() {
loadFont(kFontYellow);
// no game loaded
- _vm->text()->drawResTextCentered(10, 100, 620, MAKE_RESOURCE(kResourcePackText, 712));
+ _vm->text()->drawCentered(10, 100, 620, MAKE_RESOURCE(kResourcePackText, 712));
// Main menu
switchFont(_cursor->position().x < 285 || _cursor->position().x > 285 + _vm->text()->getWidth(MAKE_RESOURCE(kResourcePackText, 713)) || _cursor->position().y < 273 || _cursor->position().y > 273 + 24);
_vm->text()->setPosition(285, 273);
- _vm->text()->drawResText(MAKE_RESOURCE(kResourcePackText, 713));
+ _vm->text()->draw(MAKE_RESOURCE(kResourcePackText, 713));
// action
if (_leftClick) {
diff --git a/engines/asylum/views/scenetitle.cpp b/engines/asylum/views/scenetitle.cpp
index c811dfda93..b19db3ba60 100644
--- a/engines/asylum/views/scenetitle.cpp
+++ b/engines/asylum/views/scenetitle.cpp
@@ -84,7 +84,7 @@ void SceneTitle::update(int32 tick) {
ResourceId resourceId = MAKE_RESOURCE(getScene()->getPackId(), 1797);
int32 resWidth = getText()->getWidth(resourceId);
- getText()->drawResTextCentered(320 - resWidth * 24, 30, resWidth, resourceId);
+ getText()->drawCentered(320 - resWidth * 24, 30, resWidth, resourceId);
GraphicFrame *frame = _progress->getFrame(_spinnerFrame);
Commit: df639342c450de5cd122b7228c337dd70605b4cb
https://github.com/scummvm/scummvm/commit/df639342c450de5cd122b7228c337dd70605b4cb
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:14+02:00
Commit Message:
ASYLUM: Remove unused variables from Config class
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@518 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/system/config.h
diff --git a/engines/asylum/system/config.h b/engines/asylum/system/config.h
index 7c9b82ffc4..0afd8bf6fe 100644
--- a/engines/asylum/system/config.h
+++ b/engines/asylum/system/config.h
@@ -78,17 +78,6 @@ public:
// This option will prevent the intro movies from being played whenever the engine is started
bool showIntro;
- //////////////////////////////////////////////////////////////////////////
- // TO REMOVE ??
- //////////////////////////////////////////////////////////////////////////
- // XXX Throwing some globals in here until
- // I know how to better handle them
- int word_446EE4;
-
- Common::Array<int> movieSubtitles;
- Common::Array<int> encounterSubtitles; // FIXME: take this out
- //////////////////////////////////////////////////////////////////////////
-
/**
* Load configuration file
*/
Commit: b1c3d9d7e0bccd5086dbcbdb8adc787b4f171b17
https://github.com/scummvm/scummvm/commit/b1c3d9d7e0bccd5086dbcbdb8adc787b4f171b17
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:14+02:00
Commit Message:
ASYLUM: Add some init code to Scene & Actor classes
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@519 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/asylum.cpp
engines/asylum/resources/actor.cpp
engines/asylum/respack.cpp
engines/asylum/respack.h
engines/asylum/shared.h
engines/asylum/views/scene.cpp
engines/asylum/views/scene.h
diff --git a/engines/asylum/asylum.cpp b/engines/asylum/asylum.cpp
index 8fe086f5ee..b9a321fee2 100644
--- a/engines/asylum/asylum.cpp
+++ b/engines/asylum/asylum.cpp
@@ -54,8 +54,11 @@ AsylumEngine::AsylumEngine(OSystem *system, const ADGameDescription *gd) : Engin
_console(NULL), _encounter(NULL), _resource(NULL), _mainMenu(NULL), _scene(NULL), _screen(NULL),
_sound(NULL), _text(NULL), _video(NULL) {
- // Reset flags
+ // Init data
memset(_gameFlags, 0, 1512);
+ memset(_gameFlags, 0, sizeof(_gameFlags));
+ screenUpdatesCount = 0;
+ globalTickValue_2 = 0;
// Add default search directories
const Common::FSNode gameDataDir(ConfMan.get("path"));
@@ -129,7 +132,7 @@ Common::Error AsylumEngine::run() {
//} else {
// _mainMenu->openMenu();
//}
- //
+ //
while (!shouldQuit()) {
handleEvents(true);
diff --git a/engines/asylum/resources/actor.cpp b/engines/asylum/resources/actor.cpp
index bbd283286d..4c6cae2c3c 100644
--- a/engines/asylum/resources/actor.cpp
+++ b/engines/asylum/resources/actor.cpp
@@ -47,7 +47,72 @@
namespace Asylum {
Actor::Actor(AsylumEngine *engine, ActorIndex index) : _vm(engine), _index(index) {
- // TODO Init all variables
+ // Init all variables
+ _resourceId = kResourceNone;
+ _objectIndex = 0;
+ _frameIndex = 0;
+ _frameCount = 0;
+ x = y = 0;
+ x1 = y1 = x2 = y2 = 0;
+ _direction = 0;
+ _field_3C = 0;
+ _status = kActorStatusNone;
+ _field_44 = 0;
+ _priority = 0;
+ flags = 0;
+ _field_50 = 0;
+ _field_54 = 0;
+ _field_58 = 0;
+ _field_5C = 0;
+ _field_60 = 0;
+ _actionIdx3 = 0;
+ // TODO field_68 till field_617
+ _reaction[8] = 0;
+ _field_638 = 0;
+ _walkingSound1 = 0;
+ _walkingSound2 = 0;
+ _walkingSound3 = 0;
+ _walkingSound4 = 0;
+ _field_64C = 0;
+ _field_650 = 0;
+ memset(_graphicResourceIds, 0 , sizeof(_graphicResourceIds));
+ memset(&_name, 0, 256);
+ memset(&_field_830, 0, sizeof(_field_830));
+ memset(&_field_880, 0, sizeof(_field_880));
+ memset(&_field_8D0, 0, sizeof(_field_8D0));
+ _actionIdx2 = 0;
+ _field_924 = 0;
+ _lastScreenUpdate = 0;
+ _field_92C = 0;
+ actionType = 0;
+ _field_934 = 0;
+ _field_938 = 0;
+ _soundResourceId = kResourceNone;
+ _numberValue01 = 0;
+ _field_944 = 0;
+ _field_948 = 0;
+ _field_94C = 0;
+ _numberFlag01 = 0;
+ _numberStringWidth = 0;
+ _numberStringX = 0;
+ _numberStringY = 0;
+ memset(&_numberString01, 0, 8);
+ _field_964 = 0;
+ _field_968 = 0;
+ _field_96C = 0;
+ _field_970 = 0;
+ _field_974 = 0;
+ _field_978 = 0;
+ _actionIdx1 = 0;
+ _field_980 = 0;
+ _field_984 = 0;
+ _field_988 = 0;
+ _field_98C = 0;
+ _field_990 = 0;
+ _field_994 = 0;
+ _field_998 = 0;
+ _field_99C = 0;
+ _field_9A0 = 0;
// update-related variables
_actorUpdateCounter = 0;
diff --git a/engines/asylum/respack.cpp b/engines/asylum/respack.cpp
index 7d5c7d40ae..29a9bea5fd 100644
--- a/engines/asylum/respack.cpp
+++ b/engines/asylum/respack.cpp
@@ -47,6 +47,15 @@ ResourceEntry *ResourceManager::get(ResourceId id) {
return cache->getVal(packId)->get(index);
}
+void ResourceManager::unload(ResourcePackId id) {
+ ResourcePackId packId = (ResourcePackId)((id >> 16) & 0x7FFF);
+
+ if (_resources.contains(packId))
+ _resources.erase(packId);
+
+ if (_music.contains(packId))
+ _music.erase(packId);
+}
//////////////////////////////////////////////////////////////////////////
// ResourcePack
diff --git a/engines/asylum/respack.h b/engines/asylum/respack.h
index f3b95586d3..7547a71fcd 100644
--- a/engines/asylum/respack.h
+++ b/engines/asylum/respack.h
@@ -65,12 +65,23 @@ public:
ResourceManager() {}
virtual ~ResourceManager() {}
- //void load(ResourcePackId id);
-
+ /**
+ * Get a resource entry
+ *
+ * @param id The ResourceId to get.
+ *
+ * @return the resource entry
+ */
ResourceEntry *get(ResourceId id);
- //int count(ResourceId id);
- //void unload(ResourcePackId id);
+ /**
+ * Unloads the resources associated with the id
+ *
+ * @param id The identifier.
+ */
+ void unload(ResourcePackId id);
+
+ //int count(ResourceId id);
private:
struct ResourcePackId_EqualTo {
diff --git a/engines/asylum/shared.h b/engines/asylum/shared.h
index 1d12ee5e8f..eae7dc5806 100644
--- a/engines/asylum/shared.h
+++ b/engines/asylum/shared.h
@@ -158,6 +158,7 @@ enum ActorIndexes {
};
enum ActorStatus {
+ kActorStatusNone = 0,
kActorStatus1 = 1,
kActorStatus2,
kActorStatus3,
diff --git a/engines/asylum/views/scene.cpp b/engines/asylum/views/scene.cpp
index ca68ad81bc..41449d221f 100644
--- a/engines/asylum/views/scene.cpp
+++ b/engines/asylum/views/scene.cpp
@@ -57,11 +57,36 @@ int g_debugPolygons;
int g_debugObjects;
int g_debugScrolling;
-Scene::Scene(AsylumEngine *engine): _vm(engine) {
- // TODO Initialize data
+Scene::Scene(AsylumEngine *engine): _vm(engine),
+ _actions(NULL), _special(NULL), _speech(NULL), _title(NULL), _polygons(NULL), _ws(NULL) {
+
+ // Initialize data
+ _packId = kResourcePackInvalid;
+ _playerActorIdx = 0;
+ _titleLoaded = false;
+ _walking = false;
+ _leftClick = false;
+ _rightButton = false;
+ _isActive = false;
+ _skipDrawScene = false;
+ _globalDirection = 0;
+
+ // Graphics
+ _bgResource = NULL;
+ _background = NULL;
+
+ // Initialize global data
+ _globalX = _globalY = 0;
+ _sceneOffset = 0;
+ _sceneXLeft = _sceneYTop = 0;
+ _actorUpdateFlag = false;
+ _actorUpdateFlag2 = false;
}
Scene::~Scene() {
+ // Unload the associated resources
+ getResource()->unload(_packId);
+
delete _ws;
delete _polygons;
delete _actions;
diff --git a/engines/asylum/views/scene.h b/engines/asylum/views/scene.h
index 3b406dfef4..b7b3f05972 100644
--- a/engines/asylum/views/scene.h
+++ b/engines/asylum/views/scene.h
@@ -88,6 +88,7 @@ public:
+
void handleEvent(Common::Event *event, bool doUpdate);
void activate() { _isActive = true; }
@@ -229,13 +230,13 @@ private:
bool _skipDrawScene;
ActorDirection _globalDirection;
- WorldStats *_ws;
- Polygons *_polygons;
ActionList *_actions;
- SceneTitle *_title;
- Speech *_speech;
- Special *_special;
//BlowUpPuzzle *_blowUp;
+ Special *_special;
+ Speech *_speech;
+ SceneTitle *_title;
+ Polygons *_polygons;
+ WorldStats *_ws;
GraphicResource *_bgResource;
GraphicFrame *_background;
@@ -328,7 +329,7 @@ private:
friend class SceneTitle;
-}; // end of class Scene
+};
} // end of namespace Asylum
Commit: 977afaa9c3494470712a330d3150153af4906635
https://github.com/scummvm/scummvm/commit/977afaa9c3494470712a330d3150153af4906635
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:14+02:00
Commit Message:
ASYLUM: Actor class was reading too much data
Scenes > 5 are now loading a bit further
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@520 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/resources/actor.cpp
engines/asylum/resources/worldstats.cpp
diff --git a/engines/asylum/resources/actor.cpp b/engines/asylum/resources/actor.cpp
index 4c6cae2c3c..192849ed37 100644
--- a/engines/asylum/resources/actor.cpp
+++ b/engines/asylum/resources/actor.cpp
@@ -207,7 +207,6 @@ void Actor::load(Common::SeekableReadStream *stream) {
_numberStringX = stream->readSint32LE();
_numberStringY = stream->readSint32LE();
stream->read(_numberString01, sizeof(_numberString01));
- _field_964 = stream->readSint32LE();
_field_968 = stream->readSint32LE();
_field_96C = stream->readSint32LE();
_field_970 = stream->readSint32LE();
@@ -223,9 +222,6 @@ void Actor::load(Common::SeekableReadStream *stream) {
_field_998 = stream->readSint32LE();
_field_99C = stream->readSint32LE();
_field_9A0 = stream->readSint32LE();
-
- // TODO skip field_980 till field_9A0
- stream->skip(0x24);
}
/////////////////////////////////////////////////////////////////////////
diff --git a/engines/asylum/resources/worldstats.cpp b/engines/asylum/resources/worldstats.cpp
index 107a015922..eb0b2ee1ec 100644
--- a/engines/asylum/resources/worldstats.cpp
+++ b/engines/asylum/resources/worldstats.cpp
@@ -33,8 +33,7 @@
namespace Asylum {
-WorldStats::WorldStats(Common::SeekableReadStream *stream, Scene *scene)
- : _scene(scene) {
+WorldStats::WorldStats(Common::SeekableReadStream *stream, Scene *scene) : _scene(scene) {
load(stream);
}
Commit: 10f0ac46eaec51f0f8cf9081d34be69e19cb801a
https://github.com/scummvm/scummvm/commit/10f0ac46eaec51f0f8cf9081d34be69e19cb801a
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:15+02:00
Commit Message:
ASYLUM: Use the current scene pack id when trying to load music resources
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@521 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/respack.cpp
engines/asylum/respack.h
engines/asylum/system/sound.h
engines/asylum/views/scene.cpp
diff --git a/engines/asylum/respack.cpp b/engines/asylum/respack.cpp
index 29a9bea5fd..539a01b09a 100644
--- a/engines/asylum/respack.cpp
+++ b/engines/asylum/respack.cpp
@@ -30,16 +30,26 @@ namespace Asylum {
//////////////////////////////////////////////////////////////////////////
// ResourceManager
//////////////////////////////////////////////////////////////////////////
+
+ResourceManager::ResourceManager() : _musicPackId(kResourcePackInvalid) {
+}
+
ResourceEntry *ResourceManager::get(ResourceId id) {
ResourcePackId packId = (ResourcePackId)((id >> 16) & 0x7FFF);
uint16 index = (uint16)id;
// Check if we need to load a music pack
- ResourceCache *cache = (packId == kResourcePackMusic) ? &_music : &_resources;
+ bool isMusicPack = (packId == kResourcePackMusic);
+
+ // Check that a music pack has been set
+ if (isMusicPack && _musicPackId == kResourcePackInvalid)
+ error("[ResourceManager::get] Current music pack Id has not been set!");
+
+ ResourceCache *cache = isMusicPack ? &_music : &_resources;
// Try getting the resource pack
if (!cache->contains(packId)) {
- ResourcePack *pack = new ResourcePack(Common::String::format((packId == kResourcePackMusic) ? "mus.%03d" : "res.%03d", packId));
+ ResourcePack *pack = new ResourcePack(Common::String::format(isMusicPack ? "mus.%03d" : "res.%03d", isMusicPack ? _musicPackId : packId));
cache->setVal(packId, pack);
}
diff --git a/engines/asylum/respack.h b/engines/asylum/respack.h
index 7547a71fcd..19beaf9ef4 100644
--- a/engines/asylum/respack.h
+++ b/engines/asylum/respack.h
@@ -62,8 +62,8 @@ private:
class ResourceManager {
public:
- ResourceManager() {}
- virtual ~ResourceManager() {}
+ ResourceManager();
+ virtual ~ResourceManager() {};
/**
* Get a resource entry
@@ -83,6 +83,8 @@ public:
//int count(ResourceId id);
+ void setMusicPackId(ResourcePackId id) { _musicPackId = id; }
+
private:
struct ResourcePackId_EqualTo {
bool operator()(const ResourcePackId &x, const ResourcePackId &y) const { return x == y; }
@@ -96,6 +98,8 @@ private:
ResourceCache _resources;
ResourceCache _music;
+
+ ResourcePackId _musicPackId;
};
} // end of namespace Asylum
diff --git a/engines/asylum/system/sound.h b/engines/asylum/system/sound.h
index 8be89806aa..c2fad1cba5 100644
--- a/engines/asylum/system/sound.h
+++ b/engines/asylum/system/sound.h
@@ -142,7 +142,7 @@ public:
bool isPlaying() { return _mixer->isSoundHandleActive(_soundHandle); }
// TODO Make sure this is needed
- bool isCacheOk() { error("[Sound::isCacheOk] not implemented!"); }
+ bool isCacheOk() { warning("[Sound::isCacheOk] not implemented!"); return true; }
private:
AsylumEngine *_vm;
diff --git a/engines/asylum/views/scene.cpp b/engines/asylum/views/scene.cpp
index 41449d221f..f4624cf860 100644
--- a/engines/asylum/views/scene.cpp
+++ b/engines/asylum/views/scene.cpp
@@ -218,7 +218,9 @@ void Scene::enter(ResourcePackId packId) {
}
void Scene::load(ResourcePackId packId) {
+ // Setup resource manager
_packId = packId;
+ getResource()->setMusicPackId(packId);
char filename[10];
sprintf(filename, SCENE_FILE_MASK, _packId);
Commit: db2b09d61bbb197b9ee27db34af33a97766c7e44
https://github.com/scummvm/scummvm/commit/db2b09d61bbb197b9ee27db34af33a97766c7e44
Author: Alex Bevilacqua (alexbevi at gmail.com)
Date: 2021-05-17T15:36:15+02:00
Commit Message:
ASYLUM: fix compile
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@522 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/respack.h
diff --git a/engines/asylum/respack.h b/engines/asylum/respack.h
index 19beaf9ef4..39c55654b2 100644
--- a/engines/asylum/respack.h
+++ b/engines/asylum/respack.h
@@ -57,7 +57,7 @@ private:
void init(Common::String filename);
- friend ResourceManager;
+ friend class ResourceManager;
};
class ResourceManager {
Commit: 2335f8f578478ac5d03f003f77a093d641fd546b
https://github.com/scummvm/scummvm/commit/2335f8f578478ac5d03f003f77a093d641fd546b
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:15+02:00
Commit Message:
ASYLUM: Implement WorldStats::setWheelObjects() and Scene::playIntroSpeech()
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@523 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/resources/worldstats.cpp
engines/asylum/resources/worldstats.h
engines/asylum/shared.h
engines/asylum/views/scene.cpp
engines/asylum/views/scene.h
diff --git a/engines/asylum/resources/worldstats.cpp b/engines/asylum/resources/worldstats.cpp
index eb0b2ee1ec..02c3512160 100644
--- a/engines/asylum/resources/worldstats.cpp
+++ b/engines/asylum/resources/worldstats.cpp
@@ -43,31 +43,6 @@ WorldStats::~WorldStats() {
CLEAR_ARRAY(ActionArea, actions);
}
-int32 WorldStats::getActionAreaIndexById(int32 id) {
- for (uint32 i = 0; i < actions.size(); i++) {
- if (actions[i]->id == id)
- return i;
- }
-
- return -1;
-}
-
-ActionArea* WorldStats::getActionAreaById(int32 id) {
- int index = getActionAreaIndexById(id);
- if (index == -1)
- error("[WorldStats::getActionAreaById] action id is invalid");
-
- return actions[index];
-}
-
-Object* WorldStats::getObjectById(ObjectId id) {
- for (uint32 i = 0; i < objects.size(); i++)
- if (objects[i]->getId() == id)
- return objects[i];
-
- return NULL;
-}
-
// FIXME: load necessary World Stats content
void WorldStats::load(Common::SeekableReadStream *stream) {
size = stream->readSint32LE();
@@ -237,4 +212,42 @@ void WorldStats::load(Common::SeekableReadStream *stream) {
stream->seek((ACTIONS_MAX_COUNT - numActions) * ACTIONS_SIZE, SEEK_CUR);
}
+//////////////////////////////////////////////////////////////////////////
+// Helper methods
+//////////////////////////////////////////////////////////////////////////
+int32 WorldStats::getActionAreaIndexById(int32 id) {
+ for (uint32 i = 0; i < actions.size(); i++) {
+ if (actions[i]->id == id)
+ return i;
+ }
+
+ return -1;
+}
+
+ActionArea* WorldStats::getActionAreaById(int32 id) {
+ int index = getActionAreaIndexById(id);
+ if (index == -1)
+ error("[WorldStats::getActionAreaById] action id is invalid");
+
+ return actions[index];
+}
+
+Object* WorldStats::getObjectById(ObjectId id) {
+ for (uint32 i = 0; i < objects.size(); i++)
+ if (objects[i]->getId() == id)
+ return objects[i];
+
+ return NULL;
+}
+
+void WorldStats::setWheelObjects() {
+ wheels[0] = getObjectById(kObjectWheel1);
+ wheels[1] = getObjectById(kObjectWheel2);
+ wheels[2] = getObjectById(kObjectWheel3);
+ wheels[3] = getObjectById(kObjectWheel4);
+ wheels[4] = getObjectById(kObjectWheel5);
+ wheels[6] = getObjectById(kObjectWheel6);
+ wheels[7] = getObjectById(kObjectWheel7);
+}
+
} // end of namespace Asylum
diff --git a/engines/asylum/resources/worldstats.h b/engines/asylum/resources/worldstats.h
index 02701a74fb..05cdfaf69c 100644
--- a/engines/asylum/resources/worldstats.h
+++ b/engines/asylum/resources/worldstats.h
@@ -119,6 +119,9 @@ public:
// TODO add rest fields
int32 field_E860C;
// TODO add rest fields
+ Object *wheels[7];
+
+ void setWheelObjects();
int32 getActionAreaIndexById(int32 id);
ActionArea* getActionAreaById(int32 id);
diff --git a/engines/asylum/shared.h b/engines/asylum/shared.h
index eae7dc5806..beeff7325f 100644
--- a/engines/asylum/shared.h
+++ b/engines/asylum/shared.h
@@ -317,6 +317,13 @@ enum ObjectId {
kObjectCrow3Pecks = 1503,
kObjectCrow4FlysAway = 1506,
kObjectCrow4Pecks = 1507,
+ kObjectWheel1 = 2113,
+ kObjectWheel2 = 2114,
+ kObjectWheel3 = 2115,
+ kObjectWheel4 = 2116,
+ kObjectWheel5 = 2117,
+ kObjectWheel6 = 2118,
+ kObjectWheel7 = 2119,
kObjectBodySlides1 = 2514,
kObjectBodySlides2 = 2515,
kObjectBodySlides3 = 2516,
diff --git a/engines/asylum/views/scene.cpp b/engines/asylum/views/scene.cpp
index f4624cf860..63410d6fb1 100644
--- a/engines/asylum/views/scene.cpp
+++ b/engines/asylum/views/scene.cpp
@@ -108,7 +108,7 @@ void Scene::enter(ResourcePackId packId) {
load(packId);
// Set wheel indices
- setWheelObjectIndices();
+ _ws->setWheelObjects();
// Adjust object priority
if (_ws->objects.size() > 0) {
@@ -250,6 +250,9 @@ void Scene::load(ResourcePackId packId) {
_actions = new ActionList(_vm);
_actions->load(fd);
+ // TODO load rest of data
+
+
fd->close();
delete fd;
@@ -394,7 +397,7 @@ void Scene::handleEvent(Common::Event *event, bool doUpdate) {
}
}
-int Scene::update() {
+bool Scene::update() {
#ifdef DEBUG_SCENE_TIMES
#define MESURE_TICKS(func) { \
int32 startTick =_vm->getTick(); \
@@ -419,10 +422,7 @@ int Scene::update() {
if (g_debugObjects)
debugShowObjects();
- if (_actions->process())
- return 1;
-
- return 0;
+ return _actions->process();
}
void Scene::updateMouse() {
@@ -806,7 +806,7 @@ bool Scene::hitTestPixel(ResourceId resourceId, int32 frame, int16 x, int16 y, b
}
void Scene::changePlayer(ActorIndex index) {
- error("[Scene::changePlayerActorIndex] not implemented");
+ error("[Scene::changePlayer] not implemented");
}
void Scene::updateActors() {
@@ -936,6 +936,7 @@ int32 Scene::calculateVolumeAdjustment(AmbientSoundItem *snd, Actor *act) {
}
void Scene::updateMusic() {
+ //warning("[Scene::playIntroSpeech] not implemented!");
}
void Scene::updateScreen() {
@@ -946,12 +947,31 @@ void Scene::updateScreen() {
}
}
-void Scene::setWheelObjectIndices() {
- warning("[Scene::setWheelObjectIndices] not implemented!");
-}
-
void Scene::playIntroSpeech() {
- warning("[Scene::playIntroSpeech] not implemented!");
+ ResourceId resourceId;
+
+ switch (_packId) {
+ default:
+ resourceId = (ResourceId)_packId;
+ break;
+
+ case kResourcePackCourtyardAndChapel:
+ resourceId = getSpeech()->playScene(4, 3);
+ break;
+
+ case kResourcePackCave:
+ resourceId = getSpeech()->playScene(4, 6);
+ break;
+
+ case kResourcePackLaboratory:
+ resourceId = getSpeech()->playScene(4, 7);
+ break;
+ }
+
+ getScreen()->clearScreen();
+
+ // TODO do palette fade and wait until sound is done
+ warning("[Scene::playIntroSpeech] Missing palette fade and wait!");
}
void Scene::updateAdjustScreen() {
diff --git a/engines/asylum/views/scene.h b/engines/asylum/views/scene.h
index b7b3f05972..85021dd825 100644
--- a/engines/asylum/views/scene.h
+++ b/engines/asylum/views/scene.h
@@ -263,7 +263,7 @@ private:
* objects, mouse, music, sfx, screenPosition), then
* process the current action script
*/
- int update();
+ bool update();
/** .text:0040D190
* TODO add description
*/
@@ -294,7 +294,7 @@ private:
void updateScreen();
- void setWheelObjectIndices();
+
void playIntroSpeech();
Commit: 64786bb7f7676fc352c604e761665c2929957471
https://github.com/scummvm/scummvm/commit/64786bb7f7676fc352c604e761665c2929957471
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:15+02:00
Commit Message:
ASYLUM: Fix crash on exit
The objects were destructed in the wrong order
and the resource pack id wasn't calculated properly
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@524 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/asylum.cpp
engines/asylum/respack.cpp
diff --git a/engines/asylum/asylum.cpp b/engines/asylum/asylum.cpp
index b9a321fee2..19c4d609bf 100644
--- a/engines/asylum/asylum.cpp
+++ b/engines/asylum/asylum.cpp
@@ -83,15 +83,15 @@ AsylumEngine::AsylumEngine(OSystem *system, const ADGameDescription *gd) : Engin
}
AsylumEngine::~AsylumEngine() {
- delete _console;
- delete _encounter;
- delete _resource;
- delete _mainMenu;
delete _scene;
+ delete _encounter;
delete _screen;
delete _sound;
delete _text;
delete _video;
+ delete _mainMenu;
+ delete _resource;
+ delete _console;
// Zero passed pointers
_gameDescription = NULL;
diff --git a/engines/asylum/respack.cpp b/engines/asylum/respack.cpp
index 539a01b09a..ddf84de8df 100644
--- a/engines/asylum/respack.cpp
+++ b/engines/asylum/respack.cpp
@@ -58,13 +58,11 @@ ResourceEntry *ResourceManager::get(ResourceId id) {
}
void ResourceManager::unload(ResourcePackId id) {
- ResourcePackId packId = (ResourcePackId)((id >> 16) & 0x7FFF);
-
- if (_resources.contains(packId))
- _resources.erase(packId);
+ if (_resources.contains(id))
+ _resources.erase(id);
- if (_music.contains(packId))
- _music.erase(packId);
+ if (_music.contains(id))
+ _music.erase(id);
}
//////////////////////////////////////////////////////////////////////////
Commit: d8492438401179d14bb91c0d61fba24e21026d85
https://github.com/scummvm/scummvm/commit/d8492438401179d14bb91c0d61fba24e21026d85
Author: Alex Bevilacqua (alexbevi at gmail.com)
Date: 2021-05-17T15:36:15+02:00
Commit Message:
ASYLUM: added a 'world' console command to show a worldstats summary
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@525 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/console.cpp
engines/asylum/console.h
engines/asylum/resources/worldstats.cpp
engines/asylum/resources/worldstats.h
diff --git a/engines/asylum/console.cpp b/engines/asylum/console.cpp
index 4b080eba39..0120b06613 100644
--- a/engines/asylum/console.cpp
+++ b/engines/asylum/console.cpp
@@ -55,6 +55,7 @@ Console::Console(AsylumEngine *engine) : _vm(engine) {
DCmd_Register("flags", WRAP_METHOD(Console, cmdListFlags));
DCmd_Register("object", WRAP_METHOD(Console, cmdShowObject));
DCmd_Register("objects", WRAP_METHOD(Console, cmdListObjects));
+ DCmd_Register("world", WRAP_METHOD(Console, cmdShowWorldStats));
DCmd_Register("video", WRAP_METHOD(Console, cmdPlayVideo));
DCmd_Register("script", WRAP_METHOD(Console, cmdRunScript));
@@ -97,6 +98,7 @@ bool Console::cmdHelp(int, const char **) {
DebugPrintf(" flags - show flags\n");
DebugPrintf(" object - inspect a particular object\n");
DebugPrintf(" objects - show objects information\n");
+ DebugPrintf(" world - show worldstats\n");
DebugPrintf("\n");
DebugPrintf(" video - play a video\n");
DebugPrintf(" script - run a script\n");
@@ -219,6 +221,14 @@ bool Console::cmdListFlags(int32 argc, const char **argv) {
return true;
}
+bool Console::cmdShowWorldStats(int32 argc, const char **argv) {
+ DebugPrintf("WorldStats\n");
+ DebugPrintf("----------\n");
+ DebugPrintf("%s", getWorld()->toString().c_str());
+
+ return true;
+}
+
bool Console::cmdShowObject(int32 argc, const char **argv) {
if (argc != 3) {
DebugPrintf("Syntax: %s [id|idx] <target>\n", argv[0]);
diff --git a/engines/asylum/console.h b/engines/asylum/console.h
index 22a624a9b5..6a26079c1f 100644
--- a/engines/asylum/console.h
+++ b/engines/asylum/console.h
@@ -67,6 +67,7 @@ private:
bool cmdListFlags(int32 argc, const char **argv);
bool cmdShowObject(int32 argc, const char **argv);
bool cmdListObjects(int32 argc, const char **argv);
+ bool cmdShowWorldStats(int32 argc, const char **argv);
bool cmdPlayVideo(int32 argc, const char **argv);
bool cmdRunScript(int32 argc, const char **argv);
diff --git a/engines/asylum/resources/worldstats.cpp b/engines/asylum/resources/worldstats.cpp
index 02c3512160..3f7e85f407 100644
--- a/engines/asylum/resources/worldstats.cpp
+++ b/engines/asylum/resources/worldstats.cpp
@@ -250,4 +250,27 @@ void WorldStats::setWheelObjects() {
wheels[7] = getObjectById(kObjectWheel7);
}
+Common::String WorldStats::toString() {
+ Common::String output;
+
+ output += Common::String::format("xLeft: %d\n", xLeft);
+ output += Common::String::format("yTop: %d\n", yTop);
+ output += Common::String::format("boundingRect: top[%d] left[%d] right[%d] bottom[%d]: \n", boundingRect.top, boundingRect.left, boundingRect.right, boundingRect.bottom);
+ output += Common::String::format("width: %d\n", width);
+ output += Common::String::format("height: %d\n", height);
+ output += Common::String::format("motionStatus: %d\n", motionStatus);
+ output += "coordinates: ";
+ for (int i = 0; i < 7; i++)
+ output += Common::String::format("%d[%d] ", i, coordinates[i]);
+ output += "\n";
+ output += Common::String::format("sceneRectIndex: %d\n", sceneRectIdx);
+ output += Common::String::format("sceneRects: 0: top[%d] left[%d] right[%d] bottom[%d]\n", sceneRects[0].top, sceneRects[0].left, sceneRects[0].right, sceneRects[0].bottom);
+ for (int i = 1; i < 6; i++)
+ output += Common::String::format(" %d: top[%d] left[%d] right[%d] bottom[%d]\n", i, sceneRects[i].top, sceneRects[i].left, sceneRects[i].right, sceneRects[i].bottom);
+ output += Common::String::format("scriptInex: %d\n", scriptIndex);
+ output += Common::String::format("actorType: %d\n", actorType);
+ output += Common::String::format("musicStatus: %d\n", musicStatus);
+
+ return output;
+}
} // end of namespace Asylum
diff --git a/engines/asylum/resources/worldstats.h b/engines/asylum/resources/worldstats.h
index 05cdfaf69c..133da2e7ea 100644
--- a/engines/asylum/resources/worldstats.h
+++ b/engines/asylum/resources/worldstats.h
@@ -128,6 +128,8 @@ public:
Object* getObjectById(ObjectId id);
+ Common::String toString();
+
private:
Scene *_scene;
Commit: e2c0ac1ee2fc5e9668e2d6a69a3cfe78def3bbb0
https://github.com/scummvm/scummvm/commit/e2c0ac1ee2fc5e9668e2d6a69a3cfe78def3bbb0
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:15+02:00
Commit Message:
ASYLUM: Implement sound reactions
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@526 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
A engines/asylum/resources/reaction.cpp
A engines/asylum/resources/reaction.h
engines/asylum/module.mk
engines/asylum/shared.h
diff --git a/engines/asylum/module.mk b/engines/asylum/module.mk
index bd8b6f545b..9b605a5f67 100644
--- a/engines/asylum/module.mk
+++ b/engines/asylum/module.mk
@@ -6,6 +6,7 @@ MODULE_OBJS := \
resources/object.o \
resources/encounters.o \
resources/polygons.o \
+ resources/reaction.o \
resources/special.o \
resources/worldstats.o \
system/config.o \
diff --git a/engines/asylum/resources/reaction.cpp b/engines/asylum/resources/reaction.cpp
new file mode 100644
index 0000000000..16d6a57871
--- /dev/null
+++ b/engines/asylum/resources/reaction.cpp
@@ -0,0 +1,508 @@
+/* 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.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#include "asylum/resources/reaction.h"
+
+#include "asylum/resources/actor.h"
+#include "asylum/resources/worldstats.h"
+
+#include "asylum/system/sound.h"
+#include "asylum/system/speech.h"
+
+#include "asylum/views/scene.h"
+
+#include "asylum/asylum.h"
+#include "asylum/shared.h"
+
+namespace Asylum {
+
+Reaction::Reaction(AsylumEngine *engine) : _vm(engine) {}
+
+Reaction::~Reaction() {
+}
+
+void Reaction::run(int32 reactionIndex) {
+ //debugC(kDebugLevelSound, "[SPEC] Running special function for chapter %d",getWorld()->numChapter);
+
+ switch (getWorld()->chapter) {
+ default:
+ case kChapterNone:
+ // Do nothing
+ break;
+
+ case kChapter1:
+ chapter1(reactionIndex);
+ break;
+
+ case kChapter2:
+ chapter2(reactionIndex);
+ break;
+
+ case kChapter3:
+ chapter3(reactionIndex);
+ break;
+
+ case kChapter4:
+ chapter4(reactionIndex);
+ break;
+
+ case kChapter5:
+ chapter5(reactionIndex);
+ break;
+
+ case kChapter6:
+ chapter6(reactionIndex);
+ break;
+
+ case kChapter7:
+ chapter7(reactionIndex);
+ break;
+
+ case kChapter8:
+ chapter8(reactionIndex);
+ break;
+
+ case kChapter9:
+ chapter9(reactionIndex);
+ break;
+
+ case kChapter10:
+ chapter10(reactionIndex);
+ break;
+
+ case kChapter11:
+ chapter11(reactionIndex);
+ break;
+
+ case kChapter12:
+ case kChapter13:
+ chapter12(reactionIndex);
+ break;
+ }
+}
+
+//////////////////////////////////////////////////////////////////////////
+// Reaction functions
+//////////////////////////////////////////////////////////////////////////
+void Reaction::chapter1(int32 reactionIndex) {
+ switch (reactionIndex) {
+ default:
+ play(0);
+ break;
+
+ case 0:
+ play(61);
+ break;
+
+ case 1:
+ play(69);
+ break;
+
+ case 2:
+ play(0);
+ break;
+ }
+}
+
+void Reaction::chapter2(int32 reactionIndex) {
+ switch (reactionIndex) {
+ default:
+ play(0);
+ break;
+
+ case 0:
+ play(107);
+ break;
+
+ case 1:
+ play(134);
+ break;
+
+ case 2:
+ play(104);
+ break;
+
+ case 3:
+ play(113);
+ break;
+
+ case 4:
+ play(_vm->isGameFlagSet(kGameFlag186) ? 362 : 110);
+ break;
+
+ case 5:
+ play(112);
+ break;
+
+ case 6:
+ play(117);
+ break;
+
+ case 7:
+ play(109);
+ break;
+
+ case 8:
+ play(108);
+ break;
+
+ case 9:
+ play(111);
+ break;
+
+ case 10:
+ play(106);
+ break;
+ }
+}
+
+void Reaction::chapter3(int32 reactionIndex) {
+ switch (reactionIndex) {
+ default:
+ play(reactionIndex);
+ break;
+
+ case 0:
+ play(170);
+ break;
+
+ case 1:
+ play(182);
+ break;
+
+ case 2:
+ play(181);
+ break;
+
+ case 3:
+ play(172);
+ break;
+
+ case 4:
+ play(171);
+ break;
+
+ case 5:
+ play(169);
+ break;
+ }
+}
+
+void Reaction::chapter4(int32 reactionIndex) {
+ switch (reactionIndex) {
+ default:
+ play(0);
+ break;
+
+ case 0:
+ play(61);
+ break;
+
+ case 1:
+ play((getScene()->getActor()->getNumberValue01() != 1) ? 65 : 64);
+ break;
+
+ case 2:
+ play(66);
+ break;
+
+ case 3:
+ play(67);
+ break;
+
+ case 4:
+ play(68);
+ break;
+
+ case 5:
+ play(69);
+ break;
+
+ case 6:
+ play(70);
+ break;
+
+ case 7:
+ play(78);
+ break;
+
+ case 8:
+ play(77);
+ break;
+ }
+}
+
+void Reaction::chapter5(int32 reactionIndex) {
+ if (reactionIndex)
+ play(0);
+ else
+ play(197);
+}
+
+void Reaction::chapter6(int32 reactionIndex) {
+ switch (reactionIndex) {
+ default:
+ play(0);
+ break;
+
+ case 0:
+ play(59);
+ break;
+
+ case 1:
+ play(81);
+ break;
+
+ case 2:
+ play(60);
+ break;
+
+ case 3:
+ play(84);
+ break;
+
+ case 4:
+ play(88);
+ break;
+
+ case 5:
+ play(54);
+ break;
+
+ case 6:
+ play(74);
+ break;
+
+ case 7:
+ play(139);
+ break;
+
+ case 8:
+ play(97);
+ break;
+
+ case 9:
+ play(121);
+ break;
+ }
+}
+
+void Reaction::chapter7(int32 reactionIndex) {
+ switch (reactionIndex) {
+ default:
+ play(0);
+ break;
+
+ case 0:
+ play(239);
+ break;
+
+ case 1:
+ play(234);
+ break;
+
+ case 2:
+ play(249);
+ break;
+
+ case 3:
+ play(259);
+ break;
+
+ case 4:
+ play(260);
+ break;
+
+ case 5:
+ play(272);
+ break;
+
+ case 6:
+ play(237);
+ break;
+
+ case 7:
+ play(262);
+ break;
+ }
+}
+
+void Reaction::chapter8(int32 reactionIndex) {
+ switch (reactionIndex) {
+ default:
+ play(0);
+ break;
+
+ case 0:
+ play(58);
+ break;
+
+ case 1:
+ play(59);
+ break;
+
+ case 2:
+ play(60);
+ break;
+
+ case 3:
+ play(111);
+ break;
+
+ case 4:
+ play(75);
+ break;
+
+ case 5:
+ play(76);
+ break;
+
+ case 6:
+ play(77);
+ break;
+
+ case 7:
+ play(78);
+ break;
+ }
+}
+
+void Reaction::chapter9(int32 reactionIndex) {
+ switch (reactionIndex) {
+ default:
+ play(0);
+ break;
+
+ case 0:
+ play(284);
+ break;
+
+ case 1:
+ play(285);
+ break;
+
+ case 2:
+ play(286);
+ break;
+
+ case 3:
+ play(329);
+ break;
+
+ case 4:
+ play(330);
+ break;
+
+ case 5:
+ play(331);
+ break;
+
+ case 6:
+ play(332);
+ break;
+
+ case 7:
+ play(322);
+ break;
+
+ case 9:
+ play(465);
+ break;
+ }
+}
+
+void Reaction::chapter10(int32 reactionIndex) {
+ switch (reactionIndex) {
+ default:
+ play(0);
+ break;
+
+ case 0:
+ case 1:
+ case 2:
+ case 3:
+ case 4:
+ play(91 + reactionIndex);
+ break;
+ }
+}
+
+void Reaction::chapter11(int32 reactionIndex) {
+ switch (reactionIndex) {
+ default:
+ play(0);
+ break;
+
+ case 0:
+ play(69);
+ break;
+
+ case 1:
+ play(70);
+ break;
+
+ case 2:
+ play(78);
+ break;
+ }
+}
+
+void Reaction::chapter12(int32 reactionIndex) {
+ play(0);
+}
+
+//////////////////////////////////////////////////////////////////////////
+// Utils
+//////////////////////////////////////////////////////////////////////////
+void Reaction::play(int32 index) {
+ ResourceId resourceId = kResourceNone;
+
+ switch (getWorld()->actorType) {
+ default:
+ resourceId = (ResourceId)index;
+ break;
+
+ case kActorMax:
+ resourceId = MAKE_RESOURCE(kResourcePackSpeech, index < 259 ? index : index - 9);
+ break;
+
+ case kActorSarah:
+ resourceId = MAKE_RESOURCE(kResourcePackSpeechOther, index + 1927);
+ break;
+
+ case kActorCyclops:
+ resourceId = MAKE_RESOURCE(kResourcePackSpeechOther, index + 2084);
+ break;
+
+ case kActorAztec:
+ resourceId = MAKE_RESOURCE(kResourcePackSpeechOther, index + 2234);
+ break;
+ }
+
+ if (getSpeech()->getSoundResourceId() == resourceId || !getSound()->isPlaying(resourceId))
+ getSpeech()->playPlayer(index);
+}
+
+} // End of namespace Asylum
diff --git a/engines/asylum/resources/reaction.h b/engines/asylum/resources/reaction.h
new file mode 100644
index 0000000000..778f51e0b2
--- /dev/null
+++ b/engines/asylum/resources/reaction.h
@@ -0,0 +1,69 @@
+/* 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.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#ifndef ASYLUM_REACTION_H
+#define ASYLUM_REACTION_H
+
+#include "common/scummsys.h"
+
+namespace Asylum {
+
+class AsylumEngine;
+
+class Reaction {
+public:
+ Reaction(AsylumEngine *engine);
+ virtual ~Reaction();
+
+ void run(int32 reactionIndex);
+
+private:
+ AsylumEngine* _vm;
+
+ //////////////////////////////////////////////////////////////////////////
+ // Reaction functions
+ //////////////////////////////////////////////////////////////////////////
+ void chapter1(int32 reactionIndex);
+ void chapter2(int32 reactionIndex);
+ void chapter3(int32 reactionIndex);
+ void chapter4(int32 reactionIndex);
+ void chapter5(int32 reactionIndex);
+ void chapter6(int32 reactionIndex);
+ void chapter7(int32 reactionIndex);
+ void chapter8(int32 reactionIndex);
+ void chapter9(int32 reactionIndex);
+ void chapter10(int32 reactionIndex);
+ void chapter11(int32 reactionIndex);
+ void chapter12(int32 reactionIndex);
+
+ //////////////////////////////////////////////////////////////////////////
+ // Utils
+ //////////////////////////////////////////////////////////////////////////
+ void play(int32 index);
+};
+
+} // End of namespace Asylum
+
+#endif // ASYLUM_REACTION_H
diff --git a/engines/asylum/shared.h b/engines/asylum/shared.h
index beeff7325f..4eff07fa79 100644
--- a/engines/asylum/shared.h
+++ b/engines/asylum/shared.h
@@ -35,6 +35,7 @@ enum GameFlag {
kGameFlag4 = 4,
kGameFlag12 = 12,
kGameFlagScriptProcessing = 183,
+ kGameFlag186 = 186,
kGameFlagCommentLeavingCell = 214,
kGameFlag219 = 219,
kGameFlagSolveVCRBlowUpPuzzle = 220,
Commit: e91c49f188771f705f4fe942e9887fdc76ef3ff2
https://github.com/scummvm/scummvm/commit/e91c49f188771f705f4fe942e9887fdc76ef3ff2
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:16+02:00
Commit Message:
ASYLUM: Implement more playSoundChapter functions
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@527 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/resources/special.cpp
engines/asylum/resources/special.h
engines/asylum/shared.h
diff --git a/engines/asylum/resources/special.cpp b/engines/asylum/resources/special.cpp
index 6ff5746570..458cf3fbcf 100644
--- a/engines/asylum/resources/special.cpp
+++ b/engines/asylum/resources/special.cpp
@@ -50,14 +50,10 @@ Special::~Special() {}
void Special::run(Object* object, ActorIndex index) {
- //debugC(kDebugLevelSound, "[SPEC] Running special function for chapter %d",getWorld()->numChapter);
-
switch (getWorld()->chapter) {
default:
- error("[Special::runSpecial] Invalid chapter");
-
case kChapterNone:
- // Nothing to do here
+ // Nothing to do
break;
case kChapter1:
@@ -588,8 +584,6 @@ void Special::playChapterSound(Object *object, ActorIndex actorIndex) {
switch (getWorld()->chapter) {
default:
- error("[Special::playChapterSound] Invalid chapter");
-
case kChapterNone:
case kChapter5:
case kChapter9:
@@ -628,7 +622,37 @@ void Special::playChapterSound(Object *object, ActorIndex actorIndex) {
}
void Special::playSoundChapter1(Object *object, ActorIndex actorIndex) {
- //error("[Special::playSoundChapter1] Not implemented!");
+ if (actorIndex == kActorInvalid) {
+ switch(object->getId()) {
+ default:
+ break;
+
+ case kObjectRocker:
+ if (_vm->getRandomBit())
+ playSoundPanning(MAKE_RESOURCE(kResourcePackSpeechOther, 1847), 14, object);
+ break;
+
+ case kObjectGuyWobbles:
+ if (_vm->getRandomBit())
+ playSoundPanning(MAKE_RESOURCE(kResourcePackSpeechOther, 1887), 14, object);
+ break;
+
+ case kObjectPreAlphaNut:
+ if (_vm->getRandomBit())
+ playSoundPanning(MAKE_RESOURCE(kResourcePackSpeechOther, 1889 + rnd(3)), 14, object);
+ break;
+
+ case kObjectPreAlphaNut2:
+ if (_vm->getRandomBit())
+ playSoundPanning(MAKE_RESOURCE(kResourcePackSpeechOther, 1924 + rnd(3)), 14, object);
+ break;
+ }
+ } else {
+ // The original checks for actor indexes 1582 & 1584,
+ // but the scene data only has a maximum of 50 actors
+ if (actorIndex == 1582 || actorIndex == 1584)
+ error("[Special::playSoundChapter1] Called with invalid actor indexes!");
+ }
}
void Special::playSoundChapter2(Object *object, ActorIndex actorIndex) {
@@ -636,19 +660,292 @@ void Special::playSoundChapter2(Object *object, ActorIndex actorIndex) {
}
void Special::playSoundChapter3(Object *object, ActorIndex actorIndex) {
- error("[Special::playSoundChapter3] Not implemented!");
+ if (actorIndex == kActorInvalid) {
+ switch(object->getId()) {
+ default:
+ break;
+
+ case kObjectNPC024Church:
+ case kObjectNPC024Fountain:
+ if (_vm->getRandomBit())
+ playSoundPanning(MAKE_RESOURCE(kResourcePackSpeechOther, 1895), 17, object);
+ break;
+
+ case kObjectPreacherBob:
+ if (_vm->getRandomBit())
+ playSoundPanning(MAKE_RESOURCE(kResourcePackSpeechOther, 1896 + _vm->getRandomBit()), 14, object);
+ break;
+
+ case kObjectPreacherBobAssistant:
+ case kObjectNPC026OutOfWay:
+ if (_vm->getRandomBit())
+ playSoundPanning(MAKE_RESOURCE(kResourcePackSpeechOther, 1898), 18, object);
+ break;
+
+ case kObjectNPC027Sit:
+ case kObjectNPC027Dancing:
+ if (_vm->getRandomBit())
+ playSoundPanning(MAKE_RESOURCE(kResourcePackSpeechOther, 1899), 15, object);
+ break;
+
+ case kObjectNPC028Sit:
+ case kObjectNPC028Dancing:
+ if (_vm->getRandomBit())
+ playSoundPanning(MAKE_RESOURCE(kResourcePackSpeechOther, 1900), 15, object);
+ break;
+
+ case kObjectNPC029Sit:
+ if (_vm->getRandomBit())
+ playSoundPanning(MAKE_RESOURCE(kResourcePackSpeechOther, 1901), 8, object);
+ break;
+ }
+ } else {
+ Actor *actor = getScene()->getActor(actorIndex);
+
+ switch (actorIndex) {
+ default:
+ break;
+
+ case 1:
+ if (actor->getStatus() == kActorStatus9
+ && actor->isResourcePresent()
+ && actor->getFrameIndex() == 0)
+ playSoundPanning(MAKE_RESOURCE(kResourcePackSpeechOther, 1861), 22, actorIndex);
+ break;
+
+ case 2:
+ if (actor->getStatus() == kActorStatus9
+ && actor->isResourcePresent()
+ && actor->getFrameIndex() == 1)
+ playSoundPanning(MAKE_RESOURCE(kResourcePackSpeechOther, 1892), 16, actorIndex);
+ break;
+
+ case 3:
+ if (_vm->getRandomBit())
+ playSoundPanning(MAKE_RESOURCE(kResourcePackSpeechOther, 1893), 17, actorIndex);
+ break;
+
+ case 4:
+ if (_vm->getRandomBit())
+ playSoundPanning(MAKE_RESOURCE(kResourcePackSpeechOther, 1894), 17, actorIndex);
+ break;
+
+ case 5:
+ if (_vm->getRandomBit())
+ playSoundPanning(MAKE_RESOURCE(kResourcePackSpeechOther, 1902), 15, actorIndex);
+ break;
+ }
+ }
}
void Special::playSoundChapter4(Object *object, ActorIndex actorIndex) {
- error("[Special::playSoundChapter4] Not implemented!");
+ if (actorIndex == kActorInvalid) {
+ switch(object->getId()) {
+ default:
+ break;
+
+ case kObjectNPC032Sleeping:
+ if (_vm->getRandomBit())
+ playSoundPanning(MAKE_RESOURCE(kResourcePackSpeechOther, 1903), 14, object);
+ break;
+
+ case kObjectNPC032SQOutside:
+ case kObjectNPC032SQBigTop:
+ if (_vm->getRandomBit())
+ playSoundPanning(MAKE_RESOURCE(kResourcePackSpeechOther, 1904), 14, object);
+ break;
+
+ case kObjectNPC033Reading:
+ if (_vm->getRandomBit())
+ playSoundPanning(MAKE_RESOURCE(kResourcePackSpeechOther, 1879), 16, object);
+ break;
+
+ case kObjectTattooManSQ:
+ if (_vm->getRandomBit())
+ playSoundPanning(MAKE_RESOURCE(kResourcePackSpeechOther, 1884), 14, object);
+ break;
+
+ case kObjectStrongmanSQ:
+ case kObjectStrongmanLeft:
+ case kObjectStrongmanRight:
+ playSoundPanning(MAKE_RESOURCE(kResourcePackSpeechOther, 1885), 16, object);
+ break;
+
+ case kObjectStrongmanSQ2:
+ if (_vm->getRandomBit())
+ playSoundPanning(MAKE_RESOURCE(kResourcePackSpeechOther, 1886), 16, object);
+ break;
+
+ case kObjectInfernoSQ:
+ if (_vm->getRandomBit())
+ playSoundPanning(MAKE_RESOURCE(kResourcePackSpeechOther, 1905), 12, object);
+ break;
+
+ case kObjectJuggler:
+ playSoundPanning(MAKE_RESOURCE(kResourcePackSpeechOther, 1906), 12, object);
+ break;
+
+ case kObjectClownSQ:
+ if (_vm->getRandomBit())
+ playSoundPanning(MAKE_RESOURCE(kResourcePackSpeechOther, 1907), 10, object);
+ break;
+
+ case kObjectTrixieSQ:
+ if (_vm->getRandomBit())
+ playSoundPanning(MAKE_RESOURCE(kResourcePackSpeechOther, 1908), 12, object);
+ break;
+
+ case kObjectSimonSQ:
+ if (_vm->getRandomBit())
+ playSoundPanning(MAKE_RESOURCE(kResourcePackSpeechOther, 1909), 12, object);
+ break;
+
+ case kObjectFunTixSQ:
+ if (_vm->getRandomBit())
+ playSoundPanning(MAKE_RESOURCE(kResourcePackSpeechOther, 1913), 10, object);
+ break;
+
+ case kObjectFreakTixSQUp:
+ case kObjectFreakTixSQDown:
+ if (_vm->getRandomBit())
+ playSoundPanning(MAKE_RESOURCE(kResourcePackSpeechOther, 1914), 9, object);
+ break;
+
+ case kObjectFortTellerSQ:
+ if (_vm->getRandomBit())
+ playSoundPanning(MAKE_RESOURCE(kResourcePackSpeechOther, 1915), 15, object);
+ break;
+
+ case kObjectRingTossSQ:
+ if (_vm->getRandomBit())
+ playSoundPanning(MAKE_RESOURCE(kResourcePackSpeechOther, 1916), 10, object);
+ break;
+
+ case kObjectPigShootSQ:
+ if (_vm->getRandomBit())
+ playSoundPanning(MAKE_RESOURCE(kResourcePackSpeechOther, 1917), 10, object);
+ break;
+
+ case kObjectKnockDownSQ:
+ if (_vm->isGameFlagNotSet(kGameFlag358) && _vm->getRandomBit())
+ playSoundPanning(MAKE_RESOURCE(kResourcePackSpeechOther, 1918), 10, object);
+ break;
+
+ case kObjectPretZoolSQ:
+ if (_vm->getRandomBit())
+ playSoundPanning(MAKE_RESOURCE(kResourcePackSpeechOther, 1919), 14, object);
+ break;
+
+ case kObjectTimberSQ:
+ if (_vm->getRandomBit())
+ playSoundPanning(MAKE_RESOURCE(kResourcePackSpeechOther, 1920), 14, object);
+ break;
+
+ case kObjectTwinsSQ:
+ if (_vm->getRandomBit())
+ playSoundPanning(MAKE_RESOURCE(kResourcePackSpeechOther, 1921), 20, object);
+ break;
+
+ case kObjectSeanSQ:
+ if (_vm->getRandomBit())
+ playSoundPanning(MAKE_RESOURCE(kResourcePackSpeechOther, 1923), 16, object);
+ break;
+
+ case kObjectMomAndPopSQ:
+ if (_vm->getRandomBit())
+ playSoundPanning(MAKE_RESOURCE(kResourcePackSpeechOther, 1852), 15, object);
+
+ if (_vm->getRandomBit())
+ playSoundPanning(MAKE_RESOURCE(kResourcePackSpeechOther, 1862), 15, object);
+ break;
+ }
+ } else {
+ switch (actorIndex) {
+ default:
+ break;
+
+ case 1:
+ if (_vm->getRandomBit())
+ playSoundPanning(MAKE_RESOURCE(kResourcePackSpeechOther, 1910), 14, actorIndex);
+ break;
+
+ case 2:
+ if (_vm->getRandomBit())
+ playSoundPanning(MAKE_RESOURCE(kResourcePackSpeechOther, 1911), 14, actorIndex);
+ break;
+
+ case 3:
+ if (_vm->getRandomBit())
+ playSoundPanning(MAKE_RESOURCE(kResourcePackSpeechOther, 1912), 14, actorIndex);
+ break;
+ }
+ }
}
void Special::playSoundChapter6(Object *object, ActorIndex actorIndex) {
- error("[Special::playSoundChapter6] Not implemented!");
+ if (actorIndex != kActorInvalid)
+ return;
+
+ switch(object->getId()) {
+ default:
+ break;
+
+ case kObjectGravinSQCyber:
+ if (_vm->getRandomBit())
+ playSoundPanning(MAKE_RESOURCE(kResourcePackSpeechOther, 1880), 14, object);
+ break;
+
+ case kObjectGravinWorkMachine:
+ if (_vm->getRandomBit())
+ playSoundPanning(MAKE_RESOURCE(kResourcePackSpeechOther, 1880), 14, object);
+ break;
+
+ case kObjectNPC062GritzaSQ:
+ if (_vm->getRandomBit())
+ playSoundPanning(MAKE_RESOURCE(kResourcePackSpeechOther, 1881), 12, object);
+ break;
+
+ case kObjectNPC063GrundleSQ:
+ if (_vm->getRandomBit())
+ playSoundPanning(MAKE_RESOURCE(kResourcePackSpeechOther, 1882), 12, object);
+ break;
+
+ case kObjectNPC064GrellaSQ:
+ if (_vm->getRandomBit())
+ playSoundPanning(MAKE_RESOURCE(kResourcePackSpeechOther, 1883), 12, object);
+ break;
+
+ case kObjectNPC065SQ:
+ if (_vm->getRandomBit())
+ playSoundPanning(MAKE_RESOURCE(kResourcePackSpeechOther, 1868), 12, object);
+ break;
+
+ case kObjectNPC066SQ:
+ if (_vm->getRandomBit())
+ playSoundPanning(MAKE_RESOURCE(kResourcePackSpeechOther, 1867), 12, object);
+ break;
+ }
}
void Special::playSoundChapter7(Object *object, ActorIndex actorIndex) {
- error("[Special::playSoundChapter7] Not implemented!");
+ if (actorIndex != kActorInvalid)
+ return;
+
+ switch(object->getId()) {
+ default:
+ break;
+
+ case kObjectDrawers3:
+ if (_vm->isGameFlagNotSet(kGameFlag405) && _vm->isGameFlagSet(kGameFlag423))
+ if (rnd(100) < 20)
+ playSoundPanning(MAKE_RESOURCE(kResourcePackSpeechOther, 1865), 18, object);
+ break;
+
+ case kObjectOldMan3:
+ if (rnd(100) < 20)
+ playSoundPanning(MAKE_RESOURCE(kResourcePackSpeechOther, 1866), 18, object);
+ break;
+ }
}
void Special::playSoundChapter8(Object *object, ActorIndex actorIndex) {
@@ -662,6 +959,22 @@ void Special::setPaletteGamma(ResourceId palette1, ResourceId palette2) {
error("[Special::setPaletteGamma] Not implemented!");
}
+void Special::playSoundPanning(ResourceId resourceId, int32 attenuation, Object *object) {
+ error("[Special::playSoundPanning] Not implemented!");
+}
+
+void Special::playSoundPanning(ResourceId resourceId, int32 attenuation, ActorIndex actorIndex) {
+ error("[Special::playSoundPanning] Not implemented!");
+}
+
+void Special::updateObjectFlag(ObjectId id) {
+ error("[Special::updateObjectFlag] Not implemented!");
+}
+
+void Special::checkFlags(ObjectId id, GameFlag flag1, GameFlag flag2, GameFlag flag3, GameFlag flag4, int *val1, int *val2, GameFlag flag5, int *val3) {
+ error("[Special::checkFlags] Not implemented!");
+}
+
//////////////////////////////////////////////////////////////////////////
// Helpers
//////////////////////////////////////////////////////////////////////////
diff --git a/engines/asylum/resources/special.h b/engines/asylum/resources/special.h
index f4d7479b17..a4c8e658a8 100644
--- a/engines/asylum/resources/special.h
+++ b/engines/asylum/resources/special.h
@@ -79,6 +79,12 @@ private:
//////////////////////////////////////////////////////////////////////////
void setPaletteGamma(ResourceId palette1, ResourceId palette2);
+ void playSoundPanning(ResourceId resourceId, int32 attenuation, Object *object);
+ void playSoundPanning(ResourceId resourceId, int32 attenuation, ActorIndex actorIndex);
+
+ void updateObjectFlag(ObjectId id);
+ void checkFlags(ObjectId id, GameFlag flag1, GameFlag flag2, GameFlag flag3, GameFlag flag4, int *val1, int *val2, GameFlag flag5, int *val3);
+
//////////////////////////////////////////////////////////////////////////
// Helpers
//////////////////////////////////////////////////////////////////////////
diff --git a/engines/asylum/shared.h b/engines/asylum/shared.h
index 4eff07fa79..d62f7f8cfd 100644
--- a/engines/asylum/shared.h
+++ b/engines/asylum/shared.h
@@ -48,9 +48,12 @@ enum GameFlag {
kGameFlag247 = 247,
kGameFlag248 = 248,
kGameFlag279 = 279,
+ kGameFlag358 = 358,
kGameFlag368 = 368,
kGameFlag371 = 371,
kGameFlag387 = 387,
+ kGameFlag405 = 405,
+ kGameFlag423 = 423,
kGameFlag438 = 438,
kGameFlag439 = 439,
kGameFlag440 = 440,
@@ -298,7 +301,19 @@ enum ObjectId {
kObjectHeadBanger = 101,
kObjectAngelFlares = 112,
kObjectGuyFalls = 434,
+ kObjectGuyWobbles = 405,
+ kObjectRocker = 441,
kObjectOpeningGate = 485,
+ kObjectPreacherBobAssistant = 802,
+ kObjectPreacherBob = 803,
+ kObjectNPC024Church = 816,
+ kObjectNPC024Fountain = 825,
+ kObjectNPC027Sit = 838,
+ kObjectNPC028Sit = 839,
+ kObjectNPC029Sit = 840,
+ kObjectNPC027Dancing = 844,
+ kObjectNPC028Dancing = 845,
+ kObjectNPC026OutOfWay = 861,
kObjectBubbles = 1185,
kObjectGlow = 1186,
kObjectDome = 1187,
@@ -306,10 +321,38 @@ enum ObjectId {
kObjectRing = 1189,
kObjectBallMovesUpright = 1190,
kObjectGearsLightUp = 1191,
+ kObjectNPC032Sleeping = 1250,
+ kObjectNPC032SQOutside = 1254,
+ kObjectNPC032SQBigTop = 1256,
kObjectGlobe = 1261,
+ kObjectDrawers3 = 1276,
kObjectFreezerHallInterior = 1337,
kObjectNPC033StartEnc = 1338,
kObjectNPC033GetBook = 1343,
+ kObjectNPC033Reading = 1344,
+ kObjectOldMan3 = 1377,
+ kObjectTattooManSQ = 1391, // NPC 34
+ kObjectStrongmanSQ = 1402, // NPC 35
+ kObjectStrongmanSQ2 = 1405, // NPC 35
+ kObjectInfernoSQ = 1408, // NPC 36
+ kObjectJuggler = 1424, // NPC 37
+ kObjectClownSQ = 1428, // NPC 38
+ kObjectTrixieSQ = 1432, // NPC 39
+ kObjectSimonSQ = 1434, // NPC 40
+ kObjectFunTixSQ = 1437, // NPC 44
+ kObjectFreakTixSQUp = 1439, // NPC 45
+ kObjectFreakTixSQDown = 1440, // NPC 45
+ kObjectFortTellerSQ = 1444, // NPC 45
+ kObjectStrongmanLeft = 1449, // NPC 35
+ kObjectStrongmanRight = 1450, // NPC 35
+ kObjectRingTossSQ = 1451, // NPC 47
+ kObjectKnockDownSQ = 1455, // NPC 47
+ kObjectPigShootSQ = 1456, // NPC 47
+ kObjectPretZoolSQ = 1461, // NPC 48
+ kObjectTimberSQ = 1462, // NPC 49
+ kObjectTwinsSQ = 1465, // NPC 50
+ kObjectSeanSQ = 1468, // NPC 51
+ kObjectMomAndPopSQ = 1470, // NPCs 52-53
kObjectCrow1FlysAway = 1485,
kObjectCrow1Pecks = 1486,
kObjectCrow2AmbientPecks = 1495,
@@ -318,6 +361,8 @@ enum ObjectId {
kObjectCrow3Pecks = 1503,
kObjectCrow4FlysAway = 1506,
kObjectCrow4Pecks = 1507,
+ kObjectPreAlphaNut = 1582,
+ kObjectPreAlphaNut2 = 1584,
kObjectWheel1 = 2113,
kObjectWheel2 = 2114,
kObjectWheel3 = 2115,
@@ -325,6 +370,13 @@ enum ObjectId {
kObjectWheel5 = 2117,
kObjectWheel6 = 2118,
kObjectWheel7 = 2119,
+ kObjectGravinSQCyber = 2324,
+ kObjectGravinWorkMachine = 2337,
+ kObjectNPC062GritzaSQ = 2399,
+ kObjectNPC063GrundleSQ = 2410,
+ kObjectNPC064GrellaSQ = 2418,
+ kObjectNPC065SQ = 2469,
+ kObjectNPC066SQ = 2504,
kObjectBodySlides1 = 2514,
kObjectBodySlides2 = 2515,
kObjectBodySlides3 = 2516,
Commit: d95ec4be4497b2f9214f3575f9345d385b94b9e8
https://github.com/scummvm/scummvm/commit/d95ec4be4497b2f9214f3575f9345d385b94b9e8
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:16+02:00
Commit Message:
ASYLUM: Implement Special::playSoundPanning
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@528 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/resources/object.h
engines/asylum/resources/special.cpp
engines/asylum/shared.h
diff --git a/engines/asylum/resources/object.h b/engines/asylum/resources/object.h
index 1063ea973f..27f87e724e 100644
--- a/engines/asylum/resources/object.h
+++ b/engines/asylum/resources/object.h
@@ -53,8 +53,10 @@ public:
void setFrameIndex(int32 index) { _frameIndex = index; }
void setPriority(int32 priority) { _priority = priority; }
+ void setSoundResourceId(ResourceId id) { _soundResourceId = id; }
void setField67C(int32 val) { _field_67C = val; }
+ void setField6A4(int32 val) { _field_6A4 = val; }
Common::Rect *getBoundingRect() { return &_boundingRect; }
uint32 getFrameIndex() { return _frameIndex; }
diff --git a/engines/asylum/resources/special.cpp b/engines/asylum/resources/special.cpp
index 458cf3fbcf..78becd9dae 100644
--- a/engines/asylum/resources/special.cpp
+++ b/engines/asylum/resources/special.cpp
@@ -32,6 +32,7 @@
#include "asylum/resources/worldstats.h"
#include "asylum/system/cursor.h"
+#include "asylum/system/graphics.h"
#include "asylum/system/speech.h"
#include "asylum/views/scene.h"
@@ -960,11 +961,67 @@ void Special::setPaletteGamma(ResourceId palette1, ResourceId palette2) {
}
void Special::playSoundPanning(ResourceId resourceId, int32 attenuation, Object *object) {
- error("[Special::playSoundPanning] Not implemented!");
+ int32 adjustedVolume = Config.voiceVolume;
+ int32 x = 0;
+ int32 y = 0;
+
+ switch (object->getId()) {
+ default: {
+ GraphicResource *resource = new GraphicResource(_vm, object->getResourceId());
+ GraphicFrame *frame = resource->getFrame(object->getFrameIndex());
+
+ x = (frame->getWidth() >> 1) + object->x;
+ y = (frame->getHeight() >> 1) + object->y;
+
+ delete resource;
+ }
+ break;
+
+ case kObjectDennisStatus:
+ x = 1382;
+ y = 1041;
+ break;
+
+ case kObjectSailorBoy:
+ x = 1646;
+ y = 1220;
+ break;
+
+ case kObjectSuckerSittingStatus:
+ x = 1376;
+ y = 1148;
+ break;
+
+ case kObjectDennisStatus2:
+ x = 175;
+ y = 617;
+ break;
+ }
+
+ // Calculate volume adjustment
+ adjustedVolume += getSound()->calculateVolumeAdjustement(x, y, attenuation, 0);
+
+ // Calculate panning
+ int32 panning = getSound()->calculatePanningAtPoint(x, y);
+
+ // Adjust object properties
+ object->setSoundResourceId(resourceId);
+ object->setField6A4(attenuation);
+
+ getSound()->playSound(resourceId, false, adjustedVolume, panning);
}
void Special::playSoundPanning(ResourceId resourceId, int32 attenuation, ActorIndex actorIndex) {
- error("[Special::playSoundPanning] Not implemented!");
+ Actor *actor = getScene()->getActor(actorIndex);
+
+ // Calculate volume adjustment
+ int32 adjustedVolume = Config.voiceVolume;
+ adjustedVolume += getSound()->calculateVolumeAdjustement(actor->x1, actor->y1, attenuation, 0);
+
+ // Calculate panning
+ int32 panning = getSound()->calculatePanningAtPoint(actor->x1 + actor->x2, actor->y1 + actor->y2);
+
+ getSound()->playSound(resourceId, false, adjustedVolume, panning);
}
void Special::updateObjectFlag(ObjectId id) {
diff --git a/engines/asylum/shared.h b/engines/asylum/shared.h
index d62f7f8cfd..a68e251e7d 100644
--- a/engines/asylum/shared.h
+++ b/engines/asylum/shared.h
@@ -314,6 +314,9 @@ enum ObjectId {
kObjectNPC027Dancing = 844,
kObjectNPC028Dancing = 845,
kObjectNPC026OutOfWay = 861,
+ kObjectDennisStatus = 1011,
+ kObjectSailorBoy = 1013,
+ kObjectSuckerSittingStatus = 1084,
kObjectBubbles = 1185,
kObjectGlow = 1186,
kObjectDome = 1187,
@@ -361,6 +364,7 @@ enum ObjectId {
kObjectCrow3Pecks = 1503,
kObjectCrow4FlysAway = 1506,
kObjectCrow4Pecks = 1507,
+ kObjectDennisStatus2 = 1580,
kObjectPreAlphaNut = 1582,
kObjectPreAlphaNut2 = 1584,
kObjectWheel1 = 2113,
Commit: d5e3c4536c9926bba41dae51ed11182a03ad90d9
https://github.com/scummvm/scummvm/commit/d5e3c4536c9926bba41dae51ed11182a03ad90d9
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:16+02:00
Commit Message:
ASYLUM: Remove checks for sound cache
All our files are on disk, so there is not need to check for cached music resources
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@529 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/resources/actionlist.cpp
engines/asylum/resources/actor.cpp
engines/asylum/system/sound.cpp
engines/asylum/system/sound.h
engines/asylum/views/scene.cpp
diff --git a/engines/asylum/resources/actionlist.cpp b/engines/asylum/resources/actionlist.cpp
index 3a3eff6e57..7739bfce19 100644
--- a/engines/asylum/resources/actionlist.cpp
+++ b/engines/asylum/resources/actionlist.cpp
@@ -894,8 +894,7 @@ IMPLEMENT_OPCODE(PlayMovie) {
}
if (!check && getScene()->matteVar2 == 0 && getWorld()->musicCurrentResourceIndex != kResourceMusicStopped)
- if (_vm->sound()->isCacheOk())
- _vm->sound()->playMusic(MAKE_RESOURCE(kResourcePackMusic, getWorld()->musicCurrentResourceIndex));
+ _vm->sound()->playMusic(MAKE_RESOURCE(kResourcePackMusic, getWorld()->musicCurrentResourceIndex));
getCursor()->show();
getScene()->matteVar2 = 0;
diff --git a/engines/asylum/resources/actor.cpp b/engines/asylum/resources/actor.cpp
index 192849ed37..58091b4999 100644
--- a/engines/asylum/resources/actor.cpp
+++ b/engines/asylum/resources/actor.cpp
@@ -328,20 +328,18 @@ void Actor::update() {
player->setFrameIndex(0);
getScene()->getActor(0)->setLastScreenUpdate(_vm->getTick());
- Sound *sound = _vm->sound();
- if (sound->isCacheOk())
- sound->playMusic(MAKE_RESOURCE(kResourcePackMusic, 1));
+ getSound()->playMusic(MAKE_RESOURCE(kResourcePackMusic, 1));
getWorld()->musicCurrentResourceIndex = 1;
- if (sound->isPlaying(getWorld()->soundResourceIds[7]))
- sound->stopSound(getWorld()->soundResourceIds[7]);
+ if (getSound()->isPlaying(getWorld()->soundResourceIds[7]))
+ getSound()->stopSound(getWorld()->soundResourceIds[7]);
- if (sound->isPlaying(getWorld()->soundResourceIds[6]))
- sound->stopSound(getWorld()->soundResourceIds[6]);
+ if (getSound()->isPlaying(getWorld()->soundResourceIds[6]))
+ getSound()->stopSound(getWorld()->soundResourceIds[6]);
- if (sound->isPlaying(getWorld()->soundResourceIds[5]))
- sound->stopSound(getWorld()->soundResourceIds[5]);
+ if (getSound()->isPlaying(getWorld()->soundResourceIds[5]))
+ getSound()->stopSound(getWorld()->soundResourceIds[5]);
_vm->setGameFlag(kGameFlag1131);
} else {
diff --git a/engines/asylum/system/sound.cpp b/engines/asylum/system/sound.cpp
index 621b1a1a74..2be357e0b7 100644
--- a/engines/asylum/system/sound.cpp
+++ b/engines/asylum/system/sound.cpp
@@ -101,7 +101,7 @@ int32 Sound::getAdjustedVolume(int32 volume) {
}
int32 Sound::calculateVolumeAdjustement(int32 x, int32 y, int32 a5, int32 a6) {
- error("[Sound::calculateVolume] not implemented");
+ error("[Sound::calculateVolumeAdjustement] not implemented");
}
void Sound::setPanning(ResourceId resourceId, int32 panning) {
diff --git a/engines/asylum/system/sound.h b/engines/asylum/system/sound.h
index c2fad1cba5..d0adfd58b5 100644
--- a/engines/asylum/system/sound.h
+++ b/engines/asylum/system/sound.h
@@ -141,9 +141,6 @@ public:
*/
bool isPlaying() { return _mixer->isSoundHandleActive(_soundHandle); }
- // TODO Make sure this is needed
- bool isCacheOk() { warning("[Sound::isCacheOk] not implemented!"); return true; }
-
private:
AsylumEngine *_vm;
diff --git a/engines/asylum/views/scene.cpp b/engines/asylum/views/scene.cpp
index 63410d6fb1..68d518f311 100644
--- a/engines/asylum/views/scene.cpp
+++ b/engines/asylum/views/scene.cpp
@@ -189,7 +189,7 @@ void Scene::enter(ResourcePackId packId) {
// Play intro music
ResourceId musicId = kResourceNone;
- if (_ws->musicCurrentResourceIndex != kResourceMusicStopped && _ws->chapter != kChapter1 && getSound()->isCacheOk())
+ if (_ws->musicCurrentResourceIndex != kResourceMusicStopped && _ws->chapter != kChapter1)
musicId = MAKE_RESOURCE(kResourcePackMusic, _ws->musicCurrentResourceIndex);
getSound()->playMusic(musicId);
Commit: a40c1e7484285d1e218f189165aaee467045b5f8
https://github.com/scummvm/scummvm/commit/a40c1e7484285d1e218f189165aaee467045b5f8
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:16+02:00
Commit Message:
ASYLUM: Implement changeMusic
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@530 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/resources/actionlist.cpp
engines/asylum/resources/worldstats.cpp
engines/asylum/resources/worldstats.h
engines/asylum/shared.h
engines/asylum/system/sound.cpp
engines/asylum/system/sound.h
engines/asylum/views/scene.cpp
diff --git a/engines/asylum/resources/actionlist.cpp b/engines/asylum/resources/actionlist.cpp
index 7739bfce19..bc01aecc36 100644
--- a/engines/asylum/resources/actionlist.cpp
+++ b/engines/asylum/resources/actionlist.cpp
@@ -893,7 +893,7 @@ IMPLEMENT_OPCODE(PlayMovie) {
check = true;
}
- if (!check && getScene()->matteVar2 == 0 && getWorld()->musicCurrentResourceIndex != kResourceMusicStopped)
+ if (!check && getScene()->matteVar2 == 0 && getWorld()->musicCurrentResourceIndex != kMusicStopped)
_vm->sound()->playMusic(MAKE_RESOURCE(kResourcePackMusic, getWorld()->musicCurrentResourceIndex));
getCursor()->show();
@@ -940,7 +940,7 @@ IMPLEMENT_OPCODE(ChangeMusicById) {
//////////////////////////////////////////////////////////////////////////
// Opcode 0x33
IMPLEMENT_OPCODE(StopMusic) {
- _vm->sound()->changeMusic(kResourceMusicStopped, 0);
+ _vm->sound()->changeMusic(kMusicStopped, 0);
}
//////////////////////////////////////////////////////////////////////////
diff --git a/engines/asylum/resources/worldstats.cpp b/engines/asylum/resources/worldstats.cpp
index 3f7e85f407..380314f8f1 100644
--- a/engines/asylum/resources/worldstats.cpp
+++ b/engines/asylum/resources/worldstats.cpp
@@ -139,7 +139,7 @@ void WorldStats::load(Common::SeekableReadStream *stream) {
numAmbientSound = stream->readSint32LE();
musicStatus = stream->readSint32LE();
- musicCurrentResourceIndex = stream->readSint32LE();
+ musicCurrentResourceIndex = (ResourceId)stream->readSint32LE();
musicFlag = stream->readSint32LE();
musicResourceId = (ResourceId)stream->readSint32LE();
musicStatusExt = stream->readSint32LE();
diff --git a/engines/asylum/resources/worldstats.h b/engines/asylum/resources/worldstats.h
index 133da2e7ea..62870e36be 100644
--- a/engines/asylum/resources/worldstats.h
+++ b/engines/asylum/resources/worldstats.h
@@ -105,7 +105,7 @@ public:
AmbientSoundItem ambientSounds[15];
int32 numAmbientSound;
int32 musicStatus;
- int32 musicCurrentResourceIndex;
+ uint32 musicCurrentResourceIndex;
int32 musicFlag;
ResourceId musicResourceId;
int32 musicStatusExt;
diff --git a/engines/asylum/shared.h b/engines/asylum/shared.h
index a68e251e7d..9c68e2ec30 100644
--- a/engines/asylum/shared.h
+++ b/engines/asylum/shared.h
@@ -129,8 +129,11 @@ enum ResourcePackId {
#define MAKE_RESOURCE(pack, index) (ResourceId)((0x80000000 + ((pack) << 16)) + (index))
enum ResourceId {
- kResourceNone = 0,
- kResourceMusicStopped = 0xFFFFFD66 // -666
+ kResourceNone = 0
+};
+
+enum MusicIndex {
+ kMusicStopped = 0xFFFFFD66 // -666
};
//////////////////////////////////////////////////////////////////////////
diff --git a/engines/asylum/system/sound.cpp b/engines/asylum/system/sound.cpp
index 2be357e0b7..9e07cfdd1d 100644
--- a/engines/asylum/system/sound.cpp
+++ b/engines/asylum/system/sound.cpp
@@ -27,6 +27,10 @@
#include "asylum/system/config.h"
#include "asylum/system/sound.h"
+#include "asylum/resources/worldstats.h"
+
+#include "asylum/views/scene.h"
+
#include "asylum/asylum.h"
#include "asylum/respack.h"
@@ -39,7 +43,6 @@
namespace Asylum {
Sound::Sound(AsylumEngine *engine, Audio::Mixer *mixer) : _vm(engine), _mixer(mixer) {
- _currentMusicResIndex = kResourceMusicStopped;
}
Sound::~Sound() {
@@ -260,8 +263,12 @@ void Sound::playMusic(ResourceId resourceId, int32 volume) {
playSoundData(Audio::Mixer::kMusicSoundType, &_musicHandle, resource->data, resource->size, true, volume, 0);
}
-void Sound::changeMusic(ResourceId resourceId, int32 musicStatusExt) {
- error("[Sound::changeMusic] not implemented!");
+void Sound::changeMusic(uint32 index, int32 musicStatusExt) {
+ if (index != getWorld()->musicCurrentResourceIndex) {
+ getWorld()->musicCurrentResourceIndex = index;
+ getWorld()->musicStatusExt = musicStatusExt;
+ getWorld()->musicFlag = 1;
+ }
}
void Sound::stopMusic() {
diff --git a/engines/asylum/system/sound.h b/engines/asylum/system/sound.h
index d0adfd58b5..3bc8e974f8 100644
--- a/engines/asylum/system/sound.h
+++ b/engines/asylum/system/sound.h
@@ -108,7 +108,17 @@ public:
void playSpeech(ResourceId resourceId);
void playMusic(ResourceId resourceId, int32 volume = Config.musicVolume);
- void changeMusic(ResourceId resourceId, int32 musicStatusExt);
+
+ /**
+ * Change music
+ *
+ * @param index Zero-based index of the music
+ * @param musicStatusExt The music status.
+ */
+ void changeMusic(uint32 index, int32 musicStatusExt);
+
+
+
void stopMusic();
void setVolume(ResourceId resourceId, double volume);
@@ -152,14 +162,6 @@ private:
Common::Array<SoundBufferItem> _soundBuffer;
- /**
- * The resource pointer for the currently playing music file.
- * This was originally a scene variable, but it makes more sense
- * to track it uniquely, as this doesn't involve initializing the
- * scene just to set a single variable
- */
- uint32 _currentMusicResIndex;
-
/**
* Find the index within the _soundBuffer array of the
* sound sample with provided id.
diff --git a/engines/asylum/views/scene.cpp b/engines/asylum/views/scene.cpp
index 68d518f311..b3edfa5375 100644
--- a/engines/asylum/views/scene.cpp
+++ b/engines/asylum/views/scene.cpp
@@ -189,7 +189,7 @@ void Scene::enter(ResourcePackId packId) {
// Play intro music
ResourceId musicId = kResourceNone;
- if (_ws->musicCurrentResourceIndex != kResourceMusicStopped && _ws->chapter != kChapter1)
+ if (_ws->musicCurrentResourceIndex != kMusicStopped && _ws->chapter != kChapter1)
musicId = MAKE_RESOURCE(kResourcePackMusic, _ws->musicCurrentResourceIndex);
getSound()->playMusic(musicId);
Commit: 4d383def95467143533435ad5f020eaf38604482
https://github.com/scummvm/scummvm/commit/4d383def95467143533435ad5f020eaf38604482
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:16+02:00
Commit Message:
ASYLUM: Add support for shared sound resources
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@531 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/asylum.cpp
engines/asylum/resources/reaction.cpp
engines/asylum/resources/special.cpp
engines/asylum/respack.cpp
engines/asylum/respack.h
engines/asylum/shared.h
engines/asylum/system/speech.cpp
diff --git a/engines/asylum/asylum.cpp b/engines/asylum/asylum.cpp
index 19c4d609bf..f4914792ea 100644
--- a/engines/asylum/asylum.cpp
+++ b/engines/asylum/asylum.cpp
@@ -106,6 +106,7 @@ Common::Error AsylumEngine::run() {
// Create resource manager
_resource = new ResourceManager();
+ _resource->setCdNumber(1);
// Create all game classes
_encounter = new Encounter(this);
diff --git a/engines/asylum/resources/reaction.cpp b/engines/asylum/resources/reaction.cpp
index 16d6a57871..7145524351 100644
--- a/engines/asylum/resources/reaction.cpp
+++ b/engines/asylum/resources/reaction.cpp
@@ -489,15 +489,15 @@ void Reaction::play(int32 index) {
break;
case kActorSarah:
- resourceId = MAKE_RESOURCE(kResourcePackSpeechOther, index + 1927);
+ resourceId = MAKE_RESOURCE(kResourcePackSharedSound, index + 1927);
break;
case kActorCyclops:
- resourceId = MAKE_RESOURCE(kResourcePackSpeechOther, index + 2084);
+ resourceId = MAKE_RESOURCE(kResourcePackSharedSound, index + 2084);
break;
case kActorAztec:
- resourceId = MAKE_RESOURCE(kResourcePackSpeechOther, index + 2234);
+ resourceId = MAKE_RESOURCE(kResourcePackSharedSound, index + 2234);
break;
}
diff --git a/engines/asylum/resources/special.cpp b/engines/asylum/resources/special.cpp
index 78becd9dae..81924c1394 100644
--- a/engines/asylum/resources/special.cpp
+++ b/engines/asylum/resources/special.cpp
@@ -630,22 +630,22 @@ void Special::playSoundChapter1(Object *object, ActorIndex actorIndex) {
case kObjectRocker:
if (_vm->getRandomBit())
- playSoundPanning(MAKE_RESOURCE(kResourcePackSpeechOther, 1847), 14, object);
+ playSoundPanning(MAKE_RESOURCE(kResourcePackSharedSound, 1847), 14, object);
break;
case kObjectGuyWobbles:
if (_vm->getRandomBit())
- playSoundPanning(MAKE_RESOURCE(kResourcePackSpeechOther, 1887), 14, object);
+ playSoundPanning(MAKE_RESOURCE(kResourcePackSharedSound, 1887), 14, object);
break;
case kObjectPreAlphaNut:
if (_vm->getRandomBit())
- playSoundPanning(MAKE_RESOURCE(kResourcePackSpeechOther, 1889 + rnd(3)), 14, object);
+ playSoundPanning(MAKE_RESOURCE(kResourcePackSharedSound, 1889 + rnd(3)), 14, object);
break;
case kObjectPreAlphaNut2:
if (_vm->getRandomBit())
- playSoundPanning(MAKE_RESOURCE(kResourcePackSpeechOther, 1924 + rnd(3)), 14, object);
+ playSoundPanning(MAKE_RESOURCE(kResourcePackSharedSound, 1924 + rnd(3)), 14, object);
break;
}
} else {
@@ -669,35 +669,35 @@ void Special::playSoundChapter3(Object *object, ActorIndex actorIndex) {
case kObjectNPC024Church:
case kObjectNPC024Fountain:
if (_vm->getRandomBit())
- playSoundPanning(MAKE_RESOURCE(kResourcePackSpeechOther, 1895), 17, object);
+ playSoundPanning(MAKE_RESOURCE(kResourcePackSharedSound, 1895), 17, object);
break;
case kObjectPreacherBob:
if (_vm->getRandomBit())
- playSoundPanning(MAKE_RESOURCE(kResourcePackSpeechOther, 1896 + _vm->getRandomBit()), 14, object);
+ playSoundPanning(MAKE_RESOURCE(kResourcePackSharedSound, 1896 + _vm->getRandomBit()), 14, object);
break;
case kObjectPreacherBobAssistant:
case kObjectNPC026OutOfWay:
if (_vm->getRandomBit())
- playSoundPanning(MAKE_RESOURCE(kResourcePackSpeechOther, 1898), 18, object);
+ playSoundPanning(MAKE_RESOURCE(kResourcePackSharedSound, 1898), 18, object);
break;
case kObjectNPC027Sit:
case kObjectNPC027Dancing:
if (_vm->getRandomBit())
- playSoundPanning(MAKE_RESOURCE(kResourcePackSpeechOther, 1899), 15, object);
+ playSoundPanning(MAKE_RESOURCE(kResourcePackSharedSound, 1899), 15, object);
break;
case kObjectNPC028Sit:
case kObjectNPC028Dancing:
if (_vm->getRandomBit())
- playSoundPanning(MAKE_RESOURCE(kResourcePackSpeechOther, 1900), 15, object);
+ playSoundPanning(MAKE_RESOURCE(kResourcePackSharedSound, 1900), 15, object);
break;
case kObjectNPC029Sit:
if (_vm->getRandomBit())
- playSoundPanning(MAKE_RESOURCE(kResourcePackSpeechOther, 1901), 8, object);
+ playSoundPanning(MAKE_RESOURCE(kResourcePackSharedSound, 1901), 8, object);
break;
}
} else {
@@ -711,29 +711,29 @@ void Special::playSoundChapter3(Object *object, ActorIndex actorIndex) {
if (actor->getStatus() == kActorStatus9
&& actor->isResourcePresent()
&& actor->getFrameIndex() == 0)
- playSoundPanning(MAKE_RESOURCE(kResourcePackSpeechOther, 1861), 22, actorIndex);
+ playSoundPanning(MAKE_RESOURCE(kResourcePackSharedSound, 1861), 22, actorIndex);
break;
case 2:
if (actor->getStatus() == kActorStatus9
&& actor->isResourcePresent()
&& actor->getFrameIndex() == 1)
- playSoundPanning(MAKE_RESOURCE(kResourcePackSpeechOther, 1892), 16, actorIndex);
+ playSoundPanning(MAKE_RESOURCE(kResourcePackSharedSound, 1892), 16, actorIndex);
break;
case 3:
if (_vm->getRandomBit())
- playSoundPanning(MAKE_RESOURCE(kResourcePackSpeechOther, 1893), 17, actorIndex);
+ playSoundPanning(MAKE_RESOURCE(kResourcePackSharedSound, 1893), 17, actorIndex);
break;
case 4:
if (_vm->getRandomBit())
- playSoundPanning(MAKE_RESOURCE(kResourcePackSpeechOther, 1894), 17, actorIndex);
+ playSoundPanning(MAKE_RESOURCE(kResourcePackSharedSound, 1894), 17, actorIndex);
break;
case 5:
if (_vm->getRandomBit())
- playSoundPanning(MAKE_RESOURCE(kResourcePackSpeechOther, 1902), 15, actorIndex);
+ playSoundPanning(MAKE_RESOURCE(kResourcePackSharedSound, 1902), 15, actorIndex);
break;
}
}
@@ -747,117 +747,117 @@ void Special::playSoundChapter4(Object *object, ActorIndex actorIndex) {
case kObjectNPC032Sleeping:
if (_vm->getRandomBit())
- playSoundPanning(MAKE_RESOURCE(kResourcePackSpeechOther, 1903), 14, object);
+ playSoundPanning(MAKE_RESOURCE(kResourcePackSharedSound, 1903), 14, object);
break;
case kObjectNPC032SQOutside:
case kObjectNPC032SQBigTop:
if (_vm->getRandomBit())
- playSoundPanning(MAKE_RESOURCE(kResourcePackSpeechOther, 1904), 14, object);
+ playSoundPanning(MAKE_RESOURCE(kResourcePackSharedSound, 1904), 14, object);
break;
case kObjectNPC033Reading:
if (_vm->getRandomBit())
- playSoundPanning(MAKE_RESOURCE(kResourcePackSpeechOther, 1879), 16, object);
+ playSoundPanning(MAKE_RESOURCE(kResourcePackSharedSound, 1879), 16, object);
break;
case kObjectTattooManSQ:
if (_vm->getRandomBit())
- playSoundPanning(MAKE_RESOURCE(kResourcePackSpeechOther, 1884), 14, object);
+ playSoundPanning(MAKE_RESOURCE(kResourcePackSharedSound, 1884), 14, object);
break;
case kObjectStrongmanSQ:
case kObjectStrongmanLeft:
case kObjectStrongmanRight:
- playSoundPanning(MAKE_RESOURCE(kResourcePackSpeechOther, 1885), 16, object);
+ playSoundPanning(MAKE_RESOURCE(kResourcePackSharedSound, 1885), 16, object);
break;
case kObjectStrongmanSQ2:
if (_vm->getRandomBit())
- playSoundPanning(MAKE_RESOURCE(kResourcePackSpeechOther, 1886), 16, object);
+ playSoundPanning(MAKE_RESOURCE(kResourcePackSharedSound, 1886), 16, object);
break;
case kObjectInfernoSQ:
if (_vm->getRandomBit())
- playSoundPanning(MAKE_RESOURCE(kResourcePackSpeechOther, 1905), 12, object);
+ playSoundPanning(MAKE_RESOURCE(kResourcePackSharedSound, 1905), 12, object);
break;
case kObjectJuggler:
- playSoundPanning(MAKE_RESOURCE(kResourcePackSpeechOther, 1906), 12, object);
+ playSoundPanning(MAKE_RESOURCE(kResourcePackSharedSound, 1906), 12, object);
break;
case kObjectClownSQ:
if (_vm->getRandomBit())
- playSoundPanning(MAKE_RESOURCE(kResourcePackSpeechOther, 1907), 10, object);
+ playSoundPanning(MAKE_RESOURCE(kResourcePackSharedSound, 1907), 10, object);
break;
case kObjectTrixieSQ:
if (_vm->getRandomBit())
- playSoundPanning(MAKE_RESOURCE(kResourcePackSpeechOther, 1908), 12, object);
+ playSoundPanning(MAKE_RESOURCE(kResourcePackSharedSound, 1908), 12, object);
break;
case kObjectSimonSQ:
if (_vm->getRandomBit())
- playSoundPanning(MAKE_RESOURCE(kResourcePackSpeechOther, 1909), 12, object);
+ playSoundPanning(MAKE_RESOURCE(kResourcePackSharedSound, 1909), 12, object);
break;
case kObjectFunTixSQ:
if (_vm->getRandomBit())
- playSoundPanning(MAKE_RESOURCE(kResourcePackSpeechOther, 1913), 10, object);
+ playSoundPanning(MAKE_RESOURCE(kResourcePackSharedSound, 1913), 10, object);
break;
case kObjectFreakTixSQUp:
case kObjectFreakTixSQDown:
if (_vm->getRandomBit())
- playSoundPanning(MAKE_RESOURCE(kResourcePackSpeechOther, 1914), 9, object);
+ playSoundPanning(MAKE_RESOURCE(kResourcePackSharedSound, 1914), 9, object);
break;
case kObjectFortTellerSQ:
if (_vm->getRandomBit())
- playSoundPanning(MAKE_RESOURCE(kResourcePackSpeechOther, 1915), 15, object);
+ playSoundPanning(MAKE_RESOURCE(kResourcePackSharedSound, 1915), 15, object);
break;
case kObjectRingTossSQ:
if (_vm->getRandomBit())
- playSoundPanning(MAKE_RESOURCE(kResourcePackSpeechOther, 1916), 10, object);
+ playSoundPanning(MAKE_RESOURCE(kResourcePackSharedSound, 1916), 10, object);
break;
case kObjectPigShootSQ:
if (_vm->getRandomBit())
- playSoundPanning(MAKE_RESOURCE(kResourcePackSpeechOther, 1917), 10, object);
+ playSoundPanning(MAKE_RESOURCE(kResourcePackSharedSound, 1917), 10, object);
break;
case kObjectKnockDownSQ:
if (_vm->isGameFlagNotSet(kGameFlag358) && _vm->getRandomBit())
- playSoundPanning(MAKE_RESOURCE(kResourcePackSpeechOther, 1918), 10, object);
+ playSoundPanning(MAKE_RESOURCE(kResourcePackSharedSound, 1918), 10, object);
break;
case kObjectPretZoolSQ:
if (_vm->getRandomBit())
- playSoundPanning(MAKE_RESOURCE(kResourcePackSpeechOther, 1919), 14, object);
+ playSoundPanning(MAKE_RESOURCE(kResourcePackSharedSound, 1919), 14, object);
break;
case kObjectTimberSQ:
if (_vm->getRandomBit())
- playSoundPanning(MAKE_RESOURCE(kResourcePackSpeechOther, 1920), 14, object);
+ playSoundPanning(MAKE_RESOURCE(kResourcePackSharedSound, 1920), 14, object);
break;
case kObjectTwinsSQ:
if (_vm->getRandomBit())
- playSoundPanning(MAKE_RESOURCE(kResourcePackSpeechOther, 1921), 20, object);
+ playSoundPanning(MAKE_RESOURCE(kResourcePackSharedSound, 1921), 20, object);
break;
case kObjectSeanSQ:
if (_vm->getRandomBit())
- playSoundPanning(MAKE_RESOURCE(kResourcePackSpeechOther, 1923), 16, object);
+ playSoundPanning(MAKE_RESOURCE(kResourcePackSharedSound, 1923), 16, object);
break;
case kObjectMomAndPopSQ:
if (_vm->getRandomBit())
- playSoundPanning(MAKE_RESOURCE(kResourcePackSpeechOther, 1852), 15, object);
+ playSoundPanning(MAKE_RESOURCE(kResourcePackSharedSound, 1852), 15, object);
if (_vm->getRandomBit())
- playSoundPanning(MAKE_RESOURCE(kResourcePackSpeechOther, 1862), 15, object);
+ playSoundPanning(MAKE_RESOURCE(kResourcePackSharedSound, 1862), 15, object);
break;
}
} else {
@@ -867,17 +867,17 @@ void Special::playSoundChapter4(Object *object, ActorIndex actorIndex) {
case 1:
if (_vm->getRandomBit())
- playSoundPanning(MAKE_RESOURCE(kResourcePackSpeechOther, 1910), 14, actorIndex);
+ playSoundPanning(MAKE_RESOURCE(kResourcePackSharedSound, 1910), 14, actorIndex);
break;
case 2:
if (_vm->getRandomBit())
- playSoundPanning(MAKE_RESOURCE(kResourcePackSpeechOther, 1911), 14, actorIndex);
+ playSoundPanning(MAKE_RESOURCE(kResourcePackSharedSound, 1911), 14, actorIndex);
break;
case 3:
if (_vm->getRandomBit())
- playSoundPanning(MAKE_RESOURCE(kResourcePackSpeechOther, 1912), 14, actorIndex);
+ playSoundPanning(MAKE_RESOURCE(kResourcePackSharedSound, 1912), 14, actorIndex);
break;
}
}
@@ -893,37 +893,37 @@ void Special::playSoundChapter6(Object *object, ActorIndex actorIndex) {
case kObjectGravinSQCyber:
if (_vm->getRandomBit())
- playSoundPanning(MAKE_RESOURCE(kResourcePackSpeechOther, 1880), 14, object);
+ playSoundPanning(MAKE_RESOURCE(kResourcePackSharedSound, 1880), 14, object);
break;
case kObjectGravinWorkMachine:
if (_vm->getRandomBit())
- playSoundPanning(MAKE_RESOURCE(kResourcePackSpeechOther, 1880), 14, object);
+ playSoundPanning(MAKE_RESOURCE(kResourcePackSharedSound, 1880), 14, object);
break;
case kObjectNPC062GritzaSQ:
if (_vm->getRandomBit())
- playSoundPanning(MAKE_RESOURCE(kResourcePackSpeechOther, 1881), 12, object);
+ playSoundPanning(MAKE_RESOURCE(kResourcePackSharedSound, 1881), 12, object);
break;
case kObjectNPC063GrundleSQ:
if (_vm->getRandomBit())
- playSoundPanning(MAKE_RESOURCE(kResourcePackSpeechOther, 1882), 12, object);
+ playSoundPanning(MAKE_RESOURCE(kResourcePackSharedSound, 1882), 12, object);
break;
case kObjectNPC064GrellaSQ:
if (_vm->getRandomBit())
- playSoundPanning(MAKE_RESOURCE(kResourcePackSpeechOther, 1883), 12, object);
+ playSoundPanning(MAKE_RESOURCE(kResourcePackSharedSound, 1883), 12, object);
break;
case kObjectNPC065SQ:
if (_vm->getRandomBit())
- playSoundPanning(MAKE_RESOURCE(kResourcePackSpeechOther, 1868), 12, object);
+ playSoundPanning(MAKE_RESOURCE(kResourcePackSharedSound, 1868), 12, object);
break;
case kObjectNPC066SQ:
if (_vm->getRandomBit())
- playSoundPanning(MAKE_RESOURCE(kResourcePackSpeechOther, 1867), 12, object);
+ playSoundPanning(MAKE_RESOURCE(kResourcePackSharedSound, 1867), 12, object);
break;
}
}
@@ -939,12 +939,12 @@ void Special::playSoundChapter7(Object *object, ActorIndex actorIndex) {
case kObjectDrawers3:
if (_vm->isGameFlagNotSet(kGameFlag405) && _vm->isGameFlagSet(kGameFlag423))
if (rnd(100) < 20)
- playSoundPanning(MAKE_RESOURCE(kResourcePackSpeechOther, 1865), 18, object);
+ playSoundPanning(MAKE_RESOURCE(kResourcePackSharedSound, 1865), 18, object);
break;
case kObjectOldMan3:
if (rnd(100) < 20)
- playSoundPanning(MAKE_RESOURCE(kResourcePackSpeechOther, 1866), 18, object);
+ playSoundPanning(MAKE_RESOURCE(kResourcePackSharedSound, 1866), 18, object);
break;
}
}
diff --git a/engines/asylum/respack.cpp b/engines/asylum/respack.cpp
index ddf84de8df..a54386e43d 100644
--- a/engines/asylum/respack.cpp
+++ b/engines/asylum/respack.cpp
@@ -31,7 +31,7 @@ namespace Asylum {
// ResourceManager
//////////////////////////////////////////////////////////////////////////
-ResourceManager::ResourceManager() : _musicPackId(kResourcePackInvalid) {
+ResourceManager::ResourceManager() : _cdNumber(-1), _musicPackId(kResourcePackInvalid) {
}
ResourceEntry *ResourceManager::get(ResourceId id) {
@@ -49,7 +49,20 @@ ResourceEntry *ResourceManager::get(ResourceId id) {
// Try getting the resource pack
if (!cache->contains(packId)) {
- ResourcePack *pack = new ResourcePack(Common::String::format(isMusicPack ? "mus.%03d" : "res.%03d", isMusicPack ? _musicPackId : packId));
+ ResourcePack *pack;
+
+ if (isMusicPack) {
+ pack = new ResourcePack(Common::String::format("mus.%03d", _musicPackId));
+ } else {
+ if (packId == kResourcePackSharedSound) {
+ if (_cdNumber == -1)
+ error("[ResourceManager::get] Cd number has not been set!");
+
+ pack = new ResourcePack(Common::String::format("res.%01d%02d", _cdNumber, packId));
+ } else {
+ pack = new ResourcePack(Common::String::format("res.%03d", packId));
+ }
+ }
cache->setVal(packId, pack);
}
diff --git a/engines/asylum/respack.h b/engines/asylum/respack.h
index 39c55654b2..00a055d36c 100644
--- a/engines/asylum/respack.h
+++ b/engines/asylum/respack.h
@@ -83,6 +83,7 @@ public:
//int count(ResourceId id);
+ void setCdNumber(int cdNumber) { _cdNumber = cdNumber; }
void setMusicPackId(ResourcePackId id) { _musicPackId = id; }
private:
@@ -99,6 +100,7 @@ private:
ResourceCache _resources;
ResourceCache _music;
+ int _cdNumber;
ResourcePackId _musicPackId;
};
diff --git a/engines/asylum/shared.h b/engines/asylum/shared.h
index 9c68e2ec30..212419fe9f 100644
--- a/engines/asylum/shared.h
+++ b/engines/asylum/shared.h
@@ -106,7 +106,7 @@ enum ResourcePackId {
kResourcePackShared = 1,
kResourcePackMusic = 2, // Special case: will load from mus* resources
kResourcePackSpeech = 3,
- kResourcePackSpeechOther = 4,
+ kResourcePackSharedSound = 4,
kResourcePackTowerCells = 5,
kResourcePackInnocentAbandoned = 6,
kResourcePackCourtyardAndChapel = 7,
diff --git a/engines/asylum/system/speech.cpp b/engines/asylum/system/speech.cpp
index 8f06b06be8..26bb95b2e0 100644
--- a/engines/asylum/system/speech.cpp
+++ b/engines/asylum/system/speech.cpp
@@ -96,13 +96,13 @@ ResourceId Speech::playIndexed(int32 index) {
return play(MAKE_RESOURCE(kResourcePackSpeech, index), MAKE_RESOURCE(kResourcePackText, index + 83));
case kActorSarah:
- return play(MAKE_RESOURCE(kResourcePackSpeechOther, index + 1927), MAKE_RESOURCE(kResourcePackText, index + 586));
+ return play(MAKE_RESOURCE(kResourcePackSharedSound, index + 1927), MAKE_RESOURCE(kResourcePackText, index + 586));
case kActorCyclops:
- return play(MAKE_RESOURCE(kResourcePackSpeechOther, index + 2084), MAKE_RESOURCE(kResourcePackText, index + 743));
+ return play(MAKE_RESOURCE(kResourcePackSharedSound, index + 2084), MAKE_RESOURCE(kResourcePackText, index + 743));
case kActorAztec:
- return play(MAKE_RESOURCE(kResourcePackSpeechOther, index + 2234), MAKE_RESOURCE(kResourcePackText, index + 893));
+ return play(MAKE_RESOURCE(kResourcePackSharedSound, index + 2234), MAKE_RESOURCE(kResourcePackText, index + 893));
}
return kResourceNone;
@@ -115,64 +115,64 @@ ResourceId Speech::playScene(int32 type, int32 index) {
break;
case 0:
- return play(MAKE_RESOURCE(kResourcePackSpeechOther, index + 2363), MAKE_RESOURCE(kResourcePackText, index + 1022));
+ return play(MAKE_RESOURCE(kResourcePackSharedSound, index + 2363), MAKE_RESOURCE(kResourcePackText, index + 1022));
case 1:
- return play(MAKE_RESOURCE(kResourcePackSpeechOther, index + 2366), MAKE_RESOURCE(kResourcePackText, index + 1025));
+ return play(MAKE_RESOURCE(kResourcePackSharedSound, index + 2366), MAKE_RESOURCE(kResourcePackText, index + 1025));
case 2:
- return play(MAKE_RESOURCE(kResourcePackSpeechOther, index + 2371), MAKE_RESOURCE(kResourcePackText, index + 1030));
+ return play(MAKE_RESOURCE(kResourcePackSharedSound, index + 2371), MAKE_RESOURCE(kResourcePackText, index + 1030));
case 3:
- return play(MAKE_RESOURCE(kResourcePackSpeechOther, index + 2398), MAKE_RESOURCE(kResourcePackText, index + 1057));
+ return play(MAKE_RESOURCE(kResourcePackSharedSound, index + 2398), MAKE_RESOURCE(kResourcePackText, index + 1057));
case 4:
return play(MAKE_RESOURCE(kResourcePackSpeech, index + 503), MAKE_RESOURCE(kResourcePackText, index + 1060));
case 5:
- return play(MAKE_RESOURCE(kResourcePackSpeechOther, index + 2401), MAKE_RESOURCE(kResourcePackText, index + 1068));
+ return play(MAKE_RESOURCE(kResourcePackSharedSound, index + 2401), MAKE_RESOURCE(kResourcePackText, index + 1068));
case 6:
- return play(MAKE_RESOURCE(kResourcePackSpeechOther, index + 2409), MAKE_RESOURCE(kResourcePackText, index + 1076));
+ return play(MAKE_RESOURCE(kResourcePackSharedSound, index + 2409), MAKE_RESOURCE(kResourcePackText, index + 1076));
case 7:
- return play(MAKE_RESOURCE(kResourcePackSpeechOther, index + 2415), MAKE_RESOURCE(kResourcePackText, index + 1082));
+ return play(MAKE_RESOURCE(kResourcePackSharedSound, index + 2415), MAKE_RESOURCE(kResourcePackText, index + 1082));
case 8:
return play(MAKE_RESOURCE(kResourcePackSpeech, index + 511), MAKE_RESOURCE(kResourcePackText, index + 1084));
case 9:
- return play(MAKE_RESOURCE(kResourcePackSpeechOther, index + 2417), MAKE_RESOURCE(kResourcePackText, index + 1088));
+ return play(MAKE_RESOURCE(kResourcePackSharedSound, index + 2417), MAKE_RESOURCE(kResourcePackText, index + 1088));
case 10:
- return play(MAKE_RESOURCE(kResourcePackSpeechOther, index + 2417), MAKE_RESOURCE(kResourcePackText, index + 1093));
+ return play(MAKE_RESOURCE(kResourcePackSharedSound, index + 2417), MAKE_RESOURCE(kResourcePackText, index + 1093));
case 11:
- return play(MAKE_RESOURCE(kResourcePackSpeechOther, index + 2424), MAKE_RESOURCE(kResourcePackText, index + 1100));
+ return play(MAKE_RESOURCE(kResourcePackSharedSound, index + 2424), MAKE_RESOURCE(kResourcePackText, index + 1100));
case 12:
- return play(MAKE_RESOURCE(kResourcePackSpeechOther, index + 2424), MAKE_RESOURCE(kResourcePackText, index + 1102));
+ return play(MAKE_RESOURCE(kResourcePackSharedSound, index + 2424), MAKE_RESOURCE(kResourcePackText, index + 1102));
case 13:
- return play(MAKE_RESOURCE(kResourcePackSpeechOther, index + 2430), MAKE_RESOURCE(kResourcePackText, index + 1108));
+ return play(MAKE_RESOURCE(kResourcePackSharedSound, index + 2430), MAKE_RESOURCE(kResourcePackText, index + 1108));
case 14:
- return play(MAKE_RESOURCE(kResourcePackSpeechOther, index + 2432), MAKE_RESOURCE(kResourcePackText, index + 1110));
+ return play(MAKE_RESOURCE(kResourcePackSharedSound, index + 2432), MAKE_RESOURCE(kResourcePackText, index + 1110));
case 15:
- return play(MAKE_RESOURCE(kResourcePackSpeechOther, index + 2434), MAKE_RESOURCE(kResourcePackText, index + 1112));
+ return play(MAKE_RESOURCE(kResourcePackSharedSound, index + 2434), MAKE_RESOURCE(kResourcePackText, index + 1112));
case 16:
- return play(MAKE_RESOURCE(kResourcePackSpeechOther, index + 2435), MAKE_RESOURCE(kResourcePackText, index + 1113));
+ return play(MAKE_RESOURCE(kResourcePackSharedSound, index + 2435), MAKE_RESOURCE(kResourcePackText, index + 1113));
case 17:
- return play(MAKE_RESOURCE(kResourcePackSpeechOther, index + 2436), MAKE_RESOURCE(kResourcePackText, index + 1114));
+ return play(MAKE_RESOURCE(kResourcePackSharedSound, index + 2436), MAKE_RESOURCE(kResourcePackText, index + 1114));
case 18:
- return play(MAKE_RESOURCE(kResourcePackSpeechOther, index + 2438), MAKE_RESOURCE(kResourcePackText, index + 1116));
+ return play(MAKE_RESOURCE(kResourcePackSharedSound, index + 2438), MAKE_RESOURCE(kResourcePackText, index + 1116));
case 19:
- return play(MAKE_RESOURCE(kResourcePackSpeechOther, index + 2439), MAKE_RESOURCE(kResourcePackText, index + 1117));
+ return play(MAKE_RESOURCE(kResourcePackSharedSound, index + 2439), MAKE_RESOURCE(kResourcePackText, index + 1117));
}
return kResourceNone;
@@ -199,13 +199,13 @@ ResourceId Speech::playPlayer(int32 index) {
break;
case kActorSarah:
- return play(MAKE_RESOURCE(kResourcePackSpeechOther, index + 1927), MAKE_RESOURCE(kResourcePackText, index + 586));
+ return play(MAKE_RESOURCE(kResourcePackSharedSound, index + 1927), MAKE_RESOURCE(kResourcePackText, index + 586));
case kActorCyclops:
- return play(MAKE_RESOURCE(kResourcePackSpeechOther, index + 2084), MAKE_RESOURCE(kResourcePackText, index + 743));
+ return play(MAKE_RESOURCE(kResourcePackSharedSound, index + 2084), MAKE_RESOURCE(kResourcePackText, index + 743));
case kActorAztec:
- return play(MAKE_RESOURCE(kResourcePackSpeechOther, index + 2234), MAKE_RESOURCE(kResourcePackText, index + 893));
+ return play(MAKE_RESOURCE(kResourcePackSharedSound, index + 2234), MAKE_RESOURCE(kResourcePackText, index + 893));
}
return kResourceNone;
Commit: ea952cc33ddb42575aa81ba3e5f3830a704fe65c
https://github.com/scummvm/scummvm/commit/ea952cc33ddb42575aa81ba3e5f3830a704fe65c
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:16+02:00
Commit Message:
ASYLUM: Implement Sound panning/adjustement methods
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@532 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/asylum.cpp
engines/asylum/resources/actionlist.cpp
engines/asylum/resources/actor.cpp
engines/asylum/resources/object.cpp
engines/asylum/system/sound.cpp
engines/asylum/system/sound.h
engines/asylum/system/speech.cpp
engines/asylum/views/blowuppuzzle.cpp
engines/asylum/views/menu.cpp
engines/asylum/views/scene.cpp
diff --git a/engines/asylum/asylum.cpp b/engines/asylum/asylum.cpp
index f4914792ea..a830ce087a 100644
--- a/engines/asylum/asylum.cpp
+++ b/engines/asylum/asylum.cpp
@@ -311,7 +311,7 @@ void AsylumEngine::processDelayedEvents() {
int videoIdx = _scene->actions()->getDelayedVideoIndex();
if (videoIdx >= 0) {
_sound->stopMusic();
- _sound->stopAllSounds();
+ _sound->stopAll();
_video->playVideo(videoIdx, true);
_scene->actions()->setDelayedVideoIndex(-1);
@@ -331,7 +331,7 @@ void AsylumEngine::processDelayedEvents() {
_scene->actions()->setDelayedSceneIndex(kResourcePackInvalid);
_sound->stopMusic();
- _sound->stopAllSounds();
+ _sound->stopAll();
if (_scene)
delete _scene;
diff --git a/engines/asylum/resources/actionlist.cpp b/engines/asylum/resources/actionlist.cpp
index bc01aecc36..2da727c6da 100644
--- a/engines/asylum/resources/actionlist.cpp
+++ b/engines/asylum/resources/actionlist.cpp
@@ -769,7 +769,8 @@ IMPLEMENT_OPCODE(ChangeScene) {
getScreen()->clearScreen();
// Stop all sounds & music
- _vm->sound()->stopAllSounds(true);
+ getSound()->stopAll();
+ getSound()->stopMusic();
// Change the scene number
_delayedSceneIndex = (ResourcePackId)(cmd->param1 + 4);
@@ -1419,7 +1420,7 @@ IMPLEMENT_OPCODE(ChangeActorStatus) {
// Opcode 0x4D
IMPLEMENT_OPCODE(StopSound) {
if (_vm->sound()->isPlaying((ResourceId)cmd->param1))
- _vm->sound()->stopSound((ResourceId)cmd->param1);
+ _vm->sound()->stop((ResourceId)cmd->param1);
}
//////////////////////////////////////////////////////////////////////////
diff --git a/engines/asylum/resources/actor.cpp b/engines/asylum/resources/actor.cpp
index 58091b4999..769a89fe70 100644
--- a/engines/asylum/resources/actor.cpp
+++ b/engines/asylum/resources/actor.cpp
@@ -333,13 +333,13 @@ void Actor::update() {
getWorld()->musicCurrentResourceIndex = 1;
if (getSound()->isPlaying(getWorld()->soundResourceIds[7]))
- getSound()->stopSound(getWorld()->soundResourceIds[7]);
+ getSound()->stop(getWorld()->soundResourceIds[7]);
if (getSound()->isPlaying(getWorld()->soundResourceIds[6]))
- getSound()->stopSound(getWorld()->soundResourceIds[6]);
+ getSound()->stop(getWorld()->soundResourceIds[6]);
if (getSound()->isPlaying(getWorld()->soundResourceIds[5]))
- getSound()->stopSound(getWorld()->soundResourceIds[5]);
+ getSound()->stop(getWorld()->soundResourceIds[5]);
_vm->setGameFlag(kGameFlag1131);
} else {
@@ -775,7 +775,7 @@ void Actor::setPosition(int32 newX, int32 newY, int32 newDirection, int32 frame)
//////////////////////////////////////////////////////////////////////////
void Actor::stopSound() {
if (_soundResourceId && getSound()->isPlaying(_soundResourceId))
- getSound()->stopSound(_soundResourceId);
+ getSound()->stop(_soundResourceId);
}
Common::String Actor::toString(bool shortString) {
diff --git a/engines/asylum/resources/object.cpp b/engines/asylum/resources/object.cpp
index 98acd2e866..cc32cfde0c 100644
--- a/engines/asylum/resources/object.cpp
+++ b/engines/asylum/resources/object.cpp
@@ -390,7 +390,7 @@ void Object::playSounds() {
getSound()->setPanning(item->resourceId, getSound()->calculatePanningAtPoint(soundX, soundY));
getSound()->setVolume(item->resourceId, volume);
} else {
- getSound()->stopSound(item->resourceId);
+ getSound()->stop(item->resourceId);
}
}
}
@@ -405,7 +405,7 @@ void Object::updateSoundItems() {
if (getSound()->isPlaying(item->resourceId)) {
if (item->field_4) {
- getSound()->stopSound(item->resourceId);
+ getSound()->stop(item->resourceId);
item->resourceId = kResourceNone;
item->field_4 = 0;
}
@@ -417,13 +417,13 @@ void Object::updateSoundItems() {
void Object::stopSound() {
if (getSound()->isPlaying(_soundResourceId))
- getSound()->stopSound(_soundResourceId);
+ getSound()->stop(_soundResourceId);
}
void Object::stopAllSounds() {
for (int i = 0; i < ARRAYSIZE(_soundItems); i++)
if (_soundItems[i].resourceId) {
- getSound()->stopSound(_soundItems[i].resourceId);
+ getSound()->stop(_soundItems[i].resourceId);
_soundItems[i].resourceId = kResourceNone;
}
}
diff --git a/engines/asylum/system/sound.cpp b/engines/asylum/system/sound.cpp
index 9e07cfdd1d..f23f95e5e3 100644
--- a/engines/asylum/system/sound.cpp
+++ b/engines/asylum/system/sound.cpp
@@ -27,6 +27,7 @@
#include "asylum/system/config.h"
#include "asylum/system/sound.h"
+#include "asylum/resources/actor.h"
#include "asylum/resources/worldstats.h"
#include "asylum/views/scene.h"
@@ -49,241 +50,298 @@ Sound::~Sound() {
clearSoundBuffer();
}
-// from engines/agos/sound.cpp
-void convertVolume(int32 &vol) {
- // DirectSound was orginally used, which specifies volume
- // and panning differently than ScummVM does, using a logarithmic scale
- // rather than a linear one.
- //
- // Volume is a value between -10,000 and 0.
- //
- // In both cases, the -10,000 represents -100 dB. When panning, only
- // one speaker's volume is affected - just like in ScummVM - with
- // negative values affecting the left speaker, and positive values
- // affecting the right speaker. Thus -10,000 means the left speaker is
- // silent.
+//////////////////////////////////////////////////////////////////////////
+// Playing sounds & music
+//////////////////////////////////////////////////////////////////////////
- int32 v = CLIP(vol, -10000, 0);
- if (v) {
- vol = (int)((double)Audio::Mixer::kMaxChannelVolume * pow(10.0, (double)v / 2000.0) + 0.5);
- } else {
- vol = Audio::Mixer::kMaxChannelVolume;
+void Sound::playSound(ResourceId resourceId, bool looping, int32 volume, int32 panning) {
+ SoundBufferItem *item = getItem(resourceId);
+
+ if (item) {
+ if (_mixer->isSoundHandleActive(item->handle)) {
+ debugC(kDebugLevelSound, "[Sound::playSound] handle for resource %d already active", resourceId);
+
+ return;
+ }
+
+ //warning("[Sound::playSound] resource %d already buffered", resourceId);
+
+ // TODO check what we should do here
+ return;
}
+
+ ResourceEntry *resource = getResource()->get(resourceId);
+ playSoundData(Audio::Mixer::kSFXSoundType, &_soundHandle, resource->data, resource->size, looping, volume, panning);
+ addToSoundBuffer(resourceId);
}
-// from engines/agos/sound.cpp
-void convertPan(int32 &pan) {
- // DirectSound was originally used, which specifies volume
- // and panning differently than ScummVM does, using a logarithmic scale
- // rather than a linear one.
- //
- // Panning is a value between -10,000 and 10,000.
- //
- // In both cases, the -10,000 represents -100 dB. When panning, only
- // one speaker's volume is affected - just like in ScummVM - with
- // negative values affecting the left speaker, and positive values
- // affecting the right speaker. Thus -10,000 means the left speaker is
- // silent.
+void Sound::playMusic(ResourceId resourceId, int32 volume) {
+ if (resourceId == kResourceNone) {
+ stopMusic();
+ return;
+ }
- int32 p = CLIP(pan, -10000, 10000);
- if (p < 0) {
- pan = (int)(255.0 * pow(10.0, (double)p / 2000.0) + 127.5);
- } else if (p > 0) {
- pan = (int)(255.0 * pow(10.0, (double)p / -2000.0) - 127.5);
- } else {
- pan = 0;
+ // Sets the music volume
+ setMusicVolume(volume);
+
+ // Check if music is already playing
+ if (_mixer->isSoundHandleActive(_musicHandle))
+ return;
+
+ ResourceEntry *resource = getResource()->get(resourceId);
+ playSoundData(Audio::Mixer::kMusicSoundType, &_musicHandle, resource->data, resource->size, true, volume, 0);
+}
+
+void Sound::changeMusic(uint32 index, int32 musicStatusExt) {
+ if (index != getWorld()->musicCurrentResourceIndex) {
+ getWorld()->musicCurrentResourceIndex = index;
+ getWorld()->musicStatusExt = musicStatusExt;
+ getWorld()->musicFlag = 1;
}
}
-void Sound::setVolume(ResourceId resourceId, double volume) {
- error("[Sound::setVolume] not implemented");
+bool Sound::isPlaying(ResourceId resourceId) {
+ return (getPlayingItem(resourceId) != NULL);
}
-int32 Sound::getAdjustedVolume(int32 volume) {
- error("[Sound::getAdjustedVolume] not implemented");
+//////////////////////////////////////////////////////////////////////////
+// Volume & panning
+//////////////////////////////////////////////////////////////////////////
+
+void Sound::setVolume(ResourceId resourceId, int32 volume) {
+ SoundBufferItem *item = getPlayingItem(resourceId);
+ if (!item)
+ return;
+
+ convertVolume(volume);
+
+ _mixer->setChannelVolume(item->handle, volume);
}
-int32 Sound::calculateVolumeAdjustement(int32 x, int32 y, int32 a5, int32 a6) {
- error("[Sound::calculateVolumeAdjustement] not implemented");
+void Sound::setMusicVolume(int32 volume) {
+ if (volume < -10000)
+ return;
+
+ convertVolume(volume);
+
+ _mixer->setChannelVolume(_musicHandle, volume);
}
void Sound::setPanning(ResourceId resourceId, int32 panning) {
- error("[Sound::setPanning] not implemented");
-}
+ if (Config.performance == 1)
+ return;
-int32 Sound::calculatePanningAtPoint(int32 x, int32 y) {
- error("[Sound::calculatePanningAtPoint] not implemented");
+ SoundBufferItem *item = getPlayingItem(resourceId);
+ if (!item)
+ return;
+
+ convertPan(panning);
+
+ _mixer->setChannelBalance(item->handle, panning);
}
-int32 Sound::getBufferPosition(ResourceId resourceId) {
- int32 pos = -1;
+int32 Sound::calculateVolumeAdjustement(int32 x, int32 y, int32 attenuation, int32 delta) {
+ if (!attenuation)
+ return -(delta * delta);
- for (uint32 i = 0; i < _soundBuffer.size(); i++) {
- if (resourceId == _soundBuffer[i].resourceId) {
- pos = i;
- break;
- }
+ Actor *player = getScene()->getActor();
+ if (getScene()->getGlobalX() == -1) {
+ x -= (player->x1 + player->x2);
+ y -= (player->y1 + player->y2);
+ } else {
+ x -= getScene()->getGlobalX();
+ y -= getScene()->getGlobalY();
}
- return pos;
-}
+ int32 adjustedVolume = getAdjustedVolume(x * x + y * y);
-bool Sound::addToSoundBuffer(ResourceId resourceId) {
- int32 exists = getBufferPosition(resourceId);
+ Common::Rational invAtt(100, attenuation);
+ Common::Rational v;
+ if (invAtt.toInt())
+ v = Common::Rational(adjustedVolume, 1) / invAtt;
+ else
+ v = Common::Rational(delta, 1);
- if (exists < 0) {
- SoundBufferItem sound;
- sound.resourceId = resourceId;
- sound.handle = _soundHandle;
- _soundBuffer.push_back(sound);
- }
+ int32 volume = (v.toInt() - delta) * (v.toInt() - delta);
+
+ if (volume > 10000)
+ return -10000;
- return (exists < 0) ? true : false;
+ return -volume;
}
-void Sound::removeFromSoundBuffer(ResourceId resourceId) {
- int32 pos = getBufferPosition(resourceId);
+int32 Sound::getAdjustedVolume(int32 volume) {
+ if (volume < 2)
+ return volume;
- if (pos >= 0) {
- _soundBuffer.remove_at(pos);
- }
-}
+ //warning("[Sound::getAdjustedVolume] not implemented");
-void Sound::clearSoundBuffer() {
- _soundBuffer.clear();
+ return volume;
}
-bool Sound::isPlaying(ResourceId resourceId) {
- int32 pos = getBufferPosition(resourceId);
+int32 Sound::calculatePanningAtPoint(int32 x, int32 y) {
+ int delta = x - getWorld()->xLeft;
+
+ if (delta < 0)
+ return (getWorld()->stereoReversedFlag ? 10000 : -10000);
- if (pos < 0) {
- //warning("isPlaying: resource %d not currently buffered", resourceId);
+ if (delta >= 640)
+ return (getWorld()->stereoReversedFlag ? -10000 : 10000);
+
+
+ int sign, absDelta;
+ if (delta > 320) {
+ absDelta = delta - 320;
+ sign = (getWorld()->stereoReversedFlag ? -1 : 1);
} else {
- SoundBufferItem snd = _soundBuffer[pos];
- if (_mixer->isSoundHandleActive(snd.handle)) {
- return true;
- } else {
- removeFromSoundBuffer(resourceId);
- }
+ absDelta = 320 - delta;
+ sign = (getWorld()->stereoReversedFlag ? 1 : -1);
}
- return false;
-}
+ Common::Rational v(absDelta, 6);
+ int32 volume = v.toInt() * v.toInt();
-//void Sound::playSound(ResourceId resourceId, int32 volume, bool looping, int32 panning, bool overwrite) {
-// ResourceEntry *resource = getResource()->get(resourceId);
-// if (_mixer->isSoundHandleActive(_soundHandle)) {
-// if (overwrite) {
-// _mixer->stopHandle(_soundHandle);
-// playSound(resource, looping, volume, panning);
-// }
-// } else {
-// // if the current handle isn't active, play the sound
-// playSound(resource, looping, volume, panning);
-// }
-//}
-//
-//void Sound::playSound(ResourceEntry *resource, bool looping, int32 volume, int32 panning) {
-// playSoundData(Audio::Mixer::kSFXSoundType, &_soundHandle, resource->data, resource->size, looping, volume, panning);
-//}
+ if (volume > 10000)
+ volume = 10000;
-void Sound::playSound(ResourceId resourceId, bool looping, int32 volume, int32 panning) {
- int32 pos = getBufferPosition(resourceId);
+ return volume * sign;
+}
- if (pos < 0) {
- warning("playSound: resource %d not currently bufferred", resourceId);
- } else {
- SoundBufferItem snd = _soundBuffer[pos];
- if (_mixer->isSoundHandleActive(snd.handle)) {
- debugC(kDebugLevelSound, "playSound: handle for resource %d already active", resourceId);
- } else {
- ResourceEntry *ent = getResource()->get(resourceId);
- playSoundData(Audio::Mixer::kSFXSoundType, &snd.handle, ent->data, ent->size, looping, volume, panning);
- addToSoundBuffer(resourceId);
- }
- }
+//////////////////////////////////////////////////////////////////////////
+// Stopping sounds
+//////////////////////////////////////////////////////////////////////////
+void Sound::stop(ResourceId resourceId) {
+ SoundBufferItem *item = getPlayingItem(resourceId);
+ if (item != NULL)
+ _mixer->stopHandle(item->handle);
}
-//void Sound::playSound(ResourceId resourceId, bool looping, int32 volume, int32 panning, bool fromBuffer) {
-// if (fromBuffer) {
-// playSound(resourceId, looping, volume, panning);
-// } else {
-// if (_mixer->isSoundHandleActive(_soundHandle)) {
-// debugC(kDebugLevelSound, "playSound: temporary sound handle is active");
-// } else {
-// ResourceEntry *ent = getResource()->get(resourceId);
-// playSound(resourceId, looping, volume, panning);
-// addToSoundBuffer(resourceId);
-// }
-// }
-//}
-
-void Sound::stopSound() {
- if (_mixer->isSoundHandleActive(_soundHandle))
- _mixer->stopHandle(_soundHandle);
+void Sound::stopAll(ResourceId resourceId) {
+ for (Common::Array<SoundBufferItem>::iterator it = _soundBuffer.begin(); it != _soundBuffer.end(); it++)
+ if (it->resourceId == resourceId)
+ _mixer->stopHandle(it->handle);
}
-void Sound::stopSound(ResourceId resourceId) {
- int32 pos = getBufferPosition(resourceId);
+void Sound::stopAll() {
+ for (Common::Array<SoundBufferItem>::iterator it = _soundBuffer.begin(); it != _soundBuffer.end(); it++)
+ _mixer->stopHandle(it->handle);
+}
- if (pos < 0) {
- warning("stopSound: resource %d not currently bufferred", resourceId);
- } else {
- _mixer->stopHandle(_soundBuffer[pos].handle);
- }
+void Sound::stopMusic() {
+ _mixer->stopHandle(_musicHandle);
}
-void Sound::stopAllSounds(bool stopSpeechAndMusic) {
- _mixer->stopHandle(_soundHandle);
+//////////////////////////////////////////////////////////////////////////
+// Helper functions
+//////////////////////////////////////////////////////////////////////////
- if (stopSpeechAndMusic) {
- _mixer->stopHandle(_speechHandle);
- _mixer->stopHandle(_musicHandle);
- }
+void Sound::playSoundData(Audio::Mixer::SoundType type, Audio::SoundHandle *handle, byte *soundData, int32 soundDataLength, bool loop, int32 vol, int32 pan) {
+ Common::MemoryReadStream *stream = new Common::MemoryReadStream(soundData, soundDataLength);
+ Audio::RewindableAudioStream *sndStream = Audio::makeWAVStream(stream, DisposeAfterUse::YES);
+
+ // Convert volume and panning
+ convertVolume(vol);
+ convertPan(pan);
+
+ _mixer->playStream(type, handle, Audio::makeLoopingAudioStream(sndStream, loop ? 0 : 1), -1, vol, pan);
+}
+//////////////////////////////////////////////////////////////////////////
+// Sound buffer
+//////////////////////////////////////////////////////////////////////////
+
+SoundBufferItem *Sound::getItem(ResourceId resourceId) {
for (uint32 i = 0; i < _soundBuffer.size(); i++)
- _mixer->stopHandle(_soundBuffer[i].handle);
+ if (resourceId == _soundBuffer[i].resourceId)
+ return &_soundBuffer[i];
+
+ return NULL;
}
-void Sound::playSpeech(ResourceId resourceId) {
- ResourceEntry *ent = getResource()->get(resourceId);
+SoundBufferItem *Sound::getPlayingItem(ResourceId resourceId) {
+ for (uint32 i = 0; i < _soundBuffer.size(); i++)
+ if (resourceId == _soundBuffer[i].resourceId
+ && _mixer->isSoundHandleActive(_soundBuffer[i].handle))
+ return &_soundBuffer[i];
- _mixer->stopHandle(_speechHandle);
- playSoundData(Audio::Mixer::kSpeechSoundType, &_speechHandle, ent->data, ent->size, false, 0, 0);
+ return NULL;
}
-void Sound::playMusic(ResourceId resourceId, int32 volume) {
- if (resourceId == kResourceNone)
- return;
+bool Sound::addToSoundBuffer(ResourceId resourceId) {
+ SoundBufferItem *item = getItem(resourceId);
- stopMusic();
+ if (item == NULL) {
+ SoundBufferItem sound;
+ sound.resourceId = resourceId;
+ sound.handle = _soundHandle;
+ _soundBuffer.push_back(sound);
+ }
- ResourceEntry *resource = getResource()->get(resourceId);
- playSoundData(Audio::Mixer::kMusicSoundType, &_musicHandle, resource->data, resource->size, true, volume, 0);
+ return (item == NULL) ? true : false;
}
-void Sound::changeMusic(uint32 index, int32 musicStatusExt) {
- if (index != getWorld()->musicCurrentResourceIndex) {
- getWorld()->musicCurrentResourceIndex = index;
- getWorld()->musicStatusExt = musicStatusExt;
- getWorld()->musicFlag = 1;
+void Sound::removeFromSoundBuffer(ResourceId resourceId) {
+ for (uint i = 0; i < _soundBuffer.size(); i++) {
+ if (_soundBuffer[i].resourceId == resourceId) {
+ _soundBuffer.remove_at(i);
+ break;
+ }
}
}
-void Sound::stopMusic() {
- _mixer->stopHandle(_musicHandle);
+void Sound::clearSoundBuffer() {
+ _soundBuffer.clear();
}
-// from engines/agos/sound.cpp
-void Sound::playSoundData(Audio::Mixer::SoundType type, Audio::SoundHandle *handle, byte *soundData, int32 soundDataLength, bool loop, int32 vol, int32 pan) {
- Common::MemoryReadStream *stream = new Common::MemoryReadStream(soundData, soundDataLength);
- Audio::RewindableAudioStream *sndStream = Audio::makeWAVStream(stream, DisposeAfterUse::YES);
+//////////////////////////////////////////////////////////////////////////
+// Conversion functions
+//
+// Those are from engines/agos/sound.cpp (FIXME: Move to common code?)
+//////////////////////////////////////////////////////////////////////////
- // FIXME need to convert the volume properly
- vol = Audio::Mixer::kMaxChannelVolume;
+void Sound::convertVolume(int32 &vol) {
+ // DirectSound was originally used, which specifies volume
+ // and panning differently than ScummVM does, using a logarithmic scale
+ // rather than a linear one.
+ //
+ // Volume is a value between -10,000 and 0.
+ //
+ // In both cases, the -10,000 represents -100 dB. When panning, only
+ // one speaker's volume is affected - just like in ScummVM - with
+ // negative values affecting the left speaker, and positive values
+ // affecting the right speaker. Thus -10,000 means the left speaker is
+ // silent.
- _mixer->playStream(type, handle, Audio::makeLoopingAudioStream(sndStream, loop ? 0 : 1), -1, vol, pan);
+ int32 v = CLIP(vol, -10000, 0);
+ if (v) {
+ vol = (int)((double)Audio::Mixer::kMaxChannelVolume * pow(10.0, (double)v / 2000.0) + 0.5);
+ } else {
+ vol = Audio::Mixer::kMaxChannelVolume;
+ }
+}
+
+void Sound::convertPan(int32 &pan) {
+ // DirectSound was originally used, which specifies volume
+ // and panning differently than ScummVM does, using a logarithmic scale
+ // rather than a linear one.
+ //
+ // Panning is a value between -10,000 and 10,000.
+ //
+ // In both cases, the -10,000 represents -100 dB. When panning, only
+ // one speaker's volume is affected - just like in ScummVM - with
+ // negative values affecting the left speaker, and positive values
+ // affecting the right speaker. Thus -10,000 means the left speaker is
+ // silent.
+
+ int32 p = CLIP(pan, -10000, 10000);
+ if (p < 0) {
+ pan = (int)(255.0 * pow(10.0, (double)p / 2000.0) + 127.5);
+ } else if (p > 0) {
+ pan = (int)(255.0 * pow(10.0, (double)p / -2000.0) - 127.5);
+ } else {
+ pan = 0;
+ }
}
} // end of namespace Asylum
diff --git a/engines/asylum/system/sound.h b/engines/asylum/system/sound.h
index 3bc8e974f8..89e35bef5e 100644
--- a/engines/asylum/system/sound.h
+++ b/engines/asylum/system/sound.h
@@ -82,31 +82,26 @@ public:
Sound(AsylumEngine *engine, Audio::Mixer *mixer);
~Sound();
- bool addToSoundBuffer(ResourceId resourceId);
- void removeFromSoundBuffer(ResourceId resourceId);
- void clearSoundBuffer();
+ //////////////////////////////////////////////////////////////////////////
+ // Playing sounds & music
+ //////////////////////////////////////////////////////////////////////////
/**
- * Play a sound resource from the supplied resource pack.
+ * Play sound
*
- * @param overwrite determine if _soundHandle should be overwritten if still active
+ * @param resourceId Identifier for the resource.
+ * @param looping true to looping.
+ * @param volume The volume.
+ * @param panning The panning.
*/
- //void playSound(ResourceId resourceId, int32 volume, bool looping = false, int32 panning = 0, bool overwrite = false);
- //void playSound(ResourceId resourceId, bool looping = false, int32 volume = Config.sfxVolume, int32 panning = 0, bool fromBuffer = false);
void playSound(ResourceId resourceId, bool looping = false, int32 volume = Config.sfxVolume, int32 panning = 0);
- //void playSound(ResourceEntry *resource, bool looping, int32 volume, int32 panning);
-
- void stopSound(ResourceId resourceId);
- void stopSound();
- void stopAllSounds(bool stopSpeechAndMusic = false);
/**
- * Play speech by resourceId
+ * Play music
*
- * @param resourceId Identifier for the sound resource.
+ * @param resourceId Identifier for the resource.
+ * @param volume The volume.
*/
- void playSpeech(ResourceId resourceId);
-
void playMusic(ResourceId resourceId, int32 volume = Config.musicVolume);
/**
@@ -117,57 +112,184 @@ public:
*/
void changeMusic(uint32 index, int32 musicStatusExt);
+ /**
+ * Query if a sound with the resource id is playing.
+ *
+ * @param resourceId Identifier for the resource.
+ *
+ * @return true if playing, false if not.
+ */
+ bool isPlaying(ResourceId resourceId);
+ //////////////////////////////////////////////////////////////////////////
+ // Volume & panning
+ //////////////////////////////////////////////////////////////////////////
- void stopMusic();
+ /**
+ * Sets the volume for a buffered sound resource
+ *
+ * @param resourceId Identifier for the resource.
+ * @param volume The volume.
+ */
+ void setVolume(ResourceId resourceId, int32 volume);
- void setVolume(ResourceId resourceId, double volume);
- int32 getAdjustedVolume(int32 volume);
+ /**
+ * Sets the music volume.
+ *
+ * @param volume The volume.
+ */
+ void setMusicVolume(int32 volume);
+ /**
+ * Sets the panning for a buffered sound resource
+ *
+ * @param resourceId Identifier for the resource.
+ * @param panning The panning.
+ */
void setPanning(ResourceId resourceId, int32 panning);
- int32 calculatePanningAtPoint(int32 x, int32 y);
/**
- * Determine the amount to increase the supplied sound
- * sample's volume based on the position
+ * Determine the amount to increase the supplied sound sample's volume based on the position.
+ *
+ * @param x The x coordinate.
+ * @param y The y coordinate.
+ * @param attenuation The attenuation.
+ * @param delta The delta.
+ *
+ * @return The calculated volume adjustement.
*/
- int32 calculateVolumeAdjustement(int32 x, int32 y, int32 a5, int32 a6);
+ int32 calculateVolumeAdjustement(int32 x, int32 y, int32 attenuation, int32 delta);
/**
- * Check if the buffered sound sample that matches the provided id currently
- * has an active handle.
+ * Gets an adjusted volume.
*
- * isPlaying() only manages sound samples, and not
- * music or speech, as those resources aren't managed beyond simple
- * start/stop requests.
+ * @param volume The volume.
+ *
+ * @return The adjusted volume.
*/
- bool isPlaying(ResourceId resourceId);
+ int32 getAdjustedVolume(int32 volume);
+
+ /**
+ * Calculates the panning at point.
+ *
+ * @param x The x coordinate.
+ * @param y The y coordinate.
+ *
+ * @return The calculated panning at point.
+ */
+ int32 calculatePanningAtPoint(int32 x, int32 y);
+
+ //////////////////////////////////////////////////////////////////////////
+ // Stopping sounds
+ //////////////////////////////////////////////////////////////////////////
+
+ /**
+ * Stop the first playing sound with the ResourceId
+ *
+ * @param resourceId Identifier for the resource.
+ */
+ void stop(ResourceId resourceId);
/**
- * Check if the unmanaged sound handle is in use
+ * Stop all sounds with the ResourceId
*
- * This is useful for checking the active state of a sound
- * in a blowuppuzzle
+ * @param resourceId Identifier for the resource.
+ */
+ void stopAll(ResourceId resourceId);
+
+ /**
+ * Stop all buffered sounds
*/
- bool isPlaying() { return _mixer->isSoundHandleActive(_soundHandle); }
+ void stopAll();
+
+ /**
+ * Stop music.
+ */
+ void stopMusic();
private:
AsylumEngine *_vm;
Audio::Mixer *_mixer;
- Audio::SoundHandle _speechHandle;
Audio::SoundHandle _musicHandle;
Audio::SoundHandle _soundHandle;
Common::Array<SoundBufferItem> _soundBuffer;
/**
- * Find the index within the _soundBuffer array of the
- * sound sample with provided id.
+ * Play sound data.
+ *
+ * @param type The type.
+ * @param handle The handle.
+ * @param soundData The sound data
+ * @param soundDataLength Length of the sound data.
+ * @param loop true to loop.
+ * @param vol The volume.
+ * @param pan The pan.
*/
- int32 getBufferPosition(ResourceId resourceId);
void playSoundData(Audio::Mixer::SoundType type, Audio::SoundHandle *handle, byte *soundData, int32 soundDataLength, bool loop = false, int32 vol = 0, int32 pan = 0);
+
+ //////////////////////////////////////////////////////////////////////////
+ // Sound buffer
+ //////////////////////////////////////////////////////////////////////////
+
+ /**
+ * Find the index within the _soundBuffer array of the first sound sample with provided id.
+ *
+ * @param resourceId Identifier for the resource.
+ *
+ * @return The item.
+ */
+ SoundBufferItem *getItem(ResourceId resourceId);
+
+ /**
+ * Find the index within the _soundBuffer array of the first playing sound sample with provided id.
+ *
+ * @param resourceId Identifier for the resource.
+ *
+ * @return The playing item.
+ */
+ SoundBufferItem *getPlayingItem(ResourceId resourceId);
+
+ /**
+ * Adds a sound to the sound buffer.
+ *
+ * @param resourceId Identifier for the resource.
+ *
+ * @return true if it succeeds, false if it fails.
+ */
+ bool addToSoundBuffer(ResourceId resourceId);
+
+ /**
+ * Removes a sound from the sound buffer
+ *
+ * @param resourceId Identifier for the resource.
+ */
+ void removeFromSoundBuffer(ResourceId resourceId);
+
+ /**
+ * Clears the sound buffer.
+ */
+ void clearSoundBuffer();
+
+ //////////////////////////////////////////////////////////////////////////
+ // Conversion functions
+ //////////////////////////////////////////////////////////////////////////
+
+ /**
+ * Convert volume.
+ *
+ * @param [in,out] vol The volume.
+ */
+ static void convertVolume(int32 &vol);
+
+ /**
+ * Convert pan.
+ *
+ * @param [in,out] pan The pan.
+ */
+ static void convertPan(int32 &pan);
};
} // end of namespace Asylum
diff --git a/engines/asylum/system/speech.cpp b/engines/asylum/system/speech.cpp
index 26bb95b2e0..02180fa8e8 100644
--- a/engines/asylum/system/speech.cpp
+++ b/engines/asylum/system/speech.cpp
@@ -49,7 +49,7 @@ Speech::~Speech() {
ResourceId Speech::play(ResourceId soundResourceId, ResourceId textResourceId) {
if (soundResourceId)
if (getSound()->isPlaying(soundResourceId))
- getSound()->stopSound(soundResourceId);
+ getSound()->stopAll(soundResourceId);
_soundResourceId = soundResourceId;
_textResourceId = textResourceId;
@@ -259,7 +259,7 @@ void Speech::process() {
_textDataPos = 0;
getText()->loadFont(getWorld()->font1);
- getSound()->playSpeech(_soundResourceId);
+ getSound()->playSound(_soundResourceId, false, Config.voiceVolume, 0);
} else {
_textData = 0;
_textDataPos = txt;
@@ -269,7 +269,7 @@ void Speech::process() {
}
getText()->loadFont(getWorld()->font3);
- getSound()->playSpeech(_soundResourceId);
+ getSound()->playSound(_soundResourceId, false, Config.voiceVolume, 0);
}
}
diff --git a/engines/asylum/views/blowuppuzzle.cpp b/engines/asylum/views/blowuppuzzle.cpp
index a05437c095..54eaf43202 100644
--- a/engines/asylum/views/blowuppuzzle.cpp
+++ b/engines/asylum/views/blowuppuzzle.cpp
@@ -77,7 +77,7 @@ void BlowUpPuzzleVCR::openBlowUp() {
_active = true;
getScene()->deactivate();
- getSound()->stopAllSounds(true);
+ getSound()->stopAll();
// Load the graphics palette
getScreen()->setPalette(getWorld()->graphicResourceIds[29]);
@@ -139,7 +139,7 @@ void BlowUpPuzzleVCR::update() {
if (_rightClickDown) { // quits BlowUp Puzzle
_rightClickDown = false;
closeBlowUp();
- getSound()->stopSound();
+ getSound()->stopAll();
// FIXME getScene()->enterScene();
}
@@ -590,7 +590,7 @@ void BlowUpPuzzleVCR::handleMouseUp() {
_buttonsState[kStop] = kOFF;
_buttonsState[kPlay] = kOFF;
_buttonsState[kRewind] = kOFF;
- getSound()->stopSound();
+ getSound()->stopAll();
}
if (_buttonsState[kRewind] == kDownOFF) {
diff --git a/engines/asylum/views/menu.cpp b/engines/asylum/views/menu.cpp
index dbc7c6defe..23b64d366c 100644
--- a/engines/asylum/views/menu.cpp
+++ b/engines/asylum/views/menu.cpp
@@ -122,7 +122,7 @@ void MainMenu::openMenu() {
// Stop all sounds
_vm->sound()->stopMusic();
- _vm->sound()->stopSound();
+ _vm->sound()->stopAll();
// Start playing music
_vm->sound()->playMusic(MAKE_RESOURCE(kResourcePackShared, 39));
@@ -139,7 +139,7 @@ void MainMenu::closeMenu() {
}
// Stop menu sounds and menu music
- _vm->sound()->stopSound();
+ _vm->sound()->stopAll();
_vm->sound()->stopMusic();
}
@@ -662,3 +662,4 @@ void MainMenu::updateSubMenuReturnToGame() {
}
} // end of namespace Asylum
+
diff --git a/engines/asylum/views/scene.cpp b/engines/asylum/views/scene.cpp
index b3edfa5375..aa859d3449 100644
--- a/engines/asylum/views/scene.cpp
+++ b/engines/asylum/views/scene.cpp
@@ -897,7 +897,7 @@ void Scene::updateAmbientSounds() {
}
} else {
if (_vm->sound()->isPlaying(snd->resourceId))
- _vm->sound()->stopSound(snd->resourceId);
+ _vm->sound()->stop(snd->resourceId);
}
}
}
Commit: 71125b991671eca0010d4ecedaf98914d40291cd
https://github.com/scummvm/scummvm/commit/71125b991671eca0010d4ecedaf98914d40291cd
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:16+02:00
Commit Message:
ASYLUM: Throw an error when a resource pack cannot be opened
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@533 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/respack.cpp
diff --git a/engines/asylum/respack.cpp b/engines/asylum/respack.cpp
index a54386e43d..151ee8f11c 100644
--- a/engines/asylum/respack.cpp
+++ b/engines/asylum/respack.cpp
@@ -102,7 +102,8 @@ ResourcePack::~ResourcePack() {
}
void ResourcePack::init(Common::String filename) {
- _packFile.open(filename);
+ if (!_packFile.open(filename))
+ error("[ResourcePack::init] Could not open resource file: %s", filename.c_str());
uint32 entryCount = _packFile.readUint32LE();
_resources.resize(entryCount);
Commit: 5bd13afb2bebc13f100ed65dfd0afb0edfdaf9da
https://github.com/scummvm/scummvm/commit/5bd13afb2bebc13f100ed65dfd0afb0edfdaf9da
Author: Arthur Blot (arthur.blot78 at gmail.com)
Date: 2021-05-17T15:36:17+02:00
Commit Message:
ASYLUM: Fixed scene reloading, to get the good palette after showing intro & when exiting menu
Fixed some places where the added sound looping argument was not set, so it looped but shouldn't (in example, in menu)
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@534 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/asylum.cpp
engines/asylum/views/blowuppuzzle.cpp
engines/asylum/views/menu.cpp
engines/asylum/views/scene.cpp
engines/asylum/views/scene.h
diff --git a/engines/asylum/asylum.cpp b/engines/asylum/asylum.cpp
index a830ce087a..e103e16d66 100644
--- a/engines/asylum/asylum.cpp
+++ b/engines/asylum/asylum.cpp
@@ -172,10 +172,10 @@ void AsylumEngine::startGame(ResourcePackId sceneId, StartGameType type) {
error("[AsylumEngine::startGame] Invalid start game type!");
case kStartGamePlayIntro:
- _scene->enter(sceneId);
-
playIntro();
+ _scene->enter(sceneId);
+
_cursor->show();
break;
@@ -259,7 +259,7 @@ void AsylumEngine::handleEvents(bool doUpdate) { // k_sub_40AE30 (0040AE30)
if (_mainMenu->isActive()) {
if (_scene) {
_mainMenu->closeMenu();
- // FIXME _scene->enterScene();
+ _scene->activate();
}
} else if (_scene && _scene->isActive()) {
_mainMenu->openMenu();
@@ -317,8 +317,8 @@ void AsylumEngine::processDelayedEvents() {
if (_mainMenu->isActive())
_mainMenu->openMenu();
- // FIXME else if (_scene->isActive())
- // FIXME _scene->enterScene();
+ else if (_scene->isActive())
+ _scene->activate();
}
// check for a delayed scene change
diff --git a/engines/asylum/views/blowuppuzzle.cpp b/engines/asylum/views/blowuppuzzle.cpp
index 54eaf43202..084516f732 100644
--- a/engines/asylum/views/blowuppuzzle.cpp
+++ b/engines/asylum/views/blowuppuzzle.cpp
@@ -125,7 +125,7 @@ void BlowUpPuzzleVCR::handleEvent(Common::Event *event, bool doUpdate) {
}
void BlowUpPuzzle::playSound(ResourceId resourceId, bool loop) {
- getSound()->playSound(resourceId, Config.sfxVolume, loop, 0/*, true*/);
+ getSound()->playSound(resourceId, loop, Config.sfxVolume, 0);
}
int BlowUpPuzzleVCR::inPolyRegion(int x, int y, int polyIdx) {
@@ -140,7 +140,6 @@ void BlowUpPuzzleVCR::update() {
_rightClickDown = false;
closeBlowUp();
getSound()->stopAll();
- // FIXME getScene()->enterScene();
}
if (_leftClickDown) {
@@ -184,8 +183,7 @@ void BlowUpPuzzleVCR::update() {
getVideo()->playVideo(2, true);
_isAccomplished = false;
- _active = false;
- // FIXME getScene()->enterScene();
+ closeBlowUp();
} else {
getScreen()->drawGraphicsInQueue();
}
diff --git a/engines/asylum/views/menu.cpp b/engines/asylum/views/menu.cpp
index 23b64d366c..5a716471a1 100644
--- a/engines/asylum/views/menu.cpp
+++ b/engines/asylum/views/menu.cpp
@@ -234,10 +234,8 @@ void MainMenu::update() {
getSound()->playMusic(MAKE_RESOURCE(kResourcePackShared, 38));
break;
case kReturnToGame:
- if (_vm->scene()) { // FIXME: do this properly
+ if (_vm->scene()) // FIXME: do this properly
closeMenu();
- // FIXME _vm->scene()->enterScene();
- }
break;
}
}
@@ -327,7 +325,7 @@ void MainMenu::updateMainMenu() {
// Play creepy voice
if (_activeIcon != _previousActiveIcon) {
- getSound()->playSound(MAKE_RESOURCE(kResourcePackShared, iconNum + 44), Config.sfxVolume);
+ getSound()->playSound(MAKE_RESOURCE(kResourcePackShared, iconNum + 44), false, Config.sfxVolume);
_previousActiveIcon = _activeIcon;
}
diff --git a/engines/asylum/views/scene.cpp b/engines/asylum/views/scene.cpp
index aa859d3449..7a6c951b23 100644
--- a/engines/asylum/views/scene.cpp
+++ b/engines/asylum/views/scene.cpp
@@ -206,15 +206,7 @@ void Scene::enter(ResourcePackId packId) {
_ws->field_E860C = -1;
}
-
- //////////////////////////////////////////////////////////////////////////
- // FIXME: get rid of this
- _isActive = true;
- getScreen()->setPalette(_ws->currentPaletteId);
- _background = _bgResource->getFrame(0);
- _vm->screen()->copyToBackBuffer(
- ((byte *)_background->surface.pixels) + _ws->yTop * _background->surface.w + _ws->xLeft, _background->surface.w,
- 0, 0, 640, 480);
+ activate();
}
void Scene::load(ResourcePackId packId) {
@@ -372,7 +364,7 @@ void Scene::handleEvent(Common::Event *event, bool doUpdate) {
_title->update(_vm->getTick());
if (_title->loadingComplete()) {
_titleLoaded = true;
- // FIXME enterScene();
+ activate();
}
return;
}
@@ -397,6 +389,18 @@ void Scene::handleEvent(Common::Event *event, bool doUpdate) {
}
}
+void Scene::activate() {
+ //////////////////////////////////////////////////////////////////////////
+ // FIXME: get rid of this?
+
+ _isActive = true;
+ getScreen()->setPalette(_ws->currentPaletteId);
+ _background = _bgResource->getFrame(0);
+ _vm->screen()->copyToBackBuffer(
+ ((byte *)_background->surface.pixels) + _ws->yTop * _background->surface.w + _ws->xLeft, _background->surface.w,
+ 0, 0, 640, 480);
+}
+
bool Scene::update() {
#ifdef DEBUG_SCENE_TIMES
#define MESURE_TICKS(func) { \
@@ -886,7 +890,7 @@ void Scene::updateAmbientSounds() {
else
if (tmpVol <= -10000)
tmpVol = -10000;
- getSound()->playSound(snd->resourceId, 0, tmpVol, vm()->getRandom(20001) - 10000);
+ getSound()->playSound(snd->resourceId, false, tmpVol, vm()->getRandom(20001) - 10000);
}
}
} else {
diff --git a/engines/asylum/views/scene.h b/engines/asylum/views/scene.h
index 85021dd825..85fb84330b 100644
--- a/engines/asylum/views/scene.h
+++ b/engines/asylum/views/scene.h
@@ -91,7 +91,7 @@ public:
void handleEvent(Common::Event *event, bool doUpdate);
- void activate() { _isActive = true; }
+ void activate();
void deactivate() { _isActive = false; }
bool isActive() { return _isActive; }
ResourcePackId getPackId() { return _packId; }
Commit: 509a8dd028530fffa39dbd67137f0f655adc0533
https://github.com/scummvm/scummvm/commit/509a8dd028530fffa39dbd67137f0f655adc0533
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:17+02:00
Commit Message:
ASYLUM: Implement Special::setPaletteGamma
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@535 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/resources/special.cpp
engines/asylum/resources/special.h
engines/asylum/system/screen.cpp
diff --git a/engines/asylum/resources/special.cpp b/engines/asylum/resources/special.cpp
index 81924c1394..7b87abc39a 100644
--- a/engines/asylum/resources/special.cpp
+++ b/engines/asylum/resources/special.cpp
@@ -33,6 +33,7 @@
#include "asylum/system/cursor.h"
#include "asylum/system/graphics.h"
+#include "asylum/system/screen.h"
#include "asylum/system/speech.h"
#include "asylum/views/scene.h"
@@ -43,8 +44,13 @@ namespace Asylum {
Special::Special(AsylumEngine *engine) : _vm(engine) {
- // Counters
+ // Counters & flags
_chapter2Counter = 0;
+ _chapter5Counter = 0;
+
+ _paletteFlag = false;
+ _paletteTick1 = 0;
+ _paletteTick2 = 0;
}
Special::~Special() {}
@@ -957,7 +963,53 @@ void Special::playSoundChapter8(Object *object, ActorIndex actorIndex) {
// Misc
//////////////////////////////////////////////////////////////////////////
void Special::setPaletteGamma(ResourceId palette1, ResourceId palette2) {
- error("[Special::setPaletteGamma] Not implemented!");
+ if (_paletteFlag) {
+ if (_paletteTick2 < _vm->getTick()) {
+ _paletteFlag = false;
+
+ getSound()->playSound(getWorld()->ambientSounds[rnd(5) + 2].resourceId, false, Config.ambientVolume);
+
+ _paletteTick1 = _vm->getTick() + 5000;
+ }
+ } else {
+ switch (_chapter5Counter) {
+ default:
+ if (_chapter5Counter > 0) {
+ ++_chapter5Counter;
+ } else {
+ if (_paletteTick1 < _vm->getTick()) {
+ if (rnd(100) >= 20) {
+ _paletteTick1 = _vm->getTick() + 5000;
+ } else {
+ getScreen()->setPalette(palette1);
+ getScreen()->setGammaLevel(palette1, 0);
+ _chapter5Counter = 1;
+ }
+ }
+ }
+ break;
+
+ case 500:
+ getScreen()->setPalette(palette2);
+ getScreen()->setGammaLevel(palette2, 0);
+ ++_chapter5Counter;
+ break;
+
+ case 1000:
+ getScreen()->setPalette(palette1);
+ getScreen()->setGammaLevel(palette1, 0);
+ ++_chapter5Counter;
+ break;
+
+ case 1500:
+ getScreen()->setPalette(palette2);
+ getScreen()->setGammaLevel(palette2, 0);
+ _chapter5Counter = 0;
+ _paletteFlag = true;
+ _paletteTick2 = _vm->getTick() + rnd(1000) + 1000;
+ break;
+ }
+ }
}
void Special::playSoundPanning(ResourceId resourceId, int32 attenuation, Object *object) {
diff --git a/engines/asylum/resources/special.h b/engines/asylum/resources/special.h
index a4c8e658a8..a29eb90e0e 100644
--- a/engines/asylum/resources/special.h
+++ b/engines/asylum/resources/special.h
@@ -48,6 +48,11 @@ private:
// Counters
int32 _chapter2Counter;
+ int32 _chapter5Counter;
+
+ bool _paletteFlag;
+ int32 _paletteTick1;
+ int32 _paletteTick2;
//////////////////////////////////////////////////////////////////////////
// Spec functions
diff --git a/engines/asylum/system/screen.cpp b/engines/asylum/system/screen.cpp
index 381a1cc00e..aea4c4e553 100644
--- a/engines/asylum/system/screen.cpp
+++ b/engines/asylum/system/screen.cpp
@@ -136,7 +136,7 @@ void Screen::setPalette(byte *rgbPalette) {
}
void Screen::setGammaLevel(ResourceId id, int32 val) {
- error("[Screen::setGammaLevel] not implemented");
+ warning("[Screen::setGammaLevel] not implemented");
}
void Screen::drawWideScreen(int16 barSize) {
Commit: 980ecdf3d4c9c9d83dd305fc8604a83d7653a95d
https://github.com/scummvm/scummvm/commit/980ecdf3d4c9c9d83dd305fc8604a83d7653a95d
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:17+02:00
Commit Message:
ASYLUM: Implement last 2 special chapter sound logic
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@536 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/resources/special.cpp
engines/asylum/shared.h
diff --git a/engines/asylum/resources/special.cpp b/engines/asylum/resources/special.cpp
index 7b87abc39a..f260625a70 100644
--- a/engines/asylum/resources/special.cpp
+++ b/engines/asylum/resources/special.cpp
@@ -663,7 +663,78 @@ void Special::playSoundChapter1(Object *object, ActorIndex actorIndex) {
}
void Special::playSoundChapter2(Object *object, ActorIndex actorIndex) {
- error("[Special::playSoundChapter2] Not implemented!");
+ if (actorIndex == kActorInvalid) {
+ switch(object->getId()) {
+ default:
+ break;
+
+ case kObjectJessieStatusQuo:
+ case kObjectTicaTac01:
+ if (_vm->getRandomBit()) {
+ if (!getSound()->isPlaying(MAKE_RESOURCE(kResourcePackSharedSound, 1848))
+ && !getSound()->isPlaying(MAKE_RESOURCE(kResourcePackSharedSound, 1849))
+ && !getSound()->isPlaying(MAKE_RESOURCE(kResourcePackSharedSound, 1850))
+ && !getSound()->isPlaying(MAKE_RESOURCE(kResourcePackSharedSound, 1844))
+ && !getSound()->isPlaying(MAKE_RESOURCE(kResourcePackSharedSound, 1845))
+ && !getSound()->isPlaying(MAKE_RESOURCE(kResourcePackSharedSound, 1846))) {
+ if (object->getId() == kObjectJessieStatusQuo)
+ playSoundPanning(MAKE_RESOURCE(kResourcePackSharedSound, 1848 + rnd(3)), 13, object);
+ else
+ playSoundPanning(MAKE_RESOURCE(kResourcePackSharedSound, 1844 + rnd(3)), 19, object);
+ }
+ }
+ break;
+
+ case kObjectDennisStatusQuo:
+ case kObjectDennisStatus2:
+ if (_vm->getRandomBit())
+ playSoundPanning(MAKE_RESOURCE(kResourcePackSharedSound, 1856), 16, object);
+ break;
+
+ case kObjectSuckerSittingStatusQuo:
+ if (_vm->getRandomBit())
+ playSoundPanning(MAKE_RESOURCE(kResourcePackSharedSound, 1859), 15, object);
+ break;
+
+ case kObjectSailorBoy:
+ case kObjectSailorStatusQuo:
+ if (_vm->getRandomBit())
+ playSoundPanning(MAKE_RESOURCE(kResourcePackSharedSound, 1858), 19, object);
+ break;
+
+ case kObjectFishingBoy:
+ if (_vm->getRandomBit())
+ playSoundPanning(MAKE_RESOURCE(kResourcePackSharedSound, 1860), 19, object);
+ break;
+
+ case kObjectMarty02:
+ if (_vm->getRandomBit())
+ playSoundPanning(MAKE_RESOURCE(kResourcePackSharedSound, 1854), 15, object);
+ break;
+
+ case kObjectEleenOnGround:
+ case kObjectEileenOnBench:
+ case kObject994:
+ if (_vm->getRandomBit())
+ playSoundPanning(MAKE_RESOURCE(kResourcePackSharedSound, 1857), 28, object);
+ break;
+ }
+ } else {
+ switch (actorIndex) {
+ default:
+ break;
+
+ case 1:
+ if (_vm->getRandomBit())
+ playSoundPanning(MAKE_RESOURCE(kResourcePackSharedSound, 1855), 18, actorIndex);
+ break;
+
+ case 5:
+ if (_vm->getRandomBit())
+ playSoundPanning(MAKE_RESOURCE(kResourcePackSharedSound, 1859), 15, actorIndex);
+ break;
+ }
+ }
}
void Special::playSoundChapter3(Object *object, ActorIndex actorIndex) {
@@ -756,8 +827,8 @@ void Special::playSoundChapter4(Object *object, ActorIndex actorIndex) {
playSoundPanning(MAKE_RESOURCE(kResourcePackSharedSound, 1903), 14, object);
break;
- case kObjectNPC032SQOutside:
- case kObjectNPC032SQBigTop:
+ case kObjectNPC032StatusQuoOutside:
+ case kObjectNPC032StatusQuoBigTop:
if (_vm->getRandomBit())
playSoundPanning(MAKE_RESOURCE(kResourcePackSharedSound, 1904), 14, object);
break;
@@ -767,23 +838,23 @@ void Special::playSoundChapter4(Object *object, ActorIndex actorIndex) {
playSoundPanning(MAKE_RESOURCE(kResourcePackSharedSound, 1879), 16, object);
break;
- case kObjectTattooManSQ:
+ case kObjectTattooManStatusQuo:
if (_vm->getRandomBit())
playSoundPanning(MAKE_RESOURCE(kResourcePackSharedSound, 1884), 14, object);
break;
- case kObjectStrongmanSQ:
+ case kObjectStrongmanStatusQuo:
case kObjectStrongmanLeft:
case kObjectStrongmanRight:
playSoundPanning(MAKE_RESOURCE(kResourcePackSharedSound, 1885), 16, object);
break;
- case kObjectStrongmanSQ2:
+ case kObjectStrongmanStatusQuo2:
if (_vm->getRandomBit())
playSoundPanning(MAKE_RESOURCE(kResourcePackSharedSound, 1886), 16, object);
break;
- case kObjectInfernoSQ:
+ case kObjectInfernoStatusQuo:
if (_vm->getRandomBit())
playSoundPanning(MAKE_RESOURCE(kResourcePackSharedSound, 1905), 12, object);
break;
@@ -792,73 +863,73 @@ void Special::playSoundChapter4(Object *object, ActorIndex actorIndex) {
playSoundPanning(MAKE_RESOURCE(kResourcePackSharedSound, 1906), 12, object);
break;
- case kObjectClownSQ:
+ case kObjectClownStatusQuo:
if (_vm->getRandomBit())
playSoundPanning(MAKE_RESOURCE(kResourcePackSharedSound, 1907), 10, object);
break;
- case kObjectTrixieSQ:
+ case kObjectTrixieStatusQuo:
if (_vm->getRandomBit())
playSoundPanning(MAKE_RESOURCE(kResourcePackSharedSound, 1908), 12, object);
break;
- case kObjectSimonSQ:
+ case kObjectSimonStatusQuo:
if (_vm->getRandomBit())
playSoundPanning(MAKE_RESOURCE(kResourcePackSharedSound, 1909), 12, object);
break;
- case kObjectFunTixSQ:
+ case kObjectFunTixStatusQuo:
if (_vm->getRandomBit())
playSoundPanning(MAKE_RESOURCE(kResourcePackSharedSound, 1913), 10, object);
break;
- case kObjectFreakTixSQUp:
- case kObjectFreakTixSQDown:
+ case kObjectFreakTixStatusQuoUp:
+ case kObjectFreakTixStatusQuoDown:
if (_vm->getRandomBit())
playSoundPanning(MAKE_RESOURCE(kResourcePackSharedSound, 1914), 9, object);
break;
- case kObjectFortTellerSQ:
+ case kObjectFortTellerStatusQuo:
if (_vm->getRandomBit())
playSoundPanning(MAKE_RESOURCE(kResourcePackSharedSound, 1915), 15, object);
break;
- case kObjectRingTossSQ:
+ case kObjectRingTossStatusQuo:
if (_vm->getRandomBit())
playSoundPanning(MAKE_RESOURCE(kResourcePackSharedSound, 1916), 10, object);
break;
- case kObjectPigShootSQ:
+ case kObjectPigShootStatusQuo:
if (_vm->getRandomBit())
playSoundPanning(MAKE_RESOURCE(kResourcePackSharedSound, 1917), 10, object);
break;
- case kObjectKnockDownSQ:
+ case kObjectKnockDownStatusQuo:
if (_vm->isGameFlagNotSet(kGameFlag358) && _vm->getRandomBit())
playSoundPanning(MAKE_RESOURCE(kResourcePackSharedSound, 1918), 10, object);
break;
- case kObjectPretZoolSQ:
+ case kObjectPretZoolStatusQuo:
if (_vm->getRandomBit())
playSoundPanning(MAKE_RESOURCE(kResourcePackSharedSound, 1919), 14, object);
break;
- case kObjectTimberSQ:
+ case kObjectTimberStatusQuo:
if (_vm->getRandomBit())
playSoundPanning(MAKE_RESOURCE(kResourcePackSharedSound, 1920), 14, object);
break;
- case kObjectTwinsSQ:
+ case kObjectTwinsStatusQuo:
if (_vm->getRandomBit())
playSoundPanning(MAKE_RESOURCE(kResourcePackSharedSound, 1921), 20, object);
break;
- case kObjectSeanSQ:
+ case kObjectSeanStatusQuo:
if (_vm->getRandomBit())
playSoundPanning(MAKE_RESOURCE(kResourcePackSharedSound, 1923), 16, object);
break;
- case kObjectMomAndPopSQ:
+ case kObjectMomAndPopStatusQuo:
if (_vm->getRandomBit())
playSoundPanning(MAKE_RESOURCE(kResourcePackSharedSound, 1852), 15, object);
@@ -897,7 +968,7 @@ void Special::playSoundChapter6(Object *object, ActorIndex actorIndex) {
default:
break;
- case kObjectGravinSQCyber:
+ case kObjectGravinStatusQuoCyber:
if (_vm->getRandomBit())
playSoundPanning(MAKE_RESOURCE(kResourcePackSharedSound, 1880), 14, object);
break;
@@ -907,27 +978,27 @@ void Special::playSoundChapter6(Object *object, ActorIndex actorIndex) {
playSoundPanning(MAKE_RESOURCE(kResourcePackSharedSound, 1880), 14, object);
break;
- case kObjectNPC062GritzaSQ:
+ case kObjectNPC062GritzaStatusQuo:
if (_vm->getRandomBit())
playSoundPanning(MAKE_RESOURCE(kResourcePackSharedSound, 1881), 12, object);
break;
- case kObjectNPC063GrundleSQ:
+ case kObjectNPC063GrundleStatusQuo:
if (_vm->getRandomBit())
playSoundPanning(MAKE_RESOURCE(kResourcePackSharedSound, 1882), 12, object);
break;
- case kObjectNPC064GrellaSQ:
+ case kObjectNPC064GrellaStatusQuo:
if (_vm->getRandomBit())
playSoundPanning(MAKE_RESOURCE(kResourcePackSharedSound, 1883), 12, object);
break;
- case kObjectNPC065SQ:
+ case kObjectNPC065StatusQuo:
if (_vm->getRandomBit())
playSoundPanning(MAKE_RESOURCE(kResourcePackSharedSound, 1868), 12, object);
break;
- case kObjectNPC066SQ:
+ case kObjectNPC066StatusQuo:
if (_vm->getRandomBit())
playSoundPanning(MAKE_RESOURCE(kResourcePackSharedSound, 1867), 12, object);
break;
@@ -956,7 +1027,114 @@ void Special::playSoundChapter7(Object *object, ActorIndex actorIndex) {
}
void Special::playSoundChapter8(Object *object, ActorIndex actorIndex) {
- error("[Special::playSoundChapter8] Not implemented!");
+ if (actorIndex == kActorInvalid) {
+ switch(object->getId()) {
+ default:
+ break;
+
+ case kObject703:
+ if (_vm->getRandomBit())
+ playSoundPanning(MAKE_RESOURCE(kResourcePackSharedSound, 1874), 10, object);
+ break;
+
+ case kObjectTree8:
+ if (_vm->getRandomBit())
+ playSoundPanning(MAKE_RESOURCE(kResourcePackSharedSound, 1875), 10, object);
+ break;
+
+ case kObjectSlab:
+ if (_vm->getRandomBit())
+ playSoundPanning(MAKE_RESOURCE(kResourcePackSharedSound, 1922), 10, object);
+ break;
+
+ case kObjectWitchDoctor:
+ if (_vm->getRandomBit())
+ playSoundPanning(MAKE_RESOURCE(kResourcePackSharedSound, 1863), 16, object);
+ break;
+
+ case kObjectStoneWifeStatuQuo:
+ if (_vm->getRandomBit())
+ playSoundPanning(MAKE_RESOURCE(kResourcePackSharedSound, 1872), 15, object);
+ break;
+
+ case kObjectFishermanWidowStatusQuo:
+ if (_vm->isGameFlagNotSet(kGameFlag553) && !getSound()->isPlaying(getSpeech()->getSoundResourceId()))
+ playSoundPanning(MAKE_RESOURCE(kResourcePackSharedSound, 1870), 10, object);
+ break;
+
+ case kObjectStoneMasonStatusHitt:
+ if (rnd(100) < 30)
+ playSoundPanning(MAKE_RESOURCE(kResourcePackSharedSound, 1873), 15, object);
+ break;
+
+ case kObjectGirlStatusQuo:
+ if (_vm->getRandomBit())
+ playSoundPanning(MAKE_RESOURCE(kResourcePackSharedSound, 1871), 15, object);
+ break;
+
+ case kObjectWitchWifeStirring:
+ if (rnd(100) < 30)
+ playSoundPanning(MAKE_RESOURCE(kResourcePackSharedSound, 1869), 17, object);
+ break;
+
+ case kObjectQuetzlcaotlStatusQuo:
+ playSoundPanning(MAKE_RESOURCE(kResourcePackSharedSound, 1864), 3, object);
+ break;
+
+ case kObjectBlanklPixelForWarrior:
+ if (_vm->getRandomBit())
+ playSoundPanning(MAKE_RESOURCE(kResourcePackSharedSound, 1876), 10, object);
+ break;
+
+ case kObjectPixelForHutWarrior:
+ if (_vm->getRandomBit())
+ playSoundPanning(MAKE_RESOURCE(kResourcePackSharedSound, 1878), 10, object);
+ break;
+
+ case kObjectPixelForWaterfallGhost:
+ if (_vm->getRandomBit())
+ playSoundPanning(MAKE_RESOURCE(kResourcePackSharedSound, 1877), 10, object);
+ break;
+ }
+ } else {
+ if (!_vm->isGameFlagNotSet(kGameFlag528))
+ return;
+
+ switch (actorIndex) {
+ default:
+ break;
+
+ case 1:
+ if (!getSound()->isPlaying(getWorld()->soundResourceIds[8]))
+ playSoundPanning(getWorld()->soundResourceIds[8], 15, actorIndex);
+ break;
+
+ case 2:
+ if (!getSound()->isPlaying(getWorld()->soundResourceIds[7]))
+ playSoundPanning(getWorld()->soundResourceIds[7], 15, actorIndex);
+ break;
+
+ case 3:
+ if (!getSound()->isPlaying(getWorld()->soundResourceIds[11]))
+ playSoundPanning(getWorld()->soundResourceIds[11], 15, actorIndex);
+ break;
+
+ case 4:
+ if (!getSound()->isPlaying(getWorld()->soundResourceIds[12]))
+ playSoundPanning(getWorld()->soundResourceIds[12], 15, actorIndex);
+ break;
+
+ case 5:
+ if (!getSound()->isPlaying(getWorld()->soundResourceIds[13]))
+ playSoundPanning(getWorld()->soundResourceIds[13], 15, actorIndex);
+ break;
+
+ case 6:
+ if (!getSound()->isPlaying(getWorld()->soundResourceIds[14]))
+ playSoundPanning(getWorld()->soundResourceIds[7], 15, actorIndex); // BUG: Are we really supposed to use that sound (7 instead of 14)
+ break;
+ }
+ }
}
//////////////////////////////////////////////////////////////////////////
@@ -1029,7 +1207,7 @@ void Special::playSoundPanning(ResourceId resourceId, int32 attenuation, Object
}
break;
- case kObjectDennisStatus:
+ case kObjectDennisStatusQuo:
x = 1382;
y = 1041;
break;
@@ -1039,7 +1217,7 @@ void Special::playSoundPanning(ResourceId resourceId, int32 attenuation, Object
y = 1220;
break;
- case kObjectSuckerSittingStatus:
+ case kObjectSuckerSittingStatusQuo:
x = 1376;
y = 1148;
break;
diff --git a/engines/asylum/shared.h b/engines/asylum/shared.h
index 212419fe9f..31c5583b81 100644
--- a/engines/asylum/shared.h
+++ b/engines/asylum/shared.h
@@ -67,6 +67,8 @@ enum GameFlag {
kGameFlag453 = 453,
kGameFlag454 = 454,
kGameFlag455 = 455,
+ kGameFlag528 = 528,
+ kGameFlag553 = 553,
kGameFlag556 = 556,
kGameFlag776 = 776,
kGameFlagFinishGame = 901,
@@ -303,10 +305,14 @@ enum ObjectId {
kObjectNone = 0,
kObjectHeadBanger = 101,
kObjectAngelFlares = 112,
+ kObjectTicaTac01 = 391,
kObjectGuyFalls = 434,
kObjectGuyWobbles = 405,
kObjectRocker = 441,
kObjectOpeningGate = 485,
+ kObject703 = 703,
+ kObjectTree8 = 726,
+ kObjectSlab = 743,
kObjectPreacherBobAssistant = 802,
kObjectPreacherBob = 803,
kObjectNPC024Church = 816,
@@ -317,9 +323,16 @@ enum ObjectId {
kObjectNPC027Dancing = 844,
kObjectNPC028Dancing = 845,
kObjectNPC026OutOfWay = 861,
- kObjectDennisStatus = 1011,
+ kObjectJessieStatusQuo = 984,
+ kObjectMarty02 = 991,
+ kObjectEileenOnBench = 993,
+ kObject994 = 994,
+ kObjectFishingBoy = 1001,
+ kObjectDennisStatusQuo = 1011,
kObjectSailorBoy = 1013,
- kObjectSuckerSittingStatus = 1084,
+ kObjectEleenOnGround = 1019,
+ kObjectSailorStatusQuo = 1021,
+ kObjectSuckerSittingStatusQuo = 1084,
kObjectBubbles = 1185,
kObjectGlow = 1186,
kObjectDome = 1187,
@@ -328,8 +341,8 @@ enum ObjectId {
kObjectBallMovesUpright = 1190,
kObjectGearsLightUp = 1191,
kObjectNPC032Sleeping = 1250,
- kObjectNPC032SQOutside = 1254,
- kObjectNPC032SQBigTop = 1256,
+ kObjectNPC032StatusQuoOutside = 1254,
+ kObjectNPC032StatusQuoBigTop = 1256,
kObjectGlobe = 1261,
kObjectDrawers3 = 1276,
kObjectFreezerHallInterior = 1337,
@@ -337,28 +350,28 @@ enum ObjectId {
kObjectNPC033GetBook = 1343,
kObjectNPC033Reading = 1344,
kObjectOldMan3 = 1377,
- kObjectTattooManSQ = 1391, // NPC 34
- kObjectStrongmanSQ = 1402, // NPC 35
- kObjectStrongmanSQ2 = 1405, // NPC 35
- kObjectInfernoSQ = 1408, // NPC 36
+ kObjectTattooManStatusQuo = 1391, // NPC 34
+ kObjectStrongmanStatusQuo = 1402, // NPC 35
+ kObjectStrongmanStatusQuo2 = 1405, // NPC 35
+ kObjectInfernoStatusQuo = 1408, // NPC 36
kObjectJuggler = 1424, // NPC 37
- kObjectClownSQ = 1428, // NPC 38
- kObjectTrixieSQ = 1432, // NPC 39
- kObjectSimonSQ = 1434, // NPC 40
- kObjectFunTixSQ = 1437, // NPC 44
- kObjectFreakTixSQUp = 1439, // NPC 45
- kObjectFreakTixSQDown = 1440, // NPC 45
- kObjectFortTellerSQ = 1444, // NPC 45
+ kObjectClownStatusQuo = 1428, // NPC 38
+ kObjectTrixieStatusQuo = 1432, // NPC 39
+ kObjectSimonStatusQuo = 1434, // NPC 40
+ kObjectFunTixStatusQuo = 1437, // NPC 44
+ kObjectFreakTixStatusQuoUp = 1439, // NPC 45
+ kObjectFreakTixStatusQuoDown = 1440, // NPC 45
+ kObjectFortTellerStatusQuo = 1444, // NPC 45
kObjectStrongmanLeft = 1449, // NPC 35
kObjectStrongmanRight = 1450, // NPC 35
- kObjectRingTossSQ = 1451, // NPC 47
- kObjectKnockDownSQ = 1455, // NPC 47
- kObjectPigShootSQ = 1456, // NPC 47
- kObjectPretZoolSQ = 1461, // NPC 48
- kObjectTimberSQ = 1462, // NPC 49
- kObjectTwinsSQ = 1465, // NPC 50
- kObjectSeanSQ = 1468, // NPC 51
- kObjectMomAndPopSQ = 1470, // NPCs 52-53
+ kObjectRingTossStatusQuo = 1451, // NPC 47
+ kObjectKnockDownStatusQuo = 1455, // NPC 47
+ kObjectPigShootStatusQuo = 1456, // NPC 47
+ kObjectPretZoolStatusQuo = 1461, // NPC 48
+ kObjectTimberStatusQuo = 1462, // NPC 49
+ kObjectTwinsStatusQuo = 1465, // NPC 50
+ kObjectSeanStatusQuo = 1468, // NPC 51
+ kObjectMomAndPopStatusQuo = 1470, // NPCs 52-53
kObjectCrow1FlysAway = 1485,
kObjectCrow1Pecks = 1486,
kObjectCrow2AmbientPecks = 1495,
@@ -370,6 +383,9 @@ enum ObjectId {
kObjectDennisStatus2 = 1580,
kObjectPreAlphaNut = 1582,
kObjectPreAlphaNut2 = 1584,
+ kObjectWitchDoctor = 1778,
+ kObjectStoneWifeStatuQuo = 1782,
+ kObjectFishermanWidowStatusQuo = 1786,
kObjectWheel1 = 2113,
kObjectWheel2 = 2114,
kObjectWheel3 = 2115,
@@ -377,19 +393,28 @@ enum ObjectId {
kObjectWheel5 = 2117,
kObjectWheel6 = 2118,
kObjectWheel7 = 2119,
- kObjectGravinSQCyber = 2324,
+ kObjectStoneMasonStatusHitt = 2123,
+ kObjectGravinStatusQuoCyber = 2324,
kObjectGravinWorkMachine = 2337,
- kObjectNPC062GritzaSQ = 2399,
- kObjectNPC063GrundleSQ = 2410,
- kObjectNPC064GrellaSQ = 2418,
- kObjectNPC065SQ = 2469,
- kObjectNPC066SQ = 2504,
+ kObjectNPC062GritzaStatusQuo = 2399,
+ kObjectNPC063GrundleStatusQuo = 2410,
+ kObjectNPC064GrellaStatusQuo = 2418,
+ kObjectNPC065StatusQuo = 2469,
+ kObjectNPC066StatusQuo = 2504,
kObjectBodySlides1 = 2514,
kObjectBodySlides2 = 2515,
kObjectBodySlides3 = 2516,
kObjectBodySlides4 = 2517,
kObjectBodySlides5 = 2518,
- kObjectBodySlides6 = 2519
+ kObjectBodySlides6 = 2519,
+ kObjectGirlStatusQuo = 2541,
+ kObjectWitchWifeStirring = 2543,
+ kObjectQuetzlcaotlStatusQuo = 2578,
+ kObjectBlanklPixelForWarrior = 2884,
+ kObjectPixelForHutWarrior = 2885,
+ kObjectPixelForWaterfallGhost = 2886,
+
+ kObjectEnd
};
enum ObjectFlag {
Commit: b475ba03a8dc459e1a432b94bd455760f9251561
https://github.com/scummvm/scummvm/commit/b475ba03a8dc459e1a432b94bd455760f9251561
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:17+02:00
Commit Message:
ASYLUM: Implement special logic for chapter 8
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@537 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/resources/special.cpp
engines/asylum/resources/worldstats.cpp
engines/asylum/resources/worldstats.h
engines/asylum/shared.h
engines/asylum/views/scene.cpp
diff --git a/engines/asylum/resources/special.cpp b/engines/asylum/resources/special.cpp
index f260625a70..4c485d0522 100644
--- a/engines/asylum/resources/special.cpp
+++ b/engines/asylum/resources/special.cpp
@@ -511,7 +511,86 @@ void Special::chapter7(Object *object, ActorIndex actorIndex) {
}
void Special::chapter8(Object *object, ActorIndex actorIndex) {
+ playChapterSound(object, actorIndex);
+ if (actorIndex == kActorInvalid) {
+ switch (object->getId()) {
+ default:
+ break;
+
+ case kObjectRitualLoop:
+ if (object->getFrameIndex() == object->getFrameCount() - 1) {
+ if (!getSound()->isPlaying(getSpeech()->getSoundResourceId()))
+ _vm->setGameFlag(kGameFlag897);
+ }
+ break;
+
+ case kObjectWadeThroughLava: {
+ Actor *actor0 = getScene()->getActor(0);
+
+ if (object->getFrameIndex() == 23) {
+ if (_vm->isGameFlagNotSet(kGameFlag815))
+ actor0->process_41BC00(1, 0);
+
+ _vm->setGameFlag(kGameFlag815);
+ }
+
+ if (object->getFrameIndex() == 50) {
+ object->disableAndRemoveFromQueue();
+ actor0->setDirection(4);
+
+ getCursor()->show();
+ getWorld()->motionStatus = 1;
+
+ _vm->clearFlag(kFlagType1);
+
+ actor0->show();
+ }
+ }
+ break;
+
+ case kObjectLavaBridge:
+ if (getWorld()->ambientSounds[4].field_C > -100)
+ getWorld()->ambientSounds[4].field_C -= 5;
+
+ if (_vm->isGameFlagSet(kGameFlag937)) {
+ if (getWorld()->ambientSounds[5].field_C > -100)
+ getWorld()->ambientSounds[5].field_C -= 5;
+ }
+ break;
+
+ case kObjectFlamingHeadLeftSide:
+ checkFlags(kObjectGhost1, kGameFlag543, kGameFlag544, kGameFlag545, kGameFlag875, &getWorld()->field_E8610[0], &getWorld()->field_E8628[0], kGameFlag1062, &getWorld()->field_E8660[0]);
+ checkFlags(_vm->isGameFlagSet(kGameFlag881) ? kObjectGhost2b : kObjectGhost2, kGameFlag816, kGameFlag817, kGameFlag818, kGameFlag876, &getWorld()->field_E8610[1], &getWorld()->field_E8628[1], kGameFlag1063, &getWorld()->field_E8660[1]);
+ checkFlags(kObjectGhost3, kGameFlag819, kGameFlag820, kGameFlag821, kGameFlag877, &getWorld()->field_E8610[2], &getWorld()->field_E8628[2], kGameFlag1064, &getWorld()->field_E8660[2]);
+ checkFlags(kObjectGhost4, kGameFlag822, kGameFlag823, kGameFlag824, kGameFlag878, &getWorld()->field_E8610[3], &getWorld()->field_E8628[3], kGameFlag1065, &getWorld()->field_E8660[3]);
+ checkFlags(kObjectGhost5, kGameFlag825, kGameFlag826, kGameFlag827, kGameFlag879, &getWorld()->field_E8610[4], &getWorld()->field_E8628[4], kGameFlag1066, &getWorld()->field_E8660[4]);
+ checkFlags(kObjectGhost6, kGameFlag828, kGameFlag829, kGameFlag830, kGameFlag880, &getWorld()->field_E8610[5], &getWorld()->field_E8628[5], kGameFlag1067, &getWorld()->field_E8660[5]);
+
+ updateObjectFlag(kObjectGong4);
+ updateObjectFlag(kObjectGong1);
+ updateObjectFlag(kObjectGong5);
+ updateObjectFlag(kObjectGong6);
+ updateObjectFlag(kObjectGong2);
+ updateObjectFlag(kObjectGong3);
+ break;
+ }
+ }
+
+ if (_vm->isGameFlagNotSet(kGameFlag866)) {
+ // Check wheel objects frame index
+ if (getWorld()->wheels[0]->getFrameIndex() == 0
+ && getWorld()->wheels[1]->getFrameIndex() == 4
+ && getWorld()->wheels[2]->getFrameIndex() == 8
+ && getWorld()->wheels[3]->getFrameIndex() == 12
+ && getWorld()->wheels[4]->getFrameIndex() == 16
+ && getWorld()->wheels[5]->getFrameIndex() == 23
+ && getWorld()->wheels[6]->getFrameIndex() == 27) {
+ _vm->setGameFlag(kGameFlag866);
+
+ getSound()->playSound(getWorld()->soundResourceIds[6], false, Config.sfxVolume - 10);
+ }
+ }
}
void Special::chapter9(Object *object, ActorIndex actorIndex) {
@@ -1255,11 +1334,76 @@ void Special::playSoundPanning(ResourceId resourceId, int32 attenuation, ActorIn
}
void Special::updateObjectFlag(ObjectId id) {
- error("[Special::updateObjectFlag] Not implemented!");
+ // Check if any of the scene sound resources are playing
+ for (int i = 0; i < 7; i++) {
+ if (getSound()->isPlaying(getWorld()->soundResourceIds[i]))
+ return;
+ }
+
+ getWorld()->getObjectById(id)->flags &= ~kObjectFlag10E38;
}
void Special::checkFlags(ObjectId id, GameFlag flag1, GameFlag flag2, GameFlag flag3, GameFlag flag4, int *val1, int *val2, GameFlag flag5, int *val3) {
- error("[Special::checkFlags] Not implemented!");
+ if (_vm->isGameFlagSet(flag5)
+ && _vm->isGameFlagNotSet(flag2)
+ && _vm->isGameFlagNotSet(flag1)) {
+ _vm->clearGameFlag(flag5);
+
+ *val1 = 1;
+ }
+
+ if (!*val1) {
+ *val1 = _vm->getTick() - rnd(2000);
+ return;
+ }
+
+ if (!_vm->isGameFlagNotSet(flag3)) {
+ *val1 = _vm->getTick();
+ return;
+ }
+
+ if ((_vm->getTick() - *val1) > 10000) {
+ if (_vm->isGameFlagSet(flag2)) {
+
+ _vm->clearGameFlag(flag4);
+ _vm->clearGameFlag(flag5);
+
+ if (*val2 >= 8) {
+ *val1 = 0;
+ *val2 = 0;
+
+ _vm->clearGameFlag(flag1);
+ _vm->clearGameFlag(flag2);
+
+ getWorld()->getObjectById(id)->setField67C(0);
+
+ } else {
+ *val2++;
+
+ getWorld()->getObjectById(id)->setField67C(6 - Common::Rational(*val2, 4).toInt());
+ }
+ } else {
+
+ _vm->setGameFlag(flag1);
+
+ *val3 = 0;
+
+ if (*val2 >= 8) {
+ *val1 = 0;
+ *val2 = 0;
+
+ _vm->clearGameFlag(flag2);
+ _vm->clearGameFlag(flag4);
+
+ getWorld()->getObjectById(id)->setField67C(0);
+
+ } else {
+ *val2++;
+
+ getWorld()->getObjectById(id)->setField67C(Common::Rational(*val2, 4).toInt() + 4);
+ }
+ }
+ }
}
//////////////////////////////////////////////////////////////////////////
diff --git a/engines/asylum/resources/worldstats.cpp b/engines/asylum/resources/worldstats.cpp
index 380314f8f1..fbca62272d 100644
--- a/engines/asylum/resources/worldstats.cpp
+++ b/engines/asylum/resources/worldstats.cpp
@@ -210,6 +210,27 @@ void WorldStats::load(Common::SeekableReadStream *stream) {
// Jump over unused actions
stream->seek((ACTIONS_MAX_COUNT - numActions) * ACTIONS_SIZE, SEEK_CUR);
+
+ field_E860C = stream->readSint32LE();
+ for (int32 i = 0; i < 6; i++)
+ field_E8610[i] = stream->readSint32LE();
+
+ for (int32 i = 0; i < 6; i++)
+ field_E8628[i] = stream->readSint32LE();
+
+ for (int32 i = 0; i < 7; i++) {
+ ObjectId id = (ObjectId)stream->readSint32LE();
+
+ if (id == 0)
+ wheels[i] = NULL;
+ else
+ wheels[i] = getObjectById(id);
+ }
+
+ tickCount1 = stream->readSint32LE();
+
+ for (int32 i = 0; i < 6; i++)
+ field_E8660[i] = stream->readSint32LE();
}
//////////////////////////////////////////////////////////////////////////
diff --git a/engines/asylum/resources/worldstats.h b/engines/asylum/resources/worldstats.h
index 62870e36be..eb8e955c2d 100644
--- a/engines/asylum/resources/worldstats.h
+++ b/engines/asylum/resources/worldstats.h
@@ -118,8 +118,11 @@ public:
Common::Array<ActionArea*> actions; // maxsize 400
// TODO add rest fields
int32 field_E860C;
- // TODO add rest fields
+ int32 field_E8610[6];
+ int32 field_E8628[6];
Object *wheels[7];
+ int32 tickCount1;
+ int32 field_E8660[6];
void setWheelObjects();
diff --git a/engines/asylum/shared.h b/engines/asylum/shared.h
index 31c5583b81..d54fa13e55 100644
--- a/engines/asylum/shared.h
+++ b/engines/asylum/shared.h
@@ -68,14 +68,49 @@ enum GameFlag {
kGameFlag454 = 454,
kGameFlag455 = 455,
kGameFlag528 = 528,
+ kGameFlag543 = 543,
+ kGameFlag544 = 544,
+ kGameFlag545 = 545,
kGameFlag553 = 553,
kGameFlag556 = 556,
kGameFlag776 = 776,
+ kGameFlag815 = 815,
+ kGameFlag816 = 816,
+ kGameFlag817 = 817,
+ kGameFlag818 = 818,
+ kGameFlag819 = 819,
+ kGameFlag820 = 820,
+ kGameFlag821 = 821,
+ kGameFlag822 = 822,
+ kGameFlag823 = 823,
+ kGameFlag824 = 824,
+ kGameFlag825 = 825,
+ kGameFlag826 = 826,
+ kGameFlag827 = 827,
+ kGameFlag828 = 828,
+ kGameFlag829 = 829,
+ kGameFlag830 = 830,
+ kGameFlag866 = 866,
+ kGameFlag875 = 875,
+ kGameFlag876 = 876,
+ kGameFlag877 = 877,
+ kGameFlag878 = 878,
+ kGameFlag879 = 879,
+ kGameFlag880 = 880,
+ kGameFlag881 = 881,
+ kGameFlag897 = 897,
kGameFlagFinishGame = 901,
+ kGameFlag937 = 937,
kGameFlag1009 = 1009,
kGameFlag1021 = 1021,
kGameFlag1022 = 1022,
kGameFlag1023 = 1023,
+ kGameFlag1062 = 1062,
+ kGameFlag1063 = 1063,
+ kGameFlag1064 = 1064,
+ kGameFlag1065 = 1065,
+ kGameFlag1066 = 1066,
+ kGameFlag1067 = 1067,
kGameFlag1108 = 1108,
kGameFlag1131 = 1131,
kGameFlag1137 = 1137
@@ -394,12 +429,15 @@ enum ObjectId {
kObjectWheel6 = 2118,
kObjectWheel7 = 2119,
kObjectStoneMasonStatusHitt = 2123,
+ kObjectFlamingHeadLeftSide = 2129,
kObjectGravinStatusQuoCyber = 2324,
kObjectGravinWorkMachine = 2337,
kObjectNPC062GritzaStatusQuo = 2399,
kObjectNPC063GrundleStatusQuo = 2410,
kObjectNPC064GrellaStatusQuo = 2418,
+ kObjectLavaBridge = 2445,
kObjectNPC065StatusQuo = 2469,
+ kObjectWadeThroughLava = 2500,
kObjectNPC066StatusQuo = 2504,
kObjectBodySlides1 = 2514,
kObjectBodySlides2 = 2515,
@@ -410,6 +448,20 @@ enum ObjectId {
kObjectGirlStatusQuo = 2541,
kObjectWitchWifeStirring = 2543,
kObjectQuetzlcaotlStatusQuo = 2578,
+ kObjectGhost1 = 2579,
+ kObjectGhost2 = 2580,
+ kObjectGhost3 = 2581,
+ kObjectGhost4 = 2582,
+ kObjectGhost5 = 2583,
+ kObjectGhost6 = 2584,
+ kObjectGong1 = 2590,
+ kObjectGong2 = 2591,
+ kObjectGong3 = 2592,
+ kObjectGong4 = 2593,
+ kObjectGong5 = 2594,
+ kObjectGong6 = 2596,
+ kObjectGhost2b = 2634,
+ kObjectRitualLoop = 2674,
kObjectBlanklPixelForWarrior = 2884,
kObjectPixelForHutWarrior = 2885,
kObjectPixelForWaterfallGhost = 2886,
diff --git a/engines/asylum/views/scene.cpp b/engines/asylum/views/scene.cpp
index 7a6c951b23..a8063feafb 100644
--- a/engines/asylum/views/scene.cpp
+++ b/engines/asylum/views/scene.cpp
@@ -940,7 +940,7 @@ int32 Scene::calculateVolumeAdjustment(AmbientSoundItem *snd, Actor *act) {
}
void Scene::updateMusic() {
- //warning("[Scene::playIntroSpeech] not implemented!");
+ //warning("[Scene::updateMusic] not implemented!");
}
void Scene::updateScreen() {
Commit: 50e69da09a2d33c49b2bab3222413ac0a71632d9
https://github.com/scummvm/scummvm/commit/50e69da09a2d33c49b2bab3222413ac0a71632d9
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:17+02:00
Commit Message:
ASYLUM: Implement Actor::getFieldValue()
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@538 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/resources/actor.cpp
engines/asylum/resources/actor.h
diff --git a/engines/asylum/resources/actor.cpp b/engines/asylum/resources/actor.cpp
index 769a89fe70..0ca45812d1 100644
--- a/engines/asylum/resources/actor.cpp
+++ b/engines/asylum/resources/actor.cpp
@@ -460,6 +460,7 @@ void Actor::update() {
// Fallback to next case
case kActorStatus1:
+ // TODO: do actor direction
error("[Actor::update] kActorStatus1 / kActorStatus12 case not implemented");
break;
@@ -1233,4 +1234,30 @@ int32 Actor::getGraphicsFlags() {
return ((_direction < 5) - 1) & 2;
}
+int32 Actor::getFieldValue() {
+ int32 index = (_frameIndex >= _frameCount) ? (2 * _frameCount) - _frameIndex + 1 : _frameIndex;
+
+ switch (_direction) {
+ default:
+ case 0:
+ case 4:
+ return 0;
+
+ case 1:
+ case 3:
+ return -_field_8D0[index];
+
+ case 2:
+ return -_field_830[index];
+
+ case 5:
+ case 7:
+ return _field_8D0[index];
+
+ case 6:
+ return _field_830[index];;
+ }
+
+}
+
} // end of namespace Asylum
diff --git a/engines/asylum/resources/actor.h b/engines/asylum/resources/actor.h
index 96d1b34d89..92d490dfdb 100644
--- a/engines/asylum/resources/actor.h
+++ b/engines/asylum/resources/actor.h
@@ -398,6 +398,8 @@ private:
*/
int32 getGraphicsFlags();
+ int32 getFieldValue();
+
}; // end of class MainActor
Commit: 2fcf5167ac11c3039527e8df508b52a1237d15d3
https://github.com/scummvm/scummvm/commit/2fcf5167ac11c3039527e8df508b52a1237d15d3
Author: Arthur Blot (arthur.blot78 at gmail.com)
Date: 2021-05-17T15:36:17+02:00
Commit Message:
ASYLUM: Small fix for object and actor coordinates
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@539 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/resources/actor.cpp
engines/asylum/resources/object.cpp
diff --git a/engines/asylum/resources/actor.cpp b/engines/asylum/resources/actor.cpp
index 0ca45812d1..f633a4b3e6 100644
--- a/engines/asylum/resources/actor.cpp
+++ b/engines/asylum/resources/actor.cpp
@@ -245,7 +245,9 @@ void Actor::draw() {
// Draw the actor
Common::Point point;
- getScene()->adjustCoordinates(x + x1, y + y1, &point);
+ GraphicResource *gra = new GraphicResource(_vm, _resourceId);
+ GraphicFrame *fra = gra->getFrame(_frameIndex);
+ getScene()->adjustCoordinates(fra->x + x + x1, fra->y + y + y1, &point);
// Compute frame index
int32 frameIndex = _frameIndex;
diff --git a/engines/asylum/resources/object.cpp b/engines/asylum/resources/object.cpp
index cc32cfde0c..ec4040145a 100644
--- a/engines/asylum/resources/object.cpp
+++ b/engines/asylum/resources/object.cpp
@@ -178,10 +178,12 @@ void Object::draw() {
// Draw the object
Common::Point point;
- getScene()->adjustCoordinates(x, y, &point);
+ GraphicResource *gra = new GraphicResource(_vm, _resourceId);
+ GraphicFrame *fra = gra->getFrame(_frameIndex);
+ getScene()->adjustCoordinates(x + fra->x, y + fra->y, &point);
if (_field_67C <= 0 || _field_67C >= 4 || Config.performance <= 1) {
- getScreen()->addGraphicToQueue(_resourceId, _frameIndex, x, y, (flags >> 11) & kObjectFlag2, _field_67C - 3, _priority);
+ getScreen()->addGraphicToQueue(_resourceId, _frameIndex, point.x, point.y, (flags >> 11) & kObjectFlag2, _field_67C - 3, _priority);
} else {
// TODO: Do Cross Fade
//getScreen()->addGraphicToQueue(_resourceId, _frameIndex, x, y, getWorld()->backgroundImage, getWorld()->xLeft, getWorld()->yTop, 0, 0, _field_67C - 1);
Commit: f5b8dfe9595d99bca0f7e4cc6ef79a2024f6ae29
https://github.com/scummvm/scummvm/commit/f5b8dfe9595d99bca0f7e4cc6ef79a2024f6ae29
Author: Alex Bevilacqua (alexbevi at gmail.com)
Date: 2021-05-17T15:36:17+02:00
Commit Message:
ASYLUM: plug memory leak
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@540 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/resources/actor.cpp
engines/asylum/resources/object.cpp
diff --git a/engines/asylum/resources/actor.cpp b/engines/asylum/resources/actor.cpp
index f633a4b3e6..d4c0fde7c2 100644
--- a/engines/asylum/resources/actor.cpp
+++ b/engines/asylum/resources/actor.cpp
@@ -248,6 +248,7 @@ void Actor::draw() {
GraphicResource *gra = new GraphicResource(_vm, _resourceId);
GraphicFrame *fra = gra->getFrame(_frameIndex);
getScene()->adjustCoordinates(fra->x + x + x1, fra->y + y + y1, &point);
+ delete gra;
// Compute frame index
int32 frameIndex = _frameIndex;
diff --git a/engines/asylum/resources/object.cpp b/engines/asylum/resources/object.cpp
index ec4040145a..d653187d02 100644
--- a/engines/asylum/resources/object.cpp
+++ b/engines/asylum/resources/object.cpp
@@ -181,6 +181,7 @@ void Object::draw() {
GraphicResource *gra = new GraphicResource(_vm, _resourceId);
GraphicFrame *fra = gra->getFrame(_frameIndex);
getScene()->adjustCoordinates(x + fra->x, y + fra->y, &point);
+ delete gra;
if (_field_67C <= 0 || _field_67C >= 4 || Config.performance <= 1) {
getScreen()->addGraphicToQueue(_resourceId, _frameIndex, point.x, point.y, (flags >> 11) & kObjectFlag2, _field_67C - 3, _priority);
Commit: 692ade2186ada65c936328b8f7f0e37b68828016
https://github.com/scummvm/scummvm/commit/692ade2186ada65c936328b8f7f0e37b68828016
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:18+02:00
Commit Message:
ASYLUM: Switch ActorDirection to an enumeration
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@541 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/resources/actionlist.cpp
engines/asylum/resources/actor.cpp
engines/asylum/resources/actor.h
engines/asylum/resources/object.cpp
engines/asylum/resources/object.h
engines/asylum/resources/special.cpp
engines/asylum/shared.h
engines/asylum/views/scene.cpp
diff --git a/engines/asylum/resources/actionlist.cpp b/engines/asylum/resources/actionlist.cpp
index 2da727c6da..ebadd1efbd 100644
--- a/engines/asylum/resources/actionlist.cpp
+++ b/engines/asylum/resources/actionlist.cpp
@@ -459,7 +459,7 @@ IMPLEMENT_OPCODE(ShowActor) {
IMPLEMENT_OPCODE(SetActorPosition) {
Actor *actor = getScene()->getActor(cmd->param1);
- actor->setPosition(cmd->param2, cmd->param3, cmd->param4, cmd->param5);
+ actor->setPosition(cmd->param2, cmd->param3, (ActorDirection)cmd->param4, cmd->param5);
}
//////////////////////////////////////////////////////////////////////////
@@ -548,9 +548,9 @@ IMPLEMENT_OPCODE(JumpAndSetDirection) {
if (cmd->param5 != 2) {
if (cmd->param2 == -1 || cmd->param3 == -1) {
- actor->updateFromDirection(cmd->param4);
+ actor->updateFromDirection((ActorDirection)cmd->param4);
} else if ((actor->x1 + actor->x2) == cmd->param2 && (actor->y1 + actor->y2) == cmd->param3) {
- actor->updateFromDirection(cmd->param4);
+ actor->updateFromDirection((ActorDirection)cmd->param4);
} else {
actor->processStatus(cmd->param2, cmd->param3, cmd->param4);
@@ -564,7 +564,7 @@ IMPLEMENT_OPCODE(JumpAndSetDirection) {
_lineIncrement = 0;
if ((actor->x1 + actor->x2) == cmd->param2 && (actor->y1 + actor->y2) == cmd->param3)
- actor->updateFromDirection(cmd->param4);
+ actor->updateFromDirection((ActorDirection)cmd->param4);
}
} else {
if (cmd->param5 == 2)
@@ -784,7 +784,9 @@ IMPLEMENT_OPCODE(_unk2C_ActorSub) {
Actor *player = getScene()->getActor();
Actor *actor = getScene()->getActor(_currentQueueEntry.actorIndex);
Common::Point playerPoint(player->x1 + player->x2, player->y1 + player->y2);
- ActorDirection direction = (cmd->param2 == 8) ? player->getDirection() : cmd->param2;
+ ActorDirection direction = (cmd->param2 == 8) ? player->getDirection() : (ActorDirection)cmd->param2;
+
+ ActorDirection newDirection = (ActorDirection)((player->getDirection() + 4) % 8);
if (cmd->param2 == 8)
cmd->param2 = player->getDirection();
@@ -812,18 +814,16 @@ IMPLEMENT_OPCODE(_unk2C_ActorSub) {
if (cmd->param1 == 2) {
Common::Point point(playerPoint);
- int32 index = (player->getDirection() + 4) % 8;
-
- if (player->process_408B20(&point, index, 3, false)) {
+ if (player->process_408B20(&point, newDirection, 3, false)) {
- point.x += 3 * deltaPointsArray[index].x;
- point.x += 3 * deltaPointsArray[index].y;
+ point.x += 3 * deltaPointsArray[newDirection].x;
+ point.x += 3 * deltaPointsArray[newDirection].y;
player->setPosition(point.x, point.y, actor->getDirection(), 0);
}
}
- } else if (cmd->param1 != 2 || player->process_408B20(&playerPoint, (player->getDirection() + 4) % 8, 3, false)) {
+ } else if (cmd->param1 != 2 || player->process_408B20(&playerPoint, newDirection, 3, false)) {
ResourceId id = kResourceNone;
if (direction >= 5)
id = actor->getResourcesId(5 * cmd->param1 - direction + 38);
@@ -1556,7 +1556,7 @@ IMPLEMENT_OPCODE(_unk56) {
if ((actor->x1 + actor->x2 == cmd->param6) && (actor->y1 + actor->y2 == cmd->param7)) {
getScene()->getActor()->faceTarget((ObjectId)cmd->param1, kDirectionFromActor);
- actor->updateFromDirection((actor->getDirection() + 4) & 7);
+ actor->updateFromDirection((ActorDirection)((actor->getDirection() + 4) & 7));
} else {
_currentLine = cmd->param3;
}
diff --git a/engines/asylum/resources/actor.cpp b/engines/asylum/resources/actor.cpp
index d4c0fde7c2..c377e01941 100644
--- a/engines/asylum/resources/actor.cpp
+++ b/engines/asylum/resources/actor.cpp
@@ -54,7 +54,7 @@ Actor::Actor(AsylumEngine *engine, ActorIndex index) : _vm(engine), _index(index
_frameCount = 0;
x = y = 0;
x1 = y1 = x2 = y2 = 0;
- _direction = 0;
+ _direction = kDirection0;
_field_3C = 0;
_status = kActorStatusNone;
_field_44 = 0;
@@ -149,7 +149,7 @@ void Actor::load(Common::SeekableReadStream *stream) {
_boundingRect.right = stream->readSint32LE() & 0xFFFF;
_boundingRect.bottom = stream->readSint32LE() & 0xFFFF;
- _direction = stream->readSint32LE();
+ _direction = (ActorDirection)stream->readSint32LE();
_field_3C = stream->readSint32LE();
_status = (ActorStatus)stream->readSint32LE();
_field_44 = stream->readSint32LE();
@@ -314,13 +314,13 @@ void Actor::update() {
player->updateStatus(kActorStatus3);
player->setResourceId(player->getResourcesId(35));
- player->setDirection(4);
+ player->setDirection(kDirection4);
GraphicResource *resource = new GraphicResource(_vm, player->getResourceId());
player->setFrameCount(resource->getFrameCount());
delete resource;
getCursor()->hide();
- getScene()->getActor(0)->updateFromDirection(4);
+ getScene()->getActor(0)->updateFromDirection(kDirection4);
// Queue script
getScene()->actions()->queueScript(getWorld()->getActionAreaById(2696)->scriptIndex, getScene()->getPlayerActorIndex());
@@ -582,7 +582,7 @@ void Actor::updateStatus(ActorStatus actorStatus) {
Actor *actor = getScene()->getActor(0);
actor->x1 = x2 + x1 - actor->x2;
actor->y1 = y2 + y1 - actor->y2;
- actor->setDirection(4);
+ actor->setDirection(kDirection4);
getScene()->setPlayerActorIndex(0);
@@ -762,7 +762,7 @@ void Actor::faceTarget(ObjectId id, DirectionFrom from) {
updateFromDirection(getDirection(x2 + x1, y2 + y1, newX, newY));
}
-void Actor::setPosition(int32 newX, int32 newY, int32 newDirection, int32 frame) {
+void Actor::setPosition(int32 newX, int32 newY, ActorDirection newDirection, int32 frame) {
x1 = newX - x2;
y1 = newY - y2;
@@ -978,22 +978,22 @@ void Actor::updateStatusEnabled() {
break;
case 0:
- setPosition(10, 1350, 0, 0);
+ setPosition(10, 1350, kDirection0, 0);
processStatus(1460, -100, false);
break;
case 1:
- setPosition(300, 0, 0, 0);
+ setPosition(300, 0, kDirection0, 0);
processStatus(1700, 1400, false);
break;
case 2:
- setPosition(1560, -100, 0, 0);
+ setPosition(1560, -100, kDirection0, 0);
processStatus(-300, 1470, false);
break;
case 3:
- setPosition(1150, 1400, 0, 0);
+ setPosition(1150, 1400, kDirection0, 0);
processStatus(-250, 0, false);
break;
}
@@ -1172,7 +1172,7 @@ ActorDirection Actor::getDirection(int32 ax1, int32 ay1, int32 ax2, int32 ay2) {
if (v8 >= 360)
v8 -= 360;
- int32 result;
+ ActorDirection result;
if (v8 < 157 || v8 >= 202) {
if (v8 < 112 || v8 >= 157) {
@@ -1184,28 +1184,28 @@ ActorDirection Actor::getDirection(int32 ax1, int32 ay1, int32 ax2, int32 ay2) {
if (v8 < 202 || v8 >= 247) {
error("getAngle returned a bad angle: %d.", v8);
} else {
- result = 3;
+ result = kDirection3;
}
} else {
- result = 4;
+ result = kDirection4;
}
} else {
- result = 5;
+ result = kDirection5;
}
} else {
- result = 6;
+ result = kDirection6;
}
} else {
- result = 7;
+ result = kDirection7;
}
} else {
- result = 0;
+ result = kDirection0;
}
} else {
- result = 1;
+ result = kDirection1;
}
} else {
- result = 2;
+ result = kDirection2;
}
return result;
diff --git a/engines/asylum/resources/actor.h b/engines/asylum/resources/actor.h
index 92d490dfdb..f21a5b5529 100644
--- a/engines/asylum/resources/actor.h
+++ b/engines/asylum/resources/actor.h
@@ -181,7 +181,7 @@ public:
* @param newDirection The new direction.
* @param frame The frame.
*/
- void setPosition(int32 newX, int32 newY, int32 newDirection, int32 frame);
+ void setPosition(int32 newX, int32 newY, ActorDirection newDirection, int32 frame);
/////////////////////////////////////////////////////////////////////////
// Misc
diff --git a/engines/asylum/resources/object.cpp b/engines/asylum/resources/object.cpp
index d653187d02..692b787d39 100644
--- a/engines/asylum/resources/object.cpp
+++ b/engines/asylum/resources/object.cpp
@@ -111,7 +111,7 @@ void Object::load(Common::SeekableReadStream *stream) {
_randomResourceIds[i] = (ResourceId)stream->readSint32LE();
_soundResourceId = (ResourceId)stream->readSint32LE();
- _field_6A4 = stream->readSint32LE();
+ _field_6A4 = (ActorDirection)stream->readSint32LE();
}
diff --git a/engines/asylum/resources/object.h b/engines/asylum/resources/object.h
index 27f87e724e..8ca9465a42 100644
--- a/engines/asylum/resources/object.h
+++ b/engines/asylum/resources/object.h
@@ -56,7 +56,7 @@ public:
void setSoundResourceId(ResourceId id) { _soundResourceId = id; }
void setField67C(int32 val) { _field_67C = val; }
- void setField6A4(int32 val) { _field_6A4 = val; }
+ void setField6A4(ActorDirection val) { _field_6A4 = val; }
Common::Rect *getBoundingRect() { return &_boundingRect; }
uint32 getFrameIndex() { return _frameIndex; }
@@ -72,7 +72,7 @@ public:
int32 getSoundY() { return _soundY; }
int32 getField67C() { return _field_67C; }
int32 getField688() { return _field_688; }
- int32 getField6A4() { return _field_6A4; }
+ ActorDirection getField6A4() { return _field_6A4; }
/////////////////////////////////////////////////////////////////////////
// Loading & disabling
@@ -191,7 +191,7 @@ private:
int32 _field_688;
ResourceId _randomResourceIds[5];
ResourceId _soundResourceId;
- int32 _field_6A4;
+ ActorDirection _field_6A4;
/**
* Query if this object is visible.
diff --git a/engines/asylum/resources/special.cpp b/engines/asylum/resources/special.cpp
index 4c485d0522..8921090b68 100644
--- a/engines/asylum/resources/special.cpp
+++ b/engines/asylum/resources/special.cpp
@@ -219,7 +219,7 @@ void Special::chapter2(Object *object, ActorIndex actorIndex) {
if (_chapter2Counter >= 5) {
_chapter2Counter = 0;
- actor->updateFromDirection((actor->getDirection() + 1) % ~7); // TODO check
+ actor->updateFromDirection((ActorDirection)((actor->getDirection() + 1) % ~7)); // TODO check
}
} else if (actor->getStatus() == kActorStatusEnabled) {
actor->updateStatus(kActorStatus1);
@@ -537,7 +537,7 @@ void Special::chapter8(Object *object, ActorIndex actorIndex) {
if (object->getFrameIndex() == 50) {
object->disableAndRemoveFromQueue();
- actor0->setDirection(4);
+ actor0->setDirection(kDirection4);
getCursor()->show();
getWorld()->motionStatus = 1;
@@ -1315,7 +1315,7 @@ void Special::playSoundPanning(ResourceId resourceId, int32 attenuation, Object
// Adjust object properties
object->setSoundResourceId(resourceId);
- object->setField6A4(attenuation);
+ object->setField6A4((ActorDirection)attenuation);
getSound()->playSound(resourceId, false, adjustedVolume, panning);
}
diff --git a/engines/asylum/shared.h b/engines/asylum/shared.h
index d54fa13e55..58c6ae209f 100644
--- a/engines/asylum/shared.h
+++ b/engines/asylum/shared.h
@@ -226,7 +226,17 @@ enum ActorStatus {
kActorStatus21
};
-typedef int ActorDirection;
+enum ActorDirection {
+ kDirectionInvalid = -1,
+ kDirection0 = 0,
+ kDirection1 = 1,
+ kDirection2 = 2,
+ kDirection3 = 3,
+ kDirection4 = 4,
+ kDirection5 = 5,
+ kDirection6 = 6,
+ kDirection7 = 7,
+};
enum ActorFlags {
kActorFlagVisible = 1,
diff --git a/engines/asylum/views/scene.cpp b/engines/asylum/views/scene.cpp
index a8063feafb..0ee4f785e0 100644
--- a/engines/asylum/views/scene.cpp
+++ b/engines/asylum/views/scene.cpp
@@ -69,7 +69,7 @@ Scene::Scene(AsylumEngine *engine): _vm(engine),
_rightButton = false;
_isActive = false;
_skipDrawScene = false;
- _globalDirection = 0;
+ _globalDirection = kDirection0;
// Graphics
_bgResource = NULL;
@@ -155,7 +155,7 @@ void Scene::enter(ResourcePackId packId) {
Actor *actor = _ws->actors[i];
actor->hide();
- actor->setDirection(1);
+ actor->setDirection(kDirection1);
actor->updateStatus(kActorStatusEnabled);
actor->x1 -= actor->x2;
@@ -453,7 +453,7 @@ void Scene::updateMouse() {
actorPos.bottom = pt.y + getActor(10)->y2 - 20;
}
- int dir = -1;
+ ActorDirection dir = kDirectionInvalid;
bool done = false;
if (getCursor()->position().x < actorPos.left) {
@@ -461,39 +461,39 @@ void Scene::updateMouse() {
if (getCursor()->position().y > actorPos.bottom) {
if (act->getDirection() == 2) {
if (getCursor()->position().y - actorPos.bottom > 10)
- dir = 3;
+ dir = kDirection3;
} else {
- if (act->getDirection() == 4) {
+ if (act->getDirection() == kDirection4) {
if (actorPos.left - getCursor()->position().x > 10)
- dir = 3;
+ dir = kDirection3;
} else {
- dir = 3;
+ dir = kDirection3;
}
}
} else {
if (act->getDirection() == 1) {
if (getCursor()->position().y - actorPos.top > 10)
- dir = 2;
+ dir = kDirection2;
} else {
- if (act->getDirection() == 3) {
+ if (act->getDirection() == kDirection3) {
if (actorPos.bottom - getCursor()->position().y > 10)
- dir = 2;
+ dir = kDirection2;
} else {
- dir = 2;
+ dir = kDirection2;
}
}
}
} else {
if (act->getDirection()) {
- if (act->getDirection() == 2) {
+ if (act->getDirection() == kDirection2) {
if (actorPos.top - getCursor()->position().y > 10)
- dir = 1;
+ dir = kDirection1;
} else {
- dir = 1;
+ dir = kDirection1;
}
} else {
if (actorPos.left - getCursor()->position().x > 10)
- dir = 1;
+ dir = kDirection1;
}
}
done = true;
@@ -502,28 +502,28 @@ void Scene::updateMouse() {
if (!done && getCursor()->position().x <= actorPos.right) {
if (getCursor()->position().y >= actorPos.top) {
if (getCursor()->position().y > actorPos.bottom) {
- if (act->getDirection() == 3) {
+ if (act->getDirection() == kDirection3) {
if (getCursor()->position().x - actorPos.left > 10)
- dir = 4;
+ dir = kDirection4;
} else {
- if (act->getDirection() == 5) {
+ if (act->getDirection() == kDirection5) {
if (actorPos.right - getCursor()->position().x > 10)
- dir = 4;
+ dir = kDirection4;
} else {
- dir = 4;
+ dir = kDirection4;
}
}
}
} else {
- if (act->getDirection() == 1) {
+ if (act->getDirection() == kDirection1) {
if (getCursor()->position().x - actorPos.left > 10)
- dir = 0;
+ dir = kDirection0;
} else {
- if (act->getDirection() == 7) {
+ if (act->getDirection() == kDirection7) {
if (actorPos.right - getCursor()->position().x > 10)
- dir = 0;
+ dir = kDirection0;
} else {
- dir = 0;
+ dir = kDirection0;
}
}
}
@@ -532,43 +532,43 @@ void Scene::updateMouse() {
if (!done && getCursor()->position().y < actorPos.top) {
if (act->getDirection()) {
- if (act->getDirection() == 6) {
+ if (act->getDirection() == kDirection6) {
if (actorPos.top - getCursor()->position().y > 10)
- dir = 7;
+ dir = kDirection7;
} else {
- dir = 7;
+ dir = kDirection7;
}
} else {
if (getCursor()->position().x - actorPos.right > 10)
- dir = 7;
+ dir = kDirection7;
}
done = true;
}
if (!done && getCursor()->position().y <= actorPos.bottom) {
- if (act->getDirection() == 5) {
+ if (act->getDirection() == kDirection5) {
if (actorPos.bottom - getCursor()->position().y > 10)
- dir = 6;
+ dir = kDirection6;
} else {
- if (act->getDirection() == 7) {
+ if (act->getDirection() == kDirection7) {
if (getCursor()->position().y - actorPos.top > 10)
- dir = 6;
+ dir = kDirection6;
} else {
- dir = 6;
+ dir = kDirection6;
}
}
done = true;
}
- if (!done && act->getDirection() == 4) {
+ if (!done && act->getDirection() == kDirection4) {
if (getCursor()->position().x - actorPos.right <= 10)
done = true;
if (!done)
- dir = 5;
+ dir = kDirection5;
}
- if (!done && (act->getDirection() != 6 || getCursor()->position().y - actorPos.bottom > 10))
- dir = 5;
+ if (!done && (act->getDirection() != kDirection6 || getCursor()->position().y - actorPos.bottom > 10))
+ dir = kDirection5;
handleMouseUpdate(dir, actorPos);
Commit: 7c64f717ecc8f32f06129e7e470bbc559c749343
https://github.com/scummvm/scummvm/commit/7c64f717ecc8f32f06129e7e470bbc559c749343
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:18+02:00
Commit Message:
ASYLUM: Add GraphicFrame helper functions
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@542 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/resources/actionlist.cpp
engines/asylum/resources/actor.cpp
engines/asylum/resources/object.cpp
engines/asylum/resources/special.cpp
engines/asylum/system/cursor.cpp
engines/asylum/system/graphics.cpp
engines/asylum/system/graphics.h
engines/asylum/views/menu.cpp
engines/asylum/views/scene.cpp
engines/asylum/views/scenetitle.cpp
diff --git a/engines/asylum/resources/actionlist.cpp b/engines/asylum/resources/actionlist.cpp
index ebadd1efbd..7ae09906b9 100644
--- a/engines/asylum/resources/actionlist.cpp
+++ b/engines/asylum/resources/actionlist.cpp
@@ -386,13 +386,10 @@ IMPLEMENT_OPCODE(PlayAnimation) {
getScene()->setGlobalX(object->x);
getScene()->setGlobalY(object->y);
} else {
- GraphicResource *res = new GraphicResource(_vm, object->getResourceId());
- GraphicFrame *frame = res->getFrame(object->getFrameIndex());
+ Common::Rect frameRect = GraphicResource::getFrameRect(_vm, object->getResourceId(), object->getFrameIndex());
- getScene()->setGlobalX(frame->x + (frame->getWidth() >> 1) + object->x);
- getScene()->setGlobalY(frame->y + (frame->getHeight() >> 1) + object->y);
-
- delete res;
+ getScene()->setGlobalX(frameRect.left + (frameRect.width() >> 1) + object->x);
+ getScene()->setGlobalY(frameRect.top + (frameRect.height() >> 1) + object->y);
}
}
@@ -830,13 +827,11 @@ IMPLEMENT_OPCODE(_unk2C_ActorSub) {
else
id = actor->getResourcesId(5 * cmd->param1 + direction + 30);
- GraphicResource *res = new GraphicResource(_vm, id);
actor->setResourceId(id);
- actor->setFrameCount(res->getFrameCount());
+ actor->setFrameCount(GraphicResource::getFrameCount(_vm, id));
actor->setFrameIndex(0);
actor->setDirection(direction);
actor->updateStatus(actor->getStatus() <= kActorStatus11 ? kActorStatus3 : kActorStatus19);
- delete res;
cmd->param3 = 2;
_lineIncrement = 1;
diff --git a/engines/asylum/resources/actor.cpp b/engines/asylum/resources/actor.cpp
index c377e01941..020b82ab10 100644
--- a/engines/asylum/resources/actor.cpp
+++ b/engines/asylum/resources/actor.cpp
@@ -245,10 +245,8 @@ void Actor::draw() {
// Draw the actor
Common::Point point;
- GraphicResource *gra = new GraphicResource(_vm, _resourceId);
- GraphicFrame *fra = gra->getFrame(_frameIndex);
- getScene()->adjustCoordinates(fra->x + x + x1, fra->y + y + y1, &point);
- delete gra;
+ Common::Rect frameRect = GraphicResource::getFrameRect(_vm, _resourceId, _frameIndex);
+ getScene()->adjustCoordinates(frameRect.left + x + x1, frameRect.top + y + y1, &point);
// Compute frame index
int32 frameIndex = _frameIndex;
@@ -315,9 +313,7 @@ void Actor::update() {
player->updateStatus(kActorStatus3);
player->setResourceId(player->getResourcesId(35));
player->setDirection(kDirection4);
- GraphicResource *resource = new GraphicResource(_vm, player->getResourceId());
- player->setFrameCount(resource->getFrameCount());
- delete resource;
+ player->setFrameCount(GraphicResource::getFrameCount(_vm, player->getResourceId()));
getCursor()->hide();
getScene()->getActor(0)->updateFromDirection(kDirection4);
@@ -627,7 +623,7 @@ void Actor::updateStatus(ActorStatus actorStatus) {
if (getScene()->getPlayerActorIndex() == _index) {
resource->load(_resourceId);
- _frameIndex = resource->getFrameCount() - 1;
+ _frameIndex = resource->count() - 1;
}
if (_index == 11)
@@ -637,7 +633,7 @@ void Actor::updateStatus(ActorStatus actorStatus) {
if (resource->getResourceId() != _resourceId)
resource->load(_resourceId);
- _frameCount = resource->getFrameCount();
+ _frameCount = resource->count();
delete resource;
}
@@ -673,14 +669,9 @@ void Actor::updateFromDirection(ActorDirection actorDirection) {
case kActorStatusDisabled:
case kActorStatusEnabled:
- case kActorStatus14: {
+ case kActorStatus14:
_resourceId = _graphicResourceIds[(actorDirection > 4 ? 8 - actorDirection : actorDirection) + 5];
-
- // FIXME this seems kind of wasteful just to grab a frame count
- GraphicResource *gra = new GraphicResource(_vm, _resourceId);
- _frameCount = gra->getFrameCount();
- delete gra;
- }
+ _frameCount = GraphicResource::getFrameCount(_vm, _resourceId);
break;
case kActorStatus18:
@@ -723,15 +714,10 @@ void Actor::faceTarget(ObjectId id, DirectionFrom from) {
return;
}
+ Common::Rect frameRect = GraphicResource::getFrameRect(_vm, object->getResourceId(), object->getFrameIndex());
-
- GraphicResource *resource = new GraphicResource(_vm, object->getResourceId());
- GraphicFrame *frame = resource->getFrame(object->getFrameIndex());
-
- newX = (frame->surface.w >> 1) + object->x;
- newY = (frame->surface.h >> 1) + object->y;
-
- delete resource;
+ newX = (frameRect.width() >> 1) + object->x;
+ newY = (frameRect.height() >> 1) + object->y;
}
break;
@@ -1213,11 +1199,7 @@ ActorDirection Actor::getDirection(int32 ax1, int32 ay1, int32 ax2, int32 ay2) {
void Actor::updateGraphicData(uint32 offset) {
_resourceId = _graphicResourceIds[(_direction > 4 ? 8 - _direction : _direction) + offset];
-
- GraphicResource *resource = new GraphicResource(_vm, _resourceId);
- _frameCount = resource->getFrameCount();
- delete resource;
-
+ _frameCount = GraphicResource::getFrameCount(_vm, _resourceId);
_frameIndex = 0;
}
diff --git a/engines/asylum/resources/object.cpp b/engines/asylum/resources/object.cpp
index 692b787d39..86777576e9 100644
--- a/engines/asylum/resources/object.cpp
+++ b/engines/asylum/resources/object.cpp
@@ -178,10 +178,8 @@ void Object::draw() {
// Draw the object
Common::Point point;
- GraphicResource *gra = new GraphicResource(_vm, _resourceId);
- GraphicFrame *fra = gra->getFrame(_frameIndex);
- getScene()->adjustCoordinates(x + fra->x, y + fra->y, &point);
- delete gra;
+ Common::Rect frameRect = GraphicResource::getFrameRect(_vm, _resourceId, _frameIndex);
+ getScene()->adjustCoordinates(x + frameRect.left, y + frameRect.top, &point);
if (_field_67C <= 0 || _field_67C >= 4 || Config.performance <= 1) {
getScreen()->addGraphicToQueue(_resourceId, _frameIndex, point.x, point.y, (flags >> 11) & kObjectFlag2, _field_67C - 3, _priority);
@@ -219,9 +217,7 @@ void Object::update() {
if (_vm->getRandom(_field_C0) == 1) {
if (_randomResourceIds[0]) {
_resourceId = getRandomResourceId();
- GraphicResource *gra = new GraphicResource(_vm, _resourceId);
- _frameCount = gra->getFrameCount();
- delete gra;
+ _frameCount = GraphicResource::getFrameCount(_vm, _resourceId);
}
_frameIndex++;
}
@@ -255,11 +251,9 @@ void Object::update() {
if (_frameIndex < _frameCount - 1) {
if (_field_688 == 1) {
- GraphicResource *gra = new GraphicResource(_vm, _resourceId);
- GraphicFrame *frame = gra->getFrame(_frameIndex);
- getScene()->setGlobalX(x + frame->x + (frame->getWidth() >> 1));
- getScene()->setGlobalY(y + frame->y + (frame->getHeight() >> 1));
- delete gra;
+ Common::Rect frameRect = GraphicResource::getFrameRect(_vm, _resourceId, _frameIndex);
+ getScene()->setGlobalX(x + frameRect.left + (frameRect.width() >> 1));
+ getScene()->setGlobalY(y + frameRect.top + (frameRect.height() >> 1));
}
} else {
flags &= ~kObjectFlag8;
@@ -284,11 +278,9 @@ void Object::update() {
getScene()->setGlobalY(-1);
}
} else if (_field_688 == 1) {
- GraphicResource *gra = new GraphicResource(_vm, _resourceId);
- GraphicFrame *frame = gra->getFrame(_frameIndex);
- getScene()->setGlobalX(x + frame->x + (frame->getWidth() >> 1));
- getScene()->setGlobalY(y + frame->y + (frame->getHeight() >> 1));
- delete gra;
+ Common::Rect frameRect = GraphicResource::getFrameRect(_vm, _resourceId, _frameIndex);
+ getScene()->setGlobalX(x + frameRect.left + (frameRect.width() >> 1));
+ getScene()->setGlobalY(y + frameRect.top + (frameRect.height() >> 1));
}
_tickCount = _vm->getTick();
@@ -435,16 +427,13 @@ void Object::setVolume() {
if (!_soundResourceId || !getSound()->isPlaying(_soundResourceId))
return;
- GraphicResource *resource = new GraphicResource(_vm, _resourceId);
- GraphicFrame *frame = resource->getFrame(_frameIndex);
+ Common::Rect frameRect = GraphicResource::getFrameRect(_vm, _resourceId, _frameIndex);
// Compute volume
- int32 volume = Config.voiceVolume + getSound()->calculateVolumeAdjustement((frame->getWidth() >> 1) + x, (frame->getHeight() >> 1) + y, _field_6A4, 0);
+ int32 volume = Config.voiceVolume + getSound()->calculateVolumeAdjustement((frameRect.width() >> 1) + x, (frameRect.height() >> 1) + y, _field_6A4, 0);
if (volume < -10000)
volume = -10000;
- delete resource;
-
getSound()->setVolume(_soundResourceId, volume);
}
diff --git a/engines/asylum/resources/special.cpp b/engines/asylum/resources/special.cpp
index 8921090b68..cdce48cb23 100644
--- a/engines/asylum/resources/special.cpp
+++ b/engines/asylum/resources/special.cpp
@@ -1276,13 +1276,10 @@ void Special::playSoundPanning(ResourceId resourceId, int32 attenuation, Object
switch (object->getId()) {
default: {
- GraphicResource *resource = new GraphicResource(_vm, object->getResourceId());
- GraphicFrame *frame = resource->getFrame(object->getFrameIndex());
+ Common::Rect frameRect = GraphicResource::getFrameRect(_vm, object->getResourceId(), object->getFrameIndex());
- x = (frame->getWidth() >> 1) + object->x;
- y = (frame->getHeight() >> 1) + object->y;
-
- delete resource;
+ x = (frameRect.width() >> 1) + object->x;
+ y = (frameRect.height() >> 1) + object->y;
}
break;
diff --git a/engines/asylum/system/cursor.cpp b/engines/asylum/system/cursor.cpp
index cb6abef7bc..a0406ee4ce 100644
--- a/engines/asylum/system/cursor.cpp
+++ b/engines/asylum/system/cursor.cpp
@@ -73,7 +73,7 @@ void Cursor::set(ResourceId resourceId, int32 cntr, int32 flgs, int32 frames) {
if (frames >= 0)
frameCount = frames;
else
- frameCount = _cursorRes->getFrameCount();
+ frameCount = _cursorRes->count();
this->flags = flgs;
this->counter = cntr;
currentFrame = 0;
diff --git a/engines/asylum/system/graphics.cpp b/engines/asylum/system/graphics.cpp
index ca04e41328..1a4a1278ae 100644
--- a/engines/asylum/system/graphics.cpp
+++ b/engines/asylum/system/graphics.cpp
@@ -139,4 +139,27 @@ void GraphicResource::init(byte *data, int32 size) {
}
}
+//////////////////////////////////////////////////////////////////////////
+// Helper functions
+//////////////////////////////////////////////////////////////////////////
+
+uint32 GraphicResource::getFrameCount(AsylumEngine *engine, ResourceId id) {
+ GraphicResource *resource = new GraphicResource(engine, id);
+ uint32 count = resource->count();
+ delete resource;
+
+ return count;
+}
+
+Common::Rect GraphicResource::getFrameRect(AsylumEngine *engine, ResourceId id, uint32 index) {
+ GraphicResource *resource = new GraphicResource(engine, id);
+ GraphicFrame *frame = resource->getFrame(index);
+
+ Common::Rect rect = frame->getRect();
+
+ delete resource;
+
+ return rect;
+}
+
} // end of namespace Asylum
diff --git a/engines/asylum/system/graphics.h b/engines/asylum/system/graphics.h
index cf39064fff..d50832b8da 100644
--- a/engines/asylum/system/graphics.h
+++ b/engines/asylum/system/graphics.h
@@ -46,6 +46,10 @@ struct GraphicFrame {
uint16 getWidth() { return surface.w; }
uint16 getHeight() { return surface.h; }
+
+ Common::Rect getRect() {
+ return Common::Rect(x, y, x + getWidth(), y + getHeight());
+ }
};
// Graphic resources can be sprites or images, with multiple frames
@@ -72,7 +76,11 @@ public:
ResourceId getResourceId() { return _resourceId; }
int32 getFlags() { return _flags; }
int32 getFlags2() { return _flags2; }
- uint32 getFrameCount() { return _frames.size(); }
+ uint32 count() { return _frames.size(); }
+
+ // Helper functions
+ static uint32 getFrameCount(AsylumEngine *engine, ResourceId id);
+ static Common::Rect getFrameRect(AsylumEngine *engine, ResourceId id, uint32 index);
private:
AsylumEngine *_vm;
diff --git a/engines/asylum/views/menu.cpp b/engines/asylum/views/menu.cpp
index 5a716471a1..fd64bdfd1f 100644
--- a/engines/asylum/views/menu.cpp
+++ b/engines/asylum/views/menu.cpp
@@ -309,12 +309,12 @@ void MainMenu::updateMainMenu() {
_iconResource = new GraphicResource(_vm, MAKE_RESOURCE(kResourcePackShared, iconNum + 4));
}
- GraphicFrame *iconFrame = _iconResource->getFrame(MIN<int>(_iconResource->getFrameCount() - 1, _curIconFrame));
+ GraphicFrame *iconFrame = _iconResource->getFrame(MIN<int>(_iconResource->count() - 1, _curIconFrame));
_vm->screen()->copyRectToScreenWithTransparency((byte *)iconFrame->surface.pixels, iconFrame->surface.w, iconFrame->x, iconFrame->y, iconFrame->surface.w, iconFrame->surface.h);
// Cycle icon frame
_curIconFrame++;
- if (_curIconFrame >= _iconResource->getFrameCount())
+ if (_curIconFrame >= _iconResource->count())
_curIconFrame = 0;
// Show text
@@ -335,12 +335,12 @@ void MainMenu::updateMainMenu() {
}
void MainMenu::updateSubMenu() {
- GraphicFrame *iconFrame = _iconResource->getFrame(MIN<int>(_iconResource->getFrameCount() - 1, _curIconFrame));
+ GraphicFrame *iconFrame = _iconResource->getFrame(MIN<int>(_iconResource->count() - 1, _curIconFrame));
_vm->screen()->copyRectToScreenWithTransparency((byte *)iconFrame->surface.pixels, iconFrame->surface.w, iconFrame->x, iconFrame->y, iconFrame->surface.w, iconFrame->surface.h);
// Cycle icon frame
_curIconFrame++;
- if (_curIconFrame >= _iconResource->getFrameCount())
+ if (_curIconFrame >= _iconResource->count())
_curIconFrame = 0;
switch (_activeIcon) {
@@ -577,11 +577,11 @@ void MainMenu::updateSubMenuShowCredits() {
GraphicFrame *creditsFadeFrame = _creditsFadeResource->getFrame(0);
_vm->screen()->copyRectToScreenWithTransparency((byte *)creditsFadeFrame->surface.pixels, creditsFadeFrame->surface.w, creditsFadeFrame->x, creditsFadeFrame->y, creditsFadeFrame->surface.w, creditsFadeFrame->surface.h);
- GraphicFrame *creditsFrame = _creditsResource->getFrame(MIN<int>(_creditsResource->getFrameCount() - 1, _creditsBgFrame));
+ GraphicFrame *creditsFrame = _creditsResource->getFrame(MIN<int>(_creditsResource->count() - 1, _creditsBgFrame));
_vm->screen()->copyRectToScreenWithTransparency((byte *)creditsFrame->surface.pixels, creditsFrame->surface.w, creditsFrame->x, creditsFrame->y, creditsFrame->surface.w, creditsFrame->surface.h);
_creditsBgFrame++;
- if (_creditsBgFrame >= _creditsResource->getFrameCount())
+ if (_creditsBgFrame >= _creditsResource->count())
_creditsBgFrame = 0;
do {
diff --git a/engines/asylum/views/scene.cpp b/engines/asylum/views/scene.cpp
index 0ee4f785e0..d0bc231753 100644
--- a/engines/asylum/views/scene.cpp
+++ b/engines/asylum/views/scene.cpp
@@ -792,21 +792,9 @@ bool Scene::hitTestActor(const Common::Point pt) {
}
bool Scene::hitTestPixel(ResourceId resourceId, int32 frame, int16 x, int16 y, bool flipped) {
- GraphicResource *gra = new GraphicResource(_vm, resourceId);
- GraphicFrame *fra = gra->getFrame(frame);
-
// TODO this gets a bit funky with the "flipped" calculations for x intersection
// The below is a pretty basic intersection test for proof of concept
-
- Common::Rect rect;
- rect.top = fra->x;
- rect.left = fra->y;
- rect.right = fra->x + fra->surface.w;
- rect.bottom = fra->y + fra->surface.h;
-
- delete gra;
-
- return rect.contains(x, y);
+ return GraphicResource::getFrameRect(_vm, resourceId, frame).contains(x, y);
}
void Scene::changePlayer(ActorIndex index) {
diff --git a/engines/asylum/views/scenetitle.cpp b/engines/asylum/views/scenetitle.cpp
index b19db3ba60..2ac2f20b0d 100644
--- a/engines/asylum/views/scenetitle.cpp
+++ b/engines/asylum/views/scenetitle.cpp
@@ -97,7 +97,7 @@ void SceneTitle::update(int32 tick) {
_spinnerFrame++;
- if (_spinnerFrame > _progress->getFrameCount() - 1)
+ if (_spinnerFrame > _progress->count() - 1)
_spinnerFrame = 0;
if (_spinnerProgress > 590) {
Commit: 5ff3345115db6e92361c34186b6750b5542cf984
https://github.com/scummvm/scummvm/commit/5ff3345115db6e92361c34186b6750b5542cf984
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:18+02:00
Commit Message:
ASYLUM: Fix Scene::hitTest() case for the main actor
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@543 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/views/scene.cpp
diff --git a/engines/asylum/views/scene.cpp b/engines/asylum/views/scene.cpp
index d0bc231753..9e8f4cf68c 100644
--- a/engines/asylum/views/scene.cpp
+++ b/engines/asylum/views/scene.cpp
@@ -716,9 +716,10 @@ int32 Scene::hitTest(const Common::Point pt, HitType &type) {
if (targetIdx == -1) {
targetIdx = hitTestActionArea(pt);
if (targetIdx == -1) {
- targetIdx = hitTestActor(pt);
- if (targetIdx != -1)
+ if (hitTestActor(pt)) {
+ targetIdx = _playerActorIdx;
type = kHitActor;
+ }
} else {
type = kHitActionArea;
}
Commit: c878f301f08b06bff91166aa1d188c216a26653f
https://github.com/scummvm/scummvm/commit/c878f301f08b06bff91166aa1d188c216a26653f
Author: Alex Bevilacqua (alexbevi at gmail.com)
Date: 2021-05-17T15:36:18+02:00
Commit Message:
ASYLUM: silence warning
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@544 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/shared.h
diff --git a/engines/asylum/shared.h b/engines/asylum/shared.h
index 58c6ae209f..f5cadfb0a0 100644
--- a/engines/asylum/shared.h
+++ b/engines/asylum/shared.h
@@ -235,7 +235,7 @@ enum ActorDirection {
kDirection4 = 4,
kDirection5 = 5,
kDirection6 = 6,
- kDirection7 = 7,
+ kDirection7 = 7
};
enum ActorFlags {
Commit: d38322ebca2f7a7dffda75ac408a97c174b1ec18
https://github.com/scummvm/scummvm/commit/d38322ebca2f7a7dffda75ac408a97c174b1ec18
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:18+02:00
Commit Message:
ASYLUM: Cleanup Pass 1
- Add proper init code in some classes
- Add some missing deletes in destructors
- Add const modifiers in several places
- Switch tick variables (and several others) to uint32
- Update Polygon struct slightly (with count() method instead of variable)
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@545 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/asylum.cpp
engines/asylum/asylum.h
engines/asylum/console.cpp
engines/asylum/detection.cpp
engines/asylum/resources/actionlist.cpp
engines/asylum/resources/actionlist.h
engines/asylum/resources/actor.cpp
engines/asylum/resources/actor.h
engines/asylum/resources/object.cpp
engines/asylum/resources/object.h
engines/asylum/resources/polygons.cpp
engines/asylum/resources/polygons.h
engines/asylum/resources/reaction.cpp
engines/asylum/resources/special.cpp
engines/asylum/resources/special.h
engines/asylum/resources/worldstats.h
engines/asylum/shared.h
engines/asylum/system/graphics.cpp
engines/asylum/system/graphics.h
engines/asylum/system/speech.cpp
engines/asylum/system/text.cpp
engines/asylum/views/blowuppuzzle.cpp
engines/asylum/views/menu.cpp
engines/asylum/views/menu.h
engines/asylum/views/scene.cpp
diff --git a/engines/asylum/asylum.cpp b/engines/asylum/asylum.cpp
index e103e16d66..71d7ed64de 100644
--- a/engines/asylum/asylum.cpp
+++ b/engines/asylum/asylum.cpp
@@ -51,12 +51,12 @@
namespace Asylum {
AsylumEngine::AsylumEngine(OSystem *system, const ADGameDescription *gd) : Engine(system), _gameDescription(gd),
- _console(NULL), _encounter(NULL), _resource(NULL), _mainMenu(NULL), _scene(NULL), _screen(NULL),
- _sound(NULL), _text(NULL), _video(NULL) {
+ _console(NULL), _cursor(NULL), _encounter(NULL), _mainMenu(NULL), _resource(NULL), _scene(NULL), _screen(NULL),
+ _sound(NULL), _text(NULL), _video(NULL), _introPlaying(false) {
// Init data
- memset(_gameFlags, 0, 1512);
- memset(_gameFlags, 0, sizeof(_gameFlags));
+ memset(&_gameFlags, 0, sizeof(_gameFlags));
+ memset(&_flags, 0, sizeof(_flags));
screenUpdatesCount = 0;
globalTickValue_2 = 0;
@@ -83,6 +83,7 @@ AsylumEngine::AsylumEngine(OSystem *system, const ADGameDescription *gd) : Engin
}
AsylumEngine::~AsylumEngine() {
+ delete _cursor;
delete _scene;
delete _encounter;
delete _screen;
@@ -143,7 +144,7 @@ Common::Error AsylumEngine::run() {
return Common::kNoError;
}
-void AsylumEngine::waitForTimer(int msec_delay) {
+void AsylumEngine::waitForTimer(uint32 msec_delay) {
uint32 start_time = _system->getMillis();
while (_system->getMillis() < start_time + msec_delay) {
@@ -156,6 +157,9 @@ void AsylumEngine::waitForTimer(int msec_delay) {
}
void AsylumEngine::startGame(ResourcePackId sceneId, StartGameType type) {
+ if (!_cursor || !_screen)
+ error("[AsylumEngine::startGame] Subsystems not initialized properly!");
+
// Load the default mouse cursor
_cursor->set(MAKE_RESOURCE(kResourcePackSound, 14));
_cursor->hide();
@@ -192,6 +196,9 @@ void AsylumEngine::startGame(ResourcePackId sceneId, StartGameType type) {
}
void AsylumEngine::playIntro() {
+ if (!_video || !_screen)
+ error("[AsylumEngine::playIntro] Subsystems not initialized properly!");
+
_introPlaying = true;
g_system->showMouse(false);
@@ -210,10 +217,9 @@ void AsylumEngine::playIntro() {
_sound->playSound(MAKE_RESOURCE(kResourcePackSound, 7));
}
-void AsylumEngine::handleEvents(bool doUpdate) { // k_sub_40AE30 (0040AE30)
- // Make sure the debugger is present
- if (!_console)
- error("AsylumEngine::handleEvents: called before the required subsystems have been initialized!");
+void AsylumEngine::handleEvents(bool doUpdate) {
+ if (!_console || !_video || !_screen || !_sound || !_mainMenu)
+ error("[AsylumEngine::handleEvents] Subsystems not initialized properly!");
// Show the debugger if required
_console->onFrame();
@@ -307,6 +313,9 @@ void AsylumEngine::handleEvents(bool doUpdate) { // k_sub_40AE30 (0040AE30)
}
void AsylumEngine::processDelayedEvents() {
+ if (!_video || !_sound || !_scene || !_mainMenu)
+ error("[AsylumEngine::processDelayedEvents] Subsystems not initialized properly!");
+
// check for a delayed video
int videoIdx = _scene->actions()->getDelayedVideoIndex();
if (videoIdx >= 0) {
@@ -355,30 +364,29 @@ AsylumEngine::MessageHandler *AsylumEngine::getMessageHandler(uint32 index) {
//////////////////////////////////////////////////////////////////////////
// Game flags
//////////////////////////////////////////////////////////////////////////
+#define FLAG_MASK 0xFFFFFFE0
+
void AsylumEngine::setGameFlag(GameFlag flag) {
- _gameFlags[flag / 32] |= 1 << flag % -32;
+ _gameFlags[flag / 32] |= 1 << (flag % FLAG_MASK);
}
void AsylumEngine::clearGameFlag(GameFlag flag) {
- _gameFlags[flag / 32] &= ~(1 << flag % -32);
+ _gameFlags[flag / 32] &= ~(1 << (uint32)(flag % FLAG_MASK));
}
void AsylumEngine::toggleGameFlag(GameFlag flag) {
- _gameFlags[flag / 32] ^= 1 << flag % -32;
+ _gameFlags[flag / 32] ^= 1 << (uint32)(flag % FLAG_MASK);
}
-bool AsylumEngine::isGameFlagSet(GameFlag flag) {
- return ((1 << flag % -32) & (unsigned int)_gameFlags[flag / 32]) >> flag % -32 != 0;
+bool AsylumEngine::isGameFlagSet(GameFlag flag) const {
+ return ((1 << (flag % FLAG_MASK)) & (unsigned int)_gameFlags[flag / 32]) >> (flag % FLAG_MASK) != 0;
}
-bool AsylumEngine::isGameFlagNotSet(GameFlag flag) {
- return ((1 << flag % -32) & (unsigned int)_gameFlags[flag / 32]) >> flag % -32 == 0;
+bool AsylumEngine::isGameFlagNotSet(GameFlag flag) const {
+ return ((1 << (flag % FLAG_MASK)) & (unsigned int)_gameFlags[flag / 32]) >> (flag % FLAG_MASK) == 0;
}
void AsylumEngine::setFlag(FlagType flag, bool isSet) {
- if (flag > ARRAYSIZE(_flags))
- error("[AsylumEngine::setFlag] Invalid flag type (was: %d, max: %d", flag, ARRAYSIZE(_flags));
-
_flags[flag] = isSet;
}
diff --git a/engines/asylum/asylum.h b/engines/asylum/asylum.h
index d505b4c21b..8af2b5fc81 100644
--- a/engines/asylum/asylum.h
+++ b/engines/asylum/asylum.h
@@ -115,7 +115,7 @@ public:
/**
* Wrapper function to the OSystem getMillis() method
*/
- int32 getTick() { return (int32)_system->getMillis(); }
+ uint32 getTick() { return _system->getMillis(); }
/**
* This is the global tick counter.
@@ -138,8 +138,8 @@ public:
void setGameFlag(GameFlag flag);
void clearGameFlag(GameFlag flag);
void toggleGameFlag(GameFlag flag);
- bool isGameFlagSet(GameFlag flag);
- bool isGameFlagNotSet(GameFlag flag);
+ bool isGameFlagSet(GameFlag flag) const;
+ bool isGameFlagNotSet(GameFlag flag) const;
// Misc
uint getRandom(uint max) { return _rnd.getRandomNumber(max); }
@@ -176,7 +176,7 @@ private:
bool _flags[4];
void handleEvents(bool doUpdate);
- void waitForTimer(int msec_delay);
+ void waitForTimer(uint32 msec_delay);
void updateMouseCursor();
void processDelayedEvents();
diff --git a/engines/asylum/console.cpp b/engines/asylum/console.cpp
index 0120b06613..4e56376a51 100644
--- a/engines/asylum/console.cpp
+++ b/engines/asylum/console.cpp
@@ -197,7 +197,7 @@ bool Console::cmdListFlags(int32 argc, const char **argv) {
}
DebugPrintf("\n");
} else {
- bool type = atoi(argv[1]);
+ int32 type = atoi(argv[1]);
if (type != 0 && type != 1) {
DebugPrintf("Syntax: %s <type> (nothing: all - 1: show set flags - 0: show unset flags)\n", argv[0]);
@@ -207,7 +207,7 @@ bool Console::cmdListFlags(int32 argc, const char **argv) {
// Show only set/unset flags
int count = 0;
for (int32 i = 0; i < 1512; i++) {
- if (_vm->isGameFlagSet((GameFlag)i) == type) {
+ if (_vm->isGameFlagSet((GameFlag)i) == (bool)type) {
DebugPrintf("%04d: %d ", i, _vm->isGameFlagSet((GameFlag)i));
++count;
}
@@ -221,7 +221,7 @@ bool Console::cmdListFlags(int32 argc, const char **argv) {
return true;
}
-bool Console::cmdShowWorldStats(int32 argc, const char **argv) {
+bool Console::cmdShowWorldStats(int32, const char **) {
DebugPrintf("WorldStats\n");
DebugPrintf("----------\n");
DebugPrintf("%s", getWorld()->toString().c_str());
diff --git a/engines/asylum/detection.cpp b/engines/asylum/detection.cpp
index b08b778f14..7c0e5e645b 100644
--- a/engines/asylum/detection.cpp
+++ b/engines/asylum/detection.cpp
@@ -149,18 +149,16 @@ public:
};
bool AsylumMetaEngine::hasFeature(MetaEngineFeature f) const {
- return
- (f == kSupportsListSaves) ||
- (f == kSupportsLoadingDuringStartup) ||
- (f == kSupportsDeleteSave);
+ return (f == kSupportsListSaves) ||
+ (f == kSupportsLoadingDuringStartup) ||
+ (f == kSupportsDeleteSave);
}
bool Asylum::AsylumEngine::hasFeature(EngineFeature f) const {
- return
- (f == kSupportsRTL) ||
- (f == kSupportsLoadingDuringRuntime) ||
- (f == kSupportsSavingDuringRuntime) ||
- (f == kSupportsSubtitleOptions);
+ return (f == kSupportsRTL) ||
+ (f == kSupportsLoadingDuringRuntime) ||
+ (f == kSupportsSavingDuringRuntime) ||
+ (f == kSupportsSubtitleOptions);
}
void Asylum::AsylumEngine::errorString(const char *buf_input, char *buf_output, int buf_output_size) {
diff --git a/engines/asylum/resources/actionlist.cpp b/engines/asylum/resources/actionlist.cpp
index 7ae09906b9..c7cc2c56b8 100644
--- a/engines/asylum/resources/actionlist.cpp
+++ b/engines/asylum/resources/actionlist.cpp
@@ -159,6 +159,8 @@ ActionList::~ActionList() {
_scripts.clear();
_queue.clear();
+ _currentScript = NULL;
+
// Zero-out passed pointers
_vm = NULL;
}
@@ -292,41 +294,41 @@ bool ActionList::process() {
//////////////////////////////////////////////////////////////////////////
// Opcode 0x00
-IMPLEMENT_OPCODE(Return) {
+IMPLEMENT_OPCODE(Return)
_done = true;
_lineIncrement = 0;
-}
+END_OPCODE
//////////////////////////////////////////////////////////////////////////
// Opcode 0x01
-IMPLEMENT_OPCODE(SetGameFlag) {
- GameFlag flagNum = (GameFlag)cmd->param1;
+IMPLEMENT_OPCODE(SetGameFlag)
+ int32 flagNum = cmd->param1;
if (flagNum >= 0)
- _vm->setGameFlag(flagNum);
-}
+ _vm->setGameFlag((GameFlag)flagNum);
+END_OPCODE
//////////////////////////////////////////////////////////////////////////
// Opcode 0x02
-IMPLEMENT_OPCODE(ClearGameFlag) {
- GameFlag flagNum = (GameFlag)cmd->param1;
+IMPLEMENT_OPCODE(ClearGameFlag)
+ int32 flagNum = cmd->param1;
if (flagNum >= 0)
- _vm->clearGameFlag(flagNum);
-}
+ _vm->clearGameFlag((GameFlag)flagNum);
+END_OPCODE
//////////////////////////////////////////////////////////////////////////
// Opcode 0x03
-IMPLEMENT_OPCODE(ToggleGameFlag) {
- GameFlag flagNum = (GameFlag)cmd->param1;
+IMPLEMENT_OPCODE(ToggleGameFlag)
+ int32 flagNum = cmd->param1;
if (flagNum >= 0)
- _vm->toggleGameFlag(flagNum);
-}
+ _vm->toggleGameFlag((GameFlag)flagNum);
+END_OPCODE
//////////////////////////////////////////////////////////////////////////
// Opcode 0x04
-IMPLEMENT_OPCODE(JumpIfGameFlag) {
+IMPLEMENT_OPCODE(JumpIfGameFlag)
if (cmd->param1 < 0)
return;
@@ -335,25 +337,25 @@ IMPLEMENT_OPCODE(JumpIfGameFlag) {
return;
setNextLine(cmd->param3);
-}
+END_OPCODE
//////////////////////////////////////////////////////////////////////////
// Opcode 0x05
-IMPLEMENT_OPCODE(HideCursor) {
+IMPLEMENT_OPCODE(HideCursor)
getCursor()->hide();
-}
+END_OPCODE
//////////////////////////////////////////////////////////////////////////
// Opcode 0x06
-IMPLEMENT_OPCODE(ShowCursor) {
+IMPLEMENT_OPCODE(ShowCursor)
getCursor()->show();
_vm->clearFlag(kFlagType1);
-}
+END_OPCODE
//////////////////////////////////////////////////////////////////////////
// Opcode 0x07
-IMPLEMENT_OPCODE(PlayAnimation) {
+IMPLEMENT_OPCODE(PlayAnimation)
Object *object = getWorld()->getObjectById((ObjectId)cmd->param1);
if (cmd->param2 == 2) {
@@ -388,8 +390,8 @@ IMPLEMENT_OPCODE(PlayAnimation) {
} else {
Common::Rect frameRect = GraphicResource::getFrameRect(_vm, object->getResourceId(), object->getFrameIndex());
- getScene()->setGlobalX(frameRect.left + (frameRect.width() >> 1) + object->x);
- getScene()->setGlobalY(frameRect.top + (frameRect.height() >> 1) + object->y);
+ getScene()->setGlobalX(frameRect.left + Common::Rational(frameRect.width(), 2).toInt() + object->x);
+ getScene()->setGlobalY(frameRect.top + Common::Rational(frameRect.height(), 2).toInt() + object->y);
}
}
@@ -397,11 +399,11 @@ IMPLEMENT_OPCODE(PlayAnimation) {
cmd->param2 = 2;
_lineIncrement = 1;
}
-}
+END_OPCODE
//////////////////////////////////////////////////////////////////////////
// Opcode 0x08
-IMPLEMENT_OPCODE(MoveScenePosition) {
+IMPLEMENT_OPCODE(MoveScenePosition)
if (cmd->param3 < 1) {
getWorld()->xLeft = cmd->param1;
getWorld()->yTop = cmd->param2;
@@ -430,61 +432,61 @@ IMPLEMENT_OPCODE(MoveScenePosition) {
_lineIncrement = 1;
}
-}
+END_OPCODE
//////////////////////////////////////////////////////////////////////////
// Opcode 0x09
-IMPLEMENT_OPCODE(HideActor) {
+IMPLEMENT_OPCODE(HideActor)
Actor *actor = getScene()->getActor(cmd->param1);
actor->hide();
actor->updateDirection();
-}
+END_OPCODE
//////////////////////////////////////////////////////////////////////////
// Opcode 0x0A
-IMPLEMENT_OPCODE(ShowActor) {
+IMPLEMENT_OPCODE(ShowActor)
Actor *actor = getScene()->getActor(cmd->param1);
actor->show();
actor->updateDirection();
actor->setLastScreenUpdate(_vm->getTick());
-}
+END_OPCODE
//////////////////////////////////////////////////////////////////////////
// Opcode 0x0B
-IMPLEMENT_OPCODE(SetActorPosition) {
+IMPLEMENT_OPCODE(SetActorPosition)
Actor *actor = getScene()->getActor(cmd->param1);
- actor->setPosition(cmd->param2, cmd->param3, (ActorDirection)cmd->param4, cmd->param5);
-}
+ actor->setPosition(cmd->param2, cmd->param3, (ActorDirection)cmd->param4, (uint32)cmd->param5);
+END_OPCODE
//////////////////////////////////////////////////////////////////////////
// Opcode 0x0C
-IMPLEMENT_OPCODE(SetSceneMotionStatus) {
+IMPLEMENT_OPCODE(SetSceneMotionStatus)
getWorld()->motionStatus = cmd->param1;
-}
+END_OPCODE
//////////////////////////////////////////////////////////////////////////
// Opcode 0x0D
-IMPLEMENT_OPCODE(DisableActor) {
+IMPLEMENT_OPCODE(DisableActor)
Actor *actor = getScene()->getActor(cmd->param1);
actor->updateStatus(kActorStatusDisabled);
-}
+END_OPCODE
//////////////////////////////////////////////////////////////////////////
// Opcode 0x0E
-IMPLEMENT_OPCODE(EnableActor) {
+IMPLEMENT_OPCODE(EnableActor)
Actor *actor = getScene()->getActor(cmd->param1);
if (actor->getStatus() == kActorStatusDisabled)
actor->updateStatus(kActorStatusEnabled);
-}
+END_OPCODE
//////////////////////////////////////////////////////////////////////////
// Opcode 0x0F
-IMPLEMENT_OPCODE(EnableObjects) {
+IMPLEMENT_OPCODE(EnableObjects)
Object *object = getWorld()->getObjectById((ObjectId)cmd->param1);
if (!_currentScript->counter && getWorld()->chapter != 13)
@@ -506,25 +508,25 @@ IMPLEMENT_OPCODE(EnableObjects) {
_lineIncrement = 1;
}
-}
+END_OPCODE
//////////////////////////////////////////////////////////////////////////
// Opcode 0x10 : Identical to opcode 0x00
//////////////////////////////////////////////////////////////////////////
// Opcode 0x11
-IMPLEMENT_OPCODE(RemoveObject) {
+IMPLEMENT_OPCODE(RemoveObject)
if (!cmd->param1)
return;
Object *object = getWorld()->getObjectById((ObjectId)cmd->param1);
object->disableAndRemoveFromQueue();
-}
+END_OPCODE
//////////////////////////////////////////////////////////////////////////
// Opcode 0x12
-IMPLEMENT_OPCODE(JumpActorSpeech) {
+IMPLEMENT_OPCODE(JumpActorSpeech)
Actor *actor = getScene()->getActor(cmd->param1);
if (actor->process(cmd->param2, cmd->param3))
@@ -534,11 +536,11 @@ IMPLEMENT_OPCODE(JumpActorSpeech) {
if (cmd->param5)
getSpeech()->playIndexed(1);
-}
+END_OPCODE
//////////////////////////////////////////////////////////////////////////
// Opcode 0x13
-IMPLEMENT_OPCODE(JumpAndSetDirection) {
+IMPLEMENT_OPCODE(JumpAndSetDirection)
Actor *actor = getScene()->getActor(cmd->param1);
if (actor->getStatus() != kActorStatus2 && actor->getStatus() != kActorStatus13) {
@@ -549,7 +551,7 @@ IMPLEMENT_OPCODE(JumpAndSetDirection) {
} else if ((actor->x1 + actor->x2) == cmd->param2 && (actor->y1 + actor->y2) == cmd->param3) {
actor->updateFromDirection((ActorDirection)cmd->param4);
} else {
- actor->processStatus(cmd->param2, cmd->param3, cmd->param4);
+ actor->processStatus(cmd->param2, cmd->param3, (bool)cmd->param4);
if (cmd->param5 == 1) {
cmd->param5 = 2;
@@ -567,142 +569,144 @@ IMPLEMENT_OPCODE(JumpAndSetDirection) {
if (cmd->param5 == 2)
_lineIncrement = 1;
}
-}
+END_OPCODE
//////////////////////////////////////////////////////////////////////////
// Opcode 0x14
-IMPLEMENT_OPCODE(JumpIfActorCoordinates) {
+IMPLEMENT_OPCODE(JumpIfActorCoordinates)
Actor *actor = getScene()->getActor(cmd->param1);
if ((actor->x1 + actor->x2) != cmd->param2 || (actor->y1 + actor->y2) != cmd->param3)
_lineIncrement = cmd->param4;
-}
+END_OPCODE
//////////////////////////////////////////////////////////////////////////
// Opcode 0x15
-IMPLEMENT_OPCODE(Nop) {
+IMPLEMENT_OPCODE(Nop)
// Nothing to do
-}
+END_OPCODE
//////////////////////////////////////////////////////////////////////////
// Opcode 0x16
-IMPLEMENT_OPCODE(ResetAnimation) {
+IMPLEMENT_OPCODE(ResetAnimation)
Object *object = getWorld()->getObjectById((ObjectId)cmd->param1);
if (object->flags & kObjectFlag10000)
object->setFrameIndex(object->getFrameCount() - 1);
else
object->setFrameIndex(0);
-}
+END_OPCODE
//////////////////////////////////////////////////////////////////////////
// Opcode 0x17
-IMPLEMENT_OPCODE(DisableObject) {
+IMPLEMENT_OPCODE(DisableObject)
Object *object = getWorld()->getObjectById((ObjectId)cmd->param1);
object->disable();
-}
+END_OPCODE
//////////////////////////////////////////////////////////////////////////
// Opcode 0x18
-IMPLEMENT_OPCODE(JumpIfSoundPlayingAndPlaySound) {
+IMPLEMENT_OPCODE(JumpIfSoundPlayingAndPlaySound)
+ ResourceId resource = (ResourceId)cmd->param1;
+
if (cmd->param2 == 2) {
- if (getSound()->isPlaying((ResourceId)cmd->param1))
+ if (getSound()->isPlaying(resource))
_lineIncrement = 1;
else
cmd->param2 = 1;
- } else if (!_vm->sound()->isPlaying((ResourceId)cmd->param1)) {
+ } else if (!_vm->sound()->isPlaying(resource)) {
int32 vol = getSound()->getAdjustedVolume(abs(Config.sfxVolume));
- getSound()->playSound((ResourceId)cmd->param1, cmd->param4, -((abs(cmd->param3) + vol) * (abs(cmd->param3) + vol)), 0);
+ getSound()->playSound(resource, (bool)cmd->param4, -((abs(cmd->param3) + vol) * (abs(cmd->param3) + vol)), 0);
if (cmd->param2 == 1) {
cmd->param2 = 2;
_lineIncrement= 1;
}
}
-}
+END_OPCODE
//////////////////////////////////////////////////////////////////////////
// Opcode 0x19
-IMPLEMENT_OPCODE(JumpIfActionFind) {
+IMPLEMENT_OPCODE(JumpIfActionFind)
jumpIfActionFlag(cmd, kActionTypeFind);
-}
+END_OPCODE
//////////////////////////////////////////////////////////////////////////
// Opcode 0x1A
-IMPLEMENT_OPCODE(SetActionFind) {
+IMPLEMENT_OPCODE(SetActionFind)
setActionFlag(cmd, kActionTypeFind);
-}
+END_OPCODE
//////////////////////////////////////////////////////////////////////////
// Opcode 0x1B
-IMPLEMENT_OPCODE(ClearActionFind) {
+IMPLEMENT_OPCODE(ClearActionFind)
clearActionFlag(cmd, kActionTypeFind);
-}
+END_OPCODE
//////////////////////////////////////////////////////////////////////////
// Opcode 0x1C
-IMPLEMENT_OPCODE(JumpIfActionGrab) {
+IMPLEMENT_OPCODE(JumpIfActionGrab)
jumpIfActionFlag(cmd, kActionTypeGrab);
-}
+END_OPCODE
//////////////////////////////////////////////////////////////////////////
// Opcode 0x1D
-IMPLEMENT_OPCODE(SetActionGrab) {
+IMPLEMENT_OPCODE(SetActionGrab)
setActionFlag(cmd, kActionTypeGrab);
-}
+END_OPCODE
//////////////////////////////////////////////////////////////////////////
// Opcode 0x1E
-IMPLEMENT_OPCODE(ClearActionGrab) {
+IMPLEMENT_OPCODE(ClearActionGrab)
clearActionFlag(cmd, kActionTypeGrab);
-}
+END_OPCODE
//////////////////////////////////////////////////////////////////////////
// Opcode 0x1F
-IMPLEMENT_OPCODE(JumpIfActionTalk) {
+IMPLEMENT_OPCODE(JumpIfActionTalk)
jumpIfActionFlag(cmd, kActionTypeTalk);
-}
+END_OPCODE
//////////////////////////////////////////////////////////////////////////
// Opcode 0x20
-IMPLEMENT_OPCODE(SetActionTalk) {
+IMPLEMENT_OPCODE(SetActionTalk)
setActionFlag(cmd, kActionTypeTalk);
-}
+END_OPCODE
//////////////////////////////////////////////////////////////////////////
// Opcode 0x21
-IMPLEMENT_OPCODE(ClearActionTalk) {
+IMPLEMENT_OPCODE(ClearActionTalk)
clearActionFlag(cmd, kActionTypeTalk);
-}
+END_OPCODE
//////////////////////////////////////////////////////////////////////////
// Opcode 0x22
-IMPLEMENT_OPCODE(_unk22) {
+IMPLEMENT_OPCODE(_unk22)
Actor *actor = getScene()->getActor(cmd->param3 ? cmd->param3 : _currentQueueEntry.actorIndex);
actor->process_41BC00(cmd->param1, cmd->param2);
-}
+END_OPCODE
//////////////////////////////////////////////////////////////////////////
// Opcode 0x23
-IMPLEMENT_OPCODE(_unk23) {
+IMPLEMENT_OPCODE(_unk23)
Actor *actor = getScene()->getActor(cmd->param3 ? cmd->param3 : _currentQueueEntry.actorIndex);
actor->process_41BCC0(cmd->param1, cmd->param2);
-}
+END_OPCODE
//////////////////////////////////////////////////////////////////////////
// Opcode 0x24
-IMPLEMENT_OPCODE(_unk24) {
+IMPLEMENT_OPCODE(_unk24)
Actor *actor = getScene()->getActor(cmd->param4 ? cmd->param4 : _currentQueueEntry.actorIndex);
- actor->process_41BDB0(cmd->param1, cmd->param3);
-}
+ actor->process_41BDB0(cmd->param1, (bool)cmd->param3);
+END_OPCODE
//////////////////////////////////////////////////////////////////////////
// Opcode 0x25
-IMPLEMENT_OPCODE(RunEncounter) {
+IMPLEMENT_OPCODE(RunEncounter)
Encounter *encounter = _vm->encounter();
encounter->setFlag(kEncounterFlag5, cmd->param5);
@@ -718,46 +722,46 @@ IMPLEMENT_OPCODE(RunEncounter) {
cmd->param6 = 2;
_lineIncrement = 1;
}
-}
+END_OPCODE
//////////////////////////////////////////////////////////////////////////
// Opcode 0x26
-IMPLEMENT_OPCODE(JumpIfAction16) {
+IMPLEMENT_OPCODE(JumpIfAction16)
jumpIfActionFlag(cmd, kActionType16);
-}
+END_OPCODE
//////////////////////////////////////////////////////////////////////////
// Opcode 0x27
-IMPLEMENT_OPCODE(SetAction16) {
+IMPLEMENT_OPCODE(SetAction16)
setActionFlag(cmd, kActionType16);
-}
+END_OPCODE
//////////////////////////////////////////////////////////////////////////
// Opcode 0x28
-IMPLEMENT_OPCODE(ClearAction16) {
+IMPLEMENT_OPCODE(ClearAction16)
clearActionFlag(cmd, kActionType16);
-}
+END_OPCODE
//////////////////////////////////////////////////////////////////////////
// Opcode 0x29
-IMPLEMENT_OPCODE(SetActorField638) {
+IMPLEMENT_OPCODE(SetActorField638)
Actor *actor = getScene()->getActor(cmd->param1);
actor->setField638(cmd->param2);
-}
+END_OPCODE
//////////////////////////////////////////////////////////////////////////
// Opcode 0x2A
-IMPLEMENT_OPCODE(JumpIfActorField638) {
+IMPLEMENT_OPCODE(JumpIfActorField638)
Actor *actor = getScene()->getActor(cmd->param1);
if (actor->getField638())
_currentLine = cmd->param3;
-}
+END_OPCODE
//////////////////////////////////////////////////////////////////////////
// Opcode 0x2B
-IMPLEMENT_OPCODE(ChangeScene) {
+IMPLEMENT_OPCODE(ChangeScene)
getScene()->getActor(0)->updateStatus(kActorStatusDisabled);
resetQueue();
@@ -773,14 +777,14 @@ IMPLEMENT_OPCODE(ChangeScene) {
_delayedSceneIndex = (ResourcePackId)(cmd->param1 + 4);
_exit = true;
-}
+END_OPCODE
//////////////////////////////////////////////////////////////////////////
// Opcode 0x2C
-IMPLEMENT_OPCODE(_unk2C_ActorSub) {
+IMPLEMENT_OPCODE(_unk2C_ActorSub)
Actor *player = getScene()->getActor();
Actor *actor = getScene()->getActor(_currentQueueEntry.actorIndex);
- Common::Point playerPoint(player->x1 + player->x2, player->y1 + player->y2);
+ Common::Point playerPoint((int16)(player->x1 + player->x2), (int16)(player->y1 + player->y2));
ActorDirection direction = (cmd->param2 == 8) ? player->getDirection() : (ActorDirection)cmd->param2;
ActorDirection newDirection = (ActorDirection)((player->getDirection() + 4) % 8);
@@ -813,8 +817,8 @@ IMPLEMENT_OPCODE(_unk2C_ActorSub) {
if (player->process_408B20(&point, newDirection, 3, false)) {
- point.x += 3 * deltaPointsArray[newDirection].x;
- point.x += 3 * deltaPointsArray[newDirection].y;
+ point.x += (int16)(3 * deltaPointsArray[newDirection].x);
+ point.y += (int16)(3 * deltaPointsArray[newDirection].y);
player->setPosition(point.x, point.y, actor->getDirection(), 0);
}
@@ -823,9 +827,9 @@ IMPLEMENT_OPCODE(_unk2C_ActorSub) {
} else if (cmd->param1 != 2 || player->process_408B20(&playerPoint, newDirection, 3, false)) {
ResourceId id = kResourceNone;
if (direction >= 5)
- id = actor->getResourcesId(5 * cmd->param1 - direction + 38);
+ id = actor->getResourcesId((uint32)(5 * cmd->param1 - (direction - 38)));
else
- id = actor->getResourcesId(5 * cmd->param1 + direction + 30);
+ id = actor->getResourcesId((uint32)(5 * cmd->param1 + direction + 30));
actor->setResourceId(id);
actor->setFrameCount(GraphicResource::getFrameCount(_vm, id));
@@ -836,11 +840,11 @@ IMPLEMENT_OPCODE(_unk2C_ActorSub) {
cmd->param3 = 2;
_lineIncrement = 1;
}
-}
+END_OPCODE
//////////////////////////////////////////////////////////////////////////
// Opcode 0x2D
-IMPLEMENT_OPCODE(PlayMovie) {
+IMPLEMENT_OPCODE(PlayMovie)
if (getScene()->matteBarHeight < 170) {
_lineIncrement = 1;
@@ -894,69 +898,69 @@ IMPLEMENT_OPCODE(PlayMovie) {
getCursor()->show();
getScene()->matteVar2 = 0;
-}
+END_OPCODE
//////////////////////////////////////////////////////////////////////////
// Opcode 0x2E
-IMPLEMENT_OPCODE(StopAllObjectsSounds) {
+IMPLEMENT_OPCODE(StopAllObjectsSounds)
Object *object = getWorld()->getObjectById((ObjectId)cmd->param1);
object->stopAllSounds();
-}
+END_OPCODE
//////////////////////////////////////////////////////////////////////////
// Opcode 0x2F
-IMPLEMENT_OPCODE(StopProcessing) {
+IMPLEMENT_OPCODE(StopProcessing)
_skipProcessing = true;
-}
+END_OPCODE
//////////////////////////////////////////////////////////////////////////
// Opcode 0x30
-IMPLEMENT_OPCODE(ResumeProcessing) {
+IMPLEMENT_OPCODE(ResumeProcessing)
_skipProcessing = false;
-}
+END_OPCODE
//////////////////////////////////////////////////////////////////////////
// Opcode 0x31
-IMPLEMENT_OPCODE(ResetSceneRect) {
- getWorld()->sceneRectIdx = LOBYTE(cmd->param1);
+IMPLEMENT_OPCODE(ResetSceneRect)
+ getWorld()->sceneRectIdx = (uint8)LOBYTE(cmd->param1);
getScreen()->paletteFade(0, 25, 10);
_vm->setFlag(kFlagTypeSceneRectChanged);
getWorld()->xLeft = getWorld()->sceneRects[getWorld()->sceneRectIdx].left;
getWorld()->yTop = getWorld()->sceneRects[getWorld()->sceneRectIdx].top;
-}
+END_OPCODE
//////////////////////////////////////////////////////////////////////////
// Opcode 0x32
-IMPLEMENT_OPCODE(ChangeMusicById) {
+IMPLEMENT_OPCODE(ChangeMusicById)
_vm->sound()->changeMusic((ResourceId)cmd->param1, cmd->param2 ? 2 : 1);
-}
+END_OPCODE
//////////////////////////////////////////////////////////////////////////
// Opcode 0x33
-IMPLEMENT_OPCODE(StopMusic) {
+IMPLEMENT_OPCODE(StopMusic)
_vm->sound()->changeMusic(kMusicStopped, 0);
-}
+END_OPCODE
//////////////////////////////////////////////////////////////////////////
// Opcode 0x34
-IMPLEMENT_OPCODE(_unk34_Status) {
+IMPLEMENT_OPCODE(_unk34_Status)
if (cmd->param1 >= 2) {
cmd->param1 = 0;
} else {
cmd->param1++;
_lineIncrement = 1;
}
-}
+END_OPCODE
//////////////////////////////////////////////////////////////////////////
// Opcode 0x35
-IMPLEMENT_OPCODE(SetVolume) {
+IMPLEMENT_OPCODE(SetVolume)
AmbientSoundItem item = getWorld()->ambientSounds[cmd->param1];
int var = cmd->param2 + item.field_C;
- double volume = -((Config.sfxVolume + var) * (Config.ambientVolume + var));
+ int32 volume = -((Config.sfxVolume + var) * (Config.ambientVolume + var));
if (volume < 0) {
if (volume < -10000)
@@ -966,48 +970,48 @@ IMPLEMENT_OPCODE(SetVolume) {
}
_vm->sound()->setVolume(item.resourceId, volume);
-}
+END_OPCODE
//////////////////////////////////////////////////////////////////////////
// Opcode 0x36
-IMPLEMENT_OPCODE(Jump) {
+IMPLEMENT_OPCODE(Jump)
_currentLine = cmd->param1 - 1;
-}
+END_OPCODE
//////////////////////////////////////////////////////////////////////////
// Opcode 0x37
-IMPLEMENT_OPCODE(RunBlowUpPuzzle) {
+IMPLEMENT_OPCODE(RunBlowUpPuzzle)
getScreen()->clearScreen();
getScreen()->clearGraphicsInQueue();
- _vm->switchMessageHandler(_vm->getMessageHandler(cmd->param1));
+ _vm->switchMessageHandler(_vm->getMessageHandler((uint32)cmd->param1));
_currentLine++;
_exit = true;
-}
+END_OPCODE
//////////////////////////////////////////////////////////////////////////
// Opcode 0x38
-IMPLEMENT_OPCODE(JumpIfAction8) {
+IMPLEMENT_OPCODE(JumpIfAction8)
jumpIfActionFlag(cmd, kActionType8);
-}
+END_OPCODE
//////////////////////////////////////////////////////////////////////////
// Opcode 0x39
-IMPLEMENT_OPCODE(SetAction8) {
+IMPLEMENT_OPCODE(SetAction8)
setActionFlag(cmd, kActionType8);
-}
+END_OPCODE
//////////////////////////////////////////////////////////////////////////
// Opcode 0x3A
-IMPLEMENT_OPCODE(ClearAction8) {
+IMPLEMENT_OPCODE(ClearAction8)
clearActionFlag(cmd, kActionType8);
-}
+END_OPCODE
//////////////////////////////////////////////////////////////////////////
// Opcode 0x3B
-IMPLEMENT_OPCODE(_unk3B_PALETTE_MOD) {
+IMPLEMENT_OPCODE(_unk3B_PALETTE_MOD)
if (!cmd->param2) {
getScene()->makeGreyPalette();
cmd->param2 = 1;
@@ -1030,11 +1034,11 @@ IMPLEMENT_OPCODE(_unk3B_PALETTE_MOD) {
_lineIncrement = 1;
++cmd->param1;
-}
+END_OPCODE
//////////////////////////////////////////////////////////////////////////
// Opcode 0x3C
-IMPLEMENT_OPCODE(IncrementParam2) {
+IMPLEMENT_OPCODE(IncrementParam2)
if (cmd->param1) {
if (cmd->param2 >= cmd->param1) {
cmd->param2 = 0;
@@ -1043,11 +1047,11 @@ IMPLEMENT_OPCODE(IncrementParam2) {
_lineIncrement = 1;
}
}
-}
+END_OPCODE
//////////////////////////////////////////////////////////////////////////
// Opcode 0x3D
-IMPLEMENT_OPCODE(WaitUntilFramePlayed) {
+IMPLEMENT_OPCODE(WaitUntilFramePlayed)
Object *object = getWorld()->getObjectById((ObjectId)cmd->param1);
int32 frameNum = cmd->param2;
@@ -1058,12 +1062,12 @@ IMPLEMENT_OPCODE(WaitUntilFramePlayed) {
_lineIncrement = 1;
_waitCycle = true;
}
-}
+END_OPCODE
//////////////////////////////////////////////////////////////////////////
// Opcode 0x3E
-IMPLEMENT_OPCODE(UpdateWideScreen) {
+IMPLEMENT_OPCODE(UpdateWideScreen)
int barSize = cmd->param1;
if (barSize >= 22) {
@@ -1072,26 +1076,26 @@ IMPLEMENT_OPCODE(UpdateWideScreen) {
getScene()->matteBarHeight = 0;
} else {
- getScreen()->drawWideScreen(4 * barSize);
+ getScreen()->drawWideScreen((int16)(4 * barSize));
_lineIncrement = 1;
++cmd->param1;
}
-}
+END_OPCODE
//////////////////////////////////////////////////////////////////////////
// Opcode 0x3F
-IMPLEMENT_OPCODE(JumpIfActor) {
+IMPLEMENT_OPCODE(JumpIfActor)
ActorIndex index = (cmd->param1 == kActorInvalid) ? getScene()->getPlayerActorIndex() : cmd->param1;
if (_currentQueueEntry.actorIndex != index)
_currentLine = cmd->param2 - 1;
-}
+END_OPCODE
//////////////////////////////////////////////////////////////////////////
// Opcode 0x40
-IMPLEMENT_OPCODE(PlaySpeechScene) {
+IMPLEMENT_OPCODE(PlaySpeechScene)
if (cmd->param1 < 0 || cmd->param1 >= 5)
return;
@@ -1139,11 +1143,11 @@ IMPLEMENT_OPCODE(PlaySpeechScene) {
_vm->clearFlag(kFlagType1);
_vm->clearFlag(kFlagType2);
}
-}
+END_OPCODE
//////////////////////////////////////////////////////////////////////////
// Opcode 0x41
-IMPLEMENT_OPCODE(PlaySpeech) {
+IMPLEMENT_OPCODE(PlaySpeech)
if (cmd->param1 < 0)
return;
@@ -1191,11 +1195,11 @@ IMPLEMENT_OPCODE(PlaySpeech) {
_vm->clearFlag(kFlagType1);
_vm->clearFlag(kFlagType2);
}
-}
+END_OPCODE
//////////////////////////////////////////////////////////////////////////
// Opcode 0x42
-IMPLEMENT_OPCODE(PlaySpeechScene2) {
+IMPLEMENT_OPCODE(PlaySpeechScene2)
if (cmd->param1 < 0 || cmd->param1 >= 20 || cmd->param2 < 0)
return;
@@ -1242,11 +1246,11 @@ IMPLEMENT_OPCODE(PlaySpeechScene2) {
if (cmd->param4 && !cmd->param7)
_vm->setGameFlag(kGameFlag219);
-}
+END_OPCODE
//////////////////////////////////////////////////////////////////////////
// Opcode 0x43
-IMPLEMENT_OPCODE(MoveScenePositionFromActor) {
+IMPLEMENT_OPCODE(MoveScenePositionFromActor)
Actor *actor = getScene()->getActor(cmd->param1);
if (!cmd->param3) {
@@ -1275,23 +1279,23 @@ IMPLEMENT_OPCODE(MoveScenePositionFromActor) {
else
_lineIncrement = 1;
}
-}
+END_OPCODE
//////////////////////////////////////////////////////////////////////////
// Opcode 0x44
-IMPLEMENT_OPCODE(PaletteFade) {
+IMPLEMENT_OPCODE(PaletteFade)
getScreen()->paletteFade(0, cmd->param1, cmd->param2);
-}
+END_OPCODE
//////////////////////////////////////////////////////////////////////////
// Opcode 0x45
-IMPLEMENT_OPCODE(StartPaletteFadeThread) {
+IMPLEMENT_OPCODE(StartPaletteFadeThread)
getScreen()->startPaletteFade(getWorld()->currentPaletteId, cmd->param1, cmd->param2);
-}
+END_OPCODE
//////////////////////////////////////////////////////////////////////////
// Opcode 0x46
-IMPLEMENT_OPCODE(_unk46) {
+IMPLEMENT_OPCODE(_unk46)
if (cmd->param6) {
if (getSound()->isPlaying(getSpeech()->getSoundResourceId())) {
_lineIncrement = 1;
@@ -1331,17 +1335,17 @@ IMPLEMENT_OPCODE(_unk46) {
_lineIncrement = 1;
}
}
-}
+END_OPCODE
//////////////////////////////////////////////////////////////////////////
// Opcode 0x47
-IMPLEMENT_OPCODE(ActorFaceObject) {
+IMPLEMENT_OPCODE(ActorFaceObject)
getScene()->getActor(cmd->param1)->faceTarget((ObjectId)cmd->param2, (DirectionFrom)cmd->param3);
-}
+END_OPCODE
//////////////////////////////////////////////////////////////////////////
// Opcode 0x48
-IMPLEMENT_OPCODE(_unk48_MATTE_01) {
+IMPLEMENT_OPCODE(_unk48_MATTE_01)
getScene()->matteVar1 = 0;
getScene()->matteInitialized = true;
@@ -1357,11 +1361,11 @@ IMPLEMENT_OPCODE(_unk48_MATTE_01) {
getScene()->matteBarHeight = 1;
}
}
-}
+END_OPCODE
//////////////////////////////////////////////////////////////////////////
// Opcode 0x49
-IMPLEMENT_OPCODE(_unk49_MATTE_90) {
+IMPLEMENT_OPCODE(_unk49_MATTE_90)
getScene()->matteVar1 = 0;
getScene()->matteInitialized = true;
getScene()->mattePlaySound = true;
@@ -1378,11 +1382,11 @@ IMPLEMENT_OPCODE(_unk49_MATTE_90) {
getScene()->matteBarHeight = 90;
}
}
-}
+END_OPCODE
//////////////////////////////////////////////////////////////////////////
// Opcode 0x4A
-IMPLEMENT_OPCODE(JumpIfSoundPlaying) {
+IMPLEMENT_OPCODE(JumpIfSoundPlaying)
if (cmd->param3 == 1) {
if (_vm->sound()->isPlaying((ResourceId)cmd->param1)) {
_currentLine = cmd->param2;
@@ -1390,17 +1394,17 @@ IMPLEMENT_OPCODE(JumpIfSoundPlaying) {
} else if (!_vm->sound()->isPlaying((ResourceId)cmd->param1)) {
_currentLine = cmd->param2;
}
-}
+END_OPCODE
//////////////////////////////////////////////////////////////////////////
// Opcode 0x4B
-IMPLEMENT_OPCODE(ChangePlayerActorIndex) {
+IMPLEMENT_OPCODE(ChangePlayerActorIndex)
getScene()->changePlayer(cmd->param1);
-}
+END_OPCODE
//////////////////////////////////////////////////////////////////////////
// Opcode 0x4C
-IMPLEMENT_OPCODE(ChangeActorStatus) {
+IMPLEMENT_OPCODE(ChangeActorStatus)
Actor *actor = getScene()->getActor(cmd->param1);
if (cmd->param2) {
@@ -1409,47 +1413,47 @@ IMPLEMENT_OPCODE(ChangeActorStatus) {
} else {
actor->setStatus(kActorStatusEnabled);
}
-}
+END_OPCODE
//////////////////////////////////////////////////////////////////////////
// Opcode 0x4D
-IMPLEMENT_OPCODE(StopSound) {
+IMPLEMENT_OPCODE(StopSound)
if (_vm->sound()->isPlaying((ResourceId)cmd->param1))
_vm->sound()->stop((ResourceId)cmd->param1);
-}
+END_OPCODE
//////////////////////////////////////////////////////////////////////////
// Opcode 0x4E
-IMPLEMENT_OPCODE(JumpRandom) {
- if (_vm->getRandom(cmd->param1) < (uint32)cmd->param2)
+IMPLEMENT_OPCODE(JumpRandom)
+ if (_vm->getRandom((uint32)cmd->param1) < (uint32)cmd->param2)
return;
setNextLine(cmd->param3);
-}
+END_OPCODE
//////////////////////////////////////////////////////////////////////////
// Opcode 0x4F
-IMPLEMENT_OPCODE(ClearScreen) {
- getScene()->setSkipDrawScene(cmd->param1);
+IMPLEMENT_OPCODE(ClearScreen)
+ getScene()->setSkipDrawScene((bool)cmd->param1);
if (cmd->param1)
getScreen()->clearScreen();
-}
+END_OPCODE
//////////////////////////////////////////////////////////////////////////
// Opcode 0x50
-IMPLEMENT_OPCODE(Quit) {
+IMPLEMENT_OPCODE(Quit)
getScreen()->clearScreen();
- _vm->quitGame();
+ Engine::quitGame();
// We need to exit the interpreter loop so we get back to the event loop
// and get the quit message
_exit = true;
-}
+END_OPCODE
//////////////////////////////////////////////////////////////////////////
// Opcode 0x51
-IMPLEMENT_OPCODE(JumpObjectFrame) {
+IMPLEMENT_OPCODE(JumpObjectFrame)
Object *object = getWorld()->getObjectById((ObjectId)cmd->param1);
if (cmd->param2 == -1)
@@ -1475,35 +1479,35 @@ IMPLEMENT_OPCODE(JumpObjectFrame) {
}
setNextLine(cmd->param9);
-}
+END_OPCODE
//////////////////////////////////////////////////////////////////////////
// Opcode 0x52
-IMPLEMENT_OPCODE(DeleteGraphics) {
+IMPLEMENT_OPCODE(DeleteGraphics)
for (uint i = 0; i < 55; i++)
- getScreen()->deleteGraphicFromQueue(getScene()->getActor(cmd->param1)->getResourcesId(cmd->param1));
-}
+ getScreen()->deleteGraphicFromQueue(getScene()->getActor((ActorIndex)(cmd->param1))->getResourcesId((uint32)cmd->param1));
+END_OPCODE
//////////////////////////////////////////////////////////////////////////
// Opcode 0x53
-IMPLEMENT_OPCODE(SetActorField944) {
+IMPLEMENT_OPCODE(SetActorField944)
Actor *actor = getScene()->getActor(cmd->param1);
actor->setField944(cmd->param2);
-}
+END_OPCODE
//////////////////////////////////////////////////////////////////////////
// Opcode 0x54
-IMPLEMENT_OPCODE(_unk54_SET_ACTIONLIST_6EC) {
+IMPLEMENT_OPCODE(_unk54_SET_ACTIONLIST_6EC)
if (cmd->param2)
- _currentScript->field_1BB0 = _vm->getRandom(cmd->param1);
+ _currentScript->field_1BB0 = _vm->getRandom((uint32)cmd->param1);
else
_currentScript->field_1BB0 = cmd->param1;
-}
+END_OPCODE
//////////////////////////////////////////////////////////////////////////
// Opcode 0x55
-IMPLEMENT_OPCODE(_unk55) {
+IMPLEMENT_OPCODE(_unk55)
if (cmd->param2) {
if (_currentScript->field_1BB0 == cmd->param1)
@@ -1531,11 +1535,11 @@ IMPLEMENT_OPCODE(_unk55) {
}
setNextLine(cmd->param8);
-}
+END_OPCODE
//////////////////////////////////////////////////////////////////////////
// Opcode 0x56
-IMPLEMENT_OPCODE(_unk56) {
+IMPLEMENT_OPCODE(_unk56)
Actor *actor = getScene()->getActor(cmd->param2 == 2 ? kActorInvalid : cmd->param1);
if (actor->getStatus() == kActorStatus2 || actor->getStatus() == kActorStatus13) {
@@ -1560,7 +1564,7 @@ IMPLEMENT_OPCODE(_unk56) {
int32 y = 0; // FIXME: is is set somewhere else?
if (getScene()->processActor(&x, &cmd->param4) == 1) {
- getScene()->getActor()->processStatus(x, y, cmd->param4);
+ getScene()->getActor()->processStatus(x, y, (bool)cmd->param4);
cmd->param6 = x;
cmd->param7 = y;
@@ -1575,19 +1579,19 @@ IMPLEMENT_OPCODE(_unk56) {
_currentLine = cmd->param3;
}
}
-}
+END_OPCODE
//////////////////////////////////////////////////////////////////////////
// Opcode 0x57
-IMPLEMENT_OPCODE(SetResourcePalette) {
+IMPLEMENT_OPCODE(SetResourcePalette)
getWorld()->currentPaletteId = getWorld()->graphicResourceIds[cmd->param1];
getScreen()->setPalette(getWorld()->currentPaletteId);
getScreen()->setGammaLevel(getWorld()->currentPaletteId, 0);
-}
+END_OPCODE
//////////////////////////////////////////////////////////////////////////
// Opcode 0x58
-IMPLEMENT_OPCODE(SetObjectFrameIdxFlaged) {
+IMPLEMENT_OPCODE(SetObjectFrameIdxFlaged)
Object *object = getWorld()->getObjectById((ObjectId)cmd->param1);
if (cmd->param3)
@@ -1596,11 +1600,11 @@ IMPLEMENT_OPCODE(SetObjectFrameIdxFlaged) {
object->flags &= ~kObjectFlagEnabled;
object->setFrameIndex(cmd->param2);
-}
+END_OPCODE
//////////////////////////////////////////////////////////////////////////
// Opcode 0x59
-IMPLEMENT_OPCODE(_unk59) {
+IMPLEMENT_OPCODE(_unk59)
Object *object = getWorld()->getObjectById((ObjectId)cmd->param1);
if (cmd->param2) {
@@ -1611,17 +1615,17 @@ IMPLEMENT_OPCODE(_unk59) {
if (cmd->param3 && (object->flags & kObjectFlag10E38))
_lineIncrement = 1;
-}
+END_OPCODE
//////////////////////////////////////////////////////////////////////////
// Opcode 0x5A
-IMPLEMENT_OPCODE(_unk5A) {
+IMPLEMENT_OPCODE(_unk5A)
getScene()->getActor(cmd->param1)->setActionIndex2(cmd->param2);
-}
+END_OPCODE
//////////////////////////////////////////////////////////////////////////
// Opcode 0x5B
-IMPLEMENT_OPCODE(_unk5B) {
+IMPLEMENT_OPCODE(_unk5B)
if (cmd->param2 >= 0 && cmd->param2 <= 3) {
if (cmd->param1) {
Object *object = getWorld()->getObjectById((ObjectId)cmd->param1);
@@ -1634,34 +1638,34 @@ IMPLEMENT_OPCODE(_unk5B) {
getScene()->getActor(cmd->param3)->setField96C(cmd->param2);
}
}
-}
+END_OPCODE
//////////////////////////////////////////////////////////////////////////
// Opcode 0x5C
-IMPLEMENT_OPCODE(QueueScript) {
+IMPLEMENT_OPCODE(QueueScript)
queueScript(getWorld()->getActionAreaById(cmd->param1)->scriptIndex, cmd->param2);
-}
+END_OPCODE
//////////////////////////////////////////////////////////////////////////
// Opcode 0x5D
-IMPLEMENT_OPCODE(_unk5D) {
+IMPLEMENT_OPCODE(_unk5D)
Actor *actor = getScene()->getActor(cmd->param1);
actor->process_401830(cmd->param2, cmd->param3, cmd->param4, cmd->param5, cmd->param6, cmd->param7, cmd->param8, cmd->param9);
-}
+END_OPCODE
//////////////////////////////////////////////////////////////////////////
// Opcode 0x5E
-IMPLEMENT_OPCODE(ClearActorFields) {
+IMPLEMENT_OPCODE(ClearActorFields)
Actor *actor = getScene()->getActor(cmd->param1);
// Clear fields starting from field_970
actor->clearFields();
-}
+END_OPCODE
//////////////////////////////////////////////////////////////////////////
// Opcode 0x5F
-IMPLEMENT_OPCODE(SetObjectLastFrameIdx) {
+IMPLEMENT_OPCODE(SetObjectLastFrameIdx)
Object *object = getWorld()->getObjectById((ObjectId)cmd->param1);
if (object->getFrameIndex() == object->getFrameCount() - 1) {
@@ -1670,22 +1674,22 @@ IMPLEMENT_OPCODE(SetObjectLastFrameIdx) {
} else {
_lineIncrement = 1;
}
-}
+END_OPCODE
//////////////////////////////////////////////////////////////////////////
// Opcode 0x60
-IMPLEMENT_OPCODE(_unk60_SET_OR_CLR_ACTIONAREA_FLAG) {
+IMPLEMENT_OPCODE(_unk60_SET_OR_CLR_ACTIONAREA_FLAG)
ActionArea *area = getWorld()->getActionAreaById(cmd->param1);
if (cmd->param2)
area->flags |= 1;
else
area->flags &= ~1;
-}
+END_OPCODE
//////////////////////////////////////////////////////////////////////////
// Opcode 0x61
-IMPLEMENT_OPCODE(_unk61) {
+IMPLEMENT_OPCODE(_unk61)
if (cmd->param2) {
if (getWorld()->field_E860C == -1) {
_lineIncrement = 0;
@@ -1698,17 +1702,17 @@ IMPLEMENT_OPCODE(_unk61) {
cmd->param2 = 1;
_lineIncrement = 1;
}
-}
+END_OPCODE
//////////////////////////////////////////////////////////////////////////
// Opcode 0x62
-IMPLEMENT_OPCODE(ShowOptionsScreen) {
+IMPLEMENT_OPCODE(ShowOptionsScreen)
_vm->menu()->showOptions();
-}
+END_OPCODE
//////////////////////////////////////////////////////////////////////////
// Opcode 0x63
-IMPLEMENT_OPCODE(_unk63) {
+IMPLEMENT_OPCODE(_unk63)
if (cmd->param1) {
_vm->setFlag(kFlagType1);
_vm->setFlag(kFlagType2);
@@ -1720,7 +1724,7 @@ IMPLEMENT_OPCODE(_unk63) {
} else if (!cmd->param1) {
cmd->param1 = 1;
}
-}
+END_OPCODE
//////////////////////////////////////////////////////////////////////////
// Opcode Helper functions
@@ -1786,6 +1790,9 @@ void ActionList::jumpIfActionFlag(ScriptEntry *cmd, ActionType flag) {
}
void ActionList::setNextLine(int32 line) {
+ if (!_currentScript)
+ error("[ActionList::setNextLine] No current script set!");
+
int32 opcode = _currentScript->commands[line].opcode;
if (opcode == 0x10 || opcode == 0) { // Return
_currentLine = line;
diff --git a/engines/asylum/resources/actionlist.h b/engines/asylum/resources/actionlist.h
index 6f7068f2ef..d526b77b58 100644
--- a/engines/asylum/resources/actionlist.h
+++ b/engines/asylum/resources/actionlist.h
@@ -41,7 +41,12 @@ namespace Asylum {
void k##name(ScriptEntry *cmd)
#define IMPLEMENT_OPCODE(name) \
- void ActionList::k##name(ScriptEntry *cmd)
+ void ActionList::k##name(ScriptEntry *cmd) { \
+ if (!_currentScript) error("[" #name "] No current script set!"); \
+ if (!cmd) error("[" #name "] Invalid command parameter!");
+
+#define END_OPCODE }
+
#define ADD_OPCODE(name) { \
Opcode *func = new Opcode(#name, new Common::Functor1Mem<ScriptEntry *, void, ActionList>(this, &ActionList::k##name)); \
diff --git a/engines/asylum/resources/actor.cpp b/engines/asylum/resources/actor.cpp
index 020b82ab10..e8500449fd 100644
--- a/engines/asylum/resources/actor.cpp
+++ b/engines/asylum/resources/actor.cpp
@@ -67,7 +67,7 @@ Actor::Actor(AsylumEngine *engine, ActorIndex index) : _vm(engine), _index(index
_field_60 = 0;
_actionIdx3 = 0;
// TODO field_68 till field_617
- _reaction[8] = 0;
+ memset(&_reaction, 0, sizeof(_reaction));
_field_638 = 0;
_walkingSound1 = 0;
_walkingSound2 = 0;
@@ -76,7 +76,7 @@ Actor::Actor(AsylumEngine *engine, ActorIndex index) : _vm(engine), _index(index
_field_64C = 0;
_field_650 = 0;
memset(_graphicResourceIds, 0 , sizeof(_graphicResourceIds));
- memset(&_name, 0, 256);
+ memset(&_name, 0, sizeof(_name));
memset(&_field_830, 0, sizeof(_field_830));
memset(&_field_880, 0, sizeof(_field_880));
memset(&_field_8D0, 0, sizeof(_field_8D0));
@@ -117,6 +117,9 @@ Actor::Actor(AsylumEngine *engine, ActorIndex index) : _vm(engine), _index(index
// update-related variables
_actorUpdateCounter = 0;
_enableFromStatus7 = false;
+
+ // Temporary resources
+ memset(&_resources, 0, sizeof(_resources));
}
Actor::~Actor() {
@@ -137,17 +140,17 @@ void Actor::load(Common::SeekableReadStream *stream) {
y = stream->readSint32LE();
_resourceId = (ResourceId)stream->readSint32LE();
_objectIndex = stream->readSint32LE();
- _frameIndex = stream->readSint32LE();
- _frameCount = stream->readSint32LE();
+ _frameIndex = stream->readUint32LE();
+ _frameCount = stream->readUint32LE();
x1 = stream->readSint32LE();
y1 = stream->readSint32LE();
x2 = stream->readSint32LE();
y2 = stream->readSint32LE();
- _boundingRect.left = stream->readSint32LE() & 0xFFFF;
- _boundingRect.top = stream->readSint32LE() & 0xFFFF;
- _boundingRect.right = stream->readSint32LE() & 0xFFFF;
- _boundingRect.bottom = stream->readSint32LE() & 0xFFFF;
+ _boundingRect.left = (int16)(stream->readSint32LE() & 0xFFFF);
+ _boundingRect.top = (int16)(stream->readSint32LE() & 0xFFFF);
+ _boundingRect.right = (int16)(stream->readSint32LE() & 0xFFFF);
+ _boundingRect.bottom = (int16)(stream->readSint32LE() & 0xFFFF);
_direction = (ActorDirection)stream->readSint32LE();
_field_3C = stream->readSint32LE();
@@ -192,7 +195,7 @@ void Actor::load(Common::SeekableReadStream *stream) {
_actionIdx2 = stream->readSint32LE();
_field_924 = stream->readSint32LE();
- _lastScreenUpdate = stream->readSint32LE();
+ _lastScreenUpdate = stream->readUint32LE();
_field_92C = stream->readSint32LE();
actionType = stream->readSint32LE();
_field_934 = stream->readSint32LE();
@@ -251,7 +254,7 @@ void Actor::draw() {
// Compute frame index
int32 frameIndex = _frameIndex;
if (_frameIndex >= _frameCount)
- frameIndex = 2 * _frameCount - _frameIndex - 1;
+ frameIndex = 2 * _frameCount - (_frameIndex + 1);
if (LOBYTE(flags) & kActorFlagMasked) {
Object *object = getWorld()->objects[_objectIndex];
@@ -536,7 +539,7 @@ void Actor::updateStatus(ActorStatus actorStatus) {
case kActorStatus1:
case kActorStatus12:
if ((getWorld()->chapter == kChapter2
- && _index == getScene()->getPlayerActorIndex() && (_status == kActorStatus18 || _status == kActorStatus16 || kActorStatus17))
+ && _index == getScene()->getPlayerActorIndex() && (_status == kActorStatus18 || _status == kActorStatus16 || _status == kActorStatus17))
|| (_status != kActorStatusEnabled && _status != kActorStatus9 && _status != kActorStatus14 && _status != kActorStatus15 && _status != kActorStatus18))
return;
@@ -705,7 +708,6 @@ void Actor::faceTarget(ObjectId id, DirectionFrom from) {
switch (from) {
default:
error("[Actor::faceTarget] Invalid direction input: %d (should be 0-3)", from);
- return;
case kDirectionFromObject: {
Object *object = getWorld()->getObjectById(id);
@@ -748,11 +750,11 @@ void Actor::faceTarget(ObjectId id, DirectionFrom from) {
updateFromDirection(getDirection(x2 + x1, y2 + y1, newX, newY));
}
-void Actor::setPosition(int32 newX, int32 newY, ActorDirection newDirection, int32 frame) {
+void Actor::setPosition(int32 newX, int32 newY, ActorDirection newDirection, uint32 frame) {
x1 = newX - x2;
y1 = newY - y2;
- if (_direction != 8)
+ if (_direction != kDirection8)
updateFromDirection(newDirection);
if (frame > 0)
@@ -809,11 +811,11 @@ void Actor::setRawResources(uint8 *data) {
// Unknown methods
//////////////////////////////////////////////////////////////////////////
-bool Actor::isResourcePresent() {
+bool Actor::isResourcePresent() const {
if (_status != kActorStatus9)
return false;
- int index = 10;
+ int index;
for (index = 10; index < 20; index++) {
if (_graphicResourceIds[index] == _resourceId)
break;
@@ -864,44 +866,44 @@ void Actor::update_40DE20() {
//////////////////////////////////////////////////////////////////////////
// Static update methods
//////////////////////////////////////////////////////////////////////////
-void Actor::enableActorsChapter2(AsylumEngine *_vm) {
- _vm->clearGameFlag(kGameFlag438);
- _vm->clearGameFlag(kGameFlag439);
- _vm->clearGameFlag(kGameFlag440);
- _vm->clearGameFlag(kGameFlag441);
- _vm->clearGameFlag(kGameFlag442);
+void Actor::enableActorsChapter2(AsylumEngine *engine) {
+ engine->clearGameFlag(kGameFlag438);
+ engine->clearGameFlag(kGameFlag439);
+ engine->clearGameFlag(kGameFlag440);
+ engine->clearGameFlag(kGameFlag441);
+ engine->clearGameFlag(kGameFlag442);
// Update shared data
for (int i = 0; i < 9; i++) {
// TODO find out which data is updated
}
- getScene()->getActor(13)->updateStatus(kActorStatusEnabled);
- getScene()->getActor(13)->processStatus(2300, 71, false);
+ engine->scene()->getActor(13)->updateStatus(kActorStatusEnabled);
+ engine->scene()->getActor(13)->processStatus(2300, 71, false);
- getScene()->getActor(14)->updateStatus(kActorStatusEnabled);
- getScene()->getActor(14)->processStatus(2600, 1300, false);
+ engine->scene()->getActor(14)->updateStatus(kActorStatusEnabled);
+ engine->scene()->getActor(14)->processStatus(2600, 1300, false);
- getScene()->getActor(15)->updateStatus(kActorStatusEnabled);
- getScene()->getActor(15)->processStatus(2742, 615, false);
+ engine->scene()->getActor(15)->updateStatus(kActorStatusEnabled);
+ engine->scene()->getActor(15)->processStatus(2742, 615, false);
- getScene()->getActor(16)->updateStatus(kActorStatusEnabled);
- getScene()->getActor(16)->processStatus(2700, 1200, false);
+ engine->scene()->getActor(16)->updateStatus(kActorStatusEnabled);
+ engine->scene()->getActor(16)->processStatus(2700, 1200, false);
- getScene()->getActor(17)->updateStatus(kActorStatusEnabled);
- getScene()->getActor(17)->processStatus(2751, 347, false);
+ engine->scene()->getActor(17)->updateStatus(kActorStatusEnabled);
+ engine->scene()->getActor(17)->processStatus(2751, 347, false);
- getScene()->getActor(18)->updateStatus(kActorStatusEnabled);
- getScene()->getActor(18)->processStatus(2420, 284, false);
+ engine->scene()->getActor(18)->updateStatus(kActorStatusEnabled);
+ engine->scene()->getActor(18)->processStatus(2420, 284, false);
- getScene()->getActor(19)->updateStatus(kActorStatusEnabled);
- getScene()->getActor(19)->processStatus(2800, 370, false);
+ engine->scene()->getActor(19)->updateStatus(kActorStatusEnabled);
+ engine->scene()->getActor(19)->processStatus(2800, 370, false);
- getScene()->getActor(20)->updateStatus(kActorStatusEnabled);
- getScene()->getActor(20)->processStatus(1973, 1, false);
+ engine->scene()->getActor(20)->updateStatus(kActorStatusEnabled);
+ engine->scene()->getActor(20)->processStatus(1973, 1, false);
- getScene()->getActor(21)->updateStatus(kActorStatusEnabled);
- getScene()->getActor(21)->processStatus(2541, 40, false);
+ engine->scene()->getActor(21)->updateStatus(kActorStatusEnabled);
+ engine->scene()->getActor(21)->processStatus(2541, 40, false);
error("[Actor::enableActorsChapter2] Missing update shared data part!");
}
@@ -1071,7 +1073,7 @@ void Actor::updateFinish() {
if (_field_944 == 4 || !isVisible())
return;
- int32 areaIndex = getScene()->findActionArea(Common::Point(x2 + x1, y2 + y1));
+ int32 areaIndex = getScene()->findActionArea(Common::Point((int16)(x2 + x1), (int16)(y2 + y1)));
if (areaIndex == _actionIdx3 || areaIndex == -1)
return;
@@ -1112,7 +1114,7 @@ void Actor::setVolume() {
// Helper methods
//////////////////////////////////////////////////////////////////////////
-ActorDirection Actor::getDirection(int32 ax1, int32 ay1, int32 ax2, int32 ay2) {
+ActorDirection Actor::getDirection(int32 ax1, int32 ay1, int32 ax2, int32 ay2) const {
int32 v5 = (ax2 << 16) - (ax1 << 16);
int32 v6 = 0;
int32 v4 = (ay1 << 16) - (ay2 << 16);
@@ -1144,6 +1146,9 @@ ActorDirection Actor::getDirection(int32 ax1, int32 ay1, int32 ax2, int32 ay2) {
}
switch (v6) {
+ default:
+ break;
+
case 1:
v8 = 360 - v8;
break;
@@ -1203,7 +1208,7 @@ void Actor::updateGraphicData(uint32 offset) {
_frameIndex = 0;
}
-bool Actor::isDefaultDirection(int index) {
+bool Actor::isDefaultDirection(int index) const {
return _graphicResourceIds[index] != _graphicResourceIds[5];
}
@@ -1219,30 +1224,32 @@ int32 Actor::getGraphicsFlags() {
return ((_direction < 5) - 1) & 2;
}
-int32 Actor::getFieldValue() {
- int32 index = (_frameIndex >= _frameCount) ? (2 * _frameCount) - _frameIndex + 1 : _frameIndex;
+int32 Actor::getFieldValue() const {
+ int32 index = (_frameIndex >= _frameCount) ? (2 * _frameCount) - (_frameIndex + 1): _frameIndex;
+
+ if (index >= 20)
+ error("[Actor::getFieldValue] Invalid index calculation (was: %d, max: 20)", index);
switch (_direction) {
default:
- case 0:
- case 4:
+ case kDirection0:
+ case kDirection4:
return 0;
- case 1:
- case 3:
+ case kDirection1:
+ case kDirection3:
return -_field_8D0[index];
- case 2:
+ case kDirection2:
return -_field_830[index];
- case 5:
- case 7:
+ case kDirection5:
+ case kDirection7:
return _field_8D0[index];
- case 6:
- return _field_830[index];;
+ case kDirection6:
+ return _field_830[index];
}
-
}
} // end of namespace Asylum
diff --git a/engines/asylum/resources/actor.h b/engines/asylum/resources/actor.h
index f21a5b5529..a035b0c8ab 100644
--- a/engines/asylum/resources/actor.h
+++ b/engines/asylum/resources/actor.h
@@ -181,7 +181,7 @@ public:
* @param newDirection The new direction.
* @param frame The frame.
*/
- void setPosition(int32 newX, int32 newY, ActorDirection newDirection, int32 frame);
+ void setPosition(int32 newX, int32 newY, ActorDirection newDirection, uint32 frame);
/////////////////////////////////////////////////////////////////////////
// Misc
@@ -230,7 +230,7 @@ public:
*
* @return true if resource present between 15 & 20, false if not.
*/
- bool isResourcePresent();
+ bool isResourcePresent() const;
//////////////////////////////////////////////////////////////////////////
// Static update methods
@@ -283,7 +283,7 @@ private:
int32 _field_8D0[20];
int32 _actionIdx2;
int32 _field_924;
- int32 _lastScreenUpdate;
+ uint32 _lastScreenUpdate;
int32 _field_92C;
//actionType
int32 _field_934;
@@ -373,7 +373,7 @@ private:
*
* @return The angle.
*/
- ActorDirection getDirection(int32 ax1, int32 ay1, int32 ax2, int32 ay2);
+ ActorDirection getDirection(int32 ax1, int32 ay1, int32 ax2, int32 ay2) const;
/**
* Updates the actor graphic information
@@ -389,7 +389,7 @@ private:
*
* @return true if default direction, false if not.
*/
- bool isDefaultDirection(int index);
+ bool isDefaultDirection(int index) const;
/**
* Gets the graphics flags for queuing the actor graphics
@@ -398,7 +398,7 @@ private:
*/
int32 getGraphicsFlags();
- int32 getFieldValue();
+ int32 getFieldValue() const;
}; // end of class MainActor
diff --git a/engines/asylum/resources/object.cpp b/engines/asylum/resources/object.cpp
index 86777576e9..aabb4cbe66 100644
--- a/engines/asylum/resources/object.cpp
+++ b/engines/asylum/resources/object.cpp
@@ -131,7 +131,7 @@ void Object::disableAndRemoveFromQueue() {
// Visibility
//////////////////////////////////////////////////////////////////////////
bool Object::isOnScreen() {
- Common::Rect screenRect = Common::Rect(getWorld()->xLeft, getWorld()->yTop, getWorld()->xLeft + 640, getWorld()->yTop + 480);
+ Common::Rect screenRect = Common::Rect(getWorld()->xLeft, getWorld()->yTop, getWorld()->xLeft + 640, getWorld()->yTop + 480);
Common::Rect objectRect = Common::Rect(_boundingRect);
objectRect.translate(x, y);
@@ -203,7 +203,7 @@ void Object::update() {
// Examine flags
if (flags & kObjectFlag20) {
- if (_vm->getTick() - _tickCount >= Common::Rational(1000, _field_B4).toInt()) {
+ if (_vm->getTick() - _tickCount >= (uint32)Common::Rational(1000, _field_B4).toInt()) {
_frameIndex =((_frameIndex + 1) % _frameCount);
_tickCount = _vm->getTick();
doPlaySounds = true;
@@ -229,7 +229,7 @@ void Object::update() {
}
if (!isFirstFrame) {
- if (_vm->getTick() - _tickCount >= Common::Rational(1000, _field_B4).toInt()) {
+ if (_vm->getTick() - _tickCount >= (uint32)Common::Rational(1000, _field_B4).toInt()) {
_frameIndex =((_frameIndex + 1) % _frameCount);
_tickCount = _vm->getTick();
doPlaySounds = true;
@@ -245,7 +245,7 @@ void Object::update() {
}
} else if (flags & kObjectFlag8) {
- if (_vm->getTick() - _tickCount >= Common::Rational(1000, _field_B4).toInt()) {
+ if (_vm->getTick() - _tickCount >= (uint32)Common::Rational(1000, _field_B4).toInt()) {
++_frameIndex;
@@ -267,7 +267,7 @@ void Object::update() {
}
} else if (!(BYTE1(flags) & kObjectFlag6)) {
- if ((flags & kObjectFlag10000) && (_vm->getTick() - _tickCount >= Common::Rational(1000, _field_B4).toInt())) {
+ if ((flags & kObjectFlag10000) && (_vm->getTick() - _tickCount >= (uint32)Common::Rational(1000, _field_B4).toInt())) {
++_frameIndex;
@@ -286,7 +286,7 @@ void Object::update() {
_tickCount = _vm->getTick();
doPlaySounds = true;
}
- } else if (_vm->getTick() - _tickCount >= Common::Rational(1000, _field_B4).toInt()) {
+ } else if (_vm->getTick() - _tickCount >= (uint32)Common::Rational(1000, _field_B4).toInt()) {
if (BYTE1(flags) & kObjectFlag2) {
if (_frameIndex == _frameCount - 1) {
_frameIndex--;
diff --git a/engines/asylum/resources/object.h b/engines/asylum/resources/object.h
index 8ca9465a42..bda2ae0c1e 100644
--- a/engines/asylum/resources/object.h
+++ b/engines/asylum/resources/object.h
@@ -178,8 +178,8 @@ private:
// actionType
GameFlag _gameFlags[10];
int32 _field_B4;
- int32 _tickCount;
- int32 _tickCount2;
+ uint32 _tickCount;
+ uint32 _tickCount2;
int32 _field_C0;
int32 _priority;
int32 _actionListIdx;
diff --git a/engines/asylum/resources/polygons.cpp b/engines/asylum/resources/polygons.cpp
index 7dbbb75aed..7ec9f01200 100644
--- a/engines/asylum/resources/polygons.cpp
+++ b/engines/asylum/resources/polygons.cpp
@@ -27,33 +27,28 @@
namespace Asylum {
-Polygons::Polygons(Common::SeekableReadStream *stream) {
+Polygons::Polygons(Common::SeekableReadStream *stream) : size(0), numEntries(0) {
load(stream);
}
Polygons::~Polygons() {
- for (int32 i = 0; i < numEntries; i++)
- delete[] entries[i].points;
-
entries.clear();
}
bool PolyDefinitions::contains(int16 x, int16 y) {
// Copied from backends/vkeybd/polygon.cpp
- int32 yflag0;
- int32 yflag1;
+ bool yflag0;
+ bool yflag1;
bool inside_flag = false;
- int32 pt;
- Common::Point *vtx0 = &points[numPoints - 1];
+ Common::Point *vtx0 = &points[count() - 1];
Common::Point *vtx1 = &points[0];
yflag0 = (vtx0->y >= y);
- for (pt = 0; pt < numPoints; pt++, vtx1++) {
+ for (uint32 pt = 0; pt < count(); pt++, vtx1++) {
yflag1 = (vtx1->y >= y);
if (yflag0 != yflag1) {
- if (((vtx1->y - y) * (vtx0->x - vtx1->x) >=
- (vtx1->x - x) * (vtx0->y - vtx1->y)) == yflag1) {
+ if (((vtx1->y - y) * (vtx0->x - vtx1->x) >= (vtx1->x - x) * (vtx0->y - vtx1->y)) == yflag1) {
inside_flag = !inside_flag;
}
}
@@ -70,23 +65,23 @@ void Polygons::load(Common::SeekableReadStream *stream) {
for (int32 g = 0; g < numEntries; g++) {
PolyDefinitions poly;
- memset(&poly, 0, sizeof(PolyDefinitions));
- poly.numPoints = stream->readSint32LE();
- if (poly.numPoints > 0)
- poly.points = new Common::Point[poly.numPoints];
+ uint32 numPoints = stream->readUint32LE();
+
+ for (uint32 i = 0; i < numPoints; i++) {
+ Common::Point point;
+ point.x = (int16)(stream->readSint32LE() & 0xFFFF);
+ point.y = (int16)(stream->readSint32LE() & 0xFFFF);
- for (int32 i = 0; i < poly.numPoints; i++) {
- poly.points[i].x = stream->readSint32LE() & 0xFFFF;
- poly.points[i].y = stream->readSint32LE() & 0xFFFF;
+ poly.points.push_back(point);
}
- stream->skip((MAX_POLYGONS - poly.numPoints) * 8);
+ stream->skip((MAX_POLYGONS - numPoints) * 8);
- poly.boundingRect.left = stream->readSint32LE() & 0xFFFF;
- poly.boundingRect.top = stream->readSint32LE() & 0xFFFF;
- poly.boundingRect.right = stream->readSint32LE() & 0xFFFF;
- poly.boundingRect.bottom = stream->readSint32LE() & 0xFFFF;
+ poly.boundingRect.left = (int16)(stream->readSint32LE() & 0xFFFF);
+ poly.boundingRect.top = (int16)(stream->readSint32LE() & 0xFFFF);
+ poly.boundingRect.right = (int16)(stream->readSint32LE() & 0xFFFF);
+ poly.boundingRect.bottom = (int16)(stream->readSint32LE() & 0xFFFF);
entries.push_back(poly);
}
diff --git a/engines/asylum/resources/polygons.h b/engines/asylum/resources/polygons.h
index 9a93d4e299..f3e701222e 100644
--- a/engines/asylum/resources/polygons.h
+++ b/engines/asylum/resources/polygons.h
@@ -35,8 +35,7 @@
namespace Asylum {
typedef struct PolyDefinitions {
- int32 numPoints;
- Common::Point *points;
+ Common::Array<Common::Point> points;
Common::Rect boundingRect;
/**
@@ -51,6 +50,10 @@ typedef struct PolyDefinitions {
return contains(point.x, point.y);
}
+ uint32 count() {
+ return points.size();
+ }
+
} PolyDefinitions;
class Polygons {
@@ -59,7 +62,7 @@ public:
virtual ~Polygons();
int32 size;
- int32 numEntries;
+ int32 numEntries; // TODO remove and use entries.size()
Common::Array<PolyDefinitions> entries;
diff --git a/engines/asylum/resources/reaction.cpp b/engines/asylum/resources/reaction.cpp
index 7145524351..ac8cab83c8 100644
--- a/engines/asylum/resources/reaction.cpp
+++ b/engines/asylum/resources/reaction.cpp
@@ -41,6 +41,8 @@ namespace Asylum {
Reaction::Reaction(AsylumEngine *engine) : _vm(engine) {}
Reaction::~Reaction() {
+ // Zero-out passed pointers
+ _vm = NULL;
}
void Reaction::run(int32 reactionIndex) {
@@ -469,7 +471,7 @@ void Reaction::chapter11(int32 reactionIndex) {
}
}
-void Reaction::chapter12(int32 reactionIndex) {
+void Reaction::chapter12(int32) {
play(0);
}
diff --git a/engines/asylum/resources/special.cpp b/engines/asylum/resources/special.cpp
index cdce48cb23..ded32d4e2d 100644
--- a/engines/asylum/resources/special.cpp
+++ b/engines/asylum/resources/special.cpp
@@ -53,7 +53,10 @@ Special::Special(AsylumEngine *engine) : _vm(engine) {
_paletteTick2 = 0;
}
-Special::~Special() {}
+Special::~Special() {
+ // Zero-out passed pointers
+ _vm = NULL;
+}
void Special::run(Object* object, ActorIndex index) {
@@ -161,6 +164,7 @@ void Special::chapter2(Object *object, ActorIndex actorIndex) {
case kObjectCrow2AmbientPecks:
checkObject(object, kGameFlag450, kGameFlag451);
+ break;
case kObjectCrow2FlysAway:
if (rnd(50) < 3)
@@ -238,7 +242,7 @@ void Special::chapter2(Object *object, ActorIndex actorIndex) {
Object *obj386 = getWorld()->objects[386];
actor->x1 = obj386->getSoundY();
- actor->y1 = obj386->getField688() + getWorld()->coordinates[22 - actorIndex];
+ actor->y1 = obj386->getField688() + getWorld()->coordinates[actorIndex - 22]; // FIXME out of bound access for actorIndex == 29
actor->setFrameIndex(obj386->getField67C());
actor->setDirection(obj386->getField6A4());
@@ -1278,8 +1282,8 @@ void Special::playSoundPanning(ResourceId resourceId, int32 attenuation, Object
default: {
Common::Rect frameRect = GraphicResource::getFrameRect(_vm, object->getResourceId(), object->getFrameIndex());
- x = (frameRect.width() >> 1) + object->x;
- y = (frameRect.height() >> 1) + object->y;
+ x = Common::Rational(frameRect.width(), 2).toInt() + object->x;
+ y = Common::Rational(frameRect.height(), 2).toInt() + object->y;
}
break;
@@ -1340,7 +1344,7 @@ void Special::updateObjectFlag(ObjectId id) {
getWorld()->getObjectById(id)->flags &= ~kObjectFlag10E38;
}
-void Special::checkFlags(ObjectId id, GameFlag flag1, GameFlag flag2, GameFlag flag3, GameFlag flag4, int *val1, int *val2, GameFlag flag5, int *val3) {
+void Special::checkFlags(ObjectId id, GameFlag flag1, GameFlag flag2, GameFlag flag3, GameFlag flag4, uint32 *val1, uint32 *val2, GameFlag flag5, uint32 *val3) {
if (_vm->isGameFlagSet(flag5)
&& _vm->isGameFlagNotSet(flag2)
&& _vm->isGameFlagNotSet(flag1)) {
@@ -1375,7 +1379,7 @@ void Special::checkFlags(ObjectId id, GameFlag flag1, GameFlag flag2, GameFlag f
getWorld()->getObjectById(id)->setField67C(0);
} else {
- *val2++;
+ (*val2)++;
getWorld()->getObjectById(id)->setField67C(6 - Common::Rational(*val2, 4).toInt());
}
@@ -1395,7 +1399,7 @@ void Special::checkFlags(ObjectId id, GameFlag flag1, GameFlag flag2, GameFlag f
getWorld()->getObjectById(id)->setField67C(0);
} else {
- *val2++;
+ (*val2)++;
getWorld()->getObjectById(id)->setField67C(Common::Rational(*val2, 4).toInt() + 4);
}
diff --git a/engines/asylum/resources/special.h b/engines/asylum/resources/special.h
index a29eb90e0e..eac9e6427d 100644
--- a/engines/asylum/resources/special.h
+++ b/engines/asylum/resources/special.h
@@ -51,8 +51,8 @@ private:
int32 _chapter5Counter;
bool _paletteFlag;
- int32 _paletteTick1;
- int32 _paletteTick2;
+ uint32 _paletteTick1;
+ uint32 _paletteTick2;
//////////////////////////////////////////////////////////////////////////
// Spec functions
@@ -88,7 +88,7 @@ private:
void playSoundPanning(ResourceId resourceId, int32 attenuation, ActorIndex actorIndex);
void updateObjectFlag(ObjectId id);
- void checkFlags(ObjectId id, GameFlag flag1, GameFlag flag2, GameFlag flag3, GameFlag flag4, int *val1, int *val2, GameFlag flag5, int *val3);
+ void checkFlags(ObjectId id, GameFlag flag1, GameFlag flag2, GameFlag flag3, GameFlag flag4, uint32 *val1, uint32*val2, GameFlag flag5, uint32 *val3);
//////////////////////////////////////////////////////////////////////////
// Helpers
diff --git a/engines/asylum/resources/worldstats.h b/engines/asylum/resources/worldstats.h
index eb8e955c2d..dbad487ab8 100644
--- a/engines/asylum/resources/worldstats.h
+++ b/engines/asylum/resources/worldstats.h
@@ -118,11 +118,11 @@ public:
Common::Array<ActionArea*> actions; // maxsize 400
// TODO add rest fields
int32 field_E860C;
- int32 field_E8610[6];
- int32 field_E8628[6];
+ uint32 field_E8610[6];
+ uint32 field_E8628[6];
Object *wheels[7];
int32 tickCount1;
- int32 field_E8660[6];
+ uint32 field_E8660[6];
void setWheelObjects();
diff --git a/engines/asylum/shared.h b/engines/asylum/shared.h
index f5cadfb0a0..34189af094 100644
--- a/engines/asylum/shared.h
+++ b/engines/asylum/shared.h
@@ -163,7 +163,7 @@ enum ResourcePackId {
kResourcePack304 = 304
};
-#define MAKE_RESOURCE(pack, index) (ResourceId)((0x80000000 + ((pack) << 16)) + (index))
+#define MAKE_RESOURCE(pack, index) (ResourceId)((0x80000000 + ((pack) << 16)) + (uint32)(index))
enum ResourceId {
kResourceNone = 0
diff --git a/engines/asylum/system/graphics.cpp b/engines/asylum/system/graphics.cpp
index 1a4a1278ae..f82cdb16c2 100644
--- a/engines/asylum/system/graphics.cpp
+++ b/engines/asylum/system/graphics.cpp
@@ -32,7 +32,7 @@
namespace Asylum {
-GraphicResource::GraphicResource(AsylumEngine *engine, ResourceId id) : _vm(engine) {
+GraphicResource::GraphicResource(AsylumEngine *engine, ResourceId id) : _vm(engine), _resourceId(kResourceNone), _flags(0), _flags2(0) {
load(id);
}
@@ -69,10 +69,6 @@ GraphicFrame *GraphicResource::getFrame(uint32 frame) {
void GraphicResource::init(byte *data, int32 size) {
byte *dataPtr = data;
- int32 contentOffset = 0;
- uint16 frameCount = 0;
-
- int32 i = 0;
dataPtr += 4; // tag value
@@ -80,14 +76,14 @@ void GraphicResource::init(byte *data, int32 size) {
dataPtr += 4;
//_flags2 = (int32)READ_LE_UINT32(dataPtr);
- contentOffset = (int32)READ_LE_UINT32(dataPtr);
+ int32 contentOffset = (int32)READ_LE_UINT32(dataPtr);
dataPtr += 4;
dataPtr += 4; // unknown
dataPtr += 4; // unknown
dataPtr += 4; // unknown
- frameCount = READ_LE_UINT16(dataPtr);
+ uint16 frameCount = READ_LE_UINT16(dataPtr);
dataPtr += 2;
dataPtr += 2; // max width
@@ -99,7 +95,7 @@ void GraphicResource::init(byte *data, int32 size) {
dataPtr += 4;
int32 nextOffset = 0;
- for (i = 0; i < frameCount; i++) {
+ for (int32 i = 0; i < frameCount; i++) {
GraphicFrame frame;
frame.offset = prevOffset;
@@ -117,7 +113,7 @@ void GraphicResource::init(byte *data, int32 size) {
dataPtr = data;
// Read frame data
- for (i = 0; i < frameCount; i++) {
+ for (uint32 i = 0; i < frameCount; i++) {
dataPtr = data + _frames[i].offset;
dataPtr += 4; // size
@@ -128,14 +124,14 @@ void GraphicResource::init(byte *data, int32 size) {
_frames[i].y = (int16)READ_LE_UINT16(dataPtr);
dataPtr += 2;
- int16 height = (int16)READ_LE_UINT16(dataPtr);
+ uint16 height = READ_LE_UINT16(dataPtr);
dataPtr += 2;
- int16 width = (int16)READ_LE_UINT16(dataPtr);
+ uint16 width = READ_LE_UINT16(dataPtr);
dataPtr += 2;
_frames[i].surface.create(width, height, 1);
- memcpy(_frames[i].surface.pixels, dataPtr, width * height);
+ memcpy(_frames[i].surface.pixels, dataPtr, (size_t)(width * height));
}
}
@@ -145,10 +141,10 @@ void GraphicResource::init(byte *data, int32 size) {
uint32 GraphicResource::getFrameCount(AsylumEngine *engine, ResourceId id) {
GraphicResource *resource = new GraphicResource(engine, id);
- uint32 count = resource->count();
+ uint32 frameCount = resource->count();
delete resource;
- return count;
+ return frameCount;
}
Common::Rect GraphicResource::getFrameRect(AsylumEngine *engine, ResourceId id, uint32 index) {
diff --git a/engines/asylum/system/graphics.h b/engines/asylum/system/graphics.h
index d50832b8da..22f75d4aa2 100644
--- a/engines/asylum/system/graphics.h
+++ b/engines/asylum/system/graphics.h
@@ -86,9 +86,10 @@ private:
AsylumEngine *_vm;
Common::Array <GraphicFrame> _frames;
+
+ ResourceId _resourceId;
int32 _flags;
int32 _flags2;
- ResourceId _resourceId;
void init(byte *data, int32 size);
void clear();
diff --git a/engines/asylum/system/speech.cpp b/engines/asylum/system/speech.cpp
index 02180fa8e8..18379144b7 100644
--- a/engines/asylum/system/speech.cpp
+++ b/engines/asylum/system/speech.cpp
@@ -44,6 +44,8 @@ Speech::Speech(AsylumEngine *engine): _vm(engine) {
}
Speech::~Speech() {
+ // Zero-out passed pointers
+ _vm = NULL;
}
ResourceId Speech::play(ResourceId soundResourceId, ResourceId textResourceId) {
@@ -63,7 +65,7 @@ ResourceId Speech::playIndexed(int32 index) {
int processedIndex = 0;
if (getWorld()->actorType || index != -1) {
-
+ error("[Speech::playIndexed] Missing case using static data!");
} else {
switch(_vm->getRandom(3)) {
default:
@@ -93,16 +95,16 @@ ResourceId Speech::playIndexed(int32 index) {
break;
case kActorMax:
- return play(MAKE_RESOURCE(kResourcePackSpeech, index), MAKE_RESOURCE(kResourcePackText, index + 83));
+ return play(MAKE_RESOURCE(kResourcePackSpeech, processedIndex), MAKE_RESOURCE(kResourcePackText, processedIndex + 83));
case kActorSarah:
- return play(MAKE_RESOURCE(kResourcePackSharedSound, index + 1927), MAKE_RESOURCE(kResourcePackText, index + 586));
+ return play(MAKE_RESOURCE(kResourcePackSharedSound, processedIndex + 1927), MAKE_RESOURCE(kResourcePackText, processedIndex + 586));
case kActorCyclops:
- return play(MAKE_RESOURCE(kResourcePackSharedSound, index + 2084), MAKE_RESOURCE(kResourcePackText, index + 743));
+ return play(MAKE_RESOURCE(kResourcePackSharedSound, processedIndex + 2084), MAKE_RESOURCE(kResourcePackText, processedIndex + 743));
case kActorAztec:
- return play(MAKE_RESOURCE(kResourcePackSharedSound, index + 2234), MAKE_RESOURCE(kResourcePackText, index + 893));
+ return play(MAKE_RESOURCE(kResourcePackSharedSound, processedIndex + 2234), MAKE_RESOURCE(kResourcePackText, processedIndex + 893));
}
return kResourceNone;
@@ -196,7 +198,6 @@ ResourceId Speech::playPlayer(int32 index) {
return play(soundResourceId, MAKE_RESOURCE(kResourcePackText, textResourceIndex + 83));
}
- break;
case kActorSarah:
return play(MAKE_RESOURCE(kResourcePackSharedSound, index + 1927), MAKE_RESOURCE(kResourcePackText, index + 586));
diff --git a/engines/asylum/system/text.cpp b/engines/asylum/system/text.cpp
index 022a24cd19..cabb08e069 100644
--- a/engines/asylum/system/text.cpp
+++ b/engines/asylum/system/text.cpp
@@ -44,6 +44,9 @@ Text::Text(AsylumEngine *engine) : _vm(engine) {
Text::~Text() {
delete _fontResource;
+
+ // Zero-out passed pointers
+ _vm = NULL;
}
void Text::loadFont(ResourceId resourceId) {
@@ -54,7 +57,7 @@ void Text::loadFont(ResourceId resourceId) {
_fontResource = new GraphicResource(_vm, resourceId);
- if (resourceId > 0) {
+ if (resourceId != kResourceNone) {
// load font flag data
_curFontFlags = (_fontResource->getFlags() >> 4) & 0x0F;
}
diff --git a/engines/asylum/views/blowuppuzzle.cpp b/engines/asylum/views/blowuppuzzle.cpp
index 084516f732..cd78f6b42a 100644
--- a/engines/asylum/views/blowuppuzzle.cpp
+++ b/engines/asylum/views/blowuppuzzle.cpp
@@ -46,6 +46,7 @@ BlowUpPuzzle::BlowUpPuzzle(AsylumEngine *engine): _vm(engine) {
BlowUpPuzzle::~BlowUpPuzzle() {
+
}
// BlowUp Puzzle VCR ---------------------------------------------------------------------------------------------
@@ -233,6 +234,7 @@ void BlowUpPuzzleVCR::updateJack(Jack jack, VCRDrawInfo onTable, VCRDrawInfo plu
item.y = onTable.y;
item.priority = 3;
break;
+
case kPluggedOnRed:
item.resourceId = getWorld()->graphicResourceIds[pluggedOnRed.resourceId];
item.frameIdx = 0;
@@ -240,6 +242,7 @@ void BlowUpPuzzleVCR::updateJack(Jack jack, VCRDrawInfo onTable, VCRDrawInfo plu
item.y = 407;
item.priority = 3;
break;
+
case kPluggedOnYellow:
item.resourceId = getWorld()->graphicResourceIds[pluggedOnYellow.resourceId];
item.frameIdx = 0;
@@ -247,6 +250,7 @@ void BlowUpPuzzleVCR::updateJack(Jack jack, VCRDrawInfo onTable, VCRDrawInfo plu
item.y = 413;
item.priority = 3;
break;
+
case kPluggedOnBlack:
item.resourceId = getWorld()->graphicResourceIds[pluggedOnBlack.resourceId];
item.frameIdx = 0;
@@ -254,13 +258,15 @@ void BlowUpPuzzleVCR::updateJack(Jack jack, VCRDrawInfo onTable, VCRDrawInfo plu
item.y = 418;
item.priority = 3;
break;
+
case kOnHand: {
GraphicQueueItem jackItemOnHand = getGraphicJackItem(resourceOnHandIndex);
getScreen()->addGraphicToQueue(jackItemOnHand);
item = getGraphicShadowItem();
- }
- break;
+ }
+ break;
+
default:
item.resourceId = kResourceNone;
break;
@@ -450,9 +456,9 @@ void BlowUpPuzzleVCR::updateCursorInPolyRegion() {
|| inPolyRegion(_cursor->position().x, _cursor->position().y, kYellowJack)) {
_cursor->animate();
} else {
- if ((inPolyRegion(_cursor->position().x, _cursor->position().y, kRedHole) && _holesState[kPluggedOnRed-1])
- || (inPolyRegion(_cursor->position().x, _cursor->position().y, kYellowHole) && _holesState[kPluggedOnYellow-1])
- || (inPolyRegion(_cursor->position().x, _cursor->position().y, kBlackHole) && _holesState[kPluggedOnBlack-1])) {
+ if ((inPolyRegion(_cursor->position().x, _cursor->position().y, kRedHole) && _holesState[kOnTable])
+ || (inPolyRegion(_cursor->position().x, _cursor->position().y, kYellowHole) && _holesState[kPluggedOnRed])
+ || (inPolyRegion(_cursor->position().x, _cursor->position().y, kBlackHole) && _holesState[kPluggedOnYellow])) {
if (_cursor->currentFrame != 2) { // reset cursor
_cursor->show();
_cursor->set(MAKE_RESOURCE(kResourcePackShared, 2), 0, 2);
diff --git a/engines/asylum/views/menu.cpp b/engines/asylum/views/menu.cpp
index fd64bdfd1f..f008fe01ff 100644
--- a/engines/asylum/views/menu.cpp
+++ b/engines/asylum/views/menu.cpp
@@ -59,6 +59,8 @@ MainMenu::MainMenu(AsylumEngine *vm): _vm(vm) {
_bgResource = new GraphicResource(_vm, MAKE_RESOURCE(kResourcePackShared, 0));
_eyeResource = new GraphicResource(_vm, MAKE_RESOURCE(kResourcePackShared, 1));
+ _ev = NULL;
+
_cursor = new Cursor(_vm);
_iconResource = 0;
@@ -75,6 +77,10 @@ MainMenu::~MainMenu() {
delete _eyeResource;
delete _cursor;
delete _bgResource;
+
+ // Zero-out passed pointers
+ _ev = NULL;
+ _vm = NULL;
}
void MainMenu::loadFont(Fonts font) {
@@ -244,7 +250,7 @@ void MainMenu::update() {
void MainMenu::updateEyesAnimation() {
// Eyes animation
// Get the appropriate eye resource depending on the mouse position
- int32 eyeFrameNum = kEyesFront;
+ uint32 eyeFrameNum = kEyesFront;
if (_cursor->position().x <= 200) {
if (_cursor->position().y <= 160)
diff --git a/engines/asylum/views/menu.h b/engines/asylum/views/menu.h
index 9bea1071ed..eb361af88e 100644
--- a/engines/asylum/views/menu.h
+++ b/engines/asylum/views/menu.h
@@ -103,7 +103,6 @@ private:
bool _active;
MenuScreen _activeMenuScreen;
- ResourcePack *_resPack;
GraphicResource *_bgResource;
GraphicResource *_eyeResource;
GraphicResource *_iconResource;
diff --git a/engines/asylum/views/scene.cpp b/engines/asylum/views/scene.cpp
index 9e8f4cf68c..73159cd7e9 100644
--- a/engines/asylum/views/scene.cpp
+++ b/engines/asylum/views/scene.cpp
@@ -1213,7 +1213,7 @@ void Scene::processUpdateList() {
} else {
if (object->flags & kObjectFlag40) {
PolyDefinitions *poly = &_polygons->entries[object->getPolygonIndex()];
- if (point.x > 0 && point.y > 0 && poly->numPoints > 0)
+ if (point.x > 0 && point.y > 0 && poly->count() > 0)
intersects = poly->contains(point);
else
warning ("[drawActorsAndObjects] trying to find intersection of uninitialized point");
@@ -1404,12 +1404,12 @@ void Scene::debugShowWalkRegion(PolyDefinitions *poly) {
1);
// Draw all lines in Polygon
- for (int32 i = 0; i < poly->numPoints; i++) {
+ for (uint32 i = 0; i < poly->count(); i++) {
surface.drawLine(
poly->points[i].x - poly->boundingRect.left,
poly->points[i].y - poly->boundingRect.top,
- poly->points[(i+1) % poly->numPoints].x - poly->boundingRect.left,
- poly->points[(i+1) % poly->numPoints].y - poly->boundingRect.top, 0x3A);
+ poly->points[(i+1) % poly->count()].x - poly->boundingRect.left,
+ poly->points[(i+1) % poly->count()].y - poly->boundingRect.top, 0x3A);
}
copyToBackBufferClipped(&surface, poly->boundingRect.left, poly->boundingRect.top);
@@ -1427,12 +1427,12 @@ void Scene::debugShowPolygons() {
1);
// Draw all lines in Polygon
- for (int32 i = 0; i < poly.numPoints; i++) {
+ for (uint32 i = 0; i < poly.count(); i++) {
surface.drawLine(
poly.points[i].x - poly.boundingRect.left,
poly.points[i].y - poly.boundingRect.top,
- poly.points[(i+1) % poly.numPoints].x - poly.boundingRect.left,
- poly.points[(i+1) % poly.numPoints].y - poly.boundingRect.top, 0xFF);
+ poly.points[(i+1) % poly.count()].x - poly.boundingRect.left,
+ poly.points[(i+1) % poly.count()].y - poly.boundingRect.top, 0xFF);
}
copyToBackBufferClipped(&surface, poly.boundingRect.left, poly.boundingRect.top);
Commit: 8528b9d964e2cbac34501d1fa8d846bdc25015d5
https://github.com/scummvm/scummvm/commit/8528b9d964e2cbac34501d1fa8d846bdc25015d5
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:18+02:00
Commit Message:
ASYLUM: Cleanup Pass 2
- Add proper init code for WorldStats
- Add some missing deletes in destructors (in particular Scene)
- Add const modifiers & casts in several places
- Fix some off-by-one array accesses
- Add checks for NULL in several classes
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@546 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/asylum.cpp
engines/asylum/resources/actionlist.h
engines/asylum/resources/encounters.cpp
engines/asylum/resources/encounters.h
engines/asylum/resources/object.cpp
engines/asylum/resources/special.cpp
engines/asylum/resources/worldstats.cpp
engines/asylum/respack.cpp
engines/asylum/shared.h
engines/asylum/system/cursor.cpp
engines/asylum/system/cursor.h
engines/asylum/system/screen.cpp
engines/asylum/system/screen.h
engines/asylum/system/sound.cpp
engines/asylum/system/sound.h
engines/asylum/system/speech.cpp
engines/asylum/system/text.cpp
engines/asylum/system/text.h
engines/asylum/system/video.cpp
engines/asylum/system/video.h
engines/asylum/views/menu.cpp
engines/asylum/views/scene.cpp
engines/asylum/views/scenetitle.cpp
diff --git a/engines/asylum/asylum.cpp b/engines/asylum/asylum.cpp
index 71d7ed64de..49404fbd43 100644
--- a/engines/asylum/asylum.cpp
+++ b/engines/asylum/asylum.cpp
@@ -334,7 +334,7 @@ void AsylumEngine::processDelayedEvents() {
ResourcePackId packId = _scene->actions()->getDelayedSceneIndex();
// XXX Flag 183 indicates whether the actionlist is currently
// processing
- if (packId >= 0 && isGameFlagNotSet(kGameFlagScriptProcessing)) {
+ if (packId != kResourcePackInvalid && isGameFlagNotSet(kGameFlagScriptProcessing)) {
// Reset delayed scene
_scene->actions()->setDelayedSceneIndex(kResourcePackInvalid);
diff --git a/engines/asylum/resources/actionlist.h b/engines/asylum/resources/actionlist.h
index d526b77b58..58b94ad2e0 100644
--- a/engines/asylum/resources/actionlist.h
+++ b/engines/asylum/resources/actionlist.h
@@ -79,6 +79,8 @@ struct ActionArea {
int32 array[5];
int32 volume;
+ ActionArea() {}
+
Common::String toString() {
Common::String output;
diff --git a/engines/asylum/resources/encounters.cpp b/engines/asylum/resources/encounters.cpp
index b7386285b6..ac55d347e6 100644
--- a/engines/asylum/resources/encounters.cpp
+++ b/engines/asylum/resources/encounters.cpp
@@ -31,7 +31,7 @@
namespace Asylum {
-Encounter::Encounter(AsylumEngine *engine) : _vm(engine) {
+Encounter::Encounter(AsylumEngine *engine) : _vm(engine), _currentEncounter(NULL) {
memset(_flags, 0, sizeof(_flags));
Common::File file;
@@ -39,7 +39,7 @@ Encounter::Encounter(AsylumEngine *engine) : _vm(engine) {
// TODO error checks
file.open("sntrm.dat");
- int16 _count = file.readSint16LE();
+ uint16 _count = file.readUint16LE();
_variables = (int16*)malloc(_count);
file.read(_variables, _count);
@@ -69,18 +69,26 @@ Encounter::Encounter(AsylumEngine *engine) : _vm(engine) {
file.close();
}
+Encounter::~Encounter() {
+ free(_variables);
+ _currentEncounter = NULL;
+
+ // Zero-out passed pointers
+ _vm = NULL;
+}
+
//////////////////////////////////////////////////////////////////////////
// Flags
-int32 Encounter::getFlag(EncounterFlag flag) {
- if (flag > ARRAYSIZE(_flags))
+int32 Encounter::getFlag(EncounterFlag flag) const {
+ if (flag >= ARRAYSIZE(_flags))
error("[Encounter::getFlag] Invalid flag index!");
return _flags[flag];
}
void Encounter::setFlag(EncounterFlag flag, int32 val) {
- if (flag > ARRAYSIZE(_flags))
+ if (flag >= ARRAYSIZE(_flags))
error("[Encounter::getFlag] Invalid flag index!");
_flags[flag] = val;
@@ -145,8 +153,4 @@ void Encounter::run(int32 encounterIdx, int32 objectId1, int32 objectId2, int32
*/
}
-Encounter::~Encounter() {
- free(_variables);
-}
-
}
diff --git a/engines/asylum/resources/encounters.h b/engines/asylum/resources/encounters.h
index 64e4c7ee83..9a3d02eca7 100644
--- a/engines/asylum/resources/encounters.h
+++ b/engines/asylum/resources/encounters.h
@@ -68,7 +68,7 @@ public:
}
void run(int32 encounterIdx, int32 objectId1, int32 objectId2, int32 characterIdx);
- int32 getFlag(EncounterFlag flag);
+ int32 getFlag(EncounterFlag flag) const;
void setFlag(EncounterFlag flag, int32 val);
private:
diff --git a/engines/asylum/resources/object.cpp b/engines/asylum/resources/object.cpp
index aabb4cbe66..eb075491ad 100644
--- a/engines/asylum/resources/object.cpp
+++ b/engines/asylum/resources/object.cpp
@@ -42,6 +42,8 @@ Object::Object(AsylumEngine *engine) : _vm(engine) {
}
Object::~Object() {
+ // Zero passed pointers
+ _vm = NULL;
}
/////////////////////////////////////////////////////////////////////////
diff --git a/engines/asylum/resources/special.cpp b/engines/asylum/resources/special.cpp
index ded32d4e2d..4064124767 100644
--- a/engines/asylum/resources/special.cpp
+++ b/engines/asylum/resources/special.cpp
@@ -239,19 +239,22 @@ void Special::chapter2(Object *object, ActorIndex actorIndex) {
case 28:
case 29:
if (actor->isVisible()) {
- Object *obj386 = getWorld()->objects[386];
-
- actor->x1 = obj386->getSoundY();
- actor->y1 = obj386->getField688() + getWorld()->coordinates[actorIndex - 22]; // FIXME out of bound access for actorIndex == 29
- actor->setFrameIndex(obj386->getField67C());
- actor->setDirection(obj386->getField6A4());
-
- // Get the resource Id
- Actor *actor0 = getScene()->getActor(0);
- Actor *actor13 = getScene()->getActor(13);
- ResourceId id = actor0->getResourcesId(actor13->getDirection() > 4 ? 8 - actor13->getDirection() : actor13->getDirection());
-
- actor->setResourceId(id);
+ error("[Special::chapter2] Not implemented!");
+ // FIXME: This is wrong, the 386th object is used as an offset to the proper actor
+ //Object *obj386 = getWorld()->objects[386];
+
+ //actor->x1 = obj386->getSoundY();
+ //actor->y1 = obj386->getField688() + getWorld()->coordinates[actorIndex - 22]; // FIXME out of bound access for actorIndex == 29
+ //actor->setFrameIndex(obj386->getField67C());
+ //actor->setDirection(obj386->getField6A4());
+
+ //// Get the resource Id
+ //Actor *actor0 = getScene()->getActor(0);
+ //Actor *actor13 = getScene()->getActor(13);
+ //int32 index = (actor13->getDirection() > 4) ? 8 - actor13->getDirection() : actor13->getDirection();
+ //ResourceId id = actor0->getResourcesId((uint32)index);
+
+ //actor->setResourceId(id);
}
break;
diff --git a/engines/asylum/resources/worldstats.cpp b/engines/asylum/resources/worldstats.cpp
index fbca62272d..e2de9cfb8b 100644
--- a/engines/asylum/resources/worldstats.cpp
+++ b/engines/asylum/resources/worldstats.cpp
@@ -34,6 +34,68 @@
namespace Asylum {
WorldStats::WorldStats(Common::SeekableReadStream *stream, Scene *scene) : _scene(scene) {
+ // Init values
+ size = 0;
+ numEntries = 0;
+ chapter = kChapterNone;
+ xLeft = 0;
+ yTop = 0;
+ backgroundImage = kResourceNone;
+ curScrollUp = kResourceNone;
+ curScrollUpLeft = kResourceNone;
+ curScrollLeft = kResourceNone;
+ curScrollDownLeft = kResourceNone;
+ curScrollDown = kResourceNone;
+ curScrollDownRight = kResourceNone;
+ curScrollRight = kResourceNone;
+ curScrollUpRight = kResourceNone;
+ curHand = kResourceNone;
+ curMagnifyingGlass = kResourceNone;
+ curTalkNPC = kResourceNone;
+ curGrabPointer = kResourceNone;
+ curTalkNPC2 = kResourceNone;
+ font1 = kResourceNone;
+ font2 = kResourceNone;
+ font3 = kResourceNone;
+ currentPaletteId = kResourceNone;
+ cellShadeMask1 = 0;
+ cellShadeMask2 = 0;
+ cellShadeMask3 = 0;
+ unused = 0;
+ smallCurUp = 0;
+ smallCurDown = 0;
+ encounterFrameBg = 0;
+ width = 0;
+ height = 0;
+ motionStatus = 0;
+ field_8C = 0;
+ memset(&coordinates, 0, sizeof(coordinates));
+ stereoReversedFlag = 0;
+ sceneRectIdx = 0;
+ memset(&field_11D, 0, sizeof(field_11D));
+ field_120 = 0;
+ scriptIndex = 0;
+ memset(&graphicResourceIds, kResourceNone, sizeof(graphicResourceIds));
+ sceneTitleGraphicResourceId = kResourceNone;
+ sceneTitlePaletteResourceId = kResourceNone;
+ actorType = 0;
+ memset(&soundResourceIds, kResourceNone, sizeof(soundResourceIds));
+
+ numAmbientSound = 0;
+ musicStatus = 0;
+ musicCurrentResourceIndex = 0;
+ musicFlag = 0;
+ musicResourceId = kResourceNone;
+ musicStatusExt = 0;
+
+ field_E860C = 0;
+ memset(&field_E8610, 0, sizeof(field_E8610));
+ memset(&field_E8628, 0, sizeof(field_E8628));
+ memset(&wheels, 0, sizeof(wheels));
+ tickCount1 = 0;
+ memset(&field_E8660, 0, sizeof(field_E8660));
+
+ // Load data
load(stream);
}
@@ -41,6 +103,9 @@ WorldStats::~WorldStats() {
CLEAR_ARRAY(Object, objects);
CLEAR_ARRAY(Actor, actors);
CLEAR_ARRAY(ActionArea, actions);
+
+ // Zero-out passed pointers
+ _scene = NULL;
}
// FIXME: load necessary World Stats content
@@ -52,10 +117,10 @@ void WorldStats::load(Common::SeekableReadStream *stream) {
xLeft = stream->readSint32LE();
yTop = stream->readSint32LE();
- boundingRect.left = stream->readSint32LE() & 0xFFFF;
- boundingRect.top = stream->readSint32LE() & 0xFFFF;
- boundingRect.right = stream->readSint32LE() & 0xFFFF;
- boundingRect.bottom = stream->readSint32LE() & 0xFFFF;
+ boundingRect.left = (int16)(stream->readSint32LE() & 0xFFFF);
+ boundingRect.top = (int16)(stream->readSint32LE() & 0xFFFF);
+ boundingRect.right = (int16)(stream->readSint32LE() & 0xFFFF);
+ boundingRect.bottom = (int16)(stream->readSint32LE() & 0xFFFF);
// read common graphic resources
backgroundImage = (ResourceId)stream->readSint32LE();
@@ -99,10 +164,10 @@ void WorldStats::load(Common::SeekableReadStream *stream) {
stereoReversedFlag = stream->readSint32LE();
for (int32 r = 0; r < 6; r++) {
- sceneRects[r].left = stream->readSint32LE() & 0xFFFF;
- sceneRects[r].top = stream->readSint32LE() & 0xFFFF;
- sceneRects[r].right = stream->readSint32LE() & 0xFFFF;
- sceneRects[r].bottom = stream->readSint32LE() & 0xFFFF;
+ sceneRects[r].left = (int16)(stream->readSint32LE() & 0xFFFF);
+ sceneRects[r].top = (int16)(stream->readSint32LE() & 0xFFFF);
+ sceneRects[r].right = (int16)(stream->readSint32LE() & 0xFFFF);
+ sceneRects[r].bottom = (int16)(stream->readSint32LE() & 0xFFFF);
}
sceneRectIdx = stream->readByte();
@@ -213,13 +278,13 @@ void WorldStats::load(Common::SeekableReadStream *stream) {
field_E860C = stream->readSint32LE();
for (int32 i = 0; i < 6; i++)
- field_E8610[i] = stream->readSint32LE();
+ field_E8610[i] = stream->readUint32LE();
for (int32 i = 0; i < 6; i++)
- field_E8628[i] = stream->readSint32LE();
+ field_E8628[i] = stream->readUint32LE();
for (int32 i = 0; i < 7; i++) {
- ObjectId id = (ObjectId)stream->readSint32LE();
+ ObjectId id = (ObjectId)stream->readUint32LE();
if (id == 0)
wheels[i] = NULL;
@@ -230,7 +295,7 @@ void WorldStats::load(Common::SeekableReadStream *stream) {
tickCount1 = stream->readSint32LE();
for (int32 i = 0; i < 6; i++)
- field_E8660[i] = stream->readSint32LE();
+ field_E8660[i] = stream->readUint32LE();
}
//////////////////////////////////////////////////////////////////////////
@@ -267,8 +332,8 @@ void WorldStats::setWheelObjects() {
wheels[2] = getObjectById(kObjectWheel3);
wheels[3] = getObjectById(kObjectWheel4);
wheels[4] = getObjectById(kObjectWheel5);
- wheels[6] = getObjectById(kObjectWheel6);
- wheels[7] = getObjectById(kObjectWheel7);
+ wheels[5] = getObjectById(kObjectWheel6);
+ wheels[6] = getObjectById(kObjectWheel7);
}
Common::String WorldStats::toString() {
diff --git a/engines/asylum/respack.cpp b/engines/asylum/respack.cpp
index 151ee8f11c..97a198247c 100644
--- a/engines/asylum/respack.cpp
+++ b/engines/asylum/respack.cpp
@@ -35,8 +35,8 @@ ResourceManager::ResourceManager() : _cdNumber(-1), _musicPackId(kResourcePackIn
}
ResourceEntry *ResourceManager::get(ResourceId id) {
- ResourcePackId packId = (ResourcePackId)((id >> 16) & 0x7FFF);
- uint16 index = (uint16)id;
+ ResourcePackId packId = RESOURCE_PACK(id);
+ uint16 index = RESOURCE_INDEX(id);
// Check if we need to load a music pack
bool isMusicPack = (packId == kResourcePackMusic);
@@ -116,8 +116,8 @@ void ResourcePack::init(Common::String filename) {
entry.offset = prevOffset;
// Read the offset of the next entry to determine the size of this one
- nextOffset = (i < entryCount - 1) ? _packFile.readUint32LE() : _packFile.size();
- entry.size = (nextOffset > 0) ? nextOffset - prevOffset : _packFile.size() - prevOffset;
+ nextOffset = (i < entryCount - 1) ? _packFile.readUint32LE() : (uint32)_packFile.size();
+ entry.size = (nextOffset > 0) ? nextOffset - prevOffset : (uint32)_packFile.size() - prevOffset;
entry.data = 0;
_resources[i] = entry;
diff --git a/engines/asylum/shared.h b/engines/asylum/shared.h
index 34189af094..b08c09c501 100644
--- a/engines/asylum/shared.h
+++ b/engines/asylum/shared.h
@@ -138,7 +138,6 @@ enum ChapterIndex {
//////////////////////////////////////////////////////////////////////////
enum ResourcePackId {
- kResourcePackInvalid = -1,
kResourcePackText = 0,
kResourcePackShared = 1,
kResourcePackMusic = 2, // Special case: will load from mus* resources
@@ -160,10 +159,12 @@ enum ResourcePackId {
kResourcePackSound = 18,
kResourcePack104 = 104,
kResourcePack204 = 204,
- kResourcePack304 = 304
+ kResourcePack304 = 304,
+
+ kResourcePackInvalid = 0xFFF
};
-#define MAKE_RESOURCE(pack, index) (ResourceId)((0x80000000 + ((pack) << 16)) + (uint32)(index))
+#define MAKE_RESOURCE(pack, index) (ResourceId)((((pack) << 16) + 0x80000000) + (uint32)(index))
enum ResourceId {
kResourceNone = 0
@@ -235,7 +236,8 @@ enum ActorDirection {
kDirection4 = 4,
kDirection5 = 5,
kDirection6 = 6,
- kDirection7 = 7
+ kDirection7 = 7,
+ kDirection8 = 8
};
enum ActorFlags {
@@ -533,7 +535,11 @@ enum ObjectFlag {
#define LOBYTE(d) (*((char*)&(d)))
#define BYTE1(d) (*((char*)&(d)+1)) // Same as HIBYTE()
-
+//////////////////////////////////////////////////////////////////////////
+// Resource ID macros
+//////////////////////////////////////////////////////////////////////////
+#define RESOURCE_PACK(id) (ResourcePackId)((((uint32)id) >> 16) & 0x7FFF)
+#define RESOURCE_INDEX(id) (int16)(id)
} // End of namespace Asylum
diff --git a/engines/asylum/system/cursor.cpp b/engines/asylum/system/cursor.cpp
index a0406ee4ce..c2be2f807d 100644
--- a/engines/asylum/system/cursor.cpp
+++ b/engines/asylum/system/cursor.cpp
@@ -33,15 +33,16 @@ namespace Asylum {
const uint32 CURSOR_UPDATE_TICKS = 100;
-Cursor::Cursor(AsylumEngine *engine) : _vm(engine) {
- _pos.x = 0;
- _pos.y = 0;
- _cursorRes = 0;
+Cursor::Cursor(AsylumEngine *engine) : graphicResourceId(kResourceNone), currentFrame(0), frameCount(0), counter(0), flags(0), field_11(0),
+ _vm(engine), _cursorRes(NULL), _cursorTicks(0), _cursor_byte_45756C(0) {
+
}
Cursor::~Cursor() {
- if (_cursorRes)
- delete _cursorRes;
+ delete _cursorRes;
+
+ // Zero-out passed pointers
+ _vm = NULL;
}
/*
@@ -56,15 +57,15 @@ void Cursor::load(int32 index) {
}
*/
-void Cursor::hide() {
+void Cursor::hide() const {
CursorMan.showMouse(false);
}
-void Cursor::show() {
+void Cursor::show() const {
CursorMan.showMouse(true);
}
-void Cursor::set(ResourceId resourceId, int32 cntr, int32 flgs, int32 frames) {
+void Cursor::set(ResourceId resourceId, int32 cntr, byte flgs, int32 frames) {
if (_cursorRes)
delete _cursorRes;
@@ -83,6 +84,9 @@ void Cursor::set(ResourceId resourceId, int32 cntr, int32 flgs, int32 frames) {
}
void Cursor::update() {
+ if (!_cursorRes)
+ error("[Cursor::update] Cursor resources not initialized properly!");
+
GraphicFrame *fra = _cursorRes->getFrame(currentFrame);
CursorMan.replaceCursor((byte *)fra->surface.pixels,
fra->surface.w,
diff --git a/engines/asylum/system/cursor.h b/engines/asylum/system/cursor.h
index ce981ccfca..20d6acf3fd 100644
--- a/engines/asylum/system/cursor.h
+++ b/engines/asylum/system/cursor.h
@@ -47,12 +47,12 @@ public:
/**
* Show the current cursor
*/
- void show();
+ void show() const;
/**
* Hide the current cursor
*/
- void hide();
+ void hide() const;
/**
* Set the current cursor instance to the graphic resource provide.
@@ -60,7 +60,7 @@ public:
* frame count should be derived from the graphic resource as opposed to being
* explicitly set.
*/
- void set(ResourceId resourceId, int32 cntr = 0, int32 flgs = 0, int32 frames = -1);
+ void set(ResourceId resourceId, int32 cntr = 0, byte flgs = 0, int32 frames = -1);
/**
* Set the x/y coordinates of the cursor
@@ -98,7 +98,7 @@ public:
// typedef struct CursorInfo {
ResourceId graphicResourceId;
- int32 currentFrame; // assuming field_4c is the current frame pointer
+ uint32 currentFrame; // assuming field_4c is the current frame pointer
// since it's generally initialized to zero
int32 frameCount;
int32 counter; // cursor counter
diff --git a/engines/asylum/system/screen.cpp b/engines/asylum/system/screen.cpp
index aea4c4e553..790857f2a4 100644
--- a/engines/asylum/system/screen.cpp
+++ b/engines/asylum/system/screen.cpp
@@ -42,6 +42,9 @@ Screen::Screen(AsylumEngine *vm) : _vm(vm) {
Screen::~Screen() {
_backBuffer.free();
+
+ // Zero-out passed pointers
+ _vm = NULL;
}
void Screen::draw(GraphicResource *resource, uint32 frameIndex, int32 x, int32 y, int32 flags) {
@@ -49,7 +52,7 @@ void Screen::draw(GraphicResource *resource, uint32 frameIndex, int32 x, int32 y
// Get the frame to draw
GraphicFrame *frame = resource->getFrame(frameIndex);
- copyToBackBuffer(((byte *)frame->surface.pixels) - y * frame->surface.w - x,
+ copyToBackBuffer(((byte *)frame->surface.pixels) - (y * frame->surface.w + x),
frame->surface.w,
0,
0,
@@ -61,13 +64,11 @@ void Screen::copyBackBufferToScreen() {
_vm->_system->copyRectToScreen((byte *)_backBuffer.pixels, _backBuffer.w, 0, 0, _backBuffer.w, _backBuffer.h);
}
-void Screen::copyToBackBuffer(byte *buffer, int32 pitch, int32 x, int32 y, int32 width, int32 height) {
- int32 h = height;
- int32 w = width;
+void Screen::copyToBackBuffer(byte *buffer, int32 pitch, int32 x, int32 y, uint32 width, uint32 height) {
byte *dest = (byte *)_backBuffer.pixels;
- while (h--) {
- memcpy(dest + y * _backBuffer.pitch + x, buffer, w);
+ while (height--) {
+ memcpy(dest + y * _backBuffer.pitch + x, buffer, width);
dest += 640;
buffer += pitch;
}
@@ -90,11 +91,11 @@ void Screen::copyToBackBufferWithTransparency(byte *buffer, int32 pitch, int32 x
}
}
-void Screen::copyRectToScreen(byte *buffer, int32 pitch, int32 x, int32 y, int32 width, int32 height) {
+void Screen::copyRectToScreen(byte *buffer, int32 pitch, int32 x, int32 y, int32 width, int32 height) const{
_vm->_system->copyRectToScreen(buffer, pitch, x, y, width, height);
}
-void Screen::copyRectToScreenWithTransparency(byte *buffer, int32 pitch, int32 x, int32 y, int32 width, int32 height) {
+void Screen::copyRectToScreenWithTransparency(byte *buffer, int32 pitch, int32 x, int32 y, int32 width, int32 height) const {
byte *screenBuffer = (byte *)_vm->_system->lockScreen()->pixels;
int32 left = (x < 0) ? -x : 0;
@@ -117,7 +118,7 @@ void Screen::setPalette(ResourceId id) {
setPalette(getResource()->get(id)->data + 32);
}
-void Screen::setPalette(byte *rgbPalette) {
+void Screen::setPalette(byte *rgbPalette) const {
byte palette[256 * 4];
byte *p = rgbPalette;
@@ -139,7 +140,7 @@ void Screen::setGammaLevel(ResourceId id, int32 val) {
warning("[Screen::setGammaLevel] not implemented");
}
-void Screen::drawWideScreen(int16 barSize) {
+void Screen::drawWideScreen(int16 barSize) const {
if (barSize > 0) {
_vm->_system->lockScreen()->fillRect(Common::Rect(0, 0, 640, barSize), 0);
@@ -149,7 +150,7 @@ void Screen::drawWideScreen(int16 barSize) {
}
}
-void Screen::clearScreen() {
+void Screen::clearScreen() const {
_vm->_system->fillScreen(0);
}
@@ -161,7 +162,7 @@ void Screen::startPaletteFade(ResourceId resourceId, int32 milliseconds, int32 p
error("[Screen::startPaletteFade] not implemented");
}
-void Screen::addGraphicToQueue(ResourceId resourceId, int32 frameIdx, int32 x, int32 y, int32 flags, int32 transTableNum, int32 priority) {
+void Screen::addGraphicToQueue(ResourceId resourceId, uint32 frameIdx, int32 x, int32 y, int32 flags, int32 transTableNum, int32 priority) {
GraphicQueueItem item;
item.resourceId = resourceId;
item.x = x;
@@ -174,11 +175,11 @@ void Screen::addGraphicToQueue(ResourceId resourceId, int32 frameIdx, int32 x, i
_queueItems.push_back(item);
}
-void Screen::addCrossFadeGraphicToQueue(ResourceId resourceId, int32 frameIdx, int32 x, int32 y, int32 redId2, int32 x2, int32 y2, int32 flags, int32 priority) {
+void Screen::addCrossFadeGraphicToQueue(ResourceId resourceId, uint32 frameIdx, int32 x, int32 y, int32 redId2, int32 x2, int32 y2, int32 flags, int32 priority) {
error("[Screen::addCrossFadeGraphicToQueue] not implemented");
}
-void Screen::addGraphicToQueue(GraphicQueueItem item) {
+void Screen::addGraphicToQueue(GraphicQueueItem const &item) {
_queueItems.push_back(item);
}
diff --git a/engines/asylum/system/screen.h b/engines/asylum/system/screen.h
index 7742d74d52..80df2fbf0a 100644
--- a/engines/asylum/system/screen.h
+++ b/engines/asylum/system/screen.h
@@ -40,7 +40,7 @@ class ResourcePack;
typedef struct GraphicQueueItem {
ResourceId resourceId;
- int32 frameIdx;
+ uint32 frameIdx;
int32 x;
int32 y;
int32 flags;
@@ -56,25 +56,25 @@ public:
void draw(GraphicResource *resource, uint32 frameIndex, int32 x, int32 y, int32 flags);
- void copyToBackBuffer(byte *buffer, int32 pitch, int32 x, int32 y, int32 width, int32 height);
+ void copyToBackBuffer(byte *buffer, int32 pitch, int32 x, int32 y, uint32 width, uint32 height);
void copyToBackBufferWithTransparency(byte *buffer, int32 pitch, int32 x, int32 y, int32 width, int32 height);
void copyBackBufferToScreen();
- void copyRectToScreen(byte *buffer, int32 pitch, int32 x, int32 y, int32 width, int32 height);
- void copyRectToScreenWithTransparency(byte *buffer, int32 pitch, int32 x, int32 y, int32 width, int32 height);
- void setPalette(byte *rgbPalette);
+ void copyRectToScreen(byte *buffer, int32 pitch, int32 x, int32 y, int32 width, int32 height) const;
+ void copyRectToScreenWithTransparency(byte *buffer, int32 pitch, int32 x, int32 y, int32 width, int32 height) const;
+ void setPalette(byte *rgbPalette) const;
void setPalette(ResourceId id);
void setGammaLevel(ResourceId id, int32 val);
- void drawWideScreen(int16 barSize);
- void clearScreen();
+ void drawWideScreen(int16 barSize) const;
+ void clearScreen() const;
void paletteFade(uint32 red, int32 milliseconds, int32 param);
void startPaletteFade(ResourceId resourceId, int32 milliseconds, int32 param);
- void addGraphicToQueue(ResourceId resourceId, int32 frameIdx, int32 x, int32 y, int32 flags, int32 transTableNum, int32 priority);
- void addCrossFadeGraphicToQueue(ResourceId resourceId, int32 frameIdx, int32 x, int32 y, int32 redId2, int32 x2, int32 y2, int32 flags, int32 priority);
- void addGraphicToQueue(GraphicQueueItem item);
+ void addGraphicToQueue(ResourceId resourceId, uint32 frameIdx, int32 x, int32 y, int32 flags, int32 transTableNum, int32 priority);
+ void addCrossFadeGraphicToQueue(ResourceId resourceId, uint32 frameIdx, int32 x, int32 y, int32 redId2, int32 x2, int32 y2, int32 flags, int32 priority);
+ void addGraphicToQueue(GraphicQueueItem const &item);
void drawGraphicsInQueue();
void clearGraphicsInQueue();
void graphicsSelectionSort();
diff --git a/engines/asylum/system/sound.cpp b/engines/asylum/system/sound.cpp
index f23f95e5e3..1dfd85209e 100644
--- a/engines/asylum/system/sound.cpp
+++ b/engines/asylum/system/sound.cpp
@@ -48,6 +48,10 @@ Sound::Sound(AsylumEngine *engine, Audio::Mixer *mixer) : _vm(engine), _mixer(mi
Sound::~Sound() {
clearSoundBuffer();
+
+ // Zero-out passed pointers
+ _vm = NULL;
+ _mixer = NULL;
}
//////////////////////////////////////////////////////////////////////////
@@ -115,7 +119,7 @@ void Sound::setVolume(ResourceId resourceId, int32 volume) {
convertVolume(volume);
- _mixer->setChannelVolume(item->handle, volume);
+ _mixer->setChannelVolume(item->handle, (byte)volume);
}
void Sound::setMusicVolume(int32 volume) {
@@ -124,7 +128,7 @@ void Sound::setMusicVolume(int32 volume) {
convertVolume(volume);
- _mixer->setChannelVolume(_musicHandle, volume);
+ _mixer->setChannelVolume(_musicHandle, (byte)volume);
}
void Sound::setPanning(ResourceId resourceId, int32 panning) {
@@ -137,7 +141,7 @@ void Sound::setPanning(ResourceId resourceId, int32 panning) {
convertPan(panning);
- _mixer->setChannelBalance(item->handle, panning);
+ _mixer->setChannelBalance(item->handle, (int8)panning);
}
int32 Sound::calculateVolumeAdjustement(int32 x, int32 y, int32 attenuation, int32 delta) {
@@ -179,7 +183,9 @@ int32 Sound::getAdjustedVolume(int32 volume) {
return volume;
}
-int32 Sound::calculatePanningAtPoint(int32 x, int32 y) {
+int32 Sound::calculatePanningAtPoint(int32 x, int32) {
+ // y does not seem to be used at all :S
+
int delta = x - getWorld()->xLeft;
if (delta < 0)
@@ -236,7 +242,7 @@ void Sound::stopMusic() {
// Helper functions
//////////////////////////////////////////////////////////////////////////
-void Sound::playSoundData(Audio::Mixer::SoundType type, Audio::SoundHandle *handle, byte *soundData, int32 soundDataLength, bool loop, int32 vol, int32 pan) {
+void Sound::playSoundData(Audio::Mixer::SoundType type, Audio::SoundHandle *handle, byte *soundData, uint32 soundDataLength, bool loop, int32 vol, int32 pan) {
Common::MemoryReadStream *stream = new Common::MemoryReadStream(soundData, soundDataLength);
Audio::RewindableAudioStream *sndStream = Audio::makeWAVStream(stream, DisposeAfterUse::YES);
@@ -244,7 +250,7 @@ void Sound::playSoundData(Audio::Mixer::SoundType type, Audio::SoundHandle *hand
convertVolume(vol);
convertPan(pan);
- _mixer->playStream(type, handle, Audio::makeLoopingAudioStream(sndStream, loop ? 0 : 1), -1, vol, pan);
+ _mixer->playStream(type, handle, Audio::makeLoopingAudioStream(sndStream, loop ? 0 : 1), -1, (byte)vol, (int8)pan);
}
//////////////////////////////////////////////////////////////////////////
diff --git a/engines/asylum/system/sound.h b/engines/asylum/system/sound.h
index 89e35bef5e..5f3ecfcdff 100644
--- a/engines/asylum/system/sound.h
+++ b/engines/asylum/system/sound.h
@@ -69,6 +69,17 @@ struct AmbientSoundItem {
int32 x;
int32 y;
+ AmbientSoundItem() {
+ field_0 = 0;
+ flags = 0;
+ resourceId = kResourceNone;
+ field_C = 0;
+ field_10 = 0;
+ field_14 = 0;
+ memset(&flagNum, 0, sizeof(flagNum));
+ x = 0;
+ y = 0;
+ }
};
struct SoundBufferItem {
@@ -228,7 +239,7 @@ private:
* @param vol The volume.
* @param pan The pan.
*/
- void playSoundData(Audio::Mixer::SoundType type, Audio::SoundHandle *handle, byte *soundData, int32 soundDataLength, bool loop = false, int32 vol = 0, int32 pan = 0);
+ void playSoundData(Audio::Mixer::SoundType type, Audio::SoundHandle *handle, byte *soundData, uint32 soundDataLength, bool loop = false, int32 vol = 0, int32 pan = 0);
//////////////////////////////////////////////////////////////////////////
// Sound buffer
diff --git a/engines/asylum/system/speech.cpp b/engines/asylum/system/speech.cpp
index 18379144b7..f96344dbef 100644
--- a/engines/asylum/system/speech.cpp
+++ b/engines/asylum/system/speech.cpp
@@ -37,13 +37,17 @@
namespace Asylum {
-Speech::Speech(AsylumEngine *engine): _vm(engine) {
+Speech::Speech(AsylumEngine *engine): _vm(engine), _textData(0), _textDataPos(0) {
_tick = _vm->getTick();
_soundResourceId = kResourceNone;
_textResourceId = kResourceNone;
}
Speech::~Speech() {
+ // Text resource data is disposed as part of the resource manager
+ _textData = 0;
+ _textDataPos = 0;
+
// Zero-out passed pointers
_vm = NULL;
}
@@ -62,7 +66,7 @@ ResourceId Speech::play(ResourceId soundResourceId, ResourceId textResourceId) {
}
ResourceId Speech::playIndexed(int32 index) {
- int processedIndex = 0;
+ int processedIndex;
if (getWorld()->actorType || index != -1) {
error("[Speech::playIndexed] Missing case using static data!");
diff --git a/engines/asylum/system/text.cpp b/engines/asylum/system/text.cpp
index cabb08e069..b68bc2e9bc 100644
--- a/engines/asylum/system/text.cpp
+++ b/engines/asylum/system/text.cpp
@@ -32,6 +32,7 @@
#include "asylum/respack.h"
#include "common/endian.h"
+#include "common/rational.h"
namespace Asylum {
@@ -59,7 +60,7 @@ void Text::loadFont(ResourceId resourceId) {
if (resourceId != kResourceNone) {
// load font flag data
- _curFontFlags = (_fontResource->getFlags() >> 4) & 0x0F;
+ _curFontFlags = Common::Rational(_fontResource->getFlags(), 16).toInt() & 0x0F;
}
}
@@ -69,12 +70,13 @@ void Text::setPosition(int32 x, int32 y) {
}
int32 Text::getWidth(const char *text) {
- assert(_fontResource);
+ if (!_fontResource)
+ error("[Text::getWidth] font resource hasn't been loaded yet!");
int32 width = 0;
- uint8 character = *text;
+ char character = *text;
while (character) {
- GraphicFrame *font = _fontResource->getFrame(character);
+ GraphicFrame *font = _fontResource->getFrame((uint8)character);
width += font->surface.w + font->x - _curFontFlags;
text++;
@@ -93,17 +95,18 @@ char* Text::get(ResourceId resourceId) {
return (char*)textRes->data;
}
-void Text::drawChar(unsigned char character) {
- assert(_fontResource);
+void Text::drawChar(char character) {
+ if (!_fontResource)
+ error("[Text::drawChar] font resource hasn't been loaded yet!");
- GraphicFrame *fontLetter = _fontResource->getFrame(character);
+ GraphicFrame *fontLetter = _fontResource->getFrame((uint8)character);
getScreen()->copyRectToScreenWithTransparency((byte *)fontLetter->surface.pixels, fontLetter->surface.w, _posX, _posY + fontLetter->y, fontLetter->surface.w, fontLetter->surface.h);
_posX += fontLetter->surface.w + fontLetter->x - _curFontFlags;
}
void Text::draw(const char *text) {
while (*text) {
- drawChar(*((unsigned char *)text));
+ drawChar(text[0]);
text++;
}
}
diff --git a/engines/asylum/system/text.h b/engines/asylum/system/text.h
index 13b81be309..ae4ac973da 100644
--- a/engines/asylum/system/text.h
+++ b/engines/asylum/system/text.h
@@ -48,7 +48,7 @@ public:
int32 getWidth(ResourceId resourceId);
char *get(ResourceId resourceId);
- void drawChar(unsigned char character);
+ void drawChar(char character);
void draw(const char *text);
void draw(int32 x, int32 y, const char *text);
void draw(ResourceId resourceId);
diff --git a/engines/asylum/system/video.cpp b/engines/asylum/system/video.cpp
index 6790d41c4d..10d43d752a 100644
--- a/engines/asylum/system/video.cpp
+++ b/engines/asylum/system/video.cpp
@@ -68,8 +68,8 @@ void Video::playVideo(int32 videoNumber, bool showSubtitles) {
if (showSubtitles)
loadSubtitles(videoNumber);
- uint16 x = (g_system->getWidth() - _smkDecoder->getWidth()) / 2;
- uint16 y = (g_system->getHeight() - _smkDecoder->getHeight()) / 2;
+ int32 x = Common::Rational(g_system->getWidth() - _smkDecoder->getWidth(), 2).toInt();
+ int32 y = Common::Rational(g_system->getHeight() - _smkDecoder->getHeight(), 2).toInt();
while (!_smkDecoder->endOfVideo() && !_skipVideo) {
processVideoEvents();
@@ -124,8 +124,8 @@ void Video::loadSubtitles(int32 videoNumber) {
Common::File subsFile;
subsFile.open("vids.cap");
- char *buffer = new char[subsFile.size()];
- subsFile.read(buffer, subsFile.size());
+ char *buffer = new char[(uint)subsFile.size()];
+ subsFile.read(buffer, (uint32)subsFile.size());
subsFile.close();
char *start = strstr(buffer, movieToken);
@@ -134,7 +134,7 @@ void Video::loadSubtitles(int32 videoNumber) {
if (start) {
start += 20; // skip token, newline and "CAPTION = "
- int32 count = strcspn(start, "\r\n");
+ uint32 count = strcspn(start, "\r\n");
line = new char[count + 1];
strncpy(line, start, count);
@@ -145,10 +145,19 @@ void Video::loadSubtitles(int32 videoNumber) {
while (tok) {
VideoSubtitle newSubtitle;
newSubtitle.frameStart = atoi(tok);
+
tok = strtok(NULL, " ");
+ if (!tok)
+ error("[Video::loadSubtitles] Invalid subtitle (frame end missing)!");
+
newSubtitle.frameEnd = atoi(tok);
+
tok = strtok(NULL, " ");
+ if (!tok)
+ error("[Video::loadSubtitles] Invalid subtitle (resource id missing)!");
+
newSubtitle.textResourceId = (ResourceId)(atoi(tok) + video_subtitle_resourceIds[videoNumber]);
+
tok = strtok(NULL, " ");
_subtitles.push_back(newSubtitle);
@@ -191,6 +200,9 @@ VideoText::VideoText(AsylumEngine *engine) : _vm(engine) {
VideoText::~VideoText() {
delete _fontResource;
+
+ // Zero-out passed pointers
+ _vm = NULL;
}
void VideoText::loadFont(ResourceId resourceId) {
@@ -198,9 +210,9 @@ void VideoText::loadFont(ResourceId resourceId) {
_fontResource = new GraphicResource(_vm, resourceId);
- if (resourceId > 0) {
+ if (resourceId != kResourceNone) {
// load font flag data
- _curFontFlags = (_fontResource->getFlags() >> 4) & 0x0F;
+ _curFontFlags = Common::Rational(_fontResource->getFlags(), 16).toInt() & 0x0F;
}
}
@@ -236,43 +248,41 @@ void VideoText::drawMovieSubtitle(byte *screenBuffer, ResourceId resourceId) {
for (int32 i = 0; i < curLine + 1; i++) {
int32 textWidth = getTextWidth(textLine[i].c_str());
- drawText(screenBuffer, 0 + (640 - textWidth) / 2, startY + i * spacing, textLine[i].c_str());
+ drawText(screenBuffer, (int16)Common::Rational(640 - textWidth, 2).toInt(), (int16)(startY + i * spacing), textLine[i].c_str());
}
free(text);
}
int32 VideoText::getTextWidth(const char *text) {
- assert(_fontResource);
+ if (!_fontResource)
+ error("[VideoText::getTextWidth] Video text resources not initialized properly!");
int32 width = 0;
- uint8 character = *text;
- const char *curChar = text;
- while (character) {
- GraphicFrame *font = _fontResource->getFrame(character);
+ while (*text) {
+ GraphicFrame *font = _fontResource->getFrame((uint8)*text);
width += font->surface.w + font->x - _curFontFlags;
- curChar++;
- character = *curChar;
+ text++;
}
+
return width;
}
void VideoText::drawText(byte *screenBuffer, int16 x, int16 y, const char *text) {
- assert(_fontResource);
- const byte *curChar = (byte *)text;
- int16 curX = x;
-
- while (*curChar) {
- GraphicFrame *fontLetter = _fontResource->getFrame(*curChar);
- copyToVideoFrame(screenBuffer, fontLetter, curX, y + fontLetter->y);
- curX += fontLetter->surface.w + fontLetter->x - _curFontFlags;
- curChar++;
+ if (!_fontResource)
+ error("[VideoText::drawText] Video text resources not initialized properly!");
+
+ while (*text) {
+ GraphicFrame *fontLetter = _fontResource->getFrame((uint8)*text);
+ copyToVideoFrame(screenBuffer, fontLetter, x, y + fontLetter->y);
+ x += (int16)(fontLetter->surface.w + fontLetter->x - _curFontFlags);
+ text++;
}
}
-void VideoText::copyToVideoFrame(byte *screenBuffer, GraphicFrame *frame, int32 x, int32 y) {
+void VideoText::copyToVideoFrame(byte *screenBuffer, GraphicFrame *frame, int32 x, int32 y) const {
uint16 h = frame->surface.h;
uint16 w = frame->surface.w;
int32 screenBufferPitch = 640;
diff --git a/engines/asylum/system/video.h b/engines/asylum/system/video.h
index be7ed13afc..46995ce4b8 100644
--- a/engines/asylum/system/video.h
+++ b/engines/asylum/system/video.h
@@ -88,7 +88,7 @@ private:
int32 getTextWidth(const char *text);
void drawText(byte *screenBuffer, int16 x, int16 y, const char *text);
- void copyToVideoFrame(byte *screenBuffer, GraphicFrame *frame, int x, int y);
+ void copyToVideoFrame(byte *screenBuffer, GraphicFrame *frame, int x, int y) const;
GraphicResource *_fontResource;
uint8 _curFontFlags;
diff --git a/engines/asylum/views/menu.cpp b/engines/asylum/views/menu.cpp
index f008fe01ff..520486998d 100644
--- a/engines/asylum/views/menu.cpp
+++ b/engines/asylum/views/menu.cpp
@@ -195,6 +195,9 @@ void MainMenu::update() {
}
switch (_activeIcon) {
+ default:
+ break;
+
case kNewGame:
// Nothing here
break;
@@ -315,7 +318,7 @@ void MainMenu::updateMainMenu() {
_iconResource = new GraphicResource(_vm, MAKE_RESOURCE(kResourcePackShared, iconNum + 4));
}
- GraphicFrame *iconFrame = _iconResource->getFrame(MIN<int>(_iconResource->count() - 1, _curIconFrame));
+ GraphicFrame *iconFrame = _iconResource->getFrame(MIN<uint>(_iconResource->count() - 1, _curIconFrame));
_vm->screen()->copyRectToScreenWithTransparency((byte *)iconFrame->surface.pixels, iconFrame->surface.w, iconFrame->x, iconFrame->y, iconFrame->surface.w, iconFrame->surface.h);
// Cycle icon frame
@@ -341,7 +344,7 @@ void MainMenu::updateMainMenu() {
}
void MainMenu::updateSubMenu() {
- GraphicFrame *iconFrame = _iconResource->getFrame(MIN<int>(_iconResource->count() - 1, _curIconFrame));
+ GraphicFrame *iconFrame = _iconResource->getFrame(MIN<uint>(_iconResource->count() - 1, _curIconFrame));
_vm->screen()->copyRectToScreenWithTransparency((byte *)iconFrame->surface.pixels, iconFrame->surface.w, iconFrame->x, iconFrame->y, iconFrame->surface.w, iconFrame->surface.h);
// Cycle icon frame
@@ -350,6 +353,9 @@ void MainMenu::updateSubMenu() {
_curIconFrame = 0;
switch (_activeIcon) {
+ default:
+ break;
+
case kNewGame:
updateSubMenuNewGame();
break;
@@ -583,7 +589,7 @@ void MainMenu::updateSubMenuShowCredits() {
GraphicFrame *creditsFadeFrame = _creditsFadeResource->getFrame(0);
_vm->screen()->copyRectToScreenWithTransparency((byte *)creditsFadeFrame->surface.pixels, creditsFadeFrame->surface.w, creditsFadeFrame->x, creditsFadeFrame->y, creditsFadeFrame->surface.w, creditsFadeFrame->surface.h);
- GraphicFrame *creditsFrame = _creditsResource->getFrame(MIN<int>(_creditsResource->count() - 1, _creditsBgFrame));
+ GraphicFrame *creditsFrame = _creditsResource->getFrame(MIN<uint>(_creditsResource->count() - 1, _creditsBgFrame));
_vm->screen()->copyRectToScreenWithTransparency((byte *)creditsFrame->surface.pixels, creditsFrame->surface.w, creditsFrame->x, creditsFrame->y, creditsFrame->surface.w, creditsFrame->surface.h);
_creditsBgFrame++;
diff --git a/engines/asylum/views/scene.cpp b/engines/asylum/views/scene.cpp
index 73159cd7e9..91479f2436 100644
--- a/engines/asylum/views/scene.cpp
+++ b/engines/asylum/views/scene.cpp
@@ -57,7 +57,7 @@ int g_debugPolygons;
int g_debugObjects;
int g_debugScrolling;
-Scene::Scene(AsylumEngine *engine): _vm(engine),
+Scene::Scene(AsylumEngine *engine): _vm(engine), _ev(NULL),
_actions(NULL), _special(NULL), _speech(NULL), _title(NULL), _polygons(NULL), _ws(NULL) {
// Initialize data
@@ -81,20 +81,35 @@ Scene::Scene(AsylumEngine *engine): _vm(engine),
_sceneXLeft = _sceneYTop = 0;
_actorUpdateFlag = false;
_actorUpdateFlag2 = false;
+
+ //
+ matteBarHeight = 0;
+ matteVar1 = 0;
+ matteVar2 = 0;
+ mattePlaySound = false;
+ matteInitialized = false;
+
+ memset(&savedResourceIds, 0, sizeof(savedResourceIds));
}
Scene::~Scene() {
// Unload the associated resources
getResource()->unload(_packId);
- delete _ws;
- delete _polygons;
delete _actions;
+ //delete _blowUp;
+ delete _special;
+ delete _speech;
+ delete _title;
+ delete _polygons;
+ delete _ws;
delete _bgResource;
- //delete _blowUp;
+ _background = NULL;
- delete _title;
+ // Zero passed pointers
+ _vm = NULL;
+ _ev = NULL;
}
void Scene::enter(ResourcePackId packId) {
@@ -135,8 +150,8 @@ void Scene::enter(ResourcePackId packId) {
// Update current player bounding rectangle
Actor *player = getActor();
Common::Rect *boundingRect = player->getBoundingRect();
- boundingRect->bottom = player->y2;
- boundingRect->right = player->x2 * 2;
+ boundingRect->bottom = (int16)player->y2;
+ boundingRect->right = (int16)(player->x2 * 2);
// Adjust scene bounding rect
_ws->boundingRect = Common::Rect(195, 115, 445 - boundingRect->right, 345 - boundingRect->bottom);
@@ -161,8 +176,8 @@ void Scene::enter(ResourcePackId packId) {
actor->x1 -= actor->x2;
actor->y1 -= actor->y2;
- actor->getBoundingRect()->bottom = actor->y2;
- actor->getBoundingRect()->right = 2 * actor->x2;
+ actor->getBoundingRect()->bottom = (int16)actor->y2;
+ actor->getBoundingRect()->right = (int16)(2 * actor->x2);
}
}
@@ -220,7 +235,7 @@ void Scene::load(ResourcePackId packId) {
char sceneTag[6];
Common::File* fd = new Common::File;
- if (!fd->exists(filename))
+ if (!Common::File::exists(filename))
error("Scene file doesn't exist %s", filename);
fd->open(filename);
@@ -257,11 +272,11 @@ void Scene::load(ResourcePackId packId) {
_bgResource = new GraphicResource(_vm, _ws->backgroundImage);
//_blowUp = 0;
- _background = 0;
+ _background = NULL;
_leftClick = false;
_rightButton = false;
_isActive = false;
- _skipDrawScene = 0;
+ _skipDrawScene = false;
g_debugPolygons = 0;
g_debugObjects = 0;
@@ -287,15 +302,24 @@ void Scene::load(ResourcePackId packId) {
}
Actor* Scene::getActor(ActorIndex index) {
+ if (!_ws)
+ error("[Scene::getActor] WorldStats not initialized properly!");
+
ActorIndex computedIndex = (index != -1) ? index : _playerActorIdx;
- if (computedIndex < 0 || computedIndex >= (int)_ws->actors.size())
+ if (computedIndex < 0 || computedIndex >= (int16)_ws->actors.size())
error("[Scene::getActor] Invalid actor index: %d ([0-%d] allowed)", computedIndex, _ws->actors.size() - 1);
return _ws->actors[computedIndex];
}
void Scene::setScenePosition(int x, int y) {
+ if (!_ws)
+ error("[Scene::setScenePosition] WorldStats not initialized properly!");
+
+ if (!_bgResource)
+ error("[Scene::setScenePosition] Scene resources not initialized properly!");
+
GraphicFrame *bg = _bgResource->getFrame(0);
//_startX = x;
//_startY = y;
@@ -319,6 +343,12 @@ void Scene::setScenePosition(int x, int y) {
}
void Scene::handleEvent(Common::Event *event, bool doUpdate) {
+ if (!_ws)
+ error("[Scene::handleEvent] WorldStats not initialized properly!");
+
+ if (!_title)
+ error("[Scene::handleEvent] Scene title not initialized properly!");
+
_ev = event;
switch (_ev->type) {
@@ -390,6 +420,12 @@ void Scene::handleEvent(Common::Event *event, bool doUpdate) {
}
void Scene::activate() {
+ if (!_ws)
+ error("[Scene::activate] WorldStats not initialized properly!");
+
+ if (!_bgResource)
+ error("[Scene::activate] Scene resources not initialized properly!");
+
//////////////////////////////////////////////////////////////////////////
// FIXME: get rid of this?
@@ -438,19 +474,19 @@ void Scene::updateMouse() {
// .text:0040A1B0 getCharacterScreenPosition()
// which was only ever called at this point, so
// inlining it for simplicity
- pt.x = act->x1 -_ws->xLeft;
- pt.y = act->y1 -_ws->yTop;
+ pt.x = (int16)(act->x1 -_ws->xLeft);
+ pt.y = (int16)(act->y1 -_ws->yTop);
if (_packId != 2 || _playerActorIdx != 10) {
actorPos.left = pt.x + 20;
actorPos.top = pt.y;
- actorPos.right = pt.x + 2 * act->x2;
- actorPos.bottom = pt.y + act->y2;
+ actorPos.right = (int16)(pt.x + 2 * act->x2);
+ actorPos.bottom = (int16)(pt.y + act->y2);
} else {
actorPos.left = pt.x + 50;
actorPos.top = pt.y + 60;
- actorPos.right = pt.x + getActor(10)->x2 + 10;
- actorPos.bottom = pt.y + getActor(10)->y2 - 20;
+ actorPos.right = (int16)(pt.x + getActor(10)->x2 + 10);
+ actorPos.bottom = (int16)(pt.y + getActor(10)->y2 - 20);
}
ActorDirection dir = kDirectionInvalid;
@@ -697,6 +733,9 @@ void Scene::handleMouseUpdate(int direction, Common::Rect rect) {
}
int32 Scene::hitTestObject(const Common::Point pt) {
+ if (!_ws)
+ error("[Scene::hitTestObject] WorldStats not initialized properly!");
+
int32 targetIdx = -1;
for (uint32 i = 0; i < _ws->objects.size(); i++) {
Object *object = _ws->objects[i];
@@ -739,6 +778,12 @@ int32 Scene::hitTestActionArea(const Common::Point pt) {
}
int32 Scene::findActionArea(const Common::Point pt) {
+ if (!_ws)
+ error("[Scene::findActionArea] WorldStats not initialized properly!");
+
+ if (!_polygons)
+ error("[Scene::findActionArea] Polygons not initialized properly!");
+
// TODO
// This is a VERY loose implementation of the target
// function, as this doesn't do any of the flag checking
@@ -756,6 +801,9 @@ int32 Scene::findActionArea(const Common::Point pt) {
}
ResourceId Scene::hitTestScene(const Common::Point pt, HitType &type) {
+ if (!_ws)
+ error("[Scene::hitTestScene] WorldStats not initialized properly!");
+
int32 top = pt.x + _ws->xLeft;
int32 left = pt.y + _ws->yTop;
type = kHitNone;
@@ -803,16 +851,25 @@ void Scene::changePlayer(ActorIndex index) {
}
void Scene::updateActors() {
+ if (!_ws)
+ error("[Scene::updateActors] WorldStats not initialized properly!");
+
for (uint32 i = 0; i < _ws->actors.size(); i++)
_ws->actors[i]->update();
}
void Scene::updateObjects() {
+ if (!_ws)
+ error("[Scene::updateObjects] WorldStats not initialized properly!");
+
for (uint32 i = 0; i < _ws->objects.size(); i++)
_ws->objects[i]->update();
}
void Scene::updateAmbientSounds() {
+ if (!_ws)
+ error("[Scene::updateAmbientSounds] WorldStats not initialized properly!");
+
if (Config.performance <= 3)
return;
@@ -1022,6 +1079,9 @@ void Scene::updateAdjustScreen() {
}
bool Scene::updateSceneCoordinates(int32 tX, int32 tY, int32 A0, bool checkSceneCoords, int32 *param) {
+ if (!_ws)
+ error("[Scene::updateSceneCoordinates] WorldStats not initialized properly!");
+
Common::Rect *sr = &_ws->sceneRects[_ws->sceneRectIdx];
int32 *targetX = &_ws->coordinates[0];
@@ -1092,6 +1152,9 @@ void Scene::adjustCoordinates(int32 x, int32 y, Common::Point *point) {
if (!point)
error("[Scene::adjustCoordinates] Invalid point parameter!");
+ if (!_ws)
+ error("[Scene::adjustCoordinates] WorldStats not initialized properly!");
+
point->x = x - _ws->xLeft;
point->y = y - _ws->yTop;
}
@@ -1100,6 +1163,9 @@ void Scene::adjustCoordinates(int32 x, int32 y, Common::Point *point) {
// Scene drawing
//////////////////////////////////////////////////////////////////////////
int Scene::drawScene() {
+ if (!_ws)
+ error("[Scene::drawScene] WorldStats not initialized properly!");
+
_vm->screen()->clearGraphicsInQueue();
if (_skipDrawScene) {
@@ -1139,6 +1205,9 @@ bool Scene::updateListCompare(const UpdateItem &item1, const UpdateItem &item2)
}
void Scene::buildUpdateList() {
+ if (!_ws)
+ error("[Scene::buildUpdateList] WorldStats not initialized properly!");
+
_updateList.clear();
for (uint32 i = 0; i < _ws->actors.size(); i++) {
@@ -1158,6 +1227,9 @@ void Scene::buildUpdateList() {
}
void Scene::processUpdateList() {
+ if (!_ws)
+ error("[Scene::processUpdateList] WorldStats not initialized properly!");
+
for (uint32 i = 0; i < _updateList.size(); i++) {
Actor *actor = getActor(_updateList[i].index);
int32 priority = _updateList[i].priority;
@@ -1342,6 +1414,9 @@ bool Scene::pointIntersectsRect(Common::Point point, Common::Rect rect) {
}
void Scene::getActorPosition(Actor *actor, Common::Point *pt) {
+ if (!_ws)
+ error("[Scene::getActorPosition] WorldStats not initialized properly!");
+
pt->x = actor->x1 - _ws->xLeft;
pt->y = actor->y1 - _ws->yTop;
}
@@ -1350,6 +1425,9 @@ void Scene::getActorPosition(Actor *actor, Common::Point *pt) {
// ----------------------------------
void Scene::copyToBackBufferClipped(Graphics::Surface *surface, int x, int y) {
+ if (!_ws)
+ error("[Scene::copyToBackBufferClipped] WorldStats not initialized properly!");
+
Common::Rect screenRect(_ws->xLeft, _ws->yTop, _ws->xLeft + 640, _ws->yTop + 480);
Common::Rect animRect(x, y, x + surface->w, y + surface->h);
animRect.clip(screenRect);
@@ -1383,6 +1461,9 @@ void Scene::copyToBackBufferClipped(Graphics::Surface *surface, int x, int y) {
// ----------------------------------
void Scene::debugScreenScrolling(GraphicFrame *bg) {
+ if (!_ws)
+ error("[Scene::debugScreenScrolling] WorldStats not initialized properly!");
+
// Horizontal scrolling
if (getCursor()->position().x < SCREEN_EDGES && _ws->xLeft >= SCROLL_STEP)
_ws->xLeft -= SCROLL_STEP;
@@ -1419,6 +1500,9 @@ void Scene::debugShowWalkRegion(PolyDefinitions *poly) {
// POLYGONS DEBUG
void Scene::debugShowPolygons() {
+ if (!_polygons)
+ error("[Scene::debugShowPolygons] Polygons not initialized properly!");
+
for (int32 p = 0; p < _polygons->numEntries; p++) {
Graphics::Surface surface;
PolyDefinitions poly = _polygons->entries[p];
@@ -1443,6 +1527,9 @@ void Scene::debugShowPolygons() {
// OBJECT DEBUGGING
void Scene::debugShowObjects() {
+ if (!_ws)
+ error("[Scene::debugShowObjects] WorldStats not initialized properly!");
+
for (uint32 p = 0; p < _ws->objects.size(); p++) {
Graphics::Surface surface;
Object *object = _ws->objects[p];
diff --git a/engines/asylum/views/scenetitle.cpp b/engines/asylum/views/scenetitle.cpp
index 2ac2f20b0d..796d1fd4df 100644
--- a/engines/asylum/views/scenetitle.cpp
+++ b/engines/asylum/views/scenetitle.cpp
@@ -38,7 +38,8 @@
namespace Asylum {
-SceneTitle::SceneTitle(AsylumEngine *engine): _vm(engine), _bg(NULL), _progress(NULL) {
+SceneTitle::SceneTitle(AsylumEngine *engine): _vm(engine), _bg(NULL), _progress(NULL),
+ _start(0), _ticks(0), _done(false), _spinnerFrame(0), _spinnerProgress(0), _showMouseState(false) {
}
SceneTitle::~SceneTitle() {
@@ -66,6 +67,8 @@ void SceneTitle::load() {
}
void SceneTitle::update(int32 tick) {
+ if (!_progress || !_bg)
+ error("[SceneTitle::update] SceneTitle resources not initialized properly!");
// This is not from the original. It's just some arbitrary math to throttle the progress indicator.
//
@@ -90,7 +93,7 @@ void SceneTitle::update(int32 tick) {
getScreen()->copyRectToScreenWithTransparency(((byte*)frame->surface.pixels),
frame->surface.w,
- frame->x - 290 + _spinnerProgress,
+ frame->x + (_spinnerProgress - 290),
frame->y,
frame->surface.w,
frame->surface.h);
Commit: 3e6f065a91cdee5b3481916b62700b749ae32bee
https://github.com/scummvm/scummvm/commit/3e6f065a91cdee5b3481916b62700b749ae32bee
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:18+02:00
Commit Message:
ASYLUM: Cleanup Pass 3
- Add proper init code for Object & BlowUpPuzzle classes
- Use Common::Rational in a few more places
- Add casts & const modifiers in proper places
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@547 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/resources/actionlist.cpp
engines/asylum/resources/actor.cpp
engines/asylum/resources/object.cpp
engines/asylum/resources/object.h
engines/asylum/resources/worldstats.cpp
engines/asylum/shared.h
engines/asylum/system/graphics.h
engines/asylum/system/screen.cpp
engines/asylum/system/sound.h
engines/asylum/views/blowuppuzzle.cpp
engines/asylum/views/blowuppuzzle.h
diff --git a/engines/asylum/resources/actionlist.cpp b/engines/asylum/resources/actionlist.cpp
index c7cc2c56b8..0bdc6ecb55 100644
--- a/engines/asylum/resources/actionlist.cpp
+++ b/engines/asylum/resources/actionlist.cpp
@@ -1100,7 +1100,7 @@ IMPLEMENT_OPCODE(PlaySpeechScene)
return;
if (cmd->param4 != 2) {
- cmd->param5 = getSpeech()->playIndexed(cmd->param1);
+ cmd->param5 = (int32)getSpeech()->playIndexed((ResourceId)cmd->param1);
if (cmd->param2) {
_vm->setGameFlag(kGameFlagScriptProcessing);
@@ -1152,7 +1152,7 @@ IMPLEMENT_OPCODE(PlaySpeech)
return;
if (cmd->param4 != 2) {
- cmd->param5 = getSpeech()->playPlayer((ResourceId)cmd->param1);
+ cmd->param5 = (int32)getSpeech()->playPlayer((ResourceId)cmd->param1);
if (cmd->param2) {
_vm->setGameFlag(kGameFlagScriptProcessing);
@@ -1229,7 +1229,7 @@ IMPLEMENT_OPCODE(PlaySpeechScene2)
return;
}
- cmd->param6 = getSpeech()->playScene(cmd->param1, cmd->param2);
+ cmd->param6 = (int32)getSpeech()->playScene(cmd->param1, cmd->param2);
if (cmd->param3) {
_vm->setGameFlag(kGameFlagScriptProcessing);
diff --git a/engines/asylum/resources/actor.cpp b/engines/asylum/resources/actor.cpp
index e8500449fd..9e06c48fa4 100644
--- a/engines/asylum/resources/actor.cpp
+++ b/engines/asylum/resources/actor.cpp
@@ -252,7 +252,7 @@ void Actor::draw() {
getScene()->adjustCoordinates(frameRect.left + x + x1, frameRect.top + y + y1, &point);
// Compute frame index
- int32 frameIndex = _frameIndex;
+ uint32 frameIndex = _frameIndex;
if (_frameIndex >= _frameCount)
frameIndex = 2 * _frameCount - (_frameIndex + 1);
@@ -718,8 +718,8 @@ void Actor::faceTarget(ObjectId id, DirectionFrom from) {
Common::Rect frameRect = GraphicResource::getFrameRect(_vm, object->getResourceId(), object->getFrameIndex());
- newX = (frameRect.width() >> 1) + object->x;
- newY = (frameRect.height() >> 1) + object->y;
+ newX = Common::Rational(frameRect.width(), 2).toInt() + object->x;
+ newY = Common::Rational(frameRect.height(), 2).toInt() + object->y;
}
break;
@@ -917,6 +917,9 @@ void Actor::updateStatus3_19() {
}
void Actor::updateStatusEnabled() {
+ if (_frameCount == 0)
+ error("[Actor::updateStatusEnabled] Actor has no frame!");
+
_frameIndex = (_frameIndex + 1) % _frameCount;
// Actor: Crow
@@ -1115,9 +1118,9 @@ void Actor::setVolume() {
//////////////////////////////////////////////////////////////////////////
ActorDirection Actor::getDirection(int32 ax1, int32 ay1, int32 ax2, int32 ay2) const {
- int32 v5 = (ax2 << 16) - (ax1 << 16);
+ int32 v5 = (ax2 - ax1) * 2^16;
int32 v6 = 0;
- int32 v4 = (ay1 << 16) - (ay2 << 16);
+ int32 v4 = (ay1 - ay2) * 2^16;
if (v5 < 0) {
v6 = 2;
@@ -1129,18 +1132,23 @@ ActorDirection Actor::getDirection(int32 ax1, int32 ay1, int32 ax2, int32 ay2) c
v4 = -v4;
}
- int32 v7;
int32 v8 = -1;
if (v5) {
- v7 = (v4 << 8) / v5;
+ Common::Rational v7(v4 * 256, v5);
if (v7 < 0x100)
- v8 = angleTable01[v7];
- if (v7 < 0x1000 && v8 < 0)
- v8 = angleTable02[v7 >> 4];
- if (v7 < 0x10000 && v8 < 0)
- v8 = angleTable03[v7 >> 8];
+ v8 = angleTable01[v7.toInt()];
+
+ if (v7 < 0x1000 && v8 < 0) {
+ Common::Rational vtemp = v7 / 16;
+ v8 = angleTable02[vtemp.toInt()];
+ }
+
+ if (v7 < 0x10000 && v8 < 0) {
+ Common::Rational vtemp = v7 / 256;
+ v8 = angleTable03[vtemp.toInt()];
+ }
} else {
v8 = 90;
}
@@ -1203,7 +1211,8 @@ ActorDirection Actor::getDirection(int32 ax1, int32 ay1, int32 ax2, int32 ay2) c
}
void Actor::updateGraphicData(uint32 offset) {
- _resourceId = _graphicResourceIds[(_direction > 4 ? 8 - _direction : _direction) + offset];
+ int32 index = ((_direction > 4) ? 8 - _direction : _direction) + (int32)offset;
+ _resourceId = _graphicResourceIds[index];
_frameCount = GraphicResource::getFrameCount(_vm, _resourceId);
_frameIndex = 0;
}
diff --git a/engines/asylum/resources/object.cpp b/engines/asylum/resources/object.cpp
index eb075491ad..67e2cdce6c 100644
--- a/engines/asylum/resources/object.cpp
+++ b/engines/asylum/resources/object.cpp
@@ -38,7 +38,16 @@
namespace Asylum {
-Object::Object(AsylumEngine *engine) : _vm(engine) {
+Object::Object(AsylumEngine *engine) : x(0), y(0), flags(0), actionType(0),
+ _vm(engine), _index(0),
+ _id(kObjectNone), _resourceId(kResourceNone), _field_20(0), _frameIndex(0), _frameCount(0),
+ _field_2C(0), _field_30(0), _field_34(0), _field_3C(0), _polygonIndex(0), _field_B4(0),
+ _tickCount(0), _tickCount2(0), _field_C0(0), _priority(0), _actionListIdx(0), _field_67C(0),
+ _soundX(0), _soundY(0), _field_688(0), _soundResourceId(kResourceNone), _field_6A4(kDirection0)
+{
+ memset(&_name, 0, sizeof(_name));
+ memset(&_gameFlags, 0, sizeof(_gameFlags));
+ memset(&_randomResourceIds, 0, sizeof(_randomResourceIds));
}
Object::~Object() {
@@ -55,36 +64,37 @@ void Object::load(Common::SeekableReadStream *stream) {
x = stream->readSint32LE();
y = stream->readSint32LE();
- _boundingRect.left = stream->readSint32LE() & 0xFFFF;
- _boundingRect.top = stream->readSint32LE() & 0xFFFF;
- _boundingRect.right = stream->readSint32LE() & 0xFFFF;
- _boundingRect.bottom = stream->readSint32LE() & 0xFFFF;
+ _boundingRect.left = (int16)(stream->readSint32LE() & 0xFFFF);
+ _boundingRect.top = (int16)(stream->readSint32LE() & 0xFFFF);
+ _boundingRect.right = (int16)(stream->readSint32LE() & 0xFFFF);
+ _boundingRect.bottom = (int16)(stream->readSint32LE() & 0xFFFF);
_field_20 = stream->readSint32LE();
- _frameIndex = stream->readSint32LE();
- _frameCount = stream->readSint32LE();
+ _frameIndex = stream->readUint32LE();
+ _frameCount = stream->readUint32LE();
_field_2C = stream->readSint32LE();
_field_30 = stream->readSint32LE();
_field_34 = stream->readSint32LE();
- flags = stream->readSint32LE();
+ flags = stream->readUint32LE();
_field_3C = stream->readSint32LE();
stream->read(_name, sizeof(_name));
- _rect.left = stream->readSint32LE();
- _rect.top = stream->readSint32LE();
- _rect.right = stream->readSint32LE();
- _rect.bottom = stream->readSint32LE();
+ _rect.left = (int16)(stream->readSint32LE());
+ _rect.top = (int16)(stream->readSint32LE());
+ _rect.right = (int16)(stream->readSint32LE());
+ _rect.bottom = (int16)(stream->readSint32LE());
+
_polygonIndex = stream->readSint32LE();
actionType = stream->readSint32LE();
for (int i = 0; i < 10; i++)
- _gameFlags[i] = (GameFlag)stream->readSint32LE();
+ _gameFlags[i] = stream->readSint32LE();
_field_B4 = stream->readSint32LE();
- _tickCount = stream->readSint32LE();
- _tickCount2 = stream->readSint32LE();
- _field_C0 = stream->readSint32LE();
+ _tickCount = stream->readUint32LE();
+ _tickCount2 = stream->readUint32LE();
+ _field_C0 = stream->readUint32LE();
_priority = stream->readSint32LE();
_actionListIdx = stream->readSint32LE();
@@ -133,26 +143,26 @@ void Object::disableAndRemoveFromQueue() {
// Visibility
//////////////////////////////////////////////////////////////////////////
bool Object::isOnScreen() {
- Common::Rect screenRect = Common::Rect(getWorld()->xLeft, getWorld()->yTop, getWorld()->xLeft + 640, getWorld()->yTop + 480);
+ Common::Rect screenRect = Common::Rect((int16)getWorld()->xLeft, (int16)getWorld()->yTop, (int16)(getWorld()->xLeft + 640), (int16)(getWorld()->yTop + 480));
Common::Rect objectRect = Common::Rect(_boundingRect);
- objectRect.translate(x, y);
+ objectRect.translate((int16)x, (int16)y);
return isVisible() && (flags & kObjectFlagEnabled) && screenRect.intersects(objectRect);
}
-bool Object::isVisible() {
+bool Object::isVisible() const {
if (flags & kObjectFlagEnabled) {
// Check each game flag
for (int32 i = 0; i < 10; i++) {
- GameFlag flag = _gameFlags[i];
+ int32 flag = _gameFlags[i];
bool ok = false;
if (flag <= 0)
ok = _vm->isGameFlagNotSet((GameFlag)-flag);
else
- ok = _vm->isGameFlagSet(flag);
+ ok = _vm->isGameFlagSet((GameFlag)flag);
if (!ok)
return false;
@@ -193,6 +203,9 @@ void Object::draw() {
}
void Object::update() {
+ if (_frameCount == 0)
+ error("[Object::update] Object has no frame!");
+
bool doPlaySounds = false;
if (_field_3C != 4)
@@ -254,8 +267,8 @@ void Object::update() {
if (_frameIndex < _frameCount - 1) {
if (_field_688 == 1) {
Common::Rect frameRect = GraphicResource::getFrameRect(_vm, _resourceId, _frameIndex);
- getScene()->setGlobalX(x + frameRect.left + (frameRect.width() >> 1));
- getScene()->setGlobalY(y + frameRect.top + (frameRect.height() >> 1));
+ getScene()->setGlobalX(x + frameRect.left + Common::Rational(frameRect.width(), 2).toInt());
+ getScene()->setGlobalY(y + frameRect.top + Common::Rational(frameRect.height(), 2).toInt());
}
} else {
flags &= ~kObjectFlag8;
@@ -273,7 +286,7 @@ void Object::update() {
++_frameIndex;
- if (_frameIndex <= 0) {
+ if (_frameIndex == 0) {
flags &= ~kObjectFlag10000;
if (_field_688 == 1) {
getScene()->setGlobalX(-1);
@@ -281,8 +294,8 @@ void Object::update() {
}
} else if (_field_688 == 1) {
Common::Rect frameRect = GraphicResource::getFrameRect(_vm, _resourceId, _frameIndex);
- getScene()->setGlobalX(x + frameRect.left + (frameRect.width() >> 1));
- getScene()->setGlobalY(y + frameRect.top + (frameRect.height() >> 1));
+ getScene()->setGlobalX(x + frameRect.left + Common::Rational(frameRect.width(), 2).toInt());
+ getScene()->setGlobalY(y + frameRect.top + Common::Rational(frameRect.height(), 2).toInt());
}
_tickCount = _vm->getTick();
@@ -351,8 +364,8 @@ void Object::playSounds() {
GraphicResource *resource = new GraphicResource(_vm, _resourceId);
if (LOBYTE(flags) & kObjectFlag4) {
- soundX = x + (resource->getFlags() >> 1);
- soundY = y + (resource->getFlags2() >> 1);
+ soundX = x + Common::Rational(resource->getFlags(), 2).toInt();
+ soundY = y + Common::Rational(resource->getFlags2(), 2).toInt();
} else {
// TODO _frameIndex here seems to be == _frameCount so something wrong somewhere!
/*GraphicFrame *frame = resource->getFrame(_frameIndex);
@@ -432,7 +445,7 @@ void Object::setVolume() {
Common::Rect frameRect = GraphicResource::getFrameRect(_vm, _resourceId, _frameIndex);
// Compute volume
- int32 volume = Config.voiceVolume + getSound()->calculateVolumeAdjustement((frameRect.width() >> 1) + x, (frameRect.height() >> 1) + y, _field_6A4, 0);
+ int32 volume = Config.voiceVolume + getSound()->calculateVolumeAdjustement(Common::Rational(frameRect.width(), 2).toInt() + x, Common::Rational(frameRect.height(), 2).toInt() + y, _field_6A4, 0);
if (volume < -10000)
volume = -10000;
@@ -443,7 +456,7 @@ ResourceId Object::getRandomResourceId() {
// Initialize random resource id array
ResourceId shuffle[5];
memset(&shuffle, 0, sizeof(shuffle));
- int32 count = 0;
+ uint32 count = 0;
for (int32 i = 0; i < 5; i++) {
if (_randomResourceIds[i]) {
@@ -462,7 +475,7 @@ ResourceId Object::getRandomResourceId() {
return id;
}
-bool Object::checkFlags() {
+bool Object::checkFlags() const {
return (flags & kObjectFlagEnabled) && (flags & kObjectFlag8 || flags & kObjectFlag10000);
}
@@ -472,7 +485,7 @@ Common::String Object::toString(bool shortString) {
output += Common::String::format("Object %d: %s\n", _id, _name);
if (!shortString) {
- output += Common::String::format(" resourceId: %u (0x%X) - (pack %d - index %d)\n", _resourceId, _resourceId, (_resourceId >> 16) & 0x7FFF, (int16)_resourceId);
+ output += Common::String::format(" resourceId: %u (0x%X) - (pack %d - index %d)\n", _resourceId, _resourceId, RESOURCE_PACK(_resourceId), RESOURCE_INDEX(_resourceId));
output += Common::String::format(" x: %d\n", x);
output += Common::String::format(" y: %d\n", y);
output += Common::String::format(" flags: %d\n", flags);
diff --git a/engines/asylum/resources/object.h b/engines/asylum/resources/object.h
index bda2ae0c1e..3195b37b0d 100644
--- a/engines/asylum/resources/object.h
+++ b/engines/asylum/resources/object.h
@@ -48,7 +48,7 @@ public:
//////////////////////////////////////////////////////////////////////////
int32 x;
int32 y;
- int32 flags;
+ uint32 flags;
int32 actionType;
void setFrameIndex(int32 index) { _frameIndex = index; }
@@ -141,7 +141,7 @@ public:
*
* @return true if it succeeds, false if it fails.
*/
- bool checkFlags();
+ bool checkFlags() const;
/**
* Convert this object into a string representation.
@@ -176,11 +176,11 @@ private:
Common::Rect _rect;
int32 _polygonIndex;
// actionType
- GameFlag _gameFlags[10];
+ int32 _gameFlags[10];
int32 _field_B4;
uint32 _tickCount;
uint32 _tickCount2;
- int32 _field_C0;
+ uint32 _field_C0;
int32 _priority;
int32 _actionListIdx;
SoundItem _soundItems[16];
@@ -198,7 +198,7 @@ private:
*
* @return true if visible, false if not.
*/
- bool isVisible();
+ bool isVisible() const;
/**
* Play object sounds
diff --git a/engines/asylum/resources/worldstats.cpp b/engines/asylum/resources/worldstats.cpp
index e2de9cfb8b..5634e9892f 100644
--- a/engines/asylum/resources/worldstats.cpp
+++ b/engines/asylum/resources/worldstats.cpp
@@ -204,9 +204,9 @@ void WorldStats::load(Common::SeekableReadStream *stream) {
numAmbientSound = stream->readSint32LE();
musicStatus = stream->readSint32LE();
- musicCurrentResourceIndex = (ResourceId)stream->readSint32LE();
+ musicCurrentResourceIndex = stream->readUint32LE();
musicFlag = stream->readSint32LE();
- musicResourceId = (ResourceId)stream->readSint32LE();
+ musicResourceId = (ResourceId)stream->readUint32LE();
musicStatusExt = stream->readSint32LE();
for (uint32 a = 0; a < numObjects; a++) {
diff --git a/engines/asylum/shared.h b/engines/asylum/shared.h
index b08c09c501..1c7c38027f 100644
--- a/engines/asylum/shared.h
+++ b/engines/asylum/shared.h
@@ -166,7 +166,9 @@ enum ResourcePackId {
#define MAKE_RESOURCE(pack, index) (ResourceId)((((pack) << 16) + 0x80000000) + (uint32)(index))
-enum ResourceId {
+typedef unsigned int ResourceId;
+
+enum ResourcesId {
kResourceNone = 0
};
@@ -539,7 +541,7 @@ enum ObjectFlag {
// Resource ID macros
//////////////////////////////////////////////////////////////////////////
#define RESOURCE_PACK(id) (ResourcePackId)((((uint32)id) >> 16) & 0x7FFF)
-#define RESOURCE_INDEX(id) (int16)(id)
+#define RESOURCE_INDEX(id) (uint16)(id)
} // End of namespace Asylum
diff --git a/engines/asylum/system/graphics.h b/engines/asylum/system/graphics.h
index 22f75d4aa2..02c520ba68 100644
--- a/engines/asylum/system/graphics.h
+++ b/engines/asylum/system/graphics.h
@@ -74,6 +74,7 @@ public:
GraphicFrame *getFrame(uint32 frame);
ResourceId getResourceId() { return _resourceId; }
+ // FIXME: flags are coordinates for the sound origin!
int32 getFlags() { return _flags; }
int32 getFlags2() { return _flags2; }
uint32 count() { return _frames.size(); }
diff --git a/engines/asylum/system/screen.cpp b/engines/asylum/system/screen.cpp
index 790857f2a4..d05640c718 100644
--- a/engines/asylum/system/screen.cpp
+++ b/engines/asylum/system/screen.cpp
@@ -127,9 +127,9 @@ void Screen::setPalette(byte *rgbPalette) const {
p += 3;
for (int32 i = 1; i < 256; i++) {
- palette[i * 4 + 0] = *p++ << 2;
- palette[i * 4 + 1] = *p++ << 2;
- palette[i * 4 + 2] = *p++ << 2;
+ palette[i * 4 + 0] = (byte)(*p++ << 2);
+ palette[i * 4 + 1] = (byte)(*p++ << 2);
+ palette[i * 4 + 2] = (byte)(*p++ << 2);
palette[i * 4 + 3] = 0;
}
diff --git a/engines/asylum/system/sound.h b/engines/asylum/system/sound.h
index 5f3ecfcdff..2f5bb18b9f 100644
--- a/engines/asylum/system/sound.h
+++ b/engines/asylum/system/sound.h
@@ -46,6 +46,12 @@ struct SoundItem {
int32 field_8;
int32 field_C;
+ SoundItem() {
+ resourceId = kResourceNone;
+ field_4 = 0;
+ field_8 = 0;
+ field_C = 0;
+ }
};
struct FrameSoundItem {
@@ -56,6 +62,14 @@ struct FrameSoundItem {
int32 field_10;
int32 field_14;
+ FrameSoundItem() {
+ resourceId = kResourceNone;
+ frameIndex = 0;
+ index = 0;
+ field_C = 0;
+ field_10 = 0;
+ field_14 = 0;
+ }
};
struct AmbientSoundItem {
diff --git a/engines/asylum/views/blowuppuzzle.cpp b/engines/asylum/views/blowuppuzzle.cpp
index cd78f6b42a..19c4bfc0fa 100644
--- a/engines/asylum/views/blowuppuzzle.cpp
+++ b/engines/asylum/views/blowuppuzzle.cpp
@@ -41,32 +41,34 @@
namespace Asylum {
-BlowUpPuzzle::BlowUpPuzzle(AsylumEngine *engine): _vm(engine) {
+BlowUpPuzzle::BlowUpPuzzle(AsylumEngine *engine): _vm(engine), _ev(NULL),
+ _leftClickUp(false), _leftClickDown(false), _rightClickDown(false), _active(false) {
+
+ // setup cursor & background
+ _cursor = new Cursor(_vm);
+ _bgResource = new GraphicResource(_vm, getWorld()->graphicResourceIds[0]);
}
BlowUpPuzzle::~BlowUpPuzzle() {
+ delete _cursor;
+ delete _bgResource;
+ // Zero passed pointers
+ _vm = NULL;
+ _ev = NULL;
}
// BlowUp Puzzle VCR ---------------------------------------------------------------------------------------------
BlowUpPuzzleVCR::BlowUpPuzzleVCR(AsylumEngine *engine): BlowUpPuzzle(engine) {
- _leftClickUp = false;
- _leftClickDown = false;
- _rightClickDown = false;
- _active = false;
- _bgResource = new GraphicResource(_vm, getWorld()->graphicResourceIds[0]);
- _tvScreenAnimIdx = 0;
- _isAccomplished = false;
-
- // setup cursor
- _cursor = new Cursor(_vm);
-
// reset all states
memset(&_jacksState, 0, sizeof(_jacksState));
memset(&_holesState, 0, sizeof(_holesState));
memset(&_buttonsState, 0, sizeof(_buttonsState));
+
+ _tvScreenAnimIdx = 0;
+ _isAccomplished = false;
}
BlowUpPuzzleVCR::~BlowUpPuzzleVCR() {
@@ -129,7 +131,7 @@ void BlowUpPuzzle::playSound(ResourceId resourceId, bool loop) {
getSound()->playSound(resourceId, loop, Config.sfxVolume, 0);
}
-int BlowUpPuzzleVCR::inPolyRegion(int x, int y, int polyIdx) {
+int BlowUpPuzzleVCR::inPolyRegion(int x, int y, int polyIdx) const {
return x >= BlowUpPuzzleVCRPolies[polyIdx].left && x <= BlowUpPuzzleVCRPolies[polyIdx].right &&
y >= BlowUpPuzzleVCRPolies[polyIdx].top && y <= BlowUpPuzzleVCRPolies[polyIdx].bottom;
}
@@ -173,7 +175,7 @@ void BlowUpPuzzleVCR::update() {
if (_isAccomplished) {
getScreen()->drawGraphicsInQueue();
- int barSize = 0;
+ int16 barSize = 0;
do {
getScreen()->drawWideScreen(barSize);
barSize += 4;
@@ -223,7 +225,7 @@ GraphicQueueItem BlowUpPuzzleVCR::getGraphicShadowItem() {
return shadowItem;
}
-void BlowUpPuzzleVCR::updateJack(Jack jack, VCRDrawInfo onTable, VCRDrawInfo pluggedOnRed, VCRDrawInfo pluggedOnYellow, VCRDrawInfo pluggedOnBlack, int32 resourceOnHandIndex) {
+void BlowUpPuzzleVCR::updateJack(Jack jack, const VCRDrawInfo &onTable, const VCRDrawInfo &pluggedOnRed, const VCRDrawInfo &pluggedOnYellow, const VCRDrawInfo &pluggedOnBlack, int32 resourceOnHandIndex) {
GraphicQueueItem item;
switch (_jacksState[jack]) {
@@ -349,7 +351,7 @@ int BlowUpPuzzleVCR::setJackOnHole(int jackType, JackState plugged) {
return 1;
}
-void BlowUpPuzzleVCR::updateButton(Button button, VCRDrawInfo btON, VCRDrawInfo btDown) {
+void BlowUpPuzzleVCR::updateButton(Button button, const VCRDrawInfo &btON, const VCRDrawInfo &btDown) {
GraphicQueueItem item;
switch (_buttonsState[button]) {
@@ -505,13 +507,14 @@ void BlowUpPuzzleVCR::handleMouseDown() {
if (inPolyRegion(_cursor->position().x, _cursor->position().y, kBlackHole)) {
if (!setJackOnHole(jackType, kPluggedOnBlack)) {
// TODO: this will probably segfault!
- if (_holesState[kBlackHole] != kPluggedOnYellow && _buttonsState[kPower] == 1) {
+ error("[BlowUpPuzzleVCR::handleMouseDown] Not implemented!");
+ /*if (_holesState[kBlackHole] != kPluggedOnYellow && _buttonsState[kPower] == 1) {
_buttonsState[kPower] = kOFF;
_buttonsState[kStop] = kOFF;
_buttonsState[kPlay] = kOFF;
_buttonsState[kRewind] = kOFF;
}
- return;
+ return;*/
}
}
@@ -571,7 +574,7 @@ void BlowUpPuzzleVCR::handleMouseDown() {
} else if (inPolyRegion(_cursor->position().x, _cursor->position().y, kPowerButton)) {
playSound(getWorld()->graphicResourceIds[39]);
- if (!_buttonsState[kPower] && _holesState[kPluggedOnBlack-1] == kBlack + 1 && _holesState[kPluggedOnRed-1] && _holesState[kPluggedOnYellow-1]) {
+ if (!_buttonsState[kPower] && _holesState[kPluggedOnYellow] == kRed && _holesState[kOnTable] && _holesState[kPluggedOnRed]) {
_buttonsState[kPower] = kDownON;
} else {
_buttonsState[kPower] = kDownOFF;
@@ -606,7 +609,7 @@ void BlowUpPuzzleVCR::handleMouseUp() {
if (_buttonsState[kPlay] == kDownOFF) {
_buttonsState[kPlay] = kON;
- if (_holesState[kPluggedOnRed-1] == kRed + 1 && _holesState[kPluggedOnYellow-1] == kYellow + 1 && _holesState[kPluggedOnBlack-1] == kBlack + 1) {
+ if (_holesState[kOnTable] == kYellow && _holesState[kPluggedOnRed] == kYellow + 1 /*FIXME this is not a proper value */ && _holesState[kPluggedOnYellow] == kRed) {
_vm->setGameFlag(kGameFlagSolveVCRBlowUpPuzzle);
_isAccomplished = true;
}
diff --git a/engines/asylum/views/blowuppuzzle.h b/engines/asylum/views/blowuppuzzle.h
index 089a2d19e0..fef652eb89 100644
--- a/engines/asylum/views/blowuppuzzle.h
+++ b/engines/asylum/views/blowuppuzzle.h
@@ -58,13 +58,13 @@ protected:
Common::Event *_ev;
Cursor *_cursor;
+ GraphicResource *_bgResource;
+
bool _leftClickUp;
bool _leftClickDown;
bool _rightClickDown;
bool _active;
- GraphicResource *_bgResource;
-
virtual void update() {};
void playSound(ResourceId resourceId, bool loop = false);
@@ -145,10 +145,10 @@ private:
int _jacksState[3];
int _holesState[3];
int _buttonsState[4];
- int _tvScreenAnimIdx;
+ uint32 _tvScreenAnimIdx;
bool _isAccomplished;
- int inPolyRegion(int x, int y, int polyIdx);
+ int inPolyRegion(int x, int y, int polyIdx) const;
void update();
@@ -156,13 +156,13 @@ private:
GraphicQueueItem getGraphicJackItem(int32 index);
GraphicQueueItem getGraphicShadowItem();
- void updateJack(Jack jack, VCRDrawInfo onTable, VCRDrawInfo pluggedOnRed, VCRDrawInfo pluggedOnYellow, VCRDrawInfo pluggedOnBlack, int32 resourceOnHandIndex);
+ void updateJack(Jack jack, const VCRDrawInfo &onTable, const VCRDrawInfo &pluggedOnRed, const VCRDrawInfo &pluggedOnYellow, const VCRDrawInfo &pluggedOnBlack, int32 resourceOnHandIndex);
void updateBlackJack();
void updateRedJack();
void updateYellowJack();
int setJackOnHole(int jackType, JackState plugged);
- void updateButton(Button button, VCRDrawInfo btON, VCRDrawInfo btDown);
+ void updateButton(Button button, const VCRDrawInfo &btON, const VCRDrawInfo &btDown);
void updatePowerButton();
void updateRewindButton();
void updatePlayButton();
Commit: 5186ad942592a0e8ccd17b2d0c28c8307c5817ba
https://github.com/scummvm/scummvm/commit/5186ad942592a0e8ccd17b2d0c28c8307c5817ba
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:19+02:00
Commit Message:
ASYLUM: Moved shared data to new structure
Some flags have a longer lifetime and should not be part of the scene instance.
Those are now part of the SharedData structure.
Also implements several actor::updateStatus methods, using the new shared data
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@548 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
A engines/asylum/data.h
engines/asylum/asylum.cpp
engines/asylum/asylum.h
engines/asylum/resources/actionlist.cpp
engines/asylum/resources/actor.cpp
engines/asylum/resources/actor.h
engines/asylum/resources/encounters.cpp
engines/asylum/resources/encounters.h
engines/asylum/resources/object.cpp
engines/asylum/resources/special.cpp
engines/asylum/resources/worldstats.cpp
engines/asylum/resources/worldstats.h
engines/asylum/shared.h
engines/asylum/system/sound.cpp
engines/asylum/views/scene.cpp
engines/asylum/views/scene.h
diff --git a/engines/asylum/asylum.cpp b/engines/asylum/asylum.cpp
index 49404fbd43..9be3edf461 100644
--- a/engines/asylum/asylum.cpp
+++ b/engines/asylum/asylum.cpp
@@ -56,9 +56,6 @@ AsylumEngine::AsylumEngine(OSystem *system, const ADGameDescription *gd) : Engin
// Init data
memset(&_gameFlags, 0, sizeof(_gameFlags));
- memset(&_flags, 0, sizeof(_flags));
- screenUpdatesCount = 0;
- globalTickValue_2 = 0;
// Add default search directories
const Common::FSNode gameDataDir(ConfMan.get("path"));
@@ -123,7 +120,7 @@ Common::Error AsylumEngine::run() {
// FIXME: remove
_introPlaying = false;
- // TODO: save dialogue key codes into sntrm_k.txt (need to figure out why they use such thing) (address 00411CD0)
+ // TODO: save dialog key codes into sntrm_k.txt (need to figure out why they use such thing) (address 00411CD0)
// load startup configurations (.text:0041A970)
Config.read();
// TODO: init unknown game stuffs (.text:0040F430)
@@ -386,8 +383,4 @@ bool AsylumEngine::isGameFlagNotSet(GameFlag flag) const {
return ((1 << (flag % FLAG_MASK)) & (unsigned int)_gameFlags[flag / 32]) >> (flag % FLAG_MASK) == 0;
}
-void AsylumEngine::setFlag(FlagType flag, bool isSet) {
- _flags[flag] = isSet;
-}
-
} // namespace Asylum
diff --git a/engines/asylum/asylum.h b/engines/asylum/asylum.h
index 8af2b5fc81..8ca99e88d1 100644
--- a/engines/asylum/asylum.h
+++ b/engines/asylum/asylum.h
@@ -27,6 +27,7 @@
#define ASYLUM_ENGINE_H
#include "asylum/console.h"
+#include "asylum/data.h"
#include "asylum/shared.h"
#include "common/random.h"
@@ -61,15 +62,6 @@ namespace Asylum {
// If defined, will show the scene update times on the debugger output
//#define DEBUG_SCENE_TIMES
-//////////////////////////////////////////////////////////////////////////
-// Flags
-enum FlagType {
- kFlagType1 = 0,
- kFlagType2,
- kFlagTypeSkipDraw,
- kFlagTypeSceneRectChanged
-};
-
class Cursor;
class Encounter;
class MainMenu;
@@ -112,16 +104,23 @@ public:
*/
void switchScene(ResourcePackId sceneId) { startGame(sceneId, kStartGameScene); }
- /**
+ /**
* Wrapper function to the OSystem getMillis() method
- */
+ */
uint32 getTick() { return _system->getMillis(); }
+ /**
+ * Gets the shared data.
+ *
+ * @return a pointer to the shared data.
+ */
+ SharedData *getData() { return &_data; }
+
/**
* This is the global tick counter.
*/
- uint32 screenUpdatesCount;
- uint32 globalTickValue_2;
+ uint32 screenUpdateCount;
+ uint32 lastScreenUpdate;
// Game
Cursor *cursor() { return _cursor; }
@@ -145,10 +144,6 @@ public:
uint getRandom(uint max) { return _rnd.getRandomNumber(max); }
uint getRandomBit() { return _rnd.getRandomBit(); }
- // Flags
- void setFlag(FlagType flag) { setFlag(flag, true); }
- void clearFlag(FlagType flag) { setFlag(flag, false); }
-
// Message handler
void switchMessageHandler(MessageHandler *handler);
MessageHandler *getMessageHandler(uint32 index);
@@ -171,9 +166,11 @@ private:
Text *_text;
Video *_video;
+ // Shared game data
+ SharedData _data;
+
bool _introPlaying;
int _gameFlags[1512];
- bool _flags[4];
void handleEvents(bool doUpdate);
void waitForTimer(uint32 msec_delay);
@@ -185,8 +182,6 @@ private:
*/
void playIntro();
- void setFlag(FlagType flag, bool isSet);
-
friend class Console;
};
diff --git a/engines/asylum/data.h b/engines/asylum/data.h
new file mode 100644
index 0000000000..de068271ec
--- /dev/null
+++ b/engines/asylum/data.h
@@ -0,0 +1,326 @@
+/* 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.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#ifndef ASYLUM_DATA_H
+#define ASYLUM_DATA_H
+
+#include "engines/asylum/shared.h"
+
+#include "common/rational.h"
+
+namespace Asylum {
+
+//////////////////////////////////////////////////////////////////////////
+// Flags
+enum GlobalFlag {
+ kFlag1,
+ kFlag2,
+ kFlagSkipDraw,
+ kFlagSceneRectChanged,
+ kFlagScene1,
+ kFlagEncounter2,
+ kFlagEncounter3,
+ kFlagEncounter5
+};
+
+/**
+ * Shared data
+ * -----------
+ * uint32 {1} - actorEnableForStatus7
+ *
+ * uint32 {1} - global direction
+ * uint32 {1} - lastScreenUpdate
+ *
+ * uint32 {1} - actor update counter
+ *
+ * uint32 {1} - matte bar height
+ *
+ * Lots of data
+ *
+ * -- Scene data (reset on scene load)
+ * uint32 {16} - ambient sound panning array
+ * uint32 {1} - scene counter
+ * -- Script queue (stored in ActionList - reset on scene change)
+ * uint32 {1} - global Object X
+ * uint32 {1} - global Object Y
+ * -- Skip processing flag (stored in ActionList)
+ * uint32 {1} - Encounter flag 2
+ * -- Player ActorIndex (reset on scene enter)
+ * uint32 {1} - scene xLeft
+ * uint32 {1} - scene yTop
+ * uint32 {1} - scene offset
+ * uint32 {1} - scene offsetAdd
+ * -- UNUSED ??
+ * uint32 {13} - cursor resources
+ * uint32 {3} - scene fonts (3)
+ * uint32 {1} - current palette Id
+ * uint32 {3} - cellshade masks (3)
+ * uint32 {1} - small cursor Up
+ * uint32 {1} - small cursor Down
+ * uint32 {1} - Encounter frame background
+ * uint32 {1} - Flag skip draw scene
+ * uint32 {1} - matte var 1
+ * uint32 {1} - actorUpdateEnabledCheck
+ * uint32 {1} - matte Initialized
+ * uint32 {1} - matte playSound
+ * uint32 {1} - currentScreenUpdatesCount
+ * uint32 {50} - Actor data
+ * uint32 {11} - UNUSED ?? (Actor data 2)
+ * uint32 {1} - actorUpdateEnabledCounter
+ * uint32 {9} - Actor data 3
+ * uint32 {1} - Encounter flag 5
+ * uint32 {1} - Scene flag 1
+ * uint32 {1} - nextScreenUpdate
+ * uint32 {49} - Viewed movies
+ * uint32 {1} - actorUpdateStatus15Check
+ * -- Skip opening movie command line flag (not used)
+ * uint32 {1} - Encounter flag 3
+ * uint32 {1} - Flag 2
+ * uint32 {1} - Flag 5
+ * -- scripts (reset on scene load)
+ * -- polygons (reset on scene load)
+ */
+struct SharedData {
+public:
+ SharedData() {
+ _actorEnableForStatus7 = false;
+ _flag1 = false;
+ _actorUpdateCounter = 0;
+ _matteBarHeight = 0;
+ _matteVar2 = 0;
+ _sceneCounter = 0;
+ _globalX = 0;
+ _globalY = 0;
+ _flagEncouter2 = false;
+ _sceneXLeft = 0;
+ _sceneYTop = 0;
+ _sceneOffset = 0;
+ _sceneOffsetAdd;
+ memset(&_cursorResources[13], kResourceNone, sizeof(_cursorResources));
+ memset(&_sceneFonts[3], kResourceNone, sizeof(_sceneFonts));
+ _currentPaletteId = kResourceNone;
+ memset(&_cellShadeMasks[3], 0, sizeof(_cellShadeMasks));
+ _smallCurUp = 0;
+ _smallCurDown = 0;
+ _encounterFrameBg = 0;
+ _flagSkipDrawScene = false;
+ _matteVar1 = 0;
+ _actorUpdateEnabledCheck = false;
+ _matteInitialized = false;
+ _mattePlaySound = false;
+ _currentScreenUpdatesCount = 0;
+ memset(&_data1[50], 0, sizeof(_data1));
+ memset(&_data2[11], 0, sizeof(_data2));
+ _actorUpdateStatusEnabledCounter = 0;
+ memset(&_data3[9], 0, sizeof(_data3));
+ _flagEncouter5 = false;
+ _flagScene1 = false;
+ _nextScreenUpdate = 0;
+ memset(&_movies[49], 0, sizeof(_movies));
+ _actorUpdateStatus15Check = false;
+ _flagEncouter3 = false;
+ _flag2 = false;
+ _flag5 = false;
+ }
+ // Accessors
+ int32 getActorUpdateEnabledCounter() { return _actorUpdateStatusEnabledCounter; }
+ void setActorUpdateEnabledCounter(int32 val) { _actorUpdateStatusEnabledCounter = val; }
+
+ int32 *nextScreenUpdate() { return &_nextScreenUpdate; }
+
+ bool getActorEnableForStatus7() { return _actorEnableForStatus7; }
+ void setActorEnableForStatus7(bool state) { _actorEnableForStatus7 = state; }
+
+ bool getActorUpdateEnabledCheck() { return _actorUpdateEnabledCheck; }
+
+ void setActorUpdateFlag(int32 val) { _data1[40] = 2; }
+
+ int32 getUpdateCounter() { return _actorUpdateCounter; }
+ void setUpdateCounter(int32 val) { _actorUpdateCounter = val; }
+
+ int32 getActorUpdateFlag2() { return _data1[36]; }
+ void setActorUpdateFlag2(int32 val) { _data1[36] = val; }
+
+ bool getSkipDrawScene() { return _flagSkipDrawScene; }
+ void setSkipDrawScene(bool skip) { _flagSkipDrawScene = skip; }
+
+ // Shared global Data
+ int32 getGlobalX() const { return _globalX; }
+ void setGlobalX(int32 val) { _globalX = val; }
+ int32 getGlobalY() const { return _globalY; }
+ void setGlobalY(int32 val) { _globalY = val; }
+
+ int32 getMatteBarHeight() { return _matteBarHeight;}
+ void setMatteBarHeight(int32 val) { _matteBarHeight = val; }
+
+ int32 getMatteVar1() { return _matteVar1; }
+ void setMatteVar1(int32 val) { _matteVar1 = val; }
+
+ int32 getMatteVar2() { return _matteVar2; }
+ void setMatteVar2(int32 val) { _matteVar2 = val; }
+
+ bool getMatteInitialized() { return _matteInitialized; }
+ void setMatteInitialized(bool state) { _matteInitialized = state; }
+
+ bool getMattePlaySound() { return _mattePlaySound; }
+ void setMattePlaySound(bool state) { _mattePlaySound = state; }
+
+ // Scene
+ void setSceneXLeft(int32 val) { _sceneXLeft = val; }
+ void setSceneYTop(int32 val) { _sceneYTop = val; }
+ void setSceneOffset(int32 val) { _sceneOffset = val; }
+ void setSceneOffsetAdd(const Common::Rational &offset) { _sceneOffsetAdd = offset; }
+
+ //////////////////////////////////////////////////////////////////////////
+ // Flags
+ //////////////////////////////////////////////////////////////////////////
+ bool getFlag(GlobalFlag flag) const {
+ switch (flag) {
+ default:
+ error("[SharedData::getFlag] Invalid flag type (%d)!", flag);
+
+ case kFlag1:
+ return _flag1;
+
+ case kFlag2:
+ return _flag2;
+
+ case kFlagSkipDraw:
+ return _flagSkipDrawScene;
+
+ case kFlagSceneRectChanged:
+ error("[SharedData::getFlag] Invalid flag type (kFlagSceneRectChanged)!");
+
+ case kFlagScene1:
+ return _flagScene1;
+
+ case kFlagEncounter2:
+ return _flagEncouter2;
+
+ case kFlagEncounter3:
+ return _flagEncouter3;
+
+ case kFlagEncounter5:
+ return _flagEncouter5;
+ }
+ }
+
+ void setFlag(GlobalFlag flag, bool state) {
+ switch (flag) {
+ default:
+ error("[SharedData::getFlag] Invalid flag type (%d)!", flag);
+
+ case kFlag1:
+ _flag1 = state;
+ break;
+
+ case kFlag2:
+ _flag2 = state;
+ break;
+
+ case kFlagSkipDraw:
+ _flagSkipDrawScene = state;
+ break;
+
+ case kFlagSceneRectChanged:
+ error("[SharedData::getFlag] Invalid flag type (kFlagSceneRectChanged)!");
+ break;
+
+ case kFlagScene1:
+ _flagScene1 = state;
+ break;
+
+ case kFlagEncounter2:
+ _flagEncouter2 = state;
+ break;
+
+ case kFlagEncounter3:
+ _flagEncouter3 = state;
+ break;
+
+ case kFlagEncounter5:
+ _flagEncouter5 = state;
+ break;
+ }
+ }
+
+private:
+
+
+ bool _actorEnableForStatus7;
+
+ bool _flag1;
+
+ uint32 _actorUpdateCounter;
+ uint32 _matteBarHeight;
+ uint32 _matteVar2;
+
+ // Lots of other data
+
+ // TODO Add ambient sound panning array
+ uint32 _sceneCounter;
+ int32 _globalX;
+ int32 _globalY;
+ bool _flagEncouter2;
+ int32 _sceneXLeft;
+ int32 _sceneYTop;
+ int32 _sceneOffset;
+ Common::Rational _sceneOffsetAdd;
+
+ // Saved scene data
+ ResourceId _cursorResources[13];
+ ResourceId _sceneFonts[3];
+ ResourceId _currentPaletteId;
+ int32 _cellShadeMasks[3];
+ // unused
+ int32 _smallCurUp;
+ int32 _smallCurDown;
+ int32 _encounterFrameBg;
+
+
+ bool _flagSkipDrawScene;
+ int32 _matteVar1;
+ bool _actorUpdateEnabledCheck;
+ bool _matteInitialized;
+ bool _mattePlaySound;
+ int32 _currentScreenUpdatesCount;
+ int32 _data1[50];
+ int32 _data2[11];
+ bool _actorUpdateStatusEnabledCounter;
+ int32 _data3[9];
+ bool _flagEncouter5;
+ bool _flagScene1;
+ int32 _nextScreenUpdate;
+ int32 _movies[49];
+ bool _actorUpdateStatus15Check;
+ // Skip opening flag (not used)
+ bool _flagEncouter3;
+ bool _flag2;
+ bool _flag5;
+};
+
+} // End of namespace Asylum
+
+#endif // ASYLUM_DATA_H
diff --git a/engines/asylum/resources/actionlist.cpp b/engines/asylum/resources/actionlist.cpp
index 0bdc6ecb55..7f0a7c0409 100644
--- a/engines/asylum/resources/actionlist.cpp
+++ b/engines/asylum/resources/actionlist.cpp
@@ -350,7 +350,7 @@ END_OPCODE
IMPLEMENT_OPCODE(ShowCursor)
getCursor()->show();
- _vm->clearFlag(kFlagType1);
+ getSharedData()->setFlag(kFlag1, false);
END_OPCODE
//////////////////////////////////////////////////////////////////////////
@@ -385,13 +385,13 @@ IMPLEMENT_OPCODE(PlayAnimation)
if (object->getField688() == 1) {
if (object->flags & kObjectFlag4) {
- getScene()->setGlobalX(object->x);
- getScene()->setGlobalY(object->y);
+ getSharedData()->setGlobalX(object->x);
+ getSharedData()->setGlobalY(object->y);
} else {
Common::Rect frameRect = GraphicResource::getFrameRect(_vm, object->getResourceId(), object->getFrameIndex());
- getScene()->setGlobalX(frameRect.left + Common::Rational(frameRect.width(), 2).toInt() + object->x);
- getScene()->setGlobalY(frameRect.top + Common::Rational(frameRect.height(), 2).toInt() + object->y);
+ getSharedData()->setGlobalX(frameRect.left + Common::Rational(frameRect.width(), 2).toInt() + object->x);
+ getSharedData()->setGlobalY(frameRect.top + Common::Rational(frameRect.height(), 2).toInt() + object->y);
}
}
@@ -481,7 +481,7 @@ IMPLEMENT_OPCODE(EnableActor)
Actor *actor = getScene()->getActor(cmd->param1);
if (actor->getStatus() == kActorStatusDisabled)
- actor->updateStatus(kActorStatusEnabled);
+ actor->enable();
END_OPCODE
//////////////////////////////////////////////////////////////////////////
@@ -709,10 +709,10 @@ END_OPCODE
IMPLEMENT_OPCODE(RunEncounter)
Encounter *encounter = _vm->encounter();
- encounter->setFlag(kEncounterFlag5, cmd->param5);
+ getSharedData()->setFlag(kFlagEncounter5, cmd->param5);
if (cmd->param6) {
- if (encounter->getFlag(kEncounterFlag2))
+ if (getSharedData()->getFlag(kFlagEncounter2))
_lineIncrement = 1;
else
cmd->param6 = 0;
@@ -799,7 +799,7 @@ IMPLEMENT_OPCODE(_unk2C_ActorSub)
return;
case kActorStatus7:
- actor->updateStatus(kActorStatusEnabled);
+ actor->enable();
break;
case kActorStatus16:
@@ -845,17 +845,17 @@ END_OPCODE
//////////////////////////////////////////////////////////////////////////
// Opcode 0x2D
IMPLEMENT_OPCODE(PlayMovie)
- if (getScene()->matteBarHeight < 170) {
+ if (getSharedData()->getMatteBarHeight() < 170) {
_lineIncrement = 1;
- if (!getScene()->matteBarHeight) {
+ if (!getSharedData()->getMatteBarHeight()) {
getCursor()->hide();
getScene()->makeGreyPalette();
- getScene()->matteVar1 = 1;
- getScene()->matteBarHeight = 1;
- getScene()->matteVar2 = 0;
- getScene()->mattePlaySound = (cmd->param3 == 0);
- getScene()->matteInitialized = (cmd->param2 == 0);
+ getSharedData()->setMatteVar1(1);
+ getSharedData()->setMatteBarHeight(1);
+ getSharedData()->setMatteVar2(0);
+ getSharedData()->setMattePlaySound(cmd->param3 == 0);
+ getSharedData()->setMatteInitialized(cmd->param2 == 0);
_delayedVideoIndex = cmd->param1;
}
@@ -872,10 +872,10 @@ IMPLEMENT_OPCODE(PlayMovie)
getScreen()->setGammaLevel(getWorld()->currentPaletteId, 0);
}
- getScene()->matteBarHeight = 0;
+ getSharedData()->setMatteBarHeight(0);
_lineIncrement = 0;
- if (!getScene()->mattePlaySound && _currentScript->commands[0].numLines != 0) {
+ if (!getSharedData()->getMattePlaySound() && _currentScript->commands[0].numLines != 0) {
bool found = true;
int index = 0;
@@ -893,11 +893,11 @@ IMPLEMENT_OPCODE(PlayMovie)
check = true;
}
- if (!check && getScene()->matteVar2 == 0 && getWorld()->musicCurrentResourceIndex != kMusicStopped)
+ if (!check && getSharedData()->getMatteVar2() == 0 && getWorld()->musicCurrentResourceIndex != kMusicStopped)
_vm->sound()->playMusic(MAKE_RESOURCE(kResourcePackMusic, getWorld()->musicCurrentResourceIndex));
getCursor()->show();
- getScene()->matteVar2 = 0;
+ getSharedData()->setMatteVar2(0);
END_OPCODE
//////////////////////////////////////////////////////////////////////////
@@ -925,7 +925,7 @@ END_OPCODE
IMPLEMENT_OPCODE(ResetSceneRect)
getWorld()->sceneRectIdx = (uint8)LOBYTE(cmd->param1);
getScreen()->paletteFade(0, 25, 10);
- _vm->setFlag(kFlagTypeSceneRectChanged);
+ getSharedData()->setFlag(kFlagSceneRectChanged, true);
getWorld()->xLeft = getWorld()->sceneRects[getWorld()->sceneRectIdx].left;
getWorld()->yTop = getWorld()->sceneRects[getWorld()->sceneRectIdx].top;
@@ -1074,7 +1074,7 @@ IMPLEMENT_OPCODE(UpdateWideScreen)
cmd->param1 = 0;
_lineIncrement = 0;
- getScene()->matteBarHeight = 0;
+ getSharedData()->setMatteBarHeight(0);
} else {
getScreen()->drawWideScreen((int16)(4 * barSize));
@@ -1087,7 +1087,7 @@ END_OPCODE
//////////////////////////////////////////////////////////////////////////
// Opcode 0x3F
IMPLEMENT_OPCODE(JumpIfActor)
- ActorIndex index = (cmd->param1 == kActorInvalid) ? getScene()->getPlayerActorIndex() : cmd->param1;
+ ActorIndex index = (cmd->param1 == kActorInvalid) ? getScene()->getPlayerIndex() : cmd->param1;
if (_currentQueueEntry.actorIndex != index)
_currentLine = cmd->param2 - 1;
@@ -1106,8 +1106,8 @@ IMPLEMENT_OPCODE(PlaySpeechScene)
_vm->setGameFlag(kGameFlagScriptProcessing);
cmd->param4 = 2;
if (cmd->param6) {
- _vm->setFlag(kFlagType1);
- _vm->setFlag(kFlagType2);
+ getSharedData()->setFlag(kFlag1, true);
+ getSharedData()->setFlag(kFlag2, true);
}
_lineIncrement = 1;
}
@@ -1128,8 +1128,8 @@ IMPLEMENT_OPCODE(PlaySpeechScene)
if (cmd->param3) {
if (cmd->param6) {
- _vm->clearFlag(kFlagType1);
- _vm->clearFlag(kFlagType2);
+ getSharedData()->setFlag(kFlag1, false);
+ getSharedData()->setFlag(kFlag2, false);
return;
} else {
@@ -1140,8 +1140,8 @@ IMPLEMENT_OPCODE(PlaySpeechScene)
if (!cmd->param6) {
cmd->param6 = 1;
} else {
- _vm->clearFlag(kFlagType1);
- _vm->clearFlag(kFlagType2);
+ getSharedData()->setFlag(kFlag1, false);
+ getSharedData()->setFlag(kFlag2, false);
}
END_OPCODE
@@ -1158,8 +1158,8 @@ IMPLEMENT_OPCODE(PlaySpeech)
_vm->setGameFlag(kGameFlagScriptProcessing);
cmd->param4 = 2;
if (cmd->param6) {
- _vm->setFlag(kFlagType1);
- _vm->setFlag(kFlagType2);
+ getSharedData()->setFlag(kFlag1, true);
+ getSharedData()->setFlag(kFlag2, true);
}
_lineIncrement = 1;
}
@@ -1180,8 +1180,8 @@ IMPLEMENT_OPCODE(PlaySpeech)
if (cmd->param3) {
if (cmd->param6) {
- _vm->clearFlag(kFlagType1);
- _vm->clearFlag(kFlagType2);
+ getSharedData()->setFlag(kFlag1, false);
+ getSharedData()->setFlag(kFlag2, false);
return;
} else {
@@ -1192,8 +1192,8 @@ IMPLEMENT_OPCODE(PlaySpeech)
if (!cmd->param6) {
cmd->param6 = 1;
} else {
- _vm->clearFlag(kFlagType1);
- _vm->clearFlag(kFlagType2);
+ getSharedData()->setFlag(kFlag1, false);
+ getSharedData()->setFlag(kFlag2, false);
}
END_OPCODE
@@ -1224,8 +1224,8 @@ IMPLEMENT_OPCODE(PlaySpeechScene2)
return;
}
- _vm->clearFlag(kFlagType1);
- _vm->clearFlag(kFlagType2);
+ getSharedData()->setFlag(kFlag1, false);
+ getSharedData()->setFlag(kFlag2, false);
return;
}
@@ -1237,8 +1237,8 @@ IMPLEMENT_OPCODE(PlaySpeechScene2)
cmd->param5 = 2;
if (cmd->param7) {
- _vm->clearFlag(kFlagType1);
- _vm->clearFlag(kFlagType2);
+ getSharedData()->setFlag(kFlag1, false);
+ getSharedData()->setFlag(kFlag2, false);
}
_lineIncrement = 1;
@@ -1302,7 +1302,7 @@ IMPLEMENT_OPCODE(_unk46)
} else {
cmd->param6 = 0;
if (cmd->param5) {
- getScene()->getActor(cmd->param5)->updateStatus(kActorStatusEnabled);
+ getScene()->getActor(cmd->param5)->enable();
} else if (cmd->param4 != cmd->param3 && cmd->param4) {
getWorld()->getObjectById((ObjectId)cmd->param3)->disable();
@@ -1346,19 +1346,19 @@ END_OPCODE
//////////////////////////////////////////////////////////////////////////
// Opcode 0x48
IMPLEMENT_OPCODE(_unk48_MATTE_01)
- getScene()->matteVar1 = 0;
- getScene()->matteInitialized = true;
+ getSharedData()->setMatteVar1(0);
+ getSharedData()->setMatteInitialized(true);
- if (getScene()->matteBarHeight >= 170) {
- getScene()->matteBarHeight = 0;
+ if (getSharedData()->getMatteBarHeight() >= 170) {
+ getSharedData()->setMatteBarHeight(0);
_lineIncrement = 0;
getCursor()->show();
} else {
_lineIncrement = 1;
- if (!getScene()->matteBarHeight) {
+ if (!getSharedData()->getMatteBarHeight()) {
getCursor()->hide();
- getScene()->matteBarHeight = 1;
+ getSharedData()->setMatteBarHeight(1);
}
}
END_OPCODE
@@ -1366,20 +1366,20 @@ END_OPCODE
//////////////////////////////////////////////////////////////////////////
// Opcode 0x49
IMPLEMENT_OPCODE(_unk49_MATTE_90)
- getScene()->matteVar1 = 0;
- getScene()->matteInitialized = true;
- getScene()->mattePlaySound = true;
+ getSharedData()->setMatteVar1(0);
+ getSharedData()->setMatteInitialized(true);
+ getSharedData()->setMattePlaySound(true);
- if (getScene()->matteBarHeight >= 170) {
- getScene()->matteBarHeight = 0;
+ if (getSharedData()->getMatteBarHeight() >= 170) {
+ getSharedData()->setMatteBarHeight(0);
_lineIncrement = 0;
getCursor()->show();
} else {
_lineIncrement = 1;
- if (!getScene()->matteBarHeight) {
+ if (!getSharedData()->getMatteBarHeight()) {
getCursor()->hide();
- getScene()->matteBarHeight = 90;
+ getSharedData()->setMatteBarHeight(90);
}
}
END_OPCODE
@@ -1434,7 +1434,7 @@ END_OPCODE
//////////////////////////////////////////////////////////////////////////
// Opcode 0x4F
IMPLEMENT_OPCODE(ClearScreen)
- getScene()->setSkipDrawScene((bool)cmd->param1);
+ getSharedData()->setSkipDrawScene((bool)cmd->param1);
if (cmd->param1)
getScreen()->clearScreen();
@@ -1698,7 +1698,7 @@ IMPLEMENT_OPCODE(_unk61)
_lineIncrement = 1;
}
} else {
- getScene()->updatePlayerChapter9(cmd->param1);
+ Actor::updatePlayerChapter9(_vm, cmd->param1);
cmd->param2 = 1;
_lineIncrement = 1;
}
@@ -1714,8 +1714,8 @@ END_OPCODE
// Opcode 0x63
IMPLEMENT_OPCODE(_unk63)
if (cmd->param1) {
- _vm->setFlag(kFlagType1);
- _vm->setFlag(kFlagType2);
+ getSharedData()->setFlag(kFlag1, true);
+ getSharedData()->setFlag(kFlag2, true);
}
if (_vm->sound()->isPlaying(getSpeech()->getSoundResourceId())) {
diff --git a/engines/asylum/resources/actor.cpp b/engines/asylum/resources/actor.cpp
index 9e06c48fa4..682a20cd7d 100644
--- a/engines/asylum/resources/actor.cpp
+++ b/engines/asylum/resources/actor.cpp
@@ -114,10 +114,6 @@ Actor::Actor(AsylumEngine *engine, ActorIndex index) : _vm(engine), _index(index
_field_99C = 0;
_field_9A0 = 0;
- // update-related variables
- _actorUpdateCounter = 0;
- _enableFromStatus7 = false;
-
// Temporary resources
memset(&_resources, 0, sizeof(_resources));
}
@@ -281,7 +277,7 @@ void Actor::update() {
case kActorStatus16:
if (getWorld()->chapter == 2) {
updateStatus16_Chapter2();
- } else if (getWorld()->chapter == 11 && _index == getScene()->getPlayerActorIndex()) {
+ } else if (getWorld()->chapter == 11 && _index == getScene()->getPlayerIndex()) {
updateStatus16_Chapter11();
}
break;
@@ -300,10 +296,10 @@ void Actor::update() {
if (_index == 11) {
if (_frameIndex <= _frameCount - 1) {
// Looks like a simple check using the counter, since it doesn't seem to be used anywhere else
- if (_actorUpdateCounter <= 0) {
- ++_actorUpdateCounter;
+ if (getSharedData()->getUpdateCounter() <= 0) {
+ getSharedData()->setUpdateCounter(getSharedData()->getUpdateCounter() + 1);
} else {
- _actorUpdateCounter = 0;
+ getSharedData()->setUpdateCounter(0);
++_frameIndex;
}
} else {
@@ -322,7 +318,7 @@ void Actor::update() {
getScene()->getActor(0)->updateFromDirection(kDirection4);
// Queue script
- getScene()->actions()->queueScript(getWorld()->getActionAreaById(2696)->scriptIndex, getScene()->getPlayerActorIndex());
+ getScene()->actions()->queueScript(getWorld()->getActionAreaById(2696)->scriptIndex, getScene()->getPlayerIndex());
_vm->setGameFlag(kGameFlag279);
_vm->setGameFlag(kGameFlag368);
@@ -351,7 +347,7 @@ void Actor::update() {
}
}
- if (_index == getScene()->getPlayerActorIndex()) {
+ if (_index == getScene()->getPlayerIndex()) {
if (_frameIndex <= _frameCount - 1) {
++_frameIndex;
} else {
@@ -361,12 +357,12 @@ void Actor::update() {
_vm->setGameFlag(kGameFlag238);
// Queue script
- getScene()->actions()->queueScript(getWorld()->getActionAreaById(1000)->scriptIndex, getScene()->getPlayerActorIndex());
+ getScene()->actions()->queueScript(getWorld()->getActionAreaById(1000)->scriptIndex, getScene()->getPlayerIndex());
}
}
} else if (getWorld()->chapter == kChapter11) {
- if (_index == getScene()->getPlayerActorIndex()) {
+ if (_index == getScene()->getPlayerIndex()) {
if (_frameIndex <= _frameCount - 1)
++_frameIndex;
else
@@ -383,7 +379,7 @@ void Actor::update() {
if (_index > 12)
updateStatus15_Chapter2();
- if (_index == getScene()->getPlayerActorIndex())
+ if (_index == getScene()->getPlayerIndex())
updateStatus15_Chapter2_Player();
if (_index == 11)
@@ -393,7 +389,7 @@ void Actor::update() {
if (_index >= 10 && _index < 16)
updateStatus15_Chapter11();
- if (_index == getScene()->getPlayerActorIndex())
+ if (_index == getScene()->getPlayerIndex())
updateStatus15_Chapter11_Player();
}
break;
@@ -411,14 +407,14 @@ void Actor::update() {
case kActorStatusDisabled:
_frameIndex = (_frameIndex + 1) % _frameCount;
- if (_vm->screenUpdatesCount - _lastScreenUpdate > 300) {
+ if (_vm->screenUpdateCount - _lastScreenUpdate > 300) {
if (_vm->getRandom(100) < 50) {
if (!getSpeech()->getSoundResourceId() || !getSound()->isPlaying(getSpeech()->getSoundResourceId())) {
if (isDefaultDirection(10))
updateStatus(kActorStatus9);
}
}
- _lastScreenUpdate = _vm->screenUpdatesCount;
+ _lastScreenUpdate = _vm->screenUpdateCount;
}
break;
@@ -478,9 +474,9 @@ void Actor::update() {
break;
case kActorStatus7:
- if (_enableFromStatus7) {
- _enableFromStatus7 = false;
- updateStatus(kActorStatusEnabled);
+ if (getSharedData()->getActorEnableForStatus7()) {
+ getSharedData()->setActorEnableForStatus7(false);
+ enable();
}
break;
@@ -507,12 +503,12 @@ void Actor::update() {
break;
case kActorStatus8:
- if (_vm->encounter()->getFlag(kEncounterFlag2)
+ if (getSharedData()->getFlag(kFlagEncounter2)
|| !_soundResourceId
|| getSound()->isPlaying(_soundResourceId)) {
_frameIndex = (_frameIndex + 1) % _frameCount;
} else {
- updateStatus(kActorStatusEnabled);
+ enable();
_soundResourceId = kResourceNone;
}
break;
@@ -521,7 +517,7 @@ void Actor::update() {
if (_soundResourceId && getSound()->isPlaying(_soundResourceId))
setVolume();
- if (_index != getScene()->getPlayerActorIndex() && getWorld()->chapter != kChapter9)
+ if (_index != getScene()->getPlayerIndex() && getWorld()->chapter != kChapter9)
error("[Actor::update] call to actor sound functions missing!");
updateDirection();
@@ -539,7 +535,7 @@ void Actor::updateStatus(ActorStatus actorStatus) {
case kActorStatus1:
case kActorStatus12:
if ((getWorld()->chapter == kChapter2
- && _index == getScene()->getPlayerActorIndex() && (_status == kActorStatus18 || _status == kActorStatus16 || _status == kActorStatus17))
+ && _index == getScene()->getPlayerIndex() && (_status == kActorStatus18 || _status == kActorStatus16 || _status == kActorStatus17))
|| (_status != kActorStatusEnabled && _status != kActorStatus9 && _status != kActorStatus14 && _status != kActorStatus15 && _status != kActorStatus18))
return;
@@ -602,7 +598,7 @@ void Actor::updateStatus(ActorStatus actorStatus) {
break;
case kActorStatus9:
- if (_vm->encounter()->getFlag(kEncounterFlag2))
+ if (getSharedData()->getFlag(kFlagEncounter2))
return;
if (_vm->getRandomBit() == 1 && isDefaultDirection(15))
@@ -624,7 +620,7 @@ void Actor::updateStatus(ActorStatus actorStatus) {
if (_index > 12)
_resourceId = _graphicResourceIds[_direction + 30];
- if (getScene()->getPlayerActorIndex() == _index) {
+ if (getScene()->getPlayerIndex() == _index) {
resource->load(_resourceId);
_frameIndex = resource->count() - 1;
}
@@ -878,42 +874,83 @@ void Actor::enableActorsChapter2(AsylumEngine *engine) {
// TODO find out which data is updated
}
- engine->scene()->getActor(13)->updateStatus(kActorStatusEnabled);
+ engine->scene()->getActor(13)->enable();
engine->scene()->getActor(13)->processStatus(2300, 71, false);
- engine->scene()->getActor(14)->updateStatus(kActorStatusEnabled);
+ engine->scene()->getActor(14)->enable();
engine->scene()->getActor(14)->processStatus(2600, 1300, false);
- engine->scene()->getActor(15)->updateStatus(kActorStatusEnabled);
+ engine->scene()->getActor(15)->enable();
engine->scene()->getActor(15)->processStatus(2742, 615, false);
- engine->scene()->getActor(16)->updateStatus(kActorStatusEnabled);
+ engine->scene()->getActor(16)->enable();
engine->scene()->getActor(16)->processStatus(2700, 1200, false);
- engine->scene()->getActor(17)->updateStatus(kActorStatusEnabled);
+ engine->scene()->getActor(17)->enable();
engine->scene()->getActor(17)->processStatus(2751, 347, false);
- engine->scene()->getActor(18)->updateStatus(kActorStatusEnabled);
+ engine->scene()->getActor(18)->enable();
engine->scene()->getActor(18)->processStatus(2420, 284, false);
- engine->scene()->getActor(19)->updateStatus(kActorStatusEnabled);
+ engine->scene()->getActor(19)->enable();
engine->scene()->getActor(19)->processStatus(2800, 370, false);
- engine->scene()->getActor(20)->updateStatus(kActorStatusEnabled);
+ engine->scene()->getActor(20)->enable();
engine->scene()->getActor(20)->processStatus(1973, 1, false);
- engine->scene()->getActor(21)->updateStatus(kActorStatusEnabled);
+ engine->scene()->getActor(21)->enable();
engine->scene()->getActor(21)->processStatus(2541, 40, false);
error("[Actor::enableActorsChapter2] Missing update shared data part!");
}
+void Actor::updatePlayerChapter9(AsylumEngine *engine, int type) {
+ error("[Actor::updatePlayerChapter9] Not implemented!");
+}
+
//////////////////////////////////////////////////////////////////////////
// Update methods
//////////////////////////////////////////////////////////////////////////
void Actor::updateStatus3_19() {
- error("[Actor::updateStatus3_19] not implemented!");
+ if (getWorld()->chapter != kChapter2 || _frameIndex != 6 || _status == kActorStatus3) { /* Original check: _status <= kActorStatus11 */
+ if (_frameIndex < _frameCount - 1) {
+ ++_frameIndex;
+ } else {
+ if (_status == kActorStatus3)
+ updateStatus(kActorStatus7);
+ else
+ updateStatus(kActorStatus20);
+ }
+ } else {
+ if (_index == getScene()->getPlayerIndex())
+ updateStatus19_Player();
+
+ ++_frameIndex;
+ }
+}
+
+void Actor::updateStatus19_Player() {
+ updatePumpkin(kGameFlag263, kGameFlag270, kObjectPumpkin2Dies, kObjectPumpkin2Loop);
+ updatePumpkin(kGameFlag264, kGameFlag271, kObjectPumpkin3Dies, kObjectPumpkin3Loop);
+ updatePumpkin(kGameFlag265, kGameFlag272, kObjectPumpkin4Dies, kObjectPumpkin4Loop);
+ updatePumpkin(kGameFlag266, kGameFlag273, kObjectPumpkin5Dies, kObjectPumpkin5Loop);
+ updatePumpkin(kGameFlag267, kGameFlag274, kObjectPumpkin6Dies, kObjectPumpkin6Loop);
+ updatePumpkin(kGameFlag268, kGameFlag275, kObjectPumpkin7Dies, kObjectPumpkin7Loop);
+ updatePumpkin(kGameFlag269, kGameFlag276, kObjectPumpkin1Dies, kObjectPumpkin1Loop);
+}
+
+void Actor::updatePumpkin(GameFlag flagToCheck, GameFlag flagToSet, ObjectId objectToUpdate, ObjectId objectToDisable) {
+ if (_vm->isGameFlagSet(flagToCheck)) {
+ _vm->setGameFlag(flagToSet);
+ _vm->clearGameFlag(flagToCheck);
+
+ getSharedData()->setActorUpdateFlag2(getSharedData()->getActorUpdateFlag2() + 1);
+
+ getWorld()->getObjectById(objectToUpdate)->setNextFrame(8);
+ getSound()->playSound(getWorld()->soundResourceIds[17], false, Config.sfxVolume - 10);
+ getWorld()->getObjectById(objectToDisable)->disable();
+ }
}
void Actor::updateStatusEnabled() {
@@ -922,25 +959,25 @@ void Actor::updateStatusEnabled() {
_frameIndex = (_frameIndex + 1) % _frameCount;
- // Actor: Crow
- if (_vm->screenUpdatesCount - _lastScreenUpdate > 300) {
+ if (_vm->screenUpdateCount - _lastScreenUpdate > 300) {
+ // All actors except Crow
if (strcmp((char *)&_name, "Crow")) {
if (_vm->getRandom(100) < 50
&& (!getSpeech()->getSoundResourceId() || !getSound()->isPlaying(getSpeech()->getSoundResourceId()))
&& isDefaultDirection(10))
updateStatus(kActorStatus9);
- _lastScreenUpdate = _vm->screenUpdatesCount;
+ _lastScreenUpdate = _vm->screenUpdateCount;
}
}
// Actor: Player
- if (_index == getScene()->getPlayerActorIndex()) {
- if (_vm->globalTickValue_2 && (_vm->screenUpdatesCount - _vm->globalTickValue_2) > 500) {
+ if (_index == getScene()->getPlayerIndex()) {
+ if (_vm->lastScreenUpdate && (_vm->screenUpdateCount - _vm->lastScreenUpdate) > 500) {
if (_vm->isGameFlagNotSet(kGameFlagScriptProcessing)
&& isVisible()
- && !_vm->encounter()->getFlag(kEncounterFlag2)
+ && !getSharedData()->getFlag(kFlagEncounter2)
&& !getSpeech()->getSoundResourceId()) {
if (_vm->getRandom(100) < 50) {
if (getWorld()->chapter == kChapter13)
@@ -949,50 +986,126 @@ void Actor::updateStatusEnabled() {
getSpeech()->playIndexed(4);
}
}
- _lastScreenUpdate = _vm->screenUpdatesCount;
- _vm->globalTickValue_2 = _vm->screenUpdatesCount;
+ _lastScreenUpdate = _vm->screenUpdateCount;
+ _vm->lastScreenUpdate = _vm->screenUpdateCount;
}
return;
}
// Actor:: BigCrow
- if (strcmp(_name, "Big Crow")) {
- error("[Actor::updateStatusEnabled] Big Crow logic not implemented!");
+ if (!strcmp(_name, "Big Crow")) {
+ if (_vm->getRandom(10) < 5) {
+ switch (_vm->getRandom(4)) {
+ default:
+ break;
+
+ case 0:
+ setPosition(10, 1350, kDirection0, 0);
+ processStatus(1460, -100, false);
+ break;
+
+ case 1:
+ setPosition(300, 0, kDirection0, 0);
+ processStatus(1700, 1400, false);
+ break;
+
+ case 2:
+ setPosition(1560, -100, kDirection0, 0);
+ processStatus(-300, 1470, false);
+ break;
+
+ case 3:
+ setPosition(1150, 1400, kDirection0, 0);
+ processStatus(-250, 0, false);
+ break;
+ }
+ }
+
return;
}
// All other actors
- if (_vm->getRandom(10) < 5) {
- switch (_vm->getRandom(4)) {
+ if (getWorld()->chapter != kChapter2 || _index != 8) {
+ if (_field_944 == 4) {
+ Common::Rect frameRect = GraphicResource::getFrameRect(_vm, getWorld()->backgroundImage, 0);
+ processStatus(rnd(frameRect.width() + 200) - 100, rnd(frameRect.height() + 200) - 100, false);
+ } else {
+ // Actor: Crow
+ if (rnd(1000) < 5 || !strcmp(_name, "Crow")) {
+ if (_actionIdx2 != -1) {
+
+ // Process action area
+ int32 areaIndex = getWorld()->getRandomActionAreaIndexById(_actionIdx2);
+ if (areaIndex != -1) {
+
+ ActionArea *area = getWorld()->actions[areaIndex];
+ PolyDefinitions *poly = &getScene()->polygons()->entries[area->polyIdx];
+
+ Common::Point pt(poly->boundingRect.left + rnd(poly->boundingRect.width()),
+ poly->boundingRect.top + rnd(poly->boundingRect.height()));
+
+ if (!getSharedData()->getActorUpdateEnabledCheck()) {
+ if (getScene()->isInActionArea(pt, area)) {
+ Common::Point *polyPoint = &poly->points[rnd(poly->count())];
+ processStatus(polyPoint->x, polyPoint->y, false);
+ } else {
+ processStatus(pt.x, pt.y, false);
+ }
+ }
+ }
+ }
+ }
+ }
+ } else {
+ switch (getSharedData()->getActorUpdateEnabledCounter()) {
default:
break;
case 0:
- setPosition(10, 1350, kDirection0, 0);
- processStatus(1460, -100, false);
+ updateStatusEnabledProcessStatus(1055, 989, 1, 1088, 956);
break;
case 1:
- setPosition(300, 0, kDirection0, 0);
- processStatus(1700, 1400, false);
+ updateStatusEnabledProcessStatus(1088, 956, 2, x1 + x2, 900);
break;
case 2:
- setPosition(1560, -100, kDirection0, 0);
- processStatus(-300, 1470, false);
+ updateStatusEnabledProcessStatus(1088, 900, 3, 1018, 830);
break;
case 3:
- setPosition(1150, 1400, kDirection0, 0);
- processStatus(-250, 0, false);
+ updateStatusEnabledProcessStatus(1018, 830, 4, 970, 830);
+ break;
+
+ case 4:
+ updateStatusEnabledProcessStatus(970, 830, 5, 912, 936);
+ break;
+
+ case 5:
+ updateStatusEnabledProcessStatus(912, 936, 0, 1055, 989);
break;
}
}
}
+void Actor::updateStatusEnabledProcessStatus(int32 testX, int32 testY, uint32 counter, int32 setX, int32 setY) {
+ int32 xsum = x1 + x2;
+ int32 ysum = y1 + y2;
+
+ if (xsum != testX || ysum != testY) {
+ if (rnd(1000) < 5)
+ processStatus(testX, testY, false);
+ } else {
+ getSharedData()->setActorUpdateEnabledCounter(counter);
+
+ if (rnd(1000) < 5)
+ processStatus(setX, setY, false);
+ }
+}
+
void Actor::updateStatus9() {
- if (_index == getScene()->getPlayerActorIndex()
+ if (_index == getScene()->getPlayerIndex()
&& getWorld()->chapter != kChapter9
&& getWorld()->actorType == 0
&& _frameIndex == 0
@@ -1003,8 +1116,8 @@ void Actor::updateStatus9() {
++_frameIndex;
if (_frameIndex == _frameCount) {
- updateStatus(kActorStatusEnabled);
- _lastScreenUpdate = _vm->screenUpdatesCount;
+ enable();
+ _lastScreenUpdate = _vm->screenUpdateCount;
}
}
@@ -1025,7 +1138,33 @@ void Actor::updateStatus12_Chapter11() {
}
void Actor::updateStatus14() {
- error("[Actor::updateStatus14] not implemented!");
+ _frameIndex = (_frameIndex + 1) % _frameCount;
+ _lastScreenUpdate = _vm->screenUpdateCount;
+
+ switch (getWorld()->chapter) {
+ default:
+ break;
+
+ case kChapter2:
+ if (_index == 11)
+ updateStatus(kActorStatus12);
+ else if (_index > 12)
+ updateStatus14_Chapter2();
+ break;
+
+ case kChapter11:
+ if (_index >= 10 && _index < 16)
+ updateStatus14_Chapter11();
+ break;
+ }
+}
+
+void Actor::updateStatus14_Chapter2() {
+ error("[Actor::updateStatus14_Chapter2] not implemented!");
+}
+
+void Actor::updateStatus14_Chapter11() {
+ error("[Actor::updateStatus14_Chapter11] not implemented!");
}
void Actor::updateStatus15_Chapter2() {
@@ -1057,7 +1196,18 @@ void Actor::updateStatus16_Chapter11() {
}
void Actor::updateStatus17_Chapter2() {
- error("[Actor::updateStatus17_Chapter2] not implemented!");
+ ++_frameIndex;
+
+ if (_frameIndex >= _frameCount) {
+ _frameIndex = 0;
+ updateStatus(kActorStatus14);
+ hide();
+
+ if (_vm->getRandomBit() == 1) {
+ _vm->setGameFlag(kGameFlag219);
+ getSpeech()->playPlayer(133);
+ }
+ }
}
void Actor::updateStatus18_Chapter2() {
diff --git a/engines/asylum/resources/actor.h b/engines/asylum/resources/actor.h
index a035b0c8ab..9e35927f15 100644
--- a/engines/asylum/resources/actor.h
+++ b/engines/asylum/resources/actor.h
@@ -142,6 +142,11 @@ public:
*/
void update();
+ /**
+ * Enables the actor
+ */
+ void enable() { updateStatus(kActorStatusEnabled); }
+
/**
* Updates the actor status.
*
@@ -236,6 +241,7 @@ public:
// Static update methods
//////////////////////////////////////////////////////////////////////////
static void enableActorsChapter2(AsylumEngine *engine);
+ static void updatePlayerChapter9(AsylumEngine *engine, int type);
private:
AsylumEngine *_vm;
@@ -318,17 +324,23 @@ private:
//////////////////////////////////////////////////////////////////////////
// Update methods
//////////////////////////////////////////////////////////////////////////
- int32 _actorUpdateCounter;
- bool _enableFromStatus7;
-
void updateStatus3_19();
+ void updateStatus19_Player();
+ void updatePumpkin(GameFlag flagToCheck, GameFlag flagToSet, ObjectId objectToUpdate, ObjectId objectToDisable);
+
void updateStatusEnabled();
+ void updateStatusEnabledProcessStatus(int32 testX, int32 testY, uint32 counter, int32 setX, int32 setY);
+
void updateStatus9();
void updateStatus12_Chapter2();
void updateStatus12_Chapter2_Actor11();
void updateStatus12_Chapter11_Actor1();
void updateStatus12_Chapter11();
+
void updateStatus14();
+ void updateStatus14_Chapter2();
+ void updateStatus14_Chapter11();
+
void updateStatus15_Chapter2();
void updateStatus15_Chapter2_Player();
void updateStatus15_Chapter2_Actor11();
diff --git a/engines/asylum/resources/encounters.cpp b/engines/asylum/resources/encounters.cpp
index ac55d347e6..cefd1c1c77 100644
--- a/engines/asylum/resources/encounters.cpp
+++ b/engines/asylum/resources/encounters.cpp
@@ -32,8 +32,6 @@
namespace Asylum {
Encounter::Encounter(AsylumEngine *engine) : _vm(engine), _currentEncounter(NULL) {
- memset(_flags, 0, sizeof(_flags));
-
Common::File file;
// TODO error checks
@@ -77,23 +75,6 @@ Encounter::~Encounter() {
_vm = NULL;
}
-//////////////////////////////////////////////////////////////////////////
-// Flags
-
-int32 Encounter::getFlag(EncounterFlag flag) const {
- if (flag >= ARRAYSIZE(_flags))
- error("[Encounter::getFlag] Invalid flag index!");
-
- return _flags[flag];
-}
-
-void Encounter::setFlag(EncounterFlag flag, int32 val) {
- if (flag >= ARRAYSIZE(_flags))
- error("[Encounter::getFlag] Invalid flag index!");
-
- _flags[flag] = val;
-}
-
void Encounter::run(int32 encounterIdx, int32 objectId1, int32 objectId2, int32 characterIdx) {
// Line: 12/15 :: 0x25 (1, 1584, 1584, 0, 0, 0, 0, 0, 0) // First Encounter
diff --git a/engines/asylum/resources/encounters.h b/engines/asylum/resources/encounters.h
index 9a3d02eca7..f3f60bc011 100644
--- a/engines/asylum/resources/encounters.h
+++ b/engines/asylum/resources/encounters.h
@@ -34,11 +34,6 @@ namespace Asylum {
class AsylumEngine;
-enum EncounterFlag{
- kEncounterFlag2 = 2,
- kEncounterFlag5 = 5
-};
-
typedef struct EncounterItem {
int32 keywordIndex;
int32 field2;
@@ -68,9 +63,6 @@ public:
}
void run(int32 encounterIdx, int32 objectId1, int32 objectId2, int32 characterIdx);
- int32 getFlag(EncounterFlag flag) const;
- void setFlag(EncounterFlag flag, int32 val);
-
private:
AsylumEngine *_vm;
@@ -80,8 +72,6 @@ private:
EncounterItem *_currentEncounter;
Common::Array<EncounterItem> _items;
- int32 _flags[5];
-
}; // end of class Encounter
} // end of namespace Asylum
diff --git a/engines/asylum/resources/object.cpp b/engines/asylum/resources/object.cpp
index 67e2cdce6c..ca8ae6e5f0 100644
--- a/engines/asylum/resources/object.cpp
+++ b/engines/asylum/resources/object.cpp
@@ -267,14 +267,14 @@ void Object::update() {
if (_frameIndex < _frameCount - 1) {
if (_field_688 == 1) {
Common::Rect frameRect = GraphicResource::getFrameRect(_vm, _resourceId, _frameIndex);
- getScene()->setGlobalX(x + frameRect.left + Common::Rational(frameRect.width(), 2).toInt());
- getScene()->setGlobalY(y + frameRect.top + Common::Rational(frameRect.height(), 2).toInt());
+ getSharedData()->setGlobalX(x + frameRect.left + Common::Rational(frameRect.width(), 2).toInt());
+ getSharedData()->setGlobalY(y + frameRect.top + Common::Rational(frameRect.height(), 2).toInt());
}
} else {
flags &= ~kObjectFlag8;
if (_field_688 == 1) {
- getScene()->setGlobalX(-1);
- getScene()->setGlobalY(-1);
+ getSharedData()->setGlobalX(-1);
+ getSharedData()->setGlobalY(-1);
}
}
_tickCount = _vm->getTick();
@@ -289,13 +289,13 @@ void Object::update() {
if (_frameIndex == 0) {
flags &= ~kObjectFlag10000;
if (_field_688 == 1) {
- getScene()->setGlobalX(-1);
- getScene()->setGlobalY(-1);
+ getSharedData()->setGlobalX(-1);
+ getSharedData()->setGlobalY(-1);
}
} else if (_field_688 == 1) {
Common::Rect frameRect = GraphicResource::getFrameRect(_vm, _resourceId, _frameIndex);
- getScene()->setGlobalX(x + frameRect.left + Common::Rational(frameRect.width(), 2).toInt());
- getScene()->setGlobalY(y + frameRect.top + Common::Rational(frameRect.height(), 2).toInt());
+ getSharedData()->setGlobalX(x + frameRect.left + Common::Rational(frameRect.width(), 2).toInt());
+ getSharedData()->setGlobalY(y + frameRect.top + Common::Rational(frameRect.height(), 2).toInt());
}
_tickCount = _vm->getTick();
diff --git a/engines/asylum/resources/special.cpp b/engines/asylum/resources/special.cpp
index 4064124767..af196b9cd4 100644
--- a/engines/asylum/resources/special.cpp
+++ b/engines/asylum/resources/special.cpp
@@ -196,7 +196,7 @@ void Special::chapter2(Object *object, ActorIndex actorIndex) {
for (int i = 13; i < 22; i++) {
if (getScene()->getActor(i)->isVisible()) {
- getScene()->setActorUpdateFlag(2);
+ getSharedData()->setActorUpdateFlag(2);
break;
}
}
@@ -272,7 +272,7 @@ void Special::chapter2(Object *object, ActorIndex actorIndex) {
actor->setFrameIndex(0);
if (actor->isVisible())
- if (getScene()->getActorUpdateFlag2() < 7)
+ if (getSharedData()->getActorUpdateFlag2() < 7)
getSpeech()->playPlayer(452);
_vm->setGameFlag(kGameFlag219);
@@ -444,7 +444,7 @@ void Special::chapter7(Object *object, ActorIndex actorIndex) {
if (player->getStatus() == kActorStatus6 || player->getStatus() == kActorStatus10) {
getSound()->playSound(MAKE_RESOURCE(kResourcePackSound, 2));
- player->updateStatus(kActorStatusEnabled);
+ player->enable();
} else {
getSound()->playSound(MAKE_RESOURCE(kResourcePackSound, 5));
player->updateStatus(kActorStatus6);
@@ -461,7 +461,7 @@ void Special::chapter7(Object *object, ActorIndex actorIndex) {
if (_vm->isGameFlagSet(kGameFlag1023)) {
if (player->getField638()) {
getScript()->queueScript(getWorld()->actions[getWorld()->getActionAreaIndexById(player->getField638() == 3 ? 2447 : 2448)]->scriptIndex,
- getScene()->getPlayerActorIndex());
+ getScene()->getPlayerIndex());
_vm->clearGameFlag(kGameFlag1023);
} else if (player->getStatus() != kActorStatus6) {
_vm->clearGameFlag(kGameFlag1023);
@@ -472,7 +472,7 @@ void Special::chapter7(Object *object, ActorIndex actorIndex) {
if (_vm->isGameFlagSet(kGameFlag1022)) {
_vm->clearGameFlag(kGameFlag1022);
getScript()->queueScript(getWorld()->actions[getWorld()->getActionAreaIndexById(2445)]->scriptIndex,
- getScene()->getPlayerActorIndex());
+ getScene()->getPlayerIndex());
}
break;
}
@@ -549,7 +549,7 @@ void Special::chapter8(Object *object, ActorIndex actorIndex) {
getCursor()->show();
getWorld()->motionStatus = 1;
- _vm->clearFlag(kFlagType1);
+ getSharedData()->setFlag(kFlag1, false);
actor0->show();
}
@@ -666,7 +666,7 @@ void Special::chapter9(Object *object, ActorIndex actorIndex) {
void Special::playChapterSound(Object *object, ActorIndex actorIndex) {
ResourceId id = getResourceId(object, actorIndex);
- if (getEncounter()->getFlag(kEncounterFlag2) != 0)
+ if (getSharedData()->getFlag(kFlagEncounter2))
return;
if (id != kResourceNone && getSound()->isPlaying(id))
diff --git a/engines/asylum/resources/worldstats.cpp b/engines/asylum/resources/worldstats.cpp
index 5634e9892f..999b2b199c 100644
--- a/engines/asylum/resources/worldstats.cpp
+++ b/engines/asylum/resources/worldstats.cpp
@@ -31,6 +31,8 @@
#include "asylum/views/scene.h"
+#include "asylum/asylum.h"
+
namespace Asylum {
WorldStats::WorldStats(Common::SeekableReadStream *stream, Scene *scene) : _scene(scene) {
@@ -310,6 +312,24 @@ int32 WorldStats::getActionAreaIndexById(int32 id) {
return -1;
}
+int32 WorldStats::getRandomActionAreaIndexById(int32 id) {
+ int count = 0;
+ int32 indexes[5];
+ memset(&indexes, 0, sizeof(indexes));
+
+ for (uint32 i = 0; i < actions.size(); i++) {
+ if (actions[i]->id == id && count < 5) {
+ indexes[count] = i;
+ ++count;
+ }
+ }
+
+ if (!count)
+ return -1;
+
+ return indexes[_scene->vm()->getRandom(count)];
+}
+
ActionArea* WorldStats::getActionAreaById(int32 id) {
int index = getActionAreaIndexById(id);
if (index == -1)
diff --git a/engines/asylum/resources/worldstats.h b/engines/asylum/resources/worldstats.h
index dbad487ab8..1f2ae37055 100644
--- a/engines/asylum/resources/worldstats.h
+++ b/engines/asylum/resources/worldstats.h
@@ -127,6 +127,7 @@ public:
void setWheelObjects();
int32 getActionAreaIndexById(int32 id);
+ int32 getRandomActionAreaIndexById(int32 id);
ActionArea* getActionAreaById(int32 id);
Object* getObjectById(ObjectId id);
diff --git a/engines/asylum/shared.h b/engines/asylum/shared.h
index 1c7c38027f..c44ef55cb2 100644
--- a/engines/asylum/shared.h
+++ b/engines/asylum/shared.h
@@ -47,6 +47,20 @@ enum GameFlag {
kGameFlag246 = 246,
kGameFlag247 = 247,
kGameFlag248 = 248,
+ kGameFlag263 = 263,
+ kGameFlag264 = 264,
+ kGameFlag265 = 265,
+ kGameFlag266 = 266,
+ kGameFlag267 = 267,
+ kGameFlag268 = 268,
+ kGameFlag269 = 269,
+ kGameFlag270 = 270,
+ kGameFlag271 = 271,
+ kGameFlag272 = 272,
+ kGameFlag273 = 273,
+ kGameFlag274 = 274,
+ kGameFlag275 = 275,
+ kGameFlag276 = 276,
kGameFlag279 = 279,
kGameFlag358 = 358,
kGameFlag368 = 368,
@@ -429,6 +443,20 @@ enum ObjectId {
kObjectCrow3Pecks = 1503,
kObjectCrow4FlysAway = 1506,
kObjectCrow4Pecks = 1507,
+ kObjectPumpkin1Loop = 1523,
+ kObjectPumpkin2Loop = 1524,
+ kObjectPumpkin3Loop = 1525,
+ kObjectPumpkin4Loop = 1526,
+ kObjectPumpkin5Loop = 1527,
+ kObjectPumpkin6Loop = 1528,
+ kObjectPumpkin7Loop = 1529,
+ kObjectPumpkin1Dies = 1530,
+ kObjectPumpkin2Dies = 1531,
+ kObjectPumpkin3Dies = 1532,
+ kObjectPumpkin4Dies = 1533,
+ kObjectPumpkin5Dies = 1534,
+ kObjectPumpkin6Dies = 1535,
+ kObjectPumpkin7Dies = 1536,
kObjectDennisStatus2 = 1580,
kObjectPreAlphaNut = 1582,
kObjectPreAlphaNut2 = 1584,
@@ -519,17 +547,18 @@ enum ObjectFlag {
#define rnd(val) _vm->getRandom(val)
// Engine subclasses
-#define getEncounter() _vm->encounter()
-#define getCursor() _vm->cursor()
-#define getResource() _vm->resource()
-#define getSound() _vm->sound()
-#define getScene() _vm->scene()
-#define getScreen() _vm->screen()
-#define getScript() _vm->scene()->actions()
-#define getSpeech() _vm->scene()->speech()
-#define getText() _vm->text()
-#define getVideo() _vm->video()
-#define getWorld() _vm->scene()->worldstats()
+#define getSharedData() _vm->getData()
+#define getEncounter() _vm->encounter()
+#define getCursor() _vm->cursor()
+#define getResource() _vm->resource()
+#define getSound() _vm->sound()
+#define getScene() _vm->scene()
+#define getScreen() _vm->screen()
+#define getScript() _vm->scene()->actions()
+#define getSpeech() _vm->scene()->speech()
+#define getText() _vm->text()
+#define getVideo() _vm->video()
+#define getWorld() _vm->scene()->worldstats()
//////////////////////////////////////////////////////////////////////////
// Sub-integer partial access macros
diff --git a/engines/asylum/system/sound.cpp b/engines/asylum/system/sound.cpp
index 1dfd85209e..a94b633e32 100644
--- a/engines/asylum/system/sound.cpp
+++ b/engines/asylum/system/sound.cpp
@@ -149,12 +149,12 @@ int32 Sound::calculateVolumeAdjustement(int32 x, int32 y, int32 attenuation, int
return -(delta * delta);
Actor *player = getScene()->getActor();
- if (getScene()->getGlobalX() == -1) {
+ if (getSharedData()->getGlobalX() == -1) {
x -= (player->x1 + player->x2);
y -= (player->y1 + player->y2);
} else {
- x -= getScene()->getGlobalX();
- y -= getScene()->getGlobalY();
+ x -= getSharedData()->getGlobalX();
+ y -= getSharedData()->getGlobalY();
}
int32 adjustedVolume = getAdjustedVolume(x * x + y * y);
diff --git a/engines/asylum/views/scene.cpp b/engines/asylum/views/scene.cpp
index 91479f2436..3c3f90a2b2 100644
--- a/engines/asylum/views/scene.cpp
+++ b/engines/asylum/views/scene.cpp
@@ -68,28 +68,11 @@ Scene::Scene(AsylumEngine *engine): _vm(engine), _ev(NULL),
_leftClick = false;
_rightButton = false;
_isActive = false;
- _skipDrawScene = false;
_globalDirection = kDirection0;
// Graphics
_bgResource = NULL;
_background = NULL;
-
- // Initialize global data
- _globalX = _globalY = 0;
- _sceneOffset = 0;
- _sceneXLeft = _sceneYTop = 0;
- _actorUpdateFlag = false;
- _actorUpdateFlag2 = false;
-
- //
- matteBarHeight = 0;
- matteVar1 = 0;
- matteVar2 = 0;
- mattePlaySound = false;
- matteInitialized = false;
-
- memset(&savedResourceIds, 0, sizeof(savedResourceIds));
}
Scene::~Scene() {
@@ -158,7 +141,7 @@ void Scene::enter(ResourcePackId packId) {
// Hide actor
player->hide();
- player->updateStatus(kActorStatusEnabled);
+ player->enable();
// Update current player coordinates
player->x1 -= player->x2;
@@ -171,7 +154,7 @@ void Scene::enter(ResourcePackId packId) {
actor->hide();
actor->setDirection(kDirection1);
- actor->updateStatus(kActorStatusEnabled);
+ actor->enable();
actor->x1 -= actor->x2;
actor->y1 -= actor->y2;
@@ -210,11 +193,11 @@ void Scene::enter(ResourcePackId packId) {
getSound()->playMusic(musicId);
// Update global values
- _vm->globalTickValue_2 = 1;
- _vm->screenUpdatesCount = 1;
+ _vm->lastScreenUpdate = 1;
+ getSharedData()->setFlag(kFlagScene1, true);
- player->setLastScreenUpdate(_vm->getTick());
- player->updateStatus(kActorStatusEnabled);
+ player->setLastScreenUpdate(_vm->screenUpdateCount);
+ player->enable();
if (_ws->chapter == kChapter9) {
changePlayer(1);
@@ -276,13 +259,13 @@ void Scene::load(ResourcePackId packId) {
_leftClick = false;
_rightButton = false;
_isActive = false;
- _skipDrawScene = false;
+ //_skipDrawScene = false;
g_debugPolygons = 0;
g_debugObjects = 0;
g_debugScrolling = 0;
- _globalX = _globalY = 0;
+ //_globalX = _globalY = 0;
// TODO figure out what field_120 is used for
_ws->field_120 = -1;
@@ -296,9 +279,6 @@ void Scene::load(ResourcePackId packId) {
_titleLoaded = false;
_special = new Special(_vm);
-
- _actorUpdateFlag = 0;
- _actorUpdateFlag2 = 0;
}
Actor* Scene::getActor(ActorIndex index) {
@@ -800,6 +780,10 @@ int32 Scene::findActionArea(const Common::Point pt) {
return targetIdx;
}
+int32 Scene::isInActionArea(const Common::Point &pt, ActionArea *area) {
+ error("[Scene::isInActionArea] Not implemented!");
+}
+
ResourceId Scene::hitTestScene(const Common::Point pt, HitType &type) {
if (!_ws)
error("[Scene::hitTestScene] WorldStats not initialized properly!");
@@ -1115,9 +1099,9 @@ bool Scene::updateSceneCoordinates(int32 tX, int32 tY, int32 A0, bool checkScene
*targetY = _ws->height - 480;
// Adjust scene offsets & coordinates
- _sceneOffset = 0;
- _sceneXLeft = _ws->xLeft;
- _sceneYTop = _ws->yTop;
+ getSharedData()->setSceneOffset(0);
+ getSharedData()->setSceneXLeft(_ws->xLeft);
+ getSharedData()->setSceneYTop(_ws->yTop);
int32 diffX = *targetX - _ws->xLeft;
int32 diffY = *targetY - _ws->yTop;
@@ -1126,7 +1110,7 @@ bool Scene::updateSceneCoordinates(int32 tX, int32 tY, int32 A0, bool checkScene
if (_ws->yTop > *targetY)
*coord3 = -*coord3;
- _sceneOffsetAdd = Common::Rational(*coord3, diffY) * diffX;
+ getSharedData()->setSceneOffsetAdd(Common::Rational(*coord3, diffY) * diffX);
if (param != NULL && abs(diffY) <= abs(*coord3)) {
*targetX = -1;
@@ -1137,7 +1121,7 @@ bool Scene::updateSceneCoordinates(int32 tX, int32 tY, int32 A0, bool checkScene
if (_ws->xLeft > *targetX)
*coord3 = -*coord3;
- _sceneOffsetAdd = Common::Rational(*coord3, diffX) * diffY;
+ getSharedData()->setSceneOffsetAdd(Common::Rational(*coord3, diffX) * diffY);
if (param != NULL && abs(diffX) <= abs(*coord3)) {
*targetX = -1;
@@ -1168,7 +1152,7 @@ int Scene::drawScene() {
_vm->screen()->clearGraphicsInQueue();
- if (_skipDrawScene) {
+ if (getSharedData()->getSkipDrawScene()) {
_vm->screen()->clearScreen();
} else {
// Draw scene background
@@ -1253,7 +1237,7 @@ void Scene::processUpdateList() {
int32 bottomRight = actor->getBoundingRect()->bottom + actor->y1 + 4;
- if (_ws->chapter == kChapter11 && _updateList[i].index != getPlayerActorIndex())
+ if (_ws->chapter == kChapter11 && _updateList[i].index != getPlayerIndex())
bottomRight += 20;
// Our actor rect
@@ -1564,10 +1548,6 @@ void Scene::debugShowActors() {
}
}
-void Scene::updatePlayerChapter9(int32 param) {
- error("[Scene::updatePlayerChapter9] not implemented!");
-}
-
int Scene::processActor(int *x, int *param) {
error("[Scene::processActor] not implemented!");
}
diff --git a/engines/asylum/views/scene.h b/engines/asylum/views/scene.h
index 85fb84330b..42c0f4ac66 100644
--- a/engines/asylum/views/scene.h
+++ b/engines/asylum/views/scene.h
@@ -55,6 +55,7 @@ class Text;
class Video;
class WorldStats;
+struct ActionArea;
struct AmbientSoundItem;
struct GraphicFrame;
struct ObjectItem;
@@ -86,9 +87,6 @@ public:
void load(ResourcePackId packId);
-
-
-
void handleEvent(Common::Event *event, bool doUpdate);
void activate();
@@ -99,7 +97,6 @@ public:
//BlowUpPuzzle* getBlowUpPuzzle() { return _blowUp;}
//void setBlowUpPuzzle(BlowUpPuzzle* puzzle) { _blowUp = puzzle; }
void setScenePosition(int x, int y);
- void setSkipDrawScene(bool skip) { _skipDrawScene = skip; }
AsylumEngine* vm() { return _vm; }
@@ -117,7 +114,7 @@ public:
/**
* Return the index of the current player actor
*/
- ActorIndex getPlayerActorIndex() { return _playerActorIdx; }
+ ActorIndex getPlayerIndex() { return _playerActorIdx; }
void setPlayerActorIndex(ActorIndex index) { _playerActorIdx = index; }
void changePlayer(ActorIndex index);
@@ -142,47 +139,28 @@ public:
int32 calculateVolumeAdjustment(AmbientSoundItem *snd, Actor *act);
- // Shared global Data
- int32 getGlobalX() const { return _globalX; }
- void setGlobalX(int32 val) { _globalX = val; }
- int32 getGlobalY() const { return _globalY; }
- void setGlobalY(int32 val) { _globalY = val; }
-
ActorDirection getGlobalDirection() { return _globalDirection; }
bool updateSceneCoordinates(int32 targetX, int32 targetY, int32 val, bool checkSceneCoords = false, int32 *param = NULL);
void adjustCoordinates(int32 x, int32 y, Common::Point *point);
- void updatePlayerChapter9(int32 param);
-
int processActor(int *x, int *param);
void updatePalette(int32 param);
void makeGreyPalette();
- int matteBarHeight;
- int matteVar1;
- int matteVar2;
- bool mattePlaySound;
- bool matteInitialized;
// Shared methods
void resetActor0();
- int32 getActorUpdateFlag() { return _actorUpdateFlag; }
- void setActorUpdateFlag(int32 val) { _actorUpdateFlag = val; }
-
- int32 getActorUpdateFlag2() { return _actorUpdateFlag2; }
- void setActorUpdateFlag2(int32 val) { _actorUpdateFlag2 = val; }
-
- ResourceId savedResourceIds[11]; // TODO are those really resource ids?
-
/** .text:00408980
* Determine if the supplied point intersects
* an action area's active region
*/
int32 findActionArea(const Common::Point pt);
+ int32 isInActionArea(const Common::Point &pt, ActionArea *area);
+
protected:
/** .text:0040EA50
* Run various hit tests and return the index,
@@ -227,7 +205,6 @@ private:
bool _leftClick;
bool _rightButton;
bool _isActive;
- bool _skipDrawScene;
ActorDirection _globalDirection;
ActionList *_actions;
@@ -241,13 +218,6 @@ private:
GraphicResource *_bgResource;
GraphicFrame *_background;
- int32 _globalX;
- int32 _globalY;
- int32 _sceneOffset;
- int32 _sceneXLeft;
- int32 _sceneYTop;
- Common::Rational _sceneOffsetAdd;
-
struct UpdateItem {
ActorIndex index;
int32 priority;
@@ -255,9 +225,6 @@ private:
Common::Array<UpdateItem> _updateList;
- int32 _actorUpdateFlag;
- int32 _actorUpdateFlag2;
-
/** .text:0040B5B0
* Loop through the various update blocks (actors,
* objects, mouse, music, sfx, screenPosition), then
Commit: 6a869e61715273f8cb20692b614ee025761bb647
https://github.com/scummvm/scummvm/commit/6a869e61715273f8cb20692b614ee025761bb647
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:19+02:00
Commit Message:
ASYLUM: Rename Screen::clearScreen to Screen::clear
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@549 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/asylum.cpp
engines/asylum/console.cpp
engines/asylum/resources/actionlist.cpp
engines/asylum/system/screen.cpp
engines/asylum/system/screen.h
engines/asylum/views/scene.cpp
diff --git a/engines/asylum/asylum.cpp b/engines/asylum/asylum.cpp
index 9be3edf461..3d4ece7968 100644
--- a/engines/asylum/asylum.cpp
+++ b/engines/asylum/asylum.cpp
@@ -204,7 +204,7 @@ void AsylumEngine::playIntro() {
/*if (_scene->worldstats()->musicCurrentResourceId != kResourceMusic_FFFFFD66)
_sound->playMusic(_scene->getResourcePack(), _scene->worldstats()->musicCurrentResourceId);*/
- _screen->clearScreen();
+ _screen->clear();
setGameFlag(kGameFlag4);
setGameFlag(kGameFlag12);
diff --git a/engines/asylum/console.cpp b/engines/asylum/console.cpp
index 4e56376a51..73f4078605 100644
--- a/engines/asylum/console.cpp
+++ b/engines/asylum/console.cpp
@@ -311,7 +311,7 @@ bool Console::cmdPlayVideo(int32 argc, const char **argv) {
return true;
}
- getScreen()->clearScreen();
+ getScreen()->clear();
getScene()->actions()->setDelayedVideoIndex(index);
return false;
diff --git a/engines/asylum/resources/actionlist.cpp b/engines/asylum/resources/actionlist.cpp
index 7f0a7c0409..67c445bfb5 100644
--- a/engines/asylum/resources/actionlist.cpp
+++ b/engines/asylum/resources/actionlist.cpp
@@ -767,7 +767,7 @@ IMPLEMENT_OPCODE(ChangeScene)
// Fade screen to black
getScreen()->paletteFade(0, 75, 8);
- getScreen()->clearScreen();
+ getScreen()->clear();
// Stop all sounds & music
getSound()->stopAll();
@@ -981,7 +981,7 @@ END_OPCODE
//////////////////////////////////////////////////////////////////////////
// Opcode 0x37
IMPLEMENT_OPCODE(RunBlowUpPuzzle)
- getScreen()->clearScreen();
+ getScreen()->clear();
getScreen()->clearGraphicsInQueue();
_vm->switchMessageHandler(_vm->getMessageHandler((uint32)cmd->param1));
@@ -1018,7 +1018,7 @@ IMPLEMENT_OPCODE(_unk3B_PALETTE_MOD)
}
if (cmd->param1 >= 22) {
- getScreen()->clearScreen();
+ getScreen()->clear();
cmd->param1 = 0;
cmd->param2 = 0;
@@ -1437,13 +1437,13 @@ IMPLEMENT_OPCODE(ClearScreen)
getSharedData()->setSkipDrawScene((bool)cmd->param1);
if (cmd->param1)
- getScreen()->clearScreen();
+ getScreen()->clear();
END_OPCODE
//////////////////////////////////////////////////////////////////////////
// Opcode 0x50
IMPLEMENT_OPCODE(Quit)
- getScreen()->clearScreen();
+ getScreen()->clear();
Engine::quitGame();
// We need to exit the interpreter loop so we get back to the event loop
diff --git a/engines/asylum/system/screen.cpp b/engines/asylum/system/screen.cpp
index d05640c718..1d99302902 100644
--- a/engines/asylum/system/screen.cpp
+++ b/engines/asylum/system/screen.cpp
@@ -150,7 +150,7 @@ void Screen::drawWideScreen(int16 barSize) const {
}
}
-void Screen::clearScreen() const {
+void Screen::clear() const {
_vm->_system->fillScreen(0);
}
diff --git a/engines/asylum/system/screen.h b/engines/asylum/system/screen.h
index 80df2fbf0a..aaeb1063e1 100644
--- a/engines/asylum/system/screen.h
+++ b/engines/asylum/system/screen.h
@@ -67,7 +67,7 @@ public:
void setGammaLevel(ResourceId id, int32 val);
void drawWideScreen(int16 barSize) const;
- void clearScreen() const;
+ void clear() const;
void paletteFade(uint32 red, int32 milliseconds, int32 param);
void startPaletteFade(ResourceId resourceId, int32 milliseconds, int32 param);
diff --git a/engines/asylum/views/scene.cpp b/engines/asylum/views/scene.cpp
index 3c3f90a2b2..1fcf3c1bc9 100644
--- a/engines/asylum/views/scene.cpp
+++ b/engines/asylum/views/scene.cpp
@@ -1002,7 +1002,7 @@ void Scene::playIntroSpeech() {
break;
}
- getScreen()->clearScreen();
+ getScreen()->clear();
// TODO do palette fade and wait until sound is done
warning("[Scene::playIntroSpeech] Missing palette fade and wait!");
@@ -1153,7 +1153,7 @@ int Scene::drawScene() {
_vm->screen()->clearGraphicsInQueue();
if (getSharedData()->getSkipDrawScene()) {
- _vm->screen()->clearScreen();
+ _vm->screen()->clear();
} else {
// Draw scene background
_vm->screen()->draw(_bgResource, 0, -_ws->xLeft, -_ws->yTop, 0);
Commit: a778f4e7a48e3aad41f31b4eef90c733808630eb
https://github.com/scummvm/scummvm/commit/a778f4e7a48e3aad41f31b4eef90c733808630eb
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:19+02:00
Commit Message:
ASYLUM: Scene loading & actor logic
- Move ActionArea loading to its own method
- Add actor rect shared data
- Implement one more Actor::updateStatus function
- Add several Actor helper functions
- Make x, y, x1, y1, x2, y2 private and store as Common::Point
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@550 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/data.h
engines/asylum/resources/actionlist.cpp
engines/asylum/resources/actionlist.h
engines/asylum/resources/actor.cpp
engines/asylum/resources/actor.h
engines/asylum/resources/special.cpp
engines/asylum/resources/worldstats.cpp
engines/asylum/resources/worldstats.h
engines/asylum/system/sound.cpp
engines/asylum/system/speech.cpp
engines/asylum/views/scene.cpp
diff --git a/engines/asylum/data.h b/engines/asylum/data.h
index de068271ec..170efd74b4 100644
--- a/engines/asylum/data.h
+++ b/engines/asylum/data.h
@@ -29,6 +29,7 @@
#include "engines/asylum/shared.h"
#include "common/rational.h"
+#include "common/rect.h"
namespace Asylum {
@@ -193,6 +194,8 @@ public:
void setSceneOffset(int32 val) { _sceneOffset = val; }
void setSceneOffsetAdd(const Common::Rational &offset) { _sceneOffsetAdd = offset; }
+ Common::Rect *getActorRect() { return &_actorRect; }
+
//////////////////////////////////////////////////////////////////////////
// Flags
//////////////////////////////////////////////////////////////////////////
@@ -267,7 +270,7 @@ public:
}
private:
-
+ Common::Rect _actorRect;
bool _actorEnableForStatus7;
@@ -279,6 +282,12 @@ private:
// Lots of other data
+ //////////////////////////////////////////////////////////////////////////
+ // Shared data
+ // (Some functions access those by offset, so until we figure out what
+ // exact data they need, we keep all of them here)
+ //////////////////////////////////////////////////////////////////////////
+
// TODO Add ambient sound panning array
uint32 _sceneCounter;
int32 _globalX;
diff --git a/engines/asylum/resources/actionlist.cpp b/engines/asylum/resources/actionlist.cpp
index 67c445bfb5..41d90192e1 100644
--- a/engines/asylum/resources/actionlist.cpp
+++ b/engines/asylum/resources/actionlist.cpp
@@ -46,6 +46,41 @@
namespace Asylum {
+//////////////////////////////////////////////////////////////////////////
+// ActionArea
+//////////////////////////////////////////////////////////////////////////
+void ActionArea::load(Common::SeekableReadStream *stream) {
+ stream->read(&name, 52);
+ id = stream->readSint32LE();
+ field01 = stream->readSint32LE();
+ field02 = stream->readSint32LE();
+ field_40 = stream->readSint32LE();
+ field_44 = stream->readSint32LE();
+ flags = stream->readSint32LE();
+ scriptIndex = stream->readSint32LE();
+ scriptIndex2 = stream->readSint32LE();
+ actionType = stream->readSint32LE();
+
+ for (int32 i = 0; i < 10; i++)
+ flagNums[i] = stream->readSint32LE();
+
+ field_7C = stream->readSint32LE();
+ polyIdx = stream->readSint32LE();
+ field_84 = stream->readSint32LE();
+ field_88 = stream->readSint32LE();
+ soundResourceId = (ResourceId)stream->readSint32LE();
+ field_90 = stream->readSint32LE();
+ paletteResourceId = (ResourceId)stream->readSint32LE();
+
+ for (int32 i = 0; i < 5; i++)
+ array[i] = stream->readSint32LE();
+
+ volume = stream->readSint32LE();
+}
+
+//////////////////////////////////////////////////////////////////////////
+// ActionList
+//////////////////////////////////////////////////////////////////////////
ActionList::ActionList(AsylumEngine *engine) : _vm(engine) {
// Build list of opcodes
ADD_OPCODE(Return);
@@ -548,7 +583,7 @@ IMPLEMENT_OPCODE(JumpAndSetDirection)
if (cmd->param2 == -1 || cmd->param3 == -1) {
actor->updateFromDirection((ActorDirection)cmd->param4);
- } else if ((actor->x1 + actor->x2) == cmd->param2 && (actor->y1 + actor->y2) == cmd->param3) {
+ } else if ((actor->getPoint1()->x + actor->getPoint2()->x) == cmd->param2 && (actor->getPoint1()->y + actor->getPoint2()->y) == cmd->param3) {
actor->updateFromDirection((ActorDirection)cmd->param4);
} else {
actor->processStatus(cmd->param2, cmd->param3, (bool)cmd->param4);
@@ -562,7 +597,7 @@ IMPLEMENT_OPCODE(JumpAndSetDirection)
cmd->param5 = 1;
_lineIncrement = 0;
- if ((actor->x1 + actor->x2) == cmd->param2 && (actor->y1 + actor->y2) == cmd->param3)
+ if ((actor->getPoint1()->x + actor->getPoint2()->x) == cmd->param2 && (actor->getPoint1()->y + actor->getPoint2()->y) == cmd->param3)
actor->updateFromDirection((ActorDirection)cmd->param4);
}
} else {
@@ -576,7 +611,7 @@ END_OPCODE
IMPLEMENT_OPCODE(JumpIfActorCoordinates)
Actor *actor = getScene()->getActor(cmd->param1);
- if ((actor->x1 + actor->x2) != cmd->param2 || (actor->y1 + actor->y2) != cmd->param3)
+ if ((actor->getPoint1()->x + actor->getPoint2()->x) != cmd->param2 || (actor->getPoint1()->y + actor->getPoint2()->y) != cmd->param3)
_lineIncrement = cmd->param4;
END_OPCODE
@@ -784,7 +819,7 @@ END_OPCODE
IMPLEMENT_OPCODE(_unk2C_ActorSub)
Actor *player = getScene()->getActor();
Actor *actor = getScene()->getActor(_currentQueueEntry.actorIndex);
- Common::Point playerPoint((int16)(player->x1 + player->x2), (int16)(player->y1 + player->y2));
+ Common::Point playerPoint((int16)(player->getPoint1()->x + player->getPoint2()->x), (int16)(player->getPoint1()->y + player->getPoint2()->y));
ActorDirection direction = (cmd->param2 == 8) ? player->getDirection() : (ActorDirection)cmd->param2;
ActorDirection newDirection = (ActorDirection)((player->getDirection() + 4) % 8);
@@ -1256,8 +1291,8 @@ IMPLEMENT_OPCODE(MoveScenePositionFromActor)
if (!cmd->param3) {
getWorld()->motionStatus = 5;
- getScene()->updateSceneCoordinates(actor->x1 + Common::Rational(actor->x2, 2).toInt() - 320,
- actor->y1 + Common::Rational(actor->y2, 2).toInt() - 240,
+ getScene()->updateSceneCoordinates(actor->getPoint1()->x + Common::Rational(actor->getPoint2()->x, 2).toInt() - 320,
+ actor->getPoint1()->y + Common::Rational(actor->getPoint2()->y, 2).toInt() - 240,
cmd->param2);
} else if (cmd->param6) {
if (getWorld()->motionStatus == 2) {
@@ -1270,8 +1305,8 @@ IMPLEMENT_OPCODE(MoveScenePositionFromActor)
cmd->param6 = 1;
getWorld()->motionStatus = 2;
- if (getScene()->updateSceneCoordinates(actor->x1 + Common::Rational(actor->x2, 2).toInt() - 320,
- actor->y1 + Common::Rational(actor->y2, 2).toInt() - 240,
+ if (getScene()->updateSceneCoordinates(actor->getPoint1()->x + Common::Rational(actor->getPoint2()->x, 2).toInt() - 320,
+ actor->getPoint1()->y + Common::Rational(actor->getPoint2()->y, 2).toInt() - 240,
cmd->param2,
true,
&cmd->param6))
@@ -1553,7 +1588,7 @@ IMPLEMENT_OPCODE(_unk56)
cmd->param2 = 1;
_lineIncrement = 0;
- if ((actor->x1 + actor->x2 == cmd->param6) && (actor->y1 + actor->y2 == cmd->param7)) {
+ if ((actor->getPoint1()->x + actor->getPoint2()->x == cmd->param6) && (actor->getPoint1()->y + actor->getPoint2()->y == cmd->param7)) {
getScene()->getActor()->faceTarget((ObjectId)cmd->param1, kDirectionFromActor);
actor->updateFromDirection((ActorDirection)((actor->getDirection() + 4) & 7));
} else {
diff --git a/engines/asylum/resources/actionlist.h b/engines/asylum/resources/actionlist.h
index 58b94ad2e0..b00b94bb09 100644
--- a/engines/asylum/resources/actionlist.h
+++ b/engines/asylum/resources/actionlist.h
@@ -79,7 +79,30 @@ struct ActionArea {
int32 array[5];
int32 volume;
- ActionArea() {}
+ ActionArea() {
+ memset(&name, 0, sizeof(name));
+ id = 0;
+ field01 = 0;
+ field02 = 0;
+ field_40 = 0;
+ field_44 = 0;
+ flags = 0;
+ scriptIndex = 0;
+ scriptIndex2 = 0;
+ actionType = 0;
+ memset(&flagNums, 0, sizeof(flagNums));
+ field_7C = 0;
+ polyIdx = 0;
+ field_84 = 0;
+ field_88 = 0;
+ soundResourceId = kResourceNone;
+ field_90 = 0;
+ paletteResourceId = kResourceNone;
+ memset(&array, 0, sizeof(array));
+ volume = 0;
+ }
+
+ void load(Common::SeekableReadStream *stream);
Common::String toString() {
Common::String output;
diff --git a/engines/asylum/resources/actor.cpp b/engines/asylum/resources/actor.cpp
index 682a20cd7d..a0eddf2245 100644
--- a/engines/asylum/resources/actor.cpp
+++ b/engines/asylum/resources/actor.cpp
@@ -52,8 +52,6 @@ Actor::Actor(AsylumEngine *engine, ActorIndex index) : _vm(engine), _index(index
_objectIndex = 0;
_frameIndex = 0;
_frameCount = 0;
- x = y = 0;
- x1 = y1 = x2 = y2 = 0;
_direction = kDirection0;
_field_3C = 0;
_status = kActorStatusNone;
@@ -132,16 +130,16 @@ void Actor::load(Common::SeekableReadStream *stream) {
if (!stream)
error("[Actor::load] invalid stream");
- x = stream->readSint32LE();
- y = stream->readSint32LE();
- _resourceId = (ResourceId)stream->readSint32LE();
- _objectIndex = stream->readSint32LE();
- _frameIndex = stream->readUint32LE();
- _frameCount = stream->readUint32LE();
- x1 = stream->readSint32LE();
- y1 = stream->readSint32LE();
- x2 = stream->readSint32LE();
- y2 = stream->readSint32LE();
+ _point.x = stream->readSint32LE();
+ _point.y = stream->readSint32LE();
+ _resourceId = (ResourceId)stream->readSint32LE();
+ _objectIndex = stream->readSint32LE();
+ _frameIndex = stream->readUint32LE();
+ _frameCount = stream->readUint32LE();
+ _point1.x = stream->readSint32LE();
+ _point1.y = stream->readSint32LE();
+ _point2.x = stream->readSint32LE();
+ _point2.y = stream->readSint32LE();
_boundingRect.left = (int16)(stream->readSint32LE() & 0xFFFF);
_boundingRect.top = (int16)(stream->readSint32LE() & 0xFFFF);
@@ -223,18 +221,6 @@ void Actor::load(Common::SeekableReadStream *stream) {
_field_9A0 = stream->readSint32LE();
}
-/////////////////////////////////////////////////////////////////////////
-// Visibility
-//////////////////////////////////////////////////////////////////////////
-void Actor::setVisible(bool value) {
- if (value)
- flags |= kActorFlagVisible;
- else
- flags &= ~kActorFlagVisible;
-
- stopSound();
-}
-
/////////////////////////////////////////////////////////////////////////
// Update & status
//////////////////////////////////////////////////////////////////////////
@@ -245,7 +231,7 @@ void Actor::draw() {
// Draw the actor
Common::Point point;
Common::Rect frameRect = GraphicResource::getFrameRect(_vm, _resourceId, _frameIndex);
- getScene()->adjustCoordinates(frameRect.left + x + x1, frameRect.top + y + y1, &point);
+ getScene()->adjustCoordinates(frameRect.left + _point.x + _point1.x, frameRect.top + _point.y + _point1.y, &point);
// Compute frame index
uint32 frameIndex = _frameIndex;
@@ -575,8 +561,8 @@ void Actor::updateStatus(ActorStatus actorStatus) {
case kActorStatus7:
if (getWorld()->chapter == kChapter2 && _index == 10 && _vm->isGameFlagSet(kGameFlag279)) {
Actor *actor = getScene()->getActor(0);
- actor->x1 = x2 + x1 - actor->x2;
- actor->y1 = y2 + y1 - actor->y2;
+ actor->getPoint1()->x = _point2.x + _point1.x - actor->getPoint2()->x;
+ actor->getPoint1()->y = _point2.y + _point1.y - actor->getPoint2()->y;
actor->setDirection(kDirection4);
getScene()->setPlayerActorIndex(0);
@@ -734,8 +720,8 @@ void Actor::faceTarget(ObjectId id, DirectionFrom from) {
break;
case kDirectionFromActor:
- newX = x2 + x1;
- newY = y2 + y1;
+ newX = _point1.x + _point2.x;
+ newY = _point1.y + _point2.y;
break;
case kDirectionFromParameters:
@@ -743,12 +729,12 @@ void Actor::faceTarget(ObjectId id, DirectionFrom from) {
break;
}
- updateFromDirection(getDirection(x2 + x1, y2 + y1, newX, newY));
+ updateFromDirection(getDirection(_point1.x + _point2.x, _point1.y + _point2.y, newX, newY));
}
void Actor::setPosition(int32 newX, int32 newY, ActorDirection newDirection, uint32 frame) {
- x1 = newX - x2;
- y1 = newY - y2;
+ _point1.x = newX - _point2.x;
+ _point1.y = newY - _point2.y;
if (_direction != kDirection8)
updateFromDirection(newDirection);
@@ -775,12 +761,9 @@ Common::String Actor::toString(bool shortString) {
output += Common::String::format("objectIndex: %d: \n", _objectIndex);
output += Common::String::format("frameIndex: %d: \n", _frameIndex);
output += Common::String::format("frameCount: %d: \n", _frameCount);
- output += Common::String::format("x: %d: \n", x);
- output += Common::String::format("y: %d: \n", y);
- output += Common::String::format("x1: %d: \n", x1);
- output += Common::String::format("y1: %d: \n", y1);
- output += Common::String::format("x2: %d: \n", x2);
- output += Common::String::format("y2: %d: \n", y2);
+ output += Common::String::format("(x, y): (%d , %d): \n", _point.x, _point.y);
+ output += Common::String::format("(x1, y1): (%d , %d): \n", _point1.x, _point1.y);
+ output += Common::String::format("(x2, y2): (%d , %d): \n", _point2.x, _point2.y);
output += Common::String::format("flags: %d: \n", flags);
output += Common::String::format("actionType: %d: \n", actionType);
output += Common::String::format("boundingRect: top[%d] left[%d] right[%d] bottom[%d]: \n", _boundingRect.top, _boundingRect.left, _boundingRect.right, _boundingRect.bottom);
@@ -1067,7 +1050,7 @@ void Actor::updateStatusEnabled() {
break;
case 1:
- updateStatusEnabledProcessStatus(1088, 956, 2, x1 + x2, 900);
+ updateStatusEnabledProcessStatus(1088, 956, 2, _point1.x + _point2.x, 900);
break;
case 2:
@@ -1090,8 +1073,8 @@ void Actor::updateStatusEnabled() {
}
void Actor::updateStatusEnabledProcessStatus(int32 testX, int32 testY, uint32 counter, int32 setX, int32 setY) {
- int32 xsum = x1 + x2;
- int32 ysum = y1 + y2;
+ int32 xsum = _point1.x + _point2.x;
+ int32 ysum = _point1.y + _point2.y;
if (xsum != testX || ysum != testY) {
if (rnd(1000) < 5)
@@ -1180,7 +1163,32 @@ void Actor::updateStatus15_Chapter2_Actor11() {
}
void Actor::updateStatus15_Chapter11() {
- error("[Actor::updateStatus15_Chapter11] not implemented!");
+ Common::Rect *rect = getSharedData()->getActorRect();
+ Actor *actor0 = getScene()->getActor(0);
+
+ rect->left = actor0->getPoint1()->x + actor0->getPoint2()->x;
+ rect->top = actor0->getPoint1()->y + actor0->getPoint2()->y - 5;
+ rect->right = _point1.x + _point2.x;
+ rect->bottom = _point1.y + _point2.y;
+
+ updateCoordinates(*rect);
+
+ ++_frameIndex;
+ if (_frameIndex >= _frameCount)
+ updateStatus(kActorStatus14);
+
+ if (_frameIndex == 14) {
+ if (Actor::distance(*rect) < 75) {
+ actor0->updateStatus(kActorStatus16);
+ ++getWorld()->field_E848C;
+
+ getSound()->stop(getWorld()->soundResourceIds[3]);
+ getSound()->stop(getWorld()->soundResourceIds[4]);
+ getSound()->stop(getWorld()->soundResourceIds[5]);
+
+ getSpeech()->playPlayer(131);
+ }
+ }
}
void Actor::updateStatus15_Chapter11_Player() {
@@ -1226,7 +1234,7 @@ void Actor::updateFinish() {
if (_field_944 == 4 || !isVisible())
return;
- int32 areaIndex = getScene()->findActionArea(Common::Point((int16)(x2 + x1), (int16)(y2 + y1)));
+ int32 areaIndex = getScene()->findActionArea(Common::Point((int16)(_point1.x + _point2.x), (int16)(_point1.y + _point2.y)));
if (areaIndex == _actionIdx3 || areaIndex == -1)
return;
@@ -1248,15 +1256,61 @@ void Actor::updateFinish() {
}
}
+void Actor::updateCoordinates(const Common::Rect &rect) {
+ if (getScene()->getActor(1)->isVisible())
+ return;
+
+ // FIXME: there is a check for valid rectangles in Common::Rect, so make sure we can get improper ones
+
+ uint32 width = abs(rect.bottom - rect.top);
+ if (width > 5)
+ width = 5;
+
+ if (rect.bottom - rect.top == 0)
+ return;
+
+ Common::Point pt(rect.right, rect.bottom);
+ ActorDirection direction = (rect.top - rect.bottom > 0) ? kDirection4 : kDirection0;
+
+ if (process_408B20(&pt, direction, width + 3, false))
+ updateCoordinatesForDirection(direction, width - 1, &_point);
+}
+
+void Actor::resetActors() {
+ getCursor()->hide();
+ getScene()->getActor(0)->hide();
+ getScene()->getActor(1)->setFrameIndex(0);
+
+ getWorld()->tickCount1 = _vm->getTick() + 3000;
+}
+
//////////////////////////////////////////////////////////////////////////
// Misc
//////////////////////////////////////////////////////////////////////////
+
+void Actor::setVisible(bool value) {
+ if (value)
+ flags |= kActorFlagVisible;
+ else
+ flags &= ~kActorFlagVisible;
+
+ stopSound();
+}
+
+bool Actor::isOnScreen() {
+ Common::Rect scene(getWorld()->yTop, getWorld()->xLeft, getWorld()->yTop + 480, getWorld()->xLeft + 640);
+ Common::Rect actor(_boundingRect);
+ actor.moveTo(_point1.x, _point1.y);
+
+ return isVisible() && scene.intersects(actor);
+}
+
void Actor::setVolume() {
if (!_soundResourceId || !getSound()->isPlaying(_soundResourceId))
return;
// Compute volume
- int32 volume = Config.voiceVolume + getSound()->calculateVolumeAdjustement(x2 + x1, y2 + y1, _field_968, 0);
+ int32 volume = Config.voiceVolume + getSound()->calculateVolumeAdjustement(_point1.x + _point2.x, _point1.y + _point2.y, _field_968, 0);
if (volume < -10000)
volume = -10000;
@@ -1383,7 +1437,7 @@ int32 Actor::getGraphicsFlags() {
return ((_direction < 5) - 1) & 2;
}
-int32 Actor::getFieldValue() const {
+int32 Actor::getDistance() const {
int32 index = (_frameIndex >= _frameCount) ? (2 * _frameCount) - (_frameIndex + 1): _frameIndex;
if (index >= 20)
@@ -1411,4 +1465,73 @@ int32 Actor::getFieldValue() const {
}
}
+uint32 Actor::getDistanceForFrame(ActorDirection direction, uint32 frameIndex) {
+ switch (_direction) {
+ default:
+ case kDirection0:
+ case kDirection4:
+ return _field_880[frameIndex];
+
+ case kDirection1:
+ case kDirection3:
+ case kDirection5:
+ case kDirection7:
+ return _field_8D0[frameIndex];
+
+ case kDirection2:
+ case kDirection6:
+ return _field_830[frameIndex];
+ }
+}
+
+uint32 Actor::distance(const Common::Rect &rect) {
+ return sqrt((double)(rect.width() ^ 2 + rect.height() ^ 2));
+}
+
+void Actor::updateCoordinatesForDirection(ActorDirection direction, int32 delta, Common::Point *point) {
+ if (!point)
+ error("[Actor::updateCoordinatesForDirection] Invalid point (NULL)!");
+
+ switch (direction) {
+ default:
+ break;
+
+ case kDirection0:
+ point->y -= delta;
+ break;
+
+ case kDirection1:
+ point->x -= delta;
+ point->y -= delta;
+ break;
+
+ case kDirection2:
+ point->x -= delta;
+ break;
+
+ case kDirection3:
+ point->x -= delta;
+ point->y += delta;
+ break;
+
+ case kDirection4:
+ point->y += delta;
+ break;
+
+ case kDirection5:
+ point->x += delta;
+ point->y += delta;
+ break;
+
+ case kDirection6:
+ point->x += delta;
+ break;
+
+ case kDirection7:
+ point->y += delta;
+ point->y -= delta;
+ break;
+ }
+}
+
} // end of namespace Asylum
diff --git a/engines/asylum/resources/actor.h b/engines/asylum/resources/actor.h
index 9e35927f15..7ffccbdaf0 100644
--- a/engines/asylum/resources/actor.h
+++ b/engines/asylum/resources/actor.h
@@ -48,12 +48,6 @@ public:
//////////////////////////////////////////////////////////////////////////
// Public variables & accessors
//////////////////////////////////////////////////////////////////////////
- int32 x;
- int32 y;
- int32 x1;
- int32 y1;
- int32 x2;
- int32 y2;
int32 flags;
int32 actionType; // ActionType enum value
@@ -82,6 +76,9 @@ public:
uint32 getFrameIndex() { return _frameIndex; }
char *getName() { return (char *)&_name; }
int32 getNumberValue01() { return _numberValue01; }
+ Common::Point *getPoint() { return &_point; }
+ Common::Point *getPoint1() { return &_point1; }
+ Common::Point *getPoint2() { return &_point2; }
int32 getReaction(uint32 index) { return _reaction[index]; }
ResourceId getResourceId() { return _resourceId; }
ResourceId getResourcesId(uint32 index) { return _graphicResourceIds[index]; }
@@ -255,11 +252,13 @@ private:
//////////////////////////////////////////////////////////////////////////
// Data
//////////////////////////////////////////////////////////////////////////
+ Common::Point _point;
ResourceId _resourceId;
int32 _objectIndex;
uint32 _frameIndex;
uint32 _frameCount;
- // x1, y1, x2, y2
+ Common::Point _point1;
+ Common::Point _point2;
Common::Rect _boundingRect;
ActorDirection _direction;
int32 _field_3C;
@@ -355,6 +354,8 @@ private:
void updateFinish();
+
+
//////////////////////////////////////////////////////////////////////////
// Misc
//////////////////////////////////////////////////////////////////////////
@@ -366,11 +367,22 @@ private:
*/
void setVisible(bool value);
+ /**
+ * Query if this actor is on screen.
+ *
+ * @return true if on screen, false if not.
+ */
+ bool isOnScreen();
+
/**
* Sets the volume.
*/
void setVolume();
+ void updateCoordinates(const Common::Rect &rect);
+
+ void resetActors();
+
//////////////////////////////////////////////////////////////////////////
// Helper methods
//////////////////////////////////////////////////////////////////////////
@@ -410,8 +422,40 @@ private:
*/
int32 getGraphicsFlags();
- int32 getFieldValue() const;
+ /**
+ * Gets a distance depending on actor direction
+ *
+ * @return The distance.
+ */
+ int32 getDistance() const;
+
+ /**
+ * Gets the distance for a frame.
+ *
+ * @param direction The direction.
+ * @param frameIndex Zero-based index of the frame.
+ *
+ * @return The distance for frame.
+ */
+ uint32 getDistanceForFrame(ActorDirection direction, uint32 frameIndex);
+
+ /**
+ * Get the distance from the rectangle
+ *
+ * @param rect The rectangle.
+ *
+ * @return the distance
+ */
+ static uint32 distance(const Common::Rect &rect);
+ /**
+ * Updates the coordinates depending on the direction.
+ *
+ * @param direction The direction.
+ * @param delta The delta.
+ * @param [in,out] point If non-null, the point.
+ */
+ static void updateCoordinatesForDirection(ActorDirection direction, int32 delta, Common::Point *point);
}; // end of class MainActor
diff --git a/engines/asylum/resources/special.cpp b/engines/asylum/resources/special.cpp
index af196b9cd4..dbe88608c1 100644
--- a/engines/asylum/resources/special.cpp
+++ b/engines/asylum/resources/special.cpp
@@ -243,8 +243,8 @@ void Special::chapter2(Object *object, ActorIndex actorIndex) {
// FIXME: This is wrong, the 386th object is used as an offset to the proper actor
//Object *obj386 = getWorld()->objects[386];
- //actor->x1 = obj386->getSoundY();
- //actor->y1 = obj386->getField688() + getWorld()->coordinates[actorIndex - 22]; // FIXME out of bound access for actorIndex == 29
+ //actor->getPoint1()->x = obj386->getSoundY();
+ //actor->getPoint1()->y = obj386->getField688() + getWorld()->coordinates[actorIndex - 22]; // FIXME out of bound access for actorIndex == 29
//actor->setFrameIndex(obj386->getField67C());
//actor->setDirection(obj386->getField6A4());
@@ -261,14 +261,14 @@ void Special::chapter2(Object *object, ActorIndex actorIndex) {
case 38:
case 39:
if (actor->getFrameIndex() == 9) {
- actor->x1 = -1000;
+ actor->getPoint1()->x = -1000;
actor->setFrameIndex(0);
}
break;
case 40:
if (actor->getFrameIndex() == 9) {
- actor->x1 = -1000;
+ actor->getPoint1()->x = -1000;
actor->setFrameIndex(0);
if (actor->isVisible())
@@ -416,8 +416,8 @@ void Special::chapter6(Object *object, ActorIndex actorIndex) {
if (actorIndex == 2 || actorIndex == 3) {
Actor *actor = getScene()->getActor(actorIndex);
- getWorld()->ambientSounds[0].x = actor->x2 + actor->x1;
- getWorld()->ambientSounds[0].y = actor->y2 + actor->y1;
+ getWorld()->ambientSounds[0].x = actor->getPoint2()->x + actor->getPoint1()->x;
+ getWorld()->ambientSounds[0].y = actor->getPoint2()->y + actor->getPoint1()->y;
}
}
@@ -493,21 +493,21 @@ void Special::chapter7(Object *object, ActorIndex actorIndex) {
actor1->hide();
actor2->show();
} else if (actor0->getDirection() == 2 || actor0->getDirection() == 3) {
- actor1->x1 = actor0->x1;
- actor1->y1 = actor0->y1 - 15;
+ actor1->getPoint1()->x = actor0->getPoint1()->x;
+ actor1->getPoint1()->y = actor0->getPoint1()->y - 15;
} else if (actor0->getDirection() == 5 || actor0->getDirection() == 6) {
- actor1->x1 = actor0->x1 + 20;
- actor1->y1 = actor0->y1 - 15;
+ actor1->getPoint1()->x = actor0->getPoint1()->x + 20;
+ actor1->getPoint1()->y = actor0->getPoint1()->y - 15;
} else {
- actor1->x1 = actor0->x1 + 5;
- actor1->y1 = actor0->y1 - 10;
+ actor1->getPoint1()->x = actor0->getPoint1()->x + 5;
+ actor1->getPoint1()->y = actor0->getPoint1()->y - 10;
}
break;
case 2:
if (actor0->getDirection() <= 2 || actor0->getDirection() >= 7) {
- actor2->x1 = actor0->x1 + 10;
- actor2->y1 = actor0->y1 - 10;
+ actor2->getPoint1()->x = actor0->getPoint1()->x + 10;
+ actor2->getPoint1()->y = actor0->getPoint1()->y - 10;
} else {
actor2->hide();
actor1->show();
@@ -1329,10 +1329,10 @@ void Special::playSoundPanning(ResourceId resourceId, int32 attenuation, ActorIn
// Calculate volume adjustment
int32 adjustedVolume = Config.voiceVolume;
- adjustedVolume += getSound()->calculateVolumeAdjustement(actor->x1, actor->y1, attenuation, 0);
+ adjustedVolume += getSound()->calculateVolumeAdjustement(actor->getPoint1()->x, actor->getPoint1()->y, attenuation, 0);
// Calculate panning
- int32 panning = getSound()->calculatePanningAtPoint(actor->x1 + actor->x2, actor->y1 + actor->y2);
+ int32 panning = getSound()->calculatePanningAtPoint(actor->getPoint1()->x + actor->getPoint2()->x, actor->getPoint1()->y + actor->getPoint2()->y);
getSound()->playSound(resourceId, false, adjustedVolume, panning);
}
diff --git a/engines/asylum/resources/worldstats.cpp b/engines/asylum/resources/worldstats.cpp
index 999b2b199c..65ec0bb5e6 100644
--- a/engines/asylum/resources/worldstats.cpp
+++ b/engines/asylum/resources/worldstats.cpp
@@ -125,66 +125,66 @@ void WorldStats::load(Common::SeekableReadStream *stream) {
boundingRect.bottom = (int16)(stream->readSint32LE() & 0xFFFF);
// read common graphic resources
- backgroundImage = (ResourceId)stream->readSint32LE();
- curScrollUp = (ResourceId)stream->readSint32LE();
- curScrollUpLeft = (ResourceId)stream->readSint32LE();
- curScrollLeft = (ResourceId)stream->readSint32LE();
- curScrollDownLeft = (ResourceId)stream->readSint32LE();
- curScrollDown = (ResourceId)stream->readSint32LE();
- curScrollDownRight = (ResourceId)stream->readSint32LE();
- curScrollRight = (ResourceId)stream->readSint32LE();
- curScrollUpRight = (ResourceId)stream->readSint32LE();
- curHand = (ResourceId)stream->readSint32LE();
- curMagnifyingGlass = (ResourceId)stream->readSint32LE();
- curTalkNPC = (ResourceId)stream->readSint32LE();
- curGrabPointer = (ResourceId)stream->readSint32LE();
- curTalkNPC2 = (ResourceId)stream->readSint32LE();
- font1 = (ResourceId)stream->readSint32LE();
- font2 = (ResourceId)stream->readSint32LE();
- font3 = (ResourceId)stream->readSint32LE();
- currentPaletteId = (ResourceId)stream->readSint32LE();
- cellShadeMask1 = stream->readSint32LE();
- cellShadeMask2 = stream->readSint32LE();
- cellShadeMask3 = stream->readSint32LE();
- unused = stream->readSint32LE();
- smallCurUp = stream->readSint32LE();
- smallCurDown = stream->readSint32LE();
- encounterFrameBg = stream->readSint32LE();
-
- width = stream->readSint32LE();
- height = stream->readSint32LE();
- motionStatus = stream->readSint32LE();
- field_8C = stream->readSint32LE();
+ backgroundImage = (ResourceId)stream->readSint32LE();
+ curScrollUp = (ResourceId)stream->readSint32LE();
+ curScrollUpLeft = (ResourceId)stream->readSint32LE();
+ curScrollLeft = (ResourceId)stream->readSint32LE();
+ curScrollDownLeft = (ResourceId)stream->readSint32LE();
+ curScrollDown = (ResourceId)stream->readSint32LE();
+ curScrollDownRight = (ResourceId)stream->readSint32LE();
+ curScrollRight = (ResourceId)stream->readSint32LE();
+ curScrollUpRight = (ResourceId)stream->readSint32LE();
+ curHand = (ResourceId)stream->readSint32LE();
+ curMagnifyingGlass = (ResourceId)stream->readSint32LE();
+ curTalkNPC = (ResourceId)stream->readSint32LE();
+ curGrabPointer = (ResourceId)stream->readSint32LE();
+ curTalkNPC2 = (ResourceId)stream->readSint32LE();
+ font1 = (ResourceId)stream->readSint32LE();
+ font2 = (ResourceId)stream->readSint32LE();
+ font3 = (ResourceId)stream->readSint32LE();
+ currentPaletteId = (ResourceId)stream->readSint32LE();
+ cellShadeMask1 = stream->readSint32LE();
+ cellShadeMask2 = stream->readSint32LE();
+ cellShadeMask3 = stream->readSint32LE();
+ unused = stream->readSint32LE();
+ smallCurUp = stream->readSint32LE();
+ smallCurDown = stream->readSint32LE();
+ encounterFrameBg = stream->readSint32LE();
+
+ width = stream->readSint32LE();
+ height = stream->readSint32LE();
+ motionStatus = stream->readSint32LE();
+ field_8C = stream->readSint32LE();
uint32 numActions = stream->readUint32LE();
- uint32 numObjects = stream->readUint32LE();
+ uint32 numObjects = stream->readUint32LE();
for (int32 c = 0; c < 7; c++)
coordinates[c] = stream->readSint32LE();
- uint32 numActors = stream->readUint32LE();
+ uint32 numActors = stream->readUint32LE();
stereoReversedFlag = stream->readSint32LE();
for (int32 r = 0; r < 6; r++) {
- sceneRects[r].left = (int16)(stream->readSint32LE() & 0xFFFF);
- sceneRects[r].top = (int16)(stream->readSint32LE() & 0xFFFF);
- sceneRects[r].right = (int16)(stream->readSint32LE() & 0xFFFF);
- sceneRects[r].bottom = (int16)(stream->readSint32LE() & 0xFFFF);
+ sceneRects[r].left = (int16)(stream->readSint32LE() & 0xFFFF);
+ sceneRects[r].top = (int16)(stream->readSint32LE() & 0xFFFF);
+ sceneRects[r].right = (int16)(stream->readSint32LE() & 0xFFFF);
+ sceneRects[r].bottom = (int16)(stream->readSint32LE() & 0xFFFF);
}
- sceneRectIdx = stream->readByte();
- field_11D[0] = stream->readByte();
- field_11D[1] = stream->readByte();
- field_11D[2] = stream->readByte();
- field_120 = stream->readSint32LE();
- scriptIndex = stream->readSint32LE();
+ sceneRectIdx = stream->readByte();
+ field_11D[0] = stream->readByte();
+ field_11D[1] = stream->readByte();
+ field_11D[2] = stream->readByte();
+ field_120 = stream->readSint32LE();
+ scriptIndex = stream->readSint32LE();
for (int32 gr = 0; gr < 100; gr++)
- graphicResourceIds[gr] = (ResourceId)stream->readSint32LE();
+ graphicResourceIds[gr] = (ResourceId)stream->readSint32LE();
- sceneTitleGraphicResourceId = (ResourceId)stream->readSint32LE();
+ sceneTitleGraphicResourceId = (ResourceId)stream->readSint32LE();
sceneTitlePaletteResourceId = (ResourceId)stream->readSint32LE();
- actorType = stream->readUint32LE();
+ actorType = stream->readUint32LE();
for (int32 s = 0; s < 50; s++)
soundResourceIds[s] = (ResourceId)stream->readSint32LE();
@@ -241,36 +241,9 @@ void WorldStats::load(Common::SeekableReadStream *stream) {
stream->seek(0xD6B5A); // where action items start
- // FIXME Figure out all the actions items
for (uint32 a = 0; a < numActions; a++) {
ActionArea *action = new ActionArea();
-
- stream->read(action->name, 52);
- action->id = stream->readSint32LE();
- action->field01 = stream->readSint32LE();
- action->field02 = stream->readSint32LE();
- action->field_40 = stream->readSint32LE();
- action->field_44 = stream->readSint32LE();
- action->flags = stream->readSint32LE();
- action->scriptIndex = stream->readSint32LE();
- action->scriptIndex2 = stream->readSint32LE();
- action->actionType = stream->readSint32LE();
-
- for (int32 aa1 = 0; aa1 < 10; aa1++)
- action->flagNums[aa1] = stream->readSint32LE();
-
- action->field_7C = stream->readSint32LE();
- action->polyIdx = stream->readSint32LE();
- action->field_84 = stream->readSint32LE();
- action->field_88 = stream->readSint32LE();
- action->soundResourceId = (ResourceId)stream->readSint32LE();
- action->field_90 = stream->readSint32LE();
- action->paletteResourceId = (ResourceId)stream->readSint32LE();
-
- for (int32 aa2 = 0; aa2 < 5; aa2++)
- action->array[aa2] = stream->readSint32LE();
-
- action->volume = stream->readSint32LE();
+ action->load(stream);
actions.push_back(action);
}
@@ -278,6 +251,27 @@ void WorldStats::load(Common::SeekableReadStream *stream) {
// Jump over unused actions
stream->seek((ACTIONS_MAX_COUNT - numActions) * ACTIONS_SIZE, SEEK_CUR);
+ field_E848C = stream->readSint32LE();
+ field_E8490 = stream->readSint32LE();
+ field_E8494 = stream->readSint32LE();
+ field_E8498 = stream->readSint32LE();
+ field_E849C = stream->readSint32LE();
+
+ for (int32 i = 0; i < 10; i++)
+ field_E84A0[i] = stream->readSint32LE();
+
+ for (int32 i = 0; i < 20; i++)
+ field_E84C8[i] = stream->readSint32LE();
+
+ field_E8518 = stream->readSint32LE();
+
+ for (int32 i = 0; i < 30; i++)
+ field_E851C[i] = stream->readSint32LE();
+
+ for (int32 i = 0; i < 30; i++)
+ field_E8594[i] = stream->readSint32LE();
+
+ // FIXME missing data!
field_E860C = stream->readSint32LE();
for (int32 i = 0; i < 6; i++)
field_E8610[i] = stream->readUint32LE();
diff --git a/engines/asylum/resources/worldstats.h b/engines/asylum/resources/worldstats.h
index 1f2ae37055..ad7712f099 100644
--- a/engines/asylum/resources/worldstats.h
+++ b/engines/asylum/resources/worldstats.h
@@ -109,14 +109,20 @@ public:
int32 musicFlag;
ResourceId musicResourceId;
int32 musicStatusExt;
-
- // FIXME: Investigate if we need to actually reserve maxsize for this arrays.
- // It always have that size under scene file and they are always save in savegames.
- Common::Array<Object*> objects; // maxsize 400
+ Common::Array<Object*> objects; // maxsize 400
Common::Array<Actor*> actors; // maxsize 50
// TODO add rest fields
Common::Array<ActionArea*> actions; // maxsize 400
- // TODO add rest fields
+ int32 field_E848C;
+ int32 field_E8490;
+ int32 field_E8494;
+ int32 field_E8498;
+ int32 field_E849C;
+ int32 field_E84A0[10];
+ int32 field_E84C8[20];
+ int32 field_E8518;
+ int32 field_E851C[30];
+ int32 field_E8594[30];
int32 field_E860C;
uint32 field_E8610[6];
uint32 field_E8628[6];
diff --git a/engines/asylum/system/sound.cpp b/engines/asylum/system/sound.cpp
index a94b633e32..3469e99067 100644
--- a/engines/asylum/system/sound.cpp
+++ b/engines/asylum/system/sound.cpp
@@ -150,8 +150,8 @@ int32 Sound::calculateVolumeAdjustement(int32 x, int32 y, int32 attenuation, int
Actor *player = getScene()->getActor();
if (getSharedData()->getGlobalX() == -1) {
- x -= (player->x1 + player->x2);
- y -= (player->y1 + player->y2);
+ x -= (player->getPoint1()->x + player->getPoint2()->x);
+ y -= (player->getPoint1()->y + player->getPoint2()->y);
} else {
x -= getSharedData()->getGlobalX();
y -= getSharedData()->getGlobalY();
diff --git a/engines/asylum/system/speech.cpp b/engines/asylum/system/speech.cpp
index f96344dbef..51f920bd66 100644
--- a/engines/asylum/system/speech.cpp
+++ b/engines/asylum/system/speech.cpp
@@ -236,7 +236,7 @@ void Speech::prepareSpeech() {
Common::Point point;
Actor *actor = getScene()->getActor();
- getScene()->adjustCoordinates(actor->x1, actor->y1, &point);
+ getScene()->adjustCoordinates(actor->getPoint1()->x, actor->getPoint1()->y, &point);
int32 posY = (((point.y >= 240) - 1) & 280) + 40;
diff --git a/engines/asylum/views/scene.cpp b/engines/asylum/views/scene.cpp
index 1fcf3c1bc9..1db5db400f 100644
--- a/engines/asylum/views/scene.cpp
+++ b/engines/asylum/views/scene.cpp
@@ -133,8 +133,8 @@ void Scene::enter(ResourcePackId packId) {
// Update current player bounding rectangle
Actor *player = getActor();
Common::Rect *boundingRect = player->getBoundingRect();
- boundingRect->bottom = (int16)player->y2;
- boundingRect->right = (int16)(player->x2 * 2);
+ boundingRect->bottom = (int16)player->getPoint2()->y;
+ boundingRect->right = (int16)(player->getPoint2()->x * 2);
// Adjust scene bounding rect
_ws->boundingRect = Common::Rect(195, 115, 445 - boundingRect->right, 345 - boundingRect->bottom);
@@ -144,8 +144,8 @@ void Scene::enter(ResourcePackId packId) {
player->enable();
// Update current player coordinates
- player->x1 -= player->x2;
- player->y1 -= player->y2;
+ player->getPoint1()->x -= player->getPoint2()->x;
+ player->getPoint1()->y -= player->getPoint2()->y;
// Update all other actors
if (_ws->actors.size() > 1) {
@@ -156,11 +156,11 @@ void Scene::enter(ResourcePackId packId) {
actor->setDirection(kDirection1);
actor->enable();
- actor->x1 -= actor->x2;
- actor->y1 -= actor->y2;
+ actor->getPoint1()->x -= actor->getPoint2()->x;
+ actor->getPoint1()->y -= actor->getPoint2()->y;
- actor->getBoundingRect()->bottom = (int16)actor->y2;
- actor->getBoundingRect()->right = (int16)(2 * actor->x2);
+ actor->getBoundingRect()->bottom = (int16)actor->getPoint2()->y;
+ actor->getBoundingRect()->right = (int16)(2 * actor->getPoint2()->x);
}
}
@@ -454,19 +454,19 @@ void Scene::updateMouse() {
// .text:0040A1B0 getCharacterScreenPosition()
// which was only ever called at this point, so
// inlining it for simplicity
- pt.x = (int16)(act->x1 -_ws->xLeft);
- pt.y = (int16)(act->y1 -_ws->yTop);
+ pt.x = (int16)(act->getPoint1()->x -_ws->xLeft);
+ pt.y = (int16)(act->getPoint1()->y -_ws->yTop);
if (_packId != 2 || _playerActorIdx != 10) {
actorPos.left = pt.x + 20;
actorPos.top = pt.y;
- actorPos.right = (int16)(pt.x + 2 * act->x2);
- actorPos.bottom = (int16)(pt.y + act->y2);
+ actorPos.right = (int16)(pt.x + 2 * act->getPoint2()->x);
+ actorPos.bottom = (int16)(pt.y + act->getPoint2()->y);
} else {
actorPos.left = pt.x + 50;
actorPos.top = pt.y + 60;
- actorPos.right = (int16)(pt.x + getActor(10)->x2 + 10);
- actorPos.bottom = (int16)(pt.y + getActor(10)->y2 - 20);
+ actorPos.right = (int16)(pt.x + getActor(10)->getPoint2()->x + 10);
+ actorPos.bottom = (int16)(pt.y + getActor(10)->getPoint2()->y - 20);
}
ActorDirection dir = kDirectionInvalid;
@@ -819,8 +819,8 @@ bool Scene::hitTestActor(const Common::Point pt) {
return hitTestPixel(act->getResourceId(),
hitFrame,
- pt.x - act->x - actPos.x,
- pt.y - act->y - actPos.y,
+ pt.x - act->getPoint()->x - actPos.x,
+ pt.y - act->getPoint()->y - actPos.y,
(act->getDirection() >= 0));
}
@@ -941,8 +941,8 @@ int32 Scene::calculateVolumeAdjustment(AmbientSoundItem *snd, Actor *act) {
if (snd->field_10) {
/* FIXME properly handle global x/y
if (g_object_x == -1) {
- x = snd->x - act->x1 - act->x2;
- y = snd->y - act->y1 - act->y2;
+ x = snd->x - act->getPoint1()->x - act->getPoint2()->x;
+ y = snd->y - act->getPoint1()->y - act->getPoint2()->y;
} else {
x = snd->x - g_object_x;
y = snd->y - g_object_y;
@@ -1015,8 +1015,8 @@ void Scene::updateAdjustScreen() {
Common::Rect b = _ws->boundingRect;
if (_ws->motionStatus == 1) {
- int32 posX = act->x1 - _ws->xLeft;
- int32 posY = act->y1 - _ws->yTop;
+ int32 posX = act->getPoint1()->x - _ws->xLeft;
+ int32 posY = act->getPoint1()->y - _ws->yTop;
if (posX < b.left || posX > b.right) {
int32 newRBounds = posX - b.right;
@@ -1200,7 +1200,7 @@ void Scene::buildUpdateList() {
if (actor->isVisible()) {
UpdateItem item;
item.index = i;
- item.priority = actor->y1 + actor->y2;
+ item.priority = actor->getPoint1()->y + actor->getPoint2()->y;
_updateList.push_back(item);
}
@@ -1232,16 +1232,16 @@ void Scene::processUpdateList() {
} else {
actor->setField938(1);
actor->setField934(0);
- point.x = actor->x1 + actor->x2;
- point.y = actor->y1 + actor->y2;
+ point.x = actor->getPoint1()->x + actor->getPoint2()->x;
+ point.y = actor->getPoint1()->y + actor->getPoint2()->y;
- int32 bottomRight = actor->getBoundingRect()->bottom + actor->y1 + 4;
+ int32 bottomRight = actor->getBoundingRect()->bottom + actor->getPoint1()->y + 4;
if (_ws->chapter == kChapter11 && _updateList[i].index != getPlayerIndex())
bottomRight += 20;
// Our actor rect
- Common::Rect actorRect(actor->x1, actor->y1, actor->x1 + actor->getBoundingRect()->right, bottomRight);
+ Common::Rect actorRect(actor->getPoint1()->x, actor->getPoint1()->y, actor->getPoint1()->x + actor->getBoundingRect()->right, bottomRight);
// Process objects
for (uint32 j = 0; j < _ws->objects.size(); j++) {
@@ -1323,12 +1323,12 @@ void Scene::processUpdateList() {
if (actor2->isVisible() && actor2->getField944() != 1 && actor2->getField944() != 4 && _updateList[k].index != _updateList[i].index) {
- Common::Rect actor2Rect(actor2->x1, actor2->y1, actor2->x1 + actor2->getBoundingRect()->right, actor2->y1 + actor2->getBoundingRect()->bottom);
+ Common::Rect actor2Rect(actor2->getPoint1()->x, actor2->getPoint1()->y, actor2->getPoint1()->x + actor2->getBoundingRect()->right, actor2->getPoint1()->y + actor2->getBoundingRect()->bottom);
if (actor2Rect.contains(actorRect)) {
// Inferior
- if ((actor2->y1 + actor2->y2) > (actor->y1 + actor->y2)) {
+ if ((actor2->getPoint1()->y + actor2->getPoint2()->y) > (actor->getPoint1()->y + actor->getPoint2()->y)) {
if (actor->getPriority() <= actor2->getPriority()) {
if (actor->getField934() || actor2->getNumberValue01()) {
if (!actor2->getNumberValue01())
@@ -1340,7 +1340,7 @@ void Scene::processUpdateList() {
}
// Superior
- if ((actor2->y1 + actor2->y2) < (actor->y1 + actor->y2)) {
+ if ((actor2->getPoint1()->y + actor2->getPoint2()->y) < (actor->getPoint1()->y + actor->getPoint2()->y)) {
if (actor->getPriority() >= actor2->getPriority()) {
if (actor->getField934() || actor2->getNumberValue01()) {
if (!actor2->getNumberValue01())
@@ -1401,8 +1401,8 @@ void Scene::getActorPosition(Actor *actor, Common::Point *pt) {
if (!_ws)
error("[Scene::getActorPosition] WorldStats not initialized properly!");
- pt->x = actor->x1 - _ws->xLeft;
- pt->y = actor->y1 - _ws->yTop;
+ pt->x = actor->getPoint1()->x - _ws->xLeft;
+ pt->y = actor->getPoint1()->y - _ws->yTop;
}
// ----------------------------------
// ---------- SCREEN REGION -----------
@@ -1541,7 +1541,7 @@ void Scene::debugShowActors() {
a->getBoundingRect()->bottom - a->getBoundingRect()->top + 1,
1);
surface.frameRect(*a->getBoundingRect(), 0x22);
- copyToBackBufferClipped(&surface, a->x, a->y);
+ copyToBackBufferClipped(&surface, a->getPoint()->x, a->getPoint()->y);
}
surface.free();
Commit: b090514dbd128f8ca47780b166744f4c22837544
https://github.com/scummvm/scummvm/commit/b090514dbd128f8ca47780b166744f4c22837544
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:19+02:00
Commit Message:
ASYLUM: Add missing case in Speech::playIndexed
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@551 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/staticres.h
engines/asylum/system/speech.cpp
diff --git a/engines/asylum/staticres.h b/engines/asylum/staticres.h
index da180e02db..89fc260d9a 100644
--- a/engines/asylum/staticres.h
+++ b/engines/asylum/staticres.h
@@ -34,6 +34,10 @@ const int MenuIconFixedXpos[12] = { 28, 128, 225, 320, 410, 528, 16, 115, 237, 3
/** Default Actor Indices by Scene */
const int actorType[16] = {0, 0, 0, 0, 1, 0, 2, 0, 3, 0, 1, 1, 3, 0, 0, 0};
+/** Speech indexes */
+const int speechIndex[20] = {17, 22, 27, 37, 45, 12, 16, 19, 25, 29, 14, 18, 23, 29, 35, 6, 9, 13, 19, 27};
+const int speechIndexRandom[20] = { 5, 5, 10, 8, 6, 4, 3, 6, 4, 4, 4, 5, 6, 6, 6, 3, 4, 6, 8, 4};
+
// Delta array for points
static const struct {
int x;
diff --git a/engines/asylum/system/speech.cpp b/engines/asylum/system/speech.cpp
index 51f920bd66..9a9ae1dd85 100644
--- a/engines/asylum/system/speech.cpp
+++ b/engines/asylum/system/speech.cpp
@@ -34,6 +34,7 @@
#include "asylum/views/scene.h"
#include "asylum/asylum.h"
+#include "asylum/staticres.h"
namespace Asylum {
@@ -69,7 +70,7 @@ ResourceId Speech::playIndexed(int32 index) {
int processedIndex;
if (getWorld()->actorType || index != -1) {
- error("[Speech::playIndexed] Missing case using static data!");
+ processedIndex = speechIndex[index + 5 * getWorld()->actorType] + rnd(speechIndexRandom[index + 5 * getWorld()->actorType]);
} else {
switch(_vm->getRandom(3)) {
default:
Commit: f49d9e2425866468602d5c011967fe3c240474ad
https://github.com/scummvm/scummvm/commit/f49d9e2425866468602d5c011967fe3c240474ad
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:19+02:00
Commit Message:
ASYLUM: Fix compilation with latest Singleton changes from trunk
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@552 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/system/config.cpp
diff --git a/engines/asylum/system/config.cpp b/engines/asylum/system/config.cpp
index ea647ea619..2a5df672e2 100644
--- a/engines/asylum/system/config.cpp
+++ b/engines/asylum/system/config.cpp
@@ -25,7 +25,7 @@
#include "asylum/system/config.h"
-DECLARE_SINGLETON(Asylum::ConfigurationManager)
+DECLARE_SINGLETON(Asylum::ConfigurationManager);
namespace Asylum {
Commit: 16dd32098dfcbc447ef3fee6802e5199794ae5ac
https://github.com/scummvm/scummvm/commit/16dd32098dfcbc447ef3fee6802e5199794ae5ac
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:20+02:00
Commit Message:
ASYLUM: Add reaction-related Actor process methods
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@553 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/resources/actor.cpp
engines/asylum/resources/actor.h
diff --git a/engines/asylum/resources/actor.cpp b/engines/asylum/resources/actor.cpp
index a0eddf2245..4bbd5a051a 100644
--- a/engines/asylum/resources/actor.cpp
+++ b/engines/asylum/resources/actor.cpp
@@ -827,15 +827,71 @@ bool Actor::process_408B20(Common::Point *point, ActorDirection direction, int c
}
void Actor::process_41BC00(int32 reactionIndex, int32 numberValue01Add) {
- error("[Actor::process_41BC00] not implemented!");
+ if (reactionIndex > 16)
+ return;
+
+ uint32 count = 0;
+ for (int i = 0; i < 8; i++)
+ if (_reaction[i])
+ count++;
+
+ if (count == 8)
+ return;
+
+ if (!process_41BDB0(reactionIndex, false))
+ _reaction[count] = reactionIndex;
+
+ if (numberValue01Add)
+ _numberValue01 += numberValue01Add;
+
+ getSound()->playSound(MAKE_RESOURCE(kResourcePackHive, 0));
}
void Actor::process_41BCC0(int32 reactionIndex, int32 numberValue01Substract) {
- error("[Actor::process_41BC00] not implemented!");
+ if (reactionIndex > 16)
+ return;
+
+ if (numberValue01Substract) {
+ _numberValue01 -= numberValue01Substract;
+ if (_numberValue01 < 0)
+ _numberValue01 = 0;
+ }
+
+ if (!numberValue01Substract || !_numberValue01) {
+
+ uint32 count = 0;
+ for (int i = 0; i < 8; i++)
+ if (_reaction[i])
+ count++;
+
+ if (count == 8)
+ return;
+
+ if (count == 7) {
+ _reaction[7] = 0;
+ } else {
+ memcpy(&_reaction[count], &_reaction[count + 1], 28 - 4 * count);
+ _reaction[7] = 0;
+ }
+ }
}
-bool Actor::process_41BDB0(int32 reactionIndex, bool testNumberValue01) {
- error("[Actor::process_41BC00] not implemented!");
+bool Actor::process_41BDB0(int32 reactionIndex, int32 testNumberValue01) {
+ if (reactionIndex > 16)
+ return false;
+
+ uint32 count = 0;
+ for (int i = 0; i < 8; i++)
+ if (_reaction[i])
+ count++;
+
+ if (count == 8)
+ return false;
+
+ if (testNumberValue01)
+ return _numberValue01 >= testNumberValue01;
+
+ return true;
}
void Actor::update_40DE20() {
diff --git a/engines/asylum/resources/actor.h b/engines/asylum/resources/actor.h
index 7ffccbdaf0..a2361ca5f3 100644
--- a/engines/asylum/resources/actor.h
+++ b/engines/asylum/resources/actor.h
@@ -224,7 +224,7 @@ public:
bool process_408B20(Common::Point *point, ActorDirection direction, int count, bool hasDelta);
void process_41BC00(int32 reactionIndex, int32 numberValue01Add);
void process_41BCC0(int32 reactionIndex, int32 numberValue01Substract);
- bool process_41BDB0(int32 reactionIndex, bool testNumberValue01);
+ bool process_41BDB0(int32 reactionIndex, int32 testNumberValue01);
void update_40DE20();
/**
Commit: e812374b9fd4a3723c7232ba2dfc5166cde4c1fb
https://github.com/scummvm/scummvm/commit/e812374b9fd4a3723c7232ba2dfc5166cde4c1fb
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:20+02:00
Commit Message:
ASYLUM: Add stubs for loading ActorData as part of the scene (and cleanup scene loading a bit)
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@554 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/resources/actor.cpp
engines/asylum/resources/actor.h
engines/asylum/resources/worldstats.cpp
engines/asylum/resources/worldstats.h
engines/asylum/views/scene.cpp
diff --git a/engines/asylum/resources/actor.cpp b/engines/asylum/resources/actor.cpp
index 4bbd5a051a..c7159c0f83 100644
--- a/engines/asylum/resources/actor.cpp
+++ b/engines/asylum/resources/actor.cpp
@@ -221,6 +221,11 @@ void Actor::load(Common::SeekableReadStream *stream) {
_field_9A0 = stream->readSint32LE();
}
+void Actor::loadData(Common::SeekableReadStream *stream) {
+ // TODO load actor data
+ stream->seek(ACTORDATA_SIZE, SEEK_CUR);
+}
+
/////////////////////////////////////////////////////////////////////////
// Update & status
//////////////////////////////////////////////////////////////////////////
diff --git a/engines/asylum/resources/actor.h b/engines/asylum/resources/actor.h
index a2361ca5f3..0ca2dea4ff 100644
--- a/engines/asylum/resources/actor.h
+++ b/engines/asylum/resources/actor.h
@@ -40,6 +40,11 @@ class Screen;
struct ActionArea;
struct GraphicFrame;
+struct ActorData {
+ int32 count;
+ // TODO add actor data fields
+};
+
class Actor {
public:
Actor(AsylumEngine *engine, ActorIndex index);
@@ -98,12 +103,19 @@ public:
/////////////////////////////////////////////////////////////////////////
/**
- * Loads the actor data
+ * Loads the actor
*
* @param stream If non-null, the Common::SeekableReadStream to load from
*/
void load(Common::SeekableReadStream *stream);
+ /**
+ * Loads the actor data.
+ *
+ * @param stream If non-null, the Common::SeekableReadStream to load from
+ */
+ void loadData(Common::SeekableReadStream *stream);
+
/////////////////////////////////////////////////////////////////////////
// Visibility
/////////////////////////////////////////////////////////////////////////
diff --git a/engines/asylum/resources/worldstats.cpp b/engines/asylum/resources/worldstats.cpp
index 65ec0bb5e6..5b5a76201c 100644
--- a/engines/asylum/resources/worldstats.cpp
+++ b/engines/asylum/resources/worldstats.cpp
@@ -211,6 +211,8 @@ void WorldStats::load(Common::SeekableReadStream *stream) {
musicResourceId = (ResourceId)stream->readUint32LE();
musicStatusExt = stream->readSint32LE();
+ //////////////////////////////////////////////////////////////////////////
+ // Read Objects
for (uint32 a = 0; a < numObjects; a++) {
Object *object = new Object(_scene->vm());
object->load(stream);
@@ -218,9 +220,10 @@ void WorldStats::load(Common::SeekableReadStream *stream) {
objects.push_back(object);
}
- // Jump over unused objects
stream->seek((OBJECTS_MAX_COUNT - numObjects) * OBJECTS_SIZE, SEEK_CUR);
+ //////////////////////////////////////////////////////////////////////////
+ // Read Actors
for (ActorIndex index = 0; index < (int)numActors; index++) {
Actor *actor = new Actor(_scene->vm(), index);
actor->load(stream);
@@ -228,27 +231,31 @@ void WorldStats::load(Common::SeekableReadStream *stream) {
actors.push_back(actor);
}
- // Jump over unused actors
stream->seek((ACTORS_MAX_COUNT - numActors) * ACTORS_SIZE, SEEK_CUR);
- uint8 mainActorData[500];
- stream->read(mainActorData, 500);
+ //////////////////////////////////////////////////////////////////////////
+ // Read actor data
+ for (ActorIndex index = 0; index < (int)numActors; index++)
+ actors[index]->loadData(stream);
- // FIXME
- // This is ONLY ever going to work for scenes where there's only
- // one actor in the worldStats->actors[] collection
- actors[0]->setRawResources(mainActorData);
+ stream->seek((ACTORS_MAX_COUNT - numActors) * ACTORDATA_SIZE, SEEK_CUR);
- stream->seek(0xD6B5A); // where action items start
+ //////////////////////////////////////////////////////////////////////////
+ // Read number of actionlists and polygons
+ numActionLists = stream->readUint32LE();
+ numPolygons = stream->readUint32LE();
+ // FIXME: Read missing data (64 int32)
+ for (int i = 0; i < 64; i++)
+ stream->readUint32LE();
+
+ //////////////////////////////////////////////////////////////////////////
+ // Read actions
for (uint32 a = 0; a < numActions; a++) {
ActionArea *action = new ActionArea();
action->load(stream);
-
- actions.push_back(action);
}
- // Jump over unused actions
stream->seek((ACTIONS_MAX_COUNT - numActions) * ACTIONS_SIZE, SEEK_CUR);
field_E848C = stream->readSint32LE();
@@ -271,8 +278,8 @@ void WorldStats::load(Common::SeekableReadStream *stream) {
for (int32 i = 0; i < 30; i++)
field_E8594[i] = stream->readSint32LE();
- // FIXME missing data!
field_E860C = stream->readSint32LE();
+
for (int32 i = 0; i < 6; i++)
field_E8610[i] = stream->readUint32LE();
diff --git a/engines/asylum/resources/worldstats.h b/engines/asylum/resources/worldstats.h
index ad7712f099..6de5c8649a 100644
--- a/engines/asylum/resources/worldstats.h
+++ b/engines/asylum/resources/worldstats.h
@@ -37,9 +37,10 @@ namespace Asylum {
#define OBJECTS_MAX_COUNT 400
#define ACTIONS_MAX_COUNT 400
-#define ACTORS_SIZE 2468
-#define OBJECTS_SIZE 1704
-#define ACTIONS_SIZE 180
+#define ACTORS_SIZE 2468
+#define ACTORDATA_SIZE 1448
+#define OBJECTS_SIZE 1704
+#define ACTIONS_SIZE 180
class Actor;
class Object;
@@ -109,10 +110,13 @@ public:
int32 musicFlag;
ResourceId musicResourceId;
int32 musicStatusExt;
- Common::Array<Object*> objects; // maxsize 400
+ Common::Array<Object*> objects; // maxsize 400
Common::Array<Actor*> actors; // maxsize 50
- // TODO add rest fields
+ // ActorData is stored in each actor instance
+ int32 numActionLists;
+ int32 numPolygons;
Common::Array<ActionArea*> actions; // maxsize 400
+ // TODO Add missing fields
int32 field_E848C;
int32 field_E8490;
int32 field_E8494;
diff --git a/engines/asylum/views/scene.cpp b/engines/asylum/views/scene.cpp
index 1db5db400f..2f74d9e705 100644
--- a/engines/asylum/views/scene.cpp
+++ b/engines/asylum/views/scene.cpp
@@ -232,17 +232,10 @@ void Scene::load(ResourcePackId packId) {
error("The file isn't recognized as scene %s", filename);
_ws = new WorldStats(fd, this);
- // jump to game polygons data
- fd->seek(0xE8686);
_polygons = new Polygons(fd);
- // jump to action list data
- fd->seek(0xE868E + _polygons->size * _polygons->numEntries);
_actions = new ActionList(_vm);
_actions->load(fd);
- // TODO load rest of data
-
-
fd->close();
delete fd;
Commit: f8838d532240d86d7ffe9a7b394325055063282b
https://github.com/scummvm/scummvm/commit/f8838d532240d86d7ffe9a7b394325055063282b
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:20+02:00
Commit Message:
ASYLUM: Remove unused actor field
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@555 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/resources/actor.cpp
engines/asylum/resources/actor.h
diff --git a/engines/asylum/resources/actor.cpp b/engines/asylum/resources/actor.cpp
index c7159c0f83..ff485e2fe6 100644
--- a/engines/asylum/resources/actor.cpp
+++ b/engines/asylum/resources/actor.cpp
@@ -95,7 +95,6 @@ Actor::Actor(AsylumEngine *engine, ActorIndex index) : _vm(engine), _index(index
_numberStringX = 0;
_numberStringY = 0;
memset(&_numberString01, 0, 8);
- _field_964 = 0;
_field_968 = 0;
_field_96C = 0;
_field_970 = 0;
diff --git a/engines/asylum/resources/actor.h b/engines/asylum/resources/actor.h
index 0ca2dea4ff..2683ef0d2f 100644
--- a/engines/asylum/resources/actor.h
+++ b/engines/asylum/resources/actor.h
@@ -315,7 +315,6 @@ private:
int32 _numberStringX;
int32 _numberStringY;
char _numberString01[8];
- int32 _field_964;
int32 _field_968;
int32 _field_96C;
int32 _field_970;
Commit: 3c3c0a5a4e1b5231edecbfcbea9adeb484929a28
https://github.com/scummvm/scummvm/commit/3c3c0a5a4e1b5231edecbfcbea9adeb484929a28
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:20+02:00
Commit Message:
ASYLUM: Fix compiler warnings (patch by DrMcCoy)
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@556 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/data.h
engines/asylum/resources/actor.cpp
engines/asylum/views/scene.cpp
diff --git a/engines/asylum/data.h b/engines/asylum/data.h
index 170efd74b4..f68b81ee02 100644
--- a/engines/asylum/data.h
+++ b/engines/asylum/data.h
@@ -118,7 +118,7 @@ public:
_sceneXLeft = 0;
_sceneYTop = 0;
_sceneOffset = 0;
- _sceneOffsetAdd;
+ _sceneOffsetAdd = 0;
memset(&_cursorResources[13], kResourceNone, sizeof(_cursorResources));
memset(&_sceneFonts[3], kResourceNone, sizeof(_sceneFonts));
_currentPaletteId = kResourceNone;
diff --git a/engines/asylum/resources/actor.cpp b/engines/asylum/resources/actor.cpp
index ff485e2fe6..19d33e1f23 100644
--- a/engines/asylum/resources/actor.cpp
+++ b/engines/asylum/resources/actor.cpp
@@ -1545,7 +1545,7 @@ uint32 Actor::getDistanceForFrame(ActorDirection direction, uint32 frameIndex) {
}
uint32 Actor::distance(const Common::Rect &rect) {
- return sqrt((double)(rect.width() ^ 2 + rect.height() ^ 2));
+ return sqrt((double)((rect.width() ^ 2) + (rect.height() ^ 2)));
}
void Actor::updateCoordinatesForDirection(ActorDirection direction, int32 delta, Common::Point *point) {
diff --git a/engines/asylum/views/scene.cpp b/engines/asylum/views/scene.cpp
index 2f74d9e705..213b4e85d4 100644
--- a/engines/asylum/views/scene.cpp
+++ b/engines/asylum/views/scene.cpp
@@ -629,7 +629,7 @@ void Scene::handleMouseUpdate(int direction, Common::Rect rect) {
// TODO pass a reference to hitType so it can be populated by
// hitTestScene
newGraphicResourceId = hitTestScene(getCursor()->position(), type);
- if (newGraphicResourceId != -1) {
+ if (newGraphicResourceId != (ResourceId)-1) {
warning ("Can't set mouse cursor, field_D6AC8 not handled ... yet");
// TODO
// check if _ws->field_D6AC8[act->field_638] != newGraphicResourceId
@@ -787,7 +787,7 @@ ResourceId Scene::hitTestScene(const Common::Point pt, HitType &type) {
ResourceId result = (ResourceId)findActionArea(Common::Point(top, left));
- if (result != -1) {
+ if (result != (ResourceId)-1) {
if (LOBYTE(_ws->actions[result]->actionType) & 8) {
type = kHitActionArea;
return result;
Commit: 3cd5aa8d2bcfdd448c212529bdcfa8c63e1b2363
https://github.com/scummvm/scummvm/commit/3cd5aa8d2bcfdd448c212529bdcfa8c63e1b2363
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:20+02:00
Commit Message:
ASYLUM: Fix compilation with stream changes in trunk (r54385)
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@557 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/system/sound.cpp
diff --git a/engines/asylum/system/sound.cpp b/engines/asylum/system/sound.cpp
index 3469e99067..204d252713 100644
--- a/engines/asylum/system/sound.cpp
+++ b/engines/asylum/system/sound.cpp
@@ -35,7 +35,7 @@
#include "asylum/asylum.h"
#include "asylum/respack.h"
-#include "common/stream.h"
+#include "common/memstream.h"
#include "sound/audiostream.h"
#include "sound/decoders/adpcm.h"
Commit: 9362d3b943353ebdaaf665dd6411ae5d4d5e381d
https://github.com/scummvm/scummvm/commit/9362d3b943353ebdaaf665dd6411ae5d4d5e381d
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:20+02:00
Commit Message:
ASYLUM: Use pow in Actor::distance().
Thanks to Arthur for noticing.
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@558 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/resources/actor.cpp
diff --git a/engines/asylum/resources/actor.cpp b/engines/asylum/resources/actor.cpp
index 19d33e1f23..50b3f1392c 100644
--- a/engines/asylum/resources/actor.cpp
+++ b/engines/asylum/resources/actor.cpp
@@ -1545,7 +1545,7 @@ uint32 Actor::getDistanceForFrame(ActorDirection direction, uint32 frameIndex) {
}
uint32 Actor::distance(const Common::Rect &rect) {
- return sqrt((double)((rect.width() ^ 2) + (rect.height() ^ 2)));
+ return sqrt(pow((double)rect.width(), 2) + pow((double)rect.height(), 2));
}
void Actor::updateCoordinatesForDirection(ActorDirection direction, int32 delta, Common::Point *point) {
Commit: fd5e272080de662c41f76403c3dcad0bafbf8d72
https://github.com/scummvm/scummvm/commit/fd5e272080de662c41f76403c3dcad0bafbf8d72
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:20+02:00
Commit Message:
ASYLUM: Properly reset shared data in Actor::enableActorsChapter2
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@559 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/data.h
engines/asylum/resources/actor.cpp
diff --git a/engines/asylum/data.h b/engines/asylum/data.h
index f68b81ee02..a7aa540f84 100644
--- a/engines/asylum/data.h
+++ b/engines/asylum/data.h
@@ -196,6 +196,15 @@ public:
Common::Rect *getActorRect() { return &_actorRect; }
+ // Used by Actor::enableActorsChapter2 (and maybe others)
+ void resetActorData() {
+ for (int i = 0; i < 9; i++) {
+ _data1[i] = 160;
+ _data1[i + 18] = 0;
+ _data3[i] = 0;
+ }
+ }
+
//////////////////////////////////////////////////////////////////////////
// Flags
//////////////////////////////////////////////////////////////////////////
diff --git a/engines/asylum/resources/actor.cpp b/engines/asylum/resources/actor.cpp
index 50b3f1392c..7ad05047a1 100644
--- a/engines/asylum/resources/actor.cpp
+++ b/engines/asylum/resources/actor.cpp
@@ -40,6 +40,7 @@
#include "asylum/views/scene.h"
#include "asylum/asylum.h"
+#include "asylum/data.h"
#include "asylum/staticres.h"
#include "common/endian.h"
@@ -912,10 +913,8 @@ void Actor::enableActorsChapter2(AsylumEngine *engine) {
engine->clearGameFlag(kGameFlag441);
engine->clearGameFlag(kGameFlag442);
- // Update shared data
- for (int i = 0; i < 9; i++) {
- // TODO find out which data is updated
- }
+ // Reset shared data
+ engine->getData()->resetActorData();
engine->scene()->getActor(13)->enable();
engine->scene()->getActor(13)->processStatus(2300, 71, false);
Commit: 7ed0b6eb65687e7128a5cf21d1a919bcfef5051e
https://github.com/scummvm/scummvm/commit/7ed0b6eb65687e7128a5cf21d1a919bcfef5051e
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:21+02:00
Commit Message:
ASYLUM: Update actor helper functions
- Distance is the euclidian distance between 2 vectors
- Add angle helper method
- Convert updateCoordinates to take 2 vectors (ie. points) too
- Switch the shared actor rect to a pair of vectors
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@560 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/data.h
engines/asylum/resources/actor.cpp
engines/asylum/resources/actor.h
diff --git a/engines/asylum/data.h b/engines/asylum/data.h
index a7aa540f84..142202de09 100644
--- a/engines/asylum/data.h
+++ b/engines/asylum/data.h
@@ -194,7 +194,8 @@ public:
void setSceneOffset(int32 val) { _sceneOffset = val; }
void setSceneOffsetAdd(const Common::Rational &offset) { _sceneOffsetAdd = offset; }
- Common::Rect *getActorRect() { return &_actorRect; }
+ Common::Point *getVector1() { return &_vector1; }
+ Common::Point *getVector2() { return &_vector2; }
// Used by Actor::enableActorsChapter2 (and maybe others)
void resetActorData() {
@@ -279,7 +280,8 @@ public:
}
private:
- Common::Rect _actorRect;
+ Common::Point _vector1;
+ Common::Point _vector2;
bool _actorEnableForStatus7;
diff --git a/engines/asylum/resources/actor.cpp b/engines/asylum/resources/actor.cpp
index 7ad05047a1..7f39491d5a 100644
--- a/engines/asylum/resources/actor.cpp
+++ b/engines/asylum/resources/actor.cpp
@@ -1222,22 +1222,26 @@ void Actor::updateStatus15_Chapter2_Actor11() {
}
void Actor::updateStatus15_Chapter11() {
- Common::Rect *rect = getSharedData()->getActorRect();
+ Common::Point *vector1 = getSharedData()->getVector1();
+ Common::Point *vector2 = getSharedData()->getVector2();
Actor *actor0 = getScene()->getActor(0);
- rect->left = actor0->getPoint1()->x + actor0->getPoint2()->x;
- rect->top = actor0->getPoint1()->y + actor0->getPoint2()->y - 5;
- rect->right = _point1.x + _point2.x;
- rect->bottom = _point1.y + _point2.y;
+ // Update vectors
+ vector1->x = actor0->getPoint1()->x + actor0->getPoint2()->x;
+ vector1->y = actor0->getPoint1()->y + actor0->getPoint2()->y - 5;
- updateCoordinates(*rect);
+ vector2->x = actor0->getPoint1()->x + actor0->getPoint2()->x;
+ vector2->y = actor0->getPoint1()->y + actor0->getPoint2()->y;
+
+ updateCoordinates(*vector1, *vector2);
++_frameIndex;
if (_frameIndex >= _frameCount)
updateStatus(kActorStatus14);
if (_frameIndex == 14) {
- if (Actor::distance(*rect) < 75) {
+ if (Actor::distance(*vector1, *vector2) < 75) {
+
actor0->updateStatus(kActorStatus16);
++getWorld()->field_E848C;
@@ -1315,24 +1319,23 @@ void Actor::updateFinish() {
}
}
-void Actor::updateCoordinates(const Common::Rect &rect) {
+void Actor::updateCoordinates(Common::Point vec1, Common::Point vec2) {
if (getScene()->getActor(1)->isVisible())
return;
// FIXME: there is a check for valid rectangles in Common::Rect, so make sure we can get improper ones
- uint32 width = abs(rect.bottom - rect.top);
- if (width > 5)
- width = 5;
+ uint32 diffY = abs(vec2.y - vec1.y);
+ if (diffY > 5)
+ diffY = 5;
- if (rect.bottom - rect.top == 0)
+ if (diffY == 0)
return;
- Common::Point pt(rect.right, rect.bottom);
- ActorDirection direction = (rect.top - rect.bottom > 0) ? kDirection4 : kDirection0;
+ ActorDirection direction = (diffY > 0) ? kDirection4 : kDirection0;
- if (process_408B20(&pt, direction, width + 3, false))
- updateCoordinatesForDirection(direction, width - 1, &_point);
+ if (process_408B20(&vec2, direction, diffY + 3, false))
+ updateCoordinatesForDirection(direction, diffY - 1, &_point);
}
void Actor::resetActors() {
@@ -1543,10 +1546,6 @@ uint32 Actor::getDistanceForFrame(ActorDirection direction, uint32 frameIndex) {
}
}
-uint32 Actor::distance(const Common::Rect &rect) {
- return sqrt(pow((double)rect.width(), 2) + pow((double)rect.height(), 2));
-}
-
void Actor::updateCoordinatesForDirection(ActorDirection direction, int32 delta, Common::Point *point) {
if (!point)
error("[Actor::updateCoordinatesForDirection] Invalid point (NULL)!");
@@ -1593,4 +1592,18 @@ void Actor::updateCoordinatesForDirection(ActorDirection direction, int32 delta,
}
}
+uint32 Actor::distance(Common::Point vec1, Common::Point vec2) {
+ return sqrt(pow((double)(vec2.y - vec1.y), 2) + pow((double)(vec2.x - vec1.x), 2));
+}
+
+uint32 Actor::angle(Common::Point vec1, Common::Point vec2) {
+ int32 result = ((long)(180 - acos((double)(vec2.y - vec1.y) / distance(vec1, vec2)) * 180 / PI)) % 360;
+
+ if (vec1.x < vec2.x)
+ return 360 - result;
+
+ return result;
+}
+
+
} // end of namespace Asylum
diff --git a/engines/asylum/resources/actor.h b/engines/asylum/resources/actor.h
index 2683ef0d2f..66d24af3c4 100644
--- a/engines/asylum/resources/actor.h
+++ b/engines/asylum/resources/actor.h
@@ -390,7 +390,7 @@ private:
*/
void setVolume();
- void updateCoordinates(const Common::Rect &rect);
+ void updateCoordinates(Common::Point vec1, Common::Point vec2);
void resetActors();
@@ -450,15 +450,6 @@ private:
*/
uint32 getDistanceForFrame(ActorDirection direction, uint32 frameIndex);
- /**
- * Get the distance from the rectangle
- *
- * @param rect The rectangle.
- *
- * @return the distance
- */
- static uint32 distance(const Common::Rect &rect);
-
/**
* Updates the coordinates depending on the direction.
*
@@ -468,6 +459,26 @@ private:
*/
static void updateCoordinatesForDirection(ActorDirection direction, int32 delta, Common::Point *point);
+ /**
+ * Get the euclidean distance between the two vectors
+ *
+ * @param vec1 The first vector.
+ * @param vec2 The second vector.
+ *
+ * @return the distance.
+ */
+ static uint32 distance(Common::Point vec1, Common::Point vec2);
+
+ /**
+ * Get the angle between the two vectors
+ *
+ * @param p1 The first vector.
+ * @param p2 The second vector.
+ *
+ * @return the angle
+ */
+ static uint32 angle(Common::Point vec1, Common::Point vec2);
+
}; // end of class MainActor
} // end of namespace Asylum
Commit: 23c559939b73a4ff3350b6a082f5cf0c9fc70d49
https://github.com/scummvm/scummvm/commit/23c559939b73a4ff3350b6a082f5cf0c9fc70d49
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:21+02:00
Commit Message:
ASYLUM: Implement a couple of small Actor helper functions
- Remove uses of _resources (replaced by ActorData)
- Add missing fields to ActorData struct (stubbed for now)
- Implement Actor::loadData()
- Rename Actor::update_40DE20() to Actor::updateAndDraw()
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@561 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/resources/actor.cpp
engines/asylum/resources/actor.h
engines/asylum/views/scene.cpp
diff --git a/engines/asylum/resources/actor.cpp b/engines/asylum/resources/actor.cpp
index 7f39491d5a..29e9158bf4 100644
--- a/engines/asylum/resources/actor.cpp
+++ b/engines/asylum/resources/actor.cpp
@@ -111,9 +111,6 @@ Actor::Actor(AsylumEngine *engine, ActorIndex index) : _vm(engine), _index(index
_field_998 = 0;
_field_99C = 0;
_field_9A0 = 0;
-
- // Temporary resources
- memset(&_resources, 0, sizeof(_resources));
}
Actor::~Actor() {
@@ -222,8 +219,15 @@ void Actor::load(Common::SeekableReadStream *stream) {
}
void Actor::loadData(Common::SeekableReadStream *stream) {
- // TODO load actor data
- stream->seek(ACTORDATA_SIZE, SEEK_CUR);
+ _data.count = stream->readUint32LE();
+
+ _data.field_4 = stream->readUint32LE();
+
+ for (int32 i = 0; i < 240; i++)
+ _data.field_8[i] = stream->readSint32LE();
+
+ for (int32 i = 0; i < 120; i++)
+ _data.field_3C8[i] = stream->readSint32LE();
}
/////////////////////////////////////////////////////////////////////////
@@ -782,15 +786,6 @@ Common::String Actor::toString(bool shortString) {
return output;
}
-void Actor::setRawResources(uint8 *data) {
- byte *dataPtr = data;
-
- for (int32 i = 0; i < 60; i++) {
- _resources[i] = (int32)READ_LE_UINT32(dataPtr);
- dataPtr += 4;
- }
-}
-
//////////////////////////////////////////////////////////////////////////
// Unknown methods
//////////////////////////////////////////////////////////////////////////
@@ -899,10 +894,15 @@ bool Actor::process_41BDB0(int32 reactionIndex, int32 testNumberValue01) {
return true;
}
-void Actor::update_40DE20() {
+void Actor::updateAndDraw() {
error("[Actor::update_40DE20] not implemented!");
}
+void Actor::update_409230() {
+ updateStatus(_status <= 11 ? kActorStatusEnabled : kActorStatus14);
+ _data.field_4 = 0;
+}
+
//////////////////////////////////////////////////////////////////////////
// Static update methods
//////////////////////////////////////////////////////////////////////////
@@ -1217,6 +1217,10 @@ void Actor::updateStatus15_Chapter2_Player() {
error("[Actor::updateStatus15_Chapter2_Player] not implemented!");
}
+bool Actor::updateStatus15_isNoVisibleOrStatus17() {
+ return (!isVisible() || _status == kActorStatus17);
+}
+
void Actor::updateStatus15_Chapter2_Actor11() {
error("[Actor::updateStatus15_Chapter2_Actor11] not implemented!");
}
diff --git a/engines/asylum/resources/actor.h b/engines/asylum/resources/actor.h
index 66d24af3c4..358d4bf3d4 100644
--- a/engines/asylum/resources/actor.h
+++ b/engines/asylum/resources/actor.h
@@ -41,7 +41,10 @@ struct ActionArea;
struct GraphicFrame;
struct ActorData {
- int32 count;
+ uint32 count;
+ int32 field_4;
+ int32 field_8[240];
+ int32 field_3C8[120];
// TODO add actor data fields
};
@@ -220,15 +223,6 @@ public:
*/
void clearFields() { memset(&_field_970, 0, 52); }
-
- /**
- * TEMPORARY: Initialize the 500 byte resource index from the scene
- * file (at offset 0xA73B6).
- *
- * TODO remove this or add it in the right place
- */
- void setRawResources(uint8* data);
-
// Unknown methods
bool process(int32 actorX, int32 actorY);
void processStatus(int32 actorX, int32 actorY, bool doSpeech);
@@ -237,7 +231,8 @@ public:
void process_41BC00(int32 reactionIndex, int32 numberValue01Add);
void process_41BCC0(int32 reactionIndex, int32 numberValue01Substract);
bool process_41BDB0(int32 reactionIndex, int32 testNumberValue01);
- void update_40DE20();
+ void updateAndDraw();
+ void update_409230();
/**
* Query if the object resource is present in the resource table between indices 10 & 20
@@ -258,9 +253,6 @@ private:
// Our current index
ActorIndex _index;
- // Temporary raw resources
- int32 _resources[61];
-
//////////////////////////////////////////////////////////////////////////
// Data
//////////////////////////////////////////////////////////////////////////
@@ -331,6 +323,11 @@ private:
int32 _field_99C;
int32 _field_9A0;
+ //////////////////////////////////////////////////////////////////////////
+ // Actor data
+ //////////////////////////////////////////////////////////////////////////
+ ActorData _data;
+
//////////////////////////////////////////////////////////////////////////
// Update methods
//////////////////////////////////////////////////////////////////////////
@@ -353,6 +350,8 @@ private:
void updateStatus15_Chapter2();
void updateStatus15_Chapter2_Player();
+ bool updateStatus15_isNoVisibleOrStatus17();
+
void updateStatus15_Chapter2_Actor11();
void updateStatus15_Chapter11();
void updateStatus15_Chapter11_Player();
@@ -365,8 +364,6 @@ private:
void updateFinish();
-
-
//////////////////////////////////////////////////////////////////////////
// Misc
//////////////////////////////////////////////////////////////////////////
diff --git a/engines/asylum/views/scene.cpp b/engines/asylum/views/scene.cpp
index 213b4e85d4..8d505c926d 100644
--- a/engines/asylum/views/scene.cpp
+++ b/engines/asylum/views/scene.cpp
@@ -1167,7 +1167,7 @@ int Scene::drawScene() {
Actor *player = getActor();
if (player->getStatus() == kActorStatus6 || player->getStatus() == kActorStatus10)
- player->update_40DE20();
+ player->updateAndDraw();
else
player->setNumberFlag01(0);
Commit: ca4c5d1b49fc304b244de27e4b53d4c3aac377ff
https://github.com/scummvm/scummvm/commit/ca4c5d1b49fc304b244de27e4b53d4c3aac377ff
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:21+02:00
Commit Message:
ASYLUM: Implement more Actor helper functions
- Add updateNumbers public function
- Add rect, compareAngles, compare, compareX and compareY helper functions
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@562 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/resources/actor.cpp
engines/asylum/resources/actor.h
diff --git a/engines/asylum/resources/actor.cpp b/engines/asylum/resources/actor.cpp
index 29e9158bf4..da9fa90cf2 100644
--- a/engines/asylum/resources/actor.cpp
+++ b/engines/asylum/resources/actor.cpp
@@ -1327,8 +1327,6 @@ void Actor::updateCoordinates(Common::Point vec1, Common::Point vec2) {
if (getScene()->getActor(1)->isVisible())
return;
- // FIXME: there is a check for valid rectangles in Common::Rect, so make sure we can get improper ones
-
uint32 diffY = abs(vec2.y - vec1.y);
if (diffY > 5)
diffY = 5;
@@ -1350,6 +1348,19 @@ void Actor::resetActors() {
getWorld()->tickCount1 = _vm->getTick() + 3000;
}
+void Actor::updateNumbers(int32 reaction, int32 x, int32 y) {
+ if (reaction != 1)
+ return;
+
+ _numberStringX = x;
+ _numberStringY = y + 8;
+ _numberStringWidth = 40;
+
+ itoa(_numberValue01, _numberString01, 10);
+
+ _numberFlag01 = 1;
+}
+
//////////////////////////////////////////////////////////////////////////
// Misc
//////////////////////////////////////////////////////////////////////////
@@ -1609,5 +1620,100 @@ uint32 Actor::angle(Common::Point vec1, Common::Point vec2) {
return result;
}
+void Actor::rect(Common::Rect *rect, ActorDirection direction, Common::Point point) {
+ if (!rect)
+ error("[Actor::rect] Invalid rect (NULL)!");
+
+ switch (direction) {
+ default:
+ rect->top = 0;
+ rect->left = 0;
+ rect->bottom = 0;
+ rect->right = 0;
+ return;
+
+ case kDirection0:
+ rect->top = point.x - 9;
+ rect->left = point.y - 84;
+ break;
+
+ case kDirection1:
+ rect->top = point.x - 55;
+ rect->left = point.y - 84;
+ break;
+
+ case kDirection2:
+ rect->top = point.x - 34;
+ rect->left = point.y - 93;
+ break;
+
+ case kDirection3:
+ rect->top = point.x + 27;
+ rect->left = point.y - 94;
+ break;
+
+ case kDirection4:
+ rect->top = point.x + 41;
+ rect->left = point.y - 9;
+ break;
+
+ case kDirection5:
+ rect->top = point.x + 27;
+ rect->left = point.y + 54;
+ break;
+
+ case kDirection6:
+ rect->top = point.x - 34;
+ rect->left = point.y + 53;
+ break;
+
+ case kDirection7:
+ rect->top = point.x - 55;
+ rect->left = point.y + 44;
+ break;
+ }
+
+ rect->setWidth(40);
+ rect->setHeight(40);
+}
+
+bool Actor::compareAngles(Common::Point vec1, Common::Point vec2) {
+ Common::Point vec3(2289, 171);
+
+ int32 diff = angle(vec1, vec3) - angle(vec1, vec2);
+
+ if (diff < 0)
+ diff += 359;
+
+ return (diff != 180);
+}
+
+bool Actor::compare(Common::Point vec1, Common::Point vec2, Common::Point vec) {
+ if (vec.y >= vec1.y && vec.y <= vec2.y && vec.x >= vec1.x && vec.x <= vec2.x)
+ return true;
+
+ return false;
+}
+
+int32 Actor::compareX(Common::Point vec1, Common::Point vec2, Common::Point vec) {
+ if (vec.y > vec2.y)
+ return 3;
+
+ if (vec.y < vec1.y)
+ return 2;
+
+ return 0;
+}
+
+int32 Actor::compareY(Common::Point vec1, Common::Point vec2, Common::Point vec) {
+ if (vec.y > vec2.y)
+ return 3;
+
+ if (vec.y < vec1.y)
+ return 2;
+
+ return 0;
+}
+
} // end of namespace Asylum
diff --git a/engines/asylum/resources/actor.h b/engines/asylum/resources/actor.h
index 358d4bf3d4..c1d7ee77ff 100644
--- a/engines/asylum/resources/actor.h
+++ b/engines/asylum/resources/actor.h
@@ -389,8 +389,20 @@ private:
void updateCoordinates(Common::Point vec1, Common::Point vec2);
+ /**
+ * Hide Actor 0 and reset Actor 1 frame index
+ */
void resetActors();
+ /**
+ * Updates the actor "number" data if the reaction is "1".
+ *
+ * @param reaction The reaction.
+ * @param x The second int32.
+ * @param y The third int32.
+ */
+ void updateNumbers(int32 reaction, int32 x, int32 y);
+
//////////////////////////////////////////////////////////////////////////
// Helper methods
//////////////////////////////////////////////////////////////////////////
@@ -476,6 +488,58 @@ private:
*/
static uint32 angle(Common::Point vec1, Common::Point vec2);
+ /**
+ * Create a new rect using the point, depending on the actor direction
+ *
+ * @param rect The rectangle.
+ * @param direction The direction.
+ * @param point The point.
+ */
+ static void rect(Common::Rect *rect, ActorDirection direction, Common::Point point);
+
+ /**
+ * Compares the angle between two vectors
+ *
+ * @param vec1 The first vector.
+ * @param vec2 The second vector.
+ *
+ * @return true if ...
+ */
+ static bool compareAngles(Common::Point vec1, Common::Point vec2);
+
+ /**
+ * Compares vector vec to two other vectors.
+ *
+ * @param vec1 The first vector.
+ * @param vec2 The second vector.
+ * @param vec The vector to check
+ *
+ * @return true if vec is between vec1 and vec2.
+ */
+ static bool compare(Common::Point vec1, Common::Point vec2, Common::Point vec);
+
+ /**
+ * Compare vectors
+ *
+ * @param vec1 The first vector.
+ * @param vec2 The second vector.
+ * @param vec The vector.
+ *
+ * @return value depending on whether vec.x is superior or inferior to each vector x coordinate
+ */
+ static int32 compareX(Common::Point vec1, Common::Point vec2, Common::Point vec);
+
+ /**
+ * Compare vectors
+ *
+ * @param vec1 The first vector.
+ * @param vec2 The second vector.
+ * @param vec The vector.
+ *
+ * @return value depending on whether vec.y is superior or inferior to each vector y coordinate
+ */
+ static int32 compareY(Common::Point vec1, Common::Point vec2, Common::Point vec);
+
}; // end of class MainActor
} // end of namespace Asylum
Commit: 1ca905680c4e2b0e4a4c847e74c54101a5608cb3
https://github.com/scummvm/scummvm/commit/1ca905680c4e2b0e4a4c847e74c54101a5608cb3
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:21+02:00
Commit Message:
ASYLUM: Implement some Actor::updateStatus methods
- Add accessors for shared data & data2
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@563 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/data.h
engines/asylum/resources/actor.cpp
engines/asylum/resources/actor.h
engines/asylum/shared.h
diff --git a/engines/asylum/data.h b/engines/asylum/data.h
index 142202de09..1693e38e14 100644
--- a/engines/asylum/data.h
+++ b/engines/asylum/data.h
@@ -197,6 +197,40 @@ public:
Common::Point *getVector1() { return &_vector1; }
Common::Point *getVector2() { return &_vector2; }
+ void setData(ActorIndex index, int32 val) {
+ if (index < 50)
+ _data1[index] = val;
+
+ if (index < 60)
+ _data2[index - 50] = val;
+
+ error("[SharedData::setData] index is outside valid values (was: %d, valid: [0:60]", index);
+ }
+
+ int32 getData(ActorIndex index) {
+ if (index < 50)
+ return _data1[index];
+
+ if (index < 60)
+ return _data2[index - 50];
+
+ error("[SharedData::getData] index is outside valid values (was: %d, valid: [0:60]", index);
+ }
+
+ void setData2(ActorIndex index, bool val) {
+ if (index <= 12 || index > 20)
+ error("[SharedData::setData2] index is outside valid values (was: %d, valid: [13:20]", index);
+
+ _data3[index - 12] = val;
+ }
+
+ bool getData2(ActorIndex index) {
+ if (index <= 12 || index > 20)
+ error("[SharedData::getData2] index is outside valid values (was: %d, valid: [13:20]", index);
+
+ return _data3[index - 12];
+ }
+
// Used by Actor::enableActorsChapter2 (and maybe others)
void resetActorData() {
for (int i = 0; i < 9; i++) {
@@ -329,7 +363,7 @@ private:
int32 _data1[50];
int32 _data2[11];
bool _actorUpdateStatusEnabledCounter;
- int32 _data3[9];
+ bool _data3[9];
bool _flagEncouter5;
bool _flagScene1;
int32 _nextScreenUpdate;
diff --git a/engines/asylum/resources/actor.cpp b/engines/asylum/resources/actor.cpp
index da9fa90cf2..a1cded3adb 100644
--- a/engines/asylum/resources/actor.cpp
+++ b/engines/asylum/resources/actor.cpp
@@ -111,6 +111,9 @@ Actor::Actor(AsylumEngine *engine, ActorIndex index) : _vm(engine), _index(index
_field_998 = 0;
_field_99C = 0;
_field_9A0 = 0;
+
+ // Instance data
+ _tickCount = -1;
}
Actor::~Actor() {
@@ -1202,6 +1205,10 @@ void Actor::updateStatus14() {
}
void Actor::updateStatus14_Chapter2() {
+ if (!getSharedData()->getData2(_index))
+ updateStatus(kActorStatus12);
+
+
error("[Actor::updateStatus14_Chapter2] not implemented!");
}
@@ -1217,6 +1224,33 @@ void Actor::updateStatus15_Chapter2_Player() {
error("[Actor::updateStatus15_Chapter2_Player] not implemented!");
}
+void Actor::updateStatus15_Chapter2_Helper() {
+ // we are the current player
+ Actor *actor11 = getScene()->getActor(11);
+ Actor *actor40 = getScene()->getActor(40);
+
+ Common::Point point(_point1.x + _point2.x, _point1.y + _point2.y);
+ Common::Point point11(actor11->getPoint1()->x + actor11->getPoint2()->x, actor11->getPoint1()->y + actor11->getPoint2()->y);
+
+ if (actor11->getStatus() == kActorStatus15 && distance(point, point11) < 100) {
+ Actor *actor = getScene()->getActor(getSharedData()->getData(38));
+
+ actor40->show();
+ actor40->setFrameIndex(0);
+ actor40->getPoint1()->x = actor->getPoint1()->x;
+ actor40->getPoint1()->y = actor->getPoint1()->y;
+
+ if (actor11->getFrameIndex() <= 7) {
+ getSound()->playSound(getWorld()->soundResourceIds[9], false, Config.sfxVolume - 10);
+ } else if (getSharedData()->getData(36) <= 6) {
+ getSound()->playSound(getWorld()->soundResourceIds[9], false, Config.sfxVolume - 10);
+ } else {
+ getScene()->getActor(10)->updateStatus(kActorStatus17);
+ getSound()->playSound(getWorld()->soundResourceIds[10], false, Config.sfxVolume - 10);
+ }
+ }
+}
+
bool Actor::updateStatus15_isNoVisibleOrStatus17() {
return (!isVisible() || _status == kActorStatus17);
}
@@ -1267,7 +1301,24 @@ void Actor::updateStatus16_Chapter2() {
}
void Actor::updateStatus16_Chapter11() {
- error("[Actor::updateStatus16_Chapter11] not implemented!");
+ // We are sure to be the current player
+ getCursor()->show();
+ getSharedData()->setFlag(kFlag1, false);
+
+ if (_frameIndex != -5 || _vm->isGameFlagNotSet(kGameFlag570))
+ ++_frameIndex;
+
+ if (_frameIndex > _frameCount - 1) {
+ if (getWorld()->field_E848C >= 3) {
+ _frameIndex = 0;
+
+ getScene()->getActor(0)->updateStatus(kActorStatus17);
+
+ _tickCount = _vm->getTick() + 2000;
+ } else {
+ getScene()->getActor(0)->updateStatus(kActorStatus14);
+ }
+ }
}
void Actor::updateStatus17_Chapter2() {
@@ -1286,7 +1337,22 @@ void Actor::updateStatus17_Chapter2() {
}
void Actor::updateStatus18_Chapter2() {
- error("[Actor::updateStatus18_Chapter2] not implemented!");
+ Actor *player = getScene()->getActor();
+
+ _point1.x = player->getPoint1()->x - getSharedData()->getData(2 * _index + 19);
+ _point1.y = player->getPoint1()->y - getSharedData()->getData(2 * _index + 20);
+
+ _frameIndex++;
+
+ if (_frameIndex > _frameCount - 1) {
+ getSharedData()->setData2(_index, true);
+ updateStatus(kActorStatus14);
+
+ _point1.y += 54;
+ getSound()->playSound(getWorld()->soundResourceIds[1], false, Config.sfxVolume - 10);
+
+ getSharedData()->setData(_index, getSharedData()->getData(_index) - 54);
+ }
}
void Actor::updateStatus18_Chapter2_Actor11() {
diff --git a/engines/asylum/resources/actor.h b/engines/asylum/resources/actor.h
index c1d7ee77ff..700fc99800 100644
--- a/engines/asylum/resources/actor.h
+++ b/engines/asylum/resources/actor.h
@@ -328,6 +328,8 @@ private:
//////////////////////////////////////////////////////////////////////////
ActorData _data;
+ int32 _tickCount;
+
//////////////////////////////////////////////////////////////////////////
// Update methods
//////////////////////////////////////////////////////////////////////////
@@ -350,6 +352,7 @@ private:
void updateStatus15_Chapter2();
void updateStatus15_Chapter2_Player();
+ void updateStatus15_Chapter2_Helper();
bool updateStatus15_isNoVisibleOrStatus17();
void updateStatus15_Chapter2_Actor11();
diff --git a/engines/asylum/shared.h b/engines/asylum/shared.h
index c44ef55cb2..b27f30dcc9 100644
--- a/engines/asylum/shared.h
+++ b/engines/asylum/shared.h
@@ -87,6 +87,7 @@ enum GameFlag {
kGameFlag545 = 545,
kGameFlag553 = 553,
kGameFlag556 = 556,
+ kGameFlag570 = 570,
kGameFlag776 = 776,
kGameFlag815 = 815,
kGameFlag816 = 816,
Commit: cba710ff8a982c57d27f9b2fcf796c049bd684bd
https://github.com/scummvm/scummvm/commit/cba710ff8a982c57d27f9b2fcf796c049bd684bd
Author: Alex Bevilacqua (alexbevi at gmail.com)
Date: 2021-05-17T15:36:21+02:00
Commit Message:
ASYLUM: don't use itoa() as it's not portable (use sprintf() instead)
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@564 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/resources/actor.cpp
diff --git a/engines/asylum/resources/actor.cpp b/engines/asylum/resources/actor.cpp
index a1cded3adb..14f11b2c6f 100644
--- a/engines/asylum/resources/actor.cpp
+++ b/engines/asylum/resources/actor.cpp
@@ -1422,7 +1422,9 @@ void Actor::updateNumbers(int32 reaction, int32 x, int32 y) {
_numberStringY = y + 8;
_numberStringWidth = 40;
- itoa(_numberValue01, _numberString01, 10);
+ // XXX use sprintf instead of itoa as itoa isn't part of standard
+ // C++ and therefore isn't available in GCC
+ sprintf(_numberString01, "%d", _numberValue01);
_numberFlag01 = 1;
}
Commit: b3b09775558eac4e9f05d4c34cc8238df7a59017
https://github.com/scummvm/scummvm/commit/b3b09775558eac4e9f05d4c34cc8238df7a59017
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:21+02:00
Commit Message:
ASYLUM: Implement more Actor::updateStatus* functions
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@565 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/resources/actionlist.cpp
engines/asylum/resources/actor.cpp
engines/asylum/resources/actor.h
engines/asylum/resources/worldstats.cpp
engines/asylum/resources/worldstats.h
engines/asylum/shared.h
engines/asylum/views/scene.cpp
diff --git a/engines/asylum/resources/actionlist.cpp b/engines/asylum/resources/actionlist.cpp
index 41d90192e1..d931219fcc 100644
--- a/engines/asylum/resources/actionlist.cpp
+++ b/engines/asylum/resources/actionlist.cpp
@@ -1726,7 +1726,7 @@ END_OPCODE
// Opcode 0x61
IMPLEMENT_OPCODE(_unk61)
if (cmd->param2) {
- if (getWorld()->field_E860C == -1) {
+ if (getWorld()->nextPlayer == kActorInvalid) {
_lineIncrement = 0;
cmd->param2 = 0;
} else {
diff --git a/engines/asylum/resources/actor.cpp b/engines/asylum/resources/actor.cpp
index 14f11b2c6f..88b8128ecd 100644
--- a/engines/asylum/resources/actor.cpp
+++ b/engines/asylum/resources/actor.cpp
@@ -273,9 +273,12 @@ void Actor::update() {
break;
case kActorStatus16:
+ if (_index != getScene()->getPlayerIndex())
+ break;
+
if (getWorld()->chapter == 2) {
updateStatus16_Chapter2();
- } else if (getWorld()->chapter == 11 && _index == getScene()->getPlayerIndex()) {
+ } else if (getWorld()->chapter == 11) {
updateStatus16_Chapter11();
}
break;
@@ -694,8 +697,8 @@ void Actor::updateFromDirection(ActorDirection actorDirection) {
}
}
-void Actor::faceTarget(ObjectId id, DirectionFrom from) {
- debugC(kDebugLevelActor, "[Actor::faceTarget] Facing target %d using direction from %d", id, from);
+void Actor::faceTarget(uint32 target, DirectionFrom from) {
+ debugC(kDebugLevelActor, "[Actor::faceTarget] Facing target %d using direction from %d", target, from);
int32 newX, newY;
@@ -704,9 +707,9 @@ void Actor::faceTarget(ObjectId id, DirectionFrom from) {
error("[Actor::faceTarget] Invalid direction input: %d (should be 0-3)", from);
case kDirectionFromObject: {
- Object *object = getWorld()->getObjectById(id);
+ Object *object = getWorld()->getObjectById((ObjectId)target);
if (!object) {
- warning("[Actor::faceTarget] No Object found for id %d", id);
+ warning("[Actor::faceTarget] No Object found for id %d", target);
return;
}
@@ -718,9 +721,9 @@ void Actor::faceTarget(ObjectId id, DirectionFrom from) {
break;
case kDirectionFromPolygons: {
- int32 actionIndex = getWorld()->getActionAreaIndexById(id);
+ int32 actionIndex = getWorld()->getActionAreaIndexById(target);
if (actionIndex == -1) {
- warning("[Actor::faceTarget] No ActionArea found for id %d", id);
+ warning("[Actor::faceTarget] No ActionArea found for id %d", target);
return;
}
@@ -737,7 +740,7 @@ void Actor::faceTarget(ObjectId id, DirectionFrom from) {
break;
case kDirectionFromParameters:
- newX = newY = id;
+ newX = newY = target;
break;
}
@@ -1175,11 +1178,50 @@ void Actor::updateStatus12_Chapter2_Actor11() {
}
void Actor::updateStatus12_Chapter11_Actor1() {
- error("[Actor::updateStatus12_Chapter11_Actor1] not implemented!");
+ // Original seems to have lots of dead code here
+ Actor *actor0 = getScene()->getActor(0);
+ if (actor0->isVisible())
+ return;
+
+ if (_vm->isGameFlagNotSet(kGameFlag560))
+ _frameIndex = (_frameIndex + 1) & _frameCount;
+
+ if (getWorld()->tickCount1 < (int32)_vm->getTick()
+ && !_frameIndex
+ && _vm->isGameFlagNotSet(kGameFlag560)) {
+ _vm->setGameFlag(kGameFlag560);
+ hide();
+ updateStatus(kActorStatusEnabled);
+ actor0->updateStatus(kActorStatusEnabled);
+
+ getWorld()->field_E848C = 0;
+ getScene()->actions()->queueScript(getWorld()->getActionAreaById(1574)->scriptIndex, 1);
+ }
}
void Actor::updateStatus12_Chapter11() {
- error("[Actor::updateStatus12_Chapter11] not implemented!");
+ if (!_frameIndex)
+ getSound()->playSound(getWorld()->soundResourceIds[6]);
+
+ ++_frameIndex;
+
+ if (_frameIndex >= _frameCount) {
+ _frameIndex = 0;
+ updateStatus(kActorStatus14);
+ getWorld()->tickValueArray[_index] = rnd(4000) + _vm->getTick();
+ }
+
+ Common::Point *vector1 = getSharedData()->getVector1();
+ Common::Point *vector2 = getSharedData()->getVector2();
+ Actor *actor0 = getScene()->getActor(0);
+
+ vector1->x = actor0->getPoint1()->x + actor0->getPoint2()->x;
+ vector1->y = actor0->getPoint1()->y + actor0->getPoint2()->y - 5;
+
+ vector2->x = _point1.x + _point2.x;
+ vector2->y = _point1.y + _point2.y;
+
+ updateCoordinates(*vector1, *vector2);
}
void Actor::updateStatus14() {
@@ -1205,15 +1247,42 @@ void Actor::updateStatus14() {
}
void Actor::updateStatus14_Chapter2() {
- if (!getSharedData()->getData2(_index))
+ if (!getSharedData()->getData2(_index)) {
updateStatus(kActorStatus12);
+ return;
+ }
error("[Actor::updateStatus14_Chapter2] not implemented!");
}
void Actor::updateStatus14_Chapter11() {
- error("[Actor::updateStatus14_Chapter11] not implemented!");
+ Common::Point *vector1 = getSharedData()->getVector1();
+ Common::Point *vector2 = getSharedData()->getVector2();
+ Actor *actor0 = getScene()->getActor(0);
+
+ vector1->x = actor0->getPoint1()->x + actor0->getPoint2()->x;
+ vector1->y = actor0->getPoint1()->y + actor0->getPoint2()->y - 5;
+
+ vector2->x = _point1.x + _point2.x;
+ vector2->y = _point1.y + _point2.y;
+
+ if (getWorld()->tickValueArray[_index] == -666)
+ getWorld()->tickValueArray[_index] = rnd(4000) + _vm->getTick();
+
+ faceTarget(kActorMax, kDirectionFromActor);
+ updateCoordinates(*vector1, *vector2);
+
+ if (getWorld()->tickValueArray[_index] < (int)_vm->getTick()) {
+ if (distance(*vector1, *vector2) >= 75) {
+ getWorld()->tickValueArray[_index] = rnd(1000) + 2000 + _vm->getTick();
+ } else {
+ if (actor0->getStatus() == kActorStatus12 || actor0->getStatus() == kActorStatus14 || actor0->getStatus() == kActorStatus15)
+ updateStatus(kActorStatus15);
+
+ getWorld()->tickValueArray[_index] = -666;
+ }
+ }
}
void Actor::updateStatus15_Chapter2() {
@@ -1297,7 +1366,46 @@ void Actor::updateStatus15_Chapter11_Player() {
}
void Actor::updateStatus16_Chapter2() {
- error("[Actor::updateStatus16_Chapter2] not implemented!");
+ // We are sure to be the current player
+
+ ++_frameIndex;
+
+ if (_frameIndex > _frameCount - 1) {
+ if (getSharedData()->getData(40) <= 2) {
+ _frameIndex = 0;
+ updateStatus(kActorStatus14);
+ } else {
+ _vm->clearGameFlag(kGameFlag438);
+ _vm->clearGameFlag(kGameFlag439);
+ _vm->clearGameFlag(kGameFlag440);
+ _vm->clearGameFlag(kGameFlag441);
+ _vm->clearGameFlag(kGameFlag442);
+
+ getSpeech()->playPlayer(53);
+
+ _vm->setGameFlag(kGameFlag219);
+
+ _frameIndex = 0;
+ updateStatus(kActorStatus17);
+
+ _vm->clearGameFlag(kGameFlag369);
+ _vm->clearGameFlag(kGameFlag370);
+
+ if (getSound()->isPlaying(getWorld()->soundResourceIds[5]))
+ getSound()->stop(getWorld()->soundResourceIds[5]);
+
+ if (getSound()->isPlaying(getWorld()->soundResourceIds[6]))
+ getSound()->stop(getWorld()->soundResourceIds[6]);
+
+ if (getSound()->isPlaying(getWorld()->soundResourceIds[7]))
+ getSound()->stop(getWorld()->soundResourceIds[7]);
+
+ if (_vm->isGameFlagSet(kGameFlag235)) {
+ Actor::enableActorsChapter2(_vm);
+ _vm->clearGameFlag(kGameFlag235);
+ }
+ }
+ }
}
void Actor::updateStatus16_Chapter11() {
@@ -1360,7 +1468,34 @@ void Actor::updateStatus18_Chapter2_Actor11() {
}
void Actor::updateStatus21() {
- error("[Actor::updateStatus21] not implemented!");
+ if (_resourceId == getWorld()->graphicResourceIds[3] || _resourceId == getWorld()->graphicResourceIds[4] || _resourceId == getWorld()->graphicResourceIds[5]) {
+ if (_frameIndex < _frameCount - 1) {
+ ++_frameIndex;
+
+ if (_frameIndex == _frameCount / 2) {
+ getWorld()->currentPaletteId = getWorld()->graphicResourceIds[getWorld()->nextPlayer - 1];
+ getScreen()->setPalette(getWorld()->currentPaletteId);
+ getScreen()->setGammaLevel(getWorld()->currentPaletteId, 0);
+ }
+
+ return;
+ }
+ } else {
+ if (_frameIndex > 0) {
+ --_frameIndex;
+
+ if (_frameIndex == _frameCount / 2)
+ getScreen()->setPalette(getWorld()->graphicResourceIds[getWorld()->nextPlayer - 1]);
+
+ getWorld()->currentPaletteId = getWorld()->graphicResourceIds[getWorld()->nextPlayer - 1];
+ getScreen()->setGammaLevel(getWorld()->currentPaletteId, 0);
+ return;
+ }
+ }
+
+ getScene()->changePlayer(getWorld()->nextPlayer);
+ updateStatus(kActorStatusEnabled);
+ getWorld()->nextPlayer = kActorInvalid;
}
void Actor::updateFinish() {
diff --git a/engines/asylum/resources/actor.h b/engines/asylum/resources/actor.h
index 700fc99800..47eb4cca93 100644
--- a/engines/asylum/resources/actor.h
+++ b/engines/asylum/resources/actor.h
@@ -188,7 +188,7 @@ public:
* @param target Identifier for the target.
* @param from direction to face from.
*/
- void faceTarget(ObjectId target, DirectionFrom from);
+ void faceTarget(uint32 target, DirectionFrom from);
/**
* Initialize the x1/y1 values of the actor, update the active animation frame and, if the current direction isn't 8, update the actor's direction.
@@ -341,6 +341,7 @@ private:
void updateStatusEnabledProcessStatus(int32 testX, int32 testY, uint32 counter, int32 setX, int32 setY);
void updateStatus9();
+
void updateStatus12_Chapter2();
void updateStatus12_Chapter2_Actor11();
void updateStatus12_Chapter11_Actor1();
@@ -354,15 +355,18 @@ private:
void updateStatus15_Chapter2_Player();
void updateStatus15_Chapter2_Helper();
bool updateStatus15_isNoVisibleOrStatus17();
-
void updateStatus15_Chapter2_Actor11();
void updateStatus15_Chapter11();
void updateStatus15_Chapter11_Player();
+
void updateStatus16_Chapter2();
void updateStatus16_Chapter11();
+
void updateStatus17_Chapter2();
+
void updateStatus18_Chapter2();
void updateStatus18_Chapter2_Actor11();
+
void updateStatus21();
void updateFinish();
diff --git a/engines/asylum/resources/worldstats.cpp b/engines/asylum/resources/worldstats.cpp
index 5b5a76201c..3554309a75 100644
--- a/engines/asylum/resources/worldstats.cpp
+++ b/engines/asylum/resources/worldstats.cpp
@@ -90,7 +90,7 @@ WorldStats::WorldStats(Common::SeekableReadStream *stream, Scene *scene) : _scen
musicResourceId = kResourceNone;
musicStatusExt = 0;
- field_E860C = 0;
+ nextPlayer = kActorMax;
memset(&field_E8610, 0, sizeof(field_E8610));
memset(&field_E8628, 0, sizeof(field_E8628));
memset(&wheels, 0, sizeof(wheels));
@@ -264,11 +264,8 @@ void WorldStats::load(Common::SeekableReadStream *stream) {
field_E8498 = stream->readSint32LE();
field_E849C = stream->readSint32LE();
- for (int32 i = 0; i < 10; i++)
- field_E84A0[i] = stream->readSint32LE();
-
- for (int32 i = 0; i < 20; i++)
- field_E84C8[i] = stream->readSint32LE();
+ for (int32 i = 0; i < ARRAYSIZE(tickValueArray); i++)
+ tickValueArray[i] = stream->readSint32LE();
field_E8518 = stream->readSint32LE();
@@ -278,7 +275,7 @@ void WorldStats::load(Common::SeekableReadStream *stream) {
for (int32 i = 0; i < 30; i++)
field_E8594[i] = stream->readSint32LE();
- field_E860C = stream->readSint32LE();
+ nextPlayer = (ActorIndex)stream->readSint32LE();
for (int32 i = 0; i < 6; i++)
field_E8610[i] = stream->readUint32LE();
diff --git a/engines/asylum/resources/worldstats.h b/engines/asylum/resources/worldstats.h
index 6de5c8649a..bfc2d69eaa 100644
--- a/engines/asylum/resources/worldstats.h
+++ b/engines/asylum/resources/worldstats.h
@@ -76,7 +76,7 @@ public:
ResourceId font1;
ResourceId font2;
ResourceId font3;
- ResourceId currentPaletteId;
+ int32 currentPaletteId;
int32 cellShadeMask1;
int32 cellShadeMask2;
int32 cellShadeMask3;
@@ -122,12 +122,11 @@ public:
int32 field_E8494;
int32 field_E8498;
int32 field_E849C;
- int32 field_E84A0[10];
- int32 field_E84C8[20];
+ int32 tickValueArray[30];
int32 field_E8518;
int32 field_E851C[30];
int32 field_E8594[30];
- int32 field_E860C;
+ ActorIndex nextPlayer;
uint32 field_E8610[6];
uint32 field_E8628[6];
Object *wheels[7];
diff --git a/engines/asylum/shared.h b/engines/asylum/shared.h
index b27f30dcc9..278e997c2b 100644
--- a/engines/asylum/shared.h
+++ b/engines/asylum/shared.h
@@ -39,6 +39,7 @@ enum GameFlag {
kGameFlagCommentLeavingCell = 214,
kGameFlag219 = 219,
kGameFlagSolveVCRBlowUpPuzzle = 220,
+ kGameFlag235 = 235,
kGameFlag238 = 238,
kGameFlag239 = 239,
kGameFlag243 = 243,
@@ -64,6 +65,8 @@ enum GameFlag {
kGameFlag279 = 279,
kGameFlag358 = 358,
kGameFlag368 = 368,
+ kGameFlag369 = 369,
+ kGameFlag370 = 370,
kGameFlag371 = 371,
kGameFlag387 = 387,
kGameFlag405 = 405,
@@ -87,6 +90,7 @@ enum GameFlag {
kGameFlag545 = 545,
kGameFlag553 = 553,
kGameFlag556 = 556,
+ kGameFlag560 = 560,
kGameFlag570 = 570,
kGameFlag776 = 776,
kGameFlag815 = 815,
diff --git a/engines/asylum/views/scene.cpp b/engines/asylum/views/scene.cpp
index 8d505c926d..bc33920447 100644
--- a/engines/asylum/views/scene.cpp
+++ b/engines/asylum/views/scene.cpp
@@ -201,7 +201,7 @@ void Scene::enter(ResourcePackId packId) {
if (_ws->chapter == kChapter9) {
changePlayer(1);
- _ws->field_E860C = -1;
+ _ws->nextPlayer = kActorInvalid;
}
activate();
Commit: 351c4667463b9a7c28e6614d8e321b0c76727291
https://github.com/scummvm/scummvm/commit/351c4667463b9a7c28e6614d8e321b0c76727291
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:21+02:00
Commit Message:
ASYLUM: Rename direction enum values
Also rename Actor::getDirection to Actor::direction and cleanup code
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@566 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/resources/actor.cpp
engines/asylum/resources/actor.h
engines/asylum/resources/object.cpp
engines/asylum/resources/special.cpp
engines/asylum/shared.h
engines/asylum/views/scene.cpp
diff --git a/engines/asylum/resources/actor.cpp b/engines/asylum/resources/actor.cpp
index 88b8128ecd..e09a0949e2 100644
--- a/engines/asylum/resources/actor.cpp
+++ b/engines/asylum/resources/actor.cpp
@@ -53,7 +53,7 @@ Actor::Actor(AsylumEngine *engine, ActorIndex index) : _vm(engine), _index(index
_objectIndex = 0;
_frameIndex = 0;
_frameCount = 0;
- _direction = kDirection0;
+ _direction = kDirectionN;
_field_3C = 0;
_status = kActorStatusNone;
_field_44 = 0;
@@ -312,11 +312,11 @@ void Actor::update() {
player->updateStatus(kActorStatus3);
player->setResourceId(player->getResourcesId(35));
- player->setDirection(kDirection4);
+ player->setDirection(kDirectionS);
player->setFrameCount(GraphicResource::getFrameCount(_vm, player->getResourceId()));
getCursor()->hide();
- getScene()->getActor(0)->updateFromDirection(kDirection4);
+ getScene()->getActor(0)->updateFromDirection(kDirectionS);
// Queue script
getScene()->actions()->queueScript(getWorld()->getActionAreaById(2696)->scriptIndex, getScene()->getPlayerIndex());
@@ -568,7 +568,7 @@ void Actor::updateStatus(ActorStatus actorStatus) {
case kActorStatusDisabled:
updateGraphicData(15);
- _resourceId = _graphicResourceIds[(_direction > 4 ? 8 - _direction : _direction) + 15];
+ _resourceId = _graphicResourceIds[(_direction > kDirectionS ? kDirection8 - _direction : _direction) + 15];
// TODO set word_446EE4 to -1. This global seems to be used with screen blitting
break;
@@ -578,7 +578,7 @@ void Actor::updateStatus(ActorStatus actorStatus) {
Actor *actor = getScene()->getActor(0);
actor->getPoint1()->x = _point2.x + _point1.x - actor->getPoint2()->x;
actor->getPoint1()->y = _point2.y + _point1.y - actor->getPoint2()->y;
- actor->setDirection(kDirection4);
+ actor->setDirection(kDirectionS);
getScene()->setPlayerActorIndex(0);
@@ -670,29 +670,24 @@ void Actor::updateFromDirection(ActorDirection actorDirection) {
case kActorStatusDisabled:
case kActorStatusEnabled:
case kActorStatus14:
- _resourceId = _graphicResourceIds[(actorDirection > 4 ? 8 - actorDirection : actorDirection) + 5];
+ _resourceId = _graphicResourceIds[(actorDirection > kDirectionS ? kDirection8 - actorDirection : actorDirection) + 5];
_frameCount = GraphicResource::getFrameCount(_vm, _resourceId);
break;
case kActorStatus18:
- if (getWorld()->chapter == kChapter2) {
- if (_index == 11) { // we are actor 11
- if (actorDirection > 4)
- _resourceId = _graphicResourceIds[8 - actorDirection];
- else
- _resourceId = _graphicResourceIds[actorDirection];
- }
- }
+ if (getWorld()->chapter == kChapter2)
+ if (_index == 11) // we are actor 11
+ _resourceId = _graphicResourceIds[(actorDirection > kDirectionS) ? kDirection8 - actorDirection : actorDirection];
break;
case kActorStatus1:
case kActorStatus2:
case kActorStatus12:
- _resourceId = _graphicResourceIds[(actorDirection > 4 ? 8 - actorDirection : actorDirection)];
+ _resourceId = _graphicResourceIds[(actorDirection > kDirectionS ? kDirection8 - actorDirection : actorDirection)];
break;
case kActorStatus8:
- _resourceId = _graphicResourceIds[(actorDirection > 4 ? 8 - actorDirection : actorDirection) + 20];
+ _resourceId = _graphicResourceIds[(actorDirection > kDirectionS ? kDirection8 - actorDirection : actorDirection) + 20];
break;
}
}
@@ -700,7 +695,7 @@ void Actor::updateFromDirection(ActorDirection actorDirection) {
void Actor::faceTarget(uint32 target, DirectionFrom from) {
debugC(kDebugLevelActor, "[Actor::faceTarget] Facing target %d using direction from %d", target, from);
- int32 newX, newY;
+ Common::Point point;
switch (from) {
default:
@@ -715,8 +710,8 @@ void Actor::faceTarget(uint32 target, DirectionFrom from) {
Common::Rect frameRect = GraphicResource::getFrameRect(_vm, object->getResourceId(), object->getFrameIndex());
- newX = Common::Rational(frameRect.width(), 2).toInt() + object->x;
- newY = Common::Rational(frameRect.height(), 2).toInt() + object->y;
+ point.x = Common::Rational(frameRect.width(), 2).toInt() + object->x;
+ point.y = Common::Rational(frameRect.height(), 2).toInt() + object->y;
}
break;
@@ -729,22 +724,23 @@ void Actor::faceTarget(uint32 target, DirectionFrom from) {
PolyDefinitions *polygon = &getScene()->polygons()->entries[getWorld()->actions[actionIndex]->polyIdx];
- newX = polygon->boundingRect.left + (polygon->boundingRect.right - polygon->boundingRect.left) / 2;
- newY = polygon->boundingRect.top + (polygon->boundingRect.bottom - polygon->boundingRect.top) / 2;
+ point.x = polygon->boundingRect.left + (polygon->boundingRect.right - polygon->boundingRect.left) / 2;
+ point.y = polygon->boundingRect.top + (polygon->boundingRect.bottom - polygon->boundingRect.top) / 2;
}
break;
case kDirectionFromActor:
- newX = _point1.x + _point2.x;
- newY = _point1.y + _point2.y;
+ point.x = _point1.x + _point2.x;
+ point.y = _point1.y + _point2.y;
break;
case kDirectionFromParameters:
- newX = newY = target;
+ point.x = point.y = target;
break;
}
- updateFromDirection(getDirection(_point1.x + _point2.x, _point1.y + _point2.y, newX, newY));
+ Common::Point mid(_point1.x + _point2.x, _point1.y + _point2.y);
+ updateFromDirection(direction(mid, point));
}
void Actor::setPosition(int32 newX, int32 newY, ActorDirection newDirection, uint32 frame) {
@@ -758,7 +754,6 @@ void Actor::setPosition(int32 newX, int32 newY, ActorDirection newDirection, uin
_frameIndex = frame;
}
-
/////////////////////////////////////////////////////////////////////////
// Misc
//////////////////////////////////////////////////////////////////////////
@@ -1049,22 +1044,22 @@ void Actor::updateStatusEnabled() {
break;
case 0:
- setPosition(10, 1350, kDirection0, 0);
+ setPosition(10, 1350, kDirectionN, 0);
processStatus(1460, -100, false);
break;
case 1:
- setPosition(300, 0, kDirection0, 0);
+ setPosition(300, 0, kDirectionN, 0);
processStatus(1700, 1400, false);
break;
case 2:
- setPosition(1560, -100, kDirection0, 0);
+ setPosition(1560, -100, kDirectionN, 0);
processStatus(-300, 1470, false);
break;
case 3:
- setPosition(1150, 1400, kDirection0, 0);
+ setPosition(1150, 1400, kDirectionN, 0);
processStatus(-250, 0, false);
break;
}
@@ -1535,7 +1530,7 @@ void Actor::updateCoordinates(Common::Point vec1, Common::Point vec2) {
if (diffY == 0)
return;
- ActorDirection direction = (diffY > 0) ? kDirection4 : kDirection0;
+ ActorDirection direction = (diffY > 0) ? kDirectionS : kDirectionN;
if (process_408B20(&vec2, direction, diffY + 3, false))
updateCoordinatesForDirection(direction, diffY - 1, &_point);
@@ -1601,101 +1596,97 @@ void Actor::setVolume() {
// Helper methods
//////////////////////////////////////////////////////////////////////////
-ActorDirection Actor::getDirection(int32 ax1, int32 ay1, int32 ax2, int32 ay2) const {
- int32 v5 = (ax2 - ax1) * 2^16;
- int32 v6 = 0;
- int32 v4 = (ay1 - ay2) * 2^16;
+ActorDirection Actor::direction(Common::Point vec1, Common::Point vec2) const {
+ int32 diffX = (vec2.x - vec1.x) * 2^16;
+ int32 diffY = (vec1.y - vec2.y) * 2^16;
+ int32 adjust = 0;
- if (v5 < 0) {
- v6 = 2;
- v5 = -v5;
+ if (diffX < 0) {
+ adjust = 2;
+ diffX = -diffX;
}
- if (v4 < 0) {
- v6 |= 1;
- v4 = -v4;
+ if (diffY < 0) {
+ adjust |= 1;
+ diffY = -diffY;
}
- int32 v8 = -1;
-
- if (v5) {
- Common::Rational v7(v4 * 256, v5);
+ int32 angle = -1;
- if (v7 < 0x100)
- v8 = angleTable01[v7.toInt()];
+ if (diffX) {
+ uint32 index = (diffY * 256) / diffX;
- if (v7 < 0x1000 && v8 < 0) {
- Common::Rational vtemp = v7 / 16;
- v8 = angleTable02[vtemp.toInt()];
- }
-
- if (v7 < 0x10000 && v8 < 0) {
- Common::Rational vtemp = v7 / 256;
- v8 = angleTable03[vtemp.toInt()];
- }
+ if (index < 256)
+ angle = angleTable01[index];
+ else if (index < 4096)
+ angle = angleTable02[index / 16];
+ else if (index < 65536)
+ angle = angleTable03[index / 256];
} else {
- v8 = 90;
+ angle = 90;
}
- switch (v6) {
+ switch (adjust) {
default:
break;
case 1:
- v8 = 360 - v8;
+ angle = 360 - angle;
break;
+
case 2:
- v8 = 180 - v8;
+ angle = 180 - angle;
break;
+
case 3:
- v8 += 180;
+ angle += 180;
break;
}
- if (v8 >= 360)
- v8 -= 360;
+ if (angle >= 360)
+ angle -= 360;
- ActorDirection result;
+ ActorDirection direction;
- if (v8 < 157 || v8 >= 202) {
- if (v8 < 112 || v8 >= 157) {
- if (v8 < 67 || v8 >= 112) {
- if (v8 < 22 || v8 >= 67) {
- if ((v8 < 0 || v8 >= 22) && (v8 < 337 || v8 > 359)) {
- if (v8 < 292 || v8 >= 337) {
- if (v8 < 247 || v8 >= 292) {
- if (v8 < 202 || v8 >= 247) {
- error("getAngle returned a bad angle: %d.", v8);
+ if (angle < 157 || angle >= 202) {
+ if (angle < 112 || angle >= 157) {
+ if (angle < 67 || angle >= 112) {
+ if (angle < 22 || angle >= 67) {
+ if ((angle < 0 || angle >= 22) && (angle < 337 || angle > 359)) {
+ if (angle < 292 || angle >= 337) {
+ if (angle < 247 || angle >= 292) {
+ if (angle < 202 || angle >= 247) {
+ error("[Actor::angle] returned a bad angle: %d!", angle);
} else {
- result = kDirection3;
+ direction = kDirectionSO;
}
} else {
- result = kDirection4;
+ direction = kDirectionS;
}
} else {
- result = kDirection5;
+ direction = kDirectionSE;
}
} else {
- result = kDirection6;
+ direction = kDirectionE;
}
} else {
- result = kDirection7;
+ direction = kDirectionNE;
}
} else {
- result = kDirection0;
+ direction = kDirectionN;
}
} else {
- result = kDirection1;
+ direction = kDirectionNO;
}
} else {
- result = kDirection2;
+ direction = kDirectionO;
}
- return result;
+ return direction;
}
void Actor::updateGraphicData(uint32 offset) {
- int32 index = ((_direction > 4) ? 8 - _direction : _direction) + (int32)offset;
+ int32 index = ((_direction > kDirectionS) ? kDirection8 - _direction : _direction) + (int32)offset;
_resourceId = _graphicResourceIds[index];
_frameCount = GraphicResource::getFrameCount(_vm, _resourceId);
_frameIndex = 0;
@@ -1714,7 +1705,7 @@ int32 Actor::getGraphicsFlags() {
}
// TODO replace by readable version
- return ((_direction < 5) - 1) & 2;
+ return ((_direction < kDirectionSE) - 1) & 2;
}
int32 Actor::getDistance() const {
@@ -1725,22 +1716,22 @@ int32 Actor::getDistance() const {
switch (_direction) {
default:
- case kDirection0:
- case kDirection4:
+ case kDirectionN:
+ case kDirectionS:
return 0;
- case kDirection1:
- case kDirection3:
+ case kDirectionNO:
+ case kDirectionSO:
return -_field_8D0[index];
- case kDirection2:
+ case kDirectionO:
return -_field_830[index];
- case kDirection5:
- case kDirection7:
+ case kDirectionSE:
+ case kDirectionNE:
return _field_8D0[index];
- case kDirection6:
+ case kDirectionE:
return _field_830[index];
}
}
@@ -1748,18 +1739,18 @@ int32 Actor::getDistance() const {
uint32 Actor::getDistanceForFrame(ActorDirection direction, uint32 frameIndex) {
switch (_direction) {
default:
- case kDirection0:
- case kDirection4:
+ case kDirectionN:
+ case kDirectionS:
return _field_880[frameIndex];
- case kDirection1:
- case kDirection3:
- case kDirection5:
- case kDirection7:
+ case kDirectionNO:
+ case kDirectionSO:
+ case kDirectionSE:
+ case kDirectionNE:
return _field_8D0[frameIndex];
- case kDirection2:
- case kDirection6:
+ case kDirectionO:
+ case kDirectionE:
return _field_830[frameIndex];
}
}
@@ -1772,38 +1763,38 @@ void Actor::updateCoordinatesForDirection(ActorDirection direction, int32 delta,
default:
break;
- case kDirection0:
+ case kDirectionN:
point->y -= delta;
break;
- case kDirection1:
+ case kDirectionNO:
point->x -= delta;
point->y -= delta;
break;
- case kDirection2:
+ case kDirectionO:
point->x -= delta;
break;
- case kDirection3:
+ case kDirectionSO:
point->x -= delta;
point->y += delta;
break;
- case kDirection4:
+ case kDirectionS:
point->y += delta;
break;
- case kDirection5:
+ case kDirectionSE:
point->x += delta;
point->y += delta;
break;
- case kDirection6:
+ case kDirectionE:
point->x += delta;
break;
- case kDirection7:
+ case kDirectionNE:
point->y += delta;
point->y -= delta;
break;
@@ -1835,42 +1826,42 @@ void Actor::rect(Common::Rect *rect, ActorDirection direction, Common::Point poi
rect->right = 0;
return;
- case kDirection0:
+ case kDirectionN:
rect->top = point.x - 9;
rect->left = point.y - 84;
break;
- case kDirection1:
+ case kDirectionNO:
rect->top = point.x - 55;
rect->left = point.y - 84;
break;
- case kDirection2:
+ case kDirectionO:
rect->top = point.x - 34;
rect->left = point.y - 93;
break;
- case kDirection3:
+ case kDirectionSO:
rect->top = point.x + 27;
rect->left = point.y - 94;
break;
- case kDirection4:
+ case kDirectionS:
rect->top = point.x + 41;
rect->left = point.y - 9;
break;
- case kDirection5:
+ case kDirectionSE:
rect->top = point.x + 27;
rect->left = point.y + 54;
break;
- case kDirection6:
+ case kDirectionE:
rect->top = point.x - 34;
rect->left = point.y + 53;
break;
- case kDirection7:
+ case kDirectionNE:
rect->top = point.x - 55;
rect->left = point.y + 44;
break;
diff --git a/engines/asylum/resources/actor.h b/engines/asylum/resources/actor.h
index 47eb4cca93..4c36d3fc09 100644
--- a/engines/asylum/resources/actor.h
+++ b/engines/asylum/resources/actor.h
@@ -415,16 +415,14 @@ private:
//////////////////////////////////////////////////////////////////////////
/**
- * Gets a direction using the angle between the two points
+ * Gets a direction using the angle between the two points.
*
- * @param ax1 The first ax.
- * @param ay1 The first ay.
- * @param ax2 The second ax.
- * @param ay2 The second ay.
+ * @param vec1 The first vector.
+ * @param vec2 The second vector.
*
- * @return The angle.
+ * @return The direction
*/
- ActorDirection getDirection(int32 ax1, int32 ay1, int32 ax2, int32 ay2) const;
+ ActorDirection direction(Common::Point vec1, Common::Point vec2) const;
/**
* Updates the actor graphic information
diff --git a/engines/asylum/resources/object.cpp b/engines/asylum/resources/object.cpp
index ca8ae6e5f0..088ce6ff7b 100644
--- a/engines/asylum/resources/object.cpp
+++ b/engines/asylum/resources/object.cpp
@@ -43,7 +43,7 @@ Object::Object(AsylumEngine *engine) : x(0), y(0), flags(0), actionType(0),
_id(kObjectNone), _resourceId(kResourceNone), _field_20(0), _frameIndex(0), _frameCount(0),
_field_2C(0), _field_30(0), _field_34(0), _field_3C(0), _polygonIndex(0), _field_B4(0),
_tickCount(0), _tickCount2(0), _field_C0(0), _priority(0), _actionListIdx(0), _field_67C(0),
- _soundX(0), _soundY(0), _field_688(0), _soundResourceId(kResourceNone), _field_6A4(kDirection0)
+ _soundX(0), _soundY(0), _field_688(0), _soundResourceId(kResourceNone), _field_6A4(kDirectionN)
{
memset(&_name, 0, sizeof(_name));
memset(&_gameFlags, 0, sizeof(_gameFlags));
diff --git a/engines/asylum/resources/special.cpp b/engines/asylum/resources/special.cpp
index dbe88608c1..d1024f23a2 100644
--- a/engines/asylum/resources/special.cpp
+++ b/engines/asylum/resources/special.cpp
@@ -544,7 +544,7 @@ void Special::chapter8(Object *object, ActorIndex actorIndex) {
if (object->getFrameIndex() == 50) {
object->disableAndRemoveFromQueue();
- actor0->setDirection(kDirection4);
+ actor0->setDirection(kDirectionS);
getCursor()->show();
getWorld()->motionStatus = 1;
diff --git a/engines/asylum/shared.h b/engines/asylum/shared.h
index 278e997c2b..50dcbffc79 100644
--- a/engines/asylum/shared.h
+++ b/engines/asylum/shared.h
@@ -250,14 +250,14 @@ enum ActorStatus {
enum ActorDirection {
kDirectionInvalid = -1,
- kDirection0 = 0,
- kDirection1 = 1,
- kDirection2 = 2,
- kDirection3 = 3,
- kDirection4 = 4,
- kDirection5 = 5,
- kDirection6 = 6,
- kDirection7 = 7,
+ kDirectionN = 0,
+ kDirectionNO = 1,
+ kDirectionO = 2,
+ kDirectionSO = 3,
+ kDirectionS = 4,
+ kDirectionSE = 5,
+ kDirectionE = 6,
+ kDirectionNE = 7,
kDirection8 = 8
};
diff --git a/engines/asylum/views/scene.cpp b/engines/asylum/views/scene.cpp
index bc33920447..e2a9b8ba05 100644
--- a/engines/asylum/views/scene.cpp
+++ b/engines/asylum/views/scene.cpp
@@ -68,7 +68,7 @@ Scene::Scene(AsylumEngine *engine): _vm(engine), _ev(NULL),
_leftClick = false;
_rightButton = false;
_isActive = false;
- _globalDirection = kDirection0;
+ _globalDirection = kDirectionN;
// Graphics
_bgResource = NULL;
@@ -153,7 +153,7 @@ void Scene::enter(ResourcePackId packId) {
Actor *actor = _ws->actors[i];
actor->hide();
- actor->setDirection(kDirection1);
+ actor->setDirection(kDirectionNO);
actor->enable();
actor->getPoint1()->x -= actor->getPoint2()->x;
@@ -470,39 +470,39 @@ void Scene::updateMouse() {
if (getCursor()->position().y > actorPos.bottom) {
if (act->getDirection() == 2) {
if (getCursor()->position().y - actorPos.bottom > 10)
- dir = kDirection3;
+ dir = kDirectionSO;
} else {
- if (act->getDirection() == kDirection4) {
+ if (act->getDirection() == kDirectionS) {
if (actorPos.left - getCursor()->position().x > 10)
- dir = kDirection3;
+ dir = kDirectionSO;
} else {
- dir = kDirection3;
+ dir = kDirectionSO;
}
}
} else {
if (act->getDirection() == 1) {
if (getCursor()->position().y - actorPos.top > 10)
- dir = kDirection2;
+ dir = kDirectionO;
} else {
- if (act->getDirection() == kDirection3) {
+ if (act->getDirection() == kDirectionSO) {
if (actorPos.bottom - getCursor()->position().y > 10)
- dir = kDirection2;
+ dir = kDirectionO;
} else {
- dir = kDirection2;
+ dir = kDirectionO;
}
}
}
} else {
if (act->getDirection()) {
- if (act->getDirection() == kDirection2) {
+ if (act->getDirection() == kDirectionO) {
if (actorPos.top - getCursor()->position().y > 10)
- dir = kDirection1;
+ dir = kDirectionNO;
} else {
- dir = kDirection1;
+ dir = kDirectionNO;
}
} else {
if (actorPos.left - getCursor()->position().x > 10)
- dir = kDirection1;
+ dir = kDirectionNO;
}
}
done = true;
@@ -511,28 +511,28 @@ void Scene::updateMouse() {
if (!done && getCursor()->position().x <= actorPos.right) {
if (getCursor()->position().y >= actorPos.top) {
if (getCursor()->position().y > actorPos.bottom) {
- if (act->getDirection() == kDirection3) {
+ if (act->getDirection() == kDirectionSO) {
if (getCursor()->position().x - actorPos.left > 10)
- dir = kDirection4;
+ dir = kDirectionS;
} else {
- if (act->getDirection() == kDirection5) {
+ if (act->getDirection() == kDirectionSE) {
if (actorPos.right - getCursor()->position().x > 10)
- dir = kDirection4;
+ dir = kDirectionS;
} else {
- dir = kDirection4;
+ dir = kDirectionS;
}
}
}
} else {
- if (act->getDirection() == kDirection1) {
+ if (act->getDirection() == kDirectionNO) {
if (getCursor()->position().x - actorPos.left > 10)
- dir = kDirection0;
+ dir = kDirectionN;
} else {
- if (act->getDirection() == kDirection7) {
+ if (act->getDirection() == kDirectionNE) {
if (actorPos.right - getCursor()->position().x > 10)
- dir = kDirection0;
+ dir = kDirectionN;
} else {
- dir = kDirection0;
+ dir = kDirectionN;
}
}
}
@@ -541,43 +541,43 @@ void Scene::updateMouse() {
if (!done && getCursor()->position().y < actorPos.top) {
if (act->getDirection()) {
- if (act->getDirection() == kDirection6) {
+ if (act->getDirection() == kDirectionE) {
if (actorPos.top - getCursor()->position().y > 10)
- dir = kDirection7;
+ dir = kDirectionNE;
} else {
- dir = kDirection7;
+ dir = kDirectionNE;
}
} else {
if (getCursor()->position().x - actorPos.right > 10)
- dir = kDirection7;
+ dir = kDirectionNE;
}
done = true;
}
if (!done && getCursor()->position().y <= actorPos.bottom) {
- if (act->getDirection() == kDirection5) {
+ if (act->getDirection() == kDirectionSE) {
if (actorPos.bottom - getCursor()->position().y > 10)
- dir = kDirection6;
+ dir = kDirectionE;
} else {
- if (act->getDirection() == kDirection7) {
+ if (act->getDirection() == kDirectionNE) {
if (getCursor()->position().y - actorPos.top > 10)
- dir = kDirection6;
+ dir = kDirectionE;
} else {
- dir = kDirection6;
+ dir = kDirectionE;
}
}
done = true;
}
- if (!done && act->getDirection() == kDirection4) {
+ if (!done && act->getDirection() == kDirectionS) {
if (getCursor()->position().x - actorPos.right <= 10)
done = true;
if (!done)
- dir = kDirection5;
+ dir = kDirectionSE;
}
- if (!done && (act->getDirection() != kDirection6 || getCursor()->position().y - actorPos.bottom > 10))
- dir = kDirection5;
+ if (!done && (act->getDirection() != kDirectionE || getCursor()->position().y - actorPos.bottom > 10))
+ dir = kDirectionSE;
handleMouseUpdate(dir, actorPos);
Commit: 2d04087fc2cf569cde2b82fdf85ec521f68c2fa5
https://github.com/scummvm/scummvm/commit/2d04087fc2cf569cde2b82fdf85ec521f68c2fa5
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:22+02:00
Commit Message:
ASYLUM: Add stubs for two more graphic queue methods
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@567 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/resources/actor.cpp
engines/asylum/resources/object.cpp
engines/asylum/system/screen.cpp
engines/asylum/system/screen.h
engines/asylum/views/blowuppuzzle.cpp
engines/asylum/views/blowuppuzzle.h
diff --git a/engines/asylum/resources/actor.cpp b/engines/asylum/resources/actor.cpp
index e09a0949e2..c17eb81b44 100644
--- a/engines/asylum/resources/actor.cpp
+++ b/engines/asylum/resources/actor.cpp
@@ -252,15 +252,15 @@ void Actor::draw() {
if (LOBYTE(flags) & kActorFlagMasked) {
Object *object = getWorld()->objects[_objectIndex];
- getScene()->adjustCoordinates(object->x, object->y, &point);
+ Common::Point objPoint;
+ getScene()->adjustCoordinates(object->x, object->y, &objPoint);
- error("[Actor::draw] Cross fade not implemented!");
- //getScreen()->addGraphicToQueue(_resourceId, frameIndex, point.x, point.y, object->_resourceId, point.x, point.y, getGraphicsFlags(), _priority);
+ getScreen()->addGraphicToQueueMasked(_resourceId, frameIndex, point, object->getResourceId(), objPoint, getGraphicsFlags(), _priority);
// Update flags
flags &= ~kActorFlagMasked;
} else {
- getScreen()->addGraphicToQueue(_resourceId, frameIndex, point.x, point.y, getGraphicsFlags(), _field_96C, _priority);
+ getScreen()->addGraphicToQueue(_resourceId, frameIndex, point, getGraphicsFlags(), _field_96C, _priority);
}
}
diff --git a/engines/asylum/resources/object.cpp b/engines/asylum/resources/object.cpp
index 088ce6ff7b..b6da95f17f 100644
--- a/engines/asylum/resources/object.cpp
+++ b/engines/asylum/resources/object.cpp
@@ -194,11 +194,9 @@ void Object::draw() {
getScene()->adjustCoordinates(x + frameRect.left, y + frameRect.top, &point);
if (_field_67C <= 0 || _field_67C >= 4 || Config.performance <= 1) {
- getScreen()->addGraphicToQueue(_resourceId, _frameIndex, point.x, point.y, (flags >> 11) & kObjectFlag2, _field_67C - 3, _priority);
+ getScreen()->addGraphicToQueue(_resourceId, _frameIndex, point, (flags >> 11) & kObjectFlag2, _field_67C - 3, _priority);
} else {
- // TODO: Do Cross Fade
- //getScreen()->addGraphicToQueue(_resourceId, _frameIndex, x, y, getWorld()->backgroundImage, getWorld()->xLeft, getWorld()->yTop, 0, 0, _field_67C - 1);
- error("[Object::draw] Crossfade not implemented!");
+ getScreen()->addGraphicToQueueCrossfade(_resourceId, _frameIndex, point, getWorld()->backgroundImage, Common::Point(getWorld()->xLeft, getWorld()->yTop), _field_67C - 1);
}
}
diff --git a/engines/asylum/system/screen.cpp b/engines/asylum/system/screen.cpp
index 1d99302902..6224600ebe 100644
--- a/engines/asylum/system/screen.cpp
+++ b/engines/asylum/system/screen.cpp
@@ -162,12 +162,11 @@ void Screen::startPaletteFade(ResourceId resourceId, int32 milliseconds, int32 p
error("[Screen::startPaletteFade] not implemented");
}
-void Screen::addGraphicToQueue(ResourceId resourceId, uint32 frameIdx, int32 x, int32 y, int32 flags, int32 transTableNum, int32 priority) {
+void Screen::addGraphicToQueue(ResourceId resourceId, uint32 frameIndex, Common::Point point, int32 flags, int32 transTableNum, int32 priority) {
GraphicQueueItem item;
item.resourceId = resourceId;
- item.x = x;
- item.y = y;
- item.frameIdx = frameIdx;
+ item.point = point;
+ item.frameIndex = frameIndex;
item.flags = flags;
item.transTableNum = transTableNum;
item.priority = priority;
@@ -175,8 +174,12 @@ void Screen::addGraphicToQueue(ResourceId resourceId, uint32 frameIdx, int32 x,
_queueItems.push_back(item);
}
-void Screen::addCrossFadeGraphicToQueue(ResourceId resourceId, uint32 frameIdx, int32 x, int32 y, int32 redId2, int32 x2, int32 y2, int32 flags, int32 priority) {
- error("[Screen::addCrossFadeGraphicToQueue] not implemented");
+void Screen::addGraphicToQueueMasked(ResourceId resourceId, uint32 frameIndex, Common::Point point, int32 objectResourceId, Common::Point objectPoint, int32 flags, int32 priority) {
+ error("[Screen::addGraphicToQueueMasked] not implemented");
+}
+
+void Screen::addGraphicToQueueCrossfade(ResourceId resourceId, uint32 frameIndex, Common::Point point, int32 objectResourceId, Common::Point objectPoint, int32 transTableNum) {
+ error("[Screen::addGraphicToQueueCrossfade] not implemented");
}
void Screen::addGraphicToQueue(GraphicQueueItem const &item) {
@@ -189,11 +192,11 @@ void Screen::drawGraphicsInQueue() {
for (uint32 i = 0; i < _queueItems.size(); i++) {
GraphicResource *grRes = new GraphicResource(_vm, _queueItems[i].resourceId);
- GraphicFrame *fra = grRes->getFrame(_queueItems[i].frameIdx);
+ GraphicFrame *fra = grRes->getFrame(_queueItems[i].frameIndex);
copyToBackBufferWithTransparency((byte *)fra->surface.pixels,
fra->surface.w,
- _queueItems[i].x - getWorld()->xLeft, _queueItems[i].y - getWorld()->yTop,
+ _queueItems[i].point.x - getWorld()->xLeft, _queueItems[i].point.y - getWorld()->yTop,
fra->surface.w,
fra->surface.h);
diff --git a/engines/asylum/system/screen.h b/engines/asylum/system/screen.h
index aaeb1063e1..46321b9274 100644
--- a/engines/asylum/system/screen.h
+++ b/engines/asylum/system/screen.h
@@ -40,13 +40,19 @@ class ResourcePack;
typedef struct GraphicQueueItem {
ResourceId resourceId;
- uint32 frameIdx;
- int32 x;
- int32 y;
+ uint32 frameIndex;
+ Common::Point point;
int32 flags;
int32 transTableNum;
int32 priority;
+ GraphicQueueItem() {
+ resourceId = kResourceNone;
+ frameIndex = 0;
+ flags = 0;
+ transTableNum = 0;
+ priority = 0;
+ }
} GraphicQueueItem;
class Screen {
@@ -72,8 +78,9 @@ public:
void paletteFade(uint32 red, int32 milliseconds, int32 param);
void startPaletteFade(ResourceId resourceId, int32 milliseconds, int32 param);
- void addGraphicToQueue(ResourceId resourceId, uint32 frameIdx, int32 x, int32 y, int32 flags, int32 transTableNum, int32 priority);
- void addCrossFadeGraphicToQueue(ResourceId resourceId, uint32 frameIdx, int32 x, int32 y, int32 redId2, int32 x2, int32 y2, int32 flags, int32 priority);
+ void addGraphicToQueue(ResourceId resourceId, uint32 frameIndex, Common::Point point, int32 flags, int32 transTableNum, int32 priority);
+ void addGraphicToQueueCrossfade(ResourceId resourceId, uint32 frameIndex, Common::Point point, int32 objectResourceId, Common::Point objectPoint, int32 transTableNum);
+ void addGraphicToQueueMasked(ResourceId resourceId, uint32 frameIndex, Common::Point point, int32 objectResourceId, Common::Point objectPoint, int32 flags, int32 priority);
void addGraphicToQueue(GraphicQueueItem const &item);
void drawGraphicsInQueue();
void clearGraphicsInQueue();
diff --git a/engines/asylum/views/blowuppuzzle.cpp b/engines/asylum/views/blowuppuzzle.cpp
index 19c4bfc0fa..379540d726 100644
--- a/engines/asylum/views/blowuppuzzle.cpp
+++ b/engines/asylum/views/blowuppuzzle.cpp
@@ -167,8 +167,8 @@ void BlowUpPuzzleVCR::update() {
updateStopButton();
if (_buttonsState[kPower] == kON) {
- getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[22], _tvScreenAnimIdx, 0, 37, 0, 0, 1);
- getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[23], _tvScreenAnimIdx++, 238, 22, 0, 0, 1);
+ getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[22], _tvScreenAnimIdx, Common::Point(0, 37), 0, 0, 1);
+ getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[23], _tvScreenAnimIdx++, Common::Point(238, 22), 0, 0, 1);
_tvScreenAnimIdx %= 6;
}
@@ -181,7 +181,7 @@ void BlowUpPuzzleVCR::update() {
barSize += 4;
} while (barSize < 84);
- // TODO: fade palette to grey
+ // TODO: fade palette to gray
getVideo()->playVideo(2, true);
@@ -201,9 +201,8 @@ GraphicQueueItem BlowUpPuzzleVCR::getGraphicJackItem(int32 index) {
}
jackItemOnHand.resourceId = getWorld()->graphicResourceIds[index];
- jackItemOnHand.frameIdx = 0;
- jackItemOnHand.x = _cursor->position().x - 114;
- jackItemOnHand.y = jackY - 14;
+ jackItemOnHand.frameIndex = 0;
+ jackItemOnHand.point = Common::Point(_cursor->position().x - 114, jackY - 14);
jackItemOnHand.priority = 1;
return jackItemOnHand;
@@ -217,9 +216,8 @@ GraphicQueueItem BlowUpPuzzleVCR::getGraphicShadowItem() {
shadowY = 0;
}
shadowItem.resourceId = getWorld()->graphicResourceIds[30];
- shadowItem.frameIdx = 0;
- shadowItem.x = _cursor->position().x - shadowY;
- shadowItem.y = 450;
+ shadowItem.frameIndex = 0;
+ shadowItem.point = Common::Point(_cursor->position().x - shadowY, 450);
shadowItem.priority = 2;
return shadowItem;
@@ -231,33 +229,29 @@ void BlowUpPuzzleVCR::updateJack(Jack jack, const VCRDrawInfo &onTable, const VC
switch (_jacksState[jack]) {
case kOnTable:
item.resourceId = getWorld()->graphicResourceIds[onTable.resourceId];
- item.frameIdx = 0;
- item.x = onTable.x;
- item.y = onTable.y;
+ item.frameIndex = 0;
+ item.point = onTable.point;
item.priority = 3;
break;
case kPluggedOnRed:
item.resourceId = getWorld()->graphicResourceIds[pluggedOnRed.resourceId];
- item.frameIdx = 0;
- item.x = 329;
- item.y = 407;
+ item.frameIndex = 0;
+ item.point = Common::Point(329, 407);
item.priority = 3;
break;
case kPluggedOnYellow:
item.resourceId = getWorld()->graphicResourceIds[pluggedOnYellow.resourceId];
- item.frameIdx = 0;
- item.x = 402;
- item.y = 413;
+ item.frameIndex = 0;
+ item.point = Common::Point(402, 413);
item.priority = 3;
break;
case kPluggedOnBlack:
item.resourceId = getWorld()->graphicResourceIds[pluggedOnBlack.resourceId];
- item.frameIdx = 0;
- item.x = 477;
- item.y = 418;
+ item.frameIndex = 0;
+ item.point = Common::Point(477, 418);
item.priority = 3;
break;
@@ -281,8 +275,7 @@ void BlowUpPuzzleVCR::updateJack(Jack jack, const VCRDrawInfo &onTable, const VC
void BlowUpPuzzleVCR::updateBlackJack() {
VCRDrawInfo onTable;
onTable.resourceId = 1;
- onTable.x = 0;
- onTable.y = 411;
+ onTable.point = Common::Point(0, 411);
VCRDrawInfo pluggedOnRed;
pluggedOnRed.resourceId = 5;
@@ -299,8 +292,7 @@ void BlowUpPuzzleVCR::updateBlackJack() {
void BlowUpPuzzleVCR::updateRedJack() {
VCRDrawInfo onTable;
onTable.resourceId = 2;
- onTable.x = 76;
- onTable.y = 428;
+ onTable.point = Common::Point(76, 428);
VCRDrawInfo pluggedOnRed;
pluggedOnRed.resourceId = 4;
@@ -317,8 +309,7 @@ void BlowUpPuzzleVCR::updateRedJack() {
void BlowUpPuzzleVCR::updateYellowJack() {
VCRDrawInfo onTable;
onTable.resourceId = 3;
- onTable.x = 187;
- onTable.y = 439;
+ onTable.point = Common::Point(187, 439);
VCRDrawInfo pluggedOnRed;
pluggedOnRed.resourceId = 6;
@@ -357,17 +348,15 @@ void BlowUpPuzzleVCR::updateButton(Button button, const VCRDrawInfo &btON, const
switch (_buttonsState[button]) {
case kON:
item.resourceId = getWorld()->graphicResourceIds[btON.resourceId];
- item.frameIdx = 0;
- item.x = btON.x;
- item.y = btON.y;
+ item.frameIndex = 0;
+ item.point = btON.point;
item.priority = 3;
break;
case kDownON:
case kDownOFF:
item.resourceId = getWorld()->graphicResourceIds[btDown.resourceId];
- item.frameIdx = 0;
- item.x = btDown.x;
- item.y = btDown.y;
+ item.frameIndex = 0;
+ item.point = btDown.point;
item.priority = 3;
break;
default:
@@ -383,13 +372,11 @@ void BlowUpPuzzleVCR::updateButton(Button button, const VCRDrawInfo &btON, const
void BlowUpPuzzleVCR::updatePowerButton() {
VCRDrawInfo btON;
btON.resourceId = 17;
- btON.x = 512;
- btON.y = 347;
+ btON.point = Common::Point(512, 347);
VCRDrawInfo btDown;
btDown.resourceId = 21;
- btDown.x = 506;
- btDown.y = 343;
+ btDown.point = Common::Point(506, 343);
updateButton(kPower, btON, btDown);
}
@@ -397,13 +384,11 @@ void BlowUpPuzzleVCR::updatePowerButton() {
void BlowUpPuzzleVCR::updateRewindButton() {
VCRDrawInfo btON;
btON.resourceId = 14;
- btON.x = 248;
- btON.y = 347;
+ btON.point = Common::Point(248, 347);
VCRDrawInfo btDown;
btDown.resourceId = 18;
- btDown.x = 245;
- btDown.y = 344;
+ btDown.point = Common::Point(245, 344);
updateButton(kRewind, btON, btDown);
}
@@ -411,13 +396,11 @@ void BlowUpPuzzleVCR::updateRewindButton() {
void BlowUpPuzzleVCR::updatePlayButton() {
VCRDrawInfo btON;
btON.resourceId = 16;
- btON.x = 401;
- btON.y = 359;
+ btON.point = Common::Point(401, 359);
VCRDrawInfo btDown;
btDown.resourceId = 20;
- btDown.x = 391;
- btDown.y = 355;
+ btDown.point = Common::Point(391, 355);
updateButton(kPlay, btON, btDown);
}
@@ -425,13 +408,11 @@ void BlowUpPuzzleVCR::updatePlayButton() {
void BlowUpPuzzleVCR::updateStopButton() {
VCRDrawInfo btON;
btON.resourceId = 15;
- btON.x = 330;
- btON.y = 354;
+ btON.point = Common::Point(330, 354);
VCRDrawInfo btDown;
btDown.resourceId = 19;
- btDown.x = 326;
- btDown.y = 350;
+ btDown.point = Common::Point(326, 350);
updateButton(kStop, btON, btDown);
}
diff --git a/engines/asylum/views/blowuppuzzle.h b/engines/asylum/views/blowuppuzzle.h
index fef652eb89..39245a5f59 100644
--- a/engines/asylum/views/blowuppuzzle.h
+++ b/engines/asylum/views/blowuppuzzle.h
@@ -75,8 +75,7 @@ protected:
typedef struct VCRDrawInfo {
int32 resourceId;
- int32 x;
- int32 y;
+ Common::Point point;
} VCRDrawInfo;
const Common::Rect BlowUpPuzzleVCRPolies[10] = {
Commit: e96fe9c8d310c94a8a9ab9b162b07bcc826351e5
https://github.com/scummvm/scummvm/commit/e96fe9c8d310c94a8a9ab9b162b07bcc826351e5
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:22+02:00
Commit Message:
ASYLUM: Add console command to run an encounter
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@568 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/console.cpp
engines/asylum/console.h
engines/asylum/resources/encounters.h
diff --git a/engines/asylum/console.cpp b/engines/asylum/console.cpp
index 73f4078605..fb44cdd5c3 100644
--- a/engines/asylum/console.cpp
+++ b/engines/asylum/console.cpp
@@ -27,6 +27,7 @@
#include "asylum/resources/actionlist.h"
#include "asylum/resources/actor.h"
+#include "asylum/resources/encounters.h"
#include "asylum/resources/object.h"
#include "asylum/resources/worldstats.h"
@@ -60,6 +61,7 @@ Console::Console(AsylumEngine *engine) : _vm(engine) {
DCmd_Register("video", WRAP_METHOD(Console, cmdPlayVideo));
DCmd_Register("script", WRAP_METHOD(Console, cmdRunScript));
DCmd_Register("scene", WRAP_METHOD(Console, cmdChangeScene));
+ DCmd_Register("encounter", WRAP_METHOD(Console, cmdRunEncounter));
DCmd_Register("toggle_flag", WRAP_METHOD(Console, cmdToggleFlag));
@@ -91,18 +93,19 @@ bool Console::cmdHelp(int, const char **) {
DebugPrintf("\n");
DebugPrintf("Commands\n");
DebugPrintf("--------\n");
- DebugPrintf(" ls - list engine files\n");
+ DebugPrintf(" ls - list engine files\n");
DebugPrintf("\n");
- DebugPrintf(" actors - show actors information\n");
- DebugPrintf(" action - show action information\n");
- DebugPrintf(" flags - show flags\n");
- DebugPrintf(" object - inspect a particular object\n");
- DebugPrintf(" objects - show objects information\n");
- DebugPrintf(" world - show worldstats\n");
+ DebugPrintf(" actors - show actors information\n");
+ DebugPrintf(" action - show action information\n");
+ DebugPrintf(" flags - show flags\n");
+ DebugPrintf(" object - inspect a particular object\n");
+ DebugPrintf(" objects - show objects information\n");
+ DebugPrintf(" world - show worldstats\n");
DebugPrintf("\n");
- DebugPrintf(" video - play a video\n");
- DebugPrintf(" script - run a script\n");
- DebugPrintf(" scene - change the scene\n");
+ DebugPrintf(" video - play a video\n");
+ DebugPrintf(" script - run a script\n");
+ DebugPrintf(" scene - change the scene\n");
+ DebugPrintf(" encounter - run an encounter\n");
DebugPrintf("\n");
DebugPrintf(" toggle_flag - toggle a flag\n");
DebugPrintf("\n");
@@ -345,9 +348,25 @@ bool Console::cmdChangeScene(int32 argc, const char **argv) {
}
_vm->scene()->actions()->setDelayedSceneIndex(index);
- // FIXME push the script index into the script queue
- // XXX is this right or should it be ws->actionListIdx???
- //_vm->scene()->actions()->setScriptByIndex(0);
+
+ return false;
+}
+
+bool Console::cmdRunEncounter(int32 argc, const char **argv) {
+ if (argc != 2) {
+ DebugPrintf("Syntax: %s <encounter index>\n", argv[0]);
+ return true;
+ }
+
+ uint32 index = atoi(argv[1]);
+
+ // Check index is valid
+ if (index < 0 || index >= _vm->encounter()->_items.size()) {
+ DebugPrintf("[Error] Invalid index (was: %d - valid: [0-%d])\n", index, _vm->encounter()->_items.size() - 1);
+ return true;
+ }
+
+ _vm->encounter()->run(index, kObjectNone, kObjectNone, kActorInvalid);
return false;
}
diff --git a/engines/asylum/console.h b/engines/asylum/console.h
index 6a26079c1f..6e88b2f476 100644
--- a/engines/asylum/console.h
+++ b/engines/asylum/console.h
@@ -72,6 +72,7 @@ private:
bool cmdPlayVideo(int32 argc, const char **argv);
bool cmdRunScript(int32 argc, const char **argv);
bool cmdChangeScene(int32 argc, const char **argv);
+ bool cmdRunEncounter(int32 argc, const char **argv);
bool cmdToggleFlag(int32 argc, const char **argv);
};
diff --git a/engines/asylum/resources/encounters.h b/engines/asylum/resources/encounters.h
index f3f60bc011..060b3d6d77 100644
--- a/engines/asylum/resources/encounters.h
+++ b/engines/asylum/resources/encounters.h
@@ -72,6 +72,7 @@ private:
EncounterItem *_currentEncounter;
Common::Array<EncounterItem> _items;
+ friend class Console;
}; // end of class Encounter
} // end of namespace Asylum
Commit: 307af404cf1c43dff654439ffb00f6a53289db81
https://github.com/scummvm/scummvm/commit/307af404cf1c43dff654439ffb00f6a53289db81
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:22+02:00
Commit Message:
ASYLUM: Implement "script" debug command
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@569 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/console.cpp
engines/asylum/resources/actionlist.h
diff --git a/engines/asylum/console.cpp b/engines/asylum/console.cpp
index fb44cdd5c3..c2e5a9703b 100644
--- a/engines/asylum/console.cpp
+++ b/engines/asylum/console.cpp
@@ -321,12 +321,25 @@ bool Console::cmdPlayVideo(int32 argc, const char **argv) {
}
bool Console::cmdRunScript(int32 argc, const char **argv) {
- if (argc != 2) {
- DebugPrintf("Syntax: %s <script number>\n", argv[0]);
+ if (argc != 3) {
+ DebugPrintf("Syntax: %s <script index> <actor index>\n", argv[0]);
return true;
}
- // FIXME push the script index into the script queue
- //_vm->scene()->actions()->setScriptByIndex(atoi(argv[1]));
+
+ uint32 index = atoi(argv[1]);
+ uint32 actor = atoi(argv[2]);
+
+ // Check parameters
+ if (index < 0 || index >= getScene()->actions()->_scripts.size()) {
+ DebugPrintf("[Error] Invalid index (was: %d - valid: [0-%d])\n", index, _vm->encounter()->_items.size() - 1);
+ return true;
+ }
+
+ if (actor < 0 || actor > getWorld()->actors.size()) {
+ DebugPrintf("[Error] Invalid actor index (was: %d - valid: [0-%d])\n", getWorld()->actors.size() - 1);
+ }
+
+ getScene()->actions()->queueScript(index, actor);
return false;
}
diff --git a/engines/asylum/resources/actionlist.h b/engines/asylum/resources/actionlist.h
index b00b94bb09..5ad94e1bc3 100644
--- a/engines/asylum/resources/actionlist.h
+++ b/engines/asylum/resources/actionlist.h
@@ -336,6 +336,8 @@ private:
DECLARE_OPCODE(_unk61);
DECLARE_OPCODE(ShowOptionsScreen);
DECLARE_OPCODE(_unk63);
+
+ friend class Console;
}; // end of class ActionList
} // end of namespace Asylum
Commit: 871ed2f0ed8704e73e744debd7474f50293e2053
https://github.com/scummvm/scummvm/commit/871ed2f0ed8704e73e744debd7474f50293e2053
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:22+02:00
Commit Message:
ASYLUM: Implement ActionList::enableObject()
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@570 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/resources/actionlist.cpp
engines/asylum/shared.h
diff --git a/engines/asylum/resources/actionlist.cpp b/engines/asylum/resources/actionlist.cpp
index d931219fcc..45f4478ecb 100644
--- a/engines/asylum/resources/actionlist.cpp
+++ b/engines/asylum/resources/actionlist.cpp
@@ -1766,7 +1766,114 @@ END_OPCODE
//////////////////////////////////////////////////////////////////////////
void ActionList::enableObject(ScriptEntry *cmd, ObjectEnableType type) {
- error("[ActionList::enableObject] not implemented!");
+ int32 field67C = 0;
+
+ // Setup field67C
+ switch (type) {
+ default:
+ break;
+
+ case kObjectEnableType0:
+ field67C = 4 + _currentScript->counter / cmd->param2;
+ break;
+
+ case kObjectEnableType1:
+ field67C = 6 - _currentScript->counter / cmd->param2;
+ break;
+
+ case kObjectEnableType2:
+ field67C = 0;
+ break;
+ }
+
+ // Update first set of objects
+ for (int i = 0; i < 7; i++) {
+ Object *object = getWorld()->getObjectById((ObjectId)cmd->param4);
+ if (object != NULL)
+ object->setField67C(field67C);
+
+ ++cmd->param4;
+ }
+
+ // Update per-chapter objects
+ switch (getWorld()->chapter) {
+ default:
+ break;
+
+ case kChapter3:
+ if (cmd->param1 != 810)
+ break;
+
+ getWorld()->getObjectById(kObjectTableRecordRoom)->setField67C(field67C);
+ getWorld()->getObjectById(kObjectOrangeRecord)->setField67C(field67C);
+ break;
+
+ case kChapter4:
+ if (cmd->param1 != 1232)
+ break;
+
+ getWorld()->getObjectById(kObjectInfernoStatusQuo)->setField67C(field67C);
+ getWorld()->getObjectById(kObjectJugglerWithPin)->setField67C(field67C);
+ getWorld()->getObjectById(kObjectJuggler)->setField67C(field67C);
+ getWorld()->getObjectById(kObjectClownStatusQuo)->setField67C(field67C);
+ getWorld()->getObjectById(kObjectTrixieStatusQuo)->setField67C(field67C);
+ getWorld()->getObjectById(kObjectSimonStatusQuo)->setField67C(field67C);
+ getWorld()->getObjectById(kObjectBigTopBarrel)->setField67C(field67C);
+ getWorld()->getObjectById(kObjectStandBehindJuggler)->setField67C(field67C);
+ getWorld()->getObjectById(kObjectStrongmanLeft)->setField67C(field67C);
+ getWorld()->getObjectById(kObjectStrongmanRight)->setField67C(field67C);
+ break;
+
+ case kChapter6:
+ if (cmd->param1 == 1998) {
+ getWorld()->getObjectById(kObjectGlow4)->setField67C(field67C);
+ getWorld()->getObjectById(kObjectBugOnTable)->setField67C(field67C);
+ getWorld()->getObjectById(kObjectInsidePipeCyberPod)->setField67C(field67C);
+ getWorld()->getObjectById(kObjectDiscardedBugPincer)->setField67C(field67C);
+ getWorld()->getObjectById(kObjectLitLimbScanner)->setField67C(field67C);
+ getWorld()->getObjectById(kObjectCyberTable)->setField67C(field67C);
+ }
+
+ if (cmd->param1 == 2003) {
+ getWorld()->getObjectById(kObjectNPC066StatusQuo)->setField67C(field67C);
+ getWorld()->getObjectById(kObject2507)->setField67C(field67C);
+ getWorld()->getObjectById(kObjectBrokenPipe)->setField67C(field67C);
+ getWorld()->getObjectById(kObjectEmberPopsOut)->setField67C(field67C);
+ getWorld()->getObjectById(kObjectBugCarriesEmber)->setField67C(field67C);
+ getWorld()->getObjectById(kObjectFurnaceHole)->setField67C(field67C);
+ getWorld()->getObjectById(kObjectTopOfFurnace)->setField67C(field67C);
+ getWorld()->getObjectById(kObjectElderBugLimb)->setField67C(field67C);
+ }
+ break;
+
+ case kChapter7:
+ if (cmd->param1 != 1273)
+ break;
+
+ getWorld()->getObjectById(kObjectHeadOnTable)->setField67C(field67C);
+ getWorld()->getObjectById(kObjectOfficeWallNew)->setField67C(field67C);
+ getWorld()->getObjectById(kObjectChalice)->setField67C(field67C);
+ break;
+
+ case kChapter8:
+ if (cmd->param1 != 1795)
+ break;
+
+ getWorld()->getObjectById(kObjectHook1B)->setField67C(field67C);
+ getWorld()->getObjectById(kObjectHook2B)->setField67C(field67C);
+ getWorld()->getObjectById(kObjectHook3B)->setField67C(field67C);
+ getWorld()->getObjectById(kObjectHook4B)->setField67C(field67C);
+ getWorld()->getObjectById(kObjectHook5B)->setField67C(field67C);
+ getWorld()->getObjectById(kObjectHook6B)->setField67C(field67C);
+ getWorld()->getObjectById(kObjectHook0Down)->setField67C(field67C);
+ getWorld()->getObjectById(kObjectHook2Down)->setField67C(field67C);
+ getWorld()->getObjectById(kObjectHook3Down)->setField67C(field67C);
+ getWorld()->getObjectById(kObjectHook4Down)->setField67C(field67C);
+ getWorld()->getObjectById(kObjectHook5Down)->setField67C(field67C);
+ getWorld()->getObjectById(kObjectHook6Down)->setField67C(field67C);
+ getWorld()->getObjectById(kObject2230)->setField67C(field67C);
+ break;
+ }
}
void ActionList::setActionFlag(ScriptEntry *cmd, ActionType flag) {
diff --git a/engines/asylum/shared.h b/engines/asylum/shared.h
index 50dcbffc79..ab39cad3cd 100644
--- a/engines/asylum/shared.h
+++ b/engines/asylum/shared.h
@@ -378,6 +378,7 @@ enum ObjectId {
kObjectGuyWobbles = 405,
kObjectRocker = 441,
kObjectOpeningGate = 485,
+ kObjectTableRecordRoom = 659,
kObject703 = 703,
kObjectTree8 = 726,
kObjectSlab = 743,
@@ -391,6 +392,7 @@ enum ObjectId {
kObjectNPC027Dancing = 844,
kObjectNPC028Dancing = 845,
kObjectNPC026OutOfWay = 861,
+ kObjectOrangeRecord = 920,
kObjectJessieStatusQuo = 984,
kObjectMarty02 = 991,
kObjectEileenOnBench = 993,
@@ -413,6 +415,7 @@ enum ObjectId {
kObjectNPC032StatusQuoBigTop = 1256,
kObjectGlobe = 1261,
kObjectDrawers3 = 1276,
+ kObjectChalice = 1286,
kObjectFreezerHallInterior = 1337,
kObjectNPC033StartEnc = 1338,
kObjectNPC033GetBook = 1343,
@@ -422,11 +425,14 @@ enum ObjectId {
kObjectStrongmanStatusQuo = 1402, // NPC 35
kObjectStrongmanStatusQuo2 = 1405, // NPC 35
kObjectInfernoStatusQuo = 1408, // NPC 36
+ kObjectJugglerWithPin = 1423, // NPC 37
kObjectJuggler = 1424, // NPC 37
kObjectClownStatusQuo = 1428, // NPC 38
kObjectTrixieStatusQuo = 1432, // NPC 39
kObjectSimonStatusQuo = 1434, // NPC 40
+ kObjectBigTopBarrel = 1436,
kObjectFunTixStatusQuo = 1437, // NPC 44
+ kObjectStandBehindJuggler = 1438,
kObjectFreakTixStatusQuoUp = 1439, // NPC 45
kObjectFreakTixStatusQuoDown = 1440, // NPC 45
kObjectFortTellerStatusQuo = 1444, // NPC 45
@@ -465,6 +471,7 @@ enum ObjectId {
kObjectDennisStatus2 = 1580,
kObjectPreAlphaNut = 1582,
kObjectPreAlphaNut2 = 1584,
+ kObjectHeadOnTable = 1595,
kObjectWitchDoctor = 1778,
kObjectStoneWifeStatuQuo = 1782,
kObjectFishermanWidowStatusQuo = 1786,
@@ -477,6 +484,19 @@ enum ObjectId {
kObjectWheel7 = 2119,
kObjectStoneMasonStatusHitt = 2123,
kObjectFlamingHeadLeftSide = 2129,
+ kObjectHook1B = 2131,
+ kObjectHook2B = 2132,
+ kObjectHook3B = 2133,
+ kObjectHook4B = 2134,
+ kObjectHook5B = 2135,
+ kObjectHook6B = 2136,
+ kObjectHook0Down = 2152,
+ kObjectHook2Down = 2154,
+ kObjectHook3Down = 2155,
+ kObjectHook4Down = 2156,
+ kObjectHook5Down = 2157,
+ kObjectHook6Down = 2158,
+ kObject2230 = 2230,
kObjectGravinStatusQuoCyber = 2324,
kObjectGravinWorkMachine = 2337,
kObjectNPC062GritzaStatusQuo = 2399,
@@ -484,16 +504,26 @@ enum ObjectId {
kObjectNPC064GrellaStatusQuo = 2418,
kObjectLavaBridge = 2445,
kObjectNPC065StatusQuo = 2469,
+ kObjectGlow4 = 2478,
+ kObjectBugOnTable = 2480,
kObjectWadeThroughLava = 2500,
kObjectNPC066StatusQuo = 2504,
+ kObject2507 = 2507,
+ kObjectBrokenPipe = 2508,
kObjectBodySlides1 = 2514,
kObjectBodySlides2 = 2515,
kObjectBodySlides3 = 2516,
kObjectBodySlides4 = 2517,
kObjectBodySlides5 = 2518,
kObjectBodySlides6 = 2519,
+ kObjectEmberPopsOut = 2526,
+ kObjectBugCarriesEmber = 2527,
kObjectGirlStatusQuo = 2541,
kObjectWitchWifeStirring = 2543,
+ kObjectFurnaceHole = 2554,
+ kObjectInsidePipeCyberPod = 2555,
+ kObjectTopOfFurnace = 2566,
+ kObjectElderBugLimb = 2572,
kObjectQuetzlcaotlStatusQuo = 2578,
kObjectGhost1 = 2579,
kObjectGhost2 = 2580,
@@ -501,6 +531,7 @@ enum ObjectId {
kObjectGhost4 = 2582,
kObjectGhost5 = 2583,
kObjectGhost6 = 2584,
+ kObjectDiscardedBugPincer = 2587,
kObjectGong1 = 2590,
kObjectGong2 = 2591,
kObjectGong3 = 2592,
@@ -512,6 +543,9 @@ enum ObjectId {
kObjectBlanklPixelForWarrior = 2884,
kObjectPixelForHutWarrior = 2885,
kObjectPixelForWaterfallGhost = 2886,
+ kObjectLitLimbScanner = 3061,
+ kObjectOfficeWallNew = 3062,
+ kObjectCyberTable = 3065,
kObjectEnd
};
Commit: 15e46d466ac558c2de65b0c2f3f08f17aaeb82f5
https://github.com/scummvm/scummvm/commit/15e46d466ac558c2de65b0c2f3f08f17aaeb82f5
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:22+02:00
Commit Message:
ASYLUM: Update event handling + encounter progress
- Add custom asylum event
- Implement parts of Encounter::run
- Correct parameters passed to encounter debug command
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@571 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
A engines/asylum/eventhandler.h
engines/asylum/asylum.cpp
engines/asylum/asylum.h
engines/asylum/console.cpp
engines/asylum/console.h
engines/asylum/resources/actionlist.cpp
engines/asylum/resources/encounters.cpp
engines/asylum/resources/encounters.h
engines/asylum/resources/object.h
engines/asylum/shared.h
diff --git a/engines/asylum/asylum.cpp b/engines/asylum/asylum.cpp
index 3d4ece7968..8addb6d177 100644
--- a/engines/asylum/asylum.cpp
+++ b/engines/asylum/asylum.cpp
@@ -354,7 +354,7 @@ void AsylumEngine::switchMessageHandler(MessageHandler *handler) {
error("[AsylumEngine::switchMessageHandler] not implemented");
}
-AsylumEngine::MessageHandler *AsylumEngine::getMessageHandler(uint32 index) {
+MessageHandler *AsylumEngine::getMessageHandler(uint32 index) {
error("[AsylumEngine::getMessageHandler] not implemented");
}
diff --git a/engines/asylum/asylum.h b/engines/asylum/asylum.h
index 8ca99e88d1..0b9a7ae735 100644
--- a/engines/asylum/asylum.h
+++ b/engines/asylum/asylum.h
@@ -28,6 +28,7 @@
#include "asylum/console.h"
#include "asylum/data.h"
+#include "asylum/eventhandler.h"
#include "asylum/shared.h"
#include "common/random.h"
@@ -87,8 +88,6 @@ public:
kStartGameScene
};
- typedef Common::Functor1<Common::Event &, void> MessageHandler;
-
AsylumEngine(OSystem *system, const ADGameDescription *gd);
virtual ~AsylumEngine();
diff --git a/engines/asylum/console.cpp b/engines/asylum/console.cpp
index c2e5a9703b..caa12f5466 100644
--- a/engines/asylum/console.cpp
+++ b/engines/asylum/console.cpp
@@ -379,7 +379,8 @@ bool Console::cmdRunEncounter(int32 argc, const char **argv) {
return true;
}
- _vm->encounter()->run(index, kObjectNone, kObjectNone, kActorInvalid);
+ // TODO update with array of valid objects
+ _vm->encounter()->run(index, kObjectNone, kObjectNone, kActorMax);
return false;
}
diff --git a/engines/asylum/console.h b/engines/asylum/console.h
index 6e88b2f476..9d5ce3633f 100644
--- a/engines/asylum/console.h
+++ b/engines/asylum/console.h
@@ -43,7 +43,8 @@ enum kDebugLevels {
kDebugLevelSavegame = 1 << 7,
kDebugLevelScene = 1 << 8,
kDebugLevelObjects = 1 << 9,
- kDebugLevelActor = 1 << 10
+ kDebugLevelActor = 1 << 10,
+ kDebugLevelEncounter = 1 << 11
};
class AsylumEngine;
diff --git a/engines/asylum/eventhandler.h b/engines/asylum/eventhandler.h
new file mode 100644
index 0000000000..815073a7d1
--- /dev/null
+++ b/engines/asylum/eventhandler.h
@@ -0,0 +1,46 @@
+/* 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.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#ifndef ASYLUM_EVENTHANDLER_H
+#define ASYLUM_EVENTHANDLER_H
+
+#include "common/func.h"
+#include "common/events.h"
+
+namespace Asylum {
+
+struct AsylumEvent : public Common::Event {
+ // For events of type INVALID, we check our custom event value
+ uint32 id;
+};
+
+typedef Common::Functor1<const AsylumEvent &, void> MessageHandler;
+
+#define MESSAGE_HANDLER(class, name, inst) \
+ Common::Functor1Mem<const AsylumEvent&, void, class>(inst, &class::name)
+
+} // End of namespace Asylum
+
+#endif // ASYLUM_EVENTHANDLER_H
diff --git a/engines/asylum/resources/actionlist.cpp b/engines/asylum/resources/actionlist.cpp
index 45f4478ecb..21126222f2 100644
--- a/engines/asylum/resources/actionlist.cpp
+++ b/engines/asylum/resources/actionlist.cpp
@@ -752,7 +752,7 @@ IMPLEMENT_OPCODE(RunEncounter)
else
cmd->param6 = 0;
} else {
- encounter->run(cmd->param1, cmd->param2, cmd->param3, cmd->param4);
+ encounter->run(cmd->param1, (ObjectId)cmd->param2, (ObjectId)cmd->param3, cmd->param4);
cmd->param6 = 2;
_lineIncrement = 1;
diff --git a/engines/asylum/resources/encounters.cpp b/engines/asylum/resources/encounters.cpp
index cefd1c1c77..b51ef949e7 100644
--- a/engines/asylum/resources/encounters.cpp
+++ b/engines/asylum/resources/encounters.cpp
@@ -25,13 +25,37 @@
#include "asylum/resources/encounters.h"
+#include "asylum/resources/actor.h"
+#include "asylum/resources/object.h"
+#include "asylum/resources/worldstats.h"
+
+#include "asylum/views/scene.h"
+
#include "asylum/asylum.h"
#include "common/file.h"
namespace Asylum {
-Encounter::Encounter(AsylumEngine *engine) : _vm(engine), _currentEncounter(NULL) {
+Encounter::Encounter(AsylumEngine *engine) : _vm(engine),
+ _index(NULL), _keywordIndex(0), _item(NULL), _objectId1(kObjectNone), _objectId2(kObjectNone), _actorIndex(kActorInvalid),
+ _flag1(false), _flag2(false) {
+
+ _messageHandler = new MESSAGE_HANDLER(Encounter, messageHandler, this);
+
+ load();
+}
+
+Encounter::~Encounter() {
+ delete _messageHandler;
+
+ _item = NULL;
+
+ // Zero-out passed pointers
+ _vm = NULL;
+}
+
+void Encounter::load() {
Common::File file;
// TODO error checks
@@ -39,8 +63,8 @@ Encounter::Encounter(AsylumEngine *engine) : _vm(engine), _currentEncounter(NULL
uint16 _count = file.readUint16LE();
- _variables = (int16*)malloc(_count);
- file.read(_variables, _count);
+ for (uint i = 0; i < _count; i++)
+ _variables.push_back(file.readSint16LE());
file.seek(2 + _count * 2, SEEK_SET);
@@ -67,71 +91,64 @@ Encounter::Encounter(AsylumEngine *engine) : _vm(engine), _currentEncounter(NULL
file.close();
}
-Encounter::~Encounter() {
- free(_variables);
- _currentEncounter = NULL;
+void Encounter::run(int32 encounterIndex, ObjectId objectId1, ObjectId objectId2, ActorIndex actorIndex) {
+ // Line: 12/15 :: 0x25 (1, 1584, 1584, 0, 0, 0, 0, 0, 0) // First Encounter
+ debugC(kDebugLevelEncounter, "Running Encounter %d", encounterIndex);
- // Zero-out passed pointers
- _vm = NULL;
-}
+ if (!_keywordIndex) {
+ _item = &_items[0];
+ _keywordIndex = _item->keywordIndex;
+ }
-void Encounter::run(int32 encounterIdx, int32 objectId1, int32 objectId2, int32 characterIdx) {
- // Line: 12/15 :: 0x25 (1, 1584, 1584, 0, 0, 0, 0, 0, 0) // First Encounter
+ if (encounterIndex < 0)
+ return;
- //debugC(kDebugLevelEncounter, "Running Encounter %d", encounterIdx);
+ // Original engine saves the main event handler (to be restored later)
+ _index = encounterIndex;
+ _item = &_items[encounterIndex];
+ _objectId1 = objectId1;
+ _objectId2 = objectId2;
+ _actorIndex = actorIndex;
+
+ if (getWorld()->getObjectById(objectId2))
+ getWorld()->getObjectById(objectId2)->stopSound();
+
+ getWorld()->actors[actorIndex]->stopSound();
- _currentEncounter = &_items[encounterIdx];
setVariable(1, 0);
- setVariable(2, _currentEncounter->value);
-
- //Object *b1 = _scene->worldstats()->getObjectById(objectId1);
- /*
- int32 __cdecl runEncounter(int32 newMessageHandler, int32 encounterIndex, int32 objectId1, int32 objectId2, int32 characterIndex)
- {
- int32 result; // eax at 7
- EncounterItem *v6; // eax at 2
- int32 v7; // ST04_4 at 4
- int32 v8; // eax at 4
-
- if ( !encounterKeywordIndex )
- {
- v6 = getEncounterItem(0);
- encounterItem = v6;
- encounterKeywordIndex = *(_DWORD *)&v6->keywordIndex;
- }
- if ( encounterIndex < 0 )
- {
- result = 0;
- }
- else
- {
- encounter_newMessageHandler = newMessageHandler;
- encounterIndex = encounterIndex;
- encounterItem = getEncounterItem(encounterIndex);
- encounter_objectId01 = objectId1;
- v7 = characterIndex;
- encounter_objectId02 = objectId2;
- characterIndex2 = characterIndex;
- v8 = getObjectIndexById(objectId2);
- object_sound_sub_414C30(v8, v7);
- setEncounterVariable(1, 0);
- setEncounterVariable(2, encounterItem->value);
- if ( scene.characters[playerCharacterIndex].field_40 == 5 )
- {
- encounter_flag02 = 1;
- }
- else
- {
- encounter_flag02 = 0;
- character_sub_4072A0(playerCharacterIndex, 5);
- }
- flag04 = 0;
- switchMessageHandler((int32 (__cdecl *)(_DWORD, _DWORD, _DWORD))handleMessageEncounter);
- result = 1;
- }
- return result;
+ setVariable(2, _item->value);
+
+ Actor *player = getScene()->getActor();
+ if (player->getStatus() == kActorStatusDisabled) {
+ _flag2 = true;
+ } else {
+ _flag2 = false;
+ player->updateStatus(kActorStatusDisabled);
}
- */
+
+ _flag1 = false;
+
+ // Setup encounter event handler
+ _vm->switchMessageHandler(_messageHandler);
+}
+
+
+
+//////////////////////////////////////////////////////////////////////////
+// Message handler
+//////////////////////////////////////////////////////////////////////////
+void Encounter::messageHandler(const AsylumEvent &evt) {
+
+}
+
+//////////////////////////////////////////////////////////////////////////
+// Helpers functions
+//////////////////////////////////////////////////////////////////////////
+void Encounter::setVariable(uint32 index, int32 val) {
+ if (index >= _variables.size())
+ error("[Encounter::setVariable] Invalid index (was: %d, max: %d)", index, _variables.size() - 1);
+
+ _variables[index] = val;
}
}
diff --git a/engines/asylum/resources/encounters.h b/engines/asylum/resources/encounters.h
index 060b3d6d77..72a917e30f 100644
--- a/engines/asylum/resources/encounters.h
+++ b/engines/asylum/resources/encounters.h
@@ -26,6 +26,7 @@
#ifndef ASYLUM_ENCOUNTERS_H
#define ASYLUM_ENCOUNTERS_H
+#include "asylum/asylum.h"
#include "asylum/shared.h"
#include "common/array.h"
@@ -58,20 +59,36 @@ public:
Encounter(AsylumEngine *engine);
virtual ~Encounter();
- void setVariable(int32 idx, int32 value) {
- _variables[idx] = value;
- }
- void run(int32 encounterIdx, int32 objectId1, int32 objectId2, int32 characterIdx);
+ void run(int32 encounterIndex, ObjectId objectId1, ObjectId objectId2, ActorIndex actorIndex);
+
+ void setVariable(uint32 index, int32 val);
private:
AsylumEngine *_vm;
- int16 *_variables;
- int16 _anvilStyleFlag;
+ Common::Functor1Mem<const AsylumEvent &, void, Encounter> *_messageHandler;
- EncounterItem *_currentEncounter;
+ // Data
+ Common::Array<int16> _variables;
+ int16 _anvilStyleFlag;
Common::Array<EncounterItem> _items;
+ // Running encounter data
+ int32 _index;
+ int32 _keywordIndex;
+ EncounterItem *_item;
+ ObjectId _objectId1;
+ ObjectId _objectId2;
+ ActorIndex _actorIndex;
+
+ // Internal flags
+ bool _flag1;
+ bool _flag2;
+
+ void load();
+
+ void messageHandler(const AsylumEvent &evt);
+
friend class Console;
}; // end of class Encounter
diff --git a/engines/asylum/resources/object.h b/engines/asylum/resources/object.h
index 3195b37b0d..bc851ebadb 100644
--- a/engines/asylum/resources/object.h
+++ b/engines/asylum/resources/object.h
@@ -131,6 +131,11 @@ public:
// Misc
////////////////////////////////////////////////////////////////////////
+ /**
+ * Stop the object related sounds
+ */
+ void stopSound();
+
/**
* Stop all object sounds (called from scripts)
*/
@@ -211,11 +216,6 @@ private:
*/
void updateSoundItems();
- /**
- * Stop the object related sounds
- */
- void stopSound();
-
/**
* Sets the volume.
*/
diff --git a/engines/asylum/shared.h b/engines/asylum/shared.h
index ab39cad3cd..0b5f93625c 100644
--- a/engines/asylum/shared.h
+++ b/engines/asylum/shared.h
@@ -471,6 +471,7 @@ enum ObjectId {
kObjectDennisStatus2 = 1580,
kObjectPreAlphaNut = 1582,
kObjectPreAlphaNut2 = 1584,
+ kObjectDeadMomFromOutside = 1589,
kObjectHeadOnTable = 1595,
kObjectWitchDoctor = 1778,
kObjectStoneWifeStatuQuo = 1782,
Commit: 377438ef7a2749a74e9b8f0f1810158c9bc57e37
https://github.com/scummvm/scummvm/commit/377438ef7a2749a74e9b8f0f1810158c9bc57e37
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:22+02:00
Commit Message:
ASYLUM: Update Encounter class
- Add error handling to load() method
- Implement getVariable & getVariableInv
- Add script init and entry loading
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@572 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/data.h
engines/asylum/eventhandler.h
engines/asylum/resources/encounters.cpp
engines/asylum/resources/encounters.h
engines/asylum/respack.h
diff --git a/engines/asylum/data.h b/engines/asylum/data.h
index 1693e38e14..a30b63f1ee 100644
--- a/engines/asylum/data.h
+++ b/engines/asylum/data.h
@@ -42,7 +42,6 @@ enum GlobalFlag {
kFlagSceneRectChanged,
kFlagScene1,
kFlagEncounter2,
- kFlagEncounter3,
kFlagEncounter5
};
@@ -141,7 +140,6 @@ public:
_nextScreenUpdate = 0;
memset(&_movies[49], 0, sizeof(_movies));
_actorUpdateStatus15Check = false;
- _flagEncouter3 = false;
_flag2 = false;
_flag5 = false;
}
@@ -266,9 +264,6 @@ public:
case kFlagEncounter2:
return _flagEncouter2;
- case kFlagEncounter3:
- return _flagEncouter3;
-
case kFlagEncounter5:
return _flagEncouter5;
}
@@ -303,10 +298,6 @@ public:
_flagEncouter2 = state;
break;
- case kFlagEncounter3:
- _flagEncouter3 = state;
- break;
-
case kFlagEncounter5:
_flagEncouter5 = state;
break;
@@ -370,7 +361,6 @@ private:
int32 _movies[49];
bool _actorUpdateStatus15Check;
// Skip opening flag (not used)
- bool _flagEncouter3;
bool _flag2;
bool _flag5;
};
diff --git a/engines/asylum/eventhandler.h b/engines/asylum/eventhandler.h
index 815073a7d1..660949a027 100644
--- a/engines/asylum/eventhandler.h
+++ b/engines/asylum/eventhandler.h
@@ -31,9 +31,19 @@
namespace Asylum {
+#define EVENT_ASYLUM FFF0
+
+enum AsylumMessages {
+ AsylumMessageUpdate,
+ AsylumMessageInit,
+ AsylumMessageDeInit,
+};
+
struct AsylumEvent : public Common::Event {
- // For events of type INVALID, we check our custom event value
- uint32 id;
+ // For events of type EVENT_ASYLUM, we check our custom event value
+ // Since we don't feed any custom message into the event manager,
+ // we can safely use our own custom event type.
+ uint32 extra;
};
typedef Common::Functor1<const AsylumEvent &, void> MessageHandler;
diff --git a/engines/asylum/resources/encounters.cpp b/engines/asylum/resources/encounters.cpp
index b51ef949e7..e3c2ad5173 100644
--- a/engines/asylum/resources/encounters.cpp
+++ b/engines/asylum/resources/encounters.cpp
@@ -32,6 +32,7 @@
#include "asylum/views/scene.h"
#include "asylum/asylum.h"
+#include "asylum/respack.h"
#include "common/file.h"
@@ -58,32 +59,33 @@ Encounter::~Encounter() {
void Encounter::load() {
Common::File file;
- // TODO error checks
- file.open("sntrm.dat");
+ if (!file.open("sntrm.dat"))
+ error("[Encounter::load] Could not open encounter data!");
- uint16 _count = file.readUint16LE();
-
- for (uint i = 0; i < _count; i++)
+ // Load the variables
+ uint16 count = file.readUint16LE();
+ for (uint i = 0; i < count; i++)
_variables.push_back(file.readSint16LE());
- file.seek(2 + _count * 2, SEEK_SET);
-
- // TODO assert if true
- _anvilStyleFlag = file.readSint16LE();
-
- int16 _dataCount = file.readSint16LE();
+ // Read anvil flag
+ if (file.readSint16LE())
+ error("[Encounter::load] Data file not supported!");
- for (uint8 i = 0; i < _dataCount; i++) {
+ // Read encounter data
+ int16 dataCount = file.readSint16LE();
+ for (uint8 i = 0; i < dataCount; i++) {
EncounterItem item;
memset(&item, 0, sizeof(EncounterItem));
- item.keywordIndex = file.readSint32LE();
- item.field2 = file.readSint32LE();
+ item.keywordIndex = file.readSint16LE();
+ item.field2 = file.readSint16LE();
item.scriptResourceId = (ResourceId)file.readSint32LE();
- for (uint8 j = 0; j < 50; j++) {
- item.array[j] = file.readSint32LE();
+
+ for (uint j = 0; j < 50; j++) {
+ item.array[j] = file.readSint16LE();
}
- item.value = file.readSint16LE();
+
+ item.value = file.readByte();
_items.push_back(item);
}
@@ -132,17 +134,15 @@ void Encounter::run(int32 encounterIndex, ObjectId objectId1, ObjectId objectId2
_vm->switchMessageHandler(_messageHandler);
}
-
-
//////////////////////////////////////////////////////////////////////////
// Message handler
//////////////////////////////////////////////////////////////////////////
void Encounter::messageHandler(const AsylumEvent &evt) {
-
+ error("[Encounter::messageHandler] Not implemented!");
}
//////////////////////////////////////////////////////////////////////////
-// Helpers functions
+// Variables
//////////////////////////////////////////////////////////////////////////
void Encounter::setVariable(uint32 index, int32 val) {
if (index >= _variables.size())
@@ -151,4 +151,31 @@ void Encounter::setVariable(uint32 index, int32 val) {
_variables[index] = val;
}
+int32 Encounter::getVariable(uint32 index) {
+ if (index >= _variables.size())
+ error("[Encounter::getVariable] Invalid index (was: %d, max: %d)", index, _variables.size() - 1);
+
+ return _variables[index];
+}
+int32 Encounter::getVariableInv(int32 index) {
+ if (index >= 0)
+ return index;
+
+ return getVariable(-index);
+}
+
+//////////////////////////////////////////////////////////////////////////
+// Scripts
+//////////////////////////////////////////////////////////////////////////
+void Encounter::initScript() {
+ _scriptData.reset();
+ _flag3 = false;
+}
+
+Encounter::ScriptEntry Encounter::getScriptEntry(ResourceId resourceId, uint32 offset) {
+ ResourceEntry *entry = getResource()->get(resourceId);
+
+ return (ScriptEntry)entry->getData(offset);
+}
+
}
diff --git a/engines/asylum/resources/encounters.h b/engines/asylum/resources/encounters.h
index 72a917e30f..21d9e2c1d8 100644
--- a/engines/asylum/resources/encounters.h
+++ b/engines/asylum/resources/encounters.h
@@ -35,25 +35,6 @@ namespace Asylum {
class AsylumEngine;
-typedef struct EncounterItem {
- int32 keywordIndex;
- int32 field2;
- ResourceId scriptResourceId;
- int32 array[50];
- int16 value;
-} EncounterItem;
-
-typedef struct EncounterStruct {
- int32 x1;
- int32 y1;
- int32 x2;
- int32 y2;
- int32 frameNum;
- int32 transTableNum;
- int32 status;
- ResourceId graphicResourceId;
-} EncounterStruct;
-
class Encounter {
public:
Encounter(AsylumEngine *engine);
@@ -61,14 +42,30 @@ public:
void run(int32 encounterIndex, ObjectId objectId1, ObjectId objectId2, ActorIndex actorIndex);
- void setVariable(uint32 index, int32 val);
-
private:
AsylumEngine *_vm;
- Common::Functor1Mem<const AsylumEvent &, void, Encounter> *_messageHandler;
-
+ //////////////////////////////////////////////////////////////////////////
// Data
+ typedef struct EncounterItem {
+ int16 keywordIndex;
+ int16 field2;
+ ResourceId scriptResourceId;
+ int16 array[50];
+ byte value;
+ } EncounterItem;
+
+ typedef struct EncounterStruct {
+ int32 x1;
+ int32 y1;
+ int32 x2;
+ int32 y2;
+ int32 frameNum;
+ int32 transTableNum;
+ int32 status;
+ ResourceId graphicResourceId;
+ } EncounterStruct;
+
Common::Array<int16> _variables;
int16 _anvilStyleFlag;
Common::Array<EncounterItem> _items;
@@ -84,11 +81,62 @@ private:
// Internal flags
bool _flag1;
bool _flag2;
+ bool _flag3;
+ //////////////////////////////////////////////////////////////////////////
+ // Data
void load();
+ //////////////////////////////////////////////////////////////////////////
+ // Message handling
+ Common::Functor1Mem<const AsylumEvent &, void, Encounter> *_messageHandler;
void messageHandler(const AsylumEvent &evt);
+ //////////////////////////////////////////////////////////////////////////
+ // Variables
+ void setVariable(uint32 index, int32 val);\
+ int32 getVariable(uint32 index);
+ int32 getVariableInv(int32 index);
+
+ //////////////////////////////////////////////////////////////////////////
+ // Scripts
+ struct ScriptEntry {
+ union {
+ byte opcode;
+ byte param1;
+ byte param2;
+ byte param3;
+ uint32 data;
+ };
+
+ ScriptEntry(uint32 val) {
+ data = val;
+ }
+ };
+
+ struct ScriptData {
+ int32 vars[10];
+ uint32 offset;
+ uint32 counter;
+ uint32 resourceId;
+
+ ScriptData() {
+ reset();
+ }
+
+ void reset() {
+ memset(&vars, 0, sizeof(vars));
+ offset = 0;
+ counter = 0;
+ resourceId = kResourceNone;
+ }
+ };
+
+ ScriptData _scriptData;
+
+ void initScript();
+ ScriptEntry getScriptEntry(ResourceId resourceId, uint32 offset);
+
friend class Console;
}; // end of class Encounter
diff --git a/engines/asylum/respack.h b/engines/asylum/respack.h
index 00a055d36c..da8e17a94f 100644
--- a/engines/asylum/respack.h
+++ b/engines/asylum/respack.h
@@ -40,6 +40,16 @@ struct ResourceEntry {
byte *data;
uint32 size;
uint32 offset;
+
+ ResourceEntry() {
+ data = NULL;
+ size = 0;
+ offset = 0;
+ }
+
+ uint32 getData(uint32 offset) {
+ return READ_UINT32((byte *)this + offset);
+ }
};
class ResourcePack {
Commit: 4cd87eaee2100c21c39ee8a29be2a88ca315dd80
https://github.com/scummvm/scummvm/commit/4cd87eaee2100c21c39ee8a29be2a88ca315dd80
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:23+02:00
Commit Message:
ASYLUM: Implement AsylumEngine::switchMessageHandler()
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@573 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/asylum.cpp
engines/asylum/asylum.h
engines/asylum/eventhandler.h
diff --git a/engines/asylum/asylum.cpp b/engines/asylum/asylum.cpp
index 8addb6d177..981e46d36c 100644
--- a/engines/asylum/asylum.cpp
+++ b/engines/asylum/asylum.cpp
@@ -52,7 +52,7 @@ namespace Asylum {
AsylumEngine::AsylumEngine(OSystem *system, const ADGameDescription *gd) : Engine(system), _gameDescription(gd),
_console(NULL), _cursor(NULL), _encounter(NULL), _mainMenu(NULL), _resource(NULL), _scene(NULL), _screen(NULL),
- _sound(NULL), _text(NULL), _video(NULL), _introPlaying(false) {
+ _sound(NULL), _text(NULL), _video(NULL), _introPlaying(false), _handler(NULL) {
// Init data
memset(&_gameFlags, 0, sizeof(_gameFlags));
@@ -351,7 +351,21 @@ void AsylumEngine::processDelayedEvents() {
// Message handlers
//////////////////////////////////////////////////////////////////////////
void AsylumEngine::switchMessageHandler(MessageHandler *handler) {
- error("[AsylumEngine::switchMessageHandler] not implemented");
+ if (handler == NULL)
+ error("[AsylumEngine::switchMessageHandler] Invalid handler parameter (cannot be NULL)!");
+
+ // De-init previous handler
+ if (_handler != NULL) {
+ AsylumEvent deinit(EVENT_ASYLUM, AsylumMessageDeInit);
+ (*_handler)(deinit);
+ }
+
+ // replace message handler
+ _handler = handler;
+
+ // Init new handler
+ AsylumEvent init(EVENT_ASYLUM, AsylumMessageInit);
+ (*_handler)(init);
}
MessageHandler *AsylumEngine::getMessageHandler(uint32 index) {
diff --git a/engines/asylum/asylum.h b/engines/asylum/asylum.h
index 0b9a7ae735..4c92eae2fe 100644
--- a/engines/asylum/asylum.h
+++ b/engines/asylum/asylum.h
@@ -144,6 +144,7 @@ public:
uint getRandomBit() { return _rnd.getRandomBit(); }
// Message handler
+ MessageHandler *_handler;
void switchMessageHandler(MessageHandler *handler);
MessageHandler *getMessageHandler(uint32 index);
diff --git a/engines/asylum/eventhandler.h b/engines/asylum/eventhandler.h
index 660949a027..9ce975a81b 100644
--- a/engines/asylum/eventhandler.h
+++ b/engines/asylum/eventhandler.h
@@ -31,7 +31,7 @@
namespace Asylum {
-#define EVENT_ASYLUM FFF0
+#define EVENT_ASYLUM 0xFFF0
enum AsylumMessages {
AsylumMessageUpdate,
@@ -43,7 +43,12 @@ struct AsylumEvent : public Common::Event {
// For events of type EVENT_ASYLUM, we check our custom event value
// Since we don't feed any custom message into the event manager,
// we can safely use our own custom event type.
- uint32 extra;
+ AsylumMessages extra;
+
+ AsylumEvent(uint32 msgType, AsylumMessages customMessage) {
+ type = (Common::EventType)msgType;
+ extra = customMessage;
+ }
};
typedef Common::Functor1<const AsylumEvent &, void> MessageHandler;
Commit: c8a9d4cc0a1e52c2fa60bb6416d20cd238cf67f8
https://github.com/scummvm/scummvm/commit/c8a9d4cc0a1e52c2fa60bb6416d20cd238cf67f8
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:23+02:00
Commit Message:
ASYLUM: Implement Encounter::runScript()
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@574 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/resources/encounters.cpp
engines/asylum/resources/encounters.h
diff --git a/engines/asylum/resources/encounters.cpp b/engines/asylum/resources/encounters.cpp
index e3c2ad5173..9eaebca702 100644
--- a/engines/asylum/resources/encounters.cpp
+++ b/engines/asylum/resources/encounters.cpp
@@ -25,10 +25,13 @@
#include "asylum/resources/encounters.h"
+#include "asylum/resources/actionlist.h"
#include "asylum/resources/actor.h"
#include "asylum/resources/object.h"
#include "asylum/resources/worldstats.h"
+#include "asylum/system/cursor.h"
+
#include "asylum/views/scene.h"
#include "asylum/asylum.h"
@@ -56,6 +59,9 @@ Encounter::~Encounter() {
_vm = NULL;
}
+//////////////////////////////////////////////////////////////////////////
+// Data
+//////////////////////////////////////////////////////////////////////////
void Encounter::load() {
Common::File file;
@@ -82,7 +88,7 @@ void Encounter::load() {
item.scriptResourceId = (ResourceId)file.readSint32LE();
for (uint j = 0; j < 50; j++) {
- item.array[j] = file.readSint16LE();
+ item.keywords[j] = file.readSint16LE();
}
item.value = file.readByte();
@@ -93,6 +99,13 @@ void Encounter::load() {
file.close();
}
+uint32 Encounter::findKeyword(EncounterItem *item, int16 keyword) {
+ error("[Encounter::findKeyword] Not implemented!");
+}
+
+//////////////////////////////////////////////////////////////////////////
+// Run
+//////////////////////////////////////////////////////////////////////////
void Encounter::run(int32 encounterIndex, ObjectId objectId1, ObjectId objectId2, ActorIndex actorIndex) {
// Line: 12/15 :: 0x25 (1, 1584, 1584, 0, 0, 0, 0, 0, 0) // First Encounter
debugC(kDebugLevelEncounter, "Running Encounter %d", encounterIndex);
@@ -115,7 +128,7 @@ void Encounter::run(int32 encounterIndex, ObjectId objectId1, ObjectId objectId2
if (getWorld()->getObjectById(objectId2))
getWorld()->getObjectById(objectId2)->stopSound();
- getWorld()->actors[actorIndex]->stopSound();
+ getScene()->getActor(actorIndex)->stopSound();
setVariable(1, 0);
setVariable(2, _item->value);
@@ -164,6 +177,13 @@ int32 Encounter::getVariableInv(int32 index) {
return getVariable(-index);
}
+//////////////////////////////////////////////////////////////////////////
+// Logic
+//////////////////////////////////////////////////////////////////////////
+void Encounter::resetSpeech(uint32 a1, uint32 a2) {
+ error("[Encounter::resetSpeech] Not implemented!");
+}
+
//////////////////////////////////////////////////////////////////////////
// Scripts
//////////////////////////////////////////////////////////////////////////
@@ -178,4 +198,214 @@ Encounter::ScriptEntry Encounter::getScriptEntry(ResourceId resourceId, uint32 o
return (ScriptEntry)entry->getData(offset);
}
+void Encounter::runScript() {
+ _flag4 = true;
+ bool done = false;
+
+ do {
+ ScriptEntry entry = getScriptEntry(_scriptData.resourceId, _scriptData.offset);
+
+ debugC(kDebugLevelEncounter, "Encounter %s", entry.toString().c_str());
+
+ switch (entry.opcode) {
+ default:
+ break;
+
+ case 0:
+ _flag4 = false;
+ done = true;
+ _value1 = 0;
+ break;
+
+ case 1:
+ _scriptData.vars[entry.param1] = getVariableInv(entry.param2);
+ break;
+
+ case 2:
+ _scriptData.counter = _scriptData.vars[entry.param1] - getVariableInv(entry.param2);
+ break;
+
+ case 3:
+ _scriptData.offset = entry.param2 - 1;
+ break;
+
+ case 4:
+ if (_scriptData.counter >= 0)
+ break;
+
+ _scriptData.offset = entry.param2;
+ break;
+
+ case 5:
+ if (_scriptData.counter > 0)
+ break;
+
+ _scriptData.offset = entry.param2;
+ break;
+
+ case 6:
+ if (_scriptData.counter)
+ break;
+
+ _scriptData.offset = entry.param2 - 1;
+ break;
+
+ case 7:
+ if (!_scriptData.counter)
+ break;
+
+ _scriptData.offset = entry.param2;
+ break;
+
+ case 8:
+ if (_scriptData.counter < 0)
+ break;
+
+ _scriptData.offset = entry.param2;
+ break;
+
+ case 9:
+ if (_scriptData.counter <= 0)
+ break;
+
+ _scriptData.offset = entry.param2 - 1;
+ break;
+
+ case 10:
+ if (entry.param1)
+ _item->keywords[findKeyword(_item, entry.param2)] &= ~kEncounterArray2000;
+ else
+ _item->keywords[findKeyword(_item, entry.param2)] |= kEncounterArray8000;
+ break;
+
+ case 11:
+ if (entry.param1)
+ _item->keywords[findKeyword(_item, entry.param2)] |= kEncounterArray2000;
+ else
+ _item->keywords[findKeyword(_item, entry.param2)] &= ~kEncounterArray8000;
+ break;
+
+ case 12:
+ _items[entry.param1].keywords[findKeyword(&_items[entry.param1], entry.param2)] |= kEncounterArray4000;
+ _items[entry.param1].keywords[findKeyword(&_items[entry.param1], entry.param2)] |= kEncounterArray8000;
+ break;
+
+ case 13:
+ if (!_flag3)
+ _data_455BD4 = 1;
+
+ done = true;
+ break;
+
+ case 14:
+ resetSpeech(_item->keywordIndex, getVariableInv(entry.param2));
+
+ done = true;
+ break;
+
+ case 15:
+ setVariable(entry.param2, _scriptData.vars[entry.param1]);
+ break;
+
+ case 16:
+ _scriptData.vars[entry.param1] += entry.param2;
+ break;
+
+ case 17:
+ switch (getVariable(3)) {
+ default:
+ break;
+
+ case 13:
+ case 15:
+ if (_actorIndex) {
+ getScene()->getActor(_actorIndex)->hide();
+ } else {
+ getWorld()->getObjectById(_objectId1)->disable();
+ getWorld()->getObjectById(_objectId2)->disable();
+ }
+
+ if (getVariable(3) == 13)
+ break;
+ // Fallback to next case
+
+ case 14:
+ getScene()->getActor()->hide(); // Hide player
+ break;
+
+ case 16: {
+ Object *obj = getWorld()->getObjectById((ObjectId)getVariableInv(entry.param2));
+ obj->setNextFrame(obj->flags);
+ _data_455BF4 = 1;
+ done = true;
+ }
+ break;
+
+ case 17:
+ getWorld()->getObjectById((ObjectId)getVariableInv(entry.param2))->setNextFrame(32);
+ _data_455BF4 = 1;
+ done = true;
+ break;
+
+ case 18:
+ getWorld()->getObjectById((ObjectId)getVariableInv(entry.param2))->setNextFrame(512);
+ _data_455BF4 = 1;
+ done = true;
+ break;
+ }
+
+ if (!done) {
+ _objectId3 = (ObjectId)getVariableInv(entry.param2);
+ getWorld()->getObjectById(_objectId3)->setNextFrame(8);
+ getCursor()->hide();
+ done = true;
+ }
+ break;
+
+ case 18:
+ if (entry.param1)
+ getScene()->getActor()->process_41BCC0(getVariableInv(entry.param2), _scriptData.vars[1]);
+ else
+ getScene()->getActor()->process_41BC00(getVariableInv(entry.param2), _scriptData.vars[1]);
+ break;
+
+ case 21:
+ _scriptData.counter = getScene()->getActor()->process_41BDB0(getVariableInv(entry.param2), _scriptData.vars[1]) ? 0 : 1;
+ break;
+
+ case 23:
+ if (!getSharedData()->getMatteBarHeight()) {
+ getScene()->makeGreyPalette();
+ getSharedData()->setMatteBarHeight(1);
+ getScene()->actions()->setDelayedVideoIndex(getVariableInv(entry.param2));
+ getSharedData()->setMatteVar1(1);
+ getSharedData()->setMattePlaySound(true);
+ getSharedData()->setMatteInitialized(true);
+ getSharedData()->setMatteVar2(0);
+ done = true;
+ }
+
+ if (!_data_455BE8) {
+ _data_455BE8 = true;
+ getCursor()->hide();
+ }
+ break;
+
+ case 24:
+ if (entry.param1)
+ _vm->setGameFlag((GameFlag)getVariableInv(entry.param2));
+ else
+ _vm->clearGameFlag((GameFlag)getVariableInv(entry.param2));
+ break;
+
+ case 25:
+ _scriptData.counter = _vm->isGameFlagSet((GameFlag)getVariableInv(entry.param2)) ? 1 : 0;
+ break;
+ }
+
+ ++_scriptData.offset;
+
+ } while (!done);
+}
+
}
diff --git a/engines/asylum/resources/encounters.h b/engines/asylum/resources/encounters.h
index 21d9e2c1d8..0e61430bdf 100644
--- a/engines/asylum/resources/encounters.h
+++ b/engines/asylum/resources/encounters.h
@@ -47,11 +47,17 @@ private:
//////////////////////////////////////////////////////////////////////////
// Data
+ enum EncounterArray {
+ kEncounterArray2000 = 0x2000,
+ kEncounterArray4000 = 0x4000,
+ kEncounterArray8000 = 0x8000,
+ };
+
typedef struct EncounterItem {
int16 keywordIndex;
int16 field2;
ResourceId scriptResourceId;
- int16 array[50];
+ int16 keywords[50];
byte value;
} EncounterItem;
@@ -76,16 +82,26 @@ private:
EncounterItem *_item;
ObjectId _objectId1;
ObjectId _objectId2;
+ ObjectId _objectId3;
ActorIndex _actorIndex;
+ uint32 _value1;
+
+ // Internal data
+ bool _data_455BE8;
+ uint32 _data_455BF4;
+ bool _data_455BD4;
+
// Internal flags
bool _flag1;
bool _flag2;
bool _flag3;
+ bool _flag4;
//////////////////////////////////////////////////////////////////////////
// Data
void load();
+ uint32 findKeyword(EncounterItem *item, int16 keyword);
//////////////////////////////////////////////////////////////////////////
// Message handling
@@ -98,26 +114,33 @@ private:
int32 getVariable(uint32 index);
int32 getVariableInv(int32 index);
+ //////////////////////////////////////////////////////////////////////////
+ // Logic
+ void resetSpeech(uint32 a1, uint32 a2);
+
//////////////////////////////////////////////////////////////////////////
// Scripts
struct ScriptEntry {
union {
byte opcode;
byte param1;
- byte param2;
- byte param3;
+ uint16 param2;
uint32 data;
};
ScriptEntry(uint32 val) {
data = val;
}
+
+ Common::String toString() {
+ return Common::String::format("[0x%02X] %d %d", opcode, param1, param2);
+ }
};
struct ScriptData {
int32 vars[10];
uint32 offset;
- uint32 counter;
+ int32 counter;
uint32 resourceId;
ScriptData() {
@@ -136,6 +159,7 @@ private:
void initScript();
ScriptEntry getScriptEntry(ResourceId resourceId, uint32 offset);
+ void runScript();
friend class Console;
}; // end of class Encounter
Commit: a07548e60556b68d6a5ffdb0d9ca681127b73b87
https://github.com/scummvm/scummvm/commit/a07548e60556b68d6a5ffdb0d9ca681127b73b87
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:23+02:00
Commit Message:
ASYLUM: Implement Encounter::findKeyword()
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@575 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/resources/encounters.cpp
diff --git a/engines/asylum/resources/encounters.cpp b/engines/asylum/resources/encounters.cpp
index 9eaebca702..87f045ca1d 100644
--- a/engines/asylum/resources/encounters.cpp
+++ b/engines/asylum/resources/encounters.cpp
@@ -100,7 +100,12 @@ void Encounter::load() {
}
uint32 Encounter::findKeyword(EncounterItem *item, int16 keyword) {
- error("[Encounter::findKeyword] Not implemented!");
+ for (uint i = 0; i < ARRAYSIZE(item->keywords); i++) {
+ if ((item->keywords[i] & 0xFFF) == keyword)
+ return i;
+ }
+
+ error("[Encounter::findKeyword] Could not find a valid keyword!");
}
//////////////////////////////////////////////////////////////////////////
Commit: 01b0ea49152e52e1c5fa3b7656b4274b6fb3132c
https://github.com/scummvm/scummvm/commit/01b0ea49152e52e1c5fa3b7656b4274b6fb3132c
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:23+02:00
Commit Message:
ASYLUM: Implement Encounter::messageHandler()
- Add Sound::getMusicVolume()
- Update AsylumEvent
- Add stubs for mouse, key, update and init events handlers
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@576 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/asylum.cpp
engines/asylum/eventhandler.h
engines/asylum/resources/encounters.cpp
engines/asylum/resources/encounters.h
engines/asylum/system/sound.cpp
engines/asylum/system/sound.h
diff --git a/engines/asylum/asylum.cpp b/engines/asylum/asylum.cpp
index 981e46d36c..39833dbf44 100644
--- a/engines/asylum/asylum.cpp
+++ b/engines/asylum/asylum.cpp
@@ -356,7 +356,7 @@ void AsylumEngine::switchMessageHandler(MessageHandler *handler) {
// De-init previous handler
if (_handler != NULL) {
- AsylumEvent deinit(EVENT_ASYLUM, AsylumMessageDeInit);
+ AsylumEvent deinit(EVENT_ASYLUM_DEINIT);
(*_handler)(deinit);
}
@@ -364,7 +364,7 @@ void AsylumEngine::switchMessageHandler(MessageHandler *handler) {
_handler = handler;
// Init new handler
- AsylumEvent init(EVENT_ASYLUM, AsylumMessageInit);
+ AsylumEvent init(EVENT_ASYLUM_INIT);
(*_handler)(init);
}
diff --git a/engines/asylum/eventhandler.h b/engines/asylum/eventhandler.h
index 9ce975a81b..421c3938be 100644
--- a/engines/asylum/eventhandler.h
+++ b/engines/asylum/eventhandler.h
@@ -31,23 +31,17 @@
namespace Asylum {
-#define EVENT_ASYLUM 0xFFF0
-
-enum AsylumMessages {
- AsylumMessageUpdate,
- AsylumMessageInit,
- AsylumMessageDeInit,
+enum AsylumEventType {
+ EVENT_ASYLUM_INIT = 0xFFF0,
+ EVENT_ASYLUM_DEINIT = 0xFFF1,
+ EVENT_ASYLUM_UPDATE = 0xFFF2
};
struct AsylumEvent : public Common::Event {
- // For events of type EVENT_ASYLUM, we check our custom event value
// Since we don't feed any custom message into the event manager,
// we can safely use our own custom event type.
- AsylumMessages extra;
-
- AsylumEvent(uint32 msgType, AsylumMessages customMessage) {
+ AsylumEvent(AsylumEventType msgType) {
type = (Common::EventType)msgType;
- extra = customMessage;
}
};
diff --git a/engines/asylum/resources/encounters.cpp b/engines/asylum/resources/encounters.cpp
index 87f045ca1d..fdca450968 100644
--- a/engines/asylum/resources/encounters.cpp
+++ b/engines/asylum/resources/encounters.cpp
@@ -156,7 +156,51 @@ void Encounter::run(int32 encounterIndex, ObjectId objectId1, ObjectId objectId2
// Message handler
//////////////////////////////////////////////////////////////////////////
void Encounter::messageHandler(const AsylumEvent &evt) {
- error("[Encounter::messageHandler] Not implemented!");
+ switch ((uint32)evt.type) {
+ default:
+ break;
+
+ case EVENT_ASYLUM_INIT:
+ init();
+ break;
+
+ case EVENT_ASYLUM_UPDATE:
+ update();
+ break;
+
+ case Common::EVENT_KEYDOWN:
+ key(evt);
+ break;
+
+ case Common::EVENT_LBUTTONDOWN:
+ case Common::EVENT_LBUTTONUP:
+ case Common::EVENT_RBUTTONDOWN:
+ case Common::EVENT_RBUTTONUP:
+ mouse(evt);
+ break;
+ }
+}
+
+void Encounter::init() {
+ if (getSound()->getMusicVolume() != Config.musicVolume - 500)
+ getSound()->setMusicVolume(Config.musicVolume - 500);
+
+ error("[Encounter::init] Not implemented!");
+}
+
+void Encounter::update() {
+ if (getSound()->getMusicVolume() != Config.musicVolume - 500)
+ getSound()->setMusicVolume(Config.musicVolume - 500);
+
+ error("[Encounter::update] Not implemented!");
+}
+
+void Encounter::key(const AsylumEvent &evt) {
+ error("[Encounter::key] Not implemented!");
+}
+
+void Encounter::mouse(const AsylumEvent &evt) {
+ error("[Encounter::mouse] Not implemented!");
}
//////////////////////////////////////////////////////////////////////////
diff --git a/engines/asylum/resources/encounters.h b/engines/asylum/resources/encounters.h
index 0e61430bdf..fac29d3418 100644
--- a/engines/asylum/resources/encounters.h
+++ b/engines/asylum/resources/encounters.h
@@ -107,6 +107,10 @@ private:
// Message handling
Common::Functor1Mem<const AsylumEvent &, void, Encounter> *_messageHandler;
void messageHandler(const AsylumEvent &evt);
+ void init();
+ void update();
+ void key(const AsylumEvent &evt);
+ void mouse(const AsylumEvent &evt);
//////////////////////////////////////////////////////////////////////////
// Variables
diff --git a/engines/asylum/system/sound.cpp b/engines/asylum/system/sound.cpp
index 204d252713..5e171793dc 100644
--- a/engines/asylum/system/sound.cpp
+++ b/engines/asylum/system/sound.cpp
@@ -43,7 +43,7 @@
namespace Asylum {
-Sound::Sound(AsylumEngine *engine, Audio::Mixer *mixer) : _vm(engine), _mixer(mixer) {
+Sound::Sound(AsylumEngine *engine, Audio::Mixer *mixer) : _vm(engine), _mixer(mixer), _musicVolume(-10000) {
}
Sound::~Sound() {
@@ -126,6 +126,9 @@ void Sound::setMusicVolume(int32 volume) {
if (volume < -10000)
return;
+ // Save music volume (we need to be able to return it to the logic code
+ _musicVolume = volume;
+
convertVolume(volume);
_mixer->setChannelVolume(_musicHandle, (byte)volume);
diff --git a/engines/asylum/system/sound.h b/engines/asylum/system/sound.h
index 2f5bb18b9f..5901603225 100644
--- a/engines/asylum/system/sound.h
+++ b/engines/asylum/system/sound.h
@@ -165,6 +165,13 @@ public:
*/
void setMusicVolume(int32 volume);
+ /**
+ * Gets the music volume.
+ *
+ * @return The music volume.
+ */
+ int32 getMusicVolume() { return _musicVolume; }
+
/**
* Sets the panning for a buffered sound resource
*
@@ -240,6 +247,8 @@ private:
Audio::SoundHandle _musicHandle;
Audio::SoundHandle _soundHandle;
+ int32 _musicVolume;
+
Common::Array<SoundBufferItem> _soundBuffer;
/**
Commit: e23232ddece95a76f420487dee9720ab778751ee
https://github.com/scummvm/scummvm/commit/e23232ddece95a76f420487dee9720ab778751ee
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:23+02:00
Commit Message:
ASYLUM: Add Encounter::isSpeaking() helper method
- Expose Speech tick
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@577 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/resources/encounters.cpp
engines/asylum/resources/encounters.h
engines/asylum/system/speech.h
diff --git a/engines/asylum/resources/encounters.cpp b/engines/asylum/resources/encounters.cpp
index fdca450968..d38f08e656 100644
--- a/engines/asylum/resources/encounters.cpp
+++ b/engines/asylum/resources/encounters.cpp
@@ -31,6 +31,7 @@
#include "asylum/resources/worldstats.h"
#include "asylum/system/cursor.h"
+#include "asylum/system/speech.h"
#include "asylum/views/scene.h"
@@ -227,12 +228,29 @@ int32 Encounter::getVariableInv(int32 index) {
}
//////////////////////////////////////////////////////////////////////////
-// Logic
+// Speech
//////////////////////////////////////////////////////////////////////////
void Encounter::resetSpeech(uint32 a1, uint32 a2) {
error("[Encounter::resetSpeech] Not implemented!");
}
+bool Encounter::isSpeaking() {
+ if (!_flag4)
+ return false;
+
+ if (getSpeech()->getSoundResourceId() != kResourceNone && getSound()->isPlaying(getSpeech()->getSoundResourceId())) {
+ getSound()->stopAll(getSpeech()->getSoundResourceId());
+ return true;
+ }
+
+ if (getSpeech()->getTick()) {
+ getSpeech()->setTick(_vm->getTick());
+ return true;
+ }
+
+ return false;
+}
+
//////////////////////////////////////////////////////////////////////////
// Scripts
//////////////////////////////////////////////////////////////////////////
diff --git a/engines/asylum/resources/encounters.h b/engines/asylum/resources/encounters.h
index fac29d3418..326a6b5b5f 100644
--- a/engines/asylum/resources/encounters.h
+++ b/engines/asylum/resources/encounters.h
@@ -119,8 +119,9 @@ private:
int32 getVariableInv(int32 index);
//////////////////////////////////////////////////////////////////////////
- // Logic
+ // Speech
void resetSpeech(uint32 a1, uint32 a2);
+ bool isSpeaking();
//////////////////////////////////////////////////////////////////////////
// Scripts
diff --git a/engines/asylum/system/speech.h b/engines/asylum/system/speech.h
index 7a24476c6c..54334e72b6 100644
--- a/engines/asylum/system/speech.h
+++ b/engines/asylum/system/speech.h
@@ -93,6 +93,20 @@ public:
*/
ResourceId getSoundResourceId() const { return _soundResourceId; }
+ /**
+ * Sets the tick.
+ *
+ * @param val The value.
+ */
+ void setTick(int32 val) { _tick = val;}
+
+ /**
+ * Gets the tick.
+ *
+ * @return The tick.
+ */
+ int32 getTick() { return _tick; }
+
private:
AsylumEngine *_vm;
Commit: b808ab3e2a632cf23d9672dbb7bb9a0c7e4c68ee
https://github.com/scummvm/scummvm/commit/b808ab3e2a632cf23d9672dbb7bb9a0c7e4c68ee
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:23+02:00
Commit Message:
ASYLUM: Move two encounter flags from shared data to Encounter class
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@578 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/data.h
engines/asylum/resources/actionlist.cpp
engines/asylum/resources/actor.cpp
engines/asylum/resources/encounters.h
engines/asylum/resources/special.cpp
diff --git a/engines/asylum/data.h b/engines/asylum/data.h
index a30b63f1ee..b2db7a8aa1 100644
--- a/engines/asylum/data.h
+++ b/engines/asylum/data.h
@@ -40,9 +40,7 @@ enum GlobalFlag {
kFlag2,
kFlagSkipDraw,
kFlagSceneRectChanged,
- kFlagScene1,
- kFlagEncounter2,
- kFlagEncounter5
+ kFlagScene1
};
/**
@@ -113,7 +111,6 @@ public:
_sceneCounter = 0;
_globalX = 0;
_globalY = 0;
- _flagEncouter2 = false;
_sceneXLeft = 0;
_sceneYTop = 0;
_sceneOffset = 0;
@@ -135,7 +132,6 @@ public:
memset(&_data2[11], 0, sizeof(_data2));
_actorUpdateStatusEnabledCounter = 0;
memset(&_data3[9], 0, sizeof(_data3));
- _flagEncouter5 = false;
_flagScene1 = false;
_nextScreenUpdate = 0;
memset(&_movies[49], 0, sizeof(_movies));
@@ -260,12 +256,6 @@ public:
case kFlagScene1:
return _flagScene1;
-
- case kFlagEncounter2:
- return _flagEncouter2;
-
- case kFlagEncounter5:
- return _flagEncouter5;
}
}
@@ -293,14 +283,6 @@ public:
case kFlagScene1:
_flagScene1 = state;
break;
-
- case kFlagEncounter2:
- _flagEncouter2 = state;
- break;
-
- case kFlagEncounter5:
- _flagEncouter5 = state;
- break;
}
}
@@ -328,7 +310,7 @@ private:
uint32 _sceneCounter;
int32 _globalX;
int32 _globalY;
- bool _flagEncouter2;
+ //bool _flagEncouter2;
int32 _sceneXLeft;
int32 _sceneYTop;
int32 _sceneOffset;
@@ -355,7 +337,7 @@ private:
int32 _data2[11];
bool _actorUpdateStatusEnabledCounter;
bool _data3[9];
- bool _flagEncouter5;
+ //bool _flagEncouter5;
bool _flagScene1;
int32 _nextScreenUpdate;
int32 _movies[49];
diff --git a/engines/asylum/resources/actionlist.cpp b/engines/asylum/resources/actionlist.cpp
index 21126222f2..4c456f3710 100644
--- a/engines/asylum/resources/actionlist.cpp
+++ b/engines/asylum/resources/actionlist.cpp
@@ -744,10 +744,10 @@ END_OPCODE
IMPLEMENT_OPCODE(RunEncounter)
Encounter *encounter = _vm->encounter();
- getSharedData()->setFlag(kFlagEncounter5, cmd->param5);
+ encounter->setFlag5(cmd->param5);
if (cmd->param6) {
- if (getSharedData()->getFlag(kFlagEncounter2))
+ if (encounter->getFlag6())
_lineIncrement = 1;
else
cmd->param6 = 0;
diff --git a/engines/asylum/resources/actor.cpp b/engines/asylum/resources/actor.cpp
index c17eb81b44..5a172c9275 100644
--- a/engines/asylum/resources/actor.cpp
+++ b/engines/asylum/resources/actor.cpp
@@ -504,7 +504,7 @@ void Actor::update() {
break;
case kActorStatus8:
- if (getSharedData()->getFlag(kFlagEncounter2)
+ if (_vm->encounter()->getFlag6()
|| !_soundResourceId
|| getSound()->isPlaying(_soundResourceId)) {
_frameIndex = (_frameIndex + 1) % _frameCount;
@@ -599,7 +599,7 @@ void Actor::updateStatus(ActorStatus actorStatus) {
break;
case kActorStatus9:
- if (getSharedData()->getFlag(kFlagEncounter2))
+ if (_vm->encounter()->getFlag6())
return;
if (_vm->getRandomBit() == 1 && isDefaultDirection(15))
@@ -1020,7 +1020,7 @@ void Actor::updateStatusEnabled() {
if (_vm->isGameFlagNotSet(kGameFlagScriptProcessing)
&& isVisible()
- && !getSharedData()->getFlag(kFlagEncounter2)
+ && !_vm->encounter()->getFlag6()
&& !getSpeech()->getSoundResourceId()) {
if (_vm->getRandom(100) < 50) {
if (getWorld()->chapter == kChapter13)
diff --git a/engines/asylum/resources/encounters.h b/engines/asylum/resources/encounters.h
index 326a6b5b5f..987f699740 100644
--- a/engines/asylum/resources/encounters.h
+++ b/engines/asylum/resources/encounters.h
@@ -42,6 +42,9 @@ public:
void run(int32 encounterIndex, ObjectId objectId1, ObjectId objectId2, ActorIndex actorIndex);
+ void setFlag5(bool state) { _flag5 = state; }
+ bool getFlag6() { return _flag6; }
+
private:
AsylumEngine *_vm;
@@ -97,6 +100,8 @@ private:
bool _flag2;
bool _flag3;
bool _flag4;
+ bool _flag5;
+ bool _flag6;
//////////////////////////////////////////////////////////////////////////
// Data
diff --git a/engines/asylum/resources/special.cpp b/engines/asylum/resources/special.cpp
index d1024f23a2..631b207a1f 100644
--- a/engines/asylum/resources/special.cpp
+++ b/engines/asylum/resources/special.cpp
@@ -666,7 +666,7 @@ void Special::chapter9(Object *object, ActorIndex actorIndex) {
void Special::playChapterSound(Object *object, ActorIndex actorIndex) {
ResourceId id = getResourceId(object, actorIndex);
- if (getSharedData()->getFlag(kFlagEncounter2))
+ if (_vm->encounter()->getFlag6())
return;
if (id != kResourceNone && getSound()->isPlaying(id))
Commit: 4534e7fbda55d00415c66b72e3d6d9599d3f779d
https://github.com/scummvm/scummvm/commit/4534e7fbda55d00415c66b72e3d6d9599d3f779d
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:23+02:00
Commit Message:
ASYLUM: Move data.h to resources folder
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@579 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
A engines/asylum/resources/data.h
R engines/asylum/data.h
engines/asylum/asylum.h
engines/asylum/resources/actor.cpp
diff --git a/engines/asylum/asylum.h b/engines/asylum/asylum.h
index 4c92eae2fe..3b5695dcc1 100644
--- a/engines/asylum/asylum.h
+++ b/engines/asylum/asylum.h
@@ -26,8 +26,9 @@
#ifndef ASYLUM_ENGINE_H
#define ASYLUM_ENGINE_H
+#include "asylum/resources/data.h"
+
#include "asylum/console.h"
-#include "asylum/data.h"
#include "asylum/eventhandler.h"
#include "asylum/shared.h"
diff --git a/engines/asylum/resources/actor.cpp b/engines/asylum/resources/actor.cpp
index 5a172c9275..69a84a49cf 100644
--- a/engines/asylum/resources/actor.cpp
+++ b/engines/asylum/resources/actor.cpp
@@ -40,7 +40,6 @@
#include "asylum/views/scene.h"
#include "asylum/asylum.h"
-#include "asylum/data.h"
#include "asylum/staticres.h"
#include "common/endian.h"
diff --git a/engines/asylum/data.h b/engines/asylum/resources/data.h
similarity index 100%
rename from engines/asylum/data.h
rename to engines/asylum/resources/data.h
Commit: df58690e9c607968eb3c215e5dca0c0ce5dcb7a2
https://github.com/scummvm/scummvm/commit/df58690e9c607968eb3c215e5dca0c0ce5dcb7a2
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:23+02:00
Commit Message:
ASYLUM: Move puzzle class to a separate puzzles directory
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@580 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
A engines/asylum/puzzles/puzzle.cpp
A engines/asylum/puzzles/puzzle.h
R engines/asylum/views/blowuppuzzle.cpp
R engines/asylum/views/blowuppuzzle.h
engines/asylum/module.mk
diff --git a/engines/asylum/module.mk b/engines/asylum/module.mk
index 9b605a5f67..8a84b69263 100644
--- a/engines/asylum/module.mk
+++ b/engines/asylum/module.mk
@@ -1,6 +1,7 @@
MODULE := engines/asylum
MODULE_OBJS := \
+ puzzles/puzzle.o \
resources/actionlist.o \
resources/actor.o \
resources/object.o \
@@ -17,7 +18,6 @@ MODULE_OBJS := \
system/speech.o \
system/text.o \
system/video.o \
- views/blowuppuzzle.o \
views/menu.o \
views/scene.o \
views/scenetitle.o \
diff --git a/engines/asylum/views/blowuppuzzle.cpp b/engines/asylum/puzzles/puzzle.cpp
similarity index 99%
rename from engines/asylum/views/blowuppuzzle.cpp
rename to engines/asylum/puzzles/puzzle.cpp
index 379540d726..0e976c81d3 100644
--- a/engines/asylum/views/blowuppuzzle.cpp
+++ b/engines/asylum/puzzles/puzzle.cpp
@@ -23,7 +23,7 @@
*
*/
-#include "asylum/views/blowuppuzzle.h"
+#include "asylum/puzzles/puzzle.h"
#include "asylum/resources/worldstats.h"
diff --git a/engines/asylum/views/blowuppuzzle.h b/engines/asylum/puzzles/puzzle.h
similarity index 100%
rename from engines/asylum/views/blowuppuzzle.h
rename to engines/asylum/puzzles/puzzle.h
Commit: d2c8b7e83fc7094ea8430d769c6985ff2829b0e1
https://github.com/scummvm/scummvm/commit/d2c8b7e83fc7094ea8430d769c6985ff2829b0e1
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:24+02:00
Commit Message:
ASYLUM: Move VCR puzzle to a separate file
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@581 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
A engines/asylum/puzzles/vcr.cpp
A engines/asylum/puzzles/vcr.h
engines/asylum/module.mk
engines/asylum/puzzles/puzzle.cpp
engines/asylum/puzzles/puzzle.h
diff --git a/engines/asylum/module.mk b/engines/asylum/module.mk
index 8a84b69263..6349462795 100644
--- a/engines/asylum/module.mk
+++ b/engines/asylum/module.mk
@@ -2,6 +2,7 @@ MODULE := engines/asylum
MODULE_OBJS := \
puzzles/puzzle.o \
+ puzzles/vcr.o \
resources/actionlist.o \
resources/actor.o \
resources/object.o \
diff --git a/engines/asylum/puzzles/puzzle.cpp b/engines/asylum/puzzles/puzzle.cpp
index 0e976c81d3..8a6cd0d038 100644
--- a/engines/asylum/puzzles/puzzle.cpp
+++ b/engines/asylum/puzzles/puzzle.cpp
@@ -27,21 +27,16 @@
#include "asylum/resources/worldstats.h"
-#include "asylum/system/config.h"
#include "asylum/system/cursor.h"
#include "asylum/system/graphics.h"
-#include "asylum/system/screen.h"
-#include "asylum/system/video.h"
#include "asylum/views/scene.h"
#include "asylum/asylum.h"
-#include "asylum/respack.h"
-#include "asylum/shared.h"
namespace Asylum {
-BlowUpPuzzle::BlowUpPuzzle(AsylumEngine *engine): _vm(engine), _ev(NULL),
+BlowUpPuzzle::BlowUpPuzzle(AsylumEngine *engine): _vm(engine),
_leftClickUp(false), _leftClickDown(false), _rightClickDown(false), _active(false) {
// setup cursor & background
@@ -49,562 +44,12 @@ BlowUpPuzzle::BlowUpPuzzle(AsylumEngine *engine): _vm(engine), _ev(NULL),
_bgResource = new GraphicResource(_vm, getWorld()->graphicResourceIds[0]);
}
-
BlowUpPuzzle::~BlowUpPuzzle() {
delete _cursor;
delete _bgResource;
// Zero passed pointers
_vm = NULL;
- _ev = NULL;
-}
-
-// BlowUp Puzzle VCR ---------------------------------------------------------------------------------------------
-
-BlowUpPuzzleVCR::BlowUpPuzzleVCR(AsylumEngine *engine): BlowUpPuzzle(engine) {
- // reset all states
- memset(&_jacksState, 0, sizeof(_jacksState));
- memset(&_holesState, 0, sizeof(_holesState));
- memset(&_buttonsState, 0, sizeof(_buttonsState));
-
- _tvScreenAnimIdx = 0;
- _isAccomplished = false;
-}
-
-BlowUpPuzzleVCR::~BlowUpPuzzleVCR() {
- delete _cursor;
- delete _bgResource;
-}
-
-void BlowUpPuzzleVCR::openBlowUp() {
- _active = true;
- getScene()->deactivate();
-
- getSound()->stopAll();
-
- // Load the graphics palette
- getScreen()->setPalette(getWorld()->graphicResourceIds[29]);
-
- // show blow up puzzle BG
- GraphicFrame *bg = _bgResource->getFrame(0);
- getScreen()->copyToBackBuffer((byte *)bg->surface.pixels, bg->surface.w, 0, 0, bg->surface.w, bg->surface.h);
-
- // Set mouse cursor
- _cursor->set(getWorld()->graphicResourceIds[28], 0, 2);
- _cursor->show();
-
- _leftClickUp = false;
- _leftClickDown = false;
- _rightClickDown = false;
-}
-
-void BlowUpPuzzleVCR::closeBlowUp() {
- _active = false;
- getScene()->activate();
-}
-
-void BlowUpPuzzleVCR::handleEvent(Common::Event *event, bool doUpdate) {
- _ev = event;
-
- switch (_ev->type) {
- case Common::EVENT_MOUSEMOVE:
- _cursor->move(_ev->mouse.x, _ev->mouse.y);
- break;
- case Common::EVENT_LBUTTONUP:
- _leftClickUp = true;
- break;
- case Common::EVENT_LBUTTONDOWN:
- _leftClickDown = true;
- break;
- case Common::EVENT_RBUTTONDOWN:
- _rightClickDown = true;
- break;
- default:
- break;
- }
-
- if (doUpdate || _leftClickUp || _leftClickDown)
- update();
-}
-
-void BlowUpPuzzle::playSound(ResourceId resourceId, bool loop) {
- getSound()->playSound(resourceId, loop, Config.sfxVolume, 0);
-}
-
-int BlowUpPuzzleVCR::inPolyRegion(int x, int y, int polyIdx) const {
- return x >= BlowUpPuzzleVCRPolies[polyIdx].left && x <= BlowUpPuzzleVCRPolies[polyIdx].right &&
- y >= BlowUpPuzzleVCRPolies[polyIdx].top && y <= BlowUpPuzzleVCRPolies[polyIdx].bottom;
-}
-
-void BlowUpPuzzleVCR::update() {
- getScreen()->clearGraphicsInQueue();
-
- if (_rightClickDown) { // quits BlowUp Puzzle
- _rightClickDown = false;
- closeBlowUp();
- getSound()->stopAll();
- }
-
- if (_leftClickDown) {
- _leftClickDown = false;
- handleMouseDown();
- }
-
- if (_leftClickUp) {
- _leftClickUp = false;
- handleMouseUp();
- }
-
- updateCursorInPolyRegion();
-
- updateBlackJack();
- updateRedJack();
- updateYellowJack();
-
- updatePowerButton();
- updateRewindButton();
- updatePlayButton();
- updateStopButton();
-
- if (_buttonsState[kPower] == kON) {
- getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[22], _tvScreenAnimIdx, Common::Point(0, 37), 0, 0, 1);
- getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[23], _tvScreenAnimIdx++, Common::Point(238, 22), 0, 0, 1);
- _tvScreenAnimIdx %= 6;
- }
-
- if (_isAccomplished) {
- getScreen()->drawGraphicsInQueue();
-
- int16 barSize = 0;
- do {
- getScreen()->drawWideScreen(barSize);
- barSize += 4;
- } while (barSize < 84);
-
- // TODO: fade palette to gray
-
- getVideo()->playVideo(2, true);
-
- _isAccomplished = false;
- closeBlowUp();
- } else {
- getScreen()->drawGraphicsInQueue();
- }
-}
-
-GraphicQueueItem BlowUpPuzzleVCR::getGraphicJackItem(int32 index) {
- GraphicQueueItem jackItemOnHand;
-
- int jackY = _cursor->position().y;
- if (_cursor->position().y < 356) {
- jackY = 356;
- }
-
- jackItemOnHand.resourceId = getWorld()->graphicResourceIds[index];
- jackItemOnHand.frameIndex = 0;
- jackItemOnHand.point = Common::Point(_cursor->position().x - 114, jackY - 14);
- jackItemOnHand.priority = 1;
-
- return jackItemOnHand;
-}
-
-GraphicQueueItem BlowUpPuzzleVCR::getGraphicShadowItem() {
- GraphicQueueItem shadowItem;
-
- int shadowY = (_cursor->position().y - 356) / 4;
- if (_cursor->position().y < 356) {
- shadowY = 0;
- }
- shadowItem.resourceId = getWorld()->graphicResourceIds[30];
- shadowItem.frameIndex = 0;
- shadowItem.point = Common::Point(_cursor->position().x - shadowY, 450);
- shadowItem.priority = 2;
-
- return shadowItem;
-}
-
-void BlowUpPuzzleVCR::updateJack(Jack jack, const VCRDrawInfo &onTable, const VCRDrawInfo &pluggedOnRed, const VCRDrawInfo &pluggedOnYellow, const VCRDrawInfo &pluggedOnBlack, int32 resourceOnHandIndex) {
- GraphicQueueItem item;
-
- switch (_jacksState[jack]) {
- case kOnTable:
- item.resourceId = getWorld()->graphicResourceIds[onTable.resourceId];
- item.frameIndex = 0;
- item.point = onTable.point;
- item.priority = 3;
- break;
-
- case kPluggedOnRed:
- item.resourceId = getWorld()->graphicResourceIds[pluggedOnRed.resourceId];
- item.frameIndex = 0;
- item.point = Common::Point(329, 407);
- item.priority = 3;
- break;
-
- case kPluggedOnYellow:
- item.resourceId = getWorld()->graphicResourceIds[pluggedOnYellow.resourceId];
- item.frameIndex = 0;
- item.point = Common::Point(402, 413);
- item.priority = 3;
- break;
-
- case kPluggedOnBlack:
- item.resourceId = getWorld()->graphicResourceIds[pluggedOnBlack.resourceId];
- item.frameIndex = 0;
- item.point = Common::Point(477, 418);
- item.priority = 3;
- break;
-
- case kOnHand: {
- GraphicQueueItem jackItemOnHand = getGraphicJackItem(resourceOnHandIndex);
- getScreen()->addGraphicToQueue(jackItemOnHand);
-
- item = getGraphicShadowItem();
- }
- break;
-
- default:
- item.resourceId = kResourceNone;
- break;
- }
-
- if (item.resourceId != 0)
- getScreen()->addGraphicToQueue(item);
-}
-
-void BlowUpPuzzleVCR::updateBlackJack() {
- VCRDrawInfo onTable;
- onTable.resourceId = 1;
- onTable.point = Common::Point(0, 411);
-
- VCRDrawInfo pluggedOnRed;
- pluggedOnRed.resourceId = 5;
-
- VCRDrawInfo pluggedOnYellow;
- pluggedOnYellow.resourceId = 8;
-
- VCRDrawInfo pluggedOnBlack;
- pluggedOnBlack.resourceId = 11;
-
- updateJack(kBlack, onTable, pluggedOnRed, pluggedOnYellow, pluggedOnBlack, 27);
-}
-
-void BlowUpPuzzleVCR::updateRedJack() {
- VCRDrawInfo onTable;
- onTable.resourceId = 2;
- onTable.point = Common::Point(76, 428);
-
- VCRDrawInfo pluggedOnRed;
- pluggedOnRed.resourceId = 4;
-
- VCRDrawInfo pluggedOnYellow;
- pluggedOnYellow.resourceId = 7;
-
- VCRDrawInfo pluggedOnBlack;
- pluggedOnBlack.resourceId = 10;
-
- updateJack(kRed, onTable, pluggedOnRed, pluggedOnYellow, pluggedOnBlack, 25);
-}
-
-void BlowUpPuzzleVCR::updateYellowJack() {
- VCRDrawInfo onTable;
- onTable.resourceId = 3;
- onTable.point = Common::Point(187, 439);
-
- VCRDrawInfo pluggedOnRed;
- pluggedOnRed.resourceId = 6;
-
- VCRDrawInfo pluggedOnYellow;
- pluggedOnYellow.resourceId = 9;
-
- VCRDrawInfo pluggedOnBlack;
- pluggedOnBlack.resourceId = 12;
-
- updateJack(kYellow, onTable, pluggedOnRed, pluggedOnYellow, pluggedOnBlack, 26);
-}
-
-
-// common function to set and unset the jack on holes for each type of jack
-int BlowUpPuzzleVCR::setJackOnHole(int jackType, JackState plugged) {
- if (!_holesState[plugged-1]) {
- if (_jacksState[jackType-1] == kOnHand) {
- _jacksState[jackType-1] = plugged;
- _holesState[plugged-1] = jackType; // set jack on red
- playSound(getWorld()->graphicResourceIds[44]);
- }
- } else if (jackType == 0) {
- jackType = _holesState[plugged-1];
- _jacksState[jackType-1] = kOnHand;
- _holesState[plugged-1] = 0;
- playSound(getWorld()->graphicResourceIds[43]);
- return 0;
- }
- return 1;
-}
-
-void BlowUpPuzzleVCR::updateButton(Button button, const VCRDrawInfo &btON, const VCRDrawInfo &btDown) {
- GraphicQueueItem item;
-
- switch (_buttonsState[button]) {
- case kON:
- item.resourceId = getWorld()->graphicResourceIds[btON.resourceId];
- item.frameIndex = 0;
- item.point = btON.point;
- item.priority = 3;
- break;
- case kDownON:
- case kDownOFF:
- item.resourceId = getWorld()->graphicResourceIds[btDown.resourceId];
- item.frameIndex = 0;
- item.point = btDown.point;
- item.priority = 3;
- break;
- default:
- item.resourceId = kResourceNone;
- break;
- }
-
- if (item.resourceId != 0)
- getScreen()->addGraphicToQueue(item);
-
-}
-
-void BlowUpPuzzleVCR::updatePowerButton() {
- VCRDrawInfo btON;
- btON.resourceId = 17;
- btON.point = Common::Point(512, 347);
-
- VCRDrawInfo btDown;
- btDown.resourceId = 21;
- btDown.point = Common::Point(506, 343);
-
- updateButton(kPower, btON, btDown);
-}
-
-void BlowUpPuzzleVCR::updateRewindButton() {
- VCRDrawInfo btON;
- btON.resourceId = 14;
- btON.point = Common::Point(248, 347);
-
- VCRDrawInfo btDown;
- btDown.resourceId = 18;
- btDown.point = Common::Point(245, 344);
-
- updateButton(kRewind, btON, btDown);
-}
-
-void BlowUpPuzzleVCR::updatePlayButton() {
- VCRDrawInfo btON;
- btON.resourceId = 16;
- btON.point = Common::Point(401, 359);
-
- VCRDrawInfo btDown;
- btDown.resourceId = 20;
- btDown.point = Common::Point(391, 355);
-
- updateButton(kPlay, btON, btDown);
-}
-
-void BlowUpPuzzleVCR::updateStopButton() {
- VCRDrawInfo btON;
- btON.resourceId = 15;
- btON.point = Common::Point(330, 354);
-
- VCRDrawInfo btDown;
- btDown.resourceId = 19;
- btDown.point = Common::Point(326, 350);
-
- updateButton(kStop, btON, btDown);
-}
-
-
-void BlowUpPuzzleVCR::updateCursorInPolyRegion() {
- int showCursor = 0;
-
- if (_jacksState[kBlack] == kOnHand) {
- showCursor = kBlack + 1;
- } else if (_jacksState[kRed] == kOnHand) {
- showCursor = kRed + 1;
- } else {
- showCursor = ((_jacksState[kYellow] != kOnHand) - 1) & 3;
- }
-
- if (!showCursor) {
- if (inPolyRegion(_cursor->position().x, _cursor->position().y, kRewindButton)
- || inPolyRegion(_cursor->position().x, _cursor->position().y, kStopButton)
- || inPolyRegion(_cursor->position().x, _cursor->position().y, kPlayButton)
- || inPolyRegion(_cursor->position().x, _cursor->position().y, kPowerButton)
- || inPolyRegion(_cursor->position().x, _cursor->position().y, kBlackJack)
- || inPolyRegion(_cursor->position().x, _cursor->position().y, kRedJack)
- || inPolyRegion(_cursor->position().x, _cursor->position().y, kYellowJack)) {
- _cursor->animate();
- } else {
- if ((inPolyRegion(_cursor->position().x, _cursor->position().y, kRedHole) && _holesState[kOnTable])
- || (inPolyRegion(_cursor->position().x, _cursor->position().y, kYellowHole) && _holesState[kPluggedOnRed])
- || (inPolyRegion(_cursor->position().x, _cursor->position().y, kBlackHole) && _holesState[kPluggedOnYellow])) {
- if (_cursor->currentFrame != 2) { // reset cursor
- _cursor->show();
- _cursor->set(MAKE_RESOURCE(kResourcePackShared, 2), 0, 2);
- _cursor->animate();
- }
- } else {
- if (_cursor->currentFrame != 0) { // reset cursor
- _cursor->show();
- _cursor->set(MAKE_RESOURCE(kResourcePackShared, 0), 0, 2);
- _cursor->animate();
- }
- }
- }
- } else {
- _cursor->hide();
- }
-}
-
-void BlowUpPuzzleVCR::handleMouseDown() {
-
- if (_isAccomplished)
- return;
-
- int jackType = 0;
- if (_jacksState[kBlack] == kOnHand) {
- jackType = kBlack + 1;
- } else if (_jacksState[kRed] == kOnHand) {
- jackType = kRed + 1;
- } else {
- jackType = ((_jacksState[kYellow] != kOnHand) - 1) & 3;
- }
-
- // Plug-in jacks
- if (inPolyRegion(_cursor->position().x, _cursor->position().y, kRedHole)) {
- if (!setJackOnHole(jackType, kPluggedOnRed)) {
- return;
- }
- }
- if (inPolyRegion(_cursor->position().x, _cursor->position().y, kYellowHole)) {
- if (!setJackOnHole(jackType, kPluggedOnYellow)) {
- return;
- }
- }
- if (inPolyRegion(_cursor->position().x, _cursor->position().y, kBlackHole)) {
- if (!setJackOnHole(jackType, kPluggedOnBlack)) {
- // TODO: this will probably segfault!
- error("[BlowUpPuzzleVCR::handleMouseDown] Not implemented!");
- /*if (_holesState[kBlackHole] != kPluggedOnYellow && _buttonsState[kPower] == 1) {
- _buttonsState[kPower] = kOFF;
- _buttonsState[kStop] = kOFF;
- _buttonsState[kPlay] = kOFF;
- _buttonsState[kRewind] = kOFF;
- }
- return;*/
- }
- }
-
- // Put jacks on table --
- if (jackType) {
- if (_cursor->position().x >= (int32)BlowUpPuzzleVCRPolies[kBlackJack].left && _cursor->position().x <= (int32)BlowUpPuzzleVCRPolies[kYellowJack].right
- && _cursor->position().y >= (int32)BlowUpPuzzleVCRPolies[kBlackJack].top && _cursor->position().y <= (int32)BlowUpPuzzleVCRPolies[kYellowJack].bottom) {
-
- _jacksState[jackType-1] = kOnTable;
- playSound(getWorld()->graphicResourceIds[50]);
- _cursor->show();
- }
- return;
- }
-
- // Get Jacks from Table
- if (inPolyRegion(_cursor->position().x, _cursor->position().y, kBlackJack)) {
- _jacksState[kBlack] = kOnHand;
- } else if (inPolyRegion(_cursor->position().x, _cursor->position().y, kRedJack)) {
- _jacksState[kRed] = kOnHand;
- } else if (inPolyRegion(_cursor->position().x, _cursor->position().y, kYellowJack)) {
- _jacksState[kYellow] = kOnHand;
- }
-
- // VCR button regions
- if (inPolyRegion(_cursor->position().x, _cursor->position().y, kRewindButton)) {
- playSound(getWorld()->graphicResourceIds[39]);
- if (!_buttonsState[kRewind]) {
- _buttonsState[kRewind] = kDownON;
- return;
- }
- if (_buttonsState[kRewind] == kON) {
- _buttonsState[kRewind] = kDownOFF;
- return;
- }
- } else if (inPolyRegion(_cursor->position().x, _cursor->position().y, kPlayButton)) {
- playSound(getWorld()->graphicResourceIds[39]);
- if (!_buttonsState[kPlay]) {
- _buttonsState[kPlay] = kDownON;
- return;
- }
- if (_buttonsState[kPlay] == kON) {
- _buttonsState[kPlay] = kDownOFF;
- return;
- }
- } else if (inPolyRegion(_cursor->position().x, _cursor->position().y, kStopButton)) {
- playSound(getWorld()->graphicResourceIds[39]);
- if (_buttonsState[kStop]) {
- if (_buttonsState[kStop] == kON) {
- _buttonsState[kStop] = kDownOFF;
- return;
- }
- } else {
- _buttonsState[kStop] = kDownON;
- return;
- }
- } else if (inPolyRegion(_cursor->position().x, _cursor->position().y, kPowerButton)) {
- playSound(getWorld()->graphicResourceIds[39]);
-
- if (!_buttonsState[kPower] && _holesState[kPluggedOnYellow] == kRed && _holesState[kOnTable] && _holesState[kPluggedOnRed]) {
- _buttonsState[kPower] = kDownON;
- } else {
- _buttonsState[kPower] = kDownOFF;
- }
- }
-}
-
-void BlowUpPuzzleVCR::handleMouseUp() {
- if (_isAccomplished)
- return;
-
- if (_buttonsState[kPower] == kDownON) {
- playSound(getWorld()->graphicResourceIds[47], true);
- _buttonsState[kPower] = kON;
- _buttonsState[kStop] = kON;
- _buttonsState[kPlay] = kON;
- _buttonsState[kRewind] = kON;
- } else if (_buttonsState[kPower] == kDownOFF) {
- _buttonsState[kPower] = kOFF;
- _buttonsState[kStop] = kOFF;
- _buttonsState[kPlay] = kOFF;
- _buttonsState[kRewind] = kOFF;
- getSound()->stopAll();
- }
-
- if (_buttonsState[kRewind] == kDownOFF) {
- _buttonsState[kRewind] = kON;
- playSound(getWorld()->graphicResourceIds[46]);
- } else if (_buttonsState[kRewind] == kDownON) {
- _buttonsState[kRewind] = kOFF;
- }
-
- if (_buttonsState[kPlay] == kDownOFF) {
- _buttonsState[kPlay] = kON;
- if (_holesState[kOnTable] == kYellow && _holesState[kPluggedOnRed] == kYellow + 1 /*FIXME this is not a proper value */ && _holesState[kPluggedOnYellow] == kRed) {
- _vm->setGameFlag(kGameFlagSolveVCRBlowUpPuzzle);
- _isAccomplished = true;
- }
- } else if (_buttonsState[kPlay] == kDownON) {
- _buttonsState[kPlay] = kOFF;
- }
-
- if (_buttonsState[kStop] == kDownOFF) {
- _buttonsState[kStop] = kON;
- return;
- }
- if (_buttonsState[kStop] == kDownON) {
- _buttonsState[kStop] = kOFF;
- }
}
} // end of namespace Asylum
diff --git a/engines/asylum/puzzles/puzzle.h b/engines/asylum/puzzles/puzzle.h
index 39245a5f59..6548ad95e7 100644
--- a/engines/asylum/puzzles/puzzle.h
+++ b/engines/asylum/puzzles/puzzle.h
@@ -23,12 +23,12 @@
*
*/
-#ifndef ASYLUM_BLOWUPPUZZLE_H
-#define ASYLUM_BLOWUPPUZZLE_H
+#ifndef ASYLUM_PUZZLE_H
+#define ASYLUM_PUZZLE_H
+#include "asylum/eventhandler.h"
#include "asylum/shared.h"
-#include "common/events.h"
#include "common/rect.h"
namespace Asylum {
@@ -46,17 +46,15 @@ public:
BlowUpPuzzle(AsylumEngine *engine);
virtual ~BlowUpPuzzle();
- virtual void handleEvent(Common::Event *event, bool doUpdate) {};
- virtual void openBlowUp() {};
- virtual void closeBlowUp() {};
+ virtual void handleEvent(const AsylumEvent &event, bool doUpdate) = 0;
+ virtual void open() = 0;
+ virtual void close() = 0;
bool isActive() { return _active; }
protected:
AsylumEngine *_vm;
- Common::Event *_ev;
-
Cursor *_cursor;
GraphicResource *_bgResource;
@@ -67,112 +65,8 @@ protected:
virtual void update() {};
void playSound(ResourceId resourceId, bool loop = false);
-
-}; // end of class BlowUpPuzzle
-
-
-// ---- VCR -------------------
-
-typedef struct VCRDrawInfo {
- int32 resourceId;
- Common::Point point;
-} VCRDrawInfo;
-
-const Common::Rect BlowUpPuzzleVCRPolies[10] = {
- Common::Rect(0x0F7, 0x157, 0x13A, 0x183), // rewind button region
- Common::Rect(0x14B, 0x15C, 0x17B, 0x18B), // stop button region
- Common::Rect(0x18C, 0x161, 0x1D2, 0x18F), // play button region
- Common::Rect(0x1FB, 0x156, 0x233, 0x185), // rec button region
- Common::Rect(0x154, 0x196, 0x173, 0x1AF), // red jack hole region
- Common::Rect(0x19A, 0x19B, 0x1B9, 0x1B3), // yellow jack hole region
- Common::Rect(0x1E3, 0x1A0, 0x202, 0x1BC), // black jack hole region
- Common::Rect(0x0, 0x19B, 0x3C, 0x1E0), // black jack on table region
- Common::Rect(0x4C, 0x1AC, 0x0A0, 0x1E0), // red jack on table region
- Common::Rect(0x0BB, 0x1B7, 0x0F0, 0x1E0) // yellow jack on table region
};
-class BlowUpPuzzleVCR : public BlowUpPuzzle {
-public:
- BlowUpPuzzleVCR(AsylumEngine *engine);
- ~BlowUpPuzzleVCR();
-
- void handleEvent(Common::Event *event, bool doUpdate);
- void openBlowUp();
- void closeBlowUp();
-private:
- enum Jack {
- kBlack = 0,
- kRed = 1,
- kYellow = 2
- };
-
- enum JackState {
- kOnTable = 0,
- kPluggedOnRed = 1,
- kPluggedOnYellow = 2,
- kPluggedOnBlack = 3,
- kOnHand = 4
- };
-
- enum VCRRegions {
- kRewindButton = 0,
- kStopButton = 1,
- kPlayButton = 2,
- kPowerButton = 3,
- kRedHole = 4,
- kYellowHole = 5,
- kBlackHole = 6,
- kBlackJack = 7,
- kRedJack = 8,
- kYellowJack = 9
- };
-
- enum Button {
- kRewind = 0,
- kStop = 1,
- kPlay = 2,
- kPower = 3
- };
-
- enum ButtonState {
- kOFF = 0,
- kON = 1,
- kDownON = 2,
- kDownOFF = 3
- };
-
- int _jacksState[3];
- int _holesState[3];
- int _buttonsState[4];
- uint32 _tvScreenAnimIdx;
- bool _isAccomplished;
-
- int inPolyRegion(int x, int y, int polyIdx) const;
-
- void update();
-
- void updateCursorInPolyRegion();
-
- GraphicQueueItem getGraphicJackItem(int32 index);
- GraphicQueueItem getGraphicShadowItem();
- void updateJack(Jack jack, const VCRDrawInfo &onTable, const VCRDrawInfo &pluggedOnRed, const VCRDrawInfo &pluggedOnYellow, const VCRDrawInfo &pluggedOnBlack, int32 resourceOnHandIndex);
- void updateBlackJack();
- void updateRedJack();
- void updateYellowJack();
- int setJackOnHole(int jackType, JackState plugged);
-
- void updateButton(Button button, const VCRDrawInfo &btON, const VCRDrawInfo &btDown);
- void updatePowerButton();
- void updateRewindButton();
- void updatePlayButton();
- void updateStopButton();
-
- void updateTVSync();
-
- void handleMouseDown();
- void handleMouseUp();
-}; // end of class BlowUpPuzzleVCR
-
-} // end of namespace Asylum
-
-#endif
+} // End of namespace Asylum
+
+#endif // ASYLUM_PUZZLE_H
diff --git a/engines/asylum/puzzles/vcr.cpp b/engines/asylum/puzzles/vcr.cpp
new file mode 100644
index 0000000000..db33bc5531
--- /dev/null
+++ b/engines/asylum/puzzles/vcr.cpp
@@ -0,0 +1,588 @@
+/* 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.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#include "asylum/puzzles/vcr.h"
+
+#include "asylum/resources/worldstats.h"
+
+#include "asylum/system/config.h"
+#include "asylum/system/cursor.h"
+#include "asylum/system/graphics.h"
+#include "asylum/system/screen.h"
+#include "asylum/system/video.h"
+
+#include "asylum/views/scene.h"
+
+#include "asylum/asylum.h"
+#include "asylum/respack.h"
+#include "asylum/shared.h"
+
+namespace Asylum {
+
+BlowUpPuzzleVCR::BlowUpPuzzleVCR(AsylumEngine *engine): BlowUpPuzzle(engine) {
+ // reset all states
+ memset(&_jacksState, 0, sizeof(_jacksState));
+ memset(&_holesState, 0, sizeof(_holesState));
+ memset(&_buttonsState, 0, sizeof(_buttonsState));
+
+ _tvScreenAnimIdx = 0;
+ _isAccomplished = false;
+}
+
+BlowUpPuzzleVCR::~BlowUpPuzzleVCR() {
+ delete _cursor;
+ delete _bgResource;
+}
+
+void BlowUpPuzzleVCR::open() {
+ _active = true;
+ getScene()->deactivate();
+
+ getSound()->stopAll();
+
+ // Load the graphics palette
+ getScreen()->setPalette(getWorld()->graphicResourceIds[29]);
+
+ // show blow up puzzle BG
+ GraphicFrame *bg = _bgResource->getFrame(0);
+ getScreen()->copyToBackBuffer((byte *)bg->surface.pixels, bg->surface.w, 0, 0, bg->surface.w, bg->surface.h);
+
+ // Set mouse cursor
+ _cursor->set(getWorld()->graphicResourceIds[28], 0, 2);
+ _cursor->show();
+
+ _leftClickUp = false;
+ _leftClickDown = false;
+ _rightClickDown = false;
+}
+
+void BlowUpPuzzleVCR::close() {
+ _active = false;
+ getScene()->activate();
+}
+
+void BlowUpPuzzleVCR::handleEvent(const AsylumEvent &ev, bool doUpdate) {
+ switch (ev.type) {
+ case Common::EVENT_MOUSEMOVE:
+ _cursor->move(ev.mouse.x, ev.mouse.y);
+ break;
+ case Common::EVENT_LBUTTONUP:
+ _leftClickUp = true;
+ break;
+ case Common::EVENT_LBUTTONDOWN:
+ _leftClickDown = true;
+ break;
+ case Common::EVENT_RBUTTONDOWN:
+ _rightClickDown = true;
+ break;
+ default:
+ break;
+ }
+
+ if (doUpdate || _leftClickUp || _leftClickDown)
+ update();
+}
+
+void BlowUpPuzzle::playSound(ResourceId resourceId, bool loop) {
+ getSound()->playSound(resourceId, loop, Config.sfxVolume, 0);
+}
+
+int BlowUpPuzzleVCR::inPolyRegion(int x, int y, int polyIdx) const {
+ return x >= BlowUpPuzzleVCRPolies[polyIdx].left && x <= BlowUpPuzzleVCRPolies[polyIdx].right &&
+ y >= BlowUpPuzzleVCRPolies[polyIdx].top && y <= BlowUpPuzzleVCRPolies[polyIdx].bottom;
+}
+
+void BlowUpPuzzleVCR::update() {
+ getScreen()->clearGraphicsInQueue();
+
+ if (_rightClickDown) { // quits BlowUp Puzzle
+ _rightClickDown = false;
+ close();
+ getSound()->stopAll();
+ }
+
+ if (_leftClickDown) {
+ _leftClickDown = false;
+ handleMouseDown();
+ }
+
+ if (_leftClickUp) {
+ _leftClickUp = false;
+ handleMouseUp();
+ }
+
+ updateCursorInPolyRegion();
+
+ updateBlackJack();
+ updateRedJack();
+ updateYellowJack();
+
+ updatePowerButton();
+ updateRewindButton();
+ updatePlayButton();
+ updateStopButton();
+
+ if (_buttonsState[kPower] == kON) {
+ getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[22], _tvScreenAnimIdx, Common::Point(0, 37), 0, 0, 1);
+ getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[23], _tvScreenAnimIdx++, Common::Point(238, 22), 0, 0, 1);
+ _tvScreenAnimIdx %= 6;
+ }
+
+ if (_isAccomplished) {
+ getScreen()->drawGraphicsInQueue();
+
+ int16 barSize = 0;
+ do {
+ getScreen()->drawWideScreen(barSize);
+ barSize += 4;
+ } while (barSize < 84);
+
+ // TODO: fade palette to gray
+
+ getVideo()->playVideo(2, true);
+
+ _isAccomplished = false;
+ close();
+ } else {
+ getScreen()->drawGraphicsInQueue();
+ }
+}
+
+GraphicQueueItem BlowUpPuzzleVCR::getGraphicJackItem(int32 index) {
+ GraphicQueueItem jackItemOnHand;
+
+ int jackY = _cursor->position().y;
+ if (_cursor->position().y < 356) {
+ jackY = 356;
+ }
+
+ jackItemOnHand.resourceId = getWorld()->graphicResourceIds[index];
+ jackItemOnHand.frameIndex = 0;
+ jackItemOnHand.point = Common::Point(_cursor->position().x - 114, jackY - 14);
+ jackItemOnHand.priority = 1;
+
+ return jackItemOnHand;
+}
+
+GraphicQueueItem BlowUpPuzzleVCR::getGraphicShadowItem() {
+ GraphicQueueItem shadowItem;
+
+ int shadowY = (_cursor->position().y - 356) / 4;
+ if (_cursor->position().y < 356) {
+ shadowY = 0;
+ }
+ shadowItem.resourceId = getWorld()->graphicResourceIds[30];
+ shadowItem.frameIndex = 0;
+ shadowItem.point = Common::Point(_cursor->position().x - shadowY, 450);
+ shadowItem.priority = 2;
+
+ return shadowItem;
+}
+
+void BlowUpPuzzleVCR::updateJack(Jack jack, const VCRDrawInfo &onTable, const VCRDrawInfo &pluggedOnRed, const VCRDrawInfo &pluggedOnYellow, const VCRDrawInfo &pluggedOnBlack, int32 resourceOnHandIndex) {
+ GraphicQueueItem item;
+
+ switch (_jacksState[jack]) {
+ case kOnTable:
+ item.resourceId = getWorld()->graphicResourceIds[onTable.resourceId];
+ item.frameIndex = 0;
+ item.point = onTable.point;
+ item.priority = 3;
+ break;
+
+ case kPluggedOnRed:
+ item.resourceId = getWorld()->graphicResourceIds[pluggedOnRed.resourceId];
+ item.frameIndex = 0;
+ item.point = Common::Point(329, 407);
+ item.priority = 3;
+ break;
+
+ case kPluggedOnYellow:
+ item.resourceId = getWorld()->graphicResourceIds[pluggedOnYellow.resourceId];
+ item.frameIndex = 0;
+ item.point = Common::Point(402, 413);
+ item.priority = 3;
+ break;
+
+ case kPluggedOnBlack:
+ item.resourceId = getWorld()->graphicResourceIds[pluggedOnBlack.resourceId];
+ item.frameIndex = 0;
+ item.point = Common::Point(477, 418);
+ item.priority = 3;
+ break;
+
+ case kOnHand: {
+ GraphicQueueItem jackItemOnHand = getGraphicJackItem(resourceOnHandIndex);
+ getScreen()->addGraphicToQueue(jackItemOnHand);
+
+ item = getGraphicShadowItem();
+ }
+ break;
+
+ default:
+ item.resourceId = kResourceNone;
+ break;
+ }
+
+ if (item.resourceId != 0)
+ getScreen()->addGraphicToQueue(item);
+}
+
+void BlowUpPuzzleVCR::updateBlackJack() {
+ VCRDrawInfo onTable;
+ onTable.resourceId = 1;
+ onTable.point = Common::Point(0, 411);
+
+ VCRDrawInfo pluggedOnRed;
+ pluggedOnRed.resourceId = 5;
+
+ VCRDrawInfo pluggedOnYellow;
+ pluggedOnYellow.resourceId = 8;
+
+ VCRDrawInfo pluggedOnBlack;
+ pluggedOnBlack.resourceId = 11;
+
+ updateJack(kBlack, onTable, pluggedOnRed, pluggedOnYellow, pluggedOnBlack, 27);
+}
+
+void BlowUpPuzzleVCR::updateRedJack() {
+ VCRDrawInfo onTable;
+ onTable.resourceId = 2;
+ onTable.point = Common::Point(76, 428);
+
+ VCRDrawInfo pluggedOnRed;
+ pluggedOnRed.resourceId = 4;
+
+ VCRDrawInfo pluggedOnYellow;
+ pluggedOnYellow.resourceId = 7;
+
+ VCRDrawInfo pluggedOnBlack;
+ pluggedOnBlack.resourceId = 10;
+
+ updateJack(kRed, onTable, pluggedOnRed, pluggedOnYellow, pluggedOnBlack, 25);
+}
+
+void BlowUpPuzzleVCR::updateYellowJack() {
+ VCRDrawInfo onTable;
+ onTable.resourceId = 3;
+ onTable.point = Common::Point(187, 439);
+
+ VCRDrawInfo pluggedOnRed;
+ pluggedOnRed.resourceId = 6;
+
+ VCRDrawInfo pluggedOnYellow;
+ pluggedOnYellow.resourceId = 9;
+
+ VCRDrawInfo pluggedOnBlack;
+ pluggedOnBlack.resourceId = 12;
+
+ updateJack(kYellow, onTable, pluggedOnRed, pluggedOnYellow, pluggedOnBlack, 26);
+}
+
+
+// common function to set and unset the jack on holes for each type of jack
+int BlowUpPuzzleVCR::setJackOnHole(int jackType, JackState plugged) {
+ if (!_holesState[plugged-1]) {
+ if (_jacksState[jackType-1] == kOnHand) {
+ _jacksState[jackType-1] = plugged;
+ _holesState[plugged-1] = jackType; // set jack on red
+ playSound(getWorld()->graphicResourceIds[44]);
+ }
+ } else if (jackType == 0) {
+ jackType = _holesState[plugged-1];
+ _jacksState[jackType-1] = kOnHand;
+ _holesState[plugged-1] = 0;
+ playSound(getWorld()->graphicResourceIds[43]);
+ return 0;
+ }
+ return 1;
+}
+
+void BlowUpPuzzleVCR::updateButton(Button button, const VCRDrawInfo &btON, const VCRDrawInfo &btDown) {
+ GraphicQueueItem item;
+
+ switch (_buttonsState[button]) {
+ case kON:
+ item.resourceId = getWorld()->graphicResourceIds[btON.resourceId];
+ item.frameIndex = 0;
+ item.point = btON.point;
+ item.priority = 3;
+ break;
+ case kDownON:
+ case kDownOFF:
+ item.resourceId = getWorld()->graphicResourceIds[btDown.resourceId];
+ item.frameIndex = 0;
+ item.point = btDown.point;
+ item.priority = 3;
+ break;
+ default:
+ item.resourceId = kResourceNone;
+ break;
+ }
+
+ if (item.resourceId != 0)
+ getScreen()->addGraphicToQueue(item);
+
+}
+
+void BlowUpPuzzleVCR::updatePowerButton() {
+ VCRDrawInfo btON;
+ btON.resourceId = 17;
+ btON.point = Common::Point(512, 347);
+
+ VCRDrawInfo btDown;
+ btDown.resourceId = 21;
+ btDown.point = Common::Point(506, 343);
+
+ updateButton(kPower, btON, btDown);
+}
+
+void BlowUpPuzzleVCR::updateRewindButton() {
+ VCRDrawInfo btON;
+ btON.resourceId = 14;
+ btON.point = Common::Point(248, 347);
+
+ VCRDrawInfo btDown;
+ btDown.resourceId = 18;
+ btDown.point = Common::Point(245, 344);
+
+ updateButton(kRewind, btON, btDown);
+}
+
+void BlowUpPuzzleVCR::updatePlayButton() {
+ VCRDrawInfo btON;
+ btON.resourceId = 16;
+ btON.point = Common::Point(401, 359);
+
+ VCRDrawInfo btDown;
+ btDown.resourceId = 20;
+ btDown.point = Common::Point(391, 355);
+
+ updateButton(kPlay, btON, btDown);
+}
+
+void BlowUpPuzzleVCR::updateStopButton() {
+ VCRDrawInfo btON;
+ btON.resourceId = 15;
+ btON.point = Common::Point(330, 354);
+
+ VCRDrawInfo btDown;
+ btDown.resourceId = 19;
+ btDown.point = Common::Point(326, 350);
+
+ updateButton(kStop, btON, btDown);
+}
+
+
+void BlowUpPuzzleVCR::updateCursorInPolyRegion() {
+ int showCursor = 0;
+
+ if (_jacksState[kBlack] == kOnHand) {
+ showCursor = kBlack + 1;
+ } else if (_jacksState[kRed] == kOnHand) {
+ showCursor = kRed + 1;
+ } else {
+ showCursor = ((_jacksState[kYellow] != kOnHand) - 1) & 3;
+ }
+
+ if (!showCursor) {
+ if (inPolyRegion(_cursor->position().x, _cursor->position().y, kRewindButton)
+ || inPolyRegion(_cursor->position().x, _cursor->position().y, kStopButton)
+ || inPolyRegion(_cursor->position().x, _cursor->position().y, kPlayButton)
+ || inPolyRegion(_cursor->position().x, _cursor->position().y, kPowerButton)
+ || inPolyRegion(_cursor->position().x, _cursor->position().y, kBlackJack)
+ || inPolyRegion(_cursor->position().x, _cursor->position().y, kRedJack)
+ || inPolyRegion(_cursor->position().x, _cursor->position().y, kYellowJack)) {
+ _cursor->animate();
+ } else {
+ if ((inPolyRegion(_cursor->position().x, _cursor->position().y, kRedHole) && _holesState[kOnTable])
+ || (inPolyRegion(_cursor->position().x, _cursor->position().y, kYellowHole) && _holesState[kPluggedOnRed])
+ || (inPolyRegion(_cursor->position().x, _cursor->position().y, kBlackHole) && _holesState[kPluggedOnYellow])) {
+ if (_cursor->currentFrame != 2) { // reset cursor
+ _cursor->show();
+ _cursor->set(MAKE_RESOURCE(kResourcePackShared, 2), 0, 2);
+ _cursor->animate();
+ }
+ } else {
+ if (_cursor->currentFrame != 0) { // reset cursor
+ _cursor->show();
+ _cursor->set(MAKE_RESOURCE(kResourcePackShared, 0), 0, 2);
+ _cursor->animate();
+ }
+ }
+ }
+ } else {
+ _cursor->hide();
+ }
+}
+
+void BlowUpPuzzleVCR::handleMouseDown() {
+
+ if (_isAccomplished)
+ return;
+
+ int jackType = 0;
+ if (_jacksState[kBlack] == kOnHand) {
+ jackType = kBlack + 1;
+ } else if (_jacksState[kRed] == kOnHand) {
+ jackType = kRed + 1;
+ } else {
+ jackType = ((_jacksState[kYellow] != kOnHand) - 1) & 3;
+ }
+
+ // Plug-in jacks
+ if (inPolyRegion(_cursor->position().x, _cursor->position().y, kRedHole)) {
+ if (!setJackOnHole(jackType, kPluggedOnRed)) {
+ return;
+ }
+ }
+ if (inPolyRegion(_cursor->position().x, _cursor->position().y, kYellowHole)) {
+ if (!setJackOnHole(jackType, kPluggedOnYellow)) {
+ return;
+ }
+ }
+ if (inPolyRegion(_cursor->position().x, _cursor->position().y, kBlackHole)) {
+ if (!setJackOnHole(jackType, kPluggedOnBlack)) {
+ // TODO: this will probably segfault!
+ error("[BlowUpPuzzleVCR::handleMouseDown] Not implemented!");
+ /*if (_holesState[kBlackHole] != kPluggedOnYellow && _buttonsState[kPower] == 1) {
+ _buttonsState[kPower] = kOFF;
+ _buttonsState[kStop] = kOFF;
+ _buttonsState[kPlay] = kOFF;
+ _buttonsState[kRewind] = kOFF;
+ }
+ return;*/
+ }
+ }
+
+ // Put jacks on table --
+ if (jackType) {
+ if (_cursor->position().x >= (int32)BlowUpPuzzleVCRPolies[kBlackJack].left && _cursor->position().x <= (int32)BlowUpPuzzleVCRPolies[kYellowJack].right
+ && _cursor->position().y >= (int32)BlowUpPuzzleVCRPolies[kBlackJack].top && _cursor->position().y <= (int32)BlowUpPuzzleVCRPolies[kYellowJack].bottom) {
+
+ _jacksState[jackType-1] = kOnTable;
+ playSound(getWorld()->graphicResourceIds[50]);
+ _cursor->show();
+ }
+ return;
+ }
+
+ // Get Jacks from Table
+ if (inPolyRegion(_cursor->position().x, _cursor->position().y, kBlackJack)) {
+ _jacksState[kBlack] = kOnHand;
+ } else if (inPolyRegion(_cursor->position().x, _cursor->position().y, kRedJack)) {
+ _jacksState[kRed] = kOnHand;
+ } else if (inPolyRegion(_cursor->position().x, _cursor->position().y, kYellowJack)) {
+ _jacksState[kYellow] = kOnHand;
+ }
+
+ // VCR button regions
+ if (inPolyRegion(_cursor->position().x, _cursor->position().y, kRewindButton)) {
+ playSound(getWorld()->graphicResourceIds[39]);
+ if (!_buttonsState[kRewind]) {
+ _buttonsState[kRewind] = kDownON;
+ return;
+ }
+ if (_buttonsState[kRewind] == kON) {
+ _buttonsState[kRewind] = kDownOFF;
+ return;
+ }
+ } else if (inPolyRegion(_cursor->position().x, _cursor->position().y, kPlayButton)) {
+ playSound(getWorld()->graphicResourceIds[39]);
+ if (!_buttonsState[kPlay]) {
+ _buttonsState[kPlay] = kDownON;
+ return;
+ }
+ if (_buttonsState[kPlay] == kON) {
+ _buttonsState[kPlay] = kDownOFF;
+ return;
+ }
+ } else if (inPolyRegion(_cursor->position().x, _cursor->position().y, kStopButton)) {
+ playSound(getWorld()->graphicResourceIds[39]);
+ if (_buttonsState[kStop]) {
+ if (_buttonsState[kStop] == kON) {
+ _buttonsState[kStop] = kDownOFF;
+ return;
+ }
+ } else {
+ _buttonsState[kStop] = kDownON;
+ return;
+ }
+ } else if (inPolyRegion(_cursor->position().x, _cursor->position().y, kPowerButton)) {
+ playSound(getWorld()->graphicResourceIds[39]);
+
+ if (!_buttonsState[kPower] && _holesState[kPluggedOnYellow] == kRed && _holesState[kOnTable] && _holesState[kPluggedOnRed]) {
+ _buttonsState[kPower] = kDownON;
+ } else {
+ _buttonsState[kPower] = kDownOFF;
+ }
+ }
+}
+
+void BlowUpPuzzleVCR::handleMouseUp() {
+ if (_isAccomplished)
+ return;
+
+ if (_buttonsState[kPower] == kDownON) {
+ playSound(getWorld()->graphicResourceIds[47], true);
+ _buttonsState[kPower] = kON;
+ _buttonsState[kStop] = kON;
+ _buttonsState[kPlay] = kON;
+ _buttonsState[kRewind] = kON;
+ } else if (_buttonsState[kPower] == kDownOFF) {
+ _buttonsState[kPower] = kOFF;
+ _buttonsState[kStop] = kOFF;
+ _buttonsState[kPlay] = kOFF;
+ _buttonsState[kRewind] = kOFF;
+ getSound()->stopAll();
+ }
+
+ if (_buttonsState[kRewind] == kDownOFF) {
+ _buttonsState[kRewind] = kON;
+ playSound(getWorld()->graphicResourceIds[46]);
+ } else if (_buttonsState[kRewind] == kDownON) {
+ _buttonsState[kRewind] = kOFF;
+ }
+
+ if (_buttonsState[kPlay] == kDownOFF) {
+ _buttonsState[kPlay] = kON;
+ if (_holesState[kOnTable] == kYellow && _holesState[kPluggedOnRed] == kYellow + 1 /*FIXME this is not a proper value */ && _holesState[kPluggedOnYellow] == kRed) {
+ _vm->setGameFlag(kGameFlagSolveVCRBlowUpPuzzle);
+ _isAccomplished = true;
+ }
+ } else if (_buttonsState[kPlay] == kDownON) {
+ _buttonsState[kPlay] = kOFF;
+ }
+
+ if (_buttonsState[kStop] == kDownOFF) {
+ _buttonsState[kStop] = kON;
+ return;
+ }
+ if (_buttonsState[kStop] == kDownON) {
+ _buttonsState[kStop] = kOFF;
+ }
+}
+
+} // end of namespace Asylum
diff --git a/engines/asylum/puzzles/vcr.h b/engines/asylum/puzzles/vcr.h
new file mode 100644
index 0000000000..caadf4c0ea
--- /dev/null
+++ b/engines/asylum/puzzles/vcr.h
@@ -0,0 +1,145 @@
+/* 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.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#ifndef ASYLUM_VCR_H
+#define ASYLUM_VCR_H
+
+#include "asylum/puzzles/puzzle.h"
+
+#include "asylum/shared.h"
+
+namespace Asylum {
+
+class AsylumEngine;
+//class Screen;
+//class Sound;
+//class Video;
+//class Cursor;
+//class GraphicResource;
+//struct GraphicQueueItem;
+
+typedef struct VCRDrawInfo {
+ int32 resourceId;
+ Common::Point point;
+} VCRDrawInfo;
+
+const Common::Rect BlowUpPuzzleVCRPolies[10] = {
+ Common::Rect(0x0F7, 0x157, 0x13A, 0x183), // rewind button region
+ Common::Rect(0x14B, 0x15C, 0x17B, 0x18B), // stop button region
+ Common::Rect(0x18C, 0x161, 0x1D2, 0x18F), // play button region
+ Common::Rect(0x1FB, 0x156, 0x233, 0x185), // rec button region
+ Common::Rect(0x154, 0x196, 0x173, 0x1AF), // red jack hole region
+ Common::Rect(0x19A, 0x19B, 0x1B9, 0x1B3), // yellow jack hole region
+ Common::Rect(0x1E3, 0x1A0, 0x202, 0x1BC), // black jack hole region
+ Common::Rect(0x0, 0x19B, 0x3C, 0x1E0), // black jack on table region
+ Common::Rect(0x4C, 0x1AC, 0x0A0, 0x1E0), // red jack on table region
+ Common::Rect(0x0BB, 0x1B7, 0x0F0, 0x1E0) // yellow jack on table region
+};
+
+class BlowUpPuzzleVCR : public BlowUpPuzzle {
+public:
+ BlowUpPuzzleVCR(AsylumEngine *engine);
+ ~BlowUpPuzzleVCR();
+
+ void handleEvent(const AsylumEvent &event, bool doUpdate);
+ void open();
+ void close();
+private:
+ enum Jack {
+ kBlack = 0,
+ kRed = 1,
+ kYellow = 2
+ };
+
+ enum JackState {
+ kOnTable = 0,
+ kPluggedOnRed = 1,
+ kPluggedOnYellow = 2,
+ kPluggedOnBlack = 3,
+ kOnHand = 4
+ };
+
+ enum VCRRegions {
+ kRewindButton = 0,
+ kStopButton = 1,
+ kPlayButton = 2,
+ kPowerButton = 3,
+ kRedHole = 4,
+ kYellowHole = 5,
+ kBlackHole = 6,
+ kBlackJack = 7,
+ kRedJack = 8,
+ kYellowJack = 9
+ };
+
+ enum Button {
+ kRewind = 0,
+ kStop = 1,
+ kPlay = 2,
+ kPower = 3
+ };
+
+ enum ButtonState {
+ kOFF = 0,
+ kON = 1,
+ kDownON = 2,
+ kDownOFF = 3
+ };
+
+ int _jacksState[3];
+ int _holesState[3];
+ int _buttonsState[4];
+ uint32 _tvScreenAnimIdx;
+ bool _isAccomplished;
+
+ int inPolyRegion(int x, int y, int polyIdx) const;
+
+ void update();
+
+ void updateCursorInPolyRegion();
+
+ GraphicQueueItem getGraphicJackItem(int32 index);
+ GraphicQueueItem getGraphicShadowItem();
+ void updateJack(Jack jack, const VCRDrawInfo &onTable, const VCRDrawInfo &pluggedOnRed, const VCRDrawInfo &pluggedOnYellow, const VCRDrawInfo &pluggedOnBlack, int32 resourceOnHandIndex);
+ void updateBlackJack();
+ void updateRedJack();
+ void updateYellowJack();
+ int setJackOnHole(int jackType, JackState plugged);
+
+ void updateButton(Button button, const VCRDrawInfo &btON, const VCRDrawInfo &btDown);
+ void updatePowerButton();
+ void updateRewindButton();
+ void updatePlayButton();
+ void updateStopButton();
+
+ void updateTVSync();
+
+ void handleMouseDown();
+ void handleMouseUp();
+};
+
+} // end of namespace Asylum
+
+#endif // ASYLUM_VCR_H
Commit: 7c179d025ec041792e76b655416b2a07758e4caa
https://github.com/scummvm/scummvm/commit/7c179d025ec041792e76b655416b2a07758e4caa
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:24+02:00
Commit Message:
ASYLUM: Enhance actions debug command slightly
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@582 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/console.cpp
diff --git a/engines/asylum/console.cpp b/engines/asylum/console.cpp
index caa12f5466..db05911b75 100644
--- a/engines/asylum/console.cpp
+++ b/engines/asylum/console.cpp
@@ -96,7 +96,7 @@ bool Console::cmdHelp(int, const char **) {
DebugPrintf(" ls - list engine files\n");
DebugPrintf("\n");
DebugPrintf(" actors - show actors information\n");
- DebugPrintf(" action - show action information\n");
+ DebugPrintf(" actions - show action information\n");
DebugPrintf(" flags - show flags\n");
DebugPrintf(" object - inspect a particular object\n");
DebugPrintf(" objects - show objects information\n");
@@ -148,6 +148,11 @@ bool Console::cmdListActions(int32 argc, const char **argv) {
int index = atoi(argv[1]);
int maxIndex = getWorld()->actions.size() - 1;
+ if (maxIndex == -1) {
+ DebugPrintf("[error] No actions are present!\n");
+ return true;
+ }
+
if (index < 0 || index > maxIndex) {
DebugPrintf("[error] index should be between 0 and %d\n", maxIndex);
return true;
Commit: a02af8db05164d79209e213f7e157c81848739ab
https://github.com/scummvm/scummvm/commit/a02af8db05164d79209e213f7e157c81848739ab
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:24+02:00
Commit Message:
ASYLUM: Implement Encounter::init and update Encounter::messageHandler
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@583 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/eventhandler.h
engines/asylum/resources/encounters.cpp
engines/asylum/resources/encounters.h
engines/asylum/system/speech.cpp
engines/asylum/system/speech.h
diff --git a/engines/asylum/eventhandler.h b/engines/asylum/eventhandler.h
index 421c3938be..78ace8e21c 100644
--- a/engines/asylum/eventhandler.h
+++ b/engines/asylum/eventhandler.h
@@ -45,10 +45,10 @@ struct AsylumEvent : public Common::Event {
}
};
-typedef Common::Functor1<const AsylumEvent &, void> MessageHandler;
+typedef Common::Functor1<const AsylumEvent &, bool> MessageHandler;
#define MESSAGE_HANDLER(class, name, inst) \
- Common::Functor1Mem<const AsylumEvent&, void, class>(inst, &class::name)
+ Common::Functor1Mem<const AsylumEvent&, bool, class>(inst, &class::name)
} // End of namespace Asylum
diff --git a/engines/asylum/resources/encounters.cpp b/engines/asylum/resources/encounters.cpp
index d38f08e656..dc826c2199 100644
--- a/engines/asylum/resources/encounters.cpp
+++ b/engines/asylum/resources/encounters.cpp
@@ -32,6 +32,7 @@
#include "asylum/system/cursor.h"
#include "asylum/system/speech.h"
+#include "asylum/system/text.h"
#include "asylum/views/scene.h"
@@ -46,6 +47,8 @@ Encounter::Encounter(AsylumEngine *engine) : _vm(engine),
_index(NULL), _keywordIndex(0), _item(NULL), _objectId1(kObjectNone), _objectId2(kObjectNone), _actorIndex(kActorInvalid),
_flag1(false), _flag2(false) {
+ // TODO init rest of members
+
_messageHandler = new MESSAGE_HANDLER(Encounter, messageHandler, this);
load();
@@ -54,6 +57,7 @@ Encounter::Encounter(AsylumEngine *engine) : _vm(engine),
Encounter::~Encounter() {
delete _messageHandler;
+ // Pointing to existing data
_item = NULL;
// Zero-out passed pointers
@@ -100,6 +104,22 @@ void Encounter::load() {
file.close();
}
+void Encounter::initData() {
+ error("[Encounter::initData] Not implemented!");
+}
+
+void Encounter::initCoordinates(){
+ error("[Encounter::initData] Not implemented!");
+}
+
+void Encounter::initPortrait(){
+ error("[Encounter::initData] Not implemented!");
+}
+
+void Encounter::initDrawStructs(){
+ error("[Encounter::initData] Not implemented!");
+}
+
uint32 Encounter::findKeyword(EncounterItem *item, int16 keyword) {
for (uint i = 0; i < ARRAYSIZE(item->keywords); i++) {
if ((item->keywords[i] & 0xFFF) == keyword)
@@ -156,51 +176,85 @@ void Encounter::run(int32 encounterIndex, ObjectId objectId1, ObjectId objectId2
//////////////////////////////////////////////////////////////////////////
// Message handler
//////////////////////////////////////////////////////////////////////////
-void Encounter::messageHandler(const AsylumEvent &evt) {
+bool Encounter::messageHandler(const AsylumEvent &evt) {
switch ((uint32)evt.type) {
default:
break;
case EVENT_ASYLUM_INIT:
- init();
+ return init();
break;
case EVENT_ASYLUM_UPDATE:
- update();
+ return update();
break;
case Common::EVENT_KEYDOWN:
- key(evt);
+ return key(evt);
break;
case Common::EVENT_LBUTTONDOWN:
case Common::EVENT_LBUTTONUP:
case Common::EVENT_RBUTTONDOWN:
case Common::EVENT_RBUTTONUP:
- mouse(evt);
+ return mouse(evt);
break;
}
+
+ return false;
}
-void Encounter::init() {
+bool Encounter::init() {
if (getSound()->getMusicVolume() != Config.musicVolume - 500)
getSound()->setMusicVolume(Config.musicVolume - 500);
- error("[Encounter::init] Not implemented!");
+ if (!getSharedData()->getMatteBarHeight()) {
+ _flag6 = true;
+ _data_455BD4 = 0;
+ _data_455BD8 = 0;
+ _data_455BDC = 0;
+ _data_455BE0 = 0;
+ _data_455BE4 = 0;
+ _data_455BCC = 0;
+ _data_455B3C = 1;
+ _rectIndex = -1;
+ _value1 = 0;
+ _data_455BF4 = 0;
+ _data_455BF8 = 0;
+ _data_455B14 = -1;
+
+ getSpeech()->resetTextData();
+
+ initData();
+
+ getText()->loadFont(getWorld()->font1);
+
+ initCoordinates();
+ initPortrait();
+ initDrawStructs();
+ }
+
+ _data_455BD0 = 0;
+ getCursor()->set(getWorld()->curTalkNPC, -1, 2);
+
+ if (!getSharedData()->getMatteBarHeight())
+ initScript(_item->scriptResourceId);
+
+ return true;
}
-void Encounter::update() {
+bool Encounter::update() {
if (getSound()->getMusicVolume() != Config.musicVolume - 500)
getSound()->setMusicVolume(Config.musicVolume - 500);
error("[Encounter::update] Not implemented!");
}
-void Encounter::key(const AsylumEvent &evt) {
+bool Encounter::key(const AsylumEvent &evt) {
error("[Encounter::key] Not implemented!");
}
-void Encounter::mouse(const AsylumEvent &evt) {
+bool Encounter::mouse(const AsylumEvent &evt) {
error("[Encounter::mouse] Not implemented!");
}
@@ -254,8 +308,8 @@ bool Encounter::isSpeaking() {
//////////////////////////////////////////////////////////////////////////
// Scripts
//////////////////////////////////////////////////////////////////////////
-void Encounter::initScript() {
- _scriptData.reset();
+void Encounter::initScript(ResourceId resourceId) {
+ _scriptData.reset(resourceId);
_flag3 = false;
}
diff --git a/engines/asylum/resources/encounters.h b/engines/asylum/resources/encounters.h
index 987f699740..fc394fecff 100644
--- a/engines/asylum/resources/encounters.h
+++ b/engines/asylum/resources/encounters.h
@@ -89,11 +89,21 @@ private:
ActorIndex _actorIndex;
uint32 _value1;
+ int32 _rectIndex;
// Internal data
+ int32 _data_455B14;
+ bool _data_455B3C;
+ bool _data_455BCC;
+ bool _data_455BD0;
+ bool _data_455BD4;
+ bool _data_455BD8;
+ bool _data_455BDC;
+ bool _data_455BE0;
+ bool _data_455BE4;
bool _data_455BE8;
uint32 _data_455BF4;
- bool _data_455BD4;
+ bool _data_455BF8;
// Internal flags
bool _flag1;
@@ -106,16 +116,21 @@ private:
//////////////////////////////////////////////////////////////////////////
// Data
void load();
- uint32 findKeyword(EncounterItem *item, int16 keyword);
+ void initData();
+ void initCoordinates();
+ void initPortrait();
+ void initDrawStructs();
+ uint32 findKeyword(EncounterItem *item, int16 keyword);
+
//////////////////////////////////////////////////////////////////////////
// Message handling
- Common::Functor1Mem<const AsylumEvent &, void, Encounter> *_messageHandler;
- void messageHandler(const AsylumEvent &evt);
- void init();
- void update();
- void key(const AsylumEvent &evt);
- void mouse(const AsylumEvent &evt);
+ Common::Functor1Mem<const AsylumEvent &, bool, Encounter> *_messageHandler;
+ bool messageHandler(const AsylumEvent &evt);
+ bool init();
+ bool update();
+ bool key(const AsylumEvent &evt);
+ bool mouse(const AsylumEvent &evt);
//////////////////////////////////////////////////////////////////////////
// Variables
@@ -151,23 +166,23 @@ private:
int32 vars[10];
uint32 offset;
int32 counter;
- uint32 resourceId;
+ ResourceId resourceId;
ScriptData() {
- reset();
+ reset(kResourceNone);
}
- void reset() {
+ void reset(ResourceId resourceId) {
memset(&vars, 0, sizeof(vars));
offset = 0;
counter = 0;
- resourceId = kResourceNone;
+ resourceId = resourceId;
}
};
ScriptData _scriptData;
- void initScript();
+ void initScript(ResourceId resourceId);
ScriptEntry getScriptEntry(ResourceId resourceId, uint32 offset);
void runScript();
diff --git a/engines/asylum/system/speech.cpp b/engines/asylum/system/speech.cpp
index 9a9ae1dd85..1dc718426b 100644
--- a/engines/asylum/system/speech.cpp
+++ b/engines/asylum/system/speech.cpp
@@ -222,6 +222,11 @@ void Speech::resetResourceIds() {
_textResourceId = kResourceNone;
}
+void Speech::resetTextData() {
+ _textData = NULL;
+ _textDataPos = NULL;
+}
+
//////////////////////////////////////////////////////////////////////////
// Private methods
//////////////////////////////////////////////////////////////////////////
diff --git a/engines/asylum/system/speech.h b/engines/asylum/system/speech.h
index 54334e72b6..5b14af880b 100644
--- a/engines/asylum/system/speech.h
+++ b/engines/asylum/system/speech.h
@@ -86,6 +86,11 @@ public:
*/
void resetResourceIds();
+ /**
+ * Resets text data
+ */
+ void resetTextData();
+
/**
* Gets the sound resource identifier.
*
Commit: 11a6152eae513c1cf2345006aa8aef2366b978d9
https://github.com/scummvm/scummvm/commit/11a6152eae513c1cf2345006aa8aef2366b978d9
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:24+02:00
Commit Message:
ASYLUM: Update event handling
- Add initPuzzle to initialize the list of puzzle instances
- Update switchEventHandler to take a class instance (implementing EventHandler)
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@584 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/asylum.cpp
engines/asylum/asylum.h
engines/asylum/eventhandler.h
engines/asylum/puzzles/puzzle.h
engines/asylum/puzzles/vcr.cpp
engines/asylum/puzzles/vcr.h
engines/asylum/resources/actionlist.cpp
engines/asylum/resources/encounters.cpp
engines/asylum/resources/encounters.h
diff --git a/engines/asylum/asylum.cpp b/engines/asylum/asylum.cpp
index 39833dbf44..20f05768b9 100644
--- a/engines/asylum/asylum.cpp
+++ b/engines/asylum/asylum.cpp
@@ -28,6 +28,8 @@
#include "asylum/resources/actionlist.h"
#include "asylum/resources/encounters.h"
+#include "asylum/puzzles/vcr.h"
+
#include "asylum/system/config.h"
#include "asylum/system/cursor.h"
#include "asylum/system/screen.h"
@@ -56,6 +58,7 @@ AsylumEngine::AsylumEngine(OSystem *system, const ADGameDescription *gd) : Engin
// Init data
memset(&_gameFlags, 0, sizeof(_gameFlags));
+ memset(&_puzzles, 0, sizeof(_puzzles));
// Add default search directories
const Common::FSNode gameDataDir(ConfMan.get("path"));
@@ -91,6 +94,10 @@ AsylumEngine::~AsylumEngine() {
delete _resource;
delete _console;
+ // Cleanup puzzles
+ for (uint i = 0; i < ARRAYSIZE(_puzzles); i++)
+ delete _puzzles[i];
+
// Zero passed pointers
_gameDescription = NULL;
}
@@ -113,6 +120,7 @@ Common::Error AsylumEngine::run() {
_sound = new Sound(this, _mixer);
_text = new Text(this);
_video = new Video(this, _mixer);
+ initPuzzles();
// Create main menu
_mainMenu = new MainMenu(this);
@@ -350,14 +358,14 @@ void AsylumEngine::processDelayedEvents() {
//////////////////////////////////////////////////////////////////////////
// Message handlers
//////////////////////////////////////////////////////////////////////////
-void AsylumEngine::switchMessageHandler(MessageHandler *handler) {
+void AsylumEngine::switchEventHandler(EventHandler *handler) {
if (handler == NULL)
error("[AsylumEngine::switchMessageHandler] Invalid handler parameter (cannot be NULL)!");
// De-init previous handler
if (_handler != NULL) {
AsylumEvent deinit(EVENT_ASYLUM_DEINIT);
- (*_handler)(deinit);
+ _handler->handleEvent(deinit);
}
// replace message handler
@@ -365,11 +373,39 @@ void AsylumEngine::switchMessageHandler(MessageHandler *handler) {
// Init new handler
AsylumEvent init(EVENT_ASYLUM_INIT);
- (*_handler)(init);
+ _handler->handleEvent(init);
+}
+
+EventHandler *AsylumEngine::getPuzzle(uint32 index) {
+ if (index >= ARRAYSIZE(_puzzles))
+ error("[AsylumEngine::getPuzzleEventHandler] Invalid index (was: %d - max: %d)", index, ARRAYSIZE(_puzzles));
+
+ if (_puzzles[index] == NULL)
+ error("[AsylumEngine::getPuzzleEventHandler] This puzzle doesn't have an event handler! (index: %d)", index);
+
+ return _puzzles[index];
}
-MessageHandler *AsylumEngine::getMessageHandler(uint32 index) {
- error("[AsylumEngine::getMessageHandler] not implemented");
+void AsylumEngine::initPuzzles() {
+ _puzzles[0] = new BlowUpPuzzleVCR(this);
+ _puzzles[1] = NULL;
+ _puzzles[2] = NULL;
+ _puzzles[3] = NULL;
+ _puzzles[4] = NULL;
+ _puzzles[5] = NULL;
+ _puzzles[6] = NULL;
+ _puzzles[7] = NULL;
+ _puzzles[8] = NULL;
+ _puzzles[9] = NULL;
+ _puzzles[10] = NULL;
+ _puzzles[11] = NULL;
+ _puzzles[12] = NULL;
+ _puzzles[13] = NULL;
+ _puzzles[14] = NULL;
+ _puzzles[15] = NULL;
+ _puzzles[16] = NULL;
+
+ warning("[AsylumEngine::initPuzzles] Add missing puzzles");
}
//////////////////////////////////////////////////////////////////////////
diff --git a/engines/asylum/asylum.h b/engines/asylum/asylum.h
index 3b5695dcc1..f83eceb271 100644
--- a/engines/asylum/asylum.h
+++ b/engines/asylum/asylum.h
@@ -144,10 +144,21 @@ public:
uint getRandom(uint max) { return _rnd.getRandomNumber(max); }
uint getRandomBit() { return _rnd.getRandomBit(); }
- // Message handler
- MessageHandler *_handler;
- void switchMessageHandler(MessageHandler *handler);
- MessageHandler *getMessageHandler(uint32 index);
+ /**
+ * Switch message handler.
+ *
+ * @param handler If non-null, a pointer to an EventHandler class.
+ */
+ void switchEventHandler(EventHandler *handler);
+
+ /**
+ * Gets a message handler.
+ *
+ * @param index Zero-based index of the message handler
+ *
+ * @return The message handler.
+ */
+ EventHandler* getPuzzle(uint32 index);
private:
const ADGameDescription *_gameDescription;
@@ -167,6 +178,10 @@ private:
Text *_text;
Video *_video;
+ // Current EventHandler class instance
+ EventHandler *_handler;
+ EventHandler *_puzzles[16];
+
// Shared game data
SharedData _data;
@@ -183,6 +198,11 @@ private:
*/
void playIntro();
+ /**
+ * Initializes the puzzles
+ */
+ void initPuzzles();
+
friend class Console;
};
diff --git a/engines/asylum/eventhandler.h b/engines/asylum/eventhandler.h
index 78ace8e21c..040ee92d09 100644
--- a/engines/asylum/eventhandler.h
+++ b/engines/asylum/eventhandler.h
@@ -45,10 +45,12 @@ struct AsylumEvent : public Common::Event {
}
};
-typedef Common::Functor1<const AsylumEvent &, bool> MessageHandler;
+class EventHandler {
+public:
+ virtual ~EventHandler() {}
-#define MESSAGE_HANDLER(class, name, inst) \
- Common::Functor1Mem<const AsylumEvent&, bool, class>(inst, &class::name)
+ virtual bool handleEvent(const AsylumEvent &ev) = 0;
+};
} // End of namespace Asylum
diff --git a/engines/asylum/puzzles/puzzle.h b/engines/asylum/puzzles/puzzle.h
index 6548ad95e7..1534100fe1 100644
--- a/engines/asylum/puzzles/puzzle.h
+++ b/engines/asylum/puzzles/puzzle.h
@@ -41,12 +41,11 @@ class Cursor;
class GraphicResource;
struct GraphicQueueItem;
-class BlowUpPuzzle {
+class BlowUpPuzzle : public EventHandler {
public:
BlowUpPuzzle(AsylumEngine *engine);
virtual ~BlowUpPuzzle();
- virtual void handleEvent(const AsylumEvent &event, bool doUpdate) = 0;
virtual void open() = 0;
virtual void close() = 0;
diff --git a/engines/asylum/puzzles/vcr.cpp b/engines/asylum/puzzles/vcr.cpp
index db33bc5531..282db3297a 100644
--- a/engines/asylum/puzzles/vcr.cpp
+++ b/engines/asylum/puzzles/vcr.cpp
@@ -83,7 +83,7 @@ void BlowUpPuzzleVCR::close() {
getScene()->activate();
}
-void BlowUpPuzzleVCR::handleEvent(const AsylumEvent &ev, bool doUpdate) {
+bool BlowUpPuzzleVCR::handleEvent(const AsylumEvent &ev) {
switch (ev.type) {
case Common::EVENT_MOUSEMOVE:
_cursor->move(ev.mouse.x, ev.mouse.y);
@@ -101,8 +101,10 @@ void BlowUpPuzzleVCR::handleEvent(const AsylumEvent &ev, bool doUpdate) {
break;
}
- if (doUpdate || _leftClickUp || _leftClickDown)
+ if (_leftClickUp || _leftClickDown)
update();
+
+ return true;
}
void BlowUpPuzzle::playSound(ResourceId resourceId, bool loop) {
diff --git a/engines/asylum/puzzles/vcr.h b/engines/asylum/puzzles/vcr.h
index caadf4c0ea..58ade50c35 100644
--- a/engines/asylum/puzzles/vcr.h
+++ b/engines/asylum/puzzles/vcr.h
@@ -63,7 +63,7 @@ public:
BlowUpPuzzleVCR(AsylumEngine *engine);
~BlowUpPuzzleVCR();
- void handleEvent(const AsylumEvent &event, bool doUpdate);
+ bool handleEvent(const AsylumEvent &event);
void open();
void close();
private:
diff --git a/engines/asylum/resources/actionlist.cpp b/engines/asylum/resources/actionlist.cpp
index 4c456f3710..6c807ddf62 100644
--- a/engines/asylum/resources/actionlist.cpp
+++ b/engines/asylum/resources/actionlist.cpp
@@ -1019,7 +1019,7 @@ IMPLEMENT_OPCODE(RunBlowUpPuzzle)
getScreen()->clear();
getScreen()->clearGraphicsInQueue();
- _vm->switchMessageHandler(_vm->getMessageHandler((uint32)cmd->param1));
+ _vm->switchEventHandler(_vm->getPuzzle((uint32)cmd->param1));
_currentLine++;
diff --git a/engines/asylum/resources/encounters.cpp b/engines/asylum/resources/encounters.cpp
index dc826c2199..184063c7bc 100644
--- a/engines/asylum/resources/encounters.cpp
+++ b/engines/asylum/resources/encounters.cpp
@@ -49,14 +49,10 @@ Encounter::Encounter(AsylumEngine *engine) : _vm(engine),
// TODO init rest of members
- _messageHandler = new MESSAGE_HANDLER(Encounter, messageHandler, this);
-
load();
}
Encounter::~Encounter() {
- delete _messageHandler;
-
// Pointing to existing data
_item = NULL;
@@ -170,13 +166,13 @@ void Encounter::run(int32 encounterIndex, ObjectId objectId1, ObjectId objectId2
_flag1 = false;
// Setup encounter event handler
- _vm->switchMessageHandler(_messageHandler);
+ _vm->switchEventHandler(this);
}
//////////////////////////////////////////////////////////////////////////
// Message handler
//////////////////////////////////////////////////////////////////////////
-bool Encounter::messageHandler(const AsylumEvent &evt) {
+bool Encounter::handleEvent(const AsylumEvent &evt) {
switch ((uint32)evt.type) {
default:
break;
diff --git a/engines/asylum/resources/encounters.h b/engines/asylum/resources/encounters.h
index fc394fecff..b687f29226 100644
--- a/engines/asylum/resources/encounters.h
+++ b/engines/asylum/resources/encounters.h
@@ -27,6 +27,7 @@
#define ASYLUM_ENCOUNTERS_H
#include "asylum/asylum.h"
+#include "asylum/eventhandler.h"
#include "asylum/shared.h"
#include "common/array.h"
@@ -35,13 +36,15 @@ namespace Asylum {
class AsylumEngine;
-class Encounter {
+class Encounter : public EventHandler {
public:
Encounter(AsylumEngine *engine);
virtual ~Encounter();
void run(int32 encounterIndex, ObjectId objectId1, ObjectId objectId2, ActorIndex actorIndex);
+ bool handleEvent(const AsylumEvent &evt);
+
void setFlag5(bool state) { _flag5 = state; }
bool getFlag6() { return _flag6; }
@@ -122,11 +125,9 @@ private:
void initDrawStructs();
uint32 findKeyword(EncounterItem *item, int16 keyword);
-
+
//////////////////////////////////////////////////////////////////////////
// Message handling
- Common::Functor1Mem<const AsylumEvent &, bool, Encounter> *_messageHandler;
- bool messageHandler(const AsylumEvent &evt);
bool init();
bool update();
bool key(const AsylumEvent &evt);
Commit: 10615c7aedd48cf1450f795e2bc46adb36a499fe
https://github.com/scummvm/scummvm/commit/10615c7aedd48cf1450f795e2bc46adb36a499fe
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:24+02:00
Commit Message:
ASYLUM: Init puzzle on first use (the background id is scene-dependent)
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@585 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/asylum.cpp
engines/asylum/asylum.h
engines/asylum/puzzles/puzzle.cpp
engines/asylum/puzzles/puzzle.h
diff --git a/engines/asylum/asylum.cpp b/engines/asylum/asylum.cpp
index 20f05768b9..390290721a 100644
--- a/engines/asylum/asylum.cpp
+++ b/engines/asylum/asylum.cpp
@@ -383,7 +383,9 @@ EventHandler *AsylumEngine::getPuzzle(uint32 index) {
if (_puzzles[index] == NULL)
error("[AsylumEngine::getPuzzleEventHandler] This puzzle doesn't have an event handler! (index: %d)", index);
- return _puzzles[index];
+ _puzzles[index]->init();
+
+ return (EventHandler *)_puzzles[index];
}
void AsylumEngine::initPuzzles() {
diff --git a/engines/asylum/asylum.h b/engines/asylum/asylum.h
index f83eceb271..e9b0cfe1d8 100644
--- a/engines/asylum/asylum.h
+++ b/engines/asylum/asylum.h
@@ -64,6 +64,7 @@ namespace Asylum {
// If defined, will show the scene update times on the debugger output
//#define DEBUG_SCENE_TIMES
+class BlowUpPuzzle;
class Cursor;
class Encounter;
class MainMenu;
@@ -180,7 +181,7 @@ private:
// Current EventHandler class instance
EventHandler *_handler;
- EventHandler *_puzzles[16];
+ BlowUpPuzzle *_puzzles[16];
// Shared game data
SharedData _data;
diff --git a/engines/asylum/puzzles/puzzle.cpp b/engines/asylum/puzzles/puzzle.cpp
index 8a6cd0d038..a0d4fff5f8 100644
--- a/engines/asylum/puzzles/puzzle.cpp
+++ b/engines/asylum/puzzles/puzzle.cpp
@@ -37,8 +37,11 @@
namespace Asylum {
BlowUpPuzzle::BlowUpPuzzle(AsylumEngine *engine): _vm(engine),
+ _cursor(NULL), _bgResource(NULL),
_leftClickUp(false), _leftClickDown(false), _rightClickDown(false), _active(false) {
+}
+void BlowUpPuzzle::init() {
// setup cursor & background
_cursor = new Cursor(_vm);
_bgResource = new GraphicResource(_vm, getWorld()->graphicResourceIds[0]);
diff --git a/engines/asylum/puzzles/puzzle.h b/engines/asylum/puzzles/puzzle.h
index 1534100fe1..e674b3752b 100644
--- a/engines/asylum/puzzles/puzzle.h
+++ b/engines/asylum/puzzles/puzzle.h
@@ -46,6 +46,8 @@ public:
BlowUpPuzzle(AsylumEngine *engine);
virtual ~BlowUpPuzzle();
+ void init();
+
virtual void open() = 0;
virtual void close() = 0;
Commit: 4ddf064c3f6d28e77a7ccea5e947572d0980b5f3
https://github.com/scummvm/scummvm/commit/4ddf064c3f6d28e77a7ccea5e947572d0980b5f3
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:24+02:00
Commit Message:
ASYLUM: Implement Encounter init methods
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@586 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/resources/encounters.cpp
engines/asylum/resources/encounters.h
engines/asylum/shared.h
engines/asylum/staticres.h
diff --git a/engines/asylum/resources/encounters.cpp b/engines/asylum/resources/encounters.cpp
index 184063c7bc..b13060a247 100644
--- a/engines/asylum/resources/encounters.cpp
+++ b/engines/asylum/resources/encounters.cpp
@@ -31,6 +31,7 @@
#include "asylum/resources/worldstats.h"
#include "asylum/system/cursor.h"
+#include "asylum/system/graphics.h"
#include "asylum/system/speech.h"
#include "asylum/system/text.h"
@@ -38,11 +39,14 @@
#include "asylum/asylum.h"
#include "asylum/respack.h"
+#include "asylum/staticres.h"
#include "common/file.h"
namespace Asylum {
+#define KEYWORD_MASK 0xFFF
+
Encounter::Encounter(AsylumEngine *engine) : _vm(engine),
_index(NULL), _keywordIndex(0), _item(NULL), _objectId1(kObjectNone), _objectId2(kObjectNone), _actorIndex(kActorInvalid),
_flag1(false), _flag2(false) {
@@ -101,24 +105,96 @@ void Encounter::load() {
}
void Encounter::initData() {
- error("[Encounter::initData] Not implemented!");
+ memset(&_keywordIndexes, -1, sizeof(_keywordIndexes));
+
+ uint32 currentIndex = 0;
+
+ for (uint i = 0; i < 50; i++)
+ if (_item->keywords[i] & KEYWORD_MASK)
+ if (!(BYTE1(_item->keywords[i]) & 0x20))
+ _keywordIndexes[currentIndex++] = i;
+
+ for (uint i = 0; i < 50; i++)
+ if (_item->keywords[i] & KEYWORD_MASK)
+ if (!(BYTE1(_item->keywords[i]) & 0x20))
+ _keywordIndexes[currentIndex++] = i;
}
-void Encounter::initCoordinates(){
- error("[Encounter::initData] Not implemented!");
+void Encounter::initBackground() {
+ _background.resourceId = getWorld()->encounterFrameBg;
+ _background.frameIndex = 0;
+ _background.frameCount = GraphicResource::getFrameCount(_vm, _background.resourceId);
+ _background.rect = GraphicResource::getFrameRect(_vm, _background.resourceId, _background.frameCount - 1);
+
+ Common::Point point;
+ Actor *player = getScene()->getActor();
+ getScene()->adjustCoordinates(player->getPoint1()->x, player->getPoint1()->y, &point);
+ _point = Common::Point(15, (point.y < 240) ? 464 - _background.rect.height() : 15);
+
+ _background.transTableNum = 1;
}
-void Encounter::initPortrait(){
- error("[Encounter::initData] Not implemented!");
+void Encounter::initPortraits() {
+ // Portrait 1
+ if (_index == 18)
+ _portrait1.resourceId = getWorld()->graphicResourceIds[51];
+ else
+ _portrait1.resourceId = getWorld()->graphicResourceIds[encounterPortrait1Index[getWorld()->chapter == kChapter9 ? getWorld()->actorType + 9 : getWorld()->chapter]];
+
+ if (_portrait1.resourceId == -1 && getWorld()->chapter == kChapter1)
+ _portrait1.resourceId = getWorld()->graphicResourceIds[36];
+
+ if (_portrait1.resourceId == -1)
+ error("[Encounter::initPortraits] No portrait 1 for this encounter!");
+
+ _portrait1.frameIndex = 0;
+ _portrait1.frameCount = GraphicResource::getFrameCount(_vm, _portrait1.resourceId);
+ _portrait1.rect = GraphicResource::getFrameRect(_vm, _portrait1.resourceId, 0);
+ _portrait1.transTableNum = 0;
+ _portrait1.transTableMax = 3;
+ _portrait1.speech0 = 0;
+
+ // Portrait 2
+ if (_index != 59)
+ _portrait2.resourceId = getWorld()->graphicResourceIds[encounterPortrait2Index[_index]];
+ else if (_vm->isGameFlagSet(kGameFlag353))
+ _portrait2.resourceId = getWorld()->graphicResourceIds[16];
+ else if (_vm->isGameFlagSet(kGameFlag354))
+ _portrait2.resourceId = getWorld()->graphicResourceIds[23];
+ else if (_vm->isGameFlagSet(kGameFlag355))
+ _portrait2.resourceId = getWorld()->graphicResourceIds[24];
+
+ if (_portrait2.resourceId == -1 && getWorld()->chapter == kChapter1)
+ _portrait2.resourceId = getWorld()->graphicResourceIds[36];
+
+ if (_portrait2.resourceId == -1)
+ error("[Encounter::initPortraits] No portrait 2 for this encounter!");
+
+ _portrait2.frameIndex = 0;
+ _portrait2.frameCount = GraphicResource::getFrameCount(_vm, _portrait1.resourceId);
+ _portrait2.rect = GraphicResource::getFrameRect(_vm, _portrait1.resourceId, 0);
+ _portrait2.transTableNum = 0;
+ _portrait2.transTableMax = 0;
+ _portrait2.speech0 = 0;
}
-void Encounter::initDrawStructs(){
- error("[Encounter::initData] Not implemented!");
+void Encounter::initDrawStructs() {
+ for (uint i = 0; i < ARRAYSIZE(_drawingStructs); i++) {
+ _drawingStructs[i].resourceId = (i == 0) ? getWorld()->smallCurUp : getWorld()->smallCurDown;
+ _drawingStructs[i].frameIndex = 0;
+ _drawingStructs[i].status = 0;
+ _drawingStructs[i].transTableNum = -1;
+
+ Common::Rect frameRect = GraphicResource::getFrameRect(_vm, _drawingStructs[i].resourceId, 0);
+ _drawingStructs[i].point1 = Common::Point(frameRect.height(), frameRect.width());
+ _drawingStructs[i].point2 = Common::Point(_point.x + _background.rect.width() + 10,
+ _point.y + (i == 0 ? 5 : _point.x + _background.rect.height() - 6));
+ }
}
uint32 Encounter::findKeyword(EncounterItem *item, int16 keyword) {
for (uint i = 0; i < ARRAYSIZE(item->keywords); i++) {
- if ((item->keywords[i] & 0xFFF) == keyword)
+ if ((item->keywords[i] & KEYWORD_MASK) == keyword)
return i;
}
@@ -225,8 +301,8 @@ bool Encounter::init() {
getText()->loadFont(getWorld()->font1);
- initCoordinates();
- initPortrait();
+ initBackground();
+ initPortraits();
initDrawStructs();
}
diff --git a/engines/asylum/resources/encounters.h b/engines/asylum/resources/encounters.h
index b687f29226..d89947b7ba 100644
--- a/engines/asylum/resources/encounters.h
+++ b/engines/asylum/resources/encounters.h
@@ -67,20 +67,59 @@ private:
byte value;
} EncounterItem;
- typedef struct EncounterStruct {
- int32 x1;
- int32 y1;
- int32 x2;
- int32 y2;
- int32 frameNum;
+ typedef struct EncounterGraphic {
+ int32 frameIndex;
+ int32 frameCount;
+ Common::Rect rect;
+ ResourceId resourceId;
+ int32 transTableNum;
+ int32 transTableMax;
+ int32 speech0;
+ int32 speech1;
+ int32 speech2;
+ int32 speech3;
+
+ EncounterGraphic() {
+ frameIndex = 0;
+ frameCount = 0;
+ resourceId = kResourceNone;
+ transTableNum = 0;
+ transTableMax = 0;
+ speech0 = 0;
+ speech1 = 0;
+ speech2 = 0;
+ speech3 = 0;
+ }
+ };
+
+ typedef struct EncounterDrawingStruct {
+ Common::Point point1;
+ Common::Point point2;
+ int32 frameIndex;
int32 transTableNum;
int32 status;
- ResourceId graphicResourceId;
- } EncounterStruct;
+ ResourceId resourceId;
+
+ EncounterDrawingStruct() {
+ frameIndex = 0;
+ transTableNum = -1;
+ status = 0;
+ resourceId = kResourceNone;
+ }
+ } EncounterDrawingStruct;
Common::Array<int16> _variables;
- int16 _anvilStyleFlag;
Common::Array<EncounterItem> _items;
+ EncounterDrawingStruct _drawingStructs[2];
+ int32 _keywordIndexes[50];
+
+ // Background & portrait
+ EncounterGraphic _background;
+ EncounterGraphic _portrait1;
+ EncounterGraphic _portrait2;
+ Common::Point _point;
+
+ int32 _rectIndex;
// Running encounter data
int32 _index;
@@ -92,7 +131,6 @@ private:
ActorIndex _actorIndex;
uint32 _value1;
- int32 _rectIndex;
// Internal data
int32 _data_455B14;
@@ -120,8 +158,8 @@ private:
// Data
void load();
void initData();
- void initCoordinates();
- void initPortrait();
+ void initBackground();
+ void initPortraits();
void initDrawStructs();
uint32 findKeyword(EncounterItem *item, int16 keyword);
diff --git a/engines/asylum/shared.h b/engines/asylum/shared.h
index 0b5f93625c..d63beb49bb 100644
--- a/engines/asylum/shared.h
+++ b/engines/asylum/shared.h
@@ -63,6 +63,9 @@ enum GameFlag {
kGameFlag275 = 275,
kGameFlag276 = 276,
kGameFlag279 = 279,
+ kGameFlag353 = 353,
+ kGameFlag354 = 354,
+ kGameFlag355 = 355,
kGameFlag358 = 358,
kGameFlag368 = 368,
kGameFlag369 = 369,
diff --git a/engines/asylum/staticres.h b/engines/asylum/staticres.h
index 89fc260d9a..e088ec054a 100644
--- a/engines/asylum/staticres.h
+++ b/engines/asylum/staticres.h
@@ -38,6 +38,17 @@ const int actorType[16] = {0, 0, 0, 0, 1, 0, 2, 0, 3, 0, 1, 1, 3, 0, 0, 0};
const int speechIndex[20] = {17, 22, 27, 37, 45, 12, 16, 19, 25, 29, 14, 18, 23, 29, 35, 6, 9, 13, 19, 27};
const int speechIndexRandom[20] = { 5, 5, 10, 8, 6, 4, 3, 6, 4, 4, 4, 5, 6, 6, 6, 3, 4, 6, 8, 4};
+/** Encounter indexes */
+const int encounterPortrait1Index[16] = {-1, 36, 20, 31, 1, 37, 7, 0, 0, 0, 1, 2, 3, 0, 0, 0};
+const int encounterPortrait2Index[80] = {50, 51, 52, 33, 34, 35, 36, 37, 38, 39,
+ 40, 41, 48, 49, 50, 1, 2, 3, 1, 2,
+ 3, 4, 5, 6, 7, 8, 9, 16, 17, 18,
+ 19, 20, 25, 32, 33, 34, 35, 36, 37, 38,
+ 39, 40, 41, 48, 2, 0, 3, 4, 5, 6,
+ 7, 8, 9, 16, 17, 18, 19, 20, 21, 22,
+ 23, 24, 25, 32, 33, 34, 0, 1, 2, 3,
+ 4, 5, 6, 53, 51, 52, 53, 54, 55, 54};
+
// Delta array for points
static const struct {
int x;
Commit: 46d6833e3e8867543bdfc27a9e12920b23354c95
https://github.com/scummvm/scummvm/commit/46d6833e3e8867543bdfc27a9e12920b23354c95
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:25+02:00
Commit Message:
ASYLUM: Implement some speech-related encounter helper methods
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@587 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/resources/actor.h
engines/asylum/resources/encounters.cpp
engines/asylum/resources/encounters.h
engines/asylum/shared.h
engines/asylum/system/speech.h
diff --git a/engines/asylum/resources/actor.h b/engines/asylum/resources/actor.h
index 4c36d3fc09..65a947586e 100644
--- a/engines/asylum/resources/actor.h
+++ b/engines/asylum/resources/actor.h
@@ -200,6 +200,15 @@ public:
*/
void setPosition(int32 newX, int32 newY, ActorDirection newDirection, uint32 frame);
+ /**
+ * Query if the passed direction is default direction.
+ *
+ * @param index Zero-based index of the graphic resource.
+ *
+ * @return true if default direction, false if not.
+ */
+ bool isDefaultDirection(int index) const;
+
/////////////////////////////////////////////////////////////////////////
// Misc
/////////////////////////////////////////////////////////////////////////
@@ -431,15 +440,6 @@ private:
*/
void updateGraphicData(uint32 offset);
- /**
- * Query if the passed direction is default direction.
- *
- * @param index Zero-based index of the graphic resource.
- *
- * @return true if default direction, false if not.
- */
- bool isDefaultDirection(int index) const;
-
/**
* Gets the graphics flags for queuing the actor graphics
*
diff --git a/engines/asylum/resources/encounters.cpp b/engines/asylum/resources/encounters.cpp
index b13060a247..963d9aa2e0 100644
--- a/engines/asylum/resources/encounters.cpp
+++ b/engines/asylum/resources/encounters.cpp
@@ -356,8 +356,101 @@ int32 Encounter::getVariableInv(int32 index) {
//////////////////////////////////////////////////////////////////////////
// Speech
//////////////////////////////////////////////////////////////////////////
-void Encounter::resetSpeech(uint32 a1, uint32 a2) {
- error("[Encounter::resetSpeech] Not implemented!");
+void Encounter::resetSpeech(uint32 keywordIndex, uint32 a2) {
+ getSpeech()->resetTextData();
+ setupPortraits();
+
+ _data_455BCC = 0;
+ _data_455B3C = 0;
+
+ if (keywordIndex) {
+ getSpeech()->setTextResourceId(keywordIndex + a2);
+ setupSpeechText();
+ }
+}
+
+void Encounter::setupPortraits() {
+ _portrait1.transTableMax = 3;
+ _portrait2.transTableMax = 0;
+ setupSpeechData('N', &_portrait1);
+ setupSpeechData('N', &_portrait2);
+}
+
+void Encounter::setupSpeechData(char val, EncounterGraphic *encounterGraphic) {
+ switch (val) {
+ default:
+ break;
+
+ case 'N':
+ encounterGraphic->speech3 = 0;
+ break;
+
+ case 'H':
+ encounterGraphic->speech3 = 1;
+ break;
+
+ case 'E':
+ encounterGraphic->speech3 = 2;
+ break;
+
+ case 'S':
+ encounterGraphic->speech3 = 3;
+ break;
+ }
+}
+
+void Encounter::setupSpeechText() {
+ setupSpeechData('N', &_portrait1);
+ setupSpeechData('N', &_portrait2);
+
+ char *text = getText()->get(getSpeech()->getTextResourceId());
+
+ if (*text == '{') {
+ _portrait1.transTableMax = 3;
+ _portrait2.transTableMax = 0;
+
+ getSpeech()->setTextData(text + 3);
+ getSpeech()->setTextDataPos(NULL);
+
+ setupSpeech(getSpeech()->getTextResourceId(), getWorld()->font1);
+ } else {
+ _portrait1.transTableMax = 0;
+ _portrait2.transTableMax = 3;
+
+ getSpeech()->setTextData(NULL);
+ if (*text == '/')
+ getSpeech()->setTextDataPos(text + 2);
+
+ setupSpeech(getSpeech()->getTextResourceId(), getWorld()->font3);
+ }
+
+ _data_455BCC = 0;
+ _data_455B3C = 1;
+}
+
+void Encounter::setupSpeech(ResourceId textResourceId, ResourceId fontResourceId) {
+ getText()->loadFont(fontResourceId);
+
+ char *text = getText()->get(textResourceId);
+
+ if (*text == '{') {
+ _data_455BDC = 1;
+ setupEntities(true);
+ setupSpeechData(text[1], &_portrait1);
+ } else {
+ _data_455BDC = 0;
+ setupEntities(false);
+ if (*text == '/') {
+ char *c = text + 1;
+ while (*c != ' ') {
+ setupSpeechData(*(c + 1), &_portrait2);
+ c++;
+ }
+ }
+ }
+
+ _data_455BE0 = 1;
+ getSpeech()->setSoundResourceId(MAKE_RESOURCE(kResourcePackSharedSound, textResourceId - _keywordIndex));
}
bool Encounter::isSpeaking() {
@@ -377,6 +470,61 @@ bool Encounter::isSpeaking() {
return false;
}
+//////////////////////////////////////////////////////////////////////////
+// Actor & Object
+//////////////////////////////////////////////////////////////////////////
+void Encounter::setupEntities(bool type4) {
+ // Actor
+ if (_actorIndex) {
+ Actor *actor = getScene()->getActor(_actorIndex);
+
+ if (actor->isDefaultDirection(20))
+ actor->updateStatus(type4 ? kActorStatusDisabled : kActorStatus8);
+
+ return;
+ }
+
+ // Objects
+ if (_objectId1 == _objectId2)
+ return;
+
+ if (_index == 37) {
+ if (getVariable(3)) {
+ if (getVariable(3) == 1 && _vm->isGameFlagNotSet(kGameFlag470)) {
+ getWorld()->getObjectById(type4 ? kObjectNPC026Talking : kObjectNPC026TalkStatusQuo)->disable();
+ getWorld()->getObjectById(type4 ? kObjectNPC026TalkStatusQuo : kObjectNPC026Talking)->setNextFrame(getWorld()->getObjectById(type4 ? kObjectNPC026TalkStatusQuo : kObjectNPC026Talking)->flags);
+ }
+ } else {
+ getWorld()->getObjectById(type4 ? _objectId1 : _objectId2)->disable();
+ getWorld()->getObjectById(type4 ? _objectId2 : _objectId1)->setNextFrame(getWorld()->getObjectById(type4 ? _objectId2 : _objectId1)->flags);
+ }
+ } else {
+ if (type4) {
+ getWorld()->getObjectById(_objectId1)->disable();
+ getWorld()->getObjectById(_objectId2)->setNextFrame(getWorld()->getObjectById(_objectId2)->flags);
+ } else {
+ if (_index == 5) {
+ if (!_vm->isGameFlagSet(kGameFlag262)) {
+ getWorld()->getObjectById(kObjectMariaPointsLeft)->disable();
+ getWorld()->getObjectById(_objectId2)->disable();
+
+ _objectId1 = kObjectMariaPointsRight;
+ getWorld()->getObjectById(_objectId1)->setNextFrame(getWorld()->getObjectById(_objectId1)->flags);
+ } else {
+ getWorld()->getObjectById(_objectId1)->disable();
+ getWorld()->getObjectById(_objectId2)->disable();
+
+ _objectId1 = kObjectMariaPointsLeft;
+ getWorld()->getObjectById(_objectId1)->setNextFrame(getWorld()->getObjectById(_objectId1)->flags);
+ }
+ } else {
+ getWorld()->getObjectById(_objectId2)->disable();
+ getWorld()->getObjectById(_objectId1)->setNextFrame(getWorld()->getObjectById(_objectId1)->flags);
+ }
+ }
+ }
+}
+
//////////////////////////////////////////////////////////////////////////
// Scripts
//////////////////////////////////////////////////////////////////////////
diff --git a/engines/asylum/resources/encounters.h b/engines/asylum/resources/encounters.h
index d89947b7ba..c827a2df03 100644
--- a/engines/asylum/resources/encounters.h
+++ b/engines/asylum/resources/encounters.h
@@ -180,8 +180,16 @@ private:
//////////////////////////////////////////////////////////////////////////
// Speech
void resetSpeech(uint32 a1, uint32 a2);
+ void setupPortraits();
+ void setupSpeechText();
+ void setupSpeechData(char val, EncounterGraphic *encounterGraphic);
+ void setupSpeech(ResourceId textResourceId, ResourceId fontResourceId);
bool isSpeaking();
+ //////////////////////////////////////////////////////////////////////////
+ // Actor & Object
+ void setupEntities(bool type4);
+
//////////////////////////////////////////////////////////////////////////
// Scripts
struct ScriptEntry {
diff --git a/engines/asylum/shared.h b/engines/asylum/shared.h
index d63beb49bb..0043d43f2f 100644
--- a/engines/asylum/shared.h
+++ b/engines/asylum/shared.h
@@ -49,6 +49,7 @@ enum GameFlag {
kGameFlag247 = 247,
kGameFlag248 = 248,
kGameFlag263 = 263,
+ kGameFlag262 = 262,
kGameFlag264 = 264,
kGameFlag265 = 265,
kGameFlag266 = 266,
@@ -87,6 +88,7 @@ enum GameFlag {
kGameFlag453 = 453,
kGameFlag454 = 454,
kGameFlag455 = 455,
+ kGameFlag470 = 470,
kGameFlag528 = 528,
kGameFlag543 = 543,
kGameFlag544 = 544,
@@ -395,6 +397,7 @@ enum ObjectId {
kObjectNPC027Dancing = 844,
kObjectNPC028Dancing = 845,
kObjectNPC026OutOfWay = 861,
+ kObjectNPC026Talking = 862,
kObjectOrangeRecord = 920,
kObjectJessieStatusQuo = 984,
kObjectMarty02 = 991,
@@ -405,6 +408,7 @@ enum ObjectId {
kObjectSailorBoy = 1013,
kObjectEleenOnGround = 1019,
kObjectSailorStatusQuo = 1021,
+ kObjectNPC026TalkStatusQuo = 1038,
kObjectSuckerSittingStatusQuo = 1084,
kObjectBubbles = 1185,
kObjectGlow = 1186,
@@ -413,6 +417,8 @@ enum ObjectId {
kObjectRing = 1189,
kObjectBallMovesUpright = 1190,
kObjectGearsLightUp = 1191,
+ kObjectMariaPointsLeft = 1200,
+ kObjectMariaPointsRight = 1201,
kObjectNPC032Sleeping = 1250,
kObjectNPC032StatusQuoOutside = 1254,
kObjectNPC032StatusQuoBigTop = 1256,
diff --git a/engines/asylum/system/speech.h b/engines/asylum/system/speech.h
index 5b14af880b..e1efb5cb9c 100644
--- a/engines/asylum/system/speech.h
+++ b/engines/asylum/system/speech.h
@@ -49,7 +49,7 @@ public:
/**
* Prepare speech to play
- * - Process sound speech and draws dialogue in screen
+ * - Process sound speech and draws dialog in screen
*/
void prepareSpeech();
@@ -112,6 +112,41 @@ public:
*/
int32 getTick() { return _tick; }
+ /**
+ * Sets the sound resource identifier
+ *
+ * @param id The sound resource identifier.
+ */
+ void setSoundResourceId(ResourceId id) { _soundResourceId = id; }
+
+ /**
+ * Sets the text resource identifier
+ *
+ * @param id The text resource identifier.
+ */
+ void setTextResourceId(ResourceId id) { _textResourceId = id; }
+
+ /**
+ * Gets the text resource identifier.
+ *
+ * @return The text resource identifier.
+ */
+ ResourceId getTextResourceId() { return _textResourceId; }
+
+ /**
+ * Sets text data.
+ *
+ * @param text The text.
+ */
+ void setTextData(char *text) { _textData = text; }
+
+ /**
+ * Sets text data position.
+ *
+ * @param text The text.
+ */
+ void setTextDataPos(char *text) { _textDataPos = text; }
+
private:
AsylumEngine *_vm;
Commit: 32c6bcc631a2a6d045dda63cf600697800fef808
https://github.com/scummvm/scummvm/commit/32c6bcc631a2a6d045dda63cf600697800fef808
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:25+02:00
Commit Message:
ASYLUM: Implement two more Actor process methods
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@588 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/resources/actor.cpp
engines/asylum/resources/actor.h
diff --git a/engines/asylum/resources/actor.cpp b/engines/asylum/resources/actor.cpp
index 69a84a49cf..cbd98e9cde 100644
--- a/engines/asylum/resources/actor.cpp
+++ b/engines/asylum/resources/actor.cpp
@@ -463,9 +463,14 @@ void Actor::update() {
break;
case kActorStatus2:
- case kActorStatus13:
- // TODO: do actor direction
+ case kActorStatus13: {
+ /*int32 dist = getDistance();
+ if (!dist)
+ dist = _direction;
+
+ Common::Point point(_point1.x + _point2.x, */
error("[Actor::update] kActorStatus2 / kActorStatus13 case not implemented");
+ }
break;
case kActorStatus3:
@@ -818,12 +823,156 @@ void Actor::processStatus(int32 actorX, int32 actorY, bool doSpeech) {
}
}
-void Actor::process_401830(int32 field980, int32 actionAreaId, int32 field978, int field98C, int32 field990, int32 field974, int32 param8, int32 param9) {
- error("[Actor::process_401830] not implemented!");
+void Actor::process_401830(int32 field980, int32 actionAreaId, int32 field978, int field98C, int32 field990, int32 field974, int32 field984, int32 field988) {
+ _field_980 = field980;
+ _actionIdx1 = (actionAreaId != -1) ? getWorld()->getActionAreaIndexById(actionAreaId) : -1;
+ _field_978 = field978;
+ _field_98C = field98C;
+ _field_990 = field990;
+ _field_974 = field974;
+
+ int field_984 = 0;
+ int field_988 = 0;
+ if (actionAreaId != -1) {
+ if (field984) {
+ field_984 = field984;
+ field_988 = field988;
+ } else {
+ PolyDefinitions *polygon = &getScene()->polygons()->entries[_actionIdx1];
+
+ field_984 = polygon->points[0].x;
+ field_988 = polygon->points[0].y;
+
+ // Iterate through points
+ if (polygon->count() > 1) {
+ for (uint i = 1; i < polygon->count() - 1; i++) {
+ Common::Point point = polygon->points[i];
+
+ switch (field978) {
+ default:
+ break;
+
+ case 0:
+ if (field_988 > point.y)
+ field_988 = point.y;
+ break;
+
+ case 1:
+ if (field_988 > point.y)
+ field_988 = point.y;
+
+ if (field_984 > point.x)
+ field_984 = point.x;
+ break;
+
+ case 2:
+ if (field_984 > point.x)
+ field_984 = point.x;
+ break;
+
+ case 3:
+ if (field_988 < point.y)
+ field_988 = point.y;
+
+ if (field_984 > point.x)
+ field_984 = point.x;
+ break;
+
+ case 4:
+ if (field_988 < point.y)
+ field_988 = point.y;
+ break;
+
+ case 5:
+ if (field_988 < point.y)
+ field_988 = point.y;
+
+ if (field_984 < point.x)
+ field_984 = point.x;
+ break;
+
+ case 6:
+ if (field_984 < point.x)
+ field_984 = point.x;
+ break;
+
+ case 7:
+ if (field_988 > point.y)
+ field_988 = point.y;
+
+ if (field_984 < point.x)
+ field_984 = point.x;
+ break;
+
+ case 8:
+ field_984 = 0;
+ field_988 = 0;
+ break;
+ }
+ }
+ }
+ }
+ }
+
+ _field_984 = field_984;
+ _field_988 = field_988;
+
+ double cosValue = cos(0.523598775) * 1000.0;
+ double sinValue = sin(0.523598775) * 1000.0;
+
+ _field_994 = field_984 - cosValue;
+ _field_998 = sinValue + field_988;
+ _field_99C = field_984 + cosValue;
+ _field_9A0 = field_988 - sinValue;
+ _field_970 = 1;
+
+ updateDirection();
}
bool Actor::process_408B20(Common::Point *point, ActorDirection direction, int count, bool hasDelta) {
- error("[Actor::process_408B20] not implemented!");
+ if (_field_944 == 1 || _field_944 == 4)
+ return true;
+
+ int16 x = (hasDelta ? point->x : point->x + deltaPointsArray[direction].x);
+ int16 y = (hasDelta ? point->y : point->y + deltaPointsArray[direction].y);
+
+ // Check scene rect
+ if (!_field_944) {
+ Common::Rect rect = getWorld()->sceneRects[getWorld()->sceneRectIdx];
+
+ if (x > rect.right)
+ return false;
+
+ if (x < rect.left)
+ return false;
+
+ if (y < rect.top)
+ return false;
+
+ if (y > rect.bottom)
+ return false;
+
+ if (!process_4103B0(point, direction))
+ return false;
+ }
+
+ if (count > 0) {
+ uint32 index = 0;
+
+ while (getScene()->findActionArea(/* 1*/Common::Point(x, y)) != -1) {
+ x += deltaPointsArray[direction].x;
+ y += deltaPointsArray[direction].y;
+
+ ++index;
+
+ if (index >= count)
+ return true;
+ }
+
+ return false;
+ }
+
+ return true;
}
void Actor::process_41BC00(int32 reactionIndex, int32 numberValue01Add) {
@@ -894,6 +1043,10 @@ bool Actor::process_41BDB0(int32 reactionIndex, int32 testNumberValue01) {
return true;
}
+bool Actor::process_4103B0(Common::Point *point, ActorDirection direction) {
+ error("[Actor::update_40DE20] not implemented!");
+}
+
void Actor::updateAndDraw() {
error("[Actor::update_40DE20] not implemented!");
}
@@ -1708,10 +1861,10 @@ int32 Actor::getGraphicsFlags() {
}
int32 Actor::getDistance() const {
- int32 index = (_frameIndex >= _frameCount) ? (2 * _frameCount) - (_frameIndex + 1): _frameIndex;
+ int32 index = (_frameIndex >= _frameCount) ? (2 * _frameCount) - (_frameIndex + 1) : _frameIndex;
if (index >= 20)
- error("[Actor::getFieldValue] Invalid index calculation (was: %d, max: 20)", index);
+ error("[Actor::getDistance] Invalid index calculation (was: %d, max: 20)", index);
switch (_direction) {
default:
diff --git a/engines/asylum/resources/actor.h b/engines/asylum/resources/actor.h
index 65a947586e..d3b9ab4419 100644
--- a/engines/asylum/resources/actor.h
+++ b/engines/asylum/resources/actor.h
@@ -235,11 +235,12 @@ public:
// Unknown methods
bool process(int32 actorX, int32 actorY);
void processStatus(int32 actorX, int32 actorY, bool doSpeech);
- void process_401830(int32 field980, int32 actionAreaId, int32 field978, int field98C, int32 field990, int32 field974, int32 param8, int32 param9);
+ void process_401830(int32 field980, int32 actionAreaId, int32 field978, int field98C, int32 field990, int32 field974, int32 field984, int32 field988);
bool process_408B20(Common::Point *point, ActorDirection direction, int count, bool hasDelta);
void process_41BC00(int32 reactionIndex, int32 numberValue01Add);
void process_41BCC0(int32 reactionIndex, int32 numberValue01Substract);
bool process_41BDB0(int32 reactionIndex, int32 testNumberValue01);
+ bool process_4103B0(Common::Point *point, ActorDirection direction);
void updateAndDraw();
void update_409230();
Commit: 98ee55b9f326fc2722e13e94ef7b45ce2dee8739
https://github.com/scummvm/scummvm/commit/98ee55b9f326fc2722e13e94ef7b45ce2dee8739
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:25+02:00
Commit Message:
ASYLUM: Update Text class
- Add missing text output methods
- Fix displaying of subtitles
- Add comments for obsolete methods (to be removed later)
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@589 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/system/speech.cpp
engines/asylum/system/text.cpp
engines/asylum/system/text.h
diff --git a/engines/asylum/system/speech.cpp b/engines/asylum/system/speech.cpp
index 1dc718426b..9684e608ec 100644
--- a/engines/asylum/system/speech.cpp
+++ b/engines/asylum/system/speech.cpp
@@ -246,11 +246,8 @@ void Speech::prepareSpeech() {
int32 posY = (((point.y >= 240) - 1) & 280) + 40;
- getText()->loadFont(getWorld()->font3);
- getText()->draw(20, posY, _textDataPos);
-
- getText()->loadFont(getWorld()->font1);
- getText()->draw(20, posY, _textData);
+ getText()->draw(_textDataPos, getWorld()->font3, posY);
+ getText()->draw(_textData, getWorld()->font1, posY);
}
}
}
diff --git a/engines/asylum/system/text.cpp b/engines/asylum/system/text.cpp
index b68bc2e9bc..ae52553245 100644
--- a/engines/asylum/system/text.cpp
+++ b/engines/asylum/system/text.cpp
@@ -55,7 +55,6 @@ void Text::loadFont(ResourceId resourceId) {
return;
delete _fontResource;
-
_fontResource = new GraphicResource(_vm, resourceId);
if (resourceId != kResourceNone) {
@@ -69,6 +68,12 @@ void Text::setPosition(int32 x, int32 y) {
_posY = y;
}
+int32 Text::getWidth(char c) {
+ GraphicFrame *font = _fontResource->getFrame((uint8)c);
+
+ return font->surface.w + font->x - _curFontFlags;
+}
+
int32 Text::getWidth(const char *text) {
if (!_fontResource)
error("[Text::getWidth] font resource hasn't been loaded yet!");
@@ -85,9 +90,27 @@ int32 Text::getWidth(const char *text) {
return width;
}
+int32 Text::getWidth(const char *text, uint32 length) {
+ if (!_fontResource)
+ error("[Text::getWidth] font resource hasn't been loaded yet!");
+
+ if (length == 0)
+ return 0;
+
+ int32 width = 0;
+ char character = *text;
+ while (character) {
+ GraphicFrame *font = _fontResource->getFrame((uint8)character);
+ width += font->surface.w + font->x - _curFontFlags;
+
+ text++;
+ character = *text;
+ }
+ return width;
+}
+
int32 Text::getWidth(ResourceId resourceId) {
- ResourceEntry *textRes = getResource()->get(resourceId);
- return getWidth((char*)textRes->data);
+ return getWidth(get(resourceId));
}
char* Text::get(ResourceId resourceId) {
@@ -99,29 +122,169 @@ void Text::drawChar(char character) {
if (!_fontResource)
error("[Text::drawChar] font resource hasn't been loaded yet!");
+ // TODO Add proper methods to screen class (also used by all other drawing calls)
+ /*if (getScreen()->getCurrentTransTableNum()) {
+ getScreen()->drawTransparent(_fontResource->getResourceId(), (uint8)character, _posX, _posY, 0, getScreen()->getCurrentTransTableNum());
+ } else {
+ getScreen()->draw(_fontResource->getResourceId(), (uint8)character, _posX, _posY, 0);
+ }
+ */
GraphicFrame *fontLetter = _fontResource->getFrame((uint8)character);
getScreen()->copyRectToScreenWithTransparency((byte *)fontLetter->surface.pixels, fontLetter->surface.w, _posX, _posY + fontLetter->y, fontLetter->surface.w, fontLetter->surface.h);
+
_posX += fontLetter->surface.w + fontLetter->x - _curFontFlags;
}
void Text::draw(const char *text) {
+ if (!text)
+ return;
+
while (*text) {
drawChar(text[0]);
text++;
}
}
+void Text::draw(const char *text, uint32 length) {
+ if (length == 0)
+ return;
+
+ if (!text)
+ return;
+
+ for (uint i = 0; i < length; i++)
+ drawChar(text[i]);
+}
+
void Text::draw(ResourceId resourceId) {
ResourceEntry *textRes = getResource()->get(resourceId);
draw((char*)textRes->data);
}
+void Text::draw(int32 x, int32 y, const char *text) {
+ setPosition(x - getWidth(text), y);
+ draw(text);
+}
+
+void Text::draw(int32 x, int32 y, ResourceId resourceId) {
+ draw(x, y, get(resourceId));
+}
+
+void Text::draw(const char *text, ResourceId fontResourceId, int32 y) {
+ if (text) {
+ loadFont(fontResourceId);
+ draw(true, 20, y, 16, 600, text);
+ }
+}
+
+void Text::draw(bool isCentered, int32 x, int32 y, int32 spacing, int32 width, const char *text) {
+ draw(0, 99, isCentered, x, y, spacing, width, text);
+}
+
+void Text::draw(int32 a1, int32 a2, bool isCentered, int32 x, int32 y, int32 spacing, int32 width, const char *text) {
+ if (!text || !*text)
+ return;
+
+ bool drawText = false;
+ int32 charWidth = 0;
+ int32 spaceWidth = 0;
+ int32 index = 0;
+
+ const char *string = text;
+ const char *endText = text;
+
+ for (;;) {
+label_start:
+
+ charWidth = 0;
+
+ // Draw the text
+ if (drawText) {
+ char currentChar = *endText;
+
+ if (index >= a1 && index <= (a1 + 2)) {
+ if (isCentered) {
+ drawCentered(x, y, width, endText - string, string);
+ } else {
+ setPosition(x, y);
+ draw(text, endText - text);
+ }
+
+ y += spacing;
+ }
+
+ ++index;
+
+ if (!currentChar)
+ break;
+
+ charWidth = 0;
+ spaceWidth = 0;
+ text = endText + 1;
+
+ // Skip spaces
+ if (currentChar == ' ' && *text == ' ')
+ do {
+ ++text;
+ } while (*text == ' ');
+ }
+
+ const char *txt = text;
+ int32 w = 0;
+
+ for (;;) {
+ char c = *txt;
+ w += charWidth;
+ charWidth = spaceWidth;
+ const char *txt2 = txt;
+
+ if (*txt != ' ') {
+ do {
+ if (!c)
+ break;
+
+ if (c == 1)
+ break;
+
+ charWidth += getWidth(c);
+ txt++;
+ c = txt[0];
+ } while (c != ' ');
+ }
+
+ if (w + charWidth > width) {
+ string = text;
+ endText = txt2 - 1;
+ drawText = true;
+ goto label_start;
+ }
+
+ if (!*txt)
+ break;
+
+ if (*txt == 1 || *txt == 2)
+ break;
+
+ ++txt;
+ spaceWidth = getWidth(' ');
+ }
+
+ string = text;
+ endText = txt;
+ drawText = true;
+ }
+}
+
void Text::drawCentered(int32 x, int32 y, int32 width, const char *text) {
- int32 textWidth = getWidth(text);
- setPosition(x + (width - textWidth) / 2, y);
+ setPosition(x + (width - getWidth(text)) / 2, y);
draw(text);
}
+void Text::drawCentered(int32 x, int32 y, int32 width, uint32 length, const char *text) {
+ setPosition(x + (width - getWidth(text, length)) / 2, y);
+ draw(text, length);
+}
+
void Text::drawCentered(int32 x, int32 y, int32 width, ResourceId resourceId, int32 value) {
ResourceEntry *textRes = getResource()->get(resourceId);
char *text = (char *)textRes->data;
@@ -131,32 +294,16 @@ void Text::drawCentered(int32 x, int32 y, int32 width, ResourceId resourceId, in
}
void Text::drawCentered(int32 x, int32 y, int32 width, ResourceId resourceId) {
- ResourceEntry *textRes = getResource()->get(resourceId);
- drawCentered(x, y, width, (char *)textRes->data);
-}
-
-void Text::draw(int32 x, int32 y, const char *text) {
- if (text) {
- int32 textWidth = getWidth(text);
- setPosition(x - textWidth, y);
- draw(text);
- }
-}
-
-void Text::draw(int32 x, int32 y, ResourceId resourceId) {
- ResourceEntry *textRes = getResource()->get(resourceId);
- draw(x, y, (char *)textRes->data);
+ drawCentered(x, y, width, get(resourceId));
}
void Text::drawAlignedRight(int32 x, int32 y, const char *text) {
- int32 textWidth = getWidth(text);
- setPosition(x - textWidth, y);
+ setPosition(x - getWidth(text), y);
draw(text);
}
void Text::drawAlignedRight(int32 x, int32 y, ResourceId resourceId) {
- ResourceEntry *textRes = getResource()->get(resourceId);
- drawAlignedRight(x, y, (char *)textRes->data);
+ drawAlignedRight(x, y, get(resourceId));
}
} // end of namespace Asylum
diff --git a/engines/asylum/system/text.h b/engines/asylum/system/text.h
index ae4ac973da..3a4e3baf04 100644
--- a/engines/asylum/system/text.h
+++ b/engines/asylum/system/text.h
@@ -44,7 +44,9 @@ public:
void loadFont(ResourceId resourceId);
void setPosition(int32 x, int32 y);
+ int32 getWidth(char c);
int32 getWidth(const char *text);
+ int32 getWidth(const char *text, uint32 length);
int32 getWidth(ResourceId resourceId);
char *get(ResourceId resourceId);
@@ -53,11 +55,17 @@ public:
void draw(int32 x, int32 y, const char *text);
void draw(ResourceId resourceId);
void draw(int32 x, int32 y, ResourceId resourceId);
+ void draw(const char *text, ResourceId fontResourceId, int32 y);
+ void draw(const char *text, uint32 length);
+ void draw(bool isCentered, int32 x, int32 y, int32 spacing, int32 width, const char *text);
+ void draw(int32 a1, int32 a2, bool isCentered, int32 x, int32 y, int32 spacing, int32 width, const char *text);
void drawCentered(int32 x, int32 y, int32 width, const char *text);
void drawCentered(int32 x, int32 y, int32 width, ResourceId resourceId);
- void drawCentered(int32 x, int32 y, int32 width, ResourceId resourceId, int32 value);
+ void drawCentered(int32 x, int32 y, int32 width, uint32 length, const char *text);
+ // TODO remove and use other methods
+ void drawCentered(int32 x, int32 y, int32 width, ResourceId resourceId, int32 value);
void drawAlignedRight(int32 x, int32 y, const char *text);
void drawAlignedRight(int32 x, int32 y, ResourceId resourceId);
Commit: 4c07c73e0062ecbbe7fb3af2b58d344d665fbe18
https://github.com/scummvm/scummvm/commit/4c07c73e0062ecbbe7fb3af2b58d344d665fbe18
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:25+02:00
Commit Message:
ASYLUM: Add loading of transparency tables
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@590 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/system/screen.cpp
engines/asylum/system/screen.h
engines/asylum/views/scene.cpp
diff --git a/engines/asylum/system/screen.cpp b/engines/asylum/system/screen.cpp
index 6224600ebe..c62c734c9f 100644
--- a/engines/asylum/system/screen.cpp
+++ b/engines/asylum/system/screen.cpp
@@ -34,15 +34,20 @@
#include "asylum/asylum.h"
#include "asylum/respack.h"
+#include <stdarg.h> // For va_list etc.
+
namespace Asylum {
-Screen::Screen(AsylumEngine *vm) : _vm(vm) {
+Screen::Screen(AsylumEngine *vm) : _vm(vm) ,
+ _transTableCount(0), _transTableIndex(NULL), _transTableData(NULL), _transTableBuffer(NULL) {
_backBuffer.create(640, 480, 1);
}
Screen::~Screen() {
_backBuffer.free();
+ clearTransTables();
+
// Zero-out passed pointers
_vm = NULL;
}
@@ -239,4 +244,60 @@ void Screen::deleteGraphicFromQueue(ResourceId resourceId) {
}
}
+//////////////////////////////////////////////////////////////////////////
+// Transparency tables
+//////////////////////////////////////////////////////////////////////////
+void Screen::setupTransTable(ResourceId resourceId) {
+ if (resourceId)
+ setupTransTables(1, resourceId);
+ else
+ setupTransTables(0);
+}
+
+void Screen::setupTransTables(uint32 count, ...) {
+ if (!count) {
+ clearTransTables();
+ return;
+ }
+
+ // Load tables
+ va_list va;
+ va_start(va, count);
+
+ if (_transTableCount != count)
+ clearTransTables();
+
+ _transTableCount = count;
+
+ if (!_transTableData) {
+ _transTableData = (byte *)malloc((count + 1) * 65536);
+ _transTableBuffer = (byte *)((uint32)_transTableData & 0xFFFF000) + 65536;
+ _transTableIndex = _transTableBuffer;
+ }
+
+ uint32 index = 0;
+ for (uint32 i = 0; i < _transTableCount; i++) {
+ ResourceId id = va_arg(va, ResourceId);
+
+ memcpy(&_transTableBuffer[index], getResource()->get(id)->data, 65536);
+ index += 65536;
+ }
+}
+
+void Screen::clearTransTables() {
+ delete _transTableData;
+ _transTableData = NULL;
+ _transTableBuffer = NULL;
+ _transTableIndex = NULL;
+ _transTableCount = 0;
+}
+
+void Screen::selectTransTable(uint32 index) {
+ if (index >= _transTableCount)
+ return;
+
+ _transTableIndex = &_transTableBuffer[65536 * index];
+}
+
+
} // end of namespace Asylum
diff --git a/engines/asylum/system/screen.h b/engines/asylum/system/screen.h
index 46321b9274..195900acfd 100644
--- a/engines/asylum/system/screen.h
+++ b/engines/asylum/system/screen.h
@@ -88,11 +88,24 @@ public:
void swapGraphicItem(int32 item1, int32 item2);
void deleteGraphicFromQueue(ResourceId resourceId);
+ // Transparency tables
+ void setupTransTable(ResourceId resourceId);
+ void setupTransTables(uint32 count, ...);
+ void selectTransTable(uint32 index);
+ byte *getTransTableIndex() { return _transTableIndex; }
+
private:
Graphics::Surface _backBuffer;
AsylumEngine *_vm;
Common::Array<GraphicQueueItem> _queueItems;
+
+ // Transparency tables
+ uint32 _transTableCount;
+ byte *_transTableIndex;
+ byte *_transTableData;
+ byte *_transTableBuffer;
+ void clearTransTables();
};
} // end of namespace Asylum
diff --git a/engines/asylum/views/scene.cpp b/engines/asylum/views/scene.cpp
index e2a9b8ba05..f2092517d5 100644
--- a/engines/asylum/views/scene.cpp
+++ b/engines/asylum/views/scene.cpp
@@ -171,10 +171,9 @@ void Scene::enter(ResourcePackId packId) {
// Clear the graphic queue (FIXME: not sure why we need to do this again)
getScreen()->clearGraphicsInQueue();
- // Load trans tables
- // TODO loadTransTables(3, field_64/68/7C)
- // TODO setTransTable(1)
- warning("[Scene::enter] missing transtable init!");
+ // Load transparency tables
+ getScreen()->setupTransTables(3, _ws->cellShadeMask1, _ws->cellShadeMask2, _ws->cellShadeMask3);
+ getScreen()->selectTransTable(1);
// Setup font
getText()->loadFont(_ws->font1);
Commit: a6178aa90386a30189abc7e03115abd45db9aea7
https://github.com/scummvm/scummvm/commit/a6178aa90386a30189abc7e03115abd45db9aea7
Author: Alexandre Fontoura (alexandrefontoura at gmail.com)
Date: 2021-05-17T15:36:25+02:00
Commit Message:
ASYLUM: Fixed Actors and Objects positions according with Scene screen scrolling.
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@591 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/resources/actor.cpp
engines/asylum/resources/object.cpp
diff --git a/engines/asylum/resources/actor.cpp b/engines/asylum/resources/actor.cpp
index cbd98e9cde..0b8d11b85d 100644
--- a/engines/asylum/resources/actor.cpp
+++ b/engines/asylum/resources/actor.cpp
@@ -242,7 +242,7 @@ void Actor::draw() {
// Draw the actor
Common::Point point;
Common::Rect frameRect = GraphicResource::getFrameRect(_vm, _resourceId, _frameIndex);
- getScene()->adjustCoordinates(frameRect.left + _point.x + _point1.x, frameRect.top + _point.y + _point1.y, &point);
+ getScene()->adjustCoordinates(frameRect.left + _point.x + _point1.x + getWorld()->xLeft, frameRect.top + _point.y + _point1.y + getWorld()->yTop, &point);
// Compute frame index
uint32 frameIndex = _frameIndex;
@@ -957,7 +957,7 @@ bool Actor::process_408B20(Common::Point *point, ActorDirection direction, int c
}
if (count > 0) {
- uint32 index = 0;
+ int32 index = 0;
while (getScene()->findActionArea(/* 1*/Common::Point(x, y)) != -1) {
x += deltaPointsArray[direction].x;
diff --git a/engines/asylum/resources/object.cpp b/engines/asylum/resources/object.cpp
index b6da95f17f..93eb45efec 100644
--- a/engines/asylum/resources/object.cpp
+++ b/engines/asylum/resources/object.cpp
@@ -191,7 +191,7 @@ void Object::draw() {
// Draw the object
Common::Point point;
Common::Rect frameRect = GraphicResource::getFrameRect(_vm, _resourceId, _frameIndex);
- getScene()->adjustCoordinates(x + frameRect.left, y + frameRect.top, &point);
+ getScene()->adjustCoordinates(x + frameRect.left + getWorld()->xLeft, y + frameRect.top + getWorld()->yTop, &point);
if (_field_67C <= 0 || _field_67C >= 4 || Config.performance <= 1) {
getScreen()->addGraphicToQueue(_resourceId, _frameIndex, point, (flags >> 11) & kObjectFlag2, _field_67C - 3, _priority);
Commit: ce04e571841a8ed6d67466aeed565ea94cb65fe7
https://github.com/scummvm/scummvm/commit/ce04e571841a8ed6d67466aeed565ea94cb65fe7
Author: Alexandre Fontoura (alexandrefontoura at gmail.com)
Date: 2021-05-17T15:36:25+02:00
Commit Message:
ASYLUM: Revert previous commit!! Commented WorldStats xLeft and yTop from Scene::adjustCoordinates to correct actors and objects Scene scrolling positions.
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@592 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/resources/actor.cpp
engines/asylum/resources/object.cpp
engines/asylum/views/scene.cpp
diff --git a/engines/asylum/resources/actor.cpp b/engines/asylum/resources/actor.cpp
index 0b8d11b85d..f1ea23ef03 100644
--- a/engines/asylum/resources/actor.cpp
+++ b/engines/asylum/resources/actor.cpp
@@ -242,7 +242,7 @@ void Actor::draw() {
// Draw the actor
Common::Point point;
Common::Rect frameRect = GraphicResource::getFrameRect(_vm, _resourceId, _frameIndex);
- getScene()->adjustCoordinates(frameRect.left + _point.x + _point1.x + getWorld()->xLeft, frameRect.top + _point.y + _point1.y + getWorld()->yTop, &point);
+ getScene()->adjustCoordinates(frameRect.left + _point.x + _point1.x, frameRect.top + _point.y + _point1.y, &point);
// Compute frame index
uint32 frameIndex = _frameIndex;
diff --git a/engines/asylum/resources/object.cpp b/engines/asylum/resources/object.cpp
index 93eb45efec..b6da95f17f 100644
--- a/engines/asylum/resources/object.cpp
+++ b/engines/asylum/resources/object.cpp
@@ -191,7 +191,7 @@ void Object::draw() {
// Draw the object
Common::Point point;
Common::Rect frameRect = GraphicResource::getFrameRect(_vm, _resourceId, _frameIndex);
- getScene()->adjustCoordinates(x + frameRect.left + getWorld()->xLeft, y + frameRect.top + getWorld()->yTop, &point);
+ getScene()->adjustCoordinates(x + frameRect.left, y + frameRect.top, &point);
if (_field_67C <= 0 || _field_67C >= 4 || Config.performance <= 1) {
getScreen()->addGraphicToQueue(_resourceId, _frameIndex, point, (flags >> 11) & kObjectFlag2, _field_67C - 3, _priority);
diff --git a/engines/asylum/views/scene.cpp b/engines/asylum/views/scene.cpp
index f2092517d5..51ce782413 100644
--- a/engines/asylum/views/scene.cpp
+++ b/engines/asylum/views/scene.cpp
@@ -1131,8 +1131,8 @@ void Scene::adjustCoordinates(int32 x, int32 y, Common::Point *point) {
if (!_ws)
error("[Scene::adjustCoordinates] WorldStats not initialized properly!");
- point->x = x - _ws->xLeft;
- point->y = y - _ws->yTop;
+ point->x = x;// - _ws->xLeft;
+ point->y = y;// - _ws->yTop;
}
//////////////////////////////////////////////////////////////////////////
Commit: 98a98a848635960ce2776bb812a56aa78fc73bfe
https://github.com/scummvm/scummvm/commit/98a98a848635960ce2776bb812a56aa78fc73bfe
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:26+02:00
Commit Message:
ASYLUM: Fix GCC compilation and warnings
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@593 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/console.cpp
engines/asylum/resources/actor.cpp
engines/asylum/resources/actor.h
engines/asylum/resources/encounters.cpp
engines/asylum/resources/encounters.h
engines/asylum/respack.h
engines/asylum/shared.h
engines/asylum/system/screen.cpp
diff --git a/engines/asylum/console.cpp b/engines/asylum/console.cpp
index db05911b75..5fc146cbf1 100644
--- a/engines/asylum/console.cpp
+++ b/engines/asylum/console.cpp
@@ -335,13 +335,13 @@ bool Console::cmdRunScript(int32 argc, const char **argv) {
uint32 actor = atoi(argv[2]);
// Check parameters
- if (index < 0 || index >= getScene()->actions()->_scripts.size()) {
+ if (index >= getScene()->actions()->_scripts.size()) {
DebugPrintf("[Error] Invalid index (was: %d - valid: [0-%d])\n", index, _vm->encounter()->_items.size() - 1);
return true;
}
- if (actor < 0 || actor > getWorld()->actors.size()) {
- DebugPrintf("[Error] Invalid actor index (was: %d - valid: [0-%d])\n", getWorld()->actors.size() - 1);
+ if (actor > getWorld()->actors.size()) {
+ DebugPrintf("[Error] Invalid actor index (was: %d - valid: [0-%d])\n", actor, getWorld()->actors.size() - 1);
}
getScene()->actions()->queueScript(index, actor);
@@ -379,7 +379,7 @@ bool Console::cmdRunEncounter(int32 argc, const char **argv) {
uint32 index = atoi(argv[1]);
// Check index is valid
- if (index < 0 || index >= _vm->encounter()->_items.size()) {
+ if (index >= _vm->encounter()->_items.size()) {
DebugPrintf("[Error] Invalid index (was: %d - valid: [0-%d])\n", index, _vm->encounter()->_items.size() - 1);
return true;
}
diff --git a/engines/asylum/resources/actor.cpp b/engines/asylum/resources/actor.cpp
index f1ea23ef03..f1a906971c 100644
--- a/engines/asylum/resources/actor.cpp
+++ b/engines/asylum/resources/actor.cpp
@@ -929,30 +929,30 @@ void Actor::process_401830(int32 field980, int32 actionAreaId, int32 field978, i
updateDirection();
}
-bool Actor::process_408B20(Common::Point *point, ActorDirection direction, int count, bool hasDelta) {
+bool Actor::process_408B20(Common::Point *point, ActorDirection dir, int count, bool hasDelta) {
if (_field_944 == 1 || _field_944 == 4)
return true;
- int16 x = (hasDelta ? point->x : point->x + deltaPointsArray[direction].x);
- int16 y = (hasDelta ? point->y : point->y + deltaPointsArray[direction].y);
+ int16 x = (hasDelta ? point->x : point->x + deltaPointsArray[dir].x);
+ int16 y = (hasDelta ? point->y : point->y + deltaPointsArray[dir].y);
// Check scene rect
if (!_field_944) {
- Common::Rect rect = getWorld()->sceneRects[getWorld()->sceneRectIdx];
+ Common::Rect rct = getWorld()->sceneRects[getWorld()->sceneRectIdx];
- if (x > rect.right)
+ if (x > rct.right)
return false;
- if (x < rect.left)
+ if (x < rct.left)
return false;
- if (y < rect.top)
+ if (y < rct.top)
return false;
- if (y > rect.bottom)
+ if (y > rct.bottom)
return false;
- if (!process_4103B0(point, direction))
+ if (!process_4103B0(point, dir))
return false;
}
@@ -960,8 +960,8 @@ bool Actor::process_408B20(Common::Point *point, ActorDirection direction, int c
int32 index = 0;
while (getScene()->findActionArea(/* 1*/Common::Point(x, y)) != -1) {
- x += deltaPointsArray[direction].x;
- y += deltaPointsArray[direction].y;
+ x += deltaPointsArray[dir].x;
+ y += deltaPointsArray[dir].y;
++index;
@@ -1043,7 +1043,7 @@ bool Actor::process_41BDB0(int32 reactionIndex, int32 testNumberValue01) {
return true;
}
-bool Actor::process_4103B0(Common::Point *point, ActorDirection direction) {
+bool Actor::process_4103B0(Common::Point *point, ActorDirection dir) {
error("[Actor::update_40DE20] not implemented!");
}
@@ -1560,7 +1560,7 @@ void Actor::updateStatus16_Chapter11() {
getCursor()->show();
getSharedData()->setFlag(kFlag1, false);
- if (_frameIndex != -5 || _vm->isGameFlagNotSet(kGameFlag570))
+ if (_frameIndex != 5 || _vm->isGameFlagNotSet(kGameFlag570))
++_frameIndex;
if (_frameIndex > _frameCount - 1) {
@@ -1682,10 +1682,10 @@ void Actor::updateCoordinates(Common::Point vec1, Common::Point vec2) {
if (diffY == 0)
return;
- ActorDirection direction = (diffY > 0) ? kDirectionS : kDirectionN;
+ ActorDirection dir = (diffY > 0) ? kDirectionS : kDirectionN;
- if (process_408B20(&vec2, direction, diffY + 3, false))
- updateCoordinatesForDirection(direction, diffY - 1, &_point);
+ if (process_408B20(&vec2, dir, diffY + 3, false))
+ updateCoordinatesForDirection(dir, diffY - 1, &_point);
}
void Actor::resetActors() {
@@ -1763,19 +1763,19 @@ ActorDirection Actor::direction(Common::Point vec1, Common::Point vec2) const {
diffY = -diffY;
}
- int32 angle = -1;
+ int32 dirAngle = -1;
if (diffX) {
uint32 index = (diffY * 256) / diffX;
if (index < 256)
- angle = angleTable01[index];
+ dirAngle = angleTable01[index];
else if (index < 4096)
- angle = angleTable02[index / 16];
+ dirAngle = angleTable02[index / 16];
else if (index < 65536)
- angle = angleTable03[index / 256];
+ dirAngle = angleTable03[index / 256];
} else {
- angle = 90;
+ dirAngle = 90;
}
switch (adjust) {
@@ -1783,58 +1783,58 @@ ActorDirection Actor::direction(Common::Point vec1, Common::Point vec2) const {
break;
case 1:
- angle = 360 - angle;
+ dirAngle = 360 - dirAngle;
break;
case 2:
- angle = 180 - angle;
+ dirAngle = 180 - dirAngle;
break;
case 3:
- angle += 180;
+ dirAngle += 180;
break;
}
- if (angle >= 360)
- angle -= 360;
+ if (dirAngle >= 360)
+ dirAngle -= 360;
- ActorDirection direction;
+ ActorDirection dir;
- if (angle < 157 || angle >= 202) {
- if (angle < 112 || angle >= 157) {
- if (angle < 67 || angle >= 112) {
- if (angle < 22 || angle >= 67) {
- if ((angle < 0 || angle >= 22) && (angle < 337 || angle > 359)) {
- if (angle < 292 || angle >= 337) {
- if (angle < 247 || angle >= 292) {
- if (angle < 202 || angle >= 247) {
- error("[Actor::angle] returned a bad angle: %d!", angle);
+ if (dirAngle < 157 || dirAngle >= 202) {
+ if (dirAngle < 112 || dirAngle >= 157) {
+ if (dirAngle < 67 || dirAngle >= 112) {
+ if (dirAngle < 22 || dirAngle >= 67) {
+ if ((dirAngle < 0 || dirAngle >= 22) && (dirAngle < 337 || dirAngle > 359)) {
+ if (dirAngle < 292 || dirAngle >= 337) {
+ if (dirAngle < 247 || dirAngle >= 292) {
+ if (dirAngle < 202 || dirAngle >= 247) {
+ error("[Actor::direction] got a bad direction angle: %d!", dirAngle);
} else {
- direction = kDirectionSO;
+ dir = kDirectionSO;
}
} else {
- direction = kDirectionS;
+ dir = kDirectionS;
}
} else {
- direction = kDirectionSE;
+ dir = kDirectionSE;
}
} else {
- direction = kDirectionE;
+ dir = kDirectionE;
}
} else {
- direction = kDirectionNE;
+ dir = kDirectionNE;
}
} else {
- direction = kDirectionN;
+ dir = kDirectionN;
}
} else {
- direction = kDirectionNO;
+ dir = kDirectionNO;
}
} else {
- direction = kDirectionO;
+ dir = kDirectionO;
}
- return direction;
+ return dir;
}
void Actor::updateGraphicData(uint32 offset) {
@@ -1888,8 +1888,8 @@ int32 Actor::getDistance() const {
}
}
-uint32 Actor::getDistanceForFrame(ActorDirection direction, uint32 frameIndex) {
- switch (_direction) {
+uint32 Actor::getDistanceForFrame(ActorDirection dir, uint32 frameIndex) {
+ switch (dir) {
default:
case kDirectionN:
case kDirectionS:
diff --git a/engines/asylum/resources/actor.h b/engines/asylum/resources/actor.h
index d3b9ab4419..779192d64f 100644
--- a/engines/asylum/resources/actor.h
+++ b/engines/asylum/resources/actor.h
@@ -62,7 +62,7 @@ public:
void setActionIndex2(int32 index) { _actionIdx2 = index; }
void setObjectIndex(int32 index) { _objectIndex = index; }
- void setDirection(ActorDirection direction) { _direction = direction; }
+ void setDirection(ActorDirection dir) { _direction = dir; }
void setFrameCount(int32 count) { _frameCount = count; }
void setFrameIndex(int32 number) { _frameIndex = number; }
void setLastScreenUpdate(int32 tick) { _lastScreenUpdate = tick; }
diff --git a/engines/asylum/resources/encounters.cpp b/engines/asylum/resources/encounters.cpp
index 963d9aa2e0..aa69b0872f 100644
--- a/engines/asylum/resources/encounters.cpp
+++ b/engines/asylum/resources/encounters.cpp
@@ -48,7 +48,7 @@ namespace Asylum {
#define KEYWORD_MASK 0xFFF
Encounter::Encounter(AsylumEngine *engine) : _vm(engine),
- _index(NULL), _keywordIndex(0), _item(NULL), _objectId1(kObjectNone), _objectId2(kObjectNone), _actorIndex(kActorInvalid),
+ _index(0), _keywordIndex(0), _item(NULL), _objectId1(kObjectNone), _objectId2(kObjectNone), _actorIndex(kActorInvalid),
_flag1(false), _flag2(false) {
// TODO init rest of members
@@ -141,10 +141,10 @@ void Encounter::initPortraits() {
else
_portrait1.resourceId = getWorld()->graphicResourceIds[encounterPortrait1Index[getWorld()->chapter == kChapter9 ? getWorld()->actorType + 9 : getWorld()->chapter]];
- if (_portrait1.resourceId == -1 && getWorld()->chapter == kChapter1)
+ if (_portrait1.resourceId == kResourceInvalid && getWorld()->chapter == kChapter1)
_portrait1.resourceId = getWorld()->graphicResourceIds[36];
- if (_portrait1.resourceId == -1)
+ if (_portrait1.resourceId == kResourceInvalid)
error("[Encounter::initPortraits] No portrait 1 for this encounter!");
_portrait1.frameIndex = 0;
@@ -164,10 +164,10 @@ void Encounter::initPortraits() {
else if (_vm->isGameFlagSet(kGameFlag355))
_portrait2.resourceId = getWorld()->graphicResourceIds[24];
- if (_portrait2.resourceId == -1 && getWorld()->chapter == kChapter1)
+ if (_portrait2.resourceId == kResourceInvalid && getWorld()->chapter == kChapter1)
_portrait2.resourceId = getWorld()->graphicResourceIds[36];
- if (_portrait2.resourceId == -1)
+ if (_portrait2.resourceId == kResourceInvalid)
error("[Encounter::initPortraits] No portrait 2 for this encounter!");
_portrait2.frameIndex = 0;
diff --git a/engines/asylum/resources/encounters.h b/engines/asylum/resources/encounters.h
index c827a2df03..e1f505ebc7 100644
--- a/engines/asylum/resources/encounters.h
+++ b/engines/asylum/resources/encounters.h
@@ -56,18 +56,18 @@ private:
enum EncounterArray {
kEncounterArray2000 = 0x2000,
kEncounterArray4000 = 0x4000,
- kEncounterArray8000 = 0x8000,
+ kEncounterArray8000 = 0x8000
};
- typedef struct EncounterItem {
+ struct EncounterItem {
int16 keywordIndex;
int16 field2;
ResourceId scriptResourceId;
int16 keywords[50];
byte value;
- } EncounterItem;
+ };
- typedef struct EncounterGraphic {
+ struct EncounterGraphic {
int32 frameIndex;
int32 frameCount;
Common::Rect rect;
@@ -92,7 +92,7 @@ private:
}
};
- typedef struct EncounterDrawingStruct {
+ struct EncounterDrawingStruct {
Common::Point point1;
Common::Point point2;
int32 frameIndex;
@@ -106,7 +106,7 @@ private:
status = 0;
resourceId = kResourceNone;
}
- } EncounterDrawingStruct;
+ };
Common::Array<int16> _variables;
Common::Array<EncounterItem> _items;
@@ -219,11 +219,11 @@ private:
reset(kResourceNone);
}
- void reset(ResourceId resourceId) {
+ void reset(ResourceId id) {
memset(&vars, 0, sizeof(vars));
offset = 0;
counter = 0;
- resourceId = resourceId;
+ resourceId = id;
}
};
diff --git a/engines/asylum/respack.h b/engines/asylum/respack.h
index da8e17a94f..757a10d2d6 100644
--- a/engines/asylum/respack.h
+++ b/engines/asylum/respack.h
@@ -47,8 +47,8 @@ struct ResourceEntry {
offset = 0;
}
- uint32 getData(uint32 offset) {
- return READ_UINT32((byte *)this + offset);
+ uint32 getData(uint32 off) {
+ return READ_UINT32((byte *)this + off);
}
};
diff --git a/engines/asylum/shared.h b/engines/asylum/shared.h
index 0043d43f2f..5821e9dadc 100644
--- a/engines/asylum/shared.h
+++ b/engines/asylum/shared.h
@@ -193,7 +193,8 @@ enum ResourcePackId {
typedef unsigned int ResourceId;
enum ResourcesId {
- kResourceNone = 0
+ kResourceNone = 0,
+ kResourceInvalid = 0xFFFFFFFF
};
enum MusicIndex {
diff --git a/engines/asylum/system/screen.cpp b/engines/asylum/system/screen.cpp
index c62c734c9f..665a0cd314 100644
--- a/engines/asylum/system/screen.cpp
+++ b/engines/asylum/system/screen.cpp
@@ -271,7 +271,7 @@ void Screen::setupTransTables(uint32 count, ...) {
if (!_transTableData) {
_transTableData = (byte *)malloc((count + 1) * 65536);
- _transTableBuffer = (byte *)((uint32)_transTableData & 0xFFFF000) + 65536;
+ _transTableBuffer = _transTableData + 65536;
_transTableIndex = _transTableBuffer;
}
@@ -285,7 +285,7 @@ void Screen::setupTransTables(uint32 count, ...) {
}
void Screen::clearTransTables() {
- delete _transTableData;
+ free(_transTableData);
_transTableData = NULL;
_transTableBuffer = NULL;
_transTableIndex = NULL;
Commit: fff878e1c063eb7d16cf0988854d7384da33d367
https://github.com/scummvm/scummvm/commit/fff878e1c063eb7d16cf0988854d7384da33d367
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:26+02:00
Commit Message:
ASYLUM: Cleanup some screen methods
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@594 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/puzzles/vcr.cpp
engines/asylum/resources/actionlist.cpp
engines/asylum/resources/actor.cpp
engines/asylum/resources/actor.h
engines/asylum/system/screen.cpp
engines/asylum/system/screen.h
engines/asylum/views/menu.cpp
engines/asylum/views/scene.cpp
engines/asylum/views/scenetitle.cpp
diff --git a/engines/asylum/puzzles/vcr.cpp b/engines/asylum/puzzles/vcr.cpp
index 282db3297a..55cd0bb39c 100644
--- a/engines/asylum/puzzles/vcr.cpp
+++ b/engines/asylum/puzzles/vcr.cpp
@@ -66,8 +66,7 @@ void BlowUpPuzzleVCR::open() {
getScreen()->setPalette(getWorld()->graphicResourceIds[29]);
// show blow up puzzle BG
- GraphicFrame *bg = _bgResource->getFrame(0);
- getScreen()->copyToBackBuffer((byte *)bg->surface.pixels, bg->surface.w, 0, 0, bg->surface.w, bg->surface.h);
+ getScreen()->draw(getWorld()->graphicResourceIds[0], 0, 0, 0, 0);
// Set mouse cursor
_cursor->set(getWorld()->graphicResourceIds[28], 0, 2);
@@ -157,7 +156,7 @@ void BlowUpPuzzleVCR::update() {
int16 barSize = 0;
do {
- getScreen()->drawWideScreen(barSize);
+ getScreen()->drawWideScreenBars(barSize);
barSize += 4;
} while (barSize < 84);
diff --git a/engines/asylum/resources/actionlist.cpp b/engines/asylum/resources/actionlist.cpp
index 6c807ddf62..2db0966854 100644
--- a/engines/asylum/resources/actionlist.cpp
+++ b/engines/asylum/resources/actionlist.cpp
@@ -1111,7 +1111,7 @@ IMPLEMENT_OPCODE(UpdateWideScreen)
getSharedData()->setMatteBarHeight(0);
} else {
- getScreen()->drawWideScreen((int16)(4 * barSize));
+ getScreen()->drawWideScreenBars((int16)(4 * barSize));
_lineIncrement = 1;
++cmd->param1;
diff --git a/engines/asylum/resources/actor.cpp b/engines/asylum/resources/actor.cpp
index f1a906971c..51e4b28da4 100644
--- a/engines/asylum/resources/actor.cpp
+++ b/engines/asylum/resources/actor.cpp
@@ -929,7 +929,7 @@ void Actor::process_401830(int32 field980, int32 actionAreaId, int32 field978, i
updateDirection();
}
-bool Actor::process_408B20(Common::Point *point, ActorDirection dir, int count, bool hasDelta) {
+bool Actor::process_408B20(Common::Point *point, ActorDirection dir, uint32 count, bool hasDelta) {
if (_field_944 == 1 || _field_944 == 4)
return true;
diff --git a/engines/asylum/resources/actor.h b/engines/asylum/resources/actor.h
index 779192d64f..852575f5ab 100644
--- a/engines/asylum/resources/actor.h
+++ b/engines/asylum/resources/actor.h
@@ -236,7 +236,7 @@ public:
bool process(int32 actorX, int32 actorY);
void processStatus(int32 actorX, int32 actorY, bool doSpeech);
void process_401830(int32 field980, int32 actionAreaId, int32 field978, int field98C, int32 field990, int32 field974, int32 field984, int32 field988);
- bool process_408B20(Common::Point *point, ActorDirection direction, int count, bool hasDelta);
+ bool process_408B20(Common::Point *point, ActorDirection direction, uint32 count, bool hasDelta);
void process_41BC00(int32 reactionIndex, int32 numberValue01Add);
void process_41BCC0(int32 reactionIndex, int32 numberValue01Substract);
bool process_41BDB0(int32 reactionIndex, int32 testNumberValue01);
diff --git a/engines/asylum/system/screen.cpp b/engines/asylum/system/screen.cpp
index 665a0cd314..db2b6a719d 100644
--- a/engines/asylum/system/screen.cpp
+++ b/engines/asylum/system/screen.cpp
@@ -52,17 +52,36 @@ Screen::~Screen() {
_vm = NULL;
}
-void Screen::draw(GraphicResource *resource, uint32 frameIndex, int32 x, int32 y, int32 flags) {
+//////////////////////////////////////////////////////////////////////////
+// Drawing
+//////////////////////////////////////////////////////////////////////////
+void Screen::draw(ResourceId resourceId, uint32 frameIndex, int32 x, int32 y, int32 flags, bool colorKey) {
+ draw(resourceId, frameIndex, x, y, flags, kResourceNone, 0, 0, colorKey);
+}
+
+void Screen::draw(ResourceId resourceId, uint32 frameIndex, int32 x, int32 y, int32 flags, int32 transTableNum) {
+ byte *index = _transTableIndex;
+ selectTransTable(transTableNum);
+
+ draw(resourceId, frameIndex, x, y, flags | 0x90000000);
+
+ _transTableIndex = index;
+}
+
+void Screen::draw(ResourceId resourceId, uint32 frameIndex, int32 x, int32 y, int32 flags, ResourceId resourceId2, int32 destX, int32 destY, bool colorKey) {
// Get the frame to draw
+ GraphicResource *resource = new GraphicResource(_vm, resourceId);
GraphicFrame *frame = resource->getFrame(frameIndex);
copyToBackBuffer(((byte *)frame->surface.pixels) - (y * frame->surface.w + x),
- frame->surface.w,
- 0,
- 0,
- 640,
- 480);
+ frame->surface.w,
+ 0,
+ 0,
+ 640,
+ 480);
+
+ delete resource;
}
void Screen::copyBackBufferToScreen() {
@@ -96,10 +115,6 @@ void Screen::copyToBackBufferWithTransparency(byte *buffer, int32 pitch, int32 x
}
}
-void Screen::copyRectToScreen(byte *buffer, int32 pitch, int32 x, int32 y, int32 width, int32 height) const{
- _vm->_system->copyRectToScreen(buffer, pitch, x, y, width, height);
-}
-
void Screen::copyRectToScreenWithTransparency(byte *buffer, int32 pitch, int32 x, int32 y, int32 width, int32 height) const {
byte *screenBuffer = (byte *)_vm->_system->lockScreen()->pixels;
@@ -145,9 +160,8 @@ void Screen::setGammaLevel(ResourceId id, int32 val) {
warning("[Screen::setGammaLevel] not implemented");
}
-void Screen::drawWideScreen(int16 barSize) const {
+void Screen::drawWideScreenBars(int16 barSize) const {
if (barSize > 0) {
-
_vm->_system->lockScreen()->fillRect(Common::Rect(0, 0, 640, barSize), 0);
_vm->_system->unlockScreen();
_vm->_system->lockScreen()->fillRect(Common::Rect(0, 480 - barSize, 640, 480), 0);
diff --git a/engines/asylum/system/screen.h b/engines/asylum/system/screen.h
index 195900acfd..dfe6c1f752 100644
--- a/engines/asylum/system/screen.h
+++ b/engines/asylum/system/screen.h
@@ -60,24 +60,32 @@ public:
Screen(AsylumEngine *_vm);
~Screen();
- void draw(GraphicResource *resource, uint32 frameIndex, int32 x, int32 y, int32 flags);
+ // Drawing
+ void draw(ResourceId resourceId, uint32 frameIndex, int32 x, int32 y, int32 flags, bool colorKey = true);
+ void draw(ResourceId resourceId, uint32 frameIndex, int32 x, int32 y, int32 flags, int32 transTableNum);
+ void draw(ResourceId resourceId, uint32 frameIndex, int32 x, int32 y, int32 flags, ResourceId resourceId2, int32 destX, int32 destY, bool colorKey = true);
- void copyToBackBuffer(byte *buffer, int32 pitch, int32 x, int32 y, uint32 width, uint32 height);
- void copyToBackBufferWithTransparency(byte *buffer, int32 pitch, int32 x, int32 y, int32 width, int32 height);
- void copyBackBufferToScreen();
- void copyRectToScreen(byte *buffer, int32 pitch, int32 x, int32 y, int32 width, int32 height) const;
- void copyRectToScreenWithTransparency(byte *buffer, int32 pitch, int32 x, int32 y, int32 width, int32 height) const;
+ void clear() const;
+
+ // Palette
void setPalette(byte *rgbPalette) const;
void setPalette(ResourceId id);
+ void paletteFade(uint32 red, int32 milliseconds, int32 param);
+ void startPaletteFade(ResourceId resourceId, int32 milliseconds, int32 param);
+ // Gamma
void setGammaLevel(ResourceId id, int32 val);
- void drawWideScreen(int16 barSize) const;
- void clear() const;
+ // Misc
+ void drawWideScreenBars(int16 barSize) const;
- void paletteFade(uint32 red, int32 milliseconds, int32 param);
- void startPaletteFade(ResourceId resourceId, int32 milliseconds, int32 param);
+ // Transparency tables
+ void setupTransTable(ResourceId resourceId);
+ void setupTransTables(uint32 count, ...);
+ void selectTransTable(uint32 index);
+ byte *getTransTableIndex() { return _transTableIndex; }
+ // Graphic queue
void addGraphicToQueue(ResourceId resourceId, uint32 frameIndex, Common::Point point, int32 flags, int32 transTableNum, int32 priority);
void addGraphicToQueueCrossfade(ResourceId resourceId, uint32 frameIndex, Common::Point point, int32 objectResourceId, Common::Point objectPoint, int32 transTableNum);
void addGraphicToQueueMasked(ResourceId resourceId, uint32 frameIndex, Common::Point point, int32 objectResourceId, Common::Point objectPoint, int32 flags, int32 priority);
@@ -88,11 +96,10 @@ public:
void swapGraphicItem(int32 item1, int32 item2);
void deleteGraphicFromQueue(ResourceId resourceId);
- // Transparency tables
- void setupTransTable(ResourceId resourceId);
- void setupTransTables(uint32 count, ...);
- void selectTransTable(uint32 index);
- byte *getTransTableIndex() { return _transTableIndex; }
+ // TODO Make those private
+ void copyToBackBufferWithTransparency(byte *buffer, int32 pitch, int32 x, int32 y, int32 width, int32 height);
+ void copyRectToScreenWithTransparency(byte *buffer, int32 pitch, int32 x, int32 y, int32 width, int32 height) const;
+ void copyBackBufferToScreen();
private:
Graphics::Surface _backBuffer;
@@ -106,6 +113,9 @@ private:
byte *_transTableData;
byte *_transTableBuffer;
void clearTransTables();
+
+ // Screen copying
+ void copyToBackBuffer(byte *buffer, int32 pitch, int32 x, int32 y, uint32 width, uint32 height);
};
} // end of namespace Asylum
diff --git a/engines/asylum/views/menu.cpp b/engines/asylum/views/menu.cpp
index 520486998d..c932a857f6 100644
--- a/engines/asylum/views/menu.cpp
+++ b/engines/asylum/views/menu.cpp
@@ -113,14 +113,7 @@ void MainMenu::openMenu() {
// Load the graphics palette
getScreen()->setPalette(MAKE_RESOURCE(kResourcePackShared, 17));
- // Copy the bright background to the back buffer
- GraphicFrame *bg = _bgResource->getFrame(1);
- getScreen()->copyToBackBuffer((byte *)bg->surface.pixels,
- bg->surface.w,
- 0,
- 0,
- bg->surface.w,
- bg->surface.h);
+ getScreen()->draw(MAKE_RESOURCE(kResourcePackShared, 0), 1, 0, 0, 0);
// Set mouse cursor
_cursor->set(MAKE_RESOURCE(kResourcePackShared, 2));
@@ -186,8 +179,8 @@ void MainMenu::update() {
if (_activeIcon != -1) {
// Copy the dark background to the back buffer
- GraphicFrame *bg = _bgResource->getFrame(0);
- getScreen()->copyToBackBuffer((byte *)bg->surface.pixels, bg->surface.w, 0, 0, bg->surface.w, bg->surface.h);
+ getScreen()->draw(MAKE_RESOURCE(kResourcePackShared, 0), 0, 0, 0, 0);
+
_activeMenuScreen = (MenuScreen) _activeIcon;
// Set the cursor
@@ -645,8 +638,7 @@ void MainMenu::exitSubMenu() {
_activeMenuScreen = kMainMenu;
// Copy the bright background to the back buffer
- GraphicFrame *bg = _bgResource->getFrame(1);
- _vm->screen()->copyToBackBuffer((byte *)bg->surface.pixels, bg->surface.w, 0, 0, bg->surface.w, bg->surface.h);
+ getScreen()->draw(MAKE_RESOURCE(kResourcePackShared, 0), 1, 0, 0, 0);
// Set the cursor
_cursor->set(MAKE_RESOURCE(kResourcePackShared, 2));
diff --git a/engines/asylum/views/scene.cpp b/engines/asylum/views/scene.cpp
index 51ce782413..48ff616231 100644
--- a/engines/asylum/views/scene.cpp
+++ b/engines/asylum/views/scene.cpp
@@ -403,10 +403,7 @@ void Scene::activate() {
_isActive = true;
getScreen()->setPalette(_ws->currentPaletteId);
- _background = _bgResource->getFrame(0);
- _vm->screen()->copyToBackBuffer(
- ((byte *)_background->surface.pixels) + _ws->yTop * _background->surface.w + _ws->xLeft, _background->surface.w,
- 0, 0, 640, 480);
+ getScreen()->draw(_ws->backgroundImage, 0, _ws->xLeft, _ws->yTop, 0);
}
bool Scene::update() {
@@ -1148,7 +1145,7 @@ int Scene::drawScene() {
_vm->screen()->clear();
} else {
// Draw scene background
- _vm->screen()->draw(_bgResource, 0, -_ws->xLeft, -_ws->yTop, 0);
+ _vm->screen()->draw(_ws->backgroundImage, 0, -_ws->xLeft, -_ws->yTop, 0);
// Draw actors on the update list
buildUpdateList();
diff --git a/engines/asylum/views/scenetitle.cpp b/engines/asylum/views/scenetitle.cpp
index 796d1fd4df..e39c3228ae 100644
--- a/engines/asylum/views/scenetitle.cpp
+++ b/engines/asylum/views/scenetitle.cpp
@@ -79,11 +79,7 @@ void SceneTitle::update(int32 tick) {
if ((tick - _start) % 500 > 100)
_spinnerProgress += 20;
- GraphicFrame *bgFrame = _bg->getFrame(0);
-
- getScreen()->copyToBackBuffer(((byte *)bgFrame->surface.pixels),
- bgFrame->surface.w,
- 0, 0, 640, 480);
+ getScreen()->draw(getWorld()->sceneTitleGraphicResourceId, 0, 0, 0, 0);
ResourceId resourceId = MAKE_RESOURCE(getScene()->getPackId(), 1797);
int32 resWidth = getText()->getWidth(resourceId);
Commit: 12057a04d2a300acf628b2730efa5989f6275d5e
https://github.com/scummvm/scummvm/commit/12057a04d2a300acf628b2730efa5989f6275d5e
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:26+02:00
Commit Message:
ASYLUM: Use subtitle config option when playing movies
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@595 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/asylum.cpp
engines/asylum/puzzles/vcr.cpp
engines/asylum/system/video.cpp
engines/asylum/system/video.h
diff --git a/engines/asylum/asylum.cpp b/engines/asylum/asylum.cpp
index 390290721a..d32f52b875 100644
--- a/engines/asylum/asylum.cpp
+++ b/engines/asylum/asylum.cpp
@@ -208,7 +208,7 @@ void AsylumEngine::playIntro() {
g_system->showMouse(false);
if (Config.showIntro)
- _video->playVideo(1, Config.showMovieSubtitles);
+ _video->playVideo(1);
/*if (_scene->worldstats()->musicCurrentResourceId != kResourceMusic_FFFFFD66)
_sound->playMusic(_scene->getResourcePack(), _scene->worldstats()->musicCurrentResourceId);*/
@@ -326,7 +326,7 @@ void AsylumEngine::processDelayedEvents() {
if (videoIdx >= 0) {
_sound->stopMusic();
_sound->stopAll();
- _video->playVideo(videoIdx, true);
+ _video->playVideo(videoIdx);
_scene->actions()->setDelayedVideoIndex(-1);
if (_mainMenu->isActive())
diff --git a/engines/asylum/puzzles/vcr.cpp b/engines/asylum/puzzles/vcr.cpp
index 55cd0bb39c..d371a66ed8 100644
--- a/engines/asylum/puzzles/vcr.cpp
+++ b/engines/asylum/puzzles/vcr.cpp
@@ -162,7 +162,7 @@ void BlowUpPuzzleVCR::update() {
// TODO: fade palette to gray
- getVideo()->playVideo(2, true);
+ getVideo()->playVideo(2);
_isAccomplished = false;
close();
diff --git a/engines/asylum/system/video.cpp b/engines/asylum/system/video.cpp
index 10d43d752a..02caf03631 100644
--- a/engines/asylum/system/video.cpp
+++ b/engines/asylum/system/video.cpp
@@ -25,6 +25,7 @@
#include "asylum/system/video.h"
+#include "asylum/system/config.h"
#include "asylum/system/graphics.h"
#include "asylum/system/text.h"
@@ -52,7 +53,7 @@ Video::~Video() {
delete _text;
}
-void Video::playVideo(int32 videoNumber, bool showSubtitles) {
+void Video::playVideo(int32 videoNumber) {
char filename[20];
sprintf(filename, "mov%03d.smk", videoNumber);
@@ -65,7 +66,7 @@ void Video::playVideo(int32 videoNumber, bool showSubtitles) {
bool lastMouseState = g_system->showMouse(false);
_skipVideo = false;
- if (showSubtitles)
+ if (Config.showMovieSubtitles)
loadSubtitles(videoNumber);
int32 x = Common::Rational(g_system->getWidth() - _smkDecoder->getWidth(), 2).toInt();
@@ -79,7 +80,7 @@ void Video::playVideo(int32 videoNumber, bool showSubtitles) {
if (frame) {
g_system->copyRectToScreen((byte *)frame->pixels, frame->pitch, x, y, frame->w, frame->h);
- if(showSubtitles) {
+ if(Config.showMovieSubtitles) {
Graphics::Surface *screen = g_system->lockScreen();
performPostProcessing((byte *)screen->pixels);
g_system->unlockScreen();
diff --git a/engines/asylum/system/video.h b/engines/asylum/system/video.h
index 46995ce4b8..79ee23198e 100644
--- a/engines/asylum/system/video.h
+++ b/engines/asylum/system/video.h
@@ -56,7 +56,7 @@ public:
Video(AsylumEngine *engine, Audio::Mixer *mixer);
virtual ~Video();
- void playVideo(int32 videoNumber, bool showSubtitles);
+ void playVideo(int32 videoNumber);
private:
void performPostProcessing(byte *screen);
Commit: 9d195216a322bdf220bf0193bb7cadb099a18c27
https://github.com/scummvm/scummvm/commit/9d195216a322bdf220bf0193bb7cadb099a18c27
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:26+02:00
Commit Message:
ASYLUM: Cleanup use of adjustCoordinates
Also add FIXME since the original doesn't add the frame coordinates
(we are missing code in the Screen class that would do it at drawing time)
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@596 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/resources/actor.cpp
engines/asylum/resources/actor.h
engines/asylum/resources/encounters.cpp
engines/asylum/resources/object.cpp
engines/asylum/resources/object.h
engines/asylum/system/speech.cpp
engines/asylum/views/scene.cpp
engines/asylum/views/scene.h
diff --git a/engines/asylum/resources/actor.cpp b/engines/asylum/resources/actor.cpp
index 51e4b28da4..f7f9afefae 100644
--- a/engines/asylum/resources/actor.cpp
+++ b/engines/asylum/resources/actor.cpp
@@ -242,7 +242,10 @@ void Actor::draw() {
// Draw the actor
Common::Point point;
Common::Rect frameRect = GraphicResource::getFrameRect(_vm, _resourceId, _frameIndex);
- getScene()->adjustCoordinates(frameRect.left + _point.x + _point1.x, frameRect.top + _point.y + _point1.y, &point);
+ adjustCoordinates(&point);
+ // FIXME the original doesn't add the frame coordinates!
+ point.x += _point.x + frameRect.left;
+ point.y += _point.y + frameRect.top;
// Compute frame index
uint32 frameIndex = _frameIndex;
@@ -252,7 +255,7 @@ void Actor::draw() {
if (LOBYTE(flags) & kActorFlagMasked) {
Object *object = getWorld()->objects[_objectIndex];
Common::Point objPoint;
- getScene()->adjustCoordinates(object->x, object->y, &objPoint);
+ object->adjustCoordinates(&objPoint);
getScreen()->addGraphicToQueueMasked(_resourceId, frameIndex, point, object->getResourceId(), objPoint, getGraphicsFlags(), _priority);
@@ -957,7 +960,7 @@ bool Actor::process_408B20(Common::Point *point, ActorDirection dir, uint32 coun
}
if (count > 0) {
- int32 index = 0;
+ uint32 index = 0;
while (getScene()->findActionArea(/* 1*/Common::Point(x, y)) != -1) {
x += deltaPointsArray[dir].x;
@@ -1848,6 +1851,14 @@ bool Actor::isDefaultDirection(int index) const {
return _graphicResourceIds[index] != _graphicResourceIds[5];
}
+void Actor::adjustCoordinates(Common::Point *point) {
+ if (!point)
+ error("[Actor::adjustCoordinates] Invalid point parameter!");
+
+ point->x += _point1.x - getWorld()->xLeft;
+ point->y += _point1.y - getWorld()->yTop;
+}
+
int32 Actor::getGraphicsFlags() {
if (getWorld()->chapter == kChapter11) {
int res = strcmp((char *)&_name, "Dead Sarah");
diff --git a/engines/asylum/resources/actor.h b/engines/asylum/resources/actor.h
index 852575f5ab..79de8e97bf 100644
--- a/engines/asylum/resources/actor.h
+++ b/engines/asylum/resources/actor.h
@@ -209,6 +209,13 @@ public:
*/
bool isDefaultDirection(int index) const;
+ /**
+ * Adjust coordinates.
+ *
+ * @param point The point.
+ */
+ void adjustCoordinates(Common::Point *point);
+
/////////////////////////////////////////////////////////////////////////
// Misc
/////////////////////////////////////////////////////////////////////////
diff --git a/engines/asylum/resources/encounters.cpp b/engines/asylum/resources/encounters.cpp
index aa69b0872f..0216444d1d 100644
--- a/engines/asylum/resources/encounters.cpp
+++ b/engines/asylum/resources/encounters.cpp
@@ -128,7 +128,7 @@ void Encounter::initBackground() {
Common::Point point;
Actor *player = getScene()->getActor();
- getScene()->adjustCoordinates(player->getPoint1()->x, player->getPoint1()->y, &point);
+ player->adjustCoordinates(&point);
_point = Common::Point(15, (point.y < 240) ? 464 - _background.rect.height() : 15);
_background.transTableNum = 1;
diff --git a/engines/asylum/resources/object.cpp b/engines/asylum/resources/object.cpp
index b6da95f17f..ed093e8c48 100644
--- a/engines/asylum/resources/object.cpp
+++ b/engines/asylum/resources/object.cpp
@@ -175,6 +175,14 @@ bool Object::isVisible() const {
return false;
}
+void Object::adjustCoordinates(Common::Point *point) {
+ if (!point)
+ error("[Actor::adjustCoordinates] Invalid point parameter!");
+
+ point->x += x - getWorld()->xLeft;
+ point->y += y - getWorld()->yTop;
+}
+
/////////////////////////////////////////////////////////////////////////
// Update
//////////////////////////////////////////////////////////////////////////
@@ -190,8 +198,12 @@ void Object::draw() {
// Draw the object
Common::Point point;
+ adjustCoordinates(&point);
+
+ // FIXME the original doesn't add the frame coordinates!
Common::Rect frameRect = GraphicResource::getFrameRect(_vm, _resourceId, _frameIndex);
- getScene()->adjustCoordinates(x + frameRect.left, y + frameRect.top, &point);
+ point.x += frameRect.left;
+ point.y += frameRect.top;
if (_field_67C <= 0 || _field_67C >= 4 || Config.performance <= 1) {
getScreen()->addGraphicToQueue(_resourceId, _frameIndex, point, (flags >> 11) & kObjectFlag2, _field_67C - 3, _priority);
diff --git a/engines/asylum/resources/object.h b/engines/asylum/resources/object.h
index bc851ebadb..3db9d47fe7 100644
--- a/engines/asylum/resources/object.h
+++ b/engines/asylum/resources/object.h
@@ -106,6 +106,13 @@ public:
*/
bool isOnScreen();
+ /**
+ * Adjust coordinates.
+ *
+ * @param point The point.
+ */
+ void adjustCoordinates(Common::Point *point);
+
/////////////////////////////////////////////////////////////////////////
// Drawing & update
//////////////////////////////////////////////////////////////////////////
diff --git a/engines/asylum/system/speech.cpp b/engines/asylum/system/speech.cpp
index 9684e608ec..054480caca 100644
--- a/engines/asylum/system/speech.cpp
+++ b/engines/asylum/system/speech.cpp
@@ -241,8 +241,7 @@ void Speech::prepareSpeech() {
if (Config.showEncounterSubtitles) {
Common::Point point;
Actor *actor = getScene()->getActor();
-
- getScene()->adjustCoordinates(actor->getPoint1()->x, actor->getPoint1()->y, &point);
+ actor->adjustCoordinates(&point);
int32 posY = (((point.y >= 240) - 1) & 280) + 40;
diff --git a/engines/asylum/views/scene.cpp b/engines/asylum/views/scene.cpp
index 48ff616231..0a6aa539e3 100644
--- a/engines/asylum/views/scene.cpp
+++ b/engines/asylum/views/scene.cpp
@@ -1121,17 +1121,6 @@ bool Scene::updateSceneCoordinates(int32 tX, int32 tY, int32 A0, bool checkScene
return false;
}
-void Scene::adjustCoordinates(int32 x, int32 y, Common::Point *point) {
- if (!point)
- error("[Scene::adjustCoordinates] Invalid point parameter!");
-
- if (!_ws)
- error("[Scene::adjustCoordinates] WorldStats not initialized properly!");
-
- point->x = x;// - _ws->xLeft;
- point->y = y;// - _ws->yTop;
-}
-
//////////////////////////////////////////////////////////////////////////
// Scene drawing
//////////////////////////////////////////////////////////////////////////
@@ -1279,7 +1268,7 @@ void Scene::processUpdateList() {
if (intersects && LOBYTE(actor->flags) & kActorFlagMasked) {
error("[Scene::processUpdateList] Assigning mask to masked character [%s]", actor->getName());
} else {
- adjustCoordinates(object->x, object->y, &point);
+ object->adjustCoordinates(&point);
actor->setObjectIndex(j);
actor->flags |= kActorFlagMasked;
}
diff --git a/engines/asylum/views/scene.h b/engines/asylum/views/scene.h
index 42c0f4ac66..eb33d7b469 100644
--- a/engines/asylum/views/scene.h
+++ b/engines/asylum/views/scene.h
@@ -143,8 +143,6 @@ public:
bool updateSceneCoordinates(int32 targetX, int32 targetY, int32 val, bool checkSceneCoords = false, int32 *param = NULL);
- void adjustCoordinates(int32 x, int32 y, Common::Point *point);
-
int processActor(int *x, int *param);
void updatePalette(int32 param);
Commit: f8b4d22f7b2e739292521c17406c4da33b8647f1
https://github.com/scummvm/scummvm/commit/f8b4d22f7b2e739292521c17406c4da33b8647f1
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:26+02:00
Commit Message:
ASYLUM: Move coordinate adjustement to Screen::drawGraphicsInQueue
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@597 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/resources/actor.cpp
engines/asylum/resources/object.cpp
engines/asylum/system/screen.cpp
diff --git a/engines/asylum/resources/actor.cpp b/engines/asylum/resources/actor.cpp
index f7f9afefae..6d30bc0c60 100644
--- a/engines/asylum/resources/actor.cpp
+++ b/engines/asylum/resources/actor.cpp
@@ -241,11 +241,9 @@ void Actor::draw() {
// Draw the actor
Common::Point point;
- Common::Rect frameRect = GraphicResource::getFrameRect(_vm, _resourceId, _frameIndex);
adjustCoordinates(&point);
- // FIXME the original doesn't add the frame coordinates!
- point.x += _point.x + frameRect.left;
- point.y += _point.y + frameRect.top;
+ point.x += _point.x;
+ point.y += _point.y;
// Compute frame index
uint32 frameIndex = _frameIndex;
diff --git a/engines/asylum/resources/object.cpp b/engines/asylum/resources/object.cpp
index ed093e8c48..fb7f34254d 100644
--- a/engines/asylum/resources/object.cpp
+++ b/engines/asylum/resources/object.cpp
@@ -200,11 +200,6 @@ void Object::draw() {
Common::Point point;
adjustCoordinates(&point);
- // FIXME the original doesn't add the frame coordinates!
- Common::Rect frameRect = GraphicResource::getFrameRect(_vm, _resourceId, _frameIndex);
- point.x += frameRect.left;
- point.y += frameRect.top;
-
if (_field_67C <= 0 || _field_67C >= 4 || Config.performance <= 1) {
getScreen()->addGraphicToQueue(_resourceId, _frameIndex, point, (flags >> 11) & kObjectFlag2, _field_67C - 3, _priority);
} else {
diff --git a/engines/asylum/system/screen.cpp b/engines/asylum/system/screen.cpp
index db2b6a719d..afe8ee5951 100644
--- a/engines/asylum/system/screen.cpp
+++ b/engines/asylum/system/screen.cpp
@@ -215,7 +215,7 @@ void Screen::drawGraphicsInQueue() {
copyToBackBufferWithTransparency((byte *)fra->surface.pixels,
fra->surface.w,
- _queueItems[i].point.x - getWorld()->xLeft, _queueItems[i].point.y - getWorld()->yTop,
+ _queueItems[i].point.x - getWorld()->xLeft + fra->x, _queueItems[i].point.y - getWorld()->yTop + fra->y,
fra->surface.w,
fra->surface.h);
Commit: f4b1d284b1471f7f9bcd4c72122d5ba2ab703314
https://github.com/scummvm/scummvm/commit/f4b1d284b1471f7f9bcd4c72122d5ba2ab703314
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:26+02:00
Commit Message:
ASYLUM: Convert MainMenu to implement EventHandler
- access to menu is disabled until the main event loop is converted
- update/key/mouse functions have not been converted yet
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@598 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/asylum.cpp
engines/asylum/asylum.h
engines/asylum/eventhandler.h
engines/asylum/resources/actionlist.cpp
engines/asylum/views/menu.cpp
engines/asylum/views/menu.h
diff --git a/engines/asylum/asylum.cpp b/engines/asylum/asylum.cpp
index d32f52b875..0408c9348c 100644
--- a/engines/asylum/asylum.cpp
+++ b/engines/asylum/asylum.cpp
@@ -161,6 +161,10 @@ void AsylumEngine::waitForTimer(uint32 msec_delay) {
}
}
+void AsylumEngine::init() {
+ error("[AsylumEngine::init] Not implemented!");
+}
+
void AsylumEngine::startGame(ResourcePackId sceneId, StartGameType type) {
if (!_cursor || !_screen)
error("[AsylumEngine::startGame] Subsystems not initialized properly!");
@@ -200,6 +204,10 @@ void AsylumEngine::startGame(ResourcePackId sceneId, StartGameType type) {
}
}
+void AsylumEngine::restart() {
+ error("[AsylumEngine::restart] Not implemented!");
+}
+
void AsylumEngine::playIntro() {
if (!_video || !_screen)
error("[AsylumEngine::playIntro] Subsystems not initialized properly!");
@@ -254,7 +262,7 @@ void AsylumEngine::handleEvents(bool doUpdate) {
}
}
- Common::Event ev;
+ AsylumEvent ev;
if (_eventMan->pollEvent(ev)) {
switch (ev.type) {
@@ -267,13 +275,13 @@ void AsylumEngine::handleEvents(bool doUpdate) {
if (ev.kbd.keycode == Common::KEYCODE_ESCAPE) {
// Toggle menu
- if (_mainMenu->isActive()) {
+ /*if (_mainMenu->isActive()) {*/
if (_scene) {
- _mainMenu->closeMenu();
+ //_mainMenu->closeMenu();
_scene->activate();
- }
+ //}
} else if (_scene && _scene->isActive()) {
- _mainMenu->openMenu();
+ //_mainMenu->openMenu();
}
/* FIXME
} else if (_scene && _scene->getBlowUpPuzzle()->isActive()) {
@@ -297,17 +305,20 @@ void AsylumEngine::handleEvents(bool doUpdate) {
}
if (doUpdate) {
- if (_mainMenu->isActive() ||
- (_scene && _scene->isActive())) //|| (_scene && _scene->getBlowUpPuzzle()->isActive()))
- // Copy background image
- _screen->copyBackBufferToScreen();
+ //if (_mainMenu->isActive() || (_scene && _scene->isActive())) { //|| (_scene && _scene->getBlowUpPuzzle()->isActive()))
+ //AsylumEvent updateEvt = AsylumEvent(EVENT_ASYLUM_UPDATE);
+ //_mainMenu->handleEvent(updateEvt);
+ //}
+
+ // Copy background image
+ _screen->copyBackBufferToScreen();
}
- if (_mainMenu->isActive())
+ //if (_mainMenu->isActive())
// Main menu active, pass events to it
- _mainMenu->handleEvent(&ev, doUpdate);
- else if (_scene && _scene->isActive())
+ // _mainMenu->handleEvent(ev);
+ if (_scene && _scene->isActive())
// Pass events to the game
_scene->handleEvent(&ev, doUpdate);
/* FIXME reimplement
@@ -329,9 +340,9 @@ void AsylumEngine::processDelayedEvents() {
_video->playVideo(videoIdx);
_scene->actions()->setDelayedVideoIndex(-1);
- if (_mainMenu->isActive())
- _mainMenu->openMenu();
- else if (_scene->isActive())
+ //if (_mainMenu->isActive())
+ // _mainMenu->openMenu();
+ if (_scene->isActive())
_scene->activate();
}
diff --git a/engines/asylum/asylum.h b/engines/asylum/asylum.h
index e9b0cfe1d8..7abed1c627 100644
--- a/engines/asylum/asylum.h
+++ b/engines/asylum/asylum.h
@@ -93,11 +93,21 @@ public:
AsylumEngine(OSystem *system, const ADGameDescription *gd);
virtual ~AsylumEngine();
+ /**
+ * Initializes the game
+ */
+ void init();
+
/**
* Start a new the game
*/
void startGame(ResourcePackId sceneId, StartGameType type);
+ /**
+ * Restarts the game
+ */
+ void restart();
+
/**
* Switch to a new scene
*
@@ -186,6 +196,7 @@ private:
// Shared game data
SharedData _data;
+
bool _introPlaying;
int _gameFlags[1512];
diff --git a/engines/asylum/eventhandler.h b/engines/asylum/eventhandler.h
index 040ee92d09..e71eaea9b3 100644
--- a/engines/asylum/eventhandler.h
+++ b/engines/asylum/eventhandler.h
@@ -32,15 +32,20 @@
namespace Asylum {
enum AsylumEventType {
- EVENT_ASYLUM_INIT = 0xFFF0,
- EVENT_ASYLUM_DEINIT = 0xFFF1,
- EVENT_ASYLUM_UPDATE = 0xFFF2
+ EVENT_ASYLUM_INIT = 0xFFF0,
+ EVENT_ASYLUM_DEINIT = 0xFFF1,
+ EVENT_ASYLUM_UPDATE = 0xFFF2,
+ EVENT_ASYLUM_MUSIC = 0xFFF3,
+
+ EVENT_ASYLUM_CHANGECD = 0xFFFE
};
struct AsylumEvent : public Common::Event {
+ AsylumEvent() : Event() {}
+
// Since we don't feed any custom message into the event manager,
// we can safely use our own custom event type.
- AsylumEvent(AsylumEventType msgType) {
+ AsylumEvent(AsylumEventType msgType) : Event() {
type = (Common::EventType)msgType;
}
};
diff --git a/engines/asylum/resources/actionlist.cpp b/engines/asylum/resources/actionlist.cpp
index 2db0966854..9f8be18ed1 100644
--- a/engines/asylum/resources/actionlist.cpp
+++ b/engines/asylum/resources/actionlist.cpp
@@ -1742,7 +1742,7 @@ END_OPCODE
//////////////////////////////////////////////////////////////////////////
// Opcode 0x62
IMPLEMENT_OPCODE(ShowOptionsScreen)
- _vm->menu()->showOptions();
+ _vm->menu()->show();
END_OPCODE
//////////////////////////////////////////////////////////////////////////
diff --git a/engines/asylum/views/menu.cpp b/engines/asylum/views/menu.cpp
index c932a857f6..1d16acbcfb 100644
--- a/engines/asylum/views/menu.cpp
+++ b/engines/asylum/views/menu.cpp
@@ -25,12 +25,15 @@
#include "asylum/views/menu.h"
+#include "asylum/resources/actor.h"
+
#include "asylum/system/config.h"
#include "asylum/system/cursor.h"
#include "asylum/system/graphics.h"
#include "asylum/system/screen.h"
#include "asylum/system/sound.h"
#include "asylum/system/text.h"
+#include "asylum/system/video.h"
#include "asylum/views/scene.h"
@@ -50,7 +53,7 @@ MainMenu::MainMenu(AsylumEngine *vm): _vm(vm) {
_cursorStep = 1;
_creditsBgFrame = 0;
_creditsTextScroll = 0x1E0 - 30;
- _activeMenuScreen = kMainMenu;
+ _activeScreen = kMenuMain;
_active = false;
Config.gammaLevel = 2;
@@ -59,15 +62,11 @@ MainMenu::MainMenu(AsylumEngine *vm): _vm(vm) {
_bgResource = new GraphicResource(_vm, MAKE_RESOURCE(kResourcePackShared, 0));
_eyeResource = new GraphicResource(_vm, MAKE_RESOURCE(kResourcePackShared, 1));
- _ev = NULL;
-
- _cursor = new Cursor(_vm);
-
_iconResource = 0;
_creditsResource = 0;
_creditsFadeResource = 0;
- loadFont(kFontYellow);
+ getText()->loadFont(kFontYellow);
}
MainMenu::~MainMenu() {
@@ -75,100 +74,173 @@ MainMenu::~MainMenu() {
delete _creditsFadeResource;
delete _iconResource;
delete _eyeResource;
- delete _cursor;
delete _bgResource;
// Zero-out passed pointers
- _ev = NULL;
_vm = NULL;
}
-void MainMenu::loadFont(Fonts font) {
- switch (font) {
- default:
- error("[MainMenu::loadFont] Unknown font color specified!");
+//////////////////////////////////////////////////////////////////////////
+// Loading and setup
+//////////////////////////////////////////////////////////////////////////
+void MainMenu::show() {
+ getSharedData()->setSkipDrawScene(true);
+ getScreen()->clear();
- case kFontBlue:
- getText()->loadFont(MAKE_RESOURCE(kResourcePackShared, 22));
- break;
+ // Set ourselves as the current event handler
+ _vm->switchEventHandler(this);
- case kFontYellow:
- getText()->loadFont(MAKE_RESOURCE(kResourcePackShared, 16));
- break;
+ getSound()->stopAll();
+
+ _activeScreen = kMenuReturnToGame;
+ _soundResourceId = kResourceNone;
+ _allowInteraction = false;
+
+ _dword_4562C4 = 480;
+ _dword_45628C = 0;
+
+ setup();
+}
+
+void MainMenu::setup() {
+ getScreen()->clear();
+ // Original fills the screen with black
+
+ getCursor()->hide();
+
+ getSharedData()->setFlag(kFlag1, true);
+
+ if (_vm->isGameFlagSet(kGameFlagFinishGame)) {
+ getText()->loadFont(MAKE_RESOURCE(kResourcePackShared, 32));
+ getScreen()->setPalette(MAKE_RESOURCE(kResourcePackShared, 31));
+ getScreen()->setGammaLevel(MAKE_RESOURCE(kResourcePackShared, 31), 0);
+ getScreen()->setupTransTables(4, MAKE_RESOURCE(kResourcePackShared, 34),
+ MAKE_RESOURCE(kResourcePackShared, 35),
+ MAKE_RESOURCE(kResourcePackShared, 36),
+ MAKE_RESOURCE(kResourcePackShared, 37));
+ getScreen()->selectTransTable(1);
+
+ _dword_455D4C = false;
+ _dword_455D5C = false;
+
+ getSound()->playSound(MAKE_RESOURCE(kResourcePackShared, 56), false, Config.voiceVolume);
+ } else {
+ getText()->loadFont(MAKE_RESOURCE(kResourcePackShared, 25));
+ getScreen()->setPalette(MAKE_RESOURCE(kResourcePackShared, 26));
+ getScreen()->setGammaLevel(MAKE_RESOURCE(kResourcePackShared, 26), 0);
+ getScreen()->setupTransTables(4, MAKE_RESOURCE(kResourcePackShared, 27),
+ MAKE_RESOURCE(kResourcePackShared, 28),
+ MAKE_RESOURCE(kResourcePackShared, 29),
+ MAKE_RESOURCE(kResourcePackShared, 30));
+ getScreen()->selectTransTable(1);
+
+ getSound()->playMusic(kResourceNone, 0);
+ getSound()->playMusic(MAKE_RESOURCE(kResourcePackShared, 38));
}
}
void MainMenu::switchFont(bool condition) {
- loadFont((condition) ? kFontYellow : kFontBlue);
+ getText()->loadFont((condition) ? kFontYellow : kFontBlue);
}
-void MainMenu::openMenu() {
- _active = true;
+//////////////////////////////////////////////////////////////////////////
+// Event Handler
+//////////////////////////////////////////////////////////////////////////
+bool MainMenu::handleEvent(const AsylumEvent &evt) {
+ switch ((uint32)evt.type) {
+ default:
+ break;
+
+ case EVENT_ASYLUM_INIT:
+ return init();
+ break;
+
+ case EVENT_ASYLUM_UPDATE:
+ return update();
+ break;
+
+ case EVENT_ASYLUM_MUSIC:
+ return music();
+ break;
- if (_vm->scene()) {
- _vm->scene()->deactivate();
+ case Common::EVENT_KEYDOWN:
+ return key(evt);
+ break;
+
+ case Common::EVENT_LBUTTONDOWN:
+ case Common::EVENT_LBUTTONUP:
+ case Common::EVENT_RBUTTONDOWN:
+ case Common::EVENT_RBUTTONUP:
+ return mouse(evt);
+ break;
}
- loadFont(kFontYellow);
+ return false;
+}
- // Load the graphics palette
- getScreen()->setPalette(MAKE_RESOURCE(kResourcePackShared, 17));
- getScreen()->draw(MAKE_RESOURCE(kResourcePackShared, 0), 1, 0, 0, 0);
+bool MainMenu::init() {
+ // Original writes sntrm_k.txt
- // Set mouse cursor
- _cursor->set(MAKE_RESOURCE(kResourcePackShared, 2));
- _cursor->show();
+ if (_needEyeCursorInit) {
+ getCursor()->set(MAKE_RESOURCE(kResourcePackShared, 3), 0, 2);
+ } else {
+ // Init the game if not already done
+ if (!_initGame) {
+ _initGame = true;
- // Stop all sounds
- _vm->sound()->stopMusic();
- _vm->sound()->stopAll();
+ // The original load the config here (this is done when constructing the config object)
+ // TODO initialize viewed cinematics
+ _vm->init();
- // Start playing music
- _vm->sound()->playMusic(MAKE_RESOURCE(kResourcePackShared, 39));
+ _needEyeCursorInit = true;
- _previousActiveIcon = _activeIcon = -1;
- _leftClick = false;
- _activeMenuScreen = kMainMenu;
-}
+ // Play start video
+ getVideo()->playVideo(0);
-void MainMenu::closeMenu() {
- _active = false;
- if (_vm->scene()) {
- _vm->scene()->activate();
- }
+ /*if (!getSaveLoad()->setupSavegames()) {
+ _vm->restart();
+ return true;
+ }*/
- // Stop menu sounds and menu music
- _vm->sound()->stopAll();
- _vm->sound()->stopMusic();
-}
+ // The original preloads graphics
-void MainMenu::showOptions() {
- error("[MainMenu::showOptions] : not implemented!");
-}
+ getCursor()->show();
+ }
-void MainMenu::handleEvent(Common::Event *event, bool doUpdate) {
- _ev = event;
+ _dword_4562C0 = 0;
+ _activeScreen = kMenuNone;
+ _dword_4464BC = -1;
+ _dword_455C74 = 0;
- switch (_ev->type) {
- case Common::EVENT_MOUSEMOVE:
- _cursor->move(_ev->mouse.x, _ev->mouse.y);
- break;
- case Common::EVENT_LBUTTONUP:
- _leftClick = true;
- break;
- default:
- break;
+ getCursor()->hide();
+ getCursor()->set(MAKE_RESOURCE(kResourcePackShared, 2), 0, 2);
}
- if (doUpdate || _leftClick)
- update();
+ if (_allowInteraction)
+ getScene()->getActor()->update_409230();
+
+ getScreen()->clear();
+ getText()->loadFont(kFontYellow);
+ getScreen()->setPalette(MAKE_RESOURCE(kResourcePackShared, 17));
+ getScreen()->setGammaLevel(MAKE_RESOURCE(kResourcePackShared, 17), 0);
+ getScreen()->setupTransTables(4, MAKE_RESOURCE(kResourcePackShared, 18),
+ MAKE_RESOURCE(kResourcePackShared, 19),
+ MAKE_RESOURCE(kResourcePackShared, 20),
+ MAKE_RESOURCE(kResourcePackShared, 21));
+ getScreen()->selectTransTable(1);
+
+ // Update the screen
+ g_system->updateScreen();
+
+ getCursor()->show();
+ return true;
}
-void MainMenu::update() {
+bool MainMenu::update() {
updateEyesAnimation();
- _cursor->animate();
+ //getCursor()->animate();
- if (_activeMenuScreen == kMainMenu) {
+ if (_activeScreen == kMenuMain) {
updateMainMenu();
} else {
updateSubMenu();
@@ -181,47 +253,47 @@ void MainMenu::update() {
// Copy the dark background to the back buffer
getScreen()->draw(MAKE_RESOURCE(kResourcePackShared, 0), 0, 0, 0, 0);
- _activeMenuScreen = (MenuScreen) _activeIcon;
+ _activeScreen = (MenuScreen) _activeIcon;
// Set the cursor
- _cursor->set(MAKE_RESOURCE(kResourcePackShared, 3));
+ getCursor()->set(MAKE_RESOURCE(kResourcePackShared, 3));
}
switch (_activeIcon) {
default:
break;
- case kNewGame:
+ case kMenuNewGame:
// Nothing here
break;
- case kLoadGame:
+ case kMenuLoadGame:
// TODO
break;
- case kSaveGame:
+ case kMenuSaveGame:
// TODO
break;
- case kDeleteGame:
+ case kMenuDeleteGame:
// TODO
break;
- case kViewCinematics:
+ case kMenuViewCinematics:
// TODO
break;
- case kQuitGame:
+ case kMenuQuitGame:
// Nothing here
break;
- case kTextOptions:
+ case kMenuTextOptions:
// TODO
break;
- case kAudioOptions:
+ case kMenuAudioOptions:
// TODO
break;
- case kSettings:
+ case kMenuSettings:
// TODO
break;
- case kKeyboardConfig:
+ case kMenuKeyboardConfig:
// TODO
break;
- case kShowCredits:
+ case kMenuShowCredits:
// TODO if game finished (gameFlag=901) then show resource image 33 and music 56 and than music 40
if (!_creditsResource)
_creditsResource = new GraphicResource(_vm, MAKE_RESOURCE(kResourcePackShared, 24));
@@ -235,37 +307,67 @@ void MainMenu::update() {
// Start playing music
getSound()->playMusic(MAKE_RESOURCE(kResourcePackShared, 38));
break;
- case kReturnToGame:
+ case kMenuReturnToGame:
if (_vm->scene()) // FIXME: do this properly
- closeMenu();
+ // TODO closeMenu();
break;
}
}
+
+ return true;
+}
+
+bool MainMenu::music() {
+ if (_activeScreen == kMenuReturnToGame
+ && _vm->isGameFlagSet(kGameFlagFinishGame)
+ && !_dword_455D5C
+ && !_dword_455D4C) {
+ _dword_455D5C = true;
+
+ getSound()->playMusic(kResourceNone, 0);
+ getSound()->playMusic(MAKE_RESOURCE(kResourcePackShared, 38));
+
+ return true;
+ }
+
+ return false;
+}
+
+bool MainMenu::key(const AsylumEvent &evt) {
+ // TODO handle per-screen keyboard shortcuts
+ return true;
+}
+
+bool MainMenu::mouse(const AsylumEvent &evt) {
+ return true;
}
+//////////////////////////////////////////////////////////////////////////
+// Update / key / mouse event handlers
+//////////////////////////////////////////////////////////////////////////
void MainMenu::updateEyesAnimation() {
// Eyes animation
// Get the appropriate eye resource depending on the mouse position
uint32 eyeFrameNum = kEyesFront;
- if (_cursor->position().x <= 200) {
- if (_cursor->position().y <= 160)
+ if (getCursor()->position().x <= 200) {
+ if (getCursor()->position().y <= 160)
eyeFrameNum = kEyesTopLeft;
- else if (_cursor->position().y > 160 && _cursor->position().y <= 320)
+ else if (getCursor()->position().y > 160 && getCursor()->position().y <= 320)
eyeFrameNum = kEyesLeft;
else
eyeFrameNum = kEyesBottomLeft;
- } else if (_cursor->position().x > 200 && _cursor->position().x <= 400) {
- if (_cursor->position().y <= 160)
+ } else if (getCursor()->position().x > 200 && getCursor()->position().x <= 400) {
+ if (getCursor()->position().y <= 160)
eyeFrameNum = kEyesTop;
- else if (_cursor->position().y > 160 && _cursor->position().y <= 320)
+ else if (getCursor()->position().y > 160 && getCursor()->position().y <= 320)
eyeFrameNum = kEyesFront;
else
eyeFrameNum = kEyesBottom;
- } else if (_cursor->position().x > 400) {
- if (_cursor->position().y <= 160)
+ } else if (getCursor()->position().x > 400) {
+ if (getCursor()->position().y <= 160)
eyeFrameNum = kEyesTopRight;
- else if (_cursor->position().y > 160 && _cursor->position().y <= 320)
+ else if (getCursor()->position().y > 160 && getCursor()->position().y <= 320)
eyeFrameNum = kEyesRight;
else
eyeFrameNum = kEyesBottomRight;
@@ -279,9 +381,9 @@ void MainMenu::updateEyesAnimation() {
void MainMenu::updateMainMenu() {
int32 rowId = 0;
- if (_cursor->position().y >= 20 && _cursor->position().y <= 20 + 48) {
+ if (getCursor()->position().y >= 20 && getCursor()->position().y <= 20 + 48) {
rowId = 0; // Top row
- } else if (_cursor->position().y >= 400 && _cursor->position().y <= 400 + 48) {
+ } else if (getCursor()->position().y >= 400 && getCursor()->position().y <= 400 + 48) {
rowId = 1; // Bottom row
} else {
// No row selected
@@ -290,12 +392,12 @@ void MainMenu::updateMainMenu() {
return;
}
- loadFont(kFontYellow);
+ getText()->loadFont(kFontYellow);
// Icon animation
for (int32 i = 0; i <= 5; i++) {
int32 curX = 40 + i * 100;
- if (_cursor->position().x >= curX && _cursor->position().x <= curX + 55) {
+ if (getCursor()->position().x >= curX && getCursor()->position().x <= curX + 55) {
int32 iconNum = i + 6 * rowId;
_activeIcon = iconNum;
@@ -320,7 +422,7 @@ void MainMenu::updateMainMenu() {
_curIconFrame = 0;
// Show text
- _vm->text()->drawCentered(MenuIconFixedXpos[iconNum],
+ getText()->drawCentered(MenuIconFixedXpos[iconNum],
iconFrame->y + 50,
getText()->getWidth(MAKE_RESOURCE(kResourcePackText, iconNum + 1309)),
MAKE_RESOURCE(kResourcePackText, iconNum + 1309));
@@ -349,173 +451,173 @@ void MainMenu::updateSubMenu() {
default:
break;
- case kNewGame:
+ case kMenuNewGame:
updateSubMenuNewGame();
break;
- case kLoadGame:
+ case kMenuLoadGame:
// TODO
break;
- case kSaveGame:
+ case kMenuSaveGame:
// TODO
break;
- case kDeleteGame:
+ case kMenuDeleteGame:
// TODO
break;
- case kViewCinematics:
+ case kMenuViewCinematics:
updateSubMenuCinematics();
break;
- case kQuitGame:
+ case kMenuQuitGame:
updateSubMenuQuitGame();
break;
- case kTextOptions:
+ case kMenuTextOptions:
// TODO
break;
- case kAudioOptions:
+ case kMenuAudioOptions:
// TODO
break;
- case kSettings:
+ case kMenuSettings:
updateSubMenuSettings();
break;
- case kKeyboardConfig:
+ case kMenuKeyboardConfig:
// TODO
break;
- case kShowCredits:
+ case kMenuShowCredits:
updateSubMenuShowCredits();
break;
- case kReturnToGame:
+ case kMenuReturnToGame:
updateSubMenuReturnToGame();
break;
}
}
void MainMenu::updateSubMenuNewGame() {
- loadFont(kFontYellow);
+ getText()->loadFont(kFontYellow);
// begin new game
- _vm->text()->drawCentered(10, 100, 620, MAKE_RESOURCE(kResourcePackText, 529));
+ getText()->drawCentered(10, 100, 620, MAKE_RESOURCE(kResourcePackText, 529));
// Yes
- switchFont(_cursor->position().x < 247 || _cursor->position().x > 247 + _vm->text()->getWidth(MAKE_RESOURCE(kResourcePackText, 1322)) || _cursor->position().y < 273 || _cursor->position().y > 273 + 24);
- _vm->text()->setPosition(247, 273);
- _vm->text()->draw(MAKE_RESOURCE(kResourcePackText, 1322));
+ switchFont(getCursor()->position().x < 247 || getCursor()->position().x > 247 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 1322)) || getCursor()->position().y < 273 || getCursor()->position().y > 273 + 24);
+ getText()->setPosition(247, 273);
+ getText()->draw(MAKE_RESOURCE(kResourcePackText, 1322));
// No
- switchFont(_cursor->position().x < 369 || _cursor->position().x > 369 + _vm->text()->getWidth(MAKE_RESOURCE(kResourcePackText, 1323)) || _cursor->position().y < 273 || _cursor->position().y > 273 + 24);
- _vm->text()->setPosition(369, 273);
- _vm->text()->draw(MAKE_RESOURCE(kResourcePackText, 1323));
+ switchFont(getCursor()->position().x < 369 || getCursor()->position().x > 369 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 1323)) || getCursor()->position().y < 273 || getCursor()->position().y > 273 + 24);
+ getText()->setPosition(369, 273);
+ getText()->draw(MAKE_RESOURCE(kResourcePackText, 1323));
// action
if (_leftClick) {
// Yes
- if (_cursor->position().x >= 247 && _cursor->position().x <= 247 + 24 && _cursor->position().y >= 273 && _cursor->position().y <= 273 + _vm->text()->getWidth(MAKE_RESOURCE(kResourcePackText, 1322))) {
+ if (getCursor()->position().x >= 247 && getCursor()->position().x <= 247 + 24 && getCursor()->position().y >= 273 && getCursor()->position().y <= 273 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 1322))) {
_leftClick = false;
- closeMenu();
+ // TODO closeMenu();
_vm->startGame(kResourcePackTowerCells, AsylumEngine::kStartGamePlayIntro);
}
// No
- if (_cursor->position().x >= 369 && _cursor->position().x <= 369 + 24 && _cursor->position().y >= 273 && _cursor->position().y <= 273 + _vm->text()->getWidth(MAKE_RESOURCE(kResourcePackText, 1323)))
+ if (getCursor()->position().x >= 369 && getCursor()->position().x <= 369 + 24 && getCursor()->position().y >= 273 && getCursor()->position().y <= 273 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 1323)))
exitSubMenu();
}
}
void MainMenu::updateSubMenuCinematics() {
int32 currentCD = 1; // FIXME: dummy value
- _vm->text()->drawCentered(10, 100, 620, MAKE_RESOURCE(kResourcePackText, 1352), currentCD);
- _vm->text()->setPosition(30, 340);
- _vm->text()->draw(MAKE_RESOURCE(kResourcePackText, 1353)); // Prev Page
+ getText()->drawCentered(10, 100, 620, MAKE_RESOURCE(kResourcePackText, 1352), currentCD);
+ getText()->setPosition(30, 340);
+ getText()->draw(MAKE_RESOURCE(kResourcePackText, 1353)); // Prev Page
- if (_cursor->position().x >= 280 && _cursor->position().x <= 400 && _cursor->position().y >= 340 && _cursor->position().y <= 360) {
- loadFont(kFontBlue);
+ if (getCursor()->position().x >= 280 && getCursor()->position().x <= 400 && getCursor()->position().y >= 340 && getCursor()->position().y <= 360) {
+ getText()->loadFont(kFontBlue);
if (_leftClick)
exitSubMenu();
} else {
- loadFont(kFontYellow);
+ getText()->loadFont(kFontYellow);
}
- _vm->text()->setPosition(280, 340);
- _vm->text()->draw(MAKE_RESOURCE(kResourcePackText, 1355)); // Main Menu
+ getText()->setPosition(280, 340);
+ getText()->draw(MAKE_RESOURCE(kResourcePackText, 1355)); // Main Menu
- loadFont(kFontYellow);
+ getText()->loadFont(kFontYellow);
- _vm->text()->setPosition(500, 340);
- _vm->text()->draw(MAKE_RESOURCE(kResourcePackText, 1354)); // Next Page
+ getText()->setPosition(500, 340);
+ getText()->draw(MAKE_RESOURCE(kResourcePackText, 1354)); // Next Page
}
void MainMenu::updateSubMenuSettings() {
- int32 sizeMinus = _vm->text()->getWidth("-");
- int32 sizePlus = _vm->text()->getWidth("+");
- int32 sizeMainMenu = _vm->text()->getWidth(MAKE_RESOURCE(kResourcePackText, 1437));
+ int32 sizeMinus = getText()->getWidth("-");
+ int32 sizePlus = getText()->getWidth("+");
+ int32 sizeMainMenu = getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 1437));
- loadFont(kFontYellow);
+ getText()->loadFont(kFontYellow);
// Settings
- _vm->text()->drawCentered(10, 100, 620, MAKE_RESOURCE(kResourcePackText, 1432));
+ getText()->drawCentered(10, 100, 620, MAKE_RESOURCE(kResourcePackText, 1432));
// gamma correction
- _vm->text()->drawAlignedRight(320, 150, MAKE_RESOURCE(kResourcePackText, 1433));
- switchFont(_cursor->position().x < 350 || _cursor->position().x > sizeMinus + 350 || _cursor->position().y < 150 || _cursor->position().y > 174);
- _vm->text()->setPosition(350, 150);
- _vm->text()->draw("-");
+ getText()->drawAlignedRight(320, 150, MAKE_RESOURCE(kResourcePackText, 1433));
+ switchFont(getCursor()->position().x < 350 || getCursor()->position().x > sizeMinus + 350 || getCursor()->position().y < 150 || getCursor()->position().y > 174);
+ getText()->setPosition(350, 150);
+ getText()->draw("-");
- switchFont(_cursor->position().x < sizeMinus + 360 || _cursor->position().x > sizeMinus + sizePlus + 360 || _cursor->position().y < 150 || _cursor->position().y > 174);
- _vm->text()->setPosition(sizeMinus + 360, 150);
- _vm->text()->draw("+");
+ switchFont(getCursor()->position().x < sizeMinus + 360 || getCursor()->position().x > sizeMinus + sizePlus + 360 || getCursor()->position().y < 150 || getCursor()->position().y > 174);
+ getText()->setPosition(sizeMinus + 360, 150);
+ getText()->draw("+");
- _vm->text()->setPosition(sizeMinus + sizePlus + 365, 150);
- loadFont(kFontYellow);
+ getText()->setPosition(sizeMinus + sizePlus + 365, 150);
+ getText()->loadFont(kFontYellow);
if (Config.gammaLevel) {
for (int32 i = 0; i < Config.gammaLevel; i++) {
- _vm->text()->draw("]");
+ getText()->draw("]");
}
if (Config.gammaLevel == 8)
- _vm->text()->draw("*");
+ getText()->draw("*");
} else
- _vm->text()->draw(MAKE_RESOURCE(kResourcePackText, 1435));
+ getText()->draw(MAKE_RESOURCE(kResourcePackText, 1435));
// performance
- loadFont(kFontYellow);
- _vm->text()->drawAlignedRight(320, 179, MAKE_RESOURCE(kResourcePackText, 1434));
- switchFont(_cursor->position().x < 350 || _cursor->position().x > sizeMinus + 350 || _cursor->position().y < 179 || _cursor->position().y > 203);
- _vm->text()->setPosition(350, 179);
- _vm->text()->draw("-");
-
- switchFont(_cursor->position().x < sizeMinus + 360 || _cursor->position().x > sizeMinus + sizePlus + 360 || _cursor->position().y < 179 || _cursor->position().y > 203);
- _vm->text()->setPosition(sizeMinus + 360, 179);
- _vm->text()->draw("+");
-
- _vm->text()->setPosition(sizeMinus + sizePlus + 365, 179);
- loadFont(kFontYellow);
+ getText()->loadFont(kFontYellow);
+ getText()->drawAlignedRight(320, 179, MAKE_RESOURCE(kResourcePackText, 1434));
+ switchFont(getCursor()->position().x < 350 || getCursor()->position().x > sizeMinus + 350 || getCursor()->position().y < 179 || getCursor()->position().y > 203);
+ getText()->setPosition(350, 179);
+ getText()->draw("-");
+
+ switchFont(getCursor()->position().x < sizeMinus + 360 || getCursor()->position().x > sizeMinus + sizePlus + 360 || getCursor()->position().y < 179 || getCursor()->position().y > 203);
+ getText()->setPosition(sizeMinus + 360, 179);
+ getText()->draw("+");
+
+ getText()->setPosition(sizeMinus + sizePlus + 365, 179);
+ getText()->loadFont(kFontYellow);
if (Config.performance == 5) {
- _vm->text()->draw(MAKE_RESOURCE(kResourcePackText, 1436));
+ getText()->draw(MAKE_RESOURCE(kResourcePackText, 1436));
} else {
for (int32 i = 5; i > Config.performance; --i) {
- _vm->text()->draw("]");
+ getText()->draw("]");
}
if (!Config.performance)
- _vm->text()->draw("*");
+ getText()->draw("*");
}
// back to main menu
- switchFont(_cursor->position().x < 300 || _cursor->position().x > 300 + sizeMainMenu || _cursor->position().y < 340 || _cursor->position().y > 340 + 24);
- _vm->text()->setPosition(300, 340);
- _vm->text()->draw(MAKE_RESOURCE(kResourcePackText, 1437));
+ switchFont(getCursor()->position().x < 300 || getCursor()->position().x > 300 + sizeMainMenu || getCursor()->position().y < 340 || getCursor()->position().y > 340 + 24);
+ getText()->setPosition(300, 340);
+ getText()->draw(MAKE_RESOURCE(kResourcePackText, 1437));
// action
if (_leftClick) {
// back to main menu
- if (_cursor->position().x >= 300 && _cursor->position().x <= 300 + sizeMainMenu && _cursor->position().y >= 340 && _cursor->position().y <= 340 + 24) {
+ if (getCursor()->position().x >= 300 && getCursor()->position().x <= 300 + sizeMainMenu && getCursor()->position().y >= 340 && getCursor()->position().y <= 340 + 24) {
// TODO: save new configurations
exitSubMenu();
}
// gamma level minus
- if (_cursor->position().x >= 350 && _cursor->position().x <= sizeMinus + 350 && _cursor->position().y >= 150 && _cursor->position().y <= 174) {
+ if (getCursor()->position().x >= 350 && getCursor()->position().x <= sizeMinus + 350 && getCursor()->position().y >= 150 && getCursor()->position().y <= 174) {
if (Config.gammaLevel) {
Config.gammaLevel -= 1;
// TODO: setResGammaLevel(0x80010011, 0);
}
}
// gamma level plus
- if (_cursor->position().x >= sizeMinus + 360 && _cursor->position().x <= sizeMinus + sizePlus + 360 && _cursor->position().y >= 150 && _cursor->position().y <= 174) {
+ if (getCursor()->position().x >= sizeMinus + 360 && getCursor()->position().x <= sizeMinus + sizePlus + 360 && getCursor()->position().y >= 150 && getCursor()->position().y <= 174) {
if (Config.gammaLevel < 8) {
Config.gammaLevel += 1;
// TODO: setResGammaLevel(0x80010011, 0);
@@ -523,14 +625,14 @@ void MainMenu::updateSubMenuSettings() {
}
// performance minus
- if (_cursor->position().x >= 350 && _cursor->position().x <= sizeMinus + 350 && _cursor->position().y >= 179 && _cursor->position().y <= 203) {
+ if (getCursor()->position().x >= 350 && getCursor()->position().x <= sizeMinus + 350 && getCursor()->position().y >= 179 && getCursor()->position().y <= 203) {
if (Config.performance) {
Config.performance -= 1;
// TODO: change quality settings
}
}
// performance plus
- if (_cursor->position().x >= sizeMinus + 360 && _cursor->position().x <= sizeMinus + sizePlus + 360 && _cursor->position().y >= 179 && _cursor->position().y <= 203) {
+ if (getCursor()->position().x >= sizeMinus + 360 && getCursor()->position().x <= sizeMinus + sizePlus + 360 && getCursor()->position().y >= 179 && getCursor()->position().y <= 203) {
if (Config.performance < 5) {
Config.performance += 1;
// TODO: change quality settings
@@ -540,25 +642,25 @@ void MainMenu::updateSubMenuSettings() {
}
void MainMenu::updateSubMenuQuitGame() {
- loadFont(kFontYellow);
+ getText()->loadFont(kFontYellow);
// begin new game
- _vm->text()->drawCentered(10, 100, 620, MAKE_RESOURCE(kResourcePackText, 1408));
+ getText()->drawCentered(10, 100, 620, MAKE_RESOURCE(kResourcePackText, 1408));
// Yes
- switchFont(_cursor->position().x < 247 || _cursor->position().x > 247 + _vm->text()->getWidth(MAKE_RESOURCE(kResourcePackText, 581)) || _cursor->position().y < 273 || _cursor->position().y > 273 + 24);
- _vm->text()->setPosition(247, 273);
- _vm->text()->draw(MAKE_RESOURCE(kResourcePackText, 1409));
+ switchFont(getCursor()->position().x < 247 || getCursor()->position().x > 247 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 581)) || getCursor()->position().y < 273 || getCursor()->position().y > 273 + 24);
+ getText()->setPosition(247, 273);
+ getText()->draw(MAKE_RESOURCE(kResourcePackText, 1409));
// No
- switchFont(_cursor->position().x < 369 || _cursor->position().x > 369 + _vm->text()->getWidth(MAKE_RESOURCE(kResourcePackText, 582)) || _cursor->position().y < 273 || _cursor->position().y > 273 + 24);
- _vm->text()->setPosition(369, 273);
- _vm->text()->draw(MAKE_RESOURCE(kResourcePackText, 1410));
+ switchFont(getCursor()->position().x < 369 || getCursor()->position().x > 369 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 582)) || getCursor()->position().y < 273 || getCursor()->position().y > 273 + 24);
+ getText()->setPosition(369, 273);
+ getText()->draw(MAKE_RESOURCE(kResourcePackText, 1410));
// action
if (_leftClick) {
// Yes
- if (_cursor->position().x >= 247 && _cursor->position().x <= 247 + 24 && _cursor->position().y >= 273 && _cursor->position().y <= 273 + _vm->text()->getWidth(MAKE_RESOURCE(kResourcePackText, 1409))) {
+ if (getCursor()->position().x >= 247 && getCursor()->position().x <= 247 + 24 && getCursor()->position().y >= 273 && getCursor()->position().y <= 273 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 1409))) {
_leftClick = false;
// User clicked on quit, so push a quit event
@@ -567,7 +669,7 @@ void MainMenu::updateSubMenuQuitGame() {
g_system->getEventManager()->pushEvent(event);
}
// No
- if (_cursor->position().x >= 369 && _cursor->position().x <= 369 + 24 && _cursor->position().y >= 273 && _cursor->position().y <= 273 + _vm->text()->getWidth(MAKE_RESOURCE(kResourcePackText, 1410)))
+ if (getCursor()->position().x >= 369 && getCursor()->position().x <= 369 + 24 && getCursor()->position().y >= 273 && getCursor()->position().y <= 273 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 1410)))
exitSubMenu();
}
}
@@ -608,8 +710,8 @@ void MainMenu::updateSubMenuShowCredits() {
posY = _creditsTextScroll;
}
- _vm->text()->setPosition(320, step + posY);
- _vm->text()->draw((ResourceId)(resourceId - 2147482201));
+ getText()->setPosition(320, step + posY);
+ getText()->draw((ResourceId)(resourceId - 2147482201));
posY = _creditsTextScroll;
}
step += 24;
@@ -635,30 +737,30 @@ void MainMenu::updateSubMenuShowCredits() {
void MainMenu::exitSubMenu() {
_leftClick = false;
- _activeMenuScreen = kMainMenu;
+ _activeScreen = kMenuMain;
// Copy the bright background to the back buffer
getScreen()->draw(MAKE_RESOURCE(kResourcePackShared, 0), 1, 0, 0, 0);
// Set the cursor
- _cursor->set(MAKE_RESOURCE(kResourcePackShared, 2));
+ getCursor()->set(MAKE_RESOURCE(kResourcePackShared, 2));
}
void MainMenu::updateSubMenuReturnToGame() {
- loadFont(kFontYellow);
+ getText()->loadFont(kFontYellow);
// no game loaded
- _vm->text()->drawCentered(10, 100, 620, MAKE_RESOURCE(kResourcePackText, 712));
+ getText()->drawCentered(10, 100, 620, MAKE_RESOURCE(kResourcePackText, 712));
// Main menu
- switchFont(_cursor->position().x < 285 || _cursor->position().x > 285 + _vm->text()->getWidth(MAKE_RESOURCE(kResourcePackText, 713)) || _cursor->position().y < 273 || _cursor->position().y > 273 + 24);
- _vm->text()->setPosition(285, 273);
- _vm->text()->draw(MAKE_RESOURCE(kResourcePackText, 713));
+ switchFont(getCursor()->position().x < 285 || getCursor()->position().x > 285 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 713)) || getCursor()->position().y < 273 || getCursor()->position().y > 273 + 24);
+ getText()->setPosition(285, 273);
+ getText()->draw(MAKE_RESOURCE(kResourcePackText, 713));
// action
if (_leftClick) {
// Main menu
- if (_cursor->position().x >= 285 && _cursor->position().x <= 285 + _vm->text()->getWidth(MAKE_RESOURCE(kResourcePackText, 713)) && _cursor->position().y >= 273 && _cursor->position().y <= 273 + 24)
+ if (getCursor()->position().x >= 285 && getCursor()->position().x <= 285 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 713)) && getCursor()->position().y >= 273 && getCursor()->position().y <= 273 + 24)
exitSubMenu();
}
}
diff --git a/engines/asylum/views/menu.h b/engines/asylum/views/menu.h
index eb361af88e..13b392c49e 100644
--- a/engines/asylum/views/menu.h
+++ b/engines/asylum/views/menu.h
@@ -26,7 +26,8 @@
#ifndef ASYLUM_MENU_H
#define ASYLUM_MENU_H
-#include "common/events.h"
+#include "asylum/eventhandler.h"
+#include "asylum/shared.h"
namespace Asylum {
@@ -37,20 +38,24 @@ class ResourcePack;
class Scene;
class Text;
-class MainMenu {
+class MainMenu : public EventHandler {
public:
MainMenu(AsylumEngine *vm);
~MainMenu();
- void handleEvent(Common::Event *event, bool doUpdate);
- bool isActive() {
- return _active;
- }
-
- void openMenu();
- void closeMenu();
+ /**
+ * Shows the menu
+ */
+ void show();
- void showOptions();
+ /**
+ * Handle event.
+ *
+ * @param evt The event.
+ *
+ * @return true if it succeeds, false if it fails.
+ */
+ bool handleEvent(const AsylumEvent &evt);
private:
AsylumEngine *_vm;
@@ -69,29 +74,27 @@ private:
};
enum MenuScreen {
- kNewGame = 0,
- kLoadGame = 1,
- kSaveGame = 2,
- kDeleteGame = 3,
- kViewCinematics = 4,
- kQuitGame = 5,
- kTextOptions = 6,
- kAudioOptions = 7,
- kSettings = 8,
- kKeyboardConfig = 9,
- kShowCredits = 10,
- kReturnToGame = 11,
- kMainMenu = 12
+ kMenuNone = -1,
+ kMenuNewGame = 0,
+ kMenuLoadGame = 1,
+ kMenuSaveGame = 2,
+ kMenuDeleteGame = 3,
+ kMenuViewCinematics = 4,
+ kMenuQuitGame = 5,
+ kMenuTextOptions = 6,
+ kMenuAudioOptions = 7,
+ kMenuSettings = 8,
+ kMenuKeyboardConfig = 9,
+ kMenuShowCredits = 10,
+ kMenuReturnToGame = 11,
+ kMenuMain = 12
};
enum Fonts {
- kFontBlue,
- kFontYellow
+ kFontBlue = MAKE_RESOURCE(kResourcePackShared, 22),
+ kFontYellow = MAKE_RESOURCE(kResourcePackShared, 16)
};
- Common::Event *_ev;
-
- Cursor *_cursor;
int32 _activeIcon;
int32 _previousActiveIcon;
uint32 _curIconFrame;
@@ -102,20 +105,48 @@ private:
bool _leftClick;
bool _active;
- MenuScreen _activeMenuScreen;
+ // Game initialization
+ bool _initGame;
+
+ // Data
+ MenuScreen _activeScreen;
+ ResourceId _soundResourceId;
+ bool _allowInteraction;
+ int32 _dword_4464BC;
+ int32 _dword_455C74;
+ bool _dword_455D4C;
+ bool _dword_455D5C;
+ int32 _dword_4562C0;
+ int32 _dword_4562C4;
+ int32 _dword_45628C;
+ bool _needEyeCursorInit;
+
GraphicResource *_bgResource;
GraphicResource *_eyeResource;
GraphicResource *_iconResource;
GraphicResource *_creditsResource;
GraphicResource *_creditsFadeResource;
- void loadFont(Fonts font);
/**
- * Determine which font colour to use. If the condition is true,
- * load kFontYellow, if false, load kFontBlue
+ * Setups menu screen
+ */
+ void setup();
+
+ /**
+ * Switch between fonts.
+ *
+ * @param condition if true, load kFontYellow, if false, load kFontBlue.
*/
void switchFont(bool condition);
+ //////////////////////////////////////////////////////////////////////////
+ // Message handling
+ bool init();
+ bool update();
+ bool music();
+ bool key(const AsylumEvent &evt);
+ bool mouse(const AsylumEvent &evt);
+
void updateEyesAnimation();
void updateMainMenu();
@@ -127,9 +158,6 @@ private:
void updateSubMenuQuitGame();
void updateSubMenuShowCredits();
void updateSubMenuReturnToGame();
-
- void update();
-
}; // end of class MainMenu
} // end of namespace Asylum
Commit: 0047d10a67cf4b77d260557ff4c3400e7a67c1bd
https://github.com/scummvm/scummvm/commit/0047d10a67cf4b77d260557ff4c3400e7a67c1bd
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:27+02:00
Commit Message:
ASYLUM: Add Savegame class
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@599 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
A engines/asylum/system/savegame.cpp
A engines/asylum/system/savegame.h
engines/asylum/asylum.cpp
engines/asylum/asylum.h
engines/asylum/module.mk
engines/asylum/shared.h
engines/asylum/views/menu.cpp
diff --git a/engines/asylum/asylum.cpp b/engines/asylum/asylum.cpp
index 0408c9348c..c07518e53a 100644
--- a/engines/asylum/asylum.cpp
+++ b/engines/asylum/asylum.cpp
@@ -32,6 +32,7 @@
#include "asylum/system/config.h"
#include "asylum/system/cursor.h"
+#include "asylum/system/savegame.h"
#include "asylum/system/screen.h"
#include "asylum/system/sound.h"
#include "asylum/system/text.h"
@@ -53,8 +54,9 @@
namespace Asylum {
AsylumEngine::AsylumEngine(OSystem *system, const ADGameDescription *gd) : Engine(system), _gameDescription(gd),
- _console(NULL), _cursor(NULL), _encounter(NULL), _mainMenu(NULL), _resource(NULL), _scene(NULL), _screen(NULL),
- _sound(NULL), _text(NULL), _video(NULL), _introPlaying(false), _handler(NULL) {
+ _console(NULL), _cursor(NULL), _encounter(NULL), _mainMenu(NULL), _resource(NULL), _savegame(NULL),
+ _scene(NULL), _screen(NULL), _sound(NULL), _text(NULL), _video(NULL),
+ _introPlaying(false), _handler(NULL) {
// Init data
memset(&_gameFlags, 0, sizeof(_gameFlags));
@@ -86,6 +88,7 @@ AsylumEngine::~AsylumEngine() {
delete _cursor;
delete _scene;
delete _encounter;
+ delete _savegame;
delete _screen;
delete _sound;
delete _text;
@@ -116,6 +119,7 @@ Common::Error AsylumEngine::run() {
// Create all game classes
_encounter = new Encounter(this);
_cursor = new Cursor(this);
+ _savegame = new Savegame(this);
_screen = new Screen(this);
_sound = new Sound(this, _mixer);
_text = new Text(this);
@@ -124,6 +128,7 @@ Common::Error AsylumEngine::run() {
// Create main menu
_mainMenu = new MainMenu(this);
+ _handler = _mainMenu;
// FIXME: remove
_introPlaying = false;
diff --git a/engines/asylum/asylum.h b/engines/asylum/asylum.h
index 7abed1c627..4441a51cc1 100644
--- a/engines/asylum/asylum.h
+++ b/engines/asylum/asylum.h
@@ -69,6 +69,7 @@ class Cursor;
class Encounter;
class MainMenu;
class ResourceManager;
+class Savegame;
class Scene;
class Screen;
class Sound;
@@ -138,6 +139,7 @@ public:
Encounter *encounter() { return _encounter; }
MainMenu *menu() { return _mainMenu; }
ResourceManager *resource() { return _resource; }
+ Savegame *savegame() { return _savegame; }
Scene *scene() { return _scene; }
Screen *screen() { return _screen; }
Sound *sound() { return _sound; }
@@ -183,6 +185,7 @@ private:
Encounter *_encounter;
MainMenu *_mainMenu;
ResourceManager *_resource;
+ Savegame *_savegame;
Scene *_scene;
Screen *_screen;
Sound *_sound;
@@ -196,7 +199,6 @@ private:
// Shared game data
SharedData _data;
-
bool _introPlaying;
int _gameFlags[1512];
diff --git a/engines/asylum/module.mk b/engines/asylum/module.mk
index 6349462795..341cb3c8c1 100644
--- a/engines/asylum/module.mk
+++ b/engines/asylum/module.mk
@@ -14,6 +14,7 @@ MODULE_OBJS := \
system/config.o \
system/cursor.o \
system/graphics.o \
+ system/savegame.o \
system/screen.o \
system/sound.o \
system/speech.o \
diff --git a/engines/asylum/shared.h b/engines/asylum/shared.h
index 5821e9dadc..e6e7b18af5 100644
--- a/engines/asylum/shared.h
+++ b/engines/asylum/shared.h
@@ -597,14 +597,15 @@ enum ObjectFlag {
#define rnd(val) _vm->getRandom(val)
// Engine subclasses
-#define getSharedData() _vm->getData()
#define getEncounter() _vm->encounter()
#define getCursor() _vm->cursor()
#define getResource() _vm->resource()
#define getSound() _vm->sound()
+#define getSaveLoad() _vm->savegame()
#define getScene() _vm->scene()
#define getScreen() _vm->screen()
#define getScript() _vm->scene()->actions()
+#define getSharedData() _vm->getData()
#define getSpeech() _vm->scene()->speech()
#define getText() _vm->text()
#define getVideo() _vm->video()
diff --git a/engines/asylum/system/savegame.cpp b/engines/asylum/system/savegame.cpp
new file mode 100644
index 0000000000..cc707e7f79
--- /dev/null
+++ b/engines/asylum/system/savegame.cpp
@@ -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.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#include "asylum/system/savegame.h"
+
+#include "asylum/asylum.h"
+
+namespace Asylum {
+
+Savegame::Savegame(AsylumEngine *engine) : _vm(engine) {
+}
+
+Savegame::~Savegame() {
+}
+
+bool Savegame::setup() {
+ warning("[Savegame::setup] Not implemented!");
+
+ return true;
+}
+
+} // End of namespace Asylum
diff --git a/engines/asylum/system/savegame.h b/engines/asylum/system/savegame.h
new file mode 100644
index 0000000000..d28b0b2a7a
--- /dev/null
+++ b/engines/asylum/system/savegame.h
@@ -0,0 +1,46 @@
+/* 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.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#ifndef ASYLUM_SAVEGAME_H
+#define ASYLUM_SAVEGAME_H
+
+namespace Asylum {
+
+class AsylumEngine;
+
+class Savegame {
+public:
+ Savegame(AsylumEngine *engine);
+ ~Savegame();
+
+ bool setup();
+
+private:
+ AsylumEngine* _vm;
+};
+
+} // End of namespace Asylum
+
+#endif // ASYLUM_SAVEGAME_H
diff --git a/engines/asylum/views/menu.cpp b/engines/asylum/views/menu.cpp
index 1d16acbcfb..a352eac9d2 100644
--- a/engines/asylum/views/menu.cpp
+++ b/engines/asylum/views/menu.cpp
@@ -30,6 +30,7 @@
#include "asylum/system/config.h"
#include "asylum/system/cursor.h"
#include "asylum/system/graphics.h"
+#include "asylum/system/savegame.h"
#include "asylum/system/screen.h"
#include "asylum/system/sound.h"
#include "asylum/system/text.h"
@@ -197,10 +198,10 @@ bool MainMenu::init() {
// Play start video
getVideo()->playVideo(0);
- /*if (!getSaveLoad()->setupSavegames()) {
+ if (!getSaveLoad()->setup()) {
_vm->restart();
return true;
- }*/
+ }
// The original preloads graphics
Commit: 8a6d76b65e4a13da1b8467f5d02091e6d6f88a5c
https://github.com/scummvm/scummvm/commit/8a6d76b65e4a13da1b8467f5d02091e6d6f88a5c
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:27+02:00
Commit Message:
ASYLUM: Overhaul event handling
- Cleanup game initialization
- Update event loop to use the defined handler
- Menu is now the default event handler
- Implement eye direction update using existing Actor helper method
- Add stubs for all menu update & click event handlers
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@600 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/asylum.cpp
engines/asylum/asylum.h
engines/asylum/eventhandler.h
engines/asylum/puzzles/vcr.cpp
engines/asylum/resources/actionlist.cpp
engines/asylum/resources/actor.cpp
engines/asylum/resources/actor.h
engines/asylum/resources/data.h
engines/asylum/staticres.h
engines/asylum/system/cursor.cpp
engines/asylum/system/cursor.h
engines/asylum/system/savegame.cpp
engines/asylum/system/savegame.h
engines/asylum/system/screen.cpp
engines/asylum/views/menu.cpp
engines/asylum/views/menu.h
engines/asylum/views/scene.cpp
diff --git a/engines/asylum/asylum.cpp b/engines/asylum/asylum.cpp
index c07518e53a..cb38275b1f 100644
--- a/engines/asylum/asylum.cpp
+++ b/engines/asylum/asylum.cpp
@@ -55,8 +55,7 @@ namespace Asylum {
AsylumEngine::AsylumEngine(OSystem *system, const ADGameDescription *gd) : Engine(system), _gameDescription(gd),
_console(NULL), _cursor(NULL), _encounter(NULL), _mainMenu(NULL), _resource(NULL), _savegame(NULL),
- _scene(NULL), _screen(NULL), _sound(NULL), _text(NULL), _video(NULL),
- _introPlaying(false), _handler(NULL) {
+ _scene(NULL), _screen(NULL), _sound(NULL), _text(NULL), _video(NULL), _handler(NULL) {
// Init data
memset(&_gameFlags, 0, sizeof(_gameFlags));
@@ -130,44 +129,21 @@ Common::Error AsylumEngine::run() {
_mainMenu = new MainMenu(this);
_handler = _mainMenu;
- // FIXME: remove
- _introPlaying = false;
-
- // TODO: save dialog key codes into sntrm_k.txt (need to figure out why they use such thing) (address 00411CD0)
- // load startup configurations (.text:0041A970)
+ // Load config
Config.read();
- // TODO: init unknown game stuffs (.text:0040F430)
- // TODO: if savegame not exists on folder, than start game()
- //if(0) { //SearchMan.hasArchive
- startGame(kResourcePackTowerCells, kStartGamePlayIntro);
- //} else {
- // _mainMenu->openMenu();
- //}
- //
+ // Send init event to our default event handler
+ AsylumEvent initEvt(EVENT_ASYLUM_INIT);
+ _handler->handleEvent(initEvt);
+ // Start running event loop
while (!shouldQuit()) {
- handleEvents(true);
- waitForTimer(55);
- }
-
- return Common::kNoError;
-}
-
-void AsylumEngine::waitForTimer(uint32 msec_delay) {
- uint32 start_time = _system->getMillis();
+ handleEvents();
- while (_system->getMillis() < start_time + msec_delay) {
- handleEvents(false);
- if (_scene) {
- processDelayedEvents();
- }
_system->updateScreen();
}
-}
-void AsylumEngine::init() {
- error("[AsylumEngine::init] Not implemented!");
+ return Common::kNoError;
}
void AsylumEngine::startGame(ResourcePackId sceneId, StartGameType type) {
@@ -217,8 +193,7 @@ void AsylumEngine::playIntro() {
if (!_video || !_screen)
error("[AsylumEngine::playIntro] Subsystems not initialized properly!");
- _introPlaying = true;
- g_system->showMouse(false);
+ _cursor->hide();
if (Config.showIntro)
_video->playVideo(1);
@@ -235,102 +210,49 @@ void AsylumEngine::playIntro() {
_sound->playSound(MAKE_RESOURCE(kResourcePackSound, 7));
}
-void AsylumEngine::handleEvents(bool doUpdate) {
+void AsylumEngine::handleEvents() {
if (!_console || !_video || !_screen || !_sound || !_mainMenu)
error("[AsylumEngine::handleEvents] Subsystems not initialized properly!");
// Show the debugger if required
_console->onFrame();
- // NOTE
- // In the original version of Sanitarium, the control loop for the sound
- // effect that played after the intro video involved a while loop that
- // executed until the sound handle was released.
- // This caused the application to be locked until the while loop's execution
- // completed successfully. Our implementation circumvents this issue
- // by moving the logic to the event loop and checking whether a flag is
- // set to determine if control should be returned to the engine.
- if (_introPlaying) {
- if (!_sound->isPlaying(MAKE_RESOURCE(kResourcePackSound, 7))) {
- _introPlaying = false;
-
- // TODO Since we've currently only got one sfx handle to play with in
- // the sound class, entering the scene overwrites the "alarm" loop.
- // This sound is technically supposed to play until the actor disables
- // the alarm by flipping the switch. The sound class needs to be extended
- // to be able to handle multiple handles.
- // The currently active sound resources can probably also be buffered into
- // the scene's soundResourceId[] array (seems that's the way the original worked,
- // especially when you examine isSoundinList() or isSoundPlaying())
-
- //_scene->enterScene();
- }
- }
-
AsylumEvent ev;
-
if (_eventMan->pollEvent(ev)) {
switch (ev.type) {
default:
break;
case Common::EVENT_KEYDOWN:
- if ((ev.kbd.flags & Common::KBD_CTRL) && ev.kbd.keycode == Common::KEYCODE_d)
+ if ((ev.kbd.flags & Common::KBD_CTRL) && ev.kbd.keycode == Common::KEYCODE_d) {
_console->attach();
-
- if (ev.kbd.keycode == Common::KEYCODE_ESCAPE) {
- // Toggle menu
- /*if (_mainMenu->isActive()) {*/
- if (_scene) {
- //_mainMenu->closeMenu();
- _scene->activate();
- //}
- } else if (_scene && _scene->isActive()) {
- //_mainMenu->openMenu();
- }
- /* FIXME
- } else if (_scene && _scene->getBlowUpPuzzle()->isActive()) {
- _scene->getBlowUpPuzzle()->closeBlowUp();
- _scene->enterScene();
- }
- */
- return;
+ break;
}
- // XXX: TEST ONLY
- /*
- if (ev.kbd.keycode == Common::KEYCODE_b) {
- if (_scene) {
- _scene->getBlowUpPuzzle()->openBlowUp();
- }
- }
- */
+ // Handle key events
+ _handler->handleEvent(ev);
break;
- }
- }
- if (doUpdate) {
- //if (_mainMenu->isActive() || (_scene && _scene->isActive())) { //|| (_scene && _scene->getBlowUpPuzzle()->isActive()))
- //AsylumEvent updateEvt = AsylumEvent(EVENT_ASYLUM_UPDATE);
- //_mainMenu->handleEvent(updateEvt);
- //}
+ case Common::EVENT_MOUSEMOVE:
+ case Common::EVENT_LBUTTONDOWN:
+ case Common::EVENT_LBUTTONUP:
+ case Common::EVENT_RBUTTONDOWN:
+ case Common::EVENT_RBUTTONUP:
+ // Handle mouse events
+ _handler->handleEvent(ev);
+ break;
- // Copy background image
- _screen->copyBackBufferToScreen();
- }
+ case Common::EVENT_QUIT:
+ quitGame();
+ break;
+ // TODO handle cases where we receive a midi or music event
+ }
+ }
- //if (_mainMenu->isActive())
- // Main menu active, pass events to it
- // _mainMenu->handleEvent(ev);
- if (_scene && _scene->isActive())
- // Pass events to the game
- _scene->handleEvent(&ev, doUpdate);
- /* FIXME reimplement
- else if (_scene && _scene->getBlowUpPuzzle()->isActive())
- // Pass events to BlowUp Puzzles
- _scene->getBlowUpPuzzle()->handleEvent(&ev, doUpdate);
- */
+ // Send update event to our event handler
+ AsylumEvent updateEvt = AsylumEvent(EVENT_ASYLUM_UPDATE);
+ _handler->handleEvent(updateEvt);
}
void AsylumEngine::processDelayedEvents() {
diff --git a/engines/asylum/asylum.h b/engines/asylum/asylum.h
index 4441a51cc1..f7eb598388 100644
--- a/engines/asylum/asylum.h
+++ b/engines/asylum/asylum.h
@@ -94,11 +94,6 @@ public:
AsylumEngine(OSystem *system, const ADGameDescription *gd);
virtual ~AsylumEngine();
- /**
- * Initializes the game
- */
- void init();
-
/**
* Start a new the game
*/
@@ -196,14 +191,11 @@ private:
EventHandler *_handler;
BlowUpPuzzle *_puzzles[16];
- // Shared game data
+ // Game data
SharedData _data;
-
- bool _introPlaying;
int _gameFlags[1512];
- void handleEvents(bool doUpdate);
- void waitForTimer(uint32 msec_delay);
+ void handleEvents();
void updateMouseCursor();
void processDelayedEvents();
diff --git a/engines/asylum/eventhandler.h b/engines/asylum/eventhandler.h
index e71eaea9b3..95c18a2bc7 100644
--- a/engines/asylum/eventhandler.h
+++ b/engines/asylum/eventhandler.h
@@ -36,6 +36,7 @@ enum AsylumEventType {
EVENT_ASYLUM_DEINIT = 0xFFF1,
EVENT_ASYLUM_UPDATE = 0xFFF2,
EVENT_ASYLUM_MUSIC = 0xFFF3,
+ EVENT_ASYLUM_MIDI = 0xFFF4,
EVENT_ASYLUM_CHANGECD = 0xFFFE
};
diff --git a/engines/asylum/puzzles/vcr.cpp b/engines/asylum/puzzles/vcr.cpp
index d371a66ed8..a3ff7a3755 100644
--- a/engines/asylum/puzzles/vcr.cpp
+++ b/engines/asylum/puzzles/vcr.cpp
@@ -85,7 +85,7 @@ void BlowUpPuzzleVCR::close() {
bool BlowUpPuzzleVCR::handleEvent(const AsylumEvent &ev) {
switch (ev.type) {
case Common::EVENT_MOUSEMOVE:
- _cursor->move(ev.mouse.x, ev.mouse.y);
+ //_cursor->move(ev.mouse.x, ev.mouse.y);
break;
case Common::EVENT_LBUTTONUP:
_leftClickUp = true;
diff --git a/engines/asylum/resources/actionlist.cpp b/engines/asylum/resources/actionlist.cpp
index 9f8be18ed1..ac39a7192f 100644
--- a/engines/asylum/resources/actionlist.cpp
+++ b/engines/asylum/resources/actionlist.cpp
@@ -1469,7 +1469,7 @@ END_OPCODE
//////////////////////////////////////////////////////////////////////////
// Opcode 0x4F
IMPLEMENT_OPCODE(ClearScreen)
- getSharedData()->setSkipDrawScene((bool)cmd->param1);
+ getSharedData()->setFlag(kFlagSkipDrawScene, (bool)cmd->param1);
if (cmd->param1)
getScreen()->clear();
diff --git a/engines/asylum/resources/actor.cpp b/engines/asylum/resources/actor.cpp
index 6d30bc0c60..8bdef3b5ce 100644
--- a/engines/asylum/resources/actor.cpp
+++ b/engines/asylum/resources/actor.cpp
@@ -1749,7 +1749,7 @@ void Actor::setVolume() {
// Helper methods
//////////////////////////////////////////////////////////////////////////
-ActorDirection Actor::direction(Common::Point vec1, Common::Point vec2) const {
+ActorDirection Actor::direction(Common::Point vec1, Common::Point vec2) {
int32 diffX = (vec2.x - vec1.x) * 2^16;
int32 diffY = (vec1.y - vec2.y) * 2^16;
int32 adjust = 0;
diff --git a/engines/asylum/resources/actor.h b/engines/asylum/resources/actor.h
index 79de8e97bf..8f6f87e20e 100644
--- a/engines/asylum/resources/actor.h
+++ b/engines/asylum/resources/actor.h
@@ -264,6 +264,16 @@ public:
static void enableActorsChapter2(AsylumEngine *engine);
static void updatePlayerChapter9(AsylumEngine *engine, int type);
+ /**
+ * Gets a direction using the angle between the two points.
+ *
+ * @param vec1 The first vector.
+ * @param vec2 The second vector.
+ *
+ * @return The direction
+ */
+ static ActorDirection direction(Common::Point vec1, Common::Point vec2);
+
private:
AsylumEngine *_vm;
@@ -431,16 +441,6 @@ private:
// Helper methods
//////////////////////////////////////////////////////////////////////////
- /**
- * Gets a direction using the angle between the two points.
- *
- * @param vec1 The first vector.
- * @param vec2 The second vector.
- *
- * @return The direction
- */
- ActorDirection direction(Common::Point vec1, Common::Point vec2) const;
-
/**
* Updates the actor graphic information
*
diff --git a/engines/asylum/resources/data.h b/engines/asylum/resources/data.h
index b2db7a8aa1..c4b2e4fba7 100644
--- a/engines/asylum/resources/data.h
+++ b/engines/asylum/resources/data.h
@@ -38,7 +38,8 @@ namespace Asylum {
enum GlobalFlag {
kFlag1,
kFlag2,
- kFlagSkipDraw,
+ kFlagRedraw,
+ kFlagSkipDrawScene,
kFlagSceneRectChanged,
kFlagScene1
};
@@ -133,18 +134,19 @@ public:
_actorUpdateStatusEnabledCounter = 0;
memset(&_data3[9], 0, sizeof(_data3));
_flagScene1 = false;
- _nextScreenUpdate = 0;
memset(&_movies[49], 0, sizeof(_movies));
_actorUpdateStatus15Check = false;
_flag2 = false;
- _flag5 = false;
+
+ // Screen updates
+ _flagRedraw = false;
+ _nextScreenUpdate = 0;
}
+
// Accessors
int32 getActorUpdateEnabledCounter() { return _actorUpdateStatusEnabledCounter; }
void setActorUpdateEnabledCounter(int32 val) { _actorUpdateStatusEnabledCounter = val; }
- int32 *nextScreenUpdate() { return &_nextScreenUpdate; }
-
bool getActorEnableForStatus7() { return _actorEnableForStatus7; }
void setActorEnableForStatus7(bool state) { _actorEnableForStatus7 = state; }
@@ -158,9 +160,6 @@ public:
int32 getActorUpdateFlag2() { return _data1[36]; }
void setActorUpdateFlag2(int32 val) { _data1[36] = val; }
- bool getSkipDrawScene() { return _flagSkipDrawScene; }
- void setSkipDrawScene(bool skip) { _flagSkipDrawScene = skip; }
-
// Shared global Data
int32 getGlobalX() const { return _globalX; }
void setGlobalX(int32 val) { _globalX = val; }
@@ -191,6 +190,9 @@ public:
Common::Point *getVector1() { return &_vector1; }
Common::Point *getVector2() { return &_vector2; }
+ void setNextScreenUpdate(uint32 ticks) { _nextScreenUpdate = ticks; }
+ uint32 getNextScreenUpdate() { return _nextScreenUpdate; }
+
void setData(ActorIndex index, int32 val) {
if (index < 50)
_data1[index] = val;
@@ -248,7 +250,11 @@ public:
case kFlag2:
return _flag2;
- case kFlagSkipDraw:
+ case kFlagRedraw:
+ return _flagRedraw;
+ break;
+
+ case kFlagSkipDrawScene:
return _flagSkipDrawScene;
case kFlagSceneRectChanged:
@@ -272,7 +278,11 @@ public:
_flag2 = state;
break;
- case kFlagSkipDraw:
+ case kFlagRedraw:
+ _flagRedraw = state;
+ break;
+
+ case kFlagSkipDrawScene:
_flagSkipDrawScene = state;
break;
@@ -339,12 +349,15 @@ private:
bool _data3[9];
//bool _flagEncouter5;
bool _flagScene1;
- int32 _nextScreenUpdate;
int32 _movies[49];
bool _actorUpdateStatus15Check;
// Skip opening flag (not used)
bool _flag2;
- bool _flag5;
+
+
+ // Screen updates
+ bool _flagRedraw;
+ uint32 _nextScreenUpdate;
};
} // End of namespace Asylum
diff --git a/engines/asylum/staticres.h b/engines/asylum/staticres.h
index e088ec054a..3266cd2482 100644
--- a/engines/asylum/staticres.h
+++ b/engines/asylum/staticres.h
@@ -29,7 +29,20 @@
namespace Asylum {
/** This fixes the menu icons text x position on screen */
-const int MenuIconFixedXpos[12] = { 28, 128, 225, 320, 410, 528, 16, 115, 237, 310, 508, 419 };
+const Common::Rect menuRects[12] = {Common::Rect( 19, 40, 68, 93),
+ Common::Rect( 19, 140, 68, 193),
+ Common::Rect( 19, 239, 68, 292),
+ Common::Rect( 19, 340, 68, 393),
+ Common::Rect( 19, 439, 68, 492),
+ Common::Rect( 19, 538, 68, 591),
+ Common::Rect( 400, 40, 449, 93),
+ Common::Rect( 400, 140, 449, 193),
+ Common::Rect( 400, 239, 449, 292),
+ Common::Rect( 400, 340, 449, 393),
+ Common::Rect( 400, 439, 449, 492),
+ Common::Rect( 400, 538, 449, 591)};
+
+const int eyeFrameIndex[8] = {3, 5, 1, 7, 4, 8, 2, 6};
/** Default Actor Indices by Scene */
const int actorType[16] = {0, 0, 0, 0, 1, 0, 2, 0, 3, 0, 1, 1, 3, 0, 0, 0};
diff --git a/engines/asylum/system/cursor.cpp b/engines/asylum/system/cursor.cpp
index c2be2f807d..8c161685a7 100644
--- a/engines/asylum/system/cursor.cpp
+++ b/engines/asylum/system/cursor.cpp
@@ -27,6 +27,8 @@
#include "asylum/system/graphics.h"
+#include "common/events.h"
+#include "common/system.h"
#include "graphics/cursorman.h"
namespace Asylum {
@@ -110,11 +112,6 @@ void Cursor::set(int32 frame) {
}
*/
-void Cursor::move(int16 x, int16 y) {
- _pos.x = x;
- _pos.y = y;
-}
-
void Cursor::animate() {
/*
@@ -167,4 +164,12 @@ void Cursor::update(WorldStats *ws, int32 currentAction) {
}
*/
+bool Cursor::isHidden() const {
+ return !CursorMan.isVisible();
+}
+
+Common::Point Cursor::position() const {
+ return g_system->getEventManager()->getMousePos();
+}
+
} // end of namespace Asylum
diff --git a/engines/asylum/system/cursor.h b/engines/asylum/system/cursor.h
index 20d6acf3fd..a374565700 100644
--- a/engines/asylum/system/cursor.h
+++ b/engines/asylum/system/cursor.h
@@ -54,6 +54,8 @@ public:
*/
void hide() const;
+ bool isHidden() const;
+
/**
* Set the current cursor instance to the graphic resource provide.
* The frames parameter defaults to -1, which in this case means that the
@@ -62,11 +64,6 @@ public:
*/
void set(ResourceId resourceId, int32 cntr = 0, byte flgs = 0, int32 frames = -1);
- /**
- * Set the x/y coordinates of the cursor
- */
- void move(int16 x, int16 y);
-
/**
* Scene-based update to the current cursor. This
* checks whether the cursor should be updated depending
@@ -88,7 +85,7 @@ public:
/**
* Return the cursor's position on the screen
*/
- Common::Point position() const { return _pos; }
+ Common::Point position() const;
// NOTE
// .text:00435060 contains a function that assigns global variables to a
diff --git a/engines/asylum/system/savegame.cpp b/engines/asylum/system/savegame.cpp
index cc707e7f79..9615a332af 100644
--- a/engines/asylum/system/savegame.cpp
+++ b/engines/asylum/system/savegame.cpp
@@ -41,4 +41,8 @@ bool Savegame::setup() {
return true;
}
+void Savegame::loadViewedMovies() {
+ warning("[Savegame::loadViewedMovies] Not implemented!");
+}
+
} // End of namespace Asylum
diff --git a/engines/asylum/system/savegame.h b/engines/asylum/system/savegame.h
index d28b0b2a7a..ac1ebbddb2 100644
--- a/engines/asylum/system/savegame.h
+++ b/engines/asylum/system/savegame.h
@@ -36,6 +36,7 @@ public:
~Savegame();
bool setup();
+ void loadViewedMovies();
private:
AsylumEngine* _vm;
diff --git a/engines/asylum/system/screen.cpp b/engines/asylum/system/screen.cpp
index afe8ee5951..f613dcb8ce 100644
--- a/engines/asylum/system/screen.cpp
+++ b/engines/asylum/system/screen.cpp
@@ -76,10 +76,10 @@ void Screen::draw(ResourceId resourceId, uint32 frameIndex, int32 x, int32 y, in
copyToBackBuffer(((byte *)frame->surface.pixels) - (y * frame->surface.w + x),
frame->surface.w,
- 0,
- 0,
- 640,
- 480);
+ x,
+ y,
+ frame->getWidth(),
+ frame->getHeight());
delete resource;
}
diff --git a/engines/asylum/views/menu.cpp b/engines/asylum/views/menu.cpp
index a352eac9d2..34b28baf1c 100644
--- a/engines/asylum/views/menu.cpp
+++ b/engines/asylum/views/menu.cpp
@@ -46,37 +46,36 @@
namespace Asylum {
MainMenu::MainMenu(AsylumEngine *vm): _vm(vm) {
- _leftClick = false;
- _activeIcon = -1;
- _previousActiveIcon = -1;
- _curIconFrame = 0;
- _curMouseCursor = 0;
- _cursorStep = 1;
- _creditsBgFrame = 0;
- _creditsTextScroll = 0x1E0 - 30;
- _activeScreen = kMenuMain;
- _active = false;
+ _initGame = false;
- Config.gammaLevel = 2;
- Config.performance = 5;
+ _activeScreen = kMenuNone;
+ _soundResourceId = kResourceNone;
+ _allowInteraction = false;
+ _dword_4464BC = -1;
+ _dword_455C74 = 0;
+ _dword_455D4C = 0;
+ _dword_455D5C = 0;
+ _dword_4562C0 = 0;
+ _dword_4562C4 = 0;
+ _dword_45628C = 0;
+ _needEyeCursorInit = false;
- _bgResource = new GraphicResource(_vm, MAKE_RESOURCE(kResourcePackShared, 0));
- _eyeResource = new GraphicResource(_vm, MAKE_RESOURCE(kResourcePackShared, 1));
+ memset(&_iconFrames, 0, sizeof(_iconFrames));
- _iconResource = 0;
- _creditsResource = 0;
- _creditsFadeResource = 0;
+ //_leftClick = false;
+ //_previousActiveIcon = -1;
+ //_curIconFrame = 0;
+ //_curMouseCursor = 0;
+ //_cursorStep = 1;
+ //_creditsBgFrame = 0;
+ //_creditsTextScroll = 0x1E0 - 30;
+
+ Config.gammaLevel = 2;
+ Config.performance = 5;
- getText()->loadFont(kFontYellow);
}
MainMenu::~MainMenu() {
- delete _creditsResource;
- delete _creditsFadeResource;
- delete _iconResource;
- delete _eyeResource;
- delete _bgResource;
-
// Zero-out passed pointers
_vm = NULL;
}
@@ -85,7 +84,7 @@ MainMenu::~MainMenu() {
// Loading and setup
//////////////////////////////////////////////////////////////////////////
void MainMenu::show() {
- getSharedData()->setSkipDrawScene(true);
+ getSharedData()->setFlag(kFlagSkipDrawScene, true);
getScreen()->clear();
// Set ourselves as the current event handler
@@ -172,7 +171,7 @@ bool MainMenu::handleEvent(const AsylumEvent &evt) {
case Common::EVENT_LBUTTONUP:
case Common::EVENT_RBUTTONDOWN:
case Common::EVENT_RBUTTONUP:
- return mouse(evt);
+ return click(evt);
break;
}
@@ -180,7 +179,7 @@ bool MainMenu::handleEvent(const AsylumEvent &evt) {
}
bool MainMenu::init() {
- // Original writes sntrm_k.txt
+ // TODO: save dialog key codes into sntrm_k.txt (need to figure out why they use such thing) (address 00411CD0)
if (_needEyeCursorInit) {
getCursor()->set(MAKE_RESOURCE(kResourcePackShared, 3), 0, 2);
@@ -189,9 +188,11 @@ bool MainMenu::init() {
if (!_initGame) {
_initGame = true;
- // The original load the config here (this is done when constructing the config object)
- // TODO initialize viewed cinematics
- _vm->init();
+ // The original load the config (this is done when constructing the config object)
+
+ getSaveLoad()->loadViewedMovies();
+
+ // The original initialize game structures (this is done in classes constructors)
_needEyeCursorInit = true;
@@ -238,81 +239,110 @@ bool MainMenu::init() {
}
bool MainMenu::update() {
- updateEyesAnimation();
- //getCursor()->animate();
+ uint32 ticks = _vm->getTick();
- if (_activeScreen == kMenuMain) {
- updateMainMenu();
- } else {
- updateSubMenu();
- }
+ if (!getSharedData()->getFlag(kFlagRedraw)) {
+ // TODO original fills a rectangle with black
+
+ // Draw background
+ getScreen()->draw(kBackground, (_activeScreen == kMenuNone) ? 1 : 0, 0, 0, 0);
+
+ uint32 frameIndex = 0;
- if (_leftClick) {
- _leftClick = false;
+ // Get the eye frame index
+ if (!getCursor()->isHidden()) {
+ Common::Point cursor = getCursor()->position();
- if (_activeIcon != -1) {
- // Copy the dark background to the back buffer
- getScreen()->draw(MAKE_RESOURCE(kResourcePackShared, 0), 0, 0, 0, 0);
+ if (cursor.x < 230 || cursor.x > 399 || cursor.y < 199 || cursor.y > 259)
+ frameIndex = eyeFrameIndex[Actor::direction(Common::Point(320, 240), cursor)];
+ else if (cursor.x >= 743 && cursor.x <= 743 && cursor.y >= 587 && cursor.y <= 602)
+ frameIndex = 9;
+ }
+
+ if (_activeScreen == kMenuNone) {
+ // Draw eye
+ getScreen()->draw(kEye, frameIndex, 0, 0, 0);
- _activeScreen = (MenuScreen) _activeIcon;
+ // Find mouse position
+ MenuScreen button = findMousePosition();
+ if (button != kMenuNone) {
+ warning("[MainMenu::update] Not implemented!");
+ } else {
+ _dword_455C74 = 0;
+ }
+ } else {
+ getScreen()->draw(kEye, frameIndex, 0, 0, 0, 3);
+ getScreen()->draw(MAKE_RESOURCE(kResourcePackShared, _activeScreen + 4), _iconFrames[_activeScreen], 0, 0, 0);
- // Set the cursor
- getCursor()->set(MAKE_RESOURCE(kResourcePackShared, 3));
+ // Update current menu frame index
+ _iconFrames[_activeScreen] = (_iconFrames[_activeScreen] + 1) % GraphicResource::getFrameCount(_vm, MAKE_RESOURCE(kResourcePackShared, _activeScreen + 4));
}
- switch (_activeIcon) {
+ // Update current screen
+ switch (_activeScreen) {
default:
break;
case kMenuNewGame:
- // Nothing here
+ updateNewGame();
break;
+
case kMenuLoadGame:
- // TODO
+ updateLoadGame();
break;
+
case kMenuSaveGame:
- // TODO
+ updateSaveGame();
break;
+
case kMenuDeleteGame:
- // TODO
+ updateDeleteGame();
break;
- case kMenuViewCinematics:
- // TODO
+
+ case kMenuViewMovies:
+ updateViewMovies();
break;
+
case kMenuQuitGame:
- // Nothing here
+ updateQuitGame();
break;
+
case kMenuTextOptions:
- // TODO
+ updateTextOptions();
break;
+
case kMenuAudioOptions:
- // TODO
+ updateAudioOptions();
break;
+
case kMenuSettings:
- // TODO
+ updateSettings();
break;
+
case kMenuKeyboardConfig:
- // TODO
+ updateKeyboardConfig();
break;
+
case kMenuShowCredits:
- // TODO if game finished (gameFlag=901) then show resource image 33 and music 56 and than music 40
- if (!_creditsResource)
- _creditsResource = new GraphicResource(_vm, MAKE_RESOURCE(kResourcePackShared, 24));
- if (!_creditsFadeResource)
- _creditsFadeResource = new GraphicResource(_vm, MAKE_RESOURCE(kResourcePackShared, 23));
- _creditsTextScroll = 0x1E0 - 30;
- // Set credits palette
- getScreen()->setPalette(MAKE_RESOURCE(kResourcePackShared, 26));
- // Stop all sounds
- getSound()->stopMusic();
- // Start playing music
- getSound()->playMusic(MAKE_RESOURCE(kResourcePackShared, 38));
+ updateShowCredits();
break;
+
case kMenuReturnToGame:
- if (_vm->scene()) // FIXME: do this properly
- // TODO closeMenu();
+ updateReturnToGame();
break;
}
+
+ // Ask for redraw
+ getSharedData()->setFlag(kFlagRedraw, true);
+ }
+
+ if (ticks > getSharedData()->getNextScreenUpdate()) {
+ if (getSharedData()->getFlag(kFlagRedraw)) {
+ getScreen()->copyBackBufferToScreen();
+
+ getSharedData()->setFlag(kFlagRedraw, false);
+ getSharedData()->setNextScreenUpdate(ticks + 55);
+ }
}
return true;
@@ -339,116 +369,211 @@ bool MainMenu::key(const AsylumEvent &evt) {
return true;
}
-bool MainMenu::mouse(const AsylumEvent &evt) {
+bool MainMenu::click(const AsylumEvent &evt) {
return true;
}
//////////////////////////////////////////////////////////////////////////
-// Update / key / mouse event handlers
+// Helpers
//////////////////////////////////////////////////////////////////////////
-void MainMenu::updateEyesAnimation() {
- // Eyes animation
- // Get the appropriate eye resource depending on the mouse position
- uint32 eyeFrameNum = kEyesFront;
-
- if (getCursor()->position().x <= 200) {
- if (getCursor()->position().y <= 160)
- eyeFrameNum = kEyesTopLeft;
- else if (getCursor()->position().y > 160 && getCursor()->position().y <= 320)
- eyeFrameNum = kEyesLeft;
- else
- eyeFrameNum = kEyesBottomLeft;
- } else if (getCursor()->position().x > 200 && getCursor()->position().x <= 400) {
- if (getCursor()->position().y <= 160)
- eyeFrameNum = kEyesTop;
- else if (getCursor()->position().y > 160 && getCursor()->position().y <= 320)
- eyeFrameNum = kEyesFront;
- else
- eyeFrameNum = kEyesBottom;
- } else if (getCursor()->position().x > 400) {
- if (getCursor()->position().y <= 160)
- eyeFrameNum = kEyesTopRight;
- else if (getCursor()->position().y > 160 && getCursor()->position().y <= 320)
- eyeFrameNum = kEyesRight;
- else
- eyeFrameNum = kEyesBottomRight;
- }
- // TODO: kEyesCrossed state
+MainMenu::MenuScreen MainMenu::findMousePosition() {
+ for (uint i = 0; i < ARRAYSIZE(menuRects); i++)
+ if (menuRects[i].contains(getCursor()->position()))
+ return (MenuScreen)i;
- GraphicFrame *eyeFrame = _eyeResource->getFrame(eyeFrameNum);
- _vm->screen()->copyRectToScreenWithTransparency((byte *)eyeFrame->surface.pixels, eyeFrame->surface.w, eyeFrame->x, eyeFrame->y, eyeFrame->surface.w, eyeFrame->surface.h);
+ return kMenuNone;
}
-void MainMenu::updateMainMenu() {
- int32 rowId = 0;
+//////////////////////////////////////////////////////////////////////////
+// Update handlers
+//////////////////////////////////////////////////////////////////////////
+void MainMenu::updateNewGame() {
+ error("[MainMenu::updateNewGame] Not implemented!");
+}
- if (getCursor()->position().y >= 20 && getCursor()->position().y <= 20 + 48) {
- rowId = 0; // Top row
- } else if (getCursor()->position().y >= 400 && getCursor()->position().y <= 400 + 48) {
- rowId = 1; // Bottom row
- } else {
- // No row selected
- _previousActiveIcon = _activeIcon = -1;
- _leftClick = false;
- return;
- }
+void MainMenu::updateLoadGame() {
+ error("[MainMenu::updateNewGame] Not implemented!");
+}
- getText()->loadFont(kFontYellow);
+void MainMenu::updateSaveGame() {
+ error("[MainMenu::updateNewGame] Not implemented!");
+}
- // Icon animation
- for (int32 i = 0; i <= 5; i++) {
- int32 curX = 40 + i * 100;
- if (getCursor()->position().x >= curX && getCursor()->position().x <= curX + 55) {
- int32 iconNum = i + 6 * rowId;
- _activeIcon = iconNum;
-
- // The last 2 icons are swapped
- if (iconNum == 11)
- iconNum = 10;
- else if (iconNum == 10)
- iconNum = 11;
-
- // Get the current icon animation
- if (!_iconResource || _activeIcon != _previousActiveIcon) {
- delete _iconResource;
- _iconResource = new GraphicResource(_vm, MAKE_RESOURCE(kResourcePackShared, iconNum + 4));
- }
+void MainMenu::updateDeleteGame() {
+ error("[MainMenu::updateNewGame] Not implemented!");
+}
- GraphicFrame *iconFrame = _iconResource->getFrame(MIN<uint>(_iconResource->count() - 1, _curIconFrame));
- _vm->screen()->copyRectToScreenWithTransparency((byte *)iconFrame->surface.pixels, iconFrame->surface.w, iconFrame->x, iconFrame->y, iconFrame->surface.w, iconFrame->surface.h);
+void MainMenu::updateViewMovies() {
+ error("[MainMenu::updateNewGame] Not implemented!");
+}
- // Cycle icon frame
- _curIconFrame++;
- if (_curIconFrame >= _iconResource->count())
- _curIconFrame = 0;
+void MainMenu::updateQuitGame() {
+ error("[MainMenu::updateNewGame] Not implemented!");
+}
- // Show text
- getText()->drawCentered(MenuIconFixedXpos[iconNum],
- iconFrame->y + 50,
- getText()->getWidth(MAKE_RESOURCE(kResourcePackText, iconNum + 1309)),
- MAKE_RESOURCE(kResourcePackText, iconNum + 1309));
+void MainMenu::updateTextOptions() {
+ error("[MainMenu::updateNewGame] Not implemented!");
+}
- // Play creepy voice
- if (_activeIcon != _previousActiveIcon) {
- getSound()->playSound(MAKE_RESOURCE(kResourcePackShared, iconNum + 44), false, Config.sfxVolume);
- _previousActiveIcon = _activeIcon;
- }
+void MainMenu::updateAudioOptions() {
+ error("[MainMenu::updateNewGame] Not implemented!");
+}
- break;
- }
- }
+void MainMenu::updateSettings() {
+ error("[MainMenu::updateNewGame] Not implemented!");
+}
+
+void MainMenu::updateKeyboardConfig() {
+ error("[MainMenu::updateNewGame] Not implemented!");
+}
+
+void MainMenu::updateShowCredits() {
+ error("[MainMenu::updateNewGame] Not implemented!");
+}
+
+void MainMenu::updateReturnToGame() {
+ error("[MainMenu::updateNewGame] Not implemented!");
+}
+
+//////////////////////////////////////////////////////////////////////////
+// Click handlers
+//////////////////////////////////////////////////////////////////////////
+void MainMenu::clickNewGame() {
+ error("[MainMenu::updateNewGame] Not implemented!");
+}
+
+void MainMenu::clickLoadGame() {
+ error("[MainMenu::updateNewGame] Not implemented!");
+}
+
+void MainMenu::clickSaveGame() {
+ error("[MainMenu::updateNewGame] Not implemented!");
+}
+
+void MainMenu::clickDeleteGame() {
+ error("[MainMenu::updateNewGame] Not implemented!");
+}
+
+void MainMenu::clickViewMovies() {
+ error("[MainMenu::updateNewGame] Not implemented!");
+}
+
+void MainMenu::clickQuitGame() {
+ error("[MainMenu::updateNewGame] Not implemented!");
+}
+
+void MainMenu::clickTextOptions() {
+ error("[MainMenu::updateNewGame] Not implemented!");
+}
+
+void MainMenu::clickAudioOptions() {
+ error("[MainMenu::updateNewGame] Not implemented!");
+}
+
+void MainMenu::clickSettings() {
+ error("[MainMenu::updateNewGame] Not implemented!");
+}
+
+void MainMenu::clickKeyboardConfig() {
+ error("[MainMenu::updateNewGame] Not implemented!");
+}
+
+void MainMenu::clickShowCredits() {
+ error("[MainMenu::updateNewGame] Not implemented!");
+}
+
+void MainMenu::clickReturnToGame() {
+ error("[MainMenu::updateNewGame] Not implemented!");
+}
+
+//////////////////////////////////////////////////////////////////////////
+// TODO REMOVE
+//////////////////////////////////////////////////////////////////////////
+
+// UpdateShowCredits
+//// TODO if game finished (gameFlag=901) then show resource image 33 and music 56 and than music 40
+////if (!_creditsResource)
+//// _creditsResource = new GraphicResource(_vm, MAKE_RESOURCE(kResourcePackShared, 24));
+////if (!_creditsFadeResource)
+//// _creditsFadeResource = new GraphicResource(_vm, MAKE_RESOURCE(kResourcePackShared, 23));
+////_creditsTextScroll = 0x1E0 - 30;
+//// Set credits palette
+//getScreen()->setPalette(MAKE_RESOURCE(kResourcePackShared, 26));
+//// Stop all sounds
+//getSound()->stopMusic();
+//// Start playing music
+//getSound()->playMusic(MAKE_RESOURCE(kResourcePackShared, 38));
+
+void MainMenu::updateMainMenu() {
+ //int32 rowId = 0;
+
+ //if (getCursor()->position().y >= 20 && getCursor()->position().y <= 20 + 48) {
+ // rowId = 0; // Top row
+ //} else if (getCursor()->position().y >= 400 && getCursor()->position().y <= 400 + 48) {
+ // rowId = 1; // Bottom row
+ //} else {
+ // // No row selected
+ // _previousActiveIcon = _activeScreen = -1;
+ // _leftClick = false;
+ // return;
+ //}
+
+ getText()->loadFont(kFontYellow);
+
+ // Icon animation
+// for (int32 i = 0; i <= 5; i++) {
+// int32 curX = 40 + i * 100;
+// if (getCursor()->position().x >= curX && getCursor()->position().x <= curX + 55) {
+// int32 iconNum = i + 6 * rowId;
+// _activeScreen = iconNum;
+//
+// // The last 2 icons are swapped
+// if (iconNum == 11)
+// iconNum = 10;
+// else if (iconNum == 10)
+// iconNum = 11;
+//
+// // Get the current icon animation
+// /* if (!_iconResource || _activeScreen != _previousActiveIcon) {
+// delete _iconResource;
+// _iconResource = new GraphicResource(_vm, MAKE_RESOURCE(kResourcePackShared, iconNum + 4));
+// }*/
+//
+// /* GraphicFrame *iconFrame = _iconResource->getFrame(MIN<uint>(_iconResource->count() - 1, _curIconFrame));
+// _vm->screen()->copyRectToScreenWithTransparency((byte *)iconFrame->surface.pixels, iconFrame->surface.w, iconFrame->x, iconFrame->y, iconFrame->surface.w, iconFrame->surface.h);
+//*/
+// //// Cycle icon frame
+// //_curIconFrame++;
+// //if (_curIconFrame >= _iconResource->count())
+// // _curIconFrame = 0;
+//
+// //// Show text
+// //getText()->drawCentered(MenuIconFixedXpos[iconNum],
+// // iconFrame->y + 50,
+// // getText()->getWidth(MAKE_RESOURCE(kResourcePackText, iconNum + 1309)),
+// // MAKE_RESOURCE(kResourcePackText, iconNum + 1309));
+//
+// // Play creepy voice
+// if (_activeScreen != _previousActiveIcon) {
+// getSound()->playSound(MAKE_RESOURCE(kResourcePackShared, iconNum + 44), false, Config.sfxVolume);
+// _previousActiveIcon = _activeScreen;
+// }
+//
+// break;
+// }
+// }
}
void MainMenu::updateSubMenu() {
- GraphicFrame *iconFrame = _iconResource->getFrame(MIN<uint>(_iconResource->count() - 1, _curIconFrame));
- _vm->screen()->copyRectToScreenWithTransparency((byte *)iconFrame->surface.pixels, iconFrame->surface.w, iconFrame->x, iconFrame->y, iconFrame->surface.w, iconFrame->surface.h);
+ //GraphicFrame *iconFrame = _iconResource->getFrame(MIN<uint>(_iconResource->count() - 1, _curIconFrame));
+ //_vm->screen()->copyRectToScreenWithTransparency((byte *)iconFrame->surface.pixels, iconFrame->surface.w, iconFrame->x, iconFrame->y, iconFrame->surface.w, iconFrame->surface.h);
// Cycle icon frame
- _curIconFrame++;
- if (_curIconFrame >= _iconResource->count())
- _curIconFrame = 0;
+ //_curIconFrame++;
+ //if (_curIconFrame >= _iconResource->count())
+ // _curIconFrame = 0;
- switch (_activeIcon) {
+ switch (_activeScreen) {
default:
break;
@@ -464,7 +589,7 @@ void MainMenu::updateSubMenu() {
case kMenuDeleteGame:
// TODO
break;
- case kMenuViewCinematics:
+ case kMenuViewMovies:
updateSubMenuCinematics();
break;
case kMenuQuitGame:
@@ -508,17 +633,17 @@ void MainMenu::updateSubMenuNewGame() {
getText()->draw(MAKE_RESOURCE(kResourcePackText, 1323));
// action
- if (_leftClick) {
- // Yes
- if (getCursor()->position().x >= 247 && getCursor()->position().x <= 247 + 24 && getCursor()->position().y >= 273 && getCursor()->position().y <= 273 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 1322))) {
- _leftClick = false;
- // TODO closeMenu();
- _vm->startGame(kResourcePackTowerCells, AsylumEngine::kStartGamePlayIntro);
- }
- // No
- if (getCursor()->position().x >= 369 && getCursor()->position().x <= 369 + 24 && getCursor()->position().y >= 273 && getCursor()->position().y <= 273 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 1323)))
- exitSubMenu();
- }
+ //if (_leftClick) {
+ // // Yes
+ // if (getCursor()->position().x >= 247 && getCursor()->position().x <= 247 + 24 && getCursor()->position().y >= 273 && getCursor()->position().y <= 273 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 1322))) {
+ // _leftClick = false;
+ // // TODO closeMenu();
+ // _vm->startGame(kResourcePackTowerCells, AsylumEngine::kStartGamePlayIntro);
+ // }
+ // // No
+ // if (getCursor()->position().x >= 369 && getCursor()->position().x <= 369 + 24 && getCursor()->position().y >= 273 && getCursor()->position().y <= 273 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 1323)))
+ // exitSubMenu();
+ //}
}
void MainMenu::updateSubMenuCinematics() {
@@ -527,13 +652,13 @@ void MainMenu::updateSubMenuCinematics() {
getText()->setPosition(30, 340);
getText()->draw(MAKE_RESOURCE(kResourcePackText, 1353)); // Prev Page
- if (getCursor()->position().x >= 280 && getCursor()->position().x <= 400 && getCursor()->position().y >= 340 && getCursor()->position().y <= 360) {
- getText()->loadFont(kFontBlue);
- if (_leftClick)
- exitSubMenu();
- } else {
- getText()->loadFont(kFontYellow);
- }
+ //if (getCursor()->position().x >= 280 && getCursor()->position().x <= 400 && getCursor()->position().y >= 340 && getCursor()->position().y <= 360) {
+ // getText()->loadFont(kFontBlue);
+ // if (_leftClick)
+ // exitSubMenu();
+ //} else {
+ // getText()->loadFont(kFontYellow);
+ //}
getText()->setPosition(280, 340);
getText()->draw(MAKE_RESOURCE(kResourcePackText, 1355)); // Main Menu
@@ -603,43 +728,43 @@ void MainMenu::updateSubMenuSettings() {
getText()->draw(MAKE_RESOURCE(kResourcePackText, 1437));
// action
- if (_leftClick) {
- // back to main menu
- if (getCursor()->position().x >= 300 && getCursor()->position().x <= 300 + sizeMainMenu && getCursor()->position().y >= 340 && getCursor()->position().y <= 340 + 24) {
- // TODO: save new configurations
- exitSubMenu();
- }
-
- // gamma level minus
- if (getCursor()->position().x >= 350 && getCursor()->position().x <= sizeMinus + 350 && getCursor()->position().y >= 150 && getCursor()->position().y <= 174) {
- if (Config.gammaLevel) {
- Config.gammaLevel -= 1;
- // TODO: setResGammaLevel(0x80010011, 0);
- }
- }
- // gamma level plus
- if (getCursor()->position().x >= sizeMinus + 360 && getCursor()->position().x <= sizeMinus + sizePlus + 360 && getCursor()->position().y >= 150 && getCursor()->position().y <= 174) {
- if (Config.gammaLevel < 8) {
- Config.gammaLevel += 1;
- // TODO: setResGammaLevel(0x80010011, 0);
- }
- }
-
- // performance minus
- if (getCursor()->position().x >= 350 && getCursor()->position().x <= sizeMinus + 350 && getCursor()->position().y >= 179 && getCursor()->position().y <= 203) {
- if (Config.performance) {
- Config.performance -= 1;
- // TODO: change quality settings
- }
- }
- // performance plus
- if (getCursor()->position().x >= sizeMinus + 360 && getCursor()->position().x <= sizeMinus + sizePlus + 360 && getCursor()->position().y >= 179 && getCursor()->position().y <= 203) {
- if (Config.performance < 5) {
- Config.performance += 1;
- // TODO: change quality settings
- }
- }
- }
+ //if (_leftClick) {
+ // // back to main menu
+ // if (getCursor()->position().x >= 300 && getCursor()->position().x <= 300 + sizeMainMenu && getCursor()->position().y >= 340 && getCursor()->position().y <= 340 + 24) {
+ // // TODO: save new configurations
+ // exitSubMenu();
+ // }
+
+ // // gamma level minus
+ // if (getCursor()->position().x >= 350 && getCursor()->position().x <= sizeMinus + 350 && getCursor()->position().y >= 150 && getCursor()->position().y <= 174) {
+ // if (Config.gammaLevel) {
+ // Config.gammaLevel -= 1;
+ // // TODO: setResGammaLevel(0x80010011, 0);
+ // }
+ // }
+ // // gamma level plus
+ // if (getCursor()->position().x >= sizeMinus + 360 && getCursor()->position().x <= sizeMinus + sizePlus + 360 && getCursor()->position().y >= 150 && getCursor()->position().y <= 174) {
+ // if (Config.gammaLevel < 8) {
+ // Config.gammaLevel += 1;
+ // // TODO: setResGammaLevel(0x80010011, 0);
+ // }
+ // }
+
+ // // performance minus
+ // if (getCursor()->position().x >= 350 && getCursor()->position().x <= sizeMinus + 350 && getCursor()->position().y >= 179 && getCursor()->position().y <= 203) {
+ // if (Config.performance) {
+ // Config.performance -= 1;
+ // // TODO: change quality settings
+ // }
+ // }
+ // // performance plus
+ // if (getCursor()->position().x >= sizeMinus + 360 && getCursor()->position().x <= sizeMinus + sizePlus + 360 && getCursor()->position().y >= 179 && getCursor()->position().y <= 203) {
+ // if (Config.performance < 5) {
+ // Config.performance += 1;
+ // // TODO: change quality settings
+ // }
+ // }
+ //}
}
void MainMenu::updateSubMenuQuitGame() {
@@ -658,93 +783,93 @@ void MainMenu::updateSubMenuQuitGame() {
getText()->setPosition(369, 273);
getText()->draw(MAKE_RESOURCE(kResourcePackText, 1410));
- // action
- if (_leftClick) {
- // Yes
- if (getCursor()->position().x >= 247 && getCursor()->position().x <= 247 + 24 && getCursor()->position().y >= 273 && getCursor()->position().y <= 273 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 1409))) {
- _leftClick = false;
-
- // User clicked on quit, so push a quit event
- Common::Event event;
- event.type = Common::EVENT_QUIT;
- g_system->getEventManager()->pushEvent(event);
- }
- // No
- if (getCursor()->position().x >= 369 && getCursor()->position().x <= 369 + 24 && getCursor()->position().y >= 273 && getCursor()->position().y <= 273 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 1410)))
- exitSubMenu();
- }
+ //// action
+ //if (_leftClick) {
+ // // Yes
+ // if (getCursor()->position().x >= 247 && getCursor()->position().x <= 247 + 24 && getCursor()->position().y >= 273 && getCursor()->position().y <= 273 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 1409))) {
+ // _leftClick = false;
+
+ // // User clicked on quit, so push a quit event
+ // Common::Event event;
+ // event.type = Common::EVENT_QUIT;
+ // g_system->getEventManager()->pushEvent(event);
+ // }
+ // // No
+ // if (getCursor()->position().x >= 369 && getCursor()->position().x <= 369 + 24 && getCursor()->position().y >= 273 && getCursor()->position().y <= 273 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 1410)))
+ // exitSubMenu();
+ //}
}
void MainMenu::updateSubMenuShowCredits() {
- int32 posY = _creditsTextScroll;
- ResourceId resourceId = kResourceNone;
- int32 step = 0;
- int32 minBound = 0;
- int32 maxBound = 0;
-
- GraphicFrame *creditsFadeFrame = _creditsFadeResource->getFrame(0);
- _vm->screen()->copyRectToScreenWithTransparency((byte *)creditsFadeFrame->surface.pixels, creditsFadeFrame->surface.w, creditsFadeFrame->x, creditsFadeFrame->y, creditsFadeFrame->surface.w, creditsFadeFrame->surface.h);
-
- GraphicFrame *creditsFrame = _creditsResource->getFrame(MIN<uint>(_creditsResource->count() - 1, _creditsBgFrame));
- _vm->screen()->copyRectToScreenWithTransparency((byte *)creditsFrame->surface.pixels, creditsFrame->surface.w, creditsFrame->x, creditsFrame->y, creditsFrame->surface.w, creditsFrame->surface.h);
-
- _creditsBgFrame++;
- if (_creditsBgFrame >= _creditsResource->count())
- _creditsBgFrame = 0;
-
- do {
- if (posY + step >= 0) {
- if (posY + step > 450)
- break;
-
- minBound = posY + step + 24;
- if (minBound >= 0)
- if (minBound < 32) {
- // TODO fade side text
- posY = _creditsTextScroll;
- }
-
- maxBound = posY + step;
- if (posY + step < 480)
- if (maxBound > 448) {
- // TODO fade side text
- posY = _creditsTextScroll;
- }
-
- getText()->setPosition(320, step + posY);
- getText()->draw((ResourceId)(resourceId - 2147482201));
- posY = _creditsTextScroll;
- }
- step += 24;
- resourceId = (ResourceId)(resourceId + 1);
- } while (step < 0x21F0);
-
- _creditsTextScroll -= 2;
-
- // TODO: some palette stuffs
-
- // TODO: if gameFlag=901 (finished game) and already play music 56, start music 40
-
- if (_leftClick) {
- // Restore palette
- _vm->screen()->setPalette(MAKE_RESOURCE(kResourcePackShared, 17));
- // Stop all sounds
- _vm->sound()->stopMusic();
- // Start playing music
- _vm->sound()->playMusic(MAKE_RESOURCE(kResourcePackShared, 39));
- exitSubMenu();
- }
+ //int32 posY = _creditsTextScroll;
+ //ResourceId resourceId = kResourceNone;
+ //int32 step = 0;
+ //int32 minBound = 0;
+ //int32 maxBound = 0;
+
+ ////GraphicFrame *creditsFadeFrame = _creditsFadeResource->getFrame(0);
+ ////_vm->screen()->copyRectToScreenWithTransparency((byte *)creditsFadeFrame->surface.pixels, creditsFadeFrame->surface.w, creditsFadeFrame->x, creditsFadeFrame->y, creditsFadeFrame->surface.w, creditsFadeFrame->surface.h);
+
+ ////GraphicFrame *creditsFrame = _creditsResource->getFrame(MIN<uint>(_creditsResource->count() - 1, _creditsBgFrame));
+ ////_vm->screen()->copyRectToScreenWithTransparency((byte *)creditsFrame->surface.pixels, creditsFrame->surface.w, creditsFrame->x, creditsFrame->y, creditsFrame->surface.w, creditsFrame->surface.h);
+
+ ////_creditsBgFrame++;
+ ////if (_creditsBgFrame >= _creditsResource->count())
+ //// _creditsBgFrame = 0;
+
+ //do {
+ // if (posY + step >= 0) {
+ // if (posY + step > 450)
+ // break;
+
+ // minBound = posY + step + 24;
+ // if (minBound >= 0)
+ // if (minBound < 32) {
+ // // TODO fade side text
+ // posY = _creditsTextScroll;
+ // }
+
+ // maxBound = posY + step;
+ // if (posY + step < 480)
+ // if (maxBound > 448) {
+ // // TODO fade side text
+ // posY = _creditsTextScroll;
+ // }
+
+ // getText()->setPosition(320, step + posY);
+ // getText()->draw((ResourceId)(resourceId - 2147482201));
+ // posY = _creditsTextScroll;
+ // }
+ // step += 24;
+ // resourceId = (ResourceId)(resourceId + 1);
+ //} while (step < 0x21F0);
+
+ //_creditsTextScroll -= 2;
+
+ //// TODO: some palette stuffs
+
+ //// TODO: if gameFlag=901 (finished game) and already play music 56, start music 40
+
+ //if (_leftClick) {
+ // // Restore palette
+ // _vm->screen()->setPalette(MAKE_RESOURCE(kResourcePackShared, 17));
+ // // Stop all sounds
+ // _vm->sound()->stopMusic();
+ // // Start playing music
+ // _vm->sound()->playMusic(MAKE_RESOURCE(kResourcePackShared, 39));
+ // exitSubMenu();
+ //}
}
void MainMenu::exitSubMenu() {
- _leftClick = false;
- _activeScreen = kMenuMain;
+ //_leftClick = false;
+ //_activeScreen = kMenuMain;
- // Copy the bright background to the back buffer
- getScreen()->draw(MAKE_RESOURCE(kResourcePackShared, 0), 1, 0, 0, 0);
+ //// Copy the bright background to the back buffer
+ //getScreen()->draw(MAKE_RESOURCE(kResourcePackShared, 0), 1, 0, 0, 0);
- // Set the cursor
- getCursor()->set(MAKE_RESOURCE(kResourcePackShared, 2));
+ //// Set the cursor
+ //getCursor()->set(MAKE_RESOURCE(kResourcePackShared, 2));
}
void MainMenu::updateSubMenuReturnToGame() {
@@ -759,11 +884,11 @@ void MainMenu::updateSubMenuReturnToGame() {
getText()->draw(MAKE_RESOURCE(kResourcePackText, 713));
// action
- if (_leftClick) {
- // Main menu
- if (getCursor()->position().x >= 285 && getCursor()->position().x <= 285 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 713)) && getCursor()->position().y >= 273 && getCursor()->position().y <= 273 + 24)
- exitSubMenu();
- }
+ //if (_leftClick) {
+ // // Main menu
+ // if (getCursor()->position().x >= 285 && getCursor()->position().x <= 285 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 713)) && getCursor()->position().y >= 273 && getCursor()->position().y <= 273 + 24)
+ // exitSubMenu();
+ //}
}
} // end of namespace Asylum
diff --git a/engines/asylum/views/menu.h b/engines/asylum/views/menu.h
index 13b392c49e..5a41594eb1 100644
--- a/engines/asylum/views/menu.h
+++ b/engines/asylum/views/menu.h
@@ -79,34 +79,35 @@ private:
kMenuLoadGame = 1,
kMenuSaveGame = 2,
kMenuDeleteGame = 3,
- kMenuViewCinematics = 4,
+ kMenuViewMovies = 4,
kMenuQuitGame = 5,
kMenuTextOptions = 6,
kMenuAudioOptions = 7,
kMenuSettings = 8,
kMenuKeyboardConfig = 9,
kMenuShowCredits = 10,
- kMenuReturnToGame = 11,
- kMenuMain = 12
+ kMenuReturnToGame = 11
};
- enum Fonts {
- kFontBlue = MAKE_RESOURCE(kResourcePackShared, 22),
+ enum MenuResource {
+ kBackground = MAKE_RESOURCE(kResourcePackShared, 0),
+ kEye = MAKE_RESOURCE(kResourcePackShared, 1),
+ kFontBlue = MAKE_RESOURCE(kResourcePackShared, 22),
kFontYellow = MAKE_RESOURCE(kResourcePackShared, 16)
};
- int32 _activeIcon;
- int32 _previousActiveIcon;
- uint32 _curIconFrame;
- int32 _curMouseCursor;
- int32 _cursorStep;
- uint32 _creditsBgFrame;
- int32 _creditsTextScroll;
- bool _leftClick;
- bool _active;
+ //int32 _activeIcon;
+ //int32 _previousActiveIcon;
+ //uint32 _curIconFrame;
+ //int32 _curMouseCursor;
+ //int32 _cursorStep;
+ //uint32 _creditsBgFrame;
+ //int32 _creditsTextScroll;
+ //bool _leftClick;
+ //bool _active;
// Game initialization
- bool _initGame;
+ bool _initGame;
// Data
MenuScreen _activeScreen;
@@ -120,12 +121,7 @@ private:
int32 _dword_4562C4;
int32 _dword_45628C;
bool _needEyeCursorInit;
-
- GraphicResource *_bgResource;
- GraphicResource *_eyeResource;
- GraphicResource *_iconResource;
- GraphicResource *_creditsResource;
- GraphicResource *_creditsFadeResource;
+ uint32 _iconFrames[12];
/**
* Setups menu screen
@@ -145,9 +141,41 @@ private:
bool update();
bool music();
bool key(const AsylumEvent &evt);
- bool mouse(const AsylumEvent &evt);
-
- void updateEyesAnimation();
+ bool click(const AsylumEvent &evt);
+
+ // Helpers
+ MenuScreen findMousePosition();
+
+ // Update handlers
+ void updateNewGame();
+ void updateLoadGame();
+ void updateSaveGame();
+ void updateDeleteGame();
+ void updateViewMovies();
+ void updateQuitGame();
+ void updateTextOptions();
+ void updateAudioOptions();
+ void updateSettings();
+ void updateKeyboardConfig();
+ void updateShowCredits();
+ void updateReturnToGame();
+
+ // Click handlers
+ void clickNewGame();
+ void clickLoadGame();
+ void clickSaveGame();
+ void clickDeleteGame();
+ void clickViewMovies();
+ void clickQuitGame();
+ void clickTextOptions();
+ void clickAudioOptions();
+ void clickSettings();
+ void clickKeyboardConfig();
+ void clickShowCredits();
+ void clickReturnToGame();
+
+
+ // TODO remove
void updateMainMenu();
void updateSubMenu();
diff --git a/engines/asylum/views/scene.cpp b/engines/asylum/views/scene.cpp
index 0a6aa539e3..ea010c1fab 100644
--- a/engines/asylum/views/scene.cpp
+++ b/engines/asylum/views/scene.cpp
@@ -326,8 +326,8 @@ void Scene::handleEvent(Common::Event *event, bool doUpdate) {
switch (_ev->type) {
case Common::EVENT_MOUSEMOVE:
- if (getCursor())
- getCursor()->move(_ev->mouse.x, _ev->mouse.y);
+ //if (getCursor())
+ //getCursor()->move(_ev->mouse.x, _ev->mouse.y);
break;
case Common::EVENT_LBUTTONUP:
@@ -1130,7 +1130,7 @@ int Scene::drawScene() {
_vm->screen()->clearGraphicsInQueue();
- if (getSharedData()->getSkipDrawScene()) {
+ if (getSharedData()->getFlag(kFlagRedraw)) {
_vm->screen()->clear();
} else {
// Draw scene background
Commit: 3d7b00db631d7f3c48c4674c6b360a71d621a469
https://github.com/scummvm/scummvm/commit/3d7b00db631d7f3c48c4674c6b360a71d621a469
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:27+02:00
Commit Message:
ASYLUM: Implement some menu helper functions
- Switch last two rects (the icons are "inversed")
- Remove now useles EyesAnimation enumeration
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@601 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/staticres.h
engines/asylum/views/menu.cpp
engines/asylum/views/menu.h
diff --git a/engines/asylum/staticres.h b/engines/asylum/staticres.h
index 3266cd2482..823bf0f5e2 100644
--- a/engines/asylum/staticres.h
+++ b/engines/asylum/staticres.h
@@ -29,18 +29,18 @@
namespace Asylum {
/** This fixes the menu icons text x position on screen */
-const Common::Rect menuRects[12] = {Common::Rect( 19, 40, 68, 93),
- Common::Rect( 19, 140, 68, 193),
- Common::Rect( 19, 239, 68, 292),
- Common::Rect( 19, 340, 68, 393),
- Common::Rect( 19, 439, 68, 492),
- Common::Rect( 19, 538, 68, 591),
- Common::Rect( 400, 40, 449, 93),
- Common::Rect( 400, 140, 449, 193),
- Common::Rect( 400, 239, 449, 292),
- Common::Rect( 400, 340, 449, 393),
- Common::Rect( 400, 439, 449, 492),
- Common::Rect( 400, 538, 449, 591)};
+const Common::Rect menuRects[12] = {Common::Rect( 40, 19, 93, 68),
+ Common::Rect( 140, 19, 193, 68),
+ Common::Rect( 239, 19, 292, 68),
+ Common::Rect( 340, 19, 393, 68),
+ Common::Rect( 439, 19, 492, 68),
+ Common::Rect( 538, 19, 591, 68),
+ Common::Rect( 40, 400, 93, 449),
+ Common::Rect( 140, 400, 193, 449),
+ Common::Rect( 239, 400, 292, 449),
+ Common::Rect( 340, 400, 393, 449),
+ Common::Rect( 538, 400, 591, 449), // The last two icons are swapped
+ Common::Rect( 439, 400, 492, 449)};
const int eyeFrameIndex[8] = {3, 5, 1, 7, 4, 8, 2, 6};
diff --git a/engines/asylum/views/menu.cpp b/engines/asylum/views/menu.cpp
index 34b28baf1c..f3782a6d3a 100644
--- a/engines/asylum/views/menu.cpp
+++ b/engines/asylum/views/menu.cpp
@@ -51,7 +51,7 @@ MainMenu::MainMenu(AsylumEngine *vm): _vm(vm) {
_activeScreen = kMenuNone;
_soundResourceId = kResourceNone;
_allowInteraction = false;
- _dword_4464BC = -1;
+ _currentIcon = kMenuNone;
_dword_455C74 = 0;
_dword_455D4C = 0;
_dword_455D5C = 0;
@@ -61,18 +61,6 @@ MainMenu::MainMenu(AsylumEngine *vm): _vm(vm) {
_needEyeCursorInit = false;
memset(&_iconFrames, 0, sizeof(_iconFrames));
-
- //_leftClick = false;
- //_previousActiveIcon = -1;
- //_curIconFrame = 0;
- //_curMouseCursor = 0;
- //_cursorStep = 1;
- //_creditsBgFrame = 0;
- //_creditsTextScroll = 0x1E0 - 30;
-
- Config.gammaLevel = 2;
- Config.performance = 5;
-
}
MainMenu::~MainMenu() {
@@ -92,8 +80,9 @@ void MainMenu::show() {
getSound()->stopAll();
- _activeScreen = kMenuReturnToGame;
+ _activeScreen = kMenuShowCredits;
_soundResourceId = kResourceNone;
+ _musicResourceId = kResourceNone;
_allowInteraction = false;
_dword_4562C4 = 480;
@@ -139,10 +128,54 @@ void MainMenu::setup() {
}
}
+void MainMenu::leave() {
+ _activeScreen = kMenuNone;
+ getCursor()->set(MAKE_RESOURCE(kResourcePackShared, 2), 0, 2);
+ getText()->loadFont(kFontYellow);
+}
+
void MainMenu::switchFont(bool condition) {
getText()->loadFont((condition) ? kFontYellow : kFontBlue);
}
+void MainMenu::showCredits() {
+ getScreen()->clear();
+ // Original fills the screen with black
+
+ getCursor()->show();
+ getSharedData()->setFlag(kFlag1, false);
+
+ getText()->loadFont(kFontYellow);
+ getScreen()->setPalette(MAKE_RESOURCE(kResourcePackShared, 17));
+ getScreen()->setGammaLevel(MAKE_RESOURCE(kResourcePackShared, 17), 0);
+ getScreen()->setupTransTables(4, MAKE_RESOURCE(kResourcePackShared, 18),
+ MAKE_RESOURCE(kResourcePackShared, 19),
+ MAKE_RESOURCE(kResourcePackShared, 20),
+ MAKE_RESOURCE(kResourcePackShared, 21));
+ getScreen()->selectTransTable(1);
+
+ getSound()->playMusic(kResourceNone, 0);
+ getSound()->playMusic(_musicResourceId);
+
+ if (_vm->isGameFlagSet(kGameFlagFinishGame)) {
+ if (!_dword_455D4C) {
+ _dword_455D4C = true;
+ getSound()->stop(MAKE_RESOURCE(kResourcePackShared, 56));
+ }
+ }
+
+ leave();
+}
+
+
+MainMenu::MenuScreen MainMenu::findMousePosition() {
+ for (uint i = 0; i < ARRAYSIZE(menuRects); i++)
+ if (menuRects[i].contains(getCursor()->position()))
+ return (MenuScreen)i;
+
+ return kMenuNone;
+}
+
//////////////////////////////////////////////////////////////////////////
// Event Handler
//////////////////////////////////////////////////////////////////////////
@@ -211,7 +244,7 @@ bool MainMenu::init() {
_dword_4562C0 = 0;
_activeScreen = kMenuNone;
- _dword_4464BC = -1;
+ _currentIcon = kMenuNone;
_dword_455C74 = 0;
getCursor()->hide();
@@ -264,17 +297,37 @@ bool MainMenu::update() {
getScreen()->draw(kEye, frameIndex, 0, 0, 0);
// Find mouse position
- MenuScreen button = findMousePosition();
- if (button != kMenuNone) {
- warning("[MainMenu::update] Not implemented!");
+ MenuScreen icon = findMousePosition();
+ if (icon != kMenuNone) {
+ // Draw icon
+ getScreen()->draw(MAKE_RESOURCE(kResourcePackShared, icon + 4), _iconFrames[icon], 0, 0, 0);
+ _iconFrames[icon] = (_iconFrames[icon] + 1) % GraphicResource::getFrameCount(_vm, MAKE_RESOURCE(kResourcePackShared, icon + 4));
+
+ // Draw text
+ getText()->drawCentered(menuRects[icon].left - 5, menuRects[icon].bottom + 5, menuRects[icon].width(), MAKE_RESOURCE(kResourcePackText, 1309 + icon));
+
+ if (!_dword_455C74 || _currentIcon != icon) {
+ _dword_455C74 = true;
+ _currentIcon = icon;
+
+ if (_soundResourceId
+ && getSound()->isPlaying(_soundResourceId)
+ && _soundResourceId != MAKE_RESOURCE(kResourcePackShared, icon + 44))
+ getSound()->stopAll(_soundResourceId);
+
+ if (_soundResourceId != MAKE_RESOURCE(kResourcePackShared, icon + 44) || !getSound()->isPlaying(_soundResourceId)) {
+ _soundResourceId = MAKE_RESOURCE(kResourcePackShared, icon + 44);
+ getSound()->playSound(_soundResourceId, false, Config.voiceVolume);
+ }
+ }
} else {
_dword_455C74 = 0;
}
} else {
getScreen()->draw(kEye, frameIndex, 0, 0, 0, 3);
- getScreen()->draw(MAKE_RESOURCE(kResourcePackShared, _activeScreen + 4), _iconFrames[_activeScreen], 0, 0, 0);
- // Update current menu frame index
+ // Draw icon
+ getScreen()->draw(MAKE_RESOURCE(kResourcePackShared, _activeScreen + 4), _iconFrames[_activeScreen], 0, 0, 0);
_iconFrames[_activeScreen] = (_iconFrames[_activeScreen] + 1) % GraphicResource::getFrameCount(_vm, MAKE_RESOURCE(kResourcePackShared, _activeScreen + 4));
}
@@ -349,7 +402,7 @@ bool MainMenu::update() {
}
bool MainMenu::music() {
- if (_activeScreen == kMenuReturnToGame
+ if (_activeScreen == kMenuShowCredits
&& _vm->isGameFlagSet(kGameFlagFinishGame)
&& !_dword_455D5C
&& !_dword_455D4C) {
@@ -365,7 +418,23 @@ bool MainMenu::music() {
}
bool MainMenu::key(const AsylumEvent &evt) {
- // TODO handle per-screen keyboard shortcuts
+ switch (_activeScreen) {
+ default:
+ break;
+
+ case kMenuSaveGame:
+ keySaveGame();
+ break;
+
+ case kMenuKeyboardConfig:
+ keyKeyboardConfig();
+ break;
+
+ case kMenuShowCredits:
+ keyShowCredits();
+ break;
+ }
+
return true;
}
@@ -373,16 +442,6 @@ bool MainMenu::click(const AsylumEvent &evt) {
return true;
}
-//////////////////////////////////////////////////////////////////////////
-// Helpers
-//////////////////////////////////////////////////////////////////////////
-MainMenu::MenuScreen MainMenu::findMousePosition() {
- for (uint i = 0; i < ARRAYSIZE(menuRects); i++)
- if (menuRects[i].contains(getCursor()->position()))
- return (MenuScreen)i;
-
- return kMenuNone;
-}
//////////////////////////////////////////////////////////////////////////
// Update handlers
@@ -392,98 +451,113 @@ void MainMenu::updateNewGame() {
}
void MainMenu::updateLoadGame() {
- error("[MainMenu::updateNewGame] Not implemented!");
+ error("[MainMenu::updateLoadGame] Not implemented!");
}
void MainMenu::updateSaveGame() {
- error("[MainMenu::updateNewGame] Not implemented!");
+ error("[MainMenu::updateSaveGame] Not implemented!");
}
void MainMenu::updateDeleteGame() {
- error("[MainMenu::updateNewGame] Not implemented!");
+ error("[MainMenu::updateDeleteGame] Not implemented!");
}
void MainMenu::updateViewMovies() {
- error("[MainMenu::updateNewGame] Not implemented!");
+ error("[MainMenu::updateViewMovies] Not implemented!");
}
void MainMenu::updateQuitGame() {
- error("[MainMenu::updateNewGame] Not implemented!");
+ error("[MainMenu::updateQuitGame] Not implemented!");
}
void MainMenu::updateTextOptions() {
- error("[MainMenu::updateNewGame] Not implemented!");
+ error("[MainMenu::updateTextOptions] Not implemented!");
}
void MainMenu::updateAudioOptions() {
- error("[MainMenu::updateNewGame] Not implemented!");
+ error("[MainMenu::updateAudioOptions] Not implemented!");
}
void MainMenu::updateSettings() {
- error("[MainMenu::updateNewGame] Not implemented!");
+ error("[MainMenu::updateSettings] Not implemented!");
}
void MainMenu::updateKeyboardConfig() {
- error("[MainMenu::updateNewGame] Not implemented!");
+ error("[MainMenu::updateKeyboardConfig] Not implemented!");
}
-void MainMenu::updateShowCredits() {
- error("[MainMenu::updateNewGame] Not implemented!");
+void MainMenu::updateReturnToGame() {
+ error("[MainMenu::updateReturnToGame] Not implemented!");
}
-void MainMenu::updateReturnToGame() {
- error("[MainMenu::updateNewGame] Not implemented!");
+void MainMenu::updateShowCredits() {
+ error("[MainMenu::updateShowCredits] Not implemented!");
}
//////////////////////////////////////////////////////////////////////////
// Click handlers
//////////////////////////////////////////////////////////////////////////
void MainMenu::clickNewGame() {
- error("[MainMenu::updateNewGame] Not implemented!");
+ error("[MainMenu::clickNewGame] Not implemented!");
}
void MainMenu::clickLoadGame() {
- error("[MainMenu::updateNewGame] Not implemented!");
+ error("[MainMenu::clickLoadGame] Not implemented!");
}
void MainMenu::clickSaveGame() {
- error("[MainMenu::updateNewGame] Not implemented!");
+ error("[MainMenu::clickSaveGame] Not implemented!");
}
void MainMenu::clickDeleteGame() {
- error("[MainMenu::updateNewGame] Not implemented!");
+ error("[MainMenu::clickDeleteGame] Not implemented!");
}
void MainMenu::clickViewMovies() {
- error("[MainMenu::updateNewGame] Not implemented!");
+ error("[MainMenu::clickViewMovies] Not implemented!");
}
void MainMenu::clickQuitGame() {
- error("[MainMenu::updateNewGame] Not implemented!");
+ error("[MainMenu::clickQuitGame] Not implemented!");
}
void MainMenu::clickTextOptions() {
- error("[MainMenu::updateNewGame] Not implemented!");
+ error("[MainMenu::clickTextOptions] Not implemented!");
}
void MainMenu::clickAudioOptions() {
- error("[MainMenu::updateNewGame] Not implemented!");
+ error("[MainMenu::clickAudioOptions] Not implemented!");
}
void MainMenu::clickSettings() {
- error("[MainMenu::updateNewGame] Not implemented!");
+ error("[MainMenu::clickSettings] Not implemented!");
}
void MainMenu::clickKeyboardConfig() {
- error("[MainMenu::updateNewGame] Not implemented!");
+ error("[MainMenu::clickKeyboardConfig] Not implemented!");
+}
+
+void MainMenu::clickReturnToGame() {
+ error("[MainMenu::clickReturnToGame] Not implemented!");
}
void MainMenu::clickShowCredits() {
- error("[MainMenu::updateNewGame] Not implemented!");
+ showCredits();
}
-void MainMenu::clickReturnToGame() {
- error("[MainMenu::updateNewGame] Not implemented!");
+//////////////////////////////////////////////////////////////////////////
+// Key handlers
+//////////////////////////////////////////////////////////////////////////
+void MainMenu::keySaveGame() {
+ error("[MainMenu::keySaveGame] Not implemented!");
+}
+
+void MainMenu::keyKeyboardConfig() {
+ error("[MainMenu::keyKeyboardConfig] Not implemented!");
+}
+
+void MainMenu::keyShowCredits() {
+ showCredits();
}
//////////////////////////////////////////////////////////////////////////
@@ -503,393 +577,343 @@ void MainMenu::clickReturnToGame() {
//getSound()->stopMusic();
//// Start playing music
//getSound()->playMusic(MAKE_RESOURCE(kResourcePackShared, 38));
+//
+//void MainMenu::updateMainMenu() {
+// //int32 rowId = 0;
+//
+// //if (getCursor()->position().y >= 20 && getCursor()->position().y <= 20 + 48) {
+// // rowId = 0; // Top row
+// //} else if (getCursor()->position().y >= 400 && getCursor()->position().y <= 400 + 48) {
+// // rowId = 1; // Bottom row
+// //} else {
+// // // No row selected
+// // _previousActiveIcon = _activeScreen = -1;
+// // _leftClick = false;
+// // return;
+// //}
+//
+// getText()->loadFont(kFontYellow);
+//
+// // Icon animation
+//// for (int32 i = 0; i <= 5; i++) {
+//// int32 curX = 40 + i * 100;
+//// if (getCursor()->position().x >= curX && getCursor()->position().x <= curX + 55) {
+//// int32 iconNum = i + 6 * rowId;
+//// _activeScreen = iconNum;
+////
+//// // The last 2 icons are swapped
+//// if (iconNum == 11)
+//// iconNum = 10;
+//// else if (iconNum == 10)
+//// iconNum = 11;
+////
+//// // Get the current icon animation
+//// /* if (!_iconResource || _activeScreen != _previousActiveIcon) {
+//// delete _iconResource;
+//// _iconResource = new GraphicResource(_vm, MAKE_RESOURCE(kResourcePackShared, iconNum + 4));
+//// }*/
+////
+//// /* GraphicFrame *iconFrame = _iconResource->getFrame(MIN<uint>(_iconResource->count() - 1, _curIconFrame));
+//// _vm->screen()->copyRectToScreenWithTransparency((byte *)iconFrame->surface.pixels, iconFrame->surface.w, iconFrame->x, iconFrame->y, iconFrame->surface.w, iconFrame->surface.h);
+////*/
+//// //// Cycle icon frame
+//// //_curIconFrame++;
+//// //if (_curIconFrame >= _iconResource->count())
+//// // _curIconFrame = 0;
+////
+//// //// Show text
+//// //getText()->drawCentered(MenuIconFixedXpos[iconNum],
+//// // iconFrame->y + 50,
+//// // getText()->getWidth(MAKE_RESOURCE(kResourcePackText, iconNum + 1309)),
+//// // MAKE_RESOURCE(kResourcePackText, iconNum + 1309));
+////
+//// // Play creepy voice
+//// if (_activeScreen != _previousActiveIcon) {
+//// getSound()->playSound(MAKE_RESOURCE(kResourcePackShared, iconNum + 44), false, Config.sfxVolume);
+//// _previousActiveIcon = _activeScreen;
+//// }
+////
+//// break;
+//// }
+//// }
+//}
+//
-void MainMenu::updateMainMenu() {
- //int32 rowId = 0;
-
- //if (getCursor()->position().y >= 20 && getCursor()->position().y <= 20 + 48) {
- // rowId = 0; // Top row
- //} else if (getCursor()->position().y >= 400 && getCursor()->position().y <= 400 + 48) {
- // rowId = 1; // Bottom row
- //} else {
- // // No row selected
- // _previousActiveIcon = _activeScreen = -1;
- // _leftClick = false;
- // return;
- //}
-
- getText()->loadFont(kFontYellow);
-
- // Icon animation
-// for (int32 i = 0; i <= 5; i++) {
-// int32 curX = 40 + i * 100;
-// if (getCursor()->position().x >= curX && getCursor()->position().x <= curX + 55) {
-// int32 iconNum = i + 6 * rowId;
-// _activeScreen = iconNum;
-//
-// // The last 2 icons are swapped
-// if (iconNum == 11)
-// iconNum = 10;
-// else if (iconNum == 10)
-// iconNum = 11;
-//
-// // Get the current icon animation
-// /* if (!_iconResource || _activeScreen != _previousActiveIcon) {
-// delete _iconResource;
-// _iconResource = new GraphicResource(_vm, MAKE_RESOURCE(kResourcePackShared, iconNum + 4));
-// }*/
-//
-// /* GraphicFrame *iconFrame = _iconResource->getFrame(MIN<uint>(_iconResource->count() - 1, _curIconFrame));
-// _vm->screen()->copyRectToScreenWithTransparency((byte *)iconFrame->surface.pixels, iconFrame->surface.w, iconFrame->x, iconFrame->y, iconFrame->surface.w, iconFrame->surface.h);
-//*/
-// //// Cycle icon frame
-// //_curIconFrame++;
-// //if (_curIconFrame >= _iconResource->count())
-// // _curIconFrame = 0;
-//
-// //// Show text
-// //getText()->drawCentered(MenuIconFixedXpos[iconNum],
-// // iconFrame->y + 50,
-// // getText()->getWidth(MAKE_RESOURCE(kResourcePackText, iconNum + 1309)),
-// // MAKE_RESOURCE(kResourcePackText, iconNum + 1309));
-//
-// // Play creepy voice
-// if (_activeScreen != _previousActiveIcon) {
-// getSound()->playSound(MAKE_RESOURCE(kResourcePackShared, iconNum + 44), false, Config.sfxVolume);
-// _previousActiveIcon = _activeScreen;
-// }
-//
-// break;
+//
+//void MainMenu::updateSubMenuNewGame() {
+// getText()->loadFont(kFontYellow);
+//
+// // begin new game
+// getText()->drawCentered(10, 100, 620, MAKE_RESOURCE(kResourcePackText, 529));
+//
+// // Yes
+// switchFont(getCursor()->position().x < 247 || getCursor()->position().x > 247 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 1322)) || getCursor()->position().y < 273 || getCursor()->position().y > 273 + 24);
+// getText()->setPosition(247, 273);
+// getText()->draw(MAKE_RESOURCE(kResourcePackText, 1322));
+//
+// // No
+// switchFont(getCursor()->position().x < 369 || getCursor()->position().x > 369 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 1323)) || getCursor()->position().y < 273 || getCursor()->position().y > 273 + 24);
+// getText()->setPosition(369, 273);
+// getText()->draw(MAKE_RESOURCE(kResourcePackText, 1323));
+//
+// // action
+// //if (_leftClick) {
+// // // Yes
+// // if (getCursor()->position().x >= 247 && getCursor()->position().x <= 247 + 24 && getCursor()->position().y >= 273 && getCursor()->position().y <= 273 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 1322))) {
+// // _leftClick = false;
+// // // TODO closeMenu();
+// // _vm->startGame(kResourcePackTowerCells, AsylumEngine::kStartGamePlayIntro);
+// // }
+// // // No
+// // if (getCursor()->position().x >= 369 && getCursor()->position().x <= 369 + 24 && getCursor()->position().y >= 273 && getCursor()->position().y <= 273 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 1323)))
+// // exitSubMenu();
+// //}
+//}
+//
+//void MainMenu::updateSubMenuCinematics() {
+// int32 currentCD = 1; // FIXME: dummy value
+// getText()->drawCentered(10, 100, 620, MAKE_RESOURCE(kResourcePackText, 1352), currentCD);
+// getText()->setPosition(30, 340);
+// getText()->draw(MAKE_RESOURCE(kResourcePackText, 1353)); // Prev Page
+//
+// //if (getCursor()->position().x >= 280 && getCursor()->position().x <= 400 && getCursor()->position().y >= 340 && getCursor()->position().y <= 360) {
+// // getText()->loadFont(kFontBlue);
+// // if (_leftClick)
+// // exitSubMenu();
+// //} else {
+// // getText()->loadFont(kFontYellow);
+// //}
+//
+// getText()->setPosition(280, 340);
+// getText()->draw(MAKE_RESOURCE(kResourcePackText, 1355)); // Main Menu
+//
+// getText()->loadFont(kFontYellow);
+//
+// getText()->setPosition(500, 340);
+// getText()->draw(MAKE_RESOURCE(kResourcePackText, 1354)); // Next Page
+//}
+//
+//void MainMenu::updateSubMenuSettings() {
+// int32 sizeMinus = getText()->getWidth("-");
+// int32 sizePlus = getText()->getWidth("+");
+// int32 sizeMainMenu = getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 1437));
+//
+// getText()->loadFont(kFontYellow);
+// // Settings
+// getText()->drawCentered(10, 100, 620, MAKE_RESOURCE(kResourcePackText, 1432));
+//
+// // gamma correction
+// getText()->drawAlignedRight(320, 150, MAKE_RESOURCE(kResourcePackText, 1433));
+// switchFont(getCursor()->position().x < 350 || getCursor()->position().x > sizeMinus + 350 || getCursor()->position().y < 150 || getCursor()->position().y > 174);
+// getText()->setPosition(350, 150);
+// getText()->draw("-");
+//
+// switchFont(getCursor()->position().x < sizeMinus + 360 || getCursor()->position().x > sizeMinus + sizePlus + 360 || getCursor()->position().y < 150 || getCursor()->position().y > 174);
+// getText()->setPosition(sizeMinus + 360, 150);
+// getText()->draw("+");
+//
+// getText()->setPosition(sizeMinus + sizePlus + 365, 150);
+// getText()->loadFont(kFontYellow);
+// if (Config.gammaLevel) {
+// for (int32 i = 0; i < Config.gammaLevel; i++) {
+// getText()->draw("]");
// }
+// if (Config.gammaLevel == 8)
+// getText()->draw("*");
+// } else
+// getText()->draw(MAKE_RESOURCE(kResourcePackText, 1435));
+//
+// // performance
+// getText()->loadFont(kFontYellow);
+// getText()->drawAlignedRight(320, 179, MAKE_RESOURCE(kResourcePackText, 1434));
+// switchFont(getCursor()->position().x < 350 || getCursor()->position().x > sizeMinus + 350 || getCursor()->position().y < 179 || getCursor()->position().y > 203);
+// getText()->setPosition(350, 179);
+// getText()->draw("-");
+//
+// switchFont(getCursor()->position().x < sizeMinus + 360 || getCursor()->position().x > sizeMinus + sizePlus + 360 || getCursor()->position().y < 179 || getCursor()->position().y > 203);
+// getText()->setPosition(sizeMinus + 360, 179);
+// getText()->draw("+");
+//
+// getText()->setPosition(sizeMinus + sizePlus + 365, 179);
+// getText()->loadFont(kFontYellow);
+// if (Config.performance == 5) {
+// getText()->draw(MAKE_RESOURCE(kResourcePackText, 1436));
+// } else {
+// for (int32 i = 5; i > Config.performance; --i) {
+// getText()->draw("]");
+// }
+// if (!Config.performance)
+// getText()->draw("*");
// }
-}
-
-void MainMenu::updateSubMenu() {
- //GraphicFrame *iconFrame = _iconResource->getFrame(MIN<uint>(_iconResource->count() - 1, _curIconFrame));
- //_vm->screen()->copyRectToScreenWithTransparency((byte *)iconFrame->surface.pixels, iconFrame->surface.w, iconFrame->x, iconFrame->y, iconFrame->surface.w, iconFrame->surface.h);
-
- // Cycle icon frame
- //_curIconFrame++;
- //if (_curIconFrame >= _iconResource->count())
- // _curIconFrame = 0;
-
- switch (_activeScreen) {
- default:
- break;
-
- case kMenuNewGame:
- updateSubMenuNewGame();
- break;
- case kMenuLoadGame:
- // TODO
- break;
- case kMenuSaveGame:
- // TODO
- break;
- case kMenuDeleteGame:
- // TODO
- break;
- case kMenuViewMovies:
- updateSubMenuCinematics();
- break;
- case kMenuQuitGame:
- updateSubMenuQuitGame();
- break;
- case kMenuTextOptions:
- // TODO
- break;
- case kMenuAudioOptions:
- // TODO
- break;
- case kMenuSettings:
- updateSubMenuSettings();
- break;
- case kMenuKeyboardConfig:
- // TODO
- break;
- case kMenuShowCredits:
- updateSubMenuShowCredits();
- break;
- case kMenuReturnToGame:
- updateSubMenuReturnToGame();
- break;
- }
-}
-
-void MainMenu::updateSubMenuNewGame() {
- getText()->loadFont(kFontYellow);
-
- // begin new game
- getText()->drawCentered(10, 100, 620, MAKE_RESOURCE(kResourcePackText, 529));
-
- // Yes
- switchFont(getCursor()->position().x < 247 || getCursor()->position().x > 247 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 1322)) || getCursor()->position().y < 273 || getCursor()->position().y > 273 + 24);
- getText()->setPosition(247, 273);
- getText()->draw(MAKE_RESOURCE(kResourcePackText, 1322));
-
- // No
- switchFont(getCursor()->position().x < 369 || getCursor()->position().x > 369 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 1323)) || getCursor()->position().y < 273 || getCursor()->position().y > 273 + 24);
- getText()->setPosition(369, 273);
- getText()->draw(MAKE_RESOURCE(kResourcePackText, 1323));
-
- // action
- //if (_leftClick) {
- // // Yes
- // if (getCursor()->position().x >= 247 && getCursor()->position().x <= 247 + 24 && getCursor()->position().y >= 273 && getCursor()->position().y <= 273 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 1322))) {
- // _leftClick = false;
- // // TODO closeMenu();
- // _vm->startGame(kResourcePackTowerCells, AsylumEngine::kStartGamePlayIntro);
- // }
- // // No
- // if (getCursor()->position().x >= 369 && getCursor()->position().x <= 369 + 24 && getCursor()->position().y >= 273 && getCursor()->position().y <= 273 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 1323)))
- // exitSubMenu();
- //}
-}
-
-void MainMenu::updateSubMenuCinematics() {
- int32 currentCD = 1; // FIXME: dummy value
- getText()->drawCentered(10, 100, 620, MAKE_RESOURCE(kResourcePackText, 1352), currentCD);
- getText()->setPosition(30, 340);
- getText()->draw(MAKE_RESOURCE(kResourcePackText, 1353)); // Prev Page
-
- //if (getCursor()->position().x >= 280 && getCursor()->position().x <= 400 && getCursor()->position().y >= 340 && getCursor()->position().y <= 360) {
- // getText()->loadFont(kFontBlue);
- // if (_leftClick)
- // exitSubMenu();
- //} else {
- // getText()->loadFont(kFontYellow);
- //}
-
- getText()->setPosition(280, 340);
- getText()->draw(MAKE_RESOURCE(kResourcePackText, 1355)); // Main Menu
-
- getText()->loadFont(kFontYellow);
-
- getText()->setPosition(500, 340);
- getText()->draw(MAKE_RESOURCE(kResourcePackText, 1354)); // Next Page
-}
-
-void MainMenu::updateSubMenuSettings() {
- int32 sizeMinus = getText()->getWidth("-");
- int32 sizePlus = getText()->getWidth("+");
- int32 sizeMainMenu = getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 1437));
-
- getText()->loadFont(kFontYellow);
- // Settings
- getText()->drawCentered(10, 100, 620, MAKE_RESOURCE(kResourcePackText, 1432));
-
- // gamma correction
- getText()->drawAlignedRight(320, 150, MAKE_RESOURCE(kResourcePackText, 1433));
- switchFont(getCursor()->position().x < 350 || getCursor()->position().x > sizeMinus + 350 || getCursor()->position().y < 150 || getCursor()->position().y > 174);
- getText()->setPosition(350, 150);
- getText()->draw("-");
-
- switchFont(getCursor()->position().x < sizeMinus + 360 || getCursor()->position().x > sizeMinus + sizePlus + 360 || getCursor()->position().y < 150 || getCursor()->position().y > 174);
- getText()->setPosition(sizeMinus + 360, 150);
- getText()->draw("+");
-
- getText()->setPosition(sizeMinus + sizePlus + 365, 150);
- getText()->loadFont(kFontYellow);
- if (Config.gammaLevel) {
- for (int32 i = 0; i < Config.gammaLevel; i++) {
- getText()->draw("]");
- }
- if (Config.gammaLevel == 8)
- getText()->draw("*");
- } else
- getText()->draw(MAKE_RESOURCE(kResourcePackText, 1435));
-
- // performance
- getText()->loadFont(kFontYellow);
- getText()->drawAlignedRight(320, 179, MAKE_RESOURCE(kResourcePackText, 1434));
- switchFont(getCursor()->position().x < 350 || getCursor()->position().x > sizeMinus + 350 || getCursor()->position().y < 179 || getCursor()->position().y > 203);
- getText()->setPosition(350, 179);
- getText()->draw("-");
-
- switchFont(getCursor()->position().x < sizeMinus + 360 || getCursor()->position().x > sizeMinus + sizePlus + 360 || getCursor()->position().y < 179 || getCursor()->position().y > 203);
- getText()->setPosition(sizeMinus + 360, 179);
- getText()->draw("+");
-
- getText()->setPosition(sizeMinus + sizePlus + 365, 179);
- getText()->loadFont(kFontYellow);
- if (Config.performance == 5) {
- getText()->draw(MAKE_RESOURCE(kResourcePackText, 1436));
- } else {
- for (int32 i = 5; i > Config.performance; --i) {
- getText()->draw("]");
- }
- if (!Config.performance)
- getText()->draw("*");
- }
-
- // back to main menu
- switchFont(getCursor()->position().x < 300 || getCursor()->position().x > 300 + sizeMainMenu || getCursor()->position().y < 340 || getCursor()->position().y > 340 + 24);
- getText()->setPosition(300, 340);
- getText()->draw(MAKE_RESOURCE(kResourcePackText, 1437));
-
- // action
- //if (_leftClick) {
- // // back to main menu
- // if (getCursor()->position().x >= 300 && getCursor()->position().x <= 300 + sizeMainMenu && getCursor()->position().y >= 340 && getCursor()->position().y <= 340 + 24) {
- // // TODO: save new configurations
- // exitSubMenu();
- // }
-
- // // gamma level minus
- // if (getCursor()->position().x >= 350 && getCursor()->position().x <= sizeMinus + 350 && getCursor()->position().y >= 150 && getCursor()->position().y <= 174) {
- // if (Config.gammaLevel) {
- // Config.gammaLevel -= 1;
- // // TODO: setResGammaLevel(0x80010011, 0);
- // }
- // }
- // // gamma level plus
- // if (getCursor()->position().x >= sizeMinus + 360 && getCursor()->position().x <= sizeMinus + sizePlus + 360 && getCursor()->position().y >= 150 && getCursor()->position().y <= 174) {
- // if (Config.gammaLevel < 8) {
- // Config.gammaLevel += 1;
- // // TODO: setResGammaLevel(0x80010011, 0);
- // }
- // }
-
- // // performance minus
- // if (getCursor()->position().x >= 350 && getCursor()->position().x <= sizeMinus + 350 && getCursor()->position().y >= 179 && getCursor()->position().y <= 203) {
- // if (Config.performance) {
- // Config.performance -= 1;
- // // TODO: change quality settings
- // }
- // }
- // // performance plus
- // if (getCursor()->position().x >= sizeMinus + 360 && getCursor()->position().x <= sizeMinus + sizePlus + 360 && getCursor()->position().y >= 179 && getCursor()->position().y <= 203) {
- // if (Config.performance < 5) {
- // Config.performance += 1;
- // // TODO: change quality settings
- // }
- // }
- //}
-}
-
-void MainMenu::updateSubMenuQuitGame() {
- getText()->loadFont(kFontYellow);
-
- // begin new game
- getText()->drawCentered(10, 100, 620, MAKE_RESOURCE(kResourcePackText, 1408));
-
- // Yes
- switchFont(getCursor()->position().x < 247 || getCursor()->position().x > 247 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 581)) || getCursor()->position().y < 273 || getCursor()->position().y > 273 + 24);
- getText()->setPosition(247, 273);
- getText()->draw(MAKE_RESOURCE(kResourcePackText, 1409));
-
- // No
- switchFont(getCursor()->position().x < 369 || getCursor()->position().x > 369 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 582)) || getCursor()->position().y < 273 || getCursor()->position().y > 273 + 24);
- getText()->setPosition(369, 273);
- getText()->draw(MAKE_RESOURCE(kResourcePackText, 1410));
-
- //// action
- //if (_leftClick) {
- // // Yes
- // if (getCursor()->position().x >= 247 && getCursor()->position().x <= 247 + 24 && getCursor()->position().y >= 273 && getCursor()->position().y <= 273 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 1409))) {
- // _leftClick = false;
-
- // // User clicked on quit, so push a quit event
- // Common::Event event;
- // event.type = Common::EVENT_QUIT;
- // g_system->getEventManager()->pushEvent(event);
- // }
- // // No
- // if (getCursor()->position().x >= 369 && getCursor()->position().x <= 369 + 24 && getCursor()->position().y >= 273 && getCursor()->position().y <= 273 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 1410)))
- // exitSubMenu();
- //}
-}
-
-void MainMenu::updateSubMenuShowCredits() {
- //int32 posY = _creditsTextScroll;
- //ResourceId resourceId = kResourceNone;
- //int32 step = 0;
- //int32 minBound = 0;
- //int32 maxBound = 0;
-
- ////GraphicFrame *creditsFadeFrame = _creditsFadeResource->getFrame(0);
- ////_vm->screen()->copyRectToScreenWithTransparency((byte *)creditsFadeFrame->surface.pixels, creditsFadeFrame->surface.w, creditsFadeFrame->x, creditsFadeFrame->y, creditsFadeFrame->surface.w, creditsFadeFrame->surface.h);
-
- ////GraphicFrame *creditsFrame = _creditsResource->getFrame(MIN<uint>(_creditsResource->count() - 1, _creditsBgFrame));
- ////_vm->screen()->copyRectToScreenWithTransparency((byte *)creditsFrame->surface.pixels, creditsFrame->surface.w, creditsFrame->x, creditsFrame->y, creditsFrame->surface.w, creditsFrame->surface.h);
-
- ////_creditsBgFrame++;
- ////if (_creditsBgFrame >= _creditsResource->count())
- //// _creditsBgFrame = 0;
-
- //do {
- // if (posY + step >= 0) {
- // if (posY + step > 450)
- // break;
-
- // minBound = posY + step + 24;
- // if (minBound >= 0)
- // if (minBound < 32) {
- // // TODO fade side text
- // posY = _creditsTextScroll;
- // }
-
- // maxBound = posY + step;
- // if (posY + step < 480)
- // if (maxBound > 448) {
- // // TODO fade side text
- // posY = _creditsTextScroll;
- // }
-
- // getText()->setPosition(320, step + posY);
- // getText()->draw((ResourceId)(resourceId - 2147482201));
- // posY = _creditsTextScroll;
- // }
- // step += 24;
- // resourceId = (ResourceId)(resourceId + 1);
- //} while (step < 0x21F0);
-
- //_creditsTextScroll -= 2;
-
- //// TODO: some palette stuffs
-
- //// TODO: if gameFlag=901 (finished game) and already play music 56, start music 40
-
- //if (_leftClick) {
- // // Restore palette
- // _vm->screen()->setPalette(MAKE_RESOURCE(kResourcePackShared, 17));
- // // Stop all sounds
- // _vm->sound()->stopMusic();
- // // Start playing music
- // _vm->sound()->playMusic(MAKE_RESOURCE(kResourcePackShared, 39));
- // exitSubMenu();
- //}
-}
-
-void MainMenu::exitSubMenu() {
- //_leftClick = false;
- //_activeScreen = kMenuMain;
-
- //// Copy the bright background to the back buffer
- //getScreen()->draw(MAKE_RESOURCE(kResourcePackShared, 0), 1, 0, 0, 0);
-
- //// Set the cursor
- //getCursor()->set(MAKE_RESOURCE(kResourcePackShared, 2));
-}
-
-void MainMenu::updateSubMenuReturnToGame() {
- getText()->loadFont(kFontYellow);
-
- // no game loaded
- getText()->drawCentered(10, 100, 620, MAKE_RESOURCE(kResourcePackText, 712));
-
- // Main menu
- switchFont(getCursor()->position().x < 285 || getCursor()->position().x > 285 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 713)) || getCursor()->position().y < 273 || getCursor()->position().y > 273 + 24);
- getText()->setPosition(285, 273);
- getText()->draw(MAKE_RESOURCE(kResourcePackText, 713));
-
- // action
- //if (_leftClick) {
- // // Main menu
- // if (getCursor()->position().x >= 285 && getCursor()->position().x <= 285 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 713)) && getCursor()->position().y >= 273 && getCursor()->position().y <= 273 + 24)
- // exitSubMenu();
- //}
-}
+//
+// // back to main menu
+// switchFont(getCursor()->position().x < 300 || getCursor()->position().x > 300 + sizeMainMenu || getCursor()->position().y < 340 || getCursor()->position().y > 340 + 24);
+// getText()->setPosition(300, 340);
+// getText()->draw(MAKE_RESOURCE(kResourcePackText, 1437));
+//
+// // action
+// //if (_leftClick) {
+// // // back to main menu
+// // if (getCursor()->position().x >= 300 && getCursor()->position().x <= 300 + sizeMainMenu && getCursor()->position().y >= 340 && getCursor()->position().y <= 340 + 24) {
+// // // TODO: save new configurations
+// // exitSubMenu();
+// // }
+//
+// // // gamma level minus
+// // if (getCursor()->position().x >= 350 && getCursor()->position().x <= sizeMinus + 350 && getCursor()->position().y >= 150 && getCursor()->position().y <= 174) {
+// // if (Config.gammaLevel) {
+// // Config.gammaLevel -= 1;
+// // // TODO: setResGammaLevel(0x80010011, 0);
+// // }
+// // }
+// // // gamma level plus
+// // if (getCursor()->position().x >= sizeMinus + 360 && getCursor()->position().x <= sizeMinus + sizePlus + 360 && getCursor()->position().y >= 150 && getCursor()->position().y <= 174) {
+// // if (Config.gammaLevel < 8) {
+// // Config.gammaLevel += 1;
+// // // TODO: setResGammaLevel(0x80010011, 0);
+// // }
+// // }
+//
+// // // performance minus
+// // if (getCursor()->position().x >= 350 && getCursor()->position().x <= sizeMinus + 350 && getCursor()->position().y >= 179 && getCursor()->position().y <= 203) {
+// // if (Config.performance) {
+// // Config.performance -= 1;
+// // // TODO: change quality settings
+// // }
+// // }
+// // // performance plus
+// // if (getCursor()->position().x >= sizeMinus + 360 && getCursor()->position().x <= sizeMinus + sizePlus + 360 && getCursor()->position().y >= 179 && getCursor()->position().y <= 203) {
+// // if (Config.performance < 5) {
+// // Config.performance += 1;
+// // // TODO: change quality settings
+// // }
+// // }
+// //}
+//}
+//
+//void MainMenu::updateSubMenuQuitGame() {
+// getText()->loadFont(kFontYellow);
+//
+// // begin new game
+// getText()->drawCentered(10, 100, 620, MAKE_RESOURCE(kResourcePackText, 1408));
+//
+// // Yes
+// switchFont(getCursor()->position().x < 247 || getCursor()->position().x > 247 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 581)) || getCursor()->position().y < 273 || getCursor()->position().y > 273 + 24);
+// getText()->setPosition(247, 273);
+// getText()->draw(MAKE_RESOURCE(kResourcePackText, 1409));
+//
+// // No
+// switchFont(getCursor()->position().x < 369 || getCursor()->position().x > 369 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 582)) || getCursor()->position().y < 273 || getCursor()->position().y > 273 + 24);
+// getText()->setPosition(369, 273);
+// getText()->draw(MAKE_RESOURCE(kResourcePackText, 1410));
+//
+// //// action
+// //if (_leftClick) {
+// // // Yes
+// // if (getCursor()->position().x >= 247 && getCursor()->position().x <= 247 + 24 && getCursor()->position().y >= 273 && getCursor()->position().y <= 273 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 1409))) {
+// // _leftClick = false;
+//
+// // // User clicked on quit, so push a quit event
+// // Common::Event event;
+// // event.type = Common::EVENT_QUIT;
+// // g_system->getEventManager()->pushEvent(event);
+// // }
+// // // No
+// // if (getCursor()->position().x >= 369 && getCursor()->position().x <= 369 + 24 && getCursor()->position().y >= 273 && getCursor()->position().y <= 273 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 1410)))
+// // exitSubMenu();
+// //}
+//}
+//
+//void MainMenu::updateSubMenuShowCredits() {
+// //int32 posY = _creditsTextScroll;
+// //ResourceId resourceId = kResourceNone;
+// //int32 step = 0;
+// //int32 minBound = 0;
+// //int32 maxBound = 0;
+//
+// ////GraphicFrame *creditsFadeFrame = _creditsFadeResource->getFrame(0);
+// ////_vm->screen()->copyRectToScreenWithTransparency((byte *)creditsFadeFrame->surface.pixels, creditsFadeFrame->surface.w, creditsFadeFrame->x, creditsFadeFrame->y, creditsFadeFrame->surface.w, creditsFadeFrame->surface.h);
+//
+// ////GraphicFrame *creditsFrame = _creditsResource->getFrame(MIN<uint>(_creditsResource->count() - 1, _creditsBgFrame));
+// ////_vm->screen()->copyRectToScreenWithTransparency((byte *)creditsFrame->surface.pixels, creditsFrame->surface.w, creditsFrame->x, creditsFrame->y, creditsFrame->surface.w, creditsFrame->surface.h);
+//
+// ////_creditsBgFrame++;
+// ////if (_creditsBgFrame >= _creditsResource->count())
+// //// _creditsBgFrame = 0;
+//
+// //do {
+// // if (posY + step >= 0) {
+// // if (posY + step > 450)
+// // break;
+//
+// // minBound = posY + step + 24;
+// // if (minBound >= 0)
+// // if (minBound < 32) {
+// // // TODO fade side text
+// // posY = _creditsTextScroll;
+// // }
+//
+// // maxBound = posY + step;
+// // if (posY + step < 480)
+// // if (maxBound > 448) {
+// // // TODO fade side text
+// // posY = _creditsTextScroll;
+// // }
+//
+// // getText()->setPosition(320, step + posY);
+// // getText()->draw((ResourceId)(resourceId - 2147482201));
+// // posY = _creditsTextScroll;
+// // }
+// // step += 24;
+// // resourceId = (ResourceId)(resourceId + 1);
+// //} while (step < 0x21F0);
+//
+// //_creditsTextScroll -= 2;
+//
+// //// TODO: some palette stuffs
+//
+// //// TODO: if gameFlag=901 (finished game) and already play music 56, start music 40
+//
+// //if (_leftClick) {
+// // // Restore palette
+// // _vm->screen()->setPalette(MAKE_RESOURCE(kResourcePackShared, 17));
+// // // Stop all sounds
+// // _vm->sound()->stopMusic();
+// // // Start playing music
+// // _vm->sound()->playMusic(MAKE_RESOURCE(kResourcePackShared, 39));
+// // exitSubMenu();
+// //}
+//}
+//
+//void MainMenu::exitSubMenu() {
+// //_leftClick = false;
+// //_activeScreen = kMenuMain;
+//
+// //// Copy the bright background to the back buffer
+// //getScreen()->draw(MAKE_RESOURCE(kResourcePackShared, 0), 1, 0, 0, 0);
+//
+// //// Set the cursor
+// //getCursor()->set(MAKE_RESOURCE(kResourcePackShared, 2));
+//}
+//
+//void MainMenu::updateSubMenuReturnToGame() {
+// getText()->loadFont(kFontYellow);
+//
+// // no game loaded
+// getText()->drawCentered(10, 100, 620, MAKE_RESOURCE(kResourcePackText, 712));
+//
+// // Main menu
+// switchFont(getCursor()->position().x < 285 || getCursor()->position().x > 285 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 713)) || getCursor()->position().y < 273 || getCursor()->position().y > 273 + 24);
+// getText()->setPosition(285, 273);
+// getText()->draw(MAKE_RESOURCE(kResourcePackText, 713));
+//
+// // action
+// //if (_leftClick) {
+// // // Main menu
+// // if (getCursor()->position().x >= 285 && getCursor()->position().x <= 285 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 713)) && getCursor()->position().y >= 273 && getCursor()->position().y <= 273 + 24)
+// // exitSubMenu();
+// //}
+//}
} // end of namespace Asylum
diff --git a/engines/asylum/views/menu.h b/engines/asylum/views/menu.h
index 5a41594eb1..12990be99a 100644
--- a/engines/asylum/views/menu.h
+++ b/engines/asylum/views/menu.h
@@ -60,19 +60,6 @@ public:
private:
AsylumEngine *_vm;
- enum EyesAnimation {
- kEyesFront = 0,
- kEyesLeft = 1,
- kEyesRight = 2,
- kEyesTop = 3,
- kEyesBottom = 4,
- kEyesTopLeft = 5,
- kEyesTopRight = 6,
- kEyesBottomLeft = 7,
- kEyesBottomRight = 8,
- kEyesCrossed = 9
- };
-
enum MenuScreen {
kMenuNone = -1,
kMenuNewGame = 0,
@@ -85,8 +72,8 @@ private:
kMenuAudioOptions = 7,
kMenuSettings = 8,
kMenuKeyboardConfig = 9,
- kMenuShowCredits = 10,
- kMenuReturnToGame = 11
+ kMenuReturnToGame = 10,
+ kMenuShowCredits = 11
};
enum MenuResource {
@@ -96,24 +83,15 @@ private:
kFontYellow = MAKE_RESOURCE(kResourcePackShared, 16)
};
- //int32 _activeIcon;
- //int32 _previousActiveIcon;
- //uint32 _curIconFrame;
- //int32 _curMouseCursor;
- //int32 _cursorStep;
- //uint32 _creditsBgFrame;
- //int32 _creditsTextScroll;
- //bool _leftClick;
- //bool _active;
-
// Game initialization
bool _initGame;
// Data
MenuScreen _activeScreen;
ResourceId _soundResourceId;
+ ResourceId _musicResourceId;
bool _allowInteraction;
- int32 _dword_4464BC;
+ MenuScreen _currentIcon;
int32 _dword_455C74;
bool _dword_455D4C;
bool _dword_455D5C;
@@ -128,6 +106,11 @@ private:
*/
void setup();
+ /**
+ * Leaves an opened menu
+ */
+ void leave();
+
/**
* Switch between fonts.
*
@@ -135,6 +118,18 @@ private:
*/
void switchFont(bool condition);
+ /**
+ * Shows the credits.
+ */
+ void showCredits();
+
+ /**
+ * Find if the mouse if on an icon
+ *
+ * @return The icon identifier
+ */
+ MenuScreen findMousePosition();
+
//////////////////////////////////////////////////////////////////////////
// Message handling
bool init();
@@ -143,9 +138,6 @@ private:
bool key(const AsylumEvent &evt);
bool click(const AsylumEvent &evt);
- // Helpers
- MenuScreen findMousePosition();
-
// Update handlers
void updateNewGame();
void updateLoadGame();
@@ -157,8 +149,8 @@ private:
void updateAudioOptions();
void updateSettings();
void updateKeyboardConfig();
- void updateShowCredits();
void updateReturnToGame();
+ void updateShowCredits();
// Click handlers
void clickNewGame();
@@ -171,21 +163,14 @@ private:
void clickAudioOptions();
void clickSettings();
void clickKeyboardConfig();
- void clickShowCredits();
void clickReturnToGame();
+ void clickShowCredits();
+ // Key handlers
+ void keySaveGame();
+ void keyKeyboardConfig();
+ void keyShowCredits();
- // TODO remove
- void updateMainMenu();
-
- void updateSubMenu();
- void exitSubMenu();
- void updateSubMenuNewGame();
- void updateSubMenuCinematics();
- void updateSubMenuSettings();
- void updateSubMenuQuitGame();
- void updateSubMenuShowCredits();
- void updateSubMenuReturnToGame();
}; // end of class MainMenu
} // end of namespace Asylum
Commit: 912e3131a3399928c36c25a376993ddffa54604e
https://github.com/scummvm/scummvm/commit/912e3131a3399928c36c25a376993ddffa54604e
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:27+02:00
Commit Message:
ASYLUM: Implement MainMenu::click()
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@602 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/system/savegame.cpp
engines/asylum/system/savegame.h
engines/asylum/views/menu.cpp
engines/asylum/views/menu.h
diff --git a/engines/asylum/system/savegame.cpp b/engines/asylum/system/savegame.cpp
index 9615a332af..bb0379ff02 100644
--- a/engines/asylum/system/savegame.cpp
+++ b/engines/asylum/system/savegame.cpp
@@ -45,4 +45,8 @@ void Savegame::loadViewedMovies() {
warning("[Savegame::loadViewedMovies] Not implemented!");
}
+void Savegame::loadList() {
+ warning("[Savegame::loadList] Not implemented!");
+}
+
} // End of namespace Asylum
diff --git a/engines/asylum/system/savegame.h b/engines/asylum/system/savegame.h
index ac1ebbddb2..a564ae9187 100644
--- a/engines/asylum/system/savegame.h
+++ b/engines/asylum/system/savegame.h
@@ -36,8 +36,11 @@ public:
~Savegame();
bool setup();
+
void loadViewedMovies();
+ void loadList();
+
private:
AsylumEngine* _vm;
};
diff --git a/engines/asylum/views/menu.cpp b/engines/asylum/views/menu.cpp
index f3782a6d3a..28fcf3064f 100644
--- a/engines/asylum/views/menu.cpp
+++ b/engines/asylum/views/menu.cpp
@@ -52,9 +52,14 @@ MainMenu::MainMenu(AsylumEngine *vm): _vm(vm) {
_soundResourceId = kResourceNone;
_allowInteraction = false;
_currentIcon = kMenuNone;
+ _dword_4464B8 = -1;
_dword_455C74 = 0;
- _dword_455D4C = 0;
- _dword_455D5C = 0;
+ _dword_455C78 = false;
+ _dword_455C80 = false;
+ _dword_455D4C = false;
+ _dword_455D5C = false;
+ _dword_455DD8 = false;
+ _dword_456288 = 0;
_dword_4562C0 = 0;
_dword_4562C4 = 0;
_dword_45628C = 0;
@@ -167,6 +172,9 @@ void MainMenu::showCredits() {
leave();
}
+void MainMenu::listMovies() {
+ warning("[MainMenu::listMovies] Not implemented!");
+}
MainMenu::MenuScreen MainMenu::findMousePosition() {
for (uint i = 0; i < ARRAYSIZE(menuRects); i++)
@@ -201,9 +209,7 @@ bool MainMenu::handleEvent(const AsylumEvent &evt) {
break;
case Common::EVENT_LBUTTONDOWN:
- case Common::EVENT_LBUTTONUP:
case Common::EVENT_RBUTTONDOWN:
- case Common::EVENT_RBUTTONUP:
return click(evt);
break;
}
@@ -221,12 +227,12 @@ bool MainMenu::init() {
if (!_initGame) {
_initGame = true;
- // The original load the config (this is done when constructing the config object)
+ // The original also
+ // - load the config (this is done when constructing the config object).
+ // - initialize game structures (this is done in classes constructors)
getSaveLoad()->loadViewedMovies();
- // The original initialize game structures (this is done in classes constructors)
-
_needEyeCursorInit = true;
// Play start video
@@ -439,6 +445,128 @@ bool MainMenu::key(const AsylumEvent &evt) {
}
bool MainMenu::click(const AsylumEvent &evt) {
+ if (evt.type == Common::EVENT_RBUTTONDOWN
+ && _activeScreen == kMenuShowCredits) {
+ clickShowCredits();
+ return true;
+ }
+
+ //////////////////////////////////////////////////////////////////////////
+ // Handle clicks on sub-screens
+ if (_activeScreen != kMenuNone) {
+ switch (_activeScreen) {
+ default:
+ break;
+
+ case kMenuNewGame:
+ updateNewGame();
+ break;
+
+ case kMenuLoadGame:
+ updateLoadGame();
+ break;
+
+ case kMenuSaveGame:
+ updateSaveGame();
+ break;
+
+ case kMenuDeleteGame:
+ updateDeleteGame();
+ break;
+
+ case kMenuViewMovies:
+ updateViewMovies();
+ break;
+
+ case kMenuQuitGame:
+ updateQuitGame();
+ break;
+
+ case kMenuTextOptions:
+ updateTextOptions();
+ break;
+
+ case kMenuAudioOptions:
+ updateAudioOptions();
+ break;
+
+ case kMenuSettings:
+ updateSettings();
+ break;
+
+ case kMenuKeyboardConfig:
+ updateKeyboardConfig();
+ break;
+
+ case kMenuShowCredits:
+ updateShowCredits();
+ break;
+
+ case kMenuReturnToGame:
+ updateReturnToGame();
+ break;
+ }
+
+ return true;
+ }
+
+ //////////////////////////////////////////////////////////////////////////
+ // Handle clicks on the main menu
+ _activeScreen = findMousePosition();
+ if (_activeScreen == kMenuNone)
+ return true;
+
+ getCursor()->set(MAKE_RESOURCE(kResourcePackShared, 3), 0, 2);
+ getText()->loadFont(kFontYellow);
+
+ switch (_activeScreen) {
+ default:
+ break;
+
+ case kMenuSaveGame:
+ _dword_455DD8 = false;
+ // Fallback to next case
+
+ case kMenuLoadGame:
+ _dword_455C80 = false;
+ _dword_455C78 = false;
+ _dword_456288 = 0;
+ _dword_4562C4 = 0;
+ getSaveLoad()->loadList();
+ break;
+
+ case kMenuDeleteGame:
+ _dword_455C80 = false;
+ _dword_4562C4 = 0;
+ getSaveLoad()->loadList();
+ break;
+
+ case kMenuViewMovies:
+ _needEyeCursorInit = false;
+ _dword_455C78 = false;
+ _dword_456288 = 0;
+ _dword_4562C4 = 0;
+ listMovies();
+ break;
+
+ case kMenuKeyboardConfig:
+ _dword_4464B8 = -1;
+ break;
+
+ case kMenuReturnToGame:
+ if (!_allowInteraction)
+ break;
+
+ clickReturnToGame();
+ break;
+
+ case kMenuShowCredits:
+ _dword_4562C4 = 480;
+ _dword_45628C = 0;
+ setup();
+ break;
+ }
+
return true;
}
diff --git a/engines/asylum/views/menu.h b/engines/asylum/views/menu.h
index 12990be99a..34d5ec5813 100644
--- a/engines/asylum/views/menu.h
+++ b/engines/asylum/views/menu.h
@@ -92,9 +92,14 @@ private:
ResourceId _musicResourceId;
bool _allowInteraction;
MenuScreen _currentIcon;
+ int32 _dword_4464B8;
int32 _dword_455C74;
+ bool _dword_455C78;
+ bool _dword_455C80;
bool _dword_455D4C;
bool _dword_455D5C;
+ bool _dword_455DD8;
+ int32 _dword_456288;
int32 _dword_4562C0;
int32 _dword_4562C4;
int32 _dword_45628C;
@@ -123,6 +128,11 @@ private:
*/
void showCredits();
+ /**
+ * List viewed movies
+ */
+ void listMovies();
+
/**
* Find if the mouse if on an icon
*
Commit: 1286a8bdc42485956f7df542745aa37a12e7fb9b
https://github.com/scummvm/scummvm/commit/1286a8bdc42485956f7df542745aa37a12e7fb9b
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:27+02:00
Commit Message:
ASYLUM: Add back Menu credits, new game, quit and return to game
- Fix text flickering
- Remove obsolete methods in Screen and Text classes
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@603 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/system/screen.cpp
engines/asylum/system/screen.h
engines/asylum/system/text.cpp
engines/asylum/system/text.h
engines/asylum/views/menu.cpp
engines/asylum/views/menu.h
engines/asylum/views/scene.cpp
engines/asylum/views/scene.h
engines/asylum/views/scenetitle.cpp
diff --git a/engines/asylum/system/screen.cpp b/engines/asylum/system/screen.cpp
index f613dcb8ce..0982bb71e2 100644
--- a/engines/asylum/system/screen.cpp
+++ b/engines/asylum/system/screen.cpp
@@ -115,24 +115,6 @@ void Screen::copyToBackBufferWithTransparency(byte *buffer, int32 pitch, int32 x
}
}
-void Screen::copyRectToScreenWithTransparency(byte *buffer, int32 pitch, int32 x, int32 y, int32 width, int32 height) const {
- byte *screenBuffer = (byte *)_vm->_system->lockScreen()->pixels;
-
- int32 left = (x < 0) ? -x : 0;
- int32 top = (y < 0) ? -y : 0;
- int32 right = (x + width > 640) ? 640 - abs(x) : width;
- int32 bottom = (y + height > 480) ? 480 - abs(y) : height;
-
- for (int32 curY = top; curY < bottom; curY++) {
- for (int32 curX = left; curX < right; curX++) {
- if (buffer[curX + curY * pitch] != 0) {
- screenBuffer[x + curX + (y + curY) * 640] = buffer[curX + curY * pitch];
- }
- }
- }
-
- _vm->_system->unlockScreen();
-}
void Screen::setPalette(ResourceId id) {
setPalette(getResource()->get(id)->data + 32);
diff --git a/engines/asylum/system/screen.h b/engines/asylum/system/screen.h
index dfe6c1f752..91f4cc1364 100644
--- a/engines/asylum/system/screen.h
+++ b/engines/asylum/system/screen.h
@@ -98,7 +98,6 @@ public:
// TODO Make those private
void copyToBackBufferWithTransparency(byte *buffer, int32 pitch, int32 x, int32 y, int32 width, int32 height);
- void copyRectToScreenWithTransparency(byte *buffer, int32 pitch, int32 x, int32 y, int32 width, int32 height) const;
void copyBackBufferToScreen();
private:
diff --git a/engines/asylum/system/text.cpp b/engines/asylum/system/text.cpp
index ae52553245..a7a4699f21 100644
--- a/engines/asylum/system/text.cpp
+++ b/engines/asylum/system/text.cpp
@@ -41,6 +41,7 @@ Text::Text(AsylumEngine *engine) : _vm(engine) {
_posY = 0;
_curFontFlags = 0;
_fontResource = 0;
+ _transTableNum = 0;
}
Text::~Text() {
@@ -122,15 +123,17 @@ void Text::drawChar(char character) {
if (!_fontResource)
error("[Text::drawChar] font resource hasn't been loaded yet!");
- // TODO Add proper methods to screen class (also used by all other drawing calls)
- /*if (getScreen()->getCurrentTransTableNum()) {
- getScreen()->drawTransparent(_fontResource->getResourceId(), (uint8)character, _posX, _posY, 0, getScreen()->getCurrentTransTableNum());
- } else {
- getScreen()->draw(_fontResource->getResourceId(), (uint8)character, _posX, _posY, 0);
- }
- */
+ //if (_transTableNum) {
+ // getScreen()->draw(_fontResource->getResourceId(), (uint8)character, _posX, _posY, 0, _transTableNum);
+ //} else {
+ // getScreen()->draw(_fontResource->getResourceId(), (uint8)character, _posX, _posY, 0);
+ //}
+
GraphicFrame *fontLetter = _fontResource->getFrame((uint8)character);
- getScreen()->copyRectToScreenWithTransparency((byte *)fontLetter->surface.pixels, fontLetter->surface.w, _posX, _posY + fontLetter->y, fontLetter->surface.w, fontLetter->surface.h);
+ getScreen()->copyToBackBufferWithTransparency((byte *)fontLetter->surface.pixels, fontLetter->surface.w, _posX, _posY + fontLetter->y, fontLetter->surface.w, fontLetter->surface.h);
+
+ // TODO remove
+
_posX += fontLetter->surface.w + fontLetter->x - _curFontFlags;
}
@@ -285,25 +288,8 @@ void Text::drawCentered(int32 x, int32 y, int32 width, uint32 length, const char
draw(text, length);
}
-void Text::drawCentered(int32 x, int32 y, int32 width, ResourceId resourceId, int32 value) {
- ResourceEntry *textRes = getResource()->get(resourceId);
- char *text = (char *)textRes->data;
- char txt[100];
- sprintf(txt, text, value);
- drawCentered(x, y, width, txt);
-}
-
void Text::drawCentered(int32 x, int32 y, int32 width, ResourceId resourceId) {
drawCentered(x, y, width, get(resourceId));
}
-void Text::drawAlignedRight(int32 x, int32 y, const char *text) {
- setPosition(x - getWidth(text), y);
- draw(text);
-}
-
-void Text::drawAlignedRight(int32 x, int32 y, ResourceId resourceId) {
- drawAlignedRight(x, y, get(resourceId));
-}
-
} // end of namespace Asylum
diff --git a/engines/asylum/system/text.h b/engines/asylum/system/text.h
index 3a4e3baf04..f374c08200 100644
--- a/engines/asylum/system/text.h
+++ b/engines/asylum/system/text.h
@@ -64,16 +64,15 @@ public:
void drawCentered(int32 x, int32 y, int32 width, ResourceId resourceId);
void drawCentered(int32 x, int32 y, int32 width, uint32 length, const char *text);
- // TODO remove and use other methods
- void drawCentered(int32 x, int32 y, int32 width, ResourceId resourceId, int32 value);
- void drawAlignedRight(int32 x, int32 y, const char *text);
- void drawAlignedRight(int32 x, int32 y, ResourceId resourceId);
+ void setTransTableNum(int32 val) { _transTableNum = val; }
private:
AsylumEngine *_vm;
GraphicResource *_fontResource;
+ int32 _transTableNum;
+
int32 _posX;
int32 _posY;
uint8 _curFontFlags;
diff --git a/engines/asylum/views/menu.cpp b/engines/asylum/views/menu.cpp
index 28fcf3064f..9a0e0ec39d 100644
--- a/engines/asylum/views/menu.cpp
+++ b/engines/asylum/views/menu.cpp
@@ -26,6 +26,7 @@
#include "asylum/views/menu.h"
#include "asylum/resources/actor.h"
+#include "asylum/resources/worldstats.h"
#include "asylum/system/config.h"
#include "asylum/system/cursor.h"
@@ -50,7 +51,8 @@ MainMenu::MainMenu(AsylumEngine *vm): _vm(vm) {
_activeScreen = kMenuNone;
_soundResourceId = kResourceNone;
- _allowInteraction = false;
+ _musicResourceId = kResourceNone;
+ _gameStarted = false;
_currentIcon = kMenuNone;
_dword_4464B8 = -1;
_dword_455C74 = 0;
@@ -61,8 +63,8 @@ MainMenu::MainMenu(AsylumEngine *vm): _vm(vm) {
_dword_455DD8 = false;
_dword_456288 = 0;
_dword_4562C0 = 0;
- _dword_4562C4 = 0;
- _dword_45628C = 0;
+ _creditsTextScroll = 0;
+ _creditsFrameIndex = 0;
_needEyeCursorInit = false;
memset(&_iconFrames, 0, sizeof(_iconFrames));
@@ -88,10 +90,10 @@ void MainMenu::show() {
_activeScreen = kMenuShowCredits;
_soundResourceId = kResourceNone;
_musicResourceId = kResourceNone;
- _allowInteraction = false;
+ _gameStarted = false;
- _dword_4562C4 = 480;
- _dword_45628C = 0;
+ _creditsTextScroll = 480;
+ _creditsFrameIndex = 0;
setup();
}
@@ -143,7 +145,7 @@ void MainMenu::switchFont(bool condition) {
getText()->loadFont((condition) ? kFontYellow : kFontBlue);
}
-void MainMenu::showCredits() {
+void MainMenu::closeCredits() {
getScreen()->clear();
// Original fills the screen with black
@@ -257,7 +259,7 @@ bool MainMenu::init() {
getCursor()->set(MAKE_RESOURCE(kResourcePackShared, 2), 0, 2);
}
- if (_allowInteraction)
+ if (_gameStarted)
getScene()->getActor()->update_409230();
getScreen()->clear();
@@ -459,51 +461,51 @@ bool MainMenu::click(const AsylumEvent &evt) {
break;
case kMenuNewGame:
- updateNewGame();
+ clickNewGame();
break;
case kMenuLoadGame:
- updateLoadGame();
+ clickLoadGame();
break;
case kMenuSaveGame:
- updateSaveGame();
+ clickSaveGame();
break;
case kMenuDeleteGame:
- updateDeleteGame();
+ clickDeleteGame();
break;
case kMenuViewMovies:
- updateViewMovies();
+ clickViewMovies();
break;
case kMenuQuitGame:
- updateQuitGame();
+ clickQuitGame();
break;
case kMenuTextOptions:
- updateTextOptions();
+ clickTextOptions();
break;
case kMenuAudioOptions:
- updateAudioOptions();
+ clickAudioOptions();
break;
case kMenuSettings:
- updateSettings();
+ clickSettings();
break;
case kMenuKeyboardConfig:
- updateKeyboardConfig();
+ clickKeyboardConfig();
break;
case kMenuShowCredits:
- updateShowCredits();
+ clickShowCredits();
break;
case kMenuReturnToGame:
- updateReturnToGame();
+ clickReturnToGame();
break;
}
@@ -531,13 +533,13 @@ bool MainMenu::click(const AsylumEvent &evt) {
_dword_455C80 = false;
_dword_455C78 = false;
_dword_456288 = 0;
- _dword_4562C4 = 0;
+ _creditsTextScroll = 0;
getSaveLoad()->loadList();
break;
case kMenuDeleteGame:
_dword_455C80 = false;
- _dword_4562C4 = 0;
+ _creditsTextScroll = 0;
getSaveLoad()->loadList();
break;
@@ -545,7 +547,7 @@ bool MainMenu::click(const AsylumEvent &evt) {
_needEyeCursorInit = false;
_dword_455C78 = false;
_dword_456288 = 0;
- _dword_4562C4 = 0;
+ _creditsTextScroll = 0;
listMovies();
break;
@@ -554,15 +556,15 @@ bool MainMenu::click(const AsylumEvent &evt) {
break;
case kMenuReturnToGame:
- if (!_allowInteraction)
+ if (!_gameStarted)
break;
clickReturnToGame();
break;
case kMenuShowCredits:
- _dword_4562C4 = 480;
- _dword_45628C = 0;
+ _creditsTextScroll = 480;
+ _creditsFrameIndex = 0;
setup();
break;
}
@@ -575,102 +577,261 @@ bool MainMenu::click(const AsylumEvent &evt) {
// Update handlers
//////////////////////////////////////////////////////////////////////////
void MainMenu::updateNewGame() {
- error("[MainMenu::updateNewGame] Not implemented!");
+ Common::Point cursor = getCursor()->position();
+
+ getText()->loadFont(kFontYellow);
+
+ // Begin new game
+ getText()->drawCentered(10, 100, 620, MAKE_RESOURCE(kResourcePackText, 1321));
+
+ // Yes
+ switchFont(cursor.x < 247 || cursor.x > (247 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 1322))) || cursor.y < 273 || cursor.y > (273 + 24));
+ getText()->setPosition(247, 273);
+ getText()->draw(MAKE_RESOURCE(kResourcePackText, 1322));
+
+ // No
+ switchFont(cursor.x < 369 || cursor.x > (369 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 1323))) || cursor.y < 273 || cursor.y > (273 + 24));
+ getText()->setPosition(369, 273);
+ getText()->draw(MAKE_RESOURCE(kResourcePackText, 1323));
}
void MainMenu::updateLoadGame() {
+ Common::Point cursor = getCursor()->position();
+
error("[MainMenu::updateLoadGame] Not implemented!");
}
void MainMenu::updateSaveGame() {
+ Common::Point cursor = getCursor()->position();
+
error("[MainMenu::updateSaveGame] Not implemented!");
}
void MainMenu::updateDeleteGame() {
+ Common::Point cursor = getCursor()->position();
+
error("[MainMenu::updateDeleteGame] Not implemented!");
}
void MainMenu::updateViewMovies() {
+ Common::Point cursor = getCursor()->position();
+
error("[MainMenu::updateViewMovies] Not implemented!");
}
void MainMenu::updateQuitGame() {
- error("[MainMenu::updateQuitGame] Not implemented!");
+ Common::Point cursor = getCursor()->position();
+
+ getText()->loadFont(kFontYellow);
+ getText()->drawCentered(10, 100, 620, MAKE_RESOURCE(kResourcePackText, 1408));
+
+ // Yes
+ switchFont(cursor.x < 247 || cursor.x > (247 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 1409))) || cursor.y < 273 || cursor.y > (273 + 24));
+ getText()->setPosition(247, 273);
+ getText()->draw(MAKE_RESOURCE(kResourcePackText, 1409));
+
+ // No
+ switchFont(cursor.x < 369 || cursor.x > (369 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 1410))) || cursor.y < 273 || cursor.y > (273 + 24));
+ getText()->setPosition(369, 273);
+ getText()->draw(MAKE_RESOURCE(kResourcePackText, 1410));
}
void MainMenu::updateTextOptions() {
+ Common::Point cursor = getCursor()->position();
+
error("[MainMenu::updateTextOptions] Not implemented!");
}
void MainMenu::updateAudioOptions() {
+ Common::Point cursor = getCursor()->position();
+
error("[MainMenu::updateAudioOptions] Not implemented!");
}
void MainMenu::updateSettings() {
+ Common::Point cursor = getCursor()->position();
+
error("[MainMenu::updateSettings] Not implemented!");
}
void MainMenu::updateKeyboardConfig() {
+ Common::Point cursor = getCursor()->position();
+
error("[MainMenu::updateKeyboardConfig] Not implemented!");
}
void MainMenu::updateReturnToGame() {
- error("[MainMenu::updateReturnToGame] Not implemented!");
+ Common::Point cursor = getCursor()->position();
+
+ getText()->loadFont(kFontYellow);
+
+ // No game loaded
+ getText()->drawCentered(10, 100, 620, MAKE_RESOURCE(kResourcePackText, 1810));
+
+ // Main Menu
+ switchFont(cursor.x < 285 || cursor.x > (285 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 1811))) || cursor.y < 273 || cursor.y > (273 + 24));
+ getText()->setPosition(285, 273);
+ getText()->draw(MAKE_RESOURCE(kResourcePackText, 1811));
+
}
void MainMenu::updateShowCredits() {
- error("[MainMenu::updateShowCredits] Not implemented!");
+ if (_vm->isGameFlagSet(kGameFlagFinishGame)) {
+ getScreen()->draw(MAKE_RESOURCE(kResourcePackShared, 33), 0, 0, 0, 0, false);
+ } else {
+ getScreen()->draw(MAKE_RESOURCE(kResourcePackShared, 23), 0, 0, 0, 0, false);
+ getScreen()->draw(MAKE_RESOURCE(kResourcePackShared, 24), _creditsFrameIndex++ / 2, 0, 0, 0, false);
+
+ _creditsFrameIndex %= 2 * GraphicResource::getFrameCount(_vm, MAKE_RESOURCE(kResourcePackShared, 24));
+ }
+
+ int32 step = 0;
+ uint32 index = 0;
+ do {
+ if ((_creditsTextScroll + step - 24) >= 0) {
+ if ((_creditsTextScroll + step) > 480)
+ break;
+
+ int32 minBound = _creditsTextScroll + step + 24;
+ if (minBound >= 0)
+ if (minBound < 32)
+ getText()->setTransTableNum(3 - minBound / 8);
+
+ int32 maxBound = _creditsTextScroll + step;
+ if ((_creditsTextScroll + step) < 480)
+ if (maxBound > 448)
+ getText()->setTransTableNum(3 - (479 - maxBound) / 8);
+
+ getText()->setPosition(320, step + _creditsTextScroll);
+ getText()->draw(MAKE_RESOURCE(kResourcePackText, 1447 + index));
+ }
+
+ step += 24;
+ ++index;
+ } while (step < 8688);
+
+ if (_vm->isGameFlagSet(kGameFlagFinishGame)) {
+ if (!_dword_455D4C && !getSound()->isPlaying(MAKE_RESOURCE(kResourcePackShared, 56))) {
+ _dword_455D4C = true;
+ getSound()->playMusic(kResourceNone, 0);
+ getSound()->playMusic(MAKE_RESOURCE(kResourcePackShared, 40));
+ }
+ }
+
+ _creditsTextScroll -= 2;
+ if (_creditsTextScroll < -(8688 + 24))
+ closeCredits();
}
//////////////////////////////////////////////////////////////////////////
// Click handlers
//////////////////////////////////////////////////////////////////////////
void MainMenu::clickNewGame() {
- error("[MainMenu::clickNewGame] Not implemented!");
+ Common::Point cursor = getCursor()->position();
+
+ if (cursor.x < 247
+ || cursor.x > (247 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 1322)))
+ || cursor.y < 273
+ || cursor.y > (273 + 24)) {
+ if (cursor.x >= 369
+ && cursor.x <= (369 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 1323)))
+ && cursor.y >= 273
+ && cursor.y <= (273 + 24))
+ leave();
+ } else {
+ _vm->restart();
+ }
}
void MainMenu::clickLoadGame() {
+ Common::Point cursor = getCursor()->position();
+
error("[MainMenu::clickLoadGame] Not implemented!");
}
void MainMenu::clickSaveGame() {
+ Common::Point cursor = getCursor()->position();
+
error("[MainMenu::clickSaveGame] Not implemented!");
}
void MainMenu::clickDeleteGame() {
+ Common::Point cursor = getCursor()->position();
+
error("[MainMenu::clickDeleteGame] Not implemented!");
}
void MainMenu::clickViewMovies() {
+ Common::Point cursor = getCursor()->position();
+
error("[MainMenu::clickViewMovies] Not implemented!");
}
void MainMenu::clickQuitGame() {
- error("[MainMenu::clickQuitGame] Not implemented!");
+ Common::Point cursor = getCursor()->position();
+
+ if (cursor.x < 247
+ || cursor.x > (247 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 1409)))
+ || cursor.y < 273
+ || cursor.y > (273 + 24)) {
+ if (cursor.x >= 369
+ && cursor.x <= (369 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 1410)))
+ && cursor.y >= 273
+ && cursor.y <= (273 + 24)) {
+ leave();
+ }
+ } else {
+ getCursor()->hide();
+ getScreen()->clear();
+ _vm->quitGame();
+ }
}
void MainMenu::clickTextOptions() {
+ Common::Point cursor = getCursor()->position();
+
error("[MainMenu::clickTextOptions] Not implemented!");
}
void MainMenu::clickAudioOptions() {
+ Common::Point cursor = getCursor()->position();
+
error("[MainMenu::clickAudioOptions] Not implemented!");
}
void MainMenu::clickSettings() {
+ Common::Point cursor = getCursor()->position();
+
error("[MainMenu::clickSettings] Not implemented!");
}
void MainMenu::clickKeyboardConfig() {
+ Common::Point cursor = getCursor()->position();
+
error("[MainMenu::clickKeyboardConfig] Not implemented!");
}
void MainMenu::clickReturnToGame() {
- error("[MainMenu::clickReturnToGame] Not implemented!");
+ if (_gameStarted) {
+ if (_musicResourceId != MAKE_RESOURCE(kResourcePackMusic, getWorld()->musicCurrentResourceIndex))
+ getSound()->playMusic(kResourceNone, 0);
+
+ getScreen()->clear();
+
+ _vm->switchEventHandler(_vm->scene());
+ } else {
+ Common::Point cursor = getCursor()->position();
+
+ if (cursor.x >= 285
+ && cursor.x <= (285 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 1811)))
+ && cursor.y >= 273
+ && cursor.y <= (273 + 24))
+ leave();
+ }
}
void MainMenu::clickShowCredits() {
- showCredits();
+ closeCredits();
}
//////////////////////////////////////////////////////////////////////////
@@ -685,126 +846,20 @@ void MainMenu::keyKeyboardConfig() {
}
void MainMenu::keyShowCredits() {
- showCredits();
+ closeCredits();
}
//////////////////////////////////////////////////////////////////////////
// TODO REMOVE
//////////////////////////////////////////////////////////////////////////
-// UpdateShowCredits
-//// TODO if game finished (gameFlag=901) then show resource image 33 and music 56 and than music 40
-////if (!_creditsResource)
-//// _creditsResource = new GraphicResource(_vm, MAKE_RESOURCE(kResourcePackShared, 24));
-////if (!_creditsFadeResource)
-//// _creditsFadeResource = new GraphicResource(_vm, MAKE_RESOURCE(kResourcePackShared, 23));
-////_creditsTextScroll = 0x1E0 - 30;
-//// Set credits palette
-//getScreen()->setPalette(MAKE_RESOURCE(kResourcePackShared, 26));
-//// Stop all sounds
-//getSound()->stopMusic();
-//// Start playing music
-//getSound()->playMusic(MAKE_RESOURCE(kResourcePackShared, 38));
-//
-//void MainMenu::updateMainMenu() {
-// //int32 rowId = 0;
-//
-// //if (getCursor()->position().y >= 20 && getCursor()->position().y <= 20 + 48) {
-// // rowId = 0; // Top row
-// //} else if (getCursor()->position().y >= 400 && getCursor()->position().y <= 400 + 48) {
-// // rowId = 1; // Bottom row
-// //} else {
-// // // No row selected
-// // _previousActiveIcon = _activeScreen = -1;
-// // _leftClick = false;
-// // return;
-// //}
-//
-// getText()->loadFont(kFontYellow);
-//
-// // Icon animation
-//// for (int32 i = 0; i <= 5; i++) {
-//// int32 curX = 40 + i * 100;
-//// if (getCursor()->position().x >= curX && getCursor()->position().x <= curX + 55) {
-//// int32 iconNum = i + 6 * rowId;
-//// _activeScreen = iconNum;
-////
-//// // The last 2 icons are swapped
-//// if (iconNum == 11)
-//// iconNum = 10;
-//// else if (iconNum == 10)
-//// iconNum = 11;
-////
-//// // Get the current icon animation
-//// /* if (!_iconResource || _activeScreen != _previousActiveIcon) {
-//// delete _iconResource;
-//// _iconResource = new GraphicResource(_vm, MAKE_RESOURCE(kResourcePackShared, iconNum + 4));
-//// }*/
-////
-//// /* GraphicFrame *iconFrame = _iconResource->getFrame(MIN<uint>(_iconResource->count() - 1, _curIconFrame));
-//// _vm->screen()->copyRectToScreenWithTransparency((byte *)iconFrame->surface.pixels, iconFrame->surface.w, iconFrame->x, iconFrame->y, iconFrame->surface.w, iconFrame->surface.h);
-////*/
-//// //// Cycle icon frame
-//// //_curIconFrame++;
-//// //if (_curIconFrame >= _iconResource->count())
-//// // _curIconFrame = 0;
-////
-//// //// Show text
-//// //getText()->drawCentered(MenuIconFixedXpos[iconNum],
-//// // iconFrame->y + 50,
-//// // getText()->getWidth(MAKE_RESOURCE(kResourcePackText, iconNum + 1309)),
-//// // MAKE_RESOURCE(kResourcePackText, iconNum + 1309));
-////
-//// // Play creepy voice
-//// if (_activeScreen != _previousActiveIcon) {
-//// getSound()->playSound(MAKE_RESOURCE(kResourcePackShared, iconNum + 44), false, Config.sfxVolume);
-//// _previousActiveIcon = _activeScreen;
-//// }
-////
-//// break;
-//// }
-//// }
-//}
-//
-
-//
-//void MainMenu::updateSubMenuNewGame() {
-// getText()->loadFont(kFontYellow);
-//
-// // begin new game
-// getText()->drawCentered(10, 100, 620, MAKE_RESOURCE(kResourcePackText, 529));
-//
-// // Yes
-// switchFont(getCursor()->position().x < 247 || getCursor()->position().x > 247 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 1322)) || getCursor()->position().y < 273 || getCursor()->position().y > 273 + 24);
-// getText()->setPosition(247, 273);
-// getText()->draw(MAKE_RESOURCE(kResourcePackText, 1322));
-//
-// // No
-// switchFont(getCursor()->position().x < 369 || getCursor()->position().x > 369 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 1323)) || getCursor()->position().y < 273 || getCursor()->position().y > 273 + 24);
-// getText()->setPosition(369, 273);
-// getText()->draw(MAKE_RESOURCE(kResourcePackText, 1323));
-//
-// // action
-// //if (_leftClick) {
-// // // Yes
-// // if (getCursor()->position().x >= 247 && getCursor()->position().x <= 247 + 24 && getCursor()->position().y >= 273 && getCursor()->position().y <= 273 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 1322))) {
-// // _leftClick = false;
-// // // TODO closeMenu();
-// // _vm->startGame(kResourcePackTowerCells, AsylumEngine::kStartGamePlayIntro);
-// // }
-// // // No
-// // if (getCursor()->position().x >= 369 && getCursor()->position().x <= 369 + 24 && getCursor()->position().y >= 273 && getCursor()->position().y <= 273 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 1323)))
-// // exitSubMenu();
-// //}
-//}
-//
//void MainMenu::updateSubMenuCinematics() {
// int32 currentCD = 1; // FIXME: dummy value
// getText()->drawCentered(10, 100, 620, MAKE_RESOURCE(kResourcePackText, 1352), currentCD);
// getText()->setPosition(30, 340);
// getText()->draw(MAKE_RESOURCE(kResourcePackText, 1353)); // Prev Page
//
-// //if (getCursor()->position().x >= 280 && getCursor()->position().x <= 400 && getCursor()->position().y >= 340 && getCursor()->position().y <= 360) {
+// //if (cursor.x >= 280 && cursor.x <= 400 && cursor.y >= 340 && cursor.y <= 360) {
// // getText()->loadFont(kFontBlue);
// // if (_leftClick)
// // exitSubMenu();
@@ -832,11 +887,11 @@ void MainMenu::keyShowCredits() {
//
// // gamma correction
// getText()->drawAlignedRight(320, 150, MAKE_RESOURCE(kResourcePackText, 1433));
-// switchFont(getCursor()->position().x < 350 || getCursor()->position().x > sizeMinus + 350 || getCursor()->position().y < 150 || getCursor()->position().y > 174);
+// switchFont(cursor.x < 350 || cursor.x > sizeMinus + 350 || cursor.y < 150 || cursor.y > 174);
// getText()->setPosition(350, 150);
// getText()->draw("-");
//
-// switchFont(getCursor()->position().x < sizeMinus + 360 || getCursor()->position().x > sizeMinus + sizePlus + 360 || getCursor()->position().y < 150 || getCursor()->position().y > 174);
+// switchFont(cursor.x < sizeMinus + 360 || cursor.x > sizeMinus + sizePlus + 360 || cursor.y < 150 || cursor.y > 174);
// getText()->setPosition(sizeMinus + 360, 150);
// getText()->draw("+");
//
@@ -854,11 +909,11 @@ void MainMenu::keyShowCredits() {
// // performance
// getText()->loadFont(kFontYellow);
// getText()->drawAlignedRight(320, 179, MAKE_RESOURCE(kResourcePackText, 1434));
-// switchFont(getCursor()->position().x < 350 || getCursor()->position().x > sizeMinus + 350 || getCursor()->position().y < 179 || getCursor()->position().y > 203);
+// switchFont(cursor.x < 350 || cursor.x > sizeMinus + 350 || cursor.y < 179 || cursor.y > 203);
// getText()->setPosition(350, 179);
// getText()->draw("-");
//
-// switchFont(getCursor()->position().x < sizeMinus + 360 || getCursor()->position().x > sizeMinus + sizePlus + 360 || getCursor()->position().y < 179 || getCursor()->position().y > 203);
+// switchFont(cursor.x < sizeMinus + 360 || cursor.x > sizeMinus + sizePlus + 360 || cursor.y < 179 || cursor.y > 203);
// getText()->setPosition(sizeMinus + 360, 179);
// getText()->draw("+");
//
@@ -875,27 +930,27 @@ void MainMenu::keyShowCredits() {
// }
//
// // back to main menu
-// switchFont(getCursor()->position().x < 300 || getCursor()->position().x > 300 + sizeMainMenu || getCursor()->position().y < 340 || getCursor()->position().y > 340 + 24);
+// switchFont(cursor.x < 300 || cursor.x > 300 + sizeMainMenu || cursor.y < 340 || cursor.y > 340 + 24);
// getText()->setPosition(300, 340);
// getText()->draw(MAKE_RESOURCE(kResourcePackText, 1437));
//
// // action
// //if (_leftClick) {
// // // back to main menu
-// // if (getCursor()->position().x >= 300 && getCursor()->position().x <= 300 + sizeMainMenu && getCursor()->position().y >= 340 && getCursor()->position().y <= 340 + 24) {
+// // if (cursor.x >= 300 && cursor.x <= 300 + sizeMainMenu && cursor.y >= 340 && cursor.y <= 340 + 24) {
// // // TODO: save new configurations
// // exitSubMenu();
// // }
//
// // // gamma level minus
-// // if (getCursor()->position().x >= 350 && getCursor()->position().x <= sizeMinus + 350 && getCursor()->position().y >= 150 && getCursor()->position().y <= 174) {
+// // if (cursor.x >= 350 && cursor.x <= sizeMinus + 350 && cursor.y >= 150 && cursor.y <= 174) {
// // if (Config.gammaLevel) {
// // Config.gammaLevel -= 1;
// // // TODO: setResGammaLevel(0x80010011, 0);
// // }
// // }
// // // gamma level plus
-// // if (getCursor()->position().x >= sizeMinus + 360 && getCursor()->position().x <= sizeMinus + sizePlus + 360 && getCursor()->position().y >= 150 && getCursor()->position().y <= 174) {
+// // if (cursor.x >= sizeMinus + 360 && cursor.x <= sizeMinus + sizePlus + 360 && cursor.y >= 150 && cursor.y <= 174) {
// // if (Config.gammaLevel < 8) {
// // Config.gammaLevel += 1;
// // // TODO: setResGammaLevel(0x80010011, 0);
@@ -903,14 +958,14 @@ void MainMenu::keyShowCredits() {
// // }
//
// // // performance minus
-// // if (getCursor()->position().x >= 350 && getCursor()->position().x <= sizeMinus + 350 && getCursor()->position().y >= 179 && getCursor()->position().y <= 203) {
+// // if (cursor.x >= 350 && cursor.x <= sizeMinus + 350 && cursor.y >= 179 && cursor.y <= 203) {
// // if (Config.performance) {
// // Config.performance -= 1;
// // // TODO: change quality settings
// // }
// // }
// // // performance plus
-// // if (getCursor()->position().x >= sizeMinus + 360 && getCursor()->position().x <= sizeMinus + sizePlus + 360 && getCursor()->position().y >= 179 && getCursor()->position().y <= 203) {
+// // if (cursor.x >= sizeMinus + 360 && cursor.x <= sizeMinus + sizePlus + 360 && cursor.y >= 179 && cursor.y <= 203) {
// // if (Config.performance < 5) {
// // Config.performance += 1;
// // // TODO: change quality settings
@@ -918,130 +973,7 @@ void MainMenu::keyShowCredits() {
// // }
// //}
//}
-//
-//void MainMenu::updateSubMenuQuitGame() {
-// getText()->loadFont(kFontYellow);
-//
-// // begin new game
-// getText()->drawCentered(10, 100, 620, MAKE_RESOURCE(kResourcePackText, 1408));
-//
-// // Yes
-// switchFont(getCursor()->position().x < 247 || getCursor()->position().x > 247 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 581)) || getCursor()->position().y < 273 || getCursor()->position().y > 273 + 24);
-// getText()->setPosition(247, 273);
-// getText()->draw(MAKE_RESOURCE(kResourcePackText, 1409));
-//
-// // No
-// switchFont(getCursor()->position().x < 369 || getCursor()->position().x > 369 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 582)) || getCursor()->position().y < 273 || getCursor()->position().y > 273 + 24);
-// getText()->setPosition(369, 273);
-// getText()->draw(MAKE_RESOURCE(kResourcePackText, 1410));
-//
-// //// action
-// //if (_leftClick) {
-// // // Yes
-// // if (getCursor()->position().x >= 247 && getCursor()->position().x <= 247 + 24 && getCursor()->position().y >= 273 && getCursor()->position().y <= 273 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 1409))) {
-// // _leftClick = false;
-//
-// // // User clicked on quit, so push a quit event
-// // Common::Event event;
-// // event.type = Common::EVENT_QUIT;
-// // g_system->getEventManager()->pushEvent(event);
-// // }
-// // // No
-// // if (getCursor()->position().x >= 369 && getCursor()->position().x <= 369 + 24 && getCursor()->position().y >= 273 && getCursor()->position().y <= 273 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 1410)))
-// // exitSubMenu();
-// //}
-//}
-//
-//void MainMenu::updateSubMenuShowCredits() {
-// //int32 posY = _creditsTextScroll;
-// //ResourceId resourceId = kResourceNone;
-// //int32 step = 0;
-// //int32 minBound = 0;
-// //int32 maxBound = 0;
-//
-// ////GraphicFrame *creditsFadeFrame = _creditsFadeResource->getFrame(0);
-// ////_vm->screen()->copyRectToScreenWithTransparency((byte *)creditsFadeFrame->surface.pixels, creditsFadeFrame->surface.w, creditsFadeFrame->x, creditsFadeFrame->y, creditsFadeFrame->surface.w, creditsFadeFrame->surface.h);
-//
-// ////GraphicFrame *creditsFrame = _creditsResource->getFrame(MIN<uint>(_creditsResource->count() - 1, _creditsBgFrame));
-// ////_vm->screen()->copyRectToScreenWithTransparency((byte *)creditsFrame->surface.pixels, creditsFrame->surface.w, creditsFrame->x, creditsFrame->y, creditsFrame->surface.w, creditsFrame->surface.h);
-//
-// ////_creditsBgFrame++;
-// ////if (_creditsBgFrame >= _creditsResource->count())
-// //// _creditsBgFrame = 0;
-//
-// //do {
-// // if (posY + step >= 0) {
-// // if (posY + step > 450)
-// // break;
-//
-// // minBound = posY + step + 24;
-// // if (minBound >= 0)
-// // if (minBound < 32) {
-// // // TODO fade side text
-// // posY = _creditsTextScroll;
-// // }
-//
-// // maxBound = posY + step;
-// // if (posY + step < 480)
-// // if (maxBound > 448) {
-// // // TODO fade side text
-// // posY = _creditsTextScroll;
-// // }
-//
-// // getText()->setPosition(320, step + posY);
-// // getText()->draw((ResourceId)(resourceId - 2147482201));
-// // posY = _creditsTextScroll;
-// // }
-// // step += 24;
-// // resourceId = (ResourceId)(resourceId + 1);
-// //} while (step < 0x21F0);
-//
-// //_creditsTextScroll -= 2;
-//
-// //// TODO: some palette stuffs
-//
-// //// TODO: if gameFlag=901 (finished game) and already play music 56, start music 40
-//
-// //if (_leftClick) {
-// // // Restore palette
-// // _vm->screen()->setPalette(MAKE_RESOURCE(kResourcePackShared, 17));
-// // // Stop all sounds
-// // _vm->sound()->stopMusic();
-// // // Start playing music
-// // _vm->sound()->playMusic(MAKE_RESOURCE(kResourcePackShared, 39));
-// // exitSubMenu();
-// //}
-//}
-//
-//void MainMenu::exitSubMenu() {
-// //_leftClick = false;
-// //_activeScreen = kMenuMain;
-//
-// //// Copy the bright background to the back buffer
-// //getScreen()->draw(MAKE_RESOURCE(kResourcePackShared, 0), 1, 0, 0, 0);
-//
-// //// Set the cursor
-// //getCursor()->set(MAKE_RESOURCE(kResourcePackShared, 2));
-//}
-//
-//void MainMenu::updateSubMenuReturnToGame() {
-// getText()->loadFont(kFontYellow);
-//
-// // no game loaded
-// getText()->drawCentered(10, 100, 620, MAKE_RESOURCE(kResourcePackText, 712));
-//
-// // Main menu
-// switchFont(getCursor()->position().x < 285 || getCursor()->position().x > 285 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 713)) || getCursor()->position().y < 273 || getCursor()->position().y > 273 + 24);
-// getText()->setPosition(285, 273);
-// getText()->draw(MAKE_RESOURCE(kResourcePackText, 713));
-//
-// // action
-// //if (_leftClick) {
-// // // Main menu
-// // if (getCursor()->position().x >= 285 && getCursor()->position().x <= 285 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 713)) && getCursor()->position().y >= 273 && getCursor()->position().y <= 273 + 24)
-// // exitSubMenu();
-// //}
-//}
+
} // end of namespace Asylum
diff --git a/engines/asylum/views/menu.h b/engines/asylum/views/menu.h
index 34d5ec5813..1c585fac18 100644
--- a/engines/asylum/views/menu.h
+++ b/engines/asylum/views/menu.h
@@ -90,7 +90,7 @@ private:
MenuScreen _activeScreen;
ResourceId _soundResourceId;
ResourceId _musicResourceId;
- bool _allowInteraction;
+ bool _gameStarted;
MenuScreen _currentIcon;
int32 _dword_4464B8;
int32 _dword_455C74;
@@ -101,8 +101,8 @@ private:
bool _dword_455DD8;
int32 _dword_456288;
int32 _dword_4562C0;
- int32 _dword_4562C4;
- int32 _dword_45628C;
+ int32 _creditsTextScroll;
+ int32 _creditsFrameIndex;
bool _needEyeCursorInit;
uint32 _iconFrames[12];
@@ -124,9 +124,9 @@ private:
void switchFont(bool condition);
/**
- * Shows the credits.
+ * Close the credits.
*/
- void showCredits();
+ void closeCredits();
/**
* List viewed movies
diff --git a/engines/asylum/views/scene.cpp b/engines/asylum/views/scene.cpp
index ea010c1fab..21b101f551 100644
--- a/engines/asylum/views/scene.cpp
+++ b/engines/asylum/views/scene.cpp
@@ -314,6 +314,13 @@ void Scene::setScenePosition(int x, int y) {
*targetY = bg->surface.h - 480;
}
+
+bool Scene::handleEvent(const AsylumEvent &ev) {
+ // TODO replace previous handleEvent method
+
+ return true;
+}
+
void Scene::handleEvent(Common::Event *event, bool doUpdate) {
if (!_ws)
error("[Scene::handleEvent] WorldStats not initialized properly!");
diff --git a/engines/asylum/views/scene.h b/engines/asylum/views/scene.h
index eb33d7b469..a02a6132af 100644
--- a/engines/asylum/views/scene.h
+++ b/engines/asylum/views/scene.h
@@ -26,6 +26,7 @@
#ifndef ASYLUM_SCENE_H
#define ASYLUM_SCENE_H
+#include "asylum/eventhandler.h"
#include "asylum/shared.h"
#include "common/array.h"
@@ -68,7 +69,7 @@ enum HitType {
kHitActor = 4
};
-class Scene {
+class Scene : public EventHandler {
public:
Scene(AsylumEngine *engine);
~Scene();
@@ -86,7 +87,7 @@ public:
*/
void load(ResourcePackId packId);
-
+ bool handleEvent(const AsylumEvent &ev);
void handleEvent(Common::Event *event, bool doUpdate);
void activate();
diff --git a/engines/asylum/views/scenetitle.cpp b/engines/asylum/views/scenetitle.cpp
index e39c3228ae..12f1ecb57d 100644
--- a/engines/asylum/views/scenetitle.cpp
+++ b/engines/asylum/views/scenetitle.cpp
@@ -87,7 +87,7 @@ void SceneTitle::update(int32 tick) {
GraphicFrame *frame = _progress->getFrame(_spinnerFrame);
- getScreen()->copyRectToScreenWithTransparency(((byte*)frame->surface.pixels),
+ getScreen()->copyToBackBufferWithTransparency(((byte*)frame->surface.pixels),
frame->surface.w,
frame->x + (_spinnerProgress - 290),
frame->y,
Commit: eaea0cd79d8be8ecf13b13050b993c2bb98341ee
https://github.com/scummvm/scummvm/commit/eaea0cd79d8be8ecf13b13050b993c2bb98341ee
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:27+02:00
Commit Message:
ASYLUM: Implement MainMenu update handlers for text, audio, setting and keyboard config
- Add missing keyboard shortcuts to the list of config keys
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@604 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/system/config.cpp
engines/asylum/system/config.h
engines/asylum/views/menu.cpp
engines/asylum/views/menu.h
diff --git a/engines/asylum/system/config.cpp b/engines/asylum/system/config.cpp
index 2a5df672e2..b489e0788b 100644
--- a/engines/asylum/system/config.cpp
+++ b/engines/asylum/system/config.cpp
@@ -43,13 +43,13 @@ ConfigurationManager::ConfigurationManager() {
ConfMan.registerDefault("movie_volume", 0);
ConfMan.registerDefault("music_status", true);
ConfMan.registerDefault("reverse_stereo", false);
- ConfMan.registerDefault("performance", 5);
- //ConfMan.registerDefault("versionKey", );
- //ConfMan.registerDefault("quicksave_key", );
- //ConfMan.registerDefault("quickload_key", );
- //ConfMan.registerDefault("switch_to_sara_key", );
- //ConfMan.registerDefault("switch_to_grimwall_key", );
- //ConfMan.registerDefault("switch_to_olmec_key", );
+ ConfMan.registerDefault("performance", 4);
+ ConfMan.registerDefault("key_showVersion", 'v');
+ ConfMan.registerDefault("key_quickLoad", 'L');
+ ConfMan.registerDefault("key_quickSave", 'S');
+ ConfMan.registerDefault("key_switchToSara", 's');
+ ConfMan.registerDefault("key_switchToGrimwall", 'g');
+ ConfMan.registerDefault("key_switchToOlmec", 'o');
ConfMan.registerDefault("show_scene_loading", false);
ConfMan.registerDefault("show_intro", true);
@@ -66,7 +66,14 @@ ConfigurationManager::ConfigurationManager() {
movieVolume = 0;
musicStatus = true;
reverseStereo = false;
- performance = 5;
+ performance = 4;
+
+ keyShowVersion = 'v';
+ keyQuickLoad = 'L';
+ keyQuickSave = 'S';
+ keySwitchToSara = 's';
+ keySwitchToGrimwall = 'g';
+ keySwitchToOlmec = 'o';
}
ConfigurationManager::~ConfigurationManager() {
@@ -91,6 +98,14 @@ void ConfigurationManager::read() {
// Misc options
showSceneLoading = ConfMan.getBool("show_scene_loading");
showIntro = ConfMan.getBool("show_intro");
+
+ // Keyboard shortcuts
+ keyShowVersion = (char)ConfMan.getInt("key_showVersion");
+ keyQuickLoad = (char)ConfMan.getInt("key_quickLoad");
+ keyQuickSave = (char)ConfMan.getInt("key_quickSave");
+ keySwitchToSara = (char)ConfMan.getInt("key_switchToSara");
+ keySwitchToGrimwall = (char)ConfMan.getInt("key_switchToGrimwall");
+ keySwitchToOlmec = (char)ConfMan.getInt("key_switchToOlmec");
}
void ConfigurationManager::write() {
@@ -112,6 +127,14 @@ void ConfigurationManager::write() {
// Misc Options
ConfMan.setBool("show_scene_loading", showSceneLoading);
ConfMan.setBool("show_intro", showIntro);
+
+ // Keyboard shortcuts
+ ConfMan.setInt("key_showVersion", (int)keyShowVersion);
+ ConfMan.setInt("key_quickLoad", (int)keyQuickLoad);
+ ConfMan.setInt("key_quickSave", (int)keyQuickSave);
+ ConfMan.setInt("key_switchToSara", (int)keySwitchToSara);
+ ConfMan.setInt("key_switchToGrimwall", (int)keySwitchToGrimwall);
+ ConfMan.setInt("key_switchToOlmec", (int)keySwitchToOlmec);
}
} // end of namespace Asylum
diff --git a/engines/asylum/system/config.h b/engines/asylum/system/config.h
index 0afd8bf6fe..2ae206ad59 100644
--- a/engines/asylum/system/config.h
+++ b/engines/asylum/system/config.h
@@ -59,12 +59,12 @@ public:
bool musicStatus; // On or Off
bool reverseStereo;
int performance; ///< performance only affects sound: perf > 0 ? 22050hz/16bit : 11025hz/8bit
- int versionKey;
- int quickSaveKey;
- int quickLoadKey;
- int switchToSaraKey;
- int switchToGrimwallKey;
- int switchToOlmecKey;
+ char keyShowVersion;
+ char keyQuickSave;
+ char keyQuickLoad;
+ char keySwitchToSara;
+ char keySwitchToGrimwall;
+ char keySwitchToOlmec;
//////////////////////////////////////////////////////////////////////////
// Misc configuration options (not shown in GUI)
diff --git a/engines/asylum/views/menu.cpp b/engines/asylum/views/menu.cpp
index 9a0e0ec39d..9e1b280db3 100644
--- a/engines/asylum/views/menu.cpp
+++ b/engines/asylum/views/menu.cpp
@@ -61,9 +61,10 @@ MainMenu::MainMenu(AsylumEngine *vm): _vm(vm) {
_dword_455D4C = false;
_dword_455D5C = false;
_dword_455DD8 = false;
+ _dword_455DE0 = false;
_dword_456288 = 0;
_dword_4562C0 = 0;
- _creditsTextScroll = 0;
+ _textScroll = 0;
_creditsFrameIndex = 0;
_needEyeCursorInit = false;
@@ -92,7 +93,7 @@ void MainMenu::show() {
_musicResourceId = kResourceNone;
_gameStarted = false;
- _creditsTextScroll = 480;
+ _textScroll = 480;
_creditsFrameIndex = 0;
setup();
@@ -533,13 +534,13 @@ bool MainMenu::click(const AsylumEvent &evt) {
_dword_455C80 = false;
_dword_455C78 = false;
_dword_456288 = 0;
- _creditsTextScroll = 0;
+ _textScroll = 0;
getSaveLoad()->loadList();
break;
case kMenuDeleteGame:
_dword_455C80 = false;
- _creditsTextScroll = 0;
+ _textScroll = 0;
getSaveLoad()->loadList();
break;
@@ -547,7 +548,7 @@ bool MainMenu::click(const AsylumEvent &evt) {
_needEyeCursorInit = false;
_dword_455C78 = false;
_dword_456288 = 0;
- _creditsTextScroll = 0;
+ _textScroll = 0;
listMovies();
break;
@@ -563,7 +564,7 @@ bool MainMenu::click(const AsylumEvent &evt) {
break;
case kMenuShowCredits:
- _creditsTextScroll = 480;
+ _textScroll = 480;
_creditsFrameIndex = 0;
setup();
break;
@@ -639,25 +640,247 @@ void MainMenu::updateQuitGame() {
void MainMenu::updateTextOptions() {
Common::Point cursor = getCursor()->position();
- error("[MainMenu::updateTextOptions] Not implemented!");
+ getText()->loadFont(kFontYellow);
+ getText()->drawCentered(10, 100, 620, MAKE_RESOURCE(kResourcePackText, 1411));
+
+ getText()->draw(320, 150, MAKE_RESOURCE(kResourcePackText, 1412));
+
+ switchFont(cursor.x < 350 || cursor.x > (350 + getText()->getWidth(Config.showMovieSubtitles ? MAKE_RESOURCE(kResourcePackText, 1414) : MAKE_RESOURCE(kResourcePackText, 1415))) || cursor.y < 150 || cursor.y > 174);
+ getText()->setPosition(350, 150);
+ getText()->draw(Config.showMovieSubtitles ? MAKE_RESOURCE(kResourcePackText, 1414) : MAKE_RESOURCE(kResourcePackText, 1415));
+
+ getText()->loadFont(kFontYellow);
+ getText()->draw(320, 179, MAKE_RESOURCE(kResourcePackText, 1413));
+
+ switchFont(cursor.x < 350 || cursor.x > (350 + getText()->getWidth(Config.showEncounterSubtitles ? MAKE_RESOURCE(kResourcePackText, 1414) : MAKE_RESOURCE(kResourcePackText, 1415))) || cursor.y < 179 || cursor.y > 203);
+ getText()->setPosition(350, 179);
+ getText()->draw(Config.showEncounterSubtitles ? MAKE_RESOURCE(kResourcePackText, 1414) : MAKE_RESOURCE(kResourcePackText, 1415));
+
+ switchFont(cursor.x < 300 || cursor.x > (300 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 1416))) || cursor.y < 340 || cursor.y > (340 + 24));
+ getText()->setPosition(300, 340);
+ getText()->draw(MAKE_RESOURCE(kResourcePackText, 1416));
}
void MainMenu::updateAudioOptions() {
Common::Point cursor = getCursor()->position();
- error("[MainMenu::updateAudioOptions] Not implemented!");
+ // Size of - and +
+ int32 sizeMinus = getText()->getWidth("-");
+ int32 sizePlus = getText()->getWidth("+");
+
+ getText()->loadFont(kFontYellow);
+ getText()->drawCentered(10, 100, 620, MAKE_RESOURCE(kResourcePackText, 1420));
+
+ int32 volumeIndex = 0;
+ int32 volumeValue = cursor.x;
+ do {
+ getText()->loadFont(kFontYellow);
+ getText()->draw(320, 29 * volumeIndex + 150, MAKE_RESOURCE(kResourcePackText, 1421 + volumeIndex));
+
+ switchFont(cursor.x < 350 || cursor.x > (sizeMinus + 350) || cursor.y < (29 * volumeIndex + 150) || cursor.y > (29 * (volumeIndex + 6)));
+ getText()->setPosition(350, 29 * volumeIndex + 150);
+ getText()->draw("-");
+
+ switchFont(cursor.x < (sizeMinus + 360) || cursor.x > (sizeMinus + sizePlus + 360) || cursor.y < (29 * volumeIndex + 150) || cursor.y > (29 * (volumeIndex + 6)));
+ getText()->setPosition(sizeMinus + 360, 29 * volumeIndex + 150);
+ getText()->draw("+");
+
+ switch(volumeIndex) {
+ default:
+ break;
+
+ case 0:
+ volumeValue = 0;
+ break;
+
+ case 1:
+ volumeValue = Config.musicVolume / 250 + 20;
+ break;
+
+ case 2:
+ volumeValue = Config.ambientVolume / 250 + 20;
+ break;
+
+ case 3:
+ volumeValue = Config.sfxVolume / 250 + 20;
+ break;
+
+ case 4:
+ volumeValue = Config.voiceVolume / 250 + 20;
+ break;
+
+ case 5:
+ volumeValue = Config.movieVolume / 250 + 20;
+ break;
+ }
+
+ getText()->loadFont(kFontYellow);
+ getText()->setPosition(sizePlus + sizeMinus + 365, 29 * volumeIndex + 150);
+ if (volumeValue > 0) {
+ for (int32 i = 0; i < volumeValue; i++)
+ getText()->drawChar(']');
+
+ if (volumeValue == 20)
+ getText()->drawChar('*');
+ } else if (volumeIndex) {
+ getText()->draw(MAKE_RESOURCE(kResourcePackText, 1429));
+ }
+
+ ++volumeIndex;
+ } while (volumeIndex < 6);
+
+ //////////////////////////////////////////////////////////////////////////
+ //
+ getText()->loadFont(kFontYellow);
+ getText()->draw(320, 29 *volumeIndex + 150, MAKE_RESOURCE(kResourcePackText, 1427));
+
+ switchFont(cursor.x < 350 || cursor.x > (350 + getText()->getWidth(Config.reverseStereo ? MAKE_RESOURCE(kResourcePackText, 1428) : MAKE_RESOURCE(kResourcePackText, 1429))) || cursor.y < (29 * volumeIndex + 150) || cursor.y > (29 * (volumeIndex + 6)));
+ getText()->setPosition(350, 29 * volumeIndex + 150);
+ getText()->draw(Config.reverseStereo ? MAKE_RESOURCE(kResourcePackText, 1428) : MAKE_RESOURCE(kResourcePackText, 1429));
+
+ switchFont(cursor.x < 220 || cursor.x > (220 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 1430))) || cursor.y < 360 || cursor.y > (360 + 24));
+ getText()->setPosition(220, 360);
+ getText()->draw(MAKE_RESOURCE(kResourcePackText, 1430));
+
+ switchFont((cursor.x < 360 || cursor.x > (360 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 1431))) || cursor.y < 360 || cursor.y > (360 + 24)) && !_dword_455DE0);
+ getText()->setPosition(360, 360);
+ getText()->draw(MAKE_RESOURCE(kResourcePackText, 1431));
}
void MainMenu::updateSettings() {
Common::Point cursor = getCursor()->position();
- error("[MainMenu::updateSettings] Not implemented!");
+ // Size of - and +
+ int32 sizeMinus = getText()->getWidth("-");
+ int32 sizePlus = getText()->getWidth("+");
+
+ getText()->loadFont(kFontYellow);
+
+ // Settings
+ getText()->drawCentered(10, 100, 620, MAKE_RESOURCE(kResourcePackText, 1432));
+
+ //////////////////////////////////////////////////////////////////////////
+ // Gamma correction
+ getText()->draw(320, 150, MAKE_RESOURCE(kResourcePackText, 1433));
+
+ switchFont(cursor.x < 350 || cursor.x > (sizeMinus + 350) || cursor.y < 150 || cursor.y > 174);
+ getText()->setPosition(350, 150);
+ getText()->draw("-");
+
+ switchFont(cursor.x < (sizeMinus + 360) || cursor.x > (sizeMinus + sizePlus + 360) || cursor.y < 150 || cursor.y > 174);
+ getText()->setPosition(sizeMinus + 360, 150);
+ getText()->draw("+");
+
+ getText()->setPosition(sizeMinus + sizePlus + 365, 150);
+ getText()->loadFont(kFontYellow);
+ if (Config.gammaLevel) {
+ for (int32 i = 0; i < Config.gammaLevel; i++)
+ getText()->drawChar(']');
+
+ if (Config.gammaLevel == 8)
+ getText()->drawChar('*');
+ } else {
+ getText()->draw(MAKE_RESOURCE(kResourcePackText, 1435));
+ }
+
+ //////////////////////////////////////////////////////////////////////////
+ // Performance
+ getText()->loadFont(kFontYellow);
+ getText()->draw(320, 179, MAKE_RESOURCE(kResourcePackText, 1434));
+
+ switchFont(cursor.x < 350 || cursor.x > (sizeMinus + 350) || cursor.y < 179 || cursor.y > 203);
+ getText()->setPosition(350, 179);
+ getText()->draw("-");
+
+ switchFont(cursor.x < (sizeMinus + 360) || cursor.x > (sizeMinus + sizePlus + 360) || cursor.y < 179 || cursor.y > 203);
+ getText()->setPosition(sizeMinus + 360, 179);
+ getText()->draw("+");
+
+ getText()->setPosition(sizeMinus + sizePlus + 365, 179);
+ getText()->loadFont(kFontYellow);
+ if (Config.performance == 5) {
+ getText()->draw(MAKE_RESOURCE(kResourcePackText, 1436));
+ } else {
+ for (int32 i = 5; i > Config.performance; --i)
+ getText()->drawChar(']');
+
+ if (!Config.performance)
+ getText()->draw('*');
+ }
+
+ //////////////////////////////////////////////////////////////////////////
+ // Back to main menu
+ switchFont(cursor.x < 300 || cursor.x > (300 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 1437))) || cursor.y < 340 || cursor.y > (340 + 24));
+ getText()->setPosition(300, 340);
+ getText()->draw(MAKE_RESOURCE(kResourcePackText, 1437));
}
void MainMenu::updateKeyboardConfig() {
Common::Point cursor = getCursor()->position();
- error("[MainMenu::updateKeyboardConfig] Not implemented!");
+ getText()->loadFont(kFontYellow);
+ getText()->drawCentered(10, 100, 620, MAKE_RESOURCE(kResourcePackText, 1438));
+
+ char key = 0;
+ int32 keyIndex = 0;
+
+ do {
+ getText()->loadFont(kFontYellow);
+ if ((getScene() && getWorld()->chapter == 9) || keyIndex < 3) {
+ getText()->draw(320, 29 * keyIndex + 150, MAKE_RESOURCE(kResourcePackText, 1439 + keyIndex));
+ } else {
+ getText()->draw(320, 29 * keyIndex + 150, MAKE_RESOURCE(kResourcePackText, 1445));
+ }
+
+ switch (keyIndex) {
+ default:
+ break;
+
+ case 0:
+ key = Config.keyShowVersion;
+ break;
+
+ case 1:
+ key = Config.keyQuickLoad;
+ break;
+
+ case 2:
+ key = Config.keyQuickSave;
+ break;
+
+ case 3:
+ key = Config.keySwitchToSara;
+ break;
+
+ case 4:
+ key = Config.keySwitchToGrimwall;
+ break;
+
+ case 5:
+ key = Config.keySwitchToOlmec;
+ break;
+ }
+
+ getText()->setPosition(350, 29 * keyIndex + 150);
+
+ if (keyIndex == _dword_4464B8) {
+ getText()->loadFont(kFontBlue);
+
+ if (_dword_4562C0 < 6)
+ getText()->drawChar('_');
+
+ _dword_4562C0 = (_dword_4562C0 + 1) % 12;
+ } else {
+ switchFont(getCursor()->isHidden() || cursor.x < 350 || cursor.x > (350 + getText()->getWidth(key)) || cursor.y < (29 * keyIndex + 150) || cursor.y > (29 * (keyIndex + 6)));
+ getText()->drawChar(key);
+ }
+
+ ++keyIndex;
+ } while (keyIndex < 6);
+
+ switchFont(getCursor()->isHidden() || cursor.x < 300 || cursor.x > (300 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 1446))) || cursor.y < 340 || cursor.y > (340 + 24));
+ getText()->setPosition(340, 340);
+ getText()->draw(MAKE_RESOURCE(kResourcePackText, 1446));
}
void MainMenu::updateReturnToGame() {
@@ -688,21 +911,21 @@ void MainMenu::updateShowCredits() {
int32 step = 0;
uint32 index = 0;
do {
- if ((_creditsTextScroll + step - 24) >= 0) {
- if ((_creditsTextScroll + step) > 480)
+ if ((_textScroll + step - 24) >= 0) {
+ if ((_textScroll + step) > 480)
break;
- int32 minBound = _creditsTextScroll + step + 24;
+ int32 minBound = _textScroll + step + 24;
if (minBound >= 0)
if (minBound < 32)
getText()->setTransTableNum(3 - minBound / 8);
- int32 maxBound = _creditsTextScroll + step;
- if ((_creditsTextScroll + step) < 480)
+ int32 maxBound = _textScroll + step;
+ if ((_textScroll + step) < 480)
if (maxBound > 448)
getText()->setTransTableNum(3 - (479 - maxBound) / 8);
- getText()->setPosition(320, step + _creditsTextScroll);
+ getText()->setPosition(320, step + _textScroll);
getText()->draw(MAKE_RESOURCE(kResourcePackText, 1447 + index));
}
@@ -718,8 +941,8 @@ void MainMenu::updateShowCredits() {
}
}
- _creditsTextScroll -= 2;
- if (_creditsTextScroll < -(8688 + 24))
+ _textScroll -= 2;
+ if (_textScroll < -(8688 + 24))
closeCredits();
}
@@ -877,63 +1100,6 @@ void MainMenu::keyShowCredits() {
//}
//
//void MainMenu::updateSubMenuSettings() {
-// int32 sizeMinus = getText()->getWidth("-");
-// int32 sizePlus = getText()->getWidth("+");
-// int32 sizeMainMenu = getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 1437));
-//
-// getText()->loadFont(kFontYellow);
-// // Settings
-// getText()->drawCentered(10, 100, 620, MAKE_RESOURCE(kResourcePackText, 1432));
-//
-// // gamma correction
-// getText()->drawAlignedRight(320, 150, MAKE_RESOURCE(kResourcePackText, 1433));
-// switchFont(cursor.x < 350 || cursor.x > sizeMinus + 350 || cursor.y < 150 || cursor.y > 174);
-// getText()->setPosition(350, 150);
-// getText()->draw("-");
-//
-// switchFont(cursor.x < sizeMinus + 360 || cursor.x > sizeMinus + sizePlus + 360 || cursor.y < 150 || cursor.y > 174);
-// getText()->setPosition(sizeMinus + 360, 150);
-// getText()->draw("+");
-//
-// getText()->setPosition(sizeMinus + sizePlus + 365, 150);
-// getText()->loadFont(kFontYellow);
-// if (Config.gammaLevel) {
-// for (int32 i = 0; i < Config.gammaLevel; i++) {
-// getText()->draw("]");
-// }
-// if (Config.gammaLevel == 8)
-// getText()->draw("*");
-// } else
-// getText()->draw(MAKE_RESOURCE(kResourcePackText, 1435));
-//
-// // performance
-// getText()->loadFont(kFontYellow);
-// getText()->drawAlignedRight(320, 179, MAKE_RESOURCE(kResourcePackText, 1434));
-// switchFont(cursor.x < 350 || cursor.x > sizeMinus + 350 || cursor.y < 179 || cursor.y > 203);
-// getText()->setPosition(350, 179);
-// getText()->draw("-");
-//
-// switchFont(cursor.x < sizeMinus + 360 || cursor.x > sizeMinus + sizePlus + 360 || cursor.y < 179 || cursor.y > 203);
-// getText()->setPosition(sizeMinus + 360, 179);
-// getText()->draw("+");
-//
-// getText()->setPosition(sizeMinus + sizePlus + 365, 179);
-// getText()->loadFont(kFontYellow);
-// if (Config.performance == 5) {
-// getText()->draw(MAKE_RESOURCE(kResourcePackText, 1436));
-// } else {
-// for (int32 i = 5; i > Config.performance; --i) {
-// getText()->draw("]");
-// }
-// if (!Config.performance)
-// getText()->draw("*");
-// }
-//
-// // back to main menu
-// switchFont(cursor.x < 300 || cursor.x > 300 + sizeMainMenu || cursor.y < 340 || cursor.y > 340 + 24);
-// getText()->setPosition(300, 340);
-// getText()->draw(MAKE_RESOURCE(kResourcePackText, 1437));
-//
// // action
// //if (_leftClick) {
// // // back to main menu
diff --git a/engines/asylum/views/menu.h b/engines/asylum/views/menu.h
index 1c585fac18..cdb93641ea 100644
--- a/engines/asylum/views/menu.h
+++ b/engines/asylum/views/menu.h
@@ -99,9 +99,10 @@ private:
bool _dword_455D4C;
bool _dword_455D5C;
bool _dword_455DD8;
+ bool _dword_455DE0;
int32 _dword_456288;
int32 _dword_4562C0;
- int32 _creditsTextScroll;
+ int32 _textScroll;
int32 _creditsFrameIndex;
bool _needEyeCursorInit;
uint32 _iconFrames[12];
Commit: a326b6153310c897e81fe1305c2a122830ce212d
https://github.com/scummvm/scummvm/commit/a326b6153310c897e81fe1305c2a122830ce212d
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:28+02:00
Commit Message:
ASYLUM: Implement more menu click handling
- Add click handling to audio and keyboard settings
- Add proper sound sync between mixer and in-game values
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@605 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/asylum.cpp
engines/asylum/asylum.h
engines/asylum/resources/worldstats.cpp
engines/asylum/resources/worldstats.h
engines/asylum/system/config.cpp
engines/asylum/system/config.h
engines/asylum/system/sound.cpp
engines/asylum/system/sound.h
engines/asylum/views/menu.cpp
engines/asylum/views/menu.h
diff --git a/engines/asylum/asylum.cpp b/engines/asylum/asylum.cpp
index cb38275b1f..c0a953348c 100644
--- a/engines/asylum/asylum.cpp
+++ b/engines/asylum/asylum.cpp
@@ -27,6 +27,7 @@
#include "asylum/resources/actionlist.h"
#include "asylum/resources/encounters.h"
+#include "asylum/resources/worldstats.h"
#include "asylum/puzzles/vcr.h"
@@ -132,6 +133,9 @@ Common::Error AsylumEngine::run() {
// Load config
Config.read();
+ // Setup mixer
+ syncSoundSettings();
+
// Send init event to our default event handler
AsylumEvent initEvt(EVENT_ASYLUM_INIT);
_handler->handleEvent(initEvt);
@@ -348,6 +352,11 @@ void AsylumEngine::initPuzzles() {
warning("[AsylumEngine::initPuzzles] Add missing puzzles");
}
+void AsylumEngine::updateReverseStereo() {
+ if (_scene && _scene->worldstats())
+ _scene->worldstats()->reverseStereo = Config.reverseStereo;
+}
+
//////////////////////////////////////////////////////////////////////////
// Game flags
//////////////////////////////////////////////////////////////////////////
diff --git a/engines/asylum/asylum.h b/engines/asylum/asylum.h
index f7eb598388..45336ebc9d 100644
--- a/engines/asylum/asylum.h
+++ b/engines/asylum/asylum.h
@@ -168,6 +168,11 @@ public:
*/
EventHandler* getPuzzle(uint32 index);
+ /**
+ * Updates the reverse stereo scene status from the config
+ */
+ void updateReverseStereo();
+
private:
const ADGameDescription *_gameDescription;
diff --git a/engines/asylum/resources/worldstats.cpp b/engines/asylum/resources/worldstats.cpp
index 3554309a75..485c450924 100644
--- a/engines/asylum/resources/worldstats.cpp
+++ b/engines/asylum/resources/worldstats.cpp
@@ -72,7 +72,7 @@ WorldStats::WorldStats(Common::SeekableReadStream *stream, Scene *scene) : _scen
motionStatus = 0;
field_8C = 0;
memset(&coordinates, 0, sizeof(coordinates));
- stereoReversedFlag = 0;
+ reverseStereo = 0;
sceneRectIdx = 0;
memset(&field_11D, 0, sizeof(field_11D));
field_120 = 0;
@@ -163,7 +163,7 @@ void WorldStats::load(Common::SeekableReadStream *stream) {
uint32 numActors = stream->readUint32LE();
- stereoReversedFlag = stream->readSint32LE();
+ reverseStereo = stream->readSint32LE();
for (int32 r = 0; r < 6; r++) {
sceneRects[r].left = (int16)(stream->readSint32LE() & 0xFFFF);
diff --git a/engines/asylum/resources/worldstats.h b/engines/asylum/resources/worldstats.h
index bfc2d69eaa..2c6627104b 100644
--- a/engines/asylum/resources/worldstats.h
+++ b/engines/asylum/resources/worldstats.h
@@ -92,7 +92,7 @@ public:
//uint32 numObjects;
int32 coordinates[7];
//uint32 numActors;
- int32 stereoReversedFlag;
+ int32 reverseStereo;
Common::Rect sceneRects[6]; // including scene size rect
uint8 sceneRectIdx;
uint8 field_11D[3];
diff --git a/engines/asylum/system/config.cpp b/engines/asylum/system/config.cpp
index b489e0788b..2a3852bb39 100644
--- a/engines/asylum/system/config.cpp
+++ b/engines/asylum/system/config.cpp
@@ -25,6 +25,8 @@
#include "asylum/system/config.h"
+#include "asylum/system/sound.h"
+
DECLARE_SINGLETON(Asylum::ConfigurationManager);
namespace Asylum {
@@ -39,8 +41,8 @@ ConfigurationManager::ConfigurationManager() {
// Register engine-specific options
ConfMan.registerDefault("show_encounter_subtitles", true);
ConfMan.registerDefault("gamma_level", 0);
- ConfMan.registerDefault("ambient_volume", 0);
- ConfMan.registerDefault("movie_volume", 0);
+ ConfMan.registerDefault("ambient_volume", -2000);
+ ConfMan.registerDefault("movie_volume", -1500);
ConfMan.registerDefault("music_status", true);
ConfMan.registerDefault("reverse_stereo", false);
ConfMan.registerDefault("performance", 4);
@@ -51,22 +53,25 @@ ConfigurationManager::ConfigurationManager() {
ConfMan.registerDefault("key_switchToGrimwall", 'g');
ConfMan.registerDefault("key_switchToOlmec", 'o');
- ConfMan.registerDefault("show_scene_loading", false);
+ // Special debug options
+ ConfMan.registerDefault("show_scene_loading", true);
ConfMan.registerDefault("show_intro", true);
// Init values
musicVolume = 0;
+ ambientVolume = 0;
sfxVolume = 0;
voiceVolume = 0;
- showMovieSubtitles = false;
-
- showEncounterSubtitles = true;
- gammaLevel = 0;
- ambientVolume = 0;
movieVolume = 0;
+
musicStatus = true;
reverseStereo = false;
- performance = 4;
+
+ showMovieSubtitles = false;
+ showEncounterSubtitles = true;
+
+ gammaLevel = 0;
+ performance = 0;
keyShowVersion = 'v';
keyQuickLoad = 'L';
@@ -86,6 +91,11 @@ void ConfigurationManager::read() {
voiceVolume = ConfMan.getInt("speech_volume");
showMovieSubtitles = ConfMan.getBool("subtitles");
+ // Convert volumes to engine-values
+ Sound::convertVolumeTo(musicVolume);
+ Sound::convertVolumeTo(sfxVolume);
+ Sound::convertVolumeTo(voiceVolume);
+
// Engine options
showEncounterSubtitles = ConfMan.getBool("show_encounter_subtitles");
gammaLevel = ConfMan.getInt("gamma_level");
@@ -109,10 +119,19 @@ void ConfigurationManager::read() {
}
void ConfigurationManager::write() {
+ int32 mixerMusicVolume = musicVolume;
+ int32 mixerSfxVolume = sfxVolume;
+ int32 mixerVoiceVolume = voiceVolume;
+
+ // Convert volumes to mixer-values
+ Sound::convertVolumeFrom(mixerMusicVolume);
+ Sound::convertVolumeFrom(mixerSfxVolume);
+ Sound::convertVolumeFrom(mixerVoiceVolume);
+
// Default options
- ConfMan.setInt("music_volume", musicVolume);
- ConfMan.setInt("sfx_volume", sfxVolume);
- ConfMan.setInt("speech_volume", voiceVolume);
+ ConfMan.setInt("music_volume", mixerMusicVolume);
+ ConfMan.setInt("sfx_volume", mixerSfxVolume);
+ ConfMan.setInt("speech_volume", mixerVoiceVolume);
ConfMan.setBool("subtitles", showMovieSubtitles);
// Engine options
@@ -137,4 +156,8 @@ void ConfigurationManager::write() {
ConfMan.setInt("key_switchToOlmec", (int)keySwitchToOlmec);
}
+bool ConfigurationManager::isKeyAssigned(char key) {
+ return (keyShowVersion == key || keyQuickLoad == key || keyQuickSave == key || keySwitchToSara == key || keySwitchToGrimwall == key || keySwitchToOlmec == key);
+}
+
} // end of namespace Asylum
diff --git a/engines/asylum/system/config.h b/engines/asylum/system/config.h
index 2ae206ad59..f7090e56cd 100644
--- a/engines/asylum/system/config.h
+++ b/engines/asylum/system/config.h
@@ -88,6 +88,15 @@ public:
*/
void write();
+ /**
+ * Query if 'key' is assigned.
+ *
+ * @param key The key.
+ *
+ * @return true if key assigned, false if not.
+ */
+ bool isKeyAssigned(char key);
+
private:
friend class Common::Singleton<SingletonBaseType>;
diff --git a/engines/asylum/system/sound.cpp b/engines/asylum/system/sound.cpp
index 5e171793dc..4e9c3cf6c9 100644
--- a/engines/asylum/system/sound.cpp
+++ b/engines/asylum/system/sound.cpp
@@ -117,7 +117,7 @@ void Sound::setVolume(ResourceId resourceId, int32 volume) {
if (!item)
return;
- convertVolume(volume);
+ convertVolumeFrom(volume);
_mixer->setChannelVolume(item->handle, (byte)volume);
}
@@ -129,7 +129,7 @@ void Sound::setMusicVolume(int32 volume) {
// Save music volume (we need to be able to return it to the logic code
_musicVolume = volume;
- convertVolume(volume);
+ convertVolumeFrom(volume);
_mixer->setChannelVolume(_musicHandle, (byte)volume);
}
@@ -192,19 +192,19 @@ int32 Sound::calculatePanningAtPoint(int32 x, int32) {
int delta = x - getWorld()->xLeft;
if (delta < 0)
- return (getWorld()->stereoReversedFlag ? 10000 : -10000);
+ return (getWorld()->reverseStereo ? 10000 : -10000);
if (delta >= 640)
- return (getWorld()->stereoReversedFlag ? -10000 : 10000);
+ return (getWorld()->reverseStereo ? -10000 : 10000);
int sign, absDelta;
if (delta > 320) {
absDelta = delta - 320;
- sign = (getWorld()->stereoReversedFlag ? -1 : 1);
+ sign = (getWorld()->reverseStereo ? -1 : 1);
} else {
absDelta = 320 - delta;
- sign = (getWorld()->stereoReversedFlag ? 1 : -1);
+ sign = (getWorld()->reverseStereo ? 1 : -1);
}
Common::Rational v(absDelta, 6);
@@ -250,7 +250,7 @@ void Sound::playSoundData(Audio::Mixer::SoundType type, Audio::SoundHandle *hand
Audio::RewindableAudioStream *sndStream = Audio::makeWAVStream(stream, DisposeAfterUse::YES);
// Convert volume and panning
- convertVolume(vol);
+ convertVolumeFrom(vol);
convertPan(pan);
_mixer->playStream(type, handle, Audio::makeLoopingAudioStream(sndStream, loop ? 0 : 1), -1, (byte)vol, (int8)pan);
@@ -309,7 +309,7 @@ void Sound::clearSoundBuffer() {
// Those are from engines/agos/sound.cpp (FIXME: Move to common code?)
//////////////////////////////////////////////////////////////////////////
-void Sound::convertVolume(int32 &vol) {
+void Sound::convertVolumeFrom(int32 &vol) {
// DirectSound was originally used, which specifies volume
// and panning differently than ScummVM does, using a logarithmic scale
// rather than a linear one.
@@ -330,6 +330,10 @@ void Sound::convertVolume(int32 &vol) {
}
}
+void Sound::convertVolumeTo(int32 &vol) {
+ vol = (log10(vol / (double)Audio::Mixer::kMaxChannelVolume) - 0.5) * 2000;
+}
+
void Sound::convertPan(int32 &pan) {
// DirectSound was originally used, which specifies volume
// and panning differently than ScummVM does, using a logarithmic scale
diff --git a/engines/asylum/system/sound.h b/engines/asylum/system/sound.h
index 5901603225..aa6e8298c0 100644
--- a/engines/asylum/system/sound.h
+++ b/engines/asylum/system/sound.h
@@ -239,6 +239,24 @@ public:
*/
void stopMusic();
+ //////////////////////////////////////////////////////////////////////////
+ // Conversion functions
+ //////////////////////////////////////////////////////////////////////////
+
+ /**
+ * Convert volume to a ScummVM mixer value
+ *
+ * @param [in,out] vol The volume.
+ */
+ static void convertVolumeFrom(int32 &vol);
+
+ /**
+ * Convert ScummVM mixer value to a volume
+ *
+ * @param [in,out] vol The volume.
+ */
+ static void convertVolumeTo(int32 &vol);
+
private:
AsylumEngine *_vm;
@@ -311,13 +329,6 @@ private:
// Conversion functions
//////////////////////////////////////////////////////////////////////////
- /**
- * Convert volume.
- *
- * @param [in,out] vol The volume.
- */
- static void convertVolume(int32 &vol);
-
/**
* Convert pan.
*
diff --git a/engines/asylum/views/menu.cpp b/engines/asylum/views/menu.cpp
index 9e1b280db3..c7451812ac 100644
--- a/engines/asylum/views/menu.cpp
+++ b/engines/asylum/views/menu.cpp
@@ -54,14 +54,14 @@ MainMenu::MainMenu(AsylumEngine *vm): _vm(vm) {
_musicResourceId = kResourceNone;
_gameStarted = false;
_currentIcon = kMenuNone;
- _dword_4464B8 = -1;
+ _selectedShortcutIndex = -1;
_dword_455C74 = 0;
_dword_455C78 = false;
_dword_455C80 = false;
_dword_455D4C = false;
_dword_455D5C = false;
_dword_455DD8 = false;
- _dword_455DE0 = false;
+ _testSoundsPlaying = false;
_dword_456288 = 0;
_dword_4562C0 = 0;
_textScroll = 0;
@@ -187,6 +187,78 @@ MainMenu::MenuScreen MainMenu::findMousePosition() {
return kMenuNone;
}
+void MainMenu::playTestSounds() {
+ _testSoundsPlaying = true;
+ getSound()->playSound(MAKE_RESOURCE(kResourcePackShared, 42), true, Config.ambientVolume);
+ getSound()->playSound(MAKE_RESOURCE(kResourcePackShared, 41), true, Config.sfxVolume);
+ getSound()->playSound(MAKE_RESOURCE(kResourcePackShared, 43), true, Config.voiceVolume);
+}
+
+void MainMenu::stopTestSounds() {
+ _testSoundsPlaying = false;
+ getSound()->stop(MAKE_RESOURCE(kResourcePackShared, 42));
+ getSound()->stop(MAKE_RESOURCE(kResourcePackShared, 41));
+ getSound()->stop(MAKE_RESOURCE(kResourcePackShared, 43));
+}
+
+void MainMenu::adjustMasterVolume(int32 delta) {
+ int32 *volume = NULL;
+ int32 volumeIndex = 1;
+
+ do {
+ switch (volumeIndex) {
+ default:
+ break;
+
+ case 1:
+ volume = &Config.musicVolume;
+ break;
+
+ case 2:
+ volume = &Config.ambientVolume;
+ break;
+
+ case 3:
+ volume = &Config.sfxVolume;
+ break;
+
+ case 4:
+ volume = &Config.voiceVolume;
+ break;
+
+ case 5:
+ volume = &Config.movieVolume;
+ break;
+ }
+
+ // Adjust and normalize volume
+ if (delta >= 0) {
+ if (*volume < 0) {
+ if (*volume == -9999)
+ *volume = -5000;
+
+ *volume += 250;
+
+ if (*volume > 0)
+ *volume = 0;
+ }
+ } else {
+ if (*volume > -5000) {
+ *volume -= 250;
+
+ if (*volume <= -5000)
+ *volume = -9999;
+ }
+ }
+
+ ++volumeIndex;
+ } while (volumeIndex < 6);
+}
+
+void MainMenu::adjustTestVolume() {
+
+}
+
//////////////////////////////////////////////////////////////////////////
// Event Handler
//////////////////////////////////////////////////////////////////////////
@@ -231,7 +303,7 @@ bool MainMenu::init() {
_initGame = true;
// The original also
- // - load the config (this is done when constructing the config object).
+ // - load the config (this is done when constructing the config singleton).
// - initialize game structures (this is done in classes constructors)
getSaveLoad()->loadViewedMovies();
@@ -553,7 +625,7 @@ bool MainMenu::click(const AsylumEvent &evt) {
break;
case kMenuKeyboardConfig:
- _dword_4464B8 = -1;
+ _selectedShortcutIndex = -1;
break;
case kMenuReturnToGame:
@@ -645,16 +717,16 @@ void MainMenu::updateTextOptions() {
getText()->draw(320, 150, MAKE_RESOURCE(kResourcePackText, 1412));
- switchFont(cursor.x < 350 || cursor.x > (350 + getText()->getWidth(Config.showMovieSubtitles ? MAKE_RESOURCE(kResourcePackText, 1414) : MAKE_RESOURCE(kResourcePackText, 1415))) || cursor.y < 150 || cursor.y > 174);
+ switchFont(cursor.x < 350 || cursor.x > (350 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, Config.showMovieSubtitles ? 1414 : 1415))) || cursor.y < 150 || cursor.y > 174);
getText()->setPosition(350, 150);
- getText()->draw(Config.showMovieSubtitles ? MAKE_RESOURCE(kResourcePackText, 1414) : MAKE_RESOURCE(kResourcePackText, 1415));
+ getText()->draw(MAKE_RESOURCE(kResourcePackText, Config.showMovieSubtitles ? 1414 : 1415));
getText()->loadFont(kFontYellow);
getText()->draw(320, 179, MAKE_RESOURCE(kResourcePackText, 1413));
- switchFont(cursor.x < 350 || cursor.x > (350 + getText()->getWidth(Config.showEncounterSubtitles ? MAKE_RESOURCE(kResourcePackText, 1414) : MAKE_RESOURCE(kResourcePackText, 1415))) || cursor.y < 179 || cursor.y > 203);
+ switchFont(cursor.x < 350 || cursor.x > (350 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, Config.showEncounterSubtitles ? 1414 : 1415))) || cursor.y < 179 || cursor.y > 203);
getText()->setPosition(350, 179);
- getText()->draw(Config.showEncounterSubtitles ? MAKE_RESOURCE(kResourcePackText, 1414) : MAKE_RESOURCE(kResourcePackText, 1415));
+ getText()->draw(MAKE_RESOURCE(kResourcePackText, Config.showEncounterSubtitles ? 1414 : 1415));
switchFont(cursor.x < 300 || cursor.x > (300 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 1416))) || cursor.y < 340 || cursor.y > (340 + 24));
getText()->setPosition(300, 340);
@@ -742,7 +814,7 @@ void MainMenu::updateAudioOptions() {
getText()->setPosition(220, 360);
getText()->draw(MAKE_RESOURCE(kResourcePackText, 1430));
- switchFont((cursor.x < 360 || cursor.x > (360 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 1431))) || cursor.y < 360 || cursor.y > (360 + 24)) && !_dword_455DE0);
+ switchFont((cursor.x < 360 || cursor.x > (360 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 1431))) || cursor.y < 360 || cursor.y > (360 + 24)) && !_testSoundsPlaying);
getText()->setPosition(360, 360);
getText()->draw(MAKE_RESOURCE(kResourcePackText, 1431));
}
@@ -863,7 +935,7 @@ void MainMenu::updateKeyboardConfig() {
getText()->setPosition(350, 29 * keyIndex + 150);
- if (keyIndex == _dword_4464B8) {
+ if (keyIndex == _selectedShortcutIndex) {
getText()->loadFont(kFontBlue);
if (_dword_4562C0 < 6)
@@ -1013,91 +1085,149 @@ void MainMenu::clickQuitGame() {
void MainMenu::clickTextOptions() {
Common::Point cursor = getCursor()->position();
- error("[MainMenu::clickTextOptions] Not implemented!");
+ if (cursor.x < 350 || cursor.x > (350 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, Config.showMovieSubtitles ? 1414 : 1415))) || cursor.y < 150 || cursor.y > 174) {
+ if (cursor.x < 350 || cursor.x > (350 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, Config.showEncounterSubtitles ? 1414 : 1415))) || cursor.y < 179 || cursor.y > 203) {
+ if (cursor.x >= 300 && cursor.x <= (300 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 1416))) && cursor.y >= 340 && cursor.y <= (340 + 24)) {
+ Config.write();
+ leave();
+ }
+ } else {
+ Config.showEncounterSubtitles = !Config.showEncounterSubtitles;
+ }
+ } else {
+ Config.showMovieSubtitles = !Config.showMovieSubtitles;
+ }
}
void MainMenu::clickAudioOptions() {
Common::Point cursor = getCursor()->position();
- error("[MainMenu::clickAudioOptions] Not implemented!");
-}
+ // Size of - and +
+ int32 sizeMinus = getText()->getWidth("-");
+ int32 sizePlus = getText()->getWidth("+");
-void MainMenu::clickSettings() {
- Common::Point cursor = getCursor()->position();
+ if (cursor.x >= 220 && cursor.x <= (220 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 1430))) && cursor.y >= 360 && cursor.y <= (360 + 24)) {
+ stopTestSounds();
+ Config.write();
+ _vm->syncSoundSettings();
+ leave();
+ return;
+ }
- error("[MainMenu::clickSettings] Not implemented!");
-}
+ if (cursor.x < 360 || cursor.x > (360 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 1431))) || cursor.y < 360 || cursor.y > (360 + 24)) {
+ int32 volumeIndex = 0;
+ int32 *volume = NULL;
+ bool found = false;
-void MainMenu::clickKeyboardConfig() {
- Common::Point cursor = getCursor()->position();
+ for (;;) {
+ if (found)
+ return;
- error("[MainMenu::clickKeyboardConfig] Not implemented!");
-}
+ switch (volumeIndex) {
+ default:
+ break;
-void MainMenu::clickReturnToGame() {
- if (_gameStarted) {
- if (_musicResourceId != MAKE_RESOURCE(kResourcePackMusic, getWorld()->musicCurrentResourceIndex))
- getSound()->playMusic(kResourceNone, 0);
+ case 0:
+ if (cursor.x >= 350 && cursor.x <= (350 + sizeMinus) && cursor.y >= 150 && cursor.y <= 174) {
+ adjustMasterVolume(-1);
+ adjustTestVolume();
+ found = true;
+ break;
+ }
- getScreen()->clear();
+ if (cursor.x >= (360 + sizeMinus) && cursor.x <= (360 + sizeMinus + sizePlus) && cursor.y >= 150 && cursor.y <= 174) {
+ adjustMasterVolume(1);
+ adjustTestVolume();
+ found = true;
+ break;
+ }
+ break;
- _vm->switchEventHandler(_vm->scene());
- } else {
- Common::Point cursor = getCursor()->position();
+ case 1:
+ volume = &Config.musicVolume;
+ break;
- if (cursor.x >= 285
- && cursor.x <= (285 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 1811)))
- && cursor.y >= 273
- && cursor.y <= (273 + 24))
- leave();
- }
-}
+ case 2:
+ volume = &Config.ambientVolume;
+ break;
-void MainMenu::clickShowCredits() {
- closeCredits();
-}
+ case 3:
+ volume = &Config.sfxVolume;
+ break;
-//////////////////////////////////////////////////////////////////////////
-// Key handlers
-//////////////////////////////////////////////////////////////////////////
-void MainMenu::keySaveGame() {
- error("[MainMenu::keySaveGame] Not implemented!");
-}
+ case 4:
+ volume = &Config.voiceVolume;
+ break;
-void MainMenu::keyKeyboardConfig() {
- error("[MainMenu::keyKeyboardConfig] Not implemented!");
+ case 5:
+ volume = &Config.movieVolume;
+ break;
+ }
+
+ if (!found) {
+ if (cursor.x < 350 || cursor.x > (350 + sizeMinus) || cursor.y < (29 * volumeIndex + 150) || cursor.y > (29 * (volumeIndex + 6))) {
+ if (cursor.x >= (sizeMinus + 360)) {
+ if (cursor.x <= (sizeMinus + sizePlus + 360)) {
+
+ if (cursor.y >= (29 * volumeIndex + 150) && cursor.y <= (29 * (volumeIndex + 6))) {
+ // Normalize volume
+ if (*volume < 0) {
+ if (*volume == -9999)
+ *volume = -5000;
+
+ *volume += 250;
+
+ if (*volume > 0)
+ *volume = 0;
+
+ adjustTestVolume();
+ }
+ found = true;
+ }
+ }
+ }
+ } else {
+ if (*volume > -5000) {
+ *volume -= 250;
+
+ if (*volume <= -5000)
+ *volume = -9999;
+
+ adjustTestVolume();
+ }
+ found = true;
+ }
+ }
+
+ ++volumeIndex;
+
+ if (volumeIndex >= 6) {
+ if (!found) {
+ if (cursor.x >= 350 && cursor.x <= (350 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, Config.reverseStereo ? 1428 : 1429)))
+ && cursor.y >= (29 * volumeIndex + 150) && cursor.y <= (29 * (volumeIndex + 6))) {
+ Config.reverseStereo = !Config.reverseStereo;
+ _vm->updateReverseStereo();
+ }
+ }
+
+ return;
+ }
+ }
+ }
+
+ if (_testSoundsPlaying)
+ stopTestSounds();
+ else
+ playTestSounds();
}
-void MainMenu::keyShowCredits() {
- closeCredits();
+void MainMenu::clickSettings() {
+ Common::Point cursor = getCursor()->position();
+
+ error("[MainMenu::clickSettings] Not implemented!");
}
-//////////////////////////////////////////////////////////////////////////
-// TODO REMOVE
-//////////////////////////////////////////////////////////////////////////
-//void MainMenu::updateSubMenuCinematics() {
-// int32 currentCD = 1; // FIXME: dummy value
-// getText()->drawCentered(10, 100, 620, MAKE_RESOURCE(kResourcePackText, 1352), currentCD);
-// getText()->setPosition(30, 340);
-// getText()->draw(MAKE_RESOURCE(kResourcePackText, 1353)); // Prev Page
-//
-// //if (cursor.x >= 280 && cursor.x <= 400 && cursor.y >= 340 && cursor.y <= 360) {
-// // getText()->loadFont(kFontBlue);
-// // if (_leftClick)
-// // exitSubMenu();
-// //} else {
-// // getText()->loadFont(kFontYellow);
-// //}
-//
-// getText()->setPosition(280, 340);
-// getText()->draw(MAKE_RESOURCE(kResourcePackText, 1355)); // Main Menu
-//
-// getText()->loadFont(kFontYellow);
-//
-// getText()->setPosition(500, 340);
-// getText()->draw(MAKE_RESOURCE(kResourcePackText, 1354)); // Next Page
-//}
//
//void MainMenu::updateSubMenuSettings() {
// // action
@@ -1140,6 +1270,93 @@ void MainMenu::keyShowCredits() {
// //}
//}
+void MainMenu::clickKeyboardConfig() {
+ Common::Point cursor = getCursor()->position();
+
+ if (cursor.x < 300 || cursor.x > (300 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 1446))) || cursor.y < 340 || cursor.y > (340 + 24)) {
+ int32 keyIndex = 0;
+ char key = 0;
+
+ do {
+ switch (keyIndex) {
+ default:
+ break;
+
+ case 0:
+ key = Config.keyShowVersion;
+ break;
+
+ case 1:
+ key = Config.keyQuickLoad;
+ break;
+
+ case 2:
+ key = Config.keyQuickSave;
+ break;
+
+ case 3:
+ key = Config.keySwitchToSara;
+ break;
+
+ case 4:
+ key = Config.keySwitchToGrimwall;
+ break;
+
+ case 5:
+ key = Config.keySwitchToOlmec;
+ break;
+ }
+
+ if (cursor.x >= 350 && cursor.x <= (350 + getText()->getWidth(key)) && cursor.y >= (29 * keyIndex + 150) && cursor.y <= (29 * (keyIndex + 6))) {
+ _selectedShortcutIndex = keyIndex;
+ getCursor()->hide();
+ }
+
+ ++keyIndex;
+ } while (keyIndex < 6);
+ } else {
+ Config.write();
+ leave();
+ }
+}
+
+void MainMenu::clickReturnToGame() {
+ if (_gameStarted) {
+ if (_musicResourceId != MAKE_RESOURCE(kResourcePackMusic, getWorld()->musicCurrentResourceIndex))
+ getSound()->playMusic(kResourceNone, 0);
+
+ getScreen()->clear();
+
+ _vm->switchEventHandler(_vm->scene());
+ } else {
+ Common::Point cursor = getCursor()->position();
+
+ if (cursor.x >= 285
+ && cursor.x <= (285 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 1811)))
+ && cursor.y >= 273
+ && cursor.y <= (273 + 24))
+ leave();
+ }
+}
+
+void MainMenu::clickShowCredits() {
+ closeCredits();
+}
+
+//////////////////////////////////////////////////////////////////////////
+// Key handlers
+//////////////////////////////////////////////////////////////////////////
+void MainMenu::keySaveGame() {
+ error("[MainMenu::keySaveGame] Not implemented!");
+}
+
+void MainMenu::keyKeyboardConfig() {
+ error("[MainMenu::keyKeyboardConfig] Not implemented!");
+}
+
+void MainMenu::keyShowCredits() {
+ closeCredits();
+}
} // end of namespace Asylum
diff --git a/engines/asylum/views/menu.h b/engines/asylum/views/menu.h
index cdb93641ea..1440bc399b 100644
--- a/engines/asylum/views/menu.h
+++ b/engines/asylum/views/menu.h
@@ -92,14 +92,14 @@ private:
ResourceId _musicResourceId;
bool _gameStarted;
MenuScreen _currentIcon;
- int32 _dword_4464B8;
+ int32 _selectedShortcutIndex;
int32 _dword_455C74;
bool _dword_455C78;
bool _dword_455C80;
bool _dword_455D4C;
bool _dword_455D5C;
bool _dword_455DD8;
- bool _dword_455DE0;
+ bool _testSoundsPlaying;
int32 _dword_456288;
int32 _dword_4562C0;
int32 _textScroll;
@@ -141,6 +141,28 @@ private:
*/
MenuScreen findMousePosition();
+ /**
+ * Play test sounds
+ */
+ void playTestSounds();
+
+ /**
+ * Stop test sounds.
+ */
+ void stopTestSounds();
+
+ /**
+ * Adjust volume.
+ *
+ * @param delta The delta.
+ */
+ void adjustMasterVolume(int32 delta);
+
+ /**
+ * Adjust test sounds volume.
+ */
+ void adjustTestVolume();
+
//////////////////////////////////////////////////////////////////////////
// Message handling
bool init();
Commit: 7479a0f487503f655a4c2a0327b8b9ed0c95e7ac
https://github.com/scummvm/scummvm/commit/7479a0f487503f655a4c2a0327b8b9ed0c95e7ac
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:28+02:00
Commit Message:
ASYLUM: Implement MainMenu::adjustTextVolume
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@606 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/views/menu.cpp
engines/asylum/views/menu.h
diff --git a/engines/asylum/views/menu.cpp b/engines/asylum/views/menu.cpp
index c7451812ac..44ff955794 100644
--- a/engines/asylum/views/menu.cpp
+++ b/engines/asylum/views/menu.cpp
@@ -189,16 +189,16 @@ MainMenu::MenuScreen MainMenu::findMousePosition() {
void MainMenu::playTestSounds() {
_testSoundsPlaying = true;
- getSound()->playSound(MAKE_RESOURCE(kResourcePackShared, 42), true, Config.ambientVolume);
- getSound()->playSound(MAKE_RESOURCE(kResourcePackShared, 41), true, Config.sfxVolume);
- getSound()->playSound(MAKE_RESOURCE(kResourcePackShared, 43), true, Config.voiceVolume);
+ getSound()->playSound(kAmbiantSound, true, Config.ambientVolume);
+ getSound()->playSound(kSfxSound, true, Config.sfxVolume);
+ getSound()->playSound(kVoiceSound, true, Config.voiceVolume);
}
void MainMenu::stopTestSounds() {
_testSoundsPlaying = false;
- getSound()->stop(MAKE_RESOURCE(kResourcePackShared, 42));
- getSound()->stop(MAKE_RESOURCE(kResourcePackShared, 41));
- getSound()->stop(MAKE_RESOURCE(kResourcePackShared, 43));
+ getSound()->stop(kAmbiantSound);
+ getSound()->stop(kSfxSound);
+ getSound()->stop(kVoiceSound);
}
void MainMenu::adjustMasterVolume(int32 delta) {
@@ -256,7 +256,24 @@ void MainMenu::adjustMasterVolume(int32 delta) {
}
void MainMenu::adjustTestVolume() {
-
+ getSound()->setMusicVolume(Config.musicVolume);
+ if ((Config.movieVolume / 250 + 20) <= 0)
+ getSound()->playMusic(_musicResourceId, Config.musicVolume);
+
+ if (getSound()->isPlaying(kAmbiantSound))
+ getSound()->setVolume(kAmbiantSound, Config.ambientVolume);
+ else if (_testSoundsPlaying)
+ getSound()->playSound(kAmbiantSound, true, Config.ambientVolume);
+
+ if (getSound()->isPlaying(kSfxSound))
+ getSound()->setVolume(kSfxSound, Config.sfxVolume);
+ else if (_testSoundsPlaying)
+ getSound()->playSound(kSfxSound, true, Config.sfxVolume);
+
+ if (getSound()->isPlaying(kVoiceSound))
+ getSound()->setVolume(kVoiceSound, Config.voiceVolume);
+ else if (_testSoundsPlaying)
+ getSound()->playSound(kVoiceSound, true, Config.voiceVolume);
}
//////////////////////////////////////////////////////////////////////////
diff --git a/engines/asylum/views/menu.h b/engines/asylum/views/menu.h
index 1440bc399b..0cd0725983 100644
--- a/engines/asylum/views/menu.h
+++ b/engines/asylum/views/menu.h
@@ -77,10 +77,13 @@ private:
};
enum MenuResource {
- kBackground = MAKE_RESOURCE(kResourcePackShared, 0),
- kEye = MAKE_RESOURCE(kResourcePackShared, 1),
- kFontBlue = MAKE_RESOURCE(kResourcePackShared, 22),
- kFontYellow = MAKE_RESOURCE(kResourcePackShared, 16)
+ kBackground = MAKE_RESOURCE(kResourcePackShared, 0),
+ kEye = MAKE_RESOURCE(kResourcePackShared, 1),
+ kFontBlue = MAKE_RESOURCE(kResourcePackShared, 22),
+ kFontYellow = MAKE_RESOURCE(kResourcePackShared, 16),
+ kSfxSound = MAKE_RESOURCE(kResourcePackShared, 41),
+ kAmbiantSound = MAKE_RESOURCE(kResourcePackShared, 42),
+ kVoiceSound = MAKE_RESOURCE(kResourcePackShared, 43)
};
// Game initialization
@@ -152,9 +155,9 @@ private:
void stopTestSounds();
/**
- * Adjust volume.
+ * Adjust volume.
*
- * @param delta The delta.
+ * @param delta The delta.
*/
void adjustMasterVolume(int32 delta);
Commit: 30423dae12b260bce75bf01b7d86cf4ede6099fe
https://github.com/scummvm/scummvm/commit/30423dae12b260bce75bf01b7d86cf4ede6099fe
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:28+02:00
Commit Message:
ASYLUM: Implement menu music and main settings click handling
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@607 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/views/menu.cpp
engines/asylum/views/menu.h
diff --git a/engines/asylum/views/menu.cpp b/engines/asylum/views/menu.cpp
index 44ff955794..12dd95b015 100644
--- a/engines/asylum/views/menu.cpp
+++ b/engines/asylum/views/menu.cpp
@@ -276,6 +276,32 @@ void MainMenu::adjustTestVolume() {
getSound()->playSound(kVoiceSound, true, Config.voiceVolume);
}
+void MainMenu::setupMusic() {
+ getSound()->stopAll();
+
+ int32 index = getScene() ? getWorld()->musicCurrentResourceIndex : kMusicStopped;
+
+ if (index == kMusicStopped) {
+ _soundResourceId = kResourceNone;
+ _musicResourceId = MAKE_RESOURCE(kResourcePackShared, 39);
+
+ getSound()->playMusic(_musicResourceId, Config.musicVolume);
+ } else {
+ _soundResourceId = kResourceNone;
+ _musicResourceId = MAKE_RESOURCE(kResourcePackMusic, index);
+ }
+}
+
+void MainMenu::adjustPerformance() {
+ // Original reinitialize sound to 11kHz for performance == 0, 22kHz otherwise
+
+ setupMusic();
+
+ int32 index = getScene() ? getWorld()->musicCurrentResourceIndex : kMusicStopped;
+ if (index != kMusicStopped)
+ getSound()->playMusic(MAKE_RESOURCE(kResourcePackMusic, index), Config.musicVolume);
+}
+
//////////////////////////////////////////////////////////////////////////
// Event Handler
//////////////////////////////////////////////////////////////////////////
@@ -345,6 +371,8 @@ bool MainMenu::init() {
_currentIcon = kMenuNone;
_dword_455C74 = 0;
+ setupMusic();
+
getCursor()->hide();
getCursor()->set(MAKE_RESOURCE(kResourcePackShared, 2), 0, 2);
}
@@ -890,7 +918,7 @@ void MainMenu::updateSettings() {
if (Config.performance == 5) {
getText()->draw(MAKE_RESOURCE(kResourcePackText, 1436));
} else {
- for (int32 i = 5; i > Config.performance; --i)
+ for (int32 i = 5; i > Config.performance; --i) // This has ] augmenting when pressing - which is a bit convoluted (perf == speed == more ])
getText()->drawChar(']');
if (!Config.performance)
@@ -1241,51 +1269,67 @@ void MainMenu::clickAudioOptions() {
void MainMenu::clickSettings() {
Common::Point cursor = getCursor()->position();
- error("[MainMenu::clickSettings] Not implemented!");
-}
+ // Size of - and +
+ int32 sizeMinus = getText()->getWidth("-");
+ int32 sizePlus = getText()->getWidth("+");
+
+ //////////////////////////////////////////////////////////////////////////
+ // Back to main menu
+ if (cursor.x >= 300 && cursor.x <= (300 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 1437))) && cursor.y >= 340 && cursor.y <= (340 + 24)) {
+ Config.write();
+ leave();
+ return;
+ }
+ //////////////////////////////////////////////////////////////////////////
+ // Performance minus
+ if (cursor.x >= 350 && cursor.x <= (sizeMinus + 350) && cursor.y >= 179 && cursor.y <= 203) {
+ if (!Config.performance)
+ return;
-//
-//void MainMenu::updateSubMenuSettings() {
-// // action
-// //if (_leftClick) {
-// // // back to main menu
-// // if (cursor.x >= 300 && cursor.x <= 300 + sizeMainMenu && cursor.y >= 340 && cursor.y <= 340 + 24) {
-// // // TODO: save new configurations
-// // exitSubMenu();
-// // }
-//
-// // // gamma level minus
-// // if (cursor.x >= 350 && cursor.x <= sizeMinus + 350 && cursor.y >= 150 && cursor.y <= 174) {
-// // if (Config.gammaLevel) {
-// // Config.gammaLevel -= 1;
-// // // TODO: setResGammaLevel(0x80010011, 0);
-// // }
-// // }
-// // // gamma level plus
-// // if (cursor.x >= sizeMinus + 360 && cursor.x <= sizeMinus + sizePlus + 360 && cursor.y >= 150 && cursor.y <= 174) {
-// // if (Config.gammaLevel < 8) {
-// // Config.gammaLevel += 1;
-// // // TODO: setResGammaLevel(0x80010011, 0);
-// // }
-// // }
-//
-// // // performance minus
-// // if (cursor.x >= 350 && cursor.x <= sizeMinus + 350 && cursor.y >= 179 && cursor.y <= 203) {
-// // if (Config.performance) {
-// // Config.performance -= 1;
-// // // TODO: change quality settings
-// // }
-// // }
-// // // performance plus
-// // if (cursor.x >= sizeMinus + 360 && cursor.x <= sizeMinus + sizePlus + 360 && cursor.y >= 179 && cursor.y <= 203) {
-// // if (Config.performance < 5) {
-// // Config.performance += 1;
-// // // TODO: change quality settings
-// // }
-// // }
-// //}
-//}
+ Config.performance -= 1;
+ adjustPerformance();
+
+ return;
+ }
+
+ //////////////////////////////////////////////////////////////////////////
+ // Performance plus
+ if (cursor.x >= sizeMinus + 360 && cursor.x <= (sizeMinus + sizePlus + 360) && cursor.y >= 179 && cursor.y <= 203) {
+ if (Config.performance >= 5)
+ return;
+
+ Config.performance += 1;
+ adjustPerformance();
+
+ return;
+ }
+
+ //////////////////////////////////////////////////////////////////////////
+ // Gamma level minus
+ if (cursor.x >= 350 && cursor.x <= (sizeMinus + 350) && cursor.y >= 150 && cursor.y <= 174) {
+ if (!Config.gammaLevel)
+ return;
+
+ Config.gammaLevel -= 1;
+ getScreen()->setGammaLevel(MAKE_RESOURCE(kResourcePackShared, 17), 0);
+
+ return;
+ }
+
+ //////////////////////////////////////////////////////////////////////////
+ // Gamma level plus
+ if (cursor.x >= (sizeMinus + 360) && cursor.x <= (sizeMinus + sizePlus + 360) && cursor.y >= 150 && cursor.y <= 174) {
+ if (Config.gammaLevel >= 8)
+ return;
+
+
+ Config.gammaLevel += 1;
+ getScreen()->setGammaLevel(MAKE_RESOURCE(kResourcePackShared, 17), 0);
+
+ return;
+ }
+}
void MainMenu::clickKeyboardConfig() {
Common::Point cursor = getCursor()->position();
diff --git a/engines/asylum/views/menu.h b/engines/asylum/views/menu.h
index 0cd0725983..247f4421ce 100644
--- a/engines/asylum/views/menu.h
+++ b/engines/asylum/views/menu.h
@@ -137,6 +137,11 @@ private:
*/
void listMovies();
+ /**
+ * Sets up the music.
+ */
+ void setupMusic();
+
/**
* Find if the mouse if on an icon
*
@@ -166,6 +171,11 @@ private:
*/
void adjustTestVolume();
+ /**
+ * Adjust performance.
+ */
+ void adjustPerformance();
+
//////////////////////////////////////////////////////////////////////////
// Message handling
bool init();
Commit: 7de833af20bacfe89cd20b14995a5b266dc4f7a1
https://github.com/scummvm/scummvm/commit/7de833af20bacfe89cd20b14995a5b266dc4f7a1
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:28+02:00
Commit Message:
ASYLUM: Finish keyboard handling for shortcuts configuration
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@608 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/views/menu.cpp
engines/asylum/views/menu.h
diff --git a/engines/asylum/views/menu.cpp b/engines/asylum/views/menu.cpp
index 12dd95b015..8879691b7a 100644
--- a/engines/asylum/views/menu.cpp
+++ b/engines/asylum/views/menu.cpp
@@ -549,11 +549,11 @@ bool MainMenu::key(const AsylumEvent &evt) {
break;
case kMenuSaveGame:
- keySaveGame();
+ keySaveGame(evt);
break;
case kMenuKeyboardConfig:
- keyKeyboardConfig();
+ keyKeyboardConfig(evt);
break;
case kMenuShowCredits:
@@ -1407,12 +1407,59 @@ void MainMenu::clickShowCredits() {
//////////////////////////////////////////////////////////////////////////
// Key handlers
//////////////////////////////////////////////////////////////////////////
-void MainMenu::keySaveGame() {
+void MainMenu::keySaveGame(const AsylumEvent &evt) {
error("[MainMenu::keySaveGame] Not implemented!");
}
-void MainMenu::keyKeyboardConfig() {
- error("[MainMenu::keyKeyboardConfig] Not implemented!");
+void MainMenu::keyKeyboardConfig(const AsylumEvent &evt) {
+ if (_selectedShortcutIndex == -1)
+ return;
+
+ if (evt.kbd.keycode == Common::KEYCODE_ESCAPE || evt.kbd.keycode == Common::KEYCODE_RETURN || evt.kbd.keycode == Common::KEYCODE_KP_ENTER) {
+ _selectedShortcutIndex = -1;
+ getCursor()->show();
+ return;
+ }
+
+ char *key = NULL;
+ switch(_selectedShortcutIndex) {
+ default:
+ break;
+
+ case 0:
+ key = &Config.keyShowVersion;
+ break;
+
+ case 1:
+ key = &Config.keyQuickLoad;
+ break;
+
+ case 2:
+ key = &Config.keyQuickSave;
+ break;
+
+ case 3:
+ key = &Config.keySwitchToSara;
+ break;
+
+ case 4:
+ key = &Config.keySwitchToGrimwall;
+ break;
+
+ case 5:
+ key = &Config.keySwitchToOlmec;
+ break;
+ }
+
+ // Check for alphanumeric character
+ if (evt.kbd.ascii > 255 || !isalnum(evt.kbd.ascii))
+ return;
+
+ if (!Config.isKeyAssigned(evt.kbd.ascii) || *key == evt.kbd.ascii) {
+ *key = evt.kbd.ascii;
+ _selectedShortcutIndex = -1;
+ getCursor()->show();
+ }
}
void MainMenu::keyShowCredits() {
diff --git a/engines/asylum/views/menu.h b/engines/asylum/views/menu.h
index 247f4421ce..215f652185 100644
--- a/engines/asylum/views/menu.h
+++ b/engines/asylum/views/menu.h
@@ -213,8 +213,8 @@ private:
void clickShowCredits();
// Key handlers
- void keySaveGame();
- void keyKeyboardConfig();
+ void keySaveGame(const AsylumEvent &evt);
+ void keyKeyboardConfig(const AsylumEvent &evt);
void keyShowCredits();
}; // end of class MainMenu
Commit: 2172d82d2e015cdcb42d6ba62a07f1c7bd460213
https://github.com/scummvm/scummvm/commit/2172d82d2e015cdcb42d6ba62a07f1c7bd460213
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:28+02:00
Commit Message:
ASYLUM: Implement rest of game startup
- Add stubs for game loading & setup
- Add stub for sin/cos table initialization
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@609 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/asylum.cpp
engines/asylum/asylum.h
engines/asylum/resources/actionlist.cpp
engines/asylum/resources/actionlist.h
engines/asylum/resources/data.h
engines/asylum/resources/object.cpp
engines/asylum/resources/worldstats.cpp
engines/asylum/system/graphics.h
engines/asylum/system/savegame.cpp
engines/asylum/system/savegame.h
engines/asylum/system/sound.cpp
engines/asylum/views/menu.cpp
engines/asylum/views/scene.cpp
diff --git a/engines/asylum/asylum.cpp b/engines/asylum/asylum.cpp
index c0a953348c..a881b34065 100644
--- a/engines/asylum/asylum.cpp
+++ b/engines/asylum/asylum.cpp
@@ -61,6 +61,7 @@ AsylumEngine::AsylumEngine(OSystem *system, const ADGameDescription *gd) : Engin
// Init data
memset(&_gameFlags, 0, sizeof(_gameFlags));
memset(&_puzzles, 0, sizeof(_puzzles));
+ _introPlayed = false;
// Add default search directories
const Common::FSNode gameDataDir(ConfMan.get("path"));
@@ -126,6 +127,9 @@ Common::Error AsylumEngine::run() {
_video = new Video(this, _mixer);
initPuzzles();
+ // Init tables
+ initSinCosTables();
+
// Create main menu
_mainMenu = new MainMenu(this);
_handler = _mainMenu;
@@ -161,57 +165,94 @@ void AsylumEngine::startGame(ResourcePackId sceneId, StartGameType type) {
// Clear the graphic list
_screen->clearGraphicsInQueue();
- // Reset scene
+ // Reset scene (this ensures the current resource pack is closed as in the original)
delete _scene;
_scene = new Scene(this);
+ // Original checks for the current cd (we have all data files on disc, so this is not needed)
+
switch (type) {
default:
error("[AsylumEngine::startGame] Invalid start game type!");
case kStartGamePlayIntro:
playIntro();
-
_scene->enter(sceneId);
-
- _cursor->show();
break;
case kStartGameLoad:
- error("[AsylumEngine::startGame] kStartGameLoad not implemented!");
+ if (_savegame->load()) {
+ setupLoadedGame();
+ updateReverseStereo();
+ switchEventHandler(_scene);
+ }
break;
case kStartGameScene:
_scene->enter(sceneId);
-
- _cursor->show();
break;
}
+
+ _cursor->show();
}
void AsylumEngine::restart() {
- error("[AsylumEngine::restart] Not implemented!");
+ _cursor->hide();
+
+ // Cleanup
+ memset(&_gameFlags, 0, sizeof(_gameFlags));
+ delete _scene;
+ _scene = NULL;
+
+ _data.getPoint()->x = -1;
+ _data.getPoint()->y = -1;
+
+ // FIXME the original runs a list of "reset" functions (some can be moved to constructors, others need to be part of the global data)
+
+ _introPlayed = false;
+
+ _screen->clear();
+ _sound->playMusic(kResourceNone, 0);
+
+ startGame(kResourcePackTowerCells, kStartGamePlayIntro);
}
void AsylumEngine::playIntro() {
if (!_video || !_screen)
error("[AsylumEngine::playIntro] Subsystems not initialized properly!");
- _cursor->hide();
+ updateReverseStereo();
- if (Config.showIntro)
- _video->playVideo(1);
- /*if (_scene->worldstats()->musicCurrentResourceId != kResourceMusic_FFFFFD66)
- _sound->playMusic(_scene->getResourcePack(), _scene->worldstats()->musicCurrentResourceId);*/
+ if (!_introPlayed) {
+ _cursor->hide();
- _screen->clear();
+ if (Config.showIntro) {
+ _sound->playMusic(kResourceNone, 0);
+
+ // TODO convert to new event handling
+ _video->playVideo(1);
+
+ if (_scene && _scene->worldstats()->musicCurrentResourceIndex != kMusicStopped)
+ _sound->playMusic(MAKE_RESOURCE(kResourcePackMusic, _scene->worldstats()->musicCurrentResourceIndex));
+
+ _screen->clear();
+
+ setGameFlag(kGameFlag4);
+ setGameFlag(kGameFlag12);
+
+ // Play the intro sound sample (the screen is blacked out, you hear an alarm sounding and men talking about.
+ _sound->playSound(MAKE_RESOURCE(kResourcePackSound, 7));
+ }
+
+ _introPlayed = true;
+ }
+
+ _cursor->show();
- setGameFlag(kGameFlag4);
- setGameFlag(kGameFlag12);
+ _savegame->loadViewedMovies();
- // Play the intro sound sample (the screen is blacked out, you hear
- // an alarm sounding and men talking about.
- _sound->playSound(MAKE_RESOURCE(kResourcePackSound, 7));
+ // Switch to scene event handling
+ switchEventHandler(_scene);
}
void AsylumEngine::handleEvents() {
@@ -349,7 +390,15 @@ void AsylumEngine::initPuzzles() {
_puzzles[15] = NULL;
_puzzles[16] = NULL;
- warning("[AsylumEngine::initPuzzles] Add missing puzzles");
+ warning("[AsylumEngine::initPuzzles] Add missing puzzles!");
+}
+
+void AsylumEngine::initSinCosTables() {
+ warning("[AsylumEngine::initSinCosTables] Not implemented!");
+}
+
+void AsylumEngine::setupLoadedGame() {
+ warning("[AsylumEngine::initSinCosTables] Not implemented!");
}
void AsylumEngine::updateReverseStereo() {
diff --git a/engines/asylum/asylum.h b/engines/asylum/asylum.h
index 45336ebc9d..df8eaebe60 100644
--- a/engines/asylum/asylum.h
+++ b/engines/asylum/asylum.h
@@ -199,6 +199,7 @@ private:
// Game data
SharedData _data;
int _gameFlags[1512];
+ bool _introPlayed;
void handleEvents();
void updateMouseCursor();
@@ -214,6 +215,16 @@ private:
*/
void initPuzzles();
+ /**
+ * Initializes the sine/cosine tables.
+ */
+ void initSinCosTables();
+
+ /**
+ * Sets up the loaded game.
+ */
+ void setupLoadedGame();
+
friend class Console;
};
diff --git a/engines/asylum/resources/actionlist.cpp b/engines/asylum/resources/actionlist.cpp
index ac39a7192f..ac1b8c6fcf 100644
--- a/engines/asylum/resources/actionlist.cpp
+++ b/engines/asylum/resources/actionlist.cpp
@@ -420,13 +420,13 @@ IMPLEMENT_OPCODE(PlayAnimation)
if (object->getField688() == 1) {
if (object->flags & kObjectFlag4) {
- getSharedData()->setGlobalX(object->x);
- getSharedData()->setGlobalY(object->y);
+ getSharedData()->getPoint()->x = object->x;
+ getSharedData()->getPoint()->y = object->y;
} else {
Common::Rect frameRect = GraphicResource::getFrameRect(_vm, object->getResourceId(), object->getFrameIndex());
- getSharedData()->setGlobalX(frameRect.left + Common::Rational(frameRect.width(), 2).toInt() + object->x);
- getSharedData()->setGlobalY(frameRect.top + Common::Rational(frameRect.height(), 2).toInt() + object->y);
+ getSharedData()->getPoint()->x = frameRect.left + Common::Rational(frameRect.width(), 2).toInt() + object->x;
+ getSharedData()->getPoint()->y = frameRect.top + Common::Rational(frameRect.height(), 2).toInt() + object->y;
}
}
diff --git a/engines/asylum/resources/actionlist.h b/engines/asylum/resources/actionlist.h
index 5ad94e1bc3..7ee45c54f4 100644
--- a/engines/asylum/resources/actionlist.h
+++ b/engines/asylum/resources/actionlist.h
@@ -167,6 +167,20 @@ private:
int32 param7;
int32 param8;
int32 param9;
+
+ ScriptEntry() {
+ numLines = 0;
+ opcode = 0;
+ param1 = 0;
+ param2 = 0;
+ param3 = 0;
+ param4 = 0;
+ param5 = 0;
+ param6 = 0;
+ param7 = 0;
+ param8 = 0;
+ param9 = 0;
+ }
} ScriptEntry;
typedef struct Script {
@@ -174,6 +188,12 @@ private:
int32 field_1BAC;
int32 field_1BB0;
int32 counter;
+
+ Script() {
+ field_1BAC = 0;
+ field_1BB0 = 0;
+ counter = 0;
+ }
} Script;
typedef struct ScriptQueueEntry {
diff --git a/engines/asylum/resources/data.h b/engines/asylum/resources/data.h
index c4b2e4fba7..64c0e32756 100644
--- a/engines/asylum/resources/data.h
+++ b/engines/asylum/resources/data.h
@@ -110,8 +110,8 @@ public:
_matteBarHeight = 0;
_matteVar2 = 0;
_sceneCounter = 0;
- _globalX = 0;
- _globalY = 0;
+ _point.x = -1;
+ _point.y = -1;
_sceneXLeft = 0;
_sceneYTop = 0;
_sceneOffset = 0;
@@ -161,10 +161,7 @@ public:
void setActorUpdateFlag2(int32 val) { _data1[36] = val; }
// Shared global Data
- int32 getGlobalX() const { return _globalX; }
- void setGlobalX(int32 val) { _globalX = val; }
- int32 getGlobalY() const { return _globalY; }
- void setGlobalY(int32 val) { _globalY = val; }
+ Common::Point *getPoint() { return &_point; }
int32 getMatteBarHeight() { return _matteBarHeight;}
void setMatteBarHeight(int32 val) { _matteBarHeight = val; }
@@ -318,8 +315,7 @@ private:
// TODO Add ambient sound panning array
uint32 _sceneCounter;
- int32 _globalX;
- int32 _globalY;
+ Common::Point _point; // global point
//bool _flagEncouter2;
int32 _sceneXLeft;
int32 _sceneYTop;
diff --git a/engines/asylum/resources/object.cpp b/engines/asylum/resources/object.cpp
index fb7f34254d..cf456cc154 100644
--- a/engines/asylum/resources/object.cpp
+++ b/engines/asylum/resources/object.cpp
@@ -272,14 +272,14 @@ void Object::update() {
if (_frameIndex < _frameCount - 1) {
if (_field_688 == 1) {
Common::Rect frameRect = GraphicResource::getFrameRect(_vm, _resourceId, _frameIndex);
- getSharedData()->setGlobalX(x + frameRect.left + Common::Rational(frameRect.width(), 2).toInt());
- getSharedData()->setGlobalY(y + frameRect.top + Common::Rational(frameRect.height(), 2).toInt());
+ getSharedData()->getPoint()->x = x + frameRect.left + Common::Rational(frameRect.width(), 2).toInt();
+ getSharedData()->getPoint()->y = y + frameRect.top + Common::Rational(frameRect.height(), 2).toInt();
}
} else {
flags &= ~kObjectFlag8;
if (_field_688 == 1) {
- getSharedData()->setGlobalX(-1);
- getSharedData()->setGlobalY(-1);
+ getSharedData()->getPoint()->x = -1;
+ getSharedData()->getPoint()->y = -1;
}
}
_tickCount = _vm->getTick();
@@ -294,13 +294,13 @@ void Object::update() {
if (_frameIndex == 0) {
flags &= ~kObjectFlag10000;
if (_field_688 == 1) {
- getSharedData()->setGlobalX(-1);
- getSharedData()->setGlobalY(-1);
+ getSharedData()->getPoint()->x = -1;
+ getSharedData()->getPoint()->y = -1;
}
} else if (_field_688 == 1) {
Common::Rect frameRect = GraphicResource::getFrameRect(_vm, _resourceId, _frameIndex);
- getSharedData()->setGlobalX(x + frameRect.left + Common::Rational(frameRect.width(), 2).toInt());
- getSharedData()->setGlobalY(y + frameRect.top + Common::Rational(frameRect.height(), 2).toInt());
+ getSharedData()->getPoint()->x = x + frameRect.left + Common::Rational(frameRect.width(), 2).toInt();
+ getSharedData()->getPoint()->y = y + frameRect.top + Common::Rational(frameRect.height(), 2).toInt();
}
_tickCount = _vm->getTick();
diff --git a/engines/asylum/resources/worldstats.cpp b/engines/asylum/resources/worldstats.cpp
index 485c450924..98039c5311 100644
--- a/engines/asylum/resources/worldstats.cpp
+++ b/engines/asylum/resources/worldstats.cpp
@@ -85,7 +85,7 @@ WorldStats::WorldStats(Common::SeekableReadStream *stream, Scene *scene) : _scen
numAmbientSound = 0;
musicStatus = 0;
- musicCurrentResourceIndex = 0;
+ musicCurrentResourceIndex = kResourceNone;
musicFlag = 0;
musicResourceId = kResourceNone;
musicStatusExt = 0;
diff --git a/engines/asylum/system/graphics.h b/engines/asylum/system/graphics.h
index 02c520ba68..47b36f8801 100644
--- a/engines/asylum/system/graphics.h
+++ b/engines/asylum/system/graphics.h
@@ -86,7 +86,7 @@ public:
private:
AsylumEngine *_vm;
- Common::Array <GraphicFrame> _frames;
+ Common::Array<GraphicFrame> _frames;
ResourceId _resourceId;
int32 _flags;
diff --git a/engines/asylum/system/savegame.cpp b/engines/asylum/system/savegame.cpp
index bb0379ff02..3568ad2b71 100644
--- a/engines/asylum/system/savegame.cpp
+++ b/engines/asylum/system/savegame.cpp
@@ -41,6 +41,12 @@ bool Savegame::setup() {
return true;
}
+bool Savegame::load() {
+ warning("[Savegame::load] Not implemented!");
+
+ return false;
+}
+
void Savegame::loadViewedMovies() {
warning("[Savegame::loadViewedMovies] Not implemented!");
}
diff --git a/engines/asylum/system/savegame.h b/engines/asylum/system/savegame.h
index a564ae9187..1eb5c65322 100644
--- a/engines/asylum/system/savegame.h
+++ b/engines/asylum/system/savegame.h
@@ -37,6 +37,8 @@ public:
bool setup();
+ bool load();
+
void loadViewedMovies();
void loadList();
diff --git a/engines/asylum/system/sound.cpp b/engines/asylum/system/sound.cpp
index 4e9c3cf6c9..2c02d3b55b 100644
--- a/engines/asylum/system/sound.cpp
+++ b/engines/asylum/system/sound.cpp
@@ -152,12 +152,12 @@ int32 Sound::calculateVolumeAdjustement(int32 x, int32 y, int32 attenuation, int
return -(delta * delta);
Actor *player = getScene()->getActor();
- if (getSharedData()->getGlobalX() == -1) {
+ if (getSharedData()->getPoint()->x == -1) {
x -= (player->getPoint1()->x + player->getPoint2()->x);
y -= (player->getPoint1()->y + player->getPoint2()->y);
} else {
- x -= getSharedData()->getGlobalX();
- y -= getSharedData()->getGlobalY();
+ x -= getSharedData()->getPoint()->x;
+ y -= getSharedData()->getPoint()->y;
}
int32 adjustedVolume = getAdjustedVolume(x * x + y * y);
diff --git a/engines/asylum/views/menu.cpp b/engines/asylum/views/menu.cpp
index 8879691b7a..fc192800fe 100644
--- a/engines/asylum/views/menu.cpp
+++ b/engines/asylum/views/menu.cpp
@@ -258,7 +258,7 @@ void MainMenu::adjustMasterVolume(int32 delta) {
void MainMenu::adjustTestVolume() {
getSound()->setMusicVolume(Config.musicVolume);
if ((Config.movieVolume / 250 + 20) <= 0)
- getSound()->playMusic(_musicResourceId, Config.musicVolume);
+ getSound()->playMusic(_musicResourceId);
if (getSound()->isPlaying(kAmbiantSound))
getSound()->setVolume(kAmbiantSound, Config.ambientVolume);
@@ -285,7 +285,7 @@ void MainMenu::setupMusic() {
_soundResourceId = kResourceNone;
_musicResourceId = MAKE_RESOURCE(kResourcePackShared, 39);
- getSound()->playMusic(_musicResourceId, Config.musicVolume);
+ getSound()->playMusic(_musicResourceId);
} else {
_soundResourceId = kResourceNone;
_musicResourceId = MAKE_RESOURCE(kResourcePackMusic, index);
@@ -299,7 +299,7 @@ void MainMenu::adjustPerformance() {
int32 index = getScene() ? getWorld()->musicCurrentResourceIndex : kMusicStopped;
if (index != kMusicStopped)
- getSound()->playMusic(MAKE_RESOURCE(kResourcePackMusic, index), Config.musicVolume);
+ getSound()->playMusic(MAKE_RESOURCE(kResourcePackMusic, index));
}
//////////////////////////////////////////////////////////////////////////
diff --git a/engines/asylum/views/scene.cpp b/engines/asylum/views/scene.cpp
index 21b101f551..165a586536 100644
--- a/engines/asylum/views/scene.cpp
+++ b/engines/asylum/views/scene.cpp
@@ -80,7 +80,6 @@ Scene::~Scene() {
getResource()->unload(_packId);
delete _actions;
- //delete _blowUp;
delete _special;
delete _speech;
delete _title;
@@ -410,7 +409,8 @@ void Scene::activate() {
_isActive = true;
getScreen()->setPalette(_ws->currentPaletteId);
- getScreen()->draw(_ws->backgroundImage, 0, _ws->xLeft, _ws->yTop, 0);
+ // FIXME this corrupts memory (the copyToBackBuffer function is broken)
+ //getScreen()->draw(_ws->backgroundImage, 0, _ws->xLeft, _ws->yTop, 0);
}
bool Scene::update() {
Commit: e1d12045d033a573aab95f11fda01974f50ae95d
https://github.com/scummvm/scummvm/commit/e1d12045d033a573aab95f11fda01974f50ae95d
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:28+02:00
Commit Message:
ASYLUM: Refactor parts of Scene class
- Add stubs for event handlers
- Change WorldStats to take an engine pointer like all other classes
- Move copyToBackBufferClipped to screen class
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@610 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/asylum.cpp
engines/asylum/puzzles/vcr.cpp
engines/asylum/resources/worldstats.cpp
engines/asylum/resources/worldstats.h
engines/asylum/system/screen.cpp
engines/asylum/system/screen.h
engines/asylum/views/scene.cpp
engines/asylum/views/scene.h
diff --git a/engines/asylum/asylum.cpp b/engines/asylum/asylum.cpp
index a881b34065..ea09bf0b8d 100644
--- a/engines/asylum/asylum.cpp
+++ b/engines/asylum/asylum.cpp
@@ -311,11 +311,6 @@ void AsylumEngine::processDelayedEvents() {
_sound->stopAll();
_video->playVideo(videoIdx);
_scene->actions()->setDelayedVideoIndex(-1);
-
- //if (_mainMenu->isActive())
- // _mainMenu->openMenu();
- if (_scene->isActive())
- _scene->activate();
}
// check for a delayed scene change
diff --git a/engines/asylum/puzzles/vcr.cpp b/engines/asylum/puzzles/vcr.cpp
index a3ff7a3755..80b49a3e76 100644
--- a/engines/asylum/puzzles/vcr.cpp
+++ b/engines/asylum/puzzles/vcr.cpp
@@ -58,7 +58,7 @@ BlowUpPuzzleVCR::~BlowUpPuzzleVCR() {
void BlowUpPuzzleVCR::open() {
_active = true;
- getScene()->deactivate();
+ //getScene()->deactivate();
getSound()->stopAll();
@@ -79,7 +79,7 @@ void BlowUpPuzzleVCR::open() {
void BlowUpPuzzleVCR::close() {
_active = false;
- getScene()->activate();
+ //getScene()->activate();
}
bool BlowUpPuzzleVCR::handleEvent(const AsylumEvent &ev) {
diff --git a/engines/asylum/resources/worldstats.cpp b/engines/asylum/resources/worldstats.cpp
index 98039c5311..e73e6f0966 100644
--- a/engines/asylum/resources/worldstats.cpp
+++ b/engines/asylum/resources/worldstats.cpp
@@ -29,13 +29,11 @@
#include "asylum/resources/actor.h"
#include "asylum/resources/object.h"
-#include "asylum/views/scene.h"
-
#include "asylum/asylum.h"
namespace Asylum {
-WorldStats::WorldStats(Common::SeekableReadStream *stream, Scene *scene) : _scene(scene) {
+WorldStats::WorldStats(AsylumEngine *engine) : _vm(engine) {
// Init values
size = 0;
numEntries = 0;
@@ -96,9 +94,6 @@ WorldStats::WorldStats(Common::SeekableReadStream *stream, Scene *scene) : _scen
memset(&wheels, 0, sizeof(wheels));
tickCount1 = 0;
memset(&field_E8660, 0, sizeof(field_E8660));
-
- // Load data
- load(stream);
}
WorldStats::~WorldStats() {
@@ -107,7 +102,7 @@ WorldStats::~WorldStats() {
CLEAR_ARRAY(ActionArea, actions);
// Zero-out passed pointers
- _scene = NULL;
+ _vm = NULL;
}
// FIXME: load necessary World Stats content
@@ -214,7 +209,7 @@ void WorldStats::load(Common::SeekableReadStream *stream) {
//////////////////////////////////////////////////////////////////////////
// Read Objects
for (uint32 a = 0; a < numObjects; a++) {
- Object *object = new Object(_scene->vm());
+ Object *object = new Object(_vm);
object->load(stream);
objects.push_back(object);
@@ -225,7 +220,7 @@ void WorldStats::load(Common::SeekableReadStream *stream) {
//////////////////////////////////////////////////////////////////////////
// Read Actors
for (ActorIndex index = 0; index < (int)numActors; index++) {
- Actor *actor = new Actor(_scene->vm(), index);
+ Actor *actor = new Actor(_vm, index);
actor->load(stream);
actors.push_back(actor);
@@ -325,7 +320,7 @@ int32 WorldStats::getRandomActionAreaIndexById(int32 id) {
if (!count)
return -1;
- return indexes[_scene->vm()->getRandom(count)];
+ return indexes[_vm->getRandom(count)];
}
ActionArea* WorldStats::getActionAreaById(int32 id) {
diff --git a/engines/asylum/resources/worldstats.h b/engines/asylum/resources/worldstats.h
index 2c6627104b..ec23573ceb 100644
--- a/engines/asylum/resources/worldstats.h
+++ b/engines/asylum/resources/worldstats.h
@@ -44,15 +44,22 @@ namespace Asylum {
class Actor;
class Object;
-class Scene;
+class AsylumEngine;
struct ActionArea;
class WorldStats {
public:
- WorldStats(Common::SeekableReadStream *stream, Scene *scene);
+ WorldStats(AsylumEngine *engine);
virtual ~WorldStats();
+ /**
+ * Loads the data
+ *
+ * @param stream If non-null, the Common::SeekableReadStream * to load from
+ */
+ void load(Common::SeekableReadStream *stream);
+
int32 size;
int32 numEntries;
ChapterIndex chapter;
@@ -144,9 +151,7 @@ public:
Common::String toString();
private:
- Scene *_scene;
-
- void load(Common::SeekableReadStream *stream);
+ AsylumEngine *_vm;
};
} // end of namespace Asylum
diff --git a/engines/asylum/system/screen.cpp b/engines/asylum/system/screen.cpp
index 0982bb71e2..bf0867f61d 100644
--- a/engines/asylum/system/screen.cpp
+++ b/engines/asylum/system/screen.cpp
@@ -115,6 +115,35 @@ void Screen::copyToBackBufferWithTransparency(byte *buffer, int32 pitch, int32 x
}
}
+void Screen::copyToBackBufferClipped(Graphics::Surface *surface, int x, int y) {
+ Common::Rect screenRect(getWorld()->xLeft, getWorld()->yTop, getWorld()->xLeft + 640, getWorld()->yTop + 480);
+ Common::Rect animRect(x, y, x + surface->w, y + surface->h);
+ animRect.clip(screenRect);
+
+ if (!animRect.isEmpty()) {
+ // Translate anim rectangle
+ animRect.translate(-(int16)getWorld()->xLeft, -(int16)getWorld()->yTop);
+
+ int startX = animRect.right == 640 ? 0 : surface->w - animRect.width();
+ int startY = animRect.bottom == 480 ? 0 : surface->h - animRect.height();
+
+ if (surface->w > 640)
+ startX = getWorld()->xLeft;
+ if (surface->h > 480)
+ startY = getWorld()->yTop;
+
+ _vm->screen()->copyToBackBufferWithTransparency(
+ ((byte*)surface->pixels) +
+ startY * surface->pitch +
+ startX * surface->bytesPerPixel,
+ surface->pitch,
+ animRect.left,
+ animRect.top,
+ animRect.width(),
+ animRect.height());
+ }
+}
+
void Screen::setPalette(ResourceId id) {
setPalette(getResource()->get(id)->data + 32);
diff --git a/engines/asylum/system/screen.h b/engines/asylum/system/screen.h
index 91f4cc1364..c8a7e80c21 100644
--- a/engines/asylum/system/screen.h
+++ b/engines/asylum/system/screen.h
@@ -100,6 +100,9 @@ public:
void copyToBackBufferWithTransparency(byte *buffer, int32 pitch, int32 x, int32 y, int32 width, int32 height);
void copyBackBufferToScreen();
+ // Debug
+ void copyToBackBufferClipped(Graphics::Surface *surface, int x, int y);
+
private:
Graphics::Surface _backBuffer;
AsylumEngine *_vm;
diff --git a/engines/asylum/views/scene.cpp b/engines/asylum/views/scene.cpp
index 165a586536..2f16f32ebf 100644
--- a/engines/asylum/views/scene.cpp
+++ b/engines/asylum/views/scene.cpp
@@ -57,7 +57,7 @@ int g_debugPolygons;
int g_debugObjects;
int g_debugScrolling;
-Scene::Scene(AsylumEngine *engine): _vm(engine), _ev(NULL),
+Scene::Scene(AsylumEngine *engine): _vm(engine),
_actions(NULL), _special(NULL), _speech(NULL), _title(NULL), _polygons(NULL), _ws(NULL) {
// Initialize data
@@ -69,10 +69,6 @@ Scene::Scene(AsylumEngine *engine): _vm(engine), _ev(NULL),
_rightButton = false;
_isActive = false;
_globalDirection = kDirectionN;
-
- // Graphics
- _bgResource = NULL;
- _background = NULL;
}
Scene::~Scene() {
@@ -86,12 +82,8 @@ Scene::~Scene() {
delete _polygons;
delete _ws;
- delete _bgResource;
- _background = NULL;
-
// Zero passed pointers
_vm = NULL;
- _ev = NULL;
}
void Scene::enter(ResourcePackId packId) {
@@ -184,11 +176,10 @@ void Scene::enter(ResourcePackId packId) {
_ws->actorType = actorType[_ws->chapter];
// Play intro music
- ResourceId musicId = kResourceNone;
if (_ws->musicCurrentResourceIndex != kMusicStopped && _ws->chapter != kChapter1)
- musicId = MAKE_RESOURCE(kResourcePackMusic, _ws->musicCurrentResourceIndex);
-
- getSound()->playMusic(musicId);
+ getSound()->playMusic(MAKE_RESOURCE(kResourcePackMusic, _ws->musicCurrentResourceIndex));
+ else
+ getSound()->playMusic(kResourceNone, 0);
// Update global values
_vm->lastScreenUpdate = 1;
@@ -201,8 +192,6 @@ void Scene::enter(ResourcePackId packId) {
changePlayer(1);
_ws->nextPlayer = kActorInvalid;
}
-
- activate();
}
void Scene::load(ResourcePackId packId) {
@@ -229,8 +218,11 @@ void Scene::load(ResourcePackId packId) {
if (Common::String(sceneTag, 6) != "DFISCN")
error("The file isn't recognized as scene %s", filename);
- _ws = new WorldStats(fd, this);
+ _ws = new WorldStats(_vm);
+ _ws->load(fd);
+
_polygons = new Polygons(fd);
+
_actions = new ActionList(_vm);
_actions->load(fd);
@@ -244,9 +236,6 @@ void Scene::load(ResourcePackId packId) {
// the title screen overwriting the font
_vm->text()->loadFont(_ws->font1);
- _bgResource = new GraphicResource(_vm, _ws->backgroundImage);
- //_blowUp = 0;
- _background = NULL;
_leftClick = false;
_rightButton = false;
_isActive = false;
@@ -284,52 +273,46 @@ Actor* Scene::getActor(ActorIndex index) {
return _ws->actors[computedIndex];
}
-void Scene::setScenePosition(int x, int y) {
- if (!_ws)
- error("[Scene::setScenePosition] WorldStats not initialized properly!");
-
- if (!_bgResource)
- error("[Scene::setScenePosition] Scene resources not initialized properly!");
-
- GraphicFrame *bg = _bgResource->getFrame(0);
- //_startX = x;
- //_startY = y;
-
- int32 *targetX = &_ws->coordinates[0];
- int32 *targetY = &_ws->coordinates[1];
-
- *targetX = x;
- *targetY = y;
-
- if (*targetX < 0)
- *targetX = 0;
- if (*targetX > (bg->surface.w - 640))
- *targetX = bg->surface.w - 640;
-
-
- if (*targetY < 0)
- *targetY = 0;
- if (*targetY > (bg->surface.h - 480))
- *targetY = bg->surface.h - 480;
-}
-
-
-bool Scene::handleEvent(const AsylumEvent &ev) {
+//void Scene::setScenePosition(int x, int y) {
+// if (!_ws)
+// error("[Scene::setScenePosition] WorldStats not initialized properly!");
+//
+// if (!_bgResource)
+// error("[Scene::setScenePosition] Scene resources not initialized properly!");
+//
+// GraphicFrame *bg = _bgResource->getFrame(0);
+// //_startX = x;
+// //_startY = y;
+//
+// int32 *targetX = &_ws->coordinates[0];
+// int32 *targetY = &_ws->coordinates[1];
+//
+// *targetX = x;
+// *targetY = y;
+//
+// if (*targetX < 0)
+// *targetX = 0;
+// if (*targetX > (bg->surface.w - 640))
+// *targetX = bg->surface.w - 640;
+//
+//
+// if (*targetY < 0)
+// *targetY = 0;
+// if (*targetY > (bg->surface.h - 480))
+// *targetY = bg->surface.h - 480;
+//}
+
+
+bool Scene::handleEvent(const AsylumEvent &evt) {
// TODO replace previous handleEvent method
- return true;
-}
-
-void Scene::handleEvent(Common::Event *event, bool doUpdate) {
if (!_ws)
error("[Scene::handleEvent] WorldStats not initialized properly!");
if (!_title)
error("[Scene::handleEvent] Scene title not initialized properly!");
- _ev = event;
-
- switch (_ev->type) {
+ switch (evt.type) {
case Common::EVENT_MOUSEMOVE:
//if (getCursor())
@@ -364,8 +347,8 @@ void Scene::handleEvent(Common::Event *event, bool doUpdate) {
// FIXME just updating because a left click event
// is caught causes animation speeds to change. This needs
// to be addressed
- if (!doUpdate)
- return;
+ /*if (!doUpdate)
+ return;*/
if (Config.showSceneLoading) {
if (!_titleLoaded) {
@@ -374,12 +357,12 @@ void Scene::handleEvent(Common::Event *event, bool doUpdate) {
_titleLoaded = true;
activate();
}
- return;
+ return true;
}
}
- if (update())
- return;
+ if (updateScene())
+ return true;
// TODO: check game quality
drawScene();
@@ -395,25 +378,31 @@ void Scene::handleEvent(Common::Event *event, bool doUpdate) {
_vm->clearGameFlag(kGameFlag219);
}
}
+
+ return true;
+}
+
+void Scene::update() {
+
}
void Scene::activate() {
- if (!_ws)
- error("[Scene::activate] WorldStats not initialized properly!");
+ //if (!_ws)
+ // error("[Scene::activate] WorldStats not initialized properly!");
- if (!_bgResource)
- error("[Scene::activate] Scene resources not initialized properly!");
+ //if (!_bgResource)
+ // error("[Scene::activate] Scene resources not initialized properly!");
- //////////////////////////////////////////////////////////////////////////
- // FIXME: get rid of this?
+ ////////////////////////////////////////////////////////////////////////////
+ //// FIXME: get rid of this?
- _isActive = true;
- getScreen()->setPalette(_ws->currentPaletteId);
+ //_isActive = true;
+ //getScreen()->setPalette(_ws->currentPaletteId);
// FIXME this corrupts memory (the copyToBackBuffer function is broken)
//getScreen()->draw(_ws->backgroundImage, 0, _ws->xLeft, _ws->yTop, 0);
}
-bool Scene::update() {
+bool Scene::updateScene() {
#ifdef DEBUG_SCENE_TIMES
#define MESURE_TICKS(func) { \
int32 startTick =_vm->getTick(); \
@@ -425,18 +414,20 @@ bool Scene::update() {
#endif
// Update each part of the scene
- MESURE_TICKS(updateMouse);
- MESURE_TICKS(updateActors);
- MESURE_TICKS(updateObjects);
- MESURE_TICKS(updateAmbientSounds);
- MESURE_TICKS(updateMusic);
- MESURE_TICKS(updateScreen);
-
- // Update Debug
- if (g_debugPolygons)
- debugShowPolygons();
- if (g_debugObjects)
- debugShowObjects();
+ if (getSharedData()->getMatteBarHeight() != 170 || getSharedData()->getMattePlaySound()) {
+ MESURE_TICKS(updateMouse);
+ MESURE_TICKS(updateActors);
+ MESURE_TICKS(updateObjects);
+ MESURE_TICKS(updateAmbientSounds);
+ MESURE_TICKS(updateMusic);
+ MESURE_TICKS(updateAdjustScreen);
+
+ // Update Debug
+ if (g_debugPolygons)
+ debugShowPolygons();
+ if (g_debugObjects)
+ debugShowObjects();
+ }
return _actions->process();
}
@@ -582,7 +573,7 @@ void Scene::updateMouse() {
if (!done && (act->getDirection() != kDirectionE || getCursor()->position().y - actorPos.bottom > 10))
dir = kDirectionSE;
- handleMouseUpdate(dir, actorPos);
+ updateCursor(dir, actorPos);
if (dir >= 0) {
if (act->getStatus() == 1 || act->getStatus() == 12)
@@ -590,7 +581,7 @@ void Scene::updateMouse() {
}
}
-void Scene::handleMouseUpdate(int direction, Common::Rect rect) {
+void Scene::updateCursor(int direction, Common::Rect rect) {
int16 rlimit = rect.right - 10;
ResourceId newGraphicResourceId;
HitType type = kHitNone;
@@ -969,11 +960,11 @@ void Scene::updateMusic() {
//warning("[Scene::updateMusic] not implemented!");
}
-void Scene::updateScreen() {
- if (g_debugScrolling) { // DEBUG ScreenScrolling
- debugScreenScrolling(_bgResource->getFrame(0));
+void Scene::updateAdjustScreen() {
+ if (g_debugScrolling) {
+ debugScreenScrolling();
} else {
- updateAdjustScreen();
+ updateCoordinates();
}
}
@@ -1004,7 +995,7 @@ void Scene::playIntroSpeech() {
warning("[Scene::playIntroSpeech] Missing palette fade and wait!");
}
-void Scene::updateAdjustScreen() {
+void Scene::updateCoordinates() {
Actor *act = getActor();
int32 newXLeft = -1;
int32 newYTop = -1;
@@ -1389,60 +1380,27 @@ void Scene::getActorPosition(Actor *actor, Common::Point *pt) {
pt->x = actor->getPoint1()->x - _ws->xLeft;
pt->y = actor->getPoint1()->y - _ws->yTop;
}
-// ----------------------------------
-// ---------- SCREEN REGION -----------
-// ----------------------------------
-
-void Scene::copyToBackBufferClipped(Graphics::Surface *surface, int x, int y) {
- if (!_ws)
- error("[Scene::copyToBackBufferClipped] WorldStats not initialized properly!");
-
- Common::Rect screenRect(_ws->xLeft, _ws->yTop, _ws->xLeft + 640, _ws->yTop + 480);
- Common::Rect animRect(x, y, x + surface->w, y + surface->h);
- animRect.clip(screenRect);
-
- if (!animRect.isEmpty()) {
- // Translate anim rectangle
- animRect.translate(-(int16)_ws->xLeft, -(int16)_ws->yTop);
-
- int startX = animRect.right == 640 ? 0 : surface->w - animRect.width();
- int startY = animRect.bottom == 480 ? 0 : surface->h - animRect.height();
-
- if (surface->w > 640)
- startX = _ws->xLeft;
- if (surface->h > 480)
- startY = _ws->yTop;
-
- _vm->screen()->copyToBackBufferWithTransparency(
- ((byte*)surface->pixels) +
- startY * surface->pitch +
- startX * surface->bytesPerPixel,
- surface->pitch,
- animRect.left,
- animRect.top,
- animRect.width(),
- animRect.height());
- }
-}
// ----------------------------------
// ---------- DEBUG REGION -----------
// ----------------------------------
-void Scene::debugScreenScrolling(GraphicFrame *bg) {
+void Scene::debugScreenScrolling() {
if (!_ws)
error("[Scene::debugScreenScrolling] WorldStats not initialized properly!");
+ Common::Rect rect = GraphicResource::getFrameRect(_vm, _ws->backgroundImage, 0);
+
// Horizontal scrolling
if (getCursor()->position().x < SCREEN_EDGES && _ws->xLeft >= SCROLL_STEP)
_ws->xLeft -= SCROLL_STEP;
- else if (getCursor()->position().x > 640 - SCREEN_EDGES && _ws->xLeft <= bg->surface.w - 640 - SCROLL_STEP)
+ else if (getCursor()->position().x > 640 - SCREEN_EDGES && _ws->xLeft <= rect.width() - 640 - SCROLL_STEP)
_ws->xLeft += SCROLL_STEP;
// Vertical scrolling
if (getCursor()->position().y < SCREEN_EDGES && _ws->yTop >= SCROLL_STEP)
_ws->yTop -= SCROLL_STEP;
- else if (getCursor()->position().y > 480 - SCREEN_EDGES && _ws->yTop <= bg->surface.h - 480 - SCROLL_STEP)
+ else if (getCursor()->position().y > 480 - SCREEN_EDGES && _ws->yTop <= rect.height() - 480 - SCROLL_STEP)
_ws->yTop += SCROLL_STEP;
}
@@ -1462,7 +1420,7 @@ void Scene::debugShowWalkRegion(PolyDefinitions *poly) {
poly->points[(i+1) % poly->count()].y - poly->boundingRect.top, 0x3A);
}
- copyToBackBufferClipped(&surface, poly->boundingRect.left, poly->boundingRect.top);
+ getScreen()->copyToBackBufferClipped(&surface, poly->boundingRect.left, poly->boundingRect.top);
surface.free();
}
@@ -1488,7 +1446,7 @@ void Scene::debugShowPolygons() {
poly.points[(i+1) % poly.count()].y - poly.boundingRect.top, 0xFF);
}
- copyToBackBufferClipped(&surface, poly.boundingRect.left, poly.boundingRect.top);
+ getScreen()->copyToBackBufferClipped(&surface, poly.boundingRect.left, poly.boundingRect.top);
surface.free();
}
@@ -1508,7 +1466,7 @@ void Scene::debugShowObjects() {
object->getBoundingRect()->bottom - object->getBoundingRect()->top + 1,
1);
surface.frameRect(*object->getBoundingRect(), 0x22);
- copyToBackBufferClipped(&surface, object->x, object->y);
+ getScreen()->copyToBackBufferClipped(&surface, object->x, object->y);
}
surface.free();
@@ -1526,7 +1484,7 @@ void Scene::debugShowActors() {
a->getBoundingRect()->bottom - a->getBoundingRect()->top + 1,
1);
surface.frameRect(*a->getBoundingRect(), 0x22);
- copyToBackBufferClipped(&surface, a->getPoint()->x, a->getPoint()->y);
+ getScreen()->copyToBackBufferClipped(&surface, a->getPoint()->x, a->getPoint()->y);
}
surface.free();
diff --git a/engines/asylum/views/scene.h b/engines/asylum/views/scene.h
index a02a6132af..7bbde8b9c6 100644
--- a/engines/asylum/views/scene.h
+++ b/engines/asylum/views/scene.h
@@ -75,29 +75,27 @@ public:
~Scene();
/**
- * Enter a scene
+ * Load the scene data
*
* @param packId Package id for the scene.
*/
- void enter(ResourcePackId packId);
+ void load(ResourcePackId packId);
/**
- * Load the scene data
+ * Enter a scene
+ *
* @param packId Package id for the scene.
*/
- void load(ResourcePackId packId);
+ void enter(ResourcePackId packId);
+ /**
+ * Handle events
+ *
+ * @param ev The event
+ *
+ * @return true if it succeeds, false if it fails.
+ */
bool handleEvent(const AsylumEvent &ev);
- void handleEvent(Common::Event *event, bool doUpdate);
-
- void activate();
- void deactivate() { _isActive = false; }
- bool isActive() { return _isActive; }
- ResourcePackId getPackId() { return _packId; }
-
- //BlowUpPuzzle* getBlowUpPuzzle() { return _blowUp;}
- //void setBlowUpPuzzle(BlowUpPuzzle* puzzle) { _blowUp = puzzle; }
- void setScenePosition(int x, int y);
AsylumEngine* vm() { return _vm; }
@@ -120,6 +118,13 @@ public:
void setPlayerActorIndex(ActorIndex index) { _playerActorIdx = index; }
void changePlayer(ActorIndex index);
+ /**
+ * Gets the current scene pack identifier.
+ *
+ * @return The pack identifier.
+ */
+ ResourcePackId getPackId() { return _packId; }
+
/**
* Get a reference to an actor object from the
* WorldStats actor list. Default parameter just
@@ -195,7 +200,6 @@ protected:
private:
AsylumEngine *_vm;
- Common::Event *_ev;
ResourcePackId _packId;
int32 _playerActorIdx;
@@ -214,9 +218,6 @@ private:
Polygons *_polygons;
WorldStats *_ws;
- GraphicResource *_bgResource;
- GraphicFrame *_background;
-
struct UpdateItem {
ActorIndex index;
int32 priority;
@@ -224,46 +225,72 @@ private:
Common::Array<UpdateItem> _updateList;
- /** .text:0040B5B0
- * Loop through the various update blocks (actors,
- * objects, mouse, music, sfx, screenPosition), then
- * process the current action script
+ //////////////////////////////////////////////////////////////////////////
+ // Message handling
+ void activate();
+ bool init();
+ void update();
+ bool music();
+ bool key(const AsylumEvent &evt);
+ bool click(const AsylumEvent &evt);
+
+ void updateScreen();
+
+ //////////////////////////////////////////////////////////////////////////
+ // Scene update
+ //////////////////////////////////////////////////////////////////////////
+
+ /**
+ * Loop through the various update blocks (actors, objects, mouse, music, sfx, coordinates), then process the current action script.
+ *
+ * @return true if the script is done executing, false otherwise
*/
- bool update();
- /** .text:0040D190
- * TODO add description
+ bool updateScene();
+
+ /**
+ * Updates the mouse.
*/
void updateMouse();
- /** .text:0040D580
- * TODO
- */
- void handleMouseUpdate(int direction, Common::Rect rect);
+ /**
+ * Updates the actors.
+ */
void updateActors();
- /** .text:0040CBD0
- * TODO add description
+ /**
+ * Updates the objects.
*/
void updateObjects();
- /** .text:00409BA0
- * TODO add description
+
+ /**
+ * Updates the ambient sounds.
*/
void updateAmbientSounds();
- /** .text:00409EF0
- * TODO add description
+
+ /**
+ * Updates the music.
*/
void updateMusic();
- /** .text:0040DAE0
- * TODO add description
+
+ /**
+ * Updates the screen
+ *
+ * - update coordinates or allow scrolling if the proper debug option is set
*/
void updateAdjustScreen();
- void updateScreen();
-
-
-
- void playIntroSpeech();
+ /**
+ * Updates the screen coordinates.
+ */
+ void updateCoordinates();
+ /**
+ * Update cursor
+ *
+ * @param direction The direction.
+ * @param rect The rectangle.
+ */
+ void updateCursor(int direction, Common::Rect rect);
//////////////////////////////////////////////////////////////////////////
// Scene drawing
@@ -280,21 +307,20 @@ private:
//////////////////////////////////////////////////////////////////////////
// Helpers
//////////////////////////////////////////////////////////////////////////
+ void playIntroSpeech();
+
bool pointIntersectsRect(Common::Point point, Common::Rect rect);
//////////////////////////////////////////////////////////////////////////
// Scene debugging
//////////////////////////////////////////////////////////////////////////
- void copyToBackBufferClipped(Graphics::Surface *surface, int x, int y);
-
- void debugScreenScrolling(GraphicFrame *bg);
+ void debugScreenScrolling();
void debugShowPolygons();
void debugShowObjects();
void debugShowActors();
void debugShowWalkRegion(PolyDefinitions *poly);
friend class SceneTitle;
-
};
} // end of namespace Asylum
Commit: 814ac99ac421821cc4135b319e62667c25c8ecc2
https://github.com/scummvm/scummvm/commit/814ac99ac421821cc4135b319e62667c25c8ecc2
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:28+02:00
Commit Message:
ASYLUM: Update scene event handling and preload
- Implement Scene init and activate events
- Add stubs for other events
- Update SceneTitle to use proper resource ids and draw methods
- Remove some unused variables from Scene class
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@611 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/asylum.cpp
engines/asylum/eventhandler.h
engines/asylum/puzzles/vcr.cpp
engines/asylum/resources/actor.cpp
engines/asylum/resources/data.h
engines/asylum/resources/encounters.h
engines/asylum/resources/worldstats.cpp
engines/asylum/system/screen.cpp
engines/asylum/views/scene.cpp
engines/asylum/views/scene.h
engines/asylum/views/scenetitle.cpp
engines/asylum/views/scenetitle.h
diff --git a/engines/asylum/asylum.cpp b/engines/asylum/asylum.cpp
index ea09bf0b8d..f0b1f9b81c 100644
--- a/engines/asylum/asylum.cpp
+++ b/engines/asylum/asylum.cpp
@@ -176,8 +176,8 @@ void AsylumEngine::startGame(ResourcePackId sceneId, StartGameType type) {
error("[AsylumEngine::startGame] Invalid start game type!");
case kStartGamePlayIntro:
- playIntro();
_scene->enter(sceneId);
+ playIntro();
break;
case kStartGameLoad:
@@ -226,13 +226,16 @@ void AsylumEngine::playIntro() {
if (!_introPlayed) {
_cursor->hide();
- if (Config.showIntro) {
+ if (!Config.showIntro) {
+ if (_scene->worldstats()->chapter == kChapter1)
+ _sound->playMusic(MAKE_RESOURCE(kResourcePackMusic, _scene->worldstats()->musicCurrentResourceIndex));
+ } else {
_sound->playMusic(kResourceNone, 0);
// TODO convert to new event handling
_video->playVideo(1);
- if (_scene && _scene->worldstats()->musicCurrentResourceIndex != kMusicStopped)
+ if (_scene->worldstats()->musicCurrentResourceIndex != kMusicStopped)
_sound->playMusic(MAKE_RESOURCE(kResourcePackMusic, _scene->worldstats()->musicCurrentResourceIndex));
_screen->clear();
diff --git a/engines/asylum/eventhandler.h b/engines/asylum/eventhandler.h
index 95c18a2bc7..bdd0adb2f8 100644
--- a/engines/asylum/eventhandler.h
+++ b/engines/asylum/eventhandler.h
@@ -37,6 +37,7 @@ enum AsylumEventType {
EVENT_ASYLUM_UPDATE = 0xFFF2,
EVENT_ASYLUM_MUSIC = 0xFFF3,
EVENT_ASYLUM_MIDI = 0xFFF4,
+ EVENT_ASYLUM_ACTIVATE = 0xFFF5,
EVENT_ASYLUM_CHANGECD = 0xFFFE
};
diff --git a/engines/asylum/puzzles/vcr.cpp b/engines/asylum/puzzles/vcr.cpp
index 80b49a3e76..44a003a1b6 100644
--- a/engines/asylum/puzzles/vcr.cpp
+++ b/engines/asylum/puzzles/vcr.cpp
@@ -58,7 +58,6 @@ BlowUpPuzzleVCR::~BlowUpPuzzleVCR() {
void BlowUpPuzzleVCR::open() {
_active = true;
- //getScene()->deactivate();
getSound()->stopAll();
@@ -79,7 +78,7 @@ void BlowUpPuzzleVCR::open() {
void BlowUpPuzzleVCR::close() {
_active = false;
- //getScene()->activate();
+ // TODO Switch back to scene event handler
}
bool BlowUpPuzzleVCR::handleEvent(const AsylumEvent &ev) {
diff --git a/engines/asylum/resources/actor.cpp b/engines/asylum/resources/actor.cpp
index 8bdef3b5ce..12a6ed4b27 100644
--- a/engines/asylum/resources/actor.cpp
+++ b/engines/asylum/resources/actor.cpp
@@ -632,7 +632,7 @@ void Actor::updateStatus(ActorStatus actorStatus) {
}
if (_index == 11)
- _resourceId = _graphicResourceIds[getScene()->getGlobalDirection() > 4 ? 8 - getScene()->getGlobalDirection() : getScene()->getGlobalDirection()];
+ _resourceId = _graphicResourceIds[getSharedData()->getGlobalDirection() > 4 ? 8 - getSharedData()->getGlobalDirection() : getSharedData()->getGlobalDirection()];
// Reload the graphic resource if the resource ID has changed
if (resource->getResourceId() != _resourceId)
diff --git a/engines/asylum/resources/data.h b/engines/asylum/resources/data.h
index 64c0e32756..42c3622e71 100644
--- a/engines/asylum/resources/data.h
+++ b/engines/asylum/resources/data.h
@@ -38,6 +38,7 @@ namespace Asylum {
enum GlobalFlag {
kFlag1,
kFlag2,
+ kFlag3,
kFlagRedraw,
kFlagSkipDrawScene,
kFlagSceneRectChanged,
@@ -137,6 +138,7 @@ public:
memset(&_movies[49], 0, sizeof(_movies));
_actorUpdateStatus15Check = false;
_flag2 = false;
+ _globalDirection = kDirectionN;
// Screen updates
_flagRedraw = false;
@@ -152,6 +154,8 @@ public:
bool getActorUpdateEnabledCheck() { return _actorUpdateEnabledCheck; }
+ ActorDirection getGlobalDirection() { return _globalDirection; }
+
void setActorUpdateFlag(int32 val) { _data1[40] = 2; }
int32 getUpdateCounter() { return _actorUpdateCounter; }
@@ -247,6 +251,9 @@ public:
case kFlag2:
return _flag2;
+ case kFlag3:
+ return _flag3;
+
case kFlagRedraw:
return _flagRedraw;
break;
@@ -275,6 +282,10 @@ public:
_flag2 = state;
break;
+ case kFlag3:
+ _flag3 = state;
+ break;
+
case kFlagRedraw:
_flagRedraw = state;
break;
@@ -348,8 +359,11 @@ private:
int32 _movies[49];
bool _actorUpdateStatus15Check;
// Skip opening flag (not used)
+ bool _flag3;
bool _flag2;
+ ActorDirection _globalDirection;
+
// Screen updates
bool _flagRedraw;
diff --git a/engines/asylum/resources/encounters.h b/engines/asylum/resources/encounters.h
index e1f505ebc7..50e5b4d0d4 100644
--- a/engines/asylum/resources/encounters.h
+++ b/engines/asylum/resources/encounters.h
@@ -45,6 +45,10 @@ public:
bool handleEvent(const AsylumEvent &evt);
+ void setFlag1(bool state) { _flag1 = state; }
+ bool getFlag1() { return _flag1; }
+ void setFlag3(bool state) { _flag3 = state; }
+ bool getFlag3() { return _flag3; }
void setFlag5(bool state) { _flag5 = state; }
bool getFlag6() { return _flag6; }
diff --git a/engines/asylum/resources/worldstats.cpp b/engines/asylum/resources/worldstats.cpp
index e73e6f0966..dd41705d27 100644
--- a/engines/asylum/resources/worldstats.cpp
+++ b/engines/asylum/resources/worldstats.cpp
@@ -241,6 +241,7 @@ void WorldStats::load(Common::SeekableReadStream *stream) {
numPolygons = stream->readUint32LE();
// FIXME: Read missing data (64 int32)
+ warning("[WorldStats::load] Missing some data reading!");
for (int i = 0; i < 64; i++)
stream->readUint32LE();
@@ -249,6 +250,8 @@ void WorldStats::load(Common::SeekableReadStream *stream) {
for (uint32 a = 0; a < numActions; a++) {
ActionArea *action = new ActionArea();
action->load(stream);
+
+ actions.push_back(action);
}
stream->seek((ACTIONS_MAX_COUNT - numActions) * ACTIONS_SIZE, SEEK_CUR);
diff --git a/engines/asylum/system/screen.cpp b/engines/asylum/system/screen.cpp
index bf0867f61d..d42b218523 100644
--- a/engines/asylum/system/screen.cpp
+++ b/engines/asylum/system/screen.cpp
@@ -76,8 +76,8 @@ void Screen::draw(ResourceId resourceId, uint32 frameIndex, int32 x, int32 y, in
copyToBackBuffer(((byte *)frame->surface.pixels) - (y * frame->surface.w + x),
frame->surface.w,
- x,
- y,
+ frame->x + x,
+ frame->y + y,
frame->getWidth(),
frame->getHeight());
@@ -185,11 +185,11 @@ void Screen::clear() const {
}
void Screen::paletteFade(uint32 red, int32 milliseconds, int32 param) {
- error("[Screen::palFade] not implemented");
+ warning("[Screen::paletteFade] not implemented");
}
void Screen::startPaletteFade(ResourceId resourceId, int32 milliseconds, int32 param) {
- error("[Screen::startPaletteFade] not implemented");
+ warning("[Screen::startPaletteFade] not implemented");
}
void Screen::addGraphicToQueue(ResourceId resourceId, uint32 frameIndex, Common::Point point, int32 flags, int32 transTableNum, int32 priority) {
diff --git a/engines/asylum/views/scene.cpp b/engines/asylum/views/scene.cpp
index 2f16f32ebf..2c9d0329eb 100644
--- a/engines/asylum/views/scene.cpp
+++ b/engines/asylum/views/scene.cpp
@@ -58,17 +58,19 @@ int g_debugObjects;
int g_debugScrolling;
Scene::Scene(AsylumEngine *engine): _vm(engine),
- _actions(NULL), _special(NULL), _speech(NULL), _title(NULL), _polygons(NULL), _ws(NULL) {
+ _actions(NULL), _special(NULL), _speech(NULL), _polygons(NULL), _ws(NULL) {
// Initialize data
_packId = kResourcePackInvalid;
_playerActorIdx = 0;
- _titleLoaded = false;
_walking = false;
- _leftClick = false;
- _rightButton = false;
- _isActive = false;
- _globalDirection = kDirectionN;
+
+ g_debugPolygons = 0;
+ g_debugObjects = 0;
+ g_debugScrolling = 0;
+
+ _special = new Special(_vm);
+ _speech = new Speech(_vm);
}
Scene::~Scene() {
@@ -78,7 +80,6 @@ Scene::~Scene() {
delete _actions;
delete _special;
delete _speech;
- delete _title;
delete _polygons;
delete _ws;
@@ -169,6 +170,9 @@ void Scene::enter(ResourcePackId packId) {
// Setup font
getText()->loadFont(_ws->font1);
+ // Preload graphics (we are just showing the loading screen
+ preload();
+
// Play scene intro dialog
playIntroSpeech();
@@ -229,36 +233,13 @@ void Scene::load(ResourcePackId packId) {
fd->close();
delete fd;
- _speech = new Speech(_vm);
-
- // TODO
- // This will have to be re-initialized elsewhere due to
- // the title screen overwriting the font
- _vm->text()->loadFont(_ws->font1);
-
- _leftClick = false;
- _rightButton = false;
- _isActive = false;
- //_skipDrawScene = false;
-
- g_debugPolygons = 0;
- g_debugObjects = 0;
- g_debugScrolling = 0;
-
- //_globalX = _globalY = 0;
-
// TODO figure out what field_120 is used for
_ws->field_120 = -1;
for (uint32 a = 0; a < _ws->actors.size(); a++)
_ws->actors[a]->setLastScreenUpdate(_vm->getTick());
- // TODO: init action list
-
- _title = new SceneTitle(_vm);
- _titleLoaded = false;
-
- _special = new Special(_vm);
+ getCursor()->show();
}
Actor* Scene::getActor(ActorIndex index) {
@@ -302,106 +283,124 @@ Actor* Scene::getActor(ActorIndex index) {
// *targetY = bg->surface.h - 480;
//}
-
+//////////////////////////////////////////////////////////////////////////
+// Event handling
+//////////////////////////////////////////////////////////////////////////
bool Scene::handleEvent(const AsylumEvent &evt) {
- // TODO replace previous handleEvent method
+ switch ((uint32)evt.type) {
+ default:
+ break;
- if (!_ws)
- error("[Scene::handleEvent] WorldStats not initialized properly!");
+ case EVENT_ASYLUM_INIT:
+ return init();
- if (!_title)
- error("[Scene::handleEvent] Scene title not initialized properly!");
+ case EVENT_ASYLUM_ACTIVATE:
+ activate();
+ break;
- switch (evt.type) {
+ case EVENT_ASYLUM_UPDATE:
+ return update();
- case Common::EVENT_MOUSEMOVE:
- //if (getCursor())
- //getCursor()->move(_ev->mouse.x, _ev->mouse.y);
- break;
+ case Common::EVENT_KEYDOWN:
+ return key(evt);
- case Common::EVENT_LBUTTONUP:
- //if (_actions->doesAllowInput())
- _leftClick = true;
- break;
+ case Common::EVENT_LBUTTONDOWN:
+ case Common::EVENT_RBUTTONDOWN:
+ return clickDown(evt);
+ case Common::EVENT_LBUTTONUP:
case Common::EVENT_RBUTTONUP:
- //if (_actions->doesAllowInput()) {
- // TODO This isn't always going to be the magnifying glass
- // Should check the current pointer region to identify the type
- // of cursor to use
- getCursor()->set(_ws->curMagnifyingGlass);
- _rightButton = false;
- //}
- break;
+ return clickUp(evt);
+ }
- case Common::EVENT_RBUTTONDOWN:
- //if (_actions->doesAllowInput())
- _rightButton = true;
- break;
+ return false;
+}
- default:
- break;
+ //if (_speech->getSoundResourceId() != 0) {
+ // if (_vm->sound()->isPlaying(_speech->getSoundResourceId())) {
+ // _speech->prepareSpeech();
+ // } else {
+ // _speech->resetResourceIds();
+ // _vm->clearGameFlag(kGameFlag219);
+ // }
+ //}
- }
+void Scene::activate() {
+ Actor *player = getActor();
- // FIXME just updating because a left click event
- // is caught causes animation speeds to change. This needs
- // to be addressed
- /*if (!doUpdate)
- return;*/
-
- if (Config.showSceneLoading) {
- if (!_titleLoaded) {
- _title->update(_vm->getTick());
- if (_title->loadingComplete()) {
- _titleLoaded = true;
- activate();
- }
- return true;
- }
- }
+ if (player->getStatus() == kActorStatus1)
+ player->updateStatus(kActorStatusEnabled);
- if (updateScene())
+ if (player->getStatus() == kActorStatus12)
+ player->updateStatus(kActorStatus14);
+}
+
+bool Scene::init() {
+ if (getSharedData()->getFlag((kFlag3))) { // this flag is set during an encounter
+ getSharedData()->setFlag(kFlag3, false);
+
+ // The original test for flag 1001 but doesn't use the result
return true;
+ }
- // TODO: check game quality
- drawScene();
+ getCursor()->set(_ws->curScrollUp);
+ _ws->coordinates[0] = -1;
+ getScreen()->clear();
+ getText()->loadFont(_ws->font1);
- //TODO: other process stuffs from sub 0040AE30
+ ResourceId paletteResource = _ws->actions[getActor()->getActionIndex3()]->paletteResourceId;
+ if (!paletteResource)
+ paletteResource = _ws->currentPaletteId;
+ getScreen()->setPalette(paletteResource);
+ getScreen()->setGammaLevel(paletteResource, 0);
+ makeGreyPalette();
+ getScreen()->setupTransTables(3, _ws->cellShadeMask1, _ws->cellShadeMask2, _ws->cellShadeMask3);
+ getScreen()->selectTransTable(1);
- if (_speech->getSoundResourceId() != 0) {
- if (_vm->sound()->isPlaying(_speech->getSoundResourceId())) {
- _speech->prepareSpeech();
- } else {
- _speech->resetResourceIds();
- _vm->clearGameFlag(kGameFlag219);
- }
- }
+ getCursor()->show();
return true;
}
-void Scene::update() {
+bool Scene::update() {
+ if (getEncounter()->getFlag1()) {
+ getEncounter()->setFlag1(false);
+
+ // Enable player
+ getActor()->updateStatus(kActorStatusEnabled);
+ }
+
+ error("[Scene::update] Not implemented!");
+ return true;
}
-void Scene::activate() {
- //if (!_ws)
- // error("[Scene::activate] WorldStats not initialized properly!");
+bool Scene::key(const AsylumEvent &evt) {
+ error("[Scene::key] Not implemented!");
+}
- //if (!_bgResource)
- // error("[Scene::activate] Scene resources not initialized properly!");
+bool Scene::clickDown(const AsylumEvent &evt) {
+ _vm->lastScreenUpdate = 0;
- ////////////////////////////////////////////////////////////////////////////
- //// FIXME: get rid of this?
+ if (getSharedData()->getFlag(kFlag2)) {
+ error("[Scene::clickDown] Not implemented!");
+
+ return true;
+ }
- //_isActive = true;
- //getScreen()->setPalette(_ws->currentPaletteId);
- // FIXME this corrupts memory (the copyToBackBuffer function is broken)
- //getScreen()->draw(_ws->backgroundImage, 0, _ws->xLeft, _ws->yTop, 0);
+ error("[Scene::clickDown] Not implemented!");
}
+bool Scene::clickUp(const AsylumEvent &evt) {
+ _vm->lastScreenUpdate = _vm->screenUpdateCount;
+
+ error("[Scene::clickRightUp] Not implemented!");
+}
+
+//////////////////////////////////////////////////////////////////////////
+// Scene update
+//////////////////////////////////////////////////////////////////////////
bool Scene::updateScene() {
#ifdef DEBUG_SCENE_TIMES
#define MESURE_TICKS(func) { \
@@ -1122,6 +1121,30 @@ bool Scene::updateSceneCoordinates(int32 tX, int32 tY, int32 A0, bool checkScene
//////////////////////////////////////////////////////////////////////////
// Scene drawing
//////////////////////////////////////////////////////////////////////////
+void Scene::preload() {
+ if (!Config.showSceneLoading)
+ return;
+
+ SceneTitle *title = new SceneTitle(_vm);
+ title->load();
+
+ do {
+ title->update(_vm->getTick());
+
+ getScreen()->copyBackBufferToScreen();
+ g_system->updateScreen();
+
+ g_system->delayMillis(10);
+
+ // Poll events (this ensure we don't freeze the screen)
+ Common::Event ev;
+ _vm->getEventManager()->pollEvent(ev);
+
+ } while (!title->loadingComplete());
+
+ delete title;
+}
+
int Scene::drawScene() {
if (!_ws)
error("[Scene::drawScene] WorldStats not initialized properly!");
@@ -1496,11 +1519,13 @@ int Scene::processActor(int *x, int *param) {
}
void Scene::updatePalette(int32 param) {
+ // TODO write small helper macro to get the resource id and move rest to screen class
error("[Scene::updatePalette] not implemented!");
}
void Scene::makeGreyPalette() {
- error("[Scene::makeGreyPalette] not implemented!");
+ // TODO write small helper macro to get the resource id and move rest to screen class
+ warning("[Scene::makeGreyPalette] not implemented!");
}
void Scene::resetActor0() {
diff --git a/engines/asylum/views/scene.h b/engines/asylum/views/scene.h
index 7bbde8b9c6..660de3398f 100644
--- a/engines/asylum/views/scene.h
+++ b/engines/asylum/views/scene.h
@@ -145,8 +145,6 @@ public:
int32 calculateVolumeAdjustment(AmbientSoundItem *snd, Actor *act);
- ActorDirection getGlobalDirection() { return _globalDirection; }
-
bool updateSceneCoordinates(int32 targetX, int32 targetY, int32 val, bool checkSceneCoords = false, int32 *param = NULL);
int processActor(int *x, int *param);
@@ -203,18 +201,14 @@ private:
ResourcePackId _packId;
int32 _playerActorIdx;
- bool _titleLoaded;
bool _walking;
- bool _leftClick;
- bool _rightButton;
- bool _isActive;
+
+
ActorDirection _globalDirection;
ActionList *_actions;
- //BlowUpPuzzle *_blowUp;
Special *_special;
Speech *_speech;
- SceneTitle *_title;
Polygons *_polygons;
WorldStats *_ws;
@@ -229,10 +223,10 @@ private:
// Message handling
void activate();
bool init();
- void update();
- bool music();
+ bool update();
bool key(const AsylumEvent &evt);
- bool click(const AsylumEvent &evt);
+ bool clickDown(const AsylumEvent &evt);
+ bool clickUp(const AsylumEvent &evt);
void updateScreen();
@@ -295,6 +289,7 @@ private:
//////////////////////////////////////////////////////////////////////////
// Scene drawing
//////////////////////////////////////////////////////////////////////////
+ void preload(); // Draw the loading screen
int drawScene();
void buildUpdateList();
diff --git a/engines/asylum/views/scenetitle.cpp b/engines/asylum/views/scenetitle.cpp
index 12f1ecb57d..67b354768c 100644
--- a/engines/asylum/views/scenetitle.cpp
+++ b/engines/asylum/views/scenetitle.cpp
@@ -38,14 +38,11 @@
namespace Asylum {
-SceneTitle::SceneTitle(AsylumEngine *engine): _vm(engine), _bg(NULL), _progress(NULL),
- _start(0), _ticks(0), _done(false), _spinnerFrame(0), _spinnerProgress(0), _showMouseState(false) {
+SceneTitle::SceneTitle(AsylumEngine *engine): _vm(engine),
+ _start(0), _ticks(0), _done(false), _spinnerFrameIndex(0), _spinnerProgress(0), _showMouseState(false) {
}
SceneTitle::~SceneTitle() {
- delete _bg;
- delete _progress;
-
// Zero passed pointers
_vm = NULL;
}
@@ -53,22 +50,29 @@ SceneTitle::~SceneTitle() {
void SceneTitle::load() {
_start = _vm->getTick();
- _bg = new GraphicResource(_vm, getWorld()->sceneTitleGraphicResourceId);
+ getScreen()->clear();
getScreen()->setPalette(getWorld()->sceneTitlePaletteResourceId);
-
- _progress = new GraphicResource(_vm, MAKE_RESOURCE(kResourcePackSound, 17));
- _spinnerProgress = 0;
- _spinnerFrame = 0;
+ getScreen()->paletteFade(0, 1, 1);
+ getScreen()->setGammaLevel(getWorld()->sceneTitlePaletteResourceId, 0);
getText()->loadFont(MAKE_RESOURCE(kResourcePackSound, 18));
+ _spinnerProgress = 0;
+ _spinnerFrameIndex = 0;
+ _spinnerFrameCount = GraphicResource::getFrameCount(_vm, MAKE_RESOURCE(kResourcePackSound, 17));
+
_done = false;
- _showMouseState = g_system->showMouse(false);
+
+ update(_start);
}
void SceneTitle::update(int32 tick) {
- if (!_progress || !_bg)
- error("[SceneTitle::update] SceneTitle resources not initialized properly!");
+ if (_done)
+ return;
+
+ getScreen()->draw(getWorld()->sceneTitleGraphicResourceId, 0, 0, 0, 0, false);
+ getScreen()->draw(MAKE_RESOURCE(kResourcePackSound, 17), _spinnerFrameIndex, (_spinnerProgress/590 * 580) - 290 , 0, 0, false);
+ getText()->drawCentered(320, 30, 24, MAKE_RESOURCE(kResourcePackText, 1811 + getWorld()->chapter));
// This is not from the original. It's just some arbitrary math to throttle the progress indicator.
//
@@ -79,29 +83,15 @@ void SceneTitle::update(int32 tick) {
if ((tick - _start) % 500 > 100)
_spinnerProgress += 20;
- getScreen()->draw(getWorld()->sceneTitleGraphicResourceId, 0, 0, 0, 0);
-
- ResourceId resourceId = MAKE_RESOURCE(getScene()->getPackId(), 1797);
- int32 resWidth = getText()->getWidth(resourceId);
- getText()->drawCentered(320 - resWidth * 24, 30, resWidth, resourceId);
-
- GraphicFrame *frame = _progress->getFrame(_spinnerFrame);
+ _spinnerFrameIndex++;
- getScreen()->copyToBackBufferWithTransparency(((byte*)frame->surface.pixels),
- frame->surface.w,
- frame->x + (_spinnerProgress - 290),
- frame->y,
- frame->surface.w,
- frame->surface.h);
-
- _spinnerFrame++;
-
- if (_spinnerFrame > _progress->count() - 1)
- _spinnerFrame = 0;
+ if (_spinnerFrameIndex > _spinnerFrameCount - 1)
+ _spinnerFrameIndex = 0;
if (_spinnerProgress > 590) {
_done = true;
- g_system->showMouse(_showMouseState);
+
+ getScreen()->paletteFade(0, 5, 80);
}
}
diff --git a/engines/asylum/views/scenetitle.h b/engines/asylum/views/scenetitle.h
index 4ef38e8c0a..9d8d2db0a9 100644
--- a/engines/asylum/views/scenetitle.h
+++ b/engines/asylum/views/scenetitle.h
@@ -46,16 +46,13 @@ public:
private:
AsylumEngine *_vm;
- GraphicResource *_bg;
- GraphicResource *_progress;
-
int32 _start;
int32 _ticks;
bool _done;
- uint32 _spinnerFrame;
+ uint32 _spinnerFrameIndex;
int32 _spinnerProgress;
+ uint32 _spinnerFrameCount;
bool _showMouseState;
-
};
} // End of namespace Asylum
Commit: fbe5ee06140a1b560a88aaffc2327bd0782429fb
https://github.com/scummvm/scummvm/commit/fbe5ee06140a1b560a88aaffc2327bd0782429fb
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:29+02:00
Commit Message:
ASYLUM: Fix SceneTitle spinner not moving
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@612 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/views/scenetitle.cpp
diff --git a/engines/asylum/views/scenetitle.cpp b/engines/asylum/views/scenetitle.cpp
index 67b354768c..015a65ccc5 100644
--- a/engines/asylum/views/scenetitle.cpp
+++ b/engines/asylum/views/scenetitle.cpp
@@ -71,7 +71,7 @@ void SceneTitle::update(int32 tick) {
return;
getScreen()->draw(getWorld()->sceneTitleGraphicResourceId, 0, 0, 0, 0, false);
- getScreen()->draw(MAKE_RESOURCE(kResourcePackSound, 17), _spinnerFrameIndex, (_spinnerProgress/590 * 580) - 290 , 0, 0, false);
+ getScreen()->draw(MAKE_RESOURCE(kResourcePackSound, 17), _spinnerFrameIndex, (_spinnerProgress / 590.0 * 580) - 290 , 0, 0, false);
getText()->drawCentered(320, 30, 24, MAKE_RESOURCE(kResourcePackText, 1811 + getWorld()->chapter));
// This is not from the original. It's just some arbitrary math to throttle the progress indicator.
@@ -81,7 +81,7 @@ void SceneTitle::update(int32 tick) {
// but load on demand from offset/length within a ResourcePack, the progress indicator is effectively
// useless. It's just in here as "eye candy" :P
if ((tick - _start) % 500 > 100)
- _spinnerProgress += 20;
+ _spinnerProgress += 5;
_spinnerFrameIndex++;
Commit: 818f2415307d63168a5d5b9db997cc12b6704636
https://github.com/scummvm/scummvm/commit/818f2415307d63168a5d5b9db997cc12b6704636
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:29+02:00
Commit Message:
ASYLUM: Implement Scene::update(). Scene now draw again!
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@613 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/resources/actor.cpp
engines/asylum/resources/actor.h
engines/asylum/resources/data.h
engines/asylum/shared.h
engines/asylum/views/scene.cpp
engines/asylum/views/scene.h
diff --git a/engines/asylum/resources/actor.cpp b/engines/asylum/resources/actor.cpp
index 12a6ed4b27..f3e060082b 100644
--- a/engines/asylum/resources/actor.cpp
+++ b/engines/asylum/resources/actor.cpp
@@ -36,6 +36,7 @@
#include "asylum/system/graphics.h"
#include "asylum/system/screen.h"
#include "asylum/system/speech.h"
+#include "asylum/system/text.h"
#include "asylum/views/scene.h"
@@ -264,6 +265,14 @@ void Actor::draw() {
}
}
+void Actor::drawNumber() {
+ if (!_numberFlag01)
+ return;
+
+ getText()->loadFont(getWorld()->font1);
+ getText()->drawCentered(_numberStringX, _numberStringY, _numberStringWidth, (char *)&_numberString01);
+}
+
void Actor::update() {
if (!isVisible())
return;
diff --git a/engines/asylum/resources/actor.h b/engines/asylum/resources/actor.h
index 8f6f87e20e..463fcb9dcb 100644
--- a/engines/asylum/resources/actor.h
+++ b/engines/asylum/resources/actor.h
@@ -149,6 +149,11 @@ public:
*/
void draw();
+ /**
+ * Draw number text (called on scene drawing)
+ */
+ void drawNumber();
+
/**
* Updates the actor.
*/
diff --git a/engines/asylum/resources/data.h b/engines/asylum/resources/data.h
index 42c3622e71..bea7942459 100644
--- a/engines/asylum/resources/data.h
+++ b/engines/asylum/resources/data.h
@@ -197,21 +197,19 @@ public:
void setData(ActorIndex index, int32 val) {
if (index < 50)
_data1[index] = val;
-
- if (index < 60)
+ else if (index < 60)
_data2[index - 50] = val;
-
+ else
error("[SharedData::setData] index is outside valid values (was: %d, valid: [0:60]", index);
}
int32 getData(ActorIndex index) {
if (index < 50)
return _data1[index];
-
- if (index < 60)
+ else if (index < 60)
return _data2[index - 50];
-
- error("[SharedData::getData] index is outside valid values (was: %d, valid: [0:60]", index);
+ else
+ error("[SharedData::getData] index is outside valid values (was: %d, valid: [0:60]", index);
}
void setData2(ActorIndex index, bool val) {
diff --git a/engines/asylum/shared.h b/engines/asylum/shared.h
index e6e7b18af5..312af64172 100644
--- a/engines/asylum/shared.h
+++ b/engines/asylum/shared.h
@@ -48,6 +48,7 @@ enum GameFlag {
kGameFlag246 = 246,
kGameFlag247 = 247,
kGameFlag248 = 248,
+ kGameFlag249 = 249,
kGameFlag263 = 263,
kGameFlag262 = 262,
kGameFlag264 = 264,
diff --git a/engines/asylum/views/scene.cpp b/engines/asylum/views/scene.cpp
index 2c9d0329eb..b81337a7aa 100644
--- a/engines/asylum/views/scene.cpp
+++ b/engines/asylum/views/scene.cpp
@@ -316,15 +316,6 @@ bool Scene::handleEvent(const AsylumEvent &evt) {
return false;
}
- //if (_speech->getSoundResourceId() != 0) {
- // if (_vm->sound()->isPlaying(_speech->getSoundResourceId())) {
- // _speech->prepareSpeech();
- // } else {
- // _speech->resetResourceIds();
- // _vm->clearGameFlag(kGameFlag219);
- // }
- //}
-
void Scene::activate() {
Actor *player = getActor();
@@ -371,7 +362,30 @@ bool Scene::update() {
getActor()->updateStatus(kActorStatusEnabled);
}
- error("[Scene::update] Not implemented!");
+ uint32 ticks = _vm->getTick();
+
+ if (!getSharedData()->getFlag(kFlagRedraw)) {
+ if (updateScreen())
+ return true;
+
+ getSharedData()->setFlag(kFlagRedraw, true);
+ }
+
+ if (ticks > getSharedData()->getNextScreenUpdate()) {
+ if (getSharedData()->getFlag(kFlagRedraw)) {
+ if (getSharedData()->getMatteBarHeight() <= 0)
+ getScreen()->copyBackBufferToScreen();
+ else
+ error("[Scene::update] Not implemented!");
+
+ // Original also sets an unused value to 0
+ getSharedData()->setData(39, getSharedData()->getData(39) ^ 1);
+
+ getSharedData()->setFlag(kFlagRedraw, false);
+ getSharedData()->setNextScreenUpdate(ticks + 55);
+ ++_vm->screenUpdateCount;
+ }
+ }
return true;
}
@@ -401,6 +415,63 @@ bool Scene::clickUp(const AsylumEvent &evt) {
//////////////////////////////////////////////////////////////////////////
// Scene update
//////////////////////////////////////////////////////////////////////////
+bool Scene::updateScreen() {
+ // Original has a frame counter (for showing fps)
+
+ if (updateScene())
+ return true;
+
+ if (Config.performance <= 4) {
+ // TODO when Config.performance <= 4, we need to skip drawing frames to screen
+
+ if (drawScene())
+ return true;
+
+ } else {
+ if (drawScene())
+ return true;
+ }
+
+ getActor()->drawNumber();
+
+ // Original handle all debug commands here (we do it as part of each update command)
+
+ if (getSharedData()->getFlag(kFlagScene1)) {
+ getScreen()->clear();
+
+ //getScreen()->paletteSetupAndStartFade(0, 0, 0);
+ //updateScene();
+ //drawScene();
+ // refresh screen
+ //getScreen->paletteStopAndFade(getWorld()->currentPaletteId, 100, 10);
+ //drawScene();
+ // refresh screen
+
+ warning("[Scene::updateScreen] Not implemented!");
+
+
+ getSharedData()->setFlag(kFlagScene1, false);
+ }
+
+ if (getSpeech()->getSoundResourceId() != 0) {
+ if (getSound()->isPlaying(_speech->getSoundResourceId())) {
+ getSpeech()->prepareSpeech();
+ } else {
+ getSpeech()->resetResourceIds();
+ _vm->clearGameFlag(kGameFlag219);
+ }
+ }
+
+ if (getWorld()->chapter == kChapter5) {
+ if (_vm->isGameFlagSet(kGameFlag249))
+ error("[Scene::updateScreen] Not implemented!");
+ //drawSceneData;
+ }
+
+ return false;
+}
+
+
bool Scene::updateScene() {
#ifdef DEBUG_SCENE_TIMES
#define MESURE_TICKS(func) { \
@@ -1145,7 +1216,7 @@ void Scene::preload() {
delete title;
}
-int Scene::drawScene() {
+bool Scene::drawScene() {
if (!_ws)
error("[Scene::drawScene] WorldStats not initialized properly!");
@@ -1153,34 +1224,35 @@ int Scene::drawScene() {
if (getSharedData()->getFlag(kFlagRedraw)) {
_vm->screen()->clear();
- } else {
- // Draw scene background
- _vm->screen()->draw(_ws->backgroundImage, 0, -_ws->xLeft, -_ws->yTop, 0);
+ return false;
+ }
- // Draw actors on the update list
- buildUpdateList();
- processUpdateList();
+ // Draw scene background
+ getScreen()->draw(_ws->backgroundImage, 0, -_ws->xLeft, -_ws->yTop, 0, false);
- if (_ws->chapter == kChapter11)
- checkVisibleActorsPriority();
+ // Draw actors on the update list
+ buildUpdateList();
+ processUpdateList();
- // Queue updates
- for (uint32 i = 0; i < _ws->actors.size(); i++)
- _ws->actors[i]->draw();
+ if (_ws->chapter == kChapter11)
+ checkVisibleActorsPriority();
- for (uint32 i = 0; i < _ws->objects.size(); i++)
- _ws->objects[i]->draw();
+ // Queue updates
+ for (uint32 i = 0; i < _ws->actors.size(); i++)
+ _ws->actors[i]->draw();
- Actor *player = getActor();
- if (player->getStatus() == kActorStatus6 || player->getStatus() == kActorStatus10)
- player->updateAndDraw();
- else
- player->setNumberFlag01(0);
+ for (uint32 i = 0; i < _ws->objects.size(); i++)
+ _ws->objects[i]->draw();
- _vm->screen()->drawGraphicsInQueue();
- }
+ Actor *player = getActor();
+ if (player->getStatus() == kActorStatus6 || player->getStatus() == kActorStatus10)
+ player->updateAndDraw();
+ else
+ player->setNumberFlag01(0);
+
+ _vm->screen()->drawGraphicsInQueue();
- return 1;
+ return false;
}
bool Scene::updateListCompare(const UpdateItem &item1, const UpdateItem &item2) {
diff --git a/engines/asylum/views/scene.h b/engines/asylum/views/scene.h
index 660de3398f..9b654b4b12 100644
--- a/engines/asylum/views/scene.h
+++ b/engines/asylum/views/scene.h
@@ -228,12 +228,17 @@ private:
bool clickDown(const AsylumEvent &evt);
bool clickUp(const AsylumEvent &evt);
- void updateScreen();
-
//////////////////////////////////////////////////////////////////////////
// Scene update
//////////////////////////////////////////////////////////////////////////
+ /**
+ * Updates the screen
+ *
+ * @return true if it succeeds, false if it fails.
+ */
+ bool updateScreen();
+
/**
* Loop through the various update blocks (actors, objects, mouse, music, sfx, coordinates), then process the current action script.
*
@@ -290,7 +295,7 @@ private:
// Scene drawing
//////////////////////////////////////////////////////////////////////////
void preload(); // Draw the loading screen
- int drawScene();
+ bool drawScene();
void buildUpdateList();
void processUpdateList();
Commit: 15421b6b79267d62d55038c0848b61108e35ff28
https://github.com/scummvm/scummvm/commit/15421b6b79267d62d55038c0848b61108e35ff28
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:29+02:00
Commit Message:
ASYLUM: Fix GCC warnings in Menu
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@614 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/views/menu.cpp
diff --git a/engines/asylum/views/menu.cpp b/engines/asylum/views/menu.cpp
index fc192800fe..a46e0bcdc1 100644
--- a/engines/asylum/views/menu.cpp
+++ b/engines/asylum/views/menu.cpp
@@ -279,7 +279,7 @@ void MainMenu::adjustTestVolume() {
void MainMenu::setupMusic() {
getSound()->stopAll();
- int32 index = getScene() ? getWorld()->musicCurrentResourceIndex : kMusicStopped;
+ uint32 index = getScene() ? getWorld()->musicCurrentResourceIndex : kMusicStopped;
if (index == kMusicStopped) {
_soundResourceId = kResourceNone;
@@ -297,7 +297,7 @@ void MainMenu::adjustPerformance() {
setupMusic();
- int32 index = getScene() ? getWorld()->musicCurrentResourceIndex : kMusicStopped;
+ uint32 index = getScene() ? getWorld()->musicCurrentResourceIndex : kMusicStopped;
if (index != kMusicStopped)
getSound()->playMusic(MAKE_RESOURCE(kResourcePackMusic, index));
}
@@ -938,7 +938,7 @@ void MainMenu::updateKeyboardConfig() {
getText()->loadFont(kFontYellow);
getText()->drawCentered(10, 100, 620, MAKE_RESOURCE(kResourcePackText, 1438));
- char key = 0;
+ char keyCode = 0;
int32 keyIndex = 0;
do {
@@ -954,27 +954,27 @@ void MainMenu::updateKeyboardConfig() {
break;
case 0:
- key = Config.keyShowVersion;
+ keyCode = Config.keyShowVersion;
break;
case 1:
- key = Config.keyQuickLoad;
+ keyCode = Config.keyQuickLoad;
break;
case 2:
- key = Config.keyQuickSave;
+ keyCode = Config.keyQuickSave;
break;
case 3:
- key = Config.keySwitchToSara;
+ keyCode = Config.keySwitchToSara;
break;
case 4:
- key = Config.keySwitchToGrimwall;
+ keyCode = Config.keySwitchToGrimwall;
break;
case 5:
- key = Config.keySwitchToOlmec;
+ keyCode = Config.keySwitchToOlmec;
break;
}
@@ -988,8 +988,8 @@ void MainMenu::updateKeyboardConfig() {
_dword_4562C0 = (_dword_4562C0 + 1) % 12;
} else {
- switchFont(getCursor()->isHidden() || cursor.x < 350 || cursor.x > (350 + getText()->getWidth(key)) || cursor.y < (29 * keyIndex + 150) || cursor.y > (29 * (keyIndex + 6)));
- getText()->drawChar(key);
+ switchFont(getCursor()->isHidden() || cursor.x < 350 || cursor.x > (350 + getText()->getWidth(keyCode)) || cursor.y < (29 * keyIndex + 150) || cursor.y > (29 * (keyIndex + 6)));
+ getText()->drawChar(keyCode);
}
++keyIndex;
@@ -1336,7 +1336,7 @@ void MainMenu::clickKeyboardConfig() {
if (cursor.x < 300 || cursor.x > (300 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 1446))) || cursor.y < 340 || cursor.y > (340 + 24)) {
int32 keyIndex = 0;
- char key = 0;
+ char keyCode = 0;
do {
switch (keyIndex) {
@@ -1344,31 +1344,31 @@ void MainMenu::clickKeyboardConfig() {
break;
case 0:
- key = Config.keyShowVersion;
+ keyCode = Config.keyShowVersion;
break;
case 1:
- key = Config.keyQuickLoad;
+ keyCode = Config.keyQuickLoad;
break;
case 2:
- key = Config.keyQuickSave;
+ keyCode = Config.keyQuickSave;
break;
case 3:
- key = Config.keySwitchToSara;
+ keyCode = Config.keySwitchToSara;
break;
case 4:
- key = Config.keySwitchToGrimwall;
+ keyCode = Config.keySwitchToGrimwall;
break;
case 5:
- key = Config.keySwitchToOlmec;
+ keyCode = Config.keySwitchToOlmec;
break;
}
- if (cursor.x >= 350 && cursor.x <= (350 + getText()->getWidth(key)) && cursor.y >= (29 * keyIndex + 150) && cursor.y <= (29 * (keyIndex + 6))) {
+ if (cursor.x >= 350 && cursor.x <= (350 + getText()->getWidth(keyCode)) && cursor.y >= (29 * keyIndex + 150) && cursor.y <= (29 * (keyIndex + 6))) {
_selectedShortcutIndex = keyIndex;
getCursor()->hide();
}
@@ -1421,33 +1421,33 @@ void MainMenu::keyKeyboardConfig(const AsylumEvent &evt) {
return;
}
- char *key = NULL;
+ char *keyCode = NULL;
switch(_selectedShortcutIndex) {
default:
break;
case 0:
- key = &Config.keyShowVersion;
+ keyCode = &Config.keyShowVersion;
break;
case 1:
- key = &Config.keyQuickLoad;
+ keyCode = &Config.keyQuickLoad;
break;
case 2:
- key = &Config.keyQuickSave;
+ keyCode = &Config.keyQuickSave;
break;
case 3:
- key = &Config.keySwitchToSara;
+ keyCode = &Config.keySwitchToSara;
break;
case 4:
- key = &Config.keySwitchToGrimwall;
+ keyCode = &Config.keySwitchToGrimwall;
break;
case 5:
- key = &Config.keySwitchToOlmec;
+ keyCode = &Config.keySwitchToOlmec;
break;
}
@@ -1455,8 +1455,8 @@ void MainMenu::keyKeyboardConfig(const AsylumEvent &evt) {
if (evt.kbd.ascii > 255 || !isalnum(evt.kbd.ascii))
return;
- if (!Config.isKeyAssigned(evt.kbd.ascii) || *key == evt.kbd.ascii) {
- *key = evt.kbd.ascii;
+ if (!Config.isKeyAssigned(evt.kbd.ascii) || *keyCode == evt.kbd.ascii) {
+ *keyCode = evt.kbd.ascii;
_selectedShortcutIndex = -1;
getCursor()->show();
}
Commit: 787546f83dfcebe5bb05a67aff1e530a2c16fb49
https://github.com/scummvm/scummvm/commit/787546f83dfcebe5bb05a67aff1e530a2c16fb49
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:29+02:00
Commit Message:
ASYLUM: Finish implementing Object::playSounds
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@615 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/resources/object.cpp
diff --git a/engines/asylum/resources/object.cpp b/engines/asylum/resources/object.cpp
index cf456cc154..1985050284 100644
--- a/engines/asylum/resources/object.cpp
+++ b/engines/asylum/resources/object.cpp
@@ -35,6 +35,7 @@
#include "asylum/views/scene.h"
#include "asylum/asylum.h"
+#include "asylum/respack.h"
namespace Asylum {
@@ -366,20 +367,18 @@ void Object::playSounds() {
soundX = _soundX;
soundY = _soundY;
} else {
- GraphicResource *resource = new GraphicResource(_vm, _resourceId);
-
if (LOBYTE(flags) & kObjectFlag4) {
- soundX = x + Common::Rational(resource->getFlags(), 2).toInt();
- soundY = y + Common::Rational(resource->getFlags2(), 2).toInt();
+ // Get object resource
+ ResourceEntry *resource = getResource()->get(_resourceId);
+
+ soundX = x + Common::Rational(resource->getData(1), 2).toInt();
+ soundY = y + Common::Rational(resource->getData(0), 2).toInt();
} else {
- // TODO _frameIndex here seems to be == _frameCount so something wrong somewhere!
- /*GraphicFrame *frame = resource->getFrame(_frameIndex);
+ Common::Rect rect = GraphicResource::getFrameRect(_vm, _resourceId, _frameIndex);
- soundX = x + (frame->getWidth() >> 1);
- soundY = x + (frame->getHeight() >> 1);*/
+ soundX = x + (rect.width() * 2);
+ soundY = x + (rect.height() * 2);
}
-
- delete resource;
}
for (int i = 0; i < ARRAYSIZE(_soundItems); i++) {
Commit: ee682f845893d7df9b4cdeaafdc4e4669c3e1c61
https://github.com/scummvm/scummvm/commit/ee682f845893d7df9b4cdeaafdc4e4669c3e1c61
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:29+02:00
Commit Message:
ASYLUM: Reduce SceneTitle progress total time
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@616 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/views/scenetitle.cpp
diff --git a/engines/asylum/views/scenetitle.cpp b/engines/asylum/views/scenetitle.cpp
index 015a65ccc5..f04ff56713 100644
--- a/engines/asylum/views/scenetitle.cpp
+++ b/engines/asylum/views/scenetitle.cpp
@@ -81,7 +81,7 @@ void SceneTitle::update(int32 tick) {
// but load on demand from offset/length within a ResourcePack, the progress indicator is effectively
// useless. It's just in here as "eye candy" :P
if ((tick - _start) % 500 > 100)
- _spinnerProgress += 5;
+ _spinnerProgress += 10;
_spinnerFrameIndex++;
Commit: e75170cc14d04543790425207483605d513522d8
https://github.com/scummvm/scummvm/commit/e75170cc14d04543790425207483605d513522d8
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:29+02:00
Commit Message:
ASYLUM: Implement proper blitting methods in Screen class
- Convert Text class to use Screen draw methods
- Update screen queue to use draw methods instead of direct copy
- Properly read additional graphic resource data
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@617 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/puzzles/vcr.cpp
engines/asylum/system/graphics.cpp
engines/asylum/system/graphics.h
engines/asylum/system/screen.cpp
engines/asylum/system/screen.h
engines/asylum/system/text.cpp
engines/asylum/system/video.cpp
engines/asylum/views/menu.cpp
diff --git a/engines/asylum/puzzles/vcr.cpp b/engines/asylum/puzzles/vcr.cpp
index 44a003a1b6..7add787192 100644
--- a/engines/asylum/puzzles/vcr.cpp
+++ b/engines/asylum/puzzles/vcr.cpp
@@ -180,7 +180,7 @@ GraphicQueueItem BlowUpPuzzleVCR::getGraphicJackItem(int32 index) {
jackItemOnHand.resourceId = getWorld()->graphicResourceIds[index];
jackItemOnHand.frameIndex = 0;
- jackItemOnHand.point = Common::Point(_cursor->position().x - 114, jackY - 14);
+ jackItemOnHand.source = Common::Point(_cursor->position().x - 114, jackY - 14);
jackItemOnHand.priority = 1;
return jackItemOnHand;
@@ -195,7 +195,7 @@ GraphicQueueItem BlowUpPuzzleVCR::getGraphicShadowItem() {
}
shadowItem.resourceId = getWorld()->graphicResourceIds[30];
shadowItem.frameIndex = 0;
- shadowItem.point = Common::Point(_cursor->position().x - shadowY, 450);
+ shadowItem.source = Common::Point(_cursor->position().x - shadowY, 450);
shadowItem.priority = 2;
return shadowItem;
@@ -208,28 +208,28 @@ void BlowUpPuzzleVCR::updateJack(Jack jack, const VCRDrawInfo &onTable, const VC
case kOnTable:
item.resourceId = getWorld()->graphicResourceIds[onTable.resourceId];
item.frameIndex = 0;
- item.point = onTable.point;
+ item.source = onTable.point;
item.priority = 3;
break;
case kPluggedOnRed:
item.resourceId = getWorld()->graphicResourceIds[pluggedOnRed.resourceId];
item.frameIndex = 0;
- item.point = Common::Point(329, 407);
+ item.source = Common::Point(329, 407);
item.priority = 3;
break;
case kPluggedOnYellow:
item.resourceId = getWorld()->graphicResourceIds[pluggedOnYellow.resourceId];
item.frameIndex = 0;
- item.point = Common::Point(402, 413);
+ item.source = Common::Point(402, 413);
item.priority = 3;
break;
case kPluggedOnBlack:
item.resourceId = getWorld()->graphicResourceIds[pluggedOnBlack.resourceId];
item.frameIndex = 0;
- item.point = Common::Point(477, 418);
+ item.source = Common::Point(477, 418);
item.priority = 3;
break;
@@ -327,14 +327,14 @@ void BlowUpPuzzleVCR::updateButton(Button button, const VCRDrawInfo &btON, const
case kON:
item.resourceId = getWorld()->graphicResourceIds[btON.resourceId];
item.frameIndex = 0;
- item.point = btON.point;
+ item.source = btON.point;
item.priority = 3;
break;
case kDownON:
case kDownOFF:
item.resourceId = getWorld()->graphicResourceIds[btDown.resourceId];
item.frameIndex = 0;
- item.point = btDown.point;
+ item.source = btDown.point;
item.priority = 3;
break;
default:
diff --git a/engines/asylum/system/graphics.cpp b/engines/asylum/system/graphics.cpp
index f82cdb16c2..71dadc1558 100644
--- a/engines/asylum/system/graphics.cpp
+++ b/engines/asylum/system/graphics.cpp
@@ -32,7 +32,7 @@
namespace Asylum {
-GraphicResource::GraphicResource(AsylumEngine *engine, ResourceId id) : _vm(engine), _resourceId(kResourceNone), _flags(0), _flags2(0) {
+GraphicResource::GraphicResource(AsylumEngine *engine, ResourceId id) : _vm(engine), _resourceId(kResourceNone) {
load(id);
}
@@ -70,23 +70,32 @@ GraphicFrame *GraphicResource::getFrame(uint32 frame) {
void GraphicResource::init(byte *data, int32 size) {
byte *dataPtr = data;
- dataPtr += 4; // tag value
+ // Read tag
+ for (uint i = 0; i < sizeof(_data.tag); i++) {
+ _data.tag[i] = *dataPtr;
+ ++dataPtr;
+ }
- _flags = (int32)READ_LE_UINT32(dataPtr);
+ _data.flags = READ_LE_UINT32(dataPtr);
dataPtr += 4;
- //_flags2 = (int32)READ_LE_UINT32(dataPtr);
int32 contentOffset = (int32)READ_LE_UINT32(dataPtr);
dataPtr += 4;
- dataPtr += 4; // unknown
- dataPtr += 4; // unknown
- dataPtr += 4; // unknown
+ _data.field_C = READ_LE_UINT32(dataPtr);
+ dataPtr += 4;
+
+ _data.field_10 = READ_LE_UINT32(dataPtr);
+ dataPtr += 4;
+
+ _data.field_14 = READ_LE_UINT32(dataPtr);
+ dataPtr += 4;
uint16 frameCount = READ_LE_UINT16(dataPtr);
dataPtr += 2;
- dataPtr += 2; // max width
+ _data.maxWidth = READ_LE_UINT16(dataPtr);
+ dataPtr += 2;
_frames.resize(frameCount);
diff --git a/engines/asylum/system/graphics.h b/engines/asylum/system/graphics.h
index 47b36f8801..a121e7ae13 100644
--- a/engines/asylum/system/graphics.h
+++ b/engines/asylum/system/graphics.h
@@ -55,6 +55,26 @@ struct GraphicFrame {
// Graphic resources can be sprites or images, with multiple frames
class GraphicResource {
public:
+ struct ResourceData {
+ char tag[4];
+ uint32 flags;
+ // contentOffset
+ uint32 field_C;
+ uint32 field_10;
+ uint32 field_14;
+ // frameCount
+ uint16 maxWidth;
+ // Offsets
+
+ ResourceData() {
+ memset(&tag, 0, sizeof(tag));
+ flags = 0;
+ field_C = 0;
+ field_10 = 0;
+ field_14 = 0;
+ maxWidth = 0;
+ }
+ };
GraphicResource(AsylumEngine *engine) {}
GraphicResource(AsylumEngine *engine, ResourceId id);
@@ -74,11 +94,11 @@ public:
GraphicFrame *getFrame(uint32 frame);
ResourceId getResourceId() { return _resourceId; }
- // FIXME: flags are coordinates for the sound origin!
- int32 getFlags() { return _flags; }
- int32 getFlags2() { return _flags2; }
uint32 count() { return _frames.size(); }
+ // FIXME: flags are coordinates for the sound origin!
+ ResourceData getData() { return _data; }
+
// Helper functions
static uint32 getFrameCount(AsylumEngine *engine, ResourceId id);
static Common::Rect getFrameRect(AsylumEngine *engine, ResourceId id, uint32 index);
@@ -86,11 +106,9 @@ public:
private:
AsylumEngine *_vm;
- Common::Array<GraphicFrame> _frames;
-
ResourceId _resourceId;
- int32 _flags;
- int32 _flags2;
+ ResourceData _data;
+ Common::Array<GraphicFrame> _frames;
void init(byte *data, int32 size);
void clear();
diff --git a/engines/asylum/system/screen.cpp b/engines/asylum/system/screen.cpp
index d42b218523..9ec72ad841 100644
--- a/engines/asylum/system/screen.cpp
+++ b/engines/asylum/system/screen.cpp
@@ -39,8 +39,11 @@
namespace Asylum {
Screen::Screen(AsylumEngine *vm) : _vm(vm) ,
- _transTableCount(0), _transTableIndex(NULL), _transTableData(NULL), _transTableBuffer(NULL) {
+ _useColorKey(false), _transTableCount(0), _transTableIndex(NULL), _transTableData(NULL), _transTableBuffer(NULL) {
_backBuffer.create(640, 480, 1);
+
+ _flag = 0xFF;
+ //_clipRect = Common::Rect(0, 0, 639, 479);
}
Screen::~Screen() {
@@ -68,83 +71,121 @@ void Screen::draw(ResourceId resourceId, uint32 frameIndex, int32 x, int32 y, in
_transTableIndex = index;
}
-void Screen::draw(ResourceId resourceId, uint32 frameIndex, int32 x, int32 y, int32 flags, ResourceId resourceId2, int32 destX, int32 destY, bool colorKey) {
-
+void Screen::draw(ResourceId resourceId, uint32 frameIndex, int32 sourceX, int32 sourceY, int32 flags, ResourceId resourceIdDestination, int32 destX, int32 destY, bool colorKey) {
// Get the frame to draw
GraphicResource *resource = new GraphicResource(_vm, resourceId);
GraphicFrame *frame = resource->getFrame(frameIndex);
- copyToBackBuffer(((byte *)frame->surface.pixels) - (y * frame->surface.w + x),
- frame->surface.w,
- frame->x + x,
- frame->y + y,
- frame->getWidth(),
- frame->getHeight());
+ // Compute coordinates
+ Common::Rect source;
+ Common::Rect destination;
+ destination.left = sourceX + frame->x;
+
+ if (flags & 2) {
+ if (_flag == -1) {
+ if ((resource->getData().flags & 15) >= 2) {
+ destination.left = sourceX + resource->getData().maxWidth - frame->getWidth() - frame->x;
+ }
+ } else {
+ destination.left += 2 * _flag - (frame->getHeight() * 2 - frame->x);
+ }
+ }
+
+ destination.top = sourceY + frame->y;
+ destination.right = destination.left + frame->getWidth();
+ destination.bottom = destination.top + frame->getHeight();
+
+ source.left = 0;
+ source.top = 0;
+ source.right = frame->getWidth();
+ source.bottom = frame->getHeight();
+
+ //clip(&source, &destination, flags);
+
+ bool masked = false;
+ if (resourceIdDestination) {
+ masked = true;
+
+ error("[Screen::draw] Not implemented (masked)!");
+ }
+
+ if (masked) {
+ error("[Screen::draw] Not implemented!");
+
+ return;
+ }
+
+ // Set the color key (always 0 if set)
+ _useColorKey = colorKey;
+
+ blit(frame, &source, &destination, flags, colorKey);
delete resource;
}
-void Screen::copyBackBufferToScreen() {
- _vm->_system->copyRectToScreen((byte *)_backBuffer.pixels, _backBuffer.w, 0, 0, _backBuffer.w, _backBuffer.h);
+//////////////////////////////////////////////////////////////////////////
+// Misc
+//////////////////////////////////////////////////////////////////////////
+void Screen::clear() const {
+ _vm->_system->fillScreen(0);
}
-void Screen::copyToBackBuffer(byte *buffer, int32 pitch, int32 x, int32 y, uint32 width, uint32 height) {
- byte *dest = (byte *)_backBuffer.pixels;
-
- while (height--) {
- memcpy(dest + y * _backBuffer.pitch + x, buffer, width);
- dest += 640;
- buffer += pitch;
+void Screen::drawWideScreenBars(int16 barSize) const {
+ if (barSize > 0) {
+ _vm->_system->lockScreen()->fillRect(Common::Rect(0, 0, 640, barSize), 0);
+ _vm->_system->unlockScreen();
+ _vm->_system->lockScreen()->fillRect(Common::Rect(0, 480 - barSize, 640, 480), 0);
+ _vm->_system->unlockScreen();
}
}
-void Screen::copyToBackBufferWithTransparency(byte *buffer, int32 pitch, int32 x, int32 y, int32 width, int32 height) {
- byte *dest = (byte *)_backBuffer.pixels;
-
- int32 left = (x < 0) ? -x : 0;
- int32 top = (y < 0) ? -y : 0;
- int32 right = (x + width > 640) ? 640 - abs(x) : width;
- int32 bottom = (y + height > 480) ? 480 - abs(y) : height;
+void Screen::fillRect(int32 x, int32 y, int32 width, int32 height, int32 color) {
+ _vm->_system->lockScreen()->fillRect(Common::Rect(x, y, x + width, y + height), color);
+ _vm->_system->unlockScreen();
+}
- for (int32 curY = top; curY < bottom; curY++) {
- for (int32 curX = left; curX < right; curX++) {
- if (buffer[curX + curY * pitch] != 0 ) {
- dest[x + curX + (y + curY) * 640] = buffer[curX + curY * pitch];
- }
- }
- }
+void Screen::copyBackBufferToScreen() {
+ _vm->_system->copyRectToScreen((byte *)_backBuffer.pixels, _backBuffer.w, 0, 0, _backBuffer.w, _backBuffer.h);
}
-void Screen::copyToBackBufferClipped(Graphics::Surface *surface, int x, int y) {
- Common::Rect screenRect(getWorld()->xLeft, getWorld()->yTop, getWorld()->xLeft + 640, getWorld()->yTop + 480);
- Common::Rect animRect(x, y, x + surface->w, y + surface->h);
- animRect.clip(screenRect);
+void Screen::clip(Common::Rect *source, Common::Rect *destination, int32 flags) {
+ int32 diffLeft = _clipRect.left - destination->left;
- if (!animRect.isEmpty()) {
- // Translate anim rectangle
- animRect.translate(-(int16)getWorld()->xLeft, -(int16)getWorld()->yTop);
+ if (diffLeft > 0) {
+ destination->left = _clipRect.left;
- int startX = animRect.right == 640 ? 0 : surface->w - animRect.width();
- int startY = animRect.bottom == 480 ? 0 : surface->h - animRect.height();
+ if (flags & 2)
+ source->right -= diffLeft;
+ else
+ source->left += diffLeft;
+ }
- if (surface->w > 640)
- startX = getWorld()->xLeft;
- if (surface->h > 480)
- startY = getWorld()->yTop;
+ int32 diffRightTop = destination->right - _clipRect.top - 1;
+ if (diffRightTop > 0) {
+ destination->right -= diffRightTop;
- _vm->screen()->copyToBackBufferWithTransparency(
- ((byte*)surface->pixels) +
- startY * surface->pitch +
- startX * surface->bytesPerPixel,
- surface->pitch,
- animRect.left,
- animRect.top,
- animRect.width(),
- animRect.height());
+ if (flags & 2)
+ source->left += diffRightTop;
+ else
+ source->right -= diffRightTop;
+ }
+
+ int32 diffRightTop2 = _clipRect.right - destination->top;
+ if (diffRightTop2 > 0) {
+ destination->top = _clipRect.right;
+ source->top += diffRightTop2;
}
-}
+ int32 diffBottom = destination->bottom - _clipRect.bottom - 1;
+ if (diffBottom > 0) {
+ source->bottom -= diffBottom;
+ destination->bottom -= diffBottom;
+ }
+}
+//////////////////////////////////////////////////////////////////////////
+// Palette
+//////////////////////////////////////////////////////////////////////////
void Screen::setPalette(ResourceId id) {
setPalette(getResource()->get(id)->data + 32);
}
@@ -167,45 +208,106 @@ void Screen::setPalette(byte *rgbPalette) const {
_vm->_system->setPalette(palette, 0, 256);
}
+void Screen::paletteFade(uint32 red, int32 milliseconds, int32 param) {
+ warning("[Screen::paletteFade] not implemented");
+}
+
+void Screen::startPaletteFade(ResourceId resourceId, int32 milliseconds, int32 param) {
+ warning("[Screen::startPaletteFade] not implemented");
+}
+
+//////////////////////////////////////////////////////////////////////////
+// Gamma
+//////////////////////////////////////////////////////////////////////////
void Screen::setGammaLevel(ResourceId id, int32 val) {
warning("[Screen::setGammaLevel] not implemented");
}
-void Screen::drawWideScreenBars(int16 barSize) const {
- if (barSize > 0) {
- _vm->_system->lockScreen()->fillRect(Common::Rect(0, 0, 640, barSize), 0);
- _vm->_system->unlockScreen();
- _vm->_system->lockScreen()->fillRect(Common::Rect(0, 480 - barSize, 640, 480), 0);
- _vm->_system->unlockScreen();
- }
+//////////////////////////////////////////////////////////////////////////
+// Transparency tables
+//////////////////////////////////////////////////////////////////////////
+void Screen::setupTransTable(ResourceId resourceId) {
+ if (resourceId)
+ setupTransTables(1, resourceId);
+ else
+ setupTransTables(0);
}
-void Screen::clear() const {
- _vm->_system->fillScreen(0);
+void Screen::setupTransTables(uint32 count, ...) {
+ if (!count) {
+ clearTransTables();
+ return;
+ }
+
+ // Load tables
+ va_list va;
+ va_start(va, count);
+
+ if (_transTableCount != count)
+ clearTransTables();
+
+ _transTableCount = count;
+
+ if (!_transTableData) {
+ _transTableData = (byte *)malloc((count + 1) * 65536);
+ _transTableBuffer = _transTableData + 65536;
+ _transTableIndex = _transTableBuffer;
+ }
+
+ uint32 index = 0;
+ for (uint32 i = 0; i < _transTableCount; i++) {
+ ResourceId id = va_arg(va, ResourceId);
+
+ memcpy(&_transTableBuffer[index], getResource()->get(id)->data, 65536);
+ index += 65536;
+ }
}
-void Screen::paletteFade(uint32 red, int32 milliseconds, int32 param) {
- warning("[Screen::paletteFade] not implemented");
+void Screen::clearTransTables() {
+ free(_transTableData);
+ _transTableData = NULL;
+ _transTableBuffer = NULL;
+ _transTableIndex = NULL;
+ _transTableCount = 0;
}
-void Screen::startPaletteFade(ResourceId resourceId, int32 milliseconds, int32 param) {
- warning("[Screen::startPaletteFade] not implemented");
+void Screen::selectTransTable(uint32 index) {
+ if (index >= _transTableCount)
+ return;
+
+ _transTableIndex = &_transTableBuffer[65536 * index];
}
-void Screen::addGraphicToQueue(ResourceId resourceId, uint32 frameIndex, Common::Point point, int32 flags, int32 transTableNum, int32 priority) {
+//////////////////////////////////////////////////////////////////////////
+// Graphic queue
+//////////////////////////////////////////////////////////////////////////
+void Screen::addGraphicToQueue(ResourceId resourceId, uint32 frameIndex, Common::Point point, int32 flags, int32 destX, int32 priority) {
GraphicQueueItem item;
+ item.priority = priority;
+
+ item.type = kGraphicItemNormal;
+ item.source = point;
item.resourceId = resourceId;
- item.point = point;
item.frameIndex = frameIndex;
item.flags = flags;
- item.transTableNum = transTableNum;
- item.priority = priority;
+ item.destination.x = destX;
_queueItems.push_back(item);
}
-void Screen::addGraphicToQueueMasked(ResourceId resourceId, uint32 frameIndex, Common::Point point, int32 objectResourceId, Common::Point objectPoint, int32 flags, int32 priority) {
- error("[Screen::addGraphicToQueueMasked] not implemented");
+void Screen::addGraphicToQueueMasked(ResourceId resourceId, uint32 frameIndex, Common::Point source, int32 resourceIdDestination, Common::Point destination, int32 flags, int32 priority) {
+ GraphicQueueItem item;
+ item.priority = priority;
+
+ item.type = kGraphicItemMasked;
+ item.source = source;
+ item.resourceId = resourceId;
+ item.frameIndex = frameIndex;
+ item.flags = flags;
+ item.resourceIdDestination = resourceIdDestination;
+ item.destination = destination;
+
+ _queueItems.push_back(item);
}
void Screen::addGraphicToQueueCrossfade(ResourceId resourceId, uint32 frameIndex, Common::Point point, int32 objectResourceId, Common::Point objectPoint, int32 transTableNum) {
@@ -220,17 +322,17 @@ void Screen::drawGraphicsInQueue() {
// sort by priority first
graphicsSelectionSort();
- for (uint32 i = 0; i < _queueItems.size(); i++) {
- GraphicResource *grRes = new GraphicResource(_vm, _queueItems[i].resourceId);
- GraphicFrame *fra = grRes->getFrame(_queueItems[i].frameIndex);
-
- copyToBackBufferWithTransparency((byte *)fra->surface.pixels,
- fra->surface.w,
- _queueItems[i].point.x - getWorld()->xLeft + fra->x, _queueItems[i].point.y - getWorld()->yTop + fra->y,
- fra->surface.w,
- fra->surface.h);
+ for (Common::Array<GraphicQueueItem>::const_iterator i = _queueItems.begin(); i != _queueItems.end(); i++) {
+ const GraphicQueueItem *item = i;
- delete grRes;
+ if (item->type == kGraphicItemNormal) {
+ if (item->transTableNum <= 0 || Config.performance <= 1)
+ draw(item->resourceId, item->frameIndex, item->source.x, item->source.y, item->flags);
+ else
+ draw(item->resourceId, item->frameIndex, item->source.x, item->source.y, item->flags, item->transTableNum - 1);
+ } else if (item->type == kGraphicItemMasked) {
+ draw(item->resourceId, item->frameIndex, item->source.x, item->source.y, item->flags, item->resourceIdDestination, item->destination.x, item->destination.y);
+ }
}
}
@@ -270,59 +372,89 @@ void Screen::deleteGraphicFromQueue(ResourceId resourceId) {
}
//////////////////////////////////////////////////////////////////////////
-// Transparency tables
+// Graphic Data
//////////////////////////////////////////////////////////////////////////
-void Screen::setupTransTable(ResourceId resourceId) {
- if (resourceId)
- setupTransTables(1, resourceId);
- else
- setupTransTables(0);
+void Screen::blit(GraphicFrame *frame, Common::Rect *source, Common::Rect *destination, int32 flags, bool useColorKey) {
+
+ if (flags & 0x8000000) {
+ error("[Screen::blit] not implemented");
+ } else if (flags) {
+ blt(destination, frame, source, flags, useColorKey);
+ } else {
+ bltFast(destination->left, destination->top, frame, source, useColorKey);
+ }
}
-void Screen::setupTransTables(uint32 count, ...) {
- if (!count) {
- clearTransTables();
- return;
+void Screen::blt(Common::Rect *dest, GraphicFrame* frame, Common::Rect *source, int32 flags, bool useColorKey) {
+ if (useColorKey) {
+ copyToBackBufferWithTransparency((byte *)frame->surface.pixels, frame->surface.pitch, dest->left, dest->top, frame->surface.w, frame->surface.h);
+ } else {
+ copyToBackBuffer((byte *)frame->surface.pixels, frame->surface.pitch, dest->left, dest->top, frame->surface.w, frame->surface.h);
}
+}
- // Load tables
- va_list va;
- va_start(va, count);
-
- if (_transTableCount != count)
- clearTransTables();
+void Screen::bltFast(int32 dX, int32 dY, GraphicFrame* frame, Common::Rect *source, bool useColorKey) {
+ if (useColorKey) {
+ copyToBackBufferWithTransparency((byte *)frame->surface.pixels, frame->surface.pitch, dX, dY, frame->surface.w, frame->surface.h);
+ } else {
+ copyToBackBuffer((byte *)frame->surface.pixels, frame->surface.pitch, dX, dY, frame->surface.w, frame->surface.h);
+ }
+}
- _transTableCount = count;
+void Screen::copyToBackBuffer(byte *buffer, int32 pitch, int32 x, int32 y, uint32 width, uint32 height) {
+ byte *dest = (byte *)_backBuffer.pixels;
- if (!_transTableData) {
- _transTableData = (byte *)malloc((count + 1) * 65536);
- _transTableBuffer = _transTableData + 65536;
- _transTableIndex = _transTableBuffer;
+ while (height--) {
+ memcpy(dest + y * _backBuffer.pitch + x, buffer, width);
+ dest += 640;
+ buffer += pitch;
}
+}
- uint32 index = 0;
- for (uint32 i = 0; i < _transTableCount; i++) {
- ResourceId id = va_arg(va, ResourceId);
+void Screen::copyToBackBufferWithTransparency(byte *buffer, int32 pitch, int32 x, int32 y, int32 width, int32 height) {
+ byte *dest = (byte *)_backBuffer.pixels;
- memcpy(&_transTableBuffer[index], getResource()->get(id)->data, 65536);
- index += 65536;
+ int32 left = (x < 0) ? -x : 0;
+ int32 top = (y < 0) ? -y : 0;
+ int32 right = (x + width > 640) ? 640 - abs(x) : width;
+ int32 bottom = (y + height > 480) ? 480 - abs(y) : height;
+
+ for (int32 curY = top; curY < bottom; curY++) {
+ for (int32 curX = left; curX < right; curX++) {
+ if (buffer[curX + curY * pitch] != 0 ) {
+ dest[x + curX + (y + curY) * 640] = buffer[curX + curY * pitch];
+ }
+ }
}
}
-void Screen::clearTransTables() {
- free(_transTableData);
- _transTableData = NULL;
- _transTableBuffer = NULL;
- _transTableIndex = NULL;
- _transTableCount = 0;
-}
+void Screen::copyToBackBufferClipped(Graphics::Surface *surface, int x, int y) {
+ Common::Rect screenRect(getWorld()->xLeft, getWorld()->yTop, getWorld()->xLeft + 640, getWorld()->yTop + 480);
+ Common::Rect animRect(x, y, x + surface->w, y + surface->h);
+ animRect.clip(screenRect);
-void Screen::selectTransTable(uint32 index) {
- if (index >= _transTableCount)
- return;
+ if (!animRect.isEmpty()) {
+ // Translate anim rectangle
+ animRect.translate(-(int16)getWorld()->xLeft, -(int16)getWorld()->yTop);
- _transTableIndex = &_transTableBuffer[65536 * index];
-}
+ int startX = animRect.right == 640 ? 0 : surface->w - animRect.width();
+ int startY = animRect.bottom == 480 ? 0 : surface->h - animRect.height();
+ if (surface->w > 640)
+ startX = getWorld()->xLeft;
+ if (surface->h > 480)
+ startY = getWorld()->yTop;
+
+ _vm->screen()->copyToBackBufferWithTransparency(
+ ((byte*)surface->pixels) +
+ startY * surface->pitch +
+ startX * surface->bytesPerPixel,
+ surface->pitch,
+ animRect.left,
+ animRect.top,
+ animRect.width(),
+ animRect.height());
+ }
+}
} // end of namespace Asylum
diff --git a/engines/asylum/system/screen.h b/engines/asylum/system/screen.h
index c8a7e80c21..c5521c071f 100644
--- a/engines/asylum/system/screen.h
+++ b/engines/asylum/system/screen.h
@@ -38,20 +38,33 @@ class AsylumEngine;
class GraphicResource;
class ResourcePack;
+struct GraphicFrame;
+
+enum GraphicItemType {
+ kGraphicItemNormal = 1,
+ kGraphicItemMasked = 5
+};
+
typedef struct GraphicQueueItem {
+ int32 priority;
+
+ GraphicItemType type;
ResourceId resourceId;
uint32 frameIndex;
- Common::Point point;
+ Common::Point source;
+ ResourceId resourceIdDestination;
+ Common::Point destination;
int32 flags;
int32 transTableNum;
- int32 priority;
GraphicQueueItem() {
+ priority = 0;
+
resourceId = kResourceNone;
frameIndex = 0;
+ resourceIdDestination = kResourceNone;
flags = 0;
transTableNum = 0;
- priority = 0;
}
} GraphicQueueItem;
@@ -65,7 +78,12 @@ public:
void draw(ResourceId resourceId, uint32 frameIndex, int32 x, int32 y, int32 flags, int32 transTableNum);
void draw(ResourceId resourceId, uint32 frameIndex, int32 x, int32 y, int32 flags, ResourceId resourceId2, int32 destX, int32 destY, bool colorKey = true);
+ // Misc
void clear() const;
+ void drawWideScreenBars(int16 barSize) const;
+ void fillRect(int32 x, int32 y, int32 x2, int32 y2, int32 color);
+ void copyBackBufferToScreen();
+ void setFlag(int32 val) { _flag = (val < -1) ? -1 : val; }
// Palette
void setPalette(byte *rgbPalette) const;
@@ -76,9 +94,6 @@ public:
// Gamma
void setGammaLevel(ResourceId id, int32 val);
- // Misc
- void drawWideScreenBars(int16 barSize) const;
-
// Transparency tables
void setupTransTable(ResourceId resourceId);
void setupTransTables(uint32 count, ...);
@@ -87,28 +102,26 @@ public:
// Graphic queue
void addGraphicToQueue(ResourceId resourceId, uint32 frameIndex, Common::Point point, int32 flags, int32 transTableNum, int32 priority);
- void addGraphicToQueueCrossfade(ResourceId resourceId, uint32 frameIndex, Common::Point point, int32 objectResourceId, Common::Point objectPoint, int32 transTableNum);
- void addGraphicToQueueMasked(ResourceId resourceId, uint32 frameIndex, Common::Point point, int32 objectResourceId, Common::Point objectPoint, int32 flags, int32 priority);
+ void addGraphicToQueueCrossfade(ResourceId resourceId, uint32 frameIndex, Common::Point source, int32 objectResourceId, Common::Point destination, int32 transTableNum);
+ void addGraphicToQueueMasked(ResourceId resourceId, uint32 frameIndex, Common::Point point, int32 objectResourceId, Common::Point destination, int32 flags, int32 priority);
void addGraphicToQueue(GraphicQueueItem const &item);
void drawGraphicsInQueue();
void clearGraphicsInQueue();
- void graphicsSelectionSort();
- void swapGraphicItem(int32 item1, int32 item2);
void deleteGraphicFromQueue(ResourceId resourceId);
- // TODO Make those private
- void copyToBackBufferWithTransparency(byte *buffer, int32 pitch, int32 x, int32 y, int32 width, int32 height);
- void copyBackBufferToScreen();
-
// Debug
void copyToBackBufferClipped(Graphics::Surface *surface, int x, int y);
private:
- Graphics::Surface _backBuffer;
AsylumEngine *_vm;
+ Graphics::Surface _backBuffer;
+ Common::Rect _clipRect;
Common::Array<GraphicQueueItem> _queueItems;
+ uint16 _flag;
+ bool _useColorKey;
+
// Transparency tables
uint32 _transTableCount;
byte *_transTableIndex;
@@ -116,8 +129,21 @@ private:
byte *_transTableBuffer;
void clearTransTables();
- // Screen copying
+ // Graphic queue
+ void graphicsSelectionSort();
+ void swapGraphicItem(int32 item1, int32 item2);
+
+ // Misc
+ void clip(Common::Rect *source, Common::Rect *destination, int32 flags);
+
+ // Screen blitting
+ void blit(GraphicFrame *frame, Common::Rect *source, Common::Rect *destination, int32 flags, bool useColorKey);
+ void blt(Common::Rect *dest, GraphicFrame* frame, Common::Rect *source, int32 flags, bool useColorKey);
+ void bltFast(int32 dX, int32 dY, GraphicFrame* frame, Common::Rect *source, bool useColorKey);
+
+
void copyToBackBuffer(byte *buffer, int32 pitch, int32 x, int32 y, uint32 width, uint32 height);
+ void copyToBackBufferWithTransparency(byte *buffer, int32 pitch, int32 x, int32 y, int32 width, int32 height);
};
} // end of namespace Asylum
diff --git a/engines/asylum/system/text.cpp b/engines/asylum/system/text.cpp
index a7a4699f21..7e42a7909b 100644
--- a/engines/asylum/system/text.cpp
+++ b/engines/asylum/system/text.cpp
@@ -60,7 +60,7 @@ void Text::loadFont(ResourceId resourceId) {
if (resourceId != kResourceNone) {
// load font flag data
- _curFontFlags = Common::Rational(_fontResource->getFlags(), 16).toInt() & 0x0F;
+ _curFontFlags = Common::Rational(_fontResource->getData().flags, 16).toInt() & 0x0F;
}
}
@@ -123,18 +123,13 @@ void Text::drawChar(char character) {
if (!_fontResource)
error("[Text::drawChar] font resource hasn't been loaded yet!");
- //if (_transTableNum) {
- // getScreen()->draw(_fontResource->getResourceId(), (uint8)character, _posX, _posY, 0, _transTableNum);
- //} else {
- // getScreen()->draw(_fontResource->getResourceId(), (uint8)character, _posX, _posY, 0);
- //}
+ if (_transTableNum) {
+ getScreen()->draw(_fontResource->getResourceId(), (uint8)character, _posX, _posY, 0, _transTableNum);
+ } else {
+ getScreen()->draw(_fontResource->getResourceId(), (uint8)character, _posX, _posY, 0);
+ }
GraphicFrame *fontLetter = _fontResource->getFrame((uint8)character);
- getScreen()->copyToBackBufferWithTransparency((byte *)fontLetter->surface.pixels, fontLetter->surface.w, _posX, _posY + fontLetter->y, fontLetter->surface.w, fontLetter->surface.h);
-
- // TODO remove
-
-
_posX += fontLetter->surface.w + fontLetter->x - _curFontFlags;
}
diff --git a/engines/asylum/system/video.cpp b/engines/asylum/system/video.cpp
index 02caf03631..48cc41796e 100644
--- a/engines/asylum/system/video.cpp
+++ b/engines/asylum/system/video.cpp
@@ -213,7 +213,7 @@ void VideoText::loadFont(ResourceId resourceId) {
if (resourceId != kResourceNone) {
// load font flag data
- _curFontFlags = Common::Rational(_fontResource->getFlags(), 16).toInt() & 0x0F;
+ _curFontFlags = Common::Rational(_fontResource->getData().flags, 16).toInt() & 0x0F;
}
}
diff --git a/engines/asylum/views/menu.cpp b/engines/asylum/views/menu.cpp
index a46e0bcdc1..bbf9352176 100644
--- a/engines/asylum/views/menu.cpp
+++ b/engines/asylum/views/menu.cpp
@@ -401,7 +401,8 @@ bool MainMenu::update() {
uint32 ticks = _vm->getTick();
if (!getSharedData()->getFlag(kFlagRedraw)) {
- // TODO original fills a rectangle with black
+ // The original clears the area where the eyes are
+ //getScreen()->fillRect(260, 229, 119, 16, 0);
// Draw background
getScreen()->draw(kBackground, (_activeScreen == kMenuNone) ? 1 : 0, 0, 0, 0);
Commit: fde7a99ece49390acad88c89f61b1862f99105a8
https://github.com/scummvm/scummvm/commit/fde7a99ece49390acad88c89f61b1862f99105a8
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:29+02:00
Commit Message:
ASYLUM: Properly clip coordinates and adjust drawing width/height
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@618 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/system/screen.cpp
diff --git a/engines/asylum/system/screen.cpp b/engines/asylum/system/screen.cpp
index 9ec72ad841..57e8fb4a03 100644
--- a/engines/asylum/system/screen.cpp
+++ b/engines/asylum/system/screen.cpp
@@ -43,7 +43,7 @@ Screen::Screen(AsylumEngine *vm) : _vm(vm) ,
_backBuffer.create(640, 480, 1);
_flag = 0xFF;
- //_clipRect = Common::Rect(0, 0, 639, 479);
+ _clipRect = Common::Rect(0, 0, 639, 479);
}
Screen::~Screen() {
@@ -100,7 +100,7 @@ void Screen::draw(ResourceId resourceId, uint32 frameIndex, int32 sourceX, int32
source.right = frame->getWidth();
source.bottom = frame->getHeight();
- //clip(&source, &destination, flags);
+ clip(&source, &destination, flags);
bool masked = false;
if (resourceIdDestination) {
@@ -160,20 +160,20 @@ void Screen::clip(Common::Rect *source, Common::Rect *destination, int32 flags)
source->left += diffLeft;
}
- int32 diffRightTop = destination->right - _clipRect.top - 1;
- if (diffRightTop > 0) {
- destination->right -= diffRightTop;
+ int32 diffRight = destination->right - _clipRect.right - 1;
+ if (diffRight > 0) {
+ destination->right -= diffRight;
if (flags & 2)
- source->left += diffRightTop;
+ source->left += diffRight;
else
- source->right -= diffRightTop;
+ source->right -= diffRight;
}
- int32 diffRightTop2 = _clipRect.right - destination->top;
- if (diffRightTop2 > 0) {
- destination->top = _clipRect.right;
- source->top += diffRightTop2;
+ int32 diffTop = _clipRect.top - destination->top;
+ if (diffTop > 0) {
+ destination->top = _clipRect.top;
+ source->top += diffTop;
}
int32 diffBottom = destination->bottom - _clipRect.bottom - 1;
@@ -281,7 +281,7 @@ void Screen::selectTransTable(uint32 index) {
//////////////////////////////////////////////////////////////////////////
// Graphic queue
//////////////////////////////////////////////////////////////////////////
-void Screen::addGraphicToQueue(ResourceId resourceId, uint32 frameIndex, Common::Point point, int32 flags, int32 destX, int32 priority) {
+void Screen::addGraphicToQueue(ResourceId resourceId, uint32 frameIndex, Common::Point point, int32 flags, int32 transTableNum, int32 priority) {
GraphicQueueItem item;
item.priority = priority;
@@ -290,7 +290,7 @@ void Screen::addGraphicToQueue(ResourceId resourceId, uint32 frameIndex, Common:
item.resourceId = resourceId;
item.frameIndex = frameIndex;
item.flags = flags;
- item.destination.x = destX;
+ item.transTableNum = transTableNum;
_queueItems.push_back(item);
}
@@ -386,18 +386,39 @@ void Screen::blit(GraphicFrame *frame, Common::Rect *source, Common::Rect *desti
}
void Screen::blt(Common::Rect *dest, GraphicFrame* frame, Common::Rect *source, int32 flags, bool useColorKey) {
+ // TODO adjust destination rect
if (useColorKey) {
- copyToBackBufferWithTransparency((byte *)frame->surface.pixels, frame->surface.pitch, dest->left, dest->top, frame->surface.w, frame->surface.h);
+ copyToBackBufferWithTransparency((byte *)frame->surface.pixels - (source->top * frame->surface.w + source->left),
+ frame->surface.w,
+ dest->left,
+ dest->top,
+ source->width(),
+ source->height());
} else {
- copyToBackBuffer((byte *)frame->surface.pixels, frame->surface.pitch, dest->left, dest->top, frame->surface.w, frame->surface.h);
+ copyToBackBuffer((byte *)frame->surface.pixels - (source->top * frame->surface.w + source->left),
+ frame->surface.w,
+ dest->left,
+ dest->top,
+ source->width(),
+ source->height());
}
}
void Screen::bltFast(int32 dX, int32 dY, GraphicFrame* frame, Common::Rect *source, bool useColorKey) {
if (useColorKey) {
- copyToBackBufferWithTransparency((byte *)frame->surface.pixels, frame->surface.pitch, dX, dY, frame->surface.w, frame->surface.h);
+ copyToBackBufferWithTransparency((byte *)frame->surface.pixels - (source->top * frame->surface.w + source->left),
+ frame->surface.w,
+ dX,
+ dY,
+ source->width(),
+ source->height());
} else {
- copyToBackBuffer((byte *)frame->surface.pixels, frame->surface.pitch, dX, dY, frame->surface.w, frame->surface.h);
+ copyToBackBuffer((byte *)frame->surface.pixels - (source->top * frame->surface.w + source->left),
+ frame->surface.w,
+ dX,
+ dY,
+ source->width(),
+ source->height());
}
}
Commit: 151e417b72e0d0b52656ea8f0096413025d5d082
https://github.com/scummvm/scummvm/commit/151e417b72e0d0b52656ea8f0096413025d5d082
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:30+02:00
Commit Message:
ASYLUM: Wait 10ms when handling events (reduces CPU usage a lot)
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@619 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/asylum.cpp
diff --git a/engines/asylum/asylum.cpp b/engines/asylum/asylum.cpp
index f0b1f9b81c..db279258a3 100644
--- a/engines/asylum/asylum.cpp
+++ b/engines/asylum/asylum.cpp
@@ -148,6 +148,8 @@ Common::Error AsylumEngine::run() {
while (!shouldQuit()) {
handleEvents();
+ _system->delayMillis(10);
+
_system->updateScreen();
}
Commit: b0248c93fdab66481d90ffe40b27d0804922b013
https://github.com/scummvm/scummvm/commit/b0248c93fdab66481d90ffe40b27d0804922b013
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:30+02:00
Commit Message:
ASYLUM: Remove obsolete methods from Scene class
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@620 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/resources/actionlist.cpp
engines/asylum/resources/actor.cpp
engines/asylum/resources/actor.h
engines/asylum/resources/encounters.cpp
engines/asylum/resources/special.cpp
engines/asylum/resources/worldstats.cpp
engines/asylum/system/screen.cpp
engines/asylum/system/screen.h
engines/asylum/system/sound.h
engines/asylum/views/scene.cpp
engines/asylum/views/scene.h
diff --git a/engines/asylum/resources/actionlist.cpp b/engines/asylum/resources/actionlist.cpp
index ac1b8c6fcf..74f4642144 100644
--- a/engines/asylum/resources/actionlist.cpp
+++ b/engines/asylum/resources/actionlist.cpp
@@ -885,7 +885,7 @@ IMPLEMENT_OPCODE(PlayMovie)
if (!getSharedData()->getMatteBarHeight()) {
getCursor()->hide();
- getScene()->makeGreyPalette();
+ getScreen()->makeGreyPalette();
getSharedData()->setMatteVar1(1);
getSharedData()->setMatteBarHeight(1);
getSharedData()->setMatteVar2(0);
@@ -993,7 +993,7 @@ END_OPCODE
// Opcode 0x35
IMPLEMENT_OPCODE(SetVolume)
AmbientSoundItem item = getWorld()->ambientSounds[cmd->param1];
- int var = cmd->param2 + item.field_C;
+ int var = cmd->param2 + item.delta;
int32 volume = -((Config.sfxVolume + var) * (Config.ambientVolume + var));
@@ -1048,7 +1048,7 @@ END_OPCODE
// Opcode 0x3B
IMPLEMENT_OPCODE(_unk3B_PALETTE_MOD)
if (!cmd->param2) {
- getScene()->makeGreyPalette();
+ getScreen()->makeGreyPalette();
cmd->param2 = 1;
}
@@ -1065,7 +1065,7 @@ IMPLEMENT_OPCODE(_unk3B_PALETTE_MOD)
return;
}
- getScene()->updatePalette(cmd->param1);
+ getScreen()->updatePalette(cmd->param1);
_lineIncrement = 1;
++cmd->param1;
@@ -1598,7 +1598,7 @@ IMPLEMENT_OPCODE(_unk56)
int32 x = 0;
int32 y = 0; // FIXME: is is set somewhere else?
- if (getScene()->processActor(&x, &cmd->param4) == 1) {
+ if (actor->process_4069B0(&x, &cmd->param4) == 1) {
getScene()->getActor()->processStatus(x, y, (bool)cmd->param4);
cmd->param6 = x;
cmd->param7 = y;
diff --git a/engines/asylum/resources/actor.cpp b/engines/asylum/resources/actor.cpp
index f3e060082b..3eb2052aa6 100644
--- a/engines/asylum/resources/actor.cpp
+++ b/engines/asylum/resources/actor.cpp
@@ -376,7 +376,7 @@ void Actor::update() {
if (_frameIndex <= _frameCount - 1)
++_frameIndex;
else
- getScene()->resetActor0();
+ resetActors();
}
if (_index >= 10)
@@ -939,6 +939,10 @@ void Actor::process_401830(int32 field980, int32 actionAreaId, int32 field978, i
updateDirection();
}
+bool Actor::process_4069B0(int32 *x, int32 *y) {
+ error("[Actor::process_4069B0] Not implemented!");
+}
+
bool Actor::process_408B20(Common::Point *point, ActorDirection dir, uint32 count, bool hasDelta) {
if (_field_944 == 1 || _field_944 == 4)
return true;
@@ -1862,8 +1866,8 @@ void Actor::adjustCoordinates(Common::Point *point) {
if (!point)
error("[Actor::adjustCoordinates] Invalid point parameter!");
- point->x += _point1.x - getWorld()->xLeft;
- point->y += _point1.y - getWorld()->yTop;
+ point->x = _point1.x - getWorld()->xLeft;
+ point->y = _point1.y - getWorld()->yTop;
}
int32 Actor::getGraphicsFlags() {
diff --git a/engines/asylum/resources/actor.h b/engines/asylum/resources/actor.h
index 463fcb9dcb..35195057b9 100644
--- a/engines/asylum/resources/actor.h
+++ b/engines/asylum/resources/actor.h
@@ -248,6 +248,7 @@ public:
bool process(int32 actorX, int32 actorY);
void processStatus(int32 actorX, int32 actorY, bool doSpeech);
void process_401830(int32 field980, int32 actionAreaId, int32 field978, int field98C, int32 field990, int32 field974, int32 field984, int32 field988);
+ bool process_4069B0(int32 *x, int32 *y);
bool process_408B20(Common::Point *point, ActorDirection direction, uint32 count, bool hasDelta);
void process_41BC00(int32 reactionIndex, int32 numberValue01Add);
void process_41BCC0(int32 reactionIndex, int32 numberValue01Substract);
diff --git a/engines/asylum/resources/encounters.cpp b/engines/asylum/resources/encounters.cpp
index 0216444d1d..d8c3248372 100644
--- a/engines/asylum/resources/encounters.cpp
+++ b/engines/asylum/resources/encounters.cpp
@@ -32,6 +32,7 @@
#include "asylum/system/cursor.h"
#include "asylum/system/graphics.h"
+#include "asylum/system/screen.h"
#include "asylum/system/speech.h"
#include "asylum/system/text.h"
@@ -716,7 +717,7 @@ void Encounter::runScript() {
case 23:
if (!getSharedData()->getMatteBarHeight()) {
- getScene()->makeGreyPalette();
+ getScreen()->makeGreyPalette();
getSharedData()->setMatteBarHeight(1);
getScene()->actions()->setDelayedVideoIndex(getVariableInv(entry.param2));
getSharedData()->setMatteVar1(1);
diff --git a/engines/asylum/resources/special.cpp b/engines/asylum/resources/special.cpp
index 631b207a1f..0df8335aba 100644
--- a/engines/asylum/resources/special.cpp
+++ b/engines/asylum/resources/special.cpp
@@ -557,12 +557,12 @@ void Special::chapter8(Object *object, ActorIndex actorIndex) {
break;
case kObjectLavaBridge:
- if (getWorld()->ambientSounds[4].field_C > -100)
- getWorld()->ambientSounds[4].field_C -= 5;
+ if (getWorld()->ambientSounds[4].delta > -100)
+ getWorld()->ambientSounds[4].delta -= 5;
if (_vm->isGameFlagSet(kGameFlag937)) {
- if (getWorld()->ambientSounds[5].field_C > -100)
- getWorld()->ambientSounds[5].field_C -= 5;
+ if (getWorld()->ambientSounds[5].delta > -100)
+ getWorld()->ambientSounds[5].delta -= 5;
}
break;
diff --git a/engines/asylum/resources/worldstats.cpp b/engines/asylum/resources/worldstats.cpp
index dd41705d27..51bc8e59c9 100644
--- a/engines/asylum/resources/worldstats.cpp
+++ b/engines/asylum/resources/worldstats.cpp
@@ -188,8 +188,8 @@ void WorldStats::load(Common::SeekableReadStream *stream) {
ambientSounds[s].field_0 = stream->readSint32LE();
ambientSounds[s].flags = stream->readSint32LE();
ambientSounds[s].resourceId = (ResourceId)stream->readSint32LE();
- ambientSounds[s].field_C = stream->readSint32LE();
- ambientSounds[s].field_10 = stream->readSint32LE();
+ ambientSounds[s].delta = stream->readSint32LE();
+ ambientSounds[s].attenuation = stream->readSint32LE();
ambientSounds[s].field_14 = stream->readSint32LE();
for (int32 i = 0; i < 6; i++)
diff --git a/engines/asylum/system/screen.cpp b/engines/asylum/system/screen.cpp
index 57e8fb4a03..bd4de92f08 100644
--- a/engines/asylum/system/screen.cpp
+++ b/engines/asylum/system/screen.cpp
@@ -216,6 +216,14 @@ void Screen::startPaletteFade(ResourceId resourceId, int32 milliseconds, int32 p
warning("[Screen::startPaletteFade] not implemented");
}
+void Screen::updatePalette(int32 param) {
+ error("[Screen::updatePalette] not implemented!");
+}
+
+void Screen::makeGreyPalette() {
+ warning("[Screen::makeGreyPalette] not implemented!");
+}
+
//////////////////////////////////////////////////////////////////////////
// Gamma
//////////////////////////////////////////////////////////////////////////
diff --git a/engines/asylum/system/screen.h b/engines/asylum/system/screen.h
index c5521c071f..e3c0032dd1 100644
--- a/engines/asylum/system/screen.h
+++ b/engines/asylum/system/screen.h
@@ -90,6 +90,8 @@ public:
void setPalette(ResourceId id);
void paletteFade(uint32 red, int32 milliseconds, int32 param);
void startPaletteFade(ResourceId resourceId, int32 milliseconds, int32 param);
+ void updatePalette(int32 param);
+ void makeGreyPalette();
// Gamma
void setGammaLevel(ResourceId id, int32 val);
diff --git a/engines/asylum/system/sound.h b/engines/asylum/system/sound.h
index aa6e8298c0..69c10653fb 100644
--- a/engines/asylum/system/sound.h
+++ b/engines/asylum/system/sound.h
@@ -76,8 +76,8 @@ struct AmbientSoundItem {
int32 field_0;
int32 flags;
ResourceId resourceId;
- int32 field_C;
- int32 field_10;
+ int32 delta;
+ int32 attenuation;
int32 field_14;
GameFlag flagNum[6];
int32 x;
@@ -87,8 +87,8 @@ struct AmbientSoundItem {
field_0 = 0;
flags = 0;
resourceId = kResourceNone;
- field_C = 0;
- field_10 = 0;
+ delta = 0;
+ attenuation = 0;
field_14 = 0;
memset(&flagNum, 0, sizeof(flagNum));
x = 0;
diff --git a/engines/asylum/views/scene.cpp b/engines/asylum/views/scene.cpp
index b81337a7aa..4e9ec63b2b 100644
--- a/engines/asylum/views/scene.cpp
+++ b/engines/asylum/views/scene.cpp
@@ -345,7 +345,7 @@ bool Scene::init() {
getScreen()->setPalette(paletteResource);
getScreen()->setGammaLevel(paletteResource, 0);
- makeGreyPalette();
+ getScreen()->makeGreyPalette();
getScreen()->setupTransTables(3, _ws->cellShadeMask1, _ws->cellShadeMask2, _ws->cellShadeMask3);
getScreen()->selectTransTable(1);
@@ -837,7 +837,7 @@ int32 Scene::findActionArea(const Common::Point pt) {
return targetIdx;
}
-int32 Scene::isInActionArea(const Common::Point &pt, ActionArea *area) {
+bool Scene::isInActionArea(const Common::Point &pt, ActionArea *area) {
error("[Scene::isInActionArea] Not implemented!");
}
@@ -866,7 +866,7 @@ ResourceId Scene::hitTestScene(const Common::Point pt, HitType &type) {
bool Scene::hitTestActor(const Common::Point pt) {
Actor *act = getActor();
Common::Point actPos;
- getActorPosition(act, &actPos);
+ act->adjustCoordinates(&actPos);
int32 hitFrame;
if (act->getFrameIndex() >= act->getFrameCount())
@@ -941,7 +941,7 @@ void Scene::updateAmbientSounds() {
// This adjustment only uses the actor at
// index zero, but it's supposed to loop through
// all available actors as well (I think)
- volume = calculateVolumeAdjustment(snd, getActor(0));
+ volume = getSound()->calculateVolumeAdjustement(snd->x, snd->y, snd->attenuation, snd->delta);
if (volume <= 0) {
if (volume < -10000)
volume = -10000;
@@ -957,19 +957,19 @@ void Scene::updateAmbientSounds() {
panning = 0;
}
if (snd->field_0 == 0) {
- volume = -(snd->field_C ^ 2);
+ volume = -(snd->delta ^ 2);
} else {
- volume = calculateVolumeAdjustment(snd, getActor(0));
+ volume = getSound()->calculateVolumeAdjustement(snd->x, snd->y, snd->attenuation, snd->delta);
volume += Config.ambientVolume;
}
if (loflag & 2) {
int tmpVol = volume;
- if (vm()->getRandom(10000) < 10) {
+ if (_vm->getRandom(10000) < 10) {
if (snd->field_0) {
- _vm->sound()->playSound(snd->resourceId, false, volume, panning);
+ getSound()->playSound(snd->resourceId, false, volume, panning);
} else {
// FIXME will this even work?
- tmpVol += (vm()->getRandom(500)) * (((vm()->getRandom(100) >= 50) - 1) & 2) - 1;
+ tmpVol += (_vm->getRandom(500)) * (((_vm->getRandom(100) >= 50) - 1) & 2) - 1;
if (tmpVol <= -10000)
volume = -10000;
if (volume >= 0)
@@ -977,7 +977,7 @@ void Scene::updateAmbientSounds() {
else
if (tmpVol <= -10000)
tmpVol = -10000;
- getSound()->playSound(snd->resourceId, false, tmpVol, vm()->getRandom(20001) - 10000);
+ getSound()->playSound(snd->resourceId, false, tmpVol, _vm->getRandom(20001) - 10000);
}
}
} else {
@@ -993,39 +993,6 @@ void Scene::updateAmbientSounds() {
}
}
-int32 Scene::calculateVolumeAdjustment(AmbientSoundItem *snd, Actor *act) {
- //int32 x, y;
- if (snd->field_10) {
- /* FIXME properly handle global x/y
- if (g_object_x == -1) {
- x = snd->x - act->getPoint1()->x - act->getPoint2()->x;
- y = snd->y - act->getPoint1()->y - act->getPoint2()->y;
- } else {
- x = snd->x - g_object_x;
- y = snd->y - g_object_y;
- }
- */
-
- // FIXME vol = sub_432CA0(x ^ 2 + y ^ 2);
- // Just assigning an arbitrary value for the
- // time being
- int vol = 5000;
- if (100 / snd->field_C)
- vol = vol / (100 / snd->field_C);
- else
- vol = snd->field_C;
- vol = (vol - snd->field_C) ^ 2;
- if (vol <= 10000)
- vol = -vol;
- else
- vol = -10000;
-
- return vol;
- } else {
- return -(snd->field_C ^ 2);
- }
-}
-
void Scene::updateMusic() {
//warning("[Scene::updateMusic] not implemented!");
}
@@ -1468,18 +1435,9 @@ bool Scene::pointIntersectsRect(Common::Point point, Common::Rect rect) {
return true;
}
-void Scene::getActorPosition(Actor *actor, Common::Point *pt) {
- if (!_ws)
- error("[Scene::getActorPosition] WorldStats not initialized properly!");
-
- pt->x = actor->getPoint1()->x - _ws->xLeft;
- pt->y = actor->getPoint1()->y - _ws->yTop;
-}
-
-// ----------------------------------
-// ---------- DEBUG REGION -----------
-// ----------------------------------
-
+//////////////////////////////////////////////////////////////////////////
+// Debug
+//////////////////////////////////////////////////////////////////////////
void Scene::debugScreenScrolling() {
if (!_ws)
error("[Scene::debugScreenScrolling] WorldStats not initialized properly!");
@@ -1586,22 +1544,4 @@ void Scene::debugShowActors() {
}
}
-int Scene::processActor(int *x, int *param) {
- error("[Scene::processActor] not implemented!");
-}
-
-void Scene::updatePalette(int32 param) {
- // TODO write small helper macro to get the resource id and move rest to screen class
- error("[Scene::updatePalette] not implemented!");
-}
-
-void Scene::makeGreyPalette() {
- // TODO write small helper macro to get the resource id and move rest to screen class
- warning("[Scene::makeGreyPalette] not implemented!");
-}
-
-void Scene::resetActor0() {
- error("[Scene::resetActor0] not implemented!");
-}
-
} // end of namespace Asylum
diff --git a/engines/asylum/views/scene.h b/engines/asylum/views/scene.h
index 9b654b4b12..7424905fcb 100644
--- a/engines/asylum/views/scene.h
+++ b/engines/asylum/views/scene.h
@@ -97,26 +97,17 @@ public:
*/
bool handleEvent(const AsylumEvent &ev);
- AsylumEngine* vm() { return _vm; }
-
- ActionList *actions() { return _actions; }
- Polygons *polygons() { return _polygons; }
- Special *special() { return _special; }
- Speech *speech() { return _speech; }
- WorldStats *worldstats() { return _ws; }
-
- /** .text:0040A1B0
- * Get the supplied actor's position relative to the
- * current scene's xLeft and yTop
- */
- void getActorPosition(Actor *actor, Common::Point *pt);
/**
- * Return the index of the current player actor
+ * Return the index of the player actor
*/
ActorIndex getPlayerIndex() { return _playerActorIdx; }
+ /**
+ * Sets the player actor index.
+ *
+ * @param index index of the player actor
+ */
void setPlayerActorIndex(ActorIndex index) { _playerActorIdx = index; }
- void changePlayer(ActorIndex index);
/**
* Gets the current scene pack identifier.
@@ -132,36 +123,50 @@ public:
*/
Actor* getActor(ActorIndex index = kActorInvalid);
- /** .text:00407260
- * Check the actor at actorIndex to see if the currently loaded
- * graphic resource matches the resource at grResTable[5]
+ /**
+ * Change player actor
+ *
+ * @param index new index for the player actor
*/
- bool defaultActorDirectionLoaded(int actorIndex, int grResTableIdx);
+ void changePlayer(ActorIndex index);
- /** .text:004094c0
- * Determine the amount to increase the supplied sound
- * sample's volume based on the actor's position
+ /**
+ * Updates the scene coordinates.
+ *
+ * @param targetX Target x coordinate.
+ * @param targetY Target y coordinate.
+ * @param val The value.
+ * @param checkSceneCoords true to check scene coordinates.
+ * @param [in,out] param If non-null, the parameter.
+ *
+ * @return true if it succeeds, false if it fails.
*/
- int32 calculateVolumeAdjustment(AmbientSoundItem *snd, Actor *act);
-
-
bool updateSceneCoordinates(int32 targetX, int32 targetY, int32 val, bool checkSceneCoords = false, int32 *param = NULL);
- int processActor(int *x, int *param);
-
- void updatePalette(int32 param);
- void makeGreyPalette();
-
- // Shared methods
- void resetActor0();
-
- /** .text:00408980
- * Determine if the supplied point intersects
- * an action area's active region
+ /**
+ * Determine if the supplied point intersects an action area's active region.
+ *
+ * @param pt The point.
+ *
+ * @return The found action area.
*/
int32 findActionArea(const Common::Point pt);
- int32 isInActionArea(const Common::Point &pt, ActionArea *area);
+ /**
+ * Determine if the supplied point is in the action area
+ *
+ * @param pt The point.
+ * @param [in,out] area If non-null, the area.
+ *
+ * @return
+ */
+ bool isInActionArea(const Common::Point &pt, ActionArea *area);
+
+ ActionList *actions() { return _actions; }
+ Polygons *polygons() { return _polygons; }
+ Special *special() { return _special; }
+ Speech *speech() { return _speech; }
+ WorldStats *worldstats() { return _ws; }
protected:
/** .text:0040EA50
Commit: 26cb6c985724c99f6eeaba15e45c759f7974f6a1
https://github.com/scummvm/scummvm/commit/26cb6c985724c99f6eeaba15e45c759f7974f6a1
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:30+02:00
Commit Message:
ASYLUM: Implement Scene mouse events
- Implement clickDown & clickUp event handlers
- Add cursor state setup
- Add stub for player hit test
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@621 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/asylum.cpp
engines/asylum/system/cursor.cpp
engines/asylum/system/cursor.h
engines/asylum/views/scene.cpp
engines/asylum/views/scene.h
diff --git a/engines/asylum/asylum.cpp b/engines/asylum/asylum.cpp
index db279258a3..13deb10a6e 100644
--- a/engines/asylum/asylum.cpp
+++ b/engines/asylum/asylum.cpp
@@ -288,7 +288,10 @@ void AsylumEngine::handleEvents() {
case Common::EVENT_LBUTTONUP:
case Common::EVENT_RBUTTONDOWN:
case Common::EVENT_RBUTTONUP:
+ case Common::EVENT_MBUTTONUP:
+ case Common::EVENT_MBUTTONDOWN:
// Handle mouse events
+ _cursor->setState(ev);
_handler->handleEvent(ev);
break;
diff --git a/engines/asylum/system/cursor.cpp b/engines/asylum/system/cursor.cpp
index 8c161685a7..f2ed1eb07f 100644
--- a/engines/asylum/system/cursor.cpp
+++ b/engines/asylum/system/cursor.cpp
@@ -36,7 +36,7 @@ namespace Asylum {
const uint32 CURSOR_UPDATE_TICKS = 100;
Cursor::Cursor(AsylumEngine *engine) : graphicResourceId(kResourceNone), currentFrame(0), frameCount(0), counter(0), flags(0), field_11(0),
- _vm(engine), _cursorRes(NULL), _cursorTicks(0), _cursor_byte_45756C(0) {
+ _vm(engine), _cursorRes(NULL), _cursorTicks(0), _cursor_byte_45756C(0), _state(0) {
}
@@ -96,6 +96,37 @@ void Cursor::update() {
0, 0, 0);
}
+void Cursor::setState(const Common::Event &evt) {
+ switch (evt.type) {
+ default:
+ break;
+
+ case Common::EVENT_LBUTTONDOWN:
+ _state |= kCursorLeft;
+ break;
+
+ case Common::EVENT_RBUTTONDOWN:
+ _state |= kCursorRight;
+ break;
+
+ case Common::EVENT_MBUTTONDOWN:
+ _state |= kCursorMiddle;
+ break;
+
+ case Common::EVENT_LBUTTONUP:
+ _state &= ~kCursorLeft;
+ break;
+
+ case Common::EVENT_RBUTTONUP:
+ _state &= ~kCursorRight;
+ break;
+
+ case Common::EVENT_MBUTTONUP:
+ _state &= ~kCursorMiddle;
+ break;
+ }
+}
+
/*
void Cursor::set(byte *data, byte width, byte height) {
CursorMan.replaceCursor(data, width, height, 0, 0, 0);
@@ -168,7 +199,7 @@ bool Cursor::isHidden() const {
return !CursorMan.isVisible();
}
-Common::Point Cursor::position() const {
+const Common::Point Cursor::position() const {
return g_system->getEventManager()->getMousePos();
}
diff --git a/engines/asylum/system/cursor.h b/engines/asylum/system/cursor.h
index a374565700..30988cd1a5 100644
--- a/engines/asylum/system/cursor.h
+++ b/engines/asylum/system/cursor.h
@@ -28,6 +28,7 @@
#include "asylum/shared.h"
+#include "common/events.h"
#include "common/rect.h"
namespace Asylum {
@@ -35,6 +36,12 @@ namespace Asylum {
class AsylumEngine;
class GraphicResource;
+enum CursorState {
+ kCursorLeft = 1,
+ kCursorRight = 2,
+ kCursorMiddle = 3
+};
+
/**
* Asylum cursors are GraphicResources, and are stored in
* ResourcePacks, as are all game assets.
@@ -82,10 +89,13 @@ public:
void update();
+ void setState(const Common::Event &evt);
+ byte getState() { return _state; }
+
/**
* Return the cursor's position on the screen
*/
- Common::Point position() const;
+ const Common::Point position() const;
// NOTE
// .text:00435060 contains a function that assigns global variables to a
@@ -106,6 +116,8 @@ public:
private:
AsylumEngine *_vm;
+ byte _state;
+
// Cursor resource
GraphicResource *_cursorRes;
diff --git a/engines/asylum/views/scene.cpp b/engines/asylum/views/scene.cpp
index 4e9ec63b2b..8c571620ca 100644
--- a/engines/asylum/views/scene.cpp
+++ b/engines/asylum/views/scene.cpp
@@ -62,7 +62,7 @@ Scene::Scene(AsylumEngine *engine): _vm(engine),
// Initialize data
_packId = kResourcePackInvalid;
- _playerActorIdx = 0;
+ _playerActorIndex = 0;
_walking = false;
g_debugPolygons = 0;
@@ -92,7 +92,7 @@ void Scene::enter(ResourcePackId packId) {
getCursor()->hide();
- _playerActorIdx = 0;
+ _playerActorIndex = 0;
// Load the scene data
load(packId);
@@ -246,7 +246,7 @@ Actor* Scene::getActor(ActorIndex index) {
if (!_ws)
error("[Scene::getActor] WorldStats not initialized properly!");
- ActorIndex computedIndex = (index != -1) ? index : _playerActorIdx;
+ ActorIndex computedIndex = (index != -1) ? index : _playerActorIndex;
if (computedIndex < 0 || computedIndex >= (int16)_ws->actors.size())
error("[Scene::getActor] Invalid actor index: %d ([0-%d] allowed)", computedIndex, _ws->actors.size() - 1);
@@ -295,6 +295,7 @@ bool Scene::handleEvent(const AsylumEvent &evt) {
return init();
case EVENT_ASYLUM_ACTIVATE:
+ case Common::EVENT_RBUTTONUP:
activate();
break;
@@ -306,11 +307,8 @@ bool Scene::handleEvent(const AsylumEvent &evt) {
case Common::EVENT_LBUTTONDOWN:
case Common::EVENT_RBUTTONDOWN:
+ case Common::EVENT_MBUTTONDOWN:
return clickDown(evt);
-
- case Common::EVENT_LBUTTONUP:
- case Common::EVENT_RBUTTONUP:
- return clickUp(evt);
}
return false;
@@ -398,18 +396,87 @@ bool Scene::clickDown(const AsylumEvent &evt) {
_vm->lastScreenUpdate = 0;
if (getSharedData()->getFlag(kFlag2)) {
- error("[Scene::clickDown] Not implemented!");
+ stopSpeech();
return true;
}
- error("[Scene::clickDown] Not implemented!");
-}
+ Actor *player = getActor();
+ switch (evt.type) {
+ default:
+ break;
-bool Scene::clickUp(const AsylumEvent &evt) {
- _vm->lastScreenUpdate = _vm->screenUpdateCount;
+ case Common::EVENT_RBUTTONDOWN:
+ if (getSpeech()->getSoundResourceId())
+ stopSpeech();
+
+ if (player->getStatus() == kActorStatus6 || player->getStatus() == kActorStatus10) {
+ player->updateStatus(kActorStatusEnabled);
+ getSound()->playSound(MAKE_RESOURCE(kResourcePackSound, 5));
+ } else if (player->getStatus() != kActorStatusDisabled) {
+ player->updateStatus(kActorStatus1);
+ }
+ break;
+
+ case Common::EVENT_MBUTTONDOWN:
+ if (player->getStatus() != kActorStatusDisabled) {
+ if (player->getStatus() == kActorStatus6 || player->getStatus() == kActorStatus10)
+ player->updateStatus(kActorStatusEnabled);
+ else
+ player->updateStatus(kActorStatus6);
+ }
+ break;
- error("[Scene::clickRightUp] Not implemented!");
+ case Common::EVENT_LBUTTONDOWN:
+ if (getCursor()->getState() & kCursorRight)
+ break;
+
+ if (getSpeech()->getSoundResourceId())
+ stopSpeech();
+
+ if (player->getStatus() == kActorStatusDisabled)
+ break;
+
+ if (player->getField638()) {
+ if (hitTestPlayer()) {
+ player->setField638(0);
+ return true;
+ }
+
+ HitType type = kHitNone;
+ int32 res = hitTestScene(type);
+
+ if (res == -1)
+ getSpeech()->playIndexed(2);
+ else
+ handleHit(res, type);
+
+ return true;
+ }
+
+ if (!hitTestPlayer() || player->getStatus() >= kActorStatus11 || !player->getReaction(0)) {
+ if (player->getStatus() == kActorStatus6 || player->getStatus() == kActorStatus10) {
+ playerReaction();
+ } else {
+ HitType type = kHitNone;
+ int32 res = hitTest(type);
+ if (res != -1)
+ handleHit(res, type);
+ }
+ return true;
+ }
+
+ if (player->getStatus() == kActorStatus6 || player->getStatus() == kActorStatus10) {
+ getSound()->playSound(MAKE_RESOURCE(kResourcePackSound, 5));
+ player->updateStatus(kActorStatusEnabled);
+ } else {
+ getSound()->playSound(MAKE_RESOURCE(kResourcePackSound, 2));
+ player->updateStatus(kActorStatus6);
+ }
+ break;
+ }
+
+ return true;
}
//////////////////////////////////////////////////////////////////////////
@@ -514,7 +581,7 @@ void Scene::updateMouse() {
pt.x = (int16)(act->getPoint1()->x -_ws->xLeft);
pt.y = (int16)(act->getPoint1()->y -_ws->yTop);
- if (_packId != 2 || _playerActorIdx != 10) {
+ if (_packId != 2 || _playerActorIndex != 10) {
actorPos.left = pt.x + 20;
actorPos.top = pt.y;
actorPos.right = (int16)(pt.x + 2 * act->getPoint2()->x);
@@ -681,7 +748,7 @@ void Scene::updateCursor(int direction, Common::Rect rect) {
if (act->getField638()) {
if (getCursor()->position().x >= rect.left && getCursor()->position().x <= rlimit &&
getCursor()->position().y >= rect.top && getCursor()->position().y <= rect.bottom &&
- hitTestActor(getCursor()->position())) {
+ hitTestActor()) {
// TODO LOTS of work here, because apparently we need to use
// field_638 as an index into _ws->field_D6AC8, which is not
// yet defined as part of worldstats, but according to IDA, is:
@@ -692,7 +759,7 @@ void Scene::updateCursor(int direction, Common::Rect rect) {
} else {
// TODO pass a reference to hitType so it can be populated by
// hitTestScene
- newGraphicResourceId = hitTestScene(getCursor()->position(), type);
+ newGraphicResourceId = hitTestScene(type);
if (newGraphicResourceId != (ResourceId)-1) {
warning ("Can't set mouse cursor, field_D6AC8 not handled ... yet");
// TODO
@@ -705,19 +772,19 @@ void Scene::updateCursor(int direction, Common::Rect rect) {
}
return; // return result;
}
- int32 targetIdx = hitTest(getCursor()->position(), type);
+ int32 targetIdx = hitTest(type);
//printf ("Mouse X(%d)/Y(%d) = %d\n", getCursor()->position().x, getCursor()->position().y, type);
if (getCursor()->position().x >= rect.left && getCursor()->position().x <= rlimit &&
getCursor()->position().y >= rect.top && getCursor()->position().y <= rect.bottom &&
- hitTestActor(getCursor()->position())) {
+ hitTestActor()) {
if (act->getReaction(0)) {
getCursor()->set(_ws->curGrabPointer, 0, 2);
return;
}
}
if (targetIdx == -1) {
- if (_ws->chapter != kChapter2 || _playerActorIdx != 10) {
+ if (_ws->chapter != kChapter2 || _playerActorIndex != 10) {
if (getCursor()->flags)
getCursor()->set(_ws->curMagnifyingGlass, 0, 2);
} else {
@@ -753,7 +820,7 @@ void Scene::updateCursor(int direction, Common::Rect rect) {
if (targetUpdateType & 0x10 && getCursor()->flags != 2) {
getCursor()->set(_ws->curTalkNPC2, 0, 2);
} else {
- if (_ws->chapter != kChapter2 && _playerActorIdx != 10) {
+ if (_ws->chapter != kChapter2 && _playerActorIndex != 10) {
getCursor()->set(_ws->curMagnifyingGlass, 0, 0);
} else {
if (getCursor()->flags)
@@ -769,10 +836,12 @@ void Scene::updateCursor(int direction, Common::Rect rect) {
}
-int32 Scene::hitTestObject(const Common::Point pt) {
+int32 Scene::hitTestObject() {
if (!_ws)
error("[Scene::hitTestObject] WorldStats not initialized properly!");
+ const Common::Point pt = getCursor()->position();
+
int32 targetIdx = -1;
for (uint32 i = 0; i < _ws->objects.size(); i++) {
Object *object = _ws->objects[i];
@@ -786,14 +855,14 @@ int32 Scene::hitTestObject(const Common::Point pt) {
return targetIdx;
}
-int32 Scene::hitTest(const Common::Point pt, HitType &type) {
+int32 Scene::hitTest(HitType &type) {
type = kHitNone;
- int32 targetIdx = hitTestObject(pt);
+ int32 targetIdx = hitTestObject();
if (targetIdx == -1) {
- targetIdx = hitTestActionArea(pt);
+ targetIdx = hitTestActionArea();
if (targetIdx == -1) {
- if (hitTestActor(pt)) {
- targetIdx = _playerActorIdx;
+ if (hitTestActor()) {
+ targetIdx = _playerActorIndex;
type = kHitActor;
}
} else {
@@ -805,7 +874,17 @@ int32 Scene::hitTest(const Common::Point pt, HitType &type) {
return targetIdx;
}
-int32 Scene::hitTestActionArea(const Common::Point pt) {
+void Scene::handleHit(int32 index, HitType type) {
+ error("[Scene::handleHit] Not implemented!");
+}
+
+void Scene::playerReaction() {
+ error("[Scene::playerReaction] Not implemented!");
+}
+
+int32 Scene::hitTestActionArea() {
+ const Common::Point pt = getCursor()->position();
+
int32 targetIdx = findActionArea(Common::Point(_ws->xLeft + pt.x, _ws->yTop + pt.y));
if ( targetIdx == -1 || !(_ws->actions[targetIdx]->actionType & 0x17))
@@ -841,10 +920,12 @@ bool Scene::isInActionArea(const Common::Point &pt, ActionArea *area) {
error("[Scene::isInActionArea] Not implemented!");
}
-ResourceId Scene::hitTestScene(const Common::Point pt, HitType &type) {
+ResourceId Scene::hitTestScene(HitType &type) {
if (!_ws)
error("[Scene::hitTestScene] WorldStats not initialized properly!");
+ const Common::Point pt = getCursor()->position();
+
int32 top = pt.x + _ws->xLeft;
int32 left = pt.y + _ws->yTop;
type = kHitNone;
@@ -863,7 +944,9 @@ ResourceId Scene::hitTestScene(const Common::Point pt, HitType &type) {
return result;
}
-bool Scene::hitTestActor(const Common::Point pt) {
+bool Scene::hitTestActor() {
+ const Common::Point pt = getCursor()->position();
+
Actor *act = getActor();
Common::Point actPos;
act->adjustCoordinates(&actPos);
@@ -881,6 +964,12 @@ bool Scene::hitTestActor(const Common::Point pt) {
(act->getDirection() >= 0));
}
+bool Scene::hitTestPlayer() {
+ const Common::Point pt = getCursor()->position();
+
+ error("[Scene::hitTestPlayer] Not implemented!");
+}
+
bool Scene::hitTestPixel(ResourceId resourceId, int32 frame, int16 x, int16 y, bool flipped) {
// TODO this gets a bit funky with the "flipped" calculations for x intersection
// The below is a pretty basic intersection test for proof of concept
@@ -1032,6 +1121,15 @@ void Scene::playIntroSpeech() {
warning("[Scene::playIntroSpeech] Missing palette fade and wait!");
}
+void Scene::stopSpeech() {
+ if (_vm->isGameFlagSet(kGameFlag219)) {
+ if (getSpeech()->getSoundResourceId() != kResourceNone && getSound()->isPlaying(getSpeech()->getSoundResourceId()))
+ getSound()->stopAll(getSpeech()->getSoundResourceId());
+ else if (getSpeech()->getTick())
+ getSpeech()->setTick(_vm->getTick());
+ }
+}
+
void Scene::updateCoordinates() {
Actor *act = getActor();
int32 newXLeft = -1;
diff --git a/engines/asylum/views/scene.h b/engines/asylum/views/scene.h
index 7424905fcb..19ae6e03eb 100644
--- a/engines/asylum/views/scene.h
+++ b/engines/asylum/views/scene.h
@@ -100,14 +100,14 @@ public:
/**
* Return the index of the player actor
*/
- ActorIndex getPlayerIndex() { return _playerActorIdx; }
+ ActorIndex getPlayerIndex() { return _playerActorIndex; }
/**
* Sets the player actor index.
*
* @param index index of the player actor
*/
- void setPlayerActorIndex(ActorIndex index) { _playerActorIdx = index; }
+ void setPlayerActorIndex(ActorIndex index) { _playerActorIndex = index; }
/**
* Gets the current scene pack identifier.
@@ -168,44 +168,11 @@ public:
Speech *speech() { return _speech; }
WorldStats *worldstats() { return _ws; }
-protected:
- /** .text:0040EA50
- * Run various hit tests and return the index,
- * and a reference to the located type
- */
- int32 hitTest(const Common::Point pt, HitType &type);
- /** .text:0040F010
- * TODO
- */
- int32 hitTestActionArea(const Common::Point pt);
- /** .text:0040E7F0
- * Check if the mouse cursor is currently intersecting
- * the currently active actor
- */
- bool hitTestActor(const Common::Point pt);
- /** .text:004341E0
- * Check if the mouse cursor is currently intersecting
- * a graphic resource at the supplied coordinates
- */
- bool hitTestPixel(ResourceId resourceId, int32 frame, int16 x, int16 y, bool flipped);
- /** .text:0040E8A0
- * Checks if the supplied coordinates are inside an action area, object or
- * actor, and returns -1 if nothing was found, or the type of hit if found
- */
- ResourceId hitTestScene(const Common::Point pt, HitType &type);
-
- /** .text:0040EAA0
- * Check if a object exist at the supplied coordinates.
- * If so, return it's index within the objects array, if not,
- * return -1
- */
- int32 hitTestObject(const Common::Point pt);
-
private:
AsylumEngine *_vm;
ResourcePackId _packId;
- int32 _playerActorIdx;
+ int32 _playerActorIndex;
bool _walking;
@@ -231,7 +198,6 @@ private:
bool update();
bool key(const AsylumEvent &evt);
bool clickDown(const AsylumEvent &evt);
- bool clickUp(const AsylumEvent &evt);
//////////////////////////////////////////////////////////////////////////
// Scene update
@@ -309,11 +275,60 @@ private:
void checkVisibleActorsPriority();
void adjustActorPriority(ActorIndex index);
+ //////////////////////////////////////////////////////////////////////////
+ // HitTest
+ //////////////////////////////////////////////////////////////////////////
+
+ /** .text:0040EA50
+ * Run various hit tests and return the index,
+ * and a reference to the located type
+ */
+ int32 hitTest(HitType &type);
+
+ /** .text:0040F010
+ * TODO
+ */
+ int32 hitTestActionArea();
+
+ /** .text:0040E7F0
+ * Check if the mouse cursor is currently intersecting
+ * the currently active actor
+ */
+ bool hitTestActor();
+
+ /**
+ * Check if the mouse cursor is currently intersecting the player
+ */
+ bool hitTestPlayer();
+
+ /** .text:004341E0
+ * Check if the mouse cursor is currently intersecting
+ * a graphic resource at the supplied coordinates
+ */
+ bool hitTestPixel(ResourceId resourceId, int32 frame, int16 x, int16 y, bool flipped);
+
+ /** .text:0040E8A0
+ * Checks if the supplied coordinates are inside an action area, object or
+ * actor, and returns -1 if nothing was found, or the type of hit if found
+ */
+ ResourceId hitTestScene(HitType &type);
+
+ /** .text:0040EAA0
+ * Check if a object exist at the supplied coordinates.
+ * If so, return it's index within the objects array, if not,
+ * return -1
+ */
+ int32 hitTestObject();
+
+ void handleHit(int32 index, HitType type);
+
+ void playerReaction();
+
//////////////////////////////////////////////////////////////////////////
// Helpers
//////////////////////////////////////////////////////////////////////////
void playIntroSpeech();
-
+ void stopSpeech();
bool pointIntersectsRect(Common::Point point, Common::Rect rect);
//////////////////////////////////////////////////////////////////////////
Commit: 1b8bf435702e1b08e3450340a43748c2840d41e8
https://github.com/scummvm/scummvm/commit/1b8bf435702e1b08e3450340a43748c2840d41e8
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:30+02:00
Commit Message:
ASYLUM: Cleanup Scene and add documentation
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@622 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/views/scene.cpp
engines/asylum/views/scene.h
diff --git a/engines/asylum/views/scene.cpp b/engines/asylum/views/scene.cpp
index 8c571620ca..6a4a178309 100644
--- a/engines/asylum/views/scene.cpp
+++ b/engines/asylum/views/scene.cpp
@@ -242,47 +242,6 @@ void Scene::load(ResourcePackId packId) {
getCursor()->show();
}
-Actor* Scene::getActor(ActorIndex index) {
- if (!_ws)
- error("[Scene::getActor] WorldStats not initialized properly!");
-
- ActorIndex computedIndex = (index != -1) ? index : _playerActorIndex;
-
- if (computedIndex < 0 || computedIndex >= (int16)_ws->actors.size())
- error("[Scene::getActor] Invalid actor index: %d ([0-%d] allowed)", computedIndex, _ws->actors.size() - 1);
-
- return _ws->actors[computedIndex];
-}
-
-//void Scene::setScenePosition(int x, int y) {
-// if (!_ws)
-// error("[Scene::setScenePosition] WorldStats not initialized properly!");
-//
-// if (!_bgResource)
-// error("[Scene::setScenePosition] Scene resources not initialized properly!");
-//
-// GraphicFrame *bg = _bgResource->getFrame(0);
-// //_startX = x;
-// //_startY = y;
-//
-// int32 *targetX = &_ws->coordinates[0];
-// int32 *targetY = &_ws->coordinates[1];
-//
-// *targetX = x;
-// *targetY = y;
-//
-// if (*targetX < 0)
-// *targetX = 0;
-// if (*targetX > (bg->surface.w - 640))
-// *targetX = bg->surface.w - 640;
-//
-//
-// if (*targetY < 0)
-// *targetY = 0;
-// if (*targetY > (bg->surface.h - 480))
-// *targetY = bg->surface.h - 480;
-//}
-
//////////////////////////////////////////////////////////////////////////
// Event handling
//////////////////////////////////////////////////////////////////////////
@@ -718,6 +677,174 @@ void Scene::updateMouse() {
}
}
+
+void Scene::updateActors() {
+ if (!_ws)
+ error("[Scene::updateActors] WorldStats not initialized properly!");
+
+ for (uint32 i = 0; i < _ws->actors.size(); i++)
+ _ws->actors[i]->update();
+}
+
+void Scene::updateObjects() {
+ if (!_ws)
+ error("[Scene::updateObjects] WorldStats not initialized properly!");
+
+ for (uint32 i = 0; i < _ws->objects.size(); i++)
+ _ws->objects[i]->update();
+}
+
+void Scene::updateAmbientSounds() {
+ if (!_ws)
+ error("[Scene::updateAmbientSounds] WorldStats not initialized properly!");
+
+ if (Config.performance <= 3)
+ return;
+
+ for (int32 i = 0; i < _ws->numAmbientSound; i++) {
+ bool processSound = true;
+ int panning = 0;
+ int volume = 0;
+ AmbientSoundItem *snd = &_ws->ambientSounds[i];
+
+ for (int32 f = 0; f < 6; f++) {
+ GameFlag gameFlag = snd->flagNum[f];
+ if (gameFlag >= 0) {
+ if (_vm->isGameFlagNotSet(gameFlag)) {
+ processSound = false;
+ break;
+ }
+ } else {
+ if (_vm->isGameFlagSet((GameFlag)-gameFlag)) {
+ processSound = false;
+ break;
+ }
+ }
+ }
+ if (processSound) {
+ if (_vm->sound()->isPlaying(snd->resourceId)) {
+ if (snd->field_0) {
+ // TODO optimize
+ // This adjustment only uses the actor at
+ // index zero, but it's supposed to loop through
+ // all available actors as well (I think)
+ volume = getSound()->calculateVolumeAdjustement(snd->x, snd->y, snd->attenuation, snd->delta);
+ if (volume <= 0) {
+ if (volume < -10000)
+ volume = -10000;
+ // TODO setSoundVolume(snd->resourceId, volume);
+ } else
+ ; // TODO setSoundVolume(snd->resourceId, 0);
+ }
+ } else {
+ int loflag = BYTE1(snd->flags);
+ if (snd->field_0) {
+ ; // TODO calculate panning at point
+ } else {
+ panning = 0;
+ }
+ if (snd->field_0 == 0) {
+ volume = -(snd->delta ^ 2);
+ } else {
+ volume = getSound()->calculateVolumeAdjustement(snd->x, snd->y, snd->attenuation, snd->delta);
+ volume += Config.ambientVolume;
+ }
+ if (loflag & 2) {
+ int tmpVol = volume;
+ if (_vm->getRandom(10000) < 10) {
+ if (snd->field_0) {
+ getSound()->playSound(snd->resourceId, false, volume, panning);
+ } else {
+ // FIXME will this even work?
+ tmpVol += (_vm->getRandom(500)) * (((_vm->getRandom(100) >= 50) - 1) & 2) - 1;
+ if (tmpVol <= -10000)
+ volume = -10000;
+ if (volume >= 0)
+ tmpVol = 0;
+ else
+ if (tmpVol <= -10000)
+ tmpVol = -10000;
+ getSound()->playSound(snd->resourceId, false, tmpVol, _vm->getRandom(20001) - 10000);
+ }
+ }
+ } else {
+ if (loflag & 4) {
+ // TODO panning array stuff
+ }
+ }
+ }
+ } else {
+ if (_vm->sound()->isPlaying(snd->resourceId))
+ _vm->sound()->stop(snd->resourceId);
+ }
+ }
+}
+
+void Scene::updateMusic() {
+ //warning("[Scene::updateMusic] not implemented!");
+}
+
+void Scene::updateAdjustScreen() {
+ if (g_debugScrolling) {
+ debugScreenScrolling();
+ } else {
+ updateCoordinates();
+ }
+}
+
+void Scene::updateCoordinates() {
+ Actor *act = getActor();
+ int32 newXLeft = -1;
+ int32 newYTop = -1;
+ Common::Rect b = _ws->boundingRect;
+
+ if (_ws->motionStatus == 1) {
+ int32 posX = act->getPoint1()->x - _ws->xLeft;
+ int32 posY = act->getPoint1()->y - _ws->yTop;
+
+ if (posX < b.left || posX > b.right) {
+ int32 newRBounds = posX - b.right;
+ newXLeft = newRBounds + _ws->xLeft;
+ _ws->xLeft += newRBounds;
+ }
+
+ if (posY < b.top || posY > b.bottom) {
+ int32 newBBounds = posY - b.bottom;
+ newYTop = newBBounds + _ws->yTop;
+ _ws->yTop += newBBounds;
+ }
+
+ if (newXLeft < 0)
+ newXLeft = _ws->xLeft = 0;
+
+ if (newXLeft > _ws->width - 640)
+ newXLeft = _ws->xLeft = _ws->width - 640;
+
+ if (newYTop < 0)
+ newYTop = _ws->yTop = 0;
+
+ if (newYTop > _ws->height - 480)
+ newYTop = _ws->yTop = _ws->height - 480;
+ } else {
+ // TODO
+ }
+
+ uint8 rectIndex = _ws->sceneRectIdx;
+ b = _ws->sceneRects[rectIndex];
+
+ if (newXLeft < b.left)
+ newXLeft = _ws->xLeft = b.left;
+
+ if (newYTop < b.top)
+ newYTop = _ws->yTop = b.top;
+
+ if (newXLeft + 639 > b.right)
+ newXLeft = _ws->xLeft = b.right - 639;
+
+ if (newYTop + 479 > b.bottom)
+ newYTop = _ws->yTop = b.bottom - 479;
+}
+
void Scene::updateCursor(int direction, Common::Rect rect) {
int16 rlimit = rect.right - 10;
ResourceId newGraphicResourceId;
@@ -836,25 +963,9 @@ void Scene::updateCursor(int direction, Common::Rect rect) {
}
-int32 Scene::hitTestObject() {
- if (!_ws)
- error("[Scene::hitTestObject] WorldStats not initialized properly!");
-
- const Common::Point pt = getCursor()->position();
-
- int32 targetIdx = -1;
- for (uint32 i = 0; i < _ws->objects.size(); i++) {
- Object *object = _ws->objects[i];
- if (object->isOnScreen())
- if (object->getPolygonIndex())
- if (hitTestPixel(object->getResourceId(), object->getFrameIndex(), pt.x, pt.y, object->flags & 0x1000)) {
- targetIdx = i;
- break;
- }
- }
- return targetIdx;
-}
-
+//////////////////////////////////////////////////////////////////////////
+// HitTest
+//////////////////////////////////////////////////////////////////////////
int32 Scene::hitTest(HitType &type) {
type = kHitNone;
int32 targetIdx = hitTestObject();
@@ -874,52 +985,6 @@ int32 Scene::hitTest(HitType &type) {
return targetIdx;
}
-void Scene::handleHit(int32 index, HitType type) {
- error("[Scene::handleHit] Not implemented!");
-}
-
-void Scene::playerReaction() {
- error("[Scene::playerReaction] Not implemented!");
-}
-
-int32 Scene::hitTestActionArea() {
- const Common::Point pt = getCursor()->position();
-
- int32 targetIdx = findActionArea(Common::Point(_ws->xLeft + pt.x, _ws->yTop + pt.y));
-
- if ( targetIdx == -1 || !(_ws->actions[targetIdx]->actionType & 0x17))
- targetIdx = -1;
-
- return targetIdx;
-}
-
-int32 Scene::findActionArea(const Common::Point pt) {
- if (!_ws)
- error("[Scene::findActionArea] WorldStats not initialized properly!");
-
- if (!_polygons)
- error("[Scene::findActionArea] Polygons not initialized properly!");
-
- // TODO
- // This is a VERY loose implementation of the target
- // function, as this doesn't do any of the flag checking
- // the original did
- int32 targetIdx = -1;
- for (uint32 i = 0; i < _ws->actions.size(); i++) {
- ActionArea *a = _ws->actions[i];
- PolyDefinitions p = _polygons->entries[a->polyIdx];
- if (p.contains(pt.x, pt.y)) {
- targetIdx = i;
- break;
- }
- }
- return targetIdx;
-}
-
-bool Scene::isInActionArea(const Common::Point &pt, ActionArea *area) {
- error("[Scene::isInActionArea] Not implemented!");
-}
-
ResourceId Scene::hitTestScene(HitType &type) {
if (!_ws)
error("[Scene::hitTestScene] WorldStats not initialized properly!");
@@ -944,6 +1009,17 @@ ResourceId Scene::hitTestScene(HitType &type) {
return result;
}
+int32 Scene::hitTestActionArea() {
+ const Common::Point pt = getCursor()->position();
+
+ int32 targetIdx = findActionArea(Common::Point(_ws->xLeft + pt.x, _ws->yTop + pt.y));
+
+ if ( targetIdx == -1 || !(_ws->actions[targetIdx]->actionType & 0x17))
+ targetIdx = -1;
+
+ return targetIdx;
+}
+
bool Scene::hitTestActor() {
const Common::Point pt = getCursor()->position();
@@ -970,130 +1046,42 @@ bool Scene::hitTestPlayer() {
error("[Scene::hitTestPlayer] Not implemented!");
}
-bool Scene::hitTestPixel(ResourceId resourceId, int32 frame, int16 x, int16 y, bool flipped) {
- // TODO this gets a bit funky with the "flipped" calculations for x intersection
- // The below is a pretty basic intersection test for proof of concept
- return GraphicResource::getFrameRect(_vm, resourceId, frame).contains(x, y);
-}
-
-void Scene::changePlayer(ActorIndex index) {
- error("[Scene::changePlayer] not implemented");
-}
-
-void Scene::updateActors() {
- if (!_ws)
- error("[Scene::updateActors] WorldStats not initialized properly!");
-
- for (uint32 i = 0; i < _ws->actors.size(); i++)
- _ws->actors[i]->update();
-}
-
-void Scene::updateObjects() {
- if (!_ws)
- error("[Scene::updateObjects] WorldStats not initialized properly!");
-
- for (uint32 i = 0; i < _ws->objects.size(); i++)
- _ws->objects[i]->update();
-}
-
-void Scene::updateAmbientSounds() {
+int32 Scene::hitTestObject() {
if (!_ws)
- error("[Scene::updateAmbientSounds] WorldStats not initialized properly!");
-
- if (Config.performance <= 3)
- return;
+ error("[Scene::hitTestObject] WorldStats not initialized properly!");
- for (int32 i = 0; i < _ws->numAmbientSound; i++) {
- bool processSound = true;
- int panning = 0;
- int volume = 0;
- AmbientSoundItem *snd = &_ws->ambientSounds[i];
+ const Common::Point pt = getCursor()->position();
- for (int32 f = 0; f < 6; f++) {
- GameFlag gameFlag = snd->flagNum[f];
- if (gameFlag >= 0) {
- if (_vm->isGameFlagNotSet(gameFlag)) {
- processSound = false;
- break;
- }
- } else {
- if (_vm->isGameFlagSet((GameFlag)-gameFlag)) {
- processSound = false;
+ int32 targetIdx = -1;
+ for (uint32 i = 0; i < _ws->objects.size(); i++) {
+ Object *object = _ws->objects[i];
+ if (object->isOnScreen())
+ if (object->getPolygonIndex())
+ if (hitTestPixel(object->getResourceId(), object->getFrameIndex(), pt.x, pt.y, object->flags & 0x1000)) {
+ targetIdx = i;
break;
}
- }
- }
- if (processSound) {
- if (_vm->sound()->isPlaying(snd->resourceId)) {
- if (snd->field_0) {
- // TODO optimize
- // This adjustment only uses the actor at
- // index zero, but it's supposed to loop through
- // all available actors as well (I think)
- volume = getSound()->calculateVolumeAdjustement(snd->x, snd->y, snd->attenuation, snd->delta);
- if (volume <= 0) {
- if (volume < -10000)
- volume = -10000;
- // TODO setSoundVolume(snd->resourceId, volume);
- } else
- ; // TODO setSoundVolume(snd->resourceId, 0);
- }
- } else {
- int loflag = BYTE1(snd->flags);
- if (snd->field_0) {
- ; // TODO calculate panning at point
- } else {
- panning = 0;
- }
- if (snd->field_0 == 0) {
- volume = -(snd->delta ^ 2);
- } else {
- volume = getSound()->calculateVolumeAdjustement(snd->x, snd->y, snd->attenuation, snd->delta);
- volume += Config.ambientVolume;
- }
- if (loflag & 2) {
- int tmpVol = volume;
- if (_vm->getRandom(10000) < 10) {
- if (snd->field_0) {
- getSound()->playSound(snd->resourceId, false, volume, panning);
- } else {
- // FIXME will this even work?
- tmpVol += (_vm->getRandom(500)) * (((_vm->getRandom(100) >= 50) - 1) & 2) - 1;
- if (tmpVol <= -10000)
- volume = -10000;
- if (volume >= 0)
- tmpVol = 0;
- else
- if (tmpVol <= -10000)
- tmpVol = -10000;
- getSound()->playSound(snd->resourceId, false, tmpVol, _vm->getRandom(20001) - 10000);
- }
- }
- } else {
- if (loflag & 4) {
- // TODO panning array stuff
- }
- }
- }
- } else {
- if (_vm->sound()->isPlaying(snd->resourceId))
- _vm->sound()->stop(snd->resourceId);
- }
}
+ return targetIdx;
}
-void Scene::updateMusic() {
- //warning("[Scene::updateMusic] not implemented!");
+bool Scene::hitTestPixel(ResourceId resourceId, int32 frame, int16 x, int16 y, bool flipped) {
+ // TODO this gets a bit funky with the "flipped" calculations for x intersection
+ // The below is a pretty basic intersection test for proof of concept
+ return GraphicResource::getFrameRect(_vm, resourceId, frame).contains(x, y);
}
-void Scene::updateAdjustScreen() {
- if (g_debugScrolling) {
- debugScreenScrolling();
- } else {
- updateCoordinates();
- }
+void Scene::handleHit(int32 index, HitType type) {
+ error("[Scene::handleHit] Not implemented!");
}
+void Scene::playerReaction() {
+ error("[Scene::playerReaction] Not implemented!");
+}
+
+//////////////////////////////////////////////////////////////////////////
+// Helpers
+//////////////////////////////////////////////////////////////////////////
void Scene::playIntroSpeech() {
ResourceId resourceId;
@@ -1130,58 +1118,26 @@ void Scene::stopSpeech() {
}
}
-void Scene::updateCoordinates() {
- Actor *act = getActor();
- int32 newXLeft = -1;
- int32 newYTop = -1;
- Common::Rect b = _ws->boundingRect;
-
- if (_ws->motionStatus == 1) {
- int32 posX = act->getPoint1()->x - _ws->xLeft;
- int32 posY = act->getPoint1()->y - _ws->yTop;
-
- if (posX < b.left || posX > b.right) {
- int32 newRBounds = posX - b.right;
- newXLeft = newRBounds + _ws->xLeft;
- _ws->xLeft += newRBounds;
- }
-
- if (posY < b.top || posY > b.bottom) {
- int32 newBBounds = posY - b.bottom;
- newYTop = newBBounds + _ws->yTop;
- _ws->yTop += newBBounds;
- }
-
- if (newXLeft < 0)
- newXLeft = _ws->xLeft = 0;
-
- if (newXLeft > _ws->width - 640)
- newXLeft = _ws->xLeft = _ws->width - 640;
-
- if (newYTop < 0)
- newYTop = _ws->yTop = 0;
+bool Scene::pointIntersectsRect(Common::Point point, Common::Rect rect) {
+ if (rect.top || rect.left || rect.bottom || rect.right) {
+ Common::Rational res((rect.bottom - rect.top) * (point.x - rect.left), rect.right - rect.left);
- if (newYTop > _ws->height - 480)
- newYTop = _ws->yTop = _ws->height - 480;
- } else {
- // TODO
+ return (bool)(point.y > rect.top ? 1 + res.toInt() : res.toInt());
}
- uint8 rectIndex = _ws->sceneRectIdx;
- b = _ws->sceneRects[rectIndex];
-
- if (newXLeft < b.left)
- newXLeft = _ws->xLeft = b.left;
+ return true;
+}
- if (newYTop < b.top)
- newYTop = _ws->yTop = b.top;
+Actor* Scene::getActor(ActorIndex index) {
+ if (!_ws)
+ error("[Scene::getActor] WorldStats not initialized properly!");
- if (newXLeft + 639 > b.right)
- newXLeft = _ws->xLeft = b.right - 639;
+ ActorIndex computedIndex = (index != -1) ? index : _playerActorIndex;
- if (newYTop + 479 > b.bottom)
- newYTop = _ws->yTop = b.bottom - 479;
+ if (computedIndex < 0 || computedIndex >= (int16)_ws->actors.size())
+ error("[Scene::getActor] Invalid actor index: %d ([0-%d] allowed)", computedIndex, _ws->actors.size() - 1);
+ return _ws->actors[computedIndex];
}
bool Scene::updateSceneCoordinates(int32 tX, int32 tY, int32 A0, bool checkSceneCoords, int32 *param) {
@@ -1254,6 +1210,39 @@ bool Scene::updateSceneCoordinates(int32 tX, int32 tY, int32 A0, bool checkScene
return false;
}
+
+int32 Scene::findActionArea(const Common::Point pt) {
+ if (!_ws)
+ error("[Scene::findActionArea] WorldStats not initialized properly!");
+
+ if (!_polygons)
+ error("[Scene::findActionArea] Polygons not initialized properly!");
+
+ // TODO
+ // This is a VERY loose implementation of the target
+ // function, as this doesn't do any of the flag checking
+ // the original did
+ int32 targetIdx = -1;
+ for (uint32 i = 0; i < _ws->actions.size(); i++) {
+ ActionArea *a = _ws->actions[i];
+ PolyDefinitions p = _polygons->entries[a->polyIdx];
+ if (p.contains(pt.x, pt.y)) {
+ targetIdx = i;
+ break;
+ }
+ }
+ return targetIdx;
+}
+
+bool Scene::isInActionArea(const Common::Point &pt, ActionArea *area) {
+ error("[Scene::isInActionArea] Not implemented!");
+}
+
+
+void Scene::changePlayer(ActorIndex index) {
+ error("[Scene::changePlayer] not implemented");
+}
+
//////////////////////////////////////////////////////////////////////////
// Scene drawing
//////////////////////////////////////////////////////////////////////////
@@ -1321,7 +1310,7 @@ bool Scene::drawScene() {
}
bool Scene::updateListCompare(const UpdateItem &item1, const UpdateItem &item2) {
- return item1.priority - item2.priority;
+ return (item1.priority - item2.priority < 0) ? false : true;
}
void Scene::buildUpdateList() {
@@ -1520,19 +1509,6 @@ void Scene::adjustActorPriority(ActorIndex index) {
error("[Scene::adjustActorPriority] not implemented");
}
-//////////////////////////////////////////////////////////////////////////
-// Helpers
-//////////////////////////////////////////////////////////////////////////
-bool Scene::pointIntersectsRect(Common::Point point, Common::Rect rect) {
- if (rect.top || rect.left || rect.bottom || rect.right) {
- Common::Rational res((rect.bottom - rect.top) * (point.x - rect.left), rect.right - rect.left);
-
- return (bool)(point.y > rect.top ? 1 + res.toInt() : res.toInt());
- }
-
- return true;
-}
-
//////////////////////////////////////////////////////////////////////////
// Debug
//////////////////////////////////////////////////////////////////////////
diff --git a/engines/asylum/views/scene.h b/engines/asylum/views/scene.h
index 19ae6e03eb..fa25d65c34 100644
--- a/engines/asylum/views/scene.h
+++ b/engines/asylum/views/scene.h
@@ -265,70 +265,150 @@ private:
//////////////////////////////////////////////////////////////////////////
// Scene drawing
//////////////////////////////////////////////////////////////////////////
- void preload(); // Draw the loading screen
+
+ /**
+ * Draw the loading screen
+ */
+ void preload();
+
+ /**
+ * Draw the scene
+ *
+ * @return true if it succeeds, false if it fails.
+ */
bool drawScene();
+ /**
+ * Builds the update list.
+ */
void buildUpdateList();
+
+ /**
+ * Process the update list.
+ */
void processUpdateList();
+
+ /**
+ * Compare two items priority on the update list
+ *
+ * @param item1 The first item.
+ * @param item2 The second item.
+ *
+ * @return true item1 priority is superior to item2 priority, false otherwise
+ */
static bool updateListCompare(const UpdateItem &item1, const UpdateItem &item2);
+ /**
+ * Check visible actors priority.
+ */
void checkVisibleActorsPriority();
+
+ /**
+ * Adjust actor priority.
+ *
+ * @param index Zero-based index of the actor
+ */
void adjustActorPriority(ActorIndex index);
//////////////////////////////////////////////////////////////////////////
// HitTest
//////////////////////////////////////////////////////////////////////////
- /** .text:0040EA50
- * Run various hit tests and return the index,
- * and a reference to the located type
+ /**
+ * Run various hit tests and return the index, and a reference to the located type.
+ *
+ * @param [in,out] type The type.
+ *
+ * @return The index
*/
int32 hitTest(HitType &type);
- /** .text:0040F010
- * TODO
+ /**
+ * Checks if the supplied coordinates are inside an action area, object or actor, and returns -1 if nothing was found, or the type of hit if
+ * found.
+ *
+ * @param [in,out] type The type.
+ *
+ * @return
+ */
+ ResourceId hitTestScene(HitType &type);
+
+ /**
+ * Check if the mouse cursor is currently intersecting an action area
+ *
+ * @return the index
*/
int32 hitTestActionArea();
- /** .text:0040E7F0
- * Check if the mouse cursor is currently intersecting
- * the currently active actor
+ /**
+ * Check if the mouse cursor is currently intersecting the currently active actor.
+ *
+ * @return true if it succeeds, false if it fails.
*/
bool hitTestActor();
/**
- * Check if the mouse cursor is currently intersecting the player
+ * Check if the mouse cursor is currently intersecting the player.
+ *
+ * @return true if it succeeds, false if it fails.
*/
bool hitTestPlayer();
- /** .text:004341E0
- * Check if the mouse cursor is currently intersecting
- * a graphic resource at the supplied coordinates
+ /**
+ * Check if a object exist at the supplied coordinates. If so, return it's index within the objects array, if not, return -1.
+ *
+ * @return the object index
*/
- bool hitTestPixel(ResourceId resourceId, int32 frame, int16 x, int16 y, bool flipped);
+ int32 hitTestObject();
- /** .text:0040E8A0
- * Checks if the supplied coordinates are inside an action area, object or
- * actor, and returns -1 if nothing was found, or the type of hit if found
+ /**
+ * .Check if the mouse cursor is currently intersecting a graphic resource at the supplied coordinates.
+ *
+ * @param resourceId Identifier for the resource.
+ * @param frame The frame.
+ * @param x The x coordinate.
+ * @param y The y coordinate.
+ * @param flipped true to flipped.
+ *
+ * @return true if it succeeds, false if it fails.
*/
- ResourceId hitTestScene(HitType &type);
+ bool hitTestPixel(ResourceId resourceId, int32 frame, int16 x, int16 y, bool flipped);
- /** .text:0040EAA0
- * Check if a object exist at the supplied coordinates.
- * If so, return it's index within the objects array, if not,
- * return -1
+ /**
+ * Handle hit
+ *
+ * @param index The index
+ * @param type The type.
*/
- int32 hitTestObject();
-
void handleHit(int32 index, HitType type);
+ /**
+ * Handle player reaction
+ */
void playerReaction();
//////////////////////////////////////////////////////////////////////////
// Helpers
//////////////////////////////////////////////////////////////////////////
+
+ /**
+ * Play intro speech.
+ */
void playIntroSpeech();
+
+ /**
+ * Stop speech.
+ */
void stopSpeech();
+
+ /**
+ * Check if point intersects the rectangle.
+ *
+ * @param point The point.
+ * @param rect The rectangle.
+ *
+ * @return true if it succeeds, false if it fails.
+ */
bool pointIntersectsRect(Common::Point point, Common::Rect rect);
//////////////////////////////////////////////////////////////////////////
Commit: a621f028f41379fb840c077d5aa48ead0c03210b
https://github.com/scummvm/scummvm/commit/a621f028f41379fb840c077d5aa48ead0c03210b
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:30+02:00
Commit Message:
ASYLUM: Implement and update Scene hitTest methods
- Finish Scene::hitTestScene
- Implement Scene::hitTestPlayer
- Update Scene::hitTestActionArea and Scene::hitTestObject
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@623 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/resources/actor.cpp
engines/asylum/shared.h
engines/asylum/views/scene.cpp
engines/asylum/views/scene.h
diff --git a/engines/asylum/resources/actor.cpp b/engines/asylum/resources/actor.cpp
index 3eb2052aa6..dc84b50156 100644
--- a/engines/asylum/resources/actor.cpp
+++ b/engines/asylum/resources/actor.cpp
@@ -973,7 +973,7 @@ bool Actor::process_408B20(Common::Point *point, ActorDirection dir, uint32 coun
if (count > 0) {
uint32 index = 0;
- while (getScene()->findActionArea(/* 1*/Common::Point(x, y)) != -1) {
+ while (getScene()->findActionArea(kActionAreaType1, Common::Point(x, y)) != -1) {
x += deltaPointsArray[dir].x;
y += deltaPointsArray[dir].y;
@@ -1663,7 +1663,7 @@ void Actor::updateFinish() {
if (_field_944 == 4 || !isVisible())
return;
- int32 areaIndex = getScene()->findActionArea(Common::Point((int16)(_point1.x + _point2.x), (int16)(_point1.y + _point2.y)));
+ int32 areaIndex = getScene()->findActionArea(kActionAreaType1, Common::Point((int16)(_point1.x + _point2.x), (int16)(_point1.y + _point2.y)));
if (areaIndex == _actionIdx3 || areaIndex == -1)
return;
diff --git a/engines/asylum/shared.h b/engines/asylum/shared.h
index 312af64172..e9f77e24e6 100644
--- a/engines/asylum/shared.h
+++ b/engines/asylum/shared.h
@@ -572,6 +572,7 @@ enum ObjectFlag {
kObjectFlag20 = 0x20,
kObjectFlag40 = 0x40,
kObjectFlag80 = 0x80,
+ kObjectFlag1000 = 0x1000,
kObjectFlagC000 = 0xC000,
kObjectFlag10000 = 0x10000,
kObjectFlag10E38 = 0x10E38,
diff --git a/engines/asylum/views/scene.cpp b/engines/asylum/views/scene.cpp
index 6a4a178309..6b12647dbd 100644
--- a/engines/asylum/views/scene.cpp
+++ b/engines/asylum/views/scene.cpp
@@ -968,24 +968,27 @@ void Scene::updateCursor(int direction, Common::Rect rect) {
//////////////////////////////////////////////////////////////////////////
int32 Scene::hitTest(HitType &type) {
type = kHitNone;
+
int32 targetIdx = hitTestObject();
if (targetIdx == -1) {
+
targetIdx = hitTestActionArea();
if (targetIdx == -1) {
- if (hitTestActor()) {
- targetIdx = _playerActorIndex;
- type = kHitActor;
- }
+
+ targetIdx = hitTestActor();
+ type = kHitActor;
+
} else {
type = kHitActionArea;
}
} else {
type = kHitObject;
}
+
return targetIdx;
}
-ResourceId Scene::hitTestScene(HitType &type) {
+int32 Scene::hitTestScene(HitType &type) {
if (!_ws)
error("[Scene::hitTestScene] WorldStats not initialized properly!");
@@ -995,27 +998,60 @@ ResourceId Scene::hitTestScene(HitType &type) {
int32 left = pt.y + _ws->yTop;
type = kHitNone;
- ResourceId result = (ResourceId)findActionArea(Common::Point(top, left));
-
- if (result != (ResourceId)-1) {
- if (LOBYTE(_ws->actions[result]->actionType) & 8) {
+ int32 index = findActionArea(kActionAreaType2, Common::Point(top, left));
+ if (index != -1) {
+ if (_ws->actions[index]->actionType & kActionType8) {
type = kHitActionArea;
- return result;
+ return index;
+ }
+
+ index = -1;
+ }
+
+ // Check objects
+ for (uint i = 0; i < _ws->objects.size(); i++) {
+ Object *object = _ws->objects[i];
+
+ if (object->isOnScreen() && object->actionType & kActionType8) {
+ if (hitTestPixel(object->getResourceId(),
+ object->getFrameIndex(),
+ top - object->x,
+ left - object->y,
+ object->flags & kObjectFlag1000)) {
+ type = kHitObject;
+ return i;
+ }
}
}
- // TODO object and actor checks
+ // Check actors
+ for (uint i = 0; i < _ws->actors.size(); i++) {
+ Actor *actor = _ws->actors[i];
- return result;
+ if (actor->actionType & kActionType8) {
+ uint32 frameIndex = (actor->getFrameIndex() >= actor->getFrameCount() ? 2 * actor->getFrameCount() - (actor->getFrameIndex() + 1) : actor->getFrameIndex());
+
+ if (hitTestPixel(actor->getResourceId(),
+ frameIndex,
+ top - actor->getPoint()->x - actor->getPoint1()->x,
+ left - actor->getPoint()->y - actor->getPoint1()->y,
+ actor->getDirection() >= kDirectionSE)) {
+ type = kHitActor;
+ return i;
+ }
+ }
+ }
+
+ return -1;
}
int32 Scene::hitTestActionArea() {
const Common::Point pt = getCursor()->position();
- int32 targetIdx = findActionArea(Common::Point(_ws->xLeft + pt.x, _ws->yTop + pt.y));
+ int32 targetIdx = findActionArea(kActionAreaType2, Common::Point(_ws->xLeft + pt.x, _ws->yTop + pt.y));
- if ( targetIdx == -1 || !(_ws->actions[targetIdx]->actionType & 0x17))
- targetIdx = -1;
+ if ( targetIdx == -1 || !(_ws->actions[targetIdx]->actionType & (kActionTypeFind | kActionTypeTalk | kActionTypeGrab | kActionType16)))
+ return -1;
return targetIdx;
}
@@ -1043,7 +1079,18 @@ bool Scene::hitTestActor() {
bool Scene::hitTestPlayer() {
const Common::Point pt = getCursor()->position();
- error("[Scene::hitTestPlayer] Not implemented!");
+ Actor *player = getActor();
+ Common::Point point;
+
+ player->adjustCoordinates(&point);
+
+ uint32 frameIndex = (player->getFrameIndex() >= player->getFrameCount() ? 2 * player->getFrameCount() - (player->getFrameIndex() + 1) : player->getFrameIndex());
+
+ return hitTestPixel(player->getResourceId(),
+ frameIndex,
+ pt.x - player->getPoint()->x - point.x,
+ pt.y - player->getPoint()->y - point.y,
+ player->getDirection() >= kDirectionSE);
}
int32 Scene::hitTestObject() {
@@ -1052,17 +1099,18 @@ int32 Scene::hitTestObject() {
const Common::Point pt = getCursor()->position();
- int32 targetIdx = -1;
for (uint32 i = 0; i < _ws->objects.size(); i++) {
Object *object = _ws->objects[i];
- if (object->isOnScreen())
- if (object->getPolygonIndex())
- if (hitTestPixel(object->getResourceId(), object->getFrameIndex(), pt.x, pt.y, object->flags & 0x1000)) {
- targetIdx = i;
- break;
- }
+ if (object->isOnScreen() && object->actionType)
+ if (hitTestPixel(object->getResourceId(),
+ object->getFrameIndex(),
+ _ws->xLeft + pt.x - object->x,
+ _ws->yTop + pt.y - object->y,
+ object->flags & kObjectFlag1000))
+ return i;
}
- return targetIdx;
+
+ return -1;
}
bool Scene::hitTestPixel(ResourceId resourceId, int32 frame, int16 x, int16 y, bool flipped) {
@@ -1211,7 +1259,7 @@ bool Scene::updateSceneCoordinates(int32 tX, int32 tY, int32 A0, bool checkScene
}
-int32 Scene::findActionArea(const Common::Point pt) {
+int32 Scene::findActionArea(ActionAreaType type, const Common::Point pt) {
if (!_ws)
error("[Scene::findActionArea] WorldStats not initialized properly!");
diff --git a/engines/asylum/views/scene.h b/engines/asylum/views/scene.h
index fa25d65c34..bccf80eabd 100644
--- a/engines/asylum/views/scene.h
+++ b/engines/asylum/views/scene.h
@@ -69,6 +69,11 @@ enum HitType {
kHitActor = 4
};
+enum ActionAreaType {
+ kActionAreaType1 = 1,
+ kActionAreaType2 = 2
+};
+
class Scene : public EventHandler {
public:
Scene(AsylumEngine *engine);
@@ -150,7 +155,7 @@ public:
*
* @return The found action area.
*/
- int32 findActionArea(const Common::Point pt);
+ int32 findActionArea(ActionAreaType type, const Common::Point pt);
/**
* Determine if the supplied point is in the action area
@@ -329,9 +334,9 @@ private:
*
* @param [in,out] type The type.
*
- * @return
+ * @return The Index
*/
- ResourceId hitTestScene(HitType &type);
+ int32 hitTestScene(HitType &type);
/**
* Check if the mouse cursor is currently intersecting an action area
Commit: 1cfd406ef37a092b8e26bd73df961ae781e83f1d
https://github.com/scummvm/scummvm/commit/1cfd406ef37a092b8e26bd73df961ae781e83f1d
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:30+02:00
Commit Message:
ASYLUM: Implement scene drawing list actor priority adjustment
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@624 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/views/scene.cpp
engines/asylum/views/scene.h
diff --git a/engines/asylum/views/scene.cpp b/engines/asylum/views/scene.cpp
index 6b12647dbd..22b618c258 100644
--- a/engines/asylum/views/scene.cpp
+++ b/engines/asylum/views/scene.cpp
@@ -1176,6 +1176,10 @@ bool Scene::pointIntersectsRect(Common::Point point, Common::Rect rect) {
return true;
}
+bool Scene::rectIntersect(int32 x, int32 y, int32 x1, int32 y1, int32 x2, int32 y2, int32 x3, int32 y3) {
+ return (x >= x3 && y >= y3 && x1 >= x2 && y1 >= y2);
+}
+
Actor* Scene::getActor(ActorIndex index) {
if (!_ws)
error("[Scene::getActor] WorldStats not initialized properly!");
@@ -1550,11 +1554,30 @@ void Scene::processUpdateList() {
}
void Scene::checkVisibleActorsPriority() {
- error("[Scene::checkVisibleActorsPriority] not implemented");
+ for (uint i = 2; i < 9; i++)
+ if (getActor(i)->isVisible())
+ adjustActorPriority(i);
+
+ for (uint i = 16; i < 18; i++)
+ if (getActor(i)->isVisible())
+ adjustActorPriority(i);
}
void Scene::adjustActorPriority(ActorIndex index) {
- error("[Scene::adjustActorPriority] not implemented");
+ Actor* actor0 = getActor(0);
+ Actor* actor = getActor(index);
+
+ if (rectIntersect(actor0->getPoint1()->x,
+ actor0->getPoint1()->y,
+ actor0->getPoint1()->x + actor0->getBoundingRect()->right,
+ actor0->getPoint1()->y + actor0->getBoundingRect()->bottom + 4,
+ actor->getPoint1()->x,
+ actor->getPoint1()->y,
+ actor->getPoint1()->x + actor0->getBoundingRect()->right,
+ actor->getPoint1()->y + actor0->getBoundingRect()->bottom)) {
+ if (actor->getPriority() < actor0->getPriority())
+ actor0->setPriority(actor->getPriority());
+ }
}
//////////////////////////////////////////////////////////////////////////
diff --git a/engines/asylum/views/scene.h b/engines/asylum/views/scene.h
index bccf80eabd..9e6a7c2a7b 100644
--- a/engines/asylum/views/scene.h
+++ b/engines/asylum/views/scene.h
@@ -416,6 +416,8 @@ private:
*/
bool pointIntersectsRect(Common::Point point, Common::Rect rect);
+ bool rectIntersect(int32 x, int32 y, int32 x1, int32 y1, int32 x2, int32 y2, int32 x3, int32 y3);
+
//////////////////////////////////////////////////////////////////////////
// Scene debugging
//////////////////////////////////////////////////////////////////////////
Commit: 9e18348aaed95c91f54a4a326613dbf187a2d1fb
https://github.com/scummvm/scummvm/commit/9e18348aaed95c91f54a4a326613dbf187a2d1fb
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:31+02:00
Commit Message:
ASYLUM: Implement Scene::handleHit
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@625 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/resources/actionlist.cpp
engines/asylum/resources/actionlist.h
engines/asylum/resources/actor.cpp
engines/asylum/resources/actor.h
engines/asylum/resources/object.cpp
engines/asylum/resources/object.h
engines/asylum/views/scene.cpp
engines/asylum/views/scene.h
diff --git a/engines/asylum/resources/actionlist.cpp b/engines/asylum/resources/actionlist.cpp
index 74f4642144..5eaeaa1173 100644
--- a/engines/asylum/resources/actionlist.cpp
+++ b/engines/asylum/resources/actionlist.cpp
@@ -275,6 +275,15 @@ void ActionList::queueScript(int scriptIndex, ActorIndex actorIndex) {
}
}
+bool ActionList::isInQueue(int32 scriptIndex) {
+ for (int32 i = 0; i < _queue.size(); i++) {
+ if (_queue[i].scriptIndex == scriptIndex)
+ return true;
+ }
+
+ return false;
+}
+
bool ActionList::process() {
_done = false;
_exit = false;
diff --git a/engines/asylum/resources/actionlist.h b/engines/asylum/resources/actionlist.h
index 7ee45c54f4..688d59e711 100644
--- a/engines/asylum/resources/actionlist.h
+++ b/engines/asylum/resources/actionlist.h
@@ -140,6 +140,8 @@ public:
*/
void queueScript(int32 scriptIndex, ActorIndex actorIndex);
+ bool isInQueue(int32 scriptIndex);
+
// Accessors
int32 getDelayedVideoIndex() const { return _delayedVideoIndex; }
void setDelayedVideoIndex(int32 val) { _delayedVideoIndex = val; }
diff --git a/engines/asylum/resources/actor.cpp b/engines/asylum/resources/actor.cpp
index dc84b50156..060211668f 100644
--- a/engines/asylum/resources/actor.cpp
+++ b/engines/asylum/resources/actor.cpp
@@ -82,7 +82,7 @@ Actor::Actor(AsylumEngine *engine, ActorIndex index) : _vm(engine), _index(index
_actionIdx2 = 0;
_field_924 = 0;
_lastScreenUpdate = 0;
- _field_92C = 0;
+ _scriptIndex = 0;
actionType = 0;
_field_934 = 0;
_field_938 = 0;
@@ -190,7 +190,7 @@ void Actor::load(Common::SeekableReadStream *stream) {
_actionIdx2 = stream->readSint32LE();
_field_924 = stream->readSint32LE();
_lastScreenUpdate = stream->readUint32LE();
- _field_92C = stream->readSint32LE();
+ _scriptIndex = stream->readSint32LE();
actionType = stream->readSint32LE();
_field_934 = stream->readSint32LE();
_field_938 = stream->readSint32LE();
diff --git a/engines/asylum/resources/actor.h b/engines/asylum/resources/actor.h
index 35195057b9..32b902ae21 100644
--- a/engines/asylum/resources/actor.h
+++ b/engines/asylum/resources/actor.h
@@ -69,6 +69,7 @@ public:
void setNumberFlag01(int32 number) { _numberFlag01 = number; }
void setPriority(int32 priority) { _priority = priority; }
void setResourceId(ResourceId id) { _resourceId = id; }
+ void setSoundResourceId(ResourceId id) { _soundResourceId = id; }
void setStatus(ActorStatus status) { _status = status; }
void setField638(int32 val) { _field_638 = val; }
@@ -90,6 +91,7 @@ public:
int32 getReaction(uint32 index) { return _reaction[index]; }
ResourceId getResourceId() { return _resourceId; }
ResourceId getResourcesId(uint32 index) { return _graphicResourceIds[index]; }
+ int32 getScriptIndex() { return _scriptIndex; }
ResourceId getSoundResourceId() { return _soundResourceId; }
ActorStatus getStatus() { return _status; }
@@ -326,7 +328,7 @@ private:
int32 _actionIdx2;
int32 _field_924;
uint32 _lastScreenUpdate;
- int32 _field_92C;
+ int32 _scriptIndex;
//actionType
int32 _field_934;
int32 _field_938;
diff --git a/engines/asylum/resources/object.cpp b/engines/asylum/resources/object.cpp
index 1985050284..2135e45494 100644
--- a/engines/asylum/resources/object.cpp
+++ b/engines/asylum/resources/object.cpp
@@ -43,7 +43,7 @@ Object::Object(AsylumEngine *engine) : x(0), y(0), flags(0), actionType(0),
_vm(engine), _index(0),
_id(kObjectNone), _resourceId(kResourceNone), _field_20(0), _frameIndex(0), _frameCount(0),
_field_2C(0), _field_30(0), _field_34(0), _field_3C(0), _polygonIndex(0), _field_B4(0),
- _tickCount(0), _tickCount2(0), _field_C0(0), _priority(0), _actionListIdx(0), _field_67C(0),
+ _tickCount(0), _tickCount2(0), _field_C0(0), _priority(0), _scriptIndex(0), _field_67C(0),
_soundX(0), _soundY(0), _field_688(0), _soundResourceId(kResourceNone), _field_6A4(kDirectionN)
{
memset(&_name, 0, sizeof(_name));
@@ -97,7 +97,7 @@ void Object::load(Common::SeekableReadStream *stream) {
_tickCount2 = stream->readUint32LE();
_field_C0 = stream->readUint32LE();
_priority = stream->readSint32LE();
- _actionListIdx = stream->readSint32LE();
+ _scriptIndex = stream->readSint32LE();
for (int i = 0; i < 16; i++) {
_soundItems[i].resourceId = (ResourceId)stream->readSint32LE();
@@ -509,7 +509,7 @@ Common::String Object::toString(bool shortString) {
output += Common::String::format(" tickCount2: %d\n", _tickCount2);
output += Common::String::format(" field_C0: %d\n", _field_C0);
output += Common::String::format(" priority: %d\n", _priority);
- output += Common::String::format(" actionListIdx: %d\n", _actionListIdx);
+ output += Common::String::format(" actionListIdx: %d\n", _scriptIndex);
output += Common::String::format(" field_67C: %d\n", _field_67C);
output += Common::String::format(" soundX: %d\n", _soundX);
output += Common::String::format(" soundY: %d\n", _soundY);
diff --git a/engines/asylum/resources/object.h b/engines/asylum/resources/object.h
index 3db9d47fe7..bb70fd1ec5 100644
--- a/engines/asylum/resources/object.h
+++ b/engines/asylum/resources/object.h
@@ -68,11 +68,12 @@ public:
ResourceId getResourceId() { return _resourceId; }
ResourceId getSoundResourceId() { return _soundResourceId; }
- Common::Rect *getRect() { return &_rect; }
- int32 getSoundY() { return _soundY; }
- int32 getField67C() { return _field_67C; }
- int32 getField688() { return _field_688; }
- ActorDirection getField6A4() { return _field_6A4; }
+ Common::Rect *getRect() { return &_rect; }
+ int32 getScriptIndex() { return _scriptIndex; }
+ int32 getSoundY() { return _soundY; }
+ int32 getField67C() { return _field_67C; }
+ int32 getField688() { return _field_688; }
+ ActorDirection getField6A4() { return _field_6A4; }
/////////////////////////////////////////////////////////////////////////
// Loading & disabling
@@ -194,7 +195,7 @@ private:
uint32 _tickCount2;
uint32 _field_C0;
int32 _priority;
- int32 _actionListIdx;
+ int32 _scriptIndex;
SoundItem _soundItems[16];
FrameSoundItem _frameSoundItems[50];
int32 _field_67C;
diff --git a/engines/asylum/views/scene.cpp b/engines/asylum/views/scene.cpp
index 22b618c258..b28c721b36 100644
--- a/engines/asylum/views/scene.cpp
+++ b/engines/asylum/views/scene.cpp
@@ -62,7 +62,7 @@ Scene::Scene(AsylumEngine *engine): _vm(engine),
// Initialize data
_packId = kResourcePackInvalid;
- _playerActorIndex = 0;
+ _playerIndex = 0;
_walking = false;
g_debugPolygons = 0;
@@ -92,7 +92,7 @@ void Scene::enter(ResourcePackId packId) {
getCursor()->hide();
- _playerActorIndex = 0;
+ _playerIndex = 0;
// Load the scene data
load(packId);
@@ -540,7 +540,7 @@ void Scene::updateMouse() {
pt.x = (int16)(act->getPoint1()->x -_ws->xLeft);
pt.y = (int16)(act->getPoint1()->y -_ws->yTop);
- if (_packId != 2 || _playerActorIndex != 10) {
+ if (_packId != 2 || _playerIndex != 10) {
actorPos.left = pt.x + 20;
actorPos.top = pt.y;
actorPos.right = (int16)(pt.x + 2 * act->getPoint2()->x);
@@ -911,7 +911,7 @@ void Scene::updateCursor(int direction, Common::Rect rect) {
}
}
if (targetIdx == -1) {
- if (_ws->chapter != kChapter2 || _playerActorIndex != 10) {
+ if (_ws->chapter != kChapter2 || _playerIndex != 10) {
if (getCursor()->flags)
getCursor()->set(_ws->curMagnifyingGlass, 0, 2);
} else {
@@ -947,7 +947,7 @@ void Scene::updateCursor(int direction, Common::Rect rect) {
if (targetUpdateType & 0x10 && getCursor()->flags != 2) {
getCursor()->set(_ws->curTalkNPC2, 0, 2);
} else {
- if (_ws->chapter != kChapter2 && _playerActorIndex != 10) {
+ if (_ws->chapter != kChapter2 && _playerIndex != 10) {
getCursor()->set(_ws->curMagnifyingGlass, 0, 0);
} else {
if (getCursor()->flags)
@@ -1114,19 +1114,125 @@ int32 Scene::hitTestObject() {
}
bool Scene::hitTestPixel(ResourceId resourceId, int32 frame, int16 x, int16 y, bool flipped) {
- // TODO this gets a bit funky with the "flipped" calculations for x intersection
- // The below is a pretty basic intersection test for proof of concept
- return GraphicResource::getFrameRect(_vm, resourceId, frame).contains(x, y);
+ Common::Rect rect = GraphicResource::getFrameRect(_vm, resourceId, frame);
+
+ // TODO we need to test each pixel of the surface!
+
+ return rect.contains(x, y);
}
+//////////////////////////////////////////////////////////////////////////
+// Hit actions
+//////////////////////////////////////////////////////////////////////////
void Scene::handleHit(int32 index, HitType type) {
- error("[Scene::handleHit] Not implemented!");
+ switch (type) {
+ default:
+ break;
+
+ case kHitActionArea:
+ if (!_actions->isInQueue(_ws->actions[index]->scriptIndex))
+ _actions->queueScript(_ws->actions[index]->scriptIndex, _playerIndex);
+
+ switch (_ws->chapter) {
+ default:
+ break;
+
+ case kChapter2:
+ hitAreaChapter2(_ws->actions[index]->id);
+ break;
+
+ case kChapter7:
+ hitAreaChapter7(_ws->actions[index]->id);
+ break;
+
+ case kChapter11:
+ hitAreaChapter11(_ws->actions[index]->id);
+ break;
+ }
+ break;
+
+ case kHitObject: {
+ Object *object = _ws->objects[index];
+
+ if (object->getSoundResourceId()) {
+ if (getSound()->isPlaying(object->getSoundResourceId())) {
+ getSound()->stop(object->getSoundResourceId());
+ object->setSoundResourceId(kResourceNone);
+ }
+ }
+
+ if (!_actions->isInQueue(object->getScriptIndex()))
+ _actions->queueScript(object->getScriptIndex(), _playerIndex);
+
+ // Original executes special script hit functions, but since there is none, we can skip this part
+ }
+ break;
+
+ case kHitActor: {
+ Actor *actor = _ws->actors[index];
+
+ if (actor->actionType & (kActionTypeFind | kActionType16)) {
+
+ if (_actions->isInQueue(actor->getScriptIndex()))
+ _actions->queueScript(actor->getScriptIndex(), _playerIndex);
+
+ } else if (actor->actionType & kActionTypeTalk) {
+
+ if (getSound()->isPlaying(actor->getSoundResourceId())) {
+ if (actor->getStatus() != kActorStatusEnabled)
+ actor->updateStatus(kActorStatusEnabled);
+
+ getSound()->stop(actor->getSoundResourceId());
+ actor->setSoundResourceId(kResourceNone);
+ }
+
+ if (_actions->isInQueue(actor->getScriptIndex()))
+ _actions->queueScript(actor->getScriptIndex(), _playerIndex);
+ }
+
+ switch (_ws->chapter) {
+ default:
+ break;
+
+ case kChapter2:
+ hitActorChapter2(index);
+ break;
+
+ case kChapter11:
+ hitActorChapter11(index);
+ break;
+ }
+ }
+ break;
+ }
}
void Scene::playerReaction() {
error("[Scene::playerReaction] Not implemented!");
}
+void Scene::hitAreaChapter2(int32 id) {
+ error("[Scene::hitAreaChapter2] Not implemented!");
+}
+
+void Scene::hitAreaChapter7(int32 id) {
+ error("[Scene::hitAreaChapter7] Not implemented!");
+}
+
+void Scene::hitAreaChapter11(int32 id) {
+ error("[Scene::hitAreaChapter11] Not implemented!");
+}
+
+
+void Scene::hitActorChapter2(ActorIndex index) {
+ error("[Scene::hitActorChapter2] Not implemented!");
+}
+
+void Scene::hitActorChapter11(ActorIndex index) {
+ error("[Scene::hitActorChapter11] Not implemented!");
+}
+
+
//////////////////////////////////////////////////////////////////////////
// Helpers
//////////////////////////////////////////////////////////////////////////
@@ -1184,7 +1290,7 @@ Actor* Scene::getActor(ActorIndex index) {
if (!_ws)
error("[Scene::getActor] WorldStats not initialized properly!");
- ActorIndex computedIndex = (index != -1) ? index : _playerActorIndex;
+ ActorIndex computedIndex = (index != -1) ? index : _playerIndex;
if (computedIndex < 0 || computedIndex >= (int16)_ws->actors.size())
error("[Scene::getActor] Invalid actor index: %d ([0-%d] allowed)", computedIndex, _ws->actors.size() - 1);
diff --git a/engines/asylum/views/scene.h b/engines/asylum/views/scene.h
index 9e6a7c2a7b..368d3c162b 100644
--- a/engines/asylum/views/scene.h
+++ b/engines/asylum/views/scene.h
@@ -105,14 +105,14 @@ public:
/**
* Return the index of the player actor
*/
- ActorIndex getPlayerIndex() { return _playerActorIndex; }
+ ActorIndex getPlayerIndex() { return _playerIndex; }
/**
* Sets the player actor index.
*
* @param index index of the player actor
*/
- void setPlayerActorIndex(ActorIndex index) { _playerActorIndex = index; }
+ void setPlayerActorIndex(ActorIndex index) { _playerIndex = index; }
/**
* Gets the current scene pack identifier.
@@ -177,7 +177,7 @@ private:
AsylumEngine *_vm;
ResourcePackId _packId;
- int32 _playerActorIndex;
+ int32 _playerIndex;
bool _walking;
@@ -379,6 +379,10 @@ private:
*/
bool hitTestPixel(ResourceId resourceId, int32 frame, int16 x, int16 y, bool flipped);
+ //////////////////////////////////////////////////////////////////////////
+ // Hit actions
+ //////////////////////////////////////////////////////////////////////////
+
/**
* Handle hit
*
@@ -392,6 +396,13 @@ private:
*/
void playerReaction();
+ void hitAreaChapter2(int32 id);
+ void hitAreaChapter7(int32 id);
+ void hitAreaChapter11(int32 id);
+
+ void hitActorChapter2(ActorIndex index);
+ void hitActorChapter11(ActorIndex index);
+
//////////////////////////////////////////////////////////////////////////
// Helpers
//////////////////////////////////////////////////////////////////////////
@@ -416,6 +427,20 @@ private:
*/
bool pointIntersectsRect(Common::Point point, Common::Rect rect);
+ /**
+ * Check if rectangles intersect.
+ *
+ * @param x The x coordinate.
+ * @param y The y coordinate.
+ * @param x1 The first x value.
+ * @param y1 The first y value.
+ * @param x2 The second x value.
+ * @param y2 The second y value.
+ * @param x3 The third int32.
+ * @param y3 The third int32.
+ *
+ * @return true if it succeeds, false if it fails.
+ */
bool rectIntersect(int32 x, int32 y, int32 x1, int32 y1, int32 x2, int32 y2, int32 x3, int32 y3);
//////////////////////////////////////////////////////////////////////////
Commit: b7294477827a1ff778587a8526065f5d1aee3047
https://github.com/scummvm/scummvm/commit/b7294477827a1ff778587a8526065f5d1aee3047
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:31+02:00
Commit Message:
ASYLUM: Rename ActionList to ScriptManager and move to engine class
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@626 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
A engines/asylum/resources/script.cpp
A engines/asylum/resources/script.h
R engines/asylum/resources/actionlist.cpp
R engines/asylum/resources/actionlist.h
engines/asylum/asylum.cpp
engines/asylum/asylum.h
engines/asylum/console.cpp
engines/asylum/module.mk
engines/asylum/resources/actor.cpp
engines/asylum/resources/data.h
engines/asylum/resources/encounters.cpp
engines/asylum/resources/object.cpp
engines/asylum/resources/special.cpp
engines/asylum/resources/worldstats.cpp
engines/asylum/shared.h
engines/asylum/views/scene.cpp
engines/asylum/views/scene.h
diff --git a/engines/asylum/asylum.cpp b/engines/asylum/asylum.cpp
index 13deb10a6e..473179464a 100644
--- a/engines/asylum/asylum.cpp
+++ b/engines/asylum/asylum.cpp
@@ -25,7 +25,7 @@
#include "asylum/asylum.h"
-#include "asylum/resources/actionlist.h"
+#include "asylum/resources/script.h"
#include "asylum/resources/encounters.h"
#include "asylum/resources/worldstats.h"
@@ -56,7 +56,7 @@ namespace Asylum {
AsylumEngine::AsylumEngine(OSystem *system, const ADGameDescription *gd) : Engine(system), _gameDescription(gd),
_console(NULL), _cursor(NULL), _encounter(NULL), _mainMenu(NULL), _resource(NULL), _savegame(NULL),
- _scene(NULL), _screen(NULL), _sound(NULL), _text(NULL), _video(NULL), _handler(NULL) {
+ _scene(NULL), _screen(NULL), _script(NULL), _sound(NULL), _text(NULL), _video(NULL), _handler(NULL) {
// Init data
memset(&_gameFlags, 0, sizeof(_gameFlags));
@@ -91,6 +91,7 @@ AsylumEngine::~AsylumEngine() {
delete _encounter;
delete _savegame;
delete _screen;
+ delete _script;
delete _sound;
delete _text;
delete _video;
@@ -122,6 +123,7 @@ Common::Error AsylumEngine::run() {
_cursor = new Cursor(this);
_savegame = new Savegame(this);
_screen = new Screen(this);
+ _script = new ScriptManager(this);
_sound = new Sound(this, _mixer);
_text = new Text(this);
_video = new Video(this, _mixer);
@@ -313,22 +315,22 @@ void AsylumEngine::processDelayedEvents() {
error("[AsylumEngine::processDelayedEvents] Subsystems not initialized properly!");
// check for a delayed video
- int videoIdx = _scene->actions()->getDelayedVideoIndex();
+ int videoIdx = _script->getDelayedVideoIndex();
if (videoIdx >= 0) {
_sound->stopMusic();
_sound->stopAll();
_video->playVideo(videoIdx);
- _scene->actions()->setDelayedVideoIndex(-1);
+ _script->setDelayedVideoIndex(-1);
}
// check for a delayed scene change
- ResourcePackId packId = _scene->actions()->getDelayedSceneIndex();
+ ResourcePackId packId = _script->getDelayedSceneIndex();
// XXX Flag 183 indicates whether the actionlist is currently
// processing
if (packId != kResourcePackInvalid && isGameFlagNotSet(kGameFlagScriptProcessing)) {
// Reset delayed scene
- _scene->actions()->setDelayedSceneIndex(kResourcePackInvalid);
+ _script->setDelayedSceneIndex(kResourcePackInvalid);
_sound->stopMusic();
_sound->stopAll();
diff --git a/engines/asylum/asylum.h b/engines/asylum/asylum.h
index df8eaebe60..aaeba500db 100644
--- a/engines/asylum/asylum.h
+++ b/engines/asylum/asylum.h
@@ -72,6 +72,7 @@ class ResourceManager;
class Savegame;
class Scene;
class Screen;
+class ScriptManager;
class Sound;
class Text;
class Video;
@@ -137,6 +138,7 @@ public:
Savegame *savegame() { return _savegame; }
Scene *scene() { return _scene; }
Screen *screen() { return _screen; }
+ ScriptManager *script() { return _script; }
Sound *sound() { return _sound; }
Text *text() { return _text; }
Video *video() { return _video; }
@@ -188,6 +190,7 @@ private:
Savegame *_savegame;
Scene *_scene;
Screen *_screen;
+ ScriptManager *_script;
Sound *_sound;
Text *_text;
Video *_video;
diff --git a/engines/asylum/console.cpp b/engines/asylum/console.cpp
index 5fc146cbf1..6796738839 100644
--- a/engines/asylum/console.cpp
+++ b/engines/asylum/console.cpp
@@ -25,10 +25,10 @@
#include "asylum/console.h"
-#include "asylum/resources/actionlist.h"
#include "asylum/resources/actor.h"
#include "asylum/resources/encounters.h"
#include "asylum/resources/object.h"
+#include "asylum/resources/script.h"
#include "asylum/resources/worldstats.h"
#include "asylum/system/screen.h"
@@ -320,7 +320,7 @@ bool Console::cmdPlayVideo(int32 argc, const char **argv) {
}
getScreen()->clear();
- getScene()->actions()->setDelayedVideoIndex(index);
+ getScript()->setDelayedVideoIndex(index);
return false;
}
@@ -335,7 +335,7 @@ bool Console::cmdRunScript(int32 argc, const char **argv) {
uint32 actor = atoi(argv[2]);
// Check parameters
- if (index >= getScene()->actions()->_scripts.size()) {
+ if (index >= getScript()->_scripts.size()) {
DebugPrintf("[Error] Invalid index (was: %d - valid: [0-%d])\n", index, _vm->encounter()->_items.size() - 1);
return true;
}
@@ -344,7 +344,7 @@ bool Console::cmdRunScript(int32 argc, const char **argv) {
DebugPrintf("[Error] Invalid actor index (was: %d - valid: [0-%d])\n", actor, getWorld()->actors.size() - 1);
}
- getScene()->actions()->queueScript(index, actor);
+ getScript()->queueScript(index, actor);
return false;
}
@@ -365,7 +365,7 @@ bool Console::cmdChangeScene(int32 argc, const char **argv) {
return true;
}
- _vm->scene()->actions()->setDelayedSceneIndex(index);
+ getScript()->setDelayedSceneIndex(index);
return false;
}
diff --git a/engines/asylum/module.mk b/engines/asylum/module.mk
index 341cb3c8c1..f3d7ec616e 100644
--- a/engines/asylum/module.mk
+++ b/engines/asylum/module.mk
@@ -3,12 +3,12 @@ MODULE := engines/asylum
MODULE_OBJS := \
puzzles/puzzle.o \
puzzles/vcr.o \
- resources/actionlist.o \
resources/actor.o \
resources/object.o \
resources/encounters.o \
resources/polygons.o \
resources/reaction.o \
+ resources/script.o \
resources/special.o \
resources/worldstats.o \
system/config.o \
diff --git a/engines/asylum/resources/actor.cpp b/engines/asylum/resources/actor.cpp
index 060211668f..329cb4297c 100644
--- a/engines/asylum/resources/actor.cpp
+++ b/engines/asylum/resources/actor.cpp
@@ -25,10 +25,10 @@
#include "asylum/resources/actor.h"
-#include "asylum/resources/actionlist.h"
#include "asylum/resources/encounters.h"
#include "asylum/resources/object.h"
#include "asylum/resources/polygons.h"
+#include "asylum/resources/script.h"
#include "asylum/resources/worldstats.h"
#include "asylum/system/config.h"
@@ -328,7 +328,7 @@ void Actor::update() {
getScene()->getActor(0)->updateFromDirection(kDirectionS);
// Queue script
- getScene()->actions()->queueScript(getWorld()->getActionAreaById(2696)->scriptIndex, getScene()->getPlayerIndex());
+ getScript()->queueScript(getWorld()->getActionAreaById(2696)->scriptIndex, getScene()->getPlayerIndex());
_vm->setGameFlag(kGameFlag279);
_vm->setGameFlag(kGameFlag368);
@@ -367,7 +367,7 @@ void Actor::update() {
_vm->setGameFlag(kGameFlag238);
// Queue script
- getScene()->actions()->queueScript(getWorld()->getActionAreaById(1000)->scriptIndex, getScene()->getPlayerIndex());
+ getScript()->queueScript(getWorld()->getActionAreaById(1000)->scriptIndex, getScene()->getPlayerIndex());
}
}
@@ -1356,7 +1356,7 @@ void Actor::updateStatus12_Chapter11_Actor1() {
actor0->updateStatus(kActorStatusEnabled);
getWorld()->field_E848C = 0;
- getScene()->actions()->queueScript(getWorld()->getActionAreaById(1574)->scriptIndex, 1);
+ getScript()->queueScript(getWorld()->getActionAreaById(1574)->scriptIndex, 1);
}
}
@@ -1669,9 +1669,9 @@ void Actor::updateFinish() {
ActionArea *area = getWorld()->actions[areaIndex];
ActionArea *actorArea = getWorld()->actions[_actionIdx3];
- if (!getScene()->actions()->isProcessingSkipped()) {
- getScene()->actions()->queueScript(actorArea->scriptIndex2, _index);
- getScene()->actions()->queueScript(area->scriptIndex, _index);
+ if (!getScript()->isProcessingSkipped()) {
+ getScript()->queueScript(actorArea->scriptIndex2, _index);
+ getScript()->queueScript(area->scriptIndex, _index);
}
if (!area->paletteResourceId || area->paletteResourceId == actorArea->paletteResourceId || _index) {
diff --git a/engines/asylum/resources/data.h b/engines/asylum/resources/data.h
index bea7942459..1a37259304 100644
--- a/engines/asylum/resources/data.h
+++ b/engines/asylum/resources/data.h
@@ -62,10 +62,10 @@ enum GlobalFlag {
* -- Scene data (reset on scene load)
* uint32 {16} - ambient sound panning array
* uint32 {1} - scene counter
- * -- Script queue (stored in ActionList - reset on scene change)
+ * -- Script queue (stored in ScriptManager - reset on scene change)
* uint32 {1} - global Object X
* uint32 {1} - global Object Y
- * -- Skip processing flag (stored in ActionList)
+ * -- Skip processing flag (stored in ScriptManager)
* uint32 {1} - Encounter flag 2
* -- Player ActorIndex (reset on scene enter)
* uint32 {1} - scene xLeft
diff --git a/engines/asylum/resources/encounters.cpp b/engines/asylum/resources/encounters.cpp
index d8c3248372..8499ccdfb3 100644
--- a/engines/asylum/resources/encounters.cpp
+++ b/engines/asylum/resources/encounters.cpp
@@ -25,9 +25,9 @@
#include "asylum/resources/encounters.h"
-#include "asylum/resources/actionlist.h"
#include "asylum/resources/actor.h"
#include "asylum/resources/object.h"
+#include "asylum/resources/script.h"
#include "asylum/resources/worldstats.h"
#include "asylum/system/cursor.h"
@@ -719,7 +719,7 @@ void Encounter::runScript() {
if (!getSharedData()->getMatteBarHeight()) {
getScreen()->makeGreyPalette();
getSharedData()->setMatteBarHeight(1);
- getScene()->actions()->setDelayedVideoIndex(getVariableInv(entry.param2));
+ getScript()->setDelayedVideoIndex(getVariableInv(entry.param2));
getSharedData()->setMatteVar1(1);
getSharedData()->setMattePlaySound(true);
getSharedData()->setMatteInitialized(true);
diff --git a/engines/asylum/resources/object.cpp b/engines/asylum/resources/object.cpp
index 2135e45494..a71715fbf1 100644
--- a/engines/asylum/resources/object.cpp
+++ b/engines/asylum/resources/object.cpp
@@ -509,7 +509,7 @@ Common::String Object::toString(bool shortString) {
output += Common::String::format(" tickCount2: %d\n", _tickCount2);
output += Common::String::format(" field_C0: %d\n", _field_C0);
output += Common::String::format(" priority: %d\n", _priority);
- output += Common::String::format(" actionListIdx: %d\n", _scriptIndex);
+ output += Common::String::format(" scriptIndex: %d\n", _scriptIndex);
output += Common::String::format(" field_67C: %d\n", _field_67C);
output += Common::String::format(" soundX: %d\n", _soundX);
output += Common::String::format(" soundY: %d\n", _soundY);
diff --git a/engines/asylum/resources/actionlist.cpp b/engines/asylum/resources/script.cpp
similarity index 98%
rename from engines/asylum/resources/actionlist.cpp
rename to engines/asylum/resources/script.cpp
index 5eaeaa1173..48a9d8e23f 100644
--- a/engines/asylum/resources/actionlist.cpp
+++ b/engines/asylum/resources/script.cpp
@@ -23,7 +23,7 @@
*
*/
-#include "asylum/resources/actionlist.h"
+#include "asylum/resources/script.h"
#include "asylum/resources/actor.h"
#include "asylum/resources/encounters.h"
@@ -79,9 +79,9 @@ void ActionArea::load(Common::SeekableReadStream *stream) {
}
//////////////////////////////////////////////////////////////////////////
-// ActionList
+// ScriptManager
//////////////////////////////////////////////////////////////////////////
-ActionList::ActionList(AsylumEngine *engine) : _vm(engine) {
+ScriptManager::ScriptManager(AsylumEngine *engine) : _vm(engine) {
// Build list of opcodes
ADD_OPCODE(Return);
ADD_OPCODE(SetGameFlag);
@@ -187,7 +187,7 @@ ActionList::ActionList(AsylumEngine *engine) : _vm(engine) {
reset();
}
-ActionList::~ActionList() {
+ScriptManager::~ScriptManager() {
for (int i = 0; i < (int)_opcodes.size(); i++)
delete _opcodes[i];
@@ -200,7 +200,7 @@ ActionList::~ActionList() {
_vm = NULL;
}
-void ActionList::load(Common::SeekableReadStream *stream) {
+void ScriptManager::load(Common::SeekableReadStream *stream) {
stream->readSint32LE(); // size
int32 numEntries = stream->readSint32LE();
@@ -235,10 +235,13 @@ void ActionList::load(Common::SeekableReadStream *stream) {
}
}
-void ActionList::reset() {
+void ScriptManager::reset() {
// Reset script queue
resetQueue();
+ // Remove all scripts
+ _scripts.clear();
+
_skipProcessing = false;
_currentLine = 0;
_currentLoops = 0;
@@ -251,11 +254,11 @@ void ActionList::reset() {
_waitCycle = false;
}
-void ActionList::resetQueue() {
+void ScriptManager::resetQueue() {
_queue.clear();
}
-void ActionList::queueScript(int scriptIndex, ActorIndex actorIndex) {
+void ScriptManager::queueScript(int scriptIndex, ActorIndex actorIndex) {
// When the skipProcessing flag is set, do not queue any more scripts
if (_skipProcessing)
return;
@@ -275,7 +278,7 @@ void ActionList::queueScript(int scriptIndex, ActorIndex actorIndex) {
}
}
-bool ActionList::isInQueue(int32 scriptIndex) {
+bool ScriptManager::isInQueue(int32 scriptIndex) {
for (int32 i = 0; i < _queue.size(); i++) {
if (_queue[i].scriptIndex == scriptIndex)
return true;
@@ -284,7 +287,7 @@ bool ActionList::isInQueue(int32 scriptIndex) {
return false;
}
-bool ActionList::process() {
+bool ScriptManager::process() {
_done = false;
_exit = false;
_waitCycle = false;
@@ -1774,7 +1777,7 @@ END_OPCODE
// Opcode Helper functions
//////////////////////////////////////////////////////////////////////////
-void ActionList::enableObject(ScriptEntry *cmd, ObjectEnableType type) {
+void ScriptManager::enableObject(ScriptEntry *cmd, ObjectEnableType type) {
int32 field67C = 0;
// Setup field67C
@@ -1885,7 +1888,7 @@ void ActionList::enableObject(ScriptEntry *cmd, ObjectEnableType type) {
}
}
-void ActionList::setActionFlag(ScriptEntry *cmd, ActionType flag) {
+void ScriptManager::setActionFlag(ScriptEntry *cmd, ActionType flag) {
switch (cmd->param2) {
default:
getWorld()->getObjectById((ObjectId)cmd->param1)->actionType |= flag;
@@ -1901,7 +1904,7 @@ void ActionList::setActionFlag(ScriptEntry *cmd, ActionType flag) {
}
}
-void ActionList::clearActionFlag(ScriptEntry *cmd, ActionType flag) {
+void ScriptManager::clearActionFlag(ScriptEntry *cmd, ActionType flag) {
switch (cmd->param2) {
default:
getWorld()->getObjectById((ObjectId)cmd->param1)->actionType &= ~flag;
@@ -1917,7 +1920,7 @@ void ActionList::clearActionFlag(ScriptEntry *cmd, ActionType flag) {
}
}
-void ActionList::jumpIfActionFlag(ScriptEntry *cmd, ActionType flag) {
+void ScriptManager::jumpIfActionFlag(ScriptEntry *cmd, ActionType flag) {
bool done = false;
switch (cmd->param3) {
@@ -1940,7 +1943,7 @@ void ActionList::jumpIfActionFlag(ScriptEntry *cmd, ActionType flag) {
setNextLine(cmd->param2);
}
-void ActionList::setNextLine(int32 line) {
+void ScriptManager::setNextLine(int32 line) {
if (!_currentScript)
error("[ActionList::setNextLine] No current script set!");
diff --git a/engines/asylum/resources/actionlist.h b/engines/asylum/resources/script.h
similarity index 95%
rename from engines/asylum/resources/actionlist.h
rename to engines/asylum/resources/script.h
index 688d59e711..7984d8aea1 100644
--- a/engines/asylum/resources/actionlist.h
+++ b/engines/asylum/resources/script.h
@@ -23,8 +23,8 @@
*
*/
-#ifndef ASYLUM_ACTIONLIST_H
-#define ASYLUM_ACTIONLIST_H
+#ifndef ASYLUM_SCRIPT_H
+#define ASYLUM_SCRIPT_H
#include "asylum/shared.h"
@@ -41,7 +41,7 @@ namespace Asylum {
void k##name(ScriptEntry *cmd)
#define IMPLEMENT_OPCODE(name) \
- void ActionList::k##name(ScriptEntry *cmd) { \
+ void ScriptManager::k##name(ScriptEntry *cmd) { \
if (!_currentScript) error("[" #name "] No current script set!"); \
if (!cmd) error("[" #name "] Invalid command parameter!");
@@ -49,7 +49,7 @@ namespace Asylum {
#define ADD_OPCODE(name) { \
- Opcode *func = new Opcode(#name, new Common::Functor1Mem<ScriptEntry *, void, ActionList>(this, &ActionList::k##name)); \
+ Opcode *func = new Opcode(#name, new Common::Functor1Mem<ScriptEntry *, void, ScriptManager>(this, &ScriptManager::k##name)); \
_opcodes.push_back(func); \
}
@@ -117,10 +117,10 @@ struct ActionArea {
}
};
-class ActionList {
+class ScriptManager {
public:
- ActionList(AsylumEngine *engine);
- virtual ~ActionList();
+ ScriptManager(AsylumEngine *engine);
+ virtual ~ScriptManager();
/**
* Loads the script entries
@@ -134,12 +134,24 @@ public:
*/
bool process();
+ /**
+ * Resets the queue and local variables
+ */
+ void reset();
+
/**
* Initialize the script element at actionIndex to
* the actor at actorIndex
*/
void queueScript(int32 scriptIndex, ActorIndex actorIndex);
+ /**
+ * Query if 'scriptIndex' is in queue.
+ *
+ * @param scriptIndex Zero-based index of the script.
+ *
+ * @return true if in queue, false if not.
+ */
bool isInQueue(int32 scriptIndex);
// Accessors
@@ -245,11 +257,6 @@ private:
*/
void resetQueue();
- /**
- * Resets the queue and local variables
- */
- void reset();
-
// Opcode helper functions
void enableObject(ScriptEntry *cmd, ObjectEnableType type);
void setActionFlag(ScriptEntry *cmd, ActionType flag); //|
@@ -364,4 +371,4 @@ private:
} // end of namespace Asylum
-#endif // ASYLUM_ACTIONLIST_H
+#endif // ASYLUM_SCRIPT_H
diff --git a/engines/asylum/resources/special.cpp b/engines/asylum/resources/special.cpp
index 0df8335aba..41a98ac8cd 100644
--- a/engines/asylum/resources/special.cpp
+++ b/engines/asylum/resources/special.cpp
@@ -25,10 +25,10 @@
#include "asylum/resources/special.h"
-#include "asylum/resources/actionlist.h"
#include "asylum/resources/actor.h"
#include "asylum/resources/object.h"
#include "asylum/resources/encounters.h"
+#include "asylum/resources/script.h"
#include "asylum/resources/worldstats.h"
#include "asylum/system/cursor.h"
diff --git a/engines/asylum/resources/worldstats.cpp b/engines/asylum/resources/worldstats.cpp
index 51bc8e59c9..7b320d71eb 100644
--- a/engines/asylum/resources/worldstats.cpp
+++ b/engines/asylum/resources/worldstats.cpp
@@ -25,9 +25,9 @@
#include "asylum/resources/worldstats.h"
-#include "asylum/resources/actionlist.h"
#include "asylum/resources/actor.h"
#include "asylum/resources/object.h"
+#include "asylum/resources/script.h"
#include "asylum/asylum.h"
diff --git a/engines/asylum/shared.h b/engines/asylum/shared.h
index e9f77e24e6..e09a3f84c7 100644
--- a/engines/asylum/shared.h
+++ b/engines/asylum/shared.h
@@ -606,7 +606,7 @@ enum ObjectFlag {
#define getSaveLoad() _vm->savegame()
#define getScene() _vm->scene()
#define getScreen() _vm->screen()
-#define getScript() _vm->scene()->actions()
+#define getScript() _vm->script()
#define getSharedData() _vm->getData()
#define getSpeech() _vm->scene()->speech()
#define getText() _vm->text()
diff --git a/engines/asylum/views/scene.cpp b/engines/asylum/views/scene.cpp
index b28c721b36..84b9acfd1e 100644
--- a/engines/asylum/views/scene.cpp
+++ b/engines/asylum/views/scene.cpp
@@ -25,11 +25,11 @@
#include "asylum/views/scene.h"
-#include "asylum/resources/actionlist.h"
#include "asylum/resources/actor.h"
#include "asylum/resources/encounters.h"
#include "asylum/resources/object.h"
#include "asylum/resources/polygons.h"
+#include "asylum/resources/script.h"
#include "asylum/resources/special.h"
#include "asylum/resources/worldstats.h"
@@ -58,7 +58,7 @@ int g_debugObjects;
int g_debugScrolling;
Scene::Scene(AsylumEngine *engine): _vm(engine),
- _actions(NULL), _special(NULL), _speech(NULL), _polygons(NULL), _ws(NULL) {
+ _special(NULL), _speech(NULL), _polygons(NULL), _ws(NULL) {
// Initialize data
_packId = kResourcePackInvalid;
@@ -77,7 +77,9 @@ Scene::~Scene() {
// Unload the associated resources
getResource()->unload(_packId);
- delete _actions;
+ // Clear script queue
+ getScript()->reset();
+
delete _special;
delete _speech;
delete _polygons;
@@ -158,7 +160,7 @@ void Scene::enter(ResourcePackId packId) {
// Queue scene script
if (_ws->scriptIndex)
- _actions->queueScript(_ws->scriptIndex, 0);
+ getScript()->queueScript(_ws->scriptIndex, 0);
// Clear the graphic queue (FIXME: not sure why we need to do this again)
getScreen()->clearGraphicsInQueue();
@@ -227,8 +229,7 @@ void Scene::load(ResourcePackId packId) {
_polygons = new Polygons(fd);
- _actions = new ActionList(_vm);
- _actions->load(fd);
+ getScript()->load(fd);
fd->close();
delete fd;
@@ -525,7 +526,7 @@ bool Scene::updateScene() {
debugShowObjects();
}
- return _actions->process();
+ return getScript()->process();
}
void Scene::updateMouse() {
@@ -1130,8 +1131,8 @@ void Scene::handleHit(int32 index, HitType type) {
break;
case kHitActionArea:
- if (!_actions->isInQueue(_ws->actions[index]->scriptIndex))
- _actions->queueScript(_ws->actions[index]->scriptIndex, _playerIndex);
+ if (!getScript()->isInQueue(_ws->actions[index]->scriptIndex))
+ getScript()->queueScript(_ws->actions[index]->scriptIndex, _playerIndex);
switch (_ws->chapter) {
default:
@@ -1161,8 +1162,8 @@ void Scene::handleHit(int32 index, HitType type) {
}
}
- if (!_actions->isInQueue(object->getScriptIndex()))
- _actions->queueScript(object->getScriptIndex(), _playerIndex);
+ if (!getScript()->isInQueue(object->getScriptIndex()))
+ getScript()->queueScript(object->getScriptIndex(), _playerIndex);
// Original executes special script hit functions, but since there is none, we can skip this part
}
@@ -1173,8 +1174,8 @@ void Scene::handleHit(int32 index, HitType type) {
if (actor->actionType & (kActionTypeFind | kActionType16)) {
- if (_actions->isInQueue(actor->getScriptIndex()))
- _actions->queueScript(actor->getScriptIndex(), _playerIndex);
+ if (getScript()->isInQueue(actor->getScriptIndex()))
+ getScript()->queueScript(actor->getScriptIndex(), _playerIndex);
} else if (actor->actionType & kActionTypeTalk) {
@@ -1186,8 +1187,8 @@ void Scene::handleHit(int32 index, HitType type) {
actor->setSoundResourceId(kResourceNone);
}
- if (_actions->isInQueue(actor->getScriptIndex()))
- _actions->queueScript(actor->getScriptIndex(), _playerIndex);
+ if (getScript()->isInQueue(actor->getScriptIndex()))
+ getScript()->queueScript(actor->getScriptIndex(), _playerIndex);
}
switch (_ws->chapter) {
diff --git a/engines/asylum/views/scene.h b/engines/asylum/views/scene.h
index 368d3c162b..ffe1c57af4 100644
--- a/engines/asylum/views/scene.h
+++ b/engines/asylum/views/scene.h
@@ -39,7 +39,6 @@
namespace Asylum {
-class ActionList;
class Actor;
class AsylumEngine;
class BlowUpPuzzle;
@@ -167,7 +166,6 @@ public:
*/
bool isInActionArea(const Common::Point &pt, ActionArea *area);
- ActionList *actions() { return _actions; }
Polygons *polygons() { return _polygons; }
Special *special() { return _special; }
Speech *speech() { return _speech; }
@@ -183,7 +181,6 @@ private:
ActorDirection _globalDirection;
- ActionList *_actions;
Special *_special;
Speech *_speech;
Polygons *_polygons;
Commit: 51bf14d497d279f52b05b8902a5a61964ab3f8da
https://github.com/scummvm/scummvm/commit/51bf14d497d279f52b05b8902a5a61964ab3f8da
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:31+02:00
Commit Message:
ASYLUM: Move Special and Speech instances to engine class
Also remove a couple of unused variables from Scene class
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@627 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/asylum.cpp
engines/asylum/asylum.h
engines/asylum/resources/object.cpp
engines/asylum/shared.h
engines/asylum/views/scene.cpp
engines/asylum/views/scene.h
diff --git a/engines/asylum/asylum.cpp b/engines/asylum/asylum.cpp
index 473179464a..d371147284 100644
--- a/engines/asylum/asylum.cpp
+++ b/engines/asylum/asylum.cpp
@@ -26,6 +26,7 @@
#include "asylum/asylum.h"
#include "asylum/resources/script.h"
+#include "asylum/resources/special.h"
#include "asylum/resources/encounters.h"
#include "asylum/resources/worldstats.h"
@@ -36,6 +37,7 @@
#include "asylum/system/savegame.h"
#include "asylum/system/screen.h"
#include "asylum/system/sound.h"
+#include "asylum/system/speech.h"
#include "asylum/system/text.h"
#include "asylum/system/video.h"
@@ -125,6 +127,8 @@ Common::Error AsylumEngine::run() {
_screen = new Screen(this);
_script = new ScriptManager(this);
_sound = new Sound(this, _mixer);
+ _special = new Special(this);
+ _speech = new Speech(this);
_text = new Text(this);
_video = new Video(this, _mixer);
initPuzzles();
diff --git a/engines/asylum/asylum.h b/engines/asylum/asylum.h
index aaeba500db..1989d6967b 100644
--- a/engines/asylum/asylum.h
+++ b/engines/asylum/asylum.h
@@ -73,6 +73,8 @@ class Savegame;
class Scene;
class Screen;
class ScriptManager;
+class Special;
+class Speech;
class Sound;
class Text;
class Video;
@@ -139,6 +141,8 @@ public:
Scene *scene() { return _scene; }
Screen *screen() { return _screen; }
ScriptManager *script() { return _script; }
+ Special *special() { return _special; }
+ Speech *speech() { return _speech; }
Sound *sound() { return _sound; }
Text *text() { return _text; }
Video *video() { return _video; }
@@ -191,6 +195,8 @@ private:
Scene *_scene;
Screen *_screen;
ScriptManager *_script;
+ Special *_special;
+ Speech *_speech;
Sound *_sound;
Text *_text;
Video *_video;
diff --git a/engines/asylum/resources/object.cpp b/engines/asylum/resources/object.cpp
index a71715fbf1..99fefb803a 100644
--- a/engines/asylum/resources/object.cpp
+++ b/engines/asylum/resources/object.cpp
@@ -344,7 +344,7 @@ void Object::update() {
if (doPlaySounds)
playSounds();
- getScene()->special()->run(this, -1);
+ getSpecial()->run(this, -1);
}
void Object::setNextFrame(int32 targetFlags) {
diff --git a/engines/asylum/shared.h b/engines/asylum/shared.h
index e09a3f84c7..9af8c3ed1a 100644
--- a/engines/asylum/shared.h
+++ b/engines/asylum/shared.h
@@ -608,7 +608,8 @@ enum ObjectFlag {
#define getScreen() _vm->screen()
#define getScript() _vm->script()
#define getSharedData() _vm->getData()
-#define getSpeech() _vm->scene()->speech()
+#define getSpecial() _vm->special()
+#define getSpeech() _vm->speech()
#define getText() _vm->text()
#define getVideo() _vm->video()
#define getWorld() _vm->scene()->worldstats()
diff --git a/engines/asylum/views/scene.cpp b/engines/asylum/views/scene.cpp
index 84b9acfd1e..d2ca8f60d5 100644
--- a/engines/asylum/views/scene.cpp
+++ b/engines/asylum/views/scene.cpp
@@ -58,19 +58,15 @@ int g_debugObjects;
int g_debugScrolling;
Scene::Scene(AsylumEngine *engine): _vm(engine),
- _special(NULL), _speech(NULL), _polygons(NULL), _ws(NULL) {
+ _polygons(NULL), _ws(NULL) {
// Initialize data
_packId = kResourcePackInvalid;
_playerIndex = 0;
- _walking = false;
g_debugPolygons = 0;
g_debugObjects = 0;
g_debugScrolling = 0;
-
- _special = new Special(_vm);
- _speech = new Speech(_vm);
}
Scene::~Scene() {
@@ -80,8 +76,6 @@ Scene::~Scene() {
// Clear script queue
getScript()->reset();
- delete _special;
- delete _speech;
delete _polygons;
delete _ws;
@@ -481,7 +475,7 @@ bool Scene::updateScreen() {
}
if (getSpeech()->getSoundResourceId() != 0) {
- if (getSound()->isPlaying(_speech->getSoundResourceId())) {
+ if (getSound()->isPlaying(getSpeech()->getSoundResourceId())) {
getSpeech()->prepareSpeech();
} else {
getSpeech()->resetResourceIds();
diff --git a/engines/asylum/views/scene.h b/engines/asylum/views/scene.h
index ffe1c57af4..d7ed4786b6 100644
--- a/engines/asylum/views/scene.h
+++ b/engines/asylum/views/scene.h
@@ -167,8 +167,6 @@ public:
bool isInActionArea(const Common::Point &pt, ActionArea *area);
Polygons *polygons() { return _polygons; }
- Special *special() { return _special; }
- Speech *speech() { return _speech; }
WorldStats *worldstats() { return _ws; }
private:
@@ -176,13 +174,7 @@ private:
ResourcePackId _packId;
int32 _playerIndex;
- bool _walking;
-
- ActorDirection _globalDirection;
-
- Special *_special;
- Speech *_speech;
Polygons *_polygons;
WorldStats *_ws;
Commit: b115baf346753d29099a348a6b9927c3223ea398
https://github.com/scummvm/scummvm/commit/b115baf346753d29099a348a6b9927c3223ea398
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:31+02:00
Commit Message:
ASYLUM: Implement special Scene hit actions
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@628 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/asylum.cpp
engines/asylum/resources/actor.h
engines/asylum/shared.h
engines/asylum/views/scene.cpp
engines/asylum/views/scene.h
diff --git a/engines/asylum/asylum.cpp b/engines/asylum/asylum.cpp
index d371147284..9e520a4ef9 100644
--- a/engines/asylum/asylum.cpp
+++ b/engines/asylum/asylum.cpp
@@ -289,6 +289,11 @@ void AsylumEngine::handleEvents() {
_handler->handleEvent(ev);
break;
+ case Common::EVENT_KEYUP:
+ // Handle key events
+ _handler->handleEvent(ev);
+ break;
+
case Common::EVENT_MOUSEMOVE:
case Common::EVENT_LBUTTONDOWN:
case Common::EVENT_LBUTTONUP:
diff --git a/engines/asylum/resources/actor.h b/engines/asylum/resources/actor.h
index 32b902ae21..b99dcf7681 100644
--- a/engines/asylum/resources/actor.h
+++ b/engines/asylum/resources/actor.h
@@ -282,6 +282,16 @@ public:
*/
static ActorDirection direction(Common::Point vec1, Common::Point vec2);
+ /**
+ * Get the euclidean distance between the two vectors
+ *
+ * @param vec1 The first vector.
+ * @param vec2 The second vector.
+ *
+ * @return the distance.
+ */
+ static uint32 distance(Common::Point vec1, Common::Point vec2);
+
private:
AsylumEngine *_vm;
@@ -489,16 +499,6 @@ private:
*/
static void updateCoordinatesForDirection(ActorDirection direction, int32 delta, Common::Point *point);
- /**
- * Get the euclidean distance between the two vectors
- *
- * @param vec1 The first vector.
- * @param vec2 The second vector.
- *
- * @return the distance.
- */
- static uint32 distance(Common::Point vec1, Common::Point vec2);
-
/**
* Get the angle between the two vectors
*
diff --git a/engines/asylum/shared.h b/engines/asylum/shared.h
index 9af8c3ed1a..a4a9b2c265 100644
--- a/engines/asylum/shared.h
+++ b/engines/asylum/shared.h
@@ -138,7 +138,8 @@ enum GameFlag {
kGameFlag1067 = 1067,
kGameFlag1108 = 1108,
kGameFlag1131 = 1131,
- kGameFlag1137 = 1137
+ kGameFlag1137 = 1137,
+ kGameFlag1144 = 1144
};
enum ChapterIndex {
diff --git a/engines/asylum/views/scene.cpp b/engines/asylum/views/scene.cpp
index d2ca8f60d5..2232e69868 100644
--- a/engines/asylum/views/scene.cpp
+++ b/engines/asylum/views/scene.cpp
@@ -64,6 +64,8 @@ Scene::Scene(AsylumEngine *engine): _vm(engine),
_packId = kResourcePackInvalid;
_playerIndex = 0;
+ _hitAreaChapter7Counter = 0;
+
g_debugPolygons = 0;
g_debugObjects = 0;
g_debugScrolling = 0;
@@ -257,8 +259,16 @@ bool Scene::handleEvent(const AsylumEvent &evt) {
return update();
case Common::EVENT_KEYDOWN:
+ if (evt.kbd.flags & Common::KBD_CTRL)
+ _isCTRLPressed = true;
+
return key(evt);
+ case Common::EVENT_KEYUP:
+ if (!(evt.kbd.flags & Common::KBD_CTRL))
+ _isCTRLPressed = false;
+ break;
+
case Common::EVENT_LBUTTONDOWN:
case Common::EVENT_RBUTTONDOWN:
case Common::EVENT_MBUTTONDOWN:
@@ -343,7 +353,9 @@ bool Scene::update() {
}
bool Scene::key(const AsylumEvent &evt) {
- error("[Scene::key] Not implemented!");
+ warning("[Scene::key] Not implemented!");
+
+ return true;
}
bool Scene::clickDown(const AsylumEvent &evt) {
@@ -1207,24 +1219,71 @@ void Scene::playerReaction() {
}
void Scene::hitAreaChapter2(int32 id) {
- error("[Scene::hitAreaChapter2] Not implemented!");
+ if (id == 783)
+ getActor()->setField638(6);
}
void Scene::hitAreaChapter7(int32 id) {
- error("[Scene::hitAreaChapter7] Not implemented!");
+ switch (id) {
+ default:
+ break;
+
+ case 1088:
+ if (_isCTRLPressed)
+ _vm->setGameFlag(kGameFlag1144);
+ break;
+
+ case 2504:
+ if (++_hitAreaChapter7Counter > 20) {
+ _vm->setGameFlag(kGameFlag1108);
+ getActor(1)->setPosition(570, 225, kDirectionN, 0);
+ getActor(1)->show();
+ }
+ break;
+ }
}
void Scene::hitAreaChapter11(int32 id) {
- error("[Scene::hitAreaChapter11] Not implemented!");
+ if (id == 1670)
+ _ws->field_E849C = 666;
}
void Scene::hitActorChapter2(ActorIndex index) {
- error("[Scene::hitActorChapter2] Not implemented!");
+ Actor *player = getActor();
+
+ if (player->getStatus() != kActorStatus14 && player->getStatus() != kActorStatus12)
+ return;
+
+ if (index == 11) {
+ player->faceTarget(index + 9, kDirectionFromActor);
+ player->updateStatus(kActorStatus15);
+
+ Actor *actor11 = getActor(index);
+
+ Common::Point pointPlayer(player->getPoint1()->x + player->getPoint2()->x, player->getPoint1()->y + player->getPoint2()->y);
+ Common::Point pointActor11(actor11->getPoint1()->x + actor11->getPoint2()->x, actor11->getPoint1()->y + actor11->getPoint2()->y);
+
+ if (Actor::distance(pointPlayer, pointActor11) < 150) {
+ if (actor11->getStatus() == kActorStatus12)
+ actor11->updateStatus(kActorStatus18);
+
+ if (actor11->getStatus() == kActorStatusEnabled)
+ actor11->updateStatus(kActorStatus14);
+ }
+
+ getSharedData()->setData(38, index);
+
+ } else if (index > 12) {
+ player->faceTarget(index + 9, kDirectionFromActor);
+ player->updateStatus(kActorStatus15);
+ getSharedData()->setData(38, index);
+ }
}
void Scene::hitActorChapter11(ActorIndex index) {
- error("[Scene::hitActorChapter11] Not implemented!");
+ if (_ws->field_E848C < 3)
+ _ws->field_E849C = index;
}
diff --git a/engines/asylum/views/scene.h b/engines/asylum/views/scene.h
index d7ed4786b6..933a27514c 100644
--- a/engines/asylum/views/scene.h
+++ b/engines/asylum/views/scene.h
@@ -386,6 +386,8 @@ private:
void playerReaction();
void hitAreaChapter2(int32 id);
+ bool _isCTRLPressed;
+ int32 _hitAreaChapter7Counter;
void hitAreaChapter7(int32 id);
void hitAreaChapter11(int32 id);
Commit: 2540959025881da155a99e247ca582e25cc3ff2d
https://github.com/scummvm/scummvm/commit/2540959025881da155a99e247ca582e25cc3ff2d
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:31+02:00
Commit Message:
ASYLUM: Finish implementing some Scene functions
- Implement Scene::drawChapter5()
- Add missing palette fade and waiting to Scene::playIntroSpeech()
- Add Scene::adjustCoordinates()
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@629 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/system/screen.cpp
engines/asylum/system/screen.h
engines/asylum/views/scene.cpp
engines/asylum/views/scene.h
diff --git a/engines/asylum/system/screen.cpp b/engines/asylum/system/screen.cpp
index bd4de92f08..48b244da35 100644
--- a/engines/asylum/system/screen.cpp
+++ b/engines/asylum/system/screen.cpp
@@ -208,6 +208,10 @@ void Screen::setPalette(byte *rgbPalette) const {
_vm->_system->setPalette(palette, 0, 256);
}
+void Screen::setupPaletteAndStartFade(uint32 red, int32 milliseconds, int32 param) {
+ warning("[Screen::setupPaletteAndStartFade] not implemented");
+}
+
void Screen::paletteFade(uint32 red, int32 milliseconds, int32 param) {
warning("[Screen::paletteFade] not implemented");
}
diff --git a/engines/asylum/system/screen.h b/engines/asylum/system/screen.h
index e3c0032dd1..5af3bbfc81 100644
--- a/engines/asylum/system/screen.h
+++ b/engines/asylum/system/screen.h
@@ -88,6 +88,7 @@ public:
// Palette
void setPalette(byte *rgbPalette) const;
void setPalette(ResourceId id);
+ void setupPaletteAndStartFade(uint32 red, int32 milliseconds, int32 param);
void paletteFade(uint32 red, int32 milliseconds, int32 param);
void startPaletteFade(ResourceId resourceId, int32 milliseconds, int32 param);
void updatePalette(int32 param);
diff --git a/engines/asylum/views/scene.cpp b/engines/asylum/views/scene.cpp
index 2232e69868..4f4a5b52ae 100644
--- a/engines/asylum/views/scene.cpp
+++ b/engines/asylum/views/scene.cpp
@@ -65,6 +65,7 @@ Scene::Scene(AsylumEngine *engine): _vm(engine),
_playerIndex = 0;
_hitAreaChapter7Counter = 0;
+ _chapter5FrameIndex = 0;
g_debugPolygons = 0;
g_debugObjects = 0;
@@ -497,8 +498,7 @@ bool Scene::updateScreen() {
if (getWorld()->chapter == kChapter5) {
if (_vm->isGameFlagSet(kGameFlag249))
- error("[Scene::updateScreen] Not implemented!");
- //drawSceneData;
+ drawChapter5();
}
return false;
@@ -1312,9 +1312,14 @@ void Scene::playIntroSpeech() {
}
getScreen()->clear();
+ getScreen()->setupPaletteAndStartFade(0, 0, 0);
- // TODO do palette fade and wait until sound is done
- warning("[Scene::playIntroSpeech] Missing palette fade and wait!");
+ do {
+ // Poll events (this ensure we don't freeze the screen)
+ Common::Event ev;
+ _vm->getEventManager()->pollEvent(ev);
+
+ } while (getSound()->isPlaying(resourceId));
}
void Scene::stopSpeech() {
@@ -1340,6 +1345,11 @@ bool Scene::rectIntersect(int32 x, int32 y, int32 x1, int32 y1, int32 x2, int32
return (x >= x3 && y >= y3 && x1 >= x2 && y1 >= y2);
}
+void Scene::adjustCoordinates(Common::Point *point) {
+ point->x = _ws->xLeft + getCursor()->position().x;
+ point->y = _ws->yTop + getCursor()->position().y;
+}
+
Actor* Scene::getActor(ActorIndex index) {
if (!_ws)
error("[Scene::getActor] WorldStats not initialized properly!");
@@ -1740,6 +1750,19 @@ void Scene::adjustActorPriority(ActorIndex index) {
}
}
+void Scene::drawChapter5() {
+ if (getSharedData()->getFlag(kFlagSkipDrawScene))
+ return;
+
+ for (uint y = 0; y < 512; y = y + 64) {
+ for (uint x = 0; x < 704; x = x + 64) {
+ getScreen()->draw(MAKE_RESOURCE(kResourcePackShared, 58), _chapter5FrameIndex, x + (_ws->xLeft % 64) / 8, y + (_ws->yTop % 64) / 8, 0);
+ }
+ }
+
+ _chapter5FrameIndex = (_chapter5FrameIndex + 1) % GraphicResource::getFrameCount(_vm, MAKE_RESOURCE(kResourcePackShared, 58));
+}
+
//////////////////////////////////////////////////////////////////////////
// Debug
//////////////////////////////////////////////////////////////////////////
diff --git a/engines/asylum/views/scene.h b/engines/asylum/views/scene.h
index 933a27514c..7f30050336 100644
--- a/engines/asylum/views/scene.h
+++ b/engines/asylum/views/scene.h
@@ -304,6 +304,12 @@ private:
*/
void adjustActorPriority(ActorIndex index);
+ /**
+ * Special drawing function for chapter 5.
+ */
+ void drawChapter5();
+ uint32 _chapter5FrameIndex;
+
//////////////////////////////////////////////////////////////////////////
// HitTest
//////////////////////////////////////////////////////////////////////////
@@ -434,6 +440,13 @@ private:
*/
bool rectIntersect(int32 x, int32 y, int32 x1, int32 y1, int32 x2, int32 y2, int32 x3, int32 y3);
+ /**
+ * Adjust coordinates.
+ *
+ * @param point The point.
+ */
+ void adjustCoordinates(Common::Point *point);
+
//////////////////////////////////////////////////////////////////////////
// Scene debugging
//////////////////////////////////////////////////////////////////////////
Commit: 4c7cb12983706faa5c836f17b3dd81f0b292983d
https://github.com/scummvm/scummvm/commit/4c7cb12983706faa5c836f17b3dd81f0b292983d
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:31+02:00
Commit Message:
ASYLUM: Update Scene::updateMouse() and Scene::updateAmbientSounds()
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@630 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/asylum.cpp
engines/asylum/asylum.h
engines/asylum/resources/data.h
engines/asylum/resources/worldstats.cpp
engines/asylum/resources/worldstats.h
engines/asylum/system/sound.h
engines/asylum/views/menu.cpp
engines/asylum/views/menu.h
engines/asylum/views/scene.cpp
diff --git a/engines/asylum/asylum.cpp b/engines/asylum/asylum.cpp
index 9e520a4ef9..e0c38b0a4d 100644
--- a/engines/asylum/asylum.cpp
+++ b/engines/asylum/asylum.cpp
@@ -425,6 +425,14 @@ void AsylumEngine::updateReverseStereo() {
//////////////////////////////////////////////////////////////////////////
#define FLAG_MASK 0xFFFFFFE0
+void AsylumEngine::setGameFlagByIndex(int32 index) {
+ _gameFlags[index] = 1;
+}
+
+int32 AsylumEngine::getGameFlagByIndex(int32 index) {
+ return _gameFlags[index];
+}
+
void AsylumEngine::setGameFlag(GameFlag flag) {
_gameFlags[flag / 32] |= 1 << (flag % FLAG_MASK);
}
@@ -445,4 +453,8 @@ bool AsylumEngine::isGameFlagNotSet(GameFlag flag) const {
return ((1 << (flag % FLAG_MASK)) & (unsigned int)_gameFlags[flag / 32]) >> (flag % FLAG_MASK) == 0;
}
+void AsylumEngine::resetFlags() {
+ memset(&_gameFlags[130], 0, 60);
+}
+
} // namespace Asylum
diff --git a/engines/asylum/asylum.h b/engines/asylum/asylum.h
index 1989d6967b..a445660e9e 100644
--- a/engines/asylum/asylum.h
+++ b/engines/asylum/asylum.h
@@ -148,11 +148,14 @@ public:
Video *video() { return _video; }
// Flags
+ void setGameFlagByIndex(int32 index);
+ int32 getGameFlagByIndex(int32 index);
void setGameFlag(GameFlag flag);
void clearGameFlag(GameFlag flag);
void toggleGameFlag(GameFlag flag);
bool isGameFlagSet(GameFlag flag) const;
bool isGameFlagNotSet(GameFlag flag) const;
+ void resetFlags();
// Misc
uint getRandom(uint max) { return _rnd.getRandomNumber(max); }
@@ -207,7 +210,7 @@ private:
// Game data
SharedData _data;
- int _gameFlags[1512];
+ int _gameFlags[145];
bool _introPlayed;
void handleEvents();
diff --git a/engines/asylum/resources/data.h b/engines/asylum/resources/data.h
index 1a37259304..084d913fd3 100644
--- a/engines/asylum/resources/data.h
+++ b/engines/asylum/resources/data.h
@@ -117,10 +117,10 @@ public:
_sceneYTop = 0;
_sceneOffset = 0;
_sceneOffsetAdd = 0;
- memset(&_cursorResources[13], kResourceNone, sizeof(_cursorResources));
- memset(&_sceneFonts[3], kResourceNone, sizeof(_sceneFonts));
+ memset(&_cursorResources, kResourceNone, sizeof(_cursorResources));
+ memset(&_sceneFonts, kResourceNone, sizeof(_sceneFonts));
_currentPaletteId = kResourceNone;
- memset(&_cellShadeMasks[3], 0, sizeof(_cellShadeMasks));
+ memset(&_cellShadeMasks, 0, sizeof(_cellShadeMasks));
_smallCurUp = 0;
_smallCurDown = 0;
_encounterFrameBg = 0;
@@ -130,15 +130,16 @@ public:
_matteInitialized = false;
_mattePlaySound = false;
_currentScreenUpdatesCount = 0;
- memset(&_data1[50], 0, sizeof(_data1));
- memset(&_data2[11], 0, sizeof(_data2));
+ memset(&_data1, 0, sizeof(_data1));
+ memset(&_data2, 0, sizeof(_data2));
_actorUpdateStatusEnabledCounter = 0;
- memset(&_data3[9], 0, sizeof(_data3));
+ memset(&_data3, 0, sizeof(_data3));
_flagScene1 = false;
- memset(&_movies[49], 0, sizeof(_movies));
+ memset(&_movies, 0, sizeof(_movies));
_actorUpdateStatus15Check = false;
_flag2 = false;
_globalDirection = kDirectionN;
+ memset(&_ambientTick, 0, sizeof(_ambientTick));
// Screen updates
_flagRedraw = false;
@@ -235,6 +236,13 @@ public:
}
}
+ uint32 *getAmbientTick(uint32 index) {
+ if (index >= ARRAYSIZE(_ambientTick))
+ error("[SharedData::getAmbientTick] index is outside valid values (was: %d, valid: [0:15]", index);
+
+ return &_ambientTick[index];
+ };
+
//////////////////////////////////////////////////////////////////////////
// Flags
//////////////////////////////////////////////////////////////////////////
@@ -362,6 +370,8 @@ private:
ActorDirection _globalDirection;
+ uint32 _ambientTick[16];
+
// Screen updates
bool _flagRedraw;
diff --git a/engines/asylum/resources/worldstats.cpp b/engines/asylum/resources/worldstats.cpp
index 7b320d71eb..44e0342ca9 100644
--- a/engines/asylum/resources/worldstats.cpp
+++ b/engines/asylum/resources/worldstats.cpp
@@ -81,7 +81,7 @@ WorldStats::WorldStats(AsylumEngine *engine) : _vm(engine) {
actorType = 0;
memset(&soundResourceIds, kResourceNone, sizeof(soundResourceIds));
- numAmbientSound = 0;
+ numAmbientSounds = 0;
musicStatus = 0;
musicCurrentResourceIndex = kResourceNone;
musicFlag = 0;
@@ -190,7 +190,7 @@ void WorldStats::load(Common::SeekableReadStream *stream) {
ambientSounds[s].resourceId = (ResourceId)stream->readSint32LE();
ambientSounds[s].delta = stream->readSint32LE();
ambientSounds[s].attenuation = stream->readSint32LE();
- ambientSounds[s].field_14 = stream->readSint32LE();
+ ambientSounds[s].nextTick = stream->readSint32LE();
for (int32 i = 0; i < 6; i++)
ambientSounds[s].flagNum[i] = (GameFlag)stream->readSint32LE();
@@ -199,7 +199,7 @@ void WorldStats::load(Common::SeekableReadStream *stream) {
ambientSounds[s].y = stream->readSint32LE();
}
- numAmbientSound = stream->readSint32LE();
+ numAmbientSounds = stream->readSint32LE();
musicStatus = stream->readSint32LE();
musicCurrentResourceIndex = stream->readUint32LE();
musicFlag = stream->readSint32LE();
diff --git a/engines/asylum/resources/worldstats.h b/engines/asylum/resources/worldstats.h
index ec23573ceb..62633faf99 100644
--- a/engines/asylum/resources/worldstats.h
+++ b/engines/asylum/resources/worldstats.h
@@ -111,7 +111,7 @@ public:
int32 actorType;
ResourceId soundResourceIds[50];
AmbientSoundItem ambientSounds[15];
- int32 numAmbientSound;
+ int32 numAmbientSounds;
int32 musicStatus;
uint32 musicCurrentResourceIndex;
int32 musicFlag;
diff --git a/engines/asylum/system/sound.h b/engines/asylum/system/sound.h
index 69c10653fb..e7faff7154 100644
--- a/engines/asylum/system/sound.h
+++ b/engines/asylum/system/sound.h
@@ -78,7 +78,7 @@ struct AmbientSoundItem {
ResourceId resourceId;
int32 delta;
int32 attenuation;
- int32 field_14;
+ int32 nextTick;
GameFlag flagNum[6];
int32 x;
int32 y;
@@ -89,7 +89,7 @@ struct AmbientSoundItem {
resourceId = kResourceNone;
delta = 0;
attenuation = 0;
- field_14 = 0;
+ nextTick = 0;
memset(&flagNum, 0, sizeof(flagNum));
x = 0;
y = 0;
diff --git a/engines/asylum/views/menu.cpp b/engines/asylum/views/menu.cpp
index bbf9352176..2de2d4c1a6 100644
--- a/engines/asylum/views/menu.cpp
+++ b/engines/asylum/views/menu.cpp
@@ -189,14 +189,14 @@ MainMenu::MenuScreen MainMenu::findMousePosition() {
void MainMenu::playTestSounds() {
_testSoundsPlaying = true;
- getSound()->playSound(kAmbiantSound, true, Config.ambientVolume);
+ getSound()->playSound(kAmbientSound, true, Config.ambientVolume);
getSound()->playSound(kSfxSound, true, Config.sfxVolume);
getSound()->playSound(kVoiceSound, true, Config.voiceVolume);
}
void MainMenu::stopTestSounds() {
_testSoundsPlaying = false;
- getSound()->stop(kAmbiantSound);
+ getSound()->stop(kAmbientSound);
getSound()->stop(kSfxSound);
getSound()->stop(kVoiceSound);
}
@@ -260,10 +260,10 @@ void MainMenu::adjustTestVolume() {
if ((Config.movieVolume / 250 + 20) <= 0)
getSound()->playMusic(_musicResourceId);
- if (getSound()->isPlaying(kAmbiantSound))
- getSound()->setVolume(kAmbiantSound, Config.ambientVolume);
+ if (getSound()->isPlaying(kAmbientSound))
+ getSound()->setVolume(kAmbientSound, Config.ambientVolume);
else if (_testSoundsPlaying)
- getSound()->playSound(kAmbiantSound, true, Config.ambientVolume);
+ getSound()->playSound(kAmbientSound, true, Config.ambientVolume);
if (getSound()->isPlaying(kSfxSound))
getSound()->setVolume(kSfxSound, Config.sfxVolume);
diff --git a/engines/asylum/views/menu.h b/engines/asylum/views/menu.h
index 215f652185..8487a1e5db 100644
--- a/engines/asylum/views/menu.h
+++ b/engines/asylum/views/menu.h
@@ -82,7 +82,7 @@ private:
kFontBlue = MAKE_RESOURCE(kResourcePackShared, 22),
kFontYellow = MAKE_RESOURCE(kResourcePackShared, 16),
kSfxSound = MAKE_RESOURCE(kResourcePackShared, 41),
- kAmbiantSound = MAKE_RESOURCE(kResourcePackShared, 42),
+ kAmbientSound = MAKE_RESOURCE(kResourcePackShared, 42),
kVoiceSound = MAKE_RESOURCE(kResourcePackShared, 43)
};
diff --git a/engines/asylum/views/scene.cpp b/engines/asylum/views/scene.cpp
index 4f4a5b52ae..5ce0cc5a1b 100644
--- a/engines/asylum/views/scene.cpp
+++ b/engines/asylum/views/scene.cpp
@@ -231,11 +231,12 @@ void Scene::load(ResourcePackId packId) {
fd->close();
delete fd;
- // TODO figure out what field_120 is used for
+ _vm->resetFlags();
_ws->field_120 = -1;
+ int32 tick = _vm->getTick();
for (uint32 a = 0; a < _ws->actors.size(); a++)
- _ws->actors[a]->setLastScreenUpdate(_vm->getTick());
+ _ws->actors[a]->setLastScreenUpdate(tick);
getCursor()->show();
}
@@ -536,151 +537,132 @@ bool Scene::updateScene() {
}
void Scene::updateMouse() {
- Common::Rect actorPos;
- Common::Point pt;
- Actor *act = getActor();
+ Actor *player = getActor();
+ Common::Point mouse = getCursor()->position();
- // The code below was from
- // .text:0040A1B0 getCharacterScreenPosition()
- // which was only ever called at this point, so
- // inlining it for simplicity
- pt.x = (int16)(act->getPoint1()->x -_ws->xLeft);
- pt.y = (int16)(act->getPoint1()->y -_ws->yTop);
-
- if (_packId != 2 || _playerIndex != 10) {
- actorPos.left = pt.x + 20;
- actorPos.top = pt.y;
- actorPos.right = (int16)(pt.x + 2 * act->getPoint2()->x);
- actorPos.bottom = (int16)(pt.y + act->getPoint2()->y);
+ Common::Point pt;
+ player->adjustCoordinates(&pt);
+
+ Common::Rect actorRect;
+ if (_ws->chapter != kChapter2 || _playerIndex != 10) {
+ actorRect.left = pt.x + 20;
+ actorRect.top = pt.y;
+ actorRect.right = (int16)(pt.x + 2 * player->getPoint2()->x);
+ actorRect.bottom = (int16)(pt.y + player->getPoint2()->y);
} else {
- actorPos.left = pt.x + 50;
- actorPos.top = pt.y + 60;
- actorPos.right = (int16)(pt.x + getActor(10)->getPoint2()->x + 10);
- actorPos.bottom = (int16)(pt.y + getActor(10)->getPoint2()->y - 20);
+ actorRect.left = pt.x + 50;
+ actorRect.top = pt.y + 60;
+ actorRect.right = (int16)(pt.x + getActor(10)->getPoint2()->x + 10);
+ actorRect.bottom = (int16)(pt.y + getActor(10)->getPoint2()->y - 20);
}
- ActorDirection dir = kDirectionInvalid;
- bool done = false;
+ ActorDirection newDirection = kDirectionInvalid;
- if (getCursor()->position().x < actorPos.left) {
- if (getCursor()->position().y >= actorPos.top) {
- if (getCursor()->position().y > actorPos.bottom) {
- if (act->getDirection() == 2) {
- if (getCursor()->position().y - actorPos.bottom > 10)
- dir = kDirectionSO;
+ if (mouse.x < actorRect.left) {
+ if (mouse.y >= actorRect.top) {
+ if (mouse.y > actorRect.bottom) {
+ if (player->getDirection() == kDirectionO) {
+ if ((mouse.y - actorRect.bottom) > 10)
+ newDirection = kDirectionSO;
} else {
- if (act->getDirection() == kDirectionS) {
- if (actorPos.left - getCursor()->position().x > 10)
- dir = kDirectionSO;
+ if (player->getDirection() == kDirectionS) {
+ if ((actorRect.left - mouse.x) > 10)
+ newDirection = kDirectionSO;
} else {
- dir = kDirectionSO;
+ newDirection = kDirectionSO;
}
}
} else {
- if (act->getDirection() == 1) {
- if (getCursor()->position().y - actorPos.top > 10)
- dir = kDirectionO;
+ if (player->getDirection() == kDirectionNO) {
+ if ((mouse.y - actorRect.top) > 10)
+ newDirection = kDirectionO;
} else {
- if (act->getDirection() == kDirectionSO) {
- if (actorPos.bottom - getCursor()->position().y > 10)
- dir = kDirectionO;
+ if (player->getDirection() == kDirectionSO) {
+ if ((actorRect.bottom - mouse.y) > 10)
+ newDirection = kDirectionO;
} else {
- dir = kDirectionO;
+ newDirection = kDirectionO;
}
}
}
} else {
- if (act->getDirection()) {
- if (act->getDirection() == kDirectionO) {
- if (actorPos.top - getCursor()->position().y > 10)
- dir = kDirectionNO;
+ if (player->getDirection() != kDirectionN) {
+ if (player->getDirection() == kDirectionO) {
+ if ((actorRect.top - mouse.y) > 10)
+ newDirection = kDirectionNO;
} else {
- dir = kDirectionNO;
+ newDirection = kDirectionNO;
}
} else {
- if (actorPos.left - getCursor()->position().x > 10)
- dir = kDirectionNO;
+ if ((actorRect.left - mouse.x) > 10)
+ newDirection = kDirectionNO;
}
}
- done = true;
- }
- if (!done && getCursor()->position().x <= actorPos.right) {
- if (getCursor()->position().y >= actorPos.top) {
- if (getCursor()->position().y > actorPos.bottom) {
- if (act->getDirection() == kDirectionSO) {
- if (getCursor()->position().x - actorPos.left > 10)
- dir = kDirectionS;
+ } else if (mouse.x <= actorRect.right) {
+ if (mouse.y >= actorRect.top) {
+ if (mouse.y > actorRect.bottom) {
+ if (player->getDirection() == kDirectionSO) {
+ if ((mouse.x - actorRect.left) > 10)
+ newDirection = kDirectionS;
} else {
- if (act->getDirection() == kDirectionSE) {
- if (actorPos.right - getCursor()->position().x > 10)
- dir = kDirectionS;
+ if (player->getDirection() == kDirectionSE) {
+ if ((actorRect.right - mouse.x) > 10)
+ newDirection = kDirectionS;
} else {
- dir = kDirectionS;
+ newDirection = kDirectionS;
}
}
}
} else {
- if (act->getDirection() == kDirectionNO) {
- if (getCursor()->position().x - actorPos.left > 10)
- dir = kDirectionN;
+ if (player->getDirection() == kDirectionNO) {
+ if ((mouse.x - actorRect.left) > 10)
+ newDirection = kDirectionN;
} else {
- if (act->getDirection() == kDirectionNE) {
- if (actorPos.right - getCursor()->position().x > 10)
- dir = kDirectionN;
+ if (player->getDirection() == kDirectionNE) {
+ if ((actorRect.right - mouse.x) > 10)
+ newDirection = kDirectionN;
} else {
- dir = kDirectionN;
+ newDirection = kDirectionN;
}
}
}
- done = true;
- }
-
- if (!done && getCursor()->position().y < actorPos.top) {
- if (act->getDirection()) {
- if (act->getDirection() == kDirectionE) {
- if (actorPos.top - getCursor()->position().y > 10)
- dir = kDirectionNE;
+ } else if (mouse.y < actorRect.top) {
+ if (player->getDirection() != kDirectionN) {
+ if (player->getDirection() == kDirectionE) {
+ if ((actorRect.top - mouse.y) > 10)
+ newDirection = kDirectionNE;
} else {
- dir = kDirectionNE;
+ newDirection = kDirectionNE;
}
} else {
- if (getCursor()->position().x - actorPos.right > 10)
- dir = kDirectionNE;
+ if ((mouse.x - actorRect.right) > 10)
+ newDirection = kDirectionNE;
}
- done = true;
- }
-
- if (!done && getCursor()->position().y <= actorPos.bottom) {
- if (act->getDirection() == kDirectionSE) {
- if (actorPos.bottom - getCursor()->position().y > 10)
- dir = kDirectionE;
+ } else if (mouse.y <= actorRect.bottom) {
+ if (player->getDirection() == kDirectionSE) {
+ if ((actorRect.bottom - mouse.y) > 10)
+ newDirection = kDirectionE;
} else {
- if (act->getDirection() == kDirectionNE) {
- if (getCursor()->position().y - actorPos.top > 10)
- dir = kDirectionE;
+ if (player->getDirection() == kDirectionNE) {
+ if ((mouse.y - actorRect.top) > 10)
+ newDirection = kDirectionE;
} else {
- dir = kDirectionE;
+ newDirection = kDirectionE;
}
}
- done = true;
- }
-
- if (!done && act->getDirection() == kDirectionS) {
- if (getCursor()->position().x - actorPos.right <= 10)
- done = true;
- if (!done)
- dir = kDirectionSE;
+ } else if ( player->getDirection() == kDirectionS) {
+ if ((mouse.x - actorRect.right) > 10)
+ newDirection = kDirectionSE;
+ } else if ((player->getDirection() != kDirectionE || (mouse.y - actorRect.bottom) > 10)) {
+ newDirection = kDirectionSE;
}
- if (!done && (act->getDirection() != kDirectionE || getCursor()->position().y - actorPos.bottom > 10))
- dir = kDirectionSE;
-
- updateCursor(dir, actorPos);
+ updateCursor(newDirection, actorRect);
- if (dir >= 0) {
- if (act->getStatus() == 1 || act->getStatus() == 12)
- act->setDirection(dir);
+ if (newDirection >= kDirectionN) {
+ if (player->getStatus() == kActorStatus1 || player->getStatus() == kActorStatus12)
+ player->updateFromDirection(newDirection);
}
}
@@ -708,11 +690,12 @@ void Scene::updateAmbientSounds() {
if (Config.performance <= 3)
return;
- for (int32 i = 0; i < _ws->numAmbientSound; i++) {
+ // The original loops for each actor, but the volume calculation is always the same
+
+ for (int32 i = 0; i < _ws->numAmbientSounds; i++) {
bool processSound = true;
- int panning = 0;
- int volume = 0;
AmbientSoundItem *snd = &_ws->ambientSounds[i];
+ uint32 *ambientTick = getSharedData()->getAmbientTick(i);
for (int32 f = 0; f < 6; f++) {
GameFlag gameFlag = snd->flagNum[f];
@@ -730,54 +713,69 @@ void Scene::updateAmbientSounds() {
}
if (processSound) {
if (_vm->sound()->isPlaying(snd->resourceId)) {
+
if (snd->field_0) {
- // TODO optimize
- // This adjustment only uses the actor at
- // index zero, but it's supposed to loop through
- // all available actors as well (I think)
- volume = getSound()->calculateVolumeAdjustement(snd->x, snd->y, snd->attenuation, snd->delta);
+ int32 volume = Config.ambientVolume + getSound()->calculateVolumeAdjustement(snd->x, snd->y, snd->attenuation, snd->delta);
+
if (volume <= 0) {
if (volume < -10000)
volume = -10000;
- // TODO setSoundVolume(snd->resourceId, volume);
- } else
- ; // TODO setSoundVolume(snd->resourceId, 0);
+
+ getSound()->setVolume(snd->resourceId, volume);
+ } else {
+ getSound()->setVolume(snd->resourceId, 0);
+ }
}
+
} else {
- int loflag = BYTE1(snd->flags);
- if (snd->field_0) {
- ; // TODO calculate panning at point
- } else {
- panning = 0;
- }
- if (snd->field_0 == 0) {
- volume = -(snd->delta ^ 2);
- } else {
+ int32 panning = (snd->field_0) ? getSound()->calculatePanningAtPoint(snd->x, snd->y) : 0;
+
+ int32 volume = 0;
+ if (snd->field_0)
volume = getSound()->calculateVolumeAdjustement(snd->x, snd->y, snd->attenuation, snd->delta);
- volume += Config.ambientVolume;
- }
- if (loflag & 2) {
- int tmpVol = volume;
+ else
+ volume = -pow((double)snd->delta, 2);
+
+ volume += Config.ambientVolume;
+
+
+ if (LOBYTE(snd->flags) & 1) {
+
+ getSound()->playSound(snd->resourceId, true, volume, panning);
+
+ } else if (LOBYTE(snd->flags) & 2) {
if (_vm->getRandom(10000) < 10) {
if (snd->field_0) {
getSound()->playSound(snd->resourceId, false, volume, panning);
} else {
- // FIXME will this even work?
- tmpVol += (_vm->getRandom(500)) * (((_vm->getRandom(100) >= 50) - 1) & 2) - 1;
+ int32 tmpVol = volume + _vm->getRandom(500) * ((((_vm->getRandom(100) >= 50) - 1) & 2) - 1);
+
if (tmpVol <= -10000)
- volume = -10000;
- if (volume >= 0)
+ tmpVol = -10000;
+
+ if (tmpVol >= 0)
tmpVol = 0;
- else
- if (tmpVol <= -10000)
- tmpVol = -10000;
+ else if (tmpVol <= -10000)
+ tmpVol = -10000;
+
getSound()->playSound(snd->resourceId, false, tmpVol, _vm->getRandom(20001) - 10000);
}
}
- } else {
- if (loflag & 4) {
- // TODO panning array stuff
+ } else if (LOBYTE(snd->flags) & 4) {
+ if (*ambientTick > _vm->getTick()) {
+ if (snd->nextTick >= 0)
+ *ambientTick = 60000 * snd->nextTick + _vm->getTick();
+ else
+ *ambientTick = _vm->getTick() - 1000 * snd->nextTick;
+
+ getSound()->playSound(snd->resourceId, false, volume, panning);
}
+ } else if (LOBYTE(snd->flags) & 8) {
+ if (_vm->getGameFlagByIndex(85 + i)) {
+ getSound()->playSound(snd->resourceId, false, volume, panning);
+ _vm->setGameFlagByIndex(85 + i);
+ }
+
}
}
} else {
Commit: e8933a7c0b891a442cdcb84e6d1ae06d0e34ac94
https://github.com/scummvm/scummvm/commit/e8933a7c0b891a442cdcb84e6d1ae06d0e34ac94
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:31+02:00
Commit Message:
ASYLUM: Fix scene palette not being set properly after fade
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@631 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/system/screen.cpp
engines/asylum/system/screen.h
engines/asylum/views/scene.cpp
diff --git a/engines/asylum/system/screen.cpp b/engines/asylum/system/screen.cpp
index 48b244da35..39a37bac38 100644
--- a/engines/asylum/system/screen.cpp
+++ b/engines/asylum/system/screen.cpp
@@ -209,23 +209,29 @@ void Screen::setPalette(byte *rgbPalette) const {
}
void Screen::setupPaletteAndStartFade(uint32 red, int32 milliseconds, int32 param) {
- warning("[Screen::setupPaletteAndStartFade] not implemented");
+ warning("[Screen::setupPaletteAndStartFade] Not implemented!");
+}
+
+void Screen::stopFadeAndSetPalette(ResourceId id, int32 milliseconds, int32 param) {
+ // HACK so we have a proper screen palette
+ setPalette(id);
+ warning("[Screen::stopFadeAndSetPalette] Not implemented!");
}
void Screen::paletteFade(uint32 red, int32 milliseconds, int32 param) {
- warning("[Screen::paletteFade] not implemented");
+ warning("[Screen::paletteFade] Not implemented!");
}
void Screen::startPaletteFade(ResourceId resourceId, int32 milliseconds, int32 param) {
- warning("[Screen::startPaletteFade] not implemented");
+ warning("[Screen::startPaletteFade] Not implemented!");
}
void Screen::updatePalette(int32 param) {
- error("[Screen::updatePalette] not implemented!");
+ error("[Screen::updatePalette] Not implemented!");
}
void Screen::makeGreyPalette() {
- warning("[Screen::makeGreyPalette] not implemented!");
+ warning("[Screen::makeGreyPalette] Not implemented!");
}
//////////////////////////////////////////////////////////////////////////
diff --git a/engines/asylum/system/screen.h b/engines/asylum/system/screen.h
index 5af3bbfc81..3e8537b409 100644
--- a/engines/asylum/system/screen.h
+++ b/engines/asylum/system/screen.h
@@ -89,6 +89,7 @@ public:
void setPalette(byte *rgbPalette) const;
void setPalette(ResourceId id);
void setupPaletteAndStartFade(uint32 red, int32 milliseconds, int32 param);
+ void stopFadeAndSetPalette(ResourceId id, int32 milliseconds, int32 param);
void paletteFade(uint32 red, int32 milliseconds, int32 param);
void startPaletteFade(ResourceId resourceId, int32 milliseconds, int32 param);
void updatePalette(int32 param);
diff --git a/engines/asylum/views/scene.cpp b/engines/asylum/views/scene.cpp
index 5ce0cc5a1b..e6e21eea86 100644
--- a/engines/asylum/views/scene.cpp
+++ b/engines/asylum/views/scene.cpp
@@ -474,16 +474,14 @@ bool Scene::updateScreen() {
if (getSharedData()->getFlag(kFlagScene1)) {
getScreen()->clear();
- //getScreen()->paletteSetupAndStartFade(0, 0, 0);
- //updateScene();
- //drawScene();
- // refresh screen
- //getScreen->paletteStopAndFade(getWorld()->currentPaletteId, 100, 10);
- //drawScene();
- // refresh screen
-
- warning("[Scene::updateScreen] Not implemented!");
+ getScreen()->setupPaletteAndStartFade(0, 0, 0);
+ updateScene();
+ drawScene();
+ getScreen()->copyBackBufferToScreen();
+ getScreen()->stopFadeAndSetPalette(getWorld()->currentPaletteId, 100, 10);
+ drawScene();
+ getScreen()->copyBackBufferToScreen();
getSharedData()->setFlag(kFlagScene1, false);
}
@@ -660,10 +658,9 @@ void Scene::updateMouse() {
updateCursor(newDirection, actorRect);
- if (newDirection >= kDirectionN) {
+ if (newDirection >= kDirectionN)
if (player->getStatus() == kActorStatus1 || player->getStatus() == kActorStatus12)
player->updateFromDirection(newDirection);
- }
}
Commit: 6e1b4a1801792f3bf395f2449e562bd81e0c899b
https://github.com/scummvm/scummvm/commit/6e1b4a1801792f3bf395f2449e562bd81e0c899b
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:32+02:00
Commit Message:
ASYLUM: Finish implementation of Scene::updateCursor()
- Move scene cursor resources inside an array
- Read alternate scene cursor resources
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@632 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/resources/encounters.cpp
engines/asylum/resources/worldstats.cpp
engines/asylum/resources/worldstats.h
engines/asylum/system/cursor.cpp
engines/asylum/system/cursor.h
engines/asylum/views/scene.cpp
engines/asylum/views/scene.h
diff --git a/engines/asylum/resources/encounters.cpp b/engines/asylum/resources/encounters.cpp
index 8499ccdfb3..25427455ad 100644
--- a/engines/asylum/resources/encounters.cpp
+++ b/engines/asylum/resources/encounters.cpp
@@ -50,7 +50,7 @@ namespace Asylum {
Encounter::Encounter(AsylumEngine *engine) : _vm(engine),
_index(0), _keywordIndex(0), _item(NULL), _objectId1(kObjectNone), _objectId2(kObjectNone), _actorIndex(kActorInvalid),
- _flag1(false), _flag2(false) {
+ _flag1(false), _flag2(false), _flag3(false), _flag4(false), _flag5(false), _flag6(false) {
// TODO init rest of members
@@ -308,7 +308,7 @@ bool Encounter::init() {
}
_data_455BD0 = 0;
- getCursor()->set(getWorld()->curTalkNPC, -1, 2);
+ getCursor()->set(getWorld()->cursorResources[kCursorResourceTalkNPC], -1, 2);
if (!getSharedData()->getMatteBarHeight())
initScript(_item->scriptResourceId);
diff --git a/engines/asylum/resources/worldstats.cpp b/engines/asylum/resources/worldstats.cpp
index 44e0342ca9..d6fc37a0de 100644
--- a/engines/asylum/resources/worldstats.cpp
+++ b/engines/asylum/resources/worldstats.cpp
@@ -41,19 +41,8 @@ WorldStats::WorldStats(AsylumEngine *engine) : _vm(engine) {
xLeft = 0;
yTop = 0;
backgroundImage = kResourceNone;
- curScrollUp = kResourceNone;
- curScrollUpLeft = kResourceNone;
- curScrollLeft = kResourceNone;
- curScrollDownLeft = kResourceNone;
- curScrollDown = kResourceNone;
- curScrollDownRight = kResourceNone;
- curScrollRight = kResourceNone;
- curScrollUpRight = kResourceNone;
- curHand = kResourceNone;
- curMagnifyingGlass = kResourceNone;
- curTalkNPC = kResourceNone;
- curGrabPointer = kResourceNone;
- curTalkNPC2 = kResourceNone;
+ memset(&cursorResources, kResourceNone, sizeof(cursorResources));
+
font1 = kResourceNone;
font2 = kResourceNone;
font3 = kResourceNone;
@@ -87,6 +76,9 @@ WorldStats::WorldStats(AsylumEngine *engine) : _vm(engine) {
musicFlag = 0;
musicResourceId = kResourceNone;
musicStatusExt = 0;
+ numActionLists = 0;
+ numPolygons = 0;
+ memset(&cursorResourcesAlternate, kResourceNone, sizeof(cursorResourcesAlternate));
nextPlayer = kActorMax;
memset(&field_E8610, 0, sizeof(field_E8610));
@@ -121,19 +113,10 @@ void WorldStats::load(Common::SeekableReadStream *stream) {
// read common graphic resources
backgroundImage = (ResourceId)stream->readSint32LE();
- curScrollUp = (ResourceId)stream->readSint32LE();
- curScrollUpLeft = (ResourceId)stream->readSint32LE();
- curScrollLeft = (ResourceId)stream->readSint32LE();
- curScrollDownLeft = (ResourceId)stream->readSint32LE();
- curScrollDown = (ResourceId)stream->readSint32LE();
- curScrollDownRight = (ResourceId)stream->readSint32LE();
- curScrollRight = (ResourceId)stream->readSint32LE();
- curScrollUpRight = (ResourceId)stream->readSint32LE();
- curHand = (ResourceId)stream->readSint32LE();
- curMagnifyingGlass = (ResourceId)stream->readSint32LE();
- curTalkNPC = (ResourceId)stream->readSint32LE();
- curGrabPointer = (ResourceId)stream->readSint32LE();
- curTalkNPC2 = (ResourceId)stream->readSint32LE();
+
+ for (uint i = 0; i < ARRAYSIZE(cursorResources); i++)
+ cursorResources[i] = (ResourceId)stream->readSint32LE();
+
font1 = (ResourceId)stream->readSint32LE();
font2 = (ResourceId)stream->readSint32LE();
font3 = (ResourceId)stream->readSint32LE();
@@ -236,14 +219,13 @@ void WorldStats::load(Common::SeekableReadStream *stream) {
stream->seek((ACTORS_MAX_COUNT - numActors) * ACTORDATA_SIZE, SEEK_CUR);
//////////////////////////////////////////////////////////////////////////
- // Read number of actionlists and polygons
+ // Read number of scripts and polygons
numActionLists = stream->readUint32LE();
numPolygons = stream->readUint32LE();
- // FIXME: Read missing data (64 int32)
- warning("[WorldStats::load] Missing some data reading!");
- for (int i = 0; i < 64; i++)
- stream->readUint32LE();
+ // Load the alternate cursor resources
+ for (uint32 i = 0; i < ARRAYSIZE(cursorResourcesAlternate); i++)
+ cursorResourcesAlternate[i] = (ResourceId)stream->readSint32LE();
//////////////////////////////////////////////////////////////////////////
// Read actions
diff --git a/engines/asylum/resources/worldstats.h b/engines/asylum/resources/worldstats.h
index 62633faf99..65681c6638 100644
--- a/engines/asylum/resources/worldstats.h
+++ b/engines/asylum/resources/worldstats.h
@@ -48,6 +48,22 @@ class AsylumEngine;
struct ActionArea;
+enum CursorResourceType {
+ kCursorResourceScrollUp = 0,
+ kCursorResourceScrollUpLeft,
+ kCursorResourceScrollLeft,
+ kCursorResourceScrollDownLeft,
+ kCursorResourceScrollDown,
+ kCursorResourceScrollDownRight,
+ kCursorResourceScrollRight,
+ kCursorResourceScrollUpRight,
+ kCursorResourceHand,
+ kCursorResourceMagnifyingGlass,
+ kCursorResourceTalkNPC,
+ kCursorResourceGrabPointer,
+ kCursorResourceTalkNPC2
+};
+
class WorldStats {
public:
WorldStats(AsylumEngine *engine);
@@ -67,19 +83,7 @@ public:
int32 yTop; // scene start y position
Common::Rect boundingRect;
ResourceId backgroundImage;
- ResourceId curScrollUp;
- ResourceId curScrollUpLeft;
- ResourceId curScrollLeft;
- ResourceId curScrollDownLeft;
- ResourceId curScrollDown;
- ResourceId curScrollDownRight;
- ResourceId curScrollRight;
- ResourceId curScrollUpRight;
- ResourceId curHand;
- ResourceId curMagnifyingGlass;
- ResourceId curTalkNPC;
- ResourceId curGrabPointer;
- ResourceId curTalkNPC2;
+ ResourceId cursorResources[13];
ResourceId font1;
ResourceId font2;
ResourceId font3;
@@ -122,8 +126,8 @@ public:
// ActorData is stored in each actor instance
int32 numActionLists;
int32 numPolygons;
+ ResourceId cursorResourcesAlternate[64];
Common::Array<ActionArea*> actions; // maxsize 400
- // TODO Add missing fields
int32 field_E848C;
int32 field_E8490;
int32 field_E8494;
diff --git a/engines/asylum/system/cursor.cpp b/engines/asylum/system/cursor.cpp
index f2ed1eb07f..000bfc4af8 100644
--- a/engines/asylum/system/cursor.cpp
+++ b/engines/asylum/system/cursor.cpp
@@ -35,8 +35,9 @@ namespace Asylum {
const uint32 CURSOR_UPDATE_TICKS = 100;
-Cursor::Cursor(AsylumEngine *engine) : graphicResourceId(kResourceNone), currentFrame(0), frameCount(0), counter(0), flags(0), field_11(0),
- _vm(engine), _cursorRes(NULL), _cursorTicks(0), _cursor_byte_45756C(0), _state(0) {
+Cursor::Cursor(AsylumEngine *engine) : _vm(engine),
+ graphicResourceId(kResourceNone), currentFrame(0), frameCount(0), counter(0), flags(0),
+ _cursorRes(NULL), _cursorTicks(0), _cursor_byte_45756C(0), _state(0) {
}
@@ -102,11 +103,11 @@ void Cursor::setState(const Common::Event &evt) {
break;
case Common::EVENT_LBUTTONDOWN:
- _state |= kCursorLeft;
+ _state |= kCursorStateLeft;
break;
case Common::EVENT_RBUTTONDOWN:
- _state |= kCursorRight;
+ _state |= kCursorStateRight;
break;
case Common::EVENT_MBUTTONDOWN:
@@ -114,11 +115,11 @@ void Cursor::setState(const Common::Event &evt) {
break;
case Common::EVENT_LBUTTONUP:
- _state &= ~kCursorLeft;
+ _state &= ~kCursorStateLeft;
break;
case Common::EVENT_RBUTTONUP:
- _state &= ~kCursorRight;
+ _state &= ~kCursorStateRight;
break;
case Common::EVENT_MBUTTONUP:
diff --git a/engines/asylum/system/cursor.h b/engines/asylum/system/cursor.h
index 30988cd1a5..59652e7188 100644
--- a/engines/asylum/system/cursor.h
+++ b/engines/asylum/system/cursor.h
@@ -37,8 +37,8 @@ class AsylumEngine;
class GraphicResource;
enum CursorState {
- kCursorLeft = 1,
- kCursorRight = 2,
+ kCursorStateLeft = 1,
+ kCursorStateRight = 2,
kCursorMiddle = 3
};
@@ -103,15 +103,12 @@ public:
// ever seems to be used to reference cursor info, the struct members
// may as well be class members in order to simplify the logic a bit
- // typedef struct CursorInfo {
ResourceId graphicResourceId;
uint32 currentFrame; // assuming field_4c is the current frame pointer
// since it's generally initialized to zero
int32 frameCount;
int32 counter; // cursor counter
byte flags;
- byte field_11;
- // } CursorInfo;
private:
AsylumEngine *_vm;
diff --git a/engines/asylum/views/scene.cpp b/engines/asylum/views/scene.cpp
index e6e21eea86..baab08725e 100644
--- a/engines/asylum/views/scene.cpp
+++ b/engines/asylum/views/scene.cpp
@@ -112,7 +112,7 @@ void Scene::enter(ResourcePackId packId) {
}
// Set the cursor to magnifying glass
- getCursor()->set(_ws->curMagnifyingGlass);
+ getCursor()->set(_ws->cursorResources[kCursorResourceMagnifyingGlass]);
getCursor()->show();
// Clear the graphic queue
@@ -298,7 +298,7 @@ bool Scene::init() {
return true;
}
- getCursor()->set(_ws->curScrollUp);
+ getCursor()->set(_ws->cursorResources[kCursorResourceScrollUp]);
_ws->coordinates[0] = -1;
getScreen()->clear();
getText()->loadFont(_ws->font1);
@@ -396,7 +396,7 @@ bool Scene::clickDown(const AsylumEvent &evt) {
break;
case Common::EVENT_LBUTTONDOWN:
- if (getCursor()->getState() & kCursorRight)
+ if (getCursor()->getState() & kCursorStateRight)
break;
if (getSpeech()->getSoundResourceId())
@@ -847,122 +847,121 @@ void Scene::updateCoordinates() {
newYTop = _ws->yTop = b.bottom - 479;
}
-void Scene::updateCursor(int direction, Common::Rect rect) {
- int16 rlimit = rect.right - 10;
- ResourceId newGraphicResourceId;
+void Scene::updateCursor(ActorDirection direction, Common::Rect rect) {
HitType type = kHitNone;
+ Actor *player = getActor();
+ int16 rightLimit = rect.right - 10;
+ Common::Point mouse = getCursor()->position();
- // TODO if encounter_flag03
- if (0 && getCursor()->graphicResourceId != _ws->curTalkNPC)
- getCursor()->set(_ws->curTalkNPC, 0, 2);
+ if (getEncounter()->getFlag6()) {
+ if (getCursor()->graphicResourceId != _ws->cursorResources[kCursorResourceTalkNPC])
+ getCursor()->set(_ws->cursorResources[kCursorResourceTalkNPC], 0, 2);
- Actor *act = getActor(); // get the player actor reference
+ return;
+ }
- // XXX field_11 seems to have something to do with
- // whether the event manager is handling a right mouse down
- // event
- if (getCursor()->field_11 & 2) {
- if (act->getStatus() == 1 || act->getStatus() == 12) {
- if (direction >= 0) {
- newGraphicResourceId = (ResourceId)(_ws->curScrollUp + direction);
- getCursor()->set(newGraphicResourceId, 0, 2);
- }
+ if (getCursor()->getState() & kCursorStateRight) {
+ if (player->getStatus() == kActorStatus1 || player->getStatus() == kActorStatus12) {
+
+ ResourceId resourceId =_ws->cursorResources[direction];
+
+ if (direction >= kDirectionN && getCursor()->graphicResourceId != resourceId)
+ getCursor()->set(resourceId, 0, 2);
}
+
+ return;
}
- if (act->getStatus() == 6 || act->getStatus() == 10) {
- newGraphicResourceId = _ws->curHand;
- getCursor()->set(newGraphicResourceId, 0, 2);
- } else {
- if (act->getField638()) {
- if (getCursor()->position().x >= rect.left && getCursor()->position().x <= rlimit &&
- getCursor()->position().y >= rect.top && getCursor()->position().y <= rect.bottom &&
- hitTestActor()) {
- // TODO LOTS of work here, because apparently we need to use
- // field_638 as an index into _ws->field_D6AC8, which is not
- // yet defined as part of worldstats, but according to IDA, is:
- // 000D6A88 field_D6A88 dd 16 dup(?)
- // so this is an array that is initialized as part of the scene
- // loading process. Need to investigate further ...
- warning("Something...");
+ if (player->getStatus() == kActorStatus6 || player->getStatus() == kActorStatus10) {
+ if (getCursor()->graphicResourceId != _ws->cursorResources[kCursorResourceHand])
+ getCursor()->set(_ws->cursorResources[kCursorResourceHand], 0, 2);
+
+ return;
+ }
+
+ if (player->getField638()) {
+ if (mouse.x >= rect.left && mouse.x <= rightLimit && mouse.y >= rect.top && mouse.y <= rect.bottom && hitTestPlayer()) {
+
+ ResourceId id = _ws->cursorResourcesAlternate[player->getField638() + 31];
+ if (getCursor()->graphicResourceId != id)
+ getCursor()->set(id, 0, 0);
+
+ } else {
+ if (hitTestScene(type) == -1) {
+ ResourceId id = _ws->cursorResourcesAlternate[player->getField638() + 31];
+ if (getCursor()->graphicResourceId != id)
+ getCursor()->set(id, 0, 0);
} else {
- // TODO pass a reference to hitType so it can be populated by
- // hitTestScene
- newGraphicResourceId = hitTestScene(type);
- if (newGraphicResourceId != (ResourceId)-1) {
- warning ("Can't set mouse cursor, field_D6AC8 not handled ... yet");
- // TODO
- // check if _ws->field_D6AC8[act->field_638] != newGraphicResourceId
- // if false, set mouse cursor
- } else {
- // TODO _ws->field_D6B08 stuff, then set cursor
- warning ("Can't set mouse cursor, field_D6B08 not handled ... yet");
- }
+ ResourceId id = _ws->cursorResourcesAlternate[player->getField638() + 47];
+ uint32 frameCount = GraphicResource::getFrameCount(_vm, id);
+ if (getCursor()->graphicResourceId != id)
+ getCursor()->set(id, 0, ((frameCount <= 1) - 1) & 2);
}
- return; // return result;
}
- int32 targetIdx = hitTest(type);
-
- //printf ("Mouse X(%d)/Y(%d) = %d\n", getCursor()->position().x, getCursor()->position().y, type);
- if (getCursor()->position().x >= rect.left && getCursor()->position().x <= rlimit &&
- getCursor()->position().y >= rect.top && getCursor()->position().y <= rect.bottom &&
- hitTestActor()) {
- if (act->getReaction(0)) {
- getCursor()->set(_ws->curGrabPointer, 0, 2);
- return;
- }
+
+ return;
+ }
+
+ if (mouse.x >= rect.left && mouse.x <= rightLimit && mouse.y >= rect.top && mouse.y <= rect.bottom && hitTestPlayer()) {
+ if (player->getReaction(0)) {
+ if (getCursor()->graphicResourceId != _ws->cursorResources[kCursorResourceGrabPointer])
+ getCursor()->set(_ws->cursorResources[kCursorResourceGrabPointer], 0, 2);
+
+ return;
}
- if (targetIdx == -1) {
- if (_ws->chapter != kChapter2 || _playerIndex != 10) {
- if (getCursor()->flags)
- getCursor()->set(_ws->curMagnifyingGlass, 0, 2);
- } else {
- if (getCursor()->flags)
- getCursor()->set(_ws->curTalkNPC2, 0, 2);
- }
- } else {
- int32 targetUpdateType = 0;
- switch (type) {
- case kHitActionArea:
- targetUpdateType = _ws->actions[targetIdx]->actionType;
- break;
- case kHitObject:
- targetUpdateType = _ws->objects[targetIdx]->actionType;
- break;
- case kHitActor:
- targetUpdateType = getActor(targetIdx)->getStatus();
- break;
- default:
- // TODO LOBYTE(hitType)
- break;
- }
+ }
- if (targetUpdateType & 1 && getCursor()->flags != 2) {
- getCursor()->set(_ws->curMagnifyingGlass, 0, 2);
- } else {
- if (targetUpdateType & 4) {
- getCursor()->set(_ws->curHand, 0, 2);
- } else {
- if (targetUpdateType & 2) {
- getCursor()->set(_ws->curTalkNPC, 0, 2);
- } else {
- if (targetUpdateType & 0x10 && getCursor()->flags != 2) {
- getCursor()->set(_ws->curTalkNPC2, 0, 2);
- } else {
- if (_ws->chapter != kChapter2 && _playerIndex != 10) {
- getCursor()->set(_ws->curMagnifyingGlass, 0, 0);
- } else {
- if (getCursor()->flags)
- getCursor()->set(_ws->curTalkNPC2, 0, 2);
- }
- }
- }
- }
- }
+ int32 index = hitTest(type);
+ if (index == -1) {
+ if (_ws->chapter != kChapter2 || _playerIndex != 10) {
+ if (getCursor()->flags || getCursor()->graphicResourceId != _ws->cursorResources[kCursorResourceMagnifyingGlass])
+ getCursor()->set(_ws->cursorResources[kCursorResourceMagnifyingGlass], 0, 2);
+ } else {
+ if (getCursor()->flags || getCursor()->graphicResourceId != _ws->cursorResources[kCursorResourceTalkNPC2])
+ getCursor()->set(_ws->cursorResources[kCursorResourceTalkNPC2], 0, 2);
}
+
+ return;
}
+ int32 actionType = 0;
+ switch (type) {
+ default:
+ error("[Scene::updateCursor] Invalid hit type!");
+ break;
+
+ case kHitActionArea:
+ actionType = _ws->actions[index]->actionType;
+ break;
+
+ case kHitObject:
+ actionType = _ws->objects[index]->actionType;
+ break;
+ case kHitActor:
+ actionType = getActor(index)->actionType;
+ break;
+ }
+
+ if (actionType & kActionTypeFind) {
+ if (getCursor()->graphicResourceId != _ws->cursorResources[kCursorResourceMagnifyingGlass] || getCursor()->flags != 2)
+ getCursor()->set(_ws->cursorResources[kCursorResourceMagnifyingGlass], 0, 2);
+ } else if (actionType & kActionTypeTalk) {
+ if (getCursor()->graphicResourceId != _ws->cursorResources[kCursorResourceTalkNPC])
+ getCursor()->set(_ws->cursorResources[kCursorResourceTalkNPC], 0, 2);
+ } else if (actionType & kActionTypeGrab) {
+ if (getCursor()->graphicResourceId != _ws->cursorResources[kCursorResourceHand])
+ getCursor()->set(_ws->cursorResources[kCursorResourceHand], 0, 2);
+ } else if (actionType & kActionType16) {
+ if (getCursor()->graphicResourceId != _ws->cursorResources[kCursorResourceTalkNPC2] || getCursor()->flags != 2)
+ getCursor()->set(_ws->cursorResources[kCursorResourceTalkNPC2], 0, 2);
+ } else if (_ws->chapter != kChapter2 && _playerIndex != 10) {
+ if (getCursor()->graphicResourceId != _ws->cursorResources[kCursorResourceMagnifyingGlass] || getCursor()->flags)
+ getCursor()->set(_ws->cursorResources[kCursorResourceMagnifyingGlass], 0, 2);
+ } else {
+ if (getCursor()->graphicResourceId != _ws->cursorResources[kCursorResourceTalkNPC2] || getCursor()->flags)
+ getCursor()->set(_ws->cursorResources[kCursorResourceTalkNPC2], 0, 2);
+ }
}
//////////////////////////////////////////////////////////////////////////
diff --git a/engines/asylum/views/scene.h b/engines/asylum/views/scene.h
index 7f30050336..d94bda1ec0 100644
--- a/engines/asylum/views/scene.h
+++ b/engines/asylum/views/scene.h
@@ -254,7 +254,7 @@ private:
* @param direction The direction.
* @param rect The rectangle.
*/
- void updateCursor(int direction, Common::Rect rect);
+ void updateCursor(ActorDirection direction, Common::Rect rect);
//////////////////////////////////////////////////////////////////////////
// Scene drawing
Commit: 7ac6893f228c25d01b895b18014aa83a5ba3acdb
https://github.com/scummvm/scummvm/commit/7ac6893f228c25d01b895b18014aa83a5ba3acdb
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:32+02:00
Commit Message:
ASYLUM: Implement main part of Scene::hitTestActor()
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@633 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/resources/actor.h
engines/asylum/views/scene.cpp
engines/asylum/views/scene.h
diff --git a/engines/asylum/resources/actor.h b/engines/asylum/resources/actor.h
index b99dcf7681..88b511d8b9 100644
--- a/engines/asylum/resources/actor.h
+++ b/engines/asylum/resources/actor.h
@@ -132,6 +132,13 @@ public:
*/
bool isVisible() { return flags & kActorFlagVisible; }
+ /**
+ * Query if this actor is on screen.
+ *
+ * @return true if on screen, false if not.
+ */
+ bool isOnScreen();
+
/**
* Shows this actor.
*/
@@ -427,13 +434,6 @@ private:
*/
void setVisible(bool value);
- /**
- * Query if this actor is on screen.
- *
- * @return true if on screen, false if not.
- */
- bool isOnScreen();
-
/**
* Sets the volume.
*/
diff --git a/engines/asylum/views/scene.cpp b/engines/asylum/views/scene.cpp
index baab08725e..b60e76d9d3 100644
--- a/engines/asylum/views/scene.cpp
+++ b/engines/asylum/views/scene.cpp
@@ -1057,24 +1057,75 @@ int32 Scene::hitTestActionArea() {
return targetIdx;
}
-bool Scene::hitTestActor() {
- const Common::Point pt = getCursor()->position();
+ActorIndex Scene::hitTestActor() {
+ const Common::Point mouse = getCursor()->position();
- Actor *act = getActor();
- Common::Point actPos;
- act->adjustCoordinates(&actPos);
+ if (_ws->actors.size() == 0)
+ return -1;
- int32 hitFrame;
- if (act->getFrameIndex() >= act->getFrameCount())
- hitFrame = 2 * act->getFrameIndex() - act->getFrameCount() - 1;
- else
- hitFrame = act->getFrameIndex();
+ // Check actors 13 to 20
+ if (_ws->actors.size() >= 20) {
+ for (uint i = 13; i < 21; i++) {
+ Actor *actor = getActor(i);
+
+ if (!actor->isOnScreen() || !actor->actionType)
+ continue;
+
+ Common::Rect rect = GraphicResource::getFrameRect(_vm, getActor(12)->getResourceId(), 0);
+
+ int32 x = _ws->xLeft + mouse.x - (actor->getPoint1()->x + actor->getPoint()->x);
+ int32 y = _ws->yTop + mouse.y - (actor->getPoint1()->y + actor->getPoint()->y);
+
+ if (x > (rect.left - 20)
+ && x < (rect.width() + rect.left + 20)
+ && y > (rect.top - 20)
+ && y < (rect.height() + rect.top + 20))
+ return i;
+ }
+ }
+
+ // Check Actor 11
+ if (_ws->actors.size() >= 11) {
+ Actor *actor11 = getActor(11);
+ if (actor11->isOnScreen() && actor11->actionType) {
+ int x = mouse.x + _ws->xLeft - actor11->getPoint1()->x;
+ int y = mouse.y + _ws->yTop - actor11->getPoint1()->y;
+
+ if (actor11->getBoundingRect()->contains(x, y))
+ return 11;
+ }
+ }
- return hitTestPixel(act->getResourceId(),
- hitFrame,
- pt.x - act->getPoint()->x - actPos.x,
- pt.y - act->getPoint()->y - actPos.y,
- (act->getDirection() >= 0));
+ switch (_ws->chapter) {
+ default:
+ for (int i = _ws->actors.size() - 1; i >= 0 ; i--) {
+ Actor *actor = getActor(i);
+
+ int32 hitFrame;
+ if (actor->getFrameIndex() >= actor->getFrameCount())
+ hitFrame = 2 * actor->getFrameIndex() - actor->getFrameCount() - 1;
+ else
+ hitFrame = actor->getFrameIndex();
+
+ if (hitTestPixel(actor->getResourceId(),
+ hitFrame,
+ _ws->xLeft - actor->getPoint()->x - actor->getPoint1()->x,
+ _ws->yTop - actor->getPoint()->y - actor->getPoint1()->y,
+ actor->getDirection() >= kDirectionSE))
+ return i;
+ }
+ break;
+
+ case kChapter8:
+ error("[Scene::hitTestActor] Not implemented (chapter 8)!");
+ break;
+
+ case kChapter11:
+ error("[Scene::hitTestActor] Not implemented (chapter 11)!");
+ break;
+ }
+
+ return -1;
}
bool Scene::hitTestPlayer() {
diff --git a/engines/asylum/views/scene.h b/engines/asylum/views/scene.h
index d94bda1ec0..e1e2243d6e 100644
--- a/engines/asylum/views/scene.h
+++ b/engines/asylum/views/scene.h
@@ -343,9 +343,9 @@ private:
/**
* Check if the mouse cursor is currently intersecting the currently active actor.
*
- * @return true if it succeeds, false if it fails.
+ * @return The actor index
*/
- bool hitTestActor();
+ ActorIndex hitTestActor();
/**
* Check if the mouse cursor is currently intersecting the player.
Commit: 9b4c9572ead59f8fadc1793aaee1731c12226098
https://github.com/scummvm/scummvm/commit/9b4c9572ead59f8fadc1793aaee1731c12226098
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:32+02:00
Commit Message:
ASYLUM: Implement Scene::key() and Scene::speak()
- Add savegame stubs for quickLoad and quickSave
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@634 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/system/savegame.cpp
engines/asylum/system/savegame.h
engines/asylum/views/scene.cpp
engines/asylum/views/scene.h
diff --git a/engines/asylum/system/savegame.cpp b/engines/asylum/system/savegame.cpp
index 3568ad2b71..eca4db6c47 100644
--- a/engines/asylum/system/savegame.cpp
+++ b/engines/asylum/system/savegame.cpp
@@ -41,18 +41,38 @@ bool Savegame::setup() {
return true;
}
+void Savegame::loadList() {
+ warning("[Savegame::loadList] Not implemented!");
+}
+
+
bool Savegame::load() {
warning("[Savegame::load] Not implemented!");
return false;
}
+bool Savegame::quickLoad() {
+ warning("[Savegame::quickLoad] Not implemented!");
+
+ return false;
+}
+
+bool Savegame::save() {
+ warning("[Savegame::save] Not implemented!");
+
+ return false;
+}
+
+bool Savegame::quickSave() {
+ warning("[Savegame::quickSave] Not implemented!");
+
+ return false;
+}
+
void Savegame::loadViewedMovies() {
warning("[Savegame::loadViewedMovies] Not implemented!");
}
-void Savegame::loadList() {
- warning("[Savegame::loadList] Not implemented!");
-}
} // End of namespace Asylum
diff --git a/engines/asylum/system/savegame.h b/engines/asylum/system/savegame.h
index 1eb5c65322..9fa8ced42b 100644
--- a/engines/asylum/system/savegame.h
+++ b/engines/asylum/system/savegame.h
@@ -37,11 +37,18 @@ public:
bool setup();
+ /**
+ * Loads the list of saved games
+ */
+ void loadList();
+
bool load();
+ bool quickLoad();
- void loadViewedMovies();
+ bool save();
+ bool quickSave();
- void loadList();
+ void loadViewedMovies();
private:
AsylumEngine* _vm;
diff --git a/engines/asylum/views/scene.cpp b/engines/asylum/views/scene.cpp
index b60e76d9d3..f84f936a69 100644
--- a/engines/asylum/views/scene.cpp
+++ b/engines/asylum/views/scene.cpp
@@ -36,10 +36,12 @@
#include "asylum/system/config.h"
#include "asylum/system/cursor.h"
#include "asylum/system/graphics.h"
+#include "asylum/system/savegame.h"
#include "asylum/system/screen.h"
#include "asylum/system/speech.h"
#include "asylum/system/text.h"
+#include "asylum/views/menu.h"
#include "asylum/views/scenetitle.h"
#include "asylum/asylum.h"
@@ -355,7 +357,108 @@ bool Scene::update() {
}
bool Scene::key(const AsylumEvent &evt) {
- warning("[Scene::key] Not implemented!");
+ // TODO add support for debug commands
+
+ //////////////////////////////////////////////////////////////////////////
+ // Check for keyboard shortcuts
+ if (evt.kbd.ascii == Config.keyShowVersion) {
+ // TODO show version!
+
+ return true;
+ }
+
+ if (evt.kbd.ascii == Config.keyQuickLoad) {
+ getSaveLoad()->quickLoad();
+
+ return true;
+ }
+
+ if (evt.kbd.ascii == Config.keyQuickSave) {
+ getSaveLoad()->quickSave();
+
+ return true;
+ }
+
+ if (evt.kbd.ascii == Config.keySwitchToSara) {
+ if (getCursor()->isHidden() || _ws->chapter != kChapter9)
+ return true;
+
+ getScript()->queueScript(_ws->actions[_ws->getActionAreaIndexById(2206)]->scriptIndex, _playerIndex);
+
+ return true;
+ }
+
+ if (evt.kbd.ascii == Config.keySwitchToGrimwall) {
+ if (getCursor()->isHidden() || _ws->chapter != kChapter9)
+ return true;
+
+ getScript()->queueScript(_ws->actions[_ws->getActionAreaIndexById(2207)]->scriptIndex, _playerIndex);
+
+ return true;
+ }
+
+ if (evt.kbd.ascii == Config.keySwitchToOlmec) {
+ if (getCursor()->isHidden() || _ws->chapter != kChapter9)
+ return true;
+
+ getScript()->queueScript(_ws->actions[_ws->getActionAreaIndexById(2208)]->scriptIndex, _playerIndex);
+
+ return true;
+ }
+
+ switch (evt.kbd.keycode) {
+ default:
+ break;
+
+ case Common::KEYCODE_BACKSPACE:
+ // TODO add support for debug commands
+ warning("[Scene::key] debug command handling not implemented!");
+ break;
+
+ case Common::KEYCODE_RETURN:
+ // TODO add support for debug commands
+ warning("[Scene::key] debug command handling not implemented!");
+ break;
+
+ case Common::KEYCODE_ESCAPE:
+ // TODO add support for debug commands
+
+ if (getSpeech()->getSoundResourceId()) {
+ getScene()->stopSpeech();
+ } else {
+ if (getCursor()->isHidden())
+ break;
+
+ _vm->switchEventHandler(_vm->menu());
+ }
+ break;
+
+ case Common::KEYCODE_LEFTBRACKET:
+ if (evt.kbd.ascii != 123)
+ break;
+ // Fallback to next case (we got a left brace)
+
+ case Common::KEYCODE_p:
+ case Common::KEYCODE_q:
+ case Common::KEYCODE_r:
+ case Common::KEYCODE_s:
+ case Common::KEYCODE_t:
+ case Common::KEYCODE_u:
+ case Common::KEYCODE_v:
+ case Common::KEYCODE_w:
+ case Common::KEYCODE_x:
+ case Common::KEYCODE_y:
+ case Common::KEYCODE_z:
+ if (speak(evt.kbd.keycode)) {
+ _vm->lastScreenUpdate = _vm->screenUpdateCount;
+ getActor()->setLastScreenUpdate(_vm->screenUpdateCount);
+ }
+ break;
+
+ case Common::KEYCODE_TAB:
+ warning("[Scene::key] Screenshot function not implemented!");
+ break;
+ }
return true;
}
@@ -1376,6 +1479,225 @@ void Scene::stopSpeech() {
}
}
+bool Scene::speak(Common::KeyCode code) {
+#define GET_INDEX(val) ((((long long)val >> 32) ^ abs((int)val) & 1) == ((long long)val >> 32))
+
+ int32 index = -1;
+
+ switch (code) {
+ default:
+ break;
+
+ case Common::KEYCODE_p:
+ switch (_ws->actorType) {
+ default:
+ break;
+
+ case 0:
+ index = GET_INDEX(_vm->getRandom(RAND_MAX));
+ break;
+
+ case 1:
+ case 2:
+ case 3:
+ index = 1;
+ break;
+ }
+ break;
+
+ case Common::KEYCODE_q:
+ switch (_ws->actorType) {
+ default:
+ break;
+
+ case 0:
+ index = 3 - GET_INDEX(_vm->getRandom(RAND_MAX));
+ break;
+
+ case 1:
+ case 2:
+ case 3:
+ index = 2;
+ break;
+ }
+ break;
+
+ case Common::KEYCODE_r:
+ switch (_ws->actorType) {
+ default:
+ break;
+
+ case 0:
+ index = 2;
+ break;
+
+ case 1:
+ case 2:
+ case 3:
+ index = 4;
+ break;
+ }
+ break;
+
+ case Common::KEYCODE_s:
+ switch (_ws->actorType) {
+ default:
+ break;
+
+ case 0:
+ index = 5;
+ break;
+
+ case 1:
+ case 2:
+ case 3:
+ index = 3;
+ break;
+ }
+ break;
+
+ case Common::KEYCODE_t:
+ switch (_ws->actorType) {
+ default:
+ break;
+
+ case 0:
+ index = 6;
+ break;
+
+ case 1:
+ case 2:
+ case 3:
+ index = 4;
+ break;
+ }
+ break;
+
+ case Common::KEYCODE_u:
+ switch (_ws->actorType) {
+ default:
+ break;
+
+ case 0:
+ index = 7;
+ break;
+
+ case 1:
+ case 2:
+ index = 5;
+ break;
+ }
+ break;
+
+ case Common::KEYCODE_v:
+ switch (_ws->actorType) {
+ default:
+ break;
+
+ case 0:
+ index = 8;
+ break;
+
+ case 1:
+ case 2:
+ index = 6;
+ break;
+ }
+ break;
+
+ case Common::KEYCODE_w:
+ switch (_ws->actorType) {
+ default:
+ break;
+
+ case 0:
+ index = 9;
+ break;
+
+ case 1:
+ case 2:
+ index = 7;
+ break;
+ }
+ break;
+
+ case Common::KEYCODE_x:
+ switch (_ws->actorType) {
+ default:
+ break;
+
+ case 0:
+ index = 10;
+ break;
+
+ case 1:
+ case 2:
+ index = 8;
+ break;
+ }
+ break;
+
+ case Common::KEYCODE_y:
+ switch (_ws->actorType) {
+ default:
+ break;
+
+ case 0:
+ index = 11;
+ break;
+
+ case 1:
+ case 2:
+ index = 9;
+ break;
+ }
+ break;
+
+ case Common::KEYCODE_z:
+ switch (_ws->actorType) {
+ default:
+ break;
+
+ case 0:
+ index = 13 - GET_INDEX(_vm->getRandom(65536));
+ break;
+
+ case 1:
+ case 2:
+ index = 10;
+ break;
+ }
+ break;
+
+ case Common::KEYCODE_LEFTBRACKET:
+ switch (_ws->actorType) {
+ default:
+ break;
+
+ case 0:
+ index = 15 - GET_INDEX(_vm->getRandom(RAND_MAX));
+ break;
+
+ case 2:
+ index = 12 - GET_INDEX(_vm->getRandom(RAND_MAX));
+ break;
+ }
+ break;
+ }
+
+ if (getSpeech()->getSoundResourceId() && getSound()->isPlaying(getSpeech()->getSoundResourceId()))
+ return false;
+
+ if (index == -1)
+ return false;
+
+ getSpeech()->playPlayer(index);
+
+ return true;
+
+#undef GET_INDEX
+}
+
bool Scene::pointIntersectsRect(Common::Point point, Common::Rect rect) {
if (rect.top || rect.left || rect.bottom || rect.right) {
Common::Rational res((rect.bottom - rect.top) * (point.x - rect.left), rect.right - rect.left);
diff --git a/engines/asylum/views/scene.h b/engines/asylum/views/scene.h
index e1e2243d6e..2fe5514d25 100644
--- a/engines/asylum/views/scene.h
+++ b/engines/asylum/views/scene.h
@@ -414,6 +414,15 @@ private:
*/
void stopSpeech();
+ /**
+ * Play specific speech.
+ *
+ * @param code The key code.
+ *
+ * @return true if it succeeds, false if it fails.
+ */
+ bool speak(Common::KeyCode code);
+
/**
* Check if point intersects the rectangle.
*
Commit: 787769276872b547db5dd8c31b94a8272a7a518d
https://github.com/scummvm/scummvm/commit/787769276872b547db5dd8c31b94a8272a7a518d
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:32+02:00
Commit Message:
ASYLUM: Implement cursor animation
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@635 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/asylum.cpp
engines/asylum/asylum.h
engines/asylum/eventhandler.h
engines/asylum/puzzles/vcr.cpp
engines/asylum/resources/encounters.cpp
engines/asylum/system/cursor.cpp
engines/asylum/system/cursor.h
engines/asylum/views/menu.cpp
engines/asylum/views/scene.cpp
diff --git a/engines/asylum/asylum.cpp b/engines/asylum/asylum.cpp
index e0c38b0a4d..9d0bb28dfa 100644
--- a/engines/asylum/asylum.cpp
+++ b/engines/asylum/asylum.cpp
@@ -167,7 +167,7 @@ void AsylumEngine::startGame(ResourcePackId sceneId, StartGameType type) {
error("[AsylumEngine::startGame] Subsystems not initialized properly!");
// Load the default mouse cursor
- _cursor->set(MAKE_RESOURCE(kResourcePackSound, 14));
+ _cursor->set(MAKE_RESOURCE(kResourcePackSound, 14), 0, kCursorAnimationNone);
_cursor->hide();
// Clear the graphic list
@@ -314,6 +314,9 @@ void AsylumEngine::handleEvents() {
}
}
+ // Animate cursor
+ _cursor->animate();
+
// Send update event to our event handler
AsylumEvent updateEvt = AsylumEvent(EVENT_ASYLUM_UPDATE);
_handler->handleEvent(updateEvt);
@@ -373,6 +376,14 @@ void AsylumEngine::switchEventHandler(EventHandler *handler) {
_handler->handleEvent(init);
}
+void AsylumEngine::notify(AsylumEventType type) {
+ if (_handler == NULL)
+ error("[AsylumEngine::notify] Invalid handler parameter (cannot be NULL)!");
+
+ AsylumEvent evt(type);
+ _handler->handleEvent(evt);
+}
+
EventHandler *AsylumEngine::getPuzzle(uint32 index) {
if (index >= ARRAYSIZE(_puzzles))
error("[AsylumEngine::getPuzzleEventHandler] Invalid index (was: %d - max: %d)", index, ARRAYSIZE(_puzzles));
diff --git a/engines/asylum/asylum.h b/engines/asylum/asylum.h
index a445660e9e..7eff9f3da8 100644
--- a/engines/asylum/asylum.h
+++ b/engines/asylum/asylum.h
@@ -168,6 +168,13 @@ public:
*/
void switchEventHandler(EventHandler *handler);
+ /**
+ * Notifies the current event handler of an event
+ *
+ * @param type The event type.
+ */
+ void notify(AsylumEventType type);
+
/**
* Gets a message handler.
*
diff --git a/engines/asylum/eventhandler.h b/engines/asylum/eventhandler.h
index bdd0adb2f8..87a6e02775 100644
--- a/engines/asylum/eventhandler.h
+++ b/engines/asylum/eventhandler.h
@@ -32,14 +32,15 @@
namespace Asylum {
enum AsylumEventType {
- EVENT_ASYLUM_INIT = 0xFFF0,
- EVENT_ASYLUM_DEINIT = 0xFFF1,
- EVENT_ASYLUM_UPDATE = 0xFFF2,
- EVENT_ASYLUM_MUSIC = 0xFFF3,
- EVENT_ASYLUM_MIDI = 0xFFF4,
- EVENT_ASYLUM_ACTIVATE = 0xFFF5,
+ EVENT_ASYLUM_MIDI = 953,
+ EVENT_ASYLUM_CHANGECD = 5120,
+ EVENT_ASYLUM_INIT = 5122,
+ EVENT_ASYLUM_UPDATE = 5121,
+ EVENT_ASYLUM_DEINIT = 5123,
+ EVENT_ASYLUM_CURSOR = 5124,
+ EVENT_ASYLUM_MUSIC = 5376,
- EVENT_ASYLUM_CHANGECD = 0xFFFE
+ EVENT_ASYLUM_ACTIVATE = 0xFFF0
};
struct AsylumEvent : public Common::Event {
diff --git a/engines/asylum/puzzles/vcr.cpp b/engines/asylum/puzzles/vcr.cpp
index 7add787192..00cfc4e6f0 100644
--- a/engines/asylum/puzzles/vcr.cpp
+++ b/engines/asylum/puzzles/vcr.cpp
@@ -68,7 +68,7 @@ void BlowUpPuzzleVCR::open() {
getScreen()->draw(getWorld()->graphicResourceIds[0], 0, 0, 0, 0);
// Set mouse cursor
- _cursor->set(getWorld()->graphicResourceIds[28], 0, 2);
+ _cursor->set(getWorld()->graphicResourceIds[28]);
_cursor->show();
_leftClickUp = false;
@@ -422,13 +422,13 @@ void BlowUpPuzzleVCR::updateCursorInPolyRegion() {
|| (inPolyRegion(_cursor->position().x, _cursor->position().y, kBlackHole) && _holesState[kPluggedOnYellow])) {
if (_cursor->currentFrame != 2) { // reset cursor
_cursor->show();
- _cursor->set(MAKE_RESOURCE(kResourcePackShared, 2), 0, 2);
+ _cursor->set(MAKE_RESOURCE(kResourcePackShared, 2));
_cursor->animate();
}
} else {
if (_cursor->currentFrame != 0) { // reset cursor
_cursor->show();
- _cursor->set(MAKE_RESOURCE(kResourcePackShared, 0), 0, 2);
+ _cursor->set(MAKE_RESOURCE(kResourcePackShared, 0));
_cursor->animate();
}
}
diff --git a/engines/asylum/resources/encounters.cpp b/engines/asylum/resources/encounters.cpp
index 25427455ad..ffcd0cf2cc 100644
--- a/engines/asylum/resources/encounters.cpp
+++ b/engines/asylum/resources/encounters.cpp
@@ -308,7 +308,7 @@ bool Encounter::init() {
}
_data_455BD0 = 0;
- getCursor()->set(getWorld()->cursorResources[kCursorResourceTalkNPC], -1, 2);
+ getCursor()->set(getWorld()->cursorResources[kCursorResourceTalkNPC], -1, kCursorAnimationMirror);
if (!getSharedData()->getMatteBarHeight())
initScript(_item->scriptResourceId);
diff --git a/engines/asylum/system/cursor.cpp b/engines/asylum/system/cursor.cpp
index 000bfc4af8..b02909cf5e 100644
--- a/engines/asylum/system/cursor.cpp
+++ b/engines/asylum/system/cursor.cpp
@@ -27,6 +27,8 @@
#include "asylum/system/graphics.h"
+#include "asylum/asylum.h"
+
#include "common/events.h"
#include "common/system.h"
#include "graphics/cursorman.h"
@@ -36,8 +38,8 @@ namespace Asylum {
const uint32 CURSOR_UPDATE_TICKS = 100;
Cursor::Cursor(AsylumEngine *engine) : _vm(engine),
- graphicResourceId(kResourceNone), currentFrame(0), frameCount(0), counter(0), flags(0),
- _cursorRes(NULL), _cursorTicks(0), _cursor_byte_45756C(0), _state(0) {
+ graphicResourceId(kResourceNone), currentFrame(0), lastFrameIndex(0), counter(0), animation(kCursorAnimationNone),
+ _cursorRes(NULL), _nextTick(0), _frameStep(0), _state(0) {
}
@@ -48,18 +50,6 @@ Cursor::~Cursor() {
_vm = NULL;
}
-/*
-void Cursor::load(int32 index) {
- if (cursorLoaded)
- delete _cursorResource;
-
- _cursorResource = new GraphicResource(_vm, index);
- _cursorStep = 1;
- _curFrame = 0;
- cursorLoaded = true;
-}
-*/
-
void Cursor::hide() const {
CursorMan.showMouse(false);
}
@@ -68,33 +58,53 @@ void Cursor::show() const {
CursorMan.showMouse(true);
}
-void Cursor::set(ResourceId resourceId, int32 cntr, byte flgs, int32 frames) {
- if (_cursorRes)
- delete _cursorRes;
+void Cursor::set(ResourceId resourceId, int32 counter, CursorAnimation animation, int32 frames) {
+ hide();
+ delete _cursorRes;
_cursorRes = new GraphicResource(_vm, resourceId);
+ // Set next update
+ _nextTick = _vm->getTick() + 100;
+
+ // Get frame count
if (frames >= 0)
- frameCount = frames;
+ lastFrameIndex = frames;
else
- frameCount = _cursorRes->count();
- this->flags = flgs;
- this->counter = cntr;
+ lastFrameIndex = _cursorRes->count() - 1;
+
+ this->animation = animation;
+ this->counter = counter;
currentFrame = 0;
- _cursor_byte_45756C = 1;
+ _frameStep = 1;
+
+ // Do not animate if no frames (and the other way around)
+ if (lastFrameIndex == 0 || animation == kCursorAnimationNone) {
+ lastFrameIndex = 0;
+ animation = kCursorAnimationNone;
+ }
+
+ if (lastFrameIndex >= _cursorRes->count())
+ lastFrameIndex = _cursorRes->count() - 1;
update();
+
+ show();
}
void Cursor::update() {
if (!_cursorRes)
error("[Cursor::update] Cursor resources not initialized properly!");
- GraphicFrame *fra = _cursorRes->getFrame(currentFrame);
- CursorMan.replaceCursor((byte *)fra->surface.pixels,
- fra->surface.w,
- fra->surface.h,
- 0, 0, 0);
+ Common::Point hotspot = getHotspot(currentFrame);
+
+ GraphicFrame *frame = _cursorRes->getFrame(currentFrame);
+ CursorMan.replaceCursor((byte *)frame->surface.pixels,
+ frame->surface.w,
+ frame->surface.h,
+ hotspot.x,
+ hotspot.y,
+ 0);
}
void Cursor::setState(const Common::Event &evt) {
@@ -128,73 +138,63 @@ void Cursor::setState(const Common::Event &evt) {
}
}
-/*
-void Cursor::set(byte *data, byte width, byte height) {
- CursorMan.replaceCursor(data, width, height, 0, 0, 0);
-}
+void Cursor::animate() {
+ if (isHidden() || !animation || _nextTick > _vm->getTick())
+ return;
+
+ bool notifyHandler = false;
+ int32 frame = 0;
+
+ if (animation == kCursorAnimationLinear) {
+ if (currentFrame == lastFrameIndex) {
+ currentFrame = frame = 0;
+ } else {
+ currentFrame += _frameStep;
+ frame = currentFrame;
+ }
+ } else if (animation == kCursorAnimationMirror) {
+ currentFrame += _frameStep;
+ frame = currentFrame;
+
+ if (currentFrame == 0 || currentFrame == lastFrameIndex)
+ _frameStep = -_frameStep;
+ }
-void Cursor::set(int32 frame) {
- if (frame >= 0) {
- GraphicFrame *mouseCursor = _cursorResource->getFrame(frame);
- set((byte *)mouseCursor->surface.pixels, mouseCursor->surface.w, mouseCursor->surface.h);
- _curFrame = frame;
- } else {
- _cursorStep = 1;
+ if (frame == 0) {
+ if (counter != -1) {
+ --counter;
+
+ if (!counter) {
+ animation = kCursorAnimationNone;
+ notifyHandler = true;
+ }
+ }
}
-}
-*/
+ _nextTick = _vm->getTick() + 100;
-void Cursor::animate() {
- /*
- _curFrame += _cursorStep;
- if (_curFrame == 0)
- _cursorStep = 1;
- if (_curFrame == _cursorResource->getFrameCount() - 1)
- _cursorStep = -1;
-
- set(_curFrame);
- */
+ if (notifyHandler)
+ _vm->notify(EVENT_ASYLUM_CURSOR);
+
+ update();
}
-/*
-void Cursor::update(WorldStats *ws, int32 currentAction) {
- uint32 newCursor = 0;
+Common::Point Cursor::getHotspot(uint32 frameIndex) {
+ Common::Point point;
- // Change cursor
- switch (currentAction) {
- case kWalkN:
- newCursor = ws->curScrollUp;
- break;
- case kWalkNE:
- newCursor = ws->curScrollUpRight;
- break;
- case kWalkNW:
- newCursor = ws->curScrollUpLeft;
- break;
- case kWalkS:
- newCursor = ws->curScrollDown;
- break;
- case kWalkSE:
- newCursor = ws->curScrollDownRight;
- break;
- case kWalkSW:
- newCursor = ws->curScrollDownLeft;
- break;
- case kWalkW:
- newCursor = ws->curScrollLeft;
- break;
- case kWalkE:
- newCursor = ws->curScrollRight;
- break;
+ uint32 resFlags = _cursorRes->getData().flags;
+
+ if (BYTE1(resFlags) & 0x10) {
+ if (frameIndex >= 0 && frameIndex > _cursorRes->count()) {
+ GraphicFrame *frame = _cursorRes->getFrame(currentFrame);
+
+ point.x = frame->x;
+ point.y = frame->y;
+ }
}
- // FIXME Added the newCursor > 0 check because cursors
- // aren't working properly with the new actor code
- if (_cursorResource->getEntryNum() != newCursor && newCursor > 0)
- load(newCursor);
+ return point;
}
-*/
bool Cursor::isHidden() const {
return !CursorMan.isVisible();
diff --git a/engines/asylum/system/cursor.h b/engines/asylum/system/cursor.h
index 59652e7188..145e2c6c19 100644
--- a/engines/asylum/system/cursor.h
+++ b/engines/asylum/system/cursor.h
@@ -42,6 +42,12 @@ enum CursorState {
kCursorMiddle = 3
};
+enum CursorAnimation {
+ kCursorAnimationNone = 0,
+ kCursorAnimationLinear = 1,
+ kCursorAnimationMirror = 2
+};
+
/**
* Asylum cursors are GraphicResources, and are stored in
* ResourcePacks, as are all game assets.
@@ -61,25 +67,23 @@ public:
*/
void hide() const;
- bool isHidden() const;
-
/**
- * Set the current cursor instance to the graphic resource provide.
- * The frames parameter defaults to -1, which in this case means that the
- * frame count should be derived from the graphic resource as opposed to being
- * explicitly set.
+ * Query if the cursor is hidden.
+ *
+ * @return true if hidden, false if not.
*/
- void set(ResourceId resourceId, int32 cntr = 0, byte flgs = 0, int32 frames = -1);
+ bool isHidden() const;
/**
- * Scene-based update to the current cursor. This
- * checks whether the cursor should be updated depending
- * on the MainActor's current action.
+ * Set the current cursor instance to the graphic resource provide. The frames parameter defaults to -1, which in this case means that the frame count
+ * should be derived from the graphic resource as opposed to being explicitly set.
*
- * TODO this probably doesn't belong here, but on the
- * scene, where it originally was
+ * @param resourceId Identifier for the resource.
+ * @param counter The counter.
+ * @param animation The animation type
+ * @param frames The frames.
*/
- //void update(WorldStats *ws, int32 currentAction);
+ void set(ResourceId resourceId, int32 counter = 0, CursorAnimation animation = kCursorAnimationMirror, int32 frames = -1);
/**
* Get the next logical frame from the currently loaded
@@ -87,8 +91,6 @@ public:
*/
void animate();
- void update();
-
void setState(const Common::Event &evt);
byte getState() { return _state; }
@@ -97,18 +99,16 @@ public:
*/
const Common::Point position() const;
- // NOTE
- // .text:00435060 contains a function that assigns global variables to a
+ // NOTE: The original engine contains a function that assigns global variables to a
// struct associated with cursor graphics info. Since this functionality only
// ever seems to be used to reference cursor info, the struct members
// may as well be class members in order to simplify the logic a bit
ResourceId graphicResourceId;
- uint32 currentFrame; // assuming field_4c is the current frame pointer
- // since it's generally initialized to zero
- int32 frameCount;
- int32 counter; // cursor counter
- byte flags;
+ uint32 currentFrame;
+ uint32 lastFrameIndex;
+ int32 counter;
+ CursorAnimation animation;
private:
AsylumEngine *_vm;
@@ -124,12 +124,30 @@ private:
/** the point of the cursor that triggers click hits */
Common::Point _hotspot;
- // The number of millis between
- // cursor gfx updates
- uint32 _cursorTicks;
+ // The number of milliseconds between cursor gfx updates
+ uint32 _nextTick;
+
+ int32 _frameStep;
- byte _cursor_byte_45756C;
-}; // end of class Cursor
+ /**
+ * Updates the cursor
+ */
+ void update();
+
+ /**
+ * Updates the cursor current frame.
+ */
+ void updateFrame();
+
+ /**
+ * Gets the hotspot for a specific frame.
+ *
+ * @param frameIndex Zero-based index of the frame.
+ *
+ * @return The hotspot.
+ */
+ Common::Point getHotspot(uint32 frameIndex);
+};
} // end of namespace Asylum
diff --git a/engines/asylum/views/menu.cpp b/engines/asylum/views/menu.cpp
index 2de2d4c1a6..3f3bac3c8a 100644
--- a/engines/asylum/views/menu.cpp
+++ b/engines/asylum/views/menu.cpp
@@ -138,7 +138,7 @@ void MainMenu::setup() {
void MainMenu::leave() {
_activeScreen = kMenuNone;
- getCursor()->set(MAKE_RESOURCE(kResourcePackShared, 2), 0, 2);
+ getCursor()->set(MAKE_RESOURCE(kResourcePackShared, 2));
getText()->loadFont(kFontYellow);
}
@@ -339,7 +339,7 @@ bool MainMenu::init() {
// TODO: save dialog key codes into sntrm_k.txt (need to figure out why they use such thing) (address 00411CD0)
if (_needEyeCursorInit) {
- getCursor()->set(MAKE_RESOURCE(kResourcePackShared, 3), 0, 2);
+ getCursor()->set(MAKE_RESOURCE(kResourcePackShared, 3));
} else {
// Init the game if not already done
if (!_initGame) {
@@ -374,7 +374,7 @@ bool MainMenu::init() {
setupMusic();
getCursor()->hide();
- getCursor()->set(MAKE_RESOURCE(kResourcePackShared, 2), 0, 2);
+ getCursor()->set(MAKE_RESOURCE(kResourcePackShared, 2));
}
if (_gameStarted)
@@ -637,7 +637,7 @@ bool MainMenu::click(const AsylumEvent &evt) {
if (_activeScreen == kMenuNone)
return true;
- getCursor()->set(MAKE_RESOURCE(kResourcePackShared, 3), 0, 2);
+ getCursor()->set(MAKE_RESOURCE(kResourcePackShared, 3));
getText()->loadFont(kFontYellow);
switch (_activeScreen) {
diff --git a/engines/asylum/views/scene.cpp b/engines/asylum/views/scene.cpp
index f84f936a69..b708ee9e53 100644
--- a/engines/asylum/views/scene.cpp
+++ b/engines/asylum/views/scene.cpp
@@ -114,7 +114,7 @@ void Scene::enter(ResourcePackId packId) {
}
// Set the cursor to magnifying glass
- getCursor()->set(_ws->cursorResources[kCursorResourceMagnifyingGlass]);
+ getCursor()->set(_ws->cursorResources[kCursorResourceMagnifyingGlass], 0, kCursorAnimationNone);
getCursor()->show();
// Clear the graphic queue
@@ -300,7 +300,7 @@ bool Scene::init() {
return true;
}
- getCursor()->set(_ws->cursorResources[kCursorResourceScrollUp]);
+ getCursor()->set(_ws->cursorResources[kCursorResourceScrollUp], 0, kCursorAnimationNone);
_ws->coordinates[0] = -1;
getScreen()->clear();
getText()->loadFont(_ws->font1);
@@ -958,7 +958,7 @@ void Scene::updateCursor(ActorDirection direction, Common::Rect rect) {
if (getEncounter()->getFlag6()) {
if (getCursor()->graphicResourceId != _ws->cursorResources[kCursorResourceTalkNPC])
- getCursor()->set(_ws->cursorResources[kCursorResourceTalkNPC], 0, 2);
+ getCursor()->set(_ws->cursorResources[kCursorResourceTalkNPC]);
return;
}
@@ -969,7 +969,7 @@ void Scene::updateCursor(ActorDirection direction, Common::Rect rect) {
ResourceId resourceId =_ws->cursorResources[direction];
if (direction >= kDirectionN && getCursor()->graphicResourceId != resourceId)
- getCursor()->set(resourceId, 0, 2);
+ getCursor()->set(resourceId);
}
return;
@@ -977,7 +977,7 @@ void Scene::updateCursor(ActorDirection direction, Common::Rect rect) {
if (player->getStatus() == kActorStatus6 || player->getStatus() == kActorStatus10) {
if (getCursor()->graphicResourceId != _ws->cursorResources[kCursorResourceHand])
- getCursor()->set(_ws->cursorResources[kCursorResourceHand], 0, 2);
+ getCursor()->set(_ws->cursorResources[kCursorResourceHand]);
return;
}
@@ -987,18 +987,18 @@ void Scene::updateCursor(ActorDirection direction, Common::Rect rect) {
ResourceId id = _ws->cursorResourcesAlternate[player->getField638() + 31];
if (getCursor()->graphicResourceId != id)
- getCursor()->set(id, 0, 0);
+ getCursor()->set(id, 0, kCursorAnimationNone);
} else {
if (hitTestScene(type) == -1) {
ResourceId id = _ws->cursorResourcesAlternate[player->getField638() + 31];
if (getCursor()->graphicResourceId != id)
- getCursor()->set(id, 0, 0);
+ getCursor()->set(id, 0, kCursorAnimationNone);
} else {
ResourceId id = _ws->cursorResourcesAlternate[player->getField638() + 47];
uint32 frameCount = GraphicResource::getFrameCount(_vm, id);
if (getCursor()->graphicResourceId != id)
- getCursor()->set(id, 0, ((frameCount <= 1) - 1) & 2);
+ getCursor()->set(id, 0, (CursorAnimation)(((frameCount <= 1) - 1) & 2));
}
}
@@ -1008,7 +1008,7 @@ void Scene::updateCursor(ActorDirection direction, Common::Rect rect) {
if (mouse.x >= rect.left && mouse.x <= rightLimit && mouse.y >= rect.top && mouse.y <= rect.bottom && hitTestPlayer()) {
if (player->getReaction(0)) {
if (getCursor()->graphicResourceId != _ws->cursorResources[kCursorResourceGrabPointer])
- getCursor()->set(_ws->cursorResources[kCursorResourceGrabPointer], 0, 2);
+ getCursor()->set(_ws->cursorResources[kCursorResourceGrabPointer]);
return;
}
@@ -1017,11 +1017,11 @@ void Scene::updateCursor(ActorDirection direction, Common::Rect rect) {
int32 index = hitTest(type);
if (index == -1) {
if (_ws->chapter != kChapter2 || _playerIndex != 10) {
- if (getCursor()->flags || getCursor()->graphicResourceId != _ws->cursorResources[kCursorResourceMagnifyingGlass])
- getCursor()->set(_ws->cursorResources[kCursorResourceMagnifyingGlass], 0, 2);
+ if (getCursor()->graphicResourceId != _ws->cursorResources[kCursorResourceMagnifyingGlass] || getCursor()->animation)
+ getCursor()->set(_ws->cursorResources[kCursorResourceMagnifyingGlass]);
} else {
- if (getCursor()->flags || getCursor()->graphicResourceId != _ws->cursorResources[kCursorResourceTalkNPC2])
- getCursor()->set(_ws->cursorResources[kCursorResourceTalkNPC2], 0, 2);
+ if (getCursor()->graphicResourceId != _ws->cursorResources[kCursorResourceTalkNPC2] || getCursor()->animation)
+ getCursor()->set(_ws->cursorResources[kCursorResourceTalkNPC2]);
}
return;
@@ -1047,23 +1047,23 @@ void Scene::updateCursor(ActorDirection direction, Common::Rect rect) {
}
if (actionType & kActionTypeFind) {
- if (getCursor()->graphicResourceId != _ws->cursorResources[kCursorResourceMagnifyingGlass] || getCursor()->flags != 2)
- getCursor()->set(_ws->cursorResources[kCursorResourceMagnifyingGlass], 0, 2);
+ if (getCursor()->graphicResourceId != _ws->cursorResources[kCursorResourceMagnifyingGlass] || getCursor()->animation != kCursorAnimationMirror)
+ getCursor()->set(_ws->cursorResources[kCursorResourceMagnifyingGlass]);
} else if (actionType & kActionTypeTalk) {
if (getCursor()->graphicResourceId != _ws->cursorResources[kCursorResourceTalkNPC])
- getCursor()->set(_ws->cursorResources[kCursorResourceTalkNPC], 0, 2);
+ getCursor()->set(_ws->cursorResources[kCursorResourceTalkNPC]);
} else if (actionType & kActionTypeGrab) {
if (getCursor()->graphicResourceId != _ws->cursorResources[kCursorResourceHand])
- getCursor()->set(_ws->cursorResources[kCursorResourceHand], 0, 2);
+ getCursor()->set(_ws->cursorResources[kCursorResourceHand]);
} else if (actionType & kActionType16) {
- if (getCursor()->graphicResourceId != _ws->cursorResources[kCursorResourceTalkNPC2] || getCursor()->flags != 2)
- getCursor()->set(_ws->cursorResources[kCursorResourceTalkNPC2], 0, 2);
+ if (getCursor()->graphicResourceId != _ws->cursorResources[kCursorResourceTalkNPC2] || getCursor()->animation != kCursorAnimationMirror)
+ getCursor()->set(_ws->cursorResources[kCursorResourceTalkNPC2]);
} else if (_ws->chapter != kChapter2 && _playerIndex != 10) {
- if (getCursor()->graphicResourceId != _ws->cursorResources[kCursorResourceMagnifyingGlass] || getCursor()->flags)
- getCursor()->set(_ws->cursorResources[kCursorResourceMagnifyingGlass], 0, 2);
+ if (getCursor()->graphicResourceId != _ws->cursorResources[kCursorResourceMagnifyingGlass] || getCursor()->animation)
+ getCursor()->set(_ws->cursorResources[kCursorResourceMagnifyingGlass]);
} else {
- if (getCursor()->graphicResourceId != _ws->cursorResources[kCursorResourceTalkNPC2] || getCursor()->flags)
- getCursor()->set(_ws->cursorResources[kCursorResourceTalkNPC2], 0, 2);
+ if (getCursor()->graphicResourceId != _ws->cursorResources[kCursorResourceTalkNPC2] || getCursor()->animation)
+ getCursor()->set(_ws->cursorResources[kCursorResourceTalkNPC2]);
}
}
Commit: 527a517e8526b10b66fc58e5cb79de2ec4b8b238
https://github.com/scummvm/scummvm/commit/527a517e8526b10b66fc58e5cb79de2ec4b8b238
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:32+02:00
Commit Message:
ASYLUM: Implement Scene::playerReaction
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@636 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/asylum.cpp
engines/asylum/asylum.h
engines/asylum/views/scene.cpp
diff --git a/engines/asylum/asylum.cpp b/engines/asylum/asylum.cpp
index 9d0bb28dfa..ef65cf0bda 100644
--- a/engines/asylum/asylum.cpp
+++ b/engines/asylum/asylum.cpp
@@ -422,6 +422,10 @@ void AsylumEngine::initSinCosTables() {
warning("[AsylumEngine::initSinCosTables] Not implemented!");
}
+Common::Point AsylumEngine::getSinCosValues(int32 index1, int32 index2) {
+ error("[AsylumEngine::getSinCosValues] Not implemented!");
+}
+
void AsylumEngine::setupLoadedGame() {
warning("[AsylumEngine::initSinCosTables] Not implemented!");
}
diff --git a/engines/asylum/asylum.h b/engines/asylum/asylum.h
index 7eff9f3da8..6c85aaeeb2 100644
--- a/engines/asylum/asylum.h
+++ b/engines/asylum/asylum.h
@@ -189,6 +189,16 @@ public:
*/
void updateReverseStereo();
+ /**
+ * Gets a sine cosine pair.
+ *
+ * @param index1 The first index.
+ * @param index2 The second index.
+ *
+ * @return The sine cosine values.
+ */
+ Common::Point getSinCosValues(int32 index1, int32 index2);
+
private:
const ADGameDescription *_gameDescription;
diff --git a/engines/asylum/views/scene.cpp b/engines/asylum/views/scene.cpp
index b708ee9e53..d9dbaa7b12 100644
--- a/engines/asylum/views/scene.cpp
+++ b/engines/asylum/views/scene.cpp
@@ -1319,7 +1319,7 @@ void Scene::handleHit(int32 index, HitType type) {
if (!getScript()->isInQueue(object->getScriptIndex()))
getScript()->queueScript(object->getScriptIndex(), _playerIndex);
- // Original executes special script hit functions, but since there is none, we can skip this part
+ // Original executes special script hit functions, but since there is none defined, we can skip this part
}
break;
@@ -1363,7 +1363,60 @@ void Scene::handleHit(int32 index, HitType type) {
}
void Scene::playerReaction() {
- error("[Scene::playerReaction] Not implemented!");
+ const Common::Point mouse = getCursor()->position();
+ Common::Point point;
+ Actor *player = getActor();
+
+ player->adjustCoordinates(&point);
+
+ uint32 maxIndex = 0;
+ for (maxIndex = 0; maxIndex < 8; maxIndex++) {
+ if (!player->getReaction(maxIndex))
+ break;
+ }
+
+ maxIndex -= 1;
+
+ player->setField638(0);
+
+ if (maxIndex > 0) {
+ for (uint32 i = 0; i < maxIndex; i++) {
+ Common::Point ret = _vm->getSinCosValues(maxIndex, i);
+ int32 x = point.x + player->getPoint2()->x + ret.x;
+ int32 y = point.y + player->getPoint2()->y / 2 - ret.y;
+
+ if (mouse.x >= x && mouse.x <= (x + 40) && mouse.y >= y && mouse.y <= (y + 40)) {
+ // Handle reaction
+ getSound()->playSound(MAKE_RESOURCE(kResourcePackSound, 4));
+
+ if (_ws->chapter == kChapter9) {
+ switch (i) {
+ default:
+ player->setField638(player->getReaction(i));
+ break;
+
+ case 0:
+ getScript()->queueScript(_ws->actions[_ws->getActionAreaIndexById(2206)]->scriptIndex, _playerIndex);
+ break;
+
+ case 1:
+ getScript()->queueScript(_ws->actions[_ws->getActionAreaIndexById(2207)]->scriptIndex, _playerIndex);
+ break;
+
+ case 2:
+ getScript()->queueScript(_ws->actions[_ws->getActionAreaIndexById(2208)]->scriptIndex, _playerIndex);
+ break;
+ }
+ } else {
+ player->setField638(player->getReaction(i));
+ }
+ break;
+ }
+ }
+ }
+
+ player->updateStatus(kActorStatusEnabled);
+ getSound()->playSound(MAKE_RESOURCE(kResourcePackSound, 5));
}
void Scene::hitAreaChapter2(int32 id) {
Commit: 9d4fd0da2a51b39c3af0527b7378759ea627fa24
https://github.com/scummvm/scummvm/commit/9d4fd0da2a51b39c3af0527b7378759ea627fa24
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:32+02:00
Commit Message:
ASYLUM: Implement Savegame::getMoviesViewed() and Savegame::setMovieViewed()
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@637 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/system/savegame.cpp
engines/asylum/system/savegame.h
engines/asylum/system/video.cpp
engines/asylum/system/video.h
engines/asylum/views/menu.cpp
engines/asylum/views/menu.h
diff --git a/engines/asylum/system/savegame.cpp b/engines/asylum/system/savegame.cpp
index eca4db6c47..f56c7c6c83 100644
--- a/engines/asylum/system/savegame.cpp
+++ b/engines/asylum/system/savegame.cpp
@@ -30,6 +30,7 @@
namespace Asylum {
Savegame::Savegame(AsylumEngine *engine) : _vm(engine) {
+ memset(&_moviesViewed, 0, sizeof(_moviesViewed));
}
Savegame::~Savegame() {
@@ -70,6 +71,33 @@ bool Savegame::quickSave() {
return false;
}
+void Savegame::setMovieViewed(uint32 index) {
+ if (index >= ARRAYSIZE(_moviesViewed))
+ error("[Savegame::setMovieViewed] Invalid movie index!");
+
+ if (!_moviesViewed[index]) {
+ _moviesViewed[index] = 1;
+
+ // TODO Save to disk
+ warning("[Savegame::setMovieViewed] Not implemented!");
+ }
+}
+
+uint32 Savegame::getMoviesViewed(byte *movieList) {
+ memset(movieList, -1, 196);
+
+ uint32 count = 0;
+
+ for (uint32 i = 0; i < ARRAYSIZE(_moviesViewed); i++) {
+ if (_moviesViewed[i]) {
+ movieList[i] = i;
+ ++count;
+ }
+ }
+
+ return count;
+}
+
void Savegame::loadViewedMovies() {
warning("[Savegame::loadViewedMovies] Not implemented!");
}
diff --git a/engines/asylum/system/savegame.h b/engines/asylum/system/savegame.h
index 9fa8ced42b..b3a9ba2c8f 100644
--- a/engines/asylum/system/savegame.h
+++ b/engines/asylum/system/savegame.h
@@ -26,6 +26,9 @@
#ifndef ASYLUM_SAVEGAME_H
#define ASYLUM_SAVEGAME_H
+#include "common/scummsys.h"
+#include "common/util.h"
+
namespace Asylum {
class AsylumEngine;
@@ -48,10 +51,14 @@ public:
bool save();
bool quickSave();
+ void setMovieViewed(uint32 index);
+ uint32 getMoviesViewed(byte *movieList);
void loadViewedMovies();
private:
AsylumEngine* _vm;
+
+ byte _moviesViewed[196];
};
} // End of namespace Asylum
diff --git a/engines/asylum/system/video.cpp b/engines/asylum/system/video.cpp
index 48cc41796e..8830a7c879 100644
--- a/engines/asylum/system/video.cpp
+++ b/engines/asylum/system/video.cpp
@@ -27,6 +27,7 @@
#include "asylum/system/config.h"
#include "asylum/system/graphics.h"
+#include "asylum/system/savegame.h"
#include "asylum/system/text.h"
#include "asylum/asylum.h"
@@ -35,7 +36,7 @@
namespace Asylum {
-Video::Video(AsylumEngine *engine, Audio::Mixer *mixer): _skipVideo(false) {
+Video::Video(AsylumEngine *engine, Audio::Mixer *mixer): _vm(engine), _skipVideo(false) {
Common::Event stopEvent;
_stopEvents.clear();
stopEvent.type = Common::EVENT_KEYDOWN;
@@ -51,12 +52,17 @@ Video::Video(AsylumEngine *engine, Audio::Mixer *mixer): _skipVideo(false) {
Video::~Video() {
delete _smkDecoder;
delete _text;
+
+ // Zero-out passed pointers
+ _vm = NULL;
}
void Video::playVideo(int32 videoNumber) {
char filename[20];
sprintf(filename, "mov%03d.smk", videoNumber);
+ getSaveLoad()->setMovieViewed(videoNumber);
+
if (!_smkDecoder->loadFile(filename)) {
_smkDecoder->close();
diff --git a/engines/asylum/system/video.h b/engines/asylum/system/video.h
index 79ee23198e..994c80373b 100644
--- a/engines/asylum/system/video.h
+++ b/engines/asylum/system/video.h
@@ -59,6 +59,8 @@ public:
void playVideo(int32 videoNumber);
private:
+ AsylumEngine *_vm;
+
void performPostProcessing(byte *screen);
void loadSubtitles(int32 videoNumber);
void processVideoEvents();
diff --git a/engines/asylum/views/menu.cpp b/engines/asylum/views/menu.cpp
index 3f3bac3c8a..ee98550d9e 100644
--- a/engines/asylum/views/menu.cpp
+++ b/engines/asylum/views/menu.cpp
@@ -68,6 +68,10 @@ MainMenu::MainMenu(AsylumEngine *vm): _vm(vm) {
_creditsFrameIndex = 0;
_needEyeCursorInit = false;
+ // Movies
+ _movieCount = 0;
+ memset(&_movieList, 0 , sizeof(_movieList));
+
memset(&_iconFrames, 0, sizeof(_iconFrames));
}
@@ -175,10 +179,6 @@ void MainMenu::closeCredits() {
leave();
}
-void MainMenu::listMovies() {
- warning("[MainMenu::listMovies] Not implemented!");
-}
-
MainMenu::MenuScreen MainMenu::findMousePosition() {
for (uint i = 0; i < ARRAYSIZE(menuRects); i++)
if (menuRects[i].contains(getCursor()->position()))
@@ -667,7 +667,7 @@ bool MainMenu::click(const AsylumEvent &evt) {
_dword_455C78 = false;
_dword_456288 = 0;
_textScroll = 0;
- listMovies();
+ _movieCount = getSaveLoad()->getMoviesViewed((byte *)&_movieList);
break;
case kMenuKeyboardConfig:
diff --git a/engines/asylum/views/menu.h b/engines/asylum/views/menu.h
index 8487a1e5db..cbeb61fb5d 100644
--- a/engines/asylum/views/menu.h
+++ b/engines/asylum/views/menu.h
@@ -110,6 +110,10 @@ private:
bool _needEyeCursorInit;
uint32 _iconFrames[12];
+ // Movies
+ byte _movieList[196];
+ uint32 _movieCount;
+
/**
* Setups menu screen
*/
@@ -132,11 +136,6 @@ private:
*/
void closeCredits();
- /**
- * List viewed movies
- */
- void listMovies();
-
/**
* Sets up the music.
*/
@@ -172,7 +171,7 @@ private:
void adjustTestVolume();
/**
- * Adjust performance.
+ * Adjust performance.
*/
void adjustPerformance();
Commit: ba2a0a407052e83f5c5b3f833909b62d887494be
https://github.com/scummvm/scummvm/commit/ba2a0a407052e83f5c5b3f833909b62d887494be
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:32+02:00
Commit Message:
ASYLUM: Implement remaining part of Scene::hitTestActor()
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@638 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/views/scene.cpp
diff --git a/engines/asylum/views/scene.cpp b/engines/asylum/views/scene.cpp
index d9dbaa7b12..4e930048a2 100644
--- a/engines/asylum/views/scene.cpp
+++ b/engines/asylum/views/scene.cpp
@@ -1201,33 +1201,87 @@ ActorIndex Scene::hitTestActor() {
switch (_ws->chapter) {
default:
- for (int i = _ws->actors.size() - 1; i >= 0 ; i--) {
+ break;
+
+ case kChapter8:
+ if (_ws->actors.size() <= 7)
+ error("[Scene::hitTestActor] Not enough actors to check (chapter 8 - checking actors 1-7)!");
+
+ for (uint i = 1; i < 7; i++) {
Actor *actor = getActor(i);
- int32 hitFrame;
- if (actor->getFrameIndex() >= actor->getFrameCount())
- hitFrame = 2 * actor->getFrameIndex() - actor->getFrameCount() - 1;
- else
- hitFrame = actor->getFrameIndex();
+ if (!actor->isVisible() || !actor->actionType)
+ continue;
- if (hitTestPixel(actor->getResourceId(),
- hitFrame,
- _ws->xLeft - actor->getPoint()->x - actor->getPoint1()->x,
- _ws->yTop - actor->getPoint()->y - actor->getPoint1()->y,
- actor->getDirection() >= kDirectionSE))
+ int32 x = _ws->xLeft + mouse.x - (actor->getPoint1()->x + actor->getPoint()->x);
+ int32 y = _ws->yTop + mouse.y - (actor->getPoint1()->y + actor->getPoint()->y);
+
+ if (x > 300 && x < 340 && y > 220 && y < 260)
return i;
}
break;
- case kChapter8:
- error("[Scene::hitTestActor] Not implemented (chapter 8)!");
- break;
-
case kChapter11:
- error("[Scene::hitTestActor] Not implemented (chapter 11)!");
+ if (_ws->actors.size() <= 1)
+ error("[Scene::hitTestActor] Not enough actors to check (chapter 11 - checking actor 1)!");
+
+ if (getActor(1)->isOnScreen() && getActor(1)->actionType) {
+ Actor *actor = getActor(1);
+
+ int32 x = _ws->xLeft + mouse.x - (actor->getPoint1()->x + actor->getPoint()->x);
+ int32 y = _ws->yTop + mouse.y - (actor->getPoint1()->y + actor->getPoint()->y);
+
+ Common::Rect rect = GraphicResource::getFrameRect(_vm, actor->getResourceId(), 0);
+
+ if (x > (rect.left - 10)
+ && x < (rect.width() + rect.left + 10)
+ && y > (rect.top - 10)
+ && y < (rect.height() + rect.top + 10))
+ return 1;
+ }
+
+ if (_ws->actors.size() <= 15)
+ error("[Scene::hitTestActor] Not enough actors to check (chapter 11 - checking actors 10-15)!");
+
+ for (uint i = 10; i < 15; i++) {
+ Actor *actor = getActor(i);
+
+ if (!actor->isOnScreen() || !actor->actionType)
+ continue;
+
+ Common::Rect rect = GraphicResource::getFrameRect(_vm, actor->getResourceId(), 0);
+
+ int32 x = _ws->xLeft + mouse.x - (actor->getPoint1()->x + actor->getPoint()->x);
+ int32 y = _ws->yTop + mouse.y - (actor->getPoint1()->y + actor->getPoint()->y);
+
+ if (x > (rect.left - 10)
+ && x < (rect.width() + rect.left + 10)
+ && y > (rect.top - 10)
+ && y < (rect.height() + rect.top + 10))
+ return i;
+ }
break;
}
+ //////////////////////////////////////////////////////////////////////////
+ // Default check
+ for (int i = _ws->actors.size() - 1; i >= 0 ; i--) {
+ Actor *actor = getActor(i);
+
+ int32 hitFrame;
+ if (actor->getFrameIndex() >= actor->getFrameCount())
+ hitFrame = 2 * actor->getFrameIndex() - actor->getFrameCount() - 1;
+ else
+ hitFrame = actor->getFrameIndex();
+
+ if (hitTestPixel(actor->getResourceId(),
+ hitFrame,
+ _ws->xLeft - actor->getPoint()->x - actor->getPoint1()->x,
+ _ws->yTop - actor->getPoint()->y - actor->getPoint1()->y,
+ actor->getDirection() >= kDirectionSE))
+ return i;
+ }
+
return -1;
}
Commit: 49215b5c16230ed10ddeda39fc0e8152a023feba
https://github.com/scummvm/scummvm/commit/49215b5c16230ed10ddeda39fc0e8152a023feba
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:33+02:00
Commit Message:
ASYLUM: Implement proper version of Scene::findActionArea()
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@639 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/resources/actor.cpp
engines/asylum/resources/script.cpp
engines/asylum/resources/script.h
engines/asylum/views/scene.cpp
diff --git a/engines/asylum/resources/actor.cpp b/engines/asylum/resources/actor.cpp
index 329cb4297c..7ef5f14f69 100644
--- a/engines/asylum/resources/actor.cpp
+++ b/engines/asylum/resources/actor.cpp
@@ -736,7 +736,7 @@ void Actor::faceTarget(uint32 target, DirectionFrom from) {
return;
}
- PolyDefinitions *polygon = &getScene()->polygons()->entries[getWorld()->actions[actionIndex]->polyIdx];
+ PolyDefinitions *polygon = &getScene()->polygons()->entries[getWorld()->actions[actionIndex]->polygonIndex];
point.x = polygon->boundingRect.left + (polygon->boundingRect.right - polygon->boundingRect.left) / 2;
point.y = polygon->boundingRect.top + (polygon->boundingRect.bottom - polygon->boundingRect.top) / 2;
@@ -1249,7 +1249,7 @@ void Actor::updateStatusEnabled() {
if (areaIndex != -1) {
ActionArea *area = getWorld()->actions[areaIndex];
- PolyDefinitions *poly = &getScene()->polygons()->entries[area->polyIdx];
+ PolyDefinitions *poly = &getScene()->polygons()->entries[area->polygonIndex];
Common::Point pt(poly->boundingRect.left + rnd(poly->boundingRect.width()),
poly->boundingRect.top + rnd(poly->boundingRect.height()));
diff --git a/engines/asylum/resources/script.cpp b/engines/asylum/resources/script.cpp
index 48a9d8e23f..cdd8a8460d 100644
--- a/engines/asylum/resources/script.cpp
+++ b/engines/asylum/resources/script.cpp
@@ -65,7 +65,7 @@ void ActionArea::load(Common::SeekableReadStream *stream) {
flagNums[i] = stream->readSint32LE();
field_7C = stream->readSint32LE();
- polyIdx = stream->readSint32LE();
+ polygonIndex = stream->readSint32LE();
field_84 = stream->readSint32LE();
field_88 = stream->readSint32LE();
soundResourceId = (ResourceId)stream->readSint32LE();
diff --git a/engines/asylum/resources/script.h b/engines/asylum/resources/script.h
index 7984d8aea1..ecc2719c29 100644
--- a/engines/asylum/resources/script.h
+++ b/engines/asylum/resources/script.h
@@ -70,7 +70,7 @@ struct ActionArea {
int32 actionType; ///< flag (see ActionType enumeration)
int32 flagNums[10];
int32 field_7C;
- int32 polyIdx;
+ int32 polygonIndex;
int32 field_84;
int32 field_88;
ResourceId soundResourceId;
@@ -92,7 +92,7 @@ struct ActionArea {
actionType = 0;
memset(&flagNums, 0, sizeof(flagNums));
field_7C = 0;
- polyIdx = 0;
+ polygonIndex = 0;
field_84 = 0;
field_88 = 0;
soundResourceId = kResourceNone;
@@ -108,7 +108,7 @@ struct ActionArea {
Common::String output;
output += Common::String::format("Action %d: %s\n", id, name);
- output += Common::String::format(" flags=%d scriptIndex=%d scriptIndex2=%d type=%d\n", flags, scriptIndex, actionType, polyIdx);
+ output += Common::String::format(" flags=%d scriptIndex=%d scriptIndex2=%d type=%d\n", flags, scriptIndex, actionType, polygonIndex);
output += Common::String::format(" sound=%d polygon=%d palette=%d volume=%d\n", soundResourceId, scriptIndex2, paletteResourceId, volume);
output += Common::String::format(" field01=%d field02=%d field40=%d field44=%d\n", field01, field02, field_40, field_44);
output += Common::String::format(" field7C=%d field84=%d field88=%d field90=%d\n", field_7C, field_84, field_88, field_90);
diff --git a/engines/asylum/views/scene.cpp b/engines/asylum/views/scene.cpp
index 4e930048a2..a3aad857cc 100644
--- a/engines/asylum/views/scene.cpp
+++ b/engines/asylum/views/scene.cpp
@@ -1914,20 +1914,74 @@ int32 Scene::findActionArea(ActionAreaType type, const Common::Point pt) {
if (!_polygons)
error("[Scene::findActionArea] Polygons not initialized properly!");
- // TODO
- // This is a VERY loose implementation of the target
- // function, as this doesn't do any of the flag checking
- // the original did
- int32 targetIdx = -1;
- for (uint32 i = 0; i < _ws->actions.size(); i++) {
- ActionArea *a = _ws->actions[i];
- PolyDefinitions p = _polygons->entries[a->polyIdx];
- if (p.contains(pt.x, pt.y)) {
- targetIdx = i;
- break;
+ switch (type) {
+ default:
+ return type - 2;
+
+ case kActionAreaType1:
+ if (_ws->actions.size() < 1)
+ return -1;
+
+ for (int32 i = _ws->actions.size() - 1; i >= 0; i--) {
+ ActionArea *area = _ws->actions[i];
+
+ bool found = false;
+
+ // Iterate over flagNum
+ for (uint32 j = 0; j < 10; j++) {
+ if (!area->flagNums[j])
+ break; // We stop as soon as a flag is 0
+
+ bool flagSet = false;
+ if (area->flagNums[j] <= 0)
+ flagSet = _vm->isGameFlagNotSet((GameFlag)-area->flagNums[j]);
+ else
+ flagSet = _vm->isGameFlagNotSet((GameFlag)area->flagNums[j]);
+
+ if (!flagSet) {
+ found = true;
+ break;
+ }
+ }
+
+ if (!found && _polygons->entries[area->polygonIndex].contains(pt))
+ return i;
}
+ break;
+
+ case kActionAreaType2:
+ if (_ws->actions.size() < 1)
+ return -1;
+
+ for (int32 i = _ws->actions.size() - 1; i >= 0; i--) {
+ ActionArea *area = _ws->actions[i];
+
+ bool found = false;
+
+ // Iterate over flagNum
+ for (uint32 j = 0; j < 10; j++) {
+ if (!area->flagNums[j])
+ continue; // We skip over null flags
+
+ bool flagSet = false;
+ if (area->flagNums[j] <= 0)
+ flagSet = _vm->isGameFlagNotSet((GameFlag)-area->flagNums[j]);
+ else
+ flagSet = _vm->isGameFlagNotSet((GameFlag)area->flagNums[j]);
+
+ if (!flagSet) {
+ found = true;
+ break;
+ }
+ }
+
+ if (!found && _polygons->entries[area->polygonIndex].contains(pt))
+ return i;
+ }
+ break;
}
- return targetIdx;
+
+ return -1;
}
bool Scene::isInActionArea(const Common::Point &pt, ActionArea *area) {
Commit: 9cde7749f0621cc31fb8f52916701a0f7fa1fad4
https://github.com/scummvm/scummvm/commit/9cde7749f0621cc31fb8f52916701a0f7fa1fad4
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:33+02:00
Commit Message:
ASYLUM: Move isInActionArea from Scene to Actor
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@640 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/resources/actor.cpp
engines/asylum/resources/actor.h
engines/asylum/views/scene.cpp
engines/asylum/views/scene.h
diff --git a/engines/asylum/resources/actor.cpp b/engines/asylum/resources/actor.cpp
index 7ef5f14f69..4e2337480d 100644
--- a/engines/asylum/resources/actor.cpp
+++ b/engines/asylum/resources/actor.cpp
@@ -1255,7 +1255,7 @@ void Actor::updateStatusEnabled() {
poly->boundingRect.top + rnd(poly->boundingRect.height()));
if (!getSharedData()->getActorUpdateEnabledCheck()) {
- if (getScene()->isInActionArea(pt, area)) {
+ if (isInActionArea(pt, area)) {
Common::Point *polyPoint = &poly->points[rnd(poly->count())];
processStatus(polyPoint->x, polyPoint->y, false);
} else {
@@ -1725,6 +1725,10 @@ void Actor::updateNumbers(int32 reaction, int32 x, int32 y) {
_numberFlag01 = 1;
}
+bool Actor::isInActionArea(const Common::Point &pt, ActionArea *area) {
+ error("[Actor::isInActionArea] Not implemented!");
+}
+
//////////////////////////////////////////////////////////////////////////
// Misc
//////////////////////////////////////////////////////////////////////////
diff --git a/engines/asylum/resources/actor.h b/engines/asylum/resources/actor.h
index 88b511d8b9..53645d971d 100644
--- a/engines/asylum/resources/actor.h
+++ b/engines/asylum/resources/actor.h
@@ -439,6 +439,12 @@ private:
*/
void setVolume();
+ /**
+ * Updates the coordinates.
+ *
+ * @param vec1 The first vector.
+ * @param vec2 The second vector.
+ */
void updateCoordinates(Common::Point vec1, Common::Point vec2);
/**
@@ -455,6 +461,16 @@ private:
*/
void updateNumbers(int32 reaction, int32 x, int32 y);
+ /**
+ * Determine if the supplied point is in the action area
+ *
+ * @param pt The point.
+ * @param [in,out] area If non-null, the area.
+ *
+ * @return
+ */
+ bool isInActionArea(const Common::Point &pt, ActionArea *area);
+
//////////////////////////////////////////////////////////////////////////
// Helper methods
//////////////////////////////////////////////////////////////////////////
diff --git a/engines/asylum/views/scene.cpp b/engines/asylum/views/scene.cpp
index a3aad857cc..21a1ef516c 100644
--- a/engines/asylum/views/scene.cpp
+++ b/engines/asylum/views/scene.cpp
@@ -1984,11 +1984,6 @@ int32 Scene::findActionArea(ActionAreaType type, const Common::Point pt) {
return -1;
}
-bool Scene::isInActionArea(const Common::Point &pt, ActionArea *area) {
- error("[Scene::isInActionArea] Not implemented!");
-}
-
-
void Scene::changePlayer(ActorIndex index) {
error("[Scene::changePlayer] not implemented");
}
diff --git a/engines/asylum/views/scene.h b/engines/asylum/views/scene.h
index 2fe5514d25..e902a98a1c 100644
--- a/engines/asylum/views/scene.h
+++ b/engines/asylum/views/scene.h
@@ -156,16 +156,6 @@ public:
*/
int32 findActionArea(ActionAreaType type, const Common::Point pt);
- /**
- * Determine if the supplied point is in the action area
- *
- * @param pt The point.
- * @param [in,out] area If non-null, the area.
- *
- * @return
- */
- bool isInActionArea(const Common::Point &pt, ActionArea *area);
-
Polygons *polygons() { return _polygons; }
WorldStats *worldstats() { return _ws; }
@@ -415,11 +405,11 @@ private:
void stopSpeech();
/**
- * Play specific speech.
+ * Play specific speech.
*
- * @param code The key code.
+ * @param code The key code.
*
- * @return true if it succeeds, false if it fails.
+ * @return true if it succeeds, false if it fails.
*/
bool speak(Common::KeyCode code);
Commit: 7a8741e08af4636988f9c6cec7620984b6de84c0
https://github.com/scummvm/scummvm/commit/7a8741e08af4636988f9c6cec7620984b6de84c0
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:33+02:00
Commit Message:
ASYLUM: Implement sine/cosine table calculation on engine start
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@641 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/asylum.cpp
engines/asylum/asylum.h
diff --git a/engines/asylum/asylum.cpp b/engines/asylum/asylum.cpp
index ef65cf0bda..6ea50ac103 100644
--- a/engines/asylum/asylum.cpp
+++ b/engines/asylum/asylum.cpp
@@ -63,6 +63,7 @@ AsylumEngine::AsylumEngine(OSystem *system, const ADGameDescription *gd) : Engin
// Init data
memset(&_gameFlags, 0, sizeof(_gameFlags));
memset(&_puzzles, 0, sizeof(_puzzles));
+ memset(&_sinCosTables, 0, sizeof(_sinCosTables));
_introPlayed = false;
// Add default search directories
@@ -134,7 +135,7 @@ Common::Error AsylumEngine::run() {
initPuzzles();
// Init tables
- initSinCosTables();
+ initSinCosTables(80.0, 40, 40);
// Create main menu
_mainMenu = new MainMenu(this);
@@ -418,12 +419,58 @@ void AsylumEngine::initPuzzles() {
warning("[AsylumEngine::initPuzzles] Add missing puzzles!");
}
-void AsylumEngine::initSinCosTables() {
- warning("[AsylumEngine::initSinCosTables] Not implemented!");
+void AsylumEngine::initSinCosTables(double a2, int32 a3, int32 a4) {
+ uint32 offset = 0;
+ uint32 baseStep = 1;
+
+ do {
+ if (baseStep >= 1) {
+ int32 baseAngle = 90;
+ int32 step = baseStep;
+
+ int32 *val = &_sinCosTables[2 * offset];
+
+ do {
+ double angle = (double)(baseAngle % 360) * 3.141592653589 * 0.005555555555555556;
+
+ *val = cos(angle) * a2 - (a3 / 2);
+ *(val + 1) = sin(angle) * a2 - (a4 / 2);
+
+ baseAngle += 360 / baseStep;
+ val += 2;
+ --step;
+ } while (step);
+
+ offset += baseStep;
+ }
+
+ ++baseStep;
+
+ } while (baseStep <= 8);
+}
+
+int32 AsylumEngine::computeSinCosOffset(int32 val) {
+ int32 offset = 0;
+ for (int32 i = val; i > 0; --i)
+ offset += i;
+
+ return offset - val;
}
Common::Point AsylumEngine::getSinCosValues(int32 index1, int32 index2) {
- error("[AsylumEngine::getSinCosValues] Not implemented!");
+ Common::Point values;
+
+ if (_scene->worldstats()->chapter == kChapter11) {
+ int32 offset = computeSinCosOffset(8) + index2 + 3;
+ values.x = _sinCosTables[2 * offset];
+ values.y = _sinCosTables[1];
+ } else {
+ int32 offset = computeSinCosOffset(index1) + index2;
+ values.x = _sinCosTables[2 * offset];
+ values.y = _sinCosTables[2 * offset + 1];
+ }
+
+ return values;
}
void AsylumEngine::setupLoadedGame() {
diff --git a/engines/asylum/asylum.h b/engines/asylum/asylum.h
index 6c85aaeeb2..c027b52407 100644
--- a/engines/asylum/asylum.h
+++ b/engines/asylum/asylum.h
@@ -229,6 +229,7 @@ private:
SharedData _data;
int _gameFlags[145];
bool _introPlayed;
+ int32 _sinCosTables[72];
void handleEvents();
void updateMouseCursor();
@@ -247,7 +248,16 @@ private:
/**
* Initializes the sine/cosine tables.
*/
- void initSinCosTables();
+ void initSinCosTables(double a2, int32 a3, int32 a4);
+
+ /**
+ * Calculate the offset into the sine/cosine tables.
+ *
+ * @param val The value.
+ *
+ * @return The calculated offset.
+ */
+ int32 computeSinCosOffset(int32 val);
/**
* Sets up the loaded game.
Commit: 7463acb7721d29fc7cf8bd74b639f40a5dc61247
https://github.com/scummvm/scummvm/commit/7463acb7721d29fc7cf8bd74b639f40a5dc61247
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:33+02:00
Commit Message:
ASYLUM: Implement Scene::enterLoad() and Scene::changePlayer()
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@642 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/asylum.cpp
engines/asylum/asylum.h
engines/asylum/resources/actor.h
engines/asylum/resources/data.h
engines/asylum/shared.h
engines/asylum/views/scene.cpp
engines/asylum/views/scene.h
diff --git a/engines/asylum/asylum.cpp b/engines/asylum/asylum.cpp
index 6ea50ac103..c4f640b85f 100644
--- a/engines/asylum/asylum.cpp
+++ b/engines/asylum/asylum.cpp
@@ -25,9 +25,10 @@
#include "asylum/asylum.h"
+#include "asylum/resources/actor.h"
+#include "asylum/resources/encounters.h"
#include "asylum/resources/script.h"
#include "asylum/resources/special.h"
-#include "asylum/resources/encounters.h"
#include "asylum/resources/worldstats.h"
#include "asylum/puzzles/vcr.h"
@@ -191,7 +192,7 @@ void AsylumEngine::startGame(ResourcePackId sceneId, StartGameType type) {
case kStartGameLoad:
if (_savegame->load()) {
- setupLoadedGame();
+ _scene->enterLoad();
updateReverseStereo();
switchEventHandler(_scene);
}
@@ -338,10 +339,7 @@ void AsylumEngine::processDelayedEvents() {
// check for a delayed scene change
ResourcePackId packId = _script->getDelayedSceneIndex();
- // XXX Flag 183 indicates whether the actionlist is currently
- // processing
if (packId != kResourcePackInvalid && isGameFlagNotSet(kGameFlagScriptProcessing)) {
-
// Reset delayed scene
_script->setDelayedSceneIndex(kResourcePackInvalid);
@@ -473,10 +471,6 @@ Common::Point AsylumEngine::getSinCosValues(int32 index1, int32 index2) {
return values;
}
-void AsylumEngine::setupLoadedGame() {
- warning("[AsylumEngine::initSinCosTables] Not implemented!");
-}
-
void AsylumEngine::updateReverseStereo() {
if (_scene && _scene->worldstats())
_scene->worldstats()->reverseStereo = Config.reverseStereo;
diff --git a/engines/asylum/asylum.h b/engines/asylum/asylum.h
index c027b52407..50c369a1b8 100644
--- a/engines/asylum/asylum.h
+++ b/engines/asylum/asylum.h
@@ -259,11 +259,6 @@ private:
*/
int32 computeSinCosOffset(int32 val);
- /**
- * Sets up the loaded game.
- */
- void setupLoadedGame();
-
friend class Console;
};
diff --git a/engines/asylum/resources/actor.h b/engines/asylum/resources/actor.h
index 53645d971d..654284d059 100644
--- a/engines/asylum/resources/actor.h
+++ b/engines/asylum/resources/actor.h
@@ -68,6 +68,7 @@ public:
void setLastScreenUpdate(int32 tick) { _lastScreenUpdate = tick; }
void setNumberFlag01(int32 number) { _numberFlag01 = number; }
void setPriority(int32 priority) { _priority = priority; }
+ void setReaction(int32 index, int32 val) { _reaction[index] = val; }
void setResourceId(ResourceId id) { _resourceId = id; }
void setSoundResourceId(ResourceId id) { _soundResourceId = id; }
void setStatus(ActorStatus status) { _status = status; }
@@ -440,10 +441,10 @@ private:
void setVolume();
/**
- * Updates the coordinates.
+ * Updates the coordinates.
*
- * @param vec1 The first vector.
- * @param vec2 The second vector.
+ * @param vec1 The first vector.
+ * @param vec2 The second vector.
*/
void updateCoordinates(Common::Point vec1, Common::Point vec2);
diff --git a/engines/asylum/resources/data.h b/engines/asylum/resources/data.h
index 084d913fd3..cc0c2565df 100644
--- a/engines/asylum/resources/data.h
+++ b/engines/asylum/resources/data.h
@@ -117,13 +117,13 @@ public:
_sceneYTop = 0;
_sceneOffset = 0;
_sceneOffsetAdd = 0;
- memset(&_cursorResources, kResourceNone, sizeof(_cursorResources));
- memset(&_sceneFonts, kResourceNone, sizeof(_sceneFonts));
- _currentPaletteId = kResourceNone;
- memset(&_cellShadeMasks, 0, sizeof(_cellShadeMasks));
- _smallCurUp = 0;
- _smallCurDown = 0;
- _encounterFrameBg = 0;
+ memset(&cursorResources, kResourceNone, sizeof(cursorResources));
+ memset(&sceneFonts, kResourceNone, sizeof(sceneFonts));
+ //_currentPaletteId = kResourceNone;
+ //memset(&cellShadeMasks, 0, sizeof(cellShadeMasks));
+ smallCurUp = 0;
+ smallCurDown = 0;
+ encounterFrameBg = 0;
_flagSkipDrawScene = false;
_matteVar1 = 0;
_actorUpdateEnabledCheck = false;
@@ -146,6 +146,17 @@ public:
_nextScreenUpdate = 0;
}
+ // Saved scene data
+ ResourceId cursorResources[11];
+ // 2 ResourceId unused
+ ResourceId sceneFonts[3];
+ //ResourceId _currentPaletteId;
+ //int32 _cellShadeMasks[3];
+ // unused
+ int32 smallCurUp;
+ int32 smallCurDown;
+ int32 encounterFrameBg;
+
// Accessors
int32 getActorUpdateEnabledCounter() { return _actorUpdateStatusEnabledCounter; }
void setActorUpdateEnabledCounter(int32 val) { _actorUpdateStatusEnabledCounter = val; }
@@ -339,17 +350,6 @@ private:
int32 _sceneOffset;
Common::Rational _sceneOffsetAdd;
- // Saved scene data
- ResourceId _cursorResources[13];
- ResourceId _sceneFonts[3];
- ResourceId _currentPaletteId;
- int32 _cellShadeMasks[3];
- // unused
- int32 _smallCurUp;
- int32 _smallCurDown;
- int32 _encounterFrameBg;
-
-
bool _flagSkipDrawScene;
int32 _matteVar1;
bool _actorUpdateEnabledCheck;
diff --git a/engines/asylum/shared.h b/engines/asylum/shared.h
index a4a9b2c265..8d64bb39c9 100644
--- a/engines/asylum/shared.h
+++ b/engines/asylum/shared.h
@@ -98,6 +98,9 @@ enum GameFlag {
kGameFlag556 = 556,
kGameFlag560 = 560,
kGameFlag570 = 570,
+ kGameFlag635 = 635,
+ kGameFlag636 = 636,
+ kGameFlag637 = 637,
kGameFlag776 = 776,
kGameFlag815 = 815,
kGameFlag816 = 816,
diff --git a/engines/asylum/views/scene.cpp b/engines/asylum/views/scene.cpp
index 21a1ef516c..f18b3c55e1 100644
--- a/engines/asylum/views/scene.cpp
+++ b/engines/asylum/views/scene.cpp
@@ -199,6 +199,50 @@ void Scene::enter(ResourcePackId packId) {
}
}
+void Scene::enterLoad() {
+ _vm->setGameFlag(kGameFlagScriptProcessing);
+ getScreen()->clearGraphicsInQueue();
+
+ // Setup scene bounding rect
+ _ws->boundingRect.left = 195;
+ _ws->boundingRect.top = 115;
+ _ws->boundingRect.right = 445 - getActor()->getBoundingRect()->right;
+ _ws->boundingRect.bottom = 345 - getActor()->getBoundingRect()->bottom;
+
+ // Setup transparency table
+ getScreen()->setupTransTables(3, _ws->cellShadeMask1, _ws->cellShadeMask2, _ws->cellShadeMask3);
+ getScreen()->selectTransTable(1);
+ getText()->loadFont(_ws->font1);
+
+ preload();
+
+ // Adjust object priority
+ if (_ws->objects.size() > 0) {
+ int32 priority = 4091;
+
+ for (uint32 i = 0; i < _ws->objects.size(); i++) {
+ Object *object = _ws->objects[i];
+ object->setPriority(priority);
+ object->flags &= ~kObjectFlagC000;
+ priority -= 4;
+ }
+ }
+
+ // Play intro music
+ if (_ws->musicCurrentResourceIndex != kMusicStopped)
+ getSound()->playMusic(MAKE_RESOURCE(kResourcePackMusic, _ws->musicCurrentResourceIndex));
+ else
+ getSound()->playMusic(kResourceNone, 0);
+
+ // Palette fade
+ getScreen()->paletteFade(0, 75, 8);
+ getScreen()->clear();
+
+ getSharedData()->setFlag(kFlagScene1, true);
+ _vm->lastScreenUpdate = 1;
+ getActor()->setLastScreenUpdate(_vm->screenUpdateCount);
+}
+
void Scene::load(ResourcePackId packId) {
// Setup resource manager
_packId = packId;
@@ -1985,7 +2029,123 @@ int32 Scene::findActionArea(ActionAreaType type, const Common::Point pt) {
}
void Scene::changePlayer(ActorIndex index) {
- error("[Scene::changePlayer] not implemented");
+ switch (index) {
+ default:
+ if (_ws->chapter == kChapter9) {
+ changePlayerUpdate(index);
+
+ getActor(index)->show();
+ }
+ _playerIndex = index;
+ break;
+
+ case 1:
+ if (_ws->chapter == kChapter9) {
+ changePlayerUpdate(index);
+
+ getScreen()->setPalette(_ws->graphicResourceIds[0]);
+ _ws->currentPaletteId = _ws->graphicResourceIds[0];
+ getScreen()->setGammaLevel(_ws->graphicResourceIds[0], 0);
+ _vm->setGameFlag(kGameFlag635);
+ _vm->clearGameFlag(kGameFlag636);
+ _vm->clearGameFlag(kGameFlag637);
+
+ getActor(index)->show();
+ }
+
+ _playerIndex = index;
+ break;
+
+ case 2:
+ if (_ws->chapter == kChapter9) {
+ changePlayerUpdate(index);
+
+ getScreen()->setPalette(_ws->graphicResourceIds[1]);
+ _ws->currentPaletteId = _ws->graphicResourceIds[1];
+ getScreen()->setGammaLevel(_ws->graphicResourceIds[1], 0);
+ _vm->setGameFlag(kGameFlag636);
+ _vm->clearGameFlag(kGameFlag635);
+ _vm->clearGameFlag(kGameFlag637);
+
+ getActor(index)->show();
+ }
+
+ _playerIndex = index;
+ break;
+
+ case 3:
+ if (_ws->chapter == kChapter9) {
+ changePlayerUpdate(index);
+
+ getScreen()->setPalette(_ws->graphicResourceIds[2]);
+ _ws->currentPaletteId = _ws->graphicResourceIds[2];
+ getScreen()->setGammaLevel(_ws->graphicResourceIds[2], 0);
+ _vm->setGameFlag(kGameFlag637);
+ _vm->clearGameFlag(kGameFlag635);
+ _vm->clearGameFlag(kGameFlag636);
+
+ getActor(index)->show();
+ }
+
+ getActor(index)->show();
+ _playerIndex = index;
+ break;
+
+ case 666:
+ memcpy(getSharedData()->cursorResources, _ws->cursorResources, 44);
+ getScreen()->setupTransTables(3, _ws->graphicResourceIds[50], _ws->graphicResourceIds[49], _ws->graphicResourceIds[48]);
+ getSharedData()->sceneFonts[0] = _ws->font1;
+ getSharedData()->sceneFonts[1] = _ws->font2;
+ getSharedData()->sceneFonts[2] = _ws->font3;
+ getSharedData()->smallCurDown = _ws->smallCurDown;
+ getSharedData()->smallCurUp = _ws->smallCurUp;
+ getSharedData()->encounterFrameBg = _ws->encounterFrameBg;
+
+ // Setup new values
+ for (uint32 i = 0; i < 11; i++)
+ _ws->cursorResources[i] = _ws->graphicResourceIds[40 + i];
+
+ _ws->font1 = _ws->graphicResourceIds[35];
+ _ws->font2 = _ws->graphicResourceIds[37];
+ _ws->font3 = _ws->graphicResourceIds[36];
+
+ _ws->smallCurUp = _ws->graphicResourceIds[33];
+ _ws->smallCurDown = _ws->graphicResourceIds[34];
+ _ws->encounterFrameBg = _ws->graphicResourceIds[32];
+ break;
+
+ case 667:
+ getScreen()->setupTransTables(3, _ws->cellShadeMask1, _ws->cellShadeMask2, _ws->cellShadeMask3);
+ memcpy(_ws->cursorResources, getSharedData()->cursorResources, 44);
+ _ws->font1 = getSharedData()->sceneFonts[0];
+ _ws->font2 = getSharedData()->sceneFonts[1];
+ _ws->font3 = getSharedData()->sceneFonts[2];
+
+ _ws->smallCurDown = getSharedData()->smallCurDown;
+ _ws->smallCurUp = getSharedData()->smallCurUp;
+ _ws->encounterFrameBg = getSharedData()->encounterFrameBg;
+
+ // Reset cursor
+ getCursor()->set(_ws->cursorResources[kCursorResourceMagnifyingGlass], 0, kCursorAnimationNone);
+ break;
+
+ case 668:
+ getActor(11)->setPosition(2300, 100, kDirectionN, 0);
+ getSharedData()->setData(40, 0);
+ getSharedData()->setFlag(kFlag1, false);
+ break;
+ }
+}
+
+void Scene::changePlayerUpdate(ActorIndex index) {
+ Actor *actor = getActor(index);
+ Actor *player = getActor();
+
+ actor->setPosition(player->getPoint1()->x + player->getPoint2()->x, player->getPoint1()->y + player->getPoint2()->y, player->getDirection(), 0);
+ player->hide();
+
+ for (uint i = 0; i < 8; i++)
+ actor->setReaction(i, player->getReaction(i));
}
//////////////////////////////////////////////////////////////////////////
diff --git a/engines/asylum/views/scene.h b/engines/asylum/views/scene.h
index e902a98a1c..b96b68a73d 100644
--- a/engines/asylum/views/scene.h
+++ b/engines/asylum/views/scene.h
@@ -92,6 +92,11 @@ public:
*/
void enter(ResourcePackId packId);
+ /**
+ * Enter the scene after a loaded game
+ */
+ void enterLoad();
+
/**
* Handle events
*
@@ -134,6 +139,13 @@ public:
*/
void changePlayer(ActorIndex index);
+ /**
+ * Update player position when changing current player
+ *
+ * @param index Zero-based index of the actor
+ */
+ void changePlayerUpdate(ActorIndex index);
+
/**
* Updates the scene coordinates.
*
Commit: 84dbd45ae0834c7650c3f0b4909d180a7f65903e
https://github.com/scummvm/scummvm/commit/84dbd45ae0834c7650c3f0b4909d180a7f65903e
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:33+02:00
Commit Message:
ASYLUM: Add Game::reset() function
- Set game as started in the menu, making return to game work properly
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@643 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/asylum.cpp
engines/asylum/asylum.h
engines/asylum/puzzles/puzzle.h
engines/asylum/views/menu.h
diff --git a/engines/asylum/asylum.cpp b/engines/asylum/asylum.cpp
index c4f640b85f..0277c2e1b5 100644
--- a/engines/asylum/asylum.cpp
+++ b/engines/asylum/asylum.cpp
@@ -217,7 +217,7 @@ void AsylumEngine::restart() {
_data.getPoint()->x = -1;
_data.getPoint()->y = -1;
- // FIXME the original runs a list of "reset" functions (some can be moved to constructors, others need to be part of the global data)
+ reset();
_introPlayed = false;
@@ -227,6 +227,18 @@ void AsylumEngine::restart() {
startGame(kResourcePackTowerCells, kStartGamePlayIntro);
}
+void AsylumEngine::reset() {
+ // Set game as started
+ _mainMenu->setGameStarted();
+
+ // Reset puzzles
+ for (uint32 i = 0; i < ARRAYSIZE(_puzzles); i++)
+ if (_puzzles[i] != NULL)
+ _puzzles[i]->reset();
+
+ // FIXME reset shared actor data
+}
+
void AsylumEngine::playIntro() {
if (!_video || !_screen)
error("[AsylumEngine::playIntro] Subsystems not initialized properly!");
diff --git a/engines/asylum/asylum.h b/engines/asylum/asylum.h
index 50c369a1b8..718edfaaea 100644
--- a/engines/asylum/asylum.h
+++ b/engines/asylum/asylum.h
@@ -126,6 +126,11 @@ public:
*/
SharedData *getData() { return &_data; }
+ /**
+ * Resets the game
+ */
+ void reset();
+
/**
* This is the global tick counter.
*/
diff --git a/engines/asylum/puzzles/puzzle.h b/engines/asylum/puzzles/puzzle.h
index e674b3752b..6f0f138dd9 100644
--- a/engines/asylum/puzzles/puzzle.h
+++ b/engines/asylum/puzzles/puzzle.h
@@ -51,6 +51,8 @@ public:
virtual void open() = 0;
virtual void close() = 0;
+ virtual void reset() {}
+
bool isActive() { return _active; }
protected:
diff --git a/engines/asylum/views/menu.h b/engines/asylum/views/menu.h
index cbeb61fb5d..6c2f3f365a 100644
--- a/engines/asylum/views/menu.h
+++ b/engines/asylum/views/menu.h
@@ -57,6 +57,11 @@ public:
*/
bool handleEvent(const AsylumEvent &evt);
+ /**
+ * Sets the game as started.
+ */
+ void setGameStarted() { _gameStarted = true; }
+
private:
AsylumEngine *_vm;
Commit: e137c665c15d1d3e6fd83f2544b93da1c0b05f26
https://github.com/scummvm/scummvm/commit/e137c665c15d1d3e6fd83f2544b93da1c0b05f26
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:33+02:00
Commit Message:
ASYLUM: Cleanup sound queue
- Rename sound buffer to sound queue
- Properly cleanup queue and handle duplicated queue items
- Add stub for checking if a sound resource is valid
This fixes sounds in the main menu not always playing properly on mouse over
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@644 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/system/sound.cpp
engines/asylum/system/sound.h
diff --git a/engines/asylum/system/sound.cpp b/engines/asylum/system/sound.cpp
index 2c02d3b55b..c0bd7b6cf2 100644
--- a/engines/asylum/system/sound.cpp
+++ b/engines/asylum/system/sound.cpp
@@ -47,7 +47,7 @@ Sound::Sound(AsylumEngine *engine, Audio::Mixer *mixer) : _vm(engine), _mixer(mi
}
Sound::~Sound() {
- clearSoundBuffer();
+ cleanupQueue();
// Zero-out passed pointers
_vm = NULL;
@@ -59,24 +59,32 @@ Sound::~Sound() {
//////////////////////////////////////////////////////////////////////////
void Sound::playSound(ResourceId resourceId, bool looping, int32 volume, int32 panning) {
- SoundBufferItem *item = getItem(resourceId);
+ // Cleanup sound queue
+ cleanupQueue();
- if (item) {
- if (_mixer->isSoundHandleActive(item->handle)) {
- debugC(kDebugLevelSound, "[Sound::playSound] handle for resource %d already active", resourceId);
+ if (volume <= -10000)
+ return;
+ SoundQueueItem *item = getItem(resourceId);
+ if (item) {
+ // Duplicate the queue entry
+ item = addToQueue(item->resourceId);
+ item->unknown = 0;
+ } else {
+ // Check that the sound is valid
+ if (!isValidSoundResource(resourceId))
return;
- }
- //warning("[Sound::playSound] resource %d already buffered", resourceId);
+ item = addToQueue(resourceId);
- // TODO check what we should do here
- return;
+ // TODO add missing code
}
+ // Original sets position back to 0
+ _mixer->stopHandle(item->handle);
+
ResourceEntry *resource = getResource()->get(resourceId);
- playSoundData(Audio::Mixer::kSFXSoundType, &_soundHandle, resource->data, resource->size, looping, volume, panning);
- addToSoundBuffer(resourceId);
+ playSoundData(Audio::Mixer::kSFXSoundType, &item->handle, resource->data, resource->size, looping, volume, panning);
}
void Sound::playMusic(ResourceId resourceId, int32 volume) {
@@ -113,7 +121,7 @@ bool Sound::isPlaying(ResourceId resourceId) {
//////////////////////////////////////////////////////////////////////////
void Sound::setVolume(ResourceId resourceId, int32 volume) {
- SoundBufferItem *item = getPlayingItem(resourceId);
+ SoundQueueItem *item = getPlayingItem(resourceId);
if (!item)
return;
@@ -138,7 +146,7 @@ void Sound::setPanning(ResourceId resourceId, int32 panning) {
if (Config.performance == 1)
return;
- SoundBufferItem *item = getPlayingItem(resourceId);
+ SoundQueueItem *item = getPlayingItem(resourceId);
if (!item)
return;
@@ -220,20 +228,20 @@ int32 Sound::calculatePanningAtPoint(int32 x, int32) {
// Stopping sounds
//////////////////////////////////////////////////////////////////////////
void Sound::stop(ResourceId resourceId) {
- SoundBufferItem *item = getPlayingItem(resourceId);
+ SoundQueueItem *item = getPlayingItem(resourceId);
if (item != NULL)
_mixer->stopHandle(item->handle);
}
void Sound::stopAll(ResourceId resourceId) {
- for (Common::Array<SoundBufferItem>::iterator it = _soundBuffer.begin(); it != _soundBuffer.end(); it++)
+ for (Common::Array<SoundQueueItem>::iterator it = _soundQueue.begin(); it != _soundQueue.end(); it++)
if (it->resourceId == resourceId)
_mixer->stopHandle(it->handle);
}
void Sound::stopAll() {
- for (Common::Array<SoundBufferItem>::iterator it = _soundBuffer.begin(); it != _soundBuffer.end(); it++)
+ for (Common::Array<SoundQueueItem>::iterator it = _soundQueue.begin(); it != _soundQueue.end(); it++)
_mixer->stopHandle(it->handle);
}
@@ -260,47 +268,48 @@ void Sound::playSoundData(Audio::Mixer::SoundType type, Audio::SoundHandle *hand
// Sound buffer
//////////////////////////////////////////////////////////////////////////
-SoundBufferItem *Sound::getItem(ResourceId resourceId) {
- for (uint32 i = 0; i < _soundBuffer.size(); i++)
- if (resourceId == _soundBuffer[i].resourceId)
- return &_soundBuffer[i];
+SoundQueueItem *Sound::getItem(ResourceId resourceId) {
+ for (uint32 i = 0; i < _soundQueue.size(); i++)
+ if (resourceId == _soundQueue[i].resourceId)
+ return &_soundQueue[i];
return NULL;
}
-SoundBufferItem *Sound::getPlayingItem(ResourceId resourceId) {
- for (uint32 i = 0; i < _soundBuffer.size(); i++)
- if (resourceId == _soundBuffer[i].resourceId
- && _mixer->isSoundHandleActive(_soundBuffer[i].handle))
- return &_soundBuffer[i];
+SoundQueueItem *Sound::getPlayingItem(ResourceId resourceId) {
+ for (uint32 i = 0; i < _soundQueue.size(); i++)
+ if (resourceId == _soundQueue[i].resourceId
+ && _mixer->isSoundHandleActive(_soundQueue[i].handle))
+ return &_soundQueue[i];
return NULL;
}
-bool Sound::addToSoundBuffer(ResourceId resourceId) {
- SoundBufferItem *item = getItem(resourceId);
+SoundQueueItem *Sound::addToQueue(ResourceId resourceId) {
+ SoundQueueItem sound;
+ sound.resourceId = resourceId;
+ _soundQueue.push_back(sound);
- if (item == NULL) {
- SoundBufferItem sound;
- sound.resourceId = resourceId;
- sound.handle = _soundHandle;
- _soundBuffer.push_back(sound);
- }
-
- return (item == NULL) ? true : false;
+ return &_soundQueue.back();
}
-void Sound::removeFromSoundBuffer(ResourceId resourceId) {
- for (uint i = 0; i < _soundBuffer.size(); i++) {
- if (_soundBuffer[i].resourceId == resourceId) {
- _soundBuffer.remove_at(i);
- break;
- }
+void Sound::cleanupQueue() {
+ for (uint i = 0; i < _soundQueue.size(); i++) {
+ if (_mixer->isSoundHandleActive(_soundQueue[i].handle))
+ continue;
+
+ // Remove the finished sound from the queue
+ _soundQueue.remove_at(i);
+ --i;
}
}
-void Sound::clearSoundBuffer() {
- _soundBuffer.clear();
+//////////////////////////////////////////////////////////////////////////
+// Helper functions
+//////////////////////////////////////////////////////////////////////////
+bool Sound::isValidSoundResource(ResourceId resourceId) {
+ warning("[Sound::isValidSoundFile] Not implemented!");
+ return true;
}
//////////////////////////////////////////////////////////////////////////
diff --git a/engines/asylum/system/sound.h b/engines/asylum/system/sound.h
index e7faff7154..892271e489 100644
--- a/engines/asylum/system/sound.h
+++ b/engines/asylum/system/sound.h
@@ -96,10 +96,15 @@ struct AmbientSoundItem {
}
};
-struct SoundBufferItem {
+struct SoundQueueItem {
ResourceId resourceId;
Audio::SoundHandle handle;
int32 unknown;
+
+ SoundQueueItem() {
+ resourceId = kResourceNone;
+ unknown = 0;
+ }
};
class Sound {
@@ -263,67 +268,69 @@ private:
Audio::Mixer *_mixer;
Audio::SoundHandle _musicHandle;
- Audio::SoundHandle _soundHandle;
-
int32 _musicVolume;
- Common::Array<SoundBufferItem> _soundBuffer;
-
- /**
- * Play sound data.
- *
- * @param type The type.
- * @param handle The handle.
- * @param soundData The sound data
- * @param soundDataLength Length of the sound data.
- * @param loop true to loop.
- * @param vol The volume.
- * @param pan The pan.
- */
- void playSoundData(Audio::Mixer::SoundType type, Audio::SoundHandle *handle, byte *soundData, uint32 soundDataLength, bool loop = false, int32 vol = 0, int32 pan = 0);
+ Common::Array<SoundQueueItem> _soundQueue;
//////////////////////////////////////////////////////////////////////////
- // Sound buffer
+ // Sound queue
//////////////////////////////////////////////////////////////////////////
/**
- * Find the index within the _soundBuffer array of the first sound sample with provided id.
+ * Find the index within the sound queue of the sound sample with provided id.
*
* @param resourceId Identifier for the resource.
*
* @return The item.
*/
- SoundBufferItem *getItem(ResourceId resourceId);
+ SoundQueueItem *getItem(ResourceId resourceId);
/**
- * Find the index within the _soundBuffer array of the first playing sound sample with provided id.
+ * Find the index within the sound queue of the playing sound sample with provided id.
*
* @param resourceId Identifier for the resource.
*
* @return The playing item.
*/
- SoundBufferItem *getPlayingItem(ResourceId resourceId);
+ SoundQueueItem *getPlayingItem(ResourceId resourceId);
/**
- * Adds a sound to the sound buffer.
+ * Adds a sound to the sound queue.
*
* @param resourceId Identifier for the resource.
*
- * @return true if it succeeds, false if it fails.
+ * @return the sound buffer item
*/
- bool addToSoundBuffer(ResourceId resourceId);
+ SoundQueueItem *addToQueue(ResourceId resourceId);
/**
- * Removes a sound from the sound buffer
+ * Clears the sound queue from finished sounds
+ */
+ void cleanupQueue();
+
+ //////////////////////////////////////////////////////////////////////////
+ // Helper functions
+ //////////////////////////////////////////////////////////////////////////
+
+ /**
+ * Checks if the sound file is valid
*
- * @param resourceId Identifier for the resource.
+ * @return true if valid, false if not.
*/
- void removeFromSoundBuffer(ResourceId resourceId);
+ bool isValidSoundResource(ResourceId resourceId);
/**
- * Clears the sound buffer.
+ * Play sound data.
+ *
+ * @param type The type.
+ * @param handle The handle.
+ * @param soundData The sound data
+ * @param soundDataLength Length of the sound data.
+ * @param loop true to loop.
+ * @param vol The volume.
+ * @param pan The pan.
*/
- void clearSoundBuffer();
+ void playSoundData(Audio::Mixer::SoundType type, Audio::SoundHandle *handle, byte *soundData, uint32 soundDataLength, bool loop = false, int32 vol = 0, int32 pan = 0);
//////////////////////////////////////////////////////////////////////////
// Conversion functions
Commit: 0fe5d4a88eb59f96a8394dae272159dd0fe04eaf
https://github.com/scummvm/scummvm/commit/0fe5d4a88eb59f96a8394dae272159dd0fe04eaf
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:34+02:00
Commit Message:
ASYLUM: Properly stop music and sound when adjusting performance in the menu
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@645 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/views/menu.cpp
diff --git a/engines/asylum/views/menu.cpp b/engines/asylum/views/menu.cpp
index ee98550d9e..12a4113382 100644
--- a/engines/asylum/views/menu.cpp
+++ b/engines/asylum/views/menu.cpp
@@ -294,7 +294,8 @@ void MainMenu::setupMusic() {
void MainMenu::adjustPerformance() {
// Original reinitialize sound to 11kHz for performance == 0, 22kHz otherwise
-
+ getSound()->stopAll();
+ getSound()->playMusic(kResourceNone, 0);
setupMusic();
uint32 index = getScene() ? getWorld()->musicCurrentResourceIndex : kMusicStopped;
Commit: d86ac730234e6ada306a33b064c868ad048e46c7
https://github.com/scummvm/scummvm/commit/d86ac730234e6ada306a33b064c868ad048e46c7
Author: Alex Bevilacqua (alexbevi at gmail.com)
Date: 2021-05-17T15:36:34+02:00
Commit Message:
ASYLUM: silence a few warnings
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@646 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/system/cursor.cpp
engines/asylum/system/cursor.h
diff --git a/engines/asylum/system/cursor.cpp b/engines/asylum/system/cursor.cpp
index b02909cf5e..e89cb27120 100644
--- a/engines/asylum/system/cursor.cpp
+++ b/engines/asylum/system/cursor.cpp
@@ -58,7 +58,7 @@ void Cursor::show() const {
CursorMan.showMouse(true);
}
-void Cursor::set(ResourceId resourceId, int32 counter, CursorAnimation animation, int32 frames) {
+void Cursor::set(ResourceId resourceId, int32 cnt, CursorAnimation anim, int32 frames) {
hide();
delete _cursorRes;
@@ -73,13 +73,13 @@ void Cursor::set(ResourceId resourceId, int32 counter, CursorAnimation animation
else
lastFrameIndex = _cursorRes->count() - 1;
- this->animation = animation;
- this->counter = counter;
+ this->animation = anim;
+ this->counter = cnt;
currentFrame = 0;
_frameStep = 1;
// Do not animate if no frames (and the other way around)
- if (lastFrameIndex == 0 || animation == kCursorAnimationNone) {
+ if (lastFrameIndex == 0 || anim == kCursorAnimationNone) {
lastFrameIndex = 0;
animation = kCursorAnimationNone;
}
@@ -185,7 +185,9 @@ Common::Point Cursor::getHotspot(uint32 frameIndex) {
uint32 resFlags = _cursorRes->getData().flags;
if (BYTE1(resFlags) & 0x10) {
- if (frameIndex >= 0 && frameIndex > _cursorRes->count()) {
+ // XXX removed a check for frameIndex >= 0 as it will always
+ // evaluate to true since frameIndex is unsigned
+ if (frameIndex > _cursorRes->count()) {
GraphicFrame *frame = _cursorRes->getFrame(currentFrame);
point.x = frame->x;
diff --git a/engines/asylum/system/cursor.h b/engines/asylum/system/cursor.h
index 145e2c6c19..4a29f03959 100644
--- a/engines/asylum/system/cursor.h
+++ b/engines/asylum/system/cursor.h
@@ -78,12 +78,12 @@ public:
* Set the current cursor instance to the graphic resource provide. The frames parameter defaults to -1, which in this case means that the frame count
* should be derived from the graphic resource as opposed to being explicitly set.
*
- * @param resourceId Identifier for the resource.
- * @param counter The counter.
- * @param animation The animation type
- * @param frames The frames.
+ * @param resourceId Identifier for the resource.
+ * @param cnt The counter.
+ * @param anim The animation type
+ * @param frames The frames.
*/
- void set(ResourceId resourceId, int32 counter = 0, CursorAnimation animation = kCursorAnimationMirror, int32 frames = -1);
+ void set(ResourceId resourceId, int32 cnt = 0, CursorAnimation anim = kCursorAnimationMirror, int32 frames = -1);
/**
* Get the next logical frame from the currently loaded
Commit: f0eb2a949720ba0496057eedcdd1fbec52f762da
https://github.com/scummvm/scummvm/commit/f0eb2a949720ba0496057eedcdd1fbec52f762da
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:34+02:00
Commit Message:
ASYLUM: Fix a couple more GCC warnings
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@647 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/system/screen.h
engines/asylum/views/scene.cpp
diff --git a/engines/asylum/system/screen.h b/engines/asylum/system/screen.h
index 3e8537b409..b351c12590 100644
--- a/engines/asylum/system/screen.h
+++ b/engines/asylum/system/screen.h
@@ -123,7 +123,7 @@ private:
Common::Rect _clipRect;
Common::Array<GraphicQueueItem> _queueItems;
- uint16 _flag;
+ int16 _flag;
bool _useColorKey;
// Transparency tables
diff --git a/engines/asylum/views/scene.cpp b/engines/asylum/views/scene.cpp
index f18b3c55e1..d74a17bfb4 100644
--- a/engines/asylum/views/scene.cpp
+++ b/engines/asylum/views/scene.cpp
@@ -1631,7 +1631,7 @@ void Scene::stopSpeech() {
}
bool Scene::speak(Common::KeyCode code) {
-#define GET_INDEX(val) ((((long long)val >> 32) ^ abs((int)val) & 1) == ((long long)val >> 32))
+#define GET_INDEX(val) ((((long long)val >> 32) ^ (abs((int)val) & 1)) == ((long long)val >> 32))
int32 index = -1;
Commit: d26a445376a5c6de2ee55b4428a505b8009a0acb
https://github.com/scummvm/scummvm/commit/d26a445376a5c6de2ee55b4428a505b8009a0acb
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:34+02:00
Commit Message:
ASYLUM: Finish implementation of Scene::updateCoordinates()
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@648 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/resources/data.h
engines/asylum/views/scene.cpp
diff --git a/engines/asylum/resources/data.h b/engines/asylum/resources/data.h
index cc0c2565df..7495ab24f3 100644
--- a/engines/asylum/resources/data.h
+++ b/engines/asylum/resources/data.h
@@ -113,10 +113,10 @@ public:
_sceneCounter = 0;
_point.x = -1;
_point.y = -1;
- _sceneXLeft = 0;
- _sceneYTop = 0;
- _sceneOffset = 0;
- _sceneOffsetAdd = 0;
+ sceneXLeft = 0;
+ sceneYTop = 0;
+ sceneOffset = 0;
+ sceneOffsetAdd = 0;
memset(&cursorResources, kResourceNone, sizeof(cursorResources));
memset(&sceneFonts, kResourceNone, sizeof(sceneFonts));
//_currentPaletteId = kResourceNone;
@@ -157,6 +157,12 @@ public:
int32 smallCurDown;
int32 encounterFrameBg;
+ // Global scene coordinates and offset
+ int32 sceneXLeft;
+ int32 sceneYTop;
+ int32 sceneOffset;
+ int32 sceneOffsetAdd;
+
// Accessors
int32 getActorUpdateEnabledCounter() { return _actorUpdateStatusEnabledCounter; }
void setActorUpdateEnabledCounter(int32 val) { _actorUpdateStatusEnabledCounter = val; }
@@ -194,12 +200,6 @@ public:
bool getMattePlaySound() { return _mattePlaySound; }
void setMattePlaySound(bool state) { _mattePlaySound = state; }
- // Scene
- void setSceneXLeft(int32 val) { _sceneXLeft = val; }
- void setSceneYTop(int32 val) { _sceneYTop = val; }
- void setSceneOffset(int32 val) { _sceneOffset = val; }
- void setSceneOffsetAdd(const Common::Rational &offset) { _sceneOffsetAdd = offset; }
-
Common::Point *getVector1() { return &_vector1; }
Common::Point *getVector2() { return &_vector2; }
@@ -345,10 +345,6 @@ private:
uint32 _sceneCounter;
Common::Point _point; // global point
//bool _flagEncouter2;
- int32 _sceneXLeft;
- int32 _sceneYTop;
- int32 _sceneOffset;
- Common::Rational _sceneOffsetAdd;
bool _flagSkipDrawScene;
int32 _matteVar1;
diff --git a/engines/asylum/views/scene.cpp b/engines/asylum/views/scene.cpp
index d74a17bfb4..82e45ef402 100644
--- a/engines/asylum/views/scene.cpp
+++ b/engines/asylum/views/scene.cpp
@@ -943,55 +943,100 @@ void Scene::updateAdjustScreen() {
void Scene::updateCoordinates() {
Actor *act = getActor();
- int32 newXLeft = -1;
- int32 newYTop = -1;
- Common::Rect b = _ws->boundingRect;
+ int32 xLeft = _ws->xLeft;
+ int32 yTop = _ws->yTop;
+ int32 posX = act->getPoint1()->x - _ws->xLeft;
+ int32 posY = act->getPoint1()->y - _ws->yTop;
+ Common::Rect boundingRect = _ws->boundingRect;
- if (_ws->motionStatus == 1) {
- int32 posX = act->getPoint1()->x - _ws->xLeft;
- int32 posY = act->getPoint1()->y - _ws->yTop;
+ switch (_ws->motionStatus) {
+ default:
+ break;
- if (posX < b.left || posX > b.right) {
- int32 newRBounds = posX - b.right;
- newXLeft = newRBounds + _ws->xLeft;
- _ws->xLeft += newRBounds;
+ case 1:
+ if (posX < boundingRect.left) {
+ xLeft = posX - boundingRect.left + _ws->xLeft;
+ _ws->xLeft += posX - boundingRect.left;
+ } else if (posX > boundingRect.right) {
+ xLeft = posX - boundingRect.right + _ws->xLeft;
+ _ws->xLeft += posX - boundingRect.right;
}
- if (posY < b.top || posY > b.bottom) {
- int32 newBBounds = posY - b.bottom;
- newYTop = newBBounds + _ws->yTop;
- _ws->yTop += newBBounds;
+ if (posY < boundingRect.top) {
+ yTop = posY - boundingRect.top + _ws->yTop;
+ _ws->yTop += posY - boundingRect.top;
+ } else if (posY > boundingRect.bottom) {
+ yTop = posY - boundingRect.bottom + _ws->yTop;
+ _ws->yTop += posY - boundingRect.bottom;
}
- if (newXLeft < 0)
- newXLeft = _ws->xLeft = 0;
+ if (xLeft < 0)
+ xLeft = _ws->xLeft = 0;
- if (newXLeft > _ws->width - 640)
- newXLeft = _ws->xLeft = _ws->width - 640;
+ if (xLeft > (_ws->width - 640))
+ xLeft = _ws->xLeft = _ws->width - 640;
- if (newYTop < 0)
- newYTop = _ws->yTop = 0;
+ if (yTop < 0)
+ yTop = _ws->yTop = 0;
- if (newYTop > _ws->height - 480)
- newYTop = _ws->yTop = _ws->height - 480;
- } else {
- // TODO
+ if (yTop > (_ws->height - 480))
+ yTop = _ws->yTop = _ws->height - 480;
+
+ break;
+
+ case 2:
+ case 5: {
+ getSharedData()->sceneOffset += getSharedData()->sceneOffsetAdd;
+
+ int32 coord1 = 0;
+ int32 coord2 = 0;
+
+ if (abs(getSharedData()->sceneXLeft - _ws->coordinates[0]) <= abs(getSharedData()->sceneYTop - _ws->coordinates[1])) {
+ coord1 = _ws->coordinates[1];
+ coord2 = yTop;
+
+ if (_ws->coordinates[1] != _ws->yTop)
+ xLeft = _ws->xLeft = getSharedData()->sceneOffset + getSharedData()->sceneXLeft;
+
+ yTop = _ws->coordinates[2] + _ws->yTop;
+ _ws->yTop += _ws->coordinates[2];
+
+ } else {
+ coord1 = _ws->coordinates[0];
+ coord2 = xLeft;
+
+ if (_ws->coordinates[0] != _ws->xLeft)
+ yTop = _ws->yTop = getSharedData()->sceneOffset + getSharedData()->sceneYTop;
+
+ xLeft = _ws->coordinates[2] + _ws->xLeft;
+ _ws->xLeft += _ws->coordinates[2];
+ }
+
+ if (abs(coord2 - coord1) <= abs(_ws->coordinates[2])) {
+ _ws->motionStatus = 3;
+ _ws->coordinates[0] = -1;
+ }
+
+ }
+ break;
}
- uint8 rectIndex = _ws->sceneRectIdx;
- b = _ws->sceneRects[rectIndex];
+ // Update scene coordinates
+ Common::Rect sceneRect = _ws->sceneRects[_ws->sceneRectIdx];
+
+ if (xLeft < sceneRect.left)
+ xLeft =_ws->xLeft =sceneRect.left;
- if (newXLeft < b.left)
- newXLeft = _ws->xLeft = b.left;
+ if (yTop < sceneRect.top)
+ yTop = _ws->yTop = sceneRect.top;
- if (newYTop < b.top)
- newYTop = _ws->yTop = b.top;
+ if ((xLeft + 639) > sceneRect.right)
+ xLeft = _ws->xLeft = sceneRect.right - 639;
- if (newXLeft + 639 > b.right)
- newXLeft = _ws->xLeft = b.right - 639;
+ if ((yTop + 479) > sceneRect.bottom)
+ yTop = _ws->yTop = sceneRect.bottom - 479;
- if (newYTop + 479 > b.bottom)
- newYTop = _ws->yTop = b.bottom - 479;
+ // TODO set a var if scene coordinates changed
}
void Scene::updateCursor(ActorDirection direction, Common::Rect rect) {
@@ -1917,9 +1962,9 @@ bool Scene::updateSceneCoordinates(int32 tX, int32 tY, int32 A0, bool checkScene
*targetY = _ws->height - 480;
// Adjust scene offsets & coordinates
- getSharedData()->setSceneOffset(0);
- getSharedData()->setSceneXLeft(_ws->xLeft);
- getSharedData()->setSceneYTop(_ws->yTop);
+ getSharedData()->sceneOffset = 0;
+ getSharedData()->sceneXLeft = _ws->xLeft;
+ getSharedData()->sceneYTop = _ws->yTop;
int32 diffX = *targetX - _ws->xLeft;
int32 diffY = *targetY - _ws->yTop;
@@ -1928,7 +1973,7 @@ bool Scene::updateSceneCoordinates(int32 tX, int32 tY, int32 A0, bool checkScene
if (_ws->yTop > *targetY)
*coord3 = -*coord3;
- getSharedData()->setSceneOffsetAdd(Common::Rational(*coord3, diffY) * diffX);
+ getSharedData()->sceneOffsetAdd =Common::Rational(*coord3 * diffX, diffY).toInt();
if (param != NULL && abs(diffY) <= abs(*coord3)) {
*targetX = -1;
@@ -1939,7 +1984,7 @@ bool Scene::updateSceneCoordinates(int32 tX, int32 tY, int32 A0, bool checkScene
if (_ws->xLeft > *targetX)
*coord3 = -*coord3;
- getSharedData()->setSceneOffsetAdd(Common::Rational(*coord3, diffX) * diffY);
+ getSharedData()->sceneOffsetAdd = Common::Rational(*coord3 * diffY, diffX).toInt();
if (param != NULL && abs(diffX) <= abs(*coord3)) {
*targetX = -1;
Commit: 318aaf1997fafcf7fb6ea3ec6d8ec2f5fd48388b
https://github.com/scummvm/scummvm/commit/318aaf1997fafcf7fb6ea3ec6d8ec2f5fd48388b
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:34+02:00
Commit Message:
ASYLUM: Add stub for screenshot function in Screen class
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@649 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/system/screen.cpp
engines/asylum/system/screen.h
engines/asylum/views/scene.cpp
diff --git a/engines/asylum/system/screen.cpp b/engines/asylum/system/screen.cpp
index 39a37bac38..f914807639 100644
--- a/engines/asylum/system/screen.cpp
+++ b/engines/asylum/system/screen.cpp
@@ -183,6 +183,10 @@ void Screen::clip(Common::Rect *source, Common::Rect *destination, int32 flags)
}
}
+void Screen::takeScreenshot() {
+ warning("[Screen::takeScreenshot] Screenshot function not implemented!");
+}
+
//////////////////////////////////////////////////////////////////////////
// Palette
//////////////////////////////////////////////////////////////////////////
diff --git a/engines/asylum/system/screen.h b/engines/asylum/system/screen.h
index b351c12590..6e88082361 100644
--- a/engines/asylum/system/screen.h
+++ b/engines/asylum/system/screen.h
@@ -84,6 +84,7 @@ public:
void fillRect(int32 x, int32 y, int32 x2, int32 y2, int32 color);
void copyBackBufferToScreen();
void setFlag(int32 val) { _flag = (val < -1) ? -1 : val; }
+ void takeScreenshot();
// Palette
void setPalette(byte *rgbPalette) const;
diff --git a/engines/asylum/views/scene.cpp b/engines/asylum/views/scene.cpp
index 82e45ef402..5c569630a2 100644
--- a/engines/asylum/views/scene.cpp
+++ b/engines/asylum/views/scene.cpp
@@ -500,7 +500,7 @@ bool Scene::key(const AsylumEvent &evt) {
break;
case Common::KEYCODE_TAB:
- warning("[Scene::key] Screenshot function not implemented!");
+ getScreen()->takeScreenshot();
break;
}
Commit: 9057e1e6fcc121e82c498c7b4979c3f1dff91e3f
https://github.com/scummvm/scummvm/commit/9057e1e6fcc121e82c498c7b4979c3f1dff91e3f
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:34+02:00
Commit Message:
ASYLUM: Implement Encounter::key()
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@650 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/resources/encounters.cpp
engines/asylum/system/speech.h
diff --git a/engines/asylum/resources/encounters.cpp b/engines/asylum/resources/encounters.cpp
index ffcd0cf2cc..c85c30366f 100644
--- a/engines/asylum/resources/encounters.cpp
+++ b/engines/asylum/resources/encounters.cpp
@@ -324,7 +324,24 @@ bool Encounter::update() {
}
bool Encounter::key(const AsylumEvent &evt) {
- error("[Encounter::key] Not implemented!");
+ switch (evt.kbd.keycode) {
+ default:
+ break;
+
+ case Common::KEYCODE_TAB:
+ getScreen()->takeScreenshot();
+ break;
+
+ case Common::KEYCODE_ESCAPE:
+ if (!isSpeaking()
+ && _data_455BD0
+ && !getSpeech()->getTextData()
+ && !getSpeech()->getTextDataPos())
+ _data_455BD4 = 1;
+ break;
+ }
+
+ return true;
}
bool Encounter::mouse(const AsylumEvent &evt) {
diff --git a/engines/asylum/system/speech.h b/engines/asylum/system/speech.h
index e1efb5cb9c..99925e87c7 100644
--- a/engines/asylum/system/speech.h
+++ b/engines/asylum/system/speech.h
@@ -140,6 +140,13 @@ public:
*/
void setTextData(char *text) { _textData = text; }
+ /**
+ * Get text data
+ *
+ * @return the text data
+ */
+ char *getTextData() { return _textData; }
+
/**
* Sets text data position.
*
@@ -147,6 +154,13 @@ public:
*/
void setTextDataPos(char *text) { _textDataPos = text; }
+ /**
+ * Get text data position
+ *
+ * @return the text data position
+ */
+ char *getTextDataPos() { return _textDataPos; }
+
private:
AsylumEngine *_vm;
@@ -162,7 +176,7 @@ private:
*/
void process();
-}; // end of class Speech
+};
} // end of namespace Asylum
Commit: e3870d830c4a5d3ce88e14a8e89fd2f06b40221a
https://github.com/scummvm/scummvm/commit/e3870d830c4a5d3ce88e14a8e89fd2f06b40221a
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:34+02:00
Commit Message:
ASYLUM: Implement Encounter::mouse()
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@651 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/resources/encounters.cpp
engines/asylum/resources/encounters.h
diff --git a/engines/asylum/resources/encounters.cpp b/engines/asylum/resources/encounters.cpp
index c85c30366f..ac62c259d0 100644
--- a/engines/asylum/resources/encounters.cpp
+++ b/engines/asylum/resources/encounters.cpp
@@ -193,13 +193,19 @@ void Encounter::initDrawStructs() {
}
}
-uint32 Encounter::findKeyword(EncounterItem *item, int16 keyword) {
- for (uint i = 0; i < ARRAYSIZE(item->keywords); i++) {
- if ((item->keywords[i] & KEYWORD_MASK) == keyword)
- return i;
- }
+//////////////////////////////////////////////////////////////////////////
+// Misc
+//////////////////////////////////////////////////////////////////////////
+int32 Encounter::findRect() {
+ error("[Encounter::findRect] not implemented!");
+}
- error("[Encounter::findKeyword] Could not find a valid keyword!");
+void Encounter::updateDrawingStatus1(int32 rectIndex) {
+ error("[Encounter::updateDrawingStatus1] not implemented!");
+}
+
+void Encounter::updateDrawingStatus2(int32 rectIndex) {
+ error("[Encounter::updateDrawingStatus2] not implemented!");
}
//////////////////////////////////////////////////////////////////////////
@@ -345,7 +351,44 @@ bool Encounter::key(const AsylumEvent &evt) {
}
bool Encounter::mouse(const AsylumEvent &evt) {
- error("[Encounter::mouse] Not implemented!");
+ switch (evt.type) {
+ default:
+ break;
+
+ case Common::EVENT_LBUTTONDOWN:
+ if (!_data_455BD8) {
+ _data_455BD8 = 1;
+ _rectIndex = findRect();
+
+ if (_rectIndex != -1)
+ updateDrawingStatus2(_rectIndex);
+ }
+ break;
+
+ case Common::EVENT_LBUTTONUP:
+ if (_rectIndex == -1) {
+ if (!isSpeaking())
+ choose(getKeywordIndex());
+
+ _data_455BD8 = 0;
+ } else {
+ _rectIndex = -1;
+ updateDrawingStatus1(_rectIndex);
+ _data_455BD8 = 0;
+ }
+ break;
+
+
+ case Common::EVENT_RBUTTONDOWN:
+ if (!isSpeaking()
+ && _data_455BD0
+ && !getSpeech()->getTextData()
+ && !getSpeech()->getTextDataPos())
+ _data_455BD4 = 1;
+ break;
+ }
+
+ return true;
}
//////////////////////////////////////////////////////////////////////////
@@ -364,6 +407,7 @@ int32 Encounter::getVariable(uint32 index) {
return _variables[index];
}
+
int32 Encounter::getVariableInv(int32 index) {
if (index >= 0)
return index;
@@ -371,6 +415,26 @@ int32 Encounter::getVariableInv(int32 index) {
return getVariable(-index);
}
+//////////////////////////////////////////////////////////////////////////
+// Actions
+//////////////////////////////////////////////////////////////////////////
+uint32 Encounter::findKeyword(EncounterItem *item, int16 keyword) {
+ for (uint i = 0; i < ARRAYSIZE(item->keywords); i++) {
+ if ((item->keywords[i] & KEYWORD_MASK) == keyword)
+ return i;
+ }
+
+ error("[Encounter::findKeyword] Could not find a valid keyword!");
+}
+
+int32 Encounter::getKeywordIndex() {
+ error("[Encounter::getKeywordIndex] Not implemented!");
+}
+
+void Encounter::choose(int32 keywordIndex) {
+ error("[Encounter::choose] Not implemented!");
+}
+
//////////////////////////////////////////////////////////////////////////
// Speech
//////////////////////////////////////////////////////////////////////////
diff --git a/engines/asylum/resources/encounters.h b/engines/asylum/resources/encounters.h
index 50e5b4d0d4..76e168473a 100644
--- a/engines/asylum/resources/encounters.h
+++ b/engines/asylum/resources/encounters.h
@@ -166,7 +166,11 @@ private:
void initPortraits();
void initDrawStructs();
- uint32 findKeyword(EncounterItem *item, int16 keyword);
+ //////////////////////////////////////////////////////////////////////////
+ // Misc
+ int32 findRect();
+ void updateDrawingStatus1(int32 rectIndex);
+ void updateDrawingStatus2(int32 rectIndex);
//////////////////////////////////////////////////////////////////////////
// Message handling
@@ -181,6 +185,13 @@ private:
int32 getVariable(uint32 index);
int32 getVariableInv(int32 index);
+ /////////////////////////////////////////////////////////////////////////
+ // Actions
+ uint32 findKeyword(EncounterItem *item, int16 keyword);
+ int32 getKeywordIndex();
+ void choose(int32 keywordIndex);
+
+
//////////////////////////////////////////////////////////////////////////
// Speech
void resetSpeech(uint32 a1, uint32 a2);
@@ -238,7 +249,7 @@ private:
void runScript();
friend class Console;
-}; // end of class Encounter
+};
} // end of namespace Asylum
Commit: 361b11728334d62aa30e68c9c18b3b3313d4d088
https://github.com/scummvm/scummvm/commit/361b11728334d62aa30e68c9c18b3b3313d4d088
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:34+02:00
Commit Message:
ASYLUM: Implement Encounter::update()
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@652 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/console.cpp
engines/asylum/resources/encounters.cpp
engines/asylum/resources/encounters.h
engines/asylum/system/speech.h
engines/asylum/views/scene.cpp
diff --git a/engines/asylum/console.cpp b/engines/asylum/console.cpp
index 6796738839..9979b43234 100644
--- a/engines/asylum/console.cpp
+++ b/engines/asylum/console.cpp
@@ -384,6 +384,7 @@ bool Console::cmdRunEncounter(int32 argc, const char **argv) {
return true;
}
+ // Line: 12/15 :: 0x25 (1, 1584, 1584, 0, 0, 0, 0, 0, 0) // First Encounter
// TODO update with array of valid objects
_vm->encounter()->run(index, kObjectNone, kObjectNone, kActorMax);
diff --git a/engines/asylum/resources/encounters.cpp b/engines/asylum/resources/encounters.cpp
index ac62c259d0..ea1beaabb9 100644
--- a/engines/asylum/resources/encounters.cpp
+++ b/engines/asylum/resources/encounters.cpp
@@ -208,11 +208,18 @@ void Encounter::updateDrawingStatus2(int32 rectIndex) {
error("[Encounter::updateDrawingStatus2] not implemented!");
}
+bool Encounter::updateScreen() {
+ error("[Encounter::updateScreen] not implemented!");
+}
+
+void Encounter::drawScreen() {
+ error("[Encounter::updateScreen] not implemented!");
+}
+
//////////////////////////////////////////////////////////////////////////
// Run
//////////////////////////////////////////////////////////////////////////
void Encounter::run(int32 encounterIndex, ObjectId objectId1, ObjectId objectId2, ActorIndex actorIndex) {
- // Line: 12/15 :: 0x25 (1, 1584, 1584, 0, 0, 0, 0, 0, 0) // First Encounter
debugC(kDebugLevelEncounter, "Running Encounter %d", encounterIndex);
if (!_keywordIndex) {
@@ -326,7 +333,96 @@ bool Encounter::update() {
if (getSound()->getMusicVolume() != Config.musicVolume - 500)
getSound()->setMusicVolume(Config.musicVolume - 500);
- error("[Encounter::update] Not implemented!");
+ uint32 tick = _vm->getTick();
+ ResourceId id = kResourceNone;
+
+ if (_objectId3) {
+ _data_455BD0 = 0;
+
+ Object *object = getWorld()->getObjectById(_objectId3);
+ id = object->getResourceId();
+
+ if (object->getFrameIndex() == object->getFrameCount() - 1) {
+ switch (getVariable(3)) {
+ default:
+ break;
+
+ case 13:
+ if (_actorIndex)
+ getScene()->getActor(_actorIndex)->show();
+ else
+ setupEntities(true);
+ break;
+
+ case 14:
+ getScene()->getActor()->show();
+ break;
+
+ case 15:
+ if (_actorIndex)
+ getScene()->getActor(_actorIndex)->show();
+ else
+ setupEntities(true);
+
+ getScene()->getActor()->show();
+ break;
+ }
+
+ object->disable();
+ _objectId3 = kObjectNone;
+ _data_455BF4 = 0;
+ getCursor()->show();
+ }
+ }
+
+ if (_data_455BE8) {
+ if (getSharedData()->getMatteBarHeight()) {
+ _data_455BD0 = 0;
+ } else {
+ getCursor()->show();
+ _data_455BE8 = 0;
+ _data_455BF4 = 0;
+ }
+ }
+
+ if (_data_455BD0) {
+ if (_data_455BF4 == 1) {
+ _data_455BF4 = 2;
+ runScript();
+ }
+ bool doScript;
+ if ((getSpeech()->getSoundResourceId()
+ && !getSound()->isPlaying(getSpeech()->getSoundResourceId())
+ && !_data_455BE0)
+ || (getSpeech()->getTick() && tick >= getSpeech()->getTick()))
+ doScript = true;
+
+ if (!getSharedData()->getMatteBarHeight() && doScript && _flag4) {
+ if (!setupSpeech(id))
+ runScript();
+ }
+ }
+
+ // Redraw screen
+ if (!getSharedData()->getFlag(kFlagRedraw)) {
+ if (updateScreen())
+ return true;
+
+ getSharedData()->setFlag(kFlagRedraw, true);
+ }
+
+ if (tick >= getSharedData()->getNextScreenUpdate() && getSharedData()->getFlag(kFlagRedraw)) {
+ if (getSharedData()->getMatteBarHeight() <= 0) {
+ getScreen()->copyBackBufferToScreen();
+ } else {
+ drawScreen();
+ }
+
+ getSharedData()->setFlag(kFlagRedraw, false);
+ getSharedData()->setNextScreenUpdate(tick + 55);
+ }
+
+ return true;
}
bool Encounter::key(const AsylumEvent &evt) {
@@ -535,6 +631,10 @@ void Encounter::setupSpeech(ResourceId textResourceId, ResourceId fontResourceId
getSpeech()->setSoundResourceId(MAKE_RESOURCE(kResourcePackSharedSound, textResourceId - _keywordIndex));
}
+bool Encounter::setupSpeech(ResourceId id) {
+ error("[Encounter::setupSpeech] Not implemented!");
+}
+
bool Encounter::isSpeaking() {
if (!_flag4)
return false;
diff --git a/engines/asylum/resources/encounters.h b/engines/asylum/resources/encounters.h
index 76e168473a..67a015a91a 100644
--- a/engines/asylum/resources/encounters.h
+++ b/engines/asylum/resources/encounters.h
@@ -45,6 +45,8 @@ public:
bool handleEvent(const AsylumEvent &evt);
+ void drawScreen();
+
void setFlag1(bool state) { _flag1 = state; }
bool getFlag1() { return _flag1; }
void setFlag3(bool state) { _flag3 = state; }
@@ -171,6 +173,7 @@ private:
int32 findRect();
void updateDrawingStatus1(int32 rectIndex);
void updateDrawingStatus2(int32 rectIndex);
+ bool updateScreen();
//////////////////////////////////////////////////////////////////////////
// Message handling
@@ -191,7 +194,6 @@ private:
int32 getKeywordIndex();
void choose(int32 keywordIndex);
-
//////////////////////////////////////////////////////////////////////////
// Speech
void resetSpeech(uint32 a1, uint32 a2);
@@ -199,6 +201,7 @@ private:
void setupSpeechText();
void setupSpeechData(char val, EncounterGraphic *encounterGraphic);
void setupSpeech(ResourceId textResourceId, ResourceId fontResourceId);
+ bool setupSpeech(ResourceId id);
bool isSpeaking();
//////////////////////////////////////////////////////////////////////////
diff --git a/engines/asylum/system/speech.h b/engines/asylum/system/speech.h
index 99925e87c7..2065c688da 100644
--- a/engines/asylum/system/speech.h
+++ b/engines/asylum/system/speech.h
@@ -110,7 +110,7 @@ public:
*
* @return The tick.
*/
- int32 getTick() { return _tick; }
+ uint32 getTick() { return _tick; }
/**
* Sets the sound resource identifier
diff --git a/engines/asylum/views/scene.cpp b/engines/asylum/views/scene.cpp
index 5c569630a2..5afa5e7324 100644
--- a/engines/asylum/views/scene.cpp
+++ b/engines/asylum/views/scene.cpp
@@ -386,7 +386,7 @@ bool Scene::update() {
if (getSharedData()->getMatteBarHeight() <= 0)
getScreen()->copyBackBufferToScreen();
else
- error("[Scene::update] Not implemented!");
+ getEncounter()->drawScreen();
// Original also sets an unused value to 0
getSharedData()->setData(39, getSharedData()->getData(39) ^ 1);
Commit: c01a3f39e70f5869179aa73b3d9e20cf7c798a4c
https://github.com/scummvm/scummvm/commit/c01a3f39e70f5869179aa73b3d9e20cf7c798a4c
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:35+02:00
Commit Message:
ASYLUM: Implement Encounter function findRect(), updateDrawingStatus1() and updateDrawingStatus2()
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@653 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/resources/encounters.cpp
engines/asylum/resources/encounters.h
diff --git a/engines/asylum/resources/encounters.cpp b/engines/asylum/resources/encounters.cpp
index ea1beaabb9..48d98760a2 100644
--- a/engines/asylum/resources/encounters.cpp
+++ b/engines/asylum/resources/encounters.cpp
@@ -197,15 +197,65 @@ void Encounter::initDrawStructs() {
// Misc
//////////////////////////////////////////////////////////////////////////
int32 Encounter::findRect() {
- error("[Encounter::findRect] not implemented!");
+ Common::Point mousePos = getCursor()->position();
+
+ for (uint32 i = 0; i < ARRAYSIZE(_drawingStructs); i++) {
+ EncounterDrawingStruct *drawStruct = &_drawingStructs[i];
+
+ if (mousePos.x >= drawStruct->point2.x
+ && mousePos.x < (drawStruct->point2.x + drawStruct->point1.y)
+ && mousePos.y >= drawStruct->point2.y
+ && mousePos.y < (drawStruct->point2.y + drawStruct->point1.x))
+ return i;
+ }
+
+ return -1;
}
void Encounter::updateDrawingStatus1(int32 rectIndex) {
- error("[Encounter::updateDrawingStatus1] not implemented!");
+ switch (rectIndex) {
+ default:
+ error("[Encounter::updateDrawingStatus1] Invalid rect index (%d)", rectIndex);
+ break;
+
+ case 0:
+ if (checkKeywords2()) {
+ _drawingStructs[rectIndex].status = 1;
+ ++_drawingStructs[rectIndex].transTableNum;
+ }
+ break;
+
+ case 1:
+ if (checkKeywords()) {
+ _drawingStructs[rectIndex].status = 1;
+ ++_drawingStructs[rectIndex].transTableNum;
+ }
+ break;
+ }
}
void Encounter::updateDrawingStatus2(int32 rectIndex) {
- error("[Encounter::updateDrawingStatus2] not implemented!");
+ switch (rectIndex) {
+ default:
+ error("[Encounter::updateDrawingStatus1] Invalid rect index (%d)", rectIndex);
+ break;
+
+ case 0:
+ if (checkKeywords2()) {
+ _drawingStructs[rectIndex].status = 2;
+ --_drawingStructs[rectIndex].transTableNum;
+ updateFromRect(rectIndex);
+ }
+ break;
+
+ case 1:
+ if (checkKeywords()) {
+ _drawingStructs[rectIndex].status = 2;
+ --_drawingStructs[rectIndex].transTableNum;
+ updateFromRect(rectIndex);
+ }
+ break;
+ }
}
bool Encounter::updateScreen() {
@@ -531,6 +581,18 @@ void Encounter::choose(int32 keywordIndex) {
error("[Encounter::choose] Not implemented!");
}
+bool Encounter::checkKeywords() {
+ error("[Encounter::checkKeywords] Not implemented!");
+}
+
+bool Encounter::checkKeywords2() {
+ error("[Encounter::checkKeywords2] Not implemented!");
+}
+
+void Encounter::updateFromRect(int32 rectIndex) {
+ error("[Encounter::updateFromRect] Not implemented!");
+}
+
//////////////////////////////////////////////////////////////////////////
// Speech
//////////////////////////////////////////////////////////////////////////
diff --git a/engines/asylum/resources/encounters.h b/engines/asylum/resources/encounters.h
index 67a015a91a..1339add2fb 100644
--- a/engines/asylum/resources/encounters.h
+++ b/engines/asylum/resources/encounters.h
@@ -193,6 +193,9 @@ private:
uint32 findKeyword(EncounterItem *item, int16 keyword);
int32 getKeywordIndex();
void choose(int32 keywordIndex);
+ bool checkKeywords();
+ bool checkKeywords2();
+ void updateFromRect(int32 rectIndex);
//////////////////////////////////////////////////////////////////////////
// Speech
Commit: 3c56473752d5e168d3b1dd1f3d876e95353fd118
https://github.com/scummvm/scummvm/commit/3c56473752d5e168d3b1dd1f3d876e95353fd118
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:35+02:00
Commit Message:
ASYLUM: Implement Encounter::updateScreen()
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@654 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/resources/encounters.cpp
engines/asylum/resources/encounters.h
engines/asylum/views/scene.h
diff --git a/engines/asylum/resources/encounters.cpp b/engines/asylum/resources/encounters.cpp
index 48d98760a2..413fc7e9c8 100644
--- a/engines/asylum/resources/encounters.cpp
+++ b/engines/asylum/resources/encounters.cpp
@@ -193,79 +193,6 @@ void Encounter::initDrawStructs() {
}
}
-//////////////////////////////////////////////////////////////////////////
-// Misc
-//////////////////////////////////////////////////////////////////////////
-int32 Encounter::findRect() {
- Common::Point mousePos = getCursor()->position();
-
- for (uint32 i = 0; i < ARRAYSIZE(_drawingStructs); i++) {
- EncounterDrawingStruct *drawStruct = &_drawingStructs[i];
-
- if (mousePos.x >= drawStruct->point2.x
- && mousePos.x < (drawStruct->point2.x + drawStruct->point1.y)
- && mousePos.y >= drawStruct->point2.y
- && mousePos.y < (drawStruct->point2.y + drawStruct->point1.x))
- return i;
- }
-
- return -1;
-}
-
-void Encounter::updateDrawingStatus1(int32 rectIndex) {
- switch (rectIndex) {
- default:
- error("[Encounter::updateDrawingStatus1] Invalid rect index (%d)", rectIndex);
- break;
-
- case 0:
- if (checkKeywords2()) {
- _drawingStructs[rectIndex].status = 1;
- ++_drawingStructs[rectIndex].transTableNum;
- }
- break;
-
- case 1:
- if (checkKeywords()) {
- _drawingStructs[rectIndex].status = 1;
- ++_drawingStructs[rectIndex].transTableNum;
- }
- break;
- }
-}
-
-void Encounter::updateDrawingStatus2(int32 rectIndex) {
- switch (rectIndex) {
- default:
- error("[Encounter::updateDrawingStatus1] Invalid rect index (%d)", rectIndex);
- break;
-
- case 0:
- if (checkKeywords2()) {
- _drawingStructs[rectIndex].status = 2;
- --_drawingStructs[rectIndex].transTableNum;
- updateFromRect(rectIndex);
- }
- break;
-
- case 1:
- if (checkKeywords()) {
- _drawingStructs[rectIndex].status = 2;
- --_drawingStructs[rectIndex].transTableNum;
- updateFromRect(rectIndex);
- }
- break;
- }
-}
-
-bool Encounter::updateScreen() {
- error("[Encounter::updateScreen] not implemented!");
-}
-
-void Encounter::drawScreen() {
- error("[Encounter::updateScreen] not implemented!");
-}
-
//////////////////////////////////////////////////////////////////////////
// Run
//////////////////////////////////////////////////////////////////////////
@@ -577,7 +504,10 @@ int32 Encounter::getKeywordIndex() {
error("[Encounter::getKeywordIndex] Not implemented!");
}
-void Encounter::choose(int32 keywordIndex) {
+void Encounter::choose(int32 index) {
+ if (_flag4 || index == -1)
+ return;
+
error("[Encounter::choose] Not implemented!");
}
@@ -714,8 +644,36 @@ bool Encounter::isSpeaking() {
return false;
}
+
//////////////////////////////////////////////////////////////////////////
-// Actor & Object
+// Drawing
+//////////////////////////////////////////////////////////////////////////
+bool Encounter::drawBackground() {
+ error("[Encounter::drawBackground] not implemented!");
+}
+
+bool Encounter::drawPortraits() {
+ error("[Encounter::drawPortraits] not implemented!");
+}
+
+void Encounter::drawStructs() {
+ error("[Encounter::drawStructs] not implemented!");
+}
+
+void Encounter::drawDialog() {
+ error("[Encounter::drawDialog] not implemented!");
+}
+
+void Encounter::drawText(char *text, ResourceId font, int32 y) {
+ error("[Encounter::drawText] not implemented!");
+}
+
+void Encounter::drawScreen() {
+ error("[Encounter::drawScreen] not implemented!");
+}
+
+//////////////////////////////////////////////////////////////////////////
+// Misc
//////////////////////////////////////////////////////////////////////////
void Encounter::setupEntities(bool type4) {
// Actor
@@ -769,6 +727,133 @@ void Encounter::setupEntities(bool type4) {
}
}
+int32 Encounter::findRect() {
+ Common::Point mousePos = getCursor()->position();
+
+ for (uint32 i = 0; i < ARRAYSIZE(_drawingStructs); i++) {
+ EncounterDrawingStruct *drawStruct = &_drawingStructs[i];
+
+ if (mousePos.x >= drawStruct->point2.x
+ && mousePos.x < (drawStruct->point2.x + drawStruct->point1.y)
+ && mousePos.y >= drawStruct->point2.y
+ && mousePos.y < (drawStruct->point2.y + drawStruct->point1.x))
+ return i;
+ }
+
+ return -1;
+}
+
+void Encounter::updateDrawingStatus() {
+ error("[Encounter::updateDrawingStatus] not implemented!");
+}
+
+void Encounter::updateDrawingStatus1(int32 rectIndex) {
+ switch (rectIndex) {
+ default:
+ error("[Encounter::updateDrawingStatus1] Invalid rect index (%d)", rectIndex);
+ break;
+
+ case 0:
+ if (checkKeywords2()) {
+ _drawingStructs[rectIndex].status = 1;
+ ++_drawingStructs[rectIndex].transTableNum;
+ }
+ break;
+
+ case 1:
+ if (checkKeywords()) {
+ _drawingStructs[rectIndex].status = 1;
+ ++_drawingStructs[rectIndex].transTableNum;
+ }
+ break;
+ }
+}
+
+void Encounter::updateDrawingStatus2(int32 rectIndex) {
+ switch (rectIndex) {
+ default:
+ error("[Encounter::updateDrawingStatus1] Invalid rect index (%d)", rectIndex);
+ break;
+
+ case 0:
+ if (checkKeywords2()) {
+ _drawingStructs[rectIndex].status = 2;
+ --_drawingStructs[rectIndex].transTableNum;
+ updateFromRect(rectIndex);
+ }
+ break;
+
+ case 1:
+ if (checkKeywords()) {
+ _drawingStructs[rectIndex].status = 2;
+ --_drawingStructs[rectIndex].transTableNum;
+ updateFromRect(rectIndex);
+ }
+ break;
+ }
+}
+
+bool Encounter::updateScreen() {
+ if (getScene()->updateScreen())
+ return true;
+
+ getText()->loadFont(getWorld()->font1);
+
+ if (!drawBackground()) {
+ _data_455BD0 = 0;
+ return false;
+ }
+
+ if (!drawPortraits()) {
+ _data_455BD0 = 0;
+
+ if (_data_455BD4)
+ drawStructs();
+
+ return false;
+ }
+
+ if (_data_455BD0) {
+
+ if (!getSpeech()->getTextDataPos() && !getSpeech()->getTextData()) {
+
+ drawDialog();
+ updateDrawingStatus();
+ drawStructs();
+
+ if (_rectIndex == -1 && findRect() == -1)
+ updateFromRect(-1);
+
+ return false;
+ }
+
+ drawText(getSpeech()->getTextDataPos(), getWorld()->font3, _point.y);
+ drawText(getSpeech()->getTextData(), getWorld()->font1, _point.y);
+
+ if (_data_455BE0) {
+ _data_455BE0 = 0;
+
+ // Check resources
+ if (!_data_455BDC && !_objectId1 && !_objectId2 && !_actorIndex)
+ error("[Encounter::updateScreen] Invalid encounter resources!");
+
+ getSound()->playSound(getSpeech()->getSoundResourceId(), false, Config.voiceVolume);
+ }
+
+ return false;
+ }
+
+ if (_objectId3 || _data_455BE8)
+ return false;
+
+ if (_data_455BF4)
+ _data_455BF4 = 1;
+
+ _data_455BD0 = 1;
+
+ return false;
+}
+
//////////////////////////////////////////////////////////////////////////
// Scripts
//////////////////////////////////////////////////////////////////////////
diff --git a/engines/asylum/resources/encounters.h b/engines/asylum/resources/encounters.h
index 1339add2fb..306968ad5c 100644
--- a/engines/asylum/resources/encounters.h
+++ b/engines/asylum/resources/encounters.h
@@ -168,13 +168,6 @@ private:
void initPortraits();
void initDrawStructs();
- //////////////////////////////////////////////////////////////////////////
- // Misc
- int32 findRect();
- void updateDrawingStatus1(int32 rectIndex);
- void updateDrawingStatus2(int32 rectIndex);
- bool updateScreen();
-
//////////////////////////////////////////////////////////////////////////
// Message handling
bool init();
@@ -208,8 +201,21 @@ private:
bool isSpeaking();
//////////////////////////////////////////////////////////////////////////
- // Actor & Object
+ // Drawing
+ bool drawBackground();
+ bool drawPortraits();
+ void drawStructs();
+ void drawDialog();
+ void drawText(char *text, ResourceId font, int32 y);
+
+ //////////////////////////////////////////////////////////////////////////
+ // Misc
void setupEntities(bool type4);
+ int32 findRect();
+ void updateDrawingStatus();
+ void updateDrawingStatus1(int32 rectIndex);
+ void updateDrawingStatus2(int32 rectIndex);
+ bool updateScreen();
//////////////////////////////////////////////////////////////////////////
// Scripts
diff --git a/engines/asylum/views/scene.h b/engines/asylum/views/scene.h
index b96b68a73d..df1d0062e6 100644
--- a/engines/asylum/views/scene.h
+++ b/engines/asylum/views/scene.h
@@ -159,6 +159,13 @@ public:
*/
bool updateSceneCoordinates(int32 targetX, int32 targetY, int32 val, bool checkSceneCoords = false, int32 *param = NULL);
+ /**
+ * Updates the screen
+ *
+ * @return true if it succeeds, false if it fails.
+ */
+ bool updateScreen();
+
/**
* Determine if the supplied point intersects an action area's active region.
*
@@ -199,13 +206,6 @@ private:
// Scene update
//////////////////////////////////////////////////////////////////////////
- /**
- * Updates the screen
- *
- * @return true if it succeeds, false if it fails.
- */
- bool updateScreen();
-
/**
* Loop through the various update blocks (actors, objects, mouse, music, sfx, coordinates), then process the current action script.
*
Commit: b8e6b28f8f92675e8d8a58f6cff81702e77e4a26
https://github.com/scummvm/scummvm/commit/b8e6b28f8f92675e8d8a58f6cff81702e77e4a26
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:35+02:00
Commit Message:
ASYLUM: Implement Encounter::updateDrawingStatus() and Encounter::setupSpeech()
- Properly set boolean values as true/false instead of 1/0
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@655 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/resources/encounters.cpp
diff --git a/engines/asylum/resources/encounters.cpp b/engines/asylum/resources/encounters.cpp
index 413fc7e9c8..7e7f2e6a1b 100644
--- a/engines/asylum/resources/encounters.cpp
+++ b/engines/asylum/resources/encounters.cpp
@@ -273,17 +273,17 @@ bool Encounter::init() {
if (!getSharedData()->getMatteBarHeight()) {
_flag6 = true;
- _data_455BD4 = 0;
- _data_455BD8 = 0;
- _data_455BDC = 0;
- _data_455BE0 = 0;
- _data_455BE4 = 0;
- _data_455BCC = 0;
- _data_455B3C = 1;
+ _data_455BD4 = false;
+ _data_455BD8 = false;
+ _data_455BDC = false;
+ _data_455BE0 = false;
+ _data_455BE4 = false;
+ _data_455BCC = false;
+ _data_455B3C = true;
_rectIndex = -1;
_value1 = 0;
_data_455BF4 = 0;
- _data_455BF8 = 0;
+ _data_455BF8 = false;
_data_455B14 = -1;
getSpeech()->resetTextData();
@@ -297,7 +297,7 @@ bool Encounter::init() {
initDrawStructs();
}
- _data_455BD0 = 0;
+ _data_455BD0 = false;
getCursor()->set(getWorld()->cursorResources[kCursorResourceTalkNPC], -1, kCursorAnimationMirror);
if (!getSharedData()->getMatteBarHeight())
@@ -314,7 +314,7 @@ bool Encounter::update() {
ResourceId id = kResourceNone;
if (_objectId3) {
- _data_455BD0 = 0;
+ _data_455BD0 = false;
Object *object = getWorld()->getObjectById(_objectId3);
id = object->getResourceId();
@@ -354,10 +354,10 @@ bool Encounter::update() {
if (_data_455BE8) {
if (getSharedData()->getMatteBarHeight()) {
- _data_455BD0 = 0;
+ _data_455BD0 = false;
} else {
getCursor()->show();
- _data_455BE8 = 0;
+ _data_455BE8 = false;
_data_455BF4 = 0;
}
}
@@ -416,7 +416,7 @@ bool Encounter::key(const AsylumEvent &evt) {
&& _data_455BD0
&& !getSpeech()->getTextData()
&& !getSpeech()->getTextDataPos())
- _data_455BD4 = 1;
+ _data_455BD4 = true;
break;
}
@@ -430,7 +430,7 @@ bool Encounter::mouse(const AsylumEvent &evt) {
case Common::EVENT_LBUTTONDOWN:
if (!_data_455BD8) {
- _data_455BD8 = 1;
+ _data_455BD8 = true;
_rectIndex = findRect();
if (_rectIndex != -1)
@@ -443,11 +443,11 @@ bool Encounter::mouse(const AsylumEvent &evt) {
if (!isSpeaking())
choose(getKeywordIndex());
- _data_455BD8 = 0;
+ _data_455BD8 = false;
} else {
_rectIndex = -1;
updateDrawingStatus1(_rectIndex);
- _data_455BD8 = 0;
+ _data_455BD8 = false;
}
break;
@@ -457,7 +457,7 @@ bool Encounter::mouse(const AsylumEvent &evt) {
&& _data_455BD0
&& !getSpeech()->getTextData()
&& !getSpeech()->getTextDataPos())
- _data_455BD4 = 1;
+ _data_455BD4 = true;
break;
}
@@ -530,8 +530,8 @@ void Encounter::resetSpeech(uint32 keywordIndex, uint32 a2) {
getSpeech()->resetTextData();
setupPortraits();
- _data_455BCC = 0;
- _data_455B3C = 0;
+ _data_455BCC = false;
+ _data_455B3C = false;
if (keywordIndex) {
getSpeech()->setTextResourceId(keywordIndex + a2);
@@ -594,8 +594,8 @@ void Encounter::setupSpeechText() {
setupSpeech(getSpeech()->getTextResourceId(), getWorld()->font3);
}
- _data_455BCC = 0;
- _data_455B3C = 1;
+ _data_455BCC = false;
+ _data_455B3C = true;
}
void Encounter::setupSpeech(ResourceId textResourceId, ResourceId fontResourceId) {
@@ -604,11 +604,11 @@ void Encounter::setupSpeech(ResourceId textResourceId, ResourceId fontResourceId
char *text = getText()->get(textResourceId);
if (*text == '{') {
- _data_455BDC = 1;
+ _data_455BDC = true;
setupEntities(true);
setupSpeechData(text[1], &_portrait1);
} else {
- _data_455BDC = 0;
+ _data_455BDC = false;
setupEntities(false);
if (*text == '/') {
char *c = text + 1;
@@ -619,12 +619,35 @@ void Encounter::setupSpeech(ResourceId textResourceId, ResourceId fontResourceId
}
}
- _data_455BE0 = 1;
+ _data_455BE0 = true;
getSpeech()->setSoundResourceId(MAKE_RESOURCE(kResourcePackSharedSound, textResourceId - _keywordIndex));
}
bool Encounter::setupSpeech(ResourceId id) {
- error("[Encounter::setupSpeech] Not implemented!");
+ getSpeech()->setTick(0);
+ getSpeech()->setSoundResourceId(kResourceNone);
+
+ setupEntities(false);
+
+ char *text = getText()->get(id);
+ if (text[strlen(text) - 2] == 1) {
+ setupEntities(true);
+ getSpeech()->setTextResourceId(kResourceNone);
+ getSpeech()->setTextData(0);
+ getSpeech()->setTextDataPos(0);
+
+ _data_455BCC = false;
+ _data_455B3C = true;
+
+ setupPortraits();
+
+ return false;
+ }
+
+ getSpeech()->setTextResourceId(getSpeech()->getTextResourceId() + 1);
+ setupSpeechText();
+
+ return true;
}
bool Encounter::isSpeaking() {
@@ -744,7 +767,33 @@ int32 Encounter::findRect() {
}
void Encounter::updateDrawingStatus() {
- error("[Encounter::updateDrawingStatus] not implemented!");
+ if (checkKeywords2()) {
+ if (_rectIndex) {
+ if (_drawingStructs[0].transTableNum == -1) {
+ _drawingStructs[0].status = 1;
+ _drawingStructs[0].transTableNum = 0;
+ }
+ }
+ } else {
+ if (_drawingStructs[0].transTableNum == 3) {
+ _drawingStructs[0].status = 2;
+ _drawingStructs[0].transTableNum = 2;
+ }
+ }
+
+ if (checkKeywords()) {
+ if (_rectIndex != 1) {
+ if (_drawingStructs[1].transTableNum == -1) {
+ _drawingStructs[1].status = 1;
+ _drawingStructs[1].transTableNum = 0;
+ }
+ }
+ } else {
+ if (_drawingStructs[1].transTableNum == 3) {
+ _drawingStructs[1].status = 2;
+ _drawingStructs[1].transTableNum = 2;
+ }
+ }
}
void Encounter::updateDrawingStatus1(int32 rectIndex) {
@@ -800,12 +849,12 @@ bool Encounter::updateScreen() {
getText()->loadFont(getWorld()->font1);
if (!drawBackground()) {
- _data_455BD0 = 0;
+ _data_455BD0 = false;
return false;
}
if (!drawPortraits()) {
- _data_455BD0 = 0;
+ _data_455BD0 = false;
if (_data_455BD4)
drawStructs();
@@ -831,7 +880,7 @@ bool Encounter::updateScreen() {
drawText(getSpeech()->getTextData(), getWorld()->font1, _point.y);
if (_data_455BE0) {
- _data_455BE0 = 0;
+ _data_455BE0 = false;
// Check resources
if (!_data_455BDC && !_objectId1 && !_objectId2 && !_actorIndex)
@@ -849,7 +898,7 @@ bool Encounter::updateScreen() {
if (_data_455BF4)
_data_455BF4 = 1;
- _data_455BD0 = 1;
+ _data_455BD0 = true;
return false;
}
Commit: c5acdc2a0416723e93d6020e81b973c158c3e342
https://github.com/scummvm/scummvm/commit/c5acdc2a0416723e93d6020e81b973c158c3e342
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:35+02:00
Commit Message:
ASYLUM: Implement Encounter::drawBackground() and Encounter::exit()
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@656 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/resources/encounters.cpp
engines/asylum/resources/encounters.h
diff --git a/engines/asylum/resources/encounters.cpp b/engines/asylum/resources/encounters.cpp
index 7e7f2e6a1b..68e6fa4d30 100644
--- a/engines/asylum/resources/encounters.cpp
+++ b/engines/asylum/resources/encounters.cpp
@@ -209,7 +209,7 @@ void Encounter::run(int32 encounterIndex, ObjectId objectId1, ObjectId objectId2
// Original engine saves the main event handler (to be restored later)
_index = encounterIndex;
- _item = &_items[encounterIndex];
+ _item = &_items[_index];
_objectId1 = objectId1;
_objectId2 = objectId2;
_actorIndex = actorIndex;
@@ -236,6 +236,37 @@ void Encounter::run(int32 encounterIndex, ObjectId objectId1, ObjectId objectId2
_vm->switchEventHandler(this);
}
+void Encounter::exit() {
+ setVariable(1, 32767);
+ initScript(_item->scriptResourceId);
+ _flag3 = true;
+ runScript();
+
+ setupEntities(true);
+
+ ++_item->value;
+ // Original saves the item back here
+
+ // Update flags
+ _flag6 = false;
+ getSharedData()->setFlag(kFlag3, true);
+
+ if (_flag2)
+ _flag2 = false;
+ else
+ _flag1 = true;
+
+ if (_flag5)
+ getScene()->getActor()->updateStatus(kActorStatusDisabled);
+
+ _flag5 = false;
+
+ if (getSound()->getMusicVolume() != Config.musicVolume)
+ getSound()->setMusicVolume(Config.musicVolume);
+
+ _vm->switchEventHandler(getScene());
+}
+
//////////////////////////////////////////////////////////////////////////
// Message handler
//////////////////////////////////////////////////////////////////////////
@@ -672,7 +703,48 @@ bool Encounter::isSpeaking() {
// Drawing
//////////////////////////////////////////////////////////////////////////
bool Encounter::drawBackground() {
- error("[Encounter::drawBackground] not implemented!");
+ if (Config.performance > 1) {
+ if (_vm->isGameFlagSet(kGameFlag528)) {
+ Common::Point origin;
+
+ getScreen()->addGraphicToQueueCrossfade(_background.resourceId,
+ _background.frameIndex,
+ _point,
+ getWorld()->getObjectById((ObjectId)1763)->getResourceId(),
+ origin,
+ _background.transTableNum);
+ } else {
+ Common::Point origin(getWorld()->xLeft, getWorld()->yTop);
+
+ getScreen()->addGraphicToQueueCrossfade(_background.resourceId,
+ _background.frameIndex,
+ _point,
+ getWorld()->backgroundImage,
+ origin,
+ _background.transTableNum);
+ }
+ } else {
+ getScreen()->draw(_background.resourceId, _background.frameIndex, _point.x, _point.y, 0);
+ }
+
+ if (_data_455BE4) {
+ --_background.frameIndex;
+
+ if (_background.frameIndex - 1 < 0) {
+ _background.frameIndex = 0;
+ exit();
+ }
+
+ return false;
+ }
+
+ if (_background.frameIndex < _background.frameCount - 1) {
+ ++_background.frameIndex;
+
+ return false;
+ }
+
+ return true;
}
bool Encounter::drawPortraits() {
@@ -1007,6 +1079,8 @@ void Encounter::runScript() {
case 12:
_items[entry.param1].keywords[findKeyword(&_items[entry.param1], entry.param2)] |= kEncounterArray4000;
_items[entry.param1].keywords[findKeyword(&_items[entry.param1], entry.param2)] |= kEncounterArray8000;
+
+ // Original saves the item back here
break;
case 13:
diff --git a/engines/asylum/resources/encounters.h b/engines/asylum/resources/encounters.h
index 306968ad5c..2820856b83 100644
--- a/engines/asylum/resources/encounters.h
+++ b/engines/asylum/resources/encounters.h
@@ -210,6 +210,7 @@ private:
//////////////////////////////////////////////////////////////////////////
// Misc
+ void exit();
void setupEntities(bool type4);
int32 findRect();
void updateDrawingStatus();
Commit: ac0ae2162f330d905f58a62f80d7d8813b72f35d
https://github.com/scummvm/scummvm/commit/ac0ae2162f330d905f58a62f80d7d8813b72f35d
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:35+02:00
Commit Message:
ASYLUM: Implement Encounter functions drawPortraits(), drawStructs() and drawDialog()
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@657 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/resources/encounters.cpp
diff --git a/engines/asylum/resources/encounters.cpp b/engines/asylum/resources/encounters.cpp
index 68e6fa4d30..37eb73c88f 100644
--- a/engines/asylum/resources/encounters.cpp
+++ b/engines/asylum/resources/encounters.cpp
@@ -748,18 +748,255 @@ bool Encounter::drawBackground() {
}
bool Encounter::drawPortraits() {
- error("[Encounter::drawPortraits] not implemented!");
+ bool ret = true;
+
+ if (_data_455BD4) {
+ _portrait1.transTableMax = 0;
+ _portrait2.transTableMax = 0;
+ }
+
+ // Portrait 1
+ if (_portrait1.transTableNum == 3 )
+ getScreen()->draw(_portrait1.resourceId,
+ _portrait1.frameIndex,
+ _point.x + 5,
+ _point.y + 5,
+ 0);
+ else
+ getScreen()->draw(_portrait1.resourceId,
+ _portrait1.frameIndex,
+ _point.x + 5,
+ _point.y + 5,
+ 0,
+ _portrait1.transTableNum);
+
+ if (_portrait1.transTableNum != _portrait1.transTableMax) {
+ if (_portrait1.transTableNum <= _portrait1.transTableMax)
+ ++_portrait1.transTableNum;
+ else
+ --_portrait1.transTableNum;
+
+ ret = false;
+ }
+
+ if (_portrait1.speech0) {
+ if (_portrait1.speech0 == 1)
+ ++_portrait1.frameIndex;
+ else
+ --_portrait1.frameIndex;
+
+ _portrait1.frameIndex %= _portrait1.frameCount;
+ }
+
+ // Portrait 2
+ Common::Rect frameRect = GraphicResource::getFrameRect(_vm, _portrait2.resourceId, _portrait2.frameIndex);
+
+ if (_portrait2.transTableNum == 3)
+ getScreen()->draw(_portrait2.resourceId,
+ _portrait2.frameIndex,
+ _point.x - frameRect.width() + _background.rect.width() - 6,
+ _point.y + 5,
+ 0);
+ else
+ getScreen()->draw(_portrait2.resourceId,
+ _portrait2.frameIndex,
+ _point.x - frameRect.width() + _background.rect.width() - 6,
+ _point.y + 5,
+ 0,
+ _portrait2.transTableNum);
+
+ if (_portrait2.transTableNum != _portrait2.transTableMax) {
+ if (_portrait2.transTableNum <= _portrait2.transTableMax)
+ ++_portrait2.transTableNum;
+ else
+ --_portrait2.transTableNum;
+
+ ret = false;
+ }
+
+ if (_portrait2.speech0) {
+ if (_portrait2.speech0 == 1)
+ ++_portrait2.frameIndex;
+ else
+ --_portrait2.frameIndex;
+
+ _portrait2.frameIndex %= _portrait2.frameCount;
+ }
+
+ if (_data_455BD4)
+ if (_portrait1.transTableNum == _portrait1.transTableMax
+ && _portrait2.transTableNum == _portrait2.transTableMax)
+ _data_455BE4 = true;
+
+ return ret;
}
void Encounter::drawStructs() {
- error("[Encounter::drawStructs] not implemented!");
+ // Drawing structure 1
+ if (_drawingStructs[0].transTableNum < -1 || _drawingStructs[0].transTableNum > 3)
+ error("[Encounter::drawStructs] Something got <redacted> wrong!");
+
+ if (checkKeywords2() || _drawingStructs[0].transTableNum > -1) {
+ int32 val = _drawingStructs[0].transTableNum;
+
+ if (_data_455BD4
+ && _drawingStructs[0].status != 2
+ && _drawingStructs[0].transTableNum > -1) {
+ val = _drawingStructs[0].transTableNum - 1;
+ _drawingStructs[0].status = 2;
+ --_drawingStructs[0].transTableNum;
+ }
+
+ switch (val) {
+ default:
+ break;
+
+ case -1:
+ getScreen()->draw(_drawingStructs[0].resourceId,
+ _drawingStructs[0].frameIndex,
+ _drawingStructs[0].point2.x,
+ _drawingStructs[0].point2.y,
+ 0,
+ 0);
+
+ _drawingStructs[0].status = 0;
+ break;
+
+ case 0:
+ case 1:
+ case 2:
+ getScreen()->draw(_drawingStructs[0].resourceId,
+ _drawingStructs[0].frameIndex,
+ _drawingStructs[0].point2.x,
+ _drawingStructs[0].point2.y,
+ 0,
+ val);
+
+ if (_drawingStructs[0].status == 1)
+ ++_drawingStructs[0].transTableNum;
+ else if (_drawingStructs[0].status == 2)
+ --_drawingStructs[0].transTableNum;
+
+ break;
+
+ case 3:
+ getScreen()->draw(_drawingStructs[0].resourceId,
+ _drawingStructs[0].frameIndex,
+ _drawingStructs[0].point2.x,
+ _drawingStructs[0].point2.y,
+ 0);
+
+ _drawingStructs[0].status = 0;
+ break;
+ }
+ }
+
+ // Drawing structure 2
+ if (_drawingStructs[1].transTableNum < -1 || _drawingStructs[1].transTableNum > 3)
+ error("[Encounter::drawStructs] Something got <redacted> wrong!");
+
+ if (checkKeywords() || _drawingStructs[1].transTableNum > -1) {
+ int32 val = _drawingStructs[1].transTableNum;
+
+ if (_data_455BD4
+ && _drawingStructs[1].status != 2
+ && _drawingStructs[1].transTableNum > -1) {
+ val = _drawingStructs[1].transTableNum - 1;
+ _drawingStructs[1].status = 2;
+ --_drawingStructs[1].transTableNum;
+ }
+
+ switch (val) {
+ default:
+ break;
+
+ case -1:
+ getScreen()->draw(_drawingStructs[1].resourceId,
+ _drawingStructs[1].frameIndex,
+ _drawingStructs[1].point2.x,
+ _drawingStructs[1].point2.y,
+ 0,
+ 0);
+
+ _drawingStructs[1].status = 0;
+ break;
+
+ case 0:
+ case 1:
+ case 2:
+ getScreen()->draw(_drawingStructs[1].resourceId,
+ _drawingStructs[1].frameIndex,
+ _drawingStructs[1].point2.x,
+ _drawingStructs[1].point2.y,
+ 0,
+ val);
+
+ if (_drawingStructs[1].status == 1)
+ ++_drawingStructs[1].transTableNum;
+ else if (_drawingStructs[1].status == 2)
+ --_drawingStructs[1].transTableNum;
+
+ break;
+
+ case 3:
+ getScreen()->draw(_drawingStructs[1].resourceId,
+ _drawingStructs[1].frameIndex,
+ _drawingStructs[1].point2.x,
+ _drawingStructs[1].point2.y,
+ 0);
+
+ _drawingStructs[1].status = 0;
+ break;
+ }
+ }
}
void Encounter::drawDialog() {
- error("[Encounter::drawDialog] not implemented!");
+ getText()->loadFont(getWorld()->font1);
+
+ if (_data_455BF8 >= 50)
+ return;
+
+ int32 counter = 0;
+
+ for (uint32 i = _data_455BF8; i < ARRAYSIZE(_keywordIndexes); i++) {
+ if (counter / 3 >= 8)
+ return;
+
+ int32 index = _keywordIndexes[i];
+
+ if (index < 0)
+ continue;
+
+ if ((_item->keywords[index] & KEYWORD_MASK) > 0 && (BYTE1(_keywordIndexes[i]) & 0x80)) {
+
+ if (BYTE1(_keywordIndexes[i]) & 0x20)
+ getText()->loadFont(getWorld()->font2);
+ else
+ getText()->loadFont(getWorld()->font1);
+
+ int32 x = _drawingStructs[0].point1.y + 144 * (counter % 3) + _point.x + (counter % 3) + _portrait1.rect.width() + 15;
+ int32 y = _point.y + (16 * counter / 3);
+
+ if (getKeywordIndex() == index)
+ getScreen()->fillRect(x -1, y + 5, getText()->getWidth(MAKE_RESOURCE(kResourcePackShared, 3681)), 18, 0);
+
+ getText()->setPosition(x, y);
+ getText()->draw(MAKE_RESOURCE(kResourcePackShared, 3681));
+
+ ++counter;
+ _data_455B14 = i;
+ }
+ }
}
void Encounter::drawText(char *text, ResourceId font, int32 y) {
+ if (!text)
+ return;
+
+ //int width = _background.rect.width() - _portrait1.rect.width() - _portrait2.rect.width() - 20;
+ //int x = _point.x + _portrait1.rect.width() + 10;
+
error("[Encounter::drawText] not implemented!");
}
Commit: e5b3e4c47666990e040ee0566fe6e95b26ac06c2
https://github.com/scummvm/scummvm/commit/e5b3e4c47666990e040ee0566fe6e95b26ac06c2
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:35+02:00
Commit Message:
ASYLUM: Fix two warnings and rename two flags in Encounter class
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@658 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/resources/actor.cpp
engines/asylum/resources/encounters.cpp
engines/asylum/resources/encounters.h
engines/asylum/resources/script.cpp
engines/asylum/resources/special.cpp
engines/asylum/views/scene.cpp
diff --git a/engines/asylum/resources/actor.cpp b/engines/asylum/resources/actor.cpp
index 4e2337480d..0d48cb7a61 100644
--- a/engines/asylum/resources/actor.cpp
+++ b/engines/asylum/resources/actor.cpp
@@ -518,7 +518,7 @@ void Actor::update() {
break;
case kActorStatus8:
- if (_vm->encounter()->getFlag6()
+ if (_vm->encounter()->isRunning()
|| !_soundResourceId
|| getSound()->isPlaying(_soundResourceId)) {
_frameIndex = (_frameIndex + 1) % _frameCount;
@@ -613,7 +613,7 @@ void Actor::updateStatus(ActorStatus actorStatus) {
break;
case kActorStatus9:
- if (_vm->encounter()->getFlag6())
+ if (_vm->encounter()->isRunning())
return;
if (_vm->getRandomBit() == 1 && isDefaultDirection(15))
@@ -1186,7 +1186,7 @@ void Actor::updateStatusEnabled() {
if (_vm->isGameFlagNotSet(kGameFlagScriptProcessing)
&& isVisible()
- && !_vm->encounter()->getFlag6()
+ && !_vm->encounter()->isRunning()
&& !getSpeech()->getSoundResourceId()) {
if (_vm->getRandom(100) < 50) {
if (getWorld()->chapter == kChapter13)
diff --git a/engines/asylum/resources/encounters.cpp b/engines/asylum/resources/encounters.cpp
index 37eb73c88f..76a3de0b2b 100644
--- a/engines/asylum/resources/encounters.cpp
+++ b/engines/asylum/resources/encounters.cpp
@@ -50,7 +50,7 @@ namespace Asylum {
Encounter::Encounter(AsylumEngine *engine) : _vm(engine),
_index(0), _keywordIndex(0), _item(NULL), _objectId1(kObjectNone), _objectId2(kObjectNone), _actorIndex(kActorInvalid),
- _flag1(false), _flag2(false), _flag3(false), _flag4(false), _flag5(false), _flag6(false) {
+ _flag1(false), _flag2(false), _flag3(false), _flag4(false), _disablePlayerOnExit(false), _isRunning(false) {
// TODO init rest of members
@@ -241,14 +241,14 @@ void Encounter::exit() {
initScript(_item->scriptResourceId);
_flag3 = true;
runScript();
-
+
setupEntities(true);
++_item->value;
// Original saves the item back here
// Update flags
- _flag6 = false;
+ _isRunning = false;
getSharedData()->setFlag(kFlag3, true);
if (_flag2)
@@ -256,10 +256,10 @@ void Encounter::exit() {
else
_flag1 = true;
- if (_flag5)
+ if (_disablePlayerOnExit)
getScene()->getActor()->updateStatus(kActorStatusDisabled);
- _flag5 = false;
+ _disablePlayerOnExit = false;
if (getSound()->getMusicVolume() != Config.musicVolume)
getSound()->setMusicVolume(Config.musicVolume);
@@ -303,7 +303,7 @@ bool Encounter::init() {
getSound()->setMusicVolume(Config.musicVolume - 500);
if (!getSharedData()->getMatteBarHeight()) {
- _flag6 = true;
+ _isRunning = true;
_data_455BD4 = false;
_data_455BD8 = false;
_data_455BDC = false;
@@ -314,7 +314,7 @@ bool Encounter::init() {
_rectIndex = -1;
_value1 = 0;
_data_455BF4 = 0;
- _data_455BF8 = false;
+ _data_455BF8 = 0;
_data_455B14 = -1;
getSpeech()->resetTextData();
@@ -346,10 +346,10 @@ bool Encounter::update() {
if (_objectId3) {
_data_455BD0 = false;
-
+
Object *object = getWorld()->getObjectById(_objectId3);
id = object->getResourceId();
-
+
if (object->getFrameIndex() == object->getFrameCount() - 1) {
switch (getVariable(3)) {
default:
@@ -398,13 +398,14 @@ bool Encounter::update() {
_data_455BF4 = 2;
runScript();
}
- bool doScript;
- if ((getSpeech()->getSoundResourceId()
- && !getSound()->isPlaying(getSpeech()->getSoundResourceId())
+
+ bool doScript = false;
+ if ((getSpeech()->getSoundResourceId()
+ && !getSound()->isPlaying(getSpeech()->getSoundResourceId())
&& !_data_455BE0)
|| (getSpeech()->getTick() && tick >= getSpeech()->getTick()))
doScript = true;
-
+
if (!getSharedData()->getMatteBarHeight() && doScript && _flag4) {
if (!setupSpeech(id))
runScript();
@@ -415,8 +416,8 @@ bool Encounter::update() {
if (!getSharedData()->getFlag(kFlagRedraw)) {
if (updateScreen())
return true;
-
- getSharedData()->setFlag(kFlagRedraw, true);
+
+ getSharedData()->setFlag(kFlagRedraw, true);
}
if (tick >= getSharedData()->getNextScreenUpdate() && getSharedData()->getFlag(kFlagRedraw)) {
@@ -429,7 +430,7 @@ bool Encounter::update() {
getSharedData()->setFlag(kFlagRedraw, false);
getSharedData()->setNextScreenUpdate(tick + 55);
}
-
+
return true;
}
@@ -443,8 +444,8 @@ bool Encounter::key(const AsylumEvent &evt) {
break;
case Common::KEYCODE_ESCAPE:
- if (!isSpeaking()
- && _data_455BD0
+ if (!isSpeaking()
+ && _data_455BD0
&& !getSpeech()->getTextData()
&& !getSpeech()->getTextDataPos())
_data_455BD4 = true;
@@ -473,19 +474,19 @@ bool Encounter::mouse(const AsylumEvent &evt) {
if (_rectIndex == -1) {
if (!isSpeaking())
choose(getKeywordIndex());
-
+
_data_455BD8 = false;
} else {
_rectIndex = -1;
updateDrawingStatus1(_rectIndex);
_data_455BD8 = false;
- }
+ }
break;
-
+
case Common::EVENT_RBUTTONDOWN:
- if (!isSpeaking()
- && _data_455BD0
+ if (!isSpeaking()
+ && _data_455BD0
&& !getSpeech()->getTextData()
&& !getSpeech()->getTextDataPos())
_data_455BD4 = true;
@@ -677,7 +678,7 @@ bool Encounter::setupSpeech(ResourceId id) {
getSpeech()->setTextResourceId(getSpeech()->getTextResourceId() + 1);
setupSpeechText();
-
+
return true;
}
@@ -706,7 +707,7 @@ bool Encounter::drawBackground() {
if (Config.performance > 1) {
if (_vm->isGameFlagSet(kGameFlag528)) {
Common::Point origin;
-
+
getScreen()->addGraphicToQueueCrossfade(_background.resourceId,
_background.frameIndex,
_point,
@@ -715,16 +716,16 @@ bool Encounter::drawBackground() {
_background.transTableNum);
} else {
Common::Point origin(getWorld()->xLeft, getWorld()->yTop);
-
+
getScreen()->addGraphicToQueueCrossfade(_background.resourceId,
_background.frameIndex,
_point,
getWorld()->backgroundImage,
origin,
_background.transTableNum);
- }
+ }
} else {
- getScreen()->draw(_background.resourceId, _background.frameIndex, _point.x, _point.y, 0);
+ getScreen()->draw(_background.resourceId, _background.frameIndex, _point.x, _point.y, 0);
}
if (_data_455BE4) {
@@ -749,7 +750,7 @@ bool Encounter::drawBackground() {
bool Encounter::drawPortraits() {
bool ret = true;
-
+
if (_data_455BD4) {
_portrait1.transTableMax = 0;
_portrait2.transTableMax = 0;
@@ -822,7 +823,7 @@ bool Encounter::drawPortraits() {
_portrait2.frameIndex %= _portrait2.frameCount;
}
-
+
if (_data_455BD4)
if (_portrait1.transTableNum == _portrait1.transTableMax
&& _portrait2.transTableNum == _portrait2.transTableMax)
@@ -835,7 +836,7 @@ void Encounter::drawStructs() {
// Drawing structure 1
if (_drawingStructs[0].transTableNum < -1 || _drawingStructs[0].transTableNum > 3)
error("[Encounter::drawStructs] Something got <redacted> wrong!");
-
+
if (checkKeywords2() || _drawingStructs[0].transTableNum > -1) {
int32 val = _drawingStructs[0].transTableNum;
@@ -858,10 +859,10 @@ void Encounter::drawStructs() {
_drawingStructs[0].point2.y,
0,
0);
-
+
_drawingStructs[0].status = 0;
break;
-
+
case 0:
case 1:
case 2:
@@ -878,7 +879,7 @@ void Encounter::drawStructs() {
--_drawingStructs[0].transTableNum;
break;
-
+
case 3:
getScreen()->draw(_drawingStructs[0].resourceId,
_drawingStructs[0].frameIndex,
@@ -917,10 +918,10 @@ void Encounter::drawStructs() {
_drawingStructs[1].point2.y,
0,
0);
-
+
_drawingStructs[1].status = 0;
break;
-
+
case 0:
case 1:
case 2:
@@ -937,7 +938,7 @@ void Encounter::drawStructs() {
--_drawingStructs[1].transTableNum;
break;
-
+
case 3:
getScreen()->draw(_drawingStructs[1].resourceId,
_drawingStructs[1].frameIndex,
@@ -956,7 +957,7 @@ void Encounter::drawDialog() {
if (_data_455BF8 >= 50)
return;
-
+
int32 counter = 0;
for (uint32 i = _data_455BF8; i < ARRAYSIZE(_keywordIndexes); i++) {
@@ -964,10 +965,10 @@ void Encounter::drawDialog() {
return;
int32 index = _keywordIndexes[i];
-
+
if (index < 0)
continue;
-
+
if ((_item->keywords[index] & KEYWORD_MASK) > 0 && (BYTE1(_keywordIndexes[i]) & 0x80)) {
if (BYTE1(_keywordIndexes[i]) & 0x20)
@@ -980,7 +981,7 @@ void Encounter::drawDialog() {
if (getKeywordIndex() == index)
getScreen()->fillRect(x -1, y + 5, getText()->getWidth(MAKE_RESOURCE(kResourcePackShared, 3681)), 18, 0);
-
+
getText()->setPosition(x, y);
getText()->draw(MAKE_RESOURCE(kResourcePackShared, 3681));
@@ -996,7 +997,7 @@ void Encounter::drawText(char *text, ResourceId font, int32 y) {
//int width = _background.rect.width() - _portrait1.rect.width() - _portrait2.rect.width() - 20;
//int x = _point.x + _portrait1.rect.width() + 10;
-
+
error("[Encounter::drawText] not implemented!");
}
@@ -1167,7 +1168,7 @@ bool Encounter::updateScreen() {
if (_data_455BD4)
drawStructs();
-
+
return false;
}
@@ -1181,11 +1182,11 @@ bool Encounter::updateScreen() {
if (_rectIndex == -1 && findRect() == -1)
updateFromRect(-1);
-
+
return false;
}
- drawText(getSpeech()->getTextDataPos(), getWorld()->font3, _point.y);
+ drawText(getSpeech()->getTextDataPos(), getWorld()->font3, _point.y);
drawText(getSpeech()->getTextData(), getWorld()->font1, _point.y);
if (_data_455BE0) {
diff --git a/engines/asylum/resources/encounters.h b/engines/asylum/resources/encounters.h
index 2820856b83..bd07782b72 100644
--- a/engines/asylum/resources/encounters.h
+++ b/engines/asylum/resources/encounters.h
@@ -51,8 +51,8 @@ public:
bool getFlag1() { return _flag1; }
void setFlag3(bool state) { _flag3 = state; }
bool getFlag3() { return _flag3; }
- void setFlag5(bool state) { _flag5 = state; }
- bool getFlag6() { return _flag6; }
+ void disablePlayerOnExit(bool state) { _disablePlayerOnExit = state; }
+ bool isRunning() { return _isRunning; }
private:
AsylumEngine *_vm;
@@ -150,15 +150,15 @@ private:
bool _data_455BE4;
bool _data_455BE8;
uint32 _data_455BF4;
- bool _data_455BF8;
+ uint32 _data_455BF8;
// Internal flags
bool _flag1;
bool _flag2;
bool _flag3;
bool _flag4;
- bool _flag5;
- bool _flag6;
+ bool _disablePlayerOnExit;
+ bool _isRunning;
//////////////////////////////////////////////////////////////////////////
// Data
@@ -189,7 +189,7 @@ private:
bool checkKeywords();
bool checkKeywords2();
void updateFromRect(int32 rectIndex);
-
+
//////////////////////////////////////////////////////////////////////////
// Speech
void resetSpeech(uint32 a1, uint32 a2);
@@ -209,7 +209,7 @@ private:
void drawText(char *text, ResourceId font, int32 y);
//////////////////////////////////////////////////////////////////////////
- // Misc
+ // Misc
void exit();
void setupEntities(bool type4);
int32 findRect();
diff --git a/engines/asylum/resources/script.cpp b/engines/asylum/resources/script.cpp
index cdd8a8460d..8f6f245051 100644
--- a/engines/asylum/resources/script.cpp
+++ b/engines/asylum/resources/script.cpp
@@ -756,10 +756,10 @@ END_OPCODE
IMPLEMENT_OPCODE(RunEncounter)
Encounter *encounter = _vm->encounter();
- encounter->setFlag5(cmd->param5);
+ encounter->disablePlayerOnExit(cmd->param5);
if (cmd->param6) {
- if (encounter->getFlag6())
+ if (encounter->isRunning())
_lineIncrement = 1;
else
cmd->param6 = 0;
diff --git a/engines/asylum/resources/special.cpp b/engines/asylum/resources/special.cpp
index 41a98ac8cd..4b2b91baee 100644
--- a/engines/asylum/resources/special.cpp
+++ b/engines/asylum/resources/special.cpp
@@ -666,7 +666,7 @@ void Special::chapter9(Object *object, ActorIndex actorIndex) {
void Special::playChapterSound(Object *object, ActorIndex actorIndex) {
ResourceId id = getResourceId(object, actorIndex);
- if (_vm->encounter()->getFlag6())
+ if (_vm->encounter()->isRunning())
return;
if (id != kResourceNone && getSound()->isPlaying(id))
diff --git a/engines/asylum/views/scene.cpp b/engines/asylum/views/scene.cpp
index 5afa5e7324..edc17d91e7 100644
--- a/engines/asylum/views/scene.cpp
+++ b/engines/asylum/views/scene.cpp
@@ -1045,7 +1045,7 @@ void Scene::updateCursor(ActorDirection direction, Common::Rect rect) {
int16 rightLimit = rect.right - 10;
Common::Point mouse = getCursor()->position();
- if (getEncounter()->getFlag6()) {
+ if (getEncounter()->isRunning()) {
if (getCursor()->graphicResourceId != _ws->cursorResources[kCursorResourceTalkNPC])
getCursor()->set(_ws->cursorResources[kCursorResourceTalkNPC]);
Commit: 1ea8f311a9384f2a77ce8645f228c187664b4bbb
https://github.com/scummvm/scummvm/commit/1ea8f311a9384f2a77ce8645f228c187664b4bbb
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:35+02:00
Commit Message:
ASYLUM: Implement Encounter functions getKeywordIndex(), choose(), checkKeywords(), checkKeywords() and updateFromRect()
- Initialize Encounter member variables
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@659 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/resources/encounters.cpp
engines/asylum/resources/encounters.h
diff --git a/engines/asylum/resources/encounters.cpp b/engines/asylum/resources/encounters.cpp
index 76a3de0b2b..322a7b9735 100644
--- a/engines/asylum/resources/encounters.cpp
+++ b/engines/asylum/resources/encounters.cpp
@@ -52,7 +52,25 @@ Encounter::Encounter(AsylumEngine *engine) : _vm(engine),
_index(0), _keywordIndex(0), _item(NULL), _objectId1(kObjectNone), _objectId2(kObjectNone), _actorIndex(kActorInvalid),
_flag1(false), _flag2(false), _flag3(false), _flag4(false), _disablePlayerOnExit(false), _isRunning(false) {
- // TODO init rest of members
+ memset(&_keywordIndexes, 0, sizeof(_keywordIndexes));
+ _rectIndex = -1;
+
+ _value1 = 0;
+ _tick = 0;
+ _data_455B14 = 0;
+ _data_455B3C = false;
+ _data_455B70 = 0;
+ _data_455BCC = false;
+ _data_455BD0 = false;
+ _data_455BD4 = false;
+ _data_455BD8 = false;
+ _data_455BDC = false;
+ _data_455BE0 = false;
+ _data_455BE4 = false;
+ _data_455BE8 = false;
+ _data_455BF0 = 0;
+ _data_455BF4 = 0;
+ _data_455BF8 = 0;
load();
}
@@ -533,26 +551,132 @@ uint32 Encounter::findKeyword(EncounterItem *item, int16 keyword) {
}
int32 Encounter::getKeywordIndex() {
- error("[Encounter::getKeywordIndex] Not implemented!");
+ Common::Point mousePos = getCursor()->position();
+
+ uint32 counter = 0;
+ for (uint i = _data_455BF8; i < ARRAYSIZE(_keywordIndexes); i++) {
+ int32 index = _keywordIndexes[i];
+
+ if (counter / 3 >= 8)
+ break;
+
+ if ((_item->keywords[index] & KEYWORD_MASK) && (BYTE1(_item->keywords[index]) & 0x80)) {
+ int32 x = _drawingStructs[0].point1.x + 144 * (counter % 3) + _point.x + (counter % 3) + _portrait1.rect.width() + 15;
+ int32 y = 16 * counter / 3 + _point.y + 5;
+
+ if (mousePos.x >= x && mousePos.x <= (x + getText()->getWidth(MAKE_RESOURCE(kResourcePackShared, 3681)))
+ && mousePos.y >= y && mousePos.y <= (y + 16))
+ return i;
+
+ ++counter;
+ }
+ }
+
+ return -1;
}
void Encounter::choose(int32 index) {
if (_flag4 || index == -1)
return;
- error("[Encounter::choose] Not implemented!");
+ if ((_item->keywords[index] & KEYWORD_MASK) && (BYTE1(_item->keywords[index]) & 0x80)) {
+
+ _value1 = (_item->keywords[index] & KEYWORD_MASK);
+ setVariable(1, _value1);
+
+ if (strcmp("Goodbye", getText()->get(MAKE_RESOURCE(kResourcePackShared, 3681 + _value1))))
+ if (_index != 79)
+ BYTE1(_item->keywords[index]) |= 0x20;
+
+ initScript(_item->scriptResourceId);
+ runScript();
+ }
}
bool Encounter::checkKeywords() {
- error("[Encounter::checkKeywords] Not implemented!");
+ if (_data_455B14 == -1 || _data_455B14 + 1 >= 50)
+ return false;
+
+ for (uint32 i = _data_455B14 + 1; i < ARRAYSIZE(_keywordIndexes); i++) {
+ int32 index = _keywordIndexes[i];
+
+ if (index < 0)
+ continue;
+
+ if ((_item->keywords[index] & KEYWORD_MASK) && (BYTE1(_item->keywords[index]) & 0x80))
+ return true;
+ }
+
+ return false;
}
bool Encounter::checkKeywords2() {
- error("[Encounter::checkKeywords2] Not implemented!");
+ for (uint32 i = 0; i < _data_455BF8; i++) {
+ int32 index = _keywordIndexes[i];
+
+ if (index < 0)
+ continue;
+
+ if ((_item->keywords[index] & KEYWORD_MASK) && (BYTE1(_item->keywords[index]) & 0x80))
+ return true;
+ }
+
+ return false;
}
void Encounter::updateFromRect(int32 rectIndex) {
- error("[Encounter::updateFromRect] Not implemented!");
+ if (rectIndex) {
+ if (rectIndex == 1 && (_data_455B14 + 1) < 50) {
+ bool cont = false;
+
+ for (uint32 i = _data_455B14 + 1; i < ARRAYSIZE(_keywordIndexes); i++) {
+ int32 index = _keywordIndexes[i];
+
+ if (index < 0)
+ continue;
+
+ if ((_item->keywords[index] & KEYWORD_MASK) && (BYTE1(_item->keywords[index]) & 0x80)) {
+ cont = true;
+ break;
+ }
+ }
+
+ if (!cont)
+ return;
+
+ uint32 counter = 0;
+ for (uint32 i = _data_455BF8 + 1; i < ARRAYSIZE(_keywordIndexes); i++) {
+ int32 index = _keywordIndexes[i];
+
+ if (counter == 3)
+ break;
+
+ if (index < 0)
+ continue;
+
+ if ((_item->keywords[index] & KEYWORD_MASK) && (BYTE1(_item->keywords[index]) & 0x80)) {
+ _data_455BF8 = i;
+ ++counter;
+ }
+ }
+ }
+ } else {
+ uint32 counter = 0;
+ for (uint32 i = _data_455BF8 - 1; i > -1; i--) {
+ int32 index = _keywordIndexes[i];
+
+ if (counter == 3)
+ break;
+
+ if (index < 0)
+ continue;
+
+ if ((_item->keywords[index] & KEYWORD_MASK) && (BYTE1(_item->keywords[index]) & 0x80)) {
+ _data_455BF8 = i;
+ ++counter;
+ }
+ }
+ }
}
//////////////////////////////////////////////////////////////////////////
diff --git a/engines/asylum/resources/encounters.h b/engines/asylum/resources/encounters.h
index bd07782b72..ce1c4c19cc 100644
--- a/engines/asylum/resources/encounters.h
+++ b/engines/asylum/resources/encounters.h
@@ -137,10 +137,12 @@ private:
ActorIndex _actorIndex;
uint32 _value1;
+ uint32 _tick;
// Internal data
int32 _data_455B14;
bool _data_455B3C;
+ uint32 _data_455B70;
bool _data_455BCC;
bool _data_455BD0;
bool _data_455BD4;
@@ -149,6 +151,7 @@ private:
bool _data_455BE0;
bool _data_455BE4;
bool _data_455BE8;
+ uint32 _data_455BF0;
uint32 _data_455BF4;
uint32 _data_455BF8;
Commit: 5b43d804d918e8853d8a285126ef89063a73576e
https://github.com/scummvm/scummvm/commit/5b43d804d918e8853d8a285126ef89063a73576e
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:36+02:00
Commit Message:
ASYLUM: Implement Encounter::drawText()
- Remove unused ResourcePack::count() method
- Add proper text centering calculation to drawText()
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@660 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/resources/encounters.cpp
engines/asylum/resources/encounters.h
engines/asylum/respack.h
engines/asylum/system/text.cpp
engines/asylum/system/text.h
diff --git a/engines/asylum/resources/encounters.cpp b/engines/asylum/resources/encounters.cpp
index 322a7b9735..934749e2c8 100644
--- a/engines/asylum/resources/encounters.cpp
+++ b/engines/asylum/resources/encounters.cpp
@@ -58,7 +58,7 @@ Encounter::Encounter(AsylumEngine *engine) : _vm(engine),
_value1 = 0;
_tick = 0;
_data_455B14 = 0;
- _data_455B3C = false;
+ _data_455B3C = 0;
_data_455B70 = 0;
_data_455BCC = false;
_data_455BD0 = false;
@@ -328,7 +328,7 @@ bool Encounter::init() {
_data_455BE0 = false;
_data_455BE4 = false;
_data_455BCC = false;
- _data_455B3C = true;
+ _data_455B3C = 1;
_rectIndex = -1;
_value1 = 0;
_data_455BF4 = 0;
@@ -687,7 +687,7 @@ void Encounter::resetSpeech(uint32 keywordIndex, uint32 a2) {
setupPortraits();
_data_455BCC = false;
- _data_455B3C = false;
+ _data_455B3C = 1;
if (keywordIndex) {
getSpeech()->setTextResourceId(keywordIndex + a2);
@@ -751,7 +751,7 @@ void Encounter::setupSpeechText() {
}
_data_455BCC = false;
- _data_455B3C = true;
+ _data_455B3C = 1;
}
void Encounter::setupSpeech(ResourceId textResourceId, ResourceId fontResourceId) {
@@ -793,7 +793,7 @@ bool Encounter::setupSpeech(ResourceId id) {
getSpeech()->setTextDataPos(0);
_data_455BCC = false;
- _data_455B3C = true;
+ _data_455B3C = 1;
setupPortraits();
@@ -1119,10 +1119,27 @@ void Encounter::drawText(char *text, ResourceId font, int32 y) {
if (!text)
return;
- //int width = _background.rect.width() - _portrait1.rect.width() - _portrait2.rect.width() - 20;
- //int x = _point.x + _portrait1.rect.width() + 10;
+ int width = _background.rect.width() - _portrait1.rect.width() - _portrait2.rect.width() - 20;
+ int x = _point.x + _portrait1.rect.width() + 10;
- error("[Encounter::drawText] not implemented!");
+ getText()->loadFont(font);
+
+ if (_data_455BCC) {
+ if (_data_455B3C != 1 && _tick < _vm->getTick()) {
+ _tick = _vm->getTick() + 1000 * getResource()->get(getSpeech()->getSoundResourceId())->size / 11025 / _data_455B3C;
+
+ if ((_data_455BF0 + 8) < _data_455B70)
+ _data_455BF0 += 8;
+ }
+ } else {
+ _data_455BCC = true;
+ _data_455B70 = getText()->draw(kTextCalculate, x, y, 16, width, text);
+ _data_455B3C = _data_455B70 / 8 + 1;
+ _data_455BF0 = 0;
+ _tick = _vm->getTick() + 1000 * getResource()->get(getSpeech()->getSoundResourceId())->size / 11025 / _data_455B3C;
+ }
+
+ getText()->draw(_data_455BF0, 7, kTextCenter, x, y, 16, width, text);
}
void Encounter::drawScreen() {
diff --git a/engines/asylum/resources/encounters.h b/engines/asylum/resources/encounters.h
index ce1c4c19cc..4e1d564aea 100644
--- a/engines/asylum/resources/encounters.h
+++ b/engines/asylum/resources/encounters.h
@@ -141,7 +141,7 @@ private:
// Internal data
int32 _data_455B14;
- bool _data_455B3C;
+ uint32 _data_455B3C;
uint32 _data_455B70;
bool _data_455BCC;
bool _data_455BD0;
diff --git a/engines/asylum/respack.h b/engines/asylum/respack.h
index 757a10d2d6..daa44f7ffc 100644
--- a/engines/asylum/respack.h
+++ b/engines/asylum/respack.h
@@ -55,7 +55,6 @@ struct ResourceEntry {
class ResourcePack {
public:
ResourceEntry *get(uint16 index);
- int count();
protected:
ResourcePack(Common::String filename);
diff --git a/engines/asylum/system/text.cpp b/engines/asylum/system/text.cpp
index 7e42a7909b..1b40985f71 100644
--- a/engines/asylum/system/text.cpp
+++ b/engines/asylum/system/text.cpp
@@ -171,17 +171,17 @@ void Text::draw(int32 x, int32 y, ResourceId resourceId) {
void Text::draw(const char *text, ResourceId fontResourceId, int32 y) {
if (text) {
loadFont(fontResourceId);
- draw(true, 20, y, 16, 600, text);
+ draw(kTextCenter, 20, y, 16, 600, text);
}
}
-void Text::draw(bool isCentered, int32 x, int32 y, int32 spacing, int32 width, const char *text) {
- draw(0, 99, isCentered, x, y, spacing, width, text);
+uint32 Text::draw(TextCentering centering, int32 x, int32 y, int32 spacing, int32 width, const char *text) {
+ return draw(0, 99, centering, x, y, spacing, width, text);
}
-void Text::draw(int32 a1, int32 a2, bool isCentered, int32 x, int32 y, int32 spacing, int32 width, const char *text) {
+uint32 Text::draw(int32 a1, int32 a2, TextCentering centering, int32 x, int32 y, int32 spacing, int32 width, const char *text) {
if (!text || !*text)
- return;
+ return 0;
bool drawText = false;
int32 charWidth = 0;
@@ -191,6 +191,8 @@ void Text::draw(int32 a1, int32 a2, bool isCentered, int32 x, int32 y, int32 spa
const char *string = text;
const char *endText = text;
+ uint32 printed = 0;
+
for (;;) {
label_start:
@@ -201,14 +203,23 @@ label_start:
char currentChar = *endText;
if (index >= a1 && index <= (a1 + 2)) {
- if (isCentered) {
+ switch (centering) {
+ default:
+ case kTextCalculate:
+ break;
+
+ case kTextCenter:
drawCentered(x, y, width, endText - string, string);
- } else {
+ break;
+
+ case kTextNormal:
setPosition(x, y);
draw(text, endText - text);
+ break;
}
y += spacing;
+ ++printed;
}
++index;
@@ -271,6 +282,8 @@ label_start:
endText = txt;
drawText = true;
}
+
+ return printed;
}
void Text::drawCentered(int32 x, int32 y, int32 width, const char *text) {
diff --git a/engines/asylum/system/text.h b/engines/asylum/system/text.h
index f374c08200..1e1be18dad 100644
--- a/engines/asylum/system/text.h
+++ b/engines/asylum/system/text.h
@@ -36,6 +36,12 @@ class AsylumEngine;
class GraphicResource;
class ResourcePack;
+enum TextCentering {
+ kTextNormal,
+ kTextCenter,
+ kTextCalculate
+};
+
class Text {
public:
Text(AsylumEngine *engine);
@@ -57,8 +63,8 @@ public:
void draw(int32 x, int32 y, ResourceId resourceId);
void draw(const char *text, ResourceId fontResourceId, int32 y);
void draw(const char *text, uint32 length);
- void draw(bool isCentered, int32 x, int32 y, int32 spacing, int32 width, const char *text);
- void draw(int32 a1, int32 a2, bool isCentered, int32 x, int32 y, int32 spacing, int32 width, const char *text);
+ uint32 draw(TextCentering centering, int32 x, int32 y, int32 spacing, int32 width, const char *text);
+ uint32 draw(int32 a1, int32 a2, TextCentering centering, int32 x, int32 y, int32 spacing, int32 width, const char *text);
void drawCentered(int32 x, int32 y, int32 width, const char *text);
void drawCentered(int32 x, int32 y, int32 width, ResourceId resourceId);
Commit: ce312cfe8389c7fac2fff2fe93eda98ae54cc8da
https://github.com/scummvm/scummvm/commit/ce312cfe8389c7fac2fff2fe93eda98ae54cc8da
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:36+02:00
Commit Message:
ASYLUM: Implement more Actor status update
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@661 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/resources/actor.cpp
engines/asylum/resources/actor.h
engines/asylum/resources/data.h
engines/asylum/views/scene.h
diff --git a/engines/asylum/resources/actor.cpp b/engines/asylum/resources/actor.cpp
index 0d48cb7a61..9634ee4014 100644
--- a/engines/asylum/resources/actor.cpp
+++ b/engines/asylum/resources/actor.cpp
@@ -114,6 +114,7 @@ Actor::Actor(AsylumEngine *engine, ActorIndex index) : _vm(engine), _index(index
// Instance data
_tickCount = -1;
+ _updateCounter = 0;
}
Actor::~Actor() {
@@ -306,10 +307,10 @@ void Actor::update() {
if (_index == 11) {
if (_frameIndex <= _frameCount - 1) {
// Looks like a simple check using the counter, since it doesn't seem to be used anywhere else
- if (getSharedData()->getUpdateCounter() <= 0) {
- getSharedData()->setUpdateCounter(getSharedData()->getUpdateCounter() + 1);
+ if (_updateCounter <= 0) {
+ ++_updateCounter;
} else {
- getSharedData()->setUpdateCounter(0);
+ _updateCounter = 0;
++_frameIndex;
}
} else {
@@ -467,9 +468,28 @@ void Actor::update() {
}
// Fallback to next case
- case kActorStatus1:
- // TODO: do actor direction
- error("[Actor::update] kActorStatus1 / kActorStatus12 case not implemented");
+ case kActorStatus1: {
+ uint32 index = (_frameIndex >= _frameCount) ? 2 * _frameCount - (_frameIndex + 1) : _frameIndex;
+
+ uint32 dir = _direction;
+ uint32 dist = abs((double)getDistanceForFrame(_direction, index));
+ // FIXME the original tests for != 0 and sets to an unknown value
+
+ Common::Point point(_point1.x + _point2.x, _point1.y + _point2.y);
+
+ if (process_408B20(&point, _direction, dist, false)) {
+ process_408D00(_direction, dist);
+ } else if (process_408B20(&point, (ActorDirection)((dir + 1) % 7), dist, false)) {
+ process_408D00((ActorDirection)((dir + 1) % 7), dist);
+ } else if (process_408B20(&point, (ActorDirection)((dir + 7) % 7), dist, false)) {
+ process_408D00((ActorDirection)((dir + 7) % 7), dist);
+ } else if (process_408B20(&point, (ActorDirection)((dir + 2) % 7), dist, false)) {
+ process_408D00((ActorDirection)((dir + 2) % 7), dist);
+ } else if (process_408B20(&point, (ActorDirection)((dir + 6) % 7), dist, false)) {
+ process_408D00((ActorDirection)((dir + 6) % 7), dist);
+ }
+
+ }
break;
case kActorStatus2:
@@ -989,6 +1009,10 @@ bool Actor::process_408B20(Common::Point *point, ActorDirection dir, uint32 coun
return true;
}
+void Actor::process_408D00(ActorDirection direction, uint32 count) {
+ error("[Actor::process_408D00] Not implemented!");
+}
+
void Actor::process_41BC00(int32 reactionIndex, int32 numberValue01Add) {
if (reactionIndex > 16)
return;
@@ -1058,11 +1082,99 @@ bool Actor::process_41BDB0(int32 reactionIndex, int32 testNumberValue01) {
}
bool Actor::process_4103B0(Common::Point *point, ActorDirection dir) {
- error("[Actor::update_40DE20] not implemented!");
+ int32 dist = getDistanceForFrame(dir, (_frameIndex >= _frameCount) ? 2 * _frameCount - (_frameIndex + 1) : _frameIndex);
+
+ int32 x = point->x + deltaPointsArray[dir].x * dist - _field_948 - 10;
+ int32 y = point->y + deltaPointsArray[dir].y * dist - _field_94C - 10;
+ int32 x1 = x + 2 * _field_948 + 20;
+ int32 y1 = y + 2 * _field_94C + 20;
+
+ for (int32 i = 0; i < (int32)getWorld()->actors.size(); i++) {
+ if (i == _index)
+ continue;
+
+ Actor *actor = getScene()->getActor(i);
+
+ if (!actor->isOnScreen())
+ continue;
+
+ int32 x2 = actor->getPoint1()->x + actor->getPoint2()->x - actor->getField948() - 15;
+ int32 y2 = actor->getPoint1()->y + actor->getPoint2()->y - actor->getField94C() - 10;
+ int32 x3 = actor->getPoint1()->x + actor->getPoint2()->x + 2 * actor->getField948() + 15;
+ int32 y3 = actor->getPoint1()->y + actor->getPoint2()->y + 2 * actor->getField94C() + 10;
+
+ if (i == getScene()->getPlayerIndex() && getWorld()->chapter == kChapter11) {
+ x2 -= 10;
+ y2 -= 10;
+ x3 += 10;
+ y3 += 10;
+ }
+
+ if (getScene()->rectIntersect(x, y, x1, y1, x2, y2, x3, y3)) {
+ if (i)
+ return false;
+
+ int32 x4 = x2 + 10;
+ int32 y4 = y2 + 10;
+ int32 x5 = x3 - 10;
+ int32 y5 = y3 - 10;
+
+ switch (actor->getDirection()) {
+ default:
+ break;
+
+ case kDirectionNO:
+ if (x4 >= x)
+ break;
+ // Fallback to next case
+
+ case kDirectionN:
+ if (x4 >= y)
+ break;
+
+ return false;
+
+ case kDirectionO:
+ if (x4 < x)
+ return false;
+
+ break;
+
+ case kDirectionSO:
+ if (x4 < x && y4 > y)
+ return false;
+
+ break;
+
+ case kDirectionS:
+ if (y5 > y1)
+ return false;
+
+ break;
+
+ case kDirectionE:
+ if (x5 > x1)
+ return false;
+
+ break;
+
+ case kDirectionNE:
+ if (x5 > x1 && y4 < y)
+ return false;
+
+ break;
+ }
+
+ if (getScene()->rectIntersect(x, y, x1, y1, x4, y4, x5, y5))
+ return false;
+ }
+ }
+
+ return true;
}
void Actor::updateAndDraw() {
- error("[Actor::update_40DE20] not implemented!");
+ error("[Actor::updateAndDraw] not implemented!");
}
void Actor::update_409230() {
@@ -1914,7 +2026,7 @@ int32 Actor::getDistance() const {
}
}
-uint32 Actor::getDistanceForFrame(ActorDirection dir, uint32 frameIndex) {
+int32 Actor::getDistanceForFrame(ActorDirection dir, uint32 frameIndex) {
switch (dir) {
default:
case kDirectionN:
diff --git a/engines/asylum/resources/actor.h b/engines/asylum/resources/actor.h
index 654284d059..2a7c35cf99 100644
--- a/engines/asylum/resources/actor.h
+++ b/engines/asylum/resources/actor.h
@@ -99,6 +99,8 @@ public:
int32 getField638() { return _field_638; }
int32 getField934() { return _field_934; }
int32 getField944() { return _field_944; }
+ int32 getField948() { return _field_948; }
+ int32 getField94C() { return _field_94C; }
int32 getField96C() { return _field_96C; }
int32 getField974() { return _field_974; }
int32 getField980() { return _field_980; }
@@ -260,6 +262,7 @@ public:
void process_401830(int32 field980, int32 actionAreaId, int32 field978, int field98C, int32 field990, int32 field974, int32 field984, int32 field988);
bool process_4069B0(int32 *x, int32 *y);
bool process_408B20(Common::Point *point, ActorDirection direction, uint32 count, bool hasDelta);
+ void process_408D00(ActorDirection direction, uint32 count);
void process_41BC00(int32 reactionIndex, int32 numberValue01Add);
void process_41BCC0(int32 reactionIndex, int32 numberValue01Substract);
bool process_41BDB0(int32 reactionIndex, int32 testNumberValue01);
@@ -383,6 +386,8 @@ private:
int32 _tickCount;
+ uint32 _updateCounter;
+
//////////////////////////////////////////////////////////////////////////
// Update methods
//////////////////////////////////////////////////////////////////////////
@@ -505,7 +510,7 @@ private:
*
* @return The distance for frame.
*/
- uint32 getDistanceForFrame(ActorDirection direction, uint32 frameIndex);
+ int32 getDistanceForFrame(ActorDirection direction, uint32 frameIndex);
/**
* Updates the coordinates depending on the direction.
diff --git a/engines/asylum/resources/data.h b/engines/asylum/resources/data.h
index 7495ab24f3..87fa83f337 100644
--- a/engines/asylum/resources/data.h
+++ b/engines/asylum/resources/data.h
@@ -106,8 +106,7 @@ struct SharedData {
public:
SharedData() {
_actorEnableForStatus7 = false;
- _flag1 = false;
- _actorUpdateCounter = 0;
+ _flag1 = false;
_matteBarHeight = 0;
_matteVar2 = 0;
_sceneCounter = 0;
@@ -176,9 +175,6 @@ public:
void setActorUpdateFlag(int32 val) { _data1[40] = 2; }
- int32 getUpdateCounter() { return _actorUpdateCounter; }
- void setUpdateCounter(int32 val) { _actorUpdateCounter = val; }
-
int32 getActorUpdateFlag2() { return _data1[36]; }
void setActorUpdateFlag2(int32 val) { _data1[36] = val; }
@@ -329,7 +325,6 @@ private:
bool _flag1;
- uint32 _actorUpdateCounter;
uint32 _matteBarHeight;
uint32 _matteVar2;
diff --git a/engines/asylum/views/scene.h b/engines/asylum/views/scene.h
index df1d0062e6..ab9957510b 100644
--- a/engines/asylum/views/scene.h
+++ b/engines/asylum/views/scene.h
@@ -165,7 +165,7 @@ public:
* @return true if it succeeds, false if it fails.
*/
bool updateScreen();
-
+
/**
* Determine if the supplied point intersects an action area's active region.
*
@@ -175,6 +175,22 @@ public:
*/
int32 findActionArea(ActionAreaType type, const Common::Point pt);
+ /**
+ * Check if rectangles intersect.
+ *
+ * @param x The x coordinate.
+ * @param y The y coordinate.
+ * @param x1 The first x value.
+ * @param y1 The first y value.
+ * @param x2 The second x value.
+ * @param y2 The second y value.
+ * @param x3 The third int32.
+ * @param y3 The third int32.
+ *
+ * @return true if it succeeds, false if it fails.
+ */
+ bool rectIntersect(int32 x, int32 y, int32 x1, int32 y1, int32 x2, int32 y2, int32 x3, int32 y3);
+
Polygons *polygons() { return _polygons; }
WorldStats *worldstats() { return _ws; }
@@ -364,7 +380,7 @@ private:
int32 hitTestObject();
/**
- * .Check if the mouse cursor is currently intersecting a graphic resource at the supplied coordinates.
+ * Check if the mouse cursor is currently intersecting a graphic resource at the supplied coordinates.
*
* @param resourceId Identifier for the resource.
* @param frame The frame.
@@ -435,22 +451,6 @@ private:
*/
bool pointIntersectsRect(Common::Point point, Common::Rect rect);
- /**
- * Check if rectangles intersect.
- *
- * @param x The x coordinate.
- * @param y The y coordinate.
- * @param x1 The first x value.
- * @param y1 The first y value.
- * @param x2 The second x value.
- * @param y2 The second y value.
- * @param x3 The third int32.
- * @param y3 The third int32.
- *
- * @return true if it succeeds, false if it fails.
- */
- bool rectIntersect(int32 x, int32 y, int32 x1, int32 y1, int32 x2, int32 y2, int32 x3, int32 y3);
-
/**
* Adjust coordinates.
*
Commit: 5c048aec55c17b3ed4ae4156dc7dfba29759437c
https://github.com/scummvm/scummvm/commit/5c048aec55c17b3ed4ae4156dc7dfba29759437c
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:36+02:00
Commit Message:
ASYLUM: Add proper enumeration value for kObjectCave
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@662 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/resources/encounters.cpp
engines/asylum/shared.h
diff --git a/engines/asylum/resources/encounters.cpp b/engines/asylum/resources/encounters.cpp
index 934749e2c8..c889dbca17 100644
--- a/engines/asylum/resources/encounters.cpp
+++ b/engines/asylum/resources/encounters.cpp
@@ -835,7 +835,7 @@ bool Encounter::drawBackground() {
getScreen()->addGraphicToQueueCrossfade(_background.resourceId,
_background.frameIndex,
_point,
- getWorld()->getObjectById((ObjectId)1763)->getResourceId(),
+ getWorld()->getObjectById(kObjectCave)->getResourceId(),
origin,
_background.transTableNum);
} else {
diff --git a/engines/asylum/shared.h b/engines/asylum/shared.h
index 8d64bb39c9..34a49bddc4 100644
--- a/engines/asylum/shared.h
+++ b/engines/asylum/shared.h
@@ -488,6 +488,7 @@ enum ObjectId {
kObjectPreAlphaNut2 = 1584,
kObjectDeadMomFromOutside = 1589,
kObjectHeadOnTable = 1595,
+ kObjectCave = 1763,
kObjectWitchDoctor = 1778,
kObjectStoneWifeStatuQuo = 1782,
kObjectFishermanWidowStatusQuo = 1786,
Commit: bde3c3d0d19417312caf6a6444f2fbd12a3ba49a
https://github.com/scummvm/scummvm/commit/bde3c3d0d19417312caf6a6444f2fbd12a3ba49a
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:36+02:00
Commit Message:
ASYLUM: Add back processing of delayed events
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@663 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/asylum.cpp
diff --git a/engines/asylum/asylum.cpp b/engines/asylum/asylum.cpp
index 0277c2e1b5..b467b93103 100644
--- a/engines/asylum/asylum.cpp
+++ b/engines/asylum/asylum.cpp
@@ -334,10 +334,13 @@ void AsylumEngine::handleEvents() {
// Send update event to our event handler
AsylumEvent updateEvt = AsylumEvent(EVENT_ASYLUM_UPDATE);
_handler->handleEvent(updateEvt);
+
+ // TODO replace by original game code based on switchEventHandler
+ processDelayedEvents();
}
void AsylumEngine::processDelayedEvents() {
- if (!_video || !_sound || !_scene || !_mainMenu)
+ if (!_video || !_sound || !_mainMenu)
error("[AsylumEngine::processDelayedEvents] Subsystems not initialized properly!");
// check for a delayed video
@@ -358,11 +361,11 @@ void AsylumEngine::processDelayedEvents() {
_sound->stopMusic();
_sound->stopAll();
- if (_scene)
- delete _scene;
-
+ delete _scene;
_scene = new Scene(this);
_scene->enter(packId);
+
+ switchEventHandler(_scene);
}
}
Commit: 730105912f901d67e7dbd0b18b8bef1b18043f4f
https://github.com/scummvm/scummvm/commit/730105912f901d67e7dbd0b18b8bef1b18043f4f
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:36+02:00
Commit Message:
ASYLUM: Update ResourcePackId enum values
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@664 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/shared.h
diff --git a/engines/asylum/shared.h b/engines/asylum/shared.h
index 34a49bddc4..75d877115c 100644
--- a/engines/asylum/shared.h
+++ b/engines/asylum/shared.h
@@ -176,14 +176,14 @@ enum ResourcePackId {
kResourcePackInnocentAbandoned = 6,
kResourcePackCourtyardAndChapel = 7,
kResourcePackCircusOfFools = 8,
- kResourcePackCave = 9,
- kResourcePackMansion = 10,
- kResourcePackLaboratory = 11,
- kResourcePackHive = 12,
- kResourcePackMorgueAndCementary = 13,
- kResourcePackLostVillage = 14,
- kResourcePackMaze = 15,
- kResourcePackGauntlet = 16,
+ kResourcePackLaboratory = 9,
+ kResourcePackHive = 10,
+ kResourcePackMorgueCementary = 11,
+ kResourcePackLostVillage = 12,
+ kResourcePackGauntlet = 13,
+ kResourcePackMansion = 14,
+ kResourcePackCave = 15,
+ kResourcePackMaze = 16,
kResourcePackMorgansLastGame = 17,
kResourcePackSound = 18,
kResourcePack104 = 104,
Commit: 436a6f3ef2448549e797fd9705fb62bb777fff86
https://github.com/scummvm/scummvm/commit/436a6f3ef2448549e797fd9705fb62bb777fff86
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:36+02:00
Commit Message:
ASYLUM: Rename puzzle classes
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@665 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/asylum.cpp
engines/asylum/asylum.h
engines/asylum/puzzles/puzzle.cpp
engines/asylum/puzzles/puzzle.h
engines/asylum/puzzles/vcr.cpp
engines/asylum/puzzles/vcr.h
engines/asylum/views/scene.h
diff --git a/engines/asylum/asylum.cpp b/engines/asylum/asylum.cpp
index b467b93103..b05378e289 100644
--- a/engines/asylum/asylum.cpp
+++ b/engines/asylum/asylum.cpp
@@ -411,7 +411,7 @@ EventHandler *AsylumEngine::getPuzzle(uint32 index) {
}
void AsylumEngine::initPuzzles() {
- _puzzles[0] = new BlowUpPuzzleVCR(this);
+ _puzzles[0] = new PuzzleVCR(this);
_puzzles[1] = NULL;
_puzzles[2] = NULL;
_puzzles[3] = NULL;
diff --git a/engines/asylum/asylum.h b/engines/asylum/asylum.h
index 718edfaaea..ee630329ba 100644
--- a/engines/asylum/asylum.h
+++ b/engines/asylum/asylum.h
@@ -64,7 +64,7 @@ namespace Asylum {
// If defined, will show the scene update times on the debugger output
//#define DEBUG_SCENE_TIMES
-class BlowUpPuzzle;
+class Puzzle;
class Cursor;
class Encounter;
class MainMenu;
@@ -228,7 +228,7 @@ private:
// Current EventHandler class instance
EventHandler *_handler;
- BlowUpPuzzle *_puzzles[16];
+ Puzzle *_puzzles[16];
// Game data
SharedData _data;
diff --git a/engines/asylum/puzzles/puzzle.cpp b/engines/asylum/puzzles/puzzle.cpp
index a0d4fff5f8..ac2bf47fa4 100644
--- a/engines/asylum/puzzles/puzzle.cpp
+++ b/engines/asylum/puzzles/puzzle.cpp
@@ -36,18 +36,18 @@
namespace Asylum {
-BlowUpPuzzle::BlowUpPuzzle(AsylumEngine *engine): _vm(engine),
+Puzzle::Puzzle(AsylumEngine *engine): _vm(engine),
_cursor(NULL), _bgResource(NULL),
_leftClickUp(false), _leftClickDown(false), _rightClickDown(false), _active(false) {
}
-void BlowUpPuzzle::init() {
+void Puzzle::init() {
// setup cursor & background
_cursor = new Cursor(_vm);
_bgResource = new GraphicResource(_vm, getWorld()->graphicResourceIds[0]);
}
-BlowUpPuzzle::~BlowUpPuzzle() {
+Puzzle::~Puzzle() {
delete _cursor;
delete _bgResource;
diff --git a/engines/asylum/puzzles/puzzle.h b/engines/asylum/puzzles/puzzle.h
index 6f0f138dd9..c35a9784a6 100644
--- a/engines/asylum/puzzles/puzzle.h
+++ b/engines/asylum/puzzles/puzzle.h
@@ -41,23 +41,28 @@ class Cursor;
class GraphicResource;
struct GraphicQueueItem;
-class BlowUpPuzzle : public EventHandler {
+class Puzzle : public EventHandler {
public:
- BlowUpPuzzle(AsylumEngine *engine);
- virtual ~BlowUpPuzzle();
+ Puzzle(AsylumEngine *engine);
+ virtual ~Puzzle();
- void init();
+ virtual void reset() {}
+ //////////////////////////////////////////////////////////////////////////
+ // TODO remove
+ void init();
virtual void open() = 0;
virtual void close() = 0;
-
- virtual void reset() {}
-
bool isActive() { return _active; }
+ //////////////////////////////////////////////////////////////////////////
protected:
AsylumEngine *_vm;
+
+
+ //////////////////////////////////////////////////////////////////////////
+ // TODO remove
Cursor *_cursor;
GraphicResource *_bgResource;
@@ -68,6 +73,7 @@ protected:
virtual void update() {};
void playSound(ResourceId resourceId, bool loop = false);
+ //////////////////////////////////////////////////////////////////////////
};
} // End of namespace Asylum
diff --git a/engines/asylum/puzzles/vcr.cpp b/engines/asylum/puzzles/vcr.cpp
index 00cfc4e6f0..5e2acf8e33 100644
--- a/engines/asylum/puzzles/vcr.cpp
+++ b/engines/asylum/puzzles/vcr.cpp
@@ -41,7 +41,7 @@
namespace Asylum {
-BlowUpPuzzleVCR::BlowUpPuzzleVCR(AsylumEngine *engine): BlowUpPuzzle(engine) {
+PuzzleVCR::PuzzleVCR(AsylumEngine *engine): Puzzle(engine) {
// reset all states
memset(&_jacksState, 0, sizeof(_jacksState));
memset(&_holesState, 0, sizeof(_holesState));
@@ -51,12 +51,12 @@ BlowUpPuzzleVCR::BlowUpPuzzleVCR(AsylumEngine *engine): BlowUpPuzzle(engine) {
_isAccomplished = false;
}
-BlowUpPuzzleVCR::~BlowUpPuzzleVCR() {
+PuzzleVCR::~PuzzleVCR() {
delete _cursor;
delete _bgResource;
}
-void BlowUpPuzzleVCR::open() {
+void PuzzleVCR::open() {
_active = true;
getSound()->stopAll();
@@ -76,12 +76,12 @@ void BlowUpPuzzleVCR::open() {
_rightClickDown = false;
}
-void BlowUpPuzzleVCR::close() {
+void PuzzleVCR::close() {
_active = false;
// TODO Switch back to scene event handler
}
-bool BlowUpPuzzleVCR::handleEvent(const AsylumEvent &ev) {
+bool PuzzleVCR::handleEvent(const AsylumEvent &ev) {
switch (ev.type) {
case Common::EVENT_MOUSEMOVE:
//_cursor->move(ev.mouse.x, ev.mouse.y);
@@ -105,16 +105,16 @@ bool BlowUpPuzzleVCR::handleEvent(const AsylumEvent &ev) {
return true;
}
-void BlowUpPuzzle::playSound(ResourceId resourceId, bool loop) {
+void Puzzle::playSound(ResourceId resourceId, bool loop) {
getSound()->playSound(resourceId, loop, Config.sfxVolume, 0);
}
-int BlowUpPuzzleVCR::inPolyRegion(int x, int y, int polyIdx) const {
+int PuzzleVCR::inPolyRegion(int x, int y, int polyIdx) const {
return x >= BlowUpPuzzleVCRPolies[polyIdx].left && x <= BlowUpPuzzleVCRPolies[polyIdx].right &&
y >= BlowUpPuzzleVCRPolies[polyIdx].top && y <= BlowUpPuzzleVCRPolies[polyIdx].bottom;
}
-void BlowUpPuzzleVCR::update() {
+void PuzzleVCR::update() {
getScreen()->clearGraphicsInQueue();
if (_rightClickDown) { // quits BlowUp Puzzle
@@ -170,7 +170,7 @@ void BlowUpPuzzleVCR::update() {
}
}
-GraphicQueueItem BlowUpPuzzleVCR::getGraphicJackItem(int32 index) {
+GraphicQueueItem PuzzleVCR::getGraphicJackItem(int32 index) {
GraphicQueueItem jackItemOnHand;
int jackY = _cursor->position().y;
@@ -186,7 +186,7 @@ GraphicQueueItem BlowUpPuzzleVCR::getGraphicJackItem(int32 index) {
return jackItemOnHand;
}
-GraphicQueueItem BlowUpPuzzleVCR::getGraphicShadowItem() {
+GraphicQueueItem PuzzleVCR::getGraphicShadowItem() {
GraphicQueueItem shadowItem;
int shadowY = (_cursor->position().y - 356) / 4;
@@ -201,7 +201,7 @@ GraphicQueueItem BlowUpPuzzleVCR::getGraphicShadowItem() {
return shadowItem;
}
-void BlowUpPuzzleVCR::updateJack(Jack jack, const VCRDrawInfo &onTable, const VCRDrawInfo &pluggedOnRed, const VCRDrawInfo &pluggedOnYellow, const VCRDrawInfo &pluggedOnBlack, int32 resourceOnHandIndex) {
+void PuzzleVCR::updateJack(Jack jack, const VCRDrawInfo &onTable, const VCRDrawInfo &pluggedOnRed, const VCRDrawInfo &pluggedOnYellow, const VCRDrawInfo &pluggedOnBlack, int32 resourceOnHandIndex) {
GraphicQueueItem item;
switch (_jacksState[jack]) {
@@ -250,7 +250,7 @@ void BlowUpPuzzleVCR::updateJack(Jack jack, const VCRDrawInfo &onTable, const VC
getScreen()->addGraphicToQueue(item);
}
-void BlowUpPuzzleVCR::updateBlackJack() {
+void PuzzleVCR::updateBlackJack() {
VCRDrawInfo onTable;
onTable.resourceId = 1;
onTable.point = Common::Point(0, 411);
@@ -267,7 +267,7 @@ void BlowUpPuzzleVCR::updateBlackJack() {
updateJack(kBlack, onTable, pluggedOnRed, pluggedOnYellow, pluggedOnBlack, 27);
}
-void BlowUpPuzzleVCR::updateRedJack() {
+void PuzzleVCR::updateRedJack() {
VCRDrawInfo onTable;
onTable.resourceId = 2;
onTable.point = Common::Point(76, 428);
@@ -284,7 +284,7 @@ void BlowUpPuzzleVCR::updateRedJack() {
updateJack(kRed, onTable, pluggedOnRed, pluggedOnYellow, pluggedOnBlack, 25);
}
-void BlowUpPuzzleVCR::updateYellowJack() {
+void PuzzleVCR::updateYellowJack() {
VCRDrawInfo onTable;
onTable.resourceId = 3;
onTable.point = Common::Point(187, 439);
@@ -303,7 +303,7 @@ void BlowUpPuzzleVCR::updateYellowJack() {
// common function to set and unset the jack on holes for each type of jack
-int BlowUpPuzzleVCR::setJackOnHole(int jackType, JackState plugged) {
+int PuzzleVCR::setJackOnHole(int jackType, JackState plugged) {
if (!_holesState[plugged-1]) {
if (_jacksState[jackType-1] == kOnHand) {
_jacksState[jackType-1] = plugged;
@@ -320,7 +320,7 @@ int BlowUpPuzzleVCR::setJackOnHole(int jackType, JackState plugged) {
return 1;
}
-void BlowUpPuzzleVCR::updateButton(Button button, const VCRDrawInfo &btON, const VCRDrawInfo &btDown) {
+void PuzzleVCR::updateButton(Button button, const VCRDrawInfo &btON, const VCRDrawInfo &btDown) {
GraphicQueueItem item;
switch (_buttonsState[button]) {
@@ -347,7 +347,7 @@ void BlowUpPuzzleVCR::updateButton(Button button, const VCRDrawInfo &btON, const
}
-void BlowUpPuzzleVCR::updatePowerButton() {
+void PuzzleVCR::updatePowerButton() {
VCRDrawInfo btON;
btON.resourceId = 17;
btON.point = Common::Point(512, 347);
@@ -359,7 +359,7 @@ void BlowUpPuzzleVCR::updatePowerButton() {
updateButton(kPower, btON, btDown);
}
-void BlowUpPuzzleVCR::updateRewindButton() {
+void PuzzleVCR::updateRewindButton() {
VCRDrawInfo btON;
btON.resourceId = 14;
btON.point = Common::Point(248, 347);
@@ -371,7 +371,7 @@ void BlowUpPuzzleVCR::updateRewindButton() {
updateButton(kRewind, btON, btDown);
}
-void BlowUpPuzzleVCR::updatePlayButton() {
+void PuzzleVCR::updatePlayButton() {
VCRDrawInfo btON;
btON.resourceId = 16;
btON.point = Common::Point(401, 359);
@@ -383,7 +383,7 @@ void BlowUpPuzzleVCR::updatePlayButton() {
updateButton(kPlay, btON, btDown);
}
-void BlowUpPuzzleVCR::updateStopButton() {
+void PuzzleVCR::updateStopButton() {
VCRDrawInfo btON;
btON.resourceId = 15;
btON.point = Common::Point(330, 354);
@@ -396,7 +396,7 @@ void BlowUpPuzzleVCR::updateStopButton() {
}
-void BlowUpPuzzleVCR::updateCursorInPolyRegion() {
+void PuzzleVCR::updateCursorInPolyRegion() {
int showCursor = 0;
if (_jacksState[kBlack] == kOnHand) {
@@ -438,7 +438,7 @@ void BlowUpPuzzleVCR::updateCursorInPolyRegion() {
}
}
-void BlowUpPuzzleVCR::handleMouseDown() {
+void PuzzleVCR::handleMouseDown() {
if (_isAccomplished)
return;
@@ -541,7 +541,7 @@ void BlowUpPuzzleVCR::handleMouseDown() {
}
}
-void BlowUpPuzzleVCR::handleMouseUp() {
+void PuzzleVCR::handleMouseUp() {
if (_isAccomplished)
return;
diff --git a/engines/asylum/puzzles/vcr.h b/engines/asylum/puzzles/vcr.h
index 58ade50c35..de242f77ac 100644
--- a/engines/asylum/puzzles/vcr.h
+++ b/engines/asylum/puzzles/vcr.h
@@ -58,14 +58,15 @@ const Common::Rect BlowUpPuzzleVCRPolies[10] = {
Common::Rect(0x0BB, 0x1B7, 0x0F0, 0x1E0) // yellow jack on table region
};
-class BlowUpPuzzleVCR : public BlowUpPuzzle {
+class PuzzleVCR : public Puzzle {
public:
- BlowUpPuzzleVCR(AsylumEngine *engine);
- ~BlowUpPuzzleVCR();
+ PuzzleVCR(AsylumEngine *engine);
+ ~PuzzleVCR();
bool handleEvent(const AsylumEvent &event);
void open();
void close();
+
private:
enum Jack {
kBlack = 0,
diff --git a/engines/asylum/views/scene.h b/engines/asylum/views/scene.h
index ab9957510b..305d2ef5f1 100644
--- a/engines/asylum/views/scene.h
+++ b/engines/asylum/views/scene.h
@@ -41,7 +41,7 @@ namespace Asylum {
class Actor;
class AsylumEngine;
-class BlowUpPuzzle;
+class Puzzle;
class Cursor;
class GraphicResource;
class Polygons;
Commit: 7321b5cf7320110db5266f8ad718e37ac9705f5f
https://github.com/scummvm/scummvm/commit/7321b5cf7320110db5266f8ad718e37ac9705f5f
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:36+02:00
Commit Message:
ASYLUM: Update engine status comment
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@666 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/asylum.h
diff --git a/engines/asylum/asylum.h b/engines/asylum/asylum.h
index ee630329ba..6d86e845c5 100644
--- a/engines/asylum/asylum.h
+++ b/engines/asylum/asylum.h
@@ -43,18 +43,18 @@
* This is the namespace of the Asylum engine.
*
* Status of this engine:
- * - Code for scrolling and showing up objects and actors (properly clipped) is present
- * - A preliminary script interpreter is implemented, and game scripts are read and partially parsed,
- * actors are now drawn in the scene, and there is some interaction with the environment (e.g. "examine" actions).
+ * - Script interpreters for main game and encounters are implemented
+ * - Object handling, player reaction and special chapter logic is implemented
+ * - Scene parsing and drawing is almost complete
* - Movie code is almost complete
- * - Scene information is partially read, and the scene hotspots are created correctly.
* - Mouse cursor is initialized and animated properly
- * - Game texts and game fonts are read correctly
+ * - Menu handling is mostly done (missing savegame management and movie list)
+ * - Sound code is almost complete (music is still WIP)
+ * - Only one puzzle is partially implemented
* - Preliminary code for walking around with the mouse.
- * - Some of the menu screens are working (like, for example, the credits screen)
*
* Maintainers:
- * alexbevi, alexandrefontoura, bluegr
+ * alexbevi, alexandrefontoura, bluegr, littleboy
*
* Supported games:
* - Sanitarium
Commit: d1235f9a643b8843c244fe89fb0464f51d0e654a
https://github.com/scummvm/scummvm/commit/d1235f9a643b8843c244fe89fb0464f51d0e654a
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:37+02:00
Commit Message:
ASYLUM: Fix Screen::clear()
It was only clearing the current screen and not the backbuffer
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@667 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/system/screen.cpp
engines/asylum/system/screen.h
diff --git a/engines/asylum/system/screen.cpp b/engines/asylum/system/screen.cpp
index f914807639..d57f903ce4 100644
--- a/engines/asylum/system/screen.cpp
+++ b/engines/asylum/system/screen.cpp
@@ -126,8 +126,8 @@ void Screen::draw(ResourceId resourceId, uint32 frameIndex, int32 sourceX, int32
//////////////////////////////////////////////////////////////////////////
// Misc
//////////////////////////////////////////////////////////////////////////
-void Screen::clear() const {
- _vm->_system->fillScreen(0);
+void Screen::clear() {
+ _backBuffer.fillRect(Common::Rect(0, 0, 640, 480), 0);
}
void Screen::drawWideScreenBars(int16 barSize) const {
diff --git a/engines/asylum/system/screen.h b/engines/asylum/system/screen.h
index 6e88082361..84c953de45 100644
--- a/engines/asylum/system/screen.h
+++ b/engines/asylum/system/screen.h
@@ -79,7 +79,7 @@ public:
void draw(ResourceId resourceId, uint32 frameIndex, int32 x, int32 y, int32 flags, ResourceId resourceId2, int32 destX, int32 destY, bool colorKey = true);
// Misc
- void clear() const;
+ void clear();
void drawWideScreenBars(int16 barSize) const;
void fillRect(int32 x, int32 y, int32 x2, int32 y2, int32 color);
void copyBackBufferToScreen();
Commit: 691da08b8d47ae37fa9187da1cab0e1ede87dbcd
https://github.com/scummvm/scummvm/commit/691da08b8d47ae37fa9187da1cab0e1ede87dbcd
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:37+02:00
Commit Message:
ASYLUM: Properly check for index validity in ResourcePack::get
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@668 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/respack.cpp
diff --git a/engines/asylum/respack.cpp b/engines/asylum/respack.cpp
index 97a198247c..0876e294f5 100644
--- a/engines/asylum/respack.cpp
+++ b/engines/asylum/respack.cpp
@@ -85,14 +85,6 @@ ResourcePack::ResourcePack(Common::String filename) {
init(filename);
}
-//ResourcePack::ResourcePack(ResourcePackId id) {
-// // We don't use the file number part of resource IDs
-// //uint32 fileNum = (resourceID >> 16) & 0x7FFF;
-// char filename[20];
-// sprintf(filename, "res.%03d", id);
-// init(filename);
-//}
-
ResourcePack::~ResourcePack() {
for (uint32 i = 0; i < _resources.size(); i++)
delete [] _resources[i].data;
@@ -127,6 +119,9 @@ void ResourcePack::init(Common::String filename) {
}
ResourceEntry *ResourcePack::get(uint16 index) {
+ if (index > _resources.size() - 1)
+ return NULL;
+
if (!_resources[index].data) {
// Load the requested resource if it's not loaded already
_packFile.seek(_resources[index].offset, SEEK_SET);
Commit: 701d31f34faf494e995ad2b304ea491fd038d08e
https://github.com/scummvm/scummvm/commit/701d31f34faf494e995ad2b304ea491fd038d08e
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:37+02:00
Commit Message:
ASYLUM: Check for NULL event handler before calling methods
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@669 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/asylum.cpp
diff --git a/engines/asylum/asylum.cpp b/engines/asylum/asylum.cpp
index b05378e289..3f744f4af9 100644
--- a/engines/asylum/asylum.cpp
+++ b/engines/asylum/asylum.cpp
@@ -150,7 +150,8 @@ Common::Error AsylumEngine::run() {
// Send init event to our default event handler
AsylumEvent initEvt(EVENT_ASYLUM_INIT);
- _handler->handleEvent(initEvt);
+ if (_handler)
+ _handler->handleEvent(initEvt);
// Start running event loop
while (!shouldQuit()) {
@@ -300,12 +301,14 @@ void AsylumEngine::handleEvents() {
}
// Handle key events
- _handler->handleEvent(ev);
+ if (_handler)
+ _handler->handleEvent(ev);
break;
case Common::EVENT_KEYUP:
// Handle key events
- _handler->handleEvent(ev);
+ if (_handler)
+ _handler->handleEvent(ev);
break;
case Common::EVENT_MOUSEMOVE:
@@ -317,7 +320,9 @@ void AsylumEngine::handleEvents() {
case Common::EVENT_MBUTTONDOWN:
// Handle mouse events
_cursor->setState(ev);
- _handler->handleEvent(ev);
+
+ if (_handler)
+ _handler->handleEvent(ev);
break;
case Common::EVENT_QUIT:
@@ -333,7 +338,8 @@ void AsylumEngine::handleEvents() {
// Send update event to our event handler
AsylumEvent updateEvt = AsylumEvent(EVENT_ASYLUM_UPDATE);
- _handler->handleEvent(updateEvt);
+ if (_handler)
+ _handler->handleEvent(updateEvt);
// TODO replace by original game code based on switchEventHandler
processDelayedEvents();
@@ -374,7 +380,7 @@ void AsylumEngine::processDelayedEvents() {
//////////////////////////////////////////////////////////////////////////
void AsylumEngine::switchEventHandler(EventHandler *handler) {
if (handler == NULL)
- error("[AsylumEngine::switchMessageHandler] Invalid handler parameter (cannot be NULL)!");
+ warning("[AsylumEngine::switchMessageHandler] NULL handler parameter (shouldn't happen outside of debug commands)!");
// De-init previous handler
if (_handler != NULL) {
@@ -387,7 +393,8 @@ void AsylumEngine::switchEventHandler(EventHandler *handler) {
// Init new handler
AsylumEvent init(EVENT_ASYLUM_INIT);
- _handler->handleEvent(init);
+ if (_handler)
+ _handler->handleEvent(init);
}
void AsylumEngine::notify(AsylumEventType type) {
Commit: 7a8de08efb5034f673480a43394bd9b7491f27a8
https://github.com/scummvm/scummvm/commit/7a8de08efb5034f673480a43394bd9b7491f27a8
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:37+02:00
Commit Message:
ASYLUM: Add palette and draw debug commands
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@670 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/console.cpp
engines/asylum/console.h
engines/asylum/system/graphics.cpp
engines/asylum/system/graphics.h
diff --git a/engines/asylum/console.cpp b/engines/asylum/console.cpp
index 9979b43234..179678e3eb 100644
--- a/engines/asylum/console.cpp
+++ b/engines/asylum/console.cpp
@@ -31,11 +31,14 @@
#include "asylum/resources/script.h"
#include "asylum/resources/worldstats.h"
+#include "asylum/system/cursor.h"
+#include "asylum/system/graphics.h"
#include "asylum/system/screen.h"
#include "asylum/views/scene.h"
#include "asylum/asylum.h"
+#include "asylum/respack.h"
#include "common/debug-channels.h"
@@ -63,6 +66,9 @@ Console::Console(AsylumEngine *engine) : _vm(engine) {
DCmd_Register("scene", WRAP_METHOD(Console, cmdChangeScene));
DCmd_Register("encounter", WRAP_METHOD(Console, cmdRunEncounter));
+ DCmd_Register("palette", WRAP_METHOD(Console, cmdSetPalette));
+ DCmd_Register("draw", WRAP_METHOD(Console, cmdDrawResource));
+
DCmd_Register("toggle_flag", WRAP_METHOD(Console, cmdToggleFlag));
// Variables
@@ -107,6 +113,9 @@ bool Console::cmdHelp(int, const char **) {
DebugPrintf(" scene - change the scene\n");
DebugPrintf(" encounter - run an encounter\n");
DebugPrintf("\n");
+ DebugPrintf(" palette - set the screen palette\n");
+ DebugPrintf(" draw - draw a resource\n");
+ DebugPrintf("\n");
DebugPrintf(" toggle_flag - toggle a flag\n");
DebugPrintf("\n");
@@ -391,6 +400,82 @@ bool Console::cmdRunEncounter(int32 argc, const char **argv) {
return false;
}
+bool Console::cmdSetPalette(int32 argc, const char **argv) {
+ if (argc != 3) {
+ DebugPrintf("Syntax: %s <pack> <index>\n", argv[0]);
+ return true;
+ }
+
+ uint32 pack = atoi(argv[1]);
+ uint32 index = atoi(argv[2]);
+
+ // Check resource pack
+ if (pack > 18) {
+ DebugPrintf("[Error] Invalid resource pack (was: %d - valid: [0-18])\n", pack);
+ return true;
+ }
+
+ // Try loading resource
+ ResourceId id = MAKE_RESOURCE(pack, index);
+
+ ResourceEntry *entry = getResource()->get(id);
+ if (!entry) {
+ DebugPrintf("[Error] Invalid resource (0x%X)\n", id);
+ return true;
+ }
+
+ getScreen()->setPalette(id);
+
+ return true;
+}
+
+bool Console::cmdDrawResource(int32 argc, const char **argv) {
+ if (argc != 3 && argc != 4) {
+ DebugPrintf("Syntax: %s <pack> <index> (<frame>)\n", argv[0]);
+ return true;
+ }
+
+ uint32 pack = atoi(argv[1]);
+ uint32 index = atoi(argv[2]);
+
+ uint32 frame = 0;
+ if (argc == 4)
+ frame = atoi(argv[3]);
+
+ // Check resource pack
+ if (pack > 18) {
+ DebugPrintf("[Error] Invalid resource pack (was: %d - valid: [0-18])\n", pack);
+ return true;
+ }
+
+ // Try loading resource
+ GraphicResource *resource = new GraphicResource(_vm);
+ if (!resource->load(MAKE_RESOURCE(pack, index))) {
+ DebugPrintf("[Error] Invalid resource index (was: %d)\n", index);
+ return true;
+ }
+
+ if (frame > resource->count() - 1) {
+ DebugPrintf("[Error] Invalid resource frame index (was: %d , max: %d)\n", frame, resource->count() - 1);
+ return true;
+ }
+
+ delete resource;
+
+ // Stop current event handler (to prevent screen refresh)
+ _vm->switchEventHandler(NULL);
+ getCursor()->hide();
+
+ // Draw resource
+ getScreen()->clear();
+ getScreen()->draw(MAKE_RESOURCE(pack, index), frame, 0, 0, 0);
+ getScreen()->copyBackBufferToScreen();
+
+ g_system->updateScreen();
+
+ return false;
+}
+
//////////////////////////////////////////////////////////////////////////
// Flags commands
//////////////////////////////////////////////////////////////////////////
diff --git a/engines/asylum/console.h b/engines/asylum/console.h
index 9d5ce3633f..2113049ff8 100644
--- a/engines/asylum/console.h
+++ b/engines/asylum/console.h
@@ -75,6 +75,9 @@ private:
bool cmdChangeScene(int32 argc, const char **argv);
bool cmdRunEncounter(int32 argc, const char **argv);
+ bool cmdSetPalette(int32 argc, const char **argv);
+ bool cmdDrawResource(int32 argc, const char **argv);
+
bool cmdToggleFlag(int32 argc, const char **argv);
};
diff --git a/engines/asylum/system/graphics.cpp b/engines/asylum/system/graphics.cpp
index 71dadc1558..dff1ba0910 100644
--- a/engines/asylum/system/graphics.cpp
+++ b/engines/asylum/system/graphics.cpp
@@ -32,8 +32,12 @@
namespace Asylum {
+GraphicResource::GraphicResource(AsylumEngine *engine) : _vm(engine), _resourceId(kResourceNone) {
+}
+
GraphicResource::GraphicResource(AsylumEngine *engine, ResourceId id) : _vm(engine), _resourceId(kResourceNone) {
- load(id);
+ if (!load(id))
+ error("[GraphicResource::GraphicResource] Error loading resource (0x%X)", id);
}
GraphicResource::~GraphicResource() {
@@ -43,13 +47,18 @@ GraphicResource::~GraphicResource() {
_vm = NULL;
}
-void GraphicResource::load(ResourceId id) {
+bool GraphicResource::load(ResourceId id) {
// Clear previously loaded data
clear();
ResourceEntry *resEntry = getResource()->get(id);
+ if (!resEntry)
+ return false;
+
_resourceId = id;
init(resEntry->data, resEntry->size);
+
+ return true;
}
void GraphicResource::clear() {
diff --git a/engines/asylum/system/graphics.h b/engines/asylum/system/graphics.h
index a121e7ae13..6e7854babc 100644
--- a/engines/asylum/system/graphics.h
+++ b/engines/asylum/system/graphics.h
@@ -76,11 +76,11 @@ public:
}
};
- GraphicResource(AsylumEngine *engine) {}
+ GraphicResource(AsylumEngine *engine);
GraphicResource(AsylumEngine *engine, ResourceId id);
~GraphicResource();
- void load(ResourceId id);
+ bool load(ResourceId id);
/**
* Copies an animation frame to the target buffer
Commit: c448ae8560b63334a0d09b94052a67eb1add1183
https://github.com/scummvm/scummvm/commit/c448ae8560b63334a0d09b94052a67eb1add1183
Author: Alex Bevilacqua (alexbevi at gmail.com)
Date: 2021-05-17T15:36:37+02:00
Commit Message:
ASYLUM: silence a couple warnings
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@671 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/resources/actor.cpp
engines/asylum/resources/actor.h
diff --git a/engines/asylum/resources/actor.cpp b/engines/asylum/resources/actor.cpp
index 9634ee4014..2ff61bfdee 100644
--- a/engines/asylum/resources/actor.cpp
+++ b/engines/asylum/resources/actor.cpp
@@ -1009,7 +1009,7 @@ bool Actor::process_408B20(Common::Point *point, ActorDirection dir, uint32 coun
return true;
}
-void Actor::process_408D00(ActorDirection direction, uint32 count) {
+void Actor::process_408D00(ActorDirection dir, uint32 count) {
error("[Actor::process_408D00] Not implemented!");
}
diff --git a/engines/asylum/resources/actor.h b/engines/asylum/resources/actor.h
index 2a7c35cf99..68172e66d5 100644
--- a/engines/asylum/resources/actor.h
+++ b/engines/asylum/resources/actor.h
@@ -262,7 +262,7 @@ public:
void process_401830(int32 field980, int32 actionAreaId, int32 field978, int field98C, int32 field990, int32 field974, int32 field984, int32 field988);
bool process_4069B0(int32 *x, int32 *y);
bool process_408B20(Common::Point *point, ActorDirection direction, uint32 count, bool hasDelta);
- void process_408D00(ActorDirection direction, uint32 count);
+ void process_408D00(ActorDirection dir, uint32 count);
void process_41BC00(int32 reactionIndex, int32 numberValue01Add);
void process_41BCC0(int32 reactionIndex, int32 numberValue01Substract);
bool process_41BDB0(int32 reactionIndex, int32 testNumberValue01);
Commit: dc16c2e8790c3ba0d8502cb5be6e17d4a45af351
https://github.com/scummvm/scummvm/commit/dc16c2e8790c3ba0d8502cb5be6e17d4a45af351
Author: Alex Bevilacqua (alexbevi at gmail.com)
Date: 2021-05-17T15:36:37+02:00
Commit Message:
ASYLUM: silence one more warning
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@672 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/resources/encounters.cpp
diff --git a/engines/asylum/resources/encounters.cpp b/engines/asylum/resources/encounters.cpp
index c889dbca17..65592f153d 100644
--- a/engines/asylum/resources/encounters.cpp
+++ b/engines/asylum/resources/encounters.cpp
@@ -662,7 +662,7 @@ void Encounter::updateFromRect(int32 rectIndex) {
}
} else {
uint32 counter = 0;
- for (uint32 i = _data_455BF8 - 1; i > -1; i--) {
+ for (int32 i = (int32)_data_455BF8 - 1; i > -1; i--) {
int32 index = _keywordIndexes[i];
if (counter == 3)
@@ -672,7 +672,7 @@ void Encounter::updateFromRect(int32 rectIndex) {
continue;
if ((_item->keywords[index] & KEYWORD_MASK) && (BYTE1(_item->keywords[index]) & 0x80)) {
- _data_455BF8 = i;
+ _data_455BF8 = (uint32)i;
++counter;
}
}
Commit: a91edc92ebc43a4653fdd8c86f55f7828f888221
https://github.com/scummvm/scummvm/commit/a91edc92ebc43a4653fdd8c86f55f7828f888221
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:38+02:00
Commit Message:
ASYLUM: Update Puzzle to new event handling
- Remove obsolete methods
- Add default key() event handler
- Stub VCR puzzle
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@673 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/asylum.cpp
engines/asylum/puzzles/puzzle.cpp
engines/asylum/puzzles/puzzle.h
engines/asylum/puzzles/vcr.cpp
engines/asylum/puzzles/vcr.h
diff --git a/engines/asylum/asylum.cpp b/engines/asylum/asylum.cpp
index 3f744f4af9..d85a0a8ff2 100644
--- a/engines/asylum/asylum.cpp
+++ b/engines/asylum/asylum.cpp
@@ -412,8 +412,6 @@ EventHandler *AsylumEngine::getPuzzle(uint32 index) {
if (_puzzles[index] == NULL)
error("[AsylumEngine::getPuzzleEventHandler] This puzzle doesn't have an event handler! (index: %d)", index);
- _puzzles[index]->init();
-
return (EventHandler *)_puzzles[index];
}
diff --git a/engines/asylum/puzzles/puzzle.cpp b/engines/asylum/puzzles/puzzle.cpp
index ac2bf47fa4..aac9b90ba0 100644
--- a/engines/asylum/puzzles/puzzle.cpp
+++ b/engines/asylum/puzzles/puzzle.cpp
@@ -29,6 +29,7 @@
#include "asylum/system/cursor.h"
#include "asylum/system/graphics.h"
+#include "asylum/system/screen.h"
#include "asylum/views/scene.h"
@@ -36,23 +37,30 @@
namespace Asylum {
-Puzzle::Puzzle(AsylumEngine *engine): _vm(engine),
- _cursor(NULL), _bgResource(NULL),
- _leftClickUp(false), _leftClickDown(false), _rightClickDown(false), _active(false) {
-}
-
-void Puzzle::init() {
- // setup cursor & background
- _cursor = new Cursor(_vm);
- _bgResource = new GraphicResource(_vm, getWorld()->graphicResourceIds[0]);
+Puzzle::Puzzle(AsylumEngine *engine): _vm(engine) {
}
Puzzle::~Puzzle() {
- delete _cursor;
- delete _bgResource;
-
// Zero passed pointers
_vm = NULL;
}
+//////////////////////////////////////////////////////////////////////////
+// Event Handling
+//////////////////////////////////////////////////////////////////////////
+bool Puzzle::key(const AsylumEvent &evt) {
+ switch (evt.kbd.keycode) {
+ default:
+ break;
+
+ case Common::KEYCODE_TAB:
+ getScreen()->takeScreenshot();
+ break;
+ }
+
+ return true;
+}
+
+
+
} // end of namespace Asylum
diff --git a/engines/asylum/puzzles/puzzle.h b/engines/asylum/puzzles/puzzle.h
index c35a9784a6..3d9fda92df 100644
--- a/engines/asylum/puzzles/puzzle.h
+++ b/engines/asylum/puzzles/puzzle.h
@@ -48,32 +48,16 @@ public:
virtual void reset() {}
- //////////////////////////////////////////////////////////////////////////
- // TODO remove
- void init();
- virtual void open() = 0;
- virtual void close() = 0;
- bool isActive() { return _active; }
- //////////////////////////////////////////////////////////////////////////
-
protected:
AsylumEngine *_vm;
-
-
//////////////////////////////////////////////////////////////////////////
- // TODO remove
- Cursor *_cursor;
- GraphicResource *_bgResource;
-
- bool _leftClickUp;
- bool _leftClickDown;
- bool _rightClickDown;
- bool _active;
-
- virtual void update() {};
- void playSound(ResourceId resourceId, bool loop = false);
+ // Event Handling
//////////////////////////////////////////////////////////////////////////
+ virtual bool init() = 0;
+ virtual bool update() = 0;
+ virtual bool key(const AsylumEvent &evt);
+ virtual bool mouse(const AsylumEvent &evt) = 0;
};
} // End of namespace Asylum
diff --git a/engines/asylum/puzzles/vcr.cpp b/engines/asylum/puzzles/vcr.cpp
index 5e2acf8e33..5e405409a8 100644
--- a/engines/asylum/puzzles/vcr.cpp
+++ b/engines/asylum/puzzles/vcr.cpp
@@ -52,135 +52,144 @@ PuzzleVCR::PuzzleVCR(AsylumEngine *engine): Puzzle(engine) {
}
PuzzleVCR::~PuzzleVCR() {
- delete _cursor;
- delete _bgResource;
}
-void PuzzleVCR::open() {
- _active = true;
-
- getSound()->stopAll();
-
- // Load the graphics palette
- getScreen()->setPalette(getWorld()->graphicResourceIds[29]);
-
- // show blow up puzzle BG
- getScreen()->draw(getWorld()->graphicResourceIds[0], 0, 0, 0, 0);
-
- // Set mouse cursor
- _cursor->set(getWorld()->graphicResourceIds[28]);
- _cursor->show();
-
- _leftClickUp = false;
- _leftClickDown = false;
- _rightClickDown = false;
+//////////////////////////////////////////////////////////////////////////
+// Event Handling
+//////////////////////////////////////////////////////////////////////////
+bool PuzzleVCR::handleEvent(const AsylumEvent &event) {
+ error("[PuzzleVCR::handleEvent] Not implemented!");
}
-void PuzzleVCR::close() {
- _active = false;
- // TODO Switch back to scene event handler
+bool PuzzleVCR::init() {
+ error("[PuzzleVCR::init] Not implemented!");
}
-bool PuzzleVCR::handleEvent(const AsylumEvent &ev) {
- switch (ev.type) {
- case Common::EVENT_MOUSEMOVE:
- //_cursor->move(ev.mouse.x, ev.mouse.y);
- break;
- case Common::EVENT_LBUTTONUP:
- _leftClickUp = true;
- break;
- case Common::EVENT_LBUTTONDOWN:
- _leftClickDown = true;
- break;
- case Common::EVENT_RBUTTONDOWN:
- _rightClickDown = true;
- break;
- default:
- break;
- }
-
- if (_leftClickUp || _leftClickDown)
- update();
+bool PuzzleVCR::update() {
+ error("[PuzzleVCR::update] Not implemented!");
+}
- return true;
+bool PuzzleVCR::key(const AsylumEvent &evt) {
+ error("[PuzzleVCR::key] Not implemented!");
}
-void Puzzle::playSound(ResourceId resourceId, bool loop) {
- getSound()->playSound(resourceId, loop, Config.sfxVolume, 0);
+bool PuzzleVCR::mouse(const AsylumEvent &evt) {
+ error("[PuzzleVCR::mouse] Not implemented!");
}
+//void PuzzleVCR::open() {
+// getSound()->stopAll();
+//
+// // Load the graphics palette
+// getScreen()->setPalette(getWorld()->graphicResourceIds[29]);
+//
+// // show blow up puzzle BG
+// getScreen()->draw(getWorld()->graphicResourceIds[0], 0, 0, 0, 0);
+//
+// // Set mouse cursor
+// getCursor()->set(getWorld()->graphicResourceIds[28]);
+// getCursor()->show();
+//}
+
+//bool PuzzleVCR::handleEvent(const AsylumEvent &ev) {
+// switch (ev.type) {
+// case Common::EVENT_MOUSEMOVE:
+// //getCursor()->move(ev.mouse.x, ev.mouse.y);
+// break;
+// case Common::EVENT_LBUTTONUP:
+// _leftClickUp = true;
+// break;
+// case Common::EVENT_LBUTTONDOWN:
+// _leftClickDown = true;
+// break;
+// case Common::EVENT_RBUTTONDOWN:
+// _rightClickDown = true;
+// break;
+// default:
+// break;
+// }
+//
+// if (_leftClickUp || _leftClickDown)
+// update();
+//
+// return true;
+//}
+
+
int PuzzleVCR::inPolyRegion(int x, int y, int polyIdx) const {
return x >= BlowUpPuzzleVCRPolies[polyIdx].left && x <= BlowUpPuzzleVCRPolies[polyIdx].right &&
y >= BlowUpPuzzleVCRPolies[polyIdx].top && y <= BlowUpPuzzleVCRPolies[polyIdx].bottom;
}
-void PuzzleVCR::update() {
- getScreen()->clearGraphicsInQueue();
-
- if (_rightClickDown) { // quits BlowUp Puzzle
- _rightClickDown = false;
- close();
- getSound()->stopAll();
- }
-
- if (_leftClickDown) {
- _leftClickDown = false;
- handleMouseDown();
- }
-
- if (_leftClickUp) {
- _leftClickUp = false;
- handleMouseUp();
- }
-
- updateCursorInPolyRegion();
-
- updateBlackJack();
- updateRedJack();
- updateYellowJack();
-
- updatePowerButton();
- updateRewindButton();
- updatePlayButton();
- updateStopButton();
-
- if (_buttonsState[kPower] == kON) {
- getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[22], _tvScreenAnimIdx, Common::Point(0, 37), 0, 0, 1);
- getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[23], _tvScreenAnimIdx++, Common::Point(238, 22), 0, 0, 1);
- _tvScreenAnimIdx %= 6;
- }
-
- if (_isAccomplished) {
- getScreen()->drawGraphicsInQueue();
-
- int16 barSize = 0;
- do {
- getScreen()->drawWideScreenBars(barSize);
- barSize += 4;
- } while (barSize < 84);
-
- // TODO: fade palette to gray
-
- getVideo()->playVideo(2);
-
- _isAccomplished = false;
- close();
- } else {
- getScreen()->drawGraphicsInQueue();
- }
-}
+//bool PuzzleVCR::update() {
+// getScreen()->clearGraphicsInQueue();
+//
+// if (_rightClickDown) { // quits BlowUp Puzzle
+// _rightClickDown = false;
+// close();
+// getSound()->stopAll();
+// }
+//
+// if (_leftClickDown) {
+// _leftClickDown = false;
+// handleMouseDown();
+// }
+//
+// if (_leftClickUp) {
+// _leftClickUp = false;
+// handleMouseUp();
+// }
+//
+// updateCursorInPolyRegion();
+//
+// updateBlackJack();
+// updateRedJack();
+// updateYellowJack();
+//
+// updatePowerButton();
+// updateRewindButton();
+// updatePlayButton();
+// updateStopButton();
+//
+// if (_buttonsState[kPower] == kON) {
+// getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[22], _tvScreenAnimIdx, Common::Point(0, 37), 0, 0, 1);
+// getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[23], _tvScreenAnimIdx++, Common::Point(238, 22), 0, 0, 1);
+// _tvScreenAnimIdx %= 6;
+// }
+//
+// if (_isAccomplished) {
+// getScreen()->drawGraphicsInQueue();
+//
+// int16 barSize = 0;
+// do {
+// getScreen()->drawWideScreenBars(barSize);
+// barSize += 4;
+// } while (barSize < 84);
+//
+// // TODO: fade palette to gray
+//
+// getVideo()->playVideo(2);
+//
+// _isAccomplished = false;
+// close();
+// } else {
+// getScreen()->drawGraphicsInQueue();
+// }
+//
+// return true;
+//}
GraphicQueueItem PuzzleVCR::getGraphicJackItem(int32 index) {
GraphicQueueItem jackItemOnHand;
- int jackY = _cursor->position().y;
- if (_cursor->position().y < 356) {
+ int jackY = getCursor()->position().y;
+ if (getCursor()->position().y < 356) {
jackY = 356;
}
jackItemOnHand.resourceId = getWorld()->graphicResourceIds[index];
jackItemOnHand.frameIndex = 0;
- jackItemOnHand.source = Common::Point(_cursor->position().x - 114, jackY - 14);
+ jackItemOnHand.source = Common::Point(getCursor()->position().x - 114, jackY - 14);
jackItemOnHand.priority = 1;
return jackItemOnHand;
@@ -189,13 +198,13 @@ GraphicQueueItem PuzzleVCR::getGraphicJackItem(int32 index) {
GraphicQueueItem PuzzleVCR::getGraphicShadowItem() {
GraphicQueueItem shadowItem;
- int shadowY = (_cursor->position().y - 356) / 4;
- if (_cursor->position().y < 356) {
+ int shadowY = (getCursor()->position().y - 356) / 4;
+ if (getCursor()->position().y < 356) {
shadowY = 0;
}
shadowItem.resourceId = getWorld()->graphicResourceIds[30];
shadowItem.frameIndex = 0;
- shadowItem.source = Common::Point(_cursor->position().x - shadowY, 450);
+ shadowItem.source = Common::Point(getCursor()->position().x - shadowY, 450);
shadowItem.priority = 2;
return shadowItem;
@@ -308,13 +317,13 @@ int PuzzleVCR::setJackOnHole(int jackType, JackState plugged) {
if (_jacksState[jackType-1] == kOnHand) {
_jacksState[jackType-1] = plugged;
_holesState[plugged-1] = jackType; // set jack on red
- playSound(getWorld()->graphicResourceIds[44]);
+ getSound()->playSound(getWorld()->graphicResourceIds[44]);
}
} else if (jackType == 0) {
jackType = _holesState[plugged-1];
_jacksState[jackType-1] = kOnHand;
_holesState[plugged-1] = 0;
- playSound(getWorld()->graphicResourceIds[43]);
+ getSound()->playSound(getWorld()->graphicResourceIds[43]);
return 0;
}
return 1;
@@ -408,33 +417,33 @@ void PuzzleVCR::updateCursorInPolyRegion() {
}
if (!showCursor) {
- if (inPolyRegion(_cursor->position().x, _cursor->position().y, kRewindButton)
- || inPolyRegion(_cursor->position().x, _cursor->position().y, kStopButton)
- || inPolyRegion(_cursor->position().x, _cursor->position().y, kPlayButton)
- || inPolyRegion(_cursor->position().x, _cursor->position().y, kPowerButton)
- || inPolyRegion(_cursor->position().x, _cursor->position().y, kBlackJack)
- || inPolyRegion(_cursor->position().x, _cursor->position().y, kRedJack)
- || inPolyRegion(_cursor->position().x, _cursor->position().y, kYellowJack)) {
- _cursor->animate();
+ if (inPolyRegion(getCursor()->position().x, getCursor()->position().y, kRewindButton)
+ || inPolyRegion(getCursor()->position().x, getCursor()->position().y, kStopButton)
+ || inPolyRegion(getCursor()->position().x, getCursor()->position().y, kPlayButton)
+ || inPolyRegion(getCursor()->position().x, getCursor()->position().y, kPowerButton)
+ || inPolyRegion(getCursor()->position().x, getCursor()->position().y, kBlackJack)
+ || inPolyRegion(getCursor()->position().x, getCursor()->position().y, kRedJack)
+ || inPolyRegion(getCursor()->position().x, getCursor()->position().y, kYellowJack)) {
+ getCursor()->animate();
} else {
- if ((inPolyRegion(_cursor->position().x, _cursor->position().y, kRedHole) && _holesState[kOnTable])
- || (inPolyRegion(_cursor->position().x, _cursor->position().y, kYellowHole) && _holesState[kPluggedOnRed])
- || (inPolyRegion(_cursor->position().x, _cursor->position().y, kBlackHole) && _holesState[kPluggedOnYellow])) {
- if (_cursor->currentFrame != 2) { // reset cursor
- _cursor->show();
- _cursor->set(MAKE_RESOURCE(kResourcePackShared, 2));
- _cursor->animate();
+ if ((inPolyRegion(getCursor()->position().x, getCursor()->position().y, kRedHole) && _holesState[kOnTable])
+ || (inPolyRegion(getCursor()->position().x, getCursor()->position().y, kYellowHole) && _holesState[kPluggedOnRed])
+ || (inPolyRegion(getCursor()->position().x, getCursor()->position().y, kBlackHole) && _holesState[kPluggedOnYellow])) {
+ if (getCursor()->currentFrame != 2) { // reset cursor
+ getCursor()->show();
+ getCursor()->set(MAKE_RESOURCE(kResourcePackShared, 2));
+ getCursor()->animate();
}
} else {
- if (_cursor->currentFrame != 0) { // reset cursor
- _cursor->show();
- _cursor->set(MAKE_RESOURCE(kResourcePackShared, 0));
- _cursor->animate();
+ if (getCursor()->currentFrame != 0) { // reset cursor
+ getCursor()->show();
+ getCursor()->set(MAKE_RESOURCE(kResourcePackShared, 0));
+ getCursor()->animate();
}
}
}
} else {
- _cursor->hide();
+ getCursor()->hide();
}
}
@@ -453,17 +462,17 @@ void PuzzleVCR::handleMouseDown() {
}
// Plug-in jacks
- if (inPolyRegion(_cursor->position().x, _cursor->position().y, kRedHole)) {
+ if (inPolyRegion(getCursor()->position().x, getCursor()->position().y, kRedHole)) {
if (!setJackOnHole(jackType, kPluggedOnRed)) {
return;
}
}
- if (inPolyRegion(_cursor->position().x, _cursor->position().y, kYellowHole)) {
+ if (inPolyRegion(getCursor()->position().x, getCursor()->position().y, kYellowHole)) {
if (!setJackOnHole(jackType, kPluggedOnYellow)) {
return;
}
}
- if (inPolyRegion(_cursor->position().x, _cursor->position().y, kBlackHole)) {
+ if (inPolyRegion(getCursor()->position().x, getCursor()->position().y, kBlackHole)) {
if (!setJackOnHole(jackType, kPluggedOnBlack)) {
// TODO: this will probably segfault!
error("[BlowUpPuzzleVCR::handleMouseDown] Not implemented!");
@@ -479,28 +488,28 @@ void PuzzleVCR::handleMouseDown() {
// Put jacks on table --
if (jackType) {
- if (_cursor->position().x >= (int32)BlowUpPuzzleVCRPolies[kBlackJack].left && _cursor->position().x <= (int32)BlowUpPuzzleVCRPolies[kYellowJack].right
- && _cursor->position().y >= (int32)BlowUpPuzzleVCRPolies[kBlackJack].top && _cursor->position().y <= (int32)BlowUpPuzzleVCRPolies[kYellowJack].bottom) {
+ if (getCursor()->position().x >= (int32)BlowUpPuzzleVCRPolies[kBlackJack].left && getCursor()->position().x <= (int32)BlowUpPuzzleVCRPolies[kYellowJack].right
+ && getCursor()->position().y >= (int32)BlowUpPuzzleVCRPolies[kBlackJack].top && getCursor()->position().y <= (int32)BlowUpPuzzleVCRPolies[kYellowJack].bottom) {
_jacksState[jackType-1] = kOnTable;
- playSound(getWorld()->graphicResourceIds[50]);
- _cursor->show();
+ getSound()->playSound(getWorld()->graphicResourceIds[50]);
+ getCursor()->show();
}
return;
}
// Get Jacks from Table
- if (inPolyRegion(_cursor->position().x, _cursor->position().y, kBlackJack)) {
+ if (inPolyRegion(getCursor()->position().x, getCursor()->position().y, kBlackJack)) {
_jacksState[kBlack] = kOnHand;
- } else if (inPolyRegion(_cursor->position().x, _cursor->position().y, kRedJack)) {
+ } else if (inPolyRegion(getCursor()->position().x, getCursor()->position().y, kRedJack)) {
_jacksState[kRed] = kOnHand;
- } else if (inPolyRegion(_cursor->position().x, _cursor->position().y, kYellowJack)) {
+ } else if (inPolyRegion(getCursor()->position().x, getCursor()->position().y, kYellowJack)) {
_jacksState[kYellow] = kOnHand;
}
// VCR button regions
- if (inPolyRegion(_cursor->position().x, _cursor->position().y, kRewindButton)) {
- playSound(getWorld()->graphicResourceIds[39]);
+ if (inPolyRegion(getCursor()->position().x, getCursor()->position().y, kRewindButton)) {
+ getSound()->playSound(getWorld()->graphicResourceIds[39]);
if (!_buttonsState[kRewind]) {
_buttonsState[kRewind] = kDownON;
return;
@@ -509,8 +518,8 @@ void PuzzleVCR::handleMouseDown() {
_buttonsState[kRewind] = kDownOFF;
return;
}
- } else if (inPolyRegion(_cursor->position().x, _cursor->position().y, kPlayButton)) {
- playSound(getWorld()->graphicResourceIds[39]);
+ } else if (inPolyRegion(getCursor()->position().x, getCursor()->position().y, kPlayButton)) {
+ getSound()->playSound(getWorld()->graphicResourceIds[39]);
if (!_buttonsState[kPlay]) {
_buttonsState[kPlay] = kDownON;
return;
@@ -519,8 +528,8 @@ void PuzzleVCR::handleMouseDown() {
_buttonsState[kPlay] = kDownOFF;
return;
}
- } else if (inPolyRegion(_cursor->position().x, _cursor->position().y, kStopButton)) {
- playSound(getWorld()->graphicResourceIds[39]);
+ } else if (inPolyRegion(getCursor()->position().x, getCursor()->position().y, kStopButton)) {
+ getSound()->playSound(getWorld()->graphicResourceIds[39]);
if (_buttonsState[kStop]) {
if (_buttonsState[kStop] == kON) {
_buttonsState[kStop] = kDownOFF;
@@ -530,8 +539,8 @@ void PuzzleVCR::handleMouseDown() {
_buttonsState[kStop] = kDownON;
return;
}
- } else if (inPolyRegion(_cursor->position().x, _cursor->position().y, kPowerButton)) {
- playSound(getWorld()->graphicResourceIds[39]);
+ } else if (inPolyRegion(getCursor()->position().x, getCursor()->position().y, kPowerButton)) {
+ getSound()->playSound(getWorld()->graphicResourceIds[39]);
if (!_buttonsState[kPower] && _holesState[kPluggedOnYellow] == kRed && _holesState[kOnTable] && _holesState[kPluggedOnRed]) {
_buttonsState[kPower] = kDownON;
@@ -546,7 +555,7 @@ void PuzzleVCR::handleMouseUp() {
return;
if (_buttonsState[kPower] == kDownON) {
- playSound(getWorld()->graphicResourceIds[47], true);
+ getSound()->playSound(getWorld()->graphicResourceIds[47], true);
_buttonsState[kPower] = kON;
_buttonsState[kStop] = kON;
_buttonsState[kPlay] = kON;
@@ -561,7 +570,7 @@ void PuzzleVCR::handleMouseUp() {
if (_buttonsState[kRewind] == kDownOFF) {
_buttonsState[kRewind] = kON;
- playSound(getWorld()->graphicResourceIds[46]);
+ getSound()->playSound(getWorld()->graphicResourceIds[46]);
} else if (_buttonsState[kRewind] == kDownON) {
_buttonsState[kRewind] = kOFF;
}
diff --git a/engines/asylum/puzzles/vcr.h b/engines/asylum/puzzles/vcr.h
index de242f77ac..7a443f4da1 100644
--- a/engines/asylum/puzzles/vcr.h
+++ b/engines/asylum/puzzles/vcr.h
@@ -64,8 +64,6 @@ public:
~PuzzleVCR();
bool handleEvent(const AsylumEvent &event);
- void open();
- void close();
private:
enum Jack {
@@ -117,7 +115,13 @@ private:
int inPolyRegion(int x, int y, int polyIdx) const;
- void update();
+ //////////////////////////////////////////////////////////////////////////
+ // Event Handling
+ //////////////////////////////////////////////////////////////////////////
+ bool init();
+ bool update();
+ bool key(const AsylumEvent &evt);
+ bool mouse(const AsylumEvent &evt);
void updateCursorInPolyRegion();
Commit: 34a6ee87cf910d08ffab966587bda1b213220c84
https://github.com/scummvm/scummvm/commit/34a6ee87cf910d08ffab966587bda1b213220c84
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:38+02:00
Commit Message:
ASYLUM: Add Puzzle::exit() default implementation
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@674 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/puzzles/puzzle.cpp
engines/asylum/puzzles/puzzle.h
engines/asylum/puzzles/vcr.h
diff --git a/engines/asylum/puzzles/puzzle.cpp b/engines/asylum/puzzles/puzzle.cpp
index aac9b90ba0..d05e3d9814 100644
--- a/engines/asylum/puzzles/puzzle.cpp
+++ b/engines/asylum/puzzles/puzzle.cpp
@@ -61,6 +61,11 @@ bool Puzzle::key(const AsylumEvent &evt) {
return true;
}
+void Puzzle::exit() {
+ getScreen()->clear();
+ getScreen()->copyBackBufferToScreen();
+ _vm->switchEventHandler(getScene());
+}
} // end of namespace Asylum
diff --git a/engines/asylum/puzzles/puzzle.h b/engines/asylum/puzzles/puzzle.h
index 3d9fda92df..d8875cce3b 100644
--- a/engines/asylum/puzzles/puzzle.h
+++ b/engines/asylum/puzzles/puzzle.h
@@ -58,6 +58,8 @@ protected:
virtual bool update() = 0;
virtual bool key(const AsylumEvent &evt);
virtual bool mouse(const AsylumEvent &evt) = 0;
+
+ void exit();
};
} // End of namespace Asylum
diff --git a/engines/asylum/puzzles/vcr.h b/engines/asylum/puzzles/vcr.h
index 7a443f4da1..50151142b8 100644
--- a/engines/asylum/puzzles/vcr.h
+++ b/engines/asylum/puzzles/vcr.h
@@ -33,12 +33,6 @@
namespace Asylum {
class AsylumEngine;
-//class Screen;
-//class Sound;
-//class Video;
-//class Cursor;
-//class GraphicResource;
-//struct GraphicQueueItem;
typedef struct VCRDrawInfo {
int32 resourceId;
@@ -58,6 +52,9 @@ const Common::Rect BlowUpPuzzleVCRPolies[10] = {
Common::Rect(0x0BB, 0x1B7, 0x0F0, 0x1E0) // yellow jack on table region
};
+//////////////////////////////////////////////////////////////////////////
+// Puzzle 1
+//////////////////////////////////////////////////////////////////////////
class PuzzleVCR : public Puzzle {
public:
PuzzleVCR(AsylumEngine *engine);
Commit: 574abfd1b2642feaaaa509713838eefece8759e3
https://github.com/scummvm/scummvm/commit/574abfd1b2642feaaaa509713838eefece8759e3
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:38+02:00
Commit Message:
ASYLUM: Add stubs for puzzles
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@675 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
A engines/asylum/puzzles/boardkeyhidesto.cpp
A engines/asylum/puzzles/boardkeyhidesto.h
A engines/asylum/puzzles/boardsalvation.cpp
A engines/asylum/puzzles/boardsalvation.h
A engines/asylum/puzzles/boardyouth.cpp
A engines/asylum/puzzles/boardyouth.h
A engines/asylum/puzzles/clock.cpp
A engines/asylum/puzzles/clock.h
A engines/asylum/puzzles/fisherman.cpp
A engines/asylum/puzzles/fisherman.h
A engines/asylum/puzzles/hivecontrol.cpp
A engines/asylum/puzzles/hivecontrol.h
A engines/asylum/puzzles/hivemachine.cpp
A engines/asylum/puzzles/hivemachine.h
A engines/asylum/puzzles/lock.cpp
A engines/asylum/puzzles/lock.h
A engines/asylum/puzzles/morguedoor.cpp
A engines/asylum/puzzles/morguedoor.h
A engines/asylum/puzzles/pipes.cpp
A engines/asylum/puzzles/pipes.h
A engines/asylum/puzzles/tictactoe.cpp
A engines/asylum/puzzles/tictactoe.h
A engines/asylum/puzzles/timemachine.cpp
A engines/asylum/puzzles/timemachine.h
A engines/asylum/puzzles/wheel.cpp
A engines/asylum/puzzles/wheel.h
A engines/asylum/puzzles/writings.cpp
A engines/asylum/puzzles/writings.h
engines/asylum/asylum.cpp
engines/asylum/module.mk
diff --git a/engines/asylum/asylum.cpp b/engines/asylum/asylum.cpp
index d85a0a8ff2..5dbea867e2 100644
--- a/engines/asylum/asylum.cpp
+++ b/engines/asylum/asylum.cpp
@@ -31,7 +31,21 @@
#include "asylum/resources/special.h"
#include "asylum/resources/worldstats.h"
+#include "asylum/puzzles/boardkeyhidesto.h"
+#include "asylum/puzzles/boardsalvation.h"
+#include "asylum/puzzles/boardyouth.h"
+#include "asylum/puzzles/clock.h"
+#include "asylum/puzzles/fisherman.h"
+#include "asylum/puzzles/hivecontrol.h"
+#include "asylum/puzzles/hivemachine.h"
+#include "asylum/puzzles/lock.h"
+#include "asylum/puzzles/morguedoor.h"
+#include "asylum/puzzles/pipes.h"
+#include "asylum/puzzles/tictactoe.h"
+#include "asylum/puzzles/timemachine.h"
#include "asylum/puzzles/vcr.h"
+#include "asylum/puzzles/wheel.h"
+#include "asylum/puzzles/writings.h"
#include "asylum/system/config.h"
#include "asylum/system/cursor.h"
@@ -417,22 +431,22 @@ EventHandler *AsylumEngine::getPuzzle(uint32 index) {
void AsylumEngine::initPuzzles() {
_puzzles[0] = new PuzzleVCR(this);
- _puzzles[1] = NULL;
- _puzzles[2] = NULL;
- _puzzles[3] = NULL;
- _puzzles[4] = NULL;
- _puzzles[5] = NULL;
- _puzzles[6] = NULL;
- _puzzles[7] = NULL;
- _puzzles[8] = NULL;
- _puzzles[9] = NULL;
- _puzzles[10] = NULL;
- _puzzles[11] = NULL;
- _puzzles[12] = NULL;
- _puzzles[13] = NULL;
- _puzzles[14] = NULL;
- _puzzles[15] = NULL;
- _puzzles[16] = NULL;
+ _puzzles[1] = new PuzzlePipes(this);
+ _puzzles[2] = new PuzzleTicTacToe(this);
+ _puzzles[3] = new PuzzleLock(this);
+ _puzzles[4] = NULL;// No event handler for Puzzle 5
+ _puzzles[5] = new PuzzleWheel(this);
+ _puzzles[6] = new PuzzleBoardSalvation(this);
+ _puzzles[7] = new PuzzleBoardYouth(this);
+ _puzzles[8] = new PuzzleBoardKeyHidesTo(this);
+ _puzzles[9] = new PuzzleWritings(this);
+ _puzzles[10] = new PuzzleClock(this);
+ _puzzles[11] = new PuzzleMorgueDoor(this);
+ _puzzles[12] = NULL; // FIXME Not sure which puzzle this is
+ _puzzles[13] = new PuzzleTimeMachine(this);
+ _puzzles[14] = new PuzzleFisherman(this);
+ _puzzles[15] = new PuzzleHiveMachine(this);
+ _puzzles[16] = new PuzzleHiveControl(this);
warning("[AsylumEngine::initPuzzles] Add missing puzzles!");
}
diff --git a/engines/asylum/module.mk b/engines/asylum/module.mk
index f3d7ec616e..5bc05a3027 100644
--- a/engines/asylum/module.mk
+++ b/engines/asylum/module.mk
@@ -1,8 +1,22 @@
MODULE := engines/asylum
MODULE_OBJS := \
+ puzzles/boardkeyhidesto.o \
+ puzzles/boardsalvation.o \
+ puzzles/boardyouth.o \
+ puzzles/clock.o \
+ puzzles/fisherman.o \
+ puzzles/hivecontrol.o \
+ puzzles/hivemachine.o \
+ puzzles/lock.o \
+ puzzles/morguedoor.o \
+ puzzles/pipes.o \
puzzles/puzzle.o \
+ puzzles/tictactoe.o \
+ puzzles/timemachine.o \
puzzles/vcr.o \
+ puzzles/wheel.o \
+ puzzles/writings.o \
resources/actor.o \
resources/object.o \
resources/encounters.o \
diff --git a/engines/asylum/puzzles/boardkeyhidesto.cpp b/engines/asylum/puzzles/boardkeyhidesto.cpp
new file mode 100644
index 0000000000..fca89ad87d
--- /dev/null
+++ b/engines/asylum/puzzles/boardkeyhidesto.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.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#include "asylum/puzzles/boardkeyhidesto.h"
+
+namespace Asylum {
+
+PuzzleBoardKeyHidesTo::PuzzleBoardKeyHidesTo(AsylumEngine *engine) : Puzzle(engine) {
+}
+
+PuzzleBoardKeyHidesTo::~PuzzleBoardKeyHidesTo() {
+}
+
+//////////////////////////////////////////////////////////////////////////
+// Event Handling
+//////////////////////////////////////////////////////////////////////////
+bool PuzzleBoardKeyHidesTo::handleEvent(const AsylumEvent &event) {
+ error("[PuzzleBoardKeyHidesTo::handleEvent] Not implemented!");
+}
+
+bool PuzzleBoardKeyHidesTo::init() {
+ error("[PuzzleBoardKeyHidesTo::init] Not implemented!");
+}
+
+bool PuzzleBoardKeyHidesTo::update() {
+ error("[PuzzleBoardKeyHidesTo::update] Not implemented!");
+}
+
+bool PuzzleBoardKeyHidesTo::mouse(const AsylumEvent &evt) {
+ error("[PuzzleBoardKeyHidesTo::mouse] Not implemented!");
+}
+
+} // End of namespace Asylum
diff --git a/engines/asylum/puzzles/boardkeyhidesto.h b/engines/asylum/puzzles/boardkeyhidesto.h
new file mode 100644
index 0000000000..f68bb1fece
--- /dev/null
+++ b/engines/asylum/puzzles/boardkeyhidesto.h
@@ -0,0 +1,53 @@
+/* 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.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#ifndef ASYLUM_BOARDKEYHIDESTO_H
+#define ASYLUM_BOARDKEYHIDESTO_H
+
+#include "asylum/puzzles/puzzle.h"
+
+namespace Asylum {
+
+class AsylumEngine;
+
+class PuzzleBoardKeyHidesTo : public Puzzle {
+public:
+ PuzzleBoardKeyHidesTo(AsylumEngine *engine);
+ ~PuzzleBoardKeyHidesTo();
+
+ bool handleEvent(const AsylumEvent &event);
+
+private:
+ //////////////////////////////////////////////////////////////////////////
+ // Event Handling
+ //////////////////////////////////////////////////////////////////////////
+ bool init();
+ bool update();
+ bool mouse(const AsylumEvent &evt);
+};
+
+} // End of namespace Asylum
+
+#endif // ASYLUM_BOARDKEYHIDESTO_H
diff --git a/engines/asylum/puzzles/boardsalvation.cpp b/engines/asylum/puzzles/boardsalvation.cpp
new file mode 100644
index 0000000000..74062a56bd
--- /dev/null
+++ b/engines/asylum/puzzles/boardsalvation.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.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#include "asylum/puzzles/boardsalvation.h"
+
+namespace Asylum {
+
+PuzzleBoardSalvation::PuzzleBoardSalvation(AsylumEngine *engine) : Puzzle(engine) {
+}
+
+PuzzleBoardSalvation::~PuzzleBoardSalvation() {
+}
+
+//////////////////////////////////////////////////////////////////////////
+// Event Handling
+//////////////////////////////////////////////////////////////////////////
+bool PuzzleBoardSalvation::handleEvent(const AsylumEvent &event) {
+ error("[PuzzleBoardSalvation::handleEvent] Not implemented!");
+}
+
+bool PuzzleBoardSalvation::init() {
+ error("[PuzzleBoardSalvation::init] Not implemented!");
+}
+
+bool PuzzleBoardSalvation::update() {
+ error("[PuzzleBoardSalvation::update] Not implemented!");
+}
+
+bool PuzzleBoardSalvation::mouse(const AsylumEvent &evt) {
+ error("[PuzzleBoardSalvation::mouse] Not implemented!");
+}
+
+} // End of namespace Asylum
diff --git a/engines/asylum/puzzles/boardsalvation.h b/engines/asylum/puzzles/boardsalvation.h
new file mode 100644
index 0000000000..df57b91660
--- /dev/null
+++ b/engines/asylum/puzzles/boardsalvation.h
@@ -0,0 +1,53 @@
+/* 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.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#ifndef ASYLUM_BOARDSALVATION_H
+#define ASYLUM_BOARDSALVATION_H
+
+#include "asylum/puzzles/puzzle.h"
+
+namespace Asylum {
+
+class AsylumEngine;
+
+class PuzzleBoardSalvation : public Puzzle {
+public:
+ PuzzleBoardSalvation(AsylumEngine *engine);
+ ~PuzzleBoardSalvation();
+
+ bool handleEvent(const AsylumEvent &event);
+
+private:
+ //////////////////////////////////////////////////////////////////////////
+ // Event Handling
+ //////////////////////////////////////////////////////////////////////////
+ bool init();
+ bool update();
+ bool mouse(const AsylumEvent &evt);
+};
+
+} // End of namespace Asylum
+
+#endif // ASYLUM_BOARDSALVATION_H
diff --git a/engines/asylum/puzzles/boardyouth.cpp b/engines/asylum/puzzles/boardyouth.cpp
new file mode 100644
index 0000000000..c0fd327fb6
--- /dev/null
+++ b/engines/asylum/puzzles/boardyouth.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.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#include "asylum/puzzles/boardyouth.h"
+
+namespace Asylum {
+
+PuzzleBoardYouth::PuzzleBoardYouth(AsylumEngine *engine) : Puzzle(engine) {
+}
+
+PuzzleBoardYouth::~PuzzleBoardYouth() {
+}
+
+//////////////////////////////////////////////////////////////////////////
+// Event Handling
+//////////////////////////////////////////////////////////////////////////
+bool PuzzleBoardYouth::handleEvent(const AsylumEvent &event) {
+ error("[PuzzleBoardYouth::handleEvent] Not implemented!");
+}
+
+bool PuzzleBoardYouth::init() {
+ error("[PuzzleBoardYouth::init] Not implemented!");
+}
+
+bool PuzzleBoardYouth::update() {
+ error("[PuzzleBoardYouth::update] Not implemented!");
+}
+
+bool PuzzleBoardYouth::mouse(const AsylumEvent &evt) {
+ error("[PuzzleBoardYouth::mouse] Not implemented!");
+}
+
+} // End of namespace Asylum
diff --git a/engines/asylum/puzzles/boardyouth.h b/engines/asylum/puzzles/boardyouth.h
new file mode 100644
index 0000000000..539728586a
--- /dev/null
+++ b/engines/asylum/puzzles/boardyouth.h
@@ -0,0 +1,53 @@
+/* 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.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#ifndef ASYLUM_BOARDYOUTH_H
+#define ASYLUM_BOARDYOUTH_H
+
+#include "asylum/puzzles/puzzle.h"
+
+namespace Asylum {
+
+class AsylumEngine;
+
+class PuzzleBoardYouth : public Puzzle {
+public:
+ PuzzleBoardYouth(AsylumEngine *engine);
+ ~PuzzleBoardYouth();
+
+ bool handleEvent(const AsylumEvent &event);
+
+private:
+ //////////////////////////////////////////////////////////////////////////
+ // Event Handling
+ //////////////////////////////////////////////////////////////////////////
+ bool init();
+ bool update();
+ bool mouse(const AsylumEvent &evt);
+};
+
+} // End of namespace Asylum
+
+#endif // ASYLUM_BOARDYOUTH_H
diff --git a/engines/asylum/puzzles/clock.cpp b/engines/asylum/puzzles/clock.cpp
new file mode 100644
index 0000000000..2ccee0008d
--- /dev/null
+++ b/engines/asylum/puzzles/clock.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.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#include "asylum/puzzles/clock.h"
+
+namespace Asylum {
+
+PuzzleClock::PuzzleClock(AsylumEngine *engine) : Puzzle(engine) {
+}
+
+PuzzleClock::~PuzzleClock() {
+}
+
+//////////////////////////////////////////////////////////////////////////
+// Event Handling
+//////////////////////////////////////////////////////////////////////////
+bool PuzzleClock::handleEvent(const AsylumEvent &event) {
+ error("[PuzzleClock::handleEvent] Not implemented!");
+}
+
+bool PuzzleClock::init() {
+ error("[PuzzleClock::init] Not implemented!");
+}
+
+bool PuzzleClock::update() {
+ error("[PuzzleClock::update] Not implemented!");
+}
+
+bool PuzzleClock::mouse(const AsylumEvent &evt) {
+ error("[PuzzleClock::mouse] Not implemented!");
+}
+
+} // End of namespace Asylum
diff --git a/engines/asylum/puzzles/clock.h b/engines/asylum/puzzles/clock.h
new file mode 100644
index 0000000000..717986cca5
--- /dev/null
+++ b/engines/asylum/puzzles/clock.h
@@ -0,0 +1,53 @@
+/* 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.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#ifndef ASYLUM_CLOCK_H
+#define ASYLUM_CLOCK_H
+
+#include "asylum/puzzles/puzzle.h"
+
+namespace Asylum {
+
+class AsylumEngine;
+
+class PuzzleClock : public Puzzle {
+public:
+ PuzzleClock(AsylumEngine *engine);
+ ~PuzzleClock();
+
+ bool handleEvent(const AsylumEvent &event);
+
+private:
+ //////////////////////////////////////////////////////////////////////////
+ // Event Handling
+ //////////////////////////////////////////////////////////////////////////
+ bool init();
+ bool update();
+ bool mouse(const AsylumEvent &evt);
+};
+
+} // End of namespace Asylum
+
+#endif // ASYLUM_CLOCK_H
diff --git a/engines/asylum/puzzles/fisherman.cpp b/engines/asylum/puzzles/fisherman.cpp
new file mode 100644
index 0000000000..36fb594776
--- /dev/null
+++ b/engines/asylum/puzzles/fisherman.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.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#include "asylum/puzzles/fisherman.h"
+
+namespace Asylum {
+
+PuzzleFisherman::PuzzleFisherman(AsylumEngine *engine) : Puzzle(engine) {
+}
+
+PuzzleFisherman::~PuzzleFisherman() {
+}
+
+//////////////////////////////////////////////////////////////////////////
+// Event Handling
+//////////////////////////////////////////////////////////////////////////
+bool PuzzleFisherman::handleEvent(const AsylumEvent &event) {
+ error("[PuzzleFisherman::handleEvent] Not implemented!");
+}
+
+bool PuzzleFisherman::init() {
+ error("[PuzzleFisherman::init] Not implemented!");
+}
+
+bool PuzzleFisherman::update() {
+ error("[PuzzleFisherman::update] Not implemented!");
+}
+
+bool PuzzleFisherman::mouse(const AsylumEvent &evt) {
+ error("[PuzzleFisherman::mouse] Not implemented!");
+}
+
+} // End of namespace Asylum
diff --git a/engines/asylum/puzzles/fisherman.h b/engines/asylum/puzzles/fisherman.h
new file mode 100644
index 0000000000..7b89ce32e1
--- /dev/null
+++ b/engines/asylum/puzzles/fisherman.h
@@ -0,0 +1,53 @@
+/* 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.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#ifndef ASYLUM_FISHERMAN_H
+#define ASYLUM_FISHERMAN_H
+
+#include "asylum/puzzles/puzzle.h"
+
+namespace Asylum {
+
+class AsylumEngine;
+
+class PuzzleFisherman : public Puzzle {
+public:
+ PuzzleFisherman(AsylumEngine *engine);
+ ~PuzzleFisherman();
+
+ bool handleEvent(const AsylumEvent &event);
+
+private:
+ //////////////////////////////////////////////////////////////////////////
+ // Event Handling
+ //////////////////////////////////////////////////////////////////////////
+ bool init();
+ bool update();
+ bool mouse(const AsylumEvent &evt);
+};
+
+} // End of namespace Asylum
+
+#endif // ASYLUM_FISHERMAN_H
diff --git a/engines/asylum/puzzles/hivecontrol.cpp b/engines/asylum/puzzles/hivecontrol.cpp
new file mode 100644
index 0000000000..94750d8ba8
--- /dev/null
+++ b/engines/asylum/puzzles/hivecontrol.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.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#include "asylum/puzzles/hivecontrol.h"
+
+namespace Asylum {
+
+PuzzleHiveControl::PuzzleHiveControl(AsylumEngine *engine) : Puzzle(engine) {
+}
+
+PuzzleHiveControl::~PuzzleHiveControl() {
+}
+
+//////////////////////////////////////////////////////////////////////////
+// Event Handling
+//////////////////////////////////////////////////////////////////////////
+bool PuzzleHiveControl::handleEvent(const AsylumEvent &event) {
+ error("[PuzzleHiveControl::handleEvent] Not implemented!");
+}
+
+bool PuzzleHiveControl::init() {
+ error("[PuzzleHiveControl::init] Not implemented!");
+}
+
+bool PuzzleHiveControl::update() {
+ error("[PuzzleHiveControl::update] Not implemented!");
+}
+
+bool PuzzleHiveControl::mouse(const AsylumEvent &evt) {
+ error("[PuzzleHiveControl::mouse] Not implemented!");
+}
+
+} // End of namespace Asylum
diff --git a/engines/asylum/puzzles/hivecontrol.h b/engines/asylum/puzzles/hivecontrol.h
new file mode 100644
index 0000000000..e6904ff631
--- /dev/null
+++ b/engines/asylum/puzzles/hivecontrol.h
@@ -0,0 +1,53 @@
+/* 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.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#ifndef ASYLUM_HIVECONTROL_H
+#define ASYLUM_HIVECONTROL_H
+
+#include "asylum/puzzles/puzzle.h"
+
+namespace Asylum {
+
+class AsylumEngine;
+
+class PuzzleHiveControl : public Puzzle {
+public:
+ PuzzleHiveControl(AsylumEngine *engine);
+ ~PuzzleHiveControl();
+
+ bool handleEvent(const AsylumEvent &event);
+
+private:
+ //////////////////////////////////////////////////////////////////////////
+ // Event Handling
+ //////////////////////////////////////////////////////////////////////////
+ bool init();
+ bool update();
+ bool mouse(const AsylumEvent &evt);
+};
+
+} // End of namespace Asylum
+
+#endif // ASYLUM_HIVECONTROL_H
diff --git a/engines/asylum/puzzles/hivemachine.cpp b/engines/asylum/puzzles/hivemachine.cpp
new file mode 100644
index 0000000000..4cc35e1fd1
--- /dev/null
+++ b/engines/asylum/puzzles/hivemachine.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.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#include "asylum/puzzles/hivemachine.h"
+
+namespace Asylum {
+
+PuzzleHiveMachine::PuzzleHiveMachine(AsylumEngine *engine) : Puzzle(engine) {
+}
+
+PuzzleHiveMachine::~PuzzleHiveMachine() {
+}
+
+//////////////////////////////////////////////////////////////////////////
+// Event Handling
+//////////////////////////////////////////////////////////////////////////
+bool PuzzleHiveMachine::handleEvent(const AsylumEvent &event) {
+ error("[PuzzleHiveMachine::handleEvent] Not implemented!");
+}
+
+bool PuzzleHiveMachine::init() {
+ error("[PuzzleHiveMachine::init] Not implemented!");
+}
+
+bool PuzzleHiveMachine::update() {
+ error("[PuzzleHiveMachine::update] Not implemented!");
+}
+
+bool PuzzleHiveMachine::mouse(const AsylumEvent &evt) {
+ error("[PuzzleHiveMachine::mouse] Not implemented!");
+}
+
+} // End of namespace Asylum
diff --git a/engines/asylum/puzzles/hivemachine.h b/engines/asylum/puzzles/hivemachine.h
new file mode 100644
index 0000000000..bcae852ecc
--- /dev/null
+++ b/engines/asylum/puzzles/hivemachine.h
@@ -0,0 +1,53 @@
+/* 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.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#ifndef ASYLUM_HIVEMACHINE_H
+#define ASYLUM_HIVEMACHINE_H
+
+#include "asylum/puzzles/puzzle.h"
+
+namespace Asylum {
+
+class AsylumEngine;
+
+class PuzzleHiveMachine : public Puzzle {
+public:
+ PuzzleHiveMachine(AsylumEngine *engine);
+ ~PuzzleHiveMachine();
+
+ bool handleEvent(const AsylumEvent &event);
+
+private:
+ //////////////////////////////////////////////////////////////////////////
+ // Event Handling
+ //////////////////////////////////////////////////////////////////////////
+ bool init();
+ bool update();
+ bool mouse(const AsylumEvent &evt);
+};
+
+} // End of namespace Asylum
+
+#endif // ASYLUM_HIVEMACHINE_H
diff --git a/engines/asylum/puzzles/lock.cpp b/engines/asylum/puzzles/lock.cpp
new file mode 100644
index 0000000000..86b95046eb
--- /dev/null
+++ b/engines/asylum/puzzles/lock.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.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#include "asylum/puzzles/lock.h"
+
+namespace Asylum {
+
+PuzzleLock::PuzzleLock(AsylumEngine *engine) : Puzzle(engine) {
+}
+
+PuzzleLock::~PuzzleLock() {
+}
+
+//////////////////////////////////////////////////////////////////////////
+// Event Handling
+//////////////////////////////////////////////////////////////////////////
+bool PuzzleLock::handleEvent(const AsylumEvent &event) {
+ error("[PuzzleLock::handleEvent] Not implemented!");
+}
+
+bool PuzzleLock::init() {
+ error("[PuzzleLock::init] Not implemented!");
+}
+
+bool PuzzleLock::update() {
+ error("[PuzzleLock::update] Not implemented!");
+}
+
+bool PuzzleLock::mouse(const AsylumEvent &evt) {
+ error("[PuzzleLock::mouse] Not implemented!");
+}
+
+} // End of namespace Asylum
diff --git a/engines/asylum/puzzles/lock.h b/engines/asylum/puzzles/lock.h
new file mode 100644
index 0000000000..23529b5cb3
--- /dev/null
+++ b/engines/asylum/puzzles/lock.h
@@ -0,0 +1,53 @@
+/* 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.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#ifndef ASYLUM_LOCK_H
+#define ASYLUM_LOCK_H
+
+#include "asylum/puzzles/puzzle.h"
+
+namespace Asylum {
+
+class AsylumEngine;
+
+class PuzzleLock : public Puzzle {
+public:
+ PuzzleLock(AsylumEngine *engine);
+ ~PuzzleLock();
+
+ bool handleEvent(const AsylumEvent &event);
+
+private:
+ //////////////////////////////////////////////////////////////////////////
+ // Event Handling
+ //////////////////////////////////////////////////////////////////////////
+ bool init();
+ bool update();
+ bool mouse(const AsylumEvent &evt);
+};
+
+} // End of namespace Asylum
+
+#endif // ASYLUM_LOCK_H
diff --git a/engines/asylum/puzzles/morguedoor.cpp b/engines/asylum/puzzles/morguedoor.cpp
new file mode 100644
index 0000000000..3395e5a050
--- /dev/null
+++ b/engines/asylum/puzzles/morguedoor.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.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#include "asylum/puzzles/morguedoor.h"
+
+namespace Asylum {
+
+PuzzleMorgueDoor::PuzzleMorgueDoor(AsylumEngine *engine) : Puzzle(engine) {
+}
+
+PuzzleMorgueDoor::~PuzzleMorgueDoor() {
+}
+
+//////////////////////////////////////////////////////////////////////////
+// Event Handling
+//////////////////////////////////////////////////////////////////////////
+bool PuzzleMorgueDoor::handleEvent(const AsylumEvent &event) {
+ error("[PuzzleMorgueDoor::handleEvent] Not implemented!");
+}
+
+bool PuzzleMorgueDoor::init() {
+ error("[PuzzleMorgueDoor::init] Not implemented!");
+}
+
+bool PuzzleMorgueDoor::update() {
+ error("[PuzzleMorgueDoor::update] Not implemented!");
+}
+
+bool PuzzleMorgueDoor::mouse(const AsylumEvent &evt) {
+ error("[PuzzleMorgueDoor::mouse] Not implemented!");
+}
+
+} // End of namespace Asylum
diff --git a/engines/asylum/puzzles/morguedoor.h b/engines/asylum/puzzles/morguedoor.h
new file mode 100644
index 0000000000..04b8f389a5
--- /dev/null
+++ b/engines/asylum/puzzles/morguedoor.h
@@ -0,0 +1,53 @@
+/* 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.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#ifndef ASYLUM_MORGUEDOOR_H
+#define ASYLUM_MORGUEDOOR_H
+
+#include "asylum/puzzles/puzzle.h"
+
+namespace Asylum {
+
+class AsylumEngine;
+
+class PuzzleMorgueDoor : public Puzzle {
+public:
+ PuzzleMorgueDoor(AsylumEngine *engine);
+ ~PuzzleMorgueDoor();
+
+ bool handleEvent(const AsylumEvent &event);
+
+private:
+ //////////////////////////////////////////////////////////////////////////
+ // Event Handling
+ //////////////////////////////////////////////////////////////////////////
+ bool init();
+ bool update();
+ bool mouse(const AsylumEvent &evt);
+};
+
+} // End of namespace Asylum
+
+#endif // ASYLUM_MORGUEDOOR_H
diff --git a/engines/asylum/puzzles/pipes.cpp b/engines/asylum/puzzles/pipes.cpp
new file mode 100644
index 0000000000..23350b40db
--- /dev/null
+++ b/engines/asylum/puzzles/pipes.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.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#include "asylum/puzzles/pipes.h"
+
+namespace Asylum {
+
+PuzzlePipes::PuzzlePipes(AsylumEngine *engine) : Puzzle(engine) {
+}
+
+PuzzlePipes::~PuzzlePipes() {
+}
+
+//////////////////////////////////////////////////////////////////////////
+// Event Handling
+//////////////////////////////////////////////////////////////////////////
+bool PuzzlePipes::handleEvent(const AsylumEvent &event) {
+ error("[PuzzlePipes::handleEvent] Not implemented!");
+}
+
+bool PuzzlePipes::init() {
+ error("[PuzzlePipes::init] Not implemented!");
+}
+
+bool PuzzlePipes::update() {
+ error("[PuzzlePipes::update] Not implemented!");
+}
+
+bool PuzzlePipes::mouse(const AsylumEvent &evt) {
+ error("[PuzzlePipes::mouse] Not implemented!");
+}
+
+} // End of namespace Asylum
diff --git a/engines/asylum/puzzles/pipes.h b/engines/asylum/puzzles/pipes.h
new file mode 100644
index 0000000000..0341e01a24
--- /dev/null
+++ b/engines/asylum/puzzles/pipes.h
@@ -0,0 +1,53 @@
+/* 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.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#ifndef ASYLUM_PIPES_H
+#define ASYLUM_PIPES_H
+
+#include "asylum/puzzles/puzzle.h"
+
+namespace Asylum {
+
+class AsylumEngine;
+
+class PuzzlePipes : public Puzzle {
+public:
+ PuzzlePipes(AsylumEngine *engine);
+ ~PuzzlePipes();
+
+ bool handleEvent(const AsylumEvent &event);
+
+private:
+ //////////////////////////////////////////////////////////////////////////
+ // Event Handling
+ //////////////////////////////////////////////////////////////////////////
+ bool init();
+ bool update();
+ bool mouse(const AsylumEvent &evt);
+};
+
+} // End of namespace Asylum
+
+#endif // ASYLUM_PIPES_H
diff --git a/engines/asylum/puzzles/tictactoe.cpp b/engines/asylum/puzzles/tictactoe.cpp
new file mode 100644
index 0000000000..ddf68ac277
--- /dev/null
+++ b/engines/asylum/puzzles/tictactoe.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.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#include "asylum/puzzles/tictactoe.h"
+
+namespace Asylum {
+
+PuzzleTicTacToe::PuzzleTicTacToe(AsylumEngine *engine) : Puzzle(engine) {
+}
+
+PuzzleTicTacToe::~PuzzleTicTacToe() {
+}
+
+//////////////////////////////////////////////////////////////////////////
+// Event Handling
+//////////////////////////////////////////////////////////////////////////
+bool PuzzleTicTacToe::handleEvent(const AsylumEvent &event) {
+ error("[PuzzleTicTacToe::handleEvent] Not implemented!");
+}
+
+bool PuzzleTicTacToe::init() {
+ error("[PuzzleTicTacToe::init] Not implemented!");
+}
+
+bool PuzzleTicTacToe::update() {
+ error("[PuzzleTicTacToe::update] Not implemented!");
+}
+
+bool PuzzleTicTacToe::mouse(const AsylumEvent &evt) {
+ error("[PuzzleTicTacToe::mouse] Not implemented!");
+}
+
+} // End of namespace Asylum
diff --git a/engines/asylum/puzzles/tictactoe.h b/engines/asylum/puzzles/tictactoe.h
new file mode 100644
index 0000000000..050f22ed9c
--- /dev/null
+++ b/engines/asylum/puzzles/tictactoe.h
@@ -0,0 +1,53 @@
+/* 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.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#ifndef ASYLUM_TICTACTOE_H
+#define ASYLUM_TICTACTOE_H
+
+#include "asylum/puzzles/puzzle.h"
+
+namespace Asylum {
+
+class AsylumEngine;
+
+class PuzzleTicTacToe : public Puzzle {
+public:
+ PuzzleTicTacToe(AsylumEngine *engine);
+ ~PuzzleTicTacToe();
+
+ bool handleEvent(const AsylumEvent &event);
+
+private:
+ //////////////////////////////////////////////////////////////////////////
+ // Event Handling
+ //////////////////////////////////////////////////////////////////////////
+ bool init();
+ bool update();
+ bool mouse(const AsylumEvent &evt);
+};
+
+} // End of namespace Asylum
+
+#endif // ASYLUM_TICTACTOE_H
diff --git a/engines/asylum/puzzles/timemachine.cpp b/engines/asylum/puzzles/timemachine.cpp
new file mode 100644
index 0000000000..ae1a6bc325
--- /dev/null
+++ b/engines/asylum/puzzles/timemachine.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.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#include "asylum/puzzles/timemachine.h"
+
+namespace Asylum {
+
+PuzzleTimeMachine::PuzzleTimeMachine(AsylumEngine *engine) : Puzzle(engine) {
+}
+
+PuzzleTimeMachine::~PuzzleTimeMachine() {
+}
+
+//////////////////////////////////////////////////////////////////////////
+// Event Handling
+//////////////////////////////////////////////////////////////////////////
+bool PuzzleTimeMachine::handleEvent(const AsylumEvent &event) {
+ error("[PuzzleTimeMachine::handleEvent] Not implemented!");
+}
+
+bool PuzzleTimeMachine::init() {
+ error("[PuzzleTimeMachine::init] Not implemented!");
+}
+
+bool PuzzleTimeMachine::update() {
+ error("[PuzzleTimeMachine::update] Not implemented!");
+}
+
+bool PuzzleTimeMachine::mouse(const AsylumEvent &evt) {
+ error("[PuzzleTimeMachine::mouse] Not implemented!");
+}
+
+} // End of namespace Asylum
diff --git a/engines/asylum/puzzles/timemachine.h b/engines/asylum/puzzles/timemachine.h
new file mode 100644
index 0000000000..57fe4090da
--- /dev/null
+++ b/engines/asylum/puzzles/timemachine.h
@@ -0,0 +1,53 @@
+/* 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.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#ifndef ASYLUM_TIMEMACHINE_H
+#define ASYLUM_TIMEMACHINE_H
+
+#include "asylum/puzzles/puzzle.h"
+
+namespace Asylum {
+
+class AsylumEngine;
+
+class PuzzleTimeMachine : public Puzzle {
+public:
+ PuzzleTimeMachine(AsylumEngine *engine);
+ ~PuzzleTimeMachine();
+
+ bool handleEvent(const AsylumEvent &event);
+
+private:
+ //////////////////////////////////////////////////////////////////////////
+ // Event Handling
+ //////////////////////////////////////////////////////////////////////////
+ bool init();
+ bool update();
+ bool mouse(const AsylumEvent &evt);
+};
+
+} // End of namespace Asylum
+
+#endif // ASYLUM_TIMEMACHINE_H
diff --git a/engines/asylum/puzzles/wheel.cpp b/engines/asylum/puzzles/wheel.cpp
new file mode 100644
index 0000000000..3e4c3b9295
--- /dev/null
+++ b/engines/asylum/puzzles/wheel.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.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#include "asylum/puzzles/wheel.h"
+
+namespace Asylum {
+
+PuzzleWheel::PuzzleWheel(AsylumEngine *engine) : Puzzle(engine) {
+}
+
+PuzzleWheel::~PuzzleWheel() {
+}
+
+//////////////////////////////////////////////////////////////////////////
+// Event Handling
+//////////////////////////////////////////////////////////////////////////
+bool PuzzleWheel::handleEvent(const AsylumEvent &event) {
+ error("[PuzzleWheel::handleEvent] Not implemented!");
+}
+
+bool PuzzleWheel::init() {
+ error("[PuzzleWheel::init] Not implemented!");
+}
+
+bool PuzzleWheel::update() {
+ error("[PuzzleWheel::update] Not implemented!");
+}
+
+bool PuzzleWheel::mouse(const AsylumEvent &evt) {
+ error("[PuzzleWheel::mouse] Not implemented!");
+}
+
+} // End of namespace Asylum
diff --git a/engines/asylum/puzzles/wheel.h b/engines/asylum/puzzles/wheel.h
new file mode 100644
index 0000000000..f4daf408b0
--- /dev/null
+++ b/engines/asylum/puzzles/wheel.h
@@ -0,0 +1,53 @@
+/* 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.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#ifndef ASYLUM_WHEEL_H
+#define ASYLUM_WHEEL_H
+
+#include "asylum/puzzles/puzzle.h"
+
+namespace Asylum {
+
+class AsylumEngine;
+
+class PuzzleWheel : public Puzzle {
+public:
+ PuzzleWheel(AsylumEngine *engine);
+ ~PuzzleWheel();
+
+ bool handleEvent(const AsylumEvent &event);
+
+private:
+ //////////////////////////////////////////////////////////////////////////
+ // Event Handling
+ //////////////////////////////////////////////////////////////////////////
+ bool init();
+ bool update();
+ bool mouse(const AsylumEvent &evt);
+};
+
+} // End of namespace Asylum
+
+#endif // ASYLUM_WHEEL_H
diff --git a/engines/asylum/puzzles/writings.cpp b/engines/asylum/puzzles/writings.cpp
new file mode 100644
index 0000000000..db08a67c24
--- /dev/null
+++ b/engines/asylum/puzzles/writings.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.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#include "asylum/puzzles/writings.h"
+
+namespace Asylum {
+
+PuzzleWritings::PuzzleWritings(AsylumEngine *engine) : Puzzle(engine) {
+}
+
+PuzzleWritings::~PuzzleWritings() {
+}
+
+//////////////////////////////////////////////////////////////////////////
+// Event Handling
+//////////////////////////////////////////////////////////////////////////
+bool PuzzleWritings::handleEvent(const AsylumEvent &event) {
+ error("[PuzzleWritings::handleEvent] Not implemented!");
+}
+
+bool PuzzleWritings::init() {
+ error("[PuzzleWritings::init] Not implemented!");
+}
+
+bool PuzzleWritings::update() {
+ error("[PuzzleWritings::update] Not implemented!");
+}
+
+bool PuzzleWritings::mouse(const AsylumEvent &evt) {
+ error("[PuzzleWritings::mouse] Not implemented!");
+}
+
+} // End of namespace Asylum
diff --git a/engines/asylum/puzzles/writings.h b/engines/asylum/puzzles/writings.h
new file mode 100644
index 0000000000..c5e72007c1
--- /dev/null
+++ b/engines/asylum/puzzles/writings.h
@@ -0,0 +1,53 @@
+/* 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.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#ifndef ASYLUM_WRITINGS_H
+#define ASYLUM_WRITINGS_H
+
+#include "asylum/puzzles/puzzle.h"
+
+namespace Asylum {
+
+class AsylumEngine;
+
+class PuzzleWritings : public Puzzle {
+public:
+ PuzzleWritings(AsylumEngine *engine);
+ ~PuzzleWritings();
+
+ bool handleEvent(const AsylumEvent &event);
+
+private:
+ //////////////////////////////////////////////////////////////////////////
+ // Event Handling
+ //////////////////////////////////////////////////////////////////////////
+ bool init();
+ bool update();
+ bool mouse(const AsylumEvent &evt);
+};
+
+} // End of namespace Asylum
+
+#endif // ASYLUM_WRITINGS_H
Commit: d45a2fd4a1a4db51f54b06fc654119ab26f6af7d
https://github.com/scummvm/scummvm/commit/d45a2fd4a1a4db51f54b06fc654119ab26f6af7d
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:38+02:00
Commit Message:
ASYLUM: Copy backbuffer to screen in Screen::clear()
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@676 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/puzzles/puzzle.cpp
engines/asylum/system/screen.cpp
diff --git a/engines/asylum/puzzles/puzzle.cpp b/engines/asylum/puzzles/puzzle.cpp
index d05e3d9814..6bc94d8417 100644
--- a/engines/asylum/puzzles/puzzle.cpp
+++ b/engines/asylum/puzzles/puzzle.cpp
@@ -63,7 +63,6 @@ bool Puzzle::key(const AsylumEvent &evt) {
void Puzzle::exit() {
getScreen()->clear();
- getScreen()->copyBackBufferToScreen();
_vm->switchEventHandler(getScene());
}
diff --git a/engines/asylum/system/screen.cpp b/engines/asylum/system/screen.cpp
index d57f903ce4..c5ed491d4f 100644
--- a/engines/asylum/system/screen.cpp
+++ b/engines/asylum/system/screen.cpp
@@ -128,6 +128,7 @@ void Screen::draw(ResourceId resourceId, uint32 frameIndex, int32 sourceX, int32
//////////////////////////////////////////////////////////////////////////
void Screen::clear() {
_backBuffer.fillRect(Common::Rect(0, 0, 640, 480), 0);
+ copyBackBufferToScreen();
}
void Screen::drawWideScreenBars(int16 barSize) const {
Commit: 54381ad846dee43ffe7a0473ec71eae07b05c1c9
https://github.com/scummvm/scummvm/commit/54381ad846dee43ffe7a0473ec71eae07b05c1c9
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:38+02:00
Commit Message:
ASYLUM: Implement most savegame handling (except actual write & read)
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@677 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/asylum.cpp
engines/asylum/resources/data.h
engines/asylum/resources/script.h
engines/asylum/shared.h
engines/asylum/system/savegame.cpp
engines/asylum/system/savegame.h
engines/asylum/views/menu.cpp
engines/asylum/views/menu.h
diff --git a/engines/asylum/asylum.cpp b/engines/asylum/asylum.cpp
index 5dbea867e2..07feb1bcf6 100644
--- a/engines/asylum/asylum.cpp
+++ b/engines/asylum/asylum.cpp
@@ -289,7 +289,7 @@ void AsylumEngine::playIntro() {
_cursor->show();
- _savegame->loadViewedMovies();
+ _savegame->loadMoviesViewed();
// Switch to scene event handling
switchEventHandler(_scene);
diff --git a/engines/asylum/resources/data.h b/engines/asylum/resources/data.h
index 87fa83f337..81cc7ec765 100644
--- a/engines/asylum/resources/data.h
+++ b/engines/asylum/resources/data.h
@@ -105,8 +105,9 @@ enum GlobalFlag {
struct SharedData {
public:
SharedData() {
+ cdNumber = 0;
_actorEnableForStatus7 = false;
- _flag1 = false;
+ _flag1 = false;
_matteBarHeight = 0;
_matteVar2 = 0;
_sceneCounter = 0;
@@ -145,6 +146,8 @@ public:
_nextScreenUpdate = 0;
}
+ int32 cdNumber;
+
// Saved scene data
ResourceId cursorResources[11];
// 2 ResourceId unused
diff --git a/engines/asylum/resources/script.h b/engines/asylum/resources/script.h
index ecc2719c29..f39dd243be 100644
--- a/engines/asylum/resources/script.h
+++ b/engines/asylum/resources/script.h
@@ -146,14 +146,19 @@ public:
void queueScript(int32 scriptIndex, ActorIndex actorIndex);
/**
- * Query if 'scriptIndex' is in queue.
+ * Query if 'scriptIndex' is in queue.
*
- * @param scriptIndex Zero-based index of the script.
+ * @param scriptIndex Zero-based index of the script.
*
- * @return true if in queue, false if not.
+ * @return true if in queue, false if not.
*/
bool isInQueue(int32 scriptIndex);
+ /**
+ * Resets the queue.
+ */
+ void resetQueue();
+
// Accessors
int32 getDelayedVideoIndex() const { return _delayedVideoIndex; }
void setDelayedVideoIndex(int32 val) { _delayedVideoIndex = val; }
@@ -252,11 +257,6 @@ private:
int32 _lineIncrement;
bool _waitCycle;
- /**
- * Resets the queue.
- */
- void resetQueue();
-
// Opcode helper functions
void enableObject(ScriptEntry *cmd, ObjectEnableType type);
void setActionFlag(ScriptEntry *cmd, ActionType flag); //|
diff --git a/engines/asylum/shared.h b/engines/asylum/shared.h
index 75d877115c..8f4de6c95e 100644
--- a/engines/asylum/shared.h
+++ b/engines/asylum/shared.h
@@ -606,6 +606,7 @@ enum ObjectFlag {
// Engine subclasses
#define getEncounter() _vm->encounter()
#define getCursor() _vm->cursor()
+#define getMenu() _vm->menu()
#define getResource() _vm->resource()
#define getSound() _vm->sound()
#define getSaveLoad() _vm->savegame()
diff --git a/engines/asylum/system/savegame.cpp b/engines/asylum/system/savegame.cpp
index f56c7c6c83..1a65c44284 100644
--- a/engines/asylum/system/savegame.cpp
+++ b/engines/asylum/system/savegame.cpp
@@ -25,52 +25,268 @@
#include "asylum/system/savegame.h"
+#include "asylum/resources/script.h"
+#include "asylum/resources/worldstats.h"
+
+#include "asylum/system/cursor.h"
+#include "asylum/system/screen.h"
+#include "asylum/system/sound.h"
+#include "asylum/system/text.h"
+
+#include "asylum/views/menu.h"
+#include "asylum/views/scene.h"
+
#include "asylum/asylum.h"
+#include "common/file.h"
+
namespace Asylum {
-Savegame::Savegame(AsylumEngine *engine) : _vm(engine) {
+#define SAVEGAME_BUILD 851
+#define SAVEGAME_VERSION_SIZE 11
+
+#define SAVEGAME_NAME "asylum"
+#define SAVEGAME_QUICKSLOT 25
+
+#define SAVEGAME_MOVIES "asylum.movies"
+
+const char savegame_version[12] = "v1.01 FINAL";
+
+Savegame::Savegame(AsylumEngine *engine) : _vm(engine), _index(0), _valid(false) {
memset(&_moviesViewed, 0, sizeof(_moviesViewed));
+ memset(&_savegames, 0, sizeof(_savegames));
+ memset(&_savegameToScene, 0, sizeof(_savegameToScene));
}
Savegame::~Savegame() {
+ // Zero passed pointers
+ _vm = NULL;
}
-bool Savegame::setup() {
- warning("[Savegame::setup] Not implemented!");
+bool Savegame::hasSavegames() {
+ for (uint i = 0; i < SAVEGAME_COUNT; i++)
+ if (isSavegamePresent(getFilename(i)))
+ return true;
- return true;
+ return false;
}
void Savegame::loadList() {
- warning("[Savegame::loadList] Not implemented!");
-}
+ for (uint32 i = 0; i < SAVEGAME_COUNT; i++) {
+ if (isSavegamePresent(getFilename(i))) {
+ Common::InSaveFile *file = g_system->getSavefileManager()->openForLoading(getFilename(i));
+ if (!file)
+ error("[Savegame::loadList] Cannot open savegame: %s", getFilename(i).c_str());
+ read(file, (byte *)&_savegameToScene[i], 4, 1, "Level");
+ read(file, (byte *)&_names[i], 1, 45, "Game Name");
+ _savegames[i] = true;
+
+ delete file;
+ } else {
+ _names[i] = getText()->get(MAKE_RESOURCE(kResourcePackText, 1324));
+ _savegames[i] = false;
+ }
+ }
+}
bool Savegame::load() {
- warning("[Savegame::load] Not implemented!");
+ if (!check()) {
+ getMenu()->setDword455C78(true);
+ getMenu()->setDword455C80(false);
- return false;
+ return false;
+ }
+
+ getCursor()->hide();
+ // Original clears the graphic cache
+ getScript()->resetQueue();
+ getSound()->playMusic(kResourceNone, 0);
+ getScene()->load((ResourcePackId)(_savegameToScene[_index] + 4));
+ _vm->reset();
+ // Original loads encounter data
+
+ if (!loadData(getFilename(_index))) {
+ // FIXME convert to GUI dialog
+ if (_valid)
+ error("[Savegame::load] Could not load game!");
+ else
+ error("[Savegame::load] Trying to load a game for a different version of Sanitarium!");
+ }
+
+ loadMoviesViewed();
+
+ getMenu()->setDword455C80(false);
+
+ getScreen()->clear();
+
+ return true;
}
bool Savegame::quickLoad() {
- warning("[Savegame::quickLoad] Not implemented!");
+ if (!isSavegamePresent(getFilename(SAVEGAME_QUICKSLOT)))
+ return false;
- return false;
+ _index = SAVEGAME_QUICKSLOT;
+ _vm->startGame((ResourcePackId)(getSharedData()->cdNumber + 4), AsylumEngine::kStartGameLoad);
+
+ return true;
}
-bool Savegame::save() {
- warning("[Savegame::save] Not implemented!");
+void Savegame::save() {
+ // Original creates a folder to hold saved games and checks for disk space, we can skip that
+ getCursor()->hide();
- return false;
+ if (saveData(getFilename(_index), _names[_index], getWorld()->chapter)) {
+ _savegames[_index] = true;
+
+ getMenu()->setDword455C78(true);
+ } else {
+ warning("[Savegame::save] Could not save game: %s", getFilename(_index).c_str());
+
+ _savegames[_index] = false;
+ _names[_index] = getText()->get(MAKE_RESOURCE(kResourcePackText, 1344));
+ }
+
+ getMenu()->setDword455C80(false);
+
+ getCursor()->show();
}
bool Savegame::quickSave() {
- warning("[Savegame::quickSave] Not implemented!");
+ _index = 24;
- return false;
+ // Check if there is a quick save already
+ if (isSavegamePresent(getFilename(SAVEGAME_QUICKSLOT))) {
+ _names[_index] = getText()->get(MAKE_RESOURCE(kResourcePackText, 1342));
+
+ save();
+ } else {
+ char name[45];
+
+ Common::InSaveFile *file = g_system->getSavefileManager()->openForLoading(getFilename(SAVEGAME_QUICKSLOT));
+ if (!file)
+ return false;
+
+ // Read game name
+ read(file, 1, "Level");
+ read(file, (byte *)&name, 1, 45, "Game Name");
+ _names[_index] = name;
+
+ delete file;
+
+ save();
+ }
+
+ return true;
}
+void Savegame::remove() {
+ getCursor()->hide();
+ g_system->getSavefileManager()->removeSavefile(getFilename(_index));
+
+ // Update status and name
+ _savegames[_index] = false;
+ _names[_index] = getText()->get(MAKE_RESOURCE(kResourcePackText, 1344));
+
+ getMenu()->setDword455C80(false);
+
+ getCursor()->show();
+}
+
+//////////////////////////////////////////////////////////////////////////
+// Helpers
+//////////////////////////////////////////////////////////////////////////
+bool Savegame::check() {
+ Common::InSaveFile *file = g_system->getSavefileManager()->openForLoading(getFilename(_index));
+ if (!file)
+ return false;
+
+ read(file, 2, "Level and Name");
+
+ bool valid = false;
+ if (readHeader(file))
+ valid = true;
+
+ delete file;
+
+ return valid;
+}
+
+Common::String Savegame::getFilename(uint32 index) {
+ if (index > SAVEGAME_COUNT - 1)
+ error("[Savegame::getFilename] Invalid savegame index (was:%d, valid: [0-25])", index);
+
+ return Common::String::format("%s%02d.sav", SAVEGAME_NAME, index);
+}
+
+bool Savegame::isSavegamePresent(Common::String filename) {
+ if (g_system->getSavefileManager()->listSavefiles(filename).size() == 0)
+ return false;
+
+ return true;
+}
+
+//////////////////////////////////////////////////////////////////////////
+// Reading & writing
+//////////////////////////////////////////////////////////////////////////
+bool Savegame::readHeader(Common::InSaveFile *file) {
+ int32 versionLength = 0;
+ int32 version = 0;
+ int32 build = 0;
+
+ read(file, (byte *)&versionLength, 4, 1, "Version Length");
+ read(file, (byte *)&version, 4, 1, "Version");
+ read(file, (byte *)&build, 4, 1, "Build");
+
+ // Original does not do any version check
+ // TODO check version to make sure we can read the data
+ _valid = true;
+
+ return true;
+}
+
+void Savegame::writeHeader(Common::OutSaveFile *file) {
+ // We write saved games with a 1.01 final version (build 851)
+ int length = SAVEGAME_VERSION_SIZE;
+ int build = SAVEGAME_BUILD;
+
+ write(file, (byte *)&length, 4, 1, "Version Length");
+ write(file, (byte *)&savegame_version, 1, SAVEGAME_VERSION_SIZE, "Version");
+ write(file, (byte *)&build, 4, 1, "Build");
+}
+
+bool Savegame::loadData(Common::String filename) {
+ error("[Savegame::loadData] Not implemented!");
+}
+
+bool Savegame::saveData(Common::String filename, Common::String name, ChapterIndex chapter) {
+ error("[Savegame::saveData] Not implemented!");
+}
+
+void Savegame::read(Common::InSaveFile *file, uint32 size, Common::String description) {
+ error("[Savegame::read] Not implemented!");
+}
+
+void Savegame::read(Common::InSaveFile *file, byte *data, uint32 size, uint32 count, Common::String description) {
+ error("[Savegame::read] Not implemented!");
+}
+
+void Savegame::read(Common::InSaveFile *file, Common::Serializable *data, uint32 size, uint32 count, Common::String description) {
+ error("[Savegame::read] Not implemented!");
+}
+
+void Savegame::write(Common::OutSaveFile *file, byte *data, uint32 size, uint32 count, Common::String description) {
+ error("[Savegame::write] Not implemented!");
+}
+
+void Savegame::write(Common::OutSaveFile *file, Common::Serializable *data, uint32 size, uint32 count, Common::String description) {
+ error("[Savegame::write] Not implemented!");
+}
+
+//////////////////////////////////////////////////////////////////////////
+// Movies
+//////////////////////////////////////////////////////////////////////////
void Savegame::setMovieViewed(uint32 index) {
if (index >= ARRAYSIZE(_moviesViewed))
error("[Savegame::setMovieViewed] Invalid movie index!");
@@ -78,8 +294,14 @@ void Savegame::setMovieViewed(uint32 index) {
if (!_moviesViewed[index]) {
_moviesViewed[index] = 1;
- // TODO Save to disk
- warning("[Savegame::setMovieViewed] Not implemented!");
+ // Write data to disk
+ Common::OutSaveFile *movies = g_system->getSavefileManager()->openForSaving(SAVEGAME_MOVIES);
+ if (!movies)
+ error("[Savegame::setMovieViewed] Could not open viewed movie list!");
+
+ movies->write((byte *)&_moviesViewed, sizeof(_moviesViewed));
+
+ delete movies;
}
}
@@ -98,8 +320,18 @@ uint32 Savegame::getMoviesViewed(byte *movieList) {
return count;
}
-void Savegame::loadViewedMovies() {
- warning("[Savegame::loadViewedMovies] Not implemented!");
+void Savegame::loadMoviesViewed() {
+ if (!isSavegamePresent(SAVEGAME_MOVIES))
+ return;
+
+ // Load data from disk
+ Common::InSaveFile *movies = g_system->getSavefileManager()->openForLoading(SAVEGAME_MOVIES);
+ if (!movies)
+ error("[Savegame::setMovieViewed] Could not open viewed movie list!");
+
+ movies->read((byte *)&_moviesViewed, sizeof(_moviesViewed));
+
+ delete movies;
}
diff --git a/engines/asylum/system/savegame.h b/engines/asylum/system/savegame.h
index b3a9ba2c8f..f25058acf4 100644
--- a/engines/asylum/system/savegame.h
+++ b/engines/asylum/system/savegame.h
@@ -26,11 +26,16 @@
#ifndef ASYLUM_SAVEGAME_H
#define ASYLUM_SAVEGAME_H
-#include "common/scummsys.h"
+#include "asylum/shared.h"
+
+#include "common/savefile.h"
+#include "common/serializer.h"
#include "common/util.h"
namespace Asylum {
+#define SAVEGAME_COUNT 25
+
class AsylumEngine;
class Savegame {
@@ -38,27 +43,190 @@ public:
Savegame(AsylumEngine *engine);
~Savegame();
- bool setup();
+ /**
+ * Checks if saved games are present
+ *
+ * @return true if it succeeds, false if it fails.
+ */
+ bool hasSavegames();
/**
- * Loads the list of saved games
+ * Loads the list of saved games.
*/
void loadList();
+ /**
+ * Loads a game
+ *
+ * @return true if it succeeds, false if it fails.
+ */
bool load();
+
+ /**
+ * Quick loads a game
+ *
+ * @return true if it succeeds, false if it fails.
+ */
bool quickLoad();
- bool save();
+ /**
+ * Saves a game
+ *
+ * @return true if it succeeds, false if it fails.
+ */
+ void save();
+
+ /**
+ * Quick saves a game
+ *
+ * @return true if it succeeds, false if it fails.
+ */
bool quickSave();
+ /**
+ * Removes a savegame
+ */
+ void remove();
+
+ //////////////////////////////////////////////////////////////////////////
+ // Movies
+ //////////////////////////////////////////////////////////////////////////
void setMovieViewed(uint32 index);
uint32 getMoviesViewed(byte *movieList);
- void loadViewedMovies();
+ void loadMoviesViewed();
private:
AsylumEngine* _vm;
+ uint32 _index;
byte _moviesViewed[196];
+ uint32 _savegameToScene[SAVEGAME_COUNT];
+ bool _savegames[SAVEGAME_COUNT];
+ Common::String _names[SAVEGAME_COUNT];
+ bool _valid;
+
+ //////////////////////////////////////////////////////////////////////////
+ // Helpers
+ //////////////////////////////////////////////////////////////////////////
+
+ /**
+ * Checks if a savegame is valid
+ *
+ * @return true if it succeeds, false if it fails.
+ */
+ bool check();
+
+ /**
+ * Gets a filename for a given save index
+ *
+ * @param index Zero-based index of the savegame
+ *
+ * @return The filename.
+ */
+ Common::String getFilename(uint32 index);
+
+ /**
+ * Check if a specific savegame exists
+ *
+ * @param filename Filename of the file.
+ *
+ * @return true if savegame present, false if not.
+ */
+ bool isSavegamePresent(Common::String filename);
+
+ //////////////////////////////////////////////////////////////////////////
+ // Reading & writing
+ //////////////////////////////////////////////////////////////////////////
+
+ /**
+ * Reads a savegame header.
+ *
+ * @param [in,out] file If non-null, the file.
+ *
+ * @return true if it succeeds, false if it fails.
+ */
+ bool readHeader(Common::InSaveFile *file);
+
+ /**
+ * Writes a savegame header.
+ *
+ * @param [in,out] file If non-null, the file.
+ */
+ void writeHeader(Common::OutSaveFile *file);
+
+ /**
+ * Loads savegame data
+ *
+ * @param filename Filename of the file.
+ *
+ * @return true if it succeeds, false if it fails.
+ */
+ bool loadData(Common::String filename);
+
+ /**
+ * Save savegame data.
+ *
+ * @param filename Filename of the file.
+ * @param name The name.
+ * @param chapter The chapter.
+ *
+ * @return true if it succeeds, false if it fails.
+ */
+ bool saveData(Common::String filename, Common::String name, ChapterIndex chapter);
+
+ /**
+ * Reads header data from a file
+ *
+ * @param [in,out] file If non-null, the file.
+ * @param size The size.
+ * @param description The description.
+ */
+ void read(Common::InSaveFile *file, uint32 size, Common::String description);
+
+ /**
+ * Reads data from a file.
+ *
+ * @param [in,out] file If non-null, the file.
+ * @param [in,out] data If non-null, the data.
+ * @param size The size.
+ * @param count Number of.
+ * @param description The description.
+ */
+ void read(Common::InSaveFile *file, byte *data, uint32 size, uint32 count, Common::String description);
+
+
+ /**
+ * Reads data from a file.
+ *
+ * @param [in,out] file If non-null, the file.
+ * @param [in,out] data If non-null, the data.
+ * @param size The size.
+ * @param count Number of.
+ * @param description The description.
+ */
+ void read(Common::InSaveFile *file, Common::Serializable *data, uint32 size, uint32 count, Common::String description);
+
+ /**
+ * Writes data to a file.
+ *
+ * @param [in,out] file If non-null, the file.
+ * @param [in,out] data If non-null, the data.
+ * @param size The size.
+ * @param count Number of.
+ * @param description The description.
+ */
+ void write(Common::OutSaveFile *file, byte *data, uint32 size, uint32 count, Common::String description);
+
+ /**
+ * Writes data to a file.
+ *
+ * @param [in,out] file If non-null, the file.
+ * @param [in,out] data If non-null, the data.
+ * @param size The size.
+ * @param count Number of.
+ * @param description The description.
+ */
+ void write(Common::OutSaveFile *file, Common::Serializable *data, uint32 size, uint32 count, Common::String description);
};
} // End of namespace Asylum
diff --git a/engines/asylum/views/menu.cpp b/engines/asylum/views/menu.cpp
index 12a4113382..33871718e5 100644
--- a/engines/asylum/views/menu.cpp
+++ b/engines/asylum/views/menu.cpp
@@ -349,21 +349,20 @@ bool MainMenu::init() {
// The original also
// - load the config (this is done when constructing the config singleton).
// - initialize game structures (this is done in classes constructors)
-
- getSaveLoad()->loadViewedMovies();
+ getSaveLoad()->loadMoviesViewed();
_needEyeCursorInit = true;
// Play start video
getVideo()->playVideo(0);
- if (!getSaveLoad()->setup()) {
+ // If no savegame is present, start the game directly
+ if (!getSaveLoad()->hasSavegames()) {
_vm->restart();
return true;
}
// The original preloads graphics
-
getCursor()->show();
}
diff --git a/engines/asylum/views/menu.h b/engines/asylum/views/menu.h
index 6c2f3f365a..886e7760ed 100644
--- a/engines/asylum/views/menu.h
+++ b/engines/asylum/views/menu.h
@@ -62,6 +62,10 @@ public:
*/
void setGameStarted() { _gameStarted = true; }
+ // Savegames
+ void setDword455C78(bool state) { _dword_455C78 = state; }
+ void setDword455C80(bool state) { _dword_455C80 = state; }
+
private:
AsylumEngine *_vm;
Commit: af09eecceeb356f972aebe17a8a1e2dc526e87c7
https://github.com/scummvm/scummvm/commit/af09eecceeb356f972aebe17a8a1e2dc526e87c7
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:38+02:00
Commit Message:
ASYLUM: Implement saving of games
- Added stubs for saveLoadWithSerializer
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@678 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
A engines/asylum/puzzles/data.h
engines/asylum/asylum.cpp
engines/asylum/asylum.h
engines/asylum/console.cpp
engines/asylum/resources/actor.cpp
engines/asylum/resources/encounters.h
engines/asylum/resources/script.cpp
engines/asylum/resources/script.h
engines/asylum/resources/worldstats.cpp
engines/asylum/resources/worldstats.h
engines/asylum/shared.h
engines/asylum/system/savegame.cpp
engines/asylum/system/savegame.h
diff --git a/engines/asylum/asylum.cpp b/engines/asylum/asylum.cpp
index 07feb1bcf6..6868351c22 100644
--- a/engines/asylum/asylum.cpp
+++ b/engines/asylum/asylum.cpp
@@ -510,6 +510,10 @@ void AsylumEngine::updateReverseStereo() {
_scene->worldstats()->reverseStereo = Config.reverseStereo;
}
+void AsylumEngine::saveLoadWithSerializer(Common::Serializer &s) {
+ error("[AsylumEngine::saveLoadWithSerializer] Not implemented!");
+}
+
//////////////////////////////////////////////////////////////////////////
// Game flags
//////////////////////////////////////////////////////////////////////////
diff --git a/engines/asylum/asylum.h b/engines/asylum/asylum.h
index 6d86e845c5..2d592d61c8 100644
--- a/engines/asylum/asylum.h
+++ b/engines/asylum/asylum.h
@@ -26,6 +26,7 @@
#ifndef ASYLUM_ENGINE_H
#define ASYLUM_ENGINE_H
+#include "asylum/puzzles/data.h"
#include "asylum/resources/data.h"
#include "asylum/console.h"
@@ -34,6 +35,7 @@
#include "common/random.h"
#include "common/scummsys.h"
+#include "common/serializer.h"
#include "common/system.h"
#include "engines/advancedDetector.h"
@@ -79,7 +81,7 @@ class Sound;
class Text;
class Video;
-class AsylumEngine: public Engine {
+class AsylumEngine: public Engine, public Common::Serializable {
protected:
// Engine APIs
virtual Common::Error run();
@@ -119,13 +121,6 @@ public:
*/
uint32 getTick() { return _system->getMillis(); }
- /**
- * Gets the shared data.
- *
- * @return a pointer to the shared data.
- */
- SharedData *getData() { return &_data; }
-
/**
* Resets the game
*/
@@ -152,6 +147,9 @@ public:
Text *text() { return _text; }
Video *video() { return _video; }
+ SharedData *data() { return &_data; }
+ PuzzleData *puzzleData() { return &_puzzleData; }
+
// Flags
void setGameFlagByIndex(int32 index);
int32 getGameFlagByIndex(int32 index);
@@ -204,6 +202,9 @@ public:
*/
Common::Point getSinCosValues(int32 index1, int32 index2);
+ // Serializable
+ void saveLoadWithSerializer(Common::Serializer &s);
+
private:
const ADGameDescription *_gameDescription;
@@ -231,6 +232,7 @@ private:
Puzzle *_puzzles[16];
// Game data
+ PuzzleData _puzzleData;
SharedData _data;
int _gameFlags[145];
bool _introPlayed;
diff --git a/engines/asylum/console.cpp b/engines/asylum/console.cpp
index 179678e3eb..8af6e92e06 100644
--- a/engines/asylum/console.cpp
+++ b/engines/asylum/console.cpp
@@ -345,7 +345,7 @@ bool Console::cmdRunScript(int32 argc, const char **argv) {
// Check parameters
if (index >= getScript()->_scripts.size()) {
- DebugPrintf("[Error] Invalid index (was: %d - valid: [0-%d])\n", index, _vm->encounter()->_items.size() - 1);
+ DebugPrintf("[Error] Invalid index (was: %d - valid: [0-%d])\n", index, _vm->encounter()->items()->size() - 1);
return true;
}
diff --git a/engines/asylum/puzzles/data.h b/engines/asylum/puzzles/data.h
new file mode 100644
index 0000000000..fc0d35f800
--- /dev/null
+++ b/engines/asylum/puzzles/data.h
@@ -0,0 +1,48 @@
+/* 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.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#ifndef ASYLUM_PUZZLE_DATA_H
+#define ASYLUM_PUZZLE_DATA_H
+
+#include "asylum/console.h"
+
+#include "common/serializer.h"
+
+namespace Asylum {
+
+struct PuzzleData : public Common::Serializable {
+public:
+ // Serializable
+ void saveLoadWithSerializer(Common::Serializer &s) {
+ error("[PuzzleData::saveLoadWithSerializer] Not implemented!");
+ }
+
+private:
+
+};
+
+} // End of namespace Asylum
+
+#endif // ASYLUM_PUZZLE_DATA_H
diff --git a/engines/asylum/resources/actor.cpp b/engines/asylum/resources/actor.cpp
index 2ff61bfdee..056c97290c 100644
--- a/engines/asylum/resources/actor.cpp
+++ b/engines/asylum/resources/actor.cpp
@@ -1193,7 +1193,7 @@ void Actor::enableActorsChapter2(AsylumEngine *engine) {
engine->clearGameFlag(kGameFlag442);
// Reset shared data
- engine->getData()->resetActorData();
+ engine->data()->resetActorData();
engine->scene()->getActor(13)->enable();
engine->scene()->getActor(13)->processStatus(2300, 71, false);
diff --git a/engines/asylum/resources/encounters.h b/engines/asylum/resources/encounters.h
index 4e1d564aea..5e93b6f8f2 100644
--- a/engines/asylum/resources/encounters.h
+++ b/engines/asylum/resources/encounters.h
@@ -31,11 +31,44 @@
#include "asylum/shared.h"
#include "common/array.h"
+#include "common/serializer.h"
namespace Asylum {
class AsylumEngine;
+struct EncounterItem {
+ int16 keywordIndex;
+ int16 field2;
+ ResourceId scriptResourceId;
+ int16 keywords[50];
+ byte value;
+
+ EncounterItem() {
+ keywordIndex = 0;
+ field2 = 0;
+ scriptResourceId = kResourceNone;
+ memset(&keywords, 0, sizeof(keywords));
+ value = 0;
+ }
+};
+
+class EncounterVariables : public Common::Array<int16>, public Common::Serializable {
+public:
+ // Serializable
+ void saveLoadWithSerializer(Common::Serializer &s) {
+ error("[EncounterVariables::saveLoadWithSerializer] Not implemented!");
+ }
+};
+
+class EncounterItems : public Common::Array<EncounterItem>, public Common::Serializable {
+public:
+ // Serializable
+ void saveLoadWithSerializer(Common::Serializer &s) {
+ error("[EncounterItems::saveLoadWithSerializer] Not implemented!");
+ }
+};
+
class Encounter : public EventHandler {
public:
Encounter(AsylumEngine *engine);
@@ -54,6 +87,10 @@ public:
void disablePlayerOnExit(bool state) { _disablePlayerOnExit = state; }
bool isRunning() { return _isRunning; }
+ // Accessors (for saving game)
+ EncounterItems *items() { return &_items; }
+ EncounterVariables *variables() { return &_variables; }
+
private:
AsylumEngine *_vm;
@@ -65,14 +102,6 @@ private:
kEncounterArray8000 = 0x8000
};
- struct EncounterItem {
- int16 keywordIndex;
- int16 field2;
- ResourceId scriptResourceId;
- int16 keywords[50];
- byte value;
- };
-
struct EncounterGraphic {
int32 frameIndex;
int32 frameCount;
@@ -114,8 +143,8 @@ private:
}
};
- Common::Array<int16> _variables;
- Common::Array<EncounterItem> _items;
+ EncounterVariables _variables;
+ EncounterItems _items;
EncounterDrawingStruct _drawingStructs[2];
int32 _keywordIndexes[50];
diff --git a/engines/asylum/resources/script.cpp b/engines/asylum/resources/script.cpp
index 8f6f245051..3ccffc5f26 100644
--- a/engines/asylum/resources/script.cpp
+++ b/engines/asylum/resources/script.cpp
@@ -335,6 +335,10 @@ bool ScriptManager::process() {
return false;
}
+void ScriptManager::saveLoadWithSerializer(Common::Serializer &s) {
+ error("[ScriptManager::saveLoadWithSerializer] Not implemented!");
+}
+
//////////////////////////////////////////////////////////////////////////
// Opcode Functions
//////////////////////////////////////////////////////////////////////////
diff --git a/engines/asylum/resources/script.h b/engines/asylum/resources/script.h
index f39dd243be..d9435241b6 100644
--- a/engines/asylum/resources/script.h
+++ b/engines/asylum/resources/script.h
@@ -30,6 +30,7 @@
#include "common/array.h"
#include "common/func.h"
+#include "common/serializer.h"
#include "common/stack.h"
#include "common/stream.h"
@@ -117,7 +118,7 @@ struct ActionArea {
}
};
-class ScriptManager {
+class ScriptManager : public Common::Serializable {
public:
ScriptManager(AsylumEngine *engine);
virtual ~ScriptManager();
@@ -167,6 +168,9 @@ public:
bool isProcessingSkipped() { return _skipProcessing; }
+ // Serializable
+ void saveLoadWithSerializer(Common::Serializer &s);
+
private:
enum ObjectEnableType {
kObjectEnableType0,
diff --git a/engines/asylum/resources/worldstats.cpp b/engines/asylum/resources/worldstats.cpp
index d6fc37a0de..6989edfe93 100644
--- a/engines/asylum/resources/worldstats.cpp
+++ b/engines/asylum/resources/worldstats.cpp
@@ -76,7 +76,7 @@ WorldStats::WorldStats(AsylumEngine *engine) : _vm(engine) {
musicFlag = 0;
musicResourceId = kResourceNone;
musicStatusExt = 0;
- numActionLists = 0;
+ numScripts = 0;
numPolygons = 0;
memset(&cursorResourcesAlternate, kResourceNone, sizeof(cursorResourcesAlternate));
@@ -220,7 +220,7 @@ void WorldStats::load(Common::SeekableReadStream *stream) {
//////////////////////////////////////////////////////////////////////////
// Read number of scripts and polygons
- numActionLists = stream->readUint32LE();
+ numScripts = stream->readUint32LE();
numPolygons = stream->readUint32LE();
// Load the alternate cursor resources
@@ -357,4 +357,9 @@ Common::String WorldStats::toString() {
return output;
}
+
+void WorldStats::saveLoadWithSerializer(Common::Serializer &s) {
+ error("[WorldStats::saveLoadWithSerializer] Not implemented!");
+}
+
} // end of namespace Asylum
diff --git a/engines/asylum/resources/worldstats.h b/engines/asylum/resources/worldstats.h
index 65681c6638..f6f4d821ad 100644
--- a/engines/asylum/resources/worldstats.h
+++ b/engines/asylum/resources/worldstats.h
@@ -28,8 +28,9 @@
#include "asylum/system/sound.h"
-#include "common/rect.h"
#include "common/array.h"
+#include "common/rect.h"
+#include "common/serializer.h"
namespace Asylum {
@@ -64,7 +65,7 @@ enum CursorResourceType {
kCursorResourceTalkNPC2
};
-class WorldStats {
+class WorldStats : public Common::Serializable {
public:
WorldStats(AsylumEngine *engine);
virtual ~WorldStats();
@@ -124,7 +125,7 @@ public:
Common::Array<Object*> objects; // maxsize 400
Common::Array<Actor*> actors; // maxsize 50
// ActorData is stored in each actor instance
- int32 numActionLists;
+ int32 numScripts;
int32 numPolygons;
ResourceId cursorResourcesAlternate[64];
Common::Array<ActionArea*> actions; // maxsize 400
@@ -154,6 +155,9 @@ public:
Common::String toString();
+ // Serializable
+ void saveLoadWithSerializer(Common::Serializer &s);
+
private:
AsylumEngine *_vm;
};
diff --git a/engines/asylum/shared.h b/engines/asylum/shared.h
index 8f4de6c95e..117498c797 100644
--- a/engines/asylum/shared.h
+++ b/engines/asylum/shared.h
@@ -607,13 +607,14 @@ enum ObjectFlag {
#define getEncounter() _vm->encounter()
#define getCursor() _vm->cursor()
#define getMenu() _vm->menu()
+#define getPuzzleData() _vm->puzzleData()
#define getResource() _vm->resource()
#define getSound() _vm->sound()
#define getSaveLoad() _vm->savegame()
#define getScene() _vm->scene()
#define getScreen() _vm->screen()
#define getScript() _vm->script()
-#define getSharedData() _vm->getData()
+#define getSharedData() _vm->data()
#define getSpecial() _vm->special()
#define getSpeech() _vm->speech()
#define getText() _vm->text()
diff --git a/engines/asylum/system/savegame.cpp b/engines/asylum/system/savegame.cpp
index 1a65c44284..5b09728bac 100644
--- a/engines/asylum/system/savegame.cpp
+++ b/engines/asylum/system/savegame.cpp
@@ -25,6 +25,9 @@
#include "asylum/system/savegame.h"
+#include "asylum/puzzles/data.h"
+
+#include "asylum/resources/encounters.h"
#include "asylum/resources/script.h"
#include "asylum/resources/worldstats.h"
@@ -44,13 +47,15 @@ namespace Asylum {
#define SAVEGAME_BUILD 851
#define SAVEGAME_VERSION_SIZE 11
+#define SAVEGAME_NAME_SIZE 45
#define SAVEGAME_NAME "asylum"
+
#define SAVEGAME_QUICKSLOT 25
#define SAVEGAME_MOVIES "asylum.movies"
-const char savegame_version[12] = "v1.01 FINAL";
+const Common::String savegame_version = "v1.01 FINAL";
Savegame::Savegame(AsylumEngine *engine) : _vm(engine), _index(0), _valid(false) {
memset(&_moviesViewed, 0, sizeof(_moviesViewed));
@@ -78,8 +83,8 @@ void Savegame::loadList() {
if (!file)
error("[Savegame::loadList] Cannot open savegame: %s", getFilename(i).c_str());
- read(file, (byte *)&_savegameToScene[i], 4, 1, "Level");
- read(file, (byte *)&_names[i], 1, 45, "Game Name");
+ _savegameToScene[i] = read(file, "Level");
+ _names[i] = read(file, 45, "Game Name");
_savegames[i] = true;
delete file;
@@ -162,16 +167,13 @@ bool Savegame::quickSave() {
save();
} else {
- char name[45];
-
Common::InSaveFile *file = g_system->getSavefileManager()->openForLoading(getFilename(SAVEGAME_QUICKSLOT));
if (!file)
return false;
// Read game name
- read(file, 1, "Level");
- read(file, (byte *)&name, 1, 45, "Game Name");
- _names[_index] = name;
+ seek(file, 1, "Level");
+ _names[_index] = read(file, 45, "Game Name");
delete file;
@@ -202,7 +204,7 @@ bool Savegame::check() {
if (!file)
return false;
- read(file, 2, "Level and Name");
+ seek(file, 2, "Level and Name");
bool valid = false;
if (readHeader(file))
@@ -231,13 +233,9 @@ bool Savegame::isSavegamePresent(Common::String filename) {
// Reading & writing
//////////////////////////////////////////////////////////////////////////
bool Savegame::readHeader(Common::InSaveFile *file) {
- int32 versionLength = 0;
- int32 version = 0;
- int32 build = 0;
-
- read(file, (byte *)&versionLength, 4, 1, "Version Length");
- read(file, (byte *)&version, 4, 1, "Version");
- read(file, (byte *)&build, 4, 1, "Build");
+ uint32 versionLength = read(file, "Version Length");
+ Common::String version = read(file, versionLength, "Version");
+ /*uint32 build = */read(file, "Build");
// Original does not do any version check
// TODO check version to make sure we can read the data
@@ -248,40 +246,97 @@ bool Savegame::readHeader(Common::InSaveFile *file) {
void Savegame::writeHeader(Common::OutSaveFile *file) {
// We write saved games with a 1.01 final version (build 851)
- int length = SAVEGAME_VERSION_SIZE;
- int build = SAVEGAME_BUILD;
- write(file, (byte *)&length, 4, 1, "Version Length");
- write(file, (byte *)&savegame_version, 1, SAVEGAME_VERSION_SIZE, "Version");
- write(file, (byte *)&build, 4, 1, "Build");
+ write(file, SAVEGAME_VERSION_SIZE, "Version Length");
+ write(file, savegame_version, SAVEGAME_VERSION_SIZE, "Version");
+ write(file, SAVEGAME_BUILD, "Build");
}
bool Savegame::loadData(Common::String filename) {
+ //Common::InSaveFile *file = g_system->getSavefileManager()->openForLoading(getFilename(_index));
+
error("[Savegame::loadData] Not implemented!");
}
bool Savegame::saveData(Common::String filename, Common::String name, ChapterIndex chapter) {
- error("[Savegame::saveData] Not implemented!");
+ Common::OutSaveFile *file = g_system->getSavefileManager()->openForSaving(getFilename(_index));
+ if (!file)
+ return false;
+
+ write(file, chapter, "Level");
+ write(file, name, SAVEGAME_NAME_SIZE, "Game Name");
+ writeHeader(file);
+ write(file, _vm, 1512, 1, "Game Stats");
+ write(file, getWorld(), 951928, 1, "World Stats");
+ write(file, getPuzzleData(), 752, 1, "Blowup Puzzle Data");
+ write(file, getEncounter()->items(), 109, getEncounter()->items()->size(), "Encounter Data");
+ write(file, getEncounter()->variables(), 2, getEncounter()->variables()->size(), "Encounter Variables");
+
+ if (getWorld()->numScripts)
+ write(file, getScript(), 7096, getWorld()->numScripts, "Action Lists");
+
+ write(file, _vm->getTick(), "Time");
+
+ delete file;
+
+ return true;
+}
+
+void Savegame::seek(Common::InSaveFile *file, uint32 offset, Common::String description) {
+ if (offset == 0)
+ return;
+
+ uint32 size = 0;
+ uint32 count = 0;
+
+ for (uint i = 0; i < offset; i++) {
+ size = file->readUint32LE();
+ count = file->readUint32LE();
+
+ file->seek(size * count, SEEK_CUR);
+ }
}
-void Savegame::read(Common::InSaveFile *file, uint32 size, Common::String description) {
+uint32 Savegame::read(Common::InSaveFile *file, Common::String description) {
error("[Savegame::read] Not implemented!");
}
-void Savegame::read(Common::InSaveFile *file, byte *data, uint32 size, uint32 count, Common::String description) {
+Common::String Savegame::read(Common::InSaveFile *file, uint32 strLength, Common::String description) {
error("[Savegame::read] Not implemented!");
}
+
void Savegame::read(Common::InSaveFile *file, Common::Serializable *data, uint32 size, uint32 count, Common::String description) {
error("[Savegame::read] Not implemented!");
}
-void Savegame::write(Common::OutSaveFile *file, byte *data, uint32 size, uint32 count, Common::String description) {
- error("[Savegame::write] Not implemented!");
+void Savegame::write(Common::OutSaveFile *file, uint32 val, Common::String description) {
+ file->writeUint32LE(4);
+ file->writeUint32LE(1);
+
+ // Write data
+ // TODO check for errors
+ file->writeUint32LE(val);
+}
+
+void Savegame::write(Common::OutSaveFile *file, Common::String val, uint32 count, Common::String description) {
+ file->writeUint32LE(1);
+ file->writeUint32LE(count);
+
+ // Write data
+ // TODO check for errors
+ file->writeString(val);
}
void Savegame::write(Common::OutSaveFile *file, Common::Serializable *data, uint32 size, uint32 count, Common::String description) {
- error("[Savegame::write] Not implemented!");
+ file->writeUint32LE(size);
+ file->writeUint32LE(count);
+
+ if (size * count == 0)
+ return;
+
+ Common::Serializer ser(NULL, file);
+ data->saveLoadWithSerializer(ser);
}
//////////////////////////////////////////////////////////////////////////
diff --git a/engines/asylum/system/savegame.h b/engines/asylum/system/savegame.h
index f25058acf4..bde56e5cc8 100644
--- a/engines/asylum/system/savegame.h
+++ b/engines/asylum/system/savegame.h
@@ -175,25 +175,34 @@ private:
bool saveData(Common::String filename, Common::String name, ChapterIndex chapter);
/**
- * Reads header data from a file
+ * Seeks to a specific place in the file
*
* @param [in,out] file If non-null, the file.
- * @param size The size.
+ * @param offset Offset index of the info into the file
* @param description The description.
*/
- void read(Common::InSaveFile *file, uint32 size, Common::String description);
+ void seek(Common::InSaveFile *file, uint32 offset, Common::String description);
/**
- * Reads data from a file.
+ * Reads data from a file.
*
- * @param [in,out] file If non-null, the file.
- * @param [in,out] data If non-null, the data.
- * @param size The size.
- * @param count Number of.
- * @param description The description.
+ * @param [in,out] file If non-null, the file.
+ * @param description The description.
+ *
+ * @return the value
*/
- void read(Common::InSaveFile *file, byte *data, uint32 size, uint32 count, Common::String description);
+ uint32 read(Common::InSaveFile *file, Common::String description);
+ /**
+ * Reads data from a file.
+ *
+ * @param [in,out] file If non-null, the file.
+ * @param strLength Length of the string.
+ * @param description The description.
+ *
+ * @return the string
+ */
+ Common::String read(Common::InSaveFile *file, uint32 strLength, Common::String description);
/**
* Reads data from a file.
@@ -210,12 +219,20 @@ private:
* Writes data to a file.
*
* @param [in,out] file If non-null, the file.
- * @param [in,out] data If non-null, the data.
- * @param size The size.
- * @param count Number of.
+ * @param val The value
+ * @param description The description.
+ */
+ void write(Common::OutSaveFile *file, uint32 val, Common::String description);
+
+ /**
+ * Writes data to a file.
+ *
+ * @param [in,out] file If non-null, the file.
+ * @param val The string
+ * @param count The size of the string.
* @param description The description.
*/
- void write(Common::OutSaveFile *file, byte *data, uint32 size, uint32 count, Common::String description);
+ void write(Common::OutSaveFile *file, Common::String val, uint32 count, Common::String description);
/**
* Writes data to a file.
Commit: 46aa3065139f3f1118ba2315fc289a1ed2e176da
https://github.com/scummvm/scummvm/commit/46aa3065139f3f1118ba2315fc289a1ed2e176da
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:38+02:00
Commit Message:
ASYLUM: Implement loading of games
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@679 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/asylum.cpp
engines/asylum/asylum.h
engines/asylum/resources/script.cpp
engines/asylum/shared.h
engines/asylum/system/savegame.cpp
diff --git a/engines/asylum/asylum.cpp b/engines/asylum/asylum.cpp
index 6868351c22..1d0ecefe16 100644
--- a/engines/asylum/asylum.cpp
+++ b/engines/asylum/asylum.cpp
@@ -80,6 +80,7 @@ AsylumEngine::AsylumEngine(OSystem *system, const ADGameDescription *gd) : Engin
memset(&_puzzles, 0, sizeof(_puzzles));
memset(&_sinCosTables, 0, sizeof(_sinCosTables));
_introPlayed = false;
+ _tickOffset = 0;
// Add default search directories
const Common::FSNode gameDataDir(ConfMan.get("path"));
diff --git a/engines/asylum/asylum.h b/engines/asylum/asylum.h
index 2d592d61c8..6445295b4e 100644
--- a/engines/asylum/asylum.h
+++ b/engines/asylum/asylum.h
@@ -116,10 +116,19 @@ public:
*/
void switchScene(ResourcePackId sceneId) { startGame(sceneId, kStartGameScene); }
- /**
- * Wrapper function to the OSystem getMillis() method
- */
- uint32 getTick() { return _system->getMillis(); }
+ /**
+ * Get the number of engine ticks
+ *
+ * @return The tick.
+ */
+ uint32 getTick() { return _system->getMillis() + _tickOffset; }
+
+ /**
+ * Sets the tick value
+ *
+ * @param offset The offset.
+ */
+ void setTick(uint32 offset) { _tickOffset = offset - _system->getMillis(); }
/**
* Resets the game
@@ -235,8 +244,9 @@ private:
PuzzleData _puzzleData;
SharedData _data;
int _gameFlags[145];
- bool _introPlayed;
int32 _sinCosTables[72];
+ bool _introPlayed;
+ int32 _tickOffset;
void handleEvents();
void updateMouseCursor();
diff --git a/engines/asylum/resources/script.cpp b/engines/asylum/resources/script.cpp
index 3ccffc5f26..7d8c54c44c 100644
--- a/engines/asylum/resources/script.cpp
+++ b/engines/asylum/resources/script.cpp
@@ -813,6 +813,7 @@ END_OPCODE
//////////////////////////////////////////////////////////////////////////
// Opcode 0x2B
IMPLEMENT_OPCODE(ChangeScene)
+ uint32 tick = _vm->getTick();
getScene()->getActor(0)->updateStatus(kActorStatusDisabled);
resetQueue();
@@ -821,6 +822,7 @@ IMPLEMENT_OPCODE(ChangeScene)
getScreen()->clear();
// Stop all sounds & music
+ _vm->setTick(tick);
getSound()->stopAll();
getSound()->stopMusic();
diff --git a/engines/asylum/shared.h b/engines/asylum/shared.h
index 117498c797..c1e5704aaa 100644
--- a/engines/asylum/shared.h
+++ b/engines/asylum/shared.h
@@ -146,6 +146,7 @@ enum GameFlag {
};
enum ChapterIndex {
+ kChapterInvalid = -1,
kChapterNone = 0,
kChapter1,
kChapter2,
diff --git a/engines/asylum/system/savegame.cpp b/engines/asylum/system/savegame.cpp
index 5b09728bac..c6600fbf07 100644
--- a/engines/asylum/system/savegame.cpp
+++ b/engines/asylum/system/savegame.cpp
@@ -122,7 +122,6 @@ bool Savegame::load() {
loadMoviesViewed();
getMenu()->setDword455C80(false);
-
getScreen()->clear();
return true;
@@ -154,7 +153,6 @@ void Savegame::save() {
}
getMenu()->setDword455C80(false);
-
getCursor()->show();
}
@@ -192,7 +190,6 @@ void Savegame::remove() {
_names[_index] = getText()->get(MAKE_RESOURCE(kResourcePackText, 1344));
getMenu()->setDword455C80(false);
-
getCursor()->show();
}
@@ -253,9 +250,38 @@ void Savegame::writeHeader(Common::OutSaveFile *file) {
}
bool Savegame::loadData(Common::String filename) {
- //Common::InSaveFile *file = g_system->getSavefileManager()->openForLoading(getFilename(_index));
+ Common::InSaveFile *file = g_system->getSavefileManager()->openForLoading(getFilename(_index));
+ if (!file) {
+ getWorld()->chapter = kChapterInvalid;
+ return false;
+ }
+
+ seek(file, 1, "Level");
+ seek(file, 1, "Game Name");
+
+ if (!readHeader(file)) {
+ getWorld()->chapter = kChapterInvalid;
+ return false;
+ }
+
+ read(file, _vm, 1512, 1, "Game Stats");
+ read(file, getWorld(), 951928, 1, "World Stats");
+ read(file, getPuzzleData(), 752, 1, "Blowup Puzzle Data");
+ read(file, getEncounter()->items(), 109, getEncounter()->items()->size(), "Encounter Data");
+ read(file, getEncounter()->variables(), 2, getEncounter()->variables()->size(), "Encounter Variables");
+
+ getScript()->reset();
+
+ if (getWorld()->numScripts)
+ read(file, getScript(), 7096, getWorld()->numScripts, "Action Lists");
+
+ uint32 tick = read(file, "Time");
+
+ _vm->setTick(tick);
- error("[Savegame::loadData] Not implemented!");
+ delete file;
+
+ return true;
}
bool Savegame::saveData(Common::String filename, Common::String name, ChapterIndex chapter) {
@@ -298,16 +324,47 @@ void Savegame::seek(Common::InSaveFile *file, uint32 offset, Common::String desc
}
uint32 Savegame::read(Common::InSaveFile *file, Common::String description) {
- error("[Savegame::read] Not implemented!");
+ uint32 size = file->readUint32LE();
+ uint32 count = file->readUint32LE();
+
+ if (size * count == 0)
+ return 0;
+
+ return file->readUint32LE();
}
Common::String Savegame::read(Common::InSaveFile *file, uint32 strLength, Common::String description) {
- error("[Savegame::read] Not implemented!");
-}
+ /*uint32 size =*/ file->readUint32LE();
+ uint32 count = file->readUint32LE();
+ if (strLength > count)
+ error("[Savegame::read] Count too large (asked: %d, present: %d)", strLength, count);
+
+ char *str = new char[strLength + 1];
+ memset(str, 0, strLength + 1);
+ file->read(str, strLength);
+
+ Common::String ret(str);
+
+ delete str;
+
+ return ret;
+}
void Savegame::read(Common::InSaveFile *file, Common::Serializable *data, uint32 size, uint32 count, Common::String description) {
- error("[Savegame::read] Not implemented!");
+ uint32 fileSize = file->readUint32LE();
+ if (size > fileSize)
+ error("[Savegame::read] Size too large (asked: %d, present: %d)", size, fileSize);
+
+ uint32 fileCount = file->readUint32LE();
+ if (count > fileCount)
+ error("[Savegame::read] Count too large (asked: %d, present: %d)", count, fileCount);
+
+ if (fileCount * fileSize == 0)
+ return;
+
+ Common::Serializer ser(file, NULL);
+ data->saveLoadWithSerializer(ser);
}
void Savegame::write(Common::OutSaveFile *file, uint32 val, Common::String description) {
Commit: 26eacef2fc667e906688c7f89607b7a14c61b45e
https://github.com/scummvm/scummvm/commit/26eacef2fc667e906688c7f89607b7a14c61b45e
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:38+02:00
Commit Message:
ASYLUM: Move Video class to views
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@680 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
A engines/asylum/views/video.cpp
A engines/asylum/views/video.h
R engines/asylum/system/video.cpp
R engines/asylum/system/video.h
engines/asylum/asylum.cpp
engines/asylum/eventhandler.h
engines/asylum/module.mk
engines/asylum/puzzles/vcr.cpp
engines/asylum/views/menu.cpp
diff --git a/engines/asylum/asylum.cpp b/engines/asylum/asylum.cpp
index 1d0ecefe16..ffbc880e68 100644
--- a/engines/asylum/asylum.cpp
+++ b/engines/asylum/asylum.cpp
@@ -54,10 +54,10 @@
#include "asylum/system/sound.h"
#include "asylum/system/speech.h"
#include "asylum/system/text.h"
-#include "asylum/system/video.h"
#include "asylum/views/scene.h"
#include "asylum/views/menu.h"
+#include "asylum/views/video.h"
#include "asylum/console.h"
#include "asylum/respack.h"
diff --git a/engines/asylum/eventhandler.h b/engines/asylum/eventhandler.h
index 87a6e02775..d2ad815a0f 100644
--- a/engines/asylum/eventhandler.h
+++ b/engines/asylum/eventhandler.h
@@ -38,6 +38,7 @@ enum AsylumEventType {
EVENT_ASYLUM_UPDATE = 5121,
EVENT_ASYLUM_DEINIT = 5123,
EVENT_ASYLUM_CURSOR = 5124,
+ EVENT_ASYLUM_SUBTITLE = 5125,
EVENT_ASYLUM_MUSIC = 5376,
EVENT_ASYLUM_ACTIVATE = 0xFFF0
diff --git a/engines/asylum/module.mk b/engines/asylum/module.mk
index 5bc05a3027..0368941a6a 100644
--- a/engines/asylum/module.mk
+++ b/engines/asylum/module.mk
@@ -33,10 +33,10 @@ MODULE_OBJS := \
system/sound.o \
system/speech.o \
system/text.o \
- system/video.o \
views/menu.o \
views/scene.o \
views/scenetitle.o \
+ views/video.o \
asylum.o \
console.o \
detection.o \
diff --git a/engines/asylum/puzzles/vcr.cpp b/engines/asylum/puzzles/vcr.cpp
index 5e405409a8..c0cadc284d 100644
--- a/engines/asylum/puzzles/vcr.cpp
+++ b/engines/asylum/puzzles/vcr.cpp
@@ -31,9 +31,9 @@
#include "asylum/system/cursor.h"
#include "asylum/system/graphics.h"
#include "asylum/system/screen.h"
-#include "asylum/system/video.h"
#include "asylum/views/scene.h"
+#include "asylum/views/video.h"
#include "asylum/asylum.h"
#include "asylum/respack.h"
diff --git a/engines/asylum/views/menu.cpp b/engines/asylum/views/menu.cpp
index 33871718e5..2d8a6bbb19 100644
--- a/engines/asylum/views/menu.cpp
+++ b/engines/asylum/views/menu.cpp
@@ -35,9 +35,9 @@
#include "asylum/system/screen.h"
#include "asylum/system/sound.h"
#include "asylum/system/text.h"
-#include "asylum/system/video.h"
#include "asylum/views/scene.h"
+#include "asylum/views/video.h"
#include "asylum/respack.h"
#include "asylum/staticres.h"
diff --git a/engines/asylum/system/video.cpp b/engines/asylum/views/video.cpp
similarity index 98%
rename from engines/asylum/system/video.cpp
rename to engines/asylum/views/video.cpp
index 8830a7c879..1cc1ae442e 100644
--- a/engines/asylum/system/video.cpp
+++ b/engines/asylum/views/video.cpp
@@ -23,7 +23,7 @@
*
*/
-#include "asylum/system/video.h"
+#include "asylum/views/video.h"
#include "asylum/system/config.h"
#include "asylum/system/graphics.h"
@@ -36,7 +36,7 @@
namespace Asylum {
-Video::Video(AsylumEngine *engine, Audio::Mixer *mixer): _vm(engine), _skipVideo(false) {
+Video::Video(AsylumEngine *engine, Audio::Mixer *mixer) : _vm(engine), _skipVideo(false) {
Common::Event stopEvent;
_stopEvents.clear();
stopEvent.type = Common::EVENT_KEYDOWN;
diff --git a/engines/asylum/system/video.h b/engines/asylum/views/video.h
similarity index 100%
rename from engines/asylum/system/video.h
rename to engines/asylum/views/video.h
Commit: ae4d75e6a0cee66e69be7d2bebaf15a366976929
https://github.com/scummvm/scummvm/commit/ae4d75e6a0cee66e69be7d2bebaf15a366976929
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:39+02:00
Commit Message:
ASYLUM: Convert Video to new event handling
- Change Text::LoadFont to return the previous font
- Fix AsylumEngine::processDelayedEvents not working properly for scenes
- Add two params to AsylumEvent (needed by video subtitle handling)
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@681 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/asylum.cpp
engines/asylum/asylum.h
engines/asylum/console.cpp
engines/asylum/eventhandler.h
engines/asylum/resources/encounters.cpp
engines/asylum/resources/script.h
engines/asylum/system/screen.cpp
engines/asylum/system/screen.h
engines/asylum/system/text.cpp
engines/asylum/system/text.h
engines/asylum/views/menu.cpp
engines/asylum/views/video.cpp
engines/asylum/views/video.h
diff --git a/engines/asylum/asylum.cpp b/engines/asylum/asylum.cpp
index ffbc880e68..90f22fd75c 100644
--- a/engines/asylum/asylum.cpp
+++ b/engines/asylum/asylum.cpp
@@ -82,6 +82,10 @@ AsylumEngine::AsylumEngine(OSystem *system, const ADGameDescription *gd) : Engin
_introPlayed = false;
_tickOffset = 0;
+ // Debug
+ _delayedSceneIndex = kResourcePackInvalid;
+ _delayedVideoIndex = -1;
+
// Add default search directories
const Common::FSNode gameDataDir(ConfMan.get("path"));
SearchMan.addSubDirectoryMatching(gameDataDir, "data");
@@ -271,7 +275,7 @@ void AsylumEngine::playIntro() {
_sound->playMusic(kResourceNone, 0);
// TODO convert to new event handling
- _video->playVideo(1);
+ _video->play(1, _mainMenu);
if (_scene->worldstats()->musicCurrentResourceIndex != kMusicStopped)
_sound->playMusic(MAKE_RESOURCE(kResourcePackMusic, _scene->worldstats()->musicCurrentResourceIndex));
@@ -356,7 +360,7 @@ void AsylumEngine::handleEvents() {
if (_handler)
_handler->handleEvent(updateEvt);
- // TODO replace by original game code based on switchEventHandler
+ // Handle debug events
processDelayedEvents();
}
@@ -364,30 +368,32 @@ void AsylumEngine::processDelayedEvents() {
if (!_video || !_sound || !_mainMenu)
error("[AsylumEngine::processDelayedEvents] Subsystems not initialized properly!");
- // check for a delayed video
- int videoIdx = _script->getDelayedVideoIndex();
- if (videoIdx >= 0) {
- _sound->stopMusic();
- _sound->stopAll();
- _video->playVideo(videoIdx);
- _script->setDelayedVideoIndex(-1);
- }
+ // check for a delayed scene change
+ if (_delayedSceneIndex != kResourcePackInvalid && isGameFlagNotSet(kGameFlagScriptProcessing)) {
+ ResourcePackId sceneIndex = _delayedSceneIndex;
- // check for a delayed scene change
- ResourcePackId packId = _script->getDelayedSceneIndex();
- if (packId != kResourcePackInvalid && isGameFlagNotSet(kGameFlagScriptProcessing)) {
// Reset delayed scene
- _script->setDelayedSceneIndex(kResourcePackInvalid);
+ _delayedSceneIndex = kResourcePackInvalid;
_sound->stopMusic();
_sound->stopAll();
+ switchEventHandler(NULL);
+
delete _scene;
_scene = new Scene(this);
- _scene->enter(packId);
+ _scene->enter(sceneIndex);
switchEventHandler(_scene);
}
+
+ // Check for delayed video
+ if (_delayedVideoIndex != -1 && isGameFlagNotSet(kGameFlagScriptProcessing)) {
+ int32 index = _delayedVideoIndex;
+ _delayedVideoIndex = -1;
+
+ _video->play(index, _handler);
+ }
}
//////////////////////////////////////////////////////////////////////////
@@ -412,11 +418,11 @@ void AsylumEngine::switchEventHandler(EventHandler *handler) {
_handler->handleEvent(init);
}
-void AsylumEngine::notify(AsylumEventType type) {
+void AsylumEngine::notify(AsylumEventType type, int32 param1, int32 param2) {
if (_handler == NULL)
error("[AsylumEngine::notify] Invalid handler parameter (cannot be NULL)!");
- AsylumEvent evt(type);
+ AsylumEvent evt(type, param1, param2);
_handler->handleEvent(evt);
}
diff --git a/engines/asylum/asylum.h b/engines/asylum/asylum.h
index 6445295b4e..f95c68ac8d 100644
--- a/engines/asylum/asylum.h
+++ b/engines/asylum/asylum.h
@@ -109,6 +109,11 @@ public:
*/
void restart();
+ /**
+ * Run event loop
+ */
+ void handleEvents();
+
/**
* Switch to a new scene
*
@@ -185,7 +190,7 @@ public:
*
* @param type The event type.
*/
- void notify(AsylumEventType type);
+ void notify(AsylumEventType type, int32 param1 = 0, int32 param2 = 0);
/**
* Gets a message handler.
@@ -248,7 +253,6 @@ private:
bool _introPlayed;
int32 _tickOffset;
- void handleEvents();
void updateMouseCursor();
void processDelayedEvents();
@@ -276,7 +280,11 @@ private:
*/
int32 computeSinCosOffset(int32 val);
+
+ // Debug
friend class Console;
+ ResourcePackId _delayedSceneIndex;
+ int32 _delayedVideoIndex;
};
} // namespace Asylum
diff --git a/engines/asylum/console.cpp b/engines/asylum/console.cpp
index 8af6e92e06..a15f893353 100644
--- a/engines/asylum/console.cpp
+++ b/engines/asylum/console.cpp
@@ -36,6 +36,7 @@
#include "asylum/system/screen.h"
#include "asylum/views/scene.h"
+#include "asylum/views/video.h"
#include "asylum/asylum.h"
#include "asylum/respack.h"
@@ -328,8 +329,7 @@ bool Console::cmdPlayVideo(int32 argc, const char **argv) {
return true;
}
- getScreen()->clear();
- getScript()->setDelayedVideoIndex(index);
+ _vm->_delayedVideoIndex = index;
return false;
}
@@ -374,7 +374,7 @@ bool Console::cmdChangeScene(int32 argc, const char **argv) {
return true;
}
- getScript()->setDelayedSceneIndex(index);
+ _vm->_delayedSceneIndex = index;
return false;
}
diff --git a/engines/asylum/eventhandler.h b/engines/asylum/eventhandler.h
index d2ad815a0f..ef0df99a8a 100644
--- a/engines/asylum/eventhandler.h
+++ b/engines/asylum/eventhandler.h
@@ -45,13 +45,21 @@ enum AsylumEventType {
};
struct AsylumEvent : public Common::Event {
- AsylumEvent() : Event() {}
+ AsylumEvent() : Event() {
+ param1 = 0;
+ param2 = 0;
+ }
// Since we don't feed any custom message into the event manager,
// we can safely use our own custom event type.
- AsylumEvent(AsylumEventType msgType) : Event() {
+ AsylumEvent(AsylumEventType msgType, int32 p1 = 0, int32 p2 = 0) : Event() {
type = (Common::EventType)msgType;
+ param1 = p1;
+ param2 = p2;
}
+
+ int32 param1;
+ int32 param2;
};
class EventHandler {
diff --git a/engines/asylum/resources/encounters.cpp b/engines/asylum/resources/encounters.cpp
index 65592f153d..1140ae3bc5 100644
--- a/engines/asylum/resources/encounters.cpp
+++ b/engines/asylum/resources/encounters.cpp
@@ -37,6 +37,7 @@
#include "asylum/system/text.h"
#include "asylum/views/scene.h"
+#include "asylum/views/video.h"
#include "asylum/asylum.h"
#include "asylum/respack.h"
@@ -1549,7 +1550,7 @@ void Encounter::runScript() {
if (!getSharedData()->getMatteBarHeight()) {
getScreen()->makeGreyPalette();
getSharedData()->setMatteBarHeight(1);
- getScript()->setDelayedVideoIndex(getVariableInv(entry.param2));
+ getVideo()->play(getVariableInv(entry.param2), this);
getSharedData()->setMatteVar1(1);
getSharedData()->setMattePlaySound(true);
getSharedData()->setMatteInitialized(true);
diff --git a/engines/asylum/resources/script.h b/engines/asylum/resources/script.h
index d9435241b6..23ae54337d 100644
--- a/engines/asylum/resources/script.h
+++ b/engines/asylum/resources/script.h
@@ -160,12 +160,6 @@ public:
*/
void resetQueue();
- // Accessors
- int32 getDelayedVideoIndex() const { return _delayedVideoIndex; }
- void setDelayedVideoIndex(int32 val) { _delayedVideoIndex = val; }
- ResourcePackId getDelayedSceneIndex() const { return _delayedSceneIndex; }
- void setDelayedSceneIndex(ResourcePackId id) { _delayedSceneIndex = id; }
-
bool isProcessingSkipped() { return _skipProcessing; }
// Serializable
diff --git a/engines/asylum/system/screen.cpp b/engines/asylum/system/screen.cpp
index c5ed491d4f..5c3702729d 100644
--- a/engines/asylum/system/screen.cpp
+++ b/engines/asylum/system/screen.cpp
@@ -141,8 +141,7 @@ void Screen::drawWideScreenBars(int16 barSize) const {
}
void Screen::fillRect(int32 x, int32 y, int32 width, int32 height, int32 color) {
- _vm->_system->lockScreen()->fillRect(Common::Rect(x, y, x + width, y + height), color);
- _vm->_system->unlockScreen();
+ _backBuffer.fillRect(Common::Rect(x, y, x + width, y + height), color);
}
void Screen::copyBackBufferToScreen() {
@@ -239,6 +238,10 @@ void Screen::makeGreyPalette() {
warning("[Screen::makeGreyPalette] Not implemented!");
}
+void Screen::setupPalette(byte *buffer, int start, int count) {
+ warning("[Screen::setupPalette] Not implemented!");
+}
+
//////////////////////////////////////////////////////////////////////////
// Gamma
//////////////////////////////////////////////////////////////////////////
diff --git a/engines/asylum/system/screen.h b/engines/asylum/system/screen.h
index 84c953de45..b7e4d8964c 100644
--- a/engines/asylum/system/screen.h
+++ b/engines/asylum/system/screen.h
@@ -95,6 +95,7 @@ public:
void startPaletteFade(ResourceId resourceId, int32 milliseconds, int32 param);
void updatePalette(int32 param);
void makeGreyPalette();
+ void setupPalette(byte *buffer, int start, int count);
// Gamma
void setGammaLevel(ResourceId id, int32 val);
@@ -114,6 +115,9 @@ public:
void clearGraphicsInQueue();
void deleteGraphicFromQueue(ResourceId resourceId);
+ // Used by Video
+ void copyToBackBuffer(byte *buffer, int32 pitch, int32 x, int32 y, uint32 width, uint32 height);
+
// Debug
void copyToBackBufferClipped(Graphics::Surface *surface, int x, int y);
@@ -146,8 +150,6 @@ private:
void blt(Common::Rect *dest, GraphicFrame* frame, Common::Rect *source, int32 flags, bool useColorKey);
void bltFast(int32 dX, int32 dY, GraphicFrame* frame, Common::Rect *source, bool useColorKey);
-
- void copyToBackBuffer(byte *buffer, int32 pitch, int32 x, int32 y, uint32 width, uint32 height);
void copyToBackBufferWithTransparency(byte *buffer, int32 pitch, int32 x, int32 y, int32 width, int32 height);
};
diff --git a/engines/asylum/system/text.cpp b/engines/asylum/system/text.cpp
index 1b40985f71..de51b430c2 100644
--- a/engines/asylum/system/text.cpp
+++ b/engines/asylum/system/text.cpp
@@ -51,17 +51,21 @@ Text::~Text() {
_vm = NULL;
}
-void Text::loadFont(ResourceId resourceId) {
+ResourceId Text::loadFont(ResourceId resourceId) {
if (_fontResource && resourceId == _fontResource->getResourceId())
- return;
+ return resourceId;
+
+ ResourceId previousFont = _fontResource ? _fontResource->getResourceId() : kResourceNone;
delete _fontResource;
- _fontResource = new GraphicResource(_vm, resourceId);
+ _fontResource = NULL;
if (resourceId != kResourceNone) {
- // load font flag data
+ _fontResource = new GraphicResource(_vm, resourceId);
_curFontFlags = Common::Rational(_fontResource->getData().flags, 16).toInt() & 0x0F;
}
+
+ return previousFont;
}
void Text::setPosition(int32 x, int32 y) {
diff --git a/engines/asylum/system/text.h b/engines/asylum/system/text.h
index 1e1be18dad..4363683b9c 100644
--- a/engines/asylum/system/text.h
+++ b/engines/asylum/system/text.h
@@ -47,7 +47,7 @@ public:
Text(AsylumEngine *engine);
~Text();
- void loadFont(ResourceId resourceId);
+ ResourceId loadFont(ResourceId resourceId);
void setPosition(int32 x, int32 y);
int32 getWidth(char c);
diff --git a/engines/asylum/views/menu.cpp b/engines/asylum/views/menu.cpp
index 2d8a6bbb19..ebf2938148 100644
--- a/engines/asylum/views/menu.cpp
+++ b/engines/asylum/views/menu.cpp
@@ -354,7 +354,7 @@ bool MainMenu::init() {
_needEyeCursorInit = true;
// Play start video
- getVideo()->playVideo(0);
+ getVideo()->play(0, this);
// If no savegame is present, start the game directly
if (!getSaveLoad()->hasSavegames()) {
diff --git a/engines/asylum/views/video.cpp b/engines/asylum/views/video.cpp
index 1cc1ae442e..6af4ff437d 100644
--- a/engines/asylum/views/video.cpp
+++ b/engines/asylum/views/video.cpp
@@ -26,8 +26,11 @@
#include "asylum/views/video.h"
#include "asylum/system/config.h"
+#include "asylum/system/cursor.h"
#include "asylum/system/graphics.h"
#include "asylum/system/savegame.h"
+#include "asylum/system/screen.h"
+#include "asylum/system/sound.h"
#include "asylum/system/text.h"
#include "asylum/asylum.h"
@@ -36,98 +39,176 @@
namespace Asylum {
-Video::Video(AsylumEngine *engine, Audio::Mixer *mixer) : _vm(engine), _skipVideo(false) {
- Common::Event stopEvent;
- _stopEvents.clear();
- stopEvent.type = Common::EVENT_KEYDOWN;
- stopEvent.kbd.keycode = Common::KEYCODE_ESCAPE;
- _stopEvents.push_back(stopEvent);
-
+Video::Video(AsylumEngine *engine, Audio::Mixer *mixer) : _vm(engine),
+ _currentMovie(0), _subtitleIndex(0), _subtitleCounter(0), _previousFont(kResourceNone), _done(false) {
_smkDecoder = new Graphics::SmackerDecoder(mixer);
-
- _text = new VideoText(engine);
- _text->loadFont(MAKE_RESOURCE(kResourcePackShared, 57)); // video font
}
Video::~Video() {
delete _smkDecoder;
- delete _text;
// Zero-out passed pointers
_vm = NULL;
}
-void Video::playVideo(int32 videoNumber) {
- char filename[20];
- sprintf(filename, "mov%03d.smk", videoNumber);
+//////////////////////////////////////////////////////////////////////////
+// Event Handler
+//////////////////////////////////////////////////////////////////////////
+bool Video::handleEvent(const AsylumEvent &evt) {
+ switch ((uint32)evt.type) {
+ default:
+ break;
+
+ case EVENT_ASYLUM_INIT:
+ _previousFont = getText()->loadFont(MAKE_RESOURCE(kResourcePackShared, 57));
+ _subtitleCounter = 0;
+ _subtitleIndex = -1;
+ break;
+
+ case EVENT_ASYLUM_DEINIT:
+ getScreen()->clear();
+ getText()->loadFont(_previousFont);
+ break;
+
+ case EVENT_ASYLUM_SUBTITLE: {
+ int32 newIndex = (evt.param2 == 1) ? evt.param1 : -1;
+
+ if (_subtitleIndex != newIndex) {
+ _subtitleIndex = newIndex;
+ _subtitleCounter = 2;
+ }
- getSaveLoad()->setMovieViewed(videoNumber);
+ if (_subtitleCounter > 0) {
+ getScreen()->fillRect(0, 400, 640, 80, 0);
+
+ if (_subtitleIndex >= 0) {
+ char *text1 = getText()->get((ResourceId)_currentMovie);
+
+ int32 y = 10 * (44 - getText()->draw(0, 99, kTextCalculate, 10, 400, 20, 620, text1));
+ if (y <= 400)
+ y = 405;
+
+ char *text = getText()->get(_subtitles[_subtitleIndex].resourceId);
+ getText()->draw(0, 99, kTextCenter, 10, y, 20, 620, text);
+ }
+
+ --_subtitleCounter;
+ }
+
+ return true;
+ }
- if (!_smkDecoder->loadFile(filename)) {
- _smkDecoder->close();
+ case Common::EVENT_LBUTTONDOWN:
+ case Common::EVENT_KEYDOWN:
+ _done = true;
+ getScreen()->clear();
- error("[Video::playVideo] Invalid video index (%d)", videoNumber);
+ // Original set a value that does not seems to be used anywhere
+ return true;
}
- bool lastMouseState = g_system->showMouse(false);
- _skipVideo = false;
+ return false;
+}
- if (Config.showMovieSubtitles)
- loadSubtitles(videoNumber);
+//////////////////////////////////////////////////////////////////////////
+// Playing
+//////////////////////////////////////////////////////////////////////////
+void Video::play(int32 videoNumber, EventHandler *handler) {
+ getSaveLoad()->setMovieViewed(videoNumber);
+ _currentMovie = videoNumber;
+
+ // Prepare
+ getCursor()->hide();
+ getSharedData()->setFlag(kFlag1, true);
+ getScreen()->paletteFade(0, 25, 10);
+ getSound()->stopAll();
+
+ // Play movie
+ _vm->switchEventHandler(this);
+ play(Common::String::format("mov%03d.smk", videoNumber), Config.showMovieSubtitles);
+
+ // Cleanup and switch to previous event handler
+ getCursor()->show();
+ getSharedData()->setFlag(kFlag1, false);
+ _vm->switchEventHandler(handler);
+}
+
+void Video::play(Common::String filename, bool showSubtitles) {
+ if (!_smkDecoder->loadFile(filename))
+ error("[Video::playVideo] Invalid video index (%d)", _currentMovie);
int32 x = Common::Rational(g_system->getWidth() - _smkDecoder->getWidth(), 2).toInt();
int32 y = Common::Rational(g_system->getHeight() - _smkDecoder->getHeight(), 2).toInt();
- while (!_smkDecoder->endOfVideo() && !_skipVideo) {
- processVideoEvents();
- if (_smkDecoder->needsUpdate()) {
- Graphics::Surface *frame = _smkDecoder->decodeNextFrame();
+ getScreen()->clear();
- if (frame) {
- g_system->copyRectToScreen((byte *)frame->pixels, frame->pitch, x, y, frame->w, frame->h);
+ // TODO check flags and setup volume panning
- if(Config.showMovieSubtitles) {
- Graphics::Surface *screen = g_system->lockScreen();
- performPostProcessing((byte *)screen->pixels);
- g_system->unlockScreen();
- }
+ // Load subtitles
+ if (showSubtitles)
+ loadSubtitles();
- if (_smkDecoder->hasDirtyPalette())
- _smkDecoder->setSystemPalette();
+ // Setup playing
+ _done = false;
+ uint32 index = 0;
+ int32 frameStart = 0;
+ int32 frameEnd = 0;
+ int32 currentSubtitle = 0;
- g_system->updateScreen();
+ while (!_done && !_vm->shouldQuit() && !_smkDecoder->endOfVideo()) {
+ _vm->handleEvents();
+
+ if (_smkDecoder->needsUpdate()) {
+ Graphics::Surface *frame = _smkDecoder->decodeNextFrame();
+
+ if (!frame)
+ continue;
+
+ if (_smkDecoder->hasDirtyPalette())
+ setupPalette();
+
+ getScreen()->copyToBackBuffer((byte *)frame->pixels, frame->pitch, x, y, frame->w, frame->h);
+
+ if (showSubtitles) {
+ int32 currentFrame = _smkDecoder->getCurFrame() + 1;
+
+ // Check for next frame
+ if (currentFrame > frameEnd) {
+ if (index < _subtitles.size()) {
+ frameStart = _subtitles[index].frameStart;
+ frameEnd = _subtitles[index].frameEnd;
+ currentSubtitle = index;
+ ++index;
+ }
+ }
+
+ if (currentFrame < frameStart || currentFrame > frameEnd)
+ _vm->notify(EVENT_ASYLUM_SUBTITLE, 0, 0);
+ else
+ _vm->notify(EVENT_ASYLUM_SUBTITLE, currentSubtitle, 1);
}
+
+ getScreen()->copyBackBufferToScreen();
+
+ g_system->updateScreen();
}
g_system->delayMillis(10);
}
-
_smkDecoder->close();
_subtitles.clear();
- g_system->showMouse(lastMouseState);
}
-void Video::performPostProcessing(byte *screen) {
- int32 curFrame = _smkDecoder->getCurFrame();
-
- // Reset subtitle area, by filling it with zeroes
- memset(screen + 640 * 400, 0, 640 * 80);
+void Video::setupPalette() {
+ _smkDecoder->setSystemPalette();
- for (uint32 i = 0; i < _subtitles.size(); i++) {
- VideoSubtitle curSubtitle = _subtitles[i];
- if (curFrame >= curSubtitle.frameStart &&
- curFrame <= curSubtitle.frameEnd) {
- _text->drawMovieSubtitle(screen, curSubtitle.textResourceId);
- break;
- }
- }
+ warning("[Video::setupPalette] Video palette setup not implemented!");
+ //getScreen()->setupPalette(0, 0, 0);
}
-void Video::loadSubtitles(int32 videoNumber) {
- // Read vids.cap
-
+void Video::loadSubtitles() {
char movieToken[10];
- sprintf(movieToken, "[MOV%03d]", videoNumber);
+ sprintf(movieToken, "[MOV%03d]", _currentMovie);
Common::File subsFile;
subsFile.open("vids.cap");
@@ -163,7 +244,7 @@ void Video::loadSubtitles(int32 videoNumber) {
if (!tok)
error("[Video::loadSubtitles] Invalid subtitle (resource id missing)!");
- newSubtitle.textResourceId = (ResourceId)(atoi(tok) + video_subtitle_resourceIds[videoNumber]);
+ newSubtitle.resourceId = (ResourceId)(atoi(tok) + video_subtitle_resourceIds[_currentMovie]);
tok = strtok(NULL, " ");
@@ -176,131 +257,4 @@ void Video::loadSubtitles(int32 videoNumber) {
delete [] buffer;
}
-void Video::processVideoEvents() {
- Common::Event curEvent;
- while (g_system->getEventManager()->pollEvent(curEvent)) {
- if (curEvent.type == Common::EVENT_RTL || curEvent.type == Common::EVENT_QUIT) {
- _skipVideo = true;
- }
-
- for (Common::List<Common::Event>::const_iterator iter = _stopEvents.begin(); iter != _stopEvents.end(); ++iter) {
- if (curEvent.type == iter->type) {
- if (iter->type == Common::EVENT_KEYDOWN || iter->type == Common::EVENT_KEYUP) {
- if (curEvent.kbd.keycode == iter->kbd.keycode) {
- _skipVideo = true;
- break;
- }
- } else {
- _skipVideo = true;
- break;
- }
- }
- }
- }
-}
-
-
-VideoText::VideoText(AsylumEngine *engine) : _vm(engine) {
- _curFontFlags = 0;
- _fontResource = NULL;
-}
-
-VideoText::~VideoText() {
- delete _fontResource;
-
- // Zero-out passed pointers
- _vm = NULL;
-}
-
-void VideoText::loadFont(ResourceId resourceId) {
- delete _fontResource;
-
- _fontResource = new GraphicResource(_vm, resourceId);
-
- if (resourceId != kResourceNone) {
- // load font flag data
- _curFontFlags = Common::Rational(_fontResource->getData().flags, 16).toInt() & 0x0F;
- }
-}
-
-void VideoText::drawMovieSubtitle(byte *screenBuffer, ResourceId resourceId) {
- Common::String textLine[4];
- Common::String tmpLine;
- int32 curLine = 0;
- ResourceEntry *textRes = getResource()->get(resourceId);
- char *text = strdup((const char *)textRes->data); // for strtok
- char *tok = strtok(text, " ");
- int32 startY = 420; // starting y for up to 2 subtitles
- int32 spacing = 30; // spacing for up to 2 subtitles
-
- // Videos can have up to 4 lines of text
- while (tok) {
- tmpLine += tok;
- tmpLine += " ";
- if (getTextWidth(tmpLine.c_str()) > 640) {
- tmpLine = tok;
- curLine++;
- if (curLine >= 2) {
- startY = 410; // starting Y for 3 subtitles
- spacing = 20; // spacing for 3-4 subtitles
- }
- if (curLine >= 3) {
- startY = 402; // starting Y for 4 subtitles
- }
- }
- textLine[curLine] += tok;
- textLine[curLine] += " ";
- tok = strtok(NULL, " ");
- }
-
- for (int32 i = 0; i < curLine + 1; i++) {
- int32 textWidth = getTextWidth(textLine[i].c_str());
- drawText(screenBuffer, (int16)Common::Rational(640 - textWidth, 2).toInt(), (int16)(startY + i * spacing), textLine[i].c_str());
- }
-
- free(text);
-}
-
-int32 VideoText::getTextWidth(const char *text) {
- if (!_fontResource)
- error("[VideoText::getTextWidth] Video text resources not initialized properly!");
-
- int32 width = 0;
-
- while (*text) {
- GraphicFrame *font = _fontResource->getFrame((uint8)*text);
- width += font->surface.w + font->x - _curFontFlags;
-
- text++;
- }
-
- return width;
-}
-
-void VideoText::drawText(byte *screenBuffer, int16 x, int16 y, const char *text) {
- if (!_fontResource)
- error("[VideoText::drawText] Video text resources not initialized properly!");
-
- while (*text) {
- GraphicFrame *fontLetter = _fontResource->getFrame((uint8)*text);
- copyToVideoFrame(screenBuffer, fontLetter, x, y + fontLetter->y);
- x += (int16)(fontLetter->surface.w + fontLetter->x - _curFontFlags);
- text++;
- }
-}
-
-void VideoText::copyToVideoFrame(byte *screenBuffer, GraphicFrame *frame, int32 x, int32 y) const {
- uint16 h = frame->surface.h;
- uint16 w = frame->surface.w;
- int32 screenBufferPitch = 640;
- byte *buffer = (byte *)frame->surface.pixels;
- byte *dest = screenBuffer + y * screenBufferPitch + x;
-
- while (h--) {
- memcpy(dest, buffer, w);
- dest += screenBufferPitch;
- buffer += frame->surface.w;
- }
-}
-
} // end of namespace Asylum
diff --git a/engines/asylum/views/video.h b/engines/asylum/views/video.h
index 994c80373b..926516ef45 100644
--- a/engines/asylum/views/video.h
+++ b/engines/asylum/views/video.h
@@ -26,6 +26,7 @@
#ifndef ASYLUM_VIDEO_H
#define ASYLUM_VIDEO_H
+#include "asylum/eventhandler.h"
#include "asylum/shared.h"
#include "common/array.h"
@@ -48,54 +49,62 @@ struct GraphicFrame;
struct VideoSubtitle {
int frameStart;
int frameEnd;
- ResourceId textResourceId;
+ ResourceId resourceId;
};
-class Video {
+class Video : public EventHandler {
public:
Video(AsylumEngine *engine, Audio::Mixer *mixer);
virtual ~Video();
- void playVideo(int32 videoNumber);
+ /**
+ * Plays a video.
+ *
+ * @param videoNumber The video number.
+ * @param handler The previous event handler.
+ */
+ void play(int32 videoNumber, EventHandler *handler);
+
+ /**
+ * Handle event.
+ *
+ * @param evt The event.
+ *
+ * @return true if it succeeds, false if it fails.
+ */
+ bool handleEvent(const AsylumEvent &evt);
private:
AsylumEngine *_vm;
- void performPostProcessing(byte *screen);
- void loadSubtitles(int32 videoNumber);
- void processVideoEvents();
-
- bool _skipVideo;
- VideoText *_text;
Graphics::SmackerDecoder *_smkDecoder;
- Common::List<Common::Event> _stopEvents;
- Common::Array<VideoSubtitle> _subtitles;
-}; // end of class Video
-
-// The VideoText class has some methods from the Text class,
-// but it differs from the text class: this class draws text
-// to a predefined screen buffer, whereas the Text class draws
-// text directly to the screen
-class VideoText {
-public:
- VideoText(AsylumEngine *engine);
- ~VideoText();
-
- void loadFont(ResourceId resourceId);
- void drawMovieSubtitle(byte *screenBuffer, ResourceId resourceId);
-
-private:
- AsylumEngine *_vm;
-
- int32 getTextWidth(const char *text);
-
- void drawText(byte *screenBuffer, int16 x, int16 y, const char *text);
- void copyToVideoFrame(byte *screenBuffer, GraphicFrame *frame, int x, int y) const;
-
- GraphicResource *_fontResource;
- uint8 _curFontFlags;
-
-}; // end of class VideoText
+ Common::Array<VideoSubtitle> _subtitles;
+
+ int32 _currentMovie;
+ int32 _subtitleIndex;
+ int32 _subtitleCounter;
+ ResourceId _previousFont;
+ bool _done;
+
+
+ /**
+ * Plays the given file.
+ *
+ * @param filename Filename of the file.
+ * @param showSubtitles true to show, false to hide the subtitles.
+ */
+ void play(Common::String filename, bool showSubtitles);
+
+ /**
+ * Sets up the palette.
+ */
+ void setupPalette();
+
+ /**
+ * Loads the subtitles (vids.cap)
+ */
+ void loadSubtitles();
+};
} // end of namespace Asylum
Commit: 5cf0c83dc270f75408ddf6527e73a0cd8fc812e9
https://github.com/scummvm/scummvm/commit/5cf0c83dc270f75408ddf6527e73a0cd8fc812e9
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:39+02:00
Commit Message:
ASYLUM: Implement MainMenu::keySaveGame()
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@682 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/system/savegame.cpp
engines/asylum/system/savegame.h
engines/asylum/views/menu.cpp
engines/asylum/views/menu.h
diff --git a/engines/asylum/system/savegame.cpp b/engines/asylum/system/savegame.cpp
index c6600fbf07..307e7e6c64 100644
--- a/engines/asylum/system/savegame.cpp
+++ b/engines/asylum/system/savegame.cpp
@@ -446,5 +446,22 @@ void Savegame::loadMoviesViewed() {
delete movies;
}
+//////////////////////////////////////////////////////////////////////////
+// Accessors
+//////////////////////////////////////////////////////////////////////////
+void Savegame::setName(uint32 index, Common::String name) {
+ if (index > ARRAYSIZE(_names) - 1)
+ error("[Savegame::setName] Invalid index (was: %d, max: %d)", index, ARRAYSIZE(_names) - 1);
+
+ _names[index] = name;
+}
+
+Common::String Savegame::getName(uint32 index) {
+ if (index > ARRAYSIZE(_names) - 1)
+ error("[Savegame::getName] Invalid index (was: %d, max: %d)", index, ARRAYSIZE(_names) - 1);
+
+ return _names[index];
+}
+
} // End of namespace Asylum
diff --git a/engines/asylum/system/savegame.h b/engines/asylum/system/savegame.h
index bde56e5cc8..d5c771b794 100644
--- a/engines/asylum/system/savegame.h
+++ b/engines/asylum/system/savegame.h
@@ -95,6 +95,16 @@ public:
uint32 getMoviesViewed(byte *movieList);
void loadMoviesViewed();
+ //////////////////////////////////////////////////////////////////////////
+ // Accessors
+ //////////////////////////////////////////////////////////////////////////
+ void setName(uint32 index, Common::String name);
+ Common::String getName(uint32 index);
+
+ Common::String *getName() { return &_names[_index]; }
+ void setIndex(uint32 index) { _index = index; }
+ uint32 getIndex() { return _index; }
+
private:
AsylumEngine* _vm;
diff --git a/engines/asylum/views/menu.cpp b/engines/asylum/views/menu.cpp
index ebf2938148..539d61a35b 100644
--- a/engines/asylum/views/menu.cpp
+++ b/engines/asylum/views/menu.cpp
@@ -67,12 +67,14 @@ MainMenu::MainMenu(AsylumEngine *vm): _vm(vm) {
_textScroll = 0;
_creditsFrameIndex = 0;
_needEyeCursorInit = false;
+ memset(&_iconFrames, 0, sizeof(_iconFrames));
// Movies
_movieCount = 0;
memset(&_movieList, 0 , sizeof(_movieList));
- memset(&_iconFrames, 0, sizeof(_iconFrames));
+ // Savegames
+ _prefixWidth = 0;
}
MainMenu::~MainMenu() {
@@ -1409,7 +1411,49 @@ void MainMenu::clickShowCredits() {
// Key handlers
//////////////////////////////////////////////////////////////////////////
void MainMenu::keySaveGame(const AsylumEvent &evt) {
- error("[MainMenu::keySaveGame] Not implemented!");
+ if (!_dword_455DD8)
+ return;
+
+ switch (evt.kbd.keycode) {
+ default:
+ if (evt.kbd.ascii > 255 || !isalnum(evt.kbd.ascii))
+ break;
+
+ if (getSaveLoad()->getName()->size() < 44) {
+ int32 width = getText()->getWidth(getSaveLoad()->getName()->c_str());
+
+ bool test = false;
+ if ((getSaveLoad()->getIndex() % 12) >= 6)
+ test = (width + _prefixWidth + 350 == 630);
+ else
+ test = (width + _prefixWidth + 30 == 340);
+
+ if (test)
+ *getSaveLoad()->getName() += (char)evt.kbd.ascii;
+ }
+ break;
+
+ case Common::KEYCODE_RETURN:
+ _dword_455DD8 = false;
+ getSaveLoad()->save();
+ break;
+
+ case Common::KEYCODE_ESCAPE:
+ _dword_455C80 = false;
+ _dword_455DD8 = false;
+ *getSaveLoad()->getName() = _previousName;
+ getCursor()->show();
+ break;
+
+ case Common::KEYCODE_BACKSPACE:
+ if (getSaveLoad()->getName()->size())
+ getSaveLoad()->getName()->deleteLastChar();
+ break;
+
+ case Common::KEYCODE_PERIOD:
+ *getSaveLoad()->getName() = "";
+ break;
+ }
}
void MainMenu::keyKeyboardConfig(const AsylumEvent &evt) {
diff --git a/engines/asylum/views/menu.h b/engines/asylum/views/menu.h
index 886e7760ed..0352d994a7 100644
--- a/engines/asylum/views/menu.h
+++ b/engines/asylum/views/menu.h
@@ -123,6 +123,10 @@ private:
byte _movieList[196];
uint32 _movieCount;
+ // Savegames
+ Common::String _previousName;
+ int32 _prefixWidth;
+
/**
* Setups menu screen
*/
Commit: e7366c3a91e215aa48fe3a855e2ea3f9302c0cfa
https://github.com/scummvm/scummvm/commit/e7366c3a91e215aa48fe3a855e2ea3f9302c0cfa
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:39+02:00
Commit Message:
ASYLUM: Rename MainMenu to Menu
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@683 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/asylum.cpp
engines/asylum/asylum.h
engines/asylum/views/menu.cpp
engines/asylum/views/menu.h
diff --git a/engines/asylum/asylum.cpp b/engines/asylum/asylum.cpp
index 90f22fd75c..6b721c8f17 100644
--- a/engines/asylum/asylum.cpp
+++ b/engines/asylum/asylum.cpp
@@ -72,7 +72,7 @@
namespace Asylum {
AsylumEngine::AsylumEngine(OSystem *system, const ADGameDescription *gd) : Engine(system), _gameDescription(gd),
- _console(NULL), _cursor(NULL), _encounter(NULL), _mainMenu(NULL), _resource(NULL), _savegame(NULL),
+ _console(NULL), _cursor(NULL), _encounter(NULL), _menu(NULL), _resource(NULL), _savegame(NULL),
_scene(NULL), _screen(NULL), _script(NULL), _sound(NULL), _text(NULL), _video(NULL), _handler(NULL) {
// Init data
@@ -118,7 +118,7 @@ AsylumEngine::~AsylumEngine() {
delete _sound;
delete _text;
delete _video;
- delete _mainMenu;
+ delete _menu;
delete _resource;
delete _console;
@@ -158,8 +158,8 @@ Common::Error AsylumEngine::run() {
initSinCosTables(80.0, 40, 40);
// Create main menu
- _mainMenu = new MainMenu(this);
- _handler = _mainMenu;
+ _menu = new Menu(this);
+ _handler = _menu;
// Load config
Config.read();
@@ -249,7 +249,7 @@ void AsylumEngine::restart() {
void AsylumEngine::reset() {
// Set game as started
- _mainMenu->setGameStarted();
+ _menu->setGameStarted();
// Reset puzzles
for (uint32 i = 0; i < ARRAYSIZE(_puzzles); i++)
@@ -275,7 +275,7 @@ void AsylumEngine::playIntro() {
_sound->playMusic(kResourceNone, 0);
// TODO convert to new event handling
- _video->play(1, _mainMenu);
+ _video->play(1, _menu);
if (_scene->worldstats()->musicCurrentResourceIndex != kMusicStopped)
_sound->playMusic(MAKE_RESOURCE(kResourcePackMusic, _scene->worldstats()->musicCurrentResourceIndex));
@@ -301,7 +301,7 @@ void AsylumEngine::playIntro() {
}
void AsylumEngine::handleEvents() {
- if (!_console || !_video || !_screen || !_sound || !_mainMenu)
+ if (!_console || !_video || !_screen || !_sound || !_menu)
error("[AsylumEngine::handleEvents] Subsystems not initialized properly!");
// Show the debugger if required
@@ -365,7 +365,7 @@ void AsylumEngine::handleEvents() {
}
void AsylumEngine::processDelayedEvents() {
- if (!_video || !_sound || !_mainMenu)
+ if (!_video || !_sound || !_menu)
error("[AsylumEngine::processDelayedEvents] Subsystems not initialized properly!");
// check for a delayed scene change
diff --git a/engines/asylum/asylum.h b/engines/asylum/asylum.h
index f95c68ac8d..db7b1b12a7 100644
--- a/engines/asylum/asylum.h
+++ b/engines/asylum/asylum.h
@@ -69,7 +69,7 @@ namespace Asylum {
class Puzzle;
class Cursor;
class Encounter;
-class MainMenu;
+class Menu;
class ResourceManager;
class Savegame;
class Scene;
@@ -149,7 +149,7 @@ public:
// Game
Cursor *cursor() { return _cursor; }
Encounter *encounter() { return _encounter; }
- MainMenu *menu() { return _mainMenu; }
+ Menu *menu() { return _menu; }
ResourceManager *resource() { return _resource; }
Savegame *savegame() { return _savegame; }
Scene *scene() { return _scene; }
@@ -229,7 +229,7 @@ private:
// Game
Cursor *_cursor;
Encounter *_encounter;
- MainMenu *_mainMenu;
+ Menu *_menu;
ResourceManager *_resource;
Savegame *_savegame;
Scene *_scene;
diff --git a/engines/asylum/views/menu.cpp b/engines/asylum/views/menu.cpp
index 539d61a35b..712e78baaa 100644
--- a/engines/asylum/views/menu.cpp
+++ b/engines/asylum/views/menu.cpp
@@ -46,7 +46,7 @@
namespace Asylum {
-MainMenu::MainMenu(AsylumEngine *vm): _vm(vm) {
+Menu::Menu(AsylumEngine *vm): _vm(vm) {
_initGame = false;
_activeScreen = kMenuNone;
@@ -77,7 +77,7 @@ MainMenu::MainMenu(AsylumEngine *vm): _vm(vm) {
_prefixWidth = 0;
}
-MainMenu::~MainMenu() {
+Menu::~Menu() {
// Zero-out passed pointers
_vm = NULL;
}
@@ -85,7 +85,7 @@ MainMenu::~MainMenu() {
//////////////////////////////////////////////////////////////////////////
// Loading and setup
//////////////////////////////////////////////////////////////////////////
-void MainMenu::show() {
+void Menu::show() {
getSharedData()->setFlag(kFlagSkipDrawScene, true);
getScreen()->clear();
@@ -105,7 +105,7 @@ void MainMenu::show() {
setup();
}
-void MainMenu::setup() {
+void Menu::setup() {
getScreen()->clear();
// Original fills the screen with black
@@ -142,17 +142,17 @@ void MainMenu::setup() {
}
}
-void MainMenu::leave() {
+void Menu::leave() {
_activeScreen = kMenuNone;
getCursor()->set(MAKE_RESOURCE(kResourcePackShared, 2));
getText()->loadFont(kFontYellow);
}
-void MainMenu::switchFont(bool condition) {
+void Menu::switchFont(bool condition) {
getText()->loadFont((condition) ? kFontYellow : kFontBlue);
}
-void MainMenu::closeCredits() {
+void Menu::closeCredits() {
getScreen()->clear();
// Original fills the screen with black
@@ -181,7 +181,7 @@ void MainMenu::closeCredits() {
leave();
}
-MainMenu::MenuScreen MainMenu::findMousePosition() {
+Menu::MenuScreen Menu::findMousePosition() {
for (uint i = 0; i < ARRAYSIZE(menuRects); i++)
if (menuRects[i].contains(getCursor()->position()))
return (MenuScreen)i;
@@ -189,21 +189,21 @@ MainMenu::MenuScreen MainMenu::findMousePosition() {
return kMenuNone;
}
-void MainMenu::playTestSounds() {
+void Menu::playTestSounds() {
_testSoundsPlaying = true;
getSound()->playSound(kAmbientSound, true, Config.ambientVolume);
getSound()->playSound(kSfxSound, true, Config.sfxVolume);
getSound()->playSound(kVoiceSound, true, Config.voiceVolume);
}
-void MainMenu::stopTestSounds() {
+void Menu::stopTestSounds() {
_testSoundsPlaying = false;
getSound()->stop(kAmbientSound);
getSound()->stop(kSfxSound);
getSound()->stop(kVoiceSound);
}
-void MainMenu::adjustMasterVolume(int32 delta) {
+void Menu::adjustMasterVolume(int32 delta) {
int32 *volume = NULL;
int32 volumeIndex = 1;
@@ -257,7 +257,7 @@ void MainMenu::adjustMasterVolume(int32 delta) {
} while (volumeIndex < 6);
}
-void MainMenu::adjustTestVolume() {
+void Menu::adjustTestVolume() {
getSound()->setMusicVolume(Config.musicVolume);
if ((Config.movieVolume / 250 + 20) <= 0)
getSound()->playMusic(_musicResourceId);
@@ -278,7 +278,7 @@ void MainMenu::adjustTestVolume() {
getSound()->playSound(kVoiceSound, true, Config.voiceVolume);
}
-void MainMenu::setupMusic() {
+void Menu::setupMusic() {
getSound()->stopAll();
uint32 index = getScene() ? getWorld()->musicCurrentResourceIndex : kMusicStopped;
@@ -294,7 +294,7 @@ void MainMenu::setupMusic() {
}
}
-void MainMenu::adjustPerformance() {
+void Menu::adjustPerformance() {
// Original reinitialize sound to 11kHz for performance == 0, 22kHz otherwise
getSound()->stopAll();
getSound()->playMusic(kResourceNone, 0);
@@ -308,7 +308,7 @@ void MainMenu::adjustPerformance() {
//////////////////////////////////////////////////////////////////////////
// Event Handler
//////////////////////////////////////////////////////////////////////////
-bool MainMenu::handleEvent(const AsylumEvent &evt) {
+bool Menu::handleEvent(const AsylumEvent &evt) {
switch ((uint32)evt.type) {
default:
break;
@@ -338,7 +338,7 @@ bool MainMenu::handleEvent(const AsylumEvent &evt) {
return false;
}
-bool MainMenu::init() {
+bool Menu::init() {
// TODO: save dialog key codes into sntrm_k.txt (need to figure out why they use such thing) (address 00411CD0)
if (_needEyeCursorInit) {
@@ -399,7 +399,7 @@ bool MainMenu::init() {
return true;
}
-bool MainMenu::update() {
+bool Menu::update() {
uint32 ticks = _vm->getTick();
if (!getSharedData()->getFlag(kFlagRedraw)) {
@@ -530,7 +530,7 @@ bool MainMenu::update() {
return true;
}
-bool MainMenu::music() {
+bool Menu::music() {
if (_activeScreen == kMenuShowCredits
&& _vm->isGameFlagSet(kGameFlagFinishGame)
&& !_dword_455D5C
@@ -546,7 +546,7 @@ bool MainMenu::music() {
return false;
}
-bool MainMenu::key(const AsylumEvent &evt) {
+bool Menu::key(const AsylumEvent &evt) {
switch (_activeScreen) {
default:
break;
@@ -567,7 +567,7 @@ bool MainMenu::key(const AsylumEvent &evt) {
return true;
}
-bool MainMenu::click(const AsylumEvent &evt) {
+bool Menu::click(const AsylumEvent &evt) {
if (evt.type == Common::EVENT_RBUTTONDOWN
&& _activeScreen == kMenuShowCredits) {
clickShowCredits();
@@ -697,7 +697,7 @@ bool MainMenu::click(const AsylumEvent &evt) {
//////////////////////////////////////////////////////////////////////////
// Update handlers
//////////////////////////////////////////////////////////////////////////
-void MainMenu::updateNewGame() {
+void Menu::updateNewGame() {
Common::Point cursor = getCursor()->position();
getText()->loadFont(kFontYellow);
@@ -716,31 +716,31 @@ void MainMenu::updateNewGame() {
getText()->draw(MAKE_RESOURCE(kResourcePackText, 1323));
}
-void MainMenu::updateLoadGame() {
+void Menu::updateLoadGame() {
Common::Point cursor = getCursor()->position();
error("[MainMenu::updateLoadGame] Not implemented!");
}
-void MainMenu::updateSaveGame() {
+void Menu::updateSaveGame() {
Common::Point cursor = getCursor()->position();
error("[MainMenu::updateSaveGame] Not implemented!");
}
-void MainMenu::updateDeleteGame() {
+void Menu::updateDeleteGame() {
Common::Point cursor = getCursor()->position();
error("[MainMenu::updateDeleteGame] Not implemented!");
}
-void MainMenu::updateViewMovies() {
+void Menu::updateViewMovies() {
Common::Point cursor = getCursor()->position();
error("[MainMenu::updateViewMovies] Not implemented!");
}
-void MainMenu::updateQuitGame() {
+void Menu::updateQuitGame() {
Common::Point cursor = getCursor()->position();
getText()->loadFont(kFontYellow);
@@ -757,7 +757,7 @@ void MainMenu::updateQuitGame() {
getText()->draw(MAKE_RESOURCE(kResourcePackText, 1410));
}
-void MainMenu::updateTextOptions() {
+void Menu::updateTextOptions() {
Common::Point cursor = getCursor()->position();
getText()->loadFont(kFontYellow);
@@ -781,7 +781,7 @@ void MainMenu::updateTextOptions() {
getText()->draw(MAKE_RESOURCE(kResourcePackText, 1416));
}
-void MainMenu::updateAudioOptions() {
+void Menu::updateAudioOptions() {
Common::Point cursor = getCursor()->position();
// Size of - and +
@@ -867,7 +867,7 @@ void MainMenu::updateAudioOptions() {
getText()->draw(MAKE_RESOURCE(kResourcePackText, 1431));
}
-void MainMenu::updateSettings() {
+void Menu::updateSettings() {
Common::Point cursor = getCursor()->position();
// Size of - and +
@@ -935,7 +935,7 @@ void MainMenu::updateSettings() {
getText()->draw(MAKE_RESOURCE(kResourcePackText, 1437));
}
-void MainMenu::updateKeyboardConfig() {
+void Menu::updateKeyboardConfig() {
Common::Point cursor = getCursor()->position();
getText()->loadFont(kFontYellow);
@@ -1003,7 +1003,7 @@ void MainMenu::updateKeyboardConfig() {
getText()->draw(MAKE_RESOURCE(kResourcePackText, 1446));
}
-void MainMenu::updateReturnToGame() {
+void Menu::updateReturnToGame() {
Common::Point cursor = getCursor()->position();
getText()->loadFont(kFontYellow);
@@ -1018,7 +1018,7 @@ void MainMenu::updateReturnToGame() {
}
-void MainMenu::updateShowCredits() {
+void Menu::updateShowCredits() {
if (_vm->isGameFlagSet(kGameFlagFinishGame)) {
getScreen()->draw(MAKE_RESOURCE(kResourcePackShared, 33), 0, 0, 0, 0, false);
} else {
@@ -1069,7 +1069,7 @@ void MainMenu::updateShowCredits() {
//////////////////////////////////////////////////////////////////////////
// Click handlers
//////////////////////////////////////////////////////////////////////////
-void MainMenu::clickNewGame() {
+void Menu::clickNewGame() {
Common::Point cursor = getCursor()->position();
if (cursor.x < 247
@@ -1086,31 +1086,31 @@ void MainMenu::clickNewGame() {
}
}
-void MainMenu::clickLoadGame() {
+void Menu::clickLoadGame() {
Common::Point cursor = getCursor()->position();
error("[MainMenu::clickLoadGame] Not implemented!");
}
-void MainMenu::clickSaveGame() {
+void Menu::clickSaveGame() {
Common::Point cursor = getCursor()->position();
error("[MainMenu::clickSaveGame] Not implemented!");
}
-void MainMenu::clickDeleteGame() {
+void Menu::clickDeleteGame() {
Common::Point cursor = getCursor()->position();
error("[MainMenu::clickDeleteGame] Not implemented!");
}
-void MainMenu::clickViewMovies() {
+void Menu::clickViewMovies() {
Common::Point cursor = getCursor()->position();
error("[MainMenu::clickViewMovies] Not implemented!");
}
-void MainMenu::clickQuitGame() {
+void Menu::clickQuitGame() {
Common::Point cursor = getCursor()->position();
if (cursor.x < 247
@@ -1130,7 +1130,7 @@ void MainMenu::clickQuitGame() {
}
}
-void MainMenu::clickTextOptions() {
+void Menu::clickTextOptions() {
Common::Point cursor = getCursor()->position();
if (cursor.x < 350 || cursor.x > (350 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, Config.showMovieSubtitles ? 1414 : 1415))) || cursor.y < 150 || cursor.y > 174) {
@@ -1147,7 +1147,7 @@ void MainMenu::clickTextOptions() {
}
}
-void MainMenu::clickAudioOptions() {
+void Menu::clickAudioOptions() {
Common::Point cursor = getCursor()->position();
// Size of - and +
@@ -1269,7 +1269,7 @@ void MainMenu::clickAudioOptions() {
playTestSounds();
}
-void MainMenu::clickSettings() {
+void Menu::clickSettings() {
Common::Point cursor = getCursor()->position();
// Size of - and +
@@ -1334,7 +1334,7 @@ void MainMenu::clickSettings() {
}
}
-void MainMenu::clickKeyboardConfig() {
+void Menu::clickKeyboardConfig() {
Common::Point cursor = getCursor()->position();
if (cursor.x < 300 || cursor.x > (300 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 1446))) || cursor.y < 340 || cursor.y > (340 + 24)) {
@@ -1384,7 +1384,7 @@ void MainMenu::clickKeyboardConfig() {
}
}
-void MainMenu::clickReturnToGame() {
+void Menu::clickReturnToGame() {
if (_gameStarted) {
if (_musicResourceId != MAKE_RESOURCE(kResourcePackMusic, getWorld()->musicCurrentResourceIndex))
getSound()->playMusic(kResourceNone, 0);
@@ -1403,14 +1403,14 @@ void MainMenu::clickReturnToGame() {
}
}
-void MainMenu::clickShowCredits() {
+void Menu::clickShowCredits() {
closeCredits();
}
//////////////////////////////////////////////////////////////////////////
// Key handlers
//////////////////////////////////////////////////////////////////////////
-void MainMenu::keySaveGame(const AsylumEvent &evt) {
+void Menu::keySaveGame(const AsylumEvent &evt) {
if (!_dword_455DD8)
return;
@@ -1456,7 +1456,7 @@ void MainMenu::keySaveGame(const AsylumEvent &evt) {
}
}
-void MainMenu::keyKeyboardConfig(const AsylumEvent &evt) {
+void Menu::keyKeyboardConfig(const AsylumEvent &evt) {
if (_selectedShortcutIndex == -1)
return;
@@ -1507,7 +1507,7 @@ void MainMenu::keyKeyboardConfig(const AsylumEvent &evt) {
}
}
-void MainMenu::keyShowCredits() {
+void Menu::keyShowCredits() {
closeCredits();
}
diff --git a/engines/asylum/views/menu.h b/engines/asylum/views/menu.h
index 0352d994a7..8cc0419966 100644
--- a/engines/asylum/views/menu.h
+++ b/engines/asylum/views/menu.h
@@ -38,10 +38,10 @@ class ResourcePack;
class Scene;
class Text;
-class MainMenu : public EventHandler {
+class Menu : public EventHandler {
public:
- MainMenu(AsylumEngine *vm);
- ~MainMenu();
+ Menu(AsylumEngine *vm);
+ ~Menu();
/**
* Shows the menu
Commit: 12405a143ea49102fb92f32b2ee2320875965a3d
https://github.com/scummvm/scummvm/commit/12405a143ea49102fb92f32b2ee2320875965a3d
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:39+02:00
Commit Message:
ASYLUM: When running in debug mode, make the scene title faster
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@684 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/views/scenetitle.cpp
diff --git a/engines/asylum/views/scenetitle.cpp b/engines/asylum/views/scenetitle.cpp
index f04ff56713..dcc7c73f0b 100644
--- a/engines/asylum/views/scenetitle.cpp
+++ b/engines/asylum/views/scenetitle.cpp
@@ -80,8 +80,12 @@ void SceneTitle::update(int32 tick) {
// of buffering the various scene resource. Since we don't actually buffer content like the original,
// but load on demand from offset/length within a ResourcePack, the progress indicator is effectively
// useless. It's just in here as "eye candy" :P
+#ifdef DEBUG
if ((tick - _start) % 500 > 100)
_spinnerProgress += 10;
+#else
+ _spinnerProgress += 35;
+#endif
_spinnerFrameIndex++;
Commit: 9ce5f05ba9fd2adaaf61006409b4cd79a8894a0d
https://github.com/scummvm/scummvm/commit/9ce5f05ba9fd2adaaf61006409b4cd79a8894a0d
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:39+02:00
Commit Message:
ASYLUM: Implement Menu::updateViewMovies()
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@685 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/staticres.h
engines/asylum/system/savegame.cpp
engines/asylum/system/savegame.h
engines/asylum/views/menu.cpp
engines/asylum/views/menu.h
diff --git a/engines/asylum/staticres.h b/engines/asylum/staticres.h
index 823bf0f5e2..53bac139a0 100644
--- a/engines/asylum/staticres.h
+++ b/engines/asylum/staticres.h
@@ -44,6 +44,12 @@ const Common::Rect menuRects[12] = {Common::Rect( 40, 19, 93, 68),
const int eyeFrameIndex[8] = {3, 5, 1, 7, 4, 8, 2, 6};
+const int moviesCd[49] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 3, 3,
+ 3, 3, 3, 3, 3, 3, 3, 3, 2};
+
/** Default Actor Indices by Scene */
const int actorType[16] = {0, 0, 0, 0, 1, 0, 2, 0, 3, 0, 1, 1, 3, 0, 0, 0};
diff --git a/engines/asylum/system/savegame.cpp b/engines/asylum/system/savegame.cpp
index 307e7e6c64..9a9c206462 100644
--- a/engines/asylum/system/savegame.cpp
+++ b/engines/asylum/system/savegame.cpp
@@ -170,7 +170,7 @@ bool Savegame::quickSave() {
return false;
// Read game name
- seek(file, 1, "Level");
+ seek(file, 1, "Level");
_names[_index] = read(file, 45, "Game Name");
delete file;
@@ -262,7 +262,7 @@ bool Savegame::loadData(Common::String filename) {
if (!readHeader(file)) {
getWorld()->chapter = kChapterInvalid;
return false;
- }
+ }
read(file, _vm, 1512, 1, "Game Stats");
read(file, getWorld(), 951928, 1, "World Stats");
@@ -274,7 +274,7 @@ bool Savegame::loadData(Common::String filename) {
if (getWorld()->numScripts)
read(file, getScript(), 7096, getWorld()->numScripts, "Action Lists");
-
+
uint32 tick = read(file, "Time");
_vm->setTick(tick);
@@ -339,7 +339,7 @@ Common::String Savegame::read(Common::InSaveFile *file, uint32 strLength, Common
if (strLength > count)
error("[Savegame::read] Count too large (asked: %d, present: %d)", strLength, count);
-
+
char *str = new char[strLength + 1];
memset(str, 0, strLength + 1);
file->read(str, strLength);
@@ -359,7 +359,7 @@ void Savegame::read(Common::InSaveFile *file, Common::Serializable *data, uint32
uint32 fileCount = file->readUint32LE();
if (count > fileCount)
error("[Savegame::read] Count too large (asked: %d, present: %d)", count, fileCount);
-
+
if (fileCount * fileSize == 0)
return;
@@ -417,8 +417,8 @@ void Savegame::setMovieViewed(uint32 index) {
}
}
-uint32 Savegame::getMoviesViewed(byte *movieList) {
- memset(movieList, -1, 196);
+uint32 Savegame::getMoviesViewed(int32 *movieList) {
+ memset(movieList, -1, 196 * sizeof(int32));
uint32 count = 0;
diff --git a/engines/asylum/system/savegame.h b/engines/asylum/system/savegame.h
index d5c771b794..95044bd77a 100644
--- a/engines/asylum/system/savegame.h
+++ b/engines/asylum/system/savegame.h
@@ -92,7 +92,7 @@ public:
// Movies
//////////////////////////////////////////////////////////////////////////
void setMovieViewed(uint32 index);
- uint32 getMoviesViewed(byte *movieList);
+ uint32 getMoviesViewed(int32 *movieList);
void loadMoviesViewed();
//////////////////////////////////////////////////////////////////////////
@@ -100,7 +100,7 @@ public:
//////////////////////////////////////////////////////////////////////////
void setName(uint32 index, Common::String name);
Common::String getName(uint32 index);
-
+
Common::String *getName() { return &_names[_index]; }
void setIndex(uint32 index) { _index = index; }
uint32 getIndex() { return _index; }
@@ -194,21 +194,21 @@ private:
void seek(Common::InSaveFile *file, uint32 offset, Common::String description);
/**
- * Reads data from a file.
+ * Reads data from a file.
*
- * @param [in,out] file If non-null, the file.
- * @param description The description.
+ * @param [in,out] file If non-null, the file.
+ * @param description The description.
*
* @return the value
*/
uint32 read(Common::InSaveFile *file, Common::String description);
/**
- * Reads data from a file.
+ * Reads data from a file.
*
- * @param [in,out] file If non-null, the file.
- * @param strLength Length of the string.
- * @param description The description.
+ * @param [in,out] file If non-null, the file.
+ * @param strLength Length of the string.
+ * @param description The description.
*
* @return the string
*/
diff --git a/engines/asylum/views/menu.cpp b/engines/asylum/views/menu.cpp
index 712e78baaa..f33af2c5be 100644
--- a/engines/asylum/views/menu.cpp
+++ b/engines/asylum/views/menu.cpp
@@ -669,7 +669,7 @@ bool Menu::click(const AsylumEvent &evt) {
_dword_455C78 = false;
_dword_456288 = 0;
_textScroll = 0;
- _movieCount = getSaveLoad()->getMoviesViewed((byte *)&_movieList);
+ _movieCount = getSaveLoad()->getMoviesViewed((int32 *)&_movieList);
break;
case kMenuKeyboardConfig:
@@ -737,7 +737,128 @@ void Menu::updateDeleteGame() {
void Menu::updateViewMovies() {
Common::Point cursor = getCursor()->position();
- error("[MainMenu::updateViewMovies] Not implemented!");
+ char text[100];
+ char text2[100];
+
+ if (!_dword_455C78) {
+ getText()->loadFont(kFontYellow);
+ sprintf((char *)&text2, getText()->get(MAKE_RESOURCE(kResourcePackText, 1352)), getSharedData()->cdNumber);
+ getText()->drawCentered(10, 100, 620, (char *)&text2);
+
+ int32 index = _textScroll;
+ for (int32 y = 150; y < 324; y += 29) {
+ if (index >= ARRAYSIZE(_movieList))
+ break;
+
+ if (_movieList[index] != -1 ) {
+ sprintf((char *)&text, "%d. %s ", index + 1, getText()->get(MAKE_RESOURCE(kResourcePackText, 1359 + _movieList[index])));
+ sprintf((char *)&text2, getText()->get(MAKE_RESOURCE(kResourcePackText, 1356)), moviesCd[_movieList[index]]);
+ strcat((char *)&text, (char *)&text2);
+
+ if (getCursor()->isHidden()
+ || cursor.x < 30 || cursor.x > (30 + getText()->getWidth((char *)&text))
+ || cursor.y < y || cursor.y > (y + 24))
+ getText()->loadFont(kFontYellow);
+ else
+ getText()->loadFont(kFontBlue);
+
+ getText()->setPosition(30, y);
+ getText()->draw((char *)&text);
+ }
+
+ ++index;
+ }
+
+ for (int32 y = 150; y < 324; y += 29) {
+ if (index >= ARRAYSIZE(_movieList))
+ break;
+
+ if (_movieList[index] != -1 ) {
+ sprintf((char *)&text, "%d. %s ", index + 1, getText()->get(MAKE_RESOURCE(kResourcePackText, 1359 + _movieList[index])));
+ sprintf((char *)&text2, getText()->get(MAKE_RESOURCE(kResourcePackText, 1356)), moviesCd[_movieList[index]]);
+ strcat((char *)&text, (char *)&text2);
+
+ if (getCursor()->isHidden()
+ || cursor.x < 350 || cursor.x > (350 + getText()->getWidth((char *)&text))
+ || cursor.y < y || cursor.y > (y + 24))
+ getText()->loadFont(kFontYellow);
+ else
+ getText()->loadFont(kFontBlue);
+
+ getText()->setPosition(350, y);
+ getText()->draw((char *)&text);
+ }
+
+ index++;
+ }
+
+ //////////////////////////////////////////////////////////////////////////
+ // Previous page
+ if (getCursor()->isHidden()
+ || cursor.x < 30 || cursor.x > (30 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 1353)))
+ || cursor.y < 340 || cursor.y > (340 + 24))
+ getText()->loadFont(kFontYellow);
+ else
+ getText()->loadFont(kFontBlue);
+
+ getText()->setPosition(30, 340);
+ getText()->draw(MAKE_RESOURCE(kResourcePackText, 1353));
+
+ //////////////////////////////////////////////////////////////////////////
+ // Main Menu
+ if (getCursor()->isHidden()
+ || cursor.x < 300 || cursor.x > (300 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 1355)))
+ || cursor.y < 340 || cursor.y > (340 + 24))
+ getText()->loadFont(kFontYellow);
+ else
+ getText()->loadFont(kFontBlue);
+
+ getText()->setPosition(300, 340);
+ getText()->draw(MAKE_RESOURCE(kResourcePackText, 1355));
+
+ //////////////////////////////////////////////////////////////////////////
+ // Next Page
+ if (getCursor()->isHidden()
+ || cursor.x < 550 || cursor.x > (550 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 1354)))
+ || cursor.y < 340 || cursor.y > (340 + 24))
+ getText()->loadFont(kFontYellow);
+ else
+ getText()->loadFont(kFontBlue);
+
+ getText()->setPosition(550, 340);
+ getText()->draw(MAKE_RESOURCE(kResourcePackText, 1354));
+
+ //////////////////////////////////////////////////////////////////////////
+ // Play video if needed
+ if (_needEyeCursorInit) {
+ getSound()->playMusic(0, 0);
+
+ getVideo()->play(getSaveLoad()->getIndex(), this);
+
+ getSound()->playMusic(_musicResourceId);
+ }
+
+ return;
+ }
+
+ getText()->loadFont(kFontYellow);
+ sprintf((char *)&text2, getText()->get(MAKE_RESOURCE(kResourcePackText, 1357)), getSharedData()->cdNumber);
+ getText()->drawCentered(10, 100, 620, text2);
+
+ strcpy((char *)&text, getText()->get(MAKE_RESOURCE(kResourcePackText, 1359)));
+ sprintf((char *)&text2, getText()->get((ResourceId)getSaveLoad()->getIndex()), moviesCd[getSaveLoad()->getIndex()]);
+ strcat((char *)&text, (char *)&text2);
+ getText()->drawCentered(10, 134, 620, text);
+
+ getText()->drawCentered(10, 168, 620, getText()->get(MAKE_RESOURCE(kResourcePackText, 1358)));
+
+ ++_dword_456288;
+ if (_dword_456288 == 90) {
+ _dword_456288 = 0;
+ _dword_455C78 = false;
+
+ getCursor()->show();
+ }
}
void Menu::updateQuitGame() {
@@ -1419,7 +1540,7 @@ void Menu::keySaveGame(const AsylumEvent &evt) {
if (evt.kbd.ascii > 255 || !isalnum(evt.kbd.ascii))
break;
- if (getSaveLoad()->getName()->size() < 44) {
+ if (getSaveLoad()->getName()->size() < 44) {
int32 width = getText()->getWidth(getSaveLoad()->getName()->c_str());
bool test = false;
@@ -1449,7 +1570,7 @@ void Menu::keySaveGame(const AsylumEvent &evt) {
if (getSaveLoad()->getName()->size())
getSaveLoad()->getName()->deleteLastChar();
break;
-
+
case Common::KEYCODE_PERIOD:
*getSaveLoad()->getName() = "";
break;
diff --git a/engines/asylum/views/menu.h b/engines/asylum/views/menu.h
index 8cc0419966..160cdedaf6 100644
--- a/engines/asylum/views/menu.h
+++ b/engines/asylum/views/menu.h
@@ -120,7 +120,7 @@ private:
uint32 _iconFrames[12];
// Movies
- byte _movieList[196];
+ int32 _movieList[196];
uint32 _movieCount;
// Savegames
Commit: 3e7be182caeeb1410850fedb7a1b5889d5b366f8
https://github.com/scummvm/scummvm/commit/3e7be182caeeb1410850fedb7a1b5889d5b366f8
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:40+02:00
Commit Message:
ASYLUM: Implement Menu::updateLoadGame() and Menu::updateDeleteGame()
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@686 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/views/menu.cpp
diff --git a/engines/asylum/views/menu.cpp b/engines/asylum/views/menu.cpp
index f33af2c5be..195d7a031a 100644
--- a/engines/asylum/views/menu.cpp
+++ b/engines/asylum/views/menu.cpp
@@ -719,7 +719,127 @@ void Menu::updateNewGame() {
void Menu::updateLoadGame() {
Common::Point cursor = getCursor()->position();
- error("[MainMenu::updateLoadGame] Not implemented!");
+ char text[100];
+
+ if (_dword_455C80) {
+ getText()->loadFont(kFontYellow);
+ getText()->drawCentered(10, 100, 620, MAKE_RESOURCE(kResourcePackText, 1329));
+
+ sprintf((char *)&text, "%s ?", getSaveLoad()->getName()->c_str());
+ getText()->drawCentered(10, 134, 620, (char *)&text);
+
+ if (cursor.x < 247 || cursor.x > (247 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 1330)))
+ || cursor.y < 273 || cursor.y > (273 + 24))
+ getText()->loadFont(kFontYellow);
+ else
+ getText()->loadFont(kFontBlue);
+
+ getText()->setPosition(247, 273);
+ getText()->draw(MAKE_RESOURCE(kResourcePackText, 1330));
+
+ if (cursor.x < 369 || cursor.x > (369 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 1331)))
+ || cursor.y < 273 || cursor.y > (273 + 24))
+ getText()->loadFont(kFontYellow);
+ else
+ getText()->loadFont(kFontBlue);
+
+ getText()->setPosition(369, 273);
+ getText()->draw(MAKE_RESOURCE(kResourcePackText, 1331));
+ return;
+ }
+
+ getText()->loadFont(kFontYellow);
+ getText()->drawCentered(10, 100, 620, MAKE_RESOURCE(kResourcePackText, 1325));
+
+ if (_dword_455C78) {
+ getText()->drawCentered(10, 190, 620, MAKE_RESOURCE(kResourcePackText, 1332));
+ getText()->drawCentered(10, 190 + 29, 620, MAKE_RESOURCE(kResourcePackText, 1333));
+ getText()->drawCentered(10, 190 + 53, 620, getSaveLoad()->getName()->c_str());
+
+ ++_dword_456288;
+
+ if (_dword_456288 == 60) {
+ _dword_456288 = 0;
+ _dword_455C78 = false;
+ getCursor()->show();
+ } else if (_dword_456288 == 1) {
+ getCursor()->hide();
+ }
+ } else {
+ //////////////////////////////////////////////////////////////////////////
+ // First column
+ uint32 index = 0;
+ for (int32 y = 150; y < 324; y += 29) {
+ if (index + _textScroll >= 25)
+ break;
+
+ sprintf((char *)&text, "%d. %s ", index + _textScroll + 1, getSaveLoad()->getName(index + _textScroll).c_str());
+
+ if (cursor.x < 30 || cursor.x > (30 + getText()->getWidth((char *)&text))
+ || cursor.y < y || cursor.y > (y + 24))
+ getText()->loadFont(kFontYellow);
+ else
+ getText()->loadFont(kFontBlue);
+
+ getText()->setPosition(30, y);
+ getText()->draw((char *)&text);
+
+ ++index;
+ }
+
+ //////////////////////////////////////////////////////////////////////////
+ // Second column
+ for (int32 y = 150; y < 324; y += 29) {
+ if (index + _textScroll >= 25)
+ break;
+
+ sprintf((char *)&text, "%d. %s ", index + _textScroll + 1, getSaveLoad()->getName(index + _textScroll).c_str());
+
+ if (cursor.x < 350 || cursor.x > (350 + getText()->getWidth((char *)&text))
+ || cursor.y < y || cursor.y > (y + 24))
+ getText()->loadFont(kFontYellow);
+ else
+ getText()->loadFont(kFontBlue);
+
+ getText()->setPosition(350, y);
+ getText()->draw((char *)&text);
+
+ ++index;
+ }
+ }
+
+ //////////////////////////////////////////////////////////////////////////
+ // Previous page
+ if (cursor.x < 30 || cursor.x > (30 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 1326)))
+ || cursor.y < 340 || cursor.y > (340 + 24))
+ getText()->loadFont(kFontYellow);
+ else
+ getText()->loadFont(kFontBlue);
+
+ getText()->setPosition(30, 340);
+ getText()->draw(MAKE_RESOURCE(kResourcePackText, 1326));
+
+ //////////////////////////////////////////////////////////////////////////
+ // Main menu
+ if (cursor.x < 300 || cursor.x > (300 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 1328)))
+ || cursor.y < 340 || cursor.y > (340 + 24))
+ getText()->loadFont(kFontYellow);
+ else
+ getText()->loadFont(kFontBlue);
+
+ getText()->setPosition(300, 340);
+ getText()->draw(MAKE_RESOURCE(kResourcePackText, 1328));
+
+ //////////////////////////////////////////////////////////////////////////
+ // Next page
+ if (cursor.x < 550 || cursor.x > (550 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 1327)))
+ || cursor.y < 340 || cursor.y > (340 + 24))
+ getText()->loadFont(kFontYellow);
+ else
+ getText()->loadFont(kFontBlue);
+
+ getText()->setPosition(550, 347);
+ getText()->draw(MAKE_RESOURCE(kResourcePackText, 1327));
}
void Menu::updateSaveGame() {
@@ -731,7 +851,111 @@ void Menu::updateSaveGame() {
void Menu::updateDeleteGame() {
Common::Point cursor = getCursor()->position();
- error("[MainMenu::updateDeleteGame] Not implemented!");
+ char text[100];
+
+ if (_dword_455C80) {
+ getText()->loadFont(kFontYellow);
+ getText()->drawCentered(10, 100, 620, MAKE_RESOURCE(kResourcePackText, 1349));
+
+ sprintf((char *)&text, "%s ?", getSaveLoad()->getName()->c_str());
+ getText()->drawCentered(10, 134, 620, (char *)&text);
+
+ if (cursor.x < 247 || cursor.x > (247 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 1350)))
+ || cursor.y < 273 || cursor.y > (273 + 24))
+ getText()->loadFont(kFontYellow);
+ else
+ getText()->loadFont(kFontBlue);
+
+ getText()->setPosition(247, 273);
+ getText()->draw(MAKE_RESOURCE(kResourcePackText, 1350));
+
+ if (cursor.x < 369 || cursor.x > (369 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 1351)))
+ || cursor.y < 273 || cursor.y > (273 + 24))
+ getText()->loadFont(kFontYellow);
+ else
+ getText()->loadFont(kFontBlue);
+
+ getText()->setPosition(369, 273);
+ getText()->draw(MAKE_RESOURCE(kResourcePackText, 1351));
+ return;
+ }
+
+ getText()->loadFont(kFontYellow);
+ getText()->drawCentered(10, 100, 620, MAKE_RESOURCE(kResourcePackText, 1345));
+
+ //////////////////////////////////////////////////////////////////////////
+ // First column
+ uint32 index = 0;
+ for (int32 y = 150; y < 324; y += 29) {
+ if (index + _textScroll >= 25)
+ break;
+
+ sprintf((char *)&text, "%d. %s ", index + _textScroll + 1, getSaveLoad()->getName(index + _textScroll).c_str());
+
+ if (cursor.x < 30 || cursor.x > (30 + getText()->getWidth((char *)&text))
+ || cursor.y < y || cursor.y > (y + 24))
+ getText()->loadFont(kFontYellow);
+ else
+ getText()->loadFont(kFontBlue);
+
+ getText()->setPosition(30, y);
+ getText()->draw((char *)&text);
+
+ ++index;
+ }
+
+ //////////////////////////////////////////////////////////////////////////
+ // Second column
+ for (int32 y = 150; y < 324; y += 29) {
+ if (index + _textScroll >= 25)
+ break;
+
+ sprintf((char *)&text, "%d. %s ", index + _textScroll + 1, getSaveLoad()->getName(index + _textScroll).c_str());
+
+ if (cursor.x < 350 || cursor.x > (350 + getText()->getWidth((char *)&text))
+ || cursor.y < y || cursor.y > (y + 24))
+ getText()->loadFont(kFontYellow);
+ else
+ getText()->loadFont(kFontBlue);
+
+ getText()->setPosition(350, y);
+ getText()->draw((char *)&text);
+
+ ++index;
+ }
+
+ //////////////////////////////////////////////////////////////////////////
+ // Previous page
+ if (cursor.x < 30 || cursor.x > (30 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 1346)))
+ || cursor.y < 340 || cursor.y > (340 + 24))
+ getText()->loadFont(kFontYellow);
+ else
+ getText()->loadFont(kFontBlue);
+
+ getText()->setPosition(30, 340);
+ getText()->draw(MAKE_RESOURCE(kResourcePackText, 1346));
+
+ //////////////////////////////////////////////////////////////////////////
+ // Main menu
+ if (cursor.x < 300 || cursor.x > (300 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 1348)))
+ || cursor.y < 340 || cursor.y > (340 + 24))
+ getText()->loadFont(kFontYellow);
+ else
+ getText()->loadFont(kFontBlue);
+
+ getText()->setPosition(300, 340);
+ getText()->draw(MAKE_RESOURCE(kResourcePackText, 1348));
+
+ //////////////////////////////////////////////////////////////////////////
+ // Next page
+ if (cursor.x < 550 || cursor.x > (550 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 1347)))
+ || cursor.y < 340 || cursor.y > (340 + 24))
+ getText()->loadFont(kFontYellow);
+ else
+ getText()->loadFont(kFontBlue);
+
+ getText()->setPosition(550, 347);
+ getText()->draw(MAKE_RESOURCE(kResourcePackText, 1347));
}
void Menu::updateViewMovies() {
@@ -745,6 +969,8 @@ void Menu::updateViewMovies() {
sprintf((char *)&text2, getText()->get(MAKE_RESOURCE(kResourcePackText, 1352)), getSharedData()->cdNumber);
getText()->drawCentered(10, 100, 620, (char *)&text2);
+ //////////////////////////////////////////////////////////////////////////
+ // First column
int32 index = _textScroll;
for (int32 y = 150; y < 324; y += 29) {
if (index >= ARRAYSIZE(_movieList))
@@ -769,6 +995,8 @@ void Menu::updateViewMovies() {
++index;
}
+ //////////////////////////////////////////////////////////////////////////
+ // Second column
for (int32 y = 150; y < 324; y += 29) {
if (index >= ARRAYSIZE(_movieList))
break;
Commit: 28d349179c1979926f603f02f35db26f0841af6c
https://github.com/scummvm/scummvm/commit/28d349179c1979926f603f02f35db26f0841af6c
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:40+02:00
Commit Message:
ASYLUM: Implement Menu::updateSaveGame()
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@687 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/views/menu.cpp
diff --git a/engines/asylum/views/menu.cpp b/engines/asylum/views/menu.cpp
index 195d7a031a..4d822ec852 100644
--- a/engines/asylum/views/menu.cpp
+++ b/engines/asylum/views/menu.cpp
@@ -845,7 +845,161 @@ void Menu::updateLoadGame() {
void Menu::updateSaveGame() {
Common::Point cursor = getCursor()->position();
- error("[MainMenu::updateSaveGame] Not implemented!");
+ char text[100];
+
+ if (_dword_455C80) {
+ getText()->loadFont(kFontYellow);
+ getText()->drawCentered(10, 100, 620, MAKE_RESOURCE(kResourcePackText, 1339));
+
+ sprintf((char *)&text, "%s ?", getSaveLoad()->getName()->c_str());
+ getText()->drawCentered(10, 134, 620, (char *)&text);
+
+ if (cursor.x < 247 || cursor.x > (247 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 1340)))
+ || cursor.y < 273 || cursor.y > (273 + 24))
+ getText()->loadFont(kFontYellow);
+ else
+ getText()->loadFont(kFontBlue);
+
+ getText()->setPosition(247, 273);
+ getText()->draw(MAKE_RESOURCE(kResourcePackText, 1340));
+
+ if (cursor.x < 369 || cursor.x > (369 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 1341)))
+ || cursor.y < 273 || cursor.y > (273 + 24))
+ getText()->loadFont(kFontYellow);
+ else
+ getText()->loadFont(kFontBlue);
+
+ getText()->setPosition(369, 273);
+ getText()->draw(MAKE_RESOURCE(kResourcePackText, 1341));
+ return;
+ }
+
+ getText()->loadFont(kFontYellow);
+ getText()->drawCentered(10, 100, 620, MAKE_RESOURCE(kResourcePackText, 1335));
+
+ if (_dword_455C78) {
+ getText()->drawCentered(10, 220, 620, MAKE_RESOURCE(kResourcePackText, 1343));
+ getText()->drawCentered(10, 220 + 29, 620, getSaveLoad()->getName()->c_str());
+
+ ++_dword_456288;
+
+ if (_dword_456288 == 30) {
+ _dword_456288 = 0;
+ _dword_455C78 = false;
+ getCursor()->show();
+ }
+ } else {
+ //////////////////////////////////////////////////////////////////////////
+ // First column
+ uint32 index = 0;
+ for (int32 y = 150; y < 324; y += 29) {
+ if (index + _textScroll >= 25)
+ break;
+
+ sprintf((char *)&text, "%d. %s ", index + _textScroll + 1, getSaveLoad()->getName(index + _textScroll).c_str());
+
+ if (!_dword_455DD8) {
+ if (cursor.x < 30 || cursor.x > (30 + getText()->getWidth((char *)&text))
+ || cursor.y < y || cursor.y > (y + 24))
+ getText()->loadFont(kFontYellow);
+ else
+ getText()->loadFont(kFontBlue);
+ } else {
+ if (getSaveLoad()->getIndex() != index + _textScroll)
+ getText()->loadFont(kFontYellow);
+ else
+ getText()->loadFont(kFontBlue);
+ }
+
+ getText()->setPosition(30, y);
+ getText()->draw((char *)&text);
+
+ // Draw underscore
+ if (_dword_455DD8) {
+ if (getSaveLoad()->getIndex() == index + _textScroll) {
+ if (_dword_4562C0 < 6)
+ getText()->drawChar('_');
+
+ _dword_4562C0 = (_dword_4562C0 + 1) % 12;
+ }
+ }
+
+ ++index;
+ }
+
+ //////////////////////////////////////////////////////////////////////////
+ // Second column
+ for (int32 y = 150; y < 324; y += 29) {
+ if (index + _textScroll >= 25)
+ break;
+
+ sprintf((char *)&text, "%d. %s ", index + _textScroll + 1, getSaveLoad()->getName(index + _textScroll).c_str());
+
+ if (!_dword_455DD8) {
+ if (cursor.x < 350 || cursor.x > (350 + getText()->getWidth((char *)&text))
+ || cursor.y < y || cursor.y > (y + 24))
+ getText()->loadFont(kFontYellow);
+ else
+ getText()->loadFont(kFontBlue);
+ } else {
+ if (getSaveLoad()->getIndex() != index + _textScroll)
+ getText()->loadFont(kFontYellow);
+ else
+ getText()->loadFont(kFontBlue);
+ }
+
+ getText()->setPosition(350, y);
+ getText()->draw((char *)&text);
+
+ // Draw underscore
+ if (_dword_455DD8) {
+ if (getSaveLoad()->getIndex() == index + _textScroll) {
+ if (_dword_4562C0 < 6)
+ getText()->drawChar('_');
+
+ _dword_4562C0 = (_dword_4562C0 + 1) % 12;
+ }
+ }
+
+ ++index;
+ }
+ }
+
+ //////////////////////////////////////////////////////////////////////////
+ // Previous page
+ if (getCursor()->isHidden()
+ || cursor.x < 30 || cursor.x > (30 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 1336)))
+ || cursor.y < 340 || cursor.y > (340 + 24))
+ getText()->loadFont(kFontYellow);
+ else
+ getText()->loadFont(kFontBlue);
+
+ getText()->setPosition(30, 340);
+ getText()->draw(MAKE_RESOURCE(kResourcePackText, 1336));
+
+ //////////////////////////////////////////////////////////////////////////
+ // Main menu
+ if (getCursor()->isHidden()
+ || cursor.x < 300 || cursor.x > (300 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 1338)))
+ || cursor.y < 340 || cursor.y > (340 + 24))
+ getText()->loadFont(kFontYellow);
+ else
+ getText()->loadFont(kFontBlue);
+
+ getText()->setPosition(300, 340);
+ getText()->draw(MAKE_RESOURCE(kResourcePackText, 1338));
+
+ //////////////////////////////////////////////////////////////////////////
+ // Next page
+ if (getCursor()->isHidden()
+ || cursor.x < 550 || cursor.x > (550 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 1337)))
+ || cursor.y < 340 || cursor.y > (340 + 24))
+ getText()->loadFont(kFontYellow);
+ else
+ getText()->loadFont(kFontBlue);
+
+ getText()->setPosition(550, 347);
+ getText()->draw(MAKE_RESOURCE(kResourcePackText, 1337));
}
void Menu::updateDeleteGame() {
Commit: 5c1ba7b2c56c8003e3371f5cea8f7f795c28565b
https://github.com/scummvm/scummvm/commit/5c1ba7b2c56c8003e3371f5cea8f7f795c28565b
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:40+02:00
Commit Message:
ASYLUM: Implement basic version of Sound::isValidSoundResource()
The original also checks for fmt and data tags and reads values based on those.
We just check for RIFF & WAVE headers and consider the file valid if they are present.
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@688 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/system/sound.cpp
diff --git a/engines/asylum/system/sound.cpp b/engines/asylum/system/sound.cpp
index c0bd7b6cf2..14b883c833 100644
--- a/engines/asylum/system/sound.cpp
+++ b/engines/asylum/system/sound.cpp
@@ -308,7 +308,15 @@ void Sound::cleanupQueue() {
// Helper functions
//////////////////////////////////////////////////////////////////////////
bool Sound::isValidSoundResource(ResourceId resourceId) {
- warning("[Sound::isValidSoundFile] Not implemented!");
+ ResourceEntry *entry = getResource()->get(resourceId);
+
+ if (memcmp(entry->data, "RIFF", 4) != 0)
+ return false;
+
+ if (memcmp(&entry->data[8], "WAVE", 4) != 0)
+ return false;
+
+ // Original checks for "fmt " and "data" tags and return values to the calling function
return true;
}
Commit: f0ffac202148fb66ed747339cbc940855a16a72b
https://github.com/scummvm/scummvm/commit/f0ffac202148fb66ed747339cbc940855a16a72b
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:40+02:00
Commit Message:
ASYLUM: Implement Sound::getAdjustedVolume()
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@689 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/system/sound.cpp
diff --git a/engines/asylum/system/sound.cpp b/engines/asylum/system/sound.cpp
index 14b883c833..57007a0473 100644
--- a/engines/asylum/system/sound.cpp
+++ b/engines/asylum/system/sound.cpp
@@ -189,9 +189,27 @@ int32 Sound::getAdjustedVolume(int32 volume) {
if (volume < 2)
return volume;
- //warning("[Sound::getAdjustedVolume] not implemented");
+ uint32 counter = (uint32)(log((double)volume) / log(2.0)) / 2;
+ int32 adjustedVolume = pow(2.0, (int32)counter);
- return volume;
+ uint32 offset = adjustedVolume;
+ int32 base = adjustedVolume << counter;
+
+ for (;;) {
+ --counter;
+ if ((int32)counter < 0)
+ break;
+
+ offset /= 2;
+ int32 val = base + ((offset + 2 * volume) << counter);
+
+ if (val <= volume) {
+ adjustedVolume += offset;
+ base = val;
+ }
+ }
+
+ return adjustedVolume;
}
int32 Sound::calculatePanningAtPoint(int32 x, int32) {
Commit: dc44ab0138e640a9e268bca87ea74909e073a672
https://github.com/scummvm/scummvm/commit/dc44ab0138e640a9e268bca87ea74909e073a672
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:40+02:00
Commit Message:
ASYLUM: Implement Menu::clickDeleteGame()
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@690 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/system/savegame.cpp
engines/asylum/system/savegame.h
engines/asylum/views/menu.cpp
diff --git a/engines/asylum/system/savegame.cpp b/engines/asylum/system/savegame.cpp
index 9a9c206462..beeaf3def8 100644
--- a/engines/asylum/system/savegame.cpp
+++ b/engines/asylum/system/savegame.cpp
@@ -463,5 +463,11 @@ Common::String Savegame::getName(uint32 index) {
return _names[index];
}
+bool Savegame::hasSavegame(uint32 index) {
+ if (index > ARRAYSIZE(_savegames) - 1)
+ error("[Savegame::hasSavegame] Invalid index (was: %d, max: %d)", index, ARRAYSIZE(_savegames) - 1);
+
+ return _savegames[index];
+}
} // End of namespace Asylum
diff --git a/engines/asylum/system/savegame.h b/engines/asylum/system/savegame.h
index 95044bd77a..1ba5aee521 100644
--- a/engines/asylum/system/savegame.h
+++ b/engines/asylum/system/savegame.h
@@ -105,6 +105,8 @@ public:
void setIndex(uint32 index) { _index = index; }
uint32 getIndex() { return _index; }
+ bool hasSavegame(uint32 index);
+
private:
AsylumEngine* _vm;
diff --git a/engines/asylum/views/menu.cpp b/engines/asylum/views/menu.cpp
index 4d822ec852..1c6be2bd6e 100644
--- a/engines/asylum/views/menu.cpp
+++ b/engines/asylum/views/menu.cpp
@@ -1604,7 +1604,86 @@ void Menu::clickSaveGame() {
void Menu::clickDeleteGame() {
Common::Point cursor = getCursor()->position();
- error("[MainMenu::clickDeleteGame] Not implemented!");
+ if (_dword_455C80) {
+ if (cursor.x < 247 || cursor.x > (247 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 1350)))
+ || cursor.y < 273 || cursor.y > (247 + 24)) {
+ if (cursor.x >= 369 && cursor.x <= (369 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 1351)))
+ && cursor.y >= 273 && cursor.y <= (273 + 24))
+ _dword_455C80 = 0;
+ } else {
+ getSaveLoad()->remove();
+ }
+
+ return;
+ }
+
+ if (cursor.x >= 30 && cursor.x <= (30 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 1346)))
+ && cursor.y >= 340 && cursor.y <= (340 + 24)) {
+ if (_textScroll) {
+ _textScroll -= 12;
+ if (_textScroll < 0)
+ _textScroll = 0;
+ }
+
+ return;
+ }
+
+ if (cursor.x >= 300 && cursor.x <= (300 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 1348)))
+ && cursor.y >= 340 && cursor.y <= (340 + 24)) {
+ leave();
+ return;
+ }
+
+ if (cursor.x >= 550 && cursor.x <= (550 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 1347)))
+ && cursor.y >= 340 && cursor.y <= (340 + 24)) {
+ if (_textScroll) {
+ _textScroll += 12;
+ if (_textScroll >= 25)
+ _textScroll = 24;
+ }
+
+ return;
+ }
+
+ char text[200];
+
+ //////////////////////////////////////////////////////////////////////////
+ // First column
+ uint32 index = 0;
+ for (int32 y = 150; y < 324; y += 29) {
+ if (index + _textScroll >= 25)
+ break;
+
+ if (cursor.x >= 350) {
+ sprintf((char *)&text, "%d. %s ", index + _textScroll + 7, getSaveLoad()->getName(index + _textScroll + 6).c_str());
+
+ if (cursor.x <= (30 + getText()->getWidth((char *)&text))
+ && cursor.y >= y
+ && cursor.y <= (y + 24)) {
+ if (index + _textScroll < 25) {
+ if (getSaveLoad()->hasSavegame(index + _textScroll)) {
+ _dword_455C80 = true;
+ getSaveLoad()->setIndex(index + _textScroll);
+ }
+ }
+ }
+ } else if (cursor.x >= 30) {
+ sprintf((char *)&text, "%d. %s ", index + _textScroll + 1, getSaveLoad()->getName(index + _textScroll).c_str());
+
+ if (cursor.x <= (350 + getText()->getWidth((char *)&text))
+ && cursor.y >= y
+ && cursor.y <= (y + 24)) {
+ if (index + _textScroll + 6 < 25) {
+ if (getSaveLoad()->hasSavegame(index + _textScroll + 6)) {
+ _dword_455C80 = true;
+ getSaveLoad()->setIndex(index + _textScroll + 6);
+ }
+ }
+ }
+ }
+
+ ++index;
+ }
}
void Menu::clickViewMovies() {
Commit: 5b5fa979154718e0dcbbab15169d7843eb129eb4
https://github.com/scummvm/scummvm/commit/5b5fa979154718e0dcbbab15169d7843eb129eb4
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:40+02:00
Commit Message:
ASYLUM: Implement Menu::clickViewMovies()
- Fix movies looping endlessly (was missing a reset of the flag)
- Add a movie index variable instead of using the same index for savegames and movies
- Fix a crach in updateViewMovies (wrong resource value used)
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@691 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/views/menu.cpp
engines/asylum/views/menu.h
diff --git a/engines/asylum/views/menu.cpp b/engines/asylum/views/menu.cpp
index 1c6be2bd6e..98d8802a4a 100644
--- a/engines/asylum/views/menu.cpp
+++ b/engines/asylum/views/menu.cpp
@@ -66,11 +66,12 @@ Menu::Menu(AsylumEngine *vm): _vm(vm) {
_dword_4562C0 = 0;
_textScroll = 0;
_creditsFrameIndex = 0;
- _needEyeCursorInit = false;
+ _showMovie = false;
memset(&_iconFrames, 0, sizeof(_iconFrames));
// Movies
_movieCount = 0;
+ _movieIndex = 0;
memset(&_movieList, 0 , sizeof(_movieList));
// Savegames
@@ -341,7 +342,8 @@ bool Menu::handleEvent(const AsylumEvent &evt) {
bool Menu::init() {
// TODO: save dialog key codes into sntrm_k.txt (need to figure out why they use such thing) (address 00411CD0)
- if (_needEyeCursorInit) {
+ if (_showMovie) {
+ _showMovie = false;
getCursor()->set(MAKE_RESOURCE(kResourcePackShared, 3));
} else {
// Init the game if not already done
@@ -353,7 +355,7 @@ bool Menu::init() {
// - initialize game structures (this is done in classes constructors)
getSaveLoad()->loadMoviesViewed();
- _needEyeCursorInit = true;
+ _showMovie = true;
// Play start video
getVideo()->play(0, this);
@@ -665,7 +667,7 @@ bool Menu::click(const AsylumEvent &evt) {
break;
case kMenuViewMovies:
- _needEyeCursorInit = false;
+ _showMovie = false;
_dword_455C78 = false;
_dword_456288 = 0;
_textScroll = 0;
@@ -1212,10 +1214,10 @@ void Menu::updateViewMovies() {
//////////////////////////////////////////////////////////////////////////
// Play video if needed
- if (_needEyeCursorInit) {
+ if (_showMovie) {
getSound()->playMusic(0, 0);
- getVideo()->play(getSaveLoad()->getIndex(), this);
+ getVideo()->play(_movieIndex, this);
getSound()->playMusic(_musicResourceId);
}
@@ -1227,8 +1229,8 @@ void Menu::updateViewMovies() {
sprintf((char *)&text2, getText()->get(MAKE_RESOURCE(kResourcePackText, 1357)), getSharedData()->cdNumber);
getText()->drawCentered(10, 100, 620, text2);
- strcpy((char *)&text, getText()->get(MAKE_RESOURCE(kResourcePackText, 1359)));
- sprintf((char *)&text2, getText()->get((ResourceId)getSaveLoad()->getIndex()), moviesCd[getSaveLoad()->getIndex()]);
+ strcpy((char *)&text, getText()->get(MAKE_RESOURCE(kResourcePackText, 1359 + _movieIndex)));
+ sprintf((char *)&text2, getText()->get(MAKE_RESOURCE(kResourcePackText, 1356)), moviesCd[_movieIndex]);
strcat((char *)&text, (char *)&text2);
getText()->drawCentered(10, 134, 620, text);
@@ -1617,6 +1619,8 @@ void Menu::clickDeleteGame() {
return;
}
+ //////////////////////////////////////////////////////////////////////////
+ // Previous page
if (cursor.x >= 30 && cursor.x <= (30 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 1346)))
&& cursor.y >= 340 && cursor.y <= (340 + 24)) {
if (_textScroll) {
@@ -1628,12 +1632,16 @@ void Menu::clickDeleteGame() {
return;
}
+ //////////////////////////////////////////////////////////////////////////
+ // Main menu
if (cursor.x >= 300 && cursor.x <= (300 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 1348)))
&& cursor.y >= 340 && cursor.y <= (340 + 24)) {
leave();
return;
}
+ //////////////////////////////////////////////////////////////////////////
+ // Next page
if (cursor.x >= 550 && cursor.x <= (550 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 1347)))
&& cursor.y >= 340 && cursor.y <= (340 + 24)) {
if (_textScroll) {
@@ -1648,12 +1656,9 @@ void Menu::clickDeleteGame() {
char text[200];
//////////////////////////////////////////////////////////////////////////
- // First column
+ // Columns
uint32 index = 0;
for (int32 y = 150; y < 324; y += 29) {
- if (index + _textScroll >= 25)
- break;
-
if (cursor.x >= 350) {
sprintf((char *)&text, "%d. %s ", index + _textScroll + 7, getSaveLoad()->getName(index + _textScroll + 6).c_str());
@@ -1689,7 +1694,100 @@ void Menu::clickDeleteGame() {
void Menu::clickViewMovies() {
Common::Point cursor = getCursor()->position();
- error("[MainMenu::clickViewMovies] Not implemented!");
+ if (_dword_455C78)
+ return;
+
+ //////////////////////////////////////////////////////////////////////////
+ // Previous page
+ if (cursor.x >= 30 && cursor.x <= (30 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 1353)))
+ && cursor.y >= 340 && cursor.y <= (340 + 24)) {
+ if (_textScroll) {
+ _textScroll -= 12;
+ if (_textScroll < 0)
+ _textScroll = 0;
+ }
+
+ return;
+ }
+
+ //////////////////////////////////////////////////////////////////////////
+ // Main Menu
+ if (cursor.x >= 300 && cursor.x <= (300 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 1355)))
+ && cursor.y >= 340 && cursor.y <= (340 + 24)) {
+ leave();
+ return;
+ }
+
+ //////////////////////////////////////////////////////////////////////////
+ // Next page
+ if (cursor.x >= 550 && cursor.x <= (550 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 1354)))
+ && cursor.y >= 340 && cursor.y <= (340 + 24)) {
+ if (_textScroll + 12 < (int32)_movieCount) {
+ _textScroll += 12;
+ if (_textScroll >= (int32)_movieCount)
+ _textScroll = _movieCount - 1;
+ }
+
+ return;
+ }
+
+ char text[100];
+ char text2[100];
+
+ //////////////////////////////////////////////////////////////////////////
+ // Columns
+ uint32 index = 0;
+ for (int32 y = 150; y < 324; y += 29) {
+ if (cursor.x >= 350) {
+ if (_movieList[index + _textScroll + 6] == -1)
+ break;
+
+ sprintf((char *)&text, "%d. %s ", index + 1, getText()->get(MAKE_RESOURCE(kResourcePackText, 1359 + _movieList[index])));
+ sprintf((char *)&text2, getText()->get(MAKE_RESOURCE(kResourcePackText, 1356)), moviesCd[_movieList[index]]);
+ strcat((char *)&text, (char *)&text2);
+
+ if (cursor.x <= (350 + getText()->getWidth((char *)&text))
+ && cursor.y >= y
+ && cursor.y <= (y + 24)) {
+ if (index + _textScroll + 6 <= _movieCount) {
+ // The original checks for the proper cd, but we can skip that since we have all data on disk
+ _movieIndex = _movieList[index + _textScroll + 6];
+
+ //if (moviesCd[_movieIndex] != getSharedData()->cdNumber) {
+ // _dword_455C78 = true;
+ // getCursor()->hide();
+ //} else {
+ _showMovie = true;
+ //}
+ }
+ }
+ } else if (cursor.x >= 30) {
+ if (_movieList[index + _textScroll] == -1)
+ break;
+
+ sprintf((char *)&text, "%d. %s ", index + 1, getText()->get(MAKE_RESOURCE(kResourcePackText, 1359 + _movieList[index])));
+ sprintf((char *)&text2, getText()->get(MAKE_RESOURCE(kResourcePackText, 1356)), moviesCd[_movieList[index]]);
+ strcat((char *)&text, (char *)&text2);
+
+ if (cursor.x <= (30 + getText()->getWidth((char *)&text))
+ && cursor.y >= y
+ && cursor.y <= (y + 24)) {
+ if (index + _textScroll < _movieCount) {
+ // The original checks for the proper cd, but we can skip that since we have all data on disk
+ _movieIndex = _movieList[index + _textScroll];
+
+ //if (moviesCd[_movieIndex] != getSharedData()->cdNumber) {
+ // _dword_455C78 = true;
+ // getCursor()->hide();
+ //} else {
+ _showMovie = true;
+ //}
+ }
+ }
+ }
+
+ ++index;
+ }
}
void Menu::clickQuitGame() {
diff --git a/engines/asylum/views/menu.h b/engines/asylum/views/menu.h
index 160cdedaf6..b6cfcd3617 100644
--- a/engines/asylum/views/menu.h
+++ b/engines/asylum/views/menu.h
@@ -75,7 +75,7 @@ private:
kMenuLoadGame = 1,
kMenuSaveGame = 2,
kMenuDeleteGame = 3,
- kMenuViewMovies = 4,
+ kMenuViewMovies = 4,
kMenuQuitGame = 5,
kMenuTextOptions = 6,
kMenuAudioOptions = 7,
@@ -116,12 +116,13 @@ private:
int32 _dword_4562C0;
int32 _textScroll;
int32 _creditsFrameIndex;
- bool _needEyeCursorInit;
+ bool _showMovie;
uint32 _iconFrames[12];
// Movies
int32 _movieList[196];
uint32 _movieCount;
+ uint32 _movieIndex;
// Savegames
Common::String _previousName;
Commit: 2743c1f76326884296b2fe433579e997ac0374c8
https://github.com/scummvm/scummvm/commit/2743c1f76326884296b2fe433579e997ac0374c8
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:41+02:00
Commit Message:
ASYLUM: Fix problem in Savegame::getMoviesViewed()
This was preventing all played movies from being displayed properly
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@692 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/system/savegame.cpp
diff --git a/engines/asylum/system/savegame.cpp b/engines/asylum/system/savegame.cpp
index beeaf3def8..a40439205c 100644
--- a/engines/asylum/system/savegame.cpp
+++ b/engines/asylum/system/savegame.cpp
@@ -424,7 +424,7 @@ uint32 Savegame::getMoviesViewed(int32 *movieList) {
for (uint32 i = 0; i < ARRAYSIZE(_moviesViewed); i++) {
if (_moviesViewed[i]) {
- movieList[i] = i;
+ movieList[count] = i;
++count;
}
}
Commit: dc5023408e62538fd30c31ec8f309ae68cc2a177
https://github.com/scummvm/scummvm/commit/dc5023408e62538fd30c31ec8f309ae68cc2a177
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:41+02:00
Commit Message:
ASYLUM: Implement Menu::clickLoadGame()
Also fix Menu::clickDeleteGame() not allowing switching between pages
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@693 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/system/savegame.h
engines/asylum/views/menu.cpp
diff --git a/engines/asylum/system/savegame.h b/engines/asylum/system/savegame.h
index 1ba5aee521..43750d8827 100644
--- a/engines/asylum/system/savegame.h
+++ b/engines/asylum/system/savegame.h
@@ -106,6 +106,7 @@ public:
uint32 getIndex() { return _index; }
bool hasSavegame(uint32 index);
+ ResourcePackId getScenePack() { return (ResourcePackId)(_savegameToScene[_index] + 4); }
private:
AsylumEngine* _vm;
diff --git a/engines/asylum/views/menu.cpp b/engines/asylum/views/menu.cpp
index 98d8802a4a..3e3ad166a0 100644
--- a/engines/asylum/views/menu.cpp
+++ b/engines/asylum/views/menu.cpp
@@ -1594,7 +1594,88 @@ void Menu::clickNewGame() {
void Menu::clickLoadGame() {
Common::Point cursor = getCursor()->position();
- error("[MainMenu::clickLoadGame] Not implemented!");
+ if (_dword_455C80) {
+ if (cursor.x < 247 || cursor.x > (247 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 1330)))
+ || cursor.y < 273 || cursor.y > (273 + 24)) {
+ if (cursor.x >= 369 && cursor.x <= (369 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 1331)))
+ && cursor.y >= 273 && cursor.y <= (273 + 24))
+ _dword_455C80 = false;
+ } else {
+ _vm->startGame(getSaveLoad()->getScenePack(), AsylumEngine::kStartGameLoad);
+ }
+ return;
+ }
+
+ //////////////////////////////////////////////////////////////////////////
+ // Previous page
+ if (cursor.x >= 30 && cursor.x <= (30 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 1326)))
+ && cursor.y >= 340 && cursor.y <= (340 + 24)) {
+ if (_textScroll) {
+ _textScroll -= 12;
+ if (_textScroll < 0)
+ _textScroll = 0;
+ }
+
+ return;
+ }
+
+ //////////////////////////////////////////////////////////////////////////
+ // Main Menu
+ if (cursor.x >= 300 && cursor.x <= (300 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 1328)))
+ && cursor.y >= 340 && cursor.y <= (340 + 24)) {
+ leave();
+ return;
+ }
+
+ //////////////////////////////////////////////////////////////////////////
+ // Next page
+ if (cursor.x >= 550 && cursor.x <= (550 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 1327)))
+ && cursor.y >= 340 && cursor.y <= (340 + 24)) {
+ if (_textScroll + 12 < 25) {
+ _textScroll += 12;
+ if (_textScroll >= 25)
+ _textScroll = 24;
+ }
+
+ return;
+ }
+
+ char text[100];
+
+ //////////////////////////////////////////////////////////////////////////
+ // Columns
+ uint32 index = 0;
+ for (int32 y = 150; y < 324; y += 29) {
+ if (cursor.x >= 350) {
+ sprintf((char *)&text, "%d. %s ", index + _textScroll + 7, getSaveLoad()->getName(index + _textScroll + 6).c_str());
+
+ if (cursor.x <= (350 + getText()->getWidth((char *)&text))
+ && cursor.y >= y
+ && cursor.y <= (y + 24)) {
+ if (index + _textScroll + 6 < 25) {
+ if (getSaveLoad()->hasSavegame(index + _textScroll + 6)) {
+ _dword_455C80 = true;
+ getSaveLoad()->setIndex(index + _textScroll + 6);
+ }
+ }
+ }
+ } else if (cursor.x >= 30) {
+ sprintf((char *)&text, "%d. %s ", index + _textScroll + 1, getSaveLoad()->getName(index + _textScroll).c_str());
+
+ if (cursor.x <= (30 + getText()->getWidth((char *)&text))
+ && cursor.y >= y
+ && cursor.y <= (y + 24)) {
+ if (index + _textScroll < 25) {
+ if (getSaveLoad()->hasSavegame(index + _textScroll)) {
+ _dword_455C80 = true;
+ getSaveLoad()->setIndex(index + _textScroll);
+ }
+ }
+ }
+ }
+
+ ++index;
+ }
}
void Menu::clickSaveGame() {
@@ -1644,7 +1725,7 @@ void Menu::clickDeleteGame() {
// Next page
if (cursor.x >= 550 && cursor.x <= (550 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 1347)))
&& cursor.y >= 340 && cursor.y <= (340 + 24)) {
- if (_textScroll) {
+ if (_textScroll + 12 < 25) {
_textScroll += 12;
if (_textScroll >= 25)
_textScroll = 24;
Commit: f39d411631798ed6a9a105c041e7c980742079e1
https://github.com/scummvm/scummvm/commit/f39d411631798ed6a9a105c041e7c980742079e1
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:41+02:00
Commit Message:
ASYLUM: Rename Menu _textScroll to _startIndex
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@694 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/views/menu.cpp
engines/asylum/views/menu.h
diff --git a/engines/asylum/views/menu.cpp b/engines/asylum/views/menu.cpp
index 3e3ad166a0..c74da4e28a 100644
--- a/engines/asylum/views/menu.cpp
+++ b/engines/asylum/views/menu.cpp
@@ -64,7 +64,7 @@ Menu::Menu(AsylumEngine *vm): _vm(vm) {
_testSoundsPlaying = false;
_dword_456288 = 0;
_dword_4562C0 = 0;
- _textScroll = 0;
+ _startIndex = 0;
_creditsFrameIndex = 0;
_showMovie = false;
memset(&_iconFrames, 0, sizeof(_iconFrames));
@@ -100,7 +100,7 @@ void Menu::show() {
_musicResourceId = kResourceNone;
_gameStarted = false;
- _textScroll = 480;
+ _startIndex = 480;
_creditsFrameIndex = 0;
setup();
@@ -656,13 +656,13 @@ bool Menu::click(const AsylumEvent &evt) {
_dword_455C80 = false;
_dword_455C78 = false;
_dword_456288 = 0;
- _textScroll = 0;
+ _startIndex = 0;
getSaveLoad()->loadList();
break;
case kMenuDeleteGame:
_dword_455C80 = false;
- _textScroll = 0;
+ _startIndex = 0;
getSaveLoad()->loadList();
break;
@@ -670,7 +670,7 @@ bool Menu::click(const AsylumEvent &evt) {
_showMovie = false;
_dword_455C78 = false;
_dword_456288 = 0;
- _textScroll = 0;
+ _startIndex = 0;
_movieCount = getSaveLoad()->getMoviesViewed((int32 *)&_movieList);
break;
@@ -686,7 +686,7 @@ bool Menu::click(const AsylumEvent &evt) {
break;
case kMenuShowCredits:
- _textScroll = 480;
+ _startIndex = 480;
_creditsFrameIndex = 0;
setup();
break;
@@ -772,10 +772,10 @@ void Menu::updateLoadGame() {
// First column
uint32 index = 0;
for (int32 y = 150; y < 324; y += 29) {
- if (index + _textScroll >= 25)
+ if (index + _startIndex >= 25)
break;
- sprintf((char *)&text, "%d. %s ", index + _textScroll + 1, getSaveLoad()->getName(index + _textScroll).c_str());
+ sprintf((char *)&text, "%d. %s ", index + _startIndex + 1, getSaveLoad()->getName(index + _startIndex).c_str());
if (cursor.x < 30 || cursor.x > (30 + getText()->getWidth((char *)&text))
|| cursor.y < y || cursor.y > (y + 24))
@@ -792,10 +792,10 @@ void Menu::updateLoadGame() {
//////////////////////////////////////////////////////////////////////////
// Second column
for (int32 y = 150; y < 324; y += 29) {
- if (index + _textScroll >= 25)
+ if (index + _startIndex >= 25)
break;
- sprintf((char *)&text, "%d. %s ", index + _textScroll + 1, getSaveLoad()->getName(index + _textScroll).c_str());
+ sprintf((char *)&text, "%d. %s ", index + _startIndex + 1, getSaveLoad()->getName(index + _startIndex).c_str());
if (cursor.x < 350 || cursor.x > (350 + getText()->getWidth((char *)&text))
|| cursor.y < y || cursor.y > (y + 24))
@@ -895,10 +895,10 @@ void Menu::updateSaveGame() {
// First column
uint32 index = 0;
for (int32 y = 150; y < 324; y += 29) {
- if (index + _textScroll >= 25)
+ if (index + _startIndex >= 25)
break;
- sprintf((char *)&text, "%d. %s ", index + _textScroll + 1, getSaveLoad()->getName(index + _textScroll).c_str());
+ sprintf((char *)&text, "%d. %s ", index + _startIndex + 1, getSaveLoad()->getName(index + _startIndex).c_str());
if (!_dword_455DD8) {
if (cursor.x < 30 || cursor.x > (30 + getText()->getWidth((char *)&text))
@@ -907,7 +907,7 @@ void Menu::updateSaveGame() {
else
getText()->loadFont(kFontBlue);
} else {
- if (getSaveLoad()->getIndex() != index + _textScroll)
+ if (getSaveLoad()->getIndex() != index + _startIndex)
getText()->loadFont(kFontYellow);
else
getText()->loadFont(kFontBlue);
@@ -918,7 +918,7 @@ void Menu::updateSaveGame() {
// Draw underscore
if (_dword_455DD8) {
- if (getSaveLoad()->getIndex() == index + _textScroll) {
+ if (getSaveLoad()->getIndex() == index + _startIndex) {
if (_dword_4562C0 < 6)
getText()->drawChar('_');
@@ -932,10 +932,10 @@ void Menu::updateSaveGame() {
//////////////////////////////////////////////////////////////////////////
// Second column
for (int32 y = 150; y < 324; y += 29) {
- if (index + _textScroll >= 25)
+ if (index + _startIndex >= 25)
break;
- sprintf((char *)&text, "%d. %s ", index + _textScroll + 1, getSaveLoad()->getName(index + _textScroll).c_str());
+ sprintf((char *)&text, "%d. %s ", index + _startIndex + 1, getSaveLoad()->getName(index + _startIndex).c_str());
if (!_dword_455DD8) {
if (cursor.x < 350 || cursor.x > (350 + getText()->getWidth((char *)&text))
@@ -944,7 +944,7 @@ void Menu::updateSaveGame() {
else
getText()->loadFont(kFontBlue);
} else {
- if (getSaveLoad()->getIndex() != index + _textScroll)
+ if (getSaveLoad()->getIndex() != index + _startIndex)
getText()->loadFont(kFontYellow);
else
getText()->loadFont(kFontBlue);
@@ -955,7 +955,7 @@ void Menu::updateSaveGame() {
// Draw underscore
if (_dword_455DD8) {
- if (getSaveLoad()->getIndex() == index + _textScroll) {
+ if (getSaveLoad()->getIndex() == index + _startIndex) {
if (_dword_4562C0 < 6)
getText()->drawChar('_');
@@ -1043,10 +1043,10 @@ void Menu::updateDeleteGame() {
// First column
uint32 index = 0;
for (int32 y = 150; y < 324; y += 29) {
- if (index + _textScroll >= 25)
+ if (index + _startIndex >= 25)
break;
- sprintf((char *)&text, "%d. %s ", index + _textScroll + 1, getSaveLoad()->getName(index + _textScroll).c_str());
+ sprintf((char *)&text, "%d. %s ", index + _startIndex + 1, getSaveLoad()->getName(index + _startIndex).c_str());
if (cursor.x < 30 || cursor.x > (30 + getText()->getWidth((char *)&text))
|| cursor.y < y || cursor.y > (y + 24))
@@ -1063,10 +1063,10 @@ void Menu::updateDeleteGame() {
//////////////////////////////////////////////////////////////////////////
// Second column
for (int32 y = 150; y < 324; y += 29) {
- if (index + _textScroll >= 25)
+ if (index + _startIndex >= 25)
break;
- sprintf((char *)&text, "%d. %s ", index + _textScroll + 1, getSaveLoad()->getName(index + _textScroll).c_str());
+ sprintf((char *)&text, "%d. %s ", index + _startIndex + 1, getSaveLoad()->getName(index + _startIndex).c_str());
if (cursor.x < 350 || cursor.x > (350 + getText()->getWidth((char *)&text))
|| cursor.y < y || cursor.y > (y + 24))
@@ -1127,7 +1127,7 @@ void Menu::updateViewMovies() {
//////////////////////////////////////////////////////////////////////////
// First column
- int32 index = _textScroll;
+ int32 index = _startIndex;
for (int32 y = 150; y < 324; y += 29) {
if (index >= ARRAYSIZE(_movieList))
break;
@@ -1536,21 +1536,21 @@ void Menu::updateShowCredits() {
int32 step = 0;
uint32 index = 0;
do {
- if ((_textScroll + step - 24) >= 0) {
- if ((_textScroll + step) > 480)
+ if ((_startIndex + step - 24) >= 0) {
+ if ((_startIndex + step) > 480)
break;
- int32 minBound = _textScroll + step + 24;
+ int32 minBound = _startIndex + step + 24;
if (minBound >= 0)
if (minBound < 32)
getText()->setTransTableNum(3 - minBound / 8);
- int32 maxBound = _textScroll + step;
- if ((_textScroll + step) < 480)
+ int32 maxBound = _startIndex + step;
+ if ((_startIndex + step) < 480)
if (maxBound > 448)
getText()->setTransTableNum(3 - (479 - maxBound) / 8);
- getText()->setPosition(320, step + _textScroll);
+ getText()->setPosition(320, step + _startIndex);
getText()->draw(MAKE_RESOURCE(kResourcePackText, 1447 + index));
}
@@ -1566,8 +1566,8 @@ void Menu::updateShowCredits() {
}
}
- _textScroll -= 2;
- if (_textScroll < -(8688 + 24))
+ _startIndex -= 2;
+ if (_startIndex < -(8688 + 24))
closeCredits();
}
@@ -1610,10 +1610,10 @@ void Menu::clickLoadGame() {
// Previous page
if (cursor.x >= 30 && cursor.x <= (30 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 1326)))
&& cursor.y >= 340 && cursor.y <= (340 + 24)) {
- if (_textScroll) {
- _textScroll -= 12;
- if (_textScroll < 0)
- _textScroll = 0;
+ if (_startIndex) {
+ _startIndex -= 12;
+ if (_startIndex < 0)
+ _startIndex = 0;
}
return;
@@ -1631,10 +1631,10 @@ void Menu::clickLoadGame() {
// Next page
if (cursor.x >= 550 && cursor.x <= (550 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 1327)))
&& cursor.y >= 340 && cursor.y <= (340 + 24)) {
- if (_textScroll + 12 < 25) {
- _textScroll += 12;
- if (_textScroll >= 25)
- _textScroll = 24;
+ if (_startIndex + 12 < 25) {
+ _startIndex += 12;
+ if (_startIndex >= 25)
+ _startIndex = 24;
}
return;
@@ -1647,28 +1647,28 @@ void Menu::clickLoadGame() {
uint32 index = 0;
for (int32 y = 150; y < 324; y += 29) {
if (cursor.x >= 350) {
- sprintf((char *)&text, "%d. %s ", index + _textScroll + 7, getSaveLoad()->getName(index + _textScroll + 6).c_str());
+ sprintf((char *)&text, "%d. %s ", index + _startIndex + 7, getSaveLoad()->getName(index + _startIndex + 6).c_str());
if (cursor.x <= (350 + getText()->getWidth((char *)&text))
&& cursor.y >= y
&& cursor.y <= (y + 24)) {
- if (index + _textScroll + 6 < 25) {
- if (getSaveLoad()->hasSavegame(index + _textScroll + 6)) {
+ if (index + _startIndex + 6 < 25) {
+ if (getSaveLoad()->hasSavegame(index + _startIndex + 6)) {
_dword_455C80 = true;
- getSaveLoad()->setIndex(index + _textScroll + 6);
+ getSaveLoad()->setIndex(index + _startIndex + 6);
}
}
}
} else if (cursor.x >= 30) {
- sprintf((char *)&text, "%d. %s ", index + _textScroll + 1, getSaveLoad()->getName(index + _textScroll).c_str());
+ sprintf((char *)&text, "%d. %s ", index + _startIndex + 1, getSaveLoad()->getName(index + _startIndex).c_str());
if (cursor.x <= (30 + getText()->getWidth((char *)&text))
&& cursor.y >= y
&& cursor.y <= (y + 24)) {
- if (index + _textScroll < 25) {
- if (getSaveLoad()->hasSavegame(index + _textScroll)) {
+ if (index + _startIndex < 25) {
+ if (getSaveLoad()->hasSavegame(index + _startIndex)) {
_dword_455C80 = true;
- getSaveLoad()->setIndex(index + _textScroll);
+ getSaveLoad()->setIndex(index + _startIndex);
}
}
}
@@ -1704,10 +1704,10 @@ void Menu::clickDeleteGame() {
// Previous page
if (cursor.x >= 30 && cursor.x <= (30 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 1346)))
&& cursor.y >= 340 && cursor.y <= (340 + 24)) {
- if (_textScroll) {
- _textScroll -= 12;
- if (_textScroll < 0)
- _textScroll = 0;
+ if (_startIndex) {
+ _startIndex -= 12;
+ if (_startIndex < 0)
+ _startIndex = 0;
}
return;
@@ -1725,10 +1725,10 @@ void Menu::clickDeleteGame() {
// Next page
if (cursor.x >= 550 && cursor.x <= (550 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 1347)))
&& cursor.y >= 340 && cursor.y <= (340 + 24)) {
- if (_textScroll + 12 < 25) {
- _textScroll += 12;
- if (_textScroll >= 25)
- _textScroll = 24;
+ if (_startIndex + 12 < 25) {
+ _startIndex += 12;
+ if (_startIndex >= 25)
+ _startIndex = 24;
}
return;
@@ -1741,28 +1741,28 @@ void Menu::clickDeleteGame() {
uint32 index = 0;
for (int32 y = 150; y < 324; y += 29) {
if (cursor.x >= 350) {
- sprintf((char *)&text, "%d. %s ", index + _textScroll + 7, getSaveLoad()->getName(index + _textScroll + 6).c_str());
+ sprintf((char *)&text, "%d. %s ", index + _startIndex + 7, getSaveLoad()->getName(index + _startIndex + 6).c_str());
if (cursor.x <= (30 + getText()->getWidth((char *)&text))
&& cursor.y >= y
&& cursor.y <= (y + 24)) {
- if (index + _textScroll < 25) {
- if (getSaveLoad()->hasSavegame(index + _textScroll)) {
+ if (index + _startIndex < 25) {
+ if (getSaveLoad()->hasSavegame(index + _startIndex)) {
_dword_455C80 = true;
- getSaveLoad()->setIndex(index + _textScroll);
+ getSaveLoad()->setIndex(index + _startIndex);
}
}
}
} else if (cursor.x >= 30) {
- sprintf((char *)&text, "%d. %s ", index + _textScroll + 1, getSaveLoad()->getName(index + _textScroll).c_str());
+ sprintf((char *)&text, "%d. %s ", index + _startIndex + 1, getSaveLoad()->getName(index + _startIndex).c_str());
if (cursor.x <= (350 + getText()->getWidth((char *)&text))
&& cursor.y >= y
&& cursor.y <= (y + 24)) {
- if (index + _textScroll + 6 < 25) {
- if (getSaveLoad()->hasSavegame(index + _textScroll + 6)) {
+ if (index + _startIndex + 6 < 25) {
+ if (getSaveLoad()->hasSavegame(index + _startIndex + 6)) {
_dword_455C80 = true;
- getSaveLoad()->setIndex(index + _textScroll + 6);
+ getSaveLoad()->setIndex(index + _startIndex + 6);
}
}
}
@@ -1782,10 +1782,10 @@ void Menu::clickViewMovies() {
// Previous page
if (cursor.x >= 30 && cursor.x <= (30 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 1353)))
&& cursor.y >= 340 && cursor.y <= (340 + 24)) {
- if (_textScroll) {
- _textScroll -= 12;
- if (_textScroll < 0)
- _textScroll = 0;
+ if (_startIndex) {
+ _startIndex -= 12;
+ if (_startIndex < 0)
+ _startIndex = 0;
}
return;
@@ -1803,10 +1803,10 @@ void Menu::clickViewMovies() {
// Next page
if (cursor.x >= 550 && cursor.x <= (550 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 1354)))
&& cursor.y >= 340 && cursor.y <= (340 + 24)) {
- if (_textScroll + 12 < (int32)_movieCount) {
- _textScroll += 12;
- if (_textScroll >= (int32)_movieCount)
- _textScroll = _movieCount - 1;
+ if (_startIndex + 12 < (int32)_movieCount) {
+ _startIndex += 12;
+ if (_startIndex >= (int32)_movieCount)
+ _startIndex = _movieCount - 1;
}
return;
@@ -1820,7 +1820,7 @@ void Menu::clickViewMovies() {
uint32 index = 0;
for (int32 y = 150; y < 324; y += 29) {
if (cursor.x >= 350) {
- if (_movieList[index + _textScroll + 6] == -1)
+ if (_movieList[index + _startIndex + 6] == -1)
break;
sprintf((char *)&text, "%d. %s ", index + 1, getText()->get(MAKE_RESOURCE(kResourcePackText, 1359 + _movieList[index])));
@@ -1830,9 +1830,9 @@ void Menu::clickViewMovies() {
if (cursor.x <= (350 + getText()->getWidth((char *)&text))
&& cursor.y >= y
&& cursor.y <= (y + 24)) {
- if (index + _textScroll + 6 <= _movieCount) {
+ if (index + _startIndex + 6 <= _movieCount) {
// The original checks for the proper cd, but we can skip that since we have all data on disk
- _movieIndex = _movieList[index + _textScroll + 6];
+ _movieIndex = _movieList[index + _startIndex + 6];
//if (moviesCd[_movieIndex] != getSharedData()->cdNumber) {
// _dword_455C78 = true;
@@ -1843,7 +1843,7 @@ void Menu::clickViewMovies() {
}
}
} else if (cursor.x >= 30) {
- if (_movieList[index + _textScroll] == -1)
+ if (_movieList[index + _startIndex] == -1)
break;
sprintf((char *)&text, "%d. %s ", index + 1, getText()->get(MAKE_RESOURCE(kResourcePackText, 1359 + _movieList[index])));
@@ -1853,9 +1853,9 @@ void Menu::clickViewMovies() {
if (cursor.x <= (30 + getText()->getWidth((char *)&text))
&& cursor.y >= y
&& cursor.y <= (y + 24)) {
- if (index + _textScroll < _movieCount) {
+ if (index + _startIndex < _movieCount) {
// The original checks for the proper cd, but we can skip that since we have all data on disk
- _movieIndex = _movieList[index + _textScroll];
+ _movieIndex = _movieList[index + _startIndex];
//if (moviesCd[_movieIndex] != getSharedData()->cdNumber) {
// _dword_455C78 = true;
diff --git a/engines/asylum/views/menu.h b/engines/asylum/views/menu.h
index b6cfcd3617..c4e0d39d6e 100644
--- a/engines/asylum/views/menu.h
+++ b/engines/asylum/views/menu.h
@@ -114,7 +114,7 @@ private:
bool _testSoundsPlaying;
int32 _dword_456288;
int32 _dword_4562C0;
- int32 _textScroll;
+ int32 _startIndex;
int32 _creditsFrameIndex;
bool _showMovie;
uint32 _iconFrames[12];
Commit: 2a785f0b52b62782f7be64ed598a47d286c5ac8c
https://github.com/scummvm/scummvm/commit/2a785f0b52b62782f7be64ed598a47d286c5ac8c
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:41+02:00
Commit Message:
ASYLUM: Implement Menu::clickSaveGame()
- Handle delete key as backspace
- Handle keypad period as delete
- Correct invalid width test when typing save name
- Fix problems with Menu::clickDeleteGame()
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@695 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/staticres.h
engines/asylum/views/menu.cpp
engines/asylum/views/menu.h
diff --git a/engines/asylum/staticres.h b/engines/asylum/staticres.h
index 53bac139a0..30a3c34682 100644
--- a/engines/asylum/staticres.h
+++ b/engines/asylum/staticres.h
@@ -50,6 +50,8 @@ const int moviesCd[49] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2, 2, 2, 2, 2, 2, 2, 2, 3, 3,
3, 3, 3, 3, 3, 3, 3, 3, 2};
+const int chapterIndexes[16] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 4, 4, 8, 9, 0, 0};
+
/** Default Actor Indices by Scene */
const int actorType[16] = {0, 0, 0, 0, 1, 0, 2, 0, 3, 0, 1, 1, 3, 0, 0, 0};
diff --git a/engines/asylum/views/menu.cpp b/engines/asylum/views/menu.cpp
index c74da4e28a..e470ebbd77 100644
--- a/engines/asylum/views/menu.cpp
+++ b/engines/asylum/views/menu.cpp
@@ -306,6 +306,10 @@ void Menu::adjustPerformance() {
getSound()->playMusic(MAKE_RESOURCE(kResourcePackMusic, index));
}
+Common::String Menu::getChapterName() {
+ return Common::String::format("%s%2d", getText()->get(MAKE_RESOURCE(kResourcePackText, 1334)), chapterIndexes[getWorld()->chapter]);
+}
+
//////////////////////////////////////////////////////////////////////////
// Event Handler
//////////////////////////////////////////////////////////////////////////
@@ -1681,7 +1685,107 @@ void Menu::clickLoadGame() {
void Menu::clickSaveGame() {
Common::Point cursor = getCursor()->position();
- error("[MainMenu::clickSaveGame] Not implemented!");
+ if (_dword_455C80) {
+ if (cursor.x < 247 || cursor.x > (247 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 1340)))
+ || cursor.y < 273 || cursor.y > (247 + 24)) {
+ if (cursor.x >= 369 && cursor.x <= (369 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 1341)))
+ && cursor.y >= 273 && cursor.y <= (273 + 24))
+ _dword_455C80 = 0;
+ } else {
+ _dword_455C80 = false;
+ _dword_455DD8 = true;
+
+ _previousName = *getSaveLoad()->getName();
+ _prefixWidth = getText()->getWidth(Common::String::format("%d. %c", getSaveLoad()->getIndex() + 1, '_').c_str());
+ getCursor()->hide();
+ }
+
+ return;
+ }
+
+ //////////////////////////////////////////////////////////////////////////
+ // Previous page
+ if (cursor.x >= 30 && cursor.x <= (30 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 1336)))
+ && cursor.y >= 340 && cursor.y <= (340 + 24)) {
+ if (_startIndex) {
+ _startIndex -= 12;
+ if (_startIndex < 0)
+ _startIndex = 0;
+ }
+
+ return;
+ }
+
+ //////////////////////////////////////////////////////////////////////////
+ // Main menu
+ if (cursor.x >= 300 && cursor.x <= (300 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 1338)))
+ && cursor.y >= 340 && cursor.y <= (340 + 24)) {
+ leave();
+ return;
+ }
+
+ //////////////////////////////////////////////////////////////////////////
+ // Next page
+ if (cursor.x >= 550 && cursor.x <= (550 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 1337)))
+ && cursor.y >= 340 && cursor.y <= (340 + 24)) {
+ if (_startIndex + 12 < 25) {
+ _startIndex += 12;
+ if (_startIndex >= 25)
+ _startIndex = 24;
+ }
+ return;
+ }
+
+ char text[200];
+
+ //////////////////////////////////////////////////////////////////////////
+ // Columns
+ uint32 index = 0;
+ for (int32 y = 150; y < 324; y += 29) {
+ if (cursor.x >= 350) {
+ sprintf((char *)&text, "%d. %s ", index + _startIndex + 7, getSaveLoad()->getName(index + _startIndex + 6).c_str());
+
+ if (cursor.x <= (30 + getText()->getWidth((char *)&text))
+ && cursor.y >= y
+ && cursor.y <= (y + 24)
+ && getWorld()->chapter != kChapterNone) {
+ if (index + _startIndex < 25) {
+ getSaveLoad()->setIndex(index + _startIndex + 6);
+ if (getSaveLoad()->hasSavegame(index + _startIndex + 6)) {
+ _dword_455C80 = true;
+ } else {
+ _dword_455DD8 = true;
+ _previousName = *getSaveLoad()->getName();
+ *getSaveLoad()->getName() = getChapterName();
+ _prefixWidth = getText()->getWidth(Common::String::format("%d. %c", getSaveLoad()->getIndex() + 1, '_').c_str());
+ getCursor()->hide();
+ }
+ }
+ }
+ } else if (cursor.x >= 30) {
+ sprintf((char *)&text, "%d. %s ", index + _startIndex + 1, getSaveLoad()->getName(index + _startIndex).c_str());
+
+ if (cursor.x <= (350 + getText()->getWidth((char *)&text))
+ && cursor.y >= y
+ && cursor.y <= (y + 24)
+ && getWorld()->chapter != kChapterNone) {
+ if (index + _startIndex < 25) {
+ getSaveLoad()->setIndex(index + _startIndex);
+ if (getSaveLoad()->hasSavegame(index + _startIndex)) {
+ _dword_455C80 = true;
+ } else {
+ _dword_455DD8 = true;
+ _previousName = *getSaveLoad()->getName();
+ *getSaveLoad()->getName() = getChapterName();
+ _prefixWidth = getText()->getWidth(Common::String::format("%d. %c", getSaveLoad()->getIndex() + 1, '_').c_str());
+ getCursor()->hide();
+ }
+ }
+ }
+ }
+
+ ++index;
+ }
}
void Menu::clickDeleteGame() {
@@ -1747,9 +1851,9 @@ void Menu::clickDeleteGame() {
&& cursor.y >= y
&& cursor.y <= (y + 24)) {
if (index + _startIndex < 25) {
- if (getSaveLoad()->hasSavegame(index + _startIndex)) {
+ if (getSaveLoad()->hasSavegame(index + _startIndex + 6)) {
_dword_455C80 = true;
- getSaveLoad()->setIndex(index + _startIndex);
+ getSaveLoad()->setIndex(index + _startIndex + 6);
}
}
}
@@ -1759,10 +1863,10 @@ void Menu::clickDeleteGame() {
if (cursor.x <= (350 + getText()->getWidth((char *)&text))
&& cursor.y >= y
&& cursor.y <= (y + 24)) {
- if (index + _startIndex + 6 < 25) {
- if (getSaveLoad()->hasSavegame(index + _startIndex + 6)) {
+ if (index + _startIndex < 25) {
+ if (getSaveLoad()->hasSavegame(index + _startIndex)) {
_dword_455C80 = true;
- getSaveLoad()->setIndex(index + _startIndex + 6);
+ getSaveLoad()->setIndex(index + _startIndex);
}
}
}
@@ -2185,9 +2289,9 @@ void Menu::keySaveGame(const AsylumEvent &evt) {
bool test = false;
if ((getSaveLoad()->getIndex() % 12) >= 6)
- test = (width + _prefixWidth + 350 == 630);
+ test = (width + _prefixWidth + 350 != 630);
else
- test = (width + _prefixWidth + 30 == 340);
+ test = (width + _prefixWidth + 30 != 340);
if (test)
*getSaveLoad()->getName() += (char)evt.kbd.ascii;
@@ -2207,11 +2311,12 @@ void Menu::keySaveGame(const AsylumEvent &evt) {
break;
case Common::KEYCODE_BACKSPACE:
+ case Common::KEYCODE_DELETE:
if (getSaveLoad()->getName()->size())
getSaveLoad()->getName()->deleteLastChar();
break;
- case Common::KEYCODE_PERIOD:
+ case Common::KEYCODE_KP_PERIOD:
*getSaveLoad()->getName() = "";
break;
}
diff --git a/engines/asylum/views/menu.h b/engines/asylum/views/menu.h
index c4e0d39d6e..37f302c8e8 100644
--- a/engines/asylum/views/menu.h
+++ b/engines/asylum/views/menu.h
@@ -189,6 +189,13 @@ private:
*/
void adjustPerformance();
+ /**
+ * Gets the chapter name.
+ *
+ * @return The chapter name.
+ */
+ Common::String getChapterName();
+
//////////////////////////////////////////////////////////////////////////
// Message handling
bool init();
Commit: c9985fe1cd11306462cee3302eb7d2a087505a3c
https://github.com/scummvm/scummvm/commit/c9985fe1cd11306462cee3302eb7d2a087505a3c
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:41+02:00
Commit Message:
ASYLUM: Implement Scene::updateMusic()
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@696 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/resources/worldstats.cpp
engines/asylum/resources/worldstats.h
engines/asylum/shared.h
engines/asylum/system/sound.cpp
engines/asylum/system/sound.h
engines/asylum/views/scene.cpp
engines/asylum/views/scene.h
diff --git a/engines/asylum/resources/worldstats.cpp b/engines/asylum/resources/worldstats.cpp
index 6989edfe93..2bcf7d2ac3 100644
--- a/engines/asylum/resources/worldstats.cpp
+++ b/engines/asylum/resources/worldstats.cpp
@@ -72,9 +72,9 @@ WorldStats::WorldStats(AsylumEngine *engine) : _vm(engine) {
numAmbientSounds = 0;
musicStatus = 0;
- musicCurrentResourceIndex = kResourceNone;
+ musicCurrentResourceIndex = 0;
musicFlag = 0;
- musicResourceId = kResourceNone;
+ musicResourceIndex = 0;
musicStatusExt = 0;
numScripts = 0;
numPolygons = 0;
@@ -182,12 +182,12 @@ void WorldStats::load(Common::SeekableReadStream *stream) {
ambientSounds[s].y = stream->readSint32LE();
}
- numAmbientSounds = stream->readSint32LE();
- musicStatus = stream->readSint32LE();
- musicCurrentResourceIndex = stream->readUint32LE();
- musicFlag = stream->readSint32LE();
- musicResourceId = (ResourceId)stream->readUint32LE();
- musicStatusExt = stream->readSint32LE();
+ numAmbientSounds = stream->readSint32LE();
+ musicStatus = stream->readSint32LE();
+ musicCurrentResourceIndex = stream->readSint32LE();
+ musicFlag = stream->readSint32LE();
+ musicResourceIndex = stream->readSint32LE();
+ musicStatusExt = stream->readSint32LE();
//////////////////////////////////////////////////////////////////////////
// Read Objects
diff --git a/engines/asylum/resources/worldstats.h b/engines/asylum/resources/worldstats.h
index f6f4d821ad..4caef39d76 100644
--- a/engines/asylum/resources/worldstats.h
+++ b/engines/asylum/resources/worldstats.h
@@ -118,9 +118,9 @@ public:
AmbientSoundItem ambientSounds[15];
int32 numAmbientSounds;
int32 musicStatus;
- uint32 musicCurrentResourceIndex;
+ int32 musicCurrentResourceIndex;
int32 musicFlag;
- ResourceId musicResourceId;
+ int32 musicResourceIndex;
int32 musicStatusExt;
Common::Array<Object*> objects; // maxsize 400
Common::Array<Actor*> actors; // maxsize 50
diff --git a/engines/asylum/shared.h b/engines/asylum/shared.h
index c1e5704aaa..6879809127 100644
--- a/engines/asylum/shared.h
+++ b/engines/asylum/shared.h
@@ -203,9 +203,7 @@ enum ResourcesId {
kResourceInvalid = 0xFFFFFFFF
};
-enum MusicIndex {
- kMusicStopped = 0xFFFFFD66 // -666
-};
+#define kMusicStopped -666
//////////////////////////////////////////////////////////////////////////
// Actions
diff --git a/engines/asylum/system/sound.cpp b/engines/asylum/system/sound.cpp
index 57007a0473..f0f7a423ef 100644
--- a/engines/asylum/system/sound.cpp
+++ b/engines/asylum/system/sound.cpp
@@ -104,7 +104,7 @@ void Sound::playMusic(ResourceId resourceId, int32 volume) {
playSoundData(Audio::Mixer::kMusicSoundType, &_musicHandle, resource->data, resource->size, true, volume, 0);
}
-void Sound::changeMusic(uint32 index, int32 musicStatusExt) {
+void Sound::changeMusic(int32 index, int32 musicStatusExt) {
if (index != getWorld()->musicCurrentResourceIndex) {
getWorld()->musicCurrentResourceIndex = index;
getWorld()->musicStatusExt = musicStatusExt;
diff --git a/engines/asylum/system/sound.h b/engines/asylum/system/sound.h
index 892271e489..7701ea4a96 100644
--- a/engines/asylum/system/sound.h
+++ b/engines/asylum/system/sound.h
@@ -140,7 +140,7 @@ public:
* @param index Zero-based index of the music
* @param musicStatusExt The music status.
*/
- void changeMusic(uint32 index, int32 musicStatusExt);
+ void changeMusic(int32 index, int32 musicStatusExt);
/**
* Query if a sound with the resource id is playing.
diff --git a/engines/asylum/views/scene.cpp b/engines/asylum/views/scene.cpp
index edc17d91e7..2ce4d975bf 100644
--- a/engines/asylum/views/scene.cpp
+++ b/engines/asylum/views/scene.cpp
@@ -69,6 +69,8 @@ Scene::Scene(AsylumEngine *engine): _vm(engine),
_hitAreaChapter7Counter = 0;
_chapter5FrameIndex = 0;
+ _musicVolume = 0;
+
g_debugPolygons = 0;
g_debugObjects = 0;
g_debugScrolling = 0;
@@ -930,7 +932,91 @@ void Scene::updateAmbientSounds() {
}
void Scene::updateMusic() {
- //warning("[Scene::updateMusic] not implemented!");
+ if (!getWorld()->musicFlag)
+ return;
+
+ if (getWorld()->musicCurrentResourceIndex != kMusicStopped) {
+ switch (getWorld()->musicStatus) {
+ default:
+ break;
+
+ case 1:
+ getWorld()->musicCurrentResourceIndex = getWorld()->musicResourceIndex;
+
+ if (getWorld()->musicResourceIndex == kMusicStopped) {
+ getWorld()->musicStatus = 0;
+ getSound()->playMusic(kResourceNone, 0);
+ } else {
+ getWorld()->musicStatus = getWorld()->musicStatusExt;
+ getSound()->playMusic(MAKE_RESOURCE(kResourcePackMusic, getWorld()->musicResourceIndex));
+ }
+ break;
+
+ case 2:
+ _musicVolume = getSound()->getMusicVolume();
+ getWorld()->musicStatus = 4;
+ break;
+
+ case 4:
+ _musicVolume -= 150;
+ if (_musicVolume >= -2500) {
+ getSound()->setMusicVolume(_musicVolume);
+ break;
+ }
+
+ _musicVolume = -10000;
+ getWorld()->musicCurrentResourceIndex = kMusicStopped;
+
+ if (getWorld()->musicResourceIndex == kMusicStopped) {
+ getWorld()->musicStatus = 0;
+ getSound()->playMusic(kResourceNone, 0);
+ } else {
+ getWorld()->musicStatus = 8;
+ getSound()->playMusic(kResourceNone, 0);
+ getWorld()->musicCurrentResourceIndex = getWorld()->musicResourceIndex;
+ _musicVolume = -2500;
+ getSound()->playMusic(MAKE_RESOURCE(kResourcePackMusic, getWorld()->musicResourceIndex), _musicVolume);
+ }
+ break;
+
+ case 8:
+ _musicVolume += 150;
+ if (_musicVolume < 150) {
+ getSound()->setMusicVolume(_musicVolume);
+ break;
+ }
+
+ getSound()->setMusicVolume(Config.musicVolume);
+ getWorld()->musicStatus = getWorld()->musicStatusExt;
+ getWorld()->musicResourceIndex = (int32)kMusicStopped;
+ getWorld()->musicStatusExt = 0;
+ break;
+ }
+ } if (getWorld()->musicResourceIndex != kMusicStopped) {
+ switch (getWorld()->musicStatusExt) {
+ default:
+ break;
+
+ case 1:
+ getWorld()->musicCurrentResourceIndex = getWorld()->musicResourceIndex;
+ getWorld()->musicStatus = 1;
+ getSound()->playMusic(MAKE_RESOURCE(kResourcePackMusic, getWorld()->musicResourceIndex));
+ getWorld()->musicResourceIndex = kMusicStopped;
+ getWorld()->musicStatusExt = 0;
+ getWorld()->musicFlag = 0;
+ break;
+
+ case 2:
+ _musicVolume = -10000;
+ getSound()->setMusicVolume(_musicVolume);
+ getWorld()->musicCurrentResourceIndex = getWorld()->musicResourceIndex;
+ getWorld()->musicStatus = 8;
+ getSound()->playMusic(MAKE_RESOURCE(kResourcePackMusic, getWorld()->musicResourceIndex), _musicVolume);
+ break;
+ }
+ } else {
+ getWorld()->musicFlag = 0;
+ }
}
void Scene::updateAdjustScreen() {
@@ -946,7 +1032,7 @@ void Scene::updateCoordinates() {
int32 xLeft = _ws->xLeft;
int32 yTop = _ws->yTop;
int32 posX = act->getPoint1()->x - _ws->xLeft;
- int32 posY = act->getPoint1()->y - _ws->yTop;
+ int32 posY = act->getPoint1()->y - _ws->yTop;
Common::Rect boundingRect = _ws->boundingRect;
switch (_ws->motionStatus) {
@@ -981,7 +1067,7 @@ void Scene::updateCoordinates() {
if (yTop > (_ws->height - 480))
yTop = _ws->yTop = _ws->height - 480;
-
+
break;
case 2:
@@ -990,7 +1076,7 @@ void Scene::updateCoordinates() {
int32 coord1 = 0;
int32 coord2 = 0;
-
+
if (abs(getSharedData()->sceneXLeft - _ws->coordinates[0]) <= abs(getSharedData()->sceneYTop - _ws->coordinates[1])) {
coord1 = _ws->coordinates[1];
coord2 = yTop;
@@ -1000,14 +1086,14 @@ void Scene::updateCoordinates() {
yTop = _ws->coordinates[2] + _ws->yTop;
_ws->yTop += _ws->coordinates[2];
-
+
} else {
coord1 = _ws->coordinates[0];
coord2 = xLeft;
-
+
if (_ws->coordinates[0] != _ws->xLeft)
yTop = _ws->yTop = getSharedData()->sceneOffset + getSharedData()->sceneYTop;
-
+
xLeft = _ws->coordinates[2] + _ws->xLeft;
_ws->xLeft += _ws->coordinates[2];
}
diff --git a/engines/asylum/views/scene.h b/engines/asylum/views/scene.h
index 305d2ef5f1..63ab4fb170 100644
--- a/engines/asylum/views/scene.h
+++ b/engines/asylum/views/scene.h
@@ -208,6 +208,9 @@ private:
int32 priority;
};
+ // Music volume
+ int32 _musicVolume;
+
Common::Array<UpdateItem> _updateList;
//////////////////////////////////////////////////////////////////////////
Commit: 474888bde761cc47964ba74178d1a790c55302c0
https://github.com/scummvm/scummvm/commit/474888bde761cc47964ba74178d1a790c55302c0
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:41+02:00
Commit Message:
ASYLUM: Fix savegame name editing width test
Also name variable caretBlink for caret blinking
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@697 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/views/menu.cpp
engines/asylum/views/menu.h
diff --git a/engines/asylum/views/menu.cpp b/engines/asylum/views/menu.cpp
index e470ebbd77..fd7708b4b8 100644
--- a/engines/asylum/views/menu.cpp
+++ b/engines/asylum/views/menu.cpp
@@ -63,7 +63,7 @@ Menu::Menu(AsylumEngine *vm): _vm(vm) {
_dword_455DD8 = false;
_testSoundsPlaying = false;
_dword_456288 = 0;
- _dword_4562C0 = 0;
+ _caretBlink = 0;
_startIndex = 0;
_creditsFrameIndex = 0;
_showMovie = false;
@@ -374,7 +374,7 @@ bool Menu::init() {
getCursor()->show();
}
- _dword_4562C0 = 0;
+ _caretBlink = 0;
_activeScreen = kMenuNone;
_currentIcon = kMenuNone;
_dword_455C74 = 0;
@@ -923,10 +923,10 @@ void Menu::updateSaveGame() {
// Draw underscore
if (_dword_455DD8) {
if (getSaveLoad()->getIndex() == index + _startIndex) {
- if (_dword_4562C0 < 6)
+ if (_caretBlink < 6)
getText()->drawChar('_');
- _dword_4562C0 = (_dword_4562C0 + 1) % 12;
+ _caretBlink = (_caretBlink + 1) % 12;
}
}
@@ -960,10 +960,10 @@ void Menu::updateSaveGame() {
// Draw underscore
if (_dword_455DD8) {
if (getSaveLoad()->getIndex() == index + _startIndex) {
- if (_dword_4562C0 < 6)
+ if (_caretBlink < 6)
getText()->drawChar('_');
- _dword_4562C0 = (_dword_4562C0 + 1) % 12;
+ _caretBlink = (_caretBlink + 1) % 12;
}
}
@@ -1495,10 +1495,10 @@ void Menu::updateKeyboardConfig() {
if (keyIndex == _selectedShortcutIndex) {
getText()->loadFont(kFontBlue);
- if (_dword_4562C0 < 6)
+ if (_caretBlink < 6)
getText()->drawChar('_');
- _dword_4562C0 = (_dword_4562C0 + 1) % 12;
+ _caretBlink = (_caretBlink + 1) % 12;
} else {
switchFont(getCursor()->isHidden() || cursor.x < 350 || cursor.x > (350 + getText()->getWidth(keyCode)) || cursor.y < (29 * keyIndex + 150) || cursor.y > (29 * (keyIndex + 6)));
getText()->drawChar(keyCode);
@@ -2289,9 +2289,9 @@ void Menu::keySaveGame(const AsylumEvent &evt) {
bool test = false;
if ((getSaveLoad()->getIndex() % 12) >= 6)
- test = (width + _prefixWidth + 350 != 630);
+ test = (width + _prefixWidth + 350 < 630);
else
- test = (width + _prefixWidth + 30 != 340);
+ test = (width + _prefixWidth + 30 < 340);
if (test)
*getSaveLoad()->getName() += (char)evt.kbd.ascii;
diff --git a/engines/asylum/views/menu.h b/engines/asylum/views/menu.h
index 37f302c8e8..4e3d1d2677 100644
--- a/engines/asylum/views/menu.h
+++ b/engines/asylum/views/menu.h
@@ -113,7 +113,7 @@ private:
bool _dword_455DD8;
bool _testSoundsPlaying;
int32 _dword_456288;
- int32 _dword_4562C0;
+ int32 _caretBlink;
int32 _startIndex;
int32 _creditsFrameIndex;
bool _showMovie;
Commit: 926ab4b6a05843191e80116e015c308bbd1c6d1c
https://github.com/scummvm/scummvm/commit/926ab4b6a05843191e80116e015c308bbd1c6d1c
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:41+02:00
Commit Message:
ASYLUM: Small update to Scene::processUpdateList()
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@698 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/shared.h
engines/asylum/views/scene.cpp
diff --git a/engines/asylum/shared.h b/engines/asylum/shared.h
index 6879809127..e3a48532c4 100644
--- a/engines/asylum/shared.h
+++ b/engines/asylum/shared.h
@@ -576,6 +576,7 @@ enum ObjectFlag {
kObjectFlag20 = 0x20,
kObjectFlag40 = 0x40,
kObjectFlag80 = 0x80,
+ kObjectFlagBF = 0xBF,
kObjectFlag1000 = 0x1000,
kObjectFlagC000 = 0xC000,
kObjectFlag10000 = 0x10000,
diff --git a/engines/asylum/views/scene.cpp b/engines/asylum/views/scene.cpp
index 2ce4d975bf..4fa57666cc 100644
--- a/engines/asylum/views/scene.cpp
+++ b/engines/asylum/views/scene.cpp
@@ -2412,35 +2412,29 @@ void Scene::processUpdateList() {
if (!object->isOnScreen())
continue;
- // Rect for the object
- Common::Rect objectRect(object->x, object->y, object->x + object->getBoundingRect()->right, object->y + object->getBoundingRect()->bottom);
-
// Check that the rects are contained
- if (!objectRect.contains(actorRect)) {
+ if (!rectIntersect(object->x, object->y, object->x + object->getBoundingRect()->right, object->y + object->getBoundingRect()->bottom,
+ actor->getPoint1()->x, actor->getPoint1()->y, actor->getPoint1()->x + actor->getBoundingRect()->right, bottomRight)) {
if (BYTE1(object->flags) & kObjectFlag20)
if (!(BYTE1(object->flags) & kObjectFlag80))
object->flags = BYTE1(object->flags) | kObjectFlag40;
+
continue;
}
// Check if it intersects with either the object rect or the related polygon
- bool intersects = false;
+ bool notIntersects = false;
if (object->flags & kObjectFlag2) {
- intersects = pointIntersectsRect(point, *object->getRect());
- } else {
- if (object->flags & kObjectFlag40) {
- PolyDefinitions *poly = &_polygons->entries[object->getPolygonIndex()];
- if (point.x > 0 && point.y > 0 && poly->count() > 0)
- intersects = poly->contains(point);
- else
- warning ("[drawActorsAndObjects] trying to find intersection of uninitialized point");
- }
+ notIntersects = !pointIntersectsRect(point, *object->getRect());
+ } else if (object->flags & kObjectFlag40) {
+ PolyDefinitions *poly = &_polygons->entries[object->getPolygonIndex()];
+ notIntersects = poly->contains(point);
}
// Adjust object flags
- if (BYTE1(object->flags) & kObjectFlag80 || intersects) {
+ if (BYTE1(object->flags) & kObjectFlag80 || notIntersects) {
if (BYTE1(object->flags) & kObjectFlag20)
- object->flags = (BYTE1(object->flags) & 0xBF) | kObjectFlag80;
+ object->flags = (BYTE1(object->flags) & kObjectFlagBF) | kObjectFlag80;
} else {
if (BYTE1(object->flags) & kObjectFlag20) {
object->flags = BYTE1(object->flags) | kObjectFlag40;
@@ -2448,15 +2442,15 @@ void Scene::processUpdateList() {
}
if (object->flags & kObjectFlag4) {
- if (intersects && LOBYTE(actor->flags) & kActorFlagMasked) {
- error("[Scene::processUpdateList] Assigning mask to masked character [%s]", actor->getName());
+ if (notIntersects && LOBYTE(actor->flags) & kActorFlagMasked) {
+ error("[Scene::processUpdateList] Assigning mask to masked character (%s)", actor->getName());
} else {
object->adjustCoordinates(&point);
actor->setObjectIndex(j);
actor->flags |= kActorFlagMasked;
}
} else {
- if (intersects) {
+ if (notIntersects) {
if (actor->getPriority() < object->getPriority()) {
actor->setField934(1);
actor->setPriority(object->getPriority() + 3);
Commit: abcb2858e50ca8daaf495eb75db3e0ab30988e4a
https://github.com/scummvm/scummvm/commit/abcb2858e50ca8daaf495eb75db3e0ab30988e4a
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:41+02:00
Commit Message:
ASYLUM: Correct initial value of flag in Screen class
This makes the main player visible on screen again :D
- Correct destination rect left value not being calculated properly
- Use whole flag value when testing for masked actors
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@699 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/resources/actor.cpp
engines/asylum/system/screen.cpp
diff --git a/engines/asylum/resources/actor.cpp b/engines/asylum/resources/actor.cpp
index 056c97290c..21d5b8daf7 100644
--- a/engines/asylum/resources/actor.cpp
+++ b/engines/asylum/resources/actor.cpp
@@ -252,7 +252,7 @@ void Actor::draw() {
if (_frameIndex >= _frameCount)
frameIndex = 2 * _frameCount - (_frameIndex + 1);
- if (LOBYTE(flags) & kActorFlagMasked) {
+ if (flags & kActorFlagMasked) {
Object *object = getWorld()->objects[_objectIndex];
Common::Point objPoint;
object->adjustCoordinates(&objPoint);
diff --git a/engines/asylum/system/screen.cpp b/engines/asylum/system/screen.cpp
index 5c3702729d..fdf65d8afe 100644
--- a/engines/asylum/system/screen.cpp
+++ b/engines/asylum/system/screen.cpp
@@ -42,7 +42,7 @@ Screen::Screen(AsylumEngine *vm) : _vm(vm) ,
_useColorKey(false), _transTableCount(0), _transTableIndex(NULL), _transTableData(NULL), _transTableBuffer(NULL) {
_backBuffer.create(640, 480, 1);
- _flag = 0xFF;
+ _flag = -1;
_clipRect = Common::Rect(0, 0, 639, 479);
}
@@ -87,7 +87,7 @@ void Screen::draw(ResourceId resourceId, uint32 frameIndex, int32 sourceX, int32
destination.left = sourceX + resource->getData().maxWidth - frame->getWidth() - frame->x;
}
} else {
- destination.left += 2 * _flag - (frame->getHeight() * 2 - frame->x);
+ destination.left += 2 * (_flag - (frame->getHeight() * 2 - frame->x));
}
}
Commit: 359794ec5d895d7f9aba329803cce9097a3ef586
https://github.com/scummvm/scummvm/commit/359794ec5d895d7f9aba329803cce9097a3ef586
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:42+02:00
Commit Message:
ASYLUM: Made several SharedData members public
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@700 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/asylum.cpp
engines/asylum/resources/actor.cpp
engines/asylum/resources/data.h
engines/asylum/resources/encounters.cpp
engines/asylum/resources/object.cpp
engines/asylum/resources/script.cpp
engines/asylum/system/sound.cpp
engines/asylum/views/menu.cpp
engines/asylum/views/scene.cpp
diff --git a/engines/asylum/asylum.cpp b/engines/asylum/asylum.cpp
index 6b721c8f17..1b4a117d57 100644
--- a/engines/asylum/asylum.cpp
+++ b/engines/asylum/asylum.cpp
@@ -234,8 +234,8 @@ void AsylumEngine::restart() {
delete _scene;
_scene = NULL;
- _data.getPoint()->x = -1;
- _data.getPoint()->y = -1;
+ _data.point.x = -1;
+ _data.point.y = -1;
reset();
@@ -368,7 +368,7 @@ void AsylumEngine::processDelayedEvents() {
if (!_video || !_sound || !_menu)
error("[AsylumEngine::processDelayedEvents] Subsystems not initialized properly!");
- // check for a delayed scene change
+ // check for a delayed scene change
if (_delayedSceneIndex != kResourcePackInvalid && isGameFlagNotSet(kGameFlagScriptProcessing)) {
ResourcePackId sceneIndex = _delayedSceneIndex;
diff --git a/engines/asylum/resources/actor.cpp b/engines/asylum/resources/actor.cpp
index 21d5b8daf7..de2fda00d3 100644
--- a/engines/asylum/resources/actor.cpp
+++ b/engines/asylum/resources/actor.cpp
@@ -509,8 +509,8 @@ void Actor::update() {
break;
case kActorStatus7:
- if (getSharedData()->getActorEnableForStatus7()) {
- getSharedData()->setActorEnableForStatus7(false);
+ if (getSharedData()->actorEnableForStatus7) {
+ getSharedData()->actorEnableForStatus7 = false;
enable();
}
break;
@@ -661,7 +661,7 @@ void Actor::updateStatus(ActorStatus actorStatus) {
}
if (_index == 11)
- _resourceId = _graphicResourceIds[getSharedData()->getGlobalDirection() > 4 ? 8 - getSharedData()->getGlobalDirection() : getSharedData()->getGlobalDirection()];
+ _resourceId = _graphicResourceIds[getSharedData()->globalDirection > 4 ? 8 - getSharedData()->globalDirection : getSharedData()->globalDirection];
// Reload the graphic resource if the resource ID has changed
if (resource->getResourceId() != _resourceId)
@@ -1366,7 +1366,7 @@ void Actor::updateStatusEnabled() {
Common::Point pt(poly->boundingRect.left + rnd(poly->boundingRect.width()),
poly->boundingRect.top + rnd(poly->boundingRect.height()));
- if (!getSharedData()->getActorUpdateEnabledCheck()) {
+ if (!getSharedData()->actorUpdateEnabledCheck) {
if (isInActionArea(pt, area)) {
Common::Point *polyPoint = &poly->points[rnd(poly->count())];
processStatus(polyPoint->x, polyPoint->y, false);
@@ -1379,7 +1379,7 @@ void Actor::updateStatusEnabled() {
}
}
} else {
- switch (getSharedData()->getActorUpdateEnabledCounter()) {
+ switch (getSharedData()->actorUpdateStatusEnabledCounter) {
default:
break;
@@ -1418,7 +1418,7 @@ void Actor::updateStatusEnabledProcessStatus(int32 testX, int32 testY, uint32 co
if (rnd(1000) < 5)
processStatus(testX, testY, false);
} else {
- getSharedData()->setActorUpdateEnabledCounter(counter);
+ getSharedData()->actorUpdateStatusEnabledCounter = counter;
if (rnd(1000) < 5)
processStatus(setX, setY, false);
@@ -1484,17 +1484,15 @@ void Actor::updateStatus12_Chapter11() {
getWorld()->tickValueArray[_index] = rnd(4000) + _vm->getTick();
}
- Common::Point *vector1 = getSharedData()->getVector1();
- Common::Point *vector2 = getSharedData()->getVector2();
Actor *actor0 = getScene()->getActor(0);
- vector1->x = actor0->getPoint1()->x + actor0->getPoint2()->x;
- vector1->y = actor0->getPoint1()->y + actor0->getPoint2()->y - 5;
+ getSharedData()->vector1.x = actor0->getPoint1()->x + actor0->getPoint2()->x;
+ getSharedData()->vector1.y = actor0->getPoint1()->y + actor0->getPoint2()->y - 5;
- vector2->x = _point1.x + _point2.x;
- vector2->y = _point1.y + _point2.y;
+ getSharedData()->vector2.x = _point1.x + _point2.x;
+ getSharedData()->vector2.y = _point1.y + _point2.y;
- updateCoordinates(*vector1, *vector2);
+ updateCoordinates(getSharedData()->vector1, getSharedData()->vector2);
}
void Actor::updateStatus14() {
@@ -1530,24 +1528,22 @@ void Actor::updateStatus14_Chapter2() {
}
void Actor::updateStatus14_Chapter11() {
- Common::Point *vector1 = getSharedData()->getVector1();
- Common::Point *vector2 = getSharedData()->getVector2();
Actor *actor0 = getScene()->getActor(0);
- vector1->x = actor0->getPoint1()->x + actor0->getPoint2()->x;
- vector1->y = actor0->getPoint1()->y + actor0->getPoint2()->y - 5;
+ getSharedData()->vector1.x = actor0->getPoint1()->x + actor0->getPoint2()->x;
+ getSharedData()->vector1.y = actor0->getPoint1()->y + actor0->getPoint2()->y - 5;
- vector2->x = _point1.x + _point2.x;
- vector2->y = _point1.y + _point2.y;
+ getSharedData()->vector2.x = _point1.x + _point2.x;
+ getSharedData()->vector2.y = _point1.y + _point2.y;
if (getWorld()->tickValueArray[_index] == -666)
getWorld()->tickValueArray[_index] = rnd(4000) + _vm->getTick();
faceTarget(kActorMax, kDirectionFromActor);
- updateCoordinates(*vector1, *vector2);
+ updateCoordinates(getSharedData()->vector1, getSharedData()->vector2);
if (getWorld()->tickValueArray[_index] < (int)_vm->getTick()) {
- if (distance(*vector1, *vector2) >= 75) {
+ if (distance(getSharedData()->vector1, getSharedData()->vector2) >= 75) {
getWorld()->tickValueArray[_index] = rnd(1000) + 2000 + _vm->getTick();
} else {
if (actor0->getStatus() == kActorStatus12 || actor0->getStatus() == kActorStatus14 || actor0->getStatus() == kActorStatus15)
@@ -1602,25 +1598,23 @@ void Actor::updateStatus15_Chapter2_Actor11() {
}
void Actor::updateStatus15_Chapter11() {
- Common::Point *vector1 = getSharedData()->getVector1();
- Common::Point *vector2 = getSharedData()->getVector2();
Actor *actor0 = getScene()->getActor(0);
// Update vectors
- vector1->x = actor0->getPoint1()->x + actor0->getPoint2()->x;
- vector1->y = actor0->getPoint1()->y + actor0->getPoint2()->y - 5;
+ getSharedData()->vector1.x = actor0->getPoint1()->x + actor0->getPoint2()->x;
+ getSharedData()->vector1.y = actor0->getPoint1()->y + actor0->getPoint2()->y - 5;
- vector2->x = actor0->getPoint1()->x + actor0->getPoint2()->x;
- vector2->y = actor0->getPoint1()->y + actor0->getPoint2()->y;
+ getSharedData()->vector2.x = actor0->getPoint1()->x + actor0->getPoint2()->x;
+ getSharedData()->vector2.y = actor0->getPoint1()->y + actor0->getPoint2()->y;
- updateCoordinates(*vector1, *vector2);
+ updateCoordinates(getSharedData()->vector1, getSharedData()->vector2);
++_frameIndex;
if (_frameIndex >= _frameCount)
updateStatus(kActorStatus14);
if (_frameIndex == 14) {
- if (Actor::distance(*vector1, *vector2) < 75) {
+ if (Actor::distance(getSharedData()->vector1, getSharedData()->vector2) < 75) {
actor0->updateStatus(kActorStatus16);
++getWorld()->field_E848C;
diff --git a/engines/asylum/resources/data.h b/engines/asylum/resources/data.h
index 81cc7ec765..b0d7e0d9c7 100644
--- a/engines/asylum/resources/data.h
+++ b/engines/asylum/resources/data.h
@@ -106,13 +106,13 @@ struct SharedData {
public:
SharedData() {
cdNumber = 0;
- _actorEnableForStatus7 = false;
+ actorEnableForStatus7 = false;
_flag1 = false;
- _matteBarHeight = 0;
- _matteVar2 = 0;
- _sceneCounter = 0;
- _point.x = -1;
- _point.y = -1;
+ matteBarHeight = 0;
+ matteVar2 = 0;
+ sceneCounter = 0;
+ point.x = -1;
+ point.y = -1;
sceneXLeft = 0;
sceneYTop = 0;
sceneOffset = 0;
@@ -125,85 +125,72 @@ public:
smallCurDown = 0;
encounterFrameBg = 0;
_flagSkipDrawScene = false;
- _matteVar1 = 0;
- _actorUpdateEnabledCheck = false;
- _matteInitialized = false;
- _mattePlaySound = false;
- _currentScreenUpdatesCount = 0;
+ matteVar1 = 0;
+ actorUpdateEnabledCheck = false;
+ matteInitialized = false;
+ mattePlaySound = false;
+ currentScreenUpdatesCount = 0;
memset(&_data1, 0, sizeof(_data1));
memset(&_data2, 0, sizeof(_data2));
- _actorUpdateStatusEnabledCounter = 0;
+ actorUpdateStatusEnabledCounter = 0;
memset(&_data3, 0, sizeof(_data3));
_flagScene1 = false;
- memset(&_movies, 0, sizeof(_movies));
- _actorUpdateStatus15Check = false;
+ //memset(&_movies, 0, sizeof(_movies));
+ actorUpdateStatus15Check = false;
_flag2 = false;
- _globalDirection = kDirectionN;
+ globalDirection = kDirectionN;
memset(&_ambientTick, 0, sizeof(_ambientTick));
// Screen updates
_flagRedraw = false;
- _nextScreenUpdate = 0;
+ nextScreenUpdate = 0;
}
+ // Public variables
int32 cdNumber;
// Saved scene data
ResourceId cursorResources[11];
- // 2 ResourceId unused
ResourceId sceneFonts[3];
- //ResourceId _currentPaletteId;
- //int32 _cellShadeMasks[3];
- // unused
int32 smallCurUp;
int32 smallCurDown;
int32 encounterFrameBg;
- // Global scene coordinates and offset
- int32 sceneXLeft;
- int32 sceneYTop;
- int32 sceneOffset;
- int32 sceneOffsetAdd;
-
- // Accessors
- int32 getActorUpdateEnabledCounter() { return _actorUpdateStatusEnabledCounter; }
- void setActorUpdateEnabledCounter(int32 val) { _actorUpdateStatusEnabledCounter = val; }
+ Common::Point point; // global point
+ uint32 sceneCounter;
- bool getActorEnableForStatus7() { return _actorEnableForStatus7; }
- void setActorEnableForStatus7(bool state) { _actorEnableForStatus7 = state; }
+ // Global scene coordinates and offset
+ int32 sceneXLeft;
+ int32 sceneYTop;
+ int32 sceneOffset;
+ int32 sceneOffsetAdd;
+
+ // Actor
+ Common::Point vector1;
+ Common::Point vector2;
+ bool actorEnableForStatus7;
+ bool actorUpdateEnabledCheck;
+ int32 actorUpdateStatusEnabledCounter;
+ bool actorUpdateStatus15Check;
+ ActorDirection globalDirection;
+
+ // Matte bars
+ uint32 matteBarHeight;
+ int32 matteVar1;
+ uint32 matteVar2;
+ bool matteInitialized;
+ bool mattePlaySound;
- bool getActorUpdateEnabledCheck() { return _actorUpdateEnabledCheck; }
+ // Screen updates
+ uint32 nextScreenUpdate;
+ int32 currentScreenUpdatesCount;
- ActorDirection getGlobalDirection() { return _globalDirection; }
- void setActorUpdateFlag(int32 val) { _data1[40] = 2; }
+ // Accessors
+ void setActorUpdateFlag(int32 val) { _data1[40] = 2; }
+ void setActorUpdateFlag2(int32 val) { _data1[36] = val; }
int32 getActorUpdateFlag2() { return _data1[36]; }
- void setActorUpdateFlag2(int32 val) { _data1[36] = val; }
-
- // Shared global Data
- Common::Point *getPoint() { return &_point; }
-
- int32 getMatteBarHeight() { return _matteBarHeight;}
- void setMatteBarHeight(int32 val) { _matteBarHeight = val; }
-
- int32 getMatteVar1() { return _matteVar1; }
- void setMatteVar1(int32 val) { _matteVar1 = val; }
-
- int32 getMatteVar2() { return _matteVar2; }
- void setMatteVar2(int32 val) { _matteVar2 = val; }
-
- bool getMatteInitialized() { return _matteInitialized; }
- void setMatteInitialized(bool state) { _matteInitialized = state; }
-
- bool getMattePlaySound() { return _mattePlaySound; }
- void setMattePlaySound(bool state) { _mattePlaySound = state; }
-
- Common::Point *getVector1() { return &_vector1; }
- Common::Point *getVector2() { return &_vector2; }
-
- void setNextScreenUpdate(uint32 ticks) { _nextScreenUpdate = ticks; }
- uint32 getNextScreenUpdate() { return _nextScreenUpdate; }
void setData(ActorIndex index, int32 val) {
if (index < 50)
@@ -321,55 +308,20 @@ public:
}
private:
- Common::Point _vector1;
- Common::Point _vector2;
-
- bool _actorEnableForStatus7;
+ uint32 _ambientTick[16];
+ // Flags
bool _flag1;
+ bool _flag2;
+ bool _flag3;
+ bool _flagSkipDrawScene;
+ bool _flagScene1;
+ bool _flagRedraw;
- uint32 _matteBarHeight;
- uint32 _matteVar2;
-
- // Lots of other data
-
- //////////////////////////////////////////////////////////////////////////
// Shared data
- // (Some functions access those by offset, so until we figure out what
- // exact data they need, we keep all of them here)
- //////////////////////////////////////////////////////////////////////////
-
- // TODO Add ambient sound panning array
- uint32 _sceneCounter;
- Common::Point _point; // global point
- //bool _flagEncouter2;
-
- bool _flagSkipDrawScene;
- int32 _matteVar1;
- bool _actorUpdateEnabledCheck;
- bool _matteInitialized;
- bool _mattePlaySound;
- int32 _currentScreenUpdatesCount;
int32 _data1[50];
int32 _data2[11];
- bool _actorUpdateStatusEnabledCounter;
bool _data3[9];
- //bool _flagEncouter5;
- bool _flagScene1;
- int32 _movies[49];
- bool _actorUpdateStatus15Check;
- // Skip opening flag (not used)
- bool _flag3;
- bool _flag2;
-
- ActorDirection _globalDirection;
-
- uint32 _ambientTick[16];
-
-
- // Screen updates
- bool _flagRedraw;
- uint32 _nextScreenUpdate;
};
} // End of namespace Asylum
diff --git a/engines/asylum/resources/encounters.cpp b/engines/asylum/resources/encounters.cpp
index 1140ae3bc5..22843bcbf4 100644
--- a/engines/asylum/resources/encounters.cpp
+++ b/engines/asylum/resources/encounters.cpp
@@ -321,7 +321,7 @@ bool Encounter::init() {
if (getSound()->getMusicVolume() != Config.musicVolume - 500)
getSound()->setMusicVolume(Config.musicVolume - 500);
- if (!getSharedData()->getMatteBarHeight()) {
+ if (!getSharedData()->matteBarHeight) {
_isRunning = true;
_data_455BD4 = false;
_data_455BD8 = false;
@@ -350,7 +350,7 @@ bool Encounter::init() {
_data_455BD0 = false;
getCursor()->set(getWorld()->cursorResources[kCursorResourceTalkNPC], -1, kCursorAnimationMirror);
- if (!getSharedData()->getMatteBarHeight())
+ if (!getSharedData()->matteBarHeight)
initScript(_item->scriptResourceId);
return true;
@@ -403,7 +403,7 @@ bool Encounter::update() {
}
if (_data_455BE8) {
- if (getSharedData()->getMatteBarHeight()) {
+ if (getSharedData()->matteBarHeight) {
_data_455BD0 = false;
} else {
getCursor()->show();
@@ -425,7 +425,7 @@ bool Encounter::update() {
|| (getSpeech()->getTick() && tick >= getSpeech()->getTick()))
doScript = true;
- if (!getSharedData()->getMatteBarHeight() && doScript && _flag4) {
+ if (!getSharedData()->matteBarHeight && doScript && _flag4) {
if (!setupSpeech(id))
runScript();
}
@@ -439,15 +439,15 @@ bool Encounter::update() {
getSharedData()->setFlag(kFlagRedraw, true);
}
- if (tick >= getSharedData()->getNextScreenUpdate() && getSharedData()->getFlag(kFlagRedraw)) {
- if (getSharedData()->getMatteBarHeight() <= 0) {
+ if (tick >= getSharedData()->nextScreenUpdate && getSharedData()->getFlag(kFlagRedraw)) {
+ if (getSharedData()->matteBarHeight <= 0) {
getScreen()->copyBackBufferToScreen();
} else {
drawScreen();
}
getSharedData()->setFlag(kFlagRedraw, false);
- getSharedData()->setNextScreenUpdate(tick + 55);
+ getSharedData()->nextScreenUpdate = tick + 55;
}
return true;
@@ -1547,14 +1547,14 @@ void Encounter::runScript() {
break;
case 23:
- if (!getSharedData()->getMatteBarHeight()) {
+ if (!getSharedData()->matteBarHeight) {
getScreen()->makeGreyPalette();
- getSharedData()->setMatteBarHeight(1);
+ getSharedData()->matteBarHeight = 1;
getVideo()->play(getVariableInv(entry.param2), this);
- getSharedData()->setMatteVar1(1);
- getSharedData()->setMattePlaySound(true);
- getSharedData()->setMatteInitialized(true);
- getSharedData()->setMatteVar2(0);
+ getSharedData()->matteVar1 = 1;
+ getSharedData()->mattePlaySound = true;
+ getSharedData()->matteInitialized = true;
+ getSharedData()->matteVar2 = 0;
done = true;
}
diff --git a/engines/asylum/resources/object.cpp b/engines/asylum/resources/object.cpp
index 99fefb803a..dc3581cd88 100644
--- a/engines/asylum/resources/object.cpp
+++ b/engines/asylum/resources/object.cpp
@@ -273,14 +273,14 @@ void Object::update() {
if (_frameIndex < _frameCount - 1) {
if (_field_688 == 1) {
Common::Rect frameRect = GraphicResource::getFrameRect(_vm, _resourceId, _frameIndex);
- getSharedData()->getPoint()->x = x + frameRect.left + Common::Rational(frameRect.width(), 2).toInt();
- getSharedData()->getPoint()->y = y + frameRect.top + Common::Rational(frameRect.height(), 2).toInt();
+ getSharedData()->point.x = x + frameRect.left + Common::Rational(frameRect.width(), 2).toInt();
+ getSharedData()->point.y = y + frameRect.top + Common::Rational(frameRect.height(), 2).toInt();
}
} else {
flags &= ~kObjectFlag8;
if (_field_688 == 1) {
- getSharedData()->getPoint()->x = -1;
- getSharedData()->getPoint()->y = -1;
+ getSharedData()->point.x = -1;
+ getSharedData()->point.y = -1;
}
}
_tickCount = _vm->getTick();
@@ -295,13 +295,13 @@ void Object::update() {
if (_frameIndex == 0) {
flags &= ~kObjectFlag10000;
if (_field_688 == 1) {
- getSharedData()->getPoint()->x = -1;
- getSharedData()->getPoint()->y = -1;
+ getSharedData()->point.x = -1;
+ getSharedData()->point.y = -1;
}
} else if (_field_688 == 1) {
Common::Rect frameRect = GraphicResource::getFrameRect(_vm, _resourceId, _frameIndex);
- getSharedData()->getPoint()->x = x + frameRect.left + Common::Rational(frameRect.width(), 2).toInt();
- getSharedData()->getPoint()->y = y + frameRect.top + Common::Rational(frameRect.height(), 2).toInt();
+ getSharedData()->point.x = x + frameRect.left + Common::Rational(frameRect.width(), 2).toInt();
+ getSharedData()->point.y = y + frameRect.top + Common::Rational(frameRect.height(), 2).toInt();
}
_tickCount = _vm->getTick();
diff --git a/engines/asylum/resources/script.cpp b/engines/asylum/resources/script.cpp
index 7d8c54c44c..dc98f828d3 100644
--- a/engines/asylum/resources/script.cpp
+++ b/engines/asylum/resources/script.cpp
@@ -436,13 +436,13 @@ IMPLEMENT_OPCODE(PlayAnimation)
if (object->getField688() == 1) {
if (object->flags & kObjectFlag4) {
- getSharedData()->getPoint()->x = object->x;
- getSharedData()->getPoint()->y = object->y;
+ getSharedData()->point.x = object->x;
+ getSharedData()->point.y = object->y;
} else {
Common::Rect frameRect = GraphicResource::getFrameRect(_vm, object->getResourceId(), object->getFrameIndex());
- getSharedData()->getPoint()->x = frameRect.left + Common::Rational(frameRect.width(), 2).toInt() + object->x;
- getSharedData()->getPoint()->y = frameRect.top + Common::Rational(frameRect.height(), 2).toInt() + object->y;
+ getSharedData()->point.x = frameRect.left + Common::Rational(frameRect.width(), 2).toInt() + object->x;
+ getSharedData()->point.y = frameRect.top + Common::Rational(frameRect.height(), 2).toInt() + object->y;
}
}
@@ -898,17 +898,17 @@ END_OPCODE
//////////////////////////////////////////////////////////////////////////
// Opcode 0x2D
IMPLEMENT_OPCODE(PlayMovie)
- if (getSharedData()->getMatteBarHeight() < 170) {
+ if (getSharedData()->matteBarHeight < 170) {
_lineIncrement = 1;
- if (!getSharedData()->getMatteBarHeight()) {
+ if (!getSharedData()->matteBarHeight) {
getCursor()->hide();
getScreen()->makeGreyPalette();
- getSharedData()->setMatteVar1(1);
- getSharedData()->setMatteBarHeight(1);
- getSharedData()->setMatteVar2(0);
- getSharedData()->setMattePlaySound(cmd->param3 == 0);
- getSharedData()->setMatteInitialized(cmd->param2 == 0);
+ getSharedData()->matteVar1 = 1;
+ getSharedData()->matteBarHeight = 1;
+ getSharedData()->matteVar2 = 0;
+ getSharedData()->mattePlaySound = (cmd->param3 == 0);
+ getSharedData()->matteInitialized = (cmd->param2 == 0);
_delayedVideoIndex = cmd->param1;
}
@@ -925,10 +925,10 @@ IMPLEMENT_OPCODE(PlayMovie)
getScreen()->setGammaLevel(getWorld()->currentPaletteId, 0);
}
- getSharedData()->setMatteBarHeight(0);
+ getSharedData()->matteBarHeight = 0;
_lineIncrement = 0;
- if (!getSharedData()->getMattePlaySound() && _currentScript->commands[0].numLines != 0) {
+ if (!getSharedData()->mattePlaySound && _currentScript->commands[0].numLines != 0) {
bool found = true;
int index = 0;
@@ -946,11 +946,11 @@ IMPLEMENT_OPCODE(PlayMovie)
check = true;
}
- if (!check && getSharedData()->getMatteVar2() == 0 && getWorld()->musicCurrentResourceIndex != kMusicStopped)
+ if (!check && getSharedData()->matteVar2 == 0 && getWorld()->musicCurrentResourceIndex != kMusicStopped)
_vm->sound()->playMusic(MAKE_RESOURCE(kResourcePackMusic, getWorld()->musicCurrentResourceIndex));
getCursor()->show();
- getSharedData()->setMatteVar2(0);
+ getSharedData()->matteVar2 =0;
END_OPCODE
//////////////////////////////////////////////////////////////////////////
@@ -1127,7 +1127,7 @@ IMPLEMENT_OPCODE(UpdateWideScreen)
cmd->param1 = 0;
_lineIncrement = 0;
- getSharedData()->setMatteBarHeight(0);
+ getSharedData()->matteBarHeight = 0;
} else {
getScreen()->drawWideScreenBars((int16)(4 * barSize));
@@ -1399,19 +1399,19 @@ END_OPCODE
//////////////////////////////////////////////////////////////////////////
// Opcode 0x48
IMPLEMENT_OPCODE(_unk48_MATTE_01)
- getSharedData()->setMatteVar1(0);
- getSharedData()->setMatteInitialized(true);
+ getSharedData()->matteVar1 = 0;
+ getSharedData()->matteInitialized = true;
- if (getSharedData()->getMatteBarHeight() >= 170) {
- getSharedData()->setMatteBarHeight(0);
+ if (getSharedData()->matteBarHeight >= 170) {
+ getSharedData()->matteBarHeight = 0;
_lineIncrement = 0;
getCursor()->show();
} else {
_lineIncrement = 1;
- if (!getSharedData()->getMatteBarHeight()) {
+ if (!getSharedData()->matteBarHeight) {
getCursor()->hide();
- getSharedData()->setMatteBarHeight(1);
+ getSharedData()->matteBarHeight = 1;
}
}
END_OPCODE
@@ -1419,20 +1419,20 @@ END_OPCODE
//////////////////////////////////////////////////////////////////////////
// Opcode 0x49
IMPLEMENT_OPCODE(_unk49_MATTE_90)
- getSharedData()->setMatteVar1(0);
- getSharedData()->setMatteInitialized(true);
- getSharedData()->setMattePlaySound(true);
+ getSharedData()->matteVar1 = 0;
+ getSharedData()->matteInitialized = true;
+ getSharedData()->mattePlaySound = true;
- if (getSharedData()->getMatteBarHeight() >= 170) {
- getSharedData()->setMatteBarHeight(0);
+ if (getSharedData()->matteBarHeight >= 170) {
+ getSharedData()->matteBarHeight = 0;
_lineIncrement = 0;
getCursor()->show();
} else {
_lineIncrement = 1;
- if (!getSharedData()->getMatteBarHeight()) {
+ if (!getSharedData()->matteBarHeight) {
getCursor()->hide();
- getSharedData()->setMatteBarHeight(90);
+ getSharedData()->matteBarHeight = 90;
}
}
END_OPCODE
diff --git a/engines/asylum/system/sound.cpp b/engines/asylum/system/sound.cpp
index f0f7a423ef..519d3b8a9f 100644
--- a/engines/asylum/system/sound.cpp
+++ b/engines/asylum/system/sound.cpp
@@ -160,12 +160,12 @@ int32 Sound::calculateVolumeAdjustement(int32 x, int32 y, int32 attenuation, int
return -(delta * delta);
Actor *player = getScene()->getActor();
- if (getSharedData()->getPoint()->x == -1) {
+ if (getSharedData()->point.x == -1) {
x -= (player->getPoint1()->x + player->getPoint2()->x);
y -= (player->getPoint1()->y + player->getPoint2()->y);
} else {
- x -= getSharedData()->getPoint()->x;
- y -= getSharedData()->getPoint()->y;
+ x -= getSharedData()->point.x;
+ y -= getSharedData()->point.y;
}
int32 adjustedVolume = getAdjustedVolume(x * x + y * y);
diff --git a/engines/asylum/views/menu.cpp b/engines/asylum/views/menu.cpp
index fd7708b4b8..c1526d60dc 100644
--- a/engines/asylum/views/menu.cpp
+++ b/engines/asylum/views/menu.cpp
@@ -524,12 +524,12 @@ bool Menu::update() {
getSharedData()->setFlag(kFlagRedraw, true);
}
- if (ticks > getSharedData()->getNextScreenUpdate()) {
+ if (ticks > getSharedData()->nextScreenUpdate) {
if (getSharedData()->getFlag(kFlagRedraw)) {
getScreen()->copyBackBufferToScreen();
getSharedData()->setFlag(kFlagRedraw, false);
- getSharedData()->setNextScreenUpdate(ticks + 55);
+ getSharedData()->nextScreenUpdate = ticks + 55;
}
}
diff --git a/engines/asylum/views/scene.cpp b/engines/asylum/views/scene.cpp
index 4fa57666cc..3f329d4219 100644
--- a/engines/asylum/views/scene.cpp
+++ b/engines/asylum/views/scene.cpp
@@ -383,9 +383,9 @@ bool Scene::update() {
getSharedData()->setFlag(kFlagRedraw, true);
}
- if (ticks > getSharedData()->getNextScreenUpdate()) {
+ if (ticks > getSharedData()->nextScreenUpdate) {
if (getSharedData()->getFlag(kFlagRedraw)) {
- if (getSharedData()->getMatteBarHeight() <= 0)
+ if (getSharedData()->matteBarHeight <= 0)
getScreen()->copyBackBufferToScreen();
else
getEncounter()->drawScreen();
@@ -394,7 +394,7 @@ bool Scene::update() {
getSharedData()->setData(39, getSharedData()->getData(39) ^ 1);
getSharedData()->setFlag(kFlagRedraw, false);
- getSharedData()->setNextScreenUpdate(ticks + 55);
+ getSharedData()->nextScreenUpdate = ticks + 55;
++_vm->screenUpdateCount;
}
}
@@ -665,7 +665,7 @@ bool Scene::updateScene() {
#endif
// Update each part of the scene
- if (getSharedData()->getMatteBarHeight() != 170 || getSharedData()->getMattePlaySound()) {
+ if (getSharedData()->matteBarHeight != 170 || getSharedData()->mattePlaySound) {
MESURE_TICKS(updateMouse);
MESURE_TICKS(updateActors);
MESURE_TICKS(updateObjects);
Commit: 10b68af6387f14170527c2da1efeb9a3bbf35271
https://github.com/scummvm/scummvm/commit/10b68af6387f14170527c2da1efeb9a3bbf35271
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:42+02:00
Commit Message:
ASYLUM: Remove last use of _delayedSceneIndex and delayedVideoIndex in Script class
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@701 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/resources/script.cpp
engines/asylum/resources/script.h
diff --git a/engines/asylum/resources/script.cpp b/engines/asylum/resources/script.cpp
index dc98f828d3..536ef13004 100644
--- a/engines/asylum/resources/script.cpp
+++ b/engines/asylum/resources/script.cpp
@@ -246,8 +246,6 @@ void ScriptManager::reset() {
_currentLine = 0;
_currentLoops = 0;
_currentScript = NULL;
- _delayedSceneIndex = kResourcePackInvalid;
- _delayedVideoIndex = -1;
_done = false;
_exit = false;
_lineIncrement = 0;
@@ -826,8 +824,8 @@ IMPLEMENT_OPCODE(ChangeScene)
getSound()->stopAll();
getSound()->stopMusic();
- // Change the scene number
- _delayedSceneIndex = (ResourcePackId)(cmd->param1 + 4);
+ // Switch the scene
+ _vm->switchScene((ResourcePackId)(cmd->param1 + 4));
_exit = true;
END_OPCODE
@@ -909,7 +907,7 @@ IMPLEMENT_OPCODE(PlayMovie)
getSharedData()->matteVar2 = 0;
getSharedData()->mattePlaySound = (cmd->param3 == 0);
getSharedData()->matteInitialized = (cmd->param2 == 0);
- _delayedVideoIndex = cmd->param1;
+ getSharedData()->movieIndex = cmd->param1;
}
return;
diff --git a/engines/asylum/resources/script.h b/engines/asylum/resources/script.h
index 23ae54337d..1395f52b03 100644
--- a/engines/asylum/resources/script.h
+++ b/engines/asylum/resources/script.h
@@ -248,8 +248,6 @@ private:
int32 _currentLoops;
Script *_currentScript;
ScriptQueueEntry _currentQueueEntry;
- ResourcePackId _delayedSceneIndex;
- int32 _delayedVideoIndex;
bool _done;
bool _exit;
int32 _lineIncrement;
Commit: bedc73b5f59be8e1426641448b1ea357841e1264
https://github.com/scummvm/scummvm/commit/bedc73b5f59be8e1426641448b1ea357841e1264
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:42+02:00
Commit Message:
ASYLUM: Implement Encounter::drawScreen() minus palette changes
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@702 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/resources/data.h
engines/asylum/resources/encounters.cpp
engines/asylum/resources/encounters.h
engines/asylum/system/screen.cpp
engines/asylum/system/screen.h
diff --git a/engines/asylum/resources/data.h b/engines/asylum/resources/data.h
index b0d7e0d9c7..9c5756fa07 100644
--- a/engines/asylum/resources/data.h
+++ b/engines/asylum/resources/data.h
@@ -144,10 +144,12 @@ public:
// Screen updates
_flagRedraw = false;
nextScreenUpdate = 0;
+ movieIndex = 0;
}
// Public variables
int32 cdNumber;
+ int32 movieIndex;
// Saved scene data
ResourceId cursorResources[11];
diff --git a/engines/asylum/resources/encounters.cpp b/engines/asylum/resources/encounters.cpp
index 22843bcbf4..9175d6dd9a 100644
--- a/engines/asylum/resources/encounters.cpp
+++ b/engines/asylum/resources/encounters.cpp
@@ -1144,7 +1144,77 @@ void Encounter::drawText(char *text, ResourceId font, int32 y) {
}
void Encounter::drawScreen() {
- error("[Encounter::drawScreen] not implemented!");
+ getScene()->getActor()->setLastScreenUpdate(_vm->screenUpdateCount);
+
+ if (!getSharedData()->matteInitialized)
+ getSharedData()->matteBarHeight = 85;
+
+ if (getSharedData()->matteBarHeight >= 84) {
+ if (getSharedData()->matteBarHeight == 85) {
+ if (getSharedData()->matteInitialized) {
+ getScreen()->drawWideScreenBars(82);
+
+ getScreen()->updatePalette();
+ getScreen()->setupPalette(NULL, 0, 0);
+ getScreen()->paletteFade(0, 25, 10);
+ } else {
+ getSharedData()->matteInitialized = true;
+ getScreen()->clear();
+ }
+
+ if (getSharedData()->matteVar1) {
+ if (!getSharedData()->matteVar2)
+ getSound()->playMusic(kResourceNone, 0);
+
+ // Play movie
+ getScreen()->clear();
+ getVideo()->play(getSharedData()->movieIndex, _isRunning ? (EventHandler*)this : getScene());
+ getScreen()->clearGraphicsInQueue();
+ getScreen()->clear();
+ getCursor()->hide();
+
+ if (getSharedData()->mattePlaySound) {
+ getScreen()->paletteFade(0, 2, 1);
+ getScene()->updateScreen();
+ getScreen()->drawWideScreenBars(82);
+
+ getScreen()->updatePalette();
+ getScreen()->setupPalette(NULL, 0, 0);
+
+ if (getSharedData()->mattePlaySound /* Scene::updateScreen() does script processing, so the value might have changed */
+ && !getSharedData()->matteVar2
+ && getWorld()->musicCurrentResourceIndex != kMusicStopped)
+ getSound()->playMusic(MAKE_RESOURCE(kResourcePackMusic, getWorld()->musicCurrentResourceIndex));
+ }
+
+ getSharedData()->matteBarHeight = (getSharedData()->mattePlaySound ? 346 : 170);
+ } else {
+ getSharedData()->matteBarHeight = 170;
+ }
+ } else if (getSharedData()->matteBarHeight >= 170) {
+ if (_isRunning) {
+ getSharedData()->matteBarHeight = 0;
+ getCursor()->show();
+ }
+ } else {
+ getScreen()->drawWideScreenBars(172 - getSharedData()->matteBarHeight);
+ getSharedData()->matteBarHeight += 4;
+
+ ResourceId paletteId = getWorld()->actions[getScene()->getActor()->getActionIndex3()]->paletteResourceId;
+ getScreen()->setPaletteGamma(paletteId ? paletteId : getWorld()->currentPaletteId);
+
+ updatePalette1();
+ getScreen()->setupPalette(NULL, 0, 0);
+ }
+ } else {
+ getScreen()->drawWideScreenBars(getSharedData()->matteBarHeight);
+ getSharedData()->matteBarHeight += 4;
+
+ getScreen()->setPaletteGamma(getWorld()->currentPaletteId);
+
+ updatePalette2();
+ getScreen()->setupPalette(NULL, 0, 0);
+ }
}
//////////////////////////////////////////////////////////////////////////
@@ -1355,6 +1425,14 @@ bool Encounter::updateScreen() {
return false;
}
+void Encounter::updatePalette1() {
+ error("[Encounter::updatePalette1] Not implemented!");
+}
+
+void Encounter::updatePalette2() {
+ error("[Encounter::updatePalette2] Not implemented!");
+}
+
//////////////////////////////////////////////////////////////////////////
// Scripts
//////////////////////////////////////////////////////////////////////////
@@ -1550,7 +1628,7 @@ void Encounter::runScript() {
if (!getSharedData()->matteBarHeight) {
getScreen()->makeGreyPalette();
getSharedData()->matteBarHeight = 1;
- getVideo()->play(getVariableInv(entry.param2), this);
+ getSharedData()->movieIndex = getVariableInv(entry.param2);
getSharedData()->matteVar1 = 1;
getSharedData()->mattePlaySound = true;
getSharedData()->matteInitialized = true;
diff --git a/engines/asylum/resources/encounters.h b/engines/asylum/resources/encounters.h
index 5e93b6f8f2..3529fb5977 100644
--- a/engines/asylum/resources/encounters.h
+++ b/engines/asylum/resources/encounters.h
@@ -238,7 +238,7 @@ private:
bool drawPortraits();
void drawStructs();
void drawDialog();
- void drawText(char *text, ResourceId font, int32 y);
+ void drawText(char *text, ResourceId font, int32 y);
//////////////////////////////////////////////////////////////////////////
// Misc
@@ -249,6 +249,8 @@ private:
void updateDrawingStatus1(int32 rectIndex);
void updateDrawingStatus2(int32 rectIndex);
bool updateScreen();
+ void updatePalette1();
+ void updatePalette2();
//////////////////////////////////////////////////////////////////////////
// Scripts
diff --git a/engines/asylum/system/screen.cpp b/engines/asylum/system/screen.cpp
index fdf65d8afe..1519cf6076 100644
--- a/engines/asylum/system/screen.cpp
+++ b/engines/asylum/system/screen.cpp
@@ -212,6 +212,10 @@ void Screen::setPalette(byte *rgbPalette) const {
_vm->_system->setPalette(palette, 0, 256);
}
+void Screen::setPaletteGamma(ResourceId id) {
+ warning("[Screen::setGammaPalette] not implemented");
+}
+
void Screen::setupPaletteAndStartFade(uint32 red, int32 milliseconds, int32 param) {
warning("[Screen::setupPaletteAndStartFade] Not implemented!");
}
@@ -230,6 +234,10 @@ void Screen::startPaletteFade(ResourceId resourceId, int32 milliseconds, int32 p
warning("[Screen::startPaletteFade] Not implemented!");
}
+void Screen::updatePalette() {
+ error("[Screen::updatePalette] Not implemented!");
+}
+
void Screen::updatePalette(int32 param) {
error("[Screen::updatePalette] Not implemented!");
}
diff --git a/engines/asylum/system/screen.h b/engines/asylum/system/screen.h
index b7e4d8964c..6a6204aee2 100644
--- a/engines/asylum/system/screen.h
+++ b/engines/asylum/system/screen.h
@@ -89,10 +89,12 @@ public:
// Palette
void setPalette(byte *rgbPalette) const;
void setPalette(ResourceId id);
+ void setPaletteGamma(ResourceId id);
void setupPaletteAndStartFade(uint32 red, int32 milliseconds, int32 param);
void stopFadeAndSetPalette(ResourceId id, int32 milliseconds, int32 param);
void paletteFade(uint32 red, int32 milliseconds, int32 param);
void startPaletteFade(ResourceId resourceId, int32 milliseconds, int32 param);
+ void updatePalette();
void updatePalette(int32 param);
void makeGreyPalette();
void setupPalette(byte *buffer, int start, int count);
Commit: 1d1ae9eea1f061b3d0a7d28458bb7542507ae08c
https://github.com/scummvm/scummvm/commit/1d1ae9eea1f061b3d0a7d28458bb7542507ae08c
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:42+02:00
Commit Message:
ASYLUM: Add debug command to start a puzzle
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@703 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/console.cpp
engines/asylum/console.h
diff --git a/engines/asylum/console.cpp b/engines/asylum/console.cpp
index a15f893353..9c7ac9c81a 100644
--- a/engines/asylum/console.cpp
+++ b/engines/asylum/console.cpp
@@ -66,6 +66,7 @@ Console::Console(AsylumEngine *engine) : _vm(engine) {
DCmd_Register("script", WRAP_METHOD(Console, cmdRunScript));
DCmd_Register("scene", WRAP_METHOD(Console, cmdChangeScene));
DCmd_Register("encounter", WRAP_METHOD(Console, cmdRunEncounter));
+ DCmd_Register("puzzle", WRAP_METHOD(Console, cmdRunPuzzle));
DCmd_Register("palette", WRAP_METHOD(Console, cmdSetPalette));
DCmd_Register("draw", WRAP_METHOD(Console, cmdDrawResource));
@@ -113,6 +114,7 @@ bool Console::cmdHelp(int, const char **) {
DebugPrintf(" script - run a script\n");
DebugPrintf(" scene - change the scene\n");
DebugPrintf(" encounter - run an encounter\n");
+ DebugPrintf(" puzzle - run an puzzle\n");
DebugPrintf("\n");
DebugPrintf(" palette - set the screen palette\n");
DebugPrintf(" draw - draw a resource\n");
@@ -374,7 +376,7 @@ bool Console::cmdChangeScene(int32 argc, const char **argv) {
return true;
}
- _vm->_delayedSceneIndex = index;
+ _vm->_delayedSceneIndex = index;
return false;
}
@@ -400,6 +402,34 @@ bool Console::cmdRunEncounter(int32 argc, const char **argv) {
return false;
}
+bool Console::cmdRunPuzzle(int32 argc, const char **argv) {
+ if (argc != 2) {
+ DebugPrintf("Syntax: %s <puzzle index>\n", argv[0]);
+ return true;
+ }
+
+ uint32 index = atoi(argv[1]);
+
+ // Check index is valid
+ if (index >= 16) {
+ DebugPrintf("[Error] Invalid index (was: %d - valid: [0-16])\n", index);
+ return true;
+ }
+
+ EventHandler *puzzle = _vm->getPuzzle(index);
+ if (puzzle == NULL) {
+ DebugPrintf("[Error] This puzzle does not exists (%d)", index);
+ return true;
+ }
+
+ getScreen()->clear();
+ getScreen()->clearGraphicsInQueue();
+
+ _vm->switchEventHandler(puzzle);
+
+ return false;
+}
+
bool Console::cmdSetPalette(int32 argc, const char **argv) {
if (argc != 3) {
DebugPrintf("Syntax: %s <pack> <index>\n", argv[0]);
diff --git a/engines/asylum/console.h b/engines/asylum/console.h
index 2113049ff8..cd32d872ea 100644
--- a/engines/asylum/console.h
+++ b/engines/asylum/console.h
@@ -74,6 +74,7 @@ private:
bool cmdRunScript(int32 argc, const char **argv);
bool cmdChangeScene(int32 argc, const char **argv);
bool cmdRunEncounter(int32 argc, const char **argv);
+ bool cmdRunPuzzle(int32 argc, const char **argv);
bool cmdSetPalette(int32 argc, const char **argv);
bool cmdDrawResource(int32 argc, const char **argv);
Commit: c19fba0b1fc2305cb6f9202776299abf1ac72d01
https://github.com/scummvm/scummvm/commit/c19fba0b1fc2305cb6f9202776299abf1ac72d01
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:42+02:00
Commit Message:
ASYLUM: Implement handleEvent in Puzzle class and let child classes implement init, key & mouse handlers
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@704 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/puzzles/boardkeyhidesto.cpp
engines/asylum/puzzles/boardkeyhidesto.h
engines/asylum/puzzles/boardsalvation.cpp
engines/asylum/puzzles/boardsalvation.h
engines/asylum/puzzles/boardyouth.cpp
engines/asylum/puzzles/boardyouth.h
engines/asylum/puzzles/clock.cpp
engines/asylum/puzzles/clock.h
engines/asylum/puzzles/fisherman.cpp
engines/asylum/puzzles/fisherman.h
engines/asylum/puzzles/hivecontrol.cpp
engines/asylum/puzzles/hivecontrol.h
engines/asylum/puzzles/hivemachine.cpp
engines/asylum/puzzles/hivemachine.h
engines/asylum/puzzles/lock.cpp
engines/asylum/puzzles/lock.h
engines/asylum/puzzles/morguedoor.cpp
engines/asylum/puzzles/morguedoor.h
engines/asylum/puzzles/pipes.cpp
engines/asylum/puzzles/pipes.h
engines/asylum/puzzles/puzzle.cpp
engines/asylum/puzzles/puzzle.h
engines/asylum/puzzles/tictactoe.cpp
engines/asylum/puzzles/tictactoe.h
engines/asylum/puzzles/timemachine.cpp
engines/asylum/puzzles/timemachine.h
engines/asylum/puzzles/vcr.cpp
engines/asylum/puzzles/vcr.h
engines/asylum/puzzles/wheel.cpp
engines/asylum/puzzles/wheel.h
engines/asylum/puzzles/writings.cpp
engines/asylum/puzzles/writings.h
diff --git a/engines/asylum/puzzles/boardkeyhidesto.cpp b/engines/asylum/puzzles/boardkeyhidesto.cpp
index fca89ad87d..da44f724c0 100644
--- a/engines/asylum/puzzles/boardkeyhidesto.cpp
+++ b/engines/asylum/puzzles/boardkeyhidesto.cpp
@@ -36,10 +36,6 @@ PuzzleBoardKeyHidesTo::~PuzzleBoardKeyHidesTo() {
//////////////////////////////////////////////////////////////////////////
// Event Handling
//////////////////////////////////////////////////////////////////////////
-bool PuzzleBoardKeyHidesTo::handleEvent(const AsylumEvent &event) {
- error("[PuzzleBoardKeyHidesTo::handleEvent] Not implemented!");
-}
-
bool PuzzleBoardKeyHidesTo::init() {
error("[PuzzleBoardKeyHidesTo::init] Not implemented!");
}
diff --git a/engines/asylum/puzzles/boardkeyhidesto.h b/engines/asylum/puzzles/boardkeyhidesto.h
index f68bb1fece..dbe601ab03 100644
--- a/engines/asylum/puzzles/boardkeyhidesto.h
+++ b/engines/asylum/puzzles/boardkeyhidesto.h
@@ -37,8 +37,6 @@ public:
PuzzleBoardKeyHidesTo(AsylumEngine *engine);
~PuzzleBoardKeyHidesTo();
- bool handleEvent(const AsylumEvent &event);
-
private:
//////////////////////////////////////////////////////////////////////////
// Event Handling
diff --git a/engines/asylum/puzzles/boardsalvation.cpp b/engines/asylum/puzzles/boardsalvation.cpp
index 74062a56bd..0da3284521 100644
--- a/engines/asylum/puzzles/boardsalvation.cpp
+++ b/engines/asylum/puzzles/boardsalvation.cpp
@@ -36,10 +36,6 @@ PuzzleBoardSalvation::~PuzzleBoardSalvation() {
//////////////////////////////////////////////////////////////////////////
// Event Handling
//////////////////////////////////////////////////////////////////////////
-bool PuzzleBoardSalvation::handleEvent(const AsylumEvent &event) {
- error("[PuzzleBoardSalvation::handleEvent] Not implemented!");
-}
-
bool PuzzleBoardSalvation::init() {
error("[PuzzleBoardSalvation::init] Not implemented!");
}
diff --git a/engines/asylum/puzzles/boardsalvation.h b/engines/asylum/puzzles/boardsalvation.h
index df57b91660..266f112176 100644
--- a/engines/asylum/puzzles/boardsalvation.h
+++ b/engines/asylum/puzzles/boardsalvation.h
@@ -37,8 +37,6 @@ public:
PuzzleBoardSalvation(AsylumEngine *engine);
~PuzzleBoardSalvation();
- bool handleEvent(const AsylumEvent &event);
-
private:
//////////////////////////////////////////////////////////////////////////
// Event Handling
diff --git a/engines/asylum/puzzles/boardyouth.cpp b/engines/asylum/puzzles/boardyouth.cpp
index c0fd327fb6..44e82d7868 100644
--- a/engines/asylum/puzzles/boardyouth.cpp
+++ b/engines/asylum/puzzles/boardyouth.cpp
@@ -36,10 +36,6 @@ PuzzleBoardYouth::~PuzzleBoardYouth() {
//////////////////////////////////////////////////////////////////////////
// Event Handling
//////////////////////////////////////////////////////////////////////////
-bool PuzzleBoardYouth::handleEvent(const AsylumEvent &event) {
- error("[PuzzleBoardYouth::handleEvent] Not implemented!");
-}
-
bool PuzzleBoardYouth::init() {
error("[PuzzleBoardYouth::init] Not implemented!");
}
diff --git a/engines/asylum/puzzles/boardyouth.h b/engines/asylum/puzzles/boardyouth.h
index 539728586a..f03bdc0b34 100644
--- a/engines/asylum/puzzles/boardyouth.h
+++ b/engines/asylum/puzzles/boardyouth.h
@@ -37,8 +37,6 @@ public:
PuzzleBoardYouth(AsylumEngine *engine);
~PuzzleBoardYouth();
- bool handleEvent(const AsylumEvent &event);
-
private:
//////////////////////////////////////////////////////////////////////////
// Event Handling
diff --git a/engines/asylum/puzzles/clock.cpp b/engines/asylum/puzzles/clock.cpp
index 2ccee0008d..89325346d5 100644
--- a/engines/asylum/puzzles/clock.cpp
+++ b/engines/asylum/puzzles/clock.cpp
@@ -36,10 +36,6 @@ PuzzleClock::~PuzzleClock() {
//////////////////////////////////////////////////////////////////////////
// Event Handling
//////////////////////////////////////////////////////////////////////////
-bool PuzzleClock::handleEvent(const AsylumEvent &event) {
- error("[PuzzleClock::handleEvent] Not implemented!");
-}
-
bool PuzzleClock::init() {
error("[PuzzleClock::init] Not implemented!");
}
diff --git a/engines/asylum/puzzles/clock.h b/engines/asylum/puzzles/clock.h
index 717986cca5..3aaf31746a 100644
--- a/engines/asylum/puzzles/clock.h
+++ b/engines/asylum/puzzles/clock.h
@@ -37,8 +37,6 @@ public:
PuzzleClock(AsylumEngine *engine);
~PuzzleClock();
- bool handleEvent(const AsylumEvent &event);
-
private:
//////////////////////////////////////////////////////////////////////////
// Event Handling
diff --git a/engines/asylum/puzzles/fisherman.cpp b/engines/asylum/puzzles/fisherman.cpp
index 36fb594776..ff9ff92a3c 100644
--- a/engines/asylum/puzzles/fisherman.cpp
+++ b/engines/asylum/puzzles/fisherman.cpp
@@ -36,10 +36,6 @@ PuzzleFisherman::~PuzzleFisherman() {
//////////////////////////////////////////////////////////////////////////
// Event Handling
//////////////////////////////////////////////////////////////////////////
-bool PuzzleFisherman::handleEvent(const AsylumEvent &event) {
- error("[PuzzleFisherman::handleEvent] Not implemented!");
-}
-
bool PuzzleFisherman::init() {
error("[PuzzleFisherman::init] Not implemented!");
}
diff --git a/engines/asylum/puzzles/fisherman.h b/engines/asylum/puzzles/fisherman.h
index 7b89ce32e1..a753711b15 100644
--- a/engines/asylum/puzzles/fisherman.h
+++ b/engines/asylum/puzzles/fisherman.h
@@ -37,8 +37,6 @@ public:
PuzzleFisherman(AsylumEngine *engine);
~PuzzleFisherman();
- bool handleEvent(const AsylumEvent &event);
-
private:
//////////////////////////////////////////////////////////////////////////
// Event Handling
diff --git a/engines/asylum/puzzles/hivecontrol.cpp b/engines/asylum/puzzles/hivecontrol.cpp
index 94750d8ba8..09a226adfa 100644
--- a/engines/asylum/puzzles/hivecontrol.cpp
+++ b/engines/asylum/puzzles/hivecontrol.cpp
@@ -36,10 +36,6 @@ PuzzleHiveControl::~PuzzleHiveControl() {
//////////////////////////////////////////////////////////////////////////
// Event Handling
//////////////////////////////////////////////////////////////////////////
-bool PuzzleHiveControl::handleEvent(const AsylumEvent &event) {
- error("[PuzzleHiveControl::handleEvent] Not implemented!");
-}
-
bool PuzzleHiveControl::init() {
error("[PuzzleHiveControl::init] Not implemented!");
}
diff --git a/engines/asylum/puzzles/hivecontrol.h b/engines/asylum/puzzles/hivecontrol.h
index e6904ff631..5c6dc74948 100644
--- a/engines/asylum/puzzles/hivecontrol.h
+++ b/engines/asylum/puzzles/hivecontrol.h
@@ -37,8 +37,6 @@ public:
PuzzleHiveControl(AsylumEngine *engine);
~PuzzleHiveControl();
- bool handleEvent(const AsylumEvent &event);
-
private:
//////////////////////////////////////////////////////////////////////////
// Event Handling
diff --git a/engines/asylum/puzzles/hivemachine.cpp b/engines/asylum/puzzles/hivemachine.cpp
index 4cc35e1fd1..d9753d354f 100644
--- a/engines/asylum/puzzles/hivemachine.cpp
+++ b/engines/asylum/puzzles/hivemachine.cpp
@@ -36,10 +36,6 @@ PuzzleHiveMachine::~PuzzleHiveMachine() {
//////////////////////////////////////////////////////////////////////////
// Event Handling
//////////////////////////////////////////////////////////////////////////
-bool PuzzleHiveMachine::handleEvent(const AsylumEvent &event) {
- error("[PuzzleHiveMachine::handleEvent] Not implemented!");
-}
-
bool PuzzleHiveMachine::init() {
error("[PuzzleHiveMachine::init] Not implemented!");
}
diff --git a/engines/asylum/puzzles/hivemachine.h b/engines/asylum/puzzles/hivemachine.h
index bcae852ecc..63242c82bc 100644
--- a/engines/asylum/puzzles/hivemachine.h
+++ b/engines/asylum/puzzles/hivemachine.h
@@ -37,8 +37,6 @@ public:
PuzzleHiveMachine(AsylumEngine *engine);
~PuzzleHiveMachine();
- bool handleEvent(const AsylumEvent &event);
-
private:
//////////////////////////////////////////////////////////////////////////
// Event Handling
diff --git a/engines/asylum/puzzles/lock.cpp b/engines/asylum/puzzles/lock.cpp
index 86b95046eb..94aa803627 100644
--- a/engines/asylum/puzzles/lock.cpp
+++ b/engines/asylum/puzzles/lock.cpp
@@ -36,10 +36,6 @@ PuzzleLock::~PuzzleLock() {
//////////////////////////////////////////////////////////////////////////
// Event Handling
//////////////////////////////////////////////////////////////////////////
-bool PuzzleLock::handleEvent(const AsylumEvent &event) {
- error("[PuzzleLock::handleEvent] Not implemented!");
-}
-
bool PuzzleLock::init() {
error("[PuzzleLock::init] Not implemented!");
}
diff --git a/engines/asylum/puzzles/lock.h b/engines/asylum/puzzles/lock.h
index 23529b5cb3..79ff52f94f 100644
--- a/engines/asylum/puzzles/lock.h
+++ b/engines/asylum/puzzles/lock.h
@@ -37,8 +37,6 @@ public:
PuzzleLock(AsylumEngine *engine);
~PuzzleLock();
- bool handleEvent(const AsylumEvent &event);
-
private:
//////////////////////////////////////////////////////////////////////////
// Event Handling
diff --git a/engines/asylum/puzzles/morguedoor.cpp b/engines/asylum/puzzles/morguedoor.cpp
index 3395e5a050..201a0bc3a7 100644
--- a/engines/asylum/puzzles/morguedoor.cpp
+++ b/engines/asylum/puzzles/morguedoor.cpp
@@ -36,10 +36,6 @@ PuzzleMorgueDoor::~PuzzleMorgueDoor() {
//////////////////////////////////////////////////////////////////////////
// Event Handling
//////////////////////////////////////////////////////////////////////////
-bool PuzzleMorgueDoor::handleEvent(const AsylumEvent &event) {
- error("[PuzzleMorgueDoor::handleEvent] Not implemented!");
-}
-
bool PuzzleMorgueDoor::init() {
error("[PuzzleMorgueDoor::init] Not implemented!");
}
diff --git a/engines/asylum/puzzles/morguedoor.h b/engines/asylum/puzzles/morguedoor.h
index 04b8f389a5..767bf95b8a 100644
--- a/engines/asylum/puzzles/morguedoor.h
+++ b/engines/asylum/puzzles/morguedoor.h
@@ -37,8 +37,6 @@ public:
PuzzleMorgueDoor(AsylumEngine *engine);
~PuzzleMorgueDoor();
- bool handleEvent(const AsylumEvent &event);
-
private:
//////////////////////////////////////////////////////////////////////////
// Event Handling
diff --git a/engines/asylum/puzzles/pipes.cpp b/engines/asylum/puzzles/pipes.cpp
index 23350b40db..a3ccccc53c 100644
--- a/engines/asylum/puzzles/pipes.cpp
+++ b/engines/asylum/puzzles/pipes.cpp
@@ -36,10 +36,6 @@ PuzzlePipes::~PuzzlePipes() {
//////////////////////////////////////////////////////////////////////////
// Event Handling
//////////////////////////////////////////////////////////////////////////
-bool PuzzlePipes::handleEvent(const AsylumEvent &event) {
- error("[PuzzlePipes::handleEvent] Not implemented!");
-}
-
bool PuzzlePipes::init() {
error("[PuzzlePipes::init] Not implemented!");
}
diff --git a/engines/asylum/puzzles/pipes.h b/engines/asylum/puzzles/pipes.h
index 0341e01a24..7d5d16ad88 100644
--- a/engines/asylum/puzzles/pipes.h
+++ b/engines/asylum/puzzles/pipes.h
@@ -37,8 +37,6 @@ public:
PuzzlePipes(AsylumEngine *engine);
~PuzzlePipes();
- bool handleEvent(const AsylumEvent &event);
-
private:
//////////////////////////////////////////////////////////////////////////
// Event Handling
diff --git a/engines/asylum/puzzles/puzzle.cpp b/engines/asylum/puzzles/puzzle.cpp
index 6bc94d8417..a0f47bbc0a 100644
--- a/engines/asylum/puzzles/puzzle.cpp
+++ b/engines/asylum/puzzles/puzzle.cpp
@@ -48,6 +48,38 @@ Puzzle::~Puzzle() {
//////////////////////////////////////////////////////////////////////////
// Event Handling
//////////////////////////////////////////////////////////////////////////
+bool Puzzle::handleEvent(const AsylumEvent &evt) {
+ switch ((uint32)evt.type) {
+ default:
+ break;
+
+ case EVENT_ASYLUM_INIT:
+ return init();
+ break;
+
+ case EVENT_ASYLUM_ACTIVATE:
+ return activate();
+ break;
+
+ case EVENT_ASYLUM_UPDATE:
+ return update();
+ break;
+
+ case Common::EVENT_KEYDOWN:
+ return key(evt);
+ break;
+
+ case Common::EVENT_LBUTTONDOWN:
+ case Common::EVENT_LBUTTONUP:
+ case Common::EVENT_RBUTTONDOWN:
+ case Common::EVENT_RBUTTONUP:
+ return mouse(evt);
+ break;
+ }
+
+ return false;
+}
+
bool Puzzle::key(const AsylumEvent &evt) {
switch (evt.kbd.keycode) {
default:
diff --git a/engines/asylum/puzzles/puzzle.h b/engines/asylum/puzzles/puzzle.h
index d8875cce3b..40217b2836 100644
--- a/engines/asylum/puzzles/puzzle.h
+++ b/engines/asylum/puzzles/puzzle.h
@@ -48,6 +48,8 @@ public:
virtual void reset() {}
+ bool handleEvent(const AsylumEvent &evt);
+
protected:
AsylumEngine *_vm;
@@ -56,6 +58,7 @@ protected:
//////////////////////////////////////////////////////////////////////////
virtual bool init() = 0;
virtual bool update() = 0;
+ virtual bool activate() { return true; }
virtual bool key(const AsylumEvent &evt);
virtual bool mouse(const AsylumEvent &evt) = 0;
diff --git a/engines/asylum/puzzles/tictactoe.cpp b/engines/asylum/puzzles/tictactoe.cpp
index ddf68ac277..28ce2a6b88 100644
--- a/engines/asylum/puzzles/tictactoe.cpp
+++ b/engines/asylum/puzzles/tictactoe.cpp
@@ -36,10 +36,6 @@ PuzzleTicTacToe::~PuzzleTicTacToe() {
//////////////////////////////////////////////////////////////////////////
// Event Handling
//////////////////////////////////////////////////////////////////////////
-bool PuzzleTicTacToe::handleEvent(const AsylumEvent &event) {
- error("[PuzzleTicTacToe::handleEvent] Not implemented!");
-}
-
bool PuzzleTicTacToe::init() {
error("[PuzzleTicTacToe::init] Not implemented!");
}
diff --git a/engines/asylum/puzzles/tictactoe.h b/engines/asylum/puzzles/tictactoe.h
index 050f22ed9c..e4b5147cf5 100644
--- a/engines/asylum/puzzles/tictactoe.h
+++ b/engines/asylum/puzzles/tictactoe.h
@@ -37,8 +37,6 @@ public:
PuzzleTicTacToe(AsylumEngine *engine);
~PuzzleTicTacToe();
- bool handleEvent(const AsylumEvent &event);
-
private:
//////////////////////////////////////////////////////////////////////////
// Event Handling
diff --git a/engines/asylum/puzzles/timemachine.cpp b/engines/asylum/puzzles/timemachine.cpp
index ae1a6bc325..2bb7b6dc33 100644
--- a/engines/asylum/puzzles/timemachine.cpp
+++ b/engines/asylum/puzzles/timemachine.cpp
@@ -36,10 +36,6 @@ PuzzleTimeMachine::~PuzzleTimeMachine() {
//////////////////////////////////////////////////////////////////////////
// Event Handling
//////////////////////////////////////////////////////////////////////////
-bool PuzzleTimeMachine::handleEvent(const AsylumEvent &event) {
- error("[PuzzleTimeMachine::handleEvent] Not implemented!");
-}
-
bool PuzzleTimeMachine::init() {
error("[PuzzleTimeMachine::init] Not implemented!");
}
diff --git a/engines/asylum/puzzles/timemachine.h b/engines/asylum/puzzles/timemachine.h
index 57fe4090da..54762da5f2 100644
--- a/engines/asylum/puzzles/timemachine.h
+++ b/engines/asylum/puzzles/timemachine.h
@@ -37,8 +37,6 @@ public:
PuzzleTimeMachine(AsylumEngine *engine);
~PuzzleTimeMachine();
- bool handleEvent(const AsylumEvent &event);
-
private:
//////////////////////////////////////////////////////////////////////////
// Event Handling
diff --git a/engines/asylum/puzzles/vcr.cpp b/engines/asylum/puzzles/vcr.cpp
index c0cadc284d..758ab02714 100644
--- a/engines/asylum/puzzles/vcr.cpp
+++ b/engines/asylum/puzzles/vcr.cpp
@@ -57,10 +57,6 @@ PuzzleVCR::~PuzzleVCR() {
//////////////////////////////////////////////////////////////////////////
// Event Handling
//////////////////////////////////////////////////////////////////////////
-bool PuzzleVCR::handleEvent(const AsylumEvent &event) {
- error("[PuzzleVCR::handleEvent] Not implemented!");
-}
-
bool PuzzleVCR::init() {
error("[PuzzleVCR::init] Not implemented!");
}
diff --git a/engines/asylum/puzzles/vcr.h b/engines/asylum/puzzles/vcr.h
index 50151142b8..73da875f87 100644
--- a/engines/asylum/puzzles/vcr.h
+++ b/engines/asylum/puzzles/vcr.h
@@ -60,8 +60,6 @@ public:
PuzzleVCR(AsylumEngine *engine);
~PuzzleVCR();
- bool handleEvent(const AsylumEvent &event);
-
private:
enum Jack {
kBlack = 0,
diff --git a/engines/asylum/puzzles/wheel.cpp b/engines/asylum/puzzles/wheel.cpp
index 3e4c3b9295..f74c1bec1d 100644
--- a/engines/asylum/puzzles/wheel.cpp
+++ b/engines/asylum/puzzles/wheel.cpp
@@ -36,10 +36,6 @@ PuzzleWheel::~PuzzleWheel() {
//////////////////////////////////////////////////////////////////////////
// Event Handling
//////////////////////////////////////////////////////////////////////////
-bool PuzzleWheel::handleEvent(const AsylumEvent &event) {
- error("[PuzzleWheel::handleEvent] Not implemented!");
-}
-
bool PuzzleWheel::init() {
error("[PuzzleWheel::init] Not implemented!");
}
diff --git a/engines/asylum/puzzles/wheel.h b/engines/asylum/puzzles/wheel.h
index f4daf408b0..d749b9d70a 100644
--- a/engines/asylum/puzzles/wheel.h
+++ b/engines/asylum/puzzles/wheel.h
@@ -37,8 +37,6 @@ public:
PuzzleWheel(AsylumEngine *engine);
~PuzzleWheel();
- bool handleEvent(const AsylumEvent &event);
-
private:
//////////////////////////////////////////////////////////////////////////
// Event Handling
diff --git a/engines/asylum/puzzles/writings.cpp b/engines/asylum/puzzles/writings.cpp
index db08a67c24..14027ab9bc 100644
--- a/engines/asylum/puzzles/writings.cpp
+++ b/engines/asylum/puzzles/writings.cpp
@@ -36,10 +36,6 @@ PuzzleWritings::~PuzzleWritings() {
//////////////////////////////////////////////////////////////////////////
// Event Handling
//////////////////////////////////////////////////////////////////////////
-bool PuzzleWritings::handleEvent(const AsylumEvent &event) {
- error("[PuzzleWritings::handleEvent] Not implemented!");
-}
-
bool PuzzleWritings::init() {
error("[PuzzleWritings::init] Not implemented!");
}
diff --git a/engines/asylum/puzzles/writings.h b/engines/asylum/puzzles/writings.h
index c5e72007c1..6058c03734 100644
--- a/engines/asylum/puzzles/writings.h
+++ b/engines/asylum/puzzles/writings.h
@@ -37,8 +37,6 @@ public:
PuzzleWritings(AsylumEngine *engine);
~PuzzleWritings();
- bool handleEvent(const AsylumEvent &event);
-
private:
//////////////////////////////////////////////////////////////////////////
// Event Handling
Commit: abfbc4de6ef8c2060befe2410d7a07bba1bdaab5
https://github.com/scummvm/scummvm/commit/abfbc4de6ef8c2060befe2410d7a07bba1bdaab5
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:42+02:00
Commit Message:
ASYLUM: Properly initialize GraphicQueueItem type
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@705 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/system/screen.h
diff --git a/engines/asylum/system/screen.h b/engines/asylum/system/screen.h
index 6a6204aee2..f8b1c64b7c 100644
--- a/engines/asylum/system/screen.h
+++ b/engines/asylum/system/screen.h
@@ -60,6 +60,7 @@ typedef struct GraphicQueueItem {
GraphicQueueItem() {
priority = 0;
+ type = kGraphicItemNormal;
resourceId = kResourceNone;
frameIndex = 0;
resourceIdDestination = kResourceNone;
Commit: 8fea2701720e5d8772abe8a1dd7b21badacd9be4
https://github.com/scummvm/scummvm/commit/8fea2701720e5d8772abe8a1dd7b21badacd9be4
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:42+02:00
Commit Message:
ASYLUM: Convert VCR puzzle to new event handling
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@706 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/puzzles/vcr.cpp
engines/asylum/puzzles/vcr.h
diff --git a/engines/asylum/puzzles/vcr.cpp b/engines/asylum/puzzles/vcr.cpp
index 758ab02714..7b5749dc03 100644
--- a/engines/asylum/puzzles/vcr.cpp
+++ b/engines/asylum/puzzles/vcr.cpp
@@ -47,7 +47,7 @@ PuzzleVCR::PuzzleVCR(AsylumEngine *engine): Puzzle(engine) {
memset(&_holesState, 0, sizeof(_holesState));
memset(&_buttonsState, 0, sizeof(_buttonsState));
- _tvScreenAnimIdx = 0;
+ _tvScreenFrameIndex = 0;
_isAccomplished = false;
}
@@ -58,201 +58,395 @@ PuzzleVCR::~PuzzleVCR() {
// Event Handling
//////////////////////////////////////////////////////////////////////////
bool PuzzleVCR::init() {
- error("[PuzzleVCR::init] Not implemented!");
+ // Load the graphics palette
+ getScreen()->setPalette(getWorld()->graphicResourceIds[29]);
+ getScreen()->setGammaLevel(getWorld()->graphicResourceIds[29], 0);
+
+ if (_jacksState[kBlack] == kOnHand || _jacksState[kRed] == kOnHand || _jacksState[kYellow] == kOnHand) {
+ getCursor()->hide();
+ getSharedData()->setFlag(kFlag1, true);
+ } else {
+ getCursor()->set(getWorld()->graphicResourceIds[28]);
+ }
+
+ return true;
}
bool PuzzleVCR::update() {
- error("[PuzzleVCR::update] Not implemented!");
+ uint32 ticks = _vm->getTick();
+
+ if (!getSharedData()->getFlag(kFlagRedraw)) {
+ updateScreen();
+
+ getSharedData()->setFlag(kFlagRedraw, true);
+ }
+
+ if (ticks > getSharedData()->nextScreenUpdate) {
+ if (getSharedData()->getFlag(kFlagRedraw)) {
+ getScreen()->copyBackBufferToScreen();
+
+ getSharedData()->setData(39, getSharedData()->getData(39) ^ 1);
+
+ getSharedData()->setFlag(kFlagRedraw, false);
+ getSharedData()->nextScreenUpdate = ticks + 55;
+ }
+ }
+
+ return true;
}
bool PuzzleVCR::key(const AsylumEvent &evt) {
- error("[PuzzleVCR::key] Not implemented!");
+ switch (evt.kbd.keycode) {
+ default:
+ getSound()->stop(getWorld()->graphicResourceIds[47]);
+ getScreen()->clearGraphicsInQueue();
+ getScreen()->clear();
+
+ _vm->switchEventHandler(getScene());
+ break;
+
+ case Common::KEYCODE_TAB:
+ getScreen()->takeScreenshot();
+ break;
+ }
+
+ return true;
}
bool PuzzleVCR::mouse(const AsylumEvent &evt) {
- error("[PuzzleVCR::mouse] Not implemented!");
+ switch (evt.type) {
+ case Common::EVENT_LBUTTONDOWN:
+ case Common::EVENT_RBUTTONDOWN:
+ mouseDown(evt);
+ break;
+
+ case Common::EVENT_LBUTTONUP:
+ mouseUp();
+ break;
+ }
+
+ return true;
}
-//void PuzzleVCR::open() {
-// getSound()->stopAll();
-//
-// // Load the graphics palette
-// getScreen()->setPalette(getWorld()->graphicResourceIds[29]);
-//
-// // show blow up puzzle BG
-// getScreen()->draw(getWorld()->graphicResourceIds[0], 0, 0, 0, 0);
-//
-// // Set mouse cursor
-// getCursor()->set(getWorld()->graphicResourceIds[28]);
-// getCursor()->show();
-//}
-
-//bool PuzzleVCR::handleEvent(const AsylumEvent &ev) {
-// switch (ev.type) {
-// case Common::EVENT_MOUSEMOVE:
-// //getCursor()->move(ev.mouse.x, ev.mouse.y);
-// break;
-// case Common::EVENT_LBUTTONUP:
-// _leftClickUp = true;
-// break;
-// case Common::EVENT_LBUTTONDOWN:
-// _leftClickDown = true;
-// break;
-// case Common::EVENT_RBUTTONDOWN:
-// _rightClickDown = true;
-// break;
-// default:
-// break;
-// }
-//
-// if (_leftClickUp || _leftClickDown)
-// update();
-//
-// return true;
-//}
-
-
-int PuzzleVCR::inPolyRegion(int x, int y, int polyIdx) const {
- return x >= BlowUpPuzzleVCRPolies[polyIdx].left && x <= BlowUpPuzzleVCRPolies[polyIdx].right &&
- y >= BlowUpPuzzleVCRPolies[polyIdx].top && y <= BlowUpPuzzleVCRPolies[polyIdx].bottom;
+void PuzzleVCR::mouseDown(const AsylumEvent &evt) {
+ if (_isAccomplished)
+ return;
+
+ // Handle right click
+ if (evt.type == Common::EVENT_RBUTTONDOWN) {
+ getScreen()->clearGraphicsInQueue();
+ getScreen()->clear();
+
+ getSound()->stop(getWorld()->graphicResourceIds[47]);
+
+ _vm->switchEventHandler(getScene());
+ return;
+ }
+
+ Common::Point mousePos = getCursor()->position();
+
+ //////////////////////////////////////////////////////////////////////////
+ // Plug-in jacks
+ //////////////////////////////////////////////////////////////////////////
+ JackState state = kPluggedOnRed;
+ if (_jacksState[kBlack] != kOnHand) {
+ if (_jacksState[kRed] == kOnHand)
+ state = kPluggedOnYellow;
+ else
+ state = (JackState)(((_jacksState[kYellow] != kOnHand) - 1) & 3);
+ }
+
+ if (inPolygon(mousePos.x, mousePos.y, kRedHole)) {
+ setJackOnHole(kBlack, state, kPluggedOnRed);
+ } else if (inPolygon(mousePos.x, mousePos.y, kYellowHole)) {
+ setJackOnHole(kRed, state, kPluggedOnYellow);
+ } else if (inPolygon(mousePos.x, mousePos.y, kBlackHole)) {
+ setJackOnHole(kYellow, state, kPluggedOnBlack);
+
+ if (_holesState[kYellow] != kPluggedOnYellow && _buttonsState[kPowerButton] == kON) {
+ _buttonsState[kStopButton] = kOFF;
+ _buttonsState[kPlayButton] = kOFF;
+ _buttonsState[kRewindButton] = kOFF;
+ _buttonsState[kPowerButton] = kOFF;
+ }
+ }
+
+ //////////////////////////////////////////////////////////////////////////
+ // Put jacks on table
+ //////////////////////////////////////////////////////////////////////////
+ Color jack = getJackOnHand();
+ if (jack != kNone) {
+ if (mousePos.x >= (int32)puzzleVCRPolygons[kBlackJack].left && mousePos.x <= (int32)puzzleVCRPolygons[kYellowJack].right
+ && mousePos.y >= (int32)puzzleVCRPolygons[kBlackJack].top && mousePos.y <= (int32)puzzleVCRPolygons[kYellowJack].bottom) {
+
+ _jacksState[jack] = kOnTable;
+ getSound()->playSound(getWorld()->graphicResourceIds[50]);
+ getCursor()->show();
+ getSharedData()->setFlag(kFlag1, false);
+ }
+
+ return;
+ }
+
+ //////////////////////////////////////////////////////////////////////////
+ // Get Jacks from Table
+ //////////////////////////////////////////////////////////////////////////
+ getCursor()->show();
+ getSharedData()->setFlag(kFlag1, false);
+
+
+ if (inPolygon(mousePos.x, mousePos.y, kBlackJack))
+ pickJack(kBlack);
+ else if (inPolygon(mousePos.x, mousePos.y, kRedJack))
+ pickJack(kRed);
+ else if (inPolygon(mousePos.x, mousePos.y, kYellowJack))
+ pickJack(kYellow);
+
+ //////////////////////////////////////////////////////////////////////////
+ // VCR button regions
+ //////////////////////////////////////////////////////////////////////////
+ if (inPolygon(mousePos.x, mousePos.y, kRewindButton)) {
+ getSound()->playSound(getWorld()->graphicResourceIds[39]);
+
+ if (!_buttonsState[kRewindButton])
+ _buttonsState[kRewindButton] = kDownON;
+ else if (_buttonsState[kRewindButton] == kON)
+ _buttonsState[kRewindButton] = kDownOFF;
+
+ } else if (inPolygon(mousePos.x, mousePos.y, kPlayButton)) {
+ getSound()->playSound(getWorld()->graphicResourceIds[39]);
+
+ if (!_buttonsState[kPlayButton])
+ _buttonsState[kPlayButton] = kDownON;
+ else if (_buttonsState[kPlayButton] == kON)
+ _buttonsState[kPlayButton] = kDownOFF;
+
+ } else if (inPolygon(mousePos.x, mousePos.y, kStopButton)) {
+ getSound()->playSound(getWorld()->graphicResourceIds[39]);
+
+ if (!_buttonsState[kStopButton])
+ _buttonsState[kStopButton] = kDownON;
+ else if (_buttonsState[kStopButton] == kON)
+ _buttonsState[kStopButton] = kDownOFF;
+
+ } else if (inPolygon(mousePos.x, mousePos.y, kPowerButton)) {
+ getSound()->playSound(getWorld()->graphicResourceIds[39]);
+
+ if (!_buttonsState[kPowerButton] && _holesState[kYellow] == kPluggedOnRed) {
+ _buttonsState[kPowerButton] = kDownON;
+ } else {
+ _buttonsState[kPowerButton] = kDownOFF;
+ }
+ }
}
-//bool PuzzleVCR::update() {
-// getScreen()->clearGraphicsInQueue();
-//
-// if (_rightClickDown) { // quits BlowUp Puzzle
-// _rightClickDown = false;
-// close();
-// getSound()->stopAll();
-// }
-//
-// if (_leftClickDown) {
-// _leftClickDown = false;
-// handleMouseDown();
-// }
-//
-// if (_leftClickUp) {
-// _leftClickUp = false;
-// handleMouseUp();
-// }
-//
-// updateCursorInPolyRegion();
-//
-// updateBlackJack();
-// updateRedJack();
-// updateYellowJack();
-//
-// updatePowerButton();
-// updateRewindButton();
-// updatePlayButton();
-// updateStopButton();
-//
-// if (_buttonsState[kPower] == kON) {
-// getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[22], _tvScreenAnimIdx, Common::Point(0, 37), 0, 0, 1);
-// getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[23], _tvScreenAnimIdx++, Common::Point(238, 22), 0, 0, 1);
-// _tvScreenAnimIdx %= 6;
-// }
-//
-// if (_isAccomplished) {
-// getScreen()->drawGraphicsInQueue();
-//
-// int16 barSize = 0;
-// do {
-// getScreen()->drawWideScreenBars(barSize);
-// barSize += 4;
-// } while (barSize < 84);
-//
-// // TODO: fade palette to gray
-//
-// getVideo()->playVideo(2);
-//
-// _isAccomplished = false;
-// close();
-// } else {
-// getScreen()->drawGraphicsInQueue();
-// }
-//
-// return true;
-//}
-
-GraphicQueueItem PuzzleVCR::getGraphicJackItem(int32 index) {
- GraphicQueueItem jackItemOnHand;
-
- int jackY = getCursor()->position().y;
- if (getCursor()->position().y < 356) {
- jackY = 356;
+void PuzzleVCR::mouseUp() {
+ if (_isAccomplished)
+ return;
+
+ //////////////////////////////////////////////////////////////////////////
+ // Power
+ //////////////////////////////////////////////////////////////////////////
+ if (_buttonsState[kPowerButton] == kDownON) {
+ if (!getSound()->isPlaying(getWorld()->graphicResourceIds[47]))
+ getSound()->playSound(getWorld()->graphicResourceIds[47], true);
+
+ _buttonsState[kPowerButton] = kON;
+ _buttonsState[kStopButton] = kON;
+ _buttonsState[kPlayButton] = kON;
+ _buttonsState[kRewindButton] = kON;
+ } else if (_buttonsState[kPowerButton] == kDownOFF) {
+ _buttonsState[kPowerButton] = kOFF;
+ _buttonsState[kStopButton] = kOFF;
+ _buttonsState[kPlayButton] = kOFF;
+ _buttonsState[kRewindButton] = kOFF;
+
+ getSound()->stop(getWorld()->graphicResourceIds[47]);
+ }
+
+ //////////////////////////////////////////////////////////////////////////
+ // Rewind
+ //////////////////////////////////////////////////////////////////////////
+ if (_buttonsState[kRewindButton] == kDownOFF) {
+ getSound()->playSound(getWorld()->graphicResourceIds[46]);
+ _buttonsState[kRewindButton] = kON;
+ } else if (_buttonsState[kRewindButton] == kDownON) {
+ _buttonsState[kRewindButton] = kOFF;
}
- jackItemOnHand.resourceId = getWorld()->graphicResourceIds[index];
- jackItemOnHand.frameIndex = 0;
- jackItemOnHand.source = Common::Point(getCursor()->position().x - 114, jackY - 14);
- jackItemOnHand.priority = 1;
+ //////////////////////////////////////////////////////////////////////////
+ // Play
+ //////////////////////////////////////////////////////////////////////////
+ if (_buttonsState[kPlayButton] == kDownOFF) {
+ _buttonsState[kPlayButton] = kON;
- return jackItemOnHand;
+ if (_holesState[kBlack] == kPluggedOnYellow
+ && _holesState[kRed] == kPluggedOnBlack
+ && _holesState[kYellow] == kPluggedOnRed) {
+ getCursor()->hide();
+ _vm->setGameFlag(kGameFlagSolveVCRBlowUpPuzzle);
+ _isAccomplished = true;
+ }
+ } else if (_buttonsState[kPlayButton] == kDownON) {
+ _buttonsState[kPlayButton] = kOFF;
+ }
+
+ //////////////////////////////////////////////////////////////////////////
+ // Stop
+ //////////////////////////////////////////////////////////////////////////
+ if (_buttonsState[kStopButton] == kDownOFF) {
+ _buttonsState[kStopButton] = kON;
+ } else if (_buttonsState[kStopButton] == kDownON) {
+ _buttonsState[kStopButton] = kOFF;
+ }
}
-GraphicQueueItem PuzzleVCR::getGraphicShadowItem() {
- GraphicQueueItem shadowItem;
+//////////////////////////////////////////////////////////////////////////
+// Drawing
+//////////////////////////////////////////////////////////////////////////
+void PuzzleVCR::updateScreen() {
+ Common::Point mousePos = getCursor()->position();
+
+ if (mousePos.x > 465)
+ mousePos.x = 465;
+
+ updateCursor();
+
+ // Draw background
+ getScreen()->clearGraphicsInQueue();
+ getScreen()->draw(getWorld()->graphicResourceIds[0], 0, 0, 0, 0, false);
+
+ updateBlackJack();
+ updateRedJack();
+ updateYellowJack();
- int shadowY = (getCursor()->position().y - 356) / 4;
- if (getCursor()->position().y < 356) {
- shadowY = 0;
+ updatePowerButton();
+ updateRewindButton();
+ updatePlayButton();
+ updateStopButton();
+
+ if (_buttonsState[kPowerButton] == kON) {
+ getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[22], _tvScreenFrameIndex, Common::Point(0, 37), 0, 0, 1);
+ getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[23], _tvScreenFrameIndex++, Common::Point(238, 22), 0, 0, 1);
+
+ _tvScreenFrameIndex %= GraphicResource::getFrameCount(_vm, getWorld()->graphicResourceIds[22]);
}
- shadowItem.resourceId = getWorld()->graphicResourceIds[30];
- shadowItem.frameIndex = 0;
- shadowItem.source = Common::Point(getCursor()->position().x - shadowY, 450);
- shadowItem.priority = 2;
- return shadowItem;
+ if (_isAccomplished) {
+ getCursor()->show();
+ getScreen()->draw(getWorld()->graphicResourceIds[0], 0, 0, 0, 0, false);
+ getScreen()->drawGraphicsInQueue();
+
+ for (uint32 barSize = 0; barSize < 84; barSize += 4)
+ getScreen()->drawWideScreenBars(barSize);
+
+ // Palette fade
+ getScreen()->paletteFade(0, 25, 10);
+ getScreen()->clear();
+
+ getScene()->updateScreen();
+ getScreen()->drawWideScreenBars(82);
+ getSound()->stop(getWorld()->graphicResourceIds[47]);
+ getSound()->playMusic(kResourceNone, 0);
+ getScreen()->clear();
+
+ getVideo()->play(2, getScene());
+
+ if (getWorld()->musicCurrentResourceIndex != kMusicStopped)
+ getSound()->playMusic(MAKE_RESOURCE(kResourcePackMusic, getWorld()->musicCurrentResourceIndex));
+
+ getScreen()->paletteFade(0, 2, 1);
+ getScreen()->clear();
+
+ // setupPalette();
+ getScreen()->setupPalette(0, 0, 0);
+
+ warning("[PuzzleVCR::updateScreen] Missing palette changes");
+ // TODO more stuff needed here (palette change, scene screen update, etc.)
+ } else {
+ getScreen()->drawGraphicsInQueue();
+ }
}
-void PuzzleVCR::updateJack(Jack jack, const VCRDrawInfo &onTable, const VCRDrawInfo &pluggedOnRed, const VCRDrawInfo &pluggedOnYellow, const VCRDrawInfo &pluggedOnBlack, int32 resourceOnHandIndex) {
+void PuzzleVCR::updateCursor() {
+ Common::Point mousePos = getCursor()->position();
+
+ Color jack = getJackOnHand();
+
+ if (jack == kNone) {
+ if (inPolygon(mousePos.x, mousePos.y, kRewindButton)
+ || inPolygon(mousePos.x, mousePos.y, kStopButton)
+ || inPolygon(mousePos.x, mousePos.y, kPlayButton)
+ || inPolygon(mousePos.x, mousePos.y, kPowerButton)
+ || inPolygon(mousePos.x, mousePos.y, kBlackJack)
+ || inPolygon(mousePos.x, mousePos.y, kRedJack)
+ || inPolygon(mousePos.x, mousePos.y, kYellowJack)) {
+ if (getCursor()->animation != kCursorAnimationMirror)
+ getCursor()->set(getWorld()->graphicResourceIds[28]);
+ } else if ((inPolygon(mousePos.x, mousePos.y, kRedHole) && _holesState[kBlack])
+ || (inPolygon(mousePos.x, mousePos.y, kYellowHole) && _holesState[kRed])
+ || (inPolygon(mousePos.x, mousePos.y, kBlackHole) && _holesState[kYellow])) {
+ if (getCursor()->animation != kCursorAnimationMirror)
+ getCursor()->set(getWorld()->graphicResourceIds[28]);
+ } else {
+ if (getCursor()->animation)
+ getCursor()->set(getWorld()->graphicResourceIds[28], kCursorAnimationNone);
+ }
+ } else {
+ getCursor()->hide();
+ }
+}
+
+//////////////////////////////////////////////////////////////////////////
+// Update Jack
+//////////////////////////////////////////////////////////////////////////
+void PuzzleVCR::updateJack(Color jack, const VCRDrawInfo &onTable, const VCRDrawInfo &pluggedOnRed, const VCRDrawInfo &pluggedOnYellow, const VCRDrawInfo &pluggedOnBlack, int32 resourceOnHandIndex) {
GraphicQueueItem item;
+ Common::Point mousePos = getCursor()->position();
switch (_jacksState[jack]) {
+ default:
+ return;
+
case kOnTable:
item.resourceId = getWorld()->graphicResourceIds[onTable.resourceId];
- item.frameIndex = 0;
item.source = onTable.point;
item.priority = 3;
break;
case kPluggedOnRed:
item.resourceId = getWorld()->graphicResourceIds[pluggedOnRed.resourceId];
- item.frameIndex = 0;
item.source = Common::Point(329, 407);
item.priority = 3;
break;
case kPluggedOnYellow:
item.resourceId = getWorld()->graphicResourceIds[pluggedOnYellow.resourceId];
- item.frameIndex = 0;
item.source = Common::Point(402, 413);
item.priority = 3;
break;
case kPluggedOnBlack:
item.resourceId = getWorld()->graphicResourceIds[pluggedOnBlack.resourceId];
- item.frameIndex = 0;
item.source = Common::Point(477, 418);
item.priority = 3;
break;
- case kOnHand: {
- GraphicQueueItem jackItemOnHand = getGraphicJackItem(resourceOnHandIndex);
- getScreen()->addGraphicToQueue(jackItemOnHand);
-
- item = getGraphicShadowItem();
- }
- break;
+ case kOnHand:
+ // Jack
+ item.resourceId = getWorld()->graphicResourceIds[resourceOnHandIndex];
+ item.source = Common::Point(mousePos.x - 114, mousePos.y < 356 ? 342 : mousePos.y - 14);
+ item.priority = 1;
+ getScreen()->addGraphicToQueue(item);
- default:
- item.resourceId = kResourceNone;
+ // Shadow
+ item.resourceId = getWorld()->graphicResourceIds[30];
+ item.source = Common::Point(mousePos.x - (mousePos.y < 356 ? 0 : (mousePos.y - 356) / 4), 450);
+ item.priority = 2;
break;
}
- if (item.resourceId != 0)
- getScreen()->addGraphicToQueue(item);
+ getScreen()->addGraphicToQueue(item);
}
void PuzzleVCR::updateBlackJack() {
@@ -306,50 +500,31 @@ void PuzzleVCR::updateYellowJack() {
updateJack(kYellow, onTable, pluggedOnRed, pluggedOnYellow, pluggedOnBlack, 26);
}
-
-// common function to set and unset the jack on holes for each type of jack
-int PuzzleVCR::setJackOnHole(int jackType, JackState plugged) {
- if (!_holesState[plugged-1]) {
- if (_jacksState[jackType-1] == kOnHand) {
- _jacksState[jackType-1] = plugged;
- _holesState[plugged-1] = jackType; // set jack on red
- getSound()->playSound(getWorld()->graphicResourceIds[44]);
- }
- } else if (jackType == 0) {
- jackType = _holesState[plugged-1];
- _jacksState[jackType-1] = kOnHand;
- _holesState[plugged-1] = 0;
- getSound()->playSound(getWorld()->graphicResourceIds[43]);
- return 0;
- }
- return 1;
-}
-
-void PuzzleVCR::updateButton(Button button, const VCRDrawInfo &btON, const VCRDrawInfo &btDown) {
+//////////////////////////////////////////////////////////////////////////
+// Update Button
+//////////////////////////////////////////////////////////////////////////
+void PuzzleVCR::updateButton(VCRRegions button, const VCRDrawInfo &btON, const VCRDrawInfo &btDown) {
GraphicQueueItem item;
switch (_buttonsState[button]) {
+ default:
+ return;
+
case kON:
item.resourceId = getWorld()->graphicResourceIds[btON.resourceId];
- item.frameIndex = 0;
item.source = btON.point;
item.priority = 3;
break;
+
case kDownON:
case kDownOFF:
item.resourceId = getWorld()->graphicResourceIds[btDown.resourceId];
- item.frameIndex = 0;
item.source = btDown.point;
item.priority = 3;
break;
- default:
- item.resourceId = kResourceNone;
- break;
}
- if (item.resourceId != 0)
- getScreen()->addGraphicToQueue(item);
-
+ getScreen()->addGraphicToQueue(item);
}
void PuzzleVCR::updatePowerButton() {
@@ -361,7 +536,7 @@ void PuzzleVCR::updatePowerButton() {
btDown.resourceId = 21;
btDown.point = Common::Point(506, 343);
- updateButton(kPower, btON, btDown);
+ updateButton(kPowerButton, btON, btDown);
}
void PuzzleVCR::updateRewindButton() {
@@ -373,7 +548,7 @@ void PuzzleVCR::updateRewindButton() {
btDown.resourceId = 18;
btDown.point = Common::Point(245, 344);
- updateButton(kRewind, btON, btDown);
+ updateButton(kRewindButton, btON, btDown);
}
void PuzzleVCR::updatePlayButton() {
@@ -385,7 +560,7 @@ void PuzzleVCR::updatePlayButton() {
btDown.resourceId = 20;
btDown.point = Common::Point(391, 355);
- updateButton(kPlay, btON, btDown);
+ updateButton(kPlayButton, btON, btDown);
}
void PuzzleVCR::updateStopButton() {
@@ -397,197 +572,71 @@ void PuzzleVCR::updateStopButton() {
btDown.resourceId = 19;
btDown.point = Common::Point(326, 350);
- updateButton(kStop, btON, btDown);
+ updateButton(kStopButton, btON, btDown);
}
-
-void PuzzleVCR::updateCursorInPolyRegion() {
- int showCursor = 0;
-
- if (_jacksState[kBlack] == kOnHand) {
- showCursor = kBlack + 1;
- } else if (_jacksState[kRed] == kOnHand) {
- showCursor = kRed + 1;
- } else {
- showCursor = ((_jacksState[kYellow] != kOnHand) - 1) & 3;
- }
-
- if (!showCursor) {
- if (inPolyRegion(getCursor()->position().x, getCursor()->position().y, kRewindButton)
- || inPolyRegion(getCursor()->position().x, getCursor()->position().y, kStopButton)
- || inPolyRegion(getCursor()->position().x, getCursor()->position().y, kPlayButton)
- || inPolyRegion(getCursor()->position().x, getCursor()->position().y, kPowerButton)
- || inPolyRegion(getCursor()->position().x, getCursor()->position().y, kBlackJack)
- || inPolyRegion(getCursor()->position().x, getCursor()->position().y, kRedJack)
- || inPolyRegion(getCursor()->position().x, getCursor()->position().y, kYellowJack)) {
- getCursor()->animate();
- } else {
- if ((inPolyRegion(getCursor()->position().x, getCursor()->position().y, kRedHole) && _holesState[kOnTable])
- || (inPolyRegion(getCursor()->position().x, getCursor()->position().y, kYellowHole) && _holesState[kPluggedOnRed])
- || (inPolyRegion(getCursor()->position().x, getCursor()->position().y, kBlackHole) && _holesState[kPluggedOnYellow])) {
- if (getCursor()->currentFrame != 2) { // reset cursor
- getCursor()->show();
- getCursor()->set(MAKE_RESOURCE(kResourcePackShared, 2));
- getCursor()->animate();
- }
- } else {
- if (getCursor()->currentFrame != 0) { // reset cursor
- getCursor()->show();
- getCursor()->set(MAKE_RESOURCE(kResourcePackShared, 0));
- getCursor()->animate();
- }
- }
- }
- } else {
- getCursor()->hide();
- }
+//////////////////////////////////////////////////////////////////////////
+// Helpers
+//////////////////////////////////////////////////////////////////////////
+int PuzzleVCR::inPolygon(int x, int y, int polygonIndex) const {
+ return x >= puzzleVCRPolygons[polygonIndex].left && x <= puzzleVCRPolygons[polygonIndex].right
+ && y >= puzzleVCRPolygons[polygonIndex].top && y <= puzzleVCRPolygons[polygonIndex].bottom;
}
-void PuzzleVCR::handleMouseDown() {
+PuzzleVCR::Color PuzzleVCR::getJackOnHand() {
+ Color jack = kNone;
+ if (_jacksState[kBlack] == kOnHand)
+ jack = kBlack;
+ else if (_jacksState[kRed] == kOnHand)
+ jack = kRed;
+ else if (_jacksState[kYellow] == kOnHand)
+ jack = kYellow;
- if (_isAccomplished)
- return;
-
- int jackType = 0;
- if (_jacksState[kBlack] == kOnHand) {
- jackType = kBlack + 1;
- } else if (_jacksState[kRed] == kOnHand) {
- jackType = kRed + 1;
- } else {
- jackType = ((_jacksState[kYellow] != kOnHand) - 1) & 3;
- }
+ return jack;
+}
- // Plug-in jacks
- if (inPolyRegion(getCursor()->position().x, getCursor()->position().y, kRedHole)) {
- if (!setJackOnHole(jackType, kPluggedOnRed)) {
- return;
- }
- }
- if (inPolyRegion(getCursor()->position().x, getCursor()->position().y, kYellowHole)) {
- if (!setJackOnHole(jackType, kPluggedOnYellow)) {
- return;
- }
- }
- if (inPolyRegion(getCursor()->position().x, getCursor()->position().y, kBlackHole)) {
- if (!setJackOnHole(jackType, kPluggedOnBlack)) {
- // TODO: this will probably segfault!
- error("[BlowUpPuzzleVCR::handleMouseDown] Not implemented!");
- /*if (_holesState[kBlackHole] != kPluggedOnYellow && _buttonsState[kPower] == 1) {
- _buttonsState[kPower] = kOFF;
- _buttonsState[kStop] = kOFF;
- _buttonsState[kPlay] = kOFF;
- _buttonsState[kRewind] = kOFF;
- }
- return;*/
- }
- }
+void PuzzleVCR::setJackOnHole(Color hole, JackState state, JackState newState) {
+ bool isYellow = (hole == kYellow);
- // Put jacks on table --
- if (jackType) {
- if (getCursor()->position().x >= (int32)BlowUpPuzzleVCRPolies[kBlackJack].left && getCursor()->position().x <= (int32)BlowUpPuzzleVCRPolies[kYellowJack].right
- && getCursor()->position().y >= (int32)BlowUpPuzzleVCRPolies[kBlackJack].top && getCursor()->position().y <= (int32)BlowUpPuzzleVCRPolies[kYellowJack].bottom) {
+ if (_holesState[hole]) {
+ if (isYellow)
+ getSound()->stop(getWorld()->graphicResourceIds[47]);
- _jacksState[jackType-1] = kOnTable;
- getSound()->playSound(getWorld()->graphicResourceIds[50]);
- getCursor()->show();
- }
- return;
- }
+ _jacksState[_holesState[hole] - 1] = kOnHand;
+ _holesState[hole] = kOnTable;
- // Get Jacks from Table
- if (inPolyRegion(getCursor()->position().x, getCursor()->position().y, kBlackJack)) {
- _jacksState[kBlack] = kOnHand;
- } else if (inPolyRegion(getCursor()->position().x, getCursor()->position().y, kRedJack)) {
- _jacksState[kRed] = kOnHand;
- } else if (inPolyRegion(getCursor()->position().x, getCursor()->position().y, kYellowJack)) {
- _jacksState[kYellow] = kOnHand;
- }
+ if (state != kOnTable) {
+ getSound()->playSound(getWorld()->graphicResourceIds[44]);
+ _holesState[hole] = state;
- // VCR button regions
- if (inPolyRegion(getCursor()->position().x, getCursor()->position().y, kRewindButton)) {
- getSound()->playSound(getWorld()->graphicResourceIds[39]);
- if (!_buttonsState[kRewind]) {
- _buttonsState[kRewind] = kDownON;
- return;
- }
- if (_buttonsState[kRewind] == kON) {
- _buttonsState[kRewind] = kDownOFF;
- return;
- }
- } else if (inPolyRegion(getCursor()->position().x, getCursor()->position().y, kPlayButton)) {
- getSound()->playSound(getWorld()->graphicResourceIds[39]);
- if (!_buttonsState[kPlay]) {
- _buttonsState[kPlay] = kDownON;
- return;
- }
- if (_buttonsState[kPlay] == kON) {
- _buttonsState[kPlay] = kDownOFF;
- return;
- }
- } else if (inPolyRegion(getCursor()->position().x, getCursor()->position().y, kStopButton)) {
- getSound()->playSound(getWorld()->graphicResourceIds[39]);
- if (_buttonsState[kStop]) {
- if (_buttonsState[kStop] == kON) {
- _buttonsState[kStop] = kDownOFF;
- return;
+ if (isYellow) {
+ if (state != kPluggedOnYellow && _buttonsState[kPowerButton] == kON)
+ getSound()->stop(getWorld()->graphicResourceIds[47]);
}
- } else {
- _buttonsState[kStop] = kDownON;
- return;
- }
- } else if (inPolyRegion(getCursor()->position().x, getCursor()->position().y, kPowerButton)) {
- getSound()->playSound(getWorld()->graphicResourceIds[39]);
- if (!_buttonsState[kPower] && _holesState[kPluggedOnYellow] == kRed && _holesState[kOnTable] && _holesState[kPluggedOnRed]) {
- _buttonsState[kPower] = kDownON;
+ _jacksState[state - 1] = newState;
} else {
- _buttonsState[kPower] = kDownOFF;
+ getSound()->playSound(getWorld()->graphicResourceIds[43]);
+ getCursor()->hide();
+ getSharedData()->setFlag(kFlag1, true);
}
- }
-}
-
-void PuzzleVCR::handleMouseUp() {
- if (_isAccomplished)
- return;
+ } else if (state != kOnTable) {
+ getSound()->playSound(getWorld()->graphicResourceIds[44]);
+ _holesState[hole] = state;
- if (_buttonsState[kPower] == kDownON) {
- getSound()->playSound(getWorld()->graphicResourceIds[47], true);
- _buttonsState[kPower] = kON;
- _buttonsState[kStop] = kON;
- _buttonsState[kPlay] = kON;
- _buttonsState[kRewind] = kON;
- } else if (_buttonsState[kPower] == kDownOFF) {
- _buttonsState[kPower] = kOFF;
- _buttonsState[kStop] = kOFF;
- _buttonsState[kPlay] = kOFF;
- _buttonsState[kRewind] = kOFF;
- getSound()->stopAll();
- }
-
- if (_buttonsState[kRewind] == kDownOFF) {
- _buttonsState[kRewind] = kON;
- getSound()->playSound(getWorld()->graphicResourceIds[46]);
- } else if (_buttonsState[kRewind] == kDownON) {
- _buttonsState[kRewind] = kOFF;
- }
-
- if (_buttonsState[kPlay] == kDownOFF) {
- _buttonsState[kPlay] = kON;
- if (_holesState[kOnTable] == kYellow && _holesState[kPluggedOnRed] == kYellow + 1 /*FIXME this is not a proper value */ && _holesState[kPluggedOnYellow] == kRed) {
- _vm->setGameFlag(kGameFlagSolveVCRBlowUpPuzzle);
- _isAccomplished = true;
+ if (isYellow) {
+ if (state != kPluggedOnYellow && _buttonsState[kPowerButton] == kON)
+ getSound()->stop(getWorld()->graphicResourceIds[47]);
}
- } else if (_buttonsState[kPlay] == kDownON) {
- _buttonsState[kPlay] = kOFF;
- }
- if (_buttonsState[kStop] == kDownOFF) {
- _buttonsState[kStop] = kON;
- return;
- }
- if (_buttonsState[kStop] == kDownON) {
- _buttonsState[kStop] = kOFF;
+ _jacksState[state - 1] = newState;
}
}
+void PuzzleVCR::pickJack(Color jack) {
+ getCursor()->hide();
+ getSharedData()->setFlag(kFlag1, true);
+ _jacksState[jack] = kOnHand;
+}
+
} // end of namespace Asylum
diff --git a/engines/asylum/puzzles/vcr.h b/engines/asylum/puzzles/vcr.h
index 73da875f87..0c6b703822 100644
--- a/engines/asylum/puzzles/vcr.h
+++ b/engines/asylum/puzzles/vcr.h
@@ -39,7 +39,7 @@ typedef struct VCRDrawInfo {
Common::Point point;
} VCRDrawInfo;
-const Common::Rect BlowUpPuzzleVCRPolies[10] = {
+const Common::Rect puzzleVCRPolygons[10] = {
Common::Rect(0x0F7, 0x157, 0x13A, 0x183), // rewind button region
Common::Rect(0x14B, 0x15C, 0x17B, 0x18B), // stop button region
Common::Rect(0x18C, 0x161, 0x1D2, 0x18F), // play button region
@@ -61,7 +61,8 @@ public:
~PuzzleVCR();
private:
- enum Jack {
+ enum Color {
+ kNone = -1,
kBlack = 0,
kRed = 1,
kYellow = 2
@@ -88,13 +89,6 @@ private:
kYellowJack = 9
};
- enum Button {
- kRewind = 0,
- kStop = 1,
- kPlay = 2,
- kPower = 3
- };
-
enum ButtonState {
kOFF = 0,
kON = 1,
@@ -102,14 +96,12 @@ private:
kDownOFF = 3
};
- int _jacksState[3];
- int _holesState[3];
- int _buttonsState[4];
- uint32 _tvScreenAnimIdx;
+ JackState _jacksState[3];
+ JackState _holesState[3];
+ ButtonState _buttonsState[4];
+ uint32 _tvScreenFrameIndex;
bool _isAccomplished;
- int inPolyRegion(int x, int y, int polyIdx) const;
-
//////////////////////////////////////////////////////////////////////////
// Event Handling
//////////////////////////////////////////////////////////////////////////
@@ -118,17 +110,24 @@ private:
bool key(const AsylumEvent &evt);
bool mouse(const AsylumEvent &evt);
- void updateCursorInPolyRegion();
+ void mouseDown(const AsylumEvent &evt);
+ void mouseUp();
+
+ //////////////////////////////////////////////////////////////////////////
+ // Drawing
+ //////////////////////////////////////////////////////////////////////////
+ void updateScreen();
+ void updateCursor();
- GraphicQueueItem getGraphicJackItem(int32 index);
- GraphicQueueItem getGraphicShadowItem();
- void updateJack(Jack jack, const VCRDrawInfo &onTable, const VCRDrawInfo &pluggedOnRed, const VCRDrawInfo &pluggedOnYellow, const VCRDrawInfo &pluggedOnBlack, int32 resourceOnHandIndex);
+ //////////////////////////////////////////////////////////////////////////
+ // Updates
+ //////////////////////////////////////////////////////////////////////////
+ void updateJack(Color jack, const VCRDrawInfo &onTable, const VCRDrawInfo &pluggedOnRed, const VCRDrawInfo &pluggedOnYellow, const VCRDrawInfo &pluggedOnBlack, int32 resourceOnHandIndex);
void updateBlackJack();
void updateRedJack();
void updateYellowJack();
- int setJackOnHole(int jackType, JackState plugged);
- void updateButton(Button button, const VCRDrawInfo &btON, const VCRDrawInfo &btDown);
+ void updateButton(VCRRegions button, const VCRDrawInfo &btON, const VCRDrawInfo &btDown);
void updatePowerButton();
void updateRewindButton();
void updatePlayButton();
@@ -136,8 +135,14 @@ private:
void updateTVSync();
- void handleMouseDown();
- void handleMouseUp();
+ //////////////////////////////////////////////////////////////////////////
+ // Helpers
+ //////////////////////////////////////////////////////////////////////////
+ int inPolygon(int x, int y, int polyIdx) const;
+ Color getJackOnHand();
+ void setJackOnHole(Color hole, JackState state, JackState newState);
+ void pickJack(Color jack);
+
};
} // end of namespace Asylum
Commit: 109a98049a564f7af15b68d83d1759836ecf6f49
https://github.com/scummvm/scummvm/commit/109a98049a564f7af15b68d83d1759836ecf6f49
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:43+02:00
Commit Message:
ASYLUM: Implement start of Tic Tac Toe puzzle
- Implement init() and key() event handlers
- Add stubs for puzzle functions()
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@707 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/puzzles/tictactoe.cpp
engines/asylum/puzzles/tictactoe.h
engines/asylum/shared.h
diff --git a/engines/asylum/puzzles/tictactoe.cpp b/engines/asylum/puzzles/tictactoe.cpp
index 28ce2a6b88..fe7f790678 100644
--- a/engines/asylum/puzzles/tictactoe.cpp
+++ b/engines/asylum/puzzles/tictactoe.cpp
@@ -25,9 +25,58 @@
#include "asylum/puzzles/tictactoe.h"
+#include "asylum/resources/worldstats.h"
+
+#include "asylum/system/cursor.h"
+#include "asylum/system/screen.h"
+
+#include "asylum/views/scene.h"
+
+#include "asylum/asylum.h"
+
namespace Asylum {
+const Common::Point puzzleTicTacToePolygons[36] = {
+ Common::Point( 27, 381), Common::Point(172, 368),
+ Common::Point(190, 474), Common::Point( 36, 476),
+ Common::Point(176, 362), Common::Point(294, 328),
+ Common::Point(331, 456), Common::Point(191, 472),
+ Common::Point(304, 327), Common::Point(426, 306),
+ Common::Point(457, 440), Common::Point(340, 460),
+ Common::Point( 26, 257), Common::Point(151, 238),
+ Common::Point(169, 356), Common::Point( 27, 373),
+ Common::Point(162, 234), Common::Point(275, 214),
+ Common::Point(299, 321), Common::Point(173, 355),
+ Common::Point(283, 210), Common::Point(403, 173),
+ Common::Point(437, 294), Common::Point(305, 317),
+ Common::Point( 22, 120), Common::Point(132, 126),
+ Common::Point(146, 223), Common::Point( 25, 247),
+ Common::Point(144, 119), Common::Point(247, 87),
+ Common::Point(268, 205), Common::Point(159, 222),
+ Common::Point(259, 84), Common::Point(380, 73),
+ Common::Point(405, 169), Common::Point(281, 201)
+};
+
+const Common::Point puzzleTicTacToePositions[9] = {
+ Common::Point( 62, 367),
+ Common::Point(193, 343),
+ Common::Point(329, 319),
+ Common::Point( 38, 247),
+ Common::Point(167, 217),
+ Common::Point(296, 193),
+ Common::Point( 19, 121),
+ Common::Point(147, 98),
+ Common::Point(269, 70)
+};
+
PuzzleTicTacToe::PuzzleTicTacToe(AsylumEngine *engine) : Puzzle(engine) {
+ _ticker = 0;
+ _frameIndex = 0;
+ _lastMarkedField = 0;
+ _needToInitialize = false;
+ _strikeOutPosition = 0;
+
+ memset(&_gameField, 0, sizeof(_gameField));
}
PuzzleTicTacToe::~PuzzleTicTacToe() {
@@ -37,15 +86,124 @@ PuzzleTicTacToe::~PuzzleTicTacToe() {
// Event Handling
//////////////////////////////////////////////////////////////////////////
bool PuzzleTicTacToe::init() {
- error("[PuzzleTicTacToe::init] Not implemented!");
+ _ticker = 0;
+ _vm->clearGameFlag(kGameFlag114);
+ _vm->clearGameFlag(kGameFlag215);
+ _frameIndex = 0;
+ _lastMarkedField = -1;
+ _needToInitialize = false;
+ _strikeOutPosition = -1;
+
+ getScreen()->setPalette(getWorld()->graphicResourceIds[3]);
+ getScreen()->setGammaLevel(getWorld()->graphicResourceIds[3], 0);
+
+ getCursor()->show();
+ getCursor()->set(getWorld()->graphicResourceIds[12], 4, kCursorAnimationLinear);
+
+ initField();
+
+ return true;
}
bool PuzzleTicTacToe::update() {
error("[PuzzleTicTacToe::update] Not implemented!");
}
+bool PuzzleTicTacToe::key(const AsylumEvent &evt) {
+ switch (evt.kbd.keycode) {
+ default:
+ _vm->switchEventHandler(getScene());
+ break;
+
+ case Common::KEYCODE_TAB:
+ getScreen()->takeScreenshot();
+ break;
+ }
+
+ return true;
+}
+
bool PuzzleTicTacToe::mouse(const AsylumEvent &evt) {
- error("[PuzzleTicTacToe::mouse] Not implemented!");
+ switch (evt.type) {
+ default:
+ break;
+
+ case Common::EVENT_RBUTTONDOWN:
+ exit();
+ break;
+
+ case Common::EVENT_LBUTTONDOWN:
+ mouseDown();
+ break;
+ }
+
+ return true;
+}
+
+void PuzzleTicTacToe::mouseDown() {
+ error("[PuzzleTicTacToe::mouseDown] Not implemented!");
+}
+
+//////////////////////////////////////////////////////////////////////////
+// Init & update
+//////////////////////////////////////////////////////////////////////////
+void PuzzleTicTacToe::initField() {
+ memset(&_gameField, 32, sizeof(_gameField)); // ' ' == 32
+}
+
+void PuzzleTicTacToe::updateField() {
+ error("[PuzzleTicTacToe::updateField] Not implemented!");
+}
+
+void PuzzleTicTacToe::updatePositions(uint32 field1, uint32 field2, uint32 field3) {
+ error("[PuzzleTicTacToe::updatePositions] Not implemented!");
+}
+
+//////////////////////////////////////////////////////////////////////////
+// Game
+//////////////////////////////////////////////////////////////////////////
+bool PuzzleTicTacToe::check() {
+ error("[PuzzleTicTacToe::check] Not implemented!");
+}
+
+PuzzleTicTacToe::GameStatus PuzzleTicTacToe::checkField(uint32 field1, uint32 field2, uint32 field3, char mark, uint32 *counterX, uint32 *counterO) {
+ error("[PuzzleTicTacToe::checkField] Not implemented!");
+}
+
+bool PuzzleTicTacToe::checkFields1() {
+ error("[PuzzleTicTacToe::checkFields1] Not implemented!");
+}
+
+bool PuzzleTicTacToe::checkFields2() {
+ error("[PuzzleTicTacToe::checkFields2] Not implemented!");
+}
+
+uint32 PuzzleTicTacToe::checkPosition(uint32 position1, uint32 position2, uint position32) {
+ error("[PuzzleTicTacToe::checkPosition] Not implemented!");
+}
+
+bool PuzzleTicTacToe::checkWinner() {
+ error("[PuzzleTicTacToe::checkWinner] Not implemented!");
+}
+
+bool PuzzleTicTacToe::checkWinnerHelper() {
+ error("[PuzzleTicTacToe::checkWinnerHelper] Not implemented!");
+}
+
+bool PuzzleTicTacToe::checkWinningO() {
+ error("[PuzzleTicTacToe::checkWinningO] Not implemented!");
+}
+
+bool PuzzleTicTacToe::checkWinningX() {
+ error("[PuzzleTicTacToe::checkWinningX] Not implemented!");
+}
+
+bool PuzzleTicTacToe::countEmptyFields() {
+ error("[PuzzleTicTacToe::countEmptyFields] Not implemented!");
+}
+
+void PuzzleTicTacToe::placeOpponentMark() {
+ error("[PuzzleTicTacToe::placeOpponentMark] Not implemented!");
}
} // End of namespace Asylum
diff --git a/engines/asylum/puzzles/tictactoe.h b/engines/asylum/puzzles/tictactoe.h
index e4b5147cf5..6d265a7160 100644
--- a/engines/asylum/puzzles/tictactoe.h
+++ b/engines/asylum/puzzles/tictactoe.h
@@ -38,12 +38,54 @@ public:
~PuzzleTicTacToe();
private:
+ enum GameStatus {
+ kStatus0,
+ kStatus1,
+ kStatus2
+ };
+
+ uint32 _ticker;
+ uint32 _frameIndex;
+ int32 _lastMarkedField;
+ bool _needToInitialize;
+ int32 _strikeOutPosition;
+
+ char _gameField[9];
+ uint32 _field[40];
+
+
//////////////////////////////////////////////////////////////////////////
// Event Handling
//////////////////////////////////////////////////////////////////////////
bool init();
bool update();
+ bool key(const AsylumEvent &evt);
bool mouse(const AsylumEvent &evt);
+
+ void mouseDown();
+
+ //////////////////////////////////////////////////////////////////////////
+ // Init & update
+ //////////////////////////////////////////////////////////////////////////
+ void initField();
+
+ void updateField();
+ void updatePositions(uint32 field1, uint32 field2, uint32 field3);
+
+ //////////////////////////////////////////////////////////////////////////
+ // Game
+ //////////////////////////////////////////////////////////////////////////
+ bool check();
+ GameStatus checkField(uint32 field1, uint32 field2, uint32 field3, char mark, uint32 *counterX, uint32 *counterO);
+ bool checkFields1();
+ bool checkFields2();
+ uint32 checkPosition(uint32 position1, uint32 position2, uint position32);
+ bool checkWinner();
+ bool checkWinnerHelper();
+ bool checkWinningO();
+ bool checkWinningX();
+ bool countEmptyFields();
+ void placeOpponentMark();
};
} // End of namespace Asylum
diff --git a/engines/asylum/shared.h b/engines/asylum/shared.h
index e3a48532c4..5b03cc6b19 100644
--- a/engines/asylum/shared.h
+++ b/engines/asylum/shared.h
@@ -34,6 +34,8 @@ namespace Asylum {
enum GameFlag {
kGameFlag4 = 4,
kGameFlag12 = 12,
+ kGameFlag114 = 114,
+ kGameFlag215 = 215,
kGameFlagScriptProcessing = 183,
kGameFlag186 = 186,
kGameFlagCommentLeavingCell = 214,
Commit: 4e654d2dfba877996bd8d35a7da4b2eda7cc7431
https://github.com/scummvm/scummvm/commit/4e654d2dfba877996bd8d35a7da4b2eda7cc7431
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:43+02:00
Commit Message:
ASYLUM: Load the proper scene when using the puzzle command
- Save the current scene and restore it when quitting the puzzle
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@708 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/asylum.cpp
engines/asylum/asylum.h
engines/asylum/console.cpp
diff --git a/engines/asylum/asylum.cpp b/engines/asylum/asylum.cpp
index 1b4a117d57..78054a022b 100644
--- a/engines/asylum/asylum.cpp
+++ b/engines/asylum/asylum.cpp
@@ -85,6 +85,7 @@ AsylumEngine::AsylumEngine(OSystem *system, const ADGameDescription *gd) : Engin
// Debug
_delayedSceneIndex = kResourcePackInvalid;
_delayedVideoIndex = -1;
+ _previousScene = NULL;
// Add default search directories
const Common::FSNode gameDataDir(ConfMan.get("path"));
@@ -409,6 +410,18 @@ void AsylumEngine::switchEventHandler(EventHandler *handler) {
_handler->handleEvent(deinit);
}
+ //////////////////////////////////////////////////////////////////////////
+ // DEBUG - If a previous scene is found, replace the current scene by this one
+ if (handler == _scene) {
+ if (_previousScene) {
+ delete _scene;
+ _scene = _previousScene;
+ handler = _scene;
+ _previousScene = NULL;
+ }
+ }
+ //////////////////////////////////////////////////////////////////////////
+
// replace message handler
_handler = handler;
diff --git a/engines/asylum/asylum.h b/engines/asylum/asylum.h
index db7b1b12a7..f35096e927 100644
--- a/engines/asylum/asylum.h
+++ b/engines/asylum/asylum.h
@@ -124,14 +124,14 @@ public:
/**
* Get the number of engine ticks
*
- * @return The tick.
+ * @return The tick.
*/
uint32 getTick() { return _system->getMillis() + _tickOffset; }
/**
* Sets the tick value
*
- * @param offset The offset.
+ * @param offset The offset.
*/
void setTick(uint32 offset) { _tickOffset = offset - _system->getMillis(); }
@@ -250,7 +250,7 @@ private:
SharedData _data;
int _gameFlags[145];
int32 _sinCosTables[72];
- bool _introPlayed;
+ bool _introPlayed;
int32 _tickOffset;
void updateMouseCursor();
@@ -283,6 +283,7 @@ private:
// Debug
friend class Console;
+ Scene *_previousScene;
ResourcePackId _delayedSceneIndex;
int32 _delayedVideoIndex;
};
diff --git a/engines/asylum/console.cpp b/engines/asylum/console.cpp
index 9c7ac9c81a..dde57a1faf 100644
--- a/engines/asylum/console.cpp
+++ b/engines/asylum/console.cpp
@@ -49,6 +49,26 @@ extern int32 g_debugPolygons;
extern int32 g_debugObjects;
extern int32 g_debugScrolling;
+const ResourcePackId puzzleToScenes[17] = {
+ kResourcePackTowerCells,
+ kResourcePackCourtyardAndChapel,
+ kResourcePackInnocentAbandoned,
+ kResourcePackMansion,
+ kResourcePackInvalid,
+ kResourcePackLaboratory,
+ kResourcePackLaboratory,
+ kResourcePackLaboratory,
+ kResourcePackLaboratory,
+ kResourcePackMorgueCementary,
+ kResourcePackMansion,
+ kResourcePackMorgueCementary,
+ kResourcePackInvalid,
+ kResourcePackMorgueCementary,
+ kResourcePackLostVillage,
+ kResourcePackHive,
+ kResourcePackHive
+};
+
Console::Console(AsylumEngine *engine) : _vm(engine) {
// Commands
DCmd_Register("help", WRAP_METHOD(Console, cmdHelp));
@@ -425,6 +445,13 @@ bool Console::cmdRunPuzzle(int32 argc, const char **argv) {
getScreen()->clear();
getScreen()->clearGraphicsInQueue();
+ // Save previous scene
+ _vm->_previousScene = getScene();
+
+ // Load puzzle scene
+ _vm->_scene = new Scene(_vm);
+ getScene()->load(puzzleToScenes[index]);
+
_vm->switchEventHandler(puzzle);
return false;
Commit: f437a4a2e3c74b9e85b7ee27accefd42de3c60cb
https://github.com/scummvm/scummvm/commit/f437a4a2e3c74b9e85b7ee27accefd42de3c60cb
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:43+02:00
Commit Message:
ASYLUM: Implement PuzzleTicTacToe::update()
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@709 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/puzzles/tictactoe.cpp
engines/asylum/puzzles/tictactoe.h
engines/asylum/views/scene.h
diff --git a/engines/asylum/puzzles/tictactoe.cpp b/engines/asylum/puzzles/tictactoe.cpp
index fe7f790678..48bea445a8 100644
--- a/engines/asylum/puzzles/tictactoe.cpp
+++ b/engines/asylum/puzzles/tictactoe.cpp
@@ -77,6 +77,9 @@ PuzzleTicTacToe::PuzzleTicTacToe(AsylumEngine *engine) : Puzzle(engine) {
_strikeOutPosition = 0;
memset(&_gameField, 0, sizeof(_gameField));
+ memset(&_field, 0, sizeof(_field));
+
+ _emptyCount = 0;
}
PuzzleTicTacToe::~PuzzleTicTacToe() {
@@ -106,7 +109,32 @@ bool PuzzleTicTacToe::init() {
}
bool PuzzleTicTacToe::update() {
- error("[PuzzleTicTacToe::update] Not implemented!");
+ if (_ticker) {
+ ++_ticker;
+
+ if (_ticker <= 25) {
+ if (_ticker > 20) {
+ if (check())
+ placeOpponentMark();
+
+ _ticker = 0;
+ }
+ } else {
+ if (_ticker > 40) {
+ getSound()->playSound(getWorld()->soundResourceIds[13], false, Config.sfxVolume - 100);
+
+ _ticker = 0;
+ }
+ }
+ }
+
+ getScreen()->draw(getWorld()->graphicResourceIds[0], 0, 0, 0, 0, false);
+ updateField();
+ getScene()->updateAmbientSounds();
+
+ getScreen()->copyBackBufferToScreen();
+
+ return true;
}
bool PuzzleTicTacToe::key(const AsylumEvent &evt) {
@@ -152,7 +180,7 @@ void PuzzleTicTacToe::initField() {
}
void PuzzleTicTacToe::updateField() {
- error("[PuzzleTicTacToe::updateField] Not implemented!");
+ warning("[PuzzleTicTacToe::updateField] Not implemented!");
}
void PuzzleTicTacToe::updatePositions(uint32 field1, uint32 field2, uint32 field3) {
diff --git a/engines/asylum/puzzles/tictactoe.h b/engines/asylum/puzzles/tictactoe.h
index 6d265a7160..065fb746fe 100644
--- a/engines/asylum/puzzles/tictactoe.h
+++ b/engines/asylum/puzzles/tictactoe.h
@@ -52,7 +52,7 @@ private:
char _gameField[9];
uint32 _field[40];
-
+ uint32 _emptyCount;
//////////////////////////////////////////////////////////////////////////
// Event Handling
diff --git a/engines/asylum/views/scene.h b/engines/asylum/views/scene.h
index 63ab4fb170..9f114c0797 100644
--- a/engines/asylum/views/scene.h
+++ b/engines/asylum/views/scene.h
@@ -166,6 +166,11 @@ public:
*/
bool updateScreen();
+ /**
+ * Updates the ambient sounds.
+ */
+ void updateAmbientSounds();
+
/**
* Determine if the supplied point intersects an action area's active region.
*
@@ -247,11 +252,6 @@ private:
*/
void updateObjects();
- /**
- * Updates the ambient sounds.
- */
- void updateAmbientSounds();
-
/**
* Updates the music.
*/
Commit: a3d50bb1cdeeca48287c5725b68e7dd64e790f47
https://github.com/scummvm/scummvm/commit/a3d50bb1cdeeca48287c5725b68e7dd64e790f47
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:43+02:00
Commit Message:
ASYLUM: Add a Screen::draw() helper function to draw backgrounds
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@710 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/puzzles/tictactoe.cpp
engines/asylum/puzzles/vcr.cpp
engines/asylum/system/screen.cpp
engines/asylum/system/screen.h
engines/asylum/views/menu.cpp
engines/asylum/views/scenetitle.cpp
diff --git a/engines/asylum/puzzles/tictactoe.cpp b/engines/asylum/puzzles/tictactoe.cpp
index 48bea445a8..1b4d5a20ee 100644
--- a/engines/asylum/puzzles/tictactoe.cpp
+++ b/engines/asylum/puzzles/tictactoe.cpp
@@ -128,7 +128,7 @@ bool PuzzleTicTacToe::update() {
}
}
- getScreen()->draw(getWorld()->graphicResourceIds[0], 0, 0, 0, 0, false);
+ getScreen()->draw(getWorld()->graphicResourceIds[0]);
updateField();
getScene()->updateAmbientSounds();
diff --git a/engines/asylum/puzzles/vcr.cpp b/engines/asylum/puzzles/vcr.cpp
index 7b5749dc03..88f57d0d7c 100644
--- a/engines/asylum/puzzles/vcr.cpp
+++ b/engines/asylum/puzzles/vcr.cpp
@@ -314,7 +314,7 @@ void PuzzleVCR::updateScreen() {
// Draw background
getScreen()->clearGraphicsInQueue();
- getScreen()->draw(getWorld()->graphicResourceIds[0], 0, 0, 0, 0, false);
+ getScreen()->draw(getWorld()->graphicResourceIds[0]);
updateBlackJack();
updateRedJack();
@@ -334,7 +334,7 @@ void PuzzleVCR::updateScreen() {
if (_isAccomplished) {
getCursor()->show();
- getScreen()->draw(getWorld()->graphicResourceIds[0], 0, 0, 0, 0, false);
+ getScreen()->draw(getWorld()->graphicResourceIds[0]);
getScreen()->drawGraphicsInQueue();
for (uint32 barSize = 0; barSize < 84; barSize += 4)
diff --git a/engines/asylum/system/screen.cpp b/engines/asylum/system/screen.cpp
index 1519cf6076..c44143b2f1 100644
--- a/engines/asylum/system/screen.cpp
+++ b/engines/asylum/system/screen.cpp
@@ -58,6 +58,10 @@ Screen::~Screen() {
//////////////////////////////////////////////////////////////////////////
// Drawing
//////////////////////////////////////////////////////////////////////////
+void Screen::draw(ResourceId resourceId) {
+ draw(resourceId, 0, 0, 0, 0, kResourceNone, 0, 0, false);
+}
+
void Screen::draw(ResourceId resourceId, uint32 frameIndex, int32 x, int32 y, int32 flags, bool colorKey) {
draw(resourceId, frameIndex, x, y, flags, kResourceNone, 0, 0, colorKey);
}
diff --git a/engines/asylum/system/screen.h b/engines/asylum/system/screen.h
index f8b1c64b7c..b82a1c39c3 100644
--- a/engines/asylum/system/screen.h
+++ b/engines/asylum/system/screen.h
@@ -75,6 +75,7 @@ public:
~Screen();
// Drawing
+ void draw(ResourceId resourceId);
void draw(ResourceId resourceId, uint32 frameIndex, int32 x, int32 y, int32 flags, bool colorKey = true);
void draw(ResourceId resourceId, uint32 frameIndex, int32 x, int32 y, int32 flags, int32 transTableNum);
void draw(ResourceId resourceId, uint32 frameIndex, int32 x, int32 y, int32 flags, ResourceId resourceId2, int32 destX, int32 destY, bool colorKey = true);
diff --git a/engines/asylum/views/menu.cpp b/engines/asylum/views/menu.cpp
index c1526d60dc..a19d580281 100644
--- a/engines/asylum/views/menu.cpp
+++ b/engines/asylum/views/menu.cpp
@@ -1529,9 +1529,9 @@ void Menu::updateReturnToGame() {
void Menu::updateShowCredits() {
if (_vm->isGameFlagSet(kGameFlagFinishGame)) {
- getScreen()->draw(MAKE_RESOURCE(kResourcePackShared, 33), 0, 0, 0, 0, false);
+ getScreen()->draw(MAKE_RESOURCE(kResourcePackShared, 33));
} else {
- getScreen()->draw(MAKE_RESOURCE(kResourcePackShared, 23), 0, 0, 0, 0, false);
+ getScreen()->draw(MAKE_RESOURCE(kResourcePackShared, 23));
getScreen()->draw(MAKE_RESOURCE(kResourcePackShared, 24), _creditsFrameIndex++ / 2, 0, 0, 0, false);
_creditsFrameIndex %= 2 * GraphicResource::getFrameCount(_vm, MAKE_RESOURCE(kResourcePackShared, 24));
diff --git a/engines/asylum/views/scenetitle.cpp b/engines/asylum/views/scenetitle.cpp
index dcc7c73f0b..5a02de2e27 100644
--- a/engines/asylum/views/scenetitle.cpp
+++ b/engines/asylum/views/scenetitle.cpp
@@ -70,7 +70,7 @@ void SceneTitle::update(int32 tick) {
if (_done)
return;
- getScreen()->draw(getWorld()->sceneTitleGraphicResourceId, 0, 0, 0, 0, false);
+ getScreen()->draw(getWorld()->sceneTitleGraphicResourceId);
getScreen()->draw(MAKE_RESOURCE(kResourcePackSound, 17), _spinnerFrameIndex, (_spinnerProgress / 590.0 * 580) - 290 , 0, 0, false);
getText()->drawCentered(320, 30, 24, MAKE_RESOURCE(kResourcePackText, 1811 + getWorld()->chapter));
Commit: 1ba2e61c1d972374833e56fb3771a53588e6847f
https://github.com/scummvm/scummvm/commit/1ba2e61c1d972374833e56fb3771a53588e6847f
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:43+02:00
Commit Message:
ASYLUM: Implement Polygons::contains()
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@711 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/resources/polygons.cpp
engines/asylum/resources/polygons.h
diff --git a/engines/asylum/resources/polygons.cpp b/engines/asylum/resources/polygons.cpp
index 7ec9f01200..a86c4fd392 100644
--- a/engines/asylum/resources/polygons.cpp
+++ b/engines/asylum/resources/polygons.cpp
@@ -87,4 +87,28 @@ void Polygons::load(Common::SeekableReadStream *stream) {
}
}
+//////////////////////////////////////////////////////////////////////////
+// Contains
+//////////////////////////////////////////////////////////////////////////
+
+bool Polygons::contains(Common::Point *points, uint32 count, Common::Point point, Common::Rect *boundingRect) {
+ error("[Polygons::contains] Not implemented!");
+}
+
+bool Polygons::contains(int32 x1, int32 y1, int32 x2, int32 y2, int32 x3, int32 y3, int32 x4, int32 y4) {
+ return (compareDistance(x1, y1, x2, y2, x3, y3) * compareDistance(x1, y1, x2, y2, x4, y4) <= 0
+ && compareDistance(x3, y3, x4, y4, x1, y1) * compareDistance(x3, y3, x4, y4, x2, y2) <= 0);
+}
+
+int32 Polygons::compareDistance(int32 x1, int32 y1, int32 x2, int32 y2, int32 x3, int32 y3) {
+ uint32 d1 = (y3 - y1) * (x2 - x1);
+ uint32 d2 = (x3 - x1) * (y2 - y1);
+
+ return (d1 <= d2) ? -1 : 1;
+}
+
+bool Polygons::containsHelper(Common::Point *points, uint32 count, Common::Point point, Common::Rect *boundingRect) {
+ error("[Polygons::containsHelper] Not implemented!");
+}
+
} // end of namespace Asylum
diff --git a/engines/asylum/resources/polygons.h b/engines/asylum/resources/polygons.h
index f3e701222e..a60ec12f44 100644
--- a/engines/asylum/resources/polygons.h
+++ b/engines/asylum/resources/polygons.h
@@ -66,10 +66,15 @@ public:
Common::Array<PolyDefinitions> entries;
-private:
+ static bool contains(Common::Point *points, uint32 count, Common::Point point, Common::Rect *boundingRect);
+ static bool contains(int32 x1, int32 y1, int32 x2, int32 y2, int32 x3, int32 y3, int32 x4, int32 y4);
+private:
void load(Common::SeekableReadStream *stream);
+ static int32 compareDistance(int32 x1, int32 y1, int32 x2, int32 y2, int32 x3, int32 y3);
+ static bool containsHelper(Common::Point *points, uint32 count, Common::Point point, Common::Rect *boundingRect);
+
}; // end of class Polygons
} // end of namespace Asylum
Commit: 42adf9dc52fa0cfbf68a53e707870a139e74dfd2
https://github.com/scummvm/scummvm/commit/42adf9dc52fa0cfbf68a53e707870a139e74dfd2
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:43+02:00
Commit Message:
ASYLUM: Implement Puzzle::hitTest helper functions
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@712 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/puzzles/puzzle.cpp
engines/asylum/puzzles/puzzle.h
diff --git a/engines/asylum/puzzles/puzzle.cpp b/engines/asylum/puzzles/puzzle.cpp
index a0f47bbc0a..d34496e31b 100644
--- a/engines/asylum/puzzles/puzzle.cpp
+++ b/engines/asylum/puzzles/puzzle.cpp
@@ -25,6 +25,7 @@
#include "asylum/puzzles/puzzle.h"
+#include "asylum/resources/polygons.h"
#include "asylum/resources/worldstats.h"
#include "asylum/system/cursor.h"
@@ -99,4 +100,45 @@ void Puzzle::exit() {
_vm->switchEventHandler(getScene());
}
+//////////////////////////////////////////////////////////////////////////
+// Hit test functions
+//////////////////////////////////////////////////////////////////////////
+bool Puzzle::hitTest(const Common::Point *polygonPoint, Common::Point point, uint32 index) {
+ uint32 counter = 0;
+
+ for (uint32 i = index; i < index + 3; i++)
+ if (Polygons::contains(point.x, point.y,
+ polygonPoint[index + 1].x + point.x + 100, point.y,
+ polygonPoint[i].x, polygonPoint[i].y,
+ polygonPoint[i + 1].x, polygonPoint[i + 1].y))
+ ++counter;
+
+ if (Polygons::contains(point.x, point.y,
+ polygonPoint[index + 1].x + point.x + 100, point.y,
+ polygonPoint[index].x, polygonPoint[index].y,
+ polygonPoint[index + 3].x, polygonPoint[index + 3].y))
+ ++counter;
+
+ return (counter & 1);
+}
+
+bool Puzzle::hitTest(const Common::Point *polygonPoint, Common::Point point) {
+ uint32 counter = 0;
+
+ for (uint32 i = 3; i > 1; i--)
+ if (Polygons::contains(point.x, point.y,
+ polygonPoint[1].x + point.x + 700, point.y,
+ polygonPoint[i].x, polygonPoint[i].y,
+ polygonPoint[i + 1].x, polygonPoint[i + 1].y))
+ ++counter;
+
+ if (Polygons::contains(point.x, point.y,
+ polygonPoint[0].x + point.x + 100, point.y,
+ polygonPoint[0].x, polygonPoint[0].y,
+ polygonPoint[3].x, polygonPoint[3].y))
+ ++counter;
+
+ return (counter & 1);
+}
+
} // end of namespace Asylum
diff --git a/engines/asylum/puzzles/puzzle.h b/engines/asylum/puzzles/puzzle.h
index 40217b2836..ae18af17e7 100644
--- a/engines/asylum/puzzles/puzzle.h
+++ b/engines/asylum/puzzles/puzzle.h
@@ -63,6 +63,13 @@ protected:
virtual bool mouse(const AsylumEvent &evt) = 0;
void exit();
+
+ //////////////////////////////////////////////////////////////////////////
+ // Hit test functions
+ //////////////////////////////////////////////////////////////////////////
+ bool hitTest(const Common::Point *polygonPoint, Common::Point point, uint32 index);
+ bool hitTest(const Common::Point *polygonPoint, Common::Point point);
+
};
} // End of namespace Asylum
Commit: 4082f2deae650673fe4e6c13a3b197b8ebaef9ec
https://github.com/scummvm/scummvm/commit/4082f2deae650673fe4e6c13a3b197b8ebaef9ec
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:43+02:00
Commit Message:
ASYLUM: Implement Tic Tac Toe puzzle game logic
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@713 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/puzzles/tictactoe.cpp
engines/asylum/puzzles/tictactoe.h
diff --git a/engines/asylum/puzzles/tictactoe.cpp b/engines/asylum/puzzles/tictactoe.cpp
index 1b4d5a20ee..e1521f0c8c 100644
--- a/engines/asylum/puzzles/tictactoe.cpp
+++ b/engines/asylum/puzzles/tictactoe.cpp
@@ -69,17 +69,38 @@ const Common::Point puzzleTicTacToePositions[9] = {
Common::Point(269, 70)
};
+static const struct {
+ uint32 field1;
+ uint32 field2;
+ uint32 field3;
+ uint32 strikeOutPositionX;
+ uint32 strikeOutPositionO;
+ uint32 frameCount;
+} fieldsToCheck[8] = {
+ {0, 1, 2, 1, 9, 14},
+ {3, 4, 5, 2, 10, 14},
+ {6, 7, 8, 3, 11, 14},
+ {0, 3, 6, 4, 12, 10},
+ {4, 1, 7, 5, 13, 10},
+ {8, 5, 2, 6, 14, 10},
+ {4, 6, 2, 7, 15, 4},
+ {0, 4, 8, 8, 16, 4}
+};
+
PuzzleTicTacToe::PuzzleTicTacToe(AsylumEngine *engine) : Puzzle(engine) {
_ticker = 0;
_frameIndex = 0;
+ _frameCount = 0;
_lastMarkedField = 0;
_needToInitialize = false;
_strikeOutPosition = 0;
+ // Field
memset(&_gameField, 0, sizeof(_gameField));
memset(&_field, 0, sizeof(_field));
-
_emptyCount = 0;
+
+ _var5 = 0;
}
PuzzleTicTacToe::~PuzzleTicTacToe() {
@@ -129,7 +150,7 @@ bool PuzzleTicTacToe::update() {
}
getScreen()->draw(getWorld()->graphicResourceIds[0]);
- updateField();
+ drawField();
getScene()->updateAmbientSounds();
getScreen()->copyBackBufferToScreen();
@@ -161,15 +182,44 @@ bool PuzzleTicTacToe::mouse(const AsylumEvent &evt) {
break;
case Common::EVENT_LBUTTONDOWN:
- mouseDown();
+ mouseLeft();
break;
}
return true;
}
-void PuzzleTicTacToe::mouseDown() {
- error("[PuzzleTicTacToe::mouseDown] Not implemented!");
+void PuzzleTicTacToe::mouseLeft() {
+ Common::Point mousePos = getCursor()->position();
+
+ if (!_vm->isGameFlagNotSet(kGameFlag215) || !_vm->isGameFlagNotSet(kGameFlag114)) {
+ getCursor()->show();
+ exit();
+ return;
+ }
+
+ if (_needToInitialize) {
+ _needToInitialize = false;
+ _frameIndex = 0;
+ _lastMarkedField = -1;
+ _strikeOutPosition = -1;
+ initField();
+
+ return;
+ }
+
+ for (uint32 i = 0; i < ARRAYSIZE(puzzleTicTacToePolygons) - 2; i++) {
+ if (hitTest(&puzzleTicTacToePolygons[i], mousePos, 0)) {
+ if (_gameField[i] == ' ') {
+ getSound()->playSound(getWorld()->soundResourceIds[11], false, Config.sfxVolume - 100);
+ _gameField[i] = 'X';
+ _lastMarkedField = i;
+ _frameIndex = 0;
+
+ getCursor()->hide();
+ }
+ }
+ }
}
//////////////////////////////////////////////////////////////////////////
@@ -179,59 +229,213 @@ void PuzzleTicTacToe::initField() {
memset(&_gameField, 32, sizeof(_gameField)); // ' ' == 32
}
-void PuzzleTicTacToe::updateField() {
+void PuzzleTicTacToe::drawField() {
warning("[PuzzleTicTacToe::updateField] Not implemented!");
}
void PuzzleTicTacToe::updatePositions(uint32 field1, uint32 field2, uint32 field3) {
- error("[PuzzleTicTacToe::updatePositions] Not implemented!");
+ if (_gameField[field1] != ' ') {
+ _field[_emptyCount] = field3;
+ _field[_emptyCount + 1] = field2;
+
+ _emptyCount += 2;
+ }
+
+ if (_gameField[field3] != ' ') {
+ _field[_emptyCount] = field1;
+ _field[_emptyCount + 1] = field2;
+
+ _emptyCount += 2;
+ }
+
+ if (_gameField[field2] != ' ') {
+ _field[_emptyCount] = field3;
+ _field[_emptyCount + 1] = field1;
+
+ _emptyCount += 2;
+ }
}
//////////////////////////////////////////////////////////////////////////
// Game
//////////////////////////////////////////////////////////////////////////
bool PuzzleTicTacToe::check() {
- error("[PuzzleTicTacToe::check] Not implemented!");
+ if (_needToInitialize)
+ return false;
+
+ if (!checkWinning('X')
+ && !checkWinning('O')
+ && !checkFieldsUpdatePositions()
+ && !checkFields()
+ && !countEmptyFields()) {
+ if (!_var5)
+ getCursor()->show();
+
+ _needToInitialize = true;
+
+ return false;
+ }
+
+ return true;
}
PuzzleTicTacToe::GameStatus PuzzleTicTacToe::checkField(uint32 field1, uint32 field2, uint32 field3, char mark, uint32 *counterX, uint32 *counterO) {
- error("[PuzzleTicTacToe::checkField] Not implemented!");
+ *counterX = 0;
+ *counterO = 0;
+ GameStatus status = kStatus0;
+
+ if (_gameField[field1] == 'X')
+ ++*counterX;
+ if (_gameField[field2] == 'X')
+ ++*counterX;
+ if (_gameField[field3] == 'X')
+ ++*counterX;
+
+ if (_gameField[field1] == 'O')
+ ++*counterO;
+ if (_gameField[field2] == 'O')
+ ++*counterO;
+ if (_gameField[field3] == 'O')
+ ++*counterO;
+
+ if (mark == 'O') {
+ if (*counterO == 1 && !*counterX)
+ status = kStatusFree;
+ } else if (mark == 'X') {
+ if (!*counterO && *counterX == 1)
+ status = kStatusFree;
+ }
+
+ if (mark == 'O') {
+ if (!*counterO && *counterX == 2)
+ status = kStatusNeedBlocking;
+ } else if (mark == 'X') {
+ if (*counterO == 2 && !*counterX)
+ status = kStatusNeedBlocking;
+ }
+
+ return status;
}
-bool PuzzleTicTacToe::checkFields1() {
- error("[PuzzleTicTacToe::checkFields1] Not implemented!");
+bool PuzzleTicTacToe::checkFieldsUpdatePositions() {
+ uint32 counterX = 0;
+ uint32 counterO = 0;
+
+ for (uint32 i = 0; i < ARRAYSIZE(fieldsToCheck) - 1; i++)
+ if (checkField(fieldsToCheck[i].field1, fieldsToCheck[i].field2, fieldsToCheck[i].field3, 'O', &counterX, &counterO) == kStatusFree)
+ updatePositions(fieldsToCheck[i].field1, fieldsToCheck[i].field2, fieldsToCheck[i].field3);
+
+ return (_emptyCount != 0);
}
-bool PuzzleTicTacToe::checkFields2() {
- error("[PuzzleTicTacToe::checkFields2] Not implemented!");
+bool PuzzleTicTacToe::checkFields() {
+ uint32 counterX = 0;
+ uint32 counterO = 0;
+
+ for (uint32 i = 0; i < ARRAYSIZE(fieldsToCheck) - 1; i++) {
+ checkField(fieldsToCheck[i].field1, fieldsToCheck[i].field2, fieldsToCheck[i].field3, 'O', &counterX, &counterO);
+
+ if (counterX || counterO)
+ continue;
+
+ _field[_emptyCount] = 0;
+ _field[_emptyCount + 1] = fieldsToCheck[i].field3;
+ _field[_emptyCount + 2] = fieldsToCheck[i].field2;
+
+ _emptyCount += 3;
+ }
+
+ return (_emptyCount != 0);
}
-uint32 PuzzleTicTacToe::checkPosition(uint32 position1, uint32 position2, uint position32) {
- error("[PuzzleTicTacToe::checkPosition] Not implemented!");
+uint32 PuzzleTicTacToe::checkPosition(uint32 position1, uint32 position2, uint position3) {
+ if (_gameField[position1] == ' ')
+ return position1;
+
+ if (_gameField[position2] == ' ')
+ return position2;
+
+ return position3;
}
bool PuzzleTicTacToe::checkWinner() {
- error("[PuzzleTicTacToe::checkWinner] Not implemented!");
-}
+ if (_needToInitialize)
+ return true;
+
+ if (checkWinnerHelper() == 1) {
+ _vm->setGameFlag(kGameFlag114);
+ _ticker = 30;
+ return true;
+ }
+
+ if (checkWinnerHelper() == -1) {
+ _vm->setGameFlag(kGameFlag215);
+ _ticker = 30;
+ return true;
+ }
-bool PuzzleTicTacToe::checkWinnerHelper() {
- error("[PuzzleTicTacToe::checkWinnerHelper] Not implemented!");
+ return false;
}
-bool PuzzleTicTacToe::checkWinningO() {
- error("[PuzzleTicTacToe::checkWinningO] Not implemented!");
+int32 PuzzleTicTacToe::checkWinnerHelper() {
+ uint32 counterX = 0;
+ uint32 counterO = 0;
+
+ for (uint32 i = 0; i < ARRAYSIZE(fieldsToCheck) - 1; i++) {
+ checkField(fieldsToCheck[i].field1, fieldsToCheck[i].field2, fieldsToCheck[i].field3, 'O', &counterX, &counterO);
+
+ if (counterX == 3) {
+ _strikeOutPosition = fieldsToCheck[i].strikeOutPositionX;
+ _frameCount = fieldsToCheck[i].frameCount;
+ _frameIndex = 0;
+ return 1;
+ }
+
+ if (counterO == 3) {
+ _strikeOutPosition = fieldsToCheck[i].strikeOutPositionO;
+ _frameCount = fieldsToCheck[i].frameCount;
+ _frameIndex = 0;
+ return -1;
+ }
+ }
+
+ return 0;
}
-bool PuzzleTicTacToe::checkWinningX() {
- error("[PuzzleTicTacToe::checkWinningX] Not implemented!");
+bool PuzzleTicTacToe::checkWinning(char mark) {
+ uint32 counterX = 0;
+ uint32 counterO = 0;
+ _emptyCount = 0;
+
+ for (uint32 i = 0; i < ARRAYSIZE(fieldsToCheck) - 1; i++) {
+ if (checkField(fieldsToCheck[i].field1, fieldsToCheck[i].field2, fieldsToCheck[i].field3, 'O', &counterX, &counterO) == kStatusNeedBlocking) {
+ _field[_emptyCount] = checkPosition(fieldsToCheck[i].field1, fieldsToCheck[i].field2, fieldsToCheck[i].field3);
+ ++_emptyCount;
+ }
+ }
+
+ return (_emptyCount != 0);
}
bool PuzzleTicTacToe::countEmptyFields() {
- error("[PuzzleTicTacToe::countEmptyFields] Not implemented!");
+ _emptyCount = 0;
+
+ for (uint32 i = 0; i < ARRAYSIZE(_gameField); i++) {
+ if (_gameField[i] == ' ') {
+ _field[i] = i;
+ ++_emptyCount;
+ }
+ }
+
+ return (_emptyCount != 0);
}
void PuzzleTicTacToe::placeOpponentMark() {
- error("[PuzzleTicTacToe::placeOpponentMark] Not implemented!");
+ _frameIndex = 0;
+ _lastMarkedField = _field[rnd(_emptyCount)];
+ _gameField[_lastMarkedField] = 'O';
+
+ getSound()->playSound(getWorld()->soundResourceIds[12], false, Config.sfxVolume - 100);
}
} // End of namespace Asylum
diff --git a/engines/asylum/puzzles/tictactoe.h b/engines/asylum/puzzles/tictactoe.h
index 065fb746fe..bcedc42c61 100644
--- a/engines/asylum/puzzles/tictactoe.h
+++ b/engines/asylum/puzzles/tictactoe.h
@@ -40,16 +40,19 @@ public:
private:
enum GameStatus {
kStatus0,
- kStatus1,
- kStatus2
+ kStatusFree,
+ kStatusNeedBlocking
};
uint32 _ticker;
uint32 _frameIndex;
+ uint32 _frameCount;
int32 _lastMarkedField;
bool _needToInitialize;
int32 _strikeOutPosition;
+ uint32 _var5;
+
char _gameField[9];
uint32 _field[40];
uint32 _emptyCount;
@@ -62,14 +65,13 @@ private:
bool key(const AsylumEvent &evt);
bool mouse(const AsylumEvent &evt);
- void mouseDown();
+ void mouseLeft();
//////////////////////////////////////////////////////////////////////////
// Init & update
//////////////////////////////////////////////////////////////////////////
void initField();
-
- void updateField();
+ void drawField();
void updatePositions(uint32 field1, uint32 field2, uint32 field3);
//////////////////////////////////////////////////////////////////////////
@@ -77,13 +79,12 @@ private:
//////////////////////////////////////////////////////////////////////////
bool check();
GameStatus checkField(uint32 field1, uint32 field2, uint32 field3, char mark, uint32 *counterX, uint32 *counterO);
- bool checkFields1();
- bool checkFields2();
- uint32 checkPosition(uint32 position1, uint32 position2, uint position32);
+ bool checkFieldsUpdatePositions();
+ bool checkFields();
+ uint32 checkPosition(uint32 position1, uint32 position2, uint position3);
bool checkWinner();
- bool checkWinnerHelper();
- bool checkWinningO();
- bool checkWinningX();
+ int32 checkWinnerHelper();
+ bool checkWinning(char mark);
bool countEmptyFields();
void placeOpponentMark();
};
Commit: 6bddbc6158d300ab7312067d0b00de1e54b64b74
https://github.com/scummvm/scummvm/commit/6bddbc6158d300ab7312067d0b00de1e54b64b74
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:44+02:00
Commit Message:
ASYLUM: Correct use of ARRAYSIZE
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@714 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/asylum.cpp
engines/asylum/console.cpp
engines/asylum/system/savegame.cpp
diff --git a/engines/asylum/asylum.cpp b/engines/asylum/asylum.cpp
index 78054a022b..0d821cffb0 100644
--- a/engines/asylum/asylum.cpp
+++ b/engines/asylum/asylum.cpp
@@ -440,7 +440,7 @@ void AsylumEngine::notify(AsylumEventType type, int32 param1, int32 param2) {
}
EventHandler *AsylumEngine::getPuzzle(uint32 index) {
- if (index >= ARRAYSIZE(_puzzles))
+ if (index > ARRAYSIZE(_puzzles))
error("[AsylumEngine::getPuzzleEventHandler] Invalid index (was: %d - max: %d)", index, ARRAYSIZE(_puzzles));
if (_puzzles[index] == NULL)
@@ -462,13 +462,11 @@ void AsylumEngine::initPuzzles() {
_puzzles[9] = new PuzzleWritings(this);
_puzzles[10] = new PuzzleClock(this);
_puzzles[11] = new PuzzleMorgueDoor(this);
- _puzzles[12] = NULL; // FIXME Not sure which puzzle this is
+ _puzzles[12] = NULL; warning("[AsylumEngine::initPuzzles] Add missing puzzles!"); // FIXME Not sure which puzzle this is
_puzzles[13] = new PuzzleTimeMachine(this);
_puzzles[14] = new PuzzleFisherman(this);
_puzzles[15] = new PuzzleHiveMachine(this);
_puzzles[16] = new PuzzleHiveControl(this);
-
- warning("[AsylumEngine::initPuzzles] Add missing puzzles!");
}
void AsylumEngine::initSinCosTables(double a2, int32 a3, int32 a4) {
diff --git a/engines/asylum/console.cpp b/engines/asylum/console.cpp
index dde57a1faf..770e1eee8e 100644
--- a/engines/asylum/console.cpp
+++ b/engines/asylum/console.cpp
@@ -431,8 +431,8 @@ bool Console::cmdRunPuzzle(int32 argc, const char **argv) {
uint32 index = atoi(argv[1]);
// Check index is valid
- if (index >= 16) {
- DebugPrintf("[Error] Invalid index (was: %d - valid: [0-16])\n", index);
+ if (index > ARRAYSIZE(_vm->_puzzles)) {
+ DebugPrintf("[Error] Invalid index (was: %d - valid: [0-%d])\n", index, ARRAYSIZE(_vm->_puzzles));
return true;
}
diff --git a/engines/asylum/system/savegame.cpp b/engines/asylum/system/savegame.cpp
index a40439205c..2852e0f210 100644
--- a/engines/asylum/system/savegame.cpp
+++ b/engines/asylum/system/savegame.cpp
@@ -400,7 +400,7 @@ void Savegame::write(Common::OutSaveFile *file, Common::Serializable *data, uint
// Movies
//////////////////////////////////////////////////////////////////////////
void Savegame::setMovieViewed(uint32 index) {
- if (index >= ARRAYSIZE(_moviesViewed))
+ if (index > ARRAYSIZE(_moviesViewed))
error("[Savegame::setMovieViewed] Invalid movie index!");
if (!_moviesViewed[index]) {
@@ -450,22 +450,22 @@ void Savegame::loadMoviesViewed() {
// Accessors
//////////////////////////////////////////////////////////////////////////
void Savegame::setName(uint32 index, Common::String name) {
- if (index > ARRAYSIZE(_names) - 1)
- error("[Savegame::setName] Invalid index (was: %d, max: %d)", index, ARRAYSIZE(_names) - 1);
+ if (index > ARRAYSIZE(_names))
+ error("[Savegame::setName] Invalid index (was: %d, max: %d)", index, ARRAYSIZE(_names));
_names[index] = name;
}
Common::String Savegame::getName(uint32 index) {
- if (index > ARRAYSIZE(_names) - 1)
- error("[Savegame::getName] Invalid index (was: %d, max: %d)", index, ARRAYSIZE(_names) - 1);
+ if (index > ARRAYSIZE(_names))
+ error("[Savegame::getName] Invalid index (was: %d, max: %d)", index, ARRAYSIZE(_names));
return _names[index];
}
bool Savegame::hasSavegame(uint32 index) {
- if (index > ARRAYSIZE(_savegames) - 1)
- error("[Savegame::hasSavegame] Invalid index (was: %d, max: %d)", index, ARRAYSIZE(_savegames) - 1);
+ if (index > ARRAYSIZE(_savegames))
+ error("[Savegame::hasSavegame] Invalid index (was: %d, max: %d)", index, ARRAYSIZE(_savegames));
return _savegames[index];
}
Commit: fe4560c6cd7ac0f9c41cce4e659e5fa736f40e0e
https://github.com/scummvm/scummvm/commit/fe4560c6cd7ac0f9c41cce4e659e5fa736f40e0e
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:44+02:00
Commit Message:
ASYLUM: Add Screen::drawLine debug function
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@715 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/system/screen.cpp
engines/asylum/system/screen.h
diff --git a/engines/asylum/system/screen.cpp b/engines/asylum/system/screen.cpp
index c44143b2f1..8f36747cbe 100644
--- a/engines/asylum/system/screen.cpp
+++ b/engines/asylum/system/screen.cpp
@@ -487,6 +487,13 @@ void Screen::copyToBackBufferWithTransparency(byte *buffer, int32 pitch, int32 x
}
}
+//////////////////////////////////////////////////////////////////////////
+// Debug
+//////////////////////////////////////////////////////////////////////////
+void Screen::drawLine(int x0, int y0, int x1, int y1) {
+ _backBuffer.drawLine(x0, y0, x1, y1, 0xFF);
+}
+
void Screen::copyToBackBufferClipped(Graphics::Surface *surface, int x, int y) {
Common::Rect screenRect(getWorld()->xLeft, getWorld()->yTop, getWorld()->xLeft + 640, getWorld()->yTop + 480);
Common::Rect animRect(x, y, x + surface->w, y + surface->h);
diff --git a/engines/asylum/system/screen.h b/engines/asylum/system/screen.h
index b82a1c39c3..ec2a53e075 100644
--- a/engines/asylum/system/screen.h
+++ b/engines/asylum/system/screen.h
@@ -123,6 +123,7 @@ public:
void copyToBackBuffer(byte *buffer, int32 pitch, int32 x, int32 y, uint32 width, uint32 height);
// Debug
+ void drawLine(int x0, int y0, int x1, int y1);
void copyToBackBufferClipped(Graphics::Surface *surface, int x, int y);
private:
Commit: 1150dcd7b31079b296dd3e09695b831044627078
https://github.com/scummvm/scummvm/commit/1150dcd7b31079b296dd3e09695b831044627078
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:44+02:00
Commit Message:
ASYLUM: Use Polygon contains function in Puzzle::hitTest instead of custom code
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@716 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/puzzles/puzzle.cpp
engines/asylum/resources/polygons.h
diff --git a/engines/asylum/puzzles/puzzle.cpp b/engines/asylum/puzzles/puzzle.cpp
index d34496e31b..743924b800 100644
--- a/engines/asylum/puzzles/puzzle.cpp
+++ b/engines/asylum/puzzles/puzzle.cpp
@@ -104,41 +104,15 @@ void Puzzle::exit() {
// Hit test functions
//////////////////////////////////////////////////////////////////////////
bool Puzzle::hitTest(const Common::Point *polygonPoint, Common::Point point, uint32 index) {
- uint32 counter = 0;
-
- for (uint32 i = index; i < index + 3; i++)
- if (Polygons::contains(point.x, point.y,
- polygonPoint[index + 1].x + point.x + 100, point.y,
- polygonPoint[i].x, polygonPoint[i].y,
- polygonPoint[i + 1].x, polygonPoint[i + 1].y))
- ++counter;
-
- if (Polygons::contains(point.x, point.y,
- polygonPoint[index + 1].x + point.x + 100, point.y,
- polygonPoint[index].x, polygonPoint[index].y,
- polygonPoint[index + 3].x, polygonPoint[index + 3].y))
- ++counter;
-
- return (counter & 1);
+ PolyDefinitions polygon(polygonPoint[index], polygonPoint[index + 1], polygonPoint[index + 2], polygonPoint[index + 3]);
+
+ return polygon.contains(point);
}
bool Puzzle::hitTest(const Common::Point *polygonPoint, Common::Point point) {
- uint32 counter = 0;
-
- for (uint32 i = 3; i > 1; i--)
- if (Polygons::contains(point.x, point.y,
- polygonPoint[1].x + point.x + 700, point.y,
- polygonPoint[i].x, polygonPoint[i].y,
- polygonPoint[i + 1].x, polygonPoint[i + 1].y))
- ++counter;
-
- if (Polygons::contains(point.x, point.y,
- polygonPoint[0].x + point.x + 100, point.y,
- polygonPoint[0].x, polygonPoint[0].y,
- polygonPoint[3].x, polygonPoint[3].y))
- ++counter;
-
- return (counter & 1);
+ PolyDefinitions polygon(polygonPoint[0], polygonPoint[1], polygonPoint[2], polygonPoint[3]);
+
+ return polygon.contains(point);
}
} // end of namespace Asylum
diff --git a/engines/asylum/resources/polygons.h b/engines/asylum/resources/polygons.h
index a60ec12f44..55c029ea08 100644
--- a/engines/asylum/resources/polygons.h
+++ b/engines/asylum/resources/polygons.h
@@ -38,6 +38,14 @@ typedef struct PolyDefinitions {
Common::Array<Common::Point> points;
Common::Rect boundingRect;
+ PolyDefinitions() {};
+ PolyDefinitions(Common::Point point1, Common::Point point2, Common::Point point3, Common::Point point4) {
+ points.push_back(point1);
+ points.push_back(point2);
+ points.push_back(point3);
+ points.push_back(point4);
+ }
+
/**
* Check if the x/y coordinates exist within
* the current polygon definition
Commit: 9663342e0da251aafd8dac6649debc716a4c46db
https://github.com/scummvm/scummvm/commit/9663342e0da251aafd8dac6649debc716a4c46db
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:44+02:00
Commit Message:
ASYLUM: More work on Tic Tac Toe puzzle
- Implement parts of PuzzleTicTacToe::drawField()
- Fix polygon check in PuzzleTicTacToe::mouseLeft()
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@717 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/puzzles/tictactoe.cpp
engines/asylum/puzzles/tictactoe.h
diff --git a/engines/asylum/puzzles/tictactoe.cpp b/engines/asylum/puzzles/tictactoe.cpp
index e1521f0c8c..8c33a2d025 100644
--- a/engines/asylum/puzzles/tictactoe.cpp
+++ b/engines/asylum/puzzles/tictactoe.cpp
@@ -36,25 +36,18 @@
namespace Asylum {
+extern int32 g_debugPolygons;
+
const Common::Point puzzleTicTacToePolygons[36] = {
- Common::Point( 27, 381), Common::Point(172, 368),
- Common::Point(190, 474), Common::Point( 36, 476),
- Common::Point(176, 362), Common::Point(294, 328),
- Common::Point(331, 456), Common::Point(191, 472),
- Common::Point(304, 327), Common::Point(426, 306),
- Common::Point(457, 440), Common::Point(340, 460),
- Common::Point( 26, 257), Common::Point(151, 238),
- Common::Point(169, 356), Common::Point( 27, 373),
- Common::Point(162, 234), Common::Point(275, 214),
- Common::Point(299, 321), Common::Point(173, 355),
- Common::Point(283, 210), Common::Point(403, 173),
- Common::Point(437, 294), Common::Point(305, 317),
- Common::Point( 22, 120), Common::Point(132, 126),
- Common::Point(146, 223), Common::Point( 25, 247),
- Common::Point(144, 119), Common::Point(247, 87),
- Common::Point(268, 205), Common::Point(159, 222),
- Common::Point(259, 84), Common::Point(380, 73),
- Common::Point(405, 169), Common::Point(281, 201)
+ Common::Point( 27, 381), Common::Point(172, 368), Common::Point(190, 474), Common::Point( 36, 476),
+ Common::Point(176, 362), Common::Point(294, 328), Common::Point(331, 456), Common::Point(191, 472),
+ Common::Point(304, 327), Common::Point(426, 306), Common::Point(457, 440), Common::Point(340, 460),
+ Common::Point( 26, 257), Common::Point(151, 238), Common::Point(169, 356), Common::Point( 27, 373),
+ Common::Point(162, 234), Common::Point(275, 214), Common::Point(299, 321), Common::Point(173, 355),
+ Common::Point(283, 210), Common::Point(403, 173), Common::Point(437, 294), Common::Point(305, 317),
+ Common::Point( 22, 120), Common::Point(132, 126), Common::Point(146, 223), Common::Point( 25, 247),
+ Common::Point(144, 119), Common::Point(247, 87), Common::Point(268, 205), Common::Point(159, 222),
+ Common::Point(259, 84), Common::Point(380, 73), Common::Point(405, 169), Common::Point(281, 201)
};
const Common::Point puzzleTicTacToePositions[9] = {
@@ -76,7 +69,7 @@ static const struct {
uint32 strikeOutPositionX;
uint32 strikeOutPositionO;
uint32 frameCount;
-} fieldsToCheck[8] = {
+} puzzleTicTacToeFieldsToCheck[8] = {
{0, 1, 2, 1, 9, 14},
{3, 4, 5, 2, 10, 14},
{6, 7, 8, 3, 11, 14},
@@ -100,7 +93,7 @@ PuzzleTicTacToe::PuzzleTicTacToe(AsylumEngine *engine) : Puzzle(engine) {
memset(&_field, 0, sizeof(_field));
_emptyCount = 0;
- _var5 = 0;
+ _counter = 0;
}
PuzzleTicTacToe::~PuzzleTicTacToe() {
@@ -208,8 +201,8 @@ void PuzzleTicTacToe::mouseLeft() {
return;
}
- for (uint32 i = 0; i < ARRAYSIZE(puzzleTicTacToePolygons) - 2; i++) {
- if (hitTest(&puzzleTicTacToePolygons[i], mousePos, 0)) {
+ for (uint32 i = 0; i < ARRAYSIZE(_gameField); i++) {
+ if (hitTest(&puzzleTicTacToePolygons[i * 4], mousePos, 0)) {
if (_gameField[i] == ' ') {
getSound()->playSound(getWorld()->soundResourceIds[11], false, Config.sfxVolume - 100);
_gameField[i] = 'X';
@@ -230,7 +223,49 @@ void PuzzleTicTacToe::initField() {
}
void PuzzleTicTacToe::drawField() {
- warning("[PuzzleTicTacToe::updateField] Not implemented!");
+ if (_counter > 0) {
+ --_counter;
+
+ if (_counter < 2) {
+ getCursor()->show();
+ exit();
+ _counter = 0;
+ return;
+ }
+
+ }
+
+ if (g_debugPolygons) {
+ for (uint32 p = 0; p < ARRAYSIZE(puzzleTicTacToePolygons); p += 4) {
+ getScreen()->drawLine(puzzleTicTacToePolygons[p].x, puzzleTicTacToePolygons[p].y, puzzleTicTacToePolygons[p + 1].x, puzzleTicTacToePolygons[p + 1].y);
+ getScreen()->drawLine(puzzleTicTacToePolygons[p + 1].x, puzzleTicTacToePolygons[p + 1].y, puzzleTicTacToePolygons[p + 2].x, puzzleTicTacToePolygons[p + 2].y);
+ getScreen()->drawLine(puzzleTicTacToePolygons[p + 2].x, puzzleTicTacToePolygons[p + 2].y, puzzleTicTacToePolygons[p + 3].x, puzzleTicTacToePolygons[p + 3].y);
+ getScreen()->drawLine(puzzleTicTacToePolygons[p + 3].x, puzzleTicTacToePolygons[p + 3].y, puzzleTicTacToePolygons[p].x, puzzleTicTacToePolygons[p].y);
+ }
+ }
+
+ for (uint32 i = 0; i < ARRAYSIZE(puzzleTicTacToePositions); i++) {
+ char mark = _gameField[i];
+ Common::Point point = puzzleTicTacToePositions[i];
+
+ if (_lastMarkedField = i) {
+
+ } else {
+ if (mark == 'O')
+ getScreen()->draw(getWorld()->graphicResourceIds[2], 12, point.x, point.y, 0);
+ else if (mark == 'X')
+ getScreen()->draw(getWorld()->graphicResourceIds[1], 14, point.x, point.y, 0);
+ }
+ }
+
+ if (_lastMarkedField == -1 && checkWinner())
+ _needToInitialize = true;
+
+ if (_strikeOutPosition > 0 && !_ticker) {
+
+ }
+
+ //getScreen()->draw(getWorld()->graphicResourceIds[17], 0, 0, 0, 0);
}
void PuzzleTicTacToe::updatePositions(uint32 field1, uint32 field2, uint32 field3) {
@@ -268,7 +303,7 @@ bool PuzzleTicTacToe::check() {
&& !checkFieldsUpdatePositions()
&& !checkFields()
&& !countEmptyFields()) {
- if (!_var5)
+ if (!_counter)
getCursor()->show();
_needToInitialize = true;
@@ -321,9 +356,9 @@ bool PuzzleTicTacToe::checkFieldsUpdatePositions() {
uint32 counterX = 0;
uint32 counterO = 0;
- for (uint32 i = 0; i < ARRAYSIZE(fieldsToCheck) - 1; i++)
- if (checkField(fieldsToCheck[i].field1, fieldsToCheck[i].field2, fieldsToCheck[i].field3, 'O', &counterX, &counterO) == kStatusFree)
- updatePositions(fieldsToCheck[i].field1, fieldsToCheck[i].field2, fieldsToCheck[i].field3);
+ for (uint32 i = 0; i < ARRAYSIZE(puzzleTicTacToeFieldsToCheck); i++)
+ if (checkField(puzzleTicTacToeFieldsToCheck[i].field1, puzzleTicTacToeFieldsToCheck[i].field2, puzzleTicTacToeFieldsToCheck[i].field3, 'O', &counterX, &counterO) == kStatusFree)
+ updatePositions(puzzleTicTacToeFieldsToCheck[i].field1, puzzleTicTacToeFieldsToCheck[i].field2, puzzleTicTacToeFieldsToCheck[i].field3);
return (_emptyCount != 0);
}
@@ -332,15 +367,15 @@ bool PuzzleTicTacToe::checkFields() {
uint32 counterX = 0;
uint32 counterO = 0;
- for (uint32 i = 0; i < ARRAYSIZE(fieldsToCheck) - 1; i++) {
- checkField(fieldsToCheck[i].field1, fieldsToCheck[i].field2, fieldsToCheck[i].field3, 'O', &counterX, &counterO);
+ for (uint32 i = 0; i < ARRAYSIZE(puzzleTicTacToeFieldsToCheck); i++) {
+ checkField(puzzleTicTacToeFieldsToCheck[i].field1, puzzleTicTacToeFieldsToCheck[i].field2, puzzleTicTacToeFieldsToCheck[i].field3, 'O', &counterX, &counterO);
if (counterX || counterO)
continue;
_field[_emptyCount] = 0;
- _field[_emptyCount + 1] = fieldsToCheck[i].field3;
- _field[_emptyCount + 2] = fieldsToCheck[i].field2;
+ _field[_emptyCount + 1] = puzzleTicTacToeFieldsToCheck[i].field3;
+ _field[_emptyCount + 2] = puzzleTicTacToeFieldsToCheck[i].field2;
_emptyCount += 3;
}
@@ -381,19 +416,19 @@ int32 PuzzleTicTacToe::checkWinnerHelper() {
uint32 counterX = 0;
uint32 counterO = 0;
- for (uint32 i = 0; i < ARRAYSIZE(fieldsToCheck) - 1; i++) {
- checkField(fieldsToCheck[i].field1, fieldsToCheck[i].field2, fieldsToCheck[i].field3, 'O', &counterX, &counterO);
+ for (uint32 i = 0; i < ARRAYSIZE(puzzleTicTacToeFieldsToCheck); i++) {
+ checkField(puzzleTicTacToeFieldsToCheck[i].field1, puzzleTicTacToeFieldsToCheck[i].field2, puzzleTicTacToeFieldsToCheck[i].field3, 'O', &counterX, &counterO);
if (counterX == 3) {
- _strikeOutPosition = fieldsToCheck[i].strikeOutPositionX;
- _frameCount = fieldsToCheck[i].frameCount;
+ _strikeOutPosition = puzzleTicTacToeFieldsToCheck[i].strikeOutPositionX;
+ _frameCount = puzzleTicTacToeFieldsToCheck[i].frameCount;
_frameIndex = 0;
return 1;
}
if (counterO == 3) {
- _strikeOutPosition = fieldsToCheck[i].strikeOutPositionO;
- _frameCount = fieldsToCheck[i].frameCount;
+ _strikeOutPosition = puzzleTicTacToeFieldsToCheck[i].strikeOutPositionO;
+ _frameCount = puzzleTicTacToeFieldsToCheck[i].frameCount;
_frameIndex = 0;
return -1;
}
@@ -407,9 +442,9 @@ bool PuzzleTicTacToe::checkWinning(char mark) {
uint32 counterO = 0;
_emptyCount = 0;
- for (uint32 i = 0; i < ARRAYSIZE(fieldsToCheck) - 1; i++) {
- if (checkField(fieldsToCheck[i].field1, fieldsToCheck[i].field2, fieldsToCheck[i].field3, 'O', &counterX, &counterO) == kStatusNeedBlocking) {
- _field[_emptyCount] = checkPosition(fieldsToCheck[i].field1, fieldsToCheck[i].field2, fieldsToCheck[i].field3);
+ for (uint32 i = 0; i < ARRAYSIZE(puzzleTicTacToeFieldsToCheck); i++) {
+ if (checkField(puzzleTicTacToeFieldsToCheck[i].field1, puzzleTicTacToeFieldsToCheck[i].field2, puzzleTicTacToeFieldsToCheck[i].field3, 'O', &counterX, &counterO) == kStatusNeedBlocking) {
+ _field[_emptyCount] = checkPosition(puzzleTicTacToeFieldsToCheck[i].field1, puzzleTicTacToeFieldsToCheck[i].field2, puzzleTicTacToeFieldsToCheck[i].field3);
++_emptyCount;
}
}
diff --git a/engines/asylum/puzzles/tictactoe.h b/engines/asylum/puzzles/tictactoe.h
index bcedc42c61..cbd51c4695 100644
--- a/engines/asylum/puzzles/tictactoe.h
+++ b/engines/asylum/puzzles/tictactoe.h
@@ -51,7 +51,7 @@ private:
bool _needToInitialize;
int32 _strikeOutPosition;
- uint32 _var5;
+ uint32 _counter;
char _gameField[9];
uint32 _field[40];
Commit: 5e77b91caac0b9c976a7a72140f88f96161078af
https://github.com/scummvm/scummvm/commit/5e77b91caac0b9c976a7a72140f88f96161078af
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:44+02:00
Commit Message:
ASYLUM: Finish implementation of PuzzleTicTacToe::drawField()
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@718 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/puzzles/tictactoe.cpp
engines/asylum/puzzles/tictactoe.h
diff --git a/engines/asylum/puzzles/tictactoe.cpp b/engines/asylum/puzzles/tictactoe.cpp
index 8c33a2d025..bf1ab24c17 100644
--- a/engines/asylum/puzzles/tictactoe.cpp
+++ b/engines/asylum/puzzles/tictactoe.cpp
@@ -74,10 +74,10 @@ static const struct {
{3, 4, 5, 2, 10, 14},
{6, 7, 8, 3, 11, 14},
{0, 3, 6, 4, 12, 10},
- {4, 1, 7, 5, 13, 10},
{8, 5, 2, 6, 14, 10},
- {4, 6, 2, 7, 15, 4},
- {0, 4, 8, 8, 16, 4}
+ {0, 4, 8, 8, 16, 4},
+ {4, 1, 7, 5, 13, 10},
+ {4, 6, 2, 7, 15, 4}
};
PuzzleTicTacToe::PuzzleTicTacToe(AsylumEngine *engine) : Puzzle(engine) {
@@ -94,6 +94,7 @@ PuzzleTicTacToe::PuzzleTicTacToe(AsylumEngine *engine) : Puzzle(engine) {
_emptyCount = 0;
_counter = 0;
+ _counter2 = 0;
}
PuzzleTicTacToe::~PuzzleTicTacToe() {
@@ -219,6 +220,7 @@ void PuzzleTicTacToe::mouseLeft() {
// Init & update
//////////////////////////////////////////////////////////////////////////
void PuzzleTicTacToe::initField() {
+ _counter2 = 0;
memset(&_gameField, 32, sizeof(_gameField)); // ' ' == 32
}
@@ -232,7 +234,6 @@ void PuzzleTicTacToe::drawField() {
_counter = 0;
return;
}
-
}
if (g_debugPolygons) {
@@ -244,12 +245,35 @@ void PuzzleTicTacToe::drawField() {
}
}
- for (uint32 i = 0; i < ARRAYSIZE(puzzleTicTacToePositions); i++) {
+ // Draw X & O
+ for (int32 i = 0; i < ARRAYSIZE(puzzleTicTacToePositions); i++) {
char mark = _gameField[i];
Common::Point point = puzzleTicTacToePositions[i];
- if (_lastMarkedField = i) {
+ if (_lastMarkedField == i) {
+ if (mark == 'O')
+ getScreen()->draw(getWorld()->graphicResourceIds[2], _frameIndex, point.x, point.y, 0);
+ else if (mark == 'X')
+ getScreen()->draw(getWorld()->graphicResourceIds[1], _frameIndex, point.x, point.y, 0);
+
+ // Update _frameIndex
+ ++_frameIndex;
+ if (_frameIndex > 14 && mark == 'X') {
+ _lastMarkedField = -1;
+ _frameIndex = 0;
+ _ticker = 1;
+
+ if (checkWinner())
+ _needToInitialize = 1;
+ }
+ if (_frameIndex > 12 && mark == 'O') {
+ _lastMarkedField = -1;
+ _frameIndex = 0;
+
+ if (!checkWinner() || !checkWinnerHelper())
+ getCursor()->show();
+ }
} else {
if (mark == 'O')
getScreen()->draw(getWorld()->graphicResourceIds[2], 12, point.x, point.y, 0);
@@ -261,11 +285,125 @@ void PuzzleTicTacToe::drawField() {
if (_lastMarkedField == -1 && checkWinner())
_needToInitialize = true;
+ // Draw strikeOut
if (_strikeOutPosition > 0 && !_ticker) {
+ switch (_strikeOutPosition) {
+ default:
+ break;
+
+ case 1:
+ getScreen()->draw(getWorld()->graphicResourceIds[5], _frameIndex, 38, 345, 0);
+ break;
+
+ case 2:
+ getScreen()->draw(getWorld()->graphicResourceIds[5], _frameIndex, 17, 226, 0);
+ break;
+
+ case 3:
+ getScreen()->draw(getWorld()->graphicResourceIds[5], _frameIndex, 1, 104, 0);
+ break;
+
+ case 4:
+ getScreen()->draw(getWorld()->graphicResourceIds[6], _frameIndex, 43, 117, 0);
+ break;
+
+ case 5:
+ getScreen()->draw(getWorld()->graphicResourceIds[6], _frameIndex, 176, 104, 0);
+ break;
+
+ case 6:
+ getScreen()->draw(getWorld()->graphicResourceIds[6], _frameIndex, 299, 85, 0);
+ break;
+
+ case 7:
+ if (_counter2 == 0)
+ getScreen()->draw(getWorld()->graphicResourceIds[8], _frameIndex, 30, 149, 0);
+ else if (_counter2 == 1)
+ getScreen()->draw(getWorld()->graphicResourceIds[8], _frameIndex, 180, 249, 0);
+ else {
+ getScreen()->draw(getWorld()->graphicResourceIds[8], 6, 30, 149, 0);
+ getScreen()->draw(getWorld()->graphicResourceIds[8], 6, 180, 249, 0);
+ getScreen()->draw(getWorld()->graphicResourceIds[8], _frameIndex, 330, 349, 0);
+ }
+ break;
+
+ case 8:
+ if (_counter2 == 0)
+ getScreen()->draw(getWorld()->graphicResourceIds[10], _frameIndex, 69, 66, 0);
+ else if (_counter2 == 1)
+ getScreen()->draw(getWorld()->graphicResourceIds[10], _frameIndex, -22, 220, 0);
+ else {
+ getScreen()->draw(getWorld()->graphicResourceIds[10], 6, 69, 66, 0);
+ getScreen()->draw(getWorld()->graphicResourceIds[10], 6, -22, 220, 0);
+ getScreen()->draw(getWorld()->graphicResourceIds[10], _frameIndex, -110, 370, 0);
+ }
+ break;
+
+ case 9:
+ getScreen()->draw(getWorld()->graphicResourceIds[4], _frameIndex, 38, 345, 0);
+ break;
+
+ case 10:
+ getScreen()->draw(getWorld()->graphicResourceIds[4], _frameIndex, 17, 226, 0);
+ break;
+
+ case 11:
+ getScreen()->draw(getWorld()->graphicResourceIds[4], _frameIndex, 1, 104, 0);
+ break;
+
+ case 12:
+ getScreen()->draw(getWorld()->graphicResourceIds[11], _frameIndex, 43, 117, 0);
+ break;
+
+ case 13:
+ getScreen()->draw(getWorld()->graphicResourceIds[11], _frameIndex, 176, 104, 0);
+ break;
+
+ case 14:
+ getScreen()->draw(getWorld()->graphicResourceIds[11], _frameIndex, 299, 85, 0);
+ break;
+
+ case 15:
+ if (_counter2 == 0)
+ getScreen()->draw(getWorld()->graphicResourceIds[7], _frameIndex, 30, 149, 0);
+ else if (_counter2 == 1)
+ getScreen()->draw(getWorld()->graphicResourceIds[7], _frameIndex, 180, 249, 0);
+ else {
+ getScreen()->draw(getWorld()->graphicResourceIds[7], 6, 30, 149, 0);
+ getScreen()->draw(getWorld()->graphicResourceIds[7], 6, 180, 249, 0);
+ getScreen()->draw(getWorld()->graphicResourceIds[7], _frameIndex, 330, 349, 0);
+ }
+ break;
+
+ case 16:
+ if (_counter2 == 0)
+ getScreen()->draw(getWorld()->graphicResourceIds[9], _frameIndex, 69, 66, 0);
+ else if (_counter2 == 1)
+ getScreen()->draw(getWorld()->graphicResourceIds[9], _frameIndex, -22, 220, 0);
+ else {
+ getScreen()->draw(getWorld()->graphicResourceIds[9], 6, 69, 66, 0);
+ getScreen()->draw(getWorld()->graphicResourceIds[9], 6, -22, 220, 0);
+ getScreen()->draw(getWorld()->graphicResourceIds[9], _frameIndex, -110, 370, 0);
+ }
+ break;
+ }
+
+ if (_frameIndex >= _frameCount) {
+ if (_strikeOutPosition == 7 || _strikeOutPosition == 8 || _strikeOutPosition == 15 || _strikeOutPosition == 16) {
+ if (_counter2 < 2) {
+ _frameIndex = 0;
+ ++_counter2;
+ }
+ }
+ } else {
+ ++_frameIndex;
+ }
+ if (!_counter)
+ _counter = 30;
}
- //getScreen()->draw(getWorld()->graphicResourceIds[17], 0, 0, 0, 0);
+ getScreen()->draw(getWorld()->graphicResourceIds[17], 0, 0, 0, 0);
}
void PuzzleTicTacToe::updatePositions(uint32 field1, uint32 field2, uint32 field3) {
@@ -373,9 +511,9 @@ bool PuzzleTicTacToe::checkFields() {
if (counterX || counterO)
continue;
- _field[_emptyCount] = 0;
- _field[_emptyCount + 1] = puzzleTicTacToeFieldsToCheck[i].field3;
- _field[_emptyCount + 2] = puzzleTicTacToeFieldsToCheck[i].field2;
+ _field[_emptyCount] = puzzleTicTacToeFieldsToCheck[i].field1;
+ _field[_emptyCount + 1] = puzzleTicTacToeFieldsToCheck[i].field2;
+ _field[_emptyCount + 2] = puzzleTicTacToeFieldsToCheck[i].field3;
_emptyCount += 3;
}
@@ -467,7 +605,11 @@ bool PuzzleTicTacToe::countEmptyFields() {
void PuzzleTicTacToe::placeOpponentMark() {
_frameIndex = 0;
- _lastMarkedField = _field[rnd(_emptyCount)];
+ _lastMarkedField = _field[rnd(_emptyCount - 1)];
+
+ if (_gameField[_lastMarkedField] != ' ')
+ error("[PuzzleTicTacToe::placeOpponentMark] Field is already occupied (%d)!", _lastMarkedField);
+
_gameField[_lastMarkedField] = 'O';
getSound()->playSound(getWorld()->soundResourceIds[12], false, Config.sfxVolume - 100);
diff --git a/engines/asylum/puzzles/tictactoe.h b/engines/asylum/puzzles/tictactoe.h
index cbd51c4695..0fc0686a35 100644
--- a/engines/asylum/puzzles/tictactoe.h
+++ b/engines/asylum/puzzles/tictactoe.h
@@ -52,6 +52,7 @@ private:
int32 _strikeOutPosition;
uint32 _counter;
+ uint32 _counter2;
char _gameField[9];
uint32 _field[40];
Commit: f1702ca26059824e239453a884595dca2359bef9
https://github.com/scummvm/scummvm/commit/f1702ca26059824e239453a884595dca2359bef9
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:44+02:00
Commit Message:
ASYLUM: Fix proper cursor not showing in Tic Tac Toe puzzle
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@719 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/puzzles/tictactoe.cpp
diff --git a/engines/asylum/puzzles/tictactoe.cpp b/engines/asylum/puzzles/tictactoe.cpp
index bf1ab24c17..f9cfb1c40f 100644
--- a/engines/asylum/puzzles/tictactoe.cpp
+++ b/engines/asylum/puzzles/tictactoe.cpp
@@ -116,7 +116,7 @@ bool PuzzleTicTacToe::init() {
getScreen()->setGammaLevel(getWorld()->graphicResourceIds[3], 0);
getCursor()->show();
- getCursor()->set(getWorld()->graphicResourceIds[12], 4, kCursorAnimationLinear);
+ getCursor()->set(getWorld()->graphicResourceIds[12], 4, kCursorAnimationLinear, 4);
initField();
Commit: 73d6f33c5758e6b7cbd2f3af562c332cd1a6bbf9
https://github.com/scummvm/scummvm/commit/73d6f33c5758e6b7cbd2f3af562c332cd1a6bbf9
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:44+02:00
Commit Message:
ASYLUM: Check for valid sound resource before playing music
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@720 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/system/sound.cpp
diff --git a/engines/asylum/system/sound.cpp b/engines/asylum/system/sound.cpp
index 519d3b8a9f..a86d586b78 100644
--- a/engines/asylum/system/sound.cpp
+++ b/engines/asylum/system/sound.cpp
@@ -100,6 +100,9 @@ void Sound::playMusic(ResourceId resourceId, int32 volume) {
if (_mixer->isSoundHandleActive(_musicHandle))
return;
+ if (!isValidSoundResource(resourceId))
+ return;
+
ResourceEntry *resource = getResource()->get(resourceId);
playSoundData(Audio::Mixer::kMusicSoundType, &_musicHandle, resource->data, resource->size, true, volume, 0);
}
Commit: d145f93a7c7d5972823877cdd23459a98a5cfbc1
https://github.com/scummvm/scummvm/commit/d145f93a7c7d5972823877cdd23459a98a5cfbc1
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:45+02:00
Commit Message:
ASYLUM: Use switchScene() when switching scenes through the debugger
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@721 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/asylum.cpp
diff --git a/engines/asylum/asylum.cpp b/engines/asylum/asylum.cpp
index 0d821cffb0..d4977f4303 100644
--- a/engines/asylum/asylum.cpp
+++ b/engines/asylum/asylum.cpp
@@ -199,6 +199,7 @@ void AsylumEngine::startGame(ResourcePackId sceneId, StartGameType type) {
// Reset scene (this ensures the current resource pack is closed as in the original)
delete _scene;
_scene = new Scene(this);
+ _handler = _scene;
// Original checks for the current cd (we have all data files on disc, so this is not needed)
@@ -234,6 +235,9 @@ void AsylumEngine::restart() {
memset(&_gameFlags, 0, sizeof(_gameFlags));
delete _scene;
_scene = NULL;
+ // TODO reset puzzle data
+ // TODO reset encounter data
+ _script->resetQueue();
_data.point.x = -1;
_data.point.y = -1;
@@ -376,16 +380,13 @@ void AsylumEngine::processDelayedEvents() {
// Reset delayed scene
_delayedSceneIndex = kResourcePackInvalid;
+ _scene->getActor(0)->updateStatus(kActorStatusDisabled);
+ _script->reset();
+
_sound->stopMusic();
_sound->stopAll();
- switchEventHandler(NULL);
-
- delete _scene;
- _scene = new Scene(this);
- _scene->enter(sceneIndex);
-
- switchEventHandler(_scene);
+ switchScene(sceneIndex);
}
// Check for delayed video
Commit: 2ec06b5da7420a4503b9c4236eaec4ad4e7a43f5
https://github.com/scummvm/scummvm/commit/2ec06b5da7420a4503b9c4236eaec4ad4e7a43f5
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:45+02:00
Commit Message:
ASYLUM: Use per-entry current line in script manager
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@722 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/resources/script.cpp
engines/asylum/resources/script.h
diff --git a/engines/asylum/resources/script.cpp b/engines/asylum/resources/script.cpp
index 536ef13004..5dfe16bd35 100644
--- a/engines/asylum/resources/script.cpp
+++ b/engines/asylum/resources/script.cpp
@@ -243,7 +243,6 @@ void ScriptManager::reset() {
_scripts.clear();
_skipProcessing = false;
- _currentLine = 0;
_currentLoops = 0;
_currentScript = NULL;
_done = false;
@@ -297,7 +296,7 @@ bool ScriptManager::process() {
while (!_done && !_waitCycle) {
_lineIncrement = 0; //Reset line increment value
- ScriptEntry *cmd = &_currentScript->commands[_currentLine];
+ ScriptEntry *cmd = &_currentScript->commands[_currentQueueEntry.currentLine];
int32 opcode = cmd->opcode;
@@ -313,11 +312,13 @@ bool ScriptManager::process() {
return true;
if (!_lineIncrement)
- _currentLine ++;
+ ++_currentQueueEntry.currentLine;
+
+
}
if (_done) {
- _currentLine = 0;
+ _currentQueueEntry.currentLine = 0;
if (!_queue.empty()) {
_currentQueueEntry = _queue.pop();
@@ -408,9 +409,10 @@ IMPLEMENT_OPCODE(PlayAnimation)
Object *object = getWorld()->getObjectById((ObjectId)cmd->param1);
if (cmd->param2 == 2) {
- if (object->checkFlags())
+ if (object->checkFlags()) {
+ _waitCycle = true;
_lineIncrement = 1;
- else
+ } else
cmd->param2 = 1;
return;
@@ -581,7 +583,7 @@ IMPLEMENT_OPCODE(JumpActorSpeech)
if (actor->process(cmd->param2, cmd->param3))
return;
- _currentLine = cmd->param4;
+ _currentQueueEntry.currentLine = cmd->param4;
if (cmd->param5)
getSpeech()->playIndexed(1);
@@ -805,7 +807,7 @@ IMPLEMENT_OPCODE(JumpIfActorField638)
Actor *actor = getScene()->getActor(cmd->param1);
if (actor->getField638())
- _currentLine = cmd->param3;
+ _currentQueueEntry.currentLine = cmd->param3;
END_OPCODE
//////////////////////////////////////////////////////////////////////////
@@ -1026,7 +1028,7 @@ END_OPCODE
//////////////////////////////////////////////////////////////////////////
// Opcode 0x36
IMPLEMENT_OPCODE(Jump)
- _currentLine = cmd->param1 - 1;
+ _currentQueueEntry.currentLine = cmd->param1 - 1;
END_OPCODE
//////////////////////////////////////////////////////////////////////////
@@ -1037,7 +1039,7 @@ IMPLEMENT_OPCODE(RunBlowUpPuzzle)
_vm->switchEventHandler(_vm->getPuzzle((uint32)cmd->param1));
- _currentLine++;
+ _currentQueueEntry.currentLine++;
_exit = true;
END_OPCODE
@@ -1073,7 +1075,7 @@ IMPLEMENT_OPCODE(_unk3B_PALETTE_MOD)
cmd->param1 = 0;
cmd->param2 = 0;
- _currentLine++;
+ _currentQueueEntry.currentLine++;
getScreen()->clearGraphicsInQueue();
@@ -1141,7 +1143,7 @@ IMPLEMENT_OPCODE(JumpIfActor)
ActorIndex index = (cmd->param1 == kActorInvalid) ? getScene()->getPlayerIndex() : cmd->param1;
if (_currentQueueEntry.actorIndex != index)
- _currentLine = cmd->param2 - 1;
+ _currentQueueEntry.currentLine = cmd->param2 - 1;
END_OPCODE
//////////////////////////////////////////////////////////////////////////
@@ -1440,10 +1442,10 @@ END_OPCODE
IMPLEMENT_OPCODE(JumpIfSoundPlaying)
if (cmd->param3 == 1) {
if (_vm->sound()->isPlaying((ResourceId)cmd->param1)) {
- _currentLine = cmd->param2;
+ _currentQueueEntry.currentLine = cmd->param2;
}
} else if (!_vm->sound()->isPlaying((ResourceId)cmd->param1)) {
- _currentLine = cmd->param2;
+ _currentQueueEntry.currentLine = cmd->param2;
}
END_OPCODE
@@ -1608,7 +1610,7 @@ IMPLEMENT_OPCODE(_unk56)
getScene()->getActor()->faceTarget((ObjectId)cmd->param1, kDirectionFromActor);
actor->updateFromDirection((ActorDirection)((actor->getDirection() + 4) & 7));
} else {
- _currentLine = cmd->param3;
+ _currentQueueEntry.currentLine = cmd->param3;
}
} else {
int32 x = 0;
@@ -1627,7 +1629,7 @@ IMPLEMENT_OPCODE(_unk56)
if (cmd->param4)
getSpeech()->playIndexed(1);
- _currentLine = cmd->param3;
+ _currentQueueEntry.currentLine = cmd->param3;
}
}
END_OPCODE
@@ -1953,7 +1955,7 @@ void ScriptManager::setNextLine(int32 line) {
int32 opcode = _currentScript->commands[line].opcode;
if (opcode == 0x10 || opcode == 0) { // Return
- _currentLine = line;
+ _currentQueueEntry.currentLine = line;
} else {
_done = true;
}
diff --git a/engines/asylum/resources/script.h b/engines/asylum/resources/script.h
index 1395f52b03..64e63479af 100644
--- a/engines/asylum/resources/script.h
+++ b/engines/asylum/resources/script.h
@@ -215,7 +215,18 @@ private:
typedef struct ScriptQueueEntry {
int32 scriptIndex;
+ int32 currentLine;
ActorIndex actorIndex;
+ int32 field_C;
+ int32 field_10;
+
+ ScriptQueueEntry() {
+ scriptIndex = 0;
+ currentLine = 0;
+ actorIndex = 0;
+ field_C = 0;
+ field_10 = 0;
+ }
} ScriptQueueEntry;
// Opcodes
@@ -244,7 +255,6 @@ private:
Common::Array<Script> _scripts;
bool _skipProcessing;
- int32 _currentLine;
int32 _currentLoops;
Script *_currentScript;
ScriptQueueEntry _currentQueueEntry;
Commit: ec57d4bca7660552d2974d88b34ec3d22b456025
https://github.com/scummvm/scummvm/commit/ec57d4bca7660552d2974d88b34ec3d22b456025
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:45+02:00
Commit Message:
ASYLUM: Implement parts of Fisherman puzzle
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@723 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/puzzles/fisherman.cpp
engines/asylum/puzzles/fisherman.h
engines/asylum/shared.h
diff --git a/engines/asylum/puzzles/fisherman.cpp b/engines/asylum/puzzles/fisherman.cpp
index ff9ff92a3c..3422741be1 100644
--- a/engines/asylum/puzzles/fisherman.cpp
+++ b/engines/asylum/puzzles/fisherman.cpp
@@ -25,27 +25,108 @@
#include "asylum/puzzles/fisherman.h"
+#include "asylum/resources/worldstats.h"
+
+#include "asylum/system/cursor.h"
+#include "asylum/system/screen.h"
+
+#include "asylum/views/scene.h"
+
+#include "asylum/asylum.h"
+
namespace Asylum {
PuzzleFisherman::PuzzleFisherman(AsylumEngine *engine) : Puzzle(engine) {
+ memset(&_state, 0, sizeof(_state));
+
+ _dword_45AAD4 = false;
+ _counter = 0;
+
+ _dword_45A130 = false;
+
}
PuzzleFisherman::~PuzzleFisherman() {
}
+//////////////////////////////////////////////////////////////////////////
+// Reset
+//////////////////////////////////////////////////////////////////////////
+void PuzzleFisherman::reset() {
+ memset(&_state, 0, sizeof(_state));
+ _dword_45AAD4 = false;
+
+ // Original setups polygons here
+
+ _dword_45A130 = false;
+ _counter = 0;
+
+ // TODO update scene fields
+}
+
//////////////////////////////////////////////////////////////////////////
// Event Handling
//////////////////////////////////////////////////////////////////////////
bool PuzzleFisherman::init() {
- error("[PuzzleFisherman::init] Not implemented!");
+ getCursor()->set(getWorld()->graphicResourceIds[47], -1, kCursorAnimationMirror, 7);
+
+ for (uint32 i = 0; i < ARRAYSIZE(_state); i++)
+ if (_vm->isGameFlagNotSet((GameFlag)(kGameFlag801 + i)))
+ _state[i] = 0;
+
+ if (_counter == 6) {
+ _vm->clearGameFlag(kGameFlag619);
+ _counter = 0;
+ }
+
+ _dword_45A130 = false;
+ getScreen()->setPalette(getWorld()->graphicResourceIds[39]);
+ getScreen()->setGammaLevel(getWorld()->graphicResourceIds[39], 0);
+
+ return mouseDown();
}
bool PuzzleFisherman::update() {
error("[PuzzleFisherman::update] Not implemented!");
}
+bool PuzzleFisherman::key(const AsylumEvent &evt) {
+ switch (evt.kbd.keycode) {
+ default:
+ _vm->switchEventHandler(getScene());
+ break;
+
+ case Common::KEYCODE_TAB:
+ getScreen()->takeScreenshot();
+ break;
+ }
+
+ return false;
+}
+
bool PuzzleFisherman::mouse(const AsylumEvent &evt) {
- error("[PuzzleFisherman::mouse] Not implemented!");
+ switch (evt.type) {
+ case Common::EVENT_LBUTTONDOWN:
+ return mouseDown();
+ break;
+
+ case Common::EVENT_RBUTTONDOWN:
+ getCursor()->hide();
+ getSharedData()->setFlag(kFlag1, true);
+ getScreen()->setupPaletteAndStartFade(0, 0, 0);
+
+ _vm->switchEventHandler(getScene());
+ break;
+ }
+
+ return false;
+}
+
+bool PuzzleFisherman::mouseDown() {
+ if (!_dword_45A130)
+ return false;
+
+ error("[PuzzleFisherman::mouseDown] Not implemented!");
}
} // End of namespace Asylum
diff --git a/engines/asylum/puzzles/fisherman.h b/engines/asylum/puzzles/fisherman.h
index a753711b15..fc6488d288 100644
--- a/engines/asylum/puzzles/fisherman.h
+++ b/engines/asylum/puzzles/fisherman.h
@@ -37,13 +37,24 @@ public:
PuzzleFisherman(AsylumEngine *engine);
~PuzzleFisherman();
+ void reset();
+
private:
+ uint32 _state[6];
+ int32 _counter;
+
+ bool _dword_45A130;
+ bool _dword_45AAD4;
+
//////////////////////////////////////////////////////////////////////////
// Event Handling
//////////////////////////////////////////////////////////////////////////
bool init();
bool update();
+ bool key(const AsylumEvent &evt);
bool mouse(const AsylumEvent &evt);
+
+ bool mouseDown();
};
} // End of namespace Asylum
diff --git a/engines/asylum/shared.h b/engines/asylum/shared.h
index 5b03cc6b19..50269b5af9 100644
--- a/engines/asylum/shared.h
+++ b/engines/asylum/shared.h
@@ -100,10 +100,12 @@ enum GameFlag {
kGameFlag556 = 556,
kGameFlag560 = 560,
kGameFlag570 = 570,
+ kGameFlag619 = 619,
kGameFlag635 = 635,
kGameFlag636 = 636,
kGameFlag637 = 637,
kGameFlag776 = 776,
+ kGameFlag801 = 801,
kGameFlag815 = 815,
kGameFlag816 = 816,
kGameFlag817 = 817,
Commit: f5796088c0f530ab76e3ea64c75808f1efa18cc8
https://github.com/scummvm/scummvm/commit/f5796088c0f530ab76e3ea64c75808f1efa18cc8
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:45+02:00
Commit Message:
ASYLUM: Implement rest of Fisherman puzzle
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@724 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/puzzles/fisherman.cpp
engines/asylum/puzzles/fisherman.h
engines/asylum/shared.h
diff --git a/engines/asylum/puzzles/fisherman.cpp b/engines/asylum/puzzles/fisherman.cpp
index 3422741be1..27208a7bbb 100644
--- a/engines/asylum/puzzles/fisherman.cpp
+++ b/engines/asylum/puzzles/fisherman.cpp
@@ -36,14 +36,25 @@
namespace Asylum {
+const Common::Point puzzleFishermanPolygons[31] = {
+ Common::Point( 10, 53), Common::Point(113, 52), Common::Point(222, 46), Common::Point(328, 51),
+ Common::Point(426, 51), Common::Point(523, 49), Common::Point(277, 398), Common::Point( 30, 44),
+ Common::Point(112, 44), Common::Point( 93, 400), Common::Point( 0, 400), Common::Point(130, 44),
+ Common::Point(210, 44), Common::Point(201, 400), Common::Point(112, 400), Common::Point(224, 44),
+ Common::Point(315, 44), Common::Point(309, 400), Common::Point(219, 400), Common::Point(326, 44),
+ Common::Point(411, 44), Common::Point(415, 400), Common::Point(326, 400), Common::Point(422, 44),
+ Common::Point(506, 44), Common::Point(526, 400), Common::Point(434, 400), Common::Point(523, 44),
+ Common::Point(607, 44), Common::Point(640, 400), Common::Point(545, 400)
+};
+
PuzzleFisherman::PuzzleFisherman(AsylumEngine *engine) : Puzzle(engine) {
memset(&_state, 0, sizeof(_state));
_dword_45AAD4 = false;
_counter = 0;
+ _dword_45A12C = 0;
_dword_45A130 = false;
-
}
PuzzleFisherman::~PuzzleFisherman() {
@@ -61,7 +72,11 @@ void PuzzleFisherman::reset() {
_dword_45A130 = false;
_counter = 0;
- // TODO update scene fields
+ // Original resets scene fields, but since we are called during a restart, the whole scene is recreated later anyway
+ /*for (uint32 i = 0; i < 6; i++) {
+ getWorld()->field_E8610[i] = 0;
+ getWorld()->field_E8628[i] = 0;
+ }*/
}
//////////////////////////////////////////////////////////////////////////
@@ -87,7 +102,52 @@ bool PuzzleFisherman::init() {
}
bool PuzzleFisherman::update() {
- error("[PuzzleFisherman::update] Not implemented!");
+ updateCursor();
+
+ // Draw background
+ getScreen()->clearGraphicsInQueue();
+ getScreen()->draw(getWorld()->graphicResourceIds[38]);
+
+ // Draw 7 graphics
+ for (uint32 i = 0; i < 7; i++) {
+ if (_state[i])
+ getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[40 + i], 0, puzzleFishermanPolygons[i], 0, 0, 1);
+ }
+
+ getScreen()->drawGraphicsInQueue();
+
+ _dword_45A130 = true;
+ getScreen()->copyBackBufferToScreen();
+
+ if (_dword_45AAD4 == 1) {
+ ++_dword_45A12C;
+
+ if (_dword_45A12C > 5) {
+ // Reset state
+ memset(&_state, 0, sizeof(_state));
+
+ for (uint32 i = 0; i < 6; i++)
+ _vm->clearGameFlag((GameFlag)(kGameFlag801 + i));
+
+ _dword_45A130 = true;
+ _dword_45A12C = 0;
+ }
+ }
+
+ if (_counter == 6) {
+ ++_dword_45A12C;
+
+ if (_dword_45A12C > 10) {
+ _dword_45A12C = 0;
+
+ _vm->setGameFlag(kGameFlag619);
+ getScreen()->setPalette(getWorld()->currentPaletteId);
+
+ _vm->switchEventHandler(getScene());
+ }
+ }
+
+ return true;
}
bool PuzzleFisherman::key(const AsylumEvent &evt) {
@@ -126,7 +186,111 @@ bool PuzzleFisherman::mouseDown() {
if (!_dword_45A130)
return false;
- error("[PuzzleFisherman::mouseDown] Not implemented!");
+ Common::Point mousePos = getCursor()->position();
+
+ for (uint32 i = 0; i < 7; i++) {
+ if (hitTest(&puzzleFishermanPolygons[i * 4 + 7], mousePos)) {
+ if (!_state[i]) {
+ getSound()->playSound(getWorld()->graphicResourceIds[9], false, Config.sfxVolume - 10);
+ _state[i] = true;
+ setFlags(i);
+ }
+ }
+ }
+
+ if (puzzleFishermanPolygons[6].x < mousePos.x
+ && puzzleFishermanPolygons[6].y < mousePos.y
+ && puzzleFishermanPolygons[6].x + 70 > mousePos.x
+ && puzzleFishermanPolygons[6].y + 30 > mousePos.y) {
+ getSound()->playSound(getWorld()->graphicResourceIds[10], false, Config.sfxVolume - 10);
+
+ for (uint32 i = 0; i < 6; i++)
+ _vm->clearGameFlag((GameFlag)(kGameFlag801 + i));
+
+ _dword_45AAD4 = true;
+ }
+
+ if (_dword_45AAD4)
+ _dword_45A130 = false;
+
+ return true;
+}
+
+//////////////////////////////////////////////////////////////////////////
+// Helpers
+//////////////////////////////////////////////////////////////////////////
+void PuzzleFisherman::updateCursor() {
+ Common::Point mousePos = getCursor()->position();
+ bool found = false;
+
+ for (uint32 i = 0; i < 6; i++) {
+ if (found)
+ break;
+
+ if (hitTest(&puzzleFishermanPolygons[i * 4 + 7], mousePos)) {
+ if (!_state[i]) {
+ found = true;
+
+ if (getCursor()->animation != kCursorAnimationMirror)
+ getCursor()->set(getWorld()->graphicResourceIds[47], -1, kCursorAnimationMirror, 7);
+ }
+ }
+ }
+
+ if (found)
+ return;
+
+ if (puzzleFishermanPolygons[6].x >= mousePos.x
+ || puzzleFishermanPolygons[6].y >= mousePos.y
+ || puzzleFishermanPolygons[6].x + 70 <= mousePos.x
+ || puzzleFishermanPolygons[6].y + 30 <= mousePos.y) {
+ if (getCursor()->animation != kCursorAnimationNone)
+ getCursor()->set(getWorld()->graphicResourceIds[47], -1, kCursorAnimationNone, 7);
+ else if (getCursor()->animation != kCursorAnimationMirror)
+ getCursor()->set(getWorld()->graphicResourceIds[47], -1, kCursorAnimationMirror, 7);
+ }
+}
+
+void PuzzleFisherman::setFlags(uint32 index) {
+ switch (index) {
+ default:
+ break;
+
+ case 0:
+ _vm->setGameFlag(kGameFlag801);
+ _counter = (_counter == 2) ? 3 : 0;
+ break;
+
+ case 1:
+ _vm->setGameFlag(kGameFlag802);
+ _counter = (_counter == 3) ? 4 : 0;
+ break;
+
+ case 2:
+ _vm->setGameFlag(kGameFlag803);
+ _counter = (_counter == 1) ? 2 : 0;
+ break;
+
+ case 3:
+ _vm->setGameFlag(kGameFlag804);
+ if (_counter == 5) {
+ _dword_45A130 = false;
+ _counter = 6;
+ } else {
+ _counter = 0;
+ }
+ break;
+
+ case 4:
+ _vm->setGameFlag(kGameFlag805);
+ _counter = (_counter == 0) ? 1 : 0;
+ break;
+
+ case 5:
+ _vm->setGameFlag(kGameFlag806);
+ _counter = (_counter == 4) ? 5 : 0;
+ break;
+ }
}
} // End of namespace Asylum
diff --git a/engines/asylum/puzzles/fisherman.h b/engines/asylum/puzzles/fisherman.h
index fc6488d288..68fd0a1976 100644
--- a/engines/asylum/puzzles/fisherman.h
+++ b/engines/asylum/puzzles/fisherman.h
@@ -40,9 +40,10 @@ public:
void reset();
private:
- uint32 _state[6];
+ bool _state[6];
int32 _counter;
+ int32 _dword_45A12C;
bool _dword_45A130;
bool _dword_45AAD4;
@@ -55,6 +56,12 @@ private:
bool mouse(const AsylumEvent &evt);
bool mouseDown();
+
+ //////////////////////////////////////////////////////////////////////////
+ // Helpers
+ //////////////////////////////////////////////////////////////////////////
+ void updateCursor();
+ void setFlags(uint32 index);
};
} // End of namespace Asylum
diff --git a/engines/asylum/shared.h b/engines/asylum/shared.h
index 50269b5af9..5191e0680e 100644
--- a/engines/asylum/shared.h
+++ b/engines/asylum/shared.h
@@ -106,6 +106,11 @@ enum GameFlag {
kGameFlag637 = 637,
kGameFlag776 = 776,
kGameFlag801 = 801,
+ kGameFlag802 = 802,
+ kGameFlag803 = 803,
+ kGameFlag804 = 804,
+ kGameFlag805 = 805,
+ kGameFlag806 = 806,
kGameFlag815 = 815,
kGameFlag816 = 816,
kGameFlag817 = 817,
Commit: 1ec34182d6bfe1f8847527f93330f7f8886790bc
https://github.com/scummvm/scummvm/commit/1ec34182d6bfe1f8847527f93330f7f8886790bc
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:45+02:00
Commit Message:
ASYLUM: Implement first part of Morgue Door puzzle
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@725 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/puzzles/morguedoor.cpp
engines/asylum/puzzles/morguedoor.h
diff --git a/engines/asylum/puzzles/morguedoor.cpp b/engines/asylum/puzzles/morguedoor.cpp
index 201a0bc3a7..1c4eb662cd 100644
--- a/engines/asylum/puzzles/morguedoor.cpp
+++ b/engines/asylum/puzzles/morguedoor.cpp
@@ -25,9 +25,29 @@
#include "asylum/puzzles/morguedoor.h"
+#include "asylum/resources/worldstats.h"
+
+#include "asylum/system/cursor.h"
+#include "asylum/system/graphics.h"
+#include "asylum/system/screen.h"
+
+#include "asylum/views/scene.h"
+
+#include "asylum/asylum.h"
+
namespace Asylum {
PuzzleMorgueDoor::PuzzleMorgueDoor(AsylumEngine *engine) : Puzzle(engine) {
+ memset(&_frameCounts, 0, sizeof(_frameCounts));
+ memset(&_frameIndexes, 0, sizeof(_frameIndexes));
+ _data_4572A4 = false;
+ _data_4572A8 = false;
+ _data_4572AC = false;
+ _data_4572B0 = false;
+
+ _flag1 = false;
+ _flag2 = false;
+ _flag3 = false;
}
PuzzleMorgueDoor::~PuzzleMorgueDoor() {
@@ -37,15 +57,162 @@ PuzzleMorgueDoor::~PuzzleMorgueDoor() {
// Event Handling
//////////////////////////////////////////////////////////////////////////
bool PuzzleMorgueDoor::init() {
- error("[PuzzleMorgueDoor::init] Not implemented!");
+ getCursor()->set(getWorld()->graphicResourceIds[33], -1, kCursorAnimationNone, 7);
+
+ _frameCounts[0] = GraphicResource::getFrameCount(_vm, getWorld()->graphicResourceIds[21]);
+ _frameCounts[1] = GraphicResource::getFrameCount(_vm, getWorld()->graphicResourceIds[22]);
+ _frameCounts[2] = GraphicResource::getFrameCount(_vm, getWorld()->graphicResourceIds[23]);
+ _frameCounts[3] = GraphicResource::getFrameCount(_vm, getWorld()->graphicResourceIds[24]);
+ _frameCounts[4] = GraphicResource::getFrameCount(_vm, getWorld()->graphicResourceIds[25]);
+ _frameCounts[5] = GraphicResource::getFrameCount(_vm, getWorld()->graphicResourceIds[26]);
+ _frameCounts[6] = GraphicResource::getFrameCount(_vm, getWorld()->graphicResourceIds[27]);
+ _frameCounts[7] = GraphicResource::getFrameCount(_vm, getWorld()->graphicResourceIds[28]);
+ _frameCounts[8] = GraphicResource::getFrameCount(_vm, getWorld()->graphicResourceIds[31]);
+ _frameCounts[9] = GraphicResource::getFrameCount(_vm, getWorld()->graphicResourceIds[32]);
+
+ getScreen()->setPalette(getWorld()->graphicResourceIds[20]);
+ getScreen()->setGammaLevel(getWorld()->graphicResourceIds[20], 0);
+
+ return mouseDown();
}
bool PuzzleMorgueDoor::update() {
- error("[PuzzleMorgueDoor::update] Not implemented!");
+ updateCursor();
+
+ // Draw elements
+ getScreen()->clearGraphicsInQueue();
+ getScreen()->draw(getWorld()->graphicResourceIds[19]);
+ getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[21], _frameIndexes[0], Common::Point(47, 0), 0, 0, 1);
+ getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[22], _frameIndexes[1], Common::Point(51, 236), 0, 0, 1);
+
+ if (_flag1)
+ getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[23], _frameIndexes[2], Common::Point(80, 0), 0, 0, 1);
+
+ if (_flag2)
+ getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[24], _frameIndexes[3], Common::Point(89, 230), 0, 0, 1);
+
+ getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[25], _frameIndexes[4], Common::Point(515, 41), 0, 0, 1);
+ getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[26], _frameIndexes[5], Common::Point(267, 190), 0, 0, 1);
+ getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[27], _frameIndexes[6], Common::Point(388, 105), 0, 0, 1);
+ getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[28], _frameIndexes[7], Common::Point(491, 143), 0, 0, 1);
+ getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[29], _frameIndexes[8], Common::Point(347, 124), 0, 0, 1);
+ getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[30], _frameIndexes[9], Common::Point(346, 339), 0, 0, 1);
+ getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[31], _frameIndexes[10], Common::Point(276, 67), 0, 0, 1);
+ getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[32], _frameIndexes[11], Common::Point(278, 378), 0, 0, 1);
+
+ getScreen()->drawGraphicsInQueue();
+ getScreen()->copyBackBufferToScreen();
+
+ return true;
+}
+
+bool PuzzleMorgueDoor::key(const AsylumEvent &evt) {
+ switch (evt.kbd.keycode) {
+ default:
+ _vm->switchEventHandler(getScene());
+ break;
+
+ case Common::KEYCODE_TAB:
+ getScreen()->takeScreenshot();
+ break;
+ }
+
+ return true;
}
bool PuzzleMorgueDoor::mouse(const AsylumEvent &evt) {
- error("[PuzzleMorgueDoor::mouse] Not implemented!");
+ switch (evt.type) {
+ case Common::EVENT_LBUTTONDOWN:
+ return mouseDown();
+ break;
+
+ case Common::EVENT_RBUTTONUP:
+ getCursor()->hide();
+ getSharedData()->setFlag(kFlag1, true);
+ getScreen()->setupPaletteAndStartFade(0, 0, 0);
+
+ _vm->switchEventHandler(getScene());
+ break;
+ }
+
+ return false;
+}
+
+bool PuzzleMorgueDoor::mouseDown() {
+ Common::Point mousePos = getCursor()->position();
+
+ if (mousePos.x > 347 && mousePos.x < 357
+ && mousePos.y > 124 && mousePos.y < 154) {
+ _frameIndexes[8] = 1;
+ getSound()->playSound(getWorld()->soundResourceIds[6], false, Config.sfxVolume - 10);
+ }
+
+ if (mousePos.x > 346 && mousePos.x < 356
+ && mousePos.y > 339 && mousePos.y < 386) {
+ _frameIndexes[9] = 1;
+ getSound()->playSound(getWorld()->soundResourceIds[6], false, Config.sfxVolume - 10);
+ }
+
+ if (mousePos.x > 515 && mousePos.x < 605
+ && mousePos.y > 41 && mousePos.y < 120) {
+ if (_frameIndexes[4] == 0) {
+ _frameIndexes[4] = 1;
+ getSound()->playSound(getWorld()->soundResourceIds[1], false, Config.sfxVolume - 10);
+ }
+
+ return true;
+ }
+
+ if (mousePos.x > 267 && mousePos.x < 325
+ && mousePos.y > 190 && mousePos.y < 320) {
+ if (_frameIndexes[5] == 0) {
+ _frameIndexes[5] = 1;
+ getSound()->playSound(getWorld()->soundResourceIds[0], false, Config.sfxVolume - 10);
+ _data_4572B0 = true;
+ }
+
+ return true;
+ }
+
+ if (mousePos.x > 325 && mousePos.x < 383
+ && mousePos.y > 190 && mousePos.y < 320) {
+ if (_frameIndexes[5] == 0) {
+ _frameIndexes[5] = 14;
+ getSound()->playSound(getWorld()->soundResourceIds[0], false, Config.sfxVolume - 10);
+ _data_4572B0 = false;
+ }
+
+ return true;
+ }
+
+ if (mousePos.x > 507 && mousePos.x < 556
+ && mousePos.y > 124 && mousePos.y < 177) {
+ if (_frameIndexes[7] == 4) {
+ getSound()->playSound(getWorld()->soundResourceIds[2], false, Config.sfxVolume - 10);
+ _data_4572A8 = true;
+ _data_4572AC = false;
+ }
+
+ return true;
+ }
+
+ if (mousePos.x > 556 && mousePos.x < 605
+ && mousePos.y > 124 && mousePos.y < 177) {
+ if (_frameIndexes[7] == 4) {
+ getSound()->playSound(getWorld()->soundResourceIds[2], false, Config.sfxVolume - 10);
+ _data_4572A8 = true;
+ _data_4572AC = false;
+ }
+ }
+
+ return true;
+}
+
+//////////////////////////////////////////////////////////////////////////
+// Helpers
+//////////////////////////////////////////////////////////////////////////
+void PuzzleMorgueDoor::updateCursor() {
+ warning("[PuzzleMorgueDoor::updateCursor] Not implemented!");
}
} // End of namespace Asylum
diff --git a/engines/asylum/puzzles/morguedoor.h b/engines/asylum/puzzles/morguedoor.h
index 767bf95b8a..986db5983b 100644
--- a/engines/asylum/puzzles/morguedoor.h
+++ b/engines/asylum/puzzles/morguedoor.h
@@ -38,12 +38,31 @@ public:
~PuzzleMorgueDoor();
private:
+ uint32 _frameCounts[10];
+ uint32 _frameIndexes[12];
+ bool _data_4572A4;
+ bool _data_4572A8;
+ bool _data_4572AC;
+ bool _data_4572B0;
+
+ bool _flag1;
+ bool _flag2;
+ bool _flag3;
+
//////////////////////////////////////////////////////////////////////////
// Event Handling
//////////////////////////////////////////////////////////////////////////
bool init();
bool update();
+ bool key(const AsylumEvent &evt);
bool mouse(const AsylumEvent &evt);
+
+ bool mouseDown();
+
+ //////////////////////////////////////////////////////////////////////////
+ // Helpers
+ //////////////////////////////////////////////////////////////////////////
+ void updateCursor();
};
} // End of namespace Asylum
Commit: c6b1ad3dae4e528efb77f8ac617cad38d7406d6e
https://github.com/scummvm/scummvm/commit/c6b1ad3dae4e528efb77f8ac617cad38d7406d6e
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:45+02:00
Commit Message:
ASYLUM: Implement PuzzleMorgueDoor::updateCursor()
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@726 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/puzzles/morguedoor.cpp
diff --git a/engines/asylum/puzzles/morguedoor.cpp b/engines/asylum/puzzles/morguedoor.cpp
index 1c4eb662cd..6eb0e98297 100644
--- a/engines/asylum/puzzles/morguedoor.cpp
+++ b/engines/asylum/puzzles/morguedoor.cpp
@@ -212,7 +212,39 @@ bool PuzzleMorgueDoor::mouseDown() {
// Helpers
//////////////////////////////////////////////////////////////////////////
void PuzzleMorgueDoor::updateCursor() {
- warning("[PuzzleMorgueDoor::updateCursor] Not implemented!");
+ Common::Point mousePos = getCursor()->position();
+
+ bool animate = false;
+
+ if (mousePos.x > 347 && mousePos.x < 357 && mousePos.y > 124 && mousePos.y < 154)
+ animate = true;
+
+ if (mousePos.x > 346 && mousePos.x < 356 && mousePos.y > 339 && mousePos.y < 386)
+ animate = true;
+
+ if (mousePos.x > 515 && mousePos.x < 605 && mousePos.y > 41 && mousePos.y < 120)
+ animate = true;
+
+ if (mousePos.x > 267 && mousePos.x < 325 && mousePos.y > 190 && mousePos.y < 320)
+ animate = true;
+
+ if (mousePos.x > 325 && mousePos.x < 383 && mousePos.y > 190 && mousePos.y < 320)
+ animate = true;
+
+ if (mousePos.x > 507 && mousePos.x < 556 && mousePos.y > 124 && mousePos.y < 177)
+ animate = true;
+
+ if (mousePos.x > 556 && mousePos.x < 605 && mousePos.y > 124 && mousePos.y < 177)
+ animate = true;
+
+ // Default cursor
+ if (animate) {
+ if (getCursor()->animation != kCursorAnimationMirror) {
+ getCursor()->set(getWorld()->graphicResourceIds[33], -1, kCursorAnimationMirror, 7);
+ }
+ } else if (getCursor()->animation != kCursorAnimationNone) {
+ getCursor()->set(getWorld()->graphicResourceIds[33], -1, kCursorAnimationNone, 7);
+ }
}
} // End of namespace Asylum
Commit: 2af471014209fa0a045056ebc02b1202dbf58d02
https://github.com/scummvm/scummvm/commit/2af471014209fa0a045056ebc02b1202dbf58d02
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:45+02:00
Commit Message:
ASYLUM: Implement parts of PuzzleMorgueDoor::updateState()
- Add enum for puzzle objects
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@727 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/puzzles/morguedoor.cpp
engines/asylum/puzzles/morguedoor.h
engines/asylum/shared.h
diff --git a/engines/asylum/puzzles/morguedoor.cpp b/engines/asylum/puzzles/morguedoor.cpp
index 6eb0e98297..35fe5578b6 100644
--- a/engines/asylum/puzzles/morguedoor.cpp
+++ b/engines/asylum/puzzles/morguedoor.cpp
@@ -45,9 +45,16 @@ PuzzleMorgueDoor::PuzzleMorgueDoor(AsylumEngine *engine) : Puzzle(engine) {
_data_4572AC = false;
_data_4572B0 = false;
- _flag1 = false;
- _flag2 = false;
+ _data_45A9D8 = 0;
+ _data_45A9DC = 0;
+
+ _topLeverOpen = false;
+ _bottomLeverOpen = false;
_flag3 = false;
+ _flag4 = false;
+ _flag5 = false;
+ _flag6 = false;
+ _flag7 = false;
}
PuzzleMorgueDoor::~PuzzleMorgueDoor() {
@@ -59,16 +66,16 @@ PuzzleMorgueDoor::~PuzzleMorgueDoor() {
bool PuzzleMorgueDoor::init() {
getCursor()->set(getWorld()->graphicResourceIds[33], -1, kCursorAnimationNone, 7);
- _frameCounts[0] = GraphicResource::getFrameCount(_vm, getWorld()->graphicResourceIds[21]);
- _frameCounts[1] = GraphicResource::getFrameCount(_vm, getWorld()->graphicResourceIds[22]);
- _frameCounts[2] = GraphicResource::getFrameCount(_vm, getWorld()->graphicResourceIds[23]);
- _frameCounts[3] = GraphicResource::getFrameCount(_vm, getWorld()->graphicResourceIds[24]);
- _frameCounts[4] = GraphicResource::getFrameCount(_vm, getWorld()->graphicResourceIds[25]);
- _frameCounts[5] = GraphicResource::getFrameCount(_vm, getWorld()->graphicResourceIds[26]);
- _frameCounts[6] = GraphicResource::getFrameCount(_vm, getWorld()->graphicResourceIds[27]);
- _frameCounts[7] = GraphicResource::getFrameCount(_vm, getWorld()->graphicResourceIds[28]);
- _frameCounts[8] = GraphicResource::getFrameCount(_vm, getWorld()->graphicResourceIds[31]);
- _frameCounts[9] = GraphicResource::getFrameCount(_vm, getWorld()->graphicResourceIds[32]);
+ _frameCounts[kTopLever] = GraphicResource::getFrameCount(_vm, getWorld()->graphicResourceIds[21]);
+ _frameCounts[kBottomLever] = GraphicResource::getFrameCount(_vm, getWorld()->graphicResourceIds[22]);
+ _frameCounts[kTopLeverOpened] = GraphicResource::getFrameCount(_vm, getWorld()->graphicResourceIds[23]);
+ _frameCounts[kBottomLeverOpened] = GraphicResource::getFrameCount(_vm, getWorld()->graphicResourceIds[24]);
+ _frameCounts[kTopRightValve] = GraphicResource::getFrameCount(_vm, getWorld()->graphicResourceIds[25]);
+ _frameCounts[kCenterValve] = GraphicResource::getFrameCount(_vm, getWorld()->graphicResourceIds[26]);
+ _frameCounts[kRightGear] = GraphicResource::getFrameCount(_vm, getWorld()->graphicResourceIds[27]);
+ _frameCounts[kTopRightLever] = GraphicResource::getFrameCount(_vm, getWorld()->graphicResourceIds[28]);
+ _frameCounts[kTopGear] = GraphicResource::getFrameCount(_vm, getWorld()->graphicResourceIds[31]);
+ _frameCounts[kBottomGear] = GraphicResource::getFrameCount(_vm, getWorld()->graphicResourceIds[32]);
getScreen()->setPalette(getWorld()->graphicResourceIds[20]);
getScreen()->setGammaLevel(getWorld()->graphicResourceIds[20], 0);
@@ -82,27 +89,29 @@ bool PuzzleMorgueDoor::update() {
// Draw elements
getScreen()->clearGraphicsInQueue();
getScreen()->draw(getWorld()->graphicResourceIds[19]);
- getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[21], _frameIndexes[0], Common::Point(47, 0), 0, 0, 1);
- getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[22], _frameIndexes[1], Common::Point(51, 236), 0, 0, 1);
+ getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[21], _frameIndexes[kTopLever], Common::Point(47, 0), 0, 0, 1);
+ getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[22], _frameIndexes[kBottomLever], Common::Point(51, 236), 0, 0, 1);
- if (_flag1)
- getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[23], _frameIndexes[2], Common::Point(80, 0), 0, 0, 1);
+ if (_topLeverOpen)
+ getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[23], _frameIndexes[kTopLeverOpened], Common::Point(80, 0), 0, 0, 1);
- if (_flag2)
- getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[24], _frameIndexes[3], Common::Point(89, 230), 0, 0, 1);
+ if (_bottomLeverOpen)
+ getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[24], _frameIndexes[kBottomLeverOpened], Common::Point(89, 230), 0, 0, 1);
- getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[25], _frameIndexes[4], Common::Point(515, 41), 0, 0, 1);
- getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[26], _frameIndexes[5], Common::Point(267, 190), 0, 0, 1);
- getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[27], _frameIndexes[6], Common::Point(388, 105), 0, 0, 1);
- getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[28], _frameIndexes[7], Common::Point(491, 143), 0, 0, 1);
- getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[29], _frameIndexes[8], Common::Point(347, 124), 0, 0, 1);
- getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[30], _frameIndexes[9], Common::Point(346, 339), 0, 0, 1);
- getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[31], _frameIndexes[10], Common::Point(276, 67), 0, 0, 1);
- getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[32], _frameIndexes[11], Common::Point(278, 378), 0, 0, 1);
+ getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[25], _frameIndexes[kTopRightValve], Common::Point(515, 41), 0, 0, 1);
+ getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[26], _frameIndexes[kCenterValve], Common::Point(267, 190), 0, 0, 1);
+ getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[27], _frameIndexes[kRightGear], Common::Point(388, 105), 0, 0, 1);
+ getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[28], _frameIndexes[kTopRightLever], Common::Point(491, 143), 0, 0, 1);
+ getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[29], _frameIndexes[kTopSmallLever], Common::Point(347, 124), 0, 0, 1);
+ getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[30], _frameIndexes[kBottomSmallLever], Common::Point(346, 339), 0, 0, 1);
+ getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[31], _frameIndexes[kTopGear], Common::Point(276, 67), 0, 0, 1);
+ getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[32], _frameIndexes[kBottomGear], Common::Point(278, 378), 0, 0, 1);
getScreen()->drawGraphicsInQueue();
getScreen()->copyBackBufferToScreen();
+ updateState();
+
return true;
}
@@ -141,32 +150,36 @@ bool PuzzleMorgueDoor::mouse(const AsylumEvent &evt) {
bool PuzzleMorgueDoor::mouseDown() {
Common::Point mousePos = getCursor()->position();
+ // Top small lever
if (mousePos.x > 347 && mousePos.x < 357
&& mousePos.y > 124 && mousePos.y < 154) {
- _frameIndexes[8] = 1;
+ _frameIndexes[kTopSmallLever] = 1;
getSound()->playSound(getWorld()->soundResourceIds[6], false, Config.sfxVolume - 10);
}
+ // Bottom small lever
if (mousePos.x > 346 && mousePos.x < 356
&& mousePos.y > 339 && mousePos.y < 386) {
- _frameIndexes[9] = 1;
+ _frameIndexes[kBottomSmallLever] = 1;
getSound()->playSound(getWorld()->soundResourceIds[6], false, Config.sfxVolume - 10);
}
+ // Top Right Valve
if (mousePos.x > 515 && mousePos.x < 605
&& mousePos.y > 41 && mousePos.y < 120) {
- if (_frameIndexes[4] == 0) {
- _frameIndexes[4] = 1;
+ if (_frameIndexes[kTopRightValve] == 0) {
+ _frameIndexes[kTopRightValve] = 1;
getSound()->playSound(getWorld()->soundResourceIds[1], false, Config.sfxVolume - 10);
}
return true;
}
+ // Center Valve turning left
if (mousePos.x > 267 && mousePos.x < 325
&& mousePos.y > 190 && mousePos.y < 320) {
- if (_frameIndexes[5] == 0) {
- _frameIndexes[5] = 1;
+ if (_frameIndexes[kCenterValve] == 0) {
+ _frameIndexes[kCenterValve] = 1;
getSound()->playSound(getWorld()->soundResourceIds[0], false, Config.sfxVolume - 10);
_data_4572B0 = true;
}
@@ -174,10 +187,11 @@ bool PuzzleMorgueDoor::mouseDown() {
return true;
}
+ // Center Valve turning right
if (mousePos.x > 325 && mousePos.x < 383
&& mousePos.y > 190 && mousePos.y < 320) {
- if (_frameIndexes[5] == 0) {
- _frameIndexes[5] = 14;
+ if (_frameIndexes[kCenterValve] == 0) {
+ _frameIndexes[kCenterValve] = 14;
getSound()->playSound(getWorld()->soundResourceIds[0], false, Config.sfxVolume - 10);
_data_4572B0 = false;
}
@@ -185,9 +199,10 @@ bool PuzzleMorgueDoor::mouseDown() {
return true;
}
+ // Top right lever moving left
if (mousePos.x > 507 && mousePos.x < 556
&& mousePos.y > 124 && mousePos.y < 177) {
- if (_frameIndexes[7] == 4) {
+ if (_frameIndexes[kTopRightLever] == 4) {
getSound()->playSound(getWorld()->soundResourceIds[2], false, Config.sfxVolume - 10);
_data_4572A8 = true;
_data_4572AC = false;
@@ -196,9 +211,10 @@ bool PuzzleMorgueDoor::mouseDown() {
return true;
}
+ // Top right lever moving right
if (mousePos.x > 556 && mousePos.x < 605
&& mousePos.y > 124 && mousePos.y < 177) {
- if (_frameIndexes[7] == 4) {
+ if (_frameIndexes[kTopRightLever] == 4) {
getSound()->playSound(getWorld()->soundResourceIds[2], false, Config.sfxVolume - 10);
_data_4572A8 = true;
_data_4572AC = false;
@@ -247,4 +263,217 @@ void PuzzleMorgueDoor::updateCursor() {
}
}
+void PuzzleMorgueDoor::updateState() {
+ if (_flag3) {
+ warning("[PuzzleMorgueDoor::updateState] Not implemented (flag 3)!");
+ }
+
+ if (_flag4) {
+ switch (_data_45A9DC) {
+ default:
+ break;
+
+ case 1:
+ --_frameIndexes[kBottomGear];
+
+ if (_frameIndexes[kBottomGear] < 0) {
+ _data_45A9DC = 0;
+ _frameIndexes[kBottomGear] = 0;
+
+ getSound()->stop(getWorld()->soundResourceIds[8]);
+ }
+ break;
+
+ case 2:
+ --_frameIndexes[kBottomGear];
+
+ if (_frameIndexes[kBottomGear] < 0) {
+ _data_45A9DC = 1;
+ _frameIndexes[kBottomGear] = 10;
+ }
+ break;
+
+ case 3:
+ --_frameIndexes[kBottomGear];
+
+ if (_frameIndexes[kBottomGear] < 0) {
+ _data_45A9DC = 2;
+ _frameIndexes[kBottomGear] = 10;
+ }
+ break;
+ }
+
+ if (!_flag7 || _data_45A9DC < 3)
+ _frameIndexes[kBottomLever] = 5 * _data_45A9DC;
+ }
+
+ // Update gears
+ if (_flag5) {
+ --_frameIndexes[kRightGear];
+
+ if (_data_4572AC) {
+ if (_data_45A9D8 < 3)
+ _frameIndexes[kTopGear] = 10 * (14 - _frameIndexes[kRightGear]) / 14;
+ } else {
+ if (_data_45A9DC < 3)
+ _frameIndexes[kBottomGear] = 10 * (14 - _frameIndexes[kRightGear]) / 14;
+ }
+
+ if (!_frameIndexes[kRightGear]) {
+ _flag5 = false;
+
+ if (_data_4572AC) {
+ if (_frameIndexes[kTopLever] < 15)
+ _frameIndexes[kTopLever] += 5;
+
+ if (_data_45A9D8 < 3)
+ ++_data_45A9D8;
+
+ if (_data_45A9D8 == 3 && _flag6)
+ --_frameIndexes[kTopLever];
+ } else {
+ if (_frameIndexes[kBottomLever] < 15)
+ _frameIndexes[kBottomLever] += 5;
+
+ if (_data_45A9DC < 3)
+ ++_data_45A9DC;
+
+ if (_data_45A9DC == 3 && _flag7)
+ --_frameIndexes[kBottomLever];
+ }
+ }
+ }
+
+ //////////////////////////////////////////////////////////////////////////
+ // Update levers & gears
+ if (_frameIndexes[kTopRightValve] % 3 == 1 || (_frameIndexes[kTopRightValve] == 15 && _frameIndexes[kRightGear] > 13))
+ if (_frameIndexes[kRightGear] < 14)
+ ++_frameIndexes[kRightGear];
+
+ if (_frameIndexes[kRightGear] > 14 && _frameIndexes[kTopRightValve] == 4)
+ _frameIndexes[kRightGear] = 14;
+
+ if (_data_4572A4) {
+ --_frameIndexes[kTopRightLever];
+
+ if (_frameIndexes[kTopRightLever] < 0) {
+ _frameIndexes[kTopRightLever] = 0;
+ _data_4572A4 = false;
+
+ if (_frameIndexes[kRightGear] == 14) {
+ if (_data_45A9D8 < 3)
+ getSound()->playSound(getWorld()->soundResourceIds[7], false, Config.sfxVolume, getWorld()->reverseStereo ? 2000 : -2000);
+
+ getSound()->playSound(getWorld()->soundResourceIds[7], false, Config.sfxVolume - 100, getWorld()->reverseStereo ? -3000 : 3000);
+ _flag5 = true;
+ }
+ }
+ } else {
+ if (_data_4572A8) {
+ ++_frameIndexes[kTopRightLever];
+
+ if (_frameIndexes[kTopRightLever] > 7) {
+ _frameIndexes[kTopRightLever] = 7;
+ _data_4572A8 = false;
+
+ if (_frameIndexes[kRightGear] == 14) {
+ if (_data_45A9DC < 3)
+ getSound()->playSound(getWorld()->soundResourceIds[7], false, Config.sfxVolume, getWorld()->reverseStereo ? 2000 : -2000);
+
+ getSound()->playSound(getWorld()->soundResourceIds[7], false, Config.sfxVolume - 100, getWorld()->reverseStereo ? -3000 : 3000);
+ _flag5 = true;
+ }
+ }
+ } else {
+ if (_frameIndexes[kTopRightLever] > 4)
+ --_frameIndexes[kTopRightLever];
+ else if (_frameIndexes[kTopRightLever] < 4)
+ ++_frameIndexes[kTopRightLever];
+ }
+ }
+
+ // Left valve
+ if (_frameIndexes[kTopRightValve])
+ ++_frameIndexes[kTopRightValve];
+
+ if (_frameIndexes[kCenterValve]) {
+ warning("[PuzzleMorgueDoor::updateState] Not implemented (centerValve)!");
+ }
+
+ //////////////////////////////////////////////////////////////////////////
+ // Adjust frame indexes
+ //////////////////////////////////////////////////////////////////////////
+ if (_frameIndexes[kTopGear] > _frameCounts[kTopGear] - 1)
+ _frameIndexes[kTopGear] = 0;
+
+ if (_frameIndexes[kBottomGear] > _frameCounts[kBottomGear] - 1)
+ _frameIndexes[kBottomGear] = 0;
+
+ if (_frameIndexes[kBottomLever] > _frameCounts[kBottomLever] - 1)
+ _frameIndexes[kBottomLever] = 0;
+
+ if (_frameIndexes[kTopLeverOpened] > _frameCounts[kTopLeverOpened] - 1 || _frameIndexes[kTopLeverOpened] < 0)
+ _frameIndexes[kTopLeverOpened] = 0;
+
+ if (_frameIndexes[kBottomLeverOpened] > _frameCounts[kBottomLeverOpened] - 1 || _frameIndexes[kBottomLeverOpened] < 0)
+ _frameIndexes[kBottomLeverOpened] = 0;
+
+ if (_frameIndexes[kTopRightValve] > _frameCounts[kTopRightValve] - 1 || _frameIndexes[kTopRightValve] < 0)
+ _frameIndexes[kTopRightValve] = 0;
+
+ if (_frameIndexes[kCenterValve] > _frameCounts[kCenterValve] - 1)
+ _frameIndexes[kCenterValve] = 0;
+
+ if (_frameIndexes[kRightGear] > _frameCounts[kRightGear] - 1)
+ _frameIndexes[kRightGear] = 0;
+
+ if (_frameIndexes[kTopRightLever] > _frameCounts[kTopRightLever] - 1)
+ _frameIndexes[kTopRightLever] = 0;
+
+ // Top small lever
+ if (_frameIndexes[kTopSmallLever] != 0) {
+ ++_frameIndexes[kTopSmallLever];
+
+ if (_frameIndexes[kTopSmallLever] > 5) {
+ _frameIndexes[kTopSmallLever] = 0;
+
+ if (_data_45A9D8 > 0) {
+ getSound()->playSound(getWorld()->graphicResourceIds[8], false, Config.sfxVolume - 10);
+ _flag3 = true;
+ }
+
+ _frameIndexes[10] = 10;
+ }
+ }
+
+ // Bottom small lever
+ if (_frameIndexes[kBottomSmallLever] != 0) {
+ ++_frameIndexes[kBottomSmallLever];
+
+ if (_frameIndexes[kBottomSmallLever] > 5) {
+ _frameIndexes[kBottomSmallLever] = 0;
+
+ if (_data_45A9DC > 0) {
+ getSound()->playSound(getWorld()->graphicResourceIds[8], false, Config.sfxVolume - 10);
+ _flag4 = true;
+ }
+ }
+ }
+
+ if (_flag6 && _flag7) {
+ _vm->setGameFlag(kGameFlag608);
+ _vm->setGameFlag(kGameFlag384);
+ _vm->setGameFlag(kGameFlag391);
+
+ // Original waits for 2000 ticks
+ g_system->delayMillis(2000);
+
+ getCursor()->hide();
+ getSharedData()->setFlag(kFlag1, true);
+ getScreen()->setupPaletteAndStartFade(0, 0, 0);
+
+ _vm->switchEventHandler(getScene());
+ }
+}
+
} // End of namespace Asylum
diff --git a/engines/asylum/puzzles/morguedoor.h b/engines/asylum/puzzles/morguedoor.h
index 986db5983b..6c5dc3c8c8 100644
--- a/engines/asylum/puzzles/morguedoor.h
+++ b/engines/asylum/puzzles/morguedoor.h
@@ -38,16 +38,38 @@ public:
~PuzzleMorgueDoor();
private:
- uint32 _frameCounts[10];
- uint32 _frameIndexes[12];
+ enum PuzzleObject {
+ kTopLever = 0,
+ kBottomLever = 1,
+ kTopLeverOpened = 2,
+ kBottomLeverOpened = 3,
+ kTopRightValve = 4,
+ kCenterValve = 5,
+ kRightGear = 6,
+ kTopRightLever = 7,
+ kTopSmallLever = 8,
+ kBottomSmallLever = 9,
+ kTopGear = 10,
+ kBottomGear = 11
+ };
+
+ int32 _frameCounts[12]; // indexes 8 & 9 aren't used
+ int32 _frameIndexes[12];
bool _data_4572A4;
bool _data_4572A8;
bool _data_4572AC;
bool _data_4572B0;
- bool _flag1;
- bool _flag2;
+ uint32 _data_45A9D8;
+ uint32 _data_45A9DC;
+
+ bool _topLeverOpen;
+ bool _bottomLeverOpen;
bool _flag3;
+ bool _flag4;
+ bool _flag5;
+ bool _flag6;
+ bool _flag7;
//////////////////////////////////////////////////////////////////////////
// Event Handling
@@ -63,6 +85,7 @@ private:
// Helpers
//////////////////////////////////////////////////////////////////////////
void updateCursor();
+ void updateState();
};
} // End of namespace Asylum
diff --git a/engines/asylum/shared.h b/engines/asylum/shared.h
index 5191e0680e..f511d5f909 100644
--- a/engines/asylum/shared.h
+++ b/engines/asylum/shared.h
@@ -75,7 +75,9 @@ enum GameFlag {
kGameFlag369 = 369,
kGameFlag370 = 370,
kGameFlag371 = 371,
+ kGameFlag384 = 384,
kGameFlag387 = 387,
+ kGameFlag391 = 391,
kGameFlag405 = 405,
kGameFlag423 = 423,
kGameFlag438 = 438,
@@ -100,6 +102,7 @@ enum GameFlag {
kGameFlag556 = 556,
kGameFlag560 = 560,
kGameFlag570 = 570,
+ kGameFlag608 = 608,
kGameFlag619 = 619,
kGameFlag635 = 635,
kGameFlag636 = 636,
Commit: 7e9d8389456bc1dc7d11829e0778b3c6b8adde72
https://github.com/scummvm/scummvm/commit/7e9d8389456bc1dc7d11829e0778b3c6b8adde72
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:45+02:00
Commit Message:
ASYLUM: Implement rest of PuzzleMorgueDoor::updateState()
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@728 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/puzzles/morguedoor.cpp
engines/asylum/puzzles/morguedoor.h
diff --git a/engines/asylum/puzzles/morguedoor.cpp b/engines/asylum/puzzles/morguedoor.cpp
index 35fe5578b6..6444042038 100644
--- a/engines/asylum/puzzles/morguedoor.cpp
+++ b/engines/asylum/puzzles/morguedoor.cpp
@@ -50,8 +50,8 @@ PuzzleMorgueDoor::PuzzleMorgueDoor(AsylumEngine *engine) : Puzzle(engine) {
_topLeverOpen = false;
_bottomLeverOpen = false;
- _flag3 = false;
- _flag4 = false;
+ _moveTopGear = false;
+ _moveBottomGear = false;
_flag5 = false;
_flag6 = false;
_flag7 = false;
@@ -264,11 +264,48 @@ void PuzzleMorgueDoor::updateCursor() {
}
void PuzzleMorgueDoor::updateState() {
- if (_flag3) {
- warning("[PuzzleMorgueDoor::updateState] Not implemented (flag 3)!");
+ // Move top gear
+ if (_moveTopGear) {
+ switch (_data_45A9D8) {
+ default:
+ break;
+
+ case 1:
+ --_frameIndexes[kTopGear];
+
+ if (_frameIndexes[kTopGear] < 0) {
+ _data_45A9D8 = 0;
+ _moveTopGear = false;
+ _frameIndexes[kTopGear] = 0;
+ getSound()->stop(getWorld()->soundResourceIds[8]);
+ }
+ break;
+
+ case 2:
+ --_frameIndexes[kTopGear];
+
+ if (_frameIndexes[kTopGear] < 0) {
+ _data_45A9D8 = 1;
+ _frameIndexes[kTopGear] = 10;
+ }
+ break;
+
+ case 3:
+ --_frameIndexes[kTopGear];
+
+ if (_frameIndexes[kTopGear] < 0) {
+ _data_45A9D8 = 2;
+ _frameIndexes[kTopGear] = 10;
+ }
+ break;
+ }
+
+ if (!_flag6 || _data_45A9D8 < 3)
+ _frameIndexes[kTopLever] = 5 * _data_45A9D8;
}
- if (_flag4) {
+ // Move bottom gear
+ if (_moveBottomGear) {
switch (_data_45A9DC) {
default:
break;
@@ -397,7 +434,99 @@ void PuzzleMorgueDoor::updateState() {
++_frameIndexes[kTopRightValve];
if (_frameIndexes[kCenterValve]) {
- warning("[PuzzleMorgueDoor::updateState] Not implemented (centerValve)!");
+ if (_data_4572B0) {
+ if (!_flag6 || _frameIndexes[kTopLever] < 15) {
+ if (_flag7 && _frameIndexes[kBottomLever] >= 15) {
+ _frameIndexes[kCenterValve] = 0;
+ getSound()->stop(getWorld()->soundResourceIds[0]);
+ } else {
+ ++_frameIndexes[kCenterValve];
+
+ // Update top lever
+ if (_frameIndexes[kTopLever] >= 15) {
+ if (_frameIndexes[kTopLever] == 15)
+ getSound()->playSound(getWorld()->soundResourceIds[4], false, Config.sfxVolume - 10);
+
+ if (_frameIndexes[kTopLever] >= _frameCounts[kTopLever] - 1) {
+ _frameIndexes[kCenterValve] = 0;
+ _topLeverOpen = true;
+ _flag6 = true;
+ } else {
+ ++_frameIndexes[kTopLever];
+ }
+ } else {
+ if (_frameIndexes[kCenterValve] >= 14)
+ _frameIndexes[kTopLever] = 5 * _data_45A9D8;
+ else
+ _frameIndexes[kTopLever] = _frameIndexes[kCenterValve] / 3 + 5 * _data_45A9D8;
+ }
+
+ // Update bottom lever
+ if (_frameIndexes[kBottomLever] >= 15) {
+ if (_frameIndexes[kBottomLever] == 15)
+ getSound()->playSound(getWorld()->soundResourceIds[4], false, Config.sfxVolume - 10);
+
+ if (_frameIndexes[kBottomLever] >= _frameCounts[kBottomLever] - 1) {
+ _frameIndexes[kCenterValve] = 0;
+ _bottomLeverOpen = true;
+ _flag7 = true;
+ } else {
+ ++_frameIndexes[kTopLever];
+ }
+ } else {
+ if (_frameIndexes[kCenterValve] >= 14)
+ _frameIndexes[kBottomLever] = 5 * _data_45A9DC;
+ else
+ _frameIndexes[kBottomLever] = _frameIndexes[kCenterValve] / 3 + 5 * _data_45A9DC;
+ }
+ }
+ } else {
+ _frameIndexes[kCenterValve] = 0;
+ getSound()->stop(getWorld()->soundResourceIds[0]);
+ }
+ }
+
+ if ((!_flag6 && _frameIndexes[kTopLever] >= 15)
+ || (!_flag7 && _frameIndexes[kBottomLever] >= 15)) {
+ _frameIndexes[kCenterValve] = 0;
+ getSound()->stop(getWorld()->soundResourceIds[0]);
+ } else {
+ --_frameIndexes[kCenterValve];
+
+ // Top lever
+ if (_frameIndexes[kTopLever] >= 15) {
+ if (_frameIndexes[kTopLever] == 20)
+ getSound()->playSound(getWorld()->soundResourceIds[3], false, Config.sfxVolume - 10);
+
+ if (_frameIndexes[kTopLever] <= 15) {
+ _frameIndexes[kCenterValve] = 0;
+ _flag6 = false;
+ } else {
+ --_frameIndexes[kTopLever];
+ }
+
+ _topLeverOpen = false;
+ } else {
+ _frameIndexes[kTopLever] = _frameIndexes[kCenterValve] / 3 + 5 * _data_45A9D8;
+ }
+
+ // Bottom lever
+ if (_frameIndexes[kBottomLever]) {
+ if (_frameIndexes[kBottomLever] == 20)
+ getSound()->playSound(getWorld()->soundResourceIds[3], false, Config.sfxVolume - 10);
+
+ if (_frameIndexes[kTopLever] <= 15) {
+ _frameIndexes[kCenterValve] = 0;
+ _flag7 = false;
+ } else {
+ --_frameIndexes[kTopLever];
+ }
+
+ _bottomLeverOpen = false;
+ } else {
+ _frameIndexes[kBottomLever] = _frameIndexes[kCenterValve] / 3 + 5 * _data_45A9DC;
+ }
+ }
}
//////////////////////////////////////////////////////////////////////////
@@ -439,7 +568,7 @@ void PuzzleMorgueDoor::updateState() {
if (_data_45A9D8 > 0) {
getSound()->playSound(getWorld()->graphicResourceIds[8], false, Config.sfxVolume - 10);
- _flag3 = true;
+ _moveTopGear = true;
}
_frameIndexes[10] = 10;
@@ -455,7 +584,7 @@ void PuzzleMorgueDoor::updateState() {
if (_data_45A9DC > 0) {
getSound()->playSound(getWorld()->graphicResourceIds[8], false, Config.sfxVolume - 10);
- _flag4 = true;
+ _moveBottomGear = true;
}
}
}
diff --git a/engines/asylum/puzzles/morguedoor.h b/engines/asylum/puzzles/morguedoor.h
index 6c5dc3c8c8..f5372d1505 100644
--- a/engines/asylum/puzzles/morguedoor.h
+++ b/engines/asylum/puzzles/morguedoor.h
@@ -65,8 +65,8 @@ private:
bool _topLeverOpen;
bool _bottomLeverOpen;
- bool _flag3;
- bool _flag4;
+ bool _moveTopGear;
+ bool _moveBottomGear;
bool _flag5;
bool _flag6;
bool _flag7;
Commit: ea4745df7156113be5607c08d727dc76df0dd79a
https://github.com/scummvm/scummvm/commit/ea4745df7156113be5607c08d727dc76df0dd79a
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:46+02:00
Commit Message:
ASYLUM: Puzzle 13 is really the clock puzzle
- Rename former clock puzzle to puzzle 11
- Implement proper clock puzzle
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@729 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
A engines/asylum/puzzles/puzzle11.cpp
A engines/asylum/puzzles/puzzle11.h
engines/asylum/asylum.cpp
engines/asylum/console.cpp
engines/asylum/puzzles/clock.cpp
engines/asylum/puzzles/clock.h
engines/asylum/shared.h
diff --git a/engines/asylum/asylum.cpp b/engines/asylum/asylum.cpp
index d4977f4303..d7d3e6096a 100644
--- a/engines/asylum/asylum.cpp
+++ b/engines/asylum/asylum.cpp
@@ -41,6 +41,7 @@
#include "asylum/puzzles/lock.h"
#include "asylum/puzzles/morguedoor.h"
#include "asylum/puzzles/pipes.h"
+#include "asylum/puzzles/puzzle11.h"
#include "asylum/puzzles/tictactoe.h"
#include "asylum/puzzles/timemachine.h"
#include "asylum/puzzles/vcr.h"
@@ -461,9 +462,9 @@ void AsylumEngine::initPuzzles() {
_puzzles[7] = new PuzzleBoardYouth(this);
_puzzles[8] = new PuzzleBoardKeyHidesTo(this);
_puzzles[9] = new PuzzleWritings(this);
- _puzzles[10] = new PuzzleClock(this);
+ _puzzles[10] = new Puzzle11(this);
_puzzles[11] = new PuzzleMorgueDoor(this);
- _puzzles[12] = NULL; warning("[AsylumEngine::initPuzzles] Add missing puzzles!"); // FIXME Not sure which puzzle this is
+ _puzzles[12] = new PuzzleClock(this);
_puzzles[13] = new PuzzleTimeMachine(this);
_puzzles[14] = new PuzzleFisherman(this);
_puzzles[15] = new PuzzleHiveMachine(this);
diff --git a/engines/asylum/console.cpp b/engines/asylum/console.cpp
index 770e1eee8e..72d89f1e90 100644
--- a/engines/asylum/console.cpp
+++ b/engines/asylum/console.cpp
@@ -62,7 +62,7 @@ const ResourcePackId puzzleToScenes[17] = {
kResourcePackMorgueCementary,
kResourcePackMansion,
kResourcePackMorgueCementary,
- kResourcePackInvalid,
+ kResourcePackMansion,
kResourcePackMorgueCementary,
kResourcePackLostVillage,
kResourcePackHive,
diff --git a/engines/asylum/puzzles/clock.cpp b/engines/asylum/puzzles/clock.cpp
index 89325346d5..01423f2868 100644
--- a/engines/asylum/puzzles/clock.cpp
+++ b/engines/asylum/puzzles/clock.cpp
@@ -25,27 +25,189 @@
#include "asylum/puzzles/clock.h"
+#include "asylum/resources/worldstats.h"
+
+#include "asylum/system/cursor.h"
+#include "asylum/system/graphics.h"
+#include "asylum/system/screen.h"
+
+#include "asylum/views/scene.h"
+
+#include "asylum/asylum.h"
+
namespace Asylum {
+const uint32 puzzleClockFrameIndexes[28] = {
+ 2, 4, 6, 8, 10, 11, 13, 15, 17, 19,
+ 21, 0, 19, 21, 0, 2, 4, 6, 8, 9,
+ 11, 13, 15, 17, 0, 0, 182, 0
+};
+
+const Common::Point puzzleClockPoints[3] = {
+ Common::Point(322, 187),
+ Common::Point(267, 109),
+ Common::Point(274, 124)
+};
+
+const Common::Rect puzzleClockRects[12] = {
+ Common::Rect(354, 121, 373, 142),
+ Common::Rect(384, 119, 405, 146),
+ Common::Rect(405, 135, 424, 160),
+ Common::Rect(404, 168, 425, 193),
+ Common::Rect(389, 205, 410, 236),
+ Common::Rect(359, 240, 383, 270),
+ Common::Rect(325, 255, 341, 284),
+ Common::Rect(294, 253, 313, 284),
+ Common::Rect(277, 237, 294, 264),
+ Common::Rect(273, 201, 301, 235),
+ Common::Rect(290, 168, 315, 195),
+ Common::Rect(315, 133, 344, 162)
+};
+
PuzzleClock::PuzzleClock(AsylumEngine *engine) : Puzzle(engine) {
+ memset(&_frameIndexes, 0, sizeof(_frameIndexes));
+ _showCursor = false;
+ _rightButtonClicked = false;
+ _currentRect = 0;
+ _currentFrameIndex = 0;
}
PuzzleClock::~PuzzleClock() {
}
+void PuzzleClock::reset() {
+ _frameIndexes[0] = 0;
+ _frameIndexes[1] = 6;
+ _frameIndexes[2] = 10;
+}
+
//////////////////////////////////////////////////////////////////////////
// Event Handling
//////////////////////////////////////////////////////////////////////////
bool PuzzleClock::init() {
- error("[PuzzleClock::init] Not implemented!");
+ _currentRect = -2;
+
+ updateCursor();
+
+ getScreen()->setPalette(getWorld()->graphicResourceIds[6]);
+ getScreen()->setGammaLevel(getWorld()->graphicResourceIds[6], 0);
+
+ getCursor()->show();
+
+ _frameIndexes[1] = 6;
+ _frameIndexes[2] = 10;
+ _currentFrameIndex = 10;
+ _showCursor = false;
+ _rightButtonClicked = false;
+
+ return true;
}
-bool PuzzleClock::update() {
- error("[PuzzleClock::update] Not implemented!");
+bool PuzzleClock::update() {
+ // Draw elements
+ getScreen()->clearGraphicsInQueue();
+ getScreen()->draw(getWorld()->graphicResourceIds[5]);
+
+ getScreen()->draw(getWorld()->graphicResourceIds[2], _frameIndexes[0], puzzleClockPoints[0].x, puzzleClockPoints[0].y, 0);
+ _frameIndexes[0]++;
+ _frameIndexes[0] %= GraphicResource::getFrameCount(_vm, getWorld()->graphicResourceIds[2]);
+
+ getScreen()->draw(getWorld()->graphicResourceIds[4], _frameIndexes[1], puzzleClockPoints[1].x, puzzleClockPoints[1].y, 0);
+ getScreen()->draw(getWorld()->graphicResourceIds[3], _frameIndexes[2], puzzleClockPoints[2].x, puzzleClockPoints[2].y, 0);
+
+ if (_currentFrameIndex == _frameIndexes[2]) {
+ if (_showCursor) {
+ _showCursor = false;
+ getCursor()->show();
+ setFlag();
+ }
+ } else {
+ ++_frameIndexes[2];
+ _frameIndexes[2] %= GraphicResource::getFrameCount(_vm, getWorld()->graphicResourceIds[3]);
+ }
+
+ getScreen()->drawGraphicsInQueue();
+ getScreen()->copyBackBufferToScreen();
+
+ if (_rightButtonClicked) {
+ getScreen()->clear();
+ _vm->switchEventHandler(getScene());
+ } else {
+ if (_vm->isGameFlagSet(kGameFlag511))
+ mouseRight();
+ }
+
+ return true;
}
bool PuzzleClock::mouse(const AsylumEvent &evt) {
- error("[PuzzleClock::mouse] Not implemented!");
+ switch (evt.type) {
+ default:
+ break;
+
+ case Common::EVENT_RBUTTONDOWN:
+ mouseRight();
+ break;
+
+ case Common::EVENT_LBUTTONDOWN:
+ return mouseLeft();
+ break;
+ }
+
+ return true;
+}
+
+bool PuzzleClock::mouseLeft() {
+ int32 index = findRect();
+
+ if (index == -1)
+ return false;
+
+ _currentFrameIndex = puzzleClockFrameIndexes[index];
+ ++_frameIndexes[2];
+ _frameIndexes[2] %= GraphicResource::getFrameCount(_vm, getWorld()->graphicResourceIds[3]);
+ _showCursor = true;
+
+ getCursor()->hide();
+
+ return true;
+}
+
+void PuzzleClock::mouseRight() {
+ setFlag();
+ _rightButtonClicked = true;
+}
+
+//////////////////////////////////////////////////////////////////////////
+// Helpers
+//////////////////////////////////////////////////////////////////////////
+void PuzzleClock::updateCursor() {
+ int32 index = findRect();
+
+ if (index != _currentRect) {
+ _currentRect = index;
+
+ if (index == -1)
+ getCursor()->set(getWorld()->graphicResourceIds[7], -1, kCursorAnimationNone);
+ else
+ getCursor()->set(getWorld()->graphicResourceIds[7], -1, kCursorAnimationMirror);
+ }
+}
+
+void PuzzleClock::setFlag() {
+ if (_frameIndexes[2] == puzzleClockFrameIndexes[11])
+ _vm->setGameFlag(kGameFlag511);
+}
+
+int32 PuzzleClock::findRect() {
+ Common::Point mousePos = getCursor()->position();
+
+ for (uint32 i = 0; i < ARRAYSIZE(puzzleClockRects); i++) {
+ if (puzzleClockRects[i].contains(mousePos))
+ return i;
+ }
+
+ return -1;
}
} // End of namespace Asylum
diff --git a/engines/asylum/puzzles/clock.h b/engines/asylum/puzzles/clock.h
index 3aaf31746a..75e46b2870 100644
--- a/engines/asylum/puzzles/clock.h
+++ b/engines/asylum/puzzles/clock.h
@@ -37,13 +37,31 @@ public:
PuzzleClock(AsylumEngine *engine);
~PuzzleClock();
+ void reset();
+
private:
+ uint32 _frameIndexes[3];
+ bool _showCursor;
+ bool _rightButtonClicked;
+ int32 _currentRect;
+ uint32 _currentFrameIndex;
+
//////////////////////////////////////////////////////////////////////////
// Event Handling
//////////////////////////////////////////////////////////////////////////
bool init();
bool update();
bool mouse(const AsylumEvent &evt);
+
+ bool mouseLeft();
+ void mouseRight();
+
+ //////////////////////////////////////////////////////////////////////////
+ // Helpers
+ //////////////////////////////////////////////////////////////////////////
+ void updateCursor();
+ void setFlag();
+ int32 findRect();
};
} // End of namespace Asylum
diff --git a/engines/asylum/puzzles/puzzle11.cpp b/engines/asylum/puzzles/puzzle11.cpp
new file mode 100644
index 0000000000..c6902b9023
--- /dev/null
+++ b/engines/asylum/puzzles/puzzle11.cpp
@@ -0,0 +1,51 @@
+/* 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.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#include "asylum/puzzles/puzzle11.h"
+
+namespace Asylum {
+
+Puzzle11::Puzzle11(AsylumEngine *engine) : Puzzle(engine) {
+}
+
+Puzzle11::~Puzzle11() {
+}
+
+//////////////////////////////////////////////////////////////////////////
+// Event Handling
+//////////////////////////////////////////////////////////////////////////
+bool Puzzle11::init() {
+ error("[Puzzle11::init] Not implemented!");
+}
+
+bool Puzzle11::update() {
+ error("[Puzzle11::update] Not implemented!");
+}
+
+bool Puzzle11::mouse(const AsylumEvent &evt) {
+ error("[Puzzle11::mouse] Not implemented!");
+}
+
+} // End of namespace Asylum
diff --git a/engines/asylum/puzzles/puzzle11.h b/engines/asylum/puzzles/puzzle11.h
new file mode 100644
index 0000000000..fea210ff96
--- /dev/null
+++ b/engines/asylum/puzzles/puzzle11.h
@@ -0,0 +1,51 @@
+/* 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.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#ifndef ASYLUM_PUZZLE11_H
+#define ASYLUM_PUZZLE11_H
+
+#include "asylum/puzzles/puzzle.h"
+
+namespace Asylum {
+
+class AsylumEngine;
+
+class Puzzle11 : public Puzzle {
+public:
+ Puzzle11(AsylumEngine *engine);
+ ~Puzzle11();
+
+private:
+ //////////////////////////////////////////////////////////////////////////
+ // Event Handling
+ //////////////////////////////////////////////////////////////////////////
+ bool init();
+ bool update();
+ bool mouse(const AsylumEvent &evt);
+};
+
+} // End of namespace Asylum
+
+#endif // ASYLUM_PUZZLE11_H
diff --git a/engines/asylum/shared.h b/engines/asylum/shared.h
index f511d5f909..23423c3deb 100644
--- a/engines/asylum/shared.h
+++ b/engines/asylum/shared.h
@@ -94,6 +94,7 @@ enum GameFlag {
kGameFlag454 = 454,
kGameFlag455 = 455,
kGameFlag470 = 470,
+ kGameFlag511 = 511,
kGameFlag528 = 528,
kGameFlag543 = 543,
kGameFlag544 = 544,
Commit: d7650f040976783b0abfaece67d7d0e165f0372f
https://github.com/scummvm/scummvm/commit/d7650f040976783b0abfaece67d7d0e165f0372f
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:46+02:00
Commit Message:
ASYLUM: Do not try to load kResourceNone resources in GraphicResource::load()
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@730 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/system/graphics.cpp
diff --git a/engines/asylum/system/graphics.cpp b/engines/asylum/system/graphics.cpp
index dff1ba0910..ce4a41e206 100644
--- a/engines/asylum/system/graphics.cpp
+++ b/engines/asylum/system/graphics.cpp
@@ -48,6 +48,9 @@ GraphicResource::~GraphicResource() {
}
bool GraphicResource::load(ResourceId id) {
+ if (id == kResourceNone)
+ error("[GraphicResource::load] Trying to load an invalid resource!");
+
// Clear previously loaded data
clear();
Commit: 254366a3eefb24acd16507b44da5c510e2b3db99
https://github.com/scummvm/scummvm/commit/254366a3eefb24acd16507b44da5c510e2b3db99
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:46+02:00
Commit Message:
ASYLUM: Implement parts of puzzle 11
This does not seem to reference valid graphic resources.
It might be unfinished logic code that was left there and
never used in the game
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@731 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/console.cpp
engines/asylum/puzzles/data.h
engines/asylum/puzzles/puzzle11.cpp
engines/asylum/puzzles/puzzle11.h
diff --git a/engines/asylum/console.cpp b/engines/asylum/console.cpp
index 72d89f1e90..389dd7254d 100644
--- a/engines/asylum/console.cpp
+++ b/engines/asylum/console.cpp
@@ -50,23 +50,23 @@ extern int32 g_debugObjects;
extern int32 g_debugScrolling;
const ResourcePackId puzzleToScenes[17] = {
- kResourcePackTowerCells,
- kResourcePackCourtyardAndChapel,
- kResourcePackInnocentAbandoned,
- kResourcePackMansion,
- kResourcePackInvalid,
- kResourcePackLaboratory,
- kResourcePackLaboratory,
- kResourcePackLaboratory,
- kResourcePackLaboratory,
- kResourcePackMorgueCementary,
- kResourcePackMansion,
- kResourcePackMorgueCementary,
- kResourcePackMansion,
- kResourcePackMorgueCementary,
- kResourcePackLostVillage,
- kResourcePackHive,
- kResourcePackHive
+ kResourcePackTowerCells, // VCR
+ kResourcePackCourtyardAndChapel, // Pipes
+ kResourcePackInnocentAbandoned, // TicTacToe
+ kResourcePackMansion, // Lock
+ kResourcePackInvalid, // Puzzle 5 has no event handler
+ kResourcePackLaboratory, // Wheel
+ kResourcePackLaboratory, // Board Salvation
+ kResourcePackLaboratory, // Board Youth
+ kResourcePackLaboratory, // Board Key Hides To
+ kResourcePackMorgueCementary, // Writings
+ kResourcePackInvalid, // ?? (11)
+ kResourcePackMorgueCementary, // Morgue Door
+ kResourcePackMansion, // Clock
+ kResourcePackMorgueCementary, // Time Machine
+ kResourcePackLostVillage, // Fisherman
+ kResourcePackHive, // Hive Machine
+ kResourcePackHive // Hive Control
};
Console::Console(AsylumEngine *engine) : _vm(engine) {
diff --git a/engines/asylum/puzzles/data.h b/engines/asylum/puzzles/data.h
index fc0d35f800..7a0d8ce6c6 100644
--- a/engines/asylum/puzzles/data.h
+++ b/engines/asylum/puzzles/data.h
@@ -34,13 +34,17 @@ namespace Asylum {
struct PuzzleData : public Common::Serializable {
public:
+ uint32 timeMachineCounter;
+
+
+ PuzzleData() {
+ timeMachineCounter = 0;
+ }
+
// Serializable
void saveLoadWithSerializer(Common::Serializer &s) {
error("[PuzzleData::saveLoadWithSerializer] Not implemented!");
}
-
-private:
-
};
} // End of namespace Asylum
diff --git a/engines/asylum/puzzles/puzzle11.cpp b/engines/asylum/puzzles/puzzle11.cpp
index c6902b9023..69f9fc1293 100644
--- a/engines/asylum/puzzles/puzzle11.cpp
+++ b/engines/asylum/puzzles/puzzle11.cpp
@@ -25,9 +25,25 @@
#include "asylum/puzzles/puzzle11.h"
+#include "asylum/resources/worldstats.h"
+
+#include "asylum/system/cursor.h"
+#include "asylum/system/graphics.h"
+#include "asylum/system/screen.h"
+
+#include "asylum/views/scene.h"
+
+#include "asylum/asylum.h"
+
+
namespace Asylum {
Puzzle11::Puzzle11(AsylumEngine *engine) : Puzzle(engine) {
+ _counter = 0;
+ memset(&_frameCounts, 0, sizeof(_frameCounts));
+ memset(&_frameIndexes, 0, sizeof(_frameIndexes));
+ _data_457298 = false;
+ _data_45AA34 = false;
}
Puzzle11::~Puzzle11() {
@@ -37,15 +53,86 @@ Puzzle11::~Puzzle11() {
// Event Handling
//////////////////////////////////////////////////////////////////////////
bool Puzzle11::init() {
- error("[Puzzle11::init] Not implemented!");
+ getPuzzleData()->timeMachineCounter = 0;
+
+ getScreen()->setPalette(getWorld()->graphicResourceIds[12]);
+ getScreen()->setGammaLevel(getWorld()->graphicResourceIds[12], 0);
+ getCursor()->set(getWorld()->graphicResourceIds[60], -1, kCursorAnimationNone, 7);
+
+ _data_45AA34 = false;
+
+ _frameCounts[0] = GraphicResource::getFrameCount(_vm, getWorld()->graphicResourceIds[59]);
+ _frameCounts[1] = GraphicResource::getFrameCount(_vm, getWorld()->graphicResourceIds[54]);
+ _frameCounts[2] = GraphicResource::getFrameCount(_vm, getWorld()->graphicResourceIds[55]);
+ _frameCounts[3] = GraphicResource::getFrameCount(_vm, getWorld()->graphicResourceIds[56]);
+ _frameCounts[4] = GraphicResource::getFrameCount(_vm, getWorld()->graphicResourceIds[13]);
+
+ mouseDown();
+
+ return true;
}
bool Puzzle11::update() {
- error("[Puzzle11::update] Not implemented!");
+ getScreen()->clearGraphicsInQueue();
+ getScreen()->draw(getWorld()->graphicResourceIds[11]);
+ getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[15], _frameIndexes[0], Common::Point(122, 269), 0, 0, 1);
+ getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[16], _frameIndexes[1], Common::Point(524, 175), 0, 0, 1);
+ getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[18], _frameIndexes[2], Common::Point(359, 61), 0, 0, 1);
+ getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[14], _frameIndexes[3], Common::Point(115, 80), 0, 0, 1);
+ getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[17], _frameIndexes[4], Common::Point(238, 94), 0, 0, 1);
+
+ getScreen()->drawGraphicsInQueue();
+ getScreen()->copyBackBufferToScreen();
+ warning("[Puzzle11::update] Not implemented!");
+
+ return true;
+}
+
+bool Puzzle11::key(const AsylumEvent &evt) {
+ switch (evt.kbd.keycode) {
+ default:
+ _vm->switchEventHandler(getScene());
+ break;
+
+ case Common::KEYCODE_TAB:
+ getScreen()->takeScreenshot();
+ break;
+ }
+
+ return false;
}
bool Puzzle11::mouse(const AsylumEvent &evt) {
- error("[Puzzle11::mouse] Not implemented!");
+ switch (evt.type) {
+ default:
+ break;
+
+ case Common::EVENT_RBUTTONDOWN:
+ getCursor()->hide();
+ getSharedData()->setFlag(kFlag1, true);
+ getScreen()->setupPaletteAndStartFade(0, 0, 0);
+
+ _vm->switchEventHandler(getScene());
+ break;
+
+ case Common::EVENT_LBUTTONUP:
+ mouseUp();
+ break;
+
+ case Common::EVENT_LBUTTONDOWN:
+ mouseDown();
+ return true;
+ }
+
+ return false;
+}
+
+void Puzzle11::mouseUp() {
+ warning("[Puzzle11::mouseUp] Not implemented!");
+}
+
+void Puzzle11::mouseDown() {
+ warning("[Puzzle11::mouseDown] Not implemented!");
}
} // End of namespace Asylum
diff --git a/engines/asylum/puzzles/puzzle11.h b/engines/asylum/puzzles/puzzle11.h
index fea210ff96..51a81bd039 100644
--- a/engines/asylum/puzzles/puzzle11.h
+++ b/engines/asylum/puzzles/puzzle11.h
@@ -38,12 +38,22 @@ public:
~Puzzle11();
private:
+ uint32 _counter;
+ uint32 _frameCounts[5];
+ uint32 _frameIndexes[7];
+ bool _data_457298;
+ bool _data_45AA34;
+
//////////////////////////////////////////////////////////////////////////
// Event Handling
//////////////////////////////////////////////////////////////////////////
bool init();
bool update();
+ bool key(const AsylumEvent &evt);
bool mouse(const AsylumEvent &evt);
+
+ void mouseUp();
+ void mouseDown();
};
} // End of namespace Asylum
Commit: aed293bdea17cd92c91978134a9291443c513e5d
https://github.com/scummvm/scummvm/commit/aed293bdea17cd92c91978134a9291443c513e5d
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:46+02:00
Commit Message:
ASYLUM: Implement beginning of TimeMachine puzzle
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@732 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/puzzles/timemachine.cpp
engines/asylum/puzzles/timemachine.h
engines/asylum/shared.h
diff --git a/engines/asylum/puzzles/timemachine.cpp b/engines/asylum/puzzles/timemachine.cpp
index 2bb7b6dc33..ff3c25c64b 100644
--- a/engines/asylum/puzzles/timemachine.cpp
+++ b/engines/asylum/puzzles/timemachine.cpp
@@ -25,27 +25,230 @@
#include "asylum/puzzles/timemachine.h"
+#include "asylum/resources/worldstats.h"
+
+#include "asylum/system/cursor.h"
+#include "asylum/system/graphics.h"
+#include "asylum/system/screen.h"
+
+#include "asylum/views/scene.h"
+
+#include "asylum/asylum.h"
+
namespace Asylum {
+const Common::Rect puzzleTimeMachineRects[10] = {
+ Common::Rect( 0, 241, 20, 276),
+ Common::Rect( 0, 285, 20, 320),
+ Common::Rect(117, 245, 137, 280),
+ Common::Rect(117, 284, 137, 319),
+ Common::Rect(236, 246, 256, 281),
+ Common::Rect(236, 290, 256, 325),
+ Common::Rect(356, 245, 376, 280),
+ Common::Rect(356, 287, 376, 322),
+ Common::Rect(476, 248, 496, 283),
+ Common::Rect(475, 290, 495, 325)
+};
+
+const Common::Point puzzleTimeMachinePoints[6] = {
+ Common::Point(-65, -30),
+ Common::Point(-20, -68),
+ Common::Point( 25, -106),
+ Common::Point( 70, -144),
+ Common::Point(115, -182),
+ Common::Point(-65, -30)
+};
+
PuzzleTimeMachine::PuzzleTimeMachine(AsylumEngine *engine) : Puzzle(engine) {
+ _leftButtonClicked = false;
+ _counter = 0;
+ memset(&_frameIndexes, 0, sizeof(_frameIndexes));
+ memset(&_frameCounts, 0, sizeof(_frameCounts));
+ memset(&_frameIncrements, 0, sizeof(_frameIncrements));
+ memset(&_state, 0, sizeof(_state));
+
+ _data_4572BC = false;
+ _data_4572CC = false;
}
PuzzleTimeMachine::~PuzzleTimeMachine() {
}
+void PuzzleTimeMachine::reset() {
+ _frameIndexes[0] = 0;
+ _frameIndexes[1] = 4;
+ _frameIndexes[2] = 20;
+ _frameIndexes[3] = 16;
+ _frameIndexes[4] = 20;
+}
+
//////////////////////////////////////////////////////////////////////////
// Event Handling
//////////////////////////////////////////////////////////////////////////
bool PuzzleTimeMachine::init() {
- error("[PuzzleTimeMachine::init] Not implemented!");
+ _counter = 0;
+ getCursor()->set(getWorld()->graphicResourceIds[62], -1, kCursorAnimationMirror, 7);
+
+ _frameCounts[0] = GraphicResource::getFrameCount(_vm, getWorld()->graphicResourceIds[35]);
+ _frameCounts[1] = GraphicResource::getFrameCount(_vm, getWorld()->graphicResourceIds[36]);
+ _frameCounts[2] = GraphicResource::getFrameCount(_vm, getWorld()->graphicResourceIds[37]);
+ _frameCounts[3] = GraphicResource::getFrameCount(_vm, getWorld()->graphicResourceIds[38]);
+ _frameCounts[4] = GraphicResource::getFrameCount(_vm, getWorld()->graphicResourceIds[39]);
+ _frameCounts[5] = GraphicResource::getFrameCount(_vm, getWorld()->graphicResourceIds[40]);
+
+ getScreen()->setPalette(getWorld()->graphicResourceIds[41]);
+ getScreen()->setGammaLevel(getWorld()->graphicResourceIds[41], 0);
+
+ mouseDown();
+
+ return true;
}
bool PuzzleTimeMachine::update() {
- error("[PuzzleTimeMachine::update] Not implemented!");
+ updateCursor();
+
+ // Draw screen elements
+ getScreen()->clearGraphicsInQueue();
+ getScreen()->draw(getWorld()->graphicResourceIds[34]);
+ getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[35], _frameIndexes[0], Common::Point(23, 215), 0, 0, 1);
+ getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[36], _frameIndexes[1], Common::Point(70, 217), 0, 0, 2);
+ getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[37], _frameIndexes[2], Common::Point(189, 217), 0, 0, 3);
+ getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[38], _frameIndexes[3], Common::Point(309, 218), 0, 0, 4);
+ getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[39], _frameIndexes[4], Common::Point(429, 212), 0, 0, 5);
+
+ if (_frameIndexes[0] != 28 || _frameIndexes[1] || _frameIndexes[2] || _frameIndexes[3] || _frameIndexes[4]) {
+ _leftButtonClicked = true;
+ getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[43], 0, Common::Point(599, 220), 0, 0, 5);
+ } else {
+ getSound()->stop(getWorld()->soundResourceIds[17]);
+ getSound()->stop(getWorld()->soundResourceIds[16]);
+
+ if (_vm->isGameFlagNotSet(kGameFlag925))
+ getSound()->playSound(getWorld()->soundResourceIds[18]);
+
+ _vm->setGameFlag(kGameFlag925);
+
+ ++_counter;
+ }
+
+ //getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[40], _frameIndexes[5], puzzleTimeMachinePoints[5], 0, 0, 1);
+
+ //////////////////////////////////////////////////////////////////////////
+ // Show all buttons
+ for (uint32 i = 0; i < ARRAYSIZE(puzzleTimeMachineRects); i += 2) {
+ if (_state[i / 2] != -1)
+ getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[44 + i], 0, Common::Point(puzzleTimeMachineRects[i].left, puzzleTimeMachineRects[i].top), 0, 0, 5);
+ }
+
+ for (uint32 i = 1; i < ARRAYSIZE(puzzleTimeMachineRects); i += 2) {
+ if (_state[i / 2] != 1)
+ getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[45 + i], 0, Common::Point(puzzleTimeMachineRects[i].left, puzzleTimeMachineRects[i].top), 0, 0, 5);
+ }
+
+ // Draw to screen
+ getScreen()->drawGraphicsInQueue();
+ getScreen()->copyBackBufferToScreen();
+
+ // Update data
+ if (_counter > 30 && _vm->isGameFlagSet(kGameFlag925)) {
+ getCursor()->hide();
+ getSharedData()->setFlag(kFlag1, true);
+ getScreen()->setupPaletteAndStartFade(0, 0, 0);
+
+ _vm->switchEventHandler(getScene());
+ }
+
+
+ warning("[PuzzleTimeMachine::update] Not implemented!");
+
+ return true;
+}
+
+bool PuzzleTimeMachine::key(const AsylumEvent &evt) {
+ switch (evt.kbd.keycode) {
+ default:
+ _vm->switchEventHandler(getScene());
+ break;
+
+ case Common::KEYCODE_TAB:
+ getScreen()->takeScreenshot();
+ break;
+ }
+
+ return false;
}
bool PuzzleTimeMachine::mouse(const AsylumEvent &evt) {
- error("[PuzzleTimeMachine::mouse] Not implemented!");
+ switch (evt.type) {
+ case Common::EVENT_RBUTTONDOWN:
+ getCursor()->hide();
+ getSharedData()->setFlag(kFlag1, true);
+ getScreen()->setupPaletteAndStartFade(0, 0, 0);
+ _vm->switchEventHandler(getScene());
+ break;
+
+ case Common::EVENT_LBUTTONDOWN:
+ mouseDown();
+ break;
+
+ case Common::EVENT_LBUTTONUP:
+ _leftButtonClicked = true;
+ break;
+ }
+
+ return true;
+}
+
+void PuzzleTimeMachine::mouseDown() {
+ if (_vm->isGameFlagSet(kGameFlag925))
+ return;
+
+ Common::Point mousePos = getCursor()->position();
+ _leftButtonClicked = false;
+
+ int32 index = -1;
+ for (uint32 i = 0; i < ARRAYSIZE(puzzleTimeMachineRects); i++) {
+ if (puzzleTimeMachineRects[i].contains(mousePos)) {
+ index = i;
+
+ break;
+ }
+ }
+
+ if (index == -1)
+ return;
+
+ getSound()->playSound(getWorld()->soundResourceIds[15]);
+
+ _data_4572CC = true;
+ _data_4572BC = true;
+
+ if (index % -2 == 1) {
+ _frameIncrements[index] = 1;
+ _state[index] = 1;
+ } else {
+ _frameIncrements[index] = -1;
+ _state[index] = -1;
+ }
+}
+
+//////////////////////////////////////////////////////////////////////////
+// Helpers
+//////////////////////////////////////////////////////////////////////////
+void PuzzleTimeMachine::updateCursor() {
+ Common::Point mousePos = getCursor()->position();
+
+ for (uint32 i = 0; i < ARRAYSIZE(puzzleTimeMachineRects); i++) {
+ if (puzzleTimeMachineRects[i].contains(mousePos)) {
+ if (getCursor()->animation != kCursorAnimationMirror)
+ getCursor()->set(getWorld()->graphicResourceIds[62], -1, kCursorAnimationMirror, 7);
+
+ return;
+ }
+ }
+
+ if (getCursor()->animation)
+ getCursor()->set(getWorld()->graphicResourceIds[62], -1, kCursorAnimationNone, 7);
}
} // End of namespace Asylum
diff --git a/engines/asylum/puzzles/timemachine.h b/engines/asylum/puzzles/timemachine.h
index 54762da5f2..0c6f0307cd 100644
--- a/engines/asylum/puzzles/timemachine.h
+++ b/engines/asylum/puzzles/timemachine.h
@@ -37,13 +37,34 @@ public:
PuzzleTimeMachine(AsylumEngine *engine);
~PuzzleTimeMachine();
+ void reset();
+
private:
+ bool _leftButtonClicked;
+ uint32 _counter;
+ uint32 _frameIndexes[6];
+ uint32 _frameCounts[6];
+ int32 _frameIncrements[6];
+ int8 _state[8];
+
+ bool _data_4572BC;
+ bool _data_4572CC;
+
//////////////////////////////////////////////////////////////////////////
// Event Handling
//////////////////////////////////////////////////////////////////////////
bool init();
bool update();
+ bool key(const AsylumEvent &evt);
bool mouse(const AsylumEvent &evt);
+
+ void mouseDown();
+
+ //////////////////////////////////////////////////////////////////////////
+ // Helpers
+ //////////////////////////////////////////////////////////////////////////
+ void updateCursor();
+
};
} // End of namespace Asylum
diff --git a/engines/asylum/shared.h b/engines/asylum/shared.h
index 23423c3deb..cf997c9acb 100644
--- a/engines/asylum/shared.h
+++ b/engines/asylum/shared.h
@@ -141,6 +141,7 @@ enum GameFlag {
kGameFlag881 = 881,
kGameFlag897 = 897,
kGameFlagFinishGame = 901,
+ kGameFlag925 = 925,
kGameFlag937 = 937,
kGameFlag1009 = 1009,
kGameFlag1021 = 1021,
Commit: 05fc5ab399288054b7537115e1414b712853c35b
https://github.com/scummvm/scummvm/commit/05fc5ab399288054b7537115e1414b712853c35b
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:46+02:00
Commit Message:
ASYLUM: Updated chapter 11 name (kResourcePackMorgueAndCemetery)
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@733 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/console.cpp
engines/asylum/shared.h
diff --git a/engines/asylum/console.cpp b/engines/asylum/console.cpp
index 389dd7254d..66a86d9ae0 100644
--- a/engines/asylum/console.cpp
+++ b/engines/asylum/console.cpp
@@ -59,11 +59,11 @@ const ResourcePackId puzzleToScenes[17] = {
kResourcePackLaboratory, // Board Salvation
kResourcePackLaboratory, // Board Youth
kResourcePackLaboratory, // Board Key Hides To
- kResourcePackMorgueCementary, // Writings
+ kResourcePackMorgueAndCemetery, // Writings
kResourcePackInvalid, // ?? (11)
- kResourcePackMorgueCementary, // Morgue Door
+ kResourcePackMorgueAndCemetery, // Morgue Door
kResourcePackMansion, // Clock
- kResourcePackMorgueCementary, // Time Machine
+ kResourcePackMorgueAndCemetery, // Time Machine
kResourcePackLostVillage, // Fisherman
kResourcePackHive, // Hive Machine
kResourcePackHive // Hive Control
diff --git a/engines/asylum/shared.h b/engines/asylum/shared.h
index cf997c9acb..fece84f414 100644
--- a/engines/asylum/shared.h
+++ b/engines/asylum/shared.h
@@ -193,7 +193,7 @@ enum ResourcePackId {
kResourcePackCircusOfFools = 8,
kResourcePackLaboratory = 9,
kResourcePackHive = 10,
- kResourcePackMorgueCementary = 11,
+ kResourcePackMorgueAndCemetery = 11,
kResourcePackLostVillage = 12,
kResourcePackGauntlet = 13,
kResourcePackMansion = 14,
Commit: 2dbec0c5e18aef104fb960c31d889e509b628187
https://github.com/scummvm/scummvm/commit/2dbec0c5e18aef104fb960c31d889e509b628187
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:46+02:00
Commit Message:
ASYLUM: Add reset() method to PuzzleMorgueDoor
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@734 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/puzzles/morguedoor.cpp
engines/asylum/puzzles/morguedoor.h
diff --git a/engines/asylum/puzzles/morguedoor.cpp b/engines/asylum/puzzles/morguedoor.cpp
index 6444042038..89a9c449be 100644
--- a/engines/asylum/puzzles/morguedoor.cpp
+++ b/engines/asylum/puzzles/morguedoor.cpp
@@ -60,6 +60,11 @@ PuzzleMorgueDoor::PuzzleMorgueDoor(AsylumEngine *engine) : Puzzle(engine) {
PuzzleMorgueDoor::~PuzzleMorgueDoor() {
}
+void PuzzleMorgueDoor::reset() {
+ _data_45A9D8 = 0;
+ _data_45A9DC = 0;
+}
+
//////////////////////////////////////////////////////////////////////////
// Event Handling
//////////////////////////////////////////////////////////////////////////
diff --git a/engines/asylum/puzzles/morguedoor.h b/engines/asylum/puzzles/morguedoor.h
index f5372d1505..76888caa91 100644
--- a/engines/asylum/puzzles/morguedoor.h
+++ b/engines/asylum/puzzles/morguedoor.h
@@ -37,6 +37,8 @@ public:
PuzzleMorgueDoor(AsylumEngine *engine);
~PuzzleMorgueDoor();
+ void reset();
+
private:
enum PuzzleObject {
kTopLever = 0,
Commit: ecdfe4532bd7c8db058a81995fa8b7d3653254e3
https://github.com/scummvm/scummvm/commit/ecdfe4532bd7c8db058a81995fa8b7d3653254e3
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:46+02:00
Commit Message:
ASYLUM: Implement frame indexes updates in PuzzleTimeMachine
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@735 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/console.cpp
engines/asylum/puzzles/timemachine.cpp
engines/asylum/puzzles/timemachine.h
diff --git a/engines/asylum/console.cpp b/engines/asylum/console.cpp
index 66a86d9ae0..491e04c42a 100644
--- a/engines/asylum/console.cpp
+++ b/engines/asylum/console.cpp
@@ -59,11 +59,11 @@ const ResourcePackId puzzleToScenes[17] = {
kResourcePackLaboratory, // Board Salvation
kResourcePackLaboratory, // Board Youth
kResourcePackLaboratory, // Board Key Hides To
- kResourcePackMorgueAndCemetery, // Writings
- kResourcePackInvalid, // ?? (11)
- kResourcePackMorgueAndCemetery, // Morgue Door
+ kResourcePackMorgueAndCemetery, // Writings
+ kResourcePackInvalid, // ?? (11)
+ kResourcePackMorgueAndCemetery, // Morgue Door
kResourcePackMansion, // Clock
- kResourcePackMorgueAndCemetery, // Time Machine
+ kResourcePackMorgueAndCemetery, // Time Machine
kResourcePackLostVillage, // Fisherman
kResourcePackHive, // Hive Machine
kResourcePackHive // Hive Control
diff --git a/engines/asylum/puzzles/timemachine.cpp b/engines/asylum/puzzles/timemachine.cpp
index ff3c25c64b..5ae9970809 100644
--- a/engines/asylum/puzzles/timemachine.cpp
+++ b/engines/asylum/puzzles/timemachine.cpp
@@ -62,6 +62,8 @@ const Common::Point puzzleTimeMachinePoints[6] = {
PuzzleTimeMachine::PuzzleTimeMachine(AsylumEngine *engine) : Puzzle(engine) {
_leftButtonClicked = false;
_counter = 0;
+ _counter2 = 0;
+ _currentFrameIndex = 0;
memset(&_frameIndexes, 0, sizeof(_frameIndexes));
memset(&_frameCounts, 0, sizeof(_frameCounts));
memset(&_frameIncrements, 0, sizeof(_frameIncrements));
@@ -69,6 +71,9 @@ PuzzleTimeMachine::PuzzleTimeMachine(AsylumEngine *engine) : Puzzle(engine) {
_data_4572BC = false;
_data_4572CC = false;
+
+ _data_45AAA8 = 0;
+ _data_45AAAC = 0;
}
PuzzleTimeMachine::~PuzzleTimeMachine() {
@@ -80,6 +85,8 @@ void PuzzleTimeMachine::reset() {
_frameIndexes[2] = 20;
_frameIndexes[3] = 16;
_frameIndexes[4] = 20;
+ memset(&_state, 0, sizeof(_state));
+ _data_45AAAC = 0;
}
//////////////////////////////////////////////////////////////////////////
@@ -149,7 +156,7 @@ bool PuzzleTimeMachine::update() {
getScreen()->drawGraphicsInQueue();
getScreen()->copyBackBufferToScreen();
- // Update data
+ // Check for puzzle completion
if (_counter > 30 && _vm->isGameFlagSet(kGameFlag925)) {
getCursor()->hide();
getSharedData()->setFlag(kFlag1, true);
@@ -158,8 +165,42 @@ bool PuzzleTimeMachine::update() {
_vm->switchEventHandler(getScene());
}
+ // Update frame indexes
+ if (_currentFrameIndex == 0 && _frameIncrements[0] != 0) {
+ _data_4572BC = 0;
+ _data_4572CC = 0;
+
+ _frameIndexes[5] += _frameIncrements[0];
+
+ if (_counter2 > 4) {
+ _counter2 = 0;
+
+ if (!getSound()->isPlaying(getWorld()->soundResourceIds[14]))
+ getSound()->playSound(getWorld()->soundResourceIds[14]);
+
+ _frameIndexes[0] += _frameIncrements[0];
+ } else {
+ ++_counter2;
+ }
+ } else {
+ warning("[PuzzleTimeMachine::update] Not implemented!");
+ }
+
+ // Reset frame increments & state
+ if (_counter2 == 0 && _data_4572CC == 0 && _leftButtonClicked && _data_45AAA8 == 0 && _currentFrameIndex == _data_45AAAC) {
+ for (uint32 i = 0; i < 5; i++) {
+ if (!(_frameIndexes[i] % -4))
+ _frameIncrements[i] = 0;
+ }
- warning("[PuzzleTimeMachine::update] Not implemented!");
+ memset(&_state, 0, sizeof(_state));
+ }
+
+ // Adjust frame indexes
+ for (uint32 i = 0; i < ARRAYSIZE(_frameIndexes); i++) {
+ if (_frameIndexes[i] >= _frameCounts[i])
+ _frameIndexes[i] = 0;
+ }
return true;
}
diff --git a/engines/asylum/puzzles/timemachine.h b/engines/asylum/puzzles/timemachine.h
index 0c6f0307cd..4fa3244f96 100644
--- a/engines/asylum/puzzles/timemachine.h
+++ b/engines/asylum/puzzles/timemachine.h
@@ -42,14 +42,19 @@ public:
private:
bool _leftButtonClicked;
uint32 _counter;
+ uint32 _counter2;
+ uint32 _currentFrameIndex;
uint32 _frameIndexes[6];
uint32 _frameCounts[6];
int32 _frameIncrements[6];
- int8 _state[8];
+ int8 _state[5];
bool _data_4572BC;
bool _data_4572CC;
+ uint32 _data_45AAA8;
+ uint32 _data_45AAAC;
+
//////////////////////////////////////////////////////////////////////////
// Event Handling
//////////////////////////////////////////////////////////////////////////
Commit: 81a1d389b1335a7333089fbffda969d67d58e5aa
https://github.com/scummvm/scummvm/commit/81a1d389b1335a7333089fbffda969d67d58e5aa
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:47+02:00
Commit Message:
ASYLUM: Cleanup Screen::clip() and fix wrong sign in Screen::blt()
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@736 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/system/screen.cpp
diff --git a/engines/asylum/system/screen.cpp b/engines/asylum/system/screen.cpp
index 8f36747cbe..04848e960e 100644
--- a/engines/asylum/system/screen.cpp
+++ b/engines/asylum/system/screen.cpp
@@ -43,7 +43,7 @@ Screen::Screen(AsylumEngine *vm) : _vm(vm) ,
_backBuffer.create(640, 480, 1);
_flag = -1;
- _clipRect = Common::Rect(0, 0, 639, 479);
+ _clipRect = Common::Rect(0, 0, 640, 480);
}
Screen::~Screen() {
@@ -75,7 +75,7 @@ void Screen::draw(ResourceId resourceId, uint32 frameIndex, int32 x, int32 y, in
_transTableIndex = index;
}
-void Screen::draw(ResourceId resourceId, uint32 frameIndex, int32 sourceX, int32 sourceY, int32 flags, ResourceId resourceIdDestination, int32 destX, int32 destY, bool colorKey) {
+void Screen::draw(ResourceId resourceId, uint32 frameIndex, int32 x, int32 y, int32 flags, ResourceId resourceIdDestination, int32 destX, int32 destY, bool colorKey) {
// Get the frame to draw
GraphicResource *resource = new GraphicResource(_vm, resourceId);
GraphicFrame *frame = resource->getFrame(frameIndex);
@@ -83,19 +83,19 @@ void Screen::draw(ResourceId resourceId, uint32 frameIndex, int32 sourceX, int32
// Compute coordinates
Common::Rect source;
Common::Rect destination;
- destination.left = sourceX + frame->x;
+ destination.left = x + frame->x;
if (flags & 2) {
if (_flag == -1) {
if ((resource->getData().flags & 15) >= 2) {
- destination.left = sourceX + resource->getData().maxWidth - frame->getWidth() - frame->x;
+ destination.left = x + resource->getData().maxWidth - frame->getWidth() - frame->x;
}
} else {
destination.left += 2 * (_flag - (frame->getHeight() * 2 - frame->x));
}
}
- destination.top = sourceY + frame->y;
+ destination.top = y + frame->y;
destination.right = destination.left + frame->getWidth();
destination.bottom = destination.top + frame->getHeight();
@@ -164,7 +164,7 @@ void Screen::clip(Common::Rect *source, Common::Rect *destination, int32 flags)
source->left += diffLeft;
}
- int32 diffRight = destination->right - _clipRect.right - 1;
+ int32 diffRight = destination->right - _clipRect.right;
if (diffRight > 0) {
destination->right -= diffRight;
@@ -180,7 +180,7 @@ void Screen::clip(Common::Rect *source, Common::Rect *destination, int32 flags)
source->top += diffTop;
}
- int32 diffBottom = destination->bottom - _clipRect.bottom - 1;
+ int32 diffBottom = destination->bottom - _clipRect.bottom;
if (diffBottom > 0) {
source->bottom -= diffBottom;
destination->bottom -= diffBottom;
@@ -426,14 +426,14 @@ void Screen::blit(GraphicFrame *frame, Common::Rect *source, Common::Rect *desti
void Screen::blt(Common::Rect *dest, GraphicFrame* frame, Common::Rect *source, int32 flags, bool useColorKey) {
// TODO adjust destination rect
if (useColorKey) {
- copyToBackBufferWithTransparency((byte *)frame->surface.pixels - (source->top * frame->surface.w + source->left),
+ copyToBackBufferWithTransparency((byte *)frame->surface.pixels + (source->top * frame->surface.w + source->left),
frame->surface.w,
dest->left,
dest->top,
source->width(),
source->height());
} else {
- copyToBackBuffer((byte *)frame->surface.pixels - (source->top * frame->surface.w + source->left),
+ copyToBackBuffer((byte *)frame->surface.pixels + (source->top * frame->surface.w + source->left),
frame->surface.w,
dest->left,
dest->top,
@@ -444,14 +444,14 @@ void Screen::blt(Common::Rect *dest, GraphicFrame* frame, Common::Rect *source,
void Screen::bltFast(int32 dX, int32 dY, GraphicFrame* frame, Common::Rect *source, bool useColorKey) {
if (useColorKey) {
- copyToBackBufferWithTransparency((byte *)frame->surface.pixels - (source->top * frame->surface.w + source->left),
+ copyToBackBufferWithTransparency((byte *)frame->surface.pixels + (source->top * frame->surface.w + source->left),
frame->surface.w,
dX,
dY,
source->width(),
source->height());
} else {
- copyToBackBuffer((byte *)frame->surface.pixels - (source->top * frame->surface.w + source->left),
+ copyToBackBuffer((byte *)frame->surface.pixels + (source->top * frame->surface.w + source->left),
frame->surface.w,
dX,
dY,
Commit: 9284925835b1d5c0a342d5e617c39e3c6906e2c8
https://github.com/scummvm/scummvm/commit/9284925835b1d5c0a342d5e617c39e3c6906e2c8
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:47+02:00
Commit Message:
ASYLUM: Use local _point for coordinates in PuzzleTimeMachine
Those coordinates are updated from the existing points values
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@737 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/puzzles/timemachine.cpp
engines/asylum/puzzles/timemachine.h
diff --git a/engines/asylum/puzzles/timemachine.cpp b/engines/asylum/puzzles/timemachine.cpp
index 5ae9970809..2df55d9499 100644
--- a/engines/asylum/puzzles/timemachine.cpp
+++ b/engines/asylum/puzzles/timemachine.cpp
@@ -87,6 +87,9 @@ void PuzzleTimeMachine::reset() {
_frameIndexes[4] = 20;
memset(&_state, 0, sizeof(_state));
_data_45AAAC = 0;
+
+ // Reset point only (the other values are static)
+ _point = Common::Point(-65, -30);
}
//////////////////////////////////////////////////////////////////////////
@@ -138,7 +141,7 @@ bool PuzzleTimeMachine::update() {
++_counter;
}
- //getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[40], _frameIndexes[5], puzzleTimeMachinePoints[5], 0, 0, 1);
+ getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[40], _frameIndexes[5], _point, 0, 0, 1);
//////////////////////////////////////////////////////////////////////////
// Show all buttons
diff --git a/engines/asylum/puzzles/timemachine.h b/engines/asylum/puzzles/timemachine.h
index 4fa3244f96..aec1a66545 100644
--- a/engines/asylum/puzzles/timemachine.h
+++ b/engines/asylum/puzzles/timemachine.h
@@ -48,6 +48,7 @@ private:
uint32 _frameCounts[6];
int32 _frameIncrements[6];
int8 _state[5];
+ Common::Point _point;
bool _data_4572BC;
bool _data_4572CC;
Commit: b52bed63d86972c4741488aff75a9fe71c7344a0
https://github.com/scummvm/scummvm/commit/b52bed63d86972c4741488aff75a9fe71c7344a0
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:47+02:00
Commit Message:
ASYLUM: Refactor puzzle event handling
- Change default key method to switch back to the scene on right click
- Pass current event to all event handling methods
- Implement mouseLeftDown, mouseLeftUp, mouseRightDown and/or mouseRighUp instead of a single mouse method
- Remove most uses of Cursor::position()
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@738 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/puzzles/boardkeyhidesto.cpp
engines/asylum/puzzles/boardkeyhidesto.h
engines/asylum/puzzles/boardsalvation.cpp
engines/asylum/puzzles/boardsalvation.h
engines/asylum/puzzles/boardyouth.cpp
engines/asylum/puzzles/boardyouth.h
engines/asylum/puzzles/clock.cpp
engines/asylum/puzzles/clock.h
engines/asylum/puzzles/fisherman.cpp
engines/asylum/puzzles/fisherman.h
engines/asylum/puzzles/hivecontrol.cpp
engines/asylum/puzzles/hivecontrol.h
engines/asylum/puzzles/hivemachine.cpp
engines/asylum/puzzles/hivemachine.h
engines/asylum/puzzles/lock.cpp
engines/asylum/puzzles/lock.h
engines/asylum/puzzles/morguedoor.cpp
engines/asylum/puzzles/morguedoor.h
engines/asylum/puzzles/pipes.cpp
engines/asylum/puzzles/pipes.h
engines/asylum/puzzles/puzzle.cpp
engines/asylum/puzzles/puzzle.h
engines/asylum/puzzles/puzzle11.cpp
engines/asylum/puzzles/puzzle11.h
engines/asylum/puzzles/tictactoe.cpp
engines/asylum/puzzles/tictactoe.h
engines/asylum/puzzles/timemachine.cpp
engines/asylum/puzzles/timemachine.h
engines/asylum/puzzles/vcr.cpp
engines/asylum/puzzles/vcr.h
engines/asylum/puzzles/wheel.cpp
engines/asylum/puzzles/wheel.h
engines/asylum/puzzles/writings.cpp
engines/asylum/puzzles/writings.h
diff --git a/engines/asylum/puzzles/boardkeyhidesto.cpp b/engines/asylum/puzzles/boardkeyhidesto.cpp
index da44f724c0..3952938159 100644
--- a/engines/asylum/puzzles/boardkeyhidesto.cpp
+++ b/engines/asylum/puzzles/boardkeyhidesto.cpp
@@ -36,16 +36,16 @@ PuzzleBoardKeyHidesTo::~PuzzleBoardKeyHidesTo() {
//////////////////////////////////////////////////////////////////////////
// Event Handling
//////////////////////////////////////////////////////////////////////////
-bool PuzzleBoardKeyHidesTo::init() {
+bool PuzzleBoardKeyHidesTo::init(const AsylumEvent &evt) {
error("[PuzzleBoardKeyHidesTo::init] Not implemented!");
}
-bool PuzzleBoardKeyHidesTo::update() {
+bool PuzzleBoardKeyHidesTo::update(const AsylumEvent &evt) {
error("[PuzzleBoardKeyHidesTo::update] Not implemented!");
}
-bool PuzzleBoardKeyHidesTo::mouse(const AsylumEvent &evt) {
- error("[PuzzleBoardKeyHidesTo::mouse] Not implemented!");
+bool PuzzleBoardKeyHidesTo::mouseLeftDown(const AsylumEvent &evt) {
+ error("[PuzzleBoardKeyHidesTo::mouseLeftDown] Not implemented!");
}
} // End of namespace Asylum
diff --git a/engines/asylum/puzzles/boardkeyhidesto.h b/engines/asylum/puzzles/boardkeyhidesto.h
index dbe601ab03..9ac8529fb6 100644
--- a/engines/asylum/puzzles/boardkeyhidesto.h
+++ b/engines/asylum/puzzles/boardkeyhidesto.h
@@ -41,9 +41,9 @@ private:
//////////////////////////////////////////////////////////////////////////
// Event Handling
//////////////////////////////////////////////////////////////////////////
- bool init();
- bool update();
- bool mouse(const AsylumEvent &evt);
+ bool init(const AsylumEvent &evt);
+ bool update(const AsylumEvent &evt);
+ bool mouseLeftDown(const AsylumEvent &evt);
};
} // End of namespace Asylum
diff --git a/engines/asylum/puzzles/boardsalvation.cpp b/engines/asylum/puzzles/boardsalvation.cpp
index 0da3284521..9640bca8e8 100644
--- a/engines/asylum/puzzles/boardsalvation.cpp
+++ b/engines/asylum/puzzles/boardsalvation.cpp
@@ -36,16 +36,16 @@ PuzzleBoardSalvation::~PuzzleBoardSalvation() {
//////////////////////////////////////////////////////////////////////////
// Event Handling
//////////////////////////////////////////////////////////////////////////
-bool PuzzleBoardSalvation::init() {
+bool PuzzleBoardSalvation::init(const AsylumEvent &evt) {
error("[PuzzleBoardSalvation::init] Not implemented!");
}
-bool PuzzleBoardSalvation::update() {
+bool PuzzleBoardSalvation::update(const AsylumEvent &evt) {
error("[PuzzleBoardSalvation::update] Not implemented!");
}
-bool PuzzleBoardSalvation::mouse(const AsylumEvent &evt) {
- error("[PuzzleBoardSalvation::mouse] Not implemented!");
+bool PuzzleBoardSalvation::mouseLeftDown(const AsylumEvent &evt) {
+ error("[PuzzleBoardSalvation::mouseLeftDown] Not implemented!");
}
} // End of namespace Asylum
diff --git a/engines/asylum/puzzles/boardsalvation.h b/engines/asylum/puzzles/boardsalvation.h
index 266f112176..b0ee079663 100644
--- a/engines/asylum/puzzles/boardsalvation.h
+++ b/engines/asylum/puzzles/boardsalvation.h
@@ -41,9 +41,9 @@ private:
//////////////////////////////////////////////////////////////////////////
// Event Handling
//////////////////////////////////////////////////////////////////////////
- bool init();
- bool update();
- bool mouse(const AsylumEvent &evt);
+ bool init(const AsylumEvent &evt);
+ bool update(const AsylumEvent &evt);
+ bool mouseLeftDown(const AsylumEvent &evt);
};
} // End of namespace Asylum
diff --git a/engines/asylum/puzzles/boardyouth.cpp b/engines/asylum/puzzles/boardyouth.cpp
index 44e82d7868..c65e6b1e52 100644
--- a/engines/asylum/puzzles/boardyouth.cpp
+++ b/engines/asylum/puzzles/boardyouth.cpp
@@ -36,16 +36,16 @@ PuzzleBoardYouth::~PuzzleBoardYouth() {
//////////////////////////////////////////////////////////////////////////
// Event Handling
//////////////////////////////////////////////////////////////////////////
-bool PuzzleBoardYouth::init() {
+bool PuzzleBoardYouth::init(const AsylumEvent &evt) {
error("[PuzzleBoardYouth::init] Not implemented!");
}
-bool PuzzleBoardYouth::update() {
+bool PuzzleBoardYouth::update(const AsylumEvent &evt) {
error("[PuzzleBoardYouth::update] Not implemented!");
}
-bool PuzzleBoardYouth::mouse(const AsylumEvent &evt) {
- error("[PuzzleBoardYouth::mouse] Not implemented!");
+bool PuzzleBoardYouth::mouseLeftDown(const AsylumEvent &evt) {
+ error("[PuzzleBoardYouth::mouseLeftDown] Not implemented!");
}
} // End of namespace Asylum
diff --git a/engines/asylum/puzzles/boardyouth.h b/engines/asylum/puzzles/boardyouth.h
index f03bdc0b34..c7f80386f3 100644
--- a/engines/asylum/puzzles/boardyouth.h
+++ b/engines/asylum/puzzles/boardyouth.h
@@ -41,9 +41,9 @@ private:
//////////////////////////////////////////////////////////////////////////
// Event Handling
//////////////////////////////////////////////////////////////////////////
- bool init();
- bool update();
- bool mouse(const AsylumEvent &evt);
+ bool init(const AsylumEvent &evt);
+ bool update(const AsylumEvent &evt);
+ bool mouseLeftDown(const AsylumEvent &evt);
};
} // End of namespace Asylum
diff --git a/engines/asylum/puzzles/clock.cpp b/engines/asylum/puzzles/clock.cpp
index 01423f2868..6c81f8ebd7 100644
--- a/engines/asylum/puzzles/clock.cpp
+++ b/engines/asylum/puzzles/clock.cpp
@@ -84,10 +84,10 @@ void PuzzleClock::reset() {
//////////////////////////////////////////////////////////////////////////
// Event Handling
//////////////////////////////////////////////////////////////////////////
-bool PuzzleClock::init() {
+bool PuzzleClock::init(const AsylumEvent &evt) {
_currentRect = -2;
- updateCursor();
+ updateCursor(evt.mouse);
getScreen()->setPalette(getWorld()->graphicResourceIds[6]);
getScreen()->setGammaLevel(getWorld()->graphicResourceIds[6], 0);
@@ -103,7 +103,7 @@ bool PuzzleClock::init() {
return true;
}
-bool PuzzleClock::update() {
+bool PuzzleClock::update(const AsylumEvent &evt) {
// Draw elements
getScreen()->clearGraphicsInQueue();
getScreen()->draw(getWorld()->graphicResourceIds[5]);
@@ -134,31 +134,14 @@ bool PuzzleClock::update() {
_vm->switchEventHandler(getScene());
} else {
if (_vm->isGameFlagSet(kGameFlag511))
- mouseRight();
+ mouseRightDown(evt);
}
return true;
}
-bool PuzzleClock::mouse(const AsylumEvent &evt) {
- switch (evt.type) {
- default:
- break;
-
- case Common::EVENT_RBUTTONDOWN:
- mouseRight();
- break;
-
- case Common::EVENT_LBUTTONDOWN:
- return mouseLeft();
- break;
- }
-
- return true;
-}
-
-bool PuzzleClock::mouseLeft() {
- int32 index = findRect();
+bool PuzzleClock::mouseLeftDown(const AsylumEvent &evt) {
+ int32 index = findRect(evt.mouse);
if (index == -1)
return false;
@@ -173,16 +156,18 @@ bool PuzzleClock::mouseLeft() {
return true;
}
-void PuzzleClock::mouseRight() {
+bool PuzzleClock::mouseRightDown(const AsylumEvent &evt) {
setFlag();
_rightButtonClicked = true;
+
+ return true;
}
//////////////////////////////////////////////////////////////////////////
// Helpers
//////////////////////////////////////////////////////////////////////////
-void PuzzleClock::updateCursor() {
- int32 index = findRect();
+void PuzzleClock::updateCursor(Common::Point mousePos) {
+ int32 index = findRect(mousePos);
if (index != _currentRect) {
_currentRect = index;
@@ -194,14 +179,7 @@ void PuzzleClock::updateCursor() {
}
}
-void PuzzleClock::setFlag() {
- if (_frameIndexes[2] == puzzleClockFrameIndexes[11])
- _vm->setGameFlag(kGameFlag511);
-}
-
-int32 PuzzleClock::findRect() {
- Common::Point mousePos = getCursor()->position();
-
+int32 PuzzleClock::findRect(Common::Point mousePos) {
for (uint32 i = 0; i < ARRAYSIZE(puzzleClockRects); i++) {
if (puzzleClockRects[i].contains(mousePos))
return i;
@@ -210,4 +188,9 @@ int32 PuzzleClock::findRect() {
return -1;
}
+void PuzzleClock::setFlag() {
+ if (_frameIndexes[2] == puzzleClockFrameIndexes[11])
+ _vm->setGameFlag(kGameFlag511);
+}
+
} // End of namespace Asylum
diff --git a/engines/asylum/puzzles/clock.h b/engines/asylum/puzzles/clock.h
index 75e46b2870..ae59ba0fe4 100644
--- a/engines/asylum/puzzles/clock.h
+++ b/engines/asylum/puzzles/clock.h
@@ -49,19 +49,17 @@ private:
//////////////////////////////////////////////////////////////////////////
// Event Handling
//////////////////////////////////////////////////////////////////////////
- bool init();
- bool update();
- bool mouse(const AsylumEvent &evt);
-
- bool mouseLeft();
- void mouseRight();
+ bool init(const AsylumEvent &evt);
+ bool update(const AsylumEvent &evt);
+ bool mouseLeftDown(const AsylumEvent &evt);
+ bool mouseRightDown(const AsylumEvent &evt);
//////////////////////////////////////////////////////////////////////////
// Helpers
//////////////////////////////////////////////////////////////////////////
- void updateCursor();
+ void updateCursor(Common::Point mousePos);
+ int32 findRect(Common::Point mousePos);
void setFlag();
- int32 findRect();
};
} // End of namespace Asylum
diff --git a/engines/asylum/puzzles/fisherman.cpp b/engines/asylum/puzzles/fisherman.cpp
index 27208a7bbb..85dfdc62aa 100644
--- a/engines/asylum/puzzles/fisherman.cpp
+++ b/engines/asylum/puzzles/fisherman.cpp
@@ -82,7 +82,7 @@ void PuzzleFisherman::reset() {
//////////////////////////////////////////////////////////////////////////
// Event Handling
//////////////////////////////////////////////////////////////////////////
-bool PuzzleFisherman::init() {
+bool PuzzleFisherman::init(const AsylumEvent &evt) {
getCursor()->set(getWorld()->graphicResourceIds[47], -1, kCursorAnimationMirror, 7);
for (uint32 i = 0; i < ARRAYSIZE(_state); i++)
@@ -98,11 +98,11 @@ bool PuzzleFisherman::init() {
getScreen()->setPalette(getWorld()->graphicResourceIds[39]);
getScreen()->setGammaLevel(getWorld()->graphicResourceIds[39], 0);
- return mouseDown();
+ return mouseLeftDown(evt);
}
-bool PuzzleFisherman::update() {
- updateCursor();
+bool PuzzleFisherman::update(const AsylumEvent &evt) {
+ updateCursor(evt);
// Draw background
getScreen()->clearGraphicsInQueue();
@@ -150,46 +150,12 @@ bool PuzzleFisherman::update() {
return true;
}
-bool PuzzleFisherman::key(const AsylumEvent &evt) {
- switch (evt.kbd.keycode) {
- default:
- _vm->switchEventHandler(getScene());
- break;
-
- case Common::KEYCODE_TAB:
- getScreen()->takeScreenshot();
- break;
- }
-
- return false;
-}
-
-bool PuzzleFisherman::mouse(const AsylumEvent &evt) {
- switch (evt.type) {
- case Common::EVENT_LBUTTONDOWN:
- return mouseDown();
- break;
-
- case Common::EVENT_RBUTTONDOWN:
- getCursor()->hide();
- getSharedData()->setFlag(kFlag1, true);
- getScreen()->setupPaletteAndStartFade(0, 0, 0);
-
- _vm->switchEventHandler(getScene());
- break;
- }
-
- return false;
-}
-
-bool PuzzleFisherman::mouseDown() {
+bool PuzzleFisherman::mouseLeftDown(const AsylumEvent &evt) {
if (!_dword_45A130)
return false;
- Common::Point mousePos = getCursor()->position();
-
for (uint32 i = 0; i < 7; i++) {
- if (hitTest(&puzzleFishermanPolygons[i * 4 + 7], mousePos)) {
+ if (hitTest(&puzzleFishermanPolygons[i * 4 + 7], evt.mouse)) {
if (!_state[i]) {
getSound()->playSound(getWorld()->graphicResourceIds[9], false, Config.sfxVolume - 10);
_state[i] = true;
@@ -198,10 +164,10 @@ bool PuzzleFisherman::mouseDown() {
}
}
- if (puzzleFishermanPolygons[6].x < mousePos.x
- && puzzleFishermanPolygons[6].y < mousePos.y
- && puzzleFishermanPolygons[6].x + 70 > mousePos.x
- && puzzleFishermanPolygons[6].y + 30 > mousePos.y) {
+ if (puzzleFishermanPolygons[6].x < evt.mouse.x
+ && puzzleFishermanPolygons[6].y < evt.mouse.y
+ && puzzleFishermanPolygons[6].x + 70 > evt.mouse.x
+ && puzzleFishermanPolygons[6].y + 30 > evt.mouse.y) {
getSound()->playSound(getWorld()->graphicResourceIds[10], false, Config.sfxVolume - 10);
for (uint32 i = 0; i < 6; i++)
@@ -216,18 +182,27 @@ bool PuzzleFisherman::mouseDown() {
return true;
}
+bool PuzzleFisherman::mouseRightDown(const AsylumEvent &evt) {
+ getCursor()->hide();
+ getSharedData()->setFlag(kFlag1, true);
+ getScreen()->setupPaletteAndStartFade(0, 0, 0);
+
+ _vm->switchEventHandler(getScene());
+
+ return false;
+}
+
//////////////////////////////////////////////////////////////////////////
// Helpers
//////////////////////////////////////////////////////////////////////////
-void PuzzleFisherman::updateCursor() {
- Common::Point mousePos = getCursor()->position();
+void PuzzleFisherman::updateCursor(const AsylumEvent &evt) {
bool found = false;
for (uint32 i = 0; i < 6; i++) {
if (found)
break;
- if (hitTest(&puzzleFishermanPolygons[i * 4 + 7], mousePos)) {
+ if (hitTest(&puzzleFishermanPolygons[i * 4 + 7], evt.mouse)) {
if (!_state[i]) {
found = true;
@@ -240,10 +215,10 @@ void PuzzleFisherman::updateCursor() {
if (found)
return;
- if (puzzleFishermanPolygons[6].x >= mousePos.x
- || puzzleFishermanPolygons[6].y >= mousePos.y
- || puzzleFishermanPolygons[6].x + 70 <= mousePos.x
- || puzzleFishermanPolygons[6].y + 30 <= mousePos.y) {
+ if (puzzleFishermanPolygons[6].x >= evt.mouse.x
+ || puzzleFishermanPolygons[6].y >= evt.mouse.y
+ || puzzleFishermanPolygons[6].x + 70 <= evt.mouse.x
+ || puzzleFishermanPolygons[6].y + 30 <= evt.mouse.y) {
if (getCursor()->animation != kCursorAnimationNone)
getCursor()->set(getWorld()->graphicResourceIds[47], -1, kCursorAnimationNone, 7);
else if (getCursor()->animation != kCursorAnimationMirror)
diff --git a/engines/asylum/puzzles/fisherman.h b/engines/asylum/puzzles/fisherman.h
index 68fd0a1976..5d56e8369c 100644
--- a/engines/asylum/puzzles/fisherman.h
+++ b/engines/asylum/puzzles/fisherman.h
@@ -50,17 +50,15 @@ private:
//////////////////////////////////////////////////////////////////////////
// Event Handling
//////////////////////////////////////////////////////////////////////////
- bool init();
- bool update();
- bool key(const AsylumEvent &evt);
- bool mouse(const AsylumEvent &evt);
-
- bool mouseDown();
+ bool init(const AsylumEvent &evt);
+ bool update(const AsylumEvent &evt);
+ bool mouseLeftDown(const AsylumEvent &evt);
+ bool mouseRightDown(const AsylumEvent &evt);
//////////////////////////////////////////////////////////////////////////
// Helpers
//////////////////////////////////////////////////////////////////////////
- void updateCursor();
+ void updateCursor(const AsylumEvent &evt);
void setFlags(uint32 index);
};
diff --git a/engines/asylum/puzzles/hivecontrol.cpp b/engines/asylum/puzzles/hivecontrol.cpp
index 09a226adfa..d8c6d0ba66 100644
--- a/engines/asylum/puzzles/hivecontrol.cpp
+++ b/engines/asylum/puzzles/hivecontrol.cpp
@@ -36,16 +36,16 @@ PuzzleHiveControl::~PuzzleHiveControl() {
//////////////////////////////////////////////////////////////////////////
// Event Handling
//////////////////////////////////////////////////////////////////////////
-bool PuzzleHiveControl::init() {
+bool PuzzleHiveControl::init(const AsylumEvent &evt) {
error("[PuzzleHiveControl::init] Not implemented!");
}
-bool PuzzleHiveControl::update() {
+bool PuzzleHiveControl::update(const AsylumEvent &evt) {
error("[PuzzleHiveControl::update] Not implemented!");
}
-bool PuzzleHiveControl::mouse(const AsylumEvent &evt) {
- error("[PuzzleHiveControl::mouse] Not implemented!");
+bool PuzzleHiveControl::mouseLeftDown(const AsylumEvent &evt) {
+ error("[PuzzleHiveControl::mouseLeftDown] Not implemented!");
}
} // End of namespace Asylum
diff --git a/engines/asylum/puzzles/hivecontrol.h b/engines/asylum/puzzles/hivecontrol.h
index 5c6dc74948..13d02f526d 100644
--- a/engines/asylum/puzzles/hivecontrol.h
+++ b/engines/asylum/puzzles/hivecontrol.h
@@ -41,9 +41,9 @@ private:
//////////////////////////////////////////////////////////////////////////
// Event Handling
//////////////////////////////////////////////////////////////////////////
- bool init();
- bool update();
- bool mouse(const AsylumEvent &evt);
+ bool init(const AsylumEvent &evt);
+ bool update(const AsylumEvent &evt);
+ bool mouseLeftDown(const AsylumEvent &evt);
};
} // End of namespace Asylum
diff --git a/engines/asylum/puzzles/hivemachine.cpp b/engines/asylum/puzzles/hivemachine.cpp
index d9753d354f..56d18ebbff 100644
--- a/engines/asylum/puzzles/hivemachine.cpp
+++ b/engines/asylum/puzzles/hivemachine.cpp
@@ -36,16 +36,16 @@ PuzzleHiveMachine::~PuzzleHiveMachine() {
//////////////////////////////////////////////////////////////////////////
// Event Handling
//////////////////////////////////////////////////////////////////////////
-bool PuzzleHiveMachine::init() {
+bool PuzzleHiveMachine::init(const AsylumEvent &evt) {
error("[PuzzleHiveMachine::init] Not implemented!");
}
-bool PuzzleHiveMachine::update() {
+bool PuzzleHiveMachine::update(const AsylumEvent &evt) {
error("[PuzzleHiveMachine::update] Not implemented!");
}
-bool PuzzleHiveMachine::mouse(const AsylumEvent &evt) {
- error("[PuzzleHiveMachine::mouse] Not implemented!");
+bool PuzzleHiveMachine::mouseLeftDown(const AsylumEvent &evt) {
+ error("[PuzzleHiveMachine::mouseLeftDown] Not implemented!");
}
} // End of namespace Asylum
diff --git a/engines/asylum/puzzles/hivemachine.h b/engines/asylum/puzzles/hivemachine.h
index 63242c82bc..f733f71187 100644
--- a/engines/asylum/puzzles/hivemachine.h
+++ b/engines/asylum/puzzles/hivemachine.h
@@ -41,9 +41,9 @@ private:
//////////////////////////////////////////////////////////////////////////
// Event Handling
//////////////////////////////////////////////////////////////////////////
- bool init();
- bool update();
- bool mouse(const AsylumEvent &evt);
+ bool init(const AsylumEvent &evt);
+ bool update(const AsylumEvent &evt);
+ bool mouseLeftDown(const AsylumEvent &evt);
};
} // End of namespace Asylum
diff --git a/engines/asylum/puzzles/lock.cpp b/engines/asylum/puzzles/lock.cpp
index 94aa803627..bd5a2c332e 100644
--- a/engines/asylum/puzzles/lock.cpp
+++ b/engines/asylum/puzzles/lock.cpp
@@ -36,16 +36,16 @@ PuzzleLock::~PuzzleLock() {
//////////////////////////////////////////////////////////////////////////
// Event Handling
//////////////////////////////////////////////////////////////////////////
-bool PuzzleLock::init() {
+bool PuzzleLock::init(const AsylumEvent &evt) {
error("[PuzzleLock::init] Not implemented!");
}
-bool PuzzleLock::update() {
+bool PuzzleLock::update(const AsylumEvent &evt) {
error("[PuzzleLock::update] Not implemented!");
}
-bool PuzzleLock::mouse(const AsylumEvent &evt) {
- error("[PuzzleLock::mouse] Not implemented!");
+bool PuzzleLock::mouseLeftDown(const AsylumEvent &evt) {
+ error("[PuzzleLock::mouseLeftDown] Not implemented!");
}
} // End of namespace Asylum
diff --git a/engines/asylum/puzzles/lock.h b/engines/asylum/puzzles/lock.h
index 79ff52f94f..dd12e3f24c 100644
--- a/engines/asylum/puzzles/lock.h
+++ b/engines/asylum/puzzles/lock.h
@@ -41,9 +41,9 @@ private:
//////////////////////////////////////////////////////////////////////////
// Event Handling
//////////////////////////////////////////////////////////////////////////
- bool init();
- bool update();
- bool mouse(const AsylumEvent &evt);
+ bool init(const AsylumEvent &evt);
+ bool update(const AsylumEvent &evt);
+ bool mouseLeftDown(const AsylumEvent &evt);
};
} // End of namespace Asylum
diff --git a/engines/asylum/puzzles/morguedoor.cpp b/engines/asylum/puzzles/morguedoor.cpp
index 89a9c449be..eaf5882f8e 100644
--- a/engines/asylum/puzzles/morguedoor.cpp
+++ b/engines/asylum/puzzles/morguedoor.cpp
@@ -68,7 +68,7 @@ void PuzzleMorgueDoor::reset() {
//////////////////////////////////////////////////////////////////////////
// Event Handling
//////////////////////////////////////////////////////////////////////////
-bool PuzzleMorgueDoor::init() {
+bool PuzzleMorgueDoor::init(const AsylumEvent &evt) {
getCursor()->set(getWorld()->graphicResourceIds[33], -1, kCursorAnimationNone, 7);
_frameCounts[kTopLever] = GraphicResource::getFrameCount(_vm, getWorld()->graphicResourceIds[21]);
@@ -85,11 +85,11 @@ bool PuzzleMorgueDoor::init() {
getScreen()->setPalette(getWorld()->graphicResourceIds[20]);
getScreen()->setGammaLevel(getWorld()->graphicResourceIds[20], 0);
- return mouseDown();
+ return mouseLeftDown(evt);
}
-bool PuzzleMorgueDoor::update() {
- updateCursor();
+bool PuzzleMorgueDoor::update(const AsylumEvent &evt) {
+ updateCursor(evt.mouse);
// Draw elements
getScreen()->clearGraphicsInQueue();
@@ -120,40 +120,8 @@ bool PuzzleMorgueDoor::update() {
return true;
}
-bool PuzzleMorgueDoor::key(const AsylumEvent &evt) {
- switch (evt.kbd.keycode) {
- default:
- _vm->switchEventHandler(getScene());
- break;
-
- case Common::KEYCODE_TAB:
- getScreen()->takeScreenshot();
- break;
- }
-
- return true;
-}
-
-bool PuzzleMorgueDoor::mouse(const AsylumEvent &evt) {
- switch (evt.type) {
- case Common::EVENT_LBUTTONDOWN:
- return mouseDown();
- break;
-
- case Common::EVENT_RBUTTONUP:
- getCursor()->hide();
- getSharedData()->setFlag(kFlag1, true);
- getScreen()->setupPaletteAndStartFade(0, 0, 0);
-
- _vm->switchEventHandler(getScene());
- break;
- }
-
- return false;
-}
-
-bool PuzzleMorgueDoor::mouseDown() {
- Common::Point mousePos = getCursor()->position();
+bool PuzzleMorgueDoor::mouseLeftDown(const AsylumEvent &evt) {
+ Common::Point mousePos = evt.mouse;
// Top small lever
if (mousePos.x > 347 && mousePos.x < 357
@@ -229,12 +197,20 @@ bool PuzzleMorgueDoor::mouseDown() {
return true;
}
+bool PuzzleMorgueDoor::mouseRightUp(const AsylumEvent &evt) {
+ getCursor()->hide();
+ getSharedData()->setFlag(kFlag1, true);
+ getScreen()->setupPaletteAndStartFade(0, 0, 0);
+
+ _vm->switchEventHandler(getScene());
+
+ return false;
+}
+
//////////////////////////////////////////////////////////////////////////
// Helpers
//////////////////////////////////////////////////////////////////////////
-void PuzzleMorgueDoor::updateCursor() {
- Common::Point mousePos = getCursor()->position();
-
+void PuzzleMorgueDoor::updateCursor(Common::Point mousePos) {
bool animate = false;
if (mousePos.x > 347 && mousePos.x < 357 && mousePos.y > 124 && mousePos.y < 154)
diff --git a/engines/asylum/puzzles/morguedoor.h b/engines/asylum/puzzles/morguedoor.h
index 76888caa91..2ff55911d3 100644
--- a/engines/asylum/puzzles/morguedoor.h
+++ b/engines/asylum/puzzles/morguedoor.h
@@ -76,17 +76,15 @@ private:
//////////////////////////////////////////////////////////////////////////
// Event Handling
//////////////////////////////////////////////////////////////////////////
- bool init();
- bool update();
- bool key(const AsylumEvent &evt);
- bool mouse(const AsylumEvent &evt);
-
- bool mouseDown();
+ bool init(const AsylumEvent &evt);
+ bool update(const AsylumEvent &evt);
+ bool mouseLeftDown(const AsylumEvent &evt);
+ bool mouseRightUp(const AsylumEvent &evt);
//////////////////////////////////////////////////////////////////////////
// Helpers
//////////////////////////////////////////////////////////////////////////
- void updateCursor();
+ void updateCursor(Common::Point mousePos);
void updateState();
};
diff --git a/engines/asylum/puzzles/pipes.cpp b/engines/asylum/puzzles/pipes.cpp
index a3ccccc53c..4372ea9515 100644
--- a/engines/asylum/puzzles/pipes.cpp
+++ b/engines/asylum/puzzles/pipes.cpp
@@ -36,16 +36,16 @@ PuzzlePipes::~PuzzlePipes() {
//////////////////////////////////////////////////////////////////////////
// Event Handling
//////////////////////////////////////////////////////////////////////////
-bool PuzzlePipes::init() {
+bool PuzzlePipes::init(const AsylumEvent &evt) {
error("[PuzzlePipes::init] Not implemented!");
}
-bool PuzzlePipes::update() {
+bool PuzzlePipes::update(const AsylumEvent &evt) {
error("[PuzzlePipes::update] Not implemented!");
}
-bool PuzzlePipes::mouse(const AsylumEvent &evt) {
- error("[PuzzlePipes::mouse] Not implemented!");
+bool PuzzlePipes::mouseLeftDown(const AsylumEvent &evt) {
+ error("[PuzzlePipes::mouseLeftDown] Not implemented!");
}
} // End of namespace Asylum
diff --git a/engines/asylum/puzzles/pipes.h b/engines/asylum/puzzles/pipes.h
index 7d5d16ad88..be206d8b97 100644
--- a/engines/asylum/puzzles/pipes.h
+++ b/engines/asylum/puzzles/pipes.h
@@ -41,9 +41,9 @@ private:
//////////////////////////////////////////////////////////////////////////
// Event Handling
//////////////////////////////////////////////////////////////////////////
- bool init();
- bool update();
- bool mouse(const AsylumEvent &evt);
+ bool init(const AsylumEvent &evt);
+ bool update(const AsylumEvent &evt);
+ bool mouseLeftDown(const AsylumEvent &evt);
};
} // End of namespace Asylum
diff --git a/engines/asylum/puzzles/puzzle.cpp b/engines/asylum/puzzles/puzzle.cpp
index 743924b800..bbdc24ac78 100644
--- a/engines/asylum/puzzles/puzzle.cpp
+++ b/engines/asylum/puzzles/puzzle.cpp
@@ -55,27 +55,28 @@ bool Puzzle::handleEvent(const AsylumEvent &evt) {
break;
case EVENT_ASYLUM_INIT:
- return init();
- break;
+ return init(evt);
case EVENT_ASYLUM_ACTIVATE:
- return activate();
- break;
+ return activate(evt);
case EVENT_ASYLUM_UPDATE:
- return update();
- break;
+ return update(evt);
case Common::EVENT_KEYDOWN:
return key(evt);
- break;
case Common::EVENT_LBUTTONDOWN:
+ return mouseLeftDown(evt);
+
case Common::EVENT_LBUTTONUP:
+ return mouseLeftUp(evt);
+
case Common::EVENT_RBUTTONDOWN:
+ return mouseRightDown(evt);
+
case Common::EVENT_RBUTTONUP:
- return mouse(evt);
- break;
+ return mouseRightUp(evt);
}
return false;
@@ -84,6 +85,7 @@ bool Puzzle::handleEvent(const AsylumEvent &evt) {
bool Puzzle::key(const AsylumEvent &evt) {
switch (evt.kbd.keycode) {
default:
+ _vm->switchEventHandler(getScene());
break;
case Common::KEYCODE_TAB:
diff --git a/engines/asylum/puzzles/puzzle.h b/engines/asylum/puzzles/puzzle.h
index ae18af17e7..4c33fc7158 100644
--- a/engines/asylum/puzzles/puzzle.h
+++ b/engines/asylum/puzzles/puzzle.h
@@ -56,11 +56,14 @@ protected:
//////////////////////////////////////////////////////////////////////////
// Event Handling
//////////////////////////////////////////////////////////////////////////
- virtual bool init() = 0;
- virtual bool update() = 0;
- virtual bool activate() { return true; }
+ virtual bool init(const AsylumEvent &evt) = 0;
+ virtual bool update(const AsylumEvent &evt) = 0;
+ virtual bool activate(const AsylumEvent &evt) { return true; }
virtual bool key(const AsylumEvent &evt);
- virtual bool mouse(const AsylumEvent &evt) = 0;
+ virtual bool mouseLeftUp(const AsylumEvent &evt) { return true; }
+ virtual bool mouseLeftDown(const AsylumEvent &evt) { return true; }
+ virtual bool mouseRightUp(const AsylumEvent &evt) { return true; }
+ virtual bool mouseRightDown(const AsylumEvent &evt) { return true; }
void exit();
diff --git a/engines/asylum/puzzles/puzzle11.cpp b/engines/asylum/puzzles/puzzle11.cpp
index 69f9fc1293..382b68b091 100644
--- a/engines/asylum/puzzles/puzzle11.cpp
+++ b/engines/asylum/puzzles/puzzle11.cpp
@@ -52,7 +52,7 @@ Puzzle11::~Puzzle11() {
//////////////////////////////////////////////////////////////////////////
// Event Handling
//////////////////////////////////////////////////////////////////////////
-bool Puzzle11::init() {
+bool Puzzle11::init(const AsylumEvent &evt) {
getPuzzleData()->timeMachineCounter = 0;
getScreen()->setPalette(getWorld()->graphicResourceIds[12]);
@@ -67,12 +67,12 @@ bool Puzzle11::init() {
_frameCounts[3] = GraphicResource::getFrameCount(_vm, getWorld()->graphicResourceIds[56]);
_frameCounts[4] = GraphicResource::getFrameCount(_vm, getWorld()->graphicResourceIds[13]);
- mouseDown();
+ mouseLeftDown(evt);
return true;
}
-bool Puzzle11::update() {
+bool Puzzle11::update(const AsylumEvent &evt) {
getScreen()->clearGraphicsInQueue();
getScreen()->draw(getWorld()->graphicResourceIds[11]);
getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[15], _frameIndexes[0], Common::Point(122, 269), 0, 0, 1);
@@ -88,51 +88,26 @@ bool Puzzle11::update() {
return true;
}
-bool Puzzle11::key(const AsylumEvent &evt) {
- switch (evt.kbd.keycode) {
- default:
- _vm->switchEventHandler(getScene());
- break;
-
- case Common::KEYCODE_TAB:
- getScreen()->takeScreenshot();
- break;
- }
+bool Puzzle11::mouseRightDown(const AsylumEvent &evt) {
+ warning("[Puzzle11::mouseUp] Not implemented!");
return false;
}
-bool Puzzle11::mouse(const AsylumEvent &evt) {
- switch (evt.type) {
- default:
- break;
-
- case Common::EVENT_RBUTTONDOWN:
- getCursor()->hide();
- getSharedData()->setFlag(kFlag1, true);
- getScreen()->setupPaletteAndStartFade(0, 0, 0);
-
- _vm->switchEventHandler(getScene());
- break;
-
- case Common::EVENT_LBUTTONUP:
- mouseUp();
- break;
+bool Puzzle11::mouseLeftUp(const AsylumEvent &evt) {
+ getCursor()->hide();
+ getSharedData()->setFlag(kFlag1, true);
+ getScreen()->setupPaletteAndStartFade(0, 0, 0);
- case Common::EVENT_LBUTTONDOWN:
- mouseDown();
- return true;
- }
+ _vm->switchEventHandler(getScene());
return false;
}
-void Puzzle11::mouseUp() {
- warning("[Puzzle11::mouseUp] Not implemented!");
-}
-
-void Puzzle11::mouseDown() {
+bool Puzzle11::mouseLeftDown(const AsylumEvent &evt) {
warning("[Puzzle11::mouseDown] Not implemented!");
+
+ return true;
}
} // End of namespace Asylum
diff --git a/engines/asylum/puzzles/puzzle11.h b/engines/asylum/puzzles/puzzle11.h
index 51a81bd039..3501258630 100644
--- a/engines/asylum/puzzles/puzzle11.h
+++ b/engines/asylum/puzzles/puzzle11.h
@@ -47,13 +47,11 @@ private:
//////////////////////////////////////////////////////////////////////////
// Event Handling
//////////////////////////////////////////////////////////////////////////
- bool init();
- bool update();
- bool key(const AsylumEvent &evt);
- bool mouse(const AsylumEvent &evt);
-
- void mouseUp();
- void mouseDown();
+ bool init(const AsylumEvent &evt);
+ bool update(const AsylumEvent &evt);
+ bool mouseLeftDown(const AsylumEvent &evt);
+ bool mouseLeftUp(const AsylumEvent &evt);
+ bool mouseRightDown(const AsylumEvent &evt);
};
} // End of namespace Asylum
diff --git a/engines/asylum/puzzles/tictactoe.cpp b/engines/asylum/puzzles/tictactoe.cpp
index f9cfb1c40f..c44ef43d84 100644
--- a/engines/asylum/puzzles/tictactoe.cpp
+++ b/engines/asylum/puzzles/tictactoe.cpp
@@ -103,7 +103,7 @@ PuzzleTicTacToe::~PuzzleTicTacToe() {
//////////////////////////////////////////////////////////////////////////
// Event Handling
//////////////////////////////////////////////////////////////////////////
-bool PuzzleTicTacToe::init() {
+bool PuzzleTicTacToe::init(const AsylumEvent &evt) {
_ticker = 0;
_vm->clearGameFlag(kGameFlag114);
_vm->clearGameFlag(kGameFlag215);
@@ -123,7 +123,7 @@ bool PuzzleTicTacToe::init() {
return true;
}
-bool PuzzleTicTacToe::update() {
+bool PuzzleTicTacToe::update(const AsylumEvent &evt) {
if (_ticker) {
++_ticker;
@@ -152,44 +152,11 @@ bool PuzzleTicTacToe::update() {
return true;
}
-bool PuzzleTicTacToe::key(const AsylumEvent &evt) {
- switch (evt.kbd.keycode) {
- default:
- _vm->switchEventHandler(getScene());
- break;
-
- case Common::KEYCODE_TAB:
- getScreen()->takeScreenshot();
- break;
- }
-
- return true;
-}
-
-bool PuzzleTicTacToe::mouse(const AsylumEvent &evt) {
- switch (evt.type) {
- default:
- break;
-
- case Common::EVENT_RBUTTONDOWN:
- exit();
- break;
-
- case Common::EVENT_LBUTTONDOWN:
- mouseLeft();
- break;
- }
-
- return true;
-}
-
-void PuzzleTicTacToe::mouseLeft() {
- Common::Point mousePos = getCursor()->position();
-
+bool PuzzleTicTacToe::mouseLeftDown(const AsylumEvent &evt) {
if (!_vm->isGameFlagNotSet(kGameFlag215) || !_vm->isGameFlagNotSet(kGameFlag114)) {
getCursor()->show();
exit();
- return;
+ return true;
}
if (_needToInitialize) {
@@ -199,11 +166,11 @@ void PuzzleTicTacToe::mouseLeft() {
_strikeOutPosition = -1;
initField();
- return;
+ return true;
}
for (uint32 i = 0; i < ARRAYSIZE(_gameField); i++) {
- if (hitTest(&puzzleTicTacToePolygons[i * 4], mousePos, 0)) {
+ if (hitTest(&puzzleTicTacToePolygons[i * 4], evt.mouse, 0)) {
if (_gameField[i] == ' ') {
getSound()->playSound(getWorld()->soundResourceIds[11], false, Config.sfxVolume - 100);
_gameField[i] = 'X';
@@ -214,6 +181,14 @@ void PuzzleTicTacToe::mouseLeft() {
}
}
}
+
+ return true;
+}
+
+bool PuzzleTicTacToe::mouseRightDown(const AsylumEvent &) {
+ exit();
+
+ return true;
}
//////////////////////////////////////////////////////////////////////////
diff --git a/engines/asylum/puzzles/tictactoe.h b/engines/asylum/puzzles/tictactoe.h
index 0fc0686a35..e2a8053573 100644
--- a/engines/asylum/puzzles/tictactoe.h
+++ b/engines/asylum/puzzles/tictactoe.h
@@ -61,12 +61,10 @@ private:
//////////////////////////////////////////////////////////////////////////
// Event Handling
//////////////////////////////////////////////////////////////////////////
- bool init();
- bool update();
- bool key(const AsylumEvent &evt);
- bool mouse(const AsylumEvent &evt);
-
- void mouseLeft();
+ bool init(const AsylumEvent &evt);
+ bool update(const AsylumEvent &evt);
+ bool mouseLeftDown(const AsylumEvent &evt);
+ bool mouseRightDown(const AsylumEvent &evt);
//////////////////////////////////////////////////////////////////////////
// Init & update
diff --git a/engines/asylum/puzzles/timemachine.cpp b/engines/asylum/puzzles/timemachine.cpp
index 2df55d9499..b4875beea8 100644
--- a/engines/asylum/puzzles/timemachine.cpp
+++ b/engines/asylum/puzzles/timemachine.cpp
@@ -95,7 +95,7 @@ void PuzzleTimeMachine::reset() {
//////////////////////////////////////////////////////////////////////////
// Event Handling
//////////////////////////////////////////////////////////////////////////
-bool PuzzleTimeMachine::init() {
+bool PuzzleTimeMachine::init(const AsylumEvent &evt) {
_counter = 0;
getCursor()->set(getWorld()->graphicResourceIds[62], -1, kCursorAnimationMirror, 7);
@@ -109,13 +109,13 @@ bool PuzzleTimeMachine::init() {
getScreen()->setPalette(getWorld()->graphicResourceIds[41]);
getScreen()->setGammaLevel(getWorld()->graphicResourceIds[41], 0);
- mouseDown();
+ mouseLeftDown(evt);
return true;
}
-bool PuzzleTimeMachine::update() {
- updateCursor();
+bool PuzzleTimeMachine::update(const AsylumEvent &evt) {
+ updateCursor(evt);
// Draw screen elements
getScreen()->clearGraphicsInQueue();
@@ -208,51 +208,15 @@ bool PuzzleTimeMachine::update() {
return true;
}
-bool PuzzleTimeMachine::key(const AsylumEvent &evt) {
- switch (evt.kbd.keycode) {
- default:
- _vm->switchEventHandler(getScene());
- break;
-
- case Common::KEYCODE_TAB:
- getScreen()->takeScreenshot();
- break;
- }
-
- return false;
-}
-
-bool PuzzleTimeMachine::mouse(const AsylumEvent &evt) {
- switch (evt.type) {
- case Common::EVENT_RBUTTONDOWN:
- getCursor()->hide();
- getSharedData()->setFlag(kFlag1, true);
- getScreen()->setupPaletteAndStartFade(0, 0, 0);
- _vm->switchEventHandler(getScene());
- break;
-
- case Common::EVENT_LBUTTONDOWN:
- mouseDown();
- break;
-
- case Common::EVENT_LBUTTONUP:
- _leftButtonClicked = true;
- break;
- }
-
- return true;
-}
-
-void PuzzleTimeMachine::mouseDown() {
+bool PuzzleTimeMachine::mouseLeftDown(const AsylumEvent &evt) {
if (_vm->isGameFlagSet(kGameFlag925))
- return;
+ return true;
- Common::Point mousePos = getCursor()->position();
_leftButtonClicked = false;
int32 index = -1;
for (uint32 i = 0; i < ARRAYSIZE(puzzleTimeMachineRects); i++) {
- if (puzzleTimeMachineRects[i].contains(mousePos)) {
+ if (puzzleTimeMachineRects[i].contains(evt.mouse)) {
index = i;
break;
@@ -260,7 +224,7 @@ void PuzzleTimeMachine::mouseDown() {
}
if (index == -1)
- return;
+ return true;
getSound()->playSound(getWorld()->soundResourceIds[15]);
@@ -274,16 +238,31 @@ void PuzzleTimeMachine::mouseDown() {
_frameIncrements[index] = -1;
_state[index] = -1;
}
+
+ return true;
+}
+
+bool PuzzleTimeMachine::mouseLeftUp(const AsylumEvent &evt) {
+ _leftButtonClicked = true;
+
+ return true;
+}
+
+bool PuzzleTimeMachine::mouseRightDown(const AsylumEvent &evt) {
+ getCursor()->hide();
+ getSharedData()->setFlag(kFlag1, true);
+ getScreen()->setupPaletteAndStartFade(0, 0, 0);
+ _vm->switchEventHandler(getScene());
+
+ return true;
}
//////////////////////////////////////////////////////////////////////////
// Helpers
//////////////////////////////////////////////////////////////////////////
-void PuzzleTimeMachine::updateCursor() {
- Common::Point mousePos = getCursor()->position();
-
+void PuzzleTimeMachine::updateCursor(const AsylumEvent &evt) {
for (uint32 i = 0; i < ARRAYSIZE(puzzleTimeMachineRects); i++) {
- if (puzzleTimeMachineRects[i].contains(mousePos)) {
+ if (puzzleTimeMachineRects[i].contains(evt.mouse)) {
if (getCursor()->animation != kCursorAnimationMirror)
getCursor()->set(getWorld()->graphicResourceIds[62], -1, kCursorAnimationMirror, 7);
diff --git a/engines/asylum/puzzles/timemachine.h b/engines/asylum/puzzles/timemachine.h
index aec1a66545..01b673b811 100644
--- a/engines/asylum/puzzles/timemachine.h
+++ b/engines/asylum/puzzles/timemachine.h
@@ -59,17 +59,16 @@ private:
//////////////////////////////////////////////////////////////////////////
// Event Handling
//////////////////////////////////////////////////////////////////////////
- bool init();
- bool update();
- bool key(const AsylumEvent &evt);
- bool mouse(const AsylumEvent &evt);
-
- void mouseDown();
+ bool init(const AsylumEvent &evt);
+ bool update(const AsylumEvent &evt);
+ bool mouseLeftDown(const AsylumEvent &evt);
+ bool mouseLeftUp(const AsylumEvent &evt);
+ bool mouseRightDown(const AsylumEvent &evt);
//////////////////////////////////////////////////////////////////////////
// Helpers
//////////////////////////////////////////////////////////////////////////
- void updateCursor();
+ void updateCursor(const AsylumEvent &evt);
};
diff --git a/engines/asylum/puzzles/vcr.cpp b/engines/asylum/puzzles/vcr.cpp
index 88f57d0d7c..fbb4897954 100644
--- a/engines/asylum/puzzles/vcr.cpp
+++ b/engines/asylum/puzzles/vcr.cpp
@@ -57,7 +57,7 @@ PuzzleVCR::~PuzzleVCR() {
//////////////////////////////////////////////////////////////////////////
// Event Handling
//////////////////////////////////////////////////////////////////////////
-bool PuzzleVCR::init() {
+bool PuzzleVCR::init(const AsylumEvent &evt) {
// Load the graphics palette
getScreen()->setPalette(getWorld()->graphicResourceIds[29]);
getScreen()->setGammaLevel(getWorld()->graphicResourceIds[29], 0);
@@ -72,11 +72,11 @@ bool PuzzleVCR::init() {
return true;
}
-bool PuzzleVCR::update() {
+bool PuzzleVCR::update(const AsylumEvent &evt) {
uint32 ticks = _vm->getTick();
if (!getSharedData()->getFlag(kFlagRedraw)) {
- updateScreen();
+ updateScreen(evt);
getSharedData()->setFlag(kFlagRedraw, true);
}
@@ -113,37 +113,9 @@ bool PuzzleVCR::key(const AsylumEvent &evt) {
return true;
}
-bool PuzzleVCR::mouse(const AsylumEvent &evt) {
- switch (evt.type) {
- case Common::EVENT_LBUTTONDOWN:
- case Common::EVENT_RBUTTONDOWN:
- mouseDown(evt);
- break;
-
- case Common::EVENT_LBUTTONUP:
- mouseUp();
- break;
- }
-
- return true;
-}
-
-void PuzzleVCR::mouseDown(const AsylumEvent &evt) {
+bool PuzzleVCR::mouseLeftDown(const AsylumEvent &evt) {
if (_isAccomplished)
- return;
-
- // Handle right click
- if (evt.type == Common::EVENT_RBUTTONDOWN) {
- getScreen()->clearGraphicsInQueue();
- getScreen()->clear();
-
- getSound()->stop(getWorld()->graphicResourceIds[47]);
-
- _vm->switchEventHandler(getScene());
- return;
- }
-
- Common::Point mousePos = getCursor()->position();
+ return true;
//////////////////////////////////////////////////////////////////////////
// Plug-in jacks
@@ -156,11 +128,11 @@ void PuzzleVCR::mouseDown(const AsylumEvent &evt) {
state = (JackState)(((_jacksState[kYellow] != kOnHand) - 1) & 3);
}
- if (inPolygon(mousePos.x, mousePos.y, kRedHole)) {
+ if (inPolygon(evt.mouse, kRedHole)) {
setJackOnHole(kBlack, state, kPluggedOnRed);
- } else if (inPolygon(mousePos.x, mousePos.y, kYellowHole)) {
+ } else if (inPolygon(evt.mouse, kYellowHole)) {
setJackOnHole(kRed, state, kPluggedOnYellow);
- } else if (inPolygon(mousePos.x, mousePos.y, kBlackHole)) {
+ } else if (inPolygon(evt.mouse, kBlackHole)) {
setJackOnHole(kYellow, state, kPluggedOnBlack);
if (_holesState[kYellow] != kPluggedOnYellow && _buttonsState[kPowerButton] == kON) {
@@ -176,8 +148,8 @@ void PuzzleVCR::mouseDown(const AsylumEvent &evt) {
//////////////////////////////////////////////////////////////////////////
Color jack = getJackOnHand();
if (jack != kNone) {
- if (mousePos.x >= (int32)puzzleVCRPolygons[kBlackJack].left && mousePos.x <= (int32)puzzleVCRPolygons[kYellowJack].right
- && mousePos.y >= (int32)puzzleVCRPolygons[kBlackJack].top && mousePos.y <= (int32)puzzleVCRPolygons[kYellowJack].bottom) {
+ if (evt.mouse.x >= (int32)puzzleVCRPolygons[kBlackJack].left && evt.mouse.x <= (int32)puzzleVCRPolygons[kYellowJack].right
+ && evt.mouse.y >= (int32)puzzleVCRPolygons[kBlackJack].top && evt.mouse.y <= (int32)puzzleVCRPolygons[kYellowJack].bottom) {
_jacksState[jack] = kOnTable;
getSound()->playSound(getWorld()->graphicResourceIds[50]);
@@ -185,7 +157,7 @@ void PuzzleVCR::mouseDown(const AsylumEvent &evt) {
getSharedData()->setFlag(kFlag1, false);
}
- return;
+ return true;
}
//////////////////////////////////////////////////////////////////////////
@@ -195,17 +167,17 @@ void PuzzleVCR::mouseDown(const AsylumEvent &evt) {
getSharedData()->setFlag(kFlag1, false);
- if (inPolygon(mousePos.x, mousePos.y, kBlackJack))
+ if (inPolygon(evt.mouse, kBlackJack))
pickJack(kBlack);
- else if (inPolygon(mousePos.x, mousePos.y, kRedJack))
+ else if (inPolygon(evt.mouse, kRedJack))
pickJack(kRed);
- else if (inPolygon(mousePos.x, mousePos.y, kYellowJack))
+ else if (inPolygon(evt.mouse, kYellowJack))
pickJack(kYellow);
//////////////////////////////////////////////////////////////////////////
// VCR button regions
//////////////////////////////////////////////////////////////////////////
- if (inPolygon(mousePos.x, mousePos.y, kRewindButton)) {
+ if (inPolygon(evt.mouse, kRewindButton)) {
getSound()->playSound(getWorld()->graphicResourceIds[39]);
if (!_buttonsState[kRewindButton])
@@ -213,7 +185,7 @@ void PuzzleVCR::mouseDown(const AsylumEvent &evt) {
else if (_buttonsState[kRewindButton] == kON)
_buttonsState[kRewindButton] = kDownOFF;
- } else if (inPolygon(mousePos.x, mousePos.y, kPlayButton)) {
+ } else if (inPolygon(evt.mouse, kPlayButton)) {
getSound()->playSound(getWorld()->graphicResourceIds[39]);
if (!_buttonsState[kPlayButton])
@@ -221,7 +193,7 @@ void PuzzleVCR::mouseDown(const AsylumEvent &evt) {
else if (_buttonsState[kPlayButton] == kON)
_buttonsState[kPlayButton] = kDownOFF;
- } else if (inPolygon(mousePos.x, mousePos.y, kStopButton)) {
+ } else if (inPolygon(evt.mouse, kStopButton)) {
getSound()->playSound(getWorld()->graphicResourceIds[39]);
if (!_buttonsState[kStopButton])
@@ -229,7 +201,7 @@ void PuzzleVCR::mouseDown(const AsylumEvent &evt) {
else if (_buttonsState[kStopButton] == kON)
_buttonsState[kStopButton] = kDownOFF;
- } else if (inPolygon(mousePos.x, mousePos.y, kPowerButton)) {
+ } else if (inPolygon(evt.mouse, kPowerButton)) {
getSound()->playSound(getWorld()->graphicResourceIds[39]);
if (!_buttonsState[kPowerButton] && _holesState[kYellow] == kPluggedOnRed) {
@@ -238,11 +210,13 @@ void PuzzleVCR::mouseDown(const AsylumEvent &evt) {
_buttonsState[kPowerButton] = kDownOFF;
}
}
+
+ return true;
}
-void PuzzleVCR::mouseUp() {
+bool PuzzleVCR::mouseLeftUp(const AsylumEvent &) {
if (_isAccomplished)
- return;
+ return true;
//////////////////////////////////////////////////////////////////////////
// Power
@@ -299,18 +273,31 @@ void PuzzleVCR::mouseUp() {
} else if (_buttonsState[kStopButton] == kDownON) {
_buttonsState[kStopButton] = kOFF;
}
+
+ return true;
+}
+
+bool PuzzleVCR::mouseRightDown(const AsylumEvent &evt) {
+ getScreen()->clearGraphicsInQueue();
+ getScreen()->clear();
+
+ getSound()->stop(getWorld()->graphicResourceIds[47]);
+
+ _vm->switchEventHandler(getScene());
+
+ return true;
}
//////////////////////////////////////////////////////////////////////////
// Drawing
//////////////////////////////////////////////////////////////////////////
-void PuzzleVCR::updateScreen() {
- Common::Point mousePos = getCursor()->position();
+void PuzzleVCR::updateScreen(const AsylumEvent &evt) {
+ Common::Point mousePos = evt.mouse;
- if (mousePos.x > 465)
+ if (mousePos.x)
mousePos.x = 465;
- updateCursor();
+ updateCursor(mousePos);
// Draw background
getScreen()->clearGraphicsInQueue();
@@ -368,24 +355,22 @@ void PuzzleVCR::updateScreen() {
}
}
-void PuzzleVCR::updateCursor() {
- Common::Point mousePos = getCursor()->position();
-
+void PuzzleVCR::updateCursor(Common::Point mousePos) {
Color jack = getJackOnHand();
if (jack == kNone) {
- if (inPolygon(mousePos.x, mousePos.y, kRewindButton)
- || inPolygon(mousePos.x, mousePos.y, kStopButton)
- || inPolygon(mousePos.x, mousePos.y, kPlayButton)
- || inPolygon(mousePos.x, mousePos.y, kPowerButton)
- || inPolygon(mousePos.x, mousePos.y, kBlackJack)
- || inPolygon(mousePos.x, mousePos.y, kRedJack)
- || inPolygon(mousePos.x, mousePos.y, kYellowJack)) {
+ if (inPolygon(mousePos, kRewindButton)
+ || inPolygon(mousePos, kStopButton)
+ || inPolygon(mousePos, kPlayButton)
+ || inPolygon(mousePos, kPowerButton)
+ || inPolygon(mousePos, kBlackJack)
+ || inPolygon(mousePos, kRedJack)
+ || inPolygon(mousePos, kYellowJack)) {
if (getCursor()->animation != kCursorAnimationMirror)
getCursor()->set(getWorld()->graphicResourceIds[28]);
- } else if ((inPolygon(mousePos.x, mousePos.y, kRedHole) && _holesState[kBlack])
- || (inPolygon(mousePos.x, mousePos.y, kYellowHole) && _holesState[kRed])
- || (inPolygon(mousePos.x, mousePos.y, kBlackHole) && _holesState[kYellow])) {
+ } else if ((inPolygon(mousePos, kRedHole) && _holesState[kBlack])
+ || (inPolygon(mousePos, kYellowHole) && _holesState[kRed])
+ || (inPolygon(mousePos, kBlackHole) && _holesState[kYellow])) {
if (getCursor()->animation != kCursorAnimationMirror)
getCursor()->set(getWorld()->graphicResourceIds[28]);
} else {
@@ -578,9 +563,9 @@ void PuzzleVCR::updateStopButton() {
//////////////////////////////////////////////////////////////////////////
// Helpers
//////////////////////////////////////////////////////////////////////////
-int PuzzleVCR::inPolygon(int x, int y, int polygonIndex) const {
- return x >= puzzleVCRPolygons[polygonIndex].left && x <= puzzleVCRPolygons[polygonIndex].right
- && y >= puzzleVCRPolygons[polygonIndex].top && y <= puzzleVCRPolygons[polygonIndex].bottom;
+int PuzzleVCR::inPolygon(Common::Point point, int polygonIndex) const {
+ return point.x >= puzzleVCRPolygons[polygonIndex].left && point.x <= puzzleVCRPolygons[polygonIndex].right
+ && point.y >= puzzleVCRPolygons[polygonIndex].top && point.y <= puzzleVCRPolygons[polygonIndex].bottom;
}
PuzzleVCR::Color PuzzleVCR::getJackOnHand() {
diff --git a/engines/asylum/puzzles/vcr.h b/engines/asylum/puzzles/vcr.h
index 0c6b703822..84a4911132 100644
--- a/engines/asylum/puzzles/vcr.h
+++ b/engines/asylum/puzzles/vcr.h
@@ -105,19 +105,18 @@ private:
//////////////////////////////////////////////////////////////////////////
// Event Handling
//////////////////////////////////////////////////////////////////////////
- bool init();
- bool update();
+ bool init(const AsylumEvent &evt);
+ bool update(const AsylumEvent &evt);
bool key(const AsylumEvent &evt);
- bool mouse(const AsylumEvent &evt);
-
- void mouseDown(const AsylumEvent &evt);
- void mouseUp();
+ bool mouseLeftDown(const AsylumEvent &evt);
+ bool mouseLeftUp(const AsylumEvent &evt);
+ bool mouseRightDown(const AsylumEvent &evt);
//////////////////////////////////////////////////////////////////////////
// Drawing
//////////////////////////////////////////////////////////////////////////
- void updateScreen();
- void updateCursor();
+ void updateScreen(const AsylumEvent &evt);
+ void updateCursor(Common::Point mousePos);
//////////////////////////////////////////////////////////////////////////
// Updates
@@ -138,7 +137,7 @@ private:
//////////////////////////////////////////////////////////////////////////
// Helpers
//////////////////////////////////////////////////////////////////////////
- int inPolygon(int x, int y, int polyIdx) const;
+ int inPolygon(Common::Point point, int polyIdx) const;
Color getJackOnHand();
void setJackOnHole(Color hole, JackState state, JackState newState);
void pickJack(Color jack);
diff --git a/engines/asylum/puzzles/wheel.cpp b/engines/asylum/puzzles/wheel.cpp
index f74c1bec1d..19ff5cadda 100644
--- a/engines/asylum/puzzles/wheel.cpp
+++ b/engines/asylum/puzzles/wheel.cpp
@@ -36,16 +36,16 @@ PuzzleWheel::~PuzzleWheel() {
//////////////////////////////////////////////////////////////////////////
// Event Handling
//////////////////////////////////////////////////////////////////////////
-bool PuzzleWheel::init() {
+bool PuzzleWheel::init(const AsylumEvent &evt) {
error("[PuzzleWheel::init] Not implemented!");
}
-bool PuzzleWheel::update() {
+bool PuzzleWheel::update(const AsylumEvent &evt) {
error("[PuzzleWheel::update] Not implemented!");
}
-bool PuzzleWheel::mouse(const AsylumEvent &evt) {
- error("[PuzzleWheel::mouse] Not implemented!");
+bool PuzzleWheel::mouseLeftDown(const AsylumEvent &evt) {
+ error("[PuzzleWheel::mouseLeftDown] Not implemented!");
}
} // End of namespace Asylum
diff --git a/engines/asylum/puzzles/wheel.h b/engines/asylum/puzzles/wheel.h
index d749b9d70a..8b07b91351 100644
--- a/engines/asylum/puzzles/wheel.h
+++ b/engines/asylum/puzzles/wheel.h
@@ -41,9 +41,9 @@ private:
//////////////////////////////////////////////////////////////////////////
// Event Handling
//////////////////////////////////////////////////////////////////////////
- bool init();
- bool update();
- bool mouse(const AsylumEvent &evt);
+ bool init(const AsylumEvent &evt);
+ bool update(const AsylumEvent &evt);
+ bool mouseLeftDown(const AsylumEvent &evt);
};
} // End of namespace Asylum
diff --git a/engines/asylum/puzzles/writings.cpp b/engines/asylum/puzzles/writings.cpp
index 14027ab9bc..beb83c33fc 100644
--- a/engines/asylum/puzzles/writings.cpp
+++ b/engines/asylum/puzzles/writings.cpp
@@ -36,15 +36,15 @@ PuzzleWritings::~PuzzleWritings() {
//////////////////////////////////////////////////////////////////////////
// Event Handling
//////////////////////////////////////////////////////////////////////////
-bool PuzzleWritings::init() {
+bool PuzzleWritings::init(const AsylumEvent &evt) {
error("[PuzzleWritings::init] Not implemented!");
}
-bool PuzzleWritings::update() {
+bool PuzzleWritings::update(const AsylumEvent &evt) {
error("[PuzzleWritings::update] Not implemented!");
}
-bool PuzzleWritings::mouse(const AsylumEvent &evt) {
+bool PuzzleWritings::mouseLeftDown(const AsylumEvent &evt) {
error("[PuzzleWritings::mouse] Not implemented!");
}
diff --git a/engines/asylum/puzzles/writings.h b/engines/asylum/puzzles/writings.h
index 6058c03734..a783f740f3 100644
--- a/engines/asylum/puzzles/writings.h
+++ b/engines/asylum/puzzles/writings.h
@@ -41,9 +41,9 @@ private:
//////////////////////////////////////////////////////////////////////////
// Event Handling
//////////////////////////////////////////////////////////////////////////
- bool init();
- bool update();
- bool mouse(const AsylumEvent &evt);
+ bool init(const AsylumEvent &evt);
+ bool update(const AsylumEvent &evt);
+ bool mouseLeftDown(const AsylumEvent &evt);
};
} // End of namespace Asylum
Commit: 8b02d1b6c6facafc037932a1f8760cbe6f905b8d
https://github.com/scummvm/scummvm/commit/8b02d1b6c6facafc037932a1f8760cbe6f905b8d
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:47+02:00
Commit Message:
ASYLUM: Revert back to previous Puzzle::key() implementation
- Add new keyExit() method for other puzzles
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@739 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/puzzles/fisherman.h
engines/asylum/puzzles/lock.h
engines/asylum/puzzles/morguedoor.h
engines/asylum/puzzles/puzzle.cpp
engines/asylum/puzzles/puzzle.h
engines/asylum/puzzles/puzzle11.h
engines/asylum/puzzles/tictactoe.h
engines/asylum/puzzles/timemachine.h
engines/asylum/puzzles/writings.h
diff --git a/engines/asylum/puzzles/fisherman.h b/engines/asylum/puzzles/fisherman.h
index 5d56e8369c..72ee7e24fb 100644
--- a/engines/asylum/puzzles/fisherman.h
+++ b/engines/asylum/puzzles/fisherman.h
@@ -52,6 +52,7 @@ private:
//////////////////////////////////////////////////////////////////////////
bool init(const AsylumEvent &evt);
bool update(const AsylumEvent &evt);
+ bool key(const AsylumEvent &evt) { return keyExit(evt); }
bool mouseLeftDown(const AsylumEvent &evt);
bool mouseRightDown(const AsylumEvent &evt);
diff --git a/engines/asylum/puzzles/lock.h b/engines/asylum/puzzles/lock.h
index dd12e3f24c..5f62253b93 100644
--- a/engines/asylum/puzzles/lock.h
+++ b/engines/asylum/puzzles/lock.h
@@ -43,6 +43,7 @@ private:
//////////////////////////////////////////////////////////////////////////
bool init(const AsylumEvent &evt);
bool update(const AsylumEvent &evt);
+ bool key(const AsylumEvent &evt) { return keyExit(evt); }
bool mouseLeftDown(const AsylumEvent &evt);
};
diff --git a/engines/asylum/puzzles/morguedoor.h b/engines/asylum/puzzles/morguedoor.h
index 2ff55911d3..5ac45d6922 100644
--- a/engines/asylum/puzzles/morguedoor.h
+++ b/engines/asylum/puzzles/morguedoor.h
@@ -78,6 +78,7 @@ private:
//////////////////////////////////////////////////////////////////////////
bool init(const AsylumEvent &evt);
bool update(const AsylumEvent &evt);
+ bool key(const AsylumEvent &evt) { return keyExit(evt); }
bool mouseLeftDown(const AsylumEvent &evt);
bool mouseRightUp(const AsylumEvent &evt);
diff --git a/engines/asylum/puzzles/puzzle.cpp b/engines/asylum/puzzles/puzzle.cpp
index bbdc24ac78..95bd355544 100644
--- a/engines/asylum/puzzles/puzzle.cpp
+++ b/engines/asylum/puzzles/puzzle.cpp
@@ -83,6 +83,19 @@ bool Puzzle::handleEvent(const AsylumEvent &evt) {
}
bool Puzzle::key(const AsylumEvent &evt) {
+ switch (evt.kbd.keycode) {
+ default:
+ break;
+
+ case Common::KEYCODE_TAB:
+ getScreen()->takeScreenshot();
+ break;
+ }
+
+ return true;
+}
+
+bool Puzzle::keyExit(const AsylumEvent &evt) {
switch (evt.kbd.keycode) {
default:
_vm->switchEventHandler(getScene());
@@ -96,6 +109,7 @@ bool Puzzle::key(const AsylumEvent &evt) {
return true;
}
+
void Puzzle::exit() {
getScreen()->clear();
diff --git a/engines/asylum/puzzles/puzzle.h b/engines/asylum/puzzles/puzzle.h
index 4c33fc7158..57a75c3424 100644
--- a/engines/asylum/puzzles/puzzle.h
+++ b/engines/asylum/puzzles/puzzle.h
@@ -65,6 +65,7 @@ protected:
virtual bool mouseRightUp(const AsylumEvent &evt) { return true; }
virtual bool mouseRightDown(const AsylumEvent &evt) { return true; }
+ bool keyExit(const AsylumEvent &evt);
void exit();
//////////////////////////////////////////////////////////////////////////
diff --git a/engines/asylum/puzzles/puzzle11.h b/engines/asylum/puzzles/puzzle11.h
index 3501258630..972357dd6b 100644
--- a/engines/asylum/puzzles/puzzle11.h
+++ b/engines/asylum/puzzles/puzzle11.h
@@ -49,6 +49,7 @@ private:
//////////////////////////////////////////////////////////////////////////
bool init(const AsylumEvent &evt);
bool update(const AsylumEvent &evt);
+ bool key(const AsylumEvent &evt) { return keyExit(evt); }
bool mouseLeftDown(const AsylumEvent &evt);
bool mouseLeftUp(const AsylumEvent &evt);
bool mouseRightDown(const AsylumEvent &evt);
diff --git a/engines/asylum/puzzles/tictactoe.h b/engines/asylum/puzzles/tictactoe.h
index e2a8053573..65e1278ff4 100644
--- a/engines/asylum/puzzles/tictactoe.h
+++ b/engines/asylum/puzzles/tictactoe.h
@@ -63,6 +63,7 @@ private:
//////////////////////////////////////////////////////////////////////////
bool init(const AsylumEvent &evt);
bool update(const AsylumEvent &evt);
+ bool key(const AsylumEvent &evt) { return keyExit(evt); }
bool mouseLeftDown(const AsylumEvent &evt);
bool mouseRightDown(const AsylumEvent &evt);
diff --git a/engines/asylum/puzzles/timemachine.h b/engines/asylum/puzzles/timemachine.h
index 01b673b811..b7ac4c0214 100644
--- a/engines/asylum/puzzles/timemachine.h
+++ b/engines/asylum/puzzles/timemachine.h
@@ -61,6 +61,7 @@ private:
//////////////////////////////////////////////////////////////////////////
bool init(const AsylumEvent &evt);
bool update(const AsylumEvent &evt);
+ bool key(const AsylumEvent &evt) { return keyExit(evt); }
bool mouseLeftDown(const AsylumEvent &evt);
bool mouseLeftUp(const AsylumEvent &evt);
bool mouseRightDown(const AsylumEvent &evt);
diff --git a/engines/asylum/puzzles/writings.h b/engines/asylum/puzzles/writings.h
index a783f740f3..40bd431b88 100644
--- a/engines/asylum/puzzles/writings.h
+++ b/engines/asylum/puzzles/writings.h
@@ -43,6 +43,7 @@ private:
//////////////////////////////////////////////////////////////////////////
bool init(const AsylumEvent &evt);
bool update(const AsylumEvent &evt);
+ bool key(const AsylumEvent &evt) { return keyExit(evt); }
bool mouseLeftDown(const AsylumEvent &evt);
};
Commit: 25df731c64ca0f94b4a89551bb4480c1538eb466
https://github.com/scummvm/scummvm/commit/25df731c64ca0f94b4a89551bb4480c1538eb466
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:47+02:00
Commit Message:
ASYLUM: Implement Wheel puzzle initialization
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@740 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/puzzles/wheel.cpp
engines/asylum/puzzles/wheel.h
engines/asylum/resources/special.cpp
engines/asylum/resources/special.h
engines/asylum/shared.h
diff --git a/engines/asylum/puzzles/wheel.cpp b/engines/asylum/puzzles/wheel.cpp
index 19ff5cadda..10acfc7d56 100644
--- a/engines/asylum/puzzles/wheel.cpp
+++ b/engines/asylum/puzzles/wheel.cpp
@@ -25,19 +25,76 @@
#include "asylum/puzzles/wheel.h"
+#include "asylum/resources/special.h"
+#include "asylum/resources/worldstats.h"
+
+#include "asylum/system/cursor.h"
+#include "asylum/system/graphics.h"
+#include "asylum/system/screen.h"
+
+#include "asylum/views/scene.h"
+
+#include "asylum/asylum.h"
+
namespace Asylum {
PuzzleWheel::PuzzleWheel(AsylumEngine *engine) : Puzzle(engine) {
+ _currentRect = -1;
+ _resourceIndex = 0;
+ _resourceIndex10 = 13;
+
+ _frameIndex30 = 0;
+ memset(&_frameIndexes, -1, sizeof(_frameIndexes));
+ memset(&_frameCounts, 0, sizeof(_frameCounts));
+
+ _flag1 = false;
+ _flag2 = false;
+ _flag3 = false;
}
PuzzleWheel::~PuzzleWheel() {
}
+void PuzzleWheel::reset() {
+ getSpecial()->reset(true);
+
+ _resourceIndex = 0;
+ _resourceIndex10 = 13;
+
+ _frameIndex30 = 0;
+
+ _frameCounts[0] = 0;
+ _frameCounts[9] = 0;
+ _frameCounts[10] = 0;
+ _frameCounts[11] = 0;
+
+ _flag1 = false;
+}
+
//////////////////////////////////////////////////////////////////////////
// Event Handling
//////////////////////////////////////////////////////////////////////////
bool PuzzleWheel::init(const AsylumEvent &evt) {
- error("[PuzzleWheel::init] Not implemented!");
+ getSpecial()->reset(false);
+
+ getScreen()->setPalette(getWorld()->graphicResourceIds[1]);
+ getScreen()->setGammaLevel(getWorld()->graphicResourceIds[1], 0);
+
+ updateCursor(evt);
+ getCursor()->show();
+
+ _currentRect = -2;
+
+ memset(&_frameIndexes, -1, sizeof(_frameIndexes));
+
+ for (uint32 i = 0; i < 8; i++) {
+ if (_vm->isGameFlagSet((GameFlag)(kGameFlag253 + i)))
+ _frameCounts[i + 1] = GraphicResource::getFrameCount(_vm, getWorld()->graphicResourceIds[i + 14]) - 1;
+ else
+ _frameCounts[i + 1] = GraphicResource::getFrameCount(_vm, getWorld()->graphicResourceIds[i + 4]) - 1;
+ }
+
+ return true;
}
bool PuzzleWheel::update(const AsylumEvent &evt) {
@@ -48,4 +105,35 @@ bool PuzzleWheel::mouseLeftDown(const AsylumEvent &evt) {
error("[PuzzleWheel::mouseLeftDown] Not implemented!");
}
+bool PuzzleWheel::mouseRightDown(const AsylumEvent &evt) {
+ getScreen()->clear();
+ _vm->switchEventHandler(getScene());
+
+ return true;
+}
+
+//////////////////////////////////////////////////////////////////////////
+// Helpers
+//////////////////////////////////////////////////////////////////////////
+void PuzzleWheel::updateCursor(const AsylumEvent &evt) {
+ warning("[PuzzleWheel::updateCursor] Not implemented!");
+}
+
+int32 PuzzleWheel::findRect(Common::Point mousePos) {
+ error("[PuzzleWheel::findRect] Not implemented!");
+}
+
+void PuzzleWheel::checkFlags() {
+ error("[PuzzleWheel::checkFlags] Not implemented!");
+}
+
+void PuzzleWheel::playSound() {
+ error("[PuzzleWheel::playSound] Not implemented!");
+}
+
+void PuzzleWheel::playSoundReset() {
+ error("[PuzzleWheel::playSoundReset] Not implemented!");
+}
+
+
} // End of namespace Asylum
diff --git a/engines/asylum/puzzles/wheel.h b/engines/asylum/puzzles/wheel.h
index 8b07b91351..1ef84e924c 100644
--- a/engines/asylum/puzzles/wheel.h
+++ b/engines/asylum/puzzles/wheel.h
@@ -37,13 +37,36 @@ public:
PuzzleWheel(AsylumEngine *engine);
~PuzzleWheel();
+ void reset();
+
private:
+ int32 _currentRect;
+ uint32 _resourceIndex;
+ uint32 _resourceIndex10;
+ uint32 _frameIndex30;
+ int32 _frameIndexes[8];
+ int32 _frameCounts[12];
+
+ bool _flag1;
+ bool _flag2;
+ bool _flag3;
+
//////////////////////////////////////////////////////////////////////////
// Event Handling
//////////////////////////////////////////////////////////////////////////
bool init(const AsylumEvent &evt);
bool update(const AsylumEvent &evt);
bool mouseLeftDown(const AsylumEvent &evt);
+ bool mouseRightDown(const AsylumEvent &evt);
+
+ //////////////////////////////////////////////////////////////////////////
+ // Helpers
+ //////////////////////////////////////////////////////////////////////////
+ void updateCursor(const AsylumEvent &evt);
+ int32 findRect(Common::Point mousePos);
+ void checkFlags();
+ void playSound();
+ void playSoundReset();
};
} // End of namespace Asylum
diff --git a/engines/asylum/resources/special.cpp b/engines/asylum/resources/special.cpp
index 4b2b91baee..81cd3def36 100644
--- a/engines/asylum/resources/special.cpp
+++ b/engines/asylum/resources/special.cpp
@@ -104,6 +104,15 @@ void Special::run(Object* object, ActorIndex index) {
}
}
+void Special::reset(bool resetPaletteTick2) {
+ _chapter5Counter = 0;
+ _paletteFlag = false;
+ _paletteTick1 = 0;
+
+ if (resetPaletteTick2)
+ _paletteTick2 = 0;
+}
+
//////////////////////////////////////////////////////////////////////////
// Spec functions
//////////////////////////////////////////////////////////////////////////
diff --git a/engines/asylum/resources/special.h b/engines/asylum/resources/special.h
index eac9e6427d..fb23389f68 100644
--- a/engines/asylum/resources/special.h
+++ b/engines/asylum/resources/special.h
@@ -43,6 +43,8 @@ public:
void run(Object* object, ActorIndex index);
+ void reset(bool resetPaletteTick2);
+
private:
AsylumEngine* _vm;
diff --git a/engines/asylum/shared.h b/engines/asylum/shared.h
index fece84f414..3ff191e2ce 100644
--- a/engines/asylum/shared.h
+++ b/engines/asylum/shared.h
@@ -51,6 +51,7 @@ enum GameFlag {
kGameFlag247 = 247,
kGameFlag248 = 248,
kGameFlag249 = 249,
+ kGameFlag253 = 253,
kGameFlag263 = 263,
kGameFlag262 = 262,
kGameFlag264 = 264,
Commit: 09fd8412f401fcf70c0b2d87ad6c6a2e7ff1350a
https://github.com/scummvm/scummvm/commit/09fd8412f401fcf70c0b2d87ad6c6a2e7ff1350a
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:47+02:00
Commit Message:
ASYLUM: Implement Wheel puzzle helper functions
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@741 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/puzzles/wheel.cpp
engines/asylum/puzzles/wheel.h
engines/asylum/shared.h
diff --git a/engines/asylum/puzzles/wheel.cpp b/engines/asylum/puzzles/wheel.cpp
index 10acfc7d56..24c543b8b9 100644
--- a/engines/asylum/puzzles/wheel.cpp
+++ b/engines/asylum/puzzles/wheel.cpp
@@ -38,15 +38,49 @@
namespace Asylum {
+const GameFlag puzzleWheelFlags[32] = {
+ kGameFlag253, kGameFlag257, kGameFlag259, kGameFlag254, kGameFlag258,
+ kGameFlag260, kGameFlag253, kGameFlag255, kGameFlag259, kGameFlag254,
+ kGameFlag256, kGameFlag260, kGameFlag253, kGameFlag255, kGameFlag257,
+ kGameFlag254, kGameFlag256, kGameFlag258, kGameFlag255, kGameFlag257,
+ kGameFlag259, kGameFlag256, kGameFlag258, kGameFlag260, kGameFlag253,
+ kGameFlag254, kGameFlag255, kGameFlag256, kGameFlag257, kGameFlag258,
+ kGameFlag259, kGameFlag260
+};
+
+const uint32 puzzleFrameCountIndex[24] = {
+ 1, 5, 7, 2, 6,
+ 8, 1, 3, 7, 2,
+ 4, 8, 1, 3, 5,
+ 2, 4, 6, 3, 5,
+ 7, 4, 6, 8
+};
+
+const uint32 puzzleResourceIndexes[16] = {
+ 39, 40, 42, 44, 46,
+ 48, 50, 52, 38, 41,
+ 43, 45, 47, 49, 51,
+ 53
+};
+
+const Common::Rect puzzleWheelRects[4] = {
+ Common::Rect(425, 268, 491, 407),
+ Common::Rect(358, 268, 424, 407),
+ Common::Rect(561, 251, 594, 324),
+ Common::Rect(280, 276, 310, 400)
+};
+
PuzzleWheel::PuzzleWheel(AsylumEngine *engine) : Puzzle(engine) {
_currentRect = -1;
_resourceIndex = 0;
+ _resourceIndex9 = 0;
_resourceIndex10 = 13;
_frameIndex30 = 0;
memset(&_frameIndexes, -1, sizeof(_frameIndexes));
memset(&_frameCounts, 0, sizeof(_frameCounts));
+ _showResource9 = false;
_flag1 = false;
_flag2 = false;
_flag3 = false;
@@ -102,7 +136,36 @@ bool PuzzleWheel::update(const AsylumEvent &evt) {
}
bool PuzzleWheel::mouseLeftDown(const AsylumEvent &evt) {
- error("[PuzzleWheel::mouseLeftDown] Not implemented!");
+ switch (findRect(evt.mouse)) {
+ default:
+ break;
+
+ case 0:
+ _frameCounts[9] = 0;
+ _flag1 = true;
+ _showResource9 = true;
+
+ updateIndex();
+ break;
+
+ case 1:
+ _frameCounts[9] = 0;
+ _flag1 = false;
+ _showResource9 = true;
+
+ updateIndex();
+ break;
+
+ case 2:
+ _flag2 = true;
+ break;
+
+ case 3:
+ _flag3 = true;
+ break;
+ }
+
+ return true;
}
bool PuzzleWheel::mouseRightDown(const AsylumEvent &evt) {
@@ -116,24 +179,64 @@ bool PuzzleWheel::mouseRightDown(const AsylumEvent &evt) {
// Helpers
//////////////////////////////////////////////////////////////////////////
void PuzzleWheel::updateCursor(const AsylumEvent &evt) {
- warning("[PuzzleWheel::updateCursor] Not implemented!");
+ int32 index = findRect(evt.mouse);
+
+ if (_currentRect != index) {
+ _currentRect = index;
+
+ getCursor()->set(getWorld()->graphicResourceIds[2], -1, (index == -1) ? kCursorAnimationNone : kCursorAnimationMirror);
+ }
}
int32 PuzzleWheel::findRect(Common::Point mousePos) {
- error("[PuzzleWheel::findRect] Not implemented!");
+ for (uint32 i = 0; i < ARRAYSIZE(puzzleWheelRects); i++) {
+ if (puzzleWheelRects[i].contains(mousePos))
+ return i;
+ }
+
+ return -1;
+}
+
+void PuzzleWheel::updateIndex() {
+ _resourceIndex9 = puzzleResourceIndexes[_resourceIndex + (_flag1 ? 0 : 8)];
+ _resourceIndex = (_resourceIndex + (_flag1 ? 7 : 1)) % -8;
}
void PuzzleWheel::checkFlags() {
- error("[PuzzleWheel::checkFlags] Not implemented!");
+ for (uint32 i = 0; i < 8; i++)
+ if (!_vm->isGameFlagSet(puzzleWheelFlags[i]))
+ return;
+
+ _vm->setGameFlag(kGameFlag261);
+ getScreen()->clear();
+ _vm->switchEventHandler(getScene());
}
void PuzzleWheel::playSound() {
- error("[PuzzleWheel::playSound] Not implemented!");
+ for (uint32 i = 0; i < 8; i++) {
+ if (!_vm->isGameFlagSet(puzzleWheelFlags[24 + i]))
+ continue;
+
+ getSound()->playSound(getWorld()->graphicResourceIds[69]);
+ _vm->clearGameFlag(puzzleWheelFlags[24 + i]);
+ _frameCounts[i + 1] = 0;
+ }
}
void PuzzleWheel::playSoundReset() {
- error("[PuzzleWheel::playSoundReset] Not implemented!");
-}
+ memset(&_frameIndexes, -1, sizeof(_frameIndexes));
+
+ for (uint32 i = 0; i < 3; i++) {
+ _vm->toggleGameFlag(puzzleWheelFlags[i + 3 * _resourceIndex]);
+ _frameCounts[puzzleFrameCountIndex[i + 3 * _resourceIndex]] = 0;
+
+ // Original game resets some unused data
+ if (_vm->isGameFlagSet(puzzleWheelFlags[i]))
+ getSound()->playSound(getWorld()->graphicResourceIds[68]);
+ else
+ getSound()->playSound(getWorld()->graphicResourceIds[69]);
+ }
+}
} // End of namespace Asylum
diff --git a/engines/asylum/puzzles/wheel.h b/engines/asylum/puzzles/wheel.h
index 1ef84e924c..e387ed0bbb 100644
--- a/engines/asylum/puzzles/wheel.h
+++ b/engines/asylum/puzzles/wheel.h
@@ -42,11 +42,13 @@ public:
private:
int32 _currentRect;
uint32 _resourceIndex;
+ uint32 _resourceIndex9;
uint32 _resourceIndex10;
uint32 _frameIndex30;
int32 _frameIndexes[8];
int32 _frameCounts[12];
+ bool _showResource9;
bool _flag1;
bool _flag2;
bool _flag3;
@@ -64,6 +66,7 @@ private:
//////////////////////////////////////////////////////////////////////////
void updateCursor(const AsylumEvent &evt);
int32 findRect(Common::Point mousePos);
+ void updateIndex();
void checkFlags();
void playSound();
void playSoundReset();
diff --git a/engines/asylum/shared.h b/engines/asylum/shared.h
index 3ff191e2ce..57663d254c 100644
--- a/engines/asylum/shared.h
+++ b/engines/asylum/shared.h
@@ -52,8 +52,16 @@ enum GameFlag {
kGameFlag248 = 248,
kGameFlag249 = 249,
kGameFlag253 = 253,
- kGameFlag263 = 263,
+ kGameFlag254 = 254,
+ kGameFlag255 = 255,
+ kGameFlag256 = 256,
+ kGameFlag257 = 257,
+ kGameFlag258 = 258,
+ kGameFlag259 = 259,
+ kGameFlag260 = 260,
+ kGameFlag261 = 261,
kGameFlag262 = 262,
+ kGameFlag263 = 263,
kGameFlag264 = 264,
kGameFlag265 = 265,
kGameFlag266 = 266,
Commit: a9ca52abef2cf81818e5ba2cc4df490afaea05e1
https://github.com/scummvm/scummvm/commit/a9ca52abef2cf81818e5ba2cc4df490afaea05e1
Author: Filippos Karapetis (md5 at scummvm.org)
Date: 2021-05-17T15:36:47+02:00
Commit Message:
ASYLUM: Fixed compilation after the latest trunk changes
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@742 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/views/video.cpp
diff --git a/engines/asylum/views/video.cpp b/engines/asylum/views/video.cpp
index 6af4ff437d..a2fbc25dc9 100644
--- a/engines/asylum/views/video.cpp
+++ b/engines/asylum/views/video.cpp
@@ -159,7 +159,7 @@ void Video::play(Common::String filename, bool showSubtitles) {
_vm->handleEvents();
if (_smkDecoder->needsUpdate()) {
- Graphics::Surface *frame = _smkDecoder->decodeNextFrame();
+ const Graphics::Surface *frame = _smkDecoder->decodeNextFrame();
if (!frame)
continue;
Commit: beb8ef9da9de5e10df4f0068a7e21ddac22d916b
https://github.com/scummvm/scummvm/commit/beb8ef9da9de5e10df4f0068a7e21ddac22d916b
Author: Alex Bevilacqua (alexbevi at gmail.com)
Date: 2021-05-17T15:36:48+02:00
Commit Message:
ASYLUM: fix linux compile
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@743 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/module.mk
diff --git a/engines/asylum/module.mk b/engines/asylum/module.mk
index 0368941a6a..cb70f69b18 100644
--- a/engines/asylum/module.mk
+++ b/engines/asylum/module.mk
@@ -14,6 +14,7 @@ MODULE_OBJS := \
puzzles/puzzle.o \
puzzles/tictactoe.o \
puzzles/timemachine.o \
+ puzzles/puzzle11.o \
puzzles/vcr.o \
puzzles/wheel.o \
puzzles/writings.o \
Commit: 5acbe01dd872e22ec0907ab90aae51bf8a950de6
https://github.com/scummvm/scummvm/commit/5acbe01dd872e22ec0907ab90aae51bf8a950de6
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:48+02:00
Commit Message:
ASYLUM: Rename special Scene chapter 5 function to drawRain
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@744 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/views/scene.cpp
engines/asylum/views/scene.h
diff --git a/engines/asylum/views/scene.cpp b/engines/asylum/views/scene.cpp
index 3f329d4219..e3eb354c86 100644
--- a/engines/asylum/views/scene.cpp
+++ b/engines/asylum/views/scene.cpp
@@ -646,7 +646,7 @@ bool Scene::updateScreen() {
if (getWorld()->chapter == kChapter5) {
if (_vm->isGameFlagSet(kGameFlag249))
- drawChapter5();
+ drawRain();
}
return false;
@@ -2558,7 +2558,7 @@ void Scene::adjustActorPriority(ActorIndex index) {
}
}
-void Scene::drawChapter5() {
+void Scene::drawRain() {
if (getSharedData()->getFlag(kFlagSkipDrawScene))
return;
diff --git a/engines/asylum/views/scene.h b/engines/asylum/views/scene.h
index 9f114c0797..e7478e4ad8 100644
--- a/engines/asylum/views/scene.h
+++ b/engines/asylum/views/scene.h
@@ -171,6 +171,11 @@ public:
*/
void updateAmbientSounds();
+ /**
+ * Rain drawing function for chapter 5.
+ */
+ void drawRain();
+
/**
* Determine if the supplied point intersects an action area's active region.
*
@@ -325,10 +330,6 @@ private:
*/
void adjustActorPriority(ActorIndex index);
- /**
- * Special drawing function for chapter 5.
- */
- void drawChapter5();
uint32 _chapter5FrameIndex;
//////////////////////////////////////////////////////////////////////////
Commit: 55a1bca99c4602f7c902dbae768eba3bb6dc73fb
https://github.com/scummvm/scummvm/commit/55a1bca99c4602f7c902dbae768eba3bb6dc73fb
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:48+02:00
Commit Message:
ASYLUM: Fix regression with use of evt.mouse in puzzles updateCursor functions
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@745 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/puzzles/clock.cpp
engines/asylum/puzzles/clock.h
engines/asylum/puzzles/fisherman.cpp
engines/asylum/puzzles/fisherman.h
engines/asylum/puzzles/morguedoor.cpp
engines/asylum/puzzles/morguedoor.h
engines/asylum/puzzles/timemachine.cpp
engines/asylum/puzzles/timemachine.h
engines/asylum/puzzles/vcr.cpp
engines/asylum/puzzles/vcr.h
diff --git a/engines/asylum/puzzles/clock.cpp b/engines/asylum/puzzles/clock.cpp
index 6c81f8ebd7..819fe3319a 100644
--- a/engines/asylum/puzzles/clock.cpp
+++ b/engines/asylum/puzzles/clock.cpp
@@ -87,7 +87,7 @@ void PuzzleClock::reset() {
bool PuzzleClock::init(const AsylumEvent &evt) {
_currentRect = -2;
- updateCursor(evt.mouse);
+ updateCursor();
getScreen()->setPalette(getWorld()->graphicResourceIds[6]);
getScreen()->setGammaLevel(getWorld()->graphicResourceIds[6], 0);
@@ -141,7 +141,7 @@ bool PuzzleClock::update(const AsylumEvent &evt) {
}
bool PuzzleClock::mouseLeftDown(const AsylumEvent &evt) {
- int32 index = findRect(evt.mouse);
+ int32 index = findRect();
if (index == -1)
return false;
@@ -166,8 +166,8 @@ bool PuzzleClock::mouseRightDown(const AsylumEvent &evt) {
//////////////////////////////////////////////////////////////////////////
// Helpers
//////////////////////////////////////////////////////////////////////////
-void PuzzleClock::updateCursor(Common::Point mousePos) {
- int32 index = findRect(mousePos);
+void PuzzleClock::updateCursor() {
+ int32 index = findRect();
if (index != _currentRect) {
_currentRect = index;
@@ -179,9 +179,9 @@ void PuzzleClock::updateCursor(Common::Point mousePos) {
}
}
-int32 PuzzleClock::findRect(Common::Point mousePos) {
+int32 PuzzleClock::findRect() {
for (uint32 i = 0; i < ARRAYSIZE(puzzleClockRects); i++) {
- if (puzzleClockRects[i].contains(mousePos))
+ if (puzzleClockRects[i].contains(getCursor()->position()))
return i;
}
diff --git a/engines/asylum/puzzles/clock.h b/engines/asylum/puzzles/clock.h
index ae59ba0fe4..98968ae15e 100644
--- a/engines/asylum/puzzles/clock.h
+++ b/engines/asylum/puzzles/clock.h
@@ -57,8 +57,8 @@ private:
//////////////////////////////////////////////////////////////////////////
// Helpers
//////////////////////////////////////////////////////////////////////////
- void updateCursor(Common::Point mousePos);
- int32 findRect(Common::Point mousePos);
+ void updateCursor();
+ int32 findRect();
void setFlag();
};
diff --git a/engines/asylum/puzzles/fisherman.cpp b/engines/asylum/puzzles/fisherman.cpp
index 85dfdc62aa..9be97ded05 100644
--- a/engines/asylum/puzzles/fisherman.cpp
+++ b/engines/asylum/puzzles/fisherman.cpp
@@ -102,7 +102,7 @@ bool PuzzleFisherman::init(const AsylumEvent &evt) {
}
bool PuzzleFisherman::update(const AsylumEvent &evt) {
- updateCursor(evt);
+ updateCursor();
// Draw background
getScreen()->clearGraphicsInQueue();
@@ -195,14 +195,15 @@ bool PuzzleFisherman::mouseRightDown(const AsylumEvent &evt) {
//////////////////////////////////////////////////////////////////////////
// Helpers
//////////////////////////////////////////////////////////////////////////
-void PuzzleFisherman::updateCursor(const AsylumEvent &evt) {
+void PuzzleFisherman::updateCursor() {
bool found = false;
+ Common::Point mousePos = getCursor()->position();
for (uint32 i = 0; i < 6; i++) {
if (found)
break;
- if (hitTest(&puzzleFishermanPolygons[i * 4 + 7], evt.mouse)) {
+ if (hitTest(&puzzleFishermanPolygons[i * 4 + 7], mousePos)) {
if (!_state[i]) {
found = true;
@@ -215,10 +216,10 @@ void PuzzleFisherman::updateCursor(const AsylumEvent &evt) {
if (found)
return;
- if (puzzleFishermanPolygons[6].x >= evt.mouse.x
- || puzzleFishermanPolygons[6].y >= evt.mouse.y
- || puzzleFishermanPolygons[6].x + 70 <= evt.mouse.x
- || puzzleFishermanPolygons[6].y + 30 <= evt.mouse.y) {
+ if (puzzleFishermanPolygons[6].x >= mousePos.x
+ || puzzleFishermanPolygons[6].y >= mousePos.y
+ || puzzleFishermanPolygons[6].x + 70 <= mousePos.x
+ || puzzleFishermanPolygons[6].y + 30 <= mousePos.y) {
if (getCursor()->animation != kCursorAnimationNone)
getCursor()->set(getWorld()->graphicResourceIds[47], -1, kCursorAnimationNone, 7);
else if (getCursor()->animation != kCursorAnimationMirror)
diff --git a/engines/asylum/puzzles/fisherman.h b/engines/asylum/puzzles/fisherman.h
index 72ee7e24fb..77155bbba1 100644
--- a/engines/asylum/puzzles/fisherman.h
+++ b/engines/asylum/puzzles/fisherman.h
@@ -59,7 +59,7 @@ private:
//////////////////////////////////////////////////////////////////////////
// Helpers
//////////////////////////////////////////////////////////////////////////
- void updateCursor(const AsylumEvent &evt);
+ void updateCursor();
void setFlags(uint32 index);
};
diff --git a/engines/asylum/puzzles/morguedoor.cpp b/engines/asylum/puzzles/morguedoor.cpp
index eaf5882f8e..899759cd40 100644
--- a/engines/asylum/puzzles/morguedoor.cpp
+++ b/engines/asylum/puzzles/morguedoor.cpp
@@ -89,7 +89,7 @@ bool PuzzleMorgueDoor::init(const AsylumEvent &evt) {
}
bool PuzzleMorgueDoor::update(const AsylumEvent &evt) {
- updateCursor(evt.mouse);
+ updateCursor();
// Draw elements
getScreen()->clearGraphicsInQueue();
@@ -210,8 +210,9 @@ bool PuzzleMorgueDoor::mouseRightUp(const AsylumEvent &evt) {
//////////////////////////////////////////////////////////////////////////
// Helpers
//////////////////////////////////////////////////////////////////////////
-void PuzzleMorgueDoor::updateCursor(Common::Point mousePos) {
+void PuzzleMorgueDoor::updateCursor() {
bool animate = false;
+ Common::Point mousePos = getCursor()->position();
if (mousePos.x > 347 && mousePos.x < 357 && mousePos.y > 124 && mousePos.y < 154)
animate = true;
diff --git a/engines/asylum/puzzles/morguedoor.h b/engines/asylum/puzzles/morguedoor.h
index 5ac45d6922..2c83c5cfd4 100644
--- a/engines/asylum/puzzles/morguedoor.h
+++ b/engines/asylum/puzzles/morguedoor.h
@@ -85,7 +85,7 @@ private:
//////////////////////////////////////////////////////////////////////////
// Helpers
//////////////////////////////////////////////////////////////////////////
- void updateCursor(Common::Point mousePos);
+ void updateCursor();
void updateState();
};
diff --git a/engines/asylum/puzzles/timemachine.cpp b/engines/asylum/puzzles/timemachine.cpp
index b4875beea8..8d5d824833 100644
--- a/engines/asylum/puzzles/timemachine.cpp
+++ b/engines/asylum/puzzles/timemachine.cpp
@@ -115,7 +115,7 @@ bool PuzzleTimeMachine::init(const AsylumEvent &evt) {
}
bool PuzzleTimeMachine::update(const AsylumEvent &evt) {
- updateCursor(evt);
+ updateCursor();
// Draw screen elements
getScreen()->clearGraphicsInQueue();
@@ -260,9 +260,9 @@ bool PuzzleTimeMachine::mouseRightDown(const AsylumEvent &evt) {
//////////////////////////////////////////////////////////////////////////
// Helpers
//////////////////////////////////////////////////////////////////////////
-void PuzzleTimeMachine::updateCursor(const AsylumEvent &evt) {
+void PuzzleTimeMachine::updateCursor() {
for (uint32 i = 0; i < ARRAYSIZE(puzzleTimeMachineRects); i++) {
- if (puzzleTimeMachineRects[i].contains(evt.mouse)) {
+ if (puzzleTimeMachineRects[i].contains(getCursor()->position())) {
if (getCursor()->animation != kCursorAnimationMirror)
getCursor()->set(getWorld()->graphicResourceIds[62], -1, kCursorAnimationMirror, 7);
diff --git a/engines/asylum/puzzles/timemachine.h b/engines/asylum/puzzles/timemachine.h
index b7ac4c0214..72b78b5032 100644
--- a/engines/asylum/puzzles/timemachine.h
+++ b/engines/asylum/puzzles/timemachine.h
@@ -69,8 +69,7 @@ private:
//////////////////////////////////////////////////////////////////////////
// Helpers
//////////////////////////////////////////////////////////////////////////
- void updateCursor(const AsylumEvent &evt);
-
+ void updateCursor();
};
} // End of namespace Asylum
diff --git a/engines/asylum/puzzles/vcr.cpp b/engines/asylum/puzzles/vcr.cpp
index fbb4897954..fa8f945bde 100644
--- a/engines/asylum/puzzles/vcr.cpp
+++ b/engines/asylum/puzzles/vcr.cpp
@@ -292,12 +292,7 @@ bool PuzzleVCR::mouseRightDown(const AsylumEvent &evt) {
// Drawing
//////////////////////////////////////////////////////////////////////////
void PuzzleVCR::updateScreen(const AsylumEvent &evt) {
- Common::Point mousePos = evt.mouse;
-
- if (mousePos.x)
- mousePos.x = 465;
-
- updateCursor(mousePos);
+ updateCursor();
// Draw background
getScreen()->clearGraphicsInQueue();
@@ -355,8 +350,12 @@ void PuzzleVCR::updateScreen(const AsylumEvent &evt) {
}
}
-void PuzzleVCR::updateCursor(Common::Point mousePos) {
+void PuzzleVCR::updateCursor() {
Color jack = getJackOnHand();
+ Common::Point mousePos = getCursor()->position();
+
+ if (mousePos.x)
+ mousePos.x = 465;
if (jack == kNone) {
if (inPolygon(mousePos, kRewindButton)
diff --git a/engines/asylum/puzzles/vcr.h b/engines/asylum/puzzles/vcr.h
index 84a4911132..b6a29f6df4 100644
--- a/engines/asylum/puzzles/vcr.h
+++ b/engines/asylum/puzzles/vcr.h
@@ -116,7 +116,7 @@ private:
// Drawing
//////////////////////////////////////////////////////////////////////////
void updateScreen(const AsylumEvent &evt);
- void updateCursor(Common::Point mousePos);
+ void updateCursor();
//////////////////////////////////////////////////////////////////////////
// Updates
Commit: 76e623a68167783d5da32f0cced37b00bc643479
https://github.com/scummvm/scummvm/commit/76e623a68167783d5da32f0cced37b00bc643479
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:48+02:00
Commit Message:
ASYLUM: Rename rain frame index
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@746 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/views/scene.cpp
engines/asylum/views/scene.h
diff --git a/engines/asylum/views/scene.cpp b/engines/asylum/views/scene.cpp
index e3eb354c86..abf7c8fc55 100644
--- a/engines/asylum/views/scene.cpp
+++ b/engines/asylum/views/scene.cpp
@@ -67,7 +67,7 @@ Scene::Scene(AsylumEngine *engine): _vm(engine),
_playerIndex = 0;
_hitAreaChapter7Counter = 0;
- _chapter5FrameIndex = 0;
+ _chapter5RainFrameIndex = 0;
_musicVolume = 0;
@@ -2564,11 +2564,11 @@ void Scene::drawRain() {
for (uint y = 0; y < 512; y = y + 64) {
for (uint x = 0; x < 704; x = x + 64) {
- getScreen()->draw(MAKE_RESOURCE(kResourcePackShared, 58), _chapter5FrameIndex, x + (_ws->xLeft % 64) / 8, y + (_ws->yTop % 64) / 8, 0);
+ getScreen()->draw(MAKE_RESOURCE(kResourcePackShared, 58), _chapter5RainFrameIndex, x + (_ws->xLeft % 64) / 8, y + (_ws->yTop % 64) / 8, 0);
}
}
- _chapter5FrameIndex = (_chapter5FrameIndex + 1) % GraphicResource::getFrameCount(_vm, MAKE_RESOURCE(kResourcePackShared, 58));
+ _chapter5RainFrameIndex = (_chapter5RainFrameIndex + 1) % GraphicResource::getFrameCount(_vm, MAKE_RESOURCE(kResourcePackShared, 58));
}
//////////////////////////////////////////////////////////////////////////
diff --git a/engines/asylum/views/scene.h b/engines/asylum/views/scene.h
index e7478e4ad8..3e1dd1bde8 100644
--- a/engines/asylum/views/scene.h
+++ b/engines/asylum/views/scene.h
@@ -330,7 +330,7 @@ private:
*/
void adjustActorPriority(ActorIndex index);
- uint32 _chapter5FrameIndex;
+ int32 _chapter5RainFrameIndex;
//////////////////////////////////////////////////////////////////////////
// HitTest
Commit: 8f0b6e04ba7404d70fbc558a9edcc2a5a56df77e
https://github.com/scummvm/scummvm/commit/8f0b6e04ba7404d70fbc558a9edcc2a5a56df77e
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:48+02:00
Commit Message:
ASYLUM: Make sure we don't use negative modulo with unsigned int values in PuzzleTimeMachine
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@747 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/puzzles/timemachine.cpp
engines/asylum/puzzles/timemachine.h
diff --git a/engines/asylum/puzzles/timemachine.cpp b/engines/asylum/puzzles/timemachine.cpp
index 8d5d824833..a934e407d3 100644
--- a/engines/asylum/puzzles/timemachine.cpp
+++ b/engines/asylum/puzzles/timemachine.cpp
@@ -192,7 +192,7 @@ bool PuzzleTimeMachine::update(const AsylumEvent &evt) {
// Reset frame increments & state
if (_counter2 == 0 && _data_4572CC == 0 && _leftButtonClicked && _data_45AAA8 == 0 && _currentFrameIndex == _data_45AAAC) {
for (uint32 i = 0; i < 5; i++) {
- if (!(_frameIndexes[i] % -4))
+ if (!(_frameIndexes[i] % ~3))
_frameIncrements[i] = 0;
}
@@ -231,7 +231,7 @@ bool PuzzleTimeMachine::mouseLeftDown(const AsylumEvent &evt) {
_data_4572CC = true;
_data_4572BC = true;
- if (index % -2 == 1) {
+ if (index % ~1 == 1) {
_frameIncrements[index] = 1;
_state[index] = 1;
} else {
diff --git a/engines/asylum/puzzles/timemachine.h b/engines/asylum/puzzles/timemachine.h
index 72b78b5032..1acf860f4c 100644
--- a/engines/asylum/puzzles/timemachine.h
+++ b/engines/asylum/puzzles/timemachine.h
@@ -44,7 +44,7 @@ private:
uint32 _counter;
uint32 _counter2;
uint32 _currentFrameIndex;
- uint32 _frameIndexes[6];
+ int32 _frameIndexes[6];
uint32 _frameCounts[6];
int32 _frameIncrements[6];
int8 _state[5];
Commit: cb86e1b52400d801469a10f97d05190865891337
https://github.com/scummvm/scummvm/commit/cb86e1b52400d801469a10f97d05190865891337
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:48+02:00
Commit Message:
ASYLUM: Finish implementation of Wheel puzzle
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@748 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/puzzles/wheel.cpp
engines/asylum/puzzles/wheel.h
diff --git a/engines/asylum/puzzles/wheel.cpp b/engines/asylum/puzzles/wheel.cpp
index 24c543b8b9..738c6abbe9 100644
--- a/engines/asylum/puzzles/wheel.cpp
+++ b/engines/asylum/puzzles/wheel.cpp
@@ -48,7 +48,7 @@ const GameFlag puzzleWheelFlags[32] = {
kGameFlag259, kGameFlag260
};
-const uint32 puzzleFrameCountIndex[24] = {
+const uint32 puzzleWheelContacts[24] = {
1, 5, 7, 2, 6,
8, 1, 3, 7, 2,
4, 8, 1, 3, 5,
@@ -56,13 +56,76 @@ const uint32 puzzleFrameCountIndex[24] = {
7, 4, 6, 8
};
-const uint32 puzzleResourceIndexes[16] = {
+const uint32 puzzleWheelSparks[8] = {
+ 0, 6, 5, 4, 1, 3, 7, 2
+};
+
+const uint32 puzzleWheelClockResourceIndexes[16] = {
39, 40, 42, 44, 46,
48, 50, 52, 38, 41,
43, 45, 47, 49, 51,
53
};
+const Common::Point puzzleWheelPoints[56] = {
+ Common::Point( 0, 0),
+ Common::Point( 0, 0),
+ Common::Point( 0, 0),
+ Common::Point(250, 254),
+ Common::Point(122, 24),
+ Common::Point(208, 68), // 5
+ Common::Point(238, 160),
+ Common::Point(218, 234),
+ Common::Point(162, 228),
+ Common::Point( 71, 222),
+ Common::Point( 22, 165), // 10
+ Common::Point( 35, 70),
+ Common::Point(278, 0),
+ Common::Point(536, 146),
+ Common::Point(122, 24),
+ Common::Point(208, 68), // 15
+ Common::Point(238, 160),
+ Common::Point(218, 234),
+ Common::Point(162, 228),
+ Common::Point( 71, 222),
+ Common::Point( 22, 165), // 20
+ Common::Point( 35, 70),
+ Common::Point(342, 87),
+ Common::Point(342, 87),
+ Common::Point(342, 87),
+ Common::Point(342, 87), // 25
+ Common::Point(342, 87),
+ Common::Point(342, 87),
+ Common::Point(342, 87),
+ Common::Point(342, 87),
+ Common::Point(358, 268), // 30
+ Common::Point(342, 87),
+ Common::Point(342, 87),
+ Common::Point(342, 87),
+ Common::Point(342, 87),
+ Common::Point(342, 87), // 35
+ Common::Point(342, 87),
+ Common::Point(342, 87),
+ Common::Point(342, 87),
+ Common::Point(342, 87),
+ Common::Point(342, 87), // 40
+ Common::Point(342, 87),
+ Common::Point(342, 87),
+ Common::Point(342, 87),
+ Common::Point(342, 87),
+ Common::Point(342, 87), // 45
+ Common::Point(342, 87),
+ Common::Point(536, 146),
+ Common::Point(406, 106),
+ Common::Point(402, 217),
+ Common::Point(369, 128), // 50
+ Common::Point(368, 197),
+ Common::Point(452, 184),
+ Common::Point(470, 144),
+ Common::Point(442, 116),
+ Common::Point(347, 166) // 55
+};
+
const Common::Rect puzzleWheelRects[4] = {
Common::Rect(425, 268, 491, 407),
Common::Rect(358, 268, 424, 407),
@@ -73,17 +136,17 @@ const Common::Rect puzzleWheelRects[4] = {
PuzzleWheel::PuzzleWheel(AsylumEngine *engine) : Puzzle(engine) {
_currentRect = -1;
_resourceIndex = 0;
- _resourceIndex9 = 0;
- _resourceIndex10 = 13;
+ _resourceIndexClock = 0;
+ _resourceIndexLever = 13;
- _frameIndex30 = 0;
- memset(&_frameIndexes, -1, sizeof(_frameIndexes));
- memset(&_frameCounts, 0, sizeof(_frameCounts));
+ _frameIndexWheel = 0;
+ memset(&_frameIndexes, 0, sizeof(_frameIndexes));
+ memset(&_frameIndexesSparks, -1, sizeof(_frameIndexesSparks));
- _showResource9 = false;
- _flag1 = false;
- _flag2 = false;
- _flag3 = false;
+ _showTurnedClock = false;
+ _turnWheelRight = false;
+ _moveLever = false;
+ _moveChain = false;
}
PuzzleWheel::~PuzzleWheel() {
@@ -93,16 +156,16 @@ void PuzzleWheel::reset() {
getSpecial()->reset(true);
_resourceIndex = 0;
- _resourceIndex10 = 13;
+ _resourceIndexLever = 13;
- _frameIndex30 = 0;
+ _frameIndexWheel = 0;
- _frameCounts[0] = 0;
- _frameCounts[9] = 0;
- _frameCounts[10] = 0;
- _frameCounts[11] = 0;
+ _frameIndexes[0] = 0;
+ _frameIndexes[9] = 0;
+ _frameIndexes[10] = 0;
+ _frameIndexes[11] = 0;
- _flag1 = false;
+ _turnWheelRight = false;
}
//////////////////////////////////////////////////////////////////////////
@@ -114,54 +177,182 @@ bool PuzzleWheel::init(const AsylumEvent &evt) {
getScreen()->setPalette(getWorld()->graphicResourceIds[1]);
getScreen()->setGammaLevel(getWorld()->graphicResourceIds[1], 0);
- updateCursor(evt);
+ updateCursor();
getCursor()->show();
_currentRect = -2;
- memset(&_frameIndexes, -1, sizeof(_frameIndexes));
+ memset(&_frameIndexesSparks, -1, sizeof(_frameIndexesSparks));
for (uint32 i = 0; i < 8; i++) {
if (_vm->isGameFlagSet((GameFlag)(kGameFlag253 + i)))
- _frameCounts[i + 1] = GraphicResource::getFrameCount(_vm, getWorld()->graphicResourceIds[i + 14]) - 1;
+ _frameIndexes[i + 1] = GraphicResource::getFrameCount(_vm, getWorld()->graphicResourceIds[i + 14]) - 1;
else
- _frameCounts[i + 1] = GraphicResource::getFrameCount(_vm, getWorld()->graphicResourceIds[i + 4]) - 1;
+ _frameIndexes[i + 1] = GraphicResource::getFrameCount(_vm, getWorld()->graphicResourceIds[i + 4]) - 1;
}
return true;
}
bool PuzzleWheel::update(const AsylumEvent &evt) {
- error("[PuzzleWheel::update] Not implemented!");
+ updateCursor();
+
+ getScreen()->clearGraphicsInQueue();
+ getScreen()->draw(getWorld()->graphicResourceIds[0]);
+
+ // Blinking red light
+ getScreen()->draw(getWorld()->graphicResourceIds[12], _frameIndexes[11], puzzleWheelPoints[12].x, puzzleWheelPoints[12].y, 0);
+ _frameIndexes[11] = (_frameIndexes[11] + 1 ) % GraphicResource::getFrameCount(_vm, getWorld()->graphicResourceIds[12]);
+
+ // Clock
+ if (_showTurnedClock)
+ getScreen()->draw(getWorld()->graphicResourceIds[_resourceIndexClock], _frameIndexes[9], 342, 87, 0);
+ else
+ getScreen()->draw(getWorld()->graphicResourceIds[_resourceIndex + 22], 0, 342, 87, 0);
+
+ // Chain
+ getScreen()->draw(getWorld()->graphicResourceIds[3], _frameIndexes[0], puzzleWheelPoints[3].x, puzzleWheelPoints[3].y, 0);
+
+ // Update chain frame index
+ if (_moveChain) {
+ if (!_frameIndexes[0]) {
+ getCursor()->hide();
+ getSound()->playSound(getWorld()->graphicResourceIds[65]);
+ }
+
+ _frameIndexes[0] = (_frameIndexes[0] + 1) % GraphicResource::getFrameCount(_vm, getWorld()->graphicResourceIds[3]);
+
+ if (!_frameIndexes[0]) {
+ closeLocks();
+ _moveChain = false;
+ getCursor()->show();
+ }
+ }
+
+ // Locks
+ uint32 frameIndex = 1;
+ for (uint32 i = 0; i < 8; i++) {
+ ResourceId resourceIndex = 0;
+ uint32 pointIndex = 0;
+
+ if (_vm->isGameFlagSet((GameFlag)(kGameFlag253 + i))) {
+ resourceIndex = 14 + i;
+ pointIndex = 10 + (4 + i);
+ } else {
+ resourceIndex = 4 + i;
+ pointIndex = 4 + i;
+ }
+
+ getScreen()->draw(getWorld()->graphicResourceIds[resourceIndex], _frameIndexes[frameIndex], puzzleWheelPoints[pointIndex].x, puzzleWheelPoints[pointIndex].y, 0);
+
+ if (_frameIndexes[frameIndex] != (int32)GraphicResource::getFrameCount(_vm, getWorld()->graphicResourceIds[resourceIndex]) - 1)
+ ++_frameIndexes[frameIndex];
+
+ ++frameIndex;
+ }
+
+ // Sparks
+ for (uint32 i = 0; i < 8; i++) {
+ if (_frameIndexesSparks[i] >= 0) {
+ getScreen()->draw(getWorld()->graphicResourceIds[57 + i], _frameIndexesSparks[i], puzzleWheelPoints[48 + i].x, puzzleWheelPoints[48 + i].y, 0);
+
+ if (_frameIndexesSparks[i] == (int32)GraphicResource::getFrameCount(_vm, getWorld()->graphicResourceIds[57 + i]) - 1)
+ _frameIndexesSparks[i] = -1;
+ else
+ ++_frameIndexesSparks[i];
+ }
+ }
+
+ // Lever
+ if (_resourceIndexLever == 13)
+ getScreen()->draw(getWorld()->graphicResourceIds[_resourceIndexLever], _frameIndexes[10], puzzleWheelPoints[13].x, puzzleWheelPoints[13].y, 0);
+ else if (_resourceIndexLever == 54)
+ getScreen()->draw(getWorld()->graphicResourceIds[_resourceIndexLever], _frameIndexes[10], puzzleWheelPoints[47].x, puzzleWheelPoints[47].y, 0);
+
+ // Update lever frame index
+ if (_moveLever) {
+ if (!_frameIndexes[10] && _resourceIndexLever == 13) {
+ getCursor()->hide();
+ getSound()->playSound(getWorld()->graphicResourceIds[67]);
+ }
+
+ _frameIndexes[10] = (_frameIndexes[10] + 1) % GraphicResource::getFrameCount(_vm, getWorld()->graphicResourceIds[_resourceIndexLever]);
+
+ if (!_frameIndexes[10]) {
+ if (_resourceIndexLever == 54) {
+ _resourceIndexLever = 13;
+ toggleLocks();
+ _moveLever = false;
+ getCursor()->show();
+ } else {
+ _resourceIndexLever = 54;
+ }
+ }
+ }
+
+ // Wheel
+ getScreen()->draw(getWorld()->graphicResourceIds[30], _frameIndexWheel, puzzleWheelPoints[30].x, puzzleWheelPoints[30].y, 0);
+
+ // Update wheel frame index
+ if (_showTurnedClock) {
+ if (!_frameIndexes[9]) {
+ getCursor()->hide();
+ getSound()->playSound(getWorld()->graphicResourceIds[66]);
+ }
+
+ uint32 frameCountWheel = GraphicResource::getFrameCount(_vm, getWorld()->graphicResourceIds[30]);
+ if (_turnWheelRight)
+ _frameIndexWheel = (_frameIndexWheel + 1) % frameCountWheel;
+ else
+ _frameIndexWheel = (_frameIndexWheel + frameCountWheel - 1) % frameCountWheel;
+
+ _frameIndexes[9] = (_frameIndexes[9] + 1) % GraphicResource::getFrameCount(_vm, getWorld()->graphicResourceIds[_resourceIndexClock]);
+
+ if (!_frameIndexes[9]) {
+ _showTurnedClock = false;
+ getCursor()->show();
+ }
+ }
+
+ //////////////////////////////////////////////////////////////////////////
+ // Show elements on screen
+ getScene()->drawRain();
+ getScreen()->drawGraphicsInQueue();
+ getScreen()->copyBackBufferToScreen();
+
+ // Check for completion
+ checkFlags();
+
+ return true;
}
bool PuzzleWheel::mouseLeftDown(const AsylumEvent &evt) {
- switch (findRect(evt.mouse)) {
+ switch (findRect()) {
default:
break;
- case 0:
- _frameCounts[9] = 0;
- _flag1 = true;
- _showResource9 = true;
+ case 0: // Wheel right
+ _frameIndexes[9] = 0;
+ _turnWheelRight = true;
+ _showTurnedClock = true;
updateIndex();
break;
- case 1:
- _frameCounts[9] = 0;
- _flag1 = false;
- _showResource9 = true;
+ case 1: // Wheel left
+ _frameIndexes[9] = 0;
+ _turnWheelRight = false;
+ _showTurnedClock = true;
updateIndex();
break;
- case 2:
- _flag2 = true;
+ case 2: // Lever
+ _moveLever = true;
break;
- case 3:
- _flag3 = true;
+ case 3: // Chain
+ _moveChain = true;
break;
}
@@ -178,8 +369,8 @@ bool PuzzleWheel::mouseRightDown(const AsylumEvent &evt) {
//////////////////////////////////////////////////////////////////////////
// Helpers
//////////////////////////////////////////////////////////////////////////
-void PuzzleWheel::updateCursor(const AsylumEvent &evt) {
- int32 index = findRect(evt.mouse);
+void PuzzleWheel::updateCursor() {
+ int32 index = findRect();
if (_currentRect != index) {
_currentRect = index;
@@ -188,9 +379,9 @@ void PuzzleWheel::updateCursor(const AsylumEvent &evt) {
}
}
-int32 PuzzleWheel::findRect(Common::Point mousePos) {
+int32 PuzzleWheel::findRect() {
for (uint32 i = 0; i < ARRAYSIZE(puzzleWheelRects); i++) {
- if (puzzleWheelRects[i].contains(mousePos))
+ if (puzzleWheelRects[i].contains(getCursor()->position()))
return i;
}
@@ -198,8 +389,14 @@ int32 PuzzleWheel::findRect(Common::Point mousePos) {
}
void PuzzleWheel::updateIndex() {
- _resourceIndex9 = puzzleResourceIndexes[_resourceIndex + (_flag1 ? 0 : 8)];
- _resourceIndex = (_resourceIndex + (_flag1 ? 7 : 1)) % -8;
+ if (_turnWheelRight) {
+ _resourceIndexClock = puzzleWheelClockResourceIndexes[_resourceIndex];
+ _resourceIndex = (_resourceIndex + 7) % ~7;
+ } else {
+ _resourceIndexClock = puzzleWheelClockResourceIndexes[_resourceIndex + 8];
+ _resourceIndex = (_resourceIndex + 1) % ~7;
+ }
+
}
void PuzzleWheel::checkFlags() {
@@ -212,25 +409,28 @@ void PuzzleWheel::checkFlags() {
_vm->switchEventHandler(getScene());
}
-void PuzzleWheel::playSound() {
+void PuzzleWheel::closeLocks() {
for (uint32 i = 0; i < 8; i++) {
if (!_vm->isGameFlagSet(puzzleWheelFlags[24 + i]))
continue;
getSound()->playSound(getWorld()->graphicResourceIds[69]);
_vm->clearGameFlag(puzzleWheelFlags[24 + i]);
- _frameCounts[i + 1] = 0;
+ _frameIndexes[i + 1] = 0;
}
}
-void PuzzleWheel::playSoundReset() {
- memset(&_frameIndexes, -1, sizeof(_frameIndexes));
+void PuzzleWheel::toggleLocks() {
+ memset(&_frameIndexesSparks, -1, sizeof(_frameIndexesSparks));
for (uint32 i = 0; i < 3; i++) {
_vm->toggleGameFlag(puzzleWheelFlags[i + 3 * _resourceIndex]);
- _frameCounts[puzzleFrameCountIndex[i + 3 * _resourceIndex]] = 0;
- // Original game resets some unused data
+ // Update lock frame indexes
+ _frameIndexes[puzzleWheelContacts[i + 3 * _resourceIndex]] = 0;
+
+ // Update sparks frame indexes
+ _frameIndexesSparks[puzzleWheelSparks[puzzleWheelContacts[i + 3 * _resourceIndex] - 1]] = 0;
if (_vm->isGameFlagSet(puzzleWheelFlags[i]))
getSound()->playSound(getWorld()->graphicResourceIds[68]);
diff --git a/engines/asylum/puzzles/wheel.h b/engines/asylum/puzzles/wheel.h
index e387ed0bbb..4480980975 100644
--- a/engines/asylum/puzzles/wheel.h
+++ b/engines/asylum/puzzles/wheel.h
@@ -41,17 +41,17 @@ public:
private:
int32 _currentRect;
- uint32 _resourceIndex;
- uint32 _resourceIndex9;
- uint32 _resourceIndex10;
- uint32 _frameIndex30;
- int32 _frameIndexes[8];
- int32 _frameCounts[12];
+ int32 _resourceIndex;
+ uint32 _resourceIndexClock;
+ uint32 _resourceIndexLever;
+ uint32 _frameIndexWheel;
+ int32 _frameIndexes[12];
+ int32 _frameIndexesSparks[8];
- bool _showResource9;
- bool _flag1;
- bool _flag2;
- bool _flag3;
+ bool _showTurnedClock;
+ bool _turnWheelRight;
+ bool _moveLever;
+ bool _moveChain;
//////////////////////////////////////////////////////////////////////////
// Event Handling
@@ -64,12 +64,12 @@ private:
//////////////////////////////////////////////////////////////////////////
// Helpers
//////////////////////////////////////////////////////////////////////////
- void updateCursor(const AsylumEvent &evt);
- int32 findRect(Common::Point mousePos);
+ void updateCursor();
+ int32 findRect();
void updateIndex();
void checkFlags();
- void playSound();
- void playSoundReset();
+ void closeLocks();
+ void toggleLocks();
};
} // End of namespace Asylum
Commit: 26eae3bd44dd222da29e865d8ef863158ec40ea0
https://github.com/scummvm/scummvm/commit/26eae3bd44dd222da29e865d8ef863158ec40ea0
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:48+02:00
Commit Message:
ASYLUM: Fix a typo in Text::draw and add some comments
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@749 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/system/text.cpp
diff --git a/engines/asylum/system/text.cpp b/engines/asylum/system/text.cpp
index de51b430c2..2cda73a366 100644
--- a/engines/asylum/system/text.cpp
+++ b/engines/asylum/system/text.cpp
@@ -61,7 +61,7 @@ ResourceId Text::loadFont(ResourceId resourceId) {
_fontResource = NULL;
if (resourceId != kResourceNone) {
- _fontResource = new GraphicResource(_vm, resourceId);
+ _fontResource = new GraphicResource(_vm, resourceId);
_curFontFlags = Common::Rational(_fontResource->getData().flags, 16).toInt() & 0x0F;
}
@@ -187,26 +187,24 @@ uint32 Text::draw(int32 a1, int32 a2, TextCentering centering, int32 x, int32 y,
if (!text || !*text)
return 0;
+ uint32 printed = 0;
bool drawText = false;
- int32 charWidth = 0;
int32 spaceWidth = 0;
int32 index = 0;
const char *string = text;
const char *endText = text;
- uint32 printed = 0;
-
for (;;) {
label_start:
- charWidth = 0;
+ int32 charWidth = 0;
// Draw the text
if (drawText) {
char currentChar = *endText;
- if (index >= a1 && index <= (a1 + 2)) {
+ if (index >= a1 && index <= (a1 + a2)) {
switch (centering) {
default:
case kTextCalculate:
@@ -256,16 +254,17 @@ label_start:
if (!c)
break;
- if (c == 1)
+ if (c == 1) // Start of heading (SOH)
break;
charWidth += getWidth(c);
txt++;
c = txt[0];
+
} while (c != ' ');
}
- if (w + charWidth > width) {
+ if ((w + charWidth) > width) {
string = text;
endText = txt2 - 1;
drawText = true;
@@ -275,7 +274,7 @@ label_start:
if (!*txt)
break;
- if (*txt == 1 || *txt == 2)
+ if (*txt == 1 || *txt == 2) // Start of heading (SOH) or start of text (STX)
break;
++txt;
Commit: fa0705770b7a8a88be68d357748697f26c45b18e
https://github.com/scummvm/scummvm/commit/fa0705770b7a8a88be68d357748697f26c45b18e
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:49+02:00
Commit Message:
ASYLUM: Implement parts of Writings puzzle
The original draws to a surface on initialization and then uses that surface when updating the screen.
It also uses masked drawing which we do not implement yet.
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@750 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/puzzles/writings.cpp
engines/asylum/puzzles/writings.h
engines/asylum/shared.h
diff --git a/engines/asylum/puzzles/writings.cpp b/engines/asylum/puzzles/writings.cpp
index beb83c33fc..77397654a0 100644
--- a/engines/asylum/puzzles/writings.cpp
+++ b/engines/asylum/puzzles/writings.cpp
@@ -25,9 +25,23 @@
#include "asylum/puzzles/writings.h"
+#include "asylum/resources/actor.h"
+#include "asylum/resources/worldstats.h"
+
+#include "asylum/system/cursor.h"
+#include "asylum/system/graphics.h"
+#include "asylum/system/screen.h"
+#include "asylum/system/text.h"
+
+#include "asylum/views/scene.h"
+
+#include "asylum/asylum.h"
+
namespace Asylum {
PuzzleWritings::PuzzleWritings(AsylumEngine *engine) : Puzzle(engine) {
+ _frameIndex = 0;
+ _hasGlassMagnifier = false;
}
PuzzleWritings::~PuzzleWritings() {
@@ -37,15 +51,100 @@ PuzzleWritings::~PuzzleWritings() {
// Event Handling
//////////////////////////////////////////////////////////////////////////
bool PuzzleWritings::init(const AsylumEvent &evt) {
- error("[PuzzleWritings::init] Not implemented!");
+ if (getScene()->getActor()->getField638() == 3)
+ _hasGlassMagnifier = true;
+ else
+ _hasGlassMagnifier = false;
+
+ getScreen()->setPalette(getWorld()->graphicResourceIds[10]);
+ getScreen()->setGammaLevel(getWorld()->graphicResourceIds[10], 0);
+
+ if (_hasGlassMagnifier) {
+ getCursor()->hide();
+ getSharedData()->setFlag(kFlag1, true);
+ _vm->setGameFlag(kGameFlag481);
+ } else {
+ getCursor()->set(getWorld()->graphicResourceIds[61], -1, kCursorAnimationNone, 7);
+ }
+
+ return false;
}
bool PuzzleWritings::update(const AsylumEvent &evt) {
- error("[PuzzleWritings::update] Not implemented!");
+ // Adjust palette
+ if (rnd(10) < 7) {
+ getScreen()->setPalette(getWorld()->graphicResourceIds[6]);
+ getScreen()->setGammaLevel(getWorld()->graphicResourceIds[6], 0);
+ } else {
+ getScreen()->setPalette(getWorld()->graphicResourceIds[10]);
+ getScreen()->setGammaLevel(getWorld()->graphicResourceIds[10], 0);
+ }
+
+ // Compute frame index
+ Common::Point mousePos = getCursor()->position();
+
+ if (mousePos.x > 50 && mousePos.x < 530 && mousePos.y > 20 && mousePos.y < 430) {
+ if (_frameIndex < 26)
+ ++_frameIndex;
+ } else {
+ if (_frameIndex > 0)
+ --_frameIndex;
+ }
+
+ // TODO Compute rects to update
+
+ // Draw background
+ getScreen()->clearGraphicsInQueue();
+ getScreen()->draw(getWorld()->graphicResourceIds[4]);
+
+ if (_hasGlassMagnifier) {
+ // This currently goes into an almost infinite loop and then segfaults due to a bug in Text::draw()
+ drawBackground();
+
+ // The original blits part of the background onto the surface (9) and then adds it to the queue
+
+ getScreen()->addGraphicToQueueMasked(getWorld()->graphicResourceIds[9], 0, mousePos, getWorld()->graphicResourceIds[8], mousePos, 0, 2);
+ getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[7], _frameIndex, mousePos, 0, 0, 1);
+ }
+
+ getScreen()->drawGraphicsInQueue();
+ getScreen()->copyBackBufferToScreen();
+
+ return true;
+}
+
+bool PuzzleWritings::mouseRightUp(const AsylumEvent &evt) {
+ getCursor()->hide();
+ getSharedData()->setFlag(kFlag1, true);
+ getScreen()->setupPaletteAndStartFade(0, 0, 0);
+
+ _vm->switchEventHandler(getScene());
+
+ return false;
}
-bool PuzzleWritings::mouseLeftDown(const AsylumEvent &evt) {
- error("[PuzzleWritings::mouse] Not implemented!");
+//////////////////////////////////////////////////////////////////////////
+// Helpers
+//////////////////////////////////////////////////////////////////////////
+
+void PuzzleWritings::drawBackground() {
+ // Draw background
+ getScreen()->draw(getWorld()->graphicResourceIds[5]);
+
+ // Draw all lines of text
+ getText()->loadFont(getWorld()->graphicResourceIds[42]);
+ getText()->draw(0, 99, kTextNormal, 70, 45, 16, 24, getText()->get(MAKE_RESOURCE(kResourcePackText, 1825)));
+ getText()->draw(0, 99, kTextNormal, 130, 75, 16, 24, getText()->get(MAKE_RESOURCE(kResourcePackText, 1826)));
+ getText()->draw(0, 99, kTextNormal, 70, 105, 16, 24, getText()->get(MAKE_RESOURCE(kResourcePackText, 1827)));
+ getText()->draw(0, 99, kTextNormal, 130, 135, 16, 24, getText()->get(MAKE_RESOURCE(kResourcePackText, 1828)));
+ getText()->draw(0, 99, kTextNormal, 70, 165, 16, 24, getText()->get(MAKE_RESOURCE(kResourcePackText, 1829)));
+ getText()->draw(0, 99, kTextNormal, 130, 195, 16, 24, getText()->get(MAKE_RESOURCE(kResourcePackText, 1830)));
+ getText()->draw(0, 99, kTextNormal, 70, 225, 16, 24, getText()->get(MAKE_RESOURCE(kResourcePackText, 1831)));
+ getText()->draw(0, 99, kTextNormal, 130, 255, 16, 24, getText()->get(MAKE_RESOURCE(kResourcePackText, 1832)));
+ getText()->draw(0, 99, kTextNormal, 70, 285, 16, 24, getText()->get(MAKE_RESOURCE(kResourcePackText, 1833)));
+ getText()->draw(0, 99, kTextNormal, 130, 315, 16, 24, getText()->get(MAKE_RESOURCE(kResourcePackText, 1834)));
+ getText()->draw(0, 99, kTextCenter, 320, 375, 16, 24, getText()->get(MAKE_RESOURCE(kResourcePackText, 1835)));
+ getText()->draw(0, 99, kTextCenter, 320, 405, 16, 24, getText()->get(MAKE_RESOURCE(kResourcePackText, 1836)));
}
} // End of namespace Asylum
diff --git a/engines/asylum/puzzles/writings.h b/engines/asylum/puzzles/writings.h
index 40bd431b88..14fedd464e 100644
--- a/engines/asylum/puzzles/writings.h
+++ b/engines/asylum/puzzles/writings.h
@@ -38,13 +38,29 @@ public:
~PuzzleWritings();
private:
+ int32 _frameIndex;
+
+ bool _hasGlassMagnifier;
+
//////////////////////////////////////////////////////////////////////////
// Event Handling
//////////////////////////////////////////////////////////////////////////
bool init(const AsylumEvent &evt);
bool update(const AsylumEvent &evt);
bool key(const AsylumEvent &evt) { return keyExit(evt); }
- bool mouseLeftDown(const AsylumEvent &evt);
+ bool mouseRightUp(const AsylumEvent &evt);
+
+ //////////////////////////////////////////////////////////////////////////
+ // Helpers
+ //////////////////////////////////////////////////////////////////////////
+
+ /**
+ * Draw the background.
+ *
+ * @note the original draws the background once during initialization
+ * and saves the resulting surface into the original background
+ */
+ void drawBackground();
};
} // End of namespace Asylum
diff --git a/engines/asylum/shared.h b/engines/asylum/shared.h
index 57663d254c..160b1ff2f4 100644
--- a/engines/asylum/shared.h
+++ b/engines/asylum/shared.h
@@ -103,6 +103,7 @@ enum GameFlag {
kGameFlag454 = 454,
kGameFlag455 = 455,
kGameFlag470 = 470,
+ kGameFlag481 = 481,
kGameFlag511 = 511,
kGameFlag528 = 528,
kGameFlag543 = 543,
Commit: fc53180f5fe85c77dabbcace5c91b378f7f395c6
https://github.com/scummvm/scummvm/commit/fc53180f5fe85c77dabbcace5c91b378f7f395c6
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:49+02:00
Commit Message:
ASYLUM: Implement Lock puzzle
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@751 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/console.cpp
engines/asylum/puzzles/lock.cpp
engines/asylum/puzzles/lock.h
engines/asylum/shared.h
diff --git a/engines/asylum/console.cpp b/engines/asylum/console.cpp
index 491e04c42a..fad73a29ae 100644
--- a/engines/asylum/console.cpp
+++ b/engines/asylum/console.cpp
@@ -53,7 +53,7 @@ const ResourcePackId puzzleToScenes[17] = {
kResourcePackTowerCells, // VCR
kResourcePackCourtyardAndChapel, // Pipes
kResourcePackInnocentAbandoned, // TicTacToe
- kResourcePackMansion, // Lock
+ kResourcePackInnocentAbandoned, // Lock
kResourcePackInvalid, // Puzzle 5 has no event handler
kResourcePackLaboratory, // Wheel
kResourcePackLaboratory, // Board Salvation
diff --git a/engines/asylum/puzzles/lock.cpp b/engines/asylum/puzzles/lock.cpp
index bd5a2c332e..3c901812b2 100644
--- a/engines/asylum/puzzles/lock.cpp
+++ b/engines/asylum/puzzles/lock.cpp
@@ -25,27 +25,230 @@
#include "asylum/puzzles/lock.h"
+#include "asylum/resources/worldstats.h"
+
+#include "asylum/system/cursor.h"
+#include "asylum/system/graphics.h"
+#include "asylum/system/screen.h"
+
+#include "asylum/views/scene.h"
+
+#include "asylum/asylum.h"
+
namespace Asylum {
+const Common::Point puzzleLockPolygons[16] = {
+ Common::Point(159, 293), Common::Point(151, 318), Common::Point(179, 322), Common::Point(185, 298),
+ Common::Point(212, 303), Common::Point(207, 327), Common::Point(234, 332), Common::Point(239, 308),
+ Common::Point(149, 333), Common::Point(146, 365), Common::Point(172, 369), Common::Point(176, 338),
+ Common::Point(202, 345), Common::Point(200, 375), Common::Point(226, 379), Common::Point(231, 347)
+};
+
PuzzleLock::PuzzleLock(AsylumEngine *engine) : Puzzle(engine) {
+ memset(&_frameIndexes, 0, sizeof(_frameIndexes));
+ _incrementLock = false;
+ _counter = 0;
+ memset(&_ticks, 0, sizeof(_ticks));
}
PuzzleLock::~PuzzleLock() {
}
+void PuzzleLock::reset() {
+ _frameIndexes[0] = 4;
+ _frameIndexes[1] = 4;
+ _frameIndexes[2] = 4;
+
+ for (uint32 i = 0; i < 37; i++)
+ getSharedData()->setData(i, 160);
+
+ getSharedData()->setData(37, 1);
+}
+
//////////////////////////////////////////////////////////////////////////
// Event Handling
//////////////////////////////////////////////////////////////////////////
bool PuzzleLock::init(const AsylumEvent &evt) {
- error("[PuzzleLock::init] Not implemented!");
+ getScreen()->clear();
+
+ getScreen()->setPalette(getWorld()->graphicResourceIds[14]);
+ getScreen()->setGammaLevel(getWorld()->graphicResourceIds[14], 0);
+
+ _vm->setGameFlag(kGameFlag115);
+
+ getCursor()->set(getWorld()->graphicResourceIds[41], 0, kCursorAnimationNone);
+
+ return true;
}
bool PuzzleLock::update(const AsylumEvent &evt) {
- error("[PuzzleLock::update] Not implemented!");
+ updateCursor();
+
+ // Draw screen
+ getScreen()->clearGraphicsInQueue();
+ getScreen()->draw(getWorld()->graphicResourceIds[13]);
+
+ if (_frameIndexes[0] != 32 || _frameIndexes[1] != 28 || _frameIndexes[2] != 0) {
+ getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[15], _frameIndexes[0], Common::Point(145, 292), 0, 0, 1);
+ getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[15], _frameIndexes[1], Common::Point(173, 297), 0, 0, 1);
+ getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[15], _frameIndexes[2], Common::Point(201, 302), 0, 0, 1);
+ getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[40], _frameIndexes[3], Common::Point(337, 127), 0, 0, 1);
+
+ if (_frameIndexes[4] != -1)
+ getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[42], _frameIndexes[4], Common::Point(318, 102), 0, 0, 1);
+
+ if (_frameIndexes[5] != -1)
+ getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[43], _frameIndexes[5], Common::Point(318, 99), 0, 0, 1);
+
+ getScreen()->drawGraphicsInQueue();
+ getScreen()->copyBackBufferToScreen();
+ } else {
+ if (_frameIndexes[6] == 5)
+ getSound()->playSound(getWorld()->soundResourceIds[15], false, Config.sfxVolume - 10);
+
+ getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[16], _frameIndexes[6], Common::Point(0, 264), 0, 0, 1);
+
+ ++_counter;
+
+ if (_counter > 9) {
+ ++_frameIndexes[6];
+
+ if (_frameIndexes[6] > 7) {
+ getCursor()->hide();
+ getSharedData()->setFlag(kFlag1, true);
+ _vm->setGameFlag(kGameFlag52);
+ getSound()->playSound(getWorld()->soundResourceIds[16], false, Config.sfxVolume - 10);
+ _frameIndexes[6] = 0;
+ _counter = 0;
+
+ exit();
+ } else {
+ getScreen()->drawGraphicsInQueue();
+ getScreen()->copyBackBufferToScreen();
+ _counter = 0;
+ }
+ }
+ }
+
+ // Update frame indexes
+ for (uint32 i = 0; i < 3; i++) {
+ if (_frameIndexes[i] % ~3 && _frameIndexes[i]) {
+ ++_counter;
+
+ if (_counter > 3) {
+ if (_incrementLock)
+ ++_frameIndexes[i];
+ else
+ --_frameIndexes[i];
+
+ if (_frameIndexes[i] < 0)
+ _frameIndexes[i] = 43;
+
+ if (_frameIndexes[i] > 43)
+ _frameIndexes[i] = 0;
+
+ _counter = 0;
+ }
+ }
+ }
+
+ for (uint32 i = 0; i < 2; i++) {
+ if (_frameIndexes[i + 4] == -1) {
+ _ticks[i] = _vm->getTick();
+
+ if (rnd(1000) < 10)
+ _frameIndexes[i + 4] = 0;
+ } else {
+ if (_vm->getTick() > _ticks[i] + 200) {
+ ++_frameIndexes[i + 4];
+
+ if (_frameIndexes[i + 4] > 24)
+ _frameIndexes[i + 4] = -1;
+
+ _ticks[i] = _vm->getTick();
+ }
+ }
+ }
+
+ if (_frameIndexes[3]) {
+ if (_vm->getTick() > _ticks[2] + 100) {
+ ++_frameIndexes[3];
+
+ if (_frameIndexes[3] > 15)
+ _frameIndexes[3] = 0;
+
+ _ticks[2] = _vm->getTick();
+ }
+ } else {
+ _ticks[2] = _vm->getTick();
+
+ if (rnd(1000) < 10)
+ _frameIndexes[3] = 1;
+ }
+
+ return true;
}
bool PuzzleLock::mouseLeftDown(const AsylumEvent &evt) {
- error("[PuzzleLock::mouseLeftDown] Not implemented!");
+ if (_frameIndexes[6])
+ return false;
+
+ Common::Point mousePos = evt.mouse;
+
+ for (uint32 i = 0; i < 3; i++) {
+ if (hitTest(&puzzleLockPolygons[0], mousePos, 8 + 2 * i)) {
+ if (!(_frameIndexes[i] % ~3))
+ getSound()->playSound(getWorld()->soundResourceIds[14], false, Config.sfxVolume - 10);
+
+ _incrementLock = true;
+
+ ++_frameIndexes[i];
+
+ if (_frameIndexes[i] > 43)
+ _frameIndexes[i] = 0;
+ }
+ }
+
+ for (uint32 i = 0; i < 3; i++) {
+ if (hitTest(&puzzleLockPolygons[0], mousePos, 2 * i)) {
+ if (!(_frameIndexes[i] % ~3))
+ getSound()->playSound(getWorld()->soundResourceIds[14], false, Config.sfxVolume - 10);
+
+ _incrementLock = false;
+
+ --_frameIndexes[i];
+
+ if (_frameIndexes[i] < 0)
+ _frameIndexes[i] = 43;
+ }
+ }
+
+ return true;
+}
+
+bool PuzzleLock::mouseRightDown(const AsylumEvent &evt) {
+ exit();
+
+ return true;
+}
+
+//////////////////////////////////////////////////////////////////////////
+// Helpers
+//////////////////////////////////////////////////////////////////////////
+void PuzzleLock::updateCursor() {
+ Common::Point mousePos = getCursor()->position();
+
+ for (uint32 i = 0; i < 6; i++) {
+ if (hitTest(&puzzleLockPolygons[0], mousePos, 2 * i)) {
+ if (getCursor()->animation != kCursorAnimationMirror)
+ getCursor()->set(getWorld()->graphicResourceIds[41]);
+
+ return ;
+ }
+ }
+
+ if (getCursor()->animation == kCursorAnimationMirror)
+ getCursor()->set(getWorld()->graphicResourceIds[41], 0, kCursorAnimationNone);
}
} // End of namespace Asylum
diff --git a/engines/asylum/puzzles/lock.h b/engines/asylum/puzzles/lock.h
index 5f62253b93..6419e68da1 100644
--- a/engines/asylum/puzzles/lock.h
+++ b/engines/asylum/puzzles/lock.h
@@ -37,7 +37,14 @@ public:
PuzzleLock(AsylumEngine *engine);
~PuzzleLock();
+ void reset();
+
private:
+ int32 _frameIndexes[7];
+ bool _incrementLock;
+ uint32 _counter;
+ uint32 _ticks[3];
+
//////////////////////////////////////////////////////////////////////////
// Event Handling
//////////////////////////////////////////////////////////////////////////
@@ -45,6 +52,12 @@ private:
bool update(const AsylumEvent &evt);
bool key(const AsylumEvent &evt) { return keyExit(evt); }
bool mouseLeftDown(const AsylumEvent &evt);
+ bool mouseRightDown(const AsylumEvent &evt);
+
+ //////////////////////////////////////////////////////////////////////////
+ // Helpers
+ //////////////////////////////////////////////////////////////////////////
+ void updateCursor();
};
} // End of namespace Asylum
diff --git a/engines/asylum/shared.h b/engines/asylum/shared.h
index 160b1ff2f4..9af8262ac0 100644
--- a/engines/asylum/shared.h
+++ b/engines/asylum/shared.h
@@ -32,9 +32,11 @@ namespace Asylum {
// Global
//////////////////////////////////////////////////////////////////////////
enum GameFlag {
- kGameFlag4 = 4,
- kGameFlag12 = 12,
+ kGameFlag4 = 4,
+ kGameFlag12 = 12,
+ kGameFlag52 = 52,
kGameFlag114 = 114,
+ kGameFlag115 = 115,
kGameFlag215 = 215,
kGameFlagScriptProcessing = 183,
kGameFlag186 = 186,
Commit: 265d18ee1404abae2c9cbf7a2b7b9028c76449be
https://github.com/scummvm/scummvm/commit/265d18ee1404abae2c9cbf7a2b7b9028c76449be
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:49+02:00
Commit Message:
ASYLUM: Implement proper Scene::hitTestPixel()
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@752 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/resources/actor.cpp
engines/asylum/system/screen.h
engines/asylum/views/scene.cpp
diff --git a/engines/asylum/resources/actor.cpp b/engines/asylum/resources/actor.cpp
index de2fda00d3..0ef7c619af 100644
--- a/engines/asylum/resources/actor.cpp
+++ b/engines/asylum/resources/actor.cpp
@@ -604,7 +604,7 @@ void Actor::updateStatus(ActorStatus actorStatus) {
updateGraphicData(15);
_resourceId = _graphicResourceIds[(_direction > kDirectionS ? kDirection8 - _direction : _direction) + 15];
- // TODO set word_446EE4 to -1. This global seems to be used with screen blitting
+ getScreen()->setFlag(-1);
break;
case kActorStatus7:
diff --git a/engines/asylum/system/screen.h b/engines/asylum/system/screen.h
index ec2a53e075..4fc90053dd 100644
--- a/engines/asylum/system/screen.h
+++ b/engines/asylum/system/screen.h
@@ -85,7 +85,8 @@ public:
void drawWideScreenBars(int16 barSize) const;
void fillRect(int32 x, int32 y, int32 x2, int32 y2, int32 color);
void copyBackBufferToScreen();
- void setFlag(int32 val) { _flag = (val < -1) ? -1 : val; }
+ void setFlag(int16 val) { _flag = (val < -1) ? -1 : val; }
+ int16 getFlag() { return _flag; }
void takeScreenshot();
// Palette
diff --git a/engines/asylum/views/scene.cpp b/engines/asylum/views/scene.cpp
index abf7c8fc55..e6801517b6 100644
--- a/engines/asylum/views/scene.cpp
+++ b/engines/asylum/views/scene.cpp
@@ -1497,12 +1497,56 @@ int32 Scene::hitTestObject() {
return -1;
}
-bool Scene::hitTestPixel(ResourceId resourceId, int32 frame, int16 x, int16 y, bool flipped) {
- Common::Rect rect = GraphicResource::getFrameRect(_vm, resourceId, frame);
+bool Scene::hitTestPixel(ResourceId resourceId, int32 frameIndex, int16 x, int16 y, bool flipped) {
+ if (x < 0 || y < 0)
+ return false;
+
+ GraphicResource *resource = new GraphicResource(_vm, resourceId);
+ GraphicFrame *frame = resource->getFrame(frameIndex);
+ Common::Rect frameRect = frame->getRect();
- // TODO we need to test each pixel of the surface!
+ // Check y coordinates
+ if (y < frameRect.top || y >= frameRect.bottom)
+ goto cleanup;
- return rect.contains(x, y);
+ // Compute left/right x coordinates, using flipped value
+ int32 left, right;
+ if (flipped) {
+ if (getScreen()->getFlag() == -1) {
+ left = resource->getData().maxWidth - frameRect.right;
+ right = resource->getData().maxWidth - frameRect.left;
+ } else {
+ left = frameRect.left + 2 * (getScreen()->getFlag() - (frameRect.right / 2));
+ right = x;
+ }
+ } else {
+ left = frameRect.left;
+ right = frameRect.right;
+ }
+
+ // Check x coordinates
+ if (x < left || x >= right)
+ goto cleanup;
+
+ // Check pixel value
+ byte *pixel;
+ if (flipped) {
+ pixel = (byte *)frame->surface.getBasePtr(left - x + frame->getWidth() - 1, y - frame->y);
+ } else {
+ pixel = (byte *)frame->surface.getBasePtr(x - left, y - frame->y);
+ }
+
+ if (pixel == 0)
+ goto cleanup;
+
+ delete resource;
+
+ return true;
+
+cleanup:
+ delete resource;
+
+ return false;
}
//////////////////////////////////////////////////////////////////////////
Commit: 424c02a6af6ad13b0b6d183cec748bad28be3136
https://github.com/scummvm/scummvm/commit/424c02a6af6ad13b0b6d183cec748bad28be3136
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:49+02:00
Commit Message:
ASYLUM: Fix warning in TimeMachine puzzle
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@753 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/puzzles/timemachine.cpp
diff --git a/engines/asylum/puzzles/timemachine.cpp b/engines/asylum/puzzles/timemachine.cpp
index a934e407d3..6f18b5030f 100644
--- a/engines/asylum/puzzles/timemachine.cpp
+++ b/engines/asylum/puzzles/timemachine.cpp
@@ -201,7 +201,7 @@ bool PuzzleTimeMachine::update(const AsylumEvent &evt) {
// Adjust frame indexes
for (uint32 i = 0; i < ARRAYSIZE(_frameIndexes); i++) {
- if (_frameIndexes[i] >= _frameCounts[i])
+ if (_frameIndexes[i] >= (int32)_frameCounts[i])
_frameIndexes[i] = 0;
}
Commit: 6186775f367fe0f6c7f482de6b988210598a5879
https://github.com/scummvm/scummvm/commit/6186775f367fe0f6c7f482de6b988210598a5879
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:49+02:00
Commit Message:
ASYLUM: Add stubs for Pipes puzzle
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@754 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/puzzles/pipes.cpp
engines/asylum/puzzles/pipes.h
diff --git a/engines/asylum/puzzles/pipes.cpp b/engines/asylum/puzzles/pipes.cpp
index 4372ea9515..2f3d1f0ac7 100644
--- a/engines/asylum/puzzles/pipes.cpp
+++ b/engines/asylum/puzzles/pipes.cpp
@@ -25,22 +25,53 @@
#include "asylum/puzzles/pipes.h"
+#include "asylum/resources/worldstats.h"
+
+#include "asylum/system/cursor.h"
+#include "asylum/system/graphics.h"
+#include "asylum/system/screen.h"
+
+#include "asylum/views/scene.h"
+
+#include "asylum/asylum.h"
+
namespace Asylum {
PuzzlePipes::PuzzlePipes(AsylumEngine *engine) : Puzzle(engine) {
+ _previousMusicVolume = 0;
+ _rectIndex = -2;
}
PuzzlePipes::~PuzzlePipes() {
}
+void PuzzlePipes::reset() {
+ warning("[PuzzlePipes::reset] Not implemented!");
+}
+
//////////////////////////////////////////////////////////////////////////
// Event Handling
//////////////////////////////////////////////////////////////////////////
-bool PuzzlePipes::init(const AsylumEvent &evt) {
- error("[PuzzlePipes::init] Not implemented!");
+bool PuzzlePipes::init(const AsylumEvent &evt) {
+ _previousMusicVolume = getSound()->getMusicVolume();
+
+ if (_previousMusicVolume >= -1000)
+ getSound()->setMusicVolume(-1000);
+
+ getSound()->playSound(getWorld()->graphicResourceIds[41], true, Config.ambientVolume);
+ getScreen()->setPalette(getWorld()->graphicResourceIds[0]);
+ getScreen()->setGammaLevel(getWorld()->graphicResourceIds[0], 0);
+
+ _rectIndex = -2;
+
+ updateCursor();
+ initResources();
+ setup(true);
+
+ return true;
}
-bool PuzzlePipes::update(const AsylumEvent &evt) {
+bool PuzzlePipes::update(const AsylumEvent &evt) {
error("[PuzzlePipes::update] Not implemented!");
}
@@ -48,4 +79,37 @@ bool PuzzlePipes::mouseLeftDown(const AsylumEvent &evt) {
error("[PuzzlePipes::mouseLeftDown] Not implemented!");
}
+bool PuzzlePipes::mouseRightDown(const AsylumEvent &evt) {
+ getScreen()->clear();
+ getSound()->stop(getWorld()->graphicResourceIds[41]);
+ getSound()->setMusicVolume(_previousMusicVolume);
+
+ _vm->switchEventHandler(getScene());
+
+ return true;
+}
+
+//////////////////////////////////////////////////////////////////////////
+// Helpers
+//////////////////////////////////////////////////////////////////////////
+void PuzzlePipes::initResources() {
+ error("[PuzzlePipes::initResources] Not implemented!");
+}
+
+void PuzzlePipes::setup(bool val) {
+ error("[PuzzlePipes::setup] Not implemented!");
+}
+
+void PuzzlePipes::updateCursor() {
+ error("[PuzzlePipes::updateCursor] Not implemented!");
+}
+
+int32 PuzzlePipes::findRect() {
+ error("[PuzzlePipes::findRect] Not implemented!");
+}
+
+void PuzzlePipes::checkFlags() {
+ error("[PuzzlePipes::checkFlags] Not implemented!");
+}
+
} // End of namespace Asylum
diff --git a/engines/asylum/puzzles/pipes.h b/engines/asylum/puzzles/pipes.h
index be206d8b97..19d21bf291 100644
--- a/engines/asylum/puzzles/pipes.h
+++ b/engines/asylum/puzzles/pipes.h
@@ -37,13 +37,28 @@ public:
PuzzlePipes(AsylumEngine *engine);
~PuzzlePipes();
+ void reset();
+
private:
+ int32 _previousMusicVolume;
+ int32 _rectIndex;
+
//////////////////////////////////////////////////////////////////////////
// Event Handling
//////////////////////////////////////////////////////////////////////////
bool init(const AsylumEvent &evt);
bool update(const AsylumEvent &evt);
bool mouseLeftDown(const AsylumEvent &evt);
+ bool mouseRightDown(const AsylumEvent &evt);
+
+ //////////////////////////////////////////////////////////////////////////
+ // Helpers
+ //////////////////////////////////////////////////////////////////////////
+ void initResources();
+ void setup(bool val);
+ void updateCursor();
+ int32 findRect();
+ void checkFlags();
};
} // End of namespace Asylum
Commit: 22f77dd05cc0231fba1555c136d4918c61068994
https://github.com/scummvm/scummvm/commit/22f77dd05cc0231fba1555c136d4918c61068994
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:49+02:00
Commit Message:
ASYLUM: Overhaul script processing
This fixes the following issues:
- screen freeze when examining objects
- infinite loop when playing some animations
- infinite loop when starting dialogs
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@755 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/resources/script.cpp
engines/asylum/resources/script.h
diff --git a/engines/asylum/resources/script.cpp b/engines/asylum/resources/script.cpp
index 5dfe16bd35..94366305e1 100644
--- a/engines/asylum/resources/script.cpp
+++ b/engines/asylum/resources/script.cpp
@@ -192,9 +192,7 @@ ScriptManager::~ScriptManager() {
delete _opcodes[i];
_scripts.clear();
- _queue.clear();
-
- _currentScript = NULL;
+ _queue.reset();
// Zero-out passed pointers
_vm = NULL;
@@ -243,16 +241,16 @@ void ScriptManager::reset() {
_scripts.clear();
_skipProcessing = false;
- _currentLoops = 0;
- _currentScript = NULL;
_done = false;
_exit = false;
- _lineIncrement = 0;
- _waitCycle = false;
+ _processNextEntry = 0;
+
+ _currentScript = NULL;
+ _currentQueueEntry = NULL;
}
void ScriptManager::resetQueue() {
- _queue.clear();
+ _queue.reset();
}
void ScriptManager::queueScript(int scriptIndex, ActorIndex actorIndex) {
@@ -260,75 +258,135 @@ void ScriptManager::queueScript(int scriptIndex, ActorIndex actorIndex) {
if (_skipProcessing)
return;
- ScriptQueueEntry entry;
- entry.scriptIndex = scriptIndex;
- entry.actorIndex = actorIndex;
-
- // If there's currently no script for the processor to run,
- // assign it directly and skip the stack push. If however the
- // current script is assigned, push the script to the stack
- if (_currentScript)
- _queue.push(entry);
- else {
- _currentQueueEntry = entry;
- _currentScript = &_scripts[entry.scriptIndex];
+ // Look for a empty queue slot
+ int32 index = 0;
+ for (index = 1; index < ARRAYSIZE(_queue.entries); index++) {
+ if (_queue.entries[index].scriptIndex == -1)
+ break;
}
+
+ // No empty queue slot, return
+ if (index == 0)
+ return;
+
+ // Setup script and queue
+ // TODO once everything is working properly, convert back to stack based script queue
+ _scripts[scriptIndex].counter = 0;
+ _queue.entries[index].field_10 = 0;
+ _queue.entries[index].field_C = 0;
+
+ if (_queue.currentEntry) {
+ _queue.entries[_queue.field_CC].field_C = index;
+ _queue.entries[index].field_10 = _queue.field_CC;
+ } else {
+ _queue.currentEntry = index;
+ }
+
+ _queue.field_CC = index;
+
+ _queue.entries[index].scriptIndex = scriptIndex;
+ _queue.entries[index].currentLine = 0;
+ _queue.entries[index].actorIndex = actorIndex;
}
bool ScriptManager::isInQueue(int32 scriptIndex) {
- for (int32 i = 0; i < _queue.size(); i++) {
- if (_queue[i].scriptIndex == scriptIndex)
+ for (int32 i = 0; i < ARRAYSIZE(_queue.entries); i++) {
+ if (_queue.entries[i].scriptIndex == scriptIndex)
return true;
}
return false;
}
+void ScriptManager::updateQueue(uint32 entryIndex) {
+ if (_queue.currentEntry == _queue.field_CC) {
+ _queue.field_CC = 0;
+ _queue.currentEntry = 0;
+ _queue.entries[entryIndex].scriptIndex = -1;
+ } else if (_queue.currentEntry == entryIndex) {
+ _queue.currentEntry = _queue.entries[entryIndex].field_C;
+ _queue.entries[_queue.currentEntry].field_10 = 0;
+ _queue.entries[entryIndex].scriptIndex = -1;
+ } else if (_queue.field_CC == entryIndex) {
+ _queue.field_CC = _queue.entries[entryIndex].field_10;
+ _queue.entries[_queue.field_CC].field_C = 0;
+ _queue.entries[entryIndex].scriptIndex = -1;
+ } else {
+ _queue.entries[_queue.entries[entryIndex].field_10].field_C = _queue.entries[entryIndex].field_C;
+ _queue.entries[_queue.entries[entryIndex].field_C].field_10 = _queue.entries[entryIndex].field_10;
+ _queue.entries[entryIndex].scriptIndex = -1;
+ }
+}
+
bool ScriptManager::process() {
- _done = false;
_exit = false;
- _waitCycle = false;
- _lineIncrement = 1;
_vm->setGameFlag(kGameFlagScriptProcessing);
- if (_currentScript) {
- while (!_done && !_waitCycle) {
- _lineIncrement = 0; //Reset line increment value
+ // Setup queue entry
+ if (_queue.currentEntry) {
+ uint32 entryIndex = _queue.currentEntry;
+ uint32 nextIndex = _queue.entries[entryIndex].field_C;
+ uint32 scriptIndex = _queue.entries[entryIndex].scriptIndex;
- ScriptEntry *cmd = &_currentScript->commands[_currentQueueEntry.currentLine];
+ if (scriptIndex != -1) {
- int32 opcode = cmd->opcode;
+ // Setup script
+ for (;;) {
+ _processNextEntry = false;
+ _done = false;
+ _currentScript = &_scripts[scriptIndex];
- debugC(kDebugLevelScripts, "[0x%02X] %s (%d, %d, %d, %d, %d, %d, %d, %d, %d)",
- opcode, _opcodes[opcode]->name,
- cmd->param1, cmd->param2, cmd->param3, cmd->param4, cmd->param5,
- cmd->param6, cmd->param7, cmd->param8, cmd->param9);
+ // Run script
+ for (;;) {
+ ScriptEntry *cmd = NULL;
- // Execute opcode
- (*_opcodes[opcode]->func)(cmd);
+ if (_processNextEntry)
+ goto label_processNextEntry;
- if (_exit)
- return true;
+ // TODO Check for bounds error
- if (!_lineIncrement)
- ++_currentQueueEntry.currentLine;
+ // Get the script command
+ cmd = &_currentScript->commands[_queue.entries[entryIndex].currentLine];
+ debugC(kDebugLevelScripts, "[0x%02X] %s (%d, %d, %d, %d, %d, %d, %d, %d, %d)",
+ cmd->opcode, _opcodes[cmd->opcode]->name,
+ cmd->param1, cmd->param2, cmd->param3, cmd->param4, cmd->param5,
+ cmd->param6, cmd->param7, cmd->param8, cmd->param9);
+ // Execute opcode
+ _currentQueueEntry = &_queue.entries[entryIndex];
+ (*_opcodes[cmd->opcode]->func)(cmd);
- }
+ // When we are asked to exit, return directly without setting the processing flag
+ if (_exit)
+ return true;
- if (_done) {
- _currentQueueEntry.currentLine = 0;
+ if (!_processNextEntry)
+ ++_queue.entries[entryIndex].currentLine;
- if (!_queue.empty()) {
- _currentQueueEntry = _queue.pop();
- _currentScript = &_scripts[_currentQueueEntry.scriptIndex];
- } else {
- _currentScript = NULL;
+ if (_done)
+ updateQueue(entryIndex);
+
+ if (!_done)
+ continue;
+
+label_processNextEntry:
+ entryIndex = nextIndex;
+
+ if (!nextIndex)
+ goto label_exit_processing;
+
+ nextIndex = _queue.entries[nextIndex].field_C;
+ scriptIndex = _queue.entries[nextIndex].scriptIndex;
+
+ if (scriptIndex == -1)
+ goto label_exit_processing;
+ }
}
}
}
+label_exit_processing:
_vm->clearGameFlag(kGameFlagScriptProcessing);
return false;
@@ -346,7 +404,7 @@ void ScriptManager::saveLoadWithSerializer(Common::Serializer &s) {
// Opcode 0x00
IMPLEMENT_OPCODE(Return)
_done = true;
- _lineIncrement = 0;
+ _processNextEntry = 0;
END_OPCODE
//////////////////////////////////////////////////////////////////////////
@@ -410,8 +468,7 @@ IMPLEMENT_OPCODE(PlayAnimation)
if (cmd->param2 == 2) {
if (object->checkFlags()) {
- _waitCycle = true;
- _lineIncrement = 1;
+ _processNextEntry = true;
} else
cmd->param2 = 1;
@@ -448,7 +505,7 @@ IMPLEMENT_OPCODE(PlayAnimation)
if (cmd->param2) {
cmd->param2 = 2;
- _lineIncrement = 1;
+ _processNextEntry = 1;
}
END_OPCODE
@@ -469,7 +526,7 @@ IMPLEMENT_OPCODE(MoveScenePosition)
} else if (cmd->param5) {
if (getWorld()->motionStatus == 2)
- _lineIncrement = 1;
+ _processNextEntry = 1;
else
cmd->param5 = 0;
} else {
@@ -481,7 +538,7 @@ IMPLEMENT_OPCODE(MoveScenePosition)
cmd->param3,
true);
- _lineIncrement = 1;
+ _processNextEntry = 1;
}
END_OPCODE
@@ -557,7 +614,7 @@ IMPLEMENT_OPCODE(EnableObjects)
enableObject(cmd, kObjectEnableType0);
}
- _lineIncrement = 1;
+ _processNextEntry = 1;
}
END_OPCODE
@@ -583,7 +640,7 @@ IMPLEMENT_OPCODE(JumpActorSpeech)
if (actor->process(cmd->param2, cmd->param3))
return;
- _currentQueueEntry.currentLine = cmd->param4;
+ _currentQueueEntry->currentLine = cmd->param4;
if (cmd->param5)
getSpeech()->playIndexed(1);
@@ -606,19 +663,19 @@ IMPLEMENT_OPCODE(JumpAndSetDirection)
if (cmd->param5 == 1) {
cmd->param5 = 2;
- _lineIncrement = 1;
+ _processNextEntry = 1;
}
}
} else {
cmd->param5 = 1;
- _lineIncrement = 0;
+ _processNextEntry = 0;
if ((actor->getPoint1()->x + actor->getPoint2()->x) == cmd->param2 && (actor->getPoint1()->y + actor->getPoint2()->y) == cmd->param3)
actor->updateFromDirection((ActorDirection)cmd->param4);
}
} else {
if (cmd->param5 == 2)
- _lineIncrement = 1;
+ _processNextEntry = 1;
}
END_OPCODE
@@ -628,7 +685,7 @@ IMPLEMENT_OPCODE(JumpIfActorCoordinates)
Actor *actor = getScene()->getActor(cmd->param1);
if ((actor->getPoint1()->x + actor->getPoint2()->x) != cmd->param2 || (actor->getPoint1()->y + actor->getPoint2()->y) != cmd->param3)
- _lineIncrement = cmd->param4;
+ _processNextEntry = cmd->param4;
END_OPCODE
//////////////////////////////////////////////////////////////////////////
@@ -663,7 +720,7 @@ IMPLEMENT_OPCODE(JumpIfSoundPlayingAndPlaySound)
if (cmd->param2 == 2) {
if (getSound()->isPlaying(resource))
- _lineIncrement = 1;
+ _processNextEntry = 1;
else
cmd->param2 = 1;
} else if (!_vm->sound()->isPlaying(resource)) {
@@ -672,7 +729,7 @@ IMPLEMENT_OPCODE(JumpIfSoundPlayingAndPlaySound)
if (cmd->param2 == 1) {
cmd->param2 = 2;
- _lineIncrement= 1;
+ _processNextEntry= 1;
}
}
END_OPCODE
@@ -734,7 +791,7 @@ END_OPCODE
//////////////////////////////////////////////////////////////////////////
// Opcode 0x22
IMPLEMENT_OPCODE(_unk22)
- Actor *actor = getScene()->getActor(cmd->param3 ? cmd->param3 : _currentQueueEntry.actorIndex);
+ Actor *actor = getScene()->getActor(cmd->param3 ? cmd->param3 : _currentQueueEntry->actorIndex);
actor->process_41BC00(cmd->param1, cmd->param2);
END_OPCODE
@@ -742,7 +799,7 @@ END_OPCODE
//////////////////////////////////////////////////////////////////////////
// Opcode 0x23
IMPLEMENT_OPCODE(_unk23)
- Actor *actor = getScene()->getActor(cmd->param3 ? cmd->param3 : _currentQueueEntry.actorIndex);
+ Actor *actor = getScene()->getActor(cmd->param3 ? cmd->param3 : _currentQueueEntry->actorIndex);
actor->process_41BCC0(cmd->param1, cmd->param2);
END_OPCODE
@@ -750,7 +807,7 @@ END_OPCODE
//////////////////////////////////////////////////////////////////////////
// Opcode 0x24
IMPLEMENT_OPCODE(_unk24)
- Actor *actor = getScene()->getActor(cmd->param4 ? cmd->param4 : _currentQueueEntry.actorIndex);
+ Actor *actor = getScene()->getActor(cmd->param4 ? cmd->param4 : _currentQueueEntry->actorIndex);
actor->process_41BDB0(cmd->param1, (bool)cmd->param3);
END_OPCODE
@@ -764,14 +821,14 @@ IMPLEMENT_OPCODE(RunEncounter)
if (cmd->param6) {
if (encounter->isRunning())
- _lineIncrement = 1;
+ _processNextEntry = 1;
else
cmd->param6 = 0;
} else {
encounter->run(cmd->param1, (ObjectId)cmd->param2, (ObjectId)cmd->param3, cmd->param4);
cmd->param6 = 2;
- _lineIncrement = 1;
+ _processNextEntry = 1;
}
END_OPCODE
@@ -807,7 +864,7 @@ IMPLEMENT_OPCODE(JumpIfActorField638)
Actor *actor = getScene()->getActor(cmd->param1);
if (actor->getField638())
- _currentQueueEntry.currentLine = cmd->param3;
+ _currentQueueEntry->currentLine = cmd->param3;
END_OPCODE
//////////////////////////////////////////////////////////////////////////
@@ -836,7 +893,7 @@ END_OPCODE
// Opcode 0x2C
IMPLEMENT_OPCODE(_unk2C_ActorSub)
Actor *player = getScene()->getActor();
- Actor *actor = getScene()->getActor(_currentQueueEntry.actorIndex);
+ Actor *actor = getScene()->getActor(_currentQueueEntry->actorIndex);
Common::Point playerPoint((int16)(player->getPoint1()->x + player->getPoint2()->x), (int16)(player->getPoint1()->y + player->getPoint2()->y));
ActorDirection direction = (cmd->param2 == 8) ? player->getDirection() : (ActorDirection)cmd->param2;
@@ -848,7 +905,7 @@ IMPLEMENT_OPCODE(_unk2C_ActorSub)
if (cmd->param3 == 2) {
switch (actor->getStatus()) {
default:
- _lineIncrement = 1;
+ _processNextEntry = 1;
return;
case kActorStatus7:
@@ -891,7 +948,7 @@ IMPLEMENT_OPCODE(_unk2C_ActorSub)
actor->updateStatus(actor->getStatus() <= kActorStatus11 ? kActorStatus3 : kActorStatus19);
cmd->param3 = 2;
- _lineIncrement = 1;
+ _processNextEntry = 1;
}
END_OPCODE
@@ -899,7 +956,7 @@ END_OPCODE
// Opcode 0x2D
IMPLEMENT_OPCODE(PlayMovie)
if (getSharedData()->matteBarHeight < 170) {
- _lineIncrement = 1;
+ _processNextEntry = 1;
if (!getSharedData()->matteBarHeight) {
getCursor()->hide();
@@ -926,7 +983,7 @@ IMPLEMENT_OPCODE(PlayMovie)
}
getSharedData()->matteBarHeight = 0;
- _lineIncrement = 0;
+ _processNextEntry = 0;
if (!getSharedData()->mattePlaySound && _currentScript->commands[0].numLines != 0) {
bool found = true;
@@ -1003,7 +1060,7 @@ IMPLEMENT_OPCODE(_unk34_Status)
cmd->param1 = 0;
} else {
cmd->param1++;
- _lineIncrement = 1;
+ _processNextEntry = 1;
}
END_OPCODE
@@ -1028,7 +1085,7 @@ END_OPCODE
//////////////////////////////////////////////////////////////////////////
// Opcode 0x36
IMPLEMENT_OPCODE(Jump)
- _currentQueueEntry.currentLine = cmd->param1 - 1;
+ _currentQueueEntry->currentLine = cmd->param1 - 1;
END_OPCODE
//////////////////////////////////////////////////////////////////////////
@@ -1039,7 +1096,7 @@ IMPLEMENT_OPCODE(RunBlowUpPuzzle)
_vm->switchEventHandler(_vm->getPuzzle((uint32)cmd->param1));
- _currentQueueEntry.currentLine++;
+ _currentQueueEntry->currentLine++;
_exit = true;
END_OPCODE
@@ -1075,7 +1132,7 @@ IMPLEMENT_OPCODE(_unk3B_PALETTE_MOD)
cmd->param1 = 0;
cmd->param2 = 0;
- _currentQueueEntry.currentLine++;
+ _currentQueueEntry->currentLine++;
getScreen()->clearGraphicsInQueue();
@@ -1085,7 +1142,7 @@ IMPLEMENT_OPCODE(_unk3B_PALETTE_MOD)
getScreen()->updatePalette(cmd->param1);
- _lineIncrement = 1;
+ _processNextEntry = 1;
++cmd->param1;
END_OPCODE
@@ -1097,7 +1154,7 @@ IMPLEMENT_OPCODE(IncrementParam2)
cmd->param2 = 0;
} else {
++cmd->param2;
- _lineIncrement = 1;
+ _processNextEntry = 1;
}
}
END_OPCODE
@@ -1111,10 +1168,8 @@ IMPLEMENT_OPCODE(WaitUntilFramePlayed)
if (frameNum == -1)
frameNum = object->getFrameCount() - 1;
- if ((int32)object->getFrameIndex() != frameNum) {
- _lineIncrement = 1;
- _waitCycle = true;
- }
+ if ((int32)object->getFrameIndex() != frameNum)
+ _processNextEntry = true;
END_OPCODE
@@ -1125,13 +1180,13 @@ IMPLEMENT_OPCODE(UpdateWideScreen)
if (barSize >= 22) {
cmd->param1 = 0;
- _lineIncrement = 0;
+ _processNextEntry = 0;
getSharedData()->matteBarHeight = 0;
} else {
getScreen()->drawWideScreenBars((int16)(4 * barSize));
- _lineIncrement = 1;
+ _processNextEntry = 1;
++cmd->param1;
}
END_OPCODE
@@ -1142,8 +1197,8 @@ END_OPCODE
IMPLEMENT_OPCODE(JumpIfActor)
ActorIndex index = (cmd->param1 == kActorInvalid) ? getScene()->getPlayerIndex() : cmd->param1;
- if (_currentQueueEntry.actorIndex != index)
- _currentQueueEntry.currentLine = cmd->param2 - 1;
+ if (_currentQueueEntry->actorIndex != index)
+ _currentQueueEntry->currentLine = cmd->param2 - 1;
END_OPCODE
//////////////////////////////////////////////////////////////////////////
@@ -1162,7 +1217,7 @@ IMPLEMENT_OPCODE(PlaySpeechScene)
getSharedData()->setFlag(kFlag1, true);
getSharedData()->setFlag(kFlag2, true);
}
- _lineIncrement = 1;
+ _processNextEntry = 1;
}
if (cmd->param3 && !cmd->param6)
@@ -1172,7 +1227,7 @@ IMPLEMENT_OPCODE(PlaySpeechScene)
}
if (_vm->sound()->isPlaying((ResourceId)cmd->param5)) {
- _lineIncrement = 1;
+ _processNextEntry = 1;
return;
}
@@ -1214,7 +1269,7 @@ IMPLEMENT_OPCODE(PlaySpeech)
getSharedData()->setFlag(kFlag1, true);
getSharedData()->setFlag(kFlag2, true);
}
- _lineIncrement = 1;
+ _processNextEntry = 1;
}
if (cmd->param3 && !cmd->param6)
@@ -1224,7 +1279,7 @@ IMPLEMENT_OPCODE(PlaySpeech)
}
if (_vm->sound()->isPlaying((ResourceId)cmd->param5)) {
- _lineIncrement = 1;
+ _processNextEntry = 1;
return;
}
@@ -1258,7 +1313,7 @@ IMPLEMENT_OPCODE(PlaySpeechScene2)
if (cmd->param5 == 2) {
if (getSound()->isPlaying((ResourceId)cmd->param6)) {
- _lineIncrement = 1;
+ _processNextEntry = 1;
return;
}
@@ -1294,7 +1349,7 @@ IMPLEMENT_OPCODE(PlaySpeechScene2)
getSharedData()->setFlag(kFlag2, false);
}
- _lineIncrement = 1;
+ _processNextEntry = 1;
}
if (cmd->param4 && !cmd->param7)
@@ -1314,7 +1369,7 @@ IMPLEMENT_OPCODE(MoveScenePositionFromActor)
cmd->param2);
} else if (cmd->param6) {
if (getWorld()->motionStatus == 2) {
- _lineIncrement = 1;
+ _processNextEntry = 1;
} else {
cmd->param6 = 0;
getWorld()->coordinates[0] = -1;
@@ -1328,9 +1383,9 @@ IMPLEMENT_OPCODE(MoveScenePositionFromActor)
cmd->param2,
true,
&cmd->param6))
- _lineIncrement = 0;
+ _processNextEntry = 0;
else
- _lineIncrement = 1;
+ _processNextEntry = 1;
}
END_OPCODE
@@ -1351,7 +1406,7 @@ END_OPCODE
IMPLEMENT_OPCODE(_unk46)
if (cmd->param6) {
if (getSound()->isPlaying(getSpeech()->getSoundResourceId())) {
- _lineIncrement = 1;
+ _processNextEntry = 1;
} else {
cmd->param6 = 0;
if (cmd->param5) {
@@ -1374,7 +1429,7 @@ IMPLEMENT_OPCODE(_unk46)
if (cmd->param2) {
getScene()->getActor(cmd->param5)->updateStatus(kActorStatus8);
cmd->param6 = 1;
- _lineIncrement = 1;
+ _processNextEntry = 1;
} else {
if (cmd->param4 != cmd->param3) {
if (cmd->param4)
@@ -1385,7 +1440,7 @@ IMPLEMENT_OPCODE(_unk46)
}
cmd->param6 = 1;
- _lineIncrement = 1;
+ _processNextEntry = 1;
}
}
END_OPCODE
@@ -1404,10 +1459,10 @@ IMPLEMENT_OPCODE(_unk48_MATTE_01)
if (getSharedData()->matteBarHeight >= 170) {
getSharedData()->matteBarHeight = 0;
- _lineIncrement = 0;
+ _processNextEntry = 0;
getCursor()->show();
} else {
- _lineIncrement = 1;
+ _processNextEntry = 1;
if (!getSharedData()->matteBarHeight) {
getCursor()->hide();
@@ -1425,10 +1480,10 @@ IMPLEMENT_OPCODE(_unk49_MATTE_90)
if (getSharedData()->matteBarHeight >= 170) {
getSharedData()->matteBarHeight = 0;
- _lineIncrement = 0;
+ _processNextEntry = 0;
getCursor()->show();
} else {
- _lineIncrement = 1;
+ _processNextEntry = 1;
if (!getSharedData()->matteBarHeight) {
getCursor()->hide();
@@ -1442,10 +1497,10 @@ END_OPCODE
IMPLEMENT_OPCODE(JumpIfSoundPlaying)
if (cmd->param3 == 1) {
if (_vm->sound()->isPlaying((ResourceId)cmd->param1)) {
- _currentQueueEntry.currentLine = cmd->param2;
+ _currentQueueEntry->currentLine = cmd->param2;
}
} else if (!_vm->sound()->isPlaying((ResourceId)cmd->param1)) {
- _currentQueueEntry.currentLine = cmd->param2;
+ _currentQueueEntry->currentLine = cmd->param2;
}
END_OPCODE
@@ -1597,20 +1652,20 @@ IMPLEMENT_OPCODE(_unk56)
if (actor->getStatus() == kActorStatus2 || actor->getStatus() == kActorStatus13) {
if (cmd->param2 == 2)
- _lineIncrement = 1;
+ _processNextEntry = 1;
return;
}
if (cmd->param2 == 2) {
cmd->param2 = 1;
- _lineIncrement = 0;
+ _processNextEntry = 0;
if ((actor->getPoint1()->x + actor->getPoint2()->x == cmd->param6) && (actor->getPoint1()->y + actor->getPoint2()->y == cmd->param7)) {
getScene()->getActor()->faceTarget((ObjectId)cmd->param1, kDirectionFromActor);
actor->updateFromDirection((ActorDirection)((actor->getDirection() + 4) & 7));
} else {
- _currentQueueEntry.currentLine = cmd->param3;
+ _currentQueueEntry->currentLine = cmd->param3;
}
} else {
int32 x = 0;
@@ -1623,13 +1678,13 @@ IMPLEMENT_OPCODE(_unk56)
if (cmd->param2 == 1) {
cmd->param2 = 2;
- _lineIncrement = 1;
+ _processNextEntry = 1;
}
} else {
if (cmd->param4)
getSpeech()->playIndexed(1);
- _currentQueueEntry.currentLine = cmd->param3;
+ _currentQueueEntry->currentLine = cmd->param3;
}
}
END_OPCODE
@@ -1667,7 +1722,7 @@ IMPLEMENT_OPCODE(_unk59)
}
if (cmd->param3 && (object->flags & kObjectFlag10E38))
- _lineIncrement = 1;
+ _processNextEntry = 1;
END_OPCODE
//////////////////////////////////////////////////////////////////////////
@@ -1722,10 +1777,10 @@ IMPLEMENT_OPCODE(SetObjectLastFrameIdx)
Object *object = getWorld()->getObjectById((ObjectId)cmd->param1);
if (object->getFrameIndex() == object->getFrameCount() - 1) {
- _lineIncrement = 0;
+ _processNextEntry = 0;
object->flags &= ~kObjectFlag10E38;
} else {
- _lineIncrement = 1;
+ _processNextEntry = 1;
}
END_OPCODE
@@ -1745,15 +1800,15 @@ END_OPCODE
IMPLEMENT_OPCODE(_unk61)
if (cmd->param2) {
if (getWorld()->nextPlayer == kActorInvalid) {
- _lineIncrement = 0;
+ _processNextEntry = 0;
cmd->param2 = 0;
} else {
- _lineIncrement = 1;
+ _processNextEntry = 1;
}
} else {
Actor::updatePlayerChapter9(_vm, cmd->param1);
cmd->param2 = 1;
- _lineIncrement = 1;
+ _processNextEntry = 1;
}
END_OPCODE
@@ -1772,7 +1827,7 @@ IMPLEMENT_OPCODE(_unk63)
}
if (_vm->sound()->isPlaying(getSpeech()->getSoundResourceId())) {
- _lineIncrement = 1;
+ _processNextEntry = 1;
return;
} else if (!cmd->param1) {
cmd->param1 = 1;
@@ -1955,7 +2010,7 @@ void ScriptManager::setNextLine(int32 line) {
int32 opcode = _currentScript->commands[line].opcode;
if (opcode == 0x10 || opcode == 0) { // Return
- _currentQueueEntry.currentLine = line;
+ _currentQueueEntry->currentLine = line;
} else {
_done = true;
}
diff --git a/engines/asylum/resources/script.h b/engines/asylum/resources/script.h
index 64e63479af..4e7622273c 100644
--- a/engines/asylum/resources/script.h
+++ b/engines/asylum/resources/script.h
@@ -172,7 +172,51 @@ private:
kObjectEnableType2
};
- typedef struct ScriptEntry {
+ //////////////////////////////////////////////////////////////////////////
+ // Script Queue
+ //////////////////////////////////////////////////////////////////////////
+ struct ScriptQueueEntry {
+ int32 scriptIndex;
+ int32 currentLine;
+ ActorIndex actorIndex;
+ int32 field_C;
+ int32 field_10;
+
+ ScriptQueueEntry() {
+ reset();
+ }
+
+ void reset() {
+ scriptIndex = -1;
+ currentLine = 0;
+ actorIndex = 0;
+ field_C = 0;
+ field_10 = 0;
+ }
+ };
+
+ struct ScriptQueue {
+ ScriptQueueEntry entries[10];
+ uint32 currentEntry;
+ uint32 field_CC;
+
+ ScriptQueue() {
+ reset();
+ }
+
+ void reset() {
+ for (uint32 i = 0; i < ARRAYSIZE(entries); i++)
+ entries[i].reset();
+
+ currentEntry = 0;
+ field_CC = 0;
+ }
+ };
+
+ //////////////////////////////////////////////////////////////////////////
+ // Scripts
+ //////////////////////////////////////////////////////////////////////////
+ struct ScriptEntry {
int32 numLines; // Only set on the first line of each script
int32 opcode;
int32 param1;
@@ -198,9 +242,9 @@ private:
param8 = 0;
param9 = 0;
}
- } ScriptEntry;
+ };
- typedef struct Script {
+ struct Script {
ScriptEntry commands[MAX_ACTION_COMMANDS];
int32 field_1BAC;
int32 field_1BB0;
@@ -211,25 +255,11 @@ private:
field_1BB0 = 0;
counter = 0;
}
- } Script;
-
- typedef struct ScriptQueueEntry {
- int32 scriptIndex;
- int32 currentLine;
- ActorIndex actorIndex;
- int32 field_C;
- int32 field_10;
-
- ScriptQueueEntry() {
- scriptIndex = 0;
- currentLine = 0;
- actorIndex = 0;
- field_C = 0;
- field_10 = 0;
- }
- } ScriptQueueEntry;
+ };
+ //////////////////////////////////////////////////////////////////////////
// Opcodes
+ //////////////////////////////////////////////////////////////////////////
typedef Common::Functor1<ScriptEntry *, void> OpcodeFunctor;
struct Opcode {
@@ -250,18 +280,19 @@ private:
AsylumEngine *_vm;
// Script queue and data
+ ScriptQueue _queue;
Common::Array<Opcode *> _opcodes;
- Common::Stack<ScriptQueueEntry> _queue;
Common::Array<Script> _scripts;
bool _skipProcessing;
- int32 _currentLoops;
- Script *_currentScript;
- ScriptQueueEntry _currentQueueEntry;
bool _done;
bool _exit;
- int32 _lineIncrement;
- bool _waitCycle;
+ bool _processNextEntry;
+
+ Script *_currentScript;
+ ScriptQueueEntry *_currentQueueEntry;
+
+ void updateQueue(uint32 entryIndex);
// Opcode helper functions
void enableObject(ScriptEntry *cmd, ObjectEnableType type);
Commit: 35db68fb7c00d9efce1005d6c2211d4cb694561d
https://github.com/scummvm/scummvm/commit/35db68fb7c00d9efce1005d6c2211d4cb694561d
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:50+02:00
Commit Message:
ASYLUM: Implement Actor::updatePlayerChapter9()
Also update shared data in Actor::enableActorsChapter2()
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@756 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/resources/actor.cpp
engines/asylum/resources/actor.h
diff --git a/engines/asylum/resources/actor.cpp b/engines/asylum/resources/actor.cpp
index 0ef7c619af..e6d4518c3b 100644
--- a/engines/asylum/resources/actor.cpp
+++ b/engines/asylum/resources/actor.cpp
@@ -1222,11 +1222,78 @@ void Actor::enableActorsChapter2(AsylumEngine *engine) {
engine->scene()->getActor(21)->enable();
engine->scene()->getActor(21)->processStatus(2541, 40, false);
- error("[Actor::enableActorsChapter2] Missing update shared data part!");
+ for (uint32 i = 0; i < 9; i++) {
+ engine->data()->setData(i, 160);
+ engine->data()->setData(i + 18, 0);
+ engine->data()->setData(i + 44, 0);
+ }
}
-void Actor::updatePlayerChapter9(AsylumEngine *engine, int type) {
- error("[Actor::updatePlayerChapter9] Not implemented!");
+void Actor::updatePlayerChapter9(AsylumEngine *engine, int nextPlayer) {
+ WorldStats *world = engine->scene()->worldstats();
+ if (world->chapter != kChapter9)
+ return;
+
+ Actor *player = engine->scene()->getActor();
+ world->nextPlayer = nextPlayer;
+
+ switch (engine->scene()->getPlayerIndex()) {
+ default:
+ break;
+
+ case 1:
+ if (nextPlayer == 2) {
+ player->setResourceId(world->graphicResourceIds[7]);
+
+ uint32 frameCount = GraphicResource::getFrameCount(engine, player->getResourceId());
+ player->setFrameCount(frameCount);
+ player->setFrameIndex(frameCount - 1);
+
+ } else if (nextPlayer == 3) {
+ player->setResourceId(world->graphicResourceIds[8]);
+
+ uint32 frameCount = GraphicResource::getFrameCount(engine, player->getResourceId());
+ player->setFrameCount(frameCount);
+ player->setFrameIndex(frameCount - 1);
+ }
+ break;
+
+ case 2:
+ if (nextPlayer == 1) {
+ player->setResourceId(world->graphicResourceIds[4]);
+
+ uint32 frameCount = GraphicResource::getFrameCount(engine, player->getResourceId());
+ player->setFrameCount(frameCount);
+ player->setFrameIndex(0);
+
+ } else if (nextPlayer == 3) {
+ player->setResourceId(world->graphicResourceIds[3]);
+
+ uint32 frameCount = GraphicResource::getFrameCount(engine, player->getResourceId());
+ player->setFrameCount(frameCount);
+ player->setFrameIndex(0);
+ }
+ break;
+
+ case 3:
+ if (nextPlayer == 1) {
+ player->setResourceId(world->graphicResourceIds[5]);
+
+ uint32 frameCount = GraphicResource::getFrameCount(engine, player->getResourceId());
+ player->setFrameCount(frameCount);
+ player->setFrameIndex(0);
+
+ } else if (nextPlayer == 2) {
+ player->setResourceId(world->graphicResourceIds[6]);
+
+ uint32 frameCount = GraphicResource::getFrameCount(engine, player->getResourceId());
+ player->setFrameCount(frameCount);
+ player->setFrameIndex(frameCount - 1);
+ }
+ break;
+ }
+
+ player->updateStatus(kActorStatus21);
}
//////////////////////////////////////////////////////////////////////////
diff --git a/engines/asylum/resources/actor.h b/engines/asylum/resources/actor.h
index 68172e66d5..4d2f514938 100644
--- a/engines/asylum/resources/actor.h
+++ b/engines/asylum/resources/actor.h
@@ -281,7 +281,14 @@ public:
// Static update methods
//////////////////////////////////////////////////////////////////////////
static void enableActorsChapter2(AsylumEngine *engine);
- static void updatePlayerChapter9(AsylumEngine *engine, int type);
+
+ /**
+ * Updates the player appearance in chapter 9.
+ *
+ * @param [in,out] engine If non-null, the engine.
+ * @param nextPlayer The next player index
+ */
+ static void updatePlayerChapter9(AsylumEngine *engine, int nextPlayer);
/**
* Gets a direction using the angle between the two points.
Commit: 925c146a61fd43c91f9f8c295e5366712fa749bc
https://github.com/scummvm/scummvm/commit/925c146a61fd43c91f9f8c295e5366712fa749bc
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:50+02:00
Commit Message:
ASYLUM: Implement PuzzlePipes::updateCursor()
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@757 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/puzzles/pipes.cpp
diff --git a/engines/asylum/puzzles/pipes.cpp b/engines/asylum/puzzles/pipes.cpp
index 2f3d1f0ac7..4dbe597d8e 100644
--- a/engines/asylum/puzzles/pipes.cpp
+++ b/engines/asylum/puzzles/pipes.cpp
@@ -101,7 +101,16 @@ void PuzzlePipes::setup(bool val) {
}
void PuzzlePipes::updateCursor() {
- error("[PuzzlePipes::updateCursor] Not implemented!");
+ int32 index = findRect();
+
+ if (_rectIndex == index)
+ return;
+
+ _rectIndex = index;
+ if (index == -1)
+ getCursor()->set(getWorld()->graphicResourceIds[16], 0, kCursorAnimationNone);
+ else
+ getCursor()->set(getWorld()->graphicResourceIds[16]);
}
int32 PuzzlePipes::findRect() {
Commit: 2b8aea38358b2a9d9de3e63b2639279542ab3caf
https://github.com/scummvm/scummvm/commit/2b8aea38358b2a9d9de3e63b2639279542ab3caf
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:50+02:00
Commit Message:
ASYLUM: Add stubs for Hive puzzles
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@758 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/puzzles/hivecontrol.cpp
engines/asylum/puzzles/hivecontrol.h
engines/asylum/puzzles/hivemachine.cpp
engines/asylum/puzzles/hivemachine.h
diff --git a/engines/asylum/puzzles/hivecontrol.cpp b/engines/asylum/puzzles/hivecontrol.cpp
index d8c6d0ba66..bb25ad5383 100644
--- a/engines/asylum/puzzles/hivecontrol.cpp
+++ b/engines/asylum/puzzles/hivecontrol.cpp
@@ -48,4 +48,27 @@ bool PuzzleHiveControl::mouseLeftDown(const AsylumEvent &evt) {
error("[PuzzleHiveControl::mouseLeftDown] Not implemented!");
}
+bool PuzzleHiveControl::mouseRightDown(const AsylumEvent &evt) {
+ error("[PuzzleHiveControl::mouseLeftDown] Not implemented!");
+}
+
+//////////////////////////////////////////////////////////////////////////
+// Helpers
+//////////////////////////////////////////////////////////////////////////
+void PuzzleHiveControl::updateCursor() {
+ error("[PuzzleHiveControl::updateCursor] Not implemented!");
+}
+
+int32 PuzzleHiveControl::findRect() {
+ error("[PuzzleHiveControl::findRect] Not implemented!");
+}
+
+void PuzzleHiveControl::updateScreen() {
+ error("[PuzzleHiveControl::updateScreen] Not implemented!");
+}
+
+void PuzzleHiveControl::playSound() {
+ error("[PuzzleHiveControl::playSound] Not implemented!");
+}
+
} // End of namespace Asylum
diff --git a/engines/asylum/puzzles/hivecontrol.h b/engines/asylum/puzzles/hivecontrol.h
index 13d02f526d..01753394ab 100644
--- a/engines/asylum/puzzles/hivecontrol.h
+++ b/engines/asylum/puzzles/hivecontrol.h
@@ -44,6 +44,15 @@ private:
bool init(const AsylumEvent &evt);
bool update(const AsylumEvent &evt);
bool mouseLeftDown(const AsylumEvent &evt);
+ bool mouseRightDown(const AsylumEvent &evt);
+
+ //////////////////////////////////////////////////////////////////////////
+ // Helpers
+ //////////////////////////////////////////////////////////////////////////
+ void updateCursor();
+ int32 findRect();
+ void updateScreen();
+ void playSound();
};
} // End of namespace Asylum
diff --git a/engines/asylum/puzzles/hivemachine.cpp b/engines/asylum/puzzles/hivemachine.cpp
index 56d18ebbff..6ca3b2e78b 100644
--- a/engines/asylum/puzzles/hivemachine.cpp
+++ b/engines/asylum/puzzles/hivemachine.cpp
@@ -48,4 +48,27 @@ bool PuzzleHiveMachine::mouseLeftDown(const AsylumEvent &evt) {
error("[PuzzleHiveMachine::mouseLeftDown] Not implemented!");
}
+bool PuzzleHiveMachine::mouseRightDown(const AsylumEvent &evt) {
+ error("[PuzzleHiveMachine::mouseLeftDown] Not implemented!");
+}
+
+//////////////////////////////////////////////////////////////////////////
+// Helpers
+//////////////////////////////////////////////////////////////////////////
+void PuzzleHiveMachine::updateCursor() {
+ error("[PuzzleHiveMachine::updateCursor] Not implemented!");
+}
+
+int32 PuzzleHiveMachine::findRect() {
+ error("[PuzzleHiveMachine::findRect] Not implemented!");
+}
+
+void PuzzleHiveMachine::updateScreen() {
+ error("[PuzzleHiveMachine::updateScreen] Not implemented!");
+}
+
+void PuzzleHiveMachine::playSound() {
+ error("[PuzzleHiveMachine::playSound] Not implemented!");
+}
+
} // End of namespace Asylum
diff --git a/engines/asylum/puzzles/hivemachine.h b/engines/asylum/puzzles/hivemachine.h
index f733f71187..3df8d7f38f 100644
--- a/engines/asylum/puzzles/hivemachine.h
+++ b/engines/asylum/puzzles/hivemachine.h
@@ -44,6 +44,15 @@ private:
bool init(const AsylumEvent &evt);
bool update(const AsylumEvent &evt);
bool mouseLeftDown(const AsylumEvent &evt);
+ bool mouseRightDown(const AsylumEvent &evt);
+
+ //////////////////////////////////////////////////////////////////////////
+ // Helpers
+ //////////////////////////////////////////////////////////////////////////
+ void updateCursor();
+ int32 findRect();
+ void updateScreen();
+ void playSound();
};
} // End of namespace Asylum
Commit: 4cfedb290dc4c4056c4970a939231a82ae23e689
https://github.com/scummvm/scummvm/commit/4cfedb290dc4c4056c4970a939231a82ae23e689
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:50+02:00
Commit Message:
ASYLUM: Implement some of the Hive puzzles methods
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@759 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/puzzles/hivecontrol.cpp
engines/asylum/puzzles/hivecontrol.h
engines/asylum/puzzles/hivemachine.cpp
engines/asylum/puzzles/hivemachine.h
diff --git a/engines/asylum/puzzles/hivecontrol.cpp b/engines/asylum/puzzles/hivecontrol.cpp
index bb25ad5383..2ca63b6993 100644
--- a/engines/asylum/puzzles/hivecontrol.cpp
+++ b/engines/asylum/puzzles/hivecontrol.cpp
@@ -25,9 +25,25 @@
#include "asylum/puzzles/hivecontrol.h"
+#include "asylum/resources/worldstats.h"
+
+#include "asylum/system/cursor.h"
+#include "asylum/system/graphics.h"
+#include "asylum/system/screen.h"
+
+#include "asylum/views/scene.h"
+
+#include "asylum/asylum.h"
+
namespace Asylum {
PuzzleHiveControl::PuzzleHiveControl(AsylumEngine *engine) : Puzzle(engine) {
+ _rectIndex = 0;
+ _soundVolume = 0;
+ _counter = 0;
+
+ _data_457260 = 0;
+ _data_457264 = 0;
}
PuzzleHiveControl::~PuzzleHiveControl() {
@@ -38,10 +54,41 @@ PuzzleHiveControl::~PuzzleHiveControl() {
//////////////////////////////////////////////////////////////////////////
bool PuzzleHiveControl::init(const AsylumEvent &evt) {
error("[PuzzleHiveControl::init] Not implemented!");
+
+ _rectIndex = -2;
+ updateCursor();
+
+ getScreen()->setPalette(getWorld()->graphicResourceIds[29]);
+ getScreen()->setGammaLevel(getWorld()->graphicResourceIds[29], 0);
+
+ getCursor()->show();
+
+ getScreen()->setupTransTables(1, getWorld()->graphicResourceIds[70]);
+ getScreen()->selectTransTable(0);
+
+ getSound()->playSound(getWorld()->graphicResourceIds[73], true, _soundVolume);
+ getSound()->playSound(getWorld()->graphicResourceIds[74], true, Config.ambientVolume);
+
+ return true;
}
bool PuzzleHiveControl::update(const AsylumEvent &evt) {
- error("[PuzzleHiveControl::update] Not implemented!");
+ updateCursor();
+ updateScreen();
+
+ if (!_data_457260 && !_data_457264)
+ playSound();
+
+ if (_counter) {
+ if (_counter < 30 || getSound()->isPlaying(getWorld()->graphicResourceIds[83])) {
+ ++ _counter;
+ } else {
+ mouseRightDown(evt);
+ getCursor()->show();
+ }
+ }
+
+ return true;
}
bool PuzzleHiveControl::mouseLeftDown(const AsylumEvent &evt) {
@@ -49,14 +96,32 @@ bool PuzzleHiveControl::mouseLeftDown(const AsylumEvent &evt) {
}
bool PuzzleHiveControl::mouseRightDown(const AsylumEvent &evt) {
- error("[PuzzleHiveControl::mouseLeftDown] Not implemented!");
+ getSound()->stop(getWorld()->graphicResourceIds[73]);
+ getSound()->stop(getWorld()->graphicResourceIds[74]);
+
+ getScreen()->clear();
+ getScreen()->setupTransTables(3, getWorld()->cellShadeMask1, getWorld()->cellShadeMask2, getWorld()->cellShadeMask3);
+ getScreen()->selectTransTable(1);
+
+ _vm->switchEventHandler(getScene());
+
+ return true;
}
//////////////////////////////////////////////////////////////////////////
// Helpers
//////////////////////////////////////////////////////////////////////////
void PuzzleHiveControl::updateCursor() {
- error("[PuzzleHiveControl::updateCursor] Not implemented!");
+ int32 index = findRect();
+
+ if (_rectIndex == index)
+ return;
+
+ _rectIndex = index;
+ if (index == -1)
+ getCursor()->set(getWorld()->graphicResourceIds[30], -1, kCursorAnimationNone);
+ else
+ getCursor()->set(getWorld()->graphicResourceIds[30], -1);
}
int32 PuzzleHiveControl::findRect() {
diff --git a/engines/asylum/puzzles/hivecontrol.h b/engines/asylum/puzzles/hivecontrol.h
index 01753394ab..ec8bb297ad 100644
--- a/engines/asylum/puzzles/hivecontrol.h
+++ b/engines/asylum/puzzles/hivecontrol.h
@@ -38,6 +38,13 @@ public:
~PuzzleHiveControl();
private:
+ int32 _soundVolume;
+ int32 _rectIndex;
+ uint32 _counter;
+
+ int32 _data_457260;
+ int32 _data_457264;
+
//////////////////////////////////////////////////////////////////////////
// Event Handling
//////////////////////////////////////////////////////////////////////////
diff --git a/engines/asylum/puzzles/hivemachine.cpp b/engines/asylum/puzzles/hivemachine.cpp
index 6ca3b2e78b..449c8de92f 100644
--- a/engines/asylum/puzzles/hivemachine.cpp
+++ b/engines/asylum/puzzles/hivemachine.cpp
@@ -25,9 +25,20 @@
#include "asylum/puzzles/hivemachine.h"
+#include "asylum/resources/worldstats.h"
+
+#include "asylum/system/cursor.h"
+#include "asylum/system/graphics.h"
+#include "asylum/system/screen.h"
+
+#include "asylum/views/scene.h"
+
+#include "asylum/asylum.h"
+
namespace Asylum {
PuzzleHiveMachine::PuzzleHiveMachine(AsylumEngine *engine) : Puzzle(engine) {
+ _rectIndex = 0;
}
PuzzleHiveMachine::~PuzzleHiveMachine() {
@@ -38,6 +49,13 @@ PuzzleHiveMachine::~PuzzleHiveMachine() {
//////////////////////////////////////////////////////////////////////////
bool PuzzleHiveMachine::init(const AsylumEvent &evt) {
error("[PuzzleHiveMachine::init] Not implemented!");
+
+ getScreen()->setPalette(getWorld()->graphicResourceIds[9]);
+ getScreen()->setGammaLevel(getWorld()->graphicResourceIds[9], 0);
+ _rectIndex = -2;
+ updateCursor();
+
+ return true;
}
bool PuzzleHiveMachine::update(const AsylumEvent &evt) {
@@ -49,14 +67,26 @@ bool PuzzleHiveMachine::mouseLeftDown(const AsylumEvent &evt) {
}
bool PuzzleHiveMachine::mouseRightDown(const AsylumEvent &evt) {
- error("[PuzzleHiveMachine::mouseLeftDown] Not implemented!");
+ getScreen()->clear();
+ _vm->switchEventHandler(getScene());
+
+ return true;
}
//////////////////////////////////////////////////////////////////////////
// Helpers
//////////////////////////////////////////////////////////////////////////
void PuzzleHiveMachine::updateCursor() {
- error("[PuzzleHiveMachine::updateCursor] Not implemented!");
+ int32 index = findRect();
+
+ if (_rectIndex == index)
+ return;
+
+ _rectIndex = index;
+ if (index == -1)
+ getCursor()->set(getWorld()->graphicResourceIds[12], -1, kCursorAnimationNone);
+ else
+ getCursor()->set(getWorld()->graphicResourceIds[12], -1);
}
int32 PuzzleHiveMachine::findRect() {
diff --git a/engines/asylum/puzzles/hivemachine.h b/engines/asylum/puzzles/hivemachine.h
index 3df8d7f38f..d42e3a5d7c 100644
--- a/engines/asylum/puzzles/hivemachine.h
+++ b/engines/asylum/puzzles/hivemachine.h
@@ -38,6 +38,8 @@ public:
~PuzzleHiveMachine();
private:
+ int32 _rectIndex;
+
//////////////////////////////////////////////////////////////////////////
// Event Handling
//////////////////////////////////////////////////////////////////////////
Commit: f5994d02a86b461cd87c5393912a80bbc138815c
https://github.com/scummvm/scummvm/commit/f5994d02a86b461cd87c5393912a80bbc138815c
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:50+02:00
Commit Message:
ASYLUM: Add stubs for Board puzzles
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@760 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/puzzles/boardkeyhidesto.cpp
engines/asylum/puzzles/boardkeyhidesto.h
engines/asylum/puzzles/boardsalvation.cpp
engines/asylum/puzzles/boardsalvation.h
engines/asylum/puzzles/boardyouth.cpp
engines/asylum/puzzles/boardyouth.h
diff --git a/engines/asylum/puzzles/boardkeyhidesto.cpp b/engines/asylum/puzzles/boardkeyhidesto.cpp
index 3952938159..c8ffa68ab8 100644
--- a/engines/asylum/puzzles/boardkeyhidesto.cpp
+++ b/engines/asylum/puzzles/boardkeyhidesto.cpp
@@ -33,6 +33,10 @@ PuzzleBoardKeyHidesTo::PuzzleBoardKeyHidesTo(AsylumEngine *engine) : Puzzle(engi
PuzzleBoardKeyHidesTo::~PuzzleBoardKeyHidesTo() {
}
+void PuzzleBoardKeyHidesTo::reset() {
+ memset(&_charUsed, 0, sizeof(_charUsed));
+}
+
//////////////////////////////////////////////////////////////////////////
// Event Handling
//////////////////////////////////////////////////////////////////////////
@@ -40,6 +44,10 @@ bool PuzzleBoardKeyHidesTo::init(const AsylumEvent &evt) {
error("[PuzzleBoardKeyHidesTo::init] Not implemented!");
}
+bool PuzzleBoardKeyHidesTo::activate(const AsylumEvent &evt) {
+ error("[PuzzleBoardKeyHidesTo::activate] Not implemented!");
+}
+
bool PuzzleBoardKeyHidesTo::update(const AsylumEvent &evt) {
error("[PuzzleBoardKeyHidesTo::update] Not implemented!");
}
@@ -48,4 +56,28 @@ bool PuzzleBoardKeyHidesTo::mouseLeftDown(const AsylumEvent &evt) {
error("[PuzzleBoardKeyHidesTo::mouseLeftDown] Not implemented!");
}
+//////////////////////////////////////////////////////////////////////////
+// Helpers
+//////////////////////////////////////////////////////////////////////////
+void PuzzleBoardKeyHidesTo::updateCursor() {
+ error("[PuzzleBoardKeyHidesTo::updateCursor] Not implemented!");
+}
+
+void PuzzleBoardKeyHidesTo::drawText() {
+ error("[PuzzleBoardKeyHidesTo::drawText] Not implemented!");
+}
+
+int32 PuzzleBoardKeyHidesTo::findRect() {
+ error("[PuzzleBoardKeyHidesTo::findRect] Not implemented!");
+}
+
+int32 PuzzleBoardKeyHidesTo::checkMouse() {
+ error("[PuzzleBoardKeyHidesTo::checkMouse] Not implemented!");
+}
+
+void PuzzleBoardKeyHidesTo::playSound() {
+ error("[PuzzleBoardKeyHidesTo::playSound] Not implemented!");
+}
+
+
} // End of namespace Asylum
diff --git a/engines/asylum/puzzles/boardkeyhidesto.h b/engines/asylum/puzzles/boardkeyhidesto.h
index 9ac8529fb6..3dce840809 100644
--- a/engines/asylum/puzzles/boardkeyhidesto.h
+++ b/engines/asylum/puzzles/boardkeyhidesto.h
@@ -37,13 +37,27 @@ public:
PuzzleBoardKeyHidesTo(AsylumEngine *engine);
~PuzzleBoardKeyHidesTo();
+ void reset();
+
private:
+ char _charUsed[80];
+
//////////////////////////////////////////////////////////////////////////
// Event Handling
//////////////////////////////////////////////////////////////////////////
bool init(const AsylumEvent &evt);
+ bool activate(const AsylumEvent &evt);
bool update(const AsylumEvent &evt);
bool mouseLeftDown(const AsylumEvent &evt);
+
+ //////////////////////////////////////////////////////////////////////////
+ // Helpers
+ //////////////////////////////////////////////////////////////////////////
+ void updateCursor();
+ void drawText();
+ int32 findRect();
+ int32 checkMouse();
+ void playSound();
};
} // End of namespace Asylum
diff --git a/engines/asylum/puzzles/boardsalvation.cpp b/engines/asylum/puzzles/boardsalvation.cpp
index 9640bca8e8..21127e5743 100644
--- a/engines/asylum/puzzles/boardsalvation.cpp
+++ b/engines/asylum/puzzles/boardsalvation.cpp
@@ -33,6 +33,10 @@ PuzzleBoardSalvation::PuzzleBoardSalvation(AsylumEngine *engine) : Puzzle(engine
PuzzleBoardSalvation::~PuzzleBoardSalvation() {
}
+void PuzzleBoardSalvation::reset() {
+ memset(&_charUsed, 0, sizeof(_charUsed));
+}
+
//////////////////////////////////////////////////////////////////////////
// Event Handling
//////////////////////////////////////////////////////////////////////////
@@ -40,6 +44,10 @@ bool PuzzleBoardSalvation::init(const AsylumEvent &evt) {
error("[PuzzleBoardSalvation::init] Not implemented!");
}
+bool PuzzleBoardSalvation::activate(const AsylumEvent &evt) {
+ error("[PuzzleBoardSalvation::activate] Not implemented!");
+}
+
bool PuzzleBoardSalvation::update(const AsylumEvent &evt) {
error("[PuzzleBoardSalvation::update] Not implemented!");
}
@@ -48,4 +56,27 @@ bool PuzzleBoardSalvation::mouseLeftDown(const AsylumEvent &evt) {
error("[PuzzleBoardSalvation::mouseLeftDown] Not implemented!");
}
+//////////////////////////////////////////////////////////////////////////
+// Helpers
+//////////////////////////////////////////////////////////////////////////
+void PuzzleBoardSalvation::updateCursor() {
+ error("[PuzzleBoardSalvation::updateCursor] Not implemented!");
+}
+
+void PuzzleBoardSalvation::drawText() {
+ error("[PuzzleBoardSalvation::drawText] Not implemented!");
+}
+
+int32 PuzzleBoardSalvation::findRect() {
+ error("[PuzzleBoardSalvation::findRect] Not implemented!");
+}
+
+int32 PuzzleBoardSalvation::checkMouse() {
+ error("[PuzzleBoardSalvation::checkMouse] Not implemented!");
+}
+
+void PuzzleBoardSalvation::playSound() {
+ error("[PuzzleBoardSalvation::playSound] Not implemented!");
+}
+
} // End of namespace Asylum
diff --git a/engines/asylum/puzzles/boardsalvation.h b/engines/asylum/puzzles/boardsalvation.h
index b0ee079663..0d44c6067d 100644
--- a/engines/asylum/puzzles/boardsalvation.h
+++ b/engines/asylum/puzzles/boardsalvation.h
@@ -37,13 +37,27 @@ public:
PuzzleBoardSalvation(AsylumEngine *engine);
~PuzzleBoardSalvation();
+ void reset();
+
private:
+ char _charUsed[60];
+
//////////////////////////////////////////////////////////////////////////
// Event Handling
//////////////////////////////////////////////////////////////////////////
bool init(const AsylumEvent &evt);
+ bool activate(const AsylumEvent &evt);
bool update(const AsylumEvent &evt);
bool mouseLeftDown(const AsylumEvent &evt);
+
+ //////////////////////////////////////////////////////////////////////////
+ // Helpers
+ //////////////////////////////////////////////////////////////////////////
+ void updateCursor();
+ void drawText();
+ int32 findRect();
+ int32 checkMouse();
+ void playSound();
};
} // End of namespace Asylum
diff --git a/engines/asylum/puzzles/boardyouth.cpp b/engines/asylum/puzzles/boardyouth.cpp
index c65e6b1e52..b139ceeed6 100644
--- a/engines/asylum/puzzles/boardyouth.cpp
+++ b/engines/asylum/puzzles/boardyouth.cpp
@@ -33,6 +33,10 @@ PuzzleBoardYouth::PuzzleBoardYouth(AsylumEngine *engine) : Puzzle(engine) {
PuzzleBoardYouth::~PuzzleBoardYouth() {
}
+void PuzzleBoardYouth::reset() {
+ memset(&_charUsed, 0, sizeof(_charUsed));
+}
+
//////////////////////////////////////////////////////////////////////////
// Event Handling
//////////////////////////////////////////////////////////////////////////
@@ -40,6 +44,10 @@ bool PuzzleBoardYouth::init(const AsylumEvent &evt) {
error("[PuzzleBoardYouth::init] Not implemented!");
}
+bool PuzzleBoardYouth::activate(const AsylumEvent &evt) {
+ error("[PuzzleBoardYouth::activate] Not implemented!");
+}
+
bool PuzzleBoardYouth::update(const AsylumEvent &evt) {
error("[PuzzleBoardYouth::update] Not implemented!");
}
@@ -48,4 +56,27 @@ bool PuzzleBoardYouth::mouseLeftDown(const AsylumEvent &evt) {
error("[PuzzleBoardYouth::mouseLeftDown] Not implemented!");
}
+//////////////////////////////////////////////////////////////////////////
+// Helpers
+//////////////////////////////////////////////////////////////////////////
+void PuzzleBoardYouth::updateCursor() {
+ error("[PuzzleBoardYouth::updateCursor] Not implemented!");
+}
+
+void PuzzleBoardYouth::drawText() {
+ error("[PuzzleBoardYouth::drawText] Not implemented!");
+}
+
+int32 PuzzleBoardYouth::findRect() {
+ error("[PuzzleBoardYouth::findRect] Not implemented!");
+}
+
+int32 PuzzleBoardYouth::checkMouse() {
+ error("[PuzzleBoardYouth::checkMouse] Not implemented!");
+}
+
+void PuzzleBoardYouth::playSound() {
+ error("[PuzzleBoardYouth::playSound] Not implemented!");
+}
+
} // End of namespace Asylum
diff --git a/engines/asylum/puzzles/boardyouth.h b/engines/asylum/puzzles/boardyouth.h
index c7f80386f3..a64b565d12 100644
--- a/engines/asylum/puzzles/boardyouth.h
+++ b/engines/asylum/puzzles/boardyouth.h
@@ -37,13 +37,27 @@ public:
PuzzleBoardYouth(AsylumEngine *engine);
~PuzzleBoardYouth();
+ void reset();
+
private:
+ char _charUsed[68];
+
//////////////////////////////////////////////////////////////////////////
// Event Handling
//////////////////////////////////////////////////////////////////////////
bool init(const AsylumEvent &evt);
+ bool activate(const AsylumEvent &evt);
bool update(const AsylumEvent &evt);
bool mouseLeftDown(const AsylumEvent &evt);
+
+ //////////////////////////////////////////////////////////////////////////
+ // Helpers
+ //////////////////////////////////////////////////////////////////////////
+ void updateCursor();
+ void drawText();
+ int32 findRect();
+ int32 checkMouse();
+ void playSound();
};
} // End of namespace Asylum
Commit: 148b5608b7ccf6148642bbfad4301a46f8e98de9
https://github.com/scummvm/scummvm/commit/148b5608b7ccf6148642bbfad4301a46f8e98de9
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:50+02:00
Commit Message:
ASYLUM: Add character maps for Board puzzles
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@761 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/puzzles/boardkeyhidesto.cpp
engines/asylum/puzzles/boardsalvation.cpp
engines/asylum/puzzles/boardyouth.cpp
diff --git a/engines/asylum/puzzles/boardkeyhidesto.cpp b/engines/asylum/puzzles/boardkeyhidesto.cpp
index c8ffa68ab8..e37b048457 100644
--- a/engines/asylum/puzzles/boardkeyhidesto.cpp
+++ b/engines/asylum/puzzles/boardkeyhidesto.cpp
@@ -27,6 +27,22 @@
namespace Asylum {
+static const struct {
+ char character;
+ Common::Point position;
+} puzzleKeyHidesToCharmap[10] = {
+ {'I', Common::Point( 30, 53)},
+ {'E', Common::Point(212, 71)},
+ {'D', Common::Point( 31, 103)},
+ {'H', Common::Point(447, 134)},
+ {'S', Common::Point(240, 151)},
+ {'E', Common::Point( 95, 167)},
+ {'O', Common::Point(372, 182)},
+ {'K', Common::Point(210, 215)},
+ {'Y', Common::Point(440, 247)},
+ {'T', Common::Point(479, 262)}
+};
+
PuzzleBoardKeyHidesTo::PuzzleBoardKeyHidesTo(AsylumEngine *engine) : Puzzle(engine) {
}
diff --git a/engines/asylum/puzzles/boardsalvation.cpp b/engines/asylum/puzzles/boardsalvation.cpp
index 21127e5743..bc0d147651 100644
--- a/engines/asylum/puzzles/boardsalvation.cpp
+++ b/engines/asylum/puzzles/boardsalvation.cpp
@@ -27,6 +27,21 @@
namespace Asylum {
+static const struct {
+ char character;
+ Common::Point position;
+} puzzleSalvationCharmap[9] = {
+ {'I', Common::Point( 61, 53)},
+ {'S', Common::Point(322, 53)},
+ {'A', Common::Point(529, 86)},
+ {'L', Common::Point(256, 117)},
+ {'V', Common::Point(251, 151)},
+ {'A', Common::Point( 66, 199)},
+ {'T', Common::Point(436, 229)},
+ {'O', Common::Point(172, 262)},
+ {'N', Common::Point(393, 296)}
+};
+
PuzzleBoardSalvation::PuzzleBoardSalvation(AsylumEngine *engine) : Puzzle(engine) {
}
diff --git a/engines/asylum/puzzles/boardyouth.cpp b/engines/asylum/puzzles/boardyouth.cpp
index b139ceeed6..f88395d477 100644
--- a/engines/asylum/puzzles/boardyouth.cpp
+++ b/engines/asylum/puzzles/boardyouth.cpp
@@ -27,6 +27,20 @@
namespace Asylum {
+static const struct {
+ char character;
+ Common::Point position;
+} puzzleYouthCharmap[8] = {
+ {'E', Common::Point( 64, 55)},
+ {'U', Common::Point( 26, 69)},
+ {'T', Common::Point(135, 102)},
+ {'O', Common::Point( 57, 134)},
+ {'H', Common::Point(417, 152)},
+ {'T', Common::Point(223, 181)},
+ {'H', Common::Point(497, 198)},
+ {'Y', Common::Point(435, 231)}
+};
+
PuzzleBoardYouth::PuzzleBoardYouth(AsylumEngine *engine) : Puzzle(engine) {
}
Commit: 365ceb1b4f753742e6d3a9bb179d3499aa42f152
https://github.com/scummvm/scummvm/commit/365ceb1b4f753742e6d3a9bb179d3499aa42f152
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:50+02:00
Commit Message:
ASYLUM: Add base PuzzleBoard class for Board puzzles
- Move reset() and activate() methods to base class
- Add stopSound() helper function
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@762 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
A engines/asylum/puzzles/board.cpp
A engines/asylum/puzzles/board.h
engines/asylum/module.mk
engines/asylum/puzzles/boardkeyhidesto.cpp
engines/asylum/puzzles/boardkeyhidesto.h
engines/asylum/puzzles/boardsalvation.cpp
engines/asylum/puzzles/boardsalvation.h
engines/asylum/puzzles/boardyouth.cpp
engines/asylum/puzzles/boardyouth.h
engines/asylum/puzzles/data.h
engines/asylum/puzzles/puzzle.h
diff --git a/engines/asylum/module.mk b/engines/asylum/module.mk
index cb70f69b18..05acbfe787 100644
--- a/engines/asylum/module.mk
+++ b/engines/asylum/module.mk
@@ -1,6 +1,7 @@
MODULE := engines/asylum
MODULE_OBJS := \
+ puzzles/board.o \
puzzles/boardkeyhidesto.o \
puzzles/boardsalvation.o \
puzzles/boardyouth.o \
diff --git a/engines/asylum/puzzles/board.cpp b/engines/asylum/puzzles/board.cpp
new file mode 100644
index 0000000000..f875398b29
--- /dev/null
+++ b/engines/asylum/puzzles/board.cpp
@@ -0,0 +1,84 @@
+/* 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.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#include "asylum/puzzles/board.h"
+
+#include "asylum/resources/worldstats.h"
+
+#include "asylum/system/screen.h"
+#include "asylum/system/sound.h"
+
+#include "asylum/views/scene.h"
+
+#include "asylum/asylum.h"
+
+namespace Asylum {
+
+PuzzleBoard::PuzzleBoard(AsylumEngine *engine) : Puzzle(engine) {
+ _backgroundIndex = -1;
+}
+
+PuzzleBoard::PuzzleBoard(AsylumEngine *engine, int32 backgroundIndex) : Puzzle(engine) {
+ _backgroundIndex = backgroundIndex;
+}
+
+void PuzzleBoard::reset() {
+ memset(&_charUsed, 0, sizeof(_charUsed));
+}
+
+//////////////////////////////////////////////////////////////////////////
+// Event Handling
+//////////////////////////////////////////////////////////////////////////
+bool PuzzleBoard::activate(const AsylumEvent &evt) {
+ if (_backgroundIndex == -1)
+ error("[PuzzleBoard::activate] Invalid background index!");
+
+ getScreen()->clearGraphicsInQueue();
+
+ getScreen()->draw(getWorld()->graphicResourceIds[_backgroundIndex]);
+ drawText();
+
+ getScreen()->drawGraphicsInQueue();
+ getScreen()->copyBackBufferToScreen();
+
+ return true;
+}
+
+//////////////////////////////////////////////////////////////////////////
+// Helpers
+//////////////////////////////////////////////////////////////////////////
+bool PuzzleBoard::stopSound() {
+ ResourceId soundResourceId = getPuzzleData()->soundResourceId;
+
+ if (soundResourceId && getSound()->isPlaying(soundResourceId)) {
+ getSound()->stopAll(soundResourceId);
+
+ return true;
+ }
+
+ return false;
+}
+
+} // End of namespace Asylum
diff --git a/engines/asylum/puzzles/board.h b/engines/asylum/puzzles/board.h
new file mode 100644
index 0000000000..d4e0550784
--- /dev/null
+++ b/engines/asylum/puzzles/board.h
@@ -0,0 +1,62 @@
+/* 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.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#ifndef ASYLUM_BOARD_H
+#define ASYLUM_BOARD_H
+
+#include "asylum/puzzles/puzzle.h"
+
+namespace Asylum {
+
+class AsylumEngine;
+
+class PuzzleBoard : public Puzzle {
+public:
+ PuzzleBoard(AsylumEngine *engine);
+ PuzzleBoard(AsylumEngine *engine, int32 backgroundIndex);
+
+ void reset();
+
+protected:
+ char _charUsed[80];
+
+private:
+ int32 _backgroundIndex;
+
+ //////////////////////////////////////////////////////////////////////////
+ // Event Handling
+ //////////////////////////////////////////////////////////////////////////
+ bool activate(const AsylumEvent &evt);
+
+ //////////////////////////////////////////////////////////////////////////
+ // Helpers
+ //////////////////////////////////////////////////////////////////////////
+ bool stopSound();
+ virtual void drawText();
+};
+
+} // End of namespace Asylum
+
+#endif // ASYLUM_BOARD_H
diff --git a/engines/asylum/puzzles/boardkeyhidesto.cpp b/engines/asylum/puzzles/boardkeyhidesto.cpp
index e37b048457..fce0103d93 100644
--- a/engines/asylum/puzzles/boardkeyhidesto.cpp
+++ b/engines/asylum/puzzles/boardkeyhidesto.cpp
@@ -43,16 +43,12 @@ static const struct {
{'T', Common::Point(479, 262)}
};
-PuzzleBoardKeyHidesTo::PuzzleBoardKeyHidesTo(AsylumEngine *engine) : Puzzle(engine) {
+PuzzleBoardKeyHidesTo::PuzzleBoardKeyHidesTo(AsylumEngine *engine) : PuzzleBoard(engine, 56) {
}
PuzzleBoardKeyHidesTo::~PuzzleBoardKeyHidesTo() {
}
-void PuzzleBoardKeyHidesTo::reset() {
- memset(&_charUsed, 0, sizeof(_charUsed));
-}
-
//////////////////////////////////////////////////////////////////////////
// Event Handling
//////////////////////////////////////////////////////////////////////////
@@ -60,10 +56,6 @@ bool PuzzleBoardKeyHidesTo::init(const AsylumEvent &evt) {
error("[PuzzleBoardKeyHidesTo::init] Not implemented!");
}
-bool PuzzleBoardKeyHidesTo::activate(const AsylumEvent &evt) {
- error("[PuzzleBoardKeyHidesTo::activate] Not implemented!");
-}
-
bool PuzzleBoardKeyHidesTo::update(const AsylumEvent &evt) {
error("[PuzzleBoardKeyHidesTo::update] Not implemented!");
}
diff --git a/engines/asylum/puzzles/boardkeyhidesto.h b/engines/asylum/puzzles/boardkeyhidesto.h
index 3dce840809..be04e56594 100644
--- a/engines/asylum/puzzles/boardkeyhidesto.h
+++ b/engines/asylum/puzzles/boardkeyhidesto.h
@@ -26,27 +26,22 @@
#ifndef ASYLUM_BOARDKEYHIDESTO_H
#define ASYLUM_BOARDKEYHIDESTO_H
-#include "asylum/puzzles/puzzle.h"
+#include "asylum/puzzles/board.h"
namespace Asylum {
class AsylumEngine;
-class PuzzleBoardKeyHidesTo : public Puzzle {
+class PuzzleBoardKeyHidesTo : public PuzzleBoard {
public:
PuzzleBoardKeyHidesTo(AsylumEngine *engine);
~PuzzleBoardKeyHidesTo();
- void reset();
-
private:
- char _charUsed[80];
-
//////////////////////////////////////////////////////////////////////////
// Event Handling
//////////////////////////////////////////////////////////////////////////
bool init(const AsylumEvent &evt);
- bool activate(const AsylumEvent &evt);
bool update(const AsylumEvent &evt);
bool mouseLeftDown(const AsylumEvent &evt);
diff --git a/engines/asylum/puzzles/boardsalvation.cpp b/engines/asylum/puzzles/boardsalvation.cpp
index bc0d147651..4d05251a65 100644
--- a/engines/asylum/puzzles/boardsalvation.cpp
+++ b/engines/asylum/puzzles/boardsalvation.cpp
@@ -42,16 +42,12 @@ static const struct {
{'N', Common::Point(393, 296)}
};
-PuzzleBoardSalvation::PuzzleBoardSalvation(AsylumEngine *engine) : Puzzle(engine) {
+PuzzleBoardSalvation::PuzzleBoardSalvation(AsylumEngine *engine) : PuzzleBoard(engine, 31) {
}
PuzzleBoardSalvation::~PuzzleBoardSalvation() {
}
-void PuzzleBoardSalvation::reset() {
- memset(&_charUsed, 0, sizeof(_charUsed));
-}
-
//////////////////////////////////////////////////////////////////////////
// Event Handling
//////////////////////////////////////////////////////////////////////////
@@ -59,10 +55,6 @@ bool PuzzleBoardSalvation::init(const AsylumEvent &evt) {
error("[PuzzleBoardSalvation::init] Not implemented!");
}
-bool PuzzleBoardSalvation::activate(const AsylumEvent &evt) {
- error("[PuzzleBoardSalvation::activate] Not implemented!");
-}
-
bool PuzzleBoardSalvation::update(const AsylumEvent &evt) {
error("[PuzzleBoardSalvation::update] Not implemented!");
}
diff --git a/engines/asylum/puzzles/boardsalvation.h b/engines/asylum/puzzles/boardsalvation.h
index 0d44c6067d..6c19a83829 100644
--- a/engines/asylum/puzzles/boardsalvation.h
+++ b/engines/asylum/puzzles/boardsalvation.h
@@ -26,27 +26,22 @@
#ifndef ASYLUM_BOARDSALVATION_H
#define ASYLUM_BOARDSALVATION_H
-#include "asylum/puzzles/puzzle.h"
+#include "asylum/puzzles/board.h"
namespace Asylum {
class AsylumEngine;
-class PuzzleBoardSalvation : public Puzzle {
+class PuzzleBoardSalvation : public PuzzleBoard {
public:
PuzzleBoardSalvation(AsylumEngine *engine);
~PuzzleBoardSalvation();
- void reset();
-
private:
- char _charUsed[60];
-
//////////////////////////////////////////////////////////////////////////
// Event Handling
//////////////////////////////////////////////////////////////////////////
bool init(const AsylumEvent &evt);
- bool activate(const AsylumEvent &evt);
bool update(const AsylumEvent &evt);
bool mouseLeftDown(const AsylumEvent &evt);
diff --git a/engines/asylum/puzzles/boardyouth.cpp b/engines/asylum/puzzles/boardyouth.cpp
index f88395d477..499f7ec7e4 100644
--- a/engines/asylum/puzzles/boardyouth.cpp
+++ b/engines/asylum/puzzles/boardyouth.cpp
@@ -41,16 +41,12 @@ static const struct {
{'Y', Common::Point(435, 231)}
};
-PuzzleBoardYouth::PuzzleBoardYouth(AsylumEngine *engine) : Puzzle(engine) {
+PuzzleBoardYouth::PuzzleBoardYouth(AsylumEngine *engine) : PuzzleBoard(engine, 55) {
}
PuzzleBoardYouth::~PuzzleBoardYouth() {
}
-void PuzzleBoardYouth::reset() {
- memset(&_charUsed, 0, sizeof(_charUsed));
-}
-
//////////////////////////////////////////////////////////////////////////
// Event Handling
//////////////////////////////////////////////////////////////////////////
@@ -58,10 +54,6 @@ bool PuzzleBoardYouth::init(const AsylumEvent &evt) {
error("[PuzzleBoardYouth::init] Not implemented!");
}
-bool PuzzleBoardYouth::activate(const AsylumEvent &evt) {
- error("[PuzzleBoardYouth::activate] Not implemented!");
-}
-
bool PuzzleBoardYouth::update(const AsylumEvent &evt) {
error("[PuzzleBoardYouth::update] Not implemented!");
}
diff --git a/engines/asylum/puzzles/boardyouth.h b/engines/asylum/puzzles/boardyouth.h
index a64b565d12..949c8d8479 100644
--- a/engines/asylum/puzzles/boardyouth.h
+++ b/engines/asylum/puzzles/boardyouth.h
@@ -26,27 +26,22 @@
#ifndef ASYLUM_BOARDYOUTH_H
#define ASYLUM_BOARDYOUTH_H
-#include "asylum/puzzles/puzzle.h"
+#include "asylum/puzzles/board.h"
namespace Asylum {
class AsylumEngine;
-class PuzzleBoardYouth : public Puzzle {
+class PuzzleBoardYouth : public PuzzleBoard {
public:
PuzzleBoardYouth(AsylumEngine *engine);
~PuzzleBoardYouth();
- void reset();
-
private:
- char _charUsed[68];
-
//////////////////////////////////////////////////////////////////////////
// Event Handling
//////////////////////////////////////////////////////////////////////////
bool init(const AsylumEvent &evt);
- bool activate(const AsylumEvent &evt);
bool update(const AsylumEvent &evt);
bool mouseLeftDown(const AsylumEvent &evt);
diff --git a/engines/asylum/puzzles/data.h b/engines/asylum/puzzles/data.h
index 7a0d8ce6c6..1ac5ca06ca 100644
--- a/engines/asylum/puzzles/data.h
+++ b/engines/asylum/puzzles/data.h
@@ -27,6 +27,7 @@
#define ASYLUM_PUZZLE_DATA_H
#include "asylum/console.h"
+#include "asylum/shared.h"
#include "common/serializer.h"
@@ -36,6 +37,9 @@ struct PuzzleData : public Common::Serializable {
public:
uint32 timeMachineCounter;
+ // Board puzzles
+ ResourceId soundResourceId;
+ char boardText[800];
PuzzleData() {
timeMachineCounter = 0;
diff --git a/engines/asylum/puzzles/puzzle.h b/engines/asylum/puzzles/puzzle.h
index 57a75c3424..d8ad35571a 100644
--- a/engines/asylum/puzzles/puzzle.h
+++ b/engines/asylum/puzzles/puzzle.h
@@ -73,7 +73,6 @@ protected:
//////////////////////////////////////////////////////////////////////////
bool hitTest(const Common::Point *polygonPoint, Common::Point point, uint32 index);
bool hitTest(const Common::Point *polygonPoint, Common::Point point);
-
};
} // End of namespace Asylum
Commit: dce22936adc9fe94f110d15a07373275b9f66541
https://github.com/scummvm/scummvm/commit/dce22936adc9fe94f110d15a07373275b9f66541
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:51+02:00
Commit Message:
ASYLUM: Implement shared Board puzzle methods
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@763 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/puzzles/board.cpp
engines/asylum/puzzles/board.h
engines/asylum/puzzles/boardkeyhidesto.cpp
engines/asylum/puzzles/boardkeyhidesto.h
engines/asylum/puzzles/boardsalvation.cpp
engines/asylum/puzzles/boardsalvation.h
engines/asylum/puzzles/boardyouth.cpp
engines/asylum/puzzles/boardyouth.h
engines/asylum/puzzles/data.h
engines/asylum/shared.h
diff --git a/engines/asylum/puzzles/board.cpp b/engines/asylum/puzzles/board.cpp
index f875398b29..68b848d699 100644
--- a/engines/asylum/puzzles/board.cpp
+++ b/engines/asylum/puzzles/board.cpp
@@ -1,34 +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.
- *
- * $URL$
- * $Id$
- *
- */
+*
+* 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.
+*
+* $URL$
+* $Id$
+*
+*/
#include "asylum/puzzles/board.h"
#include "asylum/resources/worldstats.h"
+#include "asylum/system/cursor.h"
#include "asylum/system/screen.h"
#include "asylum/system/sound.h"
+#include "asylum/system/text.h"
#include "asylum/views/scene.h"
@@ -37,11 +39,18 @@
namespace Asylum {
PuzzleBoard::PuzzleBoard(AsylumEngine *engine) : Puzzle(engine) {
- _backgroundIndex = -1;
+ error("[PuzzleBoard::PuzzleBoard] No puzzle data!");
}
-PuzzleBoard::PuzzleBoard(AsylumEngine *engine, int32 backgroundIndex) : Puzzle(engine) {
- _backgroundIndex = backgroundIndex;
+PuzzleBoard::PuzzleBoard(AsylumEngine *engine, PuzzleData data) : Puzzle(engine) {
+ _data = data;
+
+ // Init board
+ _solved = false;
+ memset(&_text, 0, sizeof(_text));
+ memset(&_charUsed, 0, sizeof(_charUsed));
+ memset(&_solvedText, 0, sizeof(_solvedText));
+ _soundResourceId = kResourceNone;
}
void PuzzleBoard::reset() {
@@ -52,12 +61,9 @@ void PuzzleBoard::reset() {
// Event Handling
//////////////////////////////////////////////////////////////////////////
bool PuzzleBoard::activate(const AsylumEvent &evt) {
- if (_backgroundIndex == -1)
- error("[PuzzleBoard::activate] Invalid background index!");
-
getScreen()->clearGraphicsInQueue();
- getScreen()->draw(getWorld()->graphicResourceIds[_backgroundIndex]);
+ getScreen()->draw(getWorld()->graphicResourceIds[_data.backgroundIndex]);
drawText();
getScreen()->drawGraphicsInQueue();
@@ -66,14 +72,47 @@ bool PuzzleBoard::activate(const AsylumEvent &evt) {
return true;
}
+bool PuzzleBoard::update(const AsylumEvent &evt) {
+ updateCursor();
+
+ if (!_solved)
+ playSound();
+
+
+ if (_vm->isGameFlagNotSet(_data.gameFlag)) {
+ if (_solved) {
+ if (!getSound()->isPlaying(MAKE_RESOURCE(kResourcePackSpeech, 1))) {
+ _vm->setGameFlag(_data.gameFlag);
+ getCursor()->show();
+ getScreen()->clear();
+ _vm->switchEventHandler(getScene());
+ }
+ } else {
+ _solved = true;
+ getCursor()->hide();
+ stopSound();
+ getSound()->playSound(MAKE_RESOURCE(kResourcePackSpeech, 1), false, Config.voiceVolume);
+ }
+ }
+
+ return true;
+}
+
+bool PuzzleBoard::mouseRightDown(const AsylumEvent &evt) {
+ if (!stopSound()) {
+ getScreen()->clear();
+ _vm->switchEventHandler(getScene());
+ }
+
+ return true;
+}
+
//////////////////////////////////////////////////////////////////////////
// Helpers
//////////////////////////////////////////////////////////////////////////
bool PuzzleBoard::stopSound() {
- ResourceId soundResourceId = getPuzzleData()->soundResourceId;
-
- if (soundResourceId && getSound()->isPlaying(soundResourceId)) {
- getSound()->stopAll(soundResourceId);
+ if (_soundResourceId && getSound()->isPlaying(_soundResourceId)) {
+ getSound()->stopAll(_soundResourceId);
return true;
}
@@ -81,4 +120,72 @@ bool PuzzleBoard::stopSound() {
return false;
}
+void PuzzleBoard::drawText() {
+ getText()->loadFont(getWorld()->graphicResourceIds[35]);
+ getText()->draw(0, 99, kTextCenter, 25, 50, 16, 590, _text);
+
+ int32 index = 0;
+ for (uint32 x = 215; x < _data.maxWidth; x += 24) {
+ if (!_solvedText[index])
+ break;
+
+ getText()->setPosition(x, _data_456958 != index ? 360 : 370);
+ getText()->drawChar(_solvedText[index]);
+
+ index += 2;
+ }
+}
+
+void PuzzleBoard::playSound() {
+ uint32 index = 0;
+ for (index = 0; index < _data.soundResourceSize; index++) {
+ if (!_data.soundResources[index].played)
+ break;
+ }
+
+ if (index >= _data.soundResourceSize)
+ return;
+
+ if (!_soundResourceId || !getSound()->isPlaying(_soundResourceId)) {
+ _soundResourceId = MAKE_RESOURCE(kResourcePackSharedSound, 961 + _data.soundResources[index].index);
+ getSound()->playSound(_soundResourceId, false, Config.voiceVolume);
+ _data.soundResources[index].played = true;
+ }
+}
+
+int32 PuzzleBoard::findRect() {
+ Common::Point mousePos = getCursor()->position();
+
+ for (uint32 i = 0; i < _data.charMapSize; i++) {
+ if (mousePos.x >= _data.charMap[i].position.x && mousePos.x < _data.charMap[i].position.x + 12
+ && mousePos.y >= _data.charMap[i].position.y && mousePos.y < _data.charMap[i].position.y + 18)
+ if (!_charUsed[i])
+ return i;
+ }
+
+ return -1;
+}
+
+int32 PuzzleBoard::checkMouse() {
+ Common::Point mousePos = getCursor()->position();
+
+ if (mousePos.x >= 215 && mousePos.x < (int16)_data.maxWidth && mousePos.y >= 360 && mousePos.y < 376) {
+ uint32 index = (mousePos.x - 215) / 12;
+
+ if (index >= ARRAYSIZE(_solvedText))
+ return -1;
+
+ if (_solvedText[index] != 0) {
+ if (_data.checkForSpace) {
+ if (_solvedText[index] != ' ')
+ return -3;
+ } else {
+ return -3;
+ }
+ }
+ }
+
+ return -1;
+}
+
} // End of namespace Asylum
diff --git a/engines/asylum/puzzles/board.h b/engines/asylum/puzzles/board.h
index d4e0550784..0d44d874fb 100644
--- a/engines/asylum/puzzles/board.h
+++ b/engines/asylum/puzzles/board.h
@@ -28,33 +28,74 @@
#include "asylum/puzzles/puzzle.h"
+#include "asylum/shared.h"
+
namespace Asylum {
class AsylumEngine;
class PuzzleBoard : public Puzzle {
public:
+ struct SoundResource {
+ int32 index;
+ bool played;
+ };
+
+ struct CharMap {
+ char character;
+ Common::Point position;
+ };
+
+ struct PuzzleData {
+ uint32 backgroundIndex;
+ GameFlag gameFlag;
+ uint32 maxWidth;
+ uint32 soundResourceSize;
+ SoundResource soundResources[3];
+ uint32 charMapSize;
+ CharMap charMap[10];
+ bool checkForSpace;
+ };
+
PuzzleBoard(AsylumEngine *engine);
- PuzzleBoard(AsylumEngine *engine, int32 backgroundIndex);
+ PuzzleBoard(AsylumEngine *engine, PuzzleData data);
void reset();
protected:
- char _charUsed[80];
+ bool _solved;
+ char _text[800];
+ int32 _charUsed[20];
+ char _solvedText[28]; // KeyHidesTo uses 28 chars, the other puzzles 20
+ int32 _rectIndex;
+ ResourceId _soundResourceId;
+ //Common::Array<PuzzleSoundResource> _soundResources;
+
+ int32 _data_456958;
+
+ //////////////////////////////////////////////////////////////////////////
+ // Helpers
+ //////////////////////////////////////////////////////////////////////////
+ bool stopSound();
private:
- int32 _backgroundIndex;
+ PuzzleData _data;
//////////////////////////////////////////////////////////////////////////
// Event Handling
//////////////////////////////////////////////////////////////////////////
bool activate(const AsylumEvent &evt);
+ bool update(const AsylumEvent &evt);
+ virtual bool mouseRightDown(const AsylumEvent &evt);
//////////////////////////////////////////////////////////////////////////
// Helpers
//////////////////////////////////////////////////////////////////////////
- bool stopSound();
- virtual void drawText();
+ void drawText();
+ void playSound();
+ int32 findRect();
+ int32 checkMouse();
+ virtual void updateCursor();
};
} // End of namespace Asylum
diff --git a/engines/asylum/puzzles/boardkeyhidesto.cpp b/engines/asylum/puzzles/boardkeyhidesto.cpp
index fce0103d93..e1b8ebbca8 100644
--- a/engines/asylum/puzzles/boardkeyhidesto.cpp
+++ b/engines/asylum/puzzles/boardkeyhidesto.cpp
@@ -27,11 +27,14 @@
namespace Asylum {
-static const struct {
- char character;
- Common::Point position;
-} puzzleKeyHidesToCharmap[10] = {
- {'I', Common::Point( 30, 53)},
+static const PuzzleBoard::PuzzleData puzzleKeyHidesToData = {
+ 56,
+ kGameFlag283,
+ 503,
+ 3,
+ {{5, false}, {6, false}, {7, false}},
+ 10,
+ {{'I', Common::Point( 30, 53)},
{'E', Common::Point(212, 71)},
{'D', Common::Point( 31, 103)},
{'H', Common::Point(447, 134)},
@@ -40,13 +43,11 @@ static const struct {
{'O', Common::Point(372, 182)},
{'K', Common::Point(210, 215)},
{'Y', Common::Point(440, 247)},
- {'T', Common::Point(479, 262)}
+ {'T', Common::Point(479, 262)}},
+ true
};
-PuzzleBoardKeyHidesTo::PuzzleBoardKeyHidesTo(AsylumEngine *engine) : PuzzleBoard(engine, 56) {
-}
-
-PuzzleBoardKeyHidesTo::~PuzzleBoardKeyHidesTo() {
+PuzzleBoardKeyHidesTo::PuzzleBoardKeyHidesTo(AsylumEngine *engine) : PuzzleBoard(engine, puzzleKeyHidesToData) {
}
//////////////////////////////////////////////////////////////////////////
@@ -56,36 +57,8 @@ bool PuzzleBoardKeyHidesTo::init(const AsylumEvent &evt) {
error("[PuzzleBoardKeyHidesTo::init] Not implemented!");
}
-bool PuzzleBoardKeyHidesTo::update(const AsylumEvent &evt) {
- error("[PuzzleBoardKeyHidesTo::update] Not implemented!");
-}
-
bool PuzzleBoardKeyHidesTo::mouseLeftDown(const AsylumEvent &evt) {
error("[PuzzleBoardKeyHidesTo::mouseLeftDown] Not implemented!");
}
-//////////////////////////////////////////////////////////////////////////
-// Helpers
-//////////////////////////////////////////////////////////////////////////
-void PuzzleBoardKeyHidesTo::updateCursor() {
- error("[PuzzleBoardKeyHidesTo::updateCursor] Not implemented!");
-}
-
-void PuzzleBoardKeyHidesTo::drawText() {
- error("[PuzzleBoardKeyHidesTo::drawText] Not implemented!");
-}
-
-int32 PuzzleBoardKeyHidesTo::findRect() {
- error("[PuzzleBoardKeyHidesTo::findRect] Not implemented!");
-}
-
-int32 PuzzleBoardKeyHidesTo::checkMouse() {
- error("[PuzzleBoardKeyHidesTo::checkMouse] Not implemented!");
-}
-
-void PuzzleBoardKeyHidesTo::playSound() {
- error("[PuzzleBoardKeyHidesTo::playSound] Not implemented!");
-}
-
-
} // End of namespace Asylum
diff --git a/engines/asylum/puzzles/boardkeyhidesto.h b/engines/asylum/puzzles/boardkeyhidesto.h
index be04e56594..9577232ec7 100644
--- a/engines/asylum/puzzles/boardkeyhidesto.h
+++ b/engines/asylum/puzzles/boardkeyhidesto.h
@@ -35,24 +35,13 @@ class AsylumEngine;
class PuzzleBoardKeyHidesTo : public PuzzleBoard {
public:
PuzzleBoardKeyHidesTo(AsylumEngine *engine);
- ~PuzzleBoardKeyHidesTo();
private:
//////////////////////////////////////////////////////////////////////////
// Event Handling
//////////////////////////////////////////////////////////////////////////
bool init(const AsylumEvent &evt);
- bool update(const AsylumEvent &evt);
bool mouseLeftDown(const AsylumEvent &evt);
-
- //////////////////////////////////////////////////////////////////////////
- // Helpers
- //////////////////////////////////////////////////////////////////////////
- void updateCursor();
- void drawText();
- int32 findRect();
- int32 checkMouse();
- void playSound();
};
} // End of namespace Asylum
diff --git a/engines/asylum/puzzles/boardsalvation.cpp b/engines/asylum/puzzles/boardsalvation.cpp
index 4d05251a65..df14e8fd68 100644
--- a/engines/asylum/puzzles/boardsalvation.cpp
+++ b/engines/asylum/puzzles/boardsalvation.cpp
@@ -25,13 +25,23 @@
#include "asylum/puzzles/boardsalvation.h"
+#include "asylum/system/screen.h"
+#include "asylum/system/sound.h"
+
+#include "asylum/views/scene.h"
+
+#include "asylum/asylum.h"
+
namespace Asylum {
-static const struct {
- char character;
- Common::Point position;
-} puzzleSalvationCharmap[9] = {
- {'I', Common::Point( 61, 53)},
+static const PuzzleBoard::PuzzleData puzzleSalvationData = {
+ 31,
+ kGameFlag281,
+ 431,
+ 3,
+ {{0, false}, {1, false}, {2, false}},
+ 9,
+ {{'I', Common::Point( 61, 53)},
{'S', Common::Point(322, 53)},
{'A', Common::Point(529, 86)},
{'L', Common::Point(256, 117)},
@@ -39,13 +49,13 @@ static const struct {
{'A', Common::Point( 66, 199)},
{'T', Common::Point(436, 229)},
{'O', Common::Point(172, 262)},
- {'N', Common::Point(393, 296)}
+ {'N', Common::Point(393, 296)}},
+ false
};
-PuzzleBoardSalvation::PuzzleBoardSalvation(AsylumEngine *engine) : PuzzleBoard(engine, 31) {
-}
+static const uint32 puzzleSalvationSoundResourceIndex[11] = {5, 6, 7, 10, 11, 28, 29, 30, 31, 32, 36};
-PuzzleBoardSalvation::~PuzzleBoardSalvation() {
+PuzzleBoardSalvation::PuzzleBoardSalvation(AsylumEngine *engine) : PuzzleBoard(engine, puzzleSalvationData) {
}
//////////////////////////////////////////////////////////////////////////
@@ -55,35 +65,26 @@ bool PuzzleBoardSalvation::init(const AsylumEvent &evt) {
error("[PuzzleBoardSalvation::init] Not implemented!");
}
-bool PuzzleBoardSalvation::update(const AsylumEvent &evt) {
- error("[PuzzleBoardSalvation::update] Not implemented!");
-}
-
bool PuzzleBoardSalvation::mouseLeftDown(const AsylumEvent &evt) {
error("[PuzzleBoardSalvation::mouseLeftDown] Not implemented!");
}
-//////////////////////////////////////////////////////////////////////////
-// Helpers
-//////////////////////////////////////////////////////////////////////////
-void PuzzleBoardSalvation::updateCursor() {
- error("[PuzzleBoardSalvation::updateCursor] Not implemented!");
-}
-
-void PuzzleBoardSalvation::drawText() {
- error("[PuzzleBoardSalvation::drawText] Not implemented!");
-}
-
-int32 PuzzleBoardSalvation::findRect() {
- error("[PuzzleBoardSalvation::findRect] Not implemented!");
-}
+bool PuzzleBoardSalvation::mouseRightDown(const AsylumEvent &evt) {
+ if (!stopSound()) {
+ checkANALText();
+ getScreen()->clear();
+ _vm->switchEventHandler(getScene());
+ }
-int32 PuzzleBoardSalvation::checkMouse() {
- error("[PuzzleBoardSalvation::checkMouse] Not implemented!");
+ return true;
}
-void PuzzleBoardSalvation::playSound() {
- error("[PuzzleBoardSalvation::playSound] Not implemented!");
+//////////////////////////////////////////////////////////////////////////
+// Helpers
+//////////////////////////////////////////////////////////////////////////
+void PuzzleBoardSalvation::checkANALText() {
+ if (!strcmp(_solvedText, "A N A L "))
+ getSound()->playSound(MAKE_RESOURCE(kResourcePackSpeech, puzzleSalvationSoundResourceIndex[rnd(11)]), false, Config.voiceVolume);
}
} // End of namespace Asylum
diff --git a/engines/asylum/puzzles/boardsalvation.h b/engines/asylum/puzzles/boardsalvation.h
index 6c19a83829..22394232c0 100644
--- a/engines/asylum/puzzles/boardsalvation.h
+++ b/engines/asylum/puzzles/boardsalvation.h
@@ -35,24 +35,19 @@ class AsylumEngine;
class PuzzleBoardSalvation : public PuzzleBoard {
public:
PuzzleBoardSalvation(AsylumEngine *engine);
- ~PuzzleBoardSalvation();
private:
//////////////////////////////////////////////////////////////////////////
// Event Handling
//////////////////////////////////////////////////////////////////////////
bool init(const AsylumEvent &evt);
- bool update(const AsylumEvent &evt);
bool mouseLeftDown(const AsylumEvent &evt);
+ bool mouseRightDown(const AsylumEvent &evt);
//////////////////////////////////////////////////////////////////////////
// Helpers
//////////////////////////////////////////////////////////////////////////
- void updateCursor();
- void drawText();
- int32 findRect();
- int32 checkMouse();
- void playSound();
+ void checkANALText();
};
} // End of namespace Asylum
diff --git a/engines/asylum/puzzles/boardyouth.cpp b/engines/asylum/puzzles/boardyouth.cpp
index 499f7ec7e4..9ec73d4829 100644
--- a/engines/asylum/puzzles/boardyouth.cpp
+++ b/engines/asylum/puzzles/boardyouth.cpp
@@ -27,24 +27,25 @@
namespace Asylum {
-static const struct {
- char character;
- Common::Point position;
-} puzzleYouthCharmap[8] = {
- {'E', Common::Point( 64, 55)},
+static const PuzzleBoard::PuzzleData puzzleYouthData = {
+ 55,
+ kGameFlag282,
+ 431,
+ 2,
+ {{3, false}, {4, false}, {0, false}},
+ 8,
+ {{'E', Common::Point( 64, 55)},
{'U', Common::Point( 26, 69)},
{'T', Common::Point(135, 102)},
{'O', Common::Point( 57, 134)},
{'H', Common::Point(417, 152)},
{'T', Common::Point(223, 181)},
{'H', Common::Point(497, 198)},
- {'Y', Common::Point(435, 231)}
+ {'Y', Common::Point(435, 231)}},
+ true
};
-PuzzleBoardYouth::PuzzleBoardYouth(AsylumEngine *engine) : PuzzleBoard(engine, 55) {
-}
-
-PuzzleBoardYouth::~PuzzleBoardYouth() {
+PuzzleBoardYouth::PuzzleBoardYouth(AsylumEngine *engine) : PuzzleBoard(engine, puzzleYouthData) {
}
//////////////////////////////////////////////////////////////////////////
@@ -54,35 +55,8 @@ bool PuzzleBoardYouth::init(const AsylumEvent &evt) {
error("[PuzzleBoardYouth::init] Not implemented!");
}
-bool PuzzleBoardYouth::update(const AsylumEvent &evt) {
- error("[PuzzleBoardYouth::update] Not implemented!");
-}
-
bool PuzzleBoardYouth::mouseLeftDown(const AsylumEvent &evt) {
error("[PuzzleBoardYouth::mouseLeftDown] Not implemented!");
}
-//////////////////////////////////////////////////////////////////////////
-// Helpers
-//////////////////////////////////////////////////////////////////////////
-void PuzzleBoardYouth::updateCursor() {
- error("[PuzzleBoardYouth::updateCursor] Not implemented!");
-}
-
-void PuzzleBoardYouth::drawText() {
- error("[PuzzleBoardYouth::drawText] Not implemented!");
-}
-
-int32 PuzzleBoardYouth::findRect() {
- error("[PuzzleBoardYouth::findRect] Not implemented!");
-}
-
-int32 PuzzleBoardYouth::checkMouse() {
- error("[PuzzleBoardYouth::checkMouse] Not implemented!");
-}
-
-void PuzzleBoardYouth::playSound() {
- error("[PuzzleBoardYouth::playSound] Not implemented!");
-}
-
} // End of namespace Asylum
diff --git a/engines/asylum/puzzles/boardyouth.h b/engines/asylum/puzzles/boardyouth.h
index 949c8d8479..357a6f1cd5 100644
--- a/engines/asylum/puzzles/boardyouth.h
+++ b/engines/asylum/puzzles/boardyouth.h
@@ -35,24 +35,13 @@ class AsylumEngine;
class PuzzleBoardYouth : public PuzzleBoard {
public:
PuzzleBoardYouth(AsylumEngine *engine);
- ~PuzzleBoardYouth();
private:
//////////////////////////////////////////////////////////////////////////
// Event Handling
//////////////////////////////////////////////////////////////////////////
bool init(const AsylumEvent &evt);
- bool update(const AsylumEvent &evt);
bool mouseLeftDown(const AsylumEvent &evt);
-
- //////////////////////////////////////////////////////////////////////////
- // Helpers
- //////////////////////////////////////////////////////////////////////////
- void updateCursor();
- void drawText();
- int32 findRect();
- int32 checkMouse();
- void playSound();
};
} // End of namespace Asylum
diff --git a/engines/asylum/puzzles/data.h b/engines/asylum/puzzles/data.h
index 1ac5ca06ca..88b1c68fb9 100644
--- a/engines/asylum/puzzles/data.h
+++ b/engines/asylum/puzzles/data.h
@@ -37,10 +37,6 @@ struct PuzzleData : public Common::Serializable {
public:
uint32 timeMachineCounter;
- // Board puzzles
- ResourceId soundResourceId;
- char boardText[800];
-
PuzzleData() {
timeMachineCounter = 0;
}
diff --git a/engines/asylum/shared.h b/engines/asylum/shared.h
index 9af8262ac0..305d3a4d80 100644
--- a/engines/asylum/shared.h
+++ b/engines/asylum/shared.h
@@ -32,6 +32,8 @@ namespace Asylum {
// Global
//////////////////////////////////////////////////////////////////////////
enum GameFlag {
+ kGameFlag0 = 0,
+
kGameFlag4 = 4,
kGameFlag12 = 12,
kGameFlag52 = 52,
@@ -78,6 +80,9 @@ enum GameFlag {
kGameFlag275 = 275,
kGameFlag276 = 276,
kGameFlag279 = 279,
+ kGameFlag281 = 281,
+ kGameFlag282 = 282,
+ kGameFlag283 = 283,
kGameFlag353 = 353,
kGameFlag354 = 354,
kGameFlag355 = 355,
Commit: 5632921ca5eee4ea74e3f1f370a236be2082a2eb
https://github.com/scummvm/scummvm/commit/5632921ca5eee4ea74e3f1f370a236be2082a2eb
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:51+02:00
Commit Message:
ASYLUM: Implement PuzzleBoard::updateCursor()
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@764 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/puzzles/board.cpp
engines/asylum/puzzles/board.h
diff --git a/engines/asylum/puzzles/board.cpp b/engines/asylum/puzzles/board.cpp
index 68b848d699..d93b2dbeaa 100644
--- a/engines/asylum/puzzles/board.cpp
+++ b/engines/asylum/puzzles/board.cpp
@@ -188,4 +188,51 @@ int32 PuzzleBoard::checkMouse() {
return -1;
}
+void PuzzleBoard::updateCursor() {
+ Common::Point mousePos = getCursor()->position();
+
+ if (mousePos.y <= 350) {
+ int32 index = findRect();
+
+ if (index == -1) {
+ if (getCursor()->graphicResourceId == getWorld()->graphicResourceIds[34])
+ return;
+
+ _rectIndex = index;
+
+ getCursor()->set(getWorld()->graphicResourceIds[34]);
+ } else {
+ if (getCursor()->graphicResourceId == getWorld()->graphicResourceIds[33])
+ return;
+
+ if (index == _rectIndex)
+ return;
+
+ _rectIndex = index;
+
+ getCursor()->set(getWorld()->graphicResourceIds[33]);
+ }
+ } else {
+ if (_vm->isGameFlagSet(_data.gameFlag)) {
+ if (getCursor()->graphicResourceId == getWorld()->graphicResourceIds[34])
+ return;
+
+ getCursor()->set(getWorld()->graphicResourceIds[34]);
+ } else {
+ int32 index = checkMouse();
+
+ if (getCursor()->graphicResourceId == getWorld()->graphicResourceIds[33])
+ return;
+
+ if (index == _rectIndex)
+ return;
+
+ if (index == -1)
+ getCursor()->set(getWorld()->graphicResourceIds[33], 0, kCursorAnimationNone);
+ else
+ getCursor()->set(getWorld()->graphicResourceIds[33]);
+ }
+ }
+}
+
} // End of namespace Asylum
diff --git a/engines/asylum/puzzles/board.h b/engines/asylum/puzzles/board.h
index 0d44d874fb..2a6a1e3842 100644
--- a/engines/asylum/puzzles/board.h
+++ b/engines/asylum/puzzles/board.h
@@ -95,7 +95,7 @@ private:
void playSound();
int32 findRect();
int32 checkMouse();
- virtual void updateCursor();
+ void updateCursor();
};
} // End of namespace Asylum
Commit: aefb29447f46846f578b2b8d5d8c251f80885d41
https://github.com/scummvm/scummvm/commit/aefb29447f46846f578b2b8d5d8c251f80885d41
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:51+02:00
Commit Message:
ASYLUM: Implement PuzzleBoard::init()
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@765 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/puzzles/board.cpp
engines/asylum/puzzles/board.h
engines/asylum/puzzles/boardkeyhidesto.cpp
engines/asylum/puzzles/boardkeyhidesto.h
engines/asylum/puzzles/boardsalvation.cpp
engines/asylum/puzzles/boardsalvation.h
engines/asylum/puzzles/boardyouth.cpp
engines/asylum/puzzles/boardyouth.h
diff --git a/engines/asylum/puzzles/board.cpp b/engines/asylum/puzzles/board.cpp
index d93b2dbeaa..8e4dbf2418 100644
--- a/engines/asylum/puzzles/board.cpp
+++ b/engines/asylum/puzzles/board.cpp
@@ -50,7 +50,9 @@ PuzzleBoard::PuzzleBoard(AsylumEngine *engine, PuzzleData data) : Puzzle(engine)
memset(&_text, 0, sizeof(_text));
memset(&_charUsed, 0, sizeof(_charUsed));
memset(&_solvedText, 0, sizeof(_solvedText));
+ _rectIndex = -2;
_soundResourceId = kResourceNone;
+ _data_456958 = -1;
}
void PuzzleBoard::reset() {
@@ -60,6 +62,32 @@ void PuzzleBoard::reset() {
//////////////////////////////////////////////////////////////////////////
// Event Handling
//////////////////////////////////////////////////////////////////////////
+bool PuzzleBoard::init(const AsylumEvent &evt) {
+ _rectIndex = -2;
+ _data_456958 = -1;
+ _solved = false;
+ _soundResourceId = 0;
+
+ getScreen()->setPalette(getWorld()->graphicResourceIds[32]);
+ getScreen()->setGammaLevel(getWorld()->graphicResourceIds[32], 0);
+ getText()->loadFont(getWorld()->graphicResourceIds[35]);
+
+ // Prepare text to draw
+ memset(&_text, 0, sizeof(_text));
+
+ for (uint32 i = 0; i < _data.soundResourceSize; i++) {
+ _data.soundResources[i].played = false;
+ strcat((char *)&_text, getText()->get(MAKE_RESOURCE(kResourcePackText, 1068 + _data.soundResources[i].index)));
+ strcat((char *)&_text, " ");
+ }
+
+ activate(evt);
+
+ getCursor()->show();
+
+ return true;
+}
+
bool PuzzleBoard::activate(const AsylumEvent &evt) {
getScreen()->clearGraphicsInQueue();
diff --git a/engines/asylum/puzzles/board.h b/engines/asylum/puzzles/board.h
index 2a6a1e3842..c02eec5fc0 100644
--- a/engines/asylum/puzzles/board.h
+++ b/engines/asylum/puzzles/board.h
@@ -84,6 +84,7 @@ private:
//////////////////////////////////////////////////////////////////////////
// Event Handling
//////////////////////////////////////////////////////////////////////////
+ bool init(const AsylumEvent &evt);
bool activate(const AsylumEvent &evt);
bool update(const AsylumEvent &evt);
virtual bool mouseRightDown(const AsylumEvent &evt);
diff --git a/engines/asylum/puzzles/boardkeyhidesto.cpp b/engines/asylum/puzzles/boardkeyhidesto.cpp
index e1b8ebbca8..a4b48c4a65 100644
--- a/engines/asylum/puzzles/boardkeyhidesto.cpp
+++ b/engines/asylum/puzzles/boardkeyhidesto.cpp
@@ -53,10 +53,6 @@ PuzzleBoardKeyHidesTo::PuzzleBoardKeyHidesTo(AsylumEngine *engine) : PuzzleBoard
//////////////////////////////////////////////////////////////////////////
// Event Handling
//////////////////////////////////////////////////////////////////////////
-bool PuzzleBoardKeyHidesTo::init(const AsylumEvent &evt) {
- error("[PuzzleBoardKeyHidesTo::init] Not implemented!");
-}
-
bool PuzzleBoardKeyHidesTo::mouseLeftDown(const AsylumEvent &evt) {
error("[PuzzleBoardKeyHidesTo::mouseLeftDown] Not implemented!");
}
diff --git a/engines/asylum/puzzles/boardkeyhidesto.h b/engines/asylum/puzzles/boardkeyhidesto.h
index 9577232ec7..0cc2b09062 100644
--- a/engines/asylum/puzzles/boardkeyhidesto.h
+++ b/engines/asylum/puzzles/boardkeyhidesto.h
@@ -40,7 +40,6 @@ private:
//////////////////////////////////////////////////////////////////////////
// Event Handling
//////////////////////////////////////////////////////////////////////////
- bool init(const AsylumEvent &evt);
bool mouseLeftDown(const AsylumEvent &evt);
};
diff --git a/engines/asylum/puzzles/boardsalvation.cpp b/engines/asylum/puzzles/boardsalvation.cpp
index df14e8fd68..1f83cff452 100644
--- a/engines/asylum/puzzles/boardsalvation.cpp
+++ b/engines/asylum/puzzles/boardsalvation.cpp
@@ -61,10 +61,6 @@ PuzzleBoardSalvation::PuzzleBoardSalvation(AsylumEngine *engine) : PuzzleBoard(e
//////////////////////////////////////////////////////////////////////////
// Event Handling
//////////////////////////////////////////////////////////////////////////
-bool PuzzleBoardSalvation::init(const AsylumEvent &evt) {
- error("[PuzzleBoardSalvation::init] Not implemented!");
-}
-
bool PuzzleBoardSalvation::mouseLeftDown(const AsylumEvent &evt) {
error("[PuzzleBoardSalvation::mouseLeftDown] Not implemented!");
}
diff --git a/engines/asylum/puzzles/boardsalvation.h b/engines/asylum/puzzles/boardsalvation.h
index 22394232c0..219e63f4e4 100644
--- a/engines/asylum/puzzles/boardsalvation.h
+++ b/engines/asylum/puzzles/boardsalvation.h
@@ -40,7 +40,6 @@ private:
//////////////////////////////////////////////////////////////////////////
// Event Handling
//////////////////////////////////////////////////////////////////////////
- bool init(const AsylumEvent &evt);
bool mouseLeftDown(const AsylumEvent &evt);
bool mouseRightDown(const AsylumEvent &evt);
diff --git a/engines/asylum/puzzles/boardyouth.cpp b/engines/asylum/puzzles/boardyouth.cpp
index 9ec73d4829..c474952405 100644
--- a/engines/asylum/puzzles/boardyouth.cpp
+++ b/engines/asylum/puzzles/boardyouth.cpp
@@ -51,10 +51,6 @@ PuzzleBoardYouth::PuzzleBoardYouth(AsylumEngine *engine) : PuzzleBoard(engine, p
//////////////////////////////////////////////////////////////////////////
// Event Handling
//////////////////////////////////////////////////////////////////////////
-bool PuzzleBoardYouth::init(const AsylumEvent &evt) {
- error("[PuzzleBoardYouth::init] Not implemented!");
-}
-
bool PuzzleBoardYouth::mouseLeftDown(const AsylumEvent &evt) {
error("[PuzzleBoardYouth::mouseLeftDown] Not implemented!");
}
diff --git a/engines/asylum/puzzles/boardyouth.h b/engines/asylum/puzzles/boardyouth.h
index 357a6f1cd5..36c7f5a1e5 100644
--- a/engines/asylum/puzzles/boardyouth.h
+++ b/engines/asylum/puzzles/boardyouth.h
@@ -40,7 +40,6 @@ private:
//////////////////////////////////////////////////////////////////////////
// Event Handling
//////////////////////////////////////////////////////////////////////////
- bool init(const AsylumEvent &evt);
bool mouseLeftDown(const AsylumEvent &evt);
};
Commit: 62f092c54d51cddbab2e3f6d05b942621991e248
https://github.com/scummvm/scummvm/commit/62f092c54d51cddbab2e3f6d05b942621991e248
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:51+02:00
Commit Message:
ASYLUM: Add missing check in PuzzleBoard::update()
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@766 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/puzzles/board.cpp
engines/asylum/puzzles/board.h
engines/asylum/puzzles/boardkeyhidesto.cpp
engines/asylum/puzzles/boardsalvation.cpp
engines/asylum/puzzles/boardyouth.cpp
diff --git a/engines/asylum/puzzles/board.cpp b/engines/asylum/puzzles/board.cpp
index 8e4dbf2418..8e86024a92 100644
--- a/engines/asylum/puzzles/board.cpp
+++ b/engines/asylum/puzzles/board.cpp
@@ -106,8 +106,10 @@ bool PuzzleBoard::update(const AsylumEvent &evt) {
if (!_solved)
playSound();
-
if (_vm->isGameFlagNotSet(_data.gameFlag)) {
+ if (strcmp(_solvedText, _data.solvedText))
+ return true;
+
if (_solved) {
if (!getSound()->isPlaying(MAKE_RESOURCE(kResourcePackSpeech, 1))) {
_vm->setGameFlag(_data.gameFlag);
diff --git a/engines/asylum/puzzles/board.h b/engines/asylum/puzzles/board.h
index c02eec5fc0..991e2f419c 100644
--- a/engines/asylum/puzzles/board.h
+++ b/engines/asylum/puzzles/board.h
@@ -55,6 +55,7 @@ public:
uint32 charMapSize;
CharMap charMap[10];
bool checkForSpace;
+ char solvedText[28];
};
PuzzleBoard(AsylumEngine *engine);
diff --git a/engines/asylum/puzzles/boardkeyhidesto.cpp b/engines/asylum/puzzles/boardkeyhidesto.cpp
index a4b48c4a65..69ac81912e 100644
--- a/engines/asylum/puzzles/boardkeyhidesto.cpp
+++ b/engines/asylum/puzzles/boardkeyhidesto.cpp
@@ -44,7 +44,8 @@ static const PuzzleBoard::PuzzleData puzzleKeyHidesToData = {
{'K', Common::Point(210, 215)},
{'Y', Common::Point(440, 247)},
{'T', Common::Point(479, 262)}},
- true
+ true,
+ "K E Y H I D E S T O "
};
PuzzleBoardKeyHidesTo::PuzzleBoardKeyHidesTo(AsylumEngine *engine) : PuzzleBoard(engine, puzzleKeyHidesToData) {
diff --git a/engines/asylum/puzzles/boardsalvation.cpp b/engines/asylum/puzzles/boardsalvation.cpp
index 1f83cff452..610c701c16 100644
--- a/engines/asylum/puzzles/boardsalvation.cpp
+++ b/engines/asylum/puzzles/boardsalvation.cpp
@@ -50,7 +50,8 @@ static const PuzzleBoard::PuzzleData puzzleSalvationData = {
{'T', Common::Point(436, 229)},
{'O', Common::Point(172, 262)},
{'N', Common::Point(393, 296)}},
- false
+ false,
+ "S A L V A T I O N "
};
static const uint32 puzzleSalvationSoundResourceIndex[11] = {5, 6, 7, 10, 11, 28, 29, 30, 31, 32, 36};
diff --git a/engines/asylum/puzzles/boardyouth.cpp b/engines/asylum/puzzles/boardyouth.cpp
index c474952405..d5811f3ffc 100644
--- a/engines/asylum/puzzles/boardyouth.cpp
+++ b/engines/asylum/puzzles/boardyouth.cpp
@@ -42,7 +42,8 @@ static const PuzzleBoard::PuzzleData puzzleYouthData = {
{'T', Common::Point(223, 181)},
{'H', Common::Point(497, 198)},
{'Y', Common::Point(435, 231)}},
- true
+ true,
+ "T H E Y O U T H "
};
PuzzleBoardYouth::PuzzleBoardYouth(AsylumEngine *engine) : PuzzleBoard(engine, puzzleYouthData) {
Commit: 6a5257f0ce239b6b64f57681627a24f8017a8169
https://github.com/scummvm/scummvm/commit/6a5257f0ce239b6b64f57681627a24f8017a8169
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:51+02:00
Commit Message:
ASYLUM: Implement PuzzleBoardSalvation::mouseLeftDown()
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@767 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/puzzles/board.cpp
engines/asylum/puzzles/board.h
engines/asylum/puzzles/boardsalvation.cpp
diff --git a/engines/asylum/puzzles/board.cpp b/engines/asylum/puzzles/board.cpp
index 8e86024a92..3227761f08 100644
--- a/engines/asylum/puzzles/board.cpp
+++ b/engines/asylum/puzzles/board.cpp
@@ -47,16 +47,17 @@ PuzzleBoard::PuzzleBoard(AsylumEngine *engine, PuzzleData data) : Puzzle(engine)
// Init board
_solved = false;
- memset(&_text, 0, sizeof(_text));
- memset(&_charUsed, 0, sizeof(_charUsed));
- memset(&_solvedText, 0, sizeof(_solvedText));
+ memset(&_text, 0, sizeof(_text));
+ memset(&_charUsed, false, sizeof(_charUsed));
+ memset(&_solvedText, 0, sizeof(_solvedText));
_rectIndex = -2;
_soundResourceId = kResourceNone;
- _data_456958 = -1;
+ _selectedSlot = -1;
+ _position = 0;
}
void PuzzleBoard::reset() {
- memset(&_charUsed, 0, sizeof(_charUsed));
+ memset(&_charUsed, false, sizeof(_charUsed));
}
//////////////////////////////////////////////////////////////////////////
@@ -64,7 +65,7 @@ void PuzzleBoard::reset() {
//////////////////////////////////////////////////////////////////////////
bool PuzzleBoard::init(const AsylumEvent &evt) {
_rectIndex = -2;
- _data_456958 = -1;
+ _selectedSlot = -1;
_solved = false;
_soundResourceId = 0;
@@ -81,14 +82,14 @@ bool PuzzleBoard::init(const AsylumEvent &evt) {
strcat((char *)&_text, " ");
}
- activate(evt);
+ updateScreen();
getCursor()->show();
return true;
}
-bool PuzzleBoard::activate(const AsylumEvent &evt) {
+bool PuzzleBoard::updateScreen() {
getScreen()->clearGraphicsInQueue();
getScreen()->draw(getWorld()->graphicResourceIds[_data.backgroundIndex]);
@@ -159,7 +160,7 @@ void PuzzleBoard::drawText() {
if (!_solvedText[index])
break;
- getText()->setPosition(x, _data_456958 != index ? 360 : 370);
+ getText()->setPosition(x, _selectedSlot != index ? 360 : 370);
getText()->drawChar(_solvedText[index]);
index += 2;
diff --git a/engines/asylum/puzzles/board.h b/engines/asylum/puzzles/board.h
index 991e2f419c..754ad2e4fc 100644
--- a/engines/asylum/puzzles/board.h
+++ b/engines/asylum/puzzles/board.h
@@ -66,17 +66,18 @@ public:
protected:
bool _solved;
char _text[800];
- int32 _charUsed[20];
+ bool _charUsed[20];
char _solvedText[28]; // KeyHidesTo uses 28 chars, the other puzzles 20
+ uint32 _position;
int32 _rectIndex;
+ int32 _selectedSlot;
ResourceId _soundResourceId;
- //Common::Array<PuzzleSoundResource> _soundResources;
-
- int32 _data_456958;
//////////////////////////////////////////////////////////////////////////
// Helpers
//////////////////////////////////////////////////////////////////////////
+ bool updateScreen();
+ int32 findRect();
bool stopSound();
private:
@@ -86,7 +87,7 @@ private:
// Event Handling
//////////////////////////////////////////////////////////////////////////
bool init(const AsylumEvent &evt);
- bool activate(const AsylumEvent &evt);
+ bool activate(const AsylumEvent &evt) { return updateScreen(); }
bool update(const AsylumEvent &evt);
virtual bool mouseRightDown(const AsylumEvent &evt);
@@ -95,7 +96,6 @@ private:
//////////////////////////////////////////////////////////////////////////
void drawText();
void playSound();
- int32 findRect();
int32 checkMouse();
void updateCursor();
};
diff --git a/engines/asylum/puzzles/boardsalvation.cpp b/engines/asylum/puzzles/boardsalvation.cpp
index 610c701c16..9b2cecb3bd 100644
--- a/engines/asylum/puzzles/boardsalvation.cpp
+++ b/engines/asylum/puzzles/boardsalvation.cpp
@@ -25,6 +25,7 @@
#include "asylum/puzzles/boardsalvation.h"
+#include "asylum/system/cursor.h"
#include "asylum/system/screen.h"
#include "asylum/system/sound.h"
@@ -63,7 +64,36 @@ PuzzleBoardSalvation::PuzzleBoardSalvation(AsylumEngine *engine) : PuzzleBoard(e
// Event Handling
//////////////////////////////////////////////////////////////////////////
bool PuzzleBoardSalvation::mouseLeftDown(const AsylumEvent &evt) {
- error("[PuzzleBoardSalvation::mouseLeftDown] Not implemented!");
+ Common::Point mousePos = getCursor()->position();
+
+ if (mousePos.y <= 350) {
+ int32 index = findRect();
+
+ if (index != -1 && _position < 18) {
+ _charUsed[index] = true;
+ _selectedSlot = -1;
+
+ _solvedText[_position++] = puzzleSalvationData.charMap[index].character;
+ _solvedText[_position++] = ' ';
+
+ updateScreen();
+ }
+ } else if (_vm->isGameFlagNotSet(kGameFlag281)) {
+ if (mousePos.x >= 215 && mousePos.x < 431 && mousePos.y >= 360 && mousePos.y < 376) {
+ int32 index = (mousePos.x - 215) / 12;
+
+ if (_solvedText[index]) {
+ if (_selectedSlot == -1)
+ _selectedSlot = index;
+ else
+ SWAP(_solvedText[index], _solvedText[_selectedSlot]);
+
+ updateScreen();
+ }
+ }
+ }
+
+ return true;
}
bool PuzzleBoardSalvation::mouseRightDown(const AsylumEvent &evt) {
Commit: 98e29bbe0e429dd0abef2d2bb9eef76c618e1259
https://github.com/scummvm/scummvm/commit/98e29bbe0e429dd0abef2d2bb9eef76c618e1259
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:51+02:00
Commit Message:
ASYLUM: Implement mouseLeftDown() function for KeyHidesTo and Youth board puzzles
- Add new shared function PuzzleBoard::checkSlots()
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@768 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/puzzles/board.cpp
engines/asylum/puzzles/board.h
engines/asylum/puzzles/boardkeyhidesto.cpp
engines/asylum/puzzles/boardsalvation.cpp
engines/asylum/puzzles/boardyouth.cpp
diff --git a/engines/asylum/puzzles/board.cpp b/engines/asylum/puzzles/board.cpp
index 3227761f08..58d8def419 100644
--- a/engines/asylum/puzzles/board.cpp
+++ b/engines/asylum/puzzles/board.cpp
@@ -266,4 +266,24 @@ void PuzzleBoard::updateCursor() {
}
}
+void PuzzleBoard::checkSlots() {
+ Common::Point mousePos = getCursor()->position();
+
+ if (mousePos.x >= 215 && mousePos.x < (int16)_data.maxWidth && mousePos.y >= 360 && mousePos.y < 376) {
+ int32 index = (mousePos.x - 215) / 12;
+
+ if (_solvedText[index]) {
+ if (_data.checkForSpace && _solvedText[index] == ' ')
+ return;
+
+ if (_selectedSlot == -1)
+ _selectedSlot = index;
+ else
+ SWAP(_solvedText[index], _solvedText[_selectedSlot]);
+
+ updateScreen();
+ }
+ }
+}
+
} // End of namespace Asylum
diff --git a/engines/asylum/puzzles/board.h b/engines/asylum/puzzles/board.h
index 754ad2e4fc..79c0d2f8f8 100644
--- a/engines/asylum/puzzles/board.h
+++ b/engines/asylum/puzzles/board.h
@@ -79,6 +79,7 @@ protected:
bool updateScreen();
int32 findRect();
bool stopSound();
+ void checkSlots();
private:
PuzzleData _data;
diff --git a/engines/asylum/puzzles/boardkeyhidesto.cpp b/engines/asylum/puzzles/boardkeyhidesto.cpp
index 69ac81912e..a34262b5b0 100644
--- a/engines/asylum/puzzles/boardkeyhidesto.cpp
+++ b/engines/asylum/puzzles/boardkeyhidesto.cpp
@@ -25,6 +25,10 @@
#include "asylum/puzzles/boardkeyhidesto.h"
+#include "asylum/system/cursor.h"
+
+#include "asylum/asylum.h"
+
namespace Asylum {
static const PuzzleBoard::PuzzleData puzzleKeyHidesToData = {
@@ -55,7 +59,31 @@ PuzzleBoardKeyHidesTo::PuzzleBoardKeyHidesTo(AsylumEngine *engine) : PuzzleBoard
// Event Handling
//////////////////////////////////////////////////////////////////////////
bool PuzzleBoardKeyHidesTo::mouseLeftDown(const AsylumEvent &evt) {
- error("[PuzzleBoardKeyHidesTo::mouseLeftDown] Not implemented!");
+ Common::Point mousePos = getCursor()->position();
+
+ if (mousePos.y <= 350) {
+ int32 index = findRect();
+
+ if (index != -1 && _position < 24) {
+ _charUsed[index] = true;
+ _selectedSlot = -1;
+
+ _solvedText[_position++] = puzzleKeyHidesToData.charMap[index].character;
+ _solvedText[_position++] = ' ';
+
+ if (_position == 5 || _position == 18) {
+ _solvedText[++_position] = ' ';
+ _solvedText[++_position] = ' ';
+ ++_position;
+ }
+
+ updateScreen();
+ }
+ } else if (_vm->isGameFlagNotSet(kGameFlag283)) {
+ checkSlots();
+ }
+
+ return true;
}
} // End of namespace Asylum
diff --git a/engines/asylum/puzzles/boardsalvation.cpp b/engines/asylum/puzzles/boardsalvation.cpp
index 9b2cecb3bd..e642feccd3 100644
--- a/engines/asylum/puzzles/boardsalvation.cpp
+++ b/engines/asylum/puzzles/boardsalvation.cpp
@@ -79,18 +79,7 @@ bool PuzzleBoardSalvation::mouseLeftDown(const AsylumEvent &evt) {
updateScreen();
}
} else if (_vm->isGameFlagNotSet(kGameFlag281)) {
- if (mousePos.x >= 215 && mousePos.x < 431 && mousePos.y >= 360 && mousePos.y < 376) {
- int32 index = (mousePos.x - 215) / 12;
-
- if (_solvedText[index]) {
- if (_selectedSlot == -1)
- _selectedSlot = index;
- else
- SWAP(_solvedText[index], _solvedText[_selectedSlot]);
-
- updateScreen();
- }
- }
+ checkSlots();
}
return true;
diff --git a/engines/asylum/puzzles/boardyouth.cpp b/engines/asylum/puzzles/boardyouth.cpp
index d5811f3ffc..48b19c828c 100644
--- a/engines/asylum/puzzles/boardyouth.cpp
+++ b/engines/asylum/puzzles/boardyouth.cpp
@@ -25,6 +25,10 @@
#include "asylum/puzzles/boardyouth.h"
+#include "asylum/system/cursor.h"
+
+#include "asylum/asylum.h"
+
namespace Asylum {
static const PuzzleBoard::PuzzleData puzzleYouthData = {
@@ -53,7 +57,31 @@ PuzzleBoardYouth::PuzzleBoardYouth(AsylumEngine *engine) : PuzzleBoard(engine, p
// Event Handling
//////////////////////////////////////////////////////////////////////////
bool PuzzleBoardYouth::mouseLeftDown(const AsylumEvent &evt) {
- error("[PuzzleBoardYouth::mouseLeftDown] Not implemented!");
+ Common::Point mousePos = getCursor()->position();
+
+ if (mousePos.y <= 350) {
+ int32 index = findRect();
+
+ if (index != -1 && _position < 18) {
+ _charUsed[index] = true;
+ _selectedSlot = -1;
+
+ _solvedText[_position++] = puzzleYouthData.charMap[index].character;
+ _solvedText[_position++] = ' ';
+
+ if (_position == 5) {
+ _solvedText[++_position] = ' ';
+ _solvedText[++_position] = ' ';
+ ++_position;
+ }
+
+ updateScreen();
+ }
+ } else if (_vm->isGameFlagNotSet(kGameFlag282)) {
+ checkSlots();
+ }
+
+ return true;
}
} // End of namespace Asylum
Commit: ebb7bc6673c923c53291f38eb4899b541bda9744
https://github.com/scummvm/scummvm/commit/ebb7bc6673c923c53291f38eb4899b541bda9744
Author: Filippos Karapetis (md5 at scummvm.org)
Date: 2021-05-17T15:36:51+02:00
Commit Message:
ASYLUM: Sync with trunk
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@769 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/asylum.cpp
engines/asylum/asylum.h
engines/asylum/puzzles/puzzle.h
engines/asylum/views/scene.h
engines/asylum/views/video.cpp
engines/asylum/views/video.h
diff --git a/engines/asylum/asylum.cpp b/engines/asylum/asylum.cpp
index d7d3e6096a..78e3c9dfa4 100644
--- a/engines/asylum/asylum.cpp
+++ b/engines/asylum/asylum.cpp
@@ -153,7 +153,7 @@ Common::Error AsylumEngine::run() {
_special = new Special(this);
_speech = new Speech(this);
_text = new Text(this);
- _video = new Video(this, _mixer);
+ _video = new VideoPlayer(this, _mixer);
initPuzzles();
// Init tables
diff --git a/engines/asylum/asylum.h b/engines/asylum/asylum.h
index f35096e927..a62a531132 100644
--- a/engines/asylum/asylum.h
+++ b/engines/asylum/asylum.h
@@ -79,7 +79,7 @@ class Special;
class Speech;
class Sound;
class Text;
-class Video;
+class VideoPlayer;
class AsylumEngine: public Engine, public Common::Serializable {
protected:
@@ -159,7 +159,7 @@ public:
Speech *speech() { return _speech; }
Sound *sound() { return _sound; }
Text *text() { return _text; }
- Video *video() { return _video; }
+ VideoPlayer *video() { return _video; }
SharedData *data() { return &_data; }
PuzzleData *puzzleData() { return &_puzzleData; }
@@ -239,7 +239,7 @@ private:
Speech *_speech;
Sound *_sound;
Text *_text;
- Video *_video;
+ VideoPlayer *_video;
// Current EventHandler class instance
EventHandler *_handler;
diff --git a/engines/asylum/puzzles/puzzle.h b/engines/asylum/puzzles/puzzle.h
index d8ad35571a..e40d1db192 100644
--- a/engines/asylum/puzzles/puzzle.h
+++ b/engines/asylum/puzzles/puzzle.h
@@ -36,7 +36,7 @@ namespace Asylum {
class AsylumEngine;
class Screen;
class Sound;
-class Video;
+class VideoPlayer;
class Cursor;
class GraphicResource;
struct GraphicQueueItem;
diff --git a/engines/asylum/views/scene.h b/engines/asylum/views/scene.h
index 3e1dd1bde8..4149a776a0 100644
--- a/engines/asylum/views/scene.h
+++ b/engines/asylum/views/scene.h
@@ -52,7 +52,7 @@ class Special;
class Speech;
class Sound;
class Text;
-class Video;
+class VideoPlayer;
class WorldStats;
struct ActionArea;
diff --git a/engines/asylum/views/video.cpp b/engines/asylum/views/video.cpp
index a2fbc25dc9..f8e5295323 100644
--- a/engines/asylum/views/video.cpp
+++ b/engines/asylum/views/video.cpp
@@ -39,12 +39,12 @@
namespace Asylum {
-Video::Video(AsylumEngine *engine, Audio::Mixer *mixer) : _vm(engine),
+VideoPlayer::VideoPlayer(AsylumEngine *engine, Audio::Mixer *mixer) : _vm(engine),
_currentMovie(0), _subtitleIndex(0), _subtitleCounter(0), _previousFont(kResourceNone), _done(false) {
- _smkDecoder = new Graphics::SmackerDecoder(mixer);
+ _smkDecoder = new Video::SmackerDecoder(mixer);
}
-Video::~Video() {
+VideoPlayer::~VideoPlayer() {
delete _smkDecoder;
// Zero-out passed pointers
@@ -54,7 +54,7 @@ Video::~Video() {
//////////////////////////////////////////////////////////////////////////
// Event Handler
//////////////////////////////////////////////////////////////////////////
-bool Video::handleEvent(const AsylumEvent &evt) {
+bool VideoPlayer::handleEvent(const AsylumEvent &evt) {
switch ((uint32)evt.type) {
default:
break;
@@ -113,7 +113,7 @@ bool Video::handleEvent(const AsylumEvent &evt) {
//////////////////////////////////////////////////////////////////////////
// Playing
//////////////////////////////////////////////////////////////////////////
-void Video::play(int32 videoNumber, EventHandler *handler) {
+void VideoPlayer::play(int32 videoNumber, EventHandler *handler) {
getSaveLoad()->setMovieViewed(videoNumber);
_currentMovie = videoNumber;
@@ -133,7 +133,7 @@ void Video::play(int32 videoNumber, EventHandler *handler) {
_vm->switchEventHandler(handler);
}
-void Video::play(Common::String filename, bool showSubtitles) {
+void VideoPlayer::play(Common::String filename, bool showSubtitles) {
if (!_smkDecoder->loadFile(filename))
error("[Video::playVideo] Invalid video index (%d)", _currentMovie);
@@ -199,14 +199,14 @@ void Video::play(Common::String filename, bool showSubtitles) {
_subtitles.clear();
}
-void Video::setupPalette() {
+void VideoPlayer::setupPalette() {
_smkDecoder->setSystemPalette();
warning("[Video::setupPalette] Video palette setup not implemented!");
//getScreen()->setupPalette(0, 0, 0);
}
-void Video::loadSubtitles() {
+void VideoPlayer::loadSubtitles() {
char movieToken[10];
sprintf(movieToken, "[MOV%03d]", _currentMovie);
diff --git a/engines/asylum/views/video.h b/engines/asylum/views/video.h
index 926516ef45..1199b8bf29 100644
--- a/engines/asylum/views/video.h
+++ b/engines/asylum/views/video.h
@@ -35,7 +35,7 @@
#include "common/list.h"
#include "graphics/surface.h"
-#include "graphics/video/smk_decoder.h"
+#include "video/smk_decoder.h"
#include "sound/mixer.h"
@@ -52,10 +52,10 @@ struct VideoSubtitle {
ResourceId resourceId;
};
-class Video : public EventHandler {
+class VideoPlayer : public EventHandler {
public:
- Video(AsylumEngine *engine, Audio::Mixer *mixer);
- virtual ~Video();
+ VideoPlayer(AsylumEngine *engine, Audio::Mixer *mixer);
+ virtual ~VideoPlayer();
/**
* Plays a video.
@@ -77,7 +77,7 @@ public:
private:
AsylumEngine *_vm;
- Graphics::SmackerDecoder *_smkDecoder;
+ Video::SmackerDecoder *_smkDecoder;
Common::Array<VideoSubtitle> _subtitles;
int32 _currentMovie;
Commit: ec55db749408533d4bcdc42ecc224bbce8f02134
https://github.com/scummvm/scummvm/commit/ec55db749408533d4bcdc42ecc224bbce8f02134
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:52+02:00
Commit Message:
ASYLUM: Fix some invalid array accesses, a missing array delete and a potential NULL pointer use
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@770 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/asylum.h
engines/asylum/puzzles/fisherman.cpp
engines/asylum/system/savegame.cpp
engines/asylum/views/menu.cpp
diff --git a/engines/asylum/asylum.h b/engines/asylum/asylum.h
index a62a531132..dcf30c4e46 100644
--- a/engines/asylum/asylum.h
+++ b/engines/asylum/asylum.h
@@ -243,7 +243,7 @@ private:
// Current EventHandler class instance
EventHandler *_handler;
- Puzzle *_puzzles[16];
+ Puzzle *_puzzles[17];
// Game data
PuzzleData _puzzleData;
diff --git a/engines/asylum/puzzles/fisherman.cpp b/engines/asylum/puzzles/fisherman.cpp
index 9be97ded05..f8fbba491e 100644
--- a/engines/asylum/puzzles/fisherman.cpp
+++ b/engines/asylum/puzzles/fisherman.cpp
@@ -109,7 +109,7 @@ bool PuzzleFisherman::update(const AsylumEvent &evt) {
getScreen()->draw(getWorld()->graphicResourceIds[38]);
// Draw 7 graphics
- for (uint32 i = 0; i < 7; i++) {
+ for (uint32 i = 0; i < 6; i++) {
if (_state[i])
getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[40 + i], 0, puzzleFishermanPolygons[i], 0, 0, 1);
}
@@ -154,7 +154,7 @@ bool PuzzleFisherman::mouseLeftDown(const AsylumEvent &evt) {
if (!_dword_45A130)
return false;
- for (uint32 i = 0; i < 7; i++) {
+ for (uint32 i = 0; i < 6; i++) {
if (hitTest(&puzzleFishermanPolygons[i * 4 + 7], evt.mouse)) {
if (!_state[i]) {
getSound()->playSound(getWorld()->graphicResourceIds[9], false, Config.sfxVolume - 10);
diff --git a/engines/asylum/system/savegame.cpp b/engines/asylum/system/savegame.cpp
index 2852e0f210..20eae1ebb0 100644
--- a/engines/asylum/system/savegame.cpp
+++ b/engines/asylum/system/savegame.cpp
@@ -346,7 +346,7 @@ Common::String Savegame::read(Common::InSaveFile *file, uint32 strLength, Common
Common::String ret(str);
- delete str;
+ delete[] str;
return ret;
}
diff --git a/engines/asylum/views/menu.cpp b/engines/asylum/views/menu.cpp
index a19d580281..ec742d7a0a 100644
--- a/engines/asylum/views/menu.cpp
+++ b/engines/asylum/views/menu.cpp
@@ -2029,7 +2029,8 @@ void Menu::clickAudioOptions() {
if (cursor.x < 360 || cursor.x > (360 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 1431))) || cursor.y < 360 || cursor.y > (360 + 24)) {
int32 volumeIndex = 0;
- int32 *volume = NULL;
+ int32 defaultVolume = 0;
+ int32 *volume = &defaultVolume;
bool found = false;
for (;;) {
Commit: 62098ed51e725b7b302a5aee2c4d49fc9e995479
https://github.com/scummvm/scummvm/commit/62098ed51e725b7b302a5aee2c4d49fc9e995479
Author: Filippos Karapetis (md5 at scummvm.org)
Date: 2021-05-17T15:36:52+02:00
Commit Message:
ASYLUM: Sync with the latest changes in trunk
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@771 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/system/screen.cpp
diff --git a/engines/asylum/system/screen.cpp b/engines/asylum/system/screen.cpp
index 04848e960e..ff18163325 100644
--- a/engines/asylum/system/screen.cpp
+++ b/engines/asylum/system/screen.cpp
@@ -213,7 +213,7 @@ void Screen::setPalette(byte *rgbPalette) const {
palette[i * 4 + 3] = 0;
}
- _vm->_system->setPalette(palette, 0, 256);
+ _vm->_system->getPaletteManager()->setPalette(palette, 0, 256);
}
void Screen::setPaletteGamma(ResourceId id) {
Commit: 2487a6e70b001e764f543cc9e6958eb5c4f7547e
https://github.com/scummvm/scummvm/commit/2487a6e70b001e764f543cc9e6958eb5c4f7547e
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:52+02:00
Commit Message:
ASYLUM: Sync with sound/ to audio/ changes on trunk
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@772 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/system/sound.cpp
engines/asylum/system/sound.h
engines/asylum/views/video.h
diff --git a/engines/asylum/system/sound.cpp b/engines/asylum/system/sound.cpp
index a86d586b78..cdb68e1b46 100644
--- a/engines/asylum/system/sound.cpp
+++ b/engines/asylum/system/sound.cpp
@@ -37,9 +37,9 @@
#include "common/memstream.h"
-#include "sound/audiostream.h"
-#include "sound/decoders/adpcm.h"
-#include "sound/decoders/wave.h"
+#include "audio/audiostream.h"
+#include "audio/decoders/adpcm.h"
+#include "audio/decoders/wave.h"
namespace Asylum {
diff --git a/engines/asylum/system/sound.h b/engines/asylum/system/sound.h
index 7701ea4a96..551b21da08 100644
--- a/engines/asylum/system/sound.h
+++ b/engines/asylum/system/sound.h
@@ -32,7 +32,7 @@
#include "common/array.h"
-#include "sound/mixer.h"
+#include "audio/mixer.h"
namespace Asylum {
diff --git a/engines/asylum/views/video.h b/engines/asylum/views/video.h
index 1199b8bf29..d1f048be23 100644
--- a/engines/asylum/views/video.h
+++ b/engines/asylum/views/video.h
@@ -34,10 +34,11 @@
#include "common/system.h"
#include "common/list.h"
+#include "audio/mixer.h"
+
#include "graphics/surface.h"
-#include "video/smk_decoder.h"
-#include "sound/mixer.h"
+#include "video/smk_decoder.h"
namespace Asylum {
@@ -58,10 +59,10 @@ public:
virtual ~VideoPlayer();
/**
- * Plays a video.
+ * Plays a video.
*
- * @param videoNumber The video number.
- * @param handler The previous event handler.
+ * @param videoNumber The video number.
+ * @param handler The previous event handler.
*/
void play(int32 videoNumber, EventHandler *handler);
@@ -78,7 +79,7 @@ private:
AsylumEngine *_vm;
Video::SmackerDecoder *_smkDecoder;
- Common::Array<VideoSubtitle> _subtitles;
+ Common::Array<VideoSubtitle> _subtitles;
int32 _currentMovie;
int32 _subtitleIndex;
@@ -86,17 +87,17 @@ private:
ResourceId _previousFont;
bool _done;
-
+
/**
- * Plays the given file.
+ * Plays the given file.
*
- * @param filename Filename of the file.
- * @param showSubtitles true to show, false to hide the subtitles.
+ * @param filename Filename of the file.
+ * @param showSubtitles true to show, false to hide the subtitles.
*/
void play(Common::String filename, bool showSubtitles);
/**
- * Sets up the palette.
+ * Sets up the palette.
*/
void setupPalette();
Commit: aaba66f5b40c448aac77905c11c94df6945d843d
https://github.com/scummvm/scummvm/commit/aaba66f5b40c448aac77905c11c94df6945d843d
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:52+02:00
Commit Message:
ASYLUM: Sync with palette changes on trunk
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@773 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/system/screen.cpp
diff --git a/engines/asylum/system/screen.cpp b/engines/asylum/system/screen.cpp
index ff18163325..5491201499 100644
--- a/engines/asylum/system/screen.cpp
+++ b/engines/asylum/system/screen.cpp
@@ -199,18 +199,17 @@ void Screen::setPalette(ResourceId id) {
}
void Screen::setPalette(byte *rgbPalette) const {
- byte palette[256 * 4];
+ byte palette[256 * 3];
byte *p = rgbPalette;
// skip first color and set it to black always.
- memset(palette, 0, 4);
+ memset(palette, 0, 3);
p += 3;
for (int32 i = 1; i < 256; i++) {
- palette[i * 4 + 0] = (byte)(*p++ << 2);
- palette[i * 4 + 1] = (byte)(*p++ << 2);
- palette[i * 4 + 2] = (byte)(*p++ << 2);
- palette[i * 4 + 3] = 0;
+ palette[i * 3 + 0] = (byte)(*p++ << 2);
+ palette[i * 3 + 1] = (byte)(*p++ << 2);
+ palette[i * 3 + 2] = (byte)(*p++ << 2);
}
_vm->_system->getPaletteManager()->setPalette(palette, 0, 256);
Commit: 493593bf3eaec2b8258639a24da4ad71ea0cf7a1
https://github.com/scummvm/scummvm/commit/493593bf3eaec2b8258639a24da4ad71ea0cf7a1
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:52+02:00
Commit Message:
ASYLUM: Fix signed comparison warnings
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@774 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
Changed paths:
engines/asylum/resources/script.cpp
engines/asylum/views/menu.cpp
diff --git a/engines/asylum/resources/script.cpp b/engines/asylum/resources/script.cpp
index 94366305e1..17f8d63e48 100644
--- a/engines/asylum/resources/script.cpp
+++ b/engines/asylum/resources/script.cpp
@@ -327,7 +327,7 @@ bool ScriptManager::process() {
if (_queue.currentEntry) {
uint32 entryIndex = _queue.currentEntry;
uint32 nextIndex = _queue.entries[entryIndex].field_C;
- uint32 scriptIndex = _queue.entries[entryIndex].scriptIndex;
+ int32 scriptIndex = _queue.entries[entryIndex].scriptIndex;
if (scriptIndex != -1) {
diff --git a/engines/asylum/views/menu.cpp b/engines/asylum/views/menu.cpp
index ec742d7a0a..5169b69166 100644
--- a/engines/asylum/views/menu.cpp
+++ b/engines/asylum/views/menu.cpp
@@ -282,7 +282,7 @@ void Menu::adjustTestVolume() {
void Menu::setupMusic() {
getSound()->stopAll();
- uint32 index = getScene() ? getWorld()->musicCurrentResourceIndex : kMusicStopped;
+ int32 index = getScene() ? getWorld()->musicCurrentResourceIndex : kMusicStopped;
if (index == kMusicStopped) {
_soundResourceId = kResourceNone;
@@ -301,7 +301,7 @@ void Menu::adjustPerformance() {
getSound()->playMusic(kResourceNone, 0);
setupMusic();
- uint32 index = getScene() ? getWorld()->musicCurrentResourceIndex : kMusicStopped;
+ int32 index = getScene() ? getWorld()->musicCurrentResourceIndex : kMusicStopped;
if (index != kMusicStopped)
getSound()->playMusic(MAKE_RESOURCE(kResourcePackMusic, index));
}
Commit: 3a003ea7e654caccb789b8874dbfbc113283e627
https://github.com/scummvm/scummvm/commit/3a003ea7e654caccb789b8874dbfbc113283e627
Author: Alex Bevilacqua (alexbevi at gmail.com)
Date: 2021-05-17T15:36:52+02:00
Commit Message:
ASYLUM: fix compile (PI => M_PI)
Changed paths:
engines/asylum/resources/actor.cpp
diff --git a/engines/asylum/resources/actor.cpp b/engines/asylum/resources/actor.cpp
index e6d4518c3b..398ac95443 100644
--- a/engines/asylum/resources/actor.cpp
+++ b/engines/asylum/resources/actor.cpp
@@ -2157,7 +2157,7 @@ uint32 Actor::distance(Common::Point vec1, Common::Point vec2) {
}
uint32 Actor::angle(Common::Point vec1, Common::Point vec2) {
- int32 result = ((long)(180 - acos((double)(vec2.y - vec1.y) / distance(vec1, vec2)) * 180 / PI)) % 360;
+ int32 result = ((long)(180 - acos((double)(vec2.y - vec1.y) / distance(vec1, vec2)) * 180 / M_PI)) % 360;
if (vec1.x < vec2.x)
return 360 - result;
Commit: 57229d51ab797e6ed7c4c499774f4f3e70fd0dbe
https://github.com/scummvm/scummvm/commit/57229d51ab797e6ed7c4c499774f4f3e70fd0dbe
Author: Alex Bevilacqua (alexbevi at gmail.com)
Date: 2021-05-17T15:36:52+02:00
Commit Message:
ASYLUM: fix compilation against current master
Changed paths:
engines/asylum/asylum.cpp
engines/asylum/asylum.h
engines/asylum/system/graphics.cpp
engines/asylum/system/graphics.h
engines/asylum/system/screen.cpp
engines/asylum/system/screen.h
engines/asylum/views/scene.cpp
diff --git a/engines/asylum/asylum.cpp b/engines/asylum/asylum.cpp
index 78e3c9dfa4..93f0155b21 100644
--- a/engines/asylum/asylum.cpp
+++ b/engines/asylum/asylum.cpp
@@ -107,7 +107,7 @@ AsylumEngine::AsylumEngine(OSystem *system, const ADGameDescription *gd) : Engin
DebugMan.addDebugChannel(kDebugLevelObjects, "Objects", "Debug Object Objects");
// Initialize random number source
- g_eventRec.registerRandomSource(_rnd, "asylum");
+ _rnd = new Common::RandomSource("asylum");
}
AsylumEngine::~AsylumEngine() {
diff --git a/engines/asylum/asylum.h b/engines/asylum/asylum.h
index dcf30c4e46..16d217b5f0 100644
--- a/engines/asylum/asylum.h
+++ b/engines/asylum/asylum.h
@@ -175,8 +175,8 @@ public:
void resetFlags();
// Misc
- uint getRandom(uint max) { return _rnd.getRandomNumber(max); }
- uint getRandomBit() { return _rnd.getRandomBit(); }
+ uint getRandom(uint max) { return _rnd->getRandomNumber(max); }
+ uint getRandomBit() { return _rnd->getRandomBit(); }
/**
* Switch message handler.
@@ -224,7 +224,7 @@ private:
// Misc
Console *_console;
- Common::RandomSource _rnd;
+ Common::RandomSource *_rnd;
// Game
Cursor *_cursor;
diff --git a/engines/asylum/system/graphics.cpp b/engines/asylum/system/graphics.cpp
index ce4a41e206..39968d567a 100644
--- a/engines/asylum/system/graphics.cpp
+++ b/engines/asylum/system/graphics.cpp
@@ -150,7 +150,7 @@ void GraphicResource::init(byte *data, int32 size) {
uint16 width = READ_LE_UINT16(dataPtr);
dataPtr += 2;
- _frames[i].surface.create(width, height, 1);
+ _frames[i].surface.create(width, height, Graphics::PixelFormat::createFormatCLUT8());
memcpy(_frames[i].surface.pixels, dataPtr, (size_t)(width * height));
}
diff --git a/engines/asylum/system/graphics.h b/engines/asylum/system/graphics.h
index 6e7854babc..744d44c53b 100644
--- a/engines/asylum/system/graphics.h
+++ b/engines/asylum/system/graphics.h
@@ -29,6 +29,7 @@
#include "asylum/shared.h"
#include "graphics/surface.h"
+#include "common/rect.h"
#include "common/array.h"
diff --git a/engines/asylum/system/screen.cpp b/engines/asylum/system/screen.cpp
index 5491201499..3cf78a0080 100644
--- a/engines/asylum/system/screen.cpp
+++ b/engines/asylum/system/screen.cpp
@@ -40,7 +40,7 @@ namespace Asylum {
Screen::Screen(AsylumEngine *vm) : _vm(vm) ,
_useColorKey(false), _transTableCount(0), _transTableIndex(NULL), _transTableData(NULL), _transTableBuffer(NULL) {
- _backBuffer.create(640, 480, 1);
+ _backBuffer.create(640, 480, Graphics::PixelFormat::createFormatCLUT8());
_flag = -1;
_clipRect = Common::Rect(0, 0, 640, 480);
@@ -513,7 +513,7 @@ void Screen::copyToBackBufferClipped(Graphics::Surface *surface, int x, int y) {
_vm->screen()->copyToBackBufferWithTransparency(
((byte*)surface->pixels) +
startY * surface->pitch +
- startX * surface->bytesPerPixel,
+ startX * surface->format.bytesPerPixel,
surface->pitch,
animRect.left,
animRect.top,
diff --git a/engines/asylum/system/screen.h b/engines/asylum/system/screen.h
index 4fc90053dd..9ebdb838f8 100644
--- a/engines/asylum/system/screen.h
+++ b/engines/asylum/system/screen.h
@@ -29,7 +29,9 @@
#include "asylum/shared.h"
#include "common/array.h"
+#include "common/rect.h"
+#include "graphics/palette.h"
#include "graphics/surface.h"
namespace Asylum {
diff --git a/engines/asylum/views/scene.cpp b/engines/asylum/views/scene.cpp
index e6801517b6..e268cf342c 100644
--- a/engines/asylum/views/scene.cpp
+++ b/engines/asylum/views/scene.cpp
@@ -2642,7 +2642,7 @@ void Scene::debugShowWalkRegion(PolyDefinitions *poly) {
Graphics::Surface surface;
surface.create(poly->boundingRect.right - poly->boundingRect.left + 1,
poly->boundingRect.bottom - poly->boundingRect.top + 1,
- 1);
+ Graphics::PixelFormat::createFormatCLUT8());
// Draw all lines in Polygon
for (uint32 i = 0; i < poly->count(); i++) {
@@ -2668,7 +2668,7 @@ void Scene::debugShowPolygons() {
PolyDefinitions poly = _polygons->entries[p];
surface.create(poly.boundingRect.right - poly.boundingRect.left + 1,
poly.boundingRect.bottom - poly.boundingRect.top + 1,
- 1);
+ Graphics::PixelFormat::createFormatCLUT8());
// Draw all lines in Polygon
for (uint32 i = 0; i < poly.count(); i++) {
@@ -2697,7 +2697,7 @@ void Scene::debugShowObjects() {
if (object->flags & 0x20) {
surface.create(object->getBoundingRect()->right - object->getBoundingRect()->left + 1,
object->getBoundingRect()->bottom - object->getBoundingRect()->top + 1,
- 1);
+ Graphics::PixelFormat::createFormatCLUT8());
surface.frameRect(*object->getBoundingRect(), 0x22);
getScreen()->copyToBackBufferClipped(&surface, object->x, object->y);
}
@@ -2715,7 +2715,7 @@ void Scene::debugShowActors() {
if (a->flags & 2) {
surface.create(a->getBoundingRect()->right - a->getBoundingRect()->left + 1,
a->getBoundingRect()->bottom - a->getBoundingRect()->top + 1,
- 1);
+ Graphics::PixelFormat::createFormatCLUT8());
surface.frameRect(*a->getBoundingRect(), 0x22);
getScreen()->copyToBackBufferClipped(&surface, a->getPoint()->x, a->getPoint()->y);
}
Commit: baa64d84d48fda875427c5bfa456cd540c8dcc5c
https://github.com/scummvm/scummvm/commit/baa64d84d48fda875427c5bfa456cd540c8dcc5c
Author: Alex Bevilacqua (alexbevi at gmail.com)
Date: 2021-05-17T15:36:53+02:00
Commit Message:
ASYLUM: replace exit() with exitPuzzle() or exitEncounter()
This resolves an issue with exit() recently being declared FORBIDDEN
in master
Changed paths:
engines/asylum/puzzles/lock.cpp
engines/asylum/puzzles/puzzle.cpp
engines/asylum/puzzles/puzzle.h
engines/asylum/puzzles/tictactoe.cpp
engines/asylum/resources/encounters.cpp
engines/asylum/resources/encounters.h
diff --git a/engines/asylum/puzzles/lock.cpp b/engines/asylum/puzzles/lock.cpp
index 3c901812b2..8e10128392 100644
--- a/engines/asylum/puzzles/lock.cpp
+++ b/engines/asylum/puzzles/lock.cpp
@@ -121,7 +121,7 @@ bool PuzzleLock::update(const AsylumEvent &evt) {
_frameIndexes[6] = 0;
_counter = 0;
- exit();
+ exitPuzzle();
} else {
getScreen()->drawGraphicsInQueue();
getScreen()->copyBackBufferToScreen();
@@ -227,7 +227,7 @@ bool PuzzleLock::mouseLeftDown(const AsylumEvent &evt) {
}
bool PuzzleLock::mouseRightDown(const AsylumEvent &evt) {
- exit();
+ exitPuzzle();
return true;
}
diff --git a/engines/asylum/puzzles/puzzle.cpp b/engines/asylum/puzzles/puzzle.cpp
index 95bd355544..d464dc9077 100644
--- a/engines/asylum/puzzles/puzzle.cpp
+++ b/engines/asylum/puzzles/puzzle.cpp
@@ -110,7 +110,7 @@ bool Puzzle::keyExit(const AsylumEvent &evt) {
}
-void Puzzle::exit() {
+void Puzzle::exitPuzzle() {
getScreen()->clear();
_vm->switchEventHandler(getScene());
diff --git a/engines/asylum/puzzles/puzzle.h b/engines/asylum/puzzles/puzzle.h
index e40d1db192..a84d28c780 100644
--- a/engines/asylum/puzzles/puzzle.h
+++ b/engines/asylum/puzzles/puzzle.h
@@ -66,7 +66,7 @@ protected:
virtual bool mouseRightDown(const AsylumEvent &evt) { return true; }
bool keyExit(const AsylumEvent &evt);
- void exit();
+ void exitPuzzle();
//////////////////////////////////////////////////////////////////////////
// Hit test functions
diff --git a/engines/asylum/puzzles/tictactoe.cpp b/engines/asylum/puzzles/tictactoe.cpp
index c44ef43d84..fe38a00ea0 100644
--- a/engines/asylum/puzzles/tictactoe.cpp
+++ b/engines/asylum/puzzles/tictactoe.cpp
@@ -155,7 +155,7 @@ bool PuzzleTicTacToe::update(const AsylumEvent &evt) {
bool PuzzleTicTacToe::mouseLeftDown(const AsylumEvent &evt) {
if (!_vm->isGameFlagNotSet(kGameFlag215) || !_vm->isGameFlagNotSet(kGameFlag114)) {
getCursor()->show();
- exit();
+ exitPuzzle();
return true;
}
@@ -186,7 +186,7 @@ bool PuzzleTicTacToe::mouseLeftDown(const AsylumEvent &evt) {
}
bool PuzzleTicTacToe::mouseRightDown(const AsylumEvent &) {
- exit();
+ exitPuzzle();
return true;
}
@@ -205,7 +205,7 @@ void PuzzleTicTacToe::drawField() {
if (_counter < 2) {
getCursor()->show();
- exit();
+ exitPuzzle();
_counter = 0;
return;
}
diff --git a/engines/asylum/resources/encounters.cpp b/engines/asylum/resources/encounters.cpp
index 9175d6dd9a..18ccdc24fb 100644
--- a/engines/asylum/resources/encounters.cpp
+++ b/engines/asylum/resources/encounters.cpp
@@ -255,7 +255,7 @@ void Encounter::run(int32 encounterIndex, ObjectId objectId1, ObjectId objectId2
_vm->switchEventHandler(this);
}
-void Encounter::exit() {
+void Encounter::exitEncounter() {
setVariable(1, 32767);
initScript(_item->scriptResourceId);
_flag3 = true;
@@ -858,7 +858,7 @@ bool Encounter::drawBackground() {
if (_background.frameIndex - 1 < 0) {
_background.frameIndex = 0;
- exit();
+ exitEncounter();
}
return false;
diff --git a/engines/asylum/resources/encounters.h b/engines/asylum/resources/encounters.h
index 3529fb5977..98243d5f05 100644
--- a/engines/asylum/resources/encounters.h
+++ b/engines/asylum/resources/encounters.h
@@ -242,7 +242,7 @@ private:
//////////////////////////////////////////////////////////////////////////
// Misc
- void exit();
+ void exitEncounter();
void setupEntities(bool type4);
int32 findRect();
void updateDrawingStatus();
Commit: be33e9b4813b2fb9ed3d38249a937a6e29ca079c
https://github.com/scummvm/scummvm/commit/be33e9b4813b2fb9ed3d38249a937a6e29ca079c
Author: Alex Bevilacqua (alexbevi at gmail.com)
Date: 2021-05-17T15:36:53+02:00
Commit Message:
ASYLUM: fix initialization on Linux systems
The casting of event.type to uint32 was failing silently on non-Windows
systems. Replacing these with int32 casts resolved the issue.
Thanks to Littleboy for spotting this.
Changed paths:
engines/asylum/puzzles/puzzle.cpp
engines/asylum/resources/encounters.cpp
engines/asylum/views/menu.cpp
engines/asylum/views/scene.cpp
engines/asylum/views/video.cpp
diff --git a/engines/asylum/puzzles/puzzle.cpp b/engines/asylum/puzzles/puzzle.cpp
index d464dc9077..8e80d6bdd5 100644
--- a/engines/asylum/puzzles/puzzle.cpp
+++ b/engines/asylum/puzzles/puzzle.cpp
@@ -50,7 +50,7 @@ Puzzle::~Puzzle() {
// Event Handling
//////////////////////////////////////////////////////////////////////////
bool Puzzle::handleEvent(const AsylumEvent &evt) {
- switch ((uint32)evt.type) {
+ switch ((int32)evt.type) {
default:
break;
diff --git a/engines/asylum/resources/encounters.cpp b/engines/asylum/resources/encounters.cpp
index 18ccdc24fb..e6d6211bee 100644
--- a/engines/asylum/resources/encounters.cpp
+++ b/engines/asylum/resources/encounters.cpp
@@ -290,7 +290,7 @@ void Encounter::exitEncounter() {
// Message handler
//////////////////////////////////////////////////////////////////////////
bool Encounter::handleEvent(const AsylumEvent &evt) {
- switch ((uint32)evt.type) {
+ switch ((int32)evt.type) {
default:
break;
diff --git a/engines/asylum/views/menu.cpp b/engines/asylum/views/menu.cpp
index 5169b69166..84f85026dd 100644
--- a/engines/asylum/views/menu.cpp
+++ b/engines/asylum/views/menu.cpp
@@ -314,7 +314,7 @@ Common::String Menu::getChapterName() {
// Event Handler
//////////////////////////////////////////////////////////////////////////
bool Menu::handleEvent(const AsylumEvent &evt) {
- switch ((uint32)evt.type) {
+ switch ((int32)evt.type) {
default:
break;
diff --git a/engines/asylum/views/scene.cpp b/engines/asylum/views/scene.cpp
index e268cf342c..a11bcd0d89 100644
--- a/engines/asylum/views/scene.cpp
+++ b/engines/asylum/views/scene.cpp
@@ -293,7 +293,7 @@ void Scene::load(ResourcePackId packId) {
// Event handling
//////////////////////////////////////////////////////////////////////////
bool Scene::handleEvent(const AsylumEvent &evt) {
- switch ((uint32)evt.type) {
+ switch ((int32)evt.type) {
default:
break;
diff --git a/engines/asylum/views/video.cpp b/engines/asylum/views/video.cpp
index f8e5295323..22ef51fb37 100644
--- a/engines/asylum/views/video.cpp
+++ b/engines/asylum/views/video.cpp
@@ -55,7 +55,7 @@ VideoPlayer::~VideoPlayer() {
// Event Handler
//////////////////////////////////////////////////////////////////////////
bool VideoPlayer::handleEvent(const AsylumEvent &evt) {
- switch ((uint32)evt.type) {
+ switch ((int32)evt.type) {
default:
break;
Commit: e2f2138450c804ac3bb3edfaf76808b876883f9c
https://github.com/scummvm/scummvm/commit/e2f2138450c804ac3bb3edfaf76808b876883f9c
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:53+02:00
Commit Message:
ASYLUM: Drop "Engine" from the engine name in AsylumMetaEngine::getName()
Changed paths:
engines/asylum/detection.cpp
diff --git a/engines/asylum/detection.cpp b/engines/asylum/detection.cpp
index 7c0e5e645b..908044e1b3 100644
--- a/engines/asylum/detection.cpp
+++ b/engines/asylum/detection.cpp
@@ -134,7 +134,7 @@ public:
AsylumMetaEngine() : AdvancedMetaEngine(detectionParams) {}
virtual const char *getName() const {
- return "Asylum Engine";
+ return "Asylum";
}
virtual const char *getOriginalCopyright() const {
Commit: 2b6758af004822bc4eb406a3878bda3c1da6068f
https://github.com/scummvm/scummvm/commit/2b6758af004822bc4eb406a3878bda3c1da6068f
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:53+02:00
Commit Message:
ASYLUM: Switch to alternate AdvancedMetaEngine, avoid ADParams
Changed paths:
engines/asylum/detection.cpp
diff --git a/engines/asylum/detection.cpp b/engines/asylum/detection.cpp
index 908044e1b3..ff0eee9f40 100644
--- a/engines/asylum/detection.cpp
+++ b/engines/asylum/detection.cpp
@@ -106,32 +106,15 @@ static const ADFileBasedFallback fileBasedFallback[] = {
} // End of namespace Asylum
-static const ADParams detectionParams = {
- (const byte *)Asylum::gameDescriptions,
- sizeof(ADGameDescription),
- // number of md5 bytes
- 0,
- // List of all engine targets
- asylumGames,
- // no obsolete targets data
- 0,
- // Name of single gameid (optional)
- "asylum",
- // file-based detection data to enable not yet known versions to start
- Asylum::fileBasedFallback,
- // Flags
- kADFlagPrintWarningOnFileBasedFallback,
- // Additional GUI options (for every game}
- Common::GUIO_NONE,
- // Maximum directory depth
- 1,
- // List of directory globs
- 0
-};
-
class AsylumMetaEngine : public AdvancedMetaEngine {
public:
- AsylumMetaEngine() : AdvancedMetaEngine(detectionParams) {}
+ AsylumMetaEngine() : AdvancedMetaEngine(Asylum::gameDescriptions, sizeof(ADGameDescription), asylumGames) {
+ params.singleid = "asylum";
+ params.md5Bytes = 0;
+ params.guioptions = Common::GUIO_NONE;
+ params.fileBasedFallback = Asylum::fileBasedFallback;
+ params.flags = kADFlagPrintWarningOnFileBasedFallback;
+ }
virtual const char *getName() const {
return "Asylum";
Commit: 75aabbdefbda91ae3cb5f5c4b3bd9889d61cc047
https://github.com/scummvm/scummvm/commit/75aabbdefbda91ae3cb5f5c4b3bd9889d61cc047
Author: Alex Bevilacqua (alexbevi at gmail.com)
Date: 2021-05-17T15:36:53+02:00
Commit Message:
ASYLUM: add english demo
Changed paths:
engines/asylum/detection.cpp
diff --git a/engines/asylum/detection.cpp b/engines/asylum/detection.cpp
index ff0eee9f40..2614517b36 100644
--- a/engines/asylum/detection.cpp
+++ b/engines/asylum/detection.cpp
@@ -40,6 +40,20 @@ static const PlainGameDescriptor asylumGames[] = {
namespace Asylum {
static const ADGameDescription gameDescriptions[] = {
+ {
+ // Sanitarium - English Demo
+ "asylum",
+ "",
+ {
+ {"SNTRM.DAT", 0, "6a8079e0b49affc99d148624fbb584a1", 326},
+ {"RES.000", 0, "57446ce089c6f9decb7f3faf41d09edf", 9022},
+ {0,0,0,0}
+ },
+ Common::EN_ANY,
+ Common::kPlatformPC,
+ ADGF_DEMO,
+ Common::GUIO_NONE
+ },
{
"asylum",
"Unpatched",
Commit: f36dbc95c2ddfd2df1364866502e28652d05b1b8
https://github.com/scummvm/scummvm/commit/f36dbc95c2ddfd2df1364866502e28652d05b1b8
Author: Alex Bevilacqua (alexbevi at gmail.com)
Date: 2021-05-17T15:36:53+02:00
Commit Message:
ASYLUM: fix compilation against updated AdvancedDetector changes
Thanks to digitall for the patch
Changed paths:
engines/asylum/asylum.h
engines/asylum/detection.cpp
diff --git a/engines/asylum/asylum.h b/engines/asylum/asylum.h
index 16d217b5f0..b110fa57b2 100644
--- a/engines/asylum/asylum.h
+++ b/engines/asylum/asylum.h
@@ -85,7 +85,6 @@ class AsylumEngine: public Engine, public Common::Serializable {
protected:
// Engine APIs
virtual Common::Error run();
- virtual void errorString(const char *buf_input, char *buf_output, int buf_output_size);
virtual bool hasFeature(EngineFeature f) const;
virtual GUI::Debugger *getDebugger() { return _console; }
diff --git a/engines/asylum/detection.cpp b/engines/asylum/detection.cpp
index 2614517b36..b0ac4708c5 100644
--- a/engines/asylum/detection.cpp
+++ b/engines/asylum/detection.cpp
@@ -123,11 +123,13 @@ static const ADFileBasedFallback fileBasedFallback[] = {
class AsylumMetaEngine : public AdvancedMetaEngine {
public:
AsylumMetaEngine() : AdvancedMetaEngine(Asylum::gameDescriptions, sizeof(ADGameDescription), asylumGames) {
- params.singleid = "asylum";
- params.md5Bytes = 0;
- params.guioptions = Common::GUIO_NONE;
- params.fileBasedFallback = Asylum::fileBasedFallback;
- params.flags = kADFlagPrintWarningOnFileBasedFallback;
+ _singleid = "asylum";
+ _md5Bytes = 0;
+ _guioptions = Common::GUIO_NONE;
+ }
+
+ virtual const ADGameDescription *fallbackDetect(const FileMap &allFiles, const Common::FSList &fslist) const {
+ return detectGameFilebased(allFiles, Asylum::fileBasedFallback);
}
virtual const char *getName() const {
@@ -158,10 +160,6 @@ bool Asylum::AsylumEngine::hasFeature(EngineFeature f) const {
(f == kSupportsSubtitleOptions);
}
-void Asylum::AsylumEngine::errorString(const char *buf_input, char *buf_output, int buf_output_size) {
- snprintf(buf_output, (uint)buf_output_size, "%s", buf_input);
-}
-
bool AsylumMetaEngine::createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const {
if (desc) {
*engine = new Asylum::AsylumEngine(syst, desc);
Commit: 96c6b1cd3f53c694a7e1a1198f3629ea8dfa19e1
https://github.com/scummvm/scummvm/commit/96c6b1cd3f53c694a7e1a1198f3629ea8dfa19e1
Author: eriktorbjorn (eriktorbjorn at users.sourceforge.net)
Date: 2021-05-17T15:36:53+02:00
Commit Message:
ASYLUM: Fix text centering for multi-line texts
The first example of this is the subtitles in the intro movie
Changed paths:
engines/asylum/system/text.cpp
diff --git a/engines/asylum/system/text.cpp b/engines/asylum/system/text.cpp
index 2cda73a366..6a9b7ecb7c 100644
--- a/engines/asylum/system/text.cpp
+++ b/engines/asylum/system/text.cpp
@@ -104,12 +104,13 @@ int32 Text::getWidth(const char *text, uint32 length) {
int32 width = 0;
char character = *text;
- while (character) {
+ while (character && length > 0) {
GraphicFrame *font = _fontResource->getFrame((uint8)character);
width += font->surface.w + font->x - _curFontFlags;
text++;
character = *text;
+ length--;
}
return width;
}
Commit: 4f386a7b9804e5c77a62ad8f8dd15319e0862adc
https://github.com/scummvm/scummvm/commit/4f386a7b9804e5c77a62ad8f8dd15319e0862adc
Author: eriktorbjorn (eriktorbjorn at users.sourceforge.net)
Date: 2021-05-17T15:36:54+02:00
Commit Message:
ASYLUM: Terminate subtitle info buffer
Otherwise, strstr() will read out of bounds when looking for a movie
that doesn't have subtitles
Changed paths:
engines/asylum/views/video.cpp
diff --git a/engines/asylum/views/video.cpp b/engines/asylum/views/video.cpp
index 22ef51fb37..4968f07208 100644
--- a/engines/asylum/views/video.cpp
+++ b/engines/asylum/views/video.cpp
@@ -212,9 +212,11 @@ void VideoPlayer::loadSubtitles() {
Common::File subsFile;
subsFile.open("vids.cap");
- char *buffer = new char[(uint)subsFile.size()];
- subsFile.read(buffer, (uint32)subsFile.size());
+ uint32 fileSize = subsFile.size();
+ char *buffer = new char[fileSize + 1];
+ subsFile.read(buffer, fileSize);
subsFile.close();
+ buffer[fileSize] = 0;
char *start = strstr(buffer, movieToken);
char *line = 0;
Commit: 9360e0a6a2a16e81fa808a69dc38e44607a98762
https://github.com/scummvm/scummvm/commit/9360e0a6a2a16e81fa808a69dc38e44607a98762
Author: eriktorbjorn (eriktorbjorn at users.sourceforge.net)
Date: 2021-05-17T15:36:54+02:00
Commit Message:
ASYLUM: Initialize all flag variables in SharedData to silence Valgrind warning
Changed paths:
engines/asylum/resources/data.h
diff --git a/engines/asylum/resources/data.h b/engines/asylum/resources/data.h
index 9c5756fa07..a2a1c18576 100644
--- a/engines/asylum/resources/data.h
+++ b/engines/asylum/resources/data.h
@@ -108,6 +108,8 @@ public:
cdNumber = 0;
actorEnableForStatus7 = false;
_flag1 = false;
+ _flag2 = false;
+ _flag3 = false;
matteBarHeight = 0;
matteVar2 = 0;
sceneCounter = 0;
Commit: 6614632919351f2a0bddf95bf84af33c8ae37987
https://github.com/scummvm/scummvm/commit/6614632919351f2a0bddf95bf84af33c8ae37987
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:54+02:00
Commit Message:
ASYLUM: Move DECLARE_SINGLETON() inside namespace Common
Changed paths:
engines/asylum/system/config.cpp
diff --git a/engines/asylum/system/config.cpp b/engines/asylum/system/config.cpp
index 2a3852bb39..11b5d6b360 100644
--- a/engines/asylum/system/config.cpp
+++ b/engines/asylum/system/config.cpp
@@ -27,7 +27,9 @@
#include "asylum/system/sound.h"
+namespace Common {
DECLARE_SINGLETON(Asylum::ConfigurationManager);
+}
namespace Asylum {
Commit: d9b16f88461bb9dd45c135e93ccc3746b731bc4d
https://github.com/scummvm/scummvm/commit/d9b16f88461bb9dd45c135e93ccc3746b731bc4d
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:54+02:00
Commit Message:
ASYLUM: Implement Actor::checkAllActions()
Changed paths:
engines/asylum/resources/actor.cpp
engines/asylum/resources/actor.h
diff --git a/engines/asylum/resources/actor.cpp b/engines/asylum/resources/actor.cpp
index 398ac95443..235c91a3b5 100644
--- a/engines/asylum/resources/actor.cpp
+++ b/engines/asylum/resources/actor.cpp
@@ -1434,7 +1434,7 @@ void Actor::updateStatusEnabled() {
poly->boundingRect.top + rnd(poly->boundingRect.height()));
if (!getSharedData()->actorUpdateEnabledCheck) {
- if (isInActionArea(pt, area)) {
+ if (!isInActionArea(pt, area)) {
Common::Point *polyPoint = &poly->points[rnd(poly->count())];
processStatus(polyPoint->x, polyPoint->y, false);
} else {
@@ -1898,6 +1898,22 @@ void Actor::updateNumbers(int32 reaction, int32 x, int32 y) {
_numberFlag01 = 1;
}
+//////////////////////////////////////////////////////////////////////////
+// Helpers functions
+//////////////////////////////////////////////////////////////////////////
+bool Actor::checkAllActions(const Common::Point &pt, Common::Array<ActionArea *> *actions) {
+ if (actions->size() == 0)
+ return false;
+
+ for (Common::Array<ActionArea *>::iterator it = actions->begin(); it != actions->end(); it++) {
+ if (isInActionArea(pt, *it))
+ return true;
+ }
+
+ return false;
+
+}
+
bool Actor::isInActionArea(const Common::Point &pt, ActionArea *area) {
error("[Actor::isInActionArea] Not implemented!");
}
diff --git a/engines/asylum/resources/actor.h b/engines/asylum/resources/actor.h
index 4d2f514938..a1ef1b580a 100644
--- a/engines/asylum/resources/actor.h
+++ b/engines/asylum/resources/actor.h
@@ -28,6 +28,7 @@
#include "asylum/shared.h"
+#include "common/array.h"
#include "common/rect.h"
#include "common/stream.h"
@@ -436,6 +437,11 @@ private:
void updateFinish();
+ //////////////////////////////////////////////////////////////////////////
+ // Helper functions
+ //////////////////////////////////////////////////////////////////////////
+ bool checkAllActions(const Common::Point &pt, Common::Array<ActionArea *> *actions);
+
//////////////////////////////////////////////////////////////////////////
// Misc
//////////////////////////////////////////////////////////////////////////
@@ -480,7 +486,7 @@ private:
* @param pt The point.
* @param [in,out] area If non-null, the area.
*
- * @return
+ * @return true if in the action area, false otherwise
*/
bool isInActionArea(const Common::Point &pt, ActionArea *area);
Commit: 9eb83256febb24526f79f4beb45058e5e4103db6
https://github.com/scummvm/scummvm/commit/9eb83256febb24526f79f4beb45058e5e4103db6
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:54+02:00
Commit Message:
ASYLUM: Add stubs and rename Actor update methods
Changed paths:
engines/asylum/resources/actor.cpp
engines/asylum/resources/actor.h
diff --git a/engines/asylum/resources/actor.cpp b/engines/asylum/resources/actor.cpp
index 235c91a3b5..6ccedc4354 100644
--- a/engines/asylum/resources/actor.cpp
+++ b/engines/asylum/resources/actor.cpp
@@ -1625,11 +1625,15 @@ void Actor::updateStatus15_Chapter2() {
error("[Actor::updateStatus15_Chapter2] not implemented!");
}
+void Actor::updateStatus15_Chapter2_Helper() {
+ error("[Actor::updateStatus15_Chapter2_Helper] not implemented!");
+}
+
void Actor::updateStatus15_Chapter2_Player() {
error("[Actor::updateStatus15_Chapter2_Player] not implemented!");
}
-void Actor::updateStatus15_Chapter2_Helper() {
+void Actor::updateStatus15_Chapter2_Player_Helper() {
// we are the current player
Actor *actor11 = getScene()->getActor(11);
Actor *actor40 = getScene()->getActor(40);
@@ -1664,6 +1668,10 @@ void Actor::updateStatus15_Chapter2_Actor11() {
error("[Actor::updateStatus15_Chapter2_Actor11] not implemented!");
}
+bool Actor::updateStatus15_Chapter2_Actor11_Helper(ActorIndex actorIndex1, ActorIndex actorIndex2) {
+ error("[Actor::updateStatus15_Chapter2_Actor11_Helper] not implemented!");
+}
+
void Actor::updateStatus15_Chapter11() {
Actor *actor0 = getScene()->getActor(0);
diff --git a/engines/asylum/resources/actor.h b/engines/asylum/resources/actor.h
index a1ef1b580a..4005eb4376 100644
--- a/engines/asylum/resources/actor.h
+++ b/engines/asylum/resources/actor.h
@@ -418,10 +418,12 @@ private:
void updateStatus14_Chapter11();
void updateStatus15_Chapter2();
- void updateStatus15_Chapter2_Player();
void updateStatus15_Chapter2_Helper();
+ void updateStatus15_Chapter2_Player();
+ void updateStatus15_Chapter2_Player_Helper();
bool updateStatus15_isNoVisibleOrStatus17();
void updateStatus15_Chapter2_Actor11();
+ bool updateStatus15_Chapter2_Actor11_Helper(ActorIndex actorIndex1, ActorIndex actorIndex2);
void updateStatus15_Chapter11();
void updateStatus15_Chapter11_Player();
Commit: 92968813eaa7a7b188f376da24589785bbf7362f
https://github.com/scummvm/scummvm/commit/92968813eaa7a7b188f376da24589785bbf7362f
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:54+02:00
Commit Message:
ASYLUM: Implement Actor::updateStatus15_Chapter2_Actor11_Helper()
Changed paths:
engines/asylum/resources/actor.cpp
diff --git a/engines/asylum/resources/actor.cpp b/engines/asylum/resources/actor.cpp
index 6ccedc4354..1a34e6912a 100644
--- a/engines/asylum/resources/actor.cpp
+++ b/engines/asylum/resources/actor.cpp
@@ -1669,7 +1669,24 @@ void Actor::updateStatus15_Chapter2_Actor11() {
}
bool Actor::updateStatus15_Chapter2_Actor11_Helper(ActorIndex actorIndex1, ActorIndex actorIndex2) {
- error("[Actor::updateStatus15_Chapter2_Actor11_Helper] not implemented!");
+ Actor *actor1 = getScene()->getActor(actorIndex1);
+ Actor *actor2 = getScene()->getActor(actorIndex2);
+
+ if (actor1->getField944())
+ return false;
+
+ if (actor2->getField944())
+ return false;
+
+ int16 actor2_x = actor2->getPoint1()->x + actor2->getPoint2()->x;
+ int16 actor2_y = actor2->getPoint1()->y + actor2->getPoint2()->y;
+
+ Common::Point pt1(actor2_x - actor1->getField948() - 10, actor2_y - actor1->getField94C() - 10);
+ Common::Point pt2(actor2_x + 2 * actor1->getField948() + 10, actor2_y + 2 * actor1->getField94C() + 10);
+ Common::Point pt3(actor2_x - actor2->getField948() - 25, actor2_y - actor2->getField94C() - 20);
+ Common::Point pt4(actor2_x + 2 * actor2->getField948() + 25, actor2_y + 2 * actor2->getField94C() + 20);
+
+ return getScene()->rectIntersect(pt1.x, pt1.y, pt2.x, pt2.y, pt3.x, pt3.y, pt4.x, pt4.y);
}
void Actor::updateStatus15_Chapter11() {
Commit: 9b92fc5e640e6feb61e856ce587dfd3637a3efce
https://github.com/scummvm/scummvm/commit/9b92fc5e640e6feb61e856ce587dfd3637a3efce
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:55+02:00
Commit Message:
ASYLUM: Implement Actor::updateStatus15_Chapter11_Player()
Changed paths:
engines/asylum/resources/actor.cpp
engines/asylum/resources/worldstats.h
engines/asylum/shared.h
diff --git a/engines/asylum/resources/actor.cpp b/engines/asylum/resources/actor.cpp
index 1a34e6912a..562f81aa3c 100644
--- a/engines/asylum/resources/actor.cpp
+++ b/engines/asylum/resources/actor.cpp
@@ -1721,7 +1721,60 @@ void Actor::updateStatus15_Chapter11() {
}
void Actor::updateStatus15_Chapter11_Player() {
- error("[Actor::updateStatus15_Chapter11_Player] not implemented!");
+ _frameIndex++;
+
+ if (_frameIndex == 17) {
+ getSpeech()->playPlayer(130);
+
+ if (getWorld()->field_E849C >= 666) {
+ if (_vm->isGameFlagSet(kGameFlag583)) {
+ _vm->setGameFlag(kGameFlag582);
+ _vm->clearGameFlag(kGameFlag565);
+ ++getWorld()->field_E8518;
+ getSound()->playSound(getWorld()->soundResourceIds[2]);
+ }
+ } else {
+ Actor *actor2 = getScene()->getActor(getWorld()->field_E849C);
+
+ double diffX = (actor2->getPoint1()->x + actor2->getPoint2()->x) - (_point1.x + _point2.x);
+ double diffY = (actor2->getPoint1()->y + actor2->getPoint2()->y) - (_point1.y + _point2.y);
+
+ if (sqrt(diffX * diffX + diffY * diffY) < 75.0f
+ && (actor2->getStatus() == kActorStatus14 || actor2->getStatus() == kActorStatus15)) {
+ getSound()->playSound(getWorld()->soundResourceIds[2]);
+
+ switch (getWorld()->field_E849C) {
+ default:
+ break;
+
+ case 10:
+ _vm->setGameFlag(kGameFlag563);
+ break;
+
+ case 11:
+ _vm->setGameFlag(kGameFlag724);
+ break;
+
+ case 12:
+ _vm->setGameFlag(kGameFlag727);
+ break;
+
+ case 13:
+ _vm->setGameFlag(kGameFlag730);
+ break;
+ }
+
+ actor2->updateStatus(kActorStatus17);
+ }
+ }
+ }
+
+ if (_frameIndex >= _frameCount) {
+ getCursor()->show();
+ getSharedData()->setFlag(kFlag1, false);
+ _frameIndex = 0;
+ updateStatus(kActorStatus14);
+ }
}
void Actor::updateStatus16_Chapter2() {
diff --git a/engines/asylum/resources/worldstats.h b/engines/asylum/resources/worldstats.h
index 4caef39d76..ce430c83dd 100644
--- a/engines/asylum/resources/worldstats.h
+++ b/engines/asylum/resources/worldstats.h
@@ -133,7 +133,7 @@ public:
int32 field_E8490;
int32 field_E8494;
int32 field_E8498;
- int32 field_E849C;
+ int32 field_E849C; // ActorIndex???
int32 tickValueArray[30];
int32 field_E8518;
int32 field_E851C[30];
diff --git a/engines/asylum/shared.h b/engines/asylum/shared.h
index 305d3a4d80..295f1e7e2a 100644
--- a/engines/asylum/shared.h
+++ b/engines/asylum/shared.h
@@ -119,12 +119,19 @@ enum GameFlag {
kGameFlag553 = 553,
kGameFlag556 = 556,
kGameFlag560 = 560,
+ kGameFlag563 = 563,
+ kGameFlag565 = 565,
kGameFlag570 = 570,
+ kGameFlag582 = 582,
+ kGameFlag583 = 583,
kGameFlag608 = 608,
kGameFlag619 = 619,
kGameFlag635 = 635,
kGameFlag636 = 636,
kGameFlag637 = 637,
+ kGameFlag724 = 724,
+ kGameFlag727 = 727,
+ kGameFlag730 = 730,
kGameFlag776 = 776,
kGameFlag801 = 801,
kGameFlag802 = 802,
Commit: 364fded72585a509892ef57cf9dfb50315cdeaa4
https://github.com/scummvm/scummvm/commit/364fded72585a509892ef57cf9dfb50315cdeaa4
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:55+02:00
Commit Message:
ASYLUM: Cleanup Actor::getGraphicsFlags()
Changed paths:
engines/asylum/resources/actor.cpp
diff --git a/engines/asylum/resources/actor.cpp b/engines/asylum/resources/actor.cpp
index 562f81aa3c..a84cd18d8d 100644
--- a/engines/asylum/resources/actor.cpp
+++ b/engines/asylum/resources/actor.cpp
@@ -2146,11 +2146,13 @@ int32 Actor::getGraphicsFlags() {
int res = strcmp((char *)&_name, "Dead Sarah");
if (res == 0)
- return res;
+ return 0;
}
- // TODO replace by readable version
- return ((_direction < kDirectionSE) - 1) & 2;
+ if (_direction < kDirectionSE)
+ return 0;
+
+ return 2;
}
int32 Actor::getDistance() const {
Commit: 16ae198eeafff884d1fbd7446b11325d9ac79244
https://github.com/scummvm/scummvm/commit/16ae198eeafff884d1fbd7446b11325d9ac79244
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:55+02:00
Commit Message:
ASYLUM: Implement Actor::updateStatus15_Chapter2_Helper()
Changed paths:
engines/asylum/resources/actor.cpp
engines/asylum/shared.h
diff --git a/engines/asylum/resources/actor.cpp b/engines/asylum/resources/actor.cpp
index a84cd18d8d..27ab67ff9c 100644
--- a/engines/asylum/resources/actor.cpp
+++ b/engines/asylum/resources/actor.cpp
@@ -1626,7 +1626,63 @@ void Actor::updateStatus15_Chapter2() {
}
void Actor::updateStatus15_Chapter2_Helper() {
- error("[Actor::updateStatus15_Chapter2_Helper] not implemented!");
+ Actor *actor39 = getScene()->getActor(39);
+
+ actor39->getPoint1()->x = _point1.x;
+ actor39->getPoint1()->y = _point1.y;
+
+ if (_vm->isGameFlagSet(kGameFlag169))
+ actor39->getPoint1()->y += 80;
+
+ switch (getSharedData()->getData(40)) {
+ default:
+ break;
+
+ case 0:
+ _vm->setGameFlag(kGameFlag369);
+
+ if (getSound()->isPlaying(getWorld()->soundResourceIds[5]))
+ getSound()->stop(getWorld()->soundResourceIds[5]);
+
+ if (!getSound()->isPlaying(getWorld()->soundResourceIds[6]))
+ getSound()->playSound(getWorld()->soundResourceIds[6], true, Config.sfxVolume - 10);
+ break;
+
+ case 1:
+ _vm->setGameFlag(kGameFlag370);
+
+ if (getSound()->isPlaying(getWorld()->soundResourceIds[6]))
+ getSound()->stop(getWorld()->soundResourceIds[6]);
+
+ if (!getSound()->isPlaying(getWorld()->soundResourceIds[7]))
+ getSound()->playSound(getWorld()->soundResourceIds[7], true, Config.sfxVolume - 10);
+ break;
+
+ case 2:
+ if (getSound()->isPlaying(getWorld()->soundResourceIds[7]))
+ getSound()->stop(getWorld()->soundResourceIds[7]);
+ break;
+ }
+
+ getSharedData()->setData(40, getSharedData()->getData(40) + 1);
+
+ switch (getSharedData()->getData(40)) {
+ default:
+ break;
+
+ case 0:
+ enableActorsChapter2(_vm);
+ getCursor()->hide();
+ break;
+
+ case 1:
+ _vm->setGameFlag(kGameFlag369);
+ break;
+
+ case 2:
+ _vm->setGameFlag(kGameFlag370);
+ break;
+ }
}
void Actor::updateStatus15_Chapter2_Player() {
diff --git a/engines/asylum/shared.h b/engines/asylum/shared.h
index 295f1e7e2a..e4697a21c5 100644
--- a/engines/asylum/shared.h
+++ b/engines/asylum/shared.h
@@ -39,10 +39,11 @@ enum GameFlag {
kGameFlag52 = 52,
kGameFlag114 = 114,
kGameFlag115 = 115,
- kGameFlag215 = 215,
+ kGameFlag169 = 169,
kGameFlagScriptProcessing = 183,
kGameFlag186 = 186,
kGameFlagCommentLeavingCell = 214,
+ kGameFlag215 = 215,
kGameFlag219 = 219,
kGameFlagSolveVCRBlowUpPuzzle = 220,
kGameFlag235 = 235,
Commit: 8b9d471a7ff544bb6ee12f1d101d1b2ae4a6ab0f
https://github.com/scummvm/scummvm/commit/8b9d471a7ff544bb6ee12f1d101d1b2ae4a6ab0f
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:55+02:00
Commit Message:
ASYLUM: Implement parts of Actor::process()
Changed paths:
engines/asylum/resources/actor.cpp
engines/asylum/resources/actor.h
engines/asylum/resources/script.cpp
diff --git a/engines/asylum/resources/actor.cpp b/engines/asylum/resources/actor.cpp
index 27ab67ff9c..cd5d3460dd 100644
--- a/engines/asylum/resources/actor.cpp
+++ b/engines/asylum/resources/actor.cpp
@@ -838,12 +838,125 @@ bool Actor::isResourcePresent() const {
return (index >= 15);
}
-bool Actor::process(int32 actorX, int32 actorY) {
- error("[Actor::process] not implemented!");
+bool Actor::process(const Common::Point &point) {
+ // Compute point and delta
+ Common::Point sum(_point1.x + _point2.x, _point1.y + _point2.y);
+ Common::Point delta = point - sum;
+
+ // Compute modifiers
+ int a1 = 0;
+ int a2 = 0;
+ int a3 = 0;
+
+ if (delta.x <= 0) {
+ if (delta.y >= 0) {
+ a1 = -1;
+ a2 = 1;
+ a3 = 3;
+ } else {
+ a1 = -1;
+ a2 = -1;
+ a3 = 0;
+ }
+ } else {
+ if (delta.y >= 0) {
+ a1 = 1;
+ a2 = 1;
+ a3 = 2;
+ } else {
+ a1 = 1;
+ a2 = -1;
+ a3 = 1;
+ }
+ }
+
+ if (point == sum) {
+ if (process_408B20(&sum, a3 >= 2 ? kDirectionS : kDirectionN, abs(delta.y), false)) {
+ _data.field_8[0] = point.x;
+ _data.field_8[1] = point.y;
+ _data.field_4 = 0;
+ _data.count = 1;
+
+ return true;
+ }
+ }
+
+ if (point.x == sum.x) {
+ ActorDirection direction = a3 >= 2 ? kDirectionS : kDirectionN;
+ if (process_408B20(&sum, direction, abs(delta.y), false)) {
+ _data.field_8[0] = point.x;
+ _data.field_8[1] = point.y;
+ _data.field_4 = 0;
+ _data.count = 1;
+
+ updateFromDirection(direction);
+
+ return true;
+ }
+
+ return false;
+ }
+
+ if (point.y == sum.y) {
+ ActorDirection direction = (a3 != 0 || a3 != 3) ? kDirectionE : kDirectionO;
+
+ if (process_408B20(&sum, direction, abs(delta.x), true)) {
+ _data.field_8[0] = point.x;
+ _data.field_8[1] = point.y;
+ _data.field_4 = 0;
+ _data.count = 1;
+
+ updateFromDirection(direction);
+
+ return true;
+ }
+
+ return false;
+ }
+
+ if (abs(delta.x) != abs(delta.y)) {
+ error("[Actor::process] not implemented (deltas)!");
+ }
+
+ //////////////////////////////////////////////////////////////////////////
+ // Last case: abs(delta.x) == abs(delta.y)
+
+ // Compute direction
+ ActorDirection direction = kDirectionSO;
+ switch (a3) {
+ default:
+ break;
+
+ case 0:
+ direction = kDirectionNO;
+ break;
+
+ case 1:
+ direction = kDirectionNE;
+ break;
+
+ case 2:
+ direction = kDirectionSE;
+ break;
+ }
+
+ if (!process_408B20(&sum, direction, abs(delta.y), true))
+ return false;
+
+ // Update actor data
+ _data.field_8[0] = point.x;
+ _data.field_8[1] = point.y;
+ _data.field_4 = 0;
+ _data.count = 1;
+
+ // Update actor from direction
+ updateFromDirection(direction);
+
+ return true;
}
void Actor::processStatus(int32 actorX, int32 actorY, bool doSpeech) {
- if (process(actorX, actorY)) {
+ if (process(Common::Point(actorX, actorY))) {
if (_status <= kActorStatus11)
updateStatus(kActorStatus2);
else
diff --git a/engines/asylum/resources/actor.h b/engines/asylum/resources/actor.h
index 4005eb4376..9f4f3c9edc 100644
--- a/engines/asylum/resources/actor.h
+++ b/engines/asylum/resources/actor.h
@@ -258,7 +258,7 @@ public:
void clearFields() { memset(&_field_970, 0, 52); }
// Unknown methods
- bool process(int32 actorX, int32 actorY);
+ bool process(const Common::Point &point);
void processStatus(int32 actorX, int32 actorY, bool doSpeech);
void process_401830(int32 field980, int32 actionAreaId, int32 field978, int field98C, int32 field990, int32 field974, int32 field984, int32 field988);
bool process_4069B0(int32 *x, int32 *y);
diff --git a/engines/asylum/resources/script.cpp b/engines/asylum/resources/script.cpp
index 17f8d63e48..b33dd50431 100644
--- a/engines/asylum/resources/script.cpp
+++ b/engines/asylum/resources/script.cpp
@@ -637,7 +637,7 @@ END_OPCODE
IMPLEMENT_OPCODE(JumpActorSpeech)
Actor *actor = getScene()->getActor(cmd->param1);
- if (actor->process(cmd->param2, cmd->param3))
+ if (actor->process(Common::Point(cmd->param2, cmd->param3)))
return;
_currentQueueEntry->currentLine = cmd->param4;
Commit: 74d67ae3cd708f96ba82daa0bd84c313b48f86da
https://github.com/scummvm/scummvm/commit/74d67ae3cd708f96ba82daa0bd84c313b48f86da
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:55+02:00
Commit Message:
ASYLUM: Implement Actor::isInActionArea()
Changed paths:
engines/asylum/resources/actor.cpp
diff --git a/engines/asylum/resources/actor.cpp b/engines/asylum/resources/actor.cpp
index cd5d3460dd..687cea91cd 100644
--- a/engines/asylum/resources/actor.cpp
+++ b/engines/asylum/resources/actor.cpp
@@ -2162,7 +2162,34 @@ bool Actor::checkAllActions(const Common::Point &pt, Common::Array<ActionArea *>
}
bool Actor::isInActionArea(const Common::Point &pt, ActionArea *area) {
- error("[Actor::isInActionArea] Not implemented!");
+ Common::Rect rect = getWorld()->sceneRects[getWorld()->sceneRectIdx];
+
+ if (!rect.contains(pt))
+ return false;
+
+ if (area->flags & 1)
+ return false;
+
+ // Check flags
+ bool found = false;
+ for (uint32 i = 0; i < 10; i++) {
+ int32 flag = area->flagNums[i];
+ bool state = (flag <= 0) ? _vm->isGameFlagNotSet((GameFlag)-flag) : _vm->isGameFlagSet((GameFlag)flag);
+
+ if (!state) {
+ found = true;
+ break;
+ }
+ }
+
+ if (found)
+ return false;
+
+ PolyDefinitions poly = getScene()->polygons()->entries[area->polygonIndex];
+ if (!poly.contains(pt))
+ return false;
+
+ return true;
}
//////////////////////////////////////////////////////////////////////////
Commit: 836e1f43d8a71411dc88ef16b16e20054ecb47b9
https://github.com/scummvm/scummvm/commit/836e1f43d8a71411dc88ef16b16e20054ecb47b9
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:55+02:00
Commit Message:
ASYLUM: Process all events in the queue on each call of AsylumEngine::handleEvents() instead of just one
This should fix the slowness experienced in the menu on Linux as reported by eriktorbjorn
Changed paths:
engines/asylum/asylum.cpp
diff --git a/engines/asylum/asylum.cpp b/engines/asylum/asylum.cpp
index 93f0155b21..efaa86069b 100644
--- a/engines/asylum/asylum.cpp
+++ b/engines/asylum/asylum.cpp
@@ -314,7 +314,7 @@ void AsylumEngine::handleEvents() {
_console->onFrame();
AsylumEvent ev;
- if (_eventMan->pollEvent(ev)) {
+ while (_eventMan->pollEvent(ev)) {
switch (ev.type) {
default:
break;
Commit: 1b9c4dd404df88e66f308f6c1584a43376c8b2c9
https://github.com/scummvm/scummvm/commit/1b9c4dd404df88e66f308f6c1584a43376c8b2c9
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:55+02:00
Commit Message:
ASYLUM: Add DrawFlags enumeration and update drawing functions parameters
Changed paths:
engines/asylum/console.cpp
engines/asylum/puzzles/clock.cpp
engines/asylum/puzzles/fisherman.cpp
engines/asylum/puzzles/lock.cpp
engines/asylum/puzzles/morguedoor.cpp
engines/asylum/puzzles/puzzle11.cpp
engines/asylum/puzzles/tictactoe.cpp
engines/asylum/puzzles/timemachine.cpp
engines/asylum/puzzles/vcr.cpp
engines/asylum/puzzles/wheel.cpp
engines/asylum/puzzles/writings.cpp
engines/asylum/resources/actor.cpp
engines/asylum/resources/actor.h
engines/asylum/resources/encounters.cpp
engines/asylum/resources/object.cpp
engines/asylum/shared.h
engines/asylum/system/screen.cpp
engines/asylum/system/screen.h
engines/asylum/system/text.cpp
engines/asylum/views/menu.cpp
engines/asylum/views/scene.cpp
engines/asylum/views/scenetitle.cpp
diff --git a/engines/asylum/console.cpp b/engines/asylum/console.cpp
index fad73a29ae..3d89a6cff5 100644
--- a/engines/asylum/console.cpp
+++ b/engines/asylum/console.cpp
@@ -525,7 +525,7 @@ bool Console::cmdDrawResource(int32 argc, const char **argv) {
// Draw resource
getScreen()->clear();
- getScreen()->draw(MAKE_RESOURCE(pack, index), frame, 0, 0, 0);
+ getScreen()->draw(MAKE_RESOURCE(pack, index), frame, 0, 0);
getScreen()->copyBackBufferToScreen();
g_system->updateScreen();
diff --git a/engines/asylum/puzzles/clock.cpp b/engines/asylum/puzzles/clock.cpp
index 819fe3319a..339cef9bf1 100644
--- a/engines/asylum/puzzles/clock.cpp
+++ b/engines/asylum/puzzles/clock.cpp
@@ -108,12 +108,12 @@ bool PuzzleClock::update(const AsylumEvent &evt) {
getScreen()->clearGraphicsInQueue();
getScreen()->draw(getWorld()->graphicResourceIds[5]);
- getScreen()->draw(getWorld()->graphicResourceIds[2], _frameIndexes[0], puzzleClockPoints[0].x, puzzleClockPoints[0].y, 0);
+ getScreen()->draw(getWorld()->graphicResourceIds[2], _frameIndexes[0], puzzleClockPoints[0].x, puzzleClockPoints[0].y);
_frameIndexes[0]++;
_frameIndexes[0] %= GraphicResource::getFrameCount(_vm, getWorld()->graphicResourceIds[2]);
- getScreen()->draw(getWorld()->graphicResourceIds[4], _frameIndexes[1], puzzleClockPoints[1].x, puzzleClockPoints[1].y, 0);
- getScreen()->draw(getWorld()->graphicResourceIds[3], _frameIndexes[2], puzzleClockPoints[2].x, puzzleClockPoints[2].y, 0);
+ getScreen()->draw(getWorld()->graphicResourceIds[4], _frameIndexes[1], puzzleClockPoints[1].x, puzzleClockPoints[1].y);
+ getScreen()->draw(getWorld()->graphicResourceIds[3], _frameIndexes[2], puzzleClockPoints[2].x, puzzleClockPoints[2].y);
if (_currentFrameIndex == _frameIndexes[2]) {
if (_showCursor) {
diff --git a/engines/asylum/puzzles/fisherman.cpp b/engines/asylum/puzzles/fisherman.cpp
index f8fbba491e..13d11c06e9 100644
--- a/engines/asylum/puzzles/fisherman.cpp
+++ b/engines/asylum/puzzles/fisherman.cpp
@@ -111,7 +111,7 @@ bool PuzzleFisherman::update(const AsylumEvent &evt) {
// Draw 7 graphics
for (uint32 i = 0; i < 6; i++) {
if (_state[i])
- getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[40 + i], 0, puzzleFishermanPolygons[i], 0, 0, 1);
+ getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[40 + i], 0, puzzleFishermanPolygons[i], kDrawFlagNone, 0, 1);
}
getScreen()->drawGraphicsInQueue();
diff --git a/engines/asylum/puzzles/lock.cpp b/engines/asylum/puzzles/lock.cpp
index 8e10128392..274c68eabc 100644
--- a/engines/asylum/puzzles/lock.cpp
+++ b/engines/asylum/puzzles/lock.cpp
@@ -89,16 +89,16 @@ bool PuzzleLock::update(const AsylumEvent &evt) {
getScreen()->draw(getWorld()->graphicResourceIds[13]);
if (_frameIndexes[0] != 32 || _frameIndexes[1] != 28 || _frameIndexes[2] != 0) {
- getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[15], _frameIndexes[0], Common::Point(145, 292), 0, 0, 1);
- getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[15], _frameIndexes[1], Common::Point(173, 297), 0, 0, 1);
- getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[15], _frameIndexes[2], Common::Point(201, 302), 0, 0, 1);
- getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[40], _frameIndexes[3], Common::Point(337, 127), 0, 0, 1);
+ getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[15], _frameIndexes[0], Common::Point(145, 292), kDrawFlagNone, 0, 1);
+ getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[15], _frameIndexes[1], Common::Point(173, 297), kDrawFlagNone, 0, 1);
+ getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[15], _frameIndexes[2], Common::Point(201, 302), kDrawFlagNone, 0, 1);
+ getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[40], _frameIndexes[3], Common::Point(337, 127), kDrawFlagNone, 0, 1);
if (_frameIndexes[4] != -1)
- getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[42], _frameIndexes[4], Common::Point(318, 102), 0, 0, 1);
+ getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[42], _frameIndexes[4], Common::Point(318, 102), kDrawFlagNone, 0, 1);
if (_frameIndexes[5] != -1)
- getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[43], _frameIndexes[5], Common::Point(318, 99), 0, 0, 1);
+ getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[43], _frameIndexes[5], Common::Point(318, 99), kDrawFlagNone, 0, 1);
getScreen()->drawGraphicsInQueue();
getScreen()->copyBackBufferToScreen();
@@ -106,7 +106,7 @@ bool PuzzleLock::update(const AsylumEvent &evt) {
if (_frameIndexes[6] == 5)
getSound()->playSound(getWorld()->soundResourceIds[15], false, Config.sfxVolume - 10);
- getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[16], _frameIndexes[6], Common::Point(0, 264), 0, 0, 1);
+ getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[16], _frameIndexes[6], Common::Point(0, 264), kDrawFlagNone, 0, 1);
++_counter;
diff --git a/engines/asylum/puzzles/morguedoor.cpp b/engines/asylum/puzzles/morguedoor.cpp
index 899759cd40..43cbc8c1e4 100644
--- a/engines/asylum/puzzles/morguedoor.cpp
+++ b/engines/asylum/puzzles/morguedoor.cpp
@@ -94,23 +94,23 @@ bool PuzzleMorgueDoor::update(const AsylumEvent &evt) {
// Draw elements
getScreen()->clearGraphicsInQueue();
getScreen()->draw(getWorld()->graphicResourceIds[19]);
- getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[21], _frameIndexes[kTopLever], Common::Point(47, 0), 0, 0, 1);
- getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[22], _frameIndexes[kBottomLever], Common::Point(51, 236), 0, 0, 1);
+ getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[21], _frameIndexes[kTopLever], Common::Point(47, 0), kDrawFlagNone, 0, 1);
+ getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[22], _frameIndexes[kBottomLever], Common::Point(51, 236), kDrawFlagNone, 0, 1);
if (_topLeverOpen)
- getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[23], _frameIndexes[kTopLeverOpened], Common::Point(80, 0), 0, 0, 1);
+ getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[23], _frameIndexes[kTopLeverOpened], Common::Point(80, 0), kDrawFlagNone, 0, 1);
if (_bottomLeverOpen)
- getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[24], _frameIndexes[kBottomLeverOpened], Common::Point(89, 230), 0, 0, 1);
-
- getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[25], _frameIndexes[kTopRightValve], Common::Point(515, 41), 0, 0, 1);
- getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[26], _frameIndexes[kCenterValve], Common::Point(267, 190), 0, 0, 1);
- getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[27], _frameIndexes[kRightGear], Common::Point(388, 105), 0, 0, 1);
- getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[28], _frameIndexes[kTopRightLever], Common::Point(491, 143), 0, 0, 1);
- getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[29], _frameIndexes[kTopSmallLever], Common::Point(347, 124), 0, 0, 1);
- getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[30], _frameIndexes[kBottomSmallLever], Common::Point(346, 339), 0, 0, 1);
- getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[31], _frameIndexes[kTopGear], Common::Point(276, 67), 0, 0, 1);
- getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[32], _frameIndexes[kBottomGear], Common::Point(278, 378), 0, 0, 1);
+ getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[24], _frameIndexes[kBottomLeverOpened], Common::Point(89, 230), kDrawFlagNone, 0, 1);
+
+ getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[25], _frameIndexes[kTopRightValve], Common::Point(515, 41), kDrawFlagNone, 0, 1);
+ getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[26], _frameIndexes[kCenterValve], Common::Point(267, 190), kDrawFlagNone, 0, 1);
+ getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[27], _frameIndexes[kRightGear], Common::Point(388, 105), kDrawFlagNone, 0, 1);
+ getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[28], _frameIndexes[kTopRightLever], Common::Point(491, 143), kDrawFlagNone, 0, 1);
+ getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[29], _frameIndexes[kTopSmallLever], Common::Point(347, 124), kDrawFlagNone, 0, 1);
+ getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[30], _frameIndexes[kBottomSmallLever], Common::Point(346, 339), kDrawFlagNone, 0, 1);
+ getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[31], _frameIndexes[kTopGear], Common::Point(276, 67), kDrawFlagNone, 0, 1);
+ getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[32], _frameIndexes[kBottomGear], Common::Point(278, 378), kDrawFlagNone, 0, 1);
getScreen()->drawGraphicsInQueue();
getScreen()->copyBackBufferToScreen();
diff --git a/engines/asylum/puzzles/puzzle11.cpp b/engines/asylum/puzzles/puzzle11.cpp
index 382b68b091..37bac7f5f7 100644
--- a/engines/asylum/puzzles/puzzle11.cpp
+++ b/engines/asylum/puzzles/puzzle11.cpp
@@ -75,11 +75,11 @@ bool Puzzle11::init(const AsylumEvent &evt) {
bool Puzzle11::update(const AsylumEvent &evt) {
getScreen()->clearGraphicsInQueue();
getScreen()->draw(getWorld()->graphicResourceIds[11]);
- getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[15], _frameIndexes[0], Common::Point(122, 269), 0, 0, 1);
- getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[16], _frameIndexes[1], Common::Point(524, 175), 0, 0, 1);
- getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[18], _frameIndexes[2], Common::Point(359, 61), 0, 0, 1);
- getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[14], _frameIndexes[3], Common::Point(115, 80), 0, 0, 1);
- getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[17], _frameIndexes[4], Common::Point(238, 94), 0, 0, 1);
+ getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[15], _frameIndexes[0], Common::Point(122, 269), kDrawFlagNone, 0, 1);
+ getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[16], _frameIndexes[1], Common::Point(524, 175), kDrawFlagNone, 0, 1);
+ getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[18], _frameIndexes[2], Common::Point(359, 61), kDrawFlagNone, 0, 1);
+ getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[14], _frameIndexes[3], Common::Point(115, 80), kDrawFlagNone, 0, 1);
+ getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[17], _frameIndexes[4], Common::Point(238, 94), kDrawFlagNone, 0, 1);
getScreen()->drawGraphicsInQueue();
getScreen()->copyBackBufferToScreen();
diff --git a/engines/asylum/puzzles/tictactoe.cpp b/engines/asylum/puzzles/tictactoe.cpp
index fe38a00ea0..322c8521d0 100644
--- a/engines/asylum/puzzles/tictactoe.cpp
+++ b/engines/asylum/puzzles/tictactoe.cpp
@@ -227,9 +227,9 @@ void PuzzleTicTacToe::drawField() {
if (_lastMarkedField == i) {
if (mark == 'O')
- getScreen()->draw(getWorld()->graphicResourceIds[2], _frameIndex, point.x, point.y, 0);
+ getScreen()->draw(getWorld()->graphicResourceIds[2], _frameIndex, point.x, point.y);
else if (mark == 'X')
- getScreen()->draw(getWorld()->graphicResourceIds[1], _frameIndex, point.x, point.y, 0);
+ getScreen()->draw(getWorld()->graphicResourceIds[1], _frameIndex, point.x, point.y);
// Update _frameIndex
++_frameIndex;
@@ -251,9 +251,9 @@ void PuzzleTicTacToe::drawField() {
}
} else {
if (mark == 'O')
- getScreen()->draw(getWorld()->graphicResourceIds[2], 12, point.x, point.y, 0);
+ getScreen()->draw(getWorld()->graphicResourceIds[2], 12, point.x, point.y);
else if (mark == 'X')
- getScreen()->draw(getWorld()->graphicResourceIds[1], 14, point.x, point.y, 0);
+ getScreen()->draw(getWorld()->graphicResourceIds[1], 14, point.x, point.y);
}
}
@@ -267,98 +267,98 @@ void PuzzleTicTacToe::drawField() {
break;
case 1:
- getScreen()->draw(getWorld()->graphicResourceIds[5], _frameIndex, 38, 345, 0);
+ getScreen()->draw(getWorld()->graphicResourceIds[5], _frameIndex, 38, 345);
break;
case 2:
- getScreen()->draw(getWorld()->graphicResourceIds[5], _frameIndex, 17, 226, 0);
+ getScreen()->draw(getWorld()->graphicResourceIds[5], _frameIndex, 17, 226);
break;
case 3:
- getScreen()->draw(getWorld()->graphicResourceIds[5], _frameIndex, 1, 104, 0);
+ getScreen()->draw(getWorld()->graphicResourceIds[5], _frameIndex, 1, 104);
break;
case 4:
- getScreen()->draw(getWorld()->graphicResourceIds[6], _frameIndex, 43, 117, 0);
+ getScreen()->draw(getWorld()->graphicResourceIds[6], _frameIndex, 43, 117);
break;
case 5:
- getScreen()->draw(getWorld()->graphicResourceIds[6], _frameIndex, 176, 104, 0);
+ getScreen()->draw(getWorld()->graphicResourceIds[6], _frameIndex, 176, 104);
break;
case 6:
- getScreen()->draw(getWorld()->graphicResourceIds[6], _frameIndex, 299, 85, 0);
+ getScreen()->draw(getWorld()->graphicResourceIds[6], _frameIndex, 299, 85);
break;
case 7:
if (_counter2 == 0)
- getScreen()->draw(getWorld()->graphicResourceIds[8], _frameIndex, 30, 149, 0);
+ getScreen()->draw(getWorld()->graphicResourceIds[8], _frameIndex, 30, 149);
else if (_counter2 == 1)
- getScreen()->draw(getWorld()->graphicResourceIds[8], _frameIndex, 180, 249, 0);
+ getScreen()->draw(getWorld()->graphicResourceIds[8], _frameIndex, 180, 249);
else {
- getScreen()->draw(getWorld()->graphicResourceIds[8], 6, 30, 149, 0);
- getScreen()->draw(getWorld()->graphicResourceIds[8], 6, 180, 249, 0);
- getScreen()->draw(getWorld()->graphicResourceIds[8], _frameIndex, 330, 349, 0);
+ getScreen()->draw(getWorld()->graphicResourceIds[8], 6, 30, 149);
+ getScreen()->draw(getWorld()->graphicResourceIds[8], 6, 180, 249);
+ getScreen()->draw(getWorld()->graphicResourceIds[8], _frameIndex, 330, 349);
}
break;
case 8:
if (_counter2 == 0)
- getScreen()->draw(getWorld()->graphicResourceIds[10], _frameIndex, 69, 66, 0);
+ getScreen()->draw(getWorld()->graphicResourceIds[10], _frameIndex, 69, 66);
else if (_counter2 == 1)
- getScreen()->draw(getWorld()->graphicResourceIds[10], _frameIndex, -22, 220, 0);
+ getScreen()->draw(getWorld()->graphicResourceIds[10], _frameIndex, -22, 220);
else {
- getScreen()->draw(getWorld()->graphicResourceIds[10], 6, 69, 66, 0);
- getScreen()->draw(getWorld()->graphicResourceIds[10], 6, -22, 220, 0);
- getScreen()->draw(getWorld()->graphicResourceIds[10], _frameIndex, -110, 370, 0);
+ getScreen()->draw(getWorld()->graphicResourceIds[10], 6, 69, 66);
+ getScreen()->draw(getWorld()->graphicResourceIds[10], 6, -22, 220);
+ getScreen()->draw(getWorld()->graphicResourceIds[10], _frameIndex, -110, 370);
}
break;
case 9:
- getScreen()->draw(getWorld()->graphicResourceIds[4], _frameIndex, 38, 345, 0);
+ getScreen()->draw(getWorld()->graphicResourceIds[4], _frameIndex, 38, 345);
break;
case 10:
- getScreen()->draw(getWorld()->graphicResourceIds[4], _frameIndex, 17, 226, 0);
+ getScreen()->draw(getWorld()->graphicResourceIds[4], _frameIndex, 17, 226);
break;
case 11:
- getScreen()->draw(getWorld()->graphicResourceIds[4], _frameIndex, 1, 104, 0);
+ getScreen()->draw(getWorld()->graphicResourceIds[4], _frameIndex, 1, 104);
break;
case 12:
- getScreen()->draw(getWorld()->graphicResourceIds[11], _frameIndex, 43, 117, 0);
+ getScreen()->draw(getWorld()->graphicResourceIds[11], _frameIndex, 43, 117);
break;
case 13:
- getScreen()->draw(getWorld()->graphicResourceIds[11], _frameIndex, 176, 104, 0);
+ getScreen()->draw(getWorld()->graphicResourceIds[11], _frameIndex, 176, 104);
break;
case 14:
- getScreen()->draw(getWorld()->graphicResourceIds[11], _frameIndex, 299, 85, 0);
+ getScreen()->draw(getWorld()->graphicResourceIds[11], _frameIndex, 299, 85);
break;
case 15:
if (_counter2 == 0)
- getScreen()->draw(getWorld()->graphicResourceIds[7], _frameIndex, 30, 149, 0);
+ getScreen()->draw(getWorld()->graphicResourceIds[7], _frameIndex, 30, 149);
else if (_counter2 == 1)
- getScreen()->draw(getWorld()->graphicResourceIds[7], _frameIndex, 180, 249, 0);
+ getScreen()->draw(getWorld()->graphicResourceIds[7], _frameIndex, 180, 249);
else {
- getScreen()->draw(getWorld()->graphicResourceIds[7], 6, 30, 149, 0);
- getScreen()->draw(getWorld()->graphicResourceIds[7], 6, 180, 249, 0);
- getScreen()->draw(getWorld()->graphicResourceIds[7], _frameIndex, 330, 349, 0);
+ getScreen()->draw(getWorld()->graphicResourceIds[7], 6, 30, 149);
+ getScreen()->draw(getWorld()->graphicResourceIds[7], 6, 180, 249);
+ getScreen()->draw(getWorld()->graphicResourceIds[7], _frameIndex, 330, 349);
}
break;
case 16:
if (_counter2 == 0)
- getScreen()->draw(getWorld()->graphicResourceIds[9], _frameIndex, 69, 66, 0);
+ getScreen()->draw(getWorld()->graphicResourceIds[9], _frameIndex, 69, 66);
else if (_counter2 == 1)
- getScreen()->draw(getWorld()->graphicResourceIds[9], _frameIndex, -22, 220, 0);
+ getScreen()->draw(getWorld()->graphicResourceIds[9], _frameIndex, -22, 220);
else {
- getScreen()->draw(getWorld()->graphicResourceIds[9], 6, 69, 66, 0);
- getScreen()->draw(getWorld()->graphicResourceIds[9], 6, -22, 220, 0);
- getScreen()->draw(getWorld()->graphicResourceIds[9], _frameIndex, -110, 370, 0);
+ getScreen()->draw(getWorld()->graphicResourceIds[9], 6, 69, 66);
+ getScreen()->draw(getWorld()->graphicResourceIds[9], 6, -22, 220);
+ getScreen()->draw(getWorld()->graphicResourceIds[9], _frameIndex, -110, 370);
}
break;
}
@@ -378,7 +378,7 @@ void PuzzleTicTacToe::drawField() {
_counter = 30;
}
- getScreen()->draw(getWorld()->graphicResourceIds[17], 0, 0, 0, 0);
+ getScreen()->draw(getWorld()->graphicResourceIds[17], 0, 0, 0);
}
void PuzzleTicTacToe::updatePositions(uint32 field1, uint32 field2, uint32 field3) {
diff --git a/engines/asylum/puzzles/timemachine.cpp b/engines/asylum/puzzles/timemachine.cpp
index 6f18b5030f..40833f41e5 100644
--- a/engines/asylum/puzzles/timemachine.cpp
+++ b/engines/asylum/puzzles/timemachine.cpp
@@ -120,15 +120,15 @@ bool PuzzleTimeMachine::update(const AsylumEvent &evt) {
// Draw screen elements
getScreen()->clearGraphicsInQueue();
getScreen()->draw(getWorld()->graphicResourceIds[34]);
- getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[35], _frameIndexes[0], Common::Point(23, 215), 0, 0, 1);
- getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[36], _frameIndexes[1], Common::Point(70, 217), 0, 0, 2);
- getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[37], _frameIndexes[2], Common::Point(189, 217), 0, 0, 3);
- getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[38], _frameIndexes[3], Common::Point(309, 218), 0, 0, 4);
- getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[39], _frameIndexes[4], Common::Point(429, 212), 0, 0, 5);
+ getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[35], _frameIndexes[0], Common::Point(23, 215), kDrawFlagNone, 0, 1);
+ getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[36], _frameIndexes[1], Common::Point(70, 217), kDrawFlagNone, 0, 2);
+ getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[37], _frameIndexes[2], Common::Point(189, 217), kDrawFlagNone, 0, 3);
+ getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[38], _frameIndexes[3], Common::Point(309, 218), kDrawFlagNone, 0, 4);
+ getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[39], _frameIndexes[4], Common::Point(429, 212), kDrawFlagNone, 0, 5);
if (_frameIndexes[0] != 28 || _frameIndexes[1] || _frameIndexes[2] || _frameIndexes[3] || _frameIndexes[4]) {
_leftButtonClicked = true;
- getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[43], 0, Common::Point(599, 220), 0, 0, 5);
+ getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[43], 0, Common::Point(599, 220), kDrawFlagNone, 0, 5);
} else {
getSound()->stop(getWorld()->soundResourceIds[17]);
getSound()->stop(getWorld()->soundResourceIds[16]);
@@ -141,18 +141,18 @@ bool PuzzleTimeMachine::update(const AsylumEvent &evt) {
++_counter;
}
- getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[40], _frameIndexes[5], _point, 0, 0, 1);
+ getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[40], _frameIndexes[5], _point, kDrawFlagNone, 0, 1);
//////////////////////////////////////////////////////////////////////////
// Show all buttons
for (uint32 i = 0; i < ARRAYSIZE(puzzleTimeMachineRects); i += 2) {
if (_state[i / 2] != -1)
- getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[44 + i], 0, Common::Point(puzzleTimeMachineRects[i].left, puzzleTimeMachineRects[i].top), 0, 0, 5);
+ getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[44 + i], 0, Common::Point(puzzleTimeMachineRects[i].left, puzzleTimeMachineRects[i].top), kDrawFlagNone, 0, 5);
}
for (uint32 i = 1; i < ARRAYSIZE(puzzleTimeMachineRects); i += 2) {
if (_state[i / 2] != 1)
- getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[45 + i], 0, Common::Point(puzzleTimeMachineRects[i].left, puzzleTimeMachineRects[i].top), 0, 0, 5);
+ getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[45 + i], 0, Common::Point(puzzleTimeMachineRects[i].left, puzzleTimeMachineRects[i].top), kDrawFlagNone, 0, 5);
}
// Draw to screen
diff --git a/engines/asylum/puzzles/vcr.cpp b/engines/asylum/puzzles/vcr.cpp
index fa8f945bde..67b8014dc9 100644
--- a/engines/asylum/puzzles/vcr.cpp
+++ b/engines/asylum/puzzles/vcr.cpp
@@ -308,8 +308,8 @@ void PuzzleVCR::updateScreen(const AsylumEvent &evt) {
updateStopButton();
if (_buttonsState[kPowerButton] == kON) {
- getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[22], _tvScreenFrameIndex, Common::Point(0, 37), 0, 0, 1);
- getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[23], _tvScreenFrameIndex++, Common::Point(238, 22), 0, 0, 1);
+ getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[22], _tvScreenFrameIndex, Common::Point(0, 37), kDrawFlagNone, 0, 1);
+ getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[23], _tvScreenFrameIndex++, Common::Point(238, 22), kDrawFlagNone, 0, 1);
_tvScreenFrameIndex %= GraphicResource::getFrameCount(_vm, getWorld()->graphicResourceIds[22]);
}
diff --git a/engines/asylum/puzzles/wheel.cpp b/engines/asylum/puzzles/wheel.cpp
index 738c6abbe9..dafce1061f 100644
--- a/engines/asylum/puzzles/wheel.cpp
+++ b/engines/asylum/puzzles/wheel.cpp
@@ -201,17 +201,17 @@ bool PuzzleWheel::update(const AsylumEvent &evt) {
getScreen()->draw(getWorld()->graphicResourceIds[0]);
// Blinking red light
- getScreen()->draw(getWorld()->graphicResourceIds[12], _frameIndexes[11], puzzleWheelPoints[12].x, puzzleWheelPoints[12].y, 0);
+ getScreen()->draw(getWorld()->graphicResourceIds[12], _frameIndexes[11], puzzleWheelPoints[12].x, puzzleWheelPoints[12].y);
_frameIndexes[11] = (_frameIndexes[11] + 1 ) % GraphicResource::getFrameCount(_vm, getWorld()->graphicResourceIds[12]);
// Clock
if (_showTurnedClock)
- getScreen()->draw(getWorld()->graphicResourceIds[_resourceIndexClock], _frameIndexes[9], 342, 87, 0);
+ getScreen()->draw(getWorld()->graphicResourceIds[_resourceIndexClock], _frameIndexes[9], 342, 87);
else
- getScreen()->draw(getWorld()->graphicResourceIds[_resourceIndex + 22], 0, 342, 87, 0);
+ getScreen()->draw(getWorld()->graphicResourceIds[_resourceIndex + 22], 0, 342, 87);
// Chain
- getScreen()->draw(getWorld()->graphicResourceIds[3], _frameIndexes[0], puzzleWheelPoints[3].x, puzzleWheelPoints[3].y, 0);
+ getScreen()->draw(getWorld()->graphicResourceIds[3], _frameIndexes[0], puzzleWheelPoints[3].x, puzzleWheelPoints[3].y);
// Update chain frame index
if (_moveChain) {
@@ -243,7 +243,7 @@ bool PuzzleWheel::update(const AsylumEvent &evt) {
pointIndex = 4 + i;
}
- getScreen()->draw(getWorld()->graphicResourceIds[resourceIndex], _frameIndexes[frameIndex], puzzleWheelPoints[pointIndex].x, puzzleWheelPoints[pointIndex].y, 0);
+ getScreen()->draw(getWorld()->graphicResourceIds[resourceIndex], _frameIndexes[frameIndex], puzzleWheelPoints[pointIndex].x, puzzleWheelPoints[pointIndex].y);
if (_frameIndexes[frameIndex] != (int32)GraphicResource::getFrameCount(_vm, getWorld()->graphicResourceIds[resourceIndex]) - 1)
++_frameIndexes[frameIndex];
@@ -254,7 +254,7 @@ bool PuzzleWheel::update(const AsylumEvent &evt) {
// Sparks
for (uint32 i = 0; i < 8; i++) {
if (_frameIndexesSparks[i] >= 0) {
- getScreen()->draw(getWorld()->graphicResourceIds[57 + i], _frameIndexesSparks[i], puzzleWheelPoints[48 + i].x, puzzleWheelPoints[48 + i].y, 0);
+ getScreen()->draw(getWorld()->graphicResourceIds[57 + i], _frameIndexesSparks[i], puzzleWheelPoints[48 + i].x, puzzleWheelPoints[48 + i].y);
if (_frameIndexesSparks[i] == (int32)GraphicResource::getFrameCount(_vm, getWorld()->graphicResourceIds[57 + i]) - 1)
_frameIndexesSparks[i] = -1;
@@ -265,9 +265,9 @@ bool PuzzleWheel::update(const AsylumEvent &evt) {
// Lever
if (_resourceIndexLever == 13)
- getScreen()->draw(getWorld()->graphicResourceIds[_resourceIndexLever], _frameIndexes[10], puzzleWheelPoints[13].x, puzzleWheelPoints[13].y, 0);
+ getScreen()->draw(getWorld()->graphicResourceIds[_resourceIndexLever], _frameIndexes[10], puzzleWheelPoints[13].x, puzzleWheelPoints[13].y);
else if (_resourceIndexLever == 54)
- getScreen()->draw(getWorld()->graphicResourceIds[_resourceIndexLever], _frameIndexes[10], puzzleWheelPoints[47].x, puzzleWheelPoints[47].y, 0);
+ getScreen()->draw(getWorld()->graphicResourceIds[_resourceIndexLever], _frameIndexes[10], puzzleWheelPoints[47].x, puzzleWheelPoints[47].y);
// Update lever frame index
if (_moveLever) {
@@ -291,7 +291,7 @@ bool PuzzleWheel::update(const AsylumEvent &evt) {
}
// Wheel
- getScreen()->draw(getWorld()->graphicResourceIds[30], _frameIndexWheel, puzzleWheelPoints[30].x, puzzleWheelPoints[30].y, 0);
+ getScreen()->draw(getWorld()->graphicResourceIds[30], _frameIndexWheel, puzzleWheelPoints[30].x, puzzleWheelPoints[30].y);
// Update wheel frame index
if (_showTurnedClock) {
diff --git a/engines/asylum/puzzles/writings.cpp b/engines/asylum/puzzles/writings.cpp
index 77397654a0..e9588b850b 100644
--- a/engines/asylum/puzzles/writings.cpp
+++ b/engines/asylum/puzzles/writings.cpp
@@ -103,8 +103,8 @@ bool PuzzleWritings::update(const AsylumEvent &evt) {
// The original blits part of the background onto the surface (9) and then adds it to the queue
- getScreen()->addGraphicToQueueMasked(getWorld()->graphicResourceIds[9], 0, mousePos, getWorld()->graphicResourceIds[8], mousePos, 0, 2);
- getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[7], _frameIndex, mousePos, 0, 0, 1);
+ getScreen()->addGraphicToQueueMasked(getWorld()->graphicResourceIds[9], 0, mousePos, getWorld()->graphicResourceIds[8], mousePos, kDrawFlagNone, 2);
+ getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[7], _frameIndex, mousePos, kDrawFlagNone, 0, 1);
}
getScreen()->drawGraphicsInQueue();
diff --git a/engines/asylum/resources/actor.cpp b/engines/asylum/resources/actor.cpp
index 687cea91cd..d4aa2b75b3 100644
--- a/engines/asylum/resources/actor.cpp
+++ b/engines/asylum/resources/actor.cpp
@@ -2337,18 +2337,18 @@ void Actor::adjustCoordinates(Common::Point *point) {
point->y = _point1.y - getWorld()->yTop;
}
-int32 Actor::getGraphicsFlags() {
+DrawFlags Actor::getGraphicsFlags() {
if (getWorld()->chapter == kChapter11) {
int res = strcmp((char *)&_name, "Dead Sarah");
if (res == 0)
- return 0;
+ return kDrawFlagNone;
}
if (_direction < kDirectionSE)
- return 0;
+ return kDrawFlagNone;
- return 2;
+ return kDrawFlagMirrorLeftRight;
}
int32 Actor::getDistance() const {
diff --git a/engines/asylum/resources/actor.h b/engines/asylum/resources/actor.h
index 9f4f3c9edc..1fde5ae992 100644
--- a/engines/asylum/resources/actor.h
+++ b/engines/asylum/resources/actor.h
@@ -504,11 +504,11 @@ private:
void updateGraphicData(uint32 offset);
/**
- * Gets the graphics flags for queuing the actor graphics
+ * Gets the graphics flag for queuing the actor graphics (mirrored or normal)
*
- * @return The graphics flags.
+ * @return The graphics flag.
*/
- int32 getGraphicsFlags();
+ DrawFlags getGraphicsFlags();
/**
* Gets a distance depending on actor direction
diff --git a/engines/asylum/resources/encounters.cpp b/engines/asylum/resources/encounters.cpp
index e6d6211bee..823b5de67f 100644
--- a/engines/asylum/resources/encounters.cpp
+++ b/engines/asylum/resources/encounters.cpp
@@ -850,7 +850,7 @@ bool Encounter::drawBackground() {
_background.transTableNum);
}
} else {
- getScreen()->draw(_background.resourceId, _background.frameIndex, _point.x, _point.y, 0);
+ getScreen()->draw(_background.resourceId, _background.frameIndex, _point.x, _point.y);
}
if (_data_455BE4) {
@@ -886,14 +886,13 @@ bool Encounter::drawPortraits() {
getScreen()->draw(_portrait1.resourceId,
_portrait1.frameIndex,
_point.x + 5,
- _point.y + 5,
- 0);
+ _point.y + 5);
else
getScreen()->draw(_portrait1.resourceId,
_portrait1.frameIndex,
_point.x + 5,
_point.y + 5,
- 0,
+ kDrawFlagNone,
_portrait1.transTableNum);
if (_portrait1.transTableNum != _portrait1.transTableMax) {
@@ -921,14 +920,13 @@ bool Encounter::drawPortraits() {
getScreen()->draw(_portrait2.resourceId,
_portrait2.frameIndex,
_point.x - frameRect.width() + _background.rect.width() - 6,
- _point.y + 5,
- 0);
+ _point.y + 5);
else
getScreen()->draw(_portrait2.resourceId,
_portrait2.frameIndex,
_point.x - frameRect.width() + _background.rect.width() - 6,
_point.y + 5,
- 0,
+ kDrawFlagNone,
_portrait2.transTableNum);
if (_portrait2.transTableNum != _portrait2.transTableMax) {
@@ -982,7 +980,7 @@ void Encounter::drawStructs() {
_drawingStructs[0].frameIndex,
_drawingStructs[0].point2.x,
_drawingStructs[0].point2.y,
- 0,
+ kDrawFlagNone,
0);
_drawingStructs[0].status = 0;
@@ -995,7 +993,7 @@ void Encounter::drawStructs() {
_drawingStructs[0].frameIndex,
_drawingStructs[0].point2.x,
_drawingStructs[0].point2.y,
- 0,
+ kDrawFlagNone,
val);
if (_drawingStructs[0].status == 1)
@@ -1009,8 +1007,7 @@ void Encounter::drawStructs() {
getScreen()->draw(_drawingStructs[0].resourceId,
_drawingStructs[0].frameIndex,
_drawingStructs[0].point2.x,
- _drawingStructs[0].point2.y,
- 0);
+ _drawingStructs[0].point2.y);
_drawingStructs[0].status = 0;
break;
@@ -1041,7 +1038,7 @@ void Encounter::drawStructs() {
_drawingStructs[1].frameIndex,
_drawingStructs[1].point2.x,
_drawingStructs[1].point2.y,
- 0,
+ kDrawFlagNone,
0);
_drawingStructs[1].status = 0;
@@ -1054,7 +1051,7 @@ void Encounter::drawStructs() {
_drawingStructs[1].frameIndex,
_drawingStructs[1].point2.x,
_drawingStructs[1].point2.y,
- 0,
+ kDrawFlagNone,
val);
if (_drawingStructs[1].status == 1)
@@ -1068,8 +1065,7 @@ void Encounter::drawStructs() {
getScreen()->draw(_drawingStructs[1].resourceId,
_drawingStructs[1].frameIndex,
_drawingStructs[1].point2.x,
- _drawingStructs[1].point2.y,
- 0);
+ _drawingStructs[1].point2.y);
_drawingStructs[1].status = 0;
break;
diff --git a/engines/asylum/resources/object.cpp b/engines/asylum/resources/object.cpp
index dc3581cd88..7379023933 100644
--- a/engines/asylum/resources/object.cpp
+++ b/engines/asylum/resources/object.cpp
@@ -202,7 +202,7 @@ void Object::draw() {
adjustCoordinates(&point);
if (_field_67C <= 0 || _field_67C >= 4 || Config.performance <= 1) {
- getScreen()->addGraphicToQueue(_resourceId, _frameIndex, point, (flags >> 11) & kObjectFlag2, _field_67C - 3, _priority);
+ getScreen()->addGraphicToQueue(_resourceId, _frameIndex, point, (DrawFlags)((flags >> 11) & kDrawFlagMirrorLeftRight), _field_67C - 3, _priority);
} else {
getScreen()->addGraphicToQueueCrossfade(_resourceId, _frameIndex, point, getWorld()->backgroundImage, Common::Point(getWorld()->xLeft, getWorld()->yTop), _field_67C - 1);
}
diff --git a/engines/asylum/shared.h b/engines/asylum/shared.h
index e4697a21c5..b7d79b6633 100644
--- a/engines/asylum/shared.h
+++ b/engines/asylum/shared.h
@@ -244,6 +244,14 @@ enum ResourcesId {
#define kMusicStopped -666
+//////////////////////////////////////////////////////////////////////////
+// Drawing
+//////////////////////////////////////////////////////////////////////////
+enum DrawFlags {
+ kDrawFlagNone = 0,
+ kDrawFlagMirrorLeftRight = 2
+};
+
//////////////////////////////////////////////////////////////////////////
// Actions
//////////////////////////////////////////////////////////////////////////
diff --git a/engines/asylum/system/screen.cpp b/engines/asylum/system/screen.cpp
index 3cf78a0080..02da924a4f 100644
--- a/engines/asylum/system/screen.cpp
+++ b/engines/asylum/system/screen.cpp
@@ -59,23 +59,23 @@ Screen::~Screen() {
// Drawing
//////////////////////////////////////////////////////////////////////////
void Screen::draw(ResourceId resourceId) {
- draw(resourceId, 0, 0, 0, 0, kResourceNone, 0, 0, false);
+ draw(resourceId, 0, 0, 0, kDrawFlagNone, kResourceNone, 0, 0, false);
}
-void Screen::draw(ResourceId resourceId, uint32 frameIndex, int32 x, int32 y, int32 flags, bool colorKey) {
+void Screen::draw(ResourceId resourceId, uint32 frameIndex, int32 x, int32 y, DrawFlags flags, bool colorKey) {
draw(resourceId, frameIndex, x, y, flags, kResourceNone, 0, 0, colorKey);
}
-void Screen::draw(ResourceId resourceId, uint32 frameIndex, int32 x, int32 y, int32 flags, int32 transTableNum) {
+void Screen::draw(ResourceId resourceId, uint32 frameIndex, int32 x, int32 y, DrawFlags flags, int32 transTableNum) {
byte *index = _transTableIndex;
selectTransTable(transTableNum);
- draw(resourceId, frameIndex, x, y, flags | 0x90000000);
+ draw(resourceId, frameIndex, x, y, (DrawFlags)(flags | 0x90000000));
_transTableIndex = index;
}
-void Screen::draw(ResourceId resourceId, uint32 frameIndex, int32 x, int32 y, int32 flags, ResourceId resourceIdDestination, int32 destX, int32 destY, bool colorKey) {
+void Screen::draw(ResourceId resourceId, uint32 frameIndex, int32 x, int32 y, DrawFlags flags, ResourceId resourceIdDestination, int32 destX, int32 destY, bool colorKey) {
// Get the frame to draw
GraphicResource *resource = new GraphicResource(_vm, resourceId);
GraphicFrame *frame = resource->getFrame(frameIndex);
@@ -85,7 +85,7 @@ void Screen::draw(ResourceId resourceId, uint32 frameIndex, int32 x, int32 y, in
Common::Rect destination;
destination.left = x + frame->x;
- if (flags & 2) {
+ if (flags & kDrawFlagMirrorLeftRight) {
if (_flag == -1) {
if ((resource->getData().flags & 15) >= 2) {
destination.left = x + resource->getData().maxWidth - frame->getWidth() - frame->x;
@@ -318,7 +318,7 @@ void Screen::selectTransTable(uint32 index) {
//////////////////////////////////////////////////////////////////////////
// Graphic queue
//////////////////////////////////////////////////////////////////////////
-void Screen::addGraphicToQueue(ResourceId resourceId, uint32 frameIndex, Common::Point point, int32 flags, int32 transTableNum, int32 priority) {
+void Screen::addGraphicToQueue(ResourceId resourceId, uint32 frameIndex, Common::Point point, DrawFlags flags, int32 transTableNum, int32 priority) {
GraphicQueueItem item;
item.priority = priority;
@@ -332,7 +332,7 @@ void Screen::addGraphicToQueue(ResourceId resourceId, uint32 frameIndex, Common:
_queueItems.push_back(item);
}
-void Screen::addGraphicToQueueMasked(ResourceId resourceId, uint32 frameIndex, Common::Point source, int32 resourceIdDestination, Common::Point destination, int32 flags, int32 priority) {
+void Screen::addGraphicToQueueMasked(ResourceId resourceId, uint32 frameIndex, Common::Point source, int32 resourceIdDestination, Common::Point destination, DrawFlags flags, int32 priority) {
GraphicQueueItem item;
item.priority = priority;
@@ -424,6 +424,7 @@ void Screen::blit(GraphicFrame *frame, Common::Rect *source, Common::Rect *desti
void Screen::blt(Common::Rect *dest, GraphicFrame* frame, Common::Rect *source, int32 flags, bool useColorKey) {
// TODO adjust destination rect
+ // TODO handle mirror flag
if (useColorKey) {
copyToBackBufferWithTransparency((byte *)frame->surface.pixels + (source->top * frame->surface.w + source->left),
frame->surface.w,
@@ -436,8 +437,8 @@ void Screen::blt(Common::Rect *dest, GraphicFrame* frame, Common::Rect *source,
frame->surface.w,
dest->left,
dest->top,
- source->width(),
- source->height());
+ source->width(),
+ source->height());
}
}
diff --git a/engines/asylum/system/screen.h b/engines/asylum/system/screen.h
index 9ebdb838f8..39ee5a4716 100644
--- a/engines/asylum/system/screen.h
+++ b/engines/asylum/system/screen.h
@@ -56,7 +56,7 @@ typedef struct GraphicQueueItem {
Common::Point source;
ResourceId resourceIdDestination;
Common::Point destination;
- int32 flags;
+ DrawFlags flags;
int32 transTableNum;
GraphicQueueItem() {
@@ -66,7 +66,7 @@ typedef struct GraphicQueueItem {
resourceId = kResourceNone;
frameIndex = 0;
resourceIdDestination = kResourceNone;
- flags = 0;
+ flags = kDrawFlagNone;
transTableNum = 0;
}
} GraphicQueueItem;
@@ -78,9 +78,9 @@ public:
// Drawing
void draw(ResourceId resourceId);
- void draw(ResourceId resourceId, uint32 frameIndex, int32 x, int32 y, int32 flags, bool colorKey = true);
- void draw(ResourceId resourceId, uint32 frameIndex, int32 x, int32 y, int32 flags, int32 transTableNum);
- void draw(ResourceId resourceId, uint32 frameIndex, int32 x, int32 y, int32 flags, ResourceId resourceId2, int32 destX, int32 destY, bool colorKey = true);
+ void draw(ResourceId resourceId, uint32 frameIndex, int32 x, int32 y, DrawFlags flags = kDrawFlagNone, bool colorKey = true);
+ void draw(ResourceId resourceId, uint32 frameIndex, int32 x, int32 y, DrawFlags flags, int32 transTableNum);
+ void draw(ResourceId resourceId, uint32 frameIndex, int32 x, int32 y, DrawFlags flags, ResourceId resourceId2, int32 destX, int32 destY, bool colorKey = true);
// Misc
void clear();
@@ -114,9 +114,9 @@ public:
byte *getTransTableIndex() { return _transTableIndex; }
// Graphic queue
- void addGraphicToQueue(ResourceId resourceId, uint32 frameIndex, Common::Point point, int32 flags, int32 transTableNum, int32 priority);
+ void addGraphicToQueue(ResourceId resourceId, uint32 frameIndex, Common::Point point, DrawFlags flags, int32 transTableNum, int32 priority);
void addGraphicToQueueCrossfade(ResourceId resourceId, uint32 frameIndex, Common::Point source, int32 objectResourceId, Common::Point destination, int32 transTableNum);
- void addGraphicToQueueMasked(ResourceId resourceId, uint32 frameIndex, Common::Point point, int32 objectResourceId, Common::Point destination, int32 flags, int32 priority);
+ void addGraphicToQueueMasked(ResourceId resourceId, uint32 frameIndex, Common::Point point, int32 objectResourceId, Common::Point destination, DrawFlags flags, int32 priority);
void addGraphicToQueue(GraphicQueueItem const &item);
void drawGraphicsInQueue();
void clearGraphicsInQueue();
diff --git a/engines/asylum/system/text.cpp b/engines/asylum/system/text.cpp
index 6a9b7ecb7c..3c993fee74 100644
--- a/engines/asylum/system/text.cpp
+++ b/engines/asylum/system/text.cpp
@@ -129,9 +129,9 @@ void Text::drawChar(char character) {
error("[Text::drawChar] font resource hasn't been loaded yet!");
if (_transTableNum) {
- getScreen()->draw(_fontResource->getResourceId(), (uint8)character, _posX, _posY, 0, _transTableNum);
+ getScreen()->draw(_fontResource->getResourceId(), (uint8)character, _posX, _posY, kDrawFlagNone, _transTableNum);
} else {
- getScreen()->draw(_fontResource->getResourceId(), (uint8)character, _posX, _posY, 0);
+ getScreen()->draw(_fontResource->getResourceId(), (uint8)character, _posX, _posY);
}
GraphicFrame *fontLetter = _fontResource->getFrame((uint8)character);
diff --git a/engines/asylum/views/menu.cpp b/engines/asylum/views/menu.cpp
index 84f85026dd..7b52fc8e89 100644
--- a/engines/asylum/views/menu.cpp
+++ b/engines/asylum/views/menu.cpp
@@ -413,7 +413,7 @@ bool Menu::update() {
//getScreen()->fillRect(260, 229, 119, 16, 0);
// Draw background
- getScreen()->draw(kBackground, (_activeScreen == kMenuNone) ? 1 : 0, 0, 0, 0);
+ getScreen()->draw(kBackground, (_activeScreen == kMenuNone) ? 1 : 0, 0, 0);
uint32 frameIndex = 0;
@@ -429,13 +429,13 @@ bool Menu::update() {
if (_activeScreen == kMenuNone) {
// Draw eye
- getScreen()->draw(kEye, frameIndex, 0, 0, 0);
+ getScreen()->draw(kEye, frameIndex, 0, 0);
// Find mouse position
MenuScreen icon = findMousePosition();
if (icon != kMenuNone) {
// Draw icon
- getScreen()->draw(MAKE_RESOURCE(kResourcePackShared, icon + 4), _iconFrames[icon], 0, 0, 0);
+ getScreen()->draw(MAKE_RESOURCE(kResourcePackShared, icon + 4), _iconFrames[icon], 0, 0);
_iconFrames[icon] = (_iconFrames[icon] + 1) % GraphicResource::getFrameCount(_vm, MAKE_RESOURCE(kResourcePackShared, icon + 4));
// Draw text
@@ -459,10 +459,10 @@ bool Menu::update() {
_dword_455C74 = 0;
}
} else {
- getScreen()->draw(kEye, frameIndex, 0, 0, 0, 3);
+ getScreen()->draw(kEye, frameIndex, 0, 0, kDrawFlagNone, 3);
// Draw icon
- getScreen()->draw(MAKE_RESOURCE(kResourcePackShared, _activeScreen + 4), _iconFrames[_activeScreen], 0, 0, 0);
+ getScreen()->draw(MAKE_RESOURCE(kResourcePackShared, _activeScreen + 4), _iconFrames[_activeScreen], 0, 0);
_iconFrames[_activeScreen] = (_iconFrames[_activeScreen] + 1) % GraphicResource::getFrameCount(_vm, MAKE_RESOURCE(kResourcePackShared, _activeScreen + 4));
}
@@ -1532,7 +1532,7 @@ void Menu::updateShowCredits() {
getScreen()->draw(MAKE_RESOURCE(kResourcePackShared, 33));
} else {
getScreen()->draw(MAKE_RESOURCE(kResourcePackShared, 23));
- getScreen()->draw(MAKE_RESOURCE(kResourcePackShared, 24), _creditsFrameIndex++ / 2, 0, 0, 0, false);
+ getScreen()->draw(MAKE_RESOURCE(kResourcePackShared, 24), _creditsFrameIndex++ / 2, 0, 0, kDrawFlagNone, false);
_creditsFrameIndex %= 2 * GraphicResource::getFrameCount(_vm, MAKE_RESOURCE(kResourcePackShared, 24));
}
diff --git a/engines/asylum/views/scene.cpp b/engines/asylum/views/scene.cpp
index a11bcd0d89..ca7ab7910b 100644
--- a/engines/asylum/views/scene.cpp
+++ b/engines/asylum/views/scene.cpp
@@ -2362,7 +2362,7 @@ bool Scene::drawScene() {
}
// Draw scene background
- getScreen()->draw(_ws->backgroundImage, 0, -_ws->xLeft, -_ws->yTop, 0, false);
+ getScreen()->draw(_ws->backgroundImage, 0, -_ws->xLeft, -_ws->yTop, kDrawFlagNone, false);
// Draw actors on the update list
buildUpdateList();
@@ -2608,7 +2608,7 @@ void Scene::drawRain() {
for (uint y = 0; y < 512; y = y + 64) {
for (uint x = 0; x < 704; x = x + 64) {
- getScreen()->draw(MAKE_RESOURCE(kResourcePackShared, 58), _chapter5RainFrameIndex, x + (_ws->xLeft % 64) / 8, y + (_ws->yTop % 64) / 8, 0);
+ getScreen()->draw(MAKE_RESOURCE(kResourcePackShared, 58), _chapter5RainFrameIndex, x + (_ws->xLeft % 64) / 8, y + (_ws->yTop % 64) / 8);
}
}
diff --git a/engines/asylum/views/scenetitle.cpp b/engines/asylum/views/scenetitle.cpp
index 5a02de2e27..f05925b1b6 100644
--- a/engines/asylum/views/scenetitle.cpp
+++ b/engines/asylum/views/scenetitle.cpp
@@ -71,7 +71,7 @@ void SceneTitle::update(int32 tick) {
return;
getScreen()->draw(getWorld()->sceneTitleGraphicResourceId);
- getScreen()->draw(MAKE_RESOURCE(kResourcePackSound, 17), _spinnerFrameIndex, (_spinnerProgress / 590.0 * 580) - 290 , 0, 0, false);
+ getScreen()->draw(MAKE_RESOURCE(kResourcePackSound, 17), _spinnerFrameIndex, (_spinnerProgress / 590.0 * 580) - 290 , 0, kDrawFlagNone, false);
getText()->drawCentered(320, 30, 24, MAKE_RESOURCE(kResourcePackText, 1811 + getWorld()->chapter));
// This is not from the original. It's just some arbitrary math to throttle the progress indicator.
Commit: 9f6d671569c64bf242e672cfc152638c09b87fd9
https://github.com/scummvm/scummvm/commit/9f6d671569c64bf242e672cfc152638c09b87fd9
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:56+02:00
Commit Message:
ASYLUM: Change Screen::draw() functions to take Common::Point as source/destination parameters
Changed paths:
engines/asylum/console.cpp
engines/asylum/puzzles/clock.cpp
engines/asylum/puzzles/tictactoe.cpp
engines/asylum/puzzles/wheel.cpp
engines/asylum/resources/encounters.cpp
engines/asylum/system/screen.cpp
engines/asylum/system/screen.h
engines/asylum/system/text.cpp
engines/asylum/system/text.h
engines/asylum/views/menu.cpp
engines/asylum/views/scene.cpp
engines/asylum/views/scenetitle.cpp
diff --git a/engines/asylum/console.cpp b/engines/asylum/console.cpp
index 3d89a6cff5..8425ff5311 100644
--- a/engines/asylum/console.cpp
+++ b/engines/asylum/console.cpp
@@ -525,7 +525,7 @@ bool Console::cmdDrawResource(int32 argc, const char **argv) {
// Draw resource
getScreen()->clear();
- getScreen()->draw(MAKE_RESOURCE(pack, index), frame, 0, 0);
+ getScreen()->draw(MAKE_RESOURCE(pack, index), frame, Common::Point(0, 0));
getScreen()->copyBackBufferToScreen();
g_system->updateScreen();
diff --git a/engines/asylum/puzzles/clock.cpp b/engines/asylum/puzzles/clock.cpp
index 339cef9bf1..231df7a6c5 100644
--- a/engines/asylum/puzzles/clock.cpp
+++ b/engines/asylum/puzzles/clock.cpp
@@ -108,12 +108,12 @@ bool PuzzleClock::update(const AsylumEvent &evt) {
getScreen()->clearGraphicsInQueue();
getScreen()->draw(getWorld()->graphicResourceIds[5]);
- getScreen()->draw(getWorld()->graphicResourceIds[2], _frameIndexes[0], puzzleClockPoints[0].x, puzzleClockPoints[0].y);
+ getScreen()->draw(getWorld()->graphicResourceIds[2], _frameIndexes[0], puzzleClockPoints[0]);
_frameIndexes[0]++;
_frameIndexes[0] %= GraphicResource::getFrameCount(_vm, getWorld()->graphicResourceIds[2]);
- getScreen()->draw(getWorld()->graphicResourceIds[4], _frameIndexes[1], puzzleClockPoints[1].x, puzzleClockPoints[1].y);
- getScreen()->draw(getWorld()->graphicResourceIds[3], _frameIndexes[2], puzzleClockPoints[2].x, puzzleClockPoints[2].y);
+ getScreen()->draw(getWorld()->graphicResourceIds[4], _frameIndexes[1], puzzleClockPoints[1]);
+ getScreen()->draw(getWorld()->graphicResourceIds[3], _frameIndexes[2], puzzleClockPoints[2]);
if (_currentFrameIndex == _frameIndexes[2]) {
if (_showCursor) {
diff --git a/engines/asylum/puzzles/tictactoe.cpp b/engines/asylum/puzzles/tictactoe.cpp
index 322c8521d0..14c47cb138 100644
--- a/engines/asylum/puzzles/tictactoe.cpp
+++ b/engines/asylum/puzzles/tictactoe.cpp
@@ -227,9 +227,9 @@ void PuzzleTicTacToe::drawField() {
if (_lastMarkedField == i) {
if (mark == 'O')
- getScreen()->draw(getWorld()->graphicResourceIds[2], _frameIndex, point.x, point.y);
+ getScreen()->draw(getWorld()->graphicResourceIds[2], _frameIndex, point);
else if (mark == 'X')
- getScreen()->draw(getWorld()->graphicResourceIds[1], _frameIndex, point.x, point.y);
+ getScreen()->draw(getWorld()->graphicResourceIds[1], _frameIndex, point);
// Update _frameIndex
++_frameIndex;
@@ -251,9 +251,9 @@ void PuzzleTicTacToe::drawField() {
}
} else {
if (mark == 'O')
- getScreen()->draw(getWorld()->graphicResourceIds[2], 12, point.x, point.y);
+ getScreen()->draw(getWorld()->graphicResourceIds[2], 12, point);
else if (mark == 'X')
- getScreen()->draw(getWorld()->graphicResourceIds[1], 14, point.x, point.y);
+ getScreen()->draw(getWorld()->graphicResourceIds[1], 14, point);
}
}
@@ -267,98 +267,98 @@ void PuzzleTicTacToe::drawField() {
break;
case 1:
- getScreen()->draw(getWorld()->graphicResourceIds[5], _frameIndex, 38, 345);
+ getScreen()->draw(getWorld()->graphicResourceIds[5], _frameIndex, Common::Point(38, 345));
break;
case 2:
- getScreen()->draw(getWorld()->graphicResourceIds[5], _frameIndex, 17, 226);
+ getScreen()->draw(getWorld()->graphicResourceIds[5], _frameIndex, Common::Point(17, 226));
break;
case 3:
- getScreen()->draw(getWorld()->graphicResourceIds[5], _frameIndex, 1, 104);
+ getScreen()->draw(getWorld()->graphicResourceIds[5], _frameIndex, Common::Point(1, 104));
break;
case 4:
- getScreen()->draw(getWorld()->graphicResourceIds[6], _frameIndex, 43, 117);
+ getScreen()->draw(getWorld()->graphicResourceIds[6], _frameIndex, Common::Point(43, 117));
break;
case 5:
- getScreen()->draw(getWorld()->graphicResourceIds[6], _frameIndex, 176, 104);
+ getScreen()->draw(getWorld()->graphicResourceIds[6], _frameIndex, Common::Point(176, 104));
break;
case 6:
- getScreen()->draw(getWorld()->graphicResourceIds[6], _frameIndex, 299, 85);
+ getScreen()->draw(getWorld()->graphicResourceIds[6], _frameIndex, Common::Point(299, 85));
break;
case 7:
if (_counter2 == 0)
- getScreen()->draw(getWorld()->graphicResourceIds[8], _frameIndex, 30, 149);
+ getScreen()->draw(getWorld()->graphicResourceIds[8], _frameIndex, Common::Point(30, 149));
else if (_counter2 == 1)
- getScreen()->draw(getWorld()->graphicResourceIds[8], _frameIndex, 180, 249);
+ getScreen()->draw(getWorld()->graphicResourceIds[8], _frameIndex, Common::Point(180, 249));
else {
- getScreen()->draw(getWorld()->graphicResourceIds[8], 6, 30, 149);
- getScreen()->draw(getWorld()->graphicResourceIds[8], 6, 180, 249);
- getScreen()->draw(getWorld()->graphicResourceIds[8], _frameIndex, 330, 349);
+ getScreen()->draw(getWorld()->graphicResourceIds[8], 6, Common::Point(30, 149));
+ getScreen()->draw(getWorld()->graphicResourceIds[8], 6, Common::Point(180, 249));
+ getScreen()->draw(getWorld()->graphicResourceIds[8], _frameIndex, Common::Point(330, 349));
}
break;
case 8:
if (_counter2 == 0)
- getScreen()->draw(getWorld()->graphicResourceIds[10], _frameIndex, 69, 66);
+ getScreen()->draw(getWorld()->graphicResourceIds[10], _frameIndex, Common::Point(69, 66));
else if (_counter2 == 1)
- getScreen()->draw(getWorld()->graphicResourceIds[10], _frameIndex, -22, 220);
+ getScreen()->draw(getWorld()->graphicResourceIds[10], _frameIndex, Common::Point(-22, 220));
else {
- getScreen()->draw(getWorld()->graphicResourceIds[10], 6, 69, 66);
- getScreen()->draw(getWorld()->graphicResourceIds[10], 6, -22, 220);
- getScreen()->draw(getWorld()->graphicResourceIds[10], _frameIndex, -110, 370);
+ getScreen()->draw(getWorld()->graphicResourceIds[10], 6, Common::Point( 69, 66));
+ getScreen()->draw(getWorld()->graphicResourceIds[10], 6, Common::Point(-22, 220));
+ getScreen()->draw(getWorld()->graphicResourceIds[10], _frameIndex, Common::Point(-110, 370));
}
break;
case 9:
- getScreen()->draw(getWorld()->graphicResourceIds[4], _frameIndex, 38, 345);
+ getScreen()->draw(getWorld()->graphicResourceIds[4], _frameIndex, Common::Point(38, 345));
break;
case 10:
- getScreen()->draw(getWorld()->graphicResourceIds[4], _frameIndex, 17, 226);
+ getScreen()->draw(getWorld()->graphicResourceIds[4], _frameIndex, Common::Point(17, 226));
break;
case 11:
- getScreen()->draw(getWorld()->graphicResourceIds[4], _frameIndex, 1, 104);
+ getScreen()->draw(getWorld()->graphicResourceIds[4], _frameIndex, Common::Point(1, 104));
break;
case 12:
- getScreen()->draw(getWorld()->graphicResourceIds[11], _frameIndex, 43, 117);
+ getScreen()->draw(getWorld()->graphicResourceIds[11], _frameIndex, Common::Point(43, 117));
break;
case 13:
- getScreen()->draw(getWorld()->graphicResourceIds[11], _frameIndex, 176, 104);
+ getScreen()->draw(getWorld()->graphicResourceIds[11], _frameIndex, Common::Point(176, 104));
break;
case 14:
- getScreen()->draw(getWorld()->graphicResourceIds[11], _frameIndex, 299, 85);
+ getScreen()->draw(getWorld()->graphicResourceIds[11], _frameIndex, Common::Point(299, 85));
break;
case 15:
if (_counter2 == 0)
- getScreen()->draw(getWorld()->graphicResourceIds[7], _frameIndex, 30, 149);
+ getScreen()->draw(getWorld()->graphicResourceIds[7], _frameIndex, Common::Point(30, 149));
else if (_counter2 == 1)
- getScreen()->draw(getWorld()->graphicResourceIds[7], _frameIndex, 180, 249);
+ getScreen()->draw(getWorld()->graphicResourceIds[7], _frameIndex, Common::Point(180, 249));
else {
- getScreen()->draw(getWorld()->graphicResourceIds[7], 6, 30, 149);
- getScreen()->draw(getWorld()->graphicResourceIds[7], 6, 180, 249);
- getScreen()->draw(getWorld()->graphicResourceIds[7], _frameIndex, 330, 349);
+ getScreen()->draw(getWorld()->graphicResourceIds[7], 6, Common::Point(30, 149));
+ getScreen()->draw(getWorld()->graphicResourceIds[7], 6, Common::Point(180, 249));
+ getScreen()->draw(getWorld()->graphicResourceIds[7], _frameIndex, Common::Point(330, 349));
}
break;
case 16:
if (_counter2 == 0)
- getScreen()->draw(getWorld()->graphicResourceIds[9], _frameIndex, 69, 66);
+ getScreen()->draw(getWorld()->graphicResourceIds[9], _frameIndex, Common::Point(69, 66));
else if (_counter2 == 1)
- getScreen()->draw(getWorld()->graphicResourceIds[9], _frameIndex, -22, 220);
+ getScreen()->draw(getWorld()->graphicResourceIds[9], _frameIndex, Common::Point(-22, 220));
else {
- getScreen()->draw(getWorld()->graphicResourceIds[9], 6, 69, 66);
- getScreen()->draw(getWorld()->graphicResourceIds[9], 6, -22, 220);
- getScreen()->draw(getWorld()->graphicResourceIds[9], _frameIndex, -110, 370);
+ getScreen()->draw(getWorld()->graphicResourceIds[9], 6, Common::Point(69, 66));
+ getScreen()->draw(getWorld()->graphicResourceIds[9], 6, Common::Point(-22, 220));
+ getScreen()->draw(getWorld()->graphicResourceIds[9], _frameIndex, Common::Point(-110, 370));
}
break;
}
@@ -378,7 +378,7 @@ void PuzzleTicTacToe::drawField() {
_counter = 30;
}
- getScreen()->draw(getWorld()->graphicResourceIds[17], 0, 0, 0);
+ getScreen()->draw(getWorld()->graphicResourceIds[17], 0, Common::Point(0, 0));
}
void PuzzleTicTacToe::updatePositions(uint32 field1, uint32 field2, uint32 field3) {
diff --git a/engines/asylum/puzzles/wheel.cpp b/engines/asylum/puzzles/wheel.cpp
index dafce1061f..9c558352e1 100644
--- a/engines/asylum/puzzles/wheel.cpp
+++ b/engines/asylum/puzzles/wheel.cpp
@@ -201,17 +201,17 @@ bool PuzzleWheel::update(const AsylumEvent &evt) {
getScreen()->draw(getWorld()->graphicResourceIds[0]);
// Blinking red light
- getScreen()->draw(getWorld()->graphicResourceIds[12], _frameIndexes[11], puzzleWheelPoints[12].x, puzzleWheelPoints[12].y);
+ getScreen()->draw(getWorld()->graphicResourceIds[12], _frameIndexes[11], puzzleWheelPoints[12]);
_frameIndexes[11] = (_frameIndexes[11] + 1 ) % GraphicResource::getFrameCount(_vm, getWorld()->graphicResourceIds[12]);
// Clock
if (_showTurnedClock)
- getScreen()->draw(getWorld()->graphicResourceIds[_resourceIndexClock], _frameIndexes[9], 342, 87);
+ getScreen()->draw(getWorld()->graphicResourceIds[_resourceIndexClock], _frameIndexes[9], Common::Point(342, 87));
else
- getScreen()->draw(getWorld()->graphicResourceIds[_resourceIndex + 22], 0, 342, 87);
+ getScreen()->draw(getWorld()->graphicResourceIds[_resourceIndex + 22], 0, Common::Point(342, 87));
// Chain
- getScreen()->draw(getWorld()->graphicResourceIds[3], _frameIndexes[0], puzzleWheelPoints[3].x, puzzleWheelPoints[3].y);
+ getScreen()->draw(getWorld()->graphicResourceIds[3], _frameIndexes[0], puzzleWheelPoints[3]);
// Update chain frame index
if (_moveChain) {
@@ -243,7 +243,7 @@ bool PuzzleWheel::update(const AsylumEvent &evt) {
pointIndex = 4 + i;
}
- getScreen()->draw(getWorld()->graphicResourceIds[resourceIndex], _frameIndexes[frameIndex], puzzleWheelPoints[pointIndex].x, puzzleWheelPoints[pointIndex].y);
+ getScreen()->draw(getWorld()->graphicResourceIds[resourceIndex], _frameIndexes[frameIndex], puzzleWheelPoints[pointIndex]);
if (_frameIndexes[frameIndex] != (int32)GraphicResource::getFrameCount(_vm, getWorld()->graphicResourceIds[resourceIndex]) - 1)
++_frameIndexes[frameIndex];
@@ -254,7 +254,7 @@ bool PuzzleWheel::update(const AsylumEvent &evt) {
// Sparks
for (uint32 i = 0; i < 8; i++) {
if (_frameIndexesSparks[i] >= 0) {
- getScreen()->draw(getWorld()->graphicResourceIds[57 + i], _frameIndexesSparks[i], puzzleWheelPoints[48 + i].x, puzzleWheelPoints[48 + i].y);
+ getScreen()->draw(getWorld()->graphicResourceIds[57 + i], _frameIndexesSparks[i], puzzleWheelPoints[48 + i]);
if (_frameIndexesSparks[i] == (int32)GraphicResource::getFrameCount(_vm, getWorld()->graphicResourceIds[57 + i]) - 1)
_frameIndexesSparks[i] = -1;
@@ -265,9 +265,9 @@ bool PuzzleWheel::update(const AsylumEvent &evt) {
// Lever
if (_resourceIndexLever == 13)
- getScreen()->draw(getWorld()->graphicResourceIds[_resourceIndexLever], _frameIndexes[10], puzzleWheelPoints[13].x, puzzleWheelPoints[13].y);
+ getScreen()->draw(getWorld()->graphicResourceIds[_resourceIndexLever], _frameIndexes[10], puzzleWheelPoints[13]);
else if (_resourceIndexLever == 54)
- getScreen()->draw(getWorld()->graphicResourceIds[_resourceIndexLever], _frameIndexes[10], puzzleWheelPoints[47].x, puzzleWheelPoints[47].y);
+ getScreen()->draw(getWorld()->graphicResourceIds[_resourceIndexLever], _frameIndexes[10], puzzleWheelPoints[47]);
// Update lever frame index
if (_moveLever) {
@@ -291,7 +291,7 @@ bool PuzzleWheel::update(const AsylumEvent &evt) {
}
// Wheel
- getScreen()->draw(getWorld()->graphicResourceIds[30], _frameIndexWheel, puzzleWheelPoints[30].x, puzzleWheelPoints[30].y);
+ getScreen()->draw(getWorld()->graphicResourceIds[30], _frameIndexWheel, puzzleWheelPoints[30]);
// Update wheel frame index
if (_showTurnedClock) {
diff --git a/engines/asylum/resources/encounters.cpp b/engines/asylum/resources/encounters.cpp
index 823b5de67f..0ac87eb86e 100644
--- a/engines/asylum/resources/encounters.cpp
+++ b/engines/asylum/resources/encounters.cpp
@@ -850,7 +850,7 @@ bool Encounter::drawBackground() {
_background.transTableNum);
}
} else {
- getScreen()->draw(_background.resourceId, _background.frameIndex, _point.x, _point.y);
+ getScreen()->draw(_background.resourceId, _background.frameIndex, _point);
}
if (_data_455BE4) {
@@ -885,13 +885,11 @@ bool Encounter::drawPortraits() {
if (_portrait1.transTableNum == 3 )
getScreen()->draw(_portrait1.resourceId,
_portrait1.frameIndex,
- _point.x + 5,
- _point.y + 5);
+ _point + Common::Point(5, 5));
else
getScreen()->draw(_portrait1.resourceId,
_portrait1.frameIndex,
- _point.x + 5,
- _point.y + 5,
+ _point + Common::Point(5, 5),
kDrawFlagNone,
_portrait1.transTableNum);
@@ -919,13 +917,11 @@ bool Encounter::drawPortraits() {
if (_portrait2.transTableNum == 3)
getScreen()->draw(_portrait2.resourceId,
_portrait2.frameIndex,
- _point.x - frameRect.width() + _background.rect.width() - 6,
- _point.y + 5);
+ Common::Point(_point.x - frameRect.width() + _background.rect.width() - 6, _point.y + 5));
else
getScreen()->draw(_portrait2.resourceId,
_portrait2.frameIndex,
- _point.x - frameRect.width() + _background.rect.width() - 6,
- _point.y + 5,
+ Common::Point(_point.x - frameRect.width() + _background.rect.width() - 6, _point.y + 5),
kDrawFlagNone,
_portrait2.transTableNum);
@@ -978,8 +974,7 @@ void Encounter::drawStructs() {
case -1:
getScreen()->draw(_drawingStructs[0].resourceId,
_drawingStructs[0].frameIndex,
- _drawingStructs[0].point2.x,
- _drawingStructs[0].point2.y,
+ _drawingStructs[0].point2,
kDrawFlagNone,
0);
@@ -991,8 +986,7 @@ void Encounter::drawStructs() {
case 2:
getScreen()->draw(_drawingStructs[0].resourceId,
_drawingStructs[0].frameIndex,
- _drawingStructs[0].point2.x,
- _drawingStructs[0].point2.y,
+ _drawingStructs[0].point2,
kDrawFlagNone,
val);
@@ -1006,8 +1000,7 @@ void Encounter::drawStructs() {
case 3:
getScreen()->draw(_drawingStructs[0].resourceId,
_drawingStructs[0].frameIndex,
- _drawingStructs[0].point2.x,
- _drawingStructs[0].point2.y);
+ _drawingStructs[0].point2);
_drawingStructs[0].status = 0;
break;
@@ -1036,8 +1029,7 @@ void Encounter::drawStructs() {
case -1:
getScreen()->draw(_drawingStructs[1].resourceId,
_drawingStructs[1].frameIndex,
- _drawingStructs[1].point2.x,
- _drawingStructs[1].point2.y,
+ _drawingStructs[1].point2,
kDrawFlagNone,
0);
@@ -1049,8 +1041,7 @@ void Encounter::drawStructs() {
case 2:
getScreen()->draw(_drawingStructs[1].resourceId,
_drawingStructs[1].frameIndex,
- _drawingStructs[1].point2.x,
- _drawingStructs[1].point2.y,
+ _drawingStructs[1].point2,
kDrawFlagNone,
val);
@@ -1064,8 +1055,7 @@ void Encounter::drawStructs() {
case 3:
getScreen()->draw(_drawingStructs[1].resourceId,
_drawingStructs[1].frameIndex,
- _drawingStructs[1].point2.x,
- _drawingStructs[1].point2.y);
+ _drawingStructs[1].point2);
_drawingStructs[1].status = 0;
break;
diff --git a/engines/asylum/system/screen.cpp b/engines/asylum/system/screen.cpp
index 02da924a4f..1deab97961 100644
--- a/engines/asylum/system/screen.cpp
+++ b/engines/asylum/system/screen.cpp
@@ -59,52 +59,53 @@ Screen::~Screen() {
// Drawing
//////////////////////////////////////////////////////////////////////////
void Screen::draw(ResourceId resourceId) {
- draw(resourceId, 0, 0, 0, kDrawFlagNone, kResourceNone, 0, 0, false);
+ draw(resourceId, 0, Common::Point(0, 0), kDrawFlagNone, kResourceNone, Common::Point(0, 0), false);
}
-void Screen::draw(ResourceId resourceId, uint32 frameIndex, int32 x, int32 y, DrawFlags flags, bool colorKey) {
- draw(resourceId, frameIndex, x, y, flags, kResourceNone, 0, 0, colorKey);
+void Screen::draw(ResourceId resourceId, uint32 frameIndex, const Common::Point &source, DrawFlags flags, bool colorKey) {
+ draw(resourceId, frameIndex, source, flags, kResourceNone, Common::Point(0, 0), colorKey);
}
-void Screen::draw(ResourceId resourceId, uint32 frameIndex, int32 x, int32 y, DrawFlags flags, int32 transTableNum) {
+void Screen::draw(ResourceId resourceId, uint32 frameIndex, const Common::Point &source, DrawFlags flags, int32 transTableNum) {
byte *index = _transTableIndex;
selectTransTable(transTableNum);
- draw(resourceId, frameIndex, x, y, (DrawFlags)(flags | 0x90000000));
+ draw(resourceId, frameIndex, source, (DrawFlags)(flags | 0x90000000));
_transTableIndex = index;
}
-void Screen::draw(ResourceId resourceId, uint32 frameIndex, int32 x, int32 y, DrawFlags flags, ResourceId resourceIdDestination, int32 destX, int32 destY, bool colorKey) {
+void Screen::draw(ResourceId resourceId, uint32 frameIndex, const Common::Point &source, DrawFlags flags, ResourceId resourceIdDestination, const Common::Point &destination, bool colorKey) {
// Get the frame to draw
GraphicResource *resource = new GraphicResource(_vm, resourceId);
GraphicFrame *frame = resource->getFrame(frameIndex);
// Compute coordinates
- Common::Rect source;
- Common::Rect destination;
- destination.left = x + frame->x;
+ Common::Rect src;
+ Common::Rect dest;
+ dest.left = source.x + frame->x;
+ // FIXME destination is never used
if (flags & kDrawFlagMirrorLeftRight) {
if (_flag == -1) {
if ((resource->getData().flags & 15) >= 2) {
- destination.left = x + resource->getData().maxWidth - frame->getWidth() - frame->x;
+ dest.left = source.x + resource->getData().maxWidth - frame->getWidth() - frame->x;
}
} else {
- destination.left += 2 * (_flag - (frame->getHeight() * 2 - frame->x));
+ dest.left += 2 * (_flag - (frame->getHeight() * 2 - frame->x));
}
}
- destination.top = y + frame->y;
- destination.right = destination.left + frame->getWidth();
- destination.bottom = destination.top + frame->getHeight();
+ dest.top = source.y + frame->y;
+ dest.right = dest.left + frame->getWidth();
+ dest.bottom = dest.top + frame->getHeight();
- source.left = 0;
- source.top = 0;
- source.right = frame->getWidth();
- source.bottom = frame->getHeight();
+ src.left = 0;
+ src.top = 0;
+ src.right = frame->getWidth();
+ src.bottom = frame->getHeight();
- clip(&source, &destination, flags);
+ clip(&src, &dest, flags);
bool masked = false;
if (resourceIdDestination) {
@@ -122,7 +123,7 @@ void Screen::draw(ResourceId resourceId, uint32 frameIndex, int32 x, int32 y, Dr
// Set the color key (always 0 if set)
_useColorKey = colorKey;
- blit(frame, &source, &destination, flags, colorKey);
+ blit(frame, &src, &dest, flags, colorKey);
delete resource;
}
@@ -364,11 +365,11 @@ void Screen::drawGraphicsInQueue() {
if (item->type == kGraphicItemNormal) {
if (item->transTableNum <= 0 || Config.performance <= 1)
- draw(item->resourceId, item->frameIndex, item->source.x, item->source.y, item->flags);
+ draw(item->resourceId, item->frameIndex, item->source, item->flags);
else
- draw(item->resourceId, item->frameIndex, item->source.x, item->source.y, item->flags, item->transTableNum - 1);
+ draw(item->resourceId, item->frameIndex, item->source, item->flags, item->transTableNum - 1);
} else if (item->type == kGraphicItemMasked) {
- draw(item->resourceId, item->frameIndex, item->source.x, item->source.y, item->flags, item->resourceIdDestination, item->destination.x, item->destination.y);
+ draw(item->resourceId, item->frameIndex, item->source, item->flags, item->resourceIdDestination, item->destination);
}
}
}
diff --git a/engines/asylum/system/screen.h b/engines/asylum/system/screen.h
index 39ee5a4716..311372952c 100644
--- a/engines/asylum/system/screen.h
+++ b/engines/asylum/system/screen.h
@@ -78,9 +78,9 @@ public:
// Drawing
void draw(ResourceId resourceId);
- void draw(ResourceId resourceId, uint32 frameIndex, int32 x, int32 y, DrawFlags flags = kDrawFlagNone, bool colorKey = true);
- void draw(ResourceId resourceId, uint32 frameIndex, int32 x, int32 y, DrawFlags flags, int32 transTableNum);
- void draw(ResourceId resourceId, uint32 frameIndex, int32 x, int32 y, DrawFlags flags, ResourceId resourceId2, int32 destX, int32 destY, bool colorKey = true);
+ void draw(ResourceId resourceId, uint32 frameIndex, const Common::Point &source, DrawFlags flags = kDrawFlagNone, bool colorKey = true);
+ void draw(ResourceId resourceId, uint32 frameIndex, const Common::Point &source, DrawFlags flags, int32 transTableNum);
+ void draw(ResourceId resourceId, uint32 frameIndex, const Common::Point &source, DrawFlags flags, ResourceId resourceId2, const Common::Point &destination, bool colorKey = true);
// Misc
void clear();
diff --git a/engines/asylum/system/text.cpp b/engines/asylum/system/text.cpp
index 3c993fee74..0d19d04b8a 100644
--- a/engines/asylum/system/text.cpp
+++ b/engines/asylum/system/text.cpp
@@ -37,8 +37,6 @@
namespace Asylum {
Text::Text(AsylumEngine *engine) : _vm(engine) {
- _posX = 0;
- _posY = 0;
_curFontFlags = 0;
_fontResource = 0;
_transTableNum = 0;
@@ -69,8 +67,8 @@ ResourceId Text::loadFont(ResourceId resourceId) {
}
void Text::setPosition(int32 x, int32 y) {
- _posX = x;
- _posY = y;
+ _position.x = x;
+ _position.y = y;
}
int32 Text::getWidth(char c) {
@@ -129,13 +127,13 @@ void Text::drawChar(char character) {
error("[Text::drawChar] font resource hasn't been loaded yet!");
if (_transTableNum) {
- getScreen()->draw(_fontResource->getResourceId(), (uint8)character, _posX, _posY, kDrawFlagNone, _transTableNum);
+ getScreen()->draw(_fontResource->getResourceId(), (uint8)character, _position, kDrawFlagNone, _transTableNum);
} else {
- getScreen()->draw(_fontResource->getResourceId(), (uint8)character, _posX, _posY);
+ getScreen()->draw(_fontResource->getResourceId(), (uint8)character, _position);
}
GraphicFrame *fontLetter = _fontResource->getFrame((uint8)character);
- _posX += fontLetter->surface.w + fontLetter->x - _curFontFlags;
+ _position.x += fontLetter->surface.w + fontLetter->x - _curFontFlags;
}
void Text::draw(const char *text) {
diff --git a/engines/asylum/system/text.h b/engines/asylum/system/text.h
index 4363683b9c..011d1d729c 100644
--- a/engines/asylum/system/text.h
+++ b/engines/asylum/system/text.h
@@ -28,6 +28,7 @@
#include "asylum/shared.h"
+#include "common/rect.h"
#include "common/scummsys.h"
namespace Asylum {
@@ -79,8 +80,7 @@ private:
int32 _transTableNum;
- int32 _posX;
- int32 _posY;
+ Common::Point _position;
uint8 _curFontFlags;
};
diff --git a/engines/asylum/views/menu.cpp b/engines/asylum/views/menu.cpp
index 7b52fc8e89..378be89995 100644
--- a/engines/asylum/views/menu.cpp
+++ b/engines/asylum/views/menu.cpp
@@ -413,7 +413,7 @@ bool Menu::update() {
//getScreen()->fillRect(260, 229, 119, 16, 0);
// Draw background
- getScreen()->draw(kBackground, (_activeScreen == kMenuNone) ? 1 : 0, 0, 0);
+ getScreen()->draw(kBackground, (_activeScreen == kMenuNone) ? 1 : 0, Common::Point(0, 0));
uint32 frameIndex = 0;
@@ -429,13 +429,13 @@ bool Menu::update() {
if (_activeScreen == kMenuNone) {
// Draw eye
- getScreen()->draw(kEye, frameIndex, 0, 0);
+ getScreen()->draw(kEye, frameIndex, Common::Point(0, 0));
// Find mouse position
MenuScreen icon = findMousePosition();
if (icon != kMenuNone) {
// Draw icon
- getScreen()->draw(MAKE_RESOURCE(kResourcePackShared, icon + 4), _iconFrames[icon], 0, 0);
+ getScreen()->draw(MAKE_RESOURCE(kResourcePackShared, icon + 4), _iconFrames[icon], Common::Point(0, 0));
_iconFrames[icon] = (_iconFrames[icon] + 1) % GraphicResource::getFrameCount(_vm, MAKE_RESOURCE(kResourcePackShared, icon + 4));
// Draw text
@@ -459,10 +459,10 @@ bool Menu::update() {
_dword_455C74 = 0;
}
} else {
- getScreen()->draw(kEye, frameIndex, 0, 0, kDrawFlagNone, 3);
+ getScreen()->draw(kEye, frameIndex, Common::Point(0, 0), kDrawFlagNone, 3);
// Draw icon
- getScreen()->draw(MAKE_RESOURCE(kResourcePackShared, _activeScreen + 4), _iconFrames[_activeScreen], 0, 0);
+ getScreen()->draw(MAKE_RESOURCE(kResourcePackShared, _activeScreen + 4), _iconFrames[_activeScreen], Common::Point(0, 0));
_iconFrames[_activeScreen] = (_iconFrames[_activeScreen] + 1) % GraphicResource::getFrameCount(_vm, MAKE_RESOURCE(kResourcePackShared, _activeScreen + 4));
}
@@ -1532,7 +1532,7 @@ void Menu::updateShowCredits() {
getScreen()->draw(MAKE_RESOURCE(kResourcePackShared, 33));
} else {
getScreen()->draw(MAKE_RESOURCE(kResourcePackShared, 23));
- getScreen()->draw(MAKE_RESOURCE(kResourcePackShared, 24), _creditsFrameIndex++ / 2, 0, 0, kDrawFlagNone, false);
+ getScreen()->draw(MAKE_RESOURCE(kResourcePackShared, 24), _creditsFrameIndex++ / 2, Common::Point(0, 0), kDrawFlagNone, false);
_creditsFrameIndex %= 2 * GraphicResource::getFrameCount(_vm, MAKE_RESOURCE(kResourcePackShared, 24));
}
diff --git a/engines/asylum/views/scene.cpp b/engines/asylum/views/scene.cpp
index ca7ab7910b..972e5ed8e5 100644
--- a/engines/asylum/views/scene.cpp
+++ b/engines/asylum/views/scene.cpp
@@ -2362,7 +2362,7 @@ bool Scene::drawScene() {
}
// Draw scene background
- getScreen()->draw(_ws->backgroundImage, 0, -_ws->xLeft, -_ws->yTop, kDrawFlagNone, false);
+ getScreen()->draw(_ws->backgroundImage, 0, Common::Point(-_ws->xLeft, -_ws->yTop), kDrawFlagNone, false);
// Draw actors on the update list
buildUpdateList();
@@ -2608,7 +2608,7 @@ void Scene::drawRain() {
for (uint y = 0; y < 512; y = y + 64) {
for (uint x = 0; x < 704; x = x + 64) {
- getScreen()->draw(MAKE_RESOURCE(kResourcePackShared, 58), _chapter5RainFrameIndex, x + (_ws->xLeft % 64) / 8, y + (_ws->yTop % 64) / 8);
+ getScreen()->draw(MAKE_RESOURCE(kResourcePackShared, 58), _chapter5RainFrameIndex, Common::Point(x + (_ws->xLeft % 64) / 8, y + (_ws->yTop % 64) / 8));
}
}
diff --git a/engines/asylum/views/scenetitle.cpp b/engines/asylum/views/scenetitle.cpp
index f05925b1b6..c25afa8ad1 100644
--- a/engines/asylum/views/scenetitle.cpp
+++ b/engines/asylum/views/scenetitle.cpp
@@ -71,7 +71,7 @@ void SceneTitle::update(int32 tick) {
return;
getScreen()->draw(getWorld()->sceneTitleGraphicResourceId);
- getScreen()->draw(MAKE_RESOURCE(kResourcePackSound, 17), _spinnerFrameIndex, (_spinnerProgress / 590.0 * 580) - 290 , 0, kDrawFlagNone, false);
+ getScreen()->draw(MAKE_RESOURCE(kResourcePackSound, 17), _spinnerFrameIndex, Common::Point((_spinnerProgress / 590.0 * 580) - 290 , 0), kDrawFlagNone, false);
getText()->drawCentered(320, 30, 24, MAKE_RESOURCE(kResourcePackText, 1811 + getWorld()->chapter));
// This is not from the original. It's just some arbitrary math to throttle the progress indicator.
Commit: db78a0c0f0c47a167a95c45874fb7db440a539dd
https://github.com/scummvm/scummvm/commit/db78a0c0f0c47a167a95c45874fb7db440a539dd
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:56+02:00
Commit Message:
ASYLUM: Implement Actor::playSounds()
Changed paths:
engines/asylum/resources/actor.cpp
engines/asylum/resources/actor.h
engines/asylum/resources/script.cpp
engines/asylum/resources/script.h
diff --git a/engines/asylum/resources/actor.cpp b/engines/asylum/resources/actor.cpp
index d4aa2b75b3..4a02286d05 100644
--- a/engines/asylum/resources/actor.cpp
+++ b/engines/asylum/resources/actor.cpp
@@ -171,8 +171,8 @@ void Actor::load(Common::SeekableReadStream *stream) {
_walkingSound2 = stream->readSint32LE();
_walkingSound3 = stream->readSint32LE();
_walkingSound4 = stream->readSint32LE();
- _field_64C = stream->readSint32LE();
- _field_650 = stream->readSint32LE();
+ _field_64C = stream->readUint32LE();
+ _field_650 = stream->readUint32LE();
for (int32 i = 0; i < 55; i++)
_graphicResourceIds[i] = (ResourceId)stream->readSint32LE();
@@ -478,15 +478,15 @@ void Actor::update() {
Common::Point point(_point1.x + _point2.x, _point1.y + _point2.y);
if (process_408B20(&point, _direction, dist, false)) {
- process_408D00(_direction, dist);
+ playSounds(_direction, dist);
} else if (process_408B20(&point, (ActorDirection)((dir + 1) % 7), dist, false)) {
- process_408D00((ActorDirection)((dir + 1) % 7), dist);
+ playSounds((ActorDirection)((dir + 1) % 7), dist);
} else if (process_408B20(&point, (ActorDirection)((dir + 7) % 7), dist, false)) {
- process_408D00((ActorDirection)((dir + 7) % 7), dist);
+ playSounds((ActorDirection)((dir + 7) % 7), dist);
} else if (process_408B20(&point, (ActorDirection)((dir + 2) % 7), dist, false)) {
- process_408D00((ActorDirection)((dir + 2) % 7), dist);
+ playSounds((ActorDirection)((dir + 2) % 7), dist);
} else if (process_408B20(&point, (ActorDirection)((dir + 6) % 7), dist, false)) {
- process_408D00((ActorDirection)((dir + 6) % 7), dist);
+ playSounds((ActorDirection)((dir + 6) % 7), dist);
}
}
@@ -1122,8 +1122,91 @@ bool Actor::process_408B20(Common::Point *point, ActorDirection dir, uint32 coun
return true;
}
-void Actor::process_408D00(ActorDirection dir, uint32 count) {
- error("[Actor::process_408D00] Not implemented!");
+void Actor::playSounds(ActorDirection direction, uint32 distance) {
+ _lastScreenUpdate = _vm->screenUpdateCount;
+
+ Common::Point sum(_point1.x + _point2.x, _point1.x + _point2.x);
+ int32 panning = getSound()->calculatePanningAtPoint(sum.x, sum.y);
+
+ switch (_status) {
+ default:
+ break;
+
+ case kActorStatus1:
+ case kActorStatus2:
+ case kActorStatus12:
+ case kActorStatus13:
+ updateCoordinatesForDirection(direction, distance, &_point1);
+
+ _frameIndex = (++_frameIndex) % _frameCount;
+
+ if (_walkingSound1 != kResourceNone) {
+
+ // Compute volume
+ int32 vol = sqrt((double)-Config.sfxVolume);
+ if (_index != getScene()->getPlayerIndex())
+ vol += sqrt((double)abs(getSound()->calculateVolumeAdjustement(sum.x, sum.y, 10, 0)));
+
+ int32 volume = (Config.sfxVolume + vol) * (Config.sfxVolume + vol);
+ if (volume > 10000)
+ volume = 10000;
+
+ if (_field_944 != 1 && _field_944 != 4) {
+ // Compute resource Id
+ ResourceId resourceId = kResourceNone;
+ if (getWorld()->actions[_actionIdx3]->soundResourceIdFrame != kResourceNone && strcmp((char *)&_name, "Crow") && strcmp((char *)&_name, "Big Crow")) {
+ if (_frameIndex == _field_64C)
+ resourceId = (ResourceId)(getWorld()->actions[_actionIdx3]->soundResourceIdFrame + rnd(1));
+ else if (_frameIndex == _field_650)
+ resourceId = (ResourceId)(getWorld()->actions[_actionIdx3]->soundResourceId + rnd(1));
+ } else {
+ if (_frameIndex == _field_64C)
+ resourceId = (ResourceId)(_walkingSound1 + rnd(1));
+ else if (_frameIndex == _field_650)
+ resourceId = (ResourceId)(_walkingSound3 + rnd(1));
+ }
+
+ // Play sound
+ getSound()->playSound(resourceId, false, -volume, panning);
+ }
+ }
+ break;
+
+ case kActorStatus18:
+ if (getWorld()->chapter == kChapter2) {
+ updateCoordinatesForDirection(direction, distance, &_point1);
+
+ if (_walkingSound1 == kResourceNone)
+ break;
+
+ // Compute volume
+ int32 vol = getWorld()->actions[_actionIdx3]->volume;
+ if (_index != getScene()->getPlayerIndex())
+ vol += sqrt((double)abs(getSound()->calculateVolumeAdjustement(sum.x, sum.y, 10, 0)));
+
+ int32 volume = (Config.sfxVolume + vol) * (Config.sfxVolume + vol);
+ if (volume > 10000)
+ volume = 10000;
+
+ // Compute resource Id
+ ResourceId resourceId = kResourceNone;
+ if (getWorld()->actions[_actionIdx3]->soundResourceIdFrame != kResourceNone && strcmp((char *)&_name, "Crow") && strcmp((char *)&_name, "Big Crow")) {
+ if (_frameIndex == _field_64C)
+ resourceId = (ResourceId)(getWorld()->actions[_actionIdx3]->soundResourceIdFrame + rnd(1));
+ else if (_frameIndex == _field_650)
+ resourceId = (ResourceId)(getWorld()->actions[_actionIdx3]->soundResourceId + rnd(1));
+ } else {
+ if (_frameIndex == _field_64C)
+ resourceId = (ResourceId)(_walkingSound1 + rnd(1));
+ else if (_frameIndex == _field_650)
+ resourceId = (ResourceId)(_walkingSound3 + rnd(1));
+ }
+
+ // Play sound
+ getSound()->playSound(resourceId, false, -volume, panning);
+ }
+ break;
+ }
}
void Actor::process_41BC00(int32 reactionIndex, int32 numberValue01Add) {
diff --git a/engines/asylum/resources/actor.h b/engines/asylum/resources/actor.h
index 1fde5ae992..4fbdd50fb9 100644
--- a/engines/asylum/resources/actor.h
+++ b/engines/asylum/resources/actor.h
@@ -263,7 +263,7 @@ public:
void process_401830(int32 field980, int32 actionAreaId, int32 field978, int field98C, int32 field990, int32 field974, int32 field984, int32 field988);
bool process_4069B0(int32 *x, int32 *y);
bool process_408B20(Common::Point *point, ActorDirection direction, uint32 count, bool hasDelta);
- void process_408D00(ActorDirection dir, uint32 count);
+ void playSounds(ActorDirection dir, uint32 distance);
void process_41BC00(int32 reactionIndex, int32 numberValue01Add);
void process_41BCC0(int32 reactionIndex, int32 numberValue01Substract);
bool process_41BDB0(int32 reactionIndex, int32 testNumberValue01);
@@ -343,12 +343,12 @@ private:
// TODO field_68 till field_617
int32 _reaction[8];
int32 _field_638;
- int32 _walkingSound1;
- int32 _walkingSound2;
- int32 _walkingSound3;
- int32 _walkingSound4;
- int32 _field_64C;
- int32 _field_650;
+ ResourceId _walkingSound1;
+ ResourceId _walkingSound2;
+ ResourceId _walkingSound3;
+ ResourceId _walkingSound4;
+ uint32 _field_64C;
+ uint32 _field_650;
ResourceId _graphicResourceIds[55];
char _name[256];
int32 _field_830[20];
diff --git a/engines/asylum/resources/script.cpp b/engines/asylum/resources/script.cpp
index b33dd50431..fce6c61079 100644
--- a/engines/asylum/resources/script.cpp
+++ b/engines/asylum/resources/script.cpp
@@ -64,13 +64,13 @@ void ActionArea::load(Common::SeekableReadStream *stream) {
for (int32 i = 0; i < 10; i++)
flagNums[i] = stream->readSint32LE();
- field_7C = stream->readSint32LE();
- polygonIndex = stream->readSint32LE();
- field_84 = stream->readSint32LE();
- field_88 = stream->readSint32LE();
- soundResourceId = (ResourceId)stream->readSint32LE();
- field_90 = stream->readSint32LE();
- paletteResourceId = (ResourceId)stream->readSint32LE();
+ field_7C = stream->readSint32LE();
+ polygonIndex = stream->readSint32LE();
+ soundResourceIdFrame = (ResourceId)stream->readSint32LE();
+ field_88 = stream->readSint32LE();
+ soundResourceId = (ResourceId)stream->readSint32LE();
+ field_90 = stream->readSint32LE();
+ paletteResourceId = (ResourceId)stream->readSint32LE();
for (int32 i = 0; i < 5; i++)
array[i] = stream->readSint32LE();
diff --git a/engines/asylum/resources/script.h b/engines/asylum/resources/script.h
index 4e7622273c..d6e32a3c00 100644
--- a/engines/asylum/resources/script.h
+++ b/engines/asylum/resources/script.h
@@ -72,7 +72,7 @@ struct ActionArea {
int32 flagNums[10];
int32 field_7C;
int32 polygonIndex;
- int32 field_84;
+ ResourceId soundResourceIdFrame;
int32 field_88;
ResourceId soundResourceId;
int32 field_90;
@@ -94,7 +94,7 @@ struct ActionArea {
memset(&flagNums, 0, sizeof(flagNums));
field_7C = 0;
polygonIndex = 0;
- field_84 = 0;
+ soundResourceIdFrame = kResourceNone;
field_88 = 0;
soundResourceId = kResourceNone;
field_90 = 0;
@@ -112,7 +112,7 @@ struct ActionArea {
output += Common::String::format(" flags=%d scriptIndex=%d scriptIndex2=%d type=%d\n", flags, scriptIndex, actionType, polygonIndex);
output += Common::String::format(" sound=%d polygon=%d palette=%d volume=%d\n", soundResourceId, scriptIndex2, paletteResourceId, volume);
output += Common::String::format(" field01=%d field02=%d field40=%d field44=%d\n", field01, field02, field_40, field_44);
- output += Common::String::format(" field7C=%d field84=%d field88=%d field90=%d\n", field_7C, field_84, field_88, field_90);
+ output += Common::String::format(" field7C=%d field84=%d field88=%d field90=%d\n", field_7C, soundResourceIdFrame, field_88, field_90);
return output;
}
Commit: 4229cdf88f8c1aa311c3e14bbcf675102af2e2b5
https://github.com/scummvm/scummvm/commit/4229cdf88f8c1aa311c3e14bbcf675102af2e2b5
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:56+02:00
Commit Message:
ASYLUM: Implement more of Actor::process()
- Add stubs for pathfinding functions
- Add computation of coordinates & direction
Changed paths:
engines/asylum/resources/actor.cpp
engines/asylum/resources/actor.h
diff --git a/engines/asylum/resources/actor.cpp b/engines/asylum/resources/actor.cpp
index 4a02286d05..3615a3c43e 100644
--- a/engines/asylum/resources/actor.cpp
+++ b/engines/asylum/resources/actor.cpp
@@ -115,6 +115,9 @@ Actor::Actor(AsylumEngine *engine, ActorIndex index) : _vm(engine), _index(index
// Instance data
_tickCount = -1;
_updateCounter = 0;
+
+ // Path finding
+ _frameNumber = 0;
}
Actor::~Actor() {
@@ -915,7 +918,131 @@ bool Actor::process(const Common::Point &point) {
}
if (abs(delta.x) != abs(delta.y)) {
- error("[Actor::process] not implemented (deltas)!");
+ Common::Array<int> actions;
+ Common::Point point1;
+ Common::Point point2;
+ uint32 count1 = 0;
+ uint32 count2 = 0;
+ ActorDirection direction1 = kDirectionInvalid;
+ ActorDirection direction2 = kDirectionInvalid;
+
+ // Compute coordinates, directions and counts
+ if (abs(delta.x) < abs(delta.y)) {
+ point1 = Common::Point(sum.x + abs(delta.x) * a1, sum.y + abs(delta.x) * a2);
+ point2 = Common::Point(sum.x , sum.y + abs(abs(delta.x) - abs(delta.y)) * a2);
+ count1 = abs(point1.x - sum.x);
+ count2 = abs(point1.y - point.y);
+
+ switch (a3) {
+ default:
+ error("[Actor::process] Invalid value for a3");
+ break;
+
+ case 0:
+ direction1 = kDirectionNO;
+ direction2 = kDirectionN;
+ break;
+
+ case 1:
+ direction1 = kDirectionNE;
+ direction2 = kDirectionN;
+ break;
+
+ case 2:
+ direction1 = kDirectionSE;
+ direction2 = kDirectionS;
+ break;
+
+ case 3:
+ direction1 = kDirectionSO;
+ direction2 = kDirectionS;
+ break;
+ }
+ } else {
+ point1 = Common::Point(sum.x + abs(delta.y) * a1, sum.y + abs(delta.y) * a2);
+ point2 = Common::Point(sum.x + abs(abs(delta.y) - abs(delta.x)) * a1 , sum.y);
+ count1 = abs(abs(delta.y) * a2);
+ count2 = abs(point1.y - point.x);
+
+ switch (a3) {
+ default:
+ error("[Actor::process] Invalid value for a3");
+ break;
+
+ case 0:
+ direction1 = kDirectionNO;
+ direction2 = kDirectionO;
+ break;
+
+ case 1:
+ direction1 = kDirectionNE;
+ direction2 = kDirectionE;
+ break;
+
+ case 2:
+ direction1 = kDirectionSE;
+ direction2 = kDirectionE;
+ break;
+
+ case 3:
+ direction1 = kDirectionSO;
+ direction2 = kDirectionO;
+ break;
+ }
+ }
+
+ // Check scene rects
+ if (getWorld()->chapter != kChapter2 || strcmp(_name, "Big Crow")) {
+ error("[Actor::process] not implemented (scene rects checks)!");
+ }
+
+ if (process_408B20(&sum, direction1, count1, true)
+ && process_408B20(&point1, direction2, count2, true)) {
+ error("[Actor::process] not implemented (process actor data 1)!");
+ }
+
+ if (process_408B20(&sum, direction2, count2, true)
+ && process_408B20(&point1, direction1, count1, true)) {
+ error("[Actor::process] not implemented (process actor data 2)!");
+ }
+
+ error("[Actor::process] not implemented (compute actions)!");
+
+ //////////////////////////////////////////////////////////////////////////
+ // Process actions
+
+ _frameNumber = 0;
+
+ if (abs(sum.x - point.x) > abs(sum.y - point.y)) {
+ if (sum.x <= point.x) {
+ if (!processAction1(sum, point, &actions))
+ return false;
+ } else {
+ if (!processAction2(sum, point, &actions))
+ return false;
+ }
+
+ updateFromDirection((ActorDirection)_data.field_3C8[0]);
+
+ return true;
+ }
+
+ if (sum.y > point.y) {
+ if (!processAction3(sum, point, &actions))
+ return false;
+
+ updateFromDirection((ActorDirection)_data.field_3C8[0]);
+
+ return true;
+ }
+
+ // last case: sum.y < point.y
+ if (!processAction4(sum, point, &actions))
+ return false;
+
+ updateFromDirection((ActorDirection)_data.field_3C8[0]);
+
+ return true;
}
//////////////////////////////////////////////////////////////////////////
@@ -2229,8 +2356,24 @@ void Actor::updateNumbers(int32 reaction, int32 x, int32 y) {
}
//////////////////////////////////////////////////////////////////////////
-// Helpers functions
+// Path finding functions
//////////////////////////////////////////////////////////////////////////
+bool Actor::processAction1(const Common::Point &source, const Common::Point &destination, Common::Array<int> *actions) {
+ error("[Actor::processAction1] Not implemented");
+}
+
+bool Actor::processAction2(const Common::Point &source, const Common::Point &destination, Common::Array<int> *actions) {
+ error("[Actor::processAction2] Not implemented");
+}
+
+bool Actor::processAction3(const Common::Point &source, const Common::Point &destination, Common::Array<int> *actions) {
+ error("[Actor::processAction3] Not implemented");
+}
+
+bool Actor::processAction4(const Common::Point &source, const Common::Point &destination, Common::Array<int> *actions) {
+ error("[Actor::processAction4] Not implemented");
+}
+
bool Actor::checkAllActions(const Common::Point &pt, Common::Array<ActionArea *> *actions) {
if (actions->size() == 0)
return false;
diff --git a/engines/asylum/resources/actor.h b/engines/asylum/resources/actor.h
index 4fbdd50fb9..4e792ab387 100644
--- a/engines/asylum/resources/actor.h
+++ b/engines/asylum/resources/actor.h
@@ -440,8 +440,13 @@ private:
void updateFinish();
//////////////////////////////////////////////////////////////////////////
- // Helper functions
+ // Path finding functions
//////////////////////////////////////////////////////////////////////////
+ uint32 _frameNumber;
+ bool processAction1(const Common::Point &source, const Common::Point &destination, Common::Array<int> *actions);
+ bool processAction2(const Common::Point &source, const Common::Point &destination, Common::Array<int> *actions);
+ bool processAction3(const Common::Point &source, const Common::Point &destination, Common::Array<int> *actions);
+ bool processAction4(const Common::Point &source, const Common::Point &destination, Common::Array<int> *actions);
bool checkAllActions(const Common::Point &pt, Common::Array<ActionArea *> *actions);
//////////////////////////////////////////////////////////////////////////
Commit: 12f0c9fee2498cbb440a0bfbd9f6045912a1cfa8
https://github.com/scummvm/scummvm/commit/12f0c9fee2498cbb440a0bfbd9f6045912a1cfa8
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:56+02:00
Commit Message:
ASYLUM: Fix typo in Scene::processUpdateList()
Changed paths:
engines/asylum/views/scene.cpp
diff --git a/engines/asylum/views/scene.cpp b/engines/asylum/views/scene.cpp
index 972e5ed8e5..4b0a77bbe2 100644
--- a/engines/asylum/views/scene.cpp
+++ b/engines/asylum/views/scene.cpp
@@ -2450,7 +2450,7 @@ void Scene::processUpdateList() {
// Process objects
for (uint32 j = 0; j < _ws->objects.size(); j++) {
- Object *object = _ws->objects[i];
+ Object *object = _ws->objects[j];
// Skip hidden objects
if (!object->isOnScreen())
Commit: 90d21d0ad8b198a25e292a5a771d219bbaca0755
https://github.com/scummvm/scummvm/commit/90d21d0ad8b198a25e292a5a771d219bbaca0755
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:56+02:00
Commit Message:
ASYLUM: Add support for mirrored blit
Changed paths:
engines/asylum/system/screen.cpp
engines/asylum/system/screen.h
diff --git a/engines/asylum/system/screen.cpp b/engines/asylum/system/screen.cpp
index 1deab97961..1f9c9057d9 100644
--- a/engines/asylum/system/screen.cpp
+++ b/engines/asylum/system/screen.cpp
@@ -369,7 +369,7 @@ void Screen::drawGraphicsInQueue() {
else
draw(item->resourceId, item->frameIndex, item->source, item->flags, item->transTableNum - 1);
} else if (item->type == kGraphicItemMasked) {
- draw(item->resourceId, item->frameIndex, item->source, item->flags, item->resourceIdDestination, item->destination);
+ draw(item->resourceId, item->frameIndex, item->source, item->flags, item->resourceIdDestination, item->destination);
}
}
}
@@ -413,65 +413,71 @@ void Screen::deleteGraphicFromQueue(ResourceId resourceId) {
// Graphic Data
//////////////////////////////////////////////////////////////////////////
void Screen::blit(GraphicFrame *frame, Common::Rect *source, Common::Rect *destination, int32 flags, bool useColorKey) {
-
- if (flags & 0x8000000) {
+ if (flags & 0x80000000) {
error("[Screen::blit] not implemented");
} else if (flags) {
blt(destination, frame, source, flags, useColorKey);
} else {
- bltFast(destination->left, destination->top, frame, source, useColorKey);
+ bltFast(destination->left, destination->top, frame, source, flags, useColorKey);
}
}
void Screen::blt(Common::Rect *dest, GraphicFrame* frame, Common::Rect *source, int32 flags, bool useColorKey) {
// TODO adjust destination rect
- // TODO handle mirror flag
if (useColorKey) {
copyToBackBufferWithTransparency((byte *)frame->surface.pixels + (source->top * frame->surface.w + source->left),
frame->surface.w,
dest->left,
dest->top,
source->width(),
- source->height());
+ source->height(),
+ flags & kDrawFlagMirrorLeftRight);
} else {
copyToBackBuffer((byte *)frame->surface.pixels + (source->top * frame->surface.w + source->left),
frame->surface.w,
dest->left,
dest->top,
source->width(),
- source->height());
+ source->height(),
+ flags & kDrawFlagMirrorLeftRight);
}
}
-void Screen::bltFast(int32 dX, int32 dY, GraphicFrame* frame, Common::Rect *source, bool useColorKey) {
+void Screen::bltFast(int32 dX, int32 dY, GraphicFrame* frame, Common::Rect *source, int32 flags, bool useColorKey) {
if (useColorKey) {
copyToBackBufferWithTransparency((byte *)frame->surface.pixels + (source->top * frame->surface.w + source->left),
frame->surface.w,
dX,
dY,
source->width(),
- source->height());
+ source->height(),
+ flags & kDrawFlagMirrorLeftRight);
} else {
copyToBackBuffer((byte *)frame->surface.pixels + (source->top * frame->surface.w + source->left),
frame->surface.w,
dX,
dY,
source->width(),
- source->height());
+ source->height(),
+ flags & kDrawFlagMirrorLeftRight);
}
}
-void Screen::copyToBackBuffer(byte *buffer, int32 pitch, int32 x, int32 y, uint32 width, uint32 height) {
+void Screen::copyToBackBuffer(byte *buffer, int32 pitch, int32 x, int32 y, uint32 width, uint32 height, bool mirrored) {
byte *dest = (byte *)_backBuffer.pixels;
- while (height--) {
- memcpy(dest + y * _backBuffer.pitch + x, buffer, width);
- dest += 640;
- buffer += pitch;
+ if (!mirrored) {
+ while (height--) {
+ memcpy(dest + y * _backBuffer.pitch + x, buffer, width);
+ dest += 640;
+ buffer += pitch;
+ }
+ } else {
+ error("[Screen::copyToBackBuffer] Mirrored drawing not implemented");
}
}
-void Screen::copyToBackBufferWithTransparency(byte *buffer, int32 pitch, int32 x, int32 y, int32 width, int32 height) {
+void Screen::copyToBackBufferWithTransparency(byte *buffer, int32 pitch, int32 x, int32 y, int32 width, int32 height, bool mirrored) {
byte *dest = (byte *)_backBuffer.pixels;
int32 left = (x < 0) ? -x : 0;
@@ -482,7 +488,7 @@ void Screen::copyToBackBufferWithTransparency(byte *buffer, int32 pitch, int32 x
for (int32 curY = top; curY < bottom; curY++) {
for (int32 curX = left; curX < right; curX++) {
if (buffer[curX + curY * pitch] != 0 ) {
- dest[x + curX + (y + curY) * 640] = buffer[curX + curY * pitch];
+ dest[x + curX + (y + curY) * 640] = buffer[(mirrored ? right - curX : curX) + curY * pitch];
}
}
}
diff --git a/engines/asylum/system/screen.h b/engines/asylum/system/screen.h
index 311372952c..3572290ee0 100644
--- a/engines/asylum/system/screen.h
+++ b/engines/asylum/system/screen.h
@@ -123,7 +123,7 @@ public:
void deleteGraphicFromQueue(ResourceId resourceId);
// Used by Video
- void copyToBackBuffer(byte *buffer, int32 pitch, int32 x, int32 y, uint32 width, uint32 height);
+ void copyToBackBuffer(byte *buffer, int32 pitch, int32 x, int32 y, uint32 width, uint32 height, bool mirrored = false);
// Debug
void drawLine(int x0, int y0, int x1, int y1);
@@ -156,9 +156,9 @@ private:
// Screen blitting
void blit(GraphicFrame *frame, Common::Rect *source, Common::Rect *destination, int32 flags, bool useColorKey);
void blt(Common::Rect *dest, GraphicFrame* frame, Common::Rect *source, int32 flags, bool useColorKey);
- void bltFast(int32 dX, int32 dY, GraphicFrame* frame, Common::Rect *source, bool useColorKey);
+ void bltFast(int32 dX, int32 dY, GraphicFrame* frame, Common::Rect *source, int32 flags, bool useColorKey);
- void copyToBackBufferWithTransparency(byte *buffer, int32 pitch, int32 x, int32 y, int32 width, int32 height);
+ void copyToBackBufferWithTransparency(byte *buffer, int32 pitch, int32 x, int32 y, int32 width, int32 height, bool mirrored = false);
};
} // end of namespace Asylum
Commit: 1526593cf026380feb55a45c0c70939654275ac3
https://github.com/scummvm/scummvm/commit/1526593cf026380feb55a45c0c70939654275ac3
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:56+02:00
Commit Message:
ASYLUM: Replace several pairs of (x, y) parameters by Common::Point
Changed paths:
engines/asylum/puzzles/tictactoe.cpp
engines/asylum/resources/actor.cpp
engines/asylum/resources/actor.h
engines/asylum/resources/object.cpp
engines/asylum/resources/special.cpp
engines/asylum/resources/worldstats.cpp
engines/asylum/system/screen.cpp
engines/asylum/system/screen.h
engines/asylum/system/sound.cpp
engines/asylum/system/sound.h
engines/asylum/views/scene.cpp
diff --git a/engines/asylum/puzzles/tictactoe.cpp b/engines/asylum/puzzles/tictactoe.cpp
index 14c47cb138..f97a99d41a 100644
--- a/engines/asylum/puzzles/tictactoe.cpp
+++ b/engines/asylum/puzzles/tictactoe.cpp
@@ -213,10 +213,10 @@ void PuzzleTicTacToe::drawField() {
if (g_debugPolygons) {
for (uint32 p = 0; p < ARRAYSIZE(puzzleTicTacToePolygons); p += 4) {
- getScreen()->drawLine(puzzleTicTacToePolygons[p].x, puzzleTicTacToePolygons[p].y, puzzleTicTacToePolygons[p + 1].x, puzzleTicTacToePolygons[p + 1].y);
- getScreen()->drawLine(puzzleTicTacToePolygons[p + 1].x, puzzleTicTacToePolygons[p + 1].y, puzzleTicTacToePolygons[p + 2].x, puzzleTicTacToePolygons[p + 2].y);
- getScreen()->drawLine(puzzleTicTacToePolygons[p + 2].x, puzzleTicTacToePolygons[p + 2].y, puzzleTicTacToePolygons[p + 3].x, puzzleTicTacToePolygons[p + 3].y);
- getScreen()->drawLine(puzzleTicTacToePolygons[p + 3].x, puzzleTicTacToePolygons[p + 3].y, puzzleTicTacToePolygons[p].x, puzzleTicTacToePolygons[p].y);
+ getScreen()->drawLine(puzzleTicTacToePolygons[p], puzzleTicTacToePolygons[p + 1]);
+ getScreen()->drawLine(puzzleTicTacToePolygons[p + 1], puzzleTicTacToePolygons[p + 2]);
+ getScreen()->drawLine(puzzleTicTacToePolygons[p + 2], puzzleTicTacToePolygons[p + 3]);
+ getScreen()->drawLine(puzzleTicTacToePolygons[p + 3], puzzleTicTacToePolygons[p]);
}
}
diff --git a/engines/asylum/resources/actor.cpp b/engines/asylum/resources/actor.cpp
index 3615a3c43e..4acce9de13 100644
--- a/engines/asylum/resources/actor.cpp
+++ b/engines/asylum/resources/actor.cpp
@@ -1253,7 +1253,7 @@ void Actor::playSounds(ActorDirection direction, uint32 distance) {
_lastScreenUpdate = _vm->screenUpdateCount;
Common::Point sum(_point1.x + _point2.x, _point1.x + _point2.x);
- int32 panning = getSound()->calculatePanningAtPoint(sum.x, sum.y);
+ int32 panning = getSound()->calculatePanningAtPoint(sum);
switch (_status) {
default:
@@ -1272,7 +1272,7 @@ void Actor::playSounds(ActorDirection direction, uint32 distance) {
// Compute volume
int32 vol = sqrt((double)-Config.sfxVolume);
if (_index != getScene()->getPlayerIndex())
- vol += sqrt((double)abs(getSound()->calculateVolumeAdjustement(sum.x, sum.y, 10, 0)));
+ vol += sqrt((double)abs(getSound()->calculateVolumeAdjustement(sum, 10, 0)));
int32 volume = (Config.sfxVolume + vol) * (Config.sfxVolume + vol);
if (volume > 10000)
@@ -1309,7 +1309,7 @@ void Actor::playSounds(ActorDirection direction, uint32 distance) {
// Compute volume
int32 vol = getWorld()->actions[_actionIdx3]->volume;
if (_index != getScene()->getPlayerIndex())
- vol += sqrt((double)abs(getSound()->calculateVolumeAdjustement(sum.x, sum.y, 10, 0)));
+ vol += sqrt((double)abs(getSound()->calculateVolumeAdjustement(sum, 10, 0)));
int32 volume = (Config.sfxVolume + vol) * (Config.sfxVolume + vol);
if (volume > 10000)
@@ -2340,16 +2340,13 @@ void Actor::resetActors() {
getWorld()->tickCount1 = _vm->getTick() + 3000;
}
-void Actor::updateNumbers(int32 reaction, int32 x, int32 y) {
+void Actor::updateNumbers(int32 reaction, const Common::Point &point) {
if (reaction != 1)
return;
- _numberStringX = x;
- _numberStringY = y + 8;
+ _numberStringX = point.x;
+ _numberStringY = point.y + 8;
_numberStringWidth = 40;
-
- // XXX use sprintf instead of itoa as itoa isn't part of standard
- // C++ and therefore isn't available in GCC
sprintf(_numberString01, "%d", _numberValue01);
_numberFlag01 = 1;
@@ -2444,7 +2441,7 @@ void Actor::setVolume() {
return;
// Compute volume
- int32 volume = Config.voiceVolume + getSound()->calculateVolumeAdjustement(_point1.x + _point2.x, _point1.y + _point2.y, _field_968, 0);
+ int32 volume = Config.voiceVolume + getSound()->calculateVolumeAdjustement(_point1 + _point2, _field_968, 0);
if (volume < -10000)
volume = -10000;
diff --git a/engines/asylum/resources/actor.h b/engines/asylum/resources/actor.h
index 4e792ab387..3a70dec9c7 100644
--- a/engines/asylum/resources/actor.h
+++ b/engines/asylum/resources/actor.h
@@ -482,10 +482,9 @@ private:
* Updates the actor "number" data if the reaction is "1".
*
* @param reaction The reaction.
- * @param x The second int32.
- * @param y The third int32.
+ * @param point The coordinates
*/
- void updateNumbers(int32 reaction, int32 x, int32 y);
+ void updateNumbers(int32 reaction, const Common::Point &point);
/**
* Determine if the supplied point is in the action area
diff --git a/engines/asylum/resources/object.cpp b/engines/asylum/resources/object.cpp
index 7379023933..0dae89d0fb 100644
--- a/engines/asylum/resources/object.cpp
+++ b/engines/asylum/resources/object.cpp
@@ -360,24 +360,23 @@ void Object::setNextFrame(int32 targetFlags) {
// Misc
/////////////////////////////////////////////////////////////////////////
void Object::playSounds() {
- int32 soundX = 0;
- int32 soundY = 0;
+ Common::Point point;
if (_soundX || _soundY) {
- soundX = _soundX;
- soundY = _soundY;
+ point.x = _soundX;
+ point.y = _soundY;
} else {
if (LOBYTE(flags) & kObjectFlag4) {
// Get object resource
ResourceEntry *resource = getResource()->get(_resourceId);
- soundX = x + Common::Rational(resource->getData(1), 2).toInt();
- soundY = y + Common::Rational(resource->getData(0), 2).toInt();
+ point.x = x + Common::Rational(resource->getData(1), 2).toInt();
+ point.y = y + Common::Rational(resource->getData(0), 2).toInt();
} else {
Common::Rect rect = GraphicResource::getFrameRect(_vm, _resourceId, _frameIndex);
- soundX = x + (rect.width() * 2);
- soundY = x + (rect.height() * 2);
+ point.x = x + (rect.width() * 2);
+ point.y = x + (rect.height() * 2);
}
}
@@ -388,20 +387,20 @@ void Object::playSounds() {
continue;
if (item->field_4 && !getSound()->isPlaying(item->resourceId)) {
- int32 volume = Config.sfxVolume + getSound()->calculateVolumeAdjustement(soundX, soundY, item->field_8, item->field_C);
+ int32 volume = Config.sfxVolume + getSound()->calculateVolumeAdjustement(point, item->field_8, item->field_C);
if (volume > -5000)
- getSound()->playSound(item->resourceId, true, volume, getSound()->calculatePanningAtPoint(soundX, soundY));
+ getSound()->playSound(item->resourceId, true, volume, getSound()->calculatePanningAtPoint(point));
}
if (getSound()->isPlaying(item->resourceId)) {
- int32 volume = Config.sfxVolume + getSound()->calculateVolumeAdjustement(soundX, soundY, item->field_8, item->field_C);
+ int32 volume = Config.sfxVolume + getSound()->calculateVolumeAdjustement(point, item->field_8, item->field_C);
if (volume > -5000) {
if (volume > 0)
volume = 0;
- getSound()->setPanning(item->resourceId, getSound()->calculatePanningAtPoint(soundX, soundY));
+ getSound()->setPanning(item->resourceId, getSound()->calculatePanningAtPoint(point));
getSound()->setVolume(item->resourceId, volume);
} else {
getSound()->stop(item->resourceId);
@@ -449,7 +448,8 @@ void Object::setVolume() {
Common::Rect frameRect = GraphicResource::getFrameRect(_vm, _resourceId, _frameIndex);
// Compute volume
- int32 volume = Config.voiceVolume + getSound()->calculateVolumeAdjustement(Common::Rational(frameRect.width(), 2).toInt() + x, Common::Rational(frameRect.height(), 2).toInt() + y, _field_6A4, 0);
+ Common::Point coords(Common::Rational(frameRect.width(), 2).toInt() + x, Common::Rational(frameRect.height(), 2).toInt() + y);
+ int32 volume = Config.voiceVolume + getSound()->calculateVolumeAdjustement(coords, _field_6A4, 0);
if (volume < -10000)
volume = -10000;
diff --git a/engines/asylum/resources/special.cpp b/engines/asylum/resources/special.cpp
index 81cd3def36..f355117a97 100644
--- a/engines/asylum/resources/special.cpp
+++ b/engines/asylum/resources/special.cpp
@@ -425,8 +425,8 @@ void Special::chapter6(Object *object, ActorIndex actorIndex) {
if (actorIndex == 2 || actorIndex == 3) {
Actor *actor = getScene()->getActor(actorIndex);
- getWorld()->ambientSounds[0].x = actor->getPoint2()->x + actor->getPoint1()->x;
- getWorld()->ambientSounds[0].y = actor->getPoint2()->y + actor->getPoint1()->y;
+ getWorld()->ambientSounds[0].point.x = actor->getPoint2()->x + actor->getPoint1()->x;
+ getWorld()->ambientSounds[0].point.y = actor->getPoint2()->y + actor->getPoint1()->y;
}
}
@@ -1287,44 +1287,43 @@ void Special::setPaletteGamma(ResourceId palette1, ResourceId palette2) {
void Special::playSoundPanning(ResourceId resourceId, int32 attenuation, Object *object) {
int32 adjustedVolume = Config.voiceVolume;
- int32 x = 0;
- int32 y = 0;
+ Common::Point point;
switch (object->getId()) {
default: {
Common::Rect frameRect = GraphicResource::getFrameRect(_vm, object->getResourceId(), object->getFrameIndex());
- x = Common::Rational(frameRect.width(), 2).toInt() + object->x;
- y = Common::Rational(frameRect.height(), 2).toInt() + object->y;
+ point.x = Common::Rational(frameRect.width(), 2).toInt() + object->x;
+ point.y = Common::Rational(frameRect.height(), 2).toInt() + object->y;
}
break;
case kObjectDennisStatusQuo:
- x = 1382;
- y = 1041;
+ point.x = 1382;
+ point.y = 1041;
break;
case kObjectSailorBoy:
- x = 1646;
- y = 1220;
+ point.x = 1646;
+ point.y = 1220;
break;
case kObjectSuckerSittingStatusQuo:
- x = 1376;
- y = 1148;
+ point.x = 1376;
+ point.y = 1148;
break;
case kObjectDennisStatus2:
- x = 175;
- y = 617;
+ point.x = 175;
+ point.y = 617;
break;
}
// Calculate volume adjustment
- adjustedVolume += getSound()->calculateVolumeAdjustement(x, y, attenuation, 0);
+ adjustedVolume += getSound()->calculateVolumeAdjustement(point, attenuation, 0);
// Calculate panning
- int32 panning = getSound()->calculatePanningAtPoint(x, y);
+ int32 panning = getSound()->calculatePanningAtPoint(point);
// Adjust object properties
object->setSoundResourceId(resourceId);
@@ -1338,10 +1337,10 @@ void Special::playSoundPanning(ResourceId resourceId, int32 attenuation, ActorIn
// Calculate volume adjustment
int32 adjustedVolume = Config.voiceVolume;
- adjustedVolume += getSound()->calculateVolumeAdjustement(actor->getPoint1()->x, actor->getPoint1()->y, attenuation, 0);
+ adjustedVolume += getSound()->calculateVolumeAdjustement(*actor->getPoint1(), attenuation, 0);
// Calculate panning
- int32 panning = getSound()->calculatePanningAtPoint(actor->getPoint1()->x + actor->getPoint2()->x, actor->getPoint1()->y + actor->getPoint2()->y);
+ int32 panning = getSound()->calculatePanningAtPoint(*actor->getPoint1() + *actor->getPoint2());
getSound()->playSound(resourceId, false, adjustedVolume, panning);
}
diff --git a/engines/asylum/resources/worldstats.cpp b/engines/asylum/resources/worldstats.cpp
index 2bcf7d2ac3..f0e761809d 100644
--- a/engines/asylum/resources/worldstats.cpp
+++ b/engines/asylum/resources/worldstats.cpp
@@ -178,8 +178,8 @@ void WorldStats::load(Common::SeekableReadStream *stream) {
for (int32 i = 0; i < 6; i++)
ambientSounds[s].flagNum[i] = (GameFlag)stream->readSint32LE();
- ambientSounds[s].x = stream->readSint32LE();
- ambientSounds[s].y = stream->readSint32LE();
+ ambientSounds[s].point.x = stream->readSint32LE();
+ ambientSounds[s].point.y = stream->readSint32LE();
}
numAmbientSounds = stream->readSint32LE();
diff --git a/engines/asylum/system/screen.cpp b/engines/asylum/system/screen.cpp
index 1f9c9057d9..c42044fb35 100644
--- a/engines/asylum/system/screen.cpp
+++ b/engines/asylum/system/screen.cpp
@@ -319,7 +319,7 @@ void Screen::selectTransTable(uint32 index) {
//////////////////////////////////////////////////////////////////////////
// Graphic queue
//////////////////////////////////////////////////////////////////////////
-void Screen::addGraphicToQueue(ResourceId resourceId, uint32 frameIndex, Common::Point point, DrawFlags flags, int32 transTableNum, int32 priority) {
+void Screen::addGraphicToQueue(ResourceId resourceId, uint32 frameIndex, const Common::Point &point, DrawFlags flags, int32 transTableNum, int32 priority) {
GraphicQueueItem item;
item.priority = priority;
@@ -333,7 +333,7 @@ void Screen::addGraphicToQueue(ResourceId resourceId, uint32 frameIndex, Common:
_queueItems.push_back(item);
}
-void Screen::addGraphicToQueueMasked(ResourceId resourceId, uint32 frameIndex, Common::Point source, int32 resourceIdDestination, Common::Point destination, DrawFlags flags, int32 priority) {
+void Screen::addGraphicToQueueMasked(ResourceId resourceId, uint32 frameIndex, const Common::Point &source, int32 resourceIdDestination, const Common::Point &destination, DrawFlags flags, int32 priority) {
GraphicQueueItem item;
item.priority = priority;
@@ -497,8 +497,8 @@ void Screen::copyToBackBufferWithTransparency(byte *buffer, int32 pitch, int32 x
//////////////////////////////////////////////////////////////////////////
// Debug
//////////////////////////////////////////////////////////////////////////
-void Screen::drawLine(int x0, int y0, int x1, int y1) {
- _backBuffer.drawLine(x0, y0, x1, y1, 0xFF);
+void Screen::drawLine(const Common::Point &source, const Common::Point &destination) {
+ _backBuffer.drawLine(source.x, source.y, destination.x, destination.y, 0xFF);
}
void Screen::copyToBackBufferClipped(Graphics::Surface *surface, int x, int y) {
@@ -507,7 +507,7 @@ void Screen::copyToBackBufferClipped(Graphics::Surface *surface, int x, int y) {
animRect.clip(screenRect);
if (!animRect.isEmpty()) {
- // Translate anim rectangle
+ // Translate animation rectangle
animRect.translate(-(int16)getWorld()->xLeft, -(int16)getWorld()->yTop);
int startX = animRect.right == 640 ? 0 : surface->w - animRect.width();
diff --git a/engines/asylum/system/screen.h b/engines/asylum/system/screen.h
index 3572290ee0..73853ab155 100644
--- a/engines/asylum/system/screen.h
+++ b/engines/asylum/system/screen.h
@@ -114,9 +114,9 @@ public:
byte *getTransTableIndex() { return _transTableIndex; }
// Graphic queue
- void addGraphicToQueue(ResourceId resourceId, uint32 frameIndex, Common::Point point, DrawFlags flags, int32 transTableNum, int32 priority);
+ void addGraphicToQueue(ResourceId resourceId, uint32 frameIndex, const Common::Point &point, DrawFlags flags, int32 transTableNum, int32 priority);
void addGraphicToQueueCrossfade(ResourceId resourceId, uint32 frameIndex, Common::Point source, int32 objectResourceId, Common::Point destination, int32 transTableNum);
- void addGraphicToQueueMasked(ResourceId resourceId, uint32 frameIndex, Common::Point point, int32 objectResourceId, Common::Point destination, DrawFlags flags, int32 priority);
+ void addGraphicToQueueMasked(ResourceId resourceId, uint32 frameIndex, const Common::Point &source, int32 objectResourceId, const Common::Point &destination, DrawFlags flags, int32 priority);
void addGraphicToQueue(GraphicQueueItem const &item);
void drawGraphicsInQueue();
void clearGraphicsInQueue();
@@ -126,7 +126,7 @@ public:
void copyToBackBuffer(byte *buffer, int32 pitch, int32 x, int32 y, uint32 width, uint32 height, bool mirrored = false);
// Debug
- void drawLine(int x0, int y0, int x1, int y1);
+ void drawLine(const Common::Point &origin, const Common::Point &destination);
void copyToBackBufferClipped(Graphics::Surface *surface, int x, int y);
private:
diff --git a/engines/asylum/system/sound.cpp b/engines/asylum/system/sound.cpp
index cdb68e1b46..ab47030e86 100644
--- a/engines/asylum/system/sound.cpp
+++ b/engines/asylum/system/sound.cpp
@@ -158,20 +158,21 @@ void Sound::setPanning(ResourceId resourceId, int32 panning) {
_mixer->setChannelBalance(item->handle, (int8)panning);
}
-int32 Sound::calculateVolumeAdjustement(int32 x, int32 y, int32 attenuation, int32 delta) {
+int32 Sound::calculateVolumeAdjustement(const Common::Point &point, int32 attenuation, int32 delta) {
if (!attenuation)
return -(delta * delta);
+ Common::Point adjusted(point);
Actor *player = getScene()->getActor();
if (getSharedData()->point.x == -1) {
- x -= (player->getPoint1()->x + player->getPoint2()->x);
- y -= (player->getPoint1()->y + player->getPoint2()->y);
+ adjusted.x -= (player->getPoint1()->x + player->getPoint2()->x);
+ adjusted.y -= (player->getPoint1()->y + player->getPoint2()->y);
} else {
- x -= getSharedData()->point.x;
- y -= getSharedData()->point.y;
+ adjusted.x -= getSharedData()->point.x;
+ adjusted.y -= getSharedData()->point.y;
}
- int32 adjustedVolume = getAdjustedVolume(x * x + y * y);
+ int32 adjustedVolume = getAdjustedVolume(adjusted.x * adjusted.x + adjusted.y * adjusted.y);
Common::Rational invAtt(100, attenuation);
Common::Rational v;
@@ -215,10 +216,10 @@ int32 Sound::getAdjustedVolume(int32 volume) {
return adjustedVolume;
}
-int32 Sound::calculatePanningAtPoint(int32 x, int32) {
- // y does not seem to be used at all :S
+int32 Sound::calculatePanningAtPoint(const Common::Point &point) {
+ // point.y does not seem to be used at all :S
- int delta = x - getWorld()->xLeft;
+ int delta = point.x - getWorld()->xLeft;
if (delta < 0)
return (getWorld()->reverseStereo ? 10000 : -10000);
diff --git a/engines/asylum/system/sound.h b/engines/asylum/system/sound.h
index 551b21da08..3f174f222d 100644
--- a/engines/asylum/system/sound.h
+++ b/engines/asylum/system/sound.h
@@ -31,6 +31,7 @@
#include "asylum/shared.h"
#include "common/array.h"
+#include "common/rect.h"
#include "audio/mixer.h"
@@ -80,8 +81,7 @@ struct AmbientSoundItem {
int32 attenuation;
int32 nextTick;
GameFlag flagNum[6];
- int32 x;
- int32 y;
+ Common::Point point;
AmbientSoundItem() {
field_0 = 0;
@@ -91,8 +91,6 @@ struct AmbientSoundItem {
attenuation = 0;
nextTick = 0;
memset(&flagNum, 0, sizeof(flagNum));
- x = 0;
- y = 0;
}
};
@@ -188,14 +186,13 @@ public:
/**
* Determine the amount to increase the supplied sound sample's volume based on the position.
*
- * @param x The x coordinate.
- * @param y The y coordinate.
+ * @param point The coordinates
* @param attenuation The attenuation.
- * @param delta The delta.
+ * @param delta The delta.
*
* @return The calculated volume adjustement.
*/
- int32 calculateVolumeAdjustement(int32 x, int32 y, int32 attenuation, int32 delta);
+ int32 calculateVolumeAdjustement(const Common::Point &point, int32 attenuation, int32 delta);
/**
* Gets an adjusted volume.
@@ -209,12 +206,11 @@ public:
/**
* Calculates the panning at point.
*
- * @param x The x coordinate.
- * @param y The y coordinate.
+ * @param point The coordinates.
*
* @return The calculated panning at point.
*/
- int32 calculatePanningAtPoint(int32 x, int32 y);
+ int32 calculatePanningAtPoint(const Common::Point &point);
//////////////////////////////////////////////////////////////////////////
// Stopping sounds
diff --git a/engines/asylum/views/scene.cpp b/engines/asylum/views/scene.cpp
index 4b0a77bbe2..9521d38551 100644
--- a/engines/asylum/views/scene.cpp
+++ b/engines/asylum/views/scene.cpp
@@ -861,7 +861,7 @@ void Scene::updateAmbientSounds() {
if (_vm->sound()->isPlaying(snd->resourceId)) {
if (snd->field_0) {
- int32 volume = Config.ambientVolume + getSound()->calculateVolumeAdjustement(snd->x, snd->y, snd->attenuation, snd->delta);
+ int32 volume = Config.ambientVolume + getSound()->calculateVolumeAdjustement(snd->point, snd->attenuation, snd->delta);
if (volume <= 0) {
if (volume < -10000)
@@ -874,11 +874,11 @@ void Scene::updateAmbientSounds() {
}
} else {
- int32 panning = (snd->field_0) ? getSound()->calculatePanningAtPoint(snd->x, snd->y) : 0;
+ int32 panning = (snd->field_0) ? getSound()->calculatePanningAtPoint(snd->point) : 0;
int32 volume = 0;
if (snd->field_0)
- volume = getSound()->calculateVolumeAdjustement(snd->x, snd->y, snd->attenuation, snd->delta);
+ volume = getSound()->calculateVolumeAdjustement(snd->point, snd->attenuation, snd->delta);
else
volume = -pow((double)snd->delta, 2);
Commit: 9979c064214514252572c8c09c88c592d5cb32ed
https://github.com/scummvm/scummvm/commit/9979c064214514252572c8c09c88c592d5cb32ed
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:56+02:00
Commit Message:
ASYLUM: Implement pipes puzzle
Original patch by midstream
Changed paths:
engines/asylum/puzzles/pipes.cpp
engines/asylum/puzzles/pipes.h
diff --git a/engines/asylum/puzzles/pipes.cpp b/engines/asylum/puzzles/pipes.cpp
index 4dbe597d8e..c7225cbd4d 100644
--- a/engines/asylum/puzzles/pipes.cpp
+++ b/engines/asylum/puzzles/pipes.cpp
@@ -18,9 +18,6 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * $URL$
- * $Id$
- *
*/
#include "asylum/puzzles/pipes.h"
@@ -35,11 +32,243 @@
#include "asylum/asylum.h"
+#include <math.h>
+
namespace Asylum {
+const Common::Point connectorPoints[] = {
+ Common::Point(158, 59),
+ Common::Point(202, 59),
+ Common::Point(271, 60),
+ Common::Point(380, 72),
+ Common::Point(205, 132),
+ Common::Point(272, 131),
+ Common::Point(469, 119),
+ Common::Point(163, 172),
+ Common::Point(206, 172),
+ Common::Point(318, 169),
+ Common::Point(360, 171),
+ Common::Point(428, 172),
+ Common::Point(466, 171),
+ Common::Point(319, 206),
+ Common::Point(360, 206),
+ Common::Point(168, 272),
+ Common::Point(273, 262),
+ Common::Point(318, 261),
+ Common::Point(401, 242),
+ Common::Point(399, 295),
+ Common::Point(460, 294)
+};
+
+const Common::Point peepholePoints[] = {
+ Common::Point(140, 65),
+ Common::Point(311, 44),
+ Common::Point(387, 48),
+ Common::Point(475, 72),
+ Common::Point(189, 67),
+ Common::Point(246, 66),
+ Common::Point(169, 113),
+ Common::Point(215, 106),
+ Common::Point(280, 105),
+ Common::Point(336, 95),
+ Common::Point(434, 80),
+ Common::Point(248, 136),
+ Common::Point(303, 154),
+ Common::Point(407, 125),
+ Common::Point(470, 151),
+ Common::Point(193, 180),
+ Common::Point(347, 176),
+ Common::Point(401, 177),
+ Common::Point(245, 201),
+ Common::Point(325, 196),
+ Common::Point(347, 212),
+ Common::Point(406, 213),
+ Common::Point(431, 218),
+ Common::Point(174, 228),
+ Common::Point(217, 234),
+ Common::Point(280, 227),
+ Common::Point(325, 239),
+ Common::Point(370, 244),
+ Common::Point(467, 239),
+ Common::Point(303, 267),
+ Common::Point(405, 273),
+ Common::Point(356, 293),
+ Common::Point(436, 294),
+ Common::Point(182, 317),
+ Common::Point(277, 299),
+ Common::Point(324, 291),
+ Common::Point(461, 323)
+};
+
+const uint32 peepholeResources[] = {15, 15, 15, 15, 32, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 32, 32, 15,
+ 15, 32, 32, 15, 15, 15, 15,15, 15, 15, 15, 32, 15, 15, 15, 15, 15, 15, 15};
+
+//////////////////////////////////////////////////////////////////////////
+// Peephole
+//////////////////////////////////////////////////////////////////////////
+bool Peephole::marks[peepholesCount];
+
+void Peephole::connect(Connector *connector) {
+ _connectors.push_back(connector);
+}
+
+void Peephole::disconnect(Connector *connector) {
+ _connectors.remove(connector);
+}
+
+void Peephole::startUpWater(bool flag) {
+ if (flag)
+ memset(marks, false, sizeof(marks));
+
+ marks[_id] = true;
+
+ for (Common::List<Connector *>::iterator iter = _connectors.begin(); iter != _connectors.end(); ++iter) {
+ for (Common::List<Peephole *>::iterator iter1 = (*iter)->_connectedNodes.begin(); iter1 != (*iter)->_connectedNodes.end(); ++iter1) {
+ if (!marks[(*iter1)->getId()]) {
+
+ for (uint32 i = 0; i < 4; ++i) {
+ if (isConnected(i) && (*iter1)->getId() > 3)
+ (*iter1)->_flowValues[i] += _flowValues[i];
+ }
+
+ (*iter1)->startUpWater();
+ }
+ }
+ }
+}
+
+//////////////////////////////////////////////////////////////////////////
+// Connector
+//////////////////////////////////////////////////////////////////////////
+void Connector::init(Peephole *n, Peephole *e, Peephole *s, Peephole *w, BinNum state, Connector *nextConnector, Direction nextConnectorPosition) {
+ _nodes[0] = n;
+ _nodes[1] = e;
+ _nodes[2] = s;
+ _nodes[3] = w;
+
+ _state = state;
+ _nextConnector = nextConnector;
+ _nextConnectorPosition = nextConnectorPosition;
+ _isConnected = false;
+
+ for (uint32 i = 0; i < 4; ++i) {
+ if (_state & (1 << i) && _nodes[i]) {
+ _nodes[i]->connect(this);
+ _connectedNodes.push_back(_nodes[i]);
+ }
+ }
+}
+
+void Connector::initGroup() {
+ if (!_isConnected && isReadyForConnection() && _nextConnector->isReadyForConnection())
+ connect(_nextConnector);
+}
+
+void Connector::turn() {
+ BinNum newState = BinNum(_state >> 1 | (_state & 1) << 3);
+
+ uint32 delta = _state ^ newState;
+ uint32 newIndex[2], oldIndex[2];
+
+ if (delta == kBinNum1111) {
+ if (newState == kBinNum0101) {
+ newIndex[0] = 0;
+ newIndex[1] = 2;
+ oldIndex[0] = 1;
+ oldIndex[1] = 3;
+ } else {
+ newIndex[0] = 1;
+ newIndex[1] = 3;
+ oldIndex[0] = 0;
+ oldIndex[1] = 2;
+ }
+ } else {
+ newIndex[0] = log((double)(newState & delta)) / log((double)2);
+ oldIndex[0] = log((double)(_state & delta)) / log((double)2);
+ }
+
+ for (uint32 i = 0; i < (uint32)(delta == kBinNum1111 ? 2 : 1); ++i) {
+ if (_nodes[oldIndex[i]]) {
+ _nodes[oldIndex[i]]->disconnect(this);
+ _connectedNodes.remove(_nodes[oldIndex[i]]);
+ }
+
+ if (_nodes[newIndex[i]]) {
+ _nodes[newIndex[i]]->connect(this);
+ _connectedNodes.push_back(_nodes[newIndex[i]]);
+ }
+ }
+
+ _state = newState;
+
+ if (_nextConnector) {
+ if (_isConnected) {
+ if(!(_nextConnectorPosition & _state))
+ disconnect(_nextConnector);
+ } else if (_nextConnectorPosition & _state && _nextConnector->isReadyForConnection()) {
+ connect(_nextConnector);
+ }
+ }
+}
+
+void Connector::connect(Connector *connector) {
+ for (Common::List<Peephole *>::iterator iter = _connectedNodes.begin(); iter != _connectedNodes.end(); ++iter) {
+ (*iter)->connect(connector);
+ connector->_connectedNodes.push_back(*iter);
+ }
+
+ for (Common::List<Peephole *>::iterator iter = connector->_connectedNodes.begin(); iter != connector->_connectedNodes.end(); ++iter) {
+ (*iter)->connect(this);
+ _connectedNodes.push_back(*iter);
+ }
+
+ _isConnected = connector->_isConnected = true;
+
+}
+
+void Connector::disconnect(Connector *connector) {
+ uint32 i;
+ Common::List<Common::List<Peephole *>::iterator> markedForDeletion;
+ bool flag;
+
+ for (i = 0; i < 4; ++i)
+ if (_nodes[i]) {
+ _nodes[i]->disconnect(connector);
+ connector->_connectedNodes.remove(_nodes[i]);
+ }
+
+ for (Common::List<Peephole *>::iterator iter = _connectedNodes.begin(); iter != _connectedNodes.end(); ++iter) {
+ flag = true;
+
+ for (i = 0; i < 4; ++i) {
+ if (*iter == _nodes[i]) {
+ flag = false;
+ break;
+ }
+ }
+
+ if (flag)
+ markedForDeletion.push_back(iter);
+ }
+
+ for (Common::List<Common::List<Peephole *>::iterator>::iterator iter1 = markedForDeletion.begin(); iter1 != markedForDeletion.end(); ++iter1) {
+ (*(*iter1))->disconnect(this);
+ _connectedNodes.remove(*(*iter1));
+ }
+
+ _isConnected = connector->_isConnected = false;
+}
+
+//////////////////////////////////////////////////////////////////////////
+// PuzzlePipes
+//////////////////////////////////////////////////////////////////////////
PuzzlePipes::PuzzlePipes(AsylumEngine *engine) : Puzzle(engine) {
_previousMusicVolume = 0;
_rectIndex = -2;
+
+ _frameIndex = _frameIndexLever = 0;
+ memset(&_levelFlags, false, sizeof(_levelFlags));
+ _levelFlags[4] = true;
}
PuzzlePipes::~PuzzlePipes() {
@@ -64,19 +293,88 @@ bool PuzzlePipes::init(const AsylumEvent &evt) {
_rectIndex = -2;
- updateCursor();
initResources();
- setup(true);
+ setup();
return true;
}
bool PuzzlePipes::update(const AsylumEvent &evt) {
- error("[PuzzlePipes::update] Not implemented!");
+ getScreen()->clear();
+ getScreen()->clearGraphicsInQueue();
+ getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[1], 0, Common::Point(0, 0), kDrawFlagNone, 0, 4);
+
+ for (uint32 i = 0; i < ARRAYSIZE(_connectors); ++i)
+ getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[_connectorResources[_connectors[i].getState()]], 0, connectorPoints[i], kDrawFlagNone, 0, 1);
+
+ // TODO: continuous progressbars
+ getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[18], 0, Common::Point(210, 444 - uint32(_levelValues[0] * 52)), kDrawFlagNone, 0, 3);
+ getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[18], 0, Common::Point(276, 455 - uint32(_levelValues[1] * 52)), kDrawFlagNone, 0, 3);
+ getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[18], 0, Common::Point(376, 448 - uint32(_levelValues[2] * 52)), kDrawFlagNone, 0, 3);
+ getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[18], 0, Common::Point(458, 442 - uint32(_levelValues[3] * 52)), kDrawFlagNone, 0, 3);
+
+ getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[33], 0, Common::Point(204, 377), kDrawFlagNone, 0, 1);
+
+ _frameIndex = (_frameIndex + 1) % GraphicResource::getFrameCount(_vm, getWorld()->graphicResourceIds[15]);
+ for (uint32 i = 0; i < ARRAYSIZE(_peepholes); ++i)
+ if (_peepholes[i].isConnected())
+ getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[peepholeResources[i]], _frameIndex, peepholePoints[i], kDrawFlagNone, 0, 1);
+
+ getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[2], _frameIndexLever, Common::Point(540, 90), kDrawFlagNone, 0, 1);
+ _isLeverReady = false;
+ if (_frameIndexLever) {
+ _frameIndexLever = (_frameIndexLever + 1) % GraphicResource::getFrameCount(_vm, getWorld()->graphicResourceIds[2]);
+ if (!_frameIndexLever)
+ _isLeverReady = true;
+ }
+
+ // TODO: turn the fountain on
+ if (_levelFlags[0])
+ getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[40], 0, Common::Point(233, 416), kDrawFlagNone, 0, 1);
+ else if (_levelFlags[1])
+ getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[40], 0, Common::Point(299, 431), kDrawFlagNone, 0, 1);
+ else if (_levelFlags[2])
+ getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[40], 0, Common::Point(398, 421), kDrawFlagNone, 0, 1);
+ else if (_levelFlags[3])
+ getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[40], 0, Common::Point(481, 417), kDrawFlagNone, 0, 1);
+ if (!_levelFlags[4])
+ getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[45], 0, Common::Point(518, 108), kDrawFlagNone, 0, 2);
+
+ getScreen()->drawGraphicsInQueue();
+ getScreen()->copyBackBufferToScreen();
+ updateCursor();
+
+ if (_isLeverReady && !_levelFlags[4]) {
+ getScreen()->clear();
+ getSound()->stop(getWorld()->graphicResourceIds[41]);
+ getSound()->setMusicVolume(_previousMusicVolume);
+
+ _vm->switchEventHandler(getScene());
+ }
+
+ return true;
}
bool PuzzlePipes::mouseLeftDown(const AsylumEvent &evt) {
- error("[PuzzlePipes::mouseLeftDown] Not implemented!");
+ Common::Point mousePos = getCursor()->position();
+
+ if (Common::Rect(540, 90, 590, 250).contains(mousePos)) {
+ if (!_frameIndexLever)
+ ++_frameIndexLever;
+
+ getSound()->playSound(getWorld()->graphicResourceIds[43], false, Config.sfxVolume - 10);
+ } else {
+ if (_rectIndex != -1) {
+ getSound()->playSound(getWorld()->graphicResourceIds[42], false, Config.sfxVolume - 10);
+
+ _connectors[_rectIndex].turn();
+ startUpWater();
+ memset(_levelFlags, false, sizeof(_levelFlags));
+ _levelFlags[checkFlags()] = true;
+ }
+ }
+
+ return true;
}
bool PuzzlePipes::mouseRightDown(const AsylumEvent &evt) {
@@ -93,11 +391,63 @@ bool PuzzlePipes::mouseRightDown(const AsylumEvent &evt) {
// Helpers
//////////////////////////////////////////////////////////////////////////
void PuzzlePipes::initResources() {
- error("[PuzzlePipes::initResources] Not implemented!");
+ _connectorResources[kBinNum0011] = 4;
+ _connectorResources[kBinNum0110] = 3;
+ _connectorResources[kBinNum1100] = 6;
+ _connectorResources[kBinNum1001] = 5;
+
+ _connectorResources[kBinNum0111] = 7;
+ _connectorResources[kBinNum1110] = 10;
+ _connectorResources[kBinNum1101] = 9;
+ _connectorResources[kBinNum1011] = 8;
+
+ _connectorResources[kBinNum0101] = 11;
+ _connectorResources[kBinNum1010] = 12;
}
-void PuzzlePipes::setup(bool val) {
- error("[PuzzlePipes::setup] Not implemented!");
+void PuzzlePipes::setup() {
+ memset(&_levelValues, 0.0, sizeof(_levelValues));
+
+ for (uint32 i = 0; i < peepholesCount; ++i)
+ _peepholes[i].setId(i);
+
+ for (uint32 i = 0; i < connectorsCount; ++i)
+ _connectors[i].setId(i);
+
+ for (uint32 i = 0; i < 4; ++i) {
+ _sinks[i] = &_peepholes[peepholesCount - 4 + i];
+ _sources[i] = &_peepholes[i];
+ memset(&_sources[i]->_flowValues, 0, sizeof(_sources[i]->_flowValues));
+ _sources[i]->_flowValues[i] = 1;
+ }
+
+ _connectors[ 0].init( NULL, _peepholes + 4, _peepholes + 6, _peepholes + 0, kBinNum0110);
+ _connectors[ 1].init( NULL, _peepholes + 5, _peepholes + 7, _peepholes + 4, kBinNum0110);
+ _connectors[ 2].init( NULL, _peepholes + 1, _peepholes + 8, _peepholes + 5, kBinNum0110);
+ _connectors[ 3].init(_peepholes + 2, _peepholes + 10, NULL, _peepholes + 9, kBinNum0011);
+ _connectors[ 4].init(_peepholes + 7, _peepholes + 11, NULL, NULL, kBinNum0011, _connectors + 8, kDirectionSh);
+ _connectors[ 5].init(_peepholes + 8, _peepholes + 12, _peepholes + 25, _peepholes + 11, kBinNum0111);
+ _connectors[ 6].init(_peepholes + 3, NULL, _peepholes + 14, _peepholes + 13, kBinNum1100);
+ _connectors[ 7].init(_peepholes + 6, _peepholes + 15, _peepholes + 23, NULL, kBinNum0110);
+ _connectors[ 8].init( NULL, _peepholes + 18, _peepholes + 24, _peepholes + 15, kBinNum0111, _connectors + 4, kDirectionNh);
+ _connectors[ 9].init(_peepholes + 9, _peepholes + 16, _peepholes + 19, _peepholes + 12, kBinNum1110);
+ _connectors[10].init(_peepholes + 13, _peepholes + 17, NULL, _peepholes + 16, kBinNum0111, _connectors + 14, kDirectionSh);
+ _connectors[11].init(_peepholes + 10, NULL, _peepholes + 22, _peepholes + 17, kBinNum0101, _connectors + 12, kDirectionEt);
+ _connectors[12].init(_peepholes + 14, NULL, _peepholes + 28, NULL, kBinNum1001, _connectors + 11, kDirectionWt);
+ _connectors[13].init(_peepholes + 19, _peepholes + 20, _peepholes + 26, NULL, kBinNum0011);
+ _connectors[14].init( NULL, _peepholes + 21, _peepholes + 27, _peepholes + 20, kBinNum1110, _connectors + 10, kDirectionNh);
+ _connectors[15].init(_peepholes + 23, _peepholes + 24, _peepholes + 33, NULL, kBinNum0011);
+ _connectors[16].init(_peepholes + 25, _peepholes + 29, _peepholes + 34, _peepholes + 18, kBinNum1011);
+ _connectors[17].init(_peepholes + 26, _peepholes + 31, _peepholes + 35, _peepholes + 29, kBinNum1011);
+ _connectors[18].init(_peepholes + 21, _peepholes + 22, _peepholes + 30, _peepholes + 27, kBinNum1011);
+ _connectors[19].init(_peepholes + 30, _peepholes + 32, NULL, _peepholes + 31, kBinNum0011);
+ _connectors[20].init(_peepholes + 28, NULL, _peepholes + 36, _peepholes + 32, kBinNum1001);
+
+ _connectors[ 4].initGroup();
+ _connectors[10].initGroup();
+ _connectors[11].initGroup();
+
+ startUpWater();
}
void PuzzlePipes::updateCursor() {
@@ -107,18 +457,47 @@ void PuzzlePipes::updateCursor() {
return;
_rectIndex = index;
- if (index == -1)
- getCursor()->set(getWorld()->graphicResourceIds[16], 0, kCursorAnimationNone);
- else
+ // FIXME
+ if (index > -1 || Common::Rect(540, 90, 590, 250).contains(getCursor()->position()))
getCursor()->set(getWorld()->graphicResourceIds[16]);
+ else
+ getCursor()->set(getWorld()->graphicResourceIds[16], 0, kCursorAnimationNone);
}
int32 PuzzlePipes::findRect() {
- error("[PuzzlePipes::findRect] Not implemented!");
+ for (uint32 i = 0; i < ARRAYSIZE(connectorPoints); ++i)
+ if (Common::Rect(connectorPoints[i].x - 5, connectorPoints[i].y - 5, connectorPoints[i].x + 30, connectorPoints[i].y + 30).contains(getCursor()->position()))
+ return i;
+
+ return -1;
}
-void PuzzlePipes::checkFlags() {
- error("[PuzzlePipes::checkFlags] Not implemented!");
+uint32 PuzzlePipes::checkFlags() {
+ uint32 total = _sinks[0]->getLevel1() + _sinks[1]->getLevel1() +_sinks[2]->getLevel1() + _sinks[3]->getLevel1();
+ float temp;
+ uint32 val = 4;
+
+ if (total)
+ for (uint32 i = 0; i < 4; ++i) {
+ temp = _sinks[i]->getLevel1() / float(total);
+ _levelValues[i] = temp * _sinks[i]->getLevel() / 4;
+ if (_levelValues[i] == 1.0)
+ val = i;
+ }
+ else
+ memset(_levelValues, 0, sizeof(_levelValues));
+
+ return val;
+}
+
+void PuzzlePipes::startUpWater() {
+ for (uint32 i = 4; i < peepholesCount; ++i)
+ memset(_peepholes[i]._flowValues, 0, sizeof(_peepholes[i]._flowValues));
+
+ _sources[0]->startUpWater(true);
+ _sources[1]->startUpWater(true);
+ _sources[2]->startUpWater(true);
+ _sources[3]->startUpWater(true);
}
} // End of namespace Asylum
diff --git a/engines/asylum/puzzles/pipes.h b/engines/asylum/puzzles/pipes.h
index 19d21bf291..ae3f640770 100644
--- a/engines/asylum/puzzles/pipes.h
+++ b/engines/asylum/puzzles/pipes.h
@@ -18,9 +18,6 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * $URL$
- * $Id$
- *
*/
#ifndef ASYLUM_PIPES_H
@@ -28,9 +25,98 @@
#include "asylum/puzzles/puzzle.h"
+#include "common/list.h"
+#include "common/hashmap.h"
+
namespace Asylum {
class AsylumEngine;
+class Connector;
+
+static const uint32 connectorsCount = 21, peepholesCount = 37;
+
+enum BinNum {
+ kBinNum0000,
+ kBinNum0001,
+ kBinNum0010,
+ kBinNum0011,
+ kBinNum0100,
+ kBinNum0101,
+ kBinNum0110,
+ kBinNum0111,
+ kBinNum1000,
+ kBinNum1001,
+ kBinNum1010,
+ kBinNum1011,
+ kBinNum1100,
+ kBinNum1101,
+ kBinNum1110,
+ kBinNum1111
+};
+
+enum Direction {
+ kDirectionNowhere = kBinNum0000,
+ kDirectionNh = kBinNum0001,
+ kDirectionEt = kBinNum0010,
+ kDirectionSh = kBinNum0100,
+ kDirectionWt = kBinNum1000
+};
+
+class Peephole {
+public:
+ Peephole() {}
+ ~Peephole() {}
+
+ static bool marks[peepholesCount];
+ uint32 _flowValues[4];
+
+ uint32 getId() { return _id; }
+ void setId(uint32 id) { _id = id; }
+ uint32 getLevel() { return (_flowValues[0] > 0) + (_flowValues[1] > 0) + (_flowValues[2] > 0) + (_flowValues[3] > 0); }
+ uint32 getLevel1() { return _flowValues[0] + _flowValues[1] + _flowValues[2] + _flowValues[3]; }
+ bool isConnected() { return isConnected(0) || isConnected(1) || isConnected(2) || isConnected(3); }
+
+ void connect(Connector *connector);
+ void disconnect(Connector *connector);
+ void startUpWater(bool flag = false);
+
+private:
+ uint32 _id;
+ Common::List<Connector *> _connectors;
+
+ bool isConnected(uint32 val) { return _flowValues[val]; }
+};
+
+class Connector {
+public:
+ Connector() {}
+ ~Connector() {}
+
+ uint32 getId() { return _id; }
+ void setId(uint32 id) { _id = id; }
+ BinNum getState() { return _state; }
+
+ void init(Peephole *n, Peephole *e, Peephole *s, Peephole *w, BinNum state, Connector *nextConnector = NULL, Direction nextConnectorPosition = kDirectionNowhere);
+ void initGroup();
+ void turn();
+
+private:
+ uint32 _id;
+ BinNum _state;
+ Peephole *_nodes[4];
+ Common::List<Peephole *> _connectedNodes;
+
+ Connector *_nextConnector;
+ Direction _nextConnectorPosition;
+ bool _isConnected;
+
+ void connect(Connector *connector);
+ void disconnect(Connector *connector);
+
+ bool isReadyForConnection() { return _state & _nextConnectorPosition; }
+
+ friend void Peephole::startUpWater(bool);
+};
class PuzzlePipes : public Puzzle {
public:
@@ -42,6 +128,14 @@ public:
private:
int32 _previousMusicVolume;
int32 _rectIndex;
+ uint32 _frameIndex, _frameIndexLever;
+ bool _levelFlags[5];
+ float _levelValues[4];
+ bool _isLeverReady;
+ Common::HashMap<uint32, uint32> _connectorResources;
+ Connector _connectors[connectorsCount];
+ Peephole _peepholes[peepholesCount];
+ Peephole *_sinks[4], *_sources[4];
//////////////////////////////////////////////////////////////////////////
// Event Handling
@@ -55,10 +149,11 @@ private:
// Helpers
//////////////////////////////////////////////////////////////////////////
void initResources();
- void setup(bool val);
+ void setup();
void updateCursor();
int32 findRect();
- void checkFlags();
+ uint32 checkFlags();
+ void startUpWater();
};
} // End of namespace Asylum
Commit: 1db67c5c8825f538d0a5cc345a34b303f076032e
https://github.com/scummvm/scummvm/commit/1db67c5c8825f538d0a5cc345a34b303f076032e
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:57+02:00
Commit Message:
ASYLUM: Remove SVN keywords
Changed paths:
engines/asylum/asylum.cpp
engines/asylum/asylum.h
engines/asylum/console.cpp
engines/asylum/console.h
engines/asylum/detection.cpp
engines/asylum/eventhandler.h
engines/asylum/puzzles/board.cpp
engines/asylum/puzzles/board.h
engines/asylum/puzzles/boardkeyhidesto.cpp
engines/asylum/puzzles/boardkeyhidesto.h
engines/asylum/puzzles/boardsalvation.cpp
engines/asylum/puzzles/boardsalvation.h
engines/asylum/puzzles/boardyouth.cpp
engines/asylum/puzzles/boardyouth.h
engines/asylum/puzzles/clock.cpp
engines/asylum/puzzles/clock.h
engines/asylum/puzzles/data.h
engines/asylum/puzzles/fisherman.cpp
engines/asylum/puzzles/fisherman.h
engines/asylum/puzzles/hivecontrol.cpp
engines/asylum/puzzles/hivecontrol.h
engines/asylum/puzzles/hivemachine.cpp
engines/asylum/puzzles/hivemachine.h
engines/asylum/puzzles/lock.cpp
engines/asylum/puzzles/lock.h
engines/asylum/puzzles/morguedoor.cpp
engines/asylum/puzzles/morguedoor.h
engines/asylum/puzzles/puzzle.cpp
engines/asylum/puzzles/puzzle.h
engines/asylum/puzzles/puzzle11.cpp
engines/asylum/puzzles/puzzle11.h
engines/asylum/puzzles/tictactoe.cpp
engines/asylum/puzzles/tictactoe.h
engines/asylum/puzzles/timemachine.cpp
engines/asylum/puzzles/timemachine.h
engines/asylum/puzzles/vcr.cpp
engines/asylum/puzzles/vcr.h
engines/asylum/puzzles/wheel.cpp
engines/asylum/puzzles/wheel.h
engines/asylum/puzzles/writings.cpp
engines/asylum/puzzles/writings.h
engines/asylum/resources/actor.cpp
engines/asylum/resources/actor.h
engines/asylum/resources/data.h
engines/asylum/resources/encounters.cpp
engines/asylum/resources/encounters.h
engines/asylum/resources/object.cpp
engines/asylum/resources/object.h
engines/asylum/resources/polygons.cpp
engines/asylum/resources/polygons.h
engines/asylum/resources/reaction.cpp
engines/asylum/resources/reaction.h
engines/asylum/resources/script.cpp
engines/asylum/resources/script.h
engines/asylum/resources/special.cpp
engines/asylum/resources/special.h
engines/asylum/resources/worldstats.cpp
engines/asylum/resources/worldstats.h
engines/asylum/respack.cpp
engines/asylum/respack.h
engines/asylum/shared.h
engines/asylum/staticres.h
engines/asylum/system/config.cpp
engines/asylum/system/config.h
engines/asylum/system/cursor.cpp
engines/asylum/system/cursor.h
engines/asylum/system/graphics.cpp
engines/asylum/system/graphics.h
engines/asylum/system/savegame.cpp
engines/asylum/system/savegame.h
engines/asylum/system/screen.cpp
engines/asylum/system/screen.h
engines/asylum/system/sound.cpp
engines/asylum/system/sound.h
engines/asylum/system/speech.cpp
engines/asylum/system/speech.h
engines/asylum/system/text.cpp
engines/asylum/system/text.h
engines/asylum/views/menu.cpp
engines/asylum/views/menu.h
engines/asylum/views/scene.cpp
engines/asylum/views/scene.h
engines/asylum/views/scenetitle.cpp
engines/asylum/views/scenetitle.h
engines/asylum/views/video.cpp
engines/asylum/views/video.h
diff --git a/engines/asylum/asylum.cpp b/engines/asylum/asylum.cpp
index efaa86069b..4106302ff3 100644
--- a/engines/asylum/asylum.cpp
+++ b/engines/asylum/asylum.cpp
@@ -18,9 +18,6 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * $URL$
- * $Id$
- *
*/
#include "asylum/asylum.h"
diff --git a/engines/asylum/asylum.h b/engines/asylum/asylum.h
index b110fa57b2..72f3f4065e 100644
--- a/engines/asylum/asylum.h
+++ b/engines/asylum/asylum.h
@@ -18,9 +18,6 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * $URL$
- * $Id$
- *
*/
#ifndef ASYLUM_ENGINE_H
diff --git a/engines/asylum/console.cpp b/engines/asylum/console.cpp
index 8425ff5311..6983160494 100644
--- a/engines/asylum/console.cpp
+++ b/engines/asylum/console.cpp
@@ -18,9 +18,6 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * $URL$
- * $Id$
- *
*/
#include "asylum/console.h"
diff --git a/engines/asylum/console.h b/engines/asylum/console.h
index cd32d872ea..d20a1c10aa 100644
--- a/engines/asylum/console.h
+++ b/engines/asylum/console.h
@@ -18,9 +18,6 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * $URL$
- * $Id$
- *
*/
// Console module header file
diff --git a/engines/asylum/detection.cpp b/engines/asylum/detection.cpp
index b0ac4708c5..f8815815b4 100644
--- a/engines/asylum/detection.cpp
+++ b/engines/asylum/detection.cpp
@@ -18,9 +18,6 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * $URL$
- * $Id$
- *
*/
#include "common/config-manager.h"
diff --git a/engines/asylum/eventhandler.h b/engines/asylum/eventhandler.h
index ef0df99a8a..282949f026 100644
--- a/engines/asylum/eventhandler.h
+++ b/engines/asylum/eventhandler.h
@@ -18,9 +18,6 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * $URL$
- * $Id$
- *
*/
#ifndef ASYLUM_EVENTHANDLER_H
diff --git a/engines/asylum/puzzles/board.cpp b/engines/asylum/puzzles/board.cpp
index 58d8def419..608c77e9f4 100644
--- a/engines/asylum/puzzles/board.cpp
+++ b/engines/asylum/puzzles/board.cpp
@@ -18,9 +18,6 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
-* $URL$
-* $Id$
-*
*/
#include "asylum/puzzles/board.h"
diff --git a/engines/asylum/puzzles/board.h b/engines/asylum/puzzles/board.h
index 79c0d2f8f8..e4a28f1e0f 100644
--- a/engines/asylum/puzzles/board.h
+++ b/engines/asylum/puzzles/board.h
@@ -18,9 +18,6 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * $URL$
- * $Id$
- *
*/
#ifndef ASYLUM_BOARD_H
diff --git a/engines/asylum/puzzles/boardkeyhidesto.cpp b/engines/asylum/puzzles/boardkeyhidesto.cpp
index a34262b5b0..d4df7db57d 100644
--- a/engines/asylum/puzzles/boardkeyhidesto.cpp
+++ b/engines/asylum/puzzles/boardkeyhidesto.cpp
@@ -18,9 +18,6 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * $URL$
- * $Id$
- *
*/
#include "asylum/puzzles/boardkeyhidesto.h"
diff --git a/engines/asylum/puzzles/boardkeyhidesto.h b/engines/asylum/puzzles/boardkeyhidesto.h
index 0cc2b09062..202a5b6c60 100644
--- a/engines/asylum/puzzles/boardkeyhidesto.h
+++ b/engines/asylum/puzzles/boardkeyhidesto.h
@@ -18,9 +18,6 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * $URL$
- * $Id$
- *
*/
#ifndef ASYLUM_BOARDKEYHIDESTO_H
diff --git a/engines/asylum/puzzles/boardsalvation.cpp b/engines/asylum/puzzles/boardsalvation.cpp
index e642feccd3..72714c85f8 100644
--- a/engines/asylum/puzzles/boardsalvation.cpp
+++ b/engines/asylum/puzzles/boardsalvation.cpp
@@ -18,9 +18,6 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * $URL$
- * $Id$
- *
*/
#include "asylum/puzzles/boardsalvation.h"
diff --git a/engines/asylum/puzzles/boardsalvation.h b/engines/asylum/puzzles/boardsalvation.h
index 219e63f4e4..549ad5bc8b 100644
--- a/engines/asylum/puzzles/boardsalvation.h
+++ b/engines/asylum/puzzles/boardsalvation.h
@@ -18,9 +18,6 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * $URL$
- * $Id$
- *
*/
#ifndef ASYLUM_BOARDSALVATION_H
diff --git a/engines/asylum/puzzles/boardyouth.cpp b/engines/asylum/puzzles/boardyouth.cpp
index 48b19c828c..8ce5de53b8 100644
--- a/engines/asylum/puzzles/boardyouth.cpp
+++ b/engines/asylum/puzzles/boardyouth.cpp
@@ -18,9 +18,6 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * $URL$
- * $Id$
- *
*/
#include "asylum/puzzles/boardyouth.h"
diff --git a/engines/asylum/puzzles/boardyouth.h b/engines/asylum/puzzles/boardyouth.h
index 36c7f5a1e5..eb0e8f964b 100644
--- a/engines/asylum/puzzles/boardyouth.h
+++ b/engines/asylum/puzzles/boardyouth.h
@@ -18,9 +18,6 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * $URL$
- * $Id$
- *
*/
#ifndef ASYLUM_BOARDYOUTH_H
diff --git a/engines/asylum/puzzles/clock.cpp b/engines/asylum/puzzles/clock.cpp
index 231df7a6c5..5ff69c7c30 100644
--- a/engines/asylum/puzzles/clock.cpp
+++ b/engines/asylum/puzzles/clock.cpp
@@ -18,9 +18,6 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * $URL$
- * $Id$
- *
*/
#include "asylum/puzzles/clock.h"
diff --git a/engines/asylum/puzzles/clock.h b/engines/asylum/puzzles/clock.h
index 98968ae15e..18f68a0845 100644
--- a/engines/asylum/puzzles/clock.h
+++ b/engines/asylum/puzzles/clock.h
@@ -18,9 +18,6 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * $URL$
- * $Id$
- *
*/
#ifndef ASYLUM_CLOCK_H
diff --git a/engines/asylum/puzzles/data.h b/engines/asylum/puzzles/data.h
index 88b1c68fb9..5c06a90115 100644
--- a/engines/asylum/puzzles/data.h
+++ b/engines/asylum/puzzles/data.h
@@ -18,9 +18,6 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * $URL$
- * $Id$
- *
*/
#ifndef ASYLUM_PUZZLE_DATA_H
diff --git a/engines/asylum/puzzles/fisherman.cpp b/engines/asylum/puzzles/fisherman.cpp
index 13d11c06e9..18d12747b9 100644
--- a/engines/asylum/puzzles/fisherman.cpp
+++ b/engines/asylum/puzzles/fisherman.cpp
@@ -18,9 +18,6 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * $URL$
- * $Id$
- *
*/
#include "asylum/puzzles/fisherman.h"
diff --git a/engines/asylum/puzzles/fisherman.h b/engines/asylum/puzzles/fisherman.h
index 77155bbba1..87f49d099c 100644
--- a/engines/asylum/puzzles/fisherman.h
+++ b/engines/asylum/puzzles/fisherman.h
@@ -18,9 +18,6 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * $URL$
- * $Id$
- *
*/
#ifndef ASYLUM_FISHERMAN_H
diff --git a/engines/asylum/puzzles/hivecontrol.cpp b/engines/asylum/puzzles/hivecontrol.cpp
index 2ca63b6993..b9acac27b3 100644
--- a/engines/asylum/puzzles/hivecontrol.cpp
+++ b/engines/asylum/puzzles/hivecontrol.cpp
@@ -18,9 +18,6 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * $URL$
- * $Id$
- *
*/
#include "asylum/puzzles/hivecontrol.h"
diff --git a/engines/asylum/puzzles/hivecontrol.h b/engines/asylum/puzzles/hivecontrol.h
index ec8bb297ad..116f1e7eef 100644
--- a/engines/asylum/puzzles/hivecontrol.h
+++ b/engines/asylum/puzzles/hivecontrol.h
@@ -18,9 +18,6 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * $URL$
- * $Id$
- *
*/
#ifndef ASYLUM_HIVECONTROL_H
diff --git a/engines/asylum/puzzles/hivemachine.cpp b/engines/asylum/puzzles/hivemachine.cpp
index 449c8de92f..92289b550d 100644
--- a/engines/asylum/puzzles/hivemachine.cpp
+++ b/engines/asylum/puzzles/hivemachine.cpp
@@ -18,9 +18,6 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * $URL$
- * $Id$
- *
*/
#include "asylum/puzzles/hivemachine.h"
diff --git a/engines/asylum/puzzles/hivemachine.h b/engines/asylum/puzzles/hivemachine.h
index d42e3a5d7c..70f06d4f7b 100644
--- a/engines/asylum/puzzles/hivemachine.h
+++ b/engines/asylum/puzzles/hivemachine.h
@@ -18,9 +18,6 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * $URL$
- * $Id$
- *
*/
#ifndef ASYLUM_HIVEMACHINE_H
diff --git a/engines/asylum/puzzles/lock.cpp b/engines/asylum/puzzles/lock.cpp
index 274c68eabc..5d01b5dc5b 100644
--- a/engines/asylum/puzzles/lock.cpp
+++ b/engines/asylum/puzzles/lock.cpp
@@ -18,9 +18,6 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * $URL$
- * $Id$
- *
*/
#include "asylum/puzzles/lock.h"
diff --git a/engines/asylum/puzzles/lock.h b/engines/asylum/puzzles/lock.h
index 6419e68da1..073c3a7545 100644
--- a/engines/asylum/puzzles/lock.h
+++ b/engines/asylum/puzzles/lock.h
@@ -18,9 +18,6 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * $URL$
- * $Id$
- *
*/
#ifndef ASYLUM_LOCK_H
diff --git a/engines/asylum/puzzles/morguedoor.cpp b/engines/asylum/puzzles/morguedoor.cpp
index 43cbc8c1e4..b707296323 100644
--- a/engines/asylum/puzzles/morguedoor.cpp
+++ b/engines/asylum/puzzles/morguedoor.cpp
@@ -18,9 +18,6 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * $URL$
- * $Id$
- *
*/
#include "asylum/puzzles/morguedoor.h"
diff --git a/engines/asylum/puzzles/morguedoor.h b/engines/asylum/puzzles/morguedoor.h
index 2c83c5cfd4..3fccfbacb3 100644
--- a/engines/asylum/puzzles/morguedoor.h
+++ b/engines/asylum/puzzles/morguedoor.h
@@ -18,9 +18,6 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * $URL$
- * $Id$
- *
*/
#ifndef ASYLUM_MORGUEDOOR_H
diff --git a/engines/asylum/puzzles/puzzle.cpp b/engines/asylum/puzzles/puzzle.cpp
index 8e80d6bdd5..26233f5865 100644
--- a/engines/asylum/puzzles/puzzle.cpp
+++ b/engines/asylum/puzzles/puzzle.cpp
@@ -18,9 +18,6 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * $URL$
- * $Id$
- *
*/
#include "asylum/puzzles/puzzle.h"
diff --git a/engines/asylum/puzzles/puzzle.h b/engines/asylum/puzzles/puzzle.h
index a84d28c780..445881da11 100644
--- a/engines/asylum/puzzles/puzzle.h
+++ b/engines/asylum/puzzles/puzzle.h
@@ -18,9 +18,6 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * $URL$
- * $Id$
- *
*/
#ifndef ASYLUM_PUZZLE_H
diff --git a/engines/asylum/puzzles/puzzle11.cpp b/engines/asylum/puzzles/puzzle11.cpp
index 37bac7f5f7..4379bbb804 100644
--- a/engines/asylum/puzzles/puzzle11.cpp
+++ b/engines/asylum/puzzles/puzzle11.cpp
@@ -18,9 +18,6 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * $URL$
- * $Id$
- *
*/
#include "asylum/puzzles/puzzle11.h"
diff --git a/engines/asylum/puzzles/puzzle11.h b/engines/asylum/puzzles/puzzle11.h
index 972357dd6b..c916c4a47e 100644
--- a/engines/asylum/puzzles/puzzle11.h
+++ b/engines/asylum/puzzles/puzzle11.h
@@ -18,9 +18,6 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * $URL$
- * $Id$
- *
*/
#ifndef ASYLUM_PUZZLE11_H
diff --git a/engines/asylum/puzzles/tictactoe.cpp b/engines/asylum/puzzles/tictactoe.cpp
index f97a99d41a..4ce9c9a0c4 100644
--- a/engines/asylum/puzzles/tictactoe.cpp
+++ b/engines/asylum/puzzles/tictactoe.cpp
@@ -18,9 +18,6 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * $URL$
- * $Id$
- *
*/
#include "asylum/puzzles/tictactoe.h"
diff --git a/engines/asylum/puzzles/tictactoe.h b/engines/asylum/puzzles/tictactoe.h
index 65e1278ff4..ab57fef24c 100644
--- a/engines/asylum/puzzles/tictactoe.h
+++ b/engines/asylum/puzzles/tictactoe.h
@@ -18,9 +18,6 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * $URL$
- * $Id$
- *
*/
#ifndef ASYLUM_TICTACTOE_H
diff --git a/engines/asylum/puzzles/timemachine.cpp b/engines/asylum/puzzles/timemachine.cpp
index 40833f41e5..3619c338f7 100644
--- a/engines/asylum/puzzles/timemachine.cpp
+++ b/engines/asylum/puzzles/timemachine.cpp
@@ -18,9 +18,6 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * $URL$
- * $Id$
- *
*/
#include "asylum/puzzles/timemachine.h"
diff --git a/engines/asylum/puzzles/timemachine.h b/engines/asylum/puzzles/timemachine.h
index 1acf860f4c..fd0bda1028 100644
--- a/engines/asylum/puzzles/timemachine.h
+++ b/engines/asylum/puzzles/timemachine.h
@@ -18,9 +18,6 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * $URL$
- * $Id$
- *
*/
#ifndef ASYLUM_TIMEMACHINE_H
diff --git a/engines/asylum/puzzles/vcr.cpp b/engines/asylum/puzzles/vcr.cpp
index 67b8014dc9..4b85106a10 100644
--- a/engines/asylum/puzzles/vcr.cpp
+++ b/engines/asylum/puzzles/vcr.cpp
@@ -18,9 +18,6 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * $URL$
- * $Id$
- *
*/
#include "asylum/puzzles/vcr.h"
diff --git a/engines/asylum/puzzles/vcr.h b/engines/asylum/puzzles/vcr.h
index b6a29f6df4..e8356a00f9 100644
--- a/engines/asylum/puzzles/vcr.h
+++ b/engines/asylum/puzzles/vcr.h
@@ -18,9 +18,6 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * $URL$
- * $Id$
- *
*/
#ifndef ASYLUM_VCR_H
diff --git a/engines/asylum/puzzles/wheel.cpp b/engines/asylum/puzzles/wheel.cpp
index 9c558352e1..bd13453657 100644
--- a/engines/asylum/puzzles/wheel.cpp
+++ b/engines/asylum/puzzles/wheel.cpp
@@ -18,9 +18,6 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * $URL$
- * $Id$
- *
*/
#include "asylum/puzzles/wheel.h"
diff --git a/engines/asylum/puzzles/wheel.h b/engines/asylum/puzzles/wheel.h
index 4480980975..8a5f2815b0 100644
--- a/engines/asylum/puzzles/wheel.h
+++ b/engines/asylum/puzzles/wheel.h
@@ -18,9 +18,6 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * $URL$
- * $Id$
- *
*/
#ifndef ASYLUM_WHEEL_H
diff --git a/engines/asylum/puzzles/writings.cpp b/engines/asylum/puzzles/writings.cpp
index e9588b850b..748aa4b273 100644
--- a/engines/asylum/puzzles/writings.cpp
+++ b/engines/asylum/puzzles/writings.cpp
@@ -18,9 +18,6 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * $URL$
- * $Id$
- *
*/
#include "asylum/puzzles/writings.h"
diff --git a/engines/asylum/puzzles/writings.h b/engines/asylum/puzzles/writings.h
index 14fedd464e..cbd5f1a4a6 100644
--- a/engines/asylum/puzzles/writings.h
+++ b/engines/asylum/puzzles/writings.h
@@ -18,9 +18,6 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * $URL$
- * $Id$
- *
*/
#ifndef ASYLUM_WRITINGS_H
diff --git a/engines/asylum/resources/actor.cpp b/engines/asylum/resources/actor.cpp
index 4acce9de13..ecbe6f913e 100644
--- a/engines/asylum/resources/actor.cpp
+++ b/engines/asylum/resources/actor.cpp
@@ -18,9 +18,6 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * $URL$
- * $Id$
- *
*/
#include "asylum/resources/actor.h"
diff --git a/engines/asylum/resources/actor.h b/engines/asylum/resources/actor.h
index 3a70dec9c7..1906d05dec 100644
--- a/engines/asylum/resources/actor.h
+++ b/engines/asylum/resources/actor.h
@@ -18,9 +18,6 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * $URL$
- * $Id$
- *
*/
#ifndef ASYLUM_ACTOR_H
diff --git a/engines/asylum/resources/data.h b/engines/asylum/resources/data.h
index a2a1c18576..f6d885adc2 100644
--- a/engines/asylum/resources/data.h
+++ b/engines/asylum/resources/data.h
@@ -18,9 +18,6 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * $URL$
- * $Id$
- *
*/
#ifndef ASYLUM_DATA_H
diff --git a/engines/asylum/resources/encounters.cpp b/engines/asylum/resources/encounters.cpp
index 0ac87eb86e..3a595cfd46 100644
--- a/engines/asylum/resources/encounters.cpp
+++ b/engines/asylum/resources/encounters.cpp
@@ -18,9 +18,6 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * $URL$
- * $Id$
- *
*/
#include "asylum/resources/encounters.h"
diff --git a/engines/asylum/resources/encounters.h b/engines/asylum/resources/encounters.h
index 98243d5f05..5101ee754a 100644
--- a/engines/asylum/resources/encounters.h
+++ b/engines/asylum/resources/encounters.h
@@ -18,9 +18,6 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * $URL$
- * $Id$
- *
*/
#ifndef ASYLUM_ENCOUNTERS_H
@@ -238,7 +235,7 @@ private:
bool drawPortraits();
void drawStructs();
void drawDialog();
- void drawText(char *text, ResourceId font, int32 y);
+ void drawText(char *text, ResourceId font, int32 y);
//////////////////////////////////////////////////////////////////////////
// Misc
diff --git a/engines/asylum/resources/object.cpp b/engines/asylum/resources/object.cpp
index 0dae89d0fb..d11a918825 100644
--- a/engines/asylum/resources/object.cpp
+++ b/engines/asylum/resources/object.cpp
@@ -18,9 +18,6 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * $URL$
- * $Id$
- *
*/
#include "asylum/resources/object.h"
diff --git a/engines/asylum/resources/object.h b/engines/asylum/resources/object.h
index bb70fd1ec5..dc152e0f48 100644
--- a/engines/asylum/resources/object.h
+++ b/engines/asylum/resources/object.h
@@ -18,9 +18,6 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * $URL$
- * $Id$
- *
*/
#ifndef ASYLUM_OBJECT_H
diff --git a/engines/asylum/resources/polygons.cpp b/engines/asylum/resources/polygons.cpp
index a86c4fd392..2760f1a736 100644
--- a/engines/asylum/resources/polygons.cpp
+++ b/engines/asylum/resources/polygons.cpp
@@ -18,9 +18,6 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * $URL$
- * $Id$
- *
*/
#include "asylum/resources/polygons.h"
diff --git a/engines/asylum/resources/polygons.h b/engines/asylum/resources/polygons.h
index 55c029ea08..0e3d8f9fad 100644
--- a/engines/asylum/resources/polygons.h
+++ b/engines/asylum/resources/polygons.h
@@ -18,9 +18,6 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * $URL$
- * $Id$
- *
*/
#ifndef ASYLUM_POLYGONS_H
diff --git a/engines/asylum/resources/reaction.cpp b/engines/asylum/resources/reaction.cpp
index ac8cab83c8..c0de9f9d61 100644
--- a/engines/asylum/resources/reaction.cpp
+++ b/engines/asylum/resources/reaction.cpp
@@ -18,9 +18,6 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * $URL$
- * $Id$
- *
*/
#include "asylum/resources/reaction.h"
diff --git a/engines/asylum/resources/reaction.h b/engines/asylum/resources/reaction.h
index 778f51e0b2..cad7858df9 100644
--- a/engines/asylum/resources/reaction.h
+++ b/engines/asylum/resources/reaction.h
@@ -18,9 +18,6 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * $URL$
- * $Id$
- *
*/
#ifndef ASYLUM_REACTION_H
diff --git a/engines/asylum/resources/script.cpp b/engines/asylum/resources/script.cpp
index fce6c61079..2ba0962b31 100644
--- a/engines/asylum/resources/script.cpp
+++ b/engines/asylum/resources/script.cpp
@@ -18,9 +18,6 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * $URL$
- * $Id$
- *
*/
#include "asylum/resources/script.h"
diff --git a/engines/asylum/resources/script.h b/engines/asylum/resources/script.h
index d6e32a3c00..4dc52d2e73 100644
--- a/engines/asylum/resources/script.h
+++ b/engines/asylum/resources/script.h
@@ -18,9 +18,6 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * $URL$
- * $Id$
- *
*/
#ifndef ASYLUM_SCRIPT_H
diff --git a/engines/asylum/resources/special.cpp b/engines/asylum/resources/special.cpp
index f355117a97..25e1effe5c 100644
--- a/engines/asylum/resources/special.cpp
+++ b/engines/asylum/resources/special.cpp
@@ -18,9 +18,6 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * $URL$
- * $Id$
- *
*/
#include "asylum/resources/special.h"
diff --git a/engines/asylum/resources/special.h b/engines/asylum/resources/special.h
index fb23389f68..5f21a545bf 100644
--- a/engines/asylum/resources/special.h
+++ b/engines/asylum/resources/special.h
@@ -18,9 +18,6 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * $URL$
- * $Id$
- *
*/
#ifndef ASYLUM_SPECIAL_H
diff --git a/engines/asylum/resources/worldstats.cpp b/engines/asylum/resources/worldstats.cpp
index f0e761809d..da85a543ea 100644
--- a/engines/asylum/resources/worldstats.cpp
+++ b/engines/asylum/resources/worldstats.cpp
@@ -18,9 +18,6 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * $URL$
- * $Id$
- *
*/
#include "asylum/resources/worldstats.h"
diff --git a/engines/asylum/resources/worldstats.h b/engines/asylum/resources/worldstats.h
index ce430c83dd..7a1afa0870 100644
--- a/engines/asylum/resources/worldstats.h
+++ b/engines/asylum/resources/worldstats.h
@@ -18,9 +18,6 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * $URL$
- * $Id$
- *
*/
#ifndef ASYLUM_WORLDSTATS_H
diff --git a/engines/asylum/respack.cpp b/engines/asylum/respack.cpp
index 0876e294f5..633fdcf00d 100644
--- a/engines/asylum/respack.cpp
+++ b/engines/asylum/respack.cpp
@@ -18,9 +18,6 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * $URL$
- * $Id$
- *
*/
#include "asylum/respack.h"
diff --git a/engines/asylum/respack.h b/engines/asylum/respack.h
index daa44f7ffc..48d89eb0c7 100644
--- a/engines/asylum/respack.h
+++ b/engines/asylum/respack.h
@@ -18,9 +18,6 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * $URL$
- * $Id$
- *
*/
#ifndef ASYLUM_RESOURCEPACK_H
diff --git a/engines/asylum/shared.h b/engines/asylum/shared.h
index b7d79b6633..6476e6cdde 100644
--- a/engines/asylum/shared.h
+++ b/engines/asylum/shared.h
@@ -18,9 +18,6 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * $URL$
- * $Id$
- *
*/
#ifndef ASYLUM_SHARED_H
diff --git a/engines/asylum/staticres.h b/engines/asylum/staticres.h
index 30a3c34682..3eb1ac26f6 100644
--- a/engines/asylum/staticres.h
+++ b/engines/asylum/staticres.h
@@ -18,9 +18,6 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * $URL$
- * $Id$
- *
*/
#ifndef ASYLUM_STATICRES_H
diff --git a/engines/asylum/system/config.cpp b/engines/asylum/system/config.cpp
index 11b5d6b360..b99e7a184c 100644
--- a/engines/asylum/system/config.cpp
+++ b/engines/asylum/system/config.cpp
@@ -18,9 +18,6 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * $URL$
- * $Id$
- *
*/
#include "asylum/system/config.h"
diff --git a/engines/asylum/system/config.h b/engines/asylum/system/config.h
index f7090e56cd..092b6da370 100644
--- a/engines/asylum/system/config.h
+++ b/engines/asylum/system/config.h
@@ -18,9 +18,6 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * $URL$
- * $Id$
- *
*/
#ifndef ASYLUM_CONFIGURATIONMANAGER_H
diff --git a/engines/asylum/system/cursor.cpp b/engines/asylum/system/cursor.cpp
index e89cb27120..88e56618be 100644
--- a/engines/asylum/system/cursor.cpp
+++ b/engines/asylum/system/cursor.cpp
@@ -18,9 +18,6 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * $URL$
- * $Id$
- *
*/
#include "asylum/system/cursor.h"
diff --git a/engines/asylum/system/cursor.h b/engines/asylum/system/cursor.h
index 4a29f03959..f3ee0d460b 100644
--- a/engines/asylum/system/cursor.h
+++ b/engines/asylum/system/cursor.h
@@ -18,9 +18,6 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * $URL$
- * $Id$
- *
*/
#ifndef ASYLUM_CURSOR_H
diff --git a/engines/asylum/system/graphics.cpp b/engines/asylum/system/graphics.cpp
index 39968d567a..3df2110c9d 100644
--- a/engines/asylum/system/graphics.cpp
+++ b/engines/asylum/system/graphics.cpp
@@ -18,9 +18,6 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * $URL$
- * $Id$
- *
*/
#include "asylum/system/graphics.h"
diff --git a/engines/asylum/system/graphics.h b/engines/asylum/system/graphics.h
index 744d44c53b..abd894d132 100644
--- a/engines/asylum/system/graphics.h
+++ b/engines/asylum/system/graphics.h
@@ -18,9 +18,6 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * $URL$
- * $Id$
- *
*/
#ifndef ASYLUM_GRAPHICS_H
diff --git a/engines/asylum/system/savegame.cpp b/engines/asylum/system/savegame.cpp
index 20eae1ebb0..edebb0a635 100644
--- a/engines/asylum/system/savegame.cpp
+++ b/engines/asylum/system/savegame.cpp
@@ -18,9 +18,6 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * $URL$
- * $Id$
- *
*/
#include "asylum/system/savegame.h"
diff --git a/engines/asylum/system/savegame.h b/engines/asylum/system/savegame.h
index 43750d8827..bb26e98fd1 100644
--- a/engines/asylum/system/savegame.h
+++ b/engines/asylum/system/savegame.h
@@ -18,9 +18,6 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * $URL$
- * $Id$
- *
*/
#ifndef ASYLUM_SAVEGAME_H
diff --git a/engines/asylum/system/screen.cpp b/engines/asylum/system/screen.cpp
index c42044fb35..73da735c04 100644
--- a/engines/asylum/system/screen.cpp
+++ b/engines/asylum/system/screen.cpp
@@ -18,9 +18,6 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * $URL$
- * $Id$
- *
*/
#include "asylum/system/screen.h"
diff --git a/engines/asylum/system/screen.h b/engines/asylum/system/screen.h
index 73853ab155..80e0a06fe2 100644
--- a/engines/asylum/system/screen.h
+++ b/engines/asylum/system/screen.h
@@ -18,9 +18,6 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * $URL$
- * $Id$
- *
*/
#ifndef ASYLUM_SCREEN_H
diff --git a/engines/asylum/system/sound.cpp b/engines/asylum/system/sound.cpp
index ab47030e86..9ca2f4f22e 100644
--- a/engines/asylum/system/sound.cpp
+++ b/engines/asylum/system/sound.cpp
@@ -18,9 +18,6 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * $URL$
- * $Id$
- *
*/
diff --git a/engines/asylum/system/sound.h b/engines/asylum/system/sound.h
index 3f174f222d..be898a201e 100644
--- a/engines/asylum/system/sound.h
+++ b/engines/asylum/system/sound.h
@@ -18,9 +18,6 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * $URL$
- * $Id$
- *
*/
#ifndef ASYLUM_SOUND_H
diff --git a/engines/asylum/system/speech.cpp b/engines/asylum/system/speech.cpp
index 054480caca..d4d7e4ebad 100644
--- a/engines/asylum/system/speech.cpp
+++ b/engines/asylum/system/speech.cpp
@@ -18,9 +18,6 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * $URL$
- * $Id$
- *
*/
#include "asylum/system/speech.h"
diff --git a/engines/asylum/system/speech.h b/engines/asylum/system/speech.h
index 2065c688da..779ebfbe0a 100644
--- a/engines/asylum/system/speech.h
+++ b/engines/asylum/system/speech.h
@@ -18,9 +18,6 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * $URL$
- * $Id$
- *
*/
#ifndef ASYLUM_SPEECH_H
diff --git a/engines/asylum/system/text.cpp b/engines/asylum/system/text.cpp
index 0d19d04b8a..2efba27656 100644
--- a/engines/asylum/system/text.cpp
+++ b/engines/asylum/system/text.cpp
@@ -18,9 +18,6 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * $URL$
- * $Id$
- *
*/
#include "asylum/system/text.h"
diff --git a/engines/asylum/system/text.h b/engines/asylum/system/text.h
index 011d1d729c..52ed51be1a 100644
--- a/engines/asylum/system/text.h
+++ b/engines/asylum/system/text.h
@@ -18,9 +18,6 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * $URL$
- * $Id$
- *
*/
#ifndef ASYLUM_TEXT_H
diff --git a/engines/asylum/views/menu.cpp b/engines/asylum/views/menu.cpp
index 378be89995..76b64f54ff 100644
--- a/engines/asylum/views/menu.cpp
+++ b/engines/asylum/views/menu.cpp
@@ -18,9 +18,6 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * $URL$
- * $Id$
- *
*/
#include "asylum/views/menu.h"
diff --git a/engines/asylum/views/menu.h b/engines/asylum/views/menu.h
index 4e3d1d2677..1f862c3c4e 100644
--- a/engines/asylum/views/menu.h
+++ b/engines/asylum/views/menu.h
@@ -18,9 +18,6 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * $URL$
- * $Id$
- *
*/
#ifndef ASYLUM_MENU_H
@@ -190,9 +187,9 @@ private:
void adjustPerformance();
/**
- * Gets the chapter name.
+ * Gets the chapter name.
*
- * @return The chapter name.
+ * @return The chapter name.
*/
Common::String getChapterName();
diff --git a/engines/asylum/views/scene.cpp b/engines/asylum/views/scene.cpp
index 9521d38551..5cbc32867b 100644
--- a/engines/asylum/views/scene.cpp
+++ b/engines/asylum/views/scene.cpp
@@ -18,9 +18,6 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * $URL$
- * $Id$
- *
*/
#include "asylum/views/scene.h"
diff --git a/engines/asylum/views/scene.h b/engines/asylum/views/scene.h
index 4149a776a0..6c833a9773 100644
--- a/engines/asylum/views/scene.h
+++ b/engines/asylum/views/scene.h
@@ -18,9 +18,6 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * $URL$
- * $Id$
- *
*/
#ifndef ASYLUM_SCENE_H
diff --git a/engines/asylum/views/scenetitle.cpp b/engines/asylum/views/scenetitle.cpp
index c25afa8ad1..4733ada70e 100644
--- a/engines/asylum/views/scenetitle.cpp
+++ b/engines/asylum/views/scenetitle.cpp
@@ -18,9 +18,6 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * $URL$
- * $Id$
- *
*/
#include "asylum/views/scenetitle.h"
diff --git a/engines/asylum/views/scenetitle.h b/engines/asylum/views/scenetitle.h
index 9d8d2db0a9..705791d34f 100644
--- a/engines/asylum/views/scenetitle.h
+++ b/engines/asylum/views/scenetitle.h
@@ -18,9 +18,6 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * $URL$
- * $Id$
- *
*/
#ifndef ASYLUM_SCENETITLE_H
diff --git a/engines/asylum/views/video.cpp b/engines/asylum/views/video.cpp
index 4968f07208..bfed3b7ee5 100644
--- a/engines/asylum/views/video.cpp
+++ b/engines/asylum/views/video.cpp
@@ -18,9 +18,6 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * $URL$
- * $Id$
- *
*/
#include "asylum/views/video.h"
@@ -83,7 +80,7 @@ bool VideoPlayer::handleEvent(const AsylumEvent &evt) {
if (_subtitleIndex >= 0) {
char *text1 = getText()->get((ResourceId)_currentMovie);
-
+
int32 y = 10 * (44 - getText()->draw(0, 99, kTextCalculate, 10, 400, 20, 620, text1));
if (y <= 400)
y = 405;
@@ -94,7 +91,7 @@ bool VideoPlayer::handleEvent(const AsylumEvent &evt) {
--_subtitleCounter;
}
-
+
return true;
}
@@ -160,7 +157,7 @@ void VideoPlayer::play(Common::String filename, bool showSubtitles) {
if (_smkDecoder->needsUpdate()) {
const Graphics::Surface *frame = _smkDecoder->decodeNextFrame();
-
+
if (!frame)
continue;
@@ -171,7 +168,7 @@ void VideoPlayer::play(Common::String filename, bool showSubtitles) {
if (showSubtitles) {
int32 currentFrame = _smkDecoder->getCurFrame() + 1;
-
+
// Check for next frame
if (currentFrame > frameEnd) {
if (index < _subtitles.size()) {
@@ -181,16 +178,16 @@ void VideoPlayer::play(Common::String filename, bool showSubtitles) {
++index;
}
}
-
+
if (currentFrame < frameStart || currentFrame > frameEnd)
_vm->notify(EVENT_ASYLUM_SUBTITLE, 0, 0);
else
- _vm->notify(EVENT_ASYLUM_SUBTITLE, currentSubtitle, 1);
+ _vm->notify(EVENT_ASYLUM_SUBTITLE, currentSubtitle, 1);
}
getScreen()->copyBackBufferToScreen();
- g_system->updateScreen();
+ g_system->updateScreen();
}
g_system->delayMillis(10);
}
@@ -206,7 +203,7 @@ void VideoPlayer::setupPalette() {
//getScreen()->setupPalette(0, 0, 0);
}
-void VideoPlayer::loadSubtitles() {
+void VideoPlayer::loadSubtitles() {
char movieToken[10];
sprintf(movieToken, "[MOV%03d]", _currentMovie);
diff --git a/engines/asylum/views/video.h b/engines/asylum/views/video.h
index d1f048be23..8665084cb8 100644
--- a/engines/asylum/views/video.h
+++ b/engines/asylum/views/video.h
@@ -18,9 +18,6 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * $URL$
- * $Id$
- *
*/
#ifndef ASYLUM_VIDEO_H
Commit: a64de0c34be5f37de35cf5ea176eb45d3d8e0d32
https://github.com/scummvm/scummvm/commit/a64de0c34be5f37de35cf5ea176eb45d3d8e0d32
Author: Alex Bevilacqua (alexbevi at gmail.com)
Date: 2021-05-17T15:36:57+02:00
Commit Message:
ASYLUM: silence warnings about shadowed variable declarations
Changed paths:
engines/asylum/resources/actor.cpp
diff --git a/engines/asylum/resources/actor.cpp b/engines/asylum/resources/actor.cpp
index ecbe6f913e..2304011bc5 100644
--- a/engines/asylum/resources/actor.cpp
+++ b/engines/asylum/resources/actor.cpp
@@ -882,14 +882,14 @@ bool Actor::process(const Common::Point &point) {
}
if (point.x == sum.x) {
- ActorDirection direction = a3 >= 2 ? kDirectionS : kDirectionN;
- if (process_408B20(&sum, direction, abs(delta.y), false)) {
+ ActorDirection actorDir = a3 >= 2 ? kDirectionS : kDirectionN;
+ if (process_408B20(&sum, actorDir, abs(delta.y), false)) {
_data.field_8[0] = point.x;
_data.field_8[1] = point.y;
_data.field_4 = 0;
_data.count = 1;
- updateFromDirection(direction);
+ updateFromDirection(actorDir);
return true;
}
@@ -898,15 +898,15 @@ bool Actor::process(const Common::Point &point) {
}
if (point.y == sum.y) {
- ActorDirection direction = (a3 != 0 || a3 != 3) ? kDirectionE : kDirectionO;
+ ActorDirection actorDir = (a3 != 0 || a3 != 3) ? kDirectionE : kDirectionO;
- if (process_408B20(&sum, direction, abs(delta.x), true)) {
+ if (process_408B20(&sum, actorDir, abs(delta.x), true)) {
_data.field_8[0] = point.x;
_data.field_8[1] = point.y;
_data.field_4 = 0;
_data.count = 1;
- updateFromDirection(direction);
+ updateFromDirection(actorDir);
return true;
}
@@ -1046,25 +1046,25 @@ bool Actor::process(const Common::Point &point) {
// Last case: abs(delta.x) == abs(delta.y)
// Compute direction
- ActorDirection direction = kDirectionSO;
+ ActorDirection actorDir = kDirectionSO;
switch (a3) {
default:
break;
case 0:
- direction = kDirectionNO;
+ actorDir = kDirectionNO;
break;
case 1:
- direction = kDirectionNE;
+ actorDir = kDirectionNE;
break;
case 2:
- direction = kDirectionSE;
+ actorDir = kDirectionSE;
break;
}
- if (!process_408B20(&sum, direction, abs(delta.y), true))
+ if (!process_408B20(&sum, actorDir, abs(delta.y), true))
return false;
// Update actor data
@@ -1074,7 +1074,7 @@ bool Actor::process(const Common::Point &point) {
_data.count = 1;
// Update actor from direction
- updateFromDirection(direction);
+ updateFromDirection(actorDir);
return true;
}
@@ -1246,7 +1246,7 @@ bool Actor::process_408B20(Common::Point *point, ActorDirection dir, uint32 coun
return true;
}
-void Actor::playSounds(ActorDirection direction, uint32 distance) {
+void Actor::playSounds(ActorDirection actorDir, uint32 dist) {
_lastScreenUpdate = _vm->screenUpdateCount;
Common::Point sum(_point1.x + _point2.x, _point1.x + _point2.x);
@@ -1260,7 +1260,7 @@ void Actor::playSounds(ActorDirection direction, uint32 distance) {
case kActorStatus2:
case kActorStatus12:
case kActorStatus13:
- updateCoordinatesForDirection(direction, distance, &_point1);
+ updateCoordinatesForDirection(actorDir, dist, &_point1);
_frameIndex = (++_frameIndex) % _frameCount;
@@ -1298,7 +1298,7 @@ void Actor::playSounds(ActorDirection direction, uint32 distance) {
case kActorStatus18:
if (getWorld()->chapter == kChapter2) {
- updateCoordinatesForDirection(direction, distance, &_point1);
+ updateCoordinatesForDirection(actorDir, dist, &_point1);
if (_walkingSound1 == kResourceNone)
break;
@@ -2382,9 +2382,9 @@ bool Actor::checkAllActions(const Common::Point &pt, Common::Array<ActionArea *>
}
bool Actor::isInActionArea(const Common::Point &pt, ActionArea *area) {
- Common::Rect rect = getWorld()->sceneRects[getWorld()->sceneRectIdx];
+ Common::Rect sceneRect = getWorld()->sceneRects[getWorld()->sceneRectIdx];
- if (!rect.contains(pt))
+ if (!sceneRect.contains(pt))
return false;
if (area->flags & 1)
Commit: b3a4c7fc9f8d483318598a3e38e07f5c9baf2f6a
https://github.com/scummvm/scummvm/commit/b3a4c7fc9f8d483318598a3e38e07f5c9baf2f6a
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:57+02:00
Commit Message:
ASYLUM: Fix mirrored blit
Changed paths:
engines/asylum/system/screen.cpp
diff --git a/engines/asylum/system/screen.cpp b/engines/asylum/system/screen.cpp
index 73da735c04..792e73f573 100644
--- a/engines/asylum/system/screen.cpp
+++ b/engines/asylum/system/screen.cpp
@@ -484,9 +484,10 @@ void Screen::copyToBackBufferWithTransparency(byte *buffer, int32 pitch, int32 x
for (int32 curY = top; curY < bottom; curY++) {
for (int32 curX = left; curX < right; curX++) {
- if (buffer[curX + curY * pitch] != 0 ) {
- dest[x + curX + (y + curY) * 640] = buffer[(mirrored ? right - curX : curX) + curY * pitch];
- }
+ uint32 offset = (mirrored ? right - curX - 1 : curX) + curY * pitch;
+
+ if (buffer[offset] != 0 )
+ dest[x + curX + (y + curY) * 640] = buffer[offset];
}
}
}
Commit: 4cb90f40236a1fd41bc6278d87e605e54e39c46a
https://github.com/scummvm/scummvm/commit/4cb90f40236a1fd41bc6278d87e605e54e39c46a
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:57+02:00
Commit Message:
ASYLUM: Fix Scene::rectIntersect() and cleanup part of Scene::processUpdateList()
Changed paths:
engines/asylum/views/scene.cpp
diff --git a/engines/asylum/views/scene.cpp b/engines/asylum/views/scene.cpp
index 5cbc32867b..af3568ea34 100644
--- a/engines/asylum/views/scene.cpp
+++ b/engines/asylum/views/scene.cpp
@@ -2032,7 +2032,7 @@ bool Scene::pointIntersectsRect(Common::Point point, Common::Rect rect) {
}
bool Scene::rectIntersect(int32 x, int32 y, int32 x1, int32 y1, int32 x2, int32 y2, int32 x3, int32 y3) {
- return (x >= x3 && y >= y3 && x1 >= x2 && y1 >= y2);
+ return (x <= x3 && x1 >= x2) && (y <= y3 && y1 >= y2);
}
void Scene::adjustCoordinates(Common::Point *point) {
@@ -2434,10 +2434,9 @@ void Scene::processUpdateList() {
} else {
actor->setField938(1);
actor->setField934(0);
- point.x = actor->getPoint1()->x + actor->getPoint2()->x;
- point.y = actor->getPoint1()->y + actor->getPoint2()->y;
+ point = *actor->getPoint1() + *actor->getPoint2();
- int32 bottomRight = actor->getBoundingRect()->bottom + actor->getPoint1()->y + 4;
+ int32 bottomRight = actor->getPoint1()->y + actor->getBoundingRect()->bottom + 4;
if (_ws->chapter == kChapter11 && _updateList[i].index != getPlayerIndex())
bottomRight += 20;
@@ -2456,9 +2455,9 @@ void Scene::processUpdateList() {
// Check that the rects are contained
if (!rectIntersect(object->x, object->y, object->x + object->getBoundingRect()->right, object->y + object->getBoundingRect()->bottom,
actor->getPoint1()->x, actor->getPoint1()->y, actor->getPoint1()->x + actor->getBoundingRect()->right, bottomRight)) {
- if (BYTE1(object->flags) & kObjectFlag20)
- if (!(BYTE1(object->flags) & kObjectFlag80))
- object->flags = BYTE1(object->flags) | kObjectFlag40;
+
+ if (BYTE1(object->flags) & kObjectFlag20 && !(BYTE1(object->flags) & kObjectFlag80))
+ object->flags = BYTE1(object->flags) | kObjectFlag40;
continue;
}
@@ -2475,21 +2474,20 @@ void Scene::processUpdateList() {
// Adjust object flags
if (BYTE1(object->flags) & kObjectFlag80 || notIntersects) {
if (BYTE1(object->flags) & kObjectFlag20)
- object->flags = (BYTE1(object->flags) & kObjectFlagBF) | kObjectFlag80;
+ object->flags = BYTE1(object->flags) & kObjectFlagBF | kObjectFlag80;
} else {
if (BYTE1(object->flags) & kObjectFlag20) {
object->flags = BYTE1(object->flags) | kObjectFlag40;
}
}
- if (object->flags & kObjectFlag4) {
- if (notIntersects && LOBYTE(actor->flags) & kActorFlagMasked) {
+ if (LOBYTE(object->flags) & kObjectFlag4) {
+ if (notIntersects && (actor->flags & kActorFlagMasked))
error("[Scene::processUpdateList] Assigning mask to masked character (%s)", actor->getName());
- } else {
- object->adjustCoordinates(&point);
- actor->setObjectIndex(j);
- actor->flags |= kActorFlagMasked;
- }
+
+ object->adjustCoordinates(&point);
+ actor->setObjectIndex(j);
+ actor->flags |= kActorFlagMasked;
} else {
if (notIntersects) {
if (actor->getPriority() < object->getPriority()) {
Commit: 958b7f10414b2ebb54edcade59179daef99972eb
https://github.com/scummvm/scummvm/commit/958b7f10414b2ebb54edcade59179daef99972eb
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:57+02:00
Commit Message:
ASYLUM: Fix GCC warning on undefined operation in Actor::playSounds()
Reported by: eriktorbjorn
Changed paths:
engines/asylum/resources/actor.cpp
diff --git a/engines/asylum/resources/actor.cpp b/engines/asylum/resources/actor.cpp
index 2304011bc5..fc7b6f4824 100644
--- a/engines/asylum/resources/actor.cpp
+++ b/engines/asylum/resources/actor.cpp
@@ -1262,7 +1262,7 @@ void Actor::playSounds(ActorDirection actorDir, uint32 dist) {
case kActorStatus13:
updateCoordinatesForDirection(actorDir, dist, &_point1);
- _frameIndex = (++_frameIndex) % _frameCount;
+ _frameIndex = (_frameIndex + 1) % _frameCount;
if (_walkingSound1 != kResourceNone) {
Commit: e212e20a6b3c679e94f59ae5ed8df614bcc7cab0
https://github.com/scummvm/scummvm/commit/e212e20a6b3c679e94f59ae5ed8df614bcc7cab0
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:57+02:00
Commit Message:
ASYLUM: Fix ResourceEntry::getData()
Changed paths:
engines/asylum/resources/object.cpp
engines/asylum/respack.cpp
engines/asylum/respack.h
diff --git a/engines/asylum/resources/object.cpp b/engines/asylum/resources/object.cpp
index d11a918825..6656d0f78f 100644
--- a/engines/asylum/resources/object.cpp
+++ b/engines/asylum/resources/object.cpp
@@ -367,7 +367,7 @@ void Object::playSounds() {
// Get object resource
ResourceEntry *resource = getResource()->get(_resourceId);
- point.x = x + Common::Rational(resource->getData(1), 2).toInt();
+ point.x = x + Common::Rational(resource->getData(4), 2).toInt();
point.y = y + Common::Rational(resource->getData(0), 2).toInt();
} else {
Common::Rect rect = GraphicResource::getFrameRect(_vm, _resourceId, _frameIndex);
diff --git a/engines/asylum/respack.cpp b/engines/asylum/respack.cpp
index 633fdcf00d..84a9282799 100644
--- a/engines/asylum/respack.cpp
+++ b/engines/asylum/respack.cpp
@@ -107,7 +107,7 @@ void ResourcePack::init(Common::String filename) {
// Read the offset of the next entry to determine the size of this one
nextOffset = (i < entryCount - 1) ? _packFile.readUint32LE() : (uint32)_packFile.size();
entry.size = (nextOffset > 0) ? nextOffset - prevOffset : (uint32)_packFile.size() - prevOffset;
- entry.data = 0;
+ entry.data = NULL;
_resources[i] = entry;
diff --git a/engines/asylum/respack.h b/engines/asylum/respack.h
index 48d89eb0c7..50b885974b 100644
--- a/engines/asylum/respack.h
+++ b/engines/asylum/respack.h
@@ -45,7 +45,10 @@ struct ResourceEntry {
}
uint32 getData(uint32 off) {
- return READ_UINT32((byte *)this + off);
+ if (data == NULL)
+ error("[ResourceEntry::getData] Invalid data");
+
+ return READ_UINT32(data + off);
}
};
Commit: 3ddd300f10ffea5e40a3bd31e621a6f95de7dedd
https://github.com/scummvm/scummvm/commit/3ddd300f10ffea5e40a3bd31e621a6f95de7dedd
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:57+02:00
Commit Message:
ASYLUM: Update Screen::draw() with mask source and destination rectangles calculation and add stub for Screen::blitMasked()
Changed paths:
engines/asylum/system/screen.cpp
engines/asylum/system/screen.h
diff --git a/engines/asylum/system/screen.cpp b/engines/asylum/system/screen.cpp
index 792e73f573..fb8074f4d2 100644
--- a/engines/asylum/system/screen.cpp
+++ b/engines/asylum/system/screen.cpp
@@ -76,13 +76,15 @@ void Screen::draw(ResourceId resourceId, uint32 frameIndex, const Common::Point
// Get the frame to draw
GraphicResource *resource = new GraphicResource(_vm, resourceId);
GraphicFrame *frame = resource->getFrame(frameIndex);
+ ResourceEntry *resourceMask = NULL;
// Compute coordinates
Common::Rect src;
Common::Rect dest;
- dest.left = source.x + frame->x;
+ Common::Rect srcMask;
+ Common::Rect destMask;
- // FIXME destination is never used
+ dest.left = source.x + frame->x;
if (flags & kDrawFlagMirrorLeftRight) {
if (_flag == -1) {
if ((resource->getData().flags & 15) >= 2) {
@@ -108,19 +110,32 @@ void Screen::draw(ResourceId resourceId, uint32 frameIndex, const Common::Point
if (resourceIdDestination) {
masked = true;
- error("[Screen::draw] Not implemented (masked)!");
- }
+ // Get the resource to use as a mask
+ resourceMask = getResource()->get(resourceIdDestination);
- if (masked) {
- error("[Screen::draw] Not implemented!");
+ // Adjust masked rectangles
+ srcMask = Common::Rect(0, 0, resourceMask->getData(0), resourceMask->getData(4));
- return;
+ destMask = Common::Rect(destination.y,
+ destination.x,
+ destination.y + resourceMask->getData(0),
+ destination.x + resourceMask->getData(4));
+
+ clip(&srcMask, &destMask, 0);
+
+ if (dest.intersects(destMask))
+ masked = false;
}
// Set the color key (always 0 if set)
_useColorKey = colorKey;
- blit(frame, &src, &dest, flags, colorKey);
+ if (masked) {
+ blitMasked(frame, &src, resourceMask->data + 8, &srcMask, &destMask, resourceMask->getData(4), &dest, flags);
+ } else {
+ // Normal blit
+ blit(frame, &src, &dest, flags, colorKey);
+ }
delete resource;
}
@@ -419,6 +434,11 @@ void Screen::blit(GraphicFrame *frame, Common::Rect *source, Common::Rect *desti
}
}
+void Screen::blitMasked(GraphicFrame *frame, Common::Rect *source, byte *maskData, Common::Rect *sourceMask, Common::Rect *destMask, int maskHeight, Common::Rect *destination, int32 flags) {
+ // TODO
+ blit(frame, source, destination, flags, _useColorKey);
+}
+
void Screen::blt(Common::Rect *dest, GraphicFrame* frame, Common::Rect *source, int32 flags, bool useColorKey) {
// TODO adjust destination rect
if (useColorKey) {
@@ -470,7 +490,7 @@ void Screen::copyToBackBuffer(byte *buffer, int32 pitch, int32 x, int32 y, uint3
buffer += pitch;
}
} else {
- error("[Screen::copyToBackBuffer] Mirrored drawing not implemented");
+ warning("[Screen::copyToBackBuffer] Mirrored drawing not implemented");
}
}
diff --git a/engines/asylum/system/screen.h b/engines/asylum/system/screen.h
index 80e0a06fe2..09dd0ffe9d 100644
--- a/engines/asylum/system/screen.h
+++ b/engines/asylum/system/screen.h
@@ -152,6 +152,7 @@ private:
// Screen blitting
void blit(GraphicFrame *frame, Common::Rect *source, Common::Rect *destination, int32 flags, bool useColorKey);
+ void blitMasked(GraphicFrame *frame, Common::Rect *source, byte *maskData, Common::Rect *sourceMask, Common::Rect *destMask, int maskHeight, Common::Rect *destination, int32 flags);
void blt(Common::Rect *dest, GraphicFrame* frame, Common::Rect *source, int32 flags, bool useColorKey);
void bltFast(int32 dX, int32 dY, GraphicFrame* frame, Common::Rect *source, int32 flags, bool useColorKey);
Commit: b9eb9f91ec72f05dbc5666f0c35712109174ed4a
https://github.com/scummvm/scummvm/commit/b9eb9f91ec72f05dbc5666f0c35712109174ed4a
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:58+02:00
Commit Message:
ASYLUM: Screen::blitFast() does not need flags
Changed paths:
engines/asylum/system/screen.cpp
engines/asylum/system/screen.h
diff --git a/engines/asylum/system/screen.cpp b/engines/asylum/system/screen.cpp
index fb8074f4d2..791736ad8b 100644
--- a/engines/asylum/system/screen.cpp
+++ b/engines/asylum/system/screen.cpp
@@ -430,7 +430,7 @@ void Screen::blit(GraphicFrame *frame, Common::Rect *source, Common::Rect *desti
} else if (flags) {
blt(destination, frame, source, flags, useColorKey);
} else {
- bltFast(destination->left, destination->top, frame, source, flags, useColorKey);
+ bltFast(destination->left, destination->top, frame, source, useColorKey);
}
}
@@ -460,7 +460,7 @@ void Screen::blt(Common::Rect *dest, GraphicFrame* frame, Common::Rect *source,
}
}
-void Screen::bltFast(int32 dX, int32 dY, GraphicFrame* frame, Common::Rect *source, int32 flags, bool useColorKey) {
+void Screen::bltFast(int32 dX, int32 dY, GraphicFrame* frame, Common::Rect *source, bool useColorKey) {
if (useColorKey) {
copyToBackBufferWithTransparency((byte *)frame->surface.pixels + (source->top * frame->surface.w + source->left),
frame->surface.w,
@@ -468,7 +468,7 @@ void Screen::bltFast(int32 dX, int32 dY, GraphicFrame* frame, Common::Rect *sour
dY,
source->width(),
source->height(),
- flags & kDrawFlagMirrorLeftRight);
+ kDrawFlagNone);
} else {
copyToBackBuffer((byte *)frame->surface.pixels + (source->top * frame->surface.w + source->left),
frame->surface.w,
@@ -476,7 +476,7 @@ void Screen::bltFast(int32 dX, int32 dY, GraphicFrame* frame, Common::Rect *sour
dY,
source->width(),
source->height(),
- flags & kDrawFlagMirrorLeftRight);
+ kDrawFlagNone);
}
}
diff --git a/engines/asylum/system/screen.h b/engines/asylum/system/screen.h
index 09dd0ffe9d..b7f61b5ad7 100644
--- a/engines/asylum/system/screen.h
+++ b/engines/asylum/system/screen.h
@@ -154,7 +154,7 @@ private:
void blit(GraphicFrame *frame, Common::Rect *source, Common::Rect *destination, int32 flags, bool useColorKey);
void blitMasked(GraphicFrame *frame, Common::Rect *source, byte *maskData, Common::Rect *sourceMask, Common::Rect *destMask, int maskHeight, Common::Rect *destination, int32 flags);
void blt(Common::Rect *dest, GraphicFrame* frame, Common::Rect *source, int32 flags, bool useColorKey);
- void bltFast(int32 dX, int32 dY, GraphicFrame* frame, Common::Rect *source, int32 flags, bool useColorKey);
+ void bltFast(int32 dX, int32 dY, GraphicFrame* frame, Common::Rect *source, bool useColorKey);
void copyToBackBufferWithTransparency(byte *buffer, int32 pitch, int32 x, int32 y, int32 width, int32 height, bool mirrored = false);
};
Commit: ee89b3837a11ae7579d2c9b3ab7ff30893b4b32f
https://github.com/scummvm/scummvm/commit/ee89b3837a11ae7579d2c9b3ab7ff30893b4b32f
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:58+02:00
Commit Message:
ASYLUM: Implement Screen::addGraphicToQueueCrossfade() and add stub for Screen::blitCrossfade()
Changed paths:
engines/asylum/system/screen.cpp
engines/asylum/system/screen.h
diff --git a/engines/asylum/system/screen.cpp b/engines/asylum/system/screen.cpp
index 791736ad8b..933d7da5a6 100644
--- a/engines/asylum/system/screen.cpp
+++ b/engines/asylum/system/screen.cpp
@@ -127,7 +127,7 @@ void Screen::draw(ResourceId resourceId, uint32 frameIndex, const Common::Point
masked = false;
}
- // Set the color key (always 0 if set)
+ // Set the color key
_useColorKey = colorKey;
if (masked) {
@@ -198,6 +198,13 @@ void Screen::clip(Common::Rect *source, Common::Rect *destination, int32 flags)
source->bottom -= diffBottom;
destination->bottom -= diffBottom;
}
+
+ // Check validity
+ if (!source->isValidRect())
+ error("[Screen::clip] Invalid resulting source rectangle");
+
+ if (!destination->isValidRect())
+ error("[Screen::clip] Invalid resulting destination rectangle");
}
void Screen::takeScreenshot() {
@@ -361,7 +368,40 @@ void Screen::addGraphicToQueueMasked(ResourceId resourceId, uint32 frameIndex, c
}
void Screen::addGraphicToQueueCrossfade(ResourceId resourceId, uint32 frameIndex, Common::Point point, int32 objectResourceId, Common::Point objectPoint, int32 transTableNum) {
- error("[Screen::addGraphicToQueueCrossfade] not implemented");
+ // Save current transparency index
+ byte *transparencyIndex= _transTableIndex;
+ selectTransTable(transTableNum);
+
+ // Get graphic frames
+ GraphicResource *resource = new GraphicResource(_vm, resourceId);
+ GraphicFrame *frame = resource->getFrame(frameIndex);
+
+ GraphicResource *resourceObject = new GraphicResource(_vm, objectResourceId);
+ GraphicFrame *frameObject = resourceObject->getFrame(0);
+
+ // Compute rectangles
+ Common::Rect src(0, 0, frame->getWidth(), frame->getHeight());
+ Common::Rect dst = src;
+ dst.translate(point.x + frame->x, point.y + frame->y);
+
+ clip(&src, &dst, 0);
+
+ // Set the color key (always 0)
+ _useColorKey = true;
+
+ blitCrossfade((byte *)_backBuffer.pixels + dst.top * _backBuffer.pitch + dst.left,
+ (byte *)frame->surface.pixels + src.top * frame->surface.pitch + src.left,
+ (byte *)frameObject->surface.pixels + (objectPoint.y + dst.top) * frameObject->surface.pitch + (dst.left + objectPoint.x),
+ dst.width() + (dst.height() << 16),
+ frame->surface.pitch - dst.width(),
+ _backBuffer.pitch - dst.width(),
+ frameObject->surface.pitch - dst.width());
+
+ // Restore transparency table
+ _transTableIndex = transparencyIndex;
+
+ delete resource;
+ delete resourceObject;
}
void Screen::addGraphicToQueue(GraphicQueueItem const &item) {
@@ -369,7 +409,7 @@ void Screen::addGraphicToQueue(GraphicQueueItem const &item) {
}
void Screen::drawGraphicsInQueue() {
- // sort by priority first
+ // Sort by priority first
graphicsSelectionSort();
for (Common::Array<GraphicQueueItem>::const_iterator i = _queueItems.begin(); i != _queueItems.end(); i++) {
@@ -426,6 +466,7 @@ void Screen::deleteGraphicFromQueue(ResourceId resourceId) {
//////////////////////////////////////////////////////////////////////////
void Screen::blit(GraphicFrame *frame, Common::Rect *source, Common::Rect *destination, int32 flags, bool useColorKey) {
if (flags & 0x80000000) {
+ // Used when closing from the menu (and more?)
error("[Screen::blit] not implemented");
} else if (flags) {
blt(destination, frame, source, flags, useColorKey);
@@ -439,8 +480,11 @@ void Screen::blitMasked(GraphicFrame *frame, Common::Rect *source, byte *maskDat
blit(frame, source, destination, flags, _useColorKey);
}
+void Screen::blitCrossfade(byte *dstBuffer, byte *srcBuffer, byte *objectBuffer, int widthHeight, uint32 srcPitch, uint32 dstPitch, uint32 objectPitch) {
+ error("[Screen::blitCrossfade] Not implemented");
+}
+
void Screen::blt(Common::Rect *dest, GraphicFrame* frame, Common::Rect *source, int32 flags, bool useColorKey) {
- // TODO adjust destination rect
if (useColorKey) {
copyToBackBufferWithTransparency((byte *)frame->surface.pixels + (source->top * frame->surface.w + source->left),
frame->surface.w,
@@ -490,7 +534,7 @@ void Screen::copyToBackBuffer(byte *buffer, int32 pitch, int32 x, int32 y, uint3
buffer += pitch;
}
} else {
- warning("[Screen::copyToBackBuffer] Mirrored drawing not implemented");
+ error("[Screen::copyToBackBuffer] Mirrored drawing not implemented (no color key)");
}
}
diff --git a/engines/asylum/system/screen.h b/engines/asylum/system/screen.h
index b7f61b5ad7..4e2b1c1b5c 100644
--- a/engines/asylum/system/screen.h
+++ b/engines/asylum/system/screen.h
@@ -153,6 +153,7 @@ private:
// Screen blitting
void blit(GraphicFrame *frame, Common::Rect *source, Common::Rect *destination, int32 flags, bool useColorKey);
void blitMasked(GraphicFrame *frame, Common::Rect *source, byte *maskData, Common::Rect *sourceMask, Common::Rect *destMask, int maskHeight, Common::Rect *destination, int32 flags);
+ void blitCrossfade(byte *dstBuffer, byte *srcBuffer, byte *objectBuffer, int widthHeight, uint32 srcPitch, uint32 dstPitch, uint32 objectPitch);
void blt(Common::Rect *dest, GraphicFrame* frame, Common::Rect *source, int32 flags, bool useColorKey);
void bltFast(int32 dX, int32 dY, GraphicFrame* frame, Common::Rect *source, bool useColorKey);
Commit: c92061336332941be8cb1327ad3dc3f1981b9428
https://github.com/scummvm/scummvm/commit/c92061336332941be8cb1327ad3dc3f1981b9428
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:58+02:00
Commit Message:
ASYLUM: Remove colorkey parameter to blt* functions and use _useColorKey member instead
Changed paths:
engines/asylum/system/screen.cpp
engines/asylum/system/screen.h
diff --git a/engines/asylum/system/screen.cpp b/engines/asylum/system/screen.cpp
index 933d7da5a6..dc8de31c3a 100644
--- a/engines/asylum/system/screen.cpp
+++ b/engines/asylum/system/screen.cpp
@@ -127,15 +127,13 @@ void Screen::draw(ResourceId resourceId, uint32 frameIndex, const Common::Point
masked = false;
}
- // Set the color key
+ // Set the color key (always 0 if set)
_useColorKey = colorKey;
- if (masked) {
+ if (masked)
blitMasked(frame, &src, resourceMask->data + 8, &srcMask, &destMask, resourceMask->getData(4), &dest, flags);
- } else {
- // Normal blit
- blit(frame, &src, &dest, flags, colorKey);
- }
+ else
+ blit(frame, &src, &dest, flags);
delete resource;
}
@@ -464,28 +462,28 @@ void Screen::deleteGraphicFromQueue(ResourceId resourceId) {
//////////////////////////////////////////////////////////////////////////
// Graphic Data
//////////////////////////////////////////////////////////////////////////
-void Screen::blit(GraphicFrame *frame, Common::Rect *source, Common::Rect *destination, int32 flags, bool useColorKey) {
+void Screen::blit(GraphicFrame *frame, Common::Rect *source, Common::Rect *destination, int32 flags) {
if (flags & 0x80000000) {
// Used when closing from the menu (and more?)
error("[Screen::blit] not implemented");
} else if (flags) {
- blt(destination, frame, source, flags, useColorKey);
+ blt(destination, frame, source, flags);
} else {
- bltFast(destination->left, destination->top, frame, source, useColorKey);
+ bltFast(destination->left, destination->top, frame, source);
}
}
void Screen::blitMasked(GraphicFrame *frame, Common::Rect *source, byte *maskData, Common::Rect *sourceMask, Common::Rect *destMask, int maskHeight, Common::Rect *destination, int32 flags) {
// TODO
- blit(frame, source, destination, flags, _useColorKey);
+ blit(frame, source, destination, flags);
}
void Screen::blitCrossfade(byte *dstBuffer, byte *srcBuffer, byte *objectBuffer, int widthHeight, uint32 srcPitch, uint32 dstPitch, uint32 objectPitch) {
error("[Screen::blitCrossfade] Not implemented");
}
-void Screen::blt(Common::Rect *dest, GraphicFrame* frame, Common::Rect *source, int32 flags, bool useColorKey) {
- if (useColorKey) {
+void Screen::blt(Common::Rect *dest, GraphicFrame* frame, Common::Rect *source, int32 flags) {
+ if (_useColorKey) {
copyToBackBufferWithTransparency((byte *)frame->surface.pixels + (source->top * frame->surface.w + source->left),
frame->surface.w,
dest->left,
@@ -504,8 +502,8 @@ void Screen::blt(Common::Rect *dest, GraphicFrame* frame, Common::Rect *source,
}
}
-void Screen::bltFast(int32 dX, int32 dY, GraphicFrame* frame, Common::Rect *source, bool useColorKey) {
- if (useColorKey) {
+void Screen::bltFast(int32 dX, int32 dY, GraphicFrame* frame, Common::Rect *source) {
+ if (_useColorKey) {
copyToBackBufferWithTransparency((byte *)frame->surface.pixels + (source->top * frame->surface.w + source->left),
frame->surface.w,
dX,
diff --git a/engines/asylum/system/screen.h b/engines/asylum/system/screen.h
index 4e2b1c1b5c..cb7a2bf89e 100644
--- a/engines/asylum/system/screen.h
+++ b/engines/asylum/system/screen.h
@@ -151,11 +151,11 @@ private:
void clip(Common::Rect *source, Common::Rect *destination, int32 flags);
// Screen blitting
- void blit(GraphicFrame *frame, Common::Rect *source, Common::Rect *destination, int32 flags, bool useColorKey);
+ void blit(GraphicFrame *frame, Common::Rect *source, Common::Rect *destination, int32 flags);
void blitMasked(GraphicFrame *frame, Common::Rect *source, byte *maskData, Common::Rect *sourceMask, Common::Rect *destMask, int maskHeight, Common::Rect *destination, int32 flags);
void blitCrossfade(byte *dstBuffer, byte *srcBuffer, byte *objectBuffer, int widthHeight, uint32 srcPitch, uint32 dstPitch, uint32 objectPitch);
- void blt(Common::Rect *dest, GraphicFrame* frame, Common::Rect *source, int32 flags, bool useColorKey);
- void bltFast(int32 dX, int32 dY, GraphicFrame* frame, Common::Rect *source, bool useColorKey);
+ void blt(Common::Rect *dest, GraphicFrame* frame, Common::Rect *source, int32 flags);
+ void bltFast(int32 dX, int32 dY, GraphicFrame* frame, Common::Rect *source);
void copyToBackBufferWithTransparency(byte *buffer, int32 pitch, int32 x, int32 y, int32 width, int32 height, bool mirrored = false);
};
Commit: 4325184d2ab8807fcb8ce91aedb75344543cb03d
https://github.com/scummvm/scummvm/commit/4325184d2ab8807fcb8ce91aedb75344543cb03d
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:58+02:00
Commit Message:
ASYLUM: Implement the rest of Screen::blit() and add stubs for all the helper blit functions
Changed paths:
engines/asylum/system/screen.cpp
engines/asylum/system/screen.h
diff --git a/engines/asylum/system/screen.cpp b/engines/asylum/system/screen.cpp
index dc8de31c3a..abd4c70883 100644
--- a/engines/asylum/system/screen.cpp
+++ b/engines/asylum/system/screen.cpp
@@ -464,8 +464,67 @@ void Screen::deleteGraphicFromQueue(ResourceId resourceId) {
//////////////////////////////////////////////////////////////////////////
void Screen::blit(GraphicFrame *frame, Common::Rect *source, Common::Rect *destination, int32 flags) {
if (flags & 0x80000000) {
- // Used when closing from the menu (and more?)
- error("[Screen::blit] not implemented");
+ // Used in the menu (and more?)
+
+ int32 flagSet = flags & 0x7FFFFFFF;
+ bool hasTransTableIndex = false;
+
+ if (flags & 0x10000000) {
+ flagSet = flags & 0x6FFFFFFF;
+ hasTransTableIndex = (_transTableIndex ? true : false);
+ }
+
+ bool isMirrored = (flagSet == kDrawFlagMirrorLeftRight);
+
+ if (hasTransTableIndex) {
+ if (isMirrored) {
+ blitTranstableMirrored((byte *)_backBuffer.pixels + destination->top * _backBuffer.pitch + destination->left,
+ (byte *)frame->surface.pixels + source->top * frame->surface.pitch + source->right - 1,
+ destination->width() + (destination->height() << 16),
+ destination->width() + frame->surface.pitch,
+ frame->surface.pitch - destination->width());
+ } else {
+ blitTranstable((byte *)_backBuffer.pixels + destination->top * _backBuffer.pitch + destination->left,
+ (byte *)frame->surface.pixels + source->top * frame->surface.pitch + source->left,
+ destination->width() + (destination->height() << 16),
+ frame->surface.pitch - destination->width(),
+ _backBuffer.pitch - destination->width());
+ }
+ } else if (flagSet) {
+ if (isMirrored) {
+ if (_useColorKey) {
+ blitMirroredColorKey((byte *)_backBuffer.pixels + destination->top * _backBuffer.pitch + destination->left,
+ (byte *)frame->surface.pixels + source->top * frame->surface.pitch + source->right,
+ destination->height(),
+ destination->width(),
+ frame->surface.pitch + destination->width(),
+ _backBuffer.pitch - destination->width());
+ } else {
+ blitMirrored((byte *)_backBuffer.pixels + destination->top * _backBuffer.pitch + destination->left,
+ (byte *)frame->surface.pixels + source->top * frame->surface.pitch + source->right,
+ destination->height(),
+ destination->width(),
+ frame->surface.pitch + destination->width(),
+ _backBuffer.pitch - destination->width());
+ }
+ }
+ } else {
+ if (_useColorKey) {
+ blitRawColorKey((byte *)_backBuffer.pixels + destination->top * _backBuffer.pitch + destination->left,
+ (byte *)frame->surface.pixels + source->top * frame->surface.pitch + source->left,
+ destination->height(),
+ destination->width(),
+ frame->surface.pitch - destination->width(),
+ _backBuffer.pitch - destination->width());
+ } else {
+ blitRaw((byte *)_backBuffer.pixels + destination->top * _backBuffer.pitch + destination->left,
+ (byte *)frame->surface.pixels + source->top * frame->surface.pitch + source->left,
+ destination->height(),
+ destination->width(),
+ frame->surface.pitch - destination->width(),
+ _backBuffer.pitch - destination->width());
+ }
+ }
} else if (flags) {
blt(destination, frame, source, flags);
} else {
@@ -473,6 +532,30 @@ void Screen::blit(GraphicFrame *frame, Common::Rect *source, Common::Rect *desti
}
}
+void Screen::blitTranstable(byte *dstBuffer, byte *srcBuffer, int32 widthHeight, int32 srcPitch, int32 dstPitch) {
+ error("[Screen::blitTranstable] Not implemented");
+}
+
+void Screen::blitTranstableMirrored(byte *dstBuffer, byte *srcBuffer, int32 widthHeight, int32 srcPitch, int32 dstPitch) {
+ error("[Screen::blitTranstableMirrored] Not implemented");
+}
+
+void Screen::blitMirrored(byte *dstBuffer, byte *srcBuffer, int16 height, int16 width, int32 srcPitch, int32 dstPitch) {
+ error("[Screen::blitMirrored] Not implemented");
+}
+
+void Screen::blitMirroredColorKey(byte *dstBuffer, byte *srcBuffer, int16 height, int16 width, int32 srcPitch, int32 dstPitch) {
+ error("[Screen::blitMirroredColorKey] Not implemented");
+}
+
+void Screen::blitRaw(byte *dstBuffer, byte *srcBuffer, int16 height, int16 width, int32 srcPitch, int32 dstPitch) {
+ error("[Screen::blitRaw] Not implemented");
+}
+
+void Screen::blitRawColorKey(byte *dstBuffer, byte *srcBuffer, int16 height, int16 width, int32 srcPitch, int32 dstPitch) {
+ error("[Screen::blitRawColorKey] Not implemented");
+}
+
void Screen::blitMasked(GraphicFrame *frame, Common::Rect *source, byte *maskData, Common::Rect *sourceMask, Common::Rect *destMask, int maskHeight, Common::Rect *destination, int32 flags) {
// TODO
blit(frame, source, destination, flags);
diff --git a/engines/asylum/system/screen.h b/engines/asylum/system/screen.h
index cb7a2bf89e..a982e19ac0 100644
--- a/engines/asylum/system/screen.h
+++ b/engines/asylum/system/screen.h
@@ -152,8 +152,16 @@ private:
// Screen blitting
void blit(GraphicFrame *frame, Common::Rect *source, Common::Rect *destination, int32 flags);
+ void blitTranstable(byte *dstBuffer, byte *srcBuffer, int32 widthHeight, int32 srcPitch, int32 dstPitch);
+ void blitTranstableMirrored(byte *dstBuffer, byte *srcBuffer, int32 widthHeight, int32 srcPitch, int32 dstPitch);
+ void blitMirrored(byte *dstBuffer, byte *srcBuffer, int16 height, int16 width, int32 srcPitch, int32 dstPitch);
+ void blitMirroredColorKey(byte *dstBuffer, byte *srcBuffer, int16 height, int16 width, int32 srcPitch, int32 dstPitch);
+ void blitRaw(byte *dstBuffer, byte *srcBuffer, int16 height, int16 width, int32 srcPitch, int32 dstPitch);
+ void blitRawColorKey(byte *dstBuffer, byte *srcBuffer, int16 height, int16 width, int32 srcPitch, int32 dstPitch);
void blitMasked(GraphicFrame *frame, Common::Rect *source, byte *maskData, Common::Rect *sourceMask, Common::Rect *destMask, int maskHeight, Common::Rect *destination, int32 flags);
void blitCrossfade(byte *dstBuffer, byte *srcBuffer, byte *objectBuffer, int widthHeight, uint32 srcPitch, uint32 dstPitch, uint32 objectPitch);
+
+ // DirectDraw-equivalent functions
void blt(Common::Rect *dest, GraphicFrame* frame, Common::Rect *source, int32 flags);
void bltFast(int32 dX, int32 dY, GraphicFrame* frame, Common::Rect *source);
Commit: 5987db75f01fd50ee13070d1552f593575c722c0
https://github.com/scummvm/scummvm/commit/5987db75f01fd50ee13070d1552f593575c722c0
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:58+02:00
Commit Message:
ASYLUM: Implement Screen::blitMasked() and some helper methods
- Fix mask rectangles calculation and check
Changed paths:
engines/asylum/system/screen.cpp
engines/asylum/system/screen.h
diff --git a/engines/asylum/system/screen.cpp b/engines/asylum/system/screen.cpp
index abd4c70883..5651fdc4dd 100644
--- a/engines/asylum/system/screen.cpp
+++ b/engines/asylum/system/screen.cpp
@@ -114,16 +114,16 @@ void Screen::draw(ResourceId resourceId, uint32 frameIndex, const Common::Point
resourceMask = getResource()->get(resourceIdDestination);
// Adjust masked rectangles
- srcMask = Common::Rect(0, 0, resourceMask->getData(0), resourceMask->getData(4));
+ srcMask = Common::Rect(0, 0, resourceMask->getData(4), resourceMask->getData(0));
- destMask = Common::Rect(destination.y,
- destination.x,
- destination.y + resourceMask->getData(0),
- destination.x + resourceMask->getData(4));
+ destMask = Common::Rect(destination.x,
+ destination.y,
+ destination.x + resourceMask->getData(4),
+ destination.y + resourceMask->getData(0));
clip(&srcMask, &destMask, 0);
- if (dest.intersects(destMask))
+ if (!dest.intersects(destMask))
masked = false;
}
@@ -541,24 +541,155 @@ void Screen::blitTranstableMirrored(byte *dstBuffer, byte *srcBuffer, int32 widt
}
void Screen::blitMirrored(byte *dstBuffer, byte *srcBuffer, int16 height, int16 width, int32 srcPitch, int32 dstPitch) {
- error("[Screen::blitMirrored] Not implemented");
+ while (height--) {
+ for (int16 i = width; i; --i) {
+ *dstBuffer = *srcBuffer;
+
+ dstBuffer++;
+ srcBuffer--;
+ }
+
+ dstBuffer += dstPitch;
+ srcBuffer += srcPitch;
+ }
}
void Screen::blitMirroredColorKey(byte *dstBuffer, byte *srcBuffer, int16 height, int16 width, int32 srcPitch, int32 dstPitch) {
- error("[Screen::blitMirroredColorKey] Not implemented");
+ while (height--) {
+ for (int16 i = width; i; --i) {
+ if (*srcBuffer != 0)
+ *dstBuffer = *srcBuffer;
+
+ dstBuffer++;
+ srcBuffer--;
+ }
+
+ dstBuffer += dstPitch;
+ srcBuffer += srcPitch;
+ }
}
void Screen::blitRaw(byte *dstBuffer, byte *srcBuffer, int16 height, int16 width, int32 srcPitch, int32 dstPitch) {
- error("[Screen::blitRaw] Not implemented");
+ while (height--) {
+ memcpy(dstBuffer, srcBuffer, width);
+ dstBuffer += dstPitch;
+ srcBuffer += srcPitch;
+ }
}
void Screen::blitRawColorKey(byte *dstBuffer, byte *srcBuffer, int16 height, int16 width, int32 srcPitch, int32 dstPitch) {
- error("[Screen::blitRawColorKey] Not implemented");
+ while (height--) {
+ for (int16 i = 0; i < width; i++) {
+ if (*srcBuffer != 0)
+ *dstBuffer = *srcBuffer;
+
+ dstBuffer++;
+ srcBuffer++;
+ }
+
+ dstBuffer += dstPitch;
+ srcBuffer += srcPitch;
+ }
}
void Screen::blitMasked(GraphicFrame *frame, Common::Rect *source, byte *maskData, Common::Rect *sourceMask, Common::Rect *destMask, int maskHeight, Common::Rect *destination, int32 flags) {
- // TODO
- blit(frame, source, destination, flags);
+ byte *frameBuffer = (byte *)frame->surface.pixels;
+ byte *mirroredBuffer = NULL;
+ int16 frameRight = frame->surface.pitch;
+ int16 srcMaskLeft = abs(sourceMask->left);
+
+ // Prepare temporary source buffer if needed
+ if (flags & kDrawFlagMirrorLeftRight) {
+ mirroredBuffer = (byte *)malloc(source->right * source->bottom);
+ blitMirrored(mirroredBuffer,
+ frameBuffer + source->right - 1,
+ source->bottom,
+ source->right,
+ source->right + frame->surface.pitch,
+ 0);
+
+ frameBuffer = mirroredBuffer;
+ frameRight = source->right;
+
+ source->right -= source->left;
+ source->left = 0;
+ }
+
+ // Setup buffers and rectangles
+ byte *frameBufferPtr = frameBuffer + source->top * frameRight + source->left;
+ byte *maskBufferPtr = maskData + sourceMask->top * (maskHeight / 8) + sourceMask->left / 8;
+
+ // Check if we need to draw masked
+ if ((destMask->left + sourceMask->width()) < destination->left
+ || (destination->left + source->width()) < destMask->left
+ || (destMask->top + sourceMask->height()) < destination->top
+ || (destination->top + source->height()) < destMask->top) {
+
+ blitRawColorKey((byte *)_backBuffer.pixels + destination->top * _backBuffer.pitch + destination->left,
+ frameBufferPtr,
+ source->height(),
+ source->width(),
+ frameRight - source->width(),
+ _backBuffer.pitch - source->width());
+
+ // cleanup
+ delete mirroredBuffer;
+
+ return;
+ }
+
+ if (destination->left > destMask->left) {
+ sourceMask->setWidth(sourceMask->width() + destMask->left - destination->left);
+ maskBufferPtr += (destination->left - destMask->left) / 8 + abs(destination->left - destMask->left) / 8;
+ srcMaskLeft = abs(destination->left - destMask->left);
+ }
+
+ if (destination->top > destMask->top) {
+ maskBufferPtr += (destination->top - destMask->top) * maskHeight / 8;
+ destMask->top = destination->top;
+ sourceMask->setHeight(sourceMask->height() + destMask->top - destination->top);
+ }
+
+ if (destination->left < destMask->left) {
+ blitRawColorKey((byte *)_backBuffer.pixels + destination->top * _backBuffer.pitch + destination->left,
+ frameBufferPtr,
+ source->height(),
+ destMask->left - destination->left,
+ destination->left + frameRight - destMask->left,
+ destination->left + _backBuffer.pitch - destMask->left);
+
+ destination->left = destMask->left;
+ frameBufferPtr += destMask->left - destination->left;
+ source->setWidth(source->width() + destination->left - destMask->left);
+ }
+
+ if ((source->width() + destination->left) > (destMask->left + sourceMask->width())) {
+ blitRawColorKey((byte *)_backBuffer.pixels + (destMask->top + sourceMask->height()) * _backBuffer.pitch + destination->left,
+ frameBufferPtr + (destMask->top + sourceMask->height() - destination->top) * frameRight,
+ destination->top + source->height() - sourceMask->height() - destMask->top,
+ source->width(),
+ frameRight - source->width(),
+ _backBuffer.pitch - source->width());
+
+ source->setHeight(destMask->top + sourceMask->height() - destination->top);
+ }
+
+ bltMasked(frameBufferPtr,
+ maskBufferPtr,
+ source->width(),
+ source->height(),
+ frameRight - source->width(),
+ (maskHeight - srcMaskLeft - source->width()) / 8,
+ srcMaskLeft,
+ (byte *)_backBuffer.pixels + _backBuffer.pitch * destination->top + destination->left,
+ _backBuffer.pitch - source->width());
+
+ // Cleanup
+ delete mirroredBuffer;
+}
+
+void Screen::bltMasked(byte *srcBuffer, byte *maskBuffer, int16 width, int16 height, int16 srcPitch, int16 maskPitch, char maskLeft, byte *dstBuffer, int16 dstPitch) {
+ error("[Screen::bltMasked] Not implemented");
}
void Screen::blitCrossfade(byte *dstBuffer, byte *srcBuffer, byte *objectBuffer, int widthHeight, uint32 srcPitch, uint32 dstPitch, uint32 objectPitch) {
diff --git a/engines/asylum/system/screen.h b/engines/asylum/system/screen.h
index a982e19ac0..0bfc48ef12 100644
--- a/engines/asylum/system/screen.h
+++ b/engines/asylum/system/screen.h
@@ -159,6 +159,7 @@ private:
void blitRaw(byte *dstBuffer, byte *srcBuffer, int16 height, int16 width, int32 srcPitch, int32 dstPitch);
void blitRawColorKey(byte *dstBuffer, byte *srcBuffer, int16 height, int16 width, int32 srcPitch, int32 dstPitch);
void blitMasked(GraphicFrame *frame, Common::Rect *source, byte *maskData, Common::Rect *sourceMask, Common::Rect *destMask, int maskHeight, Common::Rect *destination, int32 flags);
+ void bltMasked(byte *srcBuffer, byte *maskBuffer, int16 width, int16 height, int16 srcPitch, int16 maskPitch, char maskLeft, byte *dstBuffer, int16 dstPitch);
void blitCrossfade(byte *dstBuffer, byte *srcBuffer, byte *objectBuffer, int widthHeight, uint32 srcPitch, uint32 dstPitch, uint32 objectPitch);
// DirectDraw-equivalent functions
Commit: 5b5cf905faab2fe405ed3f8dff696de701fd7dc9
https://github.com/scummvm/scummvm/commit/5b5cf905faab2fe405ed3f8dff696de701fd7dc9
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:58+02:00
Commit Message:
ASYLUM: Implement Screen::blitTranstable() and Screen::blitTranstableMirrored()
Changed paths:
engines/asylum/system/screen.cpp
engines/asylum/system/screen.h
diff --git a/engines/asylum/system/screen.cpp b/engines/asylum/system/screen.cpp
index 5651fdc4dd..531e88c2db 100644
--- a/engines/asylum/system/screen.cpp
+++ b/engines/asylum/system/screen.cpp
@@ -480,13 +480,15 @@ void Screen::blit(GraphicFrame *frame, Common::Rect *source, Common::Rect *desti
if (isMirrored) {
blitTranstableMirrored((byte *)_backBuffer.pixels + destination->top * _backBuffer.pitch + destination->left,
(byte *)frame->surface.pixels + source->top * frame->surface.pitch + source->right - 1,
- destination->width() + (destination->height() << 16),
+ destination->height(),
+ destination->width(),
destination->width() + frame->surface.pitch,
frame->surface.pitch - destination->width());
} else {
blitTranstable((byte *)_backBuffer.pixels + destination->top * _backBuffer.pitch + destination->left,
(byte *)frame->surface.pixels + source->top * frame->surface.pitch + source->left,
- destination->width() + (destination->height() << 16),
+ destination->height(),
+ destination->width(),
frame->surface.pitch - destination->width(),
_backBuffer.pitch - destination->width());
}
@@ -532,12 +534,34 @@ void Screen::blit(GraphicFrame *frame, Common::Rect *source, Common::Rect *desti
}
}
-void Screen::blitTranstable(byte *dstBuffer, byte *srcBuffer, int32 widthHeight, int32 srcPitch, int32 dstPitch) {
- error("[Screen::blitTranstable] Not implemented");
+void Screen::blitTranstable(byte *dstBuffer, byte *srcBuffer, int16 height, int16 width, int32 srcPitch, int32 dstPitch) {
+ while (height--) {
+ for (int16 i = 0; i < width; i++) {
+ if (*srcBuffer)
+ *dstBuffer = _transTableIndex[*srcBuffer]; // FIXME: is this the correct offset (total table size: 65535)
+
+ dstBuffer++;
+ srcBuffer++;
+ }
+
+ dstBuffer += dstPitch;
+ srcBuffer += srcPitch;
+ }
}
-void Screen::blitTranstableMirrored(byte *dstBuffer, byte *srcBuffer, int32 widthHeight, int32 srcPitch, int32 dstPitch) {
- error("[Screen::blitTranstableMirrored] Not implemented");
+void Screen::blitTranstableMirrored(byte *dstBuffer, byte *srcBuffer, int16 height, int16 width, int32 srcPitch, int32 dstPitch) {
+ while (height--) {
+ for (int16 i = width; i; --i) {
+ if (*srcBuffer)
+ *dstBuffer = _transTableIndex[*srcBuffer]; // FIXME: is this the correct offset (total table size: 65535)
+
+ dstBuffer++;
+ srcBuffer--;
+ }
+
+ dstBuffer += dstPitch;
+ srcBuffer += srcPitch;
+ }
}
void Screen::blitMirrored(byte *dstBuffer, byte *srcBuffer, int16 height, int16 width, int32 srcPitch, int32 dstPitch) {
diff --git a/engines/asylum/system/screen.h b/engines/asylum/system/screen.h
index 0bfc48ef12..9d2027461f 100644
--- a/engines/asylum/system/screen.h
+++ b/engines/asylum/system/screen.h
@@ -152,8 +152,8 @@ private:
// Screen blitting
void blit(GraphicFrame *frame, Common::Rect *source, Common::Rect *destination, int32 flags);
- void blitTranstable(byte *dstBuffer, byte *srcBuffer, int32 widthHeight, int32 srcPitch, int32 dstPitch);
- void blitTranstableMirrored(byte *dstBuffer, byte *srcBuffer, int32 widthHeight, int32 srcPitch, int32 dstPitch);
+ void blitTranstable(byte *dstBuffer, byte *srcBuffer, int16 height, int16 width, int32 srcPitch, int32 dstPitch);
+ void blitTranstableMirrored(byte *dstBuffer, byte *srcBuffer, int16 height, int16 width, int32 srcPitch, int32 dstPitch);
void blitMirrored(byte *dstBuffer, byte *srcBuffer, int16 height, int16 width, int32 srcPitch, int32 dstPitch);
void blitMirroredColorKey(byte *dstBuffer, byte *srcBuffer, int16 height, int16 width, int32 srcPitch, int32 dstPitch);
void blitRaw(byte *dstBuffer, byte *srcBuffer, int16 height, int16 width, int32 srcPitch, int32 dstPitch);
Commit: 18e85a5efa6da81f98663678c55d339aa1f9fca5
https://github.com/scummvm/scummvm/commit/18e85a5efa6da81f98663678c55d339aa1f9fca5
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:58+02:00
Commit Message:
ASYLUM: Implement part of Actor::updateStatus12_Chapter2()
- Update ActorData structure
Changed paths:
engines/asylum/resources/actor.cpp
engines/asylum/resources/actor.h
diff --git a/engines/asylum/resources/actor.cpp b/engines/asylum/resources/actor.cpp
index fc7b6f4824..36917e8a0c 100644
--- a/engines/asylum/resources/actor.cpp
+++ b/engines/asylum/resources/actor.cpp
@@ -227,8 +227,11 @@ void Actor::loadData(Common::SeekableReadStream *stream) {
_data.field_4 = stream->readUint32LE();
- for (int32 i = 0; i < 240; i++)
- _data.field_8[i] = stream->readSint32LE();
+ _data.point.x = stream->readSint32LE();
+ _data.point.y = stream->readSint32LE();
+
+ for (int32 i = 0; i < 238; i++)
+ _data.field_10[i] = stream->readSint32LE();
for (int32 i = 0; i < 120; i++)
_data.field_3C8[i] = stream->readSint32LE();
@@ -872,8 +875,7 @@ bool Actor::process(const Common::Point &point) {
if (point == sum) {
if (process_408B20(&sum, a3 >= 2 ? kDirectionS : kDirectionN, abs(delta.y), false)) {
- _data.field_8[0] = point.x;
- _data.field_8[1] = point.y;
+ _data.point = point;
_data.field_4 = 0;
_data.count = 1;
@@ -884,8 +886,7 @@ bool Actor::process(const Common::Point &point) {
if (point.x == sum.x) {
ActorDirection actorDir = a3 >= 2 ? kDirectionS : kDirectionN;
if (process_408B20(&sum, actorDir, abs(delta.y), false)) {
- _data.field_8[0] = point.x;
- _data.field_8[1] = point.y;
+ _data.point = point;
_data.field_4 = 0;
_data.count = 1;
@@ -901,8 +902,7 @@ bool Actor::process(const Common::Point &point) {
ActorDirection actorDir = (a3 != 0 || a3 != 3) ? kDirectionE : kDirectionO;
if (process_408B20(&sum, actorDir, abs(delta.x), true)) {
- _data.field_8[0] = point.x;
- _data.field_8[1] = point.y;
+ _data.point = point;
_data.field_4 = 0;
_data.count = 1;
@@ -1068,8 +1068,7 @@ bool Actor::process(const Common::Point &point) {
return false;
// Update actor data
- _data.field_8[0] = point.x;
- _data.field_8[1] = point.y;
+ _data.point = point;
_data.field_4 = 0;
_data.count = 1;
@@ -1830,7 +1829,47 @@ void Actor::updateStatus9() {
}
void Actor::updateStatus12_Chapter2() {
- error("[Actor::updateStatus12_Chapter2] not implemented!");
+ // Compute distance
+ uint32 frameIndex = _frameIndex;
+ if (_frameIndex >= _frameCount)
+ frameIndex = 2 * _frameCount - _frameIndex - 1;
+
+ int32 distance = getDistanceForFrame(_direction, frameIndex);
+
+ // Face actor
+ faceTarget(getScene()->getPlayerIndex(), kDirectionFromActor);
+
+ // FIXME
+ if (_data.field_10[_index + 10] > 0) {
+ _direction = (ActorDirection)(_direction + 4);
+ _data.field_10[_index + 10] -= 1;
+ }
+
+ // Compute coordinates and distance
+ Actor *player = getScene()->getActor();
+ Common::Point sumPlayer = *player->getPoint1() + *player->getPoint2();
+ Common::Point sum = _point1 + _point2;
+
+ uint32 absX = abs(sum.x - sumPlayer.x);
+ uint32 absY = abs(sum.y - sumPlayer.y);
+
+ // Adjust distance
+ if (absX <= absY)
+ absX = absY;
+
+ if (!distance)
+ distance = 0; // FIXME: get proper distance value
+
+ if (absX >= 50) {
+ playSounds(_direction, abs(distance));
+ } else {
+ _frameIndex = 0;
+ // FIXME
+ _data.field_10[2 * _index + 15] = player->getPoint1()->x - _point1.x;
+ _data.field_10[2 * _index + 16] = player->getPoint1()->y - _point1.y;
+
+ updateStatus(kActorStatus18);
+ }
}
void Actor::updateStatus12_Chapter2_Actor11() {
diff --git a/engines/asylum/resources/actor.h b/engines/asylum/resources/actor.h
index 1906d05dec..6c6533de00 100644
--- a/engines/asylum/resources/actor.h
+++ b/engines/asylum/resources/actor.h
@@ -41,7 +41,8 @@ struct GraphicFrame;
struct ActorData {
uint32 count;
int32 field_4;
- int32 field_8[240];
+ Common::Point point;
+ int32 field_10[238];
int32 field_3C8[120];
// TODO add actor data fields
};
Commit: 519f4f86f2ad03d2b2d037d1e16211b01dd9b83a
https://github.com/scummvm/scummvm/commit/519f4f86f2ad03d2b2d037d1e16211b01dd9b83a
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:59+02:00
Commit Message:
ASYLUM: Implement Actor::updateAndDraw()
Changed paths:
engines/asylum/asylum.cpp
engines/asylum/asylum.h
engines/asylum/resources/actor.cpp
engines/asylum/resources/actor.h
engines/asylum/resources/special.cpp
engines/asylum/shared.h
engines/asylum/views/scene.cpp
diff --git a/engines/asylum/asylum.cpp b/engines/asylum/asylum.cpp
index 4106302ff3..cfaef02c68 100644
--- a/engines/asylum/asylum.cpp
+++ b/engines/asylum/asylum.cpp
@@ -24,6 +24,7 @@
#include "asylum/resources/actor.h"
#include "asylum/resources/encounters.h"
+#include "asylum/resources/reaction.h"
#include "asylum/resources/script.h"
#include "asylum/resources/special.h"
#include "asylum/resources/worldstats.h"
@@ -70,7 +71,7 @@
namespace Asylum {
AsylumEngine::AsylumEngine(OSystem *system, const ADGameDescription *gd) : Engine(system), _gameDescription(gd),
- _console(NULL), _cursor(NULL), _encounter(NULL), _menu(NULL), _resource(NULL), _savegame(NULL),
+ _console(NULL), _cursor(NULL), _encounter(NULL), _menu(NULL), _reaction(NULL), _resource(NULL), _savegame(NULL),
_scene(NULL), _screen(NULL), _script(NULL), _sound(NULL), _text(NULL), _video(NULL), _handler(NULL) {
// Init data
@@ -111,6 +112,7 @@ AsylumEngine::~AsylumEngine() {
delete _cursor;
delete _scene;
delete _encounter;
+ delete _reaction;
delete _savegame;
delete _screen;
delete _script;
@@ -143,6 +145,7 @@ Common::Error AsylumEngine::run() {
// Create all game classes
_encounter = new Encounter(this);
_cursor = new Cursor(this);
+ _reaction = new Reaction(this);
_savegame = new Savegame(this);
_screen = new Screen(this);
_script = new ScriptManager(this);
diff --git a/engines/asylum/asylum.h b/engines/asylum/asylum.h
index 72f3f4065e..acb8fcbe77 100644
--- a/engines/asylum/asylum.h
+++ b/engines/asylum/asylum.h
@@ -67,6 +67,7 @@ class Puzzle;
class Cursor;
class Encounter;
class Menu;
+class Reaction;
class ResourceManager;
class Savegame;
class Scene;
@@ -146,6 +147,7 @@ public:
Cursor *cursor() { return _cursor; }
Encounter *encounter() { return _encounter; }
Menu *menu() { return _menu; }
+ Reaction *reaction() { return _reaction; }
ResourceManager *resource() { return _resource; }
Savegame *savegame() { return _savegame; }
Scene *scene() { return _scene; }
@@ -226,6 +228,7 @@ private:
Cursor *_cursor;
Encounter *_encounter;
Menu *_menu;
+ Reaction *_reaction;
ResourceManager *_resource;
Savegame *_savegame;
Scene *_scene;
diff --git a/engines/asylum/resources/actor.cpp b/engines/asylum/resources/actor.cpp
index 36917e8a0c..f0cf4deff6 100644
--- a/engines/asylum/resources/actor.cpp
+++ b/engines/asylum/resources/actor.cpp
@@ -25,6 +25,7 @@
#include "asylum/resources/encounters.h"
#include "asylum/resources/object.h"
#include "asylum/resources/polygons.h"
+#include "asylum/resources/reaction.h"
#include "asylum/resources/script.h"
#include "asylum/resources/worldstats.h"
@@ -1493,7 +1494,54 @@ bool Actor::process_4103B0(Common::Point *point, ActorDirection dir) {
}
void Actor::updateAndDraw() {
- error("[Actor::updateAndDraw] not implemented!");
+ Actor *player = getScene()->getActor();
+ Common::Point mouse = getCursor()->position();
+ bool keepField = false;
+
+ // Get reaction count
+ uint32 count = 0;
+ for (int i = 0; i < 8; i++)
+ if (_reaction[i])
+ count++;
+
+ for (uint32 i = 0; i < count; i++) {
+ // Compute points
+ Common::Point coords;
+ adjustCoordinates(&coords);
+
+ Common::Point sinCos = _vm->getSinCosValues(count, i);
+ Common::Point point = coords + Common::Point(player->getPoint2()->x + sinCos.x, player->getPoint2()->y / 2 - sinCos.y);
+
+ if (mouse.x < point.x || mouse.x > (point.x + 40) || mouse.y < point.y || mouse.y > (point.y + 40)) {
+ getScreen()->addGraphicToQueue(getWorld()->cursorResourcesAlternate[_reaction[i] + 15],
+ 0,
+ point,
+ kDrawFlagNone,
+ 0,
+ 1);
+ } else {
+ if (getWorld()->field_120 != (int32)(i + 1)) {
+ getSound()->playSound(MAKE_RESOURCE(kResourcePackSound, 3));
+ getReaction()->run(_reaction[i] - 1);
+ }
+
+ getWorld()->field_120 = i + 1;
+ keepField = true;
+
+ getScreen()->addGraphicToQueue(getWorld()->cursorResourcesAlternate[_reaction[i]],
+ 0,
+ point,
+ kDrawFlagNone,
+ 0,
+ 1);
+ }
+
+ if (getWorld()->chapter == kChapter4)
+ updateNumbers(_reaction[i] - 1, point);
+ }
+
+ if (!keepField)
+ getWorld()->field_120 = 0;
}
void Actor::update_409230() {
diff --git a/engines/asylum/resources/actor.h b/engines/asylum/resources/actor.h
index 6c6533de00..47079bb762 100644
--- a/engines/asylum/resources/actor.h
+++ b/engines/asylum/resources/actor.h
@@ -88,7 +88,7 @@ public:
Common::Point *getPoint() { return &_point; }
Common::Point *getPoint1() { return &_point1; }
Common::Point *getPoint2() { return &_point2; }
- int32 getReaction(uint32 index) { return _reaction[index]; }
+ int32 getReactionValue(uint32 index) { return _reaction[index]; }
ResourceId getResourceId() { return _resourceId; }
ResourceId getResourcesId(uint32 index) { return _graphicResourceIds[index]; }
int32 getScriptIndex() { return _scriptIndex; }
diff --git a/engines/asylum/resources/special.cpp b/engines/asylum/resources/special.cpp
index 25e1effe5c..e1d91e355d 100644
--- a/engines/asylum/resources/special.cpp
+++ b/engines/asylum/resources/special.cpp
@@ -446,7 +446,7 @@ void Special::chapter7(Object *object, ActorIndex actorIndex) {
Actor *player = getScene()->getActor();
if (_vm->isGameFlagSet(kGameFlag1021)) {
- if (player->getReaction(0)) {
+ if (player->getReactionValue(0)) {
if (player->getStatus() == kActorStatus6 || player->getStatus() == kActorStatus10) {
getSound()->playSound(MAKE_RESOURCE(kResourcePackSound, 2));
diff --git a/engines/asylum/shared.h b/engines/asylum/shared.h
index 6476e6cdde..cebd769ff5 100644
--- a/engines/asylum/shared.h
+++ b/engines/asylum/shared.h
@@ -652,6 +652,7 @@ enum ObjectFlag {
#define getCursor() _vm->cursor()
#define getMenu() _vm->menu()
#define getPuzzleData() _vm->puzzleData()
+#define getReaction() _vm->reaction()
#define getResource() _vm->resource()
#define getSound() _vm->sound()
#define getSaveLoad() _vm->savegame()
diff --git a/engines/asylum/views/scene.cpp b/engines/asylum/views/scene.cpp
index af3568ea34..b86c6b530d 100644
--- a/engines/asylum/views/scene.cpp
+++ b/engines/asylum/views/scene.cpp
@@ -568,7 +568,7 @@ bool Scene::clickDown(const AsylumEvent &evt) {
return true;
}
- if (!hitTestPlayer() || player->getStatus() >= kActorStatus11 || !player->getReaction(0)) {
+ if (!hitTestPlayer() || player->getStatus() >= kActorStatus11 || !player->getReactionValue(0)) {
if (player->getStatus() == kActorStatus6 || player->getStatus() == kActorStatus10) {
playerReaction();
} else {
@@ -1178,7 +1178,7 @@ void Scene::updateCursor(ActorDirection direction, Common::Rect rect) {
}
if (mouse.x >= rect.left && mouse.x <= rightLimit && mouse.y >= rect.top && mouse.y <= rect.bottom && hitTestPlayer()) {
- if (player->getReaction(0)) {
+ if (player->getReactionValue(0)) {
if (getCursor()->graphicResourceId != _ws->cursorResources[kCursorResourceGrabPointer])
getCursor()->set(_ws->cursorResources[kCursorResourceGrabPointer]);
@@ -1641,7 +1641,7 @@ void Scene::playerReaction() {
uint32 maxIndex = 0;
for (maxIndex = 0; maxIndex < 8; maxIndex++) {
- if (!player->getReaction(maxIndex))
+ if (!player->getReactionValue(maxIndex))
break;
}
@@ -1662,7 +1662,7 @@ void Scene::playerReaction() {
if (_ws->chapter == kChapter9) {
switch (i) {
default:
- player->setField638(player->getReaction(i));
+ player->setField638(player->getReactionValue(i));
break;
case 0:
@@ -1678,7 +1678,7 @@ void Scene::playerReaction() {
break;
}
} else {
- player->setField638(player->getReaction(i));
+ player->setField638(player->getReactionValue(i));
}
break;
}
@@ -2317,7 +2317,7 @@ void Scene::changePlayerUpdate(ActorIndex index) {
player->hide();
for (uint i = 0; i < 8; i++)
- actor->setReaction(i, player->getReaction(i));
+ actor->setReaction(i, player->getReactionValue(i));
}
//////////////////////////////////////////////////////////////////////////
Commit: 986176b4452bb0b1d5a9cec4da6f4354a3b7f944
https://github.com/scummvm/scummvm/commit/986176b4452bb0b1d5a9cec4da6f4354a3b7f944
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:59+02:00
Commit Message:
ASYLUM: Finish implementation of Actor::update()
Changed paths:
engines/asylum/resources/actor.cpp
engines/asylum/resources/actor.h
diff --git a/engines/asylum/resources/actor.cpp b/engines/asylum/resources/actor.cpp
index f0cf4deff6..085d3f9432 100644
--- a/engines/asylum/resources/actor.cpp
+++ b/engines/asylum/resources/actor.cpp
@@ -26,6 +26,7 @@
#include "asylum/resources/object.h"
#include "asylum/resources/polygons.h"
#include "asylum/resources/reaction.h"
+#include "asylum/resources/special.h"
#include "asylum/resources/script.h"
#include "asylum/resources/worldstats.h"
@@ -226,7 +227,7 @@ void Actor::load(Common::SeekableReadStream *stream) {
void Actor::loadData(Common::SeekableReadStream *stream) {
_data.count = stream->readUint32LE();
- _data.field_4 = stream->readUint32LE();
+ _data.current = stream->readUint32LE();
_data.point.x = stream->readSint32LE();
_data.point.y = stream->readSint32LE();
@@ -235,7 +236,7 @@ void Actor::loadData(Common::SeekableReadStream *stream) {
_data.field_10[i] = stream->readSint32LE();
for (int32 i = 0; i < 120; i++)
- _data.field_3C8[i] = stream->readSint32LE();
+ _data.directions[i] = (ActorDirection)stream->readSint32LE();
}
/////////////////////////////////////////////////////////////////////////
@@ -475,35 +476,99 @@ void Actor::update() {
case kActorStatus1: {
uint32 index = (_frameIndex >= _frameCount) ? 2 * _frameCount - (_frameIndex + 1) : _frameIndex;
- uint32 dir = _direction;
+ // FIXME the original tests for != 0 and sets to an unknown value (offset to actor in structure?)
uint32 dist = abs((double)getDistanceForFrame(_direction, index));
- // FIXME the original tests for != 0 and sets to an unknown value
+ if (!dist)
+ error("[Actor::update] Invalid distance (kActorStatus1)");
- Common::Point point(_point1.x + _point2.x, _point1.y + _point2.y);
+ Common::Point point = _point1 + _point2;
if (process_408B20(&point, _direction, dist, false)) {
playSounds(_direction, dist);
- } else if (process_408B20(&point, (ActorDirection)((dir + 1) % 7), dist, false)) {
- playSounds((ActorDirection)((dir + 1) % 7), dist);
- } else if (process_408B20(&point, (ActorDirection)((dir + 7) % 7), dist, false)) {
- playSounds((ActorDirection)((dir + 7) % 7), dist);
- } else if (process_408B20(&point, (ActorDirection)((dir + 2) % 7), dist, false)) {
- playSounds((ActorDirection)((dir + 2) % 7), dist);
- } else if (process_408B20(&point, (ActorDirection)((dir + 6) % 7), dist, false)) {
- playSounds((ActorDirection)((dir + 6) % 7), dist);
+ } else if (process_408B20(&point, (ActorDirection)((_direction + 1) % 7), dist, false)) {
+ playSounds((ActorDirection)((_direction + 1) % 7), dist);
+ } else if (process_408B20(&point, (ActorDirection)((_direction + 7) % 7), dist, false)) {
+ playSounds((ActorDirection)((_direction + 7) % 7), dist);
+ } else if (process_408B20(&point, (ActorDirection)((_direction + 2) % 7), dist, false)) {
+ playSounds((ActorDirection)((_direction + 2) % 7), dist);
+ } else if (process_408B20(&point, (ActorDirection)((_direction + 6) % 7), dist, false)) {
+ playSounds((ActorDirection)((_direction + 6) % 7), dist);
}
+ // Finish
+ if (_soundResourceId != kResourceNone && getSound()->isPlaying(_soundResourceId))
+ setVolume();
+
+ if (_index != getScene()->getPlayerIndex() && getWorld()->chapter != kChapter9)
+ getSpecial()->run(NULL, _index);
+
+ updateDirection();
+
+ if (_field_944 != 5)
+ updateFinish();
+
}
break;
case kActorStatus2:
case kActorStatus13: {
- /*int32 dist = getDistance();
+ uint32 index = (_frameIndex >= _frameCount) ? 2 * _frameCount - (_frameIndex + 1) : _frameIndex;
+
+ // FIXME the original tests for != 0 and sets to an unknown value (offset to actor in structure?)
+ uint32 dist = abs((double)getDistanceForFrame(_direction, index));
if (!dist)
- dist = _direction;
+ error("[Actor::update] Invalid distance (kActorStatus2/kActorStatus13)");
+
+ Common::Point point = _point1 + _point2;
+
+ if (point.x < (int16)(_data.point.x - (dist - 1))
+ || point.x > (int16)(_data.point.x + (dist - 1))
+ || point.y < (int16)(_data.point.y - (dist - 1))
+ || point.y > (int16)(_data.point.y + (dist - 1))) {
+ if (process_408B20(&point, _direction, dist, false)) {
+ playSounds(_direction, dist);
+ } else {
+ update_409230();
+ }
+ } else {
+ int32 area = getScene()->findActionArea(kActionAreaType1, _data.point);
+ if (_field_944 == 1 || _field_944 == 4)
+ area = 1;
+
+ if (area == -1 || _data.current >= (int32)(_data.count - 1)) {
+ update_409230();
+ } else {
+ _frameIndex = (_frameIndex + 1) % _frameCount;
+
+ if (process_4103B0(&_data.point, _direction)) {
+ _point1.x = dist - _point2.x;
+ _point1.y = _data.point.y - _point2.y;
+
+ if (_data.current < (int32)(_data.count - 1)) {
+ _data.current++;
+
+ updateFromDirection(_data.directions[_data.current]);
+ } else {
+ update_409230();
+ }
+ } else {
+ update_409230();
+ }
+ }
+ }
+
+ // Finish
+ if (_soundResourceId != kResourceNone && getSound()->isPlaying(_soundResourceId))
+ setVolume();
+
+ if (_index != getScene()->getPlayerIndex() && getWorld()->chapter != kChapter9)
+ getSpecial()->run(NULL, _index);
+
+ updateDirection();
+
+ if (_field_944 != 5)
+ updateFinish();
- Common::Point point(_point1.x + _point2.x, */
- error("[Actor::update] kActorStatus2 / kActorStatus13 case not implemented");
}
break;
@@ -877,7 +942,7 @@ bool Actor::process(const Common::Point &point) {
if (point == sum) {
if (process_408B20(&sum, a3 >= 2 ? kDirectionS : kDirectionN, abs(delta.y), false)) {
_data.point = point;
- _data.field_4 = 0;
+ _data.current = 0;
_data.count = 1;
return true;
@@ -888,7 +953,7 @@ bool Actor::process(const Common::Point &point) {
ActorDirection actorDir = a3 >= 2 ? kDirectionS : kDirectionN;
if (process_408B20(&sum, actorDir, abs(delta.y), false)) {
_data.point = point;
- _data.field_4 = 0;
+ _data.current = 0;
_data.count = 1;
updateFromDirection(actorDir);
@@ -904,7 +969,7 @@ bool Actor::process(const Common::Point &point) {
if (process_408B20(&sum, actorDir, abs(delta.x), true)) {
_data.point = point;
- _data.field_4 = 0;
+ _data.current = 0;
_data.count = 1;
updateFromDirection(actorDir);
@@ -1020,7 +1085,7 @@ bool Actor::process(const Common::Point &point) {
return false;
}
- updateFromDirection((ActorDirection)_data.field_3C8[0]);
+ updateFromDirection(_data.directions[0]);
return true;
}
@@ -1029,7 +1094,7 @@ bool Actor::process(const Common::Point &point) {
if (!processAction3(sum, point, &actions))
return false;
- updateFromDirection((ActorDirection)_data.field_3C8[0]);
+ updateFromDirection(_data.directions[0]);
return true;
}
@@ -1038,7 +1103,7 @@ bool Actor::process(const Common::Point &point) {
if (!processAction4(sum, point, &actions))
return false;
- updateFromDirection((ActorDirection)_data.field_3C8[0]);
+ updateFromDirection(_data.directions[0]);
return true;
}
@@ -1070,7 +1135,7 @@ bool Actor::process(const Common::Point &point) {
// Update actor data
_data.point = point;
- _data.field_4 = 0;
+ _data.current = 0;
_data.count = 1;
// Update actor from direction
@@ -1546,7 +1611,7 @@ void Actor::updateAndDraw() {
void Actor::update_409230() {
updateStatus(_status <= 11 ? kActorStatusEnabled : kActorStatus14);
- _data.field_4 = 0;
+ _data.current = 0;
}
//////////////////////////////////////////////////////////////////////////
@@ -1887,7 +1952,7 @@ void Actor::updateStatus12_Chapter2() {
// Face actor
faceTarget(getScene()->getPlayerIndex(), kDirectionFromActor);
- // FIXME
+ // FIXME: another field is used (not _data!)
if (_data.field_10[_index + 10] > 0) {
_direction = (ActorDirection)(_direction + 4);
_data.field_10[_index + 10] -= 1;
@@ -1912,7 +1977,7 @@ void Actor::updateStatus12_Chapter2() {
playSounds(_direction, abs(distance));
} else {
_frameIndex = 0;
- // FIXME
+ // FIXME: another field is used (not _data!)
_data.field_10[2 * _index + 15] = player->getPoint1()->x - _point1.x;
_data.field_10[2 * _index + 16] = player->getPoint1()->y - _point1.y;
diff --git a/engines/asylum/resources/actor.h b/engines/asylum/resources/actor.h
index 47079bb762..deba085a93 100644
--- a/engines/asylum/resources/actor.h
+++ b/engines/asylum/resources/actor.h
@@ -40,11 +40,10 @@ struct GraphicFrame;
struct ActorData {
uint32 count;
- int32 field_4;
+ int32 current;
Common::Point point;
int32 field_10[238];
- int32 field_3C8[120];
- // TODO add actor data fields
+ ActorDirection directions[120];
};
class Actor {
Commit: 4e3a6d51dce46547dfe307e93ad0cd1b0e2a5246
https://github.com/scummvm/scummvm/commit/4e3a6d51dce46547dfe307e93ad0cd1b0e2a5246
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:59+02:00
Commit Message:
ASYLUM: Update ActorData structure (it is holding a set of points and directions for pathfinding)
Changed paths:
engines/asylum/resources/actor.cpp
engines/asylum/resources/actor.h
diff --git a/engines/asylum/resources/actor.cpp b/engines/asylum/resources/actor.cpp
index 085d3f9432..1fb6d5d0f2 100644
--- a/engines/asylum/resources/actor.cpp
+++ b/engines/asylum/resources/actor.cpp
@@ -229,11 +229,10 @@ void Actor::loadData(Common::SeekableReadStream *stream) {
_data.current = stream->readUint32LE();
- _data.point.x = stream->readSint32LE();
- _data.point.y = stream->readSint32LE();
-
- for (int32 i = 0; i < 238; i++)
- _data.field_10[i] = stream->readSint32LE();
+ for (int32 i = 0; i < 120; i++) {
+ _data.points[i].x = stream->readSint32LE();
+ _data.points[i].y = stream->readSint32LE();
+ }
for (int32 i = 0; i < 120; i++)
_data.directions[i] = (ActorDirection)stream->readSint32LE();
@@ -520,18 +519,19 @@ void Actor::update() {
error("[Actor::update] Invalid distance (kActorStatus2/kActorStatus13)");
Common::Point point = _point1 + _point2;
+ Common::Point current = _data.points[_data.current];
- if (point.x < (int16)(_data.point.x - (dist - 1))
- || point.x > (int16)(_data.point.x + (dist - 1))
- || point.y < (int16)(_data.point.y - (dist - 1))
- || point.y > (int16)(_data.point.y + (dist - 1))) {
+ if (point.x < (int16)(current.x - (dist - 1))
+ || point.x > (int16)(current.x + (dist - 1))
+ || point.y < (int16)(current.y - (dist - 1))
+ || point.y > (int16)(current.y + (dist - 1))) {
if (process_408B20(&point, _direction, dist, false)) {
playSounds(_direction, dist);
} else {
update_409230();
}
} else {
- int32 area = getScene()->findActionArea(kActionAreaType1, _data.point);
+ int32 area = getScene()->findActionArea(kActionAreaType1, current);
if (_field_944 == 1 || _field_944 == 4)
area = 1;
@@ -540,9 +540,9 @@ void Actor::update() {
} else {
_frameIndex = (_frameIndex + 1) % _frameCount;
- if (process_4103B0(&_data.point, _direction)) {
+ if (process_4103B0(¤t, _direction)) {
_point1.x = dist - _point2.x;
- _point1.y = _data.point.y - _point2.y;
+ _point1.y = current.y - _point2.y;
if (_data.current < (int32)(_data.count - 1)) {
_data.current++;
@@ -941,9 +941,9 @@ bool Actor::process(const Common::Point &point) {
if (point == sum) {
if (process_408B20(&sum, a3 >= 2 ? kDirectionS : kDirectionN, abs(delta.y), false)) {
- _data.point = point;
- _data.current = 0;
- _data.count = 1;
+ _data.points[0] = point;
+ _data.current = 0;
+ _data.count = 1;
return true;
}
@@ -952,9 +952,9 @@ bool Actor::process(const Common::Point &point) {
if (point.x == sum.x) {
ActorDirection actorDir = a3 >= 2 ? kDirectionS : kDirectionN;
if (process_408B20(&sum, actorDir, abs(delta.y), false)) {
- _data.point = point;
- _data.current = 0;
- _data.count = 1;
+ _data.points[0] = point;
+ _data.current = 0;
+ _data.count = 1;
updateFromDirection(actorDir);
@@ -968,9 +968,9 @@ bool Actor::process(const Common::Point &point) {
ActorDirection actorDir = (a3 != 0 || a3 != 3) ? kDirectionE : kDirectionO;
if (process_408B20(&sum, actorDir, abs(delta.x), true)) {
- _data.point = point;
- _data.current = 0;
- _data.count = 1;
+ _data.points[0] = point;
+ _data.current = 0;
+ _data.count = 1;
updateFromDirection(actorDir);
@@ -1134,9 +1134,9 @@ bool Actor::process(const Common::Point &point) {
return false;
// Update actor data
- _data.point = point;
- _data.current = 0;
- _data.count = 1;
+ _data.points[0] = point;
+ _data.current = 0;
+ _data.count = 1;
// Update actor from direction
updateFromDirection(actorDir);
@@ -1953,10 +1953,10 @@ void Actor::updateStatus12_Chapter2() {
faceTarget(getScene()->getPlayerIndex(), kDirectionFromActor);
// FIXME: another field is used (not _data!)
- if (_data.field_10[_index + 10] > 0) {
- _direction = (ActorDirection)(_direction + 4);
- _data.field_10[_index + 10] -= 1;
- }
+ //if (_data.field_10[_index + 10] > 0) {
+ // _direction = (ActorDirection)(_direction + 4);
+ // _data.field_10[_index + 10] -= 1;
+ //}
// Compute coordinates and distance
Actor *player = getScene()->getActor();
@@ -1978,8 +1978,8 @@ void Actor::updateStatus12_Chapter2() {
} else {
_frameIndex = 0;
// FIXME: another field is used (not _data!)
- _data.field_10[2 * _index + 15] = player->getPoint1()->x - _point1.x;
- _data.field_10[2 * _index + 16] = player->getPoint1()->y - _point1.y;
+ //_data.field_10[2 * _index + 15] = player->getPoint1()->x - _point1.x;
+ //_data.field_10[2 * _index + 16] = player->getPoint1()->y - _point1.y;
updateStatus(kActorStatus18);
}
diff --git a/engines/asylum/resources/actor.h b/engines/asylum/resources/actor.h
index deba085a93..ec82180e83 100644
--- a/engines/asylum/resources/actor.h
+++ b/engines/asylum/resources/actor.h
@@ -41,8 +41,7 @@ struct GraphicFrame;
struct ActorData {
uint32 count;
int32 current;
- Common::Point point;
- int32 field_10[238];
+ Common::Point points[120];
ActorDirection directions[120];
};
Commit: d2eabdf8809e91b2596407f05837b8cefb9095d6
https://github.com/scummvm/scummvm/commit/d2eabdf8809e91b2596407f05837b8cefb9095d6
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:59+02:00
Commit Message:
ASYLUM: Replace Actor::clearFields() by sane version
Changed paths:
engines/asylum/resources/actor.cpp
engines/asylum/resources/actor.h
diff --git a/engines/asylum/resources/actor.cpp b/engines/asylum/resources/actor.cpp
index 1fb6d5d0f2..a7966d0d56 100644
--- a/engines/asylum/resources/actor.cpp
+++ b/engines/asylum/resources/actor.cpp
@@ -751,13 +751,11 @@ void Actor::updateStatus(ActorStatus actorStatus) {
//////////////////////////////////////////////////////////////////////////
void Actor::updateDirection() {
- if(_field_970) {
- // TODO
- // This update is only ever done if action script 0x5D is called, and
- // the resulting switch sets field_970. Investigate 401A30 for further
- // details
- error("[Actor::updateDirection] logic not implemented");
- }
+ // Called by Script::hideActor() / showActor() and process_401830()
+ if(!_field_970)
+ return;
+
+ error("[Actor::updateDirection] Not implemented");
}
void Actor::updateFromDirection(ActorDirection actorDirection) {
@@ -894,6 +892,22 @@ Common::String Actor::toString(bool shortString) {
// Unknown methods
//////////////////////////////////////////////////////////////////////////
+void Actor::clearFields() {
+ _field_970 = 0;
+ _field_974 = 0;
+ _field_978 = 0;
+ _actionIdx1 = 0;
+ _field_980 = 0;
+ _field_984 = 0;
+ _field_988 = 0;
+ _field_98C = 0;
+ _field_990 = 0;
+ _field_994 = 0;
+ _field_998 = 0;
+ _field_99C = 0;
+ _field_9A0 = 0;
+}
+
bool Actor::isResourcePresent() const {
if (_status != kActorStatus9)
return false;
diff --git a/engines/asylum/resources/actor.h b/engines/asylum/resources/actor.h
index ec82180e83..a369ddeb7e 100644
--- a/engines/asylum/resources/actor.h
+++ b/engines/asylum/resources/actor.h
@@ -249,9 +249,9 @@ public:
Common::String toString(bool shortString = true);
/**
- * Clears actor data fields (TODO what are those fields?)
+ * Clears actor data fields
*/
- void clearFields() { memset(&_field_970, 0, 52); }
+ void clearFields();
// Unknown methods
bool process(const Common::Point &point);
Commit: 8596b8f213c6e55676f14c17711639cde24b2cbb
https://github.com/scummvm/scummvm/commit/8596b8f213c6e55676f14c17711639cde24b2cbb
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:59+02:00
Commit Message:
ASYLUM: Update use of shared data in Actor::updateStatus12_Chapter2()
Changed paths:
engines/asylum/resources/actor.cpp
diff --git a/engines/asylum/resources/actor.cpp b/engines/asylum/resources/actor.cpp
index a7966d0d56..8c2e613ede 100644
--- a/engines/asylum/resources/actor.cpp
+++ b/engines/asylum/resources/actor.cpp
@@ -1966,11 +1966,11 @@ void Actor::updateStatus12_Chapter2() {
// Face actor
faceTarget(getScene()->getPlayerIndex(), kDirectionFromActor);
- // FIXME: another field is used (not _data!)
- //if (_data.field_10[_index + 10] > 0) {
- // _direction = (ActorDirection)(_direction + 4);
- // _data.field_10[_index + 10] -= 1;
- //}
+ int32 data = getSharedData()->getData(_index + 14);
+ if (data > 0) {
+ _direction = (ActorDirection)(_direction + 4);
+ getSharedData()->setData(_index + 14, data - 1);
+ }
// Compute coordinates and distance
Actor *player = getScene()->getActor();
@@ -1985,15 +1985,15 @@ void Actor::updateStatus12_Chapter2() {
absX = absY;
if (!distance)
- distance = 0; // FIXME: get proper distance value
+ error("[Actor::updateStatus12_Chapter2] Invalid distance");
if (absX >= 50) {
playSounds(_direction, abs(distance));
} else {
_frameIndex = 0;
- // FIXME: another field is used (not _data!)
- //_data.field_10[2 * _index + 15] = player->getPoint1()->x - _point1.x;
- //_data.field_10[2 * _index + 16] = player->getPoint1()->y - _point1.y;
+
+ getSharedData()->setData(2 * _index + 19, player->getPoint1()->x - _point1.x);
+ getSharedData()->setData(2 * _index + 20, player->getPoint1()->y - _point1.y);
updateStatus(kActorStatus18);
}
Commit: cae5eaa927626fb7e9a110edcaee7d06a72bd275
https://github.com/scummvm/scummvm/commit/cae5eaa927626fb7e9a110edcaee7d06a72bd275
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:59+02:00
Commit Message:
ASYLUM: Implement Actor::checkPath()
Changed paths:
engines/asylum/resources/actor.cpp
engines/asylum/resources/actor.h
engines/asylum/staticres.h
diff --git a/engines/asylum/resources/actor.cpp b/engines/asylum/resources/actor.cpp
index 8c2e613ede..618e255eaa 100644
--- a/engines/asylum/resources/actor.cpp
+++ b/engines/asylum/resources/actor.cpp
@@ -2534,6 +2534,27 @@ bool Actor::processAction4(const Common::Point &source, const Common::Point &des
error("[Actor::processAction4] Not implemented");
}
+bool Actor::checkPath(Common::Array<ActionArea *> *actions, const Common::Point &point, uint32 index, uint32 loopcount) {
+ if (loopcount <= 1)
+ return true;
+
+ // Initialize base coordinates
+ Common::Point basePoint = deltaPointsArray[index] + point;
+ Common::Rect rect = getWorld()->sceneRects[getWorld()->sceneRectIdx];
+
+ for (uint32 i = 1; i < loopcount; i++) {
+ if (!checkAllActions(basePoint, actions))
+ break;
+
+ if (!rect.contains(basePoint))
+ return false;
+
+ basePoint += deltaPointsArray[index];
+ }
+
+ return true;
+}
+
bool Actor::checkAllActions(const Common::Point &pt, Common::Array<ActionArea *> *actions) {
if (actions->size() == 0)
return false;
diff --git a/engines/asylum/resources/actor.h b/engines/asylum/resources/actor.h
index a369ddeb7e..47f4da6e47 100644
--- a/engines/asylum/resources/actor.h
+++ b/engines/asylum/resources/actor.h
@@ -443,6 +443,7 @@ private:
bool processAction2(const Common::Point &source, const Common::Point &destination, Common::Array<int> *actions);
bool processAction3(const Common::Point &source, const Common::Point &destination, Common::Array<int> *actions);
bool processAction4(const Common::Point &source, const Common::Point &destination, Common::Array<int> *actions);
+ bool checkPath(Common::Array<ActionArea *> *actions, const Common::Point &point, uint32 index, uint32 loopcount);
bool checkAllActions(const Common::Point &pt, Common::Array<ActionArea *> *actions);
//////////////////////////////////////////////////////////////////////////
diff --git a/engines/asylum/staticres.h b/engines/asylum/staticres.h
index 3eb1ac26f6..1bed1a9870 100644
--- a/engines/asylum/staticres.h
+++ b/engines/asylum/staticres.h
@@ -23,6 +23,8 @@
#ifndef ASYLUM_STATICRES_H
#define ASYLUM_STATICRES_H
+#include "common/rect.h"
+
namespace Asylum {
/** This fixes the menu icons text x position on screen */
@@ -68,18 +70,15 @@ const int encounterPortrait2Index[80] = {50, 51, 52, 33, 34, 35, 36, 37, 38, 39,
4, 5, 6, 53, 51, 52, 53, 54, 55, 54};
// Delta array for points
-static const struct {
- int x;
- int y;
-} deltaPointsArray[8] = {
- {0, 0xFFFFFFFF},
- {0xFFFFFFFF, 0xFFFFFFFF},
- {0xFFFFFFFF, 0},
- {0xFFFFFFFF, 1},
- {0, 1},
- {1, 1},
- {1, 0},
- {1, 0xFFFFFFFF}
+static Common::Point deltaPointsArray[8] = {
+ Common::Point( 0, -1),
+ Common::Point(-1, -1),
+ Common::Point(-1, 0),
+ Common::Point(-1, 1),
+ Common::Point( 0, 1),
+ Common::Point( 1, 1),
+ Common::Point( 1, 0),
+ Common::Point( 1, -1)
};
// We hardcode all the text resources here. It makes the resulting code easier,
Commit: 6b20fdb4e4eb331ba85e76f75beb2d69e921334b
https://github.com/scummvm/scummvm/commit/6b20fdb4e4eb331ba85e76f75beb2d69e921334b
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:36:59+02:00
Commit Message:
ASYLUM: Rename arrays holding the distances for each actor frame index
Changed paths:
engines/asylum/resources/actor.cpp
engines/asylum/resources/actor.h
diff --git a/engines/asylum/resources/actor.cpp b/engines/asylum/resources/actor.cpp
index 618e255eaa..fe70182c85 100644
--- a/engines/asylum/resources/actor.cpp
+++ b/engines/asylum/resources/actor.cpp
@@ -75,9 +75,9 @@ Actor::Actor(AsylumEngine *engine, ActorIndex index) : _vm(engine), _index(index
_field_650 = 0;
memset(_graphicResourceIds, 0 , sizeof(_graphicResourceIds));
memset(&_name, 0, sizeof(_name));
- memset(&_field_830, 0, sizeof(_field_830));
- memset(&_field_880, 0, sizeof(_field_880));
- memset(&_field_8D0, 0, sizeof(_field_8D0));
+ memset(&_distancesEO, 0, sizeof(_distancesEO));
+ memset(&_distancesNS, 0, sizeof(_distancesNS));
+ memset(&_distancesNSEO, 0, sizeof(_distancesNSEO));
_actionIdx2 = 0;
_field_924 = 0;
_lastScreenUpdate = 0;
@@ -182,13 +182,13 @@ void Actor::load(Common::SeekableReadStream *stream) {
stream->read(_name, sizeof(_name));
for (int32 i = 0; i < 20; i++)
- _field_830[i] = stream->readSint32LE();
+ _distancesEO[i] = stream->readSint32LE();
for (int32 i = 0; i < 20; i++)
- _field_880[i] = stream->readSint32LE();
+ _distancesNS[i] = stream->readSint32LE();
for (int32 i = 0; i < 20; i++)
- _field_8D0[i] = stream->readSint32LE();
+ _distancesNSEO[i] = stream->readSint32LE();
_actionIdx2 = stream->readSint32LE();
_field_924 = stream->readSint32LE();
@@ -2772,36 +2772,38 @@ int32 Actor::getDistance() const {
case kDirectionNO:
case kDirectionSO:
- return -_field_8D0[index];
+ return -_distancesNSEO[index];
case kDirectionO:
- return -_field_830[index];
+ return -_distancesEO[index];
case kDirectionSE:
case kDirectionNE:
- return _field_8D0[index];
+ return _distancesNSEO[index];
case kDirectionE:
- return _field_830[index];
+ return _distancesEO[index];
}
}
int32 Actor::getDistanceForFrame(ActorDirection dir, uint32 frameIndex) {
switch (dir) {
default:
+ error("[Actor::getDistanceForFrame] Invalid direction");
+
case kDirectionN:
case kDirectionS:
- return _field_880[frameIndex];
+ return _distancesNS[frameIndex];
case kDirectionNO:
case kDirectionSO:
case kDirectionSE:
case kDirectionNE:
- return _field_8D0[frameIndex];
+ return _distancesNSEO[frameIndex];
case kDirectionO:
case kDirectionE:
- return _field_830[frameIndex];
+ return _distancesEO[frameIndex];
}
}
diff --git a/engines/asylum/resources/actor.h b/engines/asylum/resources/actor.h
index 47f4da6e47..9efa6e352d 100644
--- a/engines/asylum/resources/actor.h
+++ b/engines/asylum/resources/actor.h
@@ -347,9 +347,9 @@ private:
uint32 _field_650;
ResourceId _graphicResourceIds[55];
char _name[256];
- int32 _field_830[20];
- int32 _field_880[20];
- int32 _field_8D0[20];
+ int32 _distancesEO[20];
+ int32 _distancesNS[20];
+ int32 _distancesNSEO[20];
int32 _actionIdx2;
int32 _field_924;
uint32 _lastScreenUpdate;
Commit: 78681cf803275423560ec8747aef690831b4b681
https://github.com/scummvm/scummvm/commit/78681cf803275423560ec8747aef690831b4b681
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:37:00+02:00
Commit Message:
ASYLUM: Correct usage and implementation of Actor::getDistance()
Changed paths:
engines/asylum/resources/actor.cpp
engines/asylum/resources/actor.h
diff --git a/engines/asylum/resources/actor.cpp b/engines/asylum/resources/actor.cpp
index fe70182c85..9bd5a33013 100644
--- a/engines/asylum/resources/actor.cpp
+++ b/engines/asylum/resources/actor.cpp
@@ -475,11 +475,7 @@ void Actor::update() {
case kActorStatus1: {
uint32 index = (_frameIndex >= _frameCount) ? 2 * _frameCount - (_frameIndex + 1) : _frameIndex;
- // FIXME the original tests for != 0 and sets to an unknown value (offset to actor in structure?)
- uint32 dist = abs((double)getDistanceForFrame(_direction, index));
- if (!dist)
- error("[Actor::update] Invalid distance (kActorStatus1)");
-
+ uint32 dist = abs((double)getDistance(_direction, index));
Common::Point point = _point1 + _point2;
if (process_408B20(&point, _direction, dist, false)) {
@@ -513,10 +509,7 @@ void Actor::update() {
case kActorStatus13: {
uint32 index = (_frameIndex >= _frameCount) ? 2 * _frameCount - (_frameIndex + 1) : _frameIndex;
- // FIXME the original tests for != 0 and sets to an unknown value (offset to actor in structure?)
- uint32 dist = abs((double)getDistanceForFrame(_direction, index));
- if (!dist)
- error("[Actor::update] Invalid distance (kActorStatus2/kActorStatus13)");
+ uint32 dist = abs((double)getDistance(_direction, index));
Common::Point point = _point1 + _point2;
Common::Point current = _data.points[_data.current];
@@ -1961,7 +1954,7 @@ void Actor::updateStatus12_Chapter2() {
if (_frameIndex >= _frameCount)
frameIndex = 2 * _frameCount - _frameIndex - 1;
- int32 distance = getDistanceForFrame(_direction, frameIndex);
+ uint32 distance = abs((double)getDistance(_direction, frameIndex));
// Face actor
faceTarget(getScene()->getPlayerIndex(), kDirectionFromActor);
@@ -1984,11 +1977,8 @@ void Actor::updateStatus12_Chapter2() {
if (absX <= absY)
absX = absY;
- if (!distance)
- error("[Actor::updateStatus12_Chapter2] Invalid distance");
-
if (absX >= 50) {
- playSounds(_direction, abs(distance));
+ playSounds(_direction, distance);
} else {
_frameIndex = 0;
@@ -2758,31 +2748,32 @@ DrawFlags Actor::getGraphicsFlags() {
return kDrawFlagMirrorLeftRight;
}
-int32 Actor::getDistance() const {
- int32 index = (_frameIndex >= _frameCount) ? (2 * _frameCount) - (_frameIndex + 1) : _frameIndex;
-
- if (index >= 20)
- error("[Actor::getDistance] Invalid index calculation (was: %d, max: 20)", index);
-
+int32 Actor::getDistance(ActorDirection dir, uint32 frameIndex) const {
switch (_direction) {
default:
+ error("[Actor::getDistanceFromFrame] Invalid direction");
+
+ // The original return 0 and then checks the value and replaces it by the alternate value stored in EDX
+ // We skip that crap and directly returns the proper value
case kDirectionN:
+ return -_distancesNS[frameIndex];
+
case kDirectionS:
- return 0;
+ return _distancesNS[frameIndex];
case kDirectionNO:
case kDirectionSO:
- return -_distancesNSEO[index];
+ return -_distancesNSEO[frameIndex];
case kDirectionO:
- return -_distancesEO[index];
+ return -_distancesEO[frameIndex];
case kDirectionSE:
case kDirectionNE:
- return _distancesNSEO[index];
+ return _distancesNSEO[frameIndex];
case kDirectionE:
- return _distancesEO[index];
+ return _distancesEO[frameIndex];
}
}
diff --git a/engines/asylum/resources/actor.h b/engines/asylum/resources/actor.h
index 9efa6e352d..0bcfaf69c7 100644
--- a/engines/asylum/resources/actor.h
+++ b/engines/asylum/resources/actor.h
@@ -516,7 +516,7 @@ private:
*
* @return The distance.
*/
- int32 getDistance() const;
+ int32 getDistance(ActorDirection direction, uint32 frameIndex) const;
/**
* Gets the distance for a frame.
Commit: 345d0cf909e61e283ce61b044ea162ba7a2707c0
https://github.com/scummvm/scummvm/commit/345d0cf909e61e283ce61b044ea162ba7a2707c0
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:37:00+02:00
Commit Message:
ASYLUM: Merge getDistanceForFrame() and getDistance()
Changed paths:
engines/asylum/resources/actor.cpp
engines/asylum/resources/actor.h
diff --git a/engines/asylum/resources/actor.cpp b/engines/asylum/resources/actor.cpp
index 9bd5a33013..90c52e2b5c 100644
--- a/engines/asylum/resources/actor.cpp
+++ b/engines/asylum/resources/actor.cpp
@@ -475,7 +475,7 @@ void Actor::update() {
case kActorStatus1: {
uint32 index = (_frameIndex >= _frameCount) ? 2 * _frameCount - (_frameIndex + 1) : _frameIndex;
- uint32 dist = abs((double)getDistance(_direction, index));
+ uint32 dist = abs((double)getDistanceForFrame(_direction, index));
Common::Point point = _point1 + _point2;
if (process_408B20(&point, _direction, dist, false)) {
@@ -509,7 +509,7 @@ void Actor::update() {
case kActorStatus13: {
uint32 index = (_frameIndex >= _frameCount) ? 2 * _frameCount - (_frameIndex + 1) : _frameIndex;
- uint32 dist = abs((double)getDistance(_direction, index));
+ uint32 dist = abs((double)getDistanceForFrame(_direction, index));
Common::Point point = _point1 + _point2;
Common::Point current = _data.points[_data.current];
@@ -1954,7 +1954,7 @@ void Actor::updateStatus12_Chapter2() {
if (_frameIndex >= _frameCount)
frameIndex = 2 * _frameCount - _frameIndex - 1;
- uint32 distance = abs((double)getDistance(_direction, frameIndex));
+ uint32 distance = abs((double)getDistanceForFrame(_direction, frameIndex));
// Face actor
faceTarget(getScene()->getPlayerIndex(), kDirectionFromActor);
@@ -2748,36 +2748,7 @@ DrawFlags Actor::getGraphicsFlags() {
return kDrawFlagMirrorLeftRight;
}
-int32 Actor::getDistance(ActorDirection dir, uint32 frameIndex) const {
- switch (_direction) {
- default:
- error("[Actor::getDistanceFromFrame] Invalid direction");
-
- // The original return 0 and then checks the value and replaces it by the alternate value stored in EDX
- // We skip that crap and directly returns the proper value
- case kDirectionN:
- return -_distancesNS[frameIndex];
-
- case kDirectionS:
- return _distancesNS[frameIndex];
-
- case kDirectionNO:
- case kDirectionSO:
- return -_distancesNSEO[frameIndex];
-
- case kDirectionO:
- return -_distancesEO[frameIndex];
-
- case kDirectionSE:
- case kDirectionNE:
- return _distancesNSEO[frameIndex];
-
- case kDirectionE:
- return _distancesEO[frameIndex];
- }
-}
-
-int32 Actor::getDistanceForFrame(ActorDirection dir, uint32 frameIndex) {
+int32 Actor::getDistanceForFrame(ActorDirection dir, uint32 frameIndex) const {
switch (dir) {
default:
error("[Actor::getDistanceForFrame] Invalid direction");
diff --git a/engines/asylum/resources/actor.h b/engines/asylum/resources/actor.h
index 0bcfaf69c7..faf7aba875 100644
--- a/engines/asylum/resources/actor.h
+++ b/engines/asylum/resources/actor.h
@@ -511,22 +511,15 @@ private:
*/
DrawFlags getGraphicsFlags();
- /**
- * Gets a distance depending on actor direction
- *
- * @return The distance.
- */
- int32 getDistance(ActorDirection direction, uint32 frameIndex) const;
-
/**
* Gets the distance for a frame.
*
* @param direction The direction.
* @param frameIndex Zero-based index of the frame.
*
- * @return The distance for frame.
+ * @return The distance for the frame.
*/
- int32 getDistanceForFrame(ActorDirection direction, uint32 frameIndex);
+ int32 getDistanceForFrame(ActorDirection direction, uint32 frameIndex) const;
/**
* Updates the coordinates depending on the direction.
Commit: 010fd87b5917b22f3541677a01c3989929faf243
https://github.com/scummvm/scummvm/commit/010fd87b5917b22f3541677a01c3989929faf243
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:37:00+02:00
Commit Message:
ASYLUM: Implement Actor::processAction* helper functions
Changed paths:
engines/asylum/resources/actor.cpp
engines/asylum/resources/actor.h
diff --git a/engines/asylum/resources/actor.cpp b/engines/asylum/resources/actor.cpp
index 90c52e2b5c..0b8be86b97 100644
--- a/engines/asylum/resources/actor.cpp
+++ b/engines/asylum/resources/actor.cpp
@@ -1085,10 +1085,10 @@ bool Actor::process(const Common::Point &point) {
if (abs(sum.x - point.x) > abs(sum.y - point.y)) {
if (sum.x <= point.x) {
- if (!processAction1(sum, point, &actions))
+ if (!processActionLeft(sum, point, &actions))
return false;
} else {
- if (!processAction2(sum, point, &actions))
+ if (!processActionAll(sum, point, &actions))
return false;
}
@@ -1098,7 +1098,7 @@ bool Actor::process(const Common::Point &point) {
}
if (sum.y > point.y) {
- if (!processAction3(sum, point, &actions))
+ if (!processActionTop(sum, point, &actions))
return false;
updateFromDirection(_data.directions[0]);
@@ -1107,7 +1107,7 @@ bool Actor::process(const Common::Point &point) {
}
// last case: sum.y < point.y
- if (!processAction4(sum, point, &actions))
+ if (!processActionDown(sum, point, &actions))
return false;
updateFromDirection(_data.directions[0]);
@@ -2508,20 +2508,137 @@ void Actor::updateNumbers(int32 reaction, const Common::Point &point) {
//////////////////////////////////////////////////////////////////////////
// Path finding functions
//////////////////////////////////////////////////////////////////////////
-bool Actor::processAction1(const Common::Point &source, const Common::Point &destination, Common::Array<int> *actions) {
- error("[Actor::processAction1] Not implemented");
+bool Actor::processActionLeft(Common::Point source, const Common::Point &destination, Common::Array<int> *actions) {
+ // Reset pathfinding data
+ _data.count = 0;
+ _data.current = 0;
+
+ bool flag = false;
+ Common::Point src = source;
+
+ for (uint32 i = 0; i < 60; i++) {
+
+ // Note: this is handled differently from other processAction functions
+ // as we break instead of checking the other actors
+ if (!processAction(source, actions, &src, kDirectionE, destination, &flag)
+ && !processAction(source, actions, &src, kDirectionNE, destination, &flag)
+ && !processAction(source, actions, &src, kDirectionSE, destination, &flag)
+ && !processAction(source, actions, &src, kDirectionN, destination, &flag)
+ && !processAction(source, actions, &src, kDirectionS, destination, &flag))
+ break;
+
+ // Update source point after all processing
+ source = src;
+
+ if (flag)
+ return true;
+ }
+
+ return false;
}
-bool Actor::processAction2(const Common::Point &source, const Common::Point &destination, Common::Array<int> *actions) {
- error("[Actor::processAction2] Not implemented");
+bool Actor::processActionAll(Common::Point source, const Common::Point &destination, Common::Array<int> *actions) {
+ // Reset pathfinding data
+ _data.count = 0;
+ _data.current = 0;
+
+ bool flag = false;
+ Common::Point src = source;
+
+ for (uint32 i = 0; i < 60; i++) {
+ if (!processAction(source, actions, &src, kDirectionO, destination, &flag)
+ && !processAction(source, actions, &src, kDirectionNO, destination, &flag)
+ && !processAction(source, actions, &src, kDirectionSO, destination, &flag)) {
+ if (src.y <= destination.y) {
+ if (!processAction(source, actions, &src, kDirectionS, destination, &flag)
+ && !processAction(source, actions, &src, kDirectionN, destination, &flag)
+ && !processAction(source, actions, &src, kDirectionSE, destination, &flag)
+ && !processAction(source, actions, &src, kDirectionE, destination, &flag)
+ && !processAction(source, actions, &src, kDirectionNE, destination, &flag))
+ continue;
+ } else {
+ if (!processAction(source, actions, &src, kDirectionN, destination, &flag)
+ && !processAction(source, actions, &src, kDirectionS, destination, &flag)
+ && !processAction(source, actions, &src, kDirectionNE, destination, &flag)
+ && !processAction(source, actions, &src, kDirectionE, destination, &flag)
+ && !processAction(source, actions, &src, kDirectionSE, destination, &flag))
+ continue;
+ }
+ }
+
+ // Update source point after all processing
+ source = src;
+
+ if (flag)
+ return true;
+ }
+
+ return false;
}
-bool Actor::processAction3(const Common::Point &source, const Common::Point &destination, Common::Array<int> *actions) {
- error("[Actor::processAction3] Not implemented");
+bool Actor::processActionTop(Common::Point source, const Common::Point &destination, Common::Array<int> *actions) {
+ // Reset pathfinding data
+ _data.count = 0;
+ _data.current = 0;
+
+ bool flag = false;
+ Common::Point src = source;
+
+ for (uint32 i = 0; i < 60; i++) {
+ if (!processAction(source, actions, &src, kDirectionN, destination, &flag)) {
+ if (src.x >= destination.x) {
+ if (!processAction(source, actions, &src, kDirectionNO, destination, &flag)
+ && !processAction(source, actions, &src, kDirectionO, destination, &flag)
+ && !processAction(source, actions, &src, kDirectionNE, destination, &flag)
+ && !processAction(source, actions, &src, kDirectionE, destination, &flag))
+ continue;
+ } else {
+ if (!processAction(source, actions, &src, kDirectionNE, destination, &flag)
+ && !processAction(source, actions, &src, kDirectionE, destination, &flag)
+ && !processAction(source, actions, &src, kDirectionNO, destination, &flag)
+ && !processAction(source, actions, &src, kDirectionO, destination, &flag))
+ continue;
+ }
+ }
+
+ // Update source point after all processing
+ source = src;
+
+ if (flag)
+ return true;
+ }
+
+ return false;
+}
+
+bool Actor::processActionDown(Common::Point source, const Common::Point &destination, Common::Array<int> *actions) {
+ // Reset pathfinding data
+ _data.count = 0;
+ _data.current = 0;
+
+ bool flag = false;
+ Common::Point src = source;
+
+ for (uint32 i = 0; i < 60; i++) {
+ if (!processAction(source, actions, &src, kDirectionS, destination, &flag)
+ && !processAction(source, actions, &src, kDirectionSE, destination, &flag)
+ && !processAction(source, actions, &src, kDirectionSO, destination, &flag)
+ && !processAction(source, actions, &src, kDirectionE, destination, &flag)
+ && !processAction(source, actions, &src, kDirectionO, destination, &flag))
+ continue;
+
+ // Update source point after all processing
+ source = src;
+
+ if (flag)
+ return true;
+ }
+
+ return false;
}
-bool Actor::processAction4(const Common::Point &source, const Common::Point &destination, Common::Array<int> *actions) {
- error("[Actor::processAction4] Not implemented");
+bool Actor::processAction(const Common::Point &source, Common::Array<int> *actions, Common::Point *point, ActorDirection direction, const Common::Point &destination, bool *flag) {
+ error("[Actor::processAction] Not implemented");
}
bool Actor::checkPath(Common::Array<ActionArea *> *actions, const Common::Point &point, uint32 index, uint32 loopcount) {
diff --git a/engines/asylum/resources/actor.h b/engines/asylum/resources/actor.h
index faf7aba875..51b9422041 100644
--- a/engines/asylum/resources/actor.h
+++ b/engines/asylum/resources/actor.h
@@ -439,10 +439,11 @@ private:
// Path finding functions
//////////////////////////////////////////////////////////////////////////
uint32 _frameNumber;
- bool processAction1(const Common::Point &source, const Common::Point &destination, Common::Array<int> *actions);
- bool processAction2(const Common::Point &source, const Common::Point &destination, Common::Array<int> *actions);
- bool processAction3(const Common::Point &source, const Common::Point &destination, Common::Array<int> *actions);
- bool processAction4(const Common::Point &source, const Common::Point &destination, Common::Array<int> *actions);
+ bool processActionLeft(Common::Point source, const Common::Point &destination, Common::Array<int> *actions);
+ bool processActionAll(Common::Point source, const Common::Point &destination, Common::Array<int> *actions);
+ bool processActionTop(Common::Point source, const Common::Point &destination, Common::Array<int> *actions);
+ bool processActionDown(Common::Point source, const Common::Point &destination, Common::Array<int> *actions);
+ bool processAction(const Common::Point &source, Common::Array<int> *actions, Common::Point *point, ActorDirection direction, const Common::Point &destination, bool *flag);
bool checkPath(Common::Array<ActionArea *> *actions, const Common::Point &point, uint32 index, uint32 loopcount);
bool checkAllActions(const Common::Point &pt, Common::Array<ActionArea *> *actions);
Commit: 2a4cf12823d5511904e010c43f3b1ea198dec809
https://github.com/scummvm/scummvm/commit/2a4cf12823d5511904e010c43f3b1ea198dec809
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:37:00+02:00
Commit Message:
ASYLUM: Fix showing of debug regions
Changed paths:
engines/asylum/console.cpp
engines/asylum/puzzles/tictactoe.cpp
engines/asylum/system/screen.cpp
engines/asylum/views/scene.cpp
diff --git a/engines/asylum/console.cpp b/engines/asylum/console.cpp
index 6983160494..806bd1a55a 100644
--- a/engines/asylum/console.cpp
+++ b/engines/asylum/console.cpp
@@ -42,9 +42,11 @@
namespace Asylum {
-extern int32 g_debugPolygons;
-extern int32 g_debugObjects;
-extern int32 g_debugScrolling;
+extern int g_debugActors;
+extern int g_debugDrawRects;
+extern int g_debugObjects;
+extern int g_debugPolygons;
+extern int g_debugScrolling;
const ResourcePackId puzzleToScenes[17] = {
kResourcePackTowerCells, // VCR
@@ -91,8 +93,10 @@ Console::Console(AsylumEngine *engine) : _vm(engine) {
DCmd_Register("toggle_flag", WRAP_METHOD(Console, cmdToggleFlag));
// Variables
- DVar_Register("show_polygons", &g_debugPolygons, DVAR_INT, 0);
- DVar_Register("show_objects", &g_debugObjects, DVAR_INT, 0);
+ DVar_Register("show_actors", &g_debugActors, DVAR_INT, 0);
+ DVar_Register("show_objects", &g_debugObjects, DVAR_INT, 0);
+ DVar_Register("show_polygons", &g_debugPolygons, DVAR_INT, 0);
+ DVar_Register("show_drawrects", &g_debugDrawRects, DVAR_INT, 0);
DVar_Register("use_scrolling", &g_debugScrolling, DVAR_INT, 0);
}
@@ -112,8 +116,10 @@ bool Console::cmdHelp(int, const char **) {
DebugPrintf(" debugflag_list - Lists the available debug flags and their status\n");
DebugPrintf(" debugflag_enable - Enables a debug flag\n");
DebugPrintf(" debugflag_disable - Disables a debug flag\n");
+ DebugPrintf(" show_actors - Show actors\n");
+ DebugPrintf(" show_objects - Show objects\n");
DebugPrintf(" show_polygons - Show polygons\n");
- DebugPrintf(" show_objects - Show objects\n");
+ DebugPrintf(" show_drawrects - Show drawing rects\n");;
DebugPrintf(" use_scrolling - Use scrolling\n");
DebugPrintf("\n");
DebugPrintf("Commands\n");
diff --git a/engines/asylum/puzzles/tictactoe.cpp b/engines/asylum/puzzles/tictactoe.cpp
index 4ce9c9a0c4..7aad84630d 100644
--- a/engines/asylum/puzzles/tictactoe.cpp
+++ b/engines/asylum/puzzles/tictactoe.cpp
@@ -33,7 +33,7 @@
namespace Asylum {
-extern int32 g_debugPolygons;
+extern int g_debugPolygons;
const Common::Point puzzleTicTacToePolygons[36] = {
Common::Point( 27, 381), Common::Point(172, 368), Common::Point(190, 474), Common::Point( 36, 476),
diff --git a/engines/asylum/system/screen.cpp b/engines/asylum/system/screen.cpp
index 531e88c2db..c73f4f5ace 100644
--- a/engines/asylum/system/screen.cpp
+++ b/engines/asylum/system/screen.cpp
@@ -35,6 +35,8 @@
namespace Asylum {
+extern int g_debugDrawRects;
+
Screen::Screen(AsylumEngine *vm) : _vm(vm) ,
_useColorKey(false), _transTableCount(0), _transTableIndex(NULL), _transTableData(NULL), _transTableBuffer(NULL) {
_backBuffer.create(640, 480, Graphics::PixelFormat::createFormatCLUT8());
diff --git a/engines/asylum/views/scene.cpp b/engines/asylum/views/scene.cpp
index b86c6b530d..7f7c90404c 100644
--- a/engines/asylum/views/scene.cpp
+++ b/engines/asylum/views/scene.cpp
@@ -52,8 +52,10 @@ namespace Asylum {
#define SCREEN_EDGES 40
#define SCROLL_STEP 10
-int g_debugPolygons;
+int g_debugActors;
+int g_debugDrawRects;
int g_debugObjects;
+int g_debugPolygons;
int g_debugScrolling;
Scene::Scene(AsylumEngine *engine): _vm(engine),
@@ -669,12 +671,6 @@ bool Scene::updateScene() {
MESURE_TICKS(updateAmbientSounds);
MESURE_TICKS(updateMusic);
MESURE_TICKS(updateAdjustScreen);
-
- // Update Debug
- if (g_debugPolygons)
- debugShowPolygons();
- if (g_debugObjects)
- debugShowObjects();
}
return getScript()->process();
@@ -2383,6 +2379,16 @@ bool Scene::drawScene() {
_vm->screen()->drawGraphicsInQueue();
+ // Show debug information
+ if (g_debugScrolling)
+ debugScreenScrolling();
+ if (g_debugActors)
+ debugShowActors();
+ if (g_debugPolygons)
+ debugShowPolygons();
+ if (g_debugObjects)
+ debugShowObjects();
+
return false;
}
@@ -2667,11 +2673,11 @@ void Scene::debugShowPolygons() {
// Draw all lines in Polygon
for (uint32 i = 0; i < poly.count(); i++) {
- surface.drawLine(
- poly.points[i].x - poly.boundingRect.left,
- poly.points[i].y - poly.boundingRect.top,
- poly.points[(i+1) % poly.count()].x - poly.boundingRect.left,
- poly.points[(i+1) % poly.count()].y - poly.boundingRect.top, 0xFF);
+ surface.drawLine(poly.points[i].x - poly.boundingRect.left,
+ poly.points[i].y - poly.boundingRect.top,
+ poly.points[(i+1) % poly.count()].x - poly.boundingRect.left,
+ poly.points[(i+1) % poly.count()].y - poly.boundingRect.top,
+ 0xFF);
}
getScreen()->copyToBackBufferClipped(&surface, poly.boundingRect.left, poly.boundingRect.top);
@@ -2689,7 +2695,7 @@ void Scene::debugShowObjects() {
Graphics::Surface surface;
Object *object = _ws->objects[p];
- if (object->flags & 0x20) {
+ if (object->isOnScreen()) {
surface.create(object->getBoundingRect()->right - object->getBoundingRect()->left + 1,
object->getBoundingRect()->bottom - object->getBoundingRect()->top + 1,
Graphics::PixelFormat::createFormatCLUT8());
@@ -2707,12 +2713,12 @@ void Scene::debugShowActors() {
Graphics::Surface surface;
Actor *a = _ws->actors[p];
- if (a->flags & 2) {
+ if (a->isOnScreen()) {
surface.create(a->getBoundingRect()->right - a->getBoundingRect()->left + 1,
a->getBoundingRect()->bottom - a->getBoundingRect()->top + 1,
Graphics::PixelFormat::createFormatCLUT8());
- surface.frameRect(*a->getBoundingRect(), 0x22);
- getScreen()->copyToBackBufferClipped(&surface, a->getPoint()->x, a->getPoint()->y);
+ surface.frameRect(*a->getBoundingRect(), 0x128);
+ getScreen()->copyToBackBufferClipped(&surface, a->getPoint1()->x, a->getPoint1()->y);
}
surface.free();
Commit: c9d39ce3c297ccc0f35c67af389cb565ad1ece10
https://github.com/scummvm/scummvm/commit/c9d39ce3c297ccc0f35c67af389cb565ad1ece10
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:37:00+02:00
Commit Message:
ASYLUM: Add drawing rects and mask visualization
Changed paths:
engines/asylum/system/screen.cpp
diff --git a/engines/asylum/system/screen.cpp b/engines/asylum/system/screen.cpp
index c73f4f5ace..707bcc8bb4 100644
--- a/engines/asylum/system/screen.cpp
+++ b/engines/asylum/system/screen.cpp
@@ -127,6 +127,9 @@ void Screen::draw(ResourceId resourceId, uint32 frameIndex, const Common::Point
if (!dest.intersects(destMask))
masked = false;
+
+ if (g_debugDrawRects)
+ _backBuffer.frameRect(destMask, 0x125);
}
// Set the color key (always 0 if set)
@@ -534,6 +537,9 @@ void Screen::blit(GraphicFrame *frame, Common::Rect *source, Common::Rect *desti
} else {
bltFast(destination->left, destination->top, frame, source);
}
+
+ if (g_debugDrawRects)
+ _backBuffer.frameRect(*destination, 0x220);
}
void Screen::blitTranstable(byte *dstBuffer, byte *srcBuffer, int16 height, int16 width, int32 srcPitch, int32 dstPitch) {
@@ -661,6 +667,11 @@ void Screen::blitMasked(GraphicFrame *frame, Common::Rect *source, byte *maskDat
// cleanup
delete mirroredBuffer;
+ // Draw debug rects
+ if (g_debugDrawRects) {
+ _backBuffer.frameRect(*destMask, 0x220);
+ }
+
return;
}
Commit: 492eb8a30cd847604f2a6703301e22dd58e213a2
https://github.com/scummvm/scummvm/commit/492eb8a30cd847604f2a6703301e22dd58e213a2
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:37:00+02:00
Commit Message:
ASYLUM: Cleanup Scene::processUpdateList() and Scene::pointIntersectsRect()
Changed paths:
engines/asylum/views/scene.cpp
diff --git a/engines/asylum/views/scene.cpp b/engines/asylum/views/scene.cpp
index 7f7c90404c..598c92a751 100644
--- a/engines/asylum/views/scene.cpp
+++ b/engines/asylum/views/scene.cpp
@@ -2019,9 +2019,9 @@ bool Scene::speak(Common::KeyCode code) {
bool Scene::pointIntersectsRect(Common::Point point, Common::Rect rect) {
if (rect.top || rect.left || rect.bottom || rect.right) {
- Common::Rational res((rect.bottom - rect.top) * (point.x - rect.left), rect.right - rect.left);
+ Common::Rational res(rect.height() * (point.x - rect.left), rect.width());
- return (bool)(point.y > rect.top ? 1 + res.toInt() : res.toInt());
+ return (bool)(point.y > (rect.top + res.toInt()));
}
return true;
@@ -2425,7 +2425,6 @@ void Scene::processUpdateList() {
for (uint32 i = 0; i < _updateList.size(); i++) {
Actor *actor = getActor(_updateList[i].index);
int32 priority = _updateList[i].priority;
- Common::Point point;
// Check priority
if (priority < 0) {
@@ -2440,7 +2439,7 @@ void Scene::processUpdateList() {
} else {
actor->setField938(1);
actor->setField934(0);
- point = *actor->getPoint1() + *actor->getPoint2();
+ Common::Point sum = *actor->getPoint1() + *actor->getPoint2();
int32 bottomRight = actor->getPoint1()->y + actor->getBoundingRect()->bottom + 4;
@@ -2459,48 +2458,56 @@ void Scene::processUpdateList() {
continue;
// Check that the rects are contained
- if (!rectIntersect(object->x, object->y, object->x + object->getBoundingRect()->right, object->y + object->getBoundingRect()->bottom,
- actor->getPoint1()->x, actor->getPoint1()->y, actor->getPoint1()->x + actor->getBoundingRect()->right, bottomRight)) {
+ if (!rectIntersect(object->x,
+ object->y,
+ object->x + object->getBoundingRect()->right,
+ object->y + object->getBoundingRect()->bottom,
+ actor->getPoint1()->x,
+ actor->getPoint1()->y,
+ actor->getPoint1()->x + actor->getBoundingRect()->right,
+ bottomRight)) {
if (BYTE1(object->flags) & kObjectFlag20 && !(BYTE1(object->flags) & kObjectFlag80))
- object->flags = BYTE1(object->flags) | kObjectFlag40;
+ BYTE1(object->flags) = BYTE1(object->flags) | kObjectFlag40;
continue;
}
// Check if it intersects with either the object rect or the related polygon
- bool notIntersects = false;
+ bool isMasked = false;
if (object->flags & kObjectFlag2) {
- notIntersects = !pointIntersectsRect(point, *object->getRect());
+ isMasked = !pointIntersectsRect(sum, *object->getRect());
} else if (object->flags & kObjectFlag40) {
PolyDefinitions *poly = &_polygons->entries[object->getPolygonIndex()];
- notIntersects = poly->contains(point);
+ isMasked = poly->contains(sum);
}
// Adjust object flags
- if (BYTE1(object->flags) & kObjectFlag80 || notIntersects) {
+ if (BYTE1(object->flags) & kObjectFlag80 || isMasked) {
if (BYTE1(object->flags) & kObjectFlag20)
- object->flags = BYTE1(object->flags) & kObjectFlagBF | kObjectFlag80;
+ BYTE1(object->flags) = BYTE1(object->flags) & kObjectFlagBF | kObjectFlag80;
} else {
if (BYTE1(object->flags) & kObjectFlag20) {
- object->flags = BYTE1(object->flags) | kObjectFlag40;
+ BYTE1(object->flags) = BYTE1(object->flags) | kObjectFlag40;
}
}
if (LOBYTE(object->flags) & kObjectFlag4) {
- if (notIntersects && (actor->flags & kActorFlagMasked))
- error("[Scene::processUpdateList] Assigning mask to masked character (%s)", actor->getName());
+ if (isMasked) {
+ if (actor->flags & kActorFlagMasked)
+ error("[Scene::processUpdateList] Assigning mask to masked character (%s)", actor->getName());
- object->adjustCoordinates(&point);
- actor->setObjectIndex(j);
- actor->flags |= kActorFlagMasked;
+ // We are masked by the object!
+ actor->setObjectIndex(j);
+ actor->flags |= kActorFlagMasked;
+ }
} else {
- if (notIntersects) {
+ if (isMasked) {
if (actor->getPriority() < object->getPriority()) {
actor->setField934(1);
actor->setPriority(object->getPriority() + 3);
- if (_updateList[i].index > _updateList[0].index) {
+ if (i > 0) {
error("[Scene::processUpdateList] list update not implemented!");
}
}
@@ -2509,7 +2516,7 @@ void Scene::processUpdateList() {
actor->setField934(1);
actor->setPriority(object->getPriority() - 1);
- if (_updateList[i].index > _updateList[0].index) {
+ if (i > 0) {
error("[Scene::processUpdateList] list update not implemented!");
}
}
Commit: f011d8692072ea2161998799cac7acbde7508fe6
https://github.com/scummvm/scummvm/commit/f011d8692072ea2161998799cac7acbde7508fe6
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:37:01+02:00
Commit Message:
ASYLUM: Properly check for object flags when drawing
This fixes the actor appearing on top of the bed at the beginning
Changed paths:
engines/asylum/resources/object.cpp
diff --git a/engines/asylum/resources/object.cpp b/engines/asylum/resources/object.cpp
index 6656d0f78f..e966d13307 100644
--- a/engines/asylum/resources/object.cpp
+++ b/engines/asylum/resources/object.cpp
@@ -185,7 +185,7 @@ void Object::adjustCoordinates(Common::Point *point) {
// Update
//////////////////////////////////////////////////////////////////////////
void Object::draw() {
- if (LOBYTE(flags) & kObjectFlag4)
+ if (flags & kObjectFlag4)
return;
if (BYTE1(flags) & kObjectFlag40)
Commit: c727c909a6c0aecc3da2968803e65c1489089027
https://github.com/scummvm/scummvm/commit/c727c909a6c0aecc3da2968803e65c1489089027
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:37:01+02:00
Commit Message:
ASYLUM: Implement some missing parts of Screen::blitMasked()
Changed paths:
engines/asylum/system/screen.cpp
diff --git a/engines/asylum/system/screen.cpp b/engines/asylum/system/screen.cpp
index 707bcc8bb4..e4c9ad12be 100644
--- a/engines/asylum/system/screen.cpp
+++ b/engines/asylum/system/screen.cpp
@@ -203,11 +203,11 @@ void Screen::clip(Common::Rect *source, Common::Rect *destination, int32 flags)
}
// Check validity
- if (!source->isValidRect())
+ /*if (!source->isValidRect())
error("[Screen::clip] Invalid resulting source rectangle");
if (!destination->isValidRect())
- error("[Screen::clip] Invalid resulting destination rectangle");
+ error("[Screen::clip] Invalid resulting destination rectangle");*/
}
void Screen::takeScreenshot() {
@@ -668,39 +668,80 @@ void Screen::blitMasked(GraphicFrame *frame, Common::Rect *source, byte *maskDat
delete mirroredBuffer;
// Draw debug rects
- if (g_debugDrawRects) {
+ if (g_debugDrawRects)
_backBuffer.frameRect(*destMask, 0x220);
- }
return;
}
if (destination->left > destMask->left) {
- sourceMask->setWidth(sourceMask->width() + destMask->left - destination->left);
maskBufferPtr += (destination->left - destMask->left) / 8 + abs(destination->left - destMask->left) / 8;
+ sourceMask->setWidth(sourceMask->width() + destMask->left - destination->left);
srcMaskLeft = abs(destination->left - destMask->left);
+ destMask->left = destination->left;
}
if (destination->top > destMask->top) {
maskBufferPtr += (destination->top - destMask->top) * maskHeight / 8;
- destMask->top = destination->top;
sourceMask->setHeight(sourceMask->height() + destMask->top - destination->top);
+ destMask->top = destination->top;
}
+ //////////////////////////////////////////////////////////////////////////
+ // Left part
if (destination->left < destMask->left) {
blitRawColorKey((byte *)_backBuffer.pixels + destination->top * _backBuffer.pitch + destination->left,
frameBufferPtr,
source->height(),
destMask->left - destination->left,
- destination->left + frameRight - destMask->left,
- destination->left + _backBuffer.pitch - destMask->left);
+ frameRight + destination->left - destMask->left,
+ _backBuffer.pitch + destination->left - destMask->left);
+
+ if (g_debugDrawRects)
+ _backBuffer.frameRect(Common::Rect(destination->left, destination->top, destMask->left, destination->top + source->height()), 0x10);
- destination->left = destMask->left;
frameBufferPtr += destMask->left - destination->left;
source->setWidth(source->width() + destination->left - destMask->left);
+ destination->left = destMask->left;
}
+ //////////////////////////////////////////////////////////////////////////
+ // Right part
if ((source->width() + destination->left) > (destMask->left + sourceMask->width())) {
+ blitRawColorKey((byte *)_backBuffer.pixels + destination->top * _backBuffer.pitch + destMask->left + sourceMask->width(),
+ frameBufferPtr + destMask->left + sourceMask->width() - destination->left,
+ source->height(),
+ source->width() + destination->left - destMask->left - sourceMask->width(),
+ frameRight + destMask->left + sourceMask->width() - destination->left - source->width(),
+ _backBuffer.pitch + destMask->left + sourceMask->width() - destination->left - source->width());
+
+ if (g_debugDrawRects)
+ _backBuffer.frameRect(Common::Rect(destMask->left, destination->top, destMask->left + source->width(), destination->top + source->height()), 0x36);
+
+ source->setWidth(destMask->left + sourceMask->width() - destination->left);
+ }
+
+ //////////////////////////////////////////////////////////////////////////
+ // Top part
+ if (destination->top < destMask->top) {
+ blitRawColorKey((byte *)_backBuffer.pixels + destination->top * _backBuffer.pitch + destination->left,
+ frameBufferPtr,
+ destMask->top - destination->top,
+ source->width(),
+ frameRight - source->width(),
+ _backBuffer.pitch - source->width());
+
+ if (g_debugDrawRects)
+ _backBuffer.frameRect(Common::Rect(destination->left, destination->top, destination->left + abs(source->width()), destMask->top), 0x23);
+
+ frameBufferPtr += (destMask->top - destination->top) * frameRight;
+ source->setHeight(source->height() + destination->top - destMask->top);
+ destination->top = destMask->top;
+ }
+
+ //////////////////////////////////////////////////////////////////////////
+ // Bottom part
+ if ((source->height() + destination->top) > (destMask->top + sourceMask->height())) {
blitRawColorKey((byte *)_backBuffer.pixels + (destMask->top + sourceMask->height()) * _backBuffer.pitch + destination->left,
frameBufferPtr + (destMask->top + sourceMask->height() - destination->top) * frameRight,
destination->top + source->height() - sourceMask->height() - destMask->top,
@@ -711,6 +752,8 @@ void Screen::blitMasked(GraphicFrame *frame, Common::Rect *source, byte *maskDat
source->setHeight(destMask->top + sourceMask->height() - destination->top);
}
+ //////////////////////////////////////////////////////////////////////////
+ // Masked part
bltMasked(frameBufferPtr,
maskBufferPtr,
source->width(),
@@ -721,12 +764,16 @@ void Screen::blitMasked(GraphicFrame *frame, Common::Rect *source, byte *maskDat
(byte *)_backBuffer.pixels + _backBuffer.pitch * destination->top + destination->left,
_backBuffer.pitch - source->width());
+ // Draw debug rects
+ if (g_debugDrawRects)
+ _backBuffer.frameRect(*destination, 0x128);
+
// Cleanup
delete mirroredBuffer;
}
void Screen::bltMasked(byte *srcBuffer, byte *maskBuffer, int16 width, int16 height, int16 srcPitch, int16 maskPitch, char maskLeft, byte *dstBuffer, int16 dstPitch) {
- error("[Screen::bltMasked] Not implemented");
+ warning("[Screen::bltMasked] Not implemented!");
}
void Screen::blitCrossfade(byte *dstBuffer, byte *srcBuffer, byte *objectBuffer, int widthHeight, uint32 srcPitch, uint32 dstPitch, uint32 objectPitch) {
Commit: faaa1c1426260fe15aad82d31cb12f7e27475651
https://github.com/scummvm/scummvm/commit/faaa1c1426260fe15aad82d31cb12f7e27475651
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:37:01+02:00
Commit Message:
ASYLUM: Correct Screen::clip() and check for valid source rectangle in Screen::draw()
This fixes the crash in the credits screen (although there is still some memory and graphic corruption with transparency table blits)
Changed paths:
engines/asylum/system/screen.cpp
diff --git a/engines/asylum/system/screen.cpp b/engines/asylum/system/screen.cpp
index e4c9ad12be..6c01e86c06 100644
--- a/engines/asylum/system/screen.cpp
+++ b/engines/asylum/system/screen.cpp
@@ -108,6 +108,10 @@ void Screen::draw(ResourceId resourceId, uint32 frameIndex, const Common::Point
clip(&src, &dest, flags);
+ // Check src rectangle
+ if (!src.isValidRect())
+ return;
+
bool masked = false;
if (resourceIdDestination) {
masked = true;
@@ -170,22 +174,21 @@ void Screen::copyBackBufferToScreen() {
void Screen::clip(Common::Rect *source, Common::Rect *destination, int32 flags) {
int32 diffLeft = _clipRect.left - destination->left;
-
if (diffLeft > 0) {
destination->left = _clipRect.left;
if (flags & 2)
source->right -= diffLeft;
else
- source->left += diffLeft;
+ source->left += diffLeft;
}
- int32 diffRight = destination->right - _clipRect.right;
+ int32 diffRight = destination->right - _clipRect.right - 1;
if (diffRight > 0) {
destination->right -= diffRight;
if (flags & 2)
- source->left += diffRight;
+ source->left += diffRight;
else
source->right -= diffRight;
}
@@ -196,18 +199,11 @@ void Screen::clip(Common::Rect *source, Common::Rect *destination, int32 flags)
source->top += diffTop;
}
- int32 diffBottom = destination->bottom - _clipRect.bottom;
+ int32 diffBottom = destination->bottom - _clipRect.bottom - 1;
if (diffBottom > 0) {
source->bottom -= diffBottom;
destination->bottom -= diffBottom;
}
-
- // Check validity
- /*if (!source->isValidRect())
- error("[Screen::clip] Invalid resulting source rectangle");
-
- if (!destination->isValidRect())
- error("[Screen::clip] Invalid resulting destination rectangle");*/
}
void Screen::takeScreenshot() {
@@ -732,7 +728,7 @@ void Screen::blitMasked(GraphicFrame *frame, Common::Rect *source, byte *maskDat
_backBuffer.pitch - source->width());
if (g_debugDrawRects)
- _backBuffer.frameRect(Common::Rect(destination->left, destination->top, destination->left + abs(source->width()), destMask->top), 0x23);
+ _backBuffer.frameRect(Common::Rect(destination->left, destination->top, destination->left + source->width(), destMask->top), 0x23);
frameBufferPtr += (destMask->top - destination->top) * frameRight;
source->setHeight(source->height() + destination->top - destMask->top);
Commit: e44da6e34acd59a2e6fe0a99105c8960c4fab166
https://github.com/scummvm/scummvm/commit/e44da6e34acd59a2e6fe0a99105c8960c4fab166
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:37:01+02:00
Commit Message:
ASYLUM: Update Screen::blitTranstable()
Changed paths:
engines/asylum/system/screen.cpp
diff --git a/engines/asylum/system/screen.cpp b/engines/asylum/system/screen.cpp
index 6c01e86c06..fe96269596 100644
--- a/engines/asylum/system/screen.cpp
+++ b/engines/asylum/system/screen.cpp
@@ -540,9 +540,9 @@ void Screen::blit(GraphicFrame *frame, Common::Rect *source, Common::Rect *desti
void Screen::blitTranstable(byte *dstBuffer, byte *srcBuffer, int16 height, int16 width, int32 srcPitch, int32 dstPitch) {
while (height--) {
- for (int16 i = 0; i < width; i++) {
+ for (int16 i = width; i; --i) {
if (*srcBuffer)
- *dstBuffer = _transTableIndex[*srcBuffer]; // FIXME: is this the correct offset (total table size: 65535)
+ *dstBuffer = _transTableIndex[(*srcBuffer << 8) + *dstBuffer];
dstBuffer++;
srcBuffer++;
@@ -557,7 +557,7 @@ void Screen::blitTranstableMirrored(byte *dstBuffer, byte *srcBuffer, int16 heig
while (height--) {
for (int16 i = width; i; --i) {
if (*srcBuffer)
- *dstBuffer = _transTableIndex[*srcBuffer]; // FIXME: is this the correct offset (total table size: 65535)
+ *dstBuffer = _transTableIndex[(*srcBuffer << 8) + *dstBuffer];
dstBuffer++;
srcBuffer--;
@@ -607,7 +607,7 @@ void Screen::blitRaw(byte *dstBuffer, byte *srcBuffer, int16 height, int16 width
void Screen::blitRawColorKey(byte *dstBuffer, byte *srcBuffer, int16 height, int16 width, int32 srcPitch, int32 dstPitch) {
while (height--) {
- for (int16 i = 0; i < width; i++) {
+ for (int16 i = width; i; --i) {
if (*srcBuffer != 0)
*dstBuffer = *srcBuffer;
Commit: 018ca6a4b2275fd9a5178a66909c5cc8234a515b
https://github.com/scummvm/scummvm/commit/018ca6a4b2275fd9a5178a66909c5cc8234a515b
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:37:01+02:00
Commit Message:
ASYLUM: Add console command to modify actor coordinates
Changed paths:
engines/asylum/console.cpp
diff --git a/engines/asylum/console.cpp b/engines/asylum/console.cpp
index 806bd1a55a..4d15fb494e 100644
--- a/engines/asylum/console.cpp
+++ b/engines/asylum/console.cpp
@@ -200,8 +200,8 @@ bool Console::cmdListActions(int32 argc, const char **argv) {
}
bool Console::cmdListActors(int32 argc, const char **argv) {
- if (argc != 1 && argc != 2) {
- DebugPrintf("Syntax: %s <index> (use nothing for all)\n", argv[0]);
+ if (argc != 1 && argc != 2 && argc != 4) {
+ DebugPrintf("Syntax: %s <index> (use nothing for all) (<x>, <y>)\n", argv[0]);
return true;
}
@@ -209,7 +209,7 @@ bool Console::cmdListActors(int32 argc, const char **argv) {
for (uint32 i = 0; i < getWorld()->actors.size(); i++)
DebugPrintf("%s\n", getWorld()->actors[i]->toString().c_str());
- } else {
+ } else if (argc == 2 || argc == 4) {
int index = atoi(argv[1]);
int maxIndex = getWorld()->actors.size() - 1;
@@ -218,7 +218,18 @@ bool Console::cmdListActors(int32 argc, const char **argv) {
return true;
}
- DebugPrintf("%s\n", getWorld()->actors[index]->toString(false).c_str());
+ if (argc == 2) {
+ DebugPrintf("%s\n", getWorld()->actors[index]->toString(false).c_str());
+ return true;
+ }
+
+ // Adjust actor coordinates
+ int x = atoi(argv[2]);
+ int y = atoi(argv[3]);
+
+ // TODO add error handling
+
+ *getWorld()->actors[index]->getPoint1() = Common::Point(x, y);
}
return true;
Commit: 9be6905934a9578a6b381b004196d751b321745f
https://github.com/scummvm/scummvm/commit/9be6905934a9578a6b381b004196d751b321745f
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:37:01+02:00
Commit Message:
ASYLUM: Mark demo version as "Demo"
Changed paths:
engines/asylum/detection.cpp
diff --git a/engines/asylum/detection.cpp b/engines/asylum/detection.cpp
index f8815815b4..cebba3fd4e 100644
--- a/engines/asylum/detection.cpp
+++ b/engines/asylum/detection.cpp
@@ -40,7 +40,7 @@ static const ADGameDescription gameDescriptions[] = {
{
// Sanitarium - English Demo
"asylum",
- "",
+ "Demo",
{
{"SNTRM.DAT", 0, "6a8079e0b49affc99d148624fbb584a1", 326},
{"RES.000", 0, "57446ce089c6f9decb7f3faf41d09edf", 9022},
Commit: 9805f4cebd3aa2d8db1d962c440b4fceae7ca361
https://github.com/scummvm/scummvm/commit/9805f4cebd3aa2d8db1d962c440b4fceae7ca361
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:37:01+02:00
Commit Message:
ASYLUM: Add some bound checking to ScriptManager::process()
Changed paths:
engines/asylum/resources/script.cpp
diff --git a/engines/asylum/resources/script.cpp b/engines/asylum/resources/script.cpp
index 2ba0962b31..d9301461e3 100644
--- a/engines/asylum/resources/script.cpp
+++ b/engines/asylum/resources/script.cpp
@@ -337,14 +337,22 @@ bool ScriptManager::process() {
// Run script
for (;;) {
ScriptEntry *cmd = NULL;
+ uint32 cmdIndex = 0;
if (_processNextEntry)
goto label_processNextEntry;
- // TODO Check for bounds error
-
// Get the script command
- cmd = &_currentScript->commands[_queue.entries[entryIndex].currentLine];
+ cmdIndex = _queue.entries[entryIndex].currentLine;
+ if (cmdIndex >= MAX_ACTION_COMMANDS)
+ error("[ScriptManager::process] Invalid command index (was: %d, max: %d)", cmdIndex, MAX_ACTION_COMMANDS);
+
+ cmd = &_currentScript->commands[cmdIndex];
+
+ // Check script opcode
+ if (cmd->opcode >= (int32)_opcodes.size())
+ error("[ScriptManager::process] Invalid opcode index (was: %d, max: %d)", cmd->opcode, _opcodes.size() - 1);
+
debugC(kDebugLevelScripts, "[0x%02X] %s (%d, %d, %d, %d, %d, %d, %d, %d, %d)",
cmd->opcode, _opcodes[cmd->opcode]->name,
cmd->param1, cmd->param2, cmd->param3, cmd->param4, cmd->param5,
Commit: a5e03e18a1c4b579fef098142763aa3ad3a96e29
https://github.com/scummvm/scummvm/commit/a5e03e18a1c4b579fef098142763aa3ad3a96e29
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:37:02+02:00
Commit Message:
ASYLUM: Implement Screen::blitCrossfade()
- Update parameters to some blit functions for consistency
- Revert changes to Screen::clip (our clipRect is different from the original)
Changed paths:
engines/asylum/system/screen.cpp
engines/asylum/system/screen.h
diff --git a/engines/asylum/system/screen.cpp b/engines/asylum/system/screen.cpp
index fe96269596..aa52d23a04 100644
--- a/engines/asylum/system/screen.cpp
+++ b/engines/asylum/system/screen.cpp
@@ -183,7 +183,7 @@ void Screen::clip(Common::Rect *source, Common::Rect *destination, int32 flags)
source->left += diffLeft;
}
- int32 diffRight = destination->right - _clipRect.right - 1;
+ int32 diffRight = destination->right - _clipRect.right;
if (diffRight > 0) {
destination->right -= diffRight;
@@ -199,7 +199,7 @@ void Screen::clip(Common::Rect *source, Common::Rect *destination, int32 flags)
source->top += diffTop;
}
- int32 diffBottom = destination->bottom - _clipRect.bottom - 1;
+ int32 diffBottom = destination->bottom - _clipRect.bottom;
if (diffBottom > 0) {
source->bottom -= diffBottom;
destination->bottom -= diffBottom;
@@ -391,7 +391,8 @@ void Screen::addGraphicToQueueCrossfade(ResourceId resourceId, uint32 frameIndex
blitCrossfade((byte *)_backBuffer.pixels + dst.top * _backBuffer.pitch + dst.left,
(byte *)frame->surface.pixels + src.top * frame->surface.pitch + src.left,
(byte *)frameObject->surface.pixels + (objectPoint.y + dst.top) * frameObject->surface.pitch + (dst.left + objectPoint.x),
- dst.width() + (dst.height() << 16),
+ dst.height(),
+ dst.width(),
frame->surface.pitch - dst.width(),
_backBuffer.pitch - dst.width(),
frameObject->surface.pitch - dst.width());
@@ -568,6 +569,23 @@ void Screen::blitTranstableMirrored(byte *dstBuffer, byte *srcBuffer, int16 heig
}
}
+void Screen::blitCrossfade(byte *dstBuffer, byte *srcBuffer, byte *objectBuffer, int16 height, int16 width, uint32 srcPitch, uint32 dstPitch, uint32 objectPitch) {
+ while (height--) {
+ for (int16 i = width; i; --i) {
+ if (*srcBuffer)
+ *dstBuffer = _transTableIndex[(*srcBuffer << 8) + *objectBuffer];
+
+ dstBuffer++;
+ srcBuffer++;
+ objectBuffer++;
+ }
+
+ dstBuffer += dstPitch;
+ srcBuffer += srcPitch;
+ objectBuffer += objectPitch;
+ }
+}
+
void Screen::blitMirrored(byte *dstBuffer, byte *srcBuffer, int16 height, int16 width, int32 srcPitch, int32 dstPitch) {
while (height--) {
for (int16 i = width; i; --i) {
@@ -752,8 +770,8 @@ void Screen::blitMasked(GraphicFrame *frame, Common::Rect *source, byte *maskDat
// Masked part
bltMasked(frameBufferPtr,
maskBufferPtr,
- source->width(),
source->height(),
+ source->width(),
frameRight - source->width(),
(maskHeight - srcMaskLeft - source->width()) / 8,
srcMaskLeft,
@@ -768,14 +786,10 @@ void Screen::blitMasked(GraphicFrame *frame, Common::Rect *source, byte *maskDat
delete mirroredBuffer;
}
-void Screen::bltMasked(byte *srcBuffer, byte *maskBuffer, int16 width, int16 height, int16 srcPitch, int16 maskPitch, char maskLeft, byte *dstBuffer, int16 dstPitch) {
+void Screen::bltMasked(byte *srcBuffer, byte *maskBuffer, int16 height, int16 width, int16 srcPitch, int16 maskPitch, char maskLeft, byte *dstBuffer, int16 dstPitch) {
warning("[Screen::bltMasked] Not implemented!");
}
-void Screen::blitCrossfade(byte *dstBuffer, byte *srcBuffer, byte *objectBuffer, int widthHeight, uint32 srcPitch, uint32 dstPitch, uint32 objectPitch) {
- error("[Screen::blitCrossfade] Not implemented");
-}
-
void Screen::blt(Common::Rect *dest, GraphicFrame* frame, Common::Rect *source, int32 flags) {
if (_useColorKey) {
copyToBackBufferWithTransparency((byte *)frame->surface.pixels + (source->top * frame->surface.w + source->left),
diff --git a/engines/asylum/system/screen.h b/engines/asylum/system/screen.h
index 9d2027461f..629c30742f 100644
--- a/engines/asylum/system/screen.h
+++ b/engines/asylum/system/screen.h
@@ -152,15 +152,15 @@ private:
// Screen blitting
void blit(GraphicFrame *frame, Common::Rect *source, Common::Rect *destination, int32 flags);
- void blitTranstable(byte *dstBuffer, byte *srcBuffer, int16 height, int16 width, int32 srcPitch, int32 dstPitch);
- void blitTranstableMirrored(byte *dstBuffer, byte *srcBuffer, int16 height, int16 width, int32 srcPitch, int32 dstPitch);
- void blitMirrored(byte *dstBuffer, byte *srcBuffer, int16 height, int16 width, int32 srcPitch, int32 dstPitch);
- void blitMirroredColorKey(byte *dstBuffer, byte *srcBuffer, int16 height, int16 width, int32 srcPitch, int32 dstPitch);
- void blitRaw(byte *dstBuffer, byte *srcBuffer, int16 height, int16 width, int32 srcPitch, int32 dstPitch);
- void blitRawColorKey(byte *dstBuffer, byte *srcBuffer, int16 height, int16 width, int32 srcPitch, int32 dstPitch);
void blitMasked(GraphicFrame *frame, Common::Rect *source, byte *maskData, Common::Rect *sourceMask, Common::Rect *destMask, int maskHeight, Common::Rect *destination, int32 flags);
- void bltMasked(byte *srcBuffer, byte *maskBuffer, int16 width, int16 height, int16 srcPitch, int16 maskPitch, char maskLeft, byte *dstBuffer, int16 dstPitch);
- void blitCrossfade(byte *dstBuffer, byte *srcBuffer, byte *objectBuffer, int widthHeight, uint32 srcPitch, uint32 dstPitch, uint32 objectPitch);
+ void blitTranstable (byte *dstBuffer, byte *srcBuffer, int16 height, int16 width, int32 srcPitch, int32 dstPitch);
+ void blitTranstableMirrored(byte *dstBuffer, byte *srcBuffer, int16 height, int16 width, int32 srcPitch, int32 dstPitch);
+ void blitMirrored (byte *dstBuffer, byte *srcBuffer, int16 height, int16 width, int32 srcPitch, int32 dstPitch);
+ void blitMirroredColorKey (byte *dstBuffer, byte *srcBuffer, int16 height, int16 width, int32 srcPitch, int32 dstPitch);
+ void blitRaw (byte *dstBuffer, byte *srcBuffer, int16 height, int16 width, int32 srcPitch, int32 dstPitch);
+ void blitRawColorKey (byte *dstBuffer, byte *srcBuffer, int16 height, int16 width, int32 srcPitch, int32 dstPitch);
+ void blitCrossfade (byte *dstBuffer, byte *srcBuffer, byte *objectBuffer, int16 height, int16 width, uint32 srcPitch, uint32 dstPitch, uint32 objectPitch);
+ void bltMasked (byte *srcBuffer, byte *maskBuffer, int16 height, int16 width, int16 srcPitch, int16 maskPitch, char maskLeft, byte *dstBuffer, int16 dstPitch);
// DirectDraw-equivalent functions
void blt(Common::Rect *dest, GraphicFrame* frame, Common::Rect *source, int32 flags);
Commit: 082789c8f2413c71111fbf98562f66d4f1b4bdab
https://github.com/scummvm/scummvm/commit/082789c8f2413c71111fbf98562f66d4f1b4bdab
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:37:02+02:00
Commit Message:
ASYLUM: Rename Polygons helper function
Changed paths:
engines/asylum/resources/polygons.cpp
engines/asylum/resources/polygons.h
diff --git a/engines/asylum/resources/polygons.cpp b/engines/asylum/resources/polygons.cpp
index 2760f1a736..b03650af2c 100644
--- a/engines/asylum/resources/polygons.cpp
+++ b/engines/asylum/resources/polygons.cpp
@@ -93,8 +93,8 @@ bool Polygons::contains(Common::Point *points, uint32 count, Common::Point point
}
bool Polygons::contains(int32 x1, int32 y1, int32 x2, int32 y2, int32 x3, int32 y3, int32 x4, int32 y4) {
- return (compareDistance(x1, y1, x2, y2, x3, y3) * compareDistance(x1, y1, x2, y2, x4, y4) <= 0
- && compareDistance(x3, y3, x4, y4, x1, y1) * compareDistance(x3, y3, x4, y4, x2, y2) <= 0);
+ return (compareDistance(x1, y1, x2, y2, x3, y3) * compareDistance(x1, y1, x2, y2, x4, y4)) <= 0
+ && (compareDistance(x3, y3, x4, y4, x1, y1) * compareDistance(x3, y3, x4, y4, x2, y2) <= 0);
}
int32 Polygons::compareDistance(int32 x1, int32 y1, int32 x2, int32 y2, int32 x3, int32 y3) {
@@ -104,7 +104,7 @@ int32 Polygons::compareDistance(int32 x1, int32 y1, int32 x2, int32 y2, int32 x3
return (d1 <= d2) ? -1 : 1;
}
-bool Polygons::containsHelper(Common::Point *points, uint32 count, Common::Point point, Common::Rect *boundingRect) {
+bool Polygons::containsRect(Common::Point *points, uint32 count, Common::Point point, Common::Rect *boundingRect) {
error("[Polygons::containsHelper] Not implemented!");
}
diff --git a/engines/asylum/resources/polygons.h b/engines/asylum/resources/polygons.h
index 0e3d8f9fad..5332784b0f 100644
--- a/engines/asylum/resources/polygons.h
+++ b/engines/asylum/resources/polygons.h
@@ -78,7 +78,7 @@ private:
void load(Common::SeekableReadStream *stream);
static int32 compareDistance(int32 x1, int32 y1, int32 x2, int32 y2, int32 x3, int32 y3);
- static bool containsHelper(Common::Point *points, uint32 count, Common::Point point, Common::Rect *boundingRect);
+ static bool containsRect(Common::Point *points, uint32 count, Common::Point point, Common::Rect *boundingRect);
}; // end of class Polygons
Commit: 3727e9a8209881af50d43aafe2d1f5fd3a6846fb
https://github.com/scummvm/scummvm/commit/3727e9a8209881af50d43aafe2d1f5fd3a6846fb
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:37:02+02:00
Commit Message:
ASYLUM: Add option to draw the scene rects
Changed paths:
engines/asylum/console.cpp
engines/asylum/system/screen.cpp
engines/asylum/system/screen.h
engines/asylum/views/scene.cpp
engines/asylum/views/scene.h
diff --git a/engines/asylum/console.cpp b/engines/asylum/console.cpp
index 4d15fb494e..c31966beaf 100644
--- a/engines/asylum/console.cpp
+++ b/engines/asylum/console.cpp
@@ -46,6 +46,7 @@ extern int g_debugActors;
extern int g_debugDrawRects;
extern int g_debugObjects;
extern int g_debugPolygons;
+extern int g_debugSceneRects;
extern int g_debugScrolling;
const ResourcePackId puzzleToScenes[17] = {
@@ -93,11 +94,12 @@ Console::Console(AsylumEngine *engine) : _vm(engine) {
DCmd_Register("toggle_flag", WRAP_METHOD(Console, cmdToggleFlag));
// Variables
- DVar_Register("show_actors", &g_debugActors, DVAR_INT, 0);
- DVar_Register("show_objects", &g_debugObjects, DVAR_INT, 0);
- DVar_Register("show_polygons", &g_debugPolygons, DVAR_INT, 0);
- DVar_Register("show_drawrects", &g_debugDrawRects, DVAR_INT, 0);
- DVar_Register("use_scrolling", &g_debugScrolling, DVAR_INT, 0);
+ DVar_Register("show_actors", &g_debugActors, DVAR_INT, 0);
+ DVar_Register("show_drawrects", &g_debugDrawRects, DVAR_INT, 0);
+ DVar_Register("show_objects", &g_debugObjects, DVAR_INT, 0);
+ DVar_Register("show_polygons", &g_debugPolygons, DVAR_INT, 0);
+ DVar_Register("show_scenerects", &g_debugSceneRects, DVAR_INT, 0);
+ DVar_Register("use_scrolling", &g_debugScrolling, DVAR_INT, 0);
}
Console::~Console() {
diff --git a/engines/asylum/system/screen.cpp b/engines/asylum/system/screen.cpp
index aa52d23a04..a69d84f044 100644
--- a/engines/asylum/system/screen.cpp
+++ b/engines/asylum/system/screen.cpp
@@ -35,7 +35,7 @@
namespace Asylum {
-extern int g_debugDrawRects;
+int g_debugDrawRects;
Screen::Screen(AsylumEngine *vm) : _vm(vm) ,
_useColorKey(false), _transTableCount(0), _transTableIndex(NULL), _transTableData(NULL), _transTableBuffer(NULL) {
@@ -43,6 +43,8 @@ Screen::Screen(AsylumEngine *vm) : _vm(vm) ,
_flag = -1;
_clipRect = Common::Rect(0, 0, 640, 480);
+
+ g_debugDrawRects = 0;
}
Screen::~Screen() {
@@ -865,8 +867,12 @@ void Screen::copyToBackBufferWithTransparency(byte *buffer, int32 pitch, int32 x
//////////////////////////////////////////////////////////////////////////
// Debug
//////////////////////////////////////////////////////////////////////////
-void Screen::drawLine(const Common::Point &source, const Common::Point &destination) {
- _backBuffer.drawLine(source.x, source.y, destination.x, destination.y, 0xFF);
+void Screen::drawLine(const Common::Point &source, const Common::Point &destination, uint32 color) {
+ _backBuffer.drawLine(source.x, source.y, destination.x, destination.y, color);
+}
+
+void Screen::drawRect(const Common::Rect &rect, uint32 color) {
+ _backBuffer.frameRect(rect, color);
}
void Screen::copyToBackBufferClipped(Graphics::Surface *surface, int x, int y) {
diff --git a/engines/asylum/system/screen.h b/engines/asylum/system/screen.h
index 629c30742f..54af71d1c5 100644
--- a/engines/asylum/system/screen.h
+++ b/engines/asylum/system/screen.h
@@ -123,7 +123,8 @@ public:
void copyToBackBuffer(byte *buffer, int32 pitch, int32 x, int32 y, uint32 width, uint32 height, bool mirrored = false);
// Debug
- void drawLine(const Common::Point &origin, const Common::Point &destination);
+ void drawLine(const Common::Point &origin, const Common::Point &destination, uint32 color = 0xFF);
+ void drawRect(const Common::Rect &rect, uint32 color = 0xFF);
void copyToBackBufferClipped(Graphics::Surface *surface, int x, int y);
private:
diff --git a/engines/asylum/views/scene.cpp b/engines/asylum/views/scene.cpp
index 598c92a751..b71237da36 100644
--- a/engines/asylum/views/scene.cpp
+++ b/engines/asylum/views/scene.cpp
@@ -53,9 +53,9 @@ namespace Asylum {
#define SCROLL_STEP 10
int g_debugActors;
-int g_debugDrawRects;
int g_debugObjects;
int g_debugPolygons;
+int g_debugSceneRects;
int g_debugScrolling;
Scene::Scene(AsylumEngine *engine): _vm(engine),
@@ -70,8 +70,10 @@ Scene::Scene(AsylumEngine *engine): _vm(engine),
_musicVolume = 0;
- g_debugPolygons = 0;
+ g_debugActors = 0;
g_debugObjects = 0;
+ g_debugPolygons = 0;
+ g_debugSceneRects = 0;
g_debugScrolling = 0;
}
@@ -2388,6 +2390,8 @@ bool Scene::drawScene() {
debugShowPolygons();
if (g_debugObjects)
debugShowObjects();
+ if (g_debugSceneRects)
+ debugShowSceneRects();
return false;
}
@@ -2693,6 +2697,15 @@ void Scene::debugShowPolygons() {
}
}
+// SCENE RECTS DEBUG
+void Scene::debugShowSceneRects() {
+ if (!_ws)
+ error("[Scene::debugShowObjects] WorldStats not initialized properly!");
+
+ for (uint32 i = 0; i < ARRAYSIZE(_ws->sceneRects); i++)
+ getScreen()->drawRect(_ws->sceneRects[i]);
+}
+
// OBJECT DEBUGGING
void Scene::debugShowObjects() {
if (!_ws)
@@ -2703,8 +2716,8 @@ void Scene::debugShowObjects() {
Object *object = _ws->objects[p];
if (object->isOnScreen()) {
- surface.create(object->getBoundingRect()->right - object->getBoundingRect()->left + 1,
- object->getBoundingRect()->bottom - object->getBoundingRect()->top + 1,
+ surface.create(object->getBoundingRect()->width() + 1,
+ object->getBoundingRect()->height() + 1,
Graphics::PixelFormat::createFormatCLUT8());
surface.frameRect(*object->getBoundingRect(), 0x22);
getScreen()->copyToBackBufferClipped(&surface, object->x, object->y);
diff --git a/engines/asylum/views/scene.h b/engines/asylum/views/scene.h
index 6c833a9773..ac88cb41e0 100644
--- a/engines/asylum/views/scene.h
+++ b/engines/asylum/views/scene.h
@@ -462,10 +462,11 @@ private:
//////////////////////////////////////////////////////////////////////////
// Scene debugging
//////////////////////////////////////////////////////////////////////////
- void debugScreenScrolling();
- void debugShowPolygons();
- void debugShowObjects();
void debugShowActors();
+ void debugShowObjects();
+ void debugShowPolygons();
+ void debugShowSceneRects();
+ void debugScreenScrolling();
void debugShowWalkRegion(PolyDefinitions *poly);
friend class SceneTitle;
Commit: def09b8c2063e05d580fe54a69212384f0298b3b
https://github.com/scummvm/scummvm/commit/def09b8c2063e05d580fe54a69212384f0298b3b
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:37:02+02:00
Commit Message:
ASYLUM: Rename some movement-related Actor methods
Changed paths:
engines/asylum/resources/actor.cpp
engines/asylum/resources/actor.h
engines/asylum/resources/script.cpp
diff --git a/engines/asylum/resources/actor.cpp b/engines/asylum/resources/actor.cpp
index 0b8be86b97..b49815272d 100644
--- a/engines/asylum/resources/actor.cpp
+++ b/engines/asylum/resources/actor.cpp
@@ -478,16 +478,16 @@ void Actor::update() {
uint32 dist = abs((double)getDistanceForFrame(_direction, index));
Common::Point point = _point1 + _point2;
- if (process_408B20(&point, _direction, dist, false)) {
- playSounds(_direction, dist);
- } else if (process_408B20(&point, (ActorDirection)((_direction + 1) % 7), dist, false)) {
- playSounds((ActorDirection)((_direction + 1) % 7), dist);
- } else if (process_408B20(&point, (ActorDirection)((_direction + 7) % 7), dist, false)) {
- playSounds((ActorDirection)((_direction + 7) % 7), dist);
- } else if (process_408B20(&point, (ActorDirection)((_direction + 2) % 7), dist, false)) {
- playSounds((ActorDirection)((_direction + 2) % 7), dist);
- } else if (process_408B20(&point, (ActorDirection)((_direction + 6) % 7), dist, false)) {
- playSounds((ActorDirection)((_direction + 6) % 7), dist);
+ if (canMove(&point, _direction, dist, false)) {
+ move(_direction, dist);
+ } else if (canMove(&point, (ActorDirection)((_direction + 1) % 7), dist, false)) {
+ move((ActorDirection)((_direction + 1) % 7), dist);
+ } else if (canMove(&point, (ActorDirection)((_direction + 7) % 7), dist, false)) {
+ move((ActorDirection)((_direction + 7) % 7), dist);
+ } else if (canMove(&point, (ActorDirection)((_direction + 2) % 7), dist, false)) {
+ move((ActorDirection)((_direction + 2) % 7), dist);
+ } else if (canMove(&point, (ActorDirection)((_direction + 6) % 7), dist, false)) {
+ move((ActorDirection)((_direction + 6) % 7), dist);
}
// Finish
@@ -518,8 +518,8 @@ void Actor::update() {
|| point.x > (int16)(current.x + (dist - 1))
|| point.y < (int16)(current.y - (dist - 1))
|| point.y > (int16)(current.y + (dist - 1))) {
- if (process_408B20(&point, _direction, dist, false)) {
- playSounds(_direction, dist);
+ if (canMove(&point, _direction, dist, false)) {
+ move(_direction, dist);
} else {
update_409230();
}
@@ -533,7 +533,7 @@ void Actor::update() {
} else {
_frameIndex = (_frameIndex + 1) % _frameCount;
- if (process_4103B0(¤t, _direction)) {
+ if (canMoveCheckActors(¤t, _direction)) {
_point1.x = dist - _point2.x;
_point1.y = current.y - _point2.y;
@@ -947,7 +947,7 @@ bool Actor::process(const Common::Point &point) {
}
if (point == sum) {
- if (process_408B20(&sum, a3 >= 2 ? kDirectionS : kDirectionN, abs(delta.y), false)) {
+ if (canMove(&sum, a3 >= 2 ? kDirectionS : kDirectionN, abs(delta.y), false)) {
_data.points[0] = point;
_data.current = 0;
_data.count = 1;
@@ -958,7 +958,7 @@ bool Actor::process(const Common::Point &point) {
if (point.x == sum.x) {
ActorDirection actorDir = a3 >= 2 ? kDirectionS : kDirectionN;
- if (process_408B20(&sum, actorDir, abs(delta.y), false)) {
+ if (canMove(&sum, actorDir, abs(delta.y), false)) {
_data.points[0] = point;
_data.current = 0;
_data.count = 1;
@@ -974,7 +974,7 @@ bool Actor::process(const Common::Point &point) {
if (point.y == sum.y) {
ActorDirection actorDir = (a3 != 0 || a3 != 3) ? kDirectionE : kDirectionO;
- if (process_408B20(&sum, actorDir, abs(delta.x), true)) {
+ if (canMove(&sum, actorDir, abs(delta.x), true)) {
_data.points[0] = point;
_data.current = 0;
_data.count = 1;
@@ -1066,13 +1066,13 @@ bool Actor::process(const Common::Point &point) {
error("[Actor::process] not implemented (scene rects checks)!");
}
- if (process_408B20(&sum, direction1, count1, true)
- && process_408B20(&point1, direction2, count2, true)) {
+ if (canMove(&sum, direction1, count1, true)
+ && canMove(&point1, direction2, count2, true)) {
error("[Actor::process] not implemented (process actor data 1)!");
}
- if (process_408B20(&sum, direction2, count2, true)
- && process_408B20(&point1, direction1, count1, true)) {
+ if (canMove(&sum, direction2, count2, true)
+ && canMove(&point1, direction1, count1, true)) {
error("[Actor::process] not implemented (process actor data 2)!");
}
@@ -1137,7 +1137,7 @@ bool Actor::process(const Common::Point &point) {
break;
}
- if (!process_408B20(&sum, actorDir, abs(delta.y), true))
+ if (!canMove(&sum, actorDir, abs(delta.y), true))
return false;
// Update actor data
@@ -1272,7 +1272,7 @@ bool Actor::process_4069B0(int32 *x, int32 *y) {
error("[Actor::process_4069B0] Not implemented!");
}
-bool Actor::process_408B20(Common::Point *point, ActorDirection dir, uint32 count, bool hasDelta) {
+bool Actor::canMove(Common::Point *point, ActorDirection dir, uint32 count, bool hasDelta) {
if (_field_944 == 1 || _field_944 == 4)
return true;
@@ -1295,7 +1295,7 @@ bool Actor::process_408B20(Common::Point *point, ActorDirection dir, uint32 coun
if (y > rct.bottom)
return false;
- if (!process_4103B0(point, dir))
+ if (!canMoveCheckActors(point, dir))
return false;
}
@@ -1318,7 +1318,7 @@ bool Actor::process_408B20(Common::Point *point, ActorDirection dir, uint32 coun
return true;
}
-void Actor::playSounds(ActorDirection actorDir, uint32 dist) {
+void Actor::move(ActorDirection actorDir, uint32 dist) {
_lastScreenUpdate = _vm->screenUpdateCount;
Common::Point sum(_point1.x + _point2.x, _point1.x + _point2.x);
@@ -1473,7 +1473,7 @@ bool Actor::process_41BDB0(int32 reactionIndex, int32 testNumberValue01) {
return true;
}
-bool Actor::process_4103B0(Common::Point *point, ActorDirection dir) {
+bool Actor::canMoveCheckActors(Common::Point *point, ActorDirection dir) {
int32 dist = getDistanceForFrame(dir, (_frameIndex >= _frameCount) ? 2 * _frameCount - (_frameIndex + 1) : _frameIndex);
int32 x = point->x + deltaPointsArray[dir].x * dist - _field_948 - 10;
@@ -1978,7 +1978,7 @@ void Actor::updateStatus12_Chapter2() {
absX = absY;
if (absX >= 50) {
- playSounds(_direction, distance);
+ move(_direction, distance);
} else {
_frameIndex = 0;
@@ -2481,7 +2481,7 @@ void Actor::updateCoordinates(Common::Point vec1, Common::Point vec2) {
ActorDirection dir = (diffY > 0) ? kDirectionS : kDirectionN;
- if (process_408B20(&vec2, dir, diffY + 3, false))
+ if (canMove(&vec2, dir, diffY + 3, false))
updateCoordinatesForDirection(dir, diffY - 1, &_point);
}
diff --git a/engines/asylum/resources/actor.h b/engines/asylum/resources/actor.h
index 51b9422041..4b60b5a7bf 100644
--- a/engines/asylum/resources/actor.h
+++ b/engines/asylum/resources/actor.h
@@ -258,12 +258,12 @@ public:
void processStatus(int32 actorX, int32 actorY, bool doSpeech);
void process_401830(int32 field980, int32 actionAreaId, int32 field978, int field98C, int32 field990, int32 field974, int32 field984, int32 field988);
bool process_4069B0(int32 *x, int32 *y);
- bool process_408B20(Common::Point *point, ActorDirection direction, uint32 count, bool hasDelta);
- void playSounds(ActorDirection dir, uint32 distance);
+ bool canMove(Common::Point *point, ActorDirection direction, uint32 count, bool hasDelta);
+ void move(ActorDirection dir, uint32 distance);
void process_41BC00(int32 reactionIndex, int32 numberValue01Add);
void process_41BCC0(int32 reactionIndex, int32 numberValue01Substract);
bool process_41BDB0(int32 reactionIndex, int32 testNumberValue01);
- bool process_4103B0(Common::Point *point, ActorDirection direction);
+ bool canMoveCheckActors(Common::Point *point, ActorDirection direction);
void updateAndDraw();
void update_409230();
diff --git a/engines/asylum/resources/script.cpp b/engines/asylum/resources/script.cpp
index d9301461e3..98361b53bb 100644
--- a/engines/asylum/resources/script.cpp
+++ b/engines/asylum/resources/script.cpp
@@ -930,7 +930,7 @@ IMPLEMENT_OPCODE(_unk2C_ActorSub)
if (cmd->param1 == 2) {
Common::Point point(playerPoint);
- if (player->process_408B20(&point, newDirection, 3, false)) {
+ if (player->canMove(&point, newDirection, 3, false)) {
point.x += (int16)(3 * deltaPointsArray[newDirection].x);
point.y += (int16)(3 * deltaPointsArray[newDirection].y);
@@ -939,7 +939,7 @@ IMPLEMENT_OPCODE(_unk2C_ActorSub)
}
}
- } else if (cmd->param1 != 2 || player->process_408B20(&playerPoint, newDirection, 3, false)) {
+ } else if (cmd->param1 != 2 || player->canMove(&playerPoint, newDirection, 3, false)) {
ResourceId id = kResourceNone;
if (direction >= 5)
id = actor->getResourcesId((uint32)(5 * cmd->param1 - (direction - 38)));
Commit: 5b3efe819283d13eb1e168cb57c53c91ee04e204
https://github.com/scummvm/scummvm/commit/5b3efe819283d13eb1e168cb57c53c91ee04e204
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:37:02+02:00
Commit Message:
ASYLUM: Cleanup polygon class
Changed paths:
engines/asylum/puzzles/puzzle.cpp
engines/asylum/resources/actor.cpp
engines/asylum/resources/polygons.cpp
engines/asylum/resources/polygons.h
engines/asylum/views/scene.cpp
engines/asylum/views/scene.h
diff --git a/engines/asylum/puzzles/puzzle.cpp b/engines/asylum/puzzles/puzzle.cpp
index 26233f5865..e5e9b989ce 100644
--- a/engines/asylum/puzzles/puzzle.cpp
+++ b/engines/asylum/puzzles/puzzle.cpp
@@ -117,13 +117,13 @@ void Puzzle::exitPuzzle() {
// Hit test functions
//////////////////////////////////////////////////////////////////////////
bool Puzzle::hitTest(const Common::Point *polygonPoint, Common::Point point, uint32 index) {
- PolyDefinitions polygon(polygonPoint[index], polygonPoint[index + 1], polygonPoint[index + 2], polygonPoint[index + 3]);
+ Polygon polygon(polygonPoint[index], polygonPoint[index + 1], polygonPoint[index + 2], polygonPoint[index + 3]);
return polygon.contains(point);
}
bool Puzzle::hitTest(const Common::Point *polygonPoint, Common::Point point) {
- PolyDefinitions polygon(polygonPoint[0], polygonPoint[1], polygonPoint[2], polygonPoint[3]);
+ Polygon polygon(polygonPoint[0], polygonPoint[1], polygonPoint[2], polygonPoint[3]);
return polygon.contains(point);
}
diff --git a/engines/asylum/resources/actor.cpp b/engines/asylum/resources/actor.cpp
index b49815272d..c67173f0a5 100644
--- a/engines/asylum/resources/actor.cpp
+++ b/engines/asylum/resources/actor.cpp
@@ -816,10 +816,10 @@ void Actor::faceTarget(uint32 target, DirectionFrom from) {
return;
}
- PolyDefinitions *polygon = &getScene()->polygons()->entries[getWorld()->actions[actionIndex]->polygonIndex];
+ Polygon polygon = getScene()->polygons()->get(getWorld()->actions[actionIndex]->polygonIndex);
- point.x = polygon->boundingRect.left + (polygon->boundingRect.right - polygon->boundingRect.left) / 2;
- point.y = polygon->boundingRect.top + (polygon->boundingRect.bottom - polygon->boundingRect.top) / 2;
+ point.x = polygon.boundingRect.left + (polygon.boundingRect.right - polygon.boundingRect.left) / 2;
+ point.y = polygon.boundingRect.top + (polygon.boundingRect.bottom - polygon.boundingRect.top) / 2;
}
break;
@@ -1177,15 +1177,15 @@ void Actor::process_401830(int32 field980, int32 actionAreaId, int32 field978, i
field_984 = field984;
field_988 = field988;
} else {
- PolyDefinitions *polygon = &getScene()->polygons()->entries[_actionIdx1];
+ Polygon polygon = getScene()->polygons()->get(_actionIdx1);
- field_984 = polygon->points[0].x;
- field_988 = polygon->points[0].y;
+ field_984 = polygon.points[0].x;
+ field_988 = polygon.points[0].y;
// Iterate through points
- if (polygon->count() > 1) {
- for (uint i = 1; i < polygon->count() - 1; i++) {
- Common::Point point = polygon->points[i];
+ if (polygon.count() > 1) {
+ for (uint i = 1; i < polygon.count() - 1; i++) {
+ Common::Point point = polygon.points[i];
switch (field978) {
default:
@@ -1867,15 +1867,15 @@ void Actor::updateStatusEnabled() {
if (areaIndex != -1) {
ActionArea *area = getWorld()->actions[areaIndex];
- PolyDefinitions *poly = &getScene()->polygons()->entries[area->polygonIndex];
+ Polygon poly = getScene()->polygons()->get(area->polygonIndex);
- Common::Point pt(poly->boundingRect.left + rnd(poly->boundingRect.width()),
- poly->boundingRect.top + rnd(poly->boundingRect.height()));
+ Common::Point pt(poly.boundingRect.left + rnd(poly.boundingRect.width()),
+ poly.boundingRect.top + rnd(poly.boundingRect.height()));
if (!getSharedData()->actorUpdateEnabledCheck) {
if (!isInActionArea(pt, area)) {
- Common::Point *polyPoint = &poly->points[rnd(poly->count())];
- processStatus(polyPoint->x, polyPoint->y, false);
+ Common::Point polyPoint = poly.points[rnd(poly.count())];
+ processStatus(polyPoint.x, polyPoint.y, false);
} else {
processStatus(pt.x, pt.y, false);
}
@@ -2699,7 +2699,7 @@ bool Actor::isInActionArea(const Common::Point &pt, ActionArea *area) {
if (found)
return false;
- PolyDefinitions poly = getScene()->polygons()->entries[area->polygonIndex];
+ Polygon poly = getScene()->polygons()->get(area->polygonIndex);
if (!poly.contains(pt))
return false;
diff --git a/engines/asylum/resources/polygons.cpp b/engines/asylum/resources/polygons.cpp
index b03650af2c..1bc37bb0e9 100644
--- a/engines/asylum/resources/polygons.cpp
+++ b/engines/asylum/resources/polygons.cpp
@@ -24,15 +24,10 @@
namespace Asylum {
-Polygons::Polygons(Common::SeekableReadStream *stream) : size(0), numEntries(0) {
- load(stream);
-}
-
-Polygons::~Polygons() {
- entries.clear();
-}
-
-bool PolyDefinitions::contains(int16 x, int16 y) {
+//////////////////////////////////////////////////////////////////////////
+// Contains
+//////////////////////////////////////////////////////////////////////////
+bool Polygon::contains(const Common::Point &point) {
// Copied from backends/vkeybd/polygon.cpp
bool yflag0;
bool yflag1;
@@ -41,11 +36,11 @@ bool PolyDefinitions::contains(int16 x, int16 y) {
Common::Point *vtx0 = &points[count() - 1];
Common::Point *vtx1 = &points[0];
- yflag0 = (vtx0->y >= y);
+ yflag0 = (vtx0->y >= point.y);
for (uint32 pt = 0; pt < count(); pt++, vtx1++) {
- yflag1 = (vtx1->y >= y);
+ yflag1 = (vtx1->y >= point.y);
if (yflag0 != yflag1) {
- if (((vtx1->y - y) * (vtx0->x - vtx1->x) >= (vtx1->x - x) * (vtx0->y - vtx1->y)) == yflag1) {
+ if (((vtx1->y - point.y) * (vtx0->x - vtx1->x) >= (vtx1->x - point.x) * (vtx0->y - vtx1->y)) == yflag1) {
inside_flag = !inside_flag;
}
}
@@ -56,12 +51,30 @@ bool PolyDefinitions::contains(int16 x, int16 y) {
return inside_flag;
}
+//////////////////////////////////////////////////////////////////////////
+// Polygons
+//////////////////////////////////////////////////////////////////////////
+Polygons::Polygons(Common::SeekableReadStream *stream) : _size(0), _numEntries(0) {
+ load(stream);
+}
+
+Polygons::~Polygons() {
+ _entries.clear();
+}
+
+Polygon Polygons::get(uint32 index) {
+ if (index >= _entries.size())
+ error("[Polygons::getEntry] Invalid polygon index (was: %d, max: %d)", index, _entries.size() - 1);
+
+ return _entries[index];
+}
+
void Polygons::load(Common::SeekableReadStream *stream) {
- size = stream->readSint32LE();
- numEntries = stream->readSint32LE();
+ _size = stream->readSint32LE();
+ _numEntries = stream->readSint32LE();
- for (int32 g = 0; g < numEntries; g++) {
- PolyDefinitions poly;
+ for (int32 g = 0; g < _numEntries; g++) {
+ Polygon poly;
uint32 numPoints = stream->readUint32LE();
@@ -80,32 +93,8 @@ void Polygons::load(Common::SeekableReadStream *stream) {
poly.boundingRect.right = (int16)(stream->readSint32LE() & 0xFFFF);
poly.boundingRect.bottom = (int16)(stream->readSint32LE() & 0xFFFF);
- entries.push_back(poly);
+ _entries.push_back(poly);
}
}
-//////////////////////////////////////////////////////////////////////////
-// Contains
-//////////////////////////////////////////////////////////////////////////
-
-bool Polygons::contains(Common::Point *points, uint32 count, Common::Point point, Common::Rect *boundingRect) {
- error("[Polygons::contains] Not implemented!");
-}
-
-bool Polygons::contains(int32 x1, int32 y1, int32 x2, int32 y2, int32 x3, int32 y3, int32 x4, int32 y4) {
- return (compareDistance(x1, y1, x2, y2, x3, y3) * compareDistance(x1, y1, x2, y2, x4, y4)) <= 0
- && (compareDistance(x3, y3, x4, y4, x1, y1) * compareDistance(x3, y3, x4, y4, x2, y2) <= 0);
-}
-
-int32 Polygons::compareDistance(int32 x1, int32 y1, int32 x2, int32 y2, int32 x3, int32 y3) {
- uint32 d1 = (y3 - y1) * (x2 - x1);
- uint32 d2 = (x3 - x1) * (y2 - y1);
-
- return (d1 <= d2) ? -1 : 1;
-}
-
-bool Polygons::containsRect(Common::Point *points, uint32 count, Common::Point point, Common::Rect *boundingRect) {
- error("[Polygons::containsHelper] Not implemented!");
-}
-
} // end of namespace Asylum
diff --git a/engines/asylum/resources/polygons.h b/engines/asylum/resources/polygons.h
index 5332784b0f..b1e6498a67 100644
--- a/engines/asylum/resources/polygons.h
+++ b/engines/asylum/resources/polygons.h
@@ -31,55 +31,38 @@
namespace Asylum {
-typedef struct PolyDefinitions {
+class Polygon {
+public:
Common::Array<Common::Point> points;
Common::Rect boundingRect;
- PolyDefinitions() {};
- PolyDefinitions(Common::Point point1, Common::Point point2, Common::Point point3, Common::Point point4) {
+ Polygon() {};
+ Polygon(Common::Point point1, Common::Point point2, Common::Point point3, Common::Point point4) {
points.push_back(point1);
points.push_back(point2);
points.push_back(point3);
points.push_back(point4);
}
- /**
- * Check if the x/y coordinates exist within
- * the current polygon definition
- *
- * (was pointInPoly())
- */
- bool contains(int16 x, int16 y);
-
- bool contains(Common::Point point) {
- return contains(point.x, point.y);
- }
-
- uint32 count() {
- return points.size();
- }
-
-} PolyDefinitions;
+ bool contains(const Common::Point &point);
+ uint32 count() { return points.size(); }
+};
class Polygons {
public:
Polygons(Common::SeekableReadStream *stream);
virtual ~Polygons();
- int32 size;
- int32 numEntries; // TODO remove and use entries.size()
-
- Common::Array<PolyDefinitions> entries;
-
- static bool contains(Common::Point *points, uint32 count, Common::Point point, Common::Rect *boundingRect);
- static bool contains(int32 x1, int32 y1, int32 x2, int32 y2, int32 x3, int32 y3, int32 x4, int32 y4);
+ Polygon get(uint32 index);
+ uint32 size() { return _entries.size(); }
private:
- void load(Common::SeekableReadStream *stream);
+ int32 _size;
+ int32 _numEntries;
- static int32 compareDistance(int32 x1, int32 y1, int32 x2, int32 y2, int32 x3, int32 y3);
- static bool containsRect(Common::Point *points, uint32 count, Common::Point point, Common::Rect *boundingRect);
+ Common::Array<Polygon> _entries;
+ void load(Common::SeekableReadStream *stream);
}; // end of class Polygons
} // end of namespace Asylum
diff --git a/engines/asylum/views/scene.cpp b/engines/asylum/views/scene.cpp
index b71237da36..cef4c1b66d 100644
--- a/engines/asylum/views/scene.cpp
+++ b/engines/asylum/views/scene.cpp
@@ -2158,7 +2158,7 @@ int32 Scene::findActionArea(ActionAreaType type, const Common::Point pt) {
}
}
- if (!found && _polygons->entries[area->polygonIndex].contains(pt))
+ if (!found && _polygons->get(area->polygonIndex).contains(pt))
return i;
}
break;
@@ -2189,7 +2189,7 @@ int32 Scene::findActionArea(ActionAreaType type, const Common::Point pt) {
}
}
- if (!found && _polygons->entries[area->polygonIndex].contains(pt))
+ if (!found && _polygons->get(area->polygonIndex).contains(pt))
return i;
}
break;
@@ -2482,8 +2482,8 @@ void Scene::processUpdateList() {
if (object->flags & kObjectFlag2) {
isMasked = !pointIntersectsRect(sum, *object->getRect());
} else if (object->flags & kObjectFlag40) {
- PolyDefinitions *poly = &_polygons->entries[object->getPolygonIndex()];
- isMasked = poly->contains(sum);
+ Polygon poly = _polygons->get(object->getPolygonIndex());
+ isMasked = poly.contains(sum);
}
// Adjust object flags
@@ -2650,7 +2650,7 @@ void Scene::debugScreenScrolling() {
}
// WALK REGION DEBUG
-void Scene::debugShowWalkRegion(PolyDefinitions *poly) {
+void Scene::debugShowWalkRegion(Polygon *poly) {
Graphics::Surface surface;
surface.create(poly->boundingRect.right - poly->boundingRect.left + 1,
poly->boundingRect.bottom - poly->boundingRect.top + 1,
@@ -2675,9 +2675,9 @@ void Scene::debugShowPolygons() {
if (!_polygons)
error("[Scene::debugShowPolygons] Polygons not initialized properly!");
- for (int32 p = 0; p < _polygons->numEntries; p++) {
+ for (uint32 p = 0; p < _polygons->size(); p++) {
Graphics::Surface surface;
- PolyDefinitions poly = _polygons->entries[p];
+ Polygon poly = _polygons->get(p);
surface.create(poly.boundingRect.right - poly.boundingRect.left + 1,
poly.boundingRect.bottom - poly.boundingRect.top + 1,
Graphics::PixelFormat::createFormatCLUT8());
diff --git a/engines/asylum/views/scene.h b/engines/asylum/views/scene.h
index ac88cb41e0..b142ec20ce 100644
--- a/engines/asylum/views/scene.h
+++ b/engines/asylum/views/scene.h
@@ -42,6 +42,7 @@ class Puzzle;
class Cursor;
class GraphicResource;
class Polygons;
+class Polygon;
class ResourcePack;
class SceneTitle;
class Screen;
@@ -56,7 +57,6 @@ struct ActionArea;
struct AmbientSoundItem;
struct GraphicFrame;
struct ObjectItem;
-struct PolyDefinitions;
enum HitType {
kHitNone = -1,
@@ -467,7 +467,7 @@ private:
void debugShowPolygons();
void debugShowSceneRects();
void debugScreenScrolling();
- void debugShowWalkRegion(PolyDefinitions *poly);
+ void debugShowWalkRegion(Polygon *poly);
friend class SceneTitle;
};
Commit: 0c36e2755ac885095949f511b935347bd4d802a7
https://github.com/scummvm/scummvm/commit/0c36e2755ac885095949f511b935347bd4d802a7
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:37:02+02:00
Commit Message:
ASYLUM: Fix checking of flags when processing action areas
This fixes the player being stuck in place at the beginning (the area has a flag and the player can't move until that flag is set by scripts)
Also add an optional highlight for the current polygon to aid debugging
Changed paths:
engines/asylum/resources/actor.cpp
engines/asylum/views/scene.cpp
engines/asylum/views/scene.h
diff --git a/engines/asylum/resources/actor.cpp b/engines/asylum/resources/actor.cpp
index c67173f0a5..ce5c8bf4c2 100644
--- a/engines/asylum/resources/actor.cpp
+++ b/engines/asylum/resources/actor.cpp
@@ -443,7 +443,7 @@ void Actor::update() {
return;
} else if (getWorld()->chapter == kChapter11) {
- switch (_index) {
+ switch (_index) {
default:
break;
@@ -1272,12 +1272,12 @@ bool Actor::process_4069B0(int32 *x, int32 *y) {
error("[Actor::process_4069B0] Not implemented!");
}
-bool Actor::canMove(Common::Point *point, ActorDirection dir, uint32 count, bool hasDelta) {
+bool Actor::canMove(Common::Point *point, ActorDirection direction, uint32 distance, bool hasDelta) {
if (_field_944 == 1 || _field_944 == 4)
return true;
- int16 x = (hasDelta ? point->x : point->x + deltaPointsArray[dir].x);
- int16 y = (hasDelta ? point->y : point->y + deltaPointsArray[dir].y);
+ int16 x = (hasDelta ? point->x : point->x + deltaPointsArray[direction].x);
+ int16 y = (hasDelta ? point->y : point->y + deltaPointsArray[direction].y);
// Check scene rect
if (!_field_944) {
@@ -1295,20 +1295,20 @@ bool Actor::canMove(Common::Point *point, ActorDirection dir, uint32 count, bool
if (y > rct.bottom)
return false;
- if (!canMoveCheckActors(point, dir))
+ if (!canMoveCheckActors(point, direction))
return false;
}
- if (count > 0) {
- uint32 index = 0;
+ if (distance > 0) {
+ uint32 allowed = 0;
- while (getScene()->findActionArea(kActionAreaType1, Common::Point(x, y)) != -1) {
- x += deltaPointsArray[dir].x;
- y += deltaPointsArray[dir].y;
+ while (getScene()->findActionArea(kActionAreaType1, Common::Point(x, y), true) != -1) {
+ x += deltaPointsArray[direction].x;
+ y += deltaPointsArray[direction].y;
- ++index;
+ ++allowed;
- if (index >= count)
+ if (allowed >= distance)
return true;
}
diff --git a/engines/asylum/views/scene.cpp b/engines/asylum/views/scene.cpp
index cef4c1b66d..52e5ff21e7 100644
--- a/engines/asylum/views/scene.cpp
+++ b/engines/asylum/views/scene.cpp
@@ -2121,7 +2121,7 @@ bool Scene::updateSceneCoordinates(int32 tX, int32 tY, int32 A0, bool checkScene
}
-int32 Scene::findActionArea(ActionAreaType type, const Common::Point pt) {
+int32 Scene::findActionArea(ActionAreaType type, const Common::Point pt, bool highlight) {
if (!_ws)
error("[Scene::findActionArea] WorldStats not initialized properly!");
@@ -2139,6 +2139,9 @@ int32 Scene::findActionArea(ActionAreaType type, const Common::Point pt) {
for (int32 i = _ws->actions.size() - 1; i >= 0; i--) {
ActionArea *area = _ws->actions[i];
+ //if (g_debugPolygons && highlight)
+ // debugHighlightPolygon(area->polygonIndex);
+
bool found = false;
// Iterate over flagNum
@@ -2150,7 +2153,7 @@ int32 Scene::findActionArea(ActionAreaType type, const Common::Point pt) {
if (area->flagNums[j] <= 0)
flagSet = _vm->isGameFlagNotSet((GameFlag)-area->flagNums[j]);
else
- flagSet = _vm->isGameFlagNotSet((GameFlag)area->flagNums[j]);
+ flagSet = _vm->isGameFlagSet((GameFlag)area->flagNums[j]);
if (!flagSet) {
found = true;
@@ -2181,7 +2184,7 @@ int32 Scene::findActionArea(ActionAreaType type, const Common::Point pt) {
if (area->flagNums[j] <= 0)
flagSet = _vm->isGameFlagNotSet((GameFlag)-area->flagNums[j]);
else
- flagSet = _vm->isGameFlagNotSet((GameFlag)area->flagNums[j]);
+ flagSet = _vm->isGameFlagSet((GameFlag)area->flagNums[j]);
if (!flagSet) {
found = true;
@@ -2675,26 +2678,38 @@ void Scene::debugShowPolygons() {
if (!_polygons)
error("[Scene::debugShowPolygons] Polygons not initialized properly!");
- for (uint32 p = 0; p < _polygons->size(); p++) {
- Graphics::Surface surface;
- Polygon poly = _polygons->get(p);
- surface.create(poly.boundingRect.right - poly.boundingRect.left + 1,
- poly.boundingRect.bottom - poly.boundingRect.top + 1,
- Graphics::PixelFormat::createFormatCLUT8());
+ for (uint32 p = 0; p < _polygons->size(); p++)
+ debugShowPolygon(p);
+}
- // Draw all lines in Polygon
- for (uint32 i = 0; i < poly.count(); i++) {
- surface.drawLine(poly.points[i].x - poly.boundingRect.left,
- poly.points[i].y - poly.boundingRect.top,
- poly.points[(i+1) % poly.count()].x - poly.boundingRect.left,
- poly.points[(i+1) % poly.count()].y - poly.boundingRect.top,
- 0xFF);
- }
+void Scene::debugShowPolygon(uint32 index, uint32 color) {
+ if (index >= _polygons->size() - 1)
+ return;
- getScreen()->copyToBackBufferClipped(&surface, poly.boundingRect.left, poly.boundingRect.top);
+ Graphics::Surface surface;
+ Polygon poly = _polygons->get(index);
+ surface.create(poly.boundingRect.right - poly.boundingRect.left + 1,
+ poly.boundingRect.bottom - poly.boundingRect.top + 1,
+ Graphics::PixelFormat::createFormatCLUT8());
- surface.free();
+ // Draw all lines in Polygon
+ for (uint32 i = 0; i < poly.count(); i++) {
+ surface.drawLine(poly.points[i].x - poly.boundingRect.left,
+ poly.points[i].y - poly.boundingRect.top,
+ poly.points[(i+1) % poly.count()].x - poly.boundingRect.left,
+ poly.points[(i+1) % poly.count()].y - poly.boundingRect.top,
+ color);
}
+
+ getScreen()->copyToBackBufferClipped(&surface, poly.boundingRect.left, poly.boundingRect.top);
+
+ surface.free();
+}
+
+void Scene::debugHighlightPolygon(uint32 index) {
+ debugShowPolygon(index, 0x12);
+ getScreen()->copyBackBufferToScreen();
+ g_system->updateScreen();
}
// SCENE RECTS DEBUG
diff --git a/engines/asylum/views/scene.h b/engines/asylum/views/scene.h
index b142ec20ce..87cadacc4f 100644
--- a/engines/asylum/views/scene.h
+++ b/engines/asylum/views/scene.h
@@ -174,13 +174,15 @@ public:
void drawRain();
/**
- * Determine if the supplied point intersects an action area's active region.
+ * Determine if the supplied point intersects an action area's active region.
*
- * @param pt The point.
+ * @param type The type.
+ * @param pt The point.
+ * @param highlight (optional) whether to highlight the polygons as they are checked.
*
- * @return The found action area.
+ * @return The found action area.
*/
- int32 findActionArea(ActionAreaType type, const Common::Point pt);
+ int32 findActionArea(ActionAreaType type, const Common::Point pt, bool highlight = false);
/**
* Check if rectangles intersect.
@@ -465,6 +467,8 @@ private:
void debugShowActors();
void debugShowObjects();
void debugShowPolygons();
+ void debugShowPolygon(uint32 index, uint32 color = 0xFF);
+ void debugHighlightPolygon(uint32 index);
void debugShowSceneRects();
void debugScreenScrolling();
void debugShowWalkRegion(Polygon *poly);
Commit: 9fef4468094b0e28941f145c01286011b15efed0
https://github.com/scummvm/scummvm/commit/9fef4468094b0e28941f145c01286011b15efed0
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:37:02+02:00
Commit Message:
ASYLUM: Adjust flag array size
Changed paths:
engines/asylum/asylum.h
diff --git a/engines/asylum/asylum.h b/engines/asylum/asylum.h
index acb8fcbe77..0d669844d7 100644
--- a/engines/asylum/asylum.h
+++ b/engines/asylum/asylum.h
@@ -247,7 +247,7 @@ private:
// Game data
PuzzleData _puzzleData;
SharedData _data;
- int _gameFlags[145];
+ int _gameFlags[190];
int32 _sinCosTables[72];
bool _introPlayed;
int32 _tickOffset;
Commit: 48f733baf018e8a3fb9d9bb80529624e9c599816
https://github.com/scummvm/scummvm/commit/48f733baf018e8a3fb9d9bb80529624e9c599816
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:37:03+02:00
Commit Message:
ASYLUM: Remove unused ActorResources enumeration
Changed paths:
engines/asylum/shared.h
diff --git a/engines/asylum/shared.h b/engines/asylum/shared.h
index cebd769ff5..1429d1bdd9 100644
--- a/engines/asylum/shared.h
+++ b/engines/asylum/shared.h
@@ -327,98 +327,6 @@ enum DirectionFrom {
kDirectionFromParameters = 3
};
-// TODO investigate other actor resources (from other
-// scenes) to see if the unused blocks in the actor
-// definition are in fact used elsewhere
-enum ActorResources {
- kSound1 = 0,
- kSound2 = 1,
- kSound3 = 2,
- kSound4 = 3,
- //kUnused = 4, // 0
- kFlags = 5,
-
- kWalkN = 6,
- kWalkNW = 7,
- kWalkW = 8,
- kWalkSW = 9,
- kWalkS = 10,
-
- kFaceN = 11,
- kFaceNW = 12,
- kFaceW = 13,
- kFaceSW = 14,
- kFaceS = 15,
-
- kFaceAndShakeN = 16,
- kFaceAndShakeNW = 17,
- kFaceAndShakeW = 18,
- kFaceAndShakeSW = 19,
- kFaceAndShakeS = 20,
-
- kStretchN = 21,
- kStretchNW = 22,
- kStretchW = 23,
- kStretchSW = 24,
- kStretchS = 25,
-
- kFidgetN = 26,
- kFidgetNW = 27,
- kFidgetW = 28,
- kFidgetSW = 29,
- kFidgetS = 30,
-
- // These are 0
- /*
- kUnknown1 = 31,
- kUnknown2 = 32,
- kUnknown3 = 33,
- kUnknown4 = 34,
- kUnknown5 = 35,
- */
-
- kPickupN = 36,
- kPickupNW = 37,
- kPickupW = 38,
- kPickupSW = 39,
- kPickupS = 40,
-
- kOperateN = 41,
- kOperateNW = 42,
- kOperateW = 43,
- kOperateSW = 44,
- kOperateS = 45,
-
- kOperate2N = 46,
- kOperate2NW = 47,
- kOperate2W = 48,
- kOperate2SW = 49,
- kOperate2S = 50,
-
- // These are 0
- /*
- kUnknown6 = 51,
- kUnknown7 = 52,
- kUnknown8 = 53,
- kUnknown9 = 54,
- kUnknown10 = 55,
- kUnknown11 = 56,
- kUnknown12 = 57,
- kUnknown13 = 58,
- kUnknown14 = 59
- */
-
- // Horizontally flipped animations (100 + regular anim Id)
- kWalkNE = 107,
- kWalkE = 108,
- kWalkSE = 109,
-
- kFaceNE = 112,
- kFaceE = 113,
- kFaceSE = 114
- // TODO: finish these
-};
-
//////////////////////////////////////////////////////////////////////////
// Object
//////////////////////////////////////////////////////////////////////////
Commit: 9bc78f83db5c7cb9416d96ac9a2f1066133c7c2c
https://github.com/scummvm/scummvm/commit/9bc78f83db5c7cb9416d96ac9a2f1066133c7c2c
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:37:03+02:00
Commit Message:
ASYLUM: Update ScriptManager
- Rename several opcodes
- Add enumeration for script Opcodes
- Rename some called actor methods
Changed paths:
engines/asylum/puzzles/vcr.cpp
engines/asylum/resources/actor.cpp
engines/asylum/resources/actor.h
engines/asylum/resources/encounters.cpp
engines/asylum/resources/script.cpp
engines/asylum/resources/script.h
engines/asylum/resources/special.cpp
engines/asylum/shared.h
diff --git a/engines/asylum/puzzles/vcr.cpp b/engines/asylum/puzzles/vcr.cpp
index 4b85106a10..cdb0e7d8a3 100644
--- a/engines/asylum/puzzles/vcr.cpp
+++ b/engines/asylum/puzzles/vcr.cpp
@@ -255,7 +255,7 @@ bool PuzzleVCR::mouseLeftUp(const AsylumEvent &) {
&& _holesState[kRed] == kPluggedOnBlack
&& _holesState[kYellow] == kPluggedOnRed) {
getCursor()->hide();
- _vm->setGameFlag(kGameFlagSolveVCRBlowUpPuzzle);
+ _vm->setGameFlag(kGameFlagSolveVCRPuzzle);
_isAccomplished = true;
}
} else if (_buttonsState[kPlayButton] == kDownON) {
diff --git a/engines/asylum/resources/actor.cpp b/engines/asylum/resources/actor.cpp
index ce5c8bf4c2..6326bae922 100644
--- a/engines/asylum/resources/actor.cpp
+++ b/engines/asylum/resources/actor.cpp
@@ -1405,7 +1405,7 @@ void Actor::move(ActorDirection actorDir, uint32 dist) {
}
}
-void Actor::process_41BC00(int32 reactionIndex, int32 numberValue01Add) {
+void Actor::addReactionHive(int32 reactionIndex, int32 numberValue01Add) {
if (reactionIndex > 16)
return;
@@ -1417,7 +1417,7 @@ void Actor::process_41BC00(int32 reactionIndex, int32 numberValue01Add) {
if (count == 8)
return;
- if (!process_41BDB0(reactionIndex, false))
+ if (!hasMoreReactions(reactionIndex, false))
_reaction[count] = reactionIndex;
if (numberValue01Add)
@@ -1426,7 +1426,7 @@ void Actor::process_41BC00(int32 reactionIndex, int32 numberValue01Add) {
getSound()->playSound(MAKE_RESOURCE(kResourcePackHive, 0));
}
-void Actor::process_41BCC0(int32 reactionIndex, int32 numberValue01Substract) {
+void Actor::removeReactionHive(int32 reactionIndex, int32 numberValue01Substract) {
if (reactionIndex > 16)
return;
@@ -1455,7 +1455,7 @@ void Actor::process_41BCC0(int32 reactionIndex, int32 numberValue01Substract) {
}
}
-bool Actor::process_41BDB0(int32 reactionIndex, int32 testNumberValue01) {
+bool Actor::hasMoreReactions(int32 reactionIndex, int32 testNumberValue01) {
if (reactionIndex > 16)
return false;
diff --git a/engines/asylum/resources/actor.h b/engines/asylum/resources/actor.h
index 4b60b5a7bf..632deff4e1 100644
--- a/engines/asylum/resources/actor.h
+++ b/engines/asylum/resources/actor.h
@@ -260,9 +260,9 @@ public:
bool process_4069B0(int32 *x, int32 *y);
bool canMove(Common::Point *point, ActorDirection direction, uint32 count, bool hasDelta);
void move(ActorDirection dir, uint32 distance);
- void process_41BC00(int32 reactionIndex, int32 numberValue01Add);
- void process_41BCC0(int32 reactionIndex, int32 numberValue01Substract);
- bool process_41BDB0(int32 reactionIndex, int32 testNumberValue01);
+ void addReactionHive(int32 reactionIndex, int32 numberValue01Add);
+ void removeReactionHive(int32 reactionIndex, int32 numberValue01Substract);
+ bool hasMoreReactions(int32 reactionIndex, int32 testNumberValue01);
bool canMoveCheckActors(Common::Point *point, ActorDirection direction);
void updateAndDraw();
void update_409230();
diff --git a/engines/asylum/resources/encounters.cpp b/engines/asylum/resources/encounters.cpp
index 3a595cfd46..e7f040f434 100644
--- a/engines/asylum/resources/encounters.cpp
+++ b/engines/asylum/resources/encounters.cpp
@@ -1598,13 +1598,13 @@ void Encounter::runScript() {
case 18:
if (entry.param1)
- getScene()->getActor()->process_41BCC0(getVariableInv(entry.param2), _scriptData.vars[1]);
+ getScene()->getActor()->removeReactionHive(getVariableInv(entry.param2), _scriptData.vars[1]);
else
- getScene()->getActor()->process_41BC00(getVariableInv(entry.param2), _scriptData.vars[1]);
+ getScene()->getActor()->addReactionHive(getVariableInv(entry.param2), _scriptData.vars[1]);
break;
case 21:
- _scriptData.counter = getScene()->getActor()->process_41BDB0(getVariableInv(entry.param2), _scriptData.vars[1]) ? 0 : 1;
+ _scriptData.counter = getScene()->getActor()->hasMoreReactions(getVariableInv(entry.param2), _scriptData.vars[1]) ? 0 : 1;
break;
case 23:
diff --git a/engines/asylum/resources/script.cpp b/engines/asylum/resources/script.cpp
index 98361b53bb..d198c46671 100644
--- a/engines/asylum/resources/script.cpp
+++ b/engines/asylum/resources/script.cpp
@@ -114,9 +114,9 @@ ScriptManager::ScriptManager(AsylumEngine *engine) : _vm(engine) {
ADD_OPCODE(JumpIfActionTalk);
ADD_OPCODE(SetActionTalk);
ADD_OPCODE(ClearActionTalk);
- ADD_OPCODE(_unk22);
- ADD_OPCODE(_unk23);
- ADD_OPCODE(_unk24);
+ ADD_OPCODE(AddReactionHive);
+ ADD_OPCODE(RemoveReactionHive);
+ ADD_OPCODE(HasMoreReaction);
ADD_OPCODE(RunEncounter);
ADD_OPCODE(JumpIfAction16);
ADD_OPCODE(SetAction16);
@@ -124,7 +124,7 @@ ScriptManager::ScriptManager(AsylumEngine *engine) : _vm(engine) {
ADD_OPCODE(SetActorField638);
ADD_OPCODE(JumpIfActorField638);
ADD_OPCODE(ChangeScene);
- ADD_OPCODE(_unk2C_ActorSub);
+ ADD_OPCODE(UpdateActor);
ADD_OPCODE(PlayMovie);
ADD_OPCODE(StopAllObjectsSounds);
ADD_OPCODE(StopProcessing);
@@ -132,14 +132,14 @@ ScriptManager::ScriptManager(AsylumEngine *engine) : _vm(engine) {
ADD_OPCODE(ResetSceneRect);
ADD_OPCODE(ChangeMusicById);
ADD_OPCODE(StopMusic);
- ADD_OPCODE(_unk34_Status);
+ ADD_OPCODE(IncrementParam1);
ADD_OPCODE(SetVolume);
ADD_OPCODE(Jump);
- ADD_OPCODE(RunBlowUpPuzzle);
+ ADD_OPCODE(RunPuzzle);
ADD_OPCODE(JumpIfAction8);
ADD_OPCODE(SetAction8);
ADD_OPCODE(ClearAction8);
- ADD_OPCODE(_unk3B_PALETTE_MOD);
+ ADD_OPCODE(CreatePalette);
ADD_OPCODE(IncrementParam2);
ADD_OPCODE(WaitUntilFramePlayed);
ADD_OPCODE(UpdateWideScreen);
@@ -150,12 +150,12 @@ ScriptManager::ScriptManager(AsylumEngine *engine) : _vm(engine) {
ADD_OPCODE(MoveScenePositionFromActor);
ADD_OPCODE(PaletteFade);
ADD_OPCODE(StartPaletteFadeThread);
- ADD_OPCODE(_unk46);
- ADD_OPCODE(ActorFaceObject);
- ADD_OPCODE(_unk48_MATTE_01);
- ADD_OPCODE(_unk49_MATTE_90);
+ ADD_OPCODE(PlaySoundUpdateObject);
+ ADD_OPCODE(ActorFaceTarget);
+ ADD_OPCODE(HideMatteBars);
+ ADD_OPCODE(ShowMatteBars);
ADD_OPCODE(JumpIfSoundPlaying);
- ADD_OPCODE(ChangePlayerActorIndex);
+ ADD_OPCODE(ChangePlayer);
ADD_OPCODE(ChangeActorStatus);
ADD_OPCODE(StopSound);
ADD_OPCODE(JumpRandom);
@@ -163,23 +163,23 @@ ScriptManager::ScriptManager(AsylumEngine *engine) : _vm(engine) {
ADD_OPCODE(Quit);
ADD_OPCODE(JumpObjectFrame);
ADD_OPCODE(DeleteGraphics);
- ADD_OPCODE(DeleteGraphics);
- ADD_OPCODE(_unk54_SET_ACTIONLIST_6EC);
- ADD_OPCODE(_unk55);
- ADD_OPCODE(_unk56);
+ ADD_OPCODE(SetActorField944);
+ ADD_OPCODE(SetScriptField1BB0);
+ ADD_OPCODE(OnScriptField1BB0);
+ ADD_OPCODE(Interact);
ADD_OPCODE(SetResourcePalette);
- ADD_OPCODE(SetObjectFrameIdxFlaged);
- ADD_OPCODE(_unk59);
- ADD_OPCODE(_unk5A);
- ADD_OPCODE(_unk5B);
+ ADD_OPCODE(SetObjectFrameIndexAndFlags);
+ ADD_OPCODE(SetObjectFlags);
+ ADD_OPCODE(SetActorActionIndex2);
+ ADD_OPCODE(UpdateObjectFields);
ADD_OPCODE(QueueScript);
- ADD_OPCODE(_unk5D);
+ ADD_OPCODE(ProcessActor);
ADD_OPCODE(ClearActorFields);
- ADD_OPCODE(SetObjectLastFrameIdx);
- ADD_OPCODE(_unk60_SET_OR_CLR_ACTIONAREA_FLAG);
- ADD_OPCODE(_unk61);
- ADD_OPCODE(ShowOptionsScreen);
- ADD_OPCODE(_unk63);
+ ADD_OPCODE(SetObjectLastFrameIndex);
+ ADD_OPCODE(SetActionAreaFlags);
+ ADD_OPCODE(UpdatePlayerChapter9);
+ ADD_OPCODE(ShowMenu);
+ ADD_OPCODE(UpdateGlobalFlags);
reset();
}
@@ -208,7 +208,7 @@ void ScriptManager::load(Common::SeekableReadStream *stream) {
memset(&command, 0, sizeof(ScriptEntry));
command.numLines = stream->readSint32LE();
- command.opcode = stream->readSint32LE();
+ command.opcode = (OpcodeType)stream->readSint32LE();
command.param1 = stream->readSint32LE();
command.param2 = stream->readSint32LE();
command.param3 = stream->readSint32LE();
@@ -795,26 +795,26 @@ END_OPCODE
//////////////////////////////////////////////////////////////////////////
// Opcode 0x22
-IMPLEMENT_OPCODE(_unk22)
+IMPLEMENT_OPCODE(AddReactionHive)
Actor *actor = getScene()->getActor(cmd->param3 ? cmd->param3 : _currentQueueEntry->actorIndex);
- actor->process_41BC00(cmd->param1, cmd->param2);
+ actor->addReactionHive(cmd->param1, cmd->param2);
END_OPCODE
//////////////////////////////////////////////////////////////////////////
// Opcode 0x23
-IMPLEMENT_OPCODE(_unk23)
+IMPLEMENT_OPCODE(RemoveReactionHive)
Actor *actor = getScene()->getActor(cmd->param3 ? cmd->param3 : _currentQueueEntry->actorIndex);
- actor->process_41BCC0(cmd->param1, cmd->param2);
+ actor->removeReactionHive(cmd->param1, cmd->param2);
END_OPCODE
//////////////////////////////////////////////////////////////////////////
// Opcode 0x24
-IMPLEMENT_OPCODE(_unk24)
+IMPLEMENT_OPCODE(HasMoreReaction)
Actor *actor = getScene()->getActor(cmd->param4 ? cmd->param4 : _currentQueueEntry->actorIndex);
- actor->process_41BDB0(cmd->param1, (bool)cmd->param3);
+ actor->hasMoreReactions(cmd->param1, (bool)cmd->param3);
END_OPCODE
//////////////////////////////////////////////////////////////////////////
@@ -896,7 +896,7 @@ END_OPCODE
//////////////////////////////////////////////////////////////////////////
// Opcode 0x2C
-IMPLEMENT_OPCODE(_unk2C_ActorSub)
+IMPLEMENT_OPCODE(UpdateActor)
Actor *player = getScene()->getActor();
Actor *actor = getScene()->getActor(_currentQueueEntry->actorIndex);
Common::Point playerPoint((int16)(player->getPoint1()->x + player->getPoint2()->x), (int16)(player->getPoint1()->y + player->getPoint2()->y));
@@ -1060,7 +1060,7 @@ END_OPCODE
//////////////////////////////////////////////////////////////////////////
// Opcode 0x34
-IMPLEMENT_OPCODE(_unk34_Status)
+IMPLEMENT_OPCODE(IncrementParam1)
if (cmd->param1 >= 2) {
cmd->param1 = 0;
} else {
@@ -1095,7 +1095,7 @@ END_OPCODE
//////////////////////////////////////////////////////////////////////////
// Opcode 0x37
-IMPLEMENT_OPCODE(RunBlowUpPuzzle)
+IMPLEMENT_OPCODE(RunPuzzle)
getScreen()->clear();
getScreen()->clearGraphicsInQueue();
@@ -1126,7 +1126,7 @@ END_OPCODE
//////////////////////////////////////////////////////////////////////////
// Opcode 0x3B
-IMPLEMENT_OPCODE(_unk3B_PALETTE_MOD)
+IMPLEMENT_OPCODE(CreatePalette)
if (!cmd->param2) {
getScreen()->makeGreyPalette();
cmd->param2 = 1;
@@ -1408,7 +1408,7 @@ END_OPCODE
//////////////////////////////////////////////////////////////////////////
// Opcode 0x46
-IMPLEMENT_OPCODE(_unk46)
+IMPLEMENT_OPCODE(PlaySoundUpdateObject)
if (cmd->param6) {
if (getSound()->isPlaying(getSpeech()->getSoundResourceId())) {
_processNextEntry = 1;
@@ -1452,13 +1452,13 @@ END_OPCODE
//////////////////////////////////////////////////////////////////////////
// Opcode 0x47
-IMPLEMENT_OPCODE(ActorFaceObject)
+IMPLEMENT_OPCODE(ActorFaceTarget)
getScene()->getActor(cmd->param1)->faceTarget((ObjectId)cmd->param2, (DirectionFrom)cmd->param3);
END_OPCODE
//////////////////////////////////////////////////////////////////////////
// Opcode 0x48
-IMPLEMENT_OPCODE(_unk48_MATTE_01)
+IMPLEMENT_OPCODE(HideMatteBars)
getSharedData()->matteVar1 = 0;
getSharedData()->matteInitialized = true;
@@ -1478,7 +1478,7 @@ END_OPCODE
//////////////////////////////////////////////////////////////////////////
// Opcode 0x49
-IMPLEMENT_OPCODE(_unk49_MATTE_90)
+IMPLEMENT_OPCODE(ShowMatteBars)
getSharedData()->matteVar1 = 0;
getSharedData()->matteInitialized = true;
getSharedData()->mattePlaySound = true;
@@ -1511,7 +1511,7 @@ END_OPCODE
//////////////////////////////////////////////////////////////////////////
// Opcode 0x4B
-IMPLEMENT_OPCODE(ChangePlayerActorIndex)
+IMPLEMENT_OPCODE(ChangePlayer)
getScene()->changePlayer(cmd->param1);
END_OPCODE
@@ -1611,7 +1611,7 @@ END_OPCODE
//////////////////////////////////////////////////////////////////////////
// Opcode 0x54
-IMPLEMENT_OPCODE(_unk54_SET_ACTIONLIST_6EC)
+IMPLEMENT_OPCODE(SetScriptField1BB0)
if (cmd->param2)
_currentScript->field_1BB0 = _vm->getRandom((uint32)cmd->param1);
else
@@ -1620,7 +1620,7 @@ END_OPCODE
//////////////////////////////////////////////////////////////////////////
// Opcode 0x55
-IMPLEMENT_OPCODE(_unk55)
+IMPLEMENT_OPCODE(OnScriptField1BB0)
if (cmd->param2) {
if (_currentScript->field_1BB0 == cmd->param1)
@@ -1652,7 +1652,7 @@ END_OPCODE
//////////////////////////////////////////////////////////////////////////
// Opcode 0x56
-IMPLEMENT_OPCODE(_unk56)
+IMPLEMENT_OPCODE(Interact)
Actor *actor = getScene()->getActor(cmd->param2 == 2 ? kActorInvalid : cmd->param1);
if (actor->getStatus() == kActorStatus2 || actor->getStatus() == kActorStatus13) {
@@ -1704,7 +1704,7 @@ END_OPCODE
//////////////////////////////////////////////////////////////////////////
// Opcode 0x58
-IMPLEMENT_OPCODE(SetObjectFrameIdxFlaged)
+IMPLEMENT_OPCODE(SetObjectFrameIndexAndFlags)
Object *object = getWorld()->getObjectById((ObjectId)cmd->param1);
if (cmd->param3)
@@ -1717,7 +1717,7 @@ END_OPCODE
//////////////////////////////////////////////////////////////////////////
// Opcode 0x59
-IMPLEMENT_OPCODE(_unk59)
+IMPLEMENT_OPCODE(SetObjectFlags)
Object *object = getWorld()->getObjectById((ObjectId)cmd->param1);
if (cmd->param2) {
@@ -1732,13 +1732,13 @@ END_OPCODE
//////////////////////////////////////////////////////////////////////////
// Opcode 0x5A
-IMPLEMENT_OPCODE(_unk5A)
+IMPLEMENT_OPCODE(SetActorActionIndex2)
getScene()->getActor(cmd->param1)->setActionIndex2(cmd->param2);
END_OPCODE
//////////////////////////////////////////////////////////////////////////
// Opcode 0x5B
-IMPLEMENT_OPCODE(_unk5B)
+IMPLEMENT_OPCODE(UpdateObjectFields)
if (cmd->param2 >= 0 && cmd->param2 <= 3) {
if (cmd->param1) {
Object *object = getWorld()->getObjectById((ObjectId)cmd->param1);
@@ -1761,7 +1761,7 @@ END_OPCODE
//////////////////////////////////////////////////////////////////////////
// Opcode 0x5D
-IMPLEMENT_OPCODE(_unk5D)
+IMPLEMENT_OPCODE(ProcessActor)
Actor *actor = getScene()->getActor(cmd->param1);
actor->process_401830(cmd->param2, cmd->param3, cmd->param4, cmd->param5, cmd->param6, cmd->param7, cmd->param8, cmd->param9);
@@ -1778,7 +1778,7 @@ END_OPCODE
//////////////////////////////////////////////////////////////////////////
// Opcode 0x5F
-IMPLEMENT_OPCODE(SetObjectLastFrameIdx)
+IMPLEMENT_OPCODE(SetObjectLastFrameIndex)
Object *object = getWorld()->getObjectById((ObjectId)cmd->param1);
if (object->getFrameIndex() == object->getFrameCount() - 1) {
@@ -1791,7 +1791,7 @@ END_OPCODE
//////////////////////////////////////////////////////////////////////////
// Opcode 0x60
-IMPLEMENT_OPCODE(_unk60_SET_OR_CLR_ACTIONAREA_FLAG)
+IMPLEMENT_OPCODE(SetActionAreaFlags)
ActionArea *area = getWorld()->getActionAreaById(cmd->param1);
if (cmd->param2)
@@ -1802,7 +1802,7 @@ END_OPCODE
//////////////////////////////////////////////////////////////////////////
// Opcode 0x61
-IMPLEMENT_OPCODE(_unk61)
+IMPLEMENT_OPCODE(UpdatePlayerChapter9)
if (cmd->param2) {
if (getWorld()->nextPlayer == kActorInvalid) {
_processNextEntry = 0;
@@ -1819,13 +1819,13 @@ END_OPCODE
//////////////////////////////////////////////////////////////////////////
// Opcode 0x62
-IMPLEMENT_OPCODE(ShowOptionsScreen)
+IMPLEMENT_OPCODE(ShowMenu)
_vm->menu()->show();
END_OPCODE
//////////////////////////////////////////////////////////////////////////
// Opcode 0x63
-IMPLEMENT_OPCODE(_unk63)
+IMPLEMENT_OPCODE(UpdateGlobalFlags)
if (cmd->param1) {
getSharedData()->setFlag(kFlag1, true);
getSharedData()->setFlag(kFlag2, true);
diff --git a/engines/asylum/resources/script.h b/engines/asylum/resources/script.h
index 4dc52d2e73..33ed8d2c10 100644
--- a/engines/asylum/resources/script.h
+++ b/engines/asylum/resources/script.h
@@ -36,10 +36,10 @@ namespace Asylum {
#define MAX_ACTION_COMMANDS 161
#define DECLARE_OPCODE(name) \
- void k##name(ScriptEntry *cmd)
+ void Op##name(ScriptEntry *cmd)
#define IMPLEMENT_OPCODE(name) \
- void ScriptManager::k##name(ScriptEntry *cmd) { \
+ void ScriptManager::Op##name(ScriptEntry *cmd) { \
if (!_currentScript) error("[" #name "] No current script set!"); \
if (!cmd) error("[" #name "] Invalid command parameter!");
@@ -47,7 +47,7 @@ namespace Asylum {
#define ADD_OPCODE(name) { \
- Opcode *func = new Opcode(#name, new Common::Functor1Mem<ScriptEntry *, void, ScriptManager>(this, &ScriptManager::k##name)); \
+ Opcode *func = new Opcode(#name, new Common::Functor1Mem<ScriptEntry *, void, ScriptManager>(this, &ScriptManager::Op##name)); \
_opcodes.push_back(func); \
}
@@ -215,7 +215,7 @@ private:
//////////////////////////////////////////////////////////////////////////
struct ScriptEntry {
int32 numLines; // Only set on the first line of each script
- int32 opcode;
+ OpcodeType opcode;
int32 param1;
int32 param2;
int32 param3;
@@ -228,7 +228,7 @@ private:
ScriptEntry() {
numLines = 0;
- opcode = 0;
+ opcode = kOpcodeReturn;
param1 = 0;
param2 = 0;
param3 = 0;
@@ -333,9 +333,9 @@ private:
DECLARE_OPCODE(JumpIfActionTalk);
DECLARE_OPCODE(SetActionTalk);
DECLARE_OPCODE(ClearActionTalk);
- DECLARE_OPCODE(_unk22);
- DECLARE_OPCODE(_unk23);
- DECLARE_OPCODE(_unk24);
+ DECLARE_OPCODE(AddReactionHive);
+ DECLARE_OPCODE(RemoveReactionHive);
+ DECLARE_OPCODE(HasMoreReaction);
DECLARE_OPCODE(RunEncounter);
DECLARE_OPCODE(JumpIfAction16);
DECLARE_OPCODE(SetAction16);
@@ -343,7 +343,7 @@ private:
DECLARE_OPCODE(SetActorField638);
DECLARE_OPCODE(JumpIfActorField638);
DECLARE_OPCODE(ChangeScene);
- DECLARE_OPCODE(_unk2C_ActorSub);
+ DECLARE_OPCODE(UpdateActor);
DECLARE_OPCODE(PlayMovie);
DECLARE_OPCODE(StopAllObjectsSounds);
DECLARE_OPCODE(StopProcessing);
@@ -351,14 +351,14 @@ private:
DECLARE_OPCODE(ResetSceneRect);
DECLARE_OPCODE(ChangeMusicById);
DECLARE_OPCODE(StopMusic);
- DECLARE_OPCODE(_unk34_Status);
+ DECLARE_OPCODE(IncrementParam1);
DECLARE_OPCODE(SetVolume);
DECLARE_OPCODE(Jump);
- DECLARE_OPCODE(RunBlowUpPuzzle);
+ DECLARE_OPCODE(RunPuzzle);
DECLARE_OPCODE(JumpIfAction8);
DECLARE_OPCODE(SetAction8);
DECLARE_OPCODE(ClearAction8);
- DECLARE_OPCODE(_unk3B_PALETTE_MOD);
+ DECLARE_OPCODE(CreatePalette);
DECLARE_OPCODE(IncrementParam2);
DECLARE_OPCODE(WaitUntilFramePlayed);
DECLARE_OPCODE(UpdateWideScreen);
@@ -369,12 +369,12 @@ private:
DECLARE_OPCODE(MoveScenePositionFromActor);
DECLARE_OPCODE(PaletteFade);
DECLARE_OPCODE(StartPaletteFadeThread);
- DECLARE_OPCODE(_unk46);
- DECLARE_OPCODE(ActorFaceObject);
- DECLARE_OPCODE(_unk48_MATTE_01);
- DECLARE_OPCODE(_unk49_MATTE_90);
+ DECLARE_OPCODE(PlaySoundUpdateObject);
+ DECLARE_OPCODE(ActorFaceTarget);
+ DECLARE_OPCODE(HideMatteBars);
+ DECLARE_OPCODE(ShowMatteBars);
DECLARE_OPCODE(JumpIfSoundPlaying);
- DECLARE_OPCODE(ChangePlayerActorIndex);
+ DECLARE_OPCODE(ChangePlayer);
DECLARE_OPCODE(ChangeActorStatus);
DECLARE_OPCODE(StopSound);
DECLARE_OPCODE(JumpRandom);
@@ -383,22 +383,22 @@ private:
DECLARE_OPCODE(JumpObjectFrame);
DECLARE_OPCODE(DeleteGraphics);
DECLARE_OPCODE(SetActorField944);
- DECLARE_OPCODE(_unk54_SET_ACTIONLIST_6EC);
- DECLARE_OPCODE(_unk55);
- DECLARE_OPCODE(_unk56);
+ DECLARE_OPCODE(SetScriptField1BB0);
+ DECLARE_OPCODE(OnScriptField1BB0);
+ DECLARE_OPCODE(Interact);
DECLARE_OPCODE(SetResourcePalette);
- DECLARE_OPCODE(SetObjectFrameIdxFlaged);
- DECLARE_OPCODE(_unk59);
- DECLARE_OPCODE(_unk5A);
- DECLARE_OPCODE(_unk5B);
+ DECLARE_OPCODE(SetObjectFrameIndexAndFlags);
+ DECLARE_OPCODE(SetObjectFlags);
+ DECLARE_OPCODE(SetActorActionIndex2);
+ DECLARE_OPCODE(UpdateObjectFields);
DECLARE_OPCODE(QueueScript);
- DECLARE_OPCODE(_unk5D);
+ DECLARE_OPCODE(ProcessActor);
DECLARE_OPCODE(ClearActorFields);
- DECLARE_OPCODE(SetObjectLastFrameIdx);
- DECLARE_OPCODE(_unk60_SET_OR_CLR_ACTIONAREA_FLAG);
- DECLARE_OPCODE(_unk61);
- DECLARE_OPCODE(ShowOptionsScreen);
- DECLARE_OPCODE(_unk63);
+ DECLARE_OPCODE(SetObjectLastFrameIndex);
+ DECLARE_OPCODE(SetActionAreaFlags);
+ DECLARE_OPCODE(UpdatePlayerChapter9);
+ DECLARE_OPCODE(ShowMenu);
+ DECLARE_OPCODE(UpdateGlobalFlags);
friend class Console;
}; // end of class ActionList
diff --git a/engines/asylum/resources/special.cpp b/engines/asylum/resources/special.cpp
index e1d91e355d..d4f245a58c 100644
--- a/engines/asylum/resources/special.cpp
+++ b/engines/asylum/resources/special.cpp
@@ -543,7 +543,7 @@ void Special::chapter8(Object *object, ActorIndex actorIndex) {
if (object->getFrameIndex() == 23) {
if (_vm->isGameFlagNotSet(kGameFlag815))
- actor0->process_41BC00(1, 0);
+ actor0->addReactionHive(1, 0);
_vm->setGameFlag(kGameFlag815);
}
diff --git a/engines/asylum/shared.h b/engines/asylum/shared.h
index 1429d1bdd9..b0cdd5cb5d 100644
--- a/engines/asylum/shared.h
+++ b/engines/asylum/shared.h
@@ -42,7 +42,7 @@ enum GameFlag {
kGameFlagCommentLeavingCell = 214,
kGameFlag215 = 215,
kGameFlag219 = 219,
- kGameFlagSolveVCRBlowUpPuzzle = 220,
+ kGameFlagSolveVCRPuzzle = 220,
kGameFlag235 = 235,
kGameFlag238 = 238,
kGameFlag239 = 239,
@@ -252,7 +252,6 @@ enum DrawFlags {
//////////////////////////////////////////////////////////////////////////
// Actions
//////////////////////////////////////////////////////////////////////////
-
enum ActionType {
kActionTypeNone = 0,
kActionTypeFind = 1,
@@ -262,6 +261,112 @@ enum ActionType {
kActionType16 = 16
};
+//////////////////////////////////////////////////////////////////////////
+// Script
+//////////////////////////////////////////////////////////////////////////
+enum OpcodeType {
+ kOpcodeReturn = 0,
+ kOpcodeSetGameFlag,
+ kOpcodeClearGameFlag,
+ kOpcodeToggleGameFlag,
+ kOpcodeJumpIfGameFlag,
+ kOpcodeHideCursor, // 5
+ kOpcodeShowCursor,
+ kOpcodePlayAnimation,
+ kOpcodeMoveScenePosition,
+ kOpcodeHideActor,
+ kOpcodeShowActor, // 10
+ kOpcodeSetActorPosition,
+ kOpcodeSetSceneMotionStatus,
+ kOpcodeDisableActor,
+ kOpcodeEnableActor,
+ kOpcodeEnableObjects, // 15
+ kOpcodeReturn1,
+ kOpcodeRemoveObject,
+ kOpcodeJumpActorSpeech,
+ kOpcodeJumpAndSetDirection,
+ kOpcodeJumpIfActorCoordinates, // 20
+ kOpcodeNop,
+ kOpcodeResetAnimation,
+ kOpcodeDisableObject,
+ kOpcodeJumpIfSoundPlayingAndPlaySound,
+ kOpcodeJumpIfActionFind, // 25
+ kOpcodeSetActionFind,
+ kOpcodeClearActionFind,
+ kOpcodeJumpIfActionGrab,
+ kOpcodeSetActionGrab,
+ kOpcodeClearActionGrab, // 30
+ kOpcodeJumpIfActionTalk,
+ kOpcodeSetActionTalk,
+ kOpcodeClearActionTalk,
+ kOpcodeAddReactionHive,
+ kOpcodeRemoveReactionHive, // 35
+ kOpcodeHasMoreReactions,
+ kOpcodeRunEncounter,
+ kOpcodeJumpIfAction16,
+ kOpcodeSetAction16,
+ kOpcodeClearAction16, // 40
+ kOpcodeSetActorField638,
+ kOpcodeJumpIfActorField638,
+ kOpcodeChangeScene,
+ kOpcodeUpdateActor,
+ kOpcodePlayMovie, // 45
+ kOpcodeStopAllObjectsSounds,
+ kOpcodeStopProcessing,
+ kOpcodeResumeProcessing,
+ kOpcodeResetSceneRect,
+ kOpcodeChangeMusicById, // 50
+ kOpcodeStopMusic,
+ kOpcodeIncrementParam1,
+ kOpcodeSetVolume,
+ kOpcodeJump,
+ kOpcodeRunPuzzle, // 55
+ kOpcodeJumpIfAction8,
+ kOpcodeSetAction8,
+ kOpcodeClearAction8,
+ kOpcodeCreatePalette,
+ kOpcodeIncrementParam2, // 60
+ kOpcodeWaitUntilFramePlayed,
+ kOpcodeUpdateWideScreen,
+ kOpcodeJumpIfActor,
+ kOpcodePlaySpeechScene,
+ kOpcodePlaySpeech, // 65
+ kOpcodePlaySpeechScene2,
+ kOpcodeMoveScenePositionFromActor,
+ kOpcodePaletteFade,
+ kOpcodeStartPaletteFadeThread,
+ kOpcodePlaySoundUpdateObject, // 70
+ kOpcodeActorFaceTarget,
+ kOpcodeHidMatteBars,
+ kOpcodeShowMatteBars,
+ kOpcodeJumpIfSoundPlaying,
+ kOpcodeChangePlayer, // 75
+ kOpcodeChangeActorStatus,
+ kOpcodeStopSound,
+ kOpcodeJumpRandom,
+ kOpcodeClearScreen,
+ kOpcodeQuit, // 80
+ kOpcodeJumpObjectFrame,
+ kOpcodeDeleteGraphics,
+ kOpcodeSetPlayerField944,
+ kOpcodeSetScriptField1BB0,
+ kOpcodeOnScriptField1BB0, // 85
+ kOpcodeInteract,
+ kOpcodeSetResourcePalette,
+ kOpcodeSetObjectFrameIndexAndFlags,
+ kOpcodeSetObjectFlags,
+ kOpcodeSetActorActionIndex2, // 90
+ kOpcodeUpdateObjectFields,
+ kOpcodeQueueScript,
+ kOpcodeProcessActor,
+ kOpcodeClearActorFields,
+ kOpcodeSetObjectLastFrameIndex, // 95
+ kOpcodeSetActionAreaFlags,
+ kOpcodeUpdatePlayerChapter9,
+ kOpcodeShowMenu,
+ kOpcodeUpdateGlobalFlags
+};
+
//////////////////////////////////////////////////////////////////////////
// Actor
//////////////////////////////////////////////////////////////////////////
Commit: 62d576eae52d4f35520b750ae18f66ee83d10920
https://github.com/scummvm/scummvm/commit/62d576eae52d4f35520b750ae18f66ee83d10920
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:37:03+02:00
Commit Message:
ASYLUM: Add debug drawing of zoomed mask
- Update blit functions parameters
Changed paths:
engines/asylum/system/screen.cpp
engines/asylum/system/screen.h
diff --git a/engines/asylum/system/screen.cpp b/engines/asylum/system/screen.cpp
index a69d84f044..2fd3cc8806 100644
--- a/engines/asylum/system/screen.cpp
+++ b/engines/asylum/system/screen.cpp
@@ -541,7 +541,7 @@ void Screen::blit(GraphicFrame *frame, Common::Rect *source, Common::Rect *desti
_backBuffer.frameRect(*destination, 0x220);
}
-void Screen::blitTranstable(byte *dstBuffer, byte *srcBuffer, int16 height, int16 width, int32 srcPitch, int32 dstPitch) {
+void Screen::blitTranstable(byte *dstBuffer, byte *srcBuffer, int16 height, int16 width, uint16 srcPitch, uint16 dstPitch) {
while (height--) {
for (int16 i = width; i; --i) {
if (*srcBuffer)
@@ -556,7 +556,7 @@ void Screen::blitTranstable(byte *dstBuffer, byte *srcBuffer, int16 height, int1
}
}
-void Screen::blitTranstableMirrored(byte *dstBuffer, byte *srcBuffer, int16 height, int16 width, int32 srcPitch, int32 dstPitch) {
+void Screen::blitTranstableMirrored(byte *dstBuffer, byte *srcBuffer, int16 height, int16 width, uint16 srcPitch, uint16 dstPitch) {
while (height--) {
for (int16 i = width; i; --i) {
if (*srcBuffer)
@@ -571,7 +571,7 @@ void Screen::blitTranstableMirrored(byte *dstBuffer, byte *srcBuffer, int16 heig
}
}
-void Screen::blitCrossfade(byte *dstBuffer, byte *srcBuffer, byte *objectBuffer, int16 height, int16 width, uint32 srcPitch, uint32 dstPitch, uint32 objectPitch) {
+void Screen::blitCrossfade(byte *dstBuffer, byte *srcBuffer, byte *objectBuffer, int16 height, int16 width, uint16 srcPitch, uint16 dstPitch, uint16 objectPitch) {
while (height--) {
for (int16 i = width; i; --i) {
if (*srcBuffer)
@@ -588,7 +588,7 @@ void Screen::blitCrossfade(byte *dstBuffer, byte *srcBuffer, byte *objectBuffer,
}
}
-void Screen::blitMirrored(byte *dstBuffer, byte *srcBuffer, int16 height, int16 width, int32 srcPitch, int32 dstPitch) {
+void Screen::blitMirrored(byte *dstBuffer, byte *srcBuffer, int16 height, int16 width, uint16 srcPitch, uint16 dstPitch) {
while (height--) {
for (int16 i = width; i; --i) {
*dstBuffer = *srcBuffer;
@@ -602,7 +602,7 @@ void Screen::blitMirrored(byte *dstBuffer, byte *srcBuffer, int16 height, int16
}
}
-void Screen::blitMirroredColorKey(byte *dstBuffer, byte *srcBuffer, int16 height, int16 width, int32 srcPitch, int32 dstPitch) {
+void Screen::blitMirroredColorKey(byte *dstBuffer, byte *srcBuffer, int16 height, int16 width, uint16 srcPitch, uint16 dstPitch) {
while (height--) {
for (int16 i = width; i; --i) {
if (*srcBuffer != 0)
@@ -617,7 +617,7 @@ void Screen::blitMirroredColorKey(byte *dstBuffer, byte *srcBuffer, int16 height
}
}
-void Screen::blitRaw(byte *dstBuffer, byte *srcBuffer, int16 height, int16 width, int32 srcPitch, int32 dstPitch) {
+void Screen::blitRaw(byte *dstBuffer, byte *srcBuffer, int16 height, int16 width, uint16 srcPitch, uint16 dstPitch) {
while (height--) {
memcpy(dstBuffer, srcBuffer, width);
dstBuffer += dstPitch;
@@ -625,7 +625,7 @@ void Screen::blitRaw(byte *dstBuffer, byte *srcBuffer, int16 height, int16 width
}
}
-void Screen::blitRawColorKey(byte *dstBuffer, byte *srcBuffer, int16 height, int16 width, int32 srcPitch, int32 dstPitch) {
+void Screen::blitRawColorKey(byte *dstBuffer, byte *srcBuffer, int16 height, int16 width, uint16 srcPitch, uint16 dstPitch) {
while (height--) {
for (int16 i = width; i; --i) {
if (*srcBuffer != 0)
@@ -640,11 +640,11 @@ void Screen::blitRawColorKey(byte *dstBuffer, byte *srcBuffer, int16 height, int
}
}
-void Screen::blitMasked(GraphicFrame *frame, Common::Rect *source, byte *maskData, Common::Rect *sourceMask, Common::Rect *destMask, int maskHeight, Common::Rect *destination, int32 flags) {
+void Screen::blitMasked(GraphicFrame *frame, Common::Rect *source, byte *maskData, Common::Rect *sourceMask, Common::Rect *destMask, int maskWidth, Common::Rect *destination, int32 flags) {
byte *frameBuffer = (byte *)frame->surface.pixels;
byte *mirroredBuffer = NULL;
int16 frameRight = frame->surface.pitch;
- int16 srcMaskLeft = abs(sourceMask->left);
+ uint16 srcMaskLeft = abs(sourceMask->left);
// Prepare temporary source buffer if needed
if (flags & kDrawFlagMirrorLeftRight) {
@@ -665,7 +665,7 @@ void Screen::blitMasked(GraphicFrame *frame, Common::Rect *source, byte *maskDat
// Setup buffers and rectangles
byte *frameBufferPtr = frameBuffer + source->top * frameRight + source->left;
- byte *maskBufferPtr = maskData + sourceMask->top * (maskHeight / 8) + sourceMask->left / 8;
+ byte *maskBufferPtr = maskData + sourceMask->top * (maskWidth / 8) + sourceMask->left / 8;
// Check if we need to draw masked
if ((destMask->left + sourceMask->width()) < destination->left
@@ -698,7 +698,7 @@ void Screen::blitMasked(GraphicFrame *frame, Common::Rect *source, byte *maskDat
}
if (destination->top > destMask->top) {
- maskBufferPtr += (destination->top - destMask->top) * maskHeight / 8;
+ maskBufferPtr += (destination->top - destMask->top) * maskWidth / 8;
sourceMask->setHeight(sourceMask->height() + destMask->top - destination->top);
destMask->top = destination->top;
}
@@ -775,21 +775,52 @@ void Screen::blitMasked(GraphicFrame *frame, Common::Rect *source, byte *maskDat
source->height(),
source->width(),
frameRight - source->width(),
- (maskHeight - srcMaskLeft - source->width()) / 8,
+ (maskWidth - srcMaskLeft - source->width()) / 8,
srcMaskLeft,
(byte *)_backBuffer.pixels + _backBuffer.pitch * destination->top + destination->left,
_backBuffer.pitch - source->width());
// Draw debug rects
- if (g_debugDrawRects)
+ if (g_debugDrawRects) {
_backBuffer.frameRect(*destination, 0x128);
+ drawZoomedMask(maskData, 21, maskWidth / 8, maskWidth);
+ }
// Cleanup
delete mirroredBuffer;
}
-void Screen::bltMasked(byte *srcBuffer, byte *maskBuffer, int16 height, int16 width, int16 srcPitch, int16 maskPitch, char maskLeft, byte *dstBuffer, int16 dstPitch) {
- warning("[Screen::bltMasked] Not implemented!");
+// DEBUG: Draw the mask (zoomed)
+void Screen::drawZoomedMask(byte *mask, int16 height, int16 width, uint16 maskPitch) {
+ int zoom = 8;
+
+ byte *dstBuffer = (byte *)_backBuffer.pixels;
+ uint16 dstPitch = _backBuffer.pitch - (width * zoom);
+ uint16 srcPitch = maskPitch;
+ byte *srcBuffer = mask;
+
+ height *= zoom;
+
+ while (height--) {
+ for (int16 i = 0; i < width; i++) {
+ for (int j = 0; j < zoom; j++) {
+ *dstBuffer = *srcBuffer;
+ dstBuffer++;
+ }
+
+ srcBuffer++;
+ }
+
+ dstBuffer += dstPitch;
+ srcBuffer += (height % zoom) ? -width : srcPitch;
+ }
+}
+
+void Screen::bltMasked(byte *srcBuffer, byte *maskBuffer, int16 height, int16 width, uint16 srcPitch, uint16 maskPitch, byte maskLeft, byte *dstBuffer, uint16 dstPitch) {
+ // FIXME: Use mask
+ //warning("[Screen::bltMasked] Not implemented!");
+
+ blitRawColorKey(dstBuffer, srcBuffer, height, width, srcPitch, dstPitch);
}
void Screen::blt(Common::Rect *dest, GraphicFrame* frame, Common::Rect *source, int32 flags) {
diff --git a/engines/asylum/system/screen.h b/engines/asylum/system/screen.h
index 54af71d1c5..86f50ad35c 100644
--- a/engines/asylum/system/screen.h
+++ b/engines/asylum/system/screen.h
@@ -153,21 +153,24 @@ private:
// Screen blitting
void blit(GraphicFrame *frame, Common::Rect *source, Common::Rect *destination, int32 flags);
- void blitMasked(GraphicFrame *frame, Common::Rect *source, byte *maskData, Common::Rect *sourceMask, Common::Rect *destMask, int maskHeight, Common::Rect *destination, int32 flags);
- void blitTranstable (byte *dstBuffer, byte *srcBuffer, int16 height, int16 width, int32 srcPitch, int32 dstPitch);
- void blitTranstableMirrored(byte *dstBuffer, byte *srcBuffer, int16 height, int16 width, int32 srcPitch, int32 dstPitch);
- void blitMirrored (byte *dstBuffer, byte *srcBuffer, int16 height, int16 width, int32 srcPitch, int32 dstPitch);
- void blitMirroredColorKey (byte *dstBuffer, byte *srcBuffer, int16 height, int16 width, int32 srcPitch, int32 dstPitch);
- void blitRaw (byte *dstBuffer, byte *srcBuffer, int16 height, int16 width, int32 srcPitch, int32 dstPitch);
- void blitRawColorKey (byte *dstBuffer, byte *srcBuffer, int16 height, int16 width, int32 srcPitch, int32 dstPitch);
- void blitCrossfade (byte *dstBuffer, byte *srcBuffer, byte *objectBuffer, int16 height, int16 width, uint32 srcPitch, uint32 dstPitch, uint32 objectPitch);
- void bltMasked (byte *srcBuffer, byte *maskBuffer, int16 height, int16 width, int16 srcPitch, int16 maskPitch, char maskLeft, byte *dstBuffer, int16 dstPitch);
+ void blitMasked(GraphicFrame *frame, Common::Rect *source, byte *maskData, Common::Rect *sourceMask, Common::Rect *destMask, int maskWidth, Common::Rect *destination, int32 flags);
+ void blitTranstable (byte *dstBuffer, byte *srcBuffer, int16 height, int16 width, uint16 srcPitch, uint16 dstPitch);
+ void blitTranstableMirrored(byte *dstBuffer, byte *srcBuffer, int16 height, int16 width, uint16 srcPitch, uint16 dstPitch);
+ void blitMirrored (byte *dstBuffer, byte *srcBuffer, int16 height, int16 width, uint16 srcPitch, uint16 dstPitch);
+ void blitMirroredColorKey (byte *dstBuffer, byte *srcBuffer, int16 height, int16 width, uint16 srcPitch, uint16 dstPitch);
+ void blitRaw (byte *dstBuffer, byte *srcBuffer, int16 height, int16 width, uint16 srcPitch, uint16 dstPitch);
+ void blitRawColorKey (byte *dstBuffer, byte *srcBuffer, int16 height, int16 width, uint16 srcPitch, uint16 dstPitch);
+ void blitCrossfade (byte *dstBuffer, byte *srcBuffer, byte *objectBuffer, int16 height, int16 width, uint16 srcPitch, uint16 dstPitch, uint16 objectPitch);
+ void bltMasked (byte *srcBuffer, byte *maskBuffer, int16 height, int16 width, uint16 srcPitch, uint16 maskPitch, byte maskLeft, byte *dstBuffer, uint16 dstPitch);
// DirectDraw-equivalent functions
void blt(Common::Rect *dest, GraphicFrame* frame, Common::Rect *source, int32 flags);
void bltFast(int32 dX, int32 dY, GraphicFrame* frame, Common::Rect *source);
void copyToBackBufferWithTransparency(byte *buffer, int32 pitch, int32 x, int32 y, int32 width, int32 height, bool mirrored = false);
+
+ // Debug
+ void drawZoomedMask(byte *mask, int16 height, int16 width, uint16 maskPitch);
};
} // end of namespace Asylum
Commit: 81c6898fa622e41a8657b7e41f3bc3f2357481ed
https://github.com/scummvm/scummvm/commit/81c6898fa622e41a8657b7e41f3bc3f2357481ed
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:37:03+02:00
Commit Message:
ASYLUM: Simplify handling of transparency tables
The original uses an optimization to be able to hold the transparency table address + offset into a single register by clearing the lower 16 bits of the address. Not doing so simplifies the code and saves an allocation of 65536 bytes.
Changed paths:
engines/asylum/system/screen.cpp
engines/asylum/system/screen.h
diff --git a/engines/asylum/system/screen.cpp b/engines/asylum/system/screen.cpp
index 2fd3cc8806..91aaf32dbc 100644
--- a/engines/asylum/system/screen.cpp
+++ b/engines/asylum/system/screen.cpp
@@ -31,14 +31,16 @@
#include "asylum/asylum.h"
#include "asylum/respack.h"
-#include <stdarg.h> // For va_list etc.
+#include <stdarg.h> // For va_list etc.
namespace Asylum {
int g_debugDrawRects;
+#define TRANSPARENCY_TABLE_SIZE 256 * 256
+
Screen::Screen(AsylumEngine *vm) : _vm(vm) ,
- _useColorKey(false), _transTableCount(0), _transTableIndex(NULL), _transTableData(NULL), _transTableBuffer(NULL) {
+ _useColorKey(false), _transTableCount(0), _transTable(NULL), _transTableBuffer(NULL) {
_backBuffer.create(640, 480, Graphics::PixelFormat::createFormatCLUT8());
_flag = -1;
@@ -68,12 +70,12 @@ void Screen::draw(ResourceId resourceId, uint32 frameIndex, const Common::Point
}
void Screen::draw(ResourceId resourceId, uint32 frameIndex, const Common::Point &source, DrawFlags flags, int32 transTableNum) {
- byte *index = _transTableIndex;
+ byte *index = _transTable;
selectTransTable(transTableNum);
draw(resourceId, frameIndex, source, (DrawFlags)(flags | 0x90000000));
- _transTableIndex = index;
+ _transTable = index;
}
void Screen::draw(ResourceId resourceId, uint32 frameIndex, const Common::Point &source, DrawFlags flags, ResourceId resourceIdDestination, const Common::Point &destination, bool colorKey) {
@@ -306,26 +308,24 @@ void Screen::setupTransTables(uint32 count, ...) {
_transTableCount = count;
- if (!_transTableData) {
- _transTableData = (byte *)malloc((count + 1) * 65536);
- _transTableBuffer = _transTableData + 65536;
- _transTableIndex = _transTableBuffer;
+ if (!_transTableBuffer) {
+ _transTableBuffer = (byte *)malloc(count * TRANSPARENCY_TABLE_SIZE);
+ _transTable = _transTableBuffer;
}
uint32 index = 0;
for (uint32 i = 0; i < _transTableCount; i++) {
ResourceId id = va_arg(va, ResourceId);
- memcpy(&_transTableBuffer[index], getResource()->get(id)->data, 65536);
- index += 65536;
+ memcpy(&_transTableBuffer[index], getResource()->get(id)->data, TRANSPARENCY_TABLE_SIZE);
+ index += TRANSPARENCY_TABLE_SIZE;
}
}
void Screen::clearTransTables() {
- free(_transTableData);
- _transTableData = NULL;
+ free(_transTableBuffer);
_transTableBuffer = NULL;
- _transTableIndex = NULL;
+ _transTable = NULL;
_transTableCount = 0;
}
@@ -333,7 +333,7 @@ void Screen::selectTransTable(uint32 index) {
if (index >= _transTableCount)
return;
- _transTableIndex = &_transTableBuffer[65536 * index];
+ _transTable = &_transTableBuffer[TRANSPARENCY_TABLE_SIZE * index];
}
//////////////////////////////////////////////////////////////////////////
@@ -370,7 +370,7 @@ void Screen::addGraphicToQueueMasked(ResourceId resourceId, uint32 frameIndex, c
void Screen::addGraphicToQueueCrossfade(ResourceId resourceId, uint32 frameIndex, Common::Point point, int32 objectResourceId, Common::Point objectPoint, int32 transTableNum) {
// Save current transparency index
- byte *transparencyIndex= _transTableIndex;
+ byte *transparencyIndex= _transTable;
selectTransTable(transTableNum);
// Get graphic frames
@@ -400,7 +400,7 @@ void Screen::addGraphicToQueueCrossfade(ResourceId resourceId, uint32 frameIndex
frameObject->surface.pitch - dst.width());
// Restore transparency table
- _transTableIndex = transparencyIndex;
+ _transTable = transparencyIndex;
delete resource;
delete resourceObject;
@@ -475,7 +475,7 @@ void Screen::blit(GraphicFrame *frame, Common::Rect *source, Common::Rect *desti
if (flags & 0x10000000) {
flagSet = flags & 0x6FFFFFFF;
- hasTransTableIndex = (_transTableIndex ? true : false);
+ hasTransTableIndex = (_transTable ? true : false);
}
bool isMirrored = (flagSet == kDrawFlagMirrorLeftRight);
@@ -545,7 +545,7 @@ void Screen::blitTranstable(byte *dstBuffer, byte *srcBuffer, int16 height, int1
while (height--) {
for (int16 i = width; i; --i) {
if (*srcBuffer)
- *dstBuffer = _transTableIndex[(*srcBuffer << 8) + *dstBuffer];
+ *dstBuffer = _transTable[(*srcBuffer << 8) + *dstBuffer];
dstBuffer++;
srcBuffer++;
@@ -560,7 +560,7 @@ void Screen::blitTranstableMirrored(byte *dstBuffer, byte *srcBuffer, int16 heig
while (height--) {
for (int16 i = width; i; --i) {
if (*srcBuffer)
- *dstBuffer = _transTableIndex[(*srcBuffer << 8) + *dstBuffer];
+ *dstBuffer = _transTable[(*srcBuffer << 8) + *dstBuffer];
dstBuffer++;
srcBuffer--;
@@ -575,7 +575,7 @@ void Screen::blitCrossfade(byte *dstBuffer, byte *srcBuffer, byte *objectBuffer,
while (height--) {
for (int16 i = width; i; --i) {
if (*srcBuffer)
- *dstBuffer = _transTableIndex[(*srcBuffer << 8) + *objectBuffer];
+ *dstBuffer = _transTable[(*srcBuffer << 8) + *objectBuffer];
dstBuffer++;
srcBuffer++;
@@ -819,7 +819,7 @@ void Screen::drawZoomedMask(byte *mask, int16 height, int16 width, uint16 maskPi
void Screen::bltMasked(byte *srcBuffer, byte *maskBuffer, int16 height, int16 width, uint16 srcPitch, uint16 maskPitch, byte maskLeft, byte *dstBuffer, uint16 dstPitch) {
// FIXME: Use mask
//warning("[Screen::bltMasked] Not implemented!");
-
+
blitRawColorKey(dstBuffer, srcBuffer, height, width, srcPitch, dstPitch);
}
diff --git a/engines/asylum/system/screen.h b/engines/asylum/system/screen.h
index 86f50ad35c..6fdc08b35f 100644
--- a/engines/asylum/system/screen.h
+++ b/engines/asylum/system/screen.h
@@ -108,7 +108,6 @@ public:
void setupTransTable(ResourceId resourceId);
void setupTransTables(uint32 count, ...);
void selectTransTable(uint32 index);
- byte *getTransTableIndex() { return _transTableIndex; }
// Graphic queue
void addGraphicToQueue(ResourceId resourceId, uint32 frameIndex, const Common::Point &point, DrawFlags flags, int32 transTableNum, int32 priority);
@@ -139,8 +138,7 @@ private:
// Transparency tables
uint32 _transTableCount;
- byte *_transTableIndex;
- byte *_transTableData;
+ byte *_transTable;
byte *_transTableBuffer;
void clearTransTables();
Commit: b15b5cb4733eb9e9d095d30cef0c5997c3db9a83
https://github.com/scummvm/scummvm/commit/b15b5cb4733eb9e9d095d30cef0c5997c3db9a83
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:37:03+02:00
Commit Message:
ASYLUM: Identify transparency field for Actor and Object
- Rename related script opcode and function
Changed paths:
engines/asylum/resources/actor.cpp
engines/asylum/resources/actor.h
engines/asylum/resources/object.cpp
engines/asylum/resources/object.h
engines/asylum/resources/script.cpp
engines/asylum/resources/script.h
engines/asylum/resources/special.cpp
engines/asylum/shared.h
diff --git a/engines/asylum/resources/actor.cpp b/engines/asylum/resources/actor.cpp
index 6326bae922..9f6b4bacfc 100644
--- a/engines/asylum/resources/actor.cpp
+++ b/engines/asylum/resources/actor.cpp
@@ -96,7 +96,7 @@ Actor::Actor(AsylumEngine *engine, ActorIndex index) : _vm(engine), _index(index
_numberStringY = 0;
memset(&_numberString01, 0, 8);
_field_968 = 0;
- _field_96C = 0;
+ _transparency = 0;
_field_970 = 0;
_field_974 = 0;
_field_978 = 0;
@@ -208,7 +208,7 @@ void Actor::load(Common::SeekableReadStream *stream) {
_numberStringY = stream->readSint32LE();
stream->read(_numberString01, sizeof(_numberString01));
_field_968 = stream->readSint32LE();
- _field_96C = stream->readSint32LE();
+ _transparency = stream->readSint32LE();
_field_970 = stream->readSint32LE();
_field_974 = stream->readSint32LE();
_field_978 = stream->readSint32LE();
@@ -266,7 +266,7 @@ void Actor::draw() {
// Update flags
flags &= ~kActorFlagMasked;
} else {
- getScreen()->addGraphicToQueue(_resourceId, frameIndex, point, getGraphicsFlags(), _field_96C, _priority);
+ getScreen()->addGraphicToQueue(_resourceId, frameIndex, point, getGraphicsFlags(), _transparency, _priority);
}
}
diff --git a/engines/asylum/resources/actor.h b/engines/asylum/resources/actor.h
index 632deff4e1..a4b7467f40 100644
--- a/engines/asylum/resources/actor.h
+++ b/engines/asylum/resources/actor.h
@@ -69,12 +69,12 @@ public:
void setResourceId(ResourceId id) { _resourceId = id; }
void setSoundResourceId(ResourceId id) { _soundResourceId = id; }
void setStatus(ActorStatus status) { _status = status; }
+ void setTransparency(int32 val) { _transparency = val; }
void setField638(int32 val) { _field_638 = val; }
void setField934(int32 val) { _field_934 = val; }
void setField938(int32 val) { _field_938 = val; }
void setField944(int32 val) { _field_944 = val; }
- void setField96C(int32 val) { _field_96C = val; }
int32 getActionIndex3() { return _actionIdx3; }
Common::Rect *getBoundingRect() { return &_boundingRect; }
@@ -86,6 +86,7 @@ public:
Common::Point *getPoint() { return &_point; }
Common::Point *getPoint1() { return &_point1; }
Common::Point *getPoint2() { return &_point2; }
+ int32 getPriority() { return _priority; }
int32 getReactionValue(uint32 index) { return _reaction[index]; }
ResourceId getResourceId() { return _resourceId; }
ResourceId getResourcesId(uint32 index) { return _graphicResourceIds[index]; }
@@ -98,10 +99,8 @@ public:
int32 getField944() { return _field_944; }
int32 getField948() { return _field_948; }
int32 getField94C() { return _field_94C; }
- int32 getField96C() { return _field_96C; }
int32 getField974() { return _field_974; }
int32 getField980() { return _field_980; }
- int32 getPriority() { return _priority; }
/////////////////////////////////////////////////////////////////////////
// Data
@@ -368,7 +367,7 @@ private:
int32 _numberStringY;
char _numberString01[8];
int32 _field_968;
- int32 _field_96C;
+ int32 _transparency;
int32 _field_970;
int32 _field_974;
int32 _field_978;
diff --git a/engines/asylum/resources/object.cpp b/engines/asylum/resources/object.cpp
index e966d13307..7dd31931d1 100644
--- a/engines/asylum/resources/object.cpp
+++ b/engines/asylum/resources/object.cpp
@@ -40,7 +40,7 @@ Object::Object(AsylumEngine *engine) : x(0), y(0), flags(0), actionType(0),
_vm(engine), _index(0),
_id(kObjectNone), _resourceId(kResourceNone), _field_20(0), _frameIndex(0), _frameCount(0),
_field_2C(0), _field_30(0), _field_34(0), _field_3C(0), _polygonIndex(0), _field_B4(0),
- _tickCount(0), _tickCount2(0), _field_C0(0), _priority(0), _scriptIndex(0), _field_67C(0),
+ _tickCount(0), _tickCount2(0), _field_C0(0), _priority(0), _scriptIndex(0), _transparency(0),
_soundX(0), _soundY(0), _field_688(0), _soundResourceId(kResourceNone), _field_6A4(kDirectionN)
{
memset(&_name, 0, sizeof(_name));
@@ -112,7 +112,7 @@ void Object::load(Common::SeekableReadStream *stream) {
_frameSoundItems[i].field_14 = stream->readSint32LE();
}
- _field_67C = stream->readSint32LE();
+ _transparency = stream->readSint32LE();
_soundX = stream->readSint32LE();
_soundY = stream->readSint32LE();
_field_688 = stream->readSint32LE();
@@ -198,10 +198,10 @@ void Object::draw() {
Common::Point point;
adjustCoordinates(&point);
- if (_field_67C <= 0 || _field_67C >= 4 || Config.performance <= 1) {
- getScreen()->addGraphicToQueue(_resourceId, _frameIndex, point, (DrawFlags)((flags >> 11) & kDrawFlagMirrorLeftRight), _field_67C - 3, _priority);
+ if (_transparency <= 0 || _transparency >= 4 || Config.performance <= 1) {
+ getScreen()->addGraphicToQueue(_resourceId, _frameIndex, point, (DrawFlags)((flags >> 11) & kDrawFlagMirrorLeftRight), _transparency - 3, _priority);
} else {
- getScreen()->addGraphicToQueueCrossfade(_resourceId, _frameIndex, point, getWorld()->backgroundImage, Common::Point(getWorld()->xLeft, getWorld()->yTop), _field_67C - 1);
+ getScreen()->addGraphicToQueueCrossfade(_resourceId, _frameIndex, point, getWorld()->backgroundImage, Common::Point(getWorld()->xLeft, getWorld()->yTop), _transparency - 1);
}
}
@@ -506,8 +506,8 @@ Common::String Object::toString(bool shortString) {
output += Common::String::format(" tickCount2: %d\n", _tickCount2);
output += Common::String::format(" field_C0: %d\n", _field_C0);
output += Common::String::format(" priority: %d\n", _priority);
- output += Common::String::format(" scriptIndex: %d\n", _scriptIndex);
- output += Common::String::format(" field_67C: %d\n", _field_67C);
+ output += Common::String::format(" scriptIndex: %d\n", _scriptIndex);
+ output += Common::String::format(" transparency %d\n", _transparency);
output += Common::String::format(" soundX: %d\n", _soundX);
output += Common::String::format(" soundY: %d\n", _soundY);
output += Common::String::format(" field_688: %d\n", _field_688);
diff --git a/engines/asylum/resources/object.h b/engines/asylum/resources/object.h
index dc152e0f48..0019b57a74 100644
--- a/engines/asylum/resources/object.h
+++ b/engines/asylum/resources/object.h
@@ -52,25 +52,25 @@ public:
void setPriority(int32 priority) { _priority = priority; }
void setSoundResourceId(ResourceId id) { _soundResourceId = id; }
- void setField67C(int32 val) { _field_67C = val; }
+ void setTransparency(int32 val) { _transparency = val; }
void setField6A4(ActorDirection val) { _field_6A4 = val; }
- Common::Rect *getBoundingRect() { return &_boundingRect; }
- uint32 getFrameIndex() { return _frameIndex; }
- uint32 getFrameCount() { return _frameCount; }
+ Common::Rect *getBoundingRect() { return &_boundingRect; }
+ uint32 getFrameIndex() { return _frameIndex; }
+ uint32 getFrameCount() { return _frameCount; }
FrameSoundItem *getFrameSoundItem(uint32 index) { assert(index < ARRAYSIZE(_frameSoundItems)); return &_frameSoundItems[index]; }
- ObjectId getId() { return _id; }
- int32 getPolygonIndex() { return _polygonIndex; }
- int32 getPriority() { return _priority; }
- ResourceId getResourceId() { return _resourceId; }
- ResourceId getSoundResourceId() { return _soundResourceId; }
-
- Common::Rect *getRect() { return &_rect; }
- int32 getScriptIndex() { return _scriptIndex; }
- int32 getSoundY() { return _soundY; }
- int32 getField67C() { return _field_67C; }
- int32 getField688() { return _field_688; }
- ActorDirection getField6A4() { return _field_6A4; }
+ ObjectId getId() { return _id; }
+ int32 getPolygonIndex() { return _polygonIndex; }
+ int32 getPriority() { return _priority; }
+ ResourceId getResourceId() { return _resourceId; }
+ ResourceId getSoundResourceId() { return _soundResourceId; }
+
+ Common::Rect *getRect() { return &_rect; }
+ int32 getScriptIndex() { return _scriptIndex; }
+ int32 getSoundY() { return _soundY; }
+ int32 getTransparency() { return _transparency; }
+ int32 getField688() { return _field_688; }
+ ActorDirection getField6A4() { return _field_6A4; }
/////////////////////////////////////////////////////////////////////////
// Loading & disabling
@@ -195,7 +195,7 @@ private:
int32 _scriptIndex;
SoundItem _soundItems[16];
FrameSoundItem _frameSoundItems[50];
- int32 _field_67C;
+ int32 _transparency;
int32 _soundX;
int32 _soundY;
int32 _field_688;
diff --git a/engines/asylum/resources/script.cpp b/engines/asylum/resources/script.cpp
index d198c46671..4e7aaef9a6 100644
--- a/engines/asylum/resources/script.cpp
+++ b/engines/asylum/resources/script.cpp
@@ -171,7 +171,7 @@ ScriptManager::ScriptManager(AsylumEngine *engine) : _vm(engine) {
ADD_OPCODE(SetObjectFrameIndexAndFlags);
ADD_OPCODE(SetObjectFlags);
ADD_OPCODE(SetActorActionIndex2);
- ADD_OPCODE(UpdateObjectFields);
+ ADD_OPCODE(UpdateTransparency);
ADD_OPCODE(QueueScript);
ADD_OPCODE(ProcessActor);
ADD_OPCODE(ClearActorFields);
@@ -607,15 +607,15 @@ IMPLEMENT_OPCODE(EnableObjects)
if (_currentScript->counter >= (3 * cmd->param2 - 1)) {
_currentScript->counter = 0;
- object->setField67C(0);
- enableObject(cmd, kObjectEnableType2);
+ object->setTransparency(0);
+ enableObject(cmd, kObjectTransparencyOpaque);
} else {
++_currentScript->counter;
if (cmd->param3) {
- object->setField67C(3 - _currentScript->counter / cmd->param2);
+ object->setTransparency(3 - _currentScript->counter / cmd->param2);
enableObject(cmd, kObjectEnableType1);
} else {
- object->setField67C(_currentScript->counter / cmd->param2 + 1);
+ object->setTransparency(_currentScript->counter / cmd->param2 + 1);
enableObject(cmd, kObjectEnableType0);
}
@@ -1738,17 +1738,17 @@ END_OPCODE
//////////////////////////////////////////////////////////////////////////
// Opcode 0x5B
-IMPLEMENT_OPCODE(UpdateObjectFields)
+IMPLEMENT_OPCODE(UpdateTransparency)
if (cmd->param2 >= 0 && cmd->param2 <= 3) {
if (cmd->param1) {
Object *object = getWorld()->getObjectById((ObjectId)cmd->param1);
- object->setField67C(cmd->param2);
-
- if (object->getField67C())
- object->setField67C(object->getField67C() + 3);
+ if (!cmd->param2)
+ object->setTransparency(0);
+ else
+ object->setTransparency(cmd->param2 + 3);
} else {
- getScene()->getActor(cmd->param3)->setField96C(cmd->param2);
+ getScene()->getActor(cmd->param3)->setTransparency(cmd->param2);
}
}
END_OPCODE
@@ -1843,24 +1843,24 @@ END_OPCODE
// Opcode Helper functions
//////////////////////////////////////////////////////////////////////////
-void ScriptManager::enableObject(ScriptEntry *cmd, ObjectEnableType type) {
- int32 field67C = 0;
+void ScriptManager::enableObject(ScriptEntry *cmd, ObjectTransparency type) {
+ int32 transparency = 0;
- // Setup field67C
+ // Setup transparency
switch (type) {
default:
break;
case kObjectEnableType0:
- field67C = 4 + _currentScript->counter / cmd->param2;
+ transparency = 4 + _currentScript->counter / cmd->param2;
break;
case kObjectEnableType1:
- field67C = 6 - _currentScript->counter / cmd->param2;
+ transparency = 6 - _currentScript->counter / cmd->param2;
break;
- case kObjectEnableType2:
- field67C = 0;
+ case kObjectTransparencyOpaque:
+ transparency = 0;
break;
}
@@ -1868,7 +1868,7 @@ void ScriptManager::enableObject(ScriptEntry *cmd, ObjectEnableType type) {
for (int i = 0; i < 7; i++) {
Object *object = getWorld()->getObjectById((ObjectId)cmd->param4);
if (object != NULL)
- object->setField67C(field67C);
+ object->setTransparency(transparency);
++cmd->param4;
}
@@ -1882,45 +1882,45 @@ void ScriptManager::enableObject(ScriptEntry *cmd, ObjectEnableType type) {
if (cmd->param1 != 810)
break;
- getWorld()->getObjectById(kObjectTableRecordRoom)->setField67C(field67C);
- getWorld()->getObjectById(kObjectOrangeRecord)->setField67C(field67C);
+ getWorld()->getObjectById(kObjectTableRecordRoom)->setTransparency(transparency);
+ getWorld()->getObjectById(kObjectOrangeRecord)->setTransparency(transparency);
break;
case kChapter4:
if (cmd->param1 != 1232)
break;
- getWorld()->getObjectById(kObjectInfernoStatusQuo)->setField67C(field67C);
- getWorld()->getObjectById(kObjectJugglerWithPin)->setField67C(field67C);
- getWorld()->getObjectById(kObjectJuggler)->setField67C(field67C);
- getWorld()->getObjectById(kObjectClownStatusQuo)->setField67C(field67C);
- getWorld()->getObjectById(kObjectTrixieStatusQuo)->setField67C(field67C);
- getWorld()->getObjectById(kObjectSimonStatusQuo)->setField67C(field67C);
- getWorld()->getObjectById(kObjectBigTopBarrel)->setField67C(field67C);
- getWorld()->getObjectById(kObjectStandBehindJuggler)->setField67C(field67C);
- getWorld()->getObjectById(kObjectStrongmanLeft)->setField67C(field67C);
- getWorld()->getObjectById(kObjectStrongmanRight)->setField67C(field67C);
+ getWorld()->getObjectById(kObjectInfernoStatusQuo)->setTransparency(transparency);
+ getWorld()->getObjectById(kObjectJugglerWithPin)->setTransparency(transparency);
+ getWorld()->getObjectById(kObjectJuggler)->setTransparency(transparency);
+ getWorld()->getObjectById(kObjectClownStatusQuo)->setTransparency(transparency);
+ getWorld()->getObjectById(kObjectTrixieStatusQuo)->setTransparency(transparency);
+ getWorld()->getObjectById(kObjectSimonStatusQuo)->setTransparency(transparency);
+ getWorld()->getObjectById(kObjectBigTopBarrel)->setTransparency(transparency);
+ getWorld()->getObjectById(kObjectStandBehindJuggler)->setTransparency(transparency);
+ getWorld()->getObjectById(kObjectStrongmanLeft)->setTransparency(transparency);
+ getWorld()->getObjectById(kObjectStrongmanRight)->setTransparency(transparency);
break;
case kChapter6:
if (cmd->param1 == 1998) {
- getWorld()->getObjectById(kObjectGlow4)->setField67C(field67C);
- getWorld()->getObjectById(kObjectBugOnTable)->setField67C(field67C);
- getWorld()->getObjectById(kObjectInsidePipeCyberPod)->setField67C(field67C);
- getWorld()->getObjectById(kObjectDiscardedBugPincer)->setField67C(field67C);
- getWorld()->getObjectById(kObjectLitLimbScanner)->setField67C(field67C);
- getWorld()->getObjectById(kObjectCyberTable)->setField67C(field67C);
+ getWorld()->getObjectById(kObjectGlow4)->setTransparency(transparency);
+ getWorld()->getObjectById(kObjectBugOnTable)->setTransparency(transparency);
+ getWorld()->getObjectById(kObjectInsidePipeCyberPod)->setTransparency(transparency);
+ getWorld()->getObjectById(kObjectDiscardedBugPincer)->setTransparency(transparency);
+ getWorld()->getObjectById(kObjectLitLimbScanner)->setTransparency(transparency);
+ getWorld()->getObjectById(kObjectCyberTable)->setTransparency(transparency);
}
if (cmd->param1 == 2003) {
- getWorld()->getObjectById(kObjectNPC066StatusQuo)->setField67C(field67C);
- getWorld()->getObjectById(kObject2507)->setField67C(field67C);
- getWorld()->getObjectById(kObjectBrokenPipe)->setField67C(field67C);
- getWorld()->getObjectById(kObjectEmberPopsOut)->setField67C(field67C);
- getWorld()->getObjectById(kObjectBugCarriesEmber)->setField67C(field67C);
- getWorld()->getObjectById(kObjectFurnaceHole)->setField67C(field67C);
- getWorld()->getObjectById(kObjectTopOfFurnace)->setField67C(field67C);
- getWorld()->getObjectById(kObjectElderBugLimb)->setField67C(field67C);
+ getWorld()->getObjectById(kObjectNPC066StatusQuo)->setTransparency(transparency);
+ getWorld()->getObjectById(kObject2507)->setTransparency(transparency);
+ getWorld()->getObjectById(kObjectBrokenPipe)->setTransparency(transparency);
+ getWorld()->getObjectById(kObjectEmberPopsOut)->setTransparency(transparency);
+ getWorld()->getObjectById(kObjectBugCarriesEmber)->setTransparency(transparency);
+ getWorld()->getObjectById(kObjectFurnaceHole)->setTransparency(transparency);
+ getWorld()->getObjectById(kObjectTopOfFurnace)->setTransparency(transparency);
+ getWorld()->getObjectById(kObjectElderBugLimb)->setTransparency(transparency);
}
break;
@@ -1928,28 +1928,28 @@ void ScriptManager::enableObject(ScriptEntry *cmd, ObjectEnableType type) {
if (cmd->param1 != 1273)
break;
- getWorld()->getObjectById(kObjectHeadOnTable)->setField67C(field67C);
- getWorld()->getObjectById(kObjectOfficeWallNew)->setField67C(field67C);
- getWorld()->getObjectById(kObjectChalice)->setField67C(field67C);
+ getWorld()->getObjectById(kObjectHeadOnTable)->setTransparency(transparency);
+ getWorld()->getObjectById(kObjectOfficeWallNew)->setTransparency(transparency);
+ getWorld()->getObjectById(kObjectChalice)->setTransparency(transparency);
break;
case kChapter8:
if (cmd->param1 != 1795)
break;
- getWorld()->getObjectById(kObjectHook1B)->setField67C(field67C);
- getWorld()->getObjectById(kObjectHook2B)->setField67C(field67C);
- getWorld()->getObjectById(kObjectHook3B)->setField67C(field67C);
- getWorld()->getObjectById(kObjectHook4B)->setField67C(field67C);
- getWorld()->getObjectById(kObjectHook5B)->setField67C(field67C);
- getWorld()->getObjectById(kObjectHook6B)->setField67C(field67C);
- getWorld()->getObjectById(kObjectHook0Down)->setField67C(field67C);
- getWorld()->getObjectById(kObjectHook2Down)->setField67C(field67C);
- getWorld()->getObjectById(kObjectHook3Down)->setField67C(field67C);
- getWorld()->getObjectById(kObjectHook4Down)->setField67C(field67C);
- getWorld()->getObjectById(kObjectHook5Down)->setField67C(field67C);
- getWorld()->getObjectById(kObjectHook6Down)->setField67C(field67C);
- getWorld()->getObjectById(kObject2230)->setField67C(field67C);
+ getWorld()->getObjectById(kObjectHook1B)->setTransparency(transparency);
+ getWorld()->getObjectById(kObjectHook2B)->setTransparency(transparency);
+ getWorld()->getObjectById(kObjectHook3B)->setTransparency(transparency);
+ getWorld()->getObjectById(kObjectHook4B)->setTransparency(transparency);
+ getWorld()->getObjectById(kObjectHook5B)->setTransparency(transparency);
+ getWorld()->getObjectById(kObjectHook6B)->setTransparency(transparency);
+ getWorld()->getObjectById(kObjectHook0Down)->setTransparency(transparency);
+ getWorld()->getObjectById(kObjectHook2Down)->setTransparency(transparency);
+ getWorld()->getObjectById(kObjectHook3Down)->setTransparency(transparency);
+ getWorld()->getObjectById(kObjectHook4Down)->setTransparency(transparency);
+ getWorld()->getObjectById(kObjectHook5Down)->setTransparency(transparency);
+ getWorld()->getObjectById(kObjectHook6Down)->setTransparency(transparency);
+ getWorld()->getObjectById(kObject2230)->setTransparency(transparency);
break;
}
}
diff --git a/engines/asylum/resources/script.h b/engines/asylum/resources/script.h
index 33ed8d2c10..326bddcbd5 100644
--- a/engines/asylum/resources/script.h
+++ b/engines/asylum/resources/script.h
@@ -163,10 +163,10 @@ public:
void saveLoadWithSerializer(Common::Serializer &s);
private:
- enum ObjectEnableType {
+ enum ObjectTransparency {
kObjectEnableType0,
kObjectEnableType1,
- kObjectEnableType2
+ kObjectTransparencyOpaque
};
//////////////////////////////////////////////////////////////////////////
@@ -292,7 +292,7 @@ private:
void updateQueue(uint32 entryIndex);
// Opcode helper functions
- void enableObject(ScriptEntry *cmd, ObjectEnableType type);
+ void enableObject(ScriptEntry *cmd, ObjectTransparency type);
void setActionFlag(ScriptEntry *cmd, ActionType flag); //|
void clearActionFlag(ScriptEntry *cmd, ActionType flag); //&
void jumpIfActionFlag(ScriptEntry *cmd, ActionType flag);
@@ -390,7 +390,7 @@ private:
DECLARE_OPCODE(SetObjectFrameIndexAndFlags);
DECLARE_OPCODE(SetObjectFlags);
DECLARE_OPCODE(SetActorActionIndex2);
- DECLARE_OPCODE(UpdateObjectFields);
+ DECLARE_OPCODE(UpdateTransparency);
DECLARE_OPCODE(QueueScript);
DECLARE_OPCODE(ProcessActor);
DECLARE_OPCODE(ClearActorFields);
diff --git a/engines/asylum/resources/special.cpp b/engines/asylum/resources/special.cpp
index d4f245a58c..8393b06023 100644
--- a/engines/asylum/resources/special.cpp
+++ b/engines/asylum/resources/special.cpp
@@ -1384,12 +1384,12 @@ void Special::checkFlags(ObjectId id, GameFlag flag1, GameFlag flag2, GameFlag f
_vm->clearGameFlag(flag1);
_vm->clearGameFlag(flag2);
- getWorld()->getObjectById(id)->setField67C(0);
+ getWorld()->getObjectById(id)->setTransparency(0);
} else {
(*val2)++;
- getWorld()->getObjectById(id)->setField67C(6 - Common::Rational(*val2, 4).toInt());
+ getWorld()->getObjectById(id)->setTransparency(6 - Common::Rational(*val2, 4).toInt());
}
} else {
@@ -1404,12 +1404,12 @@ void Special::checkFlags(ObjectId id, GameFlag flag1, GameFlag flag2, GameFlag f
_vm->clearGameFlag(flag2);
_vm->clearGameFlag(flag4);
- getWorld()->getObjectById(id)->setField67C(0);
+ getWorld()->getObjectById(id)->setTransparency(0);
} else {
(*val2)++;
- getWorld()->getObjectById(id)->setField67C(Common::Rational(*val2, 4).toInt() + 4);
+ getWorld()->getObjectById(id)->setTransparency(Common::Rational(*val2, 4).toInt() + 4);
}
}
}
diff --git a/engines/asylum/shared.h b/engines/asylum/shared.h
index b0cdd5cb5d..340b51eb5d 100644
--- a/engines/asylum/shared.h
+++ b/engines/asylum/shared.h
@@ -356,7 +356,7 @@ enum OpcodeType {
kOpcodeSetObjectFrameIndexAndFlags,
kOpcodeSetObjectFlags,
kOpcodeSetActorActionIndex2, // 90
- kOpcodeUpdateObjectFields,
+ kOpcodeUpdateTransparency,
kOpcodeQueueScript,
kOpcodeProcessActor,
kOpcodeClearActorFields,
Commit: 9d54c6b5fcc1c036e02b3286634b865460f2964f
https://github.com/scummvm/scummvm/commit/9d54c6b5fcc1c036e02b3286634b865460f2964f
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:37:03+02:00
Commit Message:
ASYLUM: Rename several Actor methods
Changed paths:
engines/asylum/resources/actor.cpp
engines/asylum/resources/actor.h
engines/asylum/views/menu.cpp
engines/asylum/views/scene.cpp
diff --git a/engines/asylum/resources/actor.cpp b/engines/asylum/resources/actor.cpp
index 9f6b4bacfc..011f8e9ac9 100644
--- a/engines/asylum/resources/actor.cpp
+++ b/engines/asylum/resources/actor.cpp
@@ -834,7 +834,7 @@ void Actor::faceTarget(uint32 target, DirectionFrom from) {
}
Common::Point mid(_point1.x + _point2.x, _point1.y + _point2.y);
- updateFromDirection(direction(mid, point));
+ updateFromDirection(directionFromAngle(mid, point));
}
void Actor::setPosition(int32 newX, int32 newY, ActorDirection newDirection, uint32 frame) {
@@ -2086,7 +2086,7 @@ void Actor::updateStatus14_Chapter11() {
updateCoordinates(getSharedData()->vector1, getSharedData()->vector2);
if (getWorld()->tickValueArray[_index] < (int)_vm->getTick()) {
- if (distance(getSharedData()->vector1, getSharedData()->vector2) >= 75) {
+ if (euclidianDistance(getSharedData()->vector1, getSharedData()->vector2) >= 75) {
getWorld()->tickValueArray[_index] = rnd(1000) + 2000 + _vm->getTick();
} else {
if (actor0->getStatus() == kActorStatus12 || actor0->getStatus() == kActorStatus14 || actor0->getStatus() == kActorStatus15)
@@ -2173,7 +2173,7 @@ void Actor::updateStatus15_Chapter2_Player_Helper() {
Common::Point point(_point1.x + _point2.x, _point1.y + _point2.y);
Common::Point point11(actor11->getPoint1()->x + actor11->getPoint2()->x, actor11->getPoint1()->y + actor11->getPoint2()->y);
- if (actor11->getStatus() == kActorStatus15 && distance(point, point11) < 100) {
+ if (actor11->getStatus() == kActorStatus15 && euclidianDistance(point, point11) < 100) {
Actor *actor = getScene()->getActor(getSharedData()->getData(38));
actor40->show();
@@ -2238,7 +2238,7 @@ void Actor::updateStatus15_Chapter11() {
updateStatus(kActorStatus14);
if (_frameIndex == 14) {
- if (Actor::distance(getSharedData()->vector1, getSharedData()->vector2) < 75) {
+ if (Actor::euclidianDistance(getSharedData()->vector1, getSharedData()->vector2) < 75) {
actor0->updateStatus(kActorStatus16);
++getWorld()->field_E848C;
@@ -2743,7 +2743,7 @@ void Actor::setVolume() {
// Helper methods
//////////////////////////////////////////////////////////////////////////
-ActorDirection Actor::direction(Common::Point vec1, Common::Point vec2) {
+ActorDirection Actor::directionFromAngle(Common::Point vec1, Common::Point vec2) {
int32 diffX = (vec2.x - vec1.x) * 2^16;
int32 diffY = (vec1.y - vec2.y) * 2^16;
int32 adjust = 0;
@@ -2932,12 +2932,12 @@ void Actor::updateCoordinatesForDirection(ActorDirection direction, int32 delta,
}
}
-uint32 Actor::distance(Common::Point vec1, Common::Point vec2) {
+uint32 Actor::euclidianDistance(Common::Point vec1, Common::Point vec2) {
return sqrt(pow((double)(vec2.y - vec1.y), 2) + pow((double)(vec2.x - vec1.x), 2));
}
-uint32 Actor::angle(Common::Point vec1, Common::Point vec2) {
- int32 result = ((long)(180 - acos((double)(vec2.y - vec1.y) / distance(vec1, vec2)) * 180 / M_PI)) % 360;
+uint32 Actor::angleFromVectors(Common::Point vec1, Common::Point vec2) {
+ int32 result = ((long)(180 - acos((double)(vec2.y - vec1.y) / euclidianDistance(vec1, vec2)) * 180 / M_PI)) % 360;
if (vec1.x < vec2.x)
return 360 - result;
@@ -2945,7 +2945,7 @@ uint32 Actor::angle(Common::Point vec1, Common::Point vec2) {
return result;
}
-void Actor::rect(Common::Rect *rect, ActorDirection direction, Common::Point point) {
+void Actor::rectFromDirection(Common::Rect *rect, ActorDirection direction, Common::Point point) {
if (!rect)
error("[Actor::rect] Invalid rect (NULL)!");
@@ -3005,7 +3005,7 @@ void Actor::rect(Common::Rect *rect, ActorDirection direction, Common::Point poi
bool Actor::compareAngles(Common::Point vec1, Common::Point vec2) {
Common::Point vec3(2289, 171);
- int32 diff = angle(vec1, vec3) - angle(vec1, vec2);
+ int32 diff = angleFromVectors(vec1, vec3) - angleFromVectors(vec1, vec2);
if (diff < 0)
diff += 359;
diff --git a/engines/asylum/resources/actor.h b/engines/asylum/resources/actor.h
index a4b7467f40..3820be94a6 100644
--- a/engines/asylum/resources/actor.h
+++ b/engines/asylum/resources/actor.h
@@ -294,9 +294,9 @@ public:
*
* @return The direction
*/
- static ActorDirection direction(Common::Point vec1, Common::Point vec2);
+ static ActorDirection directionFromAngle(Common::Point vec1, Common::Point vec2);
- /**
+ /**
* Get the euclidean distance between the two vectors
*
* @param vec1 The first vector.
@@ -304,7 +304,7 @@ public:
*
* @return the distance.
*/
- static uint32 distance(Common::Point vec1, Common::Point vec2);
+ static uint32 euclidianDistance(Common::Point vec1, Common::Point vec2);
private:
AsylumEngine *_vm;
@@ -538,7 +538,7 @@ private:
*
* @return the angle
*/
- static uint32 angle(Common::Point vec1, Common::Point vec2);
+ static uint32 angleFromVectors(Common::Point vec1, Common::Point vec2);
/**
* Create a new rect using the point, depending on the actor direction
@@ -547,7 +547,7 @@ private:
* @param direction The direction.
* @param point The point.
*/
- static void rect(Common::Rect *rect, ActorDirection direction, Common::Point point);
+ static void rectFromDirection(Common::Rect *rect, ActorDirection direction, Common::Point point);
/**
* Compares the angle between two vectors
diff --git a/engines/asylum/views/menu.cpp b/engines/asylum/views/menu.cpp
index 76b64f54ff..ca321c6d33 100644
--- a/engines/asylum/views/menu.cpp
+++ b/engines/asylum/views/menu.cpp
@@ -419,7 +419,7 @@ bool Menu::update() {
Common::Point cursor = getCursor()->position();
if (cursor.x < 230 || cursor.x > 399 || cursor.y < 199 || cursor.y > 259)
- frameIndex = eyeFrameIndex[Actor::direction(Common::Point(320, 240), cursor)];
+ frameIndex = eyeFrameIndex[Actor::directionFromAngle(Common::Point(320, 240), cursor)];
else if (cursor.x >= 743 && cursor.x <= 743 && cursor.y >= 587 && cursor.y <= 602)
frameIndex = 9;
}
diff --git a/engines/asylum/views/scene.cpp b/engines/asylum/views/scene.cpp
index 52e5ff21e7..5c0765859c 100644
--- a/engines/asylum/views/scene.cpp
+++ b/engines/asylum/views/scene.cpp
@@ -1733,7 +1733,7 @@ void Scene::hitActorChapter2(ActorIndex index) {
Common::Point pointPlayer(player->getPoint1()->x + player->getPoint2()->x, player->getPoint1()->y + player->getPoint2()->y);
Common::Point pointActor11(actor11->getPoint1()->x + actor11->getPoint2()->x, actor11->getPoint1()->y + actor11->getPoint2()->y);
- if (Actor::distance(pointPlayer, pointActor11) < 150) {
+ if (Actor::euclidianDistance(pointPlayer, pointActor11) < 150) {
if (actor11->getStatus() == kActorStatus12)
actor11->updateStatus(kActorStatus18);
Commit: 7828f300faf8a7fe32be90f6d80786ff8c8a373f
https://github.com/scummvm/scummvm/commit/7828f300faf8a7fe32be90f6d80786ff8c8a373f
Author: Alex Bevilacqua (alexbevi at gmail.com)
Date: 2021-05-17T15:37:04+02:00
Commit Message:
ASYLUM: Silence GCC Warning
Class 'Scene' has virtual method 'handleEvent' but non-virtual destructor
Changed paths:
engines/asylum/views/scene.h
diff --git a/engines/asylum/views/scene.h b/engines/asylum/views/scene.h
index 87cadacc4f..291a6810a4 100644
--- a/engines/asylum/views/scene.h
+++ b/engines/asylum/views/scene.h
@@ -73,7 +73,7 @@ enum ActionAreaType {
class Scene : public EventHandler {
public:
Scene(AsylumEngine *engine);
- ~Scene();
+ virtual ~Scene();
/**
* Load the scene data
Commit: 80583b079b8aebccdedbd6ce4e449bb7caa932e8
https://github.com/scummvm/scummvm/commit/80583b079b8aebccdedbd6ce4e449bb7caa932e8
Author: Alexander (alex220486 at gmail.com)
Date: 2021-05-17T15:37:04+02:00
Commit Message:
ASYLUM: Pipes puzzle: add spiders
Changed paths:
engines/asylum/puzzles/pipes.cpp
engines/asylum/puzzles/pipes.h
diff --git a/engines/asylum/puzzles/pipes.cpp b/engines/asylum/puzzles/pipes.cpp
index c7225cbd4d..ee2c01e76e 100644
--- a/engines/asylum/puzzles/pipes.cpp
+++ b/engines/asylum/puzzles/pipes.cpp
@@ -103,19 +103,13 @@ const Common::Point peepholePoints[] = {
const uint32 peepholeResources[] = {15, 15, 15, 15, 32, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 32, 32, 15,
15, 32, 32, 15, 15, 15, 15,15, 15, 15, 15, 32, 15, 15, 15, 15, 15, 15, 15};
+const double LOG2 = 0.6931471;
+
//////////////////////////////////////////////////////////////////////////
// Peephole
//////////////////////////////////////////////////////////////////////////
bool Peephole::marks[peepholesCount];
-void Peephole::connect(Connector *connector) {
- _connectors.push_back(connector);
-}
-
-void Peephole::disconnect(Connector *connector) {
- _connectors.remove(connector);
-}
-
void Peephole::startUpWater(bool flag) {
if (flag)
memset(marks, false, sizeof(marks));
@@ -183,8 +177,8 @@ void Connector::turn() {
oldIndex[1] = 2;
}
} else {
- newIndex[0] = log((double)(newState & delta)) / log((double)2);
- oldIndex[0] = log((double)(_state & delta)) / log((double)2);
+ newIndex[0] = log((double)(newState & delta)) / LOG2;
+ oldIndex[0] = log((double)(_state & delta)) / LOG2;
}
for (uint32 i = 0; i < (uint32)(delta == kBinNum1111 ? 2 : 1); ++i) {
@@ -259,6 +253,49 @@ void Connector::disconnect(Connector *connector) {
_isConnected = connector->_isConnected = false;
}
+//////////////////////////////////////////////////////////////////////////
+// Spider
+//////////////////////////////////////////////////////////////////////////
+Spider::Spider(Common::Rect rect, Common::String id) {
+ _boundingBox = rect;
+ _rnd = new Common::RandomSource(Common::String("pipes_spider") + id);
+ _isAlive = true;
+ _location.x = _rnd->getRandomNumber(_boundingBox.right - _boundingBox.left) + _boundingBox.left;
+ _location.y = _rnd->getRandomNumber(_boundingBox.bottom - _boundingBox.top) + _boundingBox.top;
+ _direction = Direction(1 << _rnd->getRandomNumber(3));
+
+ randomize();
+}
+
+void Spider::randomize(Direction excluded) {
+ if (_rnd->getRandomNumber(5) == 5)
+ _delta = Common::Point(0, 0);
+ else {
+ while (_direction == excluded)
+ _direction = Direction(1 << _rnd->getRandomNumber(3));
+ _delta = Common::Point((_direction & kBinNum0010 ? 1 : 0) - (_direction & kBinNum1000 ? 1 : 0), (_direction & kBinNum0100 ? 1 : 0) - (_direction & kBinNum0001 ? 1 : 0));
+ }
+
+ _stepsNumber = _rnd->getRandomNumber(maxStepsNumber - minStepsNumber) + minStepsNumber;
+ _steps = 0;
+}
+
+Common::Point Spider::move() {
+ Common::Point previousLocation(_location);
+
+ if (_isAlive) {
+ if (_steps++ > _stepsNumber)
+ randomize();
+
+ if (!_boundingBox.contains(_location + _delta))
+ randomize(_direction);
+ else
+ _location += _delta;
+ }
+
+ return previousLocation;
+}
+
//////////////////////////////////////////////////////////////////////////
// PuzzlePipes
//////////////////////////////////////////////////////////////////////////
@@ -272,6 +309,9 @@ PuzzlePipes::PuzzlePipes(AsylumEngine *engine) : Puzzle(engine) {
}
PuzzlePipes::~PuzzlePipes() {
+ for (uint32 i = 0; i < _spiders.size(); ++i)
+ delete _spiders[i];
+ delete [] _frameIndexSpider;
}
void PuzzlePipes::reset() {
@@ -324,8 +364,10 @@ bool PuzzlePipes::update(const AsylumEvent &evt) {
_isLeverReady = false;
if (_frameIndexLever) {
_frameIndexLever = (_frameIndexLever + 1) % GraphicResource::getFrameCount(_vm, getWorld()->graphicResourceIds[2]);
- if (!_frameIndexLever)
+ if (!_frameIndexLever) {
_isLeverReady = true;
+ getCursor()->show();
+ }
}
// TODO: turn the fountain on
@@ -340,6 +382,32 @@ bool PuzzlePipes::update(const AsylumEvent &evt) {
if (!_levelFlags[4])
getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[45], 0, Common::Point(518, 108), kDrawFlagNone, 0, 2);
+ for (uint32 i = 0; i < _spiders.size(); ++i) {
+ uint32 spiderResourceId;
+
+ switch (_spiders[i]->getDirection()) {
+ case kDirectionNh:
+ spiderResourceId = _spiders[i]->isAlive() ? 34 : 37;
+ break;
+ case kDirectionEt:
+ spiderResourceId = _spiders[i]->isAlive() ? 35 : 38; // FIXME
+ break;
+ case kDirectionSh:
+ spiderResourceId = _spiders[i]->isAlive() ? 36 : 39;
+ break;
+ case kDirectionWt:
+ spiderResourceId = _spiders[i]->isAlive() ? 35 : 38;
+ break;
+ default: ;
+ }
+
+ if (_spiders[i]->isVisible(Common::Rect(-10, -10, 650, 490))) {
+ uint32 frameCountSpider = GraphicResource::getFrameCount(_vm, getWorld()->graphicResourceIds[spiderResourceId]);
+ _frameIndexSpider[i] = _spiders[i]->isActive() ? (_frameIndexSpider[i] + 1) % frameCountSpider : 0;
+ getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[spiderResourceId], _frameIndexSpider[i], _spiders[i]->move(), kDrawFlagNone, 0, 1);
+ }
+ }
+
getScreen()->drawGraphicsInQueue();
getScreen()->copyBackBufferToScreen();
updateCursor();
@@ -361,16 +429,22 @@ bool PuzzlePipes::mouseLeftDown(const AsylumEvent &evt) {
if (Common::Rect(540, 90, 590, 250).contains(mousePos)) {
if (!_frameIndexLever)
++_frameIndexLever;
-
+ getCursor()->hide();
getSound()->playSound(getWorld()->graphicResourceIds[43], false, Config.sfxVolume - 10);
} else {
if (_rectIndex != -1) {
- getSound()->playSound(getWorld()->graphicResourceIds[42], false, Config.sfxVolume - 10);
-
- _connectors[_rectIndex].turn();
- startUpWater();
- memset(_levelFlags, false, sizeof(_levelFlags));
- _levelFlags[checkFlags()] = true;
+ if (_rectIndex < ARRAYSIZE(connectorPoints)) {
+ getSound()->playSound(getWorld()->graphicResourceIds[42], false, Config.sfxVolume - 10);
+
+ _connectors[_rectIndex].turn();
+ startUpWater();
+ memset(_levelFlags, false, sizeof(_levelFlags));
+ _levelFlags[checkFlags()] = true;
+ } else {
+ getSound()->playSound(getWorld()->graphicResourceIds[44], false, Config.sfxVolume - 10);
+ _spiders[_rectIndex - ARRAYSIZE(connectorPoints)]->smash();
+ _frameIndexSpider[_rectIndex - ARRAYSIZE(connectorPoints)] = 0;
+ }
}
}
@@ -447,6 +521,17 @@ void PuzzlePipes::setup() {
_connectors[10].initGroup();
_connectors[11].initGroup();
+ uint32 i = rnd(7);
+ if (i & kBinNum0001)
+ _spiders.push_back(new Spider(Common::Rect(-10, 45, 92, 315), "1"));
+ if (i & kBinNum0010)
+ _spiders.push_back(new Spider(Common::Rect(-10, 389, 149, 476), "2"));
+ if (i & kBinNum0100)
+ _spiders.push_back(new Spider(Common::Rect(544, 225, 650, 490), "3"));
+
+ _frameIndexSpider = new uint32[_spiders.size()];
+ memset(_frameIndexSpider, 0, sizeof(_frameIndexSpider));
+
startUpWater();
}
@@ -469,6 +554,10 @@ int32 PuzzlePipes::findRect() {
if (Common::Rect(connectorPoints[i].x - 5, connectorPoints[i].y - 5, connectorPoints[i].x + 30, connectorPoints[i].y + 30).contains(getCursor()->position()))
return i;
+ for (uint32 i = 0; i < _spiders.size(); ++i)
+ if (_spiders[i]->getPolygon(Common::Rect(10, 10, 30, 30)).contains(getCursor()->position()))
+ return ARRAYSIZE(connectorPoints) + i;
+
return -1;
}
diff --git a/engines/asylum/puzzles/pipes.h b/engines/asylum/puzzles/pipes.h
index ae3f640770..ac5b00fc77 100644
--- a/engines/asylum/puzzles/pipes.h
+++ b/engines/asylum/puzzles/pipes.h
@@ -27,6 +27,9 @@
#include "common/list.h"
#include "common/hashmap.h"
+#include "common/array.h"
+#include "common/random.h"
+#include "common/str.h"
namespace Asylum {
@@ -76,8 +79,8 @@ public:
uint32 getLevel1() { return _flowValues[0] + _flowValues[1] + _flowValues[2] + _flowValues[3]; }
bool isConnected() { return isConnected(0) || isConnected(1) || isConnected(2) || isConnected(3); }
- void connect(Connector *connector);
- void disconnect(Connector *connector);
+ void connect(Connector *connector) { _connectors.push_back(connector); }
+ void disconnect(Connector *connector) { _connectors.remove(connector); }
void startUpWater(bool flag = false);
private:
@@ -118,6 +121,34 @@ private:
friend void Peephole::startUpWater(bool);
};
+class Spider {
+public:
+ Spider(Common::Rect rect, Common::String id);
+ ~Spider() { delete _rnd; }
+
+ bool isAlive() const { return _isAlive; }
+ bool isActive() const { return _delta != Common::Point(0, 0); }
+ bool isVisible(Common::Rect rect) const { return rect.contains(_location); }
+
+ Direction getDirection() const { return _direction; }
+ Common::Rect getPolygon(Common::Rect frame) const { return Common::Rect(_location.x - frame.left, _location.y - frame.top, _location.x + frame.right, _location.y + frame.bottom); }
+
+ Common::Point move();
+ void smash() { _isAlive = false; }
+private:
+ static const uint32 minStepsNumber = 20, maxStepsNumber = 200;
+ Common::RandomSource *_rnd;
+ bool _isAlive;
+ Common::Point _location;
+ Common::Point _delta;
+ Common::Rect _boundingBox;
+ Direction _direction;
+ uint32 _stepsNumber;
+ uint32 _steps;
+
+ void randomize(Direction excluded = kDirectionNowhere);
+};
+
class PuzzlePipes : public Puzzle {
public:
PuzzlePipes(AsylumEngine *engine);
@@ -136,6 +167,8 @@ private:
Connector _connectors[connectorsCount];
Peephole _peepholes[peepholesCount];
Peephole *_sinks[4], *_sources[4];
+ Common::Array<Spider *> _spiders;
+ uint32 *_frameIndexSpider;
//////////////////////////////////////////////////////////////////////////
// Event Handling
Commit: 4ef22bfb2f065618ce454b1aaa810df46b55f9d3
https://github.com/scummvm/scummvm/commit/4ef22bfb2f065618ce454b1aaa810df46b55f9d3
Author: Alexander (alex220486 at gmail.com)
Date: 2021-05-17T15:37:04+02:00
Commit Message:
ASYLUM: Pipes puzzle: continuous progress bars
Changed paths:
engines/asylum/puzzles/pipes.cpp
engines/asylum/puzzles/pipes.h
diff --git a/engines/asylum/puzzles/pipes.cpp b/engines/asylum/puzzles/pipes.cpp
index ee2c01e76e..522fb82fd4 100644
--- a/engines/asylum/puzzles/pipes.cpp
+++ b/engines/asylum/puzzles/pipes.cpp
@@ -304,6 +304,7 @@ PuzzlePipes::PuzzlePipes(AsylumEngine *engine) : Puzzle(engine) {
_rectIndex = -2;
_frameIndex = _frameIndexLever = 0;
+ memset(_previousLevels, 0, sizeof(_previousLevels));
memset(&_levelFlags, false, sizeof(_levelFlags));
_levelFlags[4] = true;
}
@@ -347,11 +348,15 @@ bool PuzzlePipes::update(const AsylumEvent &evt) {
for (uint32 i = 0; i < ARRAYSIZE(_connectors); ++i)
getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[_connectorResources[_connectors[i].getState()]], 0, connectorPoints[i], kDrawFlagNone, 0, 1);
- // TODO: continuous progressbars
- getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[18], 0, Common::Point(210, 444 - uint32(_levelValues[0] * 52)), kDrawFlagNone, 0, 3);
- getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[18], 0, Common::Point(276, 455 - uint32(_levelValues[1] * 52)), kDrawFlagNone, 0, 3);
- getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[18], 0, Common::Point(376, 448 - uint32(_levelValues[2] * 52)), kDrawFlagNone, 0, 3);
- getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[18], 0, Common::Point(458, 442 - uint32(_levelValues[3] * 52)), kDrawFlagNone, 0, 3);
+ for (uint32 i = 0; i < 4; ++i) {
+ if (fabs(_levelValues[i] - _previousLevels[i]) > 0.005)
+ _previousLevels[i] += _levelValues[i] > _previousLevels[i] ? 0.01 : -0.01;
+ }
+
+ getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[18], 0, Common::Point(210, 444 - uint32(_previousLevels[0] * 52)), kDrawFlagNone, 0, 3);
+ getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[18], 0, Common::Point(276, 455 - uint32(_previousLevels[1] * 52)), kDrawFlagNone, 0, 3);
+ getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[18], 0, Common::Point(376, 448 - uint32(_previousLevels[2] * 52)), kDrawFlagNone, 0, 3);
+ getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[18], 0, Common::Point(458, 442 - uint32(_previousLevels[3] * 52)), kDrawFlagNone, 0, 3);
getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[33], 0, Common::Point(204, 377), kDrawFlagNone, 0, 1);
diff --git a/engines/asylum/puzzles/pipes.h b/engines/asylum/puzzles/pipes.h
index ac5b00fc77..5ed3c9acbb 100644
--- a/engines/asylum/puzzles/pipes.h
+++ b/engines/asylum/puzzles/pipes.h
@@ -161,7 +161,7 @@ private:
int32 _rectIndex;
uint32 _frameIndex, _frameIndexLever;
bool _levelFlags[5];
- float _levelValues[4];
+ float _levelValues[4], _previousLevels[4];
bool _isLeverReady;
Common::HashMap<uint32, uint32> _connectorResources;
Connector _connectors[connectorsCount];
Commit: 2cde66d92636c8551eb10d6352dbfa9525623d42
https://github.com/scummvm/scummvm/commit/2cde66d92636c8551eb10d6352dbfa9525623d42
Author: Alexander (alex220486 at gmail.com)
Date: 2021-05-17T15:37:04+02:00
Commit Message:
ASYLUM: Implement Hive machine puzzle
Changed paths:
engines/asylum/puzzles/hivemachine.cpp
engines/asylum/puzzles/hivemachine.h
diff --git a/engines/asylum/puzzles/hivemachine.cpp b/engines/asylum/puzzles/hivemachine.cpp
index 92289b550d..3385229fc0 100644
--- a/engines/asylum/puzzles/hivemachine.cpp
+++ b/engines/asylum/puzzles/hivemachine.cpp
@@ -34,8 +34,129 @@
namespace Asylum {
+const Common::Point keyPoints[] = {
+ Common::Point(246, 106),
+ Common::Point(377, 171),
+ Common::Point(319, 250),
+ Common::Point(220, 249),
+ Common::Point(167, 154)
+};
+
+const Common::Point indicatorPoints[] = {
+ Common::Point(260, 410),
+ Common::Point(279, 411),
+ Common::Point(298, 411),
+ Common::Point(318, 412),
+ Common::Point(338, 413),
+ Common::Point(358, 413)
+};
+
PuzzleHiveMachine::PuzzleHiveMachine(AsylumEngine *engine) : Puzzle(engine) {
- _rectIndex = 0;
+ _counter = _counter1 = 0;
+ _rectIndex = -2;
+ _frameIndex = 0;
+ _soundingNote = kMusicalNoteNone;
+ _notesNumber = 0;
+ _ok = false;
+
+ _polygons[0].points.push_back(Common::Point(306, 108));
+ _polygons[0].points.push_back(Common::Point(334, 111));
+ _polygons[0].points.push_back(Common::Point(340, 112));
+ _polygons[0].points.push_back(Common::Point(346, 120));
+ _polygons[0].points.push_back(Common::Point(352, 127));
+ _polygons[0].points.push_back(Common::Point(371, 142));
+ _polygons[0].points.push_back(Common::Point(363, 160));
+ _polygons[0].points.push_back(Common::Point(363, 172));
+ _polygons[0].points.push_back(Common::Point(362, 182));
+ _polygons[0].points.push_back(Common::Point(363, 190));
+ _polygons[0].points.push_back(Common::Point(348, 202));
+ _polygons[0].points.push_back(Common::Point(318, 210));
+ _polygons[0].points.push_back(Common::Point(292, 194));
+ _polygons[0].points.push_back(Common::Point(278, 193));
+ _polygons[0].points.push_back(Common::Point(268, 180));
+ _polygons[0].points.push_back(Common::Point(270, 162));
+ _polygons[0].points.push_back(Common::Point(266, 152));
+ _polygons[0].points.push_back(Common::Point(273, 137));
+ _polygons[0].points.push_back(Common::Point(283, 120));
+
+ _polygons[1].points.push_back(Common::Point(436, 171));
+ _polygons[1].points.push_back(Common::Point(464, 181));
+ _polygons[1].points.push_back(Common::Point(482, 201));
+ _polygons[1].points.push_back(Common::Point(472, 228));
+ _polygons[1].points.push_back(Common::Point(473, 245));
+ _polygons[1].points.push_back(Common::Point(460, 262));
+ _polygons[1].points.push_back(Common::Point(452, 262));
+ _polygons[1].points.push_back(Common::Point(416, 244));
+ _polygons[1].points.push_back(Common::Point(403, 231));
+ _polygons[1].points.push_back(Common::Point(378, 220));
+ _polygons[1].points.push_back(Common::Point(379, 215));
+ _polygons[1].points.push_back(Common::Point(387, 201));
+ _polygons[1].points.push_back(Common::Point(405, 177));
+
+ _polygons[2].points.push_back(Common::Point(357, 249));
+ _polygons[2].points.push_back(Common::Point(368, 252));
+ _polygons[2].points.push_back(Common::Point(407, 277));
+ _polygons[2].points.push_back(Common::Point(415, 283));
+ _polygons[2].points.push_back(Common::Point(422, 294));
+ _polygons[2].points.push_back(Common::Point(413, 314));
+ _polygons[2].points.push_back(Common::Point(413, 324));
+ _polygons[2].points.push_back(Common::Point(406, 337));
+ _polygons[2].points.push_back(Common::Point(386, 343));
+ _polygons[2].points.push_back(Common::Point(368, 350));
+ _polygons[2].points.push_back(Common::Point(354, 347));
+ _polygons[2].points.push_back(Common::Point(335, 347));
+ _polygons[2].points.push_back(Common::Point(325, 339));
+ _polygons[2].points.push_back(Common::Point(320, 319));
+ _polygons[2].points.push_back(Common::Point(325, 308));
+ _polygons[2].points.push_back(Common::Point(324, 292));
+ _polygons[2].points.push_back(Common::Point(329, 286));
+ _polygons[2].points.push_back(Common::Point(341, 272));
+ _polygons[2].points.push_back(Common::Point(347, 253));
+
+ _polygons[3].points.push_back(Common::Point(247, 249));
+ _polygons[3].points.push_back(Common::Point(260, 263));
+ _polygons[3].points.push_back(Common::Point(279, 279));
+ _polygons[3].points.push_back(Common::Point(298, 290));
+ _polygons[3].points.push_back(Common::Point(299, 308));
+ _polygons[3].points.push_back(Common::Point(303, 322));
+ _polygons[3].points.push_back(Common::Point(294, 337));
+ _polygons[3].points.push_back(Common::Point(286, 342));
+ _polygons[3].points.push_back(Common::Point(241, 342));
+ _polygons[3].points.push_back(Common::Point(232, 338));
+ _polygons[3].points.push_back(Common::Point(219, 315));
+ _polygons[3].points.push_back(Common::Point(224, 284));
+ _polygons[3].points.push_back(Common::Point(224, 267));
+
+ _polygons[4].points.push_back(Common::Point(222, 156));
+ _polygons[4].points.push_back(Common::Point(231, 164));
+ _polygons[4].points.push_back(Common::Point(237, 174));
+ _polygons[4].points.push_back(Common::Point(246, 184));
+ _polygons[4].points.push_back(Common::Point(258, 187));
+ _polygons[4].points.push_back(Common::Point(266, 183));
+ _polygons[4].points.push_back(Common::Point(275, 195));
+ _polygons[4].points.push_back(Common::Point(261, 198));
+ _polygons[4].points.push_back(Common::Point(253, 205));
+ _polygons[4].points.push_back(Common::Point(247, 215));
+ _polygons[4].points.push_back(Common::Point(243, 232));
+ _polygons[4].points.push_back(Common::Point(246, 247));
+ _polygons[4].points.push_back(Common::Point(226, 261));
+ _polygons[4].points.push_back(Common::Point(202, 247));
+ _polygons[4].points.push_back(Common::Point(186, 236));
+ _polygons[4].points.push_back(Common::Point(184, 227));
+ _polygons[4].points.push_back(Common::Point(175, 217));
+ _polygons[4].points.push_back(Common::Point(170, 210));
+ _polygons[4].points.push_back(Common::Point(171, 196));
+ _polygons[4].points.push_back(Common::Point(175, 186));
+ _polygons[4].points.push_back(Common::Point(177, 180));
+ _polygons[4].points.push_back(Common::Point(183, 172));
+ _polygons[4].points.push_back(Common::Point(201, 158));
+ _polygons[4].points.push_back(Common::Point(207, 158));
+
+ _polygons[0].boundingRect = Common::Rect(264, 106, 370, 211);
+ _polygons[1].boundingRect = Common::Rect(376, 171, 483, 264);
+ _polygons[2].boundingRect = Common::Rect(317, 247, 424, 352);
+ _polygons[3].boundingRect = Common::Rect(217, 247, 305, 345);
+ _polygons[4].boundingRect = Common::Rect(168, 154, 278, 264);
}
PuzzleHiveMachine::~PuzzleHiveMachine() {
@@ -45,25 +166,50 @@ PuzzleHiveMachine::~PuzzleHiveMachine() {
// Event Handling
//////////////////////////////////////////////////////////////////////////
bool PuzzleHiveMachine::init(const AsylumEvent &evt) {
- error("[PuzzleHiveMachine::init] Not implemented!");
-
getScreen()->setPalette(getWorld()->graphicResourceIds[9]);
getScreen()->setGammaLevel(getWorld()->graphicResourceIds[9], 0);
_rectIndex = -2;
- updateCursor();
return true;
}
bool PuzzleHiveMachine::update(const AsylumEvent &evt) {
- error("[PuzzleHiveMachine::update] Not implemented!");
+ updateScreen();
+ updateCursor();
+
+ return true;
}
bool PuzzleHiveMachine::mouseLeftDown(const AsylumEvent &evt) {
- error("[PuzzleHiveMachine::mouseLeftDown] Not implemented!");
+ if (_rectIndex != -1 && _counter == 0) {
+ _soundingNote = MusicalNote(_rectIndex);
+ _melody.push_back(_soundingNote);
+ _notesNumber = (_notesNumber + 1) % 7;
+ _counter1 = 10;
+ _frameIndex1 = 0;
+ playSound();
+
+ if (_melody.size() == 6) {
+ _ok = (_melody[0] == kMusicalNoteA) &&
+ (_melody[1] == kMusicalNoteD) &&
+ (_melody[2] == kMusicalNoteD) &&
+ (_melody[3] == kMusicalNoteA) &&
+ (_melody[4] == kMusicalNoteF) &&
+ (_melody[5] == kMusicalNoteE);
+ if (!_ok) {
+ _melody.clear();
+ _counter = 30;
+ }
+ }
+ }
+
+ return true;
}
bool PuzzleHiveMachine::mouseRightDown(const AsylumEvent &evt) {
+ _notesNumber = 0;
+ _melody.clear();
+
getScreen()->clear();
_vm->switchEventHandler(getScene());
@@ -87,15 +233,61 @@ void PuzzleHiveMachine::updateCursor() {
}
int32 PuzzleHiveMachine::findRect() {
- error("[PuzzleHiveMachine::findRect] Not implemented!");
+ for (uint32 i = 0; i < 5; ++i)
+ if (_polygons[i].contains(getCursor()->position()))
+ return i;
+
+ return -1;
}
void PuzzleHiveMachine::updateScreen() {
- error("[PuzzleHiveMachine::updateScreen] Not implemented!");
+ getScreen()->clear();
+ getScreen()->clearGraphicsInQueue();
+ getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[8], 0, Common::Point(0, 0), kDrawFlagNone, 0, 2);
+
+ if (_ok)
+ getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[11], 0, Common::Point(271, 369), kDrawFlagNone, 0, 1);
+ else if (_counter) {
+ if (_counter == 1)
+ _notesNumber = 0;
+ else if (_counter == 30)
+ getSound()->playSound(getWorld()->graphicResourceIds[85], false, Config.sfxVolume - 10);
+ getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[10], 0, Common::Point(318, 372), kDrawFlagNone, 0, 1);
+
+ --_counter;
+ }
+
+ for (uint32 i = 0; i < 5; ++i) {
+ uint32 resourceId = i + 13, frameIndex;
+ if (_soundingNote == MusicalNote(i)) {
+ resourceId += 5;
+ frameIndex = _frameIndex1;
+ } else
+ frameIndex = _frameIndex;
+ getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[resourceId], frameIndex, keyPoints[i], kDrawFlagNone, 0, 1);
+ }
+
+ if (_counter1)
+ --_counter1;
+ else {
+ _soundingNote = kMusicalNoteNone;
+ _frameIndex1 = 0;
+ }
+
+ for (uint32 i = 0; i < _notesNumber; ++i)
+ getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[84], 0, indicatorPoints[i], kDrawFlagNone, 0, 1);
+
+ _frameIndex = (_frameIndex + 1) % GraphicResource::getFrameCount(_vm, getWorld()->graphicResourceIds[13]);
+ if (_counter1)
+ _frameIndex1 = (_frameIndex1 + 1) % GraphicResource::getFrameCount(_vm, getWorld()->graphicResourceIds[18]);
+
+ getScreen()->drawGraphicsInQueue();
+ getScreen()->copyBackBufferToScreen();
}
void PuzzleHiveMachine::playSound() {
- error("[PuzzleHiveMachine::playSound] Not implemented!");
+ uint32 soundMap[] = {4, 2, 3, 0, 1};
+ getSound()->playSound(getWorld()->graphicResourceIds[soundMap[_soundingNote] + 23], false, Config.sfxVolume - 10);
}
} // End of namespace Asylum
diff --git a/engines/asylum/puzzles/hivemachine.h b/engines/asylum/puzzles/hivemachine.h
index 70f06d4f7b..04583b1c37 100644
--- a/engines/asylum/puzzles/hivemachine.h
+++ b/engines/asylum/puzzles/hivemachine.h
@@ -25,6 +25,9 @@
#include "asylum/puzzles/puzzle.h"
+#include "common/array.h"
+#include "asylum/resources/polygons.h"
+
namespace Asylum {
class AsylumEngine;
@@ -35,7 +38,23 @@ public:
~PuzzleHiveMachine();
private:
+ enum MusicalNote {
+ kMusicalNoteNone = -1,
+ kMusicalNoteF,
+ kMusicalNoteD,
+ kMusicalNoteE,
+ kMusicalNoteA,
+ kMusicalNoteB
+ };
+
+ uint32 _counter, _counter1;
int32 _rectIndex;
+ uint32 _frameIndex, _frameIndex1;
+ Common::Array<MusicalNote> _melody;
+ MusicalNote _soundingNote;
+ uint32 _notesNumber;
+ Polygon _polygons[5];
+ bool _ok;
//////////////////////////////////////////////////////////////////////////
// Event Handling
Commit: 2dd99302978f9971b0fa3191ba69e42f9b12e2dd
https://github.com/scummvm/scummvm/commit/2dd99302978f9971b0fa3191ba69e42f9b12e2dd
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:37:04+02:00
Commit Message:
ASYLUM: Fix uninitialized variable warning in PuzzlePipes::update()
Changed paths:
engines/asylum/puzzles/pipes.cpp
diff --git a/engines/asylum/puzzles/pipes.cpp b/engines/asylum/puzzles/pipes.cpp
index 522fb82fd4..ac9d750ae3 100644
--- a/engines/asylum/puzzles/pipes.cpp
+++ b/engines/asylum/puzzles/pipes.cpp
@@ -388,22 +388,27 @@ bool PuzzlePipes::update(const AsylumEvent &evt) {
getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[45], 0, Common::Point(518, 108), kDrawFlagNone, 0, 2);
for (uint32 i = 0; i < _spiders.size(); ++i) {
- uint32 spiderResourceId;
+ uint32 spiderResourceId = 0;
switch (_spiders[i]->getDirection()) {
+ default:
+ error("[PuzzlePipes::update] Invalid spider direction (%d)", _spiders[i]->getDirection());
+
case kDirectionNh:
spiderResourceId = _spiders[i]->isAlive() ? 34 : 37;
break;
+
case kDirectionEt:
spiderResourceId = _spiders[i]->isAlive() ? 35 : 38; // FIXME
break;
+
case kDirectionSh:
spiderResourceId = _spiders[i]->isAlive() ? 36 : 39;
break;
+
case kDirectionWt:
spiderResourceId = _spiders[i]->isAlive() ? 35 : 38;
break;
- default: ;
}
if (_spiders[i]->isVisible(Common::Rect(-10, -10, 650, 490))) {
Commit: 0c223c5875f94602c83351811df618ece05a4330
https://github.com/scummvm/scummvm/commit/0c223c5875f94602c83351811df618ece05a4330
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:37:04+02:00
Commit Message:
ASYLUM: Fix flickering of text in the credits
This was due to the transparency index not being reset to 0 after the text fade animation.
Changed paths:
engines/asylum/views/menu.cpp
diff --git a/engines/asylum/views/menu.cpp b/engines/asylum/views/menu.cpp
index ca321c6d33..d2e9d0bf8a 100644
--- a/engines/asylum/views/menu.cpp
+++ b/engines/asylum/views/menu.cpp
@@ -1542,17 +1542,16 @@ void Menu::updateShowCredits() {
break;
int32 minBound = _startIndex + step + 24;
- if (minBound >= 0)
- if (minBound < 32)
- getText()->setTransTableNum(3 - minBound / 8);
+ if (minBound >= 0 && minBound < 32)
+ getText()->setTransTableNum(3 - minBound / 8);
int32 maxBound = _startIndex + step;
- if ((_startIndex + step) < 480)
- if (maxBound > 448)
- getText()->setTransTableNum(3 - (479 - maxBound) / 8);
+ if ((_startIndex + step) < 480 && maxBound > 448)
+ getText()->setTransTableNum(3 - (479 - maxBound) / 8);
getText()->setPosition(320, step + _startIndex);
getText()->draw(MAKE_RESOURCE(kResourcePackText, 1447 + index));
+ getText()->setTransTableNum(0);
}
step += 24;
@@ -1568,7 +1567,7 @@ void Menu::updateShowCredits() {
}
_startIndex -= 2;
- if (_startIndex < -(8688 + 24))
+ if (_startIndex < -8712) // 8688 + 24
closeCredits();
}
Commit: 07f49cdf9a44c9e04936c53b79805e81a8b41c7c
https://github.com/scummvm/scummvm/commit/07f49cdf9a44c9e04936c53b79805e81a8b41c7c
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:37:04+02:00
Commit Message:
ASYLUM: Initialize _frameIndexSpider in PuzzlePipes constructor
This fixes a crash on exit.
Changed paths:
engines/asylum/puzzles/pipes.cpp
diff --git a/engines/asylum/puzzles/pipes.cpp b/engines/asylum/puzzles/pipes.cpp
index ac9d750ae3..3d19cc2f03 100644
--- a/engines/asylum/puzzles/pipes.cpp
+++ b/engines/asylum/puzzles/pipes.cpp
@@ -307,6 +307,8 @@ PuzzlePipes::PuzzlePipes(AsylumEngine *engine) : Puzzle(engine) {
memset(_previousLevels, 0, sizeof(_previousLevels));
memset(&_levelFlags, false, sizeof(_levelFlags));
_levelFlags[4] = true;
+
+ _frameIndexSpider = NULL;
}
PuzzlePipes::~PuzzlePipes() {
Commit: 01f4a0769c3b8a6899050300ae855c2e684d1f24
https://github.com/scummvm/scummvm/commit/01f4a0769c3b8a6899050300ae855c2e684d1f24
Author: Alex Bevilacqua (alexbevi at gmail.com)
Date: 2021-05-17T15:37:05+02:00
Commit Message:
ASYLUM: implement Screen::setPaletteGamma and part of Screen::setGammaLevel
Changed paths:
engines/asylum/system/screen.cpp
diff --git a/engines/asylum/system/screen.cpp b/engines/asylum/system/screen.cpp
index 91aaf32dbc..9b91e52e0e 100644
--- a/engines/asylum/system/screen.cpp
+++ b/engines/asylum/system/screen.cpp
@@ -239,7 +239,33 @@ void Screen::setPalette(byte *rgbPalette) const {
}
void Screen::setPaletteGamma(ResourceId id) {
- warning("[Screen::setGammaPalette] not implemented");
+ byte *resPalette = getResource()->get(id)->data + 32;
+ byte rgbPalette[256 * 3];
+
+ _vm->_system->getPaletteManager()->grabPalette(rgbPalette, 0, 256);
+
+ for (int32 i = 1; i < 256; i++) {
+ int color = 0;
+ if (resPalette[i * 3 + 0] > 0)
+ color = resPalette[i * 3 + 0];
+ if (resPalette[i * 3 + 1] > color)
+ color = resPalette[i * 3 + 1];
+ if (resPalette[i * 3 + 2] > color)
+ color = resPalette[i * 3 + 2];
+
+ int gamma = color + (Config.gammaLevel * (63 - color) + 31) / 63;
+
+ if (gamma) {
+ if (resPalette[i * 3 + 0])
+ rgbPalette[i * 3 + 0] = 4 * ((color >> 1) + resPalette[i * 3 + 0] * gamma) / color;
+ if (resPalette[i * 3 + 1])
+ rgbPalette[i * 3 + 1] = 4 * ((color >> 1) + resPalette[i * 3 + 1] * gamma) / color;
+ if (resPalette[i * 3 + 2])
+ rgbPalette[i * 3 + 2] = 4 * ((color >> 1) + resPalette[i * 3 + 2] * gamma) / color;
+ }
+ }
+
+ _vm->_system->getPaletteManager()->setPalette(rgbPalette, 0, 256);
}
void Screen::setupPaletteAndStartFade(uint32 red, int32 milliseconds, int32 param) {
@@ -280,7 +306,10 @@ void Screen::setupPalette(byte *buffer, int start, int count) {
// Gamma
//////////////////////////////////////////////////////////////////////////
void Screen::setGammaLevel(ResourceId id, int32 val) {
- warning("[Screen::setGammaLevel] not implemented");
+ if (Config.gammaLevel)
+ setPaletteGamma(id);
+ else
+ warning("[Screen::setGammaLevel] Palette creation without a valid resource Id not implemented");
}
//////////////////////////////////////////////////////////////////////////
Commit: 7454be17ccddb4fee98cbbaa733b9df593713659
https://github.com/scummvm/scummvm/commit/7454be17ccddb4fee98cbbaa733b9df593713659
Author: Alex Bevilacqua (alexbevi at gmail.com)
Date: 2021-05-17T15:37:05+02:00
Commit Message:
ASYLUM: fix logic error in Screen::setGammaLevel
Changed paths:
engines/asylum/system/screen.cpp
diff --git a/engines/asylum/system/screen.cpp b/engines/asylum/system/screen.cpp
index 9b91e52e0e..76a70afeaf 100644
--- a/engines/asylum/system/screen.cpp
+++ b/engines/asylum/system/screen.cpp
@@ -306,10 +306,12 @@ void Screen::setupPalette(byte *buffer, int start, int count) {
// Gamma
//////////////////////////////////////////////////////////////////////////
void Screen::setGammaLevel(ResourceId id, int32 val) {
- if (Config.gammaLevel)
- setPaletteGamma(id);
- else
- warning("[Screen::setGammaLevel] Palette creation without a valid resource Id not implemented");
+ if (Config.gammaLevel) {
+ if (id)
+ setPaletteGamma(id);
+ else
+ warning("[Screen::setGammaLevel] Palette creation without a valid resource Id not implemented");
+ }
}
//////////////////////////////////////////////////////////////////////////
Commit: 83194b47c8c2d1d797c2dd4c41f2bb93e840f675
https://github.com/scummvm/scummvm/commit/83194b47c8c2d1d797c2dd4c41f2bb93e840f675
Author: Alex Bevilacqua (alexbevi at gmail.com)
Date: 2021-05-17T15:37:05+02:00
Commit Message:
ASYLUM: Silence more GCC warnings
Changed paths:
engines/asylum/views/scene.cpp
diff --git a/engines/asylum/views/scene.cpp b/engines/asylum/views/scene.cpp
index 5c0765859c..62fe64f620 100644
--- a/engines/asylum/views/scene.cpp
+++ b/engines/asylum/views/scene.cpp
@@ -1286,7 +1286,7 @@ int32 Scene::hitTestScene(HitType &type) {
for (uint i = 0; i < _ws->objects.size(); i++) {
Object *object = _ws->objects[i];
- if (object->isOnScreen() && object->actionType & kActionType8) {
+ if (object->isOnScreen() && (object->actionType & kActionType8)) {
if (hitTestPixel(object->getResourceId(),
object->getFrameIndex(),
top - object->x,
@@ -2474,7 +2474,7 @@ void Scene::processUpdateList() {
actor->getPoint1()->x + actor->getBoundingRect()->right,
bottomRight)) {
- if (BYTE1(object->flags) & kObjectFlag20 && !(BYTE1(object->flags) & kObjectFlag80))
+ if ((BYTE1(object->flags) & kObjectFlag20) && !(BYTE1(object->flags) & kObjectFlag80))
BYTE1(object->flags) = BYTE1(object->flags) | kObjectFlag40;
continue;
@@ -2490,9 +2490,9 @@ void Scene::processUpdateList() {
}
// Adjust object flags
- if (BYTE1(object->flags) & kObjectFlag80 || isMasked) {
+ if ((BYTE1(object->flags) & kObjectFlag80) || isMasked) {
if (BYTE1(object->flags) & kObjectFlag20)
- BYTE1(object->flags) = BYTE1(object->flags) & kObjectFlagBF | kObjectFlag80;
+ BYTE1(object->flags) = (BYTE1(object->flags) & kObjectFlagBF) | kObjectFlag80;
} else {
if (BYTE1(object->flags) & kObjectFlag20) {
BYTE1(object->flags) = BYTE1(object->flags) | kObjectFlag40;
Commit: a663c3da752995a692308e863551e9a41c877489
https://github.com/scummvm/scummvm/commit/a663c3da752995a692308e863551e9a41c877489
Author: Alex Bevilacqua (alexbevi at gmail.com)
Date: 2021-05-17T15:37:05+02:00
Commit Message:
ASYLUM: fix a logic error in JumpIfGameFlag
Game scripts now progress more accurately in Scene 2
Changed paths:
engines/asylum/resources/script.cpp
diff --git a/engines/asylum/resources/script.cpp b/engines/asylum/resources/script.cpp
index 4e7aaef9a6..89523bf907 100644
--- a/engines/asylum/resources/script.cpp
+++ b/engines/asylum/resources/script.cpp
@@ -445,7 +445,7 @@ IMPLEMENT_OPCODE(JumpIfGameFlag)
if (cmd->param1 < 0)
return;
- bool doJump = (cmd->param2) ? _vm->isGameFlagSet((GameFlag)cmd->param1) : _vm->isGameFlagNotSet((GameFlag)cmd->param1);
+ bool doJump = (cmd->param2) ? _vm->isGameFlagNotSet((GameFlag)cmd->param1) : _vm->isGameFlagSet((GameFlag)cmd->param1);
if (!doJump)
return;
Commit: 2608705d6db68c9a6f0cc6d71b9f1f9959645496
https://github.com/scummvm/scummvm/commit/2608705d6db68c9a6f0cc6d71b9f1f9959645496
Author: Alex Bevilacqua (alexbevi at gmail.com)
Date: 2021-05-17T15:37:05+02:00
Commit Message:
ASYLUM: sanity check for a possible assertion in Polygon::contains
Changed paths:
engines/asylum/resources/polygons.cpp
diff --git a/engines/asylum/resources/polygons.cpp b/engines/asylum/resources/polygons.cpp
index 1bc37bb0e9..a08250cd69 100644
--- a/engines/asylum/resources/polygons.cpp
+++ b/engines/asylum/resources/polygons.cpp
@@ -33,6 +33,11 @@ bool Polygon::contains(const Common::Point &point) {
bool yflag1;
bool inside_flag = false;
+ // if no points are defined, an intersect check will fail
+ // (count - 1 would trigger an assertion in vtx0)
+ if (points.size() == 0)
+ return false;
+
Common::Point *vtx0 = &points[count() - 1];
Common::Point *vtx1 = &points[0];
Commit: 4c4027200a2f500ffc9ffefefefe71ccb0097b76
https://github.com/scummvm/scummvm/commit/4c4027200a2f500ffc9ffefefefe71ccb0097b76
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:37:05+02:00
Commit Message:
ASYLUM: Implement Screen::bltMasked()
This is still slightly buggy (every other frame is slightly corrupted)
Changed paths:
engines/asylum/system/screen.cpp
engines/asylum/system/screen.h
diff --git a/engines/asylum/system/screen.cpp b/engines/asylum/system/screen.cpp
index 76a70afeaf..e38733266a 100644
--- a/engines/asylum/system/screen.cpp
+++ b/engines/asylum/system/screen.cpp
@@ -675,7 +675,7 @@ void Screen::blitMasked(GraphicFrame *frame, Common::Rect *source, byte *maskDat
byte *frameBuffer = (byte *)frame->surface.pixels;
byte *mirroredBuffer = NULL;
int16 frameRight = frame->surface.pitch;
- uint16 srcMaskLeft = abs(sourceMask->left);
+ byte zoom = abs(sourceMask->left) & 7;
// Prepare temporary source buffer if needed
if (flags & kDrawFlagMirrorLeftRight) {
@@ -695,7 +695,7 @@ void Screen::blitMasked(GraphicFrame *frame, Common::Rect *source, byte *maskDat
}
// Setup buffers and rectangles
- byte *frameBufferPtr = frameBuffer + source->top * frameRight + source->left;
+ byte *frameBufferPtr = frameBuffer + source->top * frameRight + source->left;
byte *maskBufferPtr = maskData + sourceMask->top * (maskWidth / 8) + sourceMask->left / 8;
// Check if we need to draw masked
@@ -722,9 +722,9 @@ void Screen::blitMasked(GraphicFrame *frame, Common::Rect *source, byte *maskDat
}
if (destination->left > destMask->left) {
- maskBufferPtr += (destination->left - destMask->left) / 8 + abs(destination->left - destMask->left) / 8;
+ zoom += abs(destination->left - destMask->left) & 7;
+ maskBufferPtr += (destination->left - destMask->left + zoom) / 8;
sourceMask->setWidth(sourceMask->width() + destMask->left - destination->left);
- srcMaskLeft = abs(destination->left - destMask->left);
destMask->left = destination->left;
}
@@ -806,15 +806,15 @@ void Screen::blitMasked(GraphicFrame *frame, Common::Rect *source, byte *maskDat
source->height(),
source->width(),
frameRight - source->width(),
- (maskWidth - srcMaskLeft - source->width()) / 8,
- srcMaskLeft,
+ (maskWidth - zoom - source->width()) / 8,
+ zoom,
(byte *)_backBuffer.pixels + _backBuffer.pitch * destination->top + destination->left,
_backBuffer.pitch - source->width());
// Draw debug rects
if (g_debugDrawRects) {
_backBuffer.frameRect(*destination, 0x128);
- drawZoomedMask(maskData, 21, maskWidth / 8, maskWidth);
+ drawZoomedMask(maskData, 20, maskWidth / 8, maskWidth);
}
// Cleanup
@@ -823,7 +823,7 @@ void Screen::blitMasked(GraphicFrame *frame, Common::Rect *source, byte *maskDat
// DEBUG: Draw the mask (zoomed)
void Screen::drawZoomedMask(byte *mask, int16 height, int16 width, uint16 maskPitch) {
- int zoom = 8;
+ int zoom = 7;
byte *dstBuffer = (byte *)_backBuffer.pixels;
uint16 dstPitch = _backBuffer.pitch - (width * zoom);
@@ -847,11 +847,41 @@ void Screen::drawZoomedMask(byte *mask, int16 height, int16 width, uint16 maskPi
}
}
-void Screen::bltMasked(byte *srcBuffer, byte *maskBuffer, int16 height, int16 width, uint16 srcPitch, uint16 maskPitch, byte maskLeft, byte *dstBuffer, uint16 dstPitch) {
- // FIXME: Use mask
- //warning("[Screen::bltMasked] Not implemented!");
+void Screen::bltMasked(byte *srcBuffer, byte *maskBuffer, int16 height, int16 width, uint16 srcPitch, uint16 maskPitch, byte zoom, byte *dstBuffer, uint16 dstPitch) {
+ if (zoom > 7)
+ error("[Screen::bltMasked] Invalid zoom value (was: %d, max: 7)", zoom);
- blitRawColorKey(dstBuffer, srcBuffer, height, width, srcPitch, dstPitch);
+ while (height--) {
+
+ // Calculate current zoom and run length
+ int run = (7 - zoom);
+ int skip = (*maskBuffer >> zoom);
+
+ for (int16 i = 0; i < width; i++) {
+ // Set destination value
+ if (*srcBuffer && !(skip & 1))
+ *dstBuffer = *srcBuffer;
+
+ // Advance buffers
+ dstBuffer++;
+ srcBuffer++;
+
+ // Check run/skip
+ run--;
+ if (run < 0) {
+ ++maskBuffer;
+
+ run = 7;
+ skip = *maskBuffer;
+ } else {
+ skip >>= 1;
+ }
+ }
+
+ dstBuffer += dstPitch;
+ srcBuffer += srcPitch;
+ maskBuffer += maskPitch + 1;
+ }
}
void Screen::blt(Common::Rect *dest, GraphicFrame* frame, Common::Rect *source, int32 flags) {
diff --git a/engines/asylum/system/screen.h b/engines/asylum/system/screen.h
index 6fdc08b35f..3be04b2f77 100644
--- a/engines/asylum/system/screen.h
+++ b/engines/asylum/system/screen.h
@@ -159,7 +159,7 @@ private:
void blitRaw (byte *dstBuffer, byte *srcBuffer, int16 height, int16 width, uint16 srcPitch, uint16 dstPitch);
void blitRawColorKey (byte *dstBuffer, byte *srcBuffer, int16 height, int16 width, uint16 srcPitch, uint16 dstPitch);
void blitCrossfade (byte *dstBuffer, byte *srcBuffer, byte *objectBuffer, int16 height, int16 width, uint16 srcPitch, uint16 dstPitch, uint16 objectPitch);
- void bltMasked (byte *srcBuffer, byte *maskBuffer, int16 height, int16 width, uint16 srcPitch, uint16 maskPitch, byte maskLeft, byte *dstBuffer, uint16 dstPitch);
+ void bltMasked (byte *srcBuffer, byte *maskBuffer, int16 height, int16 width, uint16 srcPitch, uint16 maskPitch, byte zoom, byte *dstBuffer, uint16 dstPitch);
// DirectDraw-equivalent functions
void blt(Common::Rect *dest, GraphicFrame* frame, Common::Rect *source, int32 flags);
Commit: da8d1c11b5d380ec67564c9beaf7f6a102e9fa7b
https://github.com/scummvm/scummvm/commit/da8d1c11b5d380ec67564c9beaf7f6a102e9fa7b
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:37:05+02:00
Commit Message:
ASYLUM: Update engine status
Changed paths:
engines/asylum/asylum.h
diff --git a/engines/asylum/asylum.h b/engines/asylum/asylum.h
index 0d669844d7..6ceb75dacc 100644
--- a/engines/asylum/asylum.h
+++ b/engines/asylum/asylum.h
@@ -44,16 +44,13 @@
* Status of this engine:
* - Script interpreters for main game and encounters are implemented
* - Object handling, player reaction and special chapter logic is implemented
- * - Scene parsing and drawing is almost complete
- * - Movie code is almost complete
- * - Mouse cursor is initialized and animated properly
- * - Menu handling is mostly done (missing savegame management and movie list)
+ * - Scene parsing and drawing, movie playing, mouse cursor and menu handling are almost complete
* - Sound code is almost complete (music is still WIP)
- * - Only one puzzle is partially implemented
- * - Preliminary code for walking around with the mouse.
+ * - Almost all puzzles are implemented
+ * - Walking is partialy implemented but the primitive pathfinding is missing
*
* Maintainers:
- * alexbevi, alexandrefontoura, bluegr, littleboy
+ * alexbevi, alexandrefontoura, bluegr, littleboy, midstream
*
* Supported games:
* - Sanitarium
Commit: 71ffd5313a6ee2ff0e83c051f3e9d145dc2cc36d
https://github.com/scummvm/scummvm/commit/71ffd5313a6ee2ff0e83c051f3e9d145dc2cc36d
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:37:06+02:00
Commit Message:
ASYLUM: Move DEBUG_SCENE_TIMES to scene.cpp
Changed paths:
engines/asylum/asylum.h
engines/asylum/views/scene.h
diff --git a/engines/asylum/asylum.h b/engines/asylum/asylum.h
index 6ceb75dacc..aea0cff9a1 100644
--- a/engines/asylum/asylum.h
+++ b/engines/asylum/asylum.h
@@ -57,9 +57,6 @@
*/
namespace Asylum {
-// If defined, will show the scene update times on the debugger output
-//#define DEBUG_SCENE_TIMES
-
class Puzzle;
class Cursor;
class Encounter;
diff --git a/engines/asylum/views/scene.h b/engines/asylum/views/scene.h
index 291a6810a4..23f033890a 100644
--- a/engines/asylum/views/scene.h
+++ b/engines/asylum/views/scene.h
@@ -34,6 +34,9 @@
#define SCENE_FILE_MASK "scn.%03d"
#define MUSIC_FILE_MASK "mus.%03d"
+// If defined, will show the scene update times on the debugger output
+//#define DEBUG_SCENE_TIMES
+
namespace Asylum {
class Actor;
Commit: 997002786d5c27bf5f96d5326ffa71b8285f85dc
https://github.com/scummvm/scummvm/commit/997002786d5c27bf5f96d5326ffa71b8285f85dc
Author: Alex Bevilacqua (alexbevi at gmail.com)
Date: 2021-05-17T15:37:06+02:00
Commit Message:
ASYLUM: Assign the current graphicResourceId in Cursor::set
This fixes cursor animations not playing
Changed paths:
engines/asylum/system/cursor.cpp
diff --git a/engines/asylum/system/cursor.cpp b/engines/asylum/system/cursor.cpp
index 88e56618be..57dcec3205 100644
--- a/engines/asylum/system/cursor.cpp
+++ b/engines/asylum/system/cursor.cpp
@@ -70,6 +70,7 @@ void Cursor::set(ResourceId resourceId, int32 cnt, CursorAnimation anim, int32 f
else
lastFrameIndex = _cursorRes->count() - 1;
+ this->graphicResourceId = resourceId;
this->animation = anim;
this->counter = cnt;
currentFrame = 0;
Commit: ef730d52d9eb2afc207fe552891bda6e82f309ff
https://github.com/scummvm/scummvm/commit/ef730d52d9eb2afc207fe552891bda6e82f309ff
Author: Alex Bevilacqua (alexbevi at gmail.com)
Date: 2021-05-17T15:37:06+02:00
Commit Message:
ASYLUM: Add a TODO regarding a proper implentation of the intro speech
Changed paths:
engines/asylum/asylum.cpp
diff --git a/engines/asylum/asylum.cpp b/engines/asylum/asylum.cpp
index cfaef02c68..99d5a75e90 100644
--- a/engines/asylum/asylum.cpp
+++ b/engines/asylum/asylum.cpp
@@ -292,7 +292,21 @@ void AsylumEngine::playIntro() {
setGameFlag(kGameFlag12);
// Play the intro sound sample (the screen is blacked out, you hear an alarm sounding and men talking about.
- _sound->playSound(MAKE_RESOURCE(kResourcePackSound, 7));
+ ResourceId introSpeech = MAKE_RESOURCE(kResourcePackSound, 7);
+ _sound->playSound(introSpeech);
+
+ // TODO In the original game, the intro speech is played after the intro video. The speech is played over a black
+ // background, and the game is locked until the speech is completed.
+ // The implementation below is here is what was originally implemented by DreamForge. This code will lock up the
+ // application if used as is as no events are being processed until the sound thread completes.
+ // A much cleaner implementation can be found in commit f6b2ed3be51b738c962608e06d10a665e3abfb82 (svn298), but
+ // needs to be adapted to the new event code.
+ /*
+ if (_sound->isPlaying(introSpeech)) {
+ while (_sound->isPlaying(introSpeech))
+ ;
+ }
+ */
}
_introPlayed = true;
Commit: 1706cc2ff74a2c67c140dfd9b24783475ba4180d
https://github.com/scummvm/scummvm/commit/1706cc2ff74a2c67c140dfd9b24783475ba4180d
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:37:06+02:00
Commit Message:
ASYLUM: Implement Actor::processAction()
Changed paths:
engines/asylum/resources/actor.cpp
engines/asylum/resources/actor.h
diff --git a/engines/asylum/resources/actor.cpp b/engines/asylum/resources/actor.cpp
index 011f8e9ac9..a52e23af2a 100644
--- a/engines/asylum/resources/actor.cpp
+++ b/engines/asylum/resources/actor.cpp
@@ -988,7 +988,7 @@ bool Actor::process(const Common::Point &point) {
}
if (abs(delta.x) != abs(delta.y)) {
- Common::Array<int> actions;
+ Common::Array<ActionArea *> actions;
Common::Point point1;
Common::Point point2;
uint32 count1 = 0;
@@ -2508,7 +2508,7 @@ void Actor::updateNumbers(int32 reaction, const Common::Point &point) {
//////////////////////////////////////////////////////////////////////////
// Path finding functions
//////////////////////////////////////////////////////////////////////////
-bool Actor::processActionLeft(Common::Point source, const Common::Point &destination, Common::Array<int> *actions) {
+bool Actor::processActionLeft(Common::Point source, const Common::Point &destination, Common::Array<ActionArea *> *actions) {
// Reset pathfinding data
_data.count = 0;
_data.current = 0;
@@ -2537,7 +2537,7 @@ bool Actor::processActionLeft(Common::Point source, const Common::Point &destina
return false;
}
-bool Actor::processActionAll(Common::Point source, const Common::Point &destination, Common::Array<int> *actions) {
+bool Actor::processActionAll(Common::Point source, const Common::Point &destination, Common::Array<ActionArea *> *actions) {
// Reset pathfinding data
_data.count = 0;
_data.current = 0;
@@ -2576,7 +2576,7 @@ bool Actor::processActionAll(Common::Point source, const Common::Point &destinat
return false;
}
-bool Actor::processActionTop(Common::Point source, const Common::Point &destination, Common::Array<int> *actions) {
+bool Actor::processActionTop(Common::Point source, const Common::Point &destination, Common::Array<ActionArea *> *actions) {
// Reset pathfinding data
_data.count = 0;
_data.current = 0;
@@ -2611,7 +2611,7 @@ bool Actor::processActionTop(Common::Point source, const Common::Point &destinat
return false;
}
-bool Actor::processActionDown(Common::Point source, const Common::Point &destination, Common::Array<int> *actions) {
+bool Actor::processActionDown(Common::Point source, const Common::Point &destination, Common::Array<ActionArea *> *actions) {
// Reset pathfinding data
_data.count = 0;
_data.current = 0;
@@ -2637,16 +2637,169 @@ bool Actor::processActionDown(Common::Point source, const Common::Point &destina
return false;
}
-bool Actor::processAction(const Common::Point &source, Common::Array<int> *actions, Common::Point *point, ActorDirection direction, const Common::Point &destination, bool *flag) {
- error("[Actor::processAction] Not implemented");
+bool Actor::processAction(const Common::Point &source, Common::Array<ActionArea *> *actions, Common::Point *point, ActorDirection direction, const Common::Point &destination, bool *flag) {
+ Common::Point sign;
+ Common::Point src = source;
+ uint32 frameNumber = _frameNumber;
+
+ switch (direction){
+ default:
+ return false;
+
+ case kDirectionN:
+ sign.y = -1;
+ break;
+
+ case kDirectionNO:
+ sign.x = -1;
+ sign.y = -1;
+ break;
+
+ case kDirectionO:
+ sign.x = -1;
+ break;
+
+ case kDirectionSO:
+ sign.x = -1;
+ sign.y = 1;
+ break;
+
+ case kDirectionS:
+ sign.y = 1;
+ break;
+
+ case kDirectionSE:
+ sign.x = 1;
+ sign.y = 1;
+ break;
+
+ case kDirectionE:
+ sign.x = 1;
+ break;
+
+ case kDirectionNE:
+ sign.x = 1;
+ sign.y = -1;
+ break;
+ }
+
+ for (int i = 0; i < 10; i++) {
+ if (!checkAllActions(src, actions))
+ break;
+
+ int32 dist = getDistanceForFrame(direction, frameNumber);
+ src.x += sign.x * dist;
+ src.y += sign.y * dist;
+
+ if (abs(src.x - destination.x) >= getDistanceForFrame(kDirectionO, frameNumber)) {
+ if (abs(src.y - destination.y) >= getDistanceForFrame(kDirectionN, frameNumber)) {
+
+ if (src.x >= destination.x) {
+ if (checkPath(actions, src, kDirectionO, src.x - destination.x)) {
+ *flag = true;
+ *point = src;
+
+ _data.points[_data.count] = src;
+ _data.directions[_data.count] = direction;
+ _data.count++;
+
+ _data.points[_data.count] = destination;
+ _data.directions[_data.count] = kDirectionO;
+ _data.count++;
+
+ return true;
+ }
+ } else {
+ if (checkPath(actions, src, kDirectionE, destination.x - src.x)) {
+ *flag = true;
+ *point = src;
+
+ _data.points[_data.count] = src;
+ _data.directions[_data.count] = direction;
+ _data.count++;
+
+ _data.points[_data.count] = destination;
+ _data.directions[_data.count] = kDirectionE;
+ _data.count++;
+
+ return true;
+ }
+ }
+ }
+ } else {
+ if (src.y >= destination.y) {
+ if (checkPath(actions, src, kDirectionN, src.y - destination.y)) {
+ *flag = true;
+ *point = src;
+
+ _data.points[_data.count] = src;
+ _data.directions[_data.count] = direction;
+ _data.count++;
+
+ _data.points[_data.count] = destination;
+ _data.directions[_data.count] = kDirectionN;
+ _data.count++;
+
+ return true;
+ }
+ } else {
+ if (checkPath(actions, src, kDirectionS, destination.y - src.y)) {
+ *flag = true;
+ *point = src;
+
+ _data.points[_data.count] = src;
+ _data.directions[_data.count] = direction;
+ _data.count++;
+
+ _data.points[_data.count] = destination;
+ _data.directions[_data.count] = kDirectionS;
+ _data.count++;
+
+ return true;
+ }
+ }
+ }
+
+ // Proceed to next frame
+ ++frameNumber;
+
+ if (frameNumber >= _frameCount)
+ frameNumber = 0;
+ }
+
+ // Check if we need to process
+ int32 distance = getDistanceForFrame(direction, frameNumber);
+ if (source.x == (src.x - sign.x * distance) && source.y == (src.y - sign.y * distance))
+ return false;
+
+ if (!getWorld()->sceneRects[getWorld()->sceneRectIdx].contains(src))
+ return false;
+
+ // Update frame and setup pathfinding
+ _frameNumber = frameNumber;
+
+ if (_frameNumber <= 0)
+ distance = getDistanceForFrame(direction, _frameCount - 1);
+ else
+ distance = getDistanceForFrame(direction, _frameNumber - 1);
+
+ src.x -= sign.x * distance;
+ src.y -= sign.y * distance;
+
+ *point = src;
+ _data.points[_data.count] = src;
+ _data.directions[_data.count] = direction;
+ _data.count++;
+
+ return true;
}
-bool Actor::checkPath(Common::Array<ActionArea *> *actions, const Common::Point &point, uint32 index, uint32 loopcount) {
+bool Actor::checkPath(Common::Array<ActionArea *> *actions, const Common::Point &point, ActorDirection direction, uint32 loopcount) {
if (loopcount <= 1)
return true;
// Initialize base coordinates
- Common::Point basePoint = deltaPointsArray[index] + point;
+ Common::Point basePoint = deltaPointsArray[direction] + point;
Common::Rect rect = getWorld()->sceneRects[getWorld()->sceneRectIdx];
for (uint32 i = 1; i < loopcount; i++) {
@@ -2656,7 +2809,7 @@ bool Actor::checkPath(Common::Array<ActionArea *> *actions, const Common::Point
if (!rect.contains(basePoint))
return false;
- basePoint += deltaPointsArray[index];
+ basePoint += deltaPointsArray[direction];
}
return true;
diff --git a/engines/asylum/resources/actor.h b/engines/asylum/resources/actor.h
index 3820be94a6..3032023a58 100644
--- a/engines/asylum/resources/actor.h
+++ b/engines/asylum/resources/actor.h
@@ -438,12 +438,12 @@ private:
// Path finding functions
//////////////////////////////////////////////////////////////////////////
uint32 _frameNumber;
- bool processActionLeft(Common::Point source, const Common::Point &destination, Common::Array<int> *actions);
- bool processActionAll(Common::Point source, const Common::Point &destination, Common::Array<int> *actions);
- bool processActionTop(Common::Point source, const Common::Point &destination, Common::Array<int> *actions);
- bool processActionDown(Common::Point source, const Common::Point &destination, Common::Array<int> *actions);
- bool processAction(const Common::Point &source, Common::Array<int> *actions, Common::Point *point, ActorDirection direction, const Common::Point &destination, bool *flag);
- bool checkPath(Common::Array<ActionArea *> *actions, const Common::Point &point, uint32 index, uint32 loopcount);
+ bool processActionLeft(Common::Point source, const Common::Point &destination, Common::Array<ActionArea *> *actions);
+ bool processActionAll(Common::Point source, const Common::Point &destination, Common::Array<ActionArea *> *actions);
+ bool processActionTop(Common::Point source, const Common::Point &destination, Common::Array<ActionArea *> *actions);
+ bool processActionDown(Common::Point source, const Common::Point &destination, Common::Array<ActionArea *> *actions);
+ bool processAction(const Common::Point &source, Common::Array<ActionArea *> *actions, Common::Point *point, ActorDirection direction, const Common::Point &destination, bool *flag);
+ bool checkPath(Common::Array<ActionArea *> *actions, const Common::Point &point, ActorDirection direction, uint32 loopcount);
bool checkAllActions(const Common::Point &pt, Common::Array<ActionArea *> *actions);
//////////////////////////////////////////////////////////////////////////
Commit: 64c70dea970d5331bbe50f67e042889c30db3fae
https://github.com/scummvm/scummvm/commit/64c70dea970d5331bbe50f67e042889c30db3fae
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:37:06+02:00
Commit Message:
ASYLUM: Implement Actor::updateDirection()
- Rename all fields related to the next actor state (as set by script)
- Rename process_401830() to processNext()
Changed paths:
engines/asylum/resources/actor.cpp
engines/asylum/resources/actor.h
engines/asylum/resources/script.cpp
engines/asylum/views/scene.cpp
diff --git a/engines/asylum/resources/actor.cpp b/engines/asylum/resources/actor.cpp
index a52e23af2a..80f2aabdb9 100644
--- a/engines/asylum/resources/actor.cpp
+++ b/engines/asylum/resources/actor.cpp
@@ -97,15 +97,11 @@ Actor::Actor(AsylumEngine *engine, ActorIndex index) : _vm(engine), _index(index
memset(&_numberString01, 0, 8);
_field_968 = 0;
_transparency = 0;
- _field_970 = 0;
- _field_974 = 0;
- _field_978 = 0;
- _actionIdx1 = 0;
- _field_980 = 0;
- _field_984 = 0;
- _field_988 = 0;
- _field_98C = 0;
- _field_990 = 0;
+ _processNewDirection = false;
+ _invertPriority = false;
+ _nextDirection = kDirectionN;
+ _nextActionIndex = 0;
+ _nextActorIndex = kActorMax;
_field_994 = 0;
_field_998 = 0;
_field_99C = 0;
@@ -190,38 +186,38 @@ void Actor::load(Common::SeekableReadStream *stream) {
for (int32 i = 0; i < 20; i++)
_distancesNSEO[i] = stream->readSint32LE();
- _actionIdx2 = stream->readSint32LE();
- _field_924 = stream->readSint32LE();
- _lastScreenUpdate = stream->readUint32LE();
- _scriptIndex = stream->readSint32LE();
- actionType = stream->readSint32LE();
- _field_934 = stream->readSint32LE();
- _field_938 = stream->readSint32LE();
- _soundResourceId = (ResourceId)stream->readSint32LE();
- _numberValue01 = stream->readSint32LE();
- _field_944 = stream->readSint32LE();
- _field_948 = stream->readSint32LE();
- _field_94C = stream->readSint32LE();
- _numberFlag01 = stream->readSint32LE();
- _numberStringWidth = stream->readSint32LE();
- _numberStringX = stream->readSint32LE();
- _numberStringY = stream->readSint32LE();
+ _actionIdx2 = stream->readSint32LE();
+ _field_924 = stream->readSint32LE();
+ _lastScreenUpdate = stream->readUint32LE();
+ _scriptIndex = stream->readSint32LE();
+ actionType = stream->readSint32LE();
+ _field_934 = stream->readSint32LE();
+ _field_938 = stream->readSint32LE();
+ _soundResourceId = (ResourceId)stream->readSint32LE();
+ _numberValue01 = stream->readSint32LE();
+ _field_944 = stream->readSint32LE();
+ _field_948 = stream->readSint32LE();
+ _field_94C = stream->readSint32LE();
+ _numberFlag01 = stream->readSint32LE();
+ _numberStringWidth = stream->readSint32LE();
+ _numberStringX = stream->readSint32LE();
+ _numberStringY = stream->readSint32LE();
stream->read(_numberString01, sizeof(_numberString01));
- _field_968 = stream->readSint32LE();
- _transparency = stream->readSint32LE();
- _field_970 = stream->readSint32LE();
- _field_974 = stream->readSint32LE();
- _field_978 = stream->readSint32LE();
- _actionIdx1 = stream->readSint32LE();
- _field_980 = stream->readSint32LE();
- _field_984 = stream->readSint32LE();
- _field_988 = stream->readSint32LE();
- _field_98C = stream->readSint32LE();
- _field_990 = stream->readSint32LE();
- _field_994 = stream->readSint32LE();
- _field_998 = stream->readSint32LE();
- _field_99C = stream->readSint32LE();
- _field_9A0 = stream->readSint32LE();
+ _field_968 = stream->readSint32LE();
+ _transparency = stream->readSint32LE();
+ _processNewDirection = (bool)stream->readSint32LE();
+ _invertPriority = (bool)stream->readSint32LE();
+ _nextDirection = (ActorDirection)stream->readSint32LE();
+ _nextActionIndex = stream->readSint32LE();
+ _nextActorIndex = stream->readSint32LE();
+ _nextPositionOffset.x = (int16)stream->readSint32LE();
+ _nextPositionOffset.y = (int16)stream->readSint32LE();
+ _nextPosition.x = (int16)stream->readSint32LE();
+ _nextPosition.y = (int16)stream->readSint32LE();
+ _field_994 = stream->readSint32LE();
+ _field_998 = stream->readSint32LE();
+ _field_99C = stream->readSint32LE();
+ _field_9A0 = stream->readSint32LE();
}
void Actor::loadData(Common::SeekableReadStream *stream) {
@@ -744,11 +740,213 @@ void Actor::updateStatus(ActorStatus actorStatus) {
//////////////////////////////////////////////////////////////////////////
void Actor::updateDirection() {
- // Called by Script::hideActor() / showActor() and process_401830()
- if(!_field_970)
+ if(!_processNewDirection)
return;
- error("[Actor::updateDirection] Not implemented");
+ Common::Point sum = _point1 + _point2;
+ if (_nextActionIndex != -1 && !getScene()->polygons()->get(getWorld()->actions[_nextActionIndex]->polygonIndex).contains(sum))
+ return;
+
+ ActorDirection direction = kDirectionN;
+ Common::Point position = sum;
+ ResourceId resourceId = kResourceNone;
+ switch (_nextDirection) {
+ default:
+ // position is unchanged
+ break;
+
+ case kDirectionN:
+ case kDirectionS:
+ position.x = _nextPosition.x + sum.x;
+ position.y = _nextPosition.y + sum.y;
+ position.y += (_nextDirection == kDirectionN ? -1 : 1) * 2 * abs(sum.y - _nextPositionOffset.y);
+
+ switch (direction) {
+ default:
+ break;
+
+ case kDirectionN:
+ direction = kDirectionS;
+ break;
+
+ case kDirectionS:
+ direction = kDirectionN;
+ break;
+
+ case kDirectionNE:
+ direction = kDirectionSE;
+ break;
+
+ case kDirectionSE:
+ direction = kDirectionNE;
+ break;
+
+ case kDirectionNO:
+ direction = kDirectionSO;
+ break;
+
+ case kDirectionSO:
+ direction = kDirectionNO;
+ break;
+ }
+ break;
+
+ case kDirectionO:
+ case kDirectionE:
+ position.x = _nextPosition.x + sum.x;
+ position.x += (_nextDirection == kDirectionO ? -1 : 1) * 2 * abs(sum.x - _nextPositionOffset.x);
+ position.y = _nextPosition.y + sum.y;
+
+ switch (direction) {
+ default:
+ break;
+
+ case kDirectionO:
+ direction = kDirectionE;
+ break;
+
+ case kDirectionE:
+ direction = kDirectionO;
+ break;
+
+ case kDirectionSO:
+ direction = kDirectionSE;
+ break;
+
+ case kDirectionNO:
+ direction = kDirectionNE;
+ break;
+
+ case kDirectionSE:
+ direction = kDirectionSO;
+ break;
+
+ case kDirectionNE:
+ direction = kDirectionNO;
+ break;
+ }
+ break;
+
+ case kDirectionNO:
+ case kDirectionSE:
+ position.x = _nextPosition.x + sum.x;
+ position.y = _nextPosition.y + sum.y;
+ position.x += (_nextDirection == kDirectionNO ? -1 : 1) * 2 * abs(sum.y - _nextPositionOffset.y);
+ position.y += (_nextDirection == kDirectionNO ? -1 : 1) * 2 * abs(sum.x - _nextPositionOffset.x);
+
+ switch (direction) {
+ default:
+ break;
+
+ case kDirectionN:
+ direction = kDirectionE;
+ break;
+
+ case kDirectionS:
+ direction = kDirectionO;
+ break;
+
+ case kDirectionO:
+ direction = kDirectionS;
+ break;
+
+ case kDirectionE:
+ direction = kDirectionN;
+ break;
+
+ case kDirectionNO:
+ direction = kDirectionSE;
+ break;
+
+ case kDirectionNE:
+ direction = kDirectionNE;
+ break;
+
+ case kDirectionSO:
+ direction = kDirectionSO;
+ break;
+
+ case kDirectionSE:
+ direction = kDirectionNO;
+ break;
+ }
+ break;
+
+ case kDirectionSO:
+ case kDirectionNE:
+ if (_nextDirection == kDirectionSO) {
+ position.x = _nextPosition.x + sum.x - 2 * abs(sum.y - _nextPositionOffset.y);
+ position.y = _nextPosition.y + sum.y + 2 * abs(sum.x - _nextPositionOffset.x);
+ } else {
+ double deltaX = sum.x * -0.56666666;
+ double deltaY = (419 - sum.y + deltaX) * 0.87613291;
+ position.x = sum.x + 2 * (_nextPositionOffset.x - deltaY);
+ position.y = sum.y + 2 * (_nextPosition.x - (sum.y + deltaX) - (deltaY * -0.56666666));
+ }
+
+ switch (direction) {
+ default:
+ break;
+
+ case kDirectionS:
+ direction = kDirectionE;
+ break;
+
+ case kDirectionN:
+ direction = kDirectionO;
+ break;
+
+ case kDirectionE:
+ direction = kDirectionS;
+ break;
+
+ case kDirectionO:
+ direction = kDirectionN;
+ break;
+
+ case kDirectionSE:
+ direction = kDirectionSE;
+ break;
+
+ case kDirectionSO:
+ direction = kDirectionNE;
+ break;
+
+ case kDirectionNE:
+ direction = kDirectionSO;
+ break;
+
+ case kDirectionNO:
+ direction = kDirectionNO;
+ break;
+ }
+ break;
+
+ case kDirection8:
+ position = _nextPosition + sum;
+ break;
+ }
+
+ // Get the next resource index offset
+ uint32 index = 0;
+ while (getWorld()->graphicResourceIds[index] != _resourceId) {
+ index++;
+
+ if (index >= 55)
+ error("[Actor::updateDirection] Invalid resource id index");
+ }
+
+ // Compute resource id and adjust frame count
+ Actor *nextActor = getScene()->getActor(_nextActorIndex);
+
+ resourceId = nextActor->getResourcesId(index - index % 5 + (direction > kDirectionS ? 8 - direction : direction));
+ nextActor->setFrameCount(GraphicResource::getFrameCount(_vm, resourceId));
+
+ // Adjust graphic resource and position
+ uint32 frameIndex = _frameIndex % nextActor->getFrameCount();
+ nextActor->setPosition(position.x, position.y, direction, frameIndex);
+ nextActor->setFrameIndex(frameIndex);
+ nextActor->setResourceId(resourceId);
}
void Actor::updateFromDirection(ActorDirection actorDirection) {
@@ -886,15 +1084,13 @@ Common::String Actor::toString(bool shortString) {
//////////////////////////////////////////////////////////////////////////
void Actor::clearFields() {
- _field_970 = 0;
- _field_974 = 0;
- _field_978 = 0;
- _actionIdx1 = 0;
- _field_980 = 0;
- _field_984 = 0;
- _field_988 = 0;
- _field_98C = 0;
- _field_990 = 0;
+ _processNewDirection = false;
+ _invertPriority = false;
+ _nextDirection = kDirectionN;
+ _nextActionIndex = 0;
+ _nextActorIndex = 0;
+ _nextPositionOffset = Common::Point(0, 0);
+ _nextPosition = Common::Point(0, 0);
_field_994 = 0;
_field_998 = 0;
_field_99C = 0;
@@ -1162,90 +1358,85 @@ void Actor::processStatus(int32 actorX, int32 actorY, bool doSpeech) {
}
}
-void Actor::process_401830(int32 field980, int32 actionAreaId, int32 field978, int field98C, int32 field990, int32 field974, int32 field984, int32 field988) {
- _field_980 = field980;
- _actionIdx1 = (actionAreaId != -1) ? getWorld()->getActionAreaIndexById(actionAreaId) : -1;
- _field_978 = field978;
- _field_98C = field98C;
- _field_990 = field990;
- _field_974 = field974;
+void Actor::processNext(ActorIndex nextActor, int32 actionAreaId, ActorDirection nextDirection, const Common::Point &nextPosition, bool invertPriority, const Common::Point &nextPositionOffset) {
+ _nextActorIndex = nextActor;
+ _nextActionIndex = (actionAreaId != -1) ? getWorld()->getActionAreaIndexById(actionAreaId) : -1;
+ _nextDirection = nextDirection;
+ _nextPosition = nextPosition;
+ _invertPriority = invertPriority;
- int field_984 = 0;
- int field_988 = 0;
+ Common::Point offset;
if (actionAreaId != -1) {
- if (field984) {
- field_984 = field984;
- field_988 = field988;
+ if (nextPositionOffset.x) {
+ offset = nextPositionOffset;
} else {
- Polygon polygon = getScene()->polygons()->get(_actionIdx1);
+ Polygon polygon = getScene()->polygons()->get(_nextActionIndex);
- field_984 = polygon.points[0].x;
- field_988 = polygon.points[0].y;
+ offset = polygon.points[0];
// Iterate through points
if (polygon.count() > 1) {
for (uint i = 1; i < polygon.count() - 1; i++) {
Common::Point point = polygon.points[i];
- switch (field978) {
+ switch (nextDirection) {
default:
break;
- case 0:
- if (field_988 > point.y)
- field_988 = point.y;
+ case kDirectionN:
+ if (offset.y > point.y)
+ offset.y = point.y;
break;
- case 1:
- if (field_988 > point.y)
- field_988 = point.y;
+ case kDirectionNO:
+ if (offset.y > point.y)
+ offset.y = point.y;
- if (field_984 > point.x)
- field_984 = point.x;
+ if (offset.x > point.x)
+ offset.x = point.x;
break;
- case 2:
- if (field_984 > point.x)
- field_984 = point.x;
+ case kDirectionO:
+ if (offset.x > point.x)
+ offset.x = point.x;
break;
- case 3:
- if (field_988 < point.y)
- field_988 = point.y;
+ case kDirectionSO:
+ if (offset.y < point.y)
+ offset.y = point.y;
- if (field_984 > point.x)
- field_984 = point.x;
+ if (offset.x > point.x)
+ offset.x = point.x;
break;
- case 4:
- if (field_988 < point.y)
- field_988 = point.y;
+ case kDirectionS:
+ if (offset.y < point.y)
+ offset.y = point.y;
break;
- case 5:
- if (field_988 < point.y)
- field_988 = point.y;
+ case kDirectionSE:
+ if (offset.y < point.y)
+ offset.y = point.y;
- if (field_984 < point.x)
- field_984 = point.x;
+ if (offset.x < point.x)
+ offset.x = point.x;
break;
- case 6:
- if (field_984 < point.x)
- field_984 = point.x;
+ case kDirectionE:
+ if (offset.x < point.x)
+ offset.x = point.x;
break;
- case 7:
- if (field_988 > point.y)
- field_988 = point.y;
+ case kDirectionNE:
+ if (offset.y > point.y)
+ offset.y = point.y;
- if (field_984 < point.x)
- field_984 = point.x;
+ if (offset.x < point.x)
+ offset.x = point.x;
break;
- case 8:
- field_984 = 0;
- field_988 = 0;
+ case kDirection8:
+ offset = Common::Point(0, 0);
break;
}
}
@@ -1253,17 +1444,17 @@ void Actor::process_401830(int32 field980, int32 actionAreaId, int32 field978, i
}
}
- _field_984 = field_984;
- _field_988 = field_988;
+ _nextPositionOffset = offset;
double cosValue = cos(0.523598775) * 1000.0;
double sinValue = sin(0.523598775) * 1000.0;
- _field_994 = field_984 - cosValue;
- _field_998 = sinValue + field_988;
- _field_99C = field_984 + cosValue;
- _field_9A0 = field_988 - sinValue;
- _field_970 = 1;
+ _field_994 = offset.x - cosValue;
+ _field_998 = offset.y + sinValue;
+ _field_99C = offset.x + cosValue;
+ _field_9A0 = offset.y - sinValue;
+
+ _processNewDirection = true;
updateDirection();
}
diff --git a/engines/asylum/resources/actor.h b/engines/asylum/resources/actor.h
index 3032023a58..14b65c244d 100644
--- a/engines/asylum/resources/actor.h
+++ b/engines/asylum/resources/actor.h
@@ -82,6 +82,7 @@ public:
uint32 getFrameCount() { return _frameCount; }
uint32 getFrameIndex() { return _frameIndex; }
char *getName() { return (char *)&_name; }
+ ActorIndex getNextActorIndex() { return _nextActorIndex; }
int32 getNumberValue01() { return _numberValue01; }
Common::Point *getPoint() { return &_point; }
Common::Point *getPoint1() { return &_point1; }
@@ -91,6 +92,7 @@ public:
ResourceId getResourceId() { return _resourceId; }
ResourceId getResourcesId(uint32 index) { return _graphicResourceIds[index]; }
int32 getScriptIndex() { return _scriptIndex; }
+ bool shouldInvertPriority() { return _invertPriority; }
ResourceId getSoundResourceId() { return _soundResourceId; }
ActorStatus getStatus() { return _status; }
@@ -99,8 +101,6 @@ public:
int32 getField944() { return _field_944; }
int32 getField948() { return _field_948; }
int32 getField94C() { return _field_94C; }
- int32 getField974() { return _field_974; }
- int32 getField980() { return _field_980; }
/////////////////////////////////////////////////////////////////////////
// Data
@@ -184,7 +184,7 @@ public:
/////////////////////////////////////////////////////////////////////////
/**
- * Updates the actor direction.
+ * Updates the actor direction, using the values set by script
*/
void updateDirection();
@@ -255,7 +255,7 @@ public:
// Unknown methods
bool process(const Common::Point &point);
void processStatus(int32 actorX, int32 actorY, bool doSpeech);
- void process_401830(int32 field980, int32 actionAreaId, int32 field978, int field98C, int32 field990, int32 field974, int32 field984, int32 field988);
+ void processNext(ActorIndex nextActor, int32 actionAreaId, ActorDirection nextDirection, const Common::Point &nextPosition, bool invertPriority, const Common::Point &nextPositionOffset);
bool process_4069B0(int32 *x, int32 *y);
bool canMove(Common::Point *point, ActorDirection direction, uint32 count, bool hasDelta);
void move(ActorDirection dir, uint32 distance);
@@ -368,15 +368,13 @@ private:
char _numberString01[8];
int32 _field_968;
int32 _transparency;
- int32 _field_970;
- int32 _field_974;
- int32 _field_978;
- int32 _actionIdx1;
- int32 _field_980;
- int32 _field_984;
- int32 _field_988;
- int32 _field_98C;
- int32 _field_990;
+ bool _processNewDirection;
+ bool _invertPriority;
+ ActorDirection _nextDirection;
+ int32 _nextActionIndex;
+ ActorIndex _nextActorIndex;
+ Common::Point _nextPositionOffset;
+ Common::Point _nextPosition;
int32 _field_994;
int32 _field_998;
int32 _field_99C;
diff --git a/engines/asylum/resources/script.cpp b/engines/asylum/resources/script.cpp
index 89523bf907..11f8ae29b5 100644
--- a/engines/asylum/resources/script.cpp
+++ b/engines/asylum/resources/script.cpp
@@ -1764,7 +1764,7 @@ END_OPCODE
IMPLEMENT_OPCODE(ProcessActor)
Actor *actor = getScene()->getActor(cmd->param1);
- actor->process_401830(cmd->param2, cmd->param3, cmd->param4, cmd->param5, cmd->param6, cmd->param7, cmd->param8, cmd->param9);
+ actor->processNext(cmd->param2, cmd->param3, (ActorDirection)cmd->param4, Common::Point(cmd->param5, cmd->param6), cmd->param7, Common::Point(cmd->param8, cmd->param9));
END_OPCODE
//////////////////////////////////////////////////////////////////////////
diff --git a/engines/asylum/views/scene.cpp b/engines/asylum/views/scene.cpp
index 62fe64f620..8863a4851c 100644
--- a/engines/asylum/views/scene.cpp
+++ b/engines/asylum/views/scene.cpp
@@ -2568,8 +2568,8 @@ void Scene::processUpdateList() {
}
}
- if (actor->getField974())
- getActor(actor->getField980())->setPriority(-actor->getPriority());
+ if (actor->shouldInvertPriority())
+ getActor(actor->getNextActorIndex())->setPriority(-actor->getPriority());
}
} // end processing actors
Commit: 5ca35ddd2f0553f510ffe2aec91571d89fb5693d
https://github.com/scummvm/scummvm/commit/5ca35ddd2f0553f510ffe2aec91571d89fb5693d
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:37:06+02:00
Commit Message:
ASYLUM: Fix playing of intro speech (wait until the sound is finished before showing the scene)
Changed paths:
engines/asylum/asylum.cpp
diff --git a/engines/asylum/asylum.cpp b/engines/asylum/asylum.cpp
index 99d5a75e90..2e40586625 100644
--- a/engines/asylum/asylum.cpp
+++ b/engines/asylum/asylum.cpp
@@ -203,7 +203,6 @@ void AsylumEngine::startGame(ResourcePackId sceneId, StartGameType type) {
_handler = _scene;
// Original checks for the current cd (we have all data files on disc, so this is not needed)
-
switch (type) {
default:
error("[AsylumEngine::startGame] Invalid start game type!");
@@ -280,8 +279,8 @@ void AsylumEngine::playIntro() {
} else {
_sound->playMusic(kResourceNone, 0);
- // TODO convert to new event handling
_video->play(1, _menu);
+ // FIXME: the cursor is still shown after the video ends
if (_scene->worldstats()->musicCurrentResourceIndex != kMusicStopped)
_sound->playMusic(MAKE_RESOURCE(kResourcePackMusic, _scene->worldstats()->musicCurrentResourceIndex));
@@ -291,22 +290,18 @@ void AsylumEngine::playIntro() {
setGameFlag(kGameFlag4);
setGameFlag(kGameFlag12);
- // Play the intro sound sample (the screen is blacked out, you hear an alarm sounding and men talking about.
+ // Play the intro speech: it is played after the intro video over a black background,
+ // and the game is "locked" until the speech is completed.
ResourceId introSpeech = MAKE_RESOURCE(kResourcePackSound, 7);
_sound->playSound(introSpeech);
- // TODO In the original game, the intro speech is played after the intro video. The speech is played over a black
- // background, and the game is locked until the speech is completed.
- // The implementation below is here is what was originally implemented by DreamForge. This code will lock up the
- // application if used as is as no events are being processed until the sound thread completes.
- // A much cleaner implementation can be found in commit f6b2ed3be51b738c962608e06d10a665e3abfb82 (svn298), but
- // needs to be adapted to the new event code.
- /*
- if (_sound->isPlaying(introSpeech)) {
- while (_sound->isPlaying(introSpeech))
- ;
- }
- */
+ do {
+ // Poll events (this ensure we don't freeze the screen)
+ Common::Event ev;
+ _eventMan->pollEvent(ev);
+
+ } while (_sound->isPlaying(introSpeech));
+
}
_introPlayed = true;
Commit: 015c1cfb92c3f17a2dd8242f844e3dd11f65c5a8
https://github.com/scummvm/scummvm/commit/015c1cfb92c3f17a2dd8242f844e3dd11f65c5a8
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:37:06+02:00
Commit Message:
ASYLUM: Fix valgrind problems reported by eriktorbjorn
- malloc/free problem in screen.cpp
- uninitialized variables (screenUpdateCount and lastScreenUpdate) usage in actor.cpp
Changed paths:
engines/asylum/asylum.cpp
engines/asylum/system/screen.cpp
diff --git a/engines/asylum/asylum.cpp b/engines/asylum/asylum.cpp
index 2e40586625..cba06da43a 100644
--- a/engines/asylum/asylum.cpp
+++ b/engines/asylum/asylum.cpp
@@ -81,6 +81,9 @@ AsylumEngine::AsylumEngine(OSystem *system, const ADGameDescription *gd) : Engin
_introPlayed = false;
_tickOffset = 0;
+ screenUpdateCount = 0;
+ lastScreenUpdate = 0;
+
// Debug
_delayedSceneIndex = kResourcePackInvalid;
_delayedVideoIndex = -1;
diff --git a/engines/asylum/system/screen.cpp b/engines/asylum/system/screen.cpp
index e38733266a..86701c0fb8 100644
--- a/engines/asylum/system/screen.cpp
+++ b/engines/asylum/system/screen.cpp
@@ -712,7 +712,7 @@ void Screen::blitMasked(GraphicFrame *frame, Common::Rect *source, byte *maskDat
_backBuffer.pitch - source->width());
// cleanup
- delete mirroredBuffer;
+ free(mirroredBuffer);
// Draw debug rects
if (g_debugDrawRects)
@@ -818,7 +818,7 @@ void Screen::blitMasked(GraphicFrame *frame, Common::Rect *source, byte *maskDat
}
// Cleanup
- delete mirroredBuffer;
+ free(mirroredBuffer);
}
// DEBUG: Draw the mask (zoomed)
Commit: 901f032b775935c4c43065324eb26dbf793a738b
https://github.com/scummvm/scummvm/commit/901f032b775935c4c43065324eb26dbf793a738b
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:37:07+02:00
Commit Message:
ASYLUM: Fix debug drawing of zoomed mask
Changed paths:
engines/asylum/system/screen.cpp
diff --git a/engines/asylum/system/screen.cpp b/engines/asylum/system/screen.cpp
index 86701c0fb8..ae1442bfeb 100644
--- a/engines/asylum/system/screen.cpp
+++ b/engines/asylum/system/screen.cpp
@@ -675,6 +675,7 @@ void Screen::blitMasked(GraphicFrame *frame, Common::Rect *source, byte *maskDat
byte *frameBuffer = (byte *)frame->surface.pixels;
byte *mirroredBuffer = NULL;
int16 frameRight = frame->surface.pitch;
+ int16 maskHeight = sourceMask->height(); // for debugging only
byte zoom = abs(sourceMask->left) & 7;
// Prepare temporary source buffer if needed
@@ -814,7 +815,7 @@ void Screen::blitMasked(GraphicFrame *frame, Common::Rect *source, byte *maskDat
// Draw debug rects
if (g_debugDrawRects) {
_backBuffer.frameRect(*destination, 0x128);
- drawZoomedMask(maskData, 20, maskWidth / 8, maskWidth);
+ drawZoomedMask(maskData, maskHeight / 8, maskWidth / 8, maskWidth);
}
// Cleanup
Commit: 6a31a7406d7feea9d7cfb146956ecd6ad9cfbb5f
https://github.com/scummvm/scummvm/commit/6a31a7406d7feea9d7cfb146956ecd6ad9cfbb5f
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:37:07+02:00
Commit Message:
ASYLUM: Add a set of functions to pass a GraphicResource* directly to Screen::draw()
This makes the drawing of text a lot faster since we don't have to decode
the font resource (and read each frame) for every character.
Changed paths:
engines/asylum/system/screen.cpp
engines/asylum/system/screen.h
engines/asylum/system/text.cpp
diff --git a/engines/asylum/system/screen.cpp b/engines/asylum/system/screen.cpp
index ae1442bfeb..292520e30b 100644
--- a/engines/asylum/system/screen.cpp
+++ b/engines/asylum/system/screen.cpp
@@ -81,6 +81,26 @@ void Screen::draw(ResourceId resourceId, uint32 frameIndex, const Common::Point
void Screen::draw(ResourceId resourceId, uint32 frameIndex, const Common::Point &source, DrawFlags flags, ResourceId resourceIdDestination, const Common::Point &destination, bool colorKey) {
// Get the frame to draw
GraphicResource *resource = new GraphicResource(_vm, resourceId);
+
+ draw(resource, frameIndex, source, flags, resourceIdDestination, destination, colorKey);
+
+ delete resource;
+}
+
+void Screen::draw(GraphicResource *resource, uint32 frameIndex, const Common::Point &source, DrawFlags flags, bool colorKey) {
+ draw(resource, frameIndex, source, flags, kResourceNone, Common::Point(0, 0), colorKey);
+}
+
+void Screen::draw(GraphicResource *resource, uint32 frameIndex, const Common::Point &source, DrawFlags flags, int32 transTableNum) {
+ byte *index = _transTable;
+ selectTransTable(transTableNum);
+
+ draw(resource, frameIndex, source, (DrawFlags)(flags | 0x90000000));
+
+ _transTable = index;
+}
+
+void Screen::draw(GraphicResource *resource, uint32 frameIndex, const Common::Point &source, DrawFlags flags, ResourceId resourceIdDestination, const Common::Point &destination, bool colorKey) {
GraphicFrame *frame = resource->getFrame(frameIndex);
ResourceEntry *resourceMask = NULL;
@@ -147,8 +167,6 @@ void Screen::draw(ResourceId resourceId, uint32 frameIndex, const Common::Point
blitMasked(frame, &src, resourceMask->data + 8, &srcMask, &destMask, resourceMask->getData(4), &dest, flags);
else
blit(frame, &src, &dest, flags);
-
- delete resource;
}
//////////////////////////////////////////////////////////////////////////
diff --git a/engines/asylum/system/screen.h b/engines/asylum/system/screen.h
index 3be04b2f77..b726d22fef 100644
--- a/engines/asylum/system/screen.h
+++ b/engines/asylum/system/screen.h
@@ -76,7 +76,9 @@ public:
// Drawing
void draw(ResourceId resourceId);
void draw(ResourceId resourceId, uint32 frameIndex, const Common::Point &source, DrawFlags flags = kDrawFlagNone, bool colorKey = true);
+ void draw(GraphicResource *resource, uint32 frameIndex, const Common::Point &source, DrawFlags flags= kDrawFlagNone, bool colorKey = true);
void draw(ResourceId resourceId, uint32 frameIndex, const Common::Point &source, DrawFlags flags, int32 transTableNum);
+ void draw(GraphicResource *resource, uint32 frameIndex, const Common::Point &source, DrawFlags flags, int32 transTableNum);
void draw(ResourceId resourceId, uint32 frameIndex, const Common::Point &source, DrawFlags flags, ResourceId resourceId2, const Common::Point &destination, bool colorKey = true);
// Misc
@@ -149,6 +151,8 @@ private:
// Misc
void clip(Common::Rect *source, Common::Rect *destination, int32 flags);
+ void draw(GraphicResource *resource, uint32 frameIndex, const Common::Point &source, DrawFlags flags, ResourceId resourceId2, const Common::Point &destination, bool colorKey = true);
+
// Screen blitting
void blit(GraphicFrame *frame, Common::Rect *source, Common::Rect *destination, int32 flags);
void blitMasked(GraphicFrame *frame, Common::Rect *source, byte *maskData, Common::Rect *sourceMask, Common::Rect *destMask, int maskWidth, Common::Rect *destination, int32 flags);
diff --git a/engines/asylum/system/text.cpp b/engines/asylum/system/text.cpp
index 2efba27656..e6172fca84 100644
--- a/engines/asylum/system/text.cpp
+++ b/engines/asylum/system/text.cpp
@@ -124,9 +124,9 @@ void Text::drawChar(char character) {
error("[Text::drawChar] font resource hasn't been loaded yet!");
if (_transTableNum) {
- getScreen()->draw(_fontResource->getResourceId(), (uint8)character, _position, kDrawFlagNone, _transTableNum);
+ getScreen()->draw(_fontResource, (uint8)character, _position, kDrawFlagNone, _transTableNum);
} else {
- getScreen()->draw(_fontResource->getResourceId(), (uint8)character, _position);
+ getScreen()->draw(_fontResource, (uint8)character, _position);
}
GraphicFrame *fontLetter = _fontResource->getFrame((uint8)character);
Commit: 55523032cebfb1fcc37270170e0390e00c59b140
https://github.com/scummvm/scummvm/commit/55523032cebfb1fcc37270170e0390e00c59b140
Author: Alexander (alex220486 at gmail.com)
Date: 2021-05-17T15:37:07+02:00
Commit Message:
ASYLUM: Implement Hive control puzzle
Changed paths:
engines/asylum/puzzles/hivecontrol.cpp
engines/asylum/puzzles/hivecontrol.h
diff --git a/engines/asylum/puzzles/hivecontrol.cpp b/engines/asylum/puzzles/hivecontrol.cpp
index b9acac27b3..87a712666d 100644
--- a/engines/asylum/puzzles/hivecontrol.cpp
+++ b/engines/asylum/puzzles/hivecontrol.cpp
@@ -34,6 +34,35 @@
namespace Asylum {
+const Control puzzleHiveControlIntToControl[] = {
+ kControlWingsButton1,
+ kControlWingsButton2,
+ kControlWingsButton3,
+ kControlReset,
+ kControlWheelLeft,
+ kControlWheelRight,
+ kControlButtonRight,
+ kControlButtonLeft,
+ kControlGlyph1,
+ kControlGlyph2,
+ kControlGlyph3,
+ kControlGlyph4,
+ kControlGlyph5,
+ kControlGlyph6
+};
+
+bool PuzzleHiveControl::hitTest1(uint32 resourceId, Common::Point point, Common::Point location) {
+ GraphicResource resource(_vm);
+ resource.load(getWorld()->graphicResourceIds[resourceId]);
+ GraphicFrame *frame = resource.getFrame(0);
+ Common::Point point1(point.x - location.x, point.y - location.y);
+
+ if (!frame->getRect().contains(point1))
+ return false;
+ else
+ return *((byte *)frame->surface.pixels + point1.x + frame->surface.pitch * point1.y) != 0;
+}
+
PuzzleHiveControl::PuzzleHiveControl(AsylumEngine *engine) : Puzzle(engine) {
_rectIndex = 0;
_soundVolume = 0;
@@ -41,19 +70,54 @@ PuzzleHiveControl::PuzzleHiveControl(AsylumEngine *engine) : Puzzle(engine) {
_data_457260 = 0;
_data_457264 = 0;
+
+ _prevLeverPosition = 3;
+ _resetFlag = false;
+ memset(&_frameIndexes, 0, sizeof(_frameIndexes));
+ reset();
}
PuzzleHiveControl::~PuzzleHiveControl() {
}
+void PuzzleHiveControl::reset() {
+ _leverPosition = 3;
+ _leverDelta = 0;
+ _currentControl = kControlNone;
+ _colorL = _colorR = 0;
+ _frameIndexOffset = 0;
+
+ memset(&_glyphFlags, false, sizeof(_glyphFlags));
+ memset(&_wingsState, false, sizeof(_wingsState));
+
+ _frameIndexes[kElementSwirlRim] = 0;
+ if (_leverPosition != _prevLeverPosition) {
+ _leverDelta = abs(_leverPosition - _prevLeverPosition) * 16 / 5;
+ _currentControl = kControlGlyph4;
+ }
+}
+
//////////////////////////////////////////////////////////////////////////
// Event Handling
//////////////////////////////////////////////////////////////////////////
-bool PuzzleHiveControl::init(const AsylumEvent &evt) {
- error("[PuzzleHiveControl::init] Not implemented!");
+bool PuzzleHiveControl::init(const AsylumEvent &evt) {
+ _controlPoints[kControlWingsButton1] = Common::Point(338, 139);
+ _controlPoints[kControlWingsButton2] = Common::Point(376, 151);
+ _controlPoints[kControlWingsButton3] = Common::Point(403, 162);
+ _controlPoints[kControlReset] = Common::Point(219, 86);
+ _controlPoints[kControlWheelRight] = Common::Point(204, 263);
+ _controlPoints[kControlWheelLeft] = Common::Point(164, 310);
+ _controlPoints[kControlButtonLeft] = Common::Point(320, 375);
+ _controlPoints[kControlButtonRight] = Common::Point(363, 337);
+ _controlPoints[kControlGlyph1] = Common::Point(102, 201);
+ _controlPoints[kControlGlyph2] = Common::Point(101, 171);
+ _controlPoints[kControlGlyph3] = Common::Point(108, 140);
+ _controlPoints[kControlGlyph4] = Common::Point(126, 111);
+ _controlPoints[kControlGlyph5] = Common::Point(140, 85);
+ _controlPoints[kControlGlyph6] = Common::Point(161, 54);
_rectIndex = -2;
- updateCursor();
+ _frameIndexes[kElementLever] = (5 - _leverPosition) * (GraphicResource::getFrameCount(_vm, getWorld()->graphicResourceIds[kElementLever]) - 1) / 5;
getScreen()->setPalette(getWorld()->graphicResourceIds[29]);
getScreen()->setGammaLevel(getWorld()->graphicResourceIds[29], 0);
@@ -69,7 +133,7 @@ bool PuzzleHiveControl::init(const AsylumEvent &evt) {
return true;
}
-bool PuzzleHiveControl::update(const AsylumEvent &evt) {
+bool PuzzleHiveControl::update(const AsylumEvent &evt) {
updateCursor();
updateScreen();
@@ -78,7 +142,7 @@ bool PuzzleHiveControl::update(const AsylumEvent &evt) {
if (_counter) {
if (_counter < 30 || getSound()->isPlaying(getWorld()->graphicResourceIds[83])) {
- ++ _counter;
+ ++_counter;
} else {
mouseRightDown(evt);
getCursor()->show();
@@ -89,10 +153,125 @@ bool PuzzleHiveControl::update(const AsylumEvent &evt) {
}
bool PuzzleHiveControl::mouseLeftDown(const AsylumEvent &evt) {
- error("[PuzzleHiveControl::mouseLeftDown] Not implemented!");
+ if (_currentControl != kControlNone)
+ return true;
+
+ _currentControl = findControl();
+ switch (_currentControl) {
+ case kControlNone:
+ break;
+
+ case kControlWingsButton1:
+ getCursor()->hide();
+ getSound()->playSound(getWorld()->graphicResourceIds[81], false, Config.sfxVolume - 10);
+ if (_wingsState[1] != _wingsState[2]) {
+ if (_wingsState[0])
+ --_frameIndexOffset;
+ else
+ ++_frameIndexOffset;
+ }
+ _frameIndexOffset += _wingsState[0] ? -1 : 1;
+ _wingsState[0] = !_wingsState[0];
+ _frameIndexes[kElementLensLeft] = _colorL * 8 + _frameIndexOffset;
+ _frameIndexes[kElementLensRight] = _colorR * 8 + _frameIndexOffset;
+ break;
+
+ case kControlWingsButton2:
+ getCursor()->hide();
+ getSound()->playSound(getWorld()->graphicResourceIds[81], false, Config.sfxVolume - 10);
+ if (_wingsState[0] != _wingsState[2]) {
+ if (_wingsState[1])
+ --_frameIndexOffset;
+ else
+ ++_frameIndexOffset;
+ }
+ _frameIndexOffset += _wingsState[1] ? -2 : 2;
+ _wingsState[1] = !_wingsState[1];
+ _frameIndexes[kElementLensLeft] = _colorL * 8 + _frameIndexOffset;
+ _frameIndexes[kElementLensRight] = _colorR * 8 + _frameIndexOffset;
+ break;
+
+ case kControlWingsButton3:
+ getCursor()->hide();
+ getSound()->playSound(getWorld()->graphicResourceIds[81], false, Config.sfxVolume - 10);
+ if (_wingsState[0] != _wingsState[1]) {
+ if (_wingsState[2])
+ --_frameIndexOffset;
+ else
+ ++_frameIndexOffset;
+ }
+ _frameIndexOffset += _wingsState[2] ? -3 : 3;
+ _wingsState[2] = !_wingsState[2];
+ _frameIndexes[kElementLensLeft] = _colorL * 8 + _frameIndexOffset;
+ _frameIndexes[kElementLensRight] = _colorR * 8 + _frameIndexOffset;
+ break;
+
+ case kControlReset:
+ getCursor()->hide();
+ getSound()->playSound(getWorld()->graphicResourceIds[78], false, Config.sfxVolume - 10);
+ getSound()->playSound(getWorld()->graphicResourceIds[79], false, Config.sfxVolume - 10);
+ _resetFlag = true;
+ reset();
+ break;
+
+ case kControlWheelLeft:
+ getCursor()->hide();
+ getSound()->playSound(getWorld()->graphicResourceIds[80], false, Config.sfxVolume - 10);
+ _colorL = (_colorL + 1) % 3;
+ break;
+
+ case kControlWheelRight:
+ getCursor()->hide();
+ getSound()->playSound(getWorld()->graphicResourceIds[80], false, Config.sfxVolume - 10);
+ _colorR = (_colorR + 1) % 3;
+ break;
+
+ case kControlButtonLeft:
+ getCursor()->hide();
+ getSound()->playSound(getWorld()->graphicResourceIds[77], false, Config.sfxVolume - 10);
+ if (!_glyphFlags[0][_leverPosition]) {
+ _glyphFlags[0][_leverPosition] = puzzleHiveControlHieroglyphs[0][_leverPosition] == _frameIndexes[kElementLensLeft];
+ if (_glyphFlags[0][_leverPosition]) {
+ getSound()->playSound(getWorld()->graphicResourceIds[83], false, Config.sfxVolume - 10);
+ ++_frameIndexes[kElementSwirlRim];
+ //if (_frameIndexes[kElementSwirlRim] == 12)
+ // ...
+ }
+ }
+ break;
+
+ case kControlButtonRight:
+ getCursor()->hide();
+ getSound()->playSound(getWorld()->graphicResourceIds[77], false, Config.sfxVolume - 10);
+ if (!_glyphFlags[1][_leverPosition]) {
+ _glyphFlags[1][_leverPosition] = puzzleHiveControlHieroglyphs[1][_leverPosition] == _frameIndexes[kElementLensRight];
+ if (_glyphFlags[1][_leverPosition]) {
+ getSound()->playSound(getWorld()->graphicResourceIds[83], false, Config.sfxVolume - 10);
+ ++_frameIndexes[kElementSwirlRim];
+ //if (_frameIndexes[kElementSwirlRim] == 12)
+ // ...
+ }
+ }
+ break;
+
+ case kControlGlyph1:
+ case kControlGlyph2:
+ case kControlGlyph3:
+ case kControlGlyph4:
+ case kControlGlyph5:
+ case kControlGlyph6:
+ _leverPosition = _currentControl - 49;
+ _leverDelta = abs(_leverPosition - _prevLeverPosition) * (GraphicResource::getFrameCount(_vm, getWorld()->graphicResourceIds[kElementLever]) - 1) / 5;
+ if (_leverDelta)
+ getSound()->playSound(getWorld()->graphicResourceIds[76], false, Config.sfxVolume - 10);
+ }
+
+ return true;
}
bool PuzzleHiveControl::mouseRightDown(const AsylumEvent &evt) {
+ reset();
+
getSound()->stop(getWorld()->graphicResourceIds[73]);
getSound()->stop(getWorld()->graphicResourceIds[74]);
@@ -109,7 +288,7 @@ bool PuzzleHiveControl::mouseRightDown(const AsylumEvent &evt) {
// Helpers
//////////////////////////////////////////////////////////////////////////
void PuzzleHiveControl::updateCursor() {
- int32 index = findRect();
+ int32 index = findControl();
if (_rectIndex == index)
return;
@@ -121,16 +300,149 @@ void PuzzleHiveControl::updateCursor() {
getCursor()->set(getWorld()->graphicResourceIds[30], -1);
}
-int32 PuzzleHiveControl::findRect() {
- error("[PuzzleHiveControl::findRect] Not implemented!");
+Control PuzzleHiveControl::findControl() {
+ for (uint32 i = 0; i < ARRAYSIZE(puzzleHiveControlIntToControl); ++i)
+ if (hitTest1(puzzleHiveControlIntToControl[i], getCursor()->position(), _controlPoints[puzzleHiveControlIntToControl[i]]))
+ return puzzleHiveControlIntToControl[i];
+
+ return kControlNone;
}
void PuzzleHiveControl::updateScreen() {
- error("[PuzzleHiveControl::updateScreen] Not implemented!");
+ getScreen()->clear();
+ getScreen()->clearGraphicsInQueue();
+ getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[28], 0, Common::Point(0, 0), kDrawFlagNone, 0, 3);
+
+ switch (_currentControl) {
+ case kControlNone:
+ break;
+ case kControlGlyph1:
+ case kControlGlyph2:
+ case kControlGlyph3:
+ case kControlGlyph4:
+ case kControlGlyph5:
+ case kControlGlyph6:
+ if (_leverDelta) {
+ if (_leverPosition > _prevLeverPosition)
+ --_frameIndexes[kElementLever];
+ else
+ ++_frameIndexes[kElementLever];
+ --_leverDelta;
+ if (_leverDelta == 0) {
+ _prevLeverPosition = _leverPosition;
+ _currentControl = kControlNone;
+ }
+ } else
+ _currentControl = kControlNone;
+ break;
+ default:
+ _frameIndexes[_currentControl] = (_frameIndexes[_currentControl] + 1) % GraphicResource::getFrameCount(_vm, getWorld()->graphicResourceIds[_currentControl]);
+ if (_frameIndexes[_currentControl] == 0) {
+ getCursor()->show();
+ if (_currentControl == kControlWheelLeft || _currentControl == kControlWheelRight) {
+ getSound()->playSound(getWorld()->graphicResourceIds[75], false, Config.sfxVolume - 10);
+ if (_currentControl == kControlWheelLeft)
+ _frameIndexes[kElementLensLeft] = (_frameIndexes[kElementLensLeft] + 8) % GraphicResource::getFrameCount(_vm, getWorld()->graphicResourceIds[kElementLensLeft]);
+ else
+ _frameIndexes[kElementLensRight] = (_frameIndexes[kElementLensRight] + 8) % GraphicResource::getFrameCount(_vm, getWorld()->graphicResourceIds[kElementLensRight]);
+ }
+ _currentControl = kControlNone;
+ }
+ }
+
+ getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[kElementSwirl], _frameIndexes[kElementSwirl], Common::Point(486, 291), kDrawFlagNone, 0, 2);
+ _frameIndexes[kElementSwirl] = (_frameIndexes[kElementSwirl] + 1) % GraphicResource::getFrameCount(_vm, getWorld()->graphicResourceIds[kElementSwirl]);
+
+ if (_resetFlag) {
+ getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[kElementResetDynamic], _frameIndexes[kElementResetDynamic], Common::Point(211, 77), kDrawFlagNone, 0, 2);
+ _frameIndexes[kElementResetDynamic] = (_frameIndexes[kElementResetDynamic] + 1) % GraphicResource::getFrameCount(_vm, getWorld()->graphicResourceIds[kElementResetDynamic]);
+ if (_frameIndexes[kElementResetDynamic] == GraphicResource::getFrameCount(_vm, getWorld()->graphicResourceIds[kElementResetDynamic]) - 1) {
+ _resetFlag = false;
+ getCursor()->show();
+ if (!(_wingsState[0] || _wingsState[1] || _wingsState[2])) {
+ _frameIndexes[kElementLensLeft] = 0;
+ _frameIndexes[kElementLensRight] = 0;
+ }
+ }
+ } else {
+ getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[kElementFlyHead], _frameIndexes[kElementFlyHead], Common::Point(258, 86), kDrawFlagNone, 0, 2);
+ getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[kElementResetStatic], _frameIndexes[kElementResetStatic], Common::Point(232, 77), kDrawFlagNone, 0, 2);
+ _frameIndexes[kElementFlyHead] = (_frameIndexes[kElementFlyHead] + 1) % GraphicResource::getFrameCount(_vm, getWorld()->graphicResourceIds[kElementFlyHead]);
+ }
+
+ getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[kControlWingsButton1], _frameIndexes[kControlWingsButton1], _controlPoints[kControlWingsButton1], kDrawFlagNone, 0, 2);
+ getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[kControlWingsButton2], _frameIndexes[kControlWingsButton2], _controlPoints[kControlWingsButton2], kDrawFlagNone, 0, 2);
+ getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[kControlWingsButton3], _frameIndexes[kControlWingsButton3], _controlPoints[kControlWingsButton3], kDrawFlagNone, 0, 2);
+
+ getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[kElementLever], _frameIndexes[kElementLever], Common::Point(9, 40), kDrawFlagNone, 0, 2);
+ getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[kControlReset], _frameIndexes[kControlReset], _controlPoints[kControlReset], kDrawFlagNone, 0, 2);
+
+ getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[kControlWheelRight], _frameIndexes[kControlWheelRight], _controlPoints[kControlWheelRight], kDrawFlagNone, 0, 2);
+ getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[kControlWheelLeft], _frameIndexes[kControlWheelLeft], _controlPoints[kControlWheelLeft], kDrawFlagNone, 0, 2);
+
+ getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[kControlButtonLeft], _frameIndexes[kControlButtonLeft], _controlPoints[kControlButtonLeft], kDrawFlagNone, 0, 2);
+ getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[kControlButtonRight], _frameIndexes[kControlButtonRight], _controlPoints[kControlButtonRight], kDrawFlagNone, 0, 2);
+
+ getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[kElementWingLeft1], _frameIndexes[kElementWingLeft1], Common::Point(326, 162), kDrawFlagNone, 1, 1);
+ getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[kElementWingRight1], _frameIndexes[kElementWingRight1], Common::Point(374, 86), kDrawFlagNone, 1, 1);
+ getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[kElementWingLeft2], _frameIndexes[kElementWingLeft2], Common::Point(275, 186), kDrawFlagNone, 1, 1);
+ getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[kElementWingRight2], _frameIndexes[kElementWingRight2], Common::Point(419, 59), kDrawFlagNone, 1, 1);
+ getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[kElementWingLeft3], _frameIndexes[kElementWingLeft3], Common::Point(386, 196), kDrawFlagNone, 1, 1);
+ getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[kElementWingRight3], _frameIndexes[kElementWingRight3], Common::Point(433, 111), kDrawFlagNone, 1, 1);
+
+ getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[kControlGlyph1], _frameIndexes[kControlGlyph1], _controlPoints[kControlGlyph1], kDrawFlagNone, 0, 2);
+ getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[kControlGlyph2], _frameIndexes[kControlGlyph2], _controlPoints[kControlGlyph2], kDrawFlagNone, 0, 2);
+ getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[kControlGlyph3], _frameIndexes[kControlGlyph3], _controlPoints[kControlGlyph3], kDrawFlagNone, 0, 2);
+ getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[kControlGlyph4], _frameIndexes[kControlGlyph4], _controlPoints[kControlGlyph4], kDrawFlagNone, 0, 2);
+ getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[kControlGlyph5], _frameIndexes[kControlGlyph5], _controlPoints[kControlGlyph5], kDrawFlagNone, 0, 2);
+ getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[kControlGlyph6], _frameIndexes[kControlGlyph6], _controlPoints[kControlGlyph6], kDrawFlagNone, 0, 2);
+
+ bool reseted = false;
+ for (uint32 i = 0; i < 3; ++i) {
+ if (_wingsState[i]) {
+ if (_frameIndexes[kElementWingLeft1 + 2*i] != GraphicResource::getFrameCount(_vm, getWorld()->graphicResourceIds[kElementWingLeft1 + 2*i]) - 1)
+ _frameIndexes[kElementWingLeft1 + 2*i] = (_frameIndexes[kElementWingLeft1 + 2*i] + 1) % GraphicResource::getFrameCount(_vm, getWorld()->graphicResourceIds[kElementWingLeft1 + 2*i]);
+ if (_frameIndexes[kElementWingRight1 + 2*i] != GraphicResource::getFrameCount(_vm, getWorld()->graphicResourceIds[kElementWingRight1 + 2*i]) - 1)
+ _frameIndexes[kElementWingRight1 + 2*i] = (_frameIndexes[kElementWingRight1 + 2*i] + 1) % GraphicResource::getFrameCount(_vm, getWorld()->graphicResourceIds[kElementWingRight1 + 2*i]);
+ }
+ else {
+ if (_frameIndexes[kElementWingLeft1 + 2*i] > 0) {
+ --_frameIndexes[kElementWingLeft1 + 2*i];
+ if (_resetFlag && _frameIndexes[kElementWingLeft1 + 2*i] == 0 && !reseted) {
+ _frameIndexes[kElementLensLeft] = 0;
+ reseted = true;
+ }
+ }
+ if (_frameIndexes[kElementWingRight1 + 2*i ] > 0) {
+ --_frameIndexes[kElementWingRight1 + 2*i];
+ if (_resetFlag && _frameIndexes[kElementWingRight1 + 2*i] == 0 && !reseted) {
+ _frameIndexes[kElementLensRight] = 0;
+ reseted = true;
+ }
+ }
+ }
+ }
+
+ getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[kElementLensLeft], _frameIndexes[kElementLensLeft], Common::Point(305, 216), kDrawFlagNone, 0, 2);
+ getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[kElementLensRight], _frameIndexes[kElementLensRight], Common::Point(411, 65), kDrawFlagNone, 0, 2);
+
+ getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[kElementIndicator], _frameIndexes[kElementSwirlRim], Common::Point(158, 148), kDrawFlagNone, 0, 2);
+
+ for (uint32 i = 0; i < 6; ++i) {
+ if (_glyphFlags[0][i])
+ getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[58 + i], 0, Common::Point(104, 58), kDrawFlagNone, 0, 1);
+ if (_glyphFlags[1][i])
+ getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[64 + i], 0, Common::Point(133, 70), kDrawFlagNone, 0, 1);
+ }
+
+ getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[kElementSwirlRim], _frameIndexes[kElementSwirlRim], Common::Point(458, 278), kDrawFlagNone, 0, 2);
+
+ getScreen()->drawGraphicsInQueue();
+ getScreen()->copyBackBufferToScreen();
}
void PuzzleHiveControl::playSound() {
- error("[PuzzleHiveControl::playSound] Not implemented!");
+ //error("[PuzzleHiveControl::playSound] Not implemented!");
}
} // End of namespace Asylum
diff --git a/engines/asylum/puzzles/hivecontrol.h b/engines/asylum/puzzles/hivecontrol.h
index 116f1e7eef..cac3433aad 100644
--- a/engines/asylum/puzzles/hivecontrol.h
+++ b/engines/asylum/puzzles/hivecontrol.h
@@ -25,16 +25,62 @@
#include "asylum/puzzles/puzzle.h"
+#include "common/hashmap.h"
+
namespace Asylum {
class AsylumEngine;
+enum Control {
+ kControlNone = -1,
+ kControlWingsButton1 = 34,
+ kControlWingsButton2 = 35,
+ kControlWingsButton3 = 36,
+ kControlReset = 38,
+ kControlWheelLeft = 39,
+ kControlWheelRight = 40,
+ kControlButtonRight = 41,
+ kControlButtonLeft = 42,
+ kControlGlyph1 = 49,
+ kControlGlyph2 = 50,
+ kControlGlyph3 = 51,
+ kControlGlyph4 = 52,
+ kControlGlyph5 = 53,
+ kControlGlyph6 = 54
+};
+
+static const uint32 puzzleHiveControlHieroglyphs[2][6] = {
+ {5, 12, 22, 13, 20, 6},
+ {21, 4, 14, 13, 20, 6}
+};
+
class PuzzleHiveControl : public Puzzle {
public:
PuzzleHiveControl(AsylumEngine *engine);
~PuzzleHiveControl();
+ bool hitTest1(uint32 resourceId, Common::Point point, Common::Point location);
+ void reset();
+
private:
+ enum Element {
+ kElementSwirl = 31,
+ kElementFlyHead = 32,
+ kElementResetDynamic = 33,
+ kElementLever = 37,
+ kElementWingLeft1 = 43,
+ kElementWingRight1 = 44,
+ kElementWingLeft2 = 45,
+ kElementWingRight2 = 46,
+ kElementWingLeft3 = 47,
+ kElementWingRight3 = 48,
+ kElementLensLeft = 55,
+ kElementLensRight = 56,
+ kElementIndicator = 57,
+ kElementSwirlRim = 71,
+ kElementResetStatic = 72
+ };
+
int32 _soundVolume;
int32 _rectIndex;
uint32 _counter;
@@ -42,6 +88,17 @@ private:
int32 _data_457260;
int32 _data_457264;
+ uint32 _frameIndexes[73];
+ Common::HashMap<uint32, Common::Point> _controlPoints;
+
+ bool _resetFlag;
+ bool _wingsState[3];
+ bool _glyphFlags[2][6];
+ Control _currentControl;
+ uint32 _colorL, _colorR;
+ uint32 _frameIndexOffset;
+ uint32 _leverPosition, _prevLeverPosition, _leverDelta;
+
//////////////////////////////////////////////////////////////////////////
// Event Handling
//////////////////////////////////////////////////////////////////////////
@@ -54,7 +111,7 @@ private:
// Helpers
//////////////////////////////////////////////////////////////////////////
void updateCursor();
- int32 findRect();
+ Control findControl();
void updateScreen();
void playSound();
};
Commit: defb533d1e3ac88a3ae11af5404bfc919b44188f
https://github.com/scummvm/scummvm/commit/defb533d1e3ac88a3ae11af5404bfc919b44188f
Author: Alexander (alex220486 at gmail.com)
Date: 2021-05-17T15:37:07+02:00
Commit Message:
ASYLUM: Pipes puzzle: replace log(x)/log(2) with Common::intLog2(x)
Changed paths:
engines/asylum/puzzles/pipes.cpp
diff --git a/engines/asylum/puzzles/pipes.cpp b/engines/asylum/puzzles/pipes.cpp
index 3d19cc2f03..92497f8f45 100644
--- a/engines/asylum/puzzles/pipes.cpp
+++ b/engines/asylum/puzzles/pipes.cpp
@@ -32,7 +32,7 @@
#include "asylum/asylum.h"
-#include <math.h>
+#include <common/math.h>
namespace Asylum {
@@ -103,8 +103,6 @@ const Common::Point peepholePoints[] = {
const uint32 peepholeResources[] = {15, 15, 15, 15, 32, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 32, 32, 15,
15, 32, 32, 15, 15, 15, 15,15, 15, 15, 15, 32, 15, 15, 15, 15, 15, 15, 15};
-const double LOG2 = 0.6931471;
-
//////////////////////////////////////////////////////////////////////////
// Peephole
//////////////////////////////////////////////////////////////////////////
@@ -177,8 +175,8 @@ void Connector::turn() {
oldIndex[1] = 2;
}
} else {
- newIndex[0] = log((double)(newState & delta)) / LOG2;
- oldIndex[0] = log((double)(_state & delta)) / LOG2;
+ newIndex[0] = Common::intLog2(newState & delta);
+ oldIndex[0] = Common::intLog2(_state & delta);
}
for (uint32 i = 0; i < (uint32)(delta == kBinNum1111 ? 2 : 1); ++i) {
Commit: 185aedd05b34856c55fbbcf0e08e645bfa539cb2
https://github.com/scummvm/scummvm/commit/185aedd05b34856c55fbbcf0e08e645bfa539cb2
Author: Alexander (alex220486 at gmail.com)
Date: 2021-05-17T15:37:07+02:00
Commit Message:
ASYLUM: Pipes puzzle: fix lamp indicators
Changed paths:
engines/asylum/puzzles/pipes.cpp
diff --git a/engines/asylum/puzzles/pipes.cpp b/engines/asylum/puzzles/pipes.cpp
index 92497f8f45..43ed59fef6 100644
--- a/engines/asylum/puzzles/pipes.cpp
+++ b/engines/asylum/puzzles/pipes.cpp
@@ -348,9 +348,12 @@ bool PuzzlePipes::update(const AsylumEvent &evt) {
for (uint32 i = 0; i < ARRAYSIZE(_connectors); ++i)
getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[_connectorResources[_connectors[i].getState()]], 0, connectorPoints[i], kDrawFlagNone, 0, 1);
+ uint32 filled = 0;
for (uint32 i = 0; i < 4; ++i) {
if (fabs(_levelValues[i] - _previousLevels[i]) > 0.005)
_previousLevels[i] += _levelValues[i] > _previousLevels[i] ? 0.01 : -0.01;
+ else
+ ++filled;
}
getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[18], 0, Common::Point(210, 444 - uint32(_previousLevels[0] * 52)), kDrawFlagNone, 0, 3);
@@ -376,16 +379,18 @@ bool PuzzlePipes::update(const AsylumEvent &evt) {
}
// TODO: turn the fountain on
- if (_levelFlags[0])
- getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[40], 0, Common::Point(233, 416), kDrawFlagNone, 0, 1);
- else if (_levelFlags[1])
- getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[40], 0, Common::Point(299, 431), kDrawFlagNone, 0, 1);
- else if (_levelFlags[2])
- getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[40], 0, Common::Point(398, 421), kDrawFlagNone, 0, 1);
- else if (_levelFlags[3])
- getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[40], 0, Common::Point(481, 417), kDrawFlagNone, 0, 1);
- if (!_levelFlags[4])
- getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[45], 0, Common::Point(518, 108), kDrawFlagNone, 0, 2);
+ if (filled == 4) {
+ if (_levelFlags[0])
+ getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[40], 0, Common::Point(233, 416), kDrawFlagNone, 0, 1);
+ else if (_levelFlags[1])
+ getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[40], 0, Common::Point(299, 431), kDrawFlagNone, 0, 1);
+ else if (_levelFlags[2])
+ getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[40], 0, Common::Point(398, 421), kDrawFlagNone, 0, 1);
+ else if (_levelFlags[3])
+ getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[40], 0, Common::Point(481, 417), kDrawFlagNone, 0, 1);
+ if (!_levelFlags[4])
+ getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[45], 0, Common::Point(518, 108), kDrawFlagNone, 0, 2);
+ }
for (uint32 i = 0; i < _spiders.size(); ++i) {
uint32 spiderResourceId = 0;
Commit: fd3e63e95e70bdcc6bd6054fc71685706f16f272
https://github.com/scummvm/scummvm/commit/fd3e63e95e70bdcc6bd6054fc71685706f16f272
Author: Alexander (alex220486 at gmail.com)
Date: 2021-05-17T15:37:07+02:00
Commit Message:
ASYLUM: Hive machine puzzle: fix typo
Changed paths:
engines/asylum/puzzles/hivemachine.cpp
diff --git a/engines/asylum/puzzles/hivemachine.cpp b/engines/asylum/puzzles/hivemachine.cpp
index 3385229fc0..8b512e9124 100644
--- a/engines/asylum/puzzles/hivemachine.cpp
+++ b/engines/asylum/puzzles/hivemachine.cpp
@@ -190,7 +190,7 @@ bool PuzzleHiveMachine::mouseLeftDown(const AsylumEvent &evt) {
playSound();
if (_melody.size() == 6) {
- _ok = (_melody[0] == kMusicalNoteA) &&
+ _ok = (_melody[0] == kMusicalNoteB) &&
(_melody[1] == kMusicalNoteD) &&
(_melody[2] == kMusicalNoteD) &&
(_melody[3] == kMusicalNoteA) &&
Commit: 83cbf040a57d942e1276b97cef5e142ec411178a
https://github.com/scummvm/scummvm/commit/83cbf040a57d942e1276b97cef5e142ec411178a
Author: Alexander (alex220486 at gmail.com)
Date: 2021-05-17T15:37:07+02:00
Commit Message:
ASYLUM: Hive machine puzzle: add missing playSound() call and rename counters
Changed paths:
engines/asylum/puzzles/hivemachine.cpp
engines/asylum/puzzles/hivemachine.h
diff --git a/engines/asylum/puzzles/hivemachine.cpp b/engines/asylum/puzzles/hivemachine.cpp
index 8b512e9124..b2acbd8e34 100644
--- a/engines/asylum/puzzles/hivemachine.cpp
+++ b/engines/asylum/puzzles/hivemachine.cpp
@@ -52,7 +52,7 @@ const Common::Point indicatorPoints[] = {
};
PuzzleHiveMachine::PuzzleHiveMachine(AsylumEngine *engine) : Puzzle(engine) {
- _counter = _counter1 = 0;
+ _counterRed = _counterGreen = _counterKey = 0;
_rectIndex = -2;
_frameIndex = 0;
_soundingNote = kMusicalNoteNone;
@@ -181,11 +181,11 @@ bool PuzzleHiveMachine::update(const AsylumEvent &evt) {
}
bool PuzzleHiveMachine::mouseLeftDown(const AsylumEvent &evt) {
- if (_rectIndex != -1 && _counter == 0) {
+ if (_rectIndex != -1 && _counterRed == 0) {
_soundingNote = MusicalNote(_rectIndex);
_melody.push_back(_soundingNote);
_notesNumber = (_notesNumber + 1) % 7;
- _counter1 = 10;
+ _counterKey = 10;
_frameIndex1 = 0;
playSound();
@@ -198,8 +198,9 @@ bool PuzzleHiveMachine::mouseLeftDown(const AsylumEvent &evt) {
(_melody[5] == kMusicalNoteE);
if (!_ok) {
_melody.clear();
- _counter = 30;
- }
+ _counterRed = 30;
+ } else
+ _counterGreen = 10;
}
}
@@ -245,16 +246,20 @@ void PuzzleHiveMachine::updateScreen() {
getScreen()->clearGraphicsInQueue();
getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[8], 0, Common::Point(0, 0), kDrawFlagNone, 0, 2);
- if (_ok)
+ if (_ok) {
+ if (_counterGreen > 1)
+ --_counterGreen;
+ else if (_counterGreen-- == 1)
+ getSound()->playSound(getWorld()->graphicResourceIds[86], false, Config.sfxVolume - 10);
getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[11], 0, Common::Point(271, 369), kDrawFlagNone, 0, 1);
- else if (_counter) {
- if (_counter == 1)
+ } else if (_counterRed) {
+ if (_counterRed == 1)
_notesNumber = 0;
- else if (_counter == 30)
+ else if (_counterRed == 30)
getSound()->playSound(getWorld()->graphicResourceIds[85], false, Config.sfxVolume - 10);
getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[10], 0, Common::Point(318, 372), kDrawFlagNone, 0, 1);
- --_counter;
+ --_counterRed;
}
for (uint32 i = 0; i < 5; ++i) {
@@ -267,8 +272,8 @@ void PuzzleHiveMachine::updateScreen() {
getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[resourceId], frameIndex, keyPoints[i], kDrawFlagNone, 0, 1);
}
- if (_counter1)
- --_counter1;
+ if (_counterKey)
+ --_counterKey;
else {
_soundingNote = kMusicalNoteNone;
_frameIndex1 = 0;
@@ -278,7 +283,7 @@ void PuzzleHiveMachine::updateScreen() {
getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[84], 0, indicatorPoints[i], kDrawFlagNone, 0, 1);
_frameIndex = (_frameIndex + 1) % GraphicResource::getFrameCount(_vm, getWorld()->graphicResourceIds[13]);
- if (_counter1)
+ if (_counterKey)
_frameIndex1 = (_frameIndex1 + 1) % GraphicResource::getFrameCount(_vm, getWorld()->graphicResourceIds[18]);
getScreen()->drawGraphicsInQueue();
diff --git a/engines/asylum/puzzles/hivemachine.h b/engines/asylum/puzzles/hivemachine.h
index 04583b1c37..2d1881863c 100644
--- a/engines/asylum/puzzles/hivemachine.h
+++ b/engines/asylum/puzzles/hivemachine.h
@@ -47,7 +47,7 @@ private:
kMusicalNoteB
};
- uint32 _counter, _counter1;
+ uint32 _counterRed, _counterGreen, _counterKey;
int32 _rectIndex;
uint32 _frameIndex, _frameIndex1;
Common::Array<MusicalNote> _melody;
Commit: c91086bee52d28cfc973681883fa29cfbcd175ef
https://github.com/scummvm/scummvm/commit/c91086bee52d28cfc973681883fa29cfbcd175ef
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:37:08+02:00
Commit Message:
ASYLUM: Fix compilation with Visual Studio
Changed paths:
engines/asylum/puzzles/hivecontrol.cpp
diff --git a/engines/asylum/puzzles/hivecontrol.cpp b/engines/asylum/puzzles/hivecontrol.cpp
index 87a712666d..c94bff2e4e 100644
--- a/engines/asylum/puzzles/hivecontrol.cpp
+++ b/engines/asylum/puzzles/hivecontrol.cpp
@@ -92,7 +92,7 @@ void PuzzleHiveControl::reset() {
_frameIndexes[kElementSwirlRim] = 0;
if (_leverPosition != _prevLeverPosition) {
- _leverDelta = abs(_leverPosition - _prevLeverPosition) * 16 / 5;
+ _leverDelta = abs((double)(_leverPosition - _prevLeverPosition)) * 16 / 5;
_currentControl = kControlGlyph4;
}
}
@@ -236,7 +236,7 @@ bool PuzzleHiveControl::mouseLeftDown(const AsylumEvent &evt) {
++_frameIndexes[kElementSwirlRim];
//if (_frameIndexes[kElementSwirlRim] == 12)
// ...
- }
+ }
}
break;
@@ -261,7 +261,7 @@ bool PuzzleHiveControl::mouseLeftDown(const AsylumEvent &evt) {
case kControlGlyph5:
case kControlGlyph6:
_leverPosition = _currentControl - 49;
- _leverDelta = abs(_leverPosition - _prevLeverPosition) * (GraphicResource::getFrameCount(_vm, getWorld()->graphicResourceIds[kElementLever]) - 1) / 5;
+ _leverDelta = abs((double)(_leverPosition - _prevLeverPosition)) * (GraphicResource::getFrameCount(_vm, getWorld()->graphicResourceIds[kElementLever]) - 1) / 5;
if (_leverDelta)
getSound()->playSound(getWorld()->graphicResourceIds[76], false, Config.sfxVolume - 10);
}
@@ -323,7 +323,7 @@ void PuzzleHiveControl::updateScreen() {
case kControlGlyph5:
case kControlGlyph6:
if (_leverDelta) {
- if (_leverPosition > _prevLeverPosition)
+ if (_leverPosition > _prevLeverPosition)
--_frameIndexes[kElementLever];
else
++_frameIndexes[kElementLever];
Commit: db1ddf2b1682b8e8cde2e4a5dde3c4877ec8e183
https://github.com/scummvm/scummvm/commit/db1ddf2b1682b8e8cde2e4a5dde3c4877ec8e183
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:37:08+02:00
Commit Message:
ASYLUM: Add the list of puzzles in the console command help message
Changed paths:
engines/asylum/console.cpp
diff --git a/engines/asylum/console.cpp b/engines/asylum/console.cpp
index c31966beaf..a8d079c647 100644
--- a/engines/asylum/console.cpp
+++ b/engines/asylum/console.cpp
@@ -441,6 +441,23 @@ bool Console::cmdRunEncounter(int32 argc, const char **argv) {
bool Console::cmdRunPuzzle(int32 argc, const char **argv) {
if (argc != 2) {
DebugPrintf("Syntax: %s <puzzle index>\n", argv[0]);
+ DebugPrintf(" 0 VCR\n");
+ DebugPrintf(" 1 Pipes\n");
+ DebugPrintf(" 2 TicTacToe\n");
+ DebugPrintf(" 3 Lock\n");
+ DebugPrintf(" 4 N/A\n");
+ DebugPrintf(" 5 Wheel\n");
+ DebugPrintf(" 6 BoardSalvation\n");
+ DebugPrintf(" 7 BoardYouth\n");
+ DebugPrintf(" 8 BoardKeyHidesTo\n");
+ DebugPrintf(" 9 Writings\n");
+ DebugPrintf(" 10 ???\n");
+ DebugPrintf(" 11 MorgueDoor\n");
+ DebugPrintf(" 12 Clock\n");
+ DebugPrintf(" 13 TimerMachine\n");
+ DebugPrintf(" 14 Fisherman\n");
+ DebugPrintf(" 15 HiveMachine\n");
+ DebugPrintf(" 16 HiveControl\n");
return true;
}
Commit: cb241adfaef43072dd45280d15fe5e7f94bfdd4c
https://github.com/scummvm/scummvm/commit/cb241adfaef43072dd45280d15fe5e7f94bfdd4c
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:37:08+02:00
Commit Message:
ASYLUM: Fix credit text disappearing instead of fading out when at the top of the screen
Changed paths:
engines/asylum/system/screen.cpp
engines/asylum/views/menu.cpp
diff --git a/engines/asylum/system/screen.cpp b/engines/asylum/system/screen.cpp
index 292520e30b..a09e403557 100644
--- a/engines/asylum/system/screen.cpp
+++ b/engines/asylum/system/screen.cpp
@@ -132,10 +132,6 @@ void Screen::draw(GraphicResource *resource, uint32 frameIndex, const Common::Po
clip(&src, &dest, flags);
- // Check src rectangle
- if (!src.isValidRect())
- return;
-
bool masked = false;
if (resourceIdDestination) {
masked = true;
@@ -160,6 +156,10 @@ void Screen::draw(GraphicResource *resource, uint32 frameIndex, const Common::Po
_backBuffer.frameRect(destMask, 0x125);
}
+ // Check src rectangle
+ if (!src.isValidRect())
+ return;
+
// Set the color key (always 0 if set)
_useColorKey = colorKey;
@@ -435,18 +435,19 @@ void Screen::addGraphicToQueueCrossfade(ResourceId resourceId, uint32 frameIndex
dst.translate(point.x + frame->x, point.y + frame->y);
clip(&src, &dst, 0);
-
- // Set the color key (always 0)
- _useColorKey = true;
-
- blitCrossfade((byte *)_backBuffer.pixels + dst.top * _backBuffer.pitch + dst.left,
- (byte *)frame->surface.pixels + src.top * frame->surface.pitch + src.left,
- (byte *)frameObject->surface.pixels + (objectPoint.y + dst.top) * frameObject->surface.pitch + (dst.left + objectPoint.x),
- dst.height(),
- dst.width(),
- frame->surface.pitch - dst.width(),
- _backBuffer.pitch - dst.width(),
- frameObject->surface.pitch - dst.width());
+ if (src.isValidRect()) {
+ // Set the color key (always 0)
+ _useColorKey = true;
+
+ blitCrossfade((byte *)_backBuffer.pixels + dst.top * _backBuffer.pitch + dst.left,
+ (byte *)frame->surface.pixels + src.top * frame->surface.pitch + src.left,
+ (byte *)frameObject->surface.pixels + (objectPoint.y + dst.top) * frameObject->surface.pitch + (dst.left + objectPoint.x),
+ dst.height(),
+ dst.width(),
+ frame->surface.pitch - dst.width(),
+ _backBuffer.pitch - dst.width(),
+ frameObject->surface.pitch - dst.width());
+ }
// Restore transparency table
_transTable = transparencyIndex;
diff --git a/engines/asylum/views/menu.cpp b/engines/asylum/views/menu.cpp
index d2e9d0bf8a..b9609860d0 100644
--- a/engines/asylum/views/menu.cpp
+++ b/engines/asylum/views/menu.cpp
@@ -1537,16 +1537,17 @@ void Menu::updateShowCredits() {
int32 step = 0;
uint32 index = 0;
do {
- if ((_startIndex + step - 24) >= 0) {
+ if ((_startIndex + step) >= -24) {
if ((_startIndex + step) > 480)
break;
int32 minBound = _startIndex + step + 24;
+ int32 maxBound = _startIndex + step;
+
if (minBound >= 0 && minBound < 32)
getText()->setTransTableNum(3 - minBound / 8);
- int32 maxBound = _startIndex + step;
- if ((_startIndex + step) < 480 && maxBound > 448)
+ if (maxBound < 480 && maxBound > 448)
getText()->setTransTableNum(3 - (479 - maxBound) / 8);
getText()->setPosition(320, step + _startIndex);
Commit: 55a9a133da60f2587ab113a78fbd4bd8493c67f2
https://github.com/scummvm/scummvm/commit/55a9a133da60f2587ab113a78fbd4bd8493c67f2
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:37:08+02:00
Commit Message:
ASYLUM: Implement the rest of Actor::process()
Changed paths:
engines/asylum/resources/actor.cpp
engines/asylum/resources/actor.h
engines/asylum/resources/script.cpp
engines/asylum/resources/script.h
diff --git a/engines/asylum/resources/actor.cpp b/engines/asylum/resources/actor.cpp
index 80f2aabdb9..188788eff8 100644
--- a/engines/asylum/resources/actor.cpp
+++ b/engines/asylum/resources/actor.cpp
@@ -1184,7 +1184,7 @@ bool Actor::process(const Common::Point &point) {
}
if (abs(delta.x) != abs(delta.y)) {
- Common::Array<ActionArea *> actions;
+ Common::Array<int> actions;
Common::Point point1;
Common::Point point2;
uint32 count1 = 0;
@@ -1259,24 +1259,67 @@ bool Actor::process(const Common::Point &point) {
// Check scene rects
if (getWorld()->chapter != kChapter2 || strcmp(_name, "Big Crow")) {
- error("[Actor::process] not implemented (scene rects checks)!");
+ Common::Rect currentRect = getWorld()->sceneRects[getWorld()->sceneRectIdx];
+
+ if (!currentRect.contains(point1) || !currentRect.contains(point2))
+ return false;
}
if (canMove(&sum, direction1, count1, true)
&& canMove(&point1, direction2, count2, true)) {
- error("[Actor::process] not implemented (process actor data 1)!");
+ _data.points[0] = point1;
+ _data.points[1] = point;
+ _data.current = 0;
+ _data.count = 2;
+
+ updateFromDirection(direction1);
+
+ _data.directions[1] = direction2;
+
+ return true;
}
if (canMove(&sum, direction2, count2, true)
&& canMove(&point1, direction1, count1, true)) {
- error("[Actor::process] not implemented (process actor data 2)!");
+ _data.points[0] = point2;
+ _data.points[1] = point;
+ _data.current = 0;
+ _data.count = 2;
+
+ updateFromDirection(direction2);
+
+ _data.directions[1] = direction1;
+
+ return true;
}
- error("[Actor::process] not implemented (compute actions)!");
+ // Compute actor actions
+ int actorActions[5];
+ ActionArea *actorArea = getWorld()->actions[_actionIdx3];
+ for (uint32 i = 0; i < 5; i++) {
+ if (actorArea->paths[i])
+ actorActions[i] = actorArea->paths[i];
+ else
+ actorActions[i] = -1;
+ }
+
+ if (actorActions[0] == -1)
+ actions.push_back(_actionIdx3);
+
+ // Process all scene actions
+ for (uint32 i = 0; i < getWorld()->actions.size(); i++) {
+ // Check each area action against each actor action
+ ActionArea *area = getWorld()->actions[i];
+ for (uint32 j = 0; j < 5; j++) {
+ for (uint32 k = 0; k < 5; k++) {
+ if (area->paths[j] == actorActions[k])
+ actions.push_back(i);
+ }
+ }
+ }
//////////////////////////////////////////////////////////////////////////
// Process actions
-
_frameNumber = 0;
if (abs(sum.x - point.x) > abs(sum.y - point.y)) {
@@ -2699,7 +2742,7 @@ void Actor::updateNumbers(int32 reaction, const Common::Point &point) {
//////////////////////////////////////////////////////////////////////////
// Path finding functions
//////////////////////////////////////////////////////////////////////////
-bool Actor::processActionLeft(Common::Point source, const Common::Point &destination, Common::Array<ActionArea *> *actions) {
+bool Actor::processActionLeft(Common::Point source, const Common::Point &destination, Common::Array<int> *actions) {
// Reset pathfinding data
_data.count = 0;
_data.current = 0;
@@ -2728,7 +2771,7 @@ bool Actor::processActionLeft(Common::Point source, const Common::Point &destina
return false;
}
-bool Actor::processActionAll(Common::Point source, const Common::Point &destination, Common::Array<ActionArea *> *actions) {
+bool Actor::processActionAll(Common::Point source, const Common::Point &destination, Common::Array<int> *actions) {
// Reset pathfinding data
_data.count = 0;
_data.current = 0;
@@ -2767,7 +2810,7 @@ bool Actor::processActionAll(Common::Point source, const Common::Point &destinat
return false;
}
-bool Actor::processActionTop(Common::Point source, const Common::Point &destination, Common::Array<ActionArea *> *actions) {
+bool Actor::processActionTop(Common::Point source, const Common::Point &destination, Common::Array<int> *actions) {
// Reset pathfinding data
_data.count = 0;
_data.current = 0;
@@ -2802,7 +2845,7 @@ bool Actor::processActionTop(Common::Point source, const Common::Point &destinat
return false;
}
-bool Actor::processActionDown(Common::Point source, const Common::Point &destination, Common::Array<ActionArea *> *actions) {
+bool Actor::processActionDown(Common::Point source, const Common::Point &destination, Common::Array<int> *actions) {
// Reset pathfinding data
_data.count = 0;
_data.current = 0;
@@ -2828,7 +2871,7 @@ bool Actor::processActionDown(Common::Point source, const Common::Point &destina
return false;
}
-bool Actor::processAction(const Common::Point &source, Common::Array<ActionArea *> *actions, Common::Point *point, ActorDirection direction, const Common::Point &destination, bool *flag) {
+bool Actor::processAction(const Common::Point &source, Common::Array<int> *actions, Common::Point *point, ActorDirection direction, const Common::Point &destination, bool *flag) {
Common::Point sign;
Common::Point src = source;
uint32 frameNumber = _frameNumber;
@@ -2985,7 +3028,7 @@ bool Actor::processAction(const Common::Point &source, Common::Array<ActionArea
return true;
}
-bool Actor::checkPath(Common::Array<ActionArea *> *actions, const Common::Point &point, ActorDirection direction, uint32 loopcount) {
+bool Actor::checkPath(Common::Array<int> *actions, const Common::Point &point, ActorDirection direction, uint32 loopcount) {
if (loopcount <= 1)
return true;
@@ -3006,12 +3049,12 @@ bool Actor::checkPath(Common::Array<ActionArea *> *actions, const Common::Point
return true;
}
-bool Actor::checkAllActions(const Common::Point &pt, Common::Array<ActionArea *> *actions) {
+bool Actor::checkAllActions(const Common::Point &pt, Common::Array<int> *actions) {
if (actions->size() == 0)
return false;
- for (Common::Array<ActionArea *>::iterator it = actions->begin(); it != actions->end(); it++) {
- if (isInActionArea(pt, *it))
+ for (Common::Array<int>::iterator it = actions->begin(); it != actions->end(); it++) {
+ if (isInActionArea(pt, getWorld()->actions[*it]))
return true;
}
diff --git a/engines/asylum/resources/actor.h b/engines/asylum/resources/actor.h
index 14b65c244d..323e99aee8 100644
--- a/engines/asylum/resources/actor.h
+++ b/engines/asylum/resources/actor.h
@@ -436,13 +436,13 @@ private:
// Path finding functions
//////////////////////////////////////////////////////////////////////////
uint32 _frameNumber;
- bool processActionLeft(Common::Point source, const Common::Point &destination, Common::Array<ActionArea *> *actions);
- bool processActionAll(Common::Point source, const Common::Point &destination, Common::Array<ActionArea *> *actions);
- bool processActionTop(Common::Point source, const Common::Point &destination, Common::Array<ActionArea *> *actions);
- bool processActionDown(Common::Point source, const Common::Point &destination, Common::Array<ActionArea *> *actions);
- bool processAction(const Common::Point &source, Common::Array<ActionArea *> *actions, Common::Point *point, ActorDirection direction, const Common::Point &destination, bool *flag);
- bool checkPath(Common::Array<ActionArea *> *actions, const Common::Point &point, ActorDirection direction, uint32 loopcount);
- bool checkAllActions(const Common::Point &pt, Common::Array<ActionArea *> *actions);
+ bool processActionLeft(Common::Point source, const Common::Point &destination, Common::Array<int> *actions);
+ bool processActionAll(Common::Point source, const Common::Point &destination, Common::Array<int> *actions);
+ bool processActionTop(Common::Point source, const Common::Point &destination, Common::Array<int> *actions);
+ bool processActionDown(Common::Point source, const Common::Point &destination, Common::Array<int> *actions);
+ bool processAction(const Common::Point &source, Common::Array<int> *actions, Common::Point *point, ActorDirection direction, const Common::Point &destination, bool *flag);
+ bool checkPath(Common::Array<int> *actions, const Common::Point &point, ActorDirection direction, uint32 loopcount);
+ bool checkAllActions(const Common::Point &pt, Common::Array<int> *actions);
//////////////////////////////////////////////////////////////////////////
// Misc
diff --git a/engines/asylum/resources/script.cpp b/engines/asylum/resources/script.cpp
index 11f8ae29b5..ca508de6f1 100644
--- a/engines/asylum/resources/script.cpp
+++ b/engines/asylum/resources/script.cpp
@@ -70,7 +70,7 @@ void ActionArea::load(Common::SeekableReadStream *stream) {
paletteResourceId = (ResourceId)stream->readSint32LE();
for (int32 i = 0; i < 5; i++)
- array[i] = stream->readSint32LE();
+ paths[i] = stream->readSint32LE();
volume = stream->readSint32LE();
}
diff --git a/engines/asylum/resources/script.h b/engines/asylum/resources/script.h
index 326bddcbd5..334002909f 100644
--- a/engines/asylum/resources/script.h
+++ b/engines/asylum/resources/script.h
@@ -74,7 +74,7 @@ struct ActionArea {
ResourceId soundResourceId;
int32 field_90;
ResourceId paletteResourceId;
- int32 array[5];
+ int32 paths[5];
int32 volume;
ActionArea() {
@@ -96,7 +96,7 @@ struct ActionArea {
soundResourceId = kResourceNone;
field_90 = 0;
paletteResourceId = kResourceNone;
- memset(&array, 0, sizeof(array));
+ memset(&paths, 0, sizeof(paths));
volume = 0;
}
Commit: 6b4f3435c0e8ecdbb24f565294734275fac4f97c
https://github.com/scummvm/scummvm/commit/6b4f3435c0e8ecdbb24f565294734275fac4f97c
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:37:08+02:00
Commit Message:
ASYLUM: Remove Puzzle::reset() functions
- Recreate all puzzle instances on reset
- Clear shared data directly from the AsylumEngine::reset() function
Changed paths:
engines/asylum/asylum.cpp
engines/asylum/puzzles/clock.cpp
engines/asylum/puzzles/clock.h
engines/asylum/puzzles/fisherman.cpp
engines/asylum/puzzles/fisherman.h
engines/asylum/puzzles/hivecontrol.cpp
engines/asylum/puzzles/hivecontrol.h
engines/asylum/puzzles/lock.cpp
engines/asylum/puzzles/lock.h
engines/asylum/puzzles/puzzle.h
diff --git a/engines/asylum/asylum.cpp b/engines/asylum/asylum.cpp
index cba06da43a..a94daf8f0c 100644
--- a/engines/asylum/asylum.cpp
+++ b/engines/asylum/asylum.cpp
@@ -260,11 +260,19 @@ void AsylumEngine::reset() {
_menu->setGameStarted();
// Reset puzzles
- for (uint32 i = 0; i < ARRAYSIZE(_puzzles); i++)
- if (_puzzles[i] != NULL)
- _puzzles[i]->reset();
+ for (uint i = 0; i < ARRAYSIZE(_puzzles); i++)
+ delete _puzzles[i];
+
+ initPuzzles();
+
+ // Reset shared data
+ for (uint32 i = 0; i < 37; i++)
+ _data.setData(i, 160);
+
+ _data.setData(37, 1);
- // FIXME reset shared actor data
+ // Reset special palette info
+ _special->reset(true);
}
void AsylumEngine::playIntro() {
diff --git a/engines/asylum/puzzles/clock.cpp b/engines/asylum/puzzles/clock.cpp
index 5ff69c7c30..369415db2d 100644
--- a/engines/asylum/puzzles/clock.cpp
+++ b/engines/asylum/puzzles/clock.cpp
@@ -72,12 +72,6 @@ PuzzleClock::PuzzleClock(AsylumEngine *engine) : Puzzle(engine) {
PuzzleClock::~PuzzleClock() {
}
-void PuzzleClock::reset() {
- _frameIndexes[0] = 0;
- _frameIndexes[1] = 6;
- _frameIndexes[2] = 10;
-}
-
//////////////////////////////////////////////////////////////////////////
// Event Handling
//////////////////////////////////////////////////////////////////////////
diff --git a/engines/asylum/puzzles/clock.h b/engines/asylum/puzzles/clock.h
index 18f68a0845..ea63108826 100644
--- a/engines/asylum/puzzles/clock.h
+++ b/engines/asylum/puzzles/clock.h
@@ -34,8 +34,6 @@ public:
PuzzleClock(AsylumEngine *engine);
~PuzzleClock();
- void reset();
-
private:
uint32 _frameIndexes[3];
bool _showCursor;
diff --git a/engines/asylum/puzzles/fisherman.cpp b/engines/asylum/puzzles/fisherman.cpp
index 18d12747b9..cbba5f4ba0 100644
--- a/engines/asylum/puzzles/fisherman.cpp
+++ b/engines/asylum/puzzles/fisherman.cpp
@@ -57,25 +57,6 @@ PuzzleFisherman::PuzzleFisherman(AsylumEngine *engine) : Puzzle(engine) {
PuzzleFisherman::~PuzzleFisherman() {
}
-//////////////////////////////////////////////////////////////////////////
-// Reset
-//////////////////////////////////////////////////////////////////////////
-void PuzzleFisherman::reset() {
- memset(&_state, 0, sizeof(_state));
- _dword_45AAD4 = false;
-
- // Original setups polygons here
-
- _dword_45A130 = false;
- _counter = 0;
-
- // Original resets scene fields, but since we are called during a restart, the whole scene is recreated later anyway
- /*for (uint32 i = 0; i < 6; i++) {
- getWorld()->field_E8610[i] = 0;
- getWorld()->field_E8628[i] = 0;
- }*/
-}
-
//////////////////////////////////////////////////////////////////////////
// Event Handling
//////////////////////////////////////////////////////////////////////////
diff --git a/engines/asylum/puzzles/fisherman.h b/engines/asylum/puzzles/fisherman.h
index 87f49d099c..607ac3042e 100644
--- a/engines/asylum/puzzles/fisherman.h
+++ b/engines/asylum/puzzles/fisherman.h
@@ -34,8 +34,6 @@ public:
PuzzleFisherman(AsylumEngine *engine);
~PuzzleFisherman();
- void reset();
-
private:
bool _state[6];
int32 _counter;
diff --git a/engines/asylum/puzzles/hivecontrol.cpp b/engines/asylum/puzzles/hivecontrol.cpp
index c94bff2e4e..5065c7cc0a 100644
--- a/engines/asylum/puzzles/hivecontrol.cpp
+++ b/engines/asylum/puzzles/hivecontrol.cpp
@@ -87,8 +87,8 @@ void PuzzleHiveControl::reset() {
_colorL = _colorR = 0;
_frameIndexOffset = 0;
- memset(&_glyphFlags, false, sizeof(_glyphFlags));
- memset(&_wingsState, false, sizeof(_wingsState));
+ memset(&_glyphFlags, false, sizeof(_glyphFlags));
+ memset(&_wingsState, false, sizeof(_wingsState));
_frameIndexes[kElementSwirlRim] = 0;
if (_leverPosition != _prevLeverPosition) {
diff --git a/engines/asylum/puzzles/hivecontrol.h b/engines/asylum/puzzles/hivecontrol.h
index cac3433aad..e0bdc115c3 100644
--- a/engines/asylum/puzzles/hivecontrol.h
+++ b/engines/asylum/puzzles/hivecontrol.h
@@ -60,7 +60,6 @@ public:
~PuzzleHiveControl();
bool hitTest1(uint32 resourceId, Common::Point point, Common::Point location);
- void reset();
private:
enum Element {
@@ -114,6 +113,7 @@ private:
Control findControl();
void updateScreen();
void playSound();
+ void reset();
};
} // End of namespace Asylum
diff --git a/engines/asylum/puzzles/lock.cpp b/engines/asylum/puzzles/lock.cpp
index 5d01b5dc5b..2c1a29ed1c 100644
--- a/engines/asylum/puzzles/lock.cpp
+++ b/engines/asylum/puzzles/lock.cpp
@@ -51,17 +51,6 @@ PuzzleLock::PuzzleLock(AsylumEngine *engine) : Puzzle(engine) {
PuzzleLock::~PuzzleLock() {
}
-void PuzzleLock::reset() {
- _frameIndexes[0] = 4;
- _frameIndexes[1] = 4;
- _frameIndexes[2] = 4;
-
- for (uint32 i = 0; i < 37; i++)
- getSharedData()->setData(i, 160);
-
- getSharedData()->setData(37, 1);
-}
-
//////////////////////////////////////////////////////////////////////////
// Event Handling
//////////////////////////////////////////////////////////////////////////
diff --git a/engines/asylum/puzzles/lock.h b/engines/asylum/puzzles/lock.h
index 073c3a7545..d6b3c66413 100644
--- a/engines/asylum/puzzles/lock.h
+++ b/engines/asylum/puzzles/lock.h
@@ -34,8 +34,6 @@ public:
PuzzleLock(AsylumEngine *engine);
~PuzzleLock();
- void reset();
-
private:
int32 _frameIndexes[7];
bool _incrementLock;
diff --git a/engines/asylum/puzzles/puzzle.h b/engines/asylum/puzzles/puzzle.h
index 445881da11..3841ba6b75 100644
--- a/engines/asylum/puzzles/puzzle.h
+++ b/engines/asylum/puzzles/puzzle.h
@@ -43,8 +43,6 @@ public:
Puzzle(AsylumEngine *engine);
virtual ~Puzzle();
- virtual void reset() {}
-
bool handleEvent(const AsylumEvent &evt);
protected:
Commit: ba2addab8d24bd59b8881590cb6b111f36bd84f5
https://github.com/scummvm/scummvm/commit/ba2addab8d24bd59b8881590cb6b111f36bd84f5
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:37:08+02:00
Commit Message:
ASYLUM: Finish implementation of AsylumEngine::restart()
Changed paths:
engines/asylum/asylum.cpp
diff --git a/engines/asylum/asylum.cpp b/engines/asylum/asylum.cpp
index a94daf8f0c..12da9d4fb0 100644
--- a/engines/asylum/asylum.cpp
+++ b/engines/asylum/asylum.cpp
@@ -238,8 +238,8 @@ void AsylumEngine::restart() {
memset(&_gameFlags, 0, sizeof(_gameFlags));
delete _scene;
_scene = NULL;
- // TODO reset puzzle data
- // TODO reset encounter data
+ delete _encounter;
+ _encounter = new Encounter(this);
_script->resetQueue();
_data.point.x = -1;
Commit: 1ba0c2a354e9fdd3ac1b4b0606c0e9c57f770a5d
https://github.com/scummvm/scummvm/commit/1ba0c2a354e9fdd3ac1b4b0606c0e9c57f770a5d
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:37:09+02:00
Commit Message:
ASYLUM: Fix crash when initializing Board puzzles
The fixed size text buffer was too small to hold all the text for two of the puzzles. This replaces it with a Common::String
Changed paths:
engines/asylum/puzzles/board.cpp
engines/asylum/puzzles/board.h
diff --git a/engines/asylum/puzzles/board.cpp b/engines/asylum/puzzles/board.cpp
index 608c77e9f4..c69a518883 100644
--- a/engines/asylum/puzzles/board.cpp
+++ b/engines/asylum/puzzles/board.cpp
@@ -44,7 +44,6 @@ PuzzleBoard::PuzzleBoard(AsylumEngine *engine, PuzzleData data) : Puzzle(engine)
// Init board
_solved = false;
- memset(&_text, 0, sizeof(_text));
memset(&_charUsed, false, sizeof(_charUsed));
memset(&_solvedText, 0, sizeof(_solvedText));
_rectIndex = -2;
@@ -71,12 +70,12 @@ bool PuzzleBoard::init(const AsylumEvent &evt) {
getText()->loadFont(getWorld()->graphicResourceIds[35]);
// Prepare text to draw
- memset(&_text, 0, sizeof(_text));
+ _text = "";
for (uint32 i = 0; i < _data.soundResourceSize; i++) {
_data.soundResources[i].played = false;
- strcat((char *)&_text, getText()->get(MAKE_RESOURCE(kResourcePackText, 1068 + _data.soundResources[i].index)));
- strcat((char *)&_text, " ");
+ _text += getText()->get(MAKE_RESOURCE(kResourcePackText, 1068 + _data.soundResources[i].index));
+ _text += " ";
}
updateScreen();
@@ -150,7 +149,7 @@ bool PuzzleBoard::stopSound() {
void PuzzleBoard::drawText() {
getText()->loadFont(getWorld()->graphicResourceIds[35]);
- getText()->draw(0, 99, kTextCenter, 25, 50, 16, 590, _text);
+ getText()->draw(0, 99, kTextCenter, 25, 50, 16, 590, _text.c_str());
int32 index = 0;
for (uint32 x = 215; x < _data.maxWidth; x += 24) {
diff --git a/engines/asylum/puzzles/board.h b/engines/asylum/puzzles/board.h
index e4a28f1e0f..738bd27a7e 100644
--- a/engines/asylum/puzzles/board.h
+++ b/engines/asylum/puzzles/board.h
@@ -62,7 +62,7 @@ public:
protected:
bool _solved;
- char _text[800];
+ Common::String _text;
bool _charUsed[20];
char _solvedText[28]; // KeyHidesTo uses 28 chars, the other puzzles 20
uint32 _position;
Commit: 7c9a793a64362e589af10960e835fca37c4dda90
https://github.com/scummvm/scummvm/commit/7c9a793a64362e589af10960e835fca37c4dda90
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:37:09+02:00
Commit Message:
ASYLUM: Finish implementation of Scene::processUpdateList()
Changed paths:
engines/asylum/views/scene.cpp
diff --git a/engines/asylum/views/scene.cpp b/engines/asylum/views/scene.cpp
index 8863a4851c..4c242514e9 100644
--- a/engines/asylum/views/scene.cpp
+++ b/engines/asylum/views/scene.cpp
@@ -2515,7 +2515,15 @@ void Scene::processUpdateList() {
actor->setPriority(object->getPriority() + 3);
if (i > 0) {
- error("[Scene::processUpdateList] list update not implemented!");
+ // Update actor priority up to current index
+ for (uint32 k = 0; k < i; k++) {
+ Actor *previousActor = getWorld()->actors[_updateList[k].index];
+
+ if (getWorld()->chapter != kChapter2 || previousActor->getField944() != 1) {
+ if (previousActor->getPriority() == actor->getPriority())
+ actor->setPriority(actor->getPriority() - 1);
+ }
+ }
}
}
} else {
@@ -2524,7 +2532,27 @@ void Scene::processUpdateList() {
actor->setPriority(object->getPriority() - 1);
if (i > 0) {
- error("[Scene::processUpdateList] list update not implemented!");
+
+ // Update actor priority up to current index
+ for (uint32 k = 0; k < i; k++) {
+ Actor *previousActor = getWorld()->actors[_updateList[k].index];
+
+ if (previousActor->getField944() != 1 && previousActor->getField944() != 4) {
+ Actor *actorCheck = getWorld()->actors[k];
+
+ if (rectIntersect(actorCheck->getPoint1()->x,
+ actorCheck->getPoint1()->y,
+ actorCheck->getPoint1()->x + actorCheck->getBoundingRect()->bottom,
+ actorCheck->getPoint1()->y + actorCheck->getBoundingRect()->right,
+ actor->getPoint1()->x,
+ actor->getPoint1()->y,
+ actor->getPoint1()->x + actor->getBoundingRect()->right,
+ bottomRight)) {
+ if (previousActor->getPriority() == actor->getPriority())
+ actor->setPriority(actor->getPriority() - 1);
+ }
+ }
+ }
}
}
}
Commit: 203e18669e7e3090bcbd9917573d50af119be23d
https://github.com/scummvm/scummvm/commit/203e18669e7e3090bcbd9917573d50af119be23d
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:37:09+02:00
Commit Message:
ASYLUM: Implement Actor::updateStatus14_Chapter2()
Changed paths:
engines/asylum/resources/actor.cpp
engines/asylum/resources/data.h
diff --git a/engines/asylum/resources/actor.cpp b/engines/asylum/resources/actor.cpp
index 188788eff8..a1873933ab 100644
--- a/engines/asylum/resources/actor.cpp
+++ b/engines/asylum/resources/actor.cpp
@@ -2300,8 +2300,85 @@ void Actor::updateStatus14_Chapter2() {
return;
}
+ // FIXME original calls getDistance but does not seem to do anything with the results
- error("[Actor::updateStatus14_Chapter2] not implemented!");
+ if (_status == kActorStatus17 || !getScene()->getActor(10)->isVisible()) {
+ updateStatus(kActorStatusEnabled);
+ getSharedData()->actorVerticalOffset[_index] = 160;
+ }
+
+ if (_status != kActorStatus16) {
+ _point1.x -= getSharedData()->getData(2 * _index + 19);
+ _point1.y -= getSharedData()->getData(2 * _index + 20) + 54;
+ }
+
+ if (_frameIndex == _frameCount - 1) {
+ _frameIndex = 0;
+ if (getSharedData()->getData(_index + 6) <= 1 || _status == kActorStatus16 || _status == kActorStatus17) {
+ getSharedData()->setData(_index + 6, getSharedData()->getData(_index + 6) + 1);
+ } else {
+ updateStatus(kActorStatus15);
+ _point1.y -= 54;
+ getSharedData()->setData(_index + 6, 0);
+ getSharedData()->setData(_index, getSharedData()->getData(_index) + 54);
+ }
+ }
+
+ if (_status == kActorStatus17 && getSharedData()->getData(_index + 6) < 100) {
+ _point1.y -= 6;
+ getSharedData()->setData(_index + 6, 100);
+ getSharedData()->setData(_index, getSharedData()->getData(_index) + 6);
+ }
+
+ if (getSharedData()->getData(_index + 6) > 99) {
+ _point1.y -= 6;
+ getSharedData()->setData(_index + 6, getSharedData()->getData(_index + 6) + 1);
+ getSharedData()->setData(_index, getSharedData()->getData(_index) + 6);
+
+ if (getSharedData()->getData(_index + 6) > 108) {
+ getSharedData()->setData(_index + 6, 0);
+
+ updateStatus(kActorStatusEnabled);
+
+ switch (_index) {
+ default:
+ error("Invalid actor index (was: %d)", _index);
+ break;
+
+ case 13:
+ processStatus(2300, 671, false);
+ break;
+
+ case 14:
+ processStatus(2600, 130, false);
+ break;
+
+ case 15:
+ processStatus(2742, 615, false);
+ break;
+
+ case 16:
+ processStatus(2700, 1400, false);
+ break;
+
+ case 17:
+ processStatus(2751, 347, false);
+ break;
+
+ case 18:
+ processStatus(2420, 284, false);
+ break;
+
+ case 19:
+ processStatus(2800, 370, false);
+ break;
+
+ case 20:
+ processStatus(1973, 1, false);
+ break;
+ }
+ }
+ }
}
void Actor::updateStatus14_Chapter11() {
diff --git a/engines/asylum/resources/data.h b/engines/asylum/resources/data.h
index f6d885adc2..76a09065e6 100644
--- a/engines/asylum/resources/data.h
+++ b/engines/asylum/resources/data.h
@@ -151,7 +151,8 @@ public:
int32 movieIndex;
// Saved scene data
- ResourceId cursorResources[11];
+ ResourceId cursorResources[11]; // FIXME (should be 8)
+ int32 actorVerticalOffset[5];
ResourceId sceneFonts[3];
int32 smallCurUp;
int32 smallCurDown;
Commit: 96abeb167219b05d3beb83a6d494f96968360574
https://github.com/scummvm/scummvm/commit/96abeb167219b05d3beb83a6d494f96968360574
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:37:09+02:00
Commit Message:
ASYLUM: Implement Actor::updateStatus15_Chapter2_Player()
Changed paths:
engines/asylum/resources/actor.cpp
engines/asylum/shared.h
diff --git a/engines/asylum/resources/actor.cpp b/engines/asylum/resources/actor.cpp
index a1873933ab..38b22ae6c4 100644
--- a/engines/asylum/resources/actor.cpp
+++ b/engines/asylum/resources/actor.cpp
@@ -2473,7 +2473,107 @@ void Actor::updateStatus15_Chapter2_Helper() {
}
void Actor::updateStatus15_Chapter2_Player() {
- error("[Actor::updateStatus15_Chapter2_Player] not implemented!");
+ Actor *player = getScene()->getActor(getScene()->getPlayerIndex());
+ ActorIndex actorIndex = getSharedData()->getData(38);
+
+ Common::Point sum = _point1 + _point2;
+ Common::Point sumPlayer = *player->getPoint1() + *player->getPoint2();
+
+ _frameIndex++;
+
+ if (_frameIndex == 1)
+ getSound()->playSound(getWorld()->soundResourceIds[3], false, Config.sfxVolume - 10);
+
+ if (player->getFrameIndex() == 3) {
+
+ if (actorIndex > 12) {
+ if (sqrt((double)((sum.y - sumPlayer.y) * (sum.y - sumPlayer.y) + (sum.x - sumPlayer.x) * (sum.x - sumPlayer.x))) < 50.0) {
+ Actor *otherActor = getScene()->getActor(actorIndex);
+
+ if (otherActor->getStatus() == kActorStatus14) {
+ // FIXME: this is a bit strange, but it looks like the original does exactly that
+ Actor* actor38 = getScene()->getActor(38);
+ actor38->setFrameIndex(0);
+ *actor38->getPoint1() = *otherActor->getPoint1();
+
+ switch (actorIndex) {
+ default:
+ break;
+
+ case 13:
+ _vm->setGameFlag(kGameFlag319);
+ _vm->clearGameFlag(kGameFlag235);
+ break;
+
+ case 14:
+ _vm->setGameFlag(kGameFlag320);
+ _vm->clearGameFlag(kGameFlag235);
+ break;
+
+ case 15:
+ if (getScene()->getActor(16)->updateStatus15_isNoVisibleOrStatus17()) {
+ _vm->setGameFlag(kGameFlag321);
+ _vm->clearGameFlag(kGameFlag235);
+ }
+ break;
+
+ case 16:
+ if (getScene()->getActor(15)->updateStatus15_isNoVisibleOrStatus17()) {
+ _vm->setGameFlag(kGameFlag321);
+ _vm->clearGameFlag(kGameFlag235);
+ }
+ break;
+
+ case 17:
+ if (getScene()->getActor(21)->updateStatus15_isNoVisibleOrStatus17()) {
+ _vm->setGameFlag(kGameFlag322);
+ _vm->clearGameFlag(kGameFlag235);
+ }
+ break;
+
+ case 18:
+ if (getScene()->getActor(19)->updateStatus15_isNoVisibleOrStatus17() && getScene()->getActor(20)->updateStatus15_isNoVisibleOrStatus17()) {
+ _vm->setGameFlag(kGameFlag323);
+ _vm->clearGameFlag(kGameFlag235);
+ }
+ break;
+
+ case 19:
+ if (getScene()->getActor(18)->updateStatus15_isNoVisibleOrStatus17() && getScene()->getActor(20)->updateStatus15_isNoVisibleOrStatus17()) {
+ _vm->setGameFlag(kGameFlag323);
+ _vm->clearGameFlag(kGameFlag235);
+ }
+ break;
+
+ case 20:
+ if (getScene()->getActor(19)->updateStatus15_isNoVisibleOrStatus17() && getScene()->getActor(18)->updateStatus15_isNoVisibleOrStatus17()) {
+ _vm->setGameFlag(kGameFlag323);
+ _vm->clearGameFlag(kGameFlag235);
+ }
+ break;
+
+ case 21:
+ if (getScene()->getActor(17)->updateStatus15_isNoVisibleOrStatus17()) {
+ _vm->setGameFlag(kGameFlag322);
+ _vm->clearGameFlag(kGameFlag235);
+ }
+ break;
+ }
+
+ otherActor->updateStatus(kActorStatus17);
+ getSound()->playSound(getWorld()->soundResourceIds[2], false, Config.sfxVolume - 10);
+ }
+ }
+ }
+
+ if (actorIndex == 11)
+ updateStatus15_Chapter2_Player_Helper();
+ }
+
+ if (_frameIndex >= _frameCount) {
+ _frameIndex = 0;
+ player->updateStatus(kActorStatus14);
+ }
}
void Actor::updateStatus15_Chapter2_Player_Helper() {
diff --git a/engines/asylum/shared.h b/engines/asylum/shared.h
index 340b51eb5d..d7df6c6d4b 100644
--- a/engines/asylum/shared.h
+++ b/engines/asylum/shared.h
@@ -81,6 +81,11 @@ enum GameFlag {
kGameFlag281 = 281,
kGameFlag282 = 282,
kGameFlag283 = 283,
+ kGameFlag319 = 319,
+ kGameFlag320 = 320,
+ kGameFlag321 = 321,
+ kGameFlag322 = 322,
+ kGameFlag323 = 323,
kGameFlag353 = 353,
kGameFlag354 = 354,
kGameFlag355 = 355,
Commit: 687994559115c9d40c1f4d19391e853a820c24ac
https://github.com/scummvm/scummvm/commit/687994559115c9d40c1f4d19391e853a820c24ac
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:37:09+02:00
Commit Message:
ASYLUM: Implement the missing part of Special::chapter2()
Changed paths:
engines/asylum/resources/actor.cpp
engines/asylum/resources/data.h
engines/asylum/resources/special.cpp
engines/asylum/views/scene.cpp
diff --git a/engines/asylum/resources/actor.cpp b/engines/asylum/resources/actor.cpp
index 38b22ae6c4..14f59d7293 100644
--- a/engines/asylum/resources/actor.cpp
+++ b/engines/asylum/resources/actor.cpp
@@ -2304,7 +2304,7 @@ void Actor::updateStatus14_Chapter2() {
if (_status == kActorStatus17 || !getScene()->getActor(10)->isVisible()) {
updateStatus(kActorStatusEnabled);
- getSharedData()->actorVerticalOffset[_index] = 160;
+ getSharedData()->setData(_index - 8, 160);
}
if (_status != kActorStatus16) {
@@ -2473,7 +2473,7 @@ void Actor::updateStatus15_Chapter2_Helper() {
}
void Actor::updateStatus15_Chapter2_Player() {
- Actor *player = getScene()->getActor(getScene()->getPlayerIndex());
+ Actor *player = getScene()->getActor();
ActorIndex actorIndex = getSharedData()->getData(38);
Common::Point sum = _point1 + _point2;
@@ -2608,6 +2608,7 @@ bool Actor::updateStatus15_isNoVisibleOrStatus17() {
}
void Actor::updateStatus15_Chapter2_Actor11() {
+
error("[Actor::updateStatus15_Chapter2_Actor11] not implemented!");
}
diff --git a/engines/asylum/resources/data.h b/engines/asylum/resources/data.h
index 76a09065e6..26a5c734eb 100644
--- a/engines/asylum/resources/data.h
+++ b/engines/asylum/resources/data.h
@@ -151,8 +151,7 @@ public:
int32 movieIndex;
// Saved scene data
- ResourceId cursorResources[11]; // FIXME (should be 8)
- int32 actorVerticalOffset[5];
+ ResourceId cursorResources[13];
ResourceId sceneFonts[3];
int32 smallCurUp;
int32 smallCurDown;
diff --git a/engines/asylum/resources/special.cpp b/engines/asylum/resources/special.cpp
index 8393b06023..d1dd1ae88d 100644
--- a/engines/asylum/resources/special.cpp
+++ b/engines/asylum/resources/special.cpp
@@ -245,22 +245,20 @@ void Special::chapter2(Object *object, ActorIndex actorIndex) {
case 28:
case 29:
if (actor->isVisible()) {
- error("[Special::chapter2] Not implemented!");
- // FIXME: This is wrong, the 386th object is used as an offset to the proper actor
- //Object *obj386 = getWorld()->objects[386];
-
- //actor->getPoint1()->x = obj386->getSoundY();
- //actor->getPoint1()->y = obj386->getField688() + getWorld()->coordinates[actorIndex - 22]; // FIXME out of bound access for actorIndex == 29
- //actor->setFrameIndex(obj386->getField67C());
- //actor->setDirection(obj386->getField6A4());
-
- //// Get the resource Id
- //Actor *actor0 = getScene()->getActor(0);
- //Actor *actor13 = getScene()->getActor(13);
- //int32 index = (actor13->getDirection() > 4) ? 8 - actor13->getDirection() : actor13->getDirection();
- //ResourceId id = actor0->getResourcesId((uint32)index);
-
- //actor->setResourceId(id);
+ // Update actor
+ Actor *refActor = getScene()->getActor(actorIndex - 9); // Original uses offset to object array (+ offset to actor).
+
+ *actor->getPoint1() = *refActor->getPoint1();
+ actor->getPoint1()->y += getSharedData()->getData(actorIndex - 8);
+ actor->setFrameIndex(refActor->getFrameIndex());
+ actor->setDirection(refActor->getDirection());
+
+ // Get the resource Id
+ Actor *actor13 = getScene()->getActor(13);
+ int32 direction = (actor13->getDirection() > kDirectionS) ? 8 - actor13->getDirection() : actor13->getDirection();
+ ResourceId id = actor->getResourcesId(actorIndex + direction);
+
+ actor->setResourceId(id);
}
break;
diff --git a/engines/asylum/views/scene.cpp b/engines/asylum/views/scene.cpp
index 4c242514e9..799acdff57 100644
--- a/engines/asylum/views/scene.cpp
+++ b/engines/asylum/views/scene.cpp
@@ -2042,7 +2042,7 @@ Actor* Scene::getActor(ActorIndex index) {
if (!_ws)
error("[Scene::getActor] WorldStats not initialized properly!");
- ActorIndex computedIndex = (index != -1) ? index : _playerIndex;
+ ActorIndex computedIndex = (index != kActorInvalid) ? index : _playerIndex;
if (computedIndex < 0 || computedIndex >= (int16)_ws->actors.size())
error("[Scene::getActor] Invalid actor index: %d ([0-%d] allowed)", computedIndex, _ws->actors.size() - 1);
Commit: 88d0d334645cf2afff2279fc7a43de5b1be8b73c
https://github.com/scummvm/scummvm/commit/88d0d334645cf2afff2279fc7a43de5b1be8b73c
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:37:09+02:00
Commit Message:
ASYLUM: Cleanup Actor::updateStatus15_Chapter2_Player()
This function is only called for the current player and thus can be simplified
Changed paths:
engines/asylum/resources/actor.cpp
diff --git a/engines/asylum/resources/actor.cpp b/engines/asylum/resources/actor.cpp
index 14f59d7293..4587e5d17c 100644
--- a/engines/asylum/resources/actor.cpp
+++ b/engines/asylum/resources/actor.cpp
@@ -2473,96 +2473,95 @@ void Actor::updateStatus15_Chapter2_Helper() {
}
void Actor::updateStatus15_Chapter2_Player() {
- Actor *player = getScene()->getActor();
- ActorIndex actorIndex = getSharedData()->getData(38);
-
- Common::Point sum = _point1 + _point2;
- Common::Point sumPlayer = *player->getPoint1() + *player->getPoint2();
+ if (_index != getScene()->getPlayerIndex())
+ error("[Actor::updateStatus15_Chapter2_Player] Function is only available for the current player");
+ // Update frame index and process
_frameIndex++;
if (_frameIndex == 1)
getSound()->playSound(getWorld()->soundResourceIds[3], false, Config.sfxVolume - 10);
- if (player->getFrameIndex() == 3) {
+ ActorIndex actorIndex = getSharedData()->getData(38);
+ if (_frameIndex == 3) {
if (actorIndex > 12) {
- if (sqrt((double)((sum.y - sumPlayer.y) * (sum.y - sumPlayer.y) + (sum.x - sumPlayer.x) * (sum.x - sumPlayer.x))) < 50.0) {
- Actor *otherActor = getScene()->getActor(actorIndex);
- if (otherActor->getStatus() == kActorStatus14) {
- // FIXME: this is a bit strange, but it looks like the original does exactly that
- Actor* actor38 = getScene()->getActor(38);
- actor38->setFrameIndex(0);
- *actor38->getPoint1() = *otherActor->getPoint1();
+ Actor *otherActor = getScene()->getActor(actorIndex);
- switch (actorIndex) {
- default:
- break;
+ if (otherActor->getStatus() == kActorStatus14) {
+ // FIXME: this is a bit strange, but it looks like the original does exactly that
+ // this might be dead code (the actor 38 never exists and thus setting values has no effect)
+ Actor* actor38 = getScene()->getActor(38);
+ actor38->setFrameIndex(0);
+ *actor38->getPoint1() = *otherActor->getPoint1();
- case 13:
- _vm->setGameFlag(kGameFlag319);
- _vm->clearGameFlag(kGameFlag235);
- break;
+ switch (actorIndex) {
+ default:
+ break;
- case 14:
- _vm->setGameFlag(kGameFlag320);
- _vm->clearGameFlag(kGameFlag235);
- break;
+ case 13:
+ _vm->setGameFlag(kGameFlag319);
+ _vm->clearGameFlag(kGameFlag235);
+ break;
- case 15:
- if (getScene()->getActor(16)->updateStatus15_isNoVisibleOrStatus17()) {
- _vm->setGameFlag(kGameFlag321);
- _vm->clearGameFlag(kGameFlag235);
- }
- break;
+ case 14:
+ _vm->setGameFlag(kGameFlag320);
+ _vm->clearGameFlag(kGameFlag235);
+ break;
- case 16:
- if (getScene()->getActor(15)->updateStatus15_isNoVisibleOrStatus17()) {
- _vm->setGameFlag(kGameFlag321);
- _vm->clearGameFlag(kGameFlag235);
- }
- break;
+ case 15:
+ if (getScene()->getActor(16)->updateStatus15_isNoVisibleOrStatus17()) {
+ _vm->setGameFlag(kGameFlag321);
+ _vm->clearGameFlag(kGameFlag235);
+ }
+ break;
- case 17:
- if (getScene()->getActor(21)->updateStatus15_isNoVisibleOrStatus17()) {
- _vm->setGameFlag(kGameFlag322);
- _vm->clearGameFlag(kGameFlag235);
- }
- break;
+ case 16:
+ if (getScene()->getActor(15)->updateStatus15_isNoVisibleOrStatus17()) {
+ _vm->setGameFlag(kGameFlag321);
+ _vm->clearGameFlag(kGameFlag235);
+ }
+ break;
- case 18:
- if (getScene()->getActor(19)->updateStatus15_isNoVisibleOrStatus17() && getScene()->getActor(20)->updateStatus15_isNoVisibleOrStatus17()) {
- _vm->setGameFlag(kGameFlag323);
- _vm->clearGameFlag(kGameFlag235);
- }
- break;
+ case 17:
+ if (getScene()->getActor(21)->updateStatus15_isNoVisibleOrStatus17()) {
+ _vm->setGameFlag(kGameFlag322);
+ _vm->clearGameFlag(kGameFlag235);
+ }
+ break;
- case 19:
- if (getScene()->getActor(18)->updateStatus15_isNoVisibleOrStatus17() && getScene()->getActor(20)->updateStatus15_isNoVisibleOrStatus17()) {
- _vm->setGameFlag(kGameFlag323);
- _vm->clearGameFlag(kGameFlag235);
- }
- break;
+ case 18:
+ if (getScene()->getActor(19)->updateStatus15_isNoVisibleOrStatus17() && getScene()->getActor(20)->updateStatus15_isNoVisibleOrStatus17()) {
+ _vm->setGameFlag(kGameFlag323);
+ _vm->clearGameFlag(kGameFlag235);
+ }
+ break;
- case 20:
- if (getScene()->getActor(19)->updateStatus15_isNoVisibleOrStatus17() && getScene()->getActor(18)->updateStatus15_isNoVisibleOrStatus17()) {
- _vm->setGameFlag(kGameFlag323);
- _vm->clearGameFlag(kGameFlag235);
- }
- break;
+ case 19:
+ if (getScene()->getActor(18)->updateStatus15_isNoVisibleOrStatus17() && getScene()->getActor(20)->updateStatus15_isNoVisibleOrStatus17()) {
+ _vm->setGameFlag(kGameFlag323);
+ _vm->clearGameFlag(kGameFlag235);
+ }
+ break;
- case 21:
- if (getScene()->getActor(17)->updateStatus15_isNoVisibleOrStatus17()) {
- _vm->setGameFlag(kGameFlag322);
- _vm->clearGameFlag(kGameFlag235);
- }
- break;
+ case 20:
+ if (getScene()->getActor(19)->updateStatus15_isNoVisibleOrStatus17() && getScene()->getActor(18)->updateStatus15_isNoVisibleOrStatus17()) {
+ _vm->setGameFlag(kGameFlag323);
+ _vm->clearGameFlag(kGameFlag235);
}
+ break;
- otherActor->updateStatus(kActorStatus17);
- getSound()->playSound(getWorld()->soundResourceIds[2], false, Config.sfxVolume - 10);
+ case 21:
+ if (getScene()->getActor(17)->updateStatus15_isNoVisibleOrStatus17()) {
+ _vm->setGameFlag(kGameFlag322);
+ _vm->clearGameFlag(kGameFlag235);
+ }
+ break;
}
+
+ otherActor->updateStatus(kActorStatus17);
+ getSound()->playSound(getWorld()->soundResourceIds[2], false, Config.sfxVolume - 10);
}
}
@@ -2572,7 +2571,7 @@ void Actor::updateStatus15_Chapter2_Player() {
if (_frameIndex >= _frameCount) {
_frameIndex = 0;
- player->updateStatus(kActorStatus14);
+ updateStatus(kActorStatus14);
}
}
Commit: 188264b94f83a137fac3dff0b7eeb566f53ee823
https://github.com/scummvm/scummvm/commit/188264b94f83a137fac3dff0b7eeb566f53ee823
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:37:10+02:00
Commit Message:
ASYLUM: Implement Actor::updateStatus15_Chapter2_Actor11()
Changed paths:
engines/asylum/resources/actor.cpp
diff --git a/engines/asylum/resources/actor.cpp b/engines/asylum/resources/actor.cpp
index 4587e5d17c..8f0054867c 100644
--- a/engines/asylum/resources/actor.cpp
+++ b/engines/asylum/resources/actor.cpp
@@ -2607,8 +2607,83 @@ bool Actor::updateStatus15_isNoVisibleOrStatus17() {
}
void Actor::updateStatus15_Chapter2_Actor11() {
+ Actor *player = getScene()->getActor();
+
+ Common::Point sum = _point1 + _point2;
+ Common::Point sumPlayer = *player->getPoint1() + *player->getPoint2();
+
+ Common::Rect rect;
+ rectFromDirection(&rect, _direction, sum);
+
+ switch (_frameIndex) {
+ default:
+ break;
+
+ case 1:
+ getSound()->playSound(getWorld()->soundResourceIds[4], false, Config.sfxVolume - 10);
+ break;
+
+ case 9:
+ getSharedData()->setData(37, 1);
+ getSharedData()->setData(42, getSharedData()->getData(42) + 1);
+ break;
+
+ case 11:
+ if (getSharedData()->getData(42) >= 3)
+ getSharedData()->setData(42, 0);
+ else
+ getSharedData()->setData(37, -1);
+ break;
+ }
+
+ _frameIndex += getSharedData()->getData(37);
- error("[Actor::updateStatus15_Chapter2_Actor11] not implemented!");
+ Common::Point actionPoint = sum;
+ actionPoint.x += compareX(Common::Point(rect.left, rect.top), Common::Point(rect.right, rect.bottom), sumPlayer);
+ actionPoint.y += compareY(Common::Point(rect.left, rect.top), Common::Point(rect.right, rect.bottom), sumPlayer);
+
+ if (getScene()->getActor(11)->getFrameIndex() < 8
+ && getScene()->findActionArea(kActionAreaType2, actionPoint)
+ && !updateStatus15_Chapter2_Actor11_Helper(10, 11))
+ _point1 = actionPoint - _point2;
+
+ if (_frameIndex != 8 || _status == kActorStatus16) { /* FIXME the status test seems useless */
+ if (_frameIndex > _frameCount - 1) {
+ _frameIndex = 0;
+
+ if (!getSharedData()->actorUpdateStatus15Check) {
+ updateStatus(kActorStatus12);
+ } else {
+ getSharedData()->actorUpdateStatus15Check = false;
+ getScene()->getActor(11)->updateStatus(kActorStatus18);
+ }
+ }
+ } else {
+ if (compare(Common::Point(rect.left, rect.top), Common::Point(rect.right, rect.bottom), sumPlayer)) {
+
+ _vm->clearGameFlag(kGameFlag263);
+ _vm->clearGameFlag(kGameFlag264);
+ _vm->clearGameFlag(kGameFlag265);
+ _vm->clearGameFlag(kGameFlag266);
+ _vm->clearGameFlag(kGameFlag267);
+ _vm->clearGameFlag(kGameFlag268);
+ _vm->clearGameFlag(kGameFlag269);
+
+ player->update_409230();
+ player->updateStatus(kActorStatus16);
+ updateStatus15_Chapter2_Helper();
+
+ getSpeech()->playPlayer(52);
+
+ _vm->setGameFlag(kGameFlag219);
+
+ } else {
+ if ((abs(sum.y - sumPlayer.y) + abs(sum.x - sumPlayer.x)) < 100) {
+ getSharedData()->setData(41, 5);
+ getSharedData()->actorUpdateStatus15Check = true;
+ }
+ }
+ }
}
bool Actor::updateStatus15_Chapter2_Actor11_Helper(ActorIndex actorIndex1, ActorIndex actorIndex2) {
Commit: f453ab6da76ac263de1d154f34708764c4904375
https://github.com/scummvm/scummvm/commit/f453ab6da76ac263de1d154f34708764c4904375
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:37:10+02:00
Commit Message:
ASYLUM: Implement Actor::updateStatus15_Chapter2()
Changed paths:
engines/asylum/resources/actor.cpp
diff --git a/engines/asylum/resources/actor.cpp b/engines/asylum/resources/actor.cpp
index 8f0054867c..cc3db73108 100644
--- a/engines/asylum/resources/actor.cpp
+++ b/engines/asylum/resources/actor.cpp
@@ -2409,7 +2409,86 @@ void Actor::updateStatus14_Chapter11() {
}
void Actor::updateStatus15_Chapter2() {
- error("[Actor::updateStatus15_Chapter2] not implemented!");
+ Actor *player = getScene()->getActor();
+
+ Common::Point sum = _point1 + _point2;
+ Common::Point sumPlayer = *player->getPoint1() + *player->getPoint2();
+
+ if (_status == kActorStatus17 || !getScene()->getActor(10)->isVisible()) {
+ updateStatus(kActorStatusEnabled);
+ getSharedData()->setData(_index - 8, 160);
+ }
+
+ if (_frameIndex == 1)
+ getSound()->playSound(getWorld()->soundResourceIds[1], false, Config.sfxVolume - 10);
+
+ if (player->getStatus() == kActorStatus17 && _frameIndex < 6)
+ updateStatus(kActorStatusEnabled);
+
+ uint32 dist = euclidianDistance(sumPlayer, sum);
+ uint32 offset = (dist <= 10) ? 7 : 12;
+ if (dist > 20) {
+ faceTarget(getScene()->getPlayerIndex(), kDirectionFromActor);
+ getScene()->getActor(_index + 9)->setDirection(_direction);
+ }
+
+ if (_frameIndex < 5 || !getSharedData()->getData2(_index))
+ _frameIndex++;
+
+ if (sumPlayer.x > sum.x)
+ _point1.x += offset;
+ else if (sumPlayer.x < sum.x)
+ _point1.x -= offset;
+
+ if (sumPlayer.y > sum.y)
+ _point1.y += offset;
+ else if (sumPlayer.y < sum.y)
+ _point1.y -= offset;
+
+ if (dist < (offset + 1)) {
+ if (player->getStatus() != kActorStatus16 && player->getStatus() != kActorStatus17 && player->getFrameIndex() < 6) {
+ _point1 = sumPlayer - _point2;
+
+ updateStatus15_Chapter2_Helper();
+ getSpeech()->playPlayer(51);
+ _vm->setGameFlag(kGameFlag219);
+
+ player->updateFromDirection((ActorDirection)((_direction + 4) & 7));
+ player->updateStatus(kActorStatus16);
+
+ getSharedData()->setData2(_index, 0);
+ }
+ }
+
+ if (_frameIndex > _frameCount - 1) {
+ switch (rnd(4)) {
+ default:
+ case 0:
+ sum.y -= 200;
+ break;
+
+ case 1:
+ sum.y += 200;
+ break;
+
+ case 2:
+ sum.x -= 200;
+ break;
+
+ case 3:
+ sum.x += 200;
+ break;
+ }
+
+ _frameIndex = 0;
+
+ if (getSharedData()->getData(40) <= 2)
+ processStatus(sum.x, sum.y, false);
+ else
+ updateStatus(kActorStatusEnabled);
+
+ getSharedData()->setData2(_index, 0);
+ }
}
void Actor::updateStatus15_Chapter2_Helper() {
Commit: fb8afdc6d62be10f644157299b98b70ac3ec4031
https://github.com/scummvm/scummvm/commit/fb8afdc6d62be10f644157299b98b70ac3ec4031
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:37:10+02:00
Commit Message:
ASYLUM: Palette and gamma functions update
- Identify dead code and remove unused parameters
- Rename several gamma and palette-relted functions
- Add stubs for palette fading functions
Changed paths:
engines/asylum/puzzles/board.cpp
engines/asylum/puzzles/clock.cpp
engines/asylum/puzzles/fisherman.cpp
engines/asylum/puzzles/hivecontrol.cpp
engines/asylum/puzzles/hivemachine.cpp
engines/asylum/puzzles/lock.cpp
engines/asylum/puzzles/morguedoor.cpp
engines/asylum/puzzles/pipes.cpp
engines/asylum/puzzles/puzzle11.cpp
engines/asylum/puzzles/tictactoe.cpp
engines/asylum/puzzles/timemachine.cpp
engines/asylum/puzzles/vcr.cpp
engines/asylum/puzzles/wheel.cpp
engines/asylum/puzzles/writings.cpp
engines/asylum/resources/actor.cpp
engines/asylum/resources/encounters.cpp
engines/asylum/resources/script.cpp
engines/asylum/resources/special.cpp
engines/asylum/system/screen.cpp
engines/asylum/system/screen.h
engines/asylum/views/menu.cpp
engines/asylum/views/scene.cpp
engines/asylum/views/scenetitle.cpp
diff --git a/engines/asylum/puzzles/board.cpp b/engines/asylum/puzzles/board.cpp
index c69a518883..985c4e4247 100644
--- a/engines/asylum/puzzles/board.cpp
+++ b/engines/asylum/puzzles/board.cpp
@@ -66,7 +66,7 @@ bool PuzzleBoard::init(const AsylumEvent &evt) {
_soundResourceId = 0;
getScreen()->setPalette(getWorld()->graphicResourceIds[32]);
- getScreen()->setGammaLevel(getWorld()->graphicResourceIds[32], 0);
+ getScreen()->setGammaLevel(getWorld()->graphicResourceIds[32]);
getText()->loadFont(getWorld()->graphicResourceIds[35]);
// Prepare text to draw
diff --git a/engines/asylum/puzzles/clock.cpp b/engines/asylum/puzzles/clock.cpp
index 369415db2d..e7d2824e9a 100644
--- a/engines/asylum/puzzles/clock.cpp
+++ b/engines/asylum/puzzles/clock.cpp
@@ -81,7 +81,7 @@ bool PuzzleClock::init(const AsylumEvent &evt) {
updateCursor();
getScreen()->setPalette(getWorld()->graphicResourceIds[6]);
- getScreen()->setGammaLevel(getWorld()->graphicResourceIds[6], 0);
+ getScreen()->setGammaLevel(getWorld()->graphicResourceIds[6]);
getCursor()->show();
diff --git a/engines/asylum/puzzles/fisherman.cpp b/engines/asylum/puzzles/fisherman.cpp
index cbba5f4ba0..3048e1a3e9 100644
--- a/engines/asylum/puzzles/fisherman.cpp
+++ b/engines/asylum/puzzles/fisherman.cpp
@@ -74,7 +74,7 @@ bool PuzzleFisherman::init(const AsylumEvent &evt) {
_dword_45A130 = false;
getScreen()->setPalette(getWorld()->graphicResourceIds[39]);
- getScreen()->setGammaLevel(getWorld()->graphicResourceIds[39], 0);
+ getScreen()->setGammaLevel(getWorld()->graphicResourceIds[39]);
return mouseLeftDown(evt);
}
@@ -163,7 +163,7 @@ bool PuzzleFisherman::mouseLeftDown(const AsylumEvent &evt) {
bool PuzzleFisherman::mouseRightDown(const AsylumEvent &evt) {
getCursor()->hide();
getSharedData()->setFlag(kFlag1, true);
- getScreen()->setupPaletteAndStartFade(0, 0, 0);
+ getScreen()->stopPaletteFade(0, 0, 0);
_vm->switchEventHandler(getScene());
diff --git a/engines/asylum/puzzles/hivecontrol.cpp b/engines/asylum/puzzles/hivecontrol.cpp
index 5065c7cc0a..7419d22b10 100644
--- a/engines/asylum/puzzles/hivecontrol.cpp
+++ b/engines/asylum/puzzles/hivecontrol.cpp
@@ -120,7 +120,7 @@ bool PuzzleHiveControl::init(const AsylumEvent &evt) {
_frameIndexes[kElementLever] = (5 - _leverPosition) * (GraphicResource::getFrameCount(_vm, getWorld()->graphicResourceIds[kElementLever]) - 1) / 5;
getScreen()->setPalette(getWorld()->graphicResourceIds[29]);
- getScreen()->setGammaLevel(getWorld()->graphicResourceIds[29], 0);
+ getScreen()->setGammaLevel(getWorld()->graphicResourceIds[29]);
getCursor()->show();
diff --git a/engines/asylum/puzzles/hivemachine.cpp b/engines/asylum/puzzles/hivemachine.cpp
index b2acbd8e34..71be69d382 100644
--- a/engines/asylum/puzzles/hivemachine.cpp
+++ b/engines/asylum/puzzles/hivemachine.cpp
@@ -167,7 +167,7 @@ PuzzleHiveMachine::~PuzzleHiveMachine() {
//////////////////////////////////////////////////////////////////////////
bool PuzzleHiveMachine::init(const AsylumEvent &evt) {
getScreen()->setPalette(getWorld()->graphicResourceIds[9]);
- getScreen()->setGammaLevel(getWorld()->graphicResourceIds[9], 0);
+ getScreen()->setGammaLevel(getWorld()->graphicResourceIds[9]);
_rectIndex = -2;
return true;
diff --git a/engines/asylum/puzzles/lock.cpp b/engines/asylum/puzzles/lock.cpp
index 2c1a29ed1c..c58a252381 100644
--- a/engines/asylum/puzzles/lock.cpp
+++ b/engines/asylum/puzzles/lock.cpp
@@ -58,7 +58,7 @@ bool PuzzleLock::init(const AsylumEvent &evt) {
getScreen()->clear();
getScreen()->setPalette(getWorld()->graphicResourceIds[14]);
- getScreen()->setGammaLevel(getWorld()->graphicResourceIds[14], 0);
+ getScreen()->setGammaLevel(getWorld()->graphicResourceIds[14]);
_vm->setGameFlag(kGameFlag115);
diff --git a/engines/asylum/puzzles/morguedoor.cpp b/engines/asylum/puzzles/morguedoor.cpp
index b707296323..2d353c4395 100644
--- a/engines/asylum/puzzles/morguedoor.cpp
+++ b/engines/asylum/puzzles/morguedoor.cpp
@@ -80,7 +80,7 @@ bool PuzzleMorgueDoor::init(const AsylumEvent &evt) {
_frameCounts[kBottomGear] = GraphicResource::getFrameCount(_vm, getWorld()->graphicResourceIds[32]);
getScreen()->setPalette(getWorld()->graphicResourceIds[20]);
- getScreen()->setGammaLevel(getWorld()->graphicResourceIds[20], 0);
+ getScreen()->setGammaLevel(getWorld()->graphicResourceIds[20]);
return mouseLeftDown(evt);
}
@@ -197,7 +197,7 @@ bool PuzzleMorgueDoor::mouseLeftDown(const AsylumEvent &evt) {
bool PuzzleMorgueDoor::mouseRightUp(const AsylumEvent &evt) {
getCursor()->hide();
getSharedData()->setFlag(kFlag1, true);
- getScreen()->setupPaletteAndStartFade(0, 0, 0);
+ getScreen()->stopPaletteFade(0, 0, 0);
_vm->switchEventHandler(getScene());
@@ -578,7 +578,7 @@ void PuzzleMorgueDoor::updateState() {
getCursor()->hide();
getSharedData()->setFlag(kFlag1, true);
- getScreen()->setupPaletteAndStartFade(0, 0, 0);
+ getScreen()->stopPaletteFade(0, 0, 0);
_vm->switchEventHandler(getScene());
}
diff --git a/engines/asylum/puzzles/pipes.cpp b/engines/asylum/puzzles/pipes.cpp
index 43ed59fef6..0723353b72 100644
--- a/engines/asylum/puzzles/pipes.cpp
+++ b/engines/asylum/puzzles/pipes.cpp
@@ -330,7 +330,7 @@ bool PuzzlePipes::init(const AsylumEvent &evt) {
getSound()->playSound(getWorld()->graphicResourceIds[41], true, Config.ambientVolume);
getScreen()->setPalette(getWorld()->graphicResourceIds[0]);
- getScreen()->setGammaLevel(getWorld()->graphicResourceIds[0], 0);
+ getScreen()->setGammaLevel(getWorld()->graphicResourceIds[0]);
_rectIndex = -2;
diff --git a/engines/asylum/puzzles/puzzle11.cpp b/engines/asylum/puzzles/puzzle11.cpp
index 4379bbb804..0198d93ec9 100644
--- a/engines/asylum/puzzles/puzzle11.cpp
+++ b/engines/asylum/puzzles/puzzle11.cpp
@@ -53,7 +53,7 @@ bool Puzzle11::init(const AsylumEvent &evt) {
getPuzzleData()->timeMachineCounter = 0;
getScreen()->setPalette(getWorld()->graphicResourceIds[12]);
- getScreen()->setGammaLevel(getWorld()->graphicResourceIds[12], 0);
+ getScreen()->setGammaLevel(getWorld()->graphicResourceIds[12]);
getCursor()->set(getWorld()->graphicResourceIds[60], -1, kCursorAnimationNone, 7);
_data_45AA34 = false;
@@ -94,7 +94,7 @@ bool Puzzle11::mouseRightDown(const AsylumEvent &evt) {
bool Puzzle11::mouseLeftUp(const AsylumEvent &evt) {
getCursor()->hide();
getSharedData()->setFlag(kFlag1, true);
- getScreen()->setupPaletteAndStartFade(0, 0, 0);
+ getScreen()->stopPaletteFade(0, 0, 0);
_vm->switchEventHandler(getScene());
diff --git a/engines/asylum/puzzles/tictactoe.cpp b/engines/asylum/puzzles/tictactoe.cpp
index 7aad84630d..8ccc7e2815 100644
--- a/engines/asylum/puzzles/tictactoe.cpp
+++ b/engines/asylum/puzzles/tictactoe.cpp
@@ -110,7 +110,7 @@ bool PuzzleTicTacToe::init(const AsylumEvent &evt) {
_strikeOutPosition = -1;
getScreen()->setPalette(getWorld()->graphicResourceIds[3]);
- getScreen()->setGammaLevel(getWorld()->graphicResourceIds[3], 0);
+ getScreen()->setGammaLevel(getWorld()->graphicResourceIds[3]);
getCursor()->show();
getCursor()->set(getWorld()->graphicResourceIds[12], 4, kCursorAnimationLinear, 4);
diff --git a/engines/asylum/puzzles/timemachine.cpp b/engines/asylum/puzzles/timemachine.cpp
index 3619c338f7..db94f4b48d 100644
--- a/engines/asylum/puzzles/timemachine.cpp
+++ b/engines/asylum/puzzles/timemachine.cpp
@@ -104,7 +104,7 @@ bool PuzzleTimeMachine::init(const AsylumEvent &evt) {
_frameCounts[5] = GraphicResource::getFrameCount(_vm, getWorld()->graphicResourceIds[40]);
getScreen()->setPalette(getWorld()->graphicResourceIds[41]);
- getScreen()->setGammaLevel(getWorld()->graphicResourceIds[41], 0);
+ getScreen()->setGammaLevel(getWorld()->graphicResourceIds[41]);
mouseLeftDown(evt);
@@ -160,7 +160,7 @@ bool PuzzleTimeMachine::update(const AsylumEvent &evt) {
if (_counter > 30 && _vm->isGameFlagSet(kGameFlag925)) {
getCursor()->hide();
getSharedData()->setFlag(kFlag1, true);
- getScreen()->setupPaletteAndStartFade(0, 0, 0);
+ getScreen()->stopPaletteFade(0, 0, 0);
_vm->switchEventHandler(getScene());
}
@@ -248,7 +248,7 @@ bool PuzzleTimeMachine::mouseLeftUp(const AsylumEvent &evt) {
bool PuzzleTimeMachine::mouseRightDown(const AsylumEvent &evt) {
getCursor()->hide();
getSharedData()->setFlag(kFlag1, true);
- getScreen()->setupPaletteAndStartFade(0, 0, 0);
+ getScreen()->stopPaletteFade(0, 0, 0);
_vm->switchEventHandler(getScene());
return true;
diff --git a/engines/asylum/puzzles/vcr.cpp b/engines/asylum/puzzles/vcr.cpp
index cdb0e7d8a3..7c4a7a2037 100644
--- a/engines/asylum/puzzles/vcr.cpp
+++ b/engines/asylum/puzzles/vcr.cpp
@@ -57,7 +57,7 @@ PuzzleVCR::~PuzzleVCR() {
bool PuzzleVCR::init(const AsylumEvent &evt) {
// Load the graphics palette
getScreen()->setPalette(getWorld()->graphicResourceIds[29]);
- getScreen()->setGammaLevel(getWorld()->graphicResourceIds[29], 0);
+ getScreen()->setGammaLevel(getWorld()->graphicResourceIds[29]);
if (_jacksState[kBlack] == kOnHand || _jacksState[kRed] == kOnHand || _jacksState[kYellow] == kOnHand) {
getCursor()->hide();
diff --git a/engines/asylum/puzzles/wheel.cpp b/engines/asylum/puzzles/wheel.cpp
index bd13453657..283ba395f5 100644
--- a/engines/asylum/puzzles/wheel.cpp
+++ b/engines/asylum/puzzles/wheel.cpp
@@ -172,7 +172,7 @@ bool PuzzleWheel::init(const AsylumEvent &evt) {
getSpecial()->reset(false);
getScreen()->setPalette(getWorld()->graphicResourceIds[1]);
- getScreen()->setGammaLevel(getWorld()->graphicResourceIds[1], 0);
+ getScreen()->setGammaLevel(getWorld()->graphicResourceIds[1]);
updateCursor();
getCursor()->show();
diff --git a/engines/asylum/puzzles/writings.cpp b/engines/asylum/puzzles/writings.cpp
index 748aa4b273..dd0f96413e 100644
--- a/engines/asylum/puzzles/writings.cpp
+++ b/engines/asylum/puzzles/writings.cpp
@@ -54,7 +54,7 @@ bool PuzzleWritings::init(const AsylumEvent &evt) {
_hasGlassMagnifier = false;
getScreen()->setPalette(getWorld()->graphicResourceIds[10]);
- getScreen()->setGammaLevel(getWorld()->graphicResourceIds[10], 0);
+ getScreen()->setGammaLevel(getWorld()->graphicResourceIds[10]);
if (_hasGlassMagnifier) {
getCursor()->hide();
@@ -71,10 +71,10 @@ bool PuzzleWritings::update(const AsylumEvent &evt) {
// Adjust palette
if (rnd(10) < 7) {
getScreen()->setPalette(getWorld()->graphicResourceIds[6]);
- getScreen()->setGammaLevel(getWorld()->graphicResourceIds[6], 0);
+ getScreen()->setGammaLevel(getWorld()->graphicResourceIds[6]);
} else {
getScreen()->setPalette(getWorld()->graphicResourceIds[10]);
- getScreen()->setGammaLevel(getWorld()->graphicResourceIds[10], 0);
+ getScreen()->setGammaLevel(getWorld()->graphicResourceIds[10]);
}
// Compute frame index
@@ -113,7 +113,7 @@ bool PuzzleWritings::update(const AsylumEvent &evt) {
bool PuzzleWritings::mouseRightUp(const AsylumEvent &evt) {
getCursor()->hide();
getSharedData()->setFlag(kFlag1, true);
- getScreen()->setupPaletteAndStartFade(0, 0, 0);
+ getScreen()->stopPaletteFade(0, 0, 0);
_vm->switchEventHandler(getScene());
diff --git a/engines/asylum/resources/actor.cpp b/engines/asylum/resources/actor.cpp
index cc3db73108..41c4b39e06 100644
--- a/engines/asylum/resources/actor.cpp
+++ b/engines/asylum/resources/actor.cpp
@@ -2984,7 +2984,7 @@ void Actor::updateStatus21() {
if (_frameIndex == _frameCount / 2) {
getWorld()->currentPaletteId = getWorld()->graphicResourceIds[getWorld()->nextPlayer - 1];
getScreen()->setPalette(getWorld()->currentPaletteId);
- getScreen()->setGammaLevel(getWorld()->currentPaletteId, 0);
+ getScreen()->setGammaLevel(getWorld()->currentPaletteId);
}
return;
@@ -2997,7 +2997,7 @@ void Actor::updateStatus21() {
getScreen()->setPalette(getWorld()->graphicResourceIds[getWorld()->nextPlayer - 1]);
getWorld()->currentPaletteId = getWorld()->graphicResourceIds[getWorld()->nextPlayer - 1];
- getScreen()->setGammaLevel(getWorld()->currentPaletteId, 0);
+ getScreen()->setGammaLevel(getWorld()->currentPaletteId);
return;
}
}
diff --git a/engines/asylum/resources/encounters.cpp b/engines/asylum/resources/encounters.cpp
index e7f040f434..bdb51b4209 100644
--- a/engines/asylum/resources/encounters.cpp
+++ b/engines/asylum/resources/encounters.cpp
@@ -1609,7 +1609,7 @@ void Encounter::runScript() {
case 23:
if (!getSharedData()->matteBarHeight) {
- getScreen()->makeGreyPalette();
+ getScreen()->loadPalette();
getSharedData()->matteBarHeight = 1;
getSharedData()->movieIndex = getVariableInv(entry.param2);
getSharedData()->matteVar1 = 1;
diff --git a/engines/asylum/resources/script.cpp b/engines/asylum/resources/script.cpp
index ca508de6f1..809fff9af6 100644
--- a/engines/asylum/resources/script.cpp
+++ b/engines/asylum/resources/script.cpp
@@ -965,7 +965,7 @@ IMPLEMENT_OPCODE(PlayMovie)
if (!getSharedData()->matteBarHeight) {
getCursor()->hide();
- getScreen()->makeGreyPalette();
+ getScreen()->loadPalette();
getSharedData()->matteVar1 = 1;
getSharedData()->matteBarHeight = 1;
getSharedData()->matteVar2 = 0;
@@ -981,10 +981,10 @@ IMPLEMENT_OPCODE(PlayMovie)
ActionArea *area = getWorld()->actions[getScene()->getActor()->getActionIndex3()];
if (area->paletteResourceId) {
getScreen()->setPalette(area->paletteResourceId);
- getScreen()->setGammaLevel(area->paletteResourceId, 0);
+ getScreen()->setGammaLevel(area->paletteResourceId);
} else {
getScreen()->setPalette(getWorld()->currentPaletteId);
- getScreen()->setGammaLevel(getWorld()->currentPaletteId, 0);
+ getScreen()->setGammaLevel(getWorld()->currentPaletteId);
}
getSharedData()->matteBarHeight = 0;
@@ -1128,7 +1128,7 @@ END_OPCODE
// Opcode 0x3B
IMPLEMENT_OPCODE(CreatePalette)
if (!cmd->param2) {
- getScreen()->makeGreyPalette();
+ getScreen()->loadPalette();
cmd->param2 = 1;
}
@@ -1699,7 +1699,7 @@ END_OPCODE
IMPLEMENT_OPCODE(SetResourcePalette)
getWorld()->currentPaletteId = getWorld()->graphicResourceIds[cmd->param1];
getScreen()->setPalette(getWorld()->currentPaletteId);
- getScreen()->setGammaLevel(getWorld()->currentPaletteId, 0);
+ getScreen()->setGammaLevel(getWorld()->currentPaletteId);
END_OPCODE
//////////////////////////////////////////////////////////////////////////
diff --git a/engines/asylum/resources/special.cpp b/engines/asylum/resources/special.cpp
index d1dd1ae88d..20ad9f5fd9 100644
--- a/engines/asylum/resources/special.cpp
+++ b/engines/asylum/resources/special.cpp
@@ -1250,7 +1250,7 @@ void Special::setPaletteGamma(ResourceId palette1, ResourceId palette2) {
_paletteTick1 = _vm->getTick() + 5000;
} else {
getScreen()->setPalette(palette1);
- getScreen()->setGammaLevel(palette1, 0);
+ getScreen()->setGammaLevel(palette1);
_chapter5Counter = 1;
}
}
@@ -1259,19 +1259,19 @@ void Special::setPaletteGamma(ResourceId palette1, ResourceId palette2) {
case 500:
getScreen()->setPalette(palette2);
- getScreen()->setGammaLevel(palette2, 0);
+ getScreen()->setGammaLevel(palette2);
++_chapter5Counter;
break;
case 1000:
getScreen()->setPalette(palette1);
- getScreen()->setGammaLevel(palette1, 0);
+ getScreen()->setGammaLevel(palette1);
++_chapter5Counter;
break;
case 1500:
getScreen()->setPalette(palette2);
- getScreen()->setGammaLevel(palette2, 0);
+ getScreen()->setGammaLevel(palette2);
_chapter5Counter = 0;
_paletteFlag = true;
_paletteTick2 = _vm->getTick() + rnd(1000) + 1000;
diff --git a/engines/asylum/system/screen.cpp b/engines/asylum/system/screen.cpp
index a09e403557..fbdc007b25 100644
--- a/engines/asylum/system/screen.cpp
+++ b/engines/asylum/system/screen.cpp
@@ -22,6 +22,8 @@
#include "asylum/system/screen.h"
+#include "asylum/resources/actor.h"
+#include "asylum/resources/script.h"
#include "asylum/resources/worldstats.h"
#include "asylum/system/graphics.h"
@@ -46,6 +48,9 @@ Screen::Screen(AsylumEngine *vm) : _vm(vm) ,
_flag = -1;
_clipRect = Common::Rect(0, 0, 640, 480);
+ memset(&_currentPalette, 0, sizeof(_currentPalette));
+ memset(&_mainPalette, 0, sizeof(_mainPalette));
+
g_debugDrawRects = 0;
}
@@ -235,103 +240,166 @@ void Screen::takeScreenshot() {
//////////////////////////////////////////////////////////////////////////
// Palette
//////////////////////////////////////////////////////////////////////////
-void Screen::setPalette(ResourceId id) {
- setPalette(getResource()->get(id)->data + 32);
+byte *Screen::getPaletteData(ResourceId id) {
+ ResourceEntry *resource = getResource()->get(id);
+
+ // Check that resource is a valid palette
+ byte flag = *(resource->data + 5);
+ if (!(flag & 32))
+ error("[Screen::getPaletteData] Invalid palette resource id %d (0x%X) with flag %d", id, id, flag);
+
+ return (resource->data + resource->getData(12));
}
-void Screen::setPalette(byte *rgbPalette) const {
- byte palette[256 * 3];
- byte *p = rgbPalette;
+void Screen::loadPalette() {
+ // Get the current action palette
+ ResourceId paletteId = getWorld()->actions[getScene()->getActor()->getActionIndex3()]->paletteResourceId;
+ if (!paletteId)
+ paletteId = getWorld()->currentPaletteId;
- // skip first color and set it to black always.
- memset(palette, 0, 3);
- p += 3;
+ // Get the data
+ byte *paletteData = getPaletteData(paletteId);
- for (int32 i = 1; i < 256; i++) {
- palette[i * 3 + 0] = (byte)(*p++ << 2);
- palette[i * 3 + 1] = (byte)(*p++ << 2);
- palette[i * 3 + 2] = (byte)(*p++ << 2);
- }
+ // Store data into our global palette
+ memcpy(&_currentPalette, paletteData, sizeof(_currentPalette));
+}
- _vm->_system->getPaletteManager()->setPalette(palette, 0, 256);
+void Screen::setPalette(ResourceId id) {
+ byte *data = getPaletteData(id);
+
+ setupPalette(data + 4, data[2], *(uint16 *)data);
}
-void Screen::setPaletteGamma(ResourceId id) {
- byte *resPalette = getResource()->get(id)->data + 32;
- byte rgbPalette[256 * 3];
+void Screen::setupPalette(byte *buffer, int start, int count) {
+ // Check parameters
+ if (start < 0 || start > 256)
+ error("[Screen::setupPalette] Invalid start parameter (was: %d, valid: [0 ; 255])", start);
- _vm->_system->getPaletteManager()->grabPalette(rgbPalette, 0, 256);
+ if ((count + start) > 256)
+ error("[Screen::setupPalette] Parameters go past the palette buffer (start: %d, count: %d with sum > 256)", start, count);
- for (int32 i = 1; i < 256; i++) {
- int color = 0;
- if (resPalette[i * 3 + 0] > 0)
- color = resPalette[i * 3 + 0];
- if (resPalette[i * 3 + 1] > color)
- color = resPalette[i * 3 + 1];
- if (resPalette[i * 3 + 2] > color)
- color = resPalette[i * 3 + 2];
+ // TODO: Update transparent palette if needed
- int gamma = color + (Config.gammaLevel * (63 - color) + 31) / 63;
+ // Setup our main palette
+ if (count > 0) {
+ byte *palette = (byte *)_mainPalette;
+ palette += 4 * start;
- if (gamma) {
- if (resPalette[i * 3 + 0])
- rgbPalette[i * 3 + 0] = 4 * ((color >> 1) + resPalette[i * 3 + 0] * gamma) / color;
- if (resPalette[i * 3 + 1])
- rgbPalette[i * 3 + 1] = 4 * ((color >> 1) + resPalette[i * 3 + 1] * gamma) / color;
- if (resPalette[i * 3 + 2])
- rgbPalette[i * 3 + 2] = 4 * ((color >> 1) + resPalette[i * 3 + 2] * gamma) / color;
+ for (int32 i = 0; i < count; i++) {
+ palette[0] = buffer[0] * 4;
+ palette[1] = buffer[1] * 4;
+ palette[2] = buffer[2] * 4;
+
+ buffer += 3;
+ palette += 3;
}
}
- _vm->_system->getPaletteManager()->setPalette(rgbPalette, 0, 256);
-}
-
-void Screen::setupPaletteAndStartFade(uint32 red, int32 milliseconds, int32 param) {
- warning("[Screen::setupPaletteAndStartFade] Not implemented!");
+ // Change the system palette
+ _vm->_system->getPaletteManager()->setPalette(_mainPalette, 0, 256);
}
-void Screen::stopFadeAndSetPalette(ResourceId id, int32 milliseconds, int32 param) {
- // HACK so we have a proper screen palette
- setPalette(id);
- warning("[Screen::stopFadeAndSetPalette] Not implemented!");
+void Screen::updatePalette() {
+ // FIXME: This is used to replace all the inline code to setup the palette before calls to setupPalette/paletteFade
+ // See if all that code can really be factorized into a single function or not
+ error("[Screen::updatePalette] Not implemented!");
}
-void Screen::paletteFade(uint32 red, int32 milliseconds, int32 param) {
- warning("[Screen::paletteFade] Not implemented!");
+void Screen::updatePalette(int32 param) {
+ error("[Screen::updatePalette] Not implemented!");
}
void Screen::startPaletteFade(ResourceId resourceId, int32 milliseconds, int32 param) {
warning("[Screen::startPaletteFade] Not implemented!");
}
-void Screen::updatePalette() {
- error("[Screen::updatePalette] Not implemented!");
+void Screen::stopPaletteFade(char red, char green, char blue) {
+ // Setup main palette
+ byte *palette = (byte *)&_mainPalette;
+ palette += 4;
+
+ for (uint32 i = 0; i < ARRAYSIZE(_mainPalette) - 4; i += 4) {
+ palette[0] = red;
+ palette[1] = green;
+ palette[2] = blue;
+
+ palette += 3;
+ }
+
+ stopPaletteFadeTimer();
+ setupPalette(0, 0, 0);
}
-void Screen::updatePalette(int32 param) {
- error("[Screen::updatePalette] Not implemented!");
+void Screen::stopPaletteFadeAndSet(ResourceId id, int32 milliseconds, int32 param) {
+ stopPaletteFadeTimer();
+ paletteFadeWorker(id, milliseconds, param);
}
-void Screen::makeGreyPalette() {
- warning("[Screen::makeGreyPalette] Not implemented!");
+void Screen::paletteFade(uint32 red, int32 milliseconds, int32 param) {
+ if (red < 0 || red > 255 || milliseconds < 0 || param <= 0)
+ return;
+
+ warning("[Screen::paletteFade] Not implemented!");
}
-void Screen::setupPalette(byte *buffer, int start, int count) {
- warning("[Screen::setupPalette] Not implemented!");
+void Screen::paletteFadeWorker(ResourceId id, int32 milliseconds, int32 param) {
+ warning("[Screen::paletteFadeWorker] Not implemented!");
+
+ // HACK setup a proper palette
+ setPalette(id);
+}
+
+void Screen::stopPaletteFadeTimer() {
+ warning("[Screen::stopPaletteFadeTimer] Not implemented!");
}
//////////////////////////////////////////////////////////////////////////
// Gamma
//////////////////////////////////////////////////////////////////////////
-void Screen::setGammaLevel(ResourceId id, int32 val) {
- if (Config.gammaLevel) {
- if (id)
- setPaletteGamma(id);
- else
- warning("[Screen::setGammaLevel] Palette creation without a valid resource Id not implemented");
+void Screen::setPaletteGamma(ResourceId id) {
+ setPaletteGamma(getPaletteData(id));
+}
+
+void Screen::setPaletteGamma(byte *data, byte *target) {
+ if (target == NULL)
+ target = (byte *)&_mainPalette;
+
+ // Skip first entry
+ data += 4;
+
+ for (int32 i = 1; i < 256; i++) {
+ int color = 0;
+ if (data[i * 3 + 0] > 0)
+ color = data[i * 3 + 0];
+ if (data[i * 3 + 1] > color)
+ color = data[i * 3 + 1];
+ if (data[i * 3 + 2] > color)
+ color = data[i * 3 + 2];
+
+ int gamma = color + (Config.gammaLevel * (63 - color) + 31) / 63;
+
+ if (gamma) {
+ if (data[i * 3 + 0])
+ target[i * 3 + 0] = 4 * ((color >> 1) + data[i * 3 + 0] * gamma) / color;
+ if (data[i * 3 + 1])
+ target[i * 3 + 1] = 4 * ((color >> 1) + data[i * 3 + 1] * gamma) / color;
+ if (data[i * 3 + 2])
+ target[i * 3 + 2] = 4 * ((color >> 1) + data[i * 3 + 2] * gamma) / color;
+ }
}
}
+void Screen::setGammaLevel(ResourceId id) {
+ if (!Config.gammaLevel)
+ return;
+
+ if (!id)
+ error("[Screen::setGammaLevel] Resource Id is invalid");
+
+ setPaletteGamma(getPaletteData(id));
+ setupPalette(0, 0, 0);
+}
+
//////////////////////////////////////////////////////////////////////////
// Transparency tables
//////////////////////////////////////////////////////////////////////////
diff --git a/engines/asylum/system/screen.h b/engines/asylum/system/screen.h
index b726d22fef..f7be347463 100644
--- a/engines/asylum/system/screen.h
+++ b/engines/asylum/system/screen.h
@@ -91,20 +91,20 @@ public:
void takeScreenshot();
// Palette
- void setPalette(byte *rgbPalette) const;
void setPalette(ResourceId id);
- void setPaletteGamma(ResourceId id);
- void setupPaletteAndStartFade(uint32 red, int32 milliseconds, int32 param);
- void stopFadeAndSetPalette(ResourceId id, int32 milliseconds, int32 param);
- void paletteFade(uint32 red, int32 milliseconds, int32 param);
- void startPaletteFade(ResourceId resourceId, int32 milliseconds, int32 param);
+ void loadPalette();
void updatePalette();
void updatePalette(int32 param);
- void makeGreyPalette();
void setupPalette(byte *buffer, int start, int count);
+ void stopPaletteFade(char red, char green, char blue);
+ void stopPaletteFadeAndSet(ResourceId id, int32 milliseconds, int32 param);
+ void paletteFade(uint32 red, int32 milliseconds, int32 param);
+ void startPaletteFade(ResourceId resourceId, int32 milliseconds, int32 param);
+
// Gamma
- void setGammaLevel(ResourceId id, int32 val);
+ void setPaletteGamma(ResourceId id);
+ void setGammaLevel(ResourceId id);
// Transparency tables
void setupTransTable(ResourceId resourceId);
@@ -144,6 +144,16 @@ private:
byte *_transTableBuffer;
void clearTransTables();
+ // Palette
+ byte _currentPalette[256 * 4];
+ byte _mainPalette[256 * 4];
+
+ byte *getPaletteData(ResourceId id);
+ void setPaletteGamma(byte *data, byte *target = NULL);
+
+ void paletteFadeWorker(ResourceId id, int32 milliseconds, int32 param);
+ void stopPaletteFadeTimer();
+
// Graphic queue
void graphicsSelectionSort();
void swapGraphicItem(int32 item1, int32 item2);
diff --git a/engines/asylum/views/menu.cpp b/engines/asylum/views/menu.cpp
index b9609860d0..0da5504302 100644
--- a/engines/asylum/views/menu.cpp
+++ b/engines/asylum/views/menu.cpp
@@ -114,7 +114,7 @@ void Menu::setup() {
if (_vm->isGameFlagSet(kGameFlagFinishGame)) {
getText()->loadFont(MAKE_RESOURCE(kResourcePackShared, 32));
getScreen()->setPalette(MAKE_RESOURCE(kResourcePackShared, 31));
- getScreen()->setGammaLevel(MAKE_RESOURCE(kResourcePackShared, 31), 0);
+ getScreen()->setGammaLevel(MAKE_RESOURCE(kResourcePackShared, 31));
getScreen()->setupTransTables(4, MAKE_RESOURCE(kResourcePackShared, 34),
MAKE_RESOURCE(kResourcePackShared, 35),
MAKE_RESOURCE(kResourcePackShared, 36),
@@ -128,7 +128,7 @@ void Menu::setup() {
} else {
getText()->loadFont(MAKE_RESOURCE(kResourcePackShared, 25));
getScreen()->setPalette(MAKE_RESOURCE(kResourcePackShared, 26));
- getScreen()->setGammaLevel(MAKE_RESOURCE(kResourcePackShared, 26), 0);
+ getScreen()->setGammaLevel(MAKE_RESOURCE(kResourcePackShared, 26));
getScreen()->setupTransTables(4, MAKE_RESOURCE(kResourcePackShared, 27),
MAKE_RESOURCE(kResourcePackShared, 28),
MAKE_RESOURCE(kResourcePackShared, 29),
@@ -159,7 +159,7 @@ void Menu::closeCredits() {
getText()->loadFont(kFontYellow);
getScreen()->setPalette(MAKE_RESOURCE(kResourcePackShared, 17));
- getScreen()->setGammaLevel(MAKE_RESOURCE(kResourcePackShared, 17), 0);
+ getScreen()->setGammaLevel(MAKE_RESOURCE(kResourcePackShared, 17));
getScreen()->setupTransTables(4, MAKE_RESOURCE(kResourcePackShared, 18),
MAKE_RESOURCE(kResourcePackShared, 19),
MAKE_RESOURCE(kResourcePackShared, 20),
@@ -388,7 +388,7 @@ bool Menu::init() {
getScreen()->clear();
getText()->loadFont(kFontYellow);
getScreen()->setPalette(MAKE_RESOURCE(kResourcePackShared, 17));
- getScreen()->setGammaLevel(MAKE_RESOURCE(kResourcePackShared, 17), 0);
+ getScreen()->setGammaLevel(MAKE_RESOURCE(kResourcePackShared, 17));
getScreen()->setupTransTables(4, MAKE_RESOURCE(kResourcePackShared, 18),
MAKE_RESOURCE(kResourcePackShared, 19),
MAKE_RESOURCE(kResourcePackShared, 20),
@@ -2178,7 +2178,7 @@ void Menu::clickSettings() {
return;
Config.gammaLevel -= 1;
- getScreen()->setGammaLevel(MAKE_RESOURCE(kResourcePackShared, 17), 0);
+ getScreen()->setGammaLevel(MAKE_RESOURCE(kResourcePackShared, 17));
return;
}
@@ -2191,7 +2191,7 @@ void Menu::clickSettings() {
Config.gammaLevel += 1;
- getScreen()->setGammaLevel(MAKE_RESOURCE(kResourcePackShared, 17), 0);
+ getScreen()->setGammaLevel(MAKE_RESOURCE(kResourcePackShared, 17));
return;
}
diff --git a/engines/asylum/views/scene.cpp b/engines/asylum/views/scene.cpp
index 799acdff57..11e9f3cf77 100644
--- a/engines/asylum/views/scene.cpp
+++ b/engines/asylum/views/scene.cpp
@@ -357,8 +357,8 @@ bool Scene::init() {
paletteResource = _ws->currentPaletteId;
getScreen()->setPalette(paletteResource);
- getScreen()->setGammaLevel(paletteResource, 0);
- getScreen()->makeGreyPalette();
+ getScreen()->setGammaLevel(paletteResource);
+ getScreen()->loadPalette();
getScreen()->setupTransTables(3, _ws->cellShadeMask1, _ws->cellShadeMask2, _ws->cellShadeMask3);
getScreen()->selectTransTable(1);
@@ -624,12 +624,12 @@ bool Scene::updateScreen() {
if (getSharedData()->getFlag(kFlagScene1)) {
getScreen()->clear();
- getScreen()->setupPaletteAndStartFade(0, 0, 0);
+ getScreen()->stopPaletteFade(0, 0, 0);
updateScene();
drawScene();
getScreen()->copyBackBufferToScreen();
- getScreen()->stopFadeAndSetPalette(getWorld()->currentPaletteId, 100, 10);
+ getScreen()->stopPaletteFadeAndSet(getWorld()->currentPaletteId, 100, 10);
drawScene();
getScreen()->copyBackBufferToScreen();
@@ -1781,7 +1781,7 @@ void Scene::playIntroSpeech() {
}
getScreen()->clear();
- getScreen()->setupPaletteAndStartFade(0, 0, 0);
+ getScreen()->stopPaletteFade(0, 0, 0);
do {
// Poll events (this ensure we don't freeze the screen)
@@ -2218,7 +2218,7 @@ void Scene::changePlayer(ActorIndex index) {
getScreen()->setPalette(_ws->graphicResourceIds[0]);
_ws->currentPaletteId = _ws->graphicResourceIds[0];
- getScreen()->setGammaLevel(_ws->graphicResourceIds[0], 0);
+ getScreen()->setGammaLevel(_ws->graphicResourceIds[0]);
_vm->setGameFlag(kGameFlag635);
_vm->clearGameFlag(kGameFlag636);
_vm->clearGameFlag(kGameFlag637);
@@ -2235,7 +2235,7 @@ void Scene::changePlayer(ActorIndex index) {
getScreen()->setPalette(_ws->graphicResourceIds[1]);
_ws->currentPaletteId = _ws->graphicResourceIds[1];
- getScreen()->setGammaLevel(_ws->graphicResourceIds[1], 0);
+ getScreen()->setGammaLevel(_ws->graphicResourceIds[1]);
_vm->setGameFlag(kGameFlag636);
_vm->clearGameFlag(kGameFlag635);
_vm->clearGameFlag(kGameFlag637);
@@ -2252,7 +2252,7 @@ void Scene::changePlayer(ActorIndex index) {
getScreen()->setPalette(_ws->graphicResourceIds[2]);
_ws->currentPaletteId = _ws->graphicResourceIds[2];
- getScreen()->setGammaLevel(_ws->graphicResourceIds[2], 0);
+ getScreen()->setGammaLevel(_ws->graphicResourceIds[2]);
_vm->setGameFlag(kGameFlag637);
_vm->clearGameFlag(kGameFlag635);
_vm->clearGameFlag(kGameFlag636);
diff --git a/engines/asylum/views/scenetitle.cpp b/engines/asylum/views/scenetitle.cpp
index 4733ada70e..464040b651 100644
--- a/engines/asylum/views/scenetitle.cpp
+++ b/engines/asylum/views/scenetitle.cpp
@@ -50,7 +50,7 @@ void SceneTitle::load() {
getScreen()->clear();
getScreen()->setPalette(getWorld()->sceneTitlePaletteResourceId);
getScreen()->paletteFade(0, 1, 1);
- getScreen()->setGammaLevel(getWorld()->sceneTitlePaletteResourceId, 0);
+ getScreen()->setGammaLevel(getWorld()->sceneTitlePaletteResourceId);
getText()->loadFont(MAKE_RESOURCE(kResourcePackSound, 18));
Commit: 86126add5f3b52d34f6dbc579848a0fd405c11ed
https://github.com/scummvm/scummvm/commit/86126add5f3b52d34f6dbc579848a0fd405c11ed
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:37:10+02:00
Commit Message:
ASYLUM: Implement palette fading timer and related functions
Changed paths:
engines/asylum/system/screen.cpp
engines/asylum/system/screen.h
diff --git a/engines/asylum/system/screen.cpp b/engines/asylum/system/screen.cpp
index fbdc007b25..e10944e451 100644
--- a/engines/asylum/system/screen.cpp
+++ b/engines/asylum/system/screen.cpp
@@ -33,6 +33,8 @@
#include "asylum/asylum.h"
#include "asylum/respack.h"
+#include "common/timer.h"
+
#include <stdarg.h> // For va_list etc.
namespace Asylum {
@@ -50,11 +52,18 @@ Screen::Screen(AsylumEngine *vm) : _vm(vm) ,
memset(&_currentPalette, 0, sizeof(_currentPalette));
memset(&_mainPalette, 0, sizeof(_mainPalette));
+ _isFading = false;
+ _fadeStop = false;
+ _fadeResourceId = kResourceNone;
+ _fadeTicksWait = 0;
+ _fadeDelta = 0;
g_debugDrawRects = 0;
}
Screen::~Screen() {
+ _vm->getTimerManager()->removeTimerProc(&paletteFadeTimer);
+
_backBuffer.free();
clearTransTables();
@@ -309,8 +318,39 @@ void Screen::updatePalette(int32 param) {
error("[Screen::updatePalette] Not implemented!");
}
-void Screen::startPaletteFade(ResourceId resourceId, int32 milliseconds, int32 param) {
- warning("[Screen::startPaletteFade] Not implemented!");
+//////////////////////////////////////////////////////////////////////////
+// Palette fading
+//////////////////////////////////////////////////////////////////////////
+void Screen::paletteFadeTimer(void *refCon) {
+ ((Screen *)refCon)->handlePaletteFadeTimer();
+}
+
+void Screen::handlePaletteFadeTimer() {
+ // Reset flag
+ _fadeStop = false;
+
+ // Start fading
+ _isFading = true;
+
+ paletteFadeWorker(_fadeResourceId, _fadeTicksWait, _fadeDelta);
+
+ // Remove ourselves as a timer (we finished fading or were interrupted)
+ _vm->getTimerManager()->removeTimerProc(&paletteFadeTimer);
+
+ _isFading = false;
+}
+
+void Screen::startPaletteFade(ResourceId resourceId, int32 ticksWait, int32 delta) {
+ if (_isFading && resourceId == _fadeResourceId)
+ return;
+
+ stopPaletteFadeTimer();
+ _fadeResourceId = resourceId;
+ _fadeTicksWait = ticksWait;
+ _fadeDelta = delta;
+
+ // Inverval == 1: we want to execute directly, since we are only going to be called back once
+ _vm->getTimerManager()->installTimerProc(&paletteFadeTimer, 1, this);
}
void Screen::stopPaletteFade(char red, char green, char blue) {
@@ -318,7 +358,7 @@ void Screen::stopPaletteFade(char red, char green, char blue) {
byte *palette = (byte *)&_mainPalette;
palette += 4;
- for (uint32 i = 0; i < ARRAYSIZE(_mainPalette) - 4; i += 4) {
+ for (uint32 i = 0; i < ARRAYSIZE(_mainPalette) - 3; i += 3) {
palette[0] = red;
palette[1] = green;
palette[2] = blue;
@@ -330,27 +370,80 @@ void Screen::stopPaletteFade(char red, char green, char blue) {
setupPalette(0, 0, 0);
}
-void Screen::stopPaletteFadeAndSet(ResourceId id, int32 milliseconds, int32 param) {
+void Screen::stopPaletteFadeAndSet(ResourceId id, int32 ticksWait, int32 delta) {
stopPaletteFadeTimer();
- paletteFadeWorker(id, milliseconds, param);
+ paletteFadeWorker(id, ticksWait, delta);
}
-void Screen::paletteFade(uint32 red, int32 milliseconds, int32 param) {
- if (red < 0 || red > 255 || milliseconds < 0 || param <= 0)
+void Screen::paletteFade(uint32 start, int32 ticksWait, int32 delta) {
+ if (start < 0 || start > 255 || ticksWait < 0 || delta <= 0)
return;
warning("[Screen::paletteFade] Not implemented!");
}
-void Screen::paletteFadeWorker(ResourceId id, int32 milliseconds, int32 param) {
- warning("[Screen::paletteFadeWorker] Not implemented!");
+void Screen::paletteFadeWorker(ResourceId id, int32 ticksWait, int32 delta) {
+ byte *data = getPaletteData(id);
+
+ if (ticksWait < 0 || delta <= 0)
+ return;
- // HACK setup a proper palette
- setPalette(id);
+ // Setup our palette
+ byte original[256 * 3];
+ byte palette[256 * 3];
+ memcpy(&original, &_mainPalette, sizeof(original));
+ memcpy(&palette, &_mainPalette, sizeof(palette));
+
+ // Adjust palette using the target palette data
+ uint32 count = *(int16 *)data;
+ uint32 start = data[2];
+ if (count > 0) {
+ byte *pData = data + 4;
+
+ for (uint32 i = 0; i < count; i++) {
+ palette[i + start] = 4 * pData[0];
+ palette[i + start + 1] = 4 * pData[1];
+ palette[i + start + 2] = 4 * pData[2];
+
+ pData += 3;
+ }
+ }
+
+ // Adjust gamma
+ setPaletteGamma(data, (byte *)&palette);
+
+ // Prepare for palette fading loop
+ uint32 colorDelta = delta + 1;
+
+ for (uint32 i = 1; i < (uint32)(delta + 1); i++) {
+ for (uint32 j = 3; j < ARRAYSIZE(_mainPalette) - 3; j += 3) {
+ _mainPalette[j] = original[j] + i * (palette[j] - original[j]) / colorDelta;
+ _mainPalette[j + 1] = original[j + 1] + i * (palette[j + 1] - original[j + 1]) / colorDelta;
+ _mainPalette[j + 2] = original[j + 2] + i * (palette[j + 2] - original[j + 2]) / colorDelta;
+ }
+
+ setupPalette(0, 0, 0);
+
+ g_system->delayMillis(ticksWait);
+ if (_fadeStop)
+ break;
+
+ // Poll events (this ensure we don't freeze the screen)
+ Common::Event ev;
+ do {
+ } while (_vm->getEventManager()->pollEvent(ev));
+
+ // Refresh the screen
+ g_system->updateScreen();
+ }
}
void Screen::stopPaletteFadeTimer() {
- warning("[Screen::stopPaletteFadeTimer] Not implemented!");
+ if (!_isFading)
+ return;
+
+ // Signal timer to exit its main loop
+ _fadeStop = true;
}
//////////////////////////////////////////////////////////////////////////
diff --git a/engines/asylum/system/screen.h b/engines/asylum/system/screen.h
index f7be347463..49d3f7f0ff 100644
--- a/engines/asylum/system/screen.h
+++ b/engines/asylum/system/screen.h
@@ -97,10 +97,10 @@ public:
void updatePalette(int32 param);
void setupPalette(byte *buffer, int start, int count);
+ void startPaletteFade(ResourceId resourceId, int32 ticksWait, int32 delta);
+ void paletteFade(uint32 start, int32 ticksWait, int32 delta);
void stopPaletteFade(char red, char green, char blue);
- void stopPaletteFadeAndSet(ResourceId id, int32 milliseconds, int32 param);
- void paletteFade(uint32 red, int32 milliseconds, int32 param);
- void startPaletteFade(ResourceId resourceId, int32 milliseconds, int32 param);
+ void stopPaletteFadeAndSet(ResourceId id, int32 ticksWait, int32 delta);
// Gamma
void setPaletteGamma(ResourceId id);
@@ -128,6 +128,11 @@ public:
void drawRect(const Common::Rect &rect, uint32 color = 0xFF);
void copyToBackBufferClipped(Graphics::Surface *surface, int x, int y);
+protected:
+ // Palette fading Timer
+ static void paletteFadeTimer(void *ptr);
+ void handlePaletteFadeTimer();
+
private:
AsylumEngine *_vm;
@@ -145,13 +150,19 @@ private:
void clearTransTables();
// Palette
- byte _currentPalette[256 * 4];
- byte _mainPalette[256 * 4];
+ byte _currentPalette[256 * 3];
+ byte _mainPalette[256 * 3];
+ bool _isFading;
+ bool _fadeStop;
+ ResourceId _fadeResourceId;
+ int32 _fadeTicksWait;
+ int32 _fadeDelta;
+
byte *getPaletteData(ResourceId id);
void setPaletteGamma(byte *data, byte *target = NULL);
- void paletteFadeWorker(ResourceId id, int32 milliseconds, int32 param);
+ void paletteFadeWorker(ResourceId id, int32 ticksWait, int32 delta);
void stopPaletteFadeTimer();
// Graphic queue
Commit: 6475c3d9f993cd871f2a17715ae695786a1f6cd5
https://github.com/scummvm/scummvm/commit/6475c3d9f993cd871f2a17715ae695786a1f6cd5
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:37:10+02:00
Commit Message:
ASYLUM: Implement Screen::paletteFade()
Changed paths:
engines/asylum/system/screen.cpp
diff --git a/engines/asylum/system/screen.cpp b/engines/asylum/system/screen.cpp
index e10944e451..441fcf99ca 100644
--- a/engines/asylum/system/screen.cpp
+++ b/engines/asylum/system/screen.cpp
@@ -379,7 +379,30 @@ void Screen::paletteFade(uint32 start, int32 ticksWait, int32 delta) {
if (start < 0 || start > 255 || ticksWait < 0 || delta <= 0)
return;
- warning("[Screen::paletteFade] Not implemented!");
+ byte palette[256 * 3];
+ memcpy(&palette, &_mainPalette, sizeof(palette));
+
+ // Prepare for palette fading loop
+ uint32 colorDelta = delta + 1;
+ for (uint32 i = 1; i < colorDelta; i++) {
+ for (uint32 j = 3; j < ARRAYSIZE(_mainPalette) - 3; j += 3) {
+ _mainPalette[j] = palette[j] + i * (palette[start + 0] - palette[j]) / colorDelta;
+ _mainPalette[j + 1] = palette[j + 1] + i * (palette[start + 1] - palette[j + 1]) / colorDelta;
+ _mainPalette[j + 2] = palette[j + 2] + i * (palette[start + 2] - palette[j + 2]) / colorDelta;
+ }
+
+ setupPalette(0, 0, 0);
+
+ g_system->delayMillis(ticksWait);
+
+ // Poll events (this ensure we don't freeze the screen)
+ Common::Event ev;
+ do {
+ } while (_vm->getEventManager()->pollEvent(ev));
+
+ // Refresh the screen
+ g_system->updateScreen();
+ }
}
void Screen::paletteFadeWorker(ResourceId id, int32 ticksWait, int32 delta) {
@@ -414,8 +437,7 @@ void Screen::paletteFadeWorker(ResourceId id, int32 ticksWait, int32 delta) {
// Prepare for palette fading loop
uint32 colorDelta = delta + 1;
-
- for (uint32 i = 1; i < (uint32)(delta + 1); i++) {
+ for (uint32 i = 1; i < colorDelta; i++) {
for (uint32 j = 3; j < ARRAYSIZE(_mainPalette) - 3; j += 3) {
_mainPalette[j] = original[j] + i * (palette[j] - original[j]) / colorDelta;
_mainPalette[j + 1] = original[j + 1] + i * (palette[j + 1] - original[j + 1]) / colorDelta;
@@ -424,6 +446,7 @@ void Screen::paletteFadeWorker(ResourceId id, int32 ticksWait, int32 delta) {
setupPalette(0, 0, 0);
+ // Original waits for event and so can be interrupted in the middle of the wait
g_system->delayMillis(ticksWait);
if (_fadeStop)
break;
Commit: 6201a4cf9eccfd0d6372de5ea4dada4cb80805c4
https://github.com/scummvm/scummvm/commit/6201a4cf9eccfd0d6372de5ea4dada4cb80805c4
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:37:10+02:00
Commit Message:
ASYLUM: Implement more palette related functions
- Use Screen::setupPalette() in Video class instead of setting the palette directly
- Implement Screen::updatePalette()
- Cleanup usage of Screen::setupPalette()
Changed paths:
engines/asylum/puzzles/vcr.cpp
engines/asylum/system/screen.cpp
engines/asylum/system/screen.h
engines/asylum/views/video.cpp
diff --git a/engines/asylum/puzzles/vcr.cpp b/engines/asylum/puzzles/vcr.cpp
index 7c4a7a2037..0d85635266 100644
--- a/engines/asylum/puzzles/vcr.cpp
+++ b/engines/asylum/puzzles/vcr.cpp
@@ -338,7 +338,7 @@ void PuzzleVCR::updateScreen(const AsylumEvent &evt) {
getScreen()->clear();
// setupPalette();
- getScreen()->setupPalette(0, 0, 0);
+ getScreen()->setupPalette(NULL, 0, 0);
warning("[PuzzleVCR::updateScreen] Missing palette changes");
// TODO more stuff needed here (palette change, scene screen update, etc.)
diff --git a/engines/asylum/system/screen.cpp b/engines/asylum/system/screen.cpp
index 441fcf99ca..05a792b1a6 100644
--- a/engines/asylum/system/screen.cpp
+++ b/engines/asylum/system/screen.cpp
@@ -279,6 +279,10 @@ void Screen::setPalette(ResourceId id) {
setupPalette(data + 4, data[2], *(uint16 *)data);
}
+void Screen::setMainPalette(const byte *data) {
+ memcpy(&_mainPalette, data, sizeof(_mainPalette));
+}
+
void Screen::setupPalette(byte *buffer, int start, int count) {
// Check parameters
if (start < 0 || start > 256)
@@ -315,7 +319,31 @@ void Screen::updatePalette() {
}
void Screen::updatePalette(int32 param) {
- error("[Screen::updatePalette] Not implemented!");
+ if (param >= 21) {
+ for (uint32 j = 3; j < ARRAYSIZE(_mainPalette) - 3; j += 3) {
+ _mainPalette[j] = _currentPalette[j];
+ _mainPalette[j + 1] = _currentPalette[j + 1];
+ _mainPalette[j + 2] = _currentPalette[j + 2];
+ }
+
+ setupPalette(NULL, 0, 0);
+ paletteFade(0, 25, 10);
+ } else {
+ // Get the current action palette
+ ResourceId paletteId = getWorld()->actions[getScene()->getActor()->getActionIndex3()]->paletteResourceId;
+ if (!paletteId)
+ paletteId = getWorld()->currentPaletteId;
+
+ // Get the data
+ byte *paletteData = getPaletteData(paletteId);
+ paletteData += 4;
+
+ for (uint32 j = 3; j < ARRAYSIZE(_mainPalette) - 3; j += 3) {
+ _mainPalette[j] = 4 * paletteData[j] + param * (4 * paletteData[j] - _currentPalette[j]);
+ _mainPalette[j + 1] = 4 * paletteData[j + 1] + param * (4 * paletteData[j + 1] - _currentPalette[j + 1]);
+ _mainPalette[j + 2] = 4 * paletteData[j + 2] + param * (4 * paletteData[j + 2] - _currentPalette[j + 2]);
+ }
+ }
}
//////////////////////////////////////////////////////////////////////////
@@ -367,7 +395,7 @@ void Screen::stopPaletteFade(char red, char green, char blue) {
}
stopPaletteFadeTimer();
- setupPalette(0, 0, 0);
+ setupPalette(NULL, 0, 0);
}
void Screen::stopPaletteFadeAndSet(ResourceId id, int32 ticksWait, int32 delta) {
@@ -386,12 +414,12 @@ void Screen::paletteFade(uint32 start, int32 ticksWait, int32 delta) {
uint32 colorDelta = delta + 1;
for (uint32 i = 1; i < colorDelta; i++) {
for (uint32 j = 3; j < ARRAYSIZE(_mainPalette) - 3; j += 3) {
- _mainPalette[j] = palette[j] + i * (palette[start + 0] - palette[j]) / colorDelta;
+ _mainPalette[j] = palette[j] + i * (palette[start] - palette[j]) / colorDelta;
_mainPalette[j + 1] = palette[j + 1] + i * (palette[start + 1] - palette[j + 1]) / colorDelta;
_mainPalette[j + 2] = palette[j + 2] + i * (palette[start + 2] - palette[j + 2]) / colorDelta;
}
- setupPalette(0, 0, 0);
+ setupPalette(NULL, 0, 0);
g_system->delayMillis(ticksWait);
@@ -444,7 +472,7 @@ void Screen::paletteFadeWorker(ResourceId id, int32 ticksWait, int32 delta) {
_mainPalette[j + 2] = original[j + 2] + i * (palette[j + 2] - original[j + 2]) / colorDelta;
}
- setupPalette(0, 0, 0);
+ setupPalette(NULL, 0, 0);
// Original waits for event and so can be interrupted in the middle of the wait
g_system->delayMillis(ticksWait);
@@ -513,7 +541,7 @@ void Screen::setGammaLevel(ResourceId id) {
error("[Screen::setGammaLevel] Resource Id is invalid");
setPaletteGamma(getPaletteData(id));
- setupPalette(0, 0, 0);
+ setupPalette(NULL, 0, 0);
}
//////////////////////////////////////////////////////////////////////////
diff --git a/engines/asylum/system/screen.h b/engines/asylum/system/screen.h
index 49d3f7f0ff..cacf2edc42 100644
--- a/engines/asylum/system/screen.h
+++ b/engines/asylum/system/screen.h
@@ -92,6 +92,7 @@ public:
// Palette
void setPalette(ResourceId id);
+ void setMainPalette(const byte *data);
void loadPalette();
void updatePalette();
void updatePalette(int32 param);
diff --git a/engines/asylum/views/video.cpp b/engines/asylum/views/video.cpp
index bfed3b7ee5..c1662d85f5 100644
--- a/engines/asylum/views/video.cpp
+++ b/engines/asylum/views/video.cpp
@@ -197,10 +197,8 @@ void VideoPlayer::play(Common::String filename, bool showSubtitles) {
}
void VideoPlayer::setupPalette() {
- _smkDecoder->setSystemPalette();
-
- warning("[Video::setupPalette] Video palette setup not implemented!");
- //getScreen()->setupPalette(0, 0, 0);
+ getScreen()->setMainPalette(_smkDecoder->getPalette());
+ getScreen()->setupPalette(NULL, 0, 0);
}
void VideoPlayer::loadSubtitles() {
Commit: 9746136ee3d2c7b749be03bdc147ff4067242ff3
https://github.com/scummvm/scummvm/commit/9746136ee3d2c7b749be03bdc147ff4067242ff3
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:37:10+02:00
Commit Message:
ASYLUM: Fix palette fading corruption (visible in the cinematics menu when starting a video)
Changed paths:
engines/asylum/system/screen.cpp
engines/asylum/system/screen.h
diff --git a/engines/asylum/system/screen.cpp b/engines/asylum/system/screen.cpp
index 05a792b1a6..82c07e30e9 100644
--- a/engines/asylum/system/screen.cpp
+++ b/engines/asylum/system/screen.cpp
@@ -407,16 +407,20 @@ void Screen::paletteFade(uint32 start, int32 ticksWait, int32 delta) {
if (start < 0 || start > 255 || ticksWait < 0 || delta <= 0)
return;
- byte palette[256 * 3];
+ byte palette[PALETTE_SIZE];
memcpy(&palette, &_mainPalette, sizeof(palette));
// Prepare for palette fading loop
- uint32 colorDelta = delta + 1;
- for (uint32 i = 1; i < colorDelta; i++) {
- for (uint32 j = 3; j < ARRAYSIZE(_mainPalette) - 3; j += 3) {
- _mainPalette[j] = palette[j] + i * (palette[start] - palette[j]) / colorDelta;
- _mainPalette[j + 1] = palette[j + 1] + i * (palette[start + 1] - palette[j + 1]) / colorDelta;
- _mainPalette[j + 2] = palette[j + 2] + i * (palette[start + 2] - palette[j + 2]) / colorDelta;
+ int32 colorDelta = delta + 1;
+ byte red = palette[3 * start];
+ byte green = palette[3 * start + 1];
+ byte blue = palette[3 * start + 2];
+
+ for (int32 i = 1; i < colorDelta; i++) {
+ for (uint32 j = 3; j < ARRAYSIZE(_mainPalette); j += 3) {
+ _mainPalette[j] = palette[j] + i * (red - palette[j]) / colorDelta;
+ _mainPalette[j + 1] = palette[j + 1] + i * (green - palette[j + 1]) / colorDelta;
+ _mainPalette[j + 2] = palette[j + 2] + i * (blue - palette[j + 2]) / colorDelta;
}
setupPalette(NULL, 0, 0);
@@ -440,8 +444,8 @@ void Screen::paletteFadeWorker(ResourceId id, int32 ticksWait, int32 delta) {
return;
// Setup our palette
- byte original[256 * 3];
- byte palette[256 * 3];
+ byte original[PALETTE_SIZE];
+ byte palette[PALETTE_SIZE];
memcpy(&original, &_mainPalette, sizeof(original));
memcpy(&palette, &_mainPalette, sizeof(palette));
@@ -464,9 +468,9 @@ void Screen::paletteFadeWorker(ResourceId id, int32 ticksWait, int32 delta) {
setPaletteGamma(data, (byte *)&palette);
// Prepare for palette fading loop
- uint32 colorDelta = delta + 1;
- for (uint32 i = 1; i < colorDelta; i++) {
- for (uint32 j = 3; j < ARRAYSIZE(_mainPalette) - 3; j += 3) {
+ int32 colorDelta = delta + 1;
+ for (int32 i = 1; i < colorDelta; i++) {
+ for (uint32 j = 3; j < ARRAYSIZE(_mainPalette); j += 3) {
_mainPalette[j] = original[j] + i * (palette[j] - original[j]) / colorDelta;
_mainPalette[j + 1] = original[j + 1] + i * (palette[j + 1] - original[j + 1]) / colorDelta;
_mainPalette[j + 2] = original[j + 2] + i * (palette[j + 2] - original[j + 2]) / colorDelta;
diff --git a/engines/asylum/system/screen.h b/engines/asylum/system/screen.h
index cacf2edc42..0b6eb38bec 100644
--- a/engines/asylum/system/screen.h
+++ b/engines/asylum/system/screen.h
@@ -33,6 +33,8 @@
namespace Asylum {
+#define PALETTE_SIZE 256 * 3
+
class AsylumEngine;
class GraphicResource;
class ResourcePack;
@@ -151,8 +153,8 @@ private:
void clearTransTables();
// Palette
- byte _currentPalette[256 * 3];
- byte _mainPalette[256 * 3];
+ byte _currentPalette[PALETTE_SIZE];
+ byte _mainPalette[PALETTE_SIZE];
bool _isFading;
bool _fadeStop;
ResourceId _fadeResourceId;
Commit: da7fd8c203341777d495fe1fe3b55eed6ab8e2c3
https://github.com/scummvm/scummvm/commit/da7fd8c203341777d495fe1fe3b55eed6ab8e2c3
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:37:11+02:00
Commit Message:
ASYLUM: Fix GCC warning in Screen::paletteFade()
Changed paths:
engines/asylum/system/screen.cpp
diff --git a/engines/asylum/system/screen.cpp b/engines/asylum/system/screen.cpp
index 82c07e30e9..4b62a27e19 100644
--- a/engines/asylum/system/screen.cpp
+++ b/engines/asylum/system/screen.cpp
@@ -404,7 +404,7 @@ void Screen::stopPaletteFadeAndSet(ResourceId id, int32 ticksWait, int32 delta)
}
void Screen::paletteFade(uint32 start, int32 ticksWait, int32 delta) {
- if (start < 0 || start > 255 || ticksWait < 0 || delta <= 0)
+ if (start > 255 || ticksWait < 0 || delta <= 0)
return;
byte palette[PALETTE_SIZE];
Commit: 82ff79f04c55cfaa53539017a64bc8c356fd53e0
https://github.com/scummvm/scummvm/commit/82ff79f04c55cfaa53539017a64bc8c356fd53e0
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:37:11+02:00
Commit Message:
ASYLUM: Implement Actor::canInteract()
Changed paths:
engines/asylum/resources/actor.cpp
engines/asylum/resources/actor.h
engines/asylum/resources/script.cpp
diff --git a/engines/asylum/resources/actor.cpp b/engines/asylum/resources/actor.cpp
index 41c4b39e06..08e473a520 100644
--- a/engines/asylum/resources/actor.cpp
+++ b/engines/asylum/resources/actor.cpp
@@ -1502,8 +1502,110 @@ void Actor::processNext(ActorIndex nextActor, int32 actionAreaId, ActorDirection
updateDirection();
}
-bool Actor::process_4069B0(int32 *x, int32 *y) {
- error("[Actor::process_4069B0] Not implemented!");
+bool Actor::canInteract(Common::Point *point, int32* param) {
+ Actor *player = getScene()->getActor();
+
+ uint32 offset = 65;
+ if (getWorld()->chapter != kChapter2 || _index != 8)
+ offset = 40;
+
+ int32 parameter = 5;
+ Common::Point pt = _point1 + _point2;
+
+ if (getWorld()->chapter != kChapter2 || _index != 1) {
+ Common::Point diff = *player->getPoint1() - _point1;
+
+ if (abs(diff.y) <= abs(diff.x)) {
+
+ if (diff.x < 0) {
+
+ parameter = 2;
+ pt.x -= offset;
+ if (getScene()->findActionArea(kActionAreaType2, pt) != -1)
+ goto processActor;
+
+ parameter = 3;
+ pt.x -= offset;
+ pt.y += offset;
+ if (getScene()->findActionArea(kActionAreaType2, pt) != -1)
+ goto processActor;
+
+ parameter = 1;
+ pt.x -= offset;
+ pt.y -= offset;
+
+ } else {
+
+ parameter = 6;
+ pt.x += offset;
+ if (getScene()->findActionArea(kActionAreaType2, pt) != -1)
+ goto processActor;
+
+ parameter = 5;
+ pt.x += offset;
+ pt.y += offset;
+ if (getScene()->findActionArea(kActionAreaType2, pt) != -1)
+ goto processActor;
+
+ parameter = 7;
+ pt.x += offset;
+ pt.y -= offset;
+ }
+
+ } else {
+
+ if (diff.y >= 0) {
+
+ parameter = 4;
+ pt.y += offset;
+ if (getScene()->findActionArea(kActionAreaType2, pt) != -1)
+ goto processActor;
+
+ parameter = 3;
+ pt.x -= offset;
+ pt.y += offset;
+ if (getScene()->findActionArea(kActionAreaType2, pt) != -1)
+ goto processActor;
+
+ parameter = 5;
+ pt.x += offset;
+ pt.y += offset;
+
+ } else {
+
+ parameter = 0;
+ pt.y -= offset;
+ if (getScene()->findActionArea(kActionAreaType2, pt) != -1)
+ goto processActor;
+
+ parameter = 1;
+ pt.x -= offset;
+ pt.y -= offset;
+ if (getScene()->findActionArea(kActionAreaType2, pt) != -1)
+ goto processActor;
+
+ parameter = 7;
+ pt.x += offset;
+ pt.y -= offset;
+ }
+ }
+ } else {
+ parameter = 5;
+ pt.x += offset;
+ pt.y += offset;
+ }
+
+ if (getScene()->findActionArea(kActionAreaType2, pt) == -1)
+ return false;
+
+processActor:
+ if (!process(pt))
+ return false;
+
+ *point = pt;
+ *param = abs(parameter + 4) & 7;
+
+ return true;
}
bool Actor::canMove(Common::Point *point, ActorDirection direction, uint32 distance, bool hasDelta) {
diff --git a/engines/asylum/resources/actor.h b/engines/asylum/resources/actor.h
index 323e99aee8..e66ae2f122 100644
--- a/engines/asylum/resources/actor.h
+++ b/engines/asylum/resources/actor.h
@@ -256,7 +256,7 @@ public:
bool process(const Common::Point &point);
void processStatus(int32 actorX, int32 actorY, bool doSpeech);
void processNext(ActorIndex nextActor, int32 actionAreaId, ActorDirection nextDirection, const Common::Point &nextPosition, bool invertPriority, const Common::Point &nextPositionOffset);
- bool process_4069B0(int32 *x, int32 *y);
+ bool canInteract(Common::Point *point, int* param);
bool canMove(Common::Point *point, ActorDirection direction, uint32 count, bool hasDelta);
void move(ActorDirection dir, uint32 distance);
void addReactionHive(int32 reactionIndex, int32 numberValue01Add);
diff --git a/engines/asylum/resources/script.cpp b/engines/asylum/resources/script.cpp
index 809fff9af6..27bbce8a95 100644
--- a/engines/asylum/resources/script.cpp
+++ b/engines/asylum/resources/script.cpp
@@ -1673,13 +1673,12 @@ IMPLEMENT_OPCODE(Interact)
_currentQueueEntry->currentLine = cmd->param3;
}
} else {
- int32 x = 0;
- int32 y = 0; // FIXME: is is set somewhere else?
+ Common::Point point;
- if (actor->process_4069B0(&x, &cmd->param4) == 1) {
- getScene()->getActor()->processStatus(x, y, (bool)cmd->param4);
- cmd->param6 = x;
- cmd->param7 = y;
+ if (actor->canInteract(&point, &cmd->param4) == 1) {
+ getScene()->getActor()->processStatus(point.x, point.y, (bool)cmd->param4);
+ cmd->param6 = point.x;
+ cmd->param7 = point.y;
if (cmd->param2 == 1) {
cmd->param2 = 2;
Commit: ed60255adf13814c39b9c007d814886504a6932c
https://github.com/scummvm/scummvm/commit/ed60255adf13814c39b9c007d814886504a6932c
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:37:11+02:00
Commit Message:
ASYLUM: Add delay in event loop in the intro
Changed paths:
engines/asylum/asylum.cpp
engines/asylum/views/scene.cpp
diff --git a/engines/asylum/asylum.cpp b/engines/asylum/asylum.cpp
index 12da9d4fb0..32576c51ff 100644
--- a/engines/asylum/asylum.cpp
+++ b/engines/asylum/asylum.cpp
@@ -311,6 +311,8 @@ void AsylumEngine::playIntro() {
Common::Event ev;
_eventMan->pollEvent(ev);
+ _system->delayMillis(100);
+
} while (_sound->isPlaying(introSpeech));
}
diff --git a/engines/asylum/views/scene.cpp b/engines/asylum/views/scene.cpp
index 11e9f3cf77..65be7d12ab 100644
--- a/engines/asylum/views/scene.cpp
+++ b/engines/asylum/views/scene.cpp
@@ -1788,6 +1788,8 @@ void Scene::playIntroSpeech() {
Common::Event ev;
_vm->getEventManager()->pollEvent(ev);
+ g_system->delayMillis(100);
+
} while (getSound()->isPlaying(resourceId));
}
Commit: f6733c0cfbdc1abce4a84018944f3ebb89c2bca6
https://github.com/scummvm/scummvm/commit/f6733c0cfbdc1abce4a84018944f3ebb89c2bca6
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:37:11+02:00
Commit Message:
ASYLUM: Update actor distances functions
Changed paths:
engines/asylum/resources/actor.cpp
engines/asylum/resources/actor.h
diff --git a/engines/asylum/resources/actor.cpp b/engines/asylum/resources/actor.cpp
index 08e473a520..b2511c04e1 100644
--- a/engines/asylum/resources/actor.cpp
+++ b/engines/asylum/resources/actor.cpp
@@ -1810,7 +1810,7 @@ bool Actor::hasMoreReactions(int32 reactionIndex, int32 testNumberValue01) {
}
bool Actor::canMoveCheckActors(Common::Point *point, ActorDirection dir) {
- int32 dist = getDistanceForFrame(dir, (_frameIndex >= _frameCount) ? 2 * _frameCount - (_frameIndex + 1) : _frameIndex);
+ int32 dist = getAbsoluteDistanceForFrame(dir, (_frameIndex >= _frameCount) ? 2 * _frameCount - (_frameIndex + 1) : _frameIndex);
int32 x = point->x + deltaPointsArray[dir].x * dist - _field_948 - 10;
int32 y = point->y + deltaPointsArray[dir].y * dist - _field_94C - 10;
@@ -2402,7 +2402,7 @@ void Actor::updateStatus14_Chapter2() {
return;
}
- // FIXME original calls getDistance but does not seem to do anything with the results
+ // FIXME original calls getDistanceForFrame but does not seem to do anything with the results
if (_status == kActorStatus17 || !getScene()->getActor(10)->isVisible()) {
updateStatus(kActorStatusEnabled);
@@ -3354,12 +3354,12 @@ bool Actor::processAction(const Common::Point &source, Common::Array<int> *actio
if (!checkAllActions(src, actions))
break;
- int32 dist = getDistanceForFrame(direction, frameNumber);
+ int32 dist = getAbsoluteDistanceForFrame(direction, frameNumber);
src.x += sign.x * dist;
src.y += sign.y * dist;
- if (abs(src.x - destination.x) >= getDistanceForFrame(kDirectionO, frameNumber)) {
- if (abs(src.y - destination.y) >= getDistanceForFrame(kDirectionN, frameNumber)) {
+ if (abs(src.x - destination.x) >= getAbsoluteDistanceForFrame(kDirectionO, frameNumber)) {
+ if (abs(src.y - destination.y) >= getAbsoluteDistanceForFrame(kDirectionN, frameNumber)) {
if (src.x >= destination.x) {
if (checkPath(actions, src, kDirectionO, src.x - destination.x)) {
@@ -3435,7 +3435,7 @@ bool Actor::processAction(const Common::Point &source, Common::Array<int> *actio
}
// Check if we need to process
- int32 distance = getDistanceForFrame(direction, frameNumber);
+ int32 distance = getAbsoluteDistanceForFrame(direction, frameNumber);
if (source.x == (src.x - sign.x * distance) && source.y == (src.y - sign.y * distance))
return false;
@@ -3446,9 +3446,9 @@ bool Actor::processAction(const Common::Point &source, Common::Array<int> *actio
_frameNumber = frameNumber;
if (_frameNumber <= 0)
- distance = getDistanceForFrame(direction, _frameCount - 1);
+ distance = getAbsoluteDistanceForFrame(direction, _frameCount - 1);
else
- distance = getDistanceForFrame(direction, _frameNumber - 1);
+ distance = getAbsoluteDistanceForFrame(direction, _frameNumber - 1);
src.x -= sign.x * distance;
src.y -= sign.y * distance;
@@ -3685,7 +3685,7 @@ DrawFlags Actor::getGraphicsFlags() {
return kDrawFlagMirrorLeftRight;
}
-int32 Actor::getDistanceForFrame(ActorDirection dir, uint32 frameIndex) const {
+int32 Actor::getAbsoluteDistanceForFrame(ActorDirection dir, uint32 frameIndex) const {
switch (dir) {
default:
error("[Actor::getDistanceForFrame] Invalid direction");
@@ -3706,6 +3706,37 @@ int32 Actor::getDistanceForFrame(ActorDirection dir, uint32 frameIndex) const {
}
}
+int32 Actor::getDistanceForFrame(ActorDirection dir, uint32 frameIndex) const {
+ switch (dir) {
+ default:
+ error("[Actor::getDistanceForFrame] Invalid direction");
+
+ case kDirectionN:
+ return -_distancesNS[frameIndex];
+
+ case kDirectionS:
+ return _distancesNS[frameIndex];
+
+ case kDirectionNO:
+ return -_distancesNSEO[frameIndex];
+
+ case kDirectionNE:
+ return -_distancesNSEO[frameIndex];
+
+ case kDirectionSO:
+ return _distancesNSEO[frameIndex];
+
+ case kDirectionSE:
+ return _distancesNSEO[frameIndex];
+
+ case kDirectionO:
+ return -_distancesEO[frameIndex];
+
+ case kDirectionE:
+ return _distancesEO[frameIndex];
+ }
+}
+
void Actor::updateCoordinatesForDirection(ActorDirection direction, int32 delta, Common::Point *point) {
if (!point)
error("[Actor::updateCoordinatesForDirection] Invalid point (NULL)!");
diff --git a/engines/asylum/resources/actor.h b/engines/asylum/resources/actor.h
index e66ae2f122..8277332a35 100644
--- a/engines/asylum/resources/actor.h
+++ b/engines/asylum/resources/actor.h
@@ -510,6 +510,16 @@ private:
DrawFlags getGraphicsFlags();
/**
+ * Gets the absolute distance for a frame.
+ *
+ * @param direction The direction.
+ * @param frameIndex Zero-based index of the frame.
+ *
+ * @return The distance for the frame.
+ */
+ int32 getAbsoluteDistanceForFrame(ActorDirection direction, uint32 frameIndex) const;
+
+ /**
* Gets the distance for a frame.
*
* @param direction The direction.
Commit: d4e5d66e59fffe36bcc68db55d0349e2fced3689
https://github.com/scummvm/scummvm/commit/d4e5d66e59fffe36bcc68db55d0349e2fced3689
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:37:11+02:00
Commit Message:
ASYLUM: Implement Actor::updateStatus18_Chapter2_Actor11()
Changed paths:
engines/asylum/resources/actor.cpp
diff --git a/engines/asylum/resources/actor.cpp b/engines/asylum/resources/actor.cpp
index b2511c04e1..e1e1001363 100644
--- a/engines/asylum/resources/actor.cpp
+++ b/engines/asylum/resources/actor.cpp
@@ -3075,7 +3075,39 @@ void Actor::updateStatus18_Chapter2() {
}
void Actor::updateStatus18_Chapter2_Actor11() {
- error("[Actor::updateStatus18_Chapter2_Actor11] not implemented!");
+#define DIR(val) (ActorDirection)((val) % -8)
+
+ uint32 frameIndex = (_frameIndex < _frameCount) ? _frameIndex : 2 * _frameCount - _frameIndex - 1;
+ int32 distance = abs((double)getDistanceForFrame(_direction, frameIndex));
+
+ getSharedData()->setData(41, getSharedData()->getData(41) + 1);
+ if (getSharedData()->getData(41) > 14) {
+ getSharedData()->setData(41, 0);
+ updateStatus(kActorStatus12);
+ }
+
+ faceTarget(getScene()->getPlayerIndex(), kDirectionFromActor);
+
+ Common::Point sum = _point1 + _point2;
+ if (canMove(&sum, DIR(_direction + 4), distance, false)) {
+ move(DIR(_direction + 4), distance);
+ --_frameIndex;
+ } else if (canMove(&sum, DIR(_direction + 5), distance, false)) {
+ move(DIR(_direction + 5), distance);
+ --_frameIndex;
+ } else if (canMove(&sum, DIR(_direction + 3), distance, false)) {
+ move(DIR(_direction + 3), distance);
+ --_frameIndex;
+ } else if (canMove(&sum, DIR(_direction + 6), distance, false)) {
+ move(DIR(_direction + 6), distance);
+ --_frameIndex;
+ } else if (canMove(&sum, DIR(_direction + 2), distance, false)) {
+ move(DIR(_direction + 2), distance);
+ --_frameIndex;
+ }
+
+ if (_frameIndex < 0)
+ _frameIndex = _frameCount - 1;
}
void Actor::updateStatus21() {
Commit: e056a928624404891f8785d6869503c0a21d6da9
https://github.com/scummvm/scummvm/commit/e056a928624404891f8785d6869503c0a21d6da9
Author: Julien Templier (littleboy at scummvm.org)
Date: 2021-05-17T15:37:11+02:00
Commit Message:
ASYLUM: Remove unused member from SoundQueueItem
It was used in the original to check when to cleanup the sound queue
Changed paths:
engines/asylum/system/sound.cpp
engines/asylum/system/sound.h
diff --git a/engines/asylum/system/sound.cpp b/engines/asylum/system/sound.cpp
index 9ca2f4f22e..310e88382d 100644
--- a/engines/asylum/system/sound.cpp
+++ b/engines/asylum/system/sound.cpp
@@ -66,15 +66,12 @@ void Sound::playSound(ResourceId resourceId, bool looping, int32 volume, int32 p
if (item) {
// Duplicate the queue entry
item = addToQueue(item->resourceId);
- item->unknown = 0;
} else {
// Check that the sound is valid
if (!isValidSoundResource(resourceId))
return;
item = addToQueue(resourceId);
-
- // TODO add missing code
}
// Original sets position back to 0
diff --git a/engines/asylum/system/sound.h b/engines/asylum/system/sound.h
index be898a201e..6e4f6d05ec 100644
--- a/engines/asylum/system/sound.h
+++ b/engines/asylum/system/sound.h
@@ -94,11 +94,9 @@ struct AmbientSoundItem {
struct SoundQueueItem {
ResourceId resourceId;
Audio::SoundHandle handle;
- int32 unknown;
SoundQueueItem() {
resourceId = kResourceNone;
- unknown = 0;
}
};
Commit: f6fd9adc50a305d0e8cdfb2a2fcb5118e8b9ff56
https://github.com/scummvm/scummvm/commit/f6fd9adc50a305d0e8cdfb2a2fcb5118e8b9ff56
Author: Littleboy (littleboy at scummvm.org)
Date: 2021-05-17T15:37:11+02:00
Commit Message:
ASYLUM: Implement Actor::updateStatus12_Chapter2_Actor11()
Changed paths:
engines/asylum/resources/actor.cpp
diff --git a/engines/asylum/resources/actor.cpp b/engines/asylum/resources/actor.cpp
index e1e1001363..e5d9f061aa 100644
--- a/engines/asylum/resources/actor.cpp
+++ b/engines/asylum/resources/actor.cpp
@@ -46,6 +46,8 @@
namespace Asylum {
+#define DIR(val) (ActorDirection)((val) % 7)
+
Actor::Actor(AsylumEngine *engine, ActorIndex index) : _vm(engine), _index(index) {
// Init all variables
_resourceId = kResourceNone;
@@ -476,14 +478,14 @@ void Actor::update() {
if (canMove(&point, _direction, dist, false)) {
move(_direction, dist);
- } else if (canMove(&point, (ActorDirection)((_direction + 1) % 7), dist, false)) {
- move((ActorDirection)((_direction + 1) % 7), dist);
- } else if (canMove(&point, (ActorDirection)((_direction + 7) % 7), dist, false)) {
- move((ActorDirection)((_direction + 7) % 7), dist);
- } else if (canMove(&point, (ActorDirection)((_direction + 2) % 7), dist, false)) {
- move((ActorDirection)((_direction + 2) % 7), dist);
- } else if (canMove(&point, (ActorDirection)((_direction + 6) % 7), dist, false)) {
- move((ActorDirection)((_direction + 6) % 7), dist);
+ } else if (canMove(&point, DIR(_direction + 1), dist, false)) {
+ move(DIR(_direction + 1), dist);
+ } else if (canMove(&point, DIR(_direction + 7), dist, false)) {
+ move(DIR(_direction + 7), dist);
+ } else if (canMove(&point, DIR(_direction + 2), dist, false)) {
+ move(DIR(_direction + 2), dist);
+ } else if (canMove(&point, DIR(_direction + 6), dist, false)) {
+ move(DIR(_direction + 6), dist);
}
// Finish
@@ -2326,7 +2328,79 @@ void Actor::updateStatus12_Chapter2() {
}
void Actor::updateStatus12_Chapter2_Actor11() {
- error("[Actor::updateStatus12_Chapter2_Actor11] not implemented!");
+ bool processEnd = true;
+ Actor *player = getScene()->getActor();
+ Common::Point sum = _point1 + _point2;
+ Common::Point sumPlayer = *player->getPoint1() + *player->getPoint2();
+
+ // Compute distance
+ uint32 frameIndex = _frameIndex;
+ if (_frameIndex >= _frameCount)
+ frameIndex = 2 * _frameCount - _frameIndex - 1;
+
+ uint32 distance = abs((double)getDistanceForFrame(_direction, frameIndex));
+
+ // Update status
+ if (player->getStatus() == kActorStatus17 || !getScene()->getActor(10)->isVisible()) {
+ updateStatus(kActorStatusEnabled);
+ getSharedData()->setData(_index - 8, 160);
+ }
+
+ // Face player
+ faceTarget(getScene()->getPlayerIndex(), kDirectionFromActor);
+
+ // Compute coordinates
+ Common::Point delta = Common::Point((sumPlayer.x + sum.x) / 2, (sumPlayer.y + sum.y) / 2);
+ Common::Point point1 = Common::Point((delta.x + sum.x) / 2, (delta.y + sum.y) / 2);
+ Common::Point point2 = Common::Point((delta.x + sumPlayer.x) / 2, (delta.y + sumPlayer.y) / 2);
+
+ if (getScene()->findActionArea(kActionAreaType1, delta) == -1
+ || getScene()->findActionArea(kActionAreaType1, point1) == -1
+ || getScene()->findActionArea(kActionAreaType1, point2) == -1) {
+ processEnd = false;
+
+ if (compareAngles(sum, sumPlayer) == false) {
+ if (canMove(&sum, DIR(_direction + 1), distance, false)) {
+ move(DIR(_direction + 1), distance);
+ } else if (canMove(&sum, DIR(_direction + 2), distance, false)) {
+ move(DIR(_direction + 2), distance);
+ } else if (canMove(&sum, DIR(_direction + 3), distance, false)) {
+ move(DIR(_direction + 3), distance);
+ } else if (canMove(&sum, DIR(_direction + 4), distance, false)) {
+ move(DIR(_direction + 1), distance);
+ }
+ } else {
+ if (canMove(&sum, DIR(_direction + 7), distance, false)) {
+ move(DIR(_direction + 7), distance);
+ } else if (canMove(&sum, DIR(_direction + 6), distance, false)) {
+ move(DIR(_direction + 6), distance);
+ } else if (canMove(&sum, DIR(_direction + 5), distance, false)) {
+ move(DIR(_direction + 5), distance);
+ } else if (canMove(&sum, DIR(_direction + 4), distance, false)) {
+ move(DIR(_direction + 4), distance);
+ }
+ }
+ } else {
+ if (canMove(&sum, DIR(_direction + 1), distance, false)) {
+ move(DIR(_direction + 1), distance);
+ } else if (canMove(&sum, DIR(_direction + 2), distance, false)) {
+ move(DIR(_direction + 2), distance);
+ } else if (canMove(&sum, DIR(_direction + 7), distance, false)) {
+ move(DIR(_direction + 7), distance);
+ } else if (canMove(&sum, DIR(_direction + 6), distance, false)) {
+ move(DIR(_direction + 6), distance);
+ }
+ }
+
+ if (processEnd) {
+ if (player->getStatus() != kActorStatus17 && player->getStatus() != kActorStatus16) {
+ if (sqrt((double)((sum.y - sumPlayer.y) * (sum.y - sumPlayer.y) + (sum.x - sumPlayer.x) * (sum.x - sumPlayer.x))) < 80.0) {
+ _frameIndex = 0;
+ faceTarget(getScene()->getPlayerIndex(), kDirectionFromActor);
+ updateStatus(kActorStatus15);
+ }
+ }
+ }
}
void Actor::updateStatus12_Chapter11_Actor1() {
@@ -3075,8 +3149,6 @@ void Actor::updateStatus18_Chapter2() {
}
void Actor::updateStatus18_Chapter2_Actor11() {
-#define DIR(val) (ActorDirection)((val) % -8)
-
uint32 frameIndex = (_frameIndex < _frameCount) ? _frameIndex : 2 * _frameCount - _frameIndex - 1;
int32 distance = abs((double)getDistanceForFrame(_direction, frameIndex));
Commit: 361c52ef01c984affc998ddedb1ab8de446ec3af
https://github.com/scummvm/scummvm/commit/361c52ef01c984affc998ddedb1ab8de446ec3af
Author: Littleboy (littleboy at scummvm.org)
Date: 2021-05-17T15:37:12+02:00
Commit Message:
ASYLUM: Add data written checks when saving games
Changed paths:
engines/asylum/system/savegame.cpp
diff --git a/engines/asylum/system/savegame.cpp b/engines/asylum/system/savegame.cpp
index edebb0a635..9660c9ab87 100644
--- a/engines/asylum/system/savegame.cpp
+++ b/engines/asylum/system/savegame.cpp
@@ -368,8 +368,6 @@ void Savegame::write(Common::OutSaveFile *file, uint32 val, Common::String descr
file->writeUint32LE(4);
file->writeUint32LE(1);
- // Write data
- // TODO check for errors
file->writeUint32LE(val);
}
@@ -377,8 +375,6 @@ void Savegame::write(Common::OutSaveFile *file, Common::String val, uint32 count
file->writeUint32LE(1);
file->writeUint32LE(count);
- // Write data
- // TODO check for errors
file->writeString(val);
}
@@ -390,7 +386,16 @@ void Savegame::write(Common::OutSaveFile *file, Common::Serializable *data, uint
return;
Common::Serializer ser(NULL, file);
+ uint before = ser.bytesSynced();
+
+ // Save the data
data->saveLoadWithSerializer(ser);
+
+ // Check we wrote the correct amount of data
+ uint after = ser.bytesSynced();
+
+ if ((after - before) != (size * count))
+ error("[Savegame::write] Invalid number of bytes written to file (was: %d, expected: %d)", after - before, size * count);
}
//////////////////////////////////////////////////////////////////////////
Commit: 5ba6a0605d8680eb918737c991fa506fbaec8b1f
https://github.com/scummvm/scummvm/commit/5ba6a0605d8680eb918737c991fa506fbaec8b1f
Author: Littleboy (littleboy at scummvm.org)
Date: 2021-05-17T15:37:12+02:00
Commit Message:
ASYLUM: Correct usage of some shared data
- Add ambientFlags array
- Update usage of ambientTicks array
- Remove some now unused gameFlags related methods
Changed paths:
engines/asylum/asylum.cpp
engines/asylum/asylum.h
engines/asylum/resources/data.h
engines/asylum/views/scene.cpp
diff --git a/engines/asylum/asylum.cpp b/engines/asylum/asylum.cpp
index 32576c51ff..3382ea6de5 100644
--- a/engines/asylum/asylum.cpp
+++ b/engines/asylum/asylum.cpp
@@ -561,14 +561,6 @@ void AsylumEngine::saveLoadWithSerializer(Common::Serializer &s) {
//////////////////////////////////////////////////////////////////////////
#define FLAG_MASK 0xFFFFFFE0
-void AsylumEngine::setGameFlagByIndex(int32 index) {
- _gameFlags[index] = 1;
-}
-
-int32 AsylumEngine::getGameFlagByIndex(int32 index) {
- return _gameFlags[index];
-}
-
void AsylumEngine::setGameFlag(GameFlag flag) {
_gameFlags[flag / 32] |= 1 << (flag % FLAG_MASK);
}
@@ -589,8 +581,4 @@ bool AsylumEngine::isGameFlagNotSet(GameFlag flag) const {
return ((1 << (flag % FLAG_MASK)) & (unsigned int)_gameFlags[flag / 32]) >> (flag % FLAG_MASK) == 0;
}
-void AsylumEngine::resetFlags() {
- memset(&_gameFlags[130], 0, 60);
-}
-
} // namespace Asylum
diff --git a/engines/asylum/asylum.h b/engines/asylum/asylum.h
index aea0cff9a1..0d6d0b63cb 100644
--- a/engines/asylum/asylum.h
+++ b/engines/asylum/asylum.h
@@ -157,8 +157,6 @@ public:
PuzzleData *puzzleData() { return &_puzzleData; }
// Flags
- void setGameFlagByIndex(int32 index);
- int32 getGameFlagByIndex(int32 index);
void setGameFlag(GameFlag flag);
void clearGameFlag(GameFlag flag);
void toggleGameFlag(GameFlag flag);
@@ -241,7 +239,7 @@ private:
// Game data
PuzzleData _puzzleData;
SharedData _data;
- int _gameFlags[190];
+ int _gameFlags[145];
int32 _sinCosTables[72];
bool _introPlayed;
int32 _tickOffset;
diff --git a/engines/asylum/resources/data.h b/engines/asylum/resources/data.h
index 26a5c734eb..3f3c8ef0b6 100644
--- a/engines/asylum/resources/data.h
+++ b/engines/asylum/resources/data.h
@@ -138,7 +138,7 @@ public:
actorUpdateStatus15Check = false;
_flag2 = false;
globalDirection = kDirectionN;
- memset(&_ambientTick, 0, sizeof(_ambientTick));
+ memset(&_ambientTicks, 0, sizeof(_ambientTicks));
// Screen updates
_flagRedraw = false;
@@ -234,13 +234,38 @@ public:
}
}
- uint32 *getAmbientTick(uint32 index) {
- if (index >= ARRAYSIZE(_ambientTick))
- error("[SharedData::getAmbientTick] index is outside valid values (was: %d, valid: [0:15]", index);
+ uint32 getAmbientTick(uint32 index) {
+ if (index >= ARRAYSIZE(_ambientTicks))
+ error("[SharedData::getAmbientTick] index is outside valid values (was: %d, valid: [0:%d]", index, ARRAYSIZE(_ambientTicks));
- return &_ambientTick[index];
+ return _ambientTicks[index];
};
+ void setAmbientTick(uint32 index, uint32 val) {
+ if (index >= ARRAYSIZE(_ambientTicks))
+ error("[SharedData::setAmbientTick] index is outside valid values (was: %d, valid: [0:%d]", index, ARRAYSIZE(_ambientTicks));
+
+ _ambientTicks[index] = val;
+ };
+
+ uint32 getAmbientFlag(uint32 index) {
+ if (index >= ARRAYSIZE(_ambientFlags))
+ error("[SharedData::getAmbientFlag] index is outside valid values (was: %d, valid: [0:%d]", index, ARRAYSIZE(_ambientFlags));
+
+ return _ambientFlags[index];
+ };
+
+ void setAmbientFlag(uint32 index, uint32 val) {
+ if (index >= ARRAYSIZE(_ambientFlags))
+ error("[SharedData::setAmbientFlag] index is outside valid values (was: %d, valid: [0:%d]", index, ARRAYSIZE(_ambientFlags));
+
+ _ambientFlags[index] = val;
+ };
+
+ void resetAmbientFlags() {
+ memset(&_ambientFlags, 0, sizeof(_ambientFlags));
+ }
+
//////////////////////////////////////////////////////////////////////////
// Flags
//////////////////////////////////////////////////////////////////////////
@@ -309,7 +334,8 @@ public:
}
private:
- uint32 _ambientTick[16];
+ uint32 _ambientFlags[15];
+ uint32 _ambientTicks[17];
// Flags
bool _flag1;
diff --git a/engines/asylum/views/scene.cpp b/engines/asylum/views/scene.cpp
index 65be7d12ab..93d19db386 100644
--- a/engines/asylum/views/scene.cpp
+++ b/engines/asylum/views/scene.cpp
@@ -280,7 +280,7 @@ void Scene::load(ResourcePackId packId) {
fd->close();
delete fd;
- _vm->resetFlags();
+ getSharedData()->resetAmbientFlags();
_ws->field_120 = -1;
int32 tick = _vm->getTick();
@@ -836,7 +836,7 @@ void Scene::updateAmbientSounds() {
for (int32 i = 0; i < _ws->numAmbientSounds; i++) {
bool processSound = true;
AmbientSoundItem *snd = &_ws->ambientSounds[i];
- uint32 *ambientTick = getSharedData()->getAmbientTick(i);
+ uint32 ambientTick = getSharedData()->getAmbientTick(i);
for (int32 f = 0; f < 6; f++) {
GameFlag gameFlag = snd->flagNum[f];
@@ -903,18 +903,18 @@ void Scene::updateAmbientSounds() {
}
}
} else if (LOBYTE(snd->flags) & 4) {
- if (*ambientTick > _vm->getTick()) {
+ if (ambientTick > _vm->getTick()) {
if (snd->nextTick >= 0)
- *ambientTick = 60000 * snd->nextTick + _vm->getTick();
+ getSharedData()->setAmbientTick(i, 60000 * snd->nextTick + _vm->getTick());
else
- *ambientTick = _vm->getTick() - 1000 * snd->nextTick;
+ getSharedData()->setAmbientTick(i, _vm->getTick() - 1000 * snd->nextTick);
getSound()->playSound(snd->resourceId, false, volume, panning);
}
} else if (LOBYTE(snd->flags) & 8) {
- if (_vm->getGameFlagByIndex(85 + i)) {
+ if (!getSharedData()->getAmbientFlag(i)) {
getSound()->playSound(snd->resourceId, false, volume, panning);
- _vm->setGameFlagByIndex(85 + i);
+ getSharedData()->setAmbientFlag(i, 1);
}
}
Commit: c78554d6d00143a86a4af24a99a50d90c7e6bea5
https://github.com/scummvm/scummvm/commit/c78554d6d00143a86a4af24a99a50d90c7e6bea5
Author: Littleboy (littleboy at scummvm.org)
Date: 2021-05-17T15:37:12+02:00
Commit Message:
ASYLUM: Reorganize and document shared data
- Add saveLoadWithSerializer() stub to SharedData
Changed paths:
engines/asylum/asylum.h
engines/asylum/resources/data.h
diff --git a/engines/asylum/asylum.h b/engines/asylum/asylum.h
index 0d6d0b63cb..d0e64f532b 100644
--- a/engines/asylum/asylum.h
+++ b/engines/asylum/asylum.h
@@ -239,7 +239,7 @@ private:
// Game data
PuzzleData _puzzleData;
SharedData _data;
- int _gameFlags[145];
+ int _gameFlags[130];
int32 _sinCosTables[72];
bool _introPlayed;
int32 _tickOffset;
diff --git a/engines/asylum/resources/data.h b/engines/asylum/resources/data.h
index 3f3c8ef0b6..2acd1b1d95 100644
--- a/engines/asylum/resources/data.h
+++ b/engines/asylum/resources/data.h
@@ -27,6 +27,7 @@
#include "common/rational.h"
#include "common/rect.h"
+#include "common/serializer.h"
namespace Asylum {
@@ -57,23 +58,25 @@ enum GlobalFlag {
* Lots of data
*
* -- Scene data (reset on scene load)
- * uint32 {16} - ambient sound panning array
- * uint32 {1} - scene counter
+ * uint32 {15} - ambient flags
+ * uint32 {15} - ambient ticks
+ * uint32 {1} - UNUSED
+ * uint32 {1} - scene updateScreen calls count
* -- Script queue (stored in ScriptManager - reset on scene change)
- * uint32 {1} - global Object X
- * uint32 {1} - global Object Y
+ * uint32 {1} - global Object X
+ * uint32 {1} - global Object Y
* -- Skip processing flag (stored in ScriptManager)
- * uint32 {1} - Encounter flag 2
- * -- Player ActorIndex (reset on scene enter)
- * uint32 {1} - scene xLeft
- * uint32 {1} - scene yTop
- * uint32 {1} - scene offset
- * uint32 {1} - scene offsetAdd
- * -- UNUSED ??
+ * -- Encounter running flag (stored in Encounter)
+ * uint32 {1} - Player ActorIndex
+ * uint32 {1} - scene xLeft
+ * uint32 {1} - scene yTop
+ * uint32 {1} - scene offset
+ * uint32 {1} - scene offsetAdd
+ * uint32 {1} - UNUSED
* uint32 {13} - cursor resources
* uint32 {3} - scene fonts (3)
- * uint32 {1} - current palette Id
- * uint32 {3} - cellshade masks (3)
+ * uint32 {3} - Chapter2 actor data (part 1)
+ * uint32 {1} - UNUSED
* uint32 {1} - small cursor Up
* uint32 {1} - small cursor Down
* uint32 {1} - Encounter frame background
@@ -83,14 +86,32 @@ enum GlobalFlag {
* uint32 {1} - matte Initialized
* uint32 {1} - matte playSound
* uint32 {1} - currentScreenUpdatesCount
- * uint32 {50} - Actor data
- * uint32 {11} - UNUSED ?? (Actor data 2)
- * uint32 {1} - actorUpdateEnabledCounter
- * uint32 {9} - Actor data 3
- * uint32 {1} - Encounter flag 5
+ * uint32 {3} - Chapter2 actor data (part 2)
+ * uint32 {1} - Chapter 2 counter 1
+ * uint32 {1} - Chapter 2 counter 2
+ * uint32 {1} - Chapter 2 counter 3
+ * uint32 {1} - Chapter 2 counter 4
+ * uint32 {1} - UNUSED
+ * uint32 {3} - Chapter2 actor data (part 3)
+ * uint32 {1} - UNUSED
+ * uint32 {8} - Chapter 2 points
+ * uint32 {9} - UNUSED
+ * uint32 {1} - Special 2 counter 5
+ * uint32 {1} - Chapter 2 frameIndex Offset
+ * uint32 {1} - Chapter 2 Actor index
+ * uint32 {1} - Event update flag
+ * uint32 {1} - Chapter 2 counter 6
+ * uint32 {1} - Chapter 2 counter 7
+ * uint32 {1} - Chapter 2 counter 8
+ * uint32 {7} - UNUSED
+ * uint32 {3} - Chapter2 actor data (part 4)
+ * uint32 {8} - UNUSED
+ * uint32 {1} - actorUpdateStatusEnabledCounter
+ * uint32 {9} - Chapter2 actor data (part 5)
+ * uint32 {1} - Encounter disablePlayerOnExit
* uint32 {1} - Scene flag 1
* uint32 {1} - nextScreenUpdate
- * uint32 {49} - Viewed movies
+ * uint32 {49} - Viewed movies
* uint32 {1} - actorUpdateStatus15Check
* -- Skip opening movie command line flag (not used)
* uint32 {1} - Encounter flag 3
@@ -99,7 +120,7 @@ enum GlobalFlag {
* -- scripts (reset on scene load)
* -- polygons (reset on scene load)
*/
-struct SharedData {
+struct SharedData : public Common::Serializable {
public:
SharedData() {
cdNumber = 0;
@@ -333,9 +354,145 @@ public:
}
}
+ void saveLoadAmbientSoundData(Common::Serializer &s) {
+ // Ambient sound flags/ticks
+ for (uint32 i = 0; i < ARRAYSIZE(_ambientFlags); i++)
+ s.syncAsUint32LE(_ambientFlags[i]);
+
+ for (uint32 i = 0; i < ARRAYSIZE(_ambientTicks); i++)
+ s.syncAsUint32LE(_ambientTicks[i]);
+ }
+
+ void saveLoadWithSerializer(Common::Serializer &s) {
+ // Original skips two elements (original has one unused, one used for debugging screen update counts)
+ s.skip(8);
+
+ // Script queue (part of ScriptManager)
+
+ // Global coordinates (original uses int32 for coordinates)
+ s.syncAsSint32LE(point.x);
+ s.syncAsSint32LE(point.y);
+
+ // Processing skipped (part of ScriptManager)
+ // Encounter running (part of Encounter)
+
+ // Player index
+ //s.syncAsUint32LE(playerIndex);
+
+ // Scene coordinates
+ s.syncAsSint32LE(sceneXLeft);
+ s.syncAsSint32LE(sceneYTop);
+ s.syncAsSint32LE(sceneOffset);
+ s.syncAsSint32LE(sceneOffsetAdd);
+
+ // Original skips 4 bytes
+ s.skip(4);
+
+ // Cursor resources
+ for (uint32 i = 0; i < ARRAYSIZE(cursorResources); i++)
+ s.syncAsUint32LE(cursorResources[i]);
+
+ // Fonts
+ for (uint32 i = 0; i < ARRAYSIZE(sceneFonts); i++)
+ s.syncAsUint32LE(sceneFonts[i]);
+
+ // Chapter 2 actor data (Part 1)
+ //for (uint32 i = 0; i < ARRAYSIZE(chapter2ActorData1); i++)
+ // s.syncAsUint32LE(chapter2ActorData1[i]);
+
+ // Original skips 4 bytes
+ s.skip(4);
+
+ // Scene information
+ s.syncAsSint32LE(smallCurUp);
+ s.syncAsSint32LE(smallCurDown);
+ s.syncAsSint32LE(encounterFrameBg);
+ s.syncAsUint32LE(_flagSkipDrawScene);
+ s.syncAsSint32LE(matteVar1);
+ s.syncAsUint32LE(actorUpdateEnabledCheck);
+ s.syncAsUint32LE(matteInitialized);
+ s.syncAsUint32LE(mattePlaySound);
+ s.syncAsSint32LE(currentScreenUpdatesCount);
+
+ // Chapter 2 actor data (Part 2)
+ //for (uint32 i = 0; i < ARRAYSIZE(chapter2ActorData2); i++)
+ // s.syncAsUint32LE(chapter2ActorData2[i]);
+
+ // Chapter 2 counters (1-4)
+ //s.syncAsSint32LE(chapter2Counter1);
+ //s.syncAsSint32LE(chapter2Counter2);
+ //s.syncAsSint32LE(chapter2Counter3);
+ //s.syncAsSint32LE(chapter2Counter4);
+
+ // Original skips 4 bytes
+ s.skip(4);
+
+ // Chapter 2 actor data (Part 3)
+ //for (uint32 i = 0; i < ARRAYSIZE(chapter2ActorData3); i++)
+ // s.syncAsUint32LE(chapter2ActorData3[i]);
+
+ // Original skips 4 bytes
+ s.skip(4);
+
+ // Chapter2 points
+ //for (uint32 i = 0; i < ARRAYSIZE(chapter2Points); i++) {
+ // s.syncAsSint32LE(chapter2Points[i].x);
+ // s.syncAsSint32LE(chapter2Points[i].y);
+ //}
+
+ // Original skips 4 bytes
+ s.skip(4);
+
+ // Chapter 2 counter (5) and other data
+ //s.syncAsSint32LE(chapter2Counter5);
+ //s.syncAsSint32LE(chapter2FrameIndexOffset);
+ //s.syncAsSint32LE(chapter2ActorIndex);
+
+ //s.syncAsSint32LE(eventUpdateFlag);
+
+ // Chapter 2 counters (6-8)
+ //s.syncAsSint32LE(chapter2Counter6);
+ //s.syncAsSint32LE(chapter2Counter7);
+ //s.syncAsSint32LE(chapter2Counter8);
+
+ // Original skips 7 * 4 bytes
+ s.skip(7 * 4);
+
+ // Chapter 2 actor data (Part 4)
+ //for (uint32 i = 0; i < ARRAYSIZE(chapter2ActorData4); i++)
+ // s.syncAsUint32LE(chapter2ActorData4[i]);
+
+ // Original skips 8 * 4 bytes
+ s.skip(8 * 4);
+
+ // Actor UpdateStatusEnabled Counter
+ s.syncAsSint32LE(actorUpdateStatusEnabledCounter);
+
+ // Chapter2 actor data (part 5)
+ //for (uint32 i = 0; i < ARRAYSIZE(chapter2ActorData5); i++)
+ // s.syncAsUint32LE(chapter2ActorData5[i]);
+
+ // Encounter disable player on exit
+ //s.syncAsSint32LE(encounterDisablePlayerOnExit);
+
+ // Scene flag 1
+ s.syncAsUint32LE(_flagScene1);
+
+ // Next screen update
+ s.syncAsUint32LE(nextScreenUpdate);
+
+ // Viewed movies (we also load it from an external file...)
+ //s.syncBytes(&_moviesViewed, sizeof(_moviesViewed));
+
+ // Actor update status 15 check
+ s.syncAsUint32LE(actorUpdateStatus15Check);
+
+ // TODO More?
+ }
+
private:
uint32 _ambientFlags[15];
- uint32 _ambientTicks[17];
+ uint32 _ambientTicks[15];
// Flags
bool _flag1;
Commit: e130e128b4ab9b7e79d63466ca700ca411820af3
https://github.com/scummvm/scummvm/commit/e130e128b4ab9b7e79d63466ca700ca411820af3
Author: Littleboy (littleboy at scummvm.org)
Date: 2021-05-17T15:37:12+02:00
Commit Message:
ASYLUM: Implement AsylumEngine::saveLoadWithSerializer()
Changed paths:
engines/asylum/asylum.cpp
diff --git a/engines/asylum/asylum.cpp b/engines/asylum/asylum.cpp
index 3382ea6de5..a7e8c0cda0 100644
--- a/engines/asylum/asylum.cpp
+++ b/engines/asylum/asylum.cpp
@@ -553,7 +553,20 @@ void AsylumEngine::updateReverseStereo() {
}
void AsylumEngine::saveLoadWithSerializer(Common::Serializer &s) {
- error("[AsylumEngine::saveLoadWithSerializer] Not implemented!");
+ // Game flags
+ for (uint32 i = 0; i < ARRAYSIZE(_gameFlags); i++)
+ s.syncAsSint32LE(_gameFlags[i]);
+
+ // The original has the script data in the middle of other shared data,
+ // so to be compatible with original savegames, we want to save it in
+ // the proper order
+ _data.saveLoadAmbientSoundData(s);
+
+ // Script queue
+ _script->saveLoadWithSerializer(s);
+
+ // Shared data (the rest of it)
+ _data.saveLoadWithSerializer(s);
}
//////////////////////////////////////////////////////////////////////////
Commit: 5aad67007b22d0ed43deef9fb3b0ee1bf9b33a70
https://github.com/scummvm/scummvm/commit/5aad67007b22d0ed43deef9fb3b0ee1bf9b33a70
Author: Littleboy (littleboy at scummvm.org)
Date: 2021-05-17T15:37:12+02:00
Commit Message:
ASYLUM: Change SharedData into a class and move method implementations into cpp file
Changed paths:
A engines/asylum/resources/data.cpp
engines/asylum/module.mk
engines/asylum/resources/data.h
diff --git a/engines/asylum/module.mk b/engines/asylum/module.mk
index 05acbfe787..9a87af312d 100644
--- a/engines/asylum/module.mk
+++ b/engines/asylum/module.mk
@@ -20,6 +20,7 @@ MODULE_OBJS := \
puzzles/wheel.o \
puzzles/writings.o \
resources/actor.o \
+ resources/data.o \
resources/object.o \
resources/encounters.o \
resources/polygons.o \
diff --git a/engines/asylum/resources/data.cpp b/engines/asylum/resources/data.cpp
new file mode 100644
index 0000000000..5e41599ae0
--- /dev/null
+++ b/engines/asylum/resources/data.cpp
@@ -0,0 +1,351 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "engines/asylum/resources/data.h"
+
+#include "common/rect.h"
+#include "common/serializer.h"
+#include "common/textconsole.h"
+
+namespace Asylum {
+
+SharedData::SharedData() {
+ cdNumber = 0;
+ actorEnableForStatus7 = false;
+ _flag1 = false;
+ _flag2 = false;
+ _flag3 = false;
+ matteBarHeight = 0;
+ matteVar2 = 0;
+ sceneCounter = 0;
+ point.x = -1;
+ point.y = -1;
+ sceneXLeft = 0;
+ sceneYTop = 0;
+ sceneOffset = 0;
+ sceneOffsetAdd = 0;
+ memset(&cursorResources, kResourceNone, sizeof(cursorResources));
+ memset(&sceneFonts, kResourceNone, sizeof(sceneFonts));
+ //_currentPaletteId = kResourceNone;
+ //memset(&cellShadeMasks, 0, sizeof(cellShadeMasks));
+ smallCurUp = 0;
+ smallCurDown = 0;
+ encounterFrameBg = 0;
+ _flagSkipDrawScene = false;
+ matteVar1 = 0;
+ actorUpdateEnabledCheck = false;
+ matteInitialized = false;
+ mattePlaySound = false;
+ currentScreenUpdatesCount = 0;
+ memset(&_data1, 0, sizeof(_data1));
+ memset(&_data2, 0, sizeof(_data2));
+ actorUpdateStatusEnabledCounter = 0;
+ memset(&_data3, 0, sizeof(_data3));
+ _flagScene1 = false;
+ //memset(&_movies, 0, sizeof(_movies));
+ actorUpdateStatus15Check = false;
+ _flag2 = false;
+ globalDirection = kDirectionN;
+ memset(&_ambientTicks, 0, sizeof(_ambientTicks));
+
+ // Screen updates
+ _flagRedraw = false;
+ nextScreenUpdate = 0;
+ movieIndex = 0;
+}
+
+void SharedData::setData(ActorIndex index, int32 val) {
+ if (index < 50)
+ _data1[index] = val;
+ else if (index < 60)
+ _data2[index - 50] = val;
+ else
+ error("[SharedData::setData] index is outside valid values (was: %d, valid: [0:60]", index);
+}
+
+int32 SharedData::getData(ActorIndex index) {
+ if (index < 50)
+ return _data1[index];
+ else if (index < 60)
+ return _data2[index - 50];
+ else
+ error("[SharedData::getData] index is outside valid values (was: %d, valid: [0:60]", index);
+}
+
+void SharedData::setData2(ActorIndex index, bool val) {
+ if (index <= 12 || index > 20)
+ error("[SharedData::setData2] index is outside valid values (was: %d, valid: [13:20]", index);
+
+ _data3[index - 12] = val;
+}
+
+bool SharedData::getData2(ActorIndex index) {
+ if (index <= 12 || index > 20)
+ error("[SharedData::getData2] index is outside valid values (was: %d, valid: [13:20]", index);
+
+ return _data3[index - 12];
+}
+
+void SharedData::resetActorData() {
+ for (int i = 0; i < 9; i++) {
+ _data1[i] = 160;
+ _data1[i + 18] = 0;
+ _data3[i] = 0;
+ }
+}
+
+uint32 SharedData::getAmbientTick(uint32 index) {
+ if (index >= ARRAYSIZE(_ambientTicks))
+ error("[SharedData::getAmbientTick] index is outside valid values (was: %d, valid: [0:%d]", index, ARRAYSIZE(_ambientTicks));
+
+ return _ambientTicks[index];
+};
+
+void SharedData::setAmbientTick(uint32 index, uint32 val) {
+ if (index >= ARRAYSIZE(_ambientTicks))
+ error("[SharedData::setAmbientTick] index is outside valid values (was: %d, valid: [0:%d]", index, ARRAYSIZE(_ambientTicks));
+
+ _ambientTicks[index] = val;
+};
+
+uint32 SharedData::getAmbientFlag(uint32 index) {
+ if (index >= ARRAYSIZE(_ambientFlags))
+ error("[SharedData::getAmbientFlag] index is outside valid values (was: %d, valid: [0:%d]", index, ARRAYSIZE(_ambientFlags));
+
+ return _ambientFlags[index];
+};
+
+void SharedData::setAmbientFlag(uint32 index, uint32 val) {
+ if (index >= ARRAYSIZE(_ambientFlags))
+ error("[SharedData::setAmbientFlag] index is outside valid values (was: %d, valid: [0:%d]", index, ARRAYSIZE(_ambientFlags));
+
+ _ambientFlags[index] = val;
+};
+
+void SharedData::resetAmbientFlags() {
+ memset(&_ambientFlags, 0, sizeof(_ambientFlags));
+}
+
+//////////////////////////////////////////////////////////////////////////
+// Flags
+//////////////////////////////////////////////////////////////////////////
+bool SharedData::getFlag(GlobalFlag flag) const {
+ switch (flag) {
+ default:
+ error("[SharedData::getFlag] Invalid flag type (%d)!", flag);
+
+ case kFlag1:
+ return _flag1;
+
+ case kFlag2:
+ return _flag2;
+
+ case kFlag3:
+ return _flag3;
+
+ case kFlagRedraw:
+ return _flagRedraw;
+ break;
+
+ case kFlagSkipDrawScene:
+ return _flagSkipDrawScene;
+
+ case kFlagSceneRectChanged:
+ error("[SharedData::getFlag] Invalid flag type (kFlagSceneRectChanged)!");
+
+ case kFlagScene1:
+ return _flagScene1;
+ }
+}
+
+void SharedData::setFlag(GlobalFlag flag, bool state) {
+ switch (flag) {
+ default:
+ error("[SharedData::getFlag] Invalid flag type (%d)!", flag);
+
+ case kFlag1:
+ _flag1 = state;
+ break;
+
+ case kFlag2:
+ _flag2 = state;
+ break;
+
+ case kFlag3:
+ _flag3 = state;
+ break;
+
+ case kFlagRedraw:
+ _flagRedraw = state;
+ break;
+
+ case kFlagSkipDrawScene:
+ _flagSkipDrawScene = state;
+ break;
+
+ case kFlagSceneRectChanged:
+ error("[SharedData::getFlag] Invalid flag type (kFlagSceneRectChanged)!");
+ break;
+
+ case kFlagScene1:
+ _flagScene1 = state;
+ break;
+ }
+}
+
+void SharedData::saveLoadAmbientSoundData(Common::Serializer &s) {
+ // Ambient sound flags/ticks
+ for (uint32 i = 0; i < ARRAYSIZE(_ambientFlags); i++)
+ s.syncAsUint32LE(_ambientFlags[i]);
+
+ for (uint32 i = 0; i < ARRAYSIZE(_ambientTicks); i++)
+ s.syncAsUint32LE(_ambientTicks[i]);
+}
+
+void SharedData::saveLoadWithSerializer(Common::Serializer &s) {
+ // Original skips two elements (original has one unused, one used for debugging screen update counts)
+ s.skip(8);
+
+ // Script queue (part of ScriptManager)
+
+ // Global coordinates (original uses int32 for coordinates)
+ s.syncAsSint32LE(point.x);
+ s.syncAsSint32LE(point.y);
+
+ // Processing skipped (part of ScriptManager)
+ // Encounter running (part of Encounter)
+
+ // Player index
+ //s.syncAsUint32LE(playerIndex);
+
+ // Scene coordinates
+ s.syncAsSint32LE(sceneXLeft);
+ s.syncAsSint32LE(sceneYTop);
+ s.syncAsSint32LE(sceneOffset);
+ s.syncAsSint32LE(sceneOffsetAdd);
+
+ // Original skips 4 bytes
+ s.skip(4);
+
+ // Cursor resources
+ for (uint32 i = 0; i < ARRAYSIZE(cursorResources); i++)
+ s.syncAsUint32LE(cursorResources[i]);
+
+ // Fonts
+ for (uint32 i = 0; i < ARRAYSIZE(sceneFonts); i++)
+ s.syncAsUint32LE(sceneFonts[i]);
+
+ // Chapter 2 actor data (Part 1)
+ //for (uint32 i = 0; i < ARRAYSIZE(chapter2ActorData1); i++)
+ // s.syncAsUint32LE(chapter2ActorData1[i]);
+
+ // Original skips 4 bytes
+ s.skip(4);
+
+ // Scene information
+ s.syncAsSint32LE(smallCurUp);
+ s.syncAsSint32LE(smallCurDown);
+ s.syncAsSint32LE(encounterFrameBg);
+ s.syncAsUint32LE(_flagSkipDrawScene);
+ s.syncAsSint32LE(matteVar1);
+ s.syncAsUint32LE(actorUpdateEnabledCheck);
+ s.syncAsUint32LE(matteInitialized);
+ s.syncAsUint32LE(mattePlaySound);
+ s.syncAsSint32LE(currentScreenUpdatesCount);
+
+ // Chapter 2 actor data (Part 2)
+ //for (uint32 i = 0; i < ARRAYSIZE(chapter2ActorData2); i++)
+ // s.syncAsUint32LE(chapter2ActorData2[i]);
+
+ // Chapter 2 counters (1-4)
+ //s.syncAsSint32LE(chapter2Counter1);
+ //s.syncAsSint32LE(chapter2Counter2);
+ //s.syncAsSint32LE(chapter2Counter3);
+ //s.syncAsSint32LE(chapter2Counter4);
+
+ // Original skips 4 bytes
+ s.skip(4);
+
+ // Chapter 2 actor data (Part 3)
+ //for (uint32 i = 0; i < ARRAYSIZE(chapter2ActorData3); i++)
+ // s.syncAsUint32LE(chapter2ActorData3[i]);
+
+ // Original skips 4 bytes
+ s.skip(4);
+
+ // Chapter2 points
+ //for (uint32 i = 0; i < ARRAYSIZE(chapter2Points); i++) {
+ // s.syncAsSint32LE(chapter2Points[i].x);
+ // s.syncAsSint32LE(chapter2Points[i].y);
+ //}
+
+ // Original skips 4 bytes
+ s.skip(4);
+
+ // Chapter 2 counter (5) and other data
+ //s.syncAsSint32LE(chapter2Counter5);
+ //s.syncAsSint32LE(chapter2FrameIndexOffset);
+ //s.syncAsSint32LE(chapter2ActorIndex);
+
+ //s.syncAsSint32LE(eventUpdateFlag);
+
+ // Chapter 2 counters (6-8)
+ //s.syncAsSint32LE(chapter2Counter6);
+ //s.syncAsSint32LE(chapter2Counter7);
+ //s.syncAsSint32LE(chapter2Counter8);
+
+ // Original skips 7 * 4 bytes
+ s.skip(7 * 4);
+
+ // Chapter 2 actor data (Part 4)
+ //for (uint32 i = 0; i < ARRAYSIZE(chapter2ActorData4); i++)
+ // s.syncAsUint32LE(chapter2ActorData4[i]);
+
+ // Original skips 8 * 4 bytes
+ s.skip(8 * 4);
+
+ // Actor UpdateStatusEnabled Counter
+ s.syncAsSint32LE(actorUpdateStatusEnabledCounter);
+
+ // Chapter2 actor data (part 5)
+ //for (uint32 i = 0; i < ARRAYSIZE(chapter2ActorData5); i++)
+ // s.syncAsUint32LE(chapter2ActorData5[i]);
+
+ // Encounter disable player on exit
+ //s.syncAsSint32LE(encounterDisablePlayerOnExit);
+
+ // Scene flag 1
+ s.syncAsUint32LE(_flagScene1);
+
+ // Next screen update
+ s.syncAsUint32LE(nextScreenUpdate);
+
+ // Viewed movies (we also load it from an external file...)
+ //s.syncBytes(&_moviesViewed, sizeof(_moviesViewed));
+
+ // Actor update status 15 check
+ s.syncAsUint32LE(actorUpdateStatus15Check);
+
+ // TODO More?
+}
+
+} // End of namespace Asylum
diff --git a/engines/asylum/resources/data.h b/engines/asylum/resources/data.h
index 2acd1b1d95..4f763ab494 100644
--- a/engines/asylum/resources/data.h
+++ b/engines/asylum/resources/data.h
@@ -25,7 +25,6 @@
#include "engines/asylum/shared.h"
-#include "common/rational.h"
#include "common/rect.h"
#include "common/serializer.h"
@@ -120,52 +119,9 @@ enum GlobalFlag {
* -- scripts (reset on scene load)
* -- polygons (reset on scene load)
*/
-struct SharedData : public Common::Serializable {
+class SharedData : public Common::Serializable {
public:
- SharedData() {
- cdNumber = 0;
- actorEnableForStatus7 = false;
- _flag1 = false;
- _flag2 = false;
- _flag3 = false;
- matteBarHeight = 0;
- matteVar2 = 0;
- sceneCounter = 0;
- point.x = -1;
- point.y = -1;
- sceneXLeft = 0;
- sceneYTop = 0;
- sceneOffset = 0;
- sceneOffsetAdd = 0;
- memset(&cursorResources, kResourceNone, sizeof(cursorResources));
- memset(&sceneFonts, kResourceNone, sizeof(sceneFonts));
- //_currentPaletteId = kResourceNone;
- //memset(&cellShadeMasks, 0, sizeof(cellShadeMasks));
- smallCurUp = 0;
- smallCurDown = 0;
- encounterFrameBg = 0;
- _flagSkipDrawScene = false;
- matteVar1 = 0;
- actorUpdateEnabledCheck = false;
- matteInitialized = false;
- mattePlaySound = false;
- currentScreenUpdatesCount = 0;
- memset(&_data1, 0, sizeof(_data1));
- memset(&_data2, 0, sizeof(_data2));
- actorUpdateStatusEnabledCounter = 0;
- memset(&_data3, 0, sizeof(_data3));
- _flagScene1 = false;
- //memset(&_movies, 0, sizeof(_movies));
- actorUpdateStatus15Check = false;
- _flag2 = false;
- globalDirection = kDirectionN;
- memset(&_ambientTicks, 0, sizeof(_ambientTicks));
-
- // Screen updates
- _flagRedraw = false;
- nextScreenUpdate = 0;
- movieIndex = 0;
- }
+ SharedData();
// Public variables
int32 cdNumber;
@@ -214,281 +170,29 @@ public:
int32 getActorUpdateFlag2() { return _data1[36]; }
- void setData(ActorIndex index, int32 val) {
- if (index < 50)
- _data1[index] = val;
- else if (index < 60)
- _data2[index - 50] = val;
- else
- error("[SharedData::setData] index is outside valid values (was: %d, valid: [0:60]", index);
- }
-
- int32 getData(ActorIndex index) {
- if (index < 50)
- return _data1[index];
- else if (index < 60)
- return _data2[index - 50];
- else
- error("[SharedData::getData] index is outside valid values (was: %d, valid: [0:60]", index);
- }
-
- void setData2(ActorIndex index, bool val) {
- if (index <= 12 || index > 20)
- error("[SharedData::setData2] index is outside valid values (was: %d, valid: [13:20]", index);
-
- _data3[index - 12] = val;
- }
-
- bool getData2(ActorIndex index) {
- if (index <= 12 || index > 20)
- error("[SharedData::getData2] index is outside valid values (was: %d, valid: [13:20]", index);
-
- return _data3[index - 12];
- }
+ // TODO Remove and replace by accessors
+ void setData(ActorIndex index, int32 val);
+ int32 getData(ActorIndex index);
+ void setData2(ActorIndex index, bool val);
+ bool getData2(ActorIndex index);
// Used by Actor::enableActorsChapter2 (and maybe others)
- void resetActorData() {
- for (int i = 0; i < 9; i++) {
- _data1[i] = 160;
- _data1[i + 18] = 0;
- _data3[i] = 0;
- }
- }
-
- uint32 getAmbientTick(uint32 index) {
- if (index >= ARRAYSIZE(_ambientTicks))
- error("[SharedData::getAmbientTick] index is outside valid values (was: %d, valid: [0:%d]", index, ARRAYSIZE(_ambientTicks));
-
- return _ambientTicks[index];
- };
+ void resetActorData();
- void setAmbientTick(uint32 index, uint32 val) {
- if (index >= ARRAYSIZE(_ambientTicks))
- error("[SharedData::setAmbientTick] index is outside valid values (was: %d, valid: [0:%d]", index, ARRAYSIZE(_ambientTicks));
+ // Ambient sound data
+ uint32 getAmbientTick(uint32 index);
+ void setAmbientTick(uint32 index, uint32 val);
+ uint32 getAmbientFlag(uint32 index);
+ void setAmbientFlag(uint32 index, uint32 val);
+ void resetAmbientFlags();
- _ambientTicks[index] = val;
- };
-
- uint32 getAmbientFlag(uint32 index) {
- if (index >= ARRAYSIZE(_ambientFlags))
- error("[SharedData::getAmbientFlag] index is outside valid values (was: %d, valid: [0:%d]", index, ARRAYSIZE(_ambientFlags));
-
- return _ambientFlags[index];
- };
-
- void setAmbientFlag(uint32 index, uint32 val) {
- if (index >= ARRAYSIZE(_ambientFlags))
- error("[SharedData::setAmbientFlag] index is outside valid values (was: %d, valid: [0:%d]", index, ARRAYSIZE(_ambientFlags));
-
- _ambientFlags[index] = val;
- };
-
- void resetAmbientFlags() {
- memset(&_ambientFlags, 0, sizeof(_ambientFlags));
- }
-
- //////////////////////////////////////////////////////////////////////////
// Flags
- //////////////////////////////////////////////////////////////////////////
- bool getFlag(GlobalFlag flag) const {
- switch (flag) {
- default:
- error("[SharedData::getFlag] Invalid flag type (%d)!", flag);
-
- case kFlag1:
- return _flag1;
-
- case kFlag2:
- return _flag2;
-
- case kFlag3:
- return _flag3;
-
- case kFlagRedraw:
- return _flagRedraw;
- break;
-
- case kFlagSkipDrawScene:
- return _flagSkipDrawScene;
-
- case kFlagSceneRectChanged:
- error("[SharedData::getFlag] Invalid flag type (kFlagSceneRectChanged)!");
-
- case kFlagScene1:
- return _flagScene1;
- }
- }
-
- void setFlag(GlobalFlag flag, bool state) {
- switch (flag) {
- default:
- error("[SharedData::getFlag] Invalid flag type (%d)!", flag);
-
- case kFlag1:
- _flag1 = state;
- break;
-
- case kFlag2:
- _flag2 = state;
- break;
-
- case kFlag3:
- _flag3 = state;
- break;
-
- case kFlagRedraw:
- _flagRedraw = state;
- break;
-
- case kFlagSkipDrawScene:
- _flagSkipDrawScene = state;
- break;
-
- case kFlagSceneRectChanged:
- error("[SharedData::getFlag] Invalid flag type (kFlagSceneRectChanged)!");
- break;
-
- case kFlagScene1:
- _flagScene1 = state;
- break;
- }
- }
-
- void saveLoadAmbientSoundData(Common::Serializer &s) {
- // Ambient sound flags/ticks
- for (uint32 i = 0; i < ARRAYSIZE(_ambientFlags); i++)
- s.syncAsUint32LE(_ambientFlags[i]);
-
- for (uint32 i = 0; i < ARRAYSIZE(_ambientTicks); i++)
- s.syncAsUint32LE(_ambientTicks[i]);
- }
-
- void saveLoadWithSerializer(Common::Serializer &s) {
- // Original skips two elements (original has one unused, one used for debugging screen update counts)
- s.skip(8);
-
- // Script queue (part of ScriptManager)
-
- // Global coordinates (original uses int32 for coordinates)
- s.syncAsSint32LE(point.x);
- s.syncAsSint32LE(point.y);
-
- // Processing skipped (part of ScriptManager)
- // Encounter running (part of Encounter)
-
- // Player index
- //s.syncAsUint32LE(playerIndex);
-
- // Scene coordinates
- s.syncAsSint32LE(sceneXLeft);
- s.syncAsSint32LE(sceneYTop);
- s.syncAsSint32LE(sceneOffset);
- s.syncAsSint32LE(sceneOffsetAdd);
-
- // Original skips 4 bytes
- s.skip(4);
-
- // Cursor resources
- for (uint32 i = 0; i < ARRAYSIZE(cursorResources); i++)
- s.syncAsUint32LE(cursorResources[i]);
-
- // Fonts
- for (uint32 i = 0; i < ARRAYSIZE(sceneFonts); i++)
- s.syncAsUint32LE(sceneFonts[i]);
-
- // Chapter 2 actor data (Part 1)
- //for (uint32 i = 0; i < ARRAYSIZE(chapter2ActorData1); i++)
- // s.syncAsUint32LE(chapter2ActorData1[i]);
-
- // Original skips 4 bytes
- s.skip(4);
-
- // Scene information
- s.syncAsSint32LE(smallCurUp);
- s.syncAsSint32LE(smallCurDown);
- s.syncAsSint32LE(encounterFrameBg);
- s.syncAsUint32LE(_flagSkipDrawScene);
- s.syncAsSint32LE(matteVar1);
- s.syncAsUint32LE(actorUpdateEnabledCheck);
- s.syncAsUint32LE(matteInitialized);
- s.syncAsUint32LE(mattePlaySound);
- s.syncAsSint32LE(currentScreenUpdatesCount);
-
- // Chapter 2 actor data (Part 2)
- //for (uint32 i = 0; i < ARRAYSIZE(chapter2ActorData2); i++)
- // s.syncAsUint32LE(chapter2ActorData2[i]);
-
- // Chapter 2 counters (1-4)
- //s.syncAsSint32LE(chapter2Counter1);
- //s.syncAsSint32LE(chapter2Counter2);
- //s.syncAsSint32LE(chapter2Counter3);
- //s.syncAsSint32LE(chapter2Counter4);
-
- // Original skips 4 bytes
- s.skip(4);
-
- // Chapter 2 actor data (Part 3)
- //for (uint32 i = 0; i < ARRAYSIZE(chapter2ActorData3); i++)
- // s.syncAsUint32LE(chapter2ActorData3[i]);
-
- // Original skips 4 bytes
- s.skip(4);
-
- // Chapter2 points
- //for (uint32 i = 0; i < ARRAYSIZE(chapter2Points); i++) {
- // s.syncAsSint32LE(chapter2Points[i].x);
- // s.syncAsSint32LE(chapter2Points[i].y);
- //}
-
- // Original skips 4 bytes
- s.skip(4);
-
- // Chapter 2 counter (5) and other data
- //s.syncAsSint32LE(chapter2Counter5);
- //s.syncAsSint32LE(chapter2FrameIndexOffset);
- //s.syncAsSint32LE(chapter2ActorIndex);
-
- //s.syncAsSint32LE(eventUpdateFlag);
-
- // Chapter 2 counters (6-8)
- //s.syncAsSint32LE(chapter2Counter6);
- //s.syncAsSint32LE(chapter2Counter7);
- //s.syncAsSint32LE(chapter2Counter8);
-
- // Original skips 7 * 4 bytes
- s.skip(7 * 4);
-
- // Chapter 2 actor data (Part 4)
- //for (uint32 i = 0; i < ARRAYSIZE(chapter2ActorData4); i++)
- // s.syncAsUint32LE(chapter2ActorData4[i]);
-
- // Original skips 8 * 4 bytes
- s.skip(8 * 4);
-
- // Actor UpdateStatusEnabled Counter
- s.syncAsSint32LE(actorUpdateStatusEnabledCounter);
-
- // Chapter2 actor data (part 5)
- //for (uint32 i = 0; i < ARRAYSIZE(chapter2ActorData5); i++)
- // s.syncAsUint32LE(chapter2ActorData5[i]);
-
- // Encounter disable player on exit
- //s.syncAsSint32LE(encounterDisablePlayerOnExit);
-
- // Scene flag 1
- s.syncAsUint32LE(_flagScene1);
-
- // Next screen update
- s.syncAsUint32LE(nextScreenUpdate);
-
- // Viewed movies (we also load it from an external file...)
- //s.syncBytes(&_moviesViewed, sizeof(_moviesViewed));
-
- // Actor update status 15 check
- s.syncAsUint32LE(actorUpdateStatus15Check);
+ bool getFlag(GlobalFlag flag) const;
+ void setFlag(GlobalFlag flag, bool state);
- // TODO More?
- }
+ // Serializer
+ void saveLoadAmbientSoundData(Common::Serializer &s);
+ void saveLoadWithSerializer(Common::Serializer &s);
private:
uint32 _ambientFlags[15];
Commit: 906cbe7a233fac2a4c619838957e5f99d622b546
https://github.com/scummvm/scummvm/commit/906cbe7a233fac2a4c619838957e5f99d622b546
Author: Littleboy (littleboy at scummvm.org)
Date: 2021-05-17T15:37:12+02:00
Commit Message:
ASYLUM: Rename puzzles/data.h to puzzles/puzzledata.h
Changed paths:
A engines/asylum/puzzles/puzzledata.h
R engines/asylum/puzzles/data.h
engines/asylum/asylum.h
engines/asylum/system/savegame.cpp
diff --git a/engines/asylum/asylum.h b/engines/asylum/asylum.h
index d0e64f532b..fb27c69495 100644
--- a/engines/asylum/asylum.h
+++ b/engines/asylum/asylum.h
@@ -23,7 +23,7 @@
#ifndef ASYLUM_ENGINE_H
#define ASYLUM_ENGINE_H
-#include "asylum/puzzles/data.h"
+#include "asylum/puzzles/puzzledata.h"
#include "asylum/resources/data.h"
#include "asylum/console.h"
diff --git a/engines/asylum/puzzles/data.h b/engines/asylum/puzzles/puzzledata.h
similarity index 100%
rename from engines/asylum/puzzles/data.h
rename to engines/asylum/puzzles/puzzledata.h
diff --git a/engines/asylum/system/savegame.cpp b/engines/asylum/system/savegame.cpp
index 9660c9ab87..c2cd810bce 100644
--- a/engines/asylum/system/savegame.cpp
+++ b/engines/asylum/system/savegame.cpp
@@ -22,7 +22,7 @@
#include "asylum/system/savegame.h"
-#include "asylum/puzzles/data.h"
+#include "asylum/puzzles/puzzledata.h"
#include "asylum/resources/encounters.h"
#include "asylum/resources/script.h"
Commit: 28363f844d0f02c860cc94bccbccfa674ce3300e
https://github.com/scummvm/scummvm/commit/28363f844d0f02c860cc94bccbccfa674ce3300e
Author: Littleboy (littleboy at scummvm.org)
Date: 2021-05-17T15:37:13+02:00
Commit Message:
ASYLUM: Reorganize SharedData
- Add accessors for most variables
- Add stubs for set/getChapter2Data()
Changed paths:
engines/asylum/asylum.cpp
engines/asylum/puzzles/vcr.cpp
engines/asylum/resources/actor.cpp
engines/asylum/resources/data.cpp
engines/asylum/resources/data.h
engines/asylum/resources/encounters.cpp
engines/asylum/resources/object.cpp
engines/asylum/resources/script.cpp
engines/asylum/resources/special.cpp
engines/asylum/resources/special.h
engines/asylum/system/sound.cpp
engines/asylum/views/menu.cpp
engines/asylum/views/scene.cpp
diff --git a/engines/asylum/asylum.cpp b/engines/asylum/asylum.cpp
index a7e8c0cda0..b4de77fe39 100644
--- a/engines/asylum/asylum.cpp
+++ b/engines/asylum/asylum.cpp
@@ -242,8 +242,7 @@ void AsylumEngine::restart() {
_encounter = new Encounter(this);
_script->resetQueue();
- _data.point.x = -1;
- _data.point.y = -1;
+ _data.setGlobalPoint(Common::Point(-1, -1));
reset();
@@ -266,10 +265,7 @@ void AsylumEngine::reset() {
initPuzzles();
// Reset shared data
- for (uint32 i = 0; i < 37; i++)
- _data.setData(i, 160);
-
- _data.setData(37, 1);
+ _data.reset();
// Reset special palette info
_special->reset(true);
diff --git a/engines/asylum/puzzles/vcr.cpp b/engines/asylum/puzzles/vcr.cpp
index 0d85635266..9ac731c0e6 100644
--- a/engines/asylum/puzzles/vcr.cpp
+++ b/engines/asylum/puzzles/vcr.cpp
@@ -78,14 +78,14 @@ bool PuzzleVCR::update(const AsylumEvent &evt) {
getSharedData()->setFlag(kFlagRedraw, true);
}
- if (ticks > getSharedData()->nextScreenUpdate) {
+ if (ticks > getSharedData()->getNextScreenUpdate()) {
if (getSharedData()->getFlag(kFlagRedraw)) {
getScreen()->copyBackBufferToScreen();
- getSharedData()->setData(39, getSharedData()->getData(39) ^ 1);
+ getSharedData()->setEventUpdate(getSharedData()->getEventUpdate() ^ 1);
getSharedData()->setFlag(kFlagRedraw, false);
- getSharedData()->nextScreenUpdate = ticks + 55;
+ getSharedData()->setNextScreenUpdate(ticks + 55);
}
}
diff --git a/engines/asylum/resources/actor.cpp b/engines/asylum/resources/actor.cpp
index e5d9f061aa..e564a9051a 100644
--- a/engines/asylum/resources/actor.cpp
+++ b/engines/asylum/resources/actor.cpp
@@ -1970,7 +1970,7 @@ void Actor::enableActorsChapter2(AsylumEngine *engine) {
engine->clearGameFlag(kGameFlag442);
// Reset shared data
- engine->data()->resetActorData();
+ engine->data()->resetChapter2Data();
engine->scene()->getActor(13)->enable();
engine->scene()->getActor(13)->processStatus(2300, 71, false);
@@ -1998,12 +1998,6 @@ void Actor::enableActorsChapter2(AsylumEngine *engine) {
engine->scene()->getActor(21)->enable();
engine->scene()->getActor(21)->processStatus(2541, 40, false);
-
- for (uint32 i = 0; i < 9; i++) {
- engine->data()->setData(i, 160);
- engine->data()->setData(i + 18, 0);
- engine->data()->setData(i + 44, 0);
- }
}
void Actor::updatePlayerChapter9(AsylumEngine *engine, int nextPlayer) {
@@ -2110,7 +2104,7 @@ void Actor::updatePumpkin(GameFlag flagToCheck, GameFlag flagToSet, ObjectId obj
_vm->setGameFlag(flagToSet);
_vm->clearGameFlag(flagToCheck);
- getSharedData()->setActorUpdateFlag2(getSharedData()->getActorUpdateFlag2() + 1);
+ getSharedData()->setChapter2Counter(5, getSharedData()->getChapter2Counter(5) + 1);
getWorld()->getObjectById(objectToUpdate)->setNextFrame(8);
getSound()->playSound(getWorld()->soundResourceIds[17], false, Config.sfxVolume - 10);
@@ -2210,7 +2204,7 @@ void Actor::updateStatusEnabled() {
Common::Point pt(poly.boundingRect.left + rnd(poly.boundingRect.width()),
poly.boundingRect.top + rnd(poly.boundingRect.height()));
- if (!getSharedData()->actorUpdateEnabledCheck) {
+ if (!getSharedData()->getFlag(kFlagActorUpdateEnabledCheck)) {
if (!isInActionArea(pt, area)) {
Common::Point polyPoint = poly.points[rnd(poly.count())];
processStatus(polyPoint.x, polyPoint.y, false);
@@ -2223,7 +2217,7 @@ void Actor::updateStatusEnabled() {
}
}
} else {
- switch (getSharedData()->actorUpdateStatusEnabledCounter) {
+ switch (getSharedData()->getActorUpdateStatusEnabledCounter()) {
default:
break;
@@ -2262,7 +2256,7 @@ void Actor::updateStatusEnabledProcessStatus(int32 testX, int32 testY, uint32 co
if (rnd(1000) < 5)
processStatus(testX, testY, false);
} else {
- getSharedData()->actorUpdateStatusEnabledCounter = counter;
+ getSharedData()->setActorUpdateStatusEnabledCounter(counter);
if (rnd(1000) < 5)
processStatus(setX, setY, false);
@@ -2297,10 +2291,10 @@ void Actor::updateStatus12_Chapter2() {
// Face actor
faceTarget(getScene()->getPlayerIndex(), kDirectionFromActor);
- int32 data = getSharedData()->getData(_index + 14);
+ int32 data = getSharedData()->getChapter2Data(3, _index + 1);
if (data > 0) {
_direction = (ActorDirection)(_direction + 4);
- getSharedData()->setData(_index + 14, data - 1);
+ getSharedData()->setChapter2Data(3, _index + 1, data - 1);
}
// Compute coordinates and distance
@@ -2320,8 +2314,8 @@ void Actor::updateStatus12_Chapter2() {
} else {
_frameIndex = 0;
- getSharedData()->setData(2 * _index + 19, player->getPoint1()->x - _point1.x);
- getSharedData()->setData(2 * _index + 20, player->getPoint1()->y - _point1.y);
+ getSharedData()->setChapter2Data(3, 2 * _index + 6, player->getPoint1()->x - _point1.x);
+ getSharedData()->setChapter2Data(3, 2 * _index + 7, player->getPoint1()->y - _point1.y);
updateStatus(kActorStatus18);
}
@@ -2343,7 +2337,7 @@ void Actor::updateStatus12_Chapter2_Actor11() {
// Update status
if (player->getStatus() == kActorStatus17 || !getScene()->getActor(10)->isVisible()) {
updateStatus(kActorStatusEnabled);
- getSharedData()->setData(_index - 8, 160);
+ getSharedData()->setChapter2Data(1, 3, 160); // &cursorResources + 8 + 11 (actorIndex)
}
// Face player
@@ -2471,48 +2465,43 @@ void Actor::updateStatus14() {
}
void Actor::updateStatus14_Chapter2() {
- if (!getSharedData()->getData2(_index)) {
- updateStatus(kActorStatus12);
- return;
- }
-
- // FIXME original calls getDistanceForFrame but does not seem to do anything with the results
+ // Original calls getDistanceForFrame but does not seem to do anything with the results
if (_status == kActorStatus17 || !getScene()->getActor(10)->isVisible()) {
updateStatus(kActorStatusEnabled);
- getSharedData()->setData(_index - 8, 160);
+ getSharedData()->setChapter2Data(1, (_index - 13) + 5, 160); // Index > 12
}
if (_status != kActorStatus16) {
- _point1.x -= getSharedData()->getData(2 * _index + 19);
- _point1.y -= getSharedData()->getData(2 * _index + 20) + 54;
+ _point1.x -= getSharedData()->getChapter2Data(3, 2 * _index + 6);
+ _point1.y -= getSharedData()->getChapter2Data(3, 2 * _index + 7) + 54;
}
if (_frameIndex == _frameCount - 1) {
_frameIndex = 0;
- if (getSharedData()->getData(_index + 6) <= 1 || _status == kActorStatus16 || _status == kActorStatus17) {
- getSharedData()->setData(_index + 6, getSharedData()->getData(_index + 6) + 1);
+ if (getSharedData()->getChapter2Data(2, _index + 6) <= 1 || _status == kActorStatus16 || _status == kActorStatus17) {
+ getSharedData()->setChapter2Data(2, _index + 6, getSharedData()->getChapter2Data(2, _index + 6) + 1);
} else {
updateStatus(kActorStatus15);
_point1.y -= 54;
- getSharedData()->setData(_index + 6, 0);
- getSharedData()->setData(_index, getSharedData()->getData(_index) + 54);
+ getSharedData()->setChapter2Data(2, _index + 6, 0);
+ getSharedData()->setChapter2Data(1, _index + 1, getSharedData()->getChapter2Data(1, _index + 1) + 54);
}
}
- if (_status == kActorStatus17 && getSharedData()->getData(_index + 6) < 100) {
+ if (_status == kActorStatus17 && getSharedData()->getChapter2Data(2, _index + 6) < 100) {
_point1.y -= 6;
- getSharedData()->setData(_index + 6, 100);
- getSharedData()->setData(_index, getSharedData()->getData(_index) + 6);
+ getSharedData()->setChapter2Data(2, _index + 6, 100);
+ getSharedData()->setChapter2Data(1, _index + 1, getSharedData()->getChapter2Data(1, _index + 1) + 6);
}
- if (getSharedData()->getData(_index + 6) > 99) {
+ if (getSharedData()->getChapter2Data(2, _index + 6) > 99) {
_point1.y -= 6;
- getSharedData()->setData(_index + 6, getSharedData()->getData(_index + 6) + 1);
- getSharedData()->setData(_index, getSharedData()->getData(_index) + 6);
+ getSharedData()->setChapter2Data(2, _index + 6, getSharedData()->getChapter2Data(2, _index + 6) + 1);
+ getSharedData()->setChapter2Data(1, _index + 1, getSharedData()->getChapter2Data(1, _index + 1) + 6);
- if (getSharedData()->getData(_index + 6) > 108) {
- getSharedData()->setData(_index + 6, 0);
+ if (getSharedData()->getChapter2Data(2, _index + 6) > 108) {
+ getSharedData()->setChapter2Data(2, _index + 6, 0);
updateStatus(kActorStatusEnabled);
@@ -2592,7 +2581,7 @@ void Actor::updateStatus15_Chapter2() {
if (_status == kActorStatus17 || !getScene()->getActor(10)->isVisible()) {
updateStatus(kActorStatusEnabled);
- getSharedData()->setData(_index - 8, 160);
+ getSharedData()->setChapter2Data(1, (_index - 13) + 5, 160); // Index > 12
}
if (_frameIndex == 1)
@@ -2608,7 +2597,7 @@ void Actor::updateStatus15_Chapter2() {
getScene()->getActor(_index + 9)->setDirection(_direction);
}
- if (_frameIndex < 5 || !getSharedData()->getData2(_index))
+ if (_frameIndex < 5 || !getSharedData()->getChapter2Data(4, _index + 7))
_frameIndex++;
if (sumPlayer.x > sum.x)
@@ -2632,7 +2621,7 @@ void Actor::updateStatus15_Chapter2() {
player->updateFromDirection((ActorDirection)((_direction + 4) & 7));
player->updateStatus(kActorStatus16);
- getSharedData()->setData2(_index, 0);
+ getSharedData()->setChapter2Data(4, _index + 7, 0);
}
}
@@ -2658,12 +2647,12 @@ void Actor::updateStatus15_Chapter2() {
_frameIndex = 0;
- if (getSharedData()->getData(40) <= 2)
+ if (getSharedData()->getChapter2Counter(6) <= 2)
processStatus(sum.x, sum.y, false);
else
updateStatus(kActorStatusEnabled);
- getSharedData()->setData2(_index, 0);
+ getSharedData()->setChapter2Data(4, _index + 7, 0);
}
}
@@ -2676,7 +2665,7 @@ void Actor::updateStatus15_Chapter2_Helper() {
if (_vm->isGameFlagSet(kGameFlag169))
actor39->getPoint1()->y += 80;
- switch (getSharedData()->getData(40)) {
+ switch (getSharedData()->getChapter2Counter(6)) {
default:
break;
@@ -2706,9 +2695,9 @@ void Actor::updateStatus15_Chapter2_Helper() {
break;
}
- getSharedData()->setData(40, getSharedData()->getData(40) + 1);
+ getSharedData()->setChapter2Counter(6, getSharedData()->getChapter2Counter(6) + 1);
- switch (getSharedData()->getData(40)) {
+ switch (getSharedData()->getChapter2Counter(6)) {
default:
break;
@@ -2737,7 +2726,7 @@ void Actor::updateStatus15_Chapter2_Player() {
if (_frameIndex == 1)
getSound()->playSound(getWorld()->soundResourceIds[3], false, Config.sfxVolume - 10);
- ActorIndex actorIndex = getSharedData()->getData(38);
+ ActorIndex actorIndex = getSharedData()->getChapter2ActorIndex();
if (_frameIndex == 3) {
if (actorIndex > 12) {
@@ -2839,7 +2828,7 @@ void Actor::updateStatus15_Chapter2_Player_Helper() {
Common::Point point11(actor11->getPoint1()->x + actor11->getPoint2()->x, actor11->getPoint1()->y + actor11->getPoint2()->y);
if (actor11->getStatus() == kActorStatus15 && euclidianDistance(point, point11) < 100) {
- Actor *actor = getScene()->getActor(getSharedData()->getData(38));
+ Actor *actor = getScene()->getActor(getSharedData()->getChapter2ActorIndex());
actor40->show();
actor40->setFrameIndex(0);
@@ -2848,7 +2837,7 @@ void Actor::updateStatus15_Chapter2_Player_Helper() {
if (actor11->getFrameIndex() <= 7) {
getSound()->playSound(getWorld()->soundResourceIds[9], false, Config.sfxVolume - 10);
- } else if (getSharedData()->getData(36) <= 6) {
+ } else if (getSharedData()->getChapter2Counter(5) <= 6) {
getSound()->playSound(getWorld()->soundResourceIds[9], false, Config.sfxVolume - 10);
} else {
getScene()->getActor(10)->updateStatus(kActorStatus17);
@@ -2879,19 +2868,19 @@ void Actor::updateStatus15_Chapter2_Actor11() {
break;
case 9:
- getSharedData()->setData(37, 1);
- getSharedData()->setData(42, getSharedData()->getData(42) + 1);
+ getSharedData()->setChapter2FrameIndexOffset(1);
+ getSharedData()->setChapter2Counter(8, getSharedData()->getChapter2Counter(8) + 1);
break;
case 11:
- if (getSharedData()->getData(42) >= 3)
- getSharedData()->setData(42, 0);
+ if (getSharedData()->getChapter2Counter(8) >= 3)
+ getSharedData()->setChapter2Counter(8, 0);
else
- getSharedData()->setData(37, -1);
+ getSharedData()->setChapter2FrameIndexOffset(-1);
break;
}
- _frameIndex += getSharedData()->getData(37);
+ _frameIndex += getSharedData()->getChapter2FrameIndexOffset();
Common::Point actionPoint = sum;
actionPoint.x += compareX(Common::Point(rect.left, rect.top), Common::Point(rect.right, rect.bottom), sumPlayer);
@@ -2906,10 +2895,10 @@ void Actor::updateStatus15_Chapter2_Actor11() {
if (_frameIndex > _frameCount - 1) {
_frameIndex = 0;
- if (!getSharedData()->actorUpdateStatus15Check) {
+ if (!getSharedData()->getFlag(kFlagActorUpdateStatus15Check)) {
updateStatus(kActorStatus12);
} else {
- getSharedData()->actorUpdateStatus15Check = false;
+ getSharedData()->setFlag(kFlagActorUpdateStatus15Check, false);
getScene()->getActor(11)->updateStatus(kActorStatus18);
}
}
@@ -2934,8 +2923,8 @@ void Actor::updateStatus15_Chapter2_Actor11() {
} else {
if ((abs(sum.y - sumPlayer.y) + abs(sum.x - sumPlayer.x)) < 100) {
- getSharedData()->setData(41, 5);
- getSharedData()->actorUpdateStatus15Check = true;
+ getSharedData()->setChapter2Counter(7, 5);
+ getSharedData()->setFlag(kFlagActorUpdateStatus15Check, true);
}
}
}
@@ -3051,13 +3040,13 @@ void Actor::updateStatus15_Chapter11_Player() {
}
void Actor::updateStatus16_Chapter2() {
- // We are sure to be the current player
+ Actor *player = getScene()->getActor();
- ++_frameIndex;
+ player->setFrameIndex(player->getFrameIndex() + 1);
- if (_frameIndex > _frameCount - 1) {
- if (getSharedData()->getData(40) <= 2) {
- _frameIndex = 0;
+ if (player->getFrameIndex() > (player->getFrameCount() - 1)) {
+ if (getSharedData()->getChapter2Counter(6) <= 2) {
+ player->setFrameIndex(0);
updateStatus(kActorStatus14);
} else {
_vm->clearGameFlag(kGameFlag438);
@@ -3070,7 +3059,7 @@ void Actor::updateStatus16_Chapter2() {
_vm->setGameFlag(kGameFlag219);
- _frameIndex = 0;
+ player->setFrameIndex(0);
updateStatus(kActorStatus17);
_vm->clearGameFlag(kGameFlag369);
@@ -3132,19 +3121,19 @@ void Actor::updateStatus17_Chapter2() {
void Actor::updateStatus18_Chapter2() {
Actor *player = getScene()->getActor();
- _point1.x = player->getPoint1()->x - getSharedData()->getData(2 * _index + 19);
- _point1.y = player->getPoint1()->y - getSharedData()->getData(2 * _index + 20);
+ _point1.x = player->getPoint1()->x - getSharedData()->getChapter2Data(3, 2 * _index + 6);
+ _point1.y = player->getPoint1()->y - getSharedData()->getChapter2Data(3, 2 * _index + 7);
_frameIndex++;
if (_frameIndex > _frameCount - 1) {
- getSharedData()->setData2(_index, true);
+ getSharedData()->setChapter2Data(4, _index + 7, true);
updateStatus(kActorStatus14);
_point1.y += 54;
getSound()->playSound(getWorld()->soundResourceIds[1], false, Config.sfxVolume - 10);
- getSharedData()->setData(_index, getSharedData()->getData(_index) - 54);
+ getSharedData()->setChapter2Data(1, _index + 1, getSharedData()->getChapter2Data(1, _index + 1) - 54);
}
}
@@ -3152,9 +3141,9 @@ void Actor::updateStatus18_Chapter2_Actor11() {
uint32 frameIndex = (_frameIndex < _frameCount) ? _frameIndex : 2 * _frameCount - _frameIndex - 1;
int32 distance = abs((double)getDistanceForFrame(_direction, frameIndex));
- getSharedData()->setData(41, getSharedData()->getData(41) + 1);
- if (getSharedData()->getData(41) > 14) {
- getSharedData()->setData(41, 0);
+ getSharedData()->setChapter2Counter(7, getSharedData()->getChapter2Counter(7) + 1);
+ if (getSharedData()->getChapter2Counter(7) > 14) {
+ getSharedData()->setChapter2Counter(7, 0);
updateStatus(kActorStatus12);
}
diff --git a/engines/asylum/resources/data.cpp b/engines/asylum/resources/data.cpp
index 5e41599ae0..3e42583593 100644
--- a/engines/asylum/resources/data.cpp
+++ b/engines/asylum/resources/data.cpp
@@ -29,90 +29,139 @@
namespace Asylum {
SharedData::SharedData() {
- cdNumber = 0;
- actorEnableForStatus7 = false;
- _flag1 = false;
- _flag2 = false;
- _flag3 = false;
- matteBarHeight = 0;
- matteVar2 = 0;
- sceneCounter = 0;
- point.x = -1;
- point.y = -1;
- sceneXLeft = 0;
- sceneYTop = 0;
- sceneOffset = 0;
- sceneOffsetAdd = 0;
- memset(&cursorResources, kResourceNone, sizeof(cursorResources));
- memset(&sceneFonts, kResourceNone, sizeof(sceneFonts));
- //_currentPaletteId = kResourceNone;
- //memset(&cellShadeMasks, 0, sizeof(cellShadeMasks));
- smallCurUp = 0;
- smallCurDown = 0;
- encounterFrameBg = 0;
- _flagSkipDrawScene = false;
- matteVar1 = 0;
- actorUpdateEnabledCheck = false;
- matteInitialized = false;
- mattePlaySound = false;
- currentScreenUpdatesCount = 0;
- memset(&_data1, 0, sizeof(_data1));
- memset(&_data2, 0, sizeof(_data2));
- actorUpdateStatusEnabledCounter = 0;
- memset(&_data3, 0, sizeof(_data3));
- _flagScene1 = false;
- //memset(&_movies, 0, sizeof(_movies));
- actorUpdateStatus15Check = false;
- _flag2 = false;
- globalDirection = kDirectionN;
+ // Public data
+ cdNumber = 0;
+ movieIndex = 0;
+ sceneCounter = 0;
+ actorEnableForStatus7 = false;
+ globalDirection = kDirectionN;
+
+
+ memset(&_ambientFlags, 0, sizeof(_ambientFlags));
memset(&_ambientTicks, 0, sizeof(_ambientTicks));
+ _globalPoint.x = -1;
+ _globalPoint.y = -1;
+ // _flagSkipScriptProcessing
+ // _flagEncounterRunning
+ // player ActorIndex
+ _sceneOffset = 0;
+ _sceneOffsetAdd = 0;
+ memset(&_cursorResources, kResourceNone, sizeof(_cursorResources));
+ memset(&_sceneFonts, kResourceNone, sizeof(_sceneFonts));
+ memset(&_chapter2Data1, 0, sizeof(_chapter2Data1));
+ _smallCurUp = 0;
+ _smallCurDown = 0;
+ _encounterFrameBg = 0;
+ _flagSkipDrawScene = false;
+ _matteVar1 = 0;
+ _flagActorUpdateEnabledCheck = false;
+ _matteInitialized = false;
+ _mattePlaySound = false;
+ _currentScreenUpdatesCount = 0;
+ memset(&_chapter2Data2, 0, sizeof(_chapter2Data2));
+ memset(&_chapter2Counters, 0, sizeof(_chapter2Counters));
+ memset(&_chapter2Data3, 0, sizeof(_chapter2Data3));
+ _chapter2FrameIndexOffset = 0;
+ _chapter2ActorIndex = 0;
+ _eventUpdate = 0;
+ memset(&_chapter2Data5, 0, sizeof(_chapter2Data4));
+ _actorUpdateStatusEnabledCounter = 0;
+ memset(&_chapter2Data5, 0, sizeof(_chapter2Data5));
+ // _flagEncounterDisablePlayerOnExit
+ _flag1 = false;
+ _nextScreenUpdate = 0;
+ // _moviesViewed;
+ _flagActorUpdateStatus15Check = false;
+
+ // Non-saved data
+ _flag2 = false;
+ _flag3 = false;
+ _flagScene1 = false;
+ _flagRedraw = false;
+
+ _matteBarHeight = 0;
+ _matteVar2 = 0;
+}
+
+//////////////////////////////////////////////////////////////////////////
+// Saved scene data
+//////////////////////////////////////////////////////////////////////////
+void SharedData::saveCursorResources(ResourceId *resources, uint32 size) {
+ memcpy((ResourceId *)&_cursorResources, resources, size);
+}
- // Screen updates
- _flagRedraw = false;
- nextScreenUpdate = 0;
- movieIndex = 0;
+void SharedData::loadCursorResources(ResourceId *resources, uint32 size) {
+ memcpy(resources, (ResourceId *)&_cursorResources, size);
}
-void SharedData::setData(ActorIndex index, int32 val) {
- if (index < 50)
- _data1[index] = val;
- else if (index < 60)
- _data2[index - 50] = val;
- else
- error("[SharedData::setData] index is outside valid values (was: %d, valid: [0:60]", index);
+void SharedData::saveSceneFonts(ResourceId font1, ResourceId font2, ResourceId font3) {
+ _sceneFonts[0] = font1;
+ _sceneFonts[1] = font2;
+ _sceneFonts[2] = font3;
}
-int32 SharedData::getData(ActorIndex index) {
- if (index < 50)
- return _data1[index];
- else if (index < 60)
- return _data2[index - 50];
- else
- error("[SharedData::getData] index is outside valid values (was: %d, valid: [0:60]", index);
+void SharedData::loadSceneFonts(ResourceId *font1, ResourceId *font2, ResourceId *font3) {
+ *font1 = _sceneFonts[0];
+ *font2 = _sceneFonts[1];
+ *font3 = _sceneFonts[2];
}
-void SharedData::setData2(ActorIndex index, bool val) {
- if (index <= 12 || index > 20)
- error("[SharedData::setData2] index is outside valid values (was: %d, valid: [13:20]", index);
+void SharedData::saveSmallCursor(int32 smallCurUp, int32 smallCurDown) {
+ _smallCurUp = smallCurUp;
+ _smallCurDown = smallCurDown;
+}
- _data3[index - 12] = val;
+void SharedData::loadSmallCursor(int32 *smallCurUp, int32 *smallCurDown) {
+ *smallCurUp = _smallCurUp;
+ *smallCurDown = _smallCurDown;
}
-bool SharedData::getData2(ActorIndex index) {
- if (index <= 12 || index > 20)
- error("[SharedData::getData2] index is outside valid values (was: %d, valid: [13:20]", index);
+//////////////////////////////////////////////////////////////////////////
+// Chapter 2 data
+//////////////////////////////////////////////////////////////////////////
+void SharedData::resetChapter2Data() {
+ for (uint32 i = 5; i < 14; i++)
+ _chapter2Data3[i] = 0;
- return _data3[index - 12];
+ for (uint32 i = 0; i < ARRAYSIZE(_chapter2Data2); i++)
+ _chapter2Data2[i] = 160;
+
+ for (uint32 i = 0; i < ARRAYSIZE(_chapter2Data5); i++)
+ _chapter2Data5[i] = 0;
}
-void SharedData::resetActorData() {
- for (int i = 0; i < 9; i++) {
- _data1[i] = 160;
- _data1[i + 18] = 0;
- _data3[i] = 0;
- }
+void SharedData::reset() {
+ for (uint32 i = 0; i < ARRAYSIZE(_chapter2Data2); i++)
+ _chapter2Data2[i] = 160;
+
+ _chapter2FrameIndexOffset = 1;
}
+void SharedData::setChapter2Data(uint32 index, int32 offset, int32 val) {
+ error("[SharedData::setChapter2Data] Not implemented");
+}
+
+int32 SharedData::getChapter2Data(uint32 index, int32 offset) {
+ error("[SharedData::getChapter2Data] Not implemented");
+}
+
+void SharedData::setChapter2Counter(uint32 index, int32 val) {
+ if (index == 0 || index > 8)
+ error("[SharedData::setChapter2Counter] Invalid index (was: %d, valid: [1;8])", index);
+
+ _chapter2Counters[index - 1] = val;
+}
+
+int32 SharedData::getChapter2Counter(uint32 index) {
+ if (index == 0 || index > 8)
+ error("[SharedData::setChapter2Counter] Invalid index (was: %d, valid: [1;8])", index);
+
+ return _chapter2Counters[index - 1];
+}
+
+//////////////////////////////////////////////////////////////////////////
+// Ambient sounds
+//////////////////////////////////////////////////////////////////////////
uint32 SharedData::getAmbientTick(uint32 index) {
if (index >= ARRAYSIZE(_ambientTicks))
error("[SharedData::getAmbientTick] index is outside valid values (was: %d, valid: [0:%d]", index, ARRAYSIZE(_ambientTicks));
@@ -174,6 +223,18 @@ bool SharedData::getFlag(GlobalFlag flag) const {
case kFlagScene1:
return _flagScene1;
+
+ //case kFlagSkipScriptProcessing:
+ // return _flagSkipScriptProcessing;
+
+ //case kFlagEncounterRunning:
+ // return _flagEncounterRunning;
+
+ case kFlagActorUpdateEnabledCheck:
+ return _flagActorUpdateEnabledCheck;
+
+ case kFlagActorUpdateStatus15Check:
+ return _flagActorUpdateStatus15Check;
}
}
@@ -209,9 +270,28 @@ void SharedData::setFlag(GlobalFlag flag, bool state) {
case kFlagScene1:
_flagScene1 = state;
break;
+
+ //case kFlagSkipScriptProcessing:
+ // _flagSkipScriptProcessing = state;
+ // break;
+
+ //case kFlagEncounterRunning:
+ // _flagEncounterRunning = state;
+ // break;
+
+ case kFlagActorUpdateEnabledCheck:
+ _flagActorUpdateEnabledCheck = state;
+ break;
+
+ case kFlagActorUpdateStatus15Check:
+ _flagActorUpdateStatus15Check = state;
+ break;
}
}
+//////////////////////////////////////////////////////////////////////////
+// Serializer
+//////////////////////////////////////////////////////////////////////////
void SharedData::saveLoadAmbientSoundData(Common::Serializer &s) {
// Ambient sound flags/ticks
for (uint32 i = 0; i < ARRAYSIZE(_ambientFlags); i++)
@@ -228,8 +308,8 @@ void SharedData::saveLoadWithSerializer(Common::Serializer &s) {
// Script queue (part of ScriptManager)
// Global coordinates (original uses int32 for coordinates)
- s.syncAsSint32LE(point.x);
- s.syncAsSint32LE(point.y);
+ s.syncAsSint32LE(_globalPoint.x);
+ s.syncAsSint32LE(_globalPoint.y);
// Processing skipped (part of ScriptManager)
// Encounter running (part of Encounter)
@@ -238,97 +318,73 @@ void SharedData::saveLoadWithSerializer(Common::Serializer &s) {
//s.syncAsUint32LE(playerIndex);
// Scene coordinates
- s.syncAsSint32LE(sceneXLeft);
- s.syncAsSint32LE(sceneYTop);
- s.syncAsSint32LE(sceneOffset);
- s.syncAsSint32LE(sceneOffsetAdd);
+ s.syncAsSint32LE(_sceneCoords.x);
+ s.syncAsSint32LE(_sceneCoords.y);
+ s.syncAsSint32LE(_sceneOffset);
+ s.syncAsSint32LE(_sceneOffsetAdd);
// Original skips 4 bytes
s.skip(4);
// Cursor resources
- for (uint32 i = 0; i < ARRAYSIZE(cursorResources); i++)
- s.syncAsUint32LE(cursorResources[i]);
+ for (uint32 i = 0; i < ARRAYSIZE(_cursorResources); i++)
+ s.syncAsUint32LE(_cursorResources[i]);
// Fonts
- for (uint32 i = 0; i < ARRAYSIZE(sceneFonts); i++)
- s.syncAsUint32LE(sceneFonts[i]);
+ for (uint32 i = 0; i < ARRAYSIZE(_sceneFonts); i++)
+ s.syncAsUint32LE(_sceneFonts[i]);
// Chapter 2 actor data (Part 1)
- //for (uint32 i = 0; i < ARRAYSIZE(chapter2ActorData1); i++)
- // s.syncAsUint32LE(chapter2ActorData1[i]);
-
- // Original skips 4 bytes
- s.skip(4);
+ for (uint32 i = 0; i < ARRAYSIZE(_chapter2Data1); i++)
+ s.syncAsUint32LE(_chapter2Data1[i]);
// Scene information
- s.syncAsSint32LE(smallCurUp);
- s.syncAsSint32LE(smallCurDown);
- s.syncAsSint32LE(encounterFrameBg);
+ s.syncAsSint32LE(_smallCurUp);
+ s.syncAsSint32LE(_smallCurDown);
+ s.syncAsSint32LE(_encounterFrameBg);
s.syncAsUint32LE(_flagSkipDrawScene);
- s.syncAsSint32LE(matteVar1);
- s.syncAsUint32LE(actorUpdateEnabledCheck);
- s.syncAsUint32LE(matteInitialized);
- s.syncAsUint32LE(mattePlaySound);
- s.syncAsSint32LE(currentScreenUpdatesCount);
+ s.syncAsSint32LE(_matteVar1);
+ s.syncAsUint32LE(_flagActorUpdateEnabledCheck);
+ s.syncAsUint32LE(_matteInitialized);
+ s.syncAsUint32LE(_mattePlaySound);
+ s.syncAsSint32LE(_currentScreenUpdatesCount);
// Chapter 2 actor data (Part 2)
- //for (uint32 i = 0; i < ARRAYSIZE(chapter2ActorData2); i++)
- // s.syncAsUint32LE(chapter2ActorData2[i]);
+ for (uint32 i = 0; i < ARRAYSIZE(_chapter2Data2); i++)
+ s.syncAsUint32LE(_chapter2Data2[i]);
// Chapter 2 counters (1-4)
- //s.syncAsSint32LE(chapter2Counter1);
- //s.syncAsSint32LE(chapter2Counter2);
- //s.syncAsSint32LE(chapter2Counter3);
- //s.syncAsSint32LE(chapter2Counter4);
-
- // Original skips 4 bytes
- s.skip(4);
+ s.syncAsSint32LE(_chapter2Counters[0]);
+ s.syncAsSint32LE(_chapter2Counters[1]);
+ s.syncAsSint32LE(_chapter2Counters[2]);
+ s.syncAsSint32LE(_chapter2Counters[3]);
// Chapter 2 actor data (Part 3)
- //for (uint32 i = 0; i < ARRAYSIZE(chapter2ActorData3); i++)
- // s.syncAsUint32LE(chapter2ActorData3[i]);
-
- // Original skips 4 bytes
- s.skip(4);
-
- // Chapter2 points
- //for (uint32 i = 0; i < ARRAYSIZE(chapter2Points); i++) {
- // s.syncAsSint32LE(chapter2Points[i].x);
- // s.syncAsSint32LE(chapter2Points[i].y);
- //}
-
- // Original skips 4 bytes
- s.skip(4);
+ for (uint32 i = 0; i < ARRAYSIZE(_chapter2Data3); i++)
+ s.syncAsUint32LE(_chapter2Data3[i]);
// Chapter 2 counter (5) and other data
- //s.syncAsSint32LE(chapter2Counter5);
- //s.syncAsSint32LE(chapter2FrameIndexOffset);
- //s.syncAsSint32LE(chapter2ActorIndex);
+ s.syncAsSint32LE(_chapter2Counters[4]);
+ s.syncAsSint32LE(_chapter2FrameIndexOffset);
+ s.syncAsSint32LE(_chapter2ActorIndex);
- //s.syncAsSint32LE(eventUpdateFlag);
+ //s.syncAsSint32LE(_eventUpdateFlag);
// Chapter 2 counters (6-8)
- //s.syncAsSint32LE(chapter2Counter6);
- //s.syncAsSint32LE(chapter2Counter7);
- //s.syncAsSint32LE(chapter2Counter8);
-
- // Original skips 7 * 4 bytes
- s.skip(7 * 4);
+ s.syncAsSint32LE(_chapter2Counters[5]);
+ s.syncAsSint32LE(_chapter2Counters[6]);
+ s.syncAsSint32LE(_chapter2Counters[7]);
// Chapter 2 actor data (Part 4)
- //for (uint32 i = 0; i < ARRAYSIZE(chapter2ActorData4); i++)
- // s.syncAsUint32LE(chapter2ActorData4[i]);
-
- // Original skips 8 * 4 bytes
- s.skip(8 * 4);
+ for (uint32 i = 0; i < ARRAYSIZE(_chapter2Data4); i++)
+ s.syncAsUint32LE(_chapter2Data4[i]);
// Actor UpdateStatusEnabled Counter
- s.syncAsSint32LE(actorUpdateStatusEnabledCounter);
+ s.syncAsSint32LE(_actorUpdateStatusEnabledCounter);
// Chapter2 actor data (part 5)
- //for (uint32 i = 0; i < ARRAYSIZE(chapter2ActorData5); i++)
- // s.syncAsUint32LE(chapter2ActorData5[i]);
+ for (uint32 i = 0; i < ARRAYSIZE(_chapter2Data5); i++)
+ s.syncAsUint32LE(_chapter2Data5[i]);
// Encounter disable player on exit
//s.syncAsSint32LE(encounterDisablePlayerOnExit);
@@ -337,13 +393,13 @@ void SharedData::saveLoadWithSerializer(Common::Serializer &s) {
s.syncAsUint32LE(_flagScene1);
// Next screen update
- s.syncAsUint32LE(nextScreenUpdate);
+ s.syncAsUint32LE(_nextScreenUpdate);
// Viewed movies (we also load it from an external file...)
//s.syncBytes(&_moviesViewed, sizeof(_moviesViewed));
// Actor update status 15 check
- s.syncAsUint32LE(actorUpdateStatus15Check);
+ s.syncAsUint32LE(_flagActorUpdateStatus15Check);
// TODO More?
}
diff --git a/engines/asylum/resources/data.h b/engines/asylum/resources/data.h
index 4f763ab494..b7cde1f720 100644
--- a/engines/asylum/resources/data.h
+++ b/engines/asylum/resources/data.h
@@ -39,7 +39,11 @@ enum GlobalFlag {
kFlagRedraw,
kFlagSkipDrawScene,
kFlagSceneRectChanged,
- kFlagScene1
+ kFlagScene1,
+ kFlagSkipScriptProcessing,
+ kFlagEncounterRunning,
+ kFlagActorUpdateEnabledCheck,
+ kFlagActorUpdateStatus15Check
};
/**
@@ -60,7 +64,7 @@ enum GlobalFlag {
* uint32 {15} - ambient flags
* uint32 {15} - ambient ticks
* uint32 {1} - UNUSED
- * uint32 {1} - scene updateScreen calls count
+ * uint32 {1} - UNUSED (scene updateScreen calls count)
* -- Script queue (stored in ScriptManager - reset on scene change)
* uint32 {1} - global Object X
* uint32 {1} - global Object Y
@@ -74,8 +78,7 @@ enum GlobalFlag {
* uint32 {1} - UNUSED
* uint32 {13} - cursor resources
* uint32 {3} - scene fonts (3)
- * uint32 {3} - Chapter2 actor data (part 1)
- * uint32 {1} - UNUSED
+ * uint32 {5} - Chapter2 actor data (part 1)
* uint32 {1} - small cursor Up
* uint32 {1} - small cursor Down
* uint32 {1} - Encounter frame background
@@ -85,16 +88,12 @@ enum GlobalFlag {
* uint32 {1} - matte Initialized
* uint32 {1} - matte playSound
* uint32 {1} - currentScreenUpdatesCount
- * uint32 {3} - Chapter2 actor data (part 2)
+ * uint32 {9} - Chapter2 actor data (part 2)
* uint32 {1} - Chapter 2 counter 1
* uint32 {1} - Chapter 2 counter 2
* uint32 {1} - Chapter 2 counter 3
* uint32 {1} - Chapter 2 counter 4
- * uint32 {1} - UNUSED
- * uint32 {3} - Chapter2 actor data (part 3)
- * uint32 {1} - UNUSED
- * uint32 {8} - Chapter 2 points
- * uint32 {9} - UNUSED
+ * uint32 {23} - Chapter2 actor data (part 3)
* uint32 {1} - Special 2 counter 5
* uint32 {1} - Chapter 2 frameIndex Offset
* uint32 {1} - Chapter 2 Actor index
@@ -102,9 +101,7 @@ enum GlobalFlag {
* uint32 {1} - Chapter 2 counter 6
* uint32 {1} - Chapter 2 counter 7
* uint32 {1} - Chapter 2 counter 8
- * uint32 {7} - UNUSED
- * uint32 {3} - Chapter2 actor data (part 4)
- * uint32 {8} - UNUSED
+ * uint32 {18} - Chapter2 actor data (part 4)
* uint32 {1} - actorUpdateStatusEnabledCounter
* uint32 {9} - Chapter2 actor data (part 5)
* uint32 {1} - Encounter disablePlayerOnExit
@@ -113,9 +110,9 @@ enum GlobalFlag {
* uint32 {49} - Viewed movies
* uint32 {1} - actorUpdateStatus15Check
* -- Skip opening movie command line flag (not used)
- * uint32 {1} - Encounter flag 3
+ * -- Encounter flag 3
* uint32 {1} - Flag 2
- * uint32 {1} - Flag 5
+ * uint32 {1} - Flag Redraw
* -- scripts (reset on scene load)
* -- polygons (reset on scene load)
*/
@@ -124,60 +121,29 @@ public:
SharedData();
// Public variables
- int32 cdNumber;
- int32 movieIndex;
-
- // Saved scene data
- ResourceId cursorResources[13];
- ResourceId sceneFonts[3];
- int32 smallCurUp;
- int32 smallCurDown;
- int32 encounterFrameBg;
-
- Common::Point point; // global point
+ int32 cdNumber;
+ int32 movieIndex;
uint32 sceneCounter;
-
- // Global scene coordinates and offset
- int32 sceneXLeft;
- int32 sceneYTop;
- int32 sceneOffset;
- int32 sceneOffsetAdd;
-
- // Actor
Common::Point vector1;
Common::Point vector2;
bool actorEnableForStatus7;
- bool actorUpdateEnabledCheck;
- int32 actorUpdateStatusEnabledCounter;
- bool actorUpdateStatus15Check;
ActorDirection globalDirection;
- // Matte bars
- uint32 matteBarHeight;
- int32 matteVar1;
- uint32 matteVar2;
- bool matteInitialized;
- bool mattePlaySound;
+ // Used by Actor::enableActorsChapter2 (and maybe others)
+ void resetChapter2Data();
+ void reset(); // called during game reset
- // Screen updates
- uint32 nextScreenUpdate;
- int32 currentScreenUpdatesCount;
+ // Flags
+ bool getFlag(GlobalFlag flag) const;
+ void setFlag(GlobalFlag flag, bool state);
+ // Serializer
+ void saveLoadAmbientSoundData(Common::Serializer &s);
+ void saveLoadWithSerializer(Common::Serializer &s);
+ //////////////////////////////////////////////////////////////////////////
// Accessors
- void setActorUpdateFlag(int32 val) { _data1[40] = 2; }
- void setActorUpdateFlag2(int32 val) { _data1[36] = val; }
-
- int32 getActorUpdateFlag2() { return _data1[36]; }
-
- // TODO Remove and replace by accessors
- void setData(ActorIndex index, int32 val);
- int32 getData(ActorIndex index);
- void setData2(ActorIndex index, bool val);
- bool getData2(ActorIndex index);
-
- // Used by Actor::enableActorsChapter2 (and maybe others)
- void resetActorData();
+ //////////////////////////////////////////////////////////////////////////
// Ambient sound data
uint32 getAmbientTick(uint32 index);
@@ -186,30 +152,103 @@ public:
void setAmbientFlag(uint32 index, uint32 val);
void resetAmbientFlags();
- // Flags
- bool getFlag(GlobalFlag flag) const;
- void setFlag(GlobalFlag flag, bool state);
+ // Coordinates
+ Common::Point getGlobalPoint() { return _globalPoint; }
+ void setGlobalPoint(const Common::Point &point) { _globalPoint = point; }
+ Common::Point getSceneCoords() { return _sceneCoords; }
+ void setSceneCoords(const Common::Point &point) { _sceneCoords = point; }
+ int32 getSceneOffset() { return _sceneOffset; }
+ void setSceneOffset(int32 sceneOffset) { _sceneOffset = sceneOffset; }
+ int32 getSceneOffsetAdd() { return _sceneOffsetAdd; }
+ void setSceneOffsetAdd(int32 sceneOffsetAdd) { _sceneOffsetAdd = sceneOffsetAdd; }
- // Serializer
- void saveLoadAmbientSoundData(Common::Serializer &s);
- void saveLoadWithSerializer(Common::Serializer &s);
+ // Saved scene data
+ void saveCursorResources(ResourceId *resources, uint32 size);
+ void loadCursorResources(ResourceId *resources, uint32 size);
+ void saveSceneFonts(ResourceId font1, ResourceId font2, ResourceId font3);
+ void loadSceneFonts(ResourceId *font1, ResourceId *font2, ResourceId *font3);
+ void saveSmallCursor(int32 smallCurUp, int32 smallCurDown);
+ void loadSmallCursor(int32 *smallCurUp, int32 *smallCurDown);
+ void saveEncounterFrameBackground(int32 encounterFrameBg) { _encounterFrameBg = encounterFrameBg; }
+ void loadEncounterFrameBackground(int32 *encounterFrameBg) { *encounterFrameBg = _encounterFrameBg; }
+
+ // Matte data
+ int32 getMatteVar1() const { return _matteVar1; }
+ void setMatteVar1(int32 val) { _matteVar1 = val; }
+ uint32 getMatteVar2() const { return _matteVar2; }
+ void setMatteVar2(uint32 val) { _matteVar2 = val; }
+ uint32 getMatteBarHeight() const { return _matteBarHeight; }
+ void setMatteBarHeight(uint32 val) { _matteBarHeight = val; }
+ bool getMatteInitialized() const { return _matteInitialized; }
+ void setMatteInitialized(bool val) { _matteInitialized = val; }
+ bool getMattePlaySound() const { return _mattePlaySound; }
+ void setMattePlaySound(bool val) { _mattePlaySound = val; }
+
+ // Chapter 2 data
+ void setChapter2Data(uint32 index, int32 offset, int32 val);
+ int32 getChapter2Data(uint32 index, int32 offset);
+ void setChapter2Counter(uint32 index, int32 val);
+ int32 getChapter2Counter(uint32 index);
+ ActorIndex getChapter2FrameIndexOffset() const { return _chapter2FrameIndexOffset; }
+ void setChapter2FrameIndexOffset(int32 val) { _chapter2FrameIndexOffset = val; }
+ ActorIndex getChapter2ActorIndex() const { return _chapter2ActorIndex; }
+ void setChapter2ActorIndex(ActorIndex val) { _chapter2ActorIndex = val; }
+
+ // Misc
+ int32 getActorUpdateStatusEnabledCounter() { return _actorUpdateStatusEnabledCounter; }
+ void setActorUpdateStatusEnabledCounter(int32 val) { _actorUpdateStatusEnabledCounter = val; }
+
+ // Screen updates
+ int32 getEventUpdate() { return _eventUpdate; }
+ void setEventUpdate(int32 val) { _eventUpdate = val; }
+ uint32 getNextScreenUpdate() { return _nextScreenUpdate; }
+ void setNextScreenUpdate(uint32 nextScreenUpdate) { _nextScreenUpdate = nextScreenUpdate; }
private:
uint32 _ambientFlags[15];
uint32 _ambientTicks[15];
-
- // Flags
+ Common::Point _globalPoint; // global point
+ // _flagSkipScriptProcessing
+ // _flagEncounterRunning
+ // player ActorIndex
+ Common::Point _sceneCoords;
+ int32 _sceneOffset;
+ int32 _sceneOffsetAdd;
+ ResourceId _cursorResources[13];
+ ResourceId _sceneFonts[3];
+ uint32 _chapter2Data1[5];
+ int32 _smallCurUp;
+ int32 _smallCurDown;
+ int32 _encounterFrameBg;
+ bool _flagSkipDrawScene;
+ int32 _matteVar1;
+ bool _flagActorUpdateEnabledCheck;
+ bool _matteInitialized;
+ bool _mattePlaySound;
+ int32 _currentScreenUpdatesCount;
+ uint32 _chapter2Data2[9];
+ int32 _chapter2Counters[8];
+ int32 _chapter2Data3[23];
+ int32 _chapter2FrameIndexOffset;
+ ActorIndex _chapter2ActorIndex;
+ int32 _eventUpdate;
+ uint32 _chapter2Data4[18];
+ int32 _actorUpdateStatusEnabledCounter;
+ uint32 _chapter2Data5[9];
+ // _flagEncounterDisablePlayerOnExit
bool _flag1;
+ uint32 _nextScreenUpdate;
+ //byte _moviesViewed[196];
+ bool _flagActorUpdateStatus15Check;
+
+ // Non-saved data
bool _flag2;
bool _flag3;
- bool _flagSkipDrawScene;
bool _flagScene1;
bool _flagRedraw;
- // Shared data
- int32 _data1[50];
- int32 _data2[11];
- bool _data3[9];
+ uint32 _matteBarHeight;
+ uint32 _matteVar2;
};
} // End of namespace Asylum
diff --git a/engines/asylum/resources/encounters.cpp b/engines/asylum/resources/encounters.cpp
index bdb51b4209..2b4c01a737 100644
--- a/engines/asylum/resources/encounters.cpp
+++ b/engines/asylum/resources/encounters.cpp
@@ -318,7 +318,7 @@ bool Encounter::init() {
if (getSound()->getMusicVolume() != Config.musicVolume - 500)
getSound()->setMusicVolume(Config.musicVolume - 500);
- if (!getSharedData()->matteBarHeight) {
+ if (!getSharedData()->getMatteBarHeight()) {
_isRunning = true;
_data_455BD4 = false;
_data_455BD8 = false;
@@ -347,7 +347,7 @@ bool Encounter::init() {
_data_455BD0 = false;
getCursor()->set(getWorld()->cursorResources[kCursorResourceTalkNPC], -1, kCursorAnimationMirror);
- if (!getSharedData()->matteBarHeight)
+ if (!getSharedData()->getMatteBarHeight())
initScript(_item->scriptResourceId);
return true;
@@ -400,7 +400,7 @@ bool Encounter::update() {
}
if (_data_455BE8) {
- if (getSharedData()->matteBarHeight) {
+ if (getSharedData()->getMatteBarHeight()) {
_data_455BD0 = false;
} else {
getCursor()->show();
@@ -422,7 +422,7 @@ bool Encounter::update() {
|| (getSpeech()->getTick() && tick >= getSpeech()->getTick()))
doScript = true;
- if (!getSharedData()->matteBarHeight && doScript && _flag4) {
+ if (!getSharedData()->getMatteBarHeight() && doScript && _flag4) {
if (!setupSpeech(id))
runScript();
}
@@ -436,15 +436,15 @@ bool Encounter::update() {
getSharedData()->setFlag(kFlagRedraw, true);
}
- if (tick >= getSharedData()->nextScreenUpdate && getSharedData()->getFlag(kFlagRedraw)) {
- if (getSharedData()->matteBarHeight <= 0) {
+ if (tick >= getSharedData()->getNextScreenUpdate() && getSharedData()->getFlag(kFlagRedraw)) {
+ if (getSharedData()->getMatteBarHeight() <= 0) {
getScreen()->copyBackBufferToScreen();
} else {
drawScreen();
}
getSharedData()->setFlag(kFlagRedraw, false);
- getSharedData()->nextScreenUpdate = tick + 55;
+ getSharedData()->setNextScreenUpdate(tick + 55);
}
return true;
@@ -1129,24 +1129,24 @@ void Encounter::drawText(char *text, ResourceId font, int32 y) {
void Encounter::drawScreen() {
getScene()->getActor()->setLastScreenUpdate(_vm->screenUpdateCount);
- if (!getSharedData()->matteInitialized)
- getSharedData()->matteBarHeight = 85;
+ if (!getSharedData()->getMatteInitialized())
+ getSharedData()->setMatteBarHeight(85);
- if (getSharedData()->matteBarHeight >= 84) {
- if (getSharedData()->matteBarHeight == 85) {
- if (getSharedData()->matteInitialized) {
+ if (getSharedData()->getMatteBarHeight() >= 84) {
+ if (getSharedData()->getMatteBarHeight() == 85) {
+ if (getSharedData()->getMatteInitialized()) {
getScreen()->drawWideScreenBars(82);
getScreen()->updatePalette();
getScreen()->setupPalette(NULL, 0, 0);
getScreen()->paletteFade(0, 25, 10);
} else {
- getSharedData()->matteInitialized = true;
+ getSharedData()->setMatteInitialized(true);
getScreen()->clear();
}
- if (getSharedData()->matteVar1) {
- if (!getSharedData()->matteVar2)
+ if (getSharedData()->getMatteVar1()) {
+ if (!getSharedData()->getMatteVar2())
getSound()->playMusic(kResourceNone, 0);
// Play movie
@@ -1156,7 +1156,7 @@ void Encounter::drawScreen() {
getScreen()->clear();
getCursor()->hide();
- if (getSharedData()->mattePlaySound) {
+ if (getSharedData()->getMattePlaySound()) {
getScreen()->paletteFade(0, 2, 1);
getScene()->updateScreen();
getScreen()->drawWideScreenBars(82);
@@ -1164,24 +1164,24 @@ void Encounter::drawScreen() {
getScreen()->updatePalette();
getScreen()->setupPalette(NULL, 0, 0);
- if (getSharedData()->mattePlaySound /* Scene::updateScreen() does script processing, so the value might have changed */
- && !getSharedData()->matteVar2
+ if (getSharedData()->getMattePlaySound() /* Scene::updateScreen() does script processing, so the value might have changed */
+ && !getSharedData()->getMatteVar2()
&& getWorld()->musicCurrentResourceIndex != kMusicStopped)
getSound()->playMusic(MAKE_RESOURCE(kResourcePackMusic, getWorld()->musicCurrentResourceIndex));
}
- getSharedData()->matteBarHeight = (getSharedData()->mattePlaySound ? 346 : 170);
+ getSharedData()->setMatteBarHeight(getSharedData()->getMattePlaySound() ? 346 : 170);
} else {
- getSharedData()->matteBarHeight = 170;
+ getSharedData()->setMatteBarHeight(170);
}
- } else if (getSharedData()->matteBarHeight >= 170) {
+ } else if (getSharedData()->getMatteBarHeight() >= 170) {
if (_isRunning) {
- getSharedData()->matteBarHeight = 0;
+ getSharedData()->setMatteBarHeight(0);
getCursor()->show();
}
} else {
- getScreen()->drawWideScreenBars(172 - getSharedData()->matteBarHeight);
- getSharedData()->matteBarHeight += 4;
+ getScreen()->drawWideScreenBars(172 - getSharedData()->getMatteBarHeight());
+ getSharedData()->setMatteBarHeight(getSharedData()->getMatteBarHeight() + 4);
ResourceId paletteId = getWorld()->actions[getScene()->getActor()->getActionIndex3()]->paletteResourceId;
getScreen()->setPaletteGamma(paletteId ? paletteId : getWorld()->currentPaletteId);
@@ -1190,8 +1190,8 @@ void Encounter::drawScreen() {
getScreen()->setupPalette(NULL, 0, 0);
}
} else {
- getScreen()->drawWideScreenBars(getSharedData()->matteBarHeight);
- getSharedData()->matteBarHeight += 4;
+ getScreen()->drawWideScreenBars(getSharedData()->getMatteBarHeight());
+ getSharedData()->setMatteBarHeight(getSharedData()->getMatteBarHeight() + 4);
getScreen()->setPaletteGamma(getWorld()->currentPaletteId);
@@ -1608,14 +1608,14 @@ void Encounter::runScript() {
break;
case 23:
- if (!getSharedData()->matteBarHeight) {
+ if (!getSharedData()->getMatteBarHeight()) {
getScreen()->loadPalette();
- getSharedData()->matteBarHeight = 1;
+ getSharedData()->setMatteBarHeight(1);
getSharedData()->movieIndex = getVariableInv(entry.param2);
- getSharedData()->matteVar1 = 1;
- getSharedData()->mattePlaySound = true;
- getSharedData()->matteInitialized = true;
- getSharedData()->matteVar2 = 0;
+ getSharedData()->setMatteVar1(1);
+ getSharedData()->setMattePlaySound(true);
+ getSharedData()->setMatteInitialized(true);
+ getSharedData()->setMatteVar2(0);
done = true;
}
diff --git a/engines/asylum/resources/object.cpp b/engines/asylum/resources/object.cpp
index 7dd31931d1..2811c7c4ca 100644
--- a/engines/asylum/resources/object.cpp
+++ b/engines/asylum/resources/object.cpp
@@ -270,16 +270,15 @@ void Object::update() {
if (_frameIndex < _frameCount - 1) {
if (_field_688 == 1) {
Common::Rect frameRect = GraphicResource::getFrameRect(_vm, _resourceId, _frameIndex);
- getSharedData()->point.x = x + frameRect.left + Common::Rational(frameRect.width(), 2).toInt();
- getSharedData()->point.y = y + frameRect.top + Common::Rational(frameRect.height(), 2).toInt();
+ getSharedData()->setGlobalPoint(Common::Point(x + frameRect.left + Common::Rational(frameRect.width(), 2).toInt(),
+ y + frameRect.top + Common::Rational(frameRect.height(), 2).toInt()));
}
} else {
flags &= ~kObjectFlag8;
- if (_field_688 == 1) {
- getSharedData()->point.x = -1;
- getSharedData()->point.y = -1;
- }
+ if (_field_688 == 1)
+ getSharedData()->setGlobalPoint(Common::Point(-1, -1));
}
+
_tickCount = _vm->getTick();
doPlaySounds = true;
}
@@ -291,14 +290,13 @@ void Object::update() {
if (_frameIndex == 0) {
flags &= ~kObjectFlag10000;
- if (_field_688 == 1) {
- getSharedData()->point.x = -1;
- getSharedData()->point.y = -1;
- }
+ if (_field_688 == 1)
+ getSharedData()->setGlobalPoint(Common::Point(-1, -1));
+
} else if (_field_688 == 1) {
Common::Rect frameRect = GraphicResource::getFrameRect(_vm, _resourceId, _frameIndex);
- getSharedData()->point.x = x + frameRect.left + Common::Rational(frameRect.width(), 2).toInt();
- getSharedData()->point.y = y + frameRect.top + Common::Rational(frameRect.height(), 2).toInt();
+ getSharedData()->setGlobalPoint(Common::Point(x + frameRect.left + Common::Rational(frameRect.width(), 2).toInt(),
+ y + frameRect.top + Common::Rational(frameRect.height(), 2).toInt()));
}
_tickCount = _vm->getTick();
diff --git a/engines/asylum/resources/script.cpp b/engines/asylum/resources/script.cpp
index 27bbce8a95..91dbf94a67 100644
--- a/engines/asylum/resources/script.cpp
+++ b/engines/asylum/resources/script.cpp
@@ -498,13 +498,12 @@ IMPLEMENT_OPCODE(PlayAnimation)
if (object->getField688() == 1) {
if (object->flags & kObjectFlag4) {
- getSharedData()->point.x = object->x;
- getSharedData()->point.y = object->y;
+ getSharedData()->setGlobalPoint(Common::Point(object->x, object->y));
} else {
Common::Rect frameRect = GraphicResource::getFrameRect(_vm, object->getResourceId(), object->getFrameIndex());
- getSharedData()->point.x = frameRect.left + Common::Rational(frameRect.width(), 2).toInt() + object->x;
- getSharedData()->point.y = frameRect.top + Common::Rational(frameRect.height(), 2).toInt() + object->y;
+ getSharedData()->setGlobalPoint(Common::Point(frameRect.left + Common::Rational(frameRect.width(), 2).toInt() + object->x,
+ frameRect.top + Common::Rational(frameRect.height(), 2).toInt() + object->y));
}
}
@@ -960,17 +959,17 @@ END_OPCODE
//////////////////////////////////////////////////////////////////////////
// Opcode 0x2D
IMPLEMENT_OPCODE(PlayMovie)
- if (getSharedData()->matteBarHeight < 170) {
+ if (getSharedData()->getMatteBarHeight() < 170) {
_processNextEntry = 1;
- if (!getSharedData()->matteBarHeight) {
+ if (!getSharedData()->getMatteBarHeight()) {
getCursor()->hide();
getScreen()->loadPalette();
- getSharedData()->matteVar1 = 1;
- getSharedData()->matteBarHeight = 1;
- getSharedData()->matteVar2 = 0;
- getSharedData()->mattePlaySound = (cmd->param3 == 0);
- getSharedData()->matteInitialized = (cmd->param2 == 0);
+ getSharedData()->setMatteVar1(1);
+ getSharedData()->setMatteBarHeight(1);
+ getSharedData()->setMatteVar2(0);
+ getSharedData()->setMattePlaySound(cmd->param3 == 0);
+ getSharedData()->setMatteInitialized(cmd->param2 == 0);
getSharedData()->movieIndex = cmd->param1;
}
@@ -987,10 +986,10 @@ IMPLEMENT_OPCODE(PlayMovie)
getScreen()->setGammaLevel(getWorld()->currentPaletteId);
}
- getSharedData()->matteBarHeight = 0;
+ getSharedData()->setMatteBarHeight(0);
_processNextEntry = 0;
- if (!getSharedData()->mattePlaySound && _currentScript->commands[0].numLines != 0) {
+ if (!getSharedData()->getMattePlaySound() && _currentScript->commands[0].numLines != 0) {
bool found = true;
int index = 0;
@@ -1008,11 +1007,11 @@ IMPLEMENT_OPCODE(PlayMovie)
check = true;
}
- if (!check && getSharedData()->matteVar2 == 0 && getWorld()->musicCurrentResourceIndex != kMusicStopped)
+ if (!check && getSharedData()->getMatteVar2() == 0 && getWorld()->musicCurrentResourceIndex != kMusicStopped)
_vm->sound()->playMusic(MAKE_RESOURCE(kResourcePackMusic, getWorld()->musicCurrentResourceIndex));
getCursor()->show();
- getSharedData()->matteVar2 =0;
+ getSharedData()->setMatteVar2(0);
END_OPCODE
//////////////////////////////////////////////////////////////////////////
@@ -1187,7 +1186,7 @@ IMPLEMENT_OPCODE(UpdateWideScreen)
cmd->param1 = 0;
_processNextEntry = 0;
- getSharedData()->matteBarHeight = 0;
+ getSharedData()->setMatteBarHeight(0);
} else {
getScreen()->drawWideScreenBars((int16)(4 * barSize));
@@ -1459,19 +1458,19 @@ END_OPCODE
//////////////////////////////////////////////////////////////////////////
// Opcode 0x48
IMPLEMENT_OPCODE(HideMatteBars)
- getSharedData()->matteVar1 = 0;
- getSharedData()->matteInitialized = true;
+ getSharedData()->setMatteVar1(0);
+ getSharedData()->setMatteInitialized(true);
- if (getSharedData()->matteBarHeight >= 170) {
- getSharedData()->matteBarHeight = 0;
+ if (getSharedData()->getMatteBarHeight() >= 170) {
+ getSharedData()->setMatteBarHeight(0);
_processNextEntry = 0;
getCursor()->show();
} else {
_processNextEntry = 1;
- if (!getSharedData()->matteBarHeight) {
+ if (!getSharedData()->getMatteBarHeight()) {
getCursor()->hide();
- getSharedData()->matteBarHeight = 1;
+ getSharedData()->setMatteBarHeight(1);
}
}
END_OPCODE
@@ -1479,20 +1478,20 @@ END_OPCODE
//////////////////////////////////////////////////////////////////////////
// Opcode 0x49
IMPLEMENT_OPCODE(ShowMatteBars)
- getSharedData()->matteVar1 = 0;
- getSharedData()->matteInitialized = true;
- getSharedData()->mattePlaySound = true;
+ getSharedData()->setMatteVar1(0);
+ getSharedData()->setMatteInitialized(true);
+ getSharedData()->setMattePlaySound(true);
- if (getSharedData()->matteBarHeight >= 170) {
- getSharedData()->matteBarHeight = 0;
+ if (getSharedData()->getMatteBarHeight() >= 170) {
+ getSharedData()->setMatteBarHeight(0);
_processNextEntry = 0;
getCursor()->show();
} else {
_processNextEntry = 1;
- if (!getSharedData()->matteBarHeight) {
+ if (!getSharedData()->getMatteBarHeight()) {
getCursor()->hide();
- getSharedData()->matteBarHeight = 90;
+ getSharedData()->setMatteBarHeight(90);
}
}
END_OPCODE
diff --git a/engines/asylum/resources/special.cpp b/engines/asylum/resources/special.cpp
index 20ad9f5fd9..f4a1ea6486 100644
--- a/engines/asylum/resources/special.cpp
+++ b/engines/asylum/resources/special.cpp
@@ -40,14 +40,12 @@
namespace Asylum {
Special::Special(AsylumEngine *engine) : _vm(engine) {
-
- // Counters & flags
- _chapter2Counter = 0;
- _chapter5Counter = 0;
-
+ // Flags
_paletteFlag = false;
_paletteTick1 = 0;
_paletteTick2 = 0;
+
+ _chapter5Counter = 0;
}
Special::~Special() {
@@ -202,7 +200,7 @@ void Special::chapter2(Object *object, ActorIndex actorIndex) {
for (int i = 13; i < 22; i++) {
if (getScene()->getActor(i)->isVisible()) {
- getSharedData()->setActorUpdateFlag(2);
+ getSharedData()->setChapter2Counter(6, 2);
break;
}
}
@@ -225,12 +223,16 @@ void Special::chapter2(Object *object, ActorIndex actorIndex) {
case 17:
case 18:
if (actor->getStatus() == kActorStatus1) {
- ++_chapter2Counter;
+ int32 counter = getSharedData()->getChapter2Counter(getCounter(actorIndex));
+ counter++;
- if (_chapter2Counter >= 5) {
- _chapter2Counter = 0;
+ if (counter >= 5) {
+ counter = 0;
actor->updateFromDirection((ActorDirection)((actor->getDirection() + 1) % ~7)); // TODO check
}
+
+ getSharedData()->setChapter2Counter(4, counter);
+
} else if (actor->getStatus() == kActorStatusEnabled) {
actor->updateStatus(kActorStatus1);
}
@@ -249,7 +251,7 @@ void Special::chapter2(Object *object, ActorIndex actorIndex) {
Actor *refActor = getScene()->getActor(actorIndex - 9); // Original uses offset to object array (+ offset to actor).
*actor->getPoint1() = *refActor->getPoint1();
- actor->getPoint1()->y += getSharedData()->getData(actorIndex - 8);
+ actor->getPoint1()->y += getSharedData()->getChapter2Data(2, actorIndex - 22); // cursorResources + 30
actor->setFrameIndex(refActor->getFrameIndex());
actor->setDirection(refActor->getDirection());
@@ -276,7 +278,7 @@ void Special::chapter2(Object *object, ActorIndex actorIndex) {
actor->setFrameIndex(0);
if (actor->isVisible())
- if (getSharedData()->getActorUpdateFlag2() < 7)
+ if (getSharedData()->getChapter2Counter(5) < 7)
getSpeech()->playPlayer(452);
_vm->setGameFlag(kGameFlag219);
@@ -1423,6 +1425,25 @@ ResourceId Special::getResourceId(Object *object, ActorIndex actorIndex) {
return (actorIndex == kActorInvalid) ? object->getSoundResourceId() : getScene()->getActor(actorIndex)->getSoundResourceId();
}
+int32 Special::getCounter(ActorIndex index) {
+ switch (index) {
+ default:
+ error("[Special::getCounter] Invalid actor index (was: %d, valid: 13, 15, 17, 18)", index);
+
+ case 13:
+ return 1;
+
+ case 15:
+ return 2;
+
+ case 17:
+ return 3;
+
+ case 18:
+ return 4;
+ }
+}
+
void Special::checkObject(Object *object, GameFlag flagToSet, GameFlag flagToClear, ObjectId objectId) {
if (object->getFrameIndex() == 15) {
_vm->setGameFlag(flagToSet);
diff --git a/engines/asylum/resources/special.h b/engines/asylum/resources/special.h
index 5f21a545bf..02ab9b0f95 100644
--- a/engines/asylum/resources/special.h
+++ b/engines/asylum/resources/special.h
@@ -46,7 +46,6 @@ private:
AsylumEngine* _vm;
// Counters
- int32 _chapter2Counter;
int32 _chapter5Counter;
bool _paletteFlag;
@@ -93,6 +92,7 @@ private:
// Helpers
//////////////////////////////////////////////////////////////////////////
ResourceId getResourceId(Object *object, ActorIndex actorIndex);
+ int32 getCounter(ActorIndex index);
void checkObject(Object *object, GameFlag flagToSet, GameFlag flagToClear, ObjectId objectId = kObjectInvalid);
void checkOtherObject(Object *object, ObjectId otherObjectId, GameFlag flagToClear, GameFlag flagToSet);
diff --git a/engines/asylum/system/sound.cpp b/engines/asylum/system/sound.cpp
index 310e88382d..6f12143817 100644
--- a/engines/asylum/system/sound.cpp
+++ b/engines/asylum/system/sound.cpp
@@ -156,15 +156,14 @@ int32 Sound::calculateVolumeAdjustement(const Common::Point &point, int32 attenu
if (!attenuation)
return -(delta * delta);
- Common::Point adjusted(point);
Actor *player = getScene()->getActor();
- if (getSharedData()->point.x == -1) {
- adjusted.x -= (player->getPoint1()->x + player->getPoint2()->x);
- adjusted.y -= (player->getPoint1()->y + player->getPoint2()->y);
- } else {
- adjusted.x -= getSharedData()->point.x;
- adjusted.y -= getSharedData()->point.y;
- }
+ Common::Point adjusted(point);
+ Common::Point sumPlayer = *player->getPoint1() + *player->getPoint2();
+
+ if (getSharedData()->getGlobalPoint().x == -1)
+ adjusted -= sumPlayer;
+ else
+ adjusted -= getSharedData()->getGlobalPoint();
int32 adjustedVolume = getAdjustedVolume(adjusted.x * adjusted.x + adjusted.y * adjusted.y);
diff --git a/engines/asylum/views/menu.cpp b/engines/asylum/views/menu.cpp
index 0da5504302..0fc4ffc22f 100644
--- a/engines/asylum/views/menu.cpp
+++ b/engines/asylum/views/menu.cpp
@@ -521,12 +521,12 @@ bool Menu::update() {
getSharedData()->setFlag(kFlagRedraw, true);
}
- if (ticks > getSharedData()->nextScreenUpdate) {
+ if (ticks > getSharedData()->getNextScreenUpdate()) {
if (getSharedData()->getFlag(kFlagRedraw)) {
getScreen()->copyBackBufferToScreen();
getSharedData()->setFlag(kFlagRedraw, false);
- getSharedData()->nextScreenUpdate = ticks + 55;
+ getSharedData()->setNextScreenUpdate(ticks + 55);
}
}
diff --git a/engines/asylum/views/scene.cpp b/engines/asylum/views/scene.cpp
index 93d19db386..4f283299b1 100644
--- a/engines/asylum/views/scene.cpp
+++ b/engines/asylum/views/scene.cpp
@@ -384,18 +384,18 @@ bool Scene::update() {
getSharedData()->setFlag(kFlagRedraw, true);
}
- if (ticks > getSharedData()->nextScreenUpdate) {
+ if (ticks > getSharedData()->getNextScreenUpdate()) {
if (getSharedData()->getFlag(kFlagRedraw)) {
- if (getSharedData()->matteBarHeight <= 0)
+ if (getSharedData()->getMatteBarHeight() <= 0)
getScreen()->copyBackBufferToScreen();
else
getEncounter()->drawScreen();
// Original also sets an unused value to 0
- getSharedData()->setData(39, getSharedData()->getData(39) ^ 1);
+ getSharedData()->setEventUpdate(getSharedData()->getEventUpdate() ^ 1);
getSharedData()->setFlag(kFlagRedraw, false);
- getSharedData()->nextScreenUpdate = ticks + 55;
+ getSharedData()->setNextScreenUpdate(ticks + 55);
++_vm->screenUpdateCount;
}
}
@@ -666,7 +666,7 @@ bool Scene::updateScene() {
#endif
// Update each part of the scene
- if (getSharedData()->matteBarHeight != 170 || getSharedData()->mattePlaySound) {
+ if (getSharedData()->getMatteBarHeight() != 170 || getSharedData()->getMattePlaySound()) {
MESURE_TICKS(updateMouse);
MESURE_TICKS(updateActors);
MESURE_TICKS(updateObjects);
@@ -1067,17 +1067,17 @@ void Scene::updateCoordinates() {
case 2:
case 5: {
- getSharedData()->sceneOffset += getSharedData()->sceneOffsetAdd;
+ getSharedData()->setSceneOffset(getSharedData()->getSceneOffset() + getSharedData()->getSceneOffsetAdd());
int32 coord1 = 0;
int32 coord2 = 0;
- if (abs(getSharedData()->sceneXLeft - _ws->coordinates[0]) <= abs(getSharedData()->sceneYTop - _ws->coordinates[1])) {
+ if (abs(getSharedData()->getSceneCoords().x - _ws->coordinates[0]) <= abs(getSharedData()->getSceneCoords().y - _ws->coordinates[1])) {
coord1 = _ws->coordinates[1];
coord2 = yTop;
if (_ws->coordinates[1] != _ws->yTop)
- xLeft = _ws->xLeft = getSharedData()->sceneOffset + getSharedData()->sceneXLeft;
+ xLeft = _ws->xLeft = getSharedData()->getSceneOffset() + getSharedData()->getSceneCoords().x;
yTop = _ws->coordinates[2] + _ws->yTop;
_ws->yTop += _ws->coordinates[2];
@@ -1087,7 +1087,7 @@ void Scene::updateCoordinates() {
coord2 = xLeft;
if (_ws->coordinates[0] != _ws->xLeft)
- yTop = _ws->yTop = getSharedData()->sceneOffset + getSharedData()->sceneYTop;
+ yTop = _ws->yTop = getSharedData()->getSceneOffset() + getSharedData()->getSceneCoords().y;
xLeft = _ws->coordinates[2] + _ws->xLeft;
_ws->xLeft += _ws->coordinates[2];
@@ -1741,12 +1741,12 @@ void Scene::hitActorChapter2(ActorIndex index) {
actor11->updateStatus(kActorStatus14);
}
- getSharedData()->setData(38, index);
+ getSharedData()->setChapter2ActorIndex(index);
} else if (index > 12) {
player->faceTarget(index + 9, kDirectionFromActor);
player->updateStatus(kActorStatus15);
- getSharedData()->setData(38, index);
+ getSharedData()->setChapter2ActorIndex(index);
}
}
@@ -2089,9 +2089,8 @@ bool Scene::updateSceneCoordinates(int32 tX, int32 tY, int32 A0, bool checkScene
*targetY = _ws->height - 480;
// Adjust scene offsets & coordinates
- getSharedData()->sceneOffset = 0;
- getSharedData()->sceneXLeft = _ws->xLeft;
- getSharedData()->sceneYTop = _ws->yTop;
+ getSharedData()->setSceneOffset(0);
+ getSharedData()->setSceneCoords(Common::Point(_ws->xLeft, _ws->yTop));
int32 diffX = *targetX - _ws->xLeft;
int32 diffY = *targetY - _ws->yTop;
@@ -2100,7 +2099,7 @@ bool Scene::updateSceneCoordinates(int32 tX, int32 tY, int32 A0, bool checkScene
if (_ws->yTop > *targetY)
*coord3 = -*coord3;
- getSharedData()->sceneOffsetAdd =Common::Rational(*coord3 * diffX, diffY).toInt();
+ getSharedData()->setSceneOffsetAdd(Common::Rational(*coord3 * diffX, diffY).toInt());
if (param != NULL && abs(diffY) <= abs(*coord3)) {
*targetX = -1;
@@ -2111,7 +2110,7 @@ bool Scene::updateSceneCoordinates(int32 tX, int32 tY, int32 A0, bool checkScene
if (_ws->xLeft > *targetX)
*coord3 = -*coord3;
- getSharedData()->sceneOffsetAdd = Common::Rational(*coord3 * diffY, diffX).toInt();
+ getSharedData()->setSceneOffsetAdd(Common::Rational(*coord3 * diffY, diffX).toInt());
if (param != NULL && abs(diffX) <= abs(*coord3)) {
*targetX = -1;
@@ -2267,14 +2266,13 @@ void Scene::changePlayer(ActorIndex index) {
break;
case 666:
- memcpy(getSharedData()->cursorResources, _ws->cursorResources, 44);
getScreen()->setupTransTables(3, _ws->graphicResourceIds[50], _ws->graphicResourceIds[49], _ws->graphicResourceIds[48]);
- getSharedData()->sceneFonts[0] = _ws->font1;
- getSharedData()->sceneFonts[1] = _ws->font2;
- getSharedData()->sceneFonts[2] = _ws->font3;
- getSharedData()->smallCurDown = _ws->smallCurDown;
- getSharedData()->smallCurUp = _ws->smallCurUp;
- getSharedData()->encounterFrameBg = _ws->encounterFrameBg;
+
+ // Save scene data
+ getSharedData()->saveCursorResources((ResourceId *)&_ws->cursorResources, sizeof(_ws->cursorResources));
+ getSharedData()->saveSceneFonts(_ws->font1, _ws->font2, _ws->font3);
+ getSharedData()->saveSmallCursor(_ws->smallCurDown, _ws->smallCurUp);
+ getSharedData()->saveEncounterFrameBackground(_ws->encounterFrameBg);
// Setup new values
for (uint32 i = 0; i < 11; i++)
@@ -2291,14 +2289,12 @@ void Scene::changePlayer(ActorIndex index) {
case 667:
getScreen()->setupTransTables(3, _ws->cellShadeMask1, _ws->cellShadeMask2, _ws->cellShadeMask3);
- memcpy(_ws->cursorResources, getSharedData()->cursorResources, 44);
- _ws->font1 = getSharedData()->sceneFonts[0];
- _ws->font2 = getSharedData()->sceneFonts[1];
- _ws->font3 = getSharedData()->sceneFonts[2];
- _ws->smallCurDown = getSharedData()->smallCurDown;
- _ws->smallCurUp = getSharedData()->smallCurUp;
- _ws->encounterFrameBg = getSharedData()->encounterFrameBg;
+ // Load scene data
+ getSharedData()->loadCursorResources((ResourceId *)&_ws->cursorResources, sizeof(_ws->cursorResources));
+ getSharedData()->loadSceneFonts(&_ws->font1, &_ws->font2, &_ws->font3);
+ getSharedData()->loadSmallCursor(&_ws->smallCurDown, &_ws->smallCurUp);
+ getSharedData()->loadEncounterFrameBackground(&_ws->encounterFrameBg);
// Reset cursor
getCursor()->set(_ws->cursorResources[kCursorResourceMagnifyingGlass], 0, kCursorAnimationNone);
@@ -2306,7 +2302,7 @@ void Scene::changePlayer(ActorIndex index) {
case 668:
getActor(11)->setPosition(2300, 100, kDirectionN, 0);
- getSharedData()->setData(40, 0);
+ getSharedData()->setChapter2Counter(6, 0);
getSharedData()->setFlag(kFlag1, false);
break;
}
Commit: 3dc4f4206237a5c8fabeff5641cf6b34fcd98fb6
https://github.com/scummvm/scummvm/commit/3dc4f4206237a5c8fabeff5641cf6b34fcd98fb6
Author: Alex Bevilacqua (alexbevi at gmail.com)
Date: 2021-05-17T15:37:13+02:00
Commit Message:
ASYLUM: add a workaround for the cursor not remaining hidden during the intro speech
Changed paths:
engines/asylum/asylum.cpp
engines/asylum/system/cursor.cpp
engines/asylum/system/cursor.h
diff --git a/engines/asylum/asylum.cpp b/engines/asylum/asylum.cpp
index b4de77fe39..3baf2fc983 100644
--- a/engines/asylum/asylum.cpp
+++ b/engines/asylum/asylum.cpp
@@ -279,7 +279,7 @@ void AsylumEngine::playIntro() {
if (!_introPlayed) {
_cursor->hide();
-
+ _cursor->forceHide = true;
if (!Config.showIntro) {
if (_scene->worldstats()->chapter == kChapter1)
_sound->playMusic(MAKE_RESOURCE(kResourcePackMusic, _scene->worldstats()->musicCurrentResourceIndex));
@@ -287,7 +287,6 @@ void AsylumEngine::playIntro() {
_sound->playMusic(kResourceNone, 0);
_video->play(1, _menu);
- // FIXME: the cursor is still shown after the video ends
if (_scene->worldstats()->musicCurrentResourceIndex != kMusicStopped)
_sound->playMusic(MAKE_RESOURCE(kResourcePackMusic, _scene->worldstats()->musicCurrentResourceIndex));
@@ -303,7 +302,7 @@ void AsylumEngine::playIntro() {
_sound->playSound(introSpeech);
do {
- // Poll events (this ensure we don't freeze the screen)
+ // Poll events (this ensures we don't freeze the screen)
Common::Event ev;
_eventMan->pollEvent(ev);
@@ -312,7 +311,7 @@ void AsylumEngine::playIntro() {
} while (_sound->isPlaying(introSpeech));
}
-
+ _cursor->forceHide = false;
_introPlayed = true;
}
diff --git a/engines/asylum/system/cursor.cpp b/engines/asylum/system/cursor.cpp
index 57dcec3205..1be8cb58a3 100644
--- a/engines/asylum/system/cursor.cpp
+++ b/engines/asylum/system/cursor.cpp
@@ -36,7 +36,7 @@ const uint32 CURSOR_UPDATE_TICKS = 100;
Cursor::Cursor(AsylumEngine *engine) : _vm(engine),
graphicResourceId(kResourceNone), currentFrame(0), lastFrameIndex(0), counter(0), animation(kCursorAnimationNone),
- _cursorRes(NULL), _nextTick(0), _frameStep(0), _state(0) {
+ _cursorRes(NULL), _nextTick(0), _frameStep(0), _state(0), forceHide(false) {
}
@@ -52,7 +52,8 @@ void Cursor::hide() const {
}
void Cursor::show() const {
- CursorMan.showMouse(true);
+ if (!forceHide)
+ CursorMan.showMouse(true);
}
void Cursor::set(ResourceId resourceId, int32 cnt, CursorAnimation anim, int32 frames) {
diff --git a/engines/asylum/system/cursor.h b/engines/asylum/system/cursor.h
index f3ee0d460b..576ca71e92 100644
--- a/engines/asylum/system/cursor.h
+++ b/engines/asylum/system/cursor.h
@@ -107,6 +107,18 @@ public:
int32 counter;
CursorAnimation animation;
+ /**
+ * Since the cursor is updated by various event handlers, if an action is
+ * currently being processed that requires the cursor to remain hidden, another
+ * event may override that request and show the cursor regardless
+ *
+ * This is currently used during the intro speech in Scene 1 after the intro
+ * video plays
+ *
+ * @default false
+ */
+ bool forceHide;
+
private:
AsylumEngine *_vm;
Commit: 1d7ac2949efc2888dba6bee44b067c45f9bcab99
https://github.com/scummvm/scummvm/commit/1d7ac2949efc2888dba6bee44b067c45f9bcab99
Author: Alex Bevilacqua (alexbevi at gmail.com)
Date: 2021-05-17T15:37:13+02:00
Commit Message:
ASYLUM: fix some warnings found by eclipse
Changed paths:
engines/asylum/resources/actor.h
engines/asylum/resources/script.cpp
engines/asylum/system/config.h
diff --git a/engines/asylum/resources/actor.h b/engines/asylum/resources/actor.h
index 8277332a35..f4dfd7d365 100644
--- a/engines/asylum/resources/actor.h
+++ b/engines/asylum/resources/actor.h
@@ -256,7 +256,7 @@ public:
bool process(const Common::Point &point);
void processStatus(int32 actorX, int32 actorY, bool doSpeech);
void processNext(ActorIndex nextActor, int32 actionAreaId, ActorDirection nextDirection, const Common::Point &nextPosition, bool invertPriority, const Common::Point &nextPositionOffset);
- bool canInteract(Common::Point *point, int* param);
+ bool canInteract(Common::Point *point, int32* param);
bool canMove(Common::Point *point, ActorDirection direction, uint32 count, bool hasDelta);
void move(ActorDirection dir, uint32 distance);
void addReactionHive(int32 reactionIndex, int32 numberValue01Add);
diff --git a/engines/asylum/resources/script.cpp b/engines/asylum/resources/script.cpp
index 91dbf94a67..cb62f73a7e 100644
--- a/engines/asylum/resources/script.cpp
+++ b/engines/asylum/resources/script.cpp
@@ -250,7 +250,7 @@ void ScriptManager::resetQueue() {
_queue.reset();
}
-void ScriptManager::queueScript(int scriptIndex, ActorIndex actorIndex) {
+void ScriptManager::queueScript(int32 scriptIndex, ActorIndex actorIndex) {
// When the skipProcessing flag is set, do not queue any more scripts
if (_skipProcessing)
return;
diff --git a/engines/asylum/system/config.h b/engines/asylum/system/config.h
index 092b6da370..d9bb15142a 100644
--- a/engines/asylum/system/config.h
+++ b/engines/asylum/system/config.h
@@ -43,9 +43,9 @@ public:
//////////////////////////////////////////////////////////////////////////
// Default options
- int musicVolume;
- int sfxVolume;
- int voiceVolume;
+ int32 musicVolume;
+ int32 sfxVolume;
+ int32 voiceVolume;
bool showMovieSubtitles;
// Engine options
Commit: 30b4f0b93126d3502e88e3468cb8c1ee6bc07c19
https://github.com/scummvm/scummvm/commit/30b4f0b93126d3502e88e3468cb8c1ee6bc07c19
Author: Alex Bevilacqua (alexbevi at gmail.com)
Date: 2021-05-17T15:37:13+02:00
Commit Message:
ASYLUM: fixed a bug in Actor::updateFinish()
We weren't checking the area flags and were running an actor reaction
immediately after the intro script completed.
Changed paths:
engines/asylum/resources/actor.cpp
diff --git a/engines/asylum/resources/actor.cpp b/engines/asylum/resources/actor.cpp
index e564a9051a..991dea40d4 100644
--- a/engines/asylum/resources/actor.cpp
+++ b/engines/asylum/resources/actor.cpp
@@ -3212,7 +3212,7 @@ void Actor::updateFinish() {
ActionArea *area = getWorld()->actions[areaIndex];
ActionArea *actorArea = getWorld()->actions[_actionIdx3];
- if (!getScript()->isProcessingSkipped()) {
+ if ((area->flags & 1) && !getScript()->isProcessingSkipped()) {
getScript()->queueScript(actorArea->scriptIndex2, _index);
getScript()->queueScript(area->scriptIndex, _index);
}
Commit: b3088399529c2c3dc301874c433bd7df65f5d0fc
https://github.com/scummvm/scummvm/commit/b3088399529c2c3dc301874c433bd7df65f5d0fc
Author: Alexander (alex220486 at gmail.com)
Date: 2021-05-17T15:37:13+02:00
Commit Message:
ASYLUM: Add detection entry for Russian version
Changed paths:
engines/asylum/detection.cpp
diff --git a/engines/asylum/detection.cpp b/engines/asylum/detection.cpp
index cebba3fd4e..bf80aafbf3 100644
--- a/engines/asylum/detection.cpp
+++ b/engines/asylum/detection.cpp
@@ -107,6 +107,20 @@ static const ADGameDescription gameDescriptions[] = {
ADGF_NO_FLAGS,
Common::GUIO_NONE
},
+ {
+ "asylum",
+ "Russian Version",
+ {
+ {"SNTRM.DAT", 0, "7cfcc457c1f579fbf9878ac175d29374", 8930},
+ {"RES.000", 0, "1f8a262bf8b3035bd3cfda24068c4651", 263624},
+ {"SCN.006", 0, "3a5b54da08198012dc0614114782d5fb", 2918330},
+ {0,0,0,0}
+ },
+ Common::RU_RUS,
+ Common::kPlatformPC,
+ ADGF_NO_FLAGS,
+ Common::GUIO_NONE
+ },
AD_TABLE_END_MARKER
};
Commit: c51cd5dea90eac9b3a4d69f6d26addeb6ec8e99c
https://github.com/scummvm/scummvm/commit/c51cd5dea90eac9b3a4d69f6d26addeb6ec8e99c
Author: Alexander (alex220486 at gmail.com)
Date: 2021-05-17T15:37:13+02:00
Commit Message:
ASYLUM: Attempt to fix a bug in Text::draw(int32, int32, TextCentering, ...)
Changed paths:
engines/asylum/system/text.cpp
diff --git a/engines/asylum/system/text.cpp b/engines/asylum/system/text.cpp
index e6172fca84..f4abb7ecaf 100644
--- a/engines/asylum/system/text.cpp
+++ b/engines/asylum/system/text.cpp
@@ -187,6 +187,7 @@ uint32 Text::draw(int32 a1, int32 a2, TextCentering centering, int32 x, int32 y,
bool drawText = false;
int32 spaceWidth = 0;
int32 index = 0;
+ int32 w = 0;
const char *string = text;
const char *endText = text;
@@ -216,6 +217,7 @@ label_start:
break;
}
+ x += w;
y += spacing;
++printed;
}
@@ -237,8 +239,8 @@ label_start:
}
const char *txt = text;
- int32 w = 0;
+ w = 0;
for (;;) {
char c = *txt;
w += charWidth;
@@ -253,16 +255,19 @@ label_start:
if (c == 1) // Start of heading (SOH)
break;
- charWidth += getWidth(c);
+ charWidth = getWidth(c);
+ w += charWidth;
txt++;
c = txt[0];
} while (c != ' ');
}
+ w += getWidth(' ');
+
if ((w + charWidth) > width) {
string = text;
- endText = txt2 - 1;
+ endText = txt;
drawText = true;
goto label_start;
}
Commit: 0978aa14ab67aba590032199e448697c82a2a2a6
https://github.com/scummvm/scummvm/commit/0978aa14ab67aba590032199e448697c82a2a2a6
Author: Alex Bevilacqua (alexbevi at gmail.com)
Date: 2021-05-17T15:37:13+02:00
Commit Message:
ASYLUM: actually save configuration changes to settings file
Changed paths:
engines/asylum/system/config.cpp
diff --git a/engines/asylum/system/config.cpp b/engines/asylum/system/config.cpp
index b99e7a184c..cb2221e8d8 100644
--- a/engines/asylum/system/config.cpp
+++ b/engines/asylum/system/config.cpp
@@ -153,6 +153,8 @@ void ConfigurationManager::write() {
ConfMan.setInt("key_switchToSara", (int)keySwitchToSara);
ConfMan.setInt("key_switchToGrimwall", (int)keySwitchToGrimwall);
ConfMan.setInt("key_switchToOlmec", (int)keySwitchToOlmec);
+
+ ConfMan.flushToDisk();
}
bool ConfigurationManager::isKeyAssigned(char key) {
Commit: ef991acd9e8ade63614460a9049f3029bc4d8dfb
https://github.com/scummvm/scummvm/commit/ef991acd9e8ade63614460a9049f3029bc4d8dfb
Author: Alex Bevilacqua (alexbevi at gmail.com)
Date: 2021-05-17T15:37:14+02:00
Commit Message:
ASYLUM: Silence GCC Warnings
Changed paths:
engines/asylum/resources/data.cpp
diff --git a/engines/asylum/resources/data.cpp b/engines/asylum/resources/data.cpp
index 3e42583593..74e2924e9a 100644
--- a/engines/asylum/resources/data.cpp
+++ b/engines/asylum/resources/data.cpp
@@ -167,28 +167,28 @@ uint32 SharedData::getAmbientTick(uint32 index) {
error("[SharedData::getAmbientTick] index is outside valid values (was: %d, valid: [0:%d]", index, ARRAYSIZE(_ambientTicks));
return _ambientTicks[index];
-};
+}
void SharedData::setAmbientTick(uint32 index, uint32 val) {
if (index >= ARRAYSIZE(_ambientTicks))
error("[SharedData::setAmbientTick] index is outside valid values (was: %d, valid: [0:%d]", index, ARRAYSIZE(_ambientTicks));
_ambientTicks[index] = val;
-};
+}
uint32 SharedData::getAmbientFlag(uint32 index) {
if (index >= ARRAYSIZE(_ambientFlags))
error("[SharedData::getAmbientFlag] index is outside valid values (was: %d, valid: [0:%d]", index, ARRAYSIZE(_ambientFlags));
return _ambientFlags[index];
-};
+}
void SharedData::setAmbientFlag(uint32 index, uint32 val) {
if (index >= ARRAYSIZE(_ambientFlags))
error("[SharedData::setAmbientFlag] index is outside valid values (was: %d, valid: [0:%d]", index, ARRAYSIZE(_ambientFlags));
_ambientFlags[index] = val;
-};
+}
void SharedData::resetAmbientFlags() {
memset(&_ambientFlags, 0, sizeof(_ambientFlags));
Commit: 0ea5649869080ce8ce1d2cbdd88c78644f9242ec
https://github.com/scummvm/scummvm/commit/0ea5649869080ce8ce1d2cbdd88c78644f9242ec
Author: Alex Bevilacqua (alexbevi at gmail.com)
Date: 2021-05-17T15:37:14+02:00
Commit Message:
ASYLUM: remove unused variable
Changed paths:
engines/asylum/system/text.cpp
diff --git a/engines/asylum/system/text.cpp b/engines/asylum/system/text.cpp
index f4abb7ecaf..68e7e011a7 100644
--- a/engines/asylum/system/text.cpp
+++ b/engines/asylum/system/text.cpp
@@ -245,7 +245,6 @@ label_start:
char c = *txt;
w += charWidth;
charWidth = spaceWidth;
- const char *txt2 = txt;
if (*txt != ' ') {
do {
Commit: 71e1afe2c4108624f63c51c2bc781a79380af2a0
https://github.com/scummvm/scummvm/commit/71e1afe2c4108624f63c51c2bc781a79380af2a0
Author: Alex Bevilacqua (alexbevi at gmail.com)
Date: 2021-05-17T15:37:14+02:00
Commit Message:
ASYLUM: make a couple actor fields int32
Changed paths:
engines/asylum/resources/actor.cpp
engines/asylum/resources/actor.h
diff --git a/engines/asylum/resources/actor.cpp b/engines/asylum/resources/actor.cpp
index 991dea40d4..76c1520651 100644
--- a/engines/asylum/resources/actor.cpp
+++ b/engines/asylum/resources/actor.cpp
@@ -135,8 +135,8 @@ void Actor::load(Common::SeekableReadStream *stream) {
_point.y = stream->readSint32LE();
_resourceId = (ResourceId)stream->readSint32LE();
_objectIndex = stream->readSint32LE();
- _frameIndex = stream->readUint32LE();
- _frameCount = stream->readUint32LE();
+ _frameIndex = stream->readSint32LE();
+ _frameCount = stream->readSint32LE();
_point1.x = stream->readSint32LE();
_point1.y = stream->readSint32LE();
_point2.x = stream->readSint32LE();
@@ -171,8 +171,8 @@ void Actor::load(Common::SeekableReadStream *stream) {
_walkingSound2 = stream->readSint32LE();
_walkingSound3 = stream->readSint32LE();
_walkingSound4 = stream->readSint32LE();
- _field_64C = stream->readUint32LE();
- _field_650 = stream->readUint32LE();
+ _field_64C = stream->readSint32LE();
+ _field_650 = stream->readSint32LE();
for (int32 i = 0; i < 55; i++)
_graphicResourceIds[i] = (ResourceId)stream->readSint32LE();
@@ -250,7 +250,7 @@ void Actor::draw() {
point.y += _point.y;
// Compute frame index
- uint32 frameIndex = _frameIndex;
+ int32 frameIndex = _frameIndex;
if (_frameIndex >= _frameCount)
frameIndex = 2 * _frameCount - (_frameIndex + 1);
@@ -3400,7 +3400,7 @@ bool Actor::processActionDown(Common::Point source, const Common::Point &destina
bool Actor::processAction(const Common::Point &source, Common::Array<int> *actions, Common::Point *point, ActorDirection direction, const Common::Point &destination, bool *flag) {
Common::Point sign;
Common::Point src = source;
- uint32 frameNumber = _frameNumber;
+ int32 frameNumber = _frameNumber;
switch (direction){
default:
diff --git a/engines/asylum/resources/actor.h b/engines/asylum/resources/actor.h
index f4dfd7d365..5a8b5774aa 100644
--- a/engines/asylum/resources/actor.h
+++ b/engines/asylum/resources/actor.h
@@ -318,8 +318,8 @@ private:
Common::Point _point;
ResourceId _resourceId;
int32 _objectIndex;
- uint32 _frameIndex;
- uint32 _frameCount;
+ int32 _frameIndex;
+ int32 _frameCount;
Common::Point _point1;
Common::Point _point2;
Common::Rect _boundingRect;
@@ -342,8 +342,8 @@ private:
ResourceId _walkingSound2;
ResourceId _walkingSound3;
ResourceId _walkingSound4;
- uint32 _field_64C;
- uint32 _field_650;
+ int32 _field_64C;
+ int32 _field_650;
ResourceId _graphicResourceIds[55];
char _name[256];
int32 _distancesEO[20];
Commit: 2e9ab6929a11dd854612fb11e1c5a33d25cf83b4
https://github.com/scummvm/scummvm/commit/2e9ab6929a11dd854612fb11e1c5a33d25cf83b4
Author: Alex Bevilacqua (alexbevi at gmail.com)
Date: 2021-05-17T15:37:14+02:00
Commit Message:
ASYLUM: revert commits aac7e28, 326ec63 and bfe63c2
Changed paths:
engines/asylum/resources/actor.cpp
engines/asylum/resources/actor.h
engines/asylum/system/text.cpp
diff --git a/engines/asylum/resources/actor.cpp b/engines/asylum/resources/actor.cpp
index 76c1520651..991dea40d4 100644
--- a/engines/asylum/resources/actor.cpp
+++ b/engines/asylum/resources/actor.cpp
@@ -135,8 +135,8 @@ void Actor::load(Common::SeekableReadStream *stream) {
_point.y = stream->readSint32LE();
_resourceId = (ResourceId)stream->readSint32LE();
_objectIndex = stream->readSint32LE();
- _frameIndex = stream->readSint32LE();
- _frameCount = stream->readSint32LE();
+ _frameIndex = stream->readUint32LE();
+ _frameCount = stream->readUint32LE();
_point1.x = stream->readSint32LE();
_point1.y = stream->readSint32LE();
_point2.x = stream->readSint32LE();
@@ -171,8 +171,8 @@ void Actor::load(Common::SeekableReadStream *stream) {
_walkingSound2 = stream->readSint32LE();
_walkingSound3 = stream->readSint32LE();
_walkingSound4 = stream->readSint32LE();
- _field_64C = stream->readSint32LE();
- _field_650 = stream->readSint32LE();
+ _field_64C = stream->readUint32LE();
+ _field_650 = stream->readUint32LE();
for (int32 i = 0; i < 55; i++)
_graphicResourceIds[i] = (ResourceId)stream->readSint32LE();
@@ -250,7 +250,7 @@ void Actor::draw() {
point.y += _point.y;
// Compute frame index
- int32 frameIndex = _frameIndex;
+ uint32 frameIndex = _frameIndex;
if (_frameIndex >= _frameCount)
frameIndex = 2 * _frameCount - (_frameIndex + 1);
@@ -3400,7 +3400,7 @@ bool Actor::processActionDown(Common::Point source, const Common::Point &destina
bool Actor::processAction(const Common::Point &source, Common::Array<int> *actions, Common::Point *point, ActorDirection direction, const Common::Point &destination, bool *flag) {
Common::Point sign;
Common::Point src = source;
- int32 frameNumber = _frameNumber;
+ uint32 frameNumber = _frameNumber;
switch (direction){
default:
diff --git a/engines/asylum/resources/actor.h b/engines/asylum/resources/actor.h
index 5a8b5774aa..f4dfd7d365 100644
--- a/engines/asylum/resources/actor.h
+++ b/engines/asylum/resources/actor.h
@@ -318,8 +318,8 @@ private:
Common::Point _point;
ResourceId _resourceId;
int32 _objectIndex;
- int32 _frameIndex;
- int32 _frameCount;
+ uint32 _frameIndex;
+ uint32 _frameCount;
Common::Point _point1;
Common::Point _point2;
Common::Rect _boundingRect;
@@ -342,8 +342,8 @@ private:
ResourceId _walkingSound2;
ResourceId _walkingSound3;
ResourceId _walkingSound4;
- int32 _field_64C;
- int32 _field_650;
+ uint32 _field_64C;
+ uint32 _field_650;
ResourceId _graphicResourceIds[55];
char _name[256];
int32 _distancesEO[20];
diff --git a/engines/asylum/system/text.cpp b/engines/asylum/system/text.cpp
index 68e7e011a7..e6172fca84 100644
--- a/engines/asylum/system/text.cpp
+++ b/engines/asylum/system/text.cpp
@@ -187,7 +187,6 @@ uint32 Text::draw(int32 a1, int32 a2, TextCentering centering, int32 x, int32 y,
bool drawText = false;
int32 spaceWidth = 0;
int32 index = 0;
- int32 w = 0;
const char *string = text;
const char *endText = text;
@@ -217,7 +216,6 @@ label_start:
break;
}
- x += w;
y += spacing;
++printed;
}
@@ -239,12 +237,13 @@ label_start:
}
const char *txt = text;
+ int32 w = 0;
- w = 0;
for (;;) {
char c = *txt;
w += charWidth;
charWidth = spaceWidth;
+ const char *txt2 = txt;
if (*txt != ' ') {
do {
@@ -254,19 +253,16 @@ label_start:
if (c == 1) // Start of heading (SOH)
break;
- charWidth = getWidth(c);
- w += charWidth;
+ charWidth += getWidth(c);
txt++;
c = txt[0];
} while (c != ' ');
}
- w += getWidth(' ');
-
if ((w + charWidth) > width) {
string = text;
- endText = txt;
+ endText = txt2 - 1;
drawText = true;
goto label_start;
}
Commit: ff0d80587f19fb324fce56310cb7e211824c7244
https://github.com/scummvm/scummvm/commit/ff0d80587f19fb324fce56310cb7e211824c7244
Author: Littleboy (littleboy at scummvm.org)
Date: 2021-05-17T15:37:14+02:00
Commit Message:
ASYLUM: Change text coordinates parameters to use Common::Point
Changed paths:
engines/asylum/puzzles/board.cpp
engines/asylum/puzzles/writings.cpp
engines/asylum/resources/actor.cpp
engines/asylum/resources/encounters.cpp
engines/asylum/system/text.cpp
engines/asylum/system/text.h
engines/asylum/views/menu.cpp
engines/asylum/views/scenetitle.cpp
engines/asylum/views/video.cpp
diff --git a/engines/asylum/puzzles/board.cpp b/engines/asylum/puzzles/board.cpp
index 985c4e4247..3d77dc4d06 100644
--- a/engines/asylum/puzzles/board.cpp
+++ b/engines/asylum/puzzles/board.cpp
@@ -149,14 +149,14 @@ bool PuzzleBoard::stopSound() {
void PuzzleBoard::drawText() {
getText()->loadFont(getWorld()->graphicResourceIds[35]);
- getText()->draw(0, 99, kTextCenter, 25, 50, 16, 590, _text.c_str());
+ getText()->draw(0, 99, kTextCenter, Common::Point(25, 50), 16, 590, _text.c_str());
int32 index = 0;
for (uint32 x = 215; x < _data.maxWidth; x += 24) {
if (!_solvedText[index])
break;
- getText()->setPosition(x, _selectedSlot != index ? 360 : 370);
+ getText()->setPosition(Common::Point(x, _selectedSlot != index ? 360 : 370));
getText()->drawChar(_solvedText[index]);
index += 2;
diff --git a/engines/asylum/puzzles/writings.cpp b/engines/asylum/puzzles/writings.cpp
index dd0f96413e..5512c7fcbf 100644
--- a/engines/asylum/puzzles/writings.cpp
+++ b/engines/asylum/puzzles/writings.cpp
@@ -130,18 +130,18 @@ void PuzzleWritings::drawBackground() {
// Draw all lines of text
getText()->loadFont(getWorld()->graphicResourceIds[42]);
- getText()->draw(0, 99, kTextNormal, 70, 45, 16, 24, getText()->get(MAKE_RESOURCE(kResourcePackText, 1825)));
- getText()->draw(0, 99, kTextNormal, 130, 75, 16, 24, getText()->get(MAKE_RESOURCE(kResourcePackText, 1826)));
- getText()->draw(0, 99, kTextNormal, 70, 105, 16, 24, getText()->get(MAKE_RESOURCE(kResourcePackText, 1827)));
- getText()->draw(0, 99, kTextNormal, 130, 135, 16, 24, getText()->get(MAKE_RESOURCE(kResourcePackText, 1828)));
- getText()->draw(0, 99, kTextNormal, 70, 165, 16, 24, getText()->get(MAKE_RESOURCE(kResourcePackText, 1829)));
- getText()->draw(0, 99, kTextNormal, 130, 195, 16, 24, getText()->get(MAKE_RESOURCE(kResourcePackText, 1830)));
- getText()->draw(0, 99, kTextNormal, 70, 225, 16, 24, getText()->get(MAKE_RESOURCE(kResourcePackText, 1831)));
- getText()->draw(0, 99, kTextNormal, 130, 255, 16, 24, getText()->get(MAKE_RESOURCE(kResourcePackText, 1832)));
- getText()->draw(0, 99, kTextNormal, 70, 285, 16, 24, getText()->get(MAKE_RESOURCE(kResourcePackText, 1833)));
- getText()->draw(0, 99, kTextNormal, 130, 315, 16, 24, getText()->get(MAKE_RESOURCE(kResourcePackText, 1834)));
- getText()->draw(0, 99, kTextCenter, 320, 375, 16, 24, getText()->get(MAKE_RESOURCE(kResourcePackText, 1835)));
- getText()->draw(0, 99, kTextCenter, 320, 405, 16, 24, getText()->get(MAKE_RESOURCE(kResourcePackText, 1836)));
+ getText()->draw(0, 99, kTextNormal, Common::Point( 70, 45), 16, 24, getText()->get(MAKE_RESOURCE(kResourcePackText, 1825)));
+ getText()->draw(0, 99, kTextNormal, Common::Point(130, 75), 16, 24, getText()->get(MAKE_RESOURCE(kResourcePackText, 1826)));
+ getText()->draw(0, 99, kTextNormal, Common::Point( 70, 105), 16, 24, getText()->get(MAKE_RESOURCE(kResourcePackText, 1827)));
+ getText()->draw(0, 99, kTextNormal, Common::Point(130, 135), 16, 24, getText()->get(MAKE_RESOURCE(kResourcePackText, 1828)));
+ getText()->draw(0, 99, kTextNormal, Common::Point( 70, 165), 16, 24, getText()->get(MAKE_RESOURCE(kResourcePackText, 1829)));
+ getText()->draw(0, 99, kTextNormal, Common::Point(130, 195), 16, 24, getText()->get(MAKE_RESOURCE(kResourcePackText, 1830)));
+ getText()->draw(0, 99, kTextNormal, Common::Point( 70, 225), 16, 24, getText()->get(MAKE_RESOURCE(kResourcePackText, 1831)));
+ getText()->draw(0, 99, kTextNormal, Common::Point(130, 255), 16, 24, getText()->get(MAKE_RESOURCE(kResourcePackText, 1832)));
+ getText()->draw(0, 99, kTextNormal, Common::Point( 70, 285), 16, 24, getText()->get(MAKE_RESOURCE(kResourcePackText, 1833)));
+ getText()->draw(0, 99, kTextNormal, Common::Point(130, 315), 16, 24, getText()->get(MAKE_RESOURCE(kResourcePackText, 1834)));
+ getText()->draw(0, 99, kTextCenter, Common::Point(320, 375), 16, 24, getText()->get(MAKE_RESOURCE(kResourcePackText, 1835)));
+ getText()->draw(0, 99, kTextCenter, Common::Point(320, 405), 16, 24, getText()->get(MAKE_RESOURCE(kResourcePackText, 1836)));
}
} // End of namespace Asylum
diff --git a/engines/asylum/resources/actor.cpp b/engines/asylum/resources/actor.cpp
index 991dea40d4..ef0b17ec03 100644
--- a/engines/asylum/resources/actor.cpp
+++ b/engines/asylum/resources/actor.cpp
@@ -273,7 +273,7 @@ void Actor::drawNumber() {
return;
getText()->loadFont(getWorld()->font1);
- getText()->drawCentered(_numberStringX, _numberStringY, _numberStringWidth, (char *)&_numberString01);
+ getText()->drawCentered(Common::Point(_numberStringX, _numberStringY), _numberStringWidth, (char *)&_numberString01);
}
void Actor::update() {
diff --git a/engines/asylum/resources/encounters.cpp b/engines/asylum/resources/encounters.cpp
index 2b4c01a737..3d43e94824 100644
--- a/engines/asylum/resources/encounters.cpp
+++ b/engines/asylum/resources/encounters.cpp
@@ -1084,13 +1084,13 @@ void Encounter::drawDialog() {
else
getText()->loadFont(getWorld()->font1);
- int32 x = _drawingStructs[0].point1.y + 144 * (counter % 3) + _point.x + (counter % 3) + _portrait1.rect.width() + 15;
- int32 y = _point.y + (16 * counter / 3);
+ Common::Point coords(_drawingStructs[0].point1.y + 144 * (counter % 3) + _point.x + (counter % 3) + _portrait1.rect.width() + 15,
+ _point.y + (16 * counter / 3));
if (getKeywordIndex() == index)
- getScreen()->fillRect(x -1, y + 5, getText()->getWidth(MAKE_RESOURCE(kResourcePackShared, 3681)), 18, 0);
+ getScreen()->fillRect(coords.x - 1, coords.y + 5, getText()->getWidth(MAKE_RESOURCE(kResourcePackShared, 3681)), 18, 0);
- getText()->setPosition(x, y);
+ getText()->setPosition(coords);
getText()->draw(MAKE_RESOURCE(kResourcePackShared, 3681));
++counter;
@@ -1117,13 +1117,13 @@ void Encounter::drawText(char *text, ResourceId font, int32 y) {
}
} else {
_data_455BCC = true;
- _data_455B70 = getText()->draw(kTextCalculate, x, y, 16, width, text);
+ _data_455B70 = getText()->draw(kTextCalculate, Common::Point(x, y), 16, width, text);
_data_455B3C = _data_455B70 / 8 + 1;
_data_455BF0 = 0;
_tick = _vm->getTick() + 1000 * getResource()->get(getSpeech()->getSoundResourceId())->size / 11025 / _data_455B3C;
}
- getText()->draw(_data_455BF0, 7, kTextCenter, x, y, 16, width, text);
+ getText()->draw(_data_455BF0, 7, kTextCenter, Common::Point(x, y), 16, width, text);
}
void Encounter::drawScreen() {
diff --git a/engines/asylum/system/text.cpp b/engines/asylum/system/text.cpp
index e6172fca84..4f2b7e7b1f 100644
--- a/engines/asylum/system/text.cpp
+++ b/engines/asylum/system/text.cpp
@@ -28,7 +28,6 @@
#include "asylum/asylum.h"
#include "asylum/respack.h"
-#include "common/endian.h"
#include "common/rational.h"
namespace Asylum {
@@ -63,9 +62,8 @@ ResourceId Text::loadFont(ResourceId resourceId) {
return previousFont;
}
-void Text::setPosition(int32 x, int32 y) {
- _position.x = x;
- _position.y = y;
+void Text::setPosition(const Common::Point &point) {
+ _position = point;
}
int32 Text::getWidth(char c) {
@@ -130,7 +128,7 @@ void Text::drawChar(char character) {
}
GraphicFrame *fontLetter = _fontResource->getFrame((uint8)character);
- _position.x += fontLetter->surface.w + fontLetter->x - _curFontFlags;
+ _position.x += (int16)fontLetter->surface.w + fontLetter->x - _curFontFlags;
}
void Text::draw(const char *text) {
@@ -159,30 +157,32 @@ void Text::draw(ResourceId resourceId) {
draw((char*)textRes->data);
}
-void Text::draw(int32 x, int32 y, const char *text) {
- setPosition(x - getWidth(text), y);
+void Text::draw(const Common::Point &point, const char *text) {
+ setPosition(Common::Point(point.x - getWidth(text), point.y));
draw(text);
}
-void Text::draw(int32 x, int32 y, ResourceId resourceId) {
- draw(x, y, get(resourceId));
+void Text::draw(const Common::Point &point, ResourceId resourceId) {
+ draw(point, get(resourceId));
}
void Text::draw(const char *text, ResourceId fontResourceId, int32 y) {
if (text) {
loadFont(fontResourceId);
- draw(kTextCenter, 20, y, 16, 600, text);
+ draw(kTextCenter, Common::Point(20, y), 16, 600, text);
}
}
-uint32 Text::draw(TextCentering centering, int32 x, int32 y, int32 spacing, int32 width, const char *text) {
- return draw(0, 99, centering, x, y, spacing, width, text);
+uint32 Text::draw(TextCentering centering, const Common::Point &point, int32 spacing, int32 width, const char *text) {
+ return draw(0, 99, centering, point, spacing, width, text);
}
-uint32 Text::draw(int32 a1, int32 a2, TextCentering centering, int32 x, int32 y, int32 spacing, int32 width, const char *text) {
+uint32 Text::draw(int32 a1, int32 a2, TextCentering centering, const Common::Point &point, int32 spacing, int32 width, const char *text) {
if (!text || !*text)
return 0;
+ Common::Point coords = point;
+
uint32 printed = 0;
bool drawText = false;
int32 spaceWidth = 0;
@@ -207,16 +207,16 @@ label_start:
break;
case kTextCenter:
- drawCentered(x, y, width, endText - string, string);
+ drawCentered(coords, width, endText - string, string);
break;
case kTextNormal:
- setPosition(x, y);
+ setPosition(coords);
draw(text, endText - text);
break;
}
- y += spacing;
+ coords.y += spacing;
++printed;
}
@@ -285,18 +285,18 @@ label_start:
return printed;
}
-void Text::drawCentered(int32 x, int32 y, int32 width, const char *text) {
- setPosition(x + (width - getWidth(text)) / 2, y);
+void Text::drawCentered(const Common::Point &point, int32 width, const char *text) {
+ setPosition(Common::Point(point.x + (width - getWidth(text)) / 2, point.y));
draw(text);
}
-void Text::drawCentered(int32 x, int32 y, int32 width, uint32 length, const char *text) {
- setPosition(x + (width - getWidth(text, length)) / 2, y);
+void Text::drawCentered(const Common::Point &point, int32 width, uint32 length, const char *text) {
+ setPosition(Common::Point(point.x + (width - getWidth(text, length)) / 2, point.y));
draw(text, length);
}
-void Text::drawCentered(int32 x, int32 y, int32 width, ResourceId resourceId) {
- drawCentered(x, y, width, get(resourceId));
+void Text::drawCentered(const Common::Point &point, int32 width, ResourceId resourceId) {
+ drawCentered(point, width, get(resourceId));
}
} // end of namespace Asylum
diff --git a/engines/asylum/system/text.h b/engines/asylum/system/text.h
index 52ed51be1a..809d092ea6 100644
--- a/engines/asylum/system/text.h
+++ b/engines/asylum/system/text.h
@@ -47,7 +47,7 @@ public:
ResourceId loadFont(ResourceId resourceId);
- void setPosition(int32 x, int32 y);
+ void setPosition(const Common::Point &point);
int32 getWidth(char c);
int32 getWidth(const char *text);
int32 getWidth(const char *text, uint32 length);
@@ -56,17 +56,17 @@ public:
void drawChar(char character);
void draw(const char *text);
- void draw(int32 x, int32 y, const char *text);
+ void draw(const Common::Point &point, const char *text);
void draw(ResourceId resourceId);
- void draw(int32 x, int32 y, ResourceId resourceId);
+ void draw(const Common::Point &point, ResourceId resourceId);
void draw(const char *text, ResourceId fontResourceId, int32 y);
void draw(const char *text, uint32 length);
- uint32 draw(TextCentering centering, int32 x, int32 y, int32 spacing, int32 width, const char *text);
- uint32 draw(int32 a1, int32 a2, TextCentering centering, int32 x, int32 y, int32 spacing, int32 width, const char *text);
+ uint32 draw(TextCentering centering, const Common::Point &point, int32 spacing, int32 width, const char *text);
+ uint32 draw(int32 a1, int32 a2, TextCentering centering, const Common::Point &point, int32 spacing, int32 width, const char *text);
- void drawCentered(int32 x, int32 y, int32 width, const char *text);
- void drawCentered(int32 x, int32 y, int32 width, ResourceId resourceId);
- void drawCentered(int32 x, int32 y, int32 width, uint32 length, const char *text);
+ void drawCentered(const Common::Point &point, int32 width, const char *text);
+ void drawCentered(const Common::Point &point, int32 width, ResourceId resourceId);
+ void drawCentered(const Common::Point &point, int32 width, uint32 length, const char *text);
void setTransTableNum(int32 val) { _transTableNum = val; }
diff --git a/engines/asylum/views/menu.cpp b/engines/asylum/views/menu.cpp
index 0fc4ffc22f..98c77c7ea9 100644
--- a/engines/asylum/views/menu.cpp
+++ b/engines/asylum/views/menu.cpp
@@ -436,7 +436,7 @@ bool Menu::update() {
_iconFrames[icon] = (_iconFrames[icon] + 1) % GraphicResource::getFrameCount(_vm, MAKE_RESOURCE(kResourcePackShared, icon + 4));
// Draw text
- getText()->drawCentered(menuRects[icon].left - 5, menuRects[icon].bottom + 5, menuRects[icon].width(), MAKE_RESOURCE(kResourcePackText, 1309 + icon));
+ getText()->drawCentered(Common::Point(menuRects[icon].left - 5, menuRects[icon].bottom + 5), menuRects[icon].width(), MAKE_RESOURCE(kResourcePackText, 1309 + icon));
if (!_dword_455C74 || _currentIcon != icon) {
_dword_455C74 = true;
@@ -706,16 +706,16 @@ void Menu::updateNewGame() {
getText()->loadFont(kFontYellow);
// Begin new game
- getText()->drawCentered(10, 100, 620, MAKE_RESOURCE(kResourcePackText, 1321));
+ getText()->drawCentered(Common::Point(10, 100), 620, MAKE_RESOURCE(kResourcePackText, 1321));
// Yes
switchFont(cursor.x < 247 || cursor.x > (247 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 1322))) || cursor.y < 273 || cursor.y > (273 + 24));
- getText()->setPosition(247, 273);
+ getText()->setPosition(Common::Point(247, 273));
getText()->draw(MAKE_RESOURCE(kResourcePackText, 1322));
// No
switchFont(cursor.x < 369 || cursor.x > (369 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 1323))) || cursor.y < 273 || cursor.y > (273 + 24));
- getText()->setPosition(369, 273);
+ getText()->setPosition(Common::Point(369, 273));
getText()->draw(MAKE_RESOURCE(kResourcePackText, 1323));
}
@@ -726,10 +726,10 @@ void Menu::updateLoadGame() {
if (_dword_455C80) {
getText()->loadFont(kFontYellow);
- getText()->drawCentered(10, 100, 620, MAKE_RESOURCE(kResourcePackText, 1329));
+ getText()->drawCentered(Common::Point(10, 100), 620, MAKE_RESOURCE(kResourcePackText, 1329));
sprintf((char *)&text, "%s ?", getSaveLoad()->getName()->c_str());
- getText()->drawCentered(10, 134, 620, (char *)&text);
+ getText()->drawCentered(Common::Point(10, 134), 620, (char *)&text);
if (cursor.x < 247 || cursor.x > (247 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 1330)))
|| cursor.y < 273 || cursor.y > (273 + 24))
@@ -737,7 +737,7 @@ void Menu::updateLoadGame() {
else
getText()->loadFont(kFontBlue);
- getText()->setPosition(247, 273);
+ getText()->setPosition(Common::Point(247, 273));
getText()->draw(MAKE_RESOURCE(kResourcePackText, 1330));
if (cursor.x < 369 || cursor.x > (369 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 1331)))
@@ -746,18 +746,18 @@ void Menu::updateLoadGame() {
else
getText()->loadFont(kFontBlue);
- getText()->setPosition(369, 273);
+ getText()->setPosition(Common::Point(369, 273));
getText()->draw(MAKE_RESOURCE(kResourcePackText, 1331));
return;
}
getText()->loadFont(kFontYellow);
- getText()->drawCentered(10, 100, 620, MAKE_RESOURCE(kResourcePackText, 1325));
+ getText()->drawCentered(Common::Point(10, 100), 620, MAKE_RESOURCE(kResourcePackText, 1325));
if (_dword_455C78) {
- getText()->drawCentered(10, 190, 620, MAKE_RESOURCE(kResourcePackText, 1332));
- getText()->drawCentered(10, 190 + 29, 620, MAKE_RESOURCE(kResourcePackText, 1333));
- getText()->drawCentered(10, 190 + 53, 620, getSaveLoad()->getName()->c_str());
+ getText()->drawCentered(Common::Point(10, 190), 620, MAKE_RESOURCE(kResourcePackText, 1332));
+ getText()->drawCentered(Common::Point(10, 190 + 29), 620, MAKE_RESOURCE(kResourcePackText, 1333));
+ getText()->drawCentered(Common::Point(10, 190 + 53), 620, getSaveLoad()->getName()->c_str());
++_dword_456288;
@@ -784,7 +784,7 @@ void Menu::updateLoadGame() {
else
getText()->loadFont(kFontBlue);
- getText()->setPosition(30, y);
+ getText()->setPosition(Common::Point(30, y));
getText()->draw((char *)&text);
++index;
@@ -804,7 +804,7 @@ void Menu::updateLoadGame() {
else
getText()->loadFont(kFontBlue);
- getText()->setPosition(350, y);
+ getText()->setPosition(Common::Point(350, y));
getText()->draw((char *)&text);
++index;
@@ -819,7 +819,7 @@ void Menu::updateLoadGame() {
else
getText()->loadFont(kFontBlue);
- getText()->setPosition(30, 340);
+ getText()->setPosition(Common::Point(30, 340));
getText()->draw(MAKE_RESOURCE(kResourcePackText, 1326));
//////////////////////////////////////////////////////////////////////////
@@ -830,7 +830,7 @@ void Menu::updateLoadGame() {
else
getText()->loadFont(kFontBlue);
- getText()->setPosition(300, 340);
+ getText()->setPosition(Common::Point(300, 340));
getText()->draw(MAKE_RESOURCE(kResourcePackText, 1328));
//////////////////////////////////////////////////////////////////////////
@@ -841,7 +841,7 @@ void Menu::updateLoadGame() {
else
getText()->loadFont(kFontBlue);
- getText()->setPosition(550, 347);
+ getText()->setPosition(Common::Point(550, 347));
getText()->draw(MAKE_RESOURCE(kResourcePackText, 1327));
}
@@ -852,10 +852,10 @@ void Menu::updateSaveGame() {
if (_dword_455C80) {
getText()->loadFont(kFontYellow);
- getText()->drawCentered(10, 100, 620, MAKE_RESOURCE(kResourcePackText, 1339));
+ getText()->drawCentered(Common::Point(10, 100), 620, MAKE_RESOURCE(kResourcePackText, 1339));
sprintf((char *)&text, "%s ?", getSaveLoad()->getName()->c_str());
- getText()->drawCentered(10, 134, 620, (char *)&text);
+ getText()->drawCentered(Common::Point(10, 134), 620, (char *)&text);
if (cursor.x < 247 || cursor.x > (247 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 1340)))
|| cursor.y < 273 || cursor.y > (273 + 24))
@@ -863,7 +863,7 @@ void Menu::updateSaveGame() {
else
getText()->loadFont(kFontBlue);
- getText()->setPosition(247, 273);
+ getText()->setPosition(Common::Point(247, 273));
getText()->draw(MAKE_RESOURCE(kResourcePackText, 1340));
if (cursor.x < 369 || cursor.x > (369 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 1341)))
@@ -872,17 +872,17 @@ void Menu::updateSaveGame() {
else
getText()->loadFont(kFontBlue);
- getText()->setPosition(369, 273);
+ getText()->setPosition(Common::Point(369, 273));
getText()->draw(MAKE_RESOURCE(kResourcePackText, 1341));
return;
}
getText()->loadFont(kFontYellow);
- getText()->drawCentered(10, 100, 620, MAKE_RESOURCE(kResourcePackText, 1335));
+ getText()->drawCentered(Common::Point(10, 100), 620, MAKE_RESOURCE(kResourcePackText, 1335));
if (_dword_455C78) {
- getText()->drawCentered(10, 220, 620, MAKE_RESOURCE(kResourcePackText, 1343));
- getText()->drawCentered(10, 220 + 29, 620, getSaveLoad()->getName()->c_str());
+ getText()->drawCentered(Common::Point(10, 220), 620, MAKE_RESOURCE(kResourcePackText, 1343));
+ getText()->drawCentered(Common::Point(10, 220 + 29), 620, getSaveLoad()->getName()->c_str());
++_dword_456288;
@@ -914,7 +914,7 @@ void Menu::updateSaveGame() {
getText()->loadFont(kFontBlue);
}
- getText()->setPosition(30, y);
+ getText()->setPosition(Common::Point(30, y));
getText()->draw((char *)&text);
// Draw underscore
@@ -951,7 +951,7 @@ void Menu::updateSaveGame() {
getText()->loadFont(kFontBlue);
}
- getText()->setPosition(350, y);
+ getText()->setPosition(Common::Point(350, y));
getText()->draw((char *)&text);
// Draw underscore
@@ -977,7 +977,7 @@ void Menu::updateSaveGame() {
else
getText()->loadFont(kFontBlue);
- getText()->setPosition(30, 340);
+ getText()->setPosition(Common::Point(30, 340));
getText()->draw(MAKE_RESOURCE(kResourcePackText, 1336));
//////////////////////////////////////////////////////////////////////////
@@ -989,7 +989,7 @@ void Menu::updateSaveGame() {
else
getText()->loadFont(kFontBlue);
- getText()->setPosition(300, 340);
+ getText()->setPosition(Common::Point(300, 340));
getText()->draw(MAKE_RESOURCE(kResourcePackText, 1338));
//////////////////////////////////////////////////////////////////////////
@@ -1001,7 +1001,7 @@ void Menu::updateSaveGame() {
else
getText()->loadFont(kFontBlue);
- getText()->setPosition(550, 347);
+ getText()->setPosition(Common::Point(550, 347));
getText()->draw(MAKE_RESOURCE(kResourcePackText, 1337));
}
@@ -1012,10 +1012,10 @@ void Menu::updateDeleteGame() {
if (_dword_455C80) {
getText()->loadFont(kFontYellow);
- getText()->drawCentered(10, 100, 620, MAKE_RESOURCE(kResourcePackText, 1349));
+ getText()->drawCentered(Common::Point(10, 100), 620, MAKE_RESOURCE(kResourcePackText, 1349));
sprintf((char *)&text, "%s ?", getSaveLoad()->getName()->c_str());
- getText()->drawCentered(10, 134, 620, (char *)&text);
+ getText()->drawCentered(Common::Point(10, 134), 620, (char *)&text);
if (cursor.x < 247 || cursor.x > (247 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 1350)))
|| cursor.y < 273 || cursor.y > (273 + 24))
@@ -1023,7 +1023,7 @@ void Menu::updateDeleteGame() {
else
getText()->loadFont(kFontBlue);
- getText()->setPosition(247, 273);
+ getText()->setPosition(Common::Point(247, 273));
getText()->draw(MAKE_RESOURCE(kResourcePackText, 1350));
if (cursor.x < 369 || cursor.x > (369 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 1351)))
@@ -1032,13 +1032,13 @@ void Menu::updateDeleteGame() {
else
getText()->loadFont(kFontBlue);
- getText()->setPosition(369, 273);
+ getText()->setPosition(Common::Point(369, 273));
getText()->draw(MAKE_RESOURCE(kResourcePackText, 1351));
return;
}
getText()->loadFont(kFontYellow);
- getText()->drawCentered(10, 100, 620, MAKE_RESOURCE(kResourcePackText, 1345));
+ getText()->drawCentered(Common::Point(10, 100), 620, MAKE_RESOURCE(kResourcePackText, 1345));
//////////////////////////////////////////////////////////////////////////
// First column
@@ -1055,7 +1055,7 @@ void Menu::updateDeleteGame() {
else
getText()->loadFont(kFontBlue);
- getText()->setPosition(30, y);
+ getText()->setPosition(Common::Point(30, y));
getText()->draw((char *)&text);
++index;
@@ -1075,7 +1075,7 @@ void Menu::updateDeleteGame() {
else
getText()->loadFont(kFontBlue);
- getText()->setPosition(350, y);
+ getText()->setPosition(Common::Point(350, y));
getText()->draw((char *)&text);
++index;
@@ -1089,7 +1089,7 @@ void Menu::updateDeleteGame() {
else
getText()->loadFont(kFontBlue);
- getText()->setPosition(30, 340);
+ getText()->setPosition(Common::Point(30, 340));
getText()->draw(MAKE_RESOURCE(kResourcePackText, 1346));
//////////////////////////////////////////////////////////////////////////
@@ -1100,7 +1100,7 @@ void Menu::updateDeleteGame() {
else
getText()->loadFont(kFontBlue);
- getText()->setPosition(300, 340);
+ getText()->setPosition(Common::Point(300, 340));
getText()->draw(MAKE_RESOURCE(kResourcePackText, 1348));
//////////////////////////////////////////////////////////////////////////
@@ -1111,7 +1111,7 @@ void Menu::updateDeleteGame() {
else
getText()->loadFont(kFontBlue);
- getText()->setPosition(550, 347);
+ getText()->setPosition(Common::Point(550, 347));
getText()->draw(MAKE_RESOURCE(kResourcePackText, 1347));
}
@@ -1124,7 +1124,7 @@ void Menu::updateViewMovies() {
if (!_dword_455C78) {
getText()->loadFont(kFontYellow);
sprintf((char *)&text2, getText()->get(MAKE_RESOURCE(kResourcePackText, 1352)), getSharedData()->cdNumber);
- getText()->drawCentered(10, 100, 620, (char *)&text2);
+ getText()->drawCentered(Common::Point(10, 100), 620, (char *)&text2);
//////////////////////////////////////////////////////////////////////////
// First column
@@ -1145,7 +1145,7 @@ void Menu::updateViewMovies() {
else
getText()->loadFont(kFontBlue);
- getText()->setPosition(30, y);
+ getText()->setPosition(Common::Point(30, y));
getText()->draw((char *)&text);
}
@@ -1170,7 +1170,7 @@ void Menu::updateViewMovies() {
else
getText()->loadFont(kFontBlue);
- getText()->setPosition(350, y);
+ getText()->setPosition(Common::Point(350, y));
getText()->draw((char *)&text);
}
@@ -1186,7 +1186,7 @@ void Menu::updateViewMovies() {
else
getText()->loadFont(kFontBlue);
- getText()->setPosition(30, 340);
+ getText()->setPosition(Common::Point(30, 340));
getText()->draw(MAKE_RESOURCE(kResourcePackText, 1353));
//////////////////////////////////////////////////////////////////////////
@@ -1198,7 +1198,7 @@ void Menu::updateViewMovies() {
else
getText()->loadFont(kFontBlue);
- getText()->setPosition(300, 340);
+ getText()->setPosition(Common::Point(300, 340));
getText()->draw(MAKE_RESOURCE(kResourcePackText, 1355));
//////////////////////////////////////////////////////////////////////////
@@ -1210,7 +1210,7 @@ void Menu::updateViewMovies() {
else
getText()->loadFont(kFontBlue);
- getText()->setPosition(550, 340);
+ getText()->setPosition(Common::Point(550, 340));
getText()->draw(MAKE_RESOURCE(kResourcePackText, 1354));
//////////////////////////////////////////////////////////////////////////
@@ -1228,14 +1228,14 @@ void Menu::updateViewMovies() {
getText()->loadFont(kFontYellow);
sprintf((char *)&text2, getText()->get(MAKE_RESOURCE(kResourcePackText, 1357)), getSharedData()->cdNumber);
- getText()->drawCentered(10, 100, 620, text2);
+ getText()->drawCentered(Common::Point(10, 100), 620, text2);
strcpy((char *)&text, getText()->get(MAKE_RESOURCE(kResourcePackText, 1359 + _movieIndex)));
sprintf((char *)&text2, getText()->get(MAKE_RESOURCE(kResourcePackText, 1356)), moviesCd[_movieIndex]);
strcat((char *)&text, (char *)&text2);
- getText()->drawCentered(10, 134, 620, text);
+ getText()->drawCentered(Common::Point(10, 134), 620, text);
- getText()->drawCentered(10, 168, 620, getText()->get(MAKE_RESOURCE(kResourcePackText, 1358)));
+ getText()->drawCentered(Common::Point(10, 168), 620, getText()->get(MAKE_RESOURCE(kResourcePackText, 1358)));
++_dword_456288;
if (_dword_456288 == 90) {
@@ -1250,16 +1250,16 @@ void Menu::updateQuitGame() {
Common::Point cursor = getCursor()->position();
getText()->loadFont(kFontYellow);
- getText()->drawCentered(10, 100, 620, MAKE_RESOURCE(kResourcePackText, 1408));
+ getText()->drawCentered(Common::Point(10, 100), 620, MAKE_RESOURCE(kResourcePackText, 1408));
// Yes
switchFont(cursor.x < 247 || cursor.x > (247 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 1409))) || cursor.y < 273 || cursor.y > (273 + 24));
- getText()->setPosition(247, 273);
+ getText()->setPosition(Common::Point(247, 273));
getText()->draw(MAKE_RESOURCE(kResourcePackText, 1409));
// No
switchFont(cursor.x < 369 || cursor.x > (369 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 1410))) || cursor.y < 273 || cursor.y > (273 + 24));
- getText()->setPosition(369, 273);
+ getText()->setPosition(Common::Point(369, 273));
getText()->draw(MAKE_RESOURCE(kResourcePackText, 1410));
}
@@ -1267,23 +1267,23 @@ void Menu::updateTextOptions() {
Common::Point cursor = getCursor()->position();
getText()->loadFont(kFontYellow);
- getText()->drawCentered(10, 100, 620, MAKE_RESOURCE(kResourcePackText, 1411));
+ getText()->drawCentered(Common::Point(10, 100), 620, MAKE_RESOURCE(kResourcePackText, 1411));
- getText()->draw(320, 150, MAKE_RESOURCE(kResourcePackText, 1412));
+ getText()->draw(Common::Point(320, 150), MAKE_RESOURCE(kResourcePackText, 1412));
switchFont(cursor.x < 350 || cursor.x > (350 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, Config.showMovieSubtitles ? 1414 : 1415))) || cursor.y < 150 || cursor.y > 174);
- getText()->setPosition(350, 150);
+ getText()->setPosition(Common::Point(350, 150));
getText()->draw(MAKE_RESOURCE(kResourcePackText, Config.showMovieSubtitles ? 1414 : 1415));
getText()->loadFont(kFontYellow);
- getText()->draw(320, 179, MAKE_RESOURCE(kResourcePackText, 1413));
+ getText()->draw(Common::Point(320, 179), MAKE_RESOURCE(kResourcePackText, 1413));
switchFont(cursor.x < 350 || cursor.x > (350 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, Config.showEncounterSubtitles ? 1414 : 1415))) || cursor.y < 179 || cursor.y > 203);
- getText()->setPosition(350, 179);
+ getText()->setPosition(Common::Point(350, 179));
getText()->draw(MAKE_RESOURCE(kResourcePackText, Config.showEncounterSubtitles ? 1414 : 1415));
switchFont(cursor.x < 300 || cursor.x > (300 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 1416))) || cursor.y < 340 || cursor.y > (340 + 24));
- getText()->setPosition(300, 340);
+ getText()->setPosition(Common::Point(300, 340));
getText()->draw(MAKE_RESOURCE(kResourcePackText, 1416));
}
@@ -1295,20 +1295,20 @@ void Menu::updateAudioOptions() {
int32 sizePlus = getText()->getWidth("+");
getText()->loadFont(kFontYellow);
- getText()->drawCentered(10, 100, 620, MAKE_RESOURCE(kResourcePackText, 1420));
+ getText()->drawCentered(Common::Point(10, 100), 620, MAKE_RESOURCE(kResourcePackText, 1420));
int32 volumeIndex = 0;
int32 volumeValue = cursor.x;
do {
getText()->loadFont(kFontYellow);
- getText()->draw(320, 29 * volumeIndex + 150, MAKE_RESOURCE(kResourcePackText, 1421 + volumeIndex));
+ getText()->draw(Common::Point(320, 29 * volumeIndex + 150), MAKE_RESOURCE(kResourcePackText, 1421 + volumeIndex));
switchFont(cursor.x < 350 || cursor.x > (sizeMinus + 350) || cursor.y < (29 * volumeIndex + 150) || cursor.y > (29 * (volumeIndex + 6)));
- getText()->setPosition(350, 29 * volumeIndex + 150);
+ getText()->setPosition(Common::Point(350, 29 * volumeIndex + 150));
getText()->draw("-");
switchFont(cursor.x < (sizeMinus + 360) || cursor.x > (sizeMinus + sizePlus + 360) || cursor.y < (29 * volumeIndex + 150) || cursor.y > (29 * (volumeIndex + 6)));
- getText()->setPosition(sizeMinus + 360, 29 * volumeIndex + 150);
+ getText()->setPosition(Common::Point(sizeMinus + 360, 29 * volumeIndex + 150));
getText()->draw("+");
switch(volumeIndex) {
@@ -1341,7 +1341,7 @@ void Menu::updateAudioOptions() {
}
getText()->loadFont(kFontYellow);
- getText()->setPosition(sizePlus + sizeMinus + 365, 29 * volumeIndex + 150);
+ getText()->setPosition(Common::Point(sizePlus + sizeMinus + 365, 29 * volumeIndex + 150));
if (volumeValue > 0) {
for (int32 i = 0; i < volumeValue; i++)
getText()->drawChar(']');
@@ -1358,18 +1358,18 @@ void Menu::updateAudioOptions() {
//////////////////////////////////////////////////////////////////////////
//
getText()->loadFont(kFontYellow);
- getText()->draw(320, 29 *volumeIndex + 150, MAKE_RESOURCE(kResourcePackText, 1427));
+ getText()->draw(Common::Point(320, 29 *volumeIndex + 150), MAKE_RESOURCE(kResourcePackText, 1427));
switchFont(cursor.x < 350 || cursor.x > (350 + getText()->getWidth(Config.reverseStereo ? MAKE_RESOURCE(kResourcePackText, 1428) : MAKE_RESOURCE(kResourcePackText, 1429))) || cursor.y < (29 * volumeIndex + 150) || cursor.y > (29 * (volumeIndex + 6)));
- getText()->setPosition(350, 29 * volumeIndex + 150);
+ getText()->setPosition(Common::Point(350, 29 * volumeIndex + 150));
getText()->draw(Config.reverseStereo ? MAKE_RESOURCE(kResourcePackText, 1428) : MAKE_RESOURCE(kResourcePackText, 1429));
switchFont(cursor.x < 220 || cursor.x > (220 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 1430))) || cursor.y < 360 || cursor.y > (360 + 24));
- getText()->setPosition(220, 360);
+ getText()->setPosition(Common::Point(220, 360));
getText()->draw(MAKE_RESOURCE(kResourcePackText, 1430));
switchFont((cursor.x < 360 || cursor.x > (360 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 1431))) || cursor.y < 360 || cursor.y > (360 + 24)) && !_testSoundsPlaying);
- getText()->setPosition(360, 360);
+ getText()->setPosition(Common::Point(360, 360));
getText()->draw(MAKE_RESOURCE(kResourcePackText, 1431));
}
@@ -1383,21 +1383,21 @@ void Menu::updateSettings() {
getText()->loadFont(kFontYellow);
// Settings
- getText()->drawCentered(10, 100, 620, MAKE_RESOURCE(kResourcePackText, 1432));
+ getText()->drawCentered(Common::Point(10, 100), 620, MAKE_RESOURCE(kResourcePackText, 1432));
//////////////////////////////////////////////////////////////////////////
// Gamma correction
- getText()->draw(320, 150, MAKE_RESOURCE(kResourcePackText, 1433));
+ getText()->draw(Common::Point(320, 150), MAKE_RESOURCE(kResourcePackText, 1433));
switchFont(cursor.x < 350 || cursor.x > (sizeMinus + 350) || cursor.y < 150 || cursor.y > 174);
- getText()->setPosition(350, 150);
+ getText()->setPosition(Common::Point(350, 150));
getText()->draw("-");
switchFont(cursor.x < (sizeMinus + 360) || cursor.x > (sizeMinus + sizePlus + 360) || cursor.y < 150 || cursor.y > 174);
- getText()->setPosition(sizeMinus + 360, 150);
+ getText()->setPosition(Common::Point(sizeMinus + 360, 150));
getText()->draw("+");
- getText()->setPosition(sizeMinus + sizePlus + 365, 150);
+ getText()->setPosition(Common::Point(sizeMinus + sizePlus + 365, 150));
getText()->loadFont(kFontYellow);
if (Config.gammaLevel) {
for (int32 i = 0; i < Config.gammaLevel; i++)
@@ -1412,17 +1412,17 @@ void Menu::updateSettings() {
//////////////////////////////////////////////////////////////////////////
// Performance
getText()->loadFont(kFontYellow);
- getText()->draw(320, 179, MAKE_RESOURCE(kResourcePackText, 1434));
+ getText()->draw(Common::Point(320, 179), MAKE_RESOURCE(kResourcePackText, 1434));
switchFont(cursor.x < 350 || cursor.x > (sizeMinus + 350) || cursor.y < 179 || cursor.y > 203);
- getText()->setPosition(350, 179);
+ getText()->setPosition(Common::Point(350, 179));
getText()->draw("-");
switchFont(cursor.x < (sizeMinus + 360) || cursor.x > (sizeMinus + sizePlus + 360) || cursor.y < 179 || cursor.y > 203);
- getText()->setPosition(sizeMinus + 360, 179);
+ getText()->setPosition(Common::Point(sizeMinus + 360, 179));
getText()->draw("+");
- getText()->setPosition(sizeMinus + sizePlus + 365, 179);
+ getText()->setPosition(Common::Point(sizeMinus + sizePlus + 365, 179));
getText()->loadFont(kFontYellow);
if (Config.performance == 5) {
getText()->draw(MAKE_RESOURCE(kResourcePackText, 1436));
@@ -1437,7 +1437,7 @@ void Menu::updateSettings() {
//////////////////////////////////////////////////////////////////////////
// Back to main menu
switchFont(cursor.x < 300 || cursor.x > (300 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 1437))) || cursor.y < 340 || cursor.y > (340 + 24));
- getText()->setPosition(300, 340);
+ getText()->setPosition(Common::Point(300, 340));
getText()->draw(MAKE_RESOURCE(kResourcePackText, 1437));
}
@@ -1445,7 +1445,7 @@ void Menu::updateKeyboardConfig() {
Common::Point cursor = getCursor()->position();
getText()->loadFont(kFontYellow);
- getText()->drawCentered(10, 100, 620, MAKE_RESOURCE(kResourcePackText, 1438));
+ getText()->drawCentered(Common::Point(10, 100), 620, MAKE_RESOURCE(kResourcePackText, 1438));
char keyCode = 0;
int32 keyIndex = 0;
@@ -1453,9 +1453,9 @@ void Menu::updateKeyboardConfig() {
do {
getText()->loadFont(kFontYellow);
if ((getScene() && getWorld()->chapter == 9) || keyIndex < 3) {
- getText()->draw(320, 29 * keyIndex + 150, MAKE_RESOURCE(kResourcePackText, 1439 + keyIndex));
+ getText()->draw(Common::Point(320, 29 * keyIndex + 150), MAKE_RESOURCE(kResourcePackText, 1439 + keyIndex));
} else {
- getText()->draw(320, 29 * keyIndex + 150, MAKE_RESOURCE(kResourcePackText, 1445));
+ getText()->draw(Common::Point(320, 29 * keyIndex + 150), MAKE_RESOURCE(kResourcePackText, 1445));
}
switch (keyIndex) {
@@ -1487,7 +1487,7 @@ void Menu::updateKeyboardConfig() {
break;
}
- getText()->setPosition(350, 29 * keyIndex + 150);
+ getText()->setPosition(Common::Point(350, 29 * keyIndex + 150));
if (keyIndex == _selectedShortcutIndex) {
getText()->loadFont(kFontBlue);
@@ -1505,7 +1505,7 @@ void Menu::updateKeyboardConfig() {
} while (keyIndex < 6);
switchFont(getCursor()->isHidden() || cursor.x < 300 || cursor.x > (300 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 1446))) || cursor.y < 340 || cursor.y > (340 + 24));
- getText()->setPosition(340, 340);
+ getText()->setPosition(Common::Point(340, 340));
getText()->draw(MAKE_RESOURCE(kResourcePackText, 1446));
}
@@ -1515,11 +1515,11 @@ void Menu::updateReturnToGame() {
getText()->loadFont(kFontYellow);
// No game loaded
- getText()->drawCentered(10, 100, 620, MAKE_RESOURCE(kResourcePackText, 1810));
+ getText()->drawCentered(Common::Point(10, 100), 620, MAKE_RESOURCE(kResourcePackText, 1810));
// Main Menu
switchFont(cursor.x < 285 || cursor.x > (285 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 1811))) || cursor.y < 273 || cursor.y > (273 + 24));
- getText()->setPosition(285, 273);
+ getText()->setPosition(Common::Point(285, 273));
getText()->draw(MAKE_RESOURCE(kResourcePackText, 1811));
}
@@ -1550,7 +1550,7 @@ void Menu::updateShowCredits() {
if (maxBound < 480 && maxBound > 448)
getText()->setTransTableNum(3 - (479 - maxBound) / 8);
- getText()->setPosition(320, step + _startIndex);
+ getText()->setPosition(Common::Point(320, step + _startIndex));
getText()->draw(MAKE_RESOURCE(kResourcePackText, 1447 + index));
getText()->setTransTableNum(0);
}
diff --git a/engines/asylum/views/scenetitle.cpp b/engines/asylum/views/scenetitle.cpp
index 464040b651..03b545503f 100644
--- a/engines/asylum/views/scenetitle.cpp
+++ b/engines/asylum/views/scenetitle.cpp
@@ -69,7 +69,7 @@ void SceneTitle::update(int32 tick) {
getScreen()->draw(getWorld()->sceneTitleGraphicResourceId);
getScreen()->draw(MAKE_RESOURCE(kResourcePackSound, 17), _spinnerFrameIndex, Common::Point((_spinnerProgress / 590.0 * 580) - 290 , 0), kDrawFlagNone, false);
- getText()->drawCentered(320, 30, 24, MAKE_RESOURCE(kResourcePackText, 1811 + getWorld()->chapter));
+ getText()->drawCentered(Common::Point(320, 30), 24, MAKE_RESOURCE(kResourcePackText, 1811 + getWorld()->chapter));
// This is not from the original. It's just some arbitrary math to throttle the progress indicator.
//
diff --git a/engines/asylum/views/video.cpp b/engines/asylum/views/video.cpp
index c1662d85f5..0259692e3c 100644
--- a/engines/asylum/views/video.cpp
+++ b/engines/asylum/views/video.cpp
@@ -81,12 +81,12 @@ bool VideoPlayer::handleEvent(const AsylumEvent &evt) {
if (_subtitleIndex >= 0) {
char *text1 = getText()->get((ResourceId)_currentMovie);
- int32 y = 10 * (44 - getText()->draw(0, 99, kTextCalculate, 10, 400, 20, 620, text1));
+ int32 y = 10 * (44 - getText()->draw(0, 99, kTextCalculate, Common::Point(10, 400), 20, 620, text1));
if (y <= 400)
y = 405;
char *text = getText()->get(_subtitles[_subtitleIndex].resourceId);
- getText()->draw(0, 99, kTextCenter, 10, y, 20, 620, text);
+ getText()->draw(0, 99, kTextCenter, Common::Point(10, y), 20, 620, text);
}
--_subtitleCounter;
Commit: 0f14a09cd41f0f365fb75fe4c0f505d6697cf2ba
https://github.com/scummvm/scummvm/commit/0f14a09cd41f0f365fb75fe4c0f505d6697cf2ba
Author: Littleboy (littleboy at scummvm.org)
Date: 2021-05-17T15:37:14+02:00
Commit Message:
ASYLUM: Remove useless includes
Changed paths:
engines/asylum/asylum.cpp
engines/asylum/detection.cpp
engines/asylum/puzzles/board.cpp
engines/asylum/puzzles/vcr.cpp
engines/asylum/resources/actor.cpp
engines/asylum/resources/encounters.cpp
engines/asylum/resources/encounters.h
engines/asylum/resources/reaction.cpp
engines/asylum/resources/script.cpp
engines/asylum/system/cursor.cpp
engines/asylum/system/graphics.cpp
engines/asylum/system/savegame.cpp
engines/asylum/system/speech.cpp
engines/asylum/views/menu.cpp
engines/asylum/views/scene.cpp
diff --git a/engines/asylum/asylum.cpp b/engines/asylum/asylum.cpp
index 3baf2fc983..d2e963f2d8 100644
--- a/engines/asylum/asylum.cpp
+++ b/engines/asylum/asylum.cpp
@@ -46,11 +46,9 @@
#include "asylum/puzzles/wheel.h"
#include "asylum/puzzles/writings.h"
-#include "asylum/system/config.h"
#include "asylum/system/cursor.h"
#include "asylum/system/savegame.h"
#include "asylum/system/screen.h"
-#include "asylum/system/sound.h"
#include "asylum/system/speech.h"
#include "asylum/system/text.h"
@@ -58,12 +56,9 @@
#include "asylum/views/menu.h"
#include "asylum/views/video.h"
-#include "asylum/console.h"
#include "asylum/respack.h"
-#include "common/config-manager.h"
#include "common/debug-channels.h"
-#include "common/events.h"
#include "common/EventRecorder.h"
#include "engines/util.h"
diff --git a/engines/asylum/detection.cpp b/engines/asylum/detection.cpp
index bf80aafbf3..1241bfabc4 100644
--- a/engines/asylum/detection.cpp
+++ b/engines/asylum/detection.cpp
@@ -25,8 +25,6 @@
#include "common/savefile.h"
#include "common/system.h"
-#include "base/plugins.h"
-
#include "asylum/asylum.h"
static const PlainGameDescriptor asylumGames[] = {
diff --git a/engines/asylum/puzzles/board.cpp b/engines/asylum/puzzles/board.cpp
index 3d77dc4d06..d29f058983 100644
--- a/engines/asylum/puzzles/board.cpp
+++ b/engines/asylum/puzzles/board.cpp
@@ -26,7 +26,6 @@
#include "asylum/system/cursor.h"
#include "asylum/system/screen.h"
-#include "asylum/system/sound.h"
#include "asylum/system/text.h"
#include "asylum/views/scene.h"
diff --git a/engines/asylum/puzzles/vcr.cpp b/engines/asylum/puzzles/vcr.cpp
index 9ac731c0e6..325b6a2a9f 100644
--- a/engines/asylum/puzzles/vcr.cpp
+++ b/engines/asylum/puzzles/vcr.cpp
@@ -24,7 +24,6 @@
#include "asylum/resources/worldstats.h"
-#include "asylum/system/config.h"
#include "asylum/system/cursor.h"
#include "asylum/system/graphics.h"
#include "asylum/system/screen.h"
@@ -34,7 +33,6 @@
#include "asylum/asylum.h"
#include "asylum/respack.h"
-#include "asylum/shared.h"
namespace Asylum {
diff --git a/engines/asylum/resources/actor.cpp b/engines/asylum/resources/actor.cpp
index ef0b17ec03..186c978116 100644
--- a/engines/asylum/resources/actor.cpp
+++ b/engines/asylum/resources/actor.cpp
@@ -30,7 +30,6 @@
#include "asylum/resources/script.h"
#include "asylum/resources/worldstats.h"
-#include "asylum/system/config.h"
#include "asylum/system/cursor.h"
#include "asylum/system/graphics.h"
#include "asylum/system/screen.h"
@@ -42,7 +41,6 @@
#include "asylum/asylum.h"
#include "asylum/staticres.h"
-#include "common/endian.h"
namespace Asylum {
diff --git a/engines/asylum/resources/encounters.cpp b/engines/asylum/resources/encounters.cpp
index 3d43e94824..5cc346fc0c 100644
--- a/engines/asylum/resources/encounters.cpp
+++ b/engines/asylum/resources/encounters.cpp
@@ -40,8 +40,6 @@
#include "asylum/respack.h"
#include "asylum/staticres.h"
-#include "common/file.h"
-
namespace Asylum {
#define KEYWORD_MASK 0xFFF
diff --git a/engines/asylum/resources/encounters.h b/engines/asylum/resources/encounters.h
index 5101ee754a..4b08e2c935 100644
--- a/engines/asylum/resources/encounters.h
+++ b/engines/asylum/resources/encounters.h
@@ -23,7 +23,6 @@
#ifndef ASYLUM_ENCOUNTERS_H
#define ASYLUM_ENCOUNTERS_H
-#include "asylum/asylum.h"
#include "asylum/eventhandler.h"
#include "asylum/shared.h"
diff --git a/engines/asylum/resources/reaction.cpp b/engines/asylum/resources/reaction.cpp
index c0de9f9d61..7930fdfcba 100644
--- a/engines/asylum/resources/reaction.cpp
+++ b/engines/asylum/resources/reaction.cpp
@@ -25,13 +25,11 @@
#include "asylum/resources/actor.h"
#include "asylum/resources/worldstats.h"
-#include "asylum/system/sound.h"
#include "asylum/system/speech.h"
#include "asylum/views/scene.h"
#include "asylum/asylum.h"
-#include "asylum/shared.h"
namespace Asylum {
diff --git a/engines/asylum/resources/script.cpp b/engines/asylum/resources/script.cpp
index cb62f73a7e..84730a8e03 100644
--- a/engines/asylum/resources/script.cpp
+++ b/engines/asylum/resources/script.cpp
@@ -27,7 +27,6 @@
#include "asylum/resources/object.h"
#include "asylum/resources/worldstats.h"
-#include "asylum/system/config.h"
#include "asylum/system/cursor.h"
#include "asylum/system/graphics.h"
#include "asylum/system/screen.h"
@@ -39,8 +38,6 @@
#include "asylum/asylum.h"
#include "asylum/staticres.h"
-#include "common/rational.h"
-
namespace Asylum {
//////////////////////////////////////////////////////////////////////////
diff --git a/engines/asylum/system/cursor.cpp b/engines/asylum/system/cursor.cpp
index 1be8cb58a3..eea1aa6438 100644
--- a/engines/asylum/system/cursor.cpp
+++ b/engines/asylum/system/cursor.cpp
@@ -26,8 +26,6 @@
#include "asylum/asylum.h"
-#include "common/events.h"
-#include "common/system.h"
#include "graphics/cursorman.h"
namespace Asylum {
diff --git a/engines/asylum/system/graphics.cpp b/engines/asylum/system/graphics.cpp
index 3df2110c9d..c750890012 100644
--- a/engines/asylum/system/graphics.cpp
+++ b/engines/asylum/system/graphics.cpp
@@ -25,8 +25,6 @@
#include "asylum/asylum.h"
#include "asylum/respack.h"
-#include "common/endian.h"
-
namespace Asylum {
GraphicResource::GraphicResource(AsylumEngine *engine) : _vm(engine), _resourceId(kResourceNone) {
diff --git a/engines/asylum/system/savegame.cpp b/engines/asylum/system/savegame.cpp
index c2cd810bce..095d8accbd 100644
--- a/engines/asylum/system/savegame.cpp
+++ b/engines/asylum/system/savegame.cpp
@@ -30,7 +30,6 @@
#include "asylum/system/cursor.h"
#include "asylum/system/screen.h"
-#include "asylum/system/sound.h"
#include "asylum/system/text.h"
#include "asylum/views/menu.h"
diff --git a/engines/asylum/system/speech.cpp b/engines/asylum/system/speech.cpp
index d4d7e4ebad..e5d9baecfe 100644
--- a/engines/asylum/system/speech.cpp
+++ b/engines/asylum/system/speech.cpp
@@ -25,7 +25,6 @@
#include "asylum/resources/actor.h"
#include "asylum/resources/worldstats.h"
-#include "asylum/system/config.h"
#include "asylum/system/text.h"
#include "asylum/views/scene.h"
diff --git a/engines/asylum/views/menu.cpp b/engines/asylum/views/menu.cpp
index 98c77c7ea9..23457c3ce2 100644
--- a/engines/asylum/views/menu.cpp
+++ b/engines/asylum/views/menu.cpp
@@ -25,12 +25,10 @@
#include "asylum/resources/actor.h"
#include "asylum/resources/worldstats.h"
-#include "asylum/system/config.h"
#include "asylum/system/cursor.h"
#include "asylum/system/graphics.h"
#include "asylum/system/savegame.h"
#include "asylum/system/screen.h"
-#include "asylum/system/sound.h"
#include "asylum/system/text.h"
#include "asylum/views/scene.h"
diff --git a/engines/asylum/views/scene.cpp b/engines/asylum/views/scene.cpp
index 4f283299b1..eca7a8b649 100644
--- a/engines/asylum/views/scene.cpp
+++ b/engines/asylum/views/scene.cpp
@@ -30,7 +30,6 @@
#include "asylum/resources/special.h"
#include "asylum/resources/worldstats.h"
-#include "asylum/system/config.h"
#include "asylum/system/cursor.h"
#include "asylum/system/graphics.h"
#include "asylum/system/savegame.h"
@@ -45,8 +44,6 @@
#include "asylum/respack.h"
#include "asylum/staticres.h"
-#include "common/file.h"
-
namespace Asylum {
#define SCREEN_EDGES 40
Commit: b9cb91d01601e7fe12c1e4fe1a6237e1d7593fcf
https://github.com/scummvm/scummvm/commit/b9cb91d01601e7fe12c1e4fe1a6237e1d7593fcf
Author: Littleboy (littleboy at scummvm.org)
Date: 2021-05-17T15:37:15+02:00
Commit Message:
ASYLUM: Cleanup puzzles
- Add missing casts
- Remove unused parameters
- Add consts modifiers
- Fix formating
- etc.
Changed paths:
engines/asylum/puzzles/board.cpp
engines/asylum/puzzles/board.h
engines/asylum/puzzles/boardkeyhidesto.cpp
engines/asylum/puzzles/boardsalvation.cpp
engines/asylum/puzzles/boardyouth.cpp
engines/asylum/puzzles/clock.cpp
engines/asylum/puzzles/fisherman.cpp
engines/asylum/puzzles/hivecontrol.cpp
engines/asylum/puzzles/hivecontrol.h
engines/asylum/puzzles/hivemachine.cpp
engines/asylum/puzzles/lock.cpp
engines/asylum/puzzles/morguedoor.cpp
engines/asylum/puzzles/morguedoor.h
engines/asylum/puzzles/pipes.cpp
engines/asylum/puzzles/pipes.h
engines/asylum/puzzles/puzzle.cpp
engines/asylum/puzzles/puzzle.h
engines/asylum/puzzles/puzzle11.cpp
engines/asylum/puzzles/tictactoe.cpp
engines/asylum/puzzles/tictactoe.h
engines/asylum/puzzles/timemachine.cpp
engines/asylum/puzzles/vcr.cpp
engines/asylum/puzzles/vcr.h
engines/asylum/puzzles/wheel.cpp
engines/asylum/puzzles/writings.cpp
diff --git a/engines/asylum/puzzles/board.cpp b/engines/asylum/puzzles/board.cpp
index d29f058983..512cc89b48 100644
--- a/engines/asylum/puzzles/board.cpp
+++ b/engines/asylum/puzzles/board.cpp
@@ -34,11 +34,7 @@
namespace Asylum {
-PuzzleBoard::PuzzleBoard(AsylumEngine *engine) : Puzzle(engine) {
- error("[PuzzleBoard::PuzzleBoard] No puzzle data!");
-}
-
-PuzzleBoard::PuzzleBoard(AsylumEngine *engine, PuzzleData data) : Puzzle(engine) {
+PuzzleBoard::PuzzleBoard(AsylumEngine *engine, const PuzzleData &data) : Puzzle(engine) {
_data = data;
// Init board
@@ -58,7 +54,7 @@ void PuzzleBoard::reset() {
//////////////////////////////////////////////////////////////////////////
// Event Handling
//////////////////////////////////////////////////////////////////////////
-bool PuzzleBoard::init(const AsylumEvent &evt) {
+bool PuzzleBoard::init(const AsylumEvent &) {
_rectIndex = -2;
_selectedSlot = -1;
_solved = false;
@@ -96,7 +92,7 @@ bool PuzzleBoard::updateScreen() {
return true;
}
-bool PuzzleBoard::update(const AsylumEvent &evt) {
+bool PuzzleBoard::update(const AsylumEvent &) {
updateCursor();
if (!_solved)
@@ -124,7 +120,7 @@ bool PuzzleBoard::update(const AsylumEvent &evt) {
return true;
}
-bool PuzzleBoard::mouseRightDown(const AsylumEvent &evt) {
+bool PuzzleBoard::mouseRightDown(const AsylumEvent &) {
if (!stopSound()) {
getScreen()->clear();
_vm->switchEventHandler(getScene());
@@ -151,7 +147,7 @@ void PuzzleBoard::drawText() {
getText()->draw(0, 99, kTextCenter, Common::Point(25, 50), 16, 590, _text.c_str());
int32 index = 0;
- for (uint32 x = 215; x < _data.maxWidth; x += 24) {
+ for (int16 x = 215; x < (int16)_data.maxWidth; x += 24) {
if (!_solvedText[index])
break;
@@ -163,7 +159,7 @@ void PuzzleBoard::drawText() {
}
void PuzzleBoard::playSound() {
- uint32 index = 0;
+ uint32 index;
for (index = 0; index < _data.soundResourceSize; index++) {
if (!_data.soundResources[index].played)
break;
@@ -196,9 +192,9 @@ int32 PuzzleBoard::checkMouse() {
Common::Point mousePos = getCursor()->position();
if (mousePos.x >= 215 && mousePos.x < (int16)_data.maxWidth && mousePos.y >= 360 && mousePos.y < 376) {
- uint32 index = (mousePos.x - 215) / 12;
+ int16 index = (mousePos.x - 215) / 12;
- if (index >= ARRAYSIZE(_solvedText))
+ if (index < 0 || index >= ARRAYSIZE(_solvedText))
return -1;
if (_solvedText[index] != 0) {
diff --git a/engines/asylum/puzzles/board.h b/engines/asylum/puzzles/board.h
index 738bd27a7e..cfd8d8ecae 100644
--- a/engines/asylum/puzzles/board.h
+++ b/engines/asylum/puzzles/board.h
@@ -55,8 +55,7 @@ public:
char solvedText[28];
};
- PuzzleBoard(AsylumEngine *engine);
- PuzzleBoard(AsylumEngine *engine, PuzzleData data);
+ PuzzleBoard(AsylumEngine *engine, const PuzzleData &data);
void reset();
diff --git a/engines/asylum/puzzles/boardkeyhidesto.cpp b/engines/asylum/puzzles/boardkeyhidesto.cpp
index d4df7db57d..84af8a5c6e 100644
--- a/engines/asylum/puzzles/boardkeyhidesto.cpp
+++ b/engines/asylum/puzzles/boardkeyhidesto.cpp
@@ -55,7 +55,7 @@ PuzzleBoardKeyHidesTo::PuzzleBoardKeyHidesTo(AsylumEngine *engine) : PuzzleBoard
//////////////////////////////////////////////////////////////////////////
// Event Handling
//////////////////////////////////////////////////////////////////////////
-bool PuzzleBoardKeyHidesTo::mouseLeftDown(const AsylumEvent &evt) {
+bool PuzzleBoardKeyHidesTo::mouseLeftDown(const AsylumEvent &) {
Common::Point mousePos = getCursor()->position();
if (mousePos.y <= 350) {
diff --git a/engines/asylum/puzzles/boardsalvation.cpp b/engines/asylum/puzzles/boardsalvation.cpp
index 72714c85f8..8543b976f0 100644
--- a/engines/asylum/puzzles/boardsalvation.cpp
+++ b/engines/asylum/puzzles/boardsalvation.cpp
@@ -60,7 +60,7 @@ PuzzleBoardSalvation::PuzzleBoardSalvation(AsylumEngine *engine) : PuzzleBoard(e
//////////////////////////////////////////////////////////////////////////
// Event Handling
//////////////////////////////////////////////////////////////////////////
-bool PuzzleBoardSalvation::mouseLeftDown(const AsylumEvent &evt) {
+bool PuzzleBoardSalvation::mouseLeftDown(const AsylumEvent &) {
Common::Point mousePos = getCursor()->position();
if (mousePos.y <= 350) {
@@ -82,7 +82,7 @@ bool PuzzleBoardSalvation::mouseLeftDown(const AsylumEvent &evt) {
return true;
}
-bool PuzzleBoardSalvation::mouseRightDown(const AsylumEvent &evt) {
+bool PuzzleBoardSalvation::mouseRightDown(const AsylumEvent &) {
if (!stopSound()) {
checkANALText();
getScreen()->clear();
diff --git a/engines/asylum/puzzles/boardyouth.cpp b/engines/asylum/puzzles/boardyouth.cpp
index 8ce5de53b8..6eca9effd6 100644
--- a/engines/asylum/puzzles/boardyouth.cpp
+++ b/engines/asylum/puzzles/boardyouth.cpp
@@ -53,7 +53,7 @@ PuzzleBoardYouth::PuzzleBoardYouth(AsylumEngine *engine) : PuzzleBoard(engine, p
//////////////////////////////////////////////////////////////////////////
// Event Handling
//////////////////////////////////////////////////////////////////////////
-bool PuzzleBoardYouth::mouseLeftDown(const AsylumEvent &evt) {
+bool PuzzleBoardYouth::mouseLeftDown(const AsylumEvent &) {
Common::Point mousePos = getCursor()->position();
if (mousePos.y <= 350) {
diff --git a/engines/asylum/puzzles/clock.cpp b/engines/asylum/puzzles/clock.cpp
index e7d2824e9a..35a9fbd1bb 100644
--- a/engines/asylum/puzzles/clock.cpp
+++ b/engines/asylum/puzzles/clock.cpp
@@ -75,7 +75,7 @@ PuzzleClock::~PuzzleClock() {
//////////////////////////////////////////////////////////////////////////
// Event Handling
//////////////////////////////////////////////////////////////////////////
-bool PuzzleClock::init(const AsylumEvent &evt) {
+bool PuzzleClock::init(const AsylumEvent &) {
_currentRect = -2;
updateCursor();
@@ -131,7 +131,7 @@ bool PuzzleClock::update(const AsylumEvent &evt) {
return true;
}
-bool PuzzleClock::mouseLeftDown(const AsylumEvent &evt) {
+bool PuzzleClock::mouseLeftDown(const AsylumEvent &) {
int32 index = findRect();
if (index == -1)
@@ -147,7 +147,7 @@ bool PuzzleClock::mouseLeftDown(const AsylumEvent &evt) {
return true;
}
-bool PuzzleClock::mouseRightDown(const AsylumEvent &evt) {
+bool PuzzleClock::mouseRightDown(const AsylumEvent &) {
setFlag();
_rightButtonClicked = true;
diff --git a/engines/asylum/puzzles/fisherman.cpp b/engines/asylum/puzzles/fisherman.cpp
index 3048e1a3e9..586c747928 100644
--- a/engines/asylum/puzzles/fisherman.cpp
+++ b/engines/asylum/puzzles/fisherman.cpp
@@ -65,7 +65,7 @@ bool PuzzleFisherman::init(const AsylumEvent &evt) {
for (uint32 i = 0; i < ARRAYSIZE(_state); i++)
if (_vm->isGameFlagNotSet((GameFlag)(kGameFlag801 + i)))
- _state[i] = 0;
+ _state[i] = false;
if (_counter == 6) {
_vm->clearGameFlag(kGameFlag619);
@@ -79,7 +79,7 @@ bool PuzzleFisherman::init(const AsylumEvent &evt) {
return mouseLeftDown(evt);
}
-bool PuzzleFisherman::update(const AsylumEvent &evt) {
+bool PuzzleFisherman::update(const AsylumEvent &) {
updateCursor();
// Draw background
@@ -160,7 +160,7 @@ bool PuzzleFisherman::mouseLeftDown(const AsylumEvent &evt) {
return true;
}
-bool PuzzleFisherman::mouseRightDown(const AsylumEvent &evt) {
+bool PuzzleFisherman::mouseRightDown(const AsylumEvent &) {
getCursor()->hide();
getSharedData()->setFlag(kFlag1, true);
getScreen()->stopPaletteFade(0, 0, 0);
diff --git a/engines/asylum/puzzles/hivecontrol.cpp b/engines/asylum/puzzles/hivecontrol.cpp
index 7419d22b10..2eba33388f 100644
--- a/engines/asylum/puzzles/hivecontrol.cpp
+++ b/engines/asylum/puzzles/hivecontrol.cpp
@@ -51,18 +51,6 @@ const Control puzzleHiveControlIntToControl[] = {
kControlGlyph6
};
-bool PuzzleHiveControl::hitTest1(uint32 resourceId, Common::Point point, Common::Point location) {
- GraphicResource resource(_vm);
- resource.load(getWorld()->graphicResourceIds[resourceId]);
- GraphicFrame *frame = resource.getFrame(0);
- Common::Point point1(point.x - location.x, point.y - location.y);
-
- if (!frame->getRect().contains(point1))
- return false;
- else
- return *((byte *)frame->surface.pixels + point1.x + frame->surface.pitch * point1.y) != 0;
-}
-
PuzzleHiveControl::PuzzleHiveControl(AsylumEngine *engine) : Puzzle(engine) {
_rectIndex = 0;
_soundVolume = 0;
@@ -92,7 +80,7 @@ void PuzzleHiveControl::reset() {
_frameIndexes[kElementSwirlRim] = 0;
if (_leverPosition != _prevLeverPosition) {
- _leverDelta = abs((double)(_leverPosition - _prevLeverPosition)) * 16 / 5;
+ _leverDelta = (uint32)abs((double)(_leverPosition - _prevLeverPosition)) * 16 / 5;
_currentControl = kControlGlyph4;
}
}
@@ -100,21 +88,21 @@ void PuzzleHiveControl::reset() {
//////////////////////////////////////////////////////////////////////////
// Event Handling
//////////////////////////////////////////////////////////////////////////
-bool PuzzleHiveControl::init(const AsylumEvent &evt) {
- _controlPoints[kControlWingsButton1] = Common::Point(338, 139);
- _controlPoints[kControlWingsButton2] = Common::Point(376, 151);
- _controlPoints[kControlWingsButton3] = Common::Point(403, 162);
- _controlPoints[kControlReset] = Common::Point(219, 86);
- _controlPoints[kControlWheelRight] = Common::Point(204, 263);
- _controlPoints[kControlWheelLeft] = Common::Point(164, 310);
- _controlPoints[kControlButtonLeft] = Common::Point(320, 375);
- _controlPoints[kControlButtonRight] = Common::Point(363, 337);
- _controlPoints[kControlGlyph1] = Common::Point(102, 201);
- _controlPoints[kControlGlyph2] = Common::Point(101, 171);
- _controlPoints[kControlGlyph3] = Common::Point(108, 140);
- _controlPoints[kControlGlyph4] = Common::Point(126, 111);
- _controlPoints[kControlGlyph5] = Common::Point(140, 85);
- _controlPoints[kControlGlyph6] = Common::Point(161, 54);
+bool PuzzleHiveControl::init(const AsylumEvent &) {
+ _controlPoints[kControlWingsButton1] = Common::Point(338, 139);
+ _controlPoints[kControlWingsButton2] = Common::Point(376, 151);
+ _controlPoints[kControlWingsButton3] = Common::Point(403, 162);
+ _controlPoints[kControlReset] = Common::Point(219, 86);
+ _controlPoints[kControlWheelRight] = Common::Point(204, 263);
+ _controlPoints[kControlWheelLeft] = Common::Point(164, 310);
+ _controlPoints[kControlButtonLeft] = Common::Point(320, 375);
+ _controlPoints[kControlButtonRight] = Common::Point(363, 337);
+ _controlPoints[kControlGlyph1] = Common::Point(102, 201);
+ _controlPoints[kControlGlyph2] = Common::Point(101, 171);
+ _controlPoints[kControlGlyph3] = Common::Point(108, 140);
+ _controlPoints[kControlGlyph4] = Common::Point(126, 111);
+ _controlPoints[kControlGlyph5] = Common::Point(140, 85);
+ _controlPoints[kControlGlyph6] = Common::Point(161, 54);
_rectIndex = -2;
_frameIndexes[kElementLever] = (5 - _leverPosition) * (GraphicResource::getFrameCount(_vm, getWorld()->graphicResourceIds[kElementLever]) - 1) / 5;
@@ -152,7 +140,7 @@ bool PuzzleHiveControl::update(const AsylumEvent &evt) {
return true;
}
-bool PuzzleHiveControl::mouseLeftDown(const AsylumEvent &evt) {
+bool PuzzleHiveControl::mouseLeftDown(const AsylumEvent &) {
if (_currentControl != kControlNone)
return true;
@@ -164,12 +152,14 @@ bool PuzzleHiveControl::mouseLeftDown(const AsylumEvent &evt) {
case kControlWingsButton1:
getCursor()->hide();
getSound()->playSound(getWorld()->graphicResourceIds[81], false, Config.sfxVolume - 10);
+
if (_wingsState[1] != _wingsState[2]) {
if (_wingsState[0])
--_frameIndexOffset;
else
++_frameIndexOffset;
}
+
_frameIndexOffset += _wingsState[0] ? -1 : 1;
_wingsState[0] = !_wingsState[0];
_frameIndexes[kElementLensLeft] = _colorL * 8 + _frameIndexOffset;
@@ -179,12 +169,14 @@ bool PuzzleHiveControl::mouseLeftDown(const AsylumEvent &evt) {
case kControlWingsButton2:
getCursor()->hide();
getSound()->playSound(getWorld()->graphicResourceIds[81], false, Config.sfxVolume - 10);
+
if (_wingsState[0] != _wingsState[2]) {
if (_wingsState[1])
--_frameIndexOffset;
else
++_frameIndexOffset;
}
+
_frameIndexOffset += _wingsState[1] ? -2 : 2;
_wingsState[1] = !_wingsState[1];
_frameIndexes[kElementLensLeft] = _colorL * 8 + _frameIndexOffset;
@@ -194,13 +186,15 @@ bool PuzzleHiveControl::mouseLeftDown(const AsylumEvent &evt) {
case kControlWingsButton3:
getCursor()->hide();
getSound()->playSound(getWorld()->graphicResourceIds[81], false, Config.sfxVolume - 10);
+
if (_wingsState[0] != _wingsState[1]) {
if (_wingsState[2])
--_frameIndexOffset;
else
++_frameIndexOffset;
}
- _frameIndexOffset += _wingsState[2] ? -3 : 3;
+
+ _frameIndexOffset += (_wingsState[2] ? -3 : 3);
_wingsState[2] = !_wingsState[2];
_frameIndexes[kElementLensLeft] = _colorL * 8 + _frameIndexOffset;
_frameIndexes[kElementLensRight] = _colorR * 8 + _frameIndexOffset;
@@ -229,11 +223,14 @@ bool PuzzleHiveControl::mouseLeftDown(const AsylumEvent &evt) {
case kControlButtonLeft:
getCursor()->hide();
getSound()->playSound(getWorld()->graphicResourceIds[77], false, Config.sfxVolume - 10);
+
if (!_glyphFlags[0][_leverPosition]) {
_glyphFlags[0][_leverPosition] = puzzleHiveControlHieroglyphs[0][_leverPosition] == _frameIndexes[kElementLensLeft];
if (_glyphFlags[0][_leverPosition]) {
getSound()->playSound(getWorld()->graphicResourceIds[83], false, Config.sfxVolume - 10);
++_frameIndexes[kElementSwirlRim];
+
+ error("[PuzzleHiveControl::mouseLeftDown] Not implemented");
//if (_frameIndexes[kElementSwirlRim] == 12)
// ...
}
@@ -260,8 +257,8 @@ bool PuzzleHiveControl::mouseLeftDown(const AsylumEvent &evt) {
case kControlGlyph4:
case kControlGlyph5:
case kControlGlyph6:
- _leverPosition = _currentControl - 49;
- _leverDelta = abs((double)(_leverPosition - _prevLeverPosition)) * (GraphicResource::getFrameCount(_vm, getWorld()->graphicResourceIds[kElementLever]) - 1) / 5;
+ _leverPosition = (uint32)(_currentControl - 49);
+ _leverDelta = (uint32)abs((double)(_leverPosition - _prevLeverPosition)) * (GraphicResource::getFrameCount(_vm, getWorld()->graphicResourceIds[kElementLever]) - 1) / 5;
if (_leverDelta)
getSound()->playSound(getWorld()->graphicResourceIds[76], false, Config.sfxVolume - 10);
}
@@ -269,7 +266,7 @@ bool PuzzleHiveControl::mouseLeftDown(const AsylumEvent &evt) {
return true;
}
-bool PuzzleHiveControl::mouseRightDown(const AsylumEvent &evt) {
+bool PuzzleHiveControl::mouseRightDown(const AsylumEvent &) {
reset();
getSound()->stop(getWorld()->graphicResourceIds[73]);
@@ -442,7 +439,22 @@ void PuzzleHiveControl::updateScreen() {
}
void PuzzleHiveControl::playSound() {
- //error("[PuzzleHiveControl::playSound] Not implemented!");
+ warning("[PuzzleHiveControl::playSound] Not implemented!");
+}
+
+bool PuzzleHiveControl::hitTest1(Control control, const Common::Point &point, const Common::Point &location) {
+ if (control == kControlNone)
+ error("[PuzzleHiveControl::hitTest1] Invalid control");
+
+ GraphicResource resource(_vm);
+ resource.load(getWorld()->graphicResourceIds[control]);
+ GraphicFrame *frame = resource.getFrame(0);
+ Common::Point point1(point.x - location.x, point.y - location.y);
+
+ if (!frame->getRect().contains(point1))
+ return false;
+ else
+ return *((byte *)frame->surface.pixels + point1.x + frame->surface.pitch * point1.y) != 0;
}
} // End of namespace Asylum
diff --git a/engines/asylum/puzzles/hivecontrol.h b/engines/asylum/puzzles/hivecontrol.h
index e0bdc115c3..5774a4f3a5 100644
--- a/engines/asylum/puzzles/hivecontrol.h
+++ b/engines/asylum/puzzles/hivecontrol.h
@@ -32,21 +32,21 @@ namespace Asylum {
class AsylumEngine;
enum Control {
- kControlNone = -1,
- kControlWingsButton1 = 34,
- kControlWingsButton2 = 35,
- kControlWingsButton3 = 36,
- kControlReset = 38,
- kControlWheelLeft = 39,
- kControlWheelRight = 40,
- kControlButtonRight = 41,
- kControlButtonLeft = 42,
- kControlGlyph1 = 49,
- kControlGlyph2 = 50,
- kControlGlyph3 = 51,
- kControlGlyph4 = 52,
- kControlGlyph5 = 53,
- kControlGlyph6 = 54
+ kControlNone = -1,
+ kControlWingsButton1 = 34,
+ kControlWingsButton2 = 35,
+ kControlWingsButton3 = 36,
+ kControlReset = 38,
+ kControlWheelLeft = 39,
+ kControlWheelRight = 40,
+ kControlButtonRight = 41,
+ kControlButtonLeft = 42,
+ kControlGlyph1 = 49,
+ kControlGlyph2 = 50,
+ kControlGlyph3 = 51,
+ kControlGlyph4 = 52,
+ kControlGlyph5 = 53,
+ kControlGlyph6 = 54
};
static const uint32 puzzleHiveControlHieroglyphs[2][6] = {
@@ -59,8 +59,6 @@ public:
PuzzleHiveControl(AsylumEngine *engine);
~PuzzleHiveControl();
- bool hitTest1(uint32 resourceId, Common::Point point, Common::Point location);
-
private:
enum Element {
kElementSwirl = 31,
@@ -114,6 +112,7 @@ private:
void updateScreen();
void playSound();
void reset();
+ bool hitTest1(Control control, const Common::Point &point, const Common::Point &location);
};
} // End of namespace Asylum
diff --git a/engines/asylum/puzzles/hivemachine.cpp b/engines/asylum/puzzles/hivemachine.cpp
index 71be69d382..0d61f43d9e 100644
--- a/engines/asylum/puzzles/hivemachine.cpp
+++ b/engines/asylum/puzzles/hivemachine.cpp
@@ -55,6 +55,7 @@ PuzzleHiveMachine::PuzzleHiveMachine(AsylumEngine *engine) : Puzzle(engine) {
_counterRed = _counterGreen = _counterKey = 0;
_rectIndex = -2;
_frameIndex = 0;
+ _frameIndex1 = 0;
_soundingNote = kMusicalNoteNone;
_notesNumber = 0;
_ok = false;
@@ -165,7 +166,7 @@ PuzzleHiveMachine::~PuzzleHiveMachine() {
//////////////////////////////////////////////////////////////////////////
// Event Handling
//////////////////////////////////////////////////////////////////////////
-bool PuzzleHiveMachine::init(const AsylumEvent &evt) {
+bool PuzzleHiveMachine::init(const AsylumEvent &) {
getScreen()->setPalette(getWorld()->graphicResourceIds[9]);
getScreen()->setGammaLevel(getWorld()->graphicResourceIds[9]);
_rectIndex = -2;
@@ -173,14 +174,14 @@ bool PuzzleHiveMachine::init(const AsylumEvent &evt) {
return true;
}
-bool PuzzleHiveMachine::update(const AsylumEvent &evt) {
+bool PuzzleHiveMachine::update(const AsylumEvent &) {
updateScreen();
updateCursor();
return true;
}
-bool PuzzleHiveMachine::mouseLeftDown(const AsylumEvent &evt) {
+bool PuzzleHiveMachine::mouseLeftDown(const AsylumEvent &) {
if (_rectIndex != -1 && _counterRed == 0) {
_soundingNote = MusicalNote(_rectIndex);
_melody.push_back(_soundingNote);
@@ -207,7 +208,7 @@ bool PuzzleHiveMachine::mouseLeftDown(const AsylumEvent &evt) {
return true;
}
-bool PuzzleHiveMachine::mouseRightDown(const AsylumEvent &evt) {
+bool PuzzleHiveMachine::mouseRightDown(const AsylumEvent &) {
_notesNumber = 0;
_melody.clear();
@@ -291,6 +292,9 @@ void PuzzleHiveMachine::updateScreen() {
}
void PuzzleHiveMachine::playSound() {
+ if (_soundingNote == kMusicalNoteNone)
+ error("[PuzzleHiveMachine::playSound] Invalid sound resource id");
+
uint32 soundMap[] = {4, 2, 3, 0, 1};
getSound()->playSound(getWorld()->graphicResourceIds[soundMap[_soundingNote] + 23], false, Config.sfxVolume - 10);
}
diff --git a/engines/asylum/puzzles/lock.cpp b/engines/asylum/puzzles/lock.cpp
index c58a252381..eb3112a101 100644
--- a/engines/asylum/puzzles/lock.cpp
+++ b/engines/asylum/puzzles/lock.cpp
@@ -54,7 +54,7 @@ PuzzleLock::~PuzzleLock() {
//////////////////////////////////////////////////////////////////////////
// Event Handling
//////////////////////////////////////////////////////////////////////////
-bool PuzzleLock::init(const AsylumEvent &evt) {
+bool PuzzleLock::init(const AsylumEvent &) {
getScreen()->clear();
getScreen()->setPalette(getWorld()->graphicResourceIds[14]);
@@ -67,7 +67,7 @@ bool PuzzleLock::init(const AsylumEvent &evt) {
return true;
}
-bool PuzzleLock::update(const AsylumEvent &evt) {
+bool PuzzleLock::update(const AsylumEvent &) {
updateCursor();
// Draw screen
@@ -75,16 +75,16 @@ bool PuzzleLock::update(const AsylumEvent &evt) {
getScreen()->draw(getWorld()->graphicResourceIds[13]);
if (_frameIndexes[0] != 32 || _frameIndexes[1] != 28 || _frameIndexes[2] != 0) {
- getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[15], _frameIndexes[0], Common::Point(145, 292), kDrawFlagNone, 0, 1);
- getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[15], _frameIndexes[1], Common::Point(173, 297), kDrawFlagNone, 0, 1);
- getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[15], _frameIndexes[2], Common::Point(201, 302), kDrawFlagNone, 0, 1);
- getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[40], _frameIndexes[3], Common::Point(337, 127), kDrawFlagNone, 0, 1);
+ getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[15], (uint32)_frameIndexes[0], Common::Point(145, 292), kDrawFlagNone, 0, 1);
+ getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[15], (uint32)_frameIndexes[1], Common::Point(173, 297), kDrawFlagNone, 0, 1);
+ getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[15], (uint32)_frameIndexes[2], Common::Point(201, 302), kDrawFlagNone, 0, 1);
+ getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[40], (uint32)_frameIndexes[3], Common::Point(337, 127), kDrawFlagNone, 0, 1);
if (_frameIndexes[4] != -1)
- getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[42], _frameIndexes[4], Common::Point(318, 102), kDrawFlagNone, 0, 1);
+ getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[42], (uint32)_frameIndexes[4], Common::Point(318, 102), kDrawFlagNone, 0, 1);
if (_frameIndexes[5] != -1)
- getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[43], _frameIndexes[5], Common::Point(318, 99), kDrawFlagNone, 0, 1);
+ getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[43], (uint32)_frameIndexes[5], Common::Point(318, 99), kDrawFlagNone, 0, 1);
getScreen()->drawGraphicsInQueue();
getScreen()->copyBackBufferToScreen();
@@ -92,7 +92,7 @@ bool PuzzleLock::update(const AsylumEvent &evt) {
if (_frameIndexes[6] == 5)
getSound()->playSound(getWorld()->soundResourceIds[15], false, Config.sfxVolume - 10);
- getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[16], _frameIndexes[6], Common::Point(0, 264), kDrawFlagNone, 0, 1);
+ getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[16], (uint32)_frameIndexes[6], Common::Point(0, 264), kDrawFlagNone, 0, 1);
++_counter;
@@ -212,7 +212,7 @@ bool PuzzleLock::mouseLeftDown(const AsylumEvent &evt) {
return true;
}
-bool PuzzleLock::mouseRightDown(const AsylumEvent &evt) {
+bool PuzzleLock::mouseRightDown(const AsylumEvent &) {
exitPuzzle();
return true;
diff --git a/engines/asylum/puzzles/morguedoor.cpp b/engines/asylum/puzzles/morguedoor.cpp
index 2d353c4395..5cb44319d0 100644
--- a/engines/asylum/puzzles/morguedoor.cpp
+++ b/engines/asylum/puzzles/morguedoor.cpp
@@ -85,29 +85,29 @@ bool PuzzleMorgueDoor::init(const AsylumEvent &evt) {
return mouseLeftDown(evt);
}
-bool PuzzleMorgueDoor::update(const AsylumEvent &evt) {
+bool PuzzleMorgueDoor::update(const AsylumEvent &) {
updateCursor();
// Draw elements
getScreen()->clearGraphicsInQueue();
getScreen()->draw(getWorld()->graphicResourceIds[19]);
- getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[21], _frameIndexes[kTopLever], Common::Point(47, 0), kDrawFlagNone, 0, 1);
- getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[22], _frameIndexes[kBottomLever], Common::Point(51, 236), kDrawFlagNone, 0, 1);
+ getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[21], (uint32)_frameIndexes[kTopLever], Common::Point(47, 0), kDrawFlagNone, 0, 1);
+ getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[22], (uint32)_frameIndexes[kBottomLever], Common::Point(51, 236), kDrawFlagNone, 0, 1);
if (_topLeverOpen)
- getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[23], _frameIndexes[kTopLeverOpened], Common::Point(80, 0), kDrawFlagNone, 0, 1);
+ getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[23], (uint32)_frameIndexes[kTopLeverOpened], Common::Point(80, 0), kDrawFlagNone, 0, 1);
if (_bottomLeverOpen)
- getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[24], _frameIndexes[kBottomLeverOpened], Common::Point(89, 230), kDrawFlagNone, 0, 1);
+ getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[24], (uint32)_frameIndexes[kBottomLeverOpened], Common::Point(89, 230), kDrawFlagNone, 0, 1);
- getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[25], _frameIndexes[kTopRightValve], Common::Point(515, 41), kDrawFlagNone, 0, 1);
- getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[26], _frameIndexes[kCenterValve], Common::Point(267, 190), kDrawFlagNone, 0, 1);
- getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[27], _frameIndexes[kRightGear], Common::Point(388, 105), kDrawFlagNone, 0, 1);
- getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[28], _frameIndexes[kTopRightLever], Common::Point(491, 143), kDrawFlagNone, 0, 1);
- getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[29], _frameIndexes[kTopSmallLever], Common::Point(347, 124), kDrawFlagNone, 0, 1);
- getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[30], _frameIndexes[kBottomSmallLever], Common::Point(346, 339), kDrawFlagNone, 0, 1);
- getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[31], _frameIndexes[kTopGear], Common::Point(276, 67), kDrawFlagNone, 0, 1);
- getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[32], _frameIndexes[kBottomGear], Common::Point(278, 378), kDrawFlagNone, 0, 1);
+ getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[25], (uint32)_frameIndexes[kTopRightValve], Common::Point(515, 41), kDrawFlagNone, 0, 1);
+ getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[26], (uint32)_frameIndexes[kCenterValve], Common::Point(267, 190), kDrawFlagNone, 0, 1);
+ getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[27], (uint32)_frameIndexes[kRightGear], Common::Point(388, 105), kDrawFlagNone, 0, 1);
+ getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[28], (uint32)_frameIndexes[kTopRightLever], Common::Point(491, 143), kDrawFlagNone, 0, 1);
+ getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[29], (uint32)_frameIndexes[kTopSmallLever], Common::Point(347, 124), kDrawFlagNone, 0, 1);
+ getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[30], (uint32)_frameIndexes[kBottomSmallLever], Common::Point(346, 339), kDrawFlagNone, 0, 1);
+ getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[31], (uint32)_frameIndexes[kTopGear], Common::Point(276, 67), kDrawFlagNone, 0, 1);
+ getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[32], (uint32)_frameIndexes[kBottomGear], Common::Point(278, 378), kDrawFlagNone, 0, 1);
getScreen()->drawGraphicsInQueue();
getScreen()->copyBackBufferToScreen();
@@ -194,7 +194,7 @@ bool PuzzleMorgueDoor::mouseLeftDown(const AsylumEvent &evt) {
return true;
}
-bool PuzzleMorgueDoor::mouseRightUp(const AsylumEvent &evt) {
+bool PuzzleMorgueDoor::mouseRightUp(const AsylumEvent &) {
getCursor()->hide();
getSharedData()->setFlag(kFlag1, true);
getScreen()->stopPaletteFade(0, 0, 0);
diff --git a/engines/asylum/puzzles/morguedoor.h b/engines/asylum/puzzles/morguedoor.h
index 3fccfbacb3..8cd070042e 100644
--- a/engines/asylum/puzzles/morguedoor.h
+++ b/engines/asylum/puzzles/morguedoor.h
@@ -59,8 +59,8 @@ private:
bool _data_4572AC;
bool _data_4572B0;
- uint32 _data_45A9D8;
- uint32 _data_45A9DC;
+ int32 _data_45A9D8;
+ int32 _data_45A9DC;
bool _topLeverOpen;
bool _bottomLeverOpen;
diff --git a/engines/asylum/puzzles/pipes.cpp b/engines/asylum/puzzles/pipes.cpp
index 0723353b72..bf9ac97965 100644
--- a/engines/asylum/puzzles/pipes.cpp
+++ b/engines/asylum/puzzles/pipes.cpp
@@ -144,7 +144,7 @@ void Connector::init(Peephole *n, Peephole *e, Peephole *s, Peephole *w, BinNum
_isConnected = false;
for (uint32 i = 0; i < 4; ++i) {
- if (_state & (1 << i) && _nodes[i]) {
+ if (_state & ((uint32)1 << i) && _nodes[i]) {
_nodes[i]->connect(this);
_connectedNodes.push_back(_nodes[i]);
}
@@ -175,8 +175,8 @@ void Connector::turn() {
oldIndex[1] = 2;
}
} else {
- newIndex[0] = Common::intLog2(newState & delta);
- oldIndex[0] = Common::intLog2(_state & delta);
+ newIndex[0] = (uint32)Common::intLog2(newState & delta);
+ oldIndex[0] = (uint32)Common::intLog2(_state & delta);
}
for (uint32 i = 0; i < (uint32)(delta == kBinNum1111 ? 2 : 1); ++i) {
@@ -254,13 +254,15 @@ void Connector::disconnect(Connector *connector) {
//////////////////////////////////////////////////////////////////////////
// Spider
//////////////////////////////////////////////////////////////////////////
-Spider::Spider(Common::Rect rect, Common::String id) {
+Spider::Spider(const Common::Rect &rect, Common::String id) {
_boundingBox = rect;
_rnd = new Common::RandomSource(Common::String("pipes_spider") + id);
_isAlive = true;
- _location.x = _rnd->getRandomNumber(_boundingBox.right - _boundingBox.left) + _boundingBox.left;
- _location.y = _rnd->getRandomNumber(_boundingBox.bottom - _boundingBox.top) + _boundingBox.top;
- _direction = Direction(1 << _rnd->getRandomNumber(3));
+ _location.x = (int16)_rnd->getRandomNumber((uint16)(_boundingBox.right - _boundingBox.left)) + _boundingBox.left;
+ _location.y = (int16)_rnd->getRandomNumber((uint16)(_boundingBox.bottom - _boundingBox.top)) + _boundingBox.top;
+ _direction = Direction((uint32)1 << _rnd->getRandomNumber(3));
+ _stepsNumber = 0;
+ _steps = 0;
randomize();
}
@@ -270,7 +272,8 @@ void Spider::randomize(Direction excluded) {
_delta = Common::Point(0, 0);
else {
while (_direction == excluded)
- _direction = Direction(1 << _rnd->getRandomNumber(3));
+ _direction = Direction((uint32)1 << _rnd->getRandomNumber(3));
+
_delta = Common::Point((_direction & kBinNum0010 ? 1 : 0) - (_direction & kBinNum1000 ? 1 : 0), (_direction & kBinNum0100 ? 1 : 0) - (_direction & kBinNum0001 ? 1 : 0));
}
@@ -300,11 +303,14 @@ Common::Point Spider::move() {
PuzzlePipes::PuzzlePipes(AsylumEngine *engine) : Puzzle(engine) {
_previousMusicVolume = 0;
_rectIndex = -2;
-
_frameIndex = _frameIndexLever = 0;
- memset(_previousLevels, 0, sizeof(_previousLevels));
memset(&_levelFlags, false, sizeof(_levelFlags));
_levelFlags[4] = true;
+ memset(&_levelValues, 0, sizeof(_levelValues));
+ memset(&_previousLevels, 0, sizeof(_previousLevels));
+ _isLeverReady = false;
+ memset(&_sinks, 0, sizeof(_sinks));
+ memset(&_sources, 0, sizeof(_sources));
_frameIndexSpider = NULL;
}
@@ -315,14 +321,10 @@ PuzzlePipes::~PuzzlePipes() {
delete [] _frameIndexSpider;
}
-void PuzzlePipes::reset() {
- warning("[PuzzlePipes::reset] Not implemented!");
-}
-
//////////////////////////////////////////////////////////////////////////
// Event Handling
//////////////////////////////////////////////////////////////////////////
-bool PuzzlePipes::init(const AsylumEvent &evt) {
+bool PuzzlePipes::init(const AsylumEvent &) {
_previousMusicVolume = getSound()->getMusicVolume();
if (_previousMusicVolume >= -1000)
@@ -340,7 +342,10 @@ bool PuzzlePipes::init(const AsylumEvent &evt) {
return true;
}
-bool PuzzlePipes::update(const AsylumEvent &evt) {
+bool PuzzlePipes::update(const AsylumEvent &) {
+ if (!_frameIndexSpider)
+ error("[PuzzlePipes::update] Puzzle not initialized properly");
+
getScreen()->clear();
getScreen()->clearGraphicsInQueue();
getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[1], 0, Common::Point(0, 0), kDrawFlagNone, 0, 4);
@@ -351,15 +356,15 @@ bool PuzzlePipes::update(const AsylumEvent &evt) {
uint32 filled = 0;
for (uint32 i = 0; i < 4; ++i) {
if (fabs(_levelValues[i] - _previousLevels[i]) > 0.005)
- _previousLevels[i] += _levelValues[i] > _previousLevels[i] ? 0.01 : -0.01;
+ _previousLevels[i] += _levelValues[i] > _previousLevels[i] ? 0.01f : -0.01f;
else
++filled;
}
- getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[18], 0, Common::Point(210, 444 - uint32(_previousLevels[0] * 52)), kDrawFlagNone, 0, 3);
- getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[18], 0, Common::Point(276, 455 - uint32(_previousLevels[1] * 52)), kDrawFlagNone, 0, 3);
- getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[18], 0, Common::Point(376, 448 - uint32(_previousLevels[2] * 52)), kDrawFlagNone, 0, 3);
- getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[18], 0, Common::Point(458, 442 - uint32(_previousLevels[3] * 52)), kDrawFlagNone, 0, 3);
+ getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[18], 0, Common::Point(210, 444 - int16(_previousLevels[0] * 52)), kDrawFlagNone, 0, 3);
+ getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[18], 0, Common::Point(276, 455 - int16(_previousLevels[1] * 52)), kDrawFlagNone, 0, 3);
+ getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[18], 0, Common::Point(376, 448 - int16(_previousLevels[2] * 52)), kDrawFlagNone, 0, 3);
+ getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[18], 0, Common::Point(458, 442 - int16(_previousLevels[3] * 52)), kDrawFlagNone, 0, 3);
getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[33], 0, Common::Point(204, 377), kDrawFlagNone, 0, 1);
@@ -438,7 +443,10 @@ bool PuzzlePipes::update(const AsylumEvent &evt) {
return true;
}
-bool PuzzlePipes::mouseLeftDown(const AsylumEvent &evt) {
+bool PuzzlePipes::mouseLeftDown(const AsylumEvent &) {
+ if (!_frameIndexSpider)
+ error("[PuzzlePipes::update] Puzzle not initialized properly");
+
Common::Point mousePos = getCursor()->position();
if (Common::Rect(540, 90, 590, 250).contains(mousePos)) {
@@ -466,7 +474,7 @@ bool PuzzlePipes::mouseLeftDown(const AsylumEvent &evt) {
return true;
}
-bool PuzzlePipes::mouseRightDown(const AsylumEvent &evt) {
+bool PuzzlePipes::mouseRightDown(const AsylumEvent &) {
getScreen()->clear();
getSound()->stop(getWorld()->graphicResourceIds[41]);
getSound()->setMusicVolume(_previousMusicVolume);
@@ -495,7 +503,7 @@ void PuzzlePipes::initResources() {
}
void PuzzlePipes::setup() {
- memset(&_levelValues, 0.0, sizeof(_levelValues));
+ memset(&_levelValues, 0, sizeof(_levelValues));
for (uint32 i = 0; i < peepholesCount; ++i)
_peepholes[i].setId(i);
@@ -504,7 +512,7 @@ void PuzzlePipes::setup() {
_connectors[i].setId(i);
for (uint32 i = 0; i < 4; ++i) {
- _sinks[i] = &_peepholes[peepholesCount - 4 + i];
+ _sinks[i] = &_peepholes[(peepholesCount - 4) + i];
_sources[i] = &_peepholes[i];
memset(&_sources[i]->_flowValues, 0, sizeof(_sources[i]->_flowValues));
_sources[i]->_flowValues[i] = 1;
diff --git a/engines/asylum/puzzles/pipes.h b/engines/asylum/puzzles/pipes.h
index 5ed3c9acbb..6946891048 100644
--- a/engines/asylum/puzzles/pipes.h
+++ b/engines/asylum/puzzles/pipes.h
@@ -123,7 +123,7 @@ private:
class Spider {
public:
- Spider(Common::Rect rect, Common::String id);
+ Spider(const Common::Rect &rect, Common::String id);
~Spider() { delete _rnd; }
bool isAlive() const { return _isAlive; }
@@ -154,8 +154,6 @@ public:
PuzzlePipes(AsylumEngine *engine);
~PuzzlePipes();
- void reset();
-
private:
int32 _previousMusicVolume;
int32 _rectIndex;
diff --git a/engines/asylum/puzzles/puzzle.cpp b/engines/asylum/puzzles/puzzle.cpp
index e5e9b989ce..fd461a4b6a 100644
--- a/engines/asylum/puzzles/puzzle.cpp
+++ b/engines/asylum/puzzles/puzzle.cpp
@@ -116,13 +116,13 @@ void Puzzle::exitPuzzle() {
//////////////////////////////////////////////////////////////////////////
// Hit test functions
//////////////////////////////////////////////////////////////////////////
-bool Puzzle::hitTest(const Common::Point *polygonPoint, Common::Point point, uint32 index) {
+bool Puzzle::hitTest(const Common::Point *polygonPoint, const Common::Point &point, uint32 index) const {
Polygon polygon(polygonPoint[index], polygonPoint[index + 1], polygonPoint[index + 2], polygonPoint[index + 3]);
return polygon.contains(point);
}
-bool Puzzle::hitTest(const Common::Point *polygonPoint, Common::Point point) {
+bool Puzzle::hitTest(const Common::Point *polygonPoint, const Common::Point &point) const {
Polygon polygon(polygonPoint[0], polygonPoint[1], polygonPoint[2], polygonPoint[3]);
return polygon.contains(point);
diff --git a/engines/asylum/puzzles/puzzle.h b/engines/asylum/puzzles/puzzle.h
index 3841ba6b75..cc9f14adc1 100644
--- a/engines/asylum/puzzles/puzzle.h
+++ b/engines/asylum/puzzles/puzzle.h
@@ -66,8 +66,8 @@ protected:
//////////////////////////////////////////////////////////////////////////
// Hit test functions
//////////////////////////////////////////////////////////////////////////
- bool hitTest(const Common::Point *polygonPoint, Common::Point point, uint32 index);
- bool hitTest(const Common::Point *polygonPoint, Common::Point point);
+ bool hitTest(const Common::Point *polygonPoint, const Common::Point &point, uint32 index) const;
+ bool hitTest(const Common::Point *polygonPoint, const Common::Point &point) const;
};
} // End of namespace Asylum
diff --git a/engines/asylum/puzzles/puzzle11.cpp b/engines/asylum/puzzles/puzzle11.cpp
index 0198d93ec9..f9feff67bc 100644
--- a/engines/asylum/puzzles/puzzle11.cpp
+++ b/engines/asylum/puzzles/puzzle11.cpp
@@ -69,7 +69,7 @@ bool Puzzle11::init(const AsylumEvent &evt) {
return true;
}
-bool Puzzle11::update(const AsylumEvent &evt) {
+bool Puzzle11::update(const AsylumEvent &) {
getScreen()->clearGraphicsInQueue();
getScreen()->draw(getWorld()->graphicResourceIds[11]);
getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[15], _frameIndexes[0], Common::Point(122, 269), kDrawFlagNone, 0, 1);
@@ -85,13 +85,13 @@ bool Puzzle11::update(const AsylumEvent &evt) {
return true;
}
-bool Puzzle11::mouseRightDown(const AsylumEvent &evt) {
+bool Puzzle11::mouseRightDown(const AsylumEvent &) {
warning("[Puzzle11::mouseUp] Not implemented!");
return false;
}
-bool Puzzle11::mouseLeftUp(const AsylumEvent &evt) {
+bool Puzzle11::mouseLeftUp(const AsylumEvent &) {
getCursor()->hide();
getSharedData()->setFlag(kFlag1, true);
getScreen()->stopPaletteFade(0, 0, 0);
@@ -101,7 +101,7 @@ bool Puzzle11::mouseLeftUp(const AsylumEvent &evt) {
return false;
}
-bool Puzzle11::mouseLeftDown(const AsylumEvent &evt) {
+bool Puzzle11::mouseLeftDown(const AsylumEvent &) {
warning("[Puzzle11::mouseDown] Not implemented!");
return true;
diff --git a/engines/asylum/puzzles/tictactoe.cpp b/engines/asylum/puzzles/tictactoe.cpp
index 8ccc7e2815..7349d7da2e 100644
--- a/engines/asylum/puzzles/tictactoe.cpp
+++ b/engines/asylum/puzzles/tictactoe.cpp
@@ -100,7 +100,7 @@ PuzzleTicTacToe::~PuzzleTicTacToe() {
//////////////////////////////////////////////////////////////////////////
// Event Handling
//////////////////////////////////////////////////////////////////////////
-bool PuzzleTicTacToe::init(const AsylumEvent &evt) {
+bool PuzzleTicTacToe::init(const AsylumEvent &) {
_ticker = 0;
_vm->clearGameFlag(kGameFlag114);
_vm->clearGameFlag(kGameFlag215);
@@ -120,7 +120,7 @@ bool PuzzleTicTacToe::init(const AsylumEvent &evt) {
return true;
}
-bool PuzzleTicTacToe::update(const AsylumEvent &evt) {
+bool PuzzleTicTacToe::update(const AsylumEvent &) {
if (_ticker) {
++_ticker;
@@ -209,7 +209,7 @@ void PuzzleTicTacToe::drawField() {
}
if (g_debugPolygons) {
- for (uint32 p = 0; p < ARRAYSIZE(puzzleTicTacToePolygons); p += 4) {
+ for (uint32 p = 0; p < ARRAYSIZE(puzzleTicTacToePolygons) - 4; p += 4) {
getScreen()->drawLine(puzzleTicTacToePolygons[p], puzzleTicTacToePolygons[p + 1]);
getScreen()->drawLine(puzzleTicTacToePolygons[p + 1], puzzleTicTacToePolygons[p + 2]);
getScreen()->drawLine(puzzleTicTacToePolygons[p + 2], puzzleTicTacToePolygons[p + 3]);
@@ -236,7 +236,7 @@ void PuzzleTicTacToe::drawField() {
_ticker = 1;
if (checkWinner())
- _needToInitialize = 1;
+ _needToInitialize = true;
}
if (_frameIndex > 12 && mark == 'O') {
@@ -424,7 +424,7 @@ bool PuzzleTicTacToe::check() {
return true;
}
-PuzzleTicTacToe::GameStatus PuzzleTicTacToe::checkField(uint32 field1, uint32 field2, uint32 field3, char mark, uint32 *counterX, uint32 *counterO) {
+PuzzleTicTacToe::GameStatus PuzzleTicTacToe::checkField(uint32 field1, uint32 field2, uint32 field3, char mark, uint32 *counterX, uint32 *counterO) const {
*counterX = 0;
*counterO = 0;
GameStatus status = kStatus0;
@@ -493,7 +493,7 @@ bool PuzzleTicTacToe::checkFields() {
return (_emptyCount != 0);
}
-uint32 PuzzleTicTacToe::checkPosition(uint32 position1, uint32 position2, uint position3) {
+uint32 PuzzleTicTacToe::checkPosition(uint32 position1, uint32 position2, uint position3) const {
if (_gameField[position1] == ' ')
return position1;
@@ -553,7 +553,7 @@ bool PuzzleTicTacToe::checkWinning(char mark) {
_emptyCount = 0;
for (uint32 i = 0; i < ARRAYSIZE(puzzleTicTacToeFieldsToCheck); i++) {
- if (checkField(puzzleTicTacToeFieldsToCheck[i].field1, puzzleTicTacToeFieldsToCheck[i].field2, puzzleTicTacToeFieldsToCheck[i].field3, 'O', &counterX, &counterO) == kStatusNeedBlocking) {
+ if (checkField(puzzleTicTacToeFieldsToCheck[i].field1, puzzleTicTacToeFieldsToCheck[i].field2, puzzleTicTacToeFieldsToCheck[i].field3, mark, &counterX, &counterO) == kStatusNeedBlocking) {
_field[_emptyCount] = checkPosition(puzzleTicTacToeFieldsToCheck[i].field1, puzzleTicTacToeFieldsToCheck[i].field2, puzzleTicTacToeFieldsToCheck[i].field3);
++_emptyCount;
}
diff --git a/engines/asylum/puzzles/tictactoe.h b/engines/asylum/puzzles/tictactoe.h
index ab57fef24c..370c7c4c3b 100644
--- a/engines/asylum/puzzles/tictactoe.h
+++ b/engines/asylum/puzzles/tictactoe.h
@@ -75,10 +75,10 @@ private:
// Game
//////////////////////////////////////////////////////////////////////////
bool check();
- GameStatus checkField(uint32 field1, uint32 field2, uint32 field3, char mark, uint32 *counterX, uint32 *counterO);
+ GameStatus checkField(uint32 field1, uint32 field2, uint32 field3, char mark, uint32 *counterX, uint32 *counterO) const;
bool checkFieldsUpdatePositions();
bool checkFields();
- uint32 checkPosition(uint32 position1, uint32 position2, uint position3);
+ uint32 checkPosition(uint32 position1, uint32 position2, uint position3) const;
bool checkWinner();
int32 checkWinnerHelper();
bool checkWinning(char mark);
diff --git a/engines/asylum/puzzles/timemachine.cpp b/engines/asylum/puzzles/timemachine.cpp
index db94f4b48d..ea6b75b679 100644
--- a/engines/asylum/puzzles/timemachine.cpp
+++ b/engines/asylum/puzzles/timemachine.cpp
@@ -111,17 +111,17 @@ bool PuzzleTimeMachine::init(const AsylumEvent &evt) {
return true;
}
-bool PuzzleTimeMachine::update(const AsylumEvent &evt) {
+bool PuzzleTimeMachine::update(const AsylumEvent &) {
updateCursor();
// Draw screen elements
getScreen()->clearGraphicsInQueue();
getScreen()->draw(getWorld()->graphicResourceIds[34]);
- getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[35], _frameIndexes[0], Common::Point(23, 215), kDrawFlagNone, 0, 1);
- getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[36], _frameIndexes[1], Common::Point(70, 217), kDrawFlagNone, 0, 2);
- getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[37], _frameIndexes[2], Common::Point(189, 217), kDrawFlagNone, 0, 3);
- getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[38], _frameIndexes[3], Common::Point(309, 218), kDrawFlagNone, 0, 4);
- getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[39], _frameIndexes[4], Common::Point(429, 212), kDrawFlagNone, 0, 5);
+ getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[35], (uint32)_frameIndexes[0], Common::Point(23, 215), kDrawFlagNone, 0, 1);
+ getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[36], (uint32)_frameIndexes[1], Common::Point(70, 217), kDrawFlagNone, 0, 2);
+ getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[37], (uint32)_frameIndexes[2], Common::Point(189, 217), kDrawFlagNone, 0, 3);
+ getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[38], (uint32)_frameIndexes[3], Common::Point(309, 218), kDrawFlagNone, 0, 4);
+ getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[39], (uint32)_frameIndexes[4], Common::Point(429, 212), kDrawFlagNone, 0, 5);
if (_frameIndexes[0] != 28 || _frameIndexes[1] || _frameIndexes[2] || _frameIndexes[3] || _frameIndexes[4]) {
_leftButtonClicked = true;
@@ -138,7 +138,7 @@ bool PuzzleTimeMachine::update(const AsylumEvent &evt) {
++_counter;
}
- getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[40], _frameIndexes[5], _point, kDrawFlagNone, 0, 1);
+ getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[40], (uint32)_frameIndexes[5], _point, kDrawFlagNone, 0, 1);
//////////////////////////////////////////////////////////////////////////
// Show all buttons
@@ -167,8 +167,8 @@ bool PuzzleTimeMachine::update(const AsylumEvent &evt) {
// Update frame indexes
if (_currentFrameIndex == 0 && _frameIncrements[0] != 0) {
- _data_4572BC = 0;
- _data_4572CC = 0;
+ _data_4572BC = false;
+ _data_4572CC = false;
_frameIndexes[5] += _frameIncrements[0];
@@ -239,13 +239,13 @@ bool PuzzleTimeMachine::mouseLeftDown(const AsylumEvent &evt) {
return true;
}
-bool PuzzleTimeMachine::mouseLeftUp(const AsylumEvent &evt) {
+bool PuzzleTimeMachine::mouseLeftUp(const AsylumEvent &) {
_leftButtonClicked = true;
return true;
}
-bool PuzzleTimeMachine::mouseRightDown(const AsylumEvent &evt) {
+bool PuzzleTimeMachine::mouseRightDown(const AsylumEvent &) {
getCursor()->hide();
getSharedData()->setFlag(kFlag1, true);
getScreen()->stopPaletteFade(0, 0, 0);
diff --git a/engines/asylum/puzzles/vcr.cpp b/engines/asylum/puzzles/vcr.cpp
index 325b6a2a9f..cb949bf308 100644
--- a/engines/asylum/puzzles/vcr.cpp
+++ b/engines/asylum/puzzles/vcr.cpp
@@ -52,7 +52,7 @@ PuzzleVCR::~PuzzleVCR() {
//////////////////////////////////////////////////////////////////////////
// Event Handling
//////////////////////////////////////////////////////////////////////////
-bool PuzzleVCR::init(const AsylumEvent &evt) {
+bool PuzzleVCR::init(const AsylumEvent &) {
// Load the graphics palette
getScreen()->setPalette(getWorld()->graphicResourceIds[29]);
getScreen()->setGammaLevel(getWorld()->graphicResourceIds[29]);
@@ -120,7 +120,7 @@ bool PuzzleVCR::mouseLeftDown(const AsylumEvent &evt) {
if (_jacksState[kRed] == kOnHand)
state = kPluggedOnYellow;
else
- state = (JackState)(((_jacksState[kYellow] != kOnHand) - 1) & 3);
+ state = (_jacksState[kYellow] != kOnHand) ? kOnTable : kPluggedOnBlack;
}
if (inPolygon(evt.mouse, kRedHole)) {
@@ -272,7 +272,7 @@ bool PuzzleVCR::mouseLeftUp(const AsylumEvent &) {
return true;
}
-bool PuzzleVCR::mouseRightDown(const AsylumEvent &evt) {
+bool PuzzleVCR::mouseRightDown(const AsylumEvent &) {
getScreen()->clearGraphicsInQueue();
getScreen()->clear();
@@ -286,7 +286,7 @@ bool PuzzleVCR::mouseRightDown(const AsylumEvent &evt) {
//////////////////////////////////////////////////////////////////////////
// Drawing
//////////////////////////////////////////////////////////////////////////
-void PuzzleVCR::updateScreen(const AsylumEvent &evt) {
+void PuzzleVCR::updateScreen(const AsylumEvent &) {
updateCursor();
// Draw background
@@ -314,7 +314,7 @@ void PuzzleVCR::updateScreen(const AsylumEvent &evt) {
getScreen()->draw(getWorld()->graphicResourceIds[0]);
getScreen()->drawGraphicsInQueue();
- for (uint32 barSize = 0; barSize < 84; barSize += 4)
+ for (int16 barSize = 0; barSize < 84; barSize += 4)
getScreen()->drawWideScreenBars(barSize);
// Palette fade
@@ -557,12 +557,12 @@ void PuzzleVCR::updateStopButton() {
//////////////////////////////////////////////////////////////////////////
// Helpers
//////////////////////////////////////////////////////////////////////////
-int PuzzleVCR::inPolygon(Common::Point point, int polygonIndex) const {
+int PuzzleVCR::inPolygon(const Common::Point &point, int polygonIndex) const {
return point.x >= puzzleVCRPolygons[polygonIndex].left && point.x <= puzzleVCRPolygons[polygonIndex].right
&& point.y >= puzzleVCRPolygons[polygonIndex].top && point.y <= puzzleVCRPolygons[polygonIndex].bottom;
}
-PuzzleVCR::Color PuzzleVCR::getJackOnHand() {
+PuzzleVCR::Color PuzzleVCR::getJackOnHand() const {
Color jack = kNone;
if (_jacksState[kBlack] == kOnHand)
jack = kBlack;
diff --git a/engines/asylum/puzzles/vcr.h b/engines/asylum/puzzles/vcr.h
index e8356a00f9..879caca17d 100644
--- a/engines/asylum/puzzles/vcr.h
+++ b/engines/asylum/puzzles/vcr.h
@@ -134,8 +134,8 @@ private:
//////////////////////////////////////////////////////////////////////////
// Helpers
//////////////////////////////////////////////////////////////////////////
- int inPolygon(Common::Point point, int polyIdx) const;
- Color getJackOnHand();
+ int inPolygon(const Common::Point &point, int polyIdx) const;
+ Color getJackOnHand() const;
void setJackOnHole(Color hole, JackState state, JackState newState);
void pickJack(Color jack);
diff --git a/engines/asylum/puzzles/wheel.cpp b/engines/asylum/puzzles/wheel.cpp
index 283ba395f5..457305ba22 100644
--- a/engines/asylum/puzzles/wheel.cpp
+++ b/engines/asylum/puzzles/wheel.cpp
@@ -168,7 +168,7 @@ void PuzzleWheel::reset() {
//////////////////////////////////////////////////////////////////////////
// Event Handling
//////////////////////////////////////////////////////////////////////////
-bool PuzzleWheel::init(const AsylumEvent &evt) {
+bool PuzzleWheel::init(const AsylumEvent &) {
getSpecial()->reset(false);
getScreen()->setPalette(getWorld()->graphicResourceIds[1]);
@@ -191,24 +191,24 @@ bool PuzzleWheel::init(const AsylumEvent &evt) {
return true;
}
-bool PuzzleWheel::update(const AsylumEvent &evt) {
+bool PuzzleWheel::update(const AsylumEvent &) {
updateCursor();
getScreen()->clearGraphicsInQueue();
getScreen()->draw(getWorld()->graphicResourceIds[0]);
// Blinking red light
- getScreen()->draw(getWorld()->graphicResourceIds[12], _frameIndexes[11], puzzleWheelPoints[12]);
- _frameIndexes[11] = (_frameIndexes[11] + 1 ) % GraphicResource::getFrameCount(_vm, getWorld()->graphicResourceIds[12]);
+ getScreen()->draw(getWorld()->graphicResourceIds[12], (uint32)_frameIndexes[11], puzzleWheelPoints[12]);
+ _frameIndexes[11] = (_frameIndexes[11] + 1 ) % (int32)GraphicResource::getFrameCount(_vm, getWorld()->graphicResourceIds[12]);
// Clock
if (_showTurnedClock)
- getScreen()->draw(getWorld()->graphicResourceIds[_resourceIndexClock], _frameIndexes[9], Common::Point(342, 87));
+ getScreen()->draw(getWorld()->graphicResourceIds[_resourceIndexClock], (uint32)_frameIndexes[9], Common::Point(342, 87));
else
getScreen()->draw(getWorld()->graphicResourceIds[_resourceIndex + 22], 0, Common::Point(342, 87));
// Chain
- getScreen()->draw(getWorld()->graphicResourceIds[3], _frameIndexes[0], puzzleWheelPoints[3]);
+ getScreen()->draw(getWorld()->graphicResourceIds[3], (uint32)_frameIndexes[0], puzzleWheelPoints[3]);
// Update chain frame index
if (_moveChain) {
@@ -217,7 +217,7 @@ bool PuzzleWheel::update(const AsylumEvent &evt) {
getSound()->playSound(getWorld()->graphicResourceIds[65]);
}
- _frameIndexes[0] = (_frameIndexes[0] + 1) % GraphicResource::getFrameCount(_vm, getWorld()->graphicResourceIds[3]);
+ _frameIndexes[0] = (_frameIndexes[0] + 1) % (int32)GraphicResource::getFrameCount(_vm, getWorld()->graphicResourceIds[3]);
if (!_frameIndexes[0]) {
closeLocks();
@@ -240,7 +240,7 @@ bool PuzzleWheel::update(const AsylumEvent &evt) {
pointIndex = 4 + i;
}
- getScreen()->draw(getWorld()->graphicResourceIds[resourceIndex], _frameIndexes[frameIndex], puzzleWheelPoints[pointIndex]);
+ getScreen()->draw(getWorld()->graphicResourceIds[resourceIndex], (uint32)_frameIndexes[frameIndex], puzzleWheelPoints[pointIndex]);
if (_frameIndexes[frameIndex] != (int32)GraphicResource::getFrameCount(_vm, getWorld()->graphicResourceIds[resourceIndex]) - 1)
++_frameIndexes[frameIndex];
@@ -251,7 +251,7 @@ bool PuzzleWheel::update(const AsylumEvent &evt) {
// Sparks
for (uint32 i = 0; i < 8; i++) {
if (_frameIndexesSparks[i] >= 0) {
- getScreen()->draw(getWorld()->graphicResourceIds[57 + i], _frameIndexesSparks[i], puzzleWheelPoints[48 + i]);
+ getScreen()->draw(getWorld()->graphicResourceIds[57 + i], (uint32)_frameIndexesSparks[i], puzzleWheelPoints[48 + i]);
if (_frameIndexesSparks[i] == (int32)GraphicResource::getFrameCount(_vm, getWorld()->graphicResourceIds[57 + i]) - 1)
_frameIndexesSparks[i] = -1;
@@ -262,9 +262,9 @@ bool PuzzleWheel::update(const AsylumEvent &evt) {
// Lever
if (_resourceIndexLever == 13)
- getScreen()->draw(getWorld()->graphicResourceIds[_resourceIndexLever], _frameIndexes[10], puzzleWheelPoints[13]);
+ getScreen()->draw(getWorld()->graphicResourceIds[_resourceIndexLever], (uint32)_frameIndexes[10], puzzleWheelPoints[13]);
else if (_resourceIndexLever == 54)
- getScreen()->draw(getWorld()->graphicResourceIds[_resourceIndexLever], _frameIndexes[10], puzzleWheelPoints[47]);
+ getScreen()->draw(getWorld()->graphicResourceIds[_resourceIndexLever], (uint32)_frameIndexes[10], puzzleWheelPoints[47]);
// Update lever frame index
if (_moveLever) {
@@ -273,7 +273,7 @@ bool PuzzleWheel::update(const AsylumEvent &evt) {
getSound()->playSound(getWorld()->graphicResourceIds[67]);
}
- _frameIndexes[10] = (_frameIndexes[10] + 1) % GraphicResource::getFrameCount(_vm, getWorld()->graphicResourceIds[_resourceIndexLever]);
+ _frameIndexes[10] = (_frameIndexes[10] + 1) % (int32)GraphicResource::getFrameCount(_vm, getWorld()->graphicResourceIds[_resourceIndexLever]);
if (!_frameIndexes[10]) {
if (_resourceIndexLever == 54) {
@@ -303,7 +303,7 @@ bool PuzzleWheel::update(const AsylumEvent &evt) {
else
_frameIndexWheel = (_frameIndexWheel + frameCountWheel - 1) % frameCountWheel;
- _frameIndexes[9] = (_frameIndexes[9] + 1) % GraphicResource::getFrameCount(_vm, getWorld()->graphicResourceIds[_resourceIndexClock]);
+ _frameIndexes[9] = (_frameIndexes[9] + 1) % (int32)GraphicResource::getFrameCount(_vm, getWorld()->graphicResourceIds[_resourceIndexClock]);
if (!_frameIndexes[9]) {
_showTurnedClock = false;
@@ -323,7 +323,7 @@ bool PuzzleWheel::update(const AsylumEvent &evt) {
return true;
}
-bool PuzzleWheel::mouseLeftDown(const AsylumEvent &evt) {
+bool PuzzleWheel::mouseLeftDown(const AsylumEvent &) {
switch (findRect()) {
default:
break;
@@ -356,7 +356,7 @@ bool PuzzleWheel::mouseLeftDown(const AsylumEvent &evt) {
return true;
}
-bool PuzzleWheel::mouseRightDown(const AsylumEvent &evt) {
+bool PuzzleWheel::mouseRightDown(const AsylumEvent &) {
getScreen()->clear();
_vm->switchEventHandler(getScene());
@@ -420,7 +420,7 @@ void PuzzleWheel::closeLocks() {
void PuzzleWheel::toggleLocks() {
memset(&_frameIndexesSparks, -1, sizeof(_frameIndexesSparks));
- for (uint32 i = 0; i < 3; i++) {
+ for (int32 i = 0; i < 3; i++) {
_vm->toggleGameFlag(puzzleWheelFlags[i + 3 * _resourceIndex]);
// Update lock frame indexes
diff --git a/engines/asylum/puzzles/writings.cpp b/engines/asylum/puzzles/writings.cpp
index 5512c7fcbf..f60c9ff557 100644
--- a/engines/asylum/puzzles/writings.cpp
+++ b/engines/asylum/puzzles/writings.cpp
@@ -47,7 +47,7 @@ PuzzleWritings::~PuzzleWritings() {
//////////////////////////////////////////////////////////////////////////
// Event Handling
//////////////////////////////////////////////////////////////////////////
-bool PuzzleWritings::init(const AsylumEvent &evt) {
+bool PuzzleWritings::init(const AsylumEvent &) {
if (getScene()->getActor()->getField638() == 3)
_hasGlassMagnifier = true;
else
@@ -67,7 +67,7 @@ bool PuzzleWritings::init(const AsylumEvent &evt) {
return false;
}
-bool PuzzleWritings::update(const AsylumEvent &evt) {
+bool PuzzleWritings::update(const AsylumEvent &) {
// Adjust palette
if (rnd(10) < 7) {
getScreen()->setPalette(getWorld()->graphicResourceIds[6]);
@@ -101,7 +101,7 @@ bool PuzzleWritings::update(const AsylumEvent &evt) {
// The original blits part of the background onto the surface (9) and then adds it to the queue
getScreen()->addGraphicToQueueMasked(getWorld()->graphicResourceIds[9], 0, mousePos, getWorld()->graphicResourceIds[8], mousePos, kDrawFlagNone, 2);
- getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[7], _frameIndex, mousePos, kDrawFlagNone, 0, 1);
+ getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[7], (uint32)_frameIndex, mousePos, kDrawFlagNone, 0, 1);
}
getScreen()->drawGraphicsInQueue();
@@ -110,7 +110,7 @@ bool PuzzleWritings::update(const AsylumEvent &evt) {
return true;
}
-bool PuzzleWritings::mouseRightUp(const AsylumEvent &evt) {
+bool PuzzleWritings::mouseRightUp(const AsylumEvent &) {
getCursor()->hide();
getSharedData()->setFlag(kFlag1, true);
getScreen()->stopPaletteFade(0, 0, 0);
Commit: 44540643e8c96a94cb77c455b37c8590f5bf868a
https://github.com/scummvm/scummvm/commit/44540643e8c96a94cb77c455b37c8590f5bf868a
Author: Littleboy (littleboy at scummvm.org)
Date: 2021-05-17T15:37:15+02:00
Commit Message:
ASYLUM: Cleanup base classes
- Made some public members of cursors private and add accessors
- Add const modifiers as needed
- Add missing casts
- Add some null-pointers checks
- etc.
Changed paths:
engines/asylum/asylum.cpp
engines/asylum/console.cpp
engines/asylum/detection.cpp
engines/asylum/puzzles/board.cpp
engines/asylum/puzzles/fisherman.cpp
engines/asylum/puzzles/lock.cpp
engines/asylum/puzzles/morguedoor.cpp
engines/asylum/puzzles/timemachine.cpp
engines/asylum/puzzles/vcr.cpp
engines/asylum/resources/special.cpp
engines/asylum/resources/special.h
engines/asylum/resources/worldstats.h
engines/asylum/staticres.h
engines/asylum/system/config.cpp
engines/asylum/system/config.h
engines/asylum/system/cursor.cpp
engines/asylum/system/cursor.h
engines/asylum/system/sound.cpp
engines/asylum/system/sound.h
engines/asylum/system/speech.cpp
engines/asylum/system/text.cpp
engines/asylum/system/text.h
engines/asylum/views/scene.cpp
engines/asylum/views/scenetitle.cpp
engines/asylum/views/video.cpp
engines/asylum/views/video.h
diff --git a/engines/asylum/asylum.cpp b/engines/asylum/asylum.cpp
index d2e963f2d8..3c5c078952 100644
--- a/engines/asylum/asylum.cpp
+++ b/engines/asylum/asylum.cpp
@@ -274,7 +274,7 @@ void AsylumEngine::playIntro() {
if (!_introPlayed) {
_cursor->hide();
- _cursor->forceHide = true;
+ _cursor->setForceHide(true);
if (!Config.showIntro) {
if (_scene->worldstats()->chapter == kChapter1)
_sound->playMusic(MAKE_RESOURCE(kResourcePackMusic, _scene->worldstats()->musicCurrentResourceIndex));
@@ -306,7 +306,7 @@ void AsylumEngine::playIntro() {
} while (_sound->isPlaying(introSpeech));
}
- _cursor->forceHide = false;
+ _cursor->setForceHide(false);
_introPlayed = true;
}
diff --git a/engines/asylum/console.cpp b/engines/asylum/console.cpp
index a8d079c647..432de925f7 100644
--- a/engines/asylum/console.cpp
+++ b/engines/asylum/console.cpp
@@ -451,7 +451,7 @@ bool Console::cmdRunPuzzle(int32 argc, const char **argv) {
DebugPrintf(" 7 BoardYouth\n");
DebugPrintf(" 8 BoardKeyHidesTo\n");
DebugPrintf(" 9 Writings\n");
- DebugPrintf(" 10 ???\n");
+ DebugPrintf(" 10 Unknown\n");
DebugPrintf(" 11 MorgueDoor\n");
DebugPrintf(" 12 Clock\n");
DebugPrintf(" 13 TimerMachine\n");
diff --git a/engines/asylum/detection.cpp b/engines/asylum/detection.cpp
index 1241bfabc4..7e26762658 100644
--- a/engines/asylum/detection.cpp
+++ b/engines/asylum/detection.cpp
@@ -137,10 +137,6 @@ public:
_guioptions = Common::GUIO_NONE;
}
- virtual const ADGameDescription *fallbackDetect(const FileMap &allFiles, const Common::FSList &fslist) const {
- return detectGameFilebased(allFiles, Asylum::fileBasedFallback);
- }
-
virtual const char *getName() const {
return "Asylum";
}
@@ -150,10 +146,15 @@ public:
}
virtual bool hasFeature(MetaEngineFeature f) const;
- virtual bool createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const;
virtual SaveStateList listSaves(const char *target) const;
virtual int getMaximumSaveSlot() const;
virtual void removeSaveState(const char *target, int slot) const;
+
+protected:
+ virtual bool createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const;
+ virtual const ADGameDescription *fallbackDetect(const FileMap &allFiles, const Common::FSList &) const {
+ return detectGameFilebased(allFiles, Asylum::fileBasedFallback);
+ }
};
bool AsylumMetaEngine::hasFeature(MetaEngineFeature f) const {
@@ -176,18 +177,16 @@ bool AsylumMetaEngine::createInstance(OSystem *syst, Engine **engine, const ADGa
return desc != 0;
}
-SaveStateList AsylumMetaEngine::listSaves(const char *target) const {
- SaveStateList saveList;
-
- return saveList;
+SaveStateList AsylumMetaEngine::listSaves(const char * /*target*/) const {
+ error("[AsylumMetaEngine::listSaves] Not implemented");
}
int AsylumMetaEngine::getMaximumSaveSlot() const {
- return 0;
+ error("[AsylumMetaEngine::getMaximumSaveSlot] Not implemented");
}
-void AsylumMetaEngine::removeSaveState(const char *target, int slot) const {
- // TODO
+void AsylumMetaEngine::removeSaveState(const char * /*target*/, int /*slot*/) const {
+ error("[AsylumMetaEngine::removeSaveState] Not implemented");
}
#if PLUGIN_ENABLED_DYNAMIC(ASYLUM)
diff --git a/engines/asylum/puzzles/board.cpp b/engines/asylum/puzzles/board.cpp
index 512cc89b48..fae8416a89 100644
--- a/engines/asylum/puzzles/board.cpp
+++ b/engines/asylum/puzzles/board.cpp
@@ -217,14 +217,14 @@ void PuzzleBoard::updateCursor() {
int32 index = findRect();
if (index == -1) {
- if (getCursor()->graphicResourceId == getWorld()->graphicResourceIds[34])
+ if (getCursor()->getResourceId() == getWorld()->graphicResourceIds[34])
return;
_rectIndex = index;
getCursor()->set(getWorld()->graphicResourceIds[34]);
} else {
- if (getCursor()->graphicResourceId == getWorld()->graphicResourceIds[33])
+ if (getCursor()->getResourceId() == getWorld()->graphicResourceIds[33])
return;
if (index == _rectIndex)
@@ -236,14 +236,14 @@ void PuzzleBoard::updateCursor() {
}
} else {
if (_vm->isGameFlagSet(_data.gameFlag)) {
- if (getCursor()->graphicResourceId == getWorld()->graphicResourceIds[34])
+ if (getCursor()->getResourceId() == getWorld()->graphicResourceIds[34])
return;
getCursor()->set(getWorld()->graphicResourceIds[34]);
} else {
int32 index = checkMouse();
- if (getCursor()->graphicResourceId == getWorld()->graphicResourceIds[33])
+ if (getCursor()->getResourceId() == getWorld()->graphicResourceIds[33])
return;
if (index == _rectIndex)
diff --git a/engines/asylum/puzzles/fisherman.cpp b/engines/asylum/puzzles/fisherman.cpp
index 586c747928..1bd939aaec 100644
--- a/engines/asylum/puzzles/fisherman.cpp
+++ b/engines/asylum/puzzles/fisherman.cpp
@@ -185,7 +185,7 @@ void PuzzleFisherman::updateCursor() {
if (!_state[i]) {
found = true;
- if (getCursor()->animation != kCursorAnimationMirror)
+ if (getCursor()->getAnimation() != kCursorAnimationMirror)
getCursor()->set(getWorld()->graphicResourceIds[47], -1, kCursorAnimationMirror, 7);
}
}
@@ -198,9 +198,9 @@ void PuzzleFisherman::updateCursor() {
|| puzzleFishermanPolygons[6].y >= mousePos.y
|| puzzleFishermanPolygons[6].x + 70 <= mousePos.x
|| puzzleFishermanPolygons[6].y + 30 <= mousePos.y) {
- if (getCursor()->animation != kCursorAnimationNone)
+ if (getCursor()->getAnimation() != kCursorAnimationNone)
getCursor()->set(getWorld()->graphicResourceIds[47], -1, kCursorAnimationNone, 7);
- else if (getCursor()->animation != kCursorAnimationMirror)
+ else if (getCursor()->getAnimation() != kCursorAnimationMirror)
getCursor()->set(getWorld()->graphicResourceIds[47], -1, kCursorAnimationMirror, 7);
}
}
diff --git a/engines/asylum/puzzles/lock.cpp b/engines/asylum/puzzles/lock.cpp
index eb3112a101..491e040744 100644
--- a/engines/asylum/puzzles/lock.cpp
+++ b/engines/asylum/puzzles/lock.cpp
@@ -226,14 +226,14 @@ void PuzzleLock::updateCursor() {
for (uint32 i = 0; i < 6; i++) {
if (hitTest(&puzzleLockPolygons[0], mousePos, 2 * i)) {
- if (getCursor()->animation != kCursorAnimationMirror)
+ if (getCursor()->getAnimation() != kCursorAnimationMirror)
getCursor()->set(getWorld()->graphicResourceIds[41]);
return ;
}
}
- if (getCursor()->animation == kCursorAnimationMirror)
+ if (getCursor()->getAnimation() == kCursorAnimationMirror)
getCursor()->set(getWorld()->graphicResourceIds[41], 0, kCursorAnimationNone);
}
diff --git a/engines/asylum/puzzles/morguedoor.cpp b/engines/asylum/puzzles/morguedoor.cpp
index 5cb44319d0..37e971175a 100644
--- a/engines/asylum/puzzles/morguedoor.cpp
+++ b/engines/asylum/puzzles/morguedoor.cpp
@@ -234,10 +234,10 @@ void PuzzleMorgueDoor::updateCursor() {
// Default cursor
if (animate) {
- if (getCursor()->animation != kCursorAnimationMirror) {
+ if (getCursor()->getAnimation() != kCursorAnimationMirror) {
getCursor()->set(getWorld()->graphicResourceIds[33], -1, kCursorAnimationMirror, 7);
}
- } else if (getCursor()->animation != kCursorAnimationNone) {
+ } else if (getCursor()->getAnimation() != kCursorAnimationNone) {
getCursor()->set(getWorld()->graphicResourceIds[33], -1, kCursorAnimationNone, 7);
}
}
diff --git a/engines/asylum/puzzles/timemachine.cpp b/engines/asylum/puzzles/timemachine.cpp
index ea6b75b679..e222619054 100644
--- a/engines/asylum/puzzles/timemachine.cpp
+++ b/engines/asylum/puzzles/timemachine.cpp
@@ -260,14 +260,14 @@ bool PuzzleTimeMachine::mouseRightDown(const AsylumEvent &) {
void PuzzleTimeMachine::updateCursor() {
for (uint32 i = 0; i < ARRAYSIZE(puzzleTimeMachineRects); i++) {
if (puzzleTimeMachineRects[i].contains(getCursor()->position())) {
- if (getCursor()->animation != kCursorAnimationMirror)
+ if (getCursor()->getAnimation() != kCursorAnimationMirror)
getCursor()->set(getWorld()->graphicResourceIds[62], -1, kCursorAnimationMirror, 7);
return;
}
}
- if (getCursor()->animation)
+ if (getCursor()->getAnimation())
getCursor()->set(getWorld()->graphicResourceIds[62], -1, kCursorAnimationNone, 7);
}
diff --git a/engines/asylum/puzzles/vcr.cpp b/engines/asylum/puzzles/vcr.cpp
index cb949bf308..5201958204 100644
--- a/engines/asylum/puzzles/vcr.cpp
+++ b/engines/asylum/puzzles/vcr.cpp
@@ -360,15 +360,15 @@ void PuzzleVCR::updateCursor() {
|| inPolygon(mousePos, kBlackJack)
|| inPolygon(mousePos, kRedJack)
|| inPolygon(mousePos, kYellowJack)) {
- if (getCursor()->animation != kCursorAnimationMirror)
+ if (getCursor()->getAnimation() != kCursorAnimationMirror)
getCursor()->set(getWorld()->graphicResourceIds[28]);
} else if ((inPolygon(mousePos, kRedHole) && _holesState[kBlack])
|| (inPolygon(mousePos, kYellowHole) && _holesState[kRed])
|| (inPolygon(mousePos, kBlackHole) && _holesState[kYellow])) {
- if (getCursor()->animation != kCursorAnimationMirror)
+ if (getCursor()->getAnimation() != kCursorAnimationMirror)
getCursor()->set(getWorld()->graphicResourceIds[28]);
} else {
- if (getCursor()->animation)
+ if (getCursor()->getAnimation())
getCursor()->set(getWorld()->graphicResourceIds[28], kCursorAnimationNone);
}
} else {
diff --git a/engines/asylum/resources/special.cpp b/engines/asylum/resources/special.cpp
index f4a1ea6486..7ae62b4d0b 100644
--- a/engines/asylum/resources/special.cpp
+++ b/engines/asylum/resources/special.cpp
@@ -251,14 +251,14 @@ void Special::chapter2(Object *object, ActorIndex actorIndex) {
Actor *refActor = getScene()->getActor(actorIndex - 9); // Original uses offset to object array (+ offset to actor).
*actor->getPoint1() = *refActor->getPoint1();
- actor->getPoint1()->y += getSharedData()->getChapter2Data(2, actorIndex - 22); // cursorResources + 30
+ actor->getPoint1()->y += (int16)getSharedData()->getChapter2Data(2, actorIndex - 22); // cursorResources + 30
actor->setFrameIndex(refActor->getFrameIndex());
actor->setDirection(refActor->getDirection());
// Get the resource Id
Actor *actor13 = getScene()->getActor(13);
int32 direction = (actor13->getDirection() > kDirectionS) ? 8 - actor13->getDirection() : actor13->getDirection();
- ResourceId id = actor->getResourcesId(actorIndex + direction);
+ ResourceId id = actor->getResourcesId((uint32)(actorIndex + direction));
actor->setResourceId(id);
}
@@ -1290,8 +1290,8 @@ void Special::playSoundPanning(ResourceId resourceId, int32 attenuation, Object
default: {
Common::Rect frameRect = GraphicResource::getFrameRect(_vm, object->getResourceId(), object->getFrameIndex());
- point.x = Common::Rational(frameRect.width(), 2).toInt() + object->x;
- point.y = Common::Rational(frameRect.height(), 2).toInt() + object->y;
+ point.x = (int16)(Common::Rational(frameRect.width(), 2).toInt() + object->x);
+ point.y = (int16)(Common::Rational(frameRect.height(), 2).toInt() + object->y);
}
break;
@@ -1425,7 +1425,7 @@ ResourceId Special::getResourceId(Object *object, ActorIndex actorIndex) {
return (actorIndex == kActorInvalid) ? object->getSoundResourceId() : getScene()->getActor(actorIndex)->getSoundResourceId();
}
-int32 Special::getCounter(ActorIndex index) {
+uint32 Special::getCounter(ActorIndex index) const {
switch (index) {
default:
error("[Special::getCounter] Invalid actor index (was: %d, valid: 13, 15, 17, 18)", index);
diff --git a/engines/asylum/resources/special.h b/engines/asylum/resources/special.h
index 02ab9b0f95..cd01129691 100644
--- a/engines/asylum/resources/special.h
+++ b/engines/asylum/resources/special.h
@@ -92,7 +92,7 @@ private:
// Helpers
//////////////////////////////////////////////////////////////////////////
ResourceId getResourceId(Object *object, ActorIndex actorIndex);
- int32 getCounter(ActorIndex index);
+ uint32 getCounter(ActorIndex index) const;
void checkObject(Object *object, GameFlag flagToSet, GameFlag flagToClear, ObjectId objectId = kObjectInvalid);
void checkOtherObject(Object *object, ObjectId otherObjectId, GameFlag flagToClear, GameFlag flagToSet);
diff --git a/engines/asylum/resources/worldstats.h b/engines/asylum/resources/worldstats.h
index 7a1afa0870..acb9f43754 100644
--- a/engines/asylum/resources/worldstats.h
+++ b/engines/asylum/resources/worldstats.h
@@ -85,7 +85,7 @@ public:
ResourceId font1;
ResourceId font2;
ResourceId font3;
- int32 currentPaletteId;
+ ResourceId currentPaletteId;
int32 cellShadeMask1;
int32 cellShadeMask2;
int32 cellShadeMask3;
diff --git a/engines/asylum/staticres.h b/engines/asylum/staticres.h
index 1bed1a9870..4334d0ab3b 100644
--- a/engines/asylum/staticres.h
+++ b/engines/asylum/staticres.h
@@ -55,8 +55,8 @@ const int chapterIndexes[16] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 4, 4, 8, 9, 0, 0};
const int actorType[16] = {0, 0, 0, 0, 1, 0, 2, 0, 3, 0, 1, 1, 3, 0, 0, 0};
/** Speech indexes */
-const int speechIndex[20] = {17, 22, 27, 37, 45, 12, 16, 19, 25, 29, 14, 18, 23, 29, 35, 6, 9, 13, 19, 27};
-const int speechIndexRandom[20] = { 5, 5, 10, 8, 6, 4, 3, 6, 4, 4, 4, 5, 6, 6, 6, 3, 4, 6, 8, 4};
+const uint speechIndex[20] = {17, 22, 27, 37, 45, 12, 16, 19, 25, 29, 14, 18, 23, 29, 35, 6, 9, 13, 19, 27};
+const uint speechIndexRandom[20] = { 5, 5, 10, 8, 6, 4, 3, 6, 4, 4, 4, 5, 6, 6, 6, 3, 4, 6, 8, 4};
/** Encounter indexes */
const int encounterPortrait1Index[16] = {-1, 36, 20, 31, 1, 37, 7, 0, 0, 0, 1, 2, 3, 0, 0, 0};
diff --git a/engines/asylum/system/config.cpp b/engines/asylum/system/config.cpp
index cb2221e8d8..4af6fda0e2 100644
--- a/engines/asylum/system/config.cpp
+++ b/engines/asylum/system/config.cpp
@@ -157,7 +157,7 @@ void ConfigurationManager::write() {
ConfMan.flushToDisk();
}
-bool ConfigurationManager::isKeyAssigned(char key) {
+bool ConfigurationManager::isKeyAssigned(char key) const {
return (keyShowVersion == key || keyQuickLoad == key || keyQuickSave == key || keySwitchToSara == key || keySwitchToGrimwall == key || keySwitchToOlmec == key);
}
diff --git a/engines/asylum/system/config.h b/engines/asylum/system/config.h
index d9bb15142a..7cb7eea214 100644
--- a/engines/asylum/system/config.h
+++ b/engines/asylum/system/config.h
@@ -92,7 +92,7 @@ public:
*
* @return true if key assigned, false if not.
*/
- bool isKeyAssigned(char key);
+ bool isKeyAssigned(char key) const;
private:
friend class Common::Singleton<SingletonBaseType>;
diff --git a/engines/asylum/system/cursor.cpp b/engines/asylum/system/cursor.cpp
index eea1aa6438..03f425caf4 100644
--- a/engines/asylum/system/cursor.cpp
+++ b/engines/asylum/system/cursor.cpp
@@ -33,9 +33,9 @@ namespace Asylum {
const uint32 CURSOR_UPDATE_TICKS = 100;
Cursor::Cursor(AsylumEngine *engine) : _vm(engine),
- graphicResourceId(kResourceNone), currentFrame(0), lastFrameIndex(0), counter(0), animation(kCursorAnimationNone),
- _cursorRes(NULL), _nextTick(0), _frameStep(0), _state(0), forceHide(false) {
-
+ _state(0), _cursorRes(NULL), _nextTick(0), _frameStep(0),
+ _graphicResourceId(kResourceNone), _currentFrame(0), _lastFrameIndex(0), _counter(0), _animation(kCursorAnimationNone),
+ _forceHide(false) {
}
Cursor::~Cursor() {
@@ -50,7 +50,7 @@ void Cursor::hide() const {
}
void Cursor::show() const {
- if (!forceHide)
+ if (!_forceHide)
CursorMan.showMouse(true);
}
@@ -65,24 +65,24 @@ void Cursor::set(ResourceId resourceId, int32 cnt, CursorAnimation anim, int32 f
// Get frame count
if (frames >= 0)
- lastFrameIndex = frames;
+ _lastFrameIndex = (uint32)frames;
else
- lastFrameIndex = _cursorRes->count() - 1;
+ _lastFrameIndex = _cursorRes->count() - 1;
- this->graphicResourceId = resourceId;
- this->animation = anim;
- this->counter = cnt;
- currentFrame = 0;
+ this->_graphicResourceId = resourceId;
+ this->_animation = anim;
+ this->_counter = cnt;
+ _currentFrame = 0;
_frameStep = 1;
// Do not animate if no frames (and the other way around)
- if (lastFrameIndex == 0 || anim == kCursorAnimationNone) {
- lastFrameIndex = 0;
- animation = kCursorAnimationNone;
+ if (_lastFrameIndex == 0 || anim == kCursorAnimationNone) {
+ _lastFrameIndex = 0;
+ _animation = kCursorAnimationNone;
}
- if (lastFrameIndex >= _cursorRes->count())
- lastFrameIndex = _cursorRes->count() - 1;
+ if (_lastFrameIndex >= _cursorRes->count())
+ _lastFrameIndex = _cursorRes->count() - 1;
update();
@@ -93,9 +93,9 @@ void Cursor::update() {
if (!_cursorRes)
error("[Cursor::update] Cursor resources not initialized properly!");
- Common::Point hotspot = getHotspot(currentFrame);
+ Common::Point hotspot = getHotspot(_currentFrame);
- GraphicFrame *frame = _cursorRes->getFrame(currentFrame);
+ GraphicFrame *frame = _cursorRes->getFrame(_currentFrame);
CursorMan.replaceCursor((byte *)frame->surface.pixels,
frame->surface.w,
frame->surface.h,
@@ -136,33 +136,33 @@ void Cursor::setState(const Common::Event &evt) {
}
void Cursor::animate() {
- if (isHidden() || !animation || _nextTick > _vm->getTick())
+ if (isHidden() || !_animation || _nextTick > _vm->getTick())
return;
bool notifyHandler = false;
int32 frame = 0;
- if (animation == kCursorAnimationLinear) {
- if (currentFrame == lastFrameIndex) {
- currentFrame = frame = 0;
+ if (_animation == kCursorAnimationLinear) {
+ if (_currentFrame == _lastFrameIndex) {
+ _currentFrame = frame = 0;
} else {
- currentFrame += _frameStep;
- frame = currentFrame;
+ _currentFrame += _frameStep;
+ frame = _currentFrame;
}
- } else if (animation == kCursorAnimationMirror) {
- currentFrame += _frameStep;
- frame = currentFrame;
+ } else if (_animation == kCursorAnimationMirror) {
+ _currentFrame += _frameStep;
+ frame = _currentFrame;
- if (currentFrame == 0 || currentFrame == lastFrameIndex)
+ if (_currentFrame == 0 || _currentFrame == _lastFrameIndex)
_frameStep = -_frameStep;
}
if (frame == 0) {
- if (counter != -1) {
- --counter;
+ if (_counter != -1) {
+ --_counter;
- if (!counter) {
- animation = kCursorAnimationNone;
+ if (!_counter) {
+ _animation = kCursorAnimationNone;
notifyHandler = true;
}
}
@@ -177,15 +177,17 @@ void Cursor::animate() {
}
Common::Point Cursor::getHotspot(uint32 frameIndex) {
- Common::Point point;
+ if (!_cursorRes)
+ error("[Cursor::getHotspot] Cursor resource not initialized properly");
+ Common::Point point;
uint32 resFlags = _cursorRes->getData().flags;
if (BYTE1(resFlags) & 0x10) {
// XXX removed a check for frameIndex >= 0 as it will always
// evaluate to true since frameIndex is unsigned
if (frameIndex > _cursorRes->count()) {
- GraphicFrame *frame = _cursorRes->getFrame(currentFrame);
+ GraphicFrame *frame = _cursorRes->getFrame(_currentFrame);
point.x = frame->x;
point.y = frame->y;
diff --git a/engines/asylum/system/cursor.h b/engines/asylum/system/cursor.h
index 576ca71e92..9feecfe821 100644
--- a/engines/asylum/system/cursor.h
+++ b/engines/asylum/system/cursor.h
@@ -88,37 +88,18 @@ public:
*/
void animate();
+ // Accessors
void setState(const Common::Event &evt);
byte getState() { return _state; }
+ void setForceHide(bool state) { _forceHide = state; }
+ ResourceId getResourceId() { return _graphicResourceId; }
+ CursorAnimation getAnimation() { return _animation; }
/**
* Return the cursor's position on the screen
*/
const Common::Point position() const;
- // NOTE: The original engine contains a function that assigns global variables to a
- // struct associated with cursor graphics info. Since this functionality only
- // ever seems to be used to reference cursor info, the struct members
- // may as well be class members in order to simplify the logic a bit
-
- ResourceId graphicResourceId;
- uint32 currentFrame;
- uint32 lastFrameIndex;
- int32 counter;
- CursorAnimation animation;
-
- /**
- * Since the cursor is updated by various event handlers, if an action is
- * currently being processed that requires the cursor to remain hidden, another
- * event may override that request and show the cursor regardless
- *
- * This is currently used during the intro speech in Scene 1 after the intro
- * video plays
- *
- * @default false
- */
- bool forceHide;
-
private:
AsylumEngine *_vm;
@@ -138,6 +119,28 @@ private:
int32 _frameStep;
+ // NOTE: The original engine contains a function that assigns global variables to a
+ // struct associated with cursor graphics info. Since this functionality only
+ // ever seems to be used to reference cursor info, the struct members
+ // may as well be class members in order to simplify the logic a bit
+ ResourceId _graphicResourceId;
+ uint32 _currentFrame;
+ uint32 _lastFrameIndex;
+ int32 _counter;
+ CursorAnimation _animation;
+
+ /**
+ * Since the cursor is updated by various event handlers, if an action is
+ * currently being processed that requires the cursor to remain hidden, another
+ * event may override that request and show the cursor regardless
+ *
+ * This is currently used during the intro speech in Scene 1 after the intro
+ * video plays
+ *
+ * @default false
+ */
+ bool _forceHide;
+
/**
* Updates the cursor
*/
diff --git a/engines/asylum/system/sound.cpp b/engines/asylum/system/sound.cpp
index 6f12143817..f6db9554b6 100644
--- a/engines/asylum/system/sound.cpp
+++ b/engines/asylum/system/sound.cpp
@@ -182,15 +182,15 @@ int32 Sound::calculateVolumeAdjustement(const Common::Point &point, int32 attenu
return -volume;
}
-int32 Sound::getAdjustedVolume(int32 volume) {
+int32 Sound::getAdjustedVolume(int32 volume) const {
if (volume < 2)
return volume;
uint32 counter = (uint32)(log((double)volume) / log(2.0)) / 2;
- int32 adjustedVolume = pow(2.0, (int32)counter);
+ uint32 adjustedVolume = (uint32)pow(2.0, (int32)counter);
uint32 offset = adjustedVolume;
- int32 base = adjustedVolume << counter;
+ uint32 base = adjustedVolume << counter;
for (;;) {
--counter;
@@ -198,9 +198,9 @@ int32 Sound::getAdjustedVolume(int32 volume) {
break;
offset /= 2;
- int32 val = base + ((offset + 2 * volume) << counter);
+ uint32 val = base + ((offset + 2 * (uint32)volume) << counter);
- if (val <= volume) {
+ if (val <= (uint32)volume) {
adjustedVolume += offset;
base = val;
}
@@ -363,7 +363,7 @@ void Sound::convertVolumeFrom(int32 &vol) {
}
void Sound::convertVolumeTo(int32 &vol) {
- vol = (log10(vol / (double)Audio::Mixer::kMaxChannelVolume) - 0.5) * 2000;
+ vol = (int32)(log10(vol / (double)Audio::Mixer::kMaxChannelVolume) - 0.5) * 2000;
}
void Sound::convertPan(int32 &pan) {
diff --git a/engines/asylum/system/sound.h b/engines/asylum/system/sound.h
index 6e4f6d05ec..f6867d4082 100644
--- a/engines/asylum/system/sound.h
+++ b/engines/asylum/system/sound.h
@@ -196,7 +196,7 @@ public:
*
* @return The adjusted volume.
*/
- int32 getAdjustedVolume(int32 volume);
+ int32 getAdjustedVolume(int32 volume) const;
/**
* Calculates the panning at point.
diff --git a/engines/asylum/system/speech.cpp b/engines/asylum/system/speech.cpp
index e5d9baecfe..5bbe3eef2d 100644
--- a/engines/asylum/system/speech.cpp
+++ b/engines/asylum/system/speech.cpp
@@ -66,7 +66,7 @@ ResourceId Speech::playIndexed(int32 index) {
int processedIndex;
if (getWorld()->actorType || index != -1) {
- processedIndex = speechIndex[index + 5 * getWorld()->actorType] + rnd(speechIndexRandom[index + 5 * getWorld()->actorType]);
+ processedIndex = (int)speechIndex[index + 5 * getWorld()->actorType] + (int)rnd(speechIndexRandom[index + 5 * getWorld()->actorType]);
} else {
switch(_vm->getRandom(3)) {
default:
@@ -239,7 +239,7 @@ void Speech::prepareSpeech() {
Actor *actor = getScene()->getActor();
actor->adjustCoordinates(&point);
- int32 posY = (((point.y >= 240) - 1) & 280) + 40;
+ int32 posY = (point.y >= 240) ? 40 : 320;
getText()->draw(_textDataPos, getWorld()->font3, posY);
getText()->draw(_textData, getWorld()->font1, posY);
diff --git a/engines/asylum/system/text.cpp b/engines/asylum/system/text.cpp
index 4f2b7e7b1f..01094c15b2 100644
--- a/engines/asylum/system/text.cpp
+++ b/engines/asylum/system/text.cpp
@@ -66,18 +66,22 @@ void Text::setPosition(const Common::Point &point) {
_position = point;
}
-int32 Text::getWidth(char c) {
+uint16 Text::getWidth(char c) {
+ if (!_fontResource)
+ error("[Text::getWidth] Font not initialized properly");
+
GraphicFrame *font = _fontResource->getFrame((uint8)c);
return font->surface.w + font->x - _curFontFlags;
}
-int32 Text::getWidth(const char *text) {
+uint16 Text::getWidth(const char *text) {
if (!_fontResource)
error("[Text::getWidth] font resource hasn't been loaded yet!");
- int32 width = 0;
+ uint16 width = 0;
char character = *text;
+
while (character) {
GraphicFrame *font = _fontResource->getFrame((uint8)character);
width += font->surface.w + font->x - _curFontFlags;
@@ -85,18 +89,20 @@ int32 Text::getWidth(const char *text) {
text++;
character = *text;
}
+
return width;
}
-int32 Text::getWidth(const char *text, uint32 length) {
+uint16 Text::getWidth(const char *text, uint32 length) {
if (!_fontResource)
error("[Text::getWidth] font resource hasn't been loaded yet!");
if (length == 0)
return 0;
- int32 width = 0;
+ uint16 width = 0;
char character = *text;
+
while (character && length > 0) {
GraphicFrame *font = _fontResource->getFrame((uint8)character);
width += font->surface.w + font->x - _curFontFlags;
@@ -105,10 +111,11 @@ int32 Text::getWidth(const char *text, uint32 length) {
character = *text;
length--;
}
+
return width;
}
-int32 Text::getWidth(ResourceId resourceId) {
+uint16 Text::getWidth(ResourceId resourceId) {
return getWidth(get(resourceId));
}
@@ -158,8 +165,8 @@ void Text::draw(ResourceId resourceId) {
}
void Text::draw(const Common::Point &point, const char *text) {
- setPosition(Common::Point(point.x - getWidth(text), point.y));
- draw(text);
+ setPosition(Common::Point(point.x - (int16)getWidth(text), point.y));
+ draw(text);
}
void Text::draw(const Common::Point &point, ResourceId resourceId) {
@@ -173,17 +180,17 @@ void Text::draw(const char *text, ResourceId fontResourceId, int32 y) {
}
}
-uint32 Text::draw(TextCentering centering, const Common::Point &point, int32 spacing, int32 width, const char *text) {
+int16 Text::draw(TextCentering centering, const Common::Point &point, int16 spacing, int16 width, const char *text) {
return draw(0, 99, centering, point, spacing, width, text);
}
-uint32 Text::draw(int32 a1, int32 a2, TextCentering centering, const Common::Point &point, int32 spacing, int32 width, const char *text) {
+int16 Text::draw(int32 a1, int32 a2, TextCentering centering, const Common::Point &point, int16 spacing, int16 width, const char *text) {
if (!text || !*text)
return 0;
Common::Point coords = point;
- uint32 printed = 0;
+ int16 printed = 0;
bool drawText = false;
int32 spaceWidth = 0;
int32 index = 0;
@@ -212,7 +219,7 @@ label_start:
case kTextNormal:
setPosition(coords);
- draw(text, endText - text);
+ draw(text, (uint32)(endText - text));
break;
}
@@ -285,17 +292,17 @@ label_start:
return printed;
}
-void Text::drawCentered(const Common::Point &point, int32 width, const char *text) {
+void Text::drawCentered(const Common::Point &point, int16 width, const char *text) {
setPosition(Common::Point(point.x + (width - getWidth(text)) / 2, point.y));
draw(text);
}
-void Text::drawCentered(const Common::Point &point, int32 width, uint32 length, const char *text) {
+void Text::drawCentered(const Common::Point &point, int16 width, int16 length, const char *text) {
setPosition(Common::Point(point.x + (width - getWidth(text, length)) / 2, point.y));
draw(text, length);
}
-void Text::drawCentered(const Common::Point &point, int32 width, ResourceId resourceId) {
+void Text::drawCentered(const Common::Point &point, int16 width, ResourceId resourceId) {
drawCentered(point, width, get(resourceId));
}
diff --git a/engines/asylum/system/text.h b/engines/asylum/system/text.h
index 809d092ea6..27128119be 100644
--- a/engines/asylum/system/text.h
+++ b/engines/asylum/system/text.h
@@ -48,11 +48,11 @@ public:
ResourceId loadFont(ResourceId resourceId);
void setPosition(const Common::Point &point);
- int32 getWidth(char c);
- int32 getWidth(const char *text);
- int32 getWidth(const char *text, uint32 length);
- int32 getWidth(ResourceId resourceId);
- char *get(ResourceId resourceId);
+ uint16 getWidth(char c);
+ uint16 getWidth(const char *text);
+ uint16 getWidth(const char *text, uint32 length);
+ uint16 getWidth(ResourceId resourceId);
+ char *get(ResourceId resourceId);
void drawChar(char character);
void draw(const char *text);
@@ -61,12 +61,12 @@ public:
void draw(const Common::Point &point, ResourceId resourceId);
void draw(const char *text, ResourceId fontResourceId, int32 y);
void draw(const char *text, uint32 length);
- uint32 draw(TextCentering centering, const Common::Point &point, int32 spacing, int32 width, const char *text);
- uint32 draw(int32 a1, int32 a2, TextCentering centering, const Common::Point &point, int32 spacing, int32 width, const char *text);
+ int16 draw(TextCentering centering, const Common::Point &point, int16 spacing, int16 width, const char *text);
+ int16 draw(int32 a1, int32 a2, TextCentering centering, const Common::Point &point, int16 spacing, int16 width, const char *text);
- void drawCentered(const Common::Point &point, int32 width, const char *text);
- void drawCentered(const Common::Point &point, int32 width, ResourceId resourceId);
- void drawCentered(const Common::Point &point, int32 width, uint32 length, const char *text);
+ void drawCentered(const Common::Point &point, int16 width, const char *text);
+ void drawCentered(const Common::Point &point, int16 width, ResourceId resourceId);
+ void drawCentered(const Common::Point &point, int16 width, int16 length, const char *text);
void setTransTableNum(int32 val) { _transTableNum = val; }
diff --git a/engines/asylum/views/scene.cpp b/engines/asylum/views/scene.cpp
index eca7a8b649..da6e321de6 100644
--- a/engines/asylum/views/scene.cpp
+++ b/engines/asylum/views/scene.cpp
@@ -1124,7 +1124,7 @@ void Scene::updateCursor(ActorDirection direction, Common::Rect rect) {
Common::Point mouse = getCursor()->position();
if (getEncounter()->isRunning()) {
- if (getCursor()->graphicResourceId != _ws->cursorResources[kCursorResourceTalkNPC])
+ if (getCursor()->getResourceId() != _ws->cursorResources[kCursorResourceTalkNPC])
getCursor()->set(_ws->cursorResources[kCursorResourceTalkNPC]);
return;
@@ -1135,7 +1135,7 @@ void Scene::updateCursor(ActorDirection direction, Common::Rect rect) {
ResourceId resourceId =_ws->cursorResources[direction];
- if (direction >= kDirectionN && getCursor()->graphicResourceId != resourceId)
+ if (direction >= kDirectionN && getCursor()->getResourceId() != resourceId)
getCursor()->set(resourceId);
}
@@ -1143,7 +1143,7 @@ void Scene::updateCursor(ActorDirection direction, Common::Rect rect) {
}
if (player->getStatus() == kActorStatus6 || player->getStatus() == kActorStatus10) {
- if (getCursor()->graphicResourceId != _ws->cursorResources[kCursorResourceHand])
+ if (getCursor()->getResourceId() != _ws->cursorResources[kCursorResourceHand])
getCursor()->set(_ws->cursorResources[kCursorResourceHand]);
return;
@@ -1153,18 +1153,18 @@ void Scene::updateCursor(ActorDirection direction, Common::Rect rect) {
if (mouse.x >= rect.left && mouse.x <= rightLimit && mouse.y >= rect.top && mouse.y <= rect.bottom && hitTestPlayer()) {
ResourceId id = _ws->cursorResourcesAlternate[player->getField638() + 31];
- if (getCursor()->graphicResourceId != id)
+ if (getCursor()->getResourceId() != id)
getCursor()->set(id, 0, kCursorAnimationNone);
} else {
if (hitTestScene(type) == -1) {
ResourceId id = _ws->cursorResourcesAlternate[player->getField638() + 31];
- if (getCursor()->graphicResourceId != id)
+ if (getCursor()->getResourceId() != id)
getCursor()->set(id, 0, kCursorAnimationNone);
} else {
ResourceId id = _ws->cursorResourcesAlternate[player->getField638() + 47];
uint32 frameCount = GraphicResource::getFrameCount(_vm, id);
- if (getCursor()->graphicResourceId != id)
+ if (getCursor()->getResourceId() != id)
getCursor()->set(id, 0, (CursorAnimation)(((frameCount <= 1) - 1) & 2));
}
}
@@ -1174,7 +1174,7 @@ void Scene::updateCursor(ActorDirection direction, Common::Rect rect) {
if (mouse.x >= rect.left && mouse.x <= rightLimit && mouse.y >= rect.top && mouse.y <= rect.bottom && hitTestPlayer()) {
if (player->getReactionValue(0)) {
- if (getCursor()->graphicResourceId != _ws->cursorResources[kCursorResourceGrabPointer])
+ if (getCursor()->getResourceId() != _ws->cursorResources[kCursorResourceGrabPointer])
getCursor()->set(_ws->cursorResources[kCursorResourceGrabPointer]);
return;
@@ -1184,10 +1184,10 @@ void Scene::updateCursor(ActorDirection direction, Common::Rect rect) {
int32 index = hitTest(type);
if (index == -1) {
if (_ws->chapter != kChapter2 || _playerIndex != 10) {
- if (getCursor()->graphicResourceId != _ws->cursorResources[kCursorResourceMagnifyingGlass] || getCursor()->animation)
+ if (getCursor()->getResourceId() != _ws->cursorResources[kCursorResourceMagnifyingGlass] || getCursor()->getAnimation())
getCursor()->set(_ws->cursorResources[kCursorResourceMagnifyingGlass]);
} else {
- if (getCursor()->graphicResourceId != _ws->cursorResources[kCursorResourceTalkNPC2] || getCursor()->animation)
+ if (getCursor()->getResourceId() != _ws->cursorResources[kCursorResourceTalkNPC2] || getCursor()->getAnimation())
getCursor()->set(_ws->cursorResources[kCursorResourceTalkNPC2]);
}
@@ -1214,22 +1214,22 @@ void Scene::updateCursor(ActorDirection direction, Common::Rect rect) {
}
if (actionType & kActionTypeFind) {
- if (getCursor()->graphicResourceId != _ws->cursorResources[kCursorResourceMagnifyingGlass] || getCursor()->animation != kCursorAnimationMirror)
+ if (getCursor()->getResourceId() != _ws->cursorResources[kCursorResourceMagnifyingGlass] || getCursor()->getAnimation() != kCursorAnimationMirror)
getCursor()->set(_ws->cursorResources[kCursorResourceMagnifyingGlass]);
} else if (actionType & kActionTypeTalk) {
- if (getCursor()->graphicResourceId != _ws->cursorResources[kCursorResourceTalkNPC])
+ if (getCursor()->getResourceId() != _ws->cursorResources[kCursorResourceTalkNPC])
getCursor()->set(_ws->cursorResources[kCursorResourceTalkNPC]);
} else if (actionType & kActionTypeGrab) {
- if (getCursor()->graphicResourceId != _ws->cursorResources[kCursorResourceHand])
+ if (getCursor()->getResourceId() != _ws->cursorResources[kCursorResourceHand])
getCursor()->set(_ws->cursorResources[kCursorResourceHand]);
} else if (actionType & kActionType16) {
- if (getCursor()->graphicResourceId != _ws->cursorResources[kCursorResourceTalkNPC2] || getCursor()->animation != kCursorAnimationMirror)
+ if (getCursor()->getResourceId() != _ws->cursorResources[kCursorResourceTalkNPC2] || getCursor()->getAnimation() != kCursorAnimationMirror)
getCursor()->set(_ws->cursorResources[kCursorResourceTalkNPC2]);
} else if (_ws->chapter != kChapter2 && _playerIndex != 10) {
- if (getCursor()->graphicResourceId != _ws->cursorResources[kCursorResourceMagnifyingGlass] || getCursor()->animation)
+ if (getCursor()->getResourceId() != _ws->cursorResources[kCursorResourceMagnifyingGlass] || getCursor()->getAnimation())
getCursor()->set(_ws->cursorResources[kCursorResourceMagnifyingGlass]);
} else {
- if (getCursor()->graphicResourceId != _ws->cursorResources[kCursorResourceTalkNPC2] || getCursor()->animation)
+ if (getCursor()->getResourceId() != _ws->cursorResources[kCursorResourceTalkNPC2] || getCursor()->getAnimation())
getCursor()->set(_ws->cursorResources[kCursorResourceTalkNPC2]);
}
}
diff --git a/engines/asylum/views/scenetitle.cpp b/engines/asylum/views/scenetitle.cpp
index 03b545503f..91c0f37d3d 100644
--- a/engines/asylum/views/scenetitle.cpp
+++ b/engines/asylum/views/scenetitle.cpp
@@ -36,7 +36,7 @@
namespace Asylum {
SceneTitle::SceneTitle(AsylumEngine *engine): _vm(engine),
- _start(0), _ticks(0), _done(false), _spinnerFrameIndex(0), _spinnerProgress(0), _showMouseState(false) {
+ _start(0), _ticks(0), _done(false), _spinnerFrameIndex(0), _spinnerProgress(0), _spinnerFrameCount(0), _showMouseState(false) {
}
SceneTitle::~SceneTitle() {
@@ -68,7 +68,7 @@ void SceneTitle::update(int32 tick) {
return;
getScreen()->draw(getWorld()->sceneTitleGraphicResourceId);
- getScreen()->draw(MAKE_RESOURCE(kResourcePackSound, 17), _spinnerFrameIndex, Common::Point((_spinnerProgress / 590.0 * 580) - 290 , 0), kDrawFlagNone, false);
+ getScreen()->draw(MAKE_RESOURCE(kResourcePackSound, 17), _spinnerFrameIndex, Common::Point((int16)(((_spinnerProgress / 590.0) * 580.0) - 290), 0), kDrawFlagNone, false);
getText()->drawCentered(Common::Point(320, 30), 24, MAKE_RESOURCE(kResourcePackText, 1811 + getWorld()->chapter));
// This is not from the original. It's just some arbitrary math to throttle the progress indicator.
@@ -89,11 +89,11 @@ void SceneTitle::update(int32 tick) {
if (_spinnerFrameIndex > _spinnerFrameCount - 1)
_spinnerFrameIndex = 0;
- if (_spinnerProgress > 590) {
+ if (_spinnerProgress > 590) {
_done = true;
getScreen()->paletteFade(0, 5, 80);
- }
+ }
}
} // End of namespace Asylum
diff --git a/engines/asylum/views/video.cpp b/engines/asylum/views/video.cpp
index 0259692e3c..05b30046af 100644
--- a/engines/asylum/views/video.cpp
+++ b/engines/asylum/views/video.cpp
@@ -81,7 +81,7 @@ bool VideoPlayer::handleEvent(const AsylumEvent &evt) {
if (_subtitleIndex >= 0) {
char *text1 = getText()->get((ResourceId)_currentMovie);
- int32 y = 10 * (44 - getText()->draw(0, 99, kTextCalculate, Common::Point(10, 400), 20, 620, text1));
+ int16 y = (int16)(10 * (44 - getText()->draw(0, 99, kTextCalculate, Common::Point(10, 400), 20, 620, text1)));
if (y <= 400)
y = 405;
@@ -110,7 +110,7 @@ bool VideoPlayer::handleEvent(const AsylumEvent &evt) {
//////////////////////////////////////////////////////////////////////////
// Playing
//////////////////////////////////////////////////////////////////////////
-void VideoPlayer::play(int32 videoNumber, EventHandler *handler) {
+void VideoPlayer::play(uint32 videoNumber, EventHandler *handler) {
getSaveLoad()->setMovieViewed(videoNumber);
_currentMovie = videoNumber;
@@ -152,7 +152,7 @@ void VideoPlayer::play(Common::String filename, bool showSubtitles) {
int32 frameEnd = 0;
int32 currentSubtitle = 0;
- while (!_done && !_vm->shouldQuit() && !_smkDecoder->endOfVideo()) {
+ while (!_done && !Engine::shouldQuit() && !_smkDecoder->endOfVideo()) {
_vm->handleEvents();
if (_smkDecoder->needsUpdate()) {
@@ -207,7 +207,7 @@ void VideoPlayer::loadSubtitles() {
Common::File subsFile;
subsFile.open("vids.cap");
- uint32 fileSize = subsFile.size();
+ uint32 fileSize = (uint32)subsFile.size();
char *buffer = new char[fileSize + 1];
subsFile.read(buffer, fileSize);
subsFile.close();
diff --git a/engines/asylum/views/video.h b/engines/asylum/views/video.h
index 8665084cb8..c292db794b 100644
--- a/engines/asylum/views/video.h
+++ b/engines/asylum/views/video.h
@@ -58,10 +58,10 @@ public:
/**
* Plays a video.
*
- * @param videoNumber The video number.
+ * @param videoNumber The video number.
* @param handler The previous event handler.
*/
- void play(int32 videoNumber, EventHandler *handler);
+ void play(uint32 videoNumber, EventHandler *handler);
/**
* Handle event.
Commit: f8d11e354a32fa897d52d3d996de9468a53322b7
https://github.com/scummvm/scummvm/commit/f8d11e354a32fa897d52d3d996de9468a53322b7
Author: Littleboy (littleboy at scummvm.org)
Date: 2021-05-17T15:37:15+02:00
Commit Message:
ASYLUM: Cleanup script manager
Changed paths:
engines/asylum/resources/object.h
engines/asylum/resources/script.cpp
engines/asylum/resources/script.h
diff --git a/engines/asylum/resources/object.h b/engines/asylum/resources/object.h
index 0019b57a74..231f88c4a4 100644
--- a/engines/asylum/resources/object.h
+++ b/engines/asylum/resources/object.h
@@ -43,8 +43,8 @@ public:
//////////////////////////////////////////////////////////////////////////
// Public variables & accessors
//////////////////////////////////////////////////////////////////////////
- int32 x;
- int32 y;
+ int16 x;
+ int16 y;
uint32 flags;
int32 actionType;
diff --git a/engines/asylum/resources/script.cpp b/engines/asylum/resources/script.cpp
index 84730a8e03..a5c09ce40e 100644
--- a/engines/asylum/resources/script.cpp
+++ b/engines/asylum/resources/script.cpp
@@ -188,6 +188,9 @@ ScriptManager::~ScriptManager() {
_scripts.clear();
_queue.reset();
+ _currentScript = NULL;
+ _currentQueueEntry = NULL;
+
// Zero-out passed pointers
_vm = NULL;
}
@@ -198,11 +201,9 @@ void ScriptManager::load(Common::SeekableReadStream *stream) {
for (int32 a = 0; a < numEntries; a++) {
Script script;
- memset(&script, 0, sizeof(Script));
for (int32 c = 0; c < MAX_ACTION_COMMANDS; c++) {
ScriptEntry command;
- memset(&command, 0, sizeof(ScriptEntry));
command.numLines = stream->readSint32LE();
command.opcode = (OpcodeType)stream->readSint32LE();
@@ -237,7 +238,7 @@ void ScriptManager::reset() {
_skipProcessing = false;
_done = false;
_exit = false;
- _processNextEntry = 0;
+ _processNextEntry = false;
_currentScript = NULL;
_currentQueueEntry = NULL;
@@ -253,18 +254,17 @@ void ScriptManager::queueScript(int32 scriptIndex, ActorIndex actorIndex) {
return;
// Look for a empty queue slot
- int32 index = 0;
+ uint32 index;
for (index = 1; index < ARRAYSIZE(_queue.entries); index++) {
if (_queue.entries[index].scriptIndex == -1)
break;
}
// No empty queue slot, return
- if (index == 0)
+ if (index == 0 || index == ARRAYSIZE(_queue.entries))
return;
// Setup script and queue
- // TODO once everything is working properly, convert back to stack based script queue
_scripts[scriptIndex].counter = 0;
_queue.entries[index].field_10 = 0;
_queue.entries[index].field_C = 0;
@@ -283,7 +283,7 @@ void ScriptManager::queueScript(int32 scriptIndex, ActorIndex actorIndex) {
_queue.entries[index].actorIndex = actorIndex;
}
-bool ScriptManager::isInQueue(int32 scriptIndex) {
+bool ScriptManager::isInQueue(int32 scriptIndex) const {
for (int32 i = 0; i < ARRAYSIZE(_queue.entries); i++) {
if (_queue.entries[i].scriptIndex == scriptIndex)
return true;
@@ -340,7 +340,7 @@ bool ScriptManager::process() {
goto label_processNextEntry;
// Get the script command
- cmdIndex = _queue.entries[entryIndex].currentLine;
+ cmdIndex = (uint32)_queue.entries[entryIndex].currentLine;
if (cmdIndex >= MAX_ACTION_COMMANDS)
error("[ScriptManager::process] Invalid command index (was: %d, max: %d)", cmdIndex, MAX_ACTION_COMMANDS);
@@ -406,7 +406,7 @@ void ScriptManager::saveLoadWithSerializer(Common::Serializer &s) {
// Opcode 0x00
IMPLEMENT_OPCODE(Return)
_done = true;
- _processNextEntry = 0;
+ _processNextEntry = false;
END_OPCODE
//////////////////////////////////////////////////////////////////////////
@@ -499,14 +499,14 @@ IMPLEMENT_OPCODE(PlayAnimation)
} else {
Common::Rect frameRect = GraphicResource::getFrameRect(_vm, object->getResourceId(), object->getFrameIndex());
- getSharedData()->setGlobalPoint(Common::Point(frameRect.left + Common::Rational(frameRect.width(), 2).toInt() + object->x,
- frameRect.top + Common::Rational(frameRect.height(), 2).toInt() + object->y));
+ getSharedData()->setGlobalPoint(Common::Point(frameRect.left + (int16)Common::Rational(frameRect.width(), 2).toInt() + object->x,
+ frameRect.top + (int16)Common::Rational(frameRect.height(), 2).toInt() + object->y));
}
}
if (cmd->param2) {
cmd->param2 = 2;
- _processNextEntry = 1;
+ _processNextEntry = true;
}
END_OPCODE
@@ -527,7 +527,7 @@ IMPLEMENT_OPCODE(MoveScenePosition)
} else if (cmd->param5) {
if (getWorld()->motionStatus == 2)
- _processNextEntry = 1;
+ _processNextEntry = true;
else
cmd->param5 = 0;
} else {
@@ -539,7 +539,7 @@ IMPLEMENT_OPCODE(MoveScenePosition)
cmd->param3,
true);
- _processNextEntry = 1;
+ _processNextEntry = true;
}
END_OPCODE
@@ -615,7 +615,7 @@ IMPLEMENT_OPCODE(EnableObjects)
enableObject(cmd, kObjectEnableType0);
}
- _processNextEntry = 1;
+ _processNextEntry = true;
}
END_OPCODE
@@ -638,7 +638,7 @@ END_OPCODE
IMPLEMENT_OPCODE(JumpActorSpeech)
Actor *actor = getScene()->getActor(cmd->param1);
- if (actor->process(Common::Point(cmd->param2, cmd->param3)))
+ if (actor->process(Common::Point((int16)cmd->param2, (int16)cmd->param3)))
return;
_currentQueueEntry->currentLine = cmd->param4;
@@ -664,19 +664,19 @@ IMPLEMENT_OPCODE(JumpAndSetDirection)
if (cmd->param5 == 1) {
cmd->param5 = 2;
- _processNextEntry = 1;
+ _processNextEntry = true;
}
}
} else {
cmd->param5 = 1;
- _processNextEntry = 0;
+ _processNextEntry = false;
if ((actor->getPoint1()->x + actor->getPoint2()->x) == cmd->param2 && (actor->getPoint1()->y + actor->getPoint2()->y) == cmd->param3)
actor->updateFromDirection((ActorDirection)cmd->param4);
}
} else {
if (cmd->param5 == 2)
- _processNextEntry = 1;
+ _processNextEntry = true;
}
END_OPCODE
@@ -686,7 +686,7 @@ IMPLEMENT_OPCODE(JumpIfActorCoordinates)
Actor *actor = getScene()->getActor(cmd->param1);
if ((actor->getPoint1()->x + actor->getPoint2()->x) != cmd->param2 || (actor->getPoint1()->y + actor->getPoint2()->y) != cmd->param3)
- _processNextEntry = cmd->param4;
+ _processNextEntry = (bool)cmd->param4;
END_OPCODE
//////////////////////////////////////////////////////////////////////////
@@ -721,7 +721,7 @@ IMPLEMENT_OPCODE(JumpIfSoundPlayingAndPlaySound)
if (cmd->param2 == 2) {
if (getSound()->isPlaying(resource))
- _processNextEntry = 1;
+ _processNextEntry = true;
else
cmd->param2 = 1;
} else if (!_vm->sound()->isPlaying(resource)) {
@@ -730,7 +730,7 @@ IMPLEMENT_OPCODE(JumpIfSoundPlayingAndPlaySound)
if (cmd->param2 == 1) {
cmd->param2 = 2;
- _processNextEntry= 1;
+ _processNextEntry = true;
}
}
END_OPCODE
@@ -818,18 +818,18 @@ END_OPCODE
IMPLEMENT_OPCODE(RunEncounter)
Encounter *encounter = _vm->encounter();
- encounter->disablePlayerOnExit(cmd->param5);
+ encounter->disablePlayerOnExit((bool)cmd->param5);
if (cmd->param6) {
if (encounter->isRunning())
- _processNextEntry = 1;
+ _processNextEntry = true;
else
cmd->param6 = 0;
} else {
encounter->run(cmd->param1, (ObjectId)cmd->param2, (ObjectId)cmd->param3, cmd->param4);
cmd->param6 = 2;
- _processNextEntry = 1;
+ _processNextEntry = true;
}
END_OPCODE
@@ -906,7 +906,7 @@ IMPLEMENT_OPCODE(UpdateActor)
if (cmd->param3 == 2) {
switch (actor->getStatus()) {
default:
- _processNextEntry = 1;
+ _processNextEntry = true;
return;
case kActorStatus7:
@@ -949,7 +949,7 @@ IMPLEMENT_OPCODE(UpdateActor)
actor->updateStatus(actor->getStatus() <= kActorStatus11 ? kActorStatus3 : kActorStatus19);
cmd->param3 = 2;
- _processNextEntry = 1;
+ _processNextEntry = true;
}
END_OPCODE
@@ -957,7 +957,7 @@ END_OPCODE
// Opcode 0x2D
IMPLEMENT_OPCODE(PlayMovie)
if (getSharedData()->getMatteBarHeight() < 170) {
- _processNextEntry = 1;
+ _processNextEntry = true;
if (!getSharedData()->getMatteBarHeight()) {
getCursor()->hide();
@@ -984,7 +984,7 @@ IMPLEMENT_OPCODE(PlayMovie)
}
getSharedData()->setMatteBarHeight(0);
- _processNextEntry = 0;
+ _processNextEntry = false;
if (!getSharedData()->getMattePlaySound() && _currentScript->commands[0].numLines != 0) {
bool found = true;
@@ -1061,7 +1061,7 @@ IMPLEMENT_OPCODE(IncrementParam1)
cmd->param1 = 0;
} else {
cmd->param1++;
- _processNextEntry = 1;
+ _processNextEntry = true;
}
END_OPCODE
@@ -1143,7 +1143,7 @@ IMPLEMENT_OPCODE(CreatePalette)
getScreen()->updatePalette(cmd->param1);
- _processNextEntry = 1;
+ _processNextEntry = true;
++cmd->param1;
END_OPCODE
@@ -1155,7 +1155,7 @@ IMPLEMENT_OPCODE(IncrementParam2)
cmd->param2 = 0;
} else {
++cmd->param2;
- _processNextEntry = 1;
+ _processNextEntry = true;
}
}
END_OPCODE
@@ -1181,13 +1181,13 @@ IMPLEMENT_OPCODE(UpdateWideScreen)
if (barSize >= 22) {
cmd->param1 = 0;
- _processNextEntry = 0;
+ _processNextEntry = false;
getSharedData()->setMatteBarHeight(0);
} else {
getScreen()->drawWideScreenBars((int16)(4 * barSize));
- _processNextEntry = 1;
+ _processNextEntry = true;
++cmd->param1;
}
END_OPCODE
@@ -1218,7 +1218,7 @@ IMPLEMENT_OPCODE(PlaySpeechScene)
getSharedData()->setFlag(kFlag1, true);
getSharedData()->setFlag(kFlag2, true);
}
- _processNextEntry = 1;
+ _processNextEntry = true;
}
if (cmd->param3 && !cmd->param6)
@@ -1228,7 +1228,7 @@ IMPLEMENT_OPCODE(PlaySpeechScene)
}
if (_vm->sound()->isPlaying((ResourceId)cmd->param5)) {
- _processNextEntry = 1;
+ _processNextEntry = true;
return;
}
@@ -1270,7 +1270,7 @@ IMPLEMENT_OPCODE(PlaySpeech)
getSharedData()->setFlag(kFlag1, true);
getSharedData()->setFlag(kFlag2, true);
}
- _processNextEntry = 1;
+ _processNextEntry = true;
}
if (cmd->param3 && !cmd->param6)
@@ -1280,7 +1280,7 @@ IMPLEMENT_OPCODE(PlaySpeech)
}
if (_vm->sound()->isPlaying((ResourceId)cmd->param5)) {
- _processNextEntry = 1;
+ _processNextEntry = true;
return;
}
@@ -1314,7 +1314,7 @@ IMPLEMENT_OPCODE(PlaySpeechScene2)
if (cmd->param5 == 2) {
if (getSound()->isPlaying((ResourceId)cmd->param6)) {
- _processNextEntry = 1;
+ _processNextEntry = true;
return;
}
@@ -1350,7 +1350,7 @@ IMPLEMENT_OPCODE(PlaySpeechScene2)
getSharedData()->setFlag(kFlag2, false);
}
- _processNextEntry = 1;
+ _processNextEntry = true;
}
if (cmd->param4 && !cmd->param7)
@@ -1370,7 +1370,7 @@ IMPLEMENT_OPCODE(MoveScenePositionFromActor)
cmd->param2);
} else if (cmd->param6) {
if (getWorld()->motionStatus == 2) {
- _processNextEntry = 1;
+ _processNextEntry = true;
} else {
cmd->param6 = 0;
getWorld()->coordinates[0] = -1;
@@ -1384,9 +1384,9 @@ IMPLEMENT_OPCODE(MoveScenePositionFromActor)
cmd->param2,
true,
&cmd->param6))
- _processNextEntry = 0;
+ _processNextEntry = false;
else
- _processNextEntry = 1;
+ _processNextEntry = true;
}
END_OPCODE
@@ -1407,7 +1407,7 @@ END_OPCODE
IMPLEMENT_OPCODE(PlaySoundUpdateObject)
if (cmd->param6) {
if (getSound()->isPlaying(getSpeech()->getSoundResourceId())) {
- _processNextEntry = 1;
+ _processNextEntry = true;
} else {
cmd->param6 = 0;
if (cmd->param5) {
@@ -1430,7 +1430,7 @@ IMPLEMENT_OPCODE(PlaySoundUpdateObject)
if (cmd->param2) {
getScene()->getActor(cmd->param5)->updateStatus(kActorStatus8);
cmd->param6 = 1;
- _processNextEntry = 1;
+ _processNextEntry = true;
} else {
if (cmd->param4 != cmd->param3) {
if (cmd->param4)
@@ -1441,7 +1441,7 @@ IMPLEMENT_OPCODE(PlaySoundUpdateObject)
}
cmd->param6 = 1;
- _processNextEntry = 1;
+ _processNextEntry = true;
}
}
END_OPCODE
@@ -1449,7 +1449,7 @@ END_OPCODE
//////////////////////////////////////////////////////////////////////////
// Opcode 0x47
IMPLEMENT_OPCODE(ActorFaceTarget)
- getScene()->getActor(cmd->param1)->faceTarget((ObjectId)cmd->param2, (DirectionFrom)cmd->param3);
+ getScene()->getActor(cmd->param1)->faceTarget((uint32)cmd->param2, (DirectionFrom)cmd->param3);
END_OPCODE
//////////////////////////////////////////////////////////////////////////
@@ -1460,10 +1460,10 @@ IMPLEMENT_OPCODE(HideMatteBars)
if (getSharedData()->getMatteBarHeight() >= 170) {
getSharedData()->setMatteBarHeight(0);
- _processNextEntry = 0;
+ _processNextEntry = false;
getCursor()->show();
} else {
- _processNextEntry = 1;
+ _processNextEntry = true;
if (!getSharedData()->getMatteBarHeight()) {
getCursor()->hide();
@@ -1481,10 +1481,10 @@ IMPLEMENT_OPCODE(ShowMatteBars)
if (getSharedData()->getMatteBarHeight() >= 170) {
getSharedData()->setMatteBarHeight(0);
- _processNextEntry = 0;
+ _processNextEntry = false;
getCursor()->show();
} else {
- _processNextEntry = 1;
+ _processNextEntry = true;
if (!getSharedData()->getMatteBarHeight()) {
getCursor()->hide();
@@ -1653,17 +1653,17 @@ IMPLEMENT_OPCODE(Interact)
if (actor->getStatus() == kActorStatus2 || actor->getStatus() == kActorStatus13) {
if (cmd->param2 == 2)
- _processNextEntry = 1;
+ _processNextEntry = true;
return;
}
if (cmd->param2 == 2) {
cmd->param2 = 1;
- _processNextEntry = 0;
+ _processNextEntry = false;
if ((actor->getPoint1()->x + actor->getPoint2()->x == cmd->param6) && (actor->getPoint1()->y + actor->getPoint2()->y == cmd->param7)) {
- getScene()->getActor()->faceTarget((ObjectId)cmd->param1, kDirectionFromActor);
+ getScene()->getActor()->faceTarget((uint32)cmd->param1, kDirectionFromActor);
actor->updateFromDirection((ActorDirection)((actor->getDirection() + 4) & 7));
} else {
_currentQueueEntry->currentLine = cmd->param3;
@@ -1678,7 +1678,7 @@ IMPLEMENT_OPCODE(Interact)
if (cmd->param2 == 1) {
cmd->param2 = 2;
- _processNextEntry = 1;
+ _processNextEntry = true;
}
} else {
if (cmd->param4)
@@ -1722,7 +1722,7 @@ IMPLEMENT_OPCODE(SetObjectFlags)
}
if (cmd->param3 && (object->flags & kObjectFlag10E38))
- _processNextEntry = 1;
+ _processNextEntry = true;
END_OPCODE
//////////////////////////////////////////////////////////////////////////
@@ -1759,7 +1759,7 @@ END_OPCODE
IMPLEMENT_OPCODE(ProcessActor)
Actor *actor = getScene()->getActor(cmd->param1);
- actor->processNext(cmd->param2, cmd->param3, (ActorDirection)cmd->param4, Common::Point(cmd->param5, cmd->param6), cmd->param7, Common::Point(cmd->param8, cmd->param9));
+ actor->processNext(cmd->param2, cmd->param3, (ActorDirection)cmd->param4, Common::Point((int16)cmd->param5, (int16)cmd->param6), (bool)cmd->param7, Common::Point((int16)cmd->param8, (int16)cmd->param9));
END_OPCODE
//////////////////////////////////////////////////////////////////////////
@@ -1777,10 +1777,10 @@ IMPLEMENT_OPCODE(SetObjectLastFrameIndex)
Object *object = getWorld()->getObjectById((ObjectId)cmd->param1);
if (object->getFrameIndex() == object->getFrameCount() - 1) {
- _processNextEntry = 0;
+ _processNextEntry = false;
object->flags &= ~kObjectFlag10E38;
} else {
- _processNextEntry = 1;
+ _processNextEntry = true;
}
END_OPCODE
@@ -1800,15 +1800,15 @@ END_OPCODE
IMPLEMENT_OPCODE(UpdatePlayerChapter9)
if (cmd->param2) {
if (getWorld()->nextPlayer == kActorInvalid) {
- _processNextEntry = 0;
+ _processNextEntry = false;
cmd->param2 = 0;
} else {
- _processNextEntry = 1;
+ _processNextEntry = true;
}
} else {
Actor::updatePlayerChapter9(_vm, cmd->param1);
cmd->param2 = 1;
- _processNextEntry = 1;
+ _processNextEntry = true;
}
END_OPCODE
@@ -1827,7 +1827,7 @@ IMPLEMENT_OPCODE(UpdateGlobalFlags)
}
if (_vm->sound()->isPlaying(getSpeech()->getSoundResourceId())) {
- _processNextEntry = 1;
+ _processNextEntry = true;
return;
} else if (!cmd->param1) {
cmd->param1 = 1;
@@ -1839,6 +1839,9 @@ END_OPCODE
//////////////////////////////////////////////////////////////////////////
void ScriptManager::enableObject(ScriptEntry *cmd, ObjectTransparency type) {
+ if (!_currentScript)
+ error("[ScriptManager::enableObject] No current script");
+
int32 transparency = 0;
// Setup transparency
@@ -2006,7 +2009,10 @@ void ScriptManager::jumpIfActionFlag(ScriptEntry *cmd, ActionType flag) {
void ScriptManager::setNextLine(int32 line) {
if (!_currentScript)
- error("[ActionList::setNextLine] No current script set!");
+ error("[ScriptManager::setNextLine] No current script");
+
+ if (!_currentQueueEntry)
+ error("[ScriptManager::setNextLine] No current queue entry");
int32 opcode = _currentScript->commands[line].opcode;
if (opcode == 0x10 || opcode == 0) { // Return
diff --git a/engines/asylum/resources/script.h b/engines/asylum/resources/script.h
index 334002909f..8e8693d641 100644
--- a/engines/asylum/resources/script.h
+++ b/engines/asylum/resources/script.h
@@ -40,8 +40,9 @@ namespace Asylum {
#define IMPLEMENT_OPCODE(name) \
void ScriptManager::Op##name(ScriptEntry *cmd) { \
- if (!_currentScript) error("[" #name "] No current script set!"); \
- if (!cmd) error("[" #name "] Invalid command parameter!");
+ if (!_currentScript) error("[" #name "] No current script set"); \
+ if (!_currentQueueEntry) error("[" #name "] Invalid current queue entry"); \
+ if (!cmd) error("[" #name "] Invalid command parameter");
#define END_OPCODE }
@@ -150,7 +151,7 @@ public:
*
* @return true if in queue, false if not.
*/
- bool isInQueue(int32 scriptIndex);
+ bool isInQueue(int32 scriptIndex) const;
/**
* Resets the queue.
@@ -176,8 +177,8 @@ private:
int32 scriptIndex;
int32 currentLine;
ActorIndex actorIndex;
- int32 field_C;
- int32 field_10;
+ uint32 field_C;
+ uint32 field_10;
ScriptQueueEntry() {
reset();
Commit: 5b0da5965cf8580d65f373c7dc8e72497f45c6e7
https://github.com/scummvm/scummvm/commit/5b0da5965cf8580d65f373c7dc8e72497f45c6e7
Author: Littleboy (littleboy at scummvm.org)
Date: 2021-05-17T15:37:15+02:00
Commit Message:
ASYLUM: Cleanup more base classes
Changed paths:
engines/asylum/asylum.cpp
engines/asylum/asylum.h
engines/asylum/console.cpp
engines/asylum/puzzles/hivecontrol.cpp
engines/asylum/resources/data.cpp
engines/asylum/resources/data.h
engines/asylum/resources/encounters.cpp
engines/asylum/resources/encounters.h
engines/asylum/resources/object.cpp
engines/asylum/resources/object.h
engines/asylum/resources/script.cpp
engines/asylum/resources/worldstats.cpp
engines/asylum/resources/worldstats.h
engines/asylum/shared.h
engines/asylum/system/savegame.cpp
engines/asylum/system/savegame.h
engines/asylum/system/sound.h
engines/asylum/system/speech.cpp
engines/asylum/system/text.cpp
engines/asylum/system/text.h
engines/asylum/views/menu.h
engines/asylum/views/scene.cpp
engines/asylum/views/scenetitle.cpp
diff --git a/engines/asylum/asylum.cpp b/engines/asylum/asylum.cpp
index 3c5c078952..5dd966c21d 100644
--- a/engines/asylum/asylum.cpp
+++ b/engines/asylum/asylum.cpp
@@ -67,7 +67,8 @@ namespace Asylum {
AsylumEngine::AsylumEngine(OSystem *system, const ADGameDescription *gd) : Engine(system), _gameDescription(gd),
_console(NULL), _cursor(NULL), _encounter(NULL), _menu(NULL), _reaction(NULL), _resource(NULL), _savegame(NULL),
- _scene(NULL), _screen(NULL), _script(NULL), _sound(NULL), _text(NULL), _video(NULL), _handler(NULL) {
+ _scene(NULL), _screen(NULL), _script(NULL), _special(NULL), _speech(NULL), _sound(NULL), _text(NULL),
+ _video(NULL), _handler(NULL) {
// Init data
memset(&_gameFlags, 0, sizeof(_gameFlags));
@@ -107,6 +108,8 @@ AsylumEngine::AsylumEngine(OSystem *system, const ADGameDescription *gd) : Engin
}
AsylumEngine::~AsylumEngine() {
+ _handler = NULL;
+
delete _cursor;
delete _scene;
delete _encounter;
@@ -114,6 +117,8 @@ AsylumEngine::~AsylumEngine() {
delete _savegame;
delete _screen;
delete _script;
+ delete _special;
+ delete _speech;
delete _sound;
delete _text;
delete _video;
@@ -121,10 +126,14 @@ AsylumEngine::~AsylumEngine() {
delete _resource;
delete _console;
+ _previousScene = NULL;
+
// Cleanup puzzles
for (uint i = 0; i < ARRAYSIZE(_puzzles); i++)
delete _puzzles[i];
+ delete _rnd;
+
// Zero passed pointers
_gameDescription = NULL;
}
@@ -185,7 +194,7 @@ Common::Error AsylumEngine::run() {
}
void AsylumEngine::startGame(ResourcePackId sceneId, StartGameType type) {
- if (!_cursor || !_screen)
+ if (!_cursor || !_screen || !_savegame)
error("[AsylumEngine::startGame] Subsystems not initialized properly!");
// Load the default mouse cursor
@@ -227,6 +236,9 @@ void AsylumEngine::startGame(ResourcePackId sceneId, StartGameType type) {
}
void AsylumEngine::restart() {
+ if (!_cursor || !_script)
+ error("[AsylumEngine::restart] Subsystems not initialized properly!");
+
_cursor->hide();
// Cleanup
@@ -250,6 +262,9 @@ void AsylumEngine::restart() {
}
void AsylumEngine::reset() {
+ if (!_menu)
+ error("[AsylumEngine::reset] Subsystems not initialized properly!");
+
// Set game as started
_menu->setGameStarted();
@@ -319,7 +334,7 @@ void AsylumEngine::playIntro() {
}
void AsylumEngine::handleEvents() {
- if (!_console || !_video || !_screen || !_sound || !_menu)
+ if (!_console || !_video || !_screen || !_sound || !_menu || !_cursor)
error("[AsylumEngine::handleEvents] Subsystems not initialized properly!");
// Show the debugger if required
@@ -383,11 +398,14 @@ void AsylumEngine::handleEvents() {
}
void AsylumEngine::processDelayedEvents() {
- if (!_video || !_sound || !_menu)
+ if (!_video || !_sound || !_menu || !_script)
error("[AsylumEngine::processDelayedEvents] Subsystems not initialized properly!");
// check for a delayed scene change
if (_delayedSceneIndex != kResourcePackInvalid && isGameFlagNotSet(kGameFlagScriptProcessing)) {
+ if (!_scene)
+ error("[AsylumEngine::processDelayedEvents] Subsystems not initialized properly!");
+
ResourcePackId sceneIndex = _delayedSceneIndex;
// Reset delayed scene
@@ -404,7 +422,7 @@ void AsylumEngine::processDelayedEvents() {
// Check for delayed video
if (_delayedVideoIndex != -1 && isGameFlagNotSet(kGameFlagScriptProcessing)) {
- int32 index = _delayedVideoIndex;
+ uint32 index = (uint32)_delayedVideoIndex;
_delayedVideoIndex = -1;
_video->play(index, _handler);
@@ -453,8 +471,8 @@ void AsylumEngine::notify(AsylumEventType type, int32 param1, int32 param2) {
_handler->handleEvent(evt);
}
-EventHandler *AsylumEngine::getPuzzle(uint32 index) {
- if (index > ARRAYSIZE(_puzzles))
+EventHandler *AsylumEngine::getPuzzle(uint32 index) const {
+ if (index >= ARRAYSIZE(_puzzles))
error("[AsylumEngine::getPuzzleEventHandler] Invalid index (was: %d - max: %d)", index, ARRAYSIZE(_puzzles));
if (_puzzles[index] == NULL)
@@ -489,16 +507,16 @@ void AsylumEngine::initSinCosTables(double a2, int32 a3, int32 a4) {
do {
if (baseStep >= 1) {
- int32 baseAngle = 90;
+ uint32 baseAngle = 90;
int32 step = baseStep;
- int32 *val = &_sinCosTables[2 * offset];
+ int16 *val = &_sinCosTables[2 * offset];
do {
double angle = (double)(baseAngle % 360) * 3.141592653589 * 0.005555555555555556;
- *val = cos(angle) * a2 - (a3 / 2);
- *(val + 1) = sin(angle) * a2 - (a4 / 2);
+ *val = (int16)(cos(angle) * a2 - (a3 / 2.0));
+ *(val + 1) = (int16)(sin(angle) * a2 - (a4 / 2.0));
baseAngle += 360 / baseStep;
val += 2;
@@ -513,7 +531,7 @@ void AsylumEngine::initSinCosTables(double a2, int32 a3, int32 a4) {
} while (baseStep <= 8);
}
-int32 AsylumEngine::computeSinCosOffset(int32 val) {
+int32 AsylumEngine::computeSinCosOffset(int32 val) const {
int32 offset = 0;
for (int32 i = val; i > 0; --i)
offset += i;
@@ -522,6 +540,9 @@ int32 AsylumEngine::computeSinCosOffset(int32 val) {
}
Common::Point AsylumEngine::getSinCosValues(int32 index1, int32 index2) {
+ if (!_scene)
+ error("[AsylumEngine::getSinCosValues] Subsystems not initialized properly!");
+
Common::Point values;
if (_scene->worldstats()->chapter == kChapter11) {
@@ -543,6 +564,9 @@ void AsylumEngine::updateReverseStereo() {
}
void AsylumEngine::saveLoadWithSerializer(Common::Serializer &s) {
+ if (!_script)
+ error("[AsylumEngine::saveLoadWithSerializer] Subsystems not initialized properly!");
+
// Game flags
for (uint32 i = 0; i < ARRAYSIZE(_gameFlags); i++)
s.syncAsSint32LE(_gameFlags[i]);
diff --git a/engines/asylum/asylum.h b/engines/asylum/asylum.h
index fb27c69495..0b4dc0813e 100644
--- a/engines/asylum/asylum.h
+++ b/engines/asylum/asylum.h
@@ -189,7 +189,7 @@ public:
*
* @return The message handler.
*/
- EventHandler* getPuzzle(uint32 index);
+ EventHandler* getPuzzle(uint32 index) const;
/**
* Updates the reverse stereo scene status from the config
@@ -240,7 +240,7 @@ private:
PuzzleData _puzzleData;
SharedData _data;
int _gameFlags[130];
- int32 _sinCosTables[72];
+ int16 _sinCosTables[72];
bool _introPlayed;
int32 _tickOffset;
@@ -269,7 +269,7 @@ private:
*
* @return The calculated offset.
*/
- int32 computeSinCosOffset(int32 val);
+ int32 computeSinCosOffset(int32 val) const;
// Debug
diff --git a/engines/asylum/console.cpp b/engines/asylum/console.cpp
index 432de925f7..eb8785a3ed 100644
--- a/engines/asylum/console.cpp
+++ b/engines/asylum/console.cpp
@@ -226,8 +226,8 @@ bool Console::cmdListActors(int32 argc, const char **argv) {
}
// Adjust actor coordinates
- int x = atoi(argv[2]);
- int y = atoi(argv[3]);
+ int16 x = (int16)atoi(argv[2]);
+ int16 y = (int16)atoi(argv[3]);
// TODO add error handling
@@ -378,16 +378,16 @@ bool Console::cmdRunScript(int32 argc, const char **argv) {
return true;
}
- uint32 index = atoi(argv[1]);
- uint32 actor = atoi(argv[2]);
+ int32 index = atoi(argv[1]);
+ int32 actor = atoi(argv[2]);
// Check parameters
- if (index >= getScript()->_scripts.size()) {
+ if (index < 0 || index >= (int32)getScript()->_scripts.size()) {
DebugPrintf("[Error] Invalid index (was: %d - valid: [0-%d])\n", index, _vm->encounter()->items()->size() - 1);
return true;
}
- if (actor > getWorld()->actors.size()) {
+ if (actor < 0 || actor >= (int32)getWorld()->actors.size()) {
DebugPrintf("[Error] Invalid actor index (was: %d - valid: [0-%d])\n", actor, getWorld()->actors.size() - 1);
}
@@ -423,10 +423,10 @@ bool Console::cmdRunEncounter(int32 argc, const char **argv) {
return true;
}
- uint32 index = atoi(argv[1]);
+ int32 index = atoi(argv[1]);
// Check index is valid
- if (index >= _vm->encounter()->_items.size()) {
+ if (index < 0 || index >= (int32)_vm->encounter()->_items.size()) {
DebugPrintf("[Error] Invalid index (was: %d - valid: [0-%d])\n", index, _vm->encounter()->_items.size() - 1);
return true;
}
@@ -461,15 +461,15 @@ bool Console::cmdRunPuzzle(int32 argc, const char **argv) {
return true;
}
- uint32 index = atoi(argv[1]);
+ int32 index = atoi(argv[1]);
// Check index is valid
- if (index > ARRAYSIZE(_vm->_puzzles)) {
+ if (index < 0 || index >= ARRAYSIZE(puzzleToScenes)) {
DebugPrintf("[Error] Invalid index (was: %d - valid: [0-%d])\n", index, ARRAYSIZE(_vm->_puzzles));
return true;
}
- EventHandler *puzzle = _vm->getPuzzle(index);
+ EventHandler *puzzle = _vm->getPuzzle((uint32)index);
if (puzzle == NULL) {
DebugPrintf("[Error] This puzzle does not exists (%d)", index);
return true;
@@ -496,17 +496,23 @@ bool Console::cmdSetPalette(int32 argc, const char **argv) {
return true;
}
- uint32 pack = atoi(argv[1]);
- uint32 index = atoi(argv[2]);
+ int32 pack = atoi(argv[1]);
+ int32 index = atoi(argv[2]);
// Check resource pack
- if (pack > 18) {
+ if (pack < 0 || pack > 18) {
DebugPrintf("[Error] Invalid resource pack (was: %d - valid: [0-18])\n", pack);
return true;
}
+ // Check index
+ if (index < 0) {
+ DebugPrintf("[Error] Invalid index (was: %d - valid: > 0)\n", index);
+ return true;
+ }
+
// Try loading resource
- ResourceId id = MAKE_RESOURCE(pack, index);
+ ResourceId id = MAKE_RESOURCE((uint32)pack, index);
ResourceEntry *entry = getResource()->get(id);
if (!entry) {
@@ -525,28 +531,38 @@ bool Console::cmdDrawResource(int32 argc, const char **argv) {
return true;
}
- uint32 pack = atoi(argv[1]);
- uint32 index = atoi(argv[2]);
+ int32 pack = atoi(argv[1]);
+ int32 index = atoi(argv[2]);
- uint32 frame = 0;
+ int32 frame = 0;
if (argc == 4)
frame = atoi(argv[3]);
// Check resource pack
- if (pack > 18) {
+ if (pack < 0 || pack > 18) {
DebugPrintf("[Error] Invalid resource pack (was: %d - valid: [0-18])\n", pack);
return true;
}
+ // Check index
+ if (index < 0) {
+ DebugPrintf("[Error] Invalid index (was: %d - valid: > 0)\n", index);
+ return true;
+ }
+
+ ResourceId resourceId = MAKE_RESOURCE((uint32)pack, index);
+
// Try loading resource
GraphicResource *resource = new GraphicResource(_vm);
- if (!resource->load(MAKE_RESOURCE(pack, index))) {
+ if (!resource->load(resourceId)) {
DebugPrintf("[Error] Invalid resource index (was: %d)\n", index);
+ delete resource;
return true;
}
- if (frame > resource->count() - 1) {
+ if (frame < 0 || frame >= (int32)resource->count()) {
DebugPrintf("[Error] Invalid resource frame index (was: %d , max: %d)\n", frame, resource->count() - 1);
+ delete resource;
return true;
}
@@ -558,7 +574,7 @@ bool Console::cmdDrawResource(int32 argc, const char **argv) {
// Draw resource
getScreen()->clear();
- getScreen()->draw(MAKE_RESOURCE(pack, index), frame, Common::Point(0, 0));
+ getScreen()->draw(resourceId, (uint32)frame, Common::Point(0, 0));
getScreen()->copyBackBufferToScreen();
g_system->updateScreen();
diff --git a/engines/asylum/puzzles/hivecontrol.cpp b/engines/asylum/puzzles/hivecontrol.cpp
index 2eba33388f..d06ce1de41 100644
--- a/engines/asylum/puzzles/hivecontrol.cpp
+++ b/engines/asylum/puzzles/hivecontrol.cpp
@@ -257,7 +257,7 @@ bool PuzzleHiveControl::mouseLeftDown(const AsylumEvent &) {
case kControlGlyph4:
case kControlGlyph5:
case kControlGlyph6:
- _leverPosition = (uint32)(_currentControl - 49);
+ _leverPosition = _currentControl - 49;
_leverDelta = (uint32)abs((double)(_leverPosition - _prevLeverPosition)) * (GraphicResource::getFrameCount(_vm, getWorld()->graphicResourceIds[kElementLever]) - 1) / 5;
if (_leverDelta)
getSound()->playSound(getWorld()->graphicResourceIds[76], false, Config.sfxVolume - 10);
diff --git a/engines/asylum/resources/data.cpp b/engines/asylum/resources/data.cpp
index 74e2924e9a..91d08756d5 100644
--- a/engines/asylum/resources/data.cpp
+++ b/engines/asylum/resources/data.cpp
@@ -22,8 +22,6 @@
#include "engines/asylum/resources/data.h"
-#include "common/rect.h"
-#include "common/serializer.h"
#include "common/textconsole.h"
namespace Asylum {
@@ -51,7 +49,7 @@ SharedData::SharedData() {
memset(&_chapter2Data1, 0, sizeof(_chapter2Data1));
_smallCurUp = 0;
_smallCurDown = 0;
- _encounterFrameBg = 0;
+ _encounterFrameBg = kResourceNone;
_flagSkipDrawScene = false;
_matteVar1 = 0;
_flagActorUpdateEnabledCheck = false;
@@ -64,7 +62,7 @@ SharedData::SharedData() {
_chapter2FrameIndexOffset = 0;
_chapter2ActorIndex = 0;
_eventUpdate = 0;
- memset(&_chapter2Data5, 0, sizeof(_chapter2Data4));
+ memset(&_chapter2Data4, 0, sizeof(_chapter2Data4));
_actorUpdateStatusEnabledCounter = 0;
memset(&_chapter2Data5, 0, sizeof(_chapter2Data5));
// _flagEncounterDisablePlayerOnExit
@@ -90,8 +88,8 @@ void SharedData::saveCursorResources(ResourceId *resources, uint32 size) {
memcpy((ResourceId *)&_cursorResources, resources, size);
}
-void SharedData::loadCursorResources(ResourceId *resources, uint32 size) {
- memcpy(resources, (ResourceId *)&_cursorResources, size);
+void SharedData::loadCursorResources(ResourceId *resources, uint32 size) const {
+ memcpy(resources, (const ResourceId *)&_cursorResources, size);
}
void SharedData::saveSceneFonts(ResourceId font1, ResourceId font2, ResourceId font3) {
@@ -100,7 +98,7 @@ void SharedData::saveSceneFonts(ResourceId font1, ResourceId font2, ResourceId f
_sceneFonts[2] = font3;
}
-void SharedData::loadSceneFonts(ResourceId *font1, ResourceId *font2, ResourceId *font3) {
+void SharedData::loadSceneFonts(ResourceId *font1, ResourceId *font2, ResourceId *font3) const {
*font1 = _sceneFonts[0];
*font2 = _sceneFonts[1];
*font3 = _sceneFonts[2];
@@ -111,7 +109,7 @@ void SharedData::saveSmallCursor(int32 smallCurUp, int32 smallCurDown) {
_smallCurDown = smallCurDown;
}
-void SharedData::loadSmallCursor(int32 *smallCurUp, int32 *smallCurDown) {
+void SharedData::loadSmallCursor(int32 *smallCurUp, int32 *smallCurDown) const {
*smallCurUp = _smallCurUp;
*smallCurDown = _smallCurDown;
}
@@ -152,7 +150,7 @@ void SharedData::setChapter2Counter(uint32 index, int32 val) {
_chapter2Counters[index - 1] = val;
}
-int32 SharedData::getChapter2Counter(uint32 index) {
+int32 SharedData::getChapter2Counter(uint32 index) const {
if (index == 0 || index > 8)
error("[SharedData::setChapter2Counter] Invalid index (was: %d, valid: [1;8])", index);
@@ -162,7 +160,7 @@ int32 SharedData::getChapter2Counter(uint32 index) {
//////////////////////////////////////////////////////////////////////////
// Ambient sounds
//////////////////////////////////////////////////////////////////////////
-uint32 SharedData::getAmbientTick(uint32 index) {
+uint32 SharedData::getAmbientTick(uint32 index) const {
if (index >= ARRAYSIZE(_ambientTicks))
error("[SharedData::getAmbientTick] index is outside valid values (was: %d, valid: [0:%d]", index, ARRAYSIZE(_ambientTicks));
@@ -176,7 +174,7 @@ void SharedData::setAmbientTick(uint32 index, uint32 val) {
_ambientTicks[index] = val;
}
-uint32 SharedData::getAmbientFlag(uint32 index) {
+uint32 SharedData::getAmbientFlag(uint32 index) const {
if (index >= ARRAYSIZE(_ambientFlags))
error("[SharedData::getAmbientFlag] index is outside valid values (was: %d, valid: [0:%d]", index, ARRAYSIZE(_ambientFlags));
@@ -213,7 +211,6 @@ bool SharedData::getFlag(GlobalFlag flag) const {
case kFlagRedraw:
return _flagRedraw;
- break;
case kFlagSkipDrawScene:
return _flagSkipDrawScene;
diff --git a/engines/asylum/resources/data.h b/engines/asylum/resources/data.h
index b7cde1f720..7b39b1f2c4 100644
--- a/engines/asylum/resources/data.h
+++ b/engines/asylum/resources/data.h
@@ -122,7 +122,7 @@ public:
// Public variables
int32 cdNumber;
- int32 movieIndex;
+ uint32 movieIndex;
uint32 sceneCounter;
Common::Point vector1;
Common::Point vector2;
@@ -146,9 +146,9 @@ public:
//////////////////////////////////////////////////////////////////////////
// Ambient sound data
- uint32 getAmbientTick(uint32 index);
+ uint32 getAmbientTick(uint32 index) const;
void setAmbientTick(uint32 index, uint32 val);
- uint32 getAmbientFlag(uint32 index);
+ uint32 getAmbientFlag(uint32 index) const;
void setAmbientFlag(uint32 index, uint32 val);
void resetAmbientFlags();
@@ -164,21 +164,21 @@ public:
// Saved scene data
void saveCursorResources(ResourceId *resources, uint32 size);
- void loadCursorResources(ResourceId *resources, uint32 size);
+ void loadCursorResources(ResourceId *resources, uint32 size) const;
void saveSceneFonts(ResourceId font1, ResourceId font2, ResourceId font3);
- void loadSceneFonts(ResourceId *font1, ResourceId *font2, ResourceId *font3);
+ void loadSceneFonts(ResourceId *font1, ResourceId *font2, ResourceId *font3) const;
void saveSmallCursor(int32 smallCurUp, int32 smallCurDown);
- void loadSmallCursor(int32 *smallCurUp, int32 *smallCurDown);
- void saveEncounterFrameBackground(int32 encounterFrameBg) { _encounterFrameBg = encounterFrameBg; }
- void loadEncounterFrameBackground(int32 *encounterFrameBg) { *encounterFrameBg = _encounterFrameBg; }
+ void loadSmallCursor(int32 *smallCurUp, int32 *smallCurDown) const;
+ void saveEncounterFrameBackground(ResourceId encounterFrameBg) { _encounterFrameBg = encounterFrameBg; }
+ void loadEncounterFrameBackground(ResourceId *encounterFrameBg) { *encounterFrameBg = _encounterFrameBg; }
// Matte data
int32 getMatteVar1() const { return _matteVar1; }
void setMatteVar1(int32 val) { _matteVar1 = val; }
uint32 getMatteVar2() const { return _matteVar2; }
void setMatteVar2(uint32 val) { _matteVar2 = val; }
- uint32 getMatteBarHeight() const { return _matteBarHeight; }
- void setMatteBarHeight(uint32 val) { _matteBarHeight = val; }
+ int16 getMatteBarHeight() const { return _matteBarHeight; }
+ void setMatteBarHeight(int16 val) { _matteBarHeight = val; }
bool getMatteInitialized() const { return _matteInitialized; }
void setMatteInitialized(bool val) { _matteInitialized = val; }
bool getMattePlaySound() const { return _mattePlaySound; }
@@ -188,7 +188,7 @@ public:
void setChapter2Data(uint32 index, int32 offset, int32 val);
int32 getChapter2Data(uint32 index, int32 offset);
void setChapter2Counter(uint32 index, int32 val);
- int32 getChapter2Counter(uint32 index);
+ int32 getChapter2Counter(uint32 index) const;
ActorIndex getChapter2FrameIndexOffset() const { return _chapter2FrameIndexOffset; }
void setChapter2FrameIndexOffset(int32 val) { _chapter2FrameIndexOffset = val; }
ActorIndex getChapter2ActorIndex() const { return _chapter2ActorIndex; }
@@ -219,7 +219,7 @@ private:
uint32 _chapter2Data1[5];
int32 _smallCurUp;
int32 _smallCurDown;
- int32 _encounterFrameBg;
+ ResourceId _encounterFrameBg;
bool _flagSkipDrawScene;
int32 _matteVar1;
bool _flagActorUpdateEnabledCheck;
@@ -247,7 +247,7 @@ private:
bool _flagScene1;
bool _flagRedraw;
- uint32 _matteBarHeight;
+ int16 _matteBarHeight;
uint32 _matteVar2;
};
diff --git a/engines/asylum/resources/encounters.cpp b/engines/asylum/resources/encounters.cpp
index 5cc346fc0c..39d6224d59 100644
--- a/engines/asylum/resources/encounters.cpp
+++ b/engines/asylum/resources/encounters.cpp
@@ -45,8 +45,9 @@ namespace Asylum {
#define KEYWORD_MASK 0xFFF
Encounter::Encounter(AsylumEngine *engine) : _vm(engine),
- _index(0), _keywordIndex(0), _item(NULL), _objectId1(kObjectNone), _objectId2(kObjectNone), _actorIndex(kActorInvalid),
- _flag1(false), _flag2(false), _flag3(false), _flag4(false), _disablePlayerOnExit(false), _isRunning(false) {
+ _index(0), _keywordIndex(0), _item(NULL), _objectId1(kObjectNone), _objectId2(kObjectNone), _objectId3(kObjectNone),
+ _actorIndex(kActorInvalid), _flag1(false), _flag2(false), _flag3(false), _flag4(false), _disablePlayerOnExit(false),
+ _isRunning(false) {
memset(&_keywordIndexes, 0, sizeof(_keywordIndexes));
_rectIndex = -1;
@@ -101,7 +102,6 @@ void Encounter::load() {
int16 dataCount = file.readSint16LE();
for (uint8 i = 0; i < dataCount; i++) {
EncounterItem item;
- memset(&item, 0, sizeof(EncounterItem));
item.keywordIndex = file.readSint16LE();
item.field2 = file.readSint16LE();
@@ -291,22 +291,18 @@ bool Encounter::handleEvent(const AsylumEvent &evt) {
case EVENT_ASYLUM_INIT:
return init();
- break;
case EVENT_ASYLUM_UPDATE:
return update();
- break;
case Common::EVENT_KEYDOWN:
return key(evt);
- break;
case Common::EVENT_LBUTTONDOWN:
case Common::EVENT_LBUTTONUP:
case Common::EVENT_RBUTTONDOWN:
case Common::EVENT_RBUTTONUP:
return mouse(evt);
- break;
}
return false;
@@ -435,7 +431,7 @@ bool Encounter::update() {
}
if (tick >= getSharedData()->getNextScreenUpdate() && getSharedData()->getFlag(kFlagRedraw)) {
- if (getSharedData()->getMatteBarHeight() <= 0) {
+ if (getSharedData()->getMatteBarHeight() == 0) {
getScreen()->copyBackBufferToScreen();
} else {
drawScreen();
@@ -513,31 +509,31 @@ bool Encounter::mouse(const AsylumEvent &evt) {
//////////////////////////////////////////////////////////////////////////
// Variables
//////////////////////////////////////////////////////////////////////////
-void Encounter::setVariable(uint32 index, int32 val) {
+void Encounter::setVariable(uint32 index, int16 val) {
if (index >= _variables.size())
error("[Encounter::setVariable] Invalid index (was: %d, max: %d)", index, _variables.size() - 1);
_variables[index] = val;
}
-int32 Encounter::getVariable(uint32 index) {
+int16 Encounter::getVariable(uint32 index) {
if (index >= _variables.size())
error("[Encounter::getVariable] Invalid index (was: %d, max: %d)", index, _variables.size() - 1);
return _variables[index];
}
-int32 Encounter::getVariableInv(int32 index) {
+int16 Encounter::getVariableInv(int16 index) {
if (index >= 0)
return index;
- return getVariable(-index);
+ return getVariable((uint16)-index);
}
//////////////////////////////////////////////////////////////////////////
// Actions
//////////////////////////////////////////////////////////////////////////
-uint32 Encounter::findKeyword(EncounterItem *item, int16 keyword) {
+uint32 Encounter::findKeyword(EncounterItem *item, int16 keyword) const {
for (uint i = 0; i < ARRAYSIZE(item->keywords); i++) {
if ((item->keywords[i] & KEYWORD_MASK) == keyword)
return i;
@@ -549,7 +545,7 @@ uint32 Encounter::findKeyword(EncounterItem *item, int16 keyword) {
int32 Encounter::getKeywordIndex() {
Common::Point mousePos = getCursor()->position();
- uint32 counter = 0;
+ int16 counter = 0;
for (uint i = _data_455BF8; i < ARRAYSIZE(_keywordIndexes); i++) {
int32 index = _keywordIndexes[i];
@@ -589,11 +585,11 @@ void Encounter::choose(int32 index) {
}
}
-bool Encounter::checkKeywords() {
+bool Encounter::checkKeywords() const {
if (_data_455B14 == -1 || _data_455B14 + 1 >= 50)
return false;
- for (uint32 i = _data_455B14 + 1; i < ARRAYSIZE(_keywordIndexes); i++) {
+ for (int32 i = _data_455B14 + 1; i < ARRAYSIZE(_keywordIndexes); i++) {
int32 index = _keywordIndexes[i];
if (index < 0)
@@ -606,7 +602,7 @@ bool Encounter::checkKeywords() {
return false;
}
-bool Encounter::checkKeywords2() {
+bool Encounter::checkKeywords2() const {
for (uint32 i = 0; i < _data_455BF8; i++) {
int32 index = _keywordIndexes[i];
@@ -625,7 +621,7 @@ void Encounter::updateFromRect(int32 rectIndex) {
if (rectIndex == 1 && (_data_455B14 + 1) < 50) {
bool cont = false;
- for (uint32 i = _data_455B14 + 1; i < ARRAYSIZE(_keywordIndexes); i++) {
+ for (int32 i = _data_455B14 + 1; i < ARRAYSIZE(_keywordIndexes); i++) {
int32 index = _keywordIndexes[i];
if (index < 0)
@@ -678,7 +674,7 @@ void Encounter::updateFromRect(int32 rectIndex) {
//////////////////////////////////////////////////////////////////////////
// Speech
//////////////////////////////////////////////////////////////////////////
-void Encounter::resetSpeech(uint32 keywordIndex, uint32 a2) {
+void Encounter::resetSpeech(int16 keywordIndex, int16 a2) {
getSpeech()->resetTextData();
setupPortraits();
@@ -698,7 +694,7 @@ void Encounter::setupPortraits() {
setupSpeechData('N', &_portrait2);
}
-void Encounter::setupSpeechData(char val, EncounterGraphic *encounterGraphic) {
+void Encounter::setupSpeechData(char val, EncounterGraphic *encounterGraphic) const {
switch (val) {
default:
break;
@@ -851,10 +847,8 @@ bool Encounter::drawBackground() {
if (_data_455BE4) {
--_background.frameIndex;
- if (_background.frameIndex - 1 < 0) {
- _background.frameIndex = 0;
+ if (_background.frameIndex == 0)
exitEncounter();
- }
return false;
}
@@ -912,11 +906,11 @@ bool Encounter::drawPortraits() {
if (_portrait2.transTableNum == 3)
getScreen()->draw(_portrait2.resourceId,
_portrait2.frameIndex,
- Common::Point(_point.x - frameRect.width() + _background.rect.width() - 6, _point.y + 5));
+ Common::Point(_point.x + _background.rect.width() - (frameRect.width() + 6), _point.y + 5));
else
getScreen()->draw(_portrait2.resourceId,
_portrait2.frameIndex,
- Common::Point(_point.x - frameRect.width() + _background.rect.width() - 6, _point.y + 5),
+ Common::Point(_point.x + _background.rect.width() - (frameRect.width() + 6), _point.y + 5),
kDrawFlagNone,
_portrait2.transTableNum);
@@ -1064,7 +1058,7 @@ void Encounter::drawDialog() {
if (_data_455BF8 >= 50)
return;
- int32 counter = 0;
+ int16 counter = 0;
for (uint32 i = _data_455BF8; i < ARRAYSIZE(_keywordIndexes); i++) {
if (counter / 3 >= 8)
@@ -1083,7 +1077,7 @@ void Encounter::drawDialog() {
getText()->loadFont(getWorld()->font1);
Common::Point coords(_drawingStructs[0].point1.y + 144 * (counter % 3) + _point.x + (counter % 3) + _portrait1.rect.width() + 15,
- _point.y + (16 * counter / 3));
+ _point.y + (int16)(16 * counter / 3));
if (getKeywordIndex() == index)
getScreen()->fillRect(coords.x - 1, coords.y + 5, getText()->getWidth(MAKE_RESOURCE(kResourcePackShared, 3681)), 18, 0);
@@ -1097,18 +1091,18 @@ void Encounter::drawDialog() {
}
}
-void Encounter::drawText(char *text, ResourceId font, int32 y) {
+void Encounter::drawText(char *text, ResourceId font, int16 y) {
if (!text)
return;
- int width = _background.rect.width() - _portrait1.rect.width() - _portrait2.rect.width() - 20;
- int x = _point.x + _portrait1.rect.width() + 10;
+ int16 width = _background.rect.width() - (_portrait1.rect.width() + _portrait2.rect.width() + 20);
+ int16 x = _point.x + _portrait1.rect.width() + 10;
getText()->loadFont(font);
if (_data_455BCC) {
if (_data_455B3C != 1 && _tick < _vm->getTick()) {
- _tick = _vm->getTick() + 1000 * getResource()->get(getSpeech()->getSoundResourceId())->size / 11025 / _data_455B3C;
+ _tick = _vm->getTick() + 1000 * (getResource()->get(getSpeech()->getSoundResourceId())->size / 11025) / (uint16)_data_455B3C;
if ((_data_455BF0 + 8) < _data_455B70)
_data_455BF0 += 8;
@@ -1118,7 +1112,7 @@ void Encounter::drawText(char *text, ResourceId font, int32 y) {
_data_455B70 = getText()->draw(kTextCalculate, Common::Point(x, y), 16, width, text);
_data_455B3C = _data_455B70 / 8 + 1;
_data_455BF0 = 0;
- _tick = _vm->getTick() + 1000 * getResource()->get(getSpeech()->getSoundResourceId())->size / 11025 / _data_455B3C;
+ _tick = _vm->getTick() + 1000 * (getResource()->get(getSpeech()->getSoundResourceId())->size / 11025) / (uint16)_data_455B3C;
}
getText()->draw(_data_455BF0, 7, kTextCenter, Common::Point(x, y), 16, width, text);
@@ -1524,7 +1518,7 @@ void Encounter::runScript() {
case 13:
if (!_flag3)
- _data_455BD4 = 1;
+ _data_455BD4 = true;
done = true;
break;
@@ -1536,7 +1530,7 @@ void Encounter::runScript() {
break;
case 15:
- setVariable(entry.param2, _scriptData.vars[entry.param1]);
+ setVariable(entry.param2, (int16)_scriptData.vars[entry.param1]);
break;
case 16:
@@ -1609,7 +1603,7 @@ void Encounter::runScript() {
if (!getSharedData()->getMatteBarHeight()) {
getScreen()->loadPalette();
getSharedData()->setMatteBarHeight(1);
- getSharedData()->movieIndex = getVariableInv(entry.param2);
+ getSharedData()->movieIndex = (uint32)getVariableInv(entry.param2);
getSharedData()->setMatteVar1(1);
getSharedData()->setMattePlaySound(true);
getSharedData()->setMatteInitialized(true);
diff --git a/engines/asylum/resources/encounters.h b/engines/asylum/resources/encounters.h
index 4b08e2c935..95d1bfa9da 100644
--- a/engines/asylum/resources/encounters.h
+++ b/engines/asylum/resources/encounters.h
@@ -99,8 +99,8 @@ private:
};
struct EncounterGraphic {
- int32 frameIndex;
- int32 frameCount;
+ uint32 frameIndex;
+ uint32 frameCount;
Common::Rect rect;
ResourceId resourceId;
int32 transTableNum;
@@ -126,7 +126,7 @@ private:
struct EncounterDrawingStruct {
Common::Point point1;
Common::Point point2;
- int32 frameIndex;
+ uint32 frameIndex;
int32 transTableNum;
int32 status;
ResourceId resourceId;
@@ -161,13 +161,13 @@ private:
ObjectId _objectId3;
ActorIndex _actorIndex;
- uint32 _value1;
+ int16 _value1;
uint32 _tick;
// Internal data
int32 _data_455B14;
- uint32 _data_455B3C;
- uint32 _data_455B70;
+ int16 _data_455B3C;
+ int16 _data_455B70;
bool _data_455BCC;
bool _data_455BD0;
bool _data_455BD4;
@@ -176,7 +176,7 @@ private:
bool _data_455BE0;
bool _data_455BE4;
bool _data_455BE8;
- uint32 _data_455BF0;
+ int16 _data_455BF0;
uint32 _data_455BF4;
uint32 _data_455BF8;
@@ -205,25 +205,25 @@ private:
//////////////////////////////////////////////////////////////////////////
// Variables
- void setVariable(uint32 index, int32 val);\
- int32 getVariable(uint32 index);
- int32 getVariableInv(int32 index);
+ void setVariable(uint32 index, int16 val);
+ int16 getVariable(uint32 index);
+ int16 getVariableInv(int16 index);
/////////////////////////////////////////////////////////////////////////
// Actions
- uint32 findKeyword(EncounterItem *item, int16 keyword);
+ uint32 findKeyword(EncounterItem *item, int16 keyword) const;
int32 getKeywordIndex();
void choose(int32 keywordIndex);
- bool checkKeywords();
- bool checkKeywords2();
+ bool checkKeywords() const;
+ bool checkKeywords2() const;
void updateFromRect(int32 rectIndex);
//////////////////////////////////////////////////////////////////////////
// Speech
- void resetSpeech(uint32 a1, uint32 a2);
+ void resetSpeech(int16 a1, int16 a2);
void setupPortraits();
void setupSpeechText();
- void setupSpeechData(char val, EncounterGraphic *encounterGraphic);
+ void setupSpeechData(char val, EncounterGraphic *encounterGraphic) const;
void setupSpeech(ResourceId textResourceId, ResourceId fontResourceId);
bool setupSpeech(ResourceId id);
bool isSpeaking();
@@ -234,7 +234,7 @@ private:
bool drawPortraits();
void drawStructs();
void drawDialog();
- void drawText(char *text, ResourceId font, int32 y);
+ void drawText(char *text, ResourceId font, int16 y);
//////////////////////////////////////////////////////////////////////////
// Misc
diff --git a/engines/asylum/resources/object.cpp b/engines/asylum/resources/object.cpp
index 2811c7c4ca..47e14ffb2f 100644
--- a/engines/asylum/resources/object.cpp
+++ b/engines/asylum/resources/object.cpp
@@ -41,7 +41,7 @@ Object::Object(AsylumEngine *engine) : x(0), y(0), flags(0), actionType(0),
_id(kObjectNone), _resourceId(kResourceNone), _field_20(0), _frameIndex(0), _frameCount(0),
_field_2C(0), _field_30(0), _field_34(0), _field_3C(0), _polygonIndex(0), _field_B4(0),
_tickCount(0), _tickCount2(0), _field_C0(0), _priority(0), _scriptIndex(0), _transparency(0),
- _soundX(0), _soundY(0), _field_688(0), _soundResourceId(kResourceNone), _field_6A4(kDirectionN)
+ _field_688(0), _soundResourceId(kResourceNone), _field_6A4(kDirectionN)
{
memset(&_name, 0, sizeof(_name));
memset(&_gameFlags, 0, sizeof(_gameFlags));
@@ -59,12 +59,12 @@ Object::~Object() {
void Object::load(Common::SeekableReadStream *stream) {
_id = (ObjectId)stream->readSint32LE();
_resourceId = (ResourceId)stream->readSint32LE();
- x = stream->readSint32LE();
- y = stream->readSint32LE();
+ x = (int16)stream->readSint32LE();
+ y = (int16)stream->readSint32LE();
- _boundingRect.left = (int16)(stream->readSint32LE() & 0xFFFF);
- _boundingRect.top = (int16)(stream->readSint32LE() & 0xFFFF);
- _boundingRect.right = (int16)(stream->readSint32LE() & 0xFFFF);
+ _boundingRect.left = (int16)(stream->readSint32LE() & 0xFFFF);
+ _boundingRect.top = (int16)(stream->readSint32LE() & 0xFFFF);
+ _boundingRect.right = (int16)(stream->readSint32LE() & 0xFFFF);
_boundingRect.bottom = (int16)(stream->readSint32LE() & 0xFFFF);
_field_20 = stream->readSint32LE();
@@ -113,8 +113,8 @@ void Object::load(Common::SeekableReadStream *stream) {
}
_transparency = stream->readSint32LE();
- _soundX = stream->readSint32LE();
- _soundY = stream->readSint32LE();
+ _soundCoords.x = (int16)stream->readSint32LE();
+ _soundCoords.y = (int16)stream->readSint32LE();
_field_688 = stream->readSint32LE();
for (int i = 0; i < 5; i++)
@@ -270,8 +270,8 @@ void Object::update() {
if (_frameIndex < _frameCount - 1) {
if (_field_688 == 1) {
Common::Rect frameRect = GraphicResource::getFrameRect(_vm, _resourceId, _frameIndex);
- getSharedData()->setGlobalPoint(Common::Point(x + frameRect.left + Common::Rational(frameRect.width(), 2).toInt(),
- y + frameRect.top + Common::Rational(frameRect.height(), 2).toInt()));
+ getSharedData()->setGlobalPoint(Common::Point(x + frameRect.left + (int16)Common::Rational(frameRect.width(), 2).toInt(),
+ y + frameRect.top + (int16)Common::Rational(frameRect.height(), 2).toInt()));
}
} else {
flags &= ~kObjectFlag8;
@@ -295,8 +295,8 @@ void Object::update() {
} else if (_field_688 == 1) {
Common::Rect frameRect = GraphicResource::getFrameRect(_vm, _resourceId, _frameIndex);
- getSharedData()->setGlobalPoint(Common::Point(x + frameRect.left + Common::Rational(frameRect.width(), 2).toInt(),
- y + frameRect.top + Common::Rational(frameRect.height(), 2).toInt()));
+ getSharedData()->setGlobalPoint(Common::Point(x + frameRect.left + (int16)Common::Rational(frameRect.width(), 2).toInt(),
+ y + frameRect.top + (int16)Common::Rational(frameRect.height(), 2).toInt()));
}
_tickCount = _vm->getTick();
@@ -357,21 +357,20 @@ void Object::setNextFrame(int32 targetFlags) {
void Object::playSounds() {
Common::Point point;
- if (_soundX || _soundY) {
- point.x = _soundX;
- point.y = _soundY;
+ if (_soundCoords.x || _soundCoords.y) {
+ point = _soundCoords;
} else {
if (LOBYTE(flags) & kObjectFlag4) {
// Get object resource
ResourceEntry *resource = getResource()->get(_resourceId);
- point.x = x + Common::Rational(resource->getData(4), 2).toInt();
- point.y = y + Common::Rational(resource->getData(0), 2).toInt();
+ point.x = x + (int16)Common::Rational(resource->getData(4), 2).toInt();
+ point.y = y + (int16)Common::Rational(resource->getData(0), 2).toInt();
} else {
Common::Rect rect = GraphicResource::getFrameRect(_vm, _resourceId, _frameIndex);
- point.x = x + (rect.width() * 2);
- point.y = x + (rect.height() * 2);
+ point.x = (int16)(x + (rect.width() * 2));
+ point.y = (int16)(x + (rect.height() * 2));
}
}
@@ -443,7 +442,7 @@ void Object::setVolume() {
Common::Rect frameRect = GraphicResource::getFrameRect(_vm, _resourceId, _frameIndex);
// Compute volume
- Common::Point coords(Common::Rational(frameRect.width(), 2).toInt() + x, Common::Rational(frameRect.height(), 2).toInt() + y);
+ Common::Point coords((int16)Common::Rational(frameRect.width(), 2).toInt() + x, (int16)Common::Rational(frameRect.height(), 2).toInt() + y);
int32 volume = Config.voiceVolume + getSound()->calculateVolumeAdjustement(coords, _field_6A4, 0);
if (volume < -10000)
volume = -10000;
@@ -506,8 +505,7 @@ Common::String Object::toString(bool shortString) {
output += Common::String::format(" priority: %d\n", _priority);
output += Common::String::format(" scriptIndex: %d\n", _scriptIndex);
output += Common::String::format(" transparency %d\n", _transparency);
- output += Common::String::format(" soundX: %d\n", _soundX);
- output += Common::String::format(" soundY: %d\n", _soundY);
+ output += Common::String::format(" soundCoords: (%d, %d)\n", _soundCoords.x, _soundCoords.y);
output += Common::String::format(" field_688: %d\n", _field_688);
output += Common::String::format(" soundResourceId: %d\n", _soundResourceId);
output += Common::String::format(" field_6A4: %d\n", _field_6A4);
diff --git a/engines/asylum/resources/object.h b/engines/asylum/resources/object.h
index 231f88c4a4..f0c1f143d8 100644
--- a/engines/asylum/resources/object.h
+++ b/engines/asylum/resources/object.h
@@ -67,7 +67,7 @@ public:
Common::Rect *getRect() { return &_rect; }
int32 getScriptIndex() { return _scriptIndex; }
- int32 getSoundY() { return _soundY; }
+ int32 getSoundY() { return _soundCoords.y; }
int32 getTransparency() { return _transparency; }
int32 getField688() { return _field_688; }
ActorDirection getField6A4() { return _field_6A4; }
@@ -174,31 +174,30 @@ private:
ResourceId _resourceId;
// x, y
Common::Rect _boundingRect;
- int32 _field_20;
- uint32 _frameIndex;
- uint32 _frameCount;
- int32 _field_2C;
- int32 _field_30;
- int32 _field_34;
+ int32 _field_20;
+ uint32 _frameIndex;
+ uint32 _frameCount;
+ int32 _field_2C;
+ int32 _field_30;
+ int32 _field_34;
// flags
- int32 _field_3C;
- uint8 _name[52];
+ int32 _field_3C;
+ uint8 _name[52];
Common::Rect _rect;
- int32 _polygonIndex;
+ int32 _polygonIndex;
// actionType
int32 _gameFlags[10];
- int32 _field_B4;
- uint32 _tickCount;
- uint32 _tickCount2;
+ int32 _field_B4;
+ uint32 _tickCount;
+ uint32 _tickCount2;
uint32 _field_C0;
- int32 _priority;
- int32 _scriptIndex;
- SoundItem _soundItems[16];
+ int32 _priority;
+ int32 _scriptIndex;
+ SoundItem _soundItems[16];
FrameSoundItem _frameSoundItems[50];
- int32 _transparency;
- int32 _soundX;
- int32 _soundY;
- int32 _field_688;
+ int32 _transparency;
+ Common::Point _soundCoords;
+ int32 _field_688;
ResourceId _randomResourceIds[5];
ResourceId _soundResourceId;
ActorDirection _field_6A4;
diff --git a/engines/asylum/resources/script.cpp b/engines/asylum/resources/script.cpp
index a5c09ce40e..c40ed5a51e 100644
--- a/engines/asylum/resources/script.cpp
+++ b/engines/asylum/resources/script.cpp
@@ -514,8 +514,8 @@ END_OPCODE
// Opcode 0x08
IMPLEMENT_OPCODE(MoveScenePosition)
if (cmd->param3 < 1) {
- getWorld()->xLeft = cmd->param1;
- getWorld()->yTop = cmd->param2;
+ getWorld()->xLeft = (int16)cmd->param1;
+ getWorld()->yTop = (int16)cmd->param2;
getWorld()->motionStatus = 3;
} else if (!cmd->param4) {
diff --git a/engines/asylum/resources/worldstats.cpp b/engines/asylum/resources/worldstats.cpp
index da85a543ea..cbb657f8c1 100644
--- a/engines/asylum/resources/worldstats.cpp
+++ b/engines/asylum/resources/worldstats.cpp
@@ -77,6 +77,15 @@ WorldStats::WorldStats(AsylumEngine *engine) : _vm(engine) {
numPolygons = 0;
memset(&cursorResourcesAlternate, kResourceNone, sizeof(cursorResourcesAlternate));
+ field_E848C = 0;
+ field_E8490 = 0;
+ field_E8494 = 0;
+ field_E8498 = 0;
+ field_E849C = 0;
+ memset(&tickValueArray, 0, sizeof(tickValueArray));
+ field_E8518 = 0;
+ memset(&field_E851C, 0, sizeof(field_E851C));
+ memset(&field_E8594, 0, sizeof(field_E8594));
nextPlayer = kActorMax;
memset(&field_E8610, 0, sizeof(field_E8610));
memset(&field_E8628, 0, sizeof(field_E8628));
@@ -100,8 +109,8 @@ void WorldStats::load(Common::SeekableReadStream *stream) {
numEntries = stream->readSint32LE();
chapter = (ChapterIndex)stream->readSint32LE();
- xLeft = stream->readSint32LE();
- yTop = stream->readSint32LE();
+ xLeft = (int16)stream->readSint32LE();
+ yTop = (int16)stream->readSint32LE();
boundingRect.left = (int16)(stream->readSint32LE() & 0xFFFF);
boundingRect.top = (int16)(stream->readSint32LE() & 0xFFFF);
@@ -124,7 +133,7 @@ void WorldStats::load(Common::SeekableReadStream *stream) {
unused = stream->readSint32LE();
smallCurUp = stream->readSint32LE();
smallCurDown = stream->readSint32LE();
- encounterFrameBg = stream->readSint32LE();
+ encounterFrameBg = (ResourceId)stream->readSint32LE();
width = stream->readSint32LE();
height = stream->readSint32LE();
@@ -173,10 +182,10 @@ void WorldStats::load(Common::SeekableReadStream *stream) {
ambientSounds[s].nextTick = stream->readSint32LE();
for (int32 i = 0; i < 6; i++)
- ambientSounds[s].flagNum[i] = (GameFlag)stream->readSint32LE();
+ ambientSounds[s].flagNum[i] = stream->readSint32LE();
- ambientSounds[s].point.x = stream->readSint32LE();
- ambientSounds[s].point.y = stream->readSint32LE();
+ ambientSounds[s].point.x = (int16)stream->readSint32LE();
+ ambientSounds[s].point.y = (int16)stream->readSint32LE();
}
numAmbientSounds = stream->readSint32LE();
@@ -288,7 +297,7 @@ int32 WorldStats::getActionAreaIndexById(int32 id) {
}
int32 WorldStats::getRandomActionAreaIndexById(int32 id) {
- int count = 0;
+ uint count = 0;
int32 indexes[5];
memset(&indexes, 0, sizeof(indexes));
diff --git a/engines/asylum/resources/worldstats.h b/engines/asylum/resources/worldstats.h
index acb9f43754..b4eaa7064a 100644
--- a/engines/asylum/resources/worldstats.h
+++ b/engines/asylum/resources/worldstats.h
@@ -77,8 +77,8 @@ public:
int32 size;
int32 numEntries;
ChapterIndex chapter;
- int32 xLeft; // scene start x position
- int32 yTop; // scene start y position
+ int16 xLeft; // scene start x position
+ int16 yTop; // scene start y position
Common::Rect boundingRect;
ResourceId backgroundImage;
ResourceId cursorResources[13];
@@ -92,7 +92,7 @@ public:
int32 unused;
int32 smallCurUp;
int32 smallCurDown;
- int32 encounterFrameBg;
+ ResourceId encounterFrameBg;
int32 width; // field_80
int32 height;
int32 motionStatus;
diff --git a/engines/asylum/shared.h b/engines/asylum/shared.h
index d7df6c6d4b..b921832006 100644
--- a/engines/asylum/shared.h
+++ b/engines/asylum/shared.h
@@ -237,11 +237,11 @@ enum ResourcePackId {
#define MAKE_RESOURCE(pack, index) (ResourceId)((((pack) << 16) + 0x80000000) + (uint32)(index))
-typedef unsigned int ResourceId;
+typedef int ResourceId;
enum ResourcesId {
kResourceNone = 0,
- kResourceInvalid = 0xFFFFFFFF
+ kResourceInvalid = 0xFFFFFFFF
};
#define kMusicStopped -666
diff --git a/engines/asylum/system/savegame.cpp b/engines/asylum/system/savegame.cpp
index 095d8accbd..68db4294b2 100644
--- a/engines/asylum/system/savegame.cpp
+++ b/engines/asylum/system/savegame.cpp
@@ -64,7 +64,7 @@ Savegame::~Savegame() {
_vm = NULL;
}
-bool Savegame::hasSavegames() {
+bool Savegame::hasSavegames() const {
for (uint i = 0; i < SAVEGAME_COUNT; i++)
if (isSavegamePresent(getFilename(i)))
return true;
@@ -178,6 +178,9 @@ bool Savegame::quickSave() {
}
void Savegame::remove() {
+ if (_index >= ARRAYSIZE(_savegames))
+ error("[Savegame::remove] Invalid savegame index");
+
getCursor()->hide();
g_system->getSavefileManager()->removeSavefile(getFilename(_index));
@@ -208,14 +211,14 @@ bool Savegame::check() {
return valid;
}
-Common::String Savegame::getFilename(uint32 index) {
+Common::String Savegame::getFilename(uint32 index) const {
if (index > SAVEGAME_COUNT - 1)
error("[Savegame::getFilename] Invalid savegame index (was:%d, valid: [0-25])", index);
return Common::String::format("%s%02d.sav", SAVEGAME_NAME, index);
}
-bool Savegame::isSavegamePresent(Common::String filename) {
+bool Savegame::isSavegamePresent(Common::String filename) const {
if (g_system->getSavefileManager()->listSavefiles(filename).size() == 0)
return false;
@@ -237,7 +240,7 @@ bool Savegame::readHeader(Common::InSaveFile *file) {
return true;
}
-void Savegame::writeHeader(Common::OutSaveFile *file) {
+void Savegame::writeHeader(Common::OutSaveFile *file) const {
// We write saved games with a 1.01 final version (build 851)
write(file, SAVEGAME_VERSION_SIZE, "Version Length");
@@ -246,7 +249,7 @@ void Savegame::writeHeader(Common::OutSaveFile *file) {
}
bool Savegame::loadData(Common::String filename) {
- Common::InSaveFile *file = g_system->getSavefileManager()->openForLoading(getFilename(_index));
+ Common::InSaveFile *file = g_system->getSavefileManager()->openForLoading(filename);
if (!file) {
getWorld()->chapter = kChapterInvalid;
return false;
@@ -269,7 +272,7 @@ bool Savegame::loadData(Common::String filename) {
getScript()->reset();
if (getWorld()->numScripts)
- read(file, getScript(), 7096, getWorld()->numScripts, "Action Lists");
+ read(file, getScript(), 7096, (uint32)getWorld()->numScripts, "Action Lists");
uint32 tick = read(file, "Time");
@@ -281,11 +284,11 @@ bool Savegame::loadData(Common::String filename) {
}
bool Savegame::saveData(Common::String filename, Common::String name, ChapterIndex chapter) {
- Common::OutSaveFile *file = g_system->getSavefileManager()->openForSaving(getFilename(_index));
+ Common::OutSaveFile *file = g_system->getSavefileManager()->openForSaving(filename);
if (!file)
return false;
- write(file, chapter, "Level");
+ write(file, (unsigned) (int32)chapter, "Level");
write(file, name, SAVEGAME_NAME_SIZE, "Game Name");
writeHeader(file);
write(file, _vm, 1512, 1, "Game Stats");
@@ -295,7 +298,7 @@ bool Savegame::saveData(Common::String filename, Common::String name, ChapterInd
write(file, getEncounter()->variables(), 2, getEncounter()->variables()->size(), "Encounter Variables");
if (getWorld()->numScripts)
- write(file, getScript(), 7096, getWorld()->numScripts, "Action Lists");
+ write(file, getScript(), 7096, (uint32)getWorld()->numScripts, "Action Lists");
write(file, _vm->getTick(), "Time");
@@ -304,7 +307,9 @@ bool Savegame::saveData(Common::String filename, Common::String name, ChapterInd
return true;
}
-void Savegame::seek(Common::InSaveFile *file, uint32 offset, Common::String description) {
+void Savegame::seek(Common::InSaveFile *file, uint32 offset, Common::String description) const {
+ debugC(kDebugLevelSavegame, "[Savegame] Seeking to offset: %s", description.c_str());
+
if (offset == 0)
return;
@@ -319,7 +324,9 @@ void Savegame::seek(Common::InSaveFile *file, uint32 offset, Common::String desc
}
}
-uint32 Savegame::read(Common::InSaveFile *file, Common::String description) {
+uint32 Savegame::read(Common::InSaveFile *file, Common::String description) const {
+ debugC(kDebugLevelSavegame, "[Savegame] Reading string: %s", description.c_str());
+
uint32 size = file->readUint32LE();
uint32 count = file->readUint32LE();
@@ -329,7 +336,9 @@ uint32 Savegame::read(Common::InSaveFile *file, Common::String description) {
return file->readUint32LE();
}
-Common::String Savegame::read(Common::InSaveFile *file, uint32 strLength, Common::String description) {
+Common::String Savegame::read(Common::InSaveFile *file, uint32 strLength, Common::String description) const {
+ debugC(kDebugLevelSavegame, "[Savegame] Reading string: %s (%d)", description.c_str(), strLength);
+
/*uint32 size =*/ file->readUint32LE();
uint32 count = file->readUint32LE();
@@ -347,7 +356,9 @@ Common::String Savegame::read(Common::InSaveFile *file, uint32 strLength, Common
return ret;
}
-void Savegame::read(Common::InSaveFile *file, Common::Serializable *data, uint32 size, uint32 count, Common::String description) {
+void Savegame::read(Common::InSaveFile *file, Common::Serializable *data, uint32 size, uint32 count, Common::String description) const {
+ debugC(kDebugLevelSavegame, "[Savegame] Reading data: %s (%d block(s) of size %d)", description.c_str(), size, count);
+
uint32 fileSize = file->readUint32LE();
if (size > fileSize)
error("[Savegame::read] Size too large (asked: %d, present: %d)", size, fileSize);
@@ -363,21 +374,27 @@ void Savegame::read(Common::InSaveFile *file, Common::Serializable *data, uint32
data->saveLoadWithSerializer(ser);
}
-void Savegame::write(Common::OutSaveFile *file, uint32 val, Common::String description) {
+void Savegame::write(Common::OutSaveFile *file, uint32 val, Common::String description) const {
+ debugC(kDebugLevelSavegame, "[Savegame] Writing value: %s", description.c_str());
+
file->writeUint32LE(4);
file->writeUint32LE(1);
file->writeUint32LE(val);
}
-void Savegame::write(Common::OutSaveFile *file, Common::String val, uint32 count, Common::String description) {
+void Savegame::write(Common::OutSaveFile *file, Common::String val, uint32 strLength, Common::String description) const {
+ debugC(kDebugLevelSavegame, "[Savegame] Writing string: %s (%d)", description.c_str(), strLength);
+
file->writeUint32LE(1);
- file->writeUint32LE(count);
+ file->writeUint32LE(strLength);
file->writeString(val);
}
-void Savegame::write(Common::OutSaveFile *file, Common::Serializable *data, uint32 size, uint32 count, Common::String description) {
+void Savegame::write(Common::OutSaveFile *file, Common::Serializable *data, uint32 size, uint32 count, Common::String description) const {
+ debugC(kDebugLevelSavegame, "[Savegame] Reading data: %s (%d block(s) of size %d)", description.c_str(), size, count);
+
file->writeUint32LE(size);
file->writeUint32LE(count);
@@ -401,7 +418,7 @@ void Savegame::write(Common::OutSaveFile *file, Common::Serializable *data, uint
// Movies
//////////////////////////////////////////////////////////////////////////
void Savegame::setMovieViewed(uint32 index) {
- if (index > ARRAYSIZE(_moviesViewed))
+ if (index >= ARRAYSIZE(_moviesViewed))
error("[Savegame::setMovieViewed] Invalid movie index!");
if (!_moviesViewed[index]) {
@@ -418,7 +435,7 @@ void Savegame::setMovieViewed(uint32 index) {
}
}
-uint32 Savegame::getMoviesViewed(int32 *movieList) {
+uint32 Savegame::getMoviesViewed(int32 *movieList) const {
memset(movieList, -1, 196 * sizeof(int32));
uint32 count = 0;
@@ -451,21 +468,21 @@ void Savegame::loadMoviesViewed() {
// Accessors
//////////////////////////////////////////////////////////////////////////
void Savegame::setName(uint32 index, Common::String name) {
- if (index > ARRAYSIZE(_names))
+ if (index >= ARRAYSIZE(_names))
error("[Savegame::setName] Invalid index (was: %d, max: %d)", index, ARRAYSIZE(_names));
_names[index] = name;
}
-Common::String Savegame::getName(uint32 index) {
- if (index > ARRAYSIZE(_names))
+Common::String Savegame::getName(uint32 index) const {
+ if (index >= ARRAYSIZE(_names))
error("[Savegame::getName] Invalid index (was: %d, max: %d)", index, ARRAYSIZE(_names));
return _names[index];
}
-bool Savegame::hasSavegame(uint32 index) {
- if (index > ARRAYSIZE(_savegames))
+bool Savegame::hasSavegame(uint32 index) const {
+ if (index >= ARRAYSIZE(_savegames))
error("[Savegame::hasSavegame] Invalid index (was: %d, max: %d)", index, ARRAYSIZE(_savegames));
return _savegames[index];
diff --git a/engines/asylum/system/savegame.h b/engines/asylum/system/savegame.h
index bb26e98fd1..d5fa4ba971 100644
--- a/engines/asylum/system/savegame.h
+++ b/engines/asylum/system/savegame.h
@@ -45,7 +45,7 @@ public:
*
* @return true if it succeeds, false if it fails.
*/
- bool hasSavegames();
+ bool hasSavegames() const;
/**
* Loads the list of saved games.
@@ -89,20 +89,20 @@ public:
// Movies
//////////////////////////////////////////////////////////////////////////
void setMovieViewed(uint32 index);
- uint32 getMoviesViewed(int32 *movieList);
+ uint32 getMoviesViewed(int32 *movieList) const;
void loadMoviesViewed();
//////////////////////////////////////////////////////////////////////////
// Accessors
//////////////////////////////////////////////////////////////////////////
void setName(uint32 index, Common::String name);
- Common::String getName(uint32 index);
+ Common::String getName(uint32 index) const;
Common::String *getName() { return &_names[_index]; }
void setIndex(uint32 index) { _index = index; }
uint32 getIndex() { return _index; }
- bool hasSavegame(uint32 index);
+ bool hasSavegame(uint32 index) const;
ResourcePackId getScenePack() { return (ResourcePackId)(_savegameToScene[_index] + 4); }
private:
@@ -133,7 +133,7 @@ private:
*
* @return The filename.
*/
- Common::String getFilename(uint32 index);
+ Common::String getFilename(uint32 index) const;
/**
* Check if a specific savegame exists
@@ -142,7 +142,7 @@ private:
*
* @return true if savegame present, false if not.
*/
- bool isSavegamePresent(Common::String filename);
+ bool isSavegamePresent(Common::String filename) const;
//////////////////////////////////////////////////////////////////////////
// Reading & writing
@@ -162,7 +162,7 @@ private:
*
* @param [in,out] file If non-null, the file.
*/
- void writeHeader(Common::OutSaveFile *file);
+ void writeHeader(Common::OutSaveFile *file) const;
/**
* Loads savegame data
@@ -191,7 +191,7 @@ private:
* @param offset Offset index of the info into the file
* @param description The description.
*/
- void seek(Common::InSaveFile *file, uint32 offset, Common::String description);
+ void seek(Common::InSaveFile *file, uint32 offset, Common::String description) const;
/**
* Reads data from a file.
@@ -201,7 +201,7 @@ private:
*
* @return the value
*/
- uint32 read(Common::InSaveFile *file, Common::String description);
+ uint32 read(Common::InSaveFile *file, Common::String description) const;
/**
* Reads data from a file.
@@ -212,7 +212,7 @@ private:
*
* @return the string
*/
- Common::String read(Common::InSaveFile *file, uint32 strLength, Common::String description);
+ Common::String read(Common::InSaveFile *file, uint32 strLength, Common::String description) const;
/**
* Reads data from a file.
@@ -223,7 +223,7 @@ private:
* @param count Number of.
* @param description The description.
*/
- void read(Common::InSaveFile *file, Common::Serializable *data, uint32 size, uint32 count, Common::String description);
+ void read(Common::InSaveFile *file, Common::Serializable *data, uint32 size, uint32 count, Common::String description) const;
/**
* Writes data to a file.
@@ -232,17 +232,17 @@ private:
* @param val The value
* @param description The description.
*/
- void write(Common::OutSaveFile *file, uint32 val, Common::String description);
+ void write(Common::OutSaveFile *file, uint32 val, Common::String description) const;
/**
* Writes data to a file.
*
* @param [in,out] file If non-null, the file.
* @param val The string
- * @param count The size of the string.
+ * @param strLength The size of the string.
* @param description The description.
*/
- void write(Common::OutSaveFile *file, Common::String val, uint32 count, Common::String description);
+ void write(Common::OutSaveFile *file, Common::String val, uint32 strLength, Common::String description) const;
/**
* Writes data to a file.
@@ -253,7 +253,7 @@ private:
* @param count Number of.
* @param description The description.
*/
- void write(Common::OutSaveFile *file, Common::Serializable *data, uint32 size, uint32 count, Common::String description);
+ void write(Common::OutSaveFile *file, Common::Serializable *data, uint32 size, uint32 count, Common::String description) const;
};
} // End of namespace Asylum
diff --git a/engines/asylum/system/sound.h b/engines/asylum/system/sound.h
index f6867d4082..9a31ccd54a 100644
--- a/engines/asylum/system/sound.h
+++ b/engines/asylum/system/sound.h
@@ -77,7 +77,7 @@ struct AmbientSoundItem {
int32 delta;
int32 attenuation;
int32 nextTick;
- GameFlag flagNum[6];
+ int32 flagNum[6];
Common::Point point;
AmbientSoundItem() {
diff --git a/engines/asylum/system/speech.cpp b/engines/asylum/system/speech.cpp
index 5bbe3eef2d..f91f32d2f6 100644
--- a/engines/asylum/system/speech.cpp
+++ b/engines/asylum/system/speech.cpp
@@ -239,7 +239,7 @@ void Speech::prepareSpeech() {
Actor *actor = getScene()->getActor();
actor->adjustCoordinates(&point);
- int32 posY = (point.y >= 240) ? 40 : 320;
+ int16 posY = (point.y >= 240) ? 40 : 320;
getText()->draw(_textDataPos, getWorld()->font3, posY);
getText()->draw(_textData, getWorld()->font1, posY);
diff --git a/engines/asylum/system/text.cpp b/engines/asylum/system/text.cpp
index 01094c15b2..06a368a906 100644
--- a/engines/asylum/system/text.cpp
+++ b/engines/asylum/system/text.cpp
@@ -66,25 +66,25 @@ void Text::setPosition(const Common::Point &point) {
_position = point;
}
-uint16 Text::getWidth(char c) {
+int16 Text::getWidth(char c) {
if (!_fontResource)
error("[Text::getWidth] Font not initialized properly");
GraphicFrame *font = _fontResource->getFrame((uint8)c);
- return font->surface.w + font->x - _curFontFlags;
+ return (int16)(font->surface.w + font->x - _curFontFlags);
}
-uint16 Text::getWidth(const char *text) {
+int16 Text::getWidth(const char *text) {
if (!_fontResource)
error("[Text::getWidth] font resource hasn't been loaded yet!");
- uint16 width = 0;
+ int16 width = 0;
char character = *text;
while (character) {
GraphicFrame *font = _fontResource->getFrame((uint8)character);
- width += font->surface.w + font->x - _curFontFlags;
+ width += (int16)(font->surface.w + font->x - _curFontFlags);
text++;
character = *text;
@@ -93,19 +93,19 @@ uint16 Text::getWidth(const char *text) {
return width;
}
-uint16 Text::getWidth(const char *text, uint32 length) {
+int16 Text::getWidth(const char *text, int16 length) {
if (!_fontResource)
error("[Text::getWidth] font resource hasn't been loaded yet!");
if (length == 0)
return 0;
- uint16 width = 0;
+ int16 width = 0;
char character = *text;
while (character && length > 0) {
GraphicFrame *font = _fontResource->getFrame((uint8)character);
- width += font->surface.w + font->x - _curFontFlags;
+ width += (int16)(font->surface.w + font->x - _curFontFlags);
text++;
character = *text;
@@ -115,7 +115,7 @@ uint16 Text::getWidth(const char *text, uint32 length) {
return width;
}
-uint16 Text::getWidth(ResourceId resourceId) {
+int16 Text::getWidth(ResourceId resourceId) {
return getWidth(get(resourceId));
}
@@ -148,14 +148,14 @@ void Text::draw(const char *text) {
}
}
-void Text::draw(const char *text, uint32 length) {
+void Text::draw(const char *text, int16 length) {
if (length == 0)
return;
if (!text)
return;
- for (uint i = 0; i < length; i++)
+ for (int16 i = 0; i < length; i++)
drawChar(text[i]);
}
@@ -173,7 +173,7 @@ void Text::draw(const Common::Point &point, ResourceId resourceId) {
draw(point, get(resourceId));
}
-void Text::draw(const char *text, ResourceId fontResourceId, int32 y) {
+void Text::draw(const char *text, ResourceId fontResourceId, int16 y) {
if (text) {
loadFont(fontResourceId);
draw(kTextCenter, Common::Point(20, y), 16, 600, text);
@@ -184,7 +184,7 @@ int16 Text::draw(TextCentering centering, const Common::Point &point, int16 spac
return draw(0, 99, centering, point, spacing, width, text);
}
-int16 Text::draw(int32 a1, int32 a2, TextCentering centering, const Common::Point &point, int16 spacing, int16 width, const char *text) {
+int16 Text::draw(int16 a1, int16 a2, TextCentering centering, const Common::Point &point, int16 spacing, int16 width, const char *text) {
if (!text || !*text)
return 0;
@@ -214,12 +214,12 @@ label_start:
break;
case kTextCenter:
- drawCentered(coords, width, endText - string, string);
+ drawCentered(coords, width, (int16)(endText - string), string);
break;
case kTextNormal:
setPosition(coords);
- draw(text, (uint32)(endText - text));
+ draw(text, (int16)(endText - text));
break;
}
diff --git a/engines/asylum/system/text.h b/engines/asylum/system/text.h
index 27128119be..fd25041fe5 100644
--- a/engines/asylum/system/text.h
+++ b/engines/asylum/system/text.h
@@ -48,10 +48,10 @@ public:
ResourceId loadFont(ResourceId resourceId);
void setPosition(const Common::Point &point);
- uint16 getWidth(char c);
- uint16 getWidth(const char *text);
- uint16 getWidth(const char *text, uint32 length);
- uint16 getWidth(ResourceId resourceId);
+ int16 getWidth(char c);
+ int16 getWidth(const char *text);
+ int16 getWidth(const char *text, int16 length);
+ int16 getWidth(ResourceId resourceId);
char *get(ResourceId resourceId);
void drawChar(char character);
@@ -59,10 +59,10 @@ public:
void draw(const Common::Point &point, const char *text);
void draw(ResourceId resourceId);
void draw(const Common::Point &point, ResourceId resourceId);
- void draw(const char *text, ResourceId fontResourceId, int32 y);
- void draw(const char *text, uint32 length);
+ void draw(const char *text, ResourceId fontResourceId, int16 y);
+ void draw(const char *text, int16 length);
int16 draw(TextCentering centering, const Common::Point &point, int16 spacing, int16 width, const char *text);
- int16 draw(int32 a1, int32 a2, TextCentering centering, const Common::Point &point, int16 spacing, int16 width, const char *text);
+ int16 draw(int16 a1, int16 a2, TextCentering centering, const Common::Point &point, int16 spacing, int16 width, const char *text);
void drawCentered(const Common::Point &point, int16 width, const char *text);
void drawCentered(const Common::Point &point, int16 width, ResourceId resourceId);
diff --git a/engines/asylum/views/menu.h b/engines/asylum/views/menu.h
index 1f862c3c4e..445e462d6a 100644
--- a/engines/asylum/views/menu.h
+++ b/engines/asylum/views/menu.h
@@ -83,6 +83,7 @@ private:
};
enum MenuResource {
+ kResourceNone = 0,
kBackground = MAKE_RESOURCE(kResourcePackShared, 0),
kEye = MAKE_RESOURCE(kResourcePackShared, 1),
kFontBlue = MAKE_RESOURCE(kResourcePackShared, 22),
diff --git a/engines/asylum/views/scene.cpp b/engines/asylum/views/scene.cpp
index da6e321de6..add781f1ca 100644
--- a/engines/asylum/views/scene.cpp
+++ b/engines/asylum/views/scene.cpp
@@ -63,6 +63,7 @@ Scene::Scene(AsylumEngine *engine): _vm(engine),
_playerIndex = 0;
_hitAreaChapter7Counter = 0;
+ _isCTRLPressed = false;
_chapter5RainFrameIndex = 0;
_musicVolume = 0;
@@ -200,6 +201,9 @@ void Scene::enter(ResourcePackId packId) {
}
void Scene::enterLoad() {
+ if (!_ws)
+ error("[Scene::enterLoad] WorldStats not initialized properly");
+
_vm->setGameFlag(kGameFlagScriptProcessing);
getScreen()->clearGraphicsInQueue();
@@ -337,6 +341,9 @@ void Scene::activate() {
}
bool Scene::init() {
+ if (!_ws)
+ error("[Scene::init] WorldStats not initialized properly");
+
if (getSharedData()->getFlag((kFlag3))) { // this flag is set during an encounter
getSharedData()->setFlag(kFlag3, false);
@@ -401,6 +408,9 @@ bool Scene::update() {
}
bool Scene::key(const AsylumEvent &evt) {
+ if (!_ws)
+ error("[Scene::key] WorldStats not initialized properly");
+
// TODO add support for debug commands
//////////////////////////////////////////////////////////////////////////
@@ -836,9 +846,9 @@ void Scene::updateAmbientSounds() {
uint32 ambientTick = getSharedData()->getAmbientTick(i);
for (int32 f = 0; f < 6; f++) {
- GameFlag gameFlag = snd->flagNum[f];
+ int32 gameFlag = snd->flagNum[f];
if (gameFlag >= 0) {
- if (_vm->isGameFlagNotSet(gameFlag)) {
+ if (_vm->isGameFlagNotSet((GameFlag)gameFlag)) {
processSound = false;
break;
}
@@ -1800,7 +1810,7 @@ void Scene::stopSpeech() {
}
bool Scene::speak(Common::KeyCode code) {
-#define GET_INDEX(val) ((((long long)val >> 32) ^ (abs((int)val) & 1)) == ((long long)val >> 32))
+#define GET_INDEX() ((int)abs((double)_vm->getRandom(RAND_MAX)) & 1)
int32 index = -1;
@@ -1814,7 +1824,7 @@ bool Scene::speak(Common::KeyCode code) {
break;
case 0:
- index = GET_INDEX(_vm->getRandom(RAND_MAX));
+ index = GET_INDEX();
break;
case 1:
@@ -1831,7 +1841,7 @@ bool Scene::speak(Common::KeyCode code) {
break;
case 0:
- index = 3 - GET_INDEX(_vm->getRandom(RAND_MAX));
+ index = 3 - GET_INDEX();
break;
case 1:
@@ -1979,7 +1989,7 @@ bool Scene::speak(Common::KeyCode code) {
break;
case 0:
- index = 13 - GET_INDEX(_vm->getRandom(65536));
+ index = 13 - GET_INDEX();
break;
case 1:
@@ -1995,11 +2005,11 @@ bool Scene::speak(Common::KeyCode code) {
break;
case 0:
- index = 15 - GET_INDEX(_vm->getRandom(RAND_MAX));
+ index = 15 - GET_INDEX();
break;
case 2:
- index = 12 - GET_INDEX(_vm->getRandom(RAND_MAX));
+ index = 12 - GET_INDEX();
break;
}
break;
@@ -2706,6 +2716,9 @@ void Scene::debugShowPolygons() {
}
void Scene::debugShowPolygon(uint32 index, uint32 color) {
+ if (!_polygons)
+ error("[Scene::debugShowPolygon] Polygons not initialized properly");
+
if (index >= _polygons->size() - 1)
return;
diff --git a/engines/asylum/views/scenetitle.cpp b/engines/asylum/views/scenetitle.cpp
index 91c0f37d3d..dad25f8c69 100644
--- a/engines/asylum/views/scenetitle.cpp
+++ b/engines/asylum/views/scenetitle.cpp
@@ -69,7 +69,7 @@ void SceneTitle::update(int32 tick) {
getScreen()->draw(getWorld()->sceneTitleGraphicResourceId);
getScreen()->draw(MAKE_RESOURCE(kResourcePackSound, 17), _spinnerFrameIndex, Common::Point((int16)(((_spinnerProgress / 590.0) * 580.0) - 290), 0), kDrawFlagNone, false);
- getText()->drawCentered(Common::Point(320, 30), 24, MAKE_RESOURCE(kResourcePackText, 1811 + getWorld()->chapter));
+ getText()->drawCentered(Common::Point(320, 30), 24, MAKE_RESOURCE(kResourcePackText, getWorld()->chapter + 1811));
// This is not from the original. It's just some arbitrary math to throttle the progress indicator.
//
Commit: 78f275d7961f55c874e2b3ca9bcb1d5231942fc9
https://github.com/scummvm/scummvm/commit/78f275d7961f55c874e2b3ca9bcb1d5231942fc9
Author: Littleboy (littleboy at scummvm.org)
Date: 2021-05-17T15:37:15+02:00
Commit Message:
ASYLUM: Cleanup Scene and related classes
Changed paths:
engines/asylum/resources/data.h
engines/asylum/resources/encounters.cpp
engines/asylum/resources/object.cpp
engines/asylum/resources/object.h
engines/asylum/resources/script.cpp
engines/asylum/resources/script.h
engines/asylum/resources/worldstats.cpp
engines/asylum/resources/worldstats.h
engines/asylum/views/scene.cpp
engines/asylum/views/scene.h
diff --git a/engines/asylum/resources/data.h b/engines/asylum/resources/data.h
index 7b39b1f2c4..4e1ee3e170 100644
--- a/engines/asylum/resources/data.h
+++ b/engines/asylum/resources/data.h
@@ -157,10 +157,10 @@ public:
void setGlobalPoint(const Common::Point &point) { _globalPoint = point; }
Common::Point getSceneCoords() { return _sceneCoords; }
void setSceneCoords(const Common::Point &point) { _sceneCoords = point; }
- int32 getSceneOffset() { return _sceneOffset; }
- void setSceneOffset(int32 sceneOffset) { _sceneOffset = sceneOffset; }
- int32 getSceneOffsetAdd() { return _sceneOffsetAdd; }
- void setSceneOffsetAdd(int32 sceneOffsetAdd) { _sceneOffsetAdd = sceneOffsetAdd; }
+ int16 getSceneOffset() { return _sceneOffset; }
+ void setSceneOffset(int16 sceneOffset) { _sceneOffset = sceneOffset; }
+ int16 getSceneOffsetAdd() { return _sceneOffsetAdd; }
+ void setSceneOffsetAdd(int16 sceneOffsetAdd) { _sceneOffsetAdd = sceneOffsetAdd; }
// Saved scene data
void saveCursorResources(ResourceId *resources, uint32 size);
@@ -212,8 +212,8 @@ private:
// _flagEncounterRunning
// player ActorIndex
Common::Point _sceneCoords;
- int32 _sceneOffset;
- int32 _sceneOffsetAdd;
+ int16 _sceneOffset;
+ int16 _sceneOffsetAdd;
ResourceId _cursorResources[13];
ResourceId _sceneFonts[3];
uint32 _chapter2Data1[5];
diff --git a/engines/asylum/resources/encounters.cpp b/engines/asylum/resources/encounters.cpp
index 39d6224d59..9e1289fc49 100644
--- a/engines/asylum/resources/encounters.cpp
+++ b/engines/asylum/resources/encounters.cpp
@@ -1603,7 +1603,7 @@ void Encounter::runScript() {
if (!getSharedData()->getMatteBarHeight()) {
getScreen()->loadPalette();
getSharedData()->setMatteBarHeight(1);
- getSharedData()->movieIndex = (uint32)getVariableInv(entry.param2);
+ getSharedData()->movieIndex = (uint16)getVariableInv(entry.param2);
getSharedData()->setMatteVar1(1);
getSharedData()->setMattePlaySound(true);
getSharedData()->setMatteInitialized(true);
diff --git a/engines/asylum/resources/object.cpp b/engines/asylum/resources/object.cpp
index 47e14ffb2f..f8aae50a12 100644
--- a/engines/asylum/resources/object.cpp
+++ b/engines/asylum/resources/object.cpp
@@ -83,7 +83,7 @@ void Object::load(Common::SeekableReadStream *stream) {
_rect.right = (int16)(stream->readSint32LE());
_rect.bottom = (int16)(stream->readSint32LE());
- _polygonIndex = stream->readSint32LE();
+ _polygonIndex = stream->readUint32LE();
actionType = stream->readSint32LE();
for (int i = 0; i < 10; i++)
diff --git a/engines/asylum/resources/object.h b/engines/asylum/resources/object.h
index f0c1f143d8..6a98485cc8 100644
--- a/engines/asylum/resources/object.h
+++ b/engines/asylum/resources/object.h
@@ -60,7 +60,7 @@ public:
uint32 getFrameCount() { return _frameCount; }
FrameSoundItem *getFrameSoundItem(uint32 index) { assert(index < ARRAYSIZE(_frameSoundItems)); return &_frameSoundItems[index]; }
ObjectId getId() { return _id; }
- int32 getPolygonIndex() { return _polygonIndex; }
+ uint32 getPolygonIndex() { return _polygonIndex; }
int32 getPriority() { return _priority; }
ResourceId getResourceId() { return _resourceId; }
ResourceId getSoundResourceId() { return _soundResourceId; }
@@ -184,7 +184,7 @@ private:
int32 _field_3C;
uint8 _name[52];
Common::Rect _rect;
- int32 _polygonIndex;
+ uint32 _polygonIndex;
// actionType
int32 _gameFlags[10];
int32 _field_B4;
diff --git a/engines/asylum/resources/script.cpp b/engines/asylum/resources/script.cpp
index c40ed5a51e..bbf3c838bc 100644
--- a/engines/asylum/resources/script.cpp
+++ b/engines/asylum/resources/script.cpp
@@ -59,7 +59,7 @@ void ActionArea::load(Common::SeekableReadStream *stream) {
flagNums[i] = stream->readSint32LE();
field_7C = stream->readSint32LE();
- polygonIndex = stream->readSint32LE();
+ polygonIndex = stream->readUint32LE();
soundResourceIdFrame = (ResourceId)stream->readSint32LE();
field_88 = stream->readSint32LE();
soundResourceId = (ResourceId)stream->readSint32LE();
@@ -522,8 +522,8 @@ IMPLEMENT_OPCODE(MoveScenePosition)
getWorld()->motionStatus = 5;
getScene()->updateSceneCoordinates(cmd->param1,
- cmd->param2,
- cmd->param3);
+ cmd->param2,
+ cmd->param3);
} else if (cmd->param5) {
if (getWorld()->motionStatus == 2)
@@ -535,9 +535,9 @@ IMPLEMENT_OPCODE(MoveScenePosition)
getWorld()->motionStatus = 2;
getScene()->updateSceneCoordinates(cmd->param1,
- cmd->param2,
- cmd->param3,
- true);
+ cmd->param2,
+ cmd->param3,
+ true);
_processNextEntry = true;
}
@@ -967,7 +967,7 @@ IMPLEMENT_OPCODE(PlayMovie)
getSharedData()->setMatteVar2(0);
getSharedData()->setMattePlaySound(cmd->param3 == 0);
getSharedData()->setMatteInitialized(cmd->param2 == 0);
- getSharedData()->movieIndex = cmd->param1;
+ getSharedData()->movieIndex = (uint32)cmd->param1;
}
return;
@@ -1366,8 +1366,8 @@ IMPLEMENT_OPCODE(MoveScenePositionFromActor)
getWorld()->motionStatus = 5;
getScene()->updateSceneCoordinates(actor->getPoint1()->x + Common::Rational(actor->getPoint2()->x, 2).toInt() - 320,
- actor->getPoint1()->y + Common::Rational(actor->getPoint2()->y, 2).toInt() - 240,
- cmd->param2);
+ actor->getPoint1()->y + Common::Rational(actor->getPoint2()->y, 2).toInt() - 240,
+ cmd->param2);
} else if (cmd->param6) {
if (getWorld()->motionStatus == 2) {
_processNextEntry = true;
@@ -1380,10 +1380,10 @@ IMPLEMENT_OPCODE(MoveScenePositionFromActor)
getWorld()->motionStatus = 2;
if (getScene()->updateSceneCoordinates(actor->getPoint1()->x + Common::Rational(actor->getPoint2()->x, 2).toInt() - 320,
- actor->getPoint1()->y + Common::Rational(actor->getPoint2()->y, 2).toInt() - 240,
- cmd->param2,
- true,
- &cmd->param6))
+ actor->getPoint1()->y + Common::Rational(actor->getPoint2()->y, 2).toInt() - 240,
+ cmd->param2,
+ true,
+ &cmd->param6))
_processNextEntry = false;
else
_processNextEntry = true;
diff --git a/engines/asylum/resources/script.h b/engines/asylum/resources/script.h
index 8e8693d641..8a8f608d13 100644
--- a/engines/asylum/resources/script.h
+++ b/engines/asylum/resources/script.h
@@ -69,7 +69,7 @@ struct ActionArea {
int32 actionType; ///< flag (see ActionType enumeration)
int32 flagNums[10];
int32 field_7C;
- int32 polygonIndex;
+ uint32 polygonIndex;
ResourceId soundResourceIdFrame;
int32 field_88;
ResourceId soundResourceId;
diff --git a/engines/asylum/resources/worldstats.cpp b/engines/asylum/resources/worldstats.cpp
index cbb657f8c1..d1a85c36e9 100644
--- a/engines/asylum/resources/worldstats.cpp
+++ b/engines/asylum/resources/worldstats.cpp
@@ -135,15 +135,15 @@ void WorldStats::load(Common::SeekableReadStream *stream) {
smallCurDown = stream->readSint32LE();
encounterFrameBg = (ResourceId)stream->readSint32LE();
- width = stream->readSint32LE();
- height = stream->readSint32LE();
+ width = (int16)stream->readSint32LE();
+ height = (int16)stream->readSint32LE();
motionStatus = stream->readSint32LE();
field_8C = stream->readSint32LE();
uint32 numActions = stream->readUint32LE();
uint32 numObjects = stream->readUint32LE();
for (int32 c = 0; c < 7; c++)
- coordinates[c] = stream->readSint32LE();
+ coordinates[c] = (int16)stream->readSint32LE();
uint32 numActors = stream->readUint32LE();
@@ -188,7 +188,7 @@ void WorldStats::load(Common::SeekableReadStream *stream) {
ambientSounds[s].point.y = (int16)stream->readSint32LE();
}
- numAmbientSounds = stream->readSint32LE();
+ numAmbientSounds = stream->readUint32LE();
musicStatus = stream->readSint32LE();
musicCurrentResourceIndex = stream->readSint32LE();
musicFlag = stream->readSint32LE();
diff --git a/engines/asylum/resources/worldstats.h b/engines/asylum/resources/worldstats.h
index b4eaa7064a..4750268ae8 100644
--- a/engines/asylum/resources/worldstats.h
+++ b/engines/asylum/resources/worldstats.h
@@ -93,13 +93,13 @@ public:
int32 smallCurUp;
int32 smallCurDown;
ResourceId encounterFrameBg;
- int32 width; // field_80
- int32 height;
+ int16 width;
+ int16 height;
int32 motionStatus;
int32 field_8C;
//uint32 numActions;
//uint32 numObjects;
- int32 coordinates[7];
+ int16 coordinates[7];
//uint32 numActors;
int32 reverseStereo;
Common::Rect sceneRects[6]; // including scene size rect
@@ -113,7 +113,7 @@ public:
int32 actorType;
ResourceId soundResourceIds[50];
AmbientSoundItem ambientSounds[15];
- int32 numAmbientSounds;
+ uint32 numAmbientSounds;
int32 musicStatus;
int32 musicCurrentResourceIndex;
int32 musicFlag;
diff --git a/engines/asylum/views/scene.cpp b/engines/asylum/views/scene.cpp
index add781f1ca..611afd863e 100644
--- a/engines/asylum/views/scene.cpp
+++ b/engines/asylum/views/scene.cpp
@@ -840,7 +840,7 @@ void Scene::updateAmbientSounds() {
// The original loops for each actor, but the volume calculation is always the same
- for (int32 i = 0; i < _ws->numAmbientSounds; i++) {
+ for (uint32 i = 0; i < _ws->numAmbientSounds; i++) {
bool processSound = true;
AmbientSoundItem *snd = &_ws->ambientSounds[i];
uint32 ambientTick = getSharedData()->getAmbientTick(i);
@@ -882,7 +882,7 @@ void Scene::updateAmbientSounds() {
if (snd->field_0)
volume = getSound()->calculateVolumeAdjustement(snd->point, snd->attenuation, snd->delta);
else
- volume = -pow((double)snd->delta, 2);
+ volume = -(int32)pow((double)snd->delta, 2);
volume += Config.ambientVolume;
@@ -896,7 +896,7 @@ void Scene::updateAmbientSounds() {
if (snd->field_0) {
getSound()->playSound(snd->resourceId, false, volume, panning);
} else {
- int32 tmpVol = volume + _vm->getRandom(500) * ((((_vm->getRandom(100) >= 50) - 1) & 2) - 1);
+ int32 tmpVol = volume + (int32)_vm->getRandom(500) * ((_vm->getRandom(100) >= 50) ? -1 : 1);
if (tmpVol <= -10000)
tmpVol = -10000;
@@ -912,9 +912,9 @@ void Scene::updateAmbientSounds() {
} else if (LOBYTE(snd->flags) & 4) {
if (ambientTick > _vm->getTick()) {
if (snd->nextTick >= 0)
- getSharedData()->setAmbientTick(i, 60000 * snd->nextTick + _vm->getTick());
+ getSharedData()->setAmbientTick(i, (uint32)((int32)_vm->getTick() + snd->nextTick * 60000));
else
- getSharedData()->setAmbientTick(i, _vm->getTick() - 1000 * snd->nextTick);
+ getSharedData()->setAmbientTick(i, (uint32)((int32)_vm->getTick() - snd->nextTick * 1000));
getSound()->playSound(snd->resourceId, false, volume, panning);
}
@@ -1031,10 +1031,10 @@ void Scene::updateAdjustScreen() {
void Scene::updateCoordinates() {
Actor *act = getActor();
- int32 xLeft = _ws->xLeft;
- int32 yTop = _ws->yTop;
- int32 posX = act->getPoint1()->x - _ws->xLeft;
- int32 posY = act->getPoint1()->y - _ws->yTop;
+ int16 xLeft = _ws->xLeft;
+ int16 yTop = _ws->yTop;
+ int16 posX = act->getPoint1()->x - _ws->xLeft;
+ int16 posY = act->getPoint1()->y - _ws->yTop;
Common::Rect boundingRect = _ws->boundingRect;
switch (_ws->motionStatus) {
@@ -1127,7 +1127,7 @@ void Scene::updateCoordinates() {
// TODO set a var if scene coordinates changed
}
-void Scene::updateCursor(ActorDirection direction, Common::Rect rect) {
+void Scene::updateCursor(ActorDirection direction, const Common::Rect &rect) {
HitType type = kHitNone;
Actor *player = getActor();
int16 rightLimit = rect.right - 10;
@@ -1175,7 +1175,7 @@ void Scene::updateCursor(ActorDirection direction, Common::Rect rect) {
ResourceId id = _ws->cursorResourcesAlternate[player->getField638() + 47];
uint32 frameCount = GraphicResource::getFrameCount(_vm, id);
if (getCursor()->getResourceId() != id)
- getCursor()->set(id, 0, (CursorAnimation)(((frameCount <= 1) - 1) & 2));
+ getCursor()->set(id, 0, (frameCount <= 1) ? kCursorAnimationNone : kCursorAnimationMirror);
}
}
@@ -1275,8 +1275,8 @@ int32 Scene::hitTestScene(HitType &type) {
const Common::Point pt = getCursor()->position();
- int32 top = pt.x + _ws->xLeft;
- int32 left = pt.y + _ws->yTop;
+ int16 top = pt.x + _ws->xLeft;
+ int16 left = pt.y + _ws->yTop;
type = kHitNone;
int32 index = findActionArea(kActionAreaType2, Common::Point(top, left));
@@ -1285,8 +1285,6 @@ int32 Scene::hitTestScene(HitType &type) {
type = kHitActionArea;
return index;
}
-
- index = -1;
}
// Check objects
@@ -1296,9 +1294,9 @@ int32 Scene::hitTestScene(HitType &type) {
if (object->isOnScreen() && (object->actionType & kActionType8)) {
if (hitTestPixel(object->getResourceId(),
object->getFrameIndex(),
- top - object->x,
- left - object->y,
- object->flags & kObjectFlag1000)) {
+ top - object->x,
+ left - object->y,
+ (bool)(object->flags & kObjectFlag1000))) {
type = kHitObject;
return i;
}
@@ -1314,8 +1312,8 @@ int32 Scene::hitTestScene(HitType &type) {
if (hitTestPixel(actor->getResourceId(),
frameIndex,
- top - actor->getPoint()->x - actor->getPoint1()->x,
- left - actor->getPoint()->y - actor->getPoint1()->y,
+ top - (actor->getPoint()->x + actor->getPoint1()->x),
+ left - (actor->getPoint()->y + actor->getPoint1()->y),
actor->getDirection() >= kDirectionSE)) {
type = kHitActor;
return i;
@@ -1338,6 +1336,9 @@ int32 Scene::hitTestActionArea() {
}
ActorIndex Scene::hitTestActor() {
+ if (!_ws)
+ error("[Scene::hitTestActor] WorldStats not initialized properly!");
+
const Common::Point mouse = getCursor()->position();
if (_ws->actors.size() == 0)
@@ -1368,10 +1369,9 @@ ActorIndex Scene::hitTestActor() {
if (_ws->actors.size() >= 11) {
Actor *actor11 = getActor(11);
if (actor11->isOnScreen() && actor11->actionType) {
- int x = mouse.x + _ws->xLeft - actor11->getPoint1()->x;
- int y = mouse.y + _ws->yTop - actor11->getPoint1()->y;
+ Common::Point pt = mouse + Common::Point(_ws->xLeft, _ws->yTop) - *actor11->getPoint1();
- if (actor11->getBoundingRect()->contains(x, y))
+ if (actor11->getBoundingRect()->contains(pt))
return 11;
}
}
@@ -1445,16 +1445,16 @@ ActorIndex Scene::hitTestActor() {
for (int i = _ws->actors.size() - 1; i >= 0 ; i--) {
Actor *actor = getActor(i);
- int32 hitFrame;
+ uint32 hitFrame;
if (actor->getFrameIndex() >= actor->getFrameCount())
- hitFrame = 2 * actor->getFrameIndex() - actor->getFrameCount() - 1;
+ hitFrame = 2 * actor->getFrameIndex() - (actor->getFrameCount() + 1);
else
hitFrame = actor->getFrameIndex();
if (hitTestPixel(actor->getResourceId(),
hitFrame,
- _ws->xLeft - actor->getPoint()->x - actor->getPoint1()->x,
- _ws->yTop - actor->getPoint()->y - actor->getPoint1()->y,
+ _ws->xLeft - (actor->getPoint()->x + actor->getPoint1()->x),
+ _ws->yTop - (actor->getPoint()->y + actor->getPoint1()->y),
actor->getDirection() >= kDirectionSE))
return i;
}
@@ -1474,8 +1474,8 @@ bool Scene::hitTestPlayer() {
return hitTestPixel(player->getResourceId(),
frameIndex,
- pt.x - player->getPoint()->x - point.x,
- pt.y - player->getPoint()->y - point.y,
+ pt.x - (player->getPoint()->x + point.x),
+ pt.y - (player->getPoint()->y + point.y),
player->getDirection() >= kDirectionSE);
}
@@ -1492,14 +1492,14 @@ int32 Scene::hitTestObject() {
object->getFrameIndex(),
_ws->xLeft + pt.x - object->x,
_ws->yTop + pt.y - object->y,
- object->flags & kObjectFlag1000))
+ (bool)(object->flags & kObjectFlag1000)))
return i;
}
return -1;
}
-bool Scene::hitTestPixel(ResourceId resourceId, int32 frameIndex, int16 x, int16 y, bool flipped) {
+bool Scene::hitTestPixel(ResourceId resourceId, uint32 frameIndex, int16 x, int16 y, bool flipped) {
if (x < 0 || y < 0)
return false;
@@ -1533,7 +1533,7 @@ bool Scene::hitTestPixel(ResourceId resourceId, int32 frameIndex, int16 x, int16
// Check pixel value
byte *pixel;
if (flipped) {
- pixel = (byte *)frame->surface.getBasePtr(left - x + frame->getWidth() - 1, y - frame->y);
+ pixel = (byte *)frame->surface.getBasePtr((left - x) + frame->getWidth() - 1, y - frame->y);
} else {
pixel = (byte *)frame->surface.getBasePtr(x - left, y - frame->y);
}
@@ -1555,6 +1555,9 @@ cleanup:
// Hit actions
//////////////////////////////////////////////////////////////////////////
void Scene::handleHit(int32 index, HitType type) {
+ if (!_ws)
+ error("[Scene::handleHit] WorldStats not initialized properly!");
+
switch (type) {
default:
break;
@@ -1644,7 +1647,7 @@ void Scene::playerReaction() {
player->adjustCoordinates(&point);
- uint32 maxIndex = 0;
+ uint32 maxIndex;
for (maxIndex = 0; maxIndex < 8; maxIndex++) {
if (!player->getReactionValue(maxIndex))
break;
@@ -1720,19 +1723,25 @@ void Scene::hitAreaChapter7(int32 id) {
}
void Scene::hitAreaChapter11(int32 id) {
+ if (!_ws)
+ error("[Scene::hitAreaChapter11] WorldStats not initialized properly!");
+
if (id == 1670)
_ws->field_E849C = 666;
}
void Scene::hitActorChapter2(ActorIndex index) {
+ if (!_ws)
+ error("[Scene::hitActorChapter2] WorldStats not initialized properly!");
+
Actor *player = getActor();
if (player->getStatus() != kActorStatus14 && player->getStatus() != kActorStatus12)
return;
if (index == 11) {
- player->faceTarget(index + 9, kDirectionFromActor);
+ player->faceTarget((uint32)(index + 9), kDirectionFromActor);
player->updateStatus(kActorStatus15);
Actor *actor11 = getActor(index);
@@ -1751,13 +1760,16 @@ void Scene::hitActorChapter2(ActorIndex index) {
getSharedData()->setChapter2ActorIndex(index);
} else if (index > 12) {
- player->faceTarget(index + 9, kDirectionFromActor);
+ player->faceTarget((uint32)(index + 9), kDirectionFromActor);
player->updateStatus(kActorStatus15);
getSharedData()->setChapter2ActorIndex(index);
}
}
void Scene::hitActorChapter11(ActorIndex index) {
+ if (!_ws)
+ error("[Scene::hitActorChapter11] WorldStats not initialized properly!");
+
if (_ws->field_E848C < 3)
_ws->field_E849C = index;
}
@@ -1810,6 +1822,9 @@ void Scene::stopSpeech() {
}
bool Scene::speak(Common::KeyCode code) {
+ if (!_ws)
+ error("[Scene::speak] WorldStats not initialized properly!");
+
#define GET_INDEX() ((int)abs((double)_vm->getRandom(RAND_MAX)) & 1)
int32 index = -1;
@@ -2028,7 +2043,7 @@ bool Scene::speak(Common::KeyCode code) {
#undef GET_INDEX
}
-bool Scene::pointIntersectsRect(Common::Point point, Common::Rect rect) {
+bool Scene::pointIntersectsRect(const Common::Point &point, const Common::Rect &rect) const {
if (rect.top || rect.left || rect.bottom || rect.right) {
Common::Rational res(rect.height() * (point.x - rect.left), rect.width());
@@ -2038,11 +2053,14 @@ bool Scene::pointIntersectsRect(Common::Point point, Common::Rect rect) {
return true;
}
-bool Scene::rectIntersect(int32 x, int32 y, int32 x1, int32 y1, int32 x2, int32 y2, int32 x3, int32 y3) {
+bool Scene::rectIntersect(int32 x, int32 y, int32 x1, int32 y1, int32 x2, int32 y2, int32 x3, int32 y3) const {
return (x <= x3 && x1 >= x2) && (y <= y3 && y1 >= y2);
}
void Scene::adjustCoordinates(Common::Point *point) {
+ if (!_ws)
+ error("[Scene::adjustCoordinates] WorldStats not initialized properly!");
+
point->x = _ws->xLeft + getCursor()->position().x;
point->y = _ws->yTop + getCursor()->position().y;
}
@@ -2065,14 +2083,14 @@ bool Scene::updateSceneCoordinates(int32 tX, int32 tY, int32 A0, bool checkScene
Common::Rect *sr = &_ws->sceneRects[_ws->sceneRectIdx];
- int32 *targetX = &_ws->coordinates[0];
- int32 *targetY = &_ws->coordinates[1];
- int32 *coord3 = &_ws->coordinates[2];
+ int16 *targetX = &_ws->coordinates[0];
+ int16 *targetY = &_ws->coordinates[1];
+ int16 *coord3 = &_ws->coordinates[2];
- *targetX = tX;
- *targetY = tY;
+ *targetX = (int16)tX;
+ *targetY = (int16)tY;
- *coord3 = A0;
+ *coord3 = (int16)A0;
// Adjust coordinates
if (checkSceneCoords)
@@ -2106,7 +2124,7 @@ bool Scene::updateSceneCoordinates(int32 tX, int32 tY, int32 A0, bool checkScene
if (_ws->yTop > *targetY)
*coord3 = -*coord3;
- getSharedData()->setSceneOffsetAdd(Common::Rational(*coord3 * diffX, diffY).toInt());
+ getSharedData()->setSceneOffsetAdd((int16)Common::Rational(*coord3 * diffX, diffY).toInt());
if (param != NULL && abs(diffY) <= abs(*coord3)) {
*targetX = -1;
@@ -2117,7 +2135,7 @@ bool Scene::updateSceneCoordinates(int32 tX, int32 tY, int32 A0, bool checkScene
if (_ws->xLeft > *targetX)
*coord3 = -*coord3;
- getSharedData()->setSceneOffsetAdd(Common::Rational(*coord3 * diffY, diffX).toInt());
+ getSharedData()->setSceneOffsetAdd((int16)Common::Rational(*coord3 * diffY, diffX).toInt());
if (param != NULL && abs(diffX) <= abs(*coord3)) {
*targetX = -1;
@@ -2129,7 +2147,7 @@ bool Scene::updateSceneCoordinates(int32 tX, int32 tY, int32 A0, bool checkScene
}
-int32 Scene::findActionArea(ActionAreaType type, const Common::Point pt, bool highlight) {
+int32 Scene::findActionArea(ActionAreaType type, const Common::Point &pt, bool highlight) {
if (!_ws)
error("[Scene::findActionArea] WorldStats not initialized properly!");
@@ -2147,8 +2165,10 @@ int32 Scene::findActionArea(ActionAreaType type, const Common::Point pt, bool hi
for (int32 i = _ws->actions.size() - 1; i >= 0; i--) {
ActionArea *area = _ws->actions[i];
- //if (g_debugPolygons && highlight)
- // debugHighlightPolygon(area->polygonIndex);
+#ifdef DEBUG
+ if (g_debugPolygons && highlight)
+ debugHighlightPolygon(area->polygonIndex);
+#endif
bool found = false;
@@ -2210,6 +2230,9 @@ int32 Scene::findActionArea(ActionAreaType type, const Common::Point pt, bool hi
}
void Scene::changePlayer(ActorIndex index) {
+ if (!_ws)
+ error("[Scene::changePlayer] WorldStats not initialized properly!");
+
switch (index) {
default:
if (_ws->chapter == kChapter9) {
@@ -2453,7 +2476,7 @@ void Scene::processUpdateList() {
actor->setField934(0);
Common::Point sum = *actor->getPoint1() + *actor->getPoint2();
- int32 bottomRight = actor->getPoint1()->y + actor->getBoundingRect()->bottom + 4;
+ int16 bottomRight = actor->getPoint1()->y + actor->getBoundingRect()->bottom + 4;
if (_ws->chapter == kChapter11 && _updateList[i].index != getPlayerIndex())
bottomRight += 20;
@@ -2651,16 +2674,19 @@ void Scene::adjustActorPriority(ActorIndex index) {
}
void Scene::drawRain() {
+ if (!_ws)
+ error("[Scene::drawRain] WorldStats not initialized properly!");
+
if (getSharedData()->getFlag(kFlagSkipDrawScene))
return;
- for (uint y = 0; y < 512; y = y + 64) {
- for (uint x = 0; x < 704; x = x + 64) {
- getScreen()->draw(MAKE_RESOURCE(kResourcePackShared, 58), _chapter5RainFrameIndex, Common::Point(x + (_ws->xLeft % 64) / 8, y + (_ws->yTop % 64) / 8));
+ for (int16 y = 0; y < 512; y = y + 64) {
+ for (int16 x = 0; x < 704; x = x + 64) {
+ getScreen()->draw(MAKE_RESOURCE(kResourcePackShared, 58), (uint32)_chapter5RainFrameIndex, Common::Point(x + (_ws->xLeft % 64) / 8, y + (_ws->yTop % 64) / 8));
}
}
- _chapter5RainFrameIndex = (_chapter5RainFrameIndex + 1) % GraphicResource::getFrameCount(_vm, MAKE_RESOURCE(kResourcePackShared, 58));
+ _chapter5RainFrameIndex = (_chapter5RainFrameIndex + 1) % (int32)GraphicResource::getFrameCount(_vm, MAKE_RESOURCE(kResourcePackShared, 58));
}
//////////////////////////////////////////////////////////////////////////
@@ -2675,21 +2701,21 @@ void Scene::debugScreenScrolling() {
// Horizontal scrolling
if (getCursor()->position().x < SCREEN_EDGES && _ws->xLeft >= SCROLL_STEP)
_ws->xLeft -= SCROLL_STEP;
- else if (getCursor()->position().x > 640 - SCREEN_EDGES && _ws->xLeft <= rect.width() - 640 - SCROLL_STEP)
+ else if (getCursor()->position().x > (640 - SCREEN_EDGES) && _ws->xLeft <= (rect.width() - (640 + SCROLL_STEP)))
_ws->xLeft += SCROLL_STEP;
// Vertical scrolling
if (getCursor()->position().y < SCREEN_EDGES && _ws->yTop >= SCROLL_STEP)
_ws->yTop -= SCROLL_STEP;
- else if (getCursor()->position().y > 480 - SCREEN_EDGES && _ws->yTop <= rect.height() - 480 - SCROLL_STEP)
+ else if (getCursor()->position().y > (480 - SCREEN_EDGES) && _ws->yTop <= (rect.height() - (480 + SCROLL_STEP)))
_ws->yTop += SCROLL_STEP;
}
// WALK REGION DEBUG
void Scene::debugShowWalkRegion(Polygon *poly) {
Graphics::Surface surface;
- surface.create(poly->boundingRect.right - poly->boundingRect.left + 1,
- poly->boundingRect.bottom - poly->boundingRect.top + 1,
+ surface.create((uint16)poly->boundingRect.width() + 1,
+ (uint16)poly->boundingRect.height() + 1,
Graphics::PixelFormat::createFormatCLUT8());
// Draw all lines in Polygon
@@ -2724,9 +2750,9 @@ void Scene::debugShowPolygon(uint32 index, uint32 color) {
Graphics::Surface surface;
Polygon poly = _polygons->get(index);
- surface.create(poly.boundingRect.right - poly.boundingRect.left + 1,
- poly.boundingRect.bottom - poly.boundingRect.top + 1,
- Graphics::PixelFormat::createFormatCLUT8());
+ surface.create((uint16)poly.boundingRect.width() + 1,
+ (uint16)poly.boundingRect.height() + 1,
+ Graphics::PixelFormat::createFormatCLUT8());
// Draw all lines in Polygon
for (uint32 i = 0; i < poly.count(); i++) {
@@ -2767,8 +2793,8 @@ void Scene::debugShowObjects() {
Object *object = _ws->objects[p];
if (object->isOnScreen()) {
- surface.create(object->getBoundingRect()->width() + 1,
- object->getBoundingRect()->height() + 1,
+ surface.create((uint16)object->getBoundingRect()->width() + 1,
+ (uint16)object->getBoundingRect()->height() + 1,
Graphics::PixelFormat::createFormatCLUT8());
surface.frameRect(*object->getBoundingRect(), 0x22);
getScreen()->copyToBackBufferClipped(&surface, object->x, object->y);
@@ -2780,13 +2806,16 @@ void Scene::debugShowObjects() {
// ACTOR DEBUGGING
void Scene::debugShowActors() {
+ if (!_ws)
+ error("[Scene::debugShowActors] WorldStats not initialized properly!");
+
for (uint32 p = 0; p < _ws->actors.size(); p++) {
Graphics::Surface surface;
Actor *a = _ws->actors[p];
if (a->isOnScreen()) {
- surface.create(a->getBoundingRect()->right - a->getBoundingRect()->left + 1,
- a->getBoundingRect()->bottom - a->getBoundingRect()->top + 1,
+ surface.create((uint16)a->getBoundingRect()->width() + 1,
+ (uint16)a->getBoundingRect()->height() + 1,
Graphics::PixelFormat::createFormatCLUT8());
surface.frameRect(*a->getBoundingRect(), 0x128);
getScreen()->copyToBackBufferClipped(&surface, a->getPoint1()->x, a->getPoint1()->y);
diff --git a/engines/asylum/views/scene.h b/engines/asylum/views/scene.h
index 23f033890a..12fd7fa2bb 100644
--- a/engines/asylum/views/scene.h
+++ b/engines/asylum/views/scene.h
@@ -185,7 +185,7 @@ public:
*
* @return The found action area.
*/
- int32 findActionArea(ActionAreaType type, const Common::Point pt, bool highlight = false);
+ int32 findActionArea(ActionAreaType type, const Common::Point &pt, bool highlight = false);
/**
* Check if rectangles intersect.
@@ -201,7 +201,7 @@ public:
*
* @return true if it succeeds, false if it fails.
*/
- bool rectIntersect(int32 x, int32 y, int32 x1, int32 y1, int32 x2, int32 y2, int32 x3, int32 y3);
+ bool rectIntersect(int32 x, int32 y, int32 x1, int32 y1, int32 x2, int32 y2, int32 x3, int32 y3) const;
Polygons *polygons() { return _polygons; }
WorldStats *worldstats() { return _ws; }
@@ -282,7 +282,7 @@ private:
* @param direction The direction.
* @param rect The rectangle.
*/
- void updateCursor(ActorDirection direction, Common::Rect rect);
+ void updateCursor(ActorDirection direction, const Common::Rect &rect);
//////////////////////////////////////////////////////////////////////////
// Scene drawing
@@ -396,7 +396,7 @@ private:
*
* @return true if it succeeds, false if it fails.
*/
- bool hitTestPixel(ResourceId resourceId, int32 frame, int16 x, int16 y, bool flipped);
+ bool hitTestPixel(ResourceId resourceId, uint32 frame, int16 x, int16 y, bool flipped);
//////////////////////////////////////////////////////////////////////////
// Hit actions
@@ -455,7 +455,7 @@ private:
*
* @return true if it succeeds, false if it fails.
*/
- bool pointIntersectsRect(Common::Point point, Common::Rect rect);
+ bool pointIntersectsRect(const Common::Point &point, const Common::Rect &rect) const;
/**
* Adjust coordinates.
Commit: 99f25211556e047e7186d507829d9bbef14a821a
https://github.com/scummvm/scummvm/commit/99f25211556e047e7186d507829d9bbef14a821a
Author: Littleboy (littleboy at scummvm.org)
Date: 2021-05-17T15:37:15+02:00
Commit Message:
ASYLUM: Cleanup Menu class
Changed paths:
engines/asylum/shared.h
engines/asylum/staticres.h
engines/asylum/views/menu.cpp
engines/asylum/views/menu.h
diff --git a/engines/asylum/shared.h b/engines/asylum/shared.h
index b921832006..66c112e99c 100644
--- a/engines/asylum/shared.h
+++ b/engines/asylum/shared.h
@@ -235,7 +235,7 @@ enum ResourcePackId {
kResourcePackInvalid = 0xFFF
};
-#define MAKE_RESOURCE(pack, index) (ResourceId)((((pack) << 16) + 0x80000000) + (uint32)(index))
+#define MAKE_RESOURCE(pack, index) (ResourceId)((((pack) << 16) + 0x80000000) + (unsigned) (int32)(index))
typedef int ResourceId;
diff --git a/engines/asylum/staticres.h b/engines/asylum/staticres.h
index 4334d0ab3b..1f6bc94030 100644
--- a/engines/asylum/staticres.h
+++ b/engines/asylum/staticres.h
@@ -41,7 +41,7 @@ const Common::Rect menuRects[12] = {Common::Rect( 40, 19, 93, 68),
Common::Rect( 538, 400, 591, 449), // The last two icons are swapped
Common::Rect( 439, 400, 492, 449)};
-const int eyeFrameIndex[8] = {3, 5, 1, 7, 4, 8, 2, 6};
+const uint32 eyeFrameIndex[8] = {3, 5, 1, 7, 4, 8, 2, 6};
const int moviesCd[49] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 2, 2, 2,
diff --git a/engines/asylum/views/menu.cpp b/engines/asylum/views/menu.cpp
index 23457c3ce2..c7845bd553 100644
--- a/engines/asylum/views/menu.cpp
+++ b/engines/asylum/views/menu.cpp
@@ -199,14 +199,14 @@ void Menu::stopTestSounds() {
getSound()->stop(kVoiceSound);
}
-void Menu::adjustMasterVolume(int32 delta) {
+void Menu::adjustMasterVolume(int32 delta) const {
int32 *volume = NULL;
int32 volumeIndex = 1;
do {
switch (volumeIndex) {
default:
- break;
+ error("[Menu::adjustMasterVolume] Invalid volume index (%d)", volumeIndex);
case 1:
volume = &Config.musicVolume;
@@ -315,24 +315,20 @@ bool Menu::handleEvent(const AsylumEvent &evt) {
case EVENT_ASYLUM_INIT:
return init();
- break;
case EVENT_ASYLUM_UPDATE:
return update();
- break;
case EVENT_ASYLUM_MUSIC:
return music();
- break;
case Common::EVENT_KEYDOWN:
return key(evt);
- break;
case Common::EVENT_LBUTTONDOWN:
case Common::EVENT_RBUTTONDOWN:
return click(evt);
- break;
+
}
return false;
@@ -769,8 +765,8 @@ void Menu::updateLoadGame() {
} else {
//////////////////////////////////////////////////////////////////////////
// First column
- uint32 index = 0;
- for (int32 y = 150; y < 324; y += 29) {
+ int32 index = 0;
+ for (int16 y = 150; y < 324; y += 29) {
if (index + _startIndex >= 25)
break;
@@ -790,7 +786,7 @@ void Menu::updateLoadGame() {
//////////////////////////////////////////////////////////////////////////
// Second column
- for (int32 y = 150; y < 324; y += 29) {
+ for (int16 y = 150; y < 324; y += 29) {
if (index + _startIndex >= 25)
break;
@@ -892,8 +888,8 @@ void Menu::updateSaveGame() {
} else {
//////////////////////////////////////////////////////////////////////////
// First column
- uint32 index = 0;
- for (int32 y = 150; y < 324; y += 29) {
+ int32 index = 0;
+ for (int16 y = 150; y < 324; y += 29) {
if (index + _startIndex >= 25)
break;
@@ -906,7 +902,7 @@ void Menu::updateSaveGame() {
else
getText()->loadFont(kFontBlue);
} else {
- if (getSaveLoad()->getIndex() != index + _startIndex)
+ if (getSaveLoad()->getIndex() != (uint32)(index + _startIndex))
getText()->loadFont(kFontYellow);
else
getText()->loadFont(kFontBlue);
@@ -917,7 +913,7 @@ void Menu::updateSaveGame() {
// Draw underscore
if (_dword_455DD8) {
- if (getSaveLoad()->getIndex() == index + _startIndex) {
+ if (getSaveLoad()->getIndex() == (uint32)(index + _startIndex)) {
if (_caretBlink < 6)
getText()->drawChar('_');
@@ -943,7 +939,7 @@ void Menu::updateSaveGame() {
else
getText()->loadFont(kFontBlue);
} else {
- if (getSaveLoad()->getIndex() != index + _startIndex)
+ if (getSaveLoad()->getIndex() != (uint32)(index + _startIndex))
getText()->loadFont(kFontYellow);
else
getText()->loadFont(kFontBlue);
@@ -954,7 +950,7 @@ void Menu::updateSaveGame() {
// Draw underscore
if (_dword_455DD8) {
- if (getSaveLoad()->getIndex() == index + _startIndex) {
+ if (getSaveLoad()->getIndex() == (uint32)(index + _startIndex)) {
if (_caretBlink < 6)
getText()->drawChar('_');
@@ -1152,7 +1148,7 @@ void Menu::updateViewMovies() {
//////////////////////////////////////////////////////////////////////////
// Second column
- for (int32 y = 150; y < 324; y += 29) {
+ for (int16 y = 150; y < 324; y += 29) {
if (index >= ARRAYSIZE(_movieList))
break;
@@ -1289,8 +1285,8 @@ void Menu::updateAudioOptions() {
Common::Point cursor = getCursor()->position();
// Size of - and +
- int32 sizeMinus = getText()->getWidth("-");
- int32 sizePlus = getText()->getWidth("+");
+ int16 sizeMinus = getText()->getWidth("-");
+ int16 sizePlus = getText()->getWidth("+");
getText()->loadFont(kFontYellow);
getText()->drawCentered(Common::Point(10, 100), 620, MAKE_RESOURCE(kResourcePackText, 1420));
@@ -1375,8 +1371,8 @@ void Menu::updateSettings() {
Common::Point cursor = getCursor()->position();
// Size of - and +
- int32 sizeMinus = getText()->getWidth("-");
- int32 sizePlus = getText()->getWidth("+");
+ int16 sizeMinus = getText()->getWidth("-");
+ int16 sizePlus = getText()->getWidth("+");
getText()->loadFont(kFontYellow);
@@ -1446,7 +1442,7 @@ void Menu::updateKeyboardConfig() {
getText()->drawCentered(Common::Point(10, 100), 620, MAKE_RESOURCE(kResourcePackText, 1438));
char keyCode = 0;
- int32 keyIndex = 0;
+ int16 keyIndex = 0;
do {
getText()->loadFont(kFontYellow);
@@ -1527,12 +1523,12 @@ void Menu::updateShowCredits() {
getScreen()->draw(MAKE_RESOURCE(kResourcePackShared, 33));
} else {
getScreen()->draw(MAKE_RESOURCE(kResourcePackShared, 23));
- getScreen()->draw(MAKE_RESOURCE(kResourcePackShared, 24), _creditsFrameIndex++ / 2, Common::Point(0, 0), kDrawFlagNone, false);
+ getScreen()->draw(MAKE_RESOURCE(kResourcePackShared, 24), (uint32)_creditsFrameIndex++ / 2, Common::Point(0, 0), kDrawFlagNone, false);
- _creditsFrameIndex %= 2 * GraphicResource::getFrameCount(_vm, MAKE_RESOURCE(kResourcePackShared, 24));
+ _creditsFrameIndex %= 2 * (int32)GraphicResource::getFrameCount(_vm, MAKE_RESOURCE(kResourcePackShared, 24));
}
- int32 step = 0;
+ int16 step = 0;
uint32 index = 0;
do {
if ((_startIndex + step) >= -24) {
@@ -1651,10 +1647,11 @@ void Menu::clickLoadGame() {
if (cursor.x <= (350 + getText()->getWidth((char *)&text))
&& cursor.y >= y
&& cursor.y <= (y + 24)) {
- if (index + _startIndex + 6 < 25) {
- if (getSaveLoad()->hasSavegame(index + _startIndex + 6)) {
+ uint32 saveIndex = (uint32)(index + _startIndex + 6);
+ if (saveIndex < 25) {
+ if (getSaveLoad()->hasSavegame(saveIndex)) {
_dword_455C80 = true;
- getSaveLoad()->setIndex(index + _startIndex + 6);
+ getSaveLoad()->setIndex(saveIndex);
}
}
}
@@ -1664,10 +1661,11 @@ void Menu::clickLoadGame() {
if (cursor.x <= (30 + getText()->getWidth((char *)&text))
&& cursor.y >= y
&& cursor.y <= (y + 24)) {
- if (index + _startIndex < 25) {
- if (getSaveLoad()->hasSavegame(index + _startIndex)) {
+ uint32 saveIndex = (uint32)(index + _startIndex);
+ if (saveIndex < 25) {
+ if (getSaveLoad()->hasSavegame(saveIndex)) {
_dword_455C80 = true;
- getSaveLoad()->setIndex(index + _startIndex);
+ getSaveLoad()->setIndex(saveIndex);
}
}
}
@@ -1685,7 +1683,7 @@ void Menu::clickSaveGame() {
|| cursor.y < 273 || cursor.y > (247 + 24)) {
if (cursor.x >= 369 && cursor.x <= (369 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 1341)))
&& cursor.y >= 273 && cursor.y <= (273 + 24))
- _dword_455C80 = 0;
+ _dword_455C80 = false;
} else {
_dword_455C80 = false;
_dword_455DD8 = true;
@@ -1735,8 +1733,8 @@ void Menu::clickSaveGame() {
//////////////////////////////////////////////////////////////////////////
// Columns
- uint32 index = 0;
- for (int32 y = 150; y < 324; y += 29) {
+ int32 index = 0;
+ for (int16 y = 150; y < 324; y += 29) {
if (cursor.x >= 350) {
sprintf((char *)&text, "%d. %s ", index + _startIndex + 7, getSaveLoad()->getName(index + _startIndex + 6).c_str());
@@ -1745,8 +1743,9 @@ void Menu::clickSaveGame() {
&& cursor.y <= (y + 24)
&& getWorld()->chapter != kChapterNone) {
if (index + _startIndex < 25) {
- getSaveLoad()->setIndex(index + _startIndex + 6);
- if (getSaveLoad()->hasSavegame(index + _startIndex + 6)) {
+ uint32 saveIndex = index + _startIndex + 6;
+ getSaveLoad()->setIndex(saveIndex);
+ if (getSaveLoad()->hasSavegame(saveIndex)) {
_dword_455C80 = true;
} else {
_dword_455DD8 = true;
@@ -1791,7 +1790,7 @@ void Menu::clickDeleteGame() {
|| cursor.y < 273 || cursor.y > (247 + 24)) {
if (cursor.x >= 369 && cursor.x <= (369 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 1351)))
&& cursor.y >= 273 && cursor.y <= (273 + 24))
- _dword_455C80 = 0;
+ _dword_455C80 = false;
} else {
getSaveLoad()->remove();
}
@@ -1837,7 +1836,7 @@ void Menu::clickDeleteGame() {
//////////////////////////////////////////////////////////////////////////
// Columns
- uint32 index = 0;
+ int32 index = 0;
for (int32 y = 150; y < 324; y += 29) {
if (cursor.x >= 350) {
sprintf((char *)&text, "%d. %s ", index + _startIndex + 7, getSaveLoad()->getName(index + _startIndex + 6).c_str());
@@ -1858,10 +1857,11 @@ void Menu::clickDeleteGame() {
if (cursor.x <= (350 + getText()->getWidth((char *)&text))
&& cursor.y >= y
&& cursor.y <= (y + 24)) {
- if (index + _startIndex < 25) {
- if (getSaveLoad()->hasSavegame(index + _startIndex)) {
+ uint32 saveIndex = (uint32)(index + _startIndex);
+ if (saveIndex < 25) {
+ if (getSaveLoad()->hasSavegame(saveIndex)) {
_dword_455C80 = true;
- getSaveLoad()->setIndex(index + _startIndex);
+ getSaveLoad()->setIndex(saveIndex);
}
}
}
@@ -1916,7 +1916,7 @@ void Menu::clickViewMovies() {
//////////////////////////////////////////////////////////////////////////
// Columns
- uint32 index = 0;
+ int32 index = 0;
for (int32 y = 150; y < 324; y += 29) {
if (cursor.x >= 350) {
if (_movieList[index + _startIndex + 6] == -1)
@@ -1929,10 +1929,12 @@ void Menu::clickViewMovies() {
if (cursor.x <= (350 + getText()->getWidth((char *)&text))
&& cursor.y >= y
&& cursor.y <= (y + 24)) {
- if (index + _startIndex + 6 <= _movieCount) {
+ uint32 movieIndex = (uint32)(index + _startIndex + 6);
+ if (movieIndex <= _movieCount) {
// The original checks for the proper cd, but we can skip that since we have all data on disk
- _movieIndex = _movieList[index + _startIndex + 6];
+ _movieIndex = _movieList[movieIndex];
+ // FIXME
//if (moviesCd[_movieIndex] != getSharedData()->cdNumber) {
// _dword_455C78 = true;
// getCursor()->hide();
@@ -1952,9 +1954,11 @@ void Menu::clickViewMovies() {
if (cursor.x <= (30 + getText()->getWidth((char *)&text))
&& cursor.y >= y
&& cursor.y <= (y + 24)) {
- if (index + _startIndex < _movieCount) {
+
+ uint32 listIndex = (uint32)(index + _startIndex);
+ if (listIndex < _movieCount) {
// The original checks for the proper cd, but we can skip that since we have all data on disk
- _movieIndex = _movieList[index + _startIndex];
+ _movieIndex = (uint32)_movieList[listIndex];
//if (moviesCd[_movieIndex] != getSharedData()->cdNumber) {
// _dword_455C78 = true;
@@ -1986,7 +1990,7 @@ void Menu::clickQuitGame() {
} else {
getCursor()->hide();
getScreen()->clear();
- _vm->quitGame();
+ Engine::quitGame();
}
}
@@ -2331,7 +2335,7 @@ void Menu::keyKeyboardConfig(const AsylumEvent &evt) {
char *keyCode = NULL;
switch(_selectedShortcutIndex) {
default:
- break;
+ error("[Menu::keyKeyboardConfig] Invalid shortcut index (%d)", _selectedShortcutIndex);
case 0:
keyCode = &Config.keyShowVersion;
diff --git a/engines/asylum/views/menu.h b/engines/asylum/views/menu.h
index 445e462d6a..5f818b3045 100644
--- a/engines/asylum/views/menu.h
+++ b/engines/asylum/views/menu.h
@@ -175,7 +175,7 @@ private:
*
* @param delta The delta.
*/
- void adjustMasterVolume(int32 delta);
+ void adjustMasterVolume(int32 delta) const;
/**
* Adjust test sounds volume.
Commit: 54ad18711dd91459ad0eea90cc55c2fdfac03579
https://github.com/scummvm/scummvm/commit/54ad18711dd91459ad0eea90cc55c2fdfac03579
Author: Littleboy (littleboy at scummvm.org)
Date: 2021-05-17T15:37:15+02:00
Commit Message:
ASYLUM: Implement ScriptManager::saveLoadWithSerializer()
Changed paths:
engines/asylum/resources/script.cpp
engines/asylum/resources/script.h
diff --git a/engines/asylum/resources/script.cpp b/engines/asylum/resources/script.cpp
index bbf3c838bc..f9ac18b9ec 100644
--- a/engines/asylum/resources/script.cpp
+++ b/engines/asylum/resources/script.cpp
@@ -394,8 +394,9 @@ label_exit_processing:
return false;
}
+// Save the script queue
void ScriptManager::saveLoadWithSerializer(Common::Serializer &s) {
- error("[ScriptManager::saveLoadWithSerializer] Not implemented!");
+ _queue.saveLoadWithSerializer(s);
}
//////////////////////////////////////////////////////////////////////////
diff --git a/engines/asylum/resources/script.h b/engines/asylum/resources/script.h
index 8a8f608d13..9f9f35727e 100644
--- a/engines/asylum/resources/script.h
+++ b/engines/asylum/resources/script.h
@@ -173,7 +173,7 @@ private:
//////////////////////////////////////////////////////////////////////////
// Script Queue
//////////////////////////////////////////////////////////////////////////
- struct ScriptQueueEntry {
+ struct ScriptQueueEntry : public Common::Serializable {
int32 scriptIndex;
int32 currentLine;
ActorIndex actorIndex;
@@ -191,9 +191,17 @@ private:
field_C = 0;
field_10 = 0;
}
+
+ void saveLoadWithSerializer(Common::Serializer &s) {
+ s.syncAsSint32LE(scriptIndex);
+ s.syncAsSint32LE(currentLine);
+ s.syncAsUint32LE(actorIndex);
+ s.syncAsUint32LE(field_C);
+ s.syncAsUint32LE(field_10);
+ }
};
- struct ScriptQueue {
+ struct ScriptQueue : public Common::Serializable {
ScriptQueueEntry entries[10];
uint32 currentEntry;
uint32 field_CC;
@@ -209,6 +217,14 @@ private:
currentEntry = 0;
field_CC = 0;
}
+
+ void saveLoadWithSerializer(Common::Serializer &s) {
+ for (uint32 i = 0; i < ARRAYSIZE(entries); i++)
+ entries[i].saveLoadWithSerializer(s);
+
+ s.syncAsUint32LE(currentEntry);
+ s.syncAsUint32LE(field_CC);
+ }
};
//////////////////////////////////////////////////////////////////////////
Commit: 1a350dd1042769315582bd209b3d195e5b0aad43
https://github.com/scummvm/scummvm/commit/1a350dd1042769315582bd209b3d195e5b0aad43
Author: Littleboy (littleboy at scummvm.org)
Date: 2021-05-17T15:37:16+02:00
Commit Message:
ASYLUM: Handle empty savegame files
Changed paths:
engines/asylum/system/savegame.cpp
diff --git a/engines/asylum/system/savegame.cpp b/engines/asylum/system/savegame.cpp
index 68db4294b2..8461d19b77 100644
--- a/engines/asylum/system/savegame.cpp
+++ b/engines/asylum/system/savegame.cpp
@@ -79,9 +79,15 @@ void Savegame::loadList() {
if (!file)
error("[Savegame::loadList] Cannot open savegame: %s", getFilename(i).c_str());
- _savegameToScene[i] = read(file, "Level");
- _names[i] = read(file, 45, "Game Name");
- _savegames[i] = true;
+ // Check file size (we handle empty files, but not invalid ones)
+ if (file->size() == 0) {
+ _names[i] = getText()->get(MAKE_RESOURCE(kResourcePackText, 1324));
+ _savegames[i] = false;
+ } else {
+ _savegameToScene[i] = read(file, "Level");
+ _names[i] = read(file, 45, "Game Name");
+ _savegames[i] = true;
+ }
delete file;
} else {
@@ -222,7 +228,15 @@ bool Savegame::isSavegamePresent(Common::String filename) const {
if (g_system->getSavefileManager()->listSavefiles(filename).size() == 0)
return false;
- return true;
+ Common::InSaveFile *file = g_system->getSavefileManager()->openForLoading(filename);
+ if (!file)
+ return false;
+
+ bool isSaveValid = (file->size() == 0) ? false : true;
+
+ delete file;
+
+ return isSaveValid;
}
//////////////////////////////////////////////////////////////////////////
@@ -393,7 +407,7 @@ void Savegame::write(Common::OutSaveFile *file, Common::String val, uint32 strLe
}
void Savegame::write(Common::OutSaveFile *file, Common::Serializable *data, uint32 size, uint32 count, Common::String description) const {
- debugC(kDebugLevelSavegame, "[Savegame] Reading data: %s (%d block(s) of size %d)", description.c_str(), size, count);
+ debugC(kDebugLevelSavegame, "[Savegame] Writing data: %s (%d block(s) of size %d)", description.c_str(), size, count);
file->writeUint32LE(size);
file->writeUint32LE(count);
Commit: ecca1260221d5e348d3ea787acf01e380c10bb4c
https://github.com/scummvm/scummvm/commit/ecca1260221d5e348d3ea787acf01e380c10bb4c
Author: Littleboy (littleboy at scummvm.org)
Date: 2021-05-17T15:37:16+02:00
Commit Message:
ASYLUM: Better debug output when writing/loading savegames
Changed paths:
engines/asylum/system/savegame.cpp
diff --git a/engines/asylum/system/savegame.cpp b/engines/asylum/system/savegame.cpp
index 8461d19b77..d764f404b8 100644
--- a/engines/asylum/system/savegame.cpp
+++ b/engines/asylum/system/savegame.cpp
@@ -339,7 +339,7 @@ void Savegame::seek(Common::InSaveFile *file, uint32 offset, Common::String desc
}
uint32 Savegame::read(Common::InSaveFile *file, Common::String description) const {
- debugC(kDebugLevelSavegame, "[Savegame] Reading string: %s", description.c_str());
+ debugC(kDebugLevelSavegame, "[Savegame] Reading %s", description.c_str());
uint32 size = file->readUint32LE();
uint32 count = file->readUint32LE();
@@ -351,7 +351,7 @@ uint32 Savegame::read(Common::InSaveFile *file, Common::String description) cons
}
Common::String Savegame::read(Common::InSaveFile *file, uint32 strLength, Common::String description) const {
- debugC(kDebugLevelSavegame, "[Savegame] Reading string: %s (%d)", description.c_str(), strLength);
+ debugC(kDebugLevelSavegame, "[Savegame] Reading %s (of length %d)", description.c_str(), strLength);
/*uint32 size =*/ file->readUint32LE();
uint32 count = file->readUint32LE();
@@ -371,7 +371,7 @@ Common::String Savegame::read(Common::InSaveFile *file, uint32 strLength, Common
}
void Savegame::read(Common::InSaveFile *file, Common::Serializable *data, uint32 size, uint32 count, Common::String description) const {
- debugC(kDebugLevelSavegame, "[Savegame] Reading data: %s (%d block(s) of size %d)", description.c_str(), size, count);
+ debugC(kDebugLevelSavegame, "[Savegame] Reading %s (%d block(s) of size %d)", description.c_str(), size, count);
uint32 fileSize = file->readUint32LE();
if (size > fileSize)
@@ -389,7 +389,7 @@ void Savegame::read(Common::InSaveFile *file, Common::Serializable *data, uint32
}
void Savegame::write(Common::OutSaveFile *file, uint32 val, Common::String description) const {
- debugC(kDebugLevelSavegame, "[Savegame] Writing value: %s", description.c_str());
+ debugC(kDebugLevelSavegame, "[Savegame] Writing %s: %d", description.c_str(), val);
file->writeUint32LE(4);
file->writeUint32LE(1);
@@ -398,7 +398,7 @@ void Savegame::write(Common::OutSaveFile *file, uint32 val, Common::String descr
}
void Savegame::write(Common::OutSaveFile *file, Common::String val, uint32 strLength, Common::String description) const {
- debugC(kDebugLevelSavegame, "[Savegame] Writing string: %s (%d)", description.c_str(), strLength);
+ debugC(kDebugLevelSavegame, "[Savegame] Writing %s (of length %d): %s", description.c_str(), strLength, val.c_str());
file->writeUint32LE(1);
file->writeUint32LE(strLength);
@@ -407,7 +407,7 @@ void Savegame::write(Common::OutSaveFile *file, Common::String val, uint32 strLe
}
void Savegame::write(Common::OutSaveFile *file, Common::Serializable *data, uint32 size, uint32 count, Common::String description) const {
- debugC(kDebugLevelSavegame, "[Savegame] Writing data: %s (%d block(s) of size %d)", description.c_str(), size, count);
+ debugC(kDebugLevelSavegame, "[Savegame] Writing %s (%d block(s) of size %d)", description.c_str(), size, count);
file->writeUint32LE(size);
file->writeUint32LE(count);
Commit: c935ba9eae89d17d716bd9f1e616dea6a6ada167
https://github.com/scummvm/scummvm/commit/c935ba9eae89d17d716bd9f1e616dea6a6ada167
Author: Littleboy (littleboy at scummvm.org)
Date: 2021-05-17T15:37:16+02:00
Commit Message:
ASYLUM: Prefix debug output with type
Changed paths:
engines/asylum/resources/actor.cpp
engines/asylum/resources/encounters.cpp
engines/asylum/resources/script.cpp
engines/asylum/views/scene.cpp
diff --git a/engines/asylum/resources/actor.cpp b/engines/asylum/resources/actor.cpp
index 186c978116..0a5114a73c 100644
--- a/engines/asylum/resources/actor.cpp
+++ b/engines/asylum/resources/actor.cpp
@@ -985,7 +985,7 @@ void Actor::updateFromDirection(ActorDirection actorDirection) {
}
void Actor::faceTarget(uint32 target, DirectionFrom from) {
- debugC(kDebugLevelActor, "[Actor::faceTarget] Facing target %d using direction from %d", target, from);
+ debugC(kDebugLevelActor, "[Actor] Facing target %d using direction from %d", target, from);
Common::Point point;
diff --git a/engines/asylum/resources/encounters.cpp b/engines/asylum/resources/encounters.cpp
index 9e1289fc49..d4f0e59c43 100644
--- a/engines/asylum/resources/encounters.cpp
+++ b/engines/asylum/resources/encounters.cpp
@@ -211,7 +211,7 @@ void Encounter::initDrawStructs() {
// Run
//////////////////////////////////////////////////////////////////////////
void Encounter::run(int32 encounterIndex, ObjectId objectId1, ObjectId objectId2, ActorIndex actorIndex) {
- debugC(kDebugLevelEncounter, "Running Encounter %d", encounterIndex);
+ debugC(kDebugLevelEncounter, "[Encounter] Running Encounter %d", encounterIndex);
if (!_keywordIndex) {
_item = &_items[0];
@@ -1429,7 +1429,7 @@ void Encounter::runScript() {
do {
ScriptEntry entry = getScriptEntry(_scriptData.resourceId, _scriptData.offset);
- debugC(kDebugLevelEncounter, "Encounter %s", entry.toString().c_str());
+ debugC(kDebugLevelEncounter, "[Encounter] Script %s", entry.toString().c_str());
switch (entry.opcode) {
default:
diff --git a/engines/asylum/resources/script.cpp b/engines/asylum/resources/script.cpp
index f9ac18b9ec..3edc63174f 100644
--- a/engines/asylum/resources/script.cpp
+++ b/engines/asylum/resources/script.cpp
@@ -350,7 +350,7 @@ bool ScriptManager::process() {
if (cmd->opcode >= (int32)_opcodes.size())
error("[ScriptManager::process] Invalid opcode index (was: %d, max: %d)", cmd->opcode, _opcodes.size() - 1);
- debugC(kDebugLevelScripts, "[0x%02X] %s (%d, %d, %d, %d, %d, %d, %d, %d, %d)",
+ debugC(kDebugLevelScripts, "[Script] 0x%02X: %s (%d, %d, %d, %d, %d, %d, %d, %d, %d)",
cmd->opcode, _opcodes[cmd->opcode]->name,
cmd->param1, cmd->param2, cmd->param3, cmd->param4, cmd->param5,
cmd->param6, cmd->param7, cmd->param8, cmd->param9);
diff --git a/engines/asylum/views/scene.cpp b/engines/asylum/views/scene.cpp
index 611afd863e..032dc70509 100644
--- a/engines/asylum/views/scene.cpp
+++ b/engines/asylum/views/scene.cpp
@@ -666,7 +666,7 @@ bool Scene::updateScene() {
#define MESURE_TICKS(func) { \
int32 startTick =_vm->getTick(); \
func(); \
- debugC(kDebugLevelScene, #func " Time: %d", _vm->getTick() - startTick); \
+ debugC(kDebugLevelScene, "[Scene] " #func " - Time: %d", _vm->getTick() - startTick); \
}
#else
#define MESURE_TICKS(func) func();
Commit: d1b6bbabfd72f2dc86c6acdf3e9dc75817e909af
https://github.com/scummvm/scummvm/commit/d1b6bbabfd72f2dc86c6acdf3e9dc75817e909af
Author: Littleboy (littleboy at scummvm.org)
Date: 2021-05-17T15:37:16+02:00
Commit Message:
ASYLUM: Move skipScriptProcessing and isEncounterRunning flags to SharedData
Changed paths:
engines/asylum/asylum.cpp
engines/asylum/resources/actor.cpp
engines/asylum/resources/data.cpp
engines/asylum/resources/data.h
engines/asylum/resources/encounters.cpp
engines/asylum/resources/encounters.h
engines/asylum/resources/script.cpp
engines/asylum/resources/script.h
engines/asylum/resources/special.cpp
engines/asylum/views/scene.cpp
diff --git a/engines/asylum/asylum.cpp b/engines/asylum/asylum.cpp
index 5dd966c21d..3d8cc68543 100644
--- a/engines/asylum/asylum.cpp
+++ b/engines/asylum/asylum.cpp
@@ -576,6 +576,10 @@ void AsylumEngine::saveLoadWithSerializer(Common::Serializer &s) {
// the proper order
_data.saveLoadAmbientSoundData(s);
+ // Original skips two elements
+ // (original has one unused, one used for debugging screen update counts)
+ s.skip(8);
+
// Script queue
_script->saveLoadWithSerializer(s);
diff --git a/engines/asylum/resources/actor.cpp b/engines/asylum/resources/actor.cpp
index 0a5114a73c..8843ab351d 100644
--- a/engines/asylum/resources/actor.cpp
+++ b/engines/asylum/resources/actor.cpp
@@ -596,7 +596,7 @@ void Actor::update() {
break;
case kActorStatus8:
- if (_vm->encounter()->isRunning()
+ if (getSharedData()->getFlag(kFlagIsEncounterRunning)
|| !_soundResourceId
|| getSound()->isPlaying(_soundResourceId)) {
_frameIndex = (_frameIndex + 1) % _frameCount;
@@ -691,7 +691,7 @@ void Actor::updateStatus(ActorStatus actorStatus) {
break;
case kActorStatus9:
- if (_vm->encounter()->isRunning())
+ if (getSharedData()->getFlag(kFlagIsEncounterRunning))
return;
if (_vm->getRandomBit() == 1 && isDefaultDirection(15))
@@ -2134,7 +2134,7 @@ void Actor::updateStatusEnabled() {
if (_vm->isGameFlagNotSet(kGameFlagScriptProcessing)
&& isVisible()
- && !_vm->encounter()->isRunning()
+ && !getSharedData()->getFlag(kFlagIsEncounterRunning)
&& !getSpeech()->getSoundResourceId()) {
if (_vm->getRandom(100) < 50) {
if (getWorld()->chapter == kChapter13)
@@ -3210,7 +3210,7 @@ void Actor::updateFinish() {
ActionArea *area = getWorld()->actions[areaIndex];
ActionArea *actorArea = getWorld()->actions[_actionIdx3];
- if ((area->flags & 1) && !getScript()->isProcessingSkipped()) {
+ if ((area->flags & 1) && !getSharedData()->getFlag(kFlagSkipScriptProcessing)) {
getScript()->queueScript(actorArea->scriptIndex2, _index);
getScript()->queueScript(area->scriptIndex, _index);
}
diff --git a/engines/asylum/resources/data.cpp b/engines/asylum/resources/data.cpp
index 91d08756d5..e8fa8f6804 100644
--- a/engines/asylum/resources/data.cpp
+++ b/engines/asylum/resources/data.cpp
@@ -39,8 +39,8 @@ SharedData::SharedData() {
memset(&_ambientTicks, 0, sizeof(_ambientTicks));
_globalPoint.x = -1;
_globalPoint.y = -1;
- // _flagSkipScriptProcessing
- // _flagEncounterRunning
+ _flagSkipScriptProcessing = false;
+ _flagIsEncounterRunning = false;
// player ActorIndex
_sceneOffset = 0;
_sceneOffsetAdd = 0;
@@ -221,11 +221,11 @@ bool SharedData::getFlag(GlobalFlag flag) const {
case kFlagScene1:
return _flagScene1;
- //case kFlagSkipScriptProcessing:
- // return _flagSkipScriptProcessing;
+ case kFlagSkipScriptProcessing:
+ return _flagSkipScriptProcessing;
- //case kFlagEncounterRunning:
- // return _flagEncounterRunning;
+ case kFlagIsEncounterRunning:
+ return _flagIsEncounterRunning;
case kFlagActorUpdateEnabledCheck:
return _flagActorUpdateEnabledCheck;
@@ -268,13 +268,13 @@ void SharedData::setFlag(GlobalFlag flag, bool state) {
_flagScene1 = state;
break;
- //case kFlagSkipScriptProcessing:
- // _flagSkipScriptProcessing = state;
- // break;
+ case kFlagSkipScriptProcessing:
+ _flagSkipScriptProcessing = state;
+ break;
- //case kFlagEncounterRunning:
- // _flagEncounterRunning = state;
- // break;
+ case kFlagIsEncounterRunning:
+ _flagIsEncounterRunning = state;
+ break;
case kFlagActorUpdateEnabledCheck:
_flagActorUpdateEnabledCheck = state;
@@ -299,17 +299,13 @@ void SharedData::saveLoadAmbientSoundData(Common::Serializer &s) {
}
void SharedData::saveLoadWithSerializer(Common::Serializer &s) {
- // Original skips two elements (original has one unused, one used for debugging screen update counts)
- s.skip(8);
-
- // Script queue (part of ScriptManager)
-
// Global coordinates (original uses int32 for coordinates)
s.syncAsSint32LE(_globalPoint.x);
s.syncAsSint32LE(_globalPoint.y);
- // Processing skipped (part of ScriptManager)
- // Encounter running (part of Encounter)
+ // Processing of scripts/encounter
+ s.syncAsUint32LE(_flagSkipScriptProcessing);
+ s.syncAsUint32LE(_flagIsEncounterRunning);
// Player index
//s.syncAsUint32LE(playerIndex);
diff --git a/engines/asylum/resources/data.h b/engines/asylum/resources/data.h
index 4e1ee3e170..57f7305eca 100644
--- a/engines/asylum/resources/data.h
+++ b/engines/asylum/resources/data.h
@@ -41,9 +41,9 @@ enum GlobalFlag {
kFlagSceneRectChanged,
kFlagScene1,
kFlagSkipScriptProcessing,
- kFlagEncounterRunning,
+ kFlagIsEncounterRunning,
kFlagActorUpdateEnabledCheck,
- kFlagActorUpdateStatus15Check
+ kFlagActorUpdateStatus15Check,
};
/**
@@ -65,7 +65,7 @@ enum GlobalFlag {
* uint32 {15} - ambient ticks
* uint32 {1} - UNUSED
* uint32 {1} - UNUSED (scene updateScreen calls count)
- * -- Script queue (stored in ScriptManager - reset on scene change)
+ * uint32 {1} - Skip script processing
* uint32 {1} - global Object X
* uint32 {1} - global Object Y
* -- Skip processing flag (stored in ScriptManager)
@@ -208,8 +208,8 @@ private:
uint32 _ambientFlags[15];
uint32 _ambientTicks[15];
Common::Point _globalPoint; // global point
- // _flagSkipScriptProcessing
- // _flagEncounterRunning
+ bool _flagSkipScriptProcessing;
+ bool _flagIsEncounterRunning;
// player ActorIndex
Common::Point _sceneCoords;
int16 _sceneOffset;
diff --git a/engines/asylum/resources/encounters.cpp b/engines/asylum/resources/encounters.cpp
index d4f0e59c43..51b2666b4c 100644
--- a/engines/asylum/resources/encounters.cpp
+++ b/engines/asylum/resources/encounters.cpp
@@ -46,8 +46,7 @@ namespace Asylum {
Encounter::Encounter(AsylumEngine *engine) : _vm(engine),
_index(0), _keywordIndex(0), _item(NULL), _objectId1(kObjectNone), _objectId2(kObjectNone), _objectId3(kObjectNone),
- _actorIndex(kActorInvalid), _flag1(false), _flag2(false), _flag3(false), _flag4(false), _disablePlayerOnExit(false),
- _isRunning(false) {
+ _actorIndex(kActorInvalid), _flag1(false), _flag2(false), _flag3(false), _flag4(false), _disablePlayerOnExit(false) {
memset(&_keywordIndexes, 0, sizeof(_keywordIndexes));
_rectIndex = -1;
@@ -262,7 +261,7 @@ void Encounter::exitEncounter() {
// Original saves the item back here
// Update flags
- _isRunning = false;
+ getSharedData()->setFlag(kFlagIsEncounterRunning, false);
getSharedData()->setFlag(kFlag3, true);
if (_flag2)
@@ -313,7 +312,7 @@ bool Encounter::init() {
getSound()->setMusicVolume(Config.musicVolume - 500);
if (!getSharedData()->getMatteBarHeight()) {
- _isRunning = true;
+ getSharedData()->setFlag(kFlagIsEncounterRunning, true);
_data_455BD4 = false;
_data_455BD8 = false;
_data_455BDC = false;
@@ -1143,7 +1142,7 @@ void Encounter::drawScreen() {
// Play movie
getScreen()->clear();
- getVideo()->play(getSharedData()->movieIndex, _isRunning ? (EventHandler*)this : getScene());
+ getVideo()->play(getSharedData()->movieIndex, getSharedData()->getFlag(kFlagIsEncounterRunning) ? (EventHandler*)this : getScene());
getScreen()->clearGraphicsInQueue();
getScreen()->clear();
getCursor()->hide();
@@ -1167,7 +1166,7 @@ void Encounter::drawScreen() {
getSharedData()->setMatteBarHeight(170);
}
} else if (getSharedData()->getMatteBarHeight() >= 170) {
- if (_isRunning) {
+ if (getSharedData()->getFlag(kFlagIsEncounterRunning)) {
getSharedData()->setMatteBarHeight(0);
getCursor()->show();
}
diff --git a/engines/asylum/resources/encounters.h b/engines/asylum/resources/encounters.h
index 95d1bfa9da..df09670900 100644
--- a/engines/asylum/resources/encounters.h
+++ b/engines/asylum/resources/encounters.h
@@ -81,7 +81,6 @@ public:
void setFlag3(bool state) { _flag3 = state; }
bool getFlag3() { return _flag3; }
void disablePlayerOnExit(bool state) { _disablePlayerOnExit = state; }
- bool isRunning() { return _isRunning; }
// Accessors (for saving game)
EncounterItems *items() { return &_items; }
@@ -186,7 +185,6 @@ private:
bool _flag3;
bool _flag4;
bool _disablePlayerOnExit;
- bool _isRunning;
//////////////////////////////////////////////////////////////////////////
// Data
diff --git a/engines/asylum/resources/script.cpp b/engines/asylum/resources/script.cpp
index 3edc63174f..2beae2df44 100644
--- a/engines/asylum/resources/script.cpp
+++ b/engines/asylum/resources/script.cpp
@@ -235,7 +235,6 @@ void ScriptManager::reset() {
// Remove all scripts
_scripts.clear();
- _skipProcessing = false;
_done = false;
_exit = false;
_processNextEntry = false;
@@ -250,7 +249,7 @@ void ScriptManager::resetQueue() {
void ScriptManager::queueScript(int32 scriptIndex, ActorIndex actorIndex) {
// When the skipProcessing flag is set, do not queue any more scripts
- if (_skipProcessing)
+ if (getSharedData()->getFlag(kFlagSkipScriptProcessing))
return;
// Look for a empty queue slot
@@ -822,7 +821,7 @@ IMPLEMENT_OPCODE(RunEncounter)
encounter->disablePlayerOnExit((bool)cmd->param5);
if (cmd->param6) {
- if (encounter->isRunning())
+ if (getSharedData()->getFlag(kFlagIsEncounterRunning))
_processNextEntry = true;
else
cmd->param6 = 0;
@@ -1023,13 +1022,13 @@ END_OPCODE
//////////////////////////////////////////////////////////////////////////
// Opcode 0x2F
IMPLEMENT_OPCODE(StopProcessing)
- _skipProcessing = true;
+ getSharedData()->setFlag(kFlagSkipScriptProcessing, true);
END_OPCODE
//////////////////////////////////////////////////////////////////////////
// Opcode 0x30
IMPLEMENT_OPCODE(ResumeProcessing)
- _skipProcessing = false;
+ getSharedData()->setFlag(kFlagSkipScriptProcessing, false);
END_OPCODE
//////////////////////////////////////////////////////////////////////////
diff --git a/engines/asylum/resources/script.h b/engines/asylum/resources/script.h
index 9f9f35727e..30d42ff9ba 100644
--- a/engines/asylum/resources/script.h
+++ b/engines/asylum/resources/script.h
@@ -158,8 +158,6 @@ public:
*/
void resetQueue();
- bool isProcessingSkipped() { return _skipProcessing; }
-
// Serializable
void saveLoadWithSerializer(Common::Serializer &s);
@@ -298,7 +296,6 @@ private:
Common::Array<Opcode *> _opcodes;
Common::Array<Script> _scripts;
- bool _skipProcessing;
bool _done;
bool _exit;
bool _processNextEntry;
diff --git a/engines/asylum/resources/special.cpp b/engines/asylum/resources/special.cpp
index 7ae62b4d0b..6b8f943474 100644
--- a/engines/asylum/resources/special.cpp
+++ b/engines/asylum/resources/special.cpp
@@ -672,7 +672,7 @@ void Special::chapter9(Object *object, ActorIndex actorIndex) {
void Special::playChapterSound(Object *object, ActorIndex actorIndex) {
ResourceId id = getResourceId(object, actorIndex);
- if (_vm->encounter()->isRunning())
+ if (getSharedData()->getFlag(kFlagIsEncounterRunning))
return;
if (id != kResourceNone && getSound()->isPlaying(id))
diff --git a/engines/asylum/views/scene.cpp b/engines/asylum/views/scene.cpp
index 032dc70509..9ba2b3d03d 100644
--- a/engines/asylum/views/scene.cpp
+++ b/engines/asylum/views/scene.cpp
@@ -1133,7 +1133,7 @@ void Scene::updateCursor(ActorDirection direction, const Common::Rect &rect) {
int16 rightLimit = rect.right - 10;
Common::Point mouse = getCursor()->position();
- if (getEncounter()->isRunning()) {
+ if (getSharedData()->getFlag(kFlagIsEncounterRunning)) {
if (getCursor()->getResourceId() != _ws->cursorResources[kCursorResourceTalkNPC])
getCursor()->set(_ws->cursorResources[kCursorResourceTalkNPC]);
Commit: 072fd08206cf7c23c56d511cf291e1b59c0bf444
https://github.com/scummvm/scummvm/commit/072fd08206cf7c23c56d511cf291e1b59c0bf444
Author: Littleboy (littleboy at scummvm.org)
Date: 2021-05-17T15:37:16+02:00
Commit Message:
ASYLUM: Accept keypad enter to validate a savegame name
Changed paths:
engines/asylum/views/menu.cpp
diff --git a/engines/asylum/views/menu.cpp b/engines/asylum/views/menu.cpp
index c7845bd553..004e59d817 100644
--- a/engines/asylum/views/menu.cpp
+++ b/engines/asylum/views/menu.cpp
@@ -2299,6 +2299,7 @@ void Menu::keySaveGame(const AsylumEvent &evt) {
break;
case Common::KEYCODE_RETURN:
+ case Common::KEYCODE_KP_ENTER:
_dword_455DD8 = false;
getSaveLoad()->save();
break;
Commit: 8f470f1fcb9eb4e8bd4f32e6fc4f362470f39c1e
https://github.com/scummvm/scummvm/commit/8f470f1fcb9eb4e8bd4f32e6fc4f362470f39c1e
Author: Littleboy (littleboy at scummvm.org)
Date: 2021-05-17T15:37:16+02:00
Commit Message:
ASYLUM: Rename flag set when we are editing a savegame name
Changed paths:
engines/asylum/views/menu.cpp
engines/asylum/views/menu.h
diff --git a/engines/asylum/views/menu.cpp b/engines/asylum/views/menu.cpp
index 004e59d817..e1f916ed99 100644
--- a/engines/asylum/views/menu.cpp
+++ b/engines/asylum/views/menu.cpp
@@ -55,7 +55,7 @@ Menu::Menu(AsylumEngine *vm): _vm(vm) {
_dword_455C80 = false;
_dword_455D4C = false;
_dword_455D5C = false;
- _dword_455DD8 = false;
+ _isEditingSavegameName = false;
_testSoundsPlaying = false;
_dword_456288 = 0;
_caretBlink = 0;
@@ -644,7 +644,7 @@ bool Menu::click(const AsylumEvent &evt) {
break;
case kMenuSaveGame:
- _dword_455DD8 = false;
+ _isEditingSavegameName = false;
// Fallback to next case
case kMenuLoadGame:
@@ -895,7 +895,7 @@ void Menu::updateSaveGame() {
sprintf((char *)&text, "%d. %s ", index + _startIndex + 1, getSaveLoad()->getName(index + _startIndex).c_str());
- if (!_dword_455DD8) {
+ if (!_isEditingSavegameName) {
if (cursor.x < 30 || cursor.x > (30 + getText()->getWidth((char *)&text))
|| cursor.y < y || cursor.y > (y + 24))
getText()->loadFont(kFontYellow);
@@ -912,7 +912,7 @@ void Menu::updateSaveGame() {
getText()->draw((char *)&text);
// Draw underscore
- if (_dword_455DD8) {
+ if (_isEditingSavegameName) {
if (getSaveLoad()->getIndex() == (uint32)(index + _startIndex)) {
if (_caretBlink < 6)
getText()->drawChar('_');
@@ -932,7 +932,7 @@ void Menu::updateSaveGame() {
sprintf((char *)&text, "%d. %s ", index + _startIndex + 1, getSaveLoad()->getName(index + _startIndex).c_str());
- if (!_dword_455DD8) {
+ if (!_isEditingSavegameName) {
if (cursor.x < 350 || cursor.x > (350 + getText()->getWidth((char *)&text))
|| cursor.y < y || cursor.y > (y + 24))
getText()->loadFont(kFontYellow);
@@ -949,7 +949,7 @@ void Menu::updateSaveGame() {
getText()->draw((char *)&text);
// Draw underscore
- if (_dword_455DD8) {
+ if (_isEditingSavegameName) {
if (getSaveLoad()->getIndex() == (uint32)(index + _startIndex)) {
if (_caretBlink < 6)
getText()->drawChar('_');
@@ -1686,7 +1686,7 @@ void Menu::clickSaveGame() {
_dword_455C80 = false;
} else {
_dword_455C80 = false;
- _dword_455DD8 = true;
+ _isEditingSavegameName = true;
_previousName = *getSaveLoad()->getName();
_prefixWidth = getText()->getWidth(Common::String::format("%d. %c", getSaveLoad()->getIndex() + 1, '_').c_str());
@@ -1748,7 +1748,7 @@ void Menu::clickSaveGame() {
if (getSaveLoad()->hasSavegame(saveIndex)) {
_dword_455C80 = true;
} else {
- _dword_455DD8 = true;
+ _isEditingSavegameName = true;
_previousName = *getSaveLoad()->getName();
*getSaveLoad()->getName() = getChapterName();
_prefixWidth = getText()->getWidth(Common::String::format("%d. %c", getSaveLoad()->getIndex() + 1, '_').c_str());
@@ -1768,7 +1768,7 @@ void Menu::clickSaveGame() {
if (getSaveLoad()->hasSavegame(index + _startIndex)) {
_dword_455C80 = true;
} else {
- _dword_455DD8 = true;
+ _isEditingSavegameName = true;
_previousName = *getSaveLoad()->getName();
*getSaveLoad()->getName() = getChapterName();
_prefixWidth = getText()->getWidth(Common::String::format("%d. %c", getSaveLoad()->getIndex() + 1, '_').c_str());
@@ -2276,7 +2276,7 @@ void Menu::clickShowCredits() {
// Key handlers
//////////////////////////////////////////////////////////////////////////
void Menu::keySaveGame(const AsylumEvent &evt) {
- if (!_dword_455DD8)
+ if (!_isEditingSavegameName)
return;
switch (evt.kbd.keycode) {
@@ -2300,13 +2300,13 @@ void Menu::keySaveGame(const AsylumEvent &evt) {
case Common::KEYCODE_RETURN:
case Common::KEYCODE_KP_ENTER:
- _dword_455DD8 = false;
+ _isEditingSavegameName = false;
getSaveLoad()->save();
break;
case Common::KEYCODE_ESCAPE:
_dword_455C80 = false;
- _dword_455DD8 = false;
+ _isEditingSavegameName = false;
*getSaveLoad()->getName() = _previousName;
getCursor()->show();
break;
diff --git a/engines/asylum/views/menu.h b/engines/asylum/views/menu.h
index 5f818b3045..46fbf3633c 100644
--- a/engines/asylum/views/menu.h
+++ b/engines/asylum/views/menu.h
@@ -108,7 +108,7 @@ private:
bool _dword_455C80;
bool _dword_455D4C;
bool _dword_455D5C;
- bool _dword_455DD8;
+ bool _isEditingSavegameName;
bool _testSoundsPlaying;
int32 _dword_456288;
int32 _caretBlink;
Commit: f106c50b36f91a7f9cc1571e1900938e5753d2e5
https://github.com/scummvm/scummvm/commit/f106c50b36f91a7f9cc1571e1900938e5753d2e5
Author: Littleboy (littleboy at scummvm.org)
Date: 2021-05-17T15:37:16+02:00
Commit Message:
ASYLUM: Move actorIndex to SharedData
Changed paths:
engines/asylum/resources/actor.cpp
engines/asylum/resources/data.cpp
engines/asylum/resources/data.h
engines/asylum/resources/script.cpp
engines/asylum/resources/special.cpp
engines/asylum/views/scene.cpp
engines/asylum/views/scene.h
diff --git a/engines/asylum/resources/actor.cpp b/engines/asylum/resources/actor.cpp
index 8843ab351d..8fae30ffe3 100644
--- a/engines/asylum/resources/actor.cpp
+++ b/engines/asylum/resources/actor.cpp
@@ -283,7 +283,7 @@ void Actor::update() {
break;
case kActorStatus16:
- if (_index != getScene()->getPlayerIndex())
+ if (_index != getSharedData()->getPlayerIndex())
break;
if (getWorld()->chapter == 2) {
@@ -329,7 +329,7 @@ void Actor::update() {
getScene()->getActor(0)->updateFromDirection(kDirectionS);
// Queue script
- getScript()->queueScript(getWorld()->getActionAreaById(2696)->scriptIndex, getScene()->getPlayerIndex());
+ getScript()->queueScript(getWorld()->getActionAreaById(2696)->scriptIndex, getSharedData()->getPlayerIndex());
_vm->setGameFlag(kGameFlag279);
_vm->setGameFlag(kGameFlag368);
@@ -358,7 +358,7 @@ void Actor::update() {
}
}
- if (_index == getScene()->getPlayerIndex()) {
+ if (_index == getSharedData()->getPlayerIndex()) {
if (_frameIndex <= _frameCount - 1) {
++_frameIndex;
} else {
@@ -368,12 +368,12 @@ void Actor::update() {
_vm->setGameFlag(kGameFlag238);
// Queue script
- getScript()->queueScript(getWorld()->getActionAreaById(1000)->scriptIndex, getScene()->getPlayerIndex());
+ getScript()->queueScript(getWorld()->getActionAreaById(1000)->scriptIndex, getSharedData()->getPlayerIndex());
}
}
} else if (getWorld()->chapter == kChapter11) {
- if (_index == getScene()->getPlayerIndex()) {
+ if (_index == getSharedData()->getPlayerIndex()) {
if (_frameIndex <= _frameCount - 1)
++_frameIndex;
else
@@ -390,7 +390,7 @@ void Actor::update() {
if (_index > 12)
updateStatus15_Chapter2();
- if (_index == getScene()->getPlayerIndex())
+ if (_index == getSharedData()->getPlayerIndex())
updateStatus15_Chapter2_Player();
if (_index == 11)
@@ -400,7 +400,7 @@ void Actor::update() {
if (_index >= 10 && _index < 16)
updateStatus15_Chapter11();
- if (_index == getScene()->getPlayerIndex())
+ if (_index == getSharedData()->getPlayerIndex())
updateStatus15_Chapter11_Player();
}
break;
@@ -490,7 +490,7 @@ void Actor::update() {
if (_soundResourceId != kResourceNone && getSound()->isPlaying(_soundResourceId))
setVolume();
- if (_index != getScene()->getPlayerIndex() && getWorld()->chapter != kChapter9)
+ if (_index != getSharedData()->getPlayerIndex() && getWorld()->chapter != kChapter9)
getSpecial()->run(NULL, _index);
updateDirection();
@@ -550,7 +550,7 @@ void Actor::update() {
if (_soundResourceId != kResourceNone && getSound()->isPlaying(_soundResourceId))
setVolume();
- if (_index != getScene()->getPlayerIndex() && getWorld()->chapter != kChapter9)
+ if (_index != getSharedData()->getPlayerIndex() && getWorld()->chapter != kChapter9)
getSpecial()->run(NULL, _index);
updateDirection();
@@ -610,7 +610,7 @@ void Actor::update() {
if (_soundResourceId && getSound()->isPlaying(_soundResourceId))
setVolume();
- if (_index != getScene()->getPlayerIndex() && getWorld()->chapter != kChapter9)
+ if (_index != getSharedData()->getPlayerIndex() && getWorld()->chapter != kChapter9)
error("[Actor::update] call to actor sound functions missing!");
updateDirection();
@@ -628,7 +628,7 @@ void Actor::updateStatus(ActorStatus actorStatus) {
case kActorStatus1:
case kActorStatus12:
if ((getWorld()->chapter == kChapter2
- && _index == getScene()->getPlayerIndex() && (_status == kActorStatus18 || _status == kActorStatus16 || _status == kActorStatus17))
+ && _index == getSharedData()->getPlayerIndex() && (_status == kActorStatus18 || _status == kActorStatus16 || _status == kActorStatus17))
|| (_status != kActorStatusEnabled && _status != kActorStatus9 && _status != kActorStatus14 && _status != kActorStatus15 && _status != kActorStatus18))
return;
@@ -672,7 +672,7 @@ void Actor::updateStatus(ActorStatus actorStatus) {
actor->getPoint1()->y = _point2.y + _point1.y - actor->getPoint2()->y;
actor->setDirection(kDirectionS);
- getScene()->setPlayerActorIndex(0);
+ getSharedData()->setPlayerIndex(0);
// Hide this actor and the show the other one
hide();
@@ -713,7 +713,7 @@ void Actor::updateStatus(ActorStatus actorStatus) {
if (_index > 12)
_resourceId = _graphicResourceIds[_direction + 30];
- if (getScene()->getPlayerIndex() == _index) {
+ if (getSharedData()->getPlayerIndex() == _index) {
resource->load(_resourceId);
_frameIndex = resource->count() - 1;
}
@@ -1676,7 +1676,7 @@ void Actor::move(ActorDirection actorDir, uint32 dist) {
// Compute volume
int32 vol = sqrt((double)-Config.sfxVolume);
- if (_index != getScene()->getPlayerIndex())
+ if (_index != getSharedData()->getPlayerIndex())
vol += sqrt((double)abs(getSound()->calculateVolumeAdjustement(sum, 10, 0)));
int32 volume = (Config.sfxVolume + vol) * (Config.sfxVolume + vol);
@@ -1713,7 +1713,7 @@ void Actor::move(ActorDirection actorDir, uint32 dist) {
// Compute volume
int32 vol = getWorld()->actions[_actionIdx3]->volume;
- if (_index != getScene()->getPlayerIndex())
+ if (_index != getSharedData()->getPlayerIndex())
vol += sqrt((double)abs(getSound()->calculateVolumeAdjustement(sum, 10, 0)));
int32 volume = (Config.sfxVolume + vol) * (Config.sfxVolume + vol);
@@ -1831,7 +1831,7 @@ bool Actor::canMoveCheckActors(Common::Point *point, ActorDirection dir) {
int32 x3 = actor->getPoint1()->x + actor->getPoint2()->x + 2 * actor->getField948() + 15;
int32 y3 = actor->getPoint1()->y + actor->getPoint2()->y + 2 * actor->getField94C() + 10;
- if (i == getScene()->getPlayerIndex() && getWorld()->chapter == kChapter11) {
+ if (i == getSharedData()->getPlayerIndex() && getWorld()->chapter == kChapter11) {
x2 -= 10;
y2 -= 10;
x3 += 10;
@@ -2006,7 +2006,7 @@ void Actor::updatePlayerChapter9(AsylumEngine *engine, int nextPlayer) {
Actor *player = engine->scene()->getActor();
world->nextPlayer = nextPlayer;
- switch (engine->scene()->getPlayerIndex()) {
+ switch (engine->data()->getPlayerIndex()) {
default:
break;
@@ -2080,7 +2080,7 @@ void Actor::updateStatus3_19() {
updateStatus(kActorStatus20);
}
} else {
- if (_index == getScene()->getPlayerIndex())
+ if (_index == getSharedData()->getPlayerIndex())
updateStatus19_Player();
++_frameIndex;
@@ -2129,7 +2129,7 @@ void Actor::updateStatusEnabled() {
}
// Actor: Player
- if (_index == getScene()->getPlayerIndex()) {
+ if (_index == getSharedData()->getPlayerIndex()) {
if (_vm->lastScreenUpdate && (_vm->screenUpdateCount - _vm->lastScreenUpdate) > 500) {
if (_vm->isGameFlagNotSet(kGameFlagScriptProcessing)
@@ -2262,7 +2262,7 @@ void Actor::updateStatusEnabledProcessStatus(int32 testX, int32 testY, uint32 co
}
void Actor::updateStatus9() {
- if (_index == getScene()->getPlayerIndex()
+ if (_index == getSharedData()->getPlayerIndex()
&& getWorld()->chapter != kChapter9
&& getWorld()->actorType == 0
&& _frameIndex == 0
@@ -2287,7 +2287,7 @@ void Actor::updateStatus12_Chapter2() {
uint32 distance = abs((double)getDistanceForFrame(_direction, frameIndex));
// Face actor
- faceTarget(getScene()->getPlayerIndex(), kDirectionFromActor);
+ faceTarget(getSharedData()->getPlayerIndex(), kDirectionFromActor);
int32 data = getSharedData()->getChapter2Data(3, _index + 1);
if (data > 0) {
@@ -2339,7 +2339,7 @@ void Actor::updateStatus12_Chapter2_Actor11() {
}
// Face player
- faceTarget(getScene()->getPlayerIndex(), kDirectionFromActor);
+ faceTarget(getSharedData()->getPlayerIndex(), kDirectionFromActor);
// Compute coordinates
Common::Point delta = Common::Point((sumPlayer.x + sum.x) / 2, (sumPlayer.y + sum.y) / 2);
@@ -2388,7 +2388,7 @@ void Actor::updateStatus12_Chapter2_Actor11() {
if (player->getStatus() != kActorStatus17 && player->getStatus() != kActorStatus16) {
if (sqrt((double)((sum.y - sumPlayer.y) * (sum.y - sumPlayer.y) + (sum.x - sumPlayer.x) * (sum.x - sumPlayer.x))) < 80.0) {
_frameIndex = 0;
- faceTarget(getScene()->getPlayerIndex(), kDirectionFromActor);
+ faceTarget(getSharedData()->getPlayerIndex(), kDirectionFromActor);
updateStatus(kActorStatus15);
}
}
@@ -2591,7 +2591,7 @@ void Actor::updateStatus15_Chapter2() {
uint32 dist = euclidianDistance(sumPlayer, sum);
uint32 offset = (dist <= 10) ? 7 : 12;
if (dist > 20) {
- faceTarget(getScene()->getPlayerIndex(), kDirectionFromActor);
+ faceTarget(getSharedData()->getPlayerIndex(), kDirectionFromActor);
getScene()->getActor(_index + 9)->setDirection(_direction);
}
@@ -2715,7 +2715,7 @@ void Actor::updateStatus15_Chapter2_Helper() {
}
void Actor::updateStatus15_Chapter2_Player() {
- if (_index != getScene()->getPlayerIndex())
+ if (_index != getSharedData()->getPlayerIndex())
error("[Actor::updateStatus15_Chapter2_Player] Function is only available for the current player");
// Update frame index and process
@@ -3145,7 +3145,7 @@ void Actor::updateStatus18_Chapter2_Actor11() {
updateStatus(kActorStatus12);
}
- faceTarget(getScene()->getPlayerIndex(), kDirectionFromActor);
+ faceTarget(getSharedData()->getPlayerIndex(), kDirectionFromActor);
Common::Point sum = _point1 + _point2;
if (canMove(&sum, DIR(_direction + 4), distance, false)) {
diff --git a/engines/asylum/resources/data.cpp b/engines/asylum/resources/data.cpp
index e8fa8f6804..b942c1334f 100644
--- a/engines/asylum/resources/data.cpp
+++ b/engines/asylum/resources/data.cpp
@@ -41,7 +41,7 @@ SharedData::SharedData() {
_globalPoint.y = -1;
_flagSkipScriptProcessing = false;
_flagIsEncounterRunning = false;
- // player ActorIndex
+ _playerIndex = 0;
_sceneOffset = 0;
_sceneOffsetAdd = 0;
memset(&_cursorResources, kResourceNone, sizeof(_cursorResources));
@@ -308,7 +308,7 @@ void SharedData::saveLoadWithSerializer(Common::Serializer &s) {
s.syncAsUint32LE(_flagIsEncounterRunning);
// Player index
- //s.syncAsUint32LE(playerIndex);
+ s.syncAsSint32LE(_playerIndex);
// Scene coordinates
s.syncAsSint32LE(_sceneCoords.x);
diff --git a/engines/asylum/resources/data.h b/engines/asylum/resources/data.h
index 57f7305eca..492586e429 100644
--- a/engines/asylum/resources/data.h
+++ b/engines/asylum/resources/data.h
@@ -65,11 +65,11 @@ enum GlobalFlag {
* uint32 {15} - ambient ticks
* uint32 {1} - UNUSED
* uint32 {1} - UNUSED (scene updateScreen calls count)
- * uint32 {1} - Skip script processing
+ * -- Script queue (stored in ScriptManager)
* uint32 {1} - global Object X
* uint32 {1} - global Object Y
- * -- Skip processing flag (stored in ScriptManager)
- * -- Encounter running flag (stored in Encounter)
+ * uint32 {1} - Skip script processing flag
+ * uint32 {1} - Encounter running flag
* uint32 {1} - Player ActorIndex
* uint32 {1} - scene xLeft
* uint32 {1} - scene yTop
@@ -152,6 +152,18 @@ public:
void setAmbientFlag(uint32 index, uint32 val);
void resetAmbientFlags();
+ /**
+ * Return the index of the player actor
+ */
+ ActorIndex getPlayerIndex() { return _playerIndex; }
+
+ /**
+ * Sets the player actor index.
+ *
+ * @param index index of the player actor
+ */
+ void setPlayerIndex(ActorIndex index) { _playerIndex = index; }
+
// Coordinates
Common::Point getGlobalPoint() { return _globalPoint; }
void setGlobalPoint(const Common::Point &point) { _globalPoint = point; }
@@ -210,7 +222,7 @@ private:
Common::Point _globalPoint; // global point
bool _flagSkipScriptProcessing;
bool _flagIsEncounterRunning;
- // player ActorIndex
+ int32 _playerIndex;
Common::Point _sceneCoords;
int16 _sceneOffset;
int16 _sceneOffsetAdd;
diff --git a/engines/asylum/resources/script.cpp b/engines/asylum/resources/script.cpp
index 2beae2df44..033868f20a 100644
--- a/engines/asylum/resources/script.cpp
+++ b/engines/asylum/resources/script.cpp
@@ -1196,7 +1196,7 @@ END_OPCODE
//////////////////////////////////////////////////////////////////////////
// Opcode 0x3F
IMPLEMENT_OPCODE(JumpIfActor)
- ActorIndex index = (cmd->param1 == kActorInvalid) ? getScene()->getPlayerIndex() : cmd->param1;
+ ActorIndex index = (cmd->param1 == kActorInvalid) ? getSharedData()->getPlayerIndex() : cmd->param1;
if (_currentQueueEntry->actorIndex != index)
_currentQueueEntry->currentLine = cmd->param2 - 1;
diff --git a/engines/asylum/resources/special.cpp b/engines/asylum/resources/special.cpp
index 6b8f943474..0ba655e97d 100644
--- a/engines/asylum/resources/special.cpp
+++ b/engines/asylum/resources/special.cpp
@@ -467,7 +467,7 @@ void Special::chapter7(Object *object, ActorIndex actorIndex) {
if (_vm->isGameFlagSet(kGameFlag1023)) {
if (player->getField638()) {
getScript()->queueScript(getWorld()->actions[getWorld()->getActionAreaIndexById(player->getField638() == 3 ? 2447 : 2448)]->scriptIndex,
- getScene()->getPlayerIndex());
+ getSharedData()->getPlayerIndex());
_vm->clearGameFlag(kGameFlag1023);
} else if (player->getStatus() != kActorStatus6) {
_vm->clearGameFlag(kGameFlag1023);
@@ -478,7 +478,7 @@ void Special::chapter7(Object *object, ActorIndex actorIndex) {
if (_vm->isGameFlagSet(kGameFlag1022)) {
_vm->clearGameFlag(kGameFlag1022);
getScript()->queueScript(getWorld()->actions[getWorld()->getActionAreaIndexById(2445)]->scriptIndex,
- getScene()->getPlayerIndex());
+ getSharedData()->getPlayerIndex());
}
break;
}
diff --git a/engines/asylum/views/scene.cpp b/engines/asylum/views/scene.cpp
index 9ba2b3d03d..a918e71b9c 100644
--- a/engines/asylum/views/scene.cpp
+++ b/engines/asylum/views/scene.cpp
@@ -60,7 +60,6 @@ Scene::Scene(AsylumEngine *engine): _vm(engine),
// Initialize data
_packId = kResourcePackInvalid;
- _playerIndex = 0;
_hitAreaChapter7Counter = 0;
_isCTRLPressed = false;
@@ -94,7 +93,7 @@ void Scene::enter(ResourcePackId packId) {
getCursor()->hide();
- _playerIndex = 0;
+ getSharedData()->setPlayerIndex(0);
// Load the scene data
load(packId);
@@ -437,7 +436,7 @@ bool Scene::key(const AsylumEvent &evt) {
if (getCursor()->isHidden() || _ws->chapter != kChapter9)
return true;
- getScript()->queueScript(_ws->actions[_ws->getActionAreaIndexById(2206)]->scriptIndex, _playerIndex);
+ getScript()->queueScript(_ws->actions[_ws->getActionAreaIndexById(2206)]->scriptIndex, getSharedData()->getPlayerIndex());
return true;
}
@@ -446,7 +445,7 @@ bool Scene::key(const AsylumEvent &evt) {
if (getCursor()->isHidden() || _ws->chapter != kChapter9)
return true;
- getScript()->queueScript(_ws->actions[_ws->getActionAreaIndexById(2207)]->scriptIndex, _playerIndex);
+ getScript()->queueScript(_ws->actions[_ws->getActionAreaIndexById(2207)]->scriptIndex, getSharedData()->getPlayerIndex());
return true;
}
@@ -455,7 +454,7 @@ bool Scene::key(const AsylumEvent &evt) {
if (getCursor()->isHidden() || _ws->chapter != kChapter9)
return true;
- getScript()->queueScript(_ws->actions[_ws->getActionAreaIndexById(2208)]->scriptIndex, _playerIndex);
+ getScript()->queueScript(_ws->actions[_ws->getActionAreaIndexById(2208)]->scriptIndex, getSharedData()->getPlayerIndex());
return true;
}
@@ -693,7 +692,7 @@ void Scene::updateMouse() {
player->adjustCoordinates(&pt);
Common::Rect actorRect;
- if (_ws->chapter != kChapter2 || _playerIndex != 10) {
+ if (_ws->chapter != kChapter2 || getSharedData()->getPlayerIndex() != 10) {
actorRect.left = pt.x + 20;
actorRect.top = pt.y;
actorRect.right = (int16)(pt.x + 2 * player->getPoint2()->x);
@@ -1193,7 +1192,7 @@ void Scene::updateCursor(ActorDirection direction, const Common::Rect &rect) {
int32 index = hitTest(type);
if (index == -1) {
- if (_ws->chapter != kChapter2 || _playerIndex != 10) {
+ if (_ws->chapter != kChapter2 || getSharedData()->getPlayerIndex() != 10) {
if (getCursor()->getResourceId() != _ws->cursorResources[kCursorResourceMagnifyingGlass] || getCursor()->getAnimation())
getCursor()->set(_ws->cursorResources[kCursorResourceMagnifyingGlass]);
} else {
@@ -1235,7 +1234,7 @@ void Scene::updateCursor(ActorDirection direction, const Common::Rect &rect) {
} else if (actionType & kActionType16) {
if (getCursor()->getResourceId() != _ws->cursorResources[kCursorResourceTalkNPC2] || getCursor()->getAnimation() != kCursorAnimationMirror)
getCursor()->set(_ws->cursorResources[kCursorResourceTalkNPC2]);
- } else if (_ws->chapter != kChapter2 && _playerIndex != 10) {
+ } else if (_ws->chapter != kChapter2 && getSharedData()->getPlayerIndex() != 10) {
if (getCursor()->getResourceId() != _ws->cursorResources[kCursorResourceMagnifyingGlass] || getCursor()->getAnimation())
getCursor()->set(_ws->cursorResources[kCursorResourceMagnifyingGlass]);
} else {
@@ -1564,7 +1563,7 @@ void Scene::handleHit(int32 index, HitType type) {
case kHitActionArea:
if (!getScript()->isInQueue(_ws->actions[index]->scriptIndex))
- getScript()->queueScript(_ws->actions[index]->scriptIndex, _playerIndex);
+ getScript()->queueScript(_ws->actions[index]->scriptIndex, getSharedData()->getPlayerIndex());
switch (_ws->chapter) {
default:
@@ -1595,7 +1594,7 @@ void Scene::handleHit(int32 index, HitType type) {
}
if (!getScript()->isInQueue(object->getScriptIndex()))
- getScript()->queueScript(object->getScriptIndex(), _playerIndex);
+ getScript()->queueScript(object->getScriptIndex(), getSharedData()->getPlayerIndex());
// Original executes special script hit functions, but since there is none defined, we can skip this part
}
@@ -1607,7 +1606,7 @@ void Scene::handleHit(int32 index, HitType type) {
if (actor->actionType & (kActionTypeFind | kActionType16)) {
if (getScript()->isInQueue(actor->getScriptIndex()))
- getScript()->queueScript(actor->getScriptIndex(), _playerIndex);
+ getScript()->queueScript(actor->getScriptIndex(), getSharedData()->getPlayerIndex());
} else if (actor->actionType & kActionTypeTalk) {
@@ -1620,7 +1619,7 @@ void Scene::handleHit(int32 index, HitType type) {
}
if (getScript()->isInQueue(actor->getScriptIndex()))
- getScript()->queueScript(actor->getScriptIndex(), _playerIndex);
+ getScript()->queueScript(actor->getScriptIndex(), getSharedData()->getPlayerIndex());
}
switch (_ws->chapter) {
@@ -1674,15 +1673,15 @@ void Scene::playerReaction() {
break;
case 0:
- getScript()->queueScript(_ws->actions[_ws->getActionAreaIndexById(2206)]->scriptIndex, _playerIndex);
+ getScript()->queueScript(_ws->actions[_ws->getActionAreaIndexById(2206)]->scriptIndex, getSharedData()->getPlayerIndex());
break;
case 1:
- getScript()->queueScript(_ws->actions[_ws->getActionAreaIndexById(2207)]->scriptIndex, _playerIndex);
+ getScript()->queueScript(_ws->actions[_ws->getActionAreaIndexById(2207)]->scriptIndex, getSharedData()->getPlayerIndex());
break;
case 2:
- getScript()->queueScript(_ws->actions[_ws->getActionAreaIndexById(2208)]->scriptIndex, _playerIndex);
+ getScript()->queueScript(_ws->actions[_ws->getActionAreaIndexById(2208)]->scriptIndex, getSharedData()->getPlayerIndex());
break;
}
} else {
@@ -2069,7 +2068,7 @@ Actor* Scene::getActor(ActorIndex index) {
if (!_ws)
error("[Scene::getActor] WorldStats not initialized properly!");
- ActorIndex computedIndex = (index != kActorInvalid) ? index : _playerIndex;
+ ActorIndex computedIndex = (index != kActorInvalid) ? index : getSharedData()->getPlayerIndex();
if (computedIndex < 0 || computedIndex >= (int16)_ws->actors.size())
error("[Scene::getActor] Invalid actor index: %d ([0-%d] allowed)", computedIndex, _ws->actors.size() - 1);
@@ -2240,7 +2239,8 @@ void Scene::changePlayer(ActorIndex index) {
getActor(index)->show();
}
- _playerIndex = index;
+
+ getSharedData()->setPlayerIndex(index);
break;
case 1:
@@ -2257,7 +2257,7 @@ void Scene::changePlayer(ActorIndex index) {
getActor(index)->show();
}
- _playerIndex = index;
+ getSharedData()->setPlayerIndex(index);
break;
case 2:
@@ -2274,7 +2274,7 @@ void Scene::changePlayer(ActorIndex index) {
getActor(index)->show();
}
- _playerIndex = index;
+ getSharedData()->setPlayerIndex(index);
break;
case 3:
@@ -2292,7 +2292,7 @@ void Scene::changePlayer(ActorIndex index) {
}
getActor(index)->show();
- _playerIndex = index;
+ getSharedData()->setPlayerIndex(index);
break;
case 666:
@@ -2478,7 +2478,7 @@ void Scene::processUpdateList() {
int16 bottomRight = actor->getPoint1()->y + actor->getBoundingRect()->bottom + 4;
- if (_ws->chapter == kChapter11 && _updateList[i].index != getPlayerIndex())
+ if (_ws->chapter == kChapter11 && _updateList[i].index != getSharedData()->getPlayerIndex())
bottomRight += 20;
// Our actor rect
diff --git a/engines/asylum/views/scene.h b/engines/asylum/views/scene.h
index 12fd7fa2bb..d25ac758e6 100644
--- a/engines/asylum/views/scene.h
+++ b/engines/asylum/views/scene.h
@@ -106,18 +106,6 @@ public:
*/
bool handleEvent(const AsylumEvent &ev);
- /**
- * Return the index of the player actor
- */
- ActorIndex getPlayerIndex() { return _playerIndex; }
-
- /**
- * Sets the player actor index.
- *
- * @param index index of the player actor
- */
- void setPlayerActorIndex(ActorIndex index) { _playerIndex = index; }
-
/**
* Gets the current scene pack identifier.
*
@@ -210,7 +198,6 @@ private:
AsylumEngine *_vm;
ResourcePackId _packId;
- int32 _playerIndex;
Polygons *_polygons;
WorldStats *_ws;
Commit: 8370719912a0c9a3a492459a42849dce8e5e5886
https://github.com/scummvm/scummvm/commit/8370719912a0c9a3a492459a42849dce8e5e5886
Author: Littleboy (littleboy at scummvm.org)
Date: 2021-05-17T15:37:17+02:00
Commit Message:
ASYLUM: Move Encounter disablePlayerOnExit flag to SharedData
Changed paths:
engines/asylum/resources/data.cpp
engines/asylum/resources/data.h
engines/asylum/resources/encounters.cpp
engines/asylum/resources/encounters.h
engines/asylum/resources/script.cpp
diff --git a/engines/asylum/resources/data.cpp b/engines/asylum/resources/data.cpp
index b942c1334f..3d27a06ca8 100644
--- a/engines/asylum/resources/data.cpp
+++ b/engines/asylum/resources/data.cpp
@@ -65,10 +65,10 @@ SharedData::SharedData() {
memset(&_chapter2Data4, 0, sizeof(_chapter2Data4));
_actorUpdateStatusEnabledCounter = 0;
memset(&_chapter2Data5, 0, sizeof(_chapter2Data5));
- // _flagEncounterDisablePlayerOnExit
+ _flagEncounterDisablePlayerOnExit = false;
_flag1 = false;
_nextScreenUpdate = 0;
- // _moviesViewed;
+ // _moviesViewed
_flagActorUpdateStatus15Check = false;
// Non-saved data
@@ -227,6 +227,9 @@ bool SharedData::getFlag(GlobalFlag flag) const {
case kFlagIsEncounterRunning:
return _flagIsEncounterRunning;
+ case kFlagEncounterDisablePlayerOnExit:
+ return _flagEncounterDisablePlayerOnExit;
+
case kFlagActorUpdateEnabledCheck:
return _flagActorUpdateEnabledCheck;
@@ -276,6 +279,10 @@ void SharedData::setFlag(GlobalFlag flag, bool state) {
_flagIsEncounterRunning = state;
break;
+ case kFlagEncounterDisablePlayerOnExit:
+ _flagEncounterDisablePlayerOnExit = state;
+ break;
+
case kFlagActorUpdateEnabledCheck:
_flagActorUpdateEnabledCheck = state;
break;
@@ -361,7 +368,7 @@ void SharedData::saveLoadWithSerializer(Common::Serializer &s) {
s.syncAsSint32LE(_chapter2FrameIndexOffset);
s.syncAsSint32LE(_chapter2ActorIndex);
- //s.syncAsSint32LE(_eventUpdateFlag);
+ s.syncAsSint32LE(_eventUpdate);
// Chapter 2 counters (6-8)
s.syncAsSint32LE(_chapter2Counters[5]);
@@ -380,7 +387,7 @@ void SharedData::saveLoadWithSerializer(Common::Serializer &s) {
s.syncAsUint32LE(_chapter2Data5[i]);
// Encounter disable player on exit
- //s.syncAsSint32LE(encounterDisablePlayerOnExit);
+ s.syncAsUint32LE(_flagEncounterDisablePlayerOnExit);
// Scene flag 1
s.syncAsUint32LE(_flagScene1);
@@ -393,8 +400,6 @@ void SharedData::saveLoadWithSerializer(Common::Serializer &s) {
// Actor update status 15 check
s.syncAsUint32LE(_flagActorUpdateStatus15Check);
-
- // TODO More?
}
} // End of namespace Asylum
diff --git a/engines/asylum/resources/data.h b/engines/asylum/resources/data.h
index 492586e429..91104d5ab2 100644
--- a/engines/asylum/resources/data.h
+++ b/engines/asylum/resources/data.h
@@ -42,6 +42,7 @@ enum GlobalFlag {
kFlagScene1,
kFlagSkipScriptProcessing,
kFlagIsEncounterRunning,
+ kFlagEncounterDisablePlayerOnExit,
kFlagActorUpdateEnabledCheck,
kFlagActorUpdateStatus15Check,
};
@@ -247,7 +248,7 @@ private:
uint32 _chapter2Data4[18];
int32 _actorUpdateStatusEnabledCounter;
uint32 _chapter2Data5[9];
- // _flagEncounterDisablePlayerOnExit
+ bool _flagEncounterDisablePlayerOnExit;
bool _flag1;
uint32 _nextScreenUpdate;
//byte _moviesViewed[196];
diff --git a/engines/asylum/resources/encounters.cpp b/engines/asylum/resources/encounters.cpp
index 51b2666b4c..a0ece256ed 100644
--- a/engines/asylum/resources/encounters.cpp
+++ b/engines/asylum/resources/encounters.cpp
@@ -46,7 +46,7 @@ namespace Asylum {
Encounter::Encounter(AsylumEngine *engine) : _vm(engine),
_index(0), _keywordIndex(0), _item(NULL), _objectId1(kObjectNone), _objectId2(kObjectNone), _objectId3(kObjectNone),
- _actorIndex(kActorInvalid), _flag1(false), _flag2(false), _flag3(false), _flag4(false), _disablePlayerOnExit(false) {
+ _actorIndex(kActorInvalid), _flag1(false), _flag2(false), _flag3(false), _flag4(false) {
memset(&_keywordIndexes, 0, sizeof(_keywordIndexes));
_rectIndex = -1;
@@ -269,10 +269,10 @@ void Encounter::exitEncounter() {
else
_flag1 = true;
- if (_disablePlayerOnExit)
+ if (getSharedData()->getFlag(kFlagEncounterDisablePlayerOnExit))
getScene()->getActor()->updateStatus(kActorStatusDisabled);
- _disablePlayerOnExit = false;
+ getSharedData()->setFlag(kFlagEncounterDisablePlayerOnExit, false);
if (getSound()->getMusicVolume() != Config.musicVolume)
getSound()->setMusicVolume(Config.musicVolume);
diff --git a/engines/asylum/resources/encounters.h b/engines/asylum/resources/encounters.h
index df09670900..74b4deb9a5 100644
--- a/engines/asylum/resources/encounters.h
+++ b/engines/asylum/resources/encounters.h
@@ -80,7 +80,6 @@ public:
bool getFlag1() { return _flag1; }
void setFlag3(bool state) { _flag3 = state; }
bool getFlag3() { return _flag3; }
- void disablePlayerOnExit(bool state) { _disablePlayerOnExit = state; }
// Accessors (for saving game)
EncounterItems *items() { return &_items; }
@@ -184,7 +183,6 @@ private:
bool _flag2;
bool _flag3;
bool _flag4;
- bool _disablePlayerOnExit;
//////////////////////////////////////////////////////////////////////////
// Data
diff --git a/engines/asylum/resources/script.cpp b/engines/asylum/resources/script.cpp
index 033868f20a..82a1967ddb 100644
--- a/engines/asylum/resources/script.cpp
+++ b/engines/asylum/resources/script.cpp
@@ -818,7 +818,7 @@ END_OPCODE
IMPLEMENT_OPCODE(RunEncounter)
Encounter *encounter = _vm->encounter();
- encounter->disablePlayerOnExit((bool)cmd->param5);
+ getSharedData()->setFlag(kFlagEncounterDisablePlayerOnExit, (bool)cmd->param5);
if (cmd->param6) {
if (getSharedData()->getFlag(kFlagIsEncounterRunning))
Commit: 70460193adc1642f11236ffd397762df6d89f522
https://github.com/scummvm/scummvm/commit/70460193adc1642f11236ffd397762df6d89f522
Author: Littleboy (littleboy at scummvm.org)
Date: 2021-05-17T15:37:17+02:00
Commit Message:
ASYLUM: Skip saving of viewed movies as part of the shared data
We load it directly from an external file and the original overwrites the data with the one from the external file
Changed paths:
engines/asylum/resources/data.cpp
diff --git a/engines/asylum/resources/data.cpp b/engines/asylum/resources/data.cpp
index 3d27a06ca8..e4fa127719 100644
--- a/engines/asylum/resources/data.cpp
+++ b/engines/asylum/resources/data.cpp
@@ -395,8 +395,9 @@ void SharedData::saveLoadWithSerializer(Common::Serializer &s) {
// Next screen update
s.syncAsUint32LE(_nextScreenUpdate);
- // Viewed movies (we also load it from an external file...)
- //s.syncBytes(&_moviesViewed, sizeof(_moviesViewed));
+ // Viewed movies
+ // (we load it directly from an external file, the original overwrites the data with the one from the external file)
+ s.skip(196);
// Actor update status 15 check
s.syncAsUint32LE(_flagActorUpdateStatus15Check);
Commit: d6883a89a1244ec1045349d024328e4c330ad1a9
https://github.com/scummvm/scummvm/commit/d6883a89a1244ec1045349d024328e4c330ad1a9
Author: Littleboy (littleboy at scummvm.org)
Date: 2021-05-17T15:37:17+02:00
Commit Message:
ASYLUM: Implement WorldStats::saveLoadWithSerializer()
- Add stubs for saveLoadWithSerializer() for ActionArea, Actor, ActorData and Object classes
Changed paths:
engines/asylum/resources/actor.cpp
engines/asylum/resources/actor.h
engines/asylum/resources/object.cpp
engines/asylum/resources/object.h
engines/asylum/resources/script.cpp
engines/asylum/resources/script.h
engines/asylum/resources/worldstats.cpp
diff --git a/engines/asylum/resources/actor.cpp b/engines/asylum/resources/actor.cpp
index 8fae30ffe3..b6ffa36f21 100644
--- a/engines/asylum/resources/actor.cpp
+++ b/engines/asylum/resources/actor.cpp
@@ -234,6 +234,10 @@ void Actor::loadData(Common::SeekableReadStream *stream) {
_data.directions[i] = (ActorDirection)stream->readSint32LE();
}
+void Actor::saveLoadWithSerializer(Common::Serializer &s) {
+ error("[Actor::saveLoadWithSerializer] Not implemented");
+}
+
/////////////////////////////////////////////////////////////////////////
// Update & status
//////////////////////////////////////////////////////////////////////////
diff --git a/engines/asylum/resources/actor.h b/engines/asylum/resources/actor.h
index f4dfd7d365..ba515d366f 100644
--- a/engines/asylum/resources/actor.h
+++ b/engines/asylum/resources/actor.h
@@ -27,6 +27,7 @@
#include "common/array.h"
#include "common/rect.h"
+#include "common/serializer.h"
#include "common/stream.h"
namespace Asylum {
@@ -38,14 +39,19 @@ class Screen;
struct ActionArea;
struct GraphicFrame;
-struct ActorData {
+struct ActorData : public Common::Serializable {
uint32 count;
int32 current;
Common::Point points[120];
ActorDirection directions[120];
+
+ // Serializable
+ void saveLoadWithSerializer(Common::Serializer &s) {
+ error("[ActorData::saveLoadWithSerializer] Not implemented");
+ }
};
-class Actor {
+class Actor : public Common::Serializable {
public:
Actor(AsylumEngine *engine, ActorIndex index);
virtual ~Actor();
@@ -102,6 +108,9 @@ public:
int32 getField948() { return _field_948; }
int32 getField94C() { return _field_94C; }
+ // For saving
+ ActorData *getData() { return &_data; }
+
/////////////////////////////////////////////////////////////////////////
// Data
/////////////////////////////////////////////////////////////////////////
@@ -306,6 +315,9 @@ public:
*/
static uint32 euclidianDistance(Common::Point vec1, Common::Point vec2);
+ // Serializable
+ void saveLoadWithSerializer(Common::Serializer &s);
+
private:
AsylumEngine *_vm;
diff --git a/engines/asylum/resources/object.cpp b/engines/asylum/resources/object.cpp
index f8aae50a12..4e29f6cd08 100644
--- a/engines/asylum/resources/object.cpp
+++ b/engines/asylum/resources/object.cpp
@@ -124,6 +124,9 @@ void Object::load(Common::SeekableReadStream *stream) {
_field_6A4 = (ActorDirection)stream->readSint32LE();
}
+void Object::saveLoadWithSerializer(Common::Serializer &s) {
+ error("[Object::saveLoadWithSerializer] Not implemented");
+}
void Object::disable() {
flags &= ~kObjectFlagEnabled;
diff --git a/engines/asylum/resources/object.h b/engines/asylum/resources/object.h
index 6a98485cc8..de6d7fcbe0 100644
--- a/engines/asylum/resources/object.h
+++ b/engines/asylum/resources/object.h
@@ -28,6 +28,7 @@
#include "asylum/system/sound.h"
#include "common/rect.h"
+#include "common/serializer.h"
#include "common/stream.h"
namespace Asylum {
@@ -35,7 +36,7 @@ namespace Asylum {
class Actor;
class AsylumEngine;
-class Object {
+class Object : public Common::Serializable {
public:
Object(AsylumEngine *engine);
virtual ~Object();
@@ -162,6 +163,9 @@ public:
*/
Common::String toString(bool shortString = true);
+ // Serializable
+ void saveLoadWithSerializer(Common::Serializer &s);
+
private:
AsylumEngine *_vm;
diff --git a/engines/asylum/resources/script.cpp b/engines/asylum/resources/script.cpp
index 82a1967ddb..7b47193738 100644
--- a/engines/asylum/resources/script.cpp
+++ b/engines/asylum/resources/script.cpp
@@ -72,6 +72,10 @@ void ActionArea::load(Common::SeekableReadStream *stream) {
volume = stream->readSint32LE();
}
+void ActionArea::saveLoadWithSerializer(Common::Serializer &s) {
+ error("[ActionArea::saveLoadWithSerializer] Not implemented");
+}
+
//////////////////////////////////////////////////////////////////////////
// ScriptManager
//////////////////////////////////////////////////////////////////////////
diff --git a/engines/asylum/resources/script.h b/engines/asylum/resources/script.h
index 30d42ff9ba..8c682b8329 100644
--- a/engines/asylum/resources/script.h
+++ b/engines/asylum/resources/script.h
@@ -56,7 +56,7 @@ class Actor;
class AsylumEngine;
class Scene;
-struct ActionArea {
+struct ActionArea : public Common::Serializable {
char name[52];
int32 id;
int32 field01;
@@ -114,6 +114,9 @@ struct ActionArea {
return output;
}
+
+ // Serializable
+ void saveLoadWithSerializer(Common::Serializer &s);
};
class ScriptManager : public Common::Serializable {
diff --git a/engines/asylum/resources/worldstats.cpp b/engines/asylum/resources/worldstats.cpp
index d1a85c36e9..9645b59902 100644
--- a/engines/asylum/resources/worldstats.cpp
+++ b/engines/asylum/resources/worldstats.cpp
@@ -365,7 +365,189 @@ Common::String WorldStats::toString() {
}
void WorldStats::saveLoadWithSerializer(Common::Serializer &s) {
- error("[WorldStats::saveLoadWithSerializer] Not implemented!");
+ s.syncAsSint32LE(chapter);
+ s.syncAsSint32LE(xLeft);
+ s.syncAsSint32LE(yTop);
+ s.syncAsSint32LE(boundingRect.left);
+ s.syncAsSint32LE(boundingRect.top);
+ s.syncAsSint32LE(boundingRect.right);
+ s.syncAsSint32LE(boundingRect.bottom);
+
+ // Common graphic resources
+ s.syncAsSint32LE(backgroundImage);
+
+ for (int32 i = 0; i < ARRAYSIZE(cursorResources); i++)
+ s.syncAsSint32LE(cursorResources[i]);
+
+ s.syncAsSint32LE(font1);
+ s.syncAsSint32LE(font2);
+ s.syncAsSint32LE(font3);
+ s.syncAsSint32LE(currentPaletteId);
+
+ s.syncAsSint32LE(cellShadeMask1);
+ s.syncAsSint32LE(cellShadeMask2);
+ s.syncAsSint32LE(cellShadeMask3);
+ s.skip(unused);
+ s.syncAsSint32LE(smallCurUp);
+ s.syncAsSint32LE(smallCurDown);
+ s.syncAsSint32LE(encounterFrameBg);
+
+ s.syncAsSint32LE(width);
+ s.syncAsSint32LE(height);
+ s.syncAsSint32LE(motionStatus);
+ s.syncAsSint32LE(field_8C);
+
+ uint32 numActions = actions.size();
+ uint32 numObjects = objects.size();
+ s.syncAsUint32LE(numActions);
+ s.syncAsUint32LE(numObjects);
+
+ for (int32 i = 0; i < ARRAYSIZE(coordinates); i++)
+ s.syncAsSint32LE(coordinates[i]);
+
+ uint32 numActors = actors.size();
+ s.syncAsUint32LE(numActors);
+
+ s.syncAsUint32LE(reverseStereo);
+
+ for (int32 i = 0; i < ARRAYSIZE(sceneRects); i++) {
+ s.syncAsSint32LE(sceneRects[i].left);
+ s.syncAsSint32LE(sceneRects[i].top);
+ s.syncAsSint32LE(sceneRects[i].right);
+ s.syncAsSint32LE(sceneRects[i].bottom);
+ }
+
+ s.syncAsByte(sceneRectIdx);
+
+ for (int32 i = 0; i < ARRAYSIZE(field_11D); i++)
+ s.syncAsByte(field_11D[i]);
+
+ s.syncAsUint32LE(field_120);
+ s.syncAsUint32LE(scriptIndex);
+
+ for (int32 i = 0; i < ARRAYSIZE(graphicResourceIds); i++)
+ s.syncAsSint32LE(graphicResourceIds[i]);
+
+ s.syncAsSint32LE(sceneTitleGraphicResourceId);
+ s.syncAsSint32LE(sceneTitlePaletteResourceId);
+ s.syncAsUint32LE(actorType);
+
+ for (int32 i = 0; i < ARRAYSIZE(soundResourceIds); i++)
+ s.syncAsSint32LE(soundResourceIds[i]);
+
+ for (int32 i = 0; i < ARRAYSIZE(ambientSounds); i++) {
+ s.syncAsSint32LE(ambientSounds[i].field_0);
+ s.syncAsSint32LE(ambientSounds[i].flags);
+ s.syncAsSint32LE(ambientSounds[i].resourceId);
+ s.syncAsSint32LE(ambientSounds[i].delta);
+ s.syncAsSint32LE(ambientSounds[i].attenuation);
+ s.syncAsSint32LE(ambientSounds[i].nextTick);
+
+ for (int32 j = 0; j < ARRAYSIZE(ambientSounds[i].flagNum); j++)
+ s.syncAsSint32LE(ambientSounds[i].flagNum[j]);
+
+ s.syncAsSint32LE(ambientSounds[i].point.x);
+ s.syncAsSint32LE(ambientSounds[i].point.y);
+ }
+
+ s.syncAsUint32LE(numAmbientSounds);
+ s.syncAsSint32LE(musicStatus);
+ s.syncAsSint32LE(musicCurrentResourceIndex);
+ s.syncAsSint32LE(musicFlag);
+ s.syncAsSint32LE(musicResourceIndex);
+ s.syncAsSint32LE(musicStatusExt);
+
+ //////////////////////////////////////////////////////////////////////////
+ // Objects
+ for (uint32 i = 0; i < numObjects; i++) {
+ if (s.isLoading())
+ objects.push_back(new Object(_vm));
+
+ objects[i]->saveLoadWithSerializer(s);
+ }
+
+ s.skip((OBJECTS_MAX_COUNT - numObjects) * OBJECTS_SIZE);
+
+ //////////////////////////////////////////////////////////////////////////
+ // Actors
+ for (uint32 i = 0; i < numActors; i++) {
+ if (s.isLoading())
+ actors.push_back(new Actor(_vm, i));
+
+ actors[i]->saveLoadWithSerializer(s);
+ }
+
+ s.skip((ACTORS_MAX_COUNT - numActors) * ACTORS_SIZE);
+
+ //////////////////////////////////////////////////////////////////////////
+ // Actor data
+ for (uint32 i = 0; i < numActors; i++)
+ actors[i]->getData()->saveLoadWithSerializer(s);
+
+ s.skip((ACTORS_MAX_COUNT - numActors) * ACTORDATA_SIZE);
+
+ //////////////////////////////////////////////////////////////////////////
+ // Number of scripts and polygons
+ s.syncAsUint32LE(numScripts);
+ s.syncAsUint32LE(numPolygons);
+
+ // Alternate cursor resources
+ for (int32 i = 0; i < ARRAYSIZE(cursorResourcesAlternate); i++)
+ s.syncAsSint32LE(cursorResourcesAlternate[i]);
+
+ //////////////////////////////////////////////////////////////////////////
+ // Read actions
+ for (uint32 i = 0; i < numActions; i++) {
+ if (s.isLoading())
+ actions.push_back(new ActionArea());
+
+ actions[i]->saveLoadWithSerializer(s);
+ }
+
+ s.skip((ACTIONS_MAX_COUNT - numActions) * ACTIONS_SIZE);
+
+ s.syncAsSint32LE(field_E848C);
+ s.syncAsSint32LE(field_E8490);
+ s.syncAsSint32LE(field_E8494);
+ s.syncAsSint32LE(field_E8498);
+ s.syncAsSint32LE(field_E849C);
+
+ for (int32 i = 0; i < ARRAYSIZE(tickValueArray); i++)
+ s.syncAsSint32LE(tickValueArray[i]);
+
+ s.syncAsSint32LE(field_E8518);
+
+ for (int32 i = 0; i < 30; i++)
+ s.syncAsSint32LE(field_E851C[i]);
+
+ for (int32 i = 0; i < 30; i++)
+ s.syncAsSint32LE(field_E8594[i]);
+
+ s.syncAsSint32LE(nextPlayer);
+
+ for (int32 i = 0; i < 6; i++)
+ s.syncAsSint32LE(field_E8610[i]);
+
+ for (int32 i = 0; i < 6; i++)
+ s.syncAsSint32LE(field_E8628[i]);
+
+ for (int32 i = 0; i < ARRAYSIZE(wheels); i++) {
+
+ ObjectId id = wheels[i] ? wheels[i]->getId() : kObjectNone;
+ s.syncAsSint32LE(id);
+
+ if (s.isLoading()) {
+ if (id == kObjectNone)
+ wheels[i] = NULL;
+ else
+ wheels[i] = getObjectById(id);
+ }
+ }
+
+ s.syncAsSint32LE(tickCount1);
+
+ for (int32 i = 0; i < 6; i++)
+ s.syncAsUint32LE(field_E8660[i]);
}
} // end of namespace Asylum
Commit: ebfd32685bd59b78d6384333126985c845391a6e
https://github.com/scummvm/scummvm/commit/ebfd32685bd59b78d6384333126985c845391a6e
Author: Littleboy (littleboy at scummvm.org)
Date: 2021-05-17T15:37:17+02:00
Commit Message:
ASYLUM: Implement Object::saveLoadWithSerializer()
Changed paths:
engines/asylum/resources/object.cpp
diff --git a/engines/asylum/resources/object.cpp b/engines/asylum/resources/object.cpp
index 4e29f6cd08..f37f50ec61 100644
--- a/engines/asylum/resources/object.cpp
+++ b/engines/asylum/resources/object.cpp
@@ -125,7 +125,71 @@ void Object::load(Common::SeekableReadStream *stream) {
}
void Object::saveLoadWithSerializer(Common::Serializer &s) {
- error("[Object::saveLoadWithSerializer] Not implemented");
+ s.syncAsSint32LE(_id);
+ s.syncAsSint32LE(_resourceId);
+ s.syncAsSint32LE(x);
+ s.syncAsSint32LE(y);
+
+ s.syncAsSint32LE(_boundingRect.left);
+ s.syncAsSint32LE(_boundingRect.top);
+ s.syncAsSint32LE(_boundingRect.right);
+ s.syncAsSint32LE(_boundingRect.bottom);
+
+ s.syncAsSint32LE(_field_20);
+ s.syncAsUint32LE(_frameIndex);
+ s.syncAsUint32LE(_frameCount);
+ s.syncAsSint32LE(_field_2C);
+ s.syncAsSint32LE(_field_30);
+ s.syncAsSint32LE(_field_34);
+ s.syncAsUint32LE(flags);
+ s.syncAsSint32LE(_field_3C);
+
+ s.syncBytes((byte *)&_name, sizeof(_name));
+
+ s.syncAsSint32LE(_rect.left);
+ s.syncAsSint32LE(_rect.top);
+ s.syncAsSint32LE(_rect.right);
+ s.syncAsSint32LE(_rect.bottom);
+
+ s.syncAsUint32LE(_polygonIndex);
+ s.syncAsSint32LE(actionType);
+
+ for (int i = 0; i < ARRAYSIZE(_gameFlags); i++)
+ s.syncAsSint32LE(_gameFlags[i]);
+
+ s.syncAsSint32LE(_field_B4);
+ s.syncAsUint32LE(_tickCount);
+ s.syncAsUint32LE(_tickCount2);
+ s.syncAsUint32LE(_field_C0);
+ s.syncAsSint32LE(_priority);
+ s.syncAsSint32LE(_scriptIndex);
+
+ for (int i = 0; i < ARRAYSIZE(_soundItems); i++) {
+ s.syncAsSint32LE(_soundItems[i].resourceId);
+ s.syncAsSint32LE(_soundItems[i].field_4);
+ s.syncAsSint32LE(_soundItems[i].field_8);
+ s.syncAsSint32LE(_soundItems[i].field_C);
+ }
+
+ for (int i = 0; i < ARRAYSIZE(_frameSoundItems); i++) {
+ s.syncAsSint32LE(_frameSoundItems[i].resourceId);
+ s.syncAsSint32LE(_frameSoundItems[i].frameIndex);
+ s.syncAsSint32LE(_frameSoundItems[i].index);
+ s.syncAsSint32LE(_frameSoundItems[i].field_C);
+ s.syncAsSint32LE(_frameSoundItems[i].field_10);
+ s.syncAsSint32LE(_frameSoundItems[i].field_14);
+ }
+
+ s.syncAsSint32LE(_transparency);
+ s.syncAsSint32LE(_soundCoords.x);
+ s.syncAsSint32LE(_soundCoords.y);
+ s.syncAsSint32LE(_field_688);
+
+ for (int i = 0; i < ARRAYSIZE(_randomResourceIds); i++)
+ s.syncAsSint32LE(_randomResourceIds[i]);
+
+ s.syncAsSint32LE(_soundResourceId);
+ s.syncAsSint32LE(_field_6A4);
}
void Object::disable() {
@@ -140,7 +204,7 @@ void Object::disableAndRemoveFromQueue() {
getScreen()->deleteGraphicFromQueue(_resourceId);
}
-/////////////////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////////////////
// Visibility
//////////////////////////////////////////////////////////////////////////
bool Object::isOnScreen() {
Commit: 059c8820c33160073de2ef766ddc705dbc70652c
https://github.com/scummvm/scummvm/commit/059c8820c33160073de2ef766ddc705dbc70652c
Author: Littleboy (littleboy at scummvm.org)
Date: 2021-05-17T15:37:17+02:00
Commit Message:
ASYLUM: Implement saveLoadWithSerializer() for Actor and ActorData
- Move loading of actor data to a struct member function
Changed paths:
engines/asylum/resources/actor.cpp
engines/asylum/resources/actor.h
engines/asylum/resources/worldstats.cpp
diff --git a/engines/asylum/resources/actor.cpp b/engines/asylum/resources/actor.cpp
index b6ffa36f21..66c9c004bb 100644
--- a/engines/asylum/resources/actor.cpp
+++ b/engines/asylum/resources/actor.cpp
@@ -220,22 +220,96 @@ void Actor::load(Common::SeekableReadStream *stream) {
_field_9A0 = stream->readSint32LE();
}
-void Actor::loadData(Common::SeekableReadStream *stream) {
- _data.count = stream->readUint32LE();
+void Actor::saveLoadWithSerializer(Common::Serializer &s) {
+ s.syncAsSint32LE(_point.x);
+ s.syncAsSint32LE(_point.y);
+ s.syncAsSint32LE(_resourceId);
+ s.syncAsSint32LE(_objectIndex);
+ s.syncAsUint32LE(_frameIndex);
+ s.syncAsUint32LE(_frameCount);
+ s.syncAsSint32LE(_point1.x);
+ s.syncAsSint32LE(_point1.y);
+ s.syncAsSint32LE(_point2.x);
+ s.syncAsSint32LE(_point2.y);
+
+ s.syncAsSint32LE(_boundingRect.left);
+ s.syncAsSint32LE(_boundingRect.top);
+ s.syncAsSint32LE(_boundingRect.right);
+ s.syncAsSint32LE(_boundingRect.bottom);
+
+ s.syncAsSint32LE(_direction);
+ s.syncAsSint32LE(_field_3C);
+ s.syncAsSint32LE(_status);
+ s.syncAsSint32LE(_field_44);
+ s.syncAsSint32LE(_priority);
+ s.syncAsSint32LE(flags);
+ s.syncAsSint32LE(_field_50);
+ s.syncAsSint32LE(_field_54);
+ s.syncAsSint32LE(_field_58);
+ s.syncAsSint32LE(_field_5C);
+ s.syncAsSint32LE(_field_60);
+ s.syncAsSint32LE(_actionIdx3);
- _data.current = stream->readUint32LE();
+ // TODO skip field_68 till field_617
+ s.skip(0x5B0);
- for (int32 i = 0; i < 120; i++) {
- _data.points[i].x = stream->readSint32LE();
- _data.points[i].y = stream->readSint32LE();
- }
+ for (int32 i = 0; i < 8; i++)
+ s.syncAsSint32LE(_reaction[i]);
- for (int32 i = 0; i < 120; i++)
- _data.directions[i] = (ActorDirection)stream->readSint32LE();
-}
+ s.syncAsSint32LE(_field_638);
+ s.syncAsSint32LE(_walkingSound1);
+ s.syncAsSint32LE(_walkingSound2);
+ s.syncAsSint32LE(_walkingSound3);
+ s.syncAsSint32LE(_walkingSound4);
+ s.syncAsUint32LE(_field_64C);
+ s.syncAsUint32LE(_field_650);
-void Actor::saveLoadWithSerializer(Common::Serializer &s) {
- error("[Actor::saveLoadWithSerializer] Not implemented");
+ for (int32 i = 0; i < ARRAYSIZE(_graphicResourceIds); i++)
+ s.syncAsSint32LE(_graphicResourceIds[i]);
+
+ s.syncBytes((byte *)&_name, sizeof(_name));
+
+ for (int32 i = 0; i < 20; i++)
+ s.syncAsSint32LE(_distancesEO[i]);
+
+ for (int32 i = 0; i < 20; i++)
+ s.syncAsSint32LE(_distancesNS[i]);
+
+ for (int32 i = 0; i < 20; i++)
+ s.syncAsSint32LE(_distancesNSEO[i]);
+
+ s.syncAsSint32LE(_actionIdx2);
+ s.syncAsSint32LE(_field_924);
+ s.syncAsSint32LE(_lastScreenUpdate);
+ s.syncAsSint32LE(_scriptIndex);
+ s.syncAsSint32LE(actionType);
+ s.syncAsSint32LE(_field_934);
+ s.syncAsSint32LE(_field_938);
+ s.syncAsSint32LE(_soundResourceId);
+ s.syncAsSint32LE(_numberValue01);
+ s.syncAsSint32LE(_field_944);
+ s.syncAsSint32LE(_field_948);
+ s.syncAsSint32LE(_field_94C);
+ s.syncAsSint32LE(_numberFlag01);
+ s.syncAsSint32LE(_numberStringWidth);
+ s.syncAsSint32LE(_numberStringX);
+ s.syncAsSint32LE(_numberStringY);
+ s.syncBytes((byte *)&_numberString01, sizeof(_numberString01));
+ s.syncAsSint32LE(_field_968);
+ s.syncAsSint32LE(_transparency);
+ s.syncAsSint32LE(_processNewDirection);
+ s.syncAsSint32LE(_invertPriority);
+ s.syncAsSint32LE(_nextDirection);
+ s.syncAsSint32LE(_nextActionIndex);
+ s.syncAsSint32LE(_nextActorIndex);
+ s.syncAsSint32LE(_nextPositionOffset.x);
+ s.syncAsSint32LE(_nextPositionOffset.y);
+ s.syncAsSint32LE(_nextPosition.x);
+ s.syncAsSint32LE(_nextPosition.y);
+ s.syncAsSint32LE(_field_994);
+ s.syncAsSint32LE(_field_998);
+ s.syncAsSint32LE(_field_99C);
+ s.syncAsSint32LE(_field_9A0);
}
/////////////////////////////////////////////////////////////////////////
diff --git a/engines/asylum/resources/actor.h b/engines/asylum/resources/actor.h
index ba515d366f..7a7cb1b67b 100644
--- a/engines/asylum/resources/actor.h
+++ b/engines/asylum/resources/actor.h
@@ -45,9 +45,32 @@ struct ActorData : public Common::Serializable {
Common::Point points[120];
ActorDirection directions[120];
+ void load(Common::SeekableReadStream *stream) {
+ count = stream->readUint32LE();
+
+ current = stream->readUint32LE();
+
+ for (int32 i = 0; i < 120; i++) {
+ points[i].x = stream->readSint32LE();
+ points[i].y = stream->readSint32LE();
+ }
+
+ for (int32 i = 0; i < 120; i++)
+ directions[i] = (ActorDirection)stream->readSint32LE();
+ }
+
// Serializable
void saveLoadWithSerializer(Common::Serializer &s) {
- error("[ActorData::saveLoadWithSerializer] Not implemented");
+ s.syncAsUint32LE(count);
+ s.syncAsSint32LE(current);
+
+ for (int32 i = 0; i < ARRAYSIZE(points); i++) {
+ s.syncAsSint32LE(points[i].x);
+ s.syncAsSint32LE(points[i].y);
+ }
+
+ for (int32 i = 0; i < ARRAYSIZE(directions); i++)
+ s.syncAsSint32LE(directions[i]);
}
};
@@ -122,13 +145,6 @@ public:
*/
void load(Common::SeekableReadStream *stream);
- /**
- * Loads the actor data.
- *
- * @param stream If non-null, the Common::SeekableReadStream to load from
- */
- void loadData(Common::SeekableReadStream *stream);
-
/////////////////////////////////////////////////////////////////////////
// Visibility
/////////////////////////////////////////////////////////////////////////
diff --git a/engines/asylum/resources/worldstats.cpp b/engines/asylum/resources/worldstats.cpp
index 9645b59902..f24e36cc6f 100644
--- a/engines/asylum/resources/worldstats.cpp
+++ b/engines/asylum/resources/worldstats.cpp
@@ -220,14 +220,14 @@ void WorldStats::load(Common::SeekableReadStream *stream) {
//////////////////////////////////////////////////////////////////////////
// Read actor data
for (ActorIndex index = 0; index < (int)numActors; index++)
- actors[index]->loadData(stream);
+ actors[index]->getData()->load(stream);
stream->seek((ACTORS_MAX_COUNT - numActors) * ACTORDATA_SIZE, SEEK_CUR);
//////////////////////////////////////////////////////////////////////////
// Read number of scripts and polygons
- numScripts = stream->readUint32LE();
- numPolygons = stream->readUint32LE();
+ numScripts = stream->readUint32LE();
+ numPolygons = stream->readUint32LE();
// Load the alternate cursor resources
for (uint32 i = 0; i < ARRAYSIZE(cursorResourcesAlternate); i++)
Commit: 639ccdaff9653ea0f1ae2aa84004e56e8fc9a300
https://github.com/scummvm/scummvm/commit/639ccdaff9653ea0f1ae2aa84004e56e8fc9a300
Author: Littleboy (littleboy at scummvm.org)
Date: 2021-05-17T15:37:17+02:00
Commit Message:
ASYLUM: Implement ActionArea::saveLoadWithSerializer()
Changed paths:
engines/asylum/resources/script.cpp
diff --git a/engines/asylum/resources/script.cpp b/engines/asylum/resources/script.cpp
index 7b47193738..6809f3df41 100644
--- a/engines/asylum/resources/script.cpp
+++ b/engines/asylum/resources/script.cpp
@@ -44,7 +44,7 @@ namespace Asylum {
// ActionArea
//////////////////////////////////////////////////////////////////////////
void ActionArea::load(Common::SeekableReadStream *stream) {
- stream->read(&name, 52);
+ stream->read(&name, sizeof(name));
id = stream->readSint32LE();
field01 = stream->readSint32LE();
field02 = stream->readSint32LE();
@@ -55,7 +55,7 @@ void ActionArea::load(Common::SeekableReadStream *stream) {
scriptIndex2 = stream->readSint32LE();
actionType = stream->readSint32LE();
- for (int32 i = 0; i < 10; i++)
+ for (int32 i = 0; i < ARRAYSIZE(flagNums); i++)
flagNums[i] = stream->readSint32LE();
field_7C = stream->readSint32LE();
@@ -73,7 +73,32 @@ void ActionArea::load(Common::SeekableReadStream *stream) {
}
void ActionArea::saveLoadWithSerializer(Common::Serializer &s) {
- error("[ActionArea::saveLoadWithSerializer] Not implemented");
+ s.syncBytes((byte *)&name, sizeof(name));
+ s.syncAsSint32LE(id);
+ s.syncAsSint32LE(field01);
+ s.syncAsSint32LE(field02);
+ s.syncAsSint32LE(field_40);
+ s.syncAsSint32LE(field_44);
+ s.syncAsSint32LE(flags);
+ s.syncAsSint32LE(scriptIndex);
+ s.syncAsSint32LE(scriptIndex2);
+ s.syncAsSint32LE(actionType);
+
+ for (int32 i = 0; i < ARRAYSIZE(flagNums); i++)
+ s.syncAsSint32LE(flagNums[i]);
+
+ s.syncAsSint32LE(field_7C);
+ s.syncAsUint32LE(polygonIndex);
+ s.syncAsSint32LE(soundResourceIdFrame);
+ s.syncAsSint32LE(field_88);
+ s.syncAsSint32LE(soundResourceId);
+ s.syncAsSint32LE(field_90);
+ s.syncAsSint32LE(paletteResourceId);
+
+ for (int32 i = 0; i < 5; i++)
+ s.syncAsSint32LE(paths[i]);
+
+ s.syncAsSint32LE(volume);
}
//////////////////////////////////////////////////////////////////////////
Commit: f09c34bc51a2a98284552c918c711f50a813cdee
https://github.com/scummvm/scummvm/commit/f09c34bc51a2a98284552c918c711f50a813cdee
Author: Littleboy (littleboy at scummvm.org)
Date: 2021-05-17T15:37:17+02:00
Commit Message:
ASYLUM: Cleanup loading/saving of scene data
Changed paths:
engines/asylum/resources/worldstats.cpp
diff --git a/engines/asylum/resources/worldstats.cpp b/engines/asylum/resources/worldstats.cpp
index f24e36cc6f..e2121367e4 100644
--- a/engines/asylum/resources/worldstats.cpp
+++ b/engines/asylum/resources/worldstats.cpp
@@ -103,7 +103,7 @@ WorldStats::~WorldStats() {
_vm = NULL;
}
-// FIXME: load necessary World Stats content
+// Load necessary World Stats content
void WorldStats::load(Common::SeekableReadStream *stream) {
size = stream->readSint32LE();
numEntries = stream->readSint32LE();
@@ -149,7 +149,7 @@ void WorldStats::load(Common::SeekableReadStream *stream) {
reverseStereo = stream->readSint32LE();
- for (int32 r = 0; r < 6; r++) {
+ for (int32 r = 0; r < ARRAYSIZE(sceneRects); r++) {
sceneRects[r].left = (int16)(stream->readSint32LE() & 0xFFFF);
sceneRects[r].top = (int16)(stream->readSint32LE() & 0xFFFF);
sceneRects[r].right = (int16)(stream->readSint32LE() & 0xFFFF);
@@ -163,17 +163,17 @@ void WorldStats::load(Common::SeekableReadStream *stream) {
field_120 = stream->readSint32LE();
scriptIndex = stream->readSint32LE();
- for (int32 gr = 0; gr < 100; gr++)
+ for (int32 gr = 0; gr < ARRAYSIZE(graphicResourceIds); gr++)
graphicResourceIds[gr] = (ResourceId)stream->readSint32LE();
sceneTitleGraphicResourceId = (ResourceId)stream->readSint32LE();
sceneTitlePaletteResourceId = (ResourceId)stream->readSint32LE();
actorType = stream->readUint32LE();
- for (int32 s = 0; s < 50; s++)
+ for (int32 s = 0; s < ARRAYSIZE(soundResourceIds); s++)
soundResourceIds[s] = (ResourceId)stream->readSint32LE();
- for (int32 s = 0; s < 15; s++) {
+ for (int32 s = 0; s < ARRAYSIZE(ambientSounds); s++) {
ambientSounds[s].field_0 = stream->readSint32LE();
ambientSounds[s].flags = stream->readSint32LE();
ambientSounds[s].resourceId = (ResourceId)stream->readSint32LE();
@@ -181,7 +181,7 @@ void WorldStats::load(Common::SeekableReadStream *stream) {
ambientSounds[s].attenuation = stream->readSint32LE();
ambientSounds[s].nextTick = stream->readSint32LE();
- for (int32 i = 0; i < 6; i++)
+ for (int32 i = 0; i < ARRAYSIZE(ambientSounds[s].flagNum); i++)
ambientSounds[s].flagNum[i] = stream->readSint32LE();
ambientSounds[s].point.x = (int16)stream->readSint32LE();
@@ -255,21 +255,21 @@ void WorldStats::load(Common::SeekableReadStream *stream) {
field_E8518 = stream->readSint32LE();
- for (int32 i = 0; i < 30; i++)
+ for (int32 i = 0; i < ARRAYSIZE(field_E851C); i++)
field_E851C[i] = stream->readSint32LE();
- for (int32 i = 0; i < 30; i++)
+ for (int32 i = 0; i < ARRAYSIZE(field_E8594); i++)
field_E8594[i] = stream->readSint32LE();
nextPlayer = (ActorIndex)stream->readSint32LE();
- for (int32 i = 0; i < 6; i++)
+ for (int32 i = 0; i < ARRAYSIZE(field_E8610); i++)
field_E8610[i] = stream->readUint32LE();
- for (int32 i = 0; i < 6; i++)
+ for (int32 i = 0; i < ARRAYSIZE(field_E8628); i++)
field_E8628[i] = stream->readUint32LE();
- for (int32 i = 0; i < 7; i++) {
+ for (int32 i = 0; i < ARRAYSIZE(wheels); i++) {
ObjectId id = (ObjectId)stream->readUint32LE();
if (id == 0)
@@ -280,90 +280,10 @@ void WorldStats::load(Common::SeekableReadStream *stream) {
tickCount1 = stream->readSint32LE();
- for (int32 i = 0; i < 6; i++)
+ for (int32 i = 0; i < ARRAYSIZE(field_E8660); i++)
field_E8660[i] = stream->readUint32LE();
}
-//////////////////////////////////////////////////////////////////////////
-// Helper methods
-//////////////////////////////////////////////////////////////////////////
-int32 WorldStats::getActionAreaIndexById(int32 id) {
- for (uint32 i = 0; i < actions.size(); i++) {
- if (actions[i]->id == id)
- return i;
- }
-
- return -1;
-}
-
-int32 WorldStats::getRandomActionAreaIndexById(int32 id) {
- uint count = 0;
- int32 indexes[5];
- memset(&indexes, 0, sizeof(indexes));
-
- for (uint32 i = 0; i < actions.size(); i++) {
- if (actions[i]->id == id && count < 5) {
- indexes[count] = i;
- ++count;
- }
- }
-
- if (!count)
- return -1;
-
- return indexes[_vm->getRandom(count)];
-}
-
-ActionArea* WorldStats::getActionAreaById(int32 id) {
- int index = getActionAreaIndexById(id);
- if (index == -1)
- error("[WorldStats::getActionAreaById] action id is invalid");
-
- return actions[index];
-}
-
-Object* WorldStats::getObjectById(ObjectId id) {
- for (uint32 i = 0; i < objects.size(); i++)
- if (objects[i]->getId() == id)
- return objects[i];
-
- return NULL;
-}
-
-void WorldStats::setWheelObjects() {
- wheels[0] = getObjectById(kObjectWheel1);
- wheels[1] = getObjectById(kObjectWheel2);
- wheels[2] = getObjectById(kObjectWheel3);
- wheels[3] = getObjectById(kObjectWheel4);
- wheels[4] = getObjectById(kObjectWheel5);
- wheels[5] = getObjectById(kObjectWheel6);
- wheels[6] = getObjectById(kObjectWheel7);
-}
-
-Common::String WorldStats::toString() {
- Common::String output;
-
- output += Common::String::format("xLeft: %d\n", xLeft);
- output += Common::String::format("yTop: %d\n", yTop);
- output += Common::String::format("boundingRect: top[%d] left[%d] right[%d] bottom[%d]: \n", boundingRect.top, boundingRect.left, boundingRect.right, boundingRect.bottom);
- output += Common::String::format("width: %d\n", width);
- output += Common::String::format("height: %d\n", height);
- output += Common::String::format("motionStatus: %d\n", motionStatus);
- output += "coordinates: ";
- for (int i = 0; i < 7; i++)
- output += Common::String::format("%d[%d] ", i, coordinates[i]);
- output += "\n";
- output += Common::String::format("sceneRectIndex: %d\n", sceneRectIdx);
- output += Common::String::format("sceneRects: 0: top[%d] left[%d] right[%d] bottom[%d]\n", sceneRects[0].top, sceneRects[0].left, sceneRects[0].right, sceneRects[0].bottom);
- for (int i = 1; i < 6; i++)
- output += Common::String::format(" %d: top[%d] left[%d] right[%d] bottom[%d]\n", i, sceneRects[i].top, sceneRects[i].left, sceneRects[i].right, sceneRects[i].bottom);
- output += Common::String::format("scriptInex: %d\n", scriptIndex);
- output += Common::String::format("actorType: %d\n", actorType);
- output += Common::String::format("musicStatus: %d\n", musicStatus);
-
- return output;
-}
-
void WorldStats::saveLoadWithSerializer(Common::Serializer &s) {
s.syncAsSint32LE(chapter);
s.syncAsSint32LE(xLeft);
@@ -387,7 +307,7 @@ void WorldStats::saveLoadWithSerializer(Common::Serializer &s) {
s.syncAsSint32LE(cellShadeMask1);
s.syncAsSint32LE(cellShadeMask2);
s.syncAsSint32LE(cellShadeMask3);
- s.skip(unused);
+ s.syncAsUint32LE(unused);
s.syncAsSint32LE(smallCurUp);
s.syncAsSint32LE(smallCurDown);
s.syncAsSint32LE(encounterFrameBg);
@@ -517,18 +437,18 @@ void WorldStats::saveLoadWithSerializer(Common::Serializer &s) {
s.syncAsSint32LE(field_E8518);
- for (int32 i = 0; i < 30; i++)
+ for (int32 i = 0; i < ARRAYSIZE(field_E851C); i++)
s.syncAsSint32LE(field_E851C[i]);
- for (int32 i = 0; i < 30; i++)
+ for (int32 i = 0; i < ARRAYSIZE(field_E8594); i++)
s.syncAsSint32LE(field_E8594[i]);
s.syncAsSint32LE(nextPlayer);
- for (int32 i = 0; i < 6; i++)
+ for (int32 i = 0; i < ARRAYSIZE(field_E8610); i++)
s.syncAsSint32LE(field_E8610[i]);
- for (int32 i = 0; i < 6; i++)
+ for (int32 i = 0; i < ARRAYSIZE(field_E8628); i++)
s.syncAsSint32LE(field_E8628[i]);
for (int32 i = 0; i < ARRAYSIZE(wheels); i++) {
@@ -546,8 +466,88 @@ void WorldStats::saveLoadWithSerializer(Common::Serializer &s) {
s.syncAsSint32LE(tickCount1);
- for (int32 i = 0; i < 6; i++)
+ for (int32 i = 0; i < ARRAYSIZE(field_E8660); i++)
s.syncAsUint32LE(field_E8660[i]);
}
+//////////////////////////////////////////////////////////////////////////
+// Helper methods
+//////////////////////////////////////////////////////////////////////////
+int32 WorldStats::getActionAreaIndexById(int32 id) {
+ for (uint32 i = 0; i < actions.size(); i++) {
+ if (actions[i]->id == id)
+ return i;
+ }
+
+ return -1;
+}
+
+int32 WorldStats::getRandomActionAreaIndexById(int32 id) {
+ uint count = 0;
+ int32 indexes[5];
+ memset(&indexes, 0, sizeof(indexes));
+
+ for (uint32 i = 0; i < actions.size(); i++) {
+ if (actions[i]->id == id && count < 5) {
+ indexes[count] = i;
+ ++count;
+ }
+ }
+
+ if (!count)
+ return -1;
+
+ return indexes[_vm->getRandom(count)];
+}
+
+ActionArea* WorldStats::getActionAreaById(int32 id) {
+ int index = getActionAreaIndexById(id);
+ if (index == -1)
+ error("[WorldStats::getActionAreaById] action id is invalid");
+
+ return actions[index];
+}
+
+Object* WorldStats::getObjectById(ObjectId id) {
+ for (uint32 i = 0; i < objects.size(); i++)
+ if (objects[i]->getId() == id)
+ return objects[i];
+
+ return NULL;
+}
+
+void WorldStats::setWheelObjects() {
+ wheels[0] = getObjectById(kObjectWheel1);
+ wheels[1] = getObjectById(kObjectWheel2);
+ wheels[2] = getObjectById(kObjectWheel3);
+ wheels[3] = getObjectById(kObjectWheel4);
+ wheels[4] = getObjectById(kObjectWheel5);
+ wheels[5] = getObjectById(kObjectWheel6);
+ wheels[6] = getObjectById(kObjectWheel7);
+}
+
+Common::String WorldStats::toString() {
+ Common::String output;
+
+ output += Common::String::format("xLeft: %d\n", xLeft);
+ output += Common::String::format("yTop: %d\n", yTop);
+ output += Common::String::format("boundingRect: top[%d] left[%d] right[%d] bottom[%d]: \n", boundingRect.top, boundingRect.left, boundingRect.right, boundingRect.bottom);
+ output += Common::String::format("width: %d\n", width);
+ output += Common::String::format("height: %d\n", height);
+ output += Common::String::format("motionStatus: %d\n", motionStatus);
+ output += "coordinates: ";
+ for (int i = 0; i < 7; i++)
+ output += Common::String::format("%d[%d] ", i, coordinates[i]);
+ output += "\n";
+ output += Common::String::format("sceneRectIndex: %d\n", sceneRectIdx);
+ output += Common::String::format("sceneRects: 0: top[%d] left[%d] right[%d] bottom[%d]\n", sceneRects[0].top, sceneRects[0].left, sceneRects[0].right, sceneRects[0].bottom);
+ for (int i = 1; i < 6; i++)
+ output += Common::String::format(" %d: top[%d] left[%d] right[%d] bottom[%d]\n", i, sceneRects[i].top, sceneRects[i].left, sceneRects[i].right, sceneRects[i].bottom);
+ output += Common::String::format("scriptInex: %d\n", scriptIndex);
+ output += Common::String::format("actorType: %d\n", actorType);
+ output += Common::String::format("musicStatus: %d\n", musicStatus);
+
+ return output;
+}
+
} // end of namespace Asylum
Commit: b1493f5be3695a592277a0a6b9cf7cadb45aad3a
https://github.com/scummvm/scummvm/commit/b1493f5be3695a592277a0a6b9cf7cadb45aad3a
Author: Littleboy (littleboy at scummvm.org)
Date: 2021-05-17T15:37:18+02:00
Commit Message:
ASYLUM: Move puzzles handling to Puzzles class (formerly PuzzleData)
Changed paths:
A engines/asylum/puzzles/puzzles.cpp
A engines/asylum/puzzles/puzzles.h
R engines/asylum/puzzles/puzzledata.h
engines/asylum/asylum.cpp
engines/asylum/asylum.h
engines/asylum/console.cpp
engines/asylum/module.mk
engines/asylum/puzzles/puzzle.cpp
engines/asylum/puzzles/puzzle.h
engines/asylum/puzzles/puzzle11.cpp
engines/asylum/resources/script.cpp
engines/asylum/shared.h
engines/asylum/system/savegame.cpp
diff --git a/engines/asylum/asylum.cpp b/engines/asylum/asylum.cpp
index 3d8cc68543..dc9cd43a60 100644
--- a/engines/asylum/asylum.cpp
+++ b/engines/asylum/asylum.cpp
@@ -29,22 +29,7 @@
#include "asylum/resources/special.h"
#include "asylum/resources/worldstats.h"
-#include "asylum/puzzles/boardkeyhidesto.h"
-#include "asylum/puzzles/boardsalvation.h"
-#include "asylum/puzzles/boardyouth.h"
-#include "asylum/puzzles/clock.h"
-#include "asylum/puzzles/fisherman.h"
-#include "asylum/puzzles/hivecontrol.h"
-#include "asylum/puzzles/hivemachine.h"
-#include "asylum/puzzles/lock.h"
-#include "asylum/puzzles/morguedoor.h"
-#include "asylum/puzzles/pipes.h"
-#include "asylum/puzzles/puzzle11.h"
-#include "asylum/puzzles/tictactoe.h"
-#include "asylum/puzzles/timemachine.h"
-#include "asylum/puzzles/vcr.h"
-#include "asylum/puzzles/wheel.h"
-#include "asylum/puzzles/writings.h"
+#include "asylum/puzzles/puzzles.h"
#include "asylum/system/cursor.h"
#include "asylum/system/savegame.h"
@@ -72,7 +57,6 @@ AsylumEngine::AsylumEngine(OSystem *system, const ADGameDescription *gd) : Engin
// Init data
memset(&_gameFlags, 0, sizeof(_gameFlags));
- memset(&_puzzles, 0, sizeof(_puzzles));
memset(&_sinCosTables, 0, sizeof(_sinCosTables));
_introPlayed = false;
_tickOffset = 0;
@@ -113,6 +97,7 @@ AsylumEngine::~AsylumEngine() {
delete _cursor;
delete _scene;
delete _encounter;
+ delete _puzzles;
delete _reaction;
delete _savegame;
delete _screen;
@@ -128,10 +113,6 @@ AsylumEngine::~AsylumEngine() {
_previousScene = NULL;
- // Cleanup puzzles
- for (uint i = 0; i < ARRAYSIZE(_puzzles); i++)
- delete _puzzles[i];
-
delete _rnd;
// Zero passed pointers
@@ -152,6 +133,7 @@ Common::Error AsylumEngine::run() {
// Create all game classes
_encounter = new Encounter(this);
_cursor = new Cursor(this);
+ _puzzles = new Puzzles(this);
_reaction = new Reaction(this);
_savegame = new Savegame(this);
_screen = new Screen(this);
@@ -161,7 +143,6 @@ Common::Error AsylumEngine::run() {
_speech = new Speech(this);
_text = new Text(this);
_video = new VideoPlayer(this, _mixer);
- initPuzzles();
// Init tables
initSinCosTables(80.0, 40, 40);
@@ -269,10 +250,7 @@ void AsylumEngine::reset() {
_menu->setGameStarted();
// Reset puzzles
- for (uint i = 0; i < ARRAYSIZE(_puzzles); i++)
- delete _puzzles[i];
-
- initPuzzles();
+ _puzzles->reset();
// Reset shared data
_data.reset();
@@ -471,35 +449,6 @@ void AsylumEngine::notify(AsylumEventType type, int32 param1, int32 param2) {
_handler->handleEvent(evt);
}
-EventHandler *AsylumEngine::getPuzzle(uint32 index) const {
- if (index >= ARRAYSIZE(_puzzles))
- error("[AsylumEngine::getPuzzleEventHandler] Invalid index (was: %d - max: %d)", index, ARRAYSIZE(_puzzles));
-
- if (_puzzles[index] == NULL)
- error("[AsylumEngine::getPuzzleEventHandler] This puzzle doesn't have an event handler! (index: %d)", index);
-
- return (EventHandler *)_puzzles[index];
-}
-
-void AsylumEngine::initPuzzles() {
- _puzzles[0] = new PuzzleVCR(this);
- _puzzles[1] = new PuzzlePipes(this);
- _puzzles[2] = new PuzzleTicTacToe(this);
- _puzzles[3] = new PuzzleLock(this);
- _puzzles[4] = NULL;// No event handler for Puzzle 5
- _puzzles[5] = new PuzzleWheel(this);
- _puzzles[6] = new PuzzleBoardSalvation(this);
- _puzzles[7] = new PuzzleBoardYouth(this);
- _puzzles[8] = new PuzzleBoardKeyHidesTo(this);
- _puzzles[9] = new PuzzleWritings(this);
- _puzzles[10] = new Puzzle11(this);
- _puzzles[11] = new PuzzleMorgueDoor(this);
- _puzzles[12] = new PuzzleClock(this);
- _puzzles[13] = new PuzzleTimeMachine(this);
- _puzzles[14] = new PuzzleFisherman(this);
- _puzzles[15] = new PuzzleHiveMachine(this);
- _puzzles[16] = new PuzzleHiveControl(this);
-}
void AsylumEngine::initSinCosTables(double a2, int32 a3, int32 a4) {
uint32 offset = 0;
diff --git a/engines/asylum/asylum.h b/engines/asylum/asylum.h
index 0b4dc0813e..e31cdd3a15 100644
--- a/engines/asylum/asylum.h
+++ b/engines/asylum/asylum.h
@@ -23,7 +23,6 @@
#ifndef ASYLUM_ENGINE_H
#define ASYLUM_ENGINE_H
-#include "asylum/puzzles/puzzledata.h"
#include "asylum/resources/data.h"
#include "asylum/console.h"
@@ -57,10 +56,10 @@
*/
namespace Asylum {
-class Puzzle;
class Cursor;
class Encounter;
class Menu;
+class Puzzles;
class Reaction;
class ResourceManager;
class Savegame;
@@ -153,8 +152,8 @@ public:
Text *text() { return _text; }
VideoPlayer *video() { return _video; }
- SharedData *data() { return &_data; }
- PuzzleData *puzzleData() { return &_puzzleData; }
+ SharedData *data() { return &_data; }
+ Puzzles *puzzles() { return _puzzles; }
// Flags
void setGameFlag(GameFlag flag);
@@ -182,15 +181,6 @@ public:
*/
void notify(AsylumEventType type, int32 param1 = 0, int32 param2 = 0);
- /**
- * Gets a message handler.
- *
- * @param index Zero-based index of the message handler
- *
- * @return The message handler.
- */
- EventHandler* getPuzzle(uint32 index) const;
-
/**
* Updates the reverse stereo scene status from the config
*/
@@ -234,15 +224,14 @@ private:
// Current EventHandler class instance
EventHandler *_handler;
- Puzzle *_puzzles[17];
// Game data
- PuzzleData _puzzleData;
- SharedData _data;
- int _gameFlags[130];
- int16 _sinCosTables[72];
- bool _introPlayed;
- int32 _tickOffset;
+ Puzzles *_puzzles;
+ SharedData _data;
+ int _gameFlags[130];
+ int16 _sinCosTables[72];
+ bool _introPlayed;
+ int32 _tickOffset;
void updateMouseCursor();
void processDelayedEvents();
@@ -252,11 +241,6 @@ private:
*/
void playIntro();
- /**
- * Initializes the puzzles
- */
- void initPuzzles();
-
/**
* Initializes the sine/cosine tables.
*/
diff --git a/engines/asylum/console.cpp b/engines/asylum/console.cpp
index eb8785a3ed..f74b823185 100644
--- a/engines/asylum/console.cpp
+++ b/engines/asylum/console.cpp
@@ -22,6 +22,8 @@
#include "asylum/console.h"
+#include "asylum/puzzles/puzzles.h"
+
#include "asylum/resources/actor.h"
#include "asylum/resources/encounters.h"
#include "asylum/resources/object.h"
@@ -465,11 +467,11 @@ bool Console::cmdRunPuzzle(int32 argc, const char **argv) {
// Check index is valid
if (index < 0 || index >= ARRAYSIZE(puzzleToScenes)) {
- DebugPrintf("[Error] Invalid index (was: %d - valid: [0-%d])\n", index, ARRAYSIZE(_vm->_puzzles));
+ DebugPrintf("[Error] Invalid index (was: %d - valid: [0-%d])\n", index, ARRAYSIZE(_vm->_puzzles->_puzzles));
return true;
}
- EventHandler *puzzle = _vm->getPuzzle((uint32)index);
+ EventHandler *puzzle = getPuzzles()->getPuzzle((uint32)index);
if (puzzle == NULL) {
DebugPrintf("[Error] This puzzle does not exists (%d)", index);
return true;
diff --git a/engines/asylum/module.mk b/engines/asylum/module.mk
index 9a87af312d..149ec0949f 100644
--- a/engines/asylum/module.mk
+++ b/engines/asylum/module.mk
@@ -13,6 +13,7 @@ MODULE_OBJS := \
puzzles/morguedoor.o \
puzzles/pipes.o \
puzzles/puzzle.o \
+ puzzles/puzzles.o \
puzzles/tictactoe.o \
puzzles/timemachine.o \
puzzles/puzzle11.o \
diff --git a/engines/asylum/puzzles/puzzle.cpp b/engines/asylum/puzzles/puzzle.cpp
index fd461a4b6a..55260e126c 100644
--- a/engines/asylum/puzzles/puzzle.cpp
+++ b/engines/asylum/puzzles/puzzle.cpp
@@ -43,6 +43,10 @@ Puzzle::~Puzzle() {
_vm = NULL;
}
+void Puzzle::saveLoadWithSerializer(Common::Serializer &s) {
+ // By default, we do not save any data
+}
+
//////////////////////////////////////////////////////////////////////////
// Event Handling
//////////////////////////////////////////////////////////////////////////
diff --git a/engines/asylum/puzzles/puzzle.h b/engines/asylum/puzzles/puzzle.h
index cc9f14adc1..e53c833080 100644
--- a/engines/asylum/puzzles/puzzle.h
+++ b/engines/asylum/puzzles/puzzle.h
@@ -27,6 +27,7 @@
#include "asylum/shared.h"
#include "common/rect.h"
+#include "common/serializer.h"
namespace Asylum {
@@ -38,13 +39,16 @@ class Cursor;
class GraphicResource;
struct GraphicQueueItem;
-class Puzzle : public EventHandler {
+class Puzzle : public EventHandler, public Common::Serializable {
public:
Puzzle(AsylumEngine *engine);
virtual ~Puzzle();
bool handleEvent(const AsylumEvent &evt);
+ // Serializable
+ void saveLoadWithSerializer(Common::Serializer &s);
+
protected:
AsylumEngine *_vm;
diff --git a/engines/asylum/puzzles/puzzle11.cpp b/engines/asylum/puzzles/puzzle11.cpp
index f9feff67bc..ab4fea67c1 100644
--- a/engines/asylum/puzzles/puzzle11.cpp
+++ b/engines/asylum/puzzles/puzzle11.cpp
@@ -50,7 +50,7 @@ Puzzle11::~Puzzle11() {
// Event Handling
//////////////////////////////////////////////////////////////////////////
bool Puzzle11::init(const AsylumEvent &evt) {
- getPuzzleData()->timeMachineCounter = 0;
+ // FIXME! getPuzzleData()->timeMachineCounter = 0;
getScreen()->setPalette(getWorld()->graphicResourceIds[12]);
getScreen()->setGammaLevel(getWorld()->graphicResourceIds[12]);
diff --git a/engines/asylum/puzzles/puzzles.cpp b/engines/asylum/puzzles/puzzles.cpp
new file mode 100644
index 0000000000..bd1dff53a8
--- /dev/null
+++ b/engines/asylum/puzzles/puzzles.cpp
@@ -0,0 +1,105 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "asylum/puzzles/puzzles.h"
+
+#include "asylum/puzzles/boardkeyhidesto.h"
+#include "asylum/puzzles/boardsalvation.h"
+#include "asylum/puzzles/boardyouth.h"
+#include "asylum/puzzles/clock.h"
+#include "asylum/puzzles/fisherman.h"
+#include "asylum/puzzles/hivecontrol.h"
+#include "asylum/puzzles/hivemachine.h"
+#include "asylum/puzzles/lock.h"
+#include "asylum/puzzles/morguedoor.h"
+#include "asylum/puzzles/pipes.h"
+#include "asylum/puzzles/puzzle11.h"
+#include "asylum/puzzles/tictactoe.h"
+#include "asylum/puzzles/timemachine.h"
+#include "asylum/puzzles/vcr.h"
+#include "asylum/puzzles/wheel.h"
+#include "asylum/puzzles/writings.h"
+
+#include "asylum/asylum.h"
+#include "asylum/console.h"
+#include "asylum/shared.h"
+
+namespace Asylum {
+
+Puzzles::Puzzles(AsylumEngine *engine) : _vm(engine) {
+ memset(&_puzzles, 0, sizeof(_puzzles));
+}
+
+Puzzles::~Puzzles() {
+ // Cleanup puzzles
+ for (uint i = 0; i < ARRAYSIZE(_puzzles); i++)
+ delete _puzzles[i];
+
+ // Zero passed pointers
+ _vm = NULL;
+}
+
+void Puzzles::reset() {
+ for (uint i = 0; i < ARRAYSIZE(_puzzles); i++)
+ delete _puzzles[i];
+
+ initPuzzles();
+}
+
+EventHandler *Puzzles::getPuzzle(uint32 index) const {
+ if (index >= ARRAYSIZE(_puzzles))
+ error("[AsylumEngine::getPuzzleEventHandler] Invalid index (was: %d - max: %d)", index, ARRAYSIZE(_puzzles));
+
+ if (_puzzles[index] == NULL)
+ error("[AsylumEngine::getPuzzleEventHandler] This puzzle doesn't have an event handler! (index: %d)", index);
+
+ return (EventHandler *)_puzzles[index];
+}
+
+void Puzzles::initPuzzles() {
+ _puzzles[0] = new PuzzleVCR(_vm);
+ _puzzles[1] = new PuzzlePipes(_vm);
+ _puzzles[2] = new PuzzleTicTacToe(_vm);
+ _puzzles[3] = new PuzzleLock(_vm);
+ _puzzles[4] = NULL; // No event handler for Puzzle 5
+ _puzzles[5] = new PuzzleWheel(_vm);
+ _puzzles[6] = new PuzzleBoardSalvation(_vm);
+ _puzzles[7] = new PuzzleBoardYouth(_vm);
+ _puzzles[8] = new PuzzleBoardKeyHidesTo(_vm);
+ _puzzles[9] = new PuzzleWritings(_vm);
+ _puzzles[10] = new Puzzle11(_vm);
+ _puzzles[11] = new PuzzleMorgueDoor(_vm);
+ _puzzles[12] = new PuzzleClock(_vm);
+ _puzzles[13] = new PuzzleTimeMachine(_vm);
+ _puzzles[14] = new PuzzleFisherman(_vm);
+ _puzzles[15] = new PuzzleHiveMachine(_vm);
+ _puzzles[16] = new PuzzleHiveControl(_vm);
+}
+
+void Puzzles::saveLoadWithSerializer(Common::Serializer &s) {
+ for (int32 i = 0; i < ARRAYSIZE(_puzzles); i++) {
+ if (_puzzles[i])
+ _puzzles[i]->saveLoadWithSerializer(s);
+ }
+}
+
+} // End of namespace Asylum
diff --git a/engines/asylum/puzzles/puzzledata.h b/engines/asylum/puzzles/puzzles.h
similarity index 65%
rename from engines/asylum/puzzles/puzzledata.h
rename to engines/asylum/puzzles/puzzles.h
index 5c06a90115..6a2568ddea 100644
--- a/engines/asylum/puzzles/puzzledata.h
+++ b/engines/asylum/puzzles/puzzles.h
@@ -20,8 +20,8 @@
*
*/
-#ifndef ASYLUM_PUZZLE_DATA_H
-#define ASYLUM_PUZZLE_DATA_H
+#ifndef ASYLUM_PUZZLES_H
+#define ASYLUM_PUZZLES_H
#include "asylum/console.h"
#include "asylum/shared.h"
@@ -30,20 +30,44 @@
namespace Asylum {
-struct PuzzleData : public Common::Serializable {
+class EventHandler;
+class Puzzle;
+
+class Puzzles : public Common::Serializable {
public:
- uint32 timeMachineCounter;
+ Puzzles(AsylumEngine *engine);
+ ~Puzzles();
+
+ /**
+ * Resets puzzles
+ */
+ void reset();
- PuzzleData() {
- timeMachineCounter = 0;
- }
+ /**
+ * Gets a message handler.
+ *
+ * @param index Zero-based index of the message handler
+ *
+ * @return The message handler.
+ */
+ EventHandler* getPuzzle(uint32 index) const;
// Serializable
- void saveLoadWithSerializer(Common::Serializer &s) {
- error("[PuzzleData::saveLoadWithSerializer] Not implemented!");
- }
+ void saveLoadWithSerializer(Common::Serializer &s);
+
+private:
+ AsylumEngine* _vm;
+ Puzzle *_puzzles[17];
+
+ /**
+ * Initializes the puzzles
+ */
+ void initPuzzles();
+
+ // Debug
+ friend class Console;
};
} // End of namespace Asylum
-#endif // ASYLUM_PUZZLE_DATA_H
+#endif // ASYLUM_PUZZLES_H
diff --git a/engines/asylum/resources/script.cpp b/engines/asylum/resources/script.cpp
index 6809f3df41..ff9a84db65 100644
--- a/engines/asylum/resources/script.cpp
+++ b/engines/asylum/resources/script.cpp
@@ -22,6 +22,8 @@
#include "asylum/resources/script.h"
+#include "asylum/puzzles/puzzles.h"
+
#include "asylum/resources/actor.h"
#include "asylum/resources/encounters.h"
#include "asylum/resources/object.h"
@@ -1124,7 +1126,7 @@ IMPLEMENT_OPCODE(RunPuzzle)
getScreen()->clear();
getScreen()->clearGraphicsInQueue();
- _vm->switchEventHandler(_vm->getPuzzle((uint32)cmd->param1));
+ _vm->switchEventHandler(getPuzzles()->getPuzzle((uint32)cmd->param1));
_currentQueueEntry->currentLine++;
diff --git a/engines/asylum/shared.h b/engines/asylum/shared.h
index 66c112e99c..0c2d66a6c1 100644
--- a/engines/asylum/shared.h
+++ b/engines/asylum/shared.h
@@ -669,7 +669,7 @@ enum ObjectFlag {
#define getEncounter() _vm->encounter()
#define getCursor() _vm->cursor()
#define getMenu() _vm->menu()
-#define getPuzzleData() _vm->puzzleData()
+#define getPuzzles() _vm->puzzles()
#define getReaction() _vm->reaction()
#define getResource() _vm->resource()
#define getSound() _vm->sound()
diff --git a/engines/asylum/system/savegame.cpp b/engines/asylum/system/savegame.cpp
index d764f404b8..8e4fe79d35 100644
--- a/engines/asylum/system/savegame.cpp
+++ b/engines/asylum/system/savegame.cpp
@@ -22,7 +22,7 @@
#include "asylum/system/savegame.h"
-#include "asylum/puzzles/puzzledata.h"
+#include "asylum/puzzles/puzzles.h"
#include "asylum/resources/encounters.h"
#include "asylum/resources/script.h"
@@ -279,7 +279,7 @@ bool Savegame::loadData(Common::String filename) {
read(file, _vm, 1512, 1, "Game Stats");
read(file, getWorld(), 951928, 1, "World Stats");
- read(file, getPuzzleData(), 752, 1, "Blowup Puzzle Data");
+ read(file, getPuzzles(), 752, 1, "Blowup Puzzle Data");
read(file, getEncounter()->items(), 109, getEncounter()->items()->size(), "Encounter Data");
read(file, getEncounter()->variables(), 2, getEncounter()->variables()->size(), "Encounter Variables");
@@ -307,7 +307,7 @@ bool Savegame::saveData(Common::String filename, Common::String name, ChapterInd
writeHeader(file);
write(file, _vm, 1512, 1, "Game Stats");
write(file, getWorld(), 951928, 1, "World Stats");
- write(file, getPuzzleData(), 752, 1, "Blowup Puzzle Data");
+ write(file, getPuzzles(), 752, 1, "Blowup Puzzle Data");
write(file, getEncounter()->items(), 109, getEncounter()->items()->size(), "Encounter Data");
write(file, getEncounter()->variables(), 2, getEncounter()->variables()->size(), "Encounter Variables");
Commit: 34b50ab2f3bfedd9c7d395f4599246e411b3c0ae
https://github.com/scummvm/scummvm/commit/34b50ab2f3bfedd9c7d395f4599246e411b3c0ae
Author: Littleboy (littleboy at scummvm.org)
Date: 2021-05-17T15:37:18+02:00
Commit Message:
ASYLUM: Add stubs for puzzles saveLoadWithSerializer()
Changed paths:
engines/asylum/puzzles/boardkeyhidesto.cpp
engines/asylum/puzzles/boardkeyhidesto.h
engines/asylum/puzzles/boardsalvation.cpp
engines/asylum/puzzles/boardsalvation.h
engines/asylum/puzzles/boardyouth.cpp
engines/asylum/puzzles/boardyouth.h
engines/asylum/puzzles/clock.cpp
engines/asylum/puzzles/clock.h
engines/asylum/puzzles/fisherman.cpp
engines/asylum/puzzles/fisherman.h
engines/asylum/puzzles/hivecontrol.cpp
engines/asylum/puzzles/hivecontrol.h
engines/asylum/puzzles/lock.cpp
engines/asylum/puzzles/lock.h
engines/asylum/puzzles/morguedoor.cpp
engines/asylum/puzzles/morguedoor.h
engines/asylum/puzzles/pipes.cpp
engines/asylum/puzzles/pipes.h
engines/asylum/puzzles/puzzle.h
engines/asylum/puzzles/puzzles.cpp
engines/asylum/puzzles/timemachine.cpp
engines/asylum/puzzles/timemachine.h
engines/asylum/puzzles/vcr.cpp
engines/asylum/puzzles/vcr.h
engines/asylum/puzzles/wheel.cpp
engines/asylum/puzzles/wheel.h
engines/asylum/shared.h
diff --git a/engines/asylum/puzzles/boardkeyhidesto.cpp b/engines/asylum/puzzles/boardkeyhidesto.cpp
index 84af8a5c6e..0b61a06187 100644
--- a/engines/asylum/puzzles/boardkeyhidesto.cpp
+++ b/engines/asylum/puzzles/boardkeyhidesto.cpp
@@ -52,6 +52,10 @@ static const PuzzleBoard::PuzzleData puzzleKeyHidesToData = {
PuzzleBoardKeyHidesTo::PuzzleBoardKeyHidesTo(AsylumEngine *engine) : PuzzleBoard(engine, puzzleKeyHidesToData) {
}
+void PuzzleBoardKeyHidesTo::saveLoadWithSerializer(Common::Serializer &s) {
+ error("[PuzzleBoardKeyHidesTo::saveLoadWithSerializer] Not implemented");
+}
+
//////////////////////////////////////////////////////////////////////////
// Event Handling
//////////////////////////////////////////////////////////////////////////
diff --git a/engines/asylum/puzzles/boardkeyhidesto.h b/engines/asylum/puzzles/boardkeyhidesto.h
index 202a5b6c60..a17554d719 100644
--- a/engines/asylum/puzzles/boardkeyhidesto.h
+++ b/engines/asylum/puzzles/boardkeyhidesto.h
@@ -33,6 +33,9 @@ class PuzzleBoardKeyHidesTo : public PuzzleBoard {
public:
PuzzleBoardKeyHidesTo(AsylumEngine *engine);
+ // Serializable
+ virtual void saveLoadWithSerializer(Common::Serializer &s);
+
private:
//////////////////////////////////////////////////////////////////////////
// Event Handling
diff --git a/engines/asylum/puzzles/boardsalvation.cpp b/engines/asylum/puzzles/boardsalvation.cpp
index 8543b976f0..7349e74f90 100644
--- a/engines/asylum/puzzles/boardsalvation.cpp
+++ b/engines/asylum/puzzles/boardsalvation.cpp
@@ -57,6 +57,10 @@ static const uint32 puzzleSalvationSoundResourceIndex[11] = {5, 6, 7, 10, 11, 28
PuzzleBoardSalvation::PuzzleBoardSalvation(AsylumEngine *engine) : PuzzleBoard(engine, puzzleSalvationData) {
}
+void PuzzleBoardSalvation::saveLoadWithSerializer(Common::Serializer &s) {
+ error("[PuzzleBoardSalvation::saveLoadWithSerializer] Not implemented");
+}
+
//////////////////////////////////////////////////////////////////////////
// Event Handling
//////////////////////////////////////////////////////////////////////////
diff --git a/engines/asylum/puzzles/boardsalvation.h b/engines/asylum/puzzles/boardsalvation.h
index 549ad5bc8b..c2dafed81a 100644
--- a/engines/asylum/puzzles/boardsalvation.h
+++ b/engines/asylum/puzzles/boardsalvation.h
@@ -33,6 +33,9 @@ class PuzzleBoardSalvation : public PuzzleBoard {
public:
PuzzleBoardSalvation(AsylumEngine *engine);
+ // Serializable
+ virtual void saveLoadWithSerializer(Common::Serializer &s);
+
private:
//////////////////////////////////////////////////////////////////////////
// Event Handling
diff --git a/engines/asylum/puzzles/boardyouth.cpp b/engines/asylum/puzzles/boardyouth.cpp
index 6eca9effd6..36438146b4 100644
--- a/engines/asylum/puzzles/boardyouth.cpp
+++ b/engines/asylum/puzzles/boardyouth.cpp
@@ -50,6 +50,10 @@ static const PuzzleBoard::PuzzleData puzzleYouthData = {
PuzzleBoardYouth::PuzzleBoardYouth(AsylumEngine *engine) : PuzzleBoard(engine, puzzleYouthData) {
}
+void PuzzleBoardYouth::saveLoadWithSerializer(Common::Serializer &s) {
+ error("[PuzzleBoardYouth::saveLoadWithSerializer] Not implemented");
+}
+
//////////////////////////////////////////////////////////////////////////
// Event Handling
//////////////////////////////////////////////////////////////////////////
diff --git a/engines/asylum/puzzles/boardyouth.h b/engines/asylum/puzzles/boardyouth.h
index eb0e8f964b..40c61e3caa 100644
--- a/engines/asylum/puzzles/boardyouth.h
+++ b/engines/asylum/puzzles/boardyouth.h
@@ -33,6 +33,9 @@ class PuzzleBoardYouth : public PuzzleBoard {
public:
PuzzleBoardYouth(AsylumEngine *engine);
+ // Serializable
+ virtual void saveLoadWithSerializer(Common::Serializer &s);
+
private:
//////////////////////////////////////////////////////////////////////////
// Event Handling
diff --git a/engines/asylum/puzzles/clock.cpp b/engines/asylum/puzzles/clock.cpp
index 35a9fbd1bb..5b7c7aef6d 100644
--- a/engines/asylum/puzzles/clock.cpp
+++ b/engines/asylum/puzzles/clock.cpp
@@ -72,6 +72,10 @@ PuzzleClock::PuzzleClock(AsylumEngine *engine) : Puzzle(engine) {
PuzzleClock::~PuzzleClock() {
}
+void PuzzleClock::saveLoadWithSerializer(Common::Serializer &s) {
+ error("[PuzzleClock::saveLoadWithSerializer] Not implemented");
+}
+
//////////////////////////////////////////////////////////////////////////
// Event Handling
//////////////////////////////////////////////////////////////////////////
diff --git a/engines/asylum/puzzles/clock.h b/engines/asylum/puzzles/clock.h
index ea63108826..799663d76b 100644
--- a/engines/asylum/puzzles/clock.h
+++ b/engines/asylum/puzzles/clock.h
@@ -34,6 +34,9 @@ public:
PuzzleClock(AsylumEngine *engine);
~PuzzleClock();
+ // Serializable
+ virtual void saveLoadWithSerializer(Common::Serializer &s);
+
private:
uint32 _frameIndexes[3];
bool _showCursor;
diff --git a/engines/asylum/puzzles/fisherman.cpp b/engines/asylum/puzzles/fisherman.cpp
index 1bd939aaec..8c8267ebb8 100644
--- a/engines/asylum/puzzles/fisherman.cpp
+++ b/engines/asylum/puzzles/fisherman.cpp
@@ -57,6 +57,10 @@ PuzzleFisherman::PuzzleFisherman(AsylumEngine *engine) : Puzzle(engine) {
PuzzleFisherman::~PuzzleFisherman() {
}
+void PuzzleFisherman::saveLoadWithSerializer(Common::Serializer &s) {
+ error("[PuzzleFisherman::saveLoadWithSerializer] Not implemented");
+}
+
//////////////////////////////////////////////////////////////////////////
// Event Handling
//////////////////////////////////////////////////////////////////////////
diff --git a/engines/asylum/puzzles/fisherman.h b/engines/asylum/puzzles/fisherman.h
index 607ac3042e..83175128a3 100644
--- a/engines/asylum/puzzles/fisherman.h
+++ b/engines/asylum/puzzles/fisherman.h
@@ -34,6 +34,9 @@ public:
PuzzleFisherman(AsylumEngine *engine);
~PuzzleFisherman();
+ // Serializable
+ virtual void saveLoadWithSerializer(Common::Serializer &s);
+
private:
bool _state[6];
int32 _counter;
diff --git a/engines/asylum/puzzles/hivecontrol.cpp b/engines/asylum/puzzles/hivecontrol.cpp
index d06ce1de41..737e4ec190 100644
--- a/engines/asylum/puzzles/hivecontrol.cpp
+++ b/engines/asylum/puzzles/hivecontrol.cpp
@@ -68,6 +68,10 @@ PuzzleHiveControl::PuzzleHiveControl(AsylumEngine *engine) : Puzzle(engine) {
PuzzleHiveControl::~PuzzleHiveControl() {
}
+void PuzzleHiveControl::saveLoadWithSerializer(Common::Serializer &s) {
+ error("[PuzzleHiveControl::saveLoadWithSerializer] Not implemented");
+}
+
void PuzzleHiveControl::reset() {
_leverPosition = 3;
_leverDelta = 0;
diff --git a/engines/asylum/puzzles/hivecontrol.h b/engines/asylum/puzzles/hivecontrol.h
index 5774a4f3a5..361af0cd2e 100644
--- a/engines/asylum/puzzles/hivecontrol.h
+++ b/engines/asylum/puzzles/hivecontrol.h
@@ -59,6 +59,9 @@ public:
PuzzleHiveControl(AsylumEngine *engine);
~PuzzleHiveControl();
+ // Serializable
+ virtual void saveLoadWithSerializer(Common::Serializer &s);
+
private:
enum Element {
kElementSwirl = 31,
diff --git a/engines/asylum/puzzles/lock.cpp b/engines/asylum/puzzles/lock.cpp
index 491e040744..6604294cb9 100644
--- a/engines/asylum/puzzles/lock.cpp
+++ b/engines/asylum/puzzles/lock.cpp
@@ -51,6 +51,10 @@ PuzzleLock::PuzzleLock(AsylumEngine *engine) : Puzzle(engine) {
PuzzleLock::~PuzzleLock() {
}
+void PuzzleLock::saveLoadWithSerializer(Common::Serializer &s) {
+ error("[PuzzleLock::saveLoadWithSerializer] Not implemented");
+}
+
//////////////////////////////////////////////////////////////////////////
// Event Handling
//////////////////////////////////////////////////////////////////////////
diff --git a/engines/asylum/puzzles/lock.h b/engines/asylum/puzzles/lock.h
index d6b3c66413..351d9833e5 100644
--- a/engines/asylum/puzzles/lock.h
+++ b/engines/asylum/puzzles/lock.h
@@ -34,6 +34,9 @@ public:
PuzzleLock(AsylumEngine *engine);
~PuzzleLock();
+ // Serializable
+ virtual void saveLoadWithSerializer(Common::Serializer &s);
+
private:
int32 _frameIndexes[7];
bool _incrementLock;
diff --git a/engines/asylum/puzzles/morguedoor.cpp b/engines/asylum/puzzles/morguedoor.cpp
index 37e971175a..26fed12271 100644
--- a/engines/asylum/puzzles/morguedoor.cpp
+++ b/engines/asylum/puzzles/morguedoor.cpp
@@ -57,9 +57,8 @@ PuzzleMorgueDoor::PuzzleMorgueDoor(AsylumEngine *engine) : Puzzle(engine) {
PuzzleMorgueDoor::~PuzzleMorgueDoor() {
}
-void PuzzleMorgueDoor::reset() {
- _data_45A9D8 = 0;
- _data_45A9DC = 0;
+void PuzzleMorgueDoor::saveLoadWithSerializer(Common::Serializer &s) {
+ error("[PuzzleMorgueDoor::saveLoadWithSerializer] Not implemented");
}
//////////////////////////////////////////////////////////////////////////
diff --git a/engines/asylum/puzzles/morguedoor.h b/engines/asylum/puzzles/morguedoor.h
index 8cd070042e..3e705bb9ed 100644
--- a/engines/asylum/puzzles/morguedoor.h
+++ b/engines/asylum/puzzles/morguedoor.h
@@ -34,7 +34,8 @@ public:
PuzzleMorgueDoor(AsylumEngine *engine);
~PuzzleMorgueDoor();
- void reset();
+ // Serializable
+ virtual void saveLoadWithSerializer(Common::Serializer &s);
private:
enum PuzzleObject {
diff --git a/engines/asylum/puzzles/pipes.cpp b/engines/asylum/puzzles/pipes.cpp
index bf9ac97965..d75d0f44ca 100644
--- a/engines/asylum/puzzles/pipes.cpp
+++ b/engines/asylum/puzzles/pipes.cpp
@@ -321,6 +321,10 @@ PuzzlePipes::~PuzzlePipes() {
delete [] _frameIndexSpider;
}
+void PuzzlePipes::saveLoadWithSerializer(Common::Serializer &s) {
+ error("[PuzzlePipes::saveLoadWithSerializer] Not implemented");
+}
+
//////////////////////////////////////////////////////////////////////////
// Event Handling
//////////////////////////////////////////////////////////////////////////
diff --git a/engines/asylum/puzzles/pipes.h b/engines/asylum/puzzles/pipes.h
index 6946891048..5e2d81c823 100644
--- a/engines/asylum/puzzles/pipes.h
+++ b/engines/asylum/puzzles/pipes.h
@@ -154,6 +154,9 @@ public:
PuzzlePipes(AsylumEngine *engine);
~PuzzlePipes();
+ // Serializable
+ virtual void saveLoadWithSerializer(Common::Serializer &s);
+
private:
int32 _previousMusicVolume;
int32 _rectIndex;
diff --git a/engines/asylum/puzzles/puzzle.h b/engines/asylum/puzzles/puzzle.h
index e53c833080..9cb240045e 100644
--- a/engines/asylum/puzzles/puzzle.h
+++ b/engines/asylum/puzzles/puzzle.h
@@ -47,7 +47,7 @@ public:
bool handleEvent(const AsylumEvent &evt);
// Serializable
- void saveLoadWithSerializer(Common::Serializer &s);
+ virtual void saveLoadWithSerializer(Common::Serializer &s);
protected:
AsylumEngine *_vm;
diff --git a/engines/asylum/puzzles/puzzles.cpp b/engines/asylum/puzzles/puzzles.cpp
index bd1dff53a8..b6e94f5a49 100644
--- a/engines/asylum/puzzles/puzzles.cpp
+++ b/engines/asylum/puzzles/puzzles.cpp
@@ -76,30 +76,41 @@ EventHandler *Puzzles::getPuzzle(uint32 index) const {
}
void Puzzles::initPuzzles() {
- _puzzles[0] = new PuzzleVCR(_vm);
- _puzzles[1] = new PuzzlePipes(_vm);
- _puzzles[2] = new PuzzleTicTacToe(_vm);
- _puzzles[3] = new PuzzleLock(_vm);
- _puzzles[4] = NULL; // No event handler for Puzzle 5
- _puzzles[5] = new PuzzleWheel(_vm);
- _puzzles[6] = new PuzzleBoardSalvation(_vm);
- _puzzles[7] = new PuzzleBoardYouth(_vm);
- _puzzles[8] = new PuzzleBoardKeyHidesTo(_vm);
- _puzzles[9] = new PuzzleWritings(_vm);
- _puzzles[10] = new Puzzle11(_vm);
- _puzzles[11] = new PuzzleMorgueDoor(_vm);
- _puzzles[12] = new PuzzleClock(_vm);
- _puzzles[13] = new PuzzleTimeMachine(_vm);
- _puzzles[14] = new PuzzleFisherman(_vm);
- _puzzles[15] = new PuzzleHiveMachine(_vm);
- _puzzles[16] = new PuzzleHiveControl(_vm);
+ _puzzles[kPuzzleVCR] = new PuzzleVCR(_vm);
+ _puzzles[kPuzzlePipes] = new PuzzlePipes(_vm);
+ _puzzles[kPuzzleTicTacToe] = new PuzzleTicTacToe(_vm);
+ _puzzles[kPuzzleLock] = new PuzzleLock(_vm);
+ _puzzles[kPuzzle4] = NULL; // No event handler for Puzzle 5
+ _puzzles[kPuzzleWheel] = new PuzzleWheel(_vm);
+ _puzzles[kPuzzleBoardSalvation] = new PuzzleBoardSalvation(_vm);
+ _puzzles[kPuzzleBoardYouth] = new PuzzleBoardYouth(_vm);
+ _puzzles[kPuzzleBoardKeyHidesTo] = new PuzzleBoardKeyHidesTo(_vm);
+ _puzzles[kPuzzleWritings] = new PuzzleWritings(_vm);
+ _puzzles[kPuzzle11] = new Puzzle11(_vm);
+ _puzzles[kPuzzleMorgueDoor] = new PuzzleMorgueDoor(_vm);
+ _puzzles[kPuzzleClock] = new PuzzleClock(_vm);
+ _puzzles[kPuzzleTimeMachine] = new PuzzleTimeMachine(_vm);
+ _puzzles[kPuzzleFisherman] = new PuzzleFisherman(_vm);
+ _puzzles[kPuzzleHiveMachine] = new PuzzleHiveMachine(_vm);
+ _puzzles[kPuzzleHiveControl] = new PuzzleHiveControl(_vm);
}
void Puzzles::saveLoadWithSerializer(Common::Serializer &s) {
- for (int32 i = 0; i < ARRAYSIZE(_puzzles); i++) {
- if (_puzzles[i])
- _puzzles[i]->saveLoadWithSerializer(s);
- }
+ _puzzles[kPuzzleVCR]->saveLoadWithSerializer(s);
+ s.skip(4);
+ _puzzles[kPuzzleLock]->saveLoadWithSerializer(s);
+ _puzzles[kPuzzlePipes]->saveLoadWithSerializer(s);
+ _puzzles[kPuzzleWheel]->saveLoadWithSerializer(s);
+ _puzzles[kPuzzleBoardSalvation]->saveLoadWithSerializer(s);
+ _puzzles[kPuzzleBoardYouth]->saveLoadWithSerializer(s);
+ s.skip(8);
+ _puzzles[kPuzzleBoardKeyHidesTo]->saveLoadWithSerializer(s);
+ _puzzles[kPuzzleMorgueDoor]->saveLoadWithSerializer(s);
+ _puzzles[kPuzzle11]->saveLoadWithSerializer(s);
+ _puzzles[kPuzzleTimeMachine]->saveLoadWithSerializer(s);
+ _puzzles[kPuzzleClock]->saveLoadWithSerializer(s);
+ _puzzles[kPuzzleFisherman]->saveLoadWithSerializer(s);
+ _puzzles[kPuzzleHiveControl]->saveLoadWithSerializer(s);
}
} // End of namespace Asylum
diff --git a/engines/asylum/puzzles/timemachine.cpp b/engines/asylum/puzzles/timemachine.cpp
index e222619054..09978a7a97 100644
--- a/engines/asylum/puzzles/timemachine.cpp
+++ b/engines/asylum/puzzles/timemachine.cpp
@@ -76,17 +76,8 @@ PuzzleTimeMachine::PuzzleTimeMachine(AsylumEngine *engine) : Puzzle(engine) {
PuzzleTimeMachine::~PuzzleTimeMachine() {
}
-void PuzzleTimeMachine::reset() {
- _frameIndexes[0] = 0;
- _frameIndexes[1] = 4;
- _frameIndexes[2] = 20;
- _frameIndexes[3] = 16;
- _frameIndexes[4] = 20;
- memset(&_state, 0, sizeof(_state));
- _data_45AAAC = 0;
-
- // Reset point only (the other values are static)
- _point = Common::Point(-65, -30);
+void PuzzleTimeMachine::saveLoadWithSerializer(Common::Serializer &s) {
+ error("[PuzzleTimeMachine::saveLoadWithSerializer] Not implemented");
}
//////////////////////////////////////////////////////////////////////////
diff --git a/engines/asylum/puzzles/timemachine.h b/engines/asylum/puzzles/timemachine.h
index fd0bda1028..b5f00280de 100644
--- a/engines/asylum/puzzles/timemachine.h
+++ b/engines/asylum/puzzles/timemachine.h
@@ -34,7 +34,8 @@ public:
PuzzleTimeMachine(AsylumEngine *engine);
~PuzzleTimeMachine();
- void reset();
+ // Serializable
+ virtual void saveLoadWithSerializer(Common::Serializer &s);
private:
bool _leftButtonClicked;
diff --git a/engines/asylum/puzzles/vcr.cpp b/engines/asylum/puzzles/vcr.cpp
index 5201958204..1b539e0e8b 100644
--- a/engines/asylum/puzzles/vcr.cpp
+++ b/engines/asylum/puzzles/vcr.cpp
@@ -49,6 +49,10 @@ PuzzleVCR::PuzzleVCR(AsylumEngine *engine): Puzzle(engine) {
PuzzleVCR::~PuzzleVCR() {
}
+void PuzzleVCR::saveLoadWithSerializer(Common::Serializer &s) {
+ error("[PuzzleVCR::saveLoadWithSerializer] Not implemented");
+}
+
//////////////////////////////////////////////////////////////////////////
// Event Handling
//////////////////////////////////////////////////////////////////////////
diff --git a/engines/asylum/puzzles/vcr.h b/engines/asylum/puzzles/vcr.h
index 879caca17d..8c8021813c 100644
--- a/engines/asylum/puzzles/vcr.h
+++ b/engines/asylum/puzzles/vcr.h
@@ -57,6 +57,9 @@ public:
PuzzleVCR(AsylumEngine *engine);
~PuzzleVCR();
+ // Serializable
+ virtual void saveLoadWithSerializer(Common::Serializer &s);
+
private:
enum Color {
kNone = -1,
diff --git a/engines/asylum/puzzles/wheel.cpp b/engines/asylum/puzzles/wheel.cpp
index 457305ba22..c746a553f7 100644
--- a/engines/asylum/puzzles/wheel.cpp
+++ b/engines/asylum/puzzles/wheel.cpp
@@ -149,20 +149,8 @@ PuzzleWheel::PuzzleWheel(AsylumEngine *engine) : Puzzle(engine) {
PuzzleWheel::~PuzzleWheel() {
}
-void PuzzleWheel::reset() {
- getSpecial()->reset(true);
-
- _resourceIndex = 0;
- _resourceIndexLever = 13;
-
- _frameIndexWheel = 0;
-
- _frameIndexes[0] = 0;
- _frameIndexes[9] = 0;
- _frameIndexes[10] = 0;
- _frameIndexes[11] = 0;
-
- _turnWheelRight = false;
+void PuzzleWheel::saveLoadWithSerializer(Common::Serializer &s) {
+ error("[PuzzleWheel::saveLoadWithSerializer] Not implemented");
}
//////////////////////////////////////////////////////////////////////////
diff --git a/engines/asylum/puzzles/wheel.h b/engines/asylum/puzzles/wheel.h
index 8a5f2815b0..41f0478558 100644
--- a/engines/asylum/puzzles/wheel.h
+++ b/engines/asylum/puzzles/wheel.h
@@ -34,7 +34,8 @@ public:
PuzzleWheel(AsylumEngine *engine);
~PuzzleWheel();
- void reset();
+ // Serializable
+ virtual void saveLoadWithSerializer(Common::Serializer &s);
private:
int32 _currentRect;
diff --git a/engines/asylum/shared.h b/engines/asylum/shared.h
index 0c2d66a6c1..3741c9d600 100644
--- a/engines/asylum/shared.h
+++ b/engines/asylum/shared.h
@@ -647,6 +647,29 @@ enum ObjectFlag {
kObjectFlag40000 = 0x40000
};
+//////////////////////////////////////////////////////////////////////////
+// Puzzles
+//////////////////////////////////////////////////////////////////////////
+enum PuzzleId {
+ kPuzzleVCR = 0,
+ kPuzzlePipes,
+ kPuzzleTicTacToe,
+ kPuzzleLock,
+ kPuzzle4,
+ kPuzzleWheel, // 5
+ kPuzzleBoardSalvation,
+ kPuzzleBoardYouth,
+ kPuzzleBoardKeyHidesTo,
+ kPuzzleWritings,
+ kPuzzle11, // 10
+ kPuzzleMorgueDoor,
+ kPuzzleClock,
+ kPuzzleTimeMachine,
+ kPuzzleFisherman,
+ kPuzzleHiveMachine, // 15
+ kPuzzleHiveControl
+};
+
//////////////////////////////////////////////////////////////////////////
// Helpers
//////////////////////////////////////////////////////////////////////////
Commit: 6eb02714406591af325421f65286a85a08195301
https://github.com/scummvm/scummvm/commit/6eb02714406591af325421f65286a85a08195301
Author: Littleboy (littleboy at scummvm.org)
Date: 2021-05-17T15:37:18+02:00
Commit Message:
ASYLUM: Implement saveLoadWithSerializer() for most of the puzzles
Changed paths:
engines/asylum/puzzles/boardkeyhidesto.cpp
engines/asylum/puzzles/boardsalvation.cpp
engines/asylum/puzzles/boardyouth.cpp
engines/asylum/puzzles/clock.cpp
engines/asylum/puzzles/fisherman.cpp
engines/asylum/puzzles/hivecontrol.cpp
engines/asylum/puzzles/lock.cpp
engines/asylum/puzzles/morguedoor.cpp
engines/asylum/puzzles/pipes.cpp
engines/asylum/puzzles/puzzle11.cpp
engines/asylum/puzzles/puzzle11.h
engines/asylum/puzzles/timemachine.cpp
engines/asylum/puzzles/vcr.cpp
engines/asylum/puzzles/wheel.cpp
diff --git a/engines/asylum/puzzles/boardkeyhidesto.cpp b/engines/asylum/puzzles/boardkeyhidesto.cpp
index 0b61a06187..d0efd7ce71 100644
--- a/engines/asylum/puzzles/boardkeyhidesto.cpp
+++ b/engines/asylum/puzzles/boardkeyhidesto.cpp
@@ -53,7 +53,12 @@ PuzzleBoardKeyHidesTo::PuzzleBoardKeyHidesTo(AsylumEngine *engine) : PuzzleBoard
}
void PuzzleBoardKeyHidesTo::saveLoadWithSerializer(Common::Serializer &s) {
- error("[PuzzleBoardKeyHidesTo::saveLoadWithSerializer] Not implemented");
+ for (int32 i = 0; i < 12; i++)
+ s.syncAsUint32LE(_charUsed[i]);
+
+ s.syncBytes((byte *)&_solvedText, 28);
+
+ s.syncAsUint32LE(_position);
}
//////////////////////////////////////////////////////////////////////////
diff --git a/engines/asylum/puzzles/boardsalvation.cpp b/engines/asylum/puzzles/boardsalvation.cpp
index 7349e74f90..af0016cdae 100644
--- a/engines/asylum/puzzles/boardsalvation.cpp
+++ b/engines/asylum/puzzles/boardsalvation.cpp
@@ -58,7 +58,12 @@ PuzzleBoardSalvation::PuzzleBoardSalvation(AsylumEngine *engine) : PuzzleBoard(e
}
void PuzzleBoardSalvation::saveLoadWithSerializer(Common::Serializer &s) {
- error("[PuzzleBoardSalvation::saveLoadWithSerializer] Not implemented");
+ for (int32 i = 0; i < 9; i++)
+ s.syncAsUint32LE(_charUsed[i]);
+
+ s.syncBytes((byte *)&_solvedText, 20);
+
+ s.syncAsUint32LE(_position);
}
//////////////////////////////////////////////////////////////////////////
diff --git a/engines/asylum/puzzles/boardyouth.cpp b/engines/asylum/puzzles/boardyouth.cpp
index 36438146b4..69ff2cf915 100644
--- a/engines/asylum/puzzles/boardyouth.cpp
+++ b/engines/asylum/puzzles/boardyouth.cpp
@@ -51,7 +51,12 @@ PuzzleBoardYouth::PuzzleBoardYouth(AsylumEngine *engine) : PuzzleBoard(engine, p
}
void PuzzleBoardYouth::saveLoadWithSerializer(Common::Serializer &s) {
- error("[PuzzleBoardYouth::saveLoadWithSerializer] Not implemented");
+ for (int32 i = 0; i < 9; i++)
+ s.syncAsUint32LE(_charUsed[i]);
+
+ s.syncBytes((byte *)&_solvedText, 20);
+
+ s.syncAsUint32LE(_position);
}
//////////////////////////////////////////////////////////////////////////
diff --git a/engines/asylum/puzzles/clock.cpp b/engines/asylum/puzzles/clock.cpp
index 5b7c7aef6d..8687c8c61b 100644
--- a/engines/asylum/puzzles/clock.cpp
+++ b/engines/asylum/puzzles/clock.cpp
@@ -73,7 +73,8 @@ PuzzleClock::~PuzzleClock() {
}
void PuzzleClock::saveLoadWithSerializer(Common::Serializer &s) {
- error("[PuzzleClock::saveLoadWithSerializer] Not implemented");
+ s.syncAsSint32LE(_frameIndexes[2]);
+ s.syncAsSint32LE(_frameIndexes[1]);
}
//////////////////////////////////////////////////////////////////////////
diff --git a/engines/asylum/puzzles/fisherman.cpp b/engines/asylum/puzzles/fisherman.cpp
index 8c8267ebb8..fd30a2466c 100644
--- a/engines/asylum/puzzles/fisherman.cpp
+++ b/engines/asylum/puzzles/fisherman.cpp
@@ -58,7 +58,11 @@ PuzzleFisherman::~PuzzleFisherman() {
}
void PuzzleFisherman::saveLoadWithSerializer(Common::Serializer &s) {
- error("[PuzzleFisherman::saveLoadWithSerializer] Not implemented");
+ for (int i = 0; i < ARRAYSIZE(_state); i++)
+ s.syncAsSint32LE(_state[i]);
+
+ s.syncAsSint32LE(_dword_45AAD4);
+ s.syncAsSint32LE(_counter);
}
//////////////////////////////////////////////////////////////////////////
diff --git a/engines/asylum/puzzles/hivecontrol.cpp b/engines/asylum/puzzles/hivecontrol.cpp
index 737e4ec190..4d23057792 100644
--- a/engines/asylum/puzzles/hivecontrol.cpp
+++ b/engines/asylum/puzzles/hivecontrol.cpp
@@ -69,7 +69,10 @@ PuzzleHiveControl::~PuzzleHiveControl() {
}
void PuzzleHiveControl::saveLoadWithSerializer(Common::Serializer &s) {
- error("[PuzzleHiveControl::saveLoadWithSerializer] Not implemented");
+ s.skip(6 * 4 * 2);
+ warning("[PuzzleHiveControl::saveLoadWithSerializer] Not implemented");
+
+ s.syncAsSint32LE(_soundVolume);
}
void PuzzleHiveControl::reset() {
diff --git a/engines/asylum/puzzles/lock.cpp b/engines/asylum/puzzles/lock.cpp
index 6604294cb9..897888e8ee 100644
--- a/engines/asylum/puzzles/lock.cpp
+++ b/engines/asylum/puzzles/lock.cpp
@@ -52,7 +52,9 @@ PuzzleLock::~PuzzleLock() {
}
void PuzzleLock::saveLoadWithSerializer(Common::Serializer &s) {
- error("[PuzzleLock::saveLoadWithSerializer] Not implemented");
+ s.syncAsSint32LE(_frameIndexes[0]);
+ s.syncAsSint32LE(_frameIndexes[1]);
+ s.syncAsSint32LE(_frameIndexes[2]);
}
//////////////////////////////////////////////////////////////////////////
diff --git a/engines/asylum/puzzles/morguedoor.cpp b/engines/asylum/puzzles/morguedoor.cpp
index 26fed12271..7e92ee4eac 100644
--- a/engines/asylum/puzzles/morguedoor.cpp
+++ b/engines/asylum/puzzles/morguedoor.cpp
@@ -58,7 +58,25 @@ PuzzleMorgueDoor::~PuzzleMorgueDoor() {
}
void PuzzleMorgueDoor::saveLoadWithSerializer(Common::Serializer &s) {
- error("[PuzzleMorgueDoor::saveLoadWithSerializer] Not implemented");
+ s.syncAsSint32LE(_frameIndexes[kTopLeverOpened]);
+ s.syncAsSint32LE(_frameIndexes[kBottomLeverOpened]);
+ s.syncAsSint32LE(_frameIndexes[kBottomGear]);
+ s.syncAsSint32LE(_frameIndexes[kTopLever]);
+ s.syncAsSint32LE(_frameIndexes[kBottomLever]);
+ s.syncAsSint32LE(_frameIndexes[kTopRightLever]);
+ s.syncAsSint32LE(_frameIndexes[kTopSmallLever]);
+ s.syncAsSint32LE(_frameIndexes[kBottomSmallLever]);
+ s.syncAsSint32LE(_frameIndexes[kRightGear]);
+ s.syncAsSint32LE(_frameIndexes[kTopGear]);
+ s.syncAsSint32LE(_frameIndexes[kTopRightValve]);
+ s.syncAsSint32LE(_frameIndexes[kCenterValve]);
+
+ s.syncAsSint32LE(_data_45A9D8);
+ s.syncAsSint32LE(_data_45A9DC);
+ s.syncAsSint32LE(_flag6);
+ s.syncAsSint32LE(_flag7);
+ s.syncAsSint32LE(_topLeverOpen);
+ s.syncAsSint32LE(_bottomLeverOpen);
}
//////////////////////////////////////////////////////////////////////////
diff --git a/engines/asylum/puzzles/pipes.cpp b/engines/asylum/puzzles/pipes.cpp
index d75d0f44ca..124a572566 100644
--- a/engines/asylum/puzzles/pipes.cpp
+++ b/engines/asylum/puzzles/pipes.cpp
@@ -322,7 +322,8 @@ PuzzlePipes::~PuzzlePipes() {
}
void PuzzlePipes::saveLoadWithSerializer(Common::Serializer &s) {
- error("[PuzzlePipes::saveLoadWithSerializer] Not implemented");
+ warning("[PuzzlePipes::saveLoadWithSerializer] Not implemented");
+ s.skip(116);
}
//////////////////////////////////////////////////////////////////////////
diff --git a/engines/asylum/puzzles/puzzle11.cpp b/engines/asylum/puzzles/puzzle11.cpp
index ab4fea67c1..1e5b2c5b29 100644
--- a/engines/asylum/puzzles/puzzle11.cpp
+++ b/engines/asylum/puzzles/puzzle11.cpp
@@ -46,6 +46,25 @@ Puzzle11::Puzzle11(AsylumEngine *engine) : Puzzle(engine) {
Puzzle11::~Puzzle11() {
}
+void Puzzle11::saveLoadWithSerializer(Common::Serializer &s) {
+ s.syncAsUint32LE(_counter);
+
+ s.skip(8); // 2 int32 that do not seem to be used
+
+ s.syncAsUint32LE(_frameIndexes[0]);
+ s.syncAsUint32LE(_frameIndexes[3]);
+
+ warning("[Puzzle11::saveLoadWithSerializer] Not implemented");
+ s.skip(8);
+ s.syncAsUint32LE(_frameIndexes[2]);
+ s.skip(4);
+ s.syncAsUint32LE(_frameIndexes[1]);
+ s.syncAsUint32LE(_frameIndexes[4]);
+ s.skip(28);
+ s.syncAsUint32LE(_frameIndexes[5]);
+ s.syncAsUint32LE(_frameIndexes[6]);
+}
+
//////////////////////////////////////////////////////////////////////////
// Event Handling
//////////////////////////////////////////////////////////////////////////
diff --git a/engines/asylum/puzzles/puzzle11.h b/engines/asylum/puzzles/puzzle11.h
index c916c4a47e..b161dacdcb 100644
--- a/engines/asylum/puzzles/puzzle11.h
+++ b/engines/asylum/puzzles/puzzle11.h
@@ -34,6 +34,9 @@ public:
Puzzle11(AsylumEngine *engine);
~Puzzle11();
+ // Serializable
+ virtual void saveLoadWithSerializer(Common::Serializer &s);
+
private:
uint32 _counter;
uint32 _frameCounts[5];
diff --git a/engines/asylum/puzzles/timemachine.cpp b/engines/asylum/puzzles/timemachine.cpp
index 09978a7a97..d54118a1c7 100644
--- a/engines/asylum/puzzles/timemachine.cpp
+++ b/engines/asylum/puzzles/timemachine.cpp
@@ -77,7 +77,31 @@ PuzzleTimeMachine::~PuzzleTimeMachine() {
}
void PuzzleTimeMachine::saveLoadWithSerializer(Common::Serializer &s) {
- error("[PuzzleTimeMachine::saveLoadWithSerializer] Not implemented");
+ s.syncAsSint32LE(_frameIndexes[0]);
+ s.syncAsSint32LE(_frameIndexes[1]);
+ s.syncAsSint32LE(_frameIndexes[2]);
+ s.syncAsSint32LE(_frameIndexes[3]);
+ s.syncAsSint32LE(_frameIndexes[4]);
+
+ s.skip(4); // Unused
+
+ s.syncBytes((byte *)&_state, sizeof(_state));
+ s.skip(3); // We only use 5 elements i the state array
+
+ s.skip(5 * 4 * 2); // The original saves 4 points that are static data
+
+ s.syncAsSint32LE(_point.x);
+ s.syncAsSint32LE(_point.y);
+
+ for (int i = 0; i < 5; i++)
+ s.syncAsSint32LE(_frameIncrements[i]);
+
+ s.syncAsSint32LE(_currentFrameIndex);
+
+ s.syncAsSint32LE(_data_45AAA8);
+ s.syncAsSint32LE(_data_45AAAC);
+
+ s.syncAsSint32LE(_frameIndexes[5]);
}
//////////////////////////////////////////////////////////////////////////
diff --git a/engines/asylum/puzzles/vcr.cpp b/engines/asylum/puzzles/vcr.cpp
index 1b539e0e8b..e8feab089b 100644
--- a/engines/asylum/puzzles/vcr.cpp
+++ b/engines/asylum/puzzles/vcr.cpp
@@ -50,7 +50,22 @@ PuzzleVCR::~PuzzleVCR() {
}
void PuzzleVCR::saveLoadWithSerializer(Common::Serializer &s) {
- error("[PuzzleVCR::saveLoadWithSerializer] Not implemented");
+ s.syncAsUint32LE(_buttonsState[kPowerButton]);
+ s.syncAsUint32LE(_buttonsState[kRewindButton]);
+ s.syncAsUint32LE(_buttonsState[kPlayButton]);
+ s.syncAsUint32LE(_buttonsState[kStopButton]);
+
+ s.syncAsUint32LE(_holesState[kBlack]);
+ s.syncAsUint32LE(_holesState[kRed]);
+ s.syncAsUint32LE(_holesState[kYellow]);
+
+
+ s.syncAsUint32LE(_jacksState[kBlack]);
+ s.syncAsUint32LE(_jacksState[kRed]);
+ s.syncAsUint32LE(_jacksState[kYellow]);
+
+ s.syncAsUint32LE(_tvScreenFrameIndex);
+ s.syncAsUint32LE(_isAccomplished);
}
//////////////////////////////////////////////////////////////////////////
diff --git a/engines/asylum/puzzles/wheel.cpp b/engines/asylum/puzzles/wheel.cpp
index c746a553f7..02674c1cad 100644
--- a/engines/asylum/puzzles/wheel.cpp
+++ b/engines/asylum/puzzles/wheel.cpp
@@ -150,7 +150,7 @@ PuzzleWheel::~PuzzleWheel() {
}
void PuzzleWheel::saveLoadWithSerializer(Common::Serializer &s) {
- error("[PuzzleWheel::saveLoadWithSerializer] Not implemented");
+ s.syncAsSint32LE(_resourceIndex);
}
//////////////////////////////////////////////////////////////////////////
Commit: ba2237ae0bda35428d2303c438fc3e9916230d15
https://github.com/scummvm/scummvm/commit/ba2237ae0bda35428d2303c438fc3e9916230d15
Author: Littleboy (littleboy at scummvm.org)
Date: 2021-05-17T15:37:18+02:00
Commit Message:
ASYLUM: Implement saveLoadWithSerializer() for EncounterItem and EncounterVariables
Changed paths:
engines/asylum/resources/encounters.h
diff --git a/engines/asylum/resources/encounters.h b/engines/asylum/resources/encounters.h
index 74b4deb9a5..8c7a898c4f 100644
--- a/engines/asylum/resources/encounters.h
+++ b/engines/asylum/resources/encounters.h
@@ -33,7 +33,7 @@ namespace Asylum {
class AsylumEngine;
-struct EncounterItem {
+struct EncounterItem : public Common::Serializable {
int16 keywordIndex;
int16 field2;
ResourceId scriptResourceId;
@@ -47,13 +47,26 @@ struct EncounterItem {
memset(&keywords, 0, sizeof(keywords));
value = 0;
}
+
+ // Serializable
+ void saveLoadWithSerializer(Common::Serializer &s) {
+ s.syncAsSint16LE(keywordIndex);
+ s.syncAsSint16LE(field2);
+ s.syncAsSint32LE(scriptResourceId);
+
+ for (int32 i = 0; i < ARRAYSIZE(keywords); i++)
+ s.syncAsSint16LE(keywords[i]);
+
+ s.syncAsByte(value);
+ }
};
class EncounterVariables : public Common::Array<int16>, public Common::Serializable {
public:
// Serializable
void saveLoadWithSerializer(Common::Serializer &s) {
- error("[EncounterVariables::saveLoadWithSerializer] Not implemented!");
+ for (uint i = 0; i < _size; i++)
+ s.syncAsSint16LE(_storage[i]);
}
};
@@ -61,7 +74,8 @@ class EncounterItems : public Common::Array<EncounterItem>, public Common::Seria
public:
// Serializable
void saveLoadWithSerializer(Common::Serializer &s) {
- error("[EncounterItems::saveLoadWithSerializer] Not implemented!");
+ for (uint i = 0; i < _size; i++)
+ _storage[i].saveLoadWithSerializer(s);
}
};
Commit: f10091a61647cb008249dc7565554e923ff7d6ac
https://github.com/scummvm/scummvm/commit/f10091a61647cb008249dc7565554e923ff7d6ac
Author: Littleboy (littleboy at scummvm.org)
Date: 2021-05-17T15:37:18+02:00
Commit Message:
ASYLUM: Implement saving of script data
Changed paths:
engines/asylum/asylum.cpp
engines/asylum/resources/script.cpp
engines/asylum/resources/script.h
diff --git a/engines/asylum/asylum.cpp b/engines/asylum/asylum.cpp
index dc9cd43a60..06cebe1b39 100644
--- a/engines/asylum/asylum.cpp
+++ b/engines/asylum/asylum.cpp
@@ -530,7 +530,7 @@ void AsylumEngine::saveLoadWithSerializer(Common::Serializer &s) {
s.skip(8);
// Script queue
- _script->saveLoadWithSerializer(s);
+ _script->saveQueue(s);
// Shared data (the rest of it)
_data.saveLoadWithSerializer(s);
diff --git a/engines/asylum/resources/script.cpp b/engines/asylum/resources/script.cpp
index ff9a84db65..2fd83c2c3b 100644
--- a/engines/asylum/resources/script.cpp
+++ b/engines/asylum/resources/script.cpp
@@ -259,6 +259,16 @@ void ScriptManager::load(Common::SeekableReadStream *stream) {
}
}
+void ScriptManager::saveLoadWithSerializer(Common::Serializer &s) {
+ for (uint i = 0; i < _scripts.size(); i++)
+ _scripts[i].saveLoadWithSerializer(s);
+}
+
+// Save the script queue (in the original, it is part of the shared data)
+void ScriptManager::saveQueue(Common::Serializer &s) {
+ _queue.saveLoadWithSerializer(s);
+}
+
void ScriptManager::reset() {
// Reset script queue
resetQueue();
@@ -424,11 +434,6 @@ label_exit_processing:
return false;
}
-// Save the script queue
-void ScriptManager::saveLoadWithSerializer(Common::Serializer &s) {
- _queue.saveLoadWithSerializer(s);
-}
-
//////////////////////////////////////////////////////////////////////////
// Opcode Functions
//////////////////////////////////////////////////////////////////////////
diff --git a/engines/asylum/resources/script.h b/engines/asylum/resources/script.h
index 8c682b8329..062dbbd8ec 100644
--- a/engines/asylum/resources/script.h
+++ b/engines/asylum/resources/script.h
@@ -163,6 +163,7 @@ public:
// Serializable
void saveLoadWithSerializer(Common::Serializer &s);
+ void saveQueue(Common::Serializer &s);
private:
enum ObjectTransparency {
@@ -231,7 +232,7 @@ private:
//////////////////////////////////////////////////////////////////////////
// Scripts
//////////////////////////////////////////////////////////////////////////
- struct ScriptEntry {
+ struct ScriptEntry : public Common::Serializable {
int32 numLines; // Only set on the first line of each script
OpcodeType opcode;
int32 param1;
@@ -257,9 +258,23 @@ private:
param8 = 0;
param9 = 0;
}
+
+ void saveLoadWithSerializer(Common::Serializer &s) {
+ s.syncAsSint32LE(numLines);
+ s.syncAsSint32LE(opcode);
+ s.syncAsSint32LE(param1);
+ s.syncAsSint32LE(param2);
+ s.syncAsSint32LE(param3);
+ s.syncAsSint32LE(param4);
+ s.syncAsSint32LE(param5);
+ s.syncAsSint32LE(param6);
+ s.syncAsSint32LE(param7);
+ s.syncAsSint32LE(param8);
+ s.syncAsSint32LE(param9);
+ }
};
- struct Script {
+ struct Script : public Common::Serializable {
ScriptEntry commands[MAX_ACTION_COMMANDS];
int32 field_1BAC;
int32 field_1BB0;
@@ -270,6 +285,15 @@ private:
field_1BB0 = 0;
counter = 0;
}
+
+ void saveLoadWithSerializer(Common::Serializer &s) {
+ for (int32 i = 0; i < ARRAYSIZE(commands); i++)
+ commands[i].saveLoadWithSerializer(s);
+
+ s.syncAsSint32LE(field_1BAC);
+ s.syncAsSint32LE(field_1BB0);
+ s.syncAsSint32LE(counter);
+ }
};
//////////////////////////////////////////////////////////////////////////
Commit: 4b7e86f22613f87dd80310169e5d3755846ea830
https://github.com/scummvm/scummvm/commit/4b7e86f22613f87dd80310169e5d3755846ea830
Author: Littleboy (littleboy at scummvm.org)
Date: 2021-05-17T15:37:18+02:00
Commit Message:
ASYLUM: Fix problems with savegames in Menu
- Fix crash when trying to save before a scene is loaded
- Fix typo preventing the deletion of saved games
Changed paths:
engines/asylum/views/menu.cpp
diff --git a/engines/asylum/views/menu.cpp b/engines/asylum/views/menu.cpp
index e1f916ed99..f23e44b960 100644
--- a/engines/asylum/views/menu.cpp
+++ b/engines/asylum/views/menu.cpp
@@ -1762,6 +1762,7 @@ void Menu::clickSaveGame() {
if (cursor.x <= (350 + getText()->getWidth((char *)&text))
&& cursor.y >= y
&& cursor.y <= (y + 24)
+ && getScene()
&& getWorld()->chapter != kChapterNone) {
if (index + _startIndex < 25) {
getSaveLoad()->setIndex(index + _startIndex);
@@ -1787,7 +1788,7 @@ void Menu::clickDeleteGame() {
if (_dword_455C80) {
if (cursor.x < 247 || cursor.x > (247 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 1350)))
- || cursor.y < 273 || cursor.y > (247 + 24)) {
+ || cursor.y < 273 || cursor.y > (273 + 24)) {
if (cursor.x >= 369 && cursor.x <= (369 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 1351)))
&& cursor.y >= 273 && cursor.y <= (273 + 24))
_dword_455C80 = false;
Commit: c3f531c272c3d5cc232990108d907ca731a91d61
https://github.com/scummvm/scummvm/commit/c3f531c272c3d5cc232990108d907ca731a91d61
Author: Littleboy (littleboy at scummvm.org)
Date: 2021-05-17T15:37:19+02:00
Commit Message:
ASYLUM: Add padding when saving strings
Changed paths:
engines/asylum/system/savegame.cpp
diff --git a/engines/asylum/system/savegame.cpp b/engines/asylum/system/savegame.cpp
index 8e4fe79d35..c66ec71b2b 100644
--- a/engines/asylum/system/savegame.cpp
+++ b/engines/asylum/system/savegame.cpp
@@ -400,10 +400,19 @@ void Savegame::write(Common::OutSaveFile *file, uint32 val, Common::String descr
void Savegame::write(Common::OutSaveFile *file, Common::String val, uint32 strLength, Common::String description) const {
debugC(kDebugLevelSavegame, "[Savegame] Writing %s (of length %d): %s", description.c_str(), strLength, val.c_str());
+ if (val.size() > strLength)
+ error("[Savegame::write] Trying to save a string that is longer than the specified size (string size: %d, size: %d)", val.size(), strLength);
+
file->writeUint32LE(1);
file->writeUint32LE(strLength);
file->writeString(val);
+
+ // Add padding
+ if (val.size() < strLength) {
+ for (uint32 i = 0; i < (strLength - val.size()); i++)
+ file->writeByte(0);
+ }
}
void Savegame::write(Common::OutSaveFile *file, Common::Serializable *data, uint32 size, uint32 count, Common::String description) const {
Commit: 8032becd15d7e536c29866d0beb0cc7e99af2548
https://github.com/scummvm/scummvm/commit/8032becd15d7e536c29866d0beb0cc7e99af2548
Author: Littleboy (littleboy at scummvm.org)
Date: 2021-05-17T15:37:19+02:00
Commit Message:
ASYLUM: Only handle final version savegames until we can verify all savegames are compatible
Changed paths:
engines/asylum/system/savegame.cpp
diff --git a/engines/asylum/system/savegame.cpp b/engines/asylum/system/savegame.cpp
index c66ec71b2b..623e91757f 100644
--- a/engines/asylum/system/savegame.cpp
+++ b/engines/asylum/system/savegame.cpp
@@ -245,12 +245,16 @@ bool Savegame::isSavegamePresent(Common::String filename) const {
bool Savegame::readHeader(Common::InSaveFile *file) {
uint32 versionLength = read(file, "Version Length");
Common::String version = read(file, versionLength, "Version");
- /*uint32 build = */read(file, "Build");
+ uint32 build = read(file, "Build");
// Original does not do any version check
- // TODO check version to make sure we can read the data
- _valid = true;
+ // Until we can verify all versions have compatible savegames, we only handle the final patched version savegames
+ if (version != savegame_version || build != SAVEGAME_BUILD) {
+ _valid = false;
+ return false;
+ }
+ _valid = true;
return true;
}
Commit: 03cd0ddf566cd596ad6ff7b389ec98bec5fe3949
https://github.com/scummvm/scummvm/commit/03cd0ddf566cd596ad6ff7b389ec98bec5fe3949
Author: Littleboy (littleboy at scummvm.org)
Date: 2021-05-17T15:37:19+02:00
Commit Message:
ASYLUM: Fix loading of saved games
- Do not add more actors/objects/actions when loading data (the correct scene was loaded and contains the data already)
- Do not reset the script queue and empty the script array before loading the script list
Changed paths:
engines/asylum/resources/script.cpp
engines/asylum/resources/script.h
engines/asylum/resources/worldstats.cpp
engines/asylum/system/savegame.cpp
diff --git a/engines/asylum/resources/script.cpp b/engines/asylum/resources/script.cpp
index 2fd83c2c3b..b31cb2151e 100644
--- a/engines/asylum/resources/script.cpp
+++ b/engines/asylum/resources/script.cpp
@@ -269,12 +269,12 @@ void ScriptManager::saveQueue(Common::Serializer &s) {
_queue.saveLoadWithSerializer(s);
}
-void ScriptManager::reset() {
- // Reset script queue
- resetQueue();
-
- // Remove all scripts
- _scripts.clear();
+void ScriptManager::reset(uint32 count) {
+ // Create a set of empty scripts
+ for (uint32 i = 0; i < count; i++) {
+ Script script;
+ _scripts.push_back(script);
+ }
_done = false;
_exit = false;
diff --git a/engines/asylum/resources/script.h b/engines/asylum/resources/script.h
index 062dbbd8ec..d4390f471c 100644
--- a/engines/asylum/resources/script.h
+++ b/engines/asylum/resources/script.h
@@ -139,7 +139,7 @@ public:
/**
* Resets the queue and local variables
*/
- void reset();
+ void reset(uint32 count = 0);
/**
* Initialize the script element at actionIndex to
diff --git a/engines/asylum/resources/worldstats.cpp b/engines/asylum/resources/worldstats.cpp
index e2121367e4..c1529f8592 100644
--- a/engines/asylum/resources/worldstats.cpp
+++ b/engines/asylum/resources/worldstats.cpp
@@ -379,23 +379,15 @@ void WorldStats::saveLoadWithSerializer(Common::Serializer &s) {
//////////////////////////////////////////////////////////////////////////
// Objects
- for (uint32 i = 0; i < numObjects; i++) {
- if (s.isLoading())
- objects.push_back(new Object(_vm));
-
+ for (uint32 i = 0; i < numObjects; i++)
objects[i]->saveLoadWithSerializer(s);
- }
s.skip((OBJECTS_MAX_COUNT - numObjects) * OBJECTS_SIZE);
//////////////////////////////////////////////////////////////////////////
// Actors
- for (uint32 i = 0; i < numActors; i++) {
- if (s.isLoading())
- actors.push_back(new Actor(_vm, i));
-
+ for (uint32 i = 0; i < numActors; i++)
actors[i]->saveLoadWithSerializer(s);
- }
s.skip((ACTORS_MAX_COUNT - numActors) * ACTORS_SIZE);
@@ -417,12 +409,8 @@ void WorldStats::saveLoadWithSerializer(Common::Serializer &s) {
//////////////////////////////////////////////////////////////////////////
// Read actions
- for (uint32 i = 0; i < numActions; i++) {
- if (s.isLoading())
- actions.push_back(new ActionArea());
-
+ for (uint32 i = 0; i < numActions; i++)
actions[i]->saveLoadWithSerializer(s);
- }
s.skip((ACTIONS_MAX_COUNT - numActions) * ACTIONS_SIZE);
diff --git a/engines/asylum/system/savegame.cpp b/engines/asylum/system/savegame.cpp
index 623e91757f..6aa48ed9e7 100644
--- a/engines/asylum/system/savegame.cpp
+++ b/engines/asylum/system/savegame.cpp
@@ -287,7 +287,7 @@ bool Savegame::loadData(Common::String filename) {
read(file, getEncounter()->items(), 109, getEncounter()->items()->size(), "Encounter Data");
read(file, getEncounter()->variables(), 2, getEncounter()->variables()->size(), "Encounter Variables");
- getScript()->reset();
+ getScript()->reset(getWorld()->numScripts);
if (getWorld()->numScripts)
read(file, getScript(), 7096, (uint32)getWorld()->numScripts, "Action Lists");
Commit: 72d5a60e3bfb610b337fed3a834d427c9486de69
https://github.com/scummvm/scummvm/commit/72d5a60e3bfb610b337fed3a834d427c9486de69
Author: Littleboy (littleboy at scummvm.org)
Date: 2021-05-17T15:37:19+02:00
Commit Message:
ASYLUM: Fix regression in loading of scenes from the console
Changed paths:
engines/asylum/asylum.cpp
diff --git a/engines/asylum/asylum.cpp b/engines/asylum/asylum.cpp
index 06cebe1b39..14f84fd6fb 100644
--- a/engines/asylum/asylum.cpp
+++ b/engines/asylum/asylum.cpp
@@ -381,16 +381,11 @@ void AsylumEngine::processDelayedEvents() {
// check for a delayed scene change
if (_delayedSceneIndex != kResourcePackInvalid && isGameFlagNotSet(kGameFlagScriptProcessing)) {
- if (!_scene)
- error("[AsylumEngine::processDelayedEvents] Subsystems not initialized properly!");
-
ResourcePackId sceneIndex = _delayedSceneIndex;
-
- // Reset delayed scene
_delayedSceneIndex = kResourcePackInvalid;
- _scene->getActor(0)->updateStatus(kActorStatusDisabled);
- _script->reset();
+ // Reset script queue
+ _script->resetQueue();
_sound->stopMusic();
_sound->stopAll();
Commit: 46d189ec9f24183807b19501060379d99d07fd49
https://github.com/scummvm/scummvm/commit/46d189ec9f24183807b19501060379d99d07fd49
Author: Littleboy (littleboy at scummvm.org)
Date: 2021-05-17T15:37:19+02:00
Commit Message:
ASYLUM: Add more error handling to script opcodes manipulating objects
Changed paths:
engines/asylum/resources/script.cpp
diff --git a/engines/asylum/resources/script.cpp b/engines/asylum/resources/script.cpp
index b31cb2151e..8c50d143b9 100644
--- a/engines/asylum/resources/script.cpp
+++ b/engines/asylum/resources/script.cpp
@@ -503,6 +503,8 @@ END_OPCODE
// Opcode 0x07
IMPLEMENT_OPCODE(PlayAnimation)
Object *object = getWorld()->getObjectById((ObjectId)cmd->param1);
+ if (!object)
+ error("[ScriptManager::opcodePlayAnimation] Cannot find specified object (id: %d)", cmd->param1);
if (cmd->param2 == 2) {
if (object->checkFlags()) {
@@ -516,7 +518,7 @@ IMPLEMENT_OPCODE(PlayAnimation)
// Update flags
if (cmd->param4) {
object->flags &= ~kObjectFlag10E38;
- object->flags |= kObjectFlag20;
+ object->flags |= kObjectFlag20;
} else if (cmd->param3) {
object->flags &= ~kObjectFlag10E38;
object->flags |= kObjectFlag10000;
@@ -633,6 +635,8 @@ END_OPCODE
// Opcode 0x0F
IMPLEMENT_OPCODE(EnableObjects)
Object *object = getWorld()->getObjectById((ObjectId)cmd->param1);
+ if (!object)
+ error("[ScriptManager::opcodeEnableObjects] Cannot find specified object (id: %d)", cmd->param1);
if (!_currentScript->counter && getWorld()->chapter != 13)
_vm->sound()->playSound(cmd->param3 ? MAKE_RESOURCE(kResourcePackSound, 6) : MAKE_RESOURCE(kResourcePackSound, 1));
@@ -665,6 +669,8 @@ IMPLEMENT_OPCODE(RemoveObject)
return;
Object *object = getWorld()->getObjectById((ObjectId)cmd->param1);
+ if (!object)
+ error("[ScriptManager::opcodeRemoveObject] Cannot find specified object (id: %d)", cmd->param1);
object->disableAndRemoveFromQueue();
END_OPCODE
@@ -735,6 +741,8 @@ END_OPCODE
// Opcode 0x16
IMPLEMENT_OPCODE(ResetAnimation)
Object *object = getWorld()->getObjectById((ObjectId)cmd->param1);
+ if (!object)
+ error("[ScriptManager::opcodeResetAnimation] Cannot find specified object (id: %d)", cmd->param1);
if (object->flags & kObjectFlag10000)
object->setFrameIndex(object->getFrameCount() - 1);
@@ -746,6 +754,8 @@ END_OPCODE
// Opcode 0x17
IMPLEMENT_OPCODE(DisableObject)
Object *object = getWorld()->getObjectById((ObjectId)cmd->param1);
+ if (!object)
+ error("[ScriptManager::opcodeDisableObject] Cannot find specified object (id: %d)", cmd->param1);
object->disable();
END_OPCODE
Commit: 919afab0bfab47e85eff885ddf010919be80eaff
https://github.com/scummvm/scummvm/commit/919afab0bfab47e85eff885ddf010919be80eaff
Author: Littleboy (littleboy at scummvm.org)
Date: 2021-05-17T15:37:19+02:00
Commit Message:
ASYLUM: Fix running of encounters from the debug console
- Pass proper data to the Encounter::run() function
- Add encounter data for the first 3 scenes
Changed paths:
engines/asylum/console.cpp
engines/asylum/resources/script.cpp
diff --git a/engines/asylum/console.cpp b/engines/asylum/console.cpp
index f74b823185..18b0ad9929 100644
--- a/engines/asylum/console.cpp
+++ b/engines/asylum/console.cpp
@@ -71,6 +71,91 @@ const ResourcePackId puzzleToScenes[17] = {
kResourcePackHive // Hive Control
};
+static const struct EncounterData {
+ int32 index;
+ uint32 objectId1;
+ uint32 objectId2;
+ ActorIndex actorIndex;
+} encounterData[13][20] = {
+ // TowerCells
+ {
+ { 0, kObjectPreAlphaNut, kObjectPreAlphaNut, kActorMax},
+ { 1, kObjectPreAlphaNut2, kObjectPreAlphaNut2, kActorMax},
+ { 2, kObjectRocker, kObjectRocker, kActorMax},
+ {-1, kObjectNone, kObjectNone, kActorMax}
+ },
+ // InnocentAbandoned
+ {
+ { 3, 1072, 1091, kActorMax},
+ { 4, 1061, 1072, kActorMax},
+ { 5, 1200, 1199, kActorMax},
+ { 7, 1105, 991, kActorMax},
+ { 9, 1012, 1011, kActorMax},
+ {10, 993, 993, kActorMax},
+ {11, 1013, 1013, kActorMax},
+ {12, 1082, 1084, kActorMax},
+ {13, 1001, 1001, kActorMax},
+ {14, 1587, 2280, kActorMax},
+ {74, 2992, 2992, kActorMax},
+ {76, 2990, 2990, kActorMax},
+ {77, 2990, 2990, kActorMax},
+ {78, 2990, 2990, kActorMax},
+ {-1, kObjectNone, kObjectNone, kActorMax}
+ },
+ // CourtyardAndChapel
+ {
+ {36, 820, 820, kActorMax},
+ {37, 863, 863, kActorMax},
+ {38, 862, 1038, kActorMax},
+ {39, 844, 844, kActorMax},
+ {40, 845, 845, kActorMax},
+ {41, 846, 846, kActorMax},
+ {43, 873, 801, kActorMax},
+ {-1, kObjectNone, kObjectNone, kActorMax}
+ },
+ // CircusOfFools
+ {
+ {-1, kObjectNone, kObjectNone, kActorMax}
+ },
+ // Laboratory
+ {
+ {-1, kObjectNone, kObjectNone, kActorMax}
+ },
+ // Hive
+ {
+ {-1, kObjectNone, kObjectNone, kActorMax}
+ },
+ // MorgueAndCemetery
+ {
+ {-1, kObjectNone, kObjectNone, kActorMax}
+ },
+ // LostVillage
+ {
+ {-1, kObjectNone, kObjectNone, kActorMax}
+ },
+ // Gauntlet
+ {
+ {-1, kObjectNone, kObjectNone, kActorMax}
+ },
+ // Mansion
+ {
+ {-1, kObjectNone, kObjectNone, kActorMax}
+ },
+ // Cave
+ {
+ {-1, kObjectNone, kObjectNone, kActorMax}
+ },
+ // Maze
+ {
+ {-1, kObjectNone, kObjectNone, kActorMax}
+ },
+ // MorgansLastGame
+ {
+ {-1, kObjectNone, kObjectNone, kActorMax}
+ }
+};
+
+
Console::Console(AsylumEngine *engine) : _vm(engine) {
// Commands
DCmd_Register("help", WRAP_METHOD(Console, cmdHelp));
@@ -425,17 +510,35 @@ bool Console::cmdRunEncounter(int32 argc, const char **argv) {
return true;
}
- int32 index = atoi(argv[1]);
+ // Check that we are inside a scene
+ if (!getScene()) {
+ DebugPrintf("[Error] Cannot run an encounter outside of a scene\n");
+ return true;
+ }
// Check index is valid
+ int32 index = atoi(argv[1]);
if (index < 0 || index >= (int32)_vm->encounter()->_items.size()) {
DebugPrintf("[Error] Invalid index (was: %d - valid: [0-%d])\n", index, _vm->encounter()->_items.size() - 1);
return true;
}
- // Line: 12/15 :: 0x25 (1, 1584, 1584, 0, 0, 0, 0, 0, 0) // First Encounter
- // TODO update with array of valid objects
- _vm->encounter()->run(index, kObjectNone, kObjectNone, kActorMax);
+ // Get the encounter data
+ EncounterData *data = NULL;
+ for (data = (EncounterData *)&encounterData[getScene()->getPackId() - 5]; data->index != -1; data++) {
+ if (data->index == index)
+ break;
+ }
+
+ if (data->index == -1) {
+ DebugPrintf("[Error] No encounter data for this index (index: %d)\n", index);
+ return true;
+ }
+
+ _vm->encounter()->run(index,
+ (ObjectId)data->objectId1,
+ (ObjectId)data->objectId2,
+ data->actorIndex);
return false;
}
diff --git a/engines/asylum/resources/script.cpp b/engines/asylum/resources/script.cpp
index 8c50d143b9..3e62e681e6 100644
--- a/engines/asylum/resources/script.cpp
+++ b/engines/asylum/resources/script.cpp
@@ -249,6 +249,12 @@ void ScriptManager::load(Common::SeekableReadStream *stream) {
command.param9 = stream->readSint32LE();
script.commands[c] = command;
+
+#ifdef DEBUG
+ // Output encounter info
+ if (command.opcode == kOpcodeRunEncounter)
+ debugC(kDebugLevelEncounter, "%d, %d, %d, %d", command.param1, command.param2, command.param3, command.param4);*/
+#endif
}
script.field_1BAC = stream->readSint32LE();
Commit: 8f2a9464e01854ec9c0f71f7989c47694fa17e45
https://github.com/scummvm/scummvm/commit/8f2a9464e01854ec9c0f71f7989c47694fa17e45
Author: Littleboy (littleboy at scummvm.org)
Date: 2021-05-17T15:37:19+02:00
Commit Message:
ASYLUM: Fix initialization of second portrait in Encounter::initPortraits()
- Rename keyword start index member
Changed paths:
engines/asylum/resources/encounters.cpp
engines/asylum/resources/encounters.h
engines/asylum/staticres.h
diff --git a/engines/asylum/resources/encounters.cpp b/engines/asylum/resources/encounters.cpp
index a0ece256ed..6b579451c7 100644
--- a/engines/asylum/resources/encounters.cpp
+++ b/engines/asylum/resources/encounters.cpp
@@ -66,7 +66,7 @@ Encounter::Encounter(AsylumEngine *engine) : _vm(engine),
_data_455BE8 = false;
_data_455BF0 = 0;
_data_455BF4 = 0;
- _data_455BF8 = 0;
+ _keywordStartIndex = 0;
load();
}
@@ -185,8 +185,8 @@ void Encounter::initPortraits() {
error("[Encounter::initPortraits] No portrait 2 for this encounter!");
_portrait2.frameIndex = 0;
- _portrait2.frameCount = GraphicResource::getFrameCount(_vm, _portrait1.resourceId);
- _portrait2.rect = GraphicResource::getFrameRect(_vm, _portrait1.resourceId, 0);
+ _portrait2.frameCount = GraphicResource::getFrameCount(_vm, _portrait2.resourceId);
+ _portrait2.rect = GraphicResource::getFrameRect(_vm, _portrait2.resourceId, 0);
_portrait2.transTableNum = 0;
_portrait2.transTableMax = 0;
_portrait2.speech0 = 0;
@@ -323,7 +323,7 @@ bool Encounter::init() {
_rectIndex = -1;
_value1 = 0;
_data_455BF4 = 0;
- _data_455BF8 = 0;
+ _keywordStartIndex = 0;
_data_455B14 = -1;
getSpeech()->resetTextData();
@@ -417,14 +417,14 @@ bool Encounter::update() {
if (!getSharedData()->getMatteBarHeight() && doScript && _flag4) {
if (!setupSpeech(id))
- runScript();
+ runScript();
}
}
// Redraw screen
if (!getSharedData()->getFlag(kFlagRedraw)) {
if (updateScreen())
- return true;
+ return true;
getSharedData()->setFlag(kFlagRedraw, true);
}
@@ -545,7 +545,7 @@ int32 Encounter::getKeywordIndex() {
Common::Point mousePos = getCursor()->position();
int16 counter = 0;
- for (uint i = _data_455BF8; i < ARRAYSIZE(_keywordIndexes); i++) {
+ for (uint i = _keywordStartIndex; i < ARRAYSIZE(_keywordIndexes); i++) {
int32 index = _keywordIndexes[i];
if (counter / 3 >= 8)
@@ -555,7 +555,7 @@ int32 Encounter::getKeywordIndex() {
int32 x = _drawingStructs[0].point1.x + 144 * (counter % 3) + _point.x + (counter % 3) + _portrait1.rect.width() + 15;
int32 y = 16 * counter / 3 + _point.y + 5;
- if (mousePos.x >= x && mousePos.x <= (x + getText()->getWidth(MAKE_RESOURCE(kResourcePackShared, 3681)))
+ if (mousePos.x >= x && mousePos.x <= (x + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 3681 + index)))
&& mousePos.y >= y && mousePos.y <= (y + 16))
return i;
@@ -575,7 +575,7 @@ void Encounter::choose(int32 index) {
_value1 = (_item->keywords[index] & KEYWORD_MASK);
setVariable(1, _value1);
- if (strcmp("Goodbye", getText()->get(MAKE_RESOURCE(kResourcePackShared, 3681 + _value1))))
+ if (strcmp("Goodbye", getText()->get(MAKE_RESOURCE(kResourcePackText, 3681 + index))))
if (_index != 79)
BYTE1(_item->keywords[index]) |= 0x20;
@@ -602,7 +602,7 @@ bool Encounter::checkKeywords() const {
}
bool Encounter::checkKeywords2() const {
- for (uint32 i = 0; i < _data_455BF8; i++) {
+ for (uint32 i = 0; i < _keywordStartIndex; i++) {
int32 index = _keywordIndexes[i];
if (index < 0)
@@ -636,7 +636,7 @@ void Encounter::updateFromRect(int32 rectIndex) {
return;
uint32 counter = 0;
- for (uint32 i = _data_455BF8 + 1; i < ARRAYSIZE(_keywordIndexes); i++) {
+ for (uint32 i = _keywordStartIndex + 1; i < ARRAYSIZE(_keywordIndexes); i++) {
int32 index = _keywordIndexes[i];
if (counter == 3)
@@ -646,14 +646,14 @@ void Encounter::updateFromRect(int32 rectIndex) {
continue;
if ((_item->keywords[index] & KEYWORD_MASK) && (BYTE1(_item->keywords[index]) & 0x80)) {
- _data_455BF8 = i;
+ _keywordStartIndex = i;
++counter;
}
}
}
} else {
uint32 counter = 0;
- for (int32 i = (int32)_data_455BF8 - 1; i > -1; i--) {
+ for (int32 i = (int32)_keywordStartIndex - 1; i > -1; i--) {
int32 index = _keywordIndexes[i];
if (counter == 3)
@@ -663,7 +663,7 @@ void Encounter::updateFromRect(int32 rectIndex) {
continue;
if ((_item->keywords[index] & KEYWORD_MASK) && (BYTE1(_item->keywords[index]) & 0x80)) {
- _data_455BF8 = (uint32)i;
+ _keywordStartIndex = (uint32)i;
++counter;
}
}
@@ -1054,21 +1054,20 @@ void Encounter::drawStructs() {
void Encounter::drawDialog() {
getText()->loadFont(getWorld()->font1);
- if (_data_455BF8 >= 50)
+ if (_keywordStartIndex >= 50)
return;
int16 counter = 0;
- for (uint32 i = _data_455BF8; i < ARRAYSIZE(_keywordIndexes); i++) {
+ for (uint32 i = _keywordStartIndex; i < ARRAYSIZE(_keywordIndexes); i++) {
if (counter / 3 >= 8)
return;
- int32 index = _keywordIndexes[i];
-
- if (index < 0)
+ int32 keywordIndex = _keywordIndexes[i];
+ if (keywordIndex < 0)
continue;
- if ((_item->keywords[index] & KEYWORD_MASK) > 0 && (BYTE1(_keywordIndexes[i]) & 0x80)) {
+ if ((_item->keywords[keywordIndex] & KEYWORD_MASK) > 0 && (BYTE1(_keywordIndexes[i]) & 0x80)) {
if (BYTE1(_keywordIndexes[i]) & 0x20)
getText()->loadFont(getWorld()->font2);
@@ -1078,11 +1077,11 @@ void Encounter::drawDialog() {
Common::Point coords(_drawingStructs[0].point1.y + 144 * (counter % 3) + _point.x + (counter % 3) + _portrait1.rect.width() + 15,
_point.y + (int16)(16 * counter / 3));
- if (getKeywordIndex() == index)
- getScreen()->fillRect(coords.x - 1, coords.y + 5, getText()->getWidth(MAKE_RESOURCE(kResourcePackShared, 3681)), 18, 0);
+ if (getKeywordIndex() == keywordIndex)
+ getScreen()->fillRect(coords.x - 1, coords.y + 5, getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 3681 + keywordIndex)), 18, 0);
getText()->setPosition(coords);
- getText()->draw(MAKE_RESOURCE(kResourcePackShared, 3681));
+ getText()->draw(MAKE_RESOURCE(kResourcePackText, 3681 + keywordIndex));
++counter;
_data_455B14 = i;
@@ -1346,17 +1345,17 @@ bool Encounter::updateScreen() {
if (!drawBackground()) {
_data_455BD0 = false;
- return false;
- }
+ return false;
+ }
if (!drawPortraits()) {
_data_455BD0 = false;
- if (_data_455BD4)
- drawStructs();
+ if (_data_455BD4)
+ drawStructs();
- return false;
- }
+ return false;
+ }
if (_data_455BD0) {
diff --git a/engines/asylum/resources/encounters.h b/engines/asylum/resources/encounters.h
index 8c7a898c4f..1490aa07bb 100644
--- a/engines/asylum/resources/encounters.h
+++ b/engines/asylum/resources/encounters.h
@@ -190,7 +190,7 @@ private:
bool _data_455BE8;
int16 _data_455BF0;
uint32 _data_455BF4;
- uint32 _data_455BF8;
+ uint32 _keywordStartIndex;
// Internal flags
bool _flag1;
diff --git a/engines/asylum/staticres.h b/engines/asylum/staticres.h
index 1f6bc94030..ea65efecb5 100644
--- a/engines/asylum/staticres.h
+++ b/engines/asylum/staticres.h
@@ -60,14 +60,14 @@ const uint speechIndexRandom[20] = { 5, 5, 10, 8, 6, 4, 3, 6, 4, 4, 4,
/** Encounter indexes */
const int encounterPortrait1Index[16] = {-1, 36, 20, 31, 1, 37, 7, 0, 0, 0, 1, 2, 3, 0, 0, 0};
-const int encounterPortrait2Index[80] = {50, 51, 52, 33, 34, 35, 36, 37, 38, 39,
- 40, 41, 48, 49, 50, 1, 2, 3, 1, 2,
- 3, 4, 5, 6, 7, 8, 9, 16, 17, 18,
- 19, 20, 25, 32, 33, 34, 35, 36, 37, 38,
- 39, 40, 41, 48, 2, 0, 3, 4, 5, 6,
- 7, 8, 9, 16, 17, 18, 19, 20, 21, 22,
- 23, 24, 25, 32, 33, 34, 0, 1, 2, 3,
- 4, 5, 6, 53, 51, 52, 53, 54, 55, 54};
+const int encounterPortrait2Index[80] = {32, 33, 34, 21, 22, 23, 24, 25, 26, 27,
+ 28, 29, 30, 31, 32, 1, 2, 3, 1, 2,
+ 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,
+ 13, 14, 19, 20, 21, 22, 23, 24, 25, 26,
+ 27, 28, 29, 30, 2, 0, 3, 4, 5, 6,
+ 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
+ 17, 18, 19, 20, 21, 22, 0, 1, 2, 3,
+ 4, 5, 6, 35, 33, 34, 35, 36, 37, 36};
// Delta array for points
static Common::Point deltaPointsArray[8] = {
Commit: 4113ef8255f23a879880c227b4408ece4d1b1857
https://github.com/scummvm/scummvm/commit/4113ef8255f23a879880c227b4408ece4d1b1857
Author: Alex Bevilacqua (alexbevi at gmail.com)
Date: 2021-05-17T15:37:20+02:00
Commit Message:
ASYLUM: Silence an analysis warning by adding a virtual destructor to SharedData
Changed paths:
engines/asylum/resources/data.h
diff --git a/engines/asylum/resources/data.h b/engines/asylum/resources/data.h
index 91104d5ab2..ea3edf3fd5 100644
--- a/engines/asylum/resources/data.h
+++ b/engines/asylum/resources/data.h
@@ -120,6 +120,7 @@ enum GlobalFlag {
class SharedData : public Common::Serializable {
public:
SharedData();
+ virtual ~SharedData() {};
// Public variables
int32 cdNumber;
Commit: fa9083c2503a8820921dbcd7c76fc7c1a9021fcb
https://github.com/scummvm/scummvm/commit/fa9083c2503a8820921dbcd7c76fc7c1a9021fcb
Author: Littleboy (littleboy at scummvm.org)
Date: 2021-05-17T15:37:20+02:00
Commit Message:
ASYLUM: Implement missing priority code in Scene::processUpdateList()
This allows some scenes to progress further
Changed paths:
engines/asylum/views/scene.cpp
diff --git a/engines/asylum/views/scene.cpp b/engines/asylum/views/scene.cpp
index a918e71b9c..f7f5ec7b18 100644
--- a/engines/asylum/views/scene.cpp
+++ b/engines/asylum/views/scene.cpp
@@ -2632,15 +2632,38 @@ void Scene::processUpdateList() {
// Go through the list from the end
if (_updateList.size() > 1) {
- for (int i = _ws->actors.size() - 1; i >= 0; --i) {
- Actor *actor = _ws->actors[i];
+ for (int i = _updateList.size() - 1; i >= 0; --i) {
+ // Get the actor
+ Actor *actor1 = getActor(_updateList[i].index);
// Skip hidden actors
- if (!actor->isVisible())
+ if (!actor1->isVisible())
continue;
- if (actor->getField944() != 1 && actor->getField944() != 4) {
- error("[Scene::processUpdateList] list update not implemented!");
+ if (actor1->getField944() != 1 && actor1->getField944() != 4) {
+ // Process all previous actors
+ if (i > 0) {
+ for (int j = i - 1; j >= 0; --j) {
+ Actor *actor2 = getActor(_updateList[j].index);
+
+ if (actor2->getField944() != 1 && actor2->getField944() != 4) {
+
+ // Process priorities
+ if (actor2->getPriority() <= actor1->getPriority()) {
+ if (rectIntersect(actor1->getPoint1()->x,
+ actor1->getPoint1()->y,
+ actor1->getPoint1()->x + actor1->getBoundingRect()->right,
+ actor1->getPoint1()->y + actor1->getBoundingRect()->bottom,
+ actor2->getPoint1()->x,
+ actor2->getPoint1()->y,
+ actor2->getPoint1()->x + actor2->getBoundingRect()->right,
+ actor2->getPoint1()->y + actor2->getBoundingRect()->bottom)) {
+ actor2->setPriority(actor1->getPriority() + 1);
+ }
+ }
+ }
+ }
+ }
}
}
}
Commit: b67ba25820dc9104b1f720d2d8a1cb296f5f1498
https://github.com/scummvm/scummvm/commit/b67ba25820dc9104b1f720d2d8a1cb296f5f1498
Author: Littleboy (littleboy at scummvm.org)
Date: 2021-05-17T15:37:20+02:00
Commit Message:
ASYLUM: Add missing call to Special::run() in Actor::update()
Changed paths:
engines/asylum/resources/actor.cpp
diff --git a/engines/asylum/resources/actor.cpp b/engines/asylum/resources/actor.cpp
index 66c9c004bb..ee0dc6f177 100644
--- a/engines/asylum/resources/actor.cpp
+++ b/engines/asylum/resources/actor.cpp
@@ -689,7 +689,7 @@ void Actor::update() {
setVolume();
if (_index != getSharedData()->getPlayerIndex() && getWorld()->chapter != kChapter9)
- error("[Actor::update] call to actor sound functions missing!");
+ getSpecial()->run(NULL, _index);
updateDirection();
Commit: ee40059ed75c0e9c7573946e5123912fabbc6319
https://github.com/scummvm/scummvm/commit/ee40059ed75c0e9c7573946e5123912fabbc6319
Author: Littleboy (littleboy at scummvm.org)
Date: 2021-05-17T15:37:20+02:00
Commit Message:
ASYLUM: Fix a bug in ScriptManager::opcodeJumpIfActorCoordinates()
Changed paths:
engines/asylum/resources/script.cpp
diff --git a/engines/asylum/resources/script.cpp b/engines/asylum/resources/script.cpp
index 3e62e681e6..8cf68d9f38 100644
--- a/engines/asylum/resources/script.cpp
+++ b/engines/asylum/resources/script.cpp
@@ -734,7 +734,7 @@ IMPLEMENT_OPCODE(JumpIfActorCoordinates)
Actor *actor = getScene()->getActor(cmd->param1);
if ((actor->getPoint1()->x + actor->getPoint2()->x) != cmd->param2 || (actor->getPoint1()->y + actor->getPoint2()->y) != cmd->param3)
- _processNextEntry = (bool)cmd->param4;
+ _currentQueueEntry->currentLine = cmd->param4;
END_OPCODE
//////////////////////////////////////////////////////////////////////////
Commit: 46f5eb05c36a6ae6502ad9106e776a0c681bc2c9
https://github.com/scummvm/scummvm/commit/46f5eb05c36a6ae6502ad9106e776a0c681bc2c9
Author: Littleboy (littleboy at scummvm.org)
Date: 2021-05-17T15:37:20+02:00
Commit Message:
ASYLUM: Implement slightly better switching of scenes through the debugger
Changed paths:
engines/asylum/asylum.cpp
diff --git a/engines/asylum/asylum.cpp b/engines/asylum/asylum.cpp
index 14f84fd6fb..2029e9e2df 100644
--- a/engines/asylum/asylum.cpp
+++ b/engines/asylum/asylum.cpp
@@ -384,12 +384,21 @@ void AsylumEngine::processDelayedEvents() {
ResourcePackId sceneIndex = _delayedSceneIndex;
_delayedSceneIndex = kResourcePackInvalid;
- // Reset script queue
+ // Reset actor and script queue
_script->resetQueue();
+ _script->reset();
+ if (_scene)
+ _scene->getActor(0)->updateStatus(kActorStatusDisabled);
+ // Fade screen to black
+ _screen->paletteFade(0, 75, 8);
+ _screen->clear();
+
+ // Stop all sounds & music
_sound->stopMusic();
_sound->stopAll();
+ // Switch the scene
switchScene(sceneIndex);
}
Commit: 734afc0bbc185b25442406634c446e3bc7bdff8f
https://github.com/scummvm/scummvm/commit/734afc0bbc185b25442406634c446e3bc7bdff8f
Author: Littleboy (littleboy at scummvm.org)
Date: 2021-05-17T15:37:20+02:00
Commit Message:
ASYLUM: Change kResourceInvalid to be -1
Changed paths:
engines/asylum/shared.h
diff --git a/engines/asylum/shared.h b/engines/asylum/shared.h
index 3741c9d600..8a6d66e893 100644
--- a/engines/asylum/shared.h
+++ b/engines/asylum/shared.h
@@ -240,8 +240,8 @@ enum ResourcePackId {
typedef int ResourceId;
enum ResourcesId {
- kResourceNone = 0,
- kResourceInvalid = 0xFFFFFFFF
+ kResourceInvalid = -1,
+ kResourceNone = 0
};
#define kMusicStopped -666
Commit: d19ec5773227a804d5a73f1eb5107a7aec73f57a
https://github.com/scummvm/scummvm/commit/d19ec5773227a804d5a73f1eb5107a7aec73f57a
Author: Littleboy (littleboy at scummvm.org)
Date: 2021-05-17T15:37:20+02:00
Commit Message:
ASYLUM: Fix memory leak in ResourceManager
The ResourceManager was never deleting the file data buffers, only removing the entries from the cache.
Thanks to digitall for the patch.
Changed paths:
engines/asylum/respack.cpp
engines/asylum/respack.h
diff --git a/engines/asylum/respack.cpp b/engines/asylum/respack.cpp
index 84a9282799..a09c596bf1 100644
--- a/engines/asylum/respack.cpp
+++ b/engines/asylum/respack.cpp
@@ -31,6 +31,13 @@ namespace Asylum {
ResourceManager::ResourceManager() : _cdNumber(-1), _musicPackId(kResourcePackInvalid) {
}
+ResourceManager::~ResourceManager() {
+ for (ResourceCache::const_iterator it = _resources.begin(); it != _resources.end(); it++)
+ delete it->_value;
+ for (ResourceCache::const_iterator it = _music.begin(); it != _music.end(); it++)
+ delete it->_value;
+}
+
ResourceEntry *ResourceManager::get(ResourceId id) {
ResourcePackId packId = RESOURCE_PACK(id);
uint16 index = RESOURCE_INDEX(id);
@@ -68,11 +75,15 @@ ResourceEntry *ResourceManager::get(ResourceId id) {
}
void ResourceManager::unload(ResourcePackId id) {
- if (_resources.contains(id))
+ if (_resources.contains(id)) {
+ delete _resources.getVal(id);
_resources.erase(id);
+ }
- if (_music.contains(id))
+ if (_music.contains(id)) {
+ delete _music.getVal(id);
_music.erase(id);
+ }
}
//////////////////////////////////////////////////////////////////////////
diff --git a/engines/asylum/respack.h b/engines/asylum/respack.h
index 50b885974b..5f5156fd31 100644
--- a/engines/asylum/respack.h
+++ b/engines/asylum/respack.h
@@ -72,7 +72,7 @@ private:
class ResourceManager {
public:
ResourceManager();
- virtual ~ResourceManager() {};
+ ~ResourceManager();
/**
* Get a resource entry
Commit: 2f18c1cb367c02c0cc966a1fc5a98c7e17656519
https://github.com/scummvm/scummvm/commit/2f18c1cb367c02c0cc966a1fc5a98c7e17656519
Author: Littleboy (littleboy at scummvm.org)
Date: 2021-05-17T15:37:21+02:00
Commit Message:
ASYLUM: Misc. cleanups
- Document some debug calls
- Remove unused parameters names
- Add const as needed
- Change some coordinates values to int16
Changed paths:
engines/asylum/asylum.cpp
engines/asylum/asylum.h
engines/asylum/console.cpp
engines/asylum/puzzles/puzzle.cpp
engines/asylum/puzzles/puzzles.cpp
engines/asylum/resources/data.h
engines/asylum/resources/worldstats.h
engines/asylum/views/menu.cpp
engines/asylum/views/scene.cpp
engines/asylum/views/scenetitle.cpp
diff --git a/engines/asylum/asylum.cpp b/engines/asylum/asylum.cpp
index 2029e9e2df..2307dbde72 100644
--- a/engines/asylum/asylum.cpp
+++ b/engines/asylum/asylum.cpp
@@ -53,7 +53,7 @@ namespace Asylum {
AsylumEngine::AsylumEngine(OSystem *system, const ADGameDescription *gd) : Engine(system), _gameDescription(gd),
_console(NULL), _cursor(NULL), _encounter(NULL), _menu(NULL), _reaction(NULL), _resource(NULL), _savegame(NULL),
_scene(NULL), _screen(NULL), _script(NULL), _special(NULL), _speech(NULL), _sound(NULL), _text(NULL),
- _video(NULL), _handler(NULL) {
+ _video(NULL), _handler(NULL), _puzzles(NULL) {
// Init data
memset(&_gameFlags, 0, sizeof(_gameFlags));
@@ -243,7 +243,7 @@ void AsylumEngine::restart() {
}
void AsylumEngine::reset() {
- if (!_menu)
+ if (!_menu || !_special || !_puzzles)
error("[AsylumEngine::reset] Subsystems not initialized properly!");
// Set game as started
@@ -376,7 +376,7 @@ void AsylumEngine::handleEvents() {
}
void AsylumEngine::processDelayedEvents() {
- if (!_video || !_sound || !_menu || !_script)
+ if (!_video || !_sound || !_menu || !_script || !_screen)
error("[AsylumEngine::processDelayedEvents] Subsystems not initialized properly!");
// check for a delayed scene change
diff --git a/engines/asylum/asylum.h b/engines/asylum/asylum.h
index e31cdd3a15..07f905e13a 100644
--- a/engines/asylum/asylum.h
+++ b/engines/asylum/asylum.h
@@ -226,12 +226,12 @@ private:
EventHandler *_handler;
// Game data
- Puzzles *_puzzles;
- SharedData _data;
- int _gameFlags[130];
- int16 _sinCosTables[72];
- bool _introPlayed;
- int32 _tickOffset;
+ Puzzles *_puzzles;
+ SharedData _data;
+ int _gameFlags[130];
+ int16 _sinCosTables[72];
+ bool _introPlayed;
+ int32 _tickOffset;
void updateMouseCursor();
void processDelayedEvents();
diff --git a/engines/asylum/console.cpp b/engines/asylum/console.cpp
index 18b0ad9929..4d5c0b7587 100644
--- a/engines/asylum/console.cpp
+++ b/engines/asylum/console.cpp
@@ -524,8 +524,8 @@ bool Console::cmdRunEncounter(int32 argc, const char **argv) {
}
// Get the encounter data
- EncounterData *data = NULL;
- for (data = (EncounterData *)&encounterData[getScene()->getPackId() - 5]; data->index != -1; data++) {
+ const EncounterData *data;
+ for (data = (const EncounterData *)&encounterData[getScene()->getPackId() - 5]; data->index != -1; data++) {
if (data->index == index)
break;
}
diff --git a/engines/asylum/puzzles/puzzle.cpp b/engines/asylum/puzzles/puzzle.cpp
index 55260e126c..9e8a39b1b7 100644
--- a/engines/asylum/puzzles/puzzle.cpp
+++ b/engines/asylum/puzzles/puzzle.cpp
@@ -43,7 +43,7 @@ Puzzle::~Puzzle() {
_vm = NULL;
}
-void Puzzle::saveLoadWithSerializer(Common::Serializer &s) {
+void Puzzle::saveLoadWithSerializer(Common::Serializer &) {
// By default, we do not save any data
}
diff --git a/engines/asylum/puzzles/puzzles.cpp b/engines/asylum/puzzles/puzzles.cpp
index b6e94f5a49..1de5ce8210 100644
--- a/engines/asylum/puzzles/puzzles.cpp
+++ b/engines/asylum/puzzles/puzzles.cpp
@@ -40,8 +40,6 @@
#include "asylum/puzzles/writings.h"
#include "asylum/asylum.h"
-#include "asylum/console.h"
-#include "asylum/shared.h"
namespace Asylum {
@@ -60,7 +58,7 @@ Puzzles::~Puzzles() {
void Puzzles::reset() {
for (uint i = 0; i < ARRAYSIZE(_puzzles); i++)
- delete _puzzles[i];
+ delete _puzzles[i];
initPuzzles();
}
diff --git a/engines/asylum/resources/data.h b/engines/asylum/resources/data.h
index ea3edf3fd5..3d10478999 100644
--- a/engines/asylum/resources/data.h
+++ b/engines/asylum/resources/data.h
@@ -44,7 +44,7 @@ enum GlobalFlag {
kFlagIsEncounterRunning,
kFlagEncounterDisablePlayerOnExit,
kFlagActorUpdateEnabledCheck,
- kFlagActorUpdateStatus15Check,
+ kFlagActorUpdateStatus15Check
};
/**
diff --git a/engines/asylum/resources/worldstats.h b/engines/asylum/resources/worldstats.h
index 4750268ae8..ea0e3d5e12 100644
--- a/engines/asylum/resources/worldstats.h
+++ b/engines/asylum/resources/worldstats.h
@@ -122,8 +122,8 @@ public:
Common::Array<Object*> objects; // maxsize 400
Common::Array<Actor*> actors; // maxsize 50
// ActorData is stored in each actor instance
- int32 numScripts;
- int32 numPolygons;
+ uint32 numScripts;
+ uint32 numPolygons;
ResourceId cursorResourcesAlternate[64];
Common::Array<ActionArea*> actions; // maxsize 400
int32 field_E848C;
diff --git a/engines/asylum/views/menu.cpp b/engines/asylum/views/menu.cpp
index f23e44b960..c27227198e 100644
--- a/engines/asylum/views/menu.cpp
+++ b/engines/asylum/views/menu.cpp
@@ -926,7 +926,7 @@ void Menu::updateSaveGame() {
//////////////////////////////////////////////////////////////////////////
// Second column
- for (int32 y = 150; y < 324; y += 29) {
+ for (int16 y = 150; y < 324; y += 29) {
if (index + _startIndex >= 25)
break;
@@ -1036,8 +1036,8 @@ void Menu::updateDeleteGame() {
//////////////////////////////////////////////////////////////////////////
// First column
- uint32 index = 0;
- for (int32 y = 150; y < 324; y += 29) {
+ int32 index = 0;
+ for (int16 y = 150; y < 324; y += 29) {
if (index + _startIndex >= 25)
break;
@@ -1057,7 +1057,7 @@ void Menu::updateDeleteGame() {
//////////////////////////////////////////////////////////////////////////
// Second column
- for (int32 y = 150; y < 324; y += 29) {
+ for (int16 y = 150; y < 324; y += 29) {
if (index + _startIndex >= 25)
break;
@@ -1123,7 +1123,7 @@ void Menu::updateViewMovies() {
//////////////////////////////////////////////////////////////////////////
// First column
int32 index = _startIndex;
- for (int32 y = 150; y < 324; y += 29) {
+ for (int16 y = 150; y < 324; y += 29) {
if (index >= ARRAYSIZE(_movieList))
break;
@@ -1291,7 +1291,7 @@ void Menu::updateAudioOptions() {
getText()->loadFont(kFontYellow);
getText()->drawCentered(Common::Point(10, 100), 620, MAKE_RESOURCE(kResourcePackText, 1420));
- int32 volumeIndex = 0;
+ int16 volumeIndex = 0;
int32 volumeValue = cursor.x;
do {
getText()->loadFont(kFontYellow);
@@ -1639,7 +1639,7 @@ void Menu::clickLoadGame() {
//////////////////////////////////////////////////////////////////////////
// Columns
- uint32 index = 0;
+ int32 index = 0;
for (int32 y = 150; y < 324; y += 29) {
if (cursor.x >= 350) {
sprintf((char *)&text, "%d. %s ", index + _startIndex + 7, getSaveLoad()->getName(index + _startIndex + 6).c_str());
@@ -1743,7 +1743,7 @@ void Menu::clickSaveGame() {
&& cursor.y <= (y + 24)
&& getWorld()->chapter != kChapterNone) {
if (index + _startIndex < 25) {
- uint32 saveIndex = index + _startIndex + 6;
+ uint32 saveIndex = (uint32)(index + _startIndex + 6);
getSaveLoad()->setIndex(saveIndex);
if (getSaveLoad()->hasSavegame(saveIndex)) {
_dword_455C80 = true;
@@ -1764,9 +1764,10 @@ void Menu::clickSaveGame() {
&& cursor.y <= (y + 24)
&& getScene()
&& getWorld()->chapter != kChapterNone) {
- if (index + _startIndex < 25) {
- getSaveLoad()->setIndex(index + _startIndex);
- if (getSaveLoad()->hasSavegame(index + _startIndex)) {
+ uint32 saveIndex = (uint32)(index + _startIndex);
+ if (saveIndex < 25) {
+ getSaveLoad()->setIndex(saveIndex);
+ if (getSaveLoad()->hasSavegame(saveIndex)) {
_dword_455C80 = true;
} else {
_isEditingSavegameName = true;
@@ -1838,17 +1839,18 @@ void Menu::clickDeleteGame() {
//////////////////////////////////////////////////////////////////////////
// Columns
int32 index = 0;
- for (int32 y = 150; y < 324; y += 29) {
+ for (int16 y = 150; y < 324; y += 29) {
if (cursor.x >= 350) {
sprintf((char *)&text, "%d. %s ", index + _startIndex + 7, getSaveLoad()->getName(index + _startIndex + 6).c_str());
if (cursor.x <= (30 + getText()->getWidth((char *)&text))
&& cursor.y >= y
&& cursor.y <= (y + 24)) {
- if (index + _startIndex < 25) {
- if (getSaveLoad()->hasSavegame(index + _startIndex + 6)) {
+ uint32 saveIndex = (uint32)(index + _startIndex);
+ if (saveIndex < 25) {
+ if (getSaveLoad()->hasSavegame(saveIndex + 6)) {
_dword_455C80 = true;
- getSaveLoad()->setIndex(index + _startIndex + 6);
+ getSaveLoad()->setIndex(saveIndex + 6);
}
}
}
diff --git a/engines/asylum/views/scene.cpp b/engines/asylum/views/scene.cpp
index f7f5ec7b18..403c4056ec 100644
--- a/engines/asylum/views/scene.cpp
+++ b/engines/asylum/views/scene.cpp
@@ -1042,18 +1042,18 @@ void Scene::updateCoordinates() {
case 1:
if (posX < boundingRect.left) {
- xLeft = posX - boundingRect.left + _ws->xLeft;
+ xLeft = (posX - boundingRect.left) + _ws->xLeft;
_ws->xLeft += posX - boundingRect.left;
} else if (posX > boundingRect.right) {
- xLeft = posX - boundingRect.right + _ws->xLeft;
+ xLeft = (posX - boundingRect.right) + _ws->xLeft;
_ws->xLeft += posX - boundingRect.right;
}
if (posY < boundingRect.top) {
- yTop = posY - boundingRect.top + _ws->yTop;
+ yTop = (posY - boundingRect.top) + _ws->yTop;
_ws->yTop += posY - boundingRect.top;
} else if (posY > boundingRect.bottom) {
- yTop = posY - boundingRect.bottom + _ws->yTop;
+ yTop = (posY - boundingRect.bottom) + _ws->yTop;
_ws->yTop += posY - boundingRect.bottom;
}
@@ -2164,10 +2164,12 @@ int32 Scene::findActionArea(ActionAreaType type, const Common::Point &pt, bool h
for (int32 i = _ws->actions.size() - 1; i >= 0; i--) {
ActionArea *area = _ws->actions[i];
+ if (g_debugPolygons && highlight) {
#ifdef DEBUG
- if (g_debugPolygons && highlight)
+ // Highlight each polygon as it gets checked for action
debugHighlightPolygon(area->polygonIndex);
#endif
+ }
bool found = false;
@@ -2205,7 +2207,7 @@ int32 Scene::findActionArea(ActionAreaType type, const Common::Point &pt, bool h
// Iterate over flagNum
for (uint32 j = 0; j < 10; j++) {
if (!area->flagNums[j])
- continue; // We skip over null flags
+ continue; // We skip over null flags
bool flagSet = false;
if (area->flagNums[j] <= 0)
diff --git a/engines/asylum/views/scenetitle.cpp b/engines/asylum/views/scenetitle.cpp
index dad25f8c69..ad94ca17e1 100644
--- a/engines/asylum/views/scenetitle.cpp
+++ b/engines/asylum/views/scenetitle.cpp
@@ -77,12 +77,13 @@ void SceneTitle::update(int32 tick) {
// of buffering the various scene resource. Since we don't actually buffer content like the original,
// but load on demand from offset/length within a ResourcePack, the progress indicator is effectively
// useless. It's just in here as "eye candy" :P
+ if ((tick - _start) % 500 > 100) {
#ifdef DEBUG
- if ((tick - _start) % 500 > 100)
_spinnerProgress += 10;
#else
- _spinnerProgress += 35;
+ _spinnerProgress += 35;
#endif
+ }
_spinnerFrameIndex++;
Commit: f929f58e9adef0bc01975924e22dbd8160bbffa2
https://github.com/scummvm/scummvm/commit/f929f58e9adef0bc01975924e22dbd8160bbffa2
Author: Littleboy (littleboy at scummvm.org)
Date: 2021-05-17T15:37:21+02:00
Commit Message:
ASYLUM: Cleanup Actor class
Changed paths:
engines/asylum/resources/actor.cpp
engines/asylum/resources/actor.h
engines/asylum/resources/data.h
diff --git a/engines/asylum/resources/actor.cpp b/engines/asylum/resources/actor.cpp
index ee0dc6f177..0c5142d3d6 100644
--- a/engines/asylum/resources/actor.cpp
+++ b/engines/asylum/resources/actor.cpp
@@ -92,8 +92,6 @@ Actor::Actor(AsylumEngine *engine, ActorIndex index) : _vm(engine), _index(index
_field_94C = 0;
_numberFlag01 = 0;
_numberStringWidth = 0;
- _numberStringX = 0;
- _numberStringY = 0;
memset(&_numberString01, 0, 8);
_field_968 = 0;
_transparency = 0;
@@ -129,16 +127,16 @@ void Actor::load(Common::SeekableReadStream *stream) {
if (!stream)
error("[Actor::load] invalid stream");
- _point.x = stream->readSint32LE();
- _point.y = stream->readSint32LE();
- _resourceId = (ResourceId)stream->readSint32LE();
- _objectIndex = stream->readSint32LE();
- _frameIndex = stream->readUint32LE();
- _frameCount = stream->readUint32LE();
- _point1.x = stream->readSint32LE();
- _point1.y = stream->readSint32LE();
- _point2.x = stream->readSint32LE();
- _point2.y = stream->readSint32LE();
+ _point.x = (int16)stream->readSint32LE();
+ _point.y = (int16)stream->readSint32LE();
+ _resourceId = (ResourceId)stream->readSint32LE();
+ _objectIndex = stream->readSint32LE();
+ _frameIndex = stream->readUint32LE();
+ _frameCount = stream->readUint32LE();
+ _point1.x = (int16)stream->readSint32LE();
+ _point1.y = (int16)stream->readSint32LE();
+ _point2.x = (int16)stream->readSint32LE();
+ _point2.y = (int16)stream->readSint32LE();
_boundingRect.left = (int16)(stream->readSint32LE() & 0xFFFF);
_boundingRect.top = (int16)(stream->readSint32LE() & 0xFFFF);
@@ -199,9 +197,9 @@ void Actor::load(Common::SeekableReadStream *stream) {
_field_948 = stream->readSint32LE();
_field_94C = stream->readSint32LE();
_numberFlag01 = stream->readSint32LE();
- _numberStringWidth = stream->readSint32LE();
- _numberStringX = stream->readSint32LE();
- _numberStringY = stream->readSint32LE();
+ _numberStringWidth = (int16)stream->readSint32LE();
+ _numberPoint.x = (int16)stream->readSint32LE();
+ _numberPoint.y = (int16)stream->readSint32LE();
stream->read(_numberString01, sizeof(_numberString01));
_field_968 = stream->readSint32LE();
_transparency = stream->readSint32LE();
@@ -292,8 +290,8 @@ void Actor::saveLoadWithSerializer(Common::Serializer &s) {
s.syncAsSint32LE(_field_94C);
s.syncAsSint32LE(_numberFlag01);
s.syncAsSint32LE(_numberStringWidth);
- s.syncAsSint32LE(_numberStringX);
- s.syncAsSint32LE(_numberStringY);
+ s.syncAsSint32LE(_numberPoint.x);
+ s.syncAsSint32LE(_numberPoint.y);
s.syncBytes((byte *)&_numberString01, sizeof(_numberString01));
s.syncAsSint32LE(_field_968);
s.syncAsSint32LE(_transparency);
@@ -349,7 +347,7 @@ void Actor::drawNumber() {
return;
getText()->loadFont(getWorld()->font1);
- getText()->drawCentered(Common::Point(_numberStringX, _numberStringY), _numberStringWidth, (char *)&_numberString01);
+ getText()->drawCentered(_numberPoint, _numberStringWidth, (char *)&_numberString01);
}
void Actor::update() {
@@ -385,7 +383,7 @@ void Actor::update() {
if (_index == 11) {
if (_frameIndex <= _frameCount - 1) {
// Looks like a simple check using the counter, since it doesn't seem to be used anywhere else
- if (_updateCounter <= 0) {
+ if (_updateCounter == 0) {
++_updateCounter;
} else {
_updateCounter = 0;
@@ -549,7 +547,7 @@ void Actor::update() {
case kActorStatus1: {
uint32 index = (_frameIndex >= _frameCount) ? 2 * _frameCount - (_frameIndex + 1) : _frameIndex;
- uint32 dist = abs((double)getDistanceForFrame(_direction, index));
+ uint32 dist = (uint32)abs((double)getDistanceForFrame(_direction, index));
Common::Point point = _point1 + _point2;
if (canMove(&point, _direction, dist, false)) {
@@ -583,7 +581,7 @@ void Actor::update() {
case kActorStatus13: {
uint32 index = (_frameIndex >= _frameCount) ? 2 * _frameCount - (_frameIndex + 1) : _frameIndex;
- uint32 dist = abs((double)getDistanceForFrame(_direction, index));
+ int32 dist = (int32)abs((double)getDistanceForFrame(_direction, index));
Common::Point point = _point1 + _point2;
Common::Point current = _data.points[_data.current];
@@ -592,8 +590,8 @@ void Actor::update() {
|| point.x > (int16)(current.x + (dist - 1))
|| point.y < (int16)(current.y - (dist - 1))
|| point.y > (int16)(current.y + (dist - 1))) {
- if (canMove(&point, _direction, dist, false)) {
- move(_direction, dist);
+ if (canMove(&point, _direction, (uint32)dist, false)) {
+ move(_direction, (uint32)dist);
} else {
update_409230();
}
@@ -608,7 +606,7 @@ void Actor::update() {
_frameIndex = (_frameIndex + 1) % _frameCount;
if (canMoveCheckActors(¤t, _direction)) {
- _point1.x = dist - _point2.x;
+ _point1.x = (int16)dist - _point2.x;
_point1.y = current.y - _point2.y;
if (_data.current < (int32)(_data.count - 1)) {
@@ -827,7 +825,7 @@ void Actor::updateDirection() {
ActorDirection direction = kDirectionN;
Common::Point position = sum;
- ResourceId resourceId = kResourceNone;
+ ResourceId resourceId;
switch (_nextDirection) {
default:
// position is unchanged
@@ -837,7 +835,7 @@ void Actor::updateDirection() {
case kDirectionS:
position.x = _nextPosition.x + sum.x;
position.y = _nextPosition.y + sum.y;
- position.y += (_nextDirection == kDirectionN ? -1 : 1) * 2 * abs(sum.y - _nextPositionOffset.y);
+ position.y += (int16)((_nextDirection == kDirectionN ? -1 : 1) * 2 * abs(sum.y - _nextPositionOffset.y));
switch (direction) {
default:
@@ -872,7 +870,7 @@ void Actor::updateDirection() {
case kDirectionO:
case kDirectionE:
position.x = _nextPosition.x + sum.x;
- position.x += (_nextDirection == kDirectionO ? -1 : 1) * 2 * abs(sum.x - _nextPositionOffset.x);
+ position.x += (int16)((_nextDirection == kDirectionO ? -1 : 1) * 2 * abs(sum.x - _nextPositionOffset.x));
position.y = _nextPosition.y + sum.y;
switch (direction) {
@@ -909,8 +907,8 @@ void Actor::updateDirection() {
case kDirectionSE:
position.x = _nextPosition.x + sum.x;
position.y = _nextPosition.y + sum.y;
- position.x += (_nextDirection == kDirectionNO ? -1 : 1) * 2 * abs(sum.y - _nextPositionOffset.y);
- position.y += (_nextDirection == kDirectionNO ? -1 : 1) * 2 * abs(sum.x - _nextPositionOffset.x);
+ position.x += (int16)((_nextDirection == kDirectionNO ? -1 : 1) * 2 * abs(sum.y - _nextPositionOffset.y));
+ position.y += (int16)((_nextDirection == kDirectionNO ? -1 : 1) * 2 * abs(sum.x - _nextPositionOffset.x));
switch (direction) {
default:
@@ -953,13 +951,13 @@ void Actor::updateDirection() {
case kDirectionSO:
case kDirectionNE:
if (_nextDirection == kDirectionSO) {
- position.x = _nextPosition.x + sum.x - 2 * abs(sum.y - _nextPositionOffset.y);
- position.y = _nextPosition.y + sum.y + 2 * abs(sum.x - _nextPositionOffset.x);
+ position.x = (int16)(_nextPosition.x + sum.x - 2 * abs(sum.y - _nextPositionOffset.y));
+ position.y = (int16)(_nextPosition.y + sum.y + 2 * abs(sum.x - _nextPositionOffset.x));
} else {
double deltaX = sum.x * -0.56666666;
- double deltaY = (419 - sum.y + deltaX) * 0.87613291;
- position.x = sum.x + 2 * (_nextPositionOffset.x - deltaY);
- position.y = sum.y + 2 * (_nextPosition.x - (sum.y + deltaX) - (deltaY * -0.56666666));
+ double deltaY = ((419 - sum.y) + deltaX) * 0.87613291;
+ position.x = (int16)(sum.x + 2 * (_nextPositionOffset.x - deltaY));
+ position.y = (int16)(sum.y + 2 * (_nextPosition.x - (sum.y + deltaX + (deltaY * -0.56666666))));
}
switch (direction) {
@@ -1017,7 +1015,7 @@ void Actor::updateDirection() {
// Compute resource id and adjust frame count
Actor *nextActor = getScene()->getActor(_nextActorIndex);
- resourceId = nextActor->getResourcesId(index - index % 5 + (direction > kDirectionS ? 8 - direction : direction));
+ resourceId = nextActor->getResourcesId((index - index % 5) + (direction > kDirectionS ? 8 - direction : direction));
nextActor->setFrameCount(GraphicResource::getFrameCount(_vm, resourceId));
// Adjust graphic resource and position
@@ -1080,8 +1078,8 @@ void Actor::faceTarget(uint32 target, DirectionFrom from) {
Common::Rect frameRect = GraphicResource::getFrameRect(_vm, object->getResourceId(), object->getFrameIndex());
- point.x = Common::Rational(frameRect.width(), 2).toInt() + object->x;
- point.y = Common::Rational(frameRect.height(), 2).toInt() + object->y;
+ point.x = (int16)Common::Rational(frameRect.width(), 2).toInt() + object->x;
+ point.y = (int16)Common::Rational(frameRect.height(), 2).toInt() + object->y;
}
break;
@@ -1105,7 +1103,7 @@ void Actor::faceTarget(uint32 target, DirectionFrom from) {
break;
case kDirectionFromParameters:
- point.x = point.y = target;
+ point.x = point.y = (int16)target;
break;
}
@@ -1113,7 +1111,7 @@ void Actor::faceTarget(uint32 target, DirectionFrom from) {
updateFromDirection(directionFromAngle(mid, point));
}
-void Actor::setPosition(int32 newX, int32 newY, ActorDirection newDirection, uint32 frame) {
+void Actor::setPosition(int16 newX, int16 newY, ActorDirection newDirection, uint32 frame) {
_point1.x = newX - _point2.x;
_point1.y = newY - _point2.y;
@@ -1194,9 +1192,9 @@ bool Actor::process(const Common::Point &point) {
Common::Point delta = point - sum;
// Compute modifiers
- int a1 = 0;
- int a2 = 0;
- int a3 = 0;
+ int16 a1 = 0;
+ int16 a2 = 0;
+ int16 a3 = 0;
if (delta.x <= 0) {
if (delta.y >= 0) {
@@ -1221,7 +1219,7 @@ bool Actor::process(const Common::Point &point) {
}
if (point == sum) {
- if (canMove(&sum, a3 >= 2 ? kDirectionS : kDirectionN, abs(delta.y), false)) {
+ if (canMove(&sum, a3 >= 2 ? kDirectionS : kDirectionN, (uint32)abs(delta.y), false)) {
_data.points[0] = point;
_data.current = 0;
_data.count = 1;
@@ -1232,7 +1230,7 @@ bool Actor::process(const Common::Point &point) {
if (point.x == sum.x) {
ActorDirection actorDir = a3 >= 2 ? kDirectionS : kDirectionN;
- if (canMove(&sum, actorDir, abs(delta.y), false)) {
+ if (canMove(&sum, actorDir, (uint32)abs(delta.y), false)) {
_data.points[0] = point;
_data.current = 0;
_data.count = 1;
@@ -1248,7 +1246,7 @@ bool Actor::process(const Common::Point &point) {
if (point.y == sum.y) {
ActorDirection actorDir = (a3 != 0 || a3 != 3) ? kDirectionE : kDirectionO;
- if (canMove(&sum, actorDir, abs(delta.x), true)) {
+ if (canMove(&sum, actorDir, (uint32)abs(delta.x), true)) {
_data.points[0] = point;
_data.current = 0;
_data.count = 1;
@@ -1272,10 +1270,10 @@ bool Actor::process(const Common::Point &point) {
// Compute coordinates, directions and counts
if (abs(delta.x) < abs(delta.y)) {
- point1 = Common::Point(sum.x + abs(delta.x) * a1, sum.y + abs(delta.x) * a2);
- point2 = Common::Point(sum.x , sum.y + abs(abs(delta.x) - abs(delta.y)) * a2);
- count1 = abs(point1.x - sum.x);
- count2 = abs(point1.y - point.y);
+ point1 = Common::Point((int16)(sum.x + abs(delta.x) * a1), (int16)(sum.y + abs(delta.x) * a2));
+ point2 = Common::Point(sum.x , (int16)(sum.y + abs(abs(delta.x) - abs(delta.y)) * a2));
+ count1 = (uint32)abs(point1.x - sum.x);
+ count2 = (uint32)abs(point1.y - point.y);
switch (a3) {
default:
@@ -1303,10 +1301,10 @@ bool Actor::process(const Common::Point &point) {
break;
}
} else {
- point1 = Common::Point(sum.x + abs(delta.y) * a1, sum.y + abs(delta.y) * a2);
- point2 = Common::Point(sum.x + abs(abs(delta.y) - abs(delta.x)) * a1 , sum.y);
- count1 = abs(abs(delta.y) * a2);
- count2 = abs(point1.y - point.x);
+ point1 = Common::Point((int16)(sum.x + abs(delta.y) * a1), (int16)(sum.y + abs(delta.y) * a2));
+ point2 = Common::Point((int16)(sum.x + abs(abs(delta.y) - abs(delta.x)) * a1), sum.y);
+ count1 = (uint32)abs(abs(delta.y) * a2);
+ count2 = (uint32)abs(point1.y - point.x);
switch (a3) {
default:
@@ -1454,7 +1452,7 @@ bool Actor::process(const Common::Point &point) {
break;
}
- if (!canMove(&sum, actorDir, abs(delta.y), true))
+ if (!canMove(&sum, actorDir, (uint32)abs(delta.y), true))
return false;
// Update actor data
@@ -1468,7 +1466,7 @@ bool Actor::process(const Common::Point &point) {
return true;
}
-void Actor::processStatus(int32 actorX, int32 actorY, bool doSpeech) {
+void Actor::processStatus(int16 actorX, int16 actorY, bool doSpeech) {
if (process(Common::Point(actorX, actorY))) {
if (_status <= kActorStatus11)
updateStatus(kActorStatus2);
@@ -1491,7 +1489,7 @@ void Actor::processNext(ActorIndex nextActor, int32 actionAreaId, ActorDirection
if (nextPositionOffset.x) {
offset = nextPositionOffset;
} else {
- Polygon polygon = getScene()->polygons()->get(_nextActionIndex);
+ Polygon polygon = getScene()->polygons()->get((uint32)_nextActionIndex);
offset = polygon.points[0];
@@ -1567,8 +1565,8 @@ void Actor::processNext(ActorIndex nextActor, int32 actionAreaId, ActorDirection
_nextPositionOffset = offset;
- double cosValue = cos(0.523598775) * 1000.0;
- double sinValue = sin(0.523598775) * 1000.0;
+ int16 cosValue = (int16)(cos(0.523598775) * 1000.0);
+ int16 sinValue = (int16)(sin(0.523598775) * 1000.0);
_field_994 = offset.x - cosValue;
_field_998 = offset.y + sinValue;
@@ -1583,7 +1581,7 @@ void Actor::processNext(ActorIndex nextActor, int32 actionAreaId, ActorDirection
bool Actor::canInteract(Common::Point *point, int32* param) {
Actor *player = getScene()->getActor();
- uint32 offset = 65;
+ int16 offset = 65;
if (getWorld()->chapter != kChapter2 || _index != 8)
offset = 40;
@@ -1733,6 +1731,9 @@ bool Actor::canMove(Common::Point *point, ActorDirection direction, uint32 dista
}
void Actor::move(ActorDirection actorDir, uint32 dist) {
+ if (_frameCount == 0)
+ error("[Actor::move] Invalid frame count (cannot be 0)");
+
_lastScreenUpdate = _vm->screenUpdateCount;
Common::Point sum(_point1.x + _point2.x, _point1.x + _point2.x);
@@ -1746,16 +1747,16 @@ void Actor::move(ActorDirection actorDir, uint32 dist) {
case kActorStatus2:
case kActorStatus12:
case kActorStatus13:
- updateCoordinatesForDirection(actorDir, dist, &_point1);
+ updateCoordinatesForDirection(actorDir, (int16)dist, &_point1);
_frameIndex = (_frameIndex + 1) % _frameCount;
if (_walkingSound1 != kResourceNone) {
// Compute volume
- int32 vol = sqrt((double)-Config.sfxVolume);
+ int32 vol = (int32)sqrt((double)-Config.sfxVolume);
if (_index != getSharedData()->getPlayerIndex())
- vol += sqrt((double)abs(getSound()->calculateVolumeAdjustement(sum, 10, 0)));
+ vol += (int32)sqrt((double)abs(getSound()->calculateVolumeAdjustement(sum, 10, 0)));
int32 volume = (Config.sfxVolume + vol) * (Config.sfxVolume + vol);
if (volume > 10000)
@@ -1766,14 +1767,14 @@ void Actor::move(ActorDirection actorDir, uint32 dist) {
ResourceId resourceId = kResourceNone;
if (getWorld()->actions[_actionIdx3]->soundResourceIdFrame != kResourceNone && strcmp((char *)&_name, "Crow") && strcmp((char *)&_name, "Big Crow")) {
if (_frameIndex == _field_64C)
- resourceId = (ResourceId)(getWorld()->actions[_actionIdx3]->soundResourceIdFrame + rnd(1));
+ resourceId = (ResourceId)(getWorld()->actions[_actionIdx3]->soundResourceIdFrame + (int)rnd(1));
else if (_frameIndex == _field_650)
- resourceId = (ResourceId)(getWorld()->actions[_actionIdx3]->soundResourceId + rnd(1));
+ resourceId = (ResourceId)(getWorld()->actions[_actionIdx3]->soundResourceId + (int)rnd(1));
} else {
if (_frameIndex == _field_64C)
- resourceId = (ResourceId)(_walkingSound1 + rnd(1));
+ resourceId = (ResourceId)(_walkingSound1 + (int)rnd(1));
else if (_frameIndex == _field_650)
- resourceId = (ResourceId)(_walkingSound3 + rnd(1));
+ resourceId = (ResourceId)(_walkingSound3 + (int)rnd(1));
}
// Play sound
@@ -1784,7 +1785,7 @@ void Actor::move(ActorDirection actorDir, uint32 dist) {
case kActorStatus18:
if (getWorld()->chapter == kChapter2) {
- updateCoordinatesForDirection(actorDir, dist, &_point1);
+ updateCoordinatesForDirection(actorDir, (int16)dist, &_point1);
if (_walkingSound1 == kResourceNone)
break;
@@ -1792,7 +1793,7 @@ void Actor::move(ActorDirection actorDir, uint32 dist) {
// Compute volume
int32 vol = getWorld()->actions[_actionIdx3]->volume;
if (_index != getSharedData()->getPlayerIndex())
- vol += sqrt((double)abs(getSound()->calculateVolumeAdjustement(sum, 10, 0)));
+ vol += (int32)sqrt((double)abs(getSound()->calculateVolumeAdjustement(sum, 10, 0)));
int32 volume = (Config.sfxVolume + vol) * (Config.sfxVolume + vol);
if (volume > 10000)
@@ -1802,14 +1803,14 @@ void Actor::move(ActorDirection actorDir, uint32 dist) {
ResourceId resourceId = kResourceNone;
if (getWorld()->actions[_actionIdx3]->soundResourceIdFrame != kResourceNone && strcmp((char *)&_name, "Crow") && strcmp((char *)&_name, "Big Crow")) {
if (_frameIndex == _field_64C)
- resourceId = (ResourceId)(getWorld()->actions[_actionIdx3]->soundResourceIdFrame + rnd(1));
+ resourceId = (ResourceId)(getWorld()->actions[_actionIdx3]->soundResourceIdFrame + (int)rnd(1));
else if (_frameIndex == _field_650)
- resourceId = (ResourceId)(getWorld()->actions[_actionIdx3]->soundResourceId + rnd(1));
+ resourceId = (ResourceId)(getWorld()->actions[_actionIdx3]->soundResourceId + (int)rnd(1));
} else {
if (_frameIndex == _field_64C)
- resourceId = (ResourceId)(_walkingSound1 + rnd(1));
+ resourceId = (ResourceId)(_walkingSound1 + (int)rnd(1));
else if (_frameIndex == _field_650)
- resourceId = (ResourceId)(_walkingSound3 + rnd(1));
+ resourceId = (ResourceId)(_walkingSound3 + (int)rnd(1));
}
// Play sound
@@ -1869,7 +1870,7 @@ void Actor::removeReactionHive(int32 reactionIndex, int32 numberValue01Substract
}
}
-bool Actor::hasMoreReactions(int32 reactionIndex, int32 testNumberValue01) {
+bool Actor::hasMoreReactions(int32 reactionIndex, int32 testNumberValue01) const {
if (reactionIndex > 16)
return false;
@@ -1890,8 +1891,8 @@ bool Actor::hasMoreReactions(int32 reactionIndex, int32 testNumberValue01) {
bool Actor::canMoveCheckActors(Common::Point *point, ActorDirection dir) {
int32 dist = getAbsoluteDistanceForFrame(dir, (_frameIndex >= _frameCount) ? 2 * _frameCount - (_frameIndex + 1) : _frameIndex);
- int32 x = point->x + deltaPointsArray[dir].x * dist - _field_948 - 10;
- int32 y = point->y + deltaPointsArray[dir].y * dist - _field_94C - 10;
+ int32 x = point->x + deltaPointsArray[dir].x * dist - (_field_948 + 10);
+ int32 y = point->y + deltaPointsArray[dir].y * dist - (_field_94C + 10);
int32 x1 = x + 2 * _field_948 + 20;
int32 y1 = y + 2 * _field_94C + 20;
@@ -1904,8 +1905,8 @@ bool Actor::canMoveCheckActors(Common::Point *point, ActorDirection dir) {
if (!actor->isOnScreen())
continue;
- int32 x2 = actor->getPoint1()->x + actor->getPoint2()->x - actor->getField948() - 15;
- int32 y2 = actor->getPoint1()->y + actor->getPoint2()->y - actor->getField94C() - 10;
+ int32 x2 = actor->getPoint1()->x + actor->getPoint2()->x - (actor->getField948() + 15);
+ int32 y2 = actor->getPoint1()->y + actor->getPoint2()->y - (actor->getField94C() + 10);
int32 x3 = actor->getPoint1()->x + actor->getPoint2()->x + 2 * actor->getField948() + 15;
int32 y3 = actor->getPoint1()->y + actor->getPoint2()->y + 2 * actor->getField94C() + 10;
@@ -2264,7 +2265,7 @@ void Actor::updateStatusEnabled() {
if (getWorld()->chapter != kChapter2 || _index != 8) {
if (_field_944 == 4) {
Common::Rect frameRect = GraphicResource::getFrameRect(_vm, getWorld()->backgroundImage, 0);
- processStatus(rnd(frameRect.width() + 200) - 100, rnd(frameRect.height() + 200) - 100, false);
+ processStatus((int16)rnd(frameRect.width() + 200) - 100, (int16)rnd(frameRect.height() + 200) - 100, false);
} else {
// Actor: Crow
if (rnd(1000) < 5 || !strcmp(_name, "Crow")) {
@@ -2277,8 +2278,8 @@ void Actor::updateStatusEnabled() {
ActionArea *area = getWorld()->actions[areaIndex];
Polygon poly = getScene()->polygons()->get(area->polygonIndex);
- Common::Point pt(poly.boundingRect.left + rnd(poly.boundingRect.width()),
- poly.boundingRect.top + rnd(poly.boundingRect.height()));
+ Common::Point pt(poly.boundingRect.left + (int16)rnd((uint16)poly.boundingRect.width()),
+ poly.boundingRect.top + (int16)rnd((uint16)poly.boundingRect.height()));
if (!getSharedData()->getFlag(kFlagActorUpdateEnabledCheck)) {
if (!isInActionArea(pt, area)) {
@@ -2324,7 +2325,7 @@ void Actor::updateStatusEnabled() {
}
}
-void Actor::updateStatusEnabledProcessStatus(int32 testX, int32 testY, uint32 counter, int32 setX, int32 setY) {
+void Actor::updateStatusEnabledProcessStatus(int16 testX, int16 testY, uint32 counter, int16 setX, int16 setY) {
int32 xsum = _point1.x + _point2.x;
int32 ysum = _point1.y + _point2.y;
@@ -2360,12 +2361,12 @@ void Actor::updateStatus12_Chapter2() {
// Compute distance
uint32 frameIndex = _frameIndex;
if (_frameIndex >= _frameCount)
- frameIndex = 2 * _frameCount - _frameIndex - 1;
+ frameIndex = 2 * _frameCount - (_frameIndex + 1);
- uint32 distance = abs((double)getDistanceForFrame(_direction, frameIndex));
+ uint32 distance = (uint32)abs((double)getDistanceForFrame(_direction, frameIndex));
// Face actor
- faceTarget(getSharedData()->getPlayerIndex(), kDirectionFromActor);
+ faceTarget((uint32)getSharedData()->getPlayerIndex(), kDirectionFromActor);
int32 data = getSharedData()->getChapter2Data(3, _index + 1);
if (data > 0) {
@@ -2378,8 +2379,8 @@ void Actor::updateStatus12_Chapter2() {
Common::Point sumPlayer = *player->getPoint1() + *player->getPoint2();
Common::Point sum = _point1 + _point2;
- uint32 absX = abs(sum.x - sumPlayer.x);
- uint32 absY = abs(sum.y - sumPlayer.y);
+ uint32 absX = (uint32)abs(sum.x - sumPlayer.x);
+ uint32 absY = (uint32)abs(sum.y - sumPlayer.y);
// Adjust distance
if (absX <= absY)
@@ -2406,9 +2407,9 @@ void Actor::updateStatus12_Chapter2_Actor11() {
// Compute distance
uint32 frameIndex = _frameIndex;
if (_frameIndex >= _frameCount)
- frameIndex = 2 * _frameCount - _frameIndex - 1;
+ frameIndex = 2 * _frameCount - (_frameIndex + 1);
- uint32 distance = abs((double)getDistanceForFrame(_direction, frameIndex));
+ uint32 distance = (uint32)abs((double)getDistanceForFrame(_direction, frameIndex));
// Update status
if (player->getStatus() == kActorStatus17 || !getScene()->getActor(10)->isVisible()) {
@@ -2417,7 +2418,7 @@ void Actor::updateStatus12_Chapter2_Actor11() {
}
// Face player
- faceTarget(getSharedData()->getPlayerIndex(), kDirectionFromActor);
+ faceTarget((uint32)getSharedData()->getPlayerIndex(), kDirectionFromActor);
// Compute coordinates
Common::Point delta = Common::Point((sumPlayer.x + sum.x) / 2, (sumPlayer.y + sum.y) / 2);
@@ -2466,7 +2467,7 @@ void Actor::updateStatus12_Chapter2_Actor11() {
if (player->getStatus() != kActorStatus17 && player->getStatus() != kActorStatus16) {
if (sqrt((double)((sum.y - sumPlayer.y) * (sum.y - sumPlayer.y) + (sum.x - sumPlayer.x) * (sum.x - sumPlayer.x))) < 80.0) {
_frameIndex = 0;
- faceTarget(getSharedData()->getPlayerIndex(), kDirectionFromActor);
+ faceTarget((uint32)getSharedData()->getPlayerIndex(), kDirectionFromActor);
updateStatus(kActorStatus15);
}
}
@@ -2519,6 +2520,9 @@ void Actor::updateStatus12_Chapter11() {
}
void Actor::updateStatus14() {
+ if (_frameCount == 0)
+ error("[Actor::updateStatus14] Invalid frame count (cannot be 0)");
+
_frameIndex = (_frameIndex + 1) % _frameCount;
_lastScreenUpdate = _vm->screenUpdateCount;
@@ -2549,8 +2553,8 @@ void Actor::updateStatus14_Chapter2() {
}
if (_status != kActorStatus16) {
- _point1.x -= getSharedData()->getChapter2Data(3, 2 * _index + 6);
- _point1.y -= getSharedData()->getChapter2Data(3, 2 * _index + 7) + 54;
+ _point1.x -= (int16)getSharedData()->getChapter2Data(3, 2 * _index + 6);
+ _point1.y -= (int16)getSharedData()->getChapter2Data(3, 2 * _index + 7) + 54;
}
if (_frameIndex == _frameCount - 1) {
@@ -2667,9 +2671,9 @@ void Actor::updateStatus15_Chapter2() {
updateStatus(kActorStatusEnabled);
uint32 dist = euclidianDistance(sumPlayer, sum);
- uint32 offset = (dist <= 10) ? 7 : 12;
+ int16 offset = (dist <= 10) ? 7 : 12;
if (dist > 20) {
- faceTarget(getSharedData()->getPlayerIndex(), kDirectionFromActor);
+ faceTarget((uint32)getSharedData()->getPlayerIndex(), kDirectionFromActor);
getScene()->getActor(_index + 9)->setDirection(_direction);
}
@@ -2686,7 +2690,7 @@ void Actor::updateStatus15_Chapter2() {
else if (sumPlayer.y < sum.y)
_point1.y -= offset;
- if (dist < (offset + 1)) {
+ if ((int32)dist < (offset + 1)) {
if (player->getStatus() != kActorStatus16 && player->getStatus() != kActorStatus17 && player->getFrameIndex() < 6) {
_point1 = sumPlayer - _point2;
@@ -3019,10 +3023,10 @@ bool Actor::updateStatus15_Chapter2_Actor11_Helper(ActorIndex actorIndex1, Actor
int16 actor2_x = actor2->getPoint1()->x + actor2->getPoint2()->x;
int16 actor2_y = actor2->getPoint1()->y + actor2->getPoint2()->y;
- Common::Point pt1(actor2_x - actor1->getField948() - 10, actor2_y - actor1->getField94C() - 10);
- Common::Point pt2(actor2_x + 2 * actor1->getField948() + 10, actor2_y + 2 * actor1->getField94C() + 10);
- Common::Point pt3(actor2_x - actor2->getField948() - 25, actor2_y - actor2->getField94C() - 20);
- Common::Point pt4(actor2_x + 2 * actor2->getField948() + 25, actor2_y + 2 * actor2->getField94C() + 20);
+ Common::Point pt1((int16)(actor2_x - (actor1->getField948() + 10)), (int16)(actor2_y - (actor1->getField94C() + 10)));
+ Common::Point pt2((int16)(actor2_x + 2 * actor1->getField948() + 10), (int16)(actor2_y + 2 * actor1->getField94C() + 10));
+ Common::Point pt3((int16)(actor2_x - (actor2->getField948() + 25)), (int16)(actor2_y - (actor2->getField94C() + 20)));
+ Common::Point pt4((int16)(actor2_x + 2 * actor2->getField948() + 25), (int16)(actor2_y + 2 * actor2->getField94C() + 20));
return getScene()->rectIntersect(pt1.x, pt1.y, pt2.x, pt2.y, pt3.x, pt3.y, pt4.x, pt4.y);
}
@@ -3197,8 +3201,8 @@ void Actor::updateStatus17_Chapter2() {
void Actor::updateStatus18_Chapter2() {
Actor *player = getScene()->getActor();
- _point1.x = player->getPoint1()->x - getSharedData()->getChapter2Data(3, 2 * _index + 6);
- _point1.y = player->getPoint1()->y - getSharedData()->getChapter2Data(3, 2 * _index + 7);
+ _point1.x = player->getPoint1()->x - (int16)getSharedData()->getChapter2Data(3, 2 * _index + 6);
+ _point1.y = player->getPoint1()->y - (int16)getSharedData()->getChapter2Data(3, 2 * _index + 7);
_frameIndex++;
@@ -3214,8 +3218,8 @@ void Actor::updateStatus18_Chapter2() {
}
void Actor::updateStatus18_Chapter2_Actor11() {
- uint32 frameIndex = (_frameIndex < _frameCount) ? _frameIndex : 2 * _frameCount - _frameIndex - 1;
- int32 distance = abs((double)getDistanceForFrame(_direction, frameIndex));
+ int32 frameIndex = (int32)_frameIndex;
+ uint32 distance = (uint32)abs((double)getDistanceForFrame(_direction, (_frameIndex < _frameCount) ? _frameIndex : 2 * _frameCount - (_frameIndex + 1)));
getSharedData()->setChapter2Counter(7, getSharedData()->getChapter2Counter(7) + 1);
if (getSharedData()->getChapter2Counter(7) > 14) {
@@ -3223,28 +3227,30 @@ void Actor::updateStatus18_Chapter2_Actor11() {
updateStatus(kActorStatus12);
}
- faceTarget(getSharedData()->getPlayerIndex(), kDirectionFromActor);
+ faceTarget((uint32)getSharedData()->getPlayerIndex(), kDirectionFromActor);
Common::Point sum = _point1 + _point2;
if (canMove(&sum, DIR(_direction + 4), distance, false)) {
move(DIR(_direction + 4), distance);
- --_frameIndex;
+ --frameIndex;
} else if (canMove(&sum, DIR(_direction + 5), distance, false)) {
move(DIR(_direction + 5), distance);
- --_frameIndex;
+ --frameIndex;
} else if (canMove(&sum, DIR(_direction + 3), distance, false)) {
move(DIR(_direction + 3), distance);
- --_frameIndex;
+ --frameIndex;
} else if (canMove(&sum, DIR(_direction + 6), distance, false)) {
move(DIR(_direction + 6), distance);
- --_frameIndex;
+ --frameIndex;
} else if (canMove(&sum, DIR(_direction + 2), distance, false)) {
move(DIR(_direction + 2), distance);
- --_frameIndex;
+ --frameIndex;
}
- if (_frameIndex < 0)
+ if (frameIndex < 0)
_frameIndex = _frameCount - 1;
+ else
+ _frameIndex = (uint32)frameIndex;
}
void Actor::updateStatus21() {
@@ -3304,11 +3310,11 @@ void Actor::updateFinish() {
}
}
-void Actor::updateCoordinates(Common::Point vec1, Common::Point vec2) {
+void Actor::updateCoordinates(const Common::Point &vec1, Common::Point vec2) {
if (getScene()->getActor(1)->isVisible())
return;
- uint32 diffY = abs(vec2.y - vec1.y);
+ uint32 diffY = (uint32)abs(vec2.y - vec1.y);
if (diffY > 5)
diffY = 5;
@@ -3318,7 +3324,7 @@ void Actor::updateCoordinates(Common::Point vec1, Common::Point vec2) {
ActorDirection dir = (diffY > 0) ? kDirectionS : kDirectionN;
if (canMove(&vec2, dir, diffY + 3, false))
- updateCoordinatesForDirection(dir, diffY - 1, &_point);
+ updateCoordinatesForDirection(dir, (int16)(diffY - 1), &_point);
}
void Actor::resetActors() {
@@ -3333,8 +3339,8 @@ void Actor::updateNumbers(int32 reaction, const Common::Point &point) {
if (reaction != 1)
return;
- _numberStringX = point.x;
- _numberStringY = point.y + 8;
+ _numberPoint.x = point.x;
+ _numberPoint.y = point.y + 8;
_numberStringWidth = 40;
sprintf(_numberString01, "%d", _numberValue01);
@@ -3524,8 +3530,8 @@ bool Actor::processAction(const Common::Point &source, Common::Array<int> *actio
break;
int32 dist = getAbsoluteDistanceForFrame(direction, frameNumber);
- src.x += sign.x * dist;
- src.y += sign.y * dist;
+ src.x += (int16)(sign.x * dist);
+ src.y += (int16)(sign.y * dist);
if (abs(src.x - destination.x) >= getAbsoluteDistanceForFrame(kDirectionO, frameNumber)) {
if (abs(src.y - destination.y) >= getAbsoluteDistanceForFrame(kDirectionN, frameNumber)) {
@@ -3614,13 +3620,13 @@ bool Actor::processAction(const Common::Point &source, Common::Array<int> *actio
// Update frame and setup pathfinding
_frameNumber = frameNumber;
- if (_frameNumber <= 0)
+ if (_frameNumber == 0)
distance = getAbsoluteDistanceForFrame(direction, _frameCount - 1);
else
distance = getAbsoluteDistanceForFrame(direction, _frameNumber - 1);
- src.x -= sign.x * distance;
- src.y -= sign.y * distance;
+ src.x -= (int16)(sign.x * distance);
+ src.y -= (int16)(sign.y * distance);
*point = src;
_data.points[_data.count] = src;
@@ -3630,7 +3636,7 @@ bool Actor::processAction(const Common::Point &source, Common::Array<int> *actio
return true;
}
-bool Actor::checkPath(Common::Array<int> *actions, const Common::Point &point, ActorDirection direction, uint32 loopcount) {
+bool Actor::checkPath(Common::Array<int> *actions, const Common::Point &point, ActorDirection direction, int16 loopcount) {
if (loopcount <= 1)
return true;
@@ -3638,7 +3644,7 @@ bool Actor::checkPath(Common::Array<int> *actions, const Common::Point &point, A
Common::Point basePoint = deltaPointsArray[direction] + point;
Common::Rect rect = getWorld()->sceneRects[getWorld()->sceneRectIdx];
- for (uint32 i = 1; i < loopcount; i++) {
+ for (int16 i = 1; i < loopcount; i++) {
if (!checkAllActions(basePoint, actions))
break;
@@ -3732,7 +3738,7 @@ void Actor::setVolume() {
// Helper methods
//////////////////////////////////////////////////////////////////////////
-ActorDirection Actor::directionFromAngle(Common::Point vec1, Common::Point vec2) {
+ActorDirection Actor::directionFromAngle(const Common::Point &vec1, const Common::Point &vec2) {
int32 diffX = (vec2.x - vec1.x) * 2^16;
int32 diffY = (vec1.y - vec2.y) * 2^16;
int32 adjust = 0;
@@ -3750,7 +3756,7 @@ ActorDirection Actor::directionFromAngle(Common::Point vec1, Common::Point vec2)
int32 dirAngle = -1;
if (diffX) {
- uint32 index = (diffY * 256) / diffX;
+ uint32 index = (uint32)((diffY * 256) / diffX);
if (index < 256)
dirAngle = angleTable01[index];
@@ -3855,6 +3861,9 @@ DrawFlags Actor::getGraphicsFlags() {
}
int32 Actor::getAbsoluteDistanceForFrame(ActorDirection dir, uint32 frameIndex) const {
+ if (frameIndex >= ARRAYSIZE(_distancesNS))
+ error("[Actor::getAbsoluteDistanceForFrame] Invalid frame index (was: %d, max: %d)", _frameIndex, ARRAYSIZE(_distancesNS) - 1);
+
switch (dir) {
default:
error("[Actor::getDistanceForFrame] Invalid direction");
@@ -3876,6 +3885,9 @@ int32 Actor::getAbsoluteDistanceForFrame(ActorDirection dir, uint32 frameIndex)
}
int32 Actor::getDistanceForFrame(ActorDirection dir, uint32 frameIndex) const {
+ if (frameIndex >= ARRAYSIZE(_distancesNS))
+ error("[Actor::getDistanceForFrame] Invalid frame index (was: %d, max: %d)", _frameIndex, ARRAYSIZE(_distancesNS) - 1);
+
switch (dir) {
default:
error("[Actor::getDistanceForFrame] Invalid direction");
@@ -3906,7 +3918,7 @@ int32 Actor::getDistanceForFrame(ActorDirection dir, uint32 frameIndex) const {
}
}
-void Actor::updateCoordinatesForDirection(ActorDirection direction, int32 delta, Common::Point *point) {
+void Actor::updateCoordinatesForDirection(ActorDirection direction, int16 delta, Common::Point *point) {
if (!point)
error("[Actor::updateCoordinatesForDirection] Invalid point (NULL)!");
@@ -3952,12 +3964,12 @@ void Actor::updateCoordinatesForDirection(ActorDirection direction, int32 delta,
}
}
-uint32 Actor::euclidianDistance(Common::Point vec1, Common::Point vec2) {
- return sqrt(pow((double)(vec2.y - vec1.y), 2) + pow((double)(vec2.x - vec1.x), 2));
+uint32 Actor::euclidianDistance(const Common::Point &vec1, const Common::Point &vec2) {
+ return (uint32)sqrt(pow((double)(vec2.y - vec1.y), 2) + pow((double)(vec2.x - vec1.x), 2));
}
-uint32 Actor::angleFromVectors(Common::Point vec1, Common::Point vec2) {
- int32 result = ((long)(180 - acos((double)(vec2.y - vec1.y) / euclidianDistance(vec1, vec2)) * 180 / M_PI)) % 360;
+int32 Actor::angleFromVectors(const Common::Point &vec1, const Common::Point &vec2) {
+ uint32 result = (uint32)(((long)(180 - acos((double)(vec2.y - vec1.y) / euclidianDistance(vec1, vec2)) * 180 / M_PI)) % 360);
if (vec1.x < vec2.x)
return 360 - result;
@@ -3965,7 +3977,7 @@ uint32 Actor::angleFromVectors(Common::Point vec1, Common::Point vec2) {
return result;
}
-void Actor::rectFromDirection(Common::Rect *rect, ActorDirection direction, Common::Point point) {
+void Actor::rectFromDirection(Common::Rect *rect, ActorDirection direction, const Common::Point &point) {
if (!rect)
error("[Actor::rect] Invalid rect (NULL)!");
@@ -4022,7 +4034,7 @@ void Actor::rectFromDirection(Common::Rect *rect, ActorDirection direction, Comm
rect->setHeight(40);
}
-bool Actor::compareAngles(Common::Point vec1, Common::Point vec2) {
+bool Actor::compareAngles(const Common::Point &vec1, const Common::Point &vec2) {
Common::Point vec3(2289, 171);
int32 diff = angleFromVectors(vec1, vec3) - angleFromVectors(vec1, vec2);
@@ -4033,14 +4045,14 @@ bool Actor::compareAngles(Common::Point vec1, Common::Point vec2) {
return (diff != 180);
}
-bool Actor::compare(Common::Point vec1, Common::Point vec2, Common::Point vec) {
+bool Actor::compare(const Common::Point &vec1, const Common::Point &vec2, const Common::Point &vec) {
if (vec.y >= vec1.y && vec.y <= vec2.y && vec.x >= vec1.x && vec.x <= vec2.x)
return true;
return false;
}
-int32 Actor::compareX(Common::Point vec1, Common::Point vec2, Common::Point vec) {
+int16 Actor::compareX(const Common::Point &vec1, const Common::Point &vec2, const Common::Point &vec) {
if (vec.y > vec2.y)
return 3;
@@ -4050,7 +4062,7 @@ int32 Actor::compareX(Common::Point vec1, Common::Point vec2, Common::Point vec)
return 0;
}
-int32 Actor::compareY(Common::Point vec1, Common::Point vec2, Common::Point vec) {
+int16 Actor::compareY(const Common::Point &vec1, const Common::Point &vec2, const Common::Point &vec) {
if (vec.y > vec2.y)
return 3;
diff --git a/engines/asylum/resources/actor.h b/engines/asylum/resources/actor.h
index 7a7cb1b67b..65140ec6bf 100644
--- a/engines/asylum/resources/actor.h
+++ b/engines/asylum/resources/actor.h
@@ -45,6 +45,12 @@ struct ActorData : public Common::Serializable {
Common::Point points[120];
ActorDirection directions[120];
+ ActorData() {
+ count = 0;
+ current = 0;
+ memset(&directions, 0, sizeof(directions));
+ }
+
void load(Common::SeekableReadStream *stream) {
count = stream->readUint32LE();
@@ -236,7 +242,7 @@ public:
* @param newDirection The new direction.
* @param frame The frame.
*/
- void setPosition(int32 newX, int32 newY, ActorDirection newDirection, uint32 frame);
+ void setPosition(int16 newX, int16 newY, ActorDirection newDirection, uint32 frame);
/**
* Query if the passed direction is default direction.
@@ -279,14 +285,14 @@ public:
// Unknown methods
bool process(const Common::Point &point);
- void processStatus(int32 actorX, int32 actorY, bool doSpeech);
+ void processStatus(int16 actorX, int16 actorY, bool doSpeech);
void processNext(ActorIndex nextActor, int32 actionAreaId, ActorDirection nextDirection, const Common::Point &nextPosition, bool invertPriority, const Common::Point &nextPositionOffset);
bool canInteract(Common::Point *point, int32* param);
bool canMove(Common::Point *point, ActorDirection direction, uint32 count, bool hasDelta);
void move(ActorDirection dir, uint32 distance);
void addReactionHive(int32 reactionIndex, int32 numberValue01Add);
void removeReactionHive(int32 reactionIndex, int32 numberValue01Substract);
- bool hasMoreReactions(int32 reactionIndex, int32 testNumberValue01);
+ bool hasMoreReactions(int32 reactionIndex, int32 testNumberValue01) const;
bool canMoveCheckActors(Common::Point *point, ActorDirection direction);
void updateAndDraw();
void update_409230();
@@ -319,7 +325,7 @@ public:
*
* @return The direction
*/
- static ActorDirection directionFromAngle(Common::Point vec1, Common::Point vec2);
+ static ActorDirection directionFromAngle(const Common::Point &vec1, const Common::Point &vec2);
/**
* Get the euclidean distance between the two vectors
@@ -329,7 +335,7 @@ public:
*
* @return the distance.
*/
- static uint32 euclidianDistance(Common::Point vec1, Common::Point vec2);
+ static uint32 euclidianDistance(const Common::Point &vec1, const Common::Point &vec2);
// Serializable
void saveLoadWithSerializer(Common::Serializer &s);
@@ -390,9 +396,8 @@ private:
int32 _field_948;
int32 _field_94C;
int32 _numberFlag01;
- int32 _numberStringWidth;
- int32 _numberStringX;
- int32 _numberStringY;
+ int16 _numberStringWidth;
+ Common::Point _numberPoint;
char _numberString01[8];
int32 _field_968;
int32 _transparency;
@@ -425,7 +430,7 @@ private:
void updatePumpkin(GameFlag flagToCheck, GameFlag flagToSet, ObjectId objectToUpdate, ObjectId objectToDisable);
void updateStatusEnabled();
- void updateStatusEnabledProcessStatus(int32 testX, int32 testY, uint32 counter, int32 setX, int32 setY);
+ void updateStatusEnabledProcessStatus(int16 testX, int16 testY, uint32 counter, int16 setX, int16 setY);
void updateStatus9();
@@ -469,7 +474,7 @@ private:
bool processActionTop(Common::Point source, const Common::Point &destination, Common::Array<int> *actions);
bool processActionDown(Common::Point source, const Common::Point &destination, Common::Array<int> *actions);
bool processAction(const Common::Point &source, Common::Array<int> *actions, Common::Point *point, ActorDirection direction, const Common::Point &destination, bool *flag);
- bool checkPath(Common::Array<int> *actions, const Common::Point &point, ActorDirection direction, uint32 loopcount);
+ bool checkPath(Common::Array<int> *actions, const Common::Point &point, ActorDirection direction, int16 loopcount);
bool checkAllActions(const Common::Point &pt, Common::Array<int> *actions);
//////////////////////////////////////////////////////////////////////////
@@ -494,7 +499,7 @@ private:
* @param vec1 The first vector.
* @param vec2 The second vector.
*/
- void updateCoordinates(Common::Point vec1, Common::Point vec2);
+ void updateCoordinates(const Common::Point &vec1, Common::Point vec2);
/**
* Hide Actor 0 and reset Actor 1 frame index
@@ -564,7 +569,7 @@ private:
* @param delta The delta.
* @param [in,out] point If non-null, the point.
*/
- static void updateCoordinatesForDirection(ActorDirection direction, int32 delta, Common::Point *point);
+ static void updateCoordinatesForDirection(ActorDirection direction, int16 delta, Common::Point *point);
/**
* Get the angle between the two vectors
@@ -574,7 +579,7 @@ private:
*
* @return the angle
*/
- static uint32 angleFromVectors(Common::Point vec1, Common::Point vec2);
+ static int32 angleFromVectors(const Common::Point &vec1, const Common::Point &vec2);
/**
* Create a new rect using the point, depending on the actor direction
@@ -583,7 +588,7 @@ private:
* @param direction The direction.
* @param point The point.
*/
- static void rectFromDirection(Common::Rect *rect, ActorDirection direction, Common::Point point);
+ static void rectFromDirection(Common::Rect *rect, ActorDirection direction, const Common::Point &point);
/**
* Compares the angle between two vectors
@@ -593,7 +598,7 @@ private:
*
* @return true if ...
*/
- static bool compareAngles(Common::Point vec1, Common::Point vec2);
+ static bool compareAngles(const Common::Point &vec1, const Common::Point &vec2);
/**
* Compares vector vec to two other vectors.
@@ -604,7 +609,7 @@ private:
*
* @return true if vec is between vec1 and vec2.
*/
- static bool compare(Common::Point vec1, Common::Point vec2, Common::Point vec);
+ static bool compare(const Common::Point &vec1, const Common::Point &vec2, const Common::Point &vec);
/**
* Compare vectors
@@ -615,7 +620,7 @@ private:
*
* @return value depending on whether vec.x is superior or inferior to each vector x coordinate
*/
- static int32 compareX(Common::Point vec1, Common::Point vec2, Common::Point vec);
+ static int16 compareX(const Common::Point &vec1, const Common::Point &vec2, const Common::Point &vec);
/**
* Compare vectors
@@ -626,7 +631,7 @@ private:
*
* @return value depending on whether vec.y is superior or inferior to each vector y coordinate
*/
- static int32 compareY(Common::Point vec1, Common::Point vec2, Common::Point vec);
+ static int16 compareY(const Common::Point &vec1, const Common::Point &vec2, const Common::Point &vec);
}; // end of class MainActor
diff --git a/engines/asylum/resources/data.h b/engines/asylum/resources/data.h
index 3d10478999..eb15fcdb01 100644
--- a/engines/asylum/resources/data.h
+++ b/engines/asylum/resources/data.h
@@ -203,7 +203,7 @@ public:
int32 getChapter2Data(uint32 index, int32 offset);
void setChapter2Counter(uint32 index, int32 val);
int32 getChapter2Counter(uint32 index) const;
- ActorIndex getChapter2FrameIndexOffset() const { return _chapter2FrameIndexOffset; }
+ int32 getChapter2FrameIndexOffset() const { return _chapter2FrameIndexOffset; }
void setChapter2FrameIndexOffset(int32 val) { _chapter2FrameIndexOffset = val; }
ActorIndex getChapter2ActorIndex() const { return _chapter2ActorIndex; }
void setChapter2ActorIndex(ActorIndex val) { _chapter2ActorIndex = val; }
Commit: bdec064f1225e2c0847a4b9bfa06f3868a49a476
https://github.com/scummvm/scummvm/commit/bdec064f1225e2c0847a4b9bfa06f3868a49a476
Author: Littleboy (littleboy at scummvm.org)
Date: 2021-05-17T15:37:21+02:00
Commit Message:
ASYLUM: More cleanup of Menu class
Changed paths:
engines/asylum/views/menu.cpp
diff --git a/engines/asylum/views/menu.cpp b/engines/asylum/views/menu.cpp
index c27227198e..6d54c4ba93 100644
--- a/engines/asylum/views/menu.cpp
+++ b/engines/asylum/views/menu.cpp
@@ -770,7 +770,7 @@ void Menu::updateLoadGame() {
if (index + _startIndex >= 25)
break;
- sprintf((char *)&text, "%d. %s ", index + _startIndex + 1, getSaveLoad()->getName(index + _startIndex).c_str());
+ sprintf((char *)&text, "%d. %s ", index + _startIndex + 1, getSaveLoad()->getName((uint32)(index + _startIndex)).c_str());
if (cursor.x < 30 || cursor.x > (30 + getText()->getWidth((char *)&text))
|| cursor.y < y || cursor.y > (y + 24))
@@ -790,7 +790,7 @@ void Menu::updateLoadGame() {
if (index + _startIndex >= 25)
break;
- sprintf((char *)&text, "%d. %s ", index + _startIndex + 1, getSaveLoad()->getName(index + _startIndex).c_str());
+ sprintf((char *)&text, "%d. %s ", index + _startIndex + 1, getSaveLoad()->getName((uint32)(index + _startIndex)).c_str());
if (cursor.x < 350 || cursor.x > (350 + getText()->getWidth((char *)&text))
|| cursor.y < y || cursor.y > (y + 24))
@@ -893,7 +893,7 @@ void Menu::updateSaveGame() {
if (index + _startIndex >= 25)
break;
- sprintf((char *)&text, "%d. %s ", index + _startIndex + 1, getSaveLoad()->getName(index + _startIndex).c_str());
+ sprintf((char *)&text, "%d. %s ", index + _startIndex + 1, getSaveLoad()->getName((uint32)(index + _startIndex)).c_str());
if (!_isEditingSavegameName) {
if (cursor.x < 30 || cursor.x > (30 + getText()->getWidth((char *)&text))
@@ -930,7 +930,7 @@ void Menu::updateSaveGame() {
if (index + _startIndex >= 25)
break;
- sprintf((char *)&text, "%d. %s ", index + _startIndex + 1, getSaveLoad()->getName(index + _startIndex).c_str());
+ sprintf((char *)&text, "%d. %s ", index + _startIndex + 1, getSaveLoad()->getName((uint32)(index + _startIndex)).c_str());
if (!_isEditingSavegameName) {
if (cursor.x < 350 || cursor.x > (350 + getText()->getWidth((char *)&text))
@@ -1041,7 +1041,7 @@ void Menu::updateDeleteGame() {
if (index + _startIndex >= 25)
break;
- sprintf((char *)&text, "%d. %s ", index + _startIndex + 1, getSaveLoad()->getName(index + _startIndex).c_str());
+ sprintf((char *)&text, "%d. %s ", index + _startIndex + 1, getSaveLoad()->getName((uint32)(index + _startIndex)).c_str());
if (cursor.x < 30 || cursor.x > (30 + getText()->getWidth((char *)&text))
|| cursor.y < y || cursor.y > (y + 24))
@@ -1061,7 +1061,7 @@ void Menu::updateDeleteGame() {
if (index + _startIndex >= 25)
break;
- sprintf((char *)&text, "%d. %s ", index + _startIndex + 1, getSaveLoad()->getName(index + _startIndex).c_str());
+ sprintf((char *)&text, "%d. %s ", index + _startIndex + 1, getSaveLoad()->getName((uint32)(index + _startIndex)).c_str());
if (cursor.x < 350 || cursor.x > (350 + getText()->getWidth((char *)&text))
|| cursor.y < y || cursor.y > (y + 24))
@@ -1295,14 +1295,14 @@ void Menu::updateAudioOptions() {
int32 volumeValue = cursor.x;
do {
getText()->loadFont(kFontYellow);
- getText()->draw(Common::Point(320, 29 * volumeIndex + 150), MAKE_RESOURCE(kResourcePackText, 1421 + volumeIndex));
+ getText()->draw(Common::Point(320, (int16)(29 * volumeIndex + 150)), MAKE_RESOURCE(kResourcePackText, 1421 + volumeIndex));
switchFont(cursor.x < 350 || cursor.x > (sizeMinus + 350) || cursor.y < (29 * volumeIndex + 150) || cursor.y > (29 * (volumeIndex + 6)));
- getText()->setPosition(Common::Point(350, 29 * volumeIndex + 150));
+ getText()->setPosition(Common::Point(350, (int16)(29 * volumeIndex + 150)));
getText()->draw("-");
switchFont(cursor.x < (sizeMinus + 360) || cursor.x > (sizeMinus + sizePlus + 360) || cursor.y < (29 * volumeIndex + 150) || cursor.y > (29 * (volumeIndex + 6)));
- getText()->setPosition(Common::Point(sizeMinus + 360, 29 * volumeIndex + 150));
+ getText()->setPosition(Common::Point(sizeMinus + 360, (int16)(29 * volumeIndex + 150)));
getText()->draw("+");
switch(volumeIndex) {
@@ -1335,7 +1335,7 @@ void Menu::updateAudioOptions() {
}
getText()->loadFont(kFontYellow);
- getText()->setPosition(Common::Point(sizePlus + sizeMinus + 365, 29 * volumeIndex + 150));
+ getText()->setPosition(Common::Point(sizePlus + sizeMinus + 365, (int16)(29 * volumeIndex + 150)));
if (volumeValue > 0) {
for (int32 i = 0; i < volumeValue; i++)
getText()->drawChar(']');
@@ -1352,10 +1352,10 @@ void Menu::updateAudioOptions() {
//////////////////////////////////////////////////////////////////////////
//
getText()->loadFont(kFontYellow);
- getText()->draw(Common::Point(320, 29 *volumeIndex + 150), MAKE_RESOURCE(kResourcePackText, 1427));
+ getText()->draw(Common::Point(320, (int16)(29 *volumeIndex + 150)), MAKE_RESOURCE(kResourcePackText, 1427));
switchFont(cursor.x < 350 || cursor.x > (350 + getText()->getWidth(Config.reverseStereo ? MAKE_RESOURCE(kResourcePackText, 1428) : MAKE_RESOURCE(kResourcePackText, 1429))) || cursor.y < (29 * volumeIndex + 150) || cursor.y > (29 * (volumeIndex + 6)));
- getText()->setPosition(Common::Point(350, 29 * volumeIndex + 150));
+ getText()->setPosition(Common::Point(350, (int16)(29 * volumeIndex + 150)));
getText()->draw(Config.reverseStereo ? MAKE_RESOURCE(kResourcePackText, 1428) : MAKE_RESOURCE(kResourcePackText, 1429));
switchFont(cursor.x < 220 || cursor.x > (220 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 1430))) || cursor.y < 360 || cursor.y > (360 + 24));
@@ -1447,9 +1447,9 @@ void Menu::updateKeyboardConfig() {
do {
getText()->loadFont(kFontYellow);
if ((getScene() && getWorld()->chapter == 9) || keyIndex < 3) {
- getText()->draw(Common::Point(320, 29 * keyIndex + 150), MAKE_RESOURCE(kResourcePackText, 1439 + keyIndex));
+ getText()->draw(Common::Point(320, (int16)(29 * keyIndex + 150)), MAKE_RESOURCE(kResourcePackText, 1439 + keyIndex));
} else {
- getText()->draw(Common::Point(320, 29 * keyIndex + 150), MAKE_RESOURCE(kResourcePackText, 1445));
+ getText()->draw(Common::Point(320, (int16)(29 * keyIndex + 150)), MAKE_RESOURCE(kResourcePackText, 1445));
}
switch (keyIndex) {
@@ -1481,7 +1481,7 @@ void Menu::updateKeyboardConfig() {
break;
}
- getText()->setPosition(Common::Point(350, 29 * keyIndex + 150));
+ getText()->setPosition(Common::Point(350, (int16)(29 * keyIndex + 150)));
if (keyIndex == _selectedShortcutIndex) {
getText()->loadFont(kFontBlue);
@@ -1544,7 +1544,7 @@ void Menu::updateShowCredits() {
if (maxBound < 480 && maxBound > 448)
getText()->setTransTableNum(3 - (479 - maxBound) / 8);
- getText()->setPosition(Common::Point(320, step + _startIndex));
+ getText()->setPosition(Common::Point(320, (int16)(step + _startIndex)));
getText()->draw(MAKE_RESOURCE(kResourcePackText, 1447 + index));
getText()->setTransTableNum(0);
}
@@ -1642,7 +1642,7 @@ void Menu::clickLoadGame() {
int32 index = 0;
for (int32 y = 150; y < 324; y += 29) {
if (cursor.x >= 350) {
- sprintf((char *)&text, "%d. %s ", index + _startIndex + 7, getSaveLoad()->getName(index + _startIndex + 6).c_str());
+ sprintf((char *)&text, "%d. %s ", index + _startIndex + 7, getSaveLoad()->getName((uint32)(index + _startIndex + 6)).c_str());
if (cursor.x <= (350 + getText()->getWidth((char *)&text))
&& cursor.y >= y
@@ -1656,7 +1656,7 @@ void Menu::clickLoadGame() {
}
}
} else if (cursor.x >= 30) {
- sprintf((char *)&text, "%d. %s ", index + _startIndex + 1, getSaveLoad()->getName(index + _startIndex).c_str());
+ sprintf((char *)&text, "%d. %s ", index + _startIndex + 1, getSaveLoad()->getName((uint32)(index + _startIndex)).c_str());
if (cursor.x <= (30 + getText()->getWidth((char *)&text))
&& cursor.y >= y
@@ -1736,7 +1736,7 @@ void Menu::clickSaveGame() {
int32 index = 0;
for (int16 y = 150; y < 324; y += 29) {
if (cursor.x >= 350) {
- sprintf((char *)&text, "%d. %s ", index + _startIndex + 7, getSaveLoad()->getName(index + _startIndex + 6).c_str());
+ sprintf((char *)&text, "%d. %s ", index + _startIndex + 7, getSaveLoad()->getName((uint32)(index + _startIndex + 6)).c_str());
if (cursor.x <= (30 + getText()->getWidth((char *)&text))
&& cursor.y >= y
@@ -1757,7 +1757,7 @@ void Menu::clickSaveGame() {
}
}
} else if (cursor.x >= 30) {
- sprintf((char *)&text, "%d. %s ", index + _startIndex + 1, getSaveLoad()->getName(index + _startIndex).c_str());
+ sprintf((char *)&text, "%d. %s ", index + _startIndex + 1, getSaveLoad()->getName((uint32)(index + _startIndex)).c_str());
if (cursor.x <= (350 + getText()->getWidth((char *)&text))
&& cursor.y >= y
@@ -1841,7 +1841,7 @@ void Menu::clickDeleteGame() {
int32 index = 0;
for (int16 y = 150; y < 324; y += 29) {
if (cursor.x >= 350) {
- sprintf((char *)&text, "%d. %s ", index + _startIndex + 7, getSaveLoad()->getName(index + _startIndex + 6).c_str());
+ sprintf((char *)&text, "%d. %s ", index + _startIndex + 7, getSaveLoad()->getName((uint32)(index + _startIndex + 6)).c_str());
if (cursor.x <= (30 + getText()->getWidth((char *)&text))
&& cursor.y >= y
@@ -1855,7 +1855,7 @@ void Menu::clickDeleteGame() {
}
}
} else if (cursor.x >= 30) {
- sprintf((char *)&text, "%d. %s ", index + _startIndex + 1, getSaveLoad()->getName(index + _startIndex).c_str());
+ sprintf((char *)&text, "%d. %s ", index + _startIndex + 1, getSaveLoad()->getName((uint32)(index + _startIndex)).c_str());
if (cursor.x <= (350 + getText()->getWidth((char *)&text))
&& cursor.y >= y
@@ -1935,7 +1935,7 @@ void Menu::clickViewMovies() {
uint32 movieIndex = (uint32)(index + _startIndex + 6);
if (movieIndex <= _movieCount) {
// The original checks for the proper cd, but we can skip that since we have all data on disk
- _movieIndex = _movieList[movieIndex];
+ _movieIndex = (uint32)_movieList[movieIndex];
// FIXME
//if (moviesCd[_movieIndex] != getSharedData()->cdNumber) {
@@ -2370,8 +2370,8 @@ void Menu::keyKeyboardConfig(const AsylumEvent &evt) {
if (evt.kbd.ascii > 255 || !isalnum(evt.kbd.ascii))
return;
- if (!Config.isKeyAssigned(evt.kbd.ascii) || *keyCode == evt.kbd.ascii) {
- *keyCode = evt.kbd.ascii;
+ if (!Config.isKeyAssigned((char)evt.kbd.ascii) || *keyCode == (char)evt.kbd.ascii) {
+ *keyCode = (char)evt.kbd.ascii;
_selectedShortcutIndex = -1;
getCursor()->show();
}
Commit: 341bf996148947b3cf29c64cfdacd56ea3f6a660
https://github.com/scummvm/scummvm/commit/341bf996148947b3cf29c64cfdacd56ea3f6a660
Author: Littleboy (littleboy at scummvm.org)
Date: 2021-05-17T15:37:21+02:00
Commit Message:
ASYLUM: Cleanup Screen class
Changed paths:
engines/asylum/resources/encounters.cpp
engines/asylum/resources/object.cpp
engines/asylum/resources/script.cpp
engines/asylum/system/screen.cpp
engines/asylum/system/screen.h
engines/asylum/system/text.cpp
engines/asylum/system/text.h
engines/asylum/views/menu.cpp
engines/asylum/views/video.cpp
diff --git a/engines/asylum/resources/encounters.cpp b/engines/asylum/resources/encounters.cpp
index 6b579451c7..21068fd1ba 100644
--- a/engines/asylum/resources/encounters.cpp
+++ b/engines/asylum/resources/encounters.cpp
@@ -828,7 +828,7 @@ bool Encounter::drawBackground() {
_point,
getWorld()->getObjectById(kObjectCave)->getResourceId(),
origin,
- _background.transTableNum);
+ (uint32)_background.transTableNum);
} else {
Common::Point origin(getWorld()->xLeft, getWorld()->yTop);
@@ -837,7 +837,7 @@ bool Encounter::drawBackground() {
_point,
getWorld()->backgroundImage,
origin,
- _background.transTableNum);
+ (uint32)_background.transTableNum);
}
} else {
getScreen()->draw(_background.resourceId, _background.frameIndex, _point);
@@ -875,11 +875,11 @@ bool Encounter::drawPortraits() {
_portrait1.frameIndex,
_point + Common::Point(5, 5));
else
- getScreen()->draw(_portrait1.resourceId,
- _portrait1.frameIndex,
- _point + Common::Point(5, 5),
- kDrawFlagNone,
- _portrait1.transTableNum);
+ getScreen()->drawTransparent(_portrait1.resourceId,
+ _portrait1.frameIndex,
+ _point + Common::Point(5, 5),
+ kDrawFlagNone,
+ (uint32)_portrait1.transTableNum);
if (_portrait1.transTableNum != _portrait1.transTableMax) {
if (_portrait1.transTableNum <= _portrait1.transTableMax)
@@ -907,11 +907,11 @@ bool Encounter::drawPortraits() {
_portrait2.frameIndex,
Common::Point(_point.x + _background.rect.width() - (frameRect.width() + 6), _point.y + 5));
else
- getScreen()->draw(_portrait2.resourceId,
- _portrait2.frameIndex,
- Common::Point(_point.x + _background.rect.width() - (frameRect.width() + 6), _point.y + 5),
- kDrawFlagNone,
- _portrait2.transTableNum);
+ getScreen()->drawTransparent(_portrait2.resourceId,
+ _portrait2.frameIndex,
+ Common::Point(_point.x + _background.rect.width() - (frameRect.width() + 6), _point.y + 5),
+ kDrawFlagNone,
+ (uint32)_portrait2.transTableNum);
if (_portrait2.transTableNum != _portrait2.transTableMax) {
if (_portrait2.transTableNum <= _portrait2.transTableMax)
@@ -960,11 +960,11 @@ void Encounter::drawStructs() {
break;
case -1:
- getScreen()->draw(_drawingStructs[0].resourceId,
- _drawingStructs[0].frameIndex,
- _drawingStructs[0].point2,
- kDrawFlagNone,
- 0);
+ getScreen()->drawTransparent(_drawingStructs[0].resourceId,
+ _drawingStructs[0].frameIndex,
+ _drawingStructs[0].point2,
+ kDrawFlagNone,
+ 0);
_drawingStructs[0].status = 0;
break;
@@ -972,11 +972,11 @@ void Encounter::drawStructs() {
case 0:
case 1:
case 2:
- getScreen()->draw(_drawingStructs[0].resourceId,
- _drawingStructs[0].frameIndex,
- _drawingStructs[0].point2,
- kDrawFlagNone,
- val);
+ getScreen()->drawTransparent(_drawingStructs[0].resourceId,
+ _drawingStructs[0].frameIndex,
+ _drawingStructs[0].point2,
+ kDrawFlagNone,
+ (uint32)val);
if (_drawingStructs[0].status == 1)
++_drawingStructs[0].transTableNum;
@@ -1015,11 +1015,11 @@ void Encounter::drawStructs() {
break;
case -1:
- getScreen()->draw(_drawingStructs[1].resourceId,
- _drawingStructs[1].frameIndex,
- _drawingStructs[1].point2,
- kDrawFlagNone,
- 0);
+ getScreen()->drawTransparent(_drawingStructs[1].resourceId,
+ _drawingStructs[1].frameIndex,
+ _drawingStructs[1].point2,
+ kDrawFlagNone,
+ 0);
_drawingStructs[1].status = 0;
break;
@@ -1027,11 +1027,11 @@ void Encounter::drawStructs() {
case 0:
case 1:
case 2:
- getScreen()->draw(_drawingStructs[1].resourceId,
- _drawingStructs[1].frameIndex,
- _drawingStructs[1].point2,
- kDrawFlagNone,
- val);
+ getScreen()->drawTransparent(_drawingStructs[1].resourceId,
+ _drawingStructs[1].frameIndex,
+ _drawingStructs[1].point2,
+ kDrawFlagNone,
+ (uint32)val);
if (_drawingStructs[1].status == 1)
++_drawingStructs[1].transTableNum;
diff --git a/engines/asylum/resources/object.cpp b/engines/asylum/resources/object.cpp
index f37f50ec61..8bb6152880 100644
--- a/engines/asylum/resources/object.cpp
+++ b/engines/asylum/resources/object.cpp
@@ -268,7 +268,7 @@ void Object::draw() {
if (_transparency <= 0 || _transparency >= 4 || Config.performance <= 1) {
getScreen()->addGraphicToQueue(_resourceId, _frameIndex, point, (DrawFlags)((flags >> 11) & kDrawFlagMirrorLeftRight), _transparency - 3, _priority);
} else {
- getScreen()->addGraphicToQueueCrossfade(_resourceId, _frameIndex, point, getWorld()->backgroundImage, Common::Point(getWorld()->xLeft, getWorld()->yTop), _transparency - 1);
+ getScreen()->addGraphicToQueueCrossfade(_resourceId, _frameIndex, point, getWorld()->backgroundImage, Common::Point(getWorld()->xLeft, getWorld()->yTop), (uint32)(_transparency - 1));
}
}
diff --git a/engines/asylum/resources/script.cpp b/engines/asylum/resources/script.cpp
index 8cf68d9f38..1fbbadf44a 100644
--- a/engines/asylum/resources/script.cpp
+++ b/engines/asylum/resources/script.cpp
@@ -611,7 +611,7 @@ END_OPCODE
IMPLEMENT_OPCODE(SetActorPosition)
Actor *actor = getScene()->getActor(cmd->param1);
- actor->setPosition(cmd->param2, cmd->param3, (ActorDirection)cmd->param4, (uint32)cmd->param5);
+ actor->setPosition((int16)cmd->param2, (int16)cmd->param3, (ActorDirection)cmd->param4, (uint32)cmd->param5);
END_OPCODE
//////////////////////////////////////////////////////////////////////////
@@ -708,7 +708,7 @@ IMPLEMENT_OPCODE(JumpAndSetDirection)
} else if ((actor->getPoint1()->x + actor->getPoint2()->x) == cmd->param2 && (actor->getPoint1()->y + actor->getPoint2()->y) == cmd->param3) {
actor->updateFromDirection((ActorDirection)cmd->param4);
} else {
- actor->processStatus(cmd->param2, cmd->param3, (bool)cmd->param4);
+ actor->processStatus((int16)cmd->param2, (int16)cmd->param3, (bool)cmd->param4);
if (cmd->param5 == 1) {
cmd->param5 = 2;
diff --git a/engines/asylum/system/screen.cpp b/engines/asylum/system/screen.cpp
index 4b62a27e19..574f5b3d42 100644
--- a/engines/asylum/system/screen.cpp
+++ b/engines/asylum/system/screen.cpp
@@ -41,7 +41,7 @@ namespace Asylum {
int g_debugDrawRects;
-#define TRANSPARENCY_TABLE_SIZE 256 * 256
+#define TRANSPARENCY_TABLE_SIZE (256 * 256)
Screen::Screen(AsylumEngine *vm) : _vm(vm) ,
_useColorKey(false), _transTableCount(0), _transTable(NULL), _transTableBuffer(NULL) {
@@ -68,6 +68,9 @@ Screen::~Screen() {
clearTransTables();
+ _transTableBuffer = NULL;
+ _transTable = NULL;
+
// Zero-out passed pointers
_vm = NULL;
}
@@ -83,7 +86,7 @@ void Screen::draw(ResourceId resourceId, uint32 frameIndex, const Common::Point
draw(resourceId, frameIndex, source, flags, kResourceNone, Common::Point(0, 0), colorKey);
}
-void Screen::draw(ResourceId resourceId, uint32 frameIndex, const Common::Point &source, DrawFlags flags, int32 transTableNum) {
+void Screen::drawTransparent(ResourceId resourceId, uint32 frameIndex, const Common::Point &source, DrawFlags flags, uint32 transTableNum) {
byte *index = _transTable;
selectTransTable(transTableNum);
@@ -105,7 +108,7 @@ void Screen::draw(GraphicResource *resource, uint32 frameIndex, const Common::Po
draw(resource, frameIndex, source, flags, kResourceNone, Common::Point(0, 0), colorKey);
}
-void Screen::draw(GraphicResource *resource, uint32 frameIndex, const Common::Point &source, DrawFlags flags, int32 transTableNum) {
+void Screen::drawTransparent(GraphicResource *resource, uint32 frameIndex, const Common::Point &source, DrawFlags flags, uint32 transTableNum) {
byte *index = _transTable;
selectTransTable(transTableNum);
@@ -128,16 +131,16 @@ void Screen::draw(GraphicResource *resource, uint32 frameIndex, const Common::Po
if (flags & kDrawFlagMirrorLeftRight) {
if (_flag == -1) {
if ((resource->getData().flags & 15) >= 2) {
- dest.left = source.x + resource->getData().maxWidth - frame->getWidth() - frame->x;
+ dest.left = source.x + (int16)resource->getData().maxWidth - ((int16)frame->getWidth() + frame->x);
}
} else {
- dest.left += 2 * (_flag - (frame->getHeight() * 2 - frame->x));
+ dest.left += (int16)(2 * (_flag - (frame->getHeight() * 2 - frame->x)));
}
}
dest.top = source.y + frame->y;
- dest.right = dest.left + frame->getWidth();
- dest.bottom = dest.top + frame->getHeight();
+ dest.right = dest.left + (int16)frame->getWidth();
+ dest.bottom = dest.top + (int16)frame->getHeight();
src.left = 0;
src.top = 0;
@@ -154,12 +157,12 @@ void Screen::draw(GraphicResource *resource, uint32 frameIndex, const Common::Po
resourceMask = getResource()->get(resourceIdDestination);
// Adjust masked rectangles
- srcMask = Common::Rect(0, 0, resourceMask->getData(4), resourceMask->getData(0));
+ srcMask = Common::Rect(0, 0, (int16)resourceMask->getData(4), (int16)resourceMask->getData(0));
destMask = Common::Rect(destination.x,
destination.y,
- destination.x + resourceMask->getData(4),
- destination.y + resourceMask->getData(0));
+ destination.x + (int16)resourceMask->getData(4),
+ destination.y + (int16)resourceMask->getData(0));
clip(&srcMask, &destMask, 0);
@@ -177,10 +180,14 @@ void Screen::draw(GraphicResource *resource, uint32 frameIndex, const Common::Po
// Set the color key (always 0 if set)
_useColorKey = colorKey;
- if (masked)
- blitMasked(frame, &src, resourceMask->data + 8, &srcMask, &destMask, resourceMask->getData(4), &dest, flags);
- else
+ if (masked) {
+ if (!resourceMask)
+ error("[Screen::draw] Trying to draw masked with an invalid resource mask");
+
+ blitMasked(frame, &src, resourceMask->data + 8, &srcMask, &destMask, (uint16)resourceMask->getData(4), &dest, flags);
+ } else {
blit(frame, &src, &dest, flags);
+ }
}
//////////////////////////////////////////////////////////////////////////
@@ -200,7 +207,7 @@ void Screen::drawWideScreenBars(int16 barSize) const {
}
}
-void Screen::fillRect(int32 x, int32 y, int32 width, int32 height, int32 color) {
+void Screen::fillRect(int16 x, int16 y, int16 width, int16 height, uint32 color) {
_backBuffer.fillRect(Common::Rect(x, y, x + width, y + height), color);
}
@@ -208,8 +215,8 @@ void Screen::copyBackBufferToScreen() {
_vm->_system->copyRectToScreen((byte *)_backBuffer.pixels, _backBuffer.w, 0, 0, _backBuffer.w, _backBuffer.h);
}
-void Screen::clip(Common::Rect *source, Common::Rect *destination, int32 flags) {
- int32 diffLeft = _clipRect.left - destination->left;
+void Screen::clip(Common::Rect *source, Common::Rect *destination, int32 flags) const {
+ int16 diffLeft = _clipRect.left - destination->left;
if (diffLeft > 0) {
destination->left = _clipRect.left;
@@ -219,7 +226,7 @@ void Screen::clip(Common::Rect *source, Common::Rect *destination, int32 flags)
source->left += diffLeft;
}
- int32 diffRight = destination->right - _clipRect.right;
+ int16 diffRight = destination->right - _clipRect.right;
if (diffRight > 0) {
destination->right -= diffRight;
@@ -229,13 +236,13 @@ void Screen::clip(Common::Rect *source, Common::Rect *destination, int32 flags)
source->right -= diffRight;
}
- int32 diffTop = _clipRect.top - destination->top;
+ int16 diffTop = _clipRect.top - destination->top;
if (diffTop > 0) {
destination->top = _clipRect.top;
source->top += diffTop;
}
- int32 diffBottom = destination->bottom - _clipRect.bottom;
+ int16 diffBottom = destination->bottom - _clipRect.bottom;
if (diffBottom > 0) {
source->bottom -= diffBottom;
destination->bottom -= diffBottom;
@@ -276,7 +283,7 @@ void Screen::loadPalette() {
void Screen::setPalette(ResourceId id) {
byte *data = getPaletteData(id);
- setupPalette(data + 4, data[2], *(uint16 *)data);
+ setupPalette(data + 4, data[2], READ_LE_UINT16(data));
}
void Screen::setMainPalette(const byte *data) {
@@ -299,9 +306,9 @@ void Screen::setupPalette(byte *buffer, int start, int count) {
palette += 4 * start;
for (int32 i = 0; i < count; i++) {
- palette[0] = buffer[0] * 4;
- palette[1] = buffer[1] * 4;
- palette[2] = buffer[2] * 4;
+ palette[0] = (byte )(buffer[0] * 4);
+ palette[1] = (byte )(buffer[1] * 4);
+ palette[2] = (byte )(buffer[2] * 4);
buffer += 3;
palette += 3;
@@ -339,9 +346,9 @@ void Screen::updatePalette(int32 param) {
paletteData += 4;
for (uint32 j = 3; j < ARRAYSIZE(_mainPalette) - 3; j += 3) {
- _mainPalette[j] = 4 * paletteData[j] + param * (4 * paletteData[j] - _currentPalette[j]);
- _mainPalette[j + 1] = 4 * paletteData[j + 1] + param * (4 * paletteData[j + 1] - _currentPalette[j + 1]);
- _mainPalette[j + 2] = 4 * paletteData[j + 2] + param * (4 * paletteData[j + 2] - _currentPalette[j + 2]);
+ _mainPalette[j] = (byte)(4 * paletteData[j] + param * (4 * paletteData[j] - _currentPalette[j]));
+ _mainPalette[j + 1] = (byte)(4 * paletteData[j + 1] + param * (4 * paletteData[j + 1] - _currentPalette[j + 1]));
+ _mainPalette[j + 2] = (byte)(4 * paletteData[j + 2] + param * (4 * paletteData[j + 2] - _currentPalette[j + 2]));
}
}
}
@@ -387,9 +394,9 @@ void Screen::stopPaletteFade(char red, char green, char blue) {
palette += 4;
for (uint32 i = 0; i < ARRAYSIZE(_mainPalette) - 3; i += 3) {
- palette[0] = red;
- palette[1] = green;
- palette[2] = blue;
+ palette[0] = (byte)red;
+ palette[1] = (byte)green;
+ palette[2] = (byte)blue;
palette += 3;
}
@@ -418,14 +425,14 @@ void Screen::paletteFade(uint32 start, int32 ticksWait, int32 delta) {
for (int32 i = 1; i < colorDelta; i++) {
for (uint32 j = 3; j < ARRAYSIZE(_mainPalette); j += 3) {
- _mainPalette[j] = palette[j] + i * (red - palette[j]) / colorDelta;
- _mainPalette[j + 1] = palette[j + 1] + i * (green - palette[j + 1]) / colorDelta;
- _mainPalette[j + 2] = palette[j + 2] + i * (blue - palette[j + 2]) / colorDelta;
+ _mainPalette[j] = (byte)(palette[j] + i * (red - palette[j]) / colorDelta);
+ _mainPalette[j + 1] = (byte)(palette[j + 1] + i * (green - palette[j + 1]) / colorDelta);
+ _mainPalette[j + 2] = (byte)(palette[j + 2] + i * (blue - palette[j + 2]) / colorDelta);
}
setupPalette(NULL, 0, 0);
- g_system->delayMillis(ticksWait);
+ g_system->delayMillis((uint32)ticksWait);
// Poll events (this ensure we don't freeze the screen)
Common::Event ev;
@@ -450,15 +457,15 @@ void Screen::paletteFadeWorker(ResourceId id, int32 ticksWait, int32 delta) {
memcpy(&palette, &_mainPalette, sizeof(palette));
// Adjust palette using the target palette data
- uint32 count = *(int16 *)data;
- uint32 start = data[2];
+ int16 count = READ_LE_UINT16(data);
+ byte start = data[2];
if (count > 0) {
byte *pData = data + 4;
- for (uint32 i = 0; i < count; i++) {
- palette[i + start] = 4 * pData[0];
- palette[i + start + 1] = 4 * pData[1];
- palette[i + start + 2] = 4 * pData[2];
+ for (int16 i = 0; i < count; i++) {
+ palette[i + start] = (byte)(4 * pData[0]);
+ palette[i + start + 1] = (byte)(4 * pData[1]);
+ palette[i + start + 2] = (byte)(4 * pData[2]);
pData += 3;
}
@@ -471,15 +478,15 @@ void Screen::paletteFadeWorker(ResourceId id, int32 ticksWait, int32 delta) {
int32 colorDelta = delta + 1;
for (int32 i = 1; i < colorDelta; i++) {
for (uint32 j = 3; j < ARRAYSIZE(_mainPalette); j += 3) {
- _mainPalette[j] = original[j] + i * (palette[j] - original[j]) / colorDelta;
- _mainPalette[j + 1] = original[j + 1] + i * (palette[j + 1] - original[j + 1]) / colorDelta;
- _mainPalette[j + 2] = original[j + 2] + i * (palette[j + 2] - original[j + 2]) / colorDelta;
+ _mainPalette[j] = (byte)(original[j] + i * (palette[j] - original[j]) / colorDelta);
+ _mainPalette[j + 1] = (byte)(original[j + 1] + i * (palette[j + 1] - original[j + 1]) / colorDelta);
+ _mainPalette[j + 2] = (byte)(original[j + 2] + i * (palette[j + 2] - original[j + 2]) / colorDelta);
}
setupPalette(NULL, 0, 0);
// Original waits for event and so can be interrupted in the middle of the wait
- g_system->delayMillis(ticksWait);
+ g_system->delayMillis((uint32)ticksWait);
if (_fadeStop)
break;
@@ -516,7 +523,7 @@ void Screen::setPaletteGamma(byte *data, byte *target) {
data += 4;
for (int32 i = 1; i < 256; i++) {
- int color = 0;
+ byte color = 0;
if (data[i * 3 + 0] > 0)
color = data[i * 3 + 0];
if (data[i * 3 + 1] > color)
@@ -524,15 +531,18 @@ void Screen::setPaletteGamma(byte *data, byte *target) {
if (data[i * 3 + 2] > color)
color = data[i * 3 + 2];
+ /*if (color == 0)
+ error("[Screen::setPaletteGamma] Invalid color");*/
+
int gamma = color + (Config.gammaLevel * (63 - color) + 31) / 63;
if (gamma) {
if (data[i * 3 + 0])
- target[i * 3 + 0] = 4 * ((color >> 1) + data[i * 3 + 0] * gamma) / color;
+ target[i * 3 + 0] = (byte)(4 * ((color >> 1) + data[i * 3 + 0] * gamma) / color);
if (data[i * 3 + 1])
- target[i * 3 + 1] = 4 * ((color >> 1) + data[i * 3 + 1] * gamma) / color;
+ target[i * 3 + 1] = (byte)(4 * ((color >> 1) + data[i * 3 + 1] * gamma) / color);
if (data[i * 3 + 2])
- target[i * 3 + 2] = 4 * ((color >> 1) + data[i * 3 + 2] * gamma) / color;
+ target[i * 3 + 2] = (byte)(4 * ((color >> 1) + data[i * 3 + 2] * gamma) / color);
}
}
}
@@ -575,6 +585,9 @@ void Screen::setupTransTables(uint32 count, ...) {
if (!_transTableBuffer) {
_transTableBuffer = (byte *)malloc(count * TRANSPARENCY_TABLE_SIZE);
+ if (!_transTableBuffer)
+ error("[Screen::setupTransTables] Cannot allocate memory for transparency table buffer");
+
_transTable = _transTableBuffer;
}
@@ -595,6 +608,9 @@ void Screen::clearTransTables() {
}
void Screen::selectTransTable(uint32 index) {
+ if (!_transTableBuffer)
+ error("[Screen::selectTransTable] Transparency table buffer not initialized");
+
if (index >= _transTableCount)
return;
@@ -633,7 +649,7 @@ void Screen::addGraphicToQueueMasked(ResourceId resourceId, uint32 frameIndex, c
_queueItems.push_back(item);
}
-void Screen::addGraphicToQueueCrossfade(ResourceId resourceId, uint32 frameIndex, Common::Point point, int32 objectResourceId, Common::Point objectPoint, int32 transTableNum) {
+void Screen::addGraphicToQueueCrossfade(ResourceId resourceId, uint32 frameIndex, const Common::Point &point, int32 objectResourceId, const Common::Point &destination, uint32 transTableNum) {
// Save current transparency index
byte *transparencyIndex= _transTable;
selectTransTable(transTableNum);
@@ -656,13 +672,13 @@ void Screen::addGraphicToQueueCrossfade(ResourceId resourceId, uint32 frameIndex
_useColorKey = true;
blitCrossfade((byte *)_backBuffer.pixels + dst.top * _backBuffer.pitch + dst.left,
- (byte *)frame->surface.pixels + src.top * frame->surface.pitch + src.left,
- (byte *)frameObject->surface.pixels + (objectPoint.y + dst.top) * frameObject->surface.pitch + (dst.left + objectPoint.x),
+ (byte *)frame->surface.pixels + src.top * frame->surface.pitch + src.left,
+ (byte *)frameObject->surface.pixels + (destination.y + dst.top) * frameObject->surface.pitch + (dst.left + destination.x),
dst.height(),
dst.width(),
- frame->surface.pitch - dst.width(),
- _backBuffer.pitch - dst.width(),
- frameObject->surface.pitch - dst.width());
+ (uint16)(frame->surface.pitch - dst.width()),
+ (uint16)(_backBuffer.pitch - dst.width()),
+ (uint16)(frameObject->surface.pitch - dst.width()));
}
// Restore transparency table
@@ -687,7 +703,7 @@ void Screen::drawGraphicsInQueue() {
if (item->transTableNum <= 0 || Config.performance <= 1)
draw(item->resourceId, item->frameIndex, item->source, item->flags);
else
- draw(item->resourceId, item->frameIndex, item->source, item->flags, item->transTableNum - 1);
+ drawTransparent(item->resourceId, item->frameIndex, item->source, item->flags, (uint32)(item->transTableNum - 1));
} else if (item->type == kGraphicItemMasked) {
draw(item->resourceId, item->frameIndex, item->source, item->flags, item->resourceIdDestination, item->destination);
}
@@ -733,7 +749,10 @@ void Screen::deleteGraphicFromQueue(ResourceId resourceId) {
// Graphic Data
//////////////////////////////////////////////////////////////////////////
void Screen::blit(GraphicFrame *frame, Common::Rect *source, Common::Rect *destination, int32 flags) {
- if (flags & 0x80000000) {
+ if (!_transTable)
+ error("[Screen::blit] Transparency table buffer not initialized");
+
+ if ((uint32)flags & 0x80000000) {
// Used in the menu (and more?)
int32 flagSet = flags & 0x7FFFFFFF;
@@ -752,15 +771,15 @@ void Screen::blit(GraphicFrame *frame, Common::Rect *source, Common::Rect *desti
(byte *)frame->surface.pixels + source->top * frame->surface.pitch + source->right - 1,
destination->height(),
destination->width(),
- destination->width() + frame->surface.pitch,
- frame->surface.pitch - destination->width());
+ (uint16)destination->width() + frame->surface.pitch,
+ (uint16)(frame->surface.pitch - destination->width()));
} else {
blitTranstable((byte *)_backBuffer.pixels + destination->top * _backBuffer.pitch + destination->left,
(byte *)frame->surface.pixels + source->top * frame->surface.pitch + source->left,
destination->height(),
destination->width(),
- frame->surface.pitch - destination->width(),
- _backBuffer.pitch - destination->width());
+ frame->surface.pitch - (uint16)destination->width(),
+ _backBuffer.pitch - (uint16)destination->width());
}
} else if (flagSet) {
if (isMirrored) {
@@ -769,15 +788,15 @@ void Screen::blit(GraphicFrame *frame, Common::Rect *source, Common::Rect *desti
(byte *)frame->surface.pixels + source->top * frame->surface.pitch + source->right,
destination->height(),
destination->width(),
- frame->surface.pitch + destination->width(),
- _backBuffer.pitch - destination->width());
+ frame->surface.pitch + (uint16)destination->width(),
+ _backBuffer.pitch - (uint16)destination->width());
} else {
blitMirrored((byte *)_backBuffer.pixels + destination->top * _backBuffer.pitch + destination->left,
(byte *)frame->surface.pixels + source->top * frame->surface.pitch + source->right,
destination->height(),
destination->width(),
- frame->surface.pitch + destination->width(),
- _backBuffer.pitch - destination->width());
+ frame->surface.pitch + (uint16)destination->width(),
+ _backBuffer.pitch - (uint16)destination->width());
}
}
} else {
@@ -786,15 +805,15 @@ void Screen::blit(GraphicFrame *frame, Common::Rect *source, Common::Rect *desti
(byte *)frame->surface.pixels + source->top * frame->surface.pitch + source->left,
destination->height(),
destination->width(),
- frame->surface.pitch - destination->width(),
- _backBuffer.pitch - destination->width());
+ frame->surface.pitch - (uint16)destination->width(),
+ _backBuffer.pitch - (uint16)destination->width());
} else {
blitRaw((byte *)_backBuffer.pixels + destination->top * _backBuffer.pitch + destination->left,
(byte *)frame->surface.pixels + source->top * frame->surface.pitch + source->left,
destination->height(),
destination->width(),
- frame->surface.pitch - destination->width(),
- _backBuffer.pitch - destination->width());
+ frame->surface.pitch - (uint16)destination->width(),
+ _backBuffer.pitch - (uint16)destination->width());
}
}
} else if (flags) {
@@ -807,7 +826,10 @@ void Screen::blit(GraphicFrame *frame, Common::Rect *source, Common::Rect *desti
_backBuffer.frameRect(*destination, 0x220);
}
-void Screen::blitTranstable(byte *dstBuffer, byte *srcBuffer, int16 height, int16 width, uint16 srcPitch, uint16 dstPitch) {
+void Screen::blitTranstable(byte *dstBuffer, byte *srcBuffer, int16 height, int16 width, uint16 srcPitch, uint16 dstPitch) const {
+ if (!_transTable)
+ error("[Screen::blitTranstable] Transparency table buffer not initialized");
+
while (height--) {
for (int16 i = width; i; --i) {
if (*srcBuffer)
@@ -822,7 +844,10 @@ void Screen::blitTranstable(byte *dstBuffer, byte *srcBuffer, int16 height, int1
}
}
-void Screen::blitTranstableMirrored(byte *dstBuffer, byte *srcBuffer, int16 height, int16 width, uint16 srcPitch, uint16 dstPitch) {
+void Screen::blitTranstableMirrored(byte *dstBuffer, byte *srcBuffer, int16 height, int16 width, uint16 srcPitch, uint16 dstPitch) const {
+ if (!_transTable)
+ error("[Screen::blitTranstableMirrored] Transparency table buffer not initialized");
+
while (height--) {
for (int16 i = width; i; --i) {
if (*srcBuffer)
@@ -837,7 +862,10 @@ void Screen::blitTranstableMirrored(byte *dstBuffer, byte *srcBuffer, int16 heig
}
}
-void Screen::blitCrossfade(byte *dstBuffer, byte *srcBuffer, byte *objectBuffer, int16 height, int16 width, uint16 srcPitch, uint16 dstPitch, uint16 objectPitch) {
+void Screen::blitCrossfade(byte *dstBuffer, byte *srcBuffer, byte *objectBuffer, int16 height, int16 width, uint16 srcPitch, uint16 dstPitch, uint16 objectPitch) const {
+ if (!_transTable)
+ error("[Screen::blitCrossfade] Transparency table buffer not initialized");
+
while (height--) {
for (int16 i = width; i; --i) {
if (*srcBuffer)
@@ -854,7 +882,7 @@ void Screen::blitCrossfade(byte *dstBuffer, byte *srcBuffer, byte *objectBuffer,
}
}
-void Screen::blitMirrored(byte *dstBuffer, byte *srcBuffer, int16 height, int16 width, uint16 srcPitch, uint16 dstPitch) {
+void Screen::blitMirrored(byte *dstBuffer, byte *srcBuffer, int16 height, int16 width, uint16 srcPitch, uint16 dstPitch) const {
while (height--) {
for (int16 i = width; i; --i) {
*dstBuffer = *srcBuffer;
@@ -868,7 +896,7 @@ void Screen::blitMirrored(byte *dstBuffer, byte *srcBuffer, int16 height, int16
}
}
-void Screen::blitMirroredColorKey(byte *dstBuffer, byte *srcBuffer, int16 height, int16 width, uint16 srcPitch, uint16 dstPitch) {
+void Screen::blitMirroredColorKey(byte *dstBuffer, byte *srcBuffer, int16 height, int16 width, uint16 srcPitch, uint16 dstPitch) const {
while (height--) {
for (int16 i = width; i; --i) {
if (*srcBuffer != 0)
@@ -883,15 +911,15 @@ void Screen::blitMirroredColorKey(byte *dstBuffer, byte *srcBuffer, int16 height
}
}
-void Screen::blitRaw(byte *dstBuffer, byte *srcBuffer, int16 height, int16 width, uint16 srcPitch, uint16 dstPitch) {
+void Screen::blitRaw(byte *dstBuffer, byte *srcBuffer, int16 height, int16 width, uint16 srcPitch, uint16 dstPitch) const {
while (height--) {
- memcpy(dstBuffer, srcBuffer, width);
+ memcpy(dstBuffer, srcBuffer, (uint16)width);
dstBuffer += dstPitch;
srcBuffer += srcPitch;
}
}
-void Screen::blitRawColorKey(byte *dstBuffer, byte *srcBuffer, int16 height, int16 width, uint16 srcPitch, uint16 dstPitch) {
+void Screen::blitRawColorKey(byte *dstBuffer, byte *srcBuffer, int16 height, int16 width, uint16 srcPitch, uint16 dstPitch) const {
while (height--) {
for (int16 i = width; i; --i) {
if (*srcBuffer != 0)
@@ -906,21 +934,24 @@ void Screen::blitRawColorKey(byte *dstBuffer, byte *srcBuffer, int16 height, int
}
}
-void Screen::blitMasked(GraphicFrame *frame, Common::Rect *source, byte *maskData, Common::Rect *sourceMask, Common::Rect *destMask, int maskWidth, Common::Rect *destination, int32 flags) {
+void Screen::blitMasked(GraphicFrame *frame, Common::Rect *source, byte *maskData, Common::Rect *sourceMask, Common::Rect *destMask, uint16 maskWidth, Common::Rect *destination, int32 flags) {
byte *frameBuffer = (byte *)frame->surface.pixels;
byte *mirroredBuffer = NULL;
int16 frameRight = frame->surface.pitch;
- int16 maskHeight = sourceMask->height(); // for debugging only
+ uint16 maskHeight = (uint16)sourceMask->height(); // for debugging only
byte zoom = abs(sourceMask->left) & 7;
// Prepare temporary source buffer if needed
if (flags & kDrawFlagMirrorLeftRight) {
- mirroredBuffer = (byte *)malloc(source->right * source->bottom);
+ mirroredBuffer = (byte *)malloc((size_t)(source->right * source->bottom));
+ if (!mirroredBuffer)
+ error("[Screen::blitMasked] Cannot allocate buffer for mirrored surface");
+
blitMirrored(mirroredBuffer,
frameBuffer + source->right - 1,
source->bottom,
source->right,
- source->right + frame->surface.pitch,
+ (uint16)(source->right + frame->surface.pitch),
0);
frameBuffer = mirroredBuffer;
@@ -944,8 +975,8 @@ void Screen::blitMasked(GraphicFrame *frame, Common::Rect *source, byte *maskDat
frameBufferPtr,
source->height(),
source->width(),
- frameRight - source->width(),
- _backBuffer.pitch - source->width());
+ (uint16)(frameRight - source->width()),
+ (uint16)(_backBuffer.pitch - source->width()));
// cleanup
free(mirroredBuffer);
@@ -959,7 +990,7 @@ void Screen::blitMasked(GraphicFrame *frame, Common::Rect *source, byte *maskDat
if (destination->left > destMask->left) {
zoom += abs(destination->left - destMask->left) & 7;
- maskBufferPtr += (destination->left - destMask->left + zoom) / 8;
+ maskBufferPtr += ((destination->left - destMask->left) + zoom) / 8;
sourceMask->setWidth(sourceMask->width() + destMask->left - destination->left);
destMask->left = destination->left;
}
@@ -977,8 +1008,8 @@ void Screen::blitMasked(GraphicFrame *frame, Common::Rect *source, byte *maskDat
frameBufferPtr,
source->height(),
destMask->left - destination->left,
- frameRight + destination->left - destMask->left,
- _backBuffer.pitch + destination->left - destMask->left);
+ (uint16)(frameRight + destination->left - destMask->left),
+ (uint16)(_backBuffer.pitch + destination->left - destMask->left));
if (g_debugDrawRects)
_backBuffer.frameRect(Common::Rect(destination->left, destination->top, destMask->left, destination->top + source->height()), 0x10);
@@ -994,9 +1025,9 @@ void Screen::blitMasked(GraphicFrame *frame, Common::Rect *source, byte *maskDat
blitRawColorKey((byte *)_backBuffer.pixels + destination->top * _backBuffer.pitch + destMask->left + sourceMask->width(),
frameBufferPtr + destMask->left + sourceMask->width() - destination->left,
source->height(),
- source->width() + destination->left - destMask->left - sourceMask->width(),
- frameRight + destMask->left + sourceMask->width() - destination->left - source->width(),
- _backBuffer.pitch + destMask->left + sourceMask->width() - destination->left - source->width());
+ source->width() + destination->left - (destMask->left + sourceMask->width()),
+ (uint16)(frameRight + destMask->left + sourceMask->width() - (destination->left + source->width())),
+ (uint16)(_backBuffer.pitch + destMask->left + sourceMask->width() - (destination->left + source->width())));
if (g_debugDrawRects)
_backBuffer.frameRect(Common::Rect(destMask->left, destination->top, destMask->left + source->width(), destination->top + source->height()), 0x36);
@@ -1011,8 +1042,8 @@ void Screen::blitMasked(GraphicFrame *frame, Common::Rect *source, byte *maskDat
frameBufferPtr,
destMask->top - destination->top,
source->width(),
- frameRight - source->width(),
- _backBuffer.pitch - source->width());
+ (uint16)(frameRight - source->width()),
+ (uint16)(_backBuffer.pitch - source->width()));
if (g_debugDrawRects)
_backBuffer.frameRect(Common::Rect(destination->left, destination->top, destination->left + source->width(), destMask->top), 0x23);
@@ -1027,10 +1058,10 @@ void Screen::blitMasked(GraphicFrame *frame, Common::Rect *source, byte *maskDat
if ((source->height() + destination->top) > (destMask->top + sourceMask->height())) {
blitRawColorKey((byte *)_backBuffer.pixels + (destMask->top + sourceMask->height()) * _backBuffer.pitch + destination->left,
frameBufferPtr + (destMask->top + sourceMask->height() - destination->top) * frameRight,
- destination->top + source->height() - sourceMask->height() - destMask->top,
+ destination->top + source->height() - (sourceMask->height() + destMask->top),
source->width(),
- frameRight - source->width(),
- _backBuffer.pitch - source->width());
+ (uint16)(frameRight - source->width()),
+ (uint16)(_backBuffer.pitch - source->width()));
source->setHeight(destMask->top + sourceMask->height() - destination->top);
}
@@ -1041,11 +1072,11 @@ void Screen::blitMasked(GraphicFrame *frame, Common::Rect *source, byte *maskDat
maskBufferPtr,
source->height(),
source->width(),
- frameRight - source->width(),
- (maskWidth - zoom - source->width()) / 8,
+ (uint16)(frameRight - source->width()),
+ (uint16)(maskWidth - (zoom + source->width())) / 8,
zoom,
(byte *)_backBuffer.pixels + _backBuffer.pitch * destination->top + destination->left,
- _backBuffer.pitch - source->width());
+ (uint16)(_backBuffer.pitch - source->width()));
// Draw debug rects
if (g_debugDrawRects) {
@@ -1058,11 +1089,11 @@ void Screen::blitMasked(GraphicFrame *frame, Common::Rect *source, byte *maskDat
}
// DEBUG: Draw the mask (zoomed)
-void Screen::drawZoomedMask(byte *mask, int16 height, int16 width, uint16 maskPitch) {
- int zoom = 7;
+void Screen::drawZoomedMask(byte *mask, uint16 height, uint16 width, uint16 maskPitch) {
+ uint16 zoom = 7;
byte *dstBuffer = (byte *)_backBuffer.pixels;
- uint16 dstPitch = _backBuffer.pitch - (width * zoom);
+ uint16 dstPitch = (uint16)(_backBuffer.pitch - (width * zoom));
uint16 srcPitch = maskPitch;
byte *srcBuffer = mask;
@@ -1083,7 +1114,7 @@ void Screen::drawZoomedMask(byte *mask, int16 height, int16 width, uint16 maskPi
}
}
-void Screen::bltMasked(byte *srcBuffer, byte *maskBuffer, int16 height, int16 width, uint16 srcPitch, uint16 maskPitch, byte zoom, byte *dstBuffer, uint16 dstPitch) {
+void Screen::bltMasked(byte *srcBuffer, byte *maskBuffer, int16 height, int16 width, uint16 srcPitch, uint16 maskPitch, byte zoom, byte *dstBuffer, uint16 dstPitch) const {
if (zoom > 7)
error("[Screen::bltMasked] Invalid zoom value (was: %d, max: 7)", zoom);
@@ -1091,7 +1122,7 @@ void Screen::bltMasked(byte *srcBuffer, byte *maskBuffer, int16 height, int16 wi
// Calculate current zoom and run length
int run = (7 - zoom);
- int skip = (*maskBuffer >> zoom);
+ uint skip = (*maskBuffer >> zoom);
for (int16 i = 0; i < width; i++) {
// Set destination value
@@ -1126,41 +1157,39 @@ void Screen::blt(Common::Rect *dest, GraphicFrame* frame, Common::Rect *source,
frame->surface.w,
dest->left,
dest->top,
- source->width(),
- source->height(),
- flags & kDrawFlagMirrorLeftRight);
+ (uint16)source->width(),
+ (uint16)source->height(),
+ (bool)(flags & kDrawFlagMirrorLeftRight));
} else {
copyToBackBuffer((byte *)frame->surface.pixels + (source->top * frame->surface.w + source->left),
frame->surface.w,
dest->left,
dest->top,
- source->width(),
- source->height(),
- flags & kDrawFlagMirrorLeftRight);
+ (uint16)source->width(),
+ (uint16)source->height(),
+ (bool)(flags & kDrawFlagMirrorLeftRight));
}
}
-void Screen::bltFast(int32 dX, int32 dY, GraphicFrame* frame, Common::Rect *source) {
+void Screen::bltFast(int16 dX, int16 dY, GraphicFrame* frame, Common::Rect *source) {
if (_useColorKey) {
copyToBackBufferWithTransparency((byte *)frame->surface.pixels + (source->top * frame->surface.w + source->left),
frame->surface.w,
dX,
dY,
- source->width(),
- source->height(),
- kDrawFlagNone);
+ (uint16)source->width(),
+ (uint16)source->height());
} else {
copyToBackBuffer((byte *)frame->surface.pixels + (source->top * frame->surface.w + source->left),
frame->surface.w,
dX,
dY,
- source->width(),
- source->height(),
- kDrawFlagNone);
+ (uint16)source->width(),
+ (uint16)source->height());
}
}
-void Screen::copyToBackBuffer(byte *buffer, int32 pitch, int32 x, int32 y, uint32 width, uint32 height, bool mirrored) {
+void Screen::copyToBackBuffer(byte *buffer, int32 pitch, int16 x, int16 y, uint16 width, uint16 height, bool mirrored) {
byte *dest = (byte *)_backBuffer.pixels;
if (!mirrored) {
@@ -1174,7 +1203,7 @@ void Screen::copyToBackBuffer(byte *buffer, int32 pitch, int32 x, int32 y, uint3
}
}
-void Screen::copyToBackBufferWithTransparency(byte *buffer, int32 pitch, int32 x, int32 y, int32 width, int32 height, bool mirrored) {
+void Screen::copyToBackBufferWithTransparency(byte *buffer, int32 pitch, int16 x, int16 y, uint16 width, uint16 height, bool mirrored) {
byte *dest = (byte *)_backBuffer.pixels;
int32 left = (x < 0) ? -x : 0;
@@ -1184,7 +1213,7 @@ void Screen::copyToBackBufferWithTransparency(byte *buffer, int32 pitch, int32 x
for (int32 curY = top; curY < bottom; curY++) {
for (int32 curX = left; curX < right; curX++) {
- uint32 offset = (mirrored ? right - curX - 1 : curX) + curY * pitch;
+ uint32 offset = (uint32)((mirrored ? right - (curX + 1) : curX) + curY * pitch);
if (buffer[offset] != 0 )
dest[x + curX + (y + curY) * 640] = buffer[offset];
@@ -1203,9 +1232,9 @@ void Screen::drawRect(const Common::Rect &rect, uint32 color) {
_backBuffer.frameRect(rect, color);
}
-void Screen::copyToBackBufferClipped(Graphics::Surface *surface, int x, int y) {
+void Screen::copyToBackBufferClipped(Graphics::Surface *surface, int16 x, int16 y) {
Common::Rect screenRect(getWorld()->xLeft, getWorld()->yTop, getWorld()->xLeft + 640, getWorld()->yTop + 480);
- Common::Rect animRect(x, y, x + surface->w, y + surface->h);
+ Common::Rect animRect(x, y, x + (int16)surface->w, y + (int16)surface->h);
animRect.clip(screenRect);
if (!animRect.isEmpty()) {
@@ -1227,8 +1256,8 @@ void Screen::copyToBackBufferClipped(Graphics::Surface *surface, int x, int y) {
surface->pitch,
animRect.left,
animRect.top,
- animRect.width(),
- animRect.height());
+ (uint16)animRect.width(),
+ (uint16)animRect.height());
}
}
diff --git a/engines/asylum/system/screen.h b/engines/asylum/system/screen.h
index 0b6eb38bec..95e975d72a 100644
--- a/engines/asylum/system/screen.h
+++ b/engines/asylum/system/screen.h
@@ -79,14 +79,14 @@ public:
void draw(ResourceId resourceId);
void draw(ResourceId resourceId, uint32 frameIndex, const Common::Point &source, DrawFlags flags = kDrawFlagNone, bool colorKey = true);
void draw(GraphicResource *resource, uint32 frameIndex, const Common::Point &source, DrawFlags flags= kDrawFlagNone, bool colorKey = true);
- void draw(ResourceId resourceId, uint32 frameIndex, const Common::Point &source, DrawFlags flags, int32 transTableNum);
- void draw(GraphicResource *resource, uint32 frameIndex, const Common::Point &source, DrawFlags flags, int32 transTableNum);
+ void drawTransparent(ResourceId resourceId, uint32 frameIndex, const Common::Point &source, DrawFlags flags, uint32 transTableNum);
+ void drawTransparent(GraphicResource *resource, uint32 frameIndex, const Common::Point &source, DrawFlags flags, uint32 transTableNum);
void draw(ResourceId resourceId, uint32 frameIndex, const Common::Point &source, DrawFlags flags, ResourceId resourceId2, const Common::Point &destination, bool colorKey = true);
// Misc
void clear();
void drawWideScreenBars(int16 barSize) const;
- void fillRect(int32 x, int32 y, int32 x2, int32 y2, int32 color);
+ void fillRect(int16 x, int16 y, int16 x2, int16 y2, uint32 color);
void copyBackBufferToScreen();
void setFlag(int16 val) { _flag = (val < -1) ? -1 : val; }
int16 getFlag() { return _flag; }
@@ -116,7 +116,7 @@ public:
// Graphic queue
void addGraphicToQueue(ResourceId resourceId, uint32 frameIndex, const Common::Point &point, DrawFlags flags, int32 transTableNum, int32 priority);
- void addGraphicToQueueCrossfade(ResourceId resourceId, uint32 frameIndex, Common::Point source, int32 objectResourceId, Common::Point destination, int32 transTableNum);
+ void addGraphicToQueueCrossfade(ResourceId resourceId, uint32 frameIndex, const Common::Point &source, int32 objectResourceId, const Common::Point &destination, uint32 transTableNum);
void addGraphicToQueueMasked(ResourceId resourceId, uint32 frameIndex, const Common::Point &source, int32 objectResourceId, const Common::Point &destination, DrawFlags flags, int32 priority);
void addGraphicToQueue(GraphicQueueItem const &item);
void drawGraphicsInQueue();
@@ -124,12 +124,12 @@ public:
void deleteGraphicFromQueue(ResourceId resourceId);
// Used by Video
- void copyToBackBuffer(byte *buffer, int32 pitch, int32 x, int32 y, uint32 width, uint32 height, bool mirrored = false);
+ void copyToBackBuffer(byte *buffer, int32 pitch, int16 x, int16 y, uint16 width, uint16 height, bool mirrored = false);
// Debug
void drawLine(const Common::Point &origin, const Common::Point &destination, uint32 color = 0xFF);
void drawRect(const Common::Rect &rect, uint32 color = 0xFF);
- void copyToBackBufferClipped(Graphics::Surface *surface, int x, int y);
+ void copyToBackBufferClipped(Graphics::Surface *surface, int16 x, int16 y);
protected:
// Palette fading Timer
@@ -173,30 +173,30 @@ private:
void swapGraphicItem(int32 item1, int32 item2);
// Misc
- void clip(Common::Rect *source, Common::Rect *destination, int32 flags);
+ void clip(Common::Rect *source, Common::Rect *destination, int32 flags) const;
void draw(GraphicResource *resource, uint32 frameIndex, const Common::Point &source, DrawFlags flags, ResourceId resourceId2, const Common::Point &destination, bool colorKey = true);
// Screen blitting
void blit(GraphicFrame *frame, Common::Rect *source, Common::Rect *destination, int32 flags);
- void blitMasked(GraphicFrame *frame, Common::Rect *source, byte *maskData, Common::Rect *sourceMask, Common::Rect *destMask, int maskWidth, Common::Rect *destination, int32 flags);
- void blitTranstable (byte *dstBuffer, byte *srcBuffer, int16 height, int16 width, uint16 srcPitch, uint16 dstPitch);
- void blitTranstableMirrored(byte *dstBuffer, byte *srcBuffer, int16 height, int16 width, uint16 srcPitch, uint16 dstPitch);
- void blitMirrored (byte *dstBuffer, byte *srcBuffer, int16 height, int16 width, uint16 srcPitch, uint16 dstPitch);
- void blitMirroredColorKey (byte *dstBuffer, byte *srcBuffer, int16 height, int16 width, uint16 srcPitch, uint16 dstPitch);
- void blitRaw (byte *dstBuffer, byte *srcBuffer, int16 height, int16 width, uint16 srcPitch, uint16 dstPitch);
- void blitRawColorKey (byte *dstBuffer, byte *srcBuffer, int16 height, int16 width, uint16 srcPitch, uint16 dstPitch);
- void blitCrossfade (byte *dstBuffer, byte *srcBuffer, byte *objectBuffer, int16 height, int16 width, uint16 srcPitch, uint16 dstPitch, uint16 objectPitch);
- void bltMasked (byte *srcBuffer, byte *maskBuffer, int16 height, int16 width, uint16 srcPitch, uint16 maskPitch, byte zoom, byte *dstBuffer, uint16 dstPitch);
+ void blitMasked(GraphicFrame *frame, Common::Rect *source, byte *maskData, Common::Rect *sourceMask, Common::Rect *destMask, uint16 maskWidth, Common::Rect *destination, int32 flags);
+ void blitTranstable (byte *dstBuffer, byte *srcBuffer, int16 height, int16 width, uint16 srcPitch, uint16 dstPitch) const;
+ void blitTranstableMirrored(byte *dstBuffer, byte *srcBuffer, int16 height, int16 width, uint16 srcPitch, uint16 dstPitch) const;
+ void blitMirrored (byte *dstBuffer, byte *srcBuffer, int16 height, int16 width, uint16 srcPitch, uint16 dstPitch) const;
+ void blitMirroredColorKey (byte *dstBuffer, byte *srcBuffer, int16 height, int16 width, uint16 srcPitch, uint16 dstPitch) const;
+ void blitRaw (byte *dstBuffer, byte *srcBuffer, int16 height, int16 width, uint16 srcPitch, uint16 dstPitch) const;
+ void blitRawColorKey (byte *dstBuffer, byte *srcBuffer, int16 height, int16 width, uint16 srcPitch, uint16 dstPitch) const;
+ void blitCrossfade (byte *dstBuffer, byte *srcBuffer, byte *objectBuffer, int16 height, int16 width, uint16 srcPitch, uint16 dstPitch, uint16 objectPitch) const;
+ void bltMasked (byte *srcBuffer, byte *maskBuffer, int16 height, int16 width, uint16 srcPitch, uint16 maskPitch, byte zoom, byte *dstBuffer, uint16 dstPitch) const;
// DirectDraw-equivalent functions
void blt(Common::Rect *dest, GraphicFrame* frame, Common::Rect *source, int32 flags);
- void bltFast(int32 dX, int32 dY, GraphicFrame* frame, Common::Rect *source);
+ void bltFast(int16 dX, int16 dY, GraphicFrame* frame, Common::Rect *source);
- void copyToBackBufferWithTransparency(byte *buffer, int32 pitch, int32 x, int32 y, int32 width, int32 height, bool mirrored = false);
+ void copyToBackBufferWithTransparency(byte *buffer, int32 pitch, int16 x, int16 y, uint16 width, uint16 height, bool mirrored = false);
// Debug
- void drawZoomedMask(byte *mask, int16 height, int16 width, uint16 maskPitch);
+ void drawZoomedMask(byte *mask, uint16 height, uint16 width, uint16 maskPitch);
};
} // end of namespace Asylum
diff --git a/engines/asylum/system/text.cpp b/engines/asylum/system/text.cpp
index 06a368a906..2b0c29b1fd 100644
--- a/engines/asylum/system/text.cpp
+++ b/engines/asylum/system/text.cpp
@@ -129,7 +129,7 @@ void Text::drawChar(char character) {
error("[Text::drawChar] font resource hasn't been loaded yet!");
if (_transTableNum) {
- getScreen()->draw(_fontResource, (uint8)character, _position, kDrawFlagNone, _transTableNum);
+ getScreen()->drawTransparent(_fontResource, (uint8)character, _position, kDrawFlagNone, _transTableNum);
} else {
getScreen()->draw(_fontResource, (uint8)character, _position);
}
diff --git a/engines/asylum/system/text.h b/engines/asylum/system/text.h
index fd25041fe5..e8a386df6f 100644
--- a/engines/asylum/system/text.h
+++ b/engines/asylum/system/text.h
@@ -68,14 +68,14 @@ public:
void drawCentered(const Common::Point &point, int16 width, ResourceId resourceId);
void drawCentered(const Common::Point &point, int16 width, int16 length, const char *text);
- void setTransTableNum(int32 val) { _transTableNum = val; }
+ void setTransTableNum(uint32 val) { _transTableNum = val; }
private:
AsylumEngine *_vm;
GraphicResource *_fontResource;
- int32 _transTableNum;
+ uint32 _transTableNum;
Common::Point _position;
uint8 _curFontFlags;
diff --git a/engines/asylum/views/menu.cpp b/engines/asylum/views/menu.cpp
index 6d54c4ba93..4e72f8b73a 100644
--- a/engines/asylum/views/menu.cpp
+++ b/engines/asylum/views/menu.cpp
@@ -450,7 +450,7 @@ bool Menu::update() {
_dword_455C74 = 0;
}
} else {
- getScreen()->draw(kEye, frameIndex, Common::Point(0, 0), kDrawFlagNone, 3);
+ getScreen()->drawTransparent(kEye, frameIndex, Common::Point(0, 0), kDrawFlagNone, 3);
// Draw icon
getScreen()->draw(MAKE_RESOURCE(kResourcePackShared, _activeScreen + 4), _iconFrames[_activeScreen], Common::Point(0, 0));
@@ -1539,10 +1539,10 @@ void Menu::updateShowCredits() {
int32 maxBound = _startIndex + step;
if (minBound >= 0 && minBound < 32)
- getText()->setTransTableNum(3 - minBound / 8);
+ getText()->setTransTableNum((uint32)(3 - minBound / 8));
if (maxBound < 480 && maxBound > 448)
- getText()->setTransTableNum(3 - (479 - maxBound) / 8);
+ getText()->setTransTableNum((uint32)(3 - (479 - maxBound) / 8));
getText()->setPosition(Common::Point(320, (int16)(step + _startIndex)));
getText()->draw(MAKE_RESOURCE(kResourcePackText, 1447 + index));
diff --git a/engines/asylum/views/video.cpp b/engines/asylum/views/video.cpp
index 05b30046af..9c87817780 100644
--- a/engines/asylum/views/video.cpp
+++ b/engines/asylum/views/video.cpp
@@ -134,8 +134,8 @@ void VideoPlayer::play(Common::String filename, bool showSubtitles) {
if (!_smkDecoder->loadFile(filename))
error("[Video::playVideo] Invalid video index (%d)", _currentMovie);
- int32 x = Common::Rational(g_system->getWidth() - _smkDecoder->getWidth(), 2).toInt();
- int32 y = Common::Rational(g_system->getHeight() - _smkDecoder->getHeight(), 2).toInt();
+ int16 x = (int16)Common::Rational(g_system->getWidth() - _smkDecoder->getWidth(), 2).toInt();
+ int16 y = (int16)Common::Rational(g_system->getHeight() - _smkDecoder->getHeight(), 2).toInt();
getScreen()->clear();
Commit: 156ffb12764c4a2029f557860fc7d6f47e859a50
https://github.com/scummvm/scummvm/commit/156ffb12764c4a2029f557860fc7d6f47e859a50
Author: Littleboy (littleboy at scummvm.org)
Date: 2021-05-17T15:37:21+02:00
Commit Message:
ASYLUM: Simplify Screen::setPaletteGamma()
Changed paths:
engines/asylum/system/screen.cpp
diff --git a/engines/asylum/system/screen.cpp b/engines/asylum/system/screen.cpp
index 574f5b3d42..86a8bd48f6 100644
--- a/engines/asylum/system/screen.cpp
+++ b/engines/asylum/system/screen.cpp
@@ -524,26 +524,27 @@ void Screen::setPaletteGamma(byte *data, byte *target) {
for (int32 i = 1; i < 256; i++) {
byte color = 0;
- if (data[i * 3 + 0] > 0)
- color = data[i * 3 + 0];
- if (data[i * 3 + 1] > color)
- color = data[i * 3 + 1];
- if (data[i * 3 + 2] > color)
- color = data[i * 3 + 2];
-
- /*if (color == 0)
- error("[Screen::setPaletteGamma] Invalid color");*/
+ if (data[0] > 0)
+ color = data[0];
+ if (data[1] > color)
+ color = data[1];
+ if (data[2] > color)
+ color = data[2];
int gamma = color + (Config.gammaLevel * (63 - color) + 31) / 63;
- if (gamma) {
- if (data[i * 3 + 0])
- target[i * 3 + 0] = (byte)(4 * ((color >> 1) + data[i * 3 + 0] * gamma) / color);
- if (data[i * 3 + 1])
- target[i * 3 + 1] = (byte)(4 * ((color >> 1) + data[i * 3 + 1] * gamma) / color);
- if (data[i * 3 + 2])
- target[i * 3 + 2] = (byte)(4 * ((color >> 1) + data[i * 3 + 2] * gamma) / color);
+ if (gamma && color != 0) {
+ if (data[0])
+ target[0] = (byte)(4 * ((color >> 1) + data[0] * gamma) / color);
+ if (data[1])
+ target[1] = (byte)(4 * ((color >> 1) + data[1] * gamma) / color);
+ if (data[2])
+ target[2] = (byte)(4 * ((color >> 1) + data[2] * gamma) / color);
}
+
+ // Advance palette data
+ target += 3;
+ data += 3;
}
}
Commit: 21fa0d155ef9205222b5881f5b2a67e393cfd570
https://github.com/scummvm/scummvm/commit/21fa0d155ef9205222b5881f5b2a67e393cfd570
Author: Littleboy (littleboy at scummvm.org)
Date: 2021-05-17T15:37:21+02:00
Commit Message:
ASYLUM: Fix some potential out of bound array accesses
Changed paths:
engines/asylum/system/screen.cpp
diff --git a/engines/asylum/system/screen.cpp b/engines/asylum/system/screen.cpp
index 86a8bd48f6..5cdc3c3e84 100644
--- a/engines/asylum/system/screen.cpp
+++ b/engines/asylum/system/screen.cpp
@@ -303,7 +303,7 @@ void Screen::setupPalette(byte *buffer, int start, int count) {
// Setup our main palette
if (count > 0) {
byte *palette = (byte *)_mainPalette;
- palette += 4 * start;
+ palette += start;
for (int32 i = 0; i < count; i++) {
palette[0] = (byte )(buffer[0] * 4);
@@ -424,7 +424,7 @@ void Screen::paletteFade(uint32 start, int32 ticksWait, int32 delta) {
byte blue = palette[3 * start + 2];
for (int32 i = 1; i < colorDelta; i++) {
- for (uint32 j = 3; j < ARRAYSIZE(_mainPalette); j += 3) {
+ for (uint32 j = 3; j < ARRAYSIZE(_mainPalette) - 3; j += 3) {
_mainPalette[j] = (byte)(palette[j] + i * (red - palette[j]) / colorDelta);
_mainPalette[j + 1] = (byte)(palette[j + 1] + i * (green - palette[j + 1]) / colorDelta);
_mainPalette[j + 2] = (byte)(palette[j + 2] + i * (blue - palette[j + 2]) / colorDelta);
@@ -477,7 +477,7 @@ void Screen::paletteFadeWorker(ResourceId id, int32 ticksWait, int32 delta) {
// Prepare for palette fading loop
int32 colorDelta = delta + 1;
for (int32 i = 1; i < colorDelta; i++) {
- for (uint32 j = 3; j < ARRAYSIZE(_mainPalette); j += 3) {
+ for (uint32 j = 3; j < ARRAYSIZE(_mainPalette) - 3; j += 3) {
_mainPalette[j] = (byte)(original[j] + i * (palette[j] - original[j]) / colorDelta);
_mainPalette[j + 1] = (byte)(original[j + 1] + i * (palette[j + 1] - original[j + 1]) / colorDelta);
_mainPalette[j + 2] = (byte)(original[j + 2] + i * (palette[j + 2] - original[j + 2]) / colorDelta);
Commit: 083afccd67130c0d108eda7b448565f531ed81cf
https://github.com/scummvm/scummvm/commit/083afccd67130c0d108eda7b448565f531ed81cf
Author: Alex Bevilacqua (alexbevi at gmail.com)
Date: 2021-05-17T15:37:21+02:00
Commit Message:
ASYLUM: Finish implementation of TimeMachine puzzle
patch contributed by midstream
Changed paths:
engines/asylum/puzzles/timemachine.cpp
engines/asylum/puzzles/timemachine.h
diff --git a/engines/asylum/puzzles/timemachine.cpp b/engines/asylum/puzzles/timemachine.cpp
index d54118a1c7..1cea062661 100644
--- a/engines/asylum/puzzles/timemachine.cpp
+++ b/engines/asylum/puzzles/timemachine.cpp
@@ -47,30 +47,22 @@ const Common::Rect puzzleTimeMachineRects[10] = {
Common::Rect(475, 290, 495, 325)
};
-const Common::Point puzzleTimeMachinePoints[6] = {
+const Common::Point puzzleTimeMachinePoints[5] = {
Common::Point(-65, -30),
Common::Point(-20, -68),
Common::Point( 25, -106),
Common::Point( 70, -144),
- Common::Point(115, -182),
- Common::Point(-65, -30)
+ Common::Point(115, -182)
};
PuzzleTimeMachine::PuzzleTimeMachine(AsylumEngine *engine) : Puzzle(engine) {
- _leftButtonClicked = false;
- _counter = 0;
- _counter2 = 0;
- _currentFrameIndex = 0;
- memset(&_frameIndexes, 0, sizeof(_frameIndexes));
- memset(&_frameCounts, 0, sizeof(_frameCounts));
- memset(&_frameIncrements, 0, sizeof(_frameIncrements));
- memset(&_state, 0, sizeof(_state));
-
- _data_4572BC = false;
- _data_4572CC = false;
-
- _data_45AAA8 = 0;
- _data_45AAAC = 0;
+ _leftButtonClicked = true;
+
+ memset(&_frameIndexes, 0, sizeof(_frameIndexes));
+ memset(&_frameCounts, 0, sizeof(_frameCounts));
+ memset(&_frameIncrements, 0, sizeof(_frameIncrements));
+
+ reset();
}
PuzzleTimeMachine::~PuzzleTimeMachine() {
@@ -104,11 +96,22 @@ void PuzzleTimeMachine::saveLoadWithSerializer(Common::Serializer &s) {
s.syncAsSint32LE(_frameIndexes[5]);
}
+void PuzzleTimeMachine::reset() {
+ _frameIndexes[0] = 0;
+ _frameIndexes[1] = 4;
+ _frameIndexes[2] = 20;
+ _frameIndexes[3] = 16;
+ _frameIndexes[4] = 20;
+
+ _index = -1;
+ _index2 = 0;
+ _point = _newPoint = puzzleTimeMachinePoints[0];
+}
+
//////////////////////////////////////////////////////////////////////////
// Event Handling
//////////////////////////////////////////////////////////////////////////
-bool PuzzleTimeMachine::init(const AsylumEvent &evt) {
- _counter = 0;
+bool PuzzleTimeMachine::init(const AsylumEvent &evt) {
getCursor()->set(getWorld()->graphicResourceIds[62], -1, kCursorAnimationMirror, 7);
_frameCounts[0] = GraphicResource::getFrameCount(_vm, getWorld()->graphicResourceIds[35]);
@@ -121,8 +124,6 @@ bool PuzzleTimeMachine::init(const AsylumEvent &evt) {
getScreen()->setPalette(getWorld()->graphicResourceIds[41]);
getScreen()->setGammaLevel(getWorld()->graphicResourceIds[41]);
- mouseLeftDown(evt);
-
return true;
}
@@ -132,15 +133,20 @@ bool PuzzleTimeMachine::update(const AsylumEvent &) {
// Draw screen elements
getScreen()->clearGraphicsInQueue();
getScreen()->draw(getWorld()->graphicResourceIds[34]);
- getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[35], (uint32)_frameIndexes[0], Common::Point(23, 215), kDrawFlagNone, 0, 1);
- getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[36], (uint32)_frameIndexes[1], Common::Point(70, 217), kDrawFlagNone, 0, 2);
- getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[37], (uint32)_frameIndexes[2], Common::Point(189, 217), kDrawFlagNone, 0, 3);
- getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[38], (uint32)_frameIndexes[3], Common::Point(309, 218), kDrawFlagNone, 0, 4);
- getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[39], (uint32)_frameIndexes[4], Common::Point(429, 212), kDrawFlagNone, 0, 5);
+ getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[35], _frameIndexes[0], Common::Point( 23, 215), kDrawFlagNone, 0, 3);
+ getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[36], _frameIndexes[1], Common::Point( 70, 217), kDrawFlagNone, 0, 3);
+ getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[37], _frameIndexes[2], Common::Point(189, 217), kDrawFlagNone, 0, 3);
+ getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[38], _frameIndexes[3], Common::Point(309, 218), kDrawFlagNone, 0, 3);
+ getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[39], _frameIndexes[4], Common::Point(429, 212), kDrawFlagNone, 0, 3);
+
+ getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[40], _frameIndexes[5], _point, kDrawFlagNone, 0, 1);
+ if (_point.x < _newPoint.x)
+ _point += Common::Point(15, -12 - (abs((double)(_point.x - _newPoint.x)) > 15 ? 1 : 0));
+ else if (_point.x > _newPoint.x)
+ _point -= Common::Point(15, -12 - (abs((double)(_point.x - _newPoint.x)) > 15 ? 1 : 0));
if (_frameIndexes[0] != 28 || _frameIndexes[1] || _frameIndexes[2] || _frameIndexes[3] || _frameIndexes[4]) {
- _leftButtonClicked = true;
- getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[43], 0, Common::Point(599, 220), kDrawFlagNone, 0, 5);
+ getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[43], 0, Common::Point(599, 220), kDrawFlagNone, 0, 2);
} else {
getSound()->stop(getWorld()->soundResourceIds[17]);
getSound()->stop(getWorld()->soundResourceIds[16]);
@@ -153,20 +159,20 @@ bool PuzzleTimeMachine::update(const AsylumEvent &) {
++_counter;
}
- getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[40], (uint32)_frameIndexes[5], _point, kDrawFlagNone, 0, 1);
-
//////////////////////////////////////////////////////////////////////////
// Show all buttons
for (uint32 i = 0; i < ARRAYSIZE(puzzleTimeMachineRects); i += 2) {
- if (_state[i / 2] != -1)
+ if ((uint32)_index != i || _leftButtonClicked)
getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[44 + i], 0, Common::Point(puzzleTimeMachineRects[i].left, puzzleTimeMachineRects[i].top), kDrawFlagNone, 0, 5);
}
for (uint32 i = 1; i < ARRAYSIZE(puzzleTimeMachineRects); i += 2) {
- if (_state[i / 2] != 1)
- getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[45 + i], 0, Common::Point(puzzleTimeMachineRects[i].left, puzzleTimeMachineRects[i].top), kDrawFlagNone, 0, 5);
+ if ((uint32)_index != i || _leftButtonClicked)
+ getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[44 + i], 0, Common::Point(puzzleTimeMachineRects[i].left, puzzleTimeMachineRects[i].top), kDrawFlagNone, 0, 5);
}
+ _leftButtonClicked = true;
+
// Draw to screen
getScreen()->drawGraphicsInQueue();
getScreen()->copyBackBufferToScreen();
@@ -180,41 +186,21 @@ bool PuzzleTimeMachine::update(const AsylumEvent &) {
_vm->switchEventHandler(getScene());
}
- // Update frame indexes
- if (_currentFrameIndex == 0 && _frameIncrements[0] != 0) {
- _data_4572BC = false;
- _data_4572CC = false;
-
- _frameIndexes[5] += _frameIncrements[0];
-
- if (_counter2 > 4) {
- _counter2 = 0;
-
- if (!getSound()->isPlaying(getWorld()->soundResourceIds[14]))
- getSound()->playSound(getWorld()->soundResourceIds[14]);
-
- _frameIndexes[0] += _frameIncrements[0];
- } else {
- ++_counter2;
- }
- } else {
- warning("[PuzzleTimeMachine::update] Not implemented!");
- }
-
- // Reset frame increments & state
- if (_counter2 == 0 && _data_4572CC == 0 && _leftButtonClicked && _data_45AAA8 == 0 && _currentFrameIndex == _data_45AAAC) {
- for (uint32 i = 0; i < 5; i++) {
- if (!(_frameIndexes[i] % ~3))
- _frameIncrements[i] = 0;
+ // Update frame indexes & increments
+ if (_index != -1) {
+ _frameIndexes[_index / 2] += _frameIncrements[_index / 2];
+ if (_frameIndexes[_index / 2] < 0) {
+ _frameIndexes[_index / 2] = _frameCounts[_index / 2] - 1;
+ } else if (_frameIndexes[_index / 2] > (int32)_frameCounts[_index / 2] - 1) {
+ _frameIndexes[_index / 2] = 0;
+ _frameIncrements[_index / 2] = 0;
+ } else if (!(_frameIndexes[_index / 2] % 4)) {
+ getSound()->playSound(getWorld()->soundResourceIds[15]);
+ _frameIncrements[_index / 2] = 0;
+ _index = -1;
}
- memset(&_state, 0, sizeof(_state));
- }
-
- // Adjust frame indexes
- for (uint32 i = 0; i < ARRAYSIZE(_frameIndexes); i++) {
- if (_frameIndexes[i] >= (int32)_frameCounts[i])
- _frameIndexes[i] = 0;
+ _frameIndexes[5] = (_frameIndexes[5] + 1) % _frameCounts[5];
}
return true;
@@ -229,7 +215,7 @@ bool PuzzleTimeMachine::mouseLeftDown(const AsylumEvent &evt) {
int32 index = -1;
for (uint32 i = 0; i < ARRAYSIZE(puzzleTimeMachineRects); i++) {
if (puzzleTimeMachineRects[i].contains(evt.mouse)) {
- index = i;
+ index = i;
break;
}
@@ -238,24 +224,18 @@ bool PuzzleTimeMachine::mouseLeftDown(const AsylumEvent &evt) {
if (index == -1)
return true;
- getSound()->playSound(getWorld()->soundResourceIds[15]);
-
- _data_4572CC = true;
- _data_4572BC = true;
-
- if (index % ~1 == 1) {
- _frameIncrements[index] = 1;
- _state[index] = 1;
- } else {
- _frameIncrements[index] = -1;
- _state[index] = -1;
+ getSound()->playSound(getWorld()->soundResourceIds[14]);
+ if ((uint32)(_index2 / 2) != index / 2) {
+ getSound()->playSound(getWorld()->soundResourceIds[16]);
+ _newPoint = puzzleTimeMachinePoints[index / 2];
}
- return true;
-}
+ if (index % 2)
+ _frameIncrements[index / 2] = 1;
+ else
+ _frameIncrements[index / 2] = -1;
-bool PuzzleTimeMachine::mouseLeftUp(const AsylumEvent &) {
- _leftButtonClicked = true;
+ _index = _index2 = index;
return true;
}
diff --git a/engines/asylum/puzzles/timemachine.h b/engines/asylum/puzzles/timemachine.h
index b5f00280de..43187d599d 100644
--- a/engines/asylum/puzzles/timemachine.h
+++ b/engines/asylum/puzzles/timemachine.h
@@ -38,21 +38,23 @@ public:
virtual void saveLoadWithSerializer(Common::Serializer &s);
private:
- bool _leftButtonClicked;
+ bool _leftButtonClicked;
uint32 _counter;
- uint32 _counter2;
- uint32 _currentFrameIndex;
- int32 _frameIndexes[6];
+ int32 _frameIndexes[6];
uint32 _frameCounts[6];
- int32 _frameIncrements[6];
- int8 _state[5];
+ int32 _frameIncrements[5];
+ int32 _index;
+ uint32 _index2;
Common::Point _point;
+ Common::Point _newPoint;
- bool _data_4572BC;
- bool _data_4572CC;
-
+ // Unused puzzle variables
+ int8 _state[5];
+ bool _data_4572BC;
+ bool _data_4572CC;
uint32 _data_45AAA8;
uint32 _data_45AAAC;
+ uint32 _currentFrameIndex;
//////////////////////////////////////////////////////////////////////////
// Event Handling
@@ -61,13 +63,13 @@ private:
bool update(const AsylumEvent &evt);
bool key(const AsylumEvent &evt) { return keyExit(evt); }
bool mouseLeftDown(const AsylumEvent &evt);
- bool mouseLeftUp(const AsylumEvent &evt);
bool mouseRightDown(const AsylumEvent &evt);
//////////////////////////////////////////////////////////////////////////
// Helpers
//////////////////////////////////////////////////////////////////////////
void updateCursor();
+ void reset();
};
} // End of namespace Asylum
Commit: 407c96b3d2efd828e9c8cb5b484bab58652fcfb2
https://github.com/scummvm/scummvm/commit/407c96b3d2efd828e9c8cb5b484bab58652fcfb2
Author: Alex Bevilacqua (alexbevi at gmail.com)
Date: 2021-05-17T15:37:22+02:00
Commit Message:
ASYLUM: fix warnings
Changed paths:
engines/asylum/puzzles/timemachine.cpp
engines/asylum/resources/encounters.h
engines/asylum/resources/object.cpp
diff --git a/engines/asylum/puzzles/timemachine.cpp b/engines/asylum/puzzles/timemachine.cpp
index 1cea062661..9bf78a1a5e 100644
--- a/engines/asylum/puzzles/timemachine.cpp
+++ b/engines/asylum/puzzles/timemachine.cpp
@@ -225,7 +225,7 @@ bool PuzzleTimeMachine::mouseLeftDown(const AsylumEvent &evt) {
return true;
getSound()->playSound(getWorld()->soundResourceIds[14]);
- if ((uint32)(_index2 / 2) != index / 2) {
+ if ((_index2 / 2) != (uint32)index / 2) {
getSound()->playSound(getWorld()->soundResourceIds[16]);
_newPoint = puzzleTimeMachinePoints[index / 2];
}
diff --git a/engines/asylum/resources/encounters.h b/engines/asylum/resources/encounters.h
index 1490aa07bb..2ac8b7fa6d 100644
--- a/engines/asylum/resources/encounters.h
+++ b/engines/asylum/resources/encounters.h
@@ -48,6 +48,8 @@ struct EncounterItem : public Common::Serializable {
value = 0;
}
+ virtual ~EncounterItem() {}
+
// Serializable
void saveLoadWithSerializer(Common::Serializer &s) {
s.syncAsSint16LE(keywordIndex);
@@ -63,6 +65,8 @@ struct EncounterItem : public Common::Serializable {
class EncounterVariables : public Common::Array<int16>, public Common::Serializable {
public:
+ virtual ~EncounterVariables() {}
+
// Serializable
void saveLoadWithSerializer(Common::Serializer &s) {
for (uint i = 0; i < _size; i++)
@@ -72,6 +76,8 @@ public:
class EncounterItems : public Common::Array<EncounterItem>, public Common::Serializable {
public:
+ virtual ~EncounterItems() {}
+
// Serializable
void saveLoadWithSerializer(Common::Serializer &s) {
for (uint i = 0; i < _size; i++)
diff --git a/engines/asylum/resources/object.cpp b/engines/asylum/resources/object.cpp
index 8bb6152880..16455746e5 100644
--- a/engines/asylum/resources/object.cpp
+++ b/engines/asylum/resources/object.cpp
@@ -541,7 +541,7 @@ ResourceId Object::getRandomResourceId() {
}
bool Object::checkFlags() const {
- return (flags & kObjectFlagEnabled) && (flags & kObjectFlag8 || flags & kObjectFlag10000);
+ return (flags & kObjectFlagEnabled) && ((flags & kObjectFlag8) || (flags & kObjectFlag10000));
}
Common::String Object::toString(bool shortString) {
Commit: 6d591a9a9987ff4973bbab84216fc00b8731f31f
https://github.com/scummvm/scummvm/commit/6d591a9a9987ff4973bbab84216fc00b8731f31f
Author: Littleboy (littleboy at scummvm.org)
Date: 2021-05-17T15:37:22+02:00
Commit Message:
ASYLUM: Add timer ID to installTimerProc() call in Screen::startPaletteFade()
Changed paths:
engines/asylum/system/screen.cpp
diff --git a/engines/asylum/system/screen.cpp b/engines/asylum/system/screen.cpp
index 5cdc3c3e84..2c1010148a 100644
--- a/engines/asylum/system/screen.cpp
+++ b/engines/asylum/system/screen.cpp
@@ -385,7 +385,7 @@ void Screen::startPaletteFade(ResourceId resourceId, int32 ticksWait, int32 delt
_fadeDelta = delta;
// Inverval == 1: we want to execute directly, since we are only going to be called back once
- _vm->getTimerManager()->installTimerProc(&paletteFadeTimer, 1, this);
+ _vm->getTimerManager()->installTimerProc(&paletteFadeTimer, 1, this, "Palette fade timer");
}
void Screen::stopPaletteFade(char red, char green, char blue) {
Commit: 92181cef22516d172dd21676db63e59b09e18310
https://github.com/scummvm/scummvm/commit/92181cef22516d172dd21676db63e59b09e18310
Author: Littleboy (littleboy at scummvm.org)
Date: 2021-05-17T15:37:22+02:00
Commit Message:
ASYLUM: Rename encounter flags
- Used to signal if the player should be re-enabled after the encounter finishes
- Used to signal the dialog should be closed
Changed paths:
engines/asylum/resources/encounters.cpp
engines/asylum/resources/encounters.h
engines/asylum/views/scene.cpp
diff --git a/engines/asylum/resources/encounters.cpp b/engines/asylum/resources/encounters.cpp
index 21068fd1ba..13df712e1d 100644
--- a/engines/asylum/resources/encounters.cpp
+++ b/engines/asylum/resources/encounters.cpp
@@ -46,7 +46,7 @@ namespace Asylum {
Encounter::Encounter(AsylumEngine *engine) : _vm(engine),
_index(0), _keywordIndex(0), _item(NULL), _objectId1(kObjectNone), _objectId2(kObjectNone), _objectId3(kObjectNone),
- _actorIndex(kActorInvalid), _flag1(false), _flag2(false), _flag3(false), _flag4(false) {
+ _actorIndex(kActorInvalid), _shouldEnablePlayer(false), _wasPlayerDisabled(false), _flag3(false), _flag4(false) {
memset(&_keywordIndexes, 0, sizeof(_keywordIndexes));
_rectIndex = -1;
@@ -57,12 +57,12 @@ Encounter::Encounter(AsylumEngine *engine) : _vm(engine),
_data_455B3C = 0;
_data_455B70 = 0;
_data_455BCC = false;
- _data_455BD0 = false;
- _data_455BD4 = false;
+ _isDialogOpen = false;
+ _shouldCloseDialog = false;
_data_455BD8 = false;
_data_455BDC = false;
_data_455BE0 = false;
- _data_455BE4 = false;
+ _shouldCloseBackground = false;
_data_455BE8 = false;
_data_455BF0 = 0;
_data_455BF4 = 0;
@@ -123,15 +123,23 @@ void Encounter::initData() {
uint32 currentIndex = 0;
- for (uint i = 0; i < 50; i++)
- if (_item->keywords[i] & KEYWORD_MASK)
- if (!(BYTE1(_item->keywords[i]) & 0x20))
- _keywordIndexes[currentIndex++] = i;
+ for (uint i = 0; i < 50; i++) {
+ if (_item->keywords[i] & KEYWORD_MASK) {
+ if (!(BYTE1(_item->keywords[i]) & 0x20)) {
+ _keywordIndexes[currentIndex] = i;
+ currentIndex++;
+ }
+ }
+ }
- for (uint i = 0; i < 50; i++)
- if (_item->keywords[i] & KEYWORD_MASK)
- if (!(BYTE1(_item->keywords[i]) & 0x20))
- _keywordIndexes[currentIndex++] = i;
+ for (uint i = currentIndex; i < 50; i++) {
+ if (_item->keywords[i] & KEYWORD_MASK) {
+ if (!(BYTE1(_item->keywords[i]) & 0x20)) {
+ _keywordIndexes[currentIndex] = i;
+ currentIndex++;
+ }
+ }
+ }
}
void Encounter::initBackground() {
@@ -237,13 +245,13 @@ void Encounter::run(int32 encounterIndex, ObjectId objectId1, ObjectId objectId2
Actor *player = getScene()->getActor();
if (player->getStatus() == kActorStatusDisabled) {
- _flag2 = true;
+ _wasPlayerDisabled = true;
} else {
- _flag2 = false;
+ _wasPlayerDisabled = false;
player->updateStatus(kActorStatusDisabled);
}
- _flag1 = false;
+ _shouldEnablePlayer = false;
// Setup encounter event handler
_vm->switchEventHandler(this);
@@ -264,10 +272,11 @@ void Encounter::exitEncounter() {
getSharedData()->setFlag(kFlagIsEncounterRunning, false);
getSharedData()->setFlag(kFlag3, true);
- if (_flag2)
- _flag2 = false;
+ // Check if we need to re-enable the player
+ if (_wasPlayerDisabled)
+ _wasPlayerDisabled = false;
else
- _flag1 = true;
+ _shouldEnablePlayer = true;
if (getSharedData()->getFlag(kFlagEncounterDisablePlayerOnExit))
getScene()->getActor()->updateStatus(kActorStatusDisabled);
@@ -313,11 +322,11 @@ bool Encounter::init() {
if (!getSharedData()->getMatteBarHeight()) {
getSharedData()->setFlag(kFlagIsEncounterRunning, true);
- _data_455BD4 = false;
+ _shouldCloseDialog = false;
_data_455BD8 = false;
_data_455BDC = false;
_data_455BE0 = false;
- _data_455BE4 = false;
+ _shouldCloseBackground = false;
_data_455BCC = false;
_data_455B3C = 1;
_rectIndex = -1;
@@ -337,7 +346,7 @@ bool Encounter::init() {
initDrawStructs();
}
- _data_455BD0 = false;
+ _isDialogOpen = false;
getCursor()->set(getWorld()->cursorResources[kCursorResourceTalkNPC], -1, kCursorAnimationMirror);
if (!getSharedData()->getMatteBarHeight())
@@ -354,7 +363,7 @@ bool Encounter::update() {
ResourceId id = kResourceNone;
if (_objectId3) {
- _data_455BD0 = false;
+ _isDialogOpen = false;
Object *object = getWorld()->getObjectById(_objectId3);
id = object->getResourceId();
@@ -394,7 +403,7 @@ bool Encounter::update() {
if (_data_455BE8) {
if (getSharedData()->getMatteBarHeight()) {
- _data_455BD0 = false;
+ _isDialogOpen = false;
} else {
getCursor()->show();
_data_455BE8 = false;
@@ -402,7 +411,7 @@ bool Encounter::update() {
}
}
- if (_data_455BD0) {
+ if (_isDialogOpen) {
if (_data_455BF4 == 1) {
_data_455BF4 = 2;
runScript();
@@ -454,10 +463,10 @@ bool Encounter::key(const AsylumEvent &evt) {
case Common::KEYCODE_ESCAPE:
if (!isSpeaking()
- && _data_455BD0
+ && _isDialogOpen
&& !getSpeech()->getTextData()
&& !getSpeech()->getTextDataPos())
- _data_455BD4 = true;
+ _shouldCloseDialog = true;
break;
}
@@ -495,10 +504,10 @@ bool Encounter::mouse(const AsylumEvent &evt) {
case Common::EVENT_RBUTTONDOWN:
if (!isSpeaking()
- && _data_455BD0
+ && _isDialogOpen
&& !getSpeech()->getTextData()
&& !getSpeech()->getTextDataPos())
- _data_455BD4 = true;
+ _shouldCloseDialog = true;
break;
}
@@ -843,7 +852,7 @@ bool Encounter::drawBackground() {
getScreen()->draw(_background.resourceId, _background.frameIndex, _point);
}
- if (_data_455BE4) {
+ if (_shouldCloseBackground) {
--_background.frameIndex;
if (_background.frameIndex == 0)
@@ -864,7 +873,7 @@ bool Encounter::drawBackground() {
bool Encounter::drawPortraits() {
bool ret = true;
- if (_data_455BD4) {
+ if (_shouldCloseDialog) {
_portrait1.transTableMax = 0;
_portrait2.transTableMax = 0;
}
@@ -931,10 +940,10 @@ bool Encounter::drawPortraits() {
_portrait2.frameIndex %= _portrait2.frameCount;
}
- if (_data_455BD4)
+ if (_shouldCloseDialog)
if (_portrait1.transTableNum == _portrait1.transTableMax
&& _portrait2.transTableNum == _portrait2.transTableMax)
- _data_455BE4 = true;
+ _shouldCloseBackground = true;
return ret;
}
@@ -947,7 +956,7 @@ void Encounter::drawStructs() {
if (checkKeywords2() || _drawingStructs[0].transTableNum > -1) {
int32 val = _drawingStructs[0].transTableNum;
- if (_data_455BD4
+ if (_shouldCloseDialog
&& _drawingStructs[0].status != 2
&& _drawingStructs[0].transTableNum > -1) {
val = _drawingStructs[0].transTableNum - 1;
@@ -1002,7 +1011,7 @@ void Encounter::drawStructs() {
if (checkKeywords() || _drawingStructs[1].transTableNum > -1) {
int32 val = _drawingStructs[1].transTableNum;
- if (_data_455BD4
+ if (_shouldCloseDialog
&& _drawingStructs[1].status != 2
&& _drawingStructs[1].transTableNum > -1) {
val = _drawingStructs[1].transTableNum - 1;
@@ -1344,20 +1353,20 @@ bool Encounter::updateScreen() {
getText()->loadFont(getWorld()->font1);
if (!drawBackground()) {
- _data_455BD0 = false;
+ _isDialogOpen = false;
return false;
}
if (!drawPortraits()) {
- _data_455BD0 = false;
+ _isDialogOpen = false;
- if (_data_455BD4)
+ if (_shouldCloseDialog)
drawStructs();
return false;
}
- if (_data_455BD0) {
+ if (_isDialogOpen) {
if (!getSpeech()->getTextDataPos() && !getSpeech()->getTextData()) {
@@ -1393,7 +1402,7 @@ bool Encounter::updateScreen() {
if (_data_455BF4)
_data_455BF4 = 1;
- _data_455BD0 = true;
+ _isDialogOpen = true;
return false;
}
@@ -1516,7 +1525,7 @@ void Encounter::runScript() {
case 13:
if (!_flag3)
- _data_455BD4 = true;
+ _shouldCloseDialog = true;
done = true;
break;
diff --git a/engines/asylum/resources/encounters.h b/engines/asylum/resources/encounters.h
index 2ac8b7fa6d..0b601eaf64 100644
--- a/engines/asylum/resources/encounters.h
+++ b/engines/asylum/resources/encounters.h
@@ -96,8 +96,8 @@ public:
void drawScreen();
- void setFlag1(bool state) { _flag1 = state; }
- bool getFlag1() { return _flag1; }
+ void setShouldEnablePlayer(bool state) { _shouldEnablePlayer = state; }
+ bool shouldEnablePlayer() { return _shouldEnablePlayer; }
void setFlag3(bool state) { _flag3 = state; }
bool getFlag3() { return _flag3; }
@@ -187,20 +187,20 @@ private:
int16 _data_455B3C;
int16 _data_455B70;
bool _data_455BCC;
- bool _data_455BD0;
- bool _data_455BD4;
+ bool _isDialogOpen;
+ bool _shouldCloseDialog;
bool _data_455BD8;
bool _data_455BDC;
bool _data_455BE0;
- bool _data_455BE4;
+ bool _shouldCloseBackground;
bool _data_455BE8;
int16 _data_455BF0;
uint32 _data_455BF4;
uint32 _keywordStartIndex;
// Internal flags
- bool _flag1;
- bool _flag2;
+ bool _shouldEnablePlayer;
+ bool _wasPlayerDisabled;
bool _flag3;
bool _flag4;
diff --git a/engines/asylum/views/scene.cpp b/engines/asylum/views/scene.cpp
index 403c4056ec..575591c14c 100644
--- a/engines/asylum/views/scene.cpp
+++ b/engines/asylum/views/scene.cpp
@@ -371,8 +371,8 @@ bool Scene::init() {
}
bool Scene::update() {
- if (getEncounter()->getFlag1()) {
- getEncounter()->setFlag1(false);
+ if (getEncounter()->shouldEnablePlayer()) {
+ getEncounter()->setShouldEnablePlayer(false);
// Enable player
getActor()->updateStatus(kActorStatusEnabled);
Commit: 76fd40f9316cf42305642fe788a99d262680c8b6
https://github.com/scummvm/scummvm/commit/76fd40f9316cf42305642fe788a99d262680c8b6
Author: Littleboy (littleboy at scummvm.org)
Date: 2021-05-17T15:37:22+02:00
Commit Message:
ASYLUM: Update Encounter
- Add opcode enumeration and enhance debug output
- Fix initData()
- Misc cleanups
Changed paths:
engines/asylum/resources/encounters.cpp
engines/asylum/resources/encounters.h
engines/asylum/shared.h
diff --git a/engines/asylum/resources/encounters.cpp b/engines/asylum/resources/encounters.cpp
index 13df712e1d..0adf7d02e7 100644
--- a/engines/asylum/resources/encounters.cpp
+++ b/engines/asylum/resources/encounters.cpp
@@ -44,9 +44,43 @@ namespace Asylum {
#define KEYWORD_MASK 0xFFF
+#define OPCODE_NAME(index) (index > 25 ? "INVALID" : opcodeNames[index])
+const char *opcodeNames[] = {
+ "Return", // 0
+ "SetScriptVar",
+ "",
+ "",
+ "",
+ "", // 5
+ "",
+ "",
+ "",
+ "",
+ "", // 10
+ "",
+ "",
+ "",
+ "",
+ "", // 15
+ "",
+ "",
+ "",
+ "",
+ "", // 20
+ "",
+ "",
+ "",
+ "",
+ "" // 25
+};
+
+Common::String Encounter::ScriptEntry::toString() {
+ return Common::String::format("0x%02X: %s (%d, %d)", opcode, OPCODE_NAME(opcode), param1, param2);
+}
+
Encounter::Encounter(AsylumEngine *engine) : _vm(engine),
_index(0), _keywordIndex(0), _item(NULL), _objectId1(kObjectNone), _objectId2(kObjectNone), _objectId3(kObjectNone),
- _actorIndex(kActorInvalid), _shouldEnablePlayer(false), _wasPlayerDisabled(false), _flag3(false), _flag4(false) {
+ _actorIndex(kActorInvalid), _shouldEnablePlayer(false), _wasPlayerDisabled(false), _flag3(false), _isScriptRunning(false) {
memset(&_keywordIndexes, 0, sizeof(_keywordIndexes));
_rectIndex = -1;
@@ -106,9 +140,8 @@ void Encounter::load() {
item.field2 = file.readSint16LE();
item.scriptResourceId = (ResourceId)file.readSint32LE();
- for (uint j = 0; j < 50; j++) {
+ for (uint j = 0; j < ARRAYSIZE(item.keywords); j++)
item.keywords[j] = file.readSint16LE();
- }
item.value = file.readByte();
@@ -132,9 +165,9 @@ void Encounter::initData() {
}
}
- for (uint i = currentIndex; i < 50; i++) {
+ for (uint i = 0; i < 50; i++) {
if (_item->keywords[i] & KEYWORD_MASK) {
- if (!(BYTE1(_item->keywords[i]) & 0x20)) {
+ if (BYTE1(_item->keywords[i]) & 0x20) {
_keywordIndexes[currentIndex] = i;
currentIndex++;
}
@@ -424,7 +457,7 @@ bool Encounter::update() {
|| (getSpeech()->getTick() && tick >= getSpeech()->getTick()))
doScript = true;
- if (!getSharedData()->getMatteBarHeight() && doScript && _flag4) {
+ if (!getSharedData()->getMatteBarHeight() && doScript && _isScriptRunning) {
if (!setupSpeech(id))
runScript();
}
@@ -576,7 +609,7 @@ int32 Encounter::getKeywordIndex() {
}
void Encounter::choose(int32 index) {
- if (_flag4 || index == -1)
+ if (_isScriptRunning || index == -1)
return;
if ((_item->keywords[index] & KEYWORD_MASK) && (BYTE1(_item->keywords[index]) & 0x80)) {
@@ -807,7 +840,7 @@ bool Encounter::setupSpeech(ResourceId id) {
}
bool Encounter::isSpeaking() {
- if (!_flag4)
+ if (!_isScriptRunning)
return false;
if (getSpeech()->getSoundResourceId() != kResourceNone && getSound()->isPlaying(getSpeech()->getSoundResourceId())) {
@@ -1076,9 +1109,10 @@ void Encounter::drawDialog() {
if (keywordIndex < 0)
continue;
- if ((_item->keywords[keywordIndex] & KEYWORD_MASK) > 0 && (BYTE1(_keywordIndexes[i]) & 0x80)) {
+ int16 keyword = _item->keywords[keywordIndex];
+ if ((keyword & KEYWORD_MASK) > 0 && (BYTE1(keyword) & 0x80)) {
- if (BYTE1(_keywordIndexes[i]) & 0x20)
+ if (BYTE1(keyword) & 0x20)
getText()->loadFont(getWorld()->font2);
else
getText()->loadFont(getWorld()->font1);
@@ -1087,10 +1121,10 @@ void Encounter::drawDialog() {
_point.y + (int16)(16 * counter / 3));
if (getKeywordIndex() == keywordIndex)
- getScreen()->fillRect(coords.x - 1, coords.y + 5, getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 3681 + keywordIndex)), 18, 0);
+ getScreen()->fillRect(coords.x - 1, coords.y + 5, getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 3681 + (keyword & KEYWORD_MASK))), 18, 0);
getText()->setPosition(coords);
- getText()->draw(MAKE_RESOURCE(kResourcePackText, 3681 + keywordIndex));
+ getText()->draw(MAKE_RESOURCE(kResourcePackText, 3681 + (keyword & KEYWORD_MASK)));
++counter;
_data_455B14 = i;
@@ -1380,8 +1414,10 @@ bool Encounter::updateScreen() {
return false;
}
- drawText(getSpeech()->getTextDataPos(), getWorld()->font3, _point.y);
- drawText(getSpeech()->getTextData(), getWorld()->font1, _point.y);
+ if (Config.showEncounterSubtitles) {
+ drawText(getSpeech()->getTextDataPos(), getWorld()->font3, _point.y);
+ drawText(getSpeech()->getTextData(), getWorld()->font1, _point.y);
+ }
if (_data_455BE0) {
_data_455BE0 = false;
@@ -1399,7 +1435,7 @@ bool Encounter::updateScreen() {
if (_objectId3 || _data_455BE8)
return false;
- if (_data_455BF4)
+ if (!_data_455BF4)
_data_455BF4 = 1;
_isDialogOpen = true;
@@ -1426,125 +1462,125 @@ void Encounter::initScript(ResourceId resourceId) {
Encounter::ScriptEntry Encounter::getScriptEntry(ResourceId resourceId, uint32 offset) {
ResourceEntry *entry = getResource()->get(resourceId);
- return (ScriptEntry)entry->getData(offset);
+ return ScriptEntry(entry->getData(offset));
}
void Encounter::runScript() {
- _flag4 = true;
+ _isScriptRunning = true;
bool done = false;
do {
ScriptEntry entry = getScriptEntry(_scriptData.resourceId, _scriptData.offset);
- debugC(kDebugLevelEncounter, "[Encounter] Script %s", entry.toString().c_str());
+ debugC(kDebugLevelEncounter, "[Encounter] %s", entry.toString().c_str());
switch (entry.opcode) {
default:
break;
- case 0:
- _flag4 = false;
+ case kOpcodeReturn:
+ _isScriptRunning = false;
done = true;
_value1 = 0;
break;
- case 1:
+ case kOpcodeSetScriptVar:
_scriptData.vars[entry.param1] = getVariableInv(entry.param2);
break;
- case 2:
+ case kOpcode2:
_scriptData.counter = _scriptData.vars[entry.param1] - getVariableInv(entry.param2);
break;
- case 3:
+ case kOpcode3:
_scriptData.offset = entry.param2 - 1;
break;
- case 4:
+ case kOpcode4:
if (_scriptData.counter >= 0)
break;
_scriptData.offset = entry.param2;
break;
- case 5:
+ case kOpcode5:
if (_scriptData.counter > 0)
break;
_scriptData.offset = entry.param2;
break;
- case 6:
+ case kOpcode6:
if (_scriptData.counter)
break;
_scriptData.offset = entry.param2 - 1;
break;
- case 7:
+ case kOpcode7:
if (!_scriptData.counter)
break;
_scriptData.offset = entry.param2;
break;
- case 8:
+ case kOpcode8:
if (_scriptData.counter < 0)
break;
_scriptData.offset = entry.param2;
break;
- case 9:
+ case kOpcode9:
if (_scriptData.counter <= 0)
break;
_scriptData.offset = entry.param2 - 1;
break;
- case 10:
+ case kOpcode10:
if (entry.param1)
_item->keywords[findKeyword(_item, entry.param2)] &= ~kEncounterArray2000;
else
_item->keywords[findKeyword(_item, entry.param2)] |= kEncounterArray8000;
break;
- case 11:
+ case kOpcode11:
if (entry.param1)
_item->keywords[findKeyword(_item, entry.param2)] |= kEncounterArray2000;
else
_item->keywords[findKeyword(_item, entry.param2)] &= ~kEncounterArray8000;
break;
- case 12:
+ case kOpcode12:
_items[entry.param1].keywords[findKeyword(&_items[entry.param1], entry.param2)] |= kEncounterArray4000;
_items[entry.param1].keywords[findKeyword(&_items[entry.param1], entry.param2)] |= kEncounterArray8000;
// Original saves the item back here
break;
- case 13:
+ case kOpcode13:
if (!_flag3)
_shouldCloseDialog = true;
done = true;
break;
- case 14:
+ case kOpcode14:
resetSpeech(_item->keywordIndex, getVariableInv(entry.param2));
done = true;
break;
- case 15:
+ case kOpcode15:
setVariable(entry.param2, (int16)_scriptData.vars[entry.param1]);
break;
- case 16:
+ case kOpcode16:
_scriptData.vars[entry.param1] += entry.param2;
break;
- case 17:
+ case kOpcode17:
switch (getVariable(3)) {
default:
break;
@@ -1595,18 +1631,18 @@ void Encounter::runScript() {
}
break;
- case 18:
+ case kOpcode18:
if (entry.param1)
getScene()->getActor()->removeReactionHive(getVariableInv(entry.param2), _scriptData.vars[1]);
else
getScene()->getActor()->addReactionHive(getVariableInv(entry.param2), _scriptData.vars[1]);
break;
- case 21:
+ case kOpcode21:
_scriptData.counter = getScene()->getActor()->hasMoreReactions(getVariableInv(entry.param2), _scriptData.vars[1]) ? 0 : 1;
break;
- case 23:
+ case kOpcode23:
if (!getSharedData()->getMatteBarHeight()) {
getScreen()->loadPalette();
getSharedData()->setMatteBarHeight(1);
@@ -1624,14 +1660,14 @@ void Encounter::runScript() {
}
break;
- case 24:
+ case kOpcode24:
if (entry.param1)
_vm->setGameFlag((GameFlag)getVariableInv(entry.param2));
else
_vm->clearGameFlag((GameFlag)getVariableInv(entry.param2));
break;
- case 25:
+ case kOpcode25:
_scriptData.counter = _vm->isGameFlagSet((GameFlag)getVariableInv(entry.param2)) ? 1 : 0;
break;
}
diff --git a/engines/asylum/resources/encounters.h b/engines/asylum/resources/encounters.h
index 0b601eaf64..f313c9003f 100644
--- a/engines/asylum/resources/encounters.h
+++ b/engines/asylum/resources/encounters.h
@@ -98,8 +98,6 @@ public:
void setShouldEnablePlayer(bool state) { _shouldEnablePlayer = state; }
bool shouldEnablePlayer() { return _shouldEnablePlayer; }
- void setFlag3(bool state) { _flag3 = state; }
- bool getFlag3() { return _flag3; }
// Accessors (for saving game)
EncounterItems *items() { return &_items; }
@@ -202,7 +200,7 @@ private:
bool _shouldEnablePlayer;
bool _wasPlayerDisabled;
bool _flag3;
- bool _flag4;
+ bool _isScriptRunning;
//////////////////////////////////////////////////////////////////////////
// Data
@@ -266,6 +264,35 @@ private:
//////////////////////////////////////////////////////////////////////////
// Scripts
+ enum EncounterOpcode {
+ kOpcodeReturn = 0,
+ kOpcodeSetScriptVar = 1,
+ kOpcode2 = 2,
+ kOpcode3 = 3,
+ kOpcode4 = 4,
+ kOpcode5 = 5,
+ kOpcode6 = 6,
+ kOpcode7 = 7,
+ kOpcode8 = 8,
+ kOpcode9 = 9,
+ kOpcode10 = 10,
+ kOpcode11 = 11,
+ kOpcode12 = 12,
+ kOpcode13 = 13,
+ kOpcode14 = 14,
+ kOpcode15 = 15,
+ kOpcode16 = 16,
+ kOpcode17 = 17,
+ kOpcode18 = 18,
+ kOpcode19 = 19,
+ kOpcode20 = 20,
+ kOpcode21 = 21,
+ kOpcode22 = 22,
+ kOpcode23 = 23,
+ kOpcode24 = 24,
+ kOpcode25 = 25
+ };
+
struct ScriptEntry {
union {
byte opcode;
@@ -278,9 +305,7 @@ private:
data = val;
}
- Common::String toString() {
- return Common::String::format("[0x%02X] %d %d", opcode, param1, param2);
- }
+ Common::String toString();
};
struct ScriptData {
diff --git a/engines/asylum/shared.h b/engines/asylum/shared.h
index 8a6d66e893..f6d1cd7ca7 100644
--- a/engines/asylum/shared.h
+++ b/engines/asylum/shared.h
@@ -712,6 +712,7 @@ enum PuzzleId {
//////////////////////////////////////////////////////////////////////////
#define LOBYTE(d) (*((char*)&(d)))
#define BYTE1(d) (*((char*)&(d)+1)) // Same as HIBYTE()
+#define LOWORD(x) (*((int16*)&(x)))
//////////////////////////////////////////////////////////////////////////
// Resource ID macros
Commit: 5dffe407336559e5cd41fe16984e30506ef07ded
https://github.com/scummvm/scummvm/commit/5dffe407336559e5cd41fe16984e30506ef07ded
Author: Littleboy (littleboy at scummvm.org)
Date: 2021-05-17T15:37:22+02:00
Commit Message:
ASYLUM: Rename EncounterItem::keywordIndex to speechResourceId
Changed paths:
engines/asylum/resources/encounters.cpp
engines/asylum/resources/encounters.h
diff --git a/engines/asylum/resources/encounters.cpp b/engines/asylum/resources/encounters.cpp
index 0adf7d02e7..9ec899b412 100644
--- a/engines/asylum/resources/encounters.cpp
+++ b/engines/asylum/resources/encounters.cpp
@@ -79,7 +79,7 @@ Common::String Encounter::ScriptEntry::toString() {
}
Encounter::Encounter(AsylumEngine *engine) : _vm(engine),
- _index(0), _keywordIndex(0), _item(NULL), _objectId1(kObjectNone), _objectId2(kObjectNone), _objectId3(kObjectNone),
+ _index(0), _speechResourceId(0), _item(NULL), _objectId1(kObjectNone), _objectId2(kObjectNone), _objectId3(kObjectNone),
_actorIndex(kActorInvalid), _shouldEnablePlayer(false), _wasPlayerDisabled(false), _flag3(false), _isScriptRunning(false) {
memset(&_keywordIndexes, 0, sizeof(_keywordIndexes));
@@ -136,9 +136,8 @@ void Encounter::load() {
for (uint8 i = 0; i < dataCount; i++) {
EncounterItem item;
- item.keywordIndex = file.readSint16LE();
- item.field2 = file.readSint16LE();
- item.scriptResourceId = (ResourceId)file.readSint32LE();
+ item.speechResourceId = file.readSint32LE();
+ item.scriptResourceId = (ResourceId)file.readSint32LE();
for (uint j = 0; j < ARRAYSIZE(item.keywords); j++)
item.keywords[j] = file.readSint16LE();
@@ -253,9 +252,9 @@ void Encounter::initDrawStructs() {
void Encounter::run(int32 encounterIndex, ObjectId objectId1, ObjectId objectId2, ActorIndex actorIndex) {
debugC(kDebugLevelEncounter, "[Encounter] Running Encounter %d", encounterIndex);
- if (!_keywordIndex) {
+ if (!_speechResourceId) {
_item = &_items[0];
- _keywordIndex = _item->keywordIndex;
+ _speechResourceId = _item->speechResourceId;
}
if (encounterIndex < 0)
@@ -809,7 +808,7 @@ void Encounter::setupSpeech(ResourceId textResourceId, ResourceId fontResourceId
}
_data_455BE0 = true;
- getSpeech()->setSoundResourceId(MAKE_RESOURCE(kResourcePackSharedSound, textResourceId - _keywordIndex));
+ getSpeech()->setSoundResourceId(MAKE_RESOURCE(kResourcePackSharedSound, textResourceId - _speechResourceId));
}
bool Encounter::setupSpeech(ResourceId id) {
@@ -1093,7 +1092,7 @@ void Encounter::drawStructs() {
}
}
-void Encounter::drawDialog() {
+void Encounter::drawDialogOptions() {
getText()->loadFont(getWorld()->font1);
if (_keywordStartIndex >= 50)
@@ -1132,7 +1131,7 @@ void Encounter::drawDialog() {
}
}
-void Encounter::drawText(char *text, ResourceId font, int16 y) {
+void Encounter::drawSubtitle(char *text, ResourceId font, int16 y) {
if (!text)
return;
@@ -1404,7 +1403,7 @@ bool Encounter::updateScreen() {
if (!getSpeech()->getTextDataPos() && !getSpeech()->getTextData()) {
- drawDialog();
+ drawDialogOptions();
updateDrawingStatus();
drawStructs();
@@ -1415,8 +1414,8 @@ bool Encounter::updateScreen() {
}
if (Config.showEncounterSubtitles) {
- drawText(getSpeech()->getTextDataPos(), getWorld()->font3, _point.y);
- drawText(getSpeech()->getTextData(), getWorld()->font1, _point.y);
+ drawSubtitle(getSpeech()->getTextDataPos(), getWorld()->font3, _point.y);
+ drawSubtitle(getSpeech()->getTextData(), getWorld()->font1, _point.y);
}
if (_data_455BE0) {
@@ -1567,7 +1566,7 @@ void Encounter::runScript() {
break;
case kOpcode14:
- resetSpeech(_item->keywordIndex, getVariableInv(entry.param2));
+ resetSpeech(_item->speechResourceId, getVariableInv(entry.param2));
done = true;
break;
diff --git a/engines/asylum/resources/encounters.h b/engines/asylum/resources/encounters.h
index f313c9003f..306b69dd29 100644
--- a/engines/asylum/resources/encounters.h
+++ b/engines/asylum/resources/encounters.h
@@ -34,15 +34,13 @@ namespace Asylum {
class AsylumEngine;
struct EncounterItem : public Common::Serializable {
- int16 keywordIndex;
- int16 field2;
+ uint32 speechResourceId;
ResourceId scriptResourceId;
int16 keywords[50];
byte value;
EncounterItem() {
- keywordIndex = 0;
- field2 = 0;
+ speechResourceId = 0;
scriptResourceId = kResourceNone;
memset(&keywords, 0, sizeof(keywords));
value = 0;
@@ -52,8 +50,7 @@ struct EncounterItem : public Common::Serializable {
// Serializable
void saveLoadWithSerializer(Common::Serializer &s) {
- s.syncAsSint16LE(keywordIndex);
- s.syncAsSint16LE(field2);
+ s.syncAsSint32LE(speechResourceId);
s.syncAsSint32LE(scriptResourceId);
for (int32 i = 0; i < ARRAYSIZE(keywords); i++)
@@ -170,7 +167,7 @@ private:
// Running encounter data
int32 _index;
- int32 _keywordIndex;
+ int32 _speechResourceId;
EncounterItem *_item;
ObjectId _objectId1;
ObjectId _objectId2;
@@ -196,6 +193,8 @@ private:
uint32 _data_455BF4;
uint32 _keywordStartIndex;
+ EventHandler *_previousEventHandler;
+
// Internal flags
bool _shouldEnablePlayer;
bool _wasPlayerDisabled;
@@ -247,8 +246,8 @@ private:
bool drawBackground();
bool drawPortraits();
void drawStructs();
- void drawDialog();
- void drawText(char *text, ResourceId font, int16 y);
+ void drawDialogOptions();
+ void drawSubtitle(char *text, ResourceId font, int16 y);
//////////////////////////////////////////////////////////////////////////
// Misc
Commit: e05d0c21e4a05edee06541f65ee355d78bcb47d0
https://github.com/scummvm/scummvm/commit/e05d0c21e4a05edee06541f65ee355d78bcb47d0
Author: Littleboy (littleboy at scummvm.org)
Date: 2021-05-17T15:37:22+02:00
Commit Message:
ASYLUM: Rename more Encounter script opcodes
Changed paths:
engines/asylum/resources/encounters.cpp
engines/asylum/resources/encounters.h
diff --git a/engines/asylum/resources/encounters.cpp b/engines/asylum/resources/encounters.cpp
index 9ec899b412..d077df4e61 100644
--- a/engines/asylum/resources/encounters.cpp
+++ b/engines/asylum/resources/encounters.cpp
@@ -46,32 +46,32 @@ namespace Asylum {
#define OPCODE_NAME(index) (index > 25 ? "INVALID" : opcodeNames[index])
const char *opcodeNames[] = {
- "Return", // 0
- "SetScriptVar",
+ "Return",
+ "SetScriptVariable",
"",
"",
"",
- "", // 5
"",
"",
"",
"",
- "", // 10
"",
"",
"",
"",
- "", // 15
"",
+ "ResetSpeech",
+ "SetVariable",
+ "IncrementScriptVariable",
"",
+ "AddRemoveReactionHive",
"",
"",
- "", // 20
+ "SetCounterFromActorReactions",
"",
"",
- "",
- "",
- "" // 25
+ "SetClearFlag",
+ "SetCounterFromFlag"
};
Common::String Encounter::ScriptEntry::toString() {
@@ -1483,7 +1483,7 @@ void Encounter::runScript() {
_value1 = 0;
break;
- case kOpcodeSetScriptVar:
+ case kOpcodeSetScriptVariable:
_scriptData.vars[entry.param1] = getVariableInv(entry.param2);
break;
@@ -1565,17 +1565,17 @@ void Encounter::runScript() {
done = true;
break;
- case kOpcode14:
+ case kOpcodeResetSpeech:
resetSpeech(_item->speechResourceId, getVariableInv(entry.param2));
done = true;
break;
- case kOpcode15:
+ case kOpcodeSetVariable:
setVariable(entry.param2, (int16)_scriptData.vars[entry.param1]);
break;
- case kOpcode16:
+ case kOpcodeIncrementScriptVariable:
_scriptData.vars[entry.param1] += entry.param2;
break;
@@ -1630,14 +1630,14 @@ void Encounter::runScript() {
}
break;
- case kOpcode18:
+ case kOpcodeAddRemoveReactionHive:
if (entry.param1)
getScene()->getActor()->removeReactionHive(getVariableInv(entry.param2), _scriptData.vars[1]);
else
getScene()->getActor()->addReactionHive(getVariableInv(entry.param2), _scriptData.vars[1]);
break;
- case kOpcode21:
+ case kOpcodeSetCounterFromActorReactions:
_scriptData.counter = getScene()->getActor()->hasMoreReactions(getVariableInv(entry.param2), _scriptData.vars[1]) ? 0 : 1;
break;
@@ -1659,14 +1659,14 @@ void Encounter::runScript() {
}
break;
- case kOpcode24:
+ case kOpcodeSetClearFlag:
if (entry.param1)
_vm->setGameFlag((GameFlag)getVariableInv(entry.param2));
else
_vm->clearGameFlag((GameFlag)getVariableInv(entry.param2));
break;
- case kOpcode25:
+ case kOpcodeSetCounterFromFlag:
_scriptData.counter = _vm->isGameFlagSet((GameFlag)getVariableInv(entry.param2)) ? 1 : 0;
break;
}
diff --git a/engines/asylum/resources/encounters.h b/engines/asylum/resources/encounters.h
index 306b69dd29..84cc455d13 100644
--- a/engines/asylum/resources/encounters.h
+++ b/engines/asylum/resources/encounters.h
@@ -264,32 +264,32 @@ private:
//////////////////////////////////////////////////////////////////////////
// Scripts
enum EncounterOpcode {
- kOpcodeReturn = 0,
- kOpcodeSetScriptVar = 1,
- kOpcode2 = 2,
- kOpcode3 = 3,
- kOpcode4 = 4,
- kOpcode5 = 5,
- kOpcode6 = 6,
- kOpcode7 = 7,
- kOpcode8 = 8,
- kOpcode9 = 9,
- kOpcode10 = 10,
- kOpcode11 = 11,
- kOpcode12 = 12,
- kOpcode13 = 13,
- kOpcode14 = 14,
- kOpcode15 = 15,
- kOpcode16 = 16,
- kOpcode17 = 17,
- kOpcode18 = 18,
- kOpcode19 = 19,
- kOpcode20 = 20,
- kOpcode21 = 21,
- kOpcode22 = 22,
- kOpcode23 = 23,
- kOpcode24 = 24,
- kOpcode25 = 25
+ kOpcodeReturn = 0,
+ kOpcodeSetScriptVariable = 1,
+ kOpcode2 = 2,
+ kOpcode3 = 3,
+ kOpcode4 = 4,
+ kOpcode5 = 5,
+ kOpcode6 = 6,
+ kOpcode7 = 7,
+ kOpcode8 = 8,
+ kOpcode9 = 9,
+ kOpcode10 = 10,
+ kOpcode11 = 11,
+ kOpcode12 = 12,
+ kOpcode13 = 13,
+ kOpcodeResetSpeech = 14,
+ kOpcodeSetVariable = 15,
+ kOpcodeIncrementScriptVariable = 16,
+ kOpcode17 = 17,
+ kOpcodeAddRemoveReactionHive = 18,
+ kOpcode19 = 19,
+ kOpcode20 = 20,
+ kOpcodeSetCounterFromActorReactions = 21,
+ kOpcode22 = 22,
+ kOpcode23 = 23,
+ kOpcodeSetClearFlag = 24,
+ kOpcodeSetCounterFromFlag = 25
};
struct ScriptEntry {
Commit: 03df42a1c7c0ac13a2874737d8463120f468e395
https://github.com/scummvm/scummvm/commit/03df42a1c7c0ac13a2874737d8463120f468e395
Author: Littleboy (littleboy at scummvm.org)
Date: 2021-05-17T15:37:22+02:00
Commit Message:
ASYLUM: Fix part of encounter scripting
The script entries are now read properly and the scripts are executing far enough to show the keywords on screen
Changed paths:
engines/asylum/resources/encounters.cpp
engines/asylum/resources/encounters.h
engines/asylum/shared.h
diff --git a/engines/asylum/resources/encounters.cpp b/engines/asylum/resources/encounters.cpp
index d077df4e61..7832fe47cd 100644
--- a/engines/asylum/resources/encounters.cpp
+++ b/engines/asylum/resources/encounters.cpp
@@ -48,28 +48,28 @@ namespace Asylum {
const char *opcodeNames[] = {
"Return",
"SetScriptVariable",
- "",
- "",
- "",
- "",
- "",
- "",
- "",
- "",
- "",
- "",
- "",
- "",
+ "2"
+ "3",
+ "4",
+ "5",
+ "6",
+ "7",
+ "8",
+ "9",
+ "10",
+ "11",
+ "12",
+ "13",
"ResetSpeech",
"SetVariable",
"IncrementScriptVariable",
- "",
+ "17",
"AddRemoveReactionHive",
- "",
- "",
+ "UNUSED(19)",
+ "UNUSED(20)",
"SetCounterFromActorReactions",
- "",
- "",
+ "UNUSED(22)",
+ "23",
"SetClearFlag",
"SetCounterFromFlag"
};
@@ -157,7 +157,7 @@ void Encounter::initData() {
for (uint i = 0; i < 50; i++) {
if (_item->keywords[i] & KEYWORD_MASK) {
- if (!(BYTE1(_item->keywords[i]) & 0x20)) {
+ if (!isKeywordDisabled(_item->keywords[i])) {
_keywordIndexes[currentIndex] = i;
currentIndex++;
}
@@ -166,7 +166,7 @@ void Encounter::initData() {
for (uint i = 0; i < 50; i++) {
if (_item->keywords[i] & KEYWORD_MASK) {
- if (BYTE1(_item->keywords[i]) & 0x20) {
+ if (isKeywordDisabled(_item->keywords[i])) {
_keywordIndexes[currentIndex] = i;
currentIndex++;
}
@@ -592,7 +592,7 @@ int32 Encounter::getKeywordIndex() {
if (counter / 3 >= 8)
break;
- if ((_item->keywords[index] & KEYWORD_MASK) && (BYTE1(_item->keywords[index]) & 0x80)) {
+ if ((_item->keywords[index] & KEYWORD_MASK) > 0 && isKeywordVisible(_item->keywords[index])) {
int32 x = _drawingStructs[0].point1.x + 144 * (counter % 3) + _point.x + (counter % 3) + _portrait1.rect.width() + 15;
int32 y = 16 * counter / 3 + _point.y + 5;
@@ -611,14 +611,14 @@ void Encounter::choose(int32 index) {
if (_isScriptRunning || index == -1)
return;
- if ((_item->keywords[index] & KEYWORD_MASK) && (BYTE1(_item->keywords[index]) & 0x80)) {
+ if ((_item->keywords[index] & KEYWORD_MASK) && isKeywordVisible(_item->keywords[index])) {
_value1 = (_item->keywords[index] & KEYWORD_MASK);
setVariable(1, _value1);
if (strcmp("Goodbye", getText()->get(MAKE_RESOURCE(kResourcePackText, 3681 + index))))
if (_index != 79)
- BYTE1(_item->keywords[index]) |= 0x20;
+ BYTE1(_item->keywords[index]) |= kKeywordOptionsDisabled;
initScript(_item->scriptResourceId);
runScript();
@@ -635,7 +635,7 @@ bool Encounter::checkKeywords() const {
if (index < 0)
continue;
- if ((_item->keywords[index] & KEYWORD_MASK) && (BYTE1(_item->keywords[index]) & 0x80))
+ if ((_item->keywords[index] & KEYWORD_MASK) && isKeywordVisible(_item->keywords[index]))
return true;
}
@@ -649,7 +649,7 @@ bool Encounter::checkKeywords2() const {
if (index < 0)
continue;
- if ((_item->keywords[index] & KEYWORD_MASK) && (BYTE1(_item->keywords[index]) & 0x80))
+ if ((_item->keywords[index] & KEYWORD_MASK) && isKeywordVisible(_item->keywords[index]))
return true;
}
@@ -667,7 +667,7 @@ void Encounter::updateFromRect(int32 rectIndex) {
if (index < 0)
continue;
- if ((_item->keywords[index] & KEYWORD_MASK) && (BYTE1(_item->keywords[index]) & 0x80)) {
+ if ((_item->keywords[index] & KEYWORD_MASK) && isKeywordVisible(_item->keywords[index])) {
cont = true;
break;
}
@@ -686,7 +686,7 @@ void Encounter::updateFromRect(int32 rectIndex) {
if (index < 0)
continue;
- if ((_item->keywords[index] & KEYWORD_MASK) && (BYTE1(_item->keywords[index]) & 0x80)) {
+ if ((_item->keywords[index] & KEYWORD_MASK) && isKeywordVisible(_item->keywords[index])) {
_keywordStartIndex = i;
++counter;
}
@@ -703,7 +703,7 @@ void Encounter::updateFromRect(int32 rectIndex) {
if (index < 0)
continue;
- if ((_item->keywords[index] & KEYWORD_MASK) && (BYTE1(_item->keywords[index]) & 0x80)) {
+ if ((_item->keywords[index] & KEYWORD_MASK) && isKeywordVisible(_item->keywords[index])) {
_keywordStartIndex = (uint32)i;
++counter;
}
@@ -1109,9 +1109,9 @@ void Encounter::drawDialogOptions() {
continue;
int16 keyword = _item->keywords[keywordIndex];
- if ((keyword & KEYWORD_MASK) > 0 && (BYTE1(keyword) & 0x80)) {
+ if ((keyword & KEYWORD_MASK) > 0 && isKeywordVisible(keyword)) {
- if (BYTE1(keyword) & 0x20)
+ if (isKeywordDisabled(keyword))
getText()->loadFont(getWorld()->font2);
else
getText()->loadFont(getWorld()->font1);
@@ -1460,8 +1460,7 @@ void Encounter::initScript(ResourceId resourceId) {
Encounter::ScriptEntry Encounter::getScriptEntry(ResourceId resourceId, uint32 offset) {
ResourceEntry *entry = getResource()->get(resourceId);
-
- return ScriptEntry(entry->getData(offset));
+ return ScriptEntry(entry->data + offset * 4);
}
void Encounter::runScript() {
@@ -1539,21 +1538,21 @@ void Encounter::runScript() {
case kOpcode10:
if (entry.param1)
- _item->keywords[findKeyword(_item, entry.param2)] &= ~kEncounterArray2000;
+ _item->keywords[findKeyword(_item, entry.param2)] &= ~(kKeywordOptionsDisabled << 8);
else
- _item->keywords[findKeyword(_item, entry.param2)] |= kEncounterArray8000;
+ _item->keywords[findKeyword(_item, entry.param2)] |= (kKeywordOptionsVisible << 8);
break;
case kOpcode11:
if (entry.param1)
- _item->keywords[findKeyword(_item, entry.param2)] |= kEncounterArray2000;
+ _item->keywords[findKeyword(_item, entry.param2)] |= (kKeywordOptionsDisabled << 8);
else
- _item->keywords[findKeyword(_item, entry.param2)] &= ~kEncounterArray8000;
+ _item->keywords[findKeyword(_item, entry.param2)] &= ~(kKeywordOptionsVisible << 8);
break;
case kOpcode12:
- _items[entry.param1].keywords[findKeyword(&_items[entry.param1], entry.param2)] |= kEncounterArray4000;
- _items[entry.param1].keywords[findKeyword(&_items[entry.param1], entry.param2)] |= kEncounterArray8000;
+ _items[entry.param1].keywords[findKeyword(&_items[entry.param1], entry.param2)] |= (kKeywordOptionsUnknown << 8);
+ _items[entry.param1].keywords[findKeyword(&_items[entry.param1], entry.param2)] |= (kKeywordOptionsVisible << 8);
// Original saves the item back here
break;
diff --git a/engines/asylum/resources/encounters.h b/engines/asylum/resources/encounters.h
index 84cc455d13..d773a4a5e0 100644
--- a/engines/asylum/resources/encounters.h
+++ b/engines/asylum/resources/encounters.h
@@ -105,10 +105,10 @@ private:
//////////////////////////////////////////////////////////////////////////
// Data
- enum EncounterArray {
- kEncounterArray2000 = 0x2000,
- kEncounterArray4000 = 0x4000,
- kEncounterArray8000 = 0x8000
+ enum KeywordOptions {
+ kKeywordOptionsDisabled = 0x20,
+ kKeywordOptionsUnknown = 0x40,
+ kKeywordOptionsVisible = 0x80
};
struct EncounterGraphic {
@@ -261,6 +261,9 @@ private:
void updatePalette1();
void updatePalette2();
+ bool isKeywordVisible(int16 keyword) const { return (bool)(BYTE1(keyword) & kKeywordOptionsVisible); }
+ bool isKeywordDisabled(int16 keyword) const { return (bool)(BYTE1(keyword) & kKeywordOptionsDisabled); }
+
//////////////////////////////////////////////////////////////////////////
// Scripts
enum EncounterOpcode {
@@ -283,25 +286,21 @@ private:
kOpcodeIncrementScriptVariable = 16,
kOpcode17 = 17,
kOpcodeAddRemoveReactionHive = 18,
- kOpcode19 = 19,
- kOpcode20 = 20,
kOpcodeSetCounterFromActorReactions = 21,
- kOpcode22 = 22,
kOpcode23 = 23,
kOpcodeSetClearFlag = 24,
kOpcodeSetCounterFromFlag = 25
};
struct ScriptEntry {
- union {
- byte opcode;
- byte param1;
- uint16 param2;
- uint32 data;
- };
-
- ScriptEntry(uint32 val) {
- data = val;
+ byte opcode;
+ byte param1;
+ uint16 param2;
+
+ ScriptEntry(byte *data) {
+ opcode = *data;
+ param1 = *(data + 1);
+ param2 = READ_LE_UINT16(data + 2);
}
Common::String toString();
diff --git a/engines/asylum/shared.h b/engines/asylum/shared.h
index f6d1cd7ca7..c506e34129 100644
--- a/engines/asylum/shared.h
+++ b/engines/asylum/shared.h
@@ -712,6 +712,7 @@ enum PuzzleId {
//////////////////////////////////////////////////////////////////////////
#define LOBYTE(d) (*((char*)&(d)))
#define BYTE1(d) (*((char*)&(d)+1)) // Same as HIBYTE()
+#define BYTE2(d) (*((char*)&(d)+2))
#define LOWORD(x) (*((int16*)&(x)))
//////////////////////////////////////////////////////////////////////////
Commit: f4a96e448d1523b340ee8d1ee5fb5928f2b30121
https://github.com/scummvm/scummvm/commit/f4a96e448d1523b340ee8d1ee5fb5928f2b30121
Author: Littleboy (littleboy at scummvm.org)
Date: 2021-05-17T15:37:23+02:00
Commit Message:
ASYLUM: Rename the rest of Encounter opcodes
Changed paths:
engines/asylum/resources/encounters.cpp
engines/asylum/resources/encounters.h
diff --git a/engines/asylum/resources/encounters.cpp b/engines/asylum/resources/encounters.cpp
index 7832fe47cd..0002c33b90 100644
--- a/engines/asylum/resources/encounters.cpp
+++ b/engines/asylum/resources/encounters.cpp
@@ -48,30 +48,30 @@ namespace Asylum {
const char *opcodeNames[] = {
"Return",
"SetScriptVariable",
- "2"
- "3",
- "4",
- "5",
- "6",
- "7",
- "8",
- "9",
- "10",
- "11",
- "12",
- "13",
+ "SetCounterFromVars"
+ "SetOffset",
+ "SetOffsetIfCounterNegative",
+ "SetOffsetIfCounterNegativeOrNull",
+ "SetOffsetIfCounterIsNull",
+ "SetOffsetIfCounterIsNotNull",
+ "SetOffsetIfCounterPositiveOrNull",
+ "SetOffsetIfCounterPositive",
+ "SetCurrentItemOptions",
+ "ClearCurrentItemOptions",
+ "SetItemOptions",
+ "CloseDialog",
"ResetSpeech",
"SetVariable",
"IncrementScriptVariable",
- "17",
+ "ProcessVariable3",
"AddRemoveReactionHive",
- "UNUSED(19)",
- "UNUSED(20)",
+ "UNUSED (19)",
+ "UNUSED (20)",
"SetCounterFromActorReactions",
- "UNUSED(22)",
- "23",
- "SetClearFlag",
- "SetCounterFromFlag"
+ "UNUSED (22)",
+ "PrepareMovie",
+ "SetClearGameFlag",
+ "SetCounterFromGameFlag"
};
Common::String Encounter::ScriptEntry::toString() {
@@ -1486,78 +1486,78 @@ void Encounter::runScript() {
_scriptData.vars[entry.param1] = getVariableInv(entry.param2);
break;
- case kOpcode2:
+ case kOpcodeSetCounterFromVars:
_scriptData.counter = _scriptData.vars[entry.param1] - getVariableInv(entry.param2);
break;
- case kOpcode3:
+ case kOpcodeSetOffset:
_scriptData.offset = entry.param2 - 1;
break;
- case kOpcode4:
+ case kOpcodeSetOffsetIfCounterNegative:
if (_scriptData.counter >= 0)
break;
_scriptData.offset = entry.param2;
break;
- case kOpcode5:
+ case kOpcodeSetOffsetIfCounterNegativeOrNull:
if (_scriptData.counter > 0)
break;
_scriptData.offset = entry.param2;
break;
- case kOpcode6:
+ case kOpcodeSetOffsetIfCounterIsNull:
if (_scriptData.counter)
break;
_scriptData.offset = entry.param2 - 1;
break;
- case kOpcode7:
+ case kOpcodeSetOffsetIfCounterIsNotNull:
if (!_scriptData.counter)
break;
_scriptData.offset = entry.param2;
break;
- case kOpcode8:
+ case kOpcodeSetOffsetIfCounterPositiveOrNull:
if (_scriptData.counter < 0)
break;
_scriptData.offset = entry.param2;
break;
- case kOpcode9:
+ case kOpcodeSetOffsetIfCounterPositive:
if (_scriptData.counter <= 0)
break;
_scriptData.offset = entry.param2 - 1;
break;
- case kOpcode10:
+ case kOpcodeSetCurrentItemOptions:
if (entry.param1)
_item->keywords[findKeyword(_item, entry.param2)] &= ~(kKeywordOptionsDisabled << 8);
else
_item->keywords[findKeyword(_item, entry.param2)] |= (kKeywordOptionsVisible << 8);
break;
- case kOpcode11:
+ case kOpcodeClearCurrentItemOptions:
if (entry.param1)
_item->keywords[findKeyword(_item, entry.param2)] |= (kKeywordOptionsDisabled << 8);
else
_item->keywords[findKeyword(_item, entry.param2)] &= ~(kKeywordOptionsVisible << 8);
break;
- case kOpcode12:
+ case kOpcodeSetItemOptions:
_items[entry.param1].keywords[findKeyword(&_items[entry.param1], entry.param2)] |= (kKeywordOptionsUnknown << 8);
_items[entry.param1].keywords[findKeyword(&_items[entry.param1], entry.param2)] |= (kKeywordOptionsVisible << 8);
// Original saves the item back here
break;
- case kOpcode13:
+ case kOpcodeCloseDialog:
if (!_flag3)
_shouldCloseDialog = true;
@@ -1578,7 +1578,7 @@ void Encounter::runScript() {
_scriptData.vars[entry.param1] += entry.param2;
break;
- case kOpcode17:
+ case kOpcodeProcessVariable3:
switch (getVariable(3)) {
default:
break;
@@ -1640,7 +1640,7 @@ void Encounter::runScript() {
_scriptData.counter = getScene()->getActor()->hasMoreReactions(getVariableInv(entry.param2), _scriptData.vars[1]) ? 0 : 1;
break;
- case kOpcode23:
+ case kOpcodePrepareMovie:
if (!getSharedData()->getMatteBarHeight()) {
getScreen()->loadPalette();
getSharedData()->setMatteBarHeight(1);
@@ -1658,14 +1658,14 @@ void Encounter::runScript() {
}
break;
- case kOpcodeSetClearFlag:
+ case kOpcodeSetClearGameFlag:
if (entry.param1)
_vm->setGameFlag((GameFlag)getVariableInv(entry.param2));
else
_vm->clearGameFlag((GameFlag)getVariableInv(entry.param2));
break;
- case kOpcodeSetCounterFromFlag:
+ case kOpcodeSetCounterFromGameFlag:
_scriptData.counter = _vm->isGameFlagSet((GameFlag)getVariableInv(entry.param2)) ? 1 : 0;
break;
}
diff --git a/engines/asylum/resources/encounters.h b/engines/asylum/resources/encounters.h
index d773a4a5e0..aedfec9b23 100644
--- a/engines/asylum/resources/encounters.h
+++ b/engines/asylum/resources/encounters.h
@@ -267,29 +267,29 @@ private:
//////////////////////////////////////////////////////////////////////////
// Scripts
enum EncounterOpcode {
- kOpcodeReturn = 0,
- kOpcodeSetScriptVariable = 1,
- kOpcode2 = 2,
- kOpcode3 = 3,
- kOpcode4 = 4,
- kOpcode5 = 5,
- kOpcode6 = 6,
- kOpcode7 = 7,
- kOpcode8 = 8,
- kOpcode9 = 9,
- kOpcode10 = 10,
- kOpcode11 = 11,
- kOpcode12 = 12,
- kOpcode13 = 13,
- kOpcodeResetSpeech = 14,
- kOpcodeSetVariable = 15,
- kOpcodeIncrementScriptVariable = 16,
- kOpcode17 = 17,
- kOpcodeAddRemoveReactionHive = 18,
- kOpcodeSetCounterFromActorReactions = 21,
- kOpcode23 = 23,
- kOpcodeSetClearFlag = 24,
- kOpcodeSetCounterFromFlag = 25
+ kOpcodeReturn = 0,
+ kOpcodeSetScriptVariable = 1,
+ kOpcodeSetCounterFromVars = 2,
+ kOpcodeSetOffset = 3,
+ kOpcodeSetOffsetIfCounterNegative = 4,
+ kOpcodeSetOffsetIfCounterNegativeOrNull = 5,
+ kOpcodeSetOffsetIfCounterIsNull = 6,
+ kOpcodeSetOffsetIfCounterIsNotNull = 7,
+ kOpcodeSetOffsetIfCounterPositiveOrNull = 8,
+ kOpcodeSetOffsetIfCounterPositive = 9,
+ kOpcodeSetCurrentItemOptions = 10,
+ kOpcodeClearCurrentItemOptions = 11,
+ kOpcodeSetItemOptions = 12,
+ kOpcodeCloseDialog = 13,
+ kOpcodeResetSpeech = 14,
+ kOpcodeSetVariable = 15,
+ kOpcodeIncrementScriptVariable = 16,
+ kOpcodeProcessVariable3 = 17,
+ kOpcodeAddRemoveReactionHive = 18,
+ kOpcodeSetCounterFromActorReactions = 21,
+ kOpcodePrepareMovie = 23,
+ kOpcodeSetClearGameFlag = 24,
+ kOpcodeSetCounterFromGameFlag = 25
};
struct ScriptEntry {
Commit: 272d5ffa1ff1e95a52b88da4698be9db6fbceeec
https://github.com/scummvm/scummvm/commit/272d5ffa1ff1e95a52b88da4698be9db6fbceeec
Author: Littleboy (littleboy at scummvm.org)
Date: 2021-05-17T15:37:23+02:00
Commit Message:
ASYLUM: Flag detections entries with ADGF_UNSTABLE
Changed paths:
engines/asylum/detection.cpp
diff --git a/engines/asylum/detection.cpp b/engines/asylum/detection.cpp
index 7e26762658..06038b2095 100644
--- a/engines/asylum/detection.cpp
+++ b/engines/asylum/detection.cpp
@@ -46,7 +46,7 @@ static const ADGameDescription gameDescriptions[] = {
},
Common::EN_ANY,
Common::kPlatformPC,
- ADGF_DEMO,
+ ADGF_DEMO|ADGF_UNSTABLE,
Common::GUIO_NONE
},
{
@@ -60,7 +60,7 @@ static const ADGameDescription gameDescriptions[] = {
},
Common::EN_ANY,
Common::kPlatformPC,
- ADGF_NO_FLAGS,
+ ADGF_UNSTABLE,
Common::GUIO_NONE
},
{
@@ -74,7 +74,7 @@ static const ADGameDescription gameDescriptions[] = {
},
Common::EN_ANY,
Common::kPlatformPC,
- ADGF_NO_FLAGS,
+ ADGF_UNSTABLE,
Common::GUIO_NONE
},
{
@@ -88,7 +88,7 @@ static const ADGameDescription gameDescriptions[] = {
},
Common::EN_ANY,
Common::kPlatformPC,
- ADGF_NO_FLAGS,
+ ADGF_UNSTABLE,
Common::GUIO_NONE
},
{
@@ -102,7 +102,7 @@ static const ADGameDescription gameDescriptions[] = {
},
Common::FR_FRA,
Common::kPlatformPC,
- ADGF_NO_FLAGS,
+ ADGF_UNSTABLE,
Common::GUIO_NONE
},
{
@@ -116,7 +116,7 @@ static const ADGameDescription gameDescriptions[] = {
},
Common::RU_RUS,
Common::kPlatformPC,
- ADGF_NO_FLAGS,
+ ADGF_UNSTABLE,
Common::GUIO_NONE
},
AD_TABLE_END_MARKER
Commit: cc81d47548e43dece0d8048274fc26de9fe8a2b7
https://github.com/scummvm/scummvm/commit/cc81d47548e43dece0d8048274fc26de9fe8a2b7
Author: Littleboy (littleboy at scummvm.org)
Date: 2021-05-17T15:37:23+02:00
Commit Message:
ASYLUM: More encounter cleanup
- Add more comments
- Reformat code for lisibility
- Rename some flags/members
- Fix typos in Encounter::getKeywordIndex()
Changed paths:
engines/asylum/resources/encounters.cpp
engines/asylum/resources/encounters.h
diff --git a/engines/asylum/resources/encounters.cpp b/engines/asylum/resources/encounters.cpp
index 0002c33b90..ded69dd1bf 100644
--- a/engines/asylum/resources/encounters.cpp
+++ b/engines/asylum/resources/encounters.cpp
@@ -80,7 +80,7 @@ Common::String Encounter::ScriptEntry::toString() {
Encounter::Encounter(AsylumEngine *engine) : _vm(engine),
_index(0), _speechResourceId(0), _item(NULL), _objectId1(kObjectNone), _objectId2(kObjectNone), _objectId3(kObjectNone),
- _actorIndex(kActorInvalid), _shouldEnablePlayer(false), _wasPlayerDisabled(false), _flag3(false), _isScriptRunning(false) {
+ _actorIndex(kActorInvalid), _shouldEnablePlayer(false), _wasPlayerDisabled(false), _isClosing(false), _isScriptRunning(false) {
memset(&_keywordIndexes, 0, sizeof(_keywordIndexes));
_rectIndex = -1;
@@ -142,7 +142,7 @@ void Encounter::load() {
for (uint j = 0; j < ARRAYSIZE(item.keywords); j++)
item.keywords[j] = file.readSint16LE();
- item.value = file.readByte();
+ item.variable2 = file.readByte();
_items.push_back(item);
}
@@ -260,7 +260,9 @@ void Encounter::run(int32 encounterIndex, ObjectId objectId1, ObjectId objectId2
if (encounterIndex < 0)
return;
- // Original engine saves the main event handler (to be restored later)
+ // Original engine saves the event handler passed as first parameter (to be restored later)
+ // Since it always passes the current scene instance, we restore it at the end and skip
+ // saving it here
_index = encounterIndex;
_item = &_items[_index];
_objectId1 = objectId1;
@@ -273,8 +275,9 @@ void Encounter::run(int32 encounterIndex, ObjectId objectId1, ObjectId objectId2
getScene()->getActor(actorIndex)->stopSound();
setVariable(1, 0);
- setVariable(2, _item->value);
+ setVariable(2, _item->variable2);
+ // Disable the player and store the previous state as a flag
Actor *player = getScene()->getActor();
if (player->getStatus() == kActorStatusDisabled) {
_wasPlayerDisabled = true;
@@ -292,13 +295,13 @@ void Encounter::run(int32 encounterIndex, ObjectId objectId1, ObjectId objectId2
void Encounter::exitEncounter() {
setVariable(1, 32767);
initScript(_item->scriptResourceId);
- _flag3 = true;
+ _isClosing = true;
runScript();
setupEntities(true);
- ++_item->value;
- // Original saves the item back here
+ ++_item->variable2;
+ // Original saves the modified item back here (we are using a reference to it all along)
// Update flags
getSharedData()->setFlag(kFlagIsEncounterRunning, false);
@@ -318,6 +321,7 @@ void Encounter::exitEncounter() {
if (getSound()->getMusicVolume() != Config.musicVolume)
getSound()->setMusicVolume(Config.musicVolume);
+ // Restore scene event handler
_vm->switchEventHandler(getScene());
}
@@ -349,6 +353,7 @@ bool Encounter::handleEvent(const AsylumEvent &evt) {
}
bool Encounter::init() {
+ // Lower music volume while we are in the encounter
if (getSound()->getMusicVolume() != Config.musicVolume - 500)
getSound()->setMusicVolume(Config.musicVolume - 500);
@@ -388,6 +393,7 @@ bool Encounter::init() {
}
bool Encounter::update() {
+ // Check that the music volume is lowered
if (getSound()->getMusicVolume() != Config.musicVolume - 500)
getSound()->setMusicVolume(Config.musicVolume - 500);
@@ -450,16 +456,15 @@ bool Encounter::update() {
}
bool doScript = false;
- if ((getSpeech()->getSoundResourceId()
- && !getSound()->isPlaying(getSpeech()->getSoundResourceId())
- && !_data_455BE0)
+ if ((getSpeech()->getSoundResourceId() && !getSound()->isPlaying(getSpeech()->getSoundResourceId()) && !_data_455BE0)
|| (getSpeech()->getTick() && tick >= getSpeech()->getTick()))
doScript = true;
- if (!getSharedData()->getMatteBarHeight() && doScript && _isScriptRunning) {
- if (!setupSpeech(id))
- runScript();
- }
+ if (doScript
+ && !getSharedData()->getMatteBarHeight()
+ && _isScriptRunning
+ && !setupSpeech(id))
+ runScript();
}
// Redraw screen
@@ -471,7 +476,7 @@ bool Encounter::update() {
}
if (tick >= getSharedData()->getNextScreenUpdate() && getSharedData()->getFlag(kFlagRedraw)) {
- if (getSharedData()->getMatteBarHeight() == 0) {
+ if (getSharedData()->getMatteBarHeight() <= 0) {
getScreen()->copyBackBufferToScreen();
} else {
drawScreen();
@@ -593,12 +598,12 @@ int32 Encounter::getKeywordIndex() {
break;
if ((_item->keywords[index] & KEYWORD_MASK) > 0 && isKeywordVisible(_item->keywords[index])) {
- int32 x = _drawingStructs[0].point1.x + 144 * (counter % 3) + _point.x + (counter % 3) + _portrait1.rect.width() + 15;
+ int32 x = _drawingStructs[0].point1.y + 145 * (counter % 3) + _point.x + _portrait1.rect.width() + 15;
int32 y = 16 * counter / 3 + _point.y + 5;
- if (mousePos.x >= x && mousePos.x <= (x + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 3681 + index)))
+ if (mousePos.x >= x && mousePos.x <= (x + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 3681 + (_item->keywords[index] & KEYWORD_MASK))))
&& mousePos.y >= y && mousePos.y <= (y + 16))
- return i;
+ return index;
++counter;
}
@@ -1095,9 +1100,6 @@ void Encounter::drawStructs() {
void Encounter::drawDialogOptions() {
getText()->loadFont(getWorld()->font1);
- if (_keywordStartIndex >= 50)
- return;
-
int16 counter = 0;
for (uint32 i = _keywordStartIndex; i < ARRAYSIZE(_keywordIndexes); i++) {
@@ -1455,7 +1457,7 @@ void Encounter::updatePalette2() {
//////////////////////////////////////////////////////////////////////////
void Encounter::initScript(ResourceId resourceId) {
_scriptData.reset(resourceId);
- _flag3 = false;
+ _isClosing = false;
}
Encounter::ScriptEntry Encounter::getScriptEntry(ResourceId resourceId, uint32 offset) {
@@ -1558,7 +1560,7 @@ void Encounter::runScript() {
break;
case kOpcodeCloseDialog:
- if (!_flag3)
+ if (!_isClosing)
_shouldCloseDialog = true;
done = true;
diff --git a/engines/asylum/resources/encounters.h b/engines/asylum/resources/encounters.h
index aedfec9b23..0bd960d711 100644
--- a/engines/asylum/resources/encounters.h
+++ b/engines/asylum/resources/encounters.h
@@ -37,13 +37,13 @@ struct EncounterItem : public Common::Serializable {
uint32 speechResourceId;
ResourceId scriptResourceId;
int16 keywords[50];
- byte value;
+ byte variable2;
EncounterItem() {
speechResourceId = 0;
scriptResourceId = kResourceNone;
memset(&keywords, 0, sizeof(keywords));
- value = 0;
+ variable2 = 0;
}
virtual ~EncounterItem() {}
@@ -56,7 +56,7 @@ struct EncounterItem : public Common::Serializable {
for (int32 i = 0; i < ARRAYSIZE(keywords); i++)
s.syncAsSint16LE(keywords[i]);
- s.syncAsByte(value);
+ s.syncAsByte(variable2);
}
};
@@ -198,7 +198,7 @@ private:
// Internal flags
bool _shouldEnablePlayer;
bool _wasPlayerDisabled;
- bool _flag3;
+ bool _isClosing;
bool _isScriptRunning;
//////////////////////////////////////////////////////////////////////////
Commit: b82752e649290fb7013508092155bf66ae825ca6
https://github.com/scummvm/scummvm/commit/b82752e649290fb7013508092155bf66ae825ca6
Author: Alexander (alex220486 at gmail.com)
Date: 2021-05-17T15:37:23+02:00
Commit Message:
ASYLUM: Pipes puzzle: fix initialization
Changed paths:
engines/asylum/puzzles/pipes.cpp
diff --git a/engines/asylum/puzzles/pipes.cpp b/engines/asylum/puzzles/pipes.cpp
index 124a572566..76a6ba40e2 100644
--- a/engines/asylum/puzzles/pipes.cpp
+++ b/engines/asylum/puzzles/pipes.cpp
@@ -318,7 +318,8 @@ PuzzlePipes::PuzzlePipes(AsylumEngine *engine) : Puzzle(engine) {
PuzzlePipes::~PuzzlePipes() {
for (uint32 i = 0; i < _spiders.size(); ++i)
delete _spiders[i];
- delete [] _frameIndexSpider;
+ if (_frameIndexSpider)
+ delete[] _frameIndexSpider;
}
void PuzzlePipes::saveLoadWithSerializer(Common::Serializer &s) {
@@ -348,9 +349,6 @@ bool PuzzlePipes::init(const AsylumEvent &) {
}
bool PuzzlePipes::update(const AsylumEvent &) {
- if (!_frameIndexSpider)
- error("[PuzzlePipes::update] Puzzle not initialized properly");
-
getScreen()->clear();
getScreen()->clearGraphicsInQueue();
getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[1], 0, Common::Point(0, 0), kDrawFlagNone, 0, 4);
@@ -449,9 +447,6 @@ bool PuzzlePipes::update(const AsylumEvent &) {
}
bool PuzzlePipes::mouseLeftDown(const AsylumEvent &) {
- if (!_frameIndexSpider)
- error("[PuzzlePipes::update] Puzzle not initialized properly");
-
Common::Point mousePos = getCursor()->position();
if (Common::Rect(540, 90, 590, 250).contains(mousePos)) {
@@ -549,16 +544,18 @@ void PuzzlePipes::setup() {
_connectors[10].initGroup();
_connectors[11].initGroup();
- uint32 i = rnd(7);
+ uint32 i = rnd(kBinNum0111);
if (i & kBinNum0001)
- _spiders.push_back(new Spider(Common::Rect(-10, 45, 92, 315), "1"));
+ _spiders.push_back(new Spider(Common::Rect(-10, 45, 92, 315), "1"));
if (i & kBinNum0010)
_spiders.push_back(new Spider(Common::Rect(-10, 389, 149, 476), "2"));
if (i & kBinNum0100)
_spiders.push_back(new Spider(Common::Rect(544, 225, 650, 490), "3"));
- _frameIndexSpider = new uint32[_spiders.size()];
- memset(_frameIndexSpider, 0, sizeof(_frameIndexSpider));
+ if (i) {
+ _frameIndexSpider = new uint32[_spiders.size()];
+ memset(_frameIndexSpider, 0, sizeof(_frameIndexSpider));
+ }
startUpWater();
}
Commit: be21e4e02871fc6c305d32dafe68af9717d9773f
https://github.com/scummvm/scummvm/commit/be21e4e02871fc6c305d32dafe68af9717d9773f
Author: Alexander (alex220486 at gmail.com)
Date: 2021-05-17T15:37:23+02:00
Commit Message:
ASYLUM: Writings puzzle: fix an infinite loop in drawBackground()
Changed paths:
engines/asylum/puzzles/writings.cpp
diff --git a/engines/asylum/puzzles/writings.cpp b/engines/asylum/puzzles/writings.cpp
index f60c9ff557..9d592c2a89 100644
--- a/engines/asylum/puzzles/writings.cpp
+++ b/engines/asylum/puzzles/writings.cpp
@@ -95,7 +95,6 @@ bool PuzzleWritings::update(const AsylumEvent &) {
getScreen()->draw(getWorld()->graphicResourceIds[4]);
if (_hasGlassMagnifier) {
- // This currently goes into an almost infinite loop and then segfaults due to a bug in Text::draw()
drawBackground();
// The original blits part of the background onto the surface (9) and then adds it to the queue
@@ -130,18 +129,18 @@ void PuzzleWritings::drawBackground() {
// Draw all lines of text
getText()->loadFont(getWorld()->graphicResourceIds[42]);
- getText()->draw(0, 99, kTextNormal, Common::Point( 70, 45), 16, 24, getText()->get(MAKE_RESOURCE(kResourcePackText, 1825)));
- getText()->draw(0, 99, kTextNormal, Common::Point(130, 75), 16, 24, getText()->get(MAKE_RESOURCE(kResourcePackText, 1826)));
- getText()->draw(0, 99, kTextNormal, Common::Point( 70, 105), 16, 24, getText()->get(MAKE_RESOURCE(kResourcePackText, 1827)));
- getText()->draw(0, 99, kTextNormal, Common::Point(130, 135), 16, 24, getText()->get(MAKE_RESOURCE(kResourcePackText, 1828)));
- getText()->draw(0, 99, kTextNormal, Common::Point( 70, 165), 16, 24, getText()->get(MAKE_RESOURCE(kResourcePackText, 1829)));
- getText()->draw(0, 99, kTextNormal, Common::Point(130, 195), 16, 24, getText()->get(MAKE_RESOURCE(kResourcePackText, 1830)));
- getText()->draw(0, 99, kTextNormal, Common::Point( 70, 225), 16, 24, getText()->get(MAKE_RESOURCE(kResourcePackText, 1831)));
- getText()->draw(0, 99, kTextNormal, Common::Point(130, 255), 16, 24, getText()->get(MAKE_RESOURCE(kResourcePackText, 1832)));
- getText()->draw(0, 99, kTextNormal, Common::Point( 70, 285), 16, 24, getText()->get(MAKE_RESOURCE(kResourcePackText, 1833)));
- getText()->draw(0, 99, kTextNormal, Common::Point(130, 315), 16, 24, getText()->get(MAKE_RESOURCE(kResourcePackText, 1834)));
- getText()->draw(0, 99, kTextCenter, Common::Point(320, 375), 16, 24, getText()->get(MAKE_RESOURCE(kResourcePackText, 1835)));
- getText()->draw(0, 99, kTextCenter, Common::Point(320, 405), 16, 24, getText()->get(MAKE_RESOURCE(kResourcePackText, 1836)));
+ getText()->draw(0, 99, kTextNormal, Common::Point( 70, 45), 16, 590, getText()->get(MAKE_RESOURCE(kResourcePackText, 1825)));
+ getText()->draw(0, 99, kTextNormal, Common::Point(130, 75), 16, 590, getText()->get(MAKE_RESOURCE(kResourcePackText, 1826)));
+ getText()->draw(0, 99, kTextNormal, Common::Point( 70, 105), 16, 590, getText()->get(MAKE_RESOURCE(kResourcePackText, 1827)));
+ getText()->draw(0, 99, kTextNormal, Common::Point(130, 135), 16, 590, getText()->get(MAKE_RESOURCE(kResourcePackText, 1828)));
+ getText()->draw(0, 99, kTextNormal, Common::Point( 70, 165), 16, 590, getText()->get(MAKE_RESOURCE(kResourcePackText, 1829)));
+ getText()->draw(0, 99, kTextNormal, Common::Point(130, 195), 16, 590, getText()->get(MAKE_RESOURCE(kResourcePackText, 1830)));
+ getText()->draw(0, 99, kTextNormal, Common::Point( 70, 225), 16, 590, getText()->get(MAKE_RESOURCE(kResourcePackText, 1831)));
+ getText()->draw(0, 99, kTextNormal, Common::Point(130, 255), 16, 590, getText()->get(MAKE_RESOURCE(kResourcePackText, 1832)));
+ getText()->draw(0, 99, kTextNormal, Common::Point( 70, 285), 16, 590, getText()->get(MAKE_RESOURCE(kResourcePackText, 1833)));
+ getText()->draw(0, 99, kTextNormal, Common::Point(130, 315), 16, 590, getText()->get(MAKE_RESOURCE(kResourcePackText, 1834)));
+ getText()->draw(0, 99, kTextCenter, Common::Point(320, 375), 16, 590, getText()->get(MAKE_RESOURCE(kResourcePackText, 1835)));
+ getText()->draw(0, 99, kTextCenter, Common::Point(320, 405), 16, 590, getText()->get(MAKE_RESOURCE(kResourcePackText, 1836)));
}
} // End of namespace Asylum
Commit: 1fc9a8a837515869afc9400aaebf5738f7dc1806
https://github.com/scummvm/scummvm/commit/1fc9a8a837515869afc9400aaebf5738f7dc1806
Author: Alexander (alex220486 at gmail.com)
Date: 2021-05-17T15:37:23+02:00
Commit Message:
ASYLUM: HiveControl puzzle: add completion checks
Changed paths:
engines/asylum/puzzles/hivecontrol.cpp
diff --git a/engines/asylum/puzzles/hivecontrol.cpp b/engines/asylum/puzzles/hivecontrol.cpp
index 4d23057792..e76456cc49 100644
--- a/engines/asylum/puzzles/hivecontrol.cpp
+++ b/engines/asylum/puzzles/hivecontrol.cpp
@@ -237,9 +237,17 @@ bool PuzzleHiveControl::mouseLeftDown(const AsylumEvent &) {
getSound()->playSound(getWorld()->graphicResourceIds[83], false, Config.sfxVolume - 10);
++_frameIndexes[kElementSwirlRim];
- error("[PuzzleHiveControl::mouseLeftDown] Not implemented");
- //if (_frameIndexes[kElementSwirlRim] == 12)
- // ...
+ // Check for puzzle completion
+ if (_frameIndexes[kElementSwirlRim] == 12) {
+ getSound()->stop(getWorld()->graphicResourceIds[73]);
+ getSound()->stop(getWorld()->graphicResourceIds[74]);
+
+ getScreen()->clear();
+ getScreen()->setupTransTables(3, getWorld()->cellShadeMask1, getWorld()->cellShadeMask2, getWorld()->cellShadeMask3);
+ getScreen()->selectTransTable(1);
+
+ _vm->switchEventHandler(getScene());
+ }
}
}
break;
@@ -252,8 +260,18 @@ bool PuzzleHiveControl::mouseLeftDown(const AsylumEvent &) {
if (_glyphFlags[1][_leverPosition]) {
getSound()->playSound(getWorld()->graphicResourceIds[83], false, Config.sfxVolume - 10);
++_frameIndexes[kElementSwirlRim];
- //if (_frameIndexes[kElementSwirlRim] == 12)
- // ...
+
+ // Check for puzzle completion
+ if (_frameIndexes[kElementSwirlRim] == 12) {
+ getSound()->stop(getWorld()->graphicResourceIds[73]);
+ getSound()->stop(getWorld()->graphicResourceIds[74]);
+
+ getScreen()->clear();
+ getScreen()->setupTransTables(3, getWorld()->cellShadeMask1, getWorld()->cellShadeMask2, getWorld()->cellShadeMask3);
+ getScreen()->selectTransTable(1);
+
+ _vm->switchEventHandler(getScene());
+ }
}
}
break;
@@ -408,8 +426,7 @@ void PuzzleHiveControl::updateScreen() {
_frameIndexes[kElementWingLeft1 + 2*i] = (_frameIndexes[kElementWingLeft1 + 2*i] + 1) % GraphicResource::getFrameCount(_vm, getWorld()->graphicResourceIds[kElementWingLeft1 + 2*i]);
if (_frameIndexes[kElementWingRight1 + 2*i] != GraphicResource::getFrameCount(_vm, getWorld()->graphicResourceIds[kElementWingRight1 + 2*i]) - 1)
_frameIndexes[kElementWingRight1 + 2*i] = (_frameIndexes[kElementWingRight1 + 2*i] + 1) % GraphicResource::getFrameCount(_vm, getWorld()->graphicResourceIds[kElementWingRight1 + 2*i]);
- }
- else {
+ } else {
if (_frameIndexes[kElementWingLeft1 + 2*i] > 0) {
--_frameIndexes[kElementWingLeft1 + 2*i];
if (_resetFlag && _frameIndexes[kElementWingLeft1 + 2*i] == 0 && !reseted) {
Commit: a67ea83e23169ec700c21c005900873d6fe8b4d0
https://github.com/scummvm/scummvm/commit/a67ea83e23169ec700c21c005900873d6fe8b4d0
Author: Alexander (alex220486 at gmail.com)
Date: 2021-05-17T15:37:23+02:00
Commit Message:
ASYLUM: HiveControl puzzle: fix a bug
_leverPosition - _prevLeverPosition should be signed.
Changed paths:
engines/asylum/puzzles/hivecontrol.cpp
diff --git a/engines/asylum/puzzles/hivecontrol.cpp b/engines/asylum/puzzles/hivecontrol.cpp
index e76456cc49..bc15e01bd9 100644
--- a/engines/asylum/puzzles/hivecontrol.cpp
+++ b/engines/asylum/puzzles/hivecontrol.cpp
@@ -87,7 +87,7 @@ void PuzzleHiveControl::reset() {
_frameIndexes[kElementSwirlRim] = 0;
if (_leverPosition != _prevLeverPosition) {
- _leverDelta = (uint32)abs((double)(_leverPosition - _prevLeverPosition)) * 16 / 5;
+ _leverDelta = (uint32)abs((double)_leverPosition - (double)_prevLeverPosition) * 16 / 5;
_currentControl = kControlGlyph4;
}
}
@@ -283,7 +283,7 @@ bool PuzzleHiveControl::mouseLeftDown(const AsylumEvent &) {
case kControlGlyph5:
case kControlGlyph6:
_leverPosition = _currentControl - 49;
- _leverDelta = (uint32)abs((double)(_leverPosition - _prevLeverPosition)) * (GraphicResource::getFrameCount(_vm, getWorld()->graphicResourceIds[kElementLever]) - 1) / 5;
+ _leverDelta = (uint32)abs((double)_leverPosition - (double)_prevLeverPosition) * (GraphicResource::getFrameCount(_vm, getWorld()->graphicResourceIds[kElementLever]) - 1) / 5;
if (_leverDelta)
getSound()->playSound(getWorld()->graphicResourceIds[76], false, Config.sfxVolume - 10);
}
Commit: d61d51f19095944b35e5dd92be06473e264ba3ab
https://github.com/scummvm/scummvm/commit/d61d51f19095944b35e5dd92be06473e264ba3ab
Author: Alexander (alex220486 at gmail.com)
Date: 2021-05-17T15:37:24+02:00
Commit Message:
ASYLUM: HiveControl puzzle: fix minor glitch in updateScreen()
Changed paths:
engines/asylum/puzzles/hivecontrol.cpp
diff --git a/engines/asylum/puzzles/hivecontrol.cpp b/engines/asylum/puzzles/hivecontrol.cpp
index bc15e01bd9..17b83d6210 100644
--- a/engines/asylum/puzzles/hivecontrol.cpp
+++ b/engines/asylum/puzzles/hivecontrol.cpp
@@ -378,7 +378,7 @@ void PuzzleHiveControl::updateScreen() {
if (_resetFlag) {
getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[kElementResetDynamic], _frameIndexes[kElementResetDynamic], Common::Point(211, 77), kDrawFlagNone, 0, 2);
_frameIndexes[kElementResetDynamic] = (_frameIndexes[kElementResetDynamic] + 1) % GraphicResource::getFrameCount(_vm, getWorld()->graphicResourceIds[kElementResetDynamic]);
- if (_frameIndexes[kElementResetDynamic] == GraphicResource::getFrameCount(_vm, getWorld()->graphicResourceIds[kElementResetDynamic]) - 1) {
+ if (_frameIndexes[kElementResetDynamic] == 0) {
_resetFlag = false;
getCursor()->show();
if (!(_wingsState[0] || _wingsState[1] || _wingsState[2])) {
Commit: f7213d1af5532720f9ac5bb184cafbc4622273c1
https://github.com/scummvm/scummvm/commit/f7213d1af5532720f9ac5bb184cafbc4622273c1
Author: Alex Bevilacqua (alexbevi at gmail.com)
Date: 2021-05-17T15:37:24+02:00
Commit Message:
ASYLUM: silence an analysis warning by adding a virtual destructor to ActorData
Changed paths:
engines/asylum/resources/actor.h
diff --git a/engines/asylum/resources/actor.h b/engines/asylum/resources/actor.h
index 65140ec6bf..85c964b4be 100644
--- a/engines/asylum/resources/actor.h
+++ b/engines/asylum/resources/actor.h
@@ -51,6 +51,8 @@ struct ActorData : public Common::Serializable {
memset(&directions, 0, sizeof(directions));
}
+ virtual ~ActorData() {}
+
void load(Common::SeekableReadStream *stream) {
count = stream->readUint32LE();
Commit: 2c1b1d3cf4d176197af1a0ed1fe2438219bb2b4d
https://github.com/scummvm/scummvm/commit/2c1b1d3cf4d176197af1a0ed1fe2438219bb2b4d
Author: Alexander (alex220486 at gmail.com)
Date: 2021-05-17T15:37:24+02:00
Commit Message:
ASYLUM: PuzzleBoard: fix checkSlots()
Changed paths:
engines/asylum/puzzles/board.cpp
diff --git a/engines/asylum/puzzles/board.cpp b/engines/asylum/puzzles/board.cpp
index fae8416a89..ee753d3c4c 100644
--- a/engines/asylum/puzzles/board.cpp
+++ b/engines/asylum/puzzles/board.cpp
@@ -267,10 +267,12 @@ void PuzzleBoard::checkSlots() {
if (_data.checkForSpace && _solvedText[index] == ' ')
return;
- if (_selectedSlot == -1)
+ if (_selectedSlot == -1) {
_selectedSlot = index;
- else
+ } else {
SWAP(_solvedText[index], _solvedText[_selectedSlot]);
+ _selectedSlot = -1;
+ }
updateScreen();
}
Commit: 68b9df5a4b177fb64a70f58c3e780ec084875155
https://github.com/scummvm/scummvm/commit/68b9df5a4b177fb64a70f58c3e780ec084875155
Author: Alex Bevilacqua (alexbevi at gmail.com)
Date: 2021-05-17T15:37:24+02:00
Commit Message:
ASYLUM: identify a couple ActorStatus values
Changed paths:
engines/asylum/resources/actor.cpp
engines/asylum/resources/script.cpp
engines/asylum/resources/special.cpp
engines/asylum/shared.h
engines/asylum/views/scene.cpp
diff --git a/engines/asylum/resources/actor.cpp b/engines/asylum/resources/actor.cpp
index 0c5142d3d6..fce272db41 100644
--- a/engines/asylum/resources/actor.cpp
+++ b/engines/asylum/resources/actor.cpp
@@ -544,7 +544,7 @@ void Actor::update() {
}
// Fallback to next case
- case kActorStatus1: {
+ case kActorStatusWalking: {
uint32 index = (_frameIndex >= _frameCount) ? 2 * _frameCount - (_frameIndex + 1) : _frameIndex;
uint32 dist = (uint32)abs((double)getDistanceForFrame(_direction, index));
@@ -577,7 +577,7 @@ void Actor::update() {
}
break;
- case kActorStatus2:
+ case kActorStatusWalkingTo:
case kActorStatus13: {
uint32 index = (_frameIndex >= _frameCount) ? 2 * _frameCount - (_frameIndex + 1) : _frameIndex;
@@ -701,7 +701,7 @@ void Actor::updateStatus(ActorStatus actorStatus) {
default:
break;
- case kActorStatus1:
+ case kActorStatusWalking:
case kActorStatus12:
if ((getWorld()->chapter == kChapter2
&& _index == getSharedData()->getPlayerIndex() && (_status == kActorStatus18 || _status == kActorStatus16 || _status == kActorStatus17))
@@ -717,7 +717,7 @@ void Actor::updateStatus(ActorStatus actorStatus) {
}
break;
- case kActorStatus2:
+ case kActorStatusWalkingTo:
case kActorStatus13:
updateGraphicData(0);
break;
@@ -1048,8 +1048,8 @@ void Actor::updateFromDirection(ActorDirection actorDirection) {
_resourceId = _graphicResourceIds[(actorDirection > kDirectionS) ? kDirection8 - actorDirection : actorDirection];
break;
- case kActorStatus1:
- case kActorStatus2:
+ case kActorStatusWalking:
+ case kActorStatusWalkingTo:
case kActorStatus12:
_resourceId = _graphicResourceIds[(actorDirection > kDirectionS ? kDirection8 - actorDirection : actorDirection)];
break;
@@ -1469,7 +1469,7 @@ bool Actor::process(const Common::Point &point) {
void Actor::processStatus(int16 actorX, int16 actorY, bool doSpeech) {
if (process(Common::Point(actorX, actorY))) {
if (_status <= kActorStatus11)
- updateStatus(kActorStatus2);
+ updateStatus(kActorStatusWalkingTo);
else
updateStatus(kActorStatus13);
} else if (doSpeech) {
@@ -1743,8 +1743,8 @@ void Actor::move(ActorDirection actorDir, uint32 dist) {
default:
break;
- case kActorStatus1:
- case kActorStatus2:
+ case kActorStatusWalking:
+ case kActorStatusWalkingTo:
case kActorStatus12:
case kActorStatus13:
updateCoordinatesForDirection(actorDir, (int16)dist, &_point1);
diff --git a/engines/asylum/resources/script.cpp b/engines/asylum/resources/script.cpp
index 1fbbadf44a..61cabf97b1 100644
--- a/engines/asylum/resources/script.cpp
+++ b/engines/asylum/resources/script.cpp
@@ -700,7 +700,7 @@ END_OPCODE
IMPLEMENT_OPCODE(JumpAndSetDirection)
Actor *actor = getScene()->getActor(cmd->param1);
- if (actor->getStatus() != kActorStatus2 && actor->getStatus() != kActorStatus13) {
+ if (actor->getStatus() != kActorStatusWalkingTo && actor->getStatus() != kActorStatus13) {
if (cmd->param5 != 2) {
if (cmd->param2 == -1 || cmd->param3 == -1) {
@@ -1703,7 +1703,7 @@ END_OPCODE
IMPLEMENT_OPCODE(Interact)
Actor *actor = getScene()->getActor(cmd->param2 == 2 ? kActorInvalid : cmd->param1);
- if (actor->getStatus() == kActorStatus2 || actor->getStatus() == kActorStatus13) {
+ if (actor->getStatus() == kActorStatusWalkingTo || actor->getStatus() == kActorStatus13) {
if (cmd->param2 == 2)
_processNextEntry = true;
diff --git a/engines/asylum/resources/special.cpp b/engines/asylum/resources/special.cpp
index 0ba655e97d..b0108cbe7b 100644
--- a/engines/asylum/resources/special.cpp
+++ b/engines/asylum/resources/special.cpp
@@ -222,7 +222,7 @@ void Special::chapter2(Object *object, ActorIndex actorIndex) {
case 15:
case 17:
case 18:
- if (actor->getStatus() == kActorStatus1) {
+ if (actor->getStatus() == kActorStatusWalking) {
int32 counter = getSharedData()->getChapter2Counter(getCounter(actorIndex));
counter++;
@@ -234,7 +234,7 @@ void Special::chapter2(Object *object, ActorIndex actorIndex) {
getSharedData()->setChapter2Counter(4, counter);
} else if (actor->getStatus() == kActorStatusEnabled) {
- actor->updateStatus(kActorStatus1);
+ actor->updateStatus(kActorStatusWalking);
}
break;
diff --git a/engines/asylum/shared.h b/engines/asylum/shared.h
index c506e34129..96f94fcae4 100644
--- a/engines/asylum/shared.h
+++ b/engines/asylum/shared.h
@@ -389,10 +389,10 @@ enum ActorIndexes {
enum ActorStatus {
kActorStatusNone = 0,
- kActorStatus1 = 1,
- kActorStatus2,
+ kActorStatusWalking = 1, // Walking
+ kActorStatusWalkingTo, // Auto-walking to target
kActorStatus3,
- kActorStatusEnabled,
+ kActorStatusEnabled, // Standing Still
kActorStatusDisabled, // 5
kActorStatus6,
kActorStatus7,
diff --git a/engines/asylum/views/scene.cpp b/engines/asylum/views/scene.cpp
index 575591c14c..461fb89259 100644
--- a/engines/asylum/views/scene.cpp
+++ b/engines/asylum/views/scene.cpp
@@ -332,7 +332,7 @@ bool Scene::handleEvent(const AsylumEvent &evt) {
void Scene::activate() {
Actor *player = getActor();
- if (player->getStatus() == kActorStatus1)
+ if (player->getStatus() == kActorStatusWalking)
player->updateStatus(kActorStatusEnabled);
if (player->getStatus() == kActorStatus12)
@@ -538,7 +538,7 @@ bool Scene::clickDown(const AsylumEvent &evt) {
player->updateStatus(kActorStatusEnabled);
getSound()->playSound(MAKE_RESOURCE(kResourcePackSound, 5));
} else if (player->getStatus() != kActorStatusDisabled) {
- player->updateStatus(kActorStatus1);
+ player->updateStatus(kActorStatusWalking);
}
break;
@@ -809,7 +809,7 @@ void Scene::updateMouse() {
updateCursor(newDirection, actorRect);
if (newDirection >= kDirectionN)
- if (player->getStatus() == kActorStatus1 || player->getStatus() == kActorStatus12)
+ if (player->getStatus() == kActorStatusWalking || player->getStatus() == kActorStatus12)
player->updateFromDirection(newDirection);
}
@@ -1140,7 +1140,7 @@ void Scene::updateCursor(ActorDirection direction, const Common::Rect &rect) {
}
if (getCursor()->getState() & kCursorStateRight) {
- if (player->getStatus() == kActorStatus1 || player->getStatus() == kActorStatus12) {
+ if (player->getStatus() == kActorStatusWalking || player->getStatus() == kActorStatus12) {
ResourceId resourceId =_ws->cursorResources[direction];
Commit: 9277116e096798380d2a8e8072206ebbce6dc76b
https://github.com/scummvm/scummvm/commit/9277116e096798380d2a8e8072206ebbce6dc76b
Author: Alex Bevilacqua (alexbevi at gmail.com)
Date: 2021-05-17T15:37:24+02:00
Commit Message:
ASYLUM: identify more ActorStatus values
Changed paths:
engines/asylum/resources/actor.cpp
engines/asylum/resources/script.cpp
engines/asylum/resources/special.cpp
engines/asylum/shared.h
diff --git a/engines/asylum/resources/actor.cpp b/engines/asylum/resources/actor.cpp
index fce272db41..38491fce51 100644
--- a/engines/asylum/resources/actor.cpp
+++ b/engines/asylum/resources/actor.cpp
@@ -498,7 +498,7 @@ void Actor::update() {
if (_vm->getRandom(100) < 50) {
if (!getSpeech()->getSoundResourceId() || !getSound()->isPlaying(getSpeech()->getSoundResourceId())) {
if (isDefaultDirection(10))
- updateStatus(kActorStatus9);
+ updateStatus(kActorStatusFidget);
}
}
_lastScreenUpdate = _vm->screenUpdateCount;
@@ -642,7 +642,7 @@ void Actor::update() {
updateStatus3_19();
break;
- case kActorStatus7:
+ case kActorStatusPickupItem:
if (getSharedData()->actorEnableForStatus7) {
getSharedData()->actorEnableForStatus7 = false;
enable();
@@ -662,7 +662,7 @@ void Actor::update() {
updateStatus21();
break;
- case kActorStatus9:
+ case kActorStatusFidget:
updateStatus9();
break;
@@ -705,7 +705,7 @@ void Actor::updateStatus(ActorStatus actorStatus) {
case kActorStatus12:
if ((getWorld()->chapter == kChapter2
&& _index == getSharedData()->getPlayerIndex() && (_status == kActorStatus18 || _status == kActorStatus16 || _status == kActorStatus17))
- || (_status != kActorStatusEnabled && _status != kActorStatus9 && _status != kActorStatus14 && _status != kActorStatus15 && _status != kActorStatus18))
+ || (_status != kActorStatusEnabled && _status != kActorStatusFidget && _status != kActorStatus14 && _status != kActorStatus15 && _status != kActorStatus18))
return;
updateGraphicData(0);
@@ -741,7 +741,7 @@ void Actor::updateStatus(ActorStatus actorStatus) {
getScreen()->setFlag(-1);
break;
- case kActorStatus7:
+ case kActorStatusPickupItem:
if (getWorld()->chapter == kChapter2 && _index == 10 && _vm->isGameFlagSet(kGameFlag279)) {
Actor *actor = getScene()->getActor(0);
actor->getPoint1()->x = _point2.x + _point1.x - actor->getPoint2()->x;
@@ -766,7 +766,7 @@ void Actor::updateStatus(ActorStatus actorStatus) {
updateGraphicData(20);
break;
- case kActorStatus9:
+ case kActorStatusFidget:
if (getSharedData()->getFlag(kFlagIsEncounterRunning))
return;
@@ -1174,7 +1174,7 @@ void Actor::clearFields() {
}
bool Actor::isResourcePresent() const {
- if (_status != kActorStatus9)
+ if (_status != kActorStatusFidget)
return false;
int index;
@@ -2154,7 +2154,7 @@ void Actor::updateStatus3_19() {
++_frameIndex;
} else {
if (_status == kActorStatus3)
- updateStatus(kActorStatus7);
+ updateStatus(kActorStatusPickupItem);
else
updateStatus(kActorStatus20);
}
@@ -2201,7 +2201,7 @@ void Actor::updateStatusEnabled() {
if (_vm->getRandom(100) < 50
&& (!getSpeech()->getSoundResourceId() || !getSound()->isPlaying(getSpeech()->getSoundResourceId()))
&& isDefaultDirection(10))
- updateStatus(kActorStatus9);
+ updateStatus(kActorStatusFidget);
_lastScreenUpdate = _vm->screenUpdateCount;
}
diff --git a/engines/asylum/resources/script.cpp b/engines/asylum/resources/script.cpp
index 61cabf97b1..4e1973b5d6 100644
--- a/engines/asylum/resources/script.cpp
+++ b/engines/asylum/resources/script.cpp
@@ -961,7 +961,7 @@ IMPLEMENT_OPCODE(UpdateActor)
_processNextEntry = true;
return;
- case kActorStatus7:
+ case kActorStatusPickupItem:
actor->enable();
break;
diff --git a/engines/asylum/resources/special.cpp b/engines/asylum/resources/special.cpp
index b0108cbe7b..44d2329dbd 100644
--- a/engines/asylum/resources/special.cpp
+++ b/engines/asylum/resources/special.cpp
@@ -877,14 +877,14 @@ void Special::playSoundChapter3(Object *object, ActorIndex actorIndex) {
break;
case 1:
- if (actor->getStatus() == kActorStatus9
+ if (actor->getStatus() == kActorStatusFidget
&& actor->isResourcePresent()
&& actor->getFrameIndex() == 0)
playSoundPanning(MAKE_RESOURCE(kResourcePackSharedSound, 1861), 22, actorIndex);
break;
case 2:
- if (actor->getStatus() == kActorStatus9
+ if (actor->getStatus() == kActorStatusFidget
&& actor->isResourcePresent()
&& actor->getFrameIndex() == 1)
playSoundPanning(MAKE_RESOURCE(kResourcePackSharedSound, 1892), 16, actorIndex);
diff --git a/engines/asylum/shared.h b/engines/asylum/shared.h
index 96f94fcae4..910c63f1e0 100644
--- a/engines/asylum/shared.h
+++ b/engines/asylum/shared.h
@@ -395,9 +395,9 @@ enum ActorStatus {
kActorStatusEnabled, // Standing Still
kActorStatusDisabled, // 5
kActorStatus6,
- kActorStatus7,
+ kActorStatusPickupItem,
kActorStatus8,
- kActorStatus9,
+ kActorStatusFidget,
kActorStatus10,
kActorStatus11,
kActorStatus12,
Commit: 0553f5dfd8fd62745d26de53586e5ca28c7ad92d
https://github.com/scummvm/scummvm/commit/0553f5dfd8fd62745d26de53586e5ca28c7ad92d
Author: Alex Bevilacqua (alexbevi at gmail.com)
Date: 2021-05-17T15:37:24+02:00
Commit Message:
ASYLUM: added a FIXME to Actor::update() for kActorStatusWalkingTo
Changed paths:
engines/asylum/resources/actor.cpp
diff --git a/engines/asylum/resources/actor.cpp b/engines/asylum/resources/actor.cpp
index 38491fce51..6924aa78d3 100644
--- a/engines/asylum/resources/actor.cpp
+++ b/engines/asylum/resources/actor.cpp
@@ -606,6 +606,11 @@ void Actor::update() {
_frameIndex = (_frameIndex + 1) % _frameCount;
if (canMoveCheckActors(¤t, _direction)) {
+ // FIXME This matches the original, but results in a negative x value,
+ // which causes the actor to warp to the left side of the screen.
+ // Perhaps _point2.x is not being properly set somewhere ...
+ // This can be quickly tested in Scene 1 by trying to pick up
+ // the towel.
_point1.x = (int16)dist - _point2.x;
_point1.y = current.y - _point2.y;
Commit: 0ab8d0c858b5305aa8f4bf4fa60ce49b869b7a36
https://github.com/scummvm/scummvm/commit/0ab8d0c858b5305aa8f4bf4fa60ce49b869b7a36
Author: Alex Bevilacqua (alexbevi at gmail.com)
Date: 2021-05-17T15:37:25+02:00
Commit Message:
ASYLUM: add a some debug output and rename ActorDirection
The ActorDirection rename here is to make the enum value for West
use an English value (W) as opposed to a French value (O).
Changed paths:
engines/asylum/resources/actor.cpp
engines/asylum/resources/object.h
engines/asylum/resources/special.cpp
engines/asylum/shared.h
engines/asylum/views/scene.cpp
diff --git a/engines/asylum/resources/actor.cpp b/engines/asylum/resources/actor.cpp
index 6924aa78d3..fc904bb3ad 100644
--- a/engines/asylum/resources/actor.cpp
+++ b/engines/asylum/resources/actor.cpp
@@ -702,6 +702,8 @@ void Actor::update() {
void Actor::updateStatus(ActorStatus actorStatus) {
+ debugC(kDebugLevelActor, "[updateStatus] %d point1(%d/%d)", actorStatus, this->_point1.x, this->_point1.y);
+
switch (actorStatus) {
default:
break;
@@ -862,58 +864,58 @@ void Actor::updateDirection() {
direction = kDirectionNE;
break;
- case kDirectionNO:
- direction = kDirectionSO;
+ case kDirectionNW:
+ direction = kDirectionSW;
break;
- case kDirectionSO:
- direction = kDirectionNO;
+ case kDirectionSW:
+ direction = kDirectionNW;
break;
}
break;
- case kDirectionO:
+ case kDirectionW:
case kDirectionE:
position.x = _nextPosition.x + sum.x;
- position.x += (int16)((_nextDirection == kDirectionO ? -1 : 1) * 2 * abs(sum.x - _nextPositionOffset.x));
+ position.x += (int16)((_nextDirection == kDirectionW ? -1 : 1) * 2 * abs(sum.x - _nextPositionOffset.x));
position.y = _nextPosition.y + sum.y;
switch (direction) {
default:
break;
- case kDirectionO:
+ case kDirectionW:
direction = kDirectionE;
break;
case kDirectionE:
- direction = kDirectionO;
+ direction = kDirectionW;
break;
- case kDirectionSO:
+ case kDirectionSW:
direction = kDirectionSE;
break;
- case kDirectionNO:
+ case kDirectionNW:
direction = kDirectionNE;
break;
case kDirectionSE:
- direction = kDirectionSO;
+ direction = kDirectionSW;
break;
case kDirectionNE:
- direction = kDirectionNO;
+ direction = kDirectionNW;
break;
}
break;
- case kDirectionNO:
+ case kDirectionNW:
case kDirectionSE:
position.x = _nextPosition.x + sum.x;
position.y = _nextPosition.y + sum.y;
- position.x += (int16)((_nextDirection == kDirectionNO ? -1 : 1) * 2 * abs(sum.y - _nextPositionOffset.y));
- position.y += (int16)((_nextDirection == kDirectionNO ? -1 : 1) * 2 * abs(sum.x - _nextPositionOffset.x));
+ position.x += (int16)((_nextDirection == kDirectionNW ? -1 : 1) * 2 * abs(sum.y - _nextPositionOffset.y));
+ position.y += (int16)((_nextDirection == kDirectionNW ? -1 : 1) * 2 * abs(sum.x - _nextPositionOffset.x));
switch (direction) {
default:
@@ -924,10 +926,10 @@ void Actor::updateDirection() {
break;
case kDirectionS:
- direction = kDirectionO;
+ direction = kDirectionW;
break;
- case kDirectionO:
+ case kDirectionW:
direction = kDirectionS;
break;
@@ -935,7 +937,7 @@ void Actor::updateDirection() {
direction = kDirectionN;
break;
- case kDirectionNO:
+ case kDirectionNW:
direction = kDirectionSE;
break;
@@ -943,19 +945,19 @@ void Actor::updateDirection() {
direction = kDirectionNE;
break;
- case kDirectionSO:
- direction = kDirectionSO;
+ case kDirectionSW:
+ direction = kDirectionSW;
break;
case kDirectionSE:
- direction = kDirectionNO;
+ direction = kDirectionNW;
break;
}
break;
- case kDirectionSO:
+ case kDirectionSW:
case kDirectionNE:
- if (_nextDirection == kDirectionSO) {
+ if (_nextDirection == kDirectionSW) {
position.x = (int16)(_nextPosition.x + sum.x - 2 * abs(sum.y - _nextPositionOffset.y));
position.y = (int16)(_nextPosition.y + sum.y + 2 * abs(sum.x - _nextPositionOffset.x));
} else {
@@ -974,14 +976,14 @@ void Actor::updateDirection() {
break;
case kDirectionN:
- direction = kDirectionO;
+ direction = kDirectionW;
break;
case kDirectionE:
direction = kDirectionS;
break;
- case kDirectionO:
+ case kDirectionW:
direction = kDirectionN;
break;
@@ -989,16 +991,16 @@ void Actor::updateDirection() {
direction = kDirectionSE;
break;
- case kDirectionSO:
+ case kDirectionSW:
direction = kDirectionNE;
break;
case kDirectionNE:
- direction = kDirectionSO;
+ direction = kDirectionSW;
break;
- case kDirectionNO:
- direction = kDirectionNO;
+ case kDirectionNW:
+ direction = kDirectionNW;
break;
}
break;
@@ -1249,7 +1251,7 @@ bool Actor::process(const Common::Point &point) {
}
if (point.y == sum.y) {
- ActorDirection actorDir = (a3 != 0 || a3 != 3) ? kDirectionE : kDirectionO;
+ ActorDirection actorDir = (a3 != 0 || a3 != 3) ? kDirectionE : kDirectionW;
if (canMove(&sum, actorDir, (uint32)abs(delta.x), true)) {
_data.points[0] = point;
@@ -1286,7 +1288,7 @@ bool Actor::process(const Common::Point &point) {
break;
case 0:
- direction1 = kDirectionNO;
+ direction1 = kDirectionNW;
direction2 = kDirectionN;
break;
@@ -1301,7 +1303,7 @@ bool Actor::process(const Common::Point &point) {
break;
case 3:
- direction1 = kDirectionSO;
+ direction1 = kDirectionSW;
direction2 = kDirectionS;
break;
}
@@ -1317,8 +1319,8 @@ bool Actor::process(const Common::Point &point) {
break;
case 0:
- direction1 = kDirectionNO;
- direction2 = kDirectionO;
+ direction1 = kDirectionNW;
+ direction2 = kDirectionW;
break;
case 1:
@@ -1332,8 +1334,8 @@ bool Actor::process(const Common::Point &point) {
break;
case 3:
- direction1 = kDirectionSO;
- direction2 = kDirectionO;
+ direction1 = kDirectionSW;
+ direction2 = kDirectionW;
break;
}
}
@@ -1439,13 +1441,13 @@ bool Actor::process(const Common::Point &point) {
// Last case: abs(delta.x) == abs(delta.y)
// Compute direction
- ActorDirection actorDir = kDirectionSO;
+ ActorDirection actorDir = kDirectionSW;
switch (a3) {
default:
break;
case 0:
- actorDir = kDirectionNO;
+ actorDir = kDirectionNW;
break;
case 1:
@@ -1512,7 +1514,7 @@ void Actor::processNext(ActorIndex nextActor, int32 actionAreaId, ActorDirection
offset.y = point.y;
break;
- case kDirectionNO:
+ case kDirectionNW:
if (offset.y > point.y)
offset.y = point.y;
@@ -1520,12 +1522,12 @@ void Actor::processNext(ActorIndex nextActor, int32 actionAreaId, ActorDirection
offset.x = point.x;
break;
- case kDirectionO:
+ case kDirectionW:
if (offset.x > point.x)
offset.x = point.x;
break;
- case kDirectionSO:
+ case kDirectionSW:
if (offset.y < point.y)
offset.y = point.y;
@@ -1935,7 +1937,7 @@ bool Actor::canMoveCheckActors(Common::Point *point, ActorDirection dir) {
default:
break;
- case kDirectionNO:
+ case kDirectionNW:
if (x4 >= x)
break;
// Fallback to next case
@@ -1946,13 +1948,13 @@ bool Actor::canMoveCheckActors(Common::Point *point, ActorDirection dir) {
return false;
- case kDirectionO:
+ case kDirectionW:
if (x4 < x)
return false;
break;
- case kDirectionSO:
+ case kDirectionSW:
if (x4 < x && y4 > y)
return false;
@@ -3393,9 +3395,9 @@ bool Actor::processActionAll(Common::Point source, const Common::Point &destinat
Common::Point src = source;
for (uint32 i = 0; i < 60; i++) {
- if (!processAction(source, actions, &src, kDirectionO, destination, &flag)
- && !processAction(source, actions, &src, kDirectionNO, destination, &flag)
- && !processAction(source, actions, &src, kDirectionSO, destination, &flag)) {
+ if (!processAction(source, actions, &src, kDirectionW, destination, &flag)
+ && !processAction(source, actions, &src, kDirectionNW, destination, &flag)
+ && !processAction(source, actions, &src, kDirectionSW, destination, &flag)) {
if (src.y <= destination.y) {
if (!processAction(source, actions, &src, kDirectionS, destination, &flag)
&& !processAction(source, actions, &src, kDirectionN, destination, &flag)
@@ -3434,16 +3436,16 @@ bool Actor::processActionTop(Common::Point source, const Common::Point &destinat
for (uint32 i = 0; i < 60; i++) {
if (!processAction(source, actions, &src, kDirectionN, destination, &flag)) {
if (src.x >= destination.x) {
- if (!processAction(source, actions, &src, kDirectionNO, destination, &flag)
- && !processAction(source, actions, &src, kDirectionO, destination, &flag)
+ if (!processAction(source, actions, &src, kDirectionNW, destination, &flag)
+ && !processAction(source, actions, &src, kDirectionW, destination, &flag)
&& !processAction(source, actions, &src, kDirectionNE, destination, &flag)
&& !processAction(source, actions, &src, kDirectionE, destination, &flag))
continue;
} else {
if (!processAction(source, actions, &src, kDirectionNE, destination, &flag)
&& !processAction(source, actions, &src, kDirectionE, destination, &flag)
- && !processAction(source, actions, &src, kDirectionNO, destination, &flag)
- && !processAction(source, actions, &src, kDirectionO, destination, &flag))
+ && !processAction(source, actions, &src, kDirectionNW, destination, &flag)
+ && !processAction(source, actions, &src, kDirectionW, destination, &flag))
continue;
}
}
@@ -3469,9 +3471,9 @@ bool Actor::processActionDown(Common::Point source, const Common::Point &destina
for (uint32 i = 0; i < 60; i++) {
if (!processAction(source, actions, &src, kDirectionS, destination, &flag)
&& !processAction(source, actions, &src, kDirectionSE, destination, &flag)
- && !processAction(source, actions, &src, kDirectionSO, destination, &flag)
+ && !processAction(source, actions, &src, kDirectionSW, destination, &flag)
&& !processAction(source, actions, &src, kDirectionE, destination, &flag)
- && !processAction(source, actions, &src, kDirectionO, destination, &flag))
+ && !processAction(source, actions, &src, kDirectionW, destination, &flag))
continue;
// Update source point after all processing
@@ -3497,16 +3499,16 @@ bool Actor::processAction(const Common::Point &source, Common::Array<int> *actio
sign.y = -1;
break;
- case kDirectionNO:
+ case kDirectionNW:
sign.x = -1;
sign.y = -1;
break;
- case kDirectionO:
+ case kDirectionW:
sign.x = -1;
break;
- case kDirectionSO:
+ case kDirectionSW:
sign.x = -1;
sign.y = 1;
break;
@@ -3538,11 +3540,11 @@ bool Actor::processAction(const Common::Point &source, Common::Array<int> *actio
src.x += (int16)(sign.x * dist);
src.y += (int16)(sign.y * dist);
- if (abs(src.x - destination.x) >= getAbsoluteDistanceForFrame(kDirectionO, frameNumber)) {
+ if (abs(src.x - destination.x) >= getAbsoluteDistanceForFrame(kDirectionW, frameNumber)) {
if (abs(src.y - destination.y) >= getAbsoluteDistanceForFrame(kDirectionN, frameNumber)) {
if (src.x >= destination.x) {
- if (checkPath(actions, src, kDirectionO, src.x - destination.x)) {
+ if (checkPath(actions, src, kDirectionW, src.x - destination.x)) {
*flag = true;
*point = src;
@@ -3551,7 +3553,7 @@ bool Actor::processAction(const Common::Point &source, Common::Array<int> *actio
_data.count++;
_data.points[_data.count] = destination;
- _data.directions[_data.count] = kDirectionO;
+ _data.directions[_data.count] = kDirectionW;
_data.count++;
return true;
@@ -3805,7 +3807,7 @@ ActorDirection Actor::directionFromAngle(const Common::Point &vec1, const Common
if (dirAngle < 202 || dirAngle >= 247) {
error("[Actor::direction] got a bad direction angle: %d!", dirAngle);
} else {
- dir = kDirectionSO;
+ dir = kDirectionSW;
}
} else {
dir = kDirectionS;
@@ -3823,10 +3825,10 @@ ActorDirection Actor::directionFromAngle(const Common::Point &vec1, const Common
dir = kDirectionN;
}
} else {
- dir = kDirectionNO;
+ dir = kDirectionNW;
}
} else {
- dir = kDirectionO;
+ dir = kDirectionW;
}
return dir;
@@ -3877,13 +3879,13 @@ int32 Actor::getAbsoluteDistanceForFrame(ActorDirection dir, uint32 frameIndex)
case kDirectionS:
return _distancesNS[frameIndex];
- case kDirectionNO:
- case kDirectionSO:
+ case kDirectionNW:
+ case kDirectionSW:
case kDirectionSE:
case kDirectionNE:
return _distancesNSEO[frameIndex];
- case kDirectionO:
+ case kDirectionW:
case kDirectionE:
return _distancesEO[frameIndex];
}
@@ -3903,19 +3905,19 @@ int32 Actor::getDistanceForFrame(ActorDirection dir, uint32 frameIndex) const {
case kDirectionS:
return _distancesNS[frameIndex];
- case kDirectionNO:
+ case kDirectionNW:
return -_distancesNSEO[frameIndex];
case kDirectionNE:
return -_distancesNSEO[frameIndex];
- case kDirectionSO:
+ case kDirectionSW:
return _distancesNSEO[frameIndex];
case kDirectionSE:
return _distancesNSEO[frameIndex];
- case kDirectionO:
+ case kDirectionW:
return -_distancesEO[frameIndex];
case kDirectionE:
@@ -3935,16 +3937,16 @@ void Actor::updateCoordinatesForDirection(ActorDirection direction, int16 delta,
point->y -= delta;
break;
- case kDirectionNO:
+ case kDirectionNW:
point->x -= delta;
point->y -= delta;
break;
- case kDirectionO:
+ case kDirectionW:
point->x -= delta;
break;
- case kDirectionSO:
+ case kDirectionSW:
point->x -= delta;
point->y += delta;
break;
@@ -3999,17 +4001,17 @@ void Actor::rectFromDirection(Common::Rect *rect, ActorDirection direction, cons
rect->left = point.y - 84;
break;
- case kDirectionNO:
+ case kDirectionNW:
rect->top = point.x - 55;
rect->left = point.y - 84;
break;
- case kDirectionO:
+ case kDirectionW:
rect->top = point.x - 34;
rect->left = point.y - 93;
break;
- case kDirectionSO:
+ case kDirectionSW:
rect->top = point.x + 27;
rect->left = point.y - 94;
break;
diff --git a/engines/asylum/resources/object.h b/engines/asylum/resources/object.h
index de6d7fcbe0..9a5412b699 100644
--- a/engines/asylum/resources/object.h
+++ b/engines/asylum/resources/object.h
@@ -154,6 +154,7 @@ public:
*/
bool checkFlags() const;
+ uint8 *getName() { return _name; }
/**
* Convert this object into a string representation.
*
diff --git a/engines/asylum/resources/special.cpp b/engines/asylum/resources/special.cpp
index 44d2329dbd..ff837dc27b 100644
--- a/engines/asylum/resources/special.cpp
+++ b/engines/asylum/resources/special.cpp
@@ -722,6 +722,7 @@ void Special::playChapterSound(Object *object, ActorIndex actorIndex) {
void Special::playSoundChapter1(Object *object, ActorIndex actorIndex) {
if (actorIndex == kActorInvalid) {
+ warning("Trying to play sound for %s", object->getName());
switch(object->getId()) {
default:
break;
diff --git a/engines/asylum/shared.h b/engines/asylum/shared.h
index 910c63f1e0..3e42fd610f 100644
--- a/engines/asylum/shared.h
+++ b/engines/asylum/shared.h
@@ -415,9 +415,9 @@ enum ActorStatus {
enum ActorDirection {
kDirectionInvalid = -1,
kDirectionN = 0,
- kDirectionNO = 1,
- kDirectionO = 2,
- kDirectionSO = 3,
+ kDirectionNW = 1,
+ kDirectionW = 2,
+ kDirectionSW = 3,
kDirectionS = 4,
kDirectionSE = 5,
kDirectionE = 6,
diff --git a/engines/asylum/views/scene.cpp b/engines/asylum/views/scene.cpp
index 461fb89259..35114b1e63 100644
--- a/engines/asylum/views/scene.cpp
+++ b/engines/asylum/views/scene.cpp
@@ -146,7 +146,7 @@ void Scene::enter(ResourcePackId packId) {
Actor *actor = _ws->actors[i];
actor->hide();
- actor->setDirection(kDirectionNO);
+ actor->setDirection(kDirectionNW);
actor->enable();
actor->getPoint1()->x -= actor->getPoint2()->x;
@@ -709,48 +709,48 @@ void Scene::updateMouse() {
if (mouse.x < actorRect.left) {
if (mouse.y >= actorRect.top) {
if (mouse.y > actorRect.bottom) {
- if (player->getDirection() == kDirectionO) {
+ if (player->getDirection() == kDirectionW) {
if ((mouse.y - actorRect.bottom) > 10)
- newDirection = kDirectionSO;
+ newDirection = kDirectionSW;
} else {
if (player->getDirection() == kDirectionS) {
if ((actorRect.left - mouse.x) > 10)
- newDirection = kDirectionSO;
+ newDirection = kDirectionSW;
} else {
- newDirection = kDirectionSO;
+ newDirection = kDirectionSW;
}
}
} else {
- if (player->getDirection() == kDirectionNO) {
+ if (player->getDirection() == kDirectionNW) {
if ((mouse.y - actorRect.top) > 10)
- newDirection = kDirectionO;
+ newDirection = kDirectionW;
} else {
- if (player->getDirection() == kDirectionSO) {
+ if (player->getDirection() == kDirectionSW) {
if ((actorRect.bottom - mouse.y) > 10)
- newDirection = kDirectionO;
+ newDirection = kDirectionW;
} else {
- newDirection = kDirectionO;
+ newDirection = kDirectionW;
}
}
}
} else {
if (player->getDirection() != kDirectionN) {
- if (player->getDirection() == kDirectionO) {
+ if (player->getDirection() == kDirectionW) {
if ((actorRect.top - mouse.y) > 10)
- newDirection = kDirectionNO;
+ newDirection = kDirectionNW;
} else {
- newDirection = kDirectionNO;
+ newDirection = kDirectionNW;
}
} else {
if ((actorRect.left - mouse.x) > 10)
- newDirection = kDirectionNO;
+ newDirection = kDirectionNW;
}
}
} else if (mouse.x <= actorRect.right) {
if (mouse.y >= actorRect.top) {
if (mouse.y > actorRect.bottom) {
- if (player->getDirection() == kDirectionSO) {
+ if (player->getDirection() == kDirectionSW) {
if ((mouse.x - actorRect.left) > 10)
newDirection = kDirectionS;
} else {
@@ -763,7 +763,7 @@ void Scene::updateMouse() {
}
}
} else {
- if (player->getDirection() == kDirectionNO) {
+ if (player->getDirection() == kDirectionNW) {
if ((mouse.x - actorRect.left) > 10)
newDirection = kDirectionN;
} else {
Commit: 472a7252c4da9a0c000e96a028527b09af361a3a
https://github.com/scummvm/scummvm/commit/472a7252c4da9a0c000e96a028527b09af361a3a
Author: Alex Bevilacqua (alexbevi at gmail.com)
Date: 2021-05-17T15:37:25+02:00
Commit Message:
ASYLUM: align enum assignments
Changed paths:
engines/asylum/shared.h
diff --git a/engines/asylum/shared.h b/engines/asylum/shared.h
index 3e42fd610f..229451f422 100644
--- a/engines/asylum/shared.h
+++ b/engines/asylum/shared.h
@@ -188,7 +188,7 @@ enum GameFlag {
enum ChapterIndex {
kChapterInvalid = -1,
- kChapterNone = 0,
+ kChapterNone = 0,
kChapter1,
kChapter2,
kChapter3,
@@ -240,8 +240,8 @@ enum ResourcePackId {
typedef int ResourceId;
enum ResourcesId {
- kResourceInvalid = -1,
- kResourceNone = 0
+ kResourceInvalid = -1,
+ kResourceNone = 0
};
#define kMusicStopped -666
@@ -262,15 +262,15 @@ enum ActionType {
kActionTypeFind = 1,
kActionTypeTalk = 2,
kActionTypeGrab = 4,
- kActionType8 = 8,
- kActionType16 = 16
+ kActionType8 = 8,
+ kActionType16 = 16
};
//////////////////////////////////////////////////////////////////////////
// Script
//////////////////////////////////////////////////////////////////////////
enum OpcodeType {
- kOpcodeReturn = 0,
+ kOpcodeReturn = 0,
kOpcodeSetGameFlag,
kOpcodeClearGameFlag,
kOpcodeToggleGameFlag,
@@ -388,7 +388,7 @@ enum ActorIndexes {
};
enum ActorStatus {
- kActorStatusNone = 0,
+ kActorStatusNone = 0,
kActorStatusWalking = 1, // Walking
kActorStatusWalkingTo, // Auto-walking to target
kActorStatus3,
@@ -414,15 +414,15 @@ enum ActorStatus {
enum ActorDirection {
kDirectionInvalid = -1,
- kDirectionN = 0,
- kDirectionNW = 1,
- kDirectionW = 2,
- kDirectionSW = 3,
- kDirectionS = 4,
- kDirectionSE = 5,
- kDirectionE = 6,
- kDirectionNE = 7,
- kDirection8 = 8
+ kDirectionN = 0,
+ kDirectionNW = 1,
+ kDirectionW = 2,
+ kDirectionSW = 3,
+ kDirectionS = 4,
+ kDirectionSE = 5,
+ kDirectionE = 6,
+ kDirectionNE = 7,
+ kDirection8 = 8
};
enum ActorFlags {
@@ -431,9 +431,9 @@ enum ActorFlags {
};
enum DirectionFrom {
- kDirectionFromObject = 0,
- kDirectionFromPolygons = 1,
- kDirectionFromActor = 2,
+ kDirectionFromObject = 0,
+ kDirectionFromPolygons = 1,
+ kDirectionFromActor = 2,
kDirectionFromParameters = 3
};
Commit: 5d0af78206849ac0f4239f04449bc794d1a2c896
https://github.com/scummvm/scummvm/commit/5d0af78206849ac0f4239f04449bc794d1a2c896
Author: Alex Bevilacqua (alexbevi at gmail.com)
Date: 2021-05-17T15:37:25+02:00
Commit Message:
ASYLUM: remove accidentally committed debug code
Changed paths:
engines/asylum/resources/special.cpp
diff --git a/engines/asylum/resources/special.cpp b/engines/asylum/resources/special.cpp
index ff837dc27b..44d2329dbd 100644
--- a/engines/asylum/resources/special.cpp
+++ b/engines/asylum/resources/special.cpp
@@ -722,7 +722,6 @@ void Special::playChapterSound(Object *object, ActorIndex actorIndex) {
void Special::playSoundChapter1(Object *object, ActorIndex actorIndex) {
if (actorIndex == kActorInvalid) {
- warning("Trying to play sound for %s", object->getName());
switch(object->getId()) {
default:
break;
Commit: e73059638a08de578a4c136b5c112a256da4890b
https://github.com/scummvm/scummvm/commit/e73059638a08de578a4c136b5c112a256da4890b
Author: Alex Bevilacqua (alexbevi at gmail.com)
Date: 2021-05-17T15:37:25+02:00
Commit Message:
ASYLUM: enable debug channel for Actor objects
Changed paths:
engines/asylum/asylum.cpp
diff --git a/engines/asylum/asylum.cpp b/engines/asylum/asylum.cpp
index 2307dbde72..03e0b72980 100644
--- a/engines/asylum/asylum.cpp
+++ b/engines/asylum/asylum.cpp
@@ -85,7 +85,8 @@ AsylumEngine::AsylumEngine(OSystem *system, const ADGameDescription *gd) : Engin
DebugMan.addDebugChannel(kDebugLevelSound, "Sound", "Sound debugging");
DebugMan.addDebugChannel(kDebugLevelSavegame, "Savegame", "Saving & restoring game debugging");
DebugMan.addDebugChannel(kDebugLevelScene, "Scene", "Scene process and draw debugging");
- DebugMan.addDebugChannel(kDebugLevelObjects, "Objects", "Debug Object Objects");
+ DebugMan.addDebugChannel(kDebugLevelObjects, "Objects", "Debug Object objects");
+ DebugMan.addDebugChannel(kDebugLevelActor, "Actor", "Debug Actor");
// Initialize random number source
_rnd = new Common::RandomSource("asylum");
Commit: cdb9c748c009758049c65582e20d33fa39786bd1
https://github.com/scummvm/scummvm/commit/cdb9c748c009758049c65582e20d33fa39786bd1
Author: Alex Bevilacqua (alexbevi at gmail.com)
Date: 2021-05-17T15:37:25+02:00
Commit Message:
ASYLUM: fix a logic error in Actor::update
Changed paths:
engines/asylum/resources/actor.cpp
diff --git a/engines/asylum/resources/actor.cpp b/engines/asylum/resources/actor.cpp
index fc904bb3ad..8fcec62ebd 100644
--- a/engines/asylum/resources/actor.cpp
+++ b/engines/asylum/resources/actor.cpp
@@ -586,10 +586,10 @@ void Actor::update() {
Common::Point point = _point1 + _point2;
Common::Point current = _data.points[_data.current];
- if (point.x < (int16)(current.x - (dist - 1))
- || point.x > (int16)(current.x + (dist - 1))
- || point.y < (int16)(current.y - (dist - 1))
- || point.y > (int16)(current.y + (dist - 1))) {
+ if (point.x < (int16)(current.x - (dist + 1))
+ || point.x > (int16)(current.x + (dist + 1))
+ || point.y < (int16)(current.y - (dist + 1))
+ || point.y > (int16)(current.y + (dist + 1))) {
if (canMove(&point, _direction, (uint32)dist, false)) {
move(_direction, (uint32)dist);
} else {
@@ -702,7 +702,7 @@ void Actor::update() {
void Actor::updateStatus(ActorStatus actorStatus) {
- debugC(kDebugLevelActor, "[updateStatus] %d point1(%d/%d)", actorStatus, this->_point1.x, this->_point1.y);
+ debugC(kDebugLevelActor, "[updateStatus] %d point1(%d:%d) point2(%d:%d)", actorStatus, _point1.x, _point1.y, _point2.x, _point2.y);
switch (actorStatus) {
default:
Commit: 59cfa7ce66b723c8e381070695f77771596574f1
https://github.com/scummvm/scummvm/commit/59cfa7ce66b723c8e381070695f77771596574f1
Author: Alex Bevilacqua (alexbevi at gmail.com)
Date: 2021-05-17T15:37:25+02:00
Commit Message:
ASYLUM: convert GUI options to sync with master
Changed paths:
engines/asylum/detection.cpp
diff --git a/engines/asylum/detection.cpp b/engines/asylum/detection.cpp
index 06038b2095..d8edab9806 100644
--- a/engines/asylum/detection.cpp
+++ b/engines/asylum/detection.cpp
@@ -47,7 +47,7 @@ static const ADGameDescription gameDescriptions[] = {
Common::EN_ANY,
Common::kPlatformPC,
ADGF_DEMO|ADGF_UNSTABLE,
- Common::GUIO_NONE
+ GUIO1(GUIO_NONE)
},
{
"asylum",
@@ -61,7 +61,7 @@ static const ADGameDescription gameDescriptions[] = {
Common::EN_ANY,
Common::kPlatformPC,
ADGF_UNSTABLE,
- Common::GUIO_NONE
+ GUIO1(GUIO_NONE)
},
{
"asylum",
@@ -75,7 +75,7 @@ static const ADGameDescription gameDescriptions[] = {
Common::EN_ANY,
Common::kPlatformPC,
ADGF_UNSTABLE,
- Common::GUIO_NONE
+ GUIO1(GUIO_NONE)
},
{
"asylum",
@@ -89,7 +89,7 @@ static const ADGameDescription gameDescriptions[] = {
Common::EN_ANY,
Common::kPlatformPC,
ADGF_UNSTABLE,
- Common::GUIO_NONE
+ GUIO1(GUIO_NONE)
},
{
"asylum",
@@ -103,7 +103,7 @@ static const ADGameDescription gameDescriptions[] = {
Common::FR_FRA,
Common::kPlatformPC,
ADGF_UNSTABLE,
- Common::GUIO_NONE
+ GUIO1(GUIO_NONE)
},
{
"asylum",
@@ -117,7 +117,7 @@ static const ADGameDescription gameDescriptions[] = {
Common::RU_RUS,
Common::kPlatformPC,
ADGF_UNSTABLE,
- Common::GUIO_NONE
+ GUIO1(GUIO_NONE)
},
AD_TABLE_END_MARKER
};
@@ -134,7 +134,7 @@ public:
AsylumMetaEngine() : AdvancedMetaEngine(Asylum::gameDescriptions, sizeof(ADGameDescription), asylumGames) {
_singleid = "asylum";
_md5Bytes = 0;
- _guioptions = Common::GUIO_NONE;
+ _guioptions = GUIO1(GUIO_NONE);
}
virtual const char *getName() const {
Commit: c97fe2a6ca88cff30e5c9ef9f474ae186c248f81
https://github.com/scummvm/scummvm/commit/c97fe2a6ca88cff30e5c9ef9f474ae186c248f81
Author: xesf (alexandrefontoura at gmail.com)
Date: 2021-05-17T15:37:25+02:00
Commit Message:
ASYLUM: Fixed script reset while changing scenes.
This prevents a lot of fault script actions.
Changed paths:
engines/asylum/resources/script.cpp
engines/asylum/resources/script.h
engines/asylum/views/scene.cpp
diff --git a/engines/asylum/resources/script.cpp b/engines/asylum/resources/script.cpp
index 4e1973b5d6..d21409ae0a 100644
--- a/engines/asylum/resources/script.cpp
+++ b/engines/asylum/resources/script.cpp
@@ -275,6 +275,12 @@ void ScriptManager::saveQueue(Common::Serializer &s) {
_queue.saveLoadWithSerializer(s);
}
+void ScriptManager::resetAll() {
+ _scripts.clear();
+ resetQueue();
+ reset();
+}
+
void ScriptManager::reset(uint32 count) {
// Create a set of empty scripts
for (uint32 i = 0; i < count; i++) {
diff --git a/engines/asylum/resources/script.h b/engines/asylum/resources/script.h
index d4390f471c..664135792a 100644
--- a/engines/asylum/resources/script.h
+++ b/engines/asylum/resources/script.h
@@ -136,6 +136,11 @@ public:
*/
bool process();
+ /**
+ * Fully resets script manager state (used while changing scenes)
+ */
+ void resetAll();
+
/**
* Resets the queue and local variables
*/
diff --git a/engines/asylum/views/scene.cpp b/engines/asylum/views/scene.cpp
index 35114b1e63..75b12f0fe1 100644
--- a/engines/asylum/views/scene.cpp
+++ b/engines/asylum/views/scene.cpp
@@ -275,7 +275,9 @@ void Scene::load(ResourcePackId packId) {
_polygons = new Polygons(fd);
- getScript()->load(fd);
+ ScriptManager *script = getScript();
+ script->resetAll();
+ script->load(fd);
fd->close();
delete fd;
Commit: 0703dbfff4dc8b7d0eda2394db86a3ebe12b2654
https://github.com/scummvm/scummvm/commit/0703dbfff4dc8b7d0eda2394db86a3ebe12b2654
Author: xesf (alexandrefontoura at gmail.com)
Date: 2021-05-17T15:37:26+02:00
Commit Message:
ASYLUM: Fixed compilation with DEBUG definition
Changed paths:
engines/asylum/resources/script.cpp
diff --git a/engines/asylum/resources/script.cpp b/engines/asylum/resources/script.cpp
index d21409ae0a..0dbc2bb0ce 100644
--- a/engines/asylum/resources/script.cpp
+++ b/engines/asylum/resources/script.cpp
@@ -253,7 +253,7 @@ void ScriptManager::load(Common::SeekableReadStream *stream) {
#ifdef DEBUG
// Output encounter info
if (command.opcode == kOpcodeRunEncounter)
- debugC(kDebugLevelEncounter, "%d, %d, %d, %d", command.param1, command.param2, command.param3, command.param4);*/
+ debugC(kDebugLevelEncounter, "%d, %d, %d, %d", command.param1, command.param2, command.param3, command.param4);
#endif
}
Commit: e68598ff9ff54c13f9ce958b684de671fe451644
https://github.com/scummvm/scummvm/commit/e68598ff9ff54c13f9ce958b684de671fe451644
Author: xesf (alexandrefontoura at gmail.com)
Date: 2021-05-17T15:37:26+02:00
Commit Message:
ASYLUM: Fixed JumpAndSetDirection incorrect parameter set.
Changed paths:
engines/asylum/resources/script.cpp
diff --git a/engines/asylum/resources/script.cpp b/engines/asylum/resources/script.cpp
index 0dbc2bb0ce..f1785c0256 100644
--- a/engines/asylum/resources/script.cpp
+++ b/engines/asylum/resources/script.cpp
@@ -714,7 +714,7 @@ IMPLEMENT_OPCODE(JumpAndSetDirection)
} else if ((actor->getPoint1()->x + actor->getPoint2()->x) == cmd->param2 && (actor->getPoint1()->y + actor->getPoint2()->y) == cmd->param3) {
actor->updateFromDirection((ActorDirection)cmd->param4);
} else {
- actor->processStatus((int16)cmd->param2, (int16)cmd->param3, (bool)cmd->param4);
+ actor->processStatus((int16)cmd->param2, (int16)cmd->param3, (bool)cmd->param6);
if (cmd->param5 == 1) {
cmd->param5 = 2;
Commit: 0dc2ab3402a97eccb3bfb2c6ff0a345026c4cbb3
https://github.com/scummvm/scummvm/commit/0dc2ab3402a97eccb3bfb2c6ff0a345026c4cbb3
Author: xesf (alexandrefontoura at gmail.com)
Date: 2021-05-17T15:37:26+02:00
Commit Message:
ASYLUM: Fixed various issues in Actor position calculations. Still missing something yet to make Max climb the first stairs. Anyway, this corrects a lot of incorrect script behaviors.
Changed paths:
engines/asylum/resources/actor.cpp
engines/asylum/resources/actor.h
diff --git a/engines/asylum/resources/actor.cpp b/engines/asylum/resources/actor.cpp
index 8fcec62ebd..e7c3793d64 100644
--- a/engines/asylum/resources/actor.cpp
+++ b/engines/asylum/resources/actor.cpp
@@ -606,12 +606,7 @@ void Actor::update() {
_frameIndex = (_frameIndex + 1) % _frameCount;
if (canMoveCheckActors(¤t, _direction)) {
- // FIXME This matches the original, but results in a negative x value,
- // which causes the actor to warp to the left side of the screen.
- // Perhaps _point2.x is not being properly set somewhere ...
- // This can be quickly tested in Scene 1 by trying to pick up
- // the towel.
- _point1.x = (int16)dist - _point2.x;
+ _point1.x = current.x - _point2.x;
_point1.y = current.y - _point2.y;
if (_data.current < (int32)(_data.count - 1)) {
@@ -1311,7 +1306,7 @@ bool Actor::process(const Common::Point &point) {
point1 = Common::Point((int16)(sum.x + abs(delta.y) * a1), (int16)(sum.y + abs(delta.y) * a2));
point2 = Common::Point((int16)(sum.x + abs(abs(delta.y) - abs(delta.x)) * a1), sum.y);
count1 = (uint32)abs(abs(delta.y) * a2);
- count2 = (uint32)abs(point1.y - point.x);
+ count2 = (uint32)abs(point1.x - point.x);
switch (a3) {
default:
@@ -1363,7 +1358,7 @@ bool Actor::process(const Common::Point &point) {
}
if (canMove(&sum, direction2, count2, true)
- && canMove(&point1, direction1, count1, true)) {
+ && canMove(&point2, direction1, count1, true)) {
_data.points[0] = point2;
_data.points[1] = point;
_data.current = 0;
@@ -1743,7 +1738,7 @@ void Actor::move(ActorDirection actorDir, uint32 dist) {
_lastScreenUpdate = _vm->screenUpdateCount;
- Common::Point sum(_point1.x + _point2.x, _point1.x + _point2.x);
+ Common::Point sum(_point1.x + _point2.x, _point1.y + _point2.y);
int32 panning = getSound()->calculatePanningAtPoint(sum);
switch (_status) {
@@ -1912,6 +1907,9 @@ bool Actor::canMoveCheckActors(Common::Point *point, ActorDirection dir) {
if (!actor->isOnScreen())
continue;
+ if (actor->_field_944)
+ continue;
+
int32 x2 = actor->getPoint1()->x + actor->getPoint2()->x - (actor->getField948() + 15);
int32 y2 = actor->getPoint1()->y + actor->getPoint2()->y - (actor->getField94C() + 10);
int32 x3 = actor->getPoint1()->x + actor->getPoint2()->x + 2 * actor->getField948() + 15;
@@ -3965,7 +3963,7 @@ void Actor::updateCoordinatesForDirection(ActorDirection direction, int16 delta,
break;
case kDirectionNE:
- point->y += delta;
+ point->x += delta;
point->y -= delta;
break;
}
diff --git a/engines/asylum/resources/actor.h b/engines/asylum/resources/actor.h
index 85c964b4be..17abe01fcb 100644
--- a/engines/asylum/resources/actor.h
+++ b/engines/asylum/resources/actor.h
@@ -394,7 +394,7 @@ private:
int32 _field_938;
ResourceId _soundResourceId; // field_93C
int32 _numberValue01;
- int32 _field_944;
+ int32 _field_944; // has collision ?!
int32 _field_948;
int32 _field_94C;
int32 _numberFlag01;
Commit: b6cce3a19f6989d867ee95115bfbba413cfe87d7
https://github.com/scummvm/scummvm/commit/b6cce3a19f6989d867ee95115bfbba413cfe87d7
Author: Alex Bevilacqua (alexbevi at gmail.com)
Date: 2021-05-17T15:37:26+02:00
Commit Message:
ASYLUM: add some debug output for sound queue events
Changed paths:
engines/asylum/system/sound.cpp
diff --git a/engines/asylum/system/sound.cpp b/engines/asylum/system/sound.cpp
index f6db9554b6..97c32cc3c6 100644
--- a/engines/asylum/system/sound.cpp
+++ b/engines/asylum/system/sound.cpp
@@ -56,6 +56,8 @@ Sound::~Sound() {
//////////////////////////////////////////////////////////////////////////
void Sound::playSound(ResourceId resourceId, bool looping, int32 volume, int32 panning) {
+ debugC(kDebugLevelSound, "[Sound] Playing Sound 0x%08X", resourceId);
+
// Cleanup sound queue
cleanupQueue();
@@ -82,6 +84,7 @@ void Sound::playSound(ResourceId resourceId, bool looping, int32 volume, int32 p
}
void Sound::playMusic(ResourceId resourceId, int32 volume) {
+ debugC(kDebugLevelSound, "[Sound] Playing Music 0x%08X", resourceId);
if (resourceId == kResourceNone) {
stopMusic();
return;
@@ -301,6 +304,7 @@ SoundQueueItem *Sound::getPlayingItem(ResourceId resourceId) {
}
SoundQueueItem *Sound::addToQueue(ResourceId resourceId) {
+ debugC(kDebugLevelSound, "[Sound] Queueing Sound 0x%08X", resourceId);
SoundQueueItem sound;
sound.resourceId = resourceId;
_soundQueue.push_back(sound);
Commit: bfe8276bc85952bc4fa735908b12e709969b95f1
https://github.com/scummvm/scummvm/commit/bfe8276bc85952bc4fa735908b12e709969b95f1
Author: Alex Bevilacqua (alexbevi at gmail.com)
Date: 2021-05-17T15:37:26+02:00
Commit Message:
ASYLUM: update a comment
Changed paths:
engines/asylum/views/scene.cpp
diff --git a/engines/asylum/views/scene.cpp b/engines/asylum/views/scene.cpp
index 75b12f0fe1..79dc4c332a 100644
--- a/engines/asylum/views/scene.cpp
+++ b/engines/asylum/views/scene.cpp
@@ -1125,7 +1125,8 @@ void Scene::updateCoordinates() {
if ((yTop + 479) > sceneRect.bottom)
yTop = _ws->yTop = sceneRect.bottom - 479;
- // TODO set a var if scene coordinates changed
+ // XXX dword_44E1EC is set to 2 at this point if the scene coordinates
+ // have changed, but that variable is never used anywhere else
}
void Scene::updateCursor(ActorDirection direction, const Common::Rect &rect) {
Commit: 0c7b3038fef9e70841265395da105c357d75b4fc
https://github.com/scummvm/scummvm/commit/0c7b3038fef9e70841265395da105c357d75b4fc
Author: Alex Bevilacqua (alexbevi at gmail.com)
Date: 2021-05-17T15:37:26+02:00
Commit Message:
ASYLUM: replace isalnum() with Common::isAlNum()
Changed paths:
engines/asylum/views/menu.cpp
diff --git a/engines/asylum/views/menu.cpp b/engines/asylum/views/menu.cpp
index 4e72f8b73a..c90b155fb7 100644
--- a/engines/asylum/views/menu.cpp
+++ b/engines/asylum/views/menu.cpp
@@ -291,7 +291,7 @@ void Menu::setupMusic() {
}
void Menu::adjustPerformance() {
- // Original reinitialize sound to 11kHz for performance == 0, 22kHz otherwise
+ // Original reinitialize sound to 11kHz for performance == 0, ikHz otherwise
getSound()->stopAll();
getSound()->playMusic(kResourceNone, 0);
setupMusic();
@@ -2284,7 +2284,7 @@ void Menu::keySaveGame(const AsylumEvent &evt) {
switch (evt.kbd.keycode) {
default:
- if (evt.kbd.ascii > 255 || !isalnum(evt.kbd.ascii))
+ if (evt.kbd.ascii > 255 || !Common::isAlnum(evt.kbd.ascii))
break;
if (getSaveLoad()->getName()->size() < 44) {
@@ -2367,7 +2367,7 @@ void Menu::keyKeyboardConfig(const AsylumEvent &evt) {
}
// Check for alphanumeric character
- if (evt.kbd.ascii > 255 || !isalnum(evt.kbd.ascii))
+ if (evt.kbd.ascii > 255 || !Common::isAlnum(evt.kbd.ascii))
return;
if (!Config.isKeyAssigned((char)evt.kbd.ascii) || *keyCode == (char)evt.kbd.ascii) {
Commit: 7bf4a85cb2efed28a85360ff17c3b67e36f581a3
https://github.com/scummvm/scummvm/commit/7bf4a85cb2efed28a85360ff17c3b67e36f581a3
Author: Alex Bevilacqua (alexbevi at gmail.com)
Date: 2021-05-17T15:37:26+02:00
Commit Message:
ASYLUM: fix compilation with latest master
Changed paths:
engines/asylum/detection.cpp
engines/asylum/views/video.cpp
diff --git a/engines/asylum/detection.cpp b/engines/asylum/detection.cpp
index d8edab9806..409d3d8241 100644
--- a/engines/asylum/detection.cpp
+++ b/engines/asylum/detection.cpp
@@ -152,8 +152,9 @@ public:
protected:
virtual bool createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const;
- virtual const ADGameDescription *fallbackDetect(const FileMap &allFiles, const Common::FSList &) const {
- return detectGameFilebased(allFiles, Asylum::fileBasedFallback);
+
+ virtual const ADGameDescription *fallbackDetect(const FileMap &allFiles, const Common::FSList &fslist) const {
+ return detectGameFilebased(allFiles, fslist, Asylum::fileBasedFallback);
}
};
diff --git a/engines/asylum/views/video.cpp b/engines/asylum/views/video.cpp
index 9c87817780..81105a00d2 100644
--- a/engines/asylum/views/video.cpp
+++ b/engines/asylum/views/video.cpp
@@ -38,7 +38,7 @@ namespace Asylum {
VideoPlayer::VideoPlayer(AsylumEngine *engine, Audio::Mixer *mixer) : _vm(engine),
_currentMovie(0), _subtitleIndex(0), _subtitleCounter(0), _previousFont(kResourceNone), _done(false) {
- _smkDecoder = new Video::SmackerDecoder(mixer);
+ _smkDecoder = new Video::SmackerDecoder();
}
VideoPlayer::~VideoPlayer() {
Commit: 6f7307bd60c024577eb412a8d7e49bbabbe62369
https://github.com/scummvm/scummvm/commit/6f7307bd60c024577eb412a8d7e49bbabbe62369
Author: Alex Bevilacqua (alexbevi at gmail.com)
Date: 2021-05-17T15:37:27+02:00
Commit Message:
ASYLUM: remove unnecessary include
Changed paths:
engines/asylum/asylum.cpp
diff --git a/engines/asylum/asylum.cpp b/engines/asylum/asylum.cpp
index 03e0b72980..07374aa42a 100644
--- a/engines/asylum/asylum.cpp
+++ b/engines/asylum/asylum.cpp
@@ -44,7 +44,6 @@
#include "asylum/respack.h"
#include "common/debug-channels.h"
-#include "common/EventRecorder.h"
#include "engines/util.h"
Commit: 5b1bb1d145d6cd862f20d74aa459c16fcccf6b6e
https://github.com/scummvm/scummvm/commit/5b1bb1d145d6cd862f20d74aa459c16fcccf6b6e
Author: Alex Bevilacqua (alexbevi at gmail.com)
Date: 2021-05-17T15:37:27+02:00
Commit Message:
ASYLUM: change kPlatformPC => kPlatformWindows
Changed paths:
engines/asylum/detection.cpp
diff --git a/engines/asylum/detection.cpp b/engines/asylum/detection.cpp
index 409d3d8241..61edc9c4d7 100644
--- a/engines/asylum/detection.cpp
+++ b/engines/asylum/detection.cpp
@@ -45,7 +45,7 @@ static const ADGameDescription gameDescriptions[] = {
{0,0,0,0}
},
Common::EN_ANY,
- Common::kPlatformPC,
+ Common::kPlatformWindows,
ADGF_DEMO|ADGF_UNSTABLE,
GUIO1(GUIO_NONE)
},
@@ -59,7 +59,7 @@ static const ADGameDescription gameDescriptions[] = {
{0,0,0,0}
},
Common::EN_ANY,
- Common::kPlatformPC,
+ Common::kPlatformWindows,
ADGF_UNSTABLE,
GUIO1(GUIO_NONE)
},
@@ -73,7 +73,7 @@ static const ADGameDescription gameDescriptions[] = {
{0,0,0,0}
},
Common::EN_ANY,
- Common::kPlatformPC,
+ Common::kPlatformWindows,
ADGF_UNSTABLE,
GUIO1(GUIO_NONE)
},
@@ -87,7 +87,7 @@ static const ADGameDescription gameDescriptions[] = {
{0,0,0,0}
},
Common::EN_ANY,
- Common::kPlatformPC,
+ Common::kPlatformWindows,
ADGF_UNSTABLE,
GUIO1(GUIO_NONE)
},
@@ -101,7 +101,7 @@ static const ADGameDescription gameDescriptions[] = {
{0,0,0,0}
},
Common::FR_FRA,
- Common::kPlatformPC,
+ Common::kPlatformWindows,
ADGF_UNSTABLE,
GUIO1(GUIO_NONE)
},
@@ -115,7 +115,7 @@ static const ADGameDescription gameDescriptions[] = {
{0,0,0,0}
},
Common::RU_RUS,
- Common::kPlatformPC,
+ Common::kPlatformWindows,
ADGF_UNSTABLE,
GUIO1(GUIO_NONE)
},
Commit: baf4fa93cb852341e07d0c893d4c12f5aee5be93
https://github.com/scummvm/scummvm/commit/baf4fa93cb852341e07d0c893d4c12f5aee5be93
Author: Alex Bevilacqua (alexbevi at gmail.com)
Date: 2021-05-17T15:37:27+02:00
Commit Message:
ASYLUM: access surface pixels via getPixels()
Changed paths:
engines/asylum/puzzles/hivecontrol.cpp
engines/asylum/system/cursor.cpp
engines/asylum/system/graphics.cpp
engines/asylum/system/screen.cpp
engines/asylum/views/video.cpp
diff --git a/engines/asylum/puzzles/hivecontrol.cpp b/engines/asylum/puzzles/hivecontrol.cpp
index 17b83d6210..eda9266be6 100644
--- a/engines/asylum/puzzles/hivecontrol.cpp
+++ b/engines/asylum/puzzles/hivecontrol.cpp
@@ -478,7 +478,7 @@ bool PuzzleHiveControl::hitTest1(Control control, const Common::Point &point, co
if (!frame->getRect().contains(point1))
return false;
else
- return *((byte *)frame->surface.pixels + point1.x + frame->surface.pitch * point1.y) != 0;
+ return *((byte *)frame->surface.getPixels() + point1.x + frame->surface.pitch * point1.y) != 0;
}
} // End of namespace Asylum
diff --git a/engines/asylum/system/cursor.cpp b/engines/asylum/system/cursor.cpp
index 03f425caf4..50a5d1ffb1 100644
--- a/engines/asylum/system/cursor.cpp
+++ b/engines/asylum/system/cursor.cpp
@@ -96,7 +96,7 @@ void Cursor::update() {
Common::Point hotspot = getHotspot(_currentFrame);
GraphicFrame *frame = _cursorRes->getFrame(_currentFrame);
- CursorMan.replaceCursor((byte *)frame->surface.pixels,
+ CursorMan.replaceCursor((byte *)frame->surface.getPixels(),
frame->surface.w,
frame->surface.h,
hotspot.x,
diff --git a/engines/asylum/system/graphics.cpp b/engines/asylum/system/graphics.cpp
index c750890012..e481316995 100644
--- a/engines/asylum/system/graphics.cpp
+++ b/engines/asylum/system/graphics.cpp
@@ -147,7 +147,7 @@ void GraphicResource::init(byte *data, int32 size) {
_frames[i].surface.create(width, height, Graphics::PixelFormat::createFormatCLUT8());
- memcpy(_frames[i].surface.pixels, dataPtr, (size_t)(width * height));
+ memcpy(_frames[i].surface.getPixels(), dataPtr, (size_t)(width * height));
}
}
diff --git a/engines/asylum/system/screen.cpp b/engines/asylum/system/screen.cpp
index 2c1010148a..32fabeb188 100644
--- a/engines/asylum/system/screen.cpp
+++ b/engines/asylum/system/screen.cpp
@@ -212,7 +212,7 @@ void Screen::fillRect(int16 x, int16 y, int16 width, int16 height, uint32 color)
}
void Screen::copyBackBufferToScreen() {
- _vm->_system->copyRectToScreen((byte *)_backBuffer.pixels, _backBuffer.w, 0, 0, _backBuffer.w, _backBuffer.h);
+ _vm->_system->copyRectToScreen((byte *)_backBuffer.getPixels(), _backBuffer.w, 0, 0, _backBuffer.w, _backBuffer.h);
}
void Screen::clip(Common::Rect *source, Common::Rect *destination, int32 flags) const {
@@ -672,9 +672,9 @@ void Screen::addGraphicToQueueCrossfade(ResourceId resourceId, uint32 frameIndex
// Set the color key (always 0)
_useColorKey = true;
- blitCrossfade((byte *)_backBuffer.pixels + dst.top * _backBuffer.pitch + dst.left,
- (byte *)frame->surface.pixels + src.top * frame->surface.pitch + src.left,
- (byte *)frameObject->surface.pixels + (destination.y + dst.top) * frameObject->surface.pitch + (dst.left + destination.x),
+ blitCrossfade((byte *)_backBuffer.getPixels() + dst.top * _backBuffer.pitch + dst.left,
+ (byte *)frame->surface.getPixels() + src.top * frame->surface.pitch + src.left,
+ (byte *)frameObject->surface.getPixels() + (destination.y + dst.top) * frameObject->surface.pitch + (dst.left + destination.x),
dst.height(),
dst.width(),
(uint16)(frame->surface.pitch - dst.width()),
@@ -768,15 +768,15 @@ void Screen::blit(GraphicFrame *frame, Common::Rect *source, Common::Rect *desti
if (hasTransTableIndex) {
if (isMirrored) {
- blitTranstableMirrored((byte *)_backBuffer.pixels + destination->top * _backBuffer.pitch + destination->left,
- (byte *)frame->surface.pixels + source->top * frame->surface.pitch + source->right - 1,
+ blitTranstableMirrored((byte *)_backBuffer.getPixels() + destination->top * _backBuffer.pitch + destination->left,
+ (byte *)frame->surface.getPixels() + source->top * frame->surface.pitch + source->right - 1,
destination->height(),
destination->width(),
(uint16)destination->width() + frame->surface.pitch,
(uint16)(frame->surface.pitch - destination->width()));
} else {
- blitTranstable((byte *)_backBuffer.pixels + destination->top * _backBuffer.pitch + destination->left,
- (byte *)frame->surface.pixels + source->top * frame->surface.pitch + source->left,
+ blitTranstable((byte *)_backBuffer.getPixels() + destination->top * _backBuffer.pitch + destination->left,
+ (byte *)frame->surface.getPixels() + source->top * frame->surface.pitch + source->left,
destination->height(),
destination->width(),
frame->surface.pitch - (uint16)destination->width(),
@@ -785,15 +785,15 @@ void Screen::blit(GraphicFrame *frame, Common::Rect *source, Common::Rect *desti
} else if (flagSet) {
if (isMirrored) {
if (_useColorKey) {
- blitMirroredColorKey((byte *)_backBuffer.pixels + destination->top * _backBuffer.pitch + destination->left,
- (byte *)frame->surface.pixels + source->top * frame->surface.pitch + source->right,
+ blitMirroredColorKey((byte *)_backBuffer.getPixels() + destination->top * _backBuffer.pitch + destination->left,
+ (byte *)frame->surface.getPixels() + source->top * frame->surface.pitch + source->right,
destination->height(),
destination->width(),
frame->surface.pitch + (uint16)destination->width(),
_backBuffer.pitch - (uint16)destination->width());
} else {
- blitMirrored((byte *)_backBuffer.pixels + destination->top * _backBuffer.pitch + destination->left,
- (byte *)frame->surface.pixels + source->top * frame->surface.pitch + source->right,
+ blitMirrored((byte *)_backBuffer.getPixels() + destination->top * _backBuffer.pitch + destination->left,
+ (byte *)frame->surface.getPixels() + source->top * frame->surface.pitch + source->right,
destination->height(),
destination->width(),
frame->surface.pitch + (uint16)destination->width(),
@@ -802,15 +802,15 @@ void Screen::blit(GraphicFrame *frame, Common::Rect *source, Common::Rect *desti
}
} else {
if (_useColorKey) {
- blitRawColorKey((byte *)_backBuffer.pixels + destination->top * _backBuffer.pitch + destination->left,
- (byte *)frame->surface.pixels + source->top * frame->surface.pitch + source->left,
+ blitRawColorKey((byte *)_backBuffer.getPixels() + destination->top * _backBuffer.pitch + destination->left,
+ (byte *)frame->surface.getPixels() + source->top * frame->surface.pitch + source->left,
destination->height(),
destination->width(),
frame->surface.pitch - (uint16)destination->width(),
_backBuffer.pitch - (uint16)destination->width());
} else {
- blitRaw((byte *)_backBuffer.pixels + destination->top * _backBuffer.pitch + destination->left,
- (byte *)frame->surface.pixels + source->top * frame->surface.pitch + source->left,
+ blitRaw((byte *)_backBuffer.getPixels() + destination->top * _backBuffer.pitch + destination->left,
+ (byte *)frame->surface.getPixels() + source->top * frame->surface.pitch + source->left,
destination->height(),
destination->width(),
frame->surface.pitch - (uint16)destination->width(),
@@ -936,7 +936,7 @@ void Screen::blitRawColorKey(byte *dstBuffer, byte *srcBuffer, int16 height, int
}
void Screen::blitMasked(GraphicFrame *frame, Common::Rect *source, byte *maskData, Common::Rect *sourceMask, Common::Rect *destMask, uint16 maskWidth, Common::Rect *destination, int32 flags) {
- byte *frameBuffer = (byte *)frame->surface.pixels;
+ byte *frameBuffer = (byte *)frame->surface.getPixels();
byte *mirroredBuffer = NULL;
int16 frameRight = frame->surface.pitch;
uint16 maskHeight = (uint16)sourceMask->height(); // for debugging only
@@ -972,7 +972,7 @@ void Screen::blitMasked(GraphicFrame *frame, Common::Rect *source, byte *maskDat
|| (destMask->top + sourceMask->height()) < destination->top
|| (destination->top + source->height()) < destMask->top) {
- blitRawColorKey((byte *)_backBuffer.pixels + destination->top * _backBuffer.pitch + destination->left,
+ blitRawColorKey((byte *)_backBuffer.getPixels() + destination->top * _backBuffer.pitch + destination->left,
frameBufferPtr,
source->height(),
source->width(),
@@ -1005,7 +1005,7 @@ void Screen::blitMasked(GraphicFrame *frame, Common::Rect *source, byte *maskDat
//////////////////////////////////////////////////////////////////////////
// Left part
if (destination->left < destMask->left) {
- blitRawColorKey((byte *)_backBuffer.pixels + destination->top * _backBuffer.pitch + destination->left,
+ blitRawColorKey((byte *)_backBuffer.getPixels() + destination->top * _backBuffer.pitch + destination->left,
frameBufferPtr,
source->height(),
destMask->left - destination->left,
@@ -1023,7 +1023,7 @@ void Screen::blitMasked(GraphicFrame *frame, Common::Rect *source, byte *maskDat
//////////////////////////////////////////////////////////////////////////
// Right part
if ((source->width() + destination->left) > (destMask->left + sourceMask->width())) {
- blitRawColorKey((byte *)_backBuffer.pixels + destination->top * _backBuffer.pitch + destMask->left + sourceMask->width(),
+ blitRawColorKey((byte *)_backBuffer.getPixels() + destination->top * _backBuffer.pitch + destMask->left + sourceMask->width(),
frameBufferPtr + destMask->left + sourceMask->width() - destination->left,
source->height(),
source->width() + destination->left - (destMask->left + sourceMask->width()),
@@ -1039,7 +1039,7 @@ void Screen::blitMasked(GraphicFrame *frame, Common::Rect *source, byte *maskDat
//////////////////////////////////////////////////////////////////////////
// Top part
if (destination->top < destMask->top) {
- blitRawColorKey((byte *)_backBuffer.pixels + destination->top * _backBuffer.pitch + destination->left,
+ blitRawColorKey((byte *)_backBuffer.getPixels() + destination->top * _backBuffer.pitch + destination->left,
frameBufferPtr,
destMask->top - destination->top,
source->width(),
@@ -1057,7 +1057,7 @@ void Screen::blitMasked(GraphicFrame *frame, Common::Rect *source, byte *maskDat
//////////////////////////////////////////////////////////////////////////
// Bottom part
if ((source->height() + destination->top) > (destMask->top + sourceMask->height())) {
- blitRawColorKey((byte *)_backBuffer.pixels + (destMask->top + sourceMask->height()) * _backBuffer.pitch + destination->left,
+ blitRawColorKey((byte *)_backBuffer.getPixels() + (destMask->top + sourceMask->height()) * _backBuffer.pitch + destination->left,
frameBufferPtr + (destMask->top + sourceMask->height() - destination->top) * frameRight,
destination->top + source->height() - (sourceMask->height() + destMask->top),
source->width(),
@@ -1076,7 +1076,7 @@ void Screen::blitMasked(GraphicFrame *frame, Common::Rect *source, byte *maskDat
(uint16)(frameRight - source->width()),
(uint16)(maskWidth - (zoom + source->width())) / 8,
zoom,
- (byte *)_backBuffer.pixels + _backBuffer.pitch * destination->top + destination->left,
+ (byte *)_backBuffer.getPixels() + _backBuffer.pitch * destination->top + destination->left,
(uint16)(_backBuffer.pitch - source->width()));
// Draw debug rects
@@ -1093,7 +1093,7 @@ void Screen::blitMasked(GraphicFrame *frame, Common::Rect *source, byte *maskDat
void Screen::drawZoomedMask(byte *mask, uint16 height, uint16 width, uint16 maskPitch) {
uint16 zoom = 7;
- byte *dstBuffer = (byte *)_backBuffer.pixels;
+ byte *dstBuffer = (byte *)_backBuffer.getPixels();
uint16 dstPitch = (uint16)(_backBuffer.pitch - (width * zoom));
uint16 srcPitch = maskPitch;
byte *srcBuffer = mask;
@@ -1154,7 +1154,7 @@ void Screen::bltMasked(byte *srcBuffer, byte *maskBuffer, int16 height, int16 wi
void Screen::blt(Common::Rect *dest, GraphicFrame* frame, Common::Rect *source, int32 flags) {
if (_useColorKey) {
- copyToBackBufferWithTransparency((byte *)frame->surface.pixels + (source->top * frame->surface.w + source->left),
+ copyToBackBufferWithTransparency((byte *)frame->surface.getPixels() + (source->top * frame->surface.w + source->left),
frame->surface.w,
dest->left,
dest->top,
@@ -1162,7 +1162,7 @@ void Screen::blt(Common::Rect *dest, GraphicFrame* frame, Common::Rect *source,
(uint16)source->height(),
(bool)(flags & kDrawFlagMirrorLeftRight));
} else {
- copyToBackBuffer((byte *)frame->surface.pixels + (source->top * frame->surface.w + source->left),
+ copyToBackBuffer((byte *)frame->surface.getPixels() + (source->top * frame->surface.w + source->left),
frame->surface.w,
dest->left,
dest->top,
@@ -1174,14 +1174,14 @@ void Screen::blt(Common::Rect *dest, GraphicFrame* frame, Common::Rect *source,
void Screen::bltFast(int16 dX, int16 dY, GraphicFrame* frame, Common::Rect *source) {
if (_useColorKey) {
- copyToBackBufferWithTransparency((byte *)frame->surface.pixels + (source->top * frame->surface.w + source->left),
+ copyToBackBufferWithTransparency((byte *)frame->surface.getPixels() + (source->top * frame->surface.w + source->left),
frame->surface.w,
dX,
dY,
(uint16)source->width(),
(uint16)source->height());
} else {
- copyToBackBuffer((byte *)frame->surface.pixels + (source->top * frame->surface.w + source->left),
+ copyToBackBuffer((byte *)frame->surface.getPixels() + (source->top * frame->surface.w + source->left),
frame->surface.w,
dX,
dY,
@@ -1191,7 +1191,7 @@ void Screen::bltFast(int16 dX, int16 dY, GraphicFrame* frame, Common::Rect *sour
}
void Screen::copyToBackBuffer(byte *buffer, int32 pitch, int16 x, int16 y, uint16 width, uint16 height, bool mirrored) {
- byte *dest = (byte *)_backBuffer.pixels;
+ byte *dest = (byte *)_backBuffer.getPixels();
if (!mirrored) {
while (height--) {
@@ -1205,7 +1205,7 @@ void Screen::copyToBackBuffer(byte *buffer, int32 pitch, int16 x, int16 y, uint1
}
void Screen::copyToBackBufferWithTransparency(byte *buffer, int32 pitch, int16 x, int16 y, uint16 width, uint16 height, bool mirrored) {
- byte *dest = (byte *)_backBuffer.pixels;
+ byte *dest = (byte *)_backBuffer.getPixels();
int32 left = (x < 0) ? -x : 0;
int32 top = (y < 0) ? -y : 0;
@@ -1251,7 +1251,7 @@ void Screen::copyToBackBufferClipped(Graphics::Surface *surface, int16 x, int16
startY = getWorld()->yTop;
_vm->screen()->copyToBackBufferWithTransparency(
- ((byte*)surface->pixels) +
+ ((byte*)surface->getPixels()) +
startY * surface->pitch +
startX * surface->format.bytesPerPixel,
surface->pitch,
diff --git a/engines/asylum/views/video.cpp b/engines/asylum/views/video.cpp
index 81105a00d2..99129d4ea6 100644
--- a/engines/asylum/views/video.cpp
+++ b/engines/asylum/views/video.cpp
@@ -164,7 +164,7 @@ void VideoPlayer::play(Common::String filename, bool showSubtitles) {
if (_smkDecoder->hasDirtyPalette())
setupPalette();
- getScreen()->copyToBackBuffer((byte *)frame->pixels, frame->pitch, x, y, frame->w, frame->h);
+ getScreen()->copyToBackBuffer((byte *)frame->getPixels(), frame->pitch, x, y, frame->w, frame->h);
if (showSubtitles) {
int32 currentFrame = _smkDecoder->getCurFrame() + 1;
Commit: c92af6b25f867207be22c8c0faac86df1ccbf120
https://github.com/scummvm/scummvm/commit/c92af6b25f867207be22c8c0faac86df1ccbf120
Author: Alex Bevilacqua (alex at alexbevi.com)
Date: 2021-05-17T15:37:27+02:00
Commit Message:
ASYLUM: update engine to new build system
Changed paths:
A engines/asylum/configure.engine
diff --git a/engines/asylum/configure.engine b/engines/asylum/configure.engine
new file mode 100644
index 0000000000..e16ef5afdf
--- /dev/null
+++ b/engines/asylum/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 asylum "Sanitarium" no
Commit: 652e134c4698a5a5bbe6e46f17fec957748b02f9
https://github.com/scummvm/scummvm/commit/652e134c4698a5a5bbe6e46f17fec957748b02f9
Author: Alex Bevilacqua (alex at alexbevi.com)
Date: 2021-05-17T15:37:27+02:00
Commit Message:
ASYLUM: fix compilation
Changed paths:
engines/asylum/console.cpp
diff --git a/engines/asylum/console.cpp b/engines/asylum/console.cpp
index 4d5c0b7587..2c3dacc9af 100644
--- a/engines/asylum/console.cpp
+++ b/engines/asylum/console.cpp
@@ -157,36 +157,36 @@ static const struct EncounterData {
Console::Console(AsylumEngine *engine) : _vm(engine) {
- // Commands
- DCmd_Register("help", WRAP_METHOD(Console, cmdHelp));
-
- DCmd_Register("ls", WRAP_METHOD(Console, cmdListFiles));
-
- DCmd_Register("actions", WRAP_METHOD(Console, cmdListActions));
- DCmd_Register("actors", WRAP_METHOD(Console, cmdListActors));
- DCmd_Register("flags", WRAP_METHOD(Console, cmdListFlags));
- DCmd_Register("object", WRAP_METHOD(Console, cmdShowObject));
- DCmd_Register("objects", WRAP_METHOD(Console, cmdListObjects));
- DCmd_Register("world", WRAP_METHOD(Console, cmdShowWorldStats));
-
- DCmd_Register("video", WRAP_METHOD(Console, cmdPlayVideo));
- DCmd_Register("script", WRAP_METHOD(Console, cmdRunScript));
- DCmd_Register("scene", WRAP_METHOD(Console, cmdChangeScene));
- DCmd_Register("encounter", WRAP_METHOD(Console, cmdRunEncounter));
- DCmd_Register("puzzle", WRAP_METHOD(Console, cmdRunPuzzle));
-
- DCmd_Register("palette", WRAP_METHOD(Console, cmdSetPalette));
- DCmd_Register("draw", WRAP_METHOD(Console, cmdDrawResource));
-
- DCmd_Register("toggle_flag", WRAP_METHOD(Console, cmdToggleFlag));
-
- // Variables
- DVar_Register("show_actors", &g_debugActors, DVAR_INT, 0);
- DVar_Register("show_drawrects", &g_debugDrawRects, DVAR_INT, 0);
- DVar_Register("show_objects", &g_debugObjects, DVAR_INT, 0);
- DVar_Register("show_polygons", &g_debugPolygons, DVAR_INT, 0);
- DVar_Register("show_scenerects", &g_debugSceneRects, DVAR_INT, 0);
- DVar_Register("use_scrolling", &g_debugScrolling, DVAR_INT, 0);
+ // Commands
+ registerCmd("help", WRAP_METHOD(Console, cmdHelp));
+
+ registerCmd("ls", WRAP_METHOD(Console, cmdListFiles));
+
+ registerCmd("actions", WRAP_METHOD(Console, cmdListActions));
+ registerCmd("actors", WRAP_METHOD(Console, cmdListActors));
+ registerCmd("flags", WRAP_METHOD(Console, cmdListFlags));
+ registerCmd("object", WRAP_METHOD(Console, cmdShowObject));
+ registerCmd("objects", WRAP_METHOD(Console, cmdListObjects));
+ registerCmd("world", WRAP_METHOD(Console, cmdShowWorldStats));
+
+ registerCmd("video", WRAP_METHOD(Console, cmdPlayVideo));
+ registerCmd("script", WRAP_METHOD(Console, cmdRunScript));
+ registerCmd("scene", WRAP_METHOD(Console, cmdChangeScene));
+ registerCmd("encounter", WRAP_METHOD(Console, cmdRunEncounter));
+ registerCmd("puzzle", WRAP_METHOD(Console, cmdRunPuzzle));
+
+ registerCmd("palette", WRAP_METHOD(Console, cmdSetPalette));
+ registerCmd("draw", WRAP_METHOD(Console, cmdDrawResource));
+
+ registerCmd("toggle_flag", WRAP_METHOD(Console, cmdToggleFlag));
+
+ // Variables
+ registerVar("show_actors", &g_debugActors);
+ registerVar("show_drawrects", &g_debugDrawRects);
+ registerVar("show_objects", &g_debugObjects);
+ registerVar("show_polygons", &g_debugPolygons);
+ registerVar("show_scenerects", &g_debugSceneRects);
+ registerVar("use_scrolling", &g_debugScrolling);
}
Console::~Console() {
@@ -200,41 +200,41 @@ Console::~Console() {
// Help
//////////////////////////////////////////////////////////////////////////
bool Console::cmdHelp(int, const char **) {
- DebugPrintf("Debug flags\n");
- DebugPrintf("-----------\n");
- DebugPrintf(" debugflag_list - Lists the available debug flags and their status\n");
- DebugPrintf(" debugflag_enable - Enables a debug flag\n");
- DebugPrintf(" debugflag_disable - Disables a debug flag\n");
- DebugPrintf(" show_actors - Show actors\n");
- DebugPrintf(" show_objects - Show objects\n");
- DebugPrintf(" show_polygons - Show polygons\n");
- DebugPrintf(" show_drawrects - Show drawing rects\n");;
- DebugPrintf(" use_scrolling - Use scrolling\n");
- DebugPrintf("\n");
- DebugPrintf("Commands\n");
- DebugPrintf("--------\n");
- DebugPrintf(" ls - list engine files\n");
- DebugPrintf("\n");
- DebugPrintf(" actors - show actors information\n");
- DebugPrintf(" actions - show action information\n");
- DebugPrintf(" flags - show flags\n");
- DebugPrintf(" object - inspect a particular object\n");
- DebugPrintf(" objects - show objects information\n");
- DebugPrintf(" world - show worldstats\n");
- DebugPrintf("\n");
- DebugPrintf(" video - play a video\n");
- DebugPrintf(" script - run a script\n");
- DebugPrintf(" scene - change the scene\n");
- DebugPrintf(" encounter - run an encounter\n");
- DebugPrintf(" puzzle - run an puzzle\n");
- DebugPrintf("\n");
- DebugPrintf(" palette - set the screen palette\n");
- DebugPrintf(" draw - draw a resource\n");
- DebugPrintf("\n");
- DebugPrintf(" toggle_flag - toggle a flag\n");
- DebugPrintf("\n");
-
- return true;
+ debugPrintf("Debug flags\n");
+ debugPrintf("-----------\n");
+ debugPrintf(" debugflag_list - Lists the available debug flags and their status\n");
+ debugPrintf(" debugflag_enable - Enables a debug flag\n");
+ debugPrintf(" debugflag_disable - Disables a debug flag\n");
+ debugPrintf(" show_actors - Show actors\n");
+ debugPrintf(" show_objects - Show objects\n");
+ debugPrintf(" show_polygons - Show polygons\n");
+ debugPrintf(" show_drawrects - Show drawing rects\n");;
+ debugPrintf(" use_scrolling - Use scrolling\n");
+ debugPrintf("\n");
+ debugPrintf("Commands\n");
+ debugPrintf("--------\n");
+ debugPrintf(" ls - list engine files\n");
+ debugPrintf("\n");
+ debugPrintf(" actors - show actors information\n");
+ debugPrintf(" actions - show action information\n");
+ debugPrintf(" flags - show flags\n");
+ debugPrintf(" object - inspect a particular object\n");
+ debugPrintf(" objects - show objects information\n");
+ debugPrintf(" world - show worldstats\n");
+ debugPrintf("\n");
+ debugPrintf(" video - play a video\n");
+ debugPrintf(" script - run a script\n");
+ debugPrintf(" scene - change the scene\n");
+ debugPrintf(" encounter - run an encounter\n");
+ debugPrintf(" puzzle - run an puzzle\n");
+ debugPrintf("\n");
+ debugPrintf(" palette - set the screen palette\n");
+ debugPrintf(" draw - draw a resource\n");
+ debugPrintf("\n");
+ debugPrintf(" toggle_flag - toggle a flag\n");
+ debugPrintf("\n");
+
+ return true;
}
//////////////////////////////////////////////////////////////////////////
@@ -242,7 +242,7 @@ bool Console::cmdHelp(int, const char **) {
//////////////////////////////////////////////////////////////////////////
bool Console::cmdListFiles(int argc, const char **argv) {
if (argc != 2) {
- DebugPrintf("Syntax: %s <filter> (use * for all)\n", argv[0]);
+ debugPrintf("Syntax: %s <filter> (use * for all)\n", argv[0]);
return true;
}
@@ -251,38 +251,38 @@ bool Console::cmdListFiles(int argc, const char **argv) {
Common::ArchiveMemberList list;
int count = SearchMan.listMatchingMembers(list, filter);
- DebugPrintf("Number of matches: %d\n", count);
+ debugPrintf("Number of matches: %d\n", count);
for (Common::ArchiveMemberList::iterator it = list.begin(); it != list.end(); ++it)
- DebugPrintf(" %s\n", (*it)->getName().c_str());
+ debugPrintf(" %s\n", (*it)->getName().c_str());
return true;
}
bool Console::cmdListActions(int32 argc, const char **argv) {
if (argc != 1 && argc != 2) {
- DebugPrintf("Syntax: %s <index> (use nothing for all)\n", argv[0]);
+ debugPrintf("Syntax: %s <index> (use nothing for all)\n", argv[0]);
return true;
}
if (argc == 1) {
for (uint32 i = 0; i < getWorld()->actions.size(); i++)
- DebugPrintf("%s\n", getWorld()->actions[i]->toString().c_str());
+ debugPrintf("%s\n", getWorld()->actions[i]->toString().c_str());
} else {
int index = atoi(argv[1]);
int maxIndex = getWorld()->actions.size() - 1;
if (maxIndex == -1) {
- DebugPrintf("[error] No actions are present!\n");
+ debugPrintf("[error] No actions are present!\n");
return true;
}
if (index < 0 || index > maxIndex) {
- DebugPrintf("[error] index should be between 0 and %d\n", maxIndex);
+ debugPrintf("[error] index should be between 0 and %d\n", maxIndex);
return true;
}
- DebugPrintf("%s\n", getWorld()->actions[index]->toString().c_str());
+ debugPrintf("%s\n", getWorld()->actions[index]->toString().c_str());
}
return true;
@@ -290,25 +290,25 @@ bool Console::cmdListActions(int32 argc, const char **argv) {
bool Console::cmdListActors(int32 argc, const char **argv) {
if (argc != 1 && argc != 2 && argc != 4) {
- DebugPrintf("Syntax: %s <index> (use nothing for all) (<x>, <y>)\n", argv[0]);
+ debugPrintf("Syntax: %s <index> (use nothing for all) (<x>, <y>)\n", argv[0]);
return true;
}
if (argc == 1) {
for (uint32 i = 0; i < getWorld()->actors.size(); i++)
- DebugPrintf("%s\n", getWorld()->actors[i]->toString().c_str());
+ debugPrintf("%s\n", getWorld()->actors[i]->toString().c_str());
} else if (argc == 2 || argc == 4) {
int index = atoi(argv[1]);
int maxIndex = getWorld()->actors.size() - 1;
if (index < 0 || index > maxIndex) {
- DebugPrintf("[error] index should be between 0 and %d\n", maxIndex);
+ debugPrintf("[error] index should be between 0 and %d\n", maxIndex);
return true;
}
if (argc == 2) {
- DebugPrintf("%s\n", getWorld()->actors[index]->toString(false).c_str());
+ debugPrintf("%s\n", getWorld()->actors[index]->toString(false).c_str());
return true;
}
@@ -326,24 +326,24 @@ bool Console::cmdListActors(int32 argc, const char **argv) {
bool Console::cmdListFlags(int32 argc, const char **argv) {
if (argc != 1 && argc != 2) {
- DebugPrintf("Syntax: %s <type> (nothing: all - 1: show set flags - 0: show unset flags)\n", argv[0]);
+ debugPrintf("Syntax: %s <type> (nothing: all - 1: show set flags - 0: show unset flags)\n", argv[0]);
return true;
}
// Show all flags
if (argc == 1) {
for (int32 i = 0; i < 1512; i++) {
- DebugPrintf("%04d: %d ", i, _vm->isGameFlagSet((GameFlag)i));
+ debugPrintf("%04d: %d ", i, _vm->isGameFlagSet((GameFlag)i));
if ((i + 1) % 10 == 0)
- DebugPrintf("\n");
+ debugPrintf("\n");
}
- DebugPrintf("\n");
+ debugPrintf("\n");
} else {
int32 type = atoi(argv[1]);
if (type != 0 && type != 1) {
- DebugPrintf("Syntax: %s <type> (nothing: all - 1: show set flags - 0: show unset flags)\n", argv[0]);
+ debugPrintf("Syntax: %s <type> (nothing: all - 1: show set flags - 0: show unset flags)\n", argv[0]);
return true;
}
@@ -351,30 +351,30 @@ bool Console::cmdListFlags(int32 argc, const char **argv) {
int count = 0;
for (int32 i = 0; i < 1512; i++) {
if (_vm->isGameFlagSet((GameFlag)i) == (bool)type) {
- DebugPrintf("%04d: %d ", i, _vm->isGameFlagSet((GameFlag)i));
+ debugPrintf("%04d: %d ", i, _vm->isGameFlagSet((GameFlag)i));
++count;
}
if ((count + 1) % 10 == 0)
- DebugPrintf("\n");
+ debugPrintf("\n");
}
- DebugPrintf("\n\n%s flags: %d\n", (type ? "Set" : "Unset"), count);
+ debugPrintf("\n\n%s flags: %d\n", (type ? "Set" : "Unset"), count);
}
return true;
}
bool Console::cmdShowWorldStats(int32, const char **) {
- DebugPrintf("WorldStats\n");
- DebugPrintf("----------\n");
- DebugPrintf("%s", getWorld()->toString().c_str());
+ debugPrintf("WorldStats\n");
+ debugPrintf("----------\n");
+ debugPrintf("%s", getWorld()->toString().c_str());
return true;
}
bool Console::cmdShowObject(int32 argc, const char **argv) {
if (argc != 3) {
- DebugPrintf("Syntax: %s [id|idx] <target>\n", argv[0]);
+ debugPrintf("Syntax: %s [id|idx] <target>\n", argv[0]);
return true;
}
@@ -382,24 +382,24 @@ bool Console::cmdShowObject(int32 argc, const char **argv) {
int id = atoi(argv[2]);
for (uint32 i = 0; i < getWorld()->objects.size(); i++) {
if (getWorld()->objects[i]->getId() == id) {
- DebugPrintf("%s", getWorld()->objects[i]->toString(false).c_str());
+ debugPrintf("%s", getWorld()->objects[i]->toString(false).c_str());
return true;
}
}
- DebugPrintf("No object with id %d found\n", id);
+ debugPrintf("No object with id %d found\n", id);
} else if (Common::String(argv[1]) == "idx") {
int index = atoi(argv[2]);
int maxIndex = getWorld()->objects.size() - 1;
if (index < 0 || index > maxIndex) {
- DebugPrintf("[error] index should be between 0 and %d\n", maxIndex);
+ debugPrintf("[error] index should be between 0 and %d\n", maxIndex);
return true;
}
- DebugPrintf("%s", getWorld()->objects[index]->toString(false).c_str());
+ debugPrintf("%s", getWorld()->objects[index]->toString(false).c_str());
} else {
- DebugPrintf("[error] valid options are 'id' and 'idx'\n");
+ debugPrintf("[error] valid options are 'id' and 'idx'\n");
}
return true;
@@ -407,7 +407,7 @@ bool Console::cmdShowObject(int32 argc, const char **argv) {
bool Console::cmdListObjects(int32 argc, const char **argv) {
if (argc != 2) {
- DebugPrintf("Syntax: %s [onscreen|*]\n", argv[0]);
+ debugPrintf("Syntax: %s [onscreen|*]\n", argv[0]);
return true;
}
@@ -415,20 +415,20 @@ bool Console::cmdListObjects(int32 argc, const char **argv) {
if (Common::String(argv[1]) == "onscreen") {
for (uint32 i = 0; i < getWorld()->objects.size(); i++) {
if (getWorld()->objects[i]->isOnScreen()) {
- DebugPrintf("%s", getWorld()->objects[i]->toString().c_str());
+ debugPrintf("%s", getWorld()->objects[i]->toString().c_str());
}
}
- DebugPrintf("Total: %d\n", getWorld()->objects.size());
+ debugPrintf("Total: %d\n", getWorld()->objects.size());
} else if (Common::String(argv[1]) == "*"){
for (uint32 i = 0; i < getWorld()->objects.size(); i++)
- DebugPrintf("%s", getWorld()->objects[i]->toString().c_str());
+ debugPrintf("%s", getWorld()->objects[i]->toString().c_str());
- DebugPrintf("Total: %d\n", getWorld()->objects.size());
+ debugPrintf("Total: %d\n", getWorld()->objects.size());
} else {
- DebugPrintf("[error] valid options are 'onscreen' and '*'\n");
+ debugPrintf("[error] valid options are 'onscreen' and '*'\n");
}
}
@@ -440,7 +440,7 @@ bool Console::cmdListObjects(int32 argc, const char **argv) {
//////////////////////////////////////////////////////////////////////////
bool Console::cmdPlayVideo(int32 argc, const char **argv) {
if (argc != 2) {
- DebugPrintf("Syntax: %s <video number>\n", argv[0]);
+ debugPrintf("Syntax: %s <video number>\n", argv[0]);
return true;
}
@@ -450,7 +450,7 @@ bool Console::cmdPlayVideo(int32 argc, const char **argv) {
char filename[20];
sprintf(filename, "mov%03d.smk", index);
if (!SearchMan.hasFile(filename)) {
- DebugPrintf("[Error] Movie %d does not exists\n", index);
+ debugPrintf("[Error] Movie %d does not exists\n", index);
return true;
}
@@ -461,7 +461,7 @@ bool Console::cmdPlayVideo(int32 argc, const char **argv) {
bool Console::cmdRunScript(int32 argc, const char **argv) {
if (argc != 3) {
- DebugPrintf("Syntax: %s <script index> <actor index>\n", argv[0]);
+ debugPrintf("Syntax: %s <script index> <actor index>\n", argv[0]);
return true;
}
@@ -470,12 +470,12 @@ bool Console::cmdRunScript(int32 argc, const char **argv) {
// Check parameters
if (index < 0 || index >= (int32)getScript()->_scripts.size()) {
- DebugPrintf("[Error] Invalid index (was: %d - valid: [0-%d])\n", index, _vm->encounter()->items()->size() - 1);
+ debugPrintf("[Error] Invalid index (was: %d - valid: [0-%d])\n", index, _vm->encounter()->items()->size() - 1);
return true;
}
if (actor < 0 || actor >= (int32)getWorld()->actors.size()) {
- DebugPrintf("[Error] Invalid actor index (was: %d - valid: [0-%d])\n", actor, getWorld()->actors.size() - 1);
+ debugPrintf("[Error] Invalid actor index (was: %d - valid: [0-%d])\n", actor, getWorld()->actors.size() - 1);
}
getScript()->queueScript(index, actor);
@@ -485,7 +485,7 @@ bool Console::cmdRunScript(int32 argc, const char **argv) {
bool Console::cmdChangeScene(int32 argc, const char **argv) {
if (argc != 2) {
- DebugPrintf("Syntax: %s <scene number>\n", argv[0]);
+ debugPrintf("Syntax: %s <scene number>\n", argv[0]);
return true;
}
@@ -495,7 +495,7 @@ bool Console::cmdChangeScene(int32 argc, const char **argv) {
char filename[20];
sprintf(filename, "scn.%03d", index);
if (!SearchMan.hasFile(filename)) {
- DebugPrintf("[Error] Scene %d does not exists\n", index);
+ debugPrintf("[Error] Scene %d does not exists\n", index);
return true;
}
@@ -506,20 +506,20 @@ bool Console::cmdChangeScene(int32 argc, const char **argv) {
bool Console::cmdRunEncounter(int32 argc, const char **argv) {
if (argc != 2) {
- DebugPrintf("Syntax: %s <encounter index>\n", argv[0]);
+ debugPrintf("Syntax: %s <encounter index>\n", argv[0]);
return true;
}
// Check that we are inside a scene
if (!getScene()) {
- DebugPrintf("[Error] Cannot run an encounter outside of a scene\n");
+ debugPrintf("[Error] Cannot run an encounter outside of a scene\n");
return true;
}
// Check index is valid
int32 index = atoi(argv[1]);
if (index < 0 || index >= (int32)_vm->encounter()->_items.size()) {
- DebugPrintf("[Error] Invalid index (was: %d - valid: [0-%d])\n", index, _vm->encounter()->_items.size() - 1);
+ debugPrintf("[Error] Invalid index (was: %d - valid: [0-%d])\n", index, _vm->encounter()->_items.size() - 1);
return true;
}
@@ -531,7 +531,7 @@ bool Console::cmdRunEncounter(int32 argc, const char **argv) {
}
if (data->index == -1) {
- DebugPrintf("[Error] No encounter data for this index (index: %d)\n", index);
+ debugPrintf("[Error] No encounter data for this index (index: %d)\n", index);
return true;
}
@@ -545,24 +545,24 @@ bool Console::cmdRunEncounter(int32 argc, const char **argv) {
bool Console::cmdRunPuzzle(int32 argc, const char **argv) {
if (argc != 2) {
- DebugPrintf("Syntax: %s <puzzle index>\n", argv[0]);
- DebugPrintf(" 0 VCR\n");
- DebugPrintf(" 1 Pipes\n");
- DebugPrintf(" 2 TicTacToe\n");
- DebugPrintf(" 3 Lock\n");
- DebugPrintf(" 4 N/A\n");
- DebugPrintf(" 5 Wheel\n");
- DebugPrintf(" 6 BoardSalvation\n");
- DebugPrintf(" 7 BoardYouth\n");
- DebugPrintf(" 8 BoardKeyHidesTo\n");
- DebugPrintf(" 9 Writings\n");
- DebugPrintf(" 10 Unknown\n");
- DebugPrintf(" 11 MorgueDoor\n");
- DebugPrintf(" 12 Clock\n");
- DebugPrintf(" 13 TimerMachine\n");
- DebugPrintf(" 14 Fisherman\n");
- DebugPrintf(" 15 HiveMachine\n");
- DebugPrintf(" 16 HiveControl\n");
+ debugPrintf("Syntax: %s <puzzle index>\n", argv[0]);
+ debugPrintf(" 0 VCR\n");
+ debugPrintf(" 1 Pipes\n");
+ debugPrintf(" 2 TicTacToe\n");
+ debugPrintf(" 3 Lock\n");
+ debugPrintf(" 4 N/A\n");
+ debugPrintf(" 5 Wheel\n");
+ debugPrintf(" 6 BoardSalvation\n");
+ debugPrintf(" 7 BoardYouth\n");
+ debugPrintf(" 8 BoardKeyHidesTo\n");
+ debugPrintf(" 9 Writings\n");
+ debugPrintf(" 10 Unknown\n");
+ debugPrintf(" 11 MorgueDoor\n");
+ debugPrintf(" 12 Clock\n");
+ debugPrintf(" 13 TimerMachine\n");
+ debugPrintf(" 14 Fisherman\n");
+ debugPrintf(" 15 HiveMachine\n");
+ debugPrintf(" 16 HiveControl\n");
return true;
}
@@ -570,13 +570,13 @@ bool Console::cmdRunPuzzle(int32 argc, const char **argv) {
// Check index is valid
if (index < 0 || index >= ARRAYSIZE(puzzleToScenes)) {
- DebugPrintf("[Error] Invalid index (was: %d - valid: [0-%d])\n", index, ARRAYSIZE(_vm->_puzzles->_puzzles));
+ debugPrintf("[Error] Invalid index (was: %d - valid: [0-%d])\n", index, ARRAYSIZE(_vm->_puzzles->_puzzles));
return true;
}
EventHandler *puzzle = getPuzzles()->getPuzzle((uint32)index);
if (puzzle == NULL) {
- DebugPrintf("[Error] This puzzle does not exists (%d)", index);
+ debugPrintf("[Error] This puzzle does not exists (%d)", index);
return true;
}
@@ -597,7 +597,7 @@ bool Console::cmdRunPuzzle(int32 argc, const char **argv) {
bool Console::cmdSetPalette(int32 argc, const char **argv) {
if (argc != 3) {
- DebugPrintf("Syntax: %s <pack> <index>\n", argv[0]);
+ debugPrintf("Syntax: %s <pack> <index>\n", argv[0]);
return true;
}
@@ -606,13 +606,13 @@ bool Console::cmdSetPalette(int32 argc, const char **argv) {
// Check resource pack
if (pack < 0 || pack > 18) {
- DebugPrintf("[Error] Invalid resource pack (was: %d - valid: [0-18])\n", pack);
+ debugPrintf("[Error] Invalid resource pack (was: %d - valid: [0-18])\n", pack);
return true;
}
// Check index
if (index < 0) {
- DebugPrintf("[Error] Invalid index (was: %d - valid: > 0)\n", index);
+ debugPrintf("[Error] Invalid index (was: %d - valid: > 0)\n", index);
return true;
}
@@ -621,7 +621,7 @@ bool Console::cmdSetPalette(int32 argc, const char **argv) {
ResourceEntry *entry = getResource()->get(id);
if (!entry) {
- DebugPrintf("[Error] Invalid resource (0x%X)\n", id);
+ debugPrintf("[Error] Invalid resource (0x%X)\n", id);
return true;
}
@@ -632,7 +632,7 @@ bool Console::cmdSetPalette(int32 argc, const char **argv) {
bool Console::cmdDrawResource(int32 argc, const char **argv) {
if (argc != 3 && argc != 4) {
- DebugPrintf("Syntax: %s <pack> <index> (<frame>)\n", argv[0]);
+ debugPrintf("Syntax: %s <pack> <index> (<frame>)\n", argv[0]);
return true;
}
@@ -645,13 +645,13 @@ bool Console::cmdDrawResource(int32 argc, const char **argv) {
// Check resource pack
if (pack < 0 || pack > 18) {
- DebugPrintf("[Error] Invalid resource pack (was: %d - valid: [0-18])\n", pack);
+ debugPrintf("[Error] Invalid resource pack (was: %d - valid: [0-18])\n", pack);
return true;
}
// Check index
if (index < 0) {
- DebugPrintf("[Error] Invalid index (was: %d - valid: > 0)\n", index);
+ debugPrintf("[Error] Invalid index (was: %d - valid: > 0)\n", index);
return true;
}
@@ -660,13 +660,13 @@ bool Console::cmdDrawResource(int32 argc, const char **argv) {
// Try loading resource
GraphicResource *resource = new GraphicResource(_vm);
if (!resource->load(resourceId)) {
- DebugPrintf("[Error] Invalid resource index (was: %d)\n", index);
+ debugPrintf("[Error] Invalid resource index (was: %d)\n", index);
delete resource;
return true;
}
if (frame < 0 || frame >= (int32)resource->count()) {
- DebugPrintf("[Error] Invalid resource frame index (was: %d , max: %d)\n", frame, resource->count() - 1);
+ debugPrintf("[Error] Invalid resource frame index (was: %d , max: %d)\n", frame, resource->count() - 1);
delete resource;
return true;
}
@@ -692,12 +692,12 @@ bool Console::cmdDrawResource(int32 argc, const char **argv) {
//////////////////////////////////////////////////////////////////////////
bool Console::cmdToggleFlag(int32 argc, const char **argv) {
if (argc != 2 || atoi(argv[1]) > 1512 || atoi(argv[1]) < 0) {
- DebugPrintf("Syntax: <value> between 0 and 1512\n");
+ debugPrintf("Syntax: <value> between 0 and 1512\n");
return true;
}
_vm->toggleGameFlag((GameFlag)atoi(argv[1]));
- DebugPrintf("Flag %d == %d\n", atoi(argv[1]), _vm->isGameFlagSet((GameFlag)atoi(argv[1])));
+ debugPrintf("Flag %d == %d\n", atoi(argv[1]), _vm->isGameFlagSet((GameFlag)atoi(argv[1])));
return true;
}
Commit: 926443d63f8869b4235b27ec61e74f6134162e91
https://github.com/scummvm/scummvm/commit/926443d63f8869b4235b27ec61e74f6134162e91
Author: Alex Bevilacqua (alex at alexbevi.com)
Date: 2021-05-17T15:37:28+02:00
Commit Message:
ASYLUM: fixed smacker video playing and added new debug level
Changed paths:
engines/asylum/console.h
engines/asylum/views/video.cpp
diff --git a/engines/asylum/console.h b/engines/asylum/console.h
index d20a1c10aa..d6dadce8cf 100644
--- a/engines/asylum/console.h
+++ b/engines/asylum/console.h
@@ -41,7 +41,8 @@ enum kDebugLevels {
kDebugLevelScene = 1 << 8,
kDebugLevelObjects = 1 << 9,
kDebugLevelActor = 1 << 10,
- kDebugLevelEncounter = 1 << 11
+ kDebugLevelEncounter = 1 << 11,
+ kDebugLevelVideo = 1 << 12
};
class AsylumEngine;
diff --git a/engines/asylum/views/video.cpp b/engines/asylum/views/video.cpp
index 99129d4ea6..f62cb34484 100644
--- a/engines/asylum/views/video.cpp
+++ b/engines/asylum/views/video.cpp
@@ -152,6 +152,8 @@ void VideoPlayer::play(Common::String filename, bool showSubtitles) {
int32 frameEnd = 0;
int32 currentSubtitle = 0;
+ _smkDecoder->start();
+
while (!_done && !Engine::shouldQuit() && !_smkDecoder->endOfVideo()) {
_vm->handleEvents();
@@ -168,7 +170,7 @@ void VideoPlayer::play(Common::String filename, bool showSubtitles) {
if (showSubtitles) {
int32 currentFrame = _smkDecoder->getCurFrame() + 1;
-
+ debugC(kDebugLevelVideo, "[Video] {%s} Playing Frame %d", filename.c_str(), currentFrame);
// Check for next frame
if (currentFrame > frameEnd) {
if (index < _subtitles.size()) {
Commit: 34214332e9ce97f75e4b21aa3178809896c8cb1d
https://github.com/scummvm/scummvm/commit/34214332e9ce97f75e4b21aa3178809896c8cb1d
Author: Alex Bevilacqua (alex at alexbevi.com)
Date: 2021-05-17T15:37:28+02:00
Commit Message:
ASYLUM: more script debug output
Changed paths:
engines/asylum/resources/script.cpp
engines/asylum/views/scene.cpp
diff --git a/engines/asylum/resources/script.cpp b/engines/asylum/resources/script.cpp
index f1785c0256..9daa7ae010 100644
--- a/engines/asylum/resources/script.cpp
+++ b/engines/asylum/resources/script.cpp
@@ -365,18 +365,20 @@ void ScriptManager::updateQueue(uint32 entryIndex) {
}
bool ScriptManager::process() {
- _exit = false;
+ _exit = false;
_vm->setGameFlag(kGameFlagScriptProcessing);
// Setup queue entry
if (_queue.currentEntry) {
- uint32 entryIndex = _queue.currentEntry;
- uint32 nextIndex = _queue.entries[entryIndex].field_C;
- int32 scriptIndex = _queue.entries[entryIndex].scriptIndex;
+ uint32 entryIndex = _queue.currentEntry;
+ uint32 nextIndex = _queue.entries[entryIndex].field_C;
+ int32 scriptIndex = _queue.entries[entryIndex].scriptIndex;
if (scriptIndex != -1) {
+ debugC(kDebugLevelScripts, "[Script] Running Script (entry: %d, idx: %d, nextIdx: %d)", entryIndex, scriptIndex, nextIndex);
+
// Setup script
for (;;) {
_processNextEntry = false;
@@ -402,6 +404,7 @@ bool ScriptManager::process() {
if (cmd->opcode >= (int32)_opcodes.size())
error("[ScriptManager::process] Invalid opcode index (was: %d, max: %d)", cmd->opcode, _opcodes.size() - 1);
+
debugC(kDebugLevelScripts, "[Script] 0x%02X: %s (%d, %d, %d, %d, %d, %d, %d, %d, %d)",
cmd->opcode, _opcodes[cmd->opcode]->name,
cmd->param1, cmd->param2, cmd->param3, cmd->param4, cmd->param5,
diff --git a/engines/asylum/views/scene.cpp b/engines/asylum/views/scene.cpp
index 79dc4c332a..0be0ace902 100644
--- a/engines/asylum/views/scene.cpp
+++ b/engines/asylum/views/scene.cpp
@@ -1565,8 +1565,11 @@ void Scene::handleHit(int32 index, HitType type) {
break;
case kHitActionArea:
- if (!getScript()->isInQueue(_ws->actions[index]->scriptIndex))
+ if (!getScript()->isInQueue(_ws->actions[index]->scriptIndex)) {
+ debugC(kDebugLevelScripts, "[Script] Queuing Script idx: %d from kHitActionArea (idx: %d, name: '%s')",
+ _ws->actions[index]->scriptIndex, index, _ws->actions[index]->name);
getScript()->queueScript(_ws->actions[index]->scriptIndex, getSharedData()->getPlayerIndex());
+ }
switch (_ws->chapter) {
default:
@@ -1596,8 +1599,12 @@ void Scene::handleHit(int32 index, HitType type) {
}
}
- if (!getScript()->isInQueue(object->getScriptIndex()))
+ if (!getScript()->isInQueue(object->getScriptIndex())) {
+ debugC(kDebugLevelScripts, "[Script] Queuing Script idx: %d from kHitObject (id: %d, name: '%s')",
+ object->getScriptIndex(), object->getId(), object->getName());
+
getScript()->queueScript(object->getScriptIndex(), getSharedData()->getPlayerIndex());
+ }
// Original executes special script hit functions, but since there is none defined, we can skip this part
}
@@ -1608,8 +1615,11 @@ void Scene::handleHit(int32 index, HitType type) {
if (actor->actionType & (kActionTypeFind | kActionType16)) {
- if (getScript()->isInQueue(actor->getScriptIndex()))
+ if (getScript()->isInQueue(actor->getScriptIndex())) {
+ debugC(kDebugLevelScripts, "[Script] Queuing Script idx: %d from kHitActor (id: %d, name: '%s')",
+ actor->getScriptIndex(), index, actor->getName());
getScript()->queueScript(actor->getScriptIndex(), getSharedData()->getPlayerIndex());
+ }
} else if (actor->actionType & kActionTypeTalk) {
@@ -1621,8 +1631,11 @@ void Scene::handleHit(int32 index, HitType type) {
actor->setSoundResourceId(kResourceNone);
}
- if (getScript()->isInQueue(actor->getScriptIndex()))
+ if (getScript()->isInQueue(actor->getScriptIndex())) {
+ debugC(kDebugLevelScripts, "[Script] Queuing Script idx: %d from kActionTypeTalk (actor idx: %d)",
+ actor->getScriptIndex(), getSharedData()->getPlayerIndex());
getScript()->queueScript(actor->getScriptIndex(), getSharedData()->getPlayerIndex());
+ }
}
switch (_ws->chapter) {
Commit: c1e47d473d1921aba3131511d5d5e6c06d697d58
https://github.com/scummvm/scummvm/commit/c1e47d473d1921aba3131511d5d5e6c06d697d58
Author: Alex Bevilacqua (alex at alexbevi.com)
Date: 2021-05-17T15:37:28+02:00
Commit Message:
ASYLUM: include the chapter number in the worldstats instance inspector
Changed paths:
engines/asylum/resources/worldstats.cpp
diff --git a/engines/asylum/resources/worldstats.cpp b/engines/asylum/resources/worldstats.cpp
index c1529f8592..e331b716b7 100644
--- a/engines/asylum/resources/worldstats.cpp
+++ b/engines/asylum/resources/worldstats.cpp
@@ -517,6 +517,7 @@ void WorldStats::setWheelObjects() {
Common::String WorldStats::toString() {
Common::String output;
+ output += Common::String::format("Chapter %d\n", chapter);
output += Common::String::format("xLeft: %d\n", xLeft);
output += Common::String::format("yTop: %d\n", yTop);
output += Common::String::format("boundingRect: top[%d] left[%d] right[%d] bottom[%d]: \n", boundingRect.top, boundingRect.left, boundingRect.right, boundingRect.bottom);
Commit: 6004f808dc93336076c70c126c118e536618d1fa
https://github.com/scummvm/scummvm/commit/6004f808dc93336076c70c126c118e536618d1fa
Author: Alex Bevilacqua (alex at alexbevi.com)
Date: 2021-05-17T15:37:28+02:00
Commit Message:
ASYLUM: add name to debug out for object inspection
Changed paths:
engines/asylum/resources/object.cpp
engines/asylum/resources/object.h
diff --git a/engines/asylum/resources/object.cpp b/engines/asylum/resources/object.cpp
index 16455746e5..1d9364535a 100644
--- a/engines/asylum/resources/object.cpp
+++ b/engines/asylum/resources/object.cpp
@@ -551,6 +551,7 @@ Common::String Object::toString(bool shortString) {
if (!shortString) {
output += Common::String::format(" resourceId: %u (0x%X) - (pack %d - index %d)\n", _resourceId, _resourceId, RESOURCE_PACK(_resourceId), RESOURCE_INDEX(_resourceId));
+ output += Common::String::format(" name: %s\n", _name);
output += Common::String::format(" x: %d\n", x);
output += Common::String::format(" y: %d\n", y);
output += Common::String::format(" flags: %d\n", flags);
diff --git a/engines/asylum/resources/object.h b/engines/asylum/resources/object.h
index 9a5412b699..b6821b18ab 100644
--- a/engines/asylum/resources/object.h
+++ b/engines/asylum/resources/object.h
@@ -154,7 +154,7 @@ public:
*/
bool checkFlags() const;
- uint8 *getName() { return _name; }
+ char *getName() { return _name; }
/**
* Convert this object into a string representation.
*
@@ -187,7 +187,7 @@ private:
int32 _field_34;
// flags
int32 _field_3C;
- uint8 _name[52];
+ char _name[52];
Common::Rect _rect;
uint32 _polygonIndex;
// actionType
Commit: 5259f1e50687c952e978401520fc4185fa7a7f1e
https://github.com/scummvm/scummvm/commit/5259f1e50687c952e978401520fc4185fa7a7f1e
Author: Alex Bevilacqua (alex at alexbevi.com)
Date: 2021-05-17T15:37:28+02:00
Commit Message:
ASYLUM: added show_script and action commands
Changed paths:
engines/asylum/console.cpp
engines/asylum/console.h
diff --git a/engines/asylum/console.cpp b/engines/asylum/console.cpp
index 2c3dacc9af..6ae104262b 100644
--- a/engines/asylum/console.cpp
+++ b/engines/asylum/console.cpp
@@ -162,6 +162,7 @@ Console::Console(AsylumEngine *engine) : _vm(engine) {
registerCmd("ls", WRAP_METHOD(Console, cmdListFiles));
+ registerCmd("action", WRAP_METHOD(Console, cmdShowAction));
registerCmd("actions", WRAP_METHOD(Console, cmdListActions));
registerCmd("actors", WRAP_METHOD(Console, cmdListActors));
registerCmd("flags", WRAP_METHOD(Console, cmdListFlags));
@@ -171,6 +172,8 @@ Console::Console(AsylumEngine *engine) : _vm(engine) {
registerCmd("video", WRAP_METHOD(Console, cmdPlayVideo));
registerCmd("script", WRAP_METHOD(Console, cmdRunScript));
+ registerCmd("show_script", WRAP_METHOD(Console, cmdShowScript));
+
registerCmd("scene", WRAP_METHOD(Console, cmdChangeScene));
registerCmd("encounter", WRAP_METHOD(Console, cmdRunEncounter));
registerCmd("puzzle", WRAP_METHOD(Console, cmdRunPuzzle));
@@ -205,18 +208,20 @@ bool Console::cmdHelp(int, const char **) {
debugPrintf(" debugflag_list - Lists the available debug flags and their status\n");
debugPrintf(" debugflag_enable - Enables a debug flag\n");
debugPrintf(" debugflag_disable - Disables a debug flag\n");
+ debugPrintf("\n");
debugPrintf(" show_actors - Show actors\n");
debugPrintf(" show_objects - Show objects\n");
debugPrintf(" show_polygons - Show polygons\n");
- debugPrintf(" show_drawrects - Show drawing rects\n");;
- debugPrintf(" use_scrolling - Use scrolling\n");
+ debugPrintf(" show_drawrects - Show drawing rects\n");
+ debugPrintf(" use_scrolling - Scroll scene using the mouse\n");
debugPrintf("\n");
debugPrintf("Commands\n");
debugPrintf("--------\n");
debugPrintf(" ls - list engine files\n");
debugPrintf("\n");
debugPrintf(" actors - show actors information\n");
- debugPrintf(" actions - show action information\n");
+ debugPrintf(" action - show action information\n");
+ debugPrintf(" actions - list actions information\n");
debugPrintf(" flags - show flags\n");
debugPrintf(" object - inspect a particular object\n");
debugPrintf(" objects - show objects information\n");
@@ -225,6 +230,7 @@ bool Console::cmdHelp(int, const char **) {
debugPrintf(" video - play a video\n");
debugPrintf(" script - run a script\n");
debugPrintf(" scene - change the scene\n");
+ debugPrintf(" show_script - Show script commands\n");
debugPrintf(" encounter - run an encounter\n");
debugPrintf(" puzzle - run an puzzle\n");
debugPrintf("\n");
@@ -405,6 +411,39 @@ bool Console::cmdShowObject(int32 argc, const char **argv) {
return true;
}
+bool Console::cmdShowAction(int32 argc, const char **argv) {
+ if (argc != 3) {
+ debugPrintf("Syntax: %s [id|idx] <target>\n", argv[0]);
+ return true;
+ }
+
+ if (Common::String(argv[1]) == "id") {
+ int id = atoi(argv[2]);
+ for (uint32 i = 0; i < getWorld()->actions.size(); i++) {
+ if (getWorld()->actions[i]->id == id) {
+ debugPrintf("%s", getWorld()->actions[i]->toString().c_str());
+ return true;
+ }
+ }
+ debugPrintf("No action with id %d found\n", id);
+ } else if (Common::String(argv[1]) == "idx") {
+ int index = atoi(argv[2]);
+ int maxIndex = getWorld()->actions.size() - 1;
+
+ if (index < 0 || index > maxIndex) {
+ debugPrintf("[error] index should be between 0 and %d\n", maxIndex);
+ return true;
+ }
+
+ debugPrintf("%s", getWorld()->actions[index]->toString().c_str());
+
+ } else {
+ debugPrintf("[error] valid options are 'id' and 'idx'\n");
+ }
+
+ return true;
+}
+
bool Console::cmdListObjects(int32 argc, const char **argv) {
if (argc != 2) {
debugPrintf("Syntax: %s [onscreen|*]\n", argv[0]);
@@ -459,6 +498,33 @@ bool Console::cmdPlayVideo(int32 argc, const char **argv) {
return false;
}
+bool Console::cmdShowScript(int32 argc, const char **argv) {
+ if (argc != 2) {
+ debugPrintf("Syntax: %s <script index>\n", argv[0]);
+ return true;
+ }
+
+ int32 index = atoi(argv[1]);
+
+ // Check parameters
+ if (index < 0 || index >= (int32)getScript()->_scripts.size()) {
+ debugPrintf("[Error] Invalid index (was: %d - valid: [0-%d])\n", index, getScript()->_scripts.size() - 1);
+ return true;
+ }
+
+ int32 lines = getScript()->_scripts[index].commands[0].numLines;
+ for (uint8 i = 0; i <= lines; i++) {
+ Asylum::ScriptManager::ScriptEntry *cmd = &getScript()->_scripts[index].commands[i];
+
+ debugPrintf("%02d: [0x%02X] %s (%d, %d, %d, %d, %d, %d, %d, %d, %d)\n",
+ i, cmd->opcode, getScript()->_opcodes[cmd->opcode]->name,
+ cmd->param1, cmd->param2, cmd->param3, cmd->param4, cmd->param5,
+ cmd->param6, cmd->param7, cmd->param8, cmd->param9);
+ }
+
+ return true;
+}
+
bool Console::cmdRunScript(int32 argc, const char **argv) {
if (argc != 3) {
debugPrintf("Syntax: %s <script index> <actor index>\n", argv[0]);
@@ -470,7 +536,7 @@ bool Console::cmdRunScript(int32 argc, const char **argv) {
// Check parameters
if (index < 0 || index >= (int32)getScript()->_scripts.size()) {
- debugPrintf("[Error] Invalid index (was: %d - valid: [0-%d])\n", index, _vm->encounter()->items()->size() - 1);
+ debugPrintf("[Error] Invalid index (was: %d - valid: [0-%d])\n", index, (int32)getScript()->_scripts.size() - 1);
return true;
}
diff --git a/engines/asylum/console.h b/engines/asylum/console.h
index d6dadce8cf..ffd8eb3b34 100644
--- a/engines/asylum/console.h
+++ b/engines/asylum/console.h
@@ -65,10 +65,12 @@ private:
bool cmdListActors(int32 argc, const char **argv);
bool cmdListFlags(int32 argc, const char **argv);
bool cmdShowObject(int32 argc, const char **argv);
+ bool cmdShowAction(int32 argc, const char **argv);
bool cmdListObjects(int32 argc, const char **argv);
bool cmdShowWorldStats(int32 argc, const char **argv);
bool cmdPlayVideo(int32 argc, const char **argv);
+ bool cmdShowScript(int32 argc, const char **argv);
bool cmdRunScript(int32 argc, const char **argv);
bool cmdChangeScene(int32 argc, const char **argv);
bool cmdRunEncounter(int32 argc, const char **argv);
Commit: 5db12fc55b4a6b681719bde9d1fe084f870df535
https://github.com/scummvm/scummvm/commit/5db12fc55b4a6b681719bde9d1fe084f870df535
Author: Alex Bevilacqua (alex at alexbevi.com)
Date: 2021-05-17T15:37:28+02:00
Commit Message:
ASYLUM: debugging helper to prevent printing running script line more than once
Changed paths:
engines/asylum/resources/script.cpp
engines/asylum/resources/script.h
diff --git a/engines/asylum/resources/script.cpp b/engines/asylum/resources/script.cpp
index 9daa7ae010..55e8d0acfe 100644
--- a/engines/asylum/resources/script.cpp
+++ b/engines/asylum/resources/script.cpp
@@ -377,8 +377,6 @@ bool ScriptManager::process() {
if (scriptIndex != -1) {
- debugC(kDebugLevelScripts, "[Script] Running Script (entry: %d, idx: %d, nextIdx: %d)", entryIndex, scriptIndex, nextIndex);
-
// Setup script
for (;;) {
_processNextEntry = false;
@@ -404,11 +402,13 @@ bool ScriptManager::process() {
if (cmd->opcode >= (int32)_opcodes.size())
error("[ScriptManager::process] Invalid opcode index (was: %d, max: %d)", cmd->opcode, _opcodes.size() - 1);
+ if (_lastProcessedCmd != cmd)
+ debugC(kDebugLevelScripts, "[Script idx: %d] 0x%02X: %s (%d, %d, %d, %d, %d, %d, %d, %d, %d)",
+ scriptIndex, cmd->opcode, _opcodes[cmd->opcode]->name,
+ cmd->param1, cmd->param2, cmd->param3, cmd->param4, cmd->param5,
+ cmd->param6, cmd->param7, cmd->param8, cmd->param9);
- debugC(kDebugLevelScripts, "[Script] 0x%02X: %s (%d, %d, %d, %d, %d, %d, %d, %d, %d)",
- cmd->opcode, _opcodes[cmd->opcode]->name,
- cmd->param1, cmd->param2, cmd->param3, cmd->param4, cmd->param5,
- cmd->param6, cmd->param7, cmd->param8, cmd->param9);
+ _lastProcessedCmd = cmd; // DEBUGGING
// Execute opcode
_currentQueueEntry = &_queue.entries[entryIndex];
@@ -695,8 +695,8 @@ END_OPCODE
IMPLEMENT_OPCODE(JumpActorSpeech)
Actor *actor = getScene()->getActor(cmd->param1);
- if (actor->process(Common::Point((int16)cmd->param2, (int16)cmd->param3)))
- return;
+// if (actor->process(Common::Point((int16)cmd->param2, (int16)cmd->param3)))
+// return;
_currentQueueEntry->currentLine = cmd->param4;
@@ -742,7 +742,8 @@ END_OPCODE
IMPLEMENT_OPCODE(JumpIfActorCoordinates)
Actor *actor = getScene()->getActor(cmd->param1);
- if ((actor->getPoint1()->x + actor->getPoint2()->x) != cmd->param2 || (actor->getPoint1()->y + actor->getPoint2()->y) != cmd->param3)
+ if ((actor->getPoint1()->x + actor->getPoint2()->x) != cmd->param2 ||
+ (actor->getPoint1()->y + actor->getPoint2()->y) != cmd->param3)
_currentQueueEntry->currentLine = cmd->param4;
END_OPCODE
diff --git a/engines/asylum/resources/script.h b/engines/asylum/resources/script.h
index 664135792a..c932e0ea6e 100644
--- a/engines/asylum/resources/script.h
+++ b/engines/asylum/resources/script.h
@@ -331,7 +331,7 @@ private:
bool _done;
bool _exit;
bool _processNextEntry;
-
+ ScriptEntry *_lastProcessedCmd; // DEBUGGING
Script *_currentScript;
ScriptQueueEntry *_currentQueueEntry;
Commit: 7388be88248658b0ad65f6ef817bcd7d6ccbe348
https://github.com/scummvm/scummvm/commit/7388be88248658b0ad65f6ef817bcd7d6ccbe348
Author: Alex Bevilacqua (alex at alexbevi.com)
Date: 2021-05-17T15:37:29+02:00
Commit Message:
ASYLUM: script debugging in actor code
Changed paths:
engines/asylum/resources/actor.cpp
diff --git a/engines/asylum/resources/actor.cpp b/engines/asylum/resources/actor.cpp
index e7c3793d64..0bf3cf676b 100644
--- a/engines/asylum/resources/actor.cpp
+++ b/engines/asylum/resources/actor.cpp
@@ -3299,8 +3299,12 @@ void Actor::updateFinish() {
ActionArea *area = getWorld()->actions[areaIndex];
ActionArea *actorArea = getWorld()->actions[_actionIdx3];
+
if ((area->flags & 1) && !getSharedData()->getFlag(kFlagSkipScriptProcessing)) {
+ debugC(kDebugLevelScripts, "[Script] Entered ActionArea (idx: %d, name: %s)", areaIndex, area->name);
+ debugC(kDebugLevelScripts, "[Script] Queuing Script #1 (idx: %d) for Actor (idx: %d)", actorArea->scriptIndex2, _index);
getScript()->queueScript(actorArea->scriptIndex2, _index);
+ debugC(kDebugLevelScripts, "[Script] Queuing Script #2 (idx: %d) for Actor (idx: %d)", actorArea->scriptIndex, _index);
getScript()->queueScript(area->scriptIndex, _index);
}
Commit: 1b6120e97408b7a9aa5d5ba2271c8833a9101417
https://github.com/scummvm/scummvm/commit/1b6120e97408b7a9aa5d5ba2271c8833a9101417
Author: Alexandre Fontoura (alexandrefontoura at gmail.com)
Date: 2021-05-17T15:37:29+02:00
Commit Message:
ASYLUM: Fixed Scene Update Coordinates with Motion
Changed paths:
engines/asylum/views/scene.cpp
diff --git a/engines/asylum/views/scene.cpp b/engines/asylum/views/scene.cpp
index 0be0ace902..184b1889f2 100644
--- a/engines/asylum/views/scene.cpp
+++ b/engines/asylum/views/scene.cpp
@@ -1087,8 +1087,8 @@ void Scene::updateCoordinates() {
if (_ws->coordinates[1] != _ws->yTop)
xLeft = _ws->xLeft = getSharedData()->getSceneOffset() + getSharedData()->getSceneCoords().x;
- yTop = _ws->coordinates[2] + _ws->yTop;
- _ws->yTop += _ws->coordinates[2];
+ xLeft = _ws->coordinates[2] + _ws->xLeft;
+ _ws->xLeft += _ws->coordinates[2];
} else {
coord1 = _ws->coordinates[0];
@@ -1097,8 +1097,8 @@ void Scene::updateCoordinates() {
if (_ws->coordinates[0] != _ws->xLeft)
yTop = _ws->yTop = getSharedData()->getSceneOffset() + getSharedData()->getSceneCoords().y;
- xLeft = _ws->coordinates[2] + _ws->xLeft;
- _ws->xLeft += _ws->coordinates[2];
+ yTop = _ws->coordinates[2] + _ws->yTop;
+ _ws->yTop += _ws->coordinates[2];
}
if (abs(coord2 - coord1) <= abs(_ws->coordinates[2])) {
Commit: de2ac3012c18454f4b094b639b9f2aaed19017dd
https://github.com/scummvm/scummvm/commit/de2ac3012c18454f4b094b639b9f2aaed19017dd
Author: Alexandre Fontoura (alexandrefontoura at gmail.com)
Date: 2021-05-17T15:37:29+02:00
Commit Message:
ASYLUM: Enable code to allow Actor to walk to a position
Changed paths:
engines/asylum/resources/script.cpp
diff --git a/engines/asylum/resources/script.cpp b/engines/asylum/resources/script.cpp
index 55e8d0acfe..270a0ad12d 100644
--- a/engines/asylum/resources/script.cpp
+++ b/engines/asylum/resources/script.cpp
@@ -695,8 +695,9 @@ END_OPCODE
IMPLEMENT_OPCODE(JumpActorSpeech)
Actor *actor = getScene()->getActor(cmd->param1);
-// if (actor->process(Common::Point((int16)cmd->param2, (int16)cmd->param3)))
-// return;
+ // Actor goes to position (param2, param3)
+ if (actor->process(Common::Point((int16)cmd->param2, (int16)cmd->param3)))
+ return;
_currentQueueEntry->currentLine = cmd->param4;
Commit: bf2d5d7765cc7c2d9e8ca1a18e216194b262a28c
https://github.com/scummvm/scummvm/commit/bf2d5d7765cc7c2d9e8ca1a18e216194b262a28c
Author: Alexandre Fontoura (alexandrefontoura at gmail.com)
Date: 2021-05-17T15:37:29+02:00
Commit Message:
ASYLUM: Fixed wrong coordinate check in Actor canMoveCheckActors
Changed paths:
engines/asylum/resources/actor.cpp
diff --git a/engines/asylum/resources/actor.cpp b/engines/asylum/resources/actor.cpp
index 0bf3cf676b..69d6be21d3 100644
--- a/engines/asylum/resources/actor.cpp
+++ b/engines/asylum/resources/actor.cpp
@@ -1941,7 +1941,7 @@ bool Actor::canMoveCheckActors(Common::Point *point, ActorDirection dir) {
// Fallback to next case
case kDirectionN:
- if (x4 >= y)
+ if (y4 >= y)
break;
return false;
Commit: ad85c727d20ea30069e958a83c581df045175e14
https://github.com/scummvm/scummvm/commit/ad85c727d20ea30069e958a83c581df045175e14
Author: Alexandre Fontoura (alexandrefontoura at gmail.com)
Date: 2021-05-17T15:37:29+02:00
Commit Message:
ASYLUM: Commented Script JumpIfActorCoordinates and added comments. This is to allow us to proceed within the script and go to other places in the scene
Changed paths:
engines/asylum/resources/script.cpp
diff --git a/engines/asylum/resources/script.cpp b/engines/asylum/resources/script.cpp
index 270a0ad12d..084fbd6431 100644
--- a/engines/asylum/resources/script.cpp
+++ b/engines/asylum/resources/script.cpp
@@ -736,6 +736,7 @@ IMPLEMENT_OPCODE(JumpAndSetDirection)
if (cmd->param5 == 2)
_processNextEntry = true;
}
+
END_OPCODE
//////////////////////////////////////////////////////////////////////////
@@ -743,9 +744,17 @@ END_OPCODE
IMPLEMENT_OPCODE(JumpIfActorCoordinates)
Actor *actor = getScene()->getActor(cmd->param1);
- if ((actor->getPoint1()->x + actor->getPoint2()->x) != cmd->param2 ||
+ // FIXME: the script is wrongly jumping to the currentLine = cmd->param4 giving a wrong behaviour
+ // actor->canMoveCheckActors (called from canMove) seems to be the cause of the issue
+ // this script fails because the position is never met for few pixels (3 to 5 pixels)
+ // usually the X coordinate but sometimes also happens with the Y coordinate
+ debugC(kDebugLevelScripts, "COMMENTED JumpIfActorCoordinates %d x: %d y: %d",
+ (actor->getPoint1()->x + actor->getPoint2()->x),
+ (actor->getPoint1()->y + actor->getPoint2()->y));
+
+ /*if ((actor->getPoint1()->x + actor->getPoint2()->x) != cmd->param2 ||
(actor->getPoint1()->y + actor->getPoint2()->y) != cmd->param3)
- _currentQueueEntry->currentLine = cmd->param4;
+ _currentQueueEntry->currentLine = cmd->param4;*/
END_OPCODE
//////////////////////////////////////////////////////////////////////////
Commit: c7a7025ca5c53f0e42e857e77c53e9afe4c2f871
https://github.com/scummvm/scummvm/commit/c7a7025ca5c53f0e42e857e77c53e9afe4c2f871
Author: xesfnet (xesfnet at gmail.com)
Date: 2021-05-17T15:37:29+02:00
Commit Message:
ASYLUM: Fixed wrong palette info attached that was causing a segmentation fault.
Changed paths:
engines/asylum/resources/actor.cpp
diff --git a/engines/asylum/resources/actor.cpp b/engines/asylum/resources/actor.cpp
index 69d6be21d3..74029278e2 100644
--- a/engines/asylum/resources/actor.cpp
+++ b/engines/asylum/resources/actor.cpp
@@ -3310,7 +3310,7 @@ void Actor::updateFinish() {
if (!area->paletteResourceId || area->paletteResourceId == actorArea->paletteResourceId || _index) {
if (area->paletteResourceId != actorArea->paletteResourceId && !_index)
- _vm->screen()->startPaletteFade(area->paletteResourceId, 50, 3);
+ _vm->screen()->startPaletteFade(getWorld()->currentPaletteId, 100, 3);
_actionIdx3 = areaIndex;
} else {
Commit: 5fbe1d706b5e6691f7499330e4c395e790ee76ab
https://github.com/scummvm/scummvm/commit/5fbe1d706b5e6691f7499330e4c395e790ee76ab
Author: xesfnet (xesfnet at gmail.com)
Date: 2021-05-17T15:37:29+02:00
Commit Message:
ASYLUM: Skip intro talk about Max
Changed paths:
engines/asylum/asylum.cpp
diff --git a/engines/asylum/asylum.cpp b/engines/asylum/asylum.cpp
index 07374aa42a..4924eb44f1 100644
--- a/engines/asylum/asylum.cpp
+++ b/engines/asylum/asylum.cpp
@@ -197,7 +197,9 @@ void AsylumEngine::startGame(ResourcePackId sceneId, StartGameType type) {
case kStartGamePlayIntro:
_scene->enter(sceneId);
+#ifndef DEBUG
playIntro();
+#endif
break;
case kStartGameLoad:
Commit: b8a3047e3fee6a78e0789a9d46569d31d4a2052f
https://github.com/scummvm/scummvm/commit/b8a3047e3fee6a78e0789a9d46569d31d4a2052f
Author: Alexandre Fontoura (alexandrefontoura at gmail.com)
Date: 2021-05-17T15:37:30+02:00
Commit Message:
ASYLUM: Fixed correct resourceId while Actor is disabled.
Changed paths:
engines/asylum/resources/actor.cpp
diff --git a/engines/asylum/resources/actor.cpp b/engines/asylum/resources/actor.cpp
index 74029278e2..501088a301 100644
--- a/engines/asylum/resources/actor.cpp
+++ b/engines/asylum/resources/actor.cpp
@@ -737,8 +737,8 @@ void Actor::updateStatus(ActorStatus actorStatus) {
break;
case kActorStatusDisabled:
- updateGraphicData(15);
- _resourceId = _graphicResourceIds[(_direction > kDirectionS ? kDirection8 - _direction : _direction) + 15];
+ updateGraphicData(5);
+ _resourceId = _graphicResourceIds[(_direction > kDirectionS ? kDirection8 - _direction : _direction) + 5];
getScreen()->setFlag(-1);
break;
Commit: 52fe2f8455fed52ec876084a762187953550c3b5
https://github.com/scummvm/scummvm/commit/52fe2f8455fed52ec876084a762187953550c3b5
Author: Alexandre Fontoura (alexandrefontoura at gmail.com)
Date: 2021-05-17T15:37:30+02:00
Commit Message:
ASYLUM: debug for non implemented palette functions instead of error, so we can proceed with the game. A lot of bugs but we can now go to the next level :)
Changed paths:
engines/asylum/resources/encounters.cpp
engines/asylum/system/screen.cpp
diff --git a/engines/asylum/resources/encounters.cpp b/engines/asylum/resources/encounters.cpp
index ded69dd1bf..156ef9ba9c 100644
--- a/engines/asylum/resources/encounters.cpp
+++ b/engines/asylum/resources/encounters.cpp
@@ -1445,11 +1445,11 @@ bool Encounter::updateScreen() {
}
void Encounter::updatePalette1() {
- error("[Encounter::updatePalette1] Not implemented!");
+ debugC(kDebugLevelEncounter, "[Encounter::updatePalette1] Not implemented!");
}
void Encounter::updatePalette2() {
- error("[Encounter::updatePalette2] Not implemented!");
+ debugC(kDebugLevelEncounter, "[Encounter::updatePalette2] Not implemented!");
}
//////////////////////////////////////////////////////////////////////////
diff --git a/engines/asylum/system/screen.cpp b/engines/asylum/system/screen.cpp
index 32fabeb188..16983da6ce 100644
--- a/engines/asylum/system/screen.cpp
+++ b/engines/asylum/system/screen.cpp
@@ -322,7 +322,7 @@ void Screen::setupPalette(byte *buffer, int start, int count) {
void Screen::updatePalette() {
// FIXME: This is used to replace all the inline code to setup the palette before calls to setupPalette/paletteFade
// See if all that code can really be factorized into a single function or not
- error("[Screen::updatePalette] Not implemented!");
+ debugC(kDebugLevelScene, "[Screen::updatePalette] Not implemented!");
}
void Screen::updatePalette(int32 param) {
Commit: 42e09f359b84ba6b9cdbb3be329749fbd9fb4de1
https://github.com/scummvm/scummvm/commit/42e09f359b84ba6b9cdbb3be329749fbd9fb4de1
Author: Alexandre Fontoura (alexandrefontoura at gmail.com)
Date: 2021-05-17T15:37:30+02:00
Commit Message:
ASYLUM: Fixed incorrect string format
Changed paths:
engines/asylum/resources/script.cpp
diff --git a/engines/asylum/resources/script.cpp b/engines/asylum/resources/script.cpp
index 084fbd6431..cb8106800a 100644
--- a/engines/asylum/resources/script.cpp
+++ b/engines/asylum/resources/script.cpp
@@ -748,7 +748,7 @@ IMPLEMENT_OPCODE(JumpIfActorCoordinates)
// actor->canMoveCheckActors (called from canMove) seems to be the cause of the issue
// this script fails because the position is never met for few pixels (3 to 5 pixels)
// usually the X coordinate but sometimes also happens with the Y coordinate
- debugC(kDebugLevelScripts, "COMMENTED JumpIfActorCoordinates %d x: %d y: %d",
+ debugC(kDebugLevelScripts, "COMMENTED JumpIfActorCoordinates x: %d y: %d",
(actor->getPoint1()->x + actor->getPoint2()->x),
(actor->getPoint1()->y + actor->getPoint2()->y));
Commit: b374c59bdf7700c0da4f2f8fc590f87395aa7115
https://github.com/scummvm/scummvm/commit/b374c59bdf7700c0da4f2f8fc590f87395aa7115
Author: Alexandre Fontoura (alexandrefontoura at gmail.com)
Date: 2021-05-17T15:37:30+02:00
Commit Message:
ASYLUM: Fixed actor visibility entering the scene. Chapter 2 can now be played.
Changed paths:
engines/asylum/views/scene.cpp
diff --git a/engines/asylum/views/scene.cpp b/engines/asylum/views/scene.cpp
index 184b1889f2..4efda0b549 100644
--- a/engines/asylum/views/scene.cpp
+++ b/engines/asylum/views/scene.cpp
@@ -132,8 +132,7 @@ void Scene::enter(ResourcePackId packId) {
// Adjust scene bounding rect
_ws->boundingRect = Common::Rect(195, 115, 445 - boundingRect->right, 345 - boundingRect->bottom);
- // Hide actor
- player->hide();
+ player->show(); // flag |= 1 (show actor)
player->enable();
// Update current player coordinates
Commit: 5dd9d33d2ca250fab9a38a53d15a2106e7ab6703
https://github.com/scummvm/scummvm/commit/5dd9d33d2ca250fab9a38a53d15a2106e7ab6703
Author: Alex Bevilacqua (alex at alexbevi.com)
Date: 2021-05-17T15:37:30+02:00
Commit Message:
ASYLUM: add debug output to special::check[Other]Object and test for kObjectInvalid
Changed paths:
engines/asylum/resources/special.cpp
diff --git a/engines/asylum/resources/special.cpp b/engines/asylum/resources/special.cpp
index 44d2329dbd..c8e9d3ae55 100644
--- a/engines/asylum/resources/special.cpp
+++ b/engines/asylum/resources/special.cpp
@@ -1445,12 +1445,16 @@ uint32 Special::getCounter(ActorIndex index) const {
}
void Special::checkObject(Object *object, GameFlag flagToSet, GameFlag flagToClear, ObjectId objectId) {
- if (object->getFrameIndex() == 15) {
+ if (objectId != kObjectInvalid && object->getFrameIndex() == 15) {
+ Object *otherObject = getWorld()->getObjectById(objectId);
+ debugC(kDebugLevelObjects, "[checkObject] %s -> %s (flags: set %d, clear %d)",
+ object->getName(), otherObject->getName(), flagToSet, flagToClear);
+
_vm->setGameFlag(flagToSet);
_vm->clearGameFlag(flagToClear);
if (objectId != kObjectNone)
- getWorld()->getObjectById(objectId)->setFrameIndex(0);
+ otherObject->setFrameIndex(0);
else
object->setFrameIndex(0);
}
@@ -1459,6 +1463,9 @@ void Special::checkObject(Object *object, GameFlag flagToSet, GameFlag flagToCle
void Special::checkOtherObject(Object *object, ObjectId otherObjectId, GameFlag flagToClear, GameFlag flagToSet) {
Object *otherObject = getWorld()->getObjectById(otherObjectId);
+ debugC(kDebugLevelObjects, "[checkOtherObject] %s -> %s (flags: set %d, clear %d)",
+ object->getName(), otherObject->getName(), flagToSet, flagToClear);
+
if (!otherObject->getFrameIndex() && !object->getFrameIndex()) {
_vm->clearGameFlag(flagToClear);
_vm->setGameFlag(flagToSet);
Commit: 294e27d67f077e33114838494413e405ad5299a0
https://github.com/scummvm/scummvm/commit/294e27d67f077e33114838494413e405ad5299a0
Author: Alexandre Fontoura (alexandrefontoura at gmail.com)
Date: 2021-05-17T15:37:30+02:00
Commit Message:
ASYLUM: Fixed chapter 2 specials crash
Changed paths:
engines/asylum/resources/special.cpp
diff --git a/engines/asylum/resources/special.cpp b/engines/asylum/resources/special.cpp
index c8e9d3ae55..37d7def4f6 100644
--- a/engines/asylum/resources/special.cpp
+++ b/engines/asylum/resources/special.cpp
@@ -1453,7 +1453,7 @@ void Special::checkObject(Object *object, GameFlag flagToSet, GameFlag flagToCle
_vm->setGameFlag(flagToSet);
_vm->clearGameFlag(flagToClear);
- if (objectId != kObjectNone)
+ if (objectId == kObjectNone)
otherObject->setFrameIndex(0);
else
object->setFrameIndex(0);
Commit: d25c7ed13ac3221997dbc89ea4200b526e2d7942
https://github.com/scummvm/scummvm/commit/d25c7ed13ac3221997dbc89ea4200b526e2d7942
Author: xesfnet (xesfnet at gmail.com)
Date: 2021-05-17T15:37:31+02:00
Commit Message:
ASYLUM: Encounter tiny fixes.
Changed paths:
engines/asylum/resources/encounters.cpp
engines/asylum/resources/encounters.h
diff --git a/engines/asylum/resources/encounters.cpp b/engines/asylum/resources/encounters.cpp
index 156ef9ba9c..04070e3da8 100644
--- a/engines/asylum/resources/encounters.cpp
+++ b/engines/asylum/resources/encounters.cpp
@@ -456,6 +456,7 @@ bool Encounter::update() {
}
bool doScript = false;
+ //bool doScript = true; // TODO: fix this later - for now it doesn run the script so let make sure it runs
if ((getSpeech()->getSoundResourceId() && !getSound()->isPlaying(getSpeech()->getSoundResourceId()) && !_data_455BE0)
|| (getSpeech()->getTick() && tick >= getSpeech()->getTick()))
doScript = true;
@@ -463,7 +464,7 @@ bool Encounter::update() {
if (doScript
&& !getSharedData()->getMatteBarHeight()
&& _isScriptRunning
- && !setupSpeech(id))
+ && !setupSpeechTest(id))
runScript();
}
@@ -781,6 +782,7 @@ void Encounter::setupSpeechText() {
_portrait2.transTableMax = 3;
getSpeech()->setTextData(NULL);
+ getSpeech()->setTextDataPos(text);
if (*text == '/')
getSpeech()->setTextDataPos(text + 2);
@@ -816,7 +818,7 @@ void Encounter::setupSpeech(ResourceId textResourceId, ResourceId fontResourceId
getSpeech()->setSoundResourceId(MAKE_RESOURCE(kResourcePackSharedSound, textResourceId - _speechResourceId));
}
-bool Encounter::setupSpeech(ResourceId id) {
+bool Encounter::setupSpeechTest(ResourceId id) {
getSpeech()->setTick(0);
getSpeech()->setSoundResourceId(kResourceNone);
diff --git a/engines/asylum/resources/encounters.h b/engines/asylum/resources/encounters.h
index 0bd960d711..d435cff907 100644
--- a/engines/asylum/resources/encounters.h
+++ b/engines/asylum/resources/encounters.h
@@ -238,7 +238,7 @@ private:
void setupSpeechText();
void setupSpeechData(char val, EncounterGraphic *encounterGraphic) const;
void setupSpeech(ResourceId textResourceId, ResourceId fontResourceId);
- bool setupSpeech(ResourceId id);
+ bool setupSpeechTest(ResourceId id);
bool isSpeaking();
//////////////////////////////////////////////////////////////////////////
Commit: 410a7aab2e88c625ba3068bab629c20e537946b0
https://github.com/scummvm/scummvm/commit/410a7aab2e88c625ba3068bab629c20e537946b0
Author: xesfnet (xesfnet at gmail.com)
Date: 2021-05-17T15:37:31+02:00
Commit Message:
ASYLUM: Encounters speech play. Still buggy has it loops through all the voices but at least isn't stuck in the screen anymore.
Changed paths:
engines/asylum/resources/encounters.cpp
engines/asylum/resources/encounters.h
diff --git a/engines/asylum/resources/encounters.cpp b/engines/asylum/resources/encounters.cpp
index 04070e3da8..1f68b4d807 100644
--- a/engines/asylum/resources/encounters.cpp
+++ b/engines/asylum/resources/encounters.cpp
@@ -456,8 +456,7 @@ bool Encounter::update() {
}
bool doScript = false;
- //bool doScript = true; // TODO: fix this later - for now it doesn run the script so let make sure it runs
- if ((getSpeech()->getSoundResourceId() && !getSound()->isPlaying(getSpeech()->getSoundResourceId()) && !_data_455BE0)
+ if ((_soundResourceId/*getSpeech()->getSoundResourceId()*/ && !getSound()->isPlaying(_soundResourceId/*getSpeech()->getSoundResourceId()*/) && !_data_455BE0) // TODO replace with speech
|| (getSpeech()->getTick() && tick >= getSpeech()->getTick()))
doScript = true;
@@ -815,12 +814,15 @@ void Encounter::setupSpeech(ResourceId textResourceId, ResourceId fontResourceId
}
_data_455BE0 = true;
- getSpeech()->setSoundResourceId(MAKE_RESOURCE(kResourcePackSharedSound, textResourceId - _speechResourceId));
+ _soundResourceId = MAKE_RESOURCE(kResourcePackSharedSound, textResourceId - _speechResourceId);
+ //_soundResourceId = MAKE_RESOURCE(kResourcePackSpeech, textResourceId - _speechResourceId); // todo replace with speech (this is being override by the actor speechs)
+ //getSpeech()->setSoundResourceId(MAKE_RESOURCE(kResourcePackSpeech, textResourceId - _speechResourceId));
}
bool Encounter::setupSpeechTest(ResourceId id) {
getSpeech()->setTick(0);
- getSpeech()->setSoundResourceId(kResourceNone);
+ _soundResourceId = kResourceNone; // TODO replace with speech (this is being override by the actor speechs)
+ //getSpeech()->setSoundResourceId(kResourceNone);
setupEntities(false);
@@ -849,8 +851,8 @@ bool Encounter::isSpeaking() {
if (!_isScriptRunning)
return false;
- if (getSpeech()->getSoundResourceId() != kResourceNone && getSound()->isPlaying(getSpeech()->getSoundResourceId())) {
- getSound()->stopAll(getSpeech()->getSoundResourceId());
+ if (_soundResourceId/*getSpeech()->getSoundResourceId()*/ != kResourceNone && getSound()->isPlaying(_soundResourceId/*getSpeech()->getSoundResourceId()*/)) { // TODO replace with speech
+ getSound()->stopAll(_soundResourceId);
return true;
}
@@ -1146,7 +1148,7 @@ void Encounter::drawSubtitle(char *text, ResourceId font, int16 y) {
if (_data_455BCC) {
if (_data_455B3C != 1 && _tick < _vm->getTick()) {
- _tick = _vm->getTick() + 1000 * (getResource()->get(getSpeech()->getSoundResourceId())->size / 11025) / (uint16)_data_455B3C;
+ _tick = _vm->getTick() + 1000 * (getResource()->get(_soundResourceId/*getSpeech()->getSoundResourceId()*/)->size / 11025) / (uint16)_data_455B3C; // TODO replace with speech
if ((_data_455BF0 + 8) < _data_455B70)
_data_455BF0 += 8;
@@ -1156,7 +1158,7 @@ void Encounter::drawSubtitle(char *text, ResourceId font, int16 y) {
_data_455B70 = getText()->draw(kTextCalculate, Common::Point(x, y), 16, width, text);
_data_455B3C = _data_455B70 / 8 + 1;
_data_455BF0 = 0;
- _tick = _vm->getTick() + 1000 * (getResource()->get(getSpeech()->getSoundResourceId())->size / 11025) / (uint16)_data_455B3C;
+ _tick = _vm->getTick() + 1000 * (getResource()->get(_soundResourceId/*getSpeech()->getSoundResourceId()*/)->size / 11025) / (uint16)_data_455B3C; // TODO replace with speech
}
getText()->draw(_data_455BF0, 7, kTextCenter, Common::Point(x, y), 16, width, text);
@@ -1429,7 +1431,7 @@ bool Encounter::updateScreen() {
if (!_data_455BDC && !_objectId1 && !_objectId2 && !_actorIndex)
error("[Encounter::updateScreen] Invalid encounter resources!");
- getSound()->playSound(getSpeech()->getSoundResourceId(), false, Config.voiceVolume);
+ getSound()->playSound(_soundResourceId/*getSpeech()->getSoundResourceId()*/, false, Config.voiceVolume); // TODO replace with speech
}
return false;
diff --git a/engines/asylum/resources/encounters.h b/engines/asylum/resources/encounters.h
index d435cff907..668fb44fad 100644
--- a/engines/asylum/resources/encounters.h
+++ b/engines/asylum/resources/encounters.h
@@ -168,6 +168,7 @@ private:
// Running encounter data
int32 _index;
int32 _speechResourceId;
+ ResourceId _soundResourceId;
EncounterItem *_item;
ObjectId _objectId1;
ObjectId _objectId2;
Commit: 40e5cc51a1ae1b1b25fc425a5715f03ed9eb8a41
https://github.com/scummvm/scummvm/commit/40e5cc51a1ae1b1b25fc425a5715f03ed9eb8a41
Author: xesfnet (xesfnet at gmail.com)
Date: 2021-05-17T15:37:31+02:00
Commit Message:
ASYLUM: Few encounter script fixes.
Changed paths:
engines/asylum/resources/encounters.cpp
diff --git a/engines/asylum/resources/encounters.cpp b/engines/asylum/resources/encounters.cpp
index 1f68b4d807..a1a56c07f4 100644
--- a/engines/asylum/resources/encounters.cpp
+++ b/engines/asylum/resources/encounters.cpp
@@ -1544,7 +1544,7 @@ void Encounter::runScript() {
case kOpcodeSetCurrentItemOptions:
if (entry.param1)
- _item->keywords[findKeyword(_item, entry.param2)] &= ~(kKeywordOptionsDisabled << 8);
+ _item->keywords[findKeyword(_item, entry.param2)] &= ~((kKeywordOptionsDisabled << 8) + 1);
else
_item->keywords[findKeyword(_item, entry.param2)] |= (kKeywordOptionsVisible << 8);
break;
@@ -1553,7 +1553,7 @@ void Encounter::runScript() {
if (entry.param1)
_item->keywords[findKeyword(_item, entry.param2)] |= (kKeywordOptionsDisabled << 8);
else
- _item->keywords[findKeyword(_item, entry.param2)] &= ~(kKeywordOptionsVisible << 8);
+ _item->keywords[findKeyword(_item, entry.param2)] &= ~((kKeywordOptionsVisible << 8) + 1);
break;
case kOpcodeSetItemOptions:
@@ -1643,7 +1643,7 @@ void Encounter::runScript() {
break;
case kOpcodeSetCounterFromActorReactions:
- _scriptData.counter = getScene()->getActor()->hasMoreReactions(getVariableInv(entry.param2), _scriptData.vars[1]) ? 0 : 1;
+ _scriptData.counter = getScene()->getActor()->hasMoreReactions(getVariableInv(entry.param2), _scriptData.vars[1]) ? 1 : 0;
break;
case kOpcodePrepareMovie:
Commit: c5ed6cb220450ae9a61eaa38b8a483fb3057d3a5
https://github.com/scummvm/scummvm/commit/c5ed6cb220450ae9a61eaa38b8a483fb3057d3a5
Author: xesfnet (xesfnet at gmail.com)
Date: 2021-05-17T15:37:31+02:00
Commit Message:
ASYLUM: Encounters script size has originl
Changed paths:
engines/asylum/resources/encounters.h
diff --git a/engines/asylum/resources/encounters.h b/engines/asylum/resources/encounters.h
index 668fb44fad..72ff173538 100644
--- a/engines/asylum/resources/encounters.h
+++ b/engines/asylum/resources/encounters.h
@@ -308,7 +308,7 @@ private:
};
struct ScriptData {
- int32 vars[10];
+ int32 vars[40];
uint32 offset;
int32 counter;
ResourceId resourceId;
Commit: 230054c0c39e64f44a6497e78ff50d8a5eb2257a
https://github.com/scummvm/scummvm/commit/230054c0c39e64f44a6497e78ff50d8a5eb2257a
Author: xesfnet (xesfnet at gmail.com)
Date: 2021-05-17T15:37:31+02:00
Commit Message:
ASYLUM: Added missing debug channels
Changed paths:
engines/asylum/asylum.cpp
diff --git a/engines/asylum/asylum.cpp b/engines/asylum/asylum.cpp
index 4924eb44f1..5c1f596764 100644
--- a/engines/asylum/asylum.cpp
+++ b/engines/asylum/asylum.cpp
@@ -86,6 +86,8 @@ AsylumEngine::AsylumEngine(OSystem *system, const ADGameDescription *gd) : Engin
DebugMan.addDebugChannel(kDebugLevelScene, "Scene", "Scene process and draw debugging");
DebugMan.addDebugChannel(kDebugLevelObjects, "Objects", "Debug Object objects");
DebugMan.addDebugChannel(kDebugLevelActor, "Actor", "Debug Actor");
+ DebugMan.addDebugChannel(kDebugLevelEncounter, "Encounter", "Debug Encounter");
+ DebugMan.addDebugChannel(kDebugLevelVideo, "Video", "Debug Video");
// Initialize random number source
_rnd = new Common::RandomSource("asylum");
Commit: 8ad1bcb8a970384a74e1891bbd2cae1b4bbd27cb
https://github.com/scummvm/scummvm/commit/8ad1bcb8a970384a74e1891bbd2cae1b4bbd27cb
Author: Joseph Davies (deledrius at gmail.com)
Date: 2021-05-17T15:37:31+02:00
Commit Message:
ASYLUM: Rename variables to match changes to AdvancedMetaEngine.
Follows guideline-conforming changes in 0b6befdcc5f5f.
Changed paths:
engines/asylum/detection.cpp
diff --git a/engines/asylum/detection.cpp b/engines/asylum/detection.cpp
index 61edc9c4d7..d5773c74a0 100644
--- a/engines/asylum/detection.cpp
+++ b/engines/asylum/detection.cpp
@@ -132,9 +132,9 @@ static const ADFileBasedFallback fileBasedFallback[] = {
class AsylumMetaEngine : public AdvancedMetaEngine {
public:
AsylumMetaEngine() : AdvancedMetaEngine(Asylum::gameDescriptions, sizeof(ADGameDescription), asylumGames) {
- _singleid = "asylum";
+ _singleId = "asylum";
_md5Bytes = 0;
- _guioptions = GUIO1(GUIO_NONE);
+ _guiOptions = GUIO1(GUIO_NONE);
}
virtual const char *getName() const {
Commit: ffe854efe7e35df48235d9020f0b277d36a6574b
https://github.com/scummvm/scummvm/commit/ffe854efe7e35df48235d9020f0b277d36a6574b
Author: D G Turner (digitall at scummvm.org)
Date: 2021-05-17T15:37:32+02:00
Commit Message:
ASYLUM: Fix Various GCC Compiler Warnings.
Changed paths:
engines/asylum/puzzles/boardsalvation.cpp
engines/asylum/puzzles/boardyouth.cpp
engines/asylum/puzzles/pipes.cpp
diff --git a/engines/asylum/puzzles/boardsalvation.cpp b/engines/asylum/puzzles/boardsalvation.cpp
index af0016cdae..933c7583ce 100644
--- a/engines/asylum/puzzles/boardsalvation.cpp
+++ b/engines/asylum/puzzles/boardsalvation.cpp
@@ -47,7 +47,8 @@ static const PuzzleBoard::PuzzleData puzzleSalvationData = {
{'A', Common::Point( 66, 199)},
{'T', Common::Point(436, 229)},
{'O', Common::Point(172, 262)},
- {'N', Common::Point(393, 296)}},
+ {'N', Common::Point(393, 296)},
+ {'\0', Common::Point(0, 0)}},
false,
"S A L V A T I O N "
};
diff --git a/engines/asylum/puzzles/boardyouth.cpp b/engines/asylum/puzzles/boardyouth.cpp
index 69ff2cf915..4d6b12711e 100644
--- a/engines/asylum/puzzles/boardyouth.cpp
+++ b/engines/asylum/puzzles/boardyouth.cpp
@@ -42,7 +42,9 @@ static const PuzzleBoard::PuzzleData puzzleYouthData = {
{'H', Common::Point(417, 152)},
{'T', Common::Point(223, 181)},
{'H', Common::Point(497, 198)},
- {'Y', Common::Point(435, 231)}},
+ {'Y', Common::Point(435, 231)},
+ {'\0', Common::Point(0, 0)},
+ {'\0', Common::Point(0, 0)}},
true,
"T H E Y O U T H "
};
diff --git a/engines/asylum/puzzles/pipes.cpp b/engines/asylum/puzzles/pipes.cpp
index 76a6ba40e2..5110da74cc 100644
--- a/engines/asylum/puzzles/pipes.cpp
+++ b/engines/asylum/puzzles/pipes.cpp
@@ -554,7 +554,7 @@ void PuzzlePipes::setup() {
if (i) {
_frameIndexSpider = new uint32[_spiders.size()];
- memset(_frameIndexSpider, 0, sizeof(_frameIndexSpider));
+ memset(_frameIndexSpider, 0, _spiders.size()*sizeof(uint32));
}
startUpWater();
Commit: 79ef1c65dd14e942560381ec389324743688e568
https://github.com/scummvm/scummvm/commit/79ef1c65dd14e942560381ec389324743688e568
Author: D G Turner (digitall at scummvm.org)
Date: 2021-05-17T15:37:32+02:00
Commit Message:
ASYLUM: Fix Compilation Due to initGraphics Function API.
Changed paths:
engines/asylum/asylum.cpp
diff --git a/engines/asylum/asylum.cpp b/engines/asylum/asylum.cpp
index 5c1f596764..81b90cc114 100644
--- a/engines/asylum/asylum.cpp
+++ b/engines/asylum/asylum.cpp
@@ -123,7 +123,7 @@ AsylumEngine::~AsylumEngine() {
Common::Error AsylumEngine::run() {
// Initialize the graphics
- initGraphics(640, 480, true);
+ initGraphics(640, 480);
// Create debugger. It requires GFX to be initialized
_console = new Console(this);
Commit: 86eee35eb4c1183a57f469d97fd58ea12dc2f84e
https://github.com/scummvm/scummvm/commit/86eee35eb4c1183a57f469d97fd58ea12dc2f84e
Author: D G Turner (digitall at scummvm.org)
Date: 2021-05-17T15:37:32+02:00
Commit Message:
ASYLUM: Correct Compilation On Newer GCC.
The abs() function returns double, but the ScummVM common/util version
should be used instead which is ABS().
Changed paths:
engines/asylum/system/screen.cpp
diff --git a/engines/asylum/system/screen.cpp b/engines/asylum/system/screen.cpp
index 16983da6ce..3a6328857a 100644
--- a/engines/asylum/system/screen.cpp
+++ b/engines/asylum/system/screen.cpp
@@ -940,7 +940,7 @@ void Screen::blitMasked(GraphicFrame *frame, Common::Rect *source, byte *maskDat
byte *mirroredBuffer = NULL;
int16 frameRight = frame->surface.pitch;
uint16 maskHeight = (uint16)sourceMask->height(); // for debugging only
- byte zoom = abs(sourceMask->left) & 7;
+ byte zoom = ABS(sourceMask->left) & 7;
// Prepare temporary source buffer if needed
if (flags & kDrawFlagMirrorLeftRight) {
Commit: a9ef5fe57a3f0968c5fb6027de6a8bdb8f7a2f9c
https://github.com/scummvm/scummvm/commit/a9ef5fe57a3f0968c5fb6027de6a8bdb8f7a2f9c
Author: Alex Bevilacqua (alex at alexbevi.com)
Date: 2021-05-17T15:37:32+02:00
Commit Message:
ASYLUM: fix fallback detection
Changed paths:
engines/asylum/detection.cpp
diff --git a/engines/asylum/detection.cpp b/engines/asylum/detection.cpp
index d5773c74a0..1b432f5583 100644
--- a/engines/asylum/detection.cpp
+++ b/engines/asylum/detection.cpp
@@ -150,12 +150,12 @@ public:
virtual int getMaximumSaveSlot() const;
virtual void removeSaveState(const char *target, int slot) const;
-protected:
- virtual bool createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const;
-
- virtual const ADGameDescription *fallbackDetect(const FileMap &allFiles, const Common::FSList &fslist) const {
+ ADDetectedGame fallbackDetect(const FileMap &allFiles, const Common::FSList &fslist) const
+ {
return detectGameFilebased(allFiles, fslist, Asylum::fileBasedFallback);
}
+protected:
+ virtual bool createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const;
};
bool AsylumMetaEngine::hasFeature(MetaEngineFeature f) const {
Commit: 19d343e82f332e5fdef95cc3ba6abede73bce171
https://github.com/scummvm/scummvm/commit/19d343e82f332e5fdef95cc3ba6abede73bce171
Author: Joseph Davies (deledrius at gmail.com)
Date: 2021-05-17T15:37:32+02:00
Commit Message:
ASYLUM: Split detection features & adapt to new plugins.
Changed paths:
A engines/asylum/metaengine.cpp
engines/asylum/asylum.h
engines/asylum/detection.cpp
engines/asylum/module.mk
diff --git a/engines/asylum/asylum.h b/engines/asylum/asylum.h
index 07f905e13a..0a999fedf1 100644
--- a/engines/asylum/asylum.h
+++ b/engines/asylum/asylum.h
@@ -49,7 +49,7 @@
* - Walking is partialy implemented but the primitive pathfinding is missing
*
* Maintainers:
- * alexbevi, alexandrefontoura, bluegr, littleboy, midstream
+ * alexbevi, alexandrefontoura, bluegr, littleboy, midstream, deledrius
*
* Supported games:
* - Sanitarium
diff --git a/engines/asylum/detection.cpp b/engines/asylum/detection.cpp
index 1b432f5583..6e99a6db51 100644
--- a/engines/asylum/detection.cpp
+++ b/engines/asylum/detection.cpp
@@ -20,178 +20,104 @@
*
*/
-#include "common/config-manager.h"
#include "engines/advancedDetector.h"
-#include "common/savefile.h"
-#include "common/system.h"
-
-#include "asylum/asylum.h"
+#include "base/plugins.h"
static const PlainGameDescriptor asylumGames[] = {
- { "asylum", "Sanitarium" },
+ { "sanitarium", "Sanitarium" },
{ 0, 0 }
};
namespace Asylum {
static const ADGameDescription gameDescriptions[] = {
- {
- // Sanitarium - English Demo
- "asylum",
- "Demo",
- {
- {"SNTRM.DAT", 0, "6a8079e0b49affc99d148624fbb584a1", 326},
- {"RES.000", 0, "57446ce089c6f9decb7f3faf41d09edf", 9022},
- {0,0,0,0}
- },
- Common::EN_ANY,
- Common::kPlatformWindows,
- ADGF_DEMO|ADGF_UNSTABLE,
- GUIO1(GUIO_NONE)
+
+ // Sanitarium - English Demo
+ { "sanitarium", "Demo", {
+ {"SNTRM.DAT", 0, "6a8079e0b49affc99d148624fbb584a1", 326},
+ {"RES.000", 0, "57446ce089c6f9decb7f3faf41d09edf", 9022},
+ AD_LISTEND},
+ Common::EN_ANY, Common::kPlatformWindows, ADGF_DEMO | ADGF_UNSTABLE, GUIO0()
},
- {
- "asylum",
- "Unpatched",
- {
- {"SNTRM.DAT", 0, "7cfcc457c1f579fbf9878ac175d29374", 8930},
- {"RES.000", 0, "4d13f1412f9e7dd3eaf0a58f0e00e662", 272057},
- {"SCN.006", 0, "71a5f49cbda597a11e877589075e27b5", 2918330},
- {0,0,0,0}
- },
- Common::EN_ANY,
- Common::kPlatformWindows,
- ADGF_UNSTABLE,
- GUIO1(GUIO_NONE)
+
+ { "sanitarium", "Unpatched",{
+ {"SNTRM.DAT", 0, "7cfcc457c1f579fbf9878ac175d29374", 8930},
+ {"RES.000", 0, "4d13f1412f9e7dd3eaf0a58f0e00e662", 272057},
+ {"SCN.006", 0, "71a5f49cbda597a11e877589075e27b5", 2918330},
+ AD_LISTEND},
+ Common::EN_ANY, Common::kPlatformWindows, ADGF_UNSTABLE, GUIO0()
},
- {
- "asylum",
- "Patched", // Level 2 Lockout Bug patch was applied
- {
- {"SNTRM.DAT", 0, "7cfcc457c1f579fbf9878ac175d29374", 8930},
- {"RES.000", 0, "4d13f1412f9e7dd3eaf0a58f0e00e662", 272057},
- {"SCN.006", 0, "3a5b54da08198012dc0614114782d5fb", 2918330},
- {0,0,0,0}
- },
- Common::EN_ANY,
- Common::kPlatformWindows,
- ADGF_UNSTABLE,
- GUIO1(GUIO_NONE)
+
+ // Level 2 Lockout Bug patch was applied
+ { "sanitarium", "Patched", {
+ {"SNTRM.DAT", 0, "7cfcc457c1f579fbf9878ac175d29374", 8930},
+ {"RES.000", 0, "4d13f1412f9e7dd3eaf0a58f0e00e662", 272057},
+ {"SCN.006", 0, "3a5b54da08198012dc0614114782d5fb", 2918330},
+ AD_LISTEND}, Common::EN_ANY, Common::kPlatformWindows, ADGF_UNSTABLE, GUIO0()
},
- {
- "asylum",
- "GOG.com",
- {
- {"SNTRM.DAT", 0, "7cfcc457c1f579fbf9878ac175d29374", 8930},
- {"RES.000", 0, "f58f8dc3e63663f174977d359e11132c", 272057},
- {"SCN.006", 0, "3a5b54da08198012dc0614114782d5fb", 2918330},
- {0,0,0,0}
- },
- Common::EN_ANY,
- Common::kPlatformWindows,
- ADGF_UNSTABLE,
- GUIO1(GUIO_NONE)
+
+ { "sanitarium", "GOG.com", {
+ {"SNTRM.DAT", 0, "7cfcc457c1f579fbf9878ac175d29374", 8930},
+ {"RES.000", 0, "f58f8dc3e63663f174977d359e11132c", 272057},
+ {"SCN.006", 0, "3a5b54da08198012dc0614114782d5fb", 2918330},
+ AD_LISTEND},
+ Common::EN_ANY, Common::kPlatformWindows, ADGF_UNSTABLE, GUIO0()
},
- {
- "asylum",
- "French Version",
- {
- {"SNTRM.DAT", 0, "e09a12543c6ede1727c8ecffb74e7fd2", 8930},
- {"RES.000", 0, "2a4677ee3fd7bfa3161e16cd59371238", 277931},
- {"SCN.006", 0, "3a5b54da08198012dc0614114782d5fb", 2918330},
- {0,0,0,0}
- },
- Common::FR_FRA,
- Common::kPlatformWindows,
- ADGF_UNSTABLE,
- GUIO1(GUIO_NONE)
+
+ { "sanitarium", "French Version", {
+ {"SNTRM.DAT", 0, "e09a12543c6ede1727c8ecffb74e7fd2", 8930},
+ {"RES.000", 0, "2a4677ee3fd7bfa3161e16cd59371238", 277931},
+ {"SCN.006", 0, "3a5b54da08198012dc0614114782d5fb", 2918330},
+ AD_LISTEND},
+ Common::FR_FRA, Common::kPlatformWindows, ADGF_UNSTABLE, GUIO0()
},
- {
- "asylum",
- "Russian Version",
- {
- {"SNTRM.DAT", 0, "7cfcc457c1f579fbf9878ac175d29374", 8930},
- {"RES.000", 0, "1f8a262bf8b3035bd3cfda24068c4651", 263624},
- {"SCN.006", 0, "3a5b54da08198012dc0614114782d5fb", 2918330},
- {0,0,0,0}
- },
- Common::RU_RUS,
- Common::kPlatformWindows,
- ADGF_UNSTABLE,
- GUIO1(GUIO_NONE)
+
+ { "sanitarium", "Russian Version", {
+ {"SNTRM.DAT", 0, "7cfcc457c1f579fbf9878ac175d29374", 8930},
+ {"RES.000", 0, "1f8a262bf8b3035bd3cfda24068c4651", 263624},
+ {"SCN.006", 0, "3a5b54da08198012dc0614114782d5fb", 2918330},
+ AD_LISTEND},
+ Common::RU_RUS, Common::kPlatformWindows, ADGF_UNSTABLE, GUIO0()
},
- AD_TABLE_END_MARKER
-};
+
+ AD_TABLE_END_MARKER};
static const ADFileBasedFallback fileBasedFallback[] = {
- { &gameDescriptions[0], { "SNTRM.DAT", 0 } }, // default to english version
- { 0, { 0 } }
+ { &Asylum::gameDescriptions[0], { "SNTRM.DAT", 0 } }, // default to english version
+ { 0, {0} } };
+
+
+static const char *directoryGlobs[] = {
+ "Data",
+ 0
};
} // End of namespace Asylum
-class AsylumMetaEngine : public AdvancedMetaEngine {
+
+class AsylumMetaEngineStatic : public AdvancedMetaEngineStatic {
public:
- AsylumMetaEngine() : AdvancedMetaEngine(Asylum::gameDescriptions, sizeof(ADGameDescription), asylumGames) {
- _singleId = "asylum";
+ AsylumMetaEngineStatic() : AdvancedMetaEngineStatic(Asylum::gameDescriptions, sizeof(ADGameDescription), asylumGames) {
_md5Bytes = 0;
- _guiOptions = GUIO1(GUIO_NONE);
+ _maxScanDepth = 2;
+ _directoryGlobs = Asylum::directoryGlobs;
}
- virtual const char *getName() const {
- return "Asylum";
+ ADDetectedGame fallbackDetect(const FileMap &allFiles, const Common::FSList &fslist) const override {
+ return detectGameFilebased(allFiles, Asylum::fileBasedFallback);
}
- virtual const char *getOriginalCopyright() const {
- return "Sanitarium (c) ASC Games";
+ const char *getEngineId() const override {
+ return "asylum";
}
- virtual bool hasFeature(MetaEngineFeature f) const;
- virtual SaveStateList listSaves(const char *target) const;
- virtual int getMaximumSaveSlot() const;
- virtual void removeSaveState(const char *target, int slot) const;
+ const char *getName() const override {
+ return "Asylum";
+ }
- ADDetectedGame fallbackDetect(const FileMap &allFiles, const Common::FSList &fslist) const
- {
- return detectGameFilebased(allFiles, fslist, Asylum::fileBasedFallback);
+ const char *getOriginalCopyright() const override {
+ return "Sanitarium (c) ASC Games";
}
-protected:
- virtual bool createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const;
};
-bool AsylumMetaEngine::hasFeature(MetaEngineFeature f) const {
- return (f == kSupportsListSaves) ||
- (f == kSupportsLoadingDuringStartup) ||
- (f == kSupportsDeleteSave);
-}
-
-bool Asylum::AsylumEngine::hasFeature(EngineFeature f) const {
- return (f == kSupportsRTL) ||
- (f == kSupportsLoadingDuringRuntime) ||
- (f == kSupportsSavingDuringRuntime) ||
- (f == kSupportsSubtitleOptions);
-}
-
-bool AsylumMetaEngine::createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const {
- if (desc) {
- *engine = new Asylum::AsylumEngine(syst, desc);
- }
- return desc != 0;
-}
-
-SaveStateList AsylumMetaEngine::listSaves(const char * /*target*/) const {
- error("[AsylumMetaEngine::listSaves] Not implemented");
-}
-
-int AsylumMetaEngine::getMaximumSaveSlot() const {
- error("[AsylumMetaEngine::getMaximumSaveSlot] Not implemented");
-}
-
-void AsylumMetaEngine::removeSaveState(const char * /*target*/, int /*slot*/) const {
- error("[AsylumMetaEngine::removeSaveState] Not implemented");
-}
-
-#if PLUGIN_ENABLED_DYNAMIC(ASYLUM)
-REGISTER_PLUGIN_DYNAMIC(ASYLUM, PLUGIN_TYPE_ENGINE, AsylumMetaEngine);
-#else
-REGISTER_PLUGIN_STATIC(ASYLUM, PLUGIN_TYPE_ENGINE, AsylumMetaEngine);
-#endif
+REGISTER_PLUGIN_STATIC(ASYLUM_DETECTION, PLUGIN_TYPE_METAENGINE, AsylumMetaEngineStatic);
diff --git a/engines/asylum/metaengine.cpp b/engines/asylum/metaengine.cpp
new file mode 100644
index 0000000000..4271b8f62b
--- /dev/null
+++ b/engines/asylum/metaengine.cpp
@@ -0,0 +1,85 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "engines/advancedDetector.h"
+#include "base/plugins.h"
+
+#include "asylum/asylum.h"
+
+
+class AsylumMetaEngine : public AdvancedMetaEngine {
+public:
+ virtual const char *getName() const {
+ return "Asylum";
+ }
+
+ virtual const char *getOriginalCopyright() const {
+ return "Sanitarium (c) ASC Games";
+ }
+
+ bool createInstance(OSystem *syst, Engine **engine, const ADGameDescription *gd) const override;
+ virtual bool hasFeature(MetaEngineFeature f) const;
+ virtual SaveStateList listSaves(const char *target) const;
+ virtual int getMaximumSaveSlot() const;
+ virtual void removeSaveState(const char *target, int slot) const;
+};
+
+bool AsylumMetaEngine::hasFeature(MetaEngineFeature f) const {
+ return
+ (f == kSupportsListSaves) ||
+ (f == kSupportsLoadingDuringStartup) ||
+ (f == kSupportsDeleteSave);
+}
+
+bool Asylum::AsylumEngine::hasFeature(EngineFeature f) const {
+ return
+ (f == kSupportsReturnToLauncher) ||
+ (f == kSupportsLoadingDuringRuntime) ||
+ (f == kSupportsSavingDuringRuntime) ||
+ (f == kSupportsSubtitleOptions);
+}
+
+bool AsylumMetaEngine::createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const {
+ if (desc) {
+ *engine = new Asylum::AsylumEngine(syst, desc);
+ }
+ return desc != 0;
+}
+
+SaveStateList AsylumMetaEngine::listSaves(const char * /*target*/) const {
+ error("[AsylumMetaEngine::listSaves] Not implemented");
+}
+
+int AsylumMetaEngine::getMaximumSaveSlot() const {
+ error("[AsylumMetaEngine::getMaximumSaveSlot] Not implemented");
+}
+
+void AsylumMetaEngine::removeSaveState(const char * /*target*/, int /*slot*/) const {
+ error("[AsylumMetaEngine::removeSaveState] Not implemented");
+}
+
+
+#if PLUGIN_ENABLED_DYNAMIC(ASYLUM)
+ REGISTER_PLUGIN_DYNAMIC(ASYLUM, PLUGIN_TYPE_ENGINE, AsylumMetaEngine);
+#else
+ REGISTER_PLUGIN_STATIC(ASYLUM, PLUGIN_TYPE_ENGINE, AsylumMetaEngine);
+#endif
diff --git a/engines/asylum/module.mk b/engines/asylum/module.mk
index 149ec0949f..e466a05c04 100644
--- a/engines/asylum/module.mk
+++ b/engines/asylum/module.mk
@@ -43,7 +43,7 @@ MODULE_OBJS := \
views/video.o \
asylum.o \
console.o \
- detection.o \
+ metaengine.o \
respack.o
# This module can be built as a plugin
@@ -53,3 +53,6 @@ endif
# Include common rules
include $(srcdir)/rules.mk
+
+# Detection objects
+DETECT_OBJS += $(MODULE)/detection.o
Commit: 9195e58c337188c2a8025f3adbc32d558c3ce5cc
https://github.com/scummvm/scummvm/commit/9195e58c337188c2a8025f3adbc32d558c3ce5cc
Author: Joseph Davies (deledrius at gmail.com)
Date: 2021-05-17T15:37:32+02:00
Commit Message:
ASYLUM: Modify data search paths to match canonical locations.
Changed paths:
engines/asylum/asylum.cpp
diff --git a/engines/asylum/asylum.cpp b/engines/asylum/asylum.cpp
index 81b90cc114..c7ce83429c 100644
--- a/engines/asylum/asylum.cpp
+++ b/engines/asylum/asylum.cpp
@@ -71,8 +71,8 @@ AsylumEngine::AsylumEngine(OSystem *system, const ADGameDescription *gd) : Engin
// Add default search directories
const Common::FSNode gameDataDir(ConfMan.get("path"));
SearchMan.addSubDirectoryMatching(gameDataDir, "data");
- SearchMan.addSubDirectoryMatching(gameDataDir, "vids");
- SearchMan.addSubDirectoryMatching(gameDataDir, "music");
+ SearchMan.addSubDirectoryMatching(gameDataDir, "data/vids");
+ SearchMan.addSubDirectoryMatching(gameDataDir, "data/music");
// Initialize custom debug levels
DebugMan.addDebugChannel(kDebugLevelMain, "Main", "Generic debug level");
Commit: e20a8bc6b1342c88a8eb34b430fdc6f64f31e3e6
https://github.com/scummvm/scummvm/commit/e20a8bc6b1342c88a8eb34b430fdc6f64f31e3e6
Author: alxpnv (alxpnv22 at yahoo.com)
Date: 2021-05-17T15:37:32+02:00
Commit Message:
ASYLUM: check param2
Changed paths:
engines/asylum/resources/script.cpp
diff --git a/engines/asylum/resources/script.cpp b/engines/asylum/resources/script.cpp
index cb8106800a..4b206a0ee2 100644
--- a/engines/asylum/resources/script.cpp
+++ b/engines/asylum/resources/script.cpp
@@ -936,7 +936,7 @@ END_OPCODE
IMPLEMENT_OPCODE(JumpIfActorField638)
Actor *actor = getScene()->getActor(cmd->param1);
- if (actor->getField638())
+ if (actor->getField638() != cmd->param2)
_currentQueueEntry->currentLine = cmd->param3;
END_OPCODE
Commit: 49941a57b4397953e82efc39df6c3700ebfed604
https://github.com/scummvm/scummvm/commit/49941a57b4397953e82efc39df6c3700ebfed604
Author: alxpnv (alxpnv22 at yahoo.com)
Date: 2021-05-17T15:37:33+02:00
Commit Message:
ASYLUM: use max index instead of count
Changed paths:
engines/asylum/views/scene.cpp
diff --git a/engines/asylum/views/scene.cpp b/engines/asylum/views/scene.cpp
index 4efda0b549..4f13d8758c 100644
--- a/engines/asylum/views/scene.cpp
+++ b/engines/asylum/views/scene.cpp
@@ -1661,19 +1661,17 @@ void Scene::playerReaction() {
player->adjustCoordinates(&point);
- uint32 maxIndex;
- for (maxIndex = 0; maxIndex < 8; maxIndex++) {
- if (!player->getReactionValue(maxIndex))
+ uint32 count;
+ for (count = 0; count < 8; count++) {
+ if (!player->getReactionValue(count))
break;
}
- maxIndex -= 1;
-
player->setField638(0);
- if (maxIndex > 0) {
- for (uint32 i = 0; i < maxIndex; i++) {
- Common::Point ret = _vm->getSinCosValues(maxIndex, i);
+ if (count > 0) {
+ for (uint32 i = 0; i < count; i++) {
+ Common::Point ret = _vm->getSinCosValues(count, i);
int32 x = point.x + player->getPoint2()->x + ret.x;
int32 y = point.y + player->getPoint2()->y / 2 - ret.y;
Commit: 3c533863320022ca08b79c27d7a10cc05ad0c4f0
https://github.com/scummvm/scummvm/commit/3c533863320022ca08b79c27d7a10cc05ad0c4f0
Author: alxpnv (alxpnv22 at yahoo.com)
Date: 2021-05-17T15:37:33+02:00
Commit Message:
ASYLUM: fix an index
Changed paths:
engines/asylum/resources/actor.cpp
diff --git a/engines/asylum/resources/actor.cpp b/engines/asylum/resources/actor.cpp
index 501088a301..6bac1cd59b 100644
--- a/engines/asylum/resources/actor.cpp
+++ b/engines/asylum/resources/actor.cpp
@@ -2002,7 +2002,7 @@ void Actor::updateAndDraw() {
adjustCoordinates(&coords);
Common::Point sinCos = _vm->getSinCosValues(count, i);
- Common::Point point = coords + Common::Point(player->getPoint2()->x + sinCos.x, player->getPoint2()->y / 2 - sinCos.y);
+ Common::Point point = coords + Common::Point(player->getPoint2()->x + sinCos.x, player->getPoint2()->y / 2 - sinCos.y - 20);
if (mouse.x < point.x || mouse.x > (point.x + 40) || mouse.y < point.y || mouse.y > (point.y + 40)) {
getScreen()->addGraphicToQueue(getWorld()->cursorResourcesAlternate[_reaction[i] + 15],
@@ -2020,7 +2020,7 @@ void Actor::updateAndDraw() {
getWorld()->field_120 = i + 1;
keepField = true;
- getScreen()->addGraphicToQueue(getWorld()->cursorResourcesAlternate[_reaction[i]],
+ getScreen()->addGraphicToQueue(getWorld()->cursorResourcesAlternate[_reaction[i] - 1],
0,
point,
kDrawFlagNone,
Commit: 4f7978b24308b909894a67b3ffe9cd45cda8a075
https://github.com/scummvm/scummvm/commit/4f7978b24308b909894a67b3ffe9cd45cda8a075
Author: alxpnv (alxpnv22 at yahoo.com)
Date: 2021-05-17T15:37:33+02:00
Commit Message:
ASYLUM: rework removeReactionHive
Changed paths:
engines/asylum/resources/actor.cpp
diff --git a/engines/asylum/resources/actor.cpp b/engines/asylum/resources/actor.cpp
index 6bac1cd59b..b4db9084db 100644
--- a/engines/asylum/resources/actor.cpp
+++ b/engines/asylum/resources/actor.cpp
@@ -1855,18 +1855,18 @@ void Actor::removeReactionHive(int32 reactionIndex, int32 numberValue01Substract
if (!numberValue01Substract || !_numberValue01) {
- uint32 count = 0;
- for (int i = 0; i < 8; i++)
- if (_reaction[i])
- count++;
+ uint32 i = 0;
+ for (i = 0; i < 8; i++)
+ if (_reaction[i] == reactionIndex)
+ break;
- if (count == 8)
+ if (i == 8)
return;
- if (count == 7) {
+ if (i == 7) {
_reaction[7] = 0;
} else {
- memcpy(&_reaction[count], &_reaction[count + 1], 28 - 4 * count);
+ memmove(&_reaction[i], &_reaction[i + 1], 32 - 4 * i);
_reaction[7] = 0;
}
}
Commit: 5bed7c1c554d5977421d8b7993f1e76aac5418c7
https://github.com/scummvm/scummvm/commit/5bed7c1c554d5977421d8b7993f1e76aac5418c7
Author: alxpnv (alxpnv22 at yahoo.com)
Date: 2021-05-17T15:37:33+02:00
Commit Message:
ASYLUM: sync with removeReactionHive
Changed paths:
engines/asylum/resources/actor.cpp
diff --git a/engines/asylum/resources/actor.cpp b/engines/asylum/resources/actor.cpp
index b4db9084db..736db9d54f 100644
--- a/engines/asylum/resources/actor.cpp
+++ b/engines/asylum/resources/actor.cpp
@@ -1834,7 +1834,7 @@ void Actor::addReactionHive(int32 reactionIndex, int32 numberValue01Add) {
if (count == 8)
return;
- if (!hasMoreReactions(reactionIndex, false))
+ if (!numberValue01Add || !_numberValue01)
_reaction[count] = reactionIndex;
if (numberValue01Add)
Commit: 88f63359e803b4cfc83ae3a039107f8b946a48a9
https://github.com/scummvm/scummvm/commit/88f63359e803b4cfc83ae3a039107f8b946a48a9
Author: alxpnv (alxpnv22 at yahoo.com)
Date: 2021-05-17T15:37:33+02:00
Commit Message:
ASYLUM: align keywords
Changed paths:
engines/asylum/resources/encounters.cpp
diff --git a/engines/asylum/resources/encounters.cpp b/engines/asylum/resources/encounters.cpp
index a1a56c07f4..efc7a168ef 100644
--- a/engines/asylum/resources/encounters.cpp
+++ b/engines/asylum/resources/encounters.cpp
@@ -599,7 +599,7 @@ int32 Encounter::getKeywordIndex() {
if ((_item->keywords[index] & KEYWORD_MASK) > 0 && isKeywordVisible(_item->keywords[index])) {
int32 x = _drawingStructs[0].point1.y + 145 * (counter % 3) + _point.x + _portrait1.rect.width() + 15;
- int32 y = 16 * counter / 3 + _point.y + 5;
+ int32 y = 16 * (counter / 3) + _point.y + 5;
if (mousePos.x >= x && mousePos.x <= (x + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 3681 + (_item->keywords[index] & KEYWORD_MASK))))
&& mousePos.y >= y && mousePos.y <= (y + 16))
@@ -1122,8 +1122,8 @@ void Encounter::drawDialogOptions() {
else
getText()->loadFont(getWorld()->font1);
- Common::Point coords(_drawingStructs[0].point1.y + 144 * (counter % 3) + _point.x + (counter % 3) + _portrait1.rect.width() + 15,
- _point.y + (int16)(16 * counter / 3));
+ Common::Point coords(_drawingStructs[0].point1.y + 145 * (counter % 3) + _point.x + (counter % 3) + _portrait1.rect.width() + 15,
+ _point.y + (int16)(16 * (counter / 3)));
if (getKeywordIndex() == keywordIndex)
getScreen()->fillRect(coords.x - 1, coords.y + 5, getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 3681 + (keyword & KEYWORD_MASK))), 18, 0);
Commit: 8157fc35ab1ea19d657265df95ee1edb9b366444
https://github.com/scummvm/scummvm/commit/8157fc35ab1ea19d657265df95ee1edb9b366444
Author: alxpnv (alxpnv22 at yahoo.com)
Date: 2021-05-17T15:37:33+02:00
Commit Message:
ASYLUM: missing comma
Changed paths:
engines/asylum/resources/encounters.cpp
diff --git a/engines/asylum/resources/encounters.cpp b/engines/asylum/resources/encounters.cpp
index efc7a168ef..f68b898616 100644
--- a/engines/asylum/resources/encounters.cpp
+++ b/engines/asylum/resources/encounters.cpp
@@ -48,7 +48,7 @@ namespace Asylum {
const char *opcodeNames[] = {
"Return",
"SetScriptVariable",
- "SetCounterFromVars"
+ "SetCounterFromVars",
"SetOffset",
"SetOffsetIfCounterNegative",
"SetOffsetIfCounterNegativeOrNull",
Commit: 87205c935e25c19c821331fc31f99f60fa0feea0
https://github.com/scummvm/scummvm/commit/87205c935e25c19c821331fc31f99f60fa0feea0
Author: alxpnv (alxpnv22 at yahoo.com)
Date: 2021-05-17T15:37:34+02:00
Commit Message:
ASYLUM: reset text data at return
Changed paths:
engines/asylum/resources/encounters.cpp
diff --git a/engines/asylum/resources/encounters.cpp b/engines/asylum/resources/encounters.cpp
index f68b898616..c17cb42d58 100644
--- a/engines/asylum/resources/encounters.cpp
+++ b/engines/asylum/resources/encounters.cpp
@@ -1486,6 +1486,7 @@ void Encounter::runScript() {
_isScriptRunning = false;
done = true;
_value1 = 0;
+ getSpeech()->resetTextData();
break;
case kOpcodeSetScriptVariable:
Commit: c7b652226c3cdbbc68f803f579e2175310845082
https://github.com/scummvm/scummvm/commit/c7b652226c3cdbbc68f803f579e2175310845082
Author: alxpnv (alxpnv22 at yahoo.com)
Date: 2021-05-17T15:37:34+02:00
Commit Message:
ASYLUM: unify script offset
Changed paths:
engines/asylum/resources/encounters.cpp
diff --git a/engines/asylum/resources/encounters.cpp b/engines/asylum/resources/encounters.cpp
index c17cb42d58..034dba42c9 100644
--- a/engines/asylum/resources/encounters.cpp
+++ b/engines/asylum/resources/encounters.cpp
@@ -1505,14 +1505,14 @@ void Encounter::runScript() {
if (_scriptData.counter >= 0)
break;
- _scriptData.offset = entry.param2;
+ _scriptData.offset = entry.param2 - 1;
break;
case kOpcodeSetOffsetIfCounterNegativeOrNull:
if (_scriptData.counter > 0)
break;
- _scriptData.offset = entry.param2;
+ _scriptData.offset = entry.param2 - 1;
break;
case kOpcodeSetOffsetIfCounterIsNull:
@@ -1526,14 +1526,14 @@ void Encounter::runScript() {
if (!_scriptData.counter)
break;
- _scriptData.offset = entry.param2;
+ _scriptData.offset = entry.param2 - 1;
break;
case kOpcodeSetOffsetIfCounterPositiveOrNull:
if (_scriptData.counter < 0)
break;
- _scriptData.offset = entry.param2;
+ _scriptData.offset = entry.param2 - 1;
break;
case kOpcodeSetOffsetIfCounterPositive:
Commit: 994fb8133d0c09d2b8877c3ec522880b4215be62
https://github.com/scummvm/scummvm/commit/994fb8133d0c09d2b8877c3ec522880b4215be62
Author: alxpnv (alxpnv22 at yahoo.com)
Date: 2021-05-17T15:37:34+02:00
Commit Message:
ASYLUM: unloop dialogs
Changed paths:
engines/asylum/resources/encounters.cpp
diff --git a/engines/asylum/resources/encounters.cpp b/engines/asylum/resources/encounters.cpp
index 034dba42c9..c17456f149 100644
--- a/engines/asylum/resources/encounters.cpp
+++ b/engines/asylum/resources/encounters.cpp
@@ -457,14 +457,17 @@ bool Encounter::update() {
bool doScript = false;
if ((_soundResourceId/*getSpeech()->getSoundResourceId()*/ && !getSound()->isPlaying(_soundResourceId/*getSpeech()->getSoundResourceId()*/) && !_data_455BE0) // TODO replace with speech
- || (getSpeech()->getTick() && tick >= getSpeech()->getTick()))
+ /*|| (getSpeech()->getTick() && tick >= getSpeech()->getTick())*/)
doScript = true;
if (doScript
&& !getSharedData()->getMatteBarHeight()
- && _isScriptRunning
- && !setupSpeechTest(id))
- runScript();
+ && _isScriptRunning) {
+ if (getSpeech()->getTextData() && _objectId1)
+ setupSpeechTest(id);
+ else
+ runScript();
+ }
}
// Redraw screen
Commit: af823c01ee4b2f239d5c6f3c8e89398c765587e7
https://github.com/scummvm/scummvm/commit/af823c01ee4b2f239d5c6f3c8e89398c765587e7
Author: alxpnv (alxpnv22 at yahoo.com)
Date: 2021-05-17T15:37:34+02:00
Commit Message:
ASYLUM: fix build
Changed paths:
engines/asylum/detection.cpp
engines/asylum/metaengine.cpp
diff --git a/engines/asylum/detection.cpp b/engines/asylum/detection.cpp
index 6e99a6db51..6d80d51bec 100644
--- a/engines/asylum/detection.cpp
+++ b/engines/asylum/detection.cpp
@@ -24,7 +24,7 @@
#include "base/plugins.h"
static const PlainGameDescriptor asylumGames[] = {
- { "sanitarium", "Sanitarium" },
+ { "asylum", "Sanitarium" },
{ 0, 0 }
};
@@ -33,14 +33,14 @@ namespace Asylum {
static const ADGameDescription gameDescriptions[] = {
// Sanitarium - English Demo
- { "sanitarium", "Demo", {
+ { "asylum", "Demo", {
{"SNTRM.DAT", 0, "6a8079e0b49affc99d148624fbb584a1", 326},
{"RES.000", 0, "57446ce089c6f9decb7f3faf41d09edf", 9022},
AD_LISTEND},
Common::EN_ANY, Common::kPlatformWindows, ADGF_DEMO | ADGF_UNSTABLE, GUIO0()
},
- { "sanitarium", "Unpatched",{
+ { "asylum", "Unpatched",{
{"SNTRM.DAT", 0, "7cfcc457c1f579fbf9878ac175d29374", 8930},
{"RES.000", 0, "4d13f1412f9e7dd3eaf0a58f0e00e662", 272057},
{"SCN.006", 0, "71a5f49cbda597a11e877589075e27b5", 2918330},
@@ -49,14 +49,14 @@ static const ADGameDescription gameDescriptions[] = {
},
// Level 2 Lockout Bug patch was applied
- { "sanitarium", "Patched", {
+ { "asylum", "Patched", {
{"SNTRM.DAT", 0, "7cfcc457c1f579fbf9878ac175d29374", 8930},
{"RES.000", 0, "4d13f1412f9e7dd3eaf0a58f0e00e662", 272057},
{"SCN.006", 0, "3a5b54da08198012dc0614114782d5fb", 2918330},
AD_LISTEND}, Common::EN_ANY, Common::kPlatformWindows, ADGF_UNSTABLE, GUIO0()
},
- { "sanitarium", "GOG.com", {
+ { "asylum", "GOG.com", {
{"SNTRM.DAT", 0, "7cfcc457c1f579fbf9878ac175d29374", 8930},
{"RES.000", 0, "f58f8dc3e63663f174977d359e11132c", 272057},
{"SCN.006", 0, "3a5b54da08198012dc0614114782d5fb", 2918330},
@@ -64,7 +64,7 @@ static const ADGameDescription gameDescriptions[] = {
Common::EN_ANY, Common::kPlatformWindows, ADGF_UNSTABLE, GUIO0()
},
- { "sanitarium", "French Version", {
+ { "asylum", "French Version", {
{"SNTRM.DAT", 0, "e09a12543c6ede1727c8ecffb74e7fd2", 8930},
{"RES.000", 0, "2a4677ee3fd7bfa3161e16cd59371238", 277931},
{"SCN.006", 0, "3a5b54da08198012dc0614114782d5fb", 2918330},
@@ -72,7 +72,7 @@ static const ADGameDescription gameDescriptions[] = {
Common::FR_FRA, Common::kPlatformWindows, ADGF_UNSTABLE, GUIO0()
},
- { "sanitarium", "Russian Version", {
+ { "asylum", "Russian Version", {
{"SNTRM.DAT", 0, "7cfcc457c1f579fbf9878ac175d29374", 8930},
{"RES.000", 0, "1f8a262bf8b3035bd3cfda24068c4651", 263624},
{"SCN.006", 0, "3a5b54da08198012dc0614114782d5fb", 2918330},
@@ -95,29 +95,29 @@ static const char *directoryGlobs[] = {
} // End of namespace Asylum
-class AsylumMetaEngineStatic : public AdvancedMetaEngineStatic {
+class AsylumMetaEngineDetection : public AdvancedMetaEngineDetection {
public:
- AsylumMetaEngineStatic() : AdvancedMetaEngineStatic(Asylum::gameDescriptions, sizeof(ADGameDescription), asylumGames) {
+ AsylumMetaEngineDetection() : AdvancedMetaEngineDetection(Asylum::gameDescriptions, sizeof(ADGameDescription), asylumGames) {
_md5Bytes = 0;
_maxScanDepth = 2;
_directoryGlobs = Asylum::directoryGlobs;
}
- ADDetectedGame fallbackDetect(const FileMap &allFiles, const Common::FSList &fslist) const override {
+ ADDetectedGame fallbackDetect(const FileMap &allFiles, const Common::FSList &fslist) const {
return detectGameFilebased(allFiles, Asylum::fileBasedFallback);
}
- const char *getEngineId() const override {
+ const char *getEngineId() const {
return "asylum";
}
- const char *getName() const override {
+ const char *getName() const {
return "Asylum";
}
- const char *getOriginalCopyright() const override {
+ const char *getOriginalCopyright() const {
return "Sanitarium (c) ASC Games";
}
};
-REGISTER_PLUGIN_STATIC(ASYLUM_DETECTION, PLUGIN_TYPE_METAENGINE, AsylumMetaEngineStatic);
+REGISTER_PLUGIN_STATIC(ASYLUM_DETECTION, PLUGIN_TYPE_ENGINE_DETECTION, AsylumMetaEngineDetection);
diff --git a/engines/asylum/metaengine.cpp b/engines/asylum/metaengine.cpp
index 4271b8f62b..d666f6f48a 100644
--- a/engines/asylum/metaengine.cpp
+++ b/engines/asylum/metaengine.cpp
@@ -28,7 +28,7 @@
class AsylumMetaEngine : public AdvancedMetaEngine {
public:
- virtual const char *getName() const {
+ virtual const char *getName() const override {
return "Asylum";
}
@@ -36,11 +36,11 @@ public:
return "Sanitarium (c) ASC Games";
}
- bool createInstance(OSystem *syst, Engine **engine, const ADGameDescription *gd) const override;
- virtual bool hasFeature(MetaEngineFeature f) const;
- virtual SaveStateList listSaves(const char *target) const;
- virtual int getMaximumSaveSlot() const;
- virtual void removeSaveState(const char *target, int slot) const;
+ Common::Error createInstance(OSystem *syst, Engine **engine, const ADGameDescription *gd) const override;
+ virtual bool hasFeature(MetaEngineFeature f) const override;
+ virtual SaveStateList listSaves(const char *target) const override;
+ virtual int getMaximumSaveSlot() const override;
+ virtual void removeSaveState(const char *target, int slot) const override;
};
bool AsylumMetaEngine::hasFeature(MetaEngineFeature f) const {
@@ -58,11 +58,11 @@ bool Asylum::AsylumEngine::hasFeature(EngineFeature f) const {
(f == kSupportsSubtitleOptions);
}
-bool AsylumMetaEngine::createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const {
+Common::Error AsylumMetaEngine::createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const {
if (desc) {
*engine = new Asylum::AsylumEngine(syst, desc);
}
- return desc != 0;
+ return desc ? Common::kNoError : Common::kUnsupportedGameidError;
}
SaveStateList AsylumMetaEngine::listSaves(const char * /*target*/) const {
Commit: 19712bac19da24041380aeb9affa18bfe589105d
https://github.com/scummvm/scummvm/commit/19712bac19da24041380aeb9affa18bfe589105d
Author: alxpnv (alxpnv22 at yahoo.com)
Date: 2021-05-17T15:37:34+02:00
Commit Message:
ASYLUM: restore palette when VCR puzzle is completed
Changed paths:
engines/asylum/puzzles/vcr.cpp
diff --git a/engines/asylum/puzzles/vcr.cpp b/engines/asylum/puzzles/vcr.cpp
index e8feab089b..b14720455b 100644
--- a/engines/asylum/puzzles/vcr.cpp
+++ b/engines/asylum/puzzles/vcr.cpp
@@ -357,8 +357,8 @@ void PuzzleVCR::updateScreen(const AsylumEvent &) {
// setupPalette();
getScreen()->setupPalette(NULL, 0, 0);
- warning("[PuzzleVCR::updateScreen] Missing palette changes");
- // TODO more stuff needed here (palette change, scene screen update, etc.)
+ getScreen()->setPalette(MAKE_RESOURCE(kResourcePackTowerCells, 28));
+ getScreen()->setGammaLevel(MAKE_RESOURCE(kResourcePackTowerCells, 28));
} else {
getScreen()->drawGraphicsInQueue();
}
Commit: c08da99266ed3dbccf487f03f27bcbda5d3c7e17
https://github.com/scummvm/scummvm/commit/c08da99266ed3dbccf487f03f27bcbda5d3c7e17
Author: alxpnv (alxpnv22 at yahoo.com)
Date: 2021-05-17T15:37:34+02:00
Commit Message:
ASYLUM: add a workaround to handle action areas intersection
Changed paths:
engines/asylum/views/scene.cpp
diff --git a/engines/asylum/views/scene.cpp b/engines/asylum/views/scene.cpp
index 4f13d8758c..3d703b7cb0 100644
--- a/engines/asylum/views/scene.cpp
+++ b/engines/asylum/views/scene.cpp
@@ -2166,6 +2166,8 @@ int32 Scene::findActionArea(ActionAreaType type, const Common::Point &pt, bool h
if (!_polygons)
error("[Scene::findActionArea] Polygons not initialized properly!");
+ Common::Array<int32> areaIds;
+
switch (type) {
default:
return type - 2;
@@ -2204,7 +2206,7 @@ int32 Scene::findActionArea(ActionAreaType type, const Common::Point &pt, bool h
}
if (!found && _polygons->get(area->polygonIndex).contains(pt))
- return i;
+ areaIds.push_back(i);
}
break;
@@ -2235,12 +2237,21 @@ int32 Scene::findActionArea(ActionAreaType type, const Common::Point &pt, bool h
}
if (!found && _polygons->get(area->polygonIndex).contains(pt))
- return i;
+ areaIds.push_back(i);
}
break;
}
- return -1;
+ if (areaIds.empty()) {
+ return -1;
+ } else {
+ int32 i;
+ for (i = 0; i < areaIds.size(); i++)
+ if (_ws->actions[i]->flags)
+ break;
+
+ return (i == areaIds.size()) ? areaIds[0] : areaIds[i];
+ }
}
void Scene::changePlayer(ActorIndex index) {
Commit: ae58cb534ddd9afbc5b93c8603396aef3fe45ef2
https://github.com/scummvm/scummvm/commit/ae58cb534ddd9afbc5b93c8603396aef3fe45ef2
Author: alxpnv (alxpnv22 at yahoo.com)
Date: 2021-05-17T15:37:34+02:00
Commit Message:
ASYLUM: re-enable the console
Changed paths:
engines/asylum/asylum.cpp
diff --git a/engines/asylum/asylum.cpp b/engines/asylum/asylum.cpp
index c7ce83429c..ce7417e7e3 100644
--- a/engines/asylum/asylum.cpp
+++ b/engines/asylum/asylum.cpp
@@ -127,6 +127,7 @@ Common::Error AsylumEngine::run() {
// Create debugger. It requires GFX to be initialized
_console = new Console(this);
+ setDebugger(_console);
// Create resource manager
_resource = new ResourceManager();
Commit: 051213bad5933ca170aa258d087405979bb3c140
https://github.com/scummvm/scummvm/commit/051213bad5933ca170aa258d087405979bb3c140
Author: alxpnv (alxpnv22 at yahoo.com)
Date: 2021-05-17T15:37:35+02:00
Commit Message:
ASYLUM: fix ActionArea::toString()
Changed paths:
engines/asylum/resources/script.h
diff --git a/engines/asylum/resources/script.h b/engines/asylum/resources/script.h
index c932e0ea6e..98f7bac1bf 100644
--- a/engines/asylum/resources/script.h
+++ b/engines/asylum/resources/script.h
@@ -107,8 +107,8 @@ struct ActionArea : public Common::Serializable {
Common::String output;
output += Common::String::format("Action %d: %s\n", id, name);
- output += Common::String::format(" flags=%d scriptIndex=%d scriptIndex2=%d type=%d\n", flags, scriptIndex, actionType, polygonIndex);
- output += Common::String::format(" sound=%d polygon=%d palette=%d volume=%d\n", soundResourceId, scriptIndex2, paletteResourceId, volume);
+ output += Common::String::format(" flags=%d scriptIndex=%d scriptIndex2=%d type=%d\n", flags, scriptIndex, scriptIndex2, actionType);
+ output += Common::String::format(" sound=%d polygon=%d palette=%d volume=%d\n", soundResourceId, polygonIndex, paletteResourceId, volume);
output += Common::String::format(" field01=%d field02=%d field40=%d field44=%d\n", field01, field02, field_40, field_44);
output += Common::String::format(" field7C=%d field84=%d field88=%d field90=%d\n", field_7C, soundResourceIdFrame, field_88, field_90);
Commit: 9f5008b18db1acde092ee9c28f0e8b4ceac2be2f
https://github.com/scummvm/scummvm/commit/9f5008b18db1acde092ee9c28f0e8b4ceac2be2f
Author: alxpnv (alxpnv22 at yahoo.com)
Date: 2021-05-17T15:37:35+02:00
Commit Message:
ASYLUM: set a game flag when the Pipes puzzle is solved
Changed paths:
engines/asylum/puzzles/pipes.cpp
diff --git a/engines/asylum/puzzles/pipes.cpp b/engines/asylum/puzzles/pipes.cpp
index 5110da74cc..f1d8a20e9a 100644
--- a/engines/asylum/puzzles/pipes.cpp
+++ b/engines/asylum/puzzles/pipes.cpp
@@ -386,7 +386,6 @@ bool PuzzlePipes::update(const AsylumEvent &) {
}
}
- // TODO: turn the fountain on
if (filled == 4) {
if (_levelFlags[0])
getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[40], 0, Common::Point(233, 416), kDrawFlagNone, 0, 1);
@@ -435,7 +434,9 @@ bool PuzzlePipes::update(const AsylumEvent &) {
getScreen()->copyBackBufferToScreen();
updateCursor();
- if (_isLeverReady && !_levelFlags[4]) {
+ if (_isLeverReady) {
+ if (!_levelFlags[4])
+ _vm->setGameFlag((GameFlag)(96 + checkFlags()));
getScreen()->clear();
getSound()->stop(getWorld()->graphicResourceIds[41]);
getSound()->setMusicVolume(_previousMusicVolume);
Commit: 560d0a68ad93476345a8412099678179e12765d0
https://github.com/scummvm/scummvm/commit/560d0a68ad93476345a8412099678179e12765d0
Author: alxpnv (alxpnv22 at yahoo.com)
Date: 2021-05-17T15:37:35+02:00
Commit Message:
ASYLUM: don't reset the Pipes puzzle's data each time it's being run
Changed paths:
engines/asylum/puzzles/pipes.cpp
diff --git a/engines/asylum/puzzles/pipes.cpp b/engines/asylum/puzzles/pipes.cpp
index f1d8a20e9a..00f5987753 100644
--- a/engines/asylum/puzzles/pipes.cpp
+++ b/engines/asylum/puzzles/pipes.cpp
@@ -311,8 +311,10 @@ PuzzlePipes::PuzzlePipes(AsylumEngine *engine) : Puzzle(engine) {
_isLeverReady = false;
memset(&_sinks, 0, sizeof(_sinks));
memset(&_sources, 0, sizeof(_sources));
-
_frameIndexSpider = NULL;
+
+ initResources();
+ setup();
}
PuzzlePipes::~PuzzlePipes() {
@@ -342,9 +344,6 @@ bool PuzzlePipes::init(const AsylumEvent &) {
_rectIndex = -2;
- initResources();
- setup();
-
return true;
}
Commit: 6678429e4928c150d36e6243bfd7b8c56362a6af
https://github.com/scummvm/scummvm/commit/6678429e4928c150d36e6243bfd7b8c56362a6af
Author: alxpnv (alxpnv22 at yahoo.com)
Date: 2021-05-17T15:37:35+02:00
Commit Message:
ASYLUM: reorder PuzzlePipes::_connectors to match the original
Changed paths:
engines/asylum/puzzles/pipes.cpp
diff --git a/engines/asylum/puzzles/pipes.cpp b/engines/asylum/puzzles/pipes.cpp
index 00f5987753..0f6db4003c 100644
--- a/engines/asylum/puzzles/pipes.cpp
+++ b/engines/asylum/puzzles/pipes.cpp
@@ -38,26 +38,32 @@ namespace Asylum {
const Common::Point connectorPoints[] = {
Common::Point(158, 59),
+ Common::Point(163, 172),
+ Common::Point(168, 272),
+
Common::Point(202, 59),
- Common::Point(271, 60),
- Common::Point(380, 72),
Common::Point(205, 132),
- Common::Point(272, 131),
- Common::Point(469, 119),
- Common::Point(163, 172),
Common::Point(206, 172),
+
+ Common::Point(271, 60),
+ Common::Point(272, 131),
+ Common::Point(273, 262),
+
Common::Point(318, 169),
- Common::Point(360, 171),
- Common::Point(428, 172),
- Common::Point(466, 171),
Common::Point(319, 206),
- Common::Point(360, 206),
- Common::Point(168, 272),
- Common::Point(273, 262),
Common::Point(318, 261),
+
+ Common::Point(380, 72),
+ Common::Point(360, 171),
+ Common::Point(360, 206),
+
+ Common::Point(428, 172),
Common::Point(401, 242),
Common::Point(399, 295),
- Common::Point(460, 294)
+
+ Common::Point(469, 119),
+ Common::Point(466, 171),
+ Common::Point(460, 294),
};
const Common::Point peepholePoints[] = {
@@ -519,30 +525,30 @@ void PuzzlePipes::setup() {
}
_connectors[ 0].init( NULL, _peepholes + 4, _peepholes + 6, _peepholes + 0, kBinNum0110);
- _connectors[ 1].init( NULL, _peepholes + 5, _peepholes + 7, _peepholes + 4, kBinNum0110);
- _connectors[ 2].init( NULL, _peepholes + 1, _peepholes + 8, _peepholes + 5, kBinNum0110);
- _connectors[ 3].init(_peepholes + 2, _peepholes + 10, NULL, _peepholes + 9, kBinNum0011);
- _connectors[ 4].init(_peepholes + 7, _peepholes + 11, NULL, NULL, kBinNum0011, _connectors + 8, kDirectionSh);
- _connectors[ 5].init(_peepholes + 8, _peepholes + 12, _peepholes + 25, _peepholes + 11, kBinNum0111);
- _connectors[ 6].init(_peepholes + 3, NULL, _peepholes + 14, _peepholes + 13, kBinNum1100);
- _connectors[ 7].init(_peepholes + 6, _peepholes + 15, _peepholes + 23, NULL, kBinNum0110);
- _connectors[ 8].init( NULL, _peepholes + 18, _peepholes + 24, _peepholes + 15, kBinNum0111, _connectors + 4, kDirectionNh);
+ _connectors[ 1].init(_peepholes + 6, _peepholes + 15, _peepholes + 23, NULL, kBinNum0110);
+ _connectors[ 2].init(_peepholes + 23, _peepholes + 24, _peepholes + 33, NULL, kBinNum0011);
+ _connectors[ 3].init( NULL, _peepholes + 5, _peepholes + 7, _peepholes + 4, kBinNum0110);
+ _connectors[ 4].init(_peepholes + 7, _peepholes + 11, NULL, NULL, kBinNum0011, _connectors + 5, kDirectionSh);
+ _connectors[ 5].init( NULL, _peepholes + 18, _peepholes + 24, _peepholes + 15, kBinNum0111, _connectors + 4, kDirectionNh);
+ _connectors[ 6].init( NULL, _peepholes + 1, _peepholes + 8, _peepholes + 5, kBinNum0110);
+ _connectors[ 7].init(_peepholes + 8, _peepholes + 12, _peepholes + 25, _peepholes + 11, kBinNum0111);
+ _connectors[ 8].init(_peepholes + 25, _peepholes + 29, _peepholes + 34, _peepholes + 18, kBinNum1011);
_connectors[ 9].init(_peepholes + 9, _peepholes + 16, _peepholes + 19, _peepholes + 12, kBinNum1110);
- _connectors[10].init(_peepholes + 13, _peepholes + 17, NULL, _peepholes + 16, kBinNum0111, _connectors + 14, kDirectionSh);
- _connectors[11].init(_peepholes + 10, NULL, _peepholes + 22, _peepholes + 17, kBinNum0101, _connectors + 12, kDirectionEt);
- _connectors[12].init(_peepholes + 14, NULL, _peepholes + 28, NULL, kBinNum1001, _connectors + 11, kDirectionWt);
- _connectors[13].init(_peepholes + 19, _peepholes + 20, _peepholes + 26, NULL, kBinNum0011);
- _connectors[14].init( NULL, _peepholes + 21, _peepholes + 27, _peepholes + 20, kBinNum1110, _connectors + 10, kDirectionNh);
- _connectors[15].init(_peepholes + 23, _peepholes + 24, _peepholes + 33, NULL, kBinNum0011);
- _connectors[16].init(_peepholes + 25, _peepholes + 29, _peepholes + 34, _peepholes + 18, kBinNum1011);
- _connectors[17].init(_peepholes + 26, _peepholes + 31, _peepholes + 35, _peepholes + 29, kBinNum1011);
- _connectors[18].init(_peepholes + 21, _peepholes + 22, _peepholes + 30, _peepholes + 27, kBinNum1011);
- _connectors[19].init(_peepholes + 30, _peepholes + 32, NULL, _peepholes + 31, kBinNum0011);
+ _connectors[10].init(_peepholes + 19, _peepholes + 20, _peepholes + 26, NULL, kBinNum0011);
+ _connectors[11].init(_peepholes + 26, _peepholes + 31, _peepholes + 35, _peepholes + 29, kBinNum1011);
+ _connectors[12].init(_peepholes + 2, _peepholes + 10, NULL, _peepholes + 9, kBinNum0011);
+ _connectors[13].init(_peepholes + 13, _peepholes + 17, NULL, _peepholes + 16, kBinNum0111, _connectors + 14, kDirectionSh);
+ _connectors[14].init( NULL, _peepholes + 21, _peepholes + 27, _peepholes + 20, kBinNum1110, _connectors + 13, kDirectionNh);
+ _connectors[15].init(_peepholes + 10, NULL, _peepholes + 22, _peepholes + 17, kBinNum0101, _connectors + 19, kDirectionEt);
+ _connectors[16].init(_peepholes + 21, _peepholes + 22, _peepholes + 30, _peepholes + 27, kBinNum1011);
+ _connectors[17].init(_peepholes + 30, _peepholes + 32, NULL, _peepholes + 31, kBinNum0011);
+ _connectors[18].init(_peepholes + 3, NULL, _peepholes + 14, _peepholes + 13, kBinNum1100);
+ _connectors[19].init(_peepholes + 14, NULL, _peepholes + 28, NULL, kBinNum1001, _connectors + 15, kDirectionWt);
_connectors[20].init(_peepholes + 28, NULL, _peepholes + 36, _peepholes + 32, kBinNum1001);
_connectors[ 4].initGroup();
- _connectors[10].initGroup();
- _connectors[11].initGroup();
+ _connectors[13].initGroup();
+ _connectors[17].initGroup();
uint32 i = rnd(kBinNum0111);
if (i & kBinNum0001)
Commit: c232bc5dec8f5dad074c10326e561d92bf249324
https://github.com/scummvm/scummvm/commit/c232bc5dec8f5dad074c10326e561d92bf249324
Author: alxpnv (alxpnv22 at yahoo.com)
Date: 2021-05-17T15:37:35+02:00
Commit Message:
ASYLUM: fix a wrong index
Changed paths:
engines/asylum/puzzles/pipes.cpp
diff --git a/engines/asylum/puzzles/pipes.cpp b/engines/asylum/puzzles/pipes.cpp
index 0f6db4003c..e05f0c0f6e 100644
--- a/engines/asylum/puzzles/pipes.cpp
+++ b/engines/asylum/puzzles/pipes.cpp
@@ -548,7 +548,7 @@ void PuzzlePipes::setup() {
_connectors[ 4].initGroup();
_connectors[13].initGroup();
- _connectors[17].initGroup();
+ _connectors[15].initGroup();
uint32 i = rnd(kBinNum0111);
if (i & kBinNum0001)
Commit: eb9443461ece48053837942fd5b107201869ebc1
https://github.com/scummvm/scummvm/commit/eb9443461ece48053837942fd5b107201869ebc1
Author: Alexandre Fontoura (xesfnet at gmail.com)
Date: 2021-05-17T15:37:35+02:00
Commit Message:
ASYLUM: gitignore build files
Changed paths:
A engines/asylum/.gitignore
diff --git a/engines/asylum/.gitignore b/engines/asylum/.gitignore
new file mode 100644
index 0000000000..33ab213e8a
--- /dev/null
+++ b/engines/asylum/.gitignore
@@ -0,0 +1,3 @@
+.deps
+*.o
+*.a
Commit: 30109163b46e674eca1ed50991be368ce6aa5150
https://github.com/scummvm/scummvm/commit/30109163b46e674eca1ed50991be368ce6aa5150
Author: Alexandre Fontoura (xesfnet at gmail.com)
Date: 2021-05-17T15:37:36+02:00
Commit Message:
ASYLUM: Fixed MacOS crash. Poll Events not allowed outside the main thread.
Changed paths:
engines/asylum/system/screen.cpp
diff --git a/engines/asylum/system/screen.cpp b/engines/asylum/system/screen.cpp
index 3a6328857a..d5942ac798 100644
--- a/engines/asylum/system/screen.cpp
+++ b/engines/asylum/system/screen.cpp
@@ -490,11 +490,6 @@ void Screen::paletteFadeWorker(ResourceId id, int32 ticksWait, int32 delta) {
if (_fadeStop)
break;
- // Poll events (this ensure we don't freeze the screen)
- Common::Event ev;
- do {
- } while (_vm->getEventManager()->pollEvent(ev));
-
// Refresh the screen
g_system->updateScreen();
}
Commit: bbceb7b09845ef434ae841b6b1f75f7277d86f98
https://github.com/scummvm/scummvm/commit/bbceb7b09845ef434ae841b6b1f75f7277d86f98
Author: Alexandre Fontoura (xesfnet at gmail.com)
Date: 2021-05-17T15:37:36+02:00
Commit Message:
ASYLUM: Skip intro speech
Changed paths:
engines/asylum/asylum.cpp
diff --git a/engines/asylum/asylum.cpp b/engines/asylum/asylum.cpp
index ce7417e7e3..964976ea4e 100644
--- a/engines/asylum/asylum.cpp
+++ b/engines/asylum/asylum.cpp
@@ -294,15 +294,28 @@ void AsylumEngine::playIntro() {
ResourceId introSpeech = MAKE_RESOURCE(kResourcePackSound, 7);
_sound->playSound(introSpeech);
+ int8 skip = 0;
do {
// Poll events (this ensures we don't freeze the screen)
Common::Event ev;
- _eventMan->pollEvent(ev);
+ while(_eventMan->pollEvent(ev)) {
+ switch (ev.type) {
+ case Common::EVENT_LBUTTONDOWN:
+ case Common::EVENT_KEYDOWN:
+ skip = true;
+ break;
+ default:
+ break;
+ }
+ }
_system->delayMillis(100);
- } while (_sound->isPlaying(introSpeech));
-
+ } while (_sound->isPlaying(introSpeech) && !skip);
+
+ if (_sound->isPlaying(introSpeech)) {
+ _sound->stop(introSpeech);
+ }
}
_cursor->setForceHide(false);
_introPlayed = true;
Commit: bc16fa16b710df1f0008a561ef13d8c5ea046fc4
https://github.com/scummvm/scummvm/commit/bc16fa16b710df1f0008a561ef13d8c5ea046fc4
Author: Alexandre Fontoura (xesfnet at gmail.com)
Date: 2021-05-17T15:37:36+02:00
Commit Message:
ASYLUM: Game detection improvements
Changed paths:
A engines/asylum/detection_table.h
engines/asylum/detection.cpp
engines/asylum/metaengine.cpp
diff --git a/engines/asylum/detection.cpp b/engines/asylum/detection.cpp
index 6d80d51bec..40f40d883d 100644
--- a/engines/asylum/detection.cpp
+++ b/engines/asylum/detection.cpp
@@ -22,78 +22,7 @@
#include "engines/advancedDetector.h"
#include "base/plugins.h"
-
-static const PlainGameDescriptor asylumGames[] = {
- { "asylum", "Sanitarium" },
- { 0, 0 }
-};
-
-namespace Asylum {
-
-static const ADGameDescription gameDescriptions[] = {
-
- // Sanitarium - English Demo
- { "asylum", "Demo", {
- {"SNTRM.DAT", 0, "6a8079e0b49affc99d148624fbb584a1", 326},
- {"RES.000", 0, "57446ce089c6f9decb7f3faf41d09edf", 9022},
- AD_LISTEND},
- Common::EN_ANY, Common::kPlatformWindows, ADGF_DEMO | ADGF_UNSTABLE, GUIO0()
- },
-
- { "asylum", "Unpatched",{
- {"SNTRM.DAT", 0, "7cfcc457c1f579fbf9878ac175d29374", 8930},
- {"RES.000", 0, "4d13f1412f9e7dd3eaf0a58f0e00e662", 272057},
- {"SCN.006", 0, "71a5f49cbda597a11e877589075e27b5", 2918330},
- AD_LISTEND},
- Common::EN_ANY, Common::kPlatformWindows, ADGF_UNSTABLE, GUIO0()
- },
-
- // Level 2 Lockout Bug patch was applied
- { "asylum", "Patched", {
- {"SNTRM.DAT", 0, "7cfcc457c1f579fbf9878ac175d29374", 8930},
- {"RES.000", 0, "4d13f1412f9e7dd3eaf0a58f0e00e662", 272057},
- {"SCN.006", 0, "3a5b54da08198012dc0614114782d5fb", 2918330},
- AD_LISTEND}, Common::EN_ANY, Common::kPlatformWindows, ADGF_UNSTABLE, GUIO0()
- },
-
- { "asylum", "GOG.com", {
- {"SNTRM.DAT", 0, "7cfcc457c1f579fbf9878ac175d29374", 8930},
- {"RES.000", 0, "f58f8dc3e63663f174977d359e11132c", 272057},
- {"SCN.006", 0, "3a5b54da08198012dc0614114782d5fb", 2918330},
- AD_LISTEND},
- Common::EN_ANY, Common::kPlatformWindows, ADGF_UNSTABLE, GUIO0()
- },
-
- { "asylum", "French Version", {
- {"SNTRM.DAT", 0, "e09a12543c6ede1727c8ecffb74e7fd2", 8930},
- {"RES.000", 0, "2a4677ee3fd7bfa3161e16cd59371238", 277931},
- {"SCN.006", 0, "3a5b54da08198012dc0614114782d5fb", 2918330},
- AD_LISTEND},
- Common::FR_FRA, Common::kPlatformWindows, ADGF_UNSTABLE, GUIO0()
- },
-
- { "asylum", "Russian Version", {
- {"SNTRM.DAT", 0, "7cfcc457c1f579fbf9878ac175d29374", 8930},
- {"RES.000", 0, "1f8a262bf8b3035bd3cfda24068c4651", 263624},
- {"SCN.006", 0, "3a5b54da08198012dc0614114782d5fb", 2918330},
- AD_LISTEND},
- Common::RU_RUS, Common::kPlatformWindows, ADGF_UNSTABLE, GUIO0()
- },
-
- AD_TABLE_END_MARKER};
-
-static const ADFileBasedFallback fileBasedFallback[] = {
- { &Asylum::gameDescriptions[0], { "SNTRM.DAT", 0 } }, // default to english version
- { 0, {0} } };
-
-
-static const char *directoryGlobs[] = {
- "Data",
- 0
-};
-
-} // End of namespace Asylum
-
+#include "asylum/detection_table.h"
class AsylumMetaEngineDetection : public AdvancedMetaEngineDetection {
public:
@@ -112,7 +41,7 @@ public:
}
const char *getName() const {
- return "Asylum";
+ return "Sanitarium";
}
const char *getOriginalCopyright() const {
diff --git a/engines/asylum/detection_table.h b/engines/asylum/detection_table.h
new file mode 100644
index 0000000000..15dc0f8f0b
--- /dev/null
+++ b/engines/asylum/detection_table.h
@@ -0,0 +1,129 @@
+/* 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.
+ *
+ */
+
+static const PlainGameDescriptor asylumGames[] = {
+ { "asylum", "Sanitarium" },
+ { 0, 0 }
+};
+
+namespace Asylum {
+
+static const char *directoryGlobs[] = {
+ "Data",
+ 0
+};
+
+
+static const ADGameDescription gameDescriptions[] = {
+ {
+ // Sanitarium - English Demo
+ "asylum",
+ "Demo",
+ {
+ {"SNTRM.DAT", 0, "6a8079e0b49affc99d148624fbb584a1", 326},
+ {"RES.000", 0, "57446ce089c6f9decb7f3faf41d09edf", 9022},
+ {0,0,0,0}
+ },
+ Common::EN_ANY,
+ Common::kPlatformWindows,
+ ADGF_DEMO|ADGF_UNSTABLE,
+ GUIO1(GUIO_NONE)
+ },
+ {
+ "asylum",
+ "Unpatched",
+ {
+ {"SNTRM.DAT", 0, "7cfcc457c1f579fbf9878ac175d29374", 8930},
+ {"RES.000", 0, "4d13f1412f9e7dd3eaf0a58f0e00e662", 272057},
+ {"SCN.006", 0, "71a5f49cbda597a11e877589075e27b5", 2918330},
+ {0,0,0,0}
+ },
+ Common::EN_ANY,
+ Common::kPlatformWindows,
+ ADGF_UNSTABLE,
+ GUIO1(GUIO_NONE)
+ },
+ {
+ "asylum",
+ "Patched", // Level 2 Lockout Bug patch was applied
+ {
+ {"SNTRM.DAT", 0, "7cfcc457c1f579fbf9878ac175d29374", 8930},
+ {"RES.000", 0, "4d13f1412f9e7dd3eaf0a58f0e00e662", 272057},
+ {"SCN.006", 0, "3a5b54da08198012dc0614114782d5fb", 2918330},
+ {0,0,0,0}
+ },
+ Common::EN_ANY,
+ Common::kPlatformWindows,
+ ADGF_UNSTABLE,
+ GUIO1(GUIO_NONE)
+ },
+ {
+ "asylum",
+ "GOG.com",
+ {
+ {"SNTRM.DAT", 0, "7cfcc457c1f579fbf9878ac175d29374", 8930},
+ {"RES.000", 0, "f58f8dc3e63663f174977d359e11132c", 272057},
+ {"SCN.006", 0, "3a5b54da08198012dc0614114782d5fb", 2918330},
+ {0,0,0,0}
+ },
+ Common::EN_ANY,
+ Common::kPlatformWindows,
+ ADGF_UNSTABLE,
+ GUIO1(GUIO_NONE)
+ },
+ {
+ "asylum",
+ "French Version",
+ {
+ {"SNTRM.DAT", 0, "e09a12543c6ede1727c8ecffb74e7fd2", 8930},
+ {"RES.000", 0, "2a4677ee3fd7bfa3161e16cd59371238", 277931},
+ {"SCN.006", 0, "3a5b54da08198012dc0614114782d5fb", 2918330},
+ {0,0,0,0}
+ },
+ Common::FR_FRA,
+ Common::kPlatformWindows,
+ ADGF_UNSTABLE,
+ GUIO1(GUIO_NONE)
+ },
+ {
+ "asylum",
+ "Russian Version",
+ {
+ {"SNTRM.DAT", 0, "7cfcc457c1f579fbf9878ac175d29374", 8930},
+ {"RES.000", 0, "1f8a262bf8b3035bd3cfda24068c4651", 263624},
+ {"SCN.006", 0, "3a5b54da08198012dc0614114782d5fb", 2918330},
+ {0,0,0,0}
+ },
+ Common::RU_RUS,
+ Common::kPlatformWindows,
+ ADGF_UNSTABLE,
+ GUIO1(GUIO_NONE)
+ },
+ AD_TABLE_END_MARKER
+};
+
+static const ADFileBasedFallback fileBasedFallback[] = {
+ { &gameDescriptions[0], { "SNTRM.DAT", 0 } }, // default to english version
+ { 0, { 0 } }
+};
+
+} // End of namespace Asylum
diff --git a/engines/asylum/metaengine.cpp b/engines/asylum/metaengine.cpp
index d666f6f48a..8cde9ec03a 100644
--- a/engines/asylum/metaengine.cpp
+++ b/engines/asylum/metaengine.cpp
@@ -29,7 +29,7 @@
class AsylumMetaEngine : public AdvancedMetaEngine {
public:
virtual const char *getName() const override {
- return "Asylum";
+ return "Sanitairum";
}
virtual const char *getOriginalCopyright() const {
Commit: 1f473eedfe42f8865dd11d8a59e7a5edcb80649a
https://github.com/scummvm/scummvm/commit/1f473eedfe42f8865dd11d8a59e7a5edcb80649a
Author: Alexandre Fontoura (xesfnet at gmail.com)
Date: 2021-05-17T15:37:36+02:00
Commit Message:
ASYLUM: Fixed metaengine mistake
Changed paths:
engines/asylum/metaengine.cpp
diff --git a/engines/asylum/metaengine.cpp b/engines/asylum/metaengine.cpp
index 8cde9ec03a..f615568070 100644
--- a/engines/asylum/metaengine.cpp
+++ b/engines/asylum/metaengine.cpp
@@ -29,7 +29,7 @@
class AsylumMetaEngine : public AdvancedMetaEngine {
public:
virtual const char *getName() const override {
- return "Sanitairum";
+ return "asylum";
}
virtual const char *getOriginalCopyright() const {
Commit: 28cbd2b28e83b444c89afdc3f28b6b124b08e60a
https://github.com/scummvm/scummvm/commit/28cbd2b28e83b444c89afdc3f28b6b124b08e60a
Author: Alexandre Fontoura (xesfnet at gmail.com)
Date: 2021-05-17T15:37:36+02:00
Commit Message:
ASYLUM: cleanup some warnings
Changed paths:
engines/asylum/resources/actor.cpp
engines/asylum/resources/encounters.h
engines/asylum/system/cursor.cpp
engines/asylum/system/savegame.cpp
engines/asylum/views/menu.h
engines/asylum/views/scenetitle.cpp
engines/asylum/views/scenetitle.h
diff --git a/engines/asylum/resources/actor.cpp b/engines/asylum/resources/actor.cpp
index 736db9d54f..2a4c3f2b08 100644
--- a/engines/asylum/resources/actor.cpp
+++ b/engines/asylum/resources/actor.cpp
@@ -1246,7 +1246,7 @@ bool Actor::process(const Common::Point &point) {
}
if (point.y == sum.y) {
- ActorDirection actorDir = (a3 != 0 || a3 != 3) ? kDirectionE : kDirectionW;
+ ActorDirection actorDir = (!a3 || a3 != 3) ? kDirectionE : kDirectionW;
if (canMove(&sum, actorDir, (uint32)abs(delta.x), true)) {
_data.points[0] = point;
diff --git a/engines/asylum/resources/encounters.h b/engines/asylum/resources/encounters.h
index 72ff173538..c187a24c95 100644
--- a/engines/asylum/resources/encounters.h
+++ b/engines/asylum/resources/encounters.h
@@ -268,7 +268,7 @@ private:
//////////////////////////////////////////////////////////////////////////
// Scripts
enum EncounterOpcode {
- kOpcodeReturn = 0,
+ kOpcodeEncounterReturn = 0,
kOpcodeSetScriptVariable = 1,
kOpcodeSetCounterFromVars = 2,
kOpcodeSetOffset = 3,
diff --git a/engines/asylum/system/cursor.cpp b/engines/asylum/system/cursor.cpp
index 50a5d1ffb1..0e98bd1634 100644
--- a/engines/asylum/system/cursor.cpp
+++ b/engines/asylum/system/cursor.cpp
@@ -61,7 +61,7 @@ void Cursor::set(ResourceId resourceId, int32 cnt, CursorAnimation anim, int32 f
_cursorRes = new GraphicResource(_vm, resourceId);
// Set next update
- _nextTick = _vm->getTick() + 100;
+ _nextTick = _vm->getTick() + CURSOR_UPDATE_TICKS;
// Get frame count
if (frames >= 0)
@@ -168,7 +168,7 @@ void Cursor::animate() {
}
}
- _nextTick = _vm->getTick() + 100;
+ _nextTick = _vm->getTick() + CURSOR_UPDATE_TICKS;
if (notifyHandler)
_vm->notify(EVENT_ASYLUM_CURSOR);
diff --git a/engines/asylum/system/savegame.cpp b/engines/asylum/system/savegame.cpp
index 6aa48ed9e7..1c3bb7e2e7 100644
--- a/engines/asylum/system/savegame.cpp
+++ b/engines/asylum/system/savegame.cpp
@@ -51,7 +51,7 @@ namespace Asylum {
#define SAVEGAME_MOVIES "asylum.movies"
-const Common::String savegame_version = "v1.01 FINAL";
+static const Common::String savegame_version = "v1.01 FINAL";
Savegame::Savegame(AsylumEngine *engine) : _vm(engine), _index(0), _valid(false) {
memset(&_moviesViewed, 0, sizeof(_moviesViewed));
diff --git a/engines/asylum/views/menu.h b/engines/asylum/views/menu.h
index 46fbf3633c..2c1a5b7685 100644
--- a/engines/asylum/views/menu.h
+++ b/engines/asylum/views/menu.h
@@ -83,7 +83,7 @@ private:
};
enum MenuResource {
- kResourceNone = 0,
+ kMenuResourceNone = 0,
kBackground = MAKE_RESOURCE(kResourcePackShared, 0),
kEye = MAKE_RESOURCE(kResourcePackShared, 1),
kFontBlue = MAKE_RESOURCE(kResourcePackShared, 22),
diff --git a/engines/asylum/views/scenetitle.cpp b/engines/asylum/views/scenetitle.cpp
index ad94ca17e1..060240deae 100644
--- a/engines/asylum/views/scenetitle.cpp
+++ b/engines/asylum/views/scenetitle.cpp
@@ -36,7 +36,7 @@
namespace Asylum {
SceneTitle::SceneTitle(AsylumEngine *engine): _vm(engine),
- _start(0), _ticks(0), _done(false), _spinnerFrameIndex(0), _spinnerProgress(0), _spinnerFrameCount(0), _showMouseState(false) {
+ _start(0), _done(false), _spinnerFrameIndex(0), _spinnerProgress(0), _spinnerFrameCount(0) {
}
SceneTitle::~SceneTitle() {
diff --git a/engines/asylum/views/scenetitle.h b/engines/asylum/views/scenetitle.h
index 705791d34f..526e555619 100644
--- a/engines/asylum/views/scenetitle.h
+++ b/engines/asylum/views/scenetitle.h
@@ -44,12 +44,10 @@ private:
AsylumEngine *_vm;
int32 _start;
- int32 _ticks;
bool _done;
uint32 _spinnerFrameIndex;
int32 _spinnerProgress;
uint32 _spinnerFrameCount;
- bool _showMouseState;
};
} // End of namespace Asylum
Commit: 617955615d126a2167f018790f7ede2b6ed4adf7
https://github.com/scummvm/scummvm/commit/617955615d126a2167f018790f7ede2b6ed4adf7
Author: alxpnv (alxpnv22 at yahoo.com)
Date: 2021-05-17T15:37:36+02:00
Commit Message:
ASYLUM: implement PuzzlePipes::saveLoadWithSerializer()
Changed paths:
engines/asylum/puzzles/pipes.cpp
engines/asylum/puzzles/pipes.h
diff --git a/engines/asylum/puzzles/pipes.cpp b/engines/asylum/puzzles/pipes.cpp
index e05f0c0f6e..0037ffc176 100644
--- a/engines/asylum/puzzles/pipes.cpp
+++ b/engines/asylum/puzzles/pipes.cpp
@@ -107,7 +107,12 @@ const Common::Point peepholePoints[] = {
};
const uint32 peepholeResources[] = {15, 15, 15, 15, 32, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 32, 32, 15,
- 15, 32, 32, 15, 15, 15, 15,15, 15, 15, 15, 32, 15, 15, 15, 15, 15, 15, 15};
+ 15, 32, 32, 15, 15, 15, 15, 15, 15, 15, 15, 32, 15, 15, 15, 15, 15, 15, 15};
+
+static BinNum calcStateFromPos(uint32 ind, ConnectorType type, uint32 position) {
+ uint32 shift = (uint32)Common::intLog2(position);
+ return BinNum((type >> shift | type << (4 - shift)) & 0xF);
+}
//////////////////////////////////////////////////////////////////////////
// Peephole
@@ -138,13 +143,16 @@ void Peephole::startUpWater(bool flag) {
//////////////////////////////////////////////////////////////////////////
// Connector
//////////////////////////////////////////////////////////////////////////
-void Connector::init(Peephole *n, Peephole *e, Peephole *s, Peephole *w, BinNum state, Connector *nextConnector, Direction nextConnectorPosition) {
+void Connector::init(Peephole *n, Peephole *e, Peephole *s, Peephole *w, uint32 pos, ConnectorType type, Connector *nextConnector, Direction nextConnectorPosition) {
_nodes[0] = n;
_nodes[1] = e;
_nodes[2] = s;
_nodes[3] = w;
- _state = state;
+ *_position = pos;
+ _type = type;
+ _state = calcStateFromPos(_id, _type, *_position);
+
_nextConnector = nextConnector;
_nextConnectorPosition = nextConnectorPosition;
_isConnected = false;
@@ -162,7 +170,9 @@ void Connector::initGroup() {
connect(_nextConnector);
}
-void Connector::turn() {
+void Connector::turn(bool updpos) {
+ if (updpos)
+ *_position = (*_position == 8) ? 1 : *_position << 1;
BinNum newState = BinNum(_state >> 1 | (_state & 1) << 3);
uint32 delta = _state ^ newState;
@@ -331,8 +341,11 @@ PuzzlePipes::~PuzzlePipes() {
}
void PuzzlePipes::saveLoadWithSerializer(Common::Serializer &s) {
- warning("[PuzzlePipes::saveLoadWithSerializer] Not implemented");
- s.skip(116);
+ s.skip(16);
+ for (uint32 i = 0; i < connectorsCount; i++) {
+ s.syncAsUint32LE(_positions[i]);
+ }
+ s.skip(16);
}
//////////////////////////////////////////////////////////////////////////
@@ -350,6 +363,10 @@ bool PuzzlePipes::init(const AsylumEvent &) {
_rectIndex = -2;
+ checkConnections();
+ startUpWater();
+ (void)checkFlags();
+
return true;
}
@@ -514,8 +531,10 @@ void PuzzlePipes::setup() {
for (uint32 i = 0; i < peepholesCount; ++i)
_peepholes[i].setId(i);
- for (uint32 i = 0; i < connectorsCount; ++i)
+ for (uint32 i = 0; i < connectorsCount; ++i) {
_connectors[i].setId(i);
+ _connectors[i].setPos(&_positions[i]);
+ }
for (uint32 i = 0; i < 4; ++i) {
_sinks[i] = &_peepholes[(peepholesCount - 4) + i];
@@ -524,27 +543,27 @@ void PuzzlePipes::setup() {
_sources[i]->_flowValues[i] = 1;
}
- _connectors[ 0].init( NULL, _peepholes + 4, _peepholes + 6, _peepholes + 0, kBinNum0110);
- _connectors[ 1].init(_peepholes + 6, _peepholes + 15, _peepholes + 23, NULL, kBinNum0110);
- _connectors[ 2].init(_peepholes + 23, _peepholes + 24, _peepholes + 33, NULL, kBinNum0011);
- _connectors[ 3].init( NULL, _peepholes + 5, _peepholes + 7, _peepholes + 4, kBinNum0110);
- _connectors[ 4].init(_peepholes + 7, _peepholes + 11, NULL, NULL, kBinNum0011, _connectors + 5, kDirectionSh);
- _connectors[ 5].init( NULL, _peepholes + 18, _peepholes + 24, _peepholes + 15, kBinNum0111, _connectors + 4, kDirectionNh);
- _connectors[ 6].init( NULL, _peepholes + 1, _peepholes + 8, _peepholes + 5, kBinNum0110);
- _connectors[ 7].init(_peepholes + 8, _peepholes + 12, _peepholes + 25, _peepholes + 11, kBinNum0111);
- _connectors[ 8].init(_peepholes + 25, _peepholes + 29, _peepholes + 34, _peepholes + 18, kBinNum1011);
- _connectors[ 9].init(_peepholes + 9, _peepholes + 16, _peepholes + 19, _peepholes + 12, kBinNum1110);
- _connectors[10].init(_peepholes + 19, _peepholes + 20, _peepholes + 26, NULL, kBinNum0011);
- _connectors[11].init(_peepholes + 26, _peepholes + 31, _peepholes + 35, _peepholes + 29, kBinNum1011);
- _connectors[12].init(_peepholes + 2, _peepholes + 10, NULL, _peepholes + 9, kBinNum0011);
- _connectors[13].init(_peepholes + 13, _peepholes + 17, NULL, _peepholes + 16, kBinNum0111, _connectors + 14, kDirectionSh);
- _connectors[14].init( NULL, _peepholes + 21, _peepholes + 27, _peepholes + 20, kBinNum1110, _connectors + 13, kDirectionNh);
- _connectors[15].init(_peepholes + 10, NULL, _peepholes + 22, _peepholes + 17, kBinNum0101, _connectors + 19, kDirectionEt);
- _connectors[16].init(_peepholes + 21, _peepholes + 22, _peepholes + 30, _peepholes + 27, kBinNum1011);
- _connectors[17].init(_peepholes + 30, _peepholes + 32, NULL, _peepholes + 31, kBinNum0011);
- _connectors[18].init(_peepholes + 3, NULL, _peepholes + 14, _peepholes + 13, kBinNum1100);
- _connectors[19].init(_peepholes + 14, NULL, _peepholes + 28, NULL, kBinNum1001, _connectors + 15, kDirectionWt);
- _connectors[20].init(_peepholes + 28, NULL, _peepholes + 36, _peepholes + 32, kBinNum1001);
+ _connectors[ 0].init( NULL, _peepholes + 4, _peepholes + 6, _peepholes + 0, 1, kConnectorTypeL);
+ _connectors[ 1].init(_peepholes + 6, _peepholes + 15, _peepholes + 23, NULL, 1, kConnectorTypeL);
+ _connectors[ 2].init(_peepholes + 23, _peepholes + 24, _peepholes + 33, NULL, 2, kConnectorTypeL);
+ _connectors[ 3].init( NULL, _peepholes + 5, _peepholes + 7, _peepholes + 4, 1, kConnectorTypeL);
+ _connectors[ 4].init(_peepholes + 7, _peepholes + 11, NULL, NULL, 2, kConnectorTypeL, _connectors + 5, kDirectionSh);
+ _connectors[ 5].init( NULL, _peepholes + 18, _peepholes + 24, _peepholes + 15, 1, kConnectorTypeT, _connectors + 4, kDirectionNh);
+ _connectors[ 6].init( NULL, _peepholes + 1, _peepholes + 8, _peepholes + 5, 1, kConnectorTypeL);
+ _connectors[ 7].init(_peepholes + 8, _peepholes + 12, _peepholes + 25, _peepholes + 11, 1, kConnectorTypeT);
+ _connectors[ 8].init(_peepholes + 25, _peepholes + 29, _peepholes + 34, _peepholes + 18, 2, kConnectorTypeT);
+ _connectors[ 9].init(_peepholes + 9, _peepholes + 16, _peepholes + 19, _peepholes + 12, 8, kConnectorTypeT);
+ _connectors[10].init(_peepholes + 19, _peepholes + 20, _peepholes + 26, NULL, 2, kConnectorTypeL);
+ _connectors[11].init(_peepholes + 26, _peepholes + 31, _peepholes + 35, _peepholes + 29, 2, kConnectorTypeT);
+ _connectors[12].init(_peepholes + 2, _peepholes + 10, NULL, _peepholes + 9, 2, kConnectorTypeL);
+ _connectors[13].init(_peepholes + 13, _peepholes + 17, NULL, _peepholes + 16, 1, kConnectorTypeT, _connectors + 14, kDirectionSh);
+ _connectors[14].init( NULL, _peepholes + 21, _peepholes + 27, _peepholes + 20, 8, kConnectorTypeT, _connectors + 13, kDirectionNh);
+ _connectors[15].init(_peepholes + 10, NULL, _peepholes + 22, _peepholes + 17, 1, kConnectorTypeI, _connectors + 19, kDirectionEt);
+ _connectors[16].init(_peepholes + 21, _peepholes + 22, _peepholes + 30, _peepholes + 27, 2, kConnectorTypeT);
+ _connectors[17].init(_peepholes + 30, _peepholes + 32, NULL, _peepholes + 31, 2, kConnectorTypeL);
+ _connectors[18].init(_peepholes + 3, NULL, _peepholes + 14, _peepholes + 13, 8, kConnectorTypeL);
+ _connectors[19].init(_peepholes + 14, NULL, _peepholes + 28, NULL, 4, kConnectorTypeL, _connectors + 15, kDirectionWt);
+ _connectors[20].init(_peepholes + 28, NULL, _peepholes + 36, _peepholes + 32, 4, kConnectorTypeL);
_connectors[ 4].initGroup();
_connectors[13].initGroup();
@@ -562,8 +581,6 @@ void PuzzlePipes::setup() {
_frameIndexSpider = new uint32[_spiders.size()];
memset(_frameIndexSpider, 0, _spiders.size()*sizeof(uint32));
}
-
- startUpWater();
}
void PuzzlePipes::updateCursor() {
@@ -610,6 +627,18 @@ uint32 PuzzlePipes::checkFlags() {
return val;
}
+void PuzzlePipes::checkConnections() {
+ for (uint32 i = 0; i < connectorsCount; i++) {
+ uint32 oldState = _connectors[i].getState(),
+ newState = calcStateFromPos(i, _connectors[i].getType(), _positions[i]);
+ if (oldState != newState) {
+ do {
+ _connectors[i].turn(false);
+ } while (_connectors[i].getState() != newState);
+ }
+ }
+}
+
void PuzzlePipes::startUpWater() {
for (uint32 i = 4; i < peepholesCount; ++i)
memset(_peepholes[i]._flowValues, 0, sizeof(_peepholes[i]._flowValues));
diff --git a/engines/asylum/puzzles/pipes.h b/engines/asylum/puzzles/pipes.h
index 5e2d81c823..db2d7d1bbc 100644
--- a/engines/asylum/puzzles/pipes.h
+++ b/engines/asylum/puzzles/pipes.h
@@ -57,6 +57,12 @@ enum BinNum {
kBinNum1111
};
+enum ConnectorType {
+ kConnectorTypeI = kBinNum0101,
+ kConnectorTypeL = kBinNum0110,
+ kConnectorTypeT = kBinNum0111
+};
+
enum Direction {
kDirectionNowhere = kBinNum0000,
kDirectionNh = kBinNum0001,
@@ -97,15 +103,19 @@ public:
uint32 getId() { return _id; }
void setId(uint32 id) { _id = id; }
+ void setPos(uint32 *pos) { _position = pos; }
BinNum getState() { return _state; }
+ ConnectorType getType() { return _type; }
- void init(Peephole *n, Peephole *e, Peephole *s, Peephole *w, BinNum state, Connector *nextConnector = NULL, Direction nextConnectorPosition = kDirectionNowhere);
+ void init(Peephole *n, Peephole *e, Peephole *s, Peephole *w, uint32 pos, ConnectorType type, Connector *nextConnector = NULL, Direction nextConnectorPosition = kDirectionNowhere);
void initGroup();
- void turn();
+ void turn(bool updpos = true);
private:
uint32 _id;
BinNum _state;
+ ConnectorType _type;
+ uint32 *_position;
Peephole *_nodes[4];
Common::List<Peephole *> _connectedNodes;
@@ -166,6 +176,7 @@ private:
bool _isLeverReady;
Common::HashMap<uint32, uint32> _connectorResources;
Connector _connectors[connectorsCount];
+ uint32 _positions[connectorsCount];
Peephole _peepholes[peepholesCount];
Peephole *_sinks[4], *_sources[4];
Common::Array<Spider *> _spiders;
@@ -188,6 +199,7 @@ private:
int32 findRect();
uint32 checkFlags();
void startUpWater();
+ void checkConnections();
};
} // End of namespace Asylum
Commit: 27cbc13eee60fae4cd0dc5bff67e6dfd47c676e8
https://github.com/scummvm/scummvm/commit/27cbc13eee60fae4cd0dc5bff67e6dfd47c676e8
Author: alxpnv (alxpnv22 at yahoo.com)
Date: 2021-05-17T15:37:36+02:00
Commit Message:
ASYLUM: add inventory debug commands
Changed paths:
engines/asylum/console.cpp
engines/asylum/console.h
diff --git a/engines/asylum/console.cpp b/engines/asylum/console.cpp
index 6ae104262b..6f7f089587 100644
--- a/engines/asylum/console.cpp
+++ b/engines/asylum/console.cpp
@@ -178,6 +178,9 @@ Console::Console(AsylumEngine *engine) : _vm(engine) {
registerCmd("encounter", WRAP_METHOD(Console, cmdRunEncounter));
registerCmd("puzzle", WRAP_METHOD(Console, cmdRunPuzzle));
+ registerCmd("grab", WRAP_METHOD(Console, cmdAddToInventory));
+ registerCmd("throw", WRAP_METHOD(Console, cmdRemoveFromInventory));
+
registerCmd("palette", WRAP_METHOD(Console, cmdSetPalette));
registerCmd("draw", WRAP_METHOD(Console, cmdDrawResource));
@@ -234,6 +237,9 @@ bool Console::cmdHelp(int, const char **) {
debugPrintf(" encounter - run an encounter\n");
debugPrintf(" puzzle - run an puzzle\n");
debugPrintf("\n");
+ debugPrintf(" grab - add an item to inventory\n");
+ debugPrintf(" throw - remove an item from inventory\n");
+ debugPrintf("\n");
debugPrintf(" palette - set the screen palette\n");
debugPrintf(" draw - draw a resource\n");
debugPrintf("\n");
@@ -661,6 +667,52 @@ bool Console::cmdRunPuzzle(int32 argc, const char **argv) {
return false;
}
+bool Console::cmdAddToInventory(int32 argc, const char **argv) {
+ if (argc != 2 && argc != 3) {
+ debugPrintf("Syntax: %s <item index> (<count>)\n", argv[0]);
+ return true;
+ }
+
+ uint32 index = atoi(argv[1]), count = argc == 3 ? atoi(argv[2]) : 0, maxIndex;
+
+ for (maxIndex = 0; maxIndex < 16; maxIndex++) {
+ if (!getWorld()->cursorResourcesAlternate[maxIndex])
+ break;
+ }
+
+ if (index > maxIndex || !index) {
+ debugPrintf("[Error] index should be between 1 and %d\n", maxIndex);
+ return true;
+ }
+
+ getScene()->getActor()->addReactionHive(index, count);
+
+ return true;
+}
+
+bool Console::cmdRemoveFromInventory(int32 argc, const char **argv) {
+ if (argc != 2 && argc != 3) {
+ debugPrintf("Syntax: %s <item index> (<count>)\n", argv[0]);
+ return true;
+ }
+
+ uint32 index = atoi(argv[1]), count = argc == 3 ? atoi(argv[2]) : 0, maxIndex;
+
+ for (maxIndex = 0; maxIndex < 16; maxIndex++) {
+ if (!getWorld()->cursorResourcesAlternate[maxIndex])
+ break;
+ }
+
+ if (index > maxIndex || !index) {
+ debugPrintf("[Error] index should be between 1 and %d\n", maxIndex);
+ return true;
+ }
+
+ getScene()->getActor()->removeReactionHive(index, count);
+
+ return true;
+}
+
bool Console::cmdSetPalette(int32 argc, const char **argv) {
if (argc != 3) {
debugPrintf("Syntax: %s <pack> <index>\n", argv[0]);
diff --git a/engines/asylum/console.h b/engines/asylum/console.h
index ffd8eb3b34..a1e0e1d0a3 100644
--- a/engines/asylum/console.h
+++ b/engines/asylum/console.h
@@ -76,6 +76,9 @@ private:
bool cmdRunEncounter(int32 argc, const char **argv);
bool cmdRunPuzzle(int32 argc, const char **argv);
+ bool cmdAddToInventory(int32 argc, const char **argv);
+ bool cmdRemoveFromInventory(int32 argc, const char **argv);
+
bool cmdSetPalette(int32 argc, const char **argv);
bool cmdDrawResource(int32 argc, const char **argv);
Commit: bf0a3ab7b5aa48f9cce36f66e4de55be3c180205
https://github.com/scummvm/scummvm/commit/bf0a3ab7b5aa48f9cce36f66e4de55be3c180205
Author: alxpnv (alxpnv22 at yahoo.com)
Date: 2021-05-17T15:37:37+02:00
Commit Message:
ASYLUM: add a debug command to list all possible inventory items
Changed paths:
engines/asylum/console.cpp
engines/asylum/console.h
diff --git a/engines/asylum/console.cpp b/engines/asylum/console.cpp
index 6f7f089587..8255cb94f5 100644
--- a/engines/asylum/console.cpp
+++ b/engines/asylum/console.cpp
@@ -33,6 +33,7 @@
#include "asylum/system/cursor.h"
#include "asylum/system/graphics.h"
#include "asylum/system/screen.h"
+#include "asylum/system/text.h"
#include "asylum/views/scene.h"
#include "asylum/views/video.h"
@@ -155,6 +156,19 @@ static const struct EncounterData {
}
};
+static const int32 itemIndices[][16] = {
+ {61, 69},
+ {107, 134, 104, 113, 110, 112, 117, 109, 108, 111, 106},
+ {170, 182, 181, 172, 171, 169},
+ {61, 64, 66, 67, 68, 69, 70, 78, 77},
+ {197},
+ {59, 81, 60, 84, 88, 54, 74, 139, 97, 121},
+ {239, 234, 249, 250, 251, 263, 237, 253},
+ {58, 59, 60, 111, 75, 76, 77, 78},
+ {284, 285, 286, 329, 330, 331, 332, 322, 465},
+ {91, 92, 93, 94, 95},
+ {69, 70, 78}
+};
Console::Console(AsylumEngine *engine) : _vm(engine) {
// Commands
@@ -178,6 +192,7 @@ Console::Console(AsylumEngine *engine) : _vm(engine) {
registerCmd("encounter", WRAP_METHOD(Console, cmdRunEncounter));
registerCmd("puzzle", WRAP_METHOD(Console, cmdRunPuzzle));
+ registerCmd("items", WRAP_METHOD(Console, cmdListItems));
registerCmd("grab", WRAP_METHOD(Console, cmdAddToInventory));
registerCmd("throw", WRAP_METHOD(Console, cmdRemoveFromInventory));
@@ -237,6 +252,7 @@ bool Console::cmdHelp(int, const char **) {
debugPrintf(" encounter - run an encounter\n");
debugPrintf(" puzzle - run an puzzle\n");
debugPrintf("\n");
+ debugPrintf(" items - list all grabbable objects\n");
debugPrintf(" grab - add an item to inventory\n");
debugPrintf(" throw - remove an item from inventory\n");
debugPrintf("\n");
@@ -667,6 +683,35 @@ bool Console::cmdRunPuzzle(int32 argc, const char **argv) {
return false;
}
+bool Console::cmdListItems(int32 argc, const char **argv) {
+ ChapterIndex chapter = getWorld()->chapter;
+ uint32 maxIndex;
+ for (maxIndex = 0; maxIndex < 16; maxIndex++) {
+ if (!itemIndices[chapter - 1][maxIndex])
+ break;
+ }
+
+ int32 offset, actorType = getWorld()->actorType;
+ if (actorType == kActorMax)
+ offset = 83;
+ else if (actorType == kActorSarah)
+ offset = 586;
+ else if (actorType == kActorCyclops)
+ offset = 743;
+ else if (actorType == kActorAztec)
+ offset = 893;
+ else
+ return true;
+
+ for (uint32 i = 0; i < maxIndex; i++) {
+ char *text = getText()->get(MAKE_RESOURCE(kResourcePackText, offset + itemIndices[chapter - 1][i]));
+ text += 4;
+ debugPrintf("%02d: %s\n", i + 1, text);
+ }
+
+ return true;
+}
+
bool Console::cmdAddToInventory(int32 argc, const char **argv) {
if (argc != 2 && argc != 3) {
debugPrintf("Syntax: %s <item index> (<count>)\n", argv[0]);
diff --git a/engines/asylum/console.h b/engines/asylum/console.h
index a1e0e1d0a3..7e8b808295 100644
--- a/engines/asylum/console.h
+++ b/engines/asylum/console.h
@@ -76,6 +76,7 @@ private:
bool cmdRunEncounter(int32 argc, const char **argv);
bool cmdRunPuzzle(int32 argc, const char **argv);
+ bool cmdListItems(int32 argc, const char **argv);
bool cmdAddToInventory(int32 argc, const char **argv);
bool cmdRemoveFromInventory(int32 argc, const char **argv);
Commit: 2c180774723437c8d7b45f9775f6f37b295bf43a
https://github.com/scummvm/scummvm/commit/2c180774723437c8d7b45f9775f6f37b295bf43a
Author: alxpnv (alxpnv22 at yahoo.com)
Date: 2021-05-17T15:37:37+02:00
Commit Message:
ASYLUM: handle intersecting action areas the way the original does (this reverts the workaround introduced in 1e933a1)
Changed paths:
engines/asylum/views/scene.cpp
diff --git a/engines/asylum/views/scene.cpp b/engines/asylum/views/scene.cpp
index 3d703b7cb0..8bcda90773 100644
--- a/engines/asylum/views/scene.cpp
+++ b/engines/asylum/views/scene.cpp
@@ -2166,8 +2166,6 @@ int32 Scene::findActionArea(ActionAreaType type, const Common::Point &pt, bool h
if (!_polygons)
error("[Scene::findActionArea] Polygons not initialized properly!");
- Common::Array<int32> areaIds;
-
switch (type) {
default:
return type - 2;
@@ -2179,6 +2177,9 @@ int32 Scene::findActionArea(ActionAreaType type, const Common::Point &pt, bool h
for (int32 i = _ws->actions.size() - 1; i >= 0; i--) {
ActionArea *area = _ws->actions[i];
+ if (!(area->flags & 1))
+ continue;
+
if (g_debugPolygons && highlight) {
#ifdef DEBUG
// Highlight each polygon as it gets checked for action
@@ -2206,7 +2207,7 @@ int32 Scene::findActionArea(ActionAreaType type, const Common::Point &pt, bool h
}
if (!found && _polygons->get(area->polygonIndex).contains(pt))
- areaIds.push_back(i);
+ return i;
}
break;
@@ -2237,21 +2238,12 @@ int32 Scene::findActionArea(ActionAreaType type, const Common::Point &pt, bool h
}
if (!found && _polygons->get(area->polygonIndex).contains(pt))
- areaIds.push_back(i);
+ return i;
}
break;
}
- if (areaIds.empty()) {
- return -1;
- } else {
- int32 i;
- for (i = 0; i < areaIds.size(); i++)
- if (_ws->actions[i]->flags)
- break;
-
- return (i == areaIds.size()) ? areaIds[0] : areaIds[i];
- }
+ return -1;
}
void Scene::changePlayer(ActorIndex index) {
Commit: 66e46adb21cb75ff37292755b66ef19a81e155d4
https://github.com/scummvm/scummvm/commit/66e46adb21cb75ff37292755b66ef19a81e155d4
Author: alxpnv (alxpnv22 at yahoo.com)
Date: 2021-05-17T15:37:37+02:00
Commit Message:
ASYLUM: initialize puzzles when the 'scene' debug command is used
Changed paths:
engines/asylum/console.cpp
diff --git a/engines/asylum/console.cpp b/engines/asylum/console.cpp
index 8255cb94f5..2b20395c0f 100644
--- a/engines/asylum/console.cpp
+++ b/engines/asylum/console.cpp
@@ -588,6 +588,7 @@ bool Console::cmdChangeScene(int32 argc, const char **argv) {
}
_vm->_delayedSceneIndex = index;
+ _vm->_puzzles->reset();
return false;
}
Commit: 540a786eb4b0cee73ea28d93f618e5d97735bb82
https://github.com/scummvm/scummvm/commit/540a786eb4b0cee73ea28d93f618e5d97735bb82
Author: alxpnv (alxpnv22 at yahoo.com)
Date: 2021-05-17T15:37:37+02:00
Commit Message:
ASYLUM: fix wrong condition in Actor::process()
Changed paths:
engines/asylum/resources/actor.cpp
diff --git a/engines/asylum/resources/actor.cpp b/engines/asylum/resources/actor.cpp
index 2a4c3f2b08..274a8f2022 100644
--- a/engines/asylum/resources/actor.cpp
+++ b/engines/asylum/resources/actor.cpp
@@ -1246,7 +1246,7 @@ bool Actor::process(const Common::Point &point) {
}
if (point.y == sum.y) {
- ActorDirection actorDir = (!a3 || a3 != 3) ? kDirectionE : kDirectionW;
+ ActorDirection actorDir = (a3 != 0 && a3 != 3) ? kDirectionE : kDirectionW;
if (canMove(&sum, actorDir, (uint32)abs(delta.x), true)) {
_data.points[0] = point;
Commit: a4882e97caac93612e0f88d4c9cfd57cb481f706
https://github.com/scummvm/scummvm/commit/a4882e97caac93612e0f88d4c9cfd57cb481f706
Author: alxpnv (alxpnv22 at yahoo.com)
Date: 2021-05-17T15:37:37+02:00
Commit Message:
ASYLUM: fix a few bugs in pathfinding
Changed paths:
engines/asylum/resources/actor.cpp
diff --git a/engines/asylum/resources/actor.cpp b/engines/asylum/resources/actor.cpp
index 274a8f2022..ec81076545 100644
--- a/engines/asylum/resources/actor.cpp
+++ b/engines/asylum/resources/actor.cpp
@@ -3543,7 +3543,7 @@ bool Actor::processAction(const Common::Point &source, Common::Array<int> *actio
src.y += (int16)(sign.y * dist);
if (abs(src.x - destination.x) >= getAbsoluteDistanceForFrame(kDirectionW, frameNumber)) {
- if (abs(src.y - destination.y) >= getAbsoluteDistanceForFrame(kDirectionN, frameNumber)) {
+ if (abs(src.y - destination.y) < getAbsoluteDistanceForFrame(kDirectionN, frameNumber)) {
if (src.x >= destination.x) {
if (checkPath(actions, src, kDirectionW, src.x - destination.x)) {
@@ -3655,7 +3655,7 @@ bool Actor::checkPath(Common::Array<int> *actions, const Common::Point &point, A
for (int16 i = 1; i < loopcount; i++) {
if (!checkAllActions(basePoint, actions))
- break;
+ return false;
if (!rect.contains(basePoint))
return false;
@@ -3685,7 +3685,7 @@ bool Actor::isInActionArea(const Common::Point &pt, ActionArea *area) {
if (!sceneRect.contains(pt))
return false;
- if (area->flags & 1)
+ if (!(area->flags & 1))
return false;
// Check flags
Commit: 305b370e5c5255789860e1f8ad1c8e0c3496e726
https://github.com/scummvm/scummvm/commit/305b370e5c5255789860e1f8ad1c8e0c3496e726
Author: alxpnv (alxpnv22 at yahoo.com)
Date: 2021-05-17T15:37:37+02:00
Commit Message:
ASYLUM: fix JumpIfActorCoordinates
Changed paths:
engines/asylum/resources/actor.cpp
engines/asylum/resources/script.cpp
diff --git a/engines/asylum/resources/actor.cpp b/engines/asylum/resources/actor.cpp
index ec81076545..6dc91ec7b6 100644
--- a/engines/asylum/resources/actor.cpp
+++ b/engines/asylum/resources/actor.cpp
@@ -600,7 +600,7 @@ void Actor::update() {
if (_field_944 == 1 || _field_944 == 4)
area = 1;
- if (area == -1 || _data.current >= (int32)(_data.count - 1)) {
+ if (area == -1 && _data.current >= (int32)(_data.count - 1)) {
update_409230();
} else {
_frameIndex = (_frameIndex + 1) % _frameCount;
diff --git a/engines/asylum/resources/script.cpp b/engines/asylum/resources/script.cpp
index 4b206a0ee2..f328b5ebce 100644
--- a/engines/asylum/resources/script.cpp
+++ b/engines/asylum/resources/script.cpp
@@ -744,17 +744,9 @@ END_OPCODE
IMPLEMENT_OPCODE(JumpIfActorCoordinates)
Actor *actor = getScene()->getActor(cmd->param1);
- // FIXME: the script is wrongly jumping to the currentLine = cmd->param4 giving a wrong behaviour
- // actor->canMoveCheckActors (called from canMove) seems to be the cause of the issue
- // this script fails because the position is never met for few pixels (3 to 5 pixels)
- // usually the X coordinate but sometimes also happens with the Y coordinate
- debugC(kDebugLevelScripts, "COMMENTED JumpIfActorCoordinates x: %d y: %d",
- (actor->getPoint1()->x + actor->getPoint2()->x),
- (actor->getPoint1()->y + actor->getPoint2()->y));
-
- /*if ((actor->getPoint1()->x + actor->getPoint2()->x) != cmd->param2 ||
+ if ((actor->getPoint1()->x + actor->getPoint2()->x) != cmd->param2 ||
(actor->getPoint1()->y + actor->getPoint2()->y) != cmd->param3)
- _currentQueueEntry->currentLine = cmd->param4;*/
+ _currentQueueEntry->currentLine = cmd->param4;
END_OPCODE
//////////////////////////////////////////////////////////////////////////
Commit: a600d38ec1178e69c33642ae4065e81d8a0f5caa
https://github.com/scummvm/scummvm/commit/a600d38ec1178e69c33642ae4065e81d8a0f5caa
Author: alxpnv (alxpnv22 at yahoo.com)
Date: 2021-05-17T15:37:37+02:00
Commit Message:
ASYLUM: fix an assertion failure in Console::cmdShowScript()
Changed paths:
engines/asylum/console.cpp
diff --git a/engines/asylum/console.cpp b/engines/asylum/console.cpp
index 2b20395c0f..5b5597edf6 100644
--- a/engines/asylum/console.cpp
+++ b/engines/asylum/console.cpp
@@ -529,8 +529,8 @@ bool Console::cmdShowScript(int32 argc, const char **argv) {
int32 index = atoi(argv[1]);
// Check parameters
- if (index < 0 || index >= (int32)getScript()->_scripts.size()) {
- debugPrintf("[Error] Invalid index (was: %d - valid: [0-%d])\n", index, getScript()->_scripts.size() - 1);
+ if (index < 0 || index >= (int32)getWorld()->numScripts) {
+ debugPrintf("[Error] Invalid index (was: %d - valid: [0-%d])\n", index, getWorld()->numScripts - 1);
return true;
}
Commit: f90b57ef85e4e45cc4a7b00aef997a71d0549723
https://github.com/scummvm/scummvm/commit/f90b57ef85e4e45cc4a7b00aef997a71d0549723
Author: alxpnv (alxpnv22 at yahoo.com)
Date: 2021-05-17T15:37:38+02:00
Commit Message:
ASYLUM: set the current cd number. This unbreaks chapter 4
Changed paths:
engines/asylum/asylum.cpp
diff --git a/engines/asylum/asylum.cpp b/engines/asylum/asylum.cpp
index 964976ea4e..897648067c 100644
--- a/engines/asylum/asylum.cpp
+++ b/engines/asylum/asylum.cpp
@@ -193,7 +193,35 @@ void AsylumEngine::startGame(ResourcePackId sceneId, StartGameType type) {
_scene = new Scene(this);
_handler = _scene;
- // Original checks for the current cd (we have all data files on disc, so this is not needed)
+ // Set the current cd number (necessary for proper SharedSound resource pack initialization)
+ switch (sceneId) {
+ default:
+ _resource->setCdNumber(-1);
+ break;
+
+ case kResourcePackTowerCells:
+ case kResourcePackInnocentAbandoned:
+ case kResourcePackCourtyardAndChapel:
+ _resource->setCdNumber(1);
+ break;
+
+ case kResourcePackCircusOfFools:
+ case kResourcePackCave:
+ case kResourcePackMansion:
+ case kResourcePackLaboratory:
+ case kResourcePackHive:
+ _resource->setCdNumber(2);
+ break;
+
+ case kResourcePackMorgueAndCemetery:
+ case kResourcePackLostVillage:
+ case kResourcePackMaze:
+ case kResourcePackGauntlet:
+ case kResourcePackMorgansLastGame:
+ _resource->setCdNumber(3);
+ break;
+ }
+
switch (type) {
default:
error("[AsylumEngine::startGame] Invalid start game type!");
Commit: e287e10fcfa969f8910ef4ee69700e192b7b723d
https://github.com/scummvm/scummvm/commit/e287e10fcfa969f8910ef4ee69700e192b7b723d
Author: alxpnv (alxpnv22 at yahoo.com)
Date: 2021-05-17T15:37:38+02:00
Commit Message:
ASYLUM: fix chapter 5 crash
Changed paths:
engines/asylum/resources/special.cpp
diff --git a/engines/asylum/resources/special.cpp b/engines/asylum/resources/special.cpp
index 37d7def4f6..a24e3c06de 100644
--- a/engines/asylum/resources/special.cpp
+++ b/engines/asylum/resources/special.cpp
@@ -316,7 +316,7 @@ void Special::chapter4(Object *object, ActorIndex actorIndex) {
}
void Special::chapter5(Object *object, ActorIndex actorIndex) {
- setPaletteGamma(MAKE_RESOURCE(kResourcePackShared, 19), getWorld()->currentPaletteId);
+ setPaletteGamma(MAKE_RESOURCE(kResourcePackShared, 59), getWorld()->currentPaletteId);
playChapterSound(object, actorIndex);
Commit: de51014306f3d4c73dfe2150f5ab45377ecff238
https://github.com/scummvm/scummvm/commit/de51014306f3d4c73dfe2150f5ab45377ecff238
Author: alxpnv (alxpnv22 at yahoo.com)
Date: 2021-05-17T15:37:38+02:00
Commit Message:
ASYLUM: fix sound resource ids
Changed paths:
engines/asylum/puzzles/board.cpp
diff --git a/engines/asylum/puzzles/board.cpp b/engines/asylum/puzzles/board.cpp
index ee753d3c4c..49c2f76ce7 100644
--- a/engines/asylum/puzzles/board.cpp
+++ b/engines/asylum/puzzles/board.cpp
@@ -169,7 +169,7 @@ void PuzzleBoard::playSound() {
return;
if (!_soundResourceId || !getSound()->isPlaying(_soundResourceId)) {
- _soundResourceId = MAKE_RESOURCE(kResourcePackSharedSound, 961 + _data.soundResources[index].index);
+ _soundResourceId = MAKE_RESOURCE(kResourcePackSharedSound, 2401 + _data.soundResources[index].index);
getSound()->playSound(_soundResourceId, false, Config.voiceVolume);
_data.soundResources[index].played = true;
}
Commit: 988c66f01d039d1c95b1f9f847ccdce10b9eac5d
https://github.com/scummvm/scummvm/commit/988c66f01d039d1c95b1f9f847ccdce10b9eac5d
Author: alxpnv (alxpnv22 at yahoo.com)
Date: 2021-05-17T15:37:38+02:00
Commit Message:
ASYLUM: various fixes to the Board puzzles. Chapter 5 is completable now
Changed paths:
engines/asylum/puzzles/board.cpp
engines/asylum/puzzles/boardkeyhidesto.cpp
engines/asylum/puzzles/boardyouth.cpp
diff --git a/engines/asylum/puzzles/board.cpp b/engines/asylum/puzzles/board.cpp
index 49c2f76ce7..5d7e6020ca 100644
--- a/engines/asylum/puzzles/board.cpp
+++ b/engines/asylum/puzzles/board.cpp
@@ -197,14 +197,8 @@ int32 PuzzleBoard::checkMouse() {
if (index < 0 || index >= ARRAYSIZE(_solvedText))
return -1;
- if (_solvedText[index] != 0) {
- if (_data.checkForSpace) {
- if (_solvedText[index] != ' ')
- return -3;
- } else {
- return -3;
- }
- }
+ if (_solvedText[index] != 0 && _solvedText[index] != ' ')
+ return -3;
}
return -1;
@@ -264,7 +258,7 @@ void PuzzleBoard::checkSlots() {
int32 index = (mousePos.x - 215) / 12;
if (_solvedText[index]) {
- if (_data.checkForSpace && _solvedText[index] == ' ')
+ if (_solvedText[index] == ' ')
return;
if (_selectedSlot == -1) {
diff --git a/engines/asylum/puzzles/boardkeyhidesto.cpp b/engines/asylum/puzzles/boardkeyhidesto.cpp
index d0efd7ce71..540f6b8a69 100644
--- a/engines/asylum/puzzles/boardkeyhidesto.cpp
+++ b/engines/asylum/puzzles/boardkeyhidesto.cpp
@@ -77,10 +77,9 @@ bool PuzzleBoardKeyHidesTo::mouseLeftDown(const AsylumEvent &) {
_solvedText[_position++] = puzzleKeyHidesToData.charMap[index].character;
_solvedText[_position++] = ' ';
- if (_position == 5 || _position == 18) {
- _solvedText[++_position] = ' ';
- _solvedText[++_position] = ' ';
- ++_position;
+ if (_position == 6 || _position == 18) {
+ _solvedText[_position++] = ' ';
+ _solvedText[_position++] = ' ';
}
updateScreen();
diff --git a/engines/asylum/puzzles/boardyouth.cpp b/engines/asylum/puzzles/boardyouth.cpp
index 4d6b12711e..dcdacb17ac 100644
--- a/engines/asylum/puzzles/boardyouth.cpp
+++ b/engines/asylum/puzzles/boardyouth.cpp
@@ -77,10 +77,9 @@ bool PuzzleBoardYouth::mouseLeftDown(const AsylumEvent &) {
_solvedText[_position++] = puzzleYouthData.charMap[index].character;
_solvedText[_position++] = ' ';
- if (_position == 5) {
- _solvedText[++_position] = ' ';
- _solvedText[++_position] = ' ';
- ++_position;
+ if (_position == 6) {
+ _solvedText[_position++] = ' ';
+ _solvedText[_position++] = ' ';
}
updateScreen();
Commit: e8fb7048dcedaebdc60eb2c8342f61166a8a0505
https://github.com/scummvm/scummvm/commit/e8fb7048dcedaebdc60eb2c8342f61166a8a0505
Author: alxpnv (alxpnv22 at yahoo.com)
Date: 2021-05-17T15:37:38+02:00
Commit Message:
ASYLUM: fix a crash caused by Screen::bltMasked()
Changed paths:
engines/asylum/system/screen.cpp
diff --git a/engines/asylum/system/screen.cpp b/engines/asylum/system/screen.cpp
index d5942ac798..280f0afb7b 100644
--- a/engines/asylum/system/screen.cpp
+++ b/engines/asylum/system/screen.cpp
@@ -1129,6 +1129,9 @@ void Screen::bltMasked(byte *srcBuffer, byte *maskBuffer, int16 height, int16 wi
dstBuffer++;
srcBuffer++;
+ if (i == width - 1)
+ break;
+
// Check run/skip
run--;
if (run < 0) {
Commit: c6087b8755f9d6679f4bdcc28e9eeccdaa47400d
https://github.com/scummvm/scummvm/commit/c6087b8755f9d6679f4bdcc28e9eeccdaa47400d
Author: alxpnv (alxpnv22 at yahoo.com)
Date: 2021-05-17T15:37:38+02:00
Commit Message:
ASYLUM: fix a few bugs in the Morgue Door puzzle
Changed paths:
engines/asylum/puzzles/morguedoor.cpp
diff --git a/engines/asylum/puzzles/morguedoor.cpp b/engines/asylum/puzzles/morguedoor.cpp
index 7e92ee4eac..f40f3bd2be 100644
--- a/engines/asylum/puzzles/morguedoor.cpp
+++ b/engines/asylum/puzzles/morguedoor.cpp
@@ -191,8 +191,8 @@ bool PuzzleMorgueDoor::mouseLeftDown(const AsylumEvent &evt) {
&& mousePos.y > 124 && mousePos.y < 177) {
if (_frameIndexes[kTopRightLever] == 4) {
getSound()->playSound(getWorld()->soundResourceIds[2], false, Config.sfxVolume - 10);
- _data_4572A8 = true;
- _data_4572AC = false;
+ _data_4572A4 = true;
+ _data_4572AC = true;
}
return true;
@@ -312,6 +312,7 @@ void PuzzleMorgueDoor::updateState() {
if (_frameIndexes[kBottomGear] < 0) {
_data_45A9DC = 0;
_frameIndexes[kBottomGear] = 0;
+ _moveBottomGear = false;
getSound()->stop(getWorld()->soundResourceIds[8]);
}
@@ -467,7 +468,7 @@ void PuzzleMorgueDoor::updateState() {
_bottomLeverOpen = true;
_flag7 = true;
} else {
- ++_frameIndexes[kTopLever];
+ ++_frameIndexes[kBottomLever];
}
} else {
if (_frameIndexes[kCenterValve] >= 14)
@@ -480,6 +481,7 @@ void PuzzleMorgueDoor::updateState() {
_frameIndexes[kCenterValve] = 0;
getSound()->stop(getWorld()->soundResourceIds[0]);
}
+ goto updateIndices;
}
if ((!_flag6 && _frameIndexes[kTopLever] >= 15)
@@ -507,15 +509,15 @@ void PuzzleMorgueDoor::updateState() {
}
// Bottom lever
- if (_frameIndexes[kBottomLever]) {
+ if (_frameIndexes[kBottomLever] >= 15) {
if (_frameIndexes[kBottomLever] == 20)
getSound()->playSound(getWorld()->soundResourceIds[3], false, Config.sfxVolume - 10);
- if (_frameIndexes[kTopLever] <= 15) {
+ if (_frameIndexes[kBottomLever] <= 15) {
_frameIndexes[kCenterValve] = 0;
_flag7 = false;
} else {
- --_frameIndexes[kTopLever];
+ --_frameIndexes[kBottomLever];
}
_bottomLeverOpen = false;
@@ -528,6 +530,7 @@ void PuzzleMorgueDoor::updateState() {
//////////////////////////////////////////////////////////////////////////
// Adjust frame indexes
//////////////////////////////////////////////////////////////////////////
+updateIndices:
if (_frameIndexes[kTopGear] > _frameCounts[kTopGear] - 1)
_frameIndexes[kTopGear] = 0;
@@ -567,7 +570,7 @@ void PuzzleMorgueDoor::updateState() {
_moveTopGear = true;
}
- _frameIndexes[10] = 10;
+ _frameIndexes[kTopGear] = 10;
}
}
Commit: f1da4bf7988f0f44b9c829e95024b041af18a7bc
https://github.com/scummvm/scummvm/commit/f1da4bf7988f0f44b9c829e95024b041af18a7bc
Author: alxpnv (alxpnv22 at yahoo.com)
Date: 2021-05-17T15:37:38+02:00
Commit Message:
ASYLUM: fix chapter 13 loading
Changed paths:
engines/asylum/resources/actor.cpp
diff --git a/engines/asylum/resources/actor.cpp b/engines/asylum/resources/actor.cpp
index 6dc91ec7b6..2fe435de46 100644
--- a/engines/asylum/resources/actor.cpp
+++ b/engines/asylum/resources/actor.cpp
@@ -1007,7 +1007,7 @@ void Actor::updateDirection() {
// Get the next resource index offset
uint32 index = 0;
- while (getWorld()->graphicResourceIds[index] != _resourceId) {
+ while (_graphicResourceIds[index] != _resourceId) {
index++;
if (index >= 55)
Commit: 361a99035c2095708bb1490485a0380cde4a8b9c
https://github.com/scummvm/scummvm/commit/361a99035c2095708bb1490485a0380cde4a8b9c
Author: alxpnv (alxpnv22 at yahoo.com)
Date: 2021-05-17T15:37:39+02:00
Commit Message:
ASYLUM: unbreak chapter 8
Changed paths:
engines/asylum/resources/data.cpp
engines/asylum/views/scene.cpp
diff --git a/engines/asylum/resources/data.cpp b/engines/asylum/resources/data.cpp
index e4fa127719..7b3f688c91 100644
--- a/engines/asylum/resources/data.cpp
+++ b/engines/asylum/resources/data.cpp
@@ -241,7 +241,7 @@ bool SharedData::getFlag(GlobalFlag flag) const {
void SharedData::setFlag(GlobalFlag flag, bool state) {
switch (flag) {
default:
- error("[SharedData::getFlag] Invalid flag type (%d)!", flag);
+ error("[SharedData::setFlag] Invalid flag type (%d)!", flag);
case kFlag1:
_flag1 = state;
@@ -264,7 +264,7 @@ void SharedData::setFlag(GlobalFlag flag, bool state) {
break;
case kFlagSceneRectChanged:
- error("[SharedData::getFlag] Invalid flag type (kFlagSceneRectChanged)!");
+ warning("[SharedData::setFlag] Invalid flag type (kFlagSceneRectChanged)!");
break;
case kFlagScene1:
diff --git a/engines/asylum/views/scene.cpp b/engines/asylum/views/scene.cpp
index 8bcda90773..d189565603 100644
--- a/engines/asylum/views/scene.cpp
+++ b/engines/asylum/views/scene.cpp
@@ -847,6 +847,9 @@ void Scene::updateAmbientSounds() {
for (int32 f = 0; f < 6; f++) {
int32 gameFlag = snd->flagNum[f];
+ if (gameFlag == 99999)
+ continue;
+
if (gameFlag >= 0) {
if (_vm->isGameFlagNotSet((GameFlag)gameFlag)) {
processSound = false;
@@ -1382,8 +1385,8 @@ ActorIndex Scene::hitTestActor() {
break;
case kChapter8:
- if (_ws->actors.size() <= 7)
- error("[Scene::hitTestActor] Not enough actors to check (chapter 8 - checking actors 1-7)!");
+ if (_ws->actors.size() < 7)
+ error("[Scene::hitTestActor] Not enough actors to check (chapter 8 - checking actors 1-6)!");
for (uint i = 1; i < 7; i++) {
Actor *actor = getActor(i);
@@ -2324,7 +2327,7 @@ void Scene::changePlayer(ActorIndex index) {
// Setup new values
for (uint32 i = 0; i < 11; i++)
- _ws->cursorResources[i] = _ws->graphicResourceIds[40 + i];
+ _ws->cursorResources[i] = _ws->graphicResourceIds[20 + i];
_ws->font1 = _ws->graphicResourceIds[35];
_ws->font2 = _ws->graphicResourceIds[37];
Commit: b6ca135125ed3484914b12f4271d00ecc1dbf5f2
https://github.com/scummvm/scummvm/commit/b6ca135125ed3484914b12f4271d00ecc1dbf5f2
Author: alxpnv (alxpnv22 at yahoo.com)
Date: 2021-05-17T15:37:39+02:00
Commit Message:
ASYLUM: rename some ScriptQueueEntry and ScriptQueue fields
Changed paths:
engines/asylum/resources/script.cpp
engines/asylum/resources/script.h
diff --git a/engines/asylum/resources/script.cpp b/engines/asylum/resources/script.cpp
index f328b5ebce..71909f59cb 100644
--- a/engines/asylum/resources/script.cpp
+++ b/engines/asylum/resources/script.cpp
@@ -318,17 +318,17 @@ void ScriptManager::queueScript(int32 scriptIndex, ActorIndex actorIndex) {
// Setup script and queue
_scripts[scriptIndex].counter = 0;
- _queue.entries[index].field_10 = 0;
- _queue.entries[index].field_C = 0;
+ _queue.entries[index].prev = 0;
+ _queue.entries[index].next = 0;
- if (_queue.currentEntry) {
- _queue.entries[_queue.field_CC].field_C = index;
- _queue.entries[index].field_10 = _queue.field_CC;
+ if (_queue.first) {
+ _queue.entries[_queue.last].next = index;
+ _queue.entries[index].prev = _queue.last;
} else {
- _queue.currentEntry = index;
+ _queue.first = index;
}
- _queue.field_CC = index;
+ _queue.last = index;
_queue.entries[index].scriptIndex = scriptIndex;
_queue.entries[index].currentLine = 0;
@@ -345,21 +345,21 @@ bool ScriptManager::isInQueue(int32 scriptIndex) const {
}
void ScriptManager::updateQueue(uint32 entryIndex) {
- if (_queue.currentEntry == _queue.field_CC) {
- _queue.field_CC = 0;
- _queue.currentEntry = 0;
+ if (_queue.first == _queue.last) {
+ _queue.last = 0;
+ _queue.first = 0;
_queue.entries[entryIndex].scriptIndex = -1;
- } else if (_queue.currentEntry == entryIndex) {
- _queue.currentEntry = _queue.entries[entryIndex].field_C;
- _queue.entries[_queue.currentEntry].field_10 = 0;
+ } else if (_queue.first == entryIndex) {
+ _queue.first = _queue.entries[entryIndex].next;
+ _queue.entries[_queue.first].prev = 0;
_queue.entries[entryIndex].scriptIndex = -1;
- } else if (_queue.field_CC == entryIndex) {
- _queue.field_CC = _queue.entries[entryIndex].field_10;
- _queue.entries[_queue.field_CC].field_C = 0;
+ } else if (_queue.last == entryIndex) {
+ _queue.last = _queue.entries[entryIndex].prev;
+ _queue.entries[_queue.last].next = 0;
_queue.entries[entryIndex].scriptIndex = -1;
} else {
- _queue.entries[_queue.entries[entryIndex].field_10].field_C = _queue.entries[entryIndex].field_C;
- _queue.entries[_queue.entries[entryIndex].field_C].field_10 = _queue.entries[entryIndex].field_10;
+ _queue.entries[_queue.entries[entryIndex].prev].next = _queue.entries[entryIndex].next;
+ _queue.entries[_queue.entries[entryIndex].next].prev = _queue.entries[entryIndex].prev;
_queue.entries[entryIndex].scriptIndex = -1;
}
}
@@ -370,9 +370,9 @@ bool ScriptManager::process() {
_vm->setGameFlag(kGameFlagScriptProcessing);
// Setup queue entry
- if (_queue.currentEntry) {
- uint32 entryIndex = _queue.currentEntry;
- uint32 nextIndex = _queue.entries[entryIndex].field_C;
+ if (_queue.first) {
+ uint32 entryIndex = _queue.first;
+ uint32 nextIndex = _queue.entries[entryIndex].next;
int32 scriptIndex = _queue.entries[entryIndex].scriptIndex;
if (scriptIndex != -1) {
@@ -403,8 +403,8 @@ bool ScriptManager::process() {
error("[ScriptManager::process] Invalid opcode index (was: %d, max: %d)", cmd->opcode, _opcodes.size() - 1);
if (_lastProcessedCmd != cmd)
- debugC(kDebugLevelScripts, "[Script idx: %d] 0x%02X: %s (%d, %d, %d, %d, %d, %d, %d, %d, %d)",
- scriptIndex, cmd->opcode, _opcodes[cmd->opcode]->name,
+ debugC(kDebugLevelScripts, "[Script idx: %d] %2d: %s (%d, %d, %d, %d, %d, %d, %d, %d, %d)",
+ scriptIndex, cmdIndex, _opcodes[cmd->opcode]->name,
cmd->param1, cmd->param2, cmd->param3, cmd->param4, cmd->param5,
cmd->param6, cmd->param7, cmd->param8, cmd->param9);
@@ -433,7 +433,7 @@ label_processNextEntry:
if (!nextIndex)
goto label_exit_processing;
- nextIndex = _queue.entries[nextIndex].field_C;
+ nextIndex = _queue.entries[nextIndex].next;
scriptIndex = _queue.entries[nextIndex].scriptIndex;
if (scriptIndex == -1)
@@ -2078,8 +2078,8 @@ void ScriptManager::setNextLine(int32 line) {
if (!_currentQueueEntry)
error("[ScriptManager::setNextLine] No current queue entry");
- int32 opcode = _currentScript->commands[line].opcode;
- if (opcode == 0x10 || opcode == 0) { // Return
+ OpcodeType opcode = _currentScript->commands[line].opcode;
+ if (opcode == kOpcodeReturn1 || opcode == kOpcodeReturn) {
_currentQueueEntry->currentLine = line;
} else {
_done = true;
diff --git a/engines/asylum/resources/script.h b/engines/asylum/resources/script.h
index 98f7bac1bf..e233d836c6 100644
--- a/engines/asylum/resources/script.h
+++ b/engines/asylum/resources/script.h
@@ -184,8 +184,8 @@ private:
int32 scriptIndex;
int32 currentLine;
ActorIndex actorIndex;
- uint32 field_C;
- uint32 field_10;
+ uint32 next;
+ uint32 prev;
ScriptQueueEntry() {
reset();
@@ -195,23 +195,23 @@ private:
scriptIndex = -1;
currentLine = 0;
actorIndex = 0;
- field_C = 0;
- field_10 = 0;
+ next = 0;
+ prev = 0;
}
void saveLoadWithSerializer(Common::Serializer &s) {
s.syncAsSint32LE(scriptIndex);
s.syncAsSint32LE(currentLine);
s.syncAsUint32LE(actorIndex);
- s.syncAsUint32LE(field_C);
- s.syncAsUint32LE(field_10);
+ s.syncAsUint32LE(next);
+ s.syncAsUint32LE(prev);
}
};
struct ScriptQueue : public Common::Serializable {
ScriptQueueEntry entries[10];
- uint32 currentEntry;
- uint32 field_CC;
+ uint32 first;
+ uint32 last;
ScriptQueue() {
reset();
@@ -221,16 +221,16 @@ private:
for (uint32 i = 0; i < ARRAYSIZE(entries); i++)
entries[i].reset();
- currentEntry = 0;
- field_CC = 0;
+ first = 0;
+ last = 0;
}
void saveLoadWithSerializer(Common::Serializer &s) {
for (uint32 i = 0; i < ARRAYSIZE(entries); i++)
entries[i].saveLoadWithSerializer(s);
- s.syncAsUint32LE(currentEntry);
- s.syncAsUint32LE(field_CC);
+ s.syncAsUint32LE(first);
+ s.syncAsUint32LE(last);
}
};
Commit: 69599ccdc6e2179a221e0df33de893571e7bbb8a
https://github.com/scummvm/scummvm/commit/69599ccdc6e2179a221e0df33de893571e7bbb8a
Author: alxpnv (alxpnv22 at yahoo.com)
Date: 2021-05-17T15:37:39+02:00
Commit Message:
ASYLUM: fix kOpcode(Set|Clear)CurrentItemOptions. From xesf@
Changed paths:
engines/asylum/resources/encounters.cpp
diff --git a/engines/asylum/resources/encounters.cpp b/engines/asylum/resources/encounters.cpp
index c17456f149..befcd07328 100644
--- a/engines/asylum/resources/encounters.cpp
+++ b/engines/asylum/resources/encounters.cpp
@@ -1548,7 +1548,7 @@ void Encounter::runScript() {
case kOpcodeSetCurrentItemOptions:
if (entry.param1)
- _item->keywords[findKeyword(_item, entry.param2)] &= ~((kKeywordOptionsDisabled << 8) + 1);
+ _item->keywords[findKeyword(_item, entry.param2)] &= -((kKeywordOptionsDisabled << 8) + 1);
else
_item->keywords[findKeyword(_item, entry.param2)] |= (kKeywordOptionsVisible << 8);
break;
@@ -1557,7 +1557,7 @@ void Encounter::runScript() {
if (entry.param1)
_item->keywords[findKeyword(_item, entry.param2)] |= (kKeywordOptionsDisabled << 8);
else
- _item->keywords[findKeyword(_item, entry.param2)] &= ~((kKeywordOptionsVisible << 8) + 1);
+ _item->keywords[findKeyword(_item, entry.param2)] &= -((kKeywordOptionsVisible << 8) + 1);
break;
case kOpcodeSetItemOptions:
Commit: bba8b4f83978020a1a01ed85765ff2efedb723af
https://github.com/scummvm/scummvm/commit/bba8b4f83978020a1a01ed85765ff2efedb723af
Author: alxpnv (alxpnv22 at yahoo.com)
Date: 2021-05-17T15:37:39+02:00
Commit Message:
ASYLUM: add a command to show encounter commands
Changed paths:
engines/asylum/console.cpp
engines/asylum/console.h
diff --git a/engines/asylum/console.cpp b/engines/asylum/console.cpp
index 5b5597edf6..45ad61330f 100644
--- a/engines/asylum/console.cpp
+++ b/engines/asylum/console.cpp
@@ -189,9 +189,11 @@ Console::Console(AsylumEngine *engine) : _vm(engine) {
registerCmd("show_script", WRAP_METHOD(Console, cmdShowScript));
registerCmd("scene", WRAP_METHOD(Console, cmdChangeScene));
- registerCmd("encounter", WRAP_METHOD(Console, cmdRunEncounter));
registerCmd("puzzle", WRAP_METHOD(Console, cmdRunPuzzle));
+ registerCmd("encounter", WRAP_METHOD(Console, cmdRunEncounter));
+ registerCmd("show_enc", WRAP_METHOD(Console, cmdShowEncounter));
+
registerCmd("items", WRAP_METHOD(Console, cmdListItems));
registerCmd("grab", WRAP_METHOD(Console, cmdAddToInventory));
registerCmd("throw", WRAP_METHOD(Console, cmdRemoveFromInventory));
@@ -248,10 +250,12 @@ bool Console::cmdHelp(int, const char **) {
debugPrintf(" video - play a video\n");
debugPrintf(" script - run a script\n");
debugPrintf(" scene - change the scene\n");
- debugPrintf(" show_script - Show script commands\n");
- debugPrintf(" encounter - run an encounter\n");
+ debugPrintf(" show_script - show script commands\n");
debugPrintf(" puzzle - run an puzzle\n");
debugPrintf("\n");
+ debugPrintf(" encounter - run an encounter\n");
+ debugPrintf(" show_enc - show encounter commands\n");
+ debugPrintf("\n");
debugPrintf(" items - list all grabbable objects\n");
debugPrintf(" grab - add an item to inventory\n");
debugPrintf(" throw - remove an item from inventory\n");
@@ -632,6 +636,32 @@ bool Console::cmdRunEncounter(int32 argc, const char **argv) {
return false;
}
+bool Console::cmdShowEncounter(int32 argc, const char **argv) {
+ if (argc != 2) {
+ debugPrintf("Syntax: %s <encounter index>\n", argv[0]);
+ return true;
+ }
+
+ // Check index is valid
+ int32 index = atoi(argv[1]);
+ if (index < 0 || index >= (int32)getEncounter()->_items.size()) {
+ debugPrintf("[Error] Invalid index (was: %d - valid: [0-%d])\n", index, getEncounter()->_items.size() - 1);
+ return true;
+ }
+
+ int32 i = 0;
+ ResourceId resourceId = getEncounter()->_items[index].scriptResourceId;
+ do {
+ Encounter::ScriptEntry entry = getEncounter()->getScriptEntry(resourceId, i);
+
+ if (entry.opcode > 25)
+ break;
+ debugPrintf("%2d %s\n", i, entry.toString().c_str());
+ } while (++i);
+
+ return true;
+}
+
bool Console::cmdRunPuzzle(int32 argc, const char **argv) {
if (argc != 2) {
debugPrintf("Syntax: %s <puzzle index>\n", argv[0]);
diff --git a/engines/asylum/console.h b/engines/asylum/console.h
index 7e8b808295..c498acce4b 100644
--- a/engines/asylum/console.h
+++ b/engines/asylum/console.h
@@ -73,9 +73,11 @@ private:
bool cmdShowScript(int32 argc, const char **argv);
bool cmdRunScript(int32 argc, const char **argv);
bool cmdChangeScene(int32 argc, const char **argv);
- bool cmdRunEncounter(int32 argc, const char **argv);
bool cmdRunPuzzle(int32 argc, const char **argv);
+ bool cmdRunEncounter(int32 argc, const char **argv);
+ bool cmdShowEncounter(int32 argc, const char **argv);
+
bool cmdListItems(int32 argc, const char **argv);
bool cmdAddToInventory(int32 argc, const char **argv);
bool cmdRemoveFromInventory(int32 argc, const char **argv);
Commit: 219dbbbee5d1ea7c4383b5d0910548b8dc4425bc
https://github.com/scummvm/scummvm/commit/219dbbbee5d1ea7c4383b5d0910548b8dc4425bc
Author: alxpnv (alxpnv22 at yahoo.com)
Date: 2021-05-17T15:37:39+02:00
Commit Message:
ASYLUM: fix reverse animation playback
Changed paths:
engines/asylum/resources/object.cpp
diff --git a/engines/asylum/resources/object.cpp b/engines/asylum/resources/object.cpp
index 1d9364535a..453d64b8bc 100644
--- a/engines/asylum/resources/object.cpp
+++ b/engines/asylum/resources/object.cpp
@@ -353,7 +353,7 @@ void Object::update() {
if ((flags & kObjectFlag10000) && (_vm->getTick() - _tickCount >= (uint32)Common::Rational(1000, _field_B4).toInt())) {
- ++_frameIndex;
+ --_frameIndex;
if (_frameIndex == 0) {
flags &= ~kObjectFlag10000;
Commit: 6876b50e4f5622740f1c880f226b2ae63d14f190
https://github.com/scummvm/scummvm/commit/6876b50e4f5622740f1c880f226b2ae63d14f190
Author: alxpnv (alxpnv22 at yahoo.com)
Date: 2021-05-17T15:37:39+02:00
Commit Message:
ASYLUM: add scene motion logging
Changed paths:
engines/asylum/views/scene.cpp
diff --git a/engines/asylum/views/scene.cpp b/engines/asylum/views/scene.cpp
index d189565603..915357cc1d 100644
--- a/engines/asylum/views/scene.cpp
+++ b/engines/asylum/views/scene.cpp
@@ -1034,8 +1034,8 @@ void Scene::updateAdjustScreen() {
void Scene::updateCoordinates() {
Actor *act = getActor();
- int16 xLeft = _ws->xLeft;
- int16 yTop = _ws->yTop;
+ int16 xLeft = _ws->xLeft, oxLeft = xLeft;
+ int16 yTop = _ws->yTop, oyTop = yTop;
int16 posX = act->getPoint1()->x - _ws->xLeft;
int16 posY = act->getPoint1()->y - _ws->yTop;
Common::Rect boundingRect = _ws->boundingRect;
@@ -1129,6 +1129,9 @@ void Scene::updateCoordinates() {
// XXX dword_44E1EC is set to 2 at this point if the scene coordinates
// have changed, but that variable is never used anywhere else
+ if ((_ws->motionStatus == 2 || _ws->motionStatus == 5) && (oxLeft != _ws->xLeft || oyTop != _ws->yTop))
+ debugC(kDebugLevelScene, "[Scene::updateCoordinates] (%d, %d) ~> (%d, %d), motionStatus = %d",
+ _ws->xLeft, _ws->yTop, _ws->coordinates[0], _ws->coordinates[1], _ws->motionStatus);
}
void Scene::updateCursor(ActorDirection direction, const Common::Rect &rect) {
Commit: 761d99e2994243c6b78daf0763936687608bfb64
https://github.com/scummvm/scummvm/commit/761d99e2994243c6b78daf0763936687608bfb64
Author: alxpnv (alxpnv22 at yahoo.com)
Date: 2021-05-17T15:37:39+02:00
Commit Message:
ASYLUM: fix index out of range
Changed paths:
engines/asylum/resources/actor.cpp
diff --git a/engines/asylum/resources/actor.cpp b/engines/asylum/resources/actor.cpp
index 2fe435de46..e7240b4959 100644
--- a/engines/asylum/resources/actor.cpp
+++ b/engines/asylum/resources/actor.cpp
@@ -2288,7 +2288,7 @@ void Actor::updateStatusEnabled() {
if (!getSharedData()->getFlag(kFlagActorUpdateEnabledCheck)) {
if (!isInActionArea(pt, area)) {
- Common::Point polyPoint = poly.points[rnd(poly.count())];
+ Common::Point polyPoint = poly.points[rnd(poly.count() - 1)];
processStatus(polyPoint.x, polyPoint.y, false);
} else {
processStatus(pt.x, pt.y, false);
Commit: 4df214d0404762ebf93c0567b33457f3082ada4d
https://github.com/scummvm/scummvm/commit/4df214d0404762ebf93c0567b33457f3082ada4d
Author: alxpnv (alxpnv22 at yahoo.com)
Date: 2021-05-17T15:37:40+02:00
Commit Message:
ASYLUM: implement SharedData::(set|get)Chapter2Data()
Changed paths:
engines/asylum/resources/data.cpp
diff --git a/engines/asylum/resources/data.cpp b/engines/asylum/resources/data.cpp
index 7b3f688c91..723b45adc5 100644
--- a/engines/asylum/resources/data.cpp
+++ b/engines/asylum/resources/data.cpp
@@ -135,12 +135,27 @@ void SharedData::reset() {
_chapter2FrameIndexOffset = 1;
}
+static const uint32 chapter2DataSizes[5] = {5, 9, 23, 18, 9};
void SharedData::setChapter2Data(uint32 index, int32 offset, int32 val) {
- error("[SharedData::setChapter2Data] Not implemented");
+ uint32 *chapter2Data[] = {_chapter2Data1, _chapter2Data2, (uint32 *)_chapter2Data3, _chapter2Data4, _chapter2Data5};
+
+ if (index == 0 || index > 5)
+ error("[SharedData::setChapter2Data] Invalid index (was: %d, valid: [1;5])", index);
+ if (offset >= chapter2DataSizes[index - 1])
+ error("[SharedData::setChapter2Data] Invalid offset (was: %d, valid: [0;%d])", offset, chapter2DataSizes[index - 1] - 1);
+
+ chapter2Data[index - 1][offset] = val;
}
int32 SharedData::getChapter2Data(uint32 index, int32 offset) {
- error("[SharedData::getChapter2Data] Not implemented");
+ const uint32 *chapter2Data[] = {_chapter2Data1, _chapter2Data2, (uint32 *)_chapter2Data3, _chapter2Data4, _chapter2Data5};
+
+ if (index == 0 || index > 5)
+ error("[SharedData::getChapter2Data] Invalid index (was: %d, valid: [1;5])", index);
+ if (offset >= chapter2DataSizes[index - 1])
+ error("[SharedData::getChapter2Data] Invalid offset (was: %d, valid: [0;%d])", offset, chapter2DataSizes[index - 1] - 1);
+
+ return (int32)chapter2Data[index - 1][offset];
}
void SharedData::setChapter2Counter(uint32 index, int32 val) {
Commit: f89dd2baeaee72771407f8156dcb82a034fd1286
https://github.com/scummvm/scummvm/commit/f89dd2baeaee72771407f8156dcb82a034fd1286
Author: alxpnv (alxpnv22 at yahoo.com)
Date: 2021-05-17T15:37:40+02:00
Commit Message:
ASYLUM: add a command to terminate a script
Changed paths:
engines/asylum/console.cpp
engines/asylum/console.h
diff --git a/engines/asylum/console.cpp b/engines/asylum/console.cpp
index 45ad61330f..d1562f6776 100644
--- a/engines/asylum/console.cpp
+++ b/engines/asylum/console.cpp
@@ -187,6 +187,7 @@ Console::Console(AsylumEngine *engine) : _vm(engine) {
registerCmd("video", WRAP_METHOD(Console, cmdPlayVideo));
registerCmd("script", WRAP_METHOD(Console, cmdRunScript));
registerCmd("show_script", WRAP_METHOD(Console, cmdShowScript));
+ registerCmd("kill_script", WRAP_METHOD(Console, cmdKillScript));
registerCmd("scene", WRAP_METHOD(Console, cmdChangeScene));
registerCmd("puzzle", WRAP_METHOD(Console, cmdRunPuzzle));
@@ -251,6 +252,7 @@ bool Console::cmdHelp(int, const char **) {
debugPrintf(" script - run a script\n");
debugPrintf(" scene - change the scene\n");
debugPrintf(" show_script - show script commands\n");
+ debugPrintf(" kill_script - terminate a script\n");
debugPrintf(" puzzle - run an puzzle\n");
debugPrintf("\n");
debugPrintf(" encounter - run an encounter\n");
@@ -575,6 +577,24 @@ bool Console::cmdRunScript(int32 argc, const char **argv) {
return false;
}
+bool Console::cmdKillScript(int32 argc, const char **argv) {
+ if (argc == 1) {
+ debugPrintf("Scripts running:\n");
+ for (uint32 i = 0; i < ARRAYSIZE(getScript()->_queue.entries); i++)
+ if (getScript()->_queue.entries[i].scriptIndex > 0)
+ debugPrintf(" %d\n", getScript()->_queue.entries[i].scriptIndex);
+
+ return true;
+ }
+
+ int32 index = atoi(argv[1]);
+
+ if (getScript()->isInQueue(index))
+ getScript()->updateQueue(index);
+
+ return false;
+}
+
bool Console::cmdChangeScene(int32 argc, const char **argv) {
if (argc != 2) {
debugPrintf("Syntax: %s <scene number>\n", argv[0]);
diff --git a/engines/asylum/console.h b/engines/asylum/console.h
index c498acce4b..0b62f0a366 100644
--- a/engines/asylum/console.h
+++ b/engines/asylum/console.h
@@ -72,6 +72,7 @@ private:
bool cmdPlayVideo(int32 argc, const char **argv);
bool cmdShowScript(int32 argc, const char **argv);
bool cmdRunScript(int32 argc, const char **argv);
+ bool cmdKillScript(int32 argc, const char **argv);
bool cmdChangeScene(int32 argc, const char **argv);
bool cmdRunPuzzle(int32 argc, const char **argv);
Commit: 46c7750585ca48234053bf2307972eab62208b1b
https://github.com/scummvm/scummvm/commit/46c7750585ca48234053bf2307972eab62208b1b
Author: alxpnv (alxpnv22 at yahoo.com)
Date: 2021-05-17T15:37:40+02:00
Commit Message:
ASYLUM: unblock chapter 11
Changed paths:
engines/asylum/resources/actor.cpp
engines/asylum/shared.h
engines/asylum/views/scene.cpp
diff --git a/engines/asylum/resources/actor.cpp b/engines/asylum/resources/actor.cpp
index e7240b4959..2f53d3a314 100644
--- a/engines/asylum/resources/actor.cpp
+++ b/engines/asylum/resources/actor.cpp
@@ -2328,6 +2328,16 @@ void Actor::updateStatusEnabled() {
break;
}
}
+
+ // XXX
+ if (getWorld()->chapter == kChapter11 && _index == 9)
+ // the following block is originally from updateStatus12_Chapter11_Actor1()
+ if (_vm->isGameFlagNotSet(kGameFlag1099)) {
+ _vm->setGameFlag(kGameFlag1099);
+ _reaction[0] = 1;
+ _reaction[1] = 2;
+ _reaction[2] = 3;
+ }
}
void Actor::updateStatusEnabledProcessStatus(int16 testX, int16 testY, uint32 counter, int16 setX, int16 setY) {
diff --git a/engines/asylum/shared.h b/engines/asylum/shared.h
index 229451f422..ba972c1f91 100644
--- a/engines/asylum/shared.h
+++ b/engines/asylum/shared.h
@@ -180,6 +180,7 @@ enum GameFlag {
kGameFlag1065 = 1065,
kGameFlag1066 = 1066,
kGameFlag1067 = 1067,
+ kGameFlag1099 = 1099,
kGameFlag1108 = 1108,
kGameFlag1131 = 1131,
kGameFlag1137 = 1137,
diff --git a/engines/asylum/views/scene.cpp b/engines/asylum/views/scene.cpp
index 915357cc1d..a799d187c2 100644
--- a/engines/asylum/views/scene.cpp
+++ b/engines/asylum/views/scene.cpp
@@ -144,7 +144,8 @@ void Scene::enter(ResourcePackId packId) {
for (uint32 i = 1; i < _ws->actors.size(); i++) {
Actor *actor = _ws->actors[i];
- actor->hide();
+ if (_ws->chapter == kChapter11) // DELETEME
+ actor->show();
actor->setDirection(kDirectionNW);
actor->enable();
Commit: 26f33b822bed6d66644302293e69a66be48dd511
https://github.com/scummvm/scummvm/commit/26f33b822bed6d66644302293e69a66be48dd511
Author: alxpnv (alxpnv22 at yahoo.com)
Date: 2021-05-17T15:37:40+02:00
Commit Message:
ASYLUM: fix ScriptManager::enableObject()
Changed paths:
engines/asylum/resources/script.cpp
diff --git a/engines/asylum/resources/script.cpp b/engines/asylum/resources/script.cpp
index 71909f59cb..7be6a80774 100644
--- a/engines/asylum/resources/script.cpp
+++ b/engines/asylum/resources/script.cpp
@@ -1927,12 +1927,13 @@ void ScriptManager::enableObject(ScriptEntry *cmd, ObjectTransparency type) {
}
// Update first set of objects
- for (int i = 0; i < 7; i++) {
- Object *object = getWorld()->getObjectById((ObjectId)cmd->param4);
+ int32 *param = &cmd->param4;
+ for (int i = 0; i < 6; i++) {
+ Object *object = getWorld()->getObjectById((ObjectId)*param);
if (object != NULL)
object->setTransparency(transparency);
- ++cmd->param4;
+ ++param;
}
// Update per-chapter objects
@@ -1976,7 +1977,7 @@ void ScriptManager::enableObject(ScriptEntry *cmd, ObjectTransparency type) {
if (cmd->param1 == 2003) {
getWorld()->getObjectById(kObjectNPC066StatusQuo)->setTransparency(transparency);
- getWorld()->getObjectById(kObject2507)->setTransparency(transparency);
+ /* getWorld()->getObjectById(kObject2507)->setTransparency(transparency); // XXX no such object */
getWorld()->getObjectById(kObjectBrokenPipe)->setTransparency(transparency);
getWorld()->getObjectById(kObjectEmberPopsOut)->setTransparency(transparency);
getWorld()->getObjectById(kObjectBugCarriesEmber)->setTransparency(transparency);
Commit: bce91352eb5cd40b122efd09cefb36f1b0cce169
https://github.com/scummvm/scummvm/commit/bce91352eb5cd40b122efd09cefb36f1b0cce169
Author: alxpnv (alxpnv22 at yahoo.com)
Date: 2021-05-17T15:37:40+02:00
Commit Message:
ASYLUM: fix PlaySoundUpdateObject opcode
Changed paths:
engines/asylum/resources/script.cpp
diff --git a/engines/asylum/resources/script.cpp b/engines/asylum/resources/script.cpp
index 7be6a80774..5b7c7d8d6f 100644
--- a/engines/asylum/resources/script.cpp
+++ b/engines/asylum/resources/script.cpp
@@ -1489,7 +1489,7 @@ IMPLEMENT_OPCODE(PlaySoundUpdateObject)
}
} else {
_vm->setGameFlag(kGameFlagScriptProcessing);
- getSpeech()->play(MAKE_RESOURCE(kResourcePackSpeech, 515 + cmd->param1), MAKE_RESOURCE(kResourcePackShared, 1290 + cmd->param1));
+ getSpeech()->play(MAKE_RESOURCE(kResourcePackSpeech, 515 + cmd->param1), MAKE_RESOURCE(kResourcePackText, 1290 + cmd->param1));
if (cmd->param2) {
getScene()->getActor(cmd->param5)->updateStatus(kActorStatus8);
@@ -1500,8 +1500,10 @@ IMPLEMENT_OPCODE(PlaySoundUpdateObject)
if (cmd->param4)
getWorld()->getObjectById((ObjectId)cmd->param4)->disable();
- if (cmd->param3)
- getWorld()->getObjectById((ObjectId)cmd->param3)->setNextFrame(getWorld()->getObjectById((ObjectId)cmd->param4)->flags);
+ if (cmd->param3) {
+ Object *object = getWorld()->getObjectById((ObjectId)cmd->param3);
+ object->setNextFrame(object->flags);
+ }
}
cmd->param6 = 1;
Commit: ea894a619f1c853721ca77c04e9fde31fe83711a
https://github.com/scummvm/scummvm/commit/ea894a619f1c853721ca77c04e9fde31fe83711a
Author: alxpnv (alxpnv22 at yahoo.com)
Date: 2021-05-17T15:37:40+02:00
Commit Message:
ASYLUM: (Writings puzzle) implement text masking
Changed paths:
engines/asylum/puzzles/writings.cpp
engines/asylum/puzzles/writings.h
engines/asylum/system/screen.h
diff --git a/engines/asylum/puzzles/writings.cpp b/engines/asylum/puzzles/writings.cpp
index 9d592c2a89..b2ec149445 100644
--- a/engines/asylum/puzzles/writings.cpp
+++ b/engines/asylum/puzzles/writings.cpp
@@ -42,6 +42,7 @@ PuzzleWritings::PuzzleWritings(AsylumEngine *engine) : Puzzle(engine) {
}
PuzzleWritings::~PuzzleWritings() {
+ _textSurface.free();
}
//////////////////////////////////////////////////////////////////////////
@@ -64,10 +65,34 @@ bool PuzzleWritings::init(const AsylumEvent &) {
getCursor()->set(getWorld()->graphicResourceIds[61], -1, kCursorAnimationNone, 7);
}
+ _textSurface.create(640, 480, Graphics::PixelFormat::createFormatCLUT8());
+
+ // Draw background
+ getScreen()->draw(getWorld()->graphicResourceIds[5]);
+
+ // Draw all lines of text
+ getText()->loadFont(getWorld()->graphicResourceIds[42]);
+ getText()->draw(0, 99, kTextNormal, Common::Point( 70, 45), 16, 590, getText()->get(MAKE_RESOURCE(kResourcePackText, 1825)));
+ getText()->draw(0, 99, kTextNormal, Common::Point(130, 75), 16, 590, getText()->get(MAKE_RESOURCE(kResourcePackText, 1826)));
+ getText()->draw(0, 99, kTextNormal, Common::Point( 70, 105), 16, 590, getText()->get(MAKE_RESOURCE(kResourcePackText, 1827)));
+ getText()->draw(0, 99, kTextNormal, Common::Point(130, 135), 16, 590, getText()->get(MAKE_RESOURCE(kResourcePackText, 1828)));
+ getText()->draw(0, 99, kTextNormal, Common::Point( 70, 165), 16, 590, getText()->get(MAKE_RESOURCE(kResourcePackText, 1829)));
+ getText()->draw(0, 99, kTextNormal, Common::Point(130, 195), 16, 590, getText()->get(MAKE_RESOURCE(kResourcePackText, 1830)));
+ getText()->draw(0, 99, kTextNormal, Common::Point( 70, 225), 16, 590, getText()->get(MAKE_RESOURCE(kResourcePackText, 1831)));
+ getText()->draw(0, 99, kTextNormal, Common::Point(130, 255), 16, 590, getText()->get(MAKE_RESOURCE(kResourcePackText, 1832)));
+ getText()->draw(0, 99, kTextNormal, Common::Point( 70, 285), 16, 590, getText()->get(MAKE_RESOURCE(kResourcePackText, 1833)));
+ getText()->draw(0, 99, kTextNormal, Common::Point(130, 315), 16, 590, getText()->get(MAKE_RESOURCE(kResourcePackText, 1834)));
+ getText()->draw(0, 99, kTextCenter, Common::Point( 20, 375), 16, 590, getText()->get(MAKE_RESOURCE(kResourcePackText, 1835)));
+ getText()->draw(0, 99, kTextCenter, Common::Point( 20, 405), 16, 590, getText()->get(MAKE_RESOURCE(kResourcePackText, 1836)));
+
+ _textSurface.copyFrom(*getScreen()->getSurface());
+
return false;
}
bool PuzzleWritings::update(const AsylumEvent &) {
+ int16 x1, y1, x2, y2;
+
// Adjust palette
if (rnd(10) < 7) {
getScreen()->setPalette(getWorld()->graphicResourceIds[6]);
@@ -88,16 +113,25 @@ bool PuzzleWritings::update(const AsylumEvent &) {
--_frameIndex;
}
- // TODO Compute rects to update
+ mousePos.x -= 50;
+ mousePos.y -= 50;
+ x1 = mousePos.x + 20;
+ y1 = mousePos.y + 20;
+ x2 = mousePos.x + 95;
+ y2 = mousePos.y + 90;
+ if (y1 < 0)
+ y1 = 0;
+ if (y2 > 480)
+ y2 = 480;
// Draw background
getScreen()->clearGraphicsInQueue();
getScreen()->draw(getWorld()->graphicResourceIds[4]);
if (_hasGlassMagnifier) {
- drawBackground();
-
- // The original blits part of the background onto the surface (9) and then adds it to the queue
+ getScreen()->copyToBackBuffer(
+ ((byte *)_textSurface.getPixels()) + y1 * _textSurface.pitch + x1 * _textSurface.format.bytesPerPixel,
+ _textSurface.pitch, x1, y1, (uint16)(x2 - x1), (uint16)(y2 - y1));
getScreen()->addGraphicToQueueMasked(getWorld()->graphicResourceIds[9], 0, mousePos, getWorld()->graphicResourceIds[8], mousePos, kDrawFlagNone, 2);
getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[7], (uint32)_frameIndex, mousePos, kDrawFlagNone, 0, 1);
@@ -119,28 +153,4 @@ bool PuzzleWritings::mouseRightUp(const AsylumEvent &) {
return false;
}
-//////////////////////////////////////////////////////////////////////////
-// Helpers
-//////////////////////////////////////////////////////////////////////////
-
-void PuzzleWritings::drawBackground() {
- // Draw background
- getScreen()->draw(getWorld()->graphicResourceIds[5]);
-
- // Draw all lines of text
- getText()->loadFont(getWorld()->graphicResourceIds[42]);
- getText()->draw(0, 99, kTextNormal, Common::Point( 70, 45), 16, 590, getText()->get(MAKE_RESOURCE(kResourcePackText, 1825)));
- getText()->draw(0, 99, kTextNormal, Common::Point(130, 75), 16, 590, getText()->get(MAKE_RESOURCE(kResourcePackText, 1826)));
- getText()->draw(0, 99, kTextNormal, Common::Point( 70, 105), 16, 590, getText()->get(MAKE_RESOURCE(kResourcePackText, 1827)));
- getText()->draw(0, 99, kTextNormal, Common::Point(130, 135), 16, 590, getText()->get(MAKE_RESOURCE(kResourcePackText, 1828)));
- getText()->draw(0, 99, kTextNormal, Common::Point( 70, 165), 16, 590, getText()->get(MAKE_RESOURCE(kResourcePackText, 1829)));
- getText()->draw(0, 99, kTextNormal, Common::Point(130, 195), 16, 590, getText()->get(MAKE_RESOURCE(kResourcePackText, 1830)));
- getText()->draw(0, 99, kTextNormal, Common::Point( 70, 225), 16, 590, getText()->get(MAKE_RESOURCE(kResourcePackText, 1831)));
- getText()->draw(0, 99, kTextNormal, Common::Point(130, 255), 16, 590, getText()->get(MAKE_RESOURCE(kResourcePackText, 1832)));
- getText()->draw(0, 99, kTextNormal, Common::Point( 70, 285), 16, 590, getText()->get(MAKE_RESOURCE(kResourcePackText, 1833)));
- getText()->draw(0, 99, kTextNormal, Common::Point(130, 315), 16, 590, getText()->get(MAKE_RESOURCE(kResourcePackText, 1834)));
- getText()->draw(0, 99, kTextCenter, Common::Point(320, 375), 16, 590, getText()->get(MAKE_RESOURCE(kResourcePackText, 1835)));
- getText()->draw(0, 99, kTextCenter, Common::Point(320, 405), 16, 590, getText()->get(MAKE_RESOURCE(kResourcePackText, 1836)));
-}
-
} // End of namespace Asylum
diff --git a/engines/asylum/puzzles/writings.h b/engines/asylum/puzzles/writings.h
index cbd5f1a4a6..a075ead6cf 100644
--- a/engines/asylum/puzzles/writings.h
+++ b/engines/asylum/puzzles/writings.h
@@ -24,6 +24,7 @@
#define ASYLUM_WRITINGS_H
#include "asylum/puzzles/puzzle.h"
+#include "asylum/system/graphics.h"
namespace Asylum {
@@ -38,6 +39,7 @@ private:
int32 _frameIndex;
bool _hasGlassMagnifier;
+ Graphics::Surface _textSurface;
//////////////////////////////////////////////////////////////////////////
// Event Handling
@@ -46,18 +48,6 @@ private:
bool update(const AsylumEvent &evt);
bool key(const AsylumEvent &evt) { return keyExit(evt); }
bool mouseRightUp(const AsylumEvent &evt);
-
- //////////////////////////////////////////////////////////////////////////
- // Helpers
- //////////////////////////////////////////////////////////////////////////
-
- /**
- * Draw the background.
- *
- * @note the original draws the background once during initialization
- * and saves the resulting surface into the original background
- */
- void drawBackground();
};
} // End of namespace Asylum
diff --git a/engines/asylum/system/screen.h b/engines/asylum/system/screen.h
index 95e975d72a..0e2aa55ec2 100644
--- a/engines/asylum/system/screen.h
+++ b/engines/asylum/system/screen.h
@@ -131,6 +131,9 @@ public:
void drawRect(const Common::Rect &rect, uint32 color = 0xFF);
void copyToBackBufferClipped(Graphics::Surface *surface, int16 x, int16 y);
+ // Used by Writings puzzle
+ const Graphics::Surface *getSurface() const { return &_backBuffer; };
+
protected:
// Palette fading Timer
static void paletteFadeTimer(void *ptr);
Commit: a29d42231b53ed15dcb13daa3e72e8de30fc4c47
https://github.com/scummvm/scummvm/commit/a29d42231b53ed15dcb13daa3e72e8de30fc4c47
Author: alxpnv (alxpnv22 at yahoo.com)
Date: 2021-05-17T15:37:40+02:00
Commit Message:
ASYLUM: fix a few bugs related to scene motion
Changed paths:
engines/asylum/views/scene.cpp
diff --git a/engines/asylum/views/scene.cpp b/engines/asylum/views/scene.cpp
index a799d187c2..fb7c3129ee 100644
--- a/engines/asylum/views/scene.cpp
+++ b/engines/asylum/views/scene.cpp
@@ -1090,9 +1090,8 @@ void Scene::updateCoordinates() {
if (_ws->coordinates[1] != _ws->yTop)
xLeft = _ws->xLeft = getSharedData()->getSceneOffset() + getSharedData()->getSceneCoords().x;
- xLeft = _ws->coordinates[2] + _ws->xLeft;
- _ws->xLeft += _ws->coordinates[2];
-
+ yTop = _ws->coordinates[2] + _ws->yTop;
+ _ws->yTop += _ws->coordinates[2];
} else {
coord1 = _ws->coordinates[0];
coord2 = xLeft;
@@ -1100,8 +1099,8 @@ void Scene::updateCoordinates() {
if (_ws->coordinates[0] != _ws->xLeft)
yTop = _ws->yTop = getSharedData()->getSceneOffset() + getSharedData()->getSceneCoords().y;
- yTop = _ws->coordinates[2] + _ws->yTop;
- _ws->yTop += _ws->coordinates[2];
+ xLeft = _ws->coordinates[2] + _ws->xLeft;
+ _ws->xLeft += _ws->coordinates[2];
}
if (abs(coord2 - coord1) <= abs(_ws->coordinates[2])) {
@@ -2125,7 +2124,7 @@ bool Scene::updateSceneCoordinates(int32 tX, int32 tY, int32 A0, bool checkScene
if (*targetX + 640 > sr->right)
*targetX = sr->right - 640;
- if (*targetY + 480 < sr->bottom)
+ if (*targetY + 480 > sr->bottom)
*targetY = sr->bottom - 480;
if (checkSceneCoords)
Commit: df473f0927a09e65a2948c3506c348441ded0e66
https://github.com/scummvm/scummvm/commit/df473f0927a09e65a2948c3506c348441ded0e66
Author: alxpnv (alxpnv22 at yahoo.com)
Date: 2021-05-17T15:37:41+02:00
Commit Message:
ASYLUM: check if the denominator is not zero
Changed paths:
engines/asylum/views/scene.cpp
diff --git a/engines/asylum/views/scene.cpp b/engines/asylum/views/scene.cpp
index fb7c3129ee..bb8b27780c 100644
--- a/engines/asylum/views/scene.cpp
+++ b/engines/asylum/views/scene.cpp
@@ -2142,7 +2142,8 @@ bool Scene::updateSceneCoordinates(int32 tX, int32 tY, int32 A0, bool checkScene
if (_ws->yTop > *targetY)
*coord3 = -*coord3;
- getSharedData()->setSceneOffsetAdd((int16)Common::Rational(*coord3 * diffX, diffY).toInt());
+ if (diffY)
+ getSharedData()->setSceneOffsetAdd((int16)Common::Rational(*coord3 * diffX, diffY).toInt());
if (param != NULL && abs(diffY) <= abs(*coord3)) {
*targetX = -1;
Commit: ff03d8fe89206deae7cd59e12f016372105732ce
https://github.com/scummvm/scummvm/commit/ff03d8fe89206deae7cd59e12f016372105732ce
Author: alxpnv (alxpnv22 at yahoo.com)
Date: 2021-05-17T15:37:41+02:00
Commit Message:
ASYLUM: restore palette after finishing playing a video
Changed paths:
engines/asylum/resources/encounters.cpp
diff --git a/engines/asylum/resources/encounters.cpp b/engines/asylum/resources/encounters.cpp
index befcd07328..03332b8fa1 100644
--- a/engines/asylum/resources/encounters.cpp
+++ b/engines/asylum/resources/encounters.cpp
@@ -1202,7 +1202,7 @@ void Encounter::drawScreen() {
getScene()->updateScreen();
getScreen()->drawWideScreenBars(82);
- getScreen()->updatePalette();
+ getScreen()->updatePalette(0);
getScreen()->setupPalette(NULL, 0, 0);
if (getSharedData()->getMattePlaySound() /* Scene::updateScreen() does script processing, so the value might have changed */
Commit: 52b02ee180e7571ce2f8150c485faaaeddfb71b6
https://github.com/scummvm/scummvm/commit/52b02ee180e7571ce2f8150c485faaaeddfb71b6
Author: alxpnv (alxpnv22 at yahoo.com)
Date: 2021-05-17T15:37:41+02:00
Commit Message:
ASYLUM: fix a few bugs in chapter 2's hard-coded logic
Changed paths:
engines/asylum/resources/special.cpp
engines/asylum/resources/special.h
diff --git a/engines/asylum/resources/special.cpp b/engines/asylum/resources/special.cpp
index a24e3c06de..fab2a4283b 100644
--- a/engines/asylum/resources/special.cpp
+++ b/engines/asylum/resources/special.cpp
@@ -163,7 +163,7 @@ void Special::chapter2(Object *object, ActorIndex actorIndex) {
break;
case kObjectCrow1Pecks:
- checkObject(object, kGameFlag447, kGameFlag448, kObjectNone);
+ checkObject(object, kGameFlag447, kGameFlag448, getWorld()->objects[0]->getId());
break;
case kObjectCrow2AmbientPecks:
@@ -1445,7 +1445,7 @@ uint32 Special::getCounter(ActorIndex index) const {
}
void Special::checkObject(Object *object, GameFlag flagToSet, GameFlag flagToClear, ObjectId objectId) {
- if (objectId != kObjectInvalid && object->getFrameIndex() == 15) {
+ if (object->getFrameIndex() == 15) {
Object *otherObject = getWorld()->getObjectById(objectId);
debugC(kDebugLevelObjects, "[checkObject] %s -> %s (flags: set %d, clear %d)",
object->getName(), otherObject->getName(), flagToSet, flagToClear);
@@ -1454,9 +1454,9 @@ void Special::checkObject(Object *object, GameFlag flagToSet, GameFlag flagToCle
_vm->clearGameFlag(flagToClear);
if (objectId == kObjectNone)
- otherObject->setFrameIndex(0);
- else
object->setFrameIndex(0);
+ else
+ otherObject->setFrameIndex(0);
}
}
diff --git a/engines/asylum/resources/special.h b/engines/asylum/resources/special.h
index cd01129691..5f20329057 100644
--- a/engines/asylum/resources/special.h
+++ b/engines/asylum/resources/special.h
@@ -94,7 +94,7 @@ private:
ResourceId getResourceId(Object *object, ActorIndex actorIndex);
uint32 getCounter(ActorIndex index) const;
- void checkObject(Object *object, GameFlag flagToSet, GameFlag flagToClear, ObjectId objectId = kObjectInvalid);
+ void checkObject(Object *object, GameFlag flagToSet, GameFlag flagToClear, ObjectId objectId = kObjectNone);
void checkOtherObject(Object *object, ObjectId otherObjectId, GameFlag flagToClear, GameFlag flagToSet);
};
Commit: 0a594dad99b16adc32f3424105ab6d0acbd5a1ae
https://github.com/scummvm/scummvm/commit/0a594dad99b16adc32f3424105ab6d0acbd5a1ae
Author: alxpnv (alxpnv22 at yahoo.com)
Date: 2021-05-17T15:37:41+02:00
Commit Message:
ASYLUM: fix processing order. This makes chapter 6 playable
Changed paths:
engines/asylum/resources/script.cpp
diff --git a/engines/asylum/resources/script.cpp b/engines/asylum/resources/script.cpp
index 5b7c7d8d6f..ed10f51265 100644
--- a/engines/asylum/resources/script.cpp
+++ b/engines/asylum/resources/script.cpp
@@ -428,17 +428,19 @@ bool ScriptManager::process() {
continue;
label_processNextEntry:
- entryIndex = nextIndex;
+ break;
+ }
- if (!nextIndex)
- goto label_exit_processing;
+ entryIndex = nextIndex;
- nextIndex = _queue.entries[nextIndex].next;
- scriptIndex = _queue.entries[nextIndex].scriptIndex;
+ if (!nextIndex)
+ goto label_exit_processing;
- if (scriptIndex == -1)
+ scriptIndex = _queue.entries[nextIndex].scriptIndex;
+ nextIndex = _queue.entries[nextIndex].next;
+
+ if (scriptIndex == -1)
goto label_exit_processing;
- }
}
}
}
Commit: ab69b65e6a58904ee5fc657d67953f6eb2777776
https://github.com/scummvm/scummvm/commit/ab69b65e6a58904ee5fc657d67953f6eb2777776
Author: alxpnv (alxpnv22 at yahoo.com)
Date: 2021-05-17T15:37:41+02:00
Commit Message:
ASYLUM: fix kOpcodeSetCounterFromActorReactions
Changed paths:
engines/asylum/resources/encounters.cpp
diff --git a/engines/asylum/resources/encounters.cpp b/engines/asylum/resources/encounters.cpp
index 03332b8fa1..b420eba79e 100644
--- a/engines/asylum/resources/encounters.cpp
+++ b/engines/asylum/resources/encounters.cpp
@@ -1647,7 +1647,7 @@ void Encounter::runScript() {
break;
case kOpcodeSetCounterFromActorReactions:
- _scriptData.counter = getScene()->getActor()->hasMoreReactions(getVariableInv(entry.param2), _scriptData.vars[1]) ? 1 : 0;
+ _scriptData.counter = getScene()->getActor()->hasMoreReactions(getVariableInv(entry.param2), _scriptData.vars[1]) ? 0 : 1;
break;
case kOpcodePrepareMovie:
Commit: c1a974d41580947916e7bf3bfdf8d4139b95b17e
https://github.com/scummvm/scummvm/commit/c1a974d41580947916e7bf3bfdf8d4139b95b17e
Author: alxpnv (alxpnv22 at yahoo.com)
Date: 2021-05-17T15:37:42+02:00
Commit Message:
ASYLUM: small fixes to Actor::update()
Changed paths:
engines/asylum/resources/actor.cpp
diff --git a/engines/asylum/resources/actor.cpp b/engines/asylum/resources/actor.cpp
index 2f53d3a314..411d4c23fa 100644
--- a/engines/asylum/resources/actor.cpp
+++ b/engines/asylum/resources/actor.cpp
@@ -394,7 +394,7 @@ void Actor::update() {
Actor *player = getScene()->getActor();
getSpeech()->playPlayer(453);
- hide();
+ getScene()->getActor(11)->hide();
player->updateStatus(kActorStatus3);
player->setResourceId(player->getResourcesId(35));
@@ -428,7 +428,7 @@ void Actor::update() {
_vm->setGameFlag(kGameFlag1131);
} else {
- updateGraphicData(25);
+ getScene()->getActor(11)->updateGraphicData(25);
_vm->setGameFlag(kGameFlag556);
}
}
Commit: 2c2c67889d50c8abaa3fd6b12777d543f598b61d
https://github.com/scummvm/scummvm/commit/2c2c67889d50c8abaa3fd6b12777d543f598b61d
Author: alxpnv (alxpnv22 at yahoo.com)
Date: 2021-05-17T15:37:42+02:00
Commit Message:
ASYLUM: add commands to get/set actor's status
Changed paths:
engines/asylum/console.cpp
engines/asylum/console.h
diff --git a/engines/asylum/console.cpp b/engines/asylum/console.cpp
index d1562f6776..0f6045d1f1 100644
--- a/engines/asylum/console.cpp
+++ b/engines/asylum/console.cpp
@@ -192,6 +192,9 @@ Console::Console(AsylumEngine *engine) : _vm(engine) {
registerCmd("scene", WRAP_METHOD(Console, cmdChangeScene));
registerCmd("puzzle", WRAP_METHOD(Console, cmdRunPuzzle));
+ registerCmd("get_status", WRAP_METHOD(Console, cmdGetStatus));
+ registerCmd("set_status", WRAP_METHOD(Console, cmdSetStatus));
+
registerCmd("encounter", WRAP_METHOD(Console, cmdRunEncounter));
registerCmd("show_enc", WRAP_METHOD(Console, cmdShowEncounter));
@@ -255,6 +258,9 @@ bool Console::cmdHelp(int, const char **) {
debugPrintf(" kill_script - terminate a script\n");
debugPrintf(" puzzle - run an puzzle\n");
debugPrintf("\n");
+ debugPrintf(" get_status - get actor's status\n");
+ debugPrintf(" set_status - set actor's status\n");
+ debugPrintf("\n");
debugPrintf(" encounter - run an encounter\n");
debugPrintf(" show_enc - show encounter commands\n");
debugPrintf("\n");
@@ -329,9 +335,14 @@ bool Console::cmdListActors(int32 argc, const char **argv) {
}
if (argc == 1) {
- for (uint32 i = 0; i < getWorld()->actors.size(); i++)
- debugPrintf("%s\n", getWorld()->actors[i]->toString().c_str());
+ Actor *player = getScene()->getActor();
+
+ for (uint32 i = 0; i < getWorld()->actors.size(); i++) {
+ Actor *actor = getWorld()->actors[i];
+ debugPrintf("%c", actor == player ? '*' : ' ');
+ debugPrintf("%s\n", actor->toString().c_str());
+ }
} else if (argc == 2 || argc == 4) {
int index = atoi(argv[1]);
int maxIndex = getWorld()->actors.size() - 1;
@@ -526,6 +537,60 @@ bool Console::cmdPlayVideo(int32 argc, const char **argv) {
return false;
}
+bool Console::cmdGetStatus(int32 argc, const char **argv) {
+ Actor *actor;
+
+ if (argc == 1) {
+ actor = getScene()->getActor();
+ } else if (argc == 2) {
+ int32 index = atoi(argv[1]);
+
+ if (index < 0 || index >= (int32)getWorld()->actors.size()) {
+ debugPrintf("[Error] Invalid actor index (was: %d - valid: [0-%d])\n", index, getWorld()->actors.size() - 1);
+ return true;
+ }
+
+ actor = getScene()->getActor(index);
+ } else {
+ debugPrintf("Syntax: %s (<actor index>)\n", argv[0]);
+ return true;
+ }
+
+ debugPrintf("%s's status = %d\n", actor->getName(), actor->getStatus());
+ return true;
+}
+
+bool Console::cmdSetStatus(int32 argc, const char **argv) {
+ Actor *actor;
+ int32 status;
+
+ if (argc == 2) {
+ actor = getScene()->getActor();
+ status = atoi(argv[1]);
+ } else if (argc == 3) {
+ int32 index = atoi(argv[1]);
+
+ if (index < 0 || index >= (int32)getWorld()->actors.size()) {
+ debugPrintf("[Error] Invalid actor index (was: %d - valid: [0-%d])\n", index, getWorld()->actors.size() - 1);
+ return true;
+ }
+
+ actor = getScene()->getActor(index);
+ status = atoi(argv[2]);
+ } else {
+ debugPrintf("Syntax: %s (<actor index>) <status>\n", argv[0]);
+ return true;
+ }
+
+ if (status <= 0 || status > 21) {
+ debugPrintf("[Error] Invalid status (was: %d - valid: [1-21])\n", status);
+ return true;
+ }
+
+ actor->updateStatus((ActorStatus)status);
+ return false;
+}
+
bool Console::cmdShowScript(int32 argc, const char **argv) {
if (argc != 2) {
debugPrintf("Syntax: %s <script index>\n", argv[0]);
diff --git a/engines/asylum/console.h b/engines/asylum/console.h
index 0b62f0a366..a3aca7837c 100644
--- a/engines/asylum/console.h
+++ b/engines/asylum/console.h
@@ -76,6 +76,9 @@ private:
bool cmdChangeScene(int32 argc, const char **argv);
bool cmdRunPuzzle(int32 argc, const char **argv);
+ bool cmdGetStatus(int32 argc, const char **argv);
+ bool cmdSetStatus(int32 argc, const char **argv);
+
bool cmdRunEncounter(int32 argc, const char **argv);
bool cmdShowEncounter(int32 argc, const char **argv);
Commit: cbbe4a05a4db8dbe8727f5cfa3b9392bef3ebc91
https://github.com/scummvm/scummvm/commit/cbbe4a05a4db8dbe8727f5cfa3b9392bef3ebc91
Author: alxpnv (alxpnv22 at yahoo.com)
Date: 2021-05-17T15:37:42+02:00
Commit Message:
ASYLUM: fix a bug in Scene::hitTestPixel()
Changed paths:
engines/asylum/views/scene.cpp
diff --git a/engines/asylum/views/scene.cpp b/engines/asylum/views/scene.cpp
index bb8b27780c..d0533fe637 100644
--- a/engines/asylum/views/scene.cpp
+++ b/engines/asylum/views/scene.cpp
@@ -1545,7 +1545,7 @@ bool Scene::hitTestPixel(ResourceId resourceId, uint32 frameIndex, int16 x, int1
pixel = (byte *)frame->surface.getBasePtr(x - left, y - frame->y);
}
- if (pixel == 0)
+ if (*pixel == 0)
goto cleanup;
delete resource;
Commit: e4af6a5045d2a4caaf6154dc6ce0720cda9338d7
https://github.com/scummvm/scummvm/commit/e4af6a5045d2a4caaf6154dc6ce0720cda9338d7
Author: alxpnv (alxpnv22 at yahoo.com)
Date: 2021-05-17T15:37:42+02:00
Commit Message:
ASYLUM: fix Actor::hasMoreReactions()
Changed paths:
engines/asylum/resources/actor.cpp
diff --git a/engines/asylum/resources/actor.cpp b/engines/asylum/resources/actor.cpp
index 411d4c23fa..92c8a102d9 100644
--- a/engines/asylum/resources/actor.cpp
+++ b/engines/asylum/resources/actor.cpp
@@ -1826,16 +1826,16 @@ void Actor::addReactionHive(int32 reactionIndex, int32 numberValue01Add) {
if (reactionIndex > 16)
return;
- uint32 count = 0;
- for (int i = 0; i < 8; i++)
- if (_reaction[i])
- count++;
+ uint32 i;
+ for (i = 0; i < 8; i++)
+ if (!_reaction[i])
+ break;
- if (count == 8)
+ if (i == 8)
return;
- if (!numberValue01Add || !_numberValue01)
- _reaction[count] = reactionIndex;
+ if (!hasMoreReactions(reactionIndex, 0))
+ _reaction[i] = reactionIndex;
if (numberValue01Add)
_numberValue01 += numberValue01Add;
@@ -1876,12 +1876,12 @@ bool Actor::hasMoreReactions(int32 reactionIndex, int32 testNumberValue01) const
if (reactionIndex > 16)
return false;
- uint32 count = 0;
- for (int i = 0; i < 8; i++)
- if (_reaction[i])
- count++;
+ uint32 i;
+ for (i = 0; i < 8; i++)
+ if (_reaction[i] == reactionIndex)
+ break;
- if (count == 8)
+ if (i == 8)
return false;
if (testNumberValue01)
Commit: bf523e991831b048732fef21f150b58fa3490e59
https://github.com/scummvm/scummvm/commit/bf523e991831b048732fef21f150b58fa3490e59
Author: alxpnv (alxpnv22 at yahoo.com)
Date: 2021-05-17T15:37:42+02:00
Commit Message:
ASYLUM: set a game flag when the Hive Control puzzle is solved
Changed paths:
engines/asylum/puzzles/hivecontrol.cpp
engines/asylum/shared.h
diff --git a/engines/asylum/puzzles/hivecontrol.cpp b/engines/asylum/puzzles/hivecontrol.cpp
index eda9266be6..feb0c28a9a 100644
--- a/engines/asylum/puzzles/hivecontrol.cpp
+++ b/engines/asylum/puzzles/hivecontrol.cpp
@@ -246,6 +246,7 @@ bool PuzzleHiveControl::mouseLeftDown(const AsylumEvent &) {
getScreen()->setupTransTables(3, getWorld()->cellShadeMask1, getWorld()->cellShadeMask2, getWorld()->cellShadeMask3);
getScreen()->selectTransTable(1);
+ _vm->setGameFlag(kGameFlagSolveHiveControl);
_vm->switchEventHandler(getScene());
}
}
@@ -270,6 +271,7 @@ bool PuzzleHiveControl::mouseLeftDown(const AsylumEvent &) {
getScreen()->setupTransTables(3, getWorld()->cellShadeMask1, getWorld()->cellShadeMask2, getWorld()->cellShadeMask3);
getScreen()->selectTransTable(1);
+ _vm->setGameFlag(kGameFlagSolveHiveControl);
_vm->switchEventHandler(getScene());
}
}
diff --git a/engines/asylum/shared.h b/engines/asylum/shared.h
index ba972c1f91..845f006008 100644
--- a/engines/asylum/shared.h
+++ b/engines/asylum/shared.h
@@ -132,6 +132,7 @@ enum GameFlag {
kGameFlag635 = 635,
kGameFlag636 = 636,
kGameFlag637 = 637,
+ kGameFlagSolveHiveControl = 640,
kGameFlag724 = 724,
kGameFlag727 = 727,
kGameFlag730 = 730,
Commit: 471ac0abfd63db1a23393501f24539504dd53eab
https://github.com/scummvm/scummvm/commit/471ac0abfd63db1a23393501f24539504dd53eab
Author: alxpnv (alxpnv22 at yahoo.com)
Date: 2021-05-17T15:37:42+02:00
Commit Message:
ASYLUM: fix a few bugs in Object::update()
Changed paths:
engines/asylum/resources/object.cpp
diff --git a/engines/asylum/resources/object.cpp b/engines/asylum/resources/object.cpp
index 453d64b8bc..ad058a6cdf 100644
--- a/engines/asylum/resources/object.cpp
+++ b/engines/asylum/resources/object.cpp
@@ -373,7 +373,7 @@ void Object::update() {
if (BYTE1(flags) & kObjectFlag2) {
if (_frameIndex == _frameCount - 1) {
_frameIndex--;
- flags = (BYTE1(flags) & 0xFD) | kObjectFlag4;
+ BYTE1(flags) = (BYTE1(flags) & 0xFD) | kObjectFlag4;
} else {
_frameIndex++;
}
@@ -381,8 +381,8 @@ void Object::update() {
if (_frameIndex) {
_frameIndex--;
} else {
- _frameIndex++;
- flags = (BYTE1(flags) & 0xFB) | kObjectFlag2;
+ _frameIndex = 1;
+ BYTE1(flags) = (BYTE1(flags) & 0xFB) | kObjectFlag2;
}
}
}
Commit: cbd1dc6c070b401c47ee9cb79bfa643ae1eaeafc
https://github.com/scummvm/scummvm/commit/cbd1dc6c070b401c47ee9cb79bfa643ae1eaeafc
Author: alxpnv (alxpnv22 at yahoo.com)
Date: 2021-05-17T15:37:43+02:00
Commit Message:
ASYLUM: use correct flag
Changed paths:
engines/asylum/resources/script.cpp
diff --git a/engines/asylum/resources/script.cpp b/engines/asylum/resources/script.cpp
index ed10f51265..8ab3c0559d 100644
--- a/engines/asylum/resources/script.cpp
+++ b/engines/asylum/resources/script.cpp
@@ -1102,7 +1102,7 @@ END_OPCODE
IMPLEMENT_OPCODE(ResetSceneRect)
getWorld()->sceneRectIdx = (uint8)LOBYTE(cmd->param1);
getScreen()->paletteFade(0, 25, 10);
- getSharedData()->setFlag(kFlagSceneRectChanged, true);
+ getSharedData()->setFlag(kFlagScene1, true);
getWorld()->xLeft = getWorld()->sceneRects[getWorld()->sceneRectIdx].left;
getWorld()->yTop = getWorld()->sceneRects[getWorld()->sceneRectIdx].top;
Commit: bbd42feed20f87c481326f3f7191a628b0a7972d
https://github.com/scummvm/scummvm/commit/bbd42feed20f87c481326f3f7191a628b0a7972d
Author: alxpnv (alxpnv22 at yahoo.com)
Date: 2021-05-17T15:37:43+02:00
Commit Message:
ASYLUM: fix HasMoreReaction opcode
Changed paths:
engines/asylum/resources/script.cpp
diff --git a/engines/asylum/resources/script.cpp b/engines/asylum/resources/script.cpp
index 8ab3c0559d..dff8d0b18b 100644
--- a/engines/asylum/resources/script.cpp
+++ b/engines/asylum/resources/script.cpp
@@ -876,7 +876,8 @@ END_OPCODE
IMPLEMENT_OPCODE(HasMoreReaction)
Actor *actor = getScene()->getActor(cmd->param4 ? cmd->param4 : _currentQueueEntry->actorIndex);
- actor->hasMoreReactions(cmd->param1, (bool)cmd->param3);
+ if (!actor->hasMoreReactions(cmd->param1, cmd->param3))
+ _currentQueueEntry->currentLine = cmd->param2;
END_OPCODE
//////////////////////////////////////////////////////////////////////////
Commit: b0839e9bac2d6e84854dbf92e6025c56ef0b288b
https://github.com/scummvm/scummvm/commit/b0839e9bac2d6e84854dbf92e6025c56ef0b288b
Author: alxpnv (alxpnv22 at yahoo.com)
Date: 2021-05-17T15:37:43+02:00
Commit Message:
ASYLUM: fix crash on exit
_console is destroyed by the base class destructor
Changed paths:
engines/asylum/asylum.cpp
diff --git a/engines/asylum/asylum.cpp b/engines/asylum/asylum.cpp
index 897648067c..d31bbb5b3a 100644
--- a/engines/asylum/asylum.cpp
+++ b/engines/asylum/asylum.cpp
@@ -111,7 +111,6 @@ AsylumEngine::~AsylumEngine() {
delete _video;
delete _menu;
delete _resource;
- delete _console;
_previousScene = NULL;
Commit: 7214a190b092aec97ee91fcdd8d11118fe4079ba
https://github.com/scummvm/scummvm/commit/7214a190b092aec97ee91fcdd8d11118fe4079ba
Author: alxpnv (alxpnv22 at yahoo.com)
Date: 2021-05-17T15:37:43+02:00
Commit Message:
ASYLUM: fixes to the Encounter system. Partly based on xesf's diff
Changed paths:
engines/asylum/console.cpp
engines/asylum/resources/encounters.cpp
diff --git a/engines/asylum/console.cpp b/engines/asylum/console.cpp
index 0f6045d1f1..60e1ac6336 100644
--- a/engines/asylum/console.cpp
+++ b/engines/asylum/console.cpp
@@ -83,6 +83,7 @@ static const struct EncounterData {
{ 0, kObjectPreAlphaNut, kObjectPreAlphaNut, kActorMax},
{ 1, kObjectPreAlphaNut2, kObjectPreAlphaNut2, kActorMax},
{ 2, kObjectRocker, kObjectRocker, kActorMax},
+ {73, kObjectNone, kObjectNone, kActorMax},
{-1, kObjectNone, kObjectNone, kActorMax}
},
// InnocentAbandoned
@@ -741,7 +742,7 @@ bool Console::cmdShowEncounter(int32 argc, const char **argv) {
if (entry.opcode > 25)
break;
- debugPrintf("%2d %s\n", i, entry.toString().c_str());
+ debugPrintf("%3d %s\n", i, entry.toString().c_str());
} while (++i);
return true;
diff --git a/engines/asylum/resources/encounters.cpp b/engines/asylum/resources/encounters.cpp
index b420eba79e..0785aabbc3 100644
--- a/engines/asylum/resources/encounters.cpp
+++ b/engines/asylum/resources/encounters.cpp
@@ -250,7 +250,8 @@ void Encounter::initDrawStructs() {
// Run
//////////////////////////////////////////////////////////////////////////
void Encounter::run(int32 encounterIndex, ObjectId objectId1, ObjectId objectId2, ActorIndex actorIndex) {
- debugC(kDebugLevelEncounter, "[Encounter] Running Encounter %d", encounterIndex);
+ debugC(kDebugLevelEncounter, "[Encounter] Running Encounter %d: object1 = %d object2 = %d actor = %d",
+ encounterIndex, objectId1, objectId2, actorIndex);
if (!_speechResourceId) {
_item = &_items[0];
@@ -462,12 +463,9 @@ bool Encounter::update() {
if (doScript
&& !getSharedData()->getMatteBarHeight()
- && _isScriptRunning) {
- if (getSpeech()->getTextData() && _objectId1)
- setupSpeechTest(id);
- else
- runScript();
- }
+ && _isScriptRunning
+ && !setupSpeechTest(id))
+ runScript();
}
// Redraw screen
@@ -829,12 +827,15 @@ bool Encounter::setupSpeechTest(ResourceId id) {
setupEntities(false);
+ if (id == kResourceNone)
+ id = getSpeech()->getTextResourceId();
+
char *text = getText()->get(id);
- if (text[strlen(text) - 2] == 1) {
+ if (text[strlen(text) - 1] == 1) {
setupEntities(true);
getSpeech()->setTextResourceId(kResourceNone);
- getSpeech()->setTextData(0);
- getSpeech()->setTextDataPos(0);
+ getSpeech()->setTextData(NULL);
+ getSpeech()->setTextDataPos(NULL);
_data_455BCC = false;
_data_455B3C = 1;
@@ -897,10 +898,10 @@ bool Encounter::drawBackground() {
}
if (_shouldCloseBackground) {
- --_background.frameIndex;
-
if (_background.frameIndex == 0)
exitEncounter();
+ else
+ --_background.frameIndex;
return false;
}
@@ -1129,7 +1130,7 @@ void Encounter::drawDialogOptions() {
_point.y + (int16)(16 * (counter / 3)));
if (getKeywordIndex() == keywordIndex)
- getScreen()->fillRect(coords.x - 1, coords.y + 5, getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 3681 + (keyword & KEYWORD_MASK))), 18, 0);
+ getScreen()->fillRect(coords.x - 1, coords.y + 5, getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 3681 + (keyword & KEYWORD_MASK))) + 2, 18, 0);
getText()->setPosition(coords);
getText()->draw(MAKE_RESOURCE(kResourcePackText, 3681 + (keyword & KEYWORD_MASK)));
@@ -1416,8 +1417,8 @@ bool Encounter::updateScreen() {
updateDrawingStatus();
drawStructs();
- if (_rectIndex == -1 && findRect() == -1)
- updateFromRect(-1);
+ if (_rectIndex != -1 && findRect() == _rectIndex)
+ updateFromRect(_rectIndex);
return false;
}
@@ -1485,11 +1486,10 @@ void Encounter::runScript() {
default:
break;
- case kOpcodeReturn:
+ case kOpcodeEncounterReturn:
_isScriptRunning = false;
done = true;
_value1 = 0;
- getSpeech()->resetTextData();
break;
case kOpcodeSetScriptVariable:
@@ -1676,7 +1676,7 @@ void Encounter::runScript() {
break;
case kOpcodeSetCounterFromGameFlag:
- _scriptData.counter = _vm->isGameFlagSet((GameFlag)getVariableInv(entry.param2)) ? 1 : 0;
+ _scriptData.counter = _vm->isGameFlagSet((GameFlag)getVariableInv(entry.param2)) ? 1 : 0;
break;
}
Commit: 733f109acc6424471df0d9e2cd24df20329cda2b
https://github.com/scummvm/scummvm/commit/733f109acc6424471df0d9e2cd24df20329cda2b
Author: alxpnv (alxpnv22 at yahoo.com)
Date: 2021-05-17T15:37:43+02:00
Commit Message:
ASYLUM: return true if the test point is on the border of the polygon
Changed paths:
engines/asylum/resources/polygons.cpp
diff --git a/engines/asylum/resources/polygons.cpp b/engines/asylum/resources/polygons.cpp
index a08250cd69..bc334a905b 100644
--- a/engines/asylum/resources/polygons.cpp
+++ b/engines/asylum/resources/polygons.cpp
@@ -41,11 +41,11 @@ bool Polygon::contains(const Common::Point &point) {
Common::Point *vtx0 = &points[count() - 1];
Common::Point *vtx1 = &points[0];
- yflag0 = (vtx0->y >= point.y);
+ yflag0 = (vtx0->y > point.y);
for (uint32 pt = 0; pt < count(); pt++, vtx1++) {
- yflag1 = (vtx1->y >= point.y);
+ yflag1 = (vtx1->y > point.y);
if (yflag0 != yflag1) {
- if (((vtx1->y - point.y) * (vtx0->x - vtx1->x) >= (vtx1->x - point.x) * (vtx0->y - vtx1->y)) == yflag1) {
+ if (((vtx1->y - point.y) * (vtx0->x - vtx1->x) > (vtx1->x - point.x) * (vtx0->y - vtx1->y)) == yflag1) {
inside_flag = !inside_flag;
}
}
Commit: 4fb8b25682e114970264728881ac48cfa497ab5e
https://github.com/scummvm/scummvm/commit/4fb8b25682e114970264728881ac48cfa497ab5e
Author: alxpnv (alxpnv22 at yahoo.com)
Date: 2021-05-17T15:37:44+02:00
Commit Message:
ASYLUM: add a separate debug channel for script commands
Changed paths:
engines/asylum/asylum.cpp
engines/asylum/console.h
engines/asylum/resources/actor.cpp
engines/asylum/resources/script.cpp
diff --git a/engines/asylum/asylum.cpp b/engines/asylum/asylum.cpp
index d31bbb5b3a..b1fd8ceaf9 100644
--- a/engines/asylum/asylum.cpp
+++ b/engines/asylum/asylum.cpp
@@ -88,6 +88,7 @@ AsylumEngine::AsylumEngine(OSystem *system, const ADGameDescription *gd) : Engin
DebugMan.addDebugChannel(kDebugLevelActor, "Actor", "Debug Actor");
DebugMan.addDebugChannel(kDebugLevelEncounter, "Encounter", "Debug Encounter");
DebugMan.addDebugChannel(kDebugLevelVideo, "Video", "Debug Video");
+ DebugMan.addDebugChannel(kDebugLevelCommands, "Commands", "Script commands debugging");
// Initialize random number source
_rnd = new Common::RandomSource("asylum");
diff --git a/engines/asylum/console.h b/engines/asylum/console.h
index a3aca7837c..a446bebcec 100644
--- a/engines/asylum/console.h
+++ b/engines/asylum/console.h
@@ -42,7 +42,8 @@ enum kDebugLevels {
kDebugLevelObjects = 1 << 9,
kDebugLevelActor = 1 << 10,
kDebugLevelEncounter = 1 << 11,
- kDebugLevelVideo = 1 << 12
+ kDebugLevelVideo = 1 << 12,
+ kDebugLevelCommands = 1 << 13,
};
class AsylumEngine;
diff --git a/engines/asylum/resources/actor.cpp b/engines/asylum/resources/actor.cpp
index 92c8a102d9..46cd50cc82 100644
--- a/engines/asylum/resources/actor.cpp
+++ b/engines/asylum/resources/actor.cpp
@@ -3314,7 +3314,7 @@ void Actor::updateFinish() {
debugC(kDebugLevelScripts, "[Script] Entered ActionArea (idx: %d, name: %s)", areaIndex, area->name);
debugC(kDebugLevelScripts, "[Script] Queuing Script #1 (idx: %d) for Actor (idx: %d)", actorArea->scriptIndex2, _index);
getScript()->queueScript(actorArea->scriptIndex2, _index);
- debugC(kDebugLevelScripts, "[Script] Queuing Script #2 (idx: %d) for Actor (idx: %d)", actorArea->scriptIndex, _index);
+ debugC(kDebugLevelScripts, "[Script] Queuing Script #2 (idx: %d) for Actor (idx: %d)", area->scriptIndex, _index);
getScript()->queueScript(area->scriptIndex, _index);
}
diff --git a/engines/asylum/resources/script.cpp b/engines/asylum/resources/script.cpp
index dff8d0b18b..f6c93acf56 100644
--- a/engines/asylum/resources/script.cpp
+++ b/engines/asylum/resources/script.cpp
@@ -403,7 +403,7 @@ bool ScriptManager::process() {
error("[ScriptManager::process] Invalid opcode index (was: %d, max: %d)", cmd->opcode, _opcodes.size() - 1);
if (_lastProcessedCmd != cmd)
- debugC(kDebugLevelScripts, "[Script idx: %d] %2d: %s (%d, %d, %d, %d, %d, %d, %d, %d, %d)",
+ debugC(kDebugLevelCommands, "[Script idx: %d] %2d: %s (%d, %d, %d, %d, %d, %d, %d, %d, %d)",
scriptIndex, cmdIndex, _opcodes[cmd->opcode]->name,
cmd->param1, cmd->param2, cmd->param3, cmd->param4, cmd->param5,
cmd->param6, cmd->param7, cmd->param8, cmd->param9);
Commit: b725db3de0bfdb30f7ee9ecf126a94c5fe04748f
https://github.com/scummvm/scummvm/commit/b725db3de0bfdb30f7ee9ecf126a94c5fe04748f
Author: alxpnv (alxpnv22 at yahoo.com)
Date: 2021-05-17T15:37:44+02:00
Commit Message:
ASYLUM: identify more ActorStatus values
Changed paths:
engines/asylum/resources/actor.cpp
engines/asylum/resources/script.cpp
engines/asylum/resources/special.cpp
engines/asylum/shared.h
engines/asylum/views/scene.cpp
diff --git a/engines/asylum/resources/actor.cpp b/engines/asylum/resources/actor.cpp
index 46cd50cc82..7abd9b893d 100644
--- a/engines/asylum/resources/actor.cpp
+++ b/engines/asylum/resources/actor.cpp
@@ -358,7 +358,7 @@ void Actor::update() {
default:
break;
- case kActorStatus16:
+ case kActorStatusGettingHurt:
if (_index != getSharedData()->getPlayerIndex())
break;
@@ -369,7 +369,7 @@ void Actor::update() {
}
break;
- case kActorStatus17:
+ case kActorStatusRestarting:
if (getWorld()->chapter == kChapter2) {
if (_index > 12) {
if (_frameIndex <= _frameCount - 1) {
@@ -396,7 +396,7 @@ void Actor::update() {
getSpeech()->playPlayer(453);
getScene()->getActor(11)->hide();
- player->updateStatus(kActorStatus3);
+ player->updateStatus(kActorStatusInteracting);
player->setResourceId(player->getResourcesId(35));
player->setDirection(kDirectionS);
player->setFrameCount(GraphicResource::getFrameCount(_vm, player->getResourceId()));
@@ -439,7 +439,7 @@ void Actor::update() {
++_frameIndex;
} else {
_vm->clearGameFlag(kGameFlag239);
- getScene()->getActor(10)->updateStatus(kActorStatus14);
+ getScene()->getActor(10)->updateStatus(kActorStatusEnabled2);
hide();
_vm->setGameFlag(kGameFlag238);
@@ -461,7 +461,7 @@ void Actor::update() {
}
break;
- case kActorStatus15:
+ case kActorStatusAttacking:
if (getWorld()->chapter == kChapter2) {
if (_index > 12)
updateStatus15_Chapter2();
@@ -505,7 +505,7 @@ void Actor::update() {
}
break;
- case kActorStatus12:
+ case kActorStatusWalking2:
if (getWorld()->chapter == kChapter2) {
if (_index > 12)
updateStatus12_Chapter2();
@@ -578,7 +578,7 @@ void Actor::update() {
break;
case kActorStatusWalkingTo:
- case kActorStatus13: {
+ case kActorStatusWalkingTo2: {
uint32 index = (_frameIndex >= _frameCount) ? 2 * _frameCount - (_frameIndex + 1) : _frameIndex;
int32 dist = (int32)abs((double)getDistanceForFrame(_direction, index));
@@ -637,8 +637,8 @@ void Actor::update() {
}
break;
- case kActorStatus3:
- case kActorStatus19:
+ case kActorStatusInteracting:
+ case kActorStatusHittingPumpkin:
updateStatus3_19();
break;
@@ -654,11 +654,11 @@ void Actor::update() {
updateStatusEnabled();
break;
- case kActorStatus14:
+ case kActorStatusEnabled2:
updateStatus14();
break;
- case kActorStatus21:
+ case kActorStatusMorphingInto:
updateStatus21();
break;
@@ -666,7 +666,7 @@ void Actor::update() {
updateStatus9();
break;
- case kActorStatus6:
+ case kActorStatusShowingInventory:
case kActorStatus10:
_frameIndex = (_frameIndex + 1) % _frameCount;
break;
@@ -704,35 +704,35 @@ void Actor::updateStatus(ActorStatus actorStatus) {
break;
case kActorStatusWalking:
- case kActorStatus12:
+ case kActorStatusWalking2:
if ((getWorld()->chapter == kChapter2
- && _index == getSharedData()->getPlayerIndex() && (_status == kActorStatus18 || _status == kActorStatus16 || _status == kActorStatus17))
- || (_status != kActorStatusEnabled && _status != kActorStatusFidget && _status != kActorStatus14 && _status != kActorStatus15 && _status != kActorStatus18))
+ && _index == getSharedData()->getPlayerIndex() && (_status == kActorStatus18 || _status == kActorStatusGettingHurt || _status == kActorStatusRestarting))
+ || (_status != kActorStatusEnabled && _status != kActorStatusFidget && _status != kActorStatusEnabled2 && _status != kActorStatusAttacking && _status != kActorStatus18))
return;
updateGraphicData(0);
// Force status in some cases
- if (_status == kActorStatus14 || _status == kActorStatus15 || _status == kActorStatus18) {
- _status = kActorStatus12;
+ if (_status == kActorStatusEnabled2 || _status == kActorStatusAttacking || _status == kActorStatus18) {
+ _status = kActorStatusWalking2;
return;
}
break;
case kActorStatusWalkingTo:
- case kActorStatus13:
+ case kActorStatusWalkingTo2:
updateGraphicData(0);
break;
- case kActorStatus3:
- case kActorStatus19:
+ case kActorStatusInteracting:
+ case kActorStatusHittingPumpkin:
if (!strcmp(_name, "Big Crow"))
_status = kActorStatusEnabled;
break;
case kActorStatusEnabled:
- case kActorStatus6:
- case kActorStatus14:
+ case kActorStatusShowingInventory:
+ case kActorStatusEnabled2:
updateGraphicData(5);
break;
@@ -764,7 +764,7 @@ void Actor::updateStatus(ActorStatus actorStatus) {
case kActorStatus8:
case kActorStatus10:
- case kActorStatus17:
+ case kActorStatusRestarting:
updateGraphicData(20);
break;
@@ -778,9 +778,9 @@ void Actor::updateStatus(ActorStatus actorStatus) {
updateGraphicData(10);
break;
- case kActorStatus15:
- case kActorStatus16:
- updateGraphicData(actorStatus == kActorStatus15 ? 10 : 15);
+ case kActorStatusAttacking:
+ case kActorStatusGettingHurt:
+ updateGraphicData(actorStatus == kActorStatusAttacking ? 10 : 15);
break;
case kActorStatus18:
@@ -1039,7 +1039,7 @@ void Actor::updateFromDirection(ActorDirection actorDirection) {
case kActorStatusDisabled:
case kActorStatusEnabled:
- case kActorStatus14:
+ case kActorStatusEnabled2:
_resourceId = _graphicResourceIds[(actorDirection > kDirectionS ? kDirection8 - actorDirection : actorDirection) + 5];
_frameCount = GraphicResource::getFrameCount(_vm, _resourceId);
break;
@@ -1052,7 +1052,7 @@ void Actor::updateFromDirection(ActorDirection actorDirection) {
case kActorStatusWalking:
case kActorStatusWalkingTo:
- case kActorStatus12:
+ case kActorStatusWalking2:
_resourceId = _graphicResourceIds[(actorDirection > kDirectionS ? kDirection8 - actorDirection : actorDirection)];
break;
@@ -1473,7 +1473,7 @@ void Actor::processStatus(int16 actorX, int16 actorY, bool doSpeech) {
if (_status <= kActorStatus11)
updateStatus(kActorStatusWalkingTo);
else
- updateStatus(kActorStatus13);
+ updateStatus(kActorStatusWalkingTo2);
} else if (doSpeech) {
getSpeech()->playIndexed(1);
}
@@ -1747,8 +1747,8 @@ void Actor::move(ActorDirection actorDir, uint32 dist) {
case kActorStatusWalking:
case kActorStatusWalkingTo:
- case kActorStatus12:
- case kActorStatus13:
+ case kActorStatusWalking2:
+ case kActorStatusWalkingTo2:
updateCoordinatesForDirection(actorDir, (int16)dist, &_point1);
_frameIndex = (_frameIndex + 1) % _frameCount;
@@ -2037,7 +2037,7 @@ void Actor::updateAndDraw() {
}
void Actor::update_409230() {
- updateStatus(_status <= 11 ? kActorStatusEnabled : kActorStatus14);
+ updateStatus(_status <= 11 ? kActorStatusEnabled : kActorStatusEnabled2);
_data.current = 0;
}
@@ -2146,7 +2146,7 @@ void Actor::updatePlayerChapter9(AsylumEngine *engine, int nextPlayer) {
break;
}
- player->updateStatus(kActorStatus21);
+ player->updateStatus(kActorStatusMorphingInto);
}
//////////////////////////////////////////////////////////////////////////
@@ -2154,11 +2154,11 @@ void Actor::updatePlayerChapter9(AsylumEngine *engine, int nextPlayer) {
//////////////////////////////////////////////////////////////////////////
void Actor::updateStatus3_19() {
- if (getWorld()->chapter != kChapter2 || _frameIndex != 6 || _status == kActorStatus3) { /* Original check: _status <= kActorStatus11 */
+ if (getWorld()->chapter != kChapter2 || _frameIndex != 6 || _status == kActorStatusInteracting) { /* Original check: _status <= kActorStatus11 */
if (_frameIndex < _frameCount - 1) {
++_frameIndex;
} else {
- if (_status == kActorStatus3)
+ if (_status == kActorStatusInteracting)
updateStatus(kActorStatusPickupItem);
else
updateStatus(kActorStatus20);
@@ -2427,7 +2427,7 @@ void Actor::updateStatus12_Chapter2_Actor11() {
uint32 distance = (uint32)abs((double)getDistanceForFrame(_direction, frameIndex));
// Update status
- if (player->getStatus() == kActorStatus17 || !getScene()->getActor(10)->isVisible()) {
+ if (player->getStatus() == kActorStatusRestarting || !getScene()->getActor(10)->isVisible()) {
updateStatus(kActorStatusEnabled);
getSharedData()->setChapter2Data(1, 3, 160); // &cursorResources + 8 + 11 (actorIndex)
}
@@ -2479,11 +2479,11 @@ void Actor::updateStatus12_Chapter2_Actor11() {
}
if (processEnd) {
- if (player->getStatus() != kActorStatus17 && player->getStatus() != kActorStatus16) {
+ if (player->getStatus() != kActorStatusRestarting && player->getStatus() != kActorStatusGettingHurt) {
if (sqrt((double)((sum.y - sumPlayer.y) * (sum.y - sumPlayer.y) + (sum.x - sumPlayer.x) * (sum.x - sumPlayer.x))) < 80.0) {
_frameIndex = 0;
faceTarget((uint32)getSharedData()->getPlayerIndex(), kDirectionFromActor);
- updateStatus(kActorStatus15);
+ updateStatus(kActorStatusAttacking);
}
}
}
@@ -2519,7 +2519,7 @@ void Actor::updateStatus12_Chapter11() {
if (_frameIndex >= _frameCount) {
_frameIndex = 0;
- updateStatus(kActorStatus14);
+ updateStatus(kActorStatusEnabled2);
getWorld()->tickValueArray[_index] = rnd(4000) + _vm->getTick();
}
@@ -2547,7 +2547,7 @@ void Actor::updateStatus14() {
case kChapter2:
if (_index == 11)
- updateStatus(kActorStatus12);
+ updateStatus(kActorStatusWalking2);
else if (_index > 12)
updateStatus14_Chapter2();
break;
@@ -2562,29 +2562,29 @@ void Actor::updateStatus14() {
void Actor::updateStatus14_Chapter2() {
// Original calls getDistanceForFrame but does not seem to do anything with the results
- if (_status == kActorStatus17 || !getScene()->getActor(10)->isVisible()) {
+ if (_status == kActorStatusRestarting || !getScene()->getActor(10)->isVisible()) {
updateStatus(kActorStatusEnabled);
getSharedData()->setChapter2Data(1, (_index - 13) + 5, 160); // Index > 12
}
- if (_status != kActorStatus16) {
+ if (_status != kActorStatusGettingHurt) {
_point1.x -= (int16)getSharedData()->getChapter2Data(3, 2 * _index + 6);
_point1.y -= (int16)getSharedData()->getChapter2Data(3, 2 * _index + 7) + 54;
}
if (_frameIndex == _frameCount - 1) {
_frameIndex = 0;
- if (getSharedData()->getChapter2Data(2, _index + 6) <= 1 || _status == kActorStatus16 || _status == kActorStatus17) {
+ if (getSharedData()->getChapter2Data(2, _index + 6) <= 1 || _status == kActorStatusGettingHurt || _status == kActorStatusRestarting) {
getSharedData()->setChapter2Data(2, _index + 6, getSharedData()->getChapter2Data(2, _index + 6) + 1);
} else {
- updateStatus(kActorStatus15);
+ updateStatus(kActorStatusAttacking);
_point1.y -= 54;
getSharedData()->setChapter2Data(2, _index + 6, 0);
getSharedData()->setChapter2Data(1, _index + 1, getSharedData()->getChapter2Data(1, _index + 1) + 54);
}
}
- if (_status == kActorStatus17 && getSharedData()->getChapter2Data(2, _index + 6) < 100) {
+ if (_status == kActorStatusRestarting && getSharedData()->getChapter2Data(2, _index + 6) < 100) {
_point1.y -= 6;
getSharedData()->setChapter2Data(2, _index + 6, 100);
getSharedData()->setChapter2Data(1, _index + 1, getSharedData()->getChapter2Data(1, _index + 1) + 6);
@@ -2660,8 +2660,8 @@ void Actor::updateStatus14_Chapter11() {
if (euclidianDistance(getSharedData()->vector1, getSharedData()->vector2) >= 75) {
getWorld()->tickValueArray[_index] = rnd(1000) + 2000 + _vm->getTick();
} else {
- if (actor0->getStatus() == kActorStatus12 || actor0->getStatus() == kActorStatus14 || actor0->getStatus() == kActorStatus15)
- updateStatus(kActorStatus15);
+ if (actor0->getStatus() == kActorStatusWalking2 || actor0->getStatus() == kActorStatusEnabled2 || actor0->getStatus() == kActorStatusAttacking)
+ updateStatus(kActorStatusAttacking);
getWorld()->tickValueArray[_index] = -666;
}
@@ -2674,7 +2674,7 @@ void Actor::updateStatus15_Chapter2() {
Common::Point sum = _point1 + _point2;
Common::Point sumPlayer = *player->getPoint1() + *player->getPoint2();
- if (_status == kActorStatus17 || !getScene()->getActor(10)->isVisible()) {
+ if (_status == kActorStatusRestarting || !getScene()->getActor(10)->isVisible()) {
updateStatus(kActorStatusEnabled);
getSharedData()->setChapter2Data(1, (_index - 13) + 5, 160); // Index > 12
}
@@ -2682,7 +2682,7 @@ void Actor::updateStatus15_Chapter2() {
if (_frameIndex == 1)
getSound()->playSound(getWorld()->soundResourceIds[1], false, Config.sfxVolume - 10);
- if (player->getStatus() == kActorStatus17 && _frameIndex < 6)
+ if (player->getStatus() == kActorStatusRestarting && _frameIndex < 6)
updateStatus(kActorStatusEnabled);
uint32 dist = euclidianDistance(sumPlayer, sum);
@@ -2706,7 +2706,7 @@ void Actor::updateStatus15_Chapter2() {
_point1.y -= offset;
if ((int32)dist < (offset + 1)) {
- if (player->getStatus() != kActorStatus16 && player->getStatus() != kActorStatus17 && player->getFrameIndex() < 6) {
+ if (player->getStatus() != kActorStatusGettingHurt && player->getStatus() != kActorStatusRestarting && player->getFrameIndex() < 6) {
_point1 = sumPlayer - _point2;
updateStatus15_Chapter2_Helper();
@@ -2714,7 +2714,7 @@ void Actor::updateStatus15_Chapter2() {
_vm->setGameFlag(kGameFlag219);
player->updateFromDirection((ActorDirection)((_direction + 4) & 7));
- player->updateStatus(kActorStatus16);
+ player->updateStatus(kActorStatusGettingHurt);
getSharedData()->setChapter2Data(4, _index + 7, 0);
}
@@ -2828,7 +2828,7 @@ void Actor::updateStatus15_Chapter2_Player() {
Actor *otherActor = getScene()->getActor(actorIndex);
- if (otherActor->getStatus() == kActorStatus14) {
+ if (otherActor->getStatus() == kActorStatusEnabled2) {
// FIXME: this is a bit strange, but it looks like the original does exactly that
// this might be dead code (the actor 38 never exists and thus setting values has no effect)
Actor* actor38 = getScene()->getActor(38);
@@ -2899,7 +2899,7 @@ void Actor::updateStatus15_Chapter2_Player() {
break;
}
- otherActor->updateStatus(kActorStatus17);
+ otherActor->updateStatus(kActorStatusRestarting);
getSound()->playSound(getWorld()->soundResourceIds[2], false, Config.sfxVolume - 10);
}
}
@@ -2910,7 +2910,7 @@ void Actor::updateStatus15_Chapter2_Player() {
if (_frameIndex >= _frameCount) {
_frameIndex = 0;
- updateStatus(kActorStatus14);
+ updateStatus(kActorStatusEnabled2);
}
}
@@ -2922,7 +2922,7 @@ void Actor::updateStatus15_Chapter2_Player_Helper() {
Common::Point point(_point1.x + _point2.x, _point1.y + _point2.y);
Common::Point point11(actor11->getPoint1()->x + actor11->getPoint2()->x, actor11->getPoint1()->y + actor11->getPoint2()->y);
- if (actor11->getStatus() == kActorStatus15 && euclidianDistance(point, point11) < 100) {
+ if (actor11->getStatus() == kActorStatusAttacking && euclidianDistance(point, point11) < 100) {
Actor *actor = getScene()->getActor(getSharedData()->getChapter2ActorIndex());
actor40->show();
@@ -2935,14 +2935,14 @@ void Actor::updateStatus15_Chapter2_Player_Helper() {
} else if (getSharedData()->getChapter2Counter(5) <= 6) {
getSound()->playSound(getWorld()->soundResourceIds[9], false, Config.sfxVolume - 10);
} else {
- getScene()->getActor(10)->updateStatus(kActorStatus17);
+ getScene()->getActor(10)->updateStatus(kActorStatusRestarting);
getSound()->playSound(getWorld()->soundResourceIds[10], false, Config.sfxVolume - 10);
}
}
}
bool Actor::updateStatus15_isNoVisibleOrStatus17() {
- return (!isVisible() || _status == kActorStatus17);
+ return (!isVisible() || _status == kActorStatusRestarting);
}
void Actor::updateStatus15_Chapter2_Actor11() {
@@ -2986,12 +2986,12 @@ void Actor::updateStatus15_Chapter2_Actor11() {
&& !updateStatus15_Chapter2_Actor11_Helper(10, 11))
_point1 = actionPoint - _point2;
- if (_frameIndex != 8 || _status == kActorStatus16) { /* FIXME the status test seems useless */
+ if (_frameIndex != 8 || _status == kActorStatusGettingHurt) { /* FIXME the status test seems useless */
if (_frameIndex > _frameCount - 1) {
_frameIndex = 0;
if (!getSharedData()->getFlag(kFlagActorUpdateStatus15Check)) {
- updateStatus(kActorStatus12);
+ updateStatus(kActorStatusWalking2);
} else {
getSharedData()->setFlag(kFlagActorUpdateStatus15Check, false);
getScene()->getActor(11)->updateStatus(kActorStatus18);
@@ -3009,7 +3009,7 @@ void Actor::updateStatus15_Chapter2_Actor11() {
_vm->clearGameFlag(kGameFlag269);
player->update_409230();
- player->updateStatus(kActorStatus16);
+ player->updateStatus(kActorStatusGettingHurt);
updateStatus15_Chapter2_Helper();
getSpeech()->playPlayer(52);
@@ -3060,12 +3060,12 @@ void Actor::updateStatus15_Chapter11() {
++_frameIndex;
if (_frameIndex >= _frameCount)
- updateStatus(kActorStatus14);
+ updateStatus(kActorStatusEnabled2);
if (_frameIndex == 14) {
if (Actor::euclidianDistance(getSharedData()->vector1, getSharedData()->vector2) < 75) {
- actor0->updateStatus(kActorStatus16);
+ actor0->updateStatus(kActorStatusGettingHurt);
++getWorld()->field_E848C;
getSound()->stop(getWorld()->soundResourceIds[3]);
@@ -3097,7 +3097,7 @@ void Actor::updateStatus15_Chapter11_Player() {
double diffY = (actor2->getPoint1()->y + actor2->getPoint2()->y) - (_point1.y + _point2.y);
if (sqrt(diffX * diffX + diffY * diffY) < 75.0f
- && (actor2->getStatus() == kActorStatus14 || actor2->getStatus() == kActorStatus15)) {
+ && (actor2->getStatus() == kActorStatusEnabled2 || actor2->getStatus() == kActorStatusAttacking)) {
getSound()->playSound(getWorld()->soundResourceIds[2]);
switch (getWorld()->field_E849C) {
@@ -3121,7 +3121,7 @@ void Actor::updateStatus15_Chapter11_Player() {
break;
}
- actor2->updateStatus(kActorStatus17);
+ actor2->updateStatus(kActorStatusRestarting);
}
}
}
@@ -3130,7 +3130,7 @@ void Actor::updateStatus15_Chapter11_Player() {
getCursor()->show();
getSharedData()->setFlag(kFlag1, false);
_frameIndex = 0;
- updateStatus(kActorStatus14);
+ updateStatus(kActorStatusEnabled2);
}
}
@@ -3142,7 +3142,7 @@ void Actor::updateStatus16_Chapter2() {
if (player->getFrameIndex() > (player->getFrameCount() - 1)) {
if (getSharedData()->getChapter2Counter(6) <= 2) {
player->setFrameIndex(0);
- updateStatus(kActorStatus14);
+ updateStatus(kActorStatusEnabled2);
} else {
_vm->clearGameFlag(kGameFlag438);
_vm->clearGameFlag(kGameFlag439);
@@ -3155,7 +3155,7 @@ void Actor::updateStatus16_Chapter2() {
_vm->setGameFlag(kGameFlag219);
player->setFrameIndex(0);
- updateStatus(kActorStatus17);
+ updateStatus(kActorStatusRestarting);
_vm->clearGameFlag(kGameFlag369);
_vm->clearGameFlag(kGameFlag370);
@@ -3189,11 +3189,11 @@ void Actor::updateStatus16_Chapter11() {
if (getWorld()->field_E848C >= 3) {
_frameIndex = 0;
- getScene()->getActor(0)->updateStatus(kActorStatus17);
+ getScene()->getActor(0)->updateStatus(kActorStatusRestarting);
_tickCount = _vm->getTick() + 2000;
} else {
- getScene()->getActor(0)->updateStatus(kActorStatus14);
+ getScene()->getActor(0)->updateStatus(kActorStatusEnabled2);
}
}
}
@@ -3203,7 +3203,7 @@ void Actor::updateStatus17_Chapter2() {
if (_frameIndex >= _frameCount) {
_frameIndex = 0;
- updateStatus(kActorStatus14);
+ updateStatus(kActorStatusEnabled2);
hide();
if (_vm->getRandomBit() == 1) {
@@ -3223,7 +3223,7 @@ void Actor::updateStatus18_Chapter2() {
if (_frameIndex > _frameCount - 1) {
getSharedData()->setChapter2Data(4, _index + 7, true);
- updateStatus(kActorStatus14);
+ updateStatus(kActorStatusEnabled2);
_point1.y += 54;
getSound()->playSound(getWorld()->soundResourceIds[1], false, Config.sfxVolume - 10);
@@ -3239,7 +3239,7 @@ void Actor::updateStatus18_Chapter2_Actor11() {
getSharedData()->setChapter2Counter(7, getSharedData()->getChapter2Counter(7) + 1);
if (getSharedData()->getChapter2Counter(7) > 14) {
getSharedData()->setChapter2Counter(7, 0);
- updateStatus(kActorStatus12);
+ updateStatus(kActorStatusWalking2);
}
faceTarget((uint32)getSharedData()->getPlayerIndex(), kDirectionFromActor);
diff --git a/engines/asylum/resources/script.cpp b/engines/asylum/resources/script.cpp
index f6c93acf56..e9f03d4efd 100644
--- a/engines/asylum/resources/script.cpp
+++ b/engines/asylum/resources/script.cpp
@@ -712,7 +712,7 @@ END_OPCODE
IMPLEMENT_OPCODE(JumpAndSetDirection)
Actor *actor = getScene()->getActor(cmd->param1);
- if (actor->getStatus() != kActorStatusWalkingTo && actor->getStatus() != kActorStatus13) {
+ if (actor->getStatus() != kActorStatusWalkingTo && actor->getStatus() != kActorStatusWalkingTo2) {
if (cmd->param5 != 2) {
if (cmd->param2 == -1 || cmd->param3 == -1) {
@@ -980,12 +980,12 @@ IMPLEMENT_OPCODE(UpdateActor)
actor->enable();
break;
- case kActorStatus16:
+ case kActorStatusGettingHurt:
// We want to continue processing and not go into the default case
break;
case kActorStatus20:
- actor->updateStatus(kActorStatus14);
+ actor->updateStatus(kActorStatusEnabled2);
}
cmd->param3 = 0;
@@ -1013,7 +1013,7 @@ IMPLEMENT_OPCODE(UpdateActor)
actor->setFrameCount(GraphicResource::getFrameCount(_vm, id));
actor->setFrameIndex(0);
actor->setDirection(direction);
- actor->updateStatus(actor->getStatus() <= kActorStatus11 ? kActorStatus3 : kActorStatus19);
+ actor->updateStatus(actor->getStatus() <= kActorStatus11 ? kActorStatusInteracting : kActorStatusHittingPumpkin);
cmd->param3 = 2;
_processNextEntry = true;
@@ -1587,7 +1587,7 @@ IMPLEMENT_OPCODE(ChangeActorStatus)
if (cmd->param2) {
if (actor->getStatus() < kActorStatus11)
- actor->setStatus(kActorStatus14);
+ actor->setStatus(kActorStatusEnabled2);
} else {
actor->setStatus(kActorStatusEnabled);
}
@@ -1720,7 +1720,7 @@ END_OPCODE
IMPLEMENT_OPCODE(Interact)
Actor *actor = getScene()->getActor(cmd->param2 == 2 ? kActorInvalid : cmd->param1);
- if (actor->getStatus() == kActorStatusWalkingTo || actor->getStatus() == kActorStatus13) {
+ if (actor->getStatus() == kActorStatusWalkingTo || actor->getStatus() == kActorStatusWalkingTo2) {
if (cmd->param2 == 2)
_processNextEntry = true;
diff --git a/engines/asylum/resources/special.cpp b/engines/asylum/resources/special.cpp
index fab2a4283b..a23fb99351 100644
--- a/engines/asylum/resources/special.cpp
+++ b/engines/asylum/resources/special.cpp
@@ -206,7 +206,7 @@ void Special::chapter2(Object *object, ActorIndex actorIndex) {
}
for (int i = 13; i < 22; i++)
- getScene()->getActor(i)->updateStatus(kActorStatus15);
+ getScene()->getActor(i)->updateStatus(kActorStatusAttacking);
}
// Play chapter sound
@@ -448,12 +448,12 @@ void Special::chapter7(Object *object, ActorIndex actorIndex) {
if (_vm->isGameFlagSet(kGameFlag1021)) {
if (player->getReactionValue(0)) {
- if (player->getStatus() == kActorStatus6 || player->getStatus() == kActorStatus10) {
+ if (player->getStatus() == kActorStatusShowingInventory || player->getStatus() == kActorStatus10) {
getSound()->playSound(MAKE_RESOURCE(kResourcePackSound, 2));
player->enable();
} else {
getSound()->playSound(MAKE_RESOURCE(kResourcePackSound, 5));
- player->updateStatus(kActorStatus6);
+ player->updateStatus(kActorStatusShowingInventory);
}
_vm->setGameFlag(kGameFlag1023);
@@ -469,7 +469,7 @@ void Special::chapter7(Object *object, ActorIndex actorIndex) {
getScript()->queueScript(getWorld()->actions[getWorld()->getActionAreaIndexById(player->getField638() == 3 ? 2447 : 2448)]->scriptIndex,
getSharedData()->getPlayerIndex());
_vm->clearGameFlag(kGameFlag1023);
- } else if (player->getStatus() != kActorStatus6) {
+ } else if (player->getStatus() != kActorStatusShowingInventory) {
_vm->clearGameFlag(kGameFlag1023);
_vm->setGameFlag(kGameFlag1022);
}
diff --git a/engines/asylum/shared.h b/engines/asylum/shared.h
index 845f006008..c1e5a29a0e 100644
--- a/engines/asylum/shared.h
+++ b/engines/asylum/shared.h
@@ -391,27 +391,27 @@ enum ActorIndexes {
enum ActorStatus {
kActorStatusNone = 0,
- kActorStatusWalking = 1, // Walking
- kActorStatusWalkingTo, // Auto-walking to target
- kActorStatus3,
- kActorStatusEnabled, // Standing Still
- kActorStatusDisabled, // 5
- kActorStatus6,
+ kActorStatusWalking = 1, // Walking
+ kActorStatusWalkingTo, // Auto-walking to target
+ kActorStatusInteracting,
+ kActorStatusEnabled, // Standing Still
+ kActorStatusDisabled, // 5
+ kActorStatusShowingInventory,
kActorStatusPickupItem,
kActorStatus8,
kActorStatusFidget,
kActorStatus10,
kActorStatus11,
- kActorStatus12,
- kActorStatus13,
- kActorStatus14,
- kActorStatus15,
- kActorStatus16,
- kActorStatus17,
+ kActorStatusWalking2,
+ kActorStatusWalkingTo2,
+ kActorStatusEnabled2,
+ kActorStatusAttacking, // 15
+ kActorStatusGettingHurt,
+ kActorStatusRestarting,
kActorStatus18,
- kActorStatus19,
+ kActorStatusHittingPumpkin,
kActorStatus20,
- kActorStatus21
+ kActorStatusMorphingInto
};
enum ActorDirection {
diff --git a/engines/asylum/views/scene.cpp b/engines/asylum/views/scene.cpp
index d0533fe637..789c379538 100644
--- a/engines/asylum/views/scene.cpp
+++ b/engines/asylum/views/scene.cpp
@@ -337,8 +337,8 @@ void Scene::activate() {
if (player->getStatus() == kActorStatusWalking)
player->updateStatus(kActorStatusEnabled);
- if (player->getStatus() == kActorStatus12)
- player->updateStatus(kActorStatus14);
+ if (player->getStatus() == kActorStatusWalking2)
+ player->updateStatus(kActorStatusEnabled2);
}
bool Scene::init() {
@@ -536,7 +536,7 @@ bool Scene::clickDown(const AsylumEvent &evt) {
if (getSpeech()->getSoundResourceId())
stopSpeech();
- if (player->getStatus() == kActorStatus6 || player->getStatus() == kActorStatus10) {
+ if (player->getStatus() == kActorStatusShowingInventory || player->getStatus() == kActorStatus10) {
player->updateStatus(kActorStatusEnabled);
getSound()->playSound(MAKE_RESOURCE(kResourcePackSound, 5));
} else if (player->getStatus() != kActorStatusDisabled) {
@@ -546,10 +546,10 @@ bool Scene::clickDown(const AsylumEvent &evt) {
case Common::EVENT_MBUTTONDOWN:
if (player->getStatus() != kActorStatusDisabled) {
- if (player->getStatus() == kActorStatus6 || player->getStatus() == kActorStatus10)
+ if (player->getStatus() == kActorStatusShowingInventory || player->getStatus() == kActorStatus10)
player->updateStatus(kActorStatusEnabled);
else
- player->updateStatus(kActorStatus6);
+ player->updateStatus(kActorStatusShowingInventory);
}
break;
@@ -581,7 +581,7 @@ bool Scene::clickDown(const AsylumEvent &evt) {
}
if (!hitTestPlayer() || player->getStatus() >= kActorStatus11 || !player->getReactionValue(0)) {
- if (player->getStatus() == kActorStatus6 || player->getStatus() == kActorStatus10) {
+ if (player->getStatus() == kActorStatusShowingInventory || player->getStatus() == kActorStatus10) {
playerReaction();
} else {
HitType type = kHitNone;
@@ -592,12 +592,12 @@ bool Scene::clickDown(const AsylumEvent &evt) {
return true;
}
- if (player->getStatus() == kActorStatus6 || player->getStatus() == kActorStatus10) {
+ if (player->getStatus() == kActorStatusShowingInventory || player->getStatus() == kActorStatus10) {
getSound()->playSound(MAKE_RESOURCE(kResourcePackSound, 5));
player->updateStatus(kActorStatusEnabled);
} else {
getSound()->playSound(MAKE_RESOURCE(kResourcePackSound, 2));
- player->updateStatus(kActorStatus6);
+ player->updateStatus(kActorStatusShowingInventory);
}
break;
}
@@ -811,7 +811,7 @@ void Scene::updateMouse() {
updateCursor(newDirection, actorRect);
if (newDirection >= kDirectionN)
- if (player->getStatus() == kActorStatusWalking || player->getStatus() == kActorStatus12)
+ if (player->getStatus() == kActorStatusWalking || player->getStatus() == kActorStatusWalking2)
player->updateFromDirection(newDirection);
}
@@ -1148,7 +1148,7 @@ void Scene::updateCursor(ActorDirection direction, const Common::Rect &rect) {
}
if (getCursor()->getState() & kCursorStateRight) {
- if (player->getStatus() == kActorStatusWalking || player->getStatus() == kActorStatus12) {
+ if (player->getStatus() == kActorStatusWalking || player->getStatus() == kActorStatusWalking2) {
ResourceId resourceId =_ws->cursorResources[direction];
@@ -1159,7 +1159,7 @@ void Scene::updateCursor(ActorDirection direction, const Common::Rect &rect) {
return;
}
- if (player->getStatus() == kActorStatus6 || player->getStatus() == kActorStatus10) {
+ if (player->getStatus() == kActorStatusShowingInventory || player->getStatus() == kActorStatus10) {
if (getCursor()->getResourceId() != _ws->cursorResources[kCursorResourceHand])
getCursor()->set(_ws->cursorResources[kCursorResourceHand]);
@@ -1755,12 +1755,12 @@ void Scene::hitActorChapter2(ActorIndex index) {
Actor *player = getActor();
- if (player->getStatus() != kActorStatus14 && player->getStatus() != kActorStatus12)
+ if (player->getStatus() != kActorStatusEnabled2 && player->getStatus() != kActorStatusWalking2)
return;
if (index == 11) {
player->faceTarget((uint32)(index + 9), kDirectionFromActor);
- player->updateStatus(kActorStatus15);
+ player->updateStatus(kActorStatusAttacking);
Actor *actor11 = getActor(index);
@@ -1768,18 +1768,18 @@ void Scene::hitActorChapter2(ActorIndex index) {
Common::Point pointActor11(actor11->getPoint1()->x + actor11->getPoint2()->x, actor11->getPoint1()->y + actor11->getPoint2()->y);
if (Actor::euclidianDistance(pointPlayer, pointActor11) < 150) {
- if (actor11->getStatus() == kActorStatus12)
+ if (actor11->getStatus() == kActorStatusWalking2)
actor11->updateStatus(kActorStatus18);
if (actor11->getStatus() == kActorStatusEnabled)
- actor11->updateStatus(kActorStatus14);
+ actor11->updateStatus(kActorStatusEnabled2);
}
getSharedData()->setChapter2ActorIndex(index);
} else if (index > 12) {
player->faceTarget((uint32)(index + 9), kDirectionFromActor);
- player->updateStatus(kActorStatus15);
+ player->updateStatus(kActorStatusAttacking);
getSharedData()->setChapter2ActorIndex(index);
}
}
@@ -2430,7 +2430,7 @@ bool Scene::drawScene() {
_ws->objects[i]->draw();
Actor *player = getActor();
- if (player->getStatus() == kActorStatus6 || player->getStatus() == kActorStatus10)
+ if (player->getStatus() == kActorStatusShowingInventory || player->getStatus() == kActorStatus10)
player->updateAndDraw();
else
player->setNumberFlag01(0);
Commit: 27f69f5a321dc848514ac626a409eee5cdf50dd6
https://github.com/scummvm/scummvm/commit/27f69f5a321dc848514ac626a409eee5cdf50dd6
Author: alxpnv (alxpnv22 at yahoo.com)
Date: 2021-05-17T15:37:44+02:00
Commit Message:
ASYLUM: fix kActorStatusWalking2 updating
Changed paths:
engines/asylum/resources/actor.cpp
diff --git a/engines/asylum/resources/actor.cpp b/engines/asylum/resources/actor.cpp
index 7abd9b893d..83a8b7e927 100644
--- a/engines/asylum/resources/actor.cpp
+++ b/engines/asylum/resources/actor.cpp
@@ -507,13 +507,15 @@ void Actor::update() {
case kActorStatusWalking2:
if (getWorld()->chapter == kChapter2) {
- if (_index > 12)
+ if (_index > 12) {
updateStatus12_Chapter2();
+ return;
+ }
- if (_index == 11)
+ if (_index == 11) {
updateStatus12_Chapter2_Actor11();
-
- return;
+ return;
+ }
} else if (getWorld()->chapter == kChapter11) {
switch (_index) {
default:
Commit: f60246580b50cedc2c89f1cfb16bcb18e4870634
https://github.com/scummvm/scummvm/commit/f60246580b50cedc2c89f1cfb16bcb18e4870634
Author: alxpnv (alxpnv22 at yahoo.com)
Date: 2021-05-17T15:37:44+02:00
Commit Message:
ASYLUM: fix Actor::isOnScreen()
Changed paths:
engines/asylum/resources/actor.cpp
diff --git a/engines/asylum/resources/actor.cpp b/engines/asylum/resources/actor.cpp
index 83a8b7e927..1fbf56fa61 100644
--- a/engines/asylum/resources/actor.cpp
+++ b/engines/asylum/resources/actor.cpp
@@ -3736,9 +3736,9 @@ void Actor::setVisible(bool value) {
}
bool Actor::isOnScreen() {
- Common::Rect scene(getWorld()->yTop, getWorld()->xLeft, getWorld()->yTop + 480, getWorld()->xLeft + 640);
+ Common::Rect scene(getWorld()->xLeft, getWorld()->yTop, getWorld()->xLeft + 640, getWorld()->yTop + 480);
Common::Rect actor(_boundingRect);
- actor.moveTo(_point1.x, _point1.y);
+ actor.translate(_point1.x, _point1.y);
return isVisible() && scene.intersects(actor);
}
Commit: 54fe4387c5ca59dd97d8d6d86f99f216728d13f7
https://github.com/scummvm/scummvm/commit/54fe4387c5ca59dd97d8d6d86f99f216728d13f7
Author: alxpnv (alxpnv22 at yahoo.com)
Date: 2021-05-17T15:37:44+02:00
Commit Message:
ASYLUM: corrections to Scare Crow behavior
Changed paths:
engines/asylum/puzzles/lock.cpp
engines/asylum/resources/actor.cpp
engines/asylum/resources/worldstats.cpp
engines/asylum/views/scene.cpp
diff --git a/engines/asylum/puzzles/lock.cpp b/engines/asylum/puzzles/lock.cpp
index 897888e8ee..07047e155b 100644
--- a/engines/asylum/puzzles/lock.cpp
+++ b/engines/asylum/puzzles/lock.cpp
@@ -112,6 +112,7 @@ bool PuzzleLock::update(const AsylumEvent &) {
getSound()->playSound(getWorld()->soundResourceIds[16], false, Config.sfxVolume - 10);
_frameIndexes[6] = 0;
_counter = 0;
+ getSharedData()->reset();
exitPuzzle();
} else {
diff --git a/engines/asylum/resources/actor.cpp b/engines/asylum/resources/actor.cpp
index 1fbf56fa61..64d72159c2 100644
--- a/engines/asylum/resources/actor.cpp
+++ b/engines/asylum/resources/actor.cpp
@@ -44,7 +44,7 @@
namespace Asylum {
-#define DIR(val) (ActorDirection)((val) % 7)
+#define DIR(val) (ActorDirection)((val) & 7)
Actor::Actor(AsylumEngine *engine, ActorIndex index) : _vm(engine), _index(index) {
// Init all variables
@@ -359,12 +359,9 @@ void Actor::update() {
break;
case kActorStatusGettingHurt:
- if (_index != getSharedData()->getPlayerIndex())
- break;
-
if (getWorld()->chapter == 2) {
updateStatus16_Chapter2();
- } else if (getWorld()->chapter == 11) {
+ } else if (getWorld()->chapter == 11 && _index == getSharedData()->getPlayerIndex()) {
updateStatus16_Chapter11();
}
break;
@@ -408,7 +405,7 @@ void Actor::update() {
getScript()->queueScript(getWorld()->getActionAreaById(2696)->scriptIndex, getSharedData()->getPlayerIndex());
_vm->setGameFlag(kGameFlag279);
- _vm->setGameFlag(kGameFlag368);
+ _vm->clearGameFlag(kGameFlag368);
player->setFrameIndex(0);
getScene()->getActor(0)->setLastScreenUpdate(_vm->getTick());
@@ -697,7 +694,6 @@ void Actor::update() {
updateFinish();
}
-
void Actor::updateStatus(ActorStatus actorStatus) {
debugC(kDebugLevelActor, "[updateStatus] %d point1(%d:%d) point2(%d:%d)", actorStatus, _point1.x, _point1.y, _point2.x, _point2.y);
@@ -1101,9 +1097,10 @@ void Actor::faceTarget(uint32 target, DirectionFrom from) {
}
break;
- case kDirectionFromActor:
- point.x = _point1.x + _point2.x;
- point.y = _point1.y + _point2.y;
+ case kDirectionFromActor: {
+ Actor *actor = getScene()->getActor((ActorIndex)target);
+ point = *actor->getPoint1() + *actor->getPoint2();
+ }
break;
case kDirectionFromParameters:
@@ -2239,7 +2236,7 @@ void Actor::updateStatusEnabled() {
// Actor:: BigCrow
if (!strcmp(_name, "Big Crow")) {
if (_vm->getRandom(10) < 5) {
- switch (_vm->getRandom(4)) {
+ switch (_vm->getRandom(3)) {
default:
break;
@@ -2403,6 +2400,9 @@ void Actor::updateStatus12_Chapter2() {
if (absX <= absY)
absX = absY;
+ if (sum.y < sumPlayer.y)
+ absX += 20;
+
if (absX >= 50) {
move(_direction, distance);
} else {
@@ -2455,7 +2455,7 @@ void Actor::updateStatus12_Chapter2_Actor11() {
} else if (canMove(&sum, DIR(_direction + 3), distance, false)) {
move(DIR(_direction + 3), distance);
} else if (canMove(&sum, DIR(_direction + 4), distance, false)) {
- move(DIR(_direction + 1), distance);
+ move(DIR(_direction + 4), distance);
}
} else {
if (canMove(&sum, DIR(_direction + 7), distance, false)) {
@@ -2564,19 +2564,22 @@ void Actor::updateStatus14() {
void Actor::updateStatus14_Chapter2() {
// Original calls getDistanceForFrame but does not seem to do anything with the results
- if (_status == kActorStatusRestarting || !getScene()->getActor(10)->isVisible()) {
+ Actor *player = getScene()->getActor();
+ ActorStatus playerStatus = player->getStatus();
+
+ if (playerStatus == kActorStatusRestarting || !getScene()->getActor(10)->isVisible()) {
updateStatus(kActorStatusEnabled);
getSharedData()->setChapter2Data(1, (_index - 13) + 5, 160); // Index > 12
}
- if (_status != kActorStatusGettingHurt) {
- _point1.x -= (int16)getSharedData()->getChapter2Data(3, 2 * _index + 6);
- _point1.y -= (int16)getSharedData()->getChapter2Data(3, 2 * _index + 7) + 54;
+ if (playerStatus != kActorStatusGettingHurt) {
+ _point1.x = player->getPoint1()->x - (int16)getSharedData()->getChapter2Data(3, 2 * _index + 6);
+ _point1.y = player->getPoint1()->y - (int16)getSharedData()->getChapter2Data(3, 2 * _index + 7) + 54;
}
if (_frameIndex == _frameCount - 1) {
_frameIndex = 0;
- if (getSharedData()->getChapter2Data(2, _index + 6) <= 1 || _status == kActorStatusGettingHurt || _status == kActorStatusRestarting) {
+ if (getSharedData()->getChapter2Data(2, _index + 6) <= 1 || playerStatus == kActorStatusGettingHurt || playerStatus == kActorStatusRestarting) {
getSharedData()->setChapter2Data(2, _index + 6, getSharedData()->getChapter2Data(2, _index + 6) + 1);
} else {
updateStatus(kActorStatusAttacking);
@@ -2586,7 +2589,7 @@ void Actor::updateStatus14_Chapter2() {
}
}
- if (_status == kActorStatusRestarting && getSharedData()->getChapter2Data(2, _index + 6) < 100) {
+ if (playerStatus == kActorStatusRestarting && getSharedData()->getChapter2Data(2, _index + 6) < 100) {
_point1.y -= 6;
getSharedData()->setChapter2Data(2, _index + 6, 100);
getSharedData()->setChapter2Data(1, _index + 1, getSharedData()->getChapter2Data(1, _index + 1) + 6);
@@ -2612,7 +2615,7 @@ void Actor::updateStatus14_Chapter2() {
break;
case 14:
- processStatus(2600, 130, false);
+ processStatus(2600, 1300, false);
break;
case 15:
@@ -2676,7 +2679,7 @@ void Actor::updateStatus15_Chapter2() {
Common::Point sum = _point1 + _point2;
Common::Point sumPlayer = *player->getPoint1() + *player->getPoint2();
- if (_status == kActorStatusRestarting || !getScene()->getActor(10)->isVisible()) {
+ if (getScene()->getActor(10)->getStatus() == kActorStatusRestarting || !getScene()->getActor(10)->isVisible()) {
updateStatus(kActorStatusEnabled);
getSharedData()->setChapter2Data(1, (_index - 13) + 5, 160); // Index > 12
}
@@ -2756,8 +2759,8 @@ void Actor::updateStatus15_Chapter2() {
void Actor::updateStatus15_Chapter2_Helper() {
Actor *actor39 = getScene()->getActor(39);
- actor39->getPoint1()->x = _point1.x;
- actor39->getPoint1()->y = _point1.y;
+ actor39->setFrameIndex(0);
+ *actor39->getPoint1() = *getScene()->getActor()->getPoint1();
if (_vm->isGameFlagSet(kGameFlag169))
actor39->getPoint1()->y += 80;
@@ -2796,11 +2799,11 @@ void Actor::updateStatus15_Chapter2_Helper() {
switch (getSharedData()->getChapter2Counter(6)) {
default:
+ enableActorsChapter2(_vm);
+ getCursor()->hide();
break;
case 0:
- enableActorsChapter2(_vm);
- getCursor()->hide();
break;
case 1:
@@ -2937,7 +2940,7 @@ void Actor::updateStatus15_Chapter2_Player_Helper() {
} else if (getSharedData()->getChapter2Counter(5) <= 6) {
getSound()->playSound(getWorld()->soundResourceIds[9], false, Config.sfxVolume - 10);
} else {
- getScene()->getActor(10)->updateStatus(kActorStatusRestarting);
+ getScene()->getActor(11)->updateStatus(kActorStatusRestarting);
getSound()->playSound(getWorld()->soundResourceIds[10], false, Config.sfxVolume - 10);
}
}
@@ -2984,7 +2987,7 @@ void Actor::updateStatus15_Chapter2_Actor11() {
actionPoint.y += compareY(Common::Point(rect.left, rect.top), Common::Point(rect.right, rect.bottom), sumPlayer);
if (getScene()->getActor(11)->getFrameIndex() < 8
- && getScene()->findActionArea(kActionAreaType2, actionPoint)
+ && getScene()->findActionArea(kActionAreaType2, actionPoint) != -1
&& !updateStatus15_Chapter2_Actor11_Helper(10, 11))
_point1 = actionPoint - _point2;
@@ -3041,7 +3044,7 @@ bool Actor::updateStatus15_Chapter2_Actor11_Helper(ActorIndex actorIndex1, Actor
int16 actor2_y = actor2->getPoint1()->y + actor2->getPoint2()->y;
Common::Point pt1((int16)(actor2_x - (actor1->getField948() + 10)), (int16)(actor2_y - (actor1->getField94C() + 10)));
- Common::Point pt2((int16)(actor2_x + 2 * actor1->getField948() + 10), (int16)(actor2_y + 2 * actor1->getField94C() + 10));
+ Common::Point pt2((int16)(actor2_x + actor1->getField948() + 10), (int16)(actor2_y + actor1->getField94C() + 10));
Common::Point pt3((int16)(actor2_x - (actor2->getField948() + 25)), (int16)(actor2_y - (actor2->getField94C() + 20)));
Common::Point pt4((int16)(actor2_x + 2 * actor2->getField948() + 25), (int16)(actor2_y + 2 * actor2->getField94C() + 20));
@@ -3144,7 +3147,7 @@ void Actor::updateStatus16_Chapter2() {
if (player->getFrameIndex() > (player->getFrameCount() - 1)) {
if (getSharedData()->getChapter2Counter(6) <= 2) {
player->setFrameIndex(0);
- updateStatus(kActorStatusEnabled2);
+ player->updateStatus(kActorStatusEnabled2);
} else {
_vm->clearGameFlag(kGameFlag438);
_vm->clearGameFlag(kGameFlag439);
@@ -3157,7 +3160,7 @@ void Actor::updateStatus16_Chapter2() {
_vm->setGameFlag(kGameFlag219);
player->setFrameIndex(0);
- updateStatus(kActorStatusRestarting);
+ player->updateStatus(kActorStatusRestarting);
_vm->clearGameFlag(kGameFlag369);
_vm->clearGameFlag(kGameFlag370);
@@ -3990,7 +3993,7 @@ uint32 Actor::euclidianDistance(const Common::Point &vec1, const Common::Point &
}
int32 Actor::angleFromVectors(const Common::Point &vec1, const Common::Point &vec2) {
- uint32 result = (uint32)(((long)(180 - acos((double)(vec2.y - vec1.y) / euclidianDistance(vec1, vec2)) * 180 / M_PI)) % 360);
+ int32 result = (int32)(((long)(180 - acos((double)(vec2.y - vec1.y) / euclidianDistance(vec1, vec2)) * 180 / -M_PI)) % 360);
if (vec1.x < vec2.x)
return 360 - result;
@@ -4011,43 +4014,43 @@ void Actor::rectFromDirection(Common::Rect *rect, ActorDirection direction, cons
return;
case kDirectionN:
- rect->top = point.x - 9;
- rect->left = point.y - 84;
+ rect->top = point.y - 84;
+ rect->left = point.x - 9;
break;
case kDirectionNW:
- rect->top = point.x - 55;
- rect->left = point.y - 84;
+ rect->top = point.y - 55;
+ rect->left = point.x - 84;
break;
case kDirectionW:
- rect->top = point.x - 34;
- rect->left = point.y - 93;
+ rect->top = point.y - 34;
+ rect->left = point.x - 93;
break;
case kDirectionSW:
- rect->top = point.x + 27;
- rect->left = point.y - 94;
+ rect->top = point.y + 27;
+ rect->left = point.x - 94;
break;
case kDirectionS:
- rect->top = point.x + 41;
- rect->left = point.y - 9;
+ rect->top = point.y + 41;
+ rect->left = point.x - 9;
break;
case kDirectionSE:
- rect->top = point.x + 27;
- rect->left = point.y + 54;
+ rect->top = point.y + 27;
+ rect->left = point.x + 54;
break;
case kDirectionE:
- rect->top = point.x - 34;
- rect->left = point.y + 53;
+ rect->top = point.y - 34;
+ rect->left = point.x + 53;
break;
case kDirectionNE:
- rect->top = point.x - 55;
- rect->left = point.y + 44;
+ rect->top = point.y - 55;
+ rect->left = point.x + 44;
break;
}
@@ -4063,7 +4066,7 @@ bool Actor::compareAngles(const Common::Point &vec1, const Common::Point &vec2)
if (diff < 0)
diff += 359;
- return (diff != 180);
+ return (diff > 180);
}
bool Actor::compare(const Common::Point &vec1, const Common::Point &vec2, const Common::Point &vec) {
@@ -4074,11 +4077,13 @@ bool Actor::compare(const Common::Point &vec1, const Common::Point &vec2, const
}
int16 Actor::compareX(const Common::Point &vec1, const Common::Point &vec2, const Common::Point &vec) {
- if (vec.y > vec2.y)
+ if (vec.x > vec2.x)
return 3;
- if (vec.y < vec1.y)
- return 2;
+ if (vec.x < vec1.x)
+ return -3;
+ else
+ return 0;
return 0;
}
@@ -4088,7 +4093,9 @@ int16 Actor::compareY(const Common::Point &vec1, const Common::Point &vec2, cons
return 3;
if (vec.y < vec1.y)
- return 2;
+ return -3;
+ else
+ return 0;
return 0;
}
diff --git a/engines/asylum/resources/worldstats.cpp b/engines/asylum/resources/worldstats.cpp
index e331b716b7..cf238b582d 100644
--- a/engines/asylum/resources/worldstats.cpp
+++ b/engines/asylum/resources/worldstats.cpp
@@ -485,7 +485,7 @@ int32 WorldStats::getRandomActionAreaIndexById(int32 id) {
if (!count)
return -1;
- return indexes[_vm->getRandom(count)];
+ return indexes[_vm->getRandom(count - 1)];
}
ActionArea* WorldStats::getActionAreaById(int32 id) {
diff --git a/engines/asylum/views/scene.cpp b/engines/asylum/views/scene.cpp
index 789c379538..c1511e075d 100644
--- a/engines/asylum/views/scene.cpp
+++ b/engines/asylum/views/scene.cpp
@@ -1759,7 +1759,7 @@ void Scene::hitActorChapter2(ActorIndex index) {
return;
if (index == 11) {
- player->faceTarget((uint32)(index + 9), kDirectionFromActor);
+ player->faceTarget((uint32)index, kDirectionFromActor);
player->updateStatus(kActorStatusAttacking);
Actor *actor11 = getActor(index);
Commit: 7dd49418c95a002b1645d65acd51d21cf502438d
https://github.com/scummvm/scummvm/commit/7dd49418c95a002b1645d65acd51d21cf502438d
Author: alxpnv (alxpnv22 at yahoo.com)
Date: 2021-05-17T15:37:45+02:00
Commit Message:
ASYLUM: fix a bug in Screen::graphicsSelectionSort()
Changed paths:
engines/asylum/system/screen.cpp
diff --git a/engines/asylum/system/screen.cpp b/engines/asylum/system/screen.cpp
index 280f0afb7b..76e892dd60 100644
--- a/engines/asylum/system/screen.cpp
+++ b/engines/asylum/system/screen.cpp
@@ -711,17 +711,17 @@ void Screen::clearGraphicsInQueue() {
}
void Screen::graphicsSelectionSort() {
- uint32 minIdx;
+ uint32 maxIdx;
for (uint32 i = 0; i < _queueItems.size(); i++) {
- minIdx = i;
+ maxIdx = i;
for (uint32 j = i + 1; j < _queueItems.size(); j++)
- if (_queueItems[j].priority > _queueItems[i].priority)
- minIdx = j;
+ if (_queueItems[j].priority > _queueItems[maxIdx].priority)
+ maxIdx = j;
- if (i != minIdx)
- swapGraphicItem(i, minIdx);
+ if (i != maxIdx)
+ swapGraphicItem(i, maxIdx);
}
}
Commit: 459de7f44e8f9da57f83fbac2519354531441600
https://github.com/scummvm/scummvm/commit/459de7f44e8f9da57f83fbac2519354531441600
Author: alxpnv (alxpnv22 at yahoo.com)
Date: 2021-05-17T15:37:45+02:00
Commit Message:
ASYLUM: remove cache entry for shared sound when cd number is changed
Changed paths:
engines/asylum/asylum.cpp
engines/asylum/respack.h
diff --git a/engines/asylum/asylum.cpp b/engines/asylum/asylum.cpp
index b1fd8ceaf9..de02b07bf7 100644
--- a/engines/asylum/asylum.cpp
+++ b/engines/asylum/asylum.cpp
@@ -194,6 +194,8 @@ void AsylumEngine::startGame(ResourcePackId sceneId, StartGameType type) {
_handler = _scene;
// Set the current cd number (necessary for proper SharedSound resource pack initialization)
+ int32 cdNumber = _resource->getCdNumber();
+
switch (sceneId) {
default:
_resource->setCdNumber(-1);
@@ -222,6 +224,9 @@ void AsylumEngine::startGame(ResourcePackId sceneId, StartGameType type) {
break;
}
+ if (_resource->getCdNumber() != cdNumber)
+ _resource->clearSharedSoundCache();
+
switch (type) {
default:
error("[AsylumEngine::startGame] Invalid start game type!");
diff --git a/engines/asylum/respack.h b/engines/asylum/respack.h
index 5f5156fd31..e3b33ca3bb 100644
--- a/engines/asylum/respack.h
+++ b/engines/asylum/respack.h
@@ -92,8 +92,10 @@ public:
//int count(ResourceId id);
+ int getCdNumber() { return _cdNumber; }
void setCdNumber(int cdNumber) { _cdNumber = cdNumber; }
void setMusicPackId(ResourcePackId id) { _musicPackId = id; }
+ void clearSharedSoundCache() { _resources.erase(kResourcePackSharedSound); }
private:
struct ResourcePackId_EqualTo {
Commit: ee37960ac448ecadb1f55c84a9bc2e93d7b380e8
https://github.com/scummvm/scummvm/commit/ee37960ac448ecadb1f55c84a9bc2e93d7b380e8
Author: alxpnv (alxpnv22 at yahoo.com)
Date: 2021-05-17T15:37:45+02:00
Commit Message:
ASYLUM: make actors interactable
Changed paths:
engines/asylum/views/scene.cpp
diff --git a/engines/asylum/views/scene.cpp b/engines/asylum/views/scene.cpp
index c1511e075d..530cd2c7b6 100644
--- a/engines/asylum/views/scene.cpp
+++ b/engines/asylum/views/scene.cpp
@@ -1450,20 +1450,23 @@ ActorIndex Scene::hitTestActor() {
//////////////////////////////////////////////////////////////////////////
// Default check
for (int i = _ws->actors.size() - 1; i >= 0 ; i--) {
- Actor *actor = getActor(i);
+ Actor *actor = getActor(i);
- uint32 hitFrame;
- if (actor->getFrameIndex() >= actor->getFrameCount())
- hitFrame = 2 * actor->getFrameIndex() - (actor->getFrameCount() + 1);
- else
- hitFrame = actor->getFrameIndex();
+ if (!actor->isOnScreen() || !actor->actionType)
+ continue;
+
+ uint32 hitFrame;
+ if (actor->getFrameIndex() >= actor->getFrameCount())
+ hitFrame = 2 * actor->getFrameIndex() - (actor->getFrameCount() + 1);
+ else
+ hitFrame = actor->getFrameIndex();
- if (hitTestPixel(actor->getResourceId(),
- hitFrame,
- _ws->xLeft - (actor->getPoint()->x + actor->getPoint1()->x),
- _ws->yTop - (actor->getPoint()->y + actor->getPoint1()->y),
- actor->getDirection() >= kDirectionSE))
- return i;
+ if (hitTestPixel(actor->getResourceId(),
+ hitFrame,
+ _ws->xLeft + mouse.x - (actor->getPoint1()->x + actor->getPoint()->x),
+ _ws->yTop + mouse.y - (actor->getPoint1()->y + actor->getPoint()->y),
+ actor->getDirection() >= kDirectionSE))
+ return i;
}
return -1;
@@ -1620,7 +1623,7 @@ void Scene::handleHit(int32 index, HitType type) {
if (actor->actionType & (kActionTypeFind | kActionType16)) {
- if (getScript()->isInQueue(actor->getScriptIndex())) {
+ if (!getScript()->isInQueue(actor->getScriptIndex())) {
debugC(kDebugLevelScripts, "[Script] Queuing Script idx: %d from kHitActor (id: %d, name: '%s')",
actor->getScriptIndex(), index, actor->getName());
getScript()->queueScript(actor->getScriptIndex(), getSharedData()->getPlayerIndex());
@@ -1636,7 +1639,7 @@ void Scene::handleHit(int32 index, HitType type) {
actor->setSoundResourceId(kResourceNone);
}
- if (getScript()->isInQueue(actor->getScriptIndex())) {
+ if (!getScript()->isInQueue(actor->getScriptIndex())) {
debugC(kDebugLevelScripts, "[Script] Queuing Script idx: %d from kActionTypeTalk (actor idx: %d)",
actor->getScriptIndex(), getSharedData()->getPlayerIndex());
getScript()->queueScript(actor->getScriptIndex(), getSharedData()->getPlayerIndex());
Commit: 413960ac6b59d9a2c376d71b0bd43fcb6653b4a6
https://github.com/scummvm/scummvm/commit/413960ac6b59d9a2c376d71b0bd43fcb6653b4a6
Author: alxpnv (alxpnv22 at yahoo.com)
Date: 2021-05-17T15:37:45+02:00
Commit Message:
ASYLUM: strict weak ordering is '<'
Changed paths:
engines/asylum/views/scene.cpp
diff --git a/engines/asylum/views/scene.cpp b/engines/asylum/views/scene.cpp
index 530cd2c7b6..d26e9dd5dc 100644
--- a/engines/asylum/views/scene.cpp
+++ b/engines/asylum/views/scene.cpp
@@ -2456,7 +2456,7 @@ bool Scene::drawScene() {
}
bool Scene::updateListCompare(const UpdateItem &item1, const UpdateItem &item2) {
- return (item1.priority - item2.priority < 0) ? false : true;
+ return (item1.priority < item2.priority);
}
void Scene::buildUpdateList() {
Commit: 5649a0e2575f6d404740591f98a8ba2b5c726d31
https://github.com/scummvm/scummvm/commit/5649a0e2575f6d404740591f98a8ba2b5c726d31
Author: alxpnv (alxpnv22 at yahoo.com)
Date: 2021-05-17T15:37:45+02:00
Commit Message:
ASYLUM: fix 'zoom' out of bounds
Changed paths:
engines/asylum/system/screen.cpp
diff --git a/engines/asylum/system/screen.cpp b/engines/asylum/system/screen.cpp
index 76e892dd60..e08632c076 100644
--- a/engines/asylum/system/screen.cpp
+++ b/engines/asylum/system/screen.cpp
@@ -986,6 +986,7 @@ void Screen::blitMasked(GraphicFrame *frame, Common::Rect *source, byte *maskDat
if (destination->left > destMask->left) {
zoom += abs(destination->left - destMask->left) & 7;
+ zoom &= 7;
maskBufferPtr += ((destination->left - destMask->left) + zoom) / 8;
sourceMask->setWidth(sourceMask->width() + destMask->left - destination->left);
destMask->left = destination->left;
Commit: a3c7fc6e10dfc30869deac9fc3f4a656bd0b3c30
https://github.com/scummvm/scummvm/commit/a3c7fc6e10dfc30869deac9fc3f4a656bd0b3c30
Author: alxpnv (alxpnv22 at yahoo.com)
Date: 2021-05-17T15:37:45+02:00
Commit Message:
ASYLUM: skip non-existent objects
Changed paths:
engines/asylum/resources/script.cpp
diff --git a/engines/asylum/resources/script.cpp b/engines/asylum/resources/script.cpp
index e9f03d4efd..a290c7bfbd 100644
--- a/engines/asylum/resources/script.cpp
+++ b/engines/asylum/resources/script.cpp
@@ -2011,13 +2011,13 @@ void ScriptManager::enableObject(ScriptEntry *cmd, ObjectTransparency type) {
getWorld()->getObjectById(kObjectHook4B)->setTransparency(transparency);
getWorld()->getObjectById(kObjectHook5B)->setTransparency(transparency);
getWorld()->getObjectById(kObjectHook6B)->setTransparency(transparency);
- getWorld()->getObjectById(kObjectHook0Down)->setTransparency(transparency);
+ //getWorld()->getObjectById(kObjectHook0Down)->setTransparency(transparency);
getWorld()->getObjectById(kObjectHook2Down)->setTransparency(transparency);
- getWorld()->getObjectById(kObjectHook3Down)->setTransparency(transparency);
+ //getWorld()->getObjectById(kObjectHook3Down)->setTransparency(transparency);
getWorld()->getObjectById(kObjectHook4Down)->setTransparency(transparency);
- getWorld()->getObjectById(kObjectHook5Down)->setTransparency(transparency);
- getWorld()->getObjectById(kObjectHook6Down)->setTransparency(transparency);
- getWorld()->getObjectById(kObject2230)->setTransparency(transparency);
+ //getWorld()->getObjectById(kObjectHook5Down)->setTransparency(transparency);
+ //getWorld()->getObjectById(kObjectHook6Down)->setTransparency(transparency);
+ //getWorld()->getObjectById(kObject2230)->setTransparency(transparency);
break;
}
}
Commit: 4a1d644b84982db74c3d3f23fc8a31dddd5f02f7
https://github.com/scummvm/scummvm/commit/4a1d644b84982db74c3d3f23fc8a31dddd5f02f7
Author: alxpnv (alxpnv22 at yahoo.com)
Date: 2021-05-17T15:37:46+02:00
Commit Message:
ASYLUM: fixes to Special::checkFlags()
Changed paths:
engines/asylum/resources/special.cpp
diff --git a/engines/asylum/resources/special.cpp b/engines/asylum/resources/special.cpp
index a23fb99351..f139805b08 100644
--- a/engines/asylum/resources/special.cpp
+++ b/engines/asylum/resources/special.cpp
@@ -1401,8 +1401,8 @@ void Special::checkFlags(ObjectId id, GameFlag flag1, GameFlag flag2, GameFlag f
*val1 = 0;
*val2 = 0;
- _vm->clearGameFlag(flag2);
- _vm->clearGameFlag(flag4);
+ _vm->setGameFlag(flag2);
+ _vm->setGameFlag(flag4);
getWorld()->getObjectById(id)->setTransparency(0);
Commit: ffb8df69d7b0f7d61bafc5680a19fcd9bd3e99f3
https://github.com/scummvm/scummvm/commit/ffb8df69d7b0f7d61bafc5680a19fcd9bd3e99f3
Author: alxpnv (alxpnv22 at yahoo.com)
Date: 2021-05-17T15:37:46+02:00
Commit Message:
ASYLUM: implement wheels update
Changed paths:
engines/asylum/resources/special.cpp
diff --git a/engines/asylum/resources/special.cpp b/engines/asylum/resources/special.cpp
index f139805b08..1d14b6d557 100644
--- a/engines/asylum/resources/special.cpp
+++ b/engines/asylum/resources/special.cpp
@@ -587,6 +587,32 @@ void Special::chapter8(Object *object, ActorIndex actorIndex) {
updateObjectFlag(kObjectGong2);
updateObjectFlag(kObjectGong3);
break;
+
+ case kObjectWheel1:
+ case kObjectWheel2:
+ case kObjectWheel3:
+ case kObjectWheel4:
+ case kObjectWheel5:
+ case kObjectWheel6:
+ case kObjectWheel7: {
+ GameFlag wheelFlag = (GameFlag)(612 + object->getId() - kObjectWheel1);
+ uint32 frameIndex = object->getFrameIndex();
+
+ if (_vm->isGameFlagSet(wheelFlag)) {
+ _vm->clearGameFlag(wheelFlag);
+ ++frameIndex;
+ }
+
+ if (frameIndex >= 17) {
+ if ((frameIndex + 1) % 4)
+ ++frameIndex;
+ } else if (frameIndex % 4) {
+ ++frameIndex;
+ }
+
+ object->setFrameIndex(frameIndex >= object->getFrameCount() ? 0 : frameIndex);
+ }
+ break;
}
}
Commit: 982bd7c359f7965700b587b40c5bba6bd9b6a878
https://github.com/scummvm/scummvm/commit/982bd7c359f7965700b587b40c5bba6bd9b6a878
Author: alxpnv (alxpnv22 at yahoo.com)
Date: 2021-05-17T15:37:46+02:00
Commit Message:
ASYLUM: set a game flag when Hive Machine puzzle is solved
Changed paths:
engines/asylum/puzzles/hivemachine.cpp
engines/asylum/shared.h
diff --git a/engines/asylum/puzzles/hivemachine.cpp b/engines/asylum/puzzles/hivemachine.cpp
index 0d61f43d9e..71c3541a37 100644
--- a/engines/asylum/puzzles/hivemachine.cpp
+++ b/engines/asylum/puzzles/hivemachine.cpp
@@ -250,8 +250,11 @@ void PuzzleHiveMachine::updateScreen() {
if (_ok) {
if (_counterGreen > 1)
--_counterGreen;
- else if (_counterGreen-- == 1)
+ else if (_counterGreen-- == 1) {
getSound()->playSound(getWorld()->graphicResourceIds[86], false, Config.sfxVolume - 10);
+ _vm->setGameFlag(kGameFlagSolveHiveMachine);
+ _vm->switchEventHandler(getScene());
+ }
getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[11], 0, Common::Point(271, 369), kDrawFlagNone, 0, 1);
} else if (_counterRed) {
if (_counterRed == 1)
diff --git a/engines/asylum/shared.h b/engines/asylum/shared.h
index c1e5a29a0e..b7f4674475 100644
--- a/engines/asylum/shared.h
+++ b/engines/asylum/shared.h
@@ -159,6 +159,7 @@ enum GameFlag {
kGameFlag828 = 828,
kGameFlag829 = 829,
kGameFlag830 = 830,
+ kGameFlagSolveHiveMachine = 834,
kGameFlag866 = 866,
kGameFlag875 = 875,
kGameFlag876 = 876,
Commit: cc41cfb4597000cc3fe9594458900cf8e996c8d8
https://github.com/scummvm/scummvm/commit/cc41cfb4597000cc3fe9594458900cf8e996c8d8
Author: alxpnv (alxpnv22 at yahoo.com)
Date: 2021-05-17T15:37:46+02:00
Commit Message:
ASYLUM: original loops through the objects in reverse
Changed paths:
engines/asylum/views/scene.cpp
diff --git a/engines/asylum/views/scene.cpp b/engines/asylum/views/scene.cpp
index d26e9dd5dc..1f2d5f7bbf 100644
--- a/engines/asylum/views/scene.cpp
+++ b/engines/asylum/views/scene.cpp
@@ -1495,7 +1495,7 @@ int32 Scene::hitTestObject() {
const Common::Point pt = getCursor()->position();
- for (uint32 i = 0; i < _ws->objects.size(); i++) {
+ for (int32 i = _ws->objects.size() - 1; i >= 0; i--) {
Object *object = _ws->objects[i];
if (object->isOnScreen() && object->actionType)
if (hitTestPixel(object->getResourceId(),
Commit: fe40af0f44fb3eba3d233a233d128875a2ec4a25
https://github.com/scummvm/scummvm/commit/fe40af0f44fb3eba3d233a233d128875a2ec4a25
Author: alxpnv (alxpnv22 at yahoo.com)
Date: 2021-05-17T15:37:46+02:00
Commit Message:
ASYLUM: check if object exists
On level 13, the game tries to set transparency of an object which doesn't exist (id 4562)
Changed paths:
engines/asylum/resources/script.cpp
diff --git a/engines/asylum/resources/script.cpp b/engines/asylum/resources/script.cpp
index a290c7bfbd..9fb722ad67 100644
--- a/engines/asylum/resources/script.cpp
+++ b/engines/asylum/resources/script.cpp
@@ -1806,6 +1806,10 @@ IMPLEMENT_OPCODE(UpdateTransparency)
if (cmd->param2 >= 0 && cmd->param2 <= 3) {
if (cmd->param1) {
Object *object = getWorld()->getObjectById((ObjectId)cmd->param1);
+ if (!object) {
+ warning("No object with id %d", cmd->param1);
+ return;
+ }
if (!cmd->param2)
object->setTransparency(0);
Commit: 840f84bc84e613d3d8eaddcc9914985d9c966343
https://github.com/scummvm/scummvm/commit/840f84bc84e613d3d8eaddcc9914985d9c966343
Author: alxpnv (alxpnv22 at yahoo.com)
Date: 2021-05-17T15:37:47+02:00
Commit Message:
ASYLUM: fix right bound of cursor.x
Changed paths:
engines/asylum/views/menu.cpp
diff --git a/engines/asylum/views/menu.cpp b/engines/asylum/views/menu.cpp
index c90b155fb7..1b61305184 100644
--- a/engines/asylum/views/menu.cpp
+++ b/engines/asylum/views/menu.cpp
@@ -1738,7 +1738,7 @@ void Menu::clickSaveGame() {
if (cursor.x >= 350) {
sprintf((char *)&text, "%d. %s ", index + _startIndex + 7, getSaveLoad()->getName((uint32)(index + _startIndex + 6)).c_str());
- if (cursor.x <= (30 + getText()->getWidth((char *)&text))
+ if (cursor.x <= (350 + getText()->getWidth((char *)&text))
&& cursor.y >= y
&& cursor.y <= (y + 24)
&& getWorld()->chapter != kChapterNone) {
@@ -1759,7 +1759,7 @@ void Menu::clickSaveGame() {
} else if (cursor.x >= 30) {
sprintf((char *)&text, "%d. %s ", index + _startIndex + 1, getSaveLoad()->getName((uint32)(index + _startIndex)).c_str());
- if (cursor.x <= (350 + getText()->getWidth((char *)&text))
+ if (cursor.x <= (30 + getText()->getWidth((char *)&text))
&& cursor.y >= y
&& cursor.y <= (y + 24)
&& getScene()
@@ -1843,7 +1843,7 @@ void Menu::clickDeleteGame() {
if (cursor.x >= 350) {
sprintf((char *)&text, "%d. %s ", index + _startIndex + 7, getSaveLoad()->getName((uint32)(index + _startIndex + 6)).c_str());
- if (cursor.x <= (30 + getText()->getWidth((char *)&text))
+ if (cursor.x <= (350 + getText()->getWidth((char *)&text))
&& cursor.y >= y
&& cursor.y <= (y + 24)) {
uint32 saveIndex = (uint32)(index + _startIndex);
@@ -1857,7 +1857,7 @@ void Menu::clickDeleteGame() {
} else if (cursor.x >= 30) {
sprintf((char *)&text, "%d. %s ", index + _startIndex + 1, getSaveLoad()->getName((uint32)(index + _startIndex)).c_str());
- if (cursor.x <= (350 + getText()->getWidth((char *)&text))
+ if (cursor.x <= (30 + getText()->getWidth((char *)&text))
&& cursor.y >= y
&& cursor.y <= (y + 24)) {
uint32 saveIndex = (uint32)(index + _startIndex);
Commit: f23be0119ef6342223afb87666c38fc6476a7df9
https://github.com/scummvm/scummvm/commit/f23be0119ef6342223afb87666c38fc6476a7df9
Author: alxpnv (alxpnv22 at yahoo.com)
Date: 2021-05-17T15:37:47+02:00
Commit Message:
ASYLUM: fix saving
Changed paths:
engines/asylum/resources/script.cpp
diff --git a/engines/asylum/resources/script.cpp b/engines/asylum/resources/script.cpp
index 9fb722ad67..19c272084e 100644
--- a/engines/asylum/resources/script.cpp
+++ b/engines/asylum/resources/script.cpp
@@ -283,6 +283,7 @@ void ScriptManager::resetAll() {
void ScriptManager::reset(uint32 count) {
// Create a set of empty scripts
+ _scripts.clear();
for (uint32 i = 0; i < count; i++) {
Script script;
_scripts.push_back(script);
Commit: f94c11658a0635d5f8d7b15a36a52e51aadadca8
https://github.com/scummvm/scummvm/commit/f94c11658a0635d5f8d7b15a36a52e51aadadca8
Author: alxpnv (alxpnv22 at yahoo.com)
Date: 2021-05-17T15:37:47+02:00
Commit Message:
ASYLUM: fix background drawing in some of the puzzles
Changed paths:
engines/asylum/puzzles/fisherman.cpp
engines/asylum/puzzles/lock.cpp
engines/asylum/puzzles/morguedoor.cpp
engines/asylum/puzzles/timemachine.cpp
engines/asylum/puzzles/vcr.cpp
engines/asylum/puzzles/writings.cpp
diff --git a/engines/asylum/puzzles/fisherman.cpp b/engines/asylum/puzzles/fisherman.cpp
index fd30a2466c..ed37d7795b 100644
--- a/engines/asylum/puzzles/fisherman.cpp
+++ b/engines/asylum/puzzles/fisherman.cpp
@@ -92,7 +92,8 @@ bool PuzzleFisherman::update(const AsylumEvent &) {
// Draw background
getScreen()->clearGraphicsInQueue();
- getScreen()->draw(getWorld()->graphicResourceIds[38]);
+ getScreen()->fillRect(0, 0, 640, 480, 251);
+ getScreen()->draw(getWorld()->graphicResourceIds[38], 0, Common::Point(0, 0), kDrawFlagNone, true);
// Draw 7 graphics
for (uint32 i = 0; i < 6; i++) {
diff --git a/engines/asylum/puzzles/lock.cpp b/engines/asylum/puzzles/lock.cpp
index 07047e155b..1813dfe4bc 100644
--- a/engines/asylum/puzzles/lock.cpp
+++ b/engines/asylum/puzzles/lock.cpp
@@ -78,7 +78,8 @@ bool PuzzleLock::update(const AsylumEvent &) {
// Draw screen
getScreen()->clearGraphicsInQueue();
- getScreen()->draw(getWorld()->graphicResourceIds[13]);
+ getScreen()->fillRect(0, 0, 640, 480, 252);
+ getScreen()->draw(getWorld()->graphicResourceIds[13], 0, Common::Point(0, 0), kDrawFlagNone, true);
if (_frameIndexes[0] != 32 || _frameIndexes[1] != 28 || _frameIndexes[2] != 0) {
getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[15], (uint32)_frameIndexes[0], Common::Point(145, 292), kDrawFlagNone, 0, 1);
diff --git a/engines/asylum/puzzles/morguedoor.cpp b/engines/asylum/puzzles/morguedoor.cpp
index f40f3bd2be..0468b49735 100644
--- a/engines/asylum/puzzles/morguedoor.cpp
+++ b/engines/asylum/puzzles/morguedoor.cpp
@@ -107,7 +107,9 @@ bool PuzzleMorgueDoor::update(const AsylumEvent &) {
// Draw elements
getScreen()->clearGraphicsInQueue();
- getScreen()->draw(getWorld()->graphicResourceIds[19]);
+ getScreen()->fillRect(0, 0, 640, 480, 252);
+ getScreen()->draw(getWorld()->graphicResourceIds[19], 0, Common::Point(0, 0), kDrawFlagNone, true);
+
getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[21], (uint32)_frameIndexes[kTopLever], Common::Point(47, 0), kDrawFlagNone, 0, 1);
getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[22], (uint32)_frameIndexes[kBottomLever], Common::Point(51, 236), kDrawFlagNone, 0, 1);
diff --git a/engines/asylum/puzzles/timemachine.cpp b/engines/asylum/puzzles/timemachine.cpp
index 9bf78a1a5e..453769648d 100644
--- a/engines/asylum/puzzles/timemachine.cpp
+++ b/engines/asylum/puzzles/timemachine.cpp
@@ -132,7 +132,9 @@ bool PuzzleTimeMachine::update(const AsylumEvent &) {
// Draw screen elements
getScreen()->clearGraphicsInQueue();
- getScreen()->draw(getWorld()->graphicResourceIds[34]);
+ getScreen()->fillRect(0, 0, 640, 480, 115);
+ getScreen()->draw(getWorld()->graphicResourceIds[34], 0, Common::Point(0, 0), kDrawFlagNone, true);
+
getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[35], _frameIndexes[0], Common::Point( 23, 215), kDrawFlagNone, 0, 3);
getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[36], _frameIndexes[1], Common::Point( 70, 217), kDrawFlagNone, 0, 3);
getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[37], _frameIndexes[2], Common::Point(189, 217), kDrawFlagNone, 0, 3);
diff --git a/engines/asylum/puzzles/vcr.cpp b/engines/asylum/puzzles/vcr.cpp
index b14720455b..ba57521e41 100644
--- a/engines/asylum/puzzles/vcr.cpp
+++ b/engines/asylum/puzzles/vcr.cpp
@@ -310,7 +310,8 @@ void PuzzleVCR::updateScreen(const AsylumEvent &) {
// Draw background
getScreen()->clearGraphicsInQueue();
- getScreen()->draw(getWorld()->graphicResourceIds[0]);
+ getScreen()->fillRect(0, 0, 640, 480, 252);
+ getScreen()->draw(getWorld()->graphicResourceIds[0], 0, Common::Point(0, 0), kDrawFlagNone, true);
updateBlackJack();
updateRedJack();
diff --git a/engines/asylum/puzzles/writings.cpp b/engines/asylum/puzzles/writings.cpp
index b2ec149445..f3b7e1a157 100644
--- a/engines/asylum/puzzles/writings.cpp
+++ b/engines/asylum/puzzles/writings.cpp
@@ -68,7 +68,8 @@ bool PuzzleWritings::init(const AsylumEvent &) {
_textSurface.create(640, 480, Graphics::PixelFormat::createFormatCLUT8());
// Draw background
- getScreen()->draw(getWorld()->graphicResourceIds[5]);
+ getScreen()->fillRect(0, 0, 640, 480, 253);
+ getScreen()->draw(getWorld()->graphicResourceIds[5], 0, Common::Point(0, 0), kDrawFlagNone, true);
// Draw all lines of text
getText()->loadFont(getWorld()->graphicResourceIds[42]);
@@ -126,7 +127,8 @@ bool PuzzleWritings::update(const AsylumEvent &) {
// Draw background
getScreen()->clearGraphicsInQueue();
- getScreen()->draw(getWorld()->graphicResourceIds[4]);
+ getScreen()->fillRect(0, 0, 640, 480, 253);
+ getScreen()->draw(getWorld()->graphicResourceIds[4], 0, Common::Point(0, 0), kDrawFlagNone, true);
if (_hasGlassMagnifier) {
getScreen()->copyToBackBuffer(
Commit: c3a3d999b5da940f3f1c82180174d04383f4a8f7
https://github.com/scummvm/scummvm/commit/c3a3d999b5da940f3f1c82180174d04383f4a8f7
Author: alxpnv (alxpnv22 at yahoo.com)
Date: 2021-05-17T15:37:47+02:00
Commit Message:
ASYLUM: implement Special::chapter12()
Changed paths:
engines/asylum/resources/special.cpp
engines/asylum/resources/special.h
engines/asylum/shared.h
diff --git a/engines/asylum/resources/special.cpp b/engines/asylum/resources/special.cpp
index 1d14b6d557..d31a46ee7c 100644
--- a/engines/asylum/resources/special.cpp
+++ b/engines/asylum/resources/special.cpp
@@ -96,6 +96,10 @@ void Special::run(Object* object, ActorIndex index) {
case kChapter9:
chapter9(object, index);
break;
+
+ case kChapter12:
+ chapter12(object, index);
+ break;
}
}
@@ -692,6 +696,102 @@ void Special::chapter9(Object *object, ActorIndex actorIndex) {
}
}
+void Special::chapter12(Object *object, ActorIndex actorIndex) {
+ playChapterSound(object, actorIndex);
+
+ if (actorIndex != kActorInvalid)
+ return;
+
+ switch (object->getId()) {
+ default:
+ return;
+
+ case kObjectFloorTrap9:
+ if (object->getFrameIndex() > 1 && _vm->isGameFlagSet(kGameFlag809)) {
+ getScript()->queueScript(getWorld()->actions[getWorld()->getActionAreaIndexById(1971)]->scriptIndex, kActorMax);
+ _vm->clearGameFlag(kGameFlag809);
+ }
+ break;
+
+ case kObjectFloorTrap8:
+ if (object->getFrameIndex() > 1 && _vm->isGameFlagSet(kGameFlag810)) {
+ getScript()->queueScript(getWorld()->actions[getWorld()->getActionAreaIndexById(1971)]->scriptIndex, kActorMax);
+ _vm->clearGameFlag(kGameFlag810);
+ }
+ break;
+
+ case kObjectFloorTrap4:
+ if (object->getFrameIndex() > 1 && _vm->isGameFlagSet(kGameFlag794)) {
+ getScript()->queueScript(getWorld()->actions[getWorld()->getActionAreaIndexById(1971)]->scriptIndex, kActorMax);
+ _vm->clearGameFlag(kGameFlag794);
+ }
+ break;
+
+ case kObjectFloorTrap3:
+ if (object->getFrameIndex() > 1 && _vm->isGameFlagSet(kGameFlag795)) {
+ getScript()->queueScript(getWorld()->actions[getWorld()->getActionAreaIndexById(1971)]->scriptIndex, kActorMax);
+ _vm->clearGameFlag(kGameFlag795);
+ }
+ break;
+
+ case kObjectFloorTrap2:
+ if (object->getFrameIndex() > 1 && _vm->isGameFlagSet(kGameFlag796)) {
+ getScript()->queueScript(getWorld()->actions[getWorld()->getActionAreaIndexById(1971)]->scriptIndex, kActorMax);
+ _vm->clearGameFlag(kGameFlag796);
+ }
+ break;
+
+ case kObjectFloorTrap1:
+ if (object->getFrameIndex() > 1 && _vm->isGameFlagSet(kGameFlag797)) {
+ getScript()->queueScript(getWorld()->actions[getWorld()->getActionAreaIndexById(1971)]->scriptIndex, kActorMax);
+ _vm->clearGameFlag(kGameFlag797);
+ }
+ break;
+
+ case kObjectFloorTrap5:
+ if (object->getFrameIndex() > 1 && _vm->isGameFlagSet(kGameFlag792)) {
+ getScript()->queueScript(getWorld()->actions[getWorld()->getActionAreaIndexById(1971)]->scriptIndex, kActorMax);
+ _vm->clearGameFlag(kGameFlag792);
+ }
+ break;
+
+ case kObjectFloorTrap6:
+ if (object->getFrameIndex() > 1 && _vm->isGameFlagSet(kGameFlag791)) {
+ getScript()->queueScript(getWorld()->actions[getWorld()->getActionAreaIndexById(1971)]->scriptIndex, kActorMax);
+ _vm->clearGameFlag(kGameFlag791);
+ }
+ break;
+
+ case kObjectFloorTrap7:
+ if (object->getFrameIndex() > 1 && _vm->isGameFlagSet(kGameFlag790)) {
+ getScript()->queueScript(getWorld()->actions[getWorld()->getActionAreaIndexById(1971)]->scriptIndex, kActorMax);
+ _vm->clearGameFlag(kGameFlag790);
+ }
+ break;
+
+ case kObjectSparkPuzzleRight:
+ if (object->getFrameIndex() > 1 && _vm->isGameFlagSet(kGameFlag761)) {
+ getScript()->queueScript(getWorld()->actions[getWorld()->getActionAreaIndexById(1971)]->scriptIndex, kActorMax);
+ _vm->clearGameFlag(kGameFlag761);
+ }
+ break;
+
+ case kObjectSparkPuzzleMiddle:
+ if (object->getFrameIndex() > 1 && _vm->isGameFlagSet(kGameFlag760)) {
+ getScript()->queueScript(getWorld()->actions[getWorld()->getActionAreaIndexById(1971)]->scriptIndex, kActorMax);
+ _vm->clearGameFlag(kGameFlag760);
+ }
+ break;
+
+ case kObjectSparkPuzzleLeft:
+ if (object->getFrameIndex() > 1 && _vm->isGameFlagSet(kGameFlag759)) {
+ getScript()->queueScript(getWorld()->actions[getWorld()->getActionAreaIndexById(1971)]->scriptIndex, kActorMax);
+ _vm->clearGameFlag(kGameFlag759);
+ }
+ break;
+ }
+}
+
//////////////////////////////////////////////////////////////////////////
// Sound logic
//////////////////////////////////////////////////////////////////////////
diff --git a/engines/asylum/resources/special.h b/engines/asylum/resources/special.h
index 5f20329057..27db52edc4 100644
--- a/engines/asylum/resources/special.h
+++ b/engines/asylum/resources/special.h
@@ -64,6 +64,7 @@ private:
void chapter7(Object *object, ActorIndex actorIndex);
void chapter8(Object *object, ActorIndex actorIndex);
void chapter9(Object *object, ActorIndex actorIndex);
+ void chapter12(Object *object, ActorIndex actorIndex);
//////////////////////////////////////////////////////////////////////////
// Sound logic
diff --git a/engines/asylum/shared.h b/engines/asylum/shared.h
index b7f4674475..0756f247ba 100644
--- a/engines/asylum/shared.h
+++ b/engines/asylum/shared.h
@@ -136,13 +136,25 @@ enum GameFlag {
kGameFlag724 = 724,
kGameFlag727 = 727,
kGameFlag730 = 730,
+ kGameFlag759 = 759,
+ kGameFlag760 = 760,
+ kGameFlag761 = 761,
kGameFlag776 = 776,
+ kGameFlag790 = 790,
+ kGameFlag791 = 791,
+ kGameFlag792 = 792,
+ kGameFlag794 = 794,
+ kGameFlag795 = 795,
+ kGameFlag796 = 796,
+ kGameFlag797 = 797,
kGameFlag801 = 801,
kGameFlag802 = 802,
kGameFlag803 = 803,
kGameFlag804 = 804,
kGameFlag805 = 805,
kGameFlag806 = 806,
+ kGameFlag809 = 809,
+ kGameFlag810 = 810,
kGameFlag815 = 815,
kGameFlag816 = 816,
kGameFlag817 = 817,
@@ -583,10 +595,22 @@ enum ObjectId {
kObjectNPC062GritzaStatusQuo = 2399,
kObjectNPC063GrundleStatusQuo = 2410,
kObjectNPC064GrellaStatusQuo = 2418,
+ kObjectSparkPuzzleLeft = 2427,
+ kObjectSparkPuzzleMiddle = 2429,
kObjectLavaBridge = 2445,
+ kObjectSparkPuzzleRight = 2451,
kObjectNPC065StatusQuo = 2469,
+ kObjectFloorTrap1 = 2473,
+ kObjectFloorTrap2 = 2474,
+ kObjectFloorTrap3 = 2475,
+ kObjectFloorTrap4 = 2476,
+ kObjectFloorTrap5 = 2477,
kObjectGlow4 = 2478,
kObjectBugOnTable = 2480,
+ kObjectFloorTrap6 = 2481,
+ kObjectFloorTrap7 = 2482,
+ kObjectFloorTrap8 = 2483,
+ kObjectFloorTrap9 = 2484,
kObjectWadeThroughLava = 2500,
kObjectNPC066StatusQuo = 2504,
kObject2507 = 2507,
Commit: 56df11e35695b4d28e3271e403873e5a10c1249b
https://github.com/scummvm/scummvm/commit/56df11e35695b4d28e3271e403873e5a10c1249b
Author: alxpnv (alxpnv22 at yahoo.com)
Date: 2021-05-17T15:37:47+02:00
Commit Message:
ASYLUM: implement Special::chapter13()
Changed paths:
engines/asylum/console.cpp
engines/asylum/resources/script.cpp
engines/asylum/resources/script.h
engines/asylum/resources/special.cpp
engines/asylum/resources/special.h
engines/asylum/shared.h
engines/asylum/views/scene.cpp
engines/asylum/views/scene.h
diff --git a/engines/asylum/console.cpp b/engines/asylum/console.cpp
index 60e1ac6336..e256cafe47 100644
--- a/engines/asylum/console.cpp
+++ b/engines/asylum/console.cpp
@@ -656,7 +656,7 @@ bool Console::cmdKillScript(int32 argc, const char **argv) {
int32 index = atoi(argv[1]);
if (getScript()->isInQueue(index))
- getScript()->updateQueue(index);
+ getScript()->removeFromQueue(index);
return false;
}
diff --git a/engines/asylum/resources/script.cpp b/engines/asylum/resources/script.cpp
index 19c272084e..ae3660840f 100644
--- a/engines/asylum/resources/script.cpp
+++ b/engines/asylum/resources/script.cpp
@@ -345,7 +345,7 @@ bool ScriptManager::isInQueue(int32 scriptIndex) const {
return false;
}
-void ScriptManager::updateQueue(uint32 entryIndex) {
+void ScriptManager::removeFromQueue(uint32 entryIndex) {
if (_queue.first == _queue.last) {
_queue.last = 0;
_queue.first = 0;
@@ -423,7 +423,7 @@ bool ScriptManager::process() {
++_queue.entries[entryIndex].currentLine;
if (_done)
- updateQueue(entryIndex);
+ removeFromQueue(entryIndex);
if (!_done)
continue;
diff --git a/engines/asylum/resources/script.h b/engines/asylum/resources/script.h
index e233d836c6..b99b06e0b8 100644
--- a/engines/asylum/resources/script.h
+++ b/engines/asylum/resources/script.h
@@ -161,6 +161,11 @@ public:
*/
bool isInQueue(int32 scriptIndex) const;
+ /**
+ * Remove a script element from the queue
+ */
+ void removeFromQueue(uint32 entryIndex);
+
/**
* Resets the queue.
*/
@@ -335,8 +340,6 @@ private:
Script *_currentScript;
ScriptQueueEntry *_currentQueueEntry;
- void updateQueue(uint32 entryIndex);
-
// Opcode helper functions
void enableObject(ScriptEntry *cmd, ObjectTransparency type);
void setActionFlag(ScriptEntry *cmd, ActionType flag); //|
diff --git a/engines/asylum/resources/special.cpp b/engines/asylum/resources/special.cpp
index d31a46ee7c..4b78355399 100644
--- a/engines/asylum/resources/special.cpp
+++ b/engines/asylum/resources/special.cpp
@@ -39,6 +39,18 @@
namespace Asylum {
+static const int32 zapPatterns[9][16] = {
+ {2292, 2299, 2301, 2302, 2303, 2304, 2306, 2307, 2310, 2311, 2312, 2313, 2314},
+ {2291, 2294, 2295, 2296, 2297, 2298, 2300, 2301, 2306, 2309, 2311, 2313, 2316},
+ {2292, 2296, 2297, 2299, 2302, 2303, 2304, 2305, 2307, 2309, 2310},
+ {2291, 2292, 2294, 2295, 2299, 2302, 2303, 2305, 2309, 2311, 2312, 2315},
+ {2293, 2294, 2296, 2297, 2298, 2300, 2302, 2306, 2307, 2309, 2311, 2313, 2316},
+ {2296, 2297, 2299, 2300, 2302, 2304, 2305, 2307, 2309, 2310, 2314, 2315},
+ {2295, 2297, 2298, 2300, 2302, 2304, 2305, 2309, 2310, 2312, 2313, 2314},
+ {2292, 2293, 2294, 2295, 2296, 2301, 2302, 2303, 2304, 2305, 2306, 2313, 2314, 2315},
+ {2293, 2296, 2297, 2298, 2299, 2300, 2302, 2304, 2306, 2307, 2309, 2310, 2311}
+};
+
Special::Special(AsylumEngine *engine) : _vm(engine) {
// Flags
_paletteFlag = false;
@@ -100,6 +112,10 @@ void Special::run(Object* object, ActorIndex index) {
case kChapter12:
chapter12(object, index);
break;
+
+ case kChapter13:
+ chapter13(object, index);
+ break;
}
}
@@ -792,6 +808,118 @@ void Special::chapter12(Object *object, ActorIndex actorIndex) {
}
}
+void Special::chapter13(Object *object, ActorIndex actorIndex) {
+ uint32 i = 0;
+
+ playChapterSound(object, actorIndex);
+
+ if (actorIndex != kActorInvalid)
+ return;
+
+ switch (object->getId()) {
+ default:
+ return;
+
+ case kObjectLine:
+ if (!(getScene()->getFrameCounter() % 50) && _vm->isGameFlagNotSet(kGameFlag1122)) {
+ if (object->getFrameIndex() >= 59) {
+ _vm->setGameFlag(kGameFlag1121);
+ object->setFrameIndex(0);
+ getScript()->removeFromQueue(getWorld()->scriptIndex);
+ getScript()->queueScript(getWorld()->actions[getWorld()->getActionAreaIndexById(2578)]->scriptIndex, kActorMax);
+ } else if (object->getFrameIndex() < object->getFrameCount()) {
+ object->setFrameIndex(object->getFrameIndex() + 1);
+ }
+ }
+ break;
+
+ case kObjectZapPattern1:
+ if (_vm->isGameFlagNotSet(kGameFlag1122) && !object->getFrameIndex() && zapPatterns[0][0]) {
+ do {
+ if (getWorld()->actions[getScene()->getActor(0)->getActionIndex3()]->id == zapPatterns[0][i++]) {
+ getScript()->queueScript(getWorld()->actions[getWorld()->getActionAreaIndexById(2237)]->scriptIndex, kActorMax);
+ }
+ } while (zapPatterns[0][i]);
+ }
+ break;
+
+ case kObjectZapPattern2:
+ if (_vm->isGameFlagNotSet(kGameFlag1122) && !object->getFrameIndex() && zapPatterns[1][0]) {
+ do {
+ if (getWorld()->actions[getScene()->getActor(0)->getActionIndex3()]->id == zapPatterns[1][i++])
+ getScript()->queueScript(getWorld()->actions[getWorld()->getActionAreaIndexById(2237)]->scriptIndex, kActorMax);
+ } while (zapPatterns[1][i]);
+ }
+ break;
+
+ case kObjectZapPattern3:
+ if (_vm->isGameFlagNotSet(kGameFlag1122) && !object->getFrameIndex() && zapPatterns[2][0]) {
+ while (getWorld()->actions[getScene()->getActor(0)->getActionIndex3()]->id != zapPatterns[2][i]) {
+ if (!zapPatterns[2][i++])
+ return;
+ }
+ getScript()->queueScript(getWorld()->actions[getWorld()->getActionAreaIndexById(2237)]->scriptIndex, kActorMax);
+ }
+ break;
+
+ case kObjectZapPattern4:
+ if (_vm->isGameFlagNotSet(kGameFlag1122) && !object->getFrameIndex() && zapPatterns[3][0]) {
+ do {
+ if (getWorld()->actions[getScene()->getActor(0)->getActionIndex3()]->id == zapPatterns[3][i++])
+ getScript()->queueScript(getWorld()->actions[getWorld()->getActionAreaIndexById(2329)]->scriptIndex, kActorMax);
+ } while (zapPatterns[3][i]);
+ }
+ break;
+
+ case kObjectZapPattern5:
+ if (_vm->isGameFlagNotSet(kGameFlag1122) && !object->getFrameIndex() && zapPatterns[4][0]) {
+ do {
+ if (getWorld()->actions[getScene()->getActor(0)->getActionIndex3()]->id == zapPatterns[4][i++])
+ getScript()->queueScript(getWorld()->actions[getWorld()->getActionAreaIndexById(2329)]->scriptIndex, kActorMax);
+ } while (zapPatterns[4][i]);
+ }
+ break;
+
+ case kObjectZapPattern6:
+ if (_vm->isGameFlagNotSet(kGameFlag1122) && !object->getFrameIndex() && zapPatterns[5][0]) {
+ do {
+ if (getWorld()->actions[getScene()->getActor(0)->getActionIndex3()]->id == zapPatterns[5][i++]) {
+ getScript()->queueScript(getWorld()->actions[getWorld()->getActionAreaIndexById(2329)]->scriptIndex, kActorMax);
+ }
+ } while (zapPatterns[5][i]);
+ }
+ break;
+
+ case kObjectZapPattern7:
+ if (_vm->isGameFlagNotSet(kGameFlag1122) && !object->getFrameIndex() && zapPatterns[6][0]) {
+ do {
+ if (getWorld()->actions[getScene()->getActor(0)->getActionIndex3()]->id == zapPatterns[6][i++])
+ getScript()->queueScript(getWorld()->actions[getWorld()->getActionAreaIndexById(2331)]->scriptIndex, kActorMax);
+ } while (zapPatterns[6][i]);
+ }
+ break;
+
+ case kObjectZapPattern8:
+ if (_vm->isGameFlagNotSet(kGameFlag1122) && !object->getFrameIndex() && zapPatterns[7][0]) {
+ do {
+ if (getWorld()->actions[getScene()->getActor(0)->getActionIndex3()]->id == zapPatterns[7][i++])
+ getScript()->queueScript(getWorld()->actions[getWorld()->getActionAreaIndexById(2331)]->scriptIndex, kActorMax);
+ } while (zapPatterns[7][i]);
+ }
+ break;
+
+ case kObjectZapPattern9:
+ if (_vm->isGameFlagNotSet(kGameFlag1122) && !object->getFrameIndex() && zapPatterns[8][0]) {
+ while (getWorld()->actions[getScene()->getActor(0)->getActionIndex3()]->id != zapPatterns[8][i++]) {
+ if (!zapPatterns[8][i])
+ return;
+ }
+ getScript()->queueScript(getWorld()->actions[getWorld()->getActionAreaIndexById(2331)]->scriptIndex, kActorMax);
+ }
+ break;
+ }
+}
+
//////////////////////////////////////////////////////////////////////////
// Sound logic
//////////////////////////////////////////////////////////////////////////
diff --git a/engines/asylum/resources/special.h b/engines/asylum/resources/special.h
index 27db52edc4..14fa57d8a4 100644
--- a/engines/asylum/resources/special.h
+++ b/engines/asylum/resources/special.h
@@ -65,6 +65,7 @@ private:
void chapter8(Object *object, ActorIndex actorIndex);
void chapter9(Object *object, ActorIndex actorIndex);
void chapter12(Object *object, ActorIndex actorIndex);
+ void chapter13(Object *object, ActorIndex actorIndex);
//////////////////////////////////////////////////////////////////////////
// Sound logic
diff --git a/engines/asylum/shared.h b/engines/asylum/shared.h
index 0756f247ba..ff66f59a81 100644
--- a/engines/asylum/shared.h
+++ b/engines/asylum/shared.h
@@ -196,6 +196,8 @@ enum GameFlag {
kGameFlag1067 = 1067,
kGameFlag1099 = 1099,
kGameFlag1108 = 1108,
+ kGameFlag1121 = 1121,
+ kGameFlag1122 = 1122,
kGameFlag1131 = 1131,
kGameFlag1137 = 1137,
kGameFlag1144 = 1144
@@ -645,9 +647,19 @@ enum ObjectId {
kObjectGong6 = 2596,
kObjectGhost2b = 2634,
kObjectRitualLoop = 2674,
+ kObjectLine = 2859,
+ kObjectZapPattern1 = 2876,
+ kObjectZapPattern2 = 2877,
+ kObjectZapPattern3 = 2878,
kObjectBlanklPixelForWarrior = 2884,
kObjectPixelForHutWarrior = 2885,
kObjectPixelForWaterfallGhost = 2886,
+ kObjectZapPattern4 = 2892,
+ kObjectZapPattern5 = 2893,
+ kObjectZapPattern6 = 2894,
+ kObjectZapPattern7 = 2895,
+ kObjectZapPattern8 = 2896,
+ kObjectZapPattern9 = 2897,
kObjectLitLimbScanner = 3061,
kObjectOfficeWallNew = 3062,
kObjectCyberTable = 3065,
diff --git a/engines/asylum/views/scene.cpp b/engines/asylum/views/scene.cpp
index 1f2d5f7bbf..9546d6a911 100644
--- a/engines/asylum/views/scene.cpp
+++ b/engines/asylum/views/scene.cpp
@@ -66,6 +66,7 @@ Scene::Scene(AsylumEngine *engine): _vm(engine),
_chapter5RainFrameIndex = 0;
_musicVolume = 0;
+ _frameCounter = 0;
g_debugActors = 0;
g_debugObjects = 0;
@@ -609,7 +610,7 @@ bool Scene::clickDown(const AsylumEvent &evt) {
// Scene update
//////////////////////////////////////////////////////////////////////////
bool Scene::updateScreen() {
- // Original has a frame counter (for showing fps)
+ _frameCounter++;
if (updateScene())
return true;
diff --git a/engines/asylum/views/scene.h b/engines/asylum/views/scene.h
index d25ac758e6..a66f25bf6b 100644
--- a/engines/asylum/views/scene.h
+++ b/engines/asylum/views/scene.h
@@ -193,6 +193,7 @@ public:
Polygons *polygons() { return _polygons; }
WorldStats *worldstats() { return _ws; }
+ uint32 getFrameCounter() { return _frameCounter; }
private:
AsylumEngine *_vm;
@@ -211,6 +212,7 @@ private:
int32 _musicVolume;
Common::Array<UpdateItem> _updateList;
+ uint32 _frameCounter;
//////////////////////////////////////////////////////////////////////////
// Message handling
Commit: bc3ebf36db96ca20ba35c7ebbe13e157264c313e
https://github.com/scummvm/scummvm/commit/bc3ebf36db96ca20ba35c7ebbe13e157264c313e
Author: alxpnv (alxpnv22 at yahoo.com)
Date: 2021-05-17T15:37:48+02:00
Commit Message:
ASYLUM: implement Special::chapter11()
Changed paths:
engines/asylum/resources/actor.cpp
engines/asylum/resources/actor.h
engines/asylum/resources/special.cpp
engines/asylum/resources/special.h
engines/asylum/resources/worldstats.cpp
engines/asylum/resources/worldstats.h
engines/asylum/shared.h
diff --git a/engines/asylum/resources/actor.cpp b/engines/asylum/resources/actor.cpp
index 64d72159c2..1bcb26b825 100644
--- a/engines/asylum/resources/actor.cpp
+++ b/engines/asylum/resources/actor.cpp
@@ -519,8 +519,8 @@ void Actor::update() {
break;
case 1:
- updateStatus12_Chapter11_Actor1();
- return;
+ getSpecial()->run(NULL, _index);
+ break;
case 10:
case 11:
@@ -2327,16 +2327,6 @@ void Actor::updateStatusEnabled() {
break;
}
}
-
- // XXX
- if (getWorld()->chapter == kChapter11 && _index == 9)
- // the following block is originally from updateStatus12_Chapter11_Actor1()
- if (_vm->isGameFlagNotSet(kGameFlag1099)) {
- _vm->setGameFlag(kGameFlag1099);
- _reaction[0] = 1;
- _reaction[1] = 2;
- _reaction[2] = 3;
- }
}
void Actor::updateStatusEnabledProcessStatus(int16 testX, int16 testY, uint32 counter, int16 setX, int16 setY) {
@@ -2491,28 +2481,6 @@ void Actor::updateStatus12_Chapter2_Actor11() {
}
}
-void Actor::updateStatus12_Chapter11_Actor1() {
- // Original seems to have lots of dead code here
- Actor *actor0 = getScene()->getActor(0);
- if (actor0->isVisible())
- return;
-
- if (_vm->isGameFlagNotSet(kGameFlag560))
- _frameIndex = (_frameIndex + 1) & _frameCount;
-
- if (getWorld()->tickCount1 < (int32)_vm->getTick()
- && !_frameIndex
- && _vm->isGameFlagNotSet(kGameFlag560)) {
- _vm->setGameFlag(kGameFlag560);
- hide();
- updateStatus(kActorStatusEnabled);
- actor0->updateStatus(kActorStatusEnabled);
-
- getWorld()->field_E848C = 0;
- getScript()->queueScript(getWorld()->getActionAreaById(1574)->scriptIndex, 1);
- }
-}
-
void Actor::updateStatus12_Chapter11() {
if (!_frameIndex)
getSound()->playSound(getWorld()->soundResourceIds[6]);
diff --git a/engines/asylum/resources/actor.h b/engines/asylum/resources/actor.h
index 17abe01fcb..e5dab90ece 100644
--- a/engines/asylum/resources/actor.h
+++ b/engines/asylum/resources/actor.h
@@ -107,6 +107,7 @@ public:
void setSoundResourceId(ResourceId id) { _soundResourceId = id; }
void setStatus(ActorStatus status) { _status = status; }
void setTransparency(int32 val) { _transparency = val; }
+ void setTickCount(int32 tickCount) { _tickCount = tickCount; }
void setField638(int32 val) { _field_638 = val; }
void setField934(int32 val) { _field_934 = val; }
@@ -132,6 +133,7 @@ public:
bool shouldInvertPriority() { return _invertPriority; }
ResourceId getSoundResourceId() { return _soundResourceId; }
ActorStatus getStatus() { return _status; }
+ int32 getTickCount() { return _tickCount; }
int32 getField638() { return _field_638; }
int32 getField934() { return _field_934; }
@@ -438,7 +440,6 @@ private:
void updateStatus12_Chapter2();
void updateStatus12_Chapter2_Actor11();
- void updateStatus12_Chapter11_Actor1();
void updateStatus12_Chapter11();
void updateStatus14();
diff --git a/engines/asylum/resources/special.cpp b/engines/asylum/resources/special.cpp
index 4b78355399..4be7698788 100644
--- a/engines/asylum/resources/special.cpp
+++ b/engines/asylum/resources/special.cpp
@@ -25,6 +25,7 @@
#include "asylum/resources/actor.h"
#include "asylum/resources/object.h"
#include "asylum/resources/encounters.h"
+#include "asylum/resources/polygons.h"
#include "asylum/resources/script.h"
#include "asylum/resources/worldstats.h"
@@ -39,6 +40,22 @@
namespace Asylum {
+static const Common::Point actorRects[][2] = {
+ {Common::Point(1100, 150), Common::Point( 30, 95)},
+ {Common::Point( 695, 159), Common::Point( 113, 54)},
+ {Common::Point( 925, 158), Common::Point( 129, 66)},
+ {Common::Point(1158, 162), Common::Point( 135, 86)},
+ {Common::Point(1319, 218), Common::Point( 150, 133)},
+ {Common::Point( 430, 351), Common::Point( 78, 56)},
+ {Common::Point( 762, 339), Common::Point( 102, 59)},
+ {Common::Point( 962, 328), Common::Point( 118, 45)},
+ {Common::Point( 848, 161), Common::Point( 36, 55)},
+ {Common::Point( 861, 334), Common::Point( 23, 79)},
+ {Common::Point( 600, 193), Common::Point( 21, 36)},
+ {Common::Point( 805, 156), Common::Point( 152, 69)},
+ {Common::Point( 641, 162), Common::Point( 150, 64)},
+};
+
static const int32 zapPatterns[9][16] = {
{2292, 2299, 2301, 2302, 2303, 2304, 2306, 2307, 2310, 2311, 2312, 2313, 2314},
{2291, 2294, 2295, 2296, 2297, 2298, 2300, 2301, 2306, 2309, 2311, 2313, 2316},
@@ -109,6 +126,10 @@ void Special::run(Object* object, ActorIndex index) {
chapter9(object, index);
break;
+ case kChapter11:
+ chapter11(object, index);
+ break;
+
case kChapter12:
chapter12(object, index);
break;
@@ -712,6 +733,265 @@ void Special::chapter9(Object *object, ActorIndex actorIndex) {
}
}
+void Special::chapter11(Object *object, ActorIndex actorIndex) {
+ Actor *actor0 = getScene()->getActor(0), *actor1 = getScene()->getActor(1);
+ Actor *player = getScene()->getActor(getSharedData()->getPlayerIndex());
+ Common::Point sum;
+
+ playChapterSound(object, actorIndex);
+
+ if (actorIndex == kActorInvalid) {
+ switch (object->getId()) {
+ default:
+ return;
+
+ case kObjectABarrier:
+ if (actor0->isVisible() && _vm->isGameFlagSet(kGameFlag708)) {
+ if (!getSound()->isPlaying(getSpeech()->getSoundResourceId()))
+ _vm->clearGameFlag(kGameFlag219);
+ if (!getWorld()->field_E848C && !getSound()->isPlaying(getWorld()->soundResourceIds[3]))
+ getSound()->playSound(getWorld()->soundResourceIds[3], false, Config.sfxVolume);
+ if (getWorld()->field_E848C == 1 && !getSound()->isPlaying(getWorld()->soundResourceIds[4]))
+ getSound()->playSound(getWorld()->soundResourceIds[4], false, Config.sfxVolume);
+ if (getWorld()->field_E848C == 2 && !getSound()->isPlaying(getWorld()->soundResourceIds[5]))
+ getSound()->playSound(getWorld()->soundResourceIds[5], false, Config.sfxVolume);
+ }
+
+ if (_vm->isGameFlagNotSet(kGameFlag1099)) {
+ _vm->setGameFlag(kGameFlag1099);
+ getScene()->getActor(9)->setReaction(0, 1);
+ getScene()->getActor(9)->setReaction(1, 2);
+ getScene()->getActor(9)->setReaction(2, 3);
+ }
+
+ if (_vm->isGameFlagSet(kGameFlag561) && _vm->isGameFlagNotSet(kGameFlag562)) {
+ ActorStatus playerStatus = player->getStatus();
+ if (playerStatus != kActorStatusGettingHurt && playerStatus != kActorStatusRestarting && playerStatus != kActorStatusAttacking && playerStatus != kActorStatusWalkingTo2)
+ actor0->updateStatus(kActorStatusAttacking);
+ _vm->clearGameFlag(kGameFlag561);
+ }
+
+ if (actor1->getTickCount() != -1 && actor1->getTickCount() < _vm->getTick()) {
+ actor1->setTickCount(-1);
+ actor1->show();
+ actor1->getPoint1()->x = actor0->getPoint2()->x + actor0->getPoint1()->x - actor1->getPoint2()->x;
+ actor1->getPoint1()->y = actor0->getPoint2()->y + actor0->getPoint1()->y - actor1->getPoint2()->y;
+ actor1->updateStatus(kActorStatusWalking2);
+ }
+
+ tentacle(10, kGameFlag557, kGameFlag558, kGameFlag563, actorRects[0][0], actorRects[0][1]);
+ tentacle(11, kGameFlag722, kGameFlag723, kGameFlag724, actorRects[8][0], actorRects[8][1]);
+ tentacle(12, kGameFlag725, kGameFlag726, kGameFlag727, actorRects[9][0], actorRects[9][1]);
+ tentacle(13, kGameFlag728, kGameFlag729, kGameFlag730, actorRects[10][0], actorRects[10][1]);
+ rock(2, kGameFlag597, kGameFlag598, kGameFlag599, kGameFlag600, actorRects[1][0], actorRects[1][1]);
+ rock(3, kGameFlag684, kGameFlag685, kGameFlag686, kGameFlag687, actorRects[2][0], actorRects[2][1]);
+ rock(4, kGameFlag688, kGameFlag689, kGameFlag690, kGameFlag691, actorRects[3][0], actorRects[3][1]);
+ rock(5, kGameFlag692, kGameFlag693, kGameFlag694, kGameFlag695, actorRects[4][0], actorRects[4][1]);
+ rock(6, kGameFlag696, kGameFlag697, kGameFlag698, kGameFlag699, actorRects[5][0], actorRects[5][1]);
+ rock(7, kGameFlag700, kGameFlag701, kGameFlag702, kGameFlag703, actorRects[6][0], actorRects[6][1]);
+ rock(8, kGameFlag704, kGameFlag705, kGameFlag706, kGameFlag707, actorRects[7][0], actorRects[7][1]);
+ rock(16, kGameFlag1054, kGameFlag1055, kGameFlag1056, kGameFlag1057, actorRects[11][0], actorRects[11][1]);
+ rock(17, kGameFlag1058, kGameFlag1059, kGameFlag1060, kGameFlag1061, actorRects[12][0], actorRects[12][1]);
+ break;
+
+ case kObjectMonsterHurt:
+ object->setFrameIndex(object->getFrameIndex() + 1);
+ if (object->getFrameIndex() == 4) {
+ if (getWorld()->field_E8518 <= 2) {
+ object->setFrameIndex(0);
+ _vm->clearGameFlag(kGameFlag582);
+ _vm->setGameFlag(kGameFlag565);
+ } else {
+ _vm->clearGameFlag(kGameFlag582);
+ _vm->setGameFlag(kGameFlag566);
+ }
+ }
+ break;
+
+ case kObjectMonsterDeath:
+ if (object->getFrameIndex() == object->getFrameCount() - 1) {
+ _vm->clearGameFlag(kGameFlag566);
+ _vm->setGameFlag(kGameFlag596);
+ } else {
+ if (object->getFrameIndex() == 40) {
+ _vm->setGameFlag(kGameFlag219);
+ getSpeech()->playPlayer(134);
+ }
+ }
+ break;
+
+ case kObjectMonsterUp:
+ object->setFrameIndex(object->getFrameIndex() + 1);
+ if (object->getFrameIndex() >= object->getFrameCount()) {
+ _vm->clearGameFlag(kGameFlag564);
+ getSpeech()->playPlayer(0);
+ object->setFrameIndex(0);
+ _vm->setGameFlag(kGameFlag565);
+ getWorld()->field_E8490 = -666;
+ }
+ break;
+
+ case kObjectMonsterAttack:
+ if (object->getFrameIndex() != 9)
+ object->setFrameIndex(object->getFrameIndex() + 1);
+ if (object->getFrameIndex() == 8) {
+ getSound()->playSound(object->getSoundResourceId(), false, Config.sfxVolume);
+
+ switch (getWorld()->field_E8494) {
+ default:
+ break;
+
+ case 0:
+ _vm->setGameFlag(kGameFlag567);
+ break;
+
+ case 1:
+ _vm->setGameFlag(kGameFlag568);
+ break;
+
+ case 2:
+ _vm->setGameFlag(kGameFlag569);
+ break;
+
+ case 3:
+ _vm->setGameFlag(kGameFlag567);
+ _vm->setGameFlag(kGameFlag568);
+ _vm->setGameFlag(kGameFlag569);
+ break;
+ }
+
+ if (++getWorld()->field_E8494 > 3)
+ getWorld()->field_E8494 = 0;
+ }
+
+ if (object->getFrameIndex() >= object->getFrameCount()) {
+ _vm->clearGameFlag(kGameFlag570);
+ object->setFrameIndex(0);
+ _vm->setGameFlag(kGameFlag565);
+ }
+ break;
+
+ case kObjectPuke1:
+ sum = *player->getPoint1() + *player->getPoint2();
+ if (getScene()->polygons()->get(getWorld()->actions[getWorld()->getActionAreaIndexById(1591)]->polygonIndex).contains(sum)) {
+ ActorStatus playerStatus = getScene()->getActor(getSharedData()->getPlayerIndex())->getStatus();
+ if (playerStatus == kActorStatusWalking2 || playerStatus == kActorStatusAttacking || playerStatus == kActorStatusEnabled2) {
+ actor0->updateStatus(kActorStatusGettingHurt);
+ getSpeech()->playPlayer(131);
+ ++getWorld()->field_E848C;
+ getSound()->stop(getWorld()->soundResourceIds[3]);
+ getSound()->stop(getWorld()->soundResourceIds[4]);
+ getSound()->stop(getWorld()->soundResourceIds[5]);
+ }
+ }
+
+ object->setFrameIndex(object->getFrameIndex() + 1);
+ if (object->getFrameIndex() == 15) {
+ Object *otherObject = getWorld()->getObjectById(kObjectMonsterAttack);
+ otherObject->setFrameIndex(otherObject->getFrameIndex() + 1);
+ }
+
+ if (object->getFrameIndex() >= object->getFrameCount()) {
+ _vm->clearGameFlag(kGameFlag567);
+ object->setFrameIndex(0);
+ }
+ break;
+
+ case kObjectPuke2:
+ sum = *player->getPoint1() + *player->getPoint2();
+ if (getScene()->polygons()->get(getWorld()->actions[getWorld()->getActionAreaIndexById(1590)]->polygonIndex).contains(sum)) {
+ ActorStatus playerStatus = getScene()->getActor(getSharedData()->getPlayerIndex())->getStatus();
+ if (playerStatus == kActorStatusWalking2 || playerStatus == kActorStatusAttacking || playerStatus == kActorStatusEnabled2) {
+ actor0->updateStatus(kActorStatusGettingHurt);
+ ++getWorld()->field_E848C;
+ getSound()->stop(getWorld()->soundResourceIds[3]);
+ getSound()->stop(getWorld()->soundResourceIds[4]);
+ getSound()->stop(getWorld()->soundResourceIds[5]);
+ getSpeech()->playPlayer(131);
+ }
+ }
+
+ object->setFrameIndex(object->getFrameIndex() + 1);
+ if (object->getFrameIndex() == 15 && _vm->isGameFlagNotSet(kGameFlag567)) {
+ Object *otherObject = getWorld()->getObjectById(kObjectMonsterAttack);
+ otherObject->setFrameIndex(otherObject->getFrameIndex() + 1);
+ }
+
+ if (object->getFrameIndex() >= object->getFrameCount()) {
+ _vm->clearGameFlag(kGameFlag568);
+ object->setFrameIndex(0);
+ }
+ break;
+
+ case kObjectPuke3:
+ sum = *player->getPoint1() + *player->getPoint2();
+ if (getScene()->polygons()->get(getWorld()->actions[getWorld()->getActionAreaIndexById(1589)]->polygonIndex).contains(sum)) {
+ ActorStatus playerStatus = getScene()->getActor(getSharedData()->getPlayerIndex())->getStatus();
+ if (playerStatus == kActorStatusWalking2 || playerStatus == kActorStatusAttacking || playerStatus == kActorStatusEnabled2) {
+ actor0->updateStatus(kActorStatusGettingHurt);
+ ++getWorld()->field_E848C;
+ getSound()->stop(getWorld()->soundResourceIds[3]);
+ getSound()->stop(getWorld()->soundResourceIds[4]);
+ getSound()->stop(getWorld()->soundResourceIds[5]);
+ getSpeech()->playPlayer(131);
+ }
+ }
+
+ object->setFrameIndex(object->getFrameIndex() + 1);
+ if (object->getFrameIndex() == 15 && _vm->isGameFlagNotSet(kGameFlag567)) {
+ Object *otherObject = getWorld()->getObjectById(kObjectMonsterAttack);
+ otherObject->setFrameIndex(otherObject->getFrameIndex() + 1);
+ }
+
+ if (object->getFrameIndex() >= object->getFrameCount()) {
+ _vm->clearGameFlag(kGameFlag569);
+ object->setFrameIndex(0);
+ }
+ break;
+
+ case kObjectMonsterStatus:
+ _vm->setGameFlag(kGameFlag572);
+ if (object->getFrameIndex() >= getWorld()->dword_4563A0 + object->getFrameIndex()) {
+ object->setFrameIndex(object->getFrameCount() - 1);
+ getWorld()->dword_4563A0 = -1;
+ }
+
+ if (object->getFrameIndex() < 0) {
+ object->setFrameIndex(0);
+ getWorld()->dword_4563A0 = 1;
+ }
+
+ if (getWorld()->field_E8490 == -666)
+ getWorld()->field_E8490 = _vm->getTick() + 3000;
+
+ if (getWorld()->field_E8490 < _vm->getTick()) {
+ getWorld()->field_E8490 = -666;
+ if (_vm->isGameFlagSet(kGameFlag572)) {
+ _vm->clearGameFlag(kGameFlag565);
+ _vm->setGameFlag(kGameFlag570);
+ }
+ }
+ break;
+
+ }
+ } else {
+ if (actorIndex == 1 && !actor0->isVisible()) {
+ if (_vm->isGameFlagNotSet(kGameFlag560))
+ actor1->setFrameIndex((actor1->getFrameIndex() + 1) % actor1->getFrameCount());
+ if (getWorld()->tickCount1 < _vm->getTick() && !actor1->getFrameIndex()) {
+ if (_vm->isGameFlagNotSet(kGameFlag560)) {
+ _vm->setGameFlag(kGameFlag560);
+ actor1->hide();
+ actor1->updateStatus(kActorStatusEnabled);
+ actor0->updateStatus(kActorStatusEnabled);
+ getWorld()->field_E848C = 0;
+ getScript()->queueScript(getWorld()->getActionAreaIndexById(1574), kActorSarah);
+ }
+ }
+ }
+ }
+}
+
void Special::chapter12(Object *object, ActorIndex actorIndex) {
playChapterSound(object, actorIndex);
@@ -1727,4 +2007,88 @@ void Special::checkOtherObject(Object *object, ObjectId otherObjectId, GameFlag
}
}
+//////////////////////////////////////////////////////////////////////////
+// Chapter 11 helpers
+//////////////////////////////////////////////////////////////////////////
+
+void Special::rock(ActorIndex actorIndex, GameFlag flag1, GameFlag flag2, GameFlag flag3, GameFlag flag4, const Common::Point &p1, const Common::Point &p2) {
+ Actor *actor = getScene()->getActor(actorIndex);
+
+ if (!(_vm->isGameFlagNotSet(flag1) && _vm->isGameFlagSet(flag2)))
+ return;
+
+ if (_vm->isGameFlagNotSet(flag3)) {
+ getWorld()->tickValueArray[actorIndex] = _vm->getTick() + 1500;
+
+ actor->getPoint1()->x = p1.x + rnd(p2.x - p1.x) - actor->getPoint2()->x;
+ actor->getPoint1()->y = p1.y + rnd(p2.y - p1.y) - actor->getPoint2()->y;
+
+ getWorld()->field_E8594[actorIndex] = actor->getPoint1()->y;
+ actor->getPoint1()->y -= 160;
+
+ actor->updateStatus(kActorStatusEnabled2);
+ getSound()->playSound(getWorld()->soundResourceIds[0], false, Config.sfxVolume - 10);
+ _vm->setGameFlag(flag3);
+ getScene()->getActor(actorIndex)->show();
+ } else if (_vm->getTick() > getWorld()->tickValueArray[actorIndex]) {
+ if (_vm->isGameFlagNotSet(flag4)) {
+ _vm->setGameFlag(flag4);
+ actor->setFrameIndex(0);
+ actor->updateStatus(kActorStatusWalking2);
+ if (actorIndex == 8 || actorIndex == 9)
+ actor->setField944(1);
+ actor->getPoint1()->y = 0;
+ } else {
+ if (actor->getPoint1()->y <= getWorld()->field_E8594[actorIndex]) {
+ actor->getPoint1()->y += 27;
+ actor->setFrameIndex((actor->getFrameIndex() + 1) % actor->getFrameCount());
+ } else if (actor->getStatus() == kActorStatusAttacking) {
+ actor->setFrameIndex((actor->getFrameIndex() + 1) % actor->getFrameCount());
+ if (actor->getFrameIndex() == actor->getFrameCount() - 1)
+ actor->hide();
+ } else {
+ actor->setField944(3);
+ getSound()->playSound(getWorld()->soundResourceIds[1], false, Config.sfxVolume - 10);
+ actor->updateStatus(kActorStatusAttacking);
+ actor->setFrameIndex(4);
+
+ ActorIndex playerIndex = getSharedData()->getPlayerIndex();
+ Common::Point sum = *actor->getPoint1() + *actor->getPoint2();
+ Common::Point playerSum = *getScene()->getActor(playerIndex)->getPoint1() + *getScene()->getActor(playerIndex)->getPoint2();
+ if (Actor::euclidianDistance(sum, playerSum) < 30) {
+ getScene()->getActor(0)->updateStatus(kActorStatusGettingHurt);
+ ++getWorld()->field_E848C;
+ getSound()->stop(getWorld()->soundResourceIds[3]);
+ getSound()->stop(getWorld()->soundResourceIds[4]);
+ getSound()->stop(getWorld()->soundResourceIds[5]);
+ getSpeech()->playPlayer(131);
+ }
+ }
+ }
+ }
+}
+
+void Special::tentacle(ActorIndex actorIndex, GameFlag flag1, GameFlag flag2, GameFlag flag3, const Common::Point &p1, const Common::Point &p2) {
+ Actor *actor = getScene()->getActor(actorIndex);
+ if (_vm->isGameFlagSet(flag1)
+ && _vm->isGameFlagNotSet(flag3)
+ && !_vm->isGameFlagSet(flag2)
+ && _vm->getTick() > getWorld()->tickValueArray[actorIndex + 10]) {
+ actor->getPoint1()->x = p1.x + rnd(p2.x - p1.x) - actor->getPoint2()->x;
+ actor->getPoint1()->y = p1.y + rnd(p2.y - p1.y) - actor->getPoint2()->y;
+
+ ActorIndex playerIndex = getSharedData()->getPlayerIndex();
+ Common::Point sum = *actor->getPoint1() + *actor->getPoint2();
+ Common::Point playerSum = *getScene()->getActor(playerIndex)->getPoint1() + *getScene()->getActor(playerIndex)->getPoint2();
+
+ if (Actor::euclidianDistance(sum, playerSum) > 40) {
+ getWorld()->tickValueArray[actorIndex + 10] = 0;
+ actor->show();
+ actor->updateStatus(kActorStatusWalking2);
+ actor->setFrameIndex(0);
+ _vm->setGameFlag(flag2);
+ }
+ }
+}
+
} // End of namespace Asylum
diff --git a/engines/asylum/resources/special.h b/engines/asylum/resources/special.h
index 14fa57d8a4..0b58b43122 100644
--- a/engines/asylum/resources/special.h
+++ b/engines/asylum/resources/special.h
@@ -26,6 +26,7 @@
#include "asylum/shared.h"
#include "common/scummsys.h"
+#include "common/rect.h"
namespace Asylum {
@@ -64,6 +65,7 @@ private:
void chapter7(Object *object, ActorIndex actorIndex);
void chapter8(Object *object, ActorIndex actorIndex);
void chapter9(Object *object, ActorIndex actorIndex);
+ void chapter11(Object *object, ActorIndex actorIndex);
void chapter12(Object *object, ActorIndex actorIndex);
void chapter13(Object *object, ActorIndex actorIndex);
@@ -98,6 +100,13 @@ private:
void checkObject(Object *object, GameFlag flagToSet, GameFlag flagToClear, ObjectId objectId = kObjectNone);
void checkOtherObject(Object *object, ObjectId otherObjectId, GameFlag flagToClear, GameFlag flagToSet);
+
+ //////////////////////////////////////////////////////////////////////////
+ // Chapter 11 helpers
+ //////////////////////////////////////////////////////////////////////////
+
+ void tentacle(ActorIndex actorIndex, GameFlag flag1, GameFlag flag2, GameFlag flag3, const Common::Point &p1, const Common::Point &p2);
+ void rock(ActorIndex actorIndex, GameFlag flag1, GameFlag flag2, GameFlag flag3, GameFlag flag4, const Common::Point &p1, const Common::Point &p2);
};
} // End of namespace Asylum
diff --git a/engines/asylum/resources/worldstats.cpp b/engines/asylum/resources/worldstats.cpp
index cf238b582d..f3babf6f63 100644
--- a/engines/asylum/resources/worldstats.cpp
+++ b/engines/asylum/resources/worldstats.cpp
@@ -92,6 +92,7 @@ WorldStats::WorldStats(AsylumEngine *engine) : _vm(engine) {
memset(&wheels, 0, sizeof(wheels));
tickCount1 = 0;
memset(&field_E8660, 0, sizeof(field_E8660));
+ dword_4563A0 = 0;
}
WorldStats::~WorldStats() {
diff --git a/engines/asylum/resources/worldstats.h b/engines/asylum/resources/worldstats.h
index ea0e3d5e12..a0bac0320e 100644
--- a/engines/asylum/resources/worldstats.h
+++ b/engines/asylum/resources/worldstats.h
@@ -141,6 +141,7 @@ public:
Object *wheels[7];
int32 tickCount1;
uint32 field_E8660[6];
+ int32 dword_4563A0;
void setWheelObjects();
diff --git a/engines/asylum/shared.h b/engines/asylum/shared.h
index ff66f59a81..ee1c8faec5 100644
--- a/engines/asylum/shared.h
+++ b/engines/asylum/shared.h
@@ -121,20 +121,66 @@ enum GameFlag {
kGameFlag545 = 545,
kGameFlag553 = 553,
kGameFlag556 = 556,
+ kGameFlag557 = 557,
+ kGameFlag558 = 558,
kGameFlag560 = 560,
+ kGameFlag561 = 561,
+ kGameFlag562 = 562,
kGameFlag563 = 563,
+ kGameFlag564 = 564,
kGameFlag565 = 565,
+ kGameFlag566 = 566,
+ kGameFlag567 = 567,
+ kGameFlag568 = 568,
+ kGameFlag569 = 569,
kGameFlag570 = 570,
+ kGameFlag572 = 572,
kGameFlag582 = 582,
kGameFlag583 = 583,
+ kGameFlag596 = 596,
+ kGameFlag597 = 597,
+ kGameFlag598 = 598,
+ kGameFlag599 = 599,
+ kGameFlag600 = 600,
kGameFlag608 = 608,
kGameFlag619 = 619,
kGameFlag635 = 635,
kGameFlag636 = 636,
kGameFlag637 = 637,
kGameFlagSolveHiveControl = 640,
+ kGameFlag684 = 684,
+ kGameFlag685 = 685,
+ kGameFlag686 = 686,
+ kGameFlag687 = 687,
+ kGameFlag688 = 688,
+ kGameFlag689 = 689,
+ kGameFlag690 = 690,
+ kGameFlag691 = 691,
+ kGameFlag692 = 692,
+ kGameFlag693 = 693,
+ kGameFlag694 = 694,
+ kGameFlag695 = 695,
+ kGameFlag696 = 696,
+ kGameFlag697 = 697,
+ kGameFlag698 = 698,
+ kGameFlag699 = 699,
+ kGameFlag700 = 700,
+ kGameFlag701 = 701,
+ kGameFlag702 = 702,
+ kGameFlag703 = 703,
+ kGameFlag704 = 704,
+ kGameFlag705 = 705,
+ kGameFlag706 = 706,
+ kGameFlag707 = 707,
+ kGameFlag708 = 708,
+ kGameFlag722 = 722,
+ kGameFlag723 = 723,
kGameFlag724 = 724,
+ kGameFlag725 = 725,
+ kGameFlag726 = 726,
kGameFlag727 = 727,
+ kGameFlag728 = 728,
+ kGameFlag729 = 729,
kGameFlag730 = 730,
kGameFlag759 = 759,
kGameFlag760 = 760,
@@ -188,6 +234,14 @@ enum GameFlag {
kGameFlag1021 = 1021,
kGameFlag1022 = 1022,
kGameFlag1023 = 1023,
+ kGameFlag1054 = 1054,
+ kGameFlag1055 = 1055,
+ kGameFlag1056 = 1056,
+ kGameFlag1057 = 1057,
+ kGameFlag1058 = 1058,
+ kGameFlag1059 = 1059,
+ kGameFlag1060 = 1060,
+ kGameFlag1061 = 1061,
kGameFlag1062 = 1062,
kGameFlag1063 = 1063,
kGameFlag1064 = 1064,
@@ -570,6 +624,15 @@ enum ObjectId {
kObjectWitchDoctor = 1778,
kObjectStoneWifeStatuQuo = 1782,
kObjectFishermanWidowStatusQuo = 1786,
+ kObjectABarrier = 1899,
+ kObjectMonsterUp = 1956,
+ kObjectMonsterStatus = 1957,
+ kObjectMonsterDeath = 1958,
+ kObjectMonsterAttack = 1959,
+ kObjectPuke1 = 1960,
+ kObjectPuke2 = 1961,
+ kObjectPuke3 = 1962,
+ kObjectMonsterHurt = 1997,
kObjectWheel1 = 2113,
kObjectWheel2 = 2114,
kObjectWheel3 = 2115,
Commit: 74f1691ca11122cd4d10f13cb512c70df193d662
https://github.com/scummvm/scummvm/commit/74f1691ca11122cd4d10f13cb512c70df193d662
Author: alxpnv (alxpnv22 at yahoo.com)
Date: 2021-05-17T15:37:48+02:00
Commit Message:
ASYLUM: fix inventory ring drawing
Changed paths:
engines/asylum/asylum.cpp
engines/asylum/resources/actor.cpp
diff --git a/engines/asylum/asylum.cpp b/engines/asylum/asylum.cpp
index de02b07bf7..7e9618097c 100644
--- a/engines/asylum/asylum.cpp
+++ b/engines/asylum/asylum.cpp
@@ -520,7 +520,7 @@ void AsylumEngine::initSinCosTables(double a2, int32 a3, int32 a4) {
double angle = (double)(baseAngle % 360) * 3.141592653589 * 0.005555555555555556;
*val = (int16)(cos(angle) * a2 - (a3 / 2.0));
- *(val + 1) = (int16)(sin(angle) * a2 - (a4 / 2.0));
+ *(val + 1) = (int16)(sin(angle) * a2 + (a4 / 2.0));
baseAngle += 360 / baseStep;
val += 2;
@@ -552,7 +552,7 @@ Common::Point AsylumEngine::getSinCosValues(int32 index1, int32 index2) {
if (_scene->worldstats()->chapter == kChapter11) {
int32 offset = computeSinCosOffset(8) + index2 + 3;
values.x = _sinCosTables[2 * offset];
- values.y = _sinCosTables[1];
+ values.y = _sinCosTables[2 * offset + 1];
} else {
int32 offset = computeSinCosOffset(index1) + index2;
values.x = _sinCosTables[2 * offset];
diff --git a/engines/asylum/resources/actor.cpp b/engines/asylum/resources/actor.cpp
index 1bcb26b825..e30a2262b6 100644
--- a/engines/asylum/resources/actor.cpp
+++ b/engines/asylum/resources/actor.cpp
@@ -2001,7 +2001,7 @@ void Actor::updateAndDraw() {
adjustCoordinates(&coords);
Common::Point sinCos = _vm->getSinCosValues(count, i);
- Common::Point point = coords + Common::Point(player->getPoint2()->x + sinCos.x, player->getPoint2()->y / 2 - sinCos.y - 20);
+ Common::Point point = coords + Common::Point(player->getPoint2()->x + sinCos.x, player->getPoint2()->y / 2 - sinCos.y);
if (mouse.x < point.x || mouse.x > (point.x + 40) || mouse.y < point.y || mouse.y > (point.y + 40)) {
getScreen()->addGraphicToQueue(getWorld()->cursorResourcesAlternate[_reaction[i] + 15],
Commit: c5547820feac6b180824b45717cac78fe91fad44
https://github.com/scummvm/scummvm/commit/c5547820feac6b180824b45717cac78fe91fad44
Author: alxpnv (alxpnv22 at yahoo.com)
Date: 2021-05-17T15:37:48+02:00
Commit Message:
ASYLUM: fixes to chapter 11's hard-coded logic
Changed paths:
engines/asylum/resources/actor.cpp
engines/asylum/resources/special.cpp
engines/asylum/resources/special.h
diff --git a/engines/asylum/resources/actor.cpp b/engines/asylum/resources/actor.cpp
index e30a2262b6..b6120754e5 100644
--- a/engines/asylum/resources/actor.cpp
+++ b/engines/asylum/resources/actor.cpp
@@ -3026,8 +3026,8 @@ void Actor::updateStatus15_Chapter11() {
getSharedData()->vector1.x = actor0->getPoint1()->x + actor0->getPoint2()->x;
getSharedData()->vector1.y = actor0->getPoint1()->y + actor0->getPoint2()->y - 5;
- getSharedData()->vector2.x = actor0->getPoint1()->x + actor0->getPoint2()->x;
- getSharedData()->vector2.y = actor0->getPoint1()->y + actor0->getPoint2()->y;
+ getSharedData()->vector2.x = getPoint1()->x + getPoint2()->x;
+ getSharedData()->vector2.y = getPoint1()->y + getPoint2()->y;
updateCoordinates(getSharedData()->vector1, getSharedData()->vector2);
@@ -3313,10 +3313,10 @@ void Actor::updateCoordinates(const Common::Point &vec1, Common::Point vec2) {
if (diffY == 0)
return;
- ActorDirection dir = (diffY > 0) ? kDirectionS : kDirectionN;
+ ActorDirection dir = (vec1.y > vec2.y) ? kDirectionS : kDirectionN;
if (canMove(&vec2, dir, diffY + 3, false))
- updateCoordinatesForDirection(dir, (int16)(diffY - 1), &_point);
+ updateCoordinatesForDirection(dir, (int16)(diffY - 1), &_point1);
}
void Actor::resetActors() {
@@ -3731,8 +3731,8 @@ void Actor::setVolume() {
//////////////////////////////////////////////////////////////////////////
ActorDirection Actor::directionFromAngle(const Common::Point &vec1, const Common::Point &vec2) {
- int32 diffX = (vec2.x - vec1.x) * 2^16;
- int32 diffY = (vec1.y - vec2.y) * 2^16;
+ int32 diffX = (vec2.x << 16) - (vec1.x << 16);
+ int32 diffY = (vec1.y << 16) - (vec2.y << 16);
int32 adjust = 0;
if (diffX < 0) {
diff --git a/engines/asylum/resources/special.cpp b/engines/asylum/resources/special.cpp
index 4be7698788..be5f3edf2c 100644
--- a/engines/asylum/resources/special.cpp
+++ b/engines/asylum/resources/special.cpp
@@ -40,20 +40,20 @@
namespace Asylum {
-static const Common::Point actorRects[][2] = {
- {Common::Point(1100, 150), Common::Point( 30, 95)},
- {Common::Point( 695, 159), Common::Point( 113, 54)},
- {Common::Point( 925, 158), Common::Point( 129, 66)},
- {Common::Point(1158, 162), Common::Point( 135, 86)},
- {Common::Point(1319, 218), Common::Point( 150, 133)},
- {Common::Point( 430, 351), Common::Point( 78, 56)},
- {Common::Point( 762, 339), Common::Point( 102, 59)},
- {Common::Point( 962, 328), Common::Point( 118, 45)},
- {Common::Point( 848, 161), Common::Point( 36, 55)},
- {Common::Point( 861, 334), Common::Point( 23, 79)},
- {Common::Point( 600, 193), Common::Point( 21, 36)},
- {Common::Point( 805, 156), Common::Point( 152, 69)},
- {Common::Point( 641, 162), Common::Point( 150, 64)},
+static const Common::Rect actorRects[] = {
+ Common::Rect(1100, 150, 1130, 245),
+ Common::Rect( 848, 161, 884, 216),
+ Common::Rect( 861, 334, 884, 413),
+ Common::Rect( 600, 193, 621, 229),
+ Common::Rect( 805, 156, 957, 225),
+ Common::Rect( 641, 162, 791, 226),
+ Common::Rect( 695, 159, 808, 213),
+ Common::Rect( 925, 158, 1054, 224),
+ Common::Rect(1158, 162, 1293, 248),
+ Common::Rect(1319, 218, 1469, 351),
+ Common::Rect( 430, 351, 508, 407),
+ Common::Rect( 762, 339, 864, 398),
+ Common::Rect( 962, 328, 1080, 373),
};
static const int32 zapPatterns[9][16] = {
@@ -735,7 +735,7 @@ void Special::chapter9(Object *object, ActorIndex actorIndex) {
void Special::chapter11(Object *object, ActorIndex actorIndex) {
Actor *actor0 = getScene()->getActor(0), *actor1 = getScene()->getActor(1);
- Actor *player = getScene()->getActor(getSharedData()->getPlayerIndex());
+ Actor *player = getScene()->getActor();
Common::Point sum;
playChapterSound(object, actorIndex);
@@ -779,19 +779,19 @@ void Special::chapter11(Object *object, ActorIndex actorIndex) {
actor1->updateStatus(kActorStatusWalking2);
}
- tentacle(10, kGameFlag557, kGameFlag558, kGameFlag563, actorRects[0][0], actorRects[0][1]);
- tentacle(11, kGameFlag722, kGameFlag723, kGameFlag724, actorRects[8][0], actorRects[8][1]);
- tentacle(12, kGameFlag725, kGameFlag726, kGameFlag727, actorRects[9][0], actorRects[9][1]);
- tentacle(13, kGameFlag728, kGameFlag729, kGameFlag730, actorRects[10][0], actorRects[10][1]);
- rock(2, kGameFlag597, kGameFlag598, kGameFlag599, kGameFlag600, actorRects[1][0], actorRects[1][1]);
- rock(3, kGameFlag684, kGameFlag685, kGameFlag686, kGameFlag687, actorRects[2][0], actorRects[2][1]);
- rock(4, kGameFlag688, kGameFlag689, kGameFlag690, kGameFlag691, actorRects[3][0], actorRects[3][1]);
- rock(5, kGameFlag692, kGameFlag693, kGameFlag694, kGameFlag695, actorRects[4][0], actorRects[4][1]);
- rock(6, kGameFlag696, kGameFlag697, kGameFlag698, kGameFlag699, actorRects[5][0], actorRects[5][1]);
- rock(7, kGameFlag700, kGameFlag701, kGameFlag702, kGameFlag703, actorRects[6][0], actorRects[6][1]);
- rock(8, kGameFlag704, kGameFlag705, kGameFlag706, kGameFlag707, actorRects[7][0], actorRects[7][1]);
- rock(16, kGameFlag1054, kGameFlag1055, kGameFlag1056, kGameFlag1057, actorRects[11][0], actorRects[11][1]);
- rock(17, kGameFlag1058, kGameFlag1059, kGameFlag1060, kGameFlag1061, actorRects[12][0], actorRects[12][1]);
+ tentacle(10, kGameFlag557, kGameFlag558, kGameFlag563, actorRects[0]);
+ tentacle(11, kGameFlag722, kGameFlag723, kGameFlag724, actorRects[1]);
+ tentacle(12, kGameFlag725, kGameFlag726, kGameFlag727, actorRects[2]);
+ tentacle(13, kGameFlag728, kGameFlag729, kGameFlag730, actorRects[3]);
+ rock(2, kGameFlag597, kGameFlag598, kGameFlag599, kGameFlag600, actorRects[6]);
+ rock(3, kGameFlag684, kGameFlag685, kGameFlag686, kGameFlag687, actorRects[7]);
+ rock(4, kGameFlag688, kGameFlag689, kGameFlag690, kGameFlag691, actorRects[8]);
+ rock(5, kGameFlag692, kGameFlag693, kGameFlag694, kGameFlag695, actorRects[9]);
+ rock(6, kGameFlag696, kGameFlag697, kGameFlag698, kGameFlag699, actorRects[10]);
+ rock(7, kGameFlag700, kGameFlag701, kGameFlag702, kGameFlag703, actorRects[11]);
+ rock(8, kGameFlag704, kGameFlag705, kGameFlag706, kGameFlag707, actorRects[12]);
+ rock(16, kGameFlag1054, kGameFlag1055, kGameFlag1056, kGameFlag1057, actorRects[4]);
+ rock(17, kGameFlag1058, kGameFlag1059, kGameFlag1060, kGameFlag1061, actorRects[5]);
break;
case kObjectMonsterHurt:
@@ -873,6 +873,8 @@ void Special::chapter11(Object *object, ActorIndex actorIndex) {
case kObjectPuke1:
sum = *player->getPoint1() + *player->getPoint2();
+ getSharedData()->vector1 = sum;
+
if (getScene()->polygons()->get(getWorld()->actions[getWorld()->getActionAreaIndexById(1591)]->polygonIndex).contains(sum)) {
ActorStatus playerStatus = getScene()->getActor(getSharedData()->getPlayerIndex())->getStatus();
if (playerStatus == kActorStatusWalking2 || playerStatus == kActorStatusAttacking || playerStatus == kActorStatusEnabled2) {
@@ -899,6 +901,8 @@ void Special::chapter11(Object *object, ActorIndex actorIndex) {
case kObjectPuke2:
sum = *player->getPoint1() + *player->getPoint2();
+ getSharedData()->vector1 = sum;
+
if (getScene()->polygons()->get(getWorld()->actions[getWorld()->getActionAreaIndexById(1590)]->polygonIndex).contains(sum)) {
ActorStatus playerStatus = getScene()->getActor(getSharedData()->getPlayerIndex())->getStatus();
if (playerStatus == kActorStatusWalking2 || playerStatus == kActorStatusAttacking || playerStatus == kActorStatusEnabled2) {
@@ -925,6 +929,8 @@ void Special::chapter11(Object *object, ActorIndex actorIndex) {
case kObjectPuke3:
sum = *player->getPoint1() + *player->getPoint2();
+ getSharedData()->vector1 = sum;
+
if (getScene()->polygons()->get(getWorld()->actions[getWorld()->getActionAreaIndexById(1589)]->polygonIndex).contains(sum)) {
ActorStatus playerStatus = getScene()->getActor(getSharedData()->getPlayerIndex())->getStatus();
if (playerStatus == kActorStatusWalking2 || playerStatus == kActorStatusAttacking || playerStatus == kActorStatusEnabled2) {
@@ -2011,7 +2017,7 @@ void Special::checkOtherObject(Object *object, ObjectId otherObjectId, GameFlag
// Chapter 11 helpers
//////////////////////////////////////////////////////////////////////////
-void Special::rock(ActorIndex actorIndex, GameFlag flag1, GameFlag flag2, GameFlag flag3, GameFlag flag4, const Common::Point &p1, const Common::Point &p2) {
+void Special::rock(ActorIndex actorIndex, GameFlag flag1, GameFlag flag2, GameFlag flag3, GameFlag flag4, const Common::Rect &rect) {
Actor *actor = getScene()->getActor(actorIndex);
if (!(_vm->isGameFlagNotSet(flag1) && _vm->isGameFlagSet(flag2)))
@@ -2020,8 +2026,8 @@ void Special::rock(ActorIndex actorIndex, GameFlag flag1, GameFlag flag2, GameFl
if (_vm->isGameFlagNotSet(flag3)) {
getWorld()->tickValueArray[actorIndex] = _vm->getTick() + 1500;
- actor->getPoint1()->x = p1.x + rnd(p2.x - p1.x) - actor->getPoint2()->x;
- actor->getPoint1()->y = p1.y + rnd(p2.y - p1.y) - actor->getPoint2()->y;
+ actor->getPoint1()->x = rect.left + rnd(rect.right - rect.left) - actor->getPoint2()->x;
+ actor->getPoint1()->y = rect.top + rnd(rect.bottom - rect.top) - actor->getPoint2()->y;
getWorld()->field_E8594[actorIndex] = actor->getPoint1()->y;
actor->getPoint1()->y -= 160;
@@ -2052,9 +2058,12 @@ void Special::rock(ActorIndex actorIndex, GameFlag flag1, GameFlag flag2, GameFl
actor->updateStatus(kActorStatusAttacking);
actor->setFrameIndex(4);
- ActorIndex playerIndex = getSharedData()->getPlayerIndex();
Common::Point sum = *actor->getPoint1() + *actor->getPoint2();
- Common::Point playerSum = *getScene()->getActor(playerIndex)->getPoint1() + *getScene()->getActor(playerIndex)->getPoint2();
+ Common::Point playerSum = *getScene()->getActor()->getPoint1() + *getScene()->getActor()->getPoint2();
+
+ getSharedData()->vector1 = playerSum;
+ getSharedData()->vector2 = sum;
+
if (Actor::euclidianDistance(sum, playerSum) < 30) {
getScene()->getActor(0)->updateStatus(kActorStatusGettingHurt);
++getWorld()->field_E848C;
@@ -2068,18 +2077,20 @@ void Special::rock(ActorIndex actorIndex, GameFlag flag1, GameFlag flag2, GameFl
}
}
-void Special::tentacle(ActorIndex actorIndex, GameFlag flag1, GameFlag flag2, GameFlag flag3, const Common::Point &p1, const Common::Point &p2) {
+void Special::tentacle(ActorIndex actorIndex, GameFlag flag1, GameFlag flag2, GameFlag flag3, const Common::Rect &rect) {
Actor *actor = getScene()->getActor(actorIndex);
if (_vm->isGameFlagSet(flag1)
&& _vm->isGameFlagNotSet(flag3)
&& !_vm->isGameFlagSet(flag2)
&& _vm->getTick() > getWorld()->tickValueArray[actorIndex + 10]) {
- actor->getPoint1()->x = p1.x + rnd(p2.x - p1.x) - actor->getPoint2()->x;
- actor->getPoint1()->y = p1.y + rnd(p2.y - p1.y) - actor->getPoint2()->y;
+ actor->getPoint1()->x = rect.left + rnd(rect.right - rect.left) - actor->getPoint2()->x;
+ actor->getPoint1()->y = rect.top + rnd(rect.bottom - rect.top) - actor->getPoint2()->y;
- ActorIndex playerIndex = getSharedData()->getPlayerIndex();
Common::Point sum = *actor->getPoint1() + *actor->getPoint2();
- Common::Point playerSum = *getScene()->getActor(playerIndex)->getPoint1() + *getScene()->getActor(playerIndex)->getPoint2();
+ Common::Point playerSum = *getScene()->getActor()->getPoint1() + *getScene()->getActor()->getPoint2();
+
+ getSharedData()->vector1 = playerSum;
+ getSharedData()->vector2 = sum;
if (Actor::euclidianDistance(sum, playerSum) > 40) {
getWorld()->tickValueArray[actorIndex + 10] = 0;
diff --git a/engines/asylum/resources/special.h b/engines/asylum/resources/special.h
index 0b58b43122..41f8208cb9 100644
--- a/engines/asylum/resources/special.h
+++ b/engines/asylum/resources/special.h
@@ -105,8 +105,8 @@ private:
// Chapter 11 helpers
//////////////////////////////////////////////////////////////////////////
- void tentacle(ActorIndex actorIndex, GameFlag flag1, GameFlag flag2, GameFlag flag3, const Common::Point &p1, const Common::Point &p2);
- void rock(ActorIndex actorIndex, GameFlag flag1, GameFlag flag2, GameFlag flag3, GameFlag flag4, const Common::Point &p1, const Common::Point &p2);
+ void tentacle(ActorIndex actorIndex, GameFlag flag1, GameFlag flag2, GameFlag flag3, const Common::Rect &rect);
+ void rock(ActorIndex actorIndex, GameFlag flag1, GameFlag flag2, GameFlag flag3, GameFlag flag4, const Common::Rect &rect);
};
} // End of namespace Asylum
Commit: 8eb94fc95e3504ceac00a6a8bd6fbe16018bb65b
https://github.com/scummvm/scummvm/commit/8eb94fc95e3504ceac00a6a8bd6fbe16018bb65b
Author: alxpnv (alxpnv22 at yahoo.com)
Date: 2021-05-17T15:37:48+02:00
Commit Message:
ASYLUM: restart chapter 11 properly
Changed paths:
engines/asylum/resources/actor.cpp
engines/asylum/resources/special.cpp
diff --git a/engines/asylum/resources/actor.cpp b/engines/asylum/resources/actor.cpp
index b6120754e5..3cbf05bc62 100644
--- a/engines/asylum/resources/actor.cpp
+++ b/engines/asylum/resources/actor.cpp
@@ -520,7 +520,7 @@ void Actor::update() {
case 1:
getSpecial()->run(NULL, _index);
- break;
+ return;
case 10:
case 11:
@@ -3163,8 +3163,7 @@ void Actor::updateStatus16_Chapter11() {
_frameIndex = 0;
getScene()->getActor(0)->updateStatus(kActorStatusRestarting);
-
- _tickCount = _vm->getTick() + 2000;
+ getScene()->getActor(1)->setTickCount(_vm->getTick() + 2000);
} else {
getScene()->getActor(0)->updateStatus(kActorStatusEnabled2);
}
diff --git a/engines/asylum/resources/special.cpp b/engines/asylum/resources/special.cpp
index be5f3edf2c..ce13bccac1 100644
--- a/engines/asylum/resources/special.cpp
+++ b/engines/asylum/resources/special.cpp
@@ -991,7 +991,7 @@ void Special::chapter11(Object *object, ActorIndex actorIndex) {
actor1->updateStatus(kActorStatusEnabled);
actor0->updateStatus(kActorStatusEnabled);
getWorld()->field_E848C = 0;
- getScript()->queueScript(getWorld()->getActionAreaIndexById(1574), kActorSarah);
+ getScript()->queueScript(getWorld()->actions[getWorld()->getActionAreaIndexById(1574)]->scriptIndex, kActorSarah);
}
}
}
Commit: b754af14d66a4b819e82333bdf8a5c3559506024
https://github.com/scummvm/scummvm/commit/b754af14d66a4b819e82333bdf8a5c3559506024
Author: alxpnv (alxpnv22 at yahoo.com)
Date: 2021-05-17T15:37:48+02:00
Commit Message:
ASYLUM: fix tentacle's status update
Changed paths:
engines/asylum/resources/actor.cpp
diff --git a/engines/asylum/resources/actor.cpp b/engines/asylum/resources/actor.cpp
index 3cbf05bc62..4b3ab0b070 100644
--- a/engines/asylum/resources/actor.cpp
+++ b/engines/asylum/resources/actor.cpp
@@ -3853,7 +3853,7 @@ DrawFlags Actor::getGraphicsFlags() {
int32 Actor::getAbsoluteDistanceForFrame(ActorDirection dir, uint32 frameIndex) const {
if (frameIndex >= ARRAYSIZE(_distancesNS))
- error("[Actor::getAbsoluteDistanceForFrame] Invalid frame index (was: %d, max: %d)", _frameIndex, ARRAYSIZE(_distancesNS) - 1);
+ warning("[Actor::getAbsoluteDistanceForFrame] Invalid frame index (was: %d, max: %d)", _frameIndex, ARRAYSIZE(_distancesNS) - 1);
switch (dir) {
default:
@@ -3861,7 +3861,8 @@ int32 Actor::getAbsoluteDistanceForFrame(ActorDirection dir, uint32 frameIndex)
case kDirectionN:
case kDirectionS:
- return _distancesNS[frameIndex];
+ // XXX it seems that the original allows frameIndex to be out of range
+ return (frameIndex < ARRAYSIZE(_distancesNS) ? _distancesNS[frameIndex] : _distancesNSEO[frameIndex % ARRAYSIZE(_distancesNS)]);
case kDirectionNW:
case kDirectionSW:
Commit: 2d5d820c9366c3d97d459bef4af12dbc6e610c89
https://github.com/scummvm/scummvm/commit/2d5d820c9366c3d97d459bef4af12dbc6e610c89
Author: alxpnv (alxpnv22 at yahoo.com)
Date: 2021-05-17T15:37:48+02:00
Commit Message:
ASYLUM: add a missing else
Changed paths:
engines/asylum/resources/actor.cpp
diff --git a/engines/asylum/resources/actor.cpp b/engines/asylum/resources/actor.cpp
index 4b3ab0b070..8ae3f7f0c5 100644
--- a/engines/asylum/resources/actor.cpp
+++ b/engines/asylum/resources/actor.cpp
@@ -3755,6 +3755,8 @@ ActorDirection Actor::directionFromAngle(const Common::Point &vec1, const Common
dirAngle = angleTable02[index / 16];
else if (index < 65536)
dirAngle = angleTable03[index / 256];
+ else
+ dirAngle = 90;
} else {
dirAngle = 90;
}
Commit: 530b4d51f61cc000cc7d8c0ccf80d5f804a28df8
https://github.com/scummvm/scummvm/commit/530b4d51f61cc000cc7d8c0ccf80d5f804a28df8
Author: alxpnv (alxpnv22 at yahoo.com)
Date: 2021-05-17T15:37:49+02:00
Commit Message:
ASYLUM: fix music changing
Changed paths:
engines/asylum/system/sound.cpp
diff --git a/engines/asylum/system/sound.cpp b/engines/asylum/system/sound.cpp
index 97c32cc3c6..359db585cd 100644
--- a/engines/asylum/system/sound.cpp
+++ b/engines/asylum/system/sound.cpp
@@ -106,7 +106,7 @@ void Sound::playMusic(ResourceId resourceId, int32 volume) {
void Sound::changeMusic(int32 index, int32 musicStatusExt) {
if (index != getWorld()->musicCurrentResourceIndex) {
- getWorld()->musicCurrentResourceIndex = index;
+ getWorld()->musicResourceIndex = index;
getWorld()->musicStatusExt = musicStatusExt;
getWorld()->musicFlag = 1;
}
Commit: b2a919279352107bb885c31a73181cd4d155edef
https://github.com/scummvm/scummvm/commit/b2a919279352107bb885c31a73181cd4d155edef
Author: alxpnv (alxpnv22 at yahoo.com)
Date: 2021-05-17T15:37:49+02:00
Commit Message:
ASYLUM: make AsylumEngine::getRandom() generate a number from [0; max) to match the original
Changed paths:
engines/asylum/asylum.h
engines/asylum/puzzles/tictactoe.cpp
engines/asylum/resources/actor.cpp
engines/asylum/resources/object.cpp
engines/asylum/resources/special.cpp
engines/asylum/resources/worldstats.cpp
diff --git a/engines/asylum/asylum.h b/engines/asylum/asylum.h
index 0a999fedf1..206d3f7963 100644
--- a/engines/asylum/asylum.h
+++ b/engines/asylum/asylum.h
@@ -164,7 +164,7 @@ public:
void resetFlags();
// Misc
- uint getRandom(uint max) { return _rnd->getRandomNumber(max); }
+ uint getRandom(uint max) { return max ? _rnd->getRandomNumber(max - 1) : 0; }
uint getRandomBit() { return _rnd->getRandomBit(); }
/**
diff --git a/engines/asylum/puzzles/tictactoe.cpp b/engines/asylum/puzzles/tictactoe.cpp
index 7349d7da2e..5fe6427715 100644
--- a/engines/asylum/puzzles/tictactoe.cpp
+++ b/engines/asylum/puzzles/tictactoe.cpp
@@ -577,7 +577,7 @@ bool PuzzleTicTacToe::countEmptyFields() {
void PuzzleTicTacToe::placeOpponentMark() {
_frameIndex = 0;
- _lastMarkedField = _field[rnd(_emptyCount - 1)];
+ _lastMarkedField = _field[rnd(_emptyCount)];
if (_gameField[_lastMarkedField] != ' ')
error("[PuzzleTicTacToe::placeOpponentMark] Field is already occupied (%d)!", _lastMarkedField);
diff --git a/engines/asylum/resources/actor.cpp b/engines/asylum/resources/actor.cpp
index 8ae3f7f0c5..a98e9505b5 100644
--- a/engines/asylum/resources/actor.cpp
+++ b/engines/asylum/resources/actor.cpp
@@ -1768,14 +1768,14 @@ void Actor::move(ActorDirection actorDir, uint32 dist) {
ResourceId resourceId = kResourceNone;
if (getWorld()->actions[_actionIdx3]->soundResourceIdFrame != kResourceNone && strcmp((char *)&_name, "Crow") && strcmp((char *)&_name, "Big Crow")) {
if (_frameIndex == _field_64C)
- resourceId = (ResourceId)(getWorld()->actions[_actionIdx3]->soundResourceIdFrame + (int)rnd(1));
+ resourceId = (ResourceId)(getWorld()->actions[_actionIdx3]->soundResourceIdFrame + (int)rnd(2));
else if (_frameIndex == _field_650)
- resourceId = (ResourceId)(getWorld()->actions[_actionIdx3]->soundResourceId + (int)rnd(1));
+ resourceId = (ResourceId)(getWorld()->actions[_actionIdx3]->soundResourceId + (int)rnd(2));
} else {
if (_frameIndex == _field_64C)
- resourceId = (ResourceId)(_walkingSound1 + (int)rnd(1));
+ resourceId = (ResourceId)(_walkingSound1 + (int)rnd(2));
else if (_frameIndex == _field_650)
- resourceId = (ResourceId)(_walkingSound3 + (int)rnd(1));
+ resourceId = (ResourceId)(_walkingSound3 + (int)rnd(2));
}
// Play sound
@@ -1804,14 +1804,14 @@ void Actor::move(ActorDirection actorDir, uint32 dist) {
ResourceId resourceId = kResourceNone;
if (getWorld()->actions[_actionIdx3]->soundResourceIdFrame != kResourceNone && strcmp((char *)&_name, "Crow") && strcmp((char *)&_name, "Big Crow")) {
if (_frameIndex == _field_64C)
- resourceId = (ResourceId)(getWorld()->actions[_actionIdx3]->soundResourceIdFrame + (int)rnd(1));
+ resourceId = (ResourceId)(getWorld()->actions[_actionIdx3]->soundResourceIdFrame + (int)rnd(2));
else if (_frameIndex == _field_650)
- resourceId = (ResourceId)(getWorld()->actions[_actionIdx3]->soundResourceId + (int)rnd(1));
+ resourceId = (ResourceId)(getWorld()->actions[_actionIdx3]->soundResourceId + (int)rnd(2));
} else {
if (_frameIndex == _field_64C)
- resourceId = (ResourceId)(_walkingSound1 + (int)rnd(1));
+ resourceId = (ResourceId)(_walkingSound1 + (int)rnd(2));
else if (_frameIndex == _field_650)
- resourceId = (ResourceId)(_walkingSound3 + (int)rnd(1));
+ resourceId = (ResourceId)(_walkingSound3 + (int)rnd(2));
}
// Play sound
@@ -2236,7 +2236,7 @@ void Actor::updateStatusEnabled() {
// Actor:: BigCrow
if (!strcmp(_name, "Big Crow")) {
if (_vm->getRandom(10) < 5) {
- switch (_vm->getRandom(3)) {
+ switch (_vm->getRandom(4)) {
default:
break;
@@ -2287,7 +2287,7 @@ void Actor::updateStatusEnabled() {
if (!getSharedData()->getFlag(kFlagActorUpdateEnabledCheck)) {
if (!isInActionArea(pt, area)) {
- Common::Point polyPoint = poly.points[rnd(poly.count() - 1)];
+ Common::Point polyPoint = poly.points[rnd(poly.count())];
processStatus(polyPoint.x, polyPoint.y, false);
} else {
processStatus(pt.x, pt.y, false);
diff --git a/engines/asylum/resources/object.cpp b/engines/asylum/resources/object.cpp
index ad058a6cdf..b1d200218b 100644
--- a/engines/asylum/resources/object.cpp
+++ b/engines/asylum/resources/object.cpp
@@ -533,7 +533,7 @@ ResourceId Object::getRandomResourceId() {
if (count == 0)
error("[Object::getRandomId] Could not get a random resource id!");
- ResourceId id = shuffle[_vm->getRandom(count - 1)];
+ ResourceId id = shuffle[_vm->getRandom(count)];
if (id == kResourceNone)
error("[Object::getRandomId] Got an empty resource id!");
diff --git a/engines/asylum/resources/special.cpp b/engines/asylum/resources/special.cpp
index ce13bccac1..d11d53260c 100644
--- a/engines/asylum/resources/special.cpp
+++ b/engines/asylum/resources/special.cpp
@@ -163,7 +163,7 @@ void Special::chapter1(Object *object, ActorIndex actorIndex) {
case kObjectHeadBanger:
if (object->getFrameIndex() == 2)
- object->getFrameSoundItem(0)->resourceId = getWorld()->graphicResourceIds[rnd(2) ? 37 : 38];
+ object->getFrameSoundItem(0)->resourceId = getWorld()->graphicResourceIds[rnd(254) ? 38 : 37];
break;
case kObjectAngelFlares:
diff --git a/engines/asylum/resources/worldstats.cpp b/engines/asylum/resources/worldstats.cpp
index f3babf6f63..a3934be0b2 100644
--- a/engines/asylum/resources/worldstats.cpp
+++ b/engines/asylum/resources/worldstats.cpp
@@ -486,7 +486,7 @@ int32 WorldStats::getRandomActionAreaIndexById(int32 id) {
if (!count)
return -1;
- return indexes[_vm->getRandom(count - 1)];
+ return indexes[_vm->getRandom(count)];
}
ActionArea* WorldStats::getActionAreaById(int32 id) {
Commit: 7654475f3ddf038177f1857ad6985cdd6ddbdd3d
https://github.com/scummvm/scummvm/commit/7654475f3ddf038177f1857ad6985cdd6ddbdd3d
Author: alxpnv (alxpnv22 at yahoo.com)
Date: 2021-05-17T15:37:49+02:00
Commit Message:
ASYLUM: finish implementation of Object::playSounds()
Changed paths:
engines/asylum/resources/object.cpp
diff --git a/engines/asylum/resources/object.cpp b/engines/asylum/resources/object.cpp
index b1d200218b..636cba2947 100644
--- a/engines/asylum/resources/object.cpp
+++ b/engines/asylum/resources/object.cpp
@@ -469,6 +469,33 @@ void Object::playSounds() {
}
}
+ for (int i = 0; i < ARRAYSIZE(_frameSoundItems); i++) {
+ FrameSoundItem *item = &_frameSoundItems[i];
+
+ if (item->frameIndex == _frameIndex) {
+ if (item->resourceId) {
+ if (_soundItems[item->index].resourceId && !_soundItems[item->index].field_4) {
+ getSound()->stop(_soundItems[item->index].resourceId);
+ _soundItems[item->index].resourceId = kResourceNone;
+ }
+
+ _soundItems[item->index].resourceId = item->resourceId;
+ _soundItems[item->index].field_4 = item->field_10;
+ _soundItems[item->index].field_8 = item->field_C;
+ _soundItems[item->index].field_C = item->field_14;
+
+ if (!getSound()->isPlaying(item->resourceId)) {
+ int32 volume = Config.sfxVolume + getSound()->calculateVolumeAdjustement(point, item->field_C, item->field_14);
+
+ if (volume > -5000)
+ getSound()->playSound(item->resourceId, item->field_10, volume, getSound()->calculatePanningAtPoint(point));
+ }
+ }
+ } else if (item->frameIndex > _frameIndex || !item->resourceId) {
+ break;
+ }
+ }
+
setVolume();
}
Commit: b96cc26bd01688b9bb46c113f26391550d9b08ad
https://github.com/scummvm/scummvm/commit/b96cc26bd01688b9bb46c113f26391550d9b08ad
Author: alxpnv (alxpnv22 at yahoo.com)
Date: 2021-05-17T15:37:49+02:00
Commit Message:
ASYLUM: add Special::chance()
Changed paths:
engines/asylum/resources/special.cpp
engines/asylum/resources/special.h
diff --git a/engines/asylum/resources/special.cpp b/engines/asylum/resources/special.cpp
index d11d53260c..f06be3c619 100644
--- a/engines/asylum/resources/special.cpp
+++ b/engines/asylum/resources/special.cpp
@@ -1267,22 +1267,22 @@ void Special::playSoundChapter1(Object *object, ActorIndex actorIndex) {
break;
case kObjectRocker:
- if (_vm->getRandomBit())
+ if (chance())
playSoundPanning(MAKE_RESOURCE(kResourcePackSharedSound, 1847), 14, object);
break;
case kObjectGuyWobbles:
- if (_vm->getRandomBit())
+ if (chance())
playSoundPanning(MAKE_RESOURCE(kResourcePackSharedSound, 1887), 14, object);
break;
case kObjectPreAlphaNut:
- if (_vm->getRandomBit())
+ if (chance())
playSoundPanning(MAKE_RESOURCE(kResourcePackSharedSound, 1889 + rnd(3)), 14, object);
break;
case kObjectPreAlphaNut2:
- if (_vm->getRandomBit())
+ if (chance())
playSoundPanning(MAKE_RESOURCE(kResourcePackSharedSound, 1924 + rnd(3)), 14, object);
break;
}
@@ -1302,7 +1302,7 @@ void Special::playSoundChapter2(Object *object, ActorIndex actorIndex) {
case kObjectJessieStatusQuo:
case kObjectTicaTac01:
- if (_vm->getRandomBit()) {
+ if (chance()) {
if (!getSound()->isPlaying(MAKE_RESOURCE(kResourcePackSharedSound, 1848))
&& !getSound()->isPlaying(MAKE_RESOURCE(kResourcePackSharedSound, 1849))
&& !getSound()->isPlaying(MAKE_RESOURCE(kResourcePackSharedSound, 1850))
@@ -1319,35 +1319,35 @@ void Special::playSoundChapter2(Object *object, ActorIndex actorIndex) {
case kObjectDennisStatusQuo:
case kObjectDennisStatus2:
- if (_vm->getRandomBit())
+ if (chance())
playSoundPanning(MAKE_RESOURCE(kResourcePackSharedSound, 1856), 16, object);
break;
case kObjectSuckerSittingStatusQuo:
- if (_vm->getRandomBit())
+ if (chance())
playSoundPanning(MAKE_RESOURCE(kResourcePackSharedSound, 1859), 15, object);
break;
case kObjectSailorBoy:
case kObjectSailorStatusQuo:
- if (_vm->getRandomBit())
+ if (chance())
playSoundPanning(MAKE_RESOURCE(kResourcePackSharedSound, 1858), 19, object);
break;
case kObjectFishingBoy:
- if (_vm->getRandomBit())
+ if (chance())
playSoundPanning(MAKE_RESOURCE(kResourcePackSharedSound, 1860), 19, object);
break;
case kObjectMarty02:
- if (_vm->getRandomBit())
+ if (chance())
playSoundPanning(MAKE_RESOURCE(kResourcePackSharedSound, 1854), 15, object);
break;
case kObjectEleenOnGround:
case kObjectEileenOnBench:
case kObject994:
- if (_vm->getRandomBit())
+ if (chance())
playSoundPanning(MAKE_RESOURCE(kResourcePackSharedSound, 1857), 28, object);
break;
}
@@ -1357,12 +1357,12 @@ void Special::playSoundChapter2(Object *object, ActorIndex actorIndex) {
break;
case 1:
- if (_vm->getRandomBit())
+ if (chance())
playSoundPanning(MAKE_RESOURCE(kResourcePackSharedSound, 1855), 18, actorIndex);
break;
case 5:
- if (_vm->getRandomBit())
+ if (chance())
playSoundPanning(MAKE_RESOURCE(kResourcePackSharedSound, 1859), 15, actorIndex);
break;
}
@@ -1377,35 +1377,35 @@ void Special::playSoundChapter3(Object *object, ActorIndex actorIndex) {
case kObjectNPC024Church:
case kObjectNPC024Fountain:
- if (_vm->getRandomBit())
+ if (chance())
playSoundPanning(MAKE_RESOURCE(kResourcePackSharedSound, 1895), 17, object);
break;
case kObjectPreacherBob:
- if (_vm->getRandomBit())
- playSoundPanning(MAKE_RESOURCE(kResourcePackSharedSound, 1896 + _vm->getRandomBit()), 14, object);
+ if (chance())
+ playSoundPanning(MAKE_RESOURCE(kResourcePackSharedSound, 1896 + rnd(2)), 14, object);
break;
case kObjectPreacherBobAssistant:
case kObjectNPC026OutOfWay:
- if (_vm->getRandomBit())
+ if (chance())
playSoundPanning(MAKE_RESOURCE(kResourcePackSharedSound, 1898), 18, object);
break;
case kObjectNPC027Sit:
case kObjectNPC027Dancing:
- if (_vm->getRandomBit())
+ if (chance())
playSoundPanning(MAKE_RESOURCE(kResourcePackSharedSound, 1899), 15, object);
break;
case kObjectNPC028Sit:
case kObjectNPC028Dancing:
- if (_vm->getRandomBit())
+ if (chance())
playSoundPanning(MAKE_RESOURCE(kResourcePackSharedSound, 1900), 15, object);
break;
case kObjectNPC029Sit:
- if (_vm->getRandomBit())
+ if (chance())
playSoundPanning(MAKE_RESOURCE(kResourcePackSharedSound, 1901), 8, object);
break;
}
@@ -1431,17 +1431,17 @@ void Special::playSoundChapter3(Object *object, ActorIndex actorIndex) {
break;
case 3:
- if (_vm->getRandomBit())
+ if (chance())
playSoundPanning(MAKE_RESOURCE(kResourcePackSharedSound, 1893), 17, actorIndex);
break;
case 4:
- if (_vm->getRandomBit())
+ if (chance())
playSoundPanning(MAKE_RESOURCE(kResourcePackSharedSound, 1894), 17, actorIndex);
break;
case 5:
- if (_vm->getRandomBit())
+ if (chance())
playSoundPanning(MAKE_RESOURCE(kResourcePackSharedSound, 1902), 15, actorIndex);
break;
}
@@ -1455,23 +1455,23 @@ void Special::playSoundChapter4(Object *object, ActorIndex actorIndex) {
break;
case kObjectNPC032Sleeping:
- if (_vm->getRandomBit())
+ if (chance())
playSoundPanning(MAKE_RESOURCE(kResourcePackSharedSound, 1903), 14, object);
break;
case kObjectNPC032StatusQuoOutside:
case kObjectNPC032StatusQuoBigTop:
- if (_vm->getRandomBit())
+ if (chance())
playSoundPanning(MAKE_RESOURCE(kResourcePackSharedSound, 1904), 14, object);
break;
case kObjectNPC033Reading:
- if (_vm->getRandomBit())
+ if (chance())
playSoundPanning(MAKE_RESOURCE(kResourcePackSharedSound, 1879), 16, object);
break;
case kObjectTattooManStatusQuo:
- if (_vm->getRandomBit())
+ if (chance())
playSoundPanning(MAKE_RESOURCE(kResourcePackSharedSound, 1884), 14, object);
break;
@@ -1482,12 +1482,12 @@ void Special::playSoundChapter4(Object *object, ActorIndex actorIndex) {
break;
case kObjectStrongmanStatusQuo2:
- if (_vm->getRandomBit())
+ if (chance())
playSoundPanning(MAKE_RESOURCE(kResourcePackSharedSound, 1886), 16, object);
break;
case kObjectInfernoStatusQuo:
- if (_vm->getRandomBit())
+ if (chance())
playSoundPanning(MAKE_RESOURCE(kResourcePackSharedSound, 1905), 12, object);
break;
@@ -1496,76 +1496,76 @@ void Special::playSoundChapter4(Object *object, ActorIndex actorIndex) {
break;
case kObjectClownStatusQuo:
- if (_vm->getRandomBit())
+ if (chance())
playSoundPanning(MAKE_RESOURCE(kResourcePackSharedSound, 1907), 10, object);
break;
case kObjectTrixieStatusQuo:
- if (_vm->getRandomBit())
+ if (chance())
playSoundPanning(MAKE_RESOURCE(kResourcePackSharedSound, 1908), 12, object);
break;
case kObjectSimonStatusQuo:
- if (_vm->getRandomBit())
+ if (chance())
playSoundPanning(MAKE_RESOURCE(kResourcePackSharedSound, 1909), 12, object);
break;
case kObjectFunTixStatusQuo:
- if (_vm->getRandomBit())
+ if (chance())
playSoundPanning(MAKE_RESOURCE(kResourcePackSharedSound, 1913), 10, object);
break;
case kObjectFreakTixStatusQuoUp:
case kObjectFreakTixStatusQuoDown:
- if (_vm->getRandomBit())
+ if (chance())
playSoundPanning(MAKE_RESOURCE(kResourcePackSharedSound, 1914), 9, object);
break;
case kObjectFortTellerStatusQuo:
- if (_vm->getRandomBit())
+ if (chance())
playSoundPanning(MAKE_RESOURCE(kResourcePackSharedSound, 1915), 15, object);
break;
case kObjectRingTossStatusQuo:
- if (_vm->getRandomBit())
+ if (chance())
playSoundPanning(MAKE_RESOURCE(kResourcePackSharedSound, 1916), 10, object);
break;
case kObjectPigShootStatusQuo:
- if (_vm->getRandomBit())
+ if (chance())
playSoundPanning(MAKE_RESOURCE(kResourcePackSharedSound, 1917), 10, object);
break;
case kObjectKnockDownStatusQuo:
- if (_vm->isGameFlagNotSet(kGameFlag358) && _vm->getRandomBit())
+ if (_vm->isGameFlagNotSet(kGameFlag358) && chance())
playSoundPanning(MAKE_RESOURCE(kResourcePackSharedSound, 1918), 10, object);
break;
case kObjectPretZoolStatusQuo:
- if (_vm->getRandomBit())
+ if (chance())
playSoundPanning(MAKE_RESOURCE(kResourcePackSharedSound, 1919), 14, object);
break;
case kObjectTimberStatusQuo:
- if (_vm->getRandomBit())
+ if (chance())
playSoundPanning(MAKE_RESOURCE(kResourcePackSharedSound, 1920), 14, object);
break;
case kObjectTwinsStatusQuo:
- if (_vm->getRandomBit())
+ if (chance())
playSoundPanning(MAKE_RESOURCE(kResourcePackSharedSound, 1921), 20, object);
break;
case kObjectSeanStatusQuo:
- if (_vm->getRandomBit())
+ if (chance())
playSoundPanning(MAKE_RESOURCE(kResourcePackSharedSound, 1923), 16, object);
break;
case kObjectMomAndPopStatusQuo:
- if (_vm->getRandomBit())
+ if (chance())
playSoundPanning(MAKE_RESOURCE(kResourcePackSharedSound, 1852), 15, object);
- if (_vm->getRandomBit())
+ if (chance())
playSoundPanning(MAKE_RESOURCE(kResourcePackSharedSound, 1862), 15, object);
break;
}
@@ -1575,17 +1575,17 @@ void Special::playSoundChapter4(Object *object, ActorIndex actorIndex) {
break;
case 1:
- if (_vm->getRandomBit())
+ if (chance())
playSoundPanning(MAKE_RESOURCE(kResourcePackSharedSound, 1910), 14, actorIndex);
break;
case 2:
- if (_vm->getRandomBit())
+ if (chance())
playSoundPanning(MAKE_RESOURCE(kResourcePackSharedSound, 1911), 14, actorIndex);
break;
case 3:
- if (_vm->getRandomBit())
+ if (chance())
playSoundPanning(MAKE_RESOURCE(kResourcePackSharedSound, 1912), 14, actorIndex);
break;
}
@@ -1601,37 +1601,37 @@ void Special::playSoundChapter6(Object *object, ActorIndex actorIndex) {
break;
case kObjectGravinStatusQuoCyber:
- if (_vm->getRandomBit())
+ if (chance())
playSoundPanning(MAKE_RESOURCE(kResourcePackSharedSound, 1880), 14, object);
break;
case kObjectGravinWorkMachine:
- if (_vm->getRandomBit())
+ if (chance())
playSoundPanning(MAKE_RESOURCE(kResourcePackSharedSound, 1880), 14, object);
break;
case kObjectNPC062GritzaStatusQuo:
- if (_vm->getRandomBit())
+ if (chance())
playSoundPanning(MAKE_RESOURCE(kResourcePackSharedSound, 1881), 12, object);
break;
case kObjectNPC063GrundleStatusQuo:
- if (_vm->getRandomBit())
+ if (chance())
playSoundPanning(MAKE_RESOURCE(kResourcePackSharedSound, 1882), 12, object);
break;
case kObjectNPC064GrellaStatusQuo:
- if (_vm->getRandomBit())
+ if (chance())
playSoundPanning(MAKE_RESOURCE(kResourcePackSharedSound, 1883), 12, object);
break;
case kObjectNPC065StatusQuo:
- if (_vm->getRandomBit())
+ if (chance())
playSoundPanning(MAKE_RESOURCE(kResourcePackSharedSound, 1868), 12, object);
break;
case kObjectNPC066StatusQuo:
- if (_vm->getRandomBit())
+ if (chance())
playSoundPanning(MAKE_RESOURCE(kResourcePackSharedSound, 1867), 12, object);
break;
}
@@ -1665,27 +1665,27 @@ void Special::playSoundChapter8(Object *object, ActorIndex actorIndex) {
break;
case kObject703:
- if (_vm->getRandomBit())
+ if (chance())
playSoundPanning(MAKE_RESOURCE(kResourcePackSharedSound, 1874), 10, object);
break;
case kObjectTree8:
- if (_vm->getRandomBit())
+ if (chance())
playSoundPanning(MAKE_RESOURCE(kResourcePackSharedSound, 1875), 10, object);
break;
case kObjectSlab:
- if (_vm->getRandomBit())
+ if (chance())
playSoundPanning(MAKE_RESOURCE(kResourcePackSharedSound, 1922), 10, object);
break;
case kObjectWitchDoctor:
- if (_vm->getRandomBit())
+ if (chance())
playSoundPanning(MAKE_RESOURCE(kResourcePackSharedSound, 1863), 16, object);
break;
case kObjectStoneWifeStatuQuo:
- if (_vm->getRandomBit())
+ if (chance())
playSoundPanning(MAKE_RESOURCE(kResourcePackSharedSound, 1872), 15, object);
break;
@@ -1700,7 +1700,7 @@ void Special::playSoundChapter8(Object *object, ActorIndex actorIndex) {
break;
case kObjectGirlStatusQuo:
- if (_vm->getRandomBit())
+ if (chance())
playSoundPanning(MAKE_RESOURCE(kResourcePackSharedSound, 1871), 15, object);
break;
@@ -1714,17 +1714,17 @@ void Special::playSoundChapter8(Object *object, ActorIndex actorIndex) {
break;
case kObjectBlanklPixelForWarrior:
- if (_vm->getRandomBit())
+ if (chance())
playSoundPanning(MAKE_RESOURCE(kResourcePackSharedSound, 1876), 10, object);
break;
case kObjectPixelForHutWarrior:
- if (_vm->getRandomBit())
+ if (chance())
playSoundPanning(MAKE_RESOURCE(kResourcePackSharedSound, 1878), 10, object);
break;
case kObjectPixelForWaterfallGhost:
- if (_vm->getRandomBit())
+ if (chance())
playSoundPanning(MAKE_RESOURCE(kResourcePackSharedSound, 1877), 10, object);
break;
}
diff --git a/engines/asylum/resources/special.h b/engines/asylum/resources/special.h
index 41f8208cb9..a1a758cbb3 100644
--- a/engines/asylum/resources/special.h
+++ b/engines/asylum/resources/special.h
@@ -24,13 +24,13 @@
#define ASYLUM_SPECIAL_H
#include "asylum/shared.h"
+#include "asylum/asylum.h"
#include "common/scummsys.h"
#include "common/rect.h"
namespace Asylum {
-class AsylumEngine;
class Object;
class Special {
@@ -97,6 +97,7 @@ private:
//////////////////////////////////////////////////////////////////////////
ResourceId getResourceId(Object *object, ActorIndex actorIndex);
uint32 getCounter(ActorIndex index) const;
+ bool chance() { return _vm->getRandom(10000) < 30; }
void checkObject(Object *object, GameFlag flagToSet, GameFlag flagToClear, ObjectId objectId = kObjectNone);
void checkOtherObject(Object *object, ObjectId otherObjectId, GameFlag flagToClear, GameFlag flagToSet);
Commit: e6f2916eea7541b59cfb96548c2e4f9447ea15f9
https://github.com/scummvm/scummvm/commit/e6f2916eea7541b59cfb96548c2e4f9447ea15f9
Author: alxpnv (alxpnv22 at yahoo.com)
Date: 2021-05-17T15:37:49+02:00
Commit Message:
ASYLUM: access chapter 2 data using a single array
Changed paths:
engines/asylum/resources/actor.cpp
engines/asylum/resources/actor.h
engines/asylum/resources/data.cpp
engines/asylum/resources/data.h
engines/asylum/resources/special.cpp
diff --git a/engines/asylum/resources/actor.cpp b/engines/asylum/resources/actor.cpp
index a98e9505b5..faebf7696c 100644
--- a/engines/asylum/resources/actor.cpp
+++ b/engines/asylum/resources/actor.cpp
@@ -359,9 +359,9 @@ void Actor::update() {
break;
case kActorStatusGettingHurt:
- if (getWorld()->chapter == 2) {
+ if (getWorld()->chapter == kChapter2) {
updateStatus16_Chapter2();
- } else if (getWorld()->chapter == 11 && _index == getSharedData()->getPlayerIndex()) {
+ } else if (getWorld()->chapter == kChapter11 && _index == getSharedData()->getPlayerIndex()) {
updateStatus16_Chapter11();
}
break;
@@ -2372,10 +2372,10 @@ void Actor::updateStatus12_Chapter2() {
// Face actor
faceTarget((uint32)getSharedData()->getPlayerIndex(), kDirectionFromActor);
- int32 data = getSharedData()->getChapter2Data(3, _index + 1);
+ int32 data = getSharedData()->crowsData[_index + 25];
if (data > 0) {
- _direction = (ActorDirection)(_direction + 4);
- getSharedData()->setChapter2Data(3, _index + 1, data - 1);
+ _direction = DIR(_direction + 4);
+ getSharedData()->crowsData[_index + 25] = data - 1;
}
// Compute coordinates and distance
@@ -2398,8 +2398,8 @@ void Actor::updateStatus12_Chapter2() {
} else {
_frameIndex = 0;
- getSharedData()->setChapter2Data(3, 2 * _index + 6, player->getPoint1()->x - _point1.x);
- getSharedData()->setChapter2Data(3, 2 * _index + 7, player->getPoint1()->y - _point1.y);
+ getSharedData()->crowsData[2 * _index + 30] = player->getPoint1()->x - _point1.x;
+ getSharedData()->crowsData[2 * _index + 31] = player->getPoint1()->y - _point1.y;
updateStatus(kActorStatus18);
}
@@ -2421,7 +2421,7 @@ void Actor::updateStatus12_Chapter2_Actor11() {
// Update status
if (player->getStatus() == kActorStatusRestarting || !getScene()->getActor(10)->isVisible()) {
updateStatus(kActorStatusEnabled);
- getSharedData()->setChapter2Data(1, 3, 160); // &cursorResources + 8 + 11 (actorIndex)
+ getSharedData()->crowsData[_index - 11] = 160;
}
// Face player
@@ -2519,7 +2519,7 @@ void Actor::updateStatus14() {
if (_index == 11)
updateStatus(kActorStatusWalking2);
else if (_index > 12)
- updateStatus14_Chapter2();
+ updateStatus14_Chapter2_Helper();
break;
case kChapter11:
@@ -2529,6 +2529,13 @@ void Actor::updateStatus14() {
}
}
+void Actor::updateStatus14_Chapter2_Helper() {
+ if (getSharedData()->crowsData[_index + 61])
+ updateStatus14_Chapter2();
+ else
+ updateStatus(kActorStatusWalking2);
+}
+
void Actor::updateStatus14_Chapter2() {
// Original calls getDistanceForFrame but does not seem to do anything with the results
@@ -2537,39 +2544,39 @@ void Actor::updateStatus14_Chapter2() {
if (playerStatus == kActorStatusRestarting || !getScene()->getActor(10)->isVisible()) {
updateStatus(kActorStatusEnabled);
- getSharedData()->setChapter2Data(1, (_index - 13) + 5, 160); // Index > 12
+ getSharedData()->crowsData[_index - 11] = 160;
}
if (playerStatus != kActorStatusGettingHurt) {
- _point1.x = player->getPoint1()->x - (int16)getSharedData()->getChapter2Data(3, 2 * _index + 6);
- _point1.y = player->getPoint1()->y - (int16)getSharedData()->getChapter2Data(3, 2 * _index + 7) + 54;
+ _point1.x = player->getPoint1()->x - (int16)getSharedData()->crowsData[2 * _index + 30];
+ _point1.y = player->getPoint1()->y - (int16)getSharedData()->crowsData[2 * _index + 31] + 54;
}
if (_frameIndex == _frameCount - 1) {
_frameIndex = 0;
- if (getSharedData()->getChapter2Data(2, _index + 6) <= 1 || playerStatus == kActorStatusGettingHurt || playerStatus == kActorStatusRestarting) {
- getSharedData()->setChapter2Data(2, _index + 6, getSharedData()->getChapter2Data(2, _index + 6) + 1);
+ if (getSharedData()->crowsData[_index + 29] <= 1 || playerStatus == kActorStatusGettingHurt || playerStatus == kActorStatusRestarting) {
+ getSharedData()->crowsData[_index + 29]++;
} else {
updateStatus(kActorStatusAttacking);
_point1.y -= 54;
- getSharedData()->setChapter2Data(2, _index + 6, 0);
- getSharedData()->setChapter2Data(1, _index + 1, getSharedData()->getChapter2Data(1, _index + 1) + 54);
+ getSharedData()->crowsData[_index + 29] = 0;
+ getSharedData()->crowsData[_index - 2] += 54;
}
}
- if (playerStatus == kActorStatusRestarting && getSharedData()->getChapter2Data(2, _index + 6) < 100) {
+ if (playerStatus == kActorStatusRestarting && getSharedData()->crowsData[_index + 17] < 100) {
_point1.y -= 6;
- getSharedData()->setChapter2Data(2, _index + 6, 100);
- getSharedData()->setChapter2Data(1, _index + 1, getSharedData()->getChapter2Data(1, _index + 1) + 6);
+ getSharedData()->crowsData[_index + 29] = 100;
+ getSharedData()->crowsData[_index - 2] += 6;
}
- if (getSharedData()->getChapter2Data(2, _index + 6) > 99) {
+ if (getSharedData()->crowsData[_index + 17] > 99) {
_point1.y -= 6;
- getSharedData()->setChapter2Data(2, _index + 6, getSharedData()->getChapter2Data(2, _index + 6) + 1);
- getSharedData()->setChapter2Data(1, _index + 1, getSharedData()->getChapter2Data(1, _index + 1) + 6);
+ getSharedData()->crowsData[_index + 17]++;
+ getSharedData()->crowsData[_index - 2] += 6;
- if (getSharedData()->getChapter2Data(2, _index + 6) > 108) {
- getSharedData()->setChapter2Data(2, _index + 6, 0);
+ if (getSharedData()->crowsData[_index + 17] > 108) {
+ getSharedData()->crowsData[_index + 29] = 0;
updateStatus(kActorStatusEnabled);
@@ -2649,7 +2656,7 @@ void Actor::updateStatus15_Chapter2() {
if (getScene()->getActor(10)->getStatus() == kActorStatusRestarting || !getScene()->getActor(10)->isVisible()) {
updateStatus(kActorStatusEnabled);
- getSharedData()->setChapter2Data(1, (_index - 13) + 5, 160); // Index > 12
+ getSharedData()->crowsData[_index - 11] = 160;
}
if (_frameIndex == 1)
@@ -2665,7 +2672,7 @@ void Actor::updateStatus15_Chapter2() {
getScene()->getActor(_index + 9)->setDirection(_direction);
}
- if (_frameIndex < 5 || !getSharedData()->getChapter2Data(4, _index + 7))
+ if (_frameIndex < 5 || !getSharedData()->crowsData[_index + 61])
_frameIndex++;
if (sumPlayer.x > sum.x)
@@ -2686,10 +2693,10 @@ void Actor::updateStatus15_Chapter2() {
getSpeech()->playPlayer(51);
_vm->setGameFlag(kGameFlag219);
- player->updateFromDirection((ActorDirection)((_direction + 4) & 7));
+ player->updateFromDirection(DIR(_direction + 4));
player->updateStatus(kActorStatusGettingHurt);
- getSharedData()->setChapter2Data(4, _index + 7, 0);
+ getSharedData()->crowsData[_index + 61] = 0;
}
}
@@ -2720,7 +2727,7 @@ void Actor::updateStatus15_Chapter2() {
else
updateStatus(kActorStatusEnabled);
- getSharedData()->setChapter2Data(4, _index + 7, 0);
+ getSharedData()->crowsData[_index + 61] = 0;
}
}
@@ -3188,19 +3195,19 @@ void Actor::updateStatus17_Chapter2() {
void Actor::updateStatus18_Chapter2() {
Actor *player = getScene()->getActor();
- _point1.x = player->getPoint1()->x - (int16)getSharedData()->getChapter2Data(3, 2 * _index + 6);
- _point1.y = player->getPoint1()->y - (int16)getSharedData()->getChapter2Data(3, 2 * _index + 7);
+ _point1.x = player->getPoint1()->x - (int16)getSharedData()->crowsData[2 * _index + 30];
+ _point1.y = player->getPoint1()->y - (int16)getSharedData()->crowsData[2 * _index + 31];
_frameIndex++;
if (_frameIndex > _frameCount - 1) {
- getSharedData()->setChapter2Data(4, _index + 7, true);
+ getSharedData()->crowsData[_index + 61] = 1;
updateStatus(kActorStatusEnabled2);
_point1.y += 54;
getSound()->playSound(getWorld()->soundResourceIds[1], false, Config.sfxVolume - 10);
- getSharedData()->setChapter2Data(1, _index + 1, getSharedData()->getChapter2Data(1, _index + 1) - 54);
+ getSharedData()->crowsData[_index - 2] -= 54;
}
}
diff --git a/engines/asylum/resources/actor.h b/engines/asylum/resources/actor.h
index e5dab90ece..1e1ce8429c 100644
--- a/engines/asylum/resources/actor.h
+++ b/engines/asylum/resources/actor.h
@@ -444,6 +444,7 @@ private:
void updateStatus14();
void updateStatus14_Chapter2();
+ void updateStatus14_Chapter2_Helper();
void updateStatus14_Chapter11();
void updateStatus15_Chapter2();
diff --git a/engines/asylum/resources/data.cpp b/engines/asylum/resources/data.cpp
index 723b45adc5..6019218e30 100644
--- a/engines/asylum/resources/data.cpp
+++ b/engines/asylum/resources/data.cpp
@@ -26,7 +26,7 @@
namespace Asylum {
-SharedData::SharedData() {
+SharedData::SharedData() : crowsData(this) {
// Public data
cdNumber = 0;
movieIndex = 0;
@@ -34,7 +34,6 @@ SharedData::SharedData() {
actorEnableForStatus7 = false;
globalDirection = kDirectionN;
-
memset(&_ambientFlags, 0, sizeof(_ambientFlags));
memset(&_ambientTicks, 0, sizeof(_ambientTicks));
_globalPoint.x = -1;
@@ -118,44 +117,27 @@ void SharedData::loadSmallCursor(int32 *smallCurUp, int32 *smallCurDown) const {
// Chapter 2 data
//////////////////////////////////////////////////////////////////////////
void SharedData::resetChapter2Data() {
- for (uint32 i = 5; i < 14; i++)
- _chapter2Data3[i] = 0;
-
- for (uint32 i = 0; i < ARRAYSIZE(_chapter2Data2); i++)
- _chapter2Data2[i] = 160;
-
- for (uint32 i = 0; i < ARRAYSIZE(_chapter2Data5); i++)
- _chapter2Data5[i] = 0;
+ for (int i = 0; i < 9; i++) {
+ crowsData[i + 11] = 160;
+ crowsData[i + 39] = 0;
+ crowsData[i + 73] = 0;
+ }
}
void SharedData::reset() {
- for (uint32 i = 0; i < ARRAYSIZE(_chapter2Data2); i++)
- _chapter2Data2[i] = 160;
+ for (int i = 0; i < 9; i++)
+ crowsData[i + 11] = 160;
_chapter2FrameIndexOffset = 1;
}
static const uint32 chapter2DataSizes[5] = {5, 9, 23, 18, 9};
-void SharedData::setChapter2Data(uint32 index, int32 offset, int32 val) {
- uint32 *chapter2Data[] = {_chapter2Data1, _chapter2Data2, (uint32 *)_chapter2Data3, _chapter2Data4, _chapter2Data5};
-
- if (index == 0 || index > 5)
- error("[SharedData::setChapter2Data] Invalid index (was: %d, valid: [1;5])", index);
- if (offset >= chapter2DataSizes[index - 1])
- error("[SharedData::setChapter2Data] Invalid offset (was: %d, valid: [0;%d])", offset, chapter2DataSizes[index - 1] - 1);
-
- chapter2Data[index - 1][offset] = val;
-}
-
-int32 SharedData::getChapter2Data(uint32 index, int32 offset) {
- const uint32 *chapter2Data[] = {_chapter2Data1, _chapter2Data2, (uint32 *)_chapter2Data3, _chapter2Data4, _chapter2Data5};
-
- if (index == 0 || index > 5)
- error("[SharedData::getChapter2Data] Invalid index (was: %d, valid: [1;5])", index);
- if (offset >= chapter2DataSizes[index - 1])
- error("[SharedData::getChapter2Data] Invalid offset (was: %d, valid: [0;%d])", offset, chapter2DataSizes[index - 1] - 1);
+int32 &CrowsData::operator[](uint32 index) {
+ if (index >= ARRAYSIZE(_data))
+ error("[CrowsData::operator[]] Invalid index (was: %d, valid: [0;%d])", index, ARRAYSIZE(_data) - 1);
- return (int32)chapter2Data[index - 1][offset];
+ // TODO use _chapter2Data*[] instead of a dedicated array
+ return _data[index];
}
void SharedData::setChapter2Counter(uint32 index, int32 val) {
diff --git a/engines/asylum/resources/data.h b/engines/asylum/resources/data.h
index eb15fcdb01..779e904623 100644
--- a/engines/asylum/resources/data.h
+++ b/engines/asylum/resources/data.h
@@ -47,6 +47,17 @@ enum GlobalFlag {
kFlagActorUpdateStatus15Check
};
+class SharedData;
+
+class CrowsData {
+public:
+ CrowsData(SharedData *sharedData) : _sharedData(sharedData), _data() {}
+ int32 &operator [](uint32 index);
+private:
+ int32 _data[84];
+ SharedData *_sharedData;
+};
+
/**
* Shared data
* -----------
@@ -130,6 +141,7 @@ public:
Common::Point vector2;
bool actorEnableForStatus7;
ActorDirection globalDirection;
+ CrowsData crowsData;
// Used by Actor::enableActorsChapter2 (and maybe others)
void resetChapter2Data();
@@ -199,8 +211,6 @@ public:
void setMattePlaySound(bool val) { _mattePlaySound = val; }
// Chapter 2 data
- void setChapter2Data(uint32 index, int32 offset, int32 val);
- int32 getChapter2Data(uint32 index, int32 offset);
void setChapter2Counter(uint32 index, int32 val);
int32 getChapter2Counter(uint32 index) const;
int32 getChapter2FrameIndexOffset() const { return _chapter2FrameIndexOffset; }
@@ -263,6 +273,8 @@ private:
int16 _matteBarHeight;
uint32 _matteVar2;
+
+ friend class CrowsData;
};
} // End of namespace Asylum
diff --git a/engines/asylum/resources/special.cpp b/engines/asylum/resources/special.cpp
index f06be3c619..f0c0d6553f 100644
--- a/engines/asylum/resources/special.cpp
+++ b/engines/asylum/resources/special.cpp
@@ -269,10 +269,10 @@ void Special::chapter2(Object *object, ActorIndex actorIndex) {
if (counter >= 5) {
counter = 0;
- actor->updateFromDirection((ActorDirection)((actor->getDirection() + 1) % ~7)); // TODO check
+ actor->updateFromDirection((ActorDirection)((actor->getDirection() + 1) & 7));
}
- getSharedData()->setChapter2Counter(4, counter);
+ getSharedData()->setChapter2Counter(getCounter(actorIndex), counter);
} else if (actor->getStatus() == kActorStatusEnabled) {
actor->updateStatus(kActorStatusWalking);
@@ -292,7 +292,7 @@ void Special::chapter2(Object *object, ActorIndex actorIndex) {
Actor *refActor = getScene()->getActor(actorIndex - 9); // Original uses offset to object array (+ offset to actor).
*actor->getPoint1() = *refActor->getPoint1();
- actor->getPoint1()->y += (int16)getSharedData()->getChapter2Data(2, actorIndex - 22); // cursorResources + 30
+ actor->getPoint1()->y += (int16)getSharedData()->crowsData[actorIndex - 11];
actor->setFrameIndex(refActor->getFrameIndex());
actor->setDirection(refActor->getDirection());
Commit: e11f8232cbd1b283230768017cecbce1fb5450ba
https://github.com/scummvm/scummvm/commit/e11f8232cbd1b283230768017cecbce1fb5450ba
Author: alxpnv (alxpnv22 at yahoo.com)
Date: 2021-05-17T15:37:50+02:00
Commit Message:
ASYLUM: fix a few bugs in reflection positioning
Changed paths:
engines/asylum/resources/actor.cpp
diff --git a/engines/asylum/resources/actor.cpp b/engines/asylum/resources/actor.cpp
index faebf7696c..8f0a2b33c3 100644
--- a/engines/asylum/resources/actor.cpp
+++ b/engines/asylum/resources/actor.cpp
@@ -816,7 +816,7 @@ void Actor::updateStatus(ActorStatus actorStatus) {
//////////////////////////////////////////////////////////////////////////
void Actor::updateDirection() {
- if(!_processNewDirection)
+ if (!_processNewDirection)
return;
Common::Point sum = _point1 + _point2;
@@ -837,7 +837,7 @@ void Actor::updateDirection() {
position.y = _nextPosition.y + sum.y;
position.y += (int16)((_nextDirection == kDirectionN ? -1 : 1) * 2 * abs(sum.y - _nextPositionOffset.y));
- switch (direction) {
+ switch (_direction) {
default:
break;
@@ -873,7 +873,7 @@ void Actor::updateDirection() {
position.x += (int16)((_nextDirection == kDirectionW ? -1 : 1) * 2 * abs(sum.x - _nextPositionOffset.x));
position.y = _nextPosition.y + sum.y;
- switch (direction) {
+ switch (_direction) {
default:
break;
@@ -905,12 +905,12 @@ void Actor::updateDirection() {
case kDirectionNW:
case kDirectionSE:
- position.x = _nextPosition.x + sum.x;
- position.y = _nextPosition.y + sum.y;
- position.x += (int16)((_nextDirection == kDirectionNW ? -1 : 1) * 2 * abs(sum.y - _nextPositionOffset.y));
- position.y += (int16)((_nextDirection == kDirectionNW ? -1 : 1) * 2 * abs(sum.x - _nextPositionOffset.x));
+ position.x = _nextPosition.x + _nextPositionOffset.x;
+ position.y = _nextPosition.y + _nextPositionOffset.y;
+ position.x += (int16)((_nextDirection == kDirectionNW ? -1 : 1) * abs(sum.y - _nextPositionOffset.y));
+ position.y += (int16)((_nextDirection == kDirectionNW ? -1 : 1) * abs(sum.x - _nextPositionOffset.x));
- switch (direction) {
+ switch (_direction) {
default:
break;
@@ -951,16 +951,16 @@ void Actor::updateDirection() {
case kDirectionSW:
case kDirectionNE:
if (_nextDirection == kDirectionSW) {
- position.x = (int16)(_nextPosition.x + sum.x - 2 * abs(sum.y - _nextPositionOffset.y));
- position.y = (int16)(_nextPosition.y + sum.y + 2 * abs(sum.x - _nextPositionOffset.x));
+ position.x = (int16)(_nextPosition.x + _nextPositionOffset.x - abs(sum.y - _nextPositionOffset.y));
+ position.y = (int16)(_nextPosition.y + _nextPositionOffset.y + abs(sum.x - _nextPositionOffset.x));
} else {
double deltaX = sum.x * -0.56666666;
- double deltaY = ((419 - sum.y) + deltaX) * 0.87613291;
+ double deltaY = (419 - (sum.y + deltaX)) * 0.87613291;
position.x = (int16)(sum.x + 2 * (_nextPositionOffset.x - deltaY));
- position.y = (int16)(sum.y + 2 * (_nextPosition.x - (sum.y + deltaX + (deltaY * -0.56666666))));
+ position.y = (int16)(sum.y + 2 * (_nextPositionOffset.y - (sum.y + deltaX + (deltaY * 0.56666666))));
}
- switch (direction) {
+ switch (_direction) {
default:
break;
Commit: 8d1c397c4828b80b576a0f07e41af258e76fe83d
https://github.com/scummvm/scummvm/commit/8d1c397c4828b80b576a0f07e41af258e76fe83d
Author: alxpnv (alxpnv22 at yahoo.com)
Date: 2021-05-17T15:37:50+02:00
Commit Message:
ASYLUM: fix object 30's frameIndex ouf of range
Changed paths:
engines/asylum/resources/actor.cpp
diff --git a/engines/asylum/resources/actor.cpp b/engines/asylum/resources/actor.cpp
index 8f0a2b33c3..61943d7010 100644
--- a/engines/asylum/resources/actor.cpp
+++ b/engines/asylum/resources/actor.cpp
@@ -1052,6 +1052,7 @@ void Actor::updateFromDirection(ActorDirection actorDirection) {
case kActorStatusWalkingTo:
case kActorStatusWalking2:
_resourceId = _graphicResourceIds[(actorDirection > kDirectionS ? kDirection8 - actorDirection : actorDirection)];
+ _frameCount = GraphicResource::getFrameCount(_vm, _resourceId);
break;
case kActorStatus8:
Commit: efcae3951864f12bc785a7aa19919c7f576c1f25
https://github.com/scummvm/scummvm/commit/efcae3951864f12bc785a7aa19919c7f576c1f25
Author: alxpnv (alxpnv22 at yahoo.com)
Date: 2021-05-17T15:37:50+02:00
Commit Message:
ASYLUM: fixes to Actor::canInteract()
Changed paths:
engines/asylum/resources/actor.cpp
engines/asylum/resources/script.cpp
diff --git a/engines/asylum/resources/actor.cpp b/engines/asylum/resources/actor.cpp
index 61943d7010..8ef94b4c55 100644
--- a/engines/asylum/resources/actor.cpp
+++ b/engines/asylum/resources/actor.cpp
@@ -1587,8 +1587,8 @@ bool Actor::canInteract(Common::Point *point, int32* param) {
if (getWorld()->chapter != kChapter2 || _index != 8)
offset = 40;
- int32 parameter = 5;
- Common::Point pt = _point1 + _point2;
+ int32 parameter;
+ Common::Point actorPoint = _point1 + _point2, pt = actorPoint;
if (getWorld()->chapter != kChapter2 || _index != 1) {
Common::Point diff = *player->getPoint1() - _point1;
@@ -1603,12 +1603,14 @@ bool Actor::canInteract(Common::Point *point, int32* param) {
goto processActor;
parameter = 3;
+ pt = actorPoint;
pt.x -= offset;
pt.y += offset;
if (getScene()->findActionArea(kActionAreaType2, pt) != -1)
goto processActor;
parameter = 1;
+ pt = actorPoint;
pt.x -= offset;
pt.y -= offset;
@@ -1620,12 +1622,14 @@ bool Actor::canInteract(Common::Point *point, int32* param) {
goto processActor;
parameter = 5;
+ pt = actorPoint;
pt.x += offset;
pt.y += offset;
if (getScene()->findActionArea(kActionAreaType2, pt) != -1)
goto processActor;
parameter = 7;
+ pt = actorPoint;
pt.x += offset;
pt.y -= offset;
}
@@ -1640,12 +1644,14 @@ bool Actor::canInteract(Common::Point *point, int32* param) {
goto processActor;
parameter = 3;
+ pt = actorPoint;
pt.x -= offset;
pt.y += offset;
if (getScene()->findActionArea(kActionAreaType2, pt) != -1)
goto processActor;
parameter = 5;
+ pt = actorPoint;
pt.x += offset;
pt.y += offset;
@@ -1657,12 +1663,14 @@ bool Actor::canInteract(Common::Point *point, int32* param) {
goto processActor;
parameter = 1;
+ pt = actorPoint;
pt.x -= offset;
pt.y -= offset;
if (getScene()->findActionArea(kActionAreaType2, pt) != -1)
goto processActor;
parameter = 7;
+ pt = actorPoint;
pt.x += offset;
pt.y -= offset;
}
@@ -1677,7 +1685,7 @@ bool Actor::canInteract(Common::Point *point, int32* param) {
return false;
processActor:
- if (!process(pt))
+ if (!player->process(pt))
return false;
*point = pt;
diff --git a/engines/asylum/resources/script.cpp b/engines/asylum/resources/script.cpp
index ae3660840f..ea4c092ad3 100644
--- a/engines/asylum/resources/script.cpp
+++ b/engines/asylum/resources/script.cpp
@@ -1719,7 +1719,7 @@ END_OPCODE
//////////////////////////////////////////////////////////////////////////
// Opcode 0x56
IMPLEMENT_OPCODE(Interact)
- Actor *actor = getScene()->getActor(cmd->param2 == 2 ? kActorInvalid : cmd->param1);
+ Actor *actor = getScene()->getActor(cmd->param2 == 2 ? getSharedData()->getPlayerIndex() : cmd->param1);
if (actor->getStatus() == kActorStatusWalkingTo || actor->getStatus() == kActorStatusWalkingTo2) {
if (cmd->param2 == 2)
@@ -1741,7 +1741,7 @@ IMPLEMENT_OPCODE(Interact)
} else {
Common::Point point;
- if (actor->canInteract(&point, &cmd->param4) == 1) {
+ if (actor->canInteract(&point, &cmd->param4)) {
getScene()->getActor()->processStatus(point.x, point.y, (bool)cmd->param4);
cmd->param6 = point.x;
cmd->param7 = point.y;
Commit: 7ac489e077d377d60dadf9586a439efa86983374
https://github.com/scummvm/scummvm/commit/7ac489e077d377d60dadf9586a439efa86983374
Author: alxpnv (alxpnv22 at yahoo.com)
Date: 2021-05-17T15:37:50+02:00
Commit Message:
ASYLUM: fix music playback in chapter 4
Changed paths:
engines/asylum/views/scene.cpp
diff --git a/engines/asylum/views/scene.cpp b/engines/asylum/views/scene.cpp
index 9546d6a911..caa64d7acc 100644
--- a/engines/asylum/views/scene.cpp
+++ b/engines/asylum/views/scene.cpp
@@ -948,15 +948,18 @@ void Scene::updateMusic() {
break;
case 1:
- getWorld()->musicCurrentResourceIndex = getWorld()->musicResourceIndex;
-
if (getWorld()->musicResourceIndex == kMusicStopped) {
+ getWorld()->musicCurrentResourceIndex = kMusicStopped;
getWorld()->musicStatus = 0;
getSound()->playMusic(kResourceNone, 0);
} else {
+ getWorld()->musicCurrentResourceIndex = getWorld()->musicResourceIndex;
getWorld()->musicStatus = getWorld()->musicStatusExt;
getSound()->playMusic(MAKE_RESOURCE(kResourcePackMusic, getWorld()->musicResourceIndex));
}
+ getWorld()->musicResourceIndex = kMusicStopped;
+ getWorld()->musicStatusExt = 0;
+ getWorld()->musicFlag = 0;
break;
case 2:
@@ -966,7 +969,7 @@ void Scene::updateMusic() {
case 4:
_musicVolume -= 150;
- if (_musicVolume >= -2500) {
+ if (_musicVolume > -2500) {
getSound()->setMusicVolume(_musicVolume);
break;
}
@@ -977,6 +980,9 @@ void Scene::updateMusic() {
if (getWorld()->musicResourceIndex == kMusicStopped) {
getWorld()->musicStatus = 0;
getSound()->playMusic(kResourceNone, 0);
+ getWorld()->musicResourceIndex = kMusicStopped;
+ getWorld()->musicStatusExt = 0;
+ getWorld()->musicFlag = 0;
} else {
getWorld()->musicStatus = 8;
getSound()->playMusic(kResourceNone, 0);
@@ -988,18 +994,19 @@ void Scene::updateMusic() {
case 8:
_musicVolume += 150;
- if (_musicVolume < 150) {
+ if (_musicVolume < Config.musicVolume) {
getSound()->setMusicVolume(_musicVolume);
break;
}
getSound()->setMusicVolume(Config.musicVolume);
getWorld()->musicStatus = getWorld()->musicStatusExt;
- getWorld()->musicResourceIndex = (int32)kMusicStopped;
+ getWorld()->musicResourceIndex = kMusicStopped;
getWorld()->musicStatusExt = 0;
+ getWorld()->musicFlag = 0;
break;
}
- } if (getWorld()->musicResourceIndex != kMusicStopped) {
+ } else if (getWorld()->musicResourceIndex != kMusicStopped) {
switch (getWorld()->musicStatusExt) {
default:
break;
Commit: 9d14df26028194ba9bf180d48a1831c185e37b38
https://github.com/scummvm/scummvm/commit/9d14df26028194ba9bf180d48a1831c185e37b38
Author: alxpnv (alxpnv22 at yahoo.com)
Date: 2021-05-17T15:37:50+02:00
Commit Message:
ASYLUM: fix dstPitch
Changed paths:
engines/asylum/system/screen.cpp
diff --git a/engines/asylum/system/screen.cpp b/engines/asylum/system/screen.cpp
index e08632c076..ccf3655a5b 100644
--- a/engines/asylum/system/screen.cpp
+++ b/engines/asylum/system/screen.cpp
@@ -768,7 +768,7 @@ void Screen::blit(GraphicFrame *frame, Common::Rect *source, Common::Rect *desti
destination->height(),
destination->width(),
(uint16)destination->width() + frame->surface.pitch,
- (uint16)(frame->surface.pitch - destination->width()));
+ _backBuffer.pitch - (uint16)destination->width());
} else {
blitTranstable((byte *)_backBuffer.getPixels() + destination->top * _backBuffer.pitch + destination->left,
(byte *)frame->surface.getPixels() + source->top * frame->surface.pitch + source->left,
Commit: 380950a300cbdc3e720dc0dc3e579256f959494b
https://github.com/scummvm/scummvm/commit/380950a300cbdc3e720dc0dc3e579256f959494b
Author: alxpnv (alxpnv22 at yahoo.com)
Date: 2021-05-17T15:37:50+02:00
Commit Message:
ASYLUM: show all actors at scene enter
Changed paths:
engines/asylum/views/scene.cpp
diff --git a/engines/asylum/views/scene.cpp b/engines/asylum/views/scene.cpp
index caa64d7acc..ca005c3955 100644
--- a/engines/asylum/views/scene.cpp
+++ b/engines/asylum/views/scene.cpp
@@ -145,8 +145,7 @@ void Scene::enter(ResourcePackId packId) {
for (uint32 i = 1; i < _ws->actors.size(); i++) {
Actor *actor = _ws->actors[i];
- if (_ws->chapter == kChapter11) // DELETEME
- actor->show();
+ actor->show();
actor->setDirection(kDirectionNW);
actor->enable();
Commit: a6140c4944004e635ad4ce7a84637174e07fc0df
https://github.com/scummvm/scummvm/commit/a6140c4944004e635ad4ce7a84637174e07fc0df
Author: alxpnv (alxpnv22 at yahoo.com)
Date: 2021-05-17T15:37:51+02:00
Commit Message:
ASYLUM: minor fixes (mostly formatting)
Changed paths:
engines/asylum/asylum.cpp
engines/asylum/puzzles/pipes.cpp
engines/asylum/puzzles/wheel.cpp
engines/asylum/resources/encounters.cpp
engines/asylum/resources/script.cpp
engines/asylum/system/screen.cpp
engines/asylum/views/menu.cpp
engines/asylum/views/scene.cpp
diff --git a/engines/asylum/asylum.cpp b/engines/asylum/asylum.cpp
index 7e9618097c..7a4cecaf81 100644
--- a/engines/asylum/asylum.cpp
+++ b/engines/asylum/asylum.cpp
@@ -331,7 +331,7 @@ void AsylumEngine::playIntro() {
do {
// Poll events (this ensures we don't freeze the screen)
Common::Event ev;
- while(_eventMan->pollEvent(ev)) {
+ while (_eventMan->pollEvent(ev)) {
switch (ev.type) {
case Common::EVENT_LBUTTONDOWN:
case Common::EVENT_KEYDOWN:
diff --git a/engines/asylum/puzzles/pipes.cpp b/engines/asylum/puzzles/pipes.cpp
index 0037ffc176..b42758a159 100644
--- a/engines/asylum/puzzles/pipes.cpp
+++ b/engines/asylum/puzzles/pipes.cpp
@@ -211,7 +211,7 @@ void Connector::turn(bool updpos) {
if (_nextConnector) {
if (_isConnected) {
- if(!(_nextConnectorPosition & _state))
+ if (!(_nextConnectorPosition & _state))
disconnect(_nextConnector);
} else if (_nextConnectorPosition & _state && _nextConnector->isReadyForConnection()) {
connect(_nextConnector);
diff --git a/engines/asylum/puzzles/wheel.cpp b/engines/asylum/puzzles/wheel.cpp
index 02674c1cad..076f5ec5c1 100644
--- a/engines/asylum/puzzles/wheel.cpp
+++ b/engines/asylum/puzzles/wheel.cpp
@@ -187,7 +187,7 @@ bool PuzzleWheel::update(const AsylumEvent &) {
// Blinking red light
getScreen()->draw(getWorld()->graphicResourceIds[12], (uint32)_frameIndexes[11], puzzleWheelPoints[12]);
- _frameIndexes[11] = (_frameIndexes[11] + 1 ) % (int32)GraphicResource::getFrameCount(_vm, getWorld()->graphicResourceIds[12]);
+ _frameIndexes[11] = (_frameIndexes[11] + 1) % (int32)GraphicResource::getFrameCount(_vm, getWorld()->graphicResourceIds[12]);
// Clock
if (_showTurnedClock)
diff --git a/engines/asylum/resources/encounters.cpp b/engines/asylum/resources/encounters.cpp
index 0785aabbc3..d1ea85a7cc 100644
--- a/engines/asylum/resources/encounters.cpp
+++ b/engines/asylum/resources/encounters.cpp
@@ -924,7 +924,7 @@ bool Encounter::drawPortraits() {
}
// Portrait 1
- if (_portrait1.transTableNum == 3 )
+ if (_portrait1.transTableNum == 3)
getScreen()->draw(_portrait1.resourceId,
_portrait1.frameIndex,
_point + Common::Point(5, 5));
diff --git a/engines/asylum/resources/script.cpp b/engines/asylum/resources/script.cpp
index ea4c092ad3..cf7e30baf5 100644
--- a/engines/asylum/resources/script.cpp
+++ b/engines/asylum/resources/script.cpp
@@ -1395,7 +1395,9 @@ IMPLEMENT_OPCODE(PlaySpeechScene2)
cmd->param7 = 1;
return;
}
- } if (!cmd->param7) {
+ }
+
+ if (!cmd->param7) {
_vm->clearGameFlag(kGameFlag219);
cmd->param7 = 1;
return;
@@ -1639,7 +1641,7 @@ IMPLEMENT_OPCODE(JumpObjectFrame)
cmd->param2 = object->getFrameCount() - 1;
if (cmd->param3) {
- if(object->getFrameIndex() == (uint32)cmd->param2)
+ if (object->getFrameIndex() == (uint32)cmd->param2)
return;
} else if (cmd->param4) {
if (object->getFrameIndex() < (uint32)cmd->param2)
diff --git a/engines/asylum/system/screen.cpp b/engines/asylum/system/screen.cpp
index ccf3655a5b..4cf460c5a4 100644
--- a/engines/asylum/system/screen.cpp
+++ b/engines/asylum/system/screen.cpp
@@ -306,9 +306,9 @@ void Screen::setupPalette(byte *buffer, int start, int count) {
palette += start;
for (int32 i = 0; i < count; i++) {
- palette[0] = (byte )(buffer[0] * 4);
- palette[1] = (byte )(buffer[1] * 4);
- palette[2] = (byte )(buffer[2] * 4);
+ palette[0] = (byte)(buffer[0] * 4);
+ palette[1] = (byte)(buffer[1] * 4);
+ palette[2] = (byte)(buffer[2] * 4);
buffer += 3;
palette += 3;
@@ -713,7 +713,7 @@ void Screen::clearGraphicsInQueue() {
void Screen::graphicsSelectionSort() {
uint32 maxIdx;
- for (uint32 i = 0; i < _queueItems.size(); i++) {
+ for (uint32 i = 0; i < _queueItems.size() - 1; i++) {
maxIdx = i;
for (uint32 j = i + 1; j < _queueItems.size(); j++)
@@ -1215,7 +1215,7 @@ void Screen::copyToBackBufferWithTransparency(byte *buffer, int32 pitch, int16 x
for (int32 curX = left; curX < right; curX++) {
uint32 offset = (uint32)((mirrored ? right - (curX + 1) : curX) + curY * pitch);
- if (buffer[offset] != 0 )
+ if (buffer[offset] != 0)
dest[x + curX + (y + curY) * 640] = buffer[offset];
}
}
diff --git a/engines/asylum/views/menu.cpp b/engines/asylum/views/menu.cpp
index 1b61305184..fb72482a32 100644
--- a/engines/asylum/views/menu.cpp
+++ b/engines/asylum/views/menu.cpp
@@ -1127,7 +1127,7 @@ void Menu::updateViewMovies() {
if (index >= ARRAYSIZE(_movieList))
break;
- if (_movieList[index] != -1 ) {
+ if (_movieList[index] != -1) {
sprintf((char *)&text, "%d. %s ", index + 1, getText()->get(MAKE_RESOURCE(kResourcePackText, 1359 + _movieList[index])));
sprintf((char *)&text2, getText()->get(MAKE_RESOURCE(kResourcePackText, 1356)), moviesCd[_movieList[index]]);
strcat((char *)&text, (char *)&text2);
@@ -1152,7 +1152,7 @@ void Menu::updateViewMovies() {
if (index >= ARRAYSIZE(_movieList))
break;
- if (_movieList[index] != -1 ) {
+ if (_movieList[index] != -1) {
sprintf((char *)&text, "%d. %s ", index + 1, getText()->get(MAKE_RESOURCE(kResourcePackText, 1359 + _movieList[index])));
sprintf((char *)&text2, getText()->get(MAKE_RESOURCE(kResourcePackText, 1356)), moviesCd[_movieList[index]]);
strcat((char *)&text, (char *)&text2);
diff --git a/engines/asylum/views/scene.cpp b/engines/asylum/views/scene.cpp
index ca005c3955..50d655cba9 100644
--- a/engines/asylum/views/scene.cpp
+++ b/engines/asylum/views/scene.cpp
@@ -664,23 +664,23 @@ bool Scene::updateScreen() {
bool Scene::updateScene() {
#ifdef DEBUG_SCENE_TIMES
-#define MESURE_TICKS(func) { \
+#define MEASURE_TICKS(func) { \
int32 startTick =_vm->getTick(); \
func(); \
debugC(kDebugLevelScene, "[Scene] " #func " - Time: %d", _vm->getTick() - startTick); \
}
#else
-#define MESURE_TICKS(func) func();
+#define MEASURE_TICKS(func) func();
#endif
// Update each part of the scene
if (getSharedData()->getMatteBarHeight() != 170 || getSharedData()->getMattePlaySound()) {
- MESURE_TICKS(updateMouse);
- MESURE_TICKS(updateActors);
- MESURE_TICKS(updateObjects);
- MESURE_TICKS(updateAmbientSounds);
- MESURE_TICKS(updateMusic);
- MESURE_TICKS(updateAdjustScreen);
+ MEASURE_TICKS(updateMouse);
+ MEASURE_TICKS(updateActors);
+ MEASURE_TICKS(updateObjects);
+ MEASURE_TICKS(updateAmbientSounds);
+ MEASURE_TICKS(updateMusic);
+ MEASURE_TICKS(updateAdjustScreen);
}
return getScript()->process();
@@ -801,7 +801,7 @@ void Scene::updateMouse() {
newDirection = kDirectionE;
}
}
- } else if ( player->getDirection() == kDirectionS) {
+ } else if (player->getDirection() == kDirectionS) {
if ((mouse.x - actorRect.right) > 10)
newDirection = kDirectionSE;
} else if ((player->getDirection() != kDirectionE || (mouse.y - actorRect.bottom) > 10)) {
@@ -1343,7 +1343,7 @@ int32 Scene::hitTestActionArea() {
int32 targetIdx = findActionArea(kActionAreaType2, Common::Point(_ws->xLeft + pt.x, _ws->yTop + pt.y));
- if ( targetIdx == -1 || !(_ws->actions[targetIdx]->actionType & (kActionTypeFind | kActionTypeTalk | kActionTypeGrab | kActionType16)))
+ if (targetIdx == -1 || !(_ws->actions[targetIdx]->actionType & (kActionTypeFind | kActionTypeTalk | kActionTypeGrab | kActionType16)))
return -1;
return targetIdx;
Commit: ff5a2323431bae5a01fc023fdd4ab4ce7ab08ff9
https://github.com/scummvm/scummvm/commit/ff5a2323431bae5a01fc023fdd4ab4ce7ab08ff9
Author: alxpnv (alxpnv22 at yahoo.com)
Date: 2021-05-17T15:37:51+02:00
Commit Message:
ASYLUM: fix out of mixer slots in chapter 8
Changed paths:
engines/asylum/resources/special.cpp
diff --git a/engines/asylum/resources/special.cpp b/engines/asylum/resources/special.cpp
index f0c0d6553f..76fc687bbb 100644
--- a/engines/asylum/resources/special.cpp
+++ b/engines/asylum/resources/special.cpp
@@ -1763,7 +1763,7 @@ void Special::playSoundChapter8(Object *object, ActorIndex actorIndex) {
case 6:
if (!getSound()->isPlaying(getWorld()->soundResourceIds[14]))
- playSoundPanning(getWorld()->soundResourceIds[7], 15, actorIndex); // BUG: Are we really supposed to use that sound (7 instead of 14)
+ playSoundPanning(getWorld()->soundResourceIds[14], 15, actorIndex);
break;
}
}
Commit: f1c05630249dc36990d483bc60d3a12db6df1455
https://github.com/scummvm/scummvm/commit/f1c05630249dc36990d483bc60d3a12db6df1455
Author: alxpnv (alxpnv22 at yahoo.com)
Date: 2021-05-17T15:37:51+02:00
Commit Message:
ASYLUM: prevent actors from getting stuck when standing close to each other
Changed paths:
engines/asylum/resources/actor.cpp
diff --git a/engines/asylum/resources/actor.cpp b/engines/asylum/resources/actor.cpp
index 8ef94b4c55..434df187bb 100644
--- a/engines/asylum/resources/actor.cpp
+++ b/engines/asylum/resources/actor.cpp
@@ -1923,7 +1923,7 @@ bool Actor::canMoveCheckActors(Common::Point *point, ActorDirection dir) {
int32 x3 = actor->getPoint1()->x + actor->getPoint2()->x + 2 * actor->getField948() + 15;
int32 y3 = actor->getPoint1()->y + actor->getPoint2()->y + 2 * actor->getField94C() + 10;
- if (i == getSharedData()->getPlayerIndex() && getWorld()->chapter == kChapter11) {
+ if (i == getSharedData()->getPlayerIndex() && getWorld()->chapter != kChapter11) {
x2 -= 10;
y2 -= 10;
x3 += 10;
@@ -1939,7 +1939,7 @@ bool Actor::canMoveCheckActors(Common::Point *point, ActorDirection dir) {
int32 x5 = x3 - 10;
int32 y5 = y3 - 10;
- switch (actor->getDirection()) {
+ switch (_direction) {
default:
break;
Commit: 94088dc7564bb8a0011d00b7460eff6b630ffbbb
https://github.com/scummvm/scummvm/commit/94088dc7564bb8a0011d00b7460eff6b630ffbbb
Author: alxpnv (alxpnv22 at yahoo.com)
Date: 2021-05-17T15:37:51+02:00
Commit Message:
ASYLUM: fix music won't play after moving to the next chapter
Changed paths:
engines/asylum/asylum.cpp
engines/asylum/respack.h
diff --git a/engines/asylum/asylum.cpp b/engines/asylum/asylum.cpp
index 7a4cecaf81..42eb52e666 100644
--- a/engines/asylum/asylum.cpp
+++ b/engines/asylum/asylum.cpp
@@ -227,6 +227,8 @@ void AsylumEngine::startGame(ResourcePackId sceneId, StartGameType type) {
if (_resource->getCdNumber() != cdNumber)
_resource->clearSharedSoundCache();
+ _resource->clearMusicCache();
+
switch (type) {
default:
error("[AsylumEngine::startGame] Invalid start game type!");
diff --git a/engines/asylum/respack.h b/engines/asylum/respack.h
index e3b33ca3bb..5f745ee5c0 100644
--- a/engines/asylum/respack.h
+++ b/engines/asylum/respack.h
@@ -96,6 +96,7 @@ public:
void setCdNumber(int cdNumber) { _cdNumber = cdNumber; }
void setMusicPackId(ResourcePackId id) { _musicPackId = id; }
void clearSharedSoundCache() { _resources.erase(kResourcePackSharedSound); }
+ void clearMusicCache() { _music.erase(kResourcePackMusic); }
private:
struct ResourcePackId_EqualTo {
Commit: 1379ce64ad63562f5219d8e13eff9ecced2dface
https://github.com/scummvm/scummvm/commit/1379ce64ad63562f5219d8e13eff9ecced2dface
Author: alxpnv (alxpnv22 at yahoo.com)
Date: 2021-05-17T15:37:51+02:00
Commit Message:
ASYLUM: fix multiple inventory voices playing at the same time
Changed paths:
engines/asylum/resources/reaction.cpp
engines/asylum/system/speech.cpp
engines/asylum/views/scene.cpp
diff --git a/engines/asylum/resources/reaction.cpp b/engines/asylum/resources/reaction.cpp
index 7930fdfcba..fbcdfd39db 100644
--- a/engines/asylum/resources/reaction.cpp
+++ b/engines/asylum/resources/reaction.cpp
@@ -498,7 +498,7 @@ void Reaction::play(int32 index) {
break;
}
- if (getSpeech()->getSoundResourceId() == resourceId || !getSound()->isPlaying(resourceId))
+ if (getSpeech()->getSoundResourceId() != resourceId || !getSound()->isPlaying(resourceId))
getSpeech()->playPlayer(index);
}
diff --git a/engines/asylum/system/speech.cpp b/engines/asylum/system/speech.cpp
index f91f32d2f6..aee880ab38 100644
--- a/engines/asylum/system/speech.cpp
+++ b/engines/asylum/system/speech.cpp
@@ -51,8 +51,8 @@ Speech::~Speech() {
ResourceId Speech::play(ResourceId soundResourceId, ResourceId textResourceId) {
if (soundResourceId)
- if (getSound()->isPlaying(soundResourceId))
- getSound()->stopAll(soundResourceId);
+ if (getSound()->isPlaying(_soundResourceId))
+ getSound()->stopAll(_soundResourceId);
_soundResourceId = soundResourceId;
_textResourceId = textResourceId;
diff --git a/engines/asylum/views/scene.cpp b/engines/asylum/views/scene.cpp
index 50d655cba9..ff00d25b3f 100644
--- a/engines/asylum/views/scene.cpp
+++ b/engines/asylum/views/scene.cpp
@@ -1841,7 +1841,7 @@ void Scene::playIntroSpeech() {
}
void Scene::stopSpeech() {
- if (_vm->isGameFlagSet(kGameFlag219)) {
+ if (_vm->isGameFlagNotSet(kGameFlag219)) {
if (getSpeech()->getSoundResourceId() != kResourceNone && getSound()->isPlaying(getSpeech()->getSoundResourceId()))
getSound()->stopAll(getSpeech()->getSoundResourceId());
else if (getSpeech()->getTick())
Commit: d15af0f4b029aefcf32dcf79787da847196a0387
https://github.com/scummvm/scummvm/commit/d15af0f4b029aefcf32dcf79787da847196a0387
Author: alxpnv (alxpnv22 at yahoo.com)
Date: 2021-05-17T15:37:51+02:00
Commit Message:
ASYLUM: fix segfault in PuzzleHiveControl::hitTest1()
Changed paths:
engines/asylum/puzzles/hivecontrol.cpp
diff --git a/engines/asylum/puzzles/hivecontrol.cpp b/engines/asylum/puzzles/hivecontrol.cpp
index feb0c28a9a..6f4da22feb 100644
--- a/engines/asylum/puzzles/hivecontrol.cpp
+++ b/engines/asylum/puzzles/hivecontrol.cpp
@@ -465,7 +465,7 @@ void PuzzleHiveControl::updateScreen() {
}
void PuzzleHiveControl::playSound() {
- warning("[PuzzleHiveControl::playSound] Not implemented!");
+ // TODO
}
bool PuzzleHiveControl::hitTest1(Control control, const Common::Point &point, const Common::Point &location) {
@@ -477,10 +477,13 @@ bool PuzzleHiveControl::hitTest1(Control control, const Common::Point &point, co
GraphicFrame *frame = resource.getFrame(0);
Common::Point point1(point.x - location.x, point.y - location.y);
- if (!frame->getRect().contains(point1))
+ if (!frame->getRect().contains(point1)) {
return false;
- else
+ } else {
+ point1.x -= frame->x;
+ point1.y -= frame->y;
return *((byte *)frame->surface.getPixels() + point1.x + frame->surface.pitch * point1.y) != 0;
+ }
}
} // End of namespace Asylum
Commit: 5eed18bbc1a9e4aa278b87be1d2cf67b1dd0ed40
https://github.com/scummvm/scummvm/commit/5eed18bbc1a9e4aa278b87be1d2cf67b1dd0ed40
Author: alxpnv (alxpnv22 at yahoo.com)
Date: 2021-05-17T15:37:52+02:00
Commit Message:
ASYLUM: fix showing of player's facial expressions
Changed paths:
engines/asylum/resources/encounters.cpp
diff --git a/engines/asylum/resources/encounters.cpp b/engines/asylum/resources/encounters.cpp
index d1ea85a7cc..944debb377 100644
--- a/engines/asylum/resources/encounters.cpp
+++ b/engines/asylum/resources/encounters.cpp
@@ -746,19 +746,19 @@ void Encounter::setupSpeechData(char val, EncounterGraphic *encounterGraphic) co
break;
case 'N':
- encounterGraphic->speech3 = 0;
+ encounterGraphic->frameIndex = 0;
break;
case 'H':
- encounterGraphic->speech3 = 1;
+ encounterGraphic->frameIndex = 1;
break;
case 'E':
- encounterGraphic->speech3 = 2;
+ encounterGraphic->frameIndex = 2;
break;
case 'S':
- encounterGraphic->speech3 = 3;
+ encounterGraphic->frameIndex = 3;
break;
}
}
Commit: 5b32634e459ac0acd0c52e86507992b30580295f
https://github.com/scummvm/scummvm/commit/5b32634e459ac0acd0c52e86507992b30580295f
Author: alxpnv (alxpnv22 at yahoo.com)
Date: 2021-05-17T15:37:52+02:00
Commit Message:
ASYLUM: remove superfluous returns
Changed paths:
engines/asylum/resources/actor.cpp
diff --git a/engines/asylum/resources/actor.cpp b/engines/asylum/resources/actor.cpp
index 434df187bb..6a06876534 100644
--- a/engines/asylum/resources/actor.cpp
+++ b/engines/asylum/resources/actor.cpp
@@ -4070,8 +4070,6 @@ int16 Actor::compareX(const Common::Point &vec1, const Common::Point &vec2, cons
return -3;
else
return 0;
-
- return 0;
}
int16 Actor::compareY(const Common::Point &vec1, const Common::Point &vec2, const Common::Point &vec) {
@@ -4082,8 +4080,6 @@ int16 Actor::compareY(const Common::Point &vec1, const Common::Point &vec2, cons
return -3;
else
return 0;
-
- return 0;
}
Commit: 410e8dc2a2802a36552476c263ec83aa84d2ffd1
https://github.com/scummvm/scummvm/commit/410e8dc2a2802a36552476c263ec83aa84d2ffd1
Author: alxpnv (alxpnv22 at yahoo.com)
Date: 2021-05-17T15:37:52+02:00
Commit Message:
ASYLUM: remove .gitignore
Changed paths:
R engines/asylum/.gitignore
diff --git a/engines/asylum/.gitignore b/engines/asylum/.gitignore
deleted file mode 100644
index 33ab213e8a..0000000000
--- a/engines/asylum/.gitignore
+++ /dev/null
@@ -1,3 +0,0 @@
-.deps
-*.o
-*.a
Commit: 72a3f0c365f3a207478f1308bf3fecbb238c90ae
https://github.com/scummvm/scummvm/commit/72a3f0c365f3a207478f1308bf3fecbb238c90ae
Author: alxpnv (alxpnv22 at yahoo.com)
Date: 2021-05-17T15:37:52+02:00
Commit Message:
ASYLUM: replace spaces in indentation with tabs
Changed paths:
engines/asylum/asylum.cpp
engines/asylum/console.cpp
engines/asylum/puzzles/pipes.cpp
engines/asylum/resources/script.cpp
engines/asylum/system/config.cpp
diff --git a/engines/asylum/asylum.cpp b/engines/asylum/asylum.cpp
index 42eb52e666..0ccc2ac6be 100644
--- a/engines/asylum/asylum.cpp
+++ b/engines/asylum/asylum.cpp
@@ -154,8 +154,8 @@ Common::Error AsylumEngine::run() {
_menu = new Menu(this);
_handler = _menu;
- // Load config
- Config.read();
+ // Load config
+ Config.read();
// Setup mixer
syncSoundSettings();
@@ -329,28 +329,28 @@ void AsylumEngine::playIntro() {
ResourceId introSpeech = MAKE_RESOURCE(kResourcePackSound, 7);
_sound->playSound(introSpeech);
- int8 skip = 0;
+ int8 skip = 0;
do {
// Poll events (this ensures we don't freeze the screen)
Common::Event ev;
- while (_eventMan->pollEvent(ev)) {
- switch (ev.type) {
- case Common::EVENT_LBUTTONDOWN:
- case Common::EVENT_KEYDOWN:
- skip = true;
- break;
- default:
- break;
- }
- }
+ while (_eventMan->pollEvent(ev)) {
+ switch (ev.type) {
+ case Common::EVENT_LBUTTONDOWN:
+ case Common::EVENT_KEYDOWN:
+ skip = true;
+ break;
+ default:
+ break;
+ }
+ }
_system->delayMillis(100);
} while (_sound->isPlaying(introSpeech) && !skip);
-
- if (_sound->isPlaying(introSpeech)) {
- _sound->stop(introSpeech);
- }
+
+ if (_sound->isPlaying(introSpeech)) {
+ _sound->stop(introSpeech);
+ }
}
_cursor->setForceHide(false);
_introPlayed = true;
diff --git a/engines/asylum/console.cpp b/engines/asylum/console.cpp
index e256cafe47..3e331f447f 100644
--- a/engines/asylum/console.cpp
+++ b/engines/asylum/console.cpp
@@ -172,49 +172,49 @@ static const int32 itemIndices[][16] = {
};
Console::Console(AsylumEngine *engine) : _vm(engine) {
- // Commands
- registerCmd("help", WRAP_METHOD(Console, cmdHelp));
+ // Commands
+ registerCmd("help", WRAP_METHOD(Console, cmdHelp));
- registerCmd("ls", WRAP_METHOD(Console, cmdListFiles));
+ registerCmd("ls", WRAP_METHOD(Console, cmdListFiles));
- registerCmd("action", WRAP_METHOD(Console, cmdShowAction));
- registerCmd("actions", WRAP_METHOD(Console, cmdListActions));
- registerCmd("actors", WRAP_METHOD(Console, cmdListActors));
- registerCmd("flags", WRAP_METHOD(Console, cmdListFlags));
- registerCmd("object", WRAP_METHOD(Console, cmdShowObject));
- registerCmd("objects", WRAP_METHOD(Console, cmdListObjects));
- registerCmd("world", WRAP_METHOD(Console, cmdShowWorldStats));
+ registerCmd("action", WRAP_METHOD(Console, cmdShowAction));
+ registerCmd("actions", WRAP_METHOD(Console, cmdListActions));
+ registerCmd("actors", WRAP_METHOD(Console, cmdListActors));
+ registerCmd("flags", WRAP_METHOD(Console, cmdListFlags));
+ registerCmd("object", WRAP_METHOD(Console, cmdShowObject));
+ registerCmd("objects", WRAP_METHOD(Console, cmdListObjects));
+ registerCmd("world", WRAP_METHOD(Console, cmdShowWorldStats));
- registerCmd("video", WRAP_METHOD(Console, cmdPlayVideo));
- registerCmd("script", WRAP_METHOD(Console, cmdRunScript));
- registerCmd("show_script", WRAP_METHOD(Console, cmdShowScript));
- registerCmd("kill_script", WRAP_METHOD(Console, cmdKillScript));
+ registerCmd("video", WRAP_METHOD(Console, cmdPlayVideo));
+ registerCmd("script", WRAP_METHOD(Console, cmdRunScript));
+ registerCmd("show_script", WRAP_METHOD(Console, cmdShowScript));
+ registerCmd("kill_script", WRAP_METHOD(Console, cmdKillScript));
- registerCmd("scene", WRAP_METHOD(Console, cmdChangeScene));
- registerCmd("puzzle", WRAP_METHOD(Console, cmdRunPuzzle));
+ registerCmd("scene", WRAP_METHOD(Console, cmdChangeScene));
+ registerCmd("puzzle", WRAP_METHOD(Console, cmdRunPuzzle));
- registerCmd("get_status", WRAP_METHOD(Console, cmdGetStatus));
- registerCmd("set_status", WRAP_METHOD(Console, cmdSetStatus));
+ registerCmd("get_status", WRAP_METHOD(Console, cmdGetStatus));
+ registerCmd("set_status", WRAP_METHOD(Console, cmdSetStatus));
- registerCmd("encounter", WRAP_METHOD(Console, cmdRunEncounter));
- registerCmd("show_enc", WRAP_METHOD(Console, cmdShowEncounter));
+ registerCmd("encounter", WRAP_METHOD(Console, cmdRunEncounter));
+ registerCmd("show_enc", WRAP_METHOD(Console, cmdShowEncounter));
- registerCmd("items", WRAP_METHOD(Console, cmdListItems));
- registerCmd("grab", WRAP_METHOD(Console, cmdAddToInventory));
- registerCmd("throw", WRAP_METHOD(Console, cmdRemoveFromInventory));
+ registerCmd("items", WRAP_METHOD(Console, cmdListItems));
+ registerCmd("grab", WRAP_METHOD(Console, cmdAddToInventory));
+ registerCmd("throw", WRAP_METHOD(Console, cmdRemoveFromInventory));
- registerCmd("palette", WRAP_METHOD(Console, cmdSetPalette));
- registerCmd("draw", WRAP_METHOD(Console, cmdDrawResource));
+ registerCmd("palette", WRAP_METHOD(Console, cmdSetPalette));
+ registerCmd("draw", WRAP_METHOD(Console, cmdDrawResource));
- registerCmd("toggle_flag", WRAP_METHOD(Console, cmdToggleFlag));
+ registerCmd("toggle_flag", WRAP_METHOD(Console, cmdToggleFlag));
- // Variables
- registerVar("show_actors", &g_debugActors);
- registerVar("show_drawrects", &g_debugDrawRects);
- registerVar("show_objects", &g_debugObjects);
- registerVar("show_polygons", &g_debugPolygons);
- registerVar("show_scenerects", &g_debugSceneRects);
- registerVar("use_scrolling", &g_debugScrolling);
+ // Variables
+ registerVar("show_actors", &g_debugActors);
+ registerVar("show_drawrects", &g_debugDrawRects);
+ registerVar("show_objects", &g_debugObjects);
+ registerVar("show_polygons", &g_debugPolygons);
+ registerVar("show_scenerects", &g_debugSceneRects);
+ registerVar("use_scrolling", &g_debugScrolling);
}
Console::~Console() {
@@ -228,54 +228,54 @@ Console::~Console() {
// Help
//////////////////////////////////////////////////////////////////////////
bool Console::cmdHelp(int, const char **) {
- debugPrintf("Debug flags\n");
- debugPrintf("-----------\n");
- debugPrintf(" debugflag_list - Lists the available debug flags and their status\n");
- debugPrintf(" debugflag_enable - Enables a debug flag\n");
- debugPrintf(" debugflag_disable - Disables a debug flag\n");
- debugPrintf("\n");
- debugPrintf(" show_actors - Show actors\n");
- debugPrintf(" show_objects - Show objects\n");
- debugPrintf(" show_polygons - Show polygons\n");
- debugPrintf(" show_drawrects - Show drawing rects\n");
- debugPrintf(" use_scrolling - Scroll scene using the mouse\n");
- debugPrintf("\n");
- debugPrintf("Commands\n");
- debugPrintf("--------\n");
- debugPrintf(" ls - list engine files\n");
- debugPrintf("\n");
- debugPrintf(" actors - show actors information\n");
- debugPrintf(" action - show action information\n");
- debugPrintf(" actions - list actions information\n");
- debugPrintf(" flags - show flags\n");
- debugPrintf(" object - inspect a particular object\n");
- debugPrintf(" objects - show objects information\n");
- debugPrintf(" world - show worldstats\n");
- debugPrintf("\n");
- debugPrintf(" video - play a video\n");
- debugPrintf(" script - run a script\n");
- debugPrintf(" scene - change the scene\n");
- debugPrintf(" show_script - show script commands\n");
- debugPrintf(" kill_script - terminate a script\n");
- debugPrintf(" puzzle - run an puzzle\n");
- debugPrintf("\n");
- debugPrintf(" get_status - get actor's status\n");
- debugPrintf(" set_status - set actor's status\n");
- debugPrintf("\n");
- debugPrintf(" encounter - run an encounter\n");
- debugPrintf(" show_enc - show encounter commands\n");
- debugPrintf("\n");
- debugPrintf(" items - list all grabbable objects\n");
- debugPrintf(" grab - add an item to inventory\n");
- debugPrintf(" throw - remove an item from inventory\n");
- debugPrintf("\n");
- debugPrintf(" palette - set the screen palette\n");
- debugPrintf(" draw - draw a resource\n");
- debugPrintf("\n");
- debugPrintf(" toggle_flag - toggle a flag\n");
- debugPrintf("\n");
-
- return true;
+ debugPrintf("Debug flags\n");
+ debugPrintf("-----------\n");
+ debugPrintf(" debugflag_list - Lists the available debug flags and their status\n");
+ debugPrintf(" debugflag_enable - Enables a debug flag\n");
+ debugPrintf(" debugflag_disable - Disables a debug flag\n");
+ debugPrintf("\n");
+ debugPrintf(" show_actors - Show actors\n");
+ debugPrintf(" show_objects - Show objects\n");
+ debugPrintf(" show_polygons - Show polygons\n");
+ debugPrintf(" show_drawrects - Show drawing rects\n");
+ debugPrintf(" use_scrolling - Scroll scene using the mouse\n");
+ debugPrintf("\n");
+ debugPrintf("Commands\n");
+ debugPrintf("--------\n");
+ debugPrintf(" ls - list engine files\n");
+ debugPrintf("\n");
+ debugPrintf(" actors - show actors information\n");
+ debugPrintf(" action - show action information\n");
+ debugPrintf(" actions - list actions information\n");
+ debugPrintf(" flags - show flags\n");
+ debugPrintf(" object - inspect a particular object\n");
+ debugPrintf(" objects - show objects information\n");
+ debugPrintf(" world - show worldstats\n");
+ debugPrintf("\n");
+ debugPrintf(" video - play a video\n");
+ debugPrintf(" script - run a script\n");
+ debugPrintf(" scene - change the scene\n");
+ debugPrintf(" show_script - show script commands\n");
+ debugPrintf(" kill_script - terminate a script\n");
+ debugPrintf(" puzzle - run an puzzle\n");
+ debugPrintf("\n");
+ debugPrintf(" get_status - get actor's status\n");
+ debugPrintf(" set_status - set actor's status\n");
+ debugPrintf("\n");
+ debugPrintf(" encounter - run an encounter\n");
+ debugPrintf(" show_enc - show encounter commands\n");
+ debugPrintf("\n");
+ debugPrintf(" items - list all grabbable objects\n");
+ debugPrintf(" grab - add an item to inventory\n");
+ debugPrintf(" throw - remove an item from inventory\n");
+ debugPrintf("\n");
+ debugPrintf(" palette - set the screen palette\n");
+ debugPrintf(" draw - draw a resource\n");
+ debugPrintf("\n");
+ debugPrintf(" toggle_flag - toggle a flag\n");
+ debugPrintf("\n");
+
+ return true;
}
//////////////////////////////////////////////////////////////////////////
diff --git a/engines/asylum/puzzles/pipes.cpp b/engines/asylum/puzzles/pipes.cpp
index b42758a159..bb3acac7ec 100644
--- a/engines/asylum/puzzles/pipes.cpp
+++ b/engines/asylum/puzzles/pipes.cpp
@@ -107,7 +107,7 @@ const Common::Point peepholePoints[] = {
};
const uint32 peepholeResources[] = {15, 15, 15, 15, 32, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 32, 32, 15,
- 15, 32, 32, 15, 15, 15, 15, 15, 15, 15, 15, 32, 15, 15, 15, 15, 15, 15, 15};
+ 15, 32, 32, 15, 15, 15, 15, 15, 15, 15, 15, 32, 15, 15, 15, 15, 15, 15, 15};
static BinNum calcStateFromPos(uint32 ind, ConnectorType type, uint32 position) {
uint32 shift = (uint32)Common::intLog2(position);
diff --git a/engines/asylum/resources/script.cpp b/engines/asylum/resources/script.cpp
index cf7e30baf5..ee4be31e42 100644
--- a/engines/asylum/resources/script.cpp
+++ b/engines/asylum/resources/script.cpp
@@ -698,7 +698,7 @@ END_OPCODE
IMPLEMENT_OPCODE(JumpActorSpeech)
Actor *actor = getScene()->getActor(cmd->param1);
- // Actor goes to position (param2, param3)
+ // Actor goes to position (param2, param3)
if (actor->process(Common::Point((int16)cmd->param2, (int16)cmd->param3)))
return;
diff --git a/engines/asylum/system/config.cpp b/engines/asylum/system/config.cpp
index 4af6fda0e2..836a86eeef 100644
--- a/engines/asylum/system/config.cpp
+++ b/engines/asylum/system/config.cpp
@@ -84,11 +84,11 @@ ConfigurationManager::~ConfigurationManager() {
}
void ConfigurationManager::read() {
- // Default options
- musicVolume = ConfMan.getInt("music_volume");
- sfxVolume = ConfMan.getInt("sfx_volume");
- voiceVolume = ConfMan.getInt("speech_volume");
- showMovieSubtitles = ConfMan.getBool("subtitles");
+ // Default options
+ musicVolume = ConfMan.getInt("music_volume");
+ sfxVolume = ConfMan.getInt("sfx_volume");
+ voiceVolume = ConfMan.getInt("speech_volume");
+ showMovieSubtitles = ConfMan.getBool("subtitles");
// Convert volumes to engine-values
Sound::convertVolumeTo(musicVolume);
@@ -127,11 +127,11 @@ void ConfigurationManager::write() {
Sound::convertVolumeFrom(mixerSfxVolume);
Sound::convertVolumeFrom(mixerVoiceVolume);
- // Default options
- ConfMan.setInt("music_volume", mixerMusicVolume);
- ConfMan.setInt("sfx_volume", mixerSfxVolume);
- ConfMan.setInt("speech_volume", mixerVoiceVolume);
- ConfMan.setBool("subtitles", showMovieSubtitles);
+ // Default options
+ ConfMan.setInt("music_volume", mixerMusicVolume);
+ ConfMan.setInt("sfx_volume", mixerSfxVolume);
+ ConfMan.setInt("speech_volume", mixerVoiceVolume);
+ ConfMan.setBool("subtitles", showMovieSubtitles);
// Engine options
ConfMan.setBool("show_encounter_subtitles", showEncounterSubtitles);
Commit: c2b1207e23145c4817ec00aa04e591ff79850dd7
https://github.com/scummvm/scummvm/commit/c2b1207e23145c4817ec00aa04e591ff79850dd7
Author: alxpnv (alxpnv22 at yahoo.com)
Date: 2021-05-17T15:37:52+02:00
Commit Message:
ASYLUM: always play intro
Changed paths:
engines/asylum/asylum.cpp
diff --git a/engines/asylum/asylum.cpp b/engines/asylum/asylum.cpp
index 0ccc2ac6be..7db1553e51 100644
--- a/engines/asylum/asylum.cpp
+++ b/engines/asylum/asylum.cpp
@@ -235,9 +235,7 @@ void AsylumEngine::startGame(ResourcePackId sceneId, StartGameType type) {
case kStartGamePlayIntro:
_scene->enter(sceneId);
-#ifndef DEBUG
playIntro();
-#endif
break;
case kStartGameLoad:
Commit: c8e9fe33a75619661a51cf9d37376d81a6bc1430
https://github.com/scummvm/scummvm/commit/c8e9fe33a75619661a51cf9d37376d81a6bc1430
Author: alxpnv (alxpnv22 at yahoo.com)
Date: 2021-05-17T15:37:53+02:00
Commit Message:
ASYLUM: mark the engine as highres
Changed paths:
engines/asylum/configure.engine
diff --git a/engines/asylum/configure.engine b/engines/asylum/configure.engine
index e16ef5afdf..3d46f7cec6 100644
--- a/engines/asylum/configure.engine
+++ b/engines/asylum/configure.engine
@@ -1,3 +1,3 @@
# This file is included from the main "configure" script
# add_engine [name] [desc] [build-by-default] [subengines] [base games] [deps]
-add_engine asylum "Sanitarium" no
+add_engine asylum "Sanitarium" no "" "" "highres"
Commit: 7c82553e8a746db2e1de73310aa7c14de17be2ad
https://github.com/scummvm/scummvm/commit/7c82553e8a746db2e1de73310aa7c14de17be2ad
Author: alxpnv (alxpnv22 at yahoo.com)
Date: 2021-05-17T15:37:53+02:00
Commit Message:
ASYLUM: mark AsylumEngine::getSinCosValues() as const
Changed paths:
engines/asylum/asylum.cpp
engines/asylum/asylum.h
diff --git a/engines/asylum/asylum.cpp b/engines/asylum/asylum.cpp
index 7db1553e51..26f2975e00 100644
--- a/engines/asylum/asylum.cpp
+++ b/engines/asylum/asylum.cpp
@@ -543,7 +543,7 @@ int32 AsylumEngine::computeSinCosOffset(int32 val) const {
return offset - val;
}
-Common::Point AsylumEngine::getSinCosValues(int32 index1, int32 index2) {
+Common::Point AsylumEngine::getSinCosValues(int32 index1, int32 index2) const {
if (!_scene)
error("[AsylumEngine::getSinCosValues] Subsystems not initialized properly!");
diff --git a/engines/asylum/asylum.h b/engines/asylum/asylum.h
index 206d3f7963..95ffc1c6da 100644
--- a/engines/asylum/asylum.h
+++ b/engines/asylum/asylum.h
@@ -194,7 +194,7 @@ public:
*
* @return The sine cosine values.
*/
- Common::Point getSinCosValues(int32 index1, int32 index2);
+ Common::Point getSinCosValues(int32 index1, int32 index2) const;
// Serializable
void saveLoadWithSerializer(Common::Serializer &s);
Commit: 263e20c0049546c038804b6ced20fffe640596f7
https://github.com/scummvm/scummvm/commit/263e20c0049546c038804b6ced20fffe640596f7
Author: alxpnv (alxpnv22 at yahoo.com)
Date: 2021-05-17T15:37:53+02:00
Commit Message:
ASYLUM: replace sprintf() with snprintf()
Changed paths:
engines/asylum/console.cpp
engines/asylum/resources/actor.cpp
engines/asylum/views/menu.cpp
engines/asylum/views/scene.cpp
engines/asylum/views/video.cpp
diff --git a/engines/asylum/console.cpp b/engines/asylum/console.cpp
index 3e331f447f..2287304b48 100644
--- a/engines/asylum/console.cpp
+++ b/engines/asylum/console.cpp
@@ -527,7 +527,7 @@ bool Console::cmdPlayVideo(int32 argc, const char **argv) {
// Check if the video exists
char filename[20];
- sprintf(filename, "mov%03d.smk", index);
+ snprintf(filename, 20, "mov%03d.smk", index);
if (!SearchMan.hasFile(filename)) {
debugPrintf("[Error] Movie %d does not exists\n", index);
return true;
@@ -671,7 +671,7 @@ bool Console::cmdChangeScene(int32 argc, const char **argv) {
// Check if the scene exists
char filename[20];
- sprintf(filename, "scn.%03d", index);
+ snprintf(filename, 20, "scn.%03d", index);
if (!SearchMan.hasFile(filename)) {
debugPrintf("[Error] Scene %d does not exists\n", index);
return true;
diff --git a/engines/asylum/resources/actor.cpp b/engines/asylum/resources/actor.cpp
index 6a06876534..cbcbae40c6 100644
--- a/engines/asylum/resources/actor.cpp
+++ b/engines/asylum/resources/actor.cpp
@@ -3349,7 +3349,7 @@ void Actor::updateNumbers(int32 reaction, const Common::Point &point) {
_numberPoint.x = point.x;
_numberPoint.y = point.y + 8;
_numberStringWidth = 40;
- sprintf(_numberString01, "%d", _numberValue01);
+ snprintf(_numberString01, sizeof(_numberString01), "%d", _numberValue01);
_numberFlag01 = 1;
}
diff --git a/engines/asylum/views/menu.cpp b/engines/asylum/views/menu.cpp
index fb72482a32..0a3d64f7ce 100644
--- a/engines/asylum/views/menu.cpp
+++ b/engines/asylum/views/menu.cpp
@@ -722,7 +722,7 @@ void Menu::updateLoadGame() {
getText()->loadFont(kFontYellow);
getText()->drawCentered(Common::Point(10, 100), 620, MAKE_RESOURCE(kResourcePackText, 1329));
- sprintf((char *)&text, "%s ?", getSaveLoad()->getName()->c_str());
+ snprintf((char *)&text, sizeof(text), "%s ?", getSaveLoad()->getName()->c_str());
getText()->drawCentered(Common::Point(10, 134), 620, (char *)&text);
if (cursor.x < 247 || cursor.x > (247 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 1330)))
@@ -770,7 +770,7 @@ void Menu::updateLoadGame() {
if (index + _startIndex >= 25)
break;
- sprintf((char *)&text, "%d. %s ", index + _startIndex + 1, getSaveLoad()->getName((uint32)(index + _startIndex)).c_str());
+ snprintf((char *)&text, sizeof(text), "%d. %s ", index + _startIndex + 1, getSaveLoad()->getName((uint32)(index + _startIndex)).c_str());
if (cursor.x < 30 || cursor.x > (30 + getText()->getWidth((char *)&text))
|| cursor.y < y || cursor.y > (y + 24))
@@ -790,7 +790,7 @@ void Menu::updateLoadGame() {
if (index + _startIndex >= 25)
break;
- sprintf((char *)&text, "%d. %s ", index + _startIndex + 1, getSaveLoad()->getName((uint32)(index + _startIndex)).c_str());
+ snprintf((char *)&text, sizeof(text), "%d. %s ", index + _startIndex + 1, getSaveLoad()->getName((uint32)(index + _startIndex)).c_str());
if (cursor.x < 350 || cursor.x > (350 + getText()->getWidth((char *)&text))
|| cursor.y < y || cursor.y > (y + 24))
@@ -848,7 +848,7 @@ void Menu::updateSaveGame() {
getText()->loadFont(kFontYellow);
getText()->drawCentered(Common::Point(10, 100), 620, MAKE_RESOURCE(kResourcePackText, 1339));
- sprintf((char *)&text, "%s ?", getSaveLoad()->getName()->c_str());
+ snprintf((char *)&text, sizeof(text), "%s ?", getSaveLoad()->getName()->c_str());
getText()->drawCentered(Common::Point(10, 134), 620, (char *)&text);
if (cursor.x < 247 || cursor.x > (247 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 1340)))
@@ -893,7 +893,7 @@ void Menu::updateSaveGame() {
if (index + _startIndex >= 25)
break;
- sprintf((char *)&text, "%d. %s ", index + _startIndex + 1, getSaveLoad()->getName((uint32)(index + _startIndex)).c_str());
+ snprintf((char *)&text, sizeof(text), "%d. %s ", index + _startIndex + 1, getSaveLoad()->getName((uint32)(index + _startIndex)).c_str());
if (!_isEditingSavegameName) {
if (cursor.x < 30 || cursor.x > (30 + getText()->getWidth((char *)&text))
@@ -930,7 +930,7 @@ void Menu::updateSaveGame() {
if (index + _startIndex >= 25)
break;
- sprintf((char *)&text, "%d. %s ", index + _startIndex + 1, getSaveLoad()->getName((uint32)(index + _startIndex)).c_str());
+ snprintf((char *)&text, sizeof(text), "%d. %s ", index + _startIndex + 1, getSaveLoad()->getName((uint32)(index + _startIndex)).c_str());
if (!_isEditingSavegameName) {
if (cursor.x < 350 || cursor.x > (350 + getText()->getWidth((char *)&text))
@@ -1008,7 +1008,7 @@ void Menu::updateDeleteGame() {
getText()->loadFont(kFontYellow);
getText()->drawCentered(Common::Point(10, 100), 620, MAKE_RESOURCE(kResourcePackText, 1349));
- sprintf((char *)&text, "%s ?", getSaveLoad()->getName()->c_str());
+ snprintf((char *)&text, sizeof(text), "%s ?", getSaveLoad()->getName()->c_str());
getText()->drawCentered(Common::Point(10, 134), 620, (char *)&text);
if (cursor.x < 247 || cursor.x > (247 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 1350)))
@@ -1041,7 +1041,7 @@ void Menu::updateDeleteGame() {
if (index + _startIndex >= 25)
break;
- sprintf((char *)&text, "%d. %s ", index + _startIndex + 1, getSaveLoad()->getName((uint32)(index + _startIndex)).c_str());
+ snprintf((char *)&text, sizeof(text), "%d. %s ", index + _startIndex + 1, getSaveLoad()->getName((uint32)(index + _startIndex)).c_str());
if (cursor.x < 30 || cursor.x > (30 + getText()->getWidth((char *)&text))
|| cursor.y < y || cursor.y > (y + 24))
@@ -1061,7 +1061,7 @@ void Menu::updateDeleteGame() {
if (index + _startIndex >= 25)
break;
- sprintf((char *)&text, "%d. %s ", index + _startIndex + 1, getSaveLoad()->getName((uint32)(index + _startIndex)).c_str());
+ snprintf((char *)&text, sizeof(text), "%d. %s ", index + _startIndex + 1, getSaveLoad()->getName((uint32)(index + _startIndex)).c_str());
if (cursor.x < 350 || cursor.x > (350 + getText()->getWidth((char *)&text))
|| cursor.y < y || cursor.y > (y + 24))
@@ -1117,7 +1117,7 @@ void Menu::updateViewMovies() {
if (!_dword_455C78) {
getText()->loadFont(kFontYellow);
- sprintf((char *)&text2, getText()->get(MAKE_RESOURCE(kResourcePackText, 1352)), getSharedData()->cdNumber);
+ snprintf((char *)&text2, sizeof(text2), getText()->get(MAKE_RESOURCE(kResourcePackText, 1352)), getSharedData()->cdNumber);
getText()->drawCentered(Common::Point(10, 100), 620, (char *)&text2);
//////////////////////////////////////////////////////////////////////////
@@ -1128,8 +1128,8 @@ void Menu::updateViewMovies() {
break;
if (_movieList[index] != -1) {
- sprintf((char *)&text, "%d. %s ", index + 1, getText()->get(MAKE_RESOURCE(kResourcePackText, 1359 + _movieList[index])));
- sprintf((char *)&text2, getText()->get(MAKE_RESOURCE(kResourcePackText, 1356)), moviesCd[_movieList[index]]);
+ snprintf((char *)&text, sizeof(text), "%d. %s ", index + 1, getText()->get(MAKE_RESOURCE(kResourcePackText, 1359 + _movieList[index])));
+ snprintf((char *)&text2, sizeof(text2), getText()->get(MAKE_RESOURCE(kResourcePackText, 1356)), moviesCd[_movieList[index]]);
strcat((char *)&text, (char *)&text2);
if (getCursor()->isHidden()
@@ -1153,8 +1153,8 @@ void Menu::updateViewMovies() {
break;
if (_movieList[index] != -1) {
- sprintf((char *)&text, "%d. %s ", index + 1, getText()->get(MAKE_RESOURCE(kResourcePackText, 1359 + _movieList[index])));
- sprintf((char *)&text2, getText()->get(MAKE_RESOURCE(kResourcePackText, 1356)), moviesCd[_movieList[index]]);
+ snprintf((char *)&text, sizeof(text), "%d. %s ", index + 1, getText()->get(MAKE_RESOURCE(kResourcePackText, 1359 + _movieList[index])));
+ snprintf((char *)&text2, sizeof(text2), getText()->get(MAKE_RESOURCE(kResourcePackText, 1356)), moviesCd[_movieList[index]]);
strcat((char *)&text, (char *)&text2);
if (getCursor()->isHidden()
@@ -1221,11 +1221,11 @@ void Menu::updateViewMovies() {
}
getText()->loadFont(kFontYellow);
- sprintf((char *)&text2, getText()->get(MAKE_RESOURCE(kResourcePackText, 1357)), getSharedData()->cdNumber);
+ snprintf((char *)&text2, sizeof(text2), getText()->get(MAKE_RESOURCE(kResourcePackText, 1357)), getSharedData()->cdNumber);
getText()->drawCentered(Common::Point(10, 100), 620, text2);
strcpy((char *)&text, getText()->get(MAKE_RESOURCE(kResourcePackText, 1359 + _movieIndex)));
- sprintf((char *)&text2, getText()->get(MAKE_RESOURCE(kResourcePackText, 1356)), moviesCd[_movieIndex]);
+ snprintf((char *)&text2, sizeof(text2), getText()->get(MAKE_RESOURCE(kResourcePackText, 1356)), moviesCd[_movieIndex]);
strcat((char *)&text, (char *)&text2);
getText()->drawCentered(Common::Point(10, 134), 620, text);
@@ -1642,7 +1642,7 @@ void Menu::clickLoadGame() {
int32 index = 0;
for (int32 y = 150; y < 324; y += 29) {
if (cursor.x >= 350) {
- sprintf((char *)&text, "%d. %s ", index + _startIndex + 7, getSaveLoad()->getName((uint32)(index + _startIndex + 6)).c_str());
+ snprintf((char *)&text, sizeof(text), "%d. %s ", index + _startIndex + 7, getSaveLoad()->getName((uint32)(index + _startIndex + 6)).c_str());
if (cursor.x <= (350 + getText()->getWidth((char *)&text))
&& cursor.y >= y
@@ -1656,7 +1656,7 @@ void Menu::clickLoadGame() {
}
}
} else if (cursor.x >= 30) {
- sprintf((char *)&text, "%d. %s ", index + _startIndex + 1, getSaveLoad()->getName((uint32)(index + _startIndex)).c_str());
+ snprintf((char *)&text, sizeof(text), "%d. %s ", index + _startIndex + 1, getSaveLoad()->getName((uint32)(index + _startIndex)).c_str());
if (cursor.x <= (30 + getText()->getWidth((char *)&text))
&& cursor.y >= y
@@ -1736,7 +1736,7 @@ void Menu::clickSaveGame() {
int32 index = 0;
for (int16 y = 150; y < 324; y += 29) {
if (cursor.x >= 350) {
- sprintf((char *)&text, "%d. %s ", index + _startIndex + 7, getSaveLoad()->getName((uint32)(index + _startIndex + 6)).c_str());
+ snprintf((char *)&text, sizeof(text), "%d. %s ", index + _startIndex + 7, getSaveLoad()->getName((uint32)(index + _startIndex + 6)).c_str());
if (cursor.x <= (350 + getText()->getWidth((char *)&text))
&& cursor.y >= y
@@ -1757,7 +1757,7 @@ void Menu::clickSaveGame() {
}
}
} else if (cursor.x >= 30) {
- sprintf((char *)&text, "%d. %s ", index + _startIndex + 1, getSaveLoad()->getName((uint32)(index + _startIndex)).c_str());
+ snprintf((char *)&text, sizeof(text), "%d. %s ", index + _startIndex + 1, getSaveLoad()->getName((uint32)(index + _startIndex)).c_str());
if (cursor.x <= (30 + getText()->getWidth((char *)&text))
&& cursor.y >= y
@@ -1841,7 +1841,7 @@ void Menu::clickDeleteGame() {
int32 index = 0;
for (int16 y = 150; y < 324; y += 29) {
if (cursor.x >= 350) {
- sprintf((char *)&text, "%d. %s ", index + _startIndex + 7, getSaveLoad()->getName((uint32)(index + _startIndex + 6)).c_str());
+ snprintf((char *)&text, sizeof(text), "%d. %s ", index + _startIndex + 7, getSaveLoad()->getName((uint32)(index + _startIndex + 6)).c_str());
if (cursor.x <= (350 + getText()->getWidth((char *)&text))
&& cursor.y >= y
@@ -1855,7 +1855,7 @@ void Menu::clickDeleteGame() {
}
}
} else if (cursor.x >= 30) {
- sprintf((char *)&text, "%d. %s ", index + _startIndex + 1, getSaveLoad()->getName((uint32)(index + _startIndex)).c_str());
+ snprintf((char *)&text, sizeof(text), "%d. %s ", index + _startIndex + 1, getSaveLoad()->getName((uint32)(index + _startIndex)).c_str());
if (cursor.x <= (30 + getText()->getWidth((char *)&text))
&& cursor.y >= y
@@ -1925,8 +1925,8 @@ void Menu::clickViewMovies() {
if (_movieList[index + _startIndex + 6] == -1)
break;
- sprintf((char *)&text, "%d. %s ", index + 1, getText()->get(MAKE_RESOURCE(kResourcePackText, 1359 + _movieList[index])));
- sprintf((char *)&text2, getText()->get(MAKE_RESOURCE(kResourcePackText, 1356)), moviesCd[_movieList[index]]);
+ snprintf((char *)&text, sizeof(text), "%d. %s ", index + 1, getText()->get(MAKE_RESOURCE(kResourcePackText, 1359 + _movieList[index])));
+ snprintf((char *)&text2, sizeof(text2), getText()->get(MAKE_RESOURCE(kResourcePackText, 1356)), moviesCd[_movieList[index]]);
strcat((char *)&text, (char *)&text2);
if (cursor.x <= (350 + getText()->getWidth((char *)&text))
@@ -1950,8 +1950,8 @@ void Menu::clickViewMovies() {
if (_movieList[index + _startIndex] == -1)
break;
- sprintf((char *)&text, "%d. %s ", index + 1, getText()->get(MAKE_RESOURCE(kResourcePackText, 1359 + _movieList[index])));
- sprintf((char *)&text2, getText()->get(MAKE_RESOURCE(kResourcePackText, 1356)), moviesCd[_movieList[index]]);
+ snprintf((char *)&text, sizeof(text), "%d. %s ", index + 1, getText()->get(MAKE_RESOURCE(kResourcePackText, 1359 + _movieList[index])));
+ snprintf((char *)&text2, sizeof(text2), getText()->get(MAKE_RESOURCE(kResourcePackText, 1356)), moviesCd[_movieList[index]]);
strcat((char *)&text, (char *)&text2);
if (cursor.x <= (30 + getText()->getWidth((char *)&text))
diff --git a/engines/asylum/views/scene.cpp b/engines/asylum/views/scene.cpp
index ff00d25b3f..3838334fa4 100644
--- a/engines/asylum/views/scene.cpp
+++ b/engines/asylum/views/scene.cpp
@@ -252,7 +252,7 @@ void Scene::load(ResourcePackId packId) {
getResource()->setMusicPackId(packId);
char filename[10];
- sprintf(filename, SCENE_FILE_MASK, _packId);
+ snprintf(filename, 10, SCENE_FILE_MASK, _packId);
char sceneTag[6];
Common::File* fd = new Common::File;
diff --git a/engines/asylum/views/video.cpp b/engines/asylum/views/video.cpp
index f62cb34484..f68b5e760c 100644
--- a/engines/asylum/views/video.cpp
+++ b/engines/asylum/views/video.cpp
@@ -205,7 +205,7 @@ void VideoPlayer::setupPalette() {
void VideoPlayer::loadSubtitles() {
char movieToken[10];
- sprintf(movieToken, "[MOV%03d]", _currentMovie);
+ snprintf(movieToken, 10, "[MOV%03d]", _currentMovie);
Common::File subsFile;
subsFile.open("vids.cap");
Commit: 15bb6fd7281e86de85da0975749c19b708c220df
https://github.com/scummvm/scummvm/commit/15bb6fd7281e86de85da0975749c19b708c220df
Author: alxpnv (alxpnv22 at yahoo.com)
Date: 2021-05-17T15:37:53+02:00
Commit Message:
ASYLUM: replace 'Fallback to next case' comments with 'fallthrough'
Changed paths:
engines/asylum/resources/actor.cpp
engines/asylum/resources/encounters.cpp
engines/asylum/views/menu.cpp
engines/asylum/views/scene.cpp
diff --git a/engines/asylum/resources/actor.cpp b/engines/asylum/resources/actor.cpp
index cbcbae40c6..8c1b2e0f32 100644
--- a/engines/asylum/resources/actor.cpp
+++ b/engines/asylum/resources/actor.cpp
@@ -541,7 +541,7 @@ void Actor::update() {
return;
}
}
- // Fallback to next case
+ // fallthrough
case kActorStatusWalking: {
uint32 index = (_frameIndex >= _frameCount) ? 2 * _frameCount - (_frameIndex + 1) : _frameIndex;
@@ -1946,7 +1946,7 @@ bool Actor::canMoveCheckActors(Common::Point *point, ActorDirection dir) {
case kDirectionNW:
if (x4 >= x)
break;
- // Fallback to next case
+ // fallthrough
case kDirectionN:
if (y4 >= y)
diff --git a/engines/asylum/resources/encounters.cpp b/engines/asylum/resources/encounters.cpp
index 944debb377..d8efe823af 100644
--- a/engines/asylum/resources/encounters.cpp
+++ b/engines/asylum/resources/encounters.cpp
@@ -1604,7 +1604,7 @@ void Encounter::runScript() {
if (getVariable(3) == 13)
break;
- // Fallback to next case
+ // fallthrough
case 14:
getScene()->getActor()->hide(); // Hide player
diff --git a/engines/asylum/views/menu.cpp b/engines/asylum/views/menu.cpp
index 0a3d64f7ce..0dcb7b8296 100644
--- a/engines/asylum/views/menu.cpp
+++ b/engines/asylum/views/menu.cpp
@@ -645,7 +645,7 @@ bool Menu::click(const AsylumEvent &evt) {
case kMenuSaveGame:
_isEditingSavegameName = false;
- // Fallback to next case
+ // fallthrough
case kMenuLoadGame:
_dword_455C80 = false;
diff --git a/engines/asylum/views/scene.cpp b/engines/asylum/views/scene.cpp
index 3838334fa4..400e5feac2 100644
--- a/engines/asylum/views/scene.cpp
+++ b/engines/asylum/views/scene.cpp
@@ -491,7 +491,7 @@ bool Scene::key(const AsylumEvent &evt) {
case Common::KEYCODE_LEFTBRACKET:
if (evt.kbd.ascii != 123)
break;
- // Fallback to next case (we got a left brace)
+ // fallthrough
case Common::KEYCODE_p:
case Common::KEYCODE_q:
Commit: ce59904effaa706a1a3b73ab15a81dbf3c39d78d
https://github.com/scummvm/scummvm/commit/ce59904effaa706a1a3b73ab15a81dbf3c39d78d
Author: alxpnv (alxpnv22 at yahoo.com)
Date: 2021-05-17T15:37:53+02:00
Commit Message:
ASYLUM: rework monster status update
Changed paths:
engines/asylum/resources/special.cpp
engines/asylum/resources/worldstats.cpp
diff --git a/engines/asylum/resources/special.cpp b/engines/asylum/resources/special.cpp
index 76fc687bbb..f8e681649d 100644
--- a/engines/asylum/resources/special.cpp
+++ b/engines/asylum/resources/special.cpp
@@ -957,14 +957,14 @@ void Special::chapter11(Object *object, ActorIndex actorIndex) {
case kObjectMonsterStatus:
_vm->setGameFlag(kGameFlag572);
- if (object->getFrameIndex() >= getWorld()->dword_4563A0 + object->getFrameIndex()) {
- object->setFrameIndex(object->getFrameCount() - 1);
- getWorld()->dword_4563A0 = -1;
- }
-
- if (object->getFrameIndex() < 0) {
- object->setFrameIndex(0);
+ if (getWorld()->dword_4563A0 == -1 && !object->getFrameIndex()) {
getWorld()->dword_4563A0 = 1;
+ } else {
+ object->setFrameIndex(getWorld()->dword_4563A0 + object->getFrameIndex());
+ if (object->getFrameIndex() >= object->getFrameCount()) {
+ object->setFrameIndex(object->getFrameCount() - 1);
+ getWorld()->dword_4563A0 = -1;
+ }
}
if (getWorld()->field_E8490 == -666)
diff --git a/engines/asylum/resources/worldstats.cpp b/engines/asylum/resources/worldstats.cpp
index a3934be0b2..846b2272e0 100644
--- a/engines/asylum/resources/worldstats.cpp
+++ b/engines/asylum/resources/worldstats.cpp
@@ -92,7 +92,7 @@ WorldStats::WorldStats(AsylumEngine *engine) : _vm(engine) {
memset(&wheels, 0, sizeof(wheels));
tickCount1 = 0;
memset(&field_E8660, 0, sizeof(field_E8660));
- dword_4563A0 = 0;
+ dword_4563A0 = 1;
}
WorldStats::~WorldStats() {
Commit: b905953e5fec2e7b1e6306c21befa494f64e1d28
https://github.com/scummvm/scummvm/commit/b905953e5fec2e7b1e6306c21befa494f64e1d28
Author: alxpnv (alxpnv22 at yahoo.com)
Date: 2021-05-17T15:37:53+02:00
Commit Message:
ASYLUM: make FrameSoundItem::frameIndex unsigned
Changed paths:
engines/asylum/resources/object.cpp
engines/asylum/system/sound.h
diff --git a/engines/asylum/resources/object.cpp b/engines/asylum/resources/object.cpp
index 636cba2947..a3fafb1aa0 100644
--- a/engines/asylum/resources/object.cpp
+++ b/engines/asylum/resources/object.cpp
@@ -105,7 +105,7 @@ void Object::load(Common::SeekableReadStream *stream) {
for (int i = 0; i < 50; i++) {
_frameSoundItems[i].resourceId = (ResourceId)stream->readSint32LE();
- _frameSoundItems[i].frameIndex = stream->readSint32LE();
+ _frameSoundItems[i].frameIndex = stream->readUint32LE();
_frameSoundItems[i].index = stream->readSint32LE();
_frameSoundItems[i].field_C = stream->readSint32LE();
_frameSoundItems[i].field_10 = stream->readSint32LE();
@@ -173,7 +173,7 @@ void Object::saveLoadWithSerializer(Common::Serializer &s) {
for (int i = 0; i < ARRAYSIZE(_frameSoundItems); i++) {
s.syncAsSint32LE(_frameSoundItems[i].resourceId);
- s.syncAsSint32LE(_frameSoundItems[i].frameIndex);
+ s.syncAsUint32LE(_frameSoundItems[i].frameIndex);
s.syncAsSint32LE(_frameSoundItems[i].index);
s.syncAsSint32LE(_frameSoundItems[i].field_C);
s.syncAsSint32LE(_frameSoundItems[i].field_10);
diff --git a/engines/asylum/system/sound.h b/engines/asylum/system/sound.h
index 9a31ccd54a..bb93f3303f 100644
--- a/engines/asylum/system/sound.h
+++ b/engines/asylum/system/sound.h
@@ -54,7 +54,7 @@ struct SoundItem {
struct FrameSoundItem {
ResourceId resourceId;
- int32 frameIndex;
+ uint32 frameIndex;
int32 index;
int32 field_C;
int32 field_10;
Commit: 7c53e7560dc176d721104785efd11b9558b7c29a
https://github.com/scummvm/scummvm/commit/7c53e7560dc176d721104785efd11b9558b7c29a
Author: alxpnv (alxpnv22 at yahoo.com)
Date: 2021-05-17T15:37:54+02:00
Commit Message:
ASYLUM: add const qualifier to silence a warning
Changed paths:
engines/asylum/system/screen.cpp
engines/asylum/system/screen.h
engines/asylum/views/video.cpp
diff --git a/engines/asylum/system/screen.cpp b/engines/asylum/system/screen.cpp
index 4cf460c5a4..8217853047 100644
--- a/engines/asylum/system/screen.cpp
+++ b/engines/asylum/system/screen.cpp
@@ -1189,7 +1189,7 @@ void Screen::bltFast(int16 dX, int16 dY, GraphicFrame* frame, Common::Rect *sour
}
}
-void Screen::copyToBackBuffer(byte *buffer, int32 pitch, int16 x, int16 y, uint16 width, uint16 height, bool mirrored) {
+void Screen::copyToBackBuffer(const byte *buffer, int32 pitch, int16 x, int16 y, uint16 width, uint16 height, bool mirrored) {
byte *dest = (byte *)_backBuffer.getPixels();
if (!mirrored) {
diff --git a/engines/asylum/system/screen.h b/engines/asylum/system/screen.h
index 0e2aa55ec2..0f16420573 100644
--- a/engines/asylum/system/screen.h
+++ b/engines/asylum/system/screen.h
@@ -124,7 +124,7 @@ public:
void deleteGraphicFromQueue(ResourceId resourceId);
// Used by Video
- void copyToBackBuffer(byte *buffer, int32 pitch, int16 x, int16 y, uint16 width, uint16 height, bool mirrored = false);
+ void copyToBackBuffer(const byte *buffer, int32 pitch, int16 x, int16 y, uint16 width, uint16 height, bool mirrored = false);
// Debug
void drawLine(const Common::Point &origin, const Common::Point &destination, uint32 color = 0xFF);
diff --git a/engines/asylum/views/video.cpp b/engines/asylum/views/video.cpp
index f68b5e760c..a6db571ca7 100644
--- a/engines/asylum/views/video.cpp
+++ b/engines/asylum/views/video.cpp
@@ -166,7 +166,7 @@ void VideoPlayer::play(Common::String filename, bool showSubtitles) {
if (_smkDecoder->hasDirtyPalette())
setupPalette();
- getScreen()->copyToBackBuffer((byte *)frame->getPixels(), frame->pitch, x, y, frame->w, frame->h);
+ getScreen()->copyToBackBuffer((const byte *)frame->getPixels(), frame->pitch, x, y, frame->w, frame->h);
if (showSubtitles) {
int32 currentFrame = _smkDecoder->getCurFrame() + 1;
Commit: 06ebca09c3bf6880c9f249db100da5b8e9114efc
https://github.com/scummvm/scummvm/commit/06ebca09c3bf6880c9f249db100da5b8e9114efc
Author: alxpnv (alxpnv22 at yahoo.com)
Date: 2021-05-17T15:37:54+02:00
Commit Message:
ASYLUM: fix signed/unsigned comparison warnings
Changed paths:
engines/asylum/resources/special.cpp
engines/asylum/resources/worldstats.cpp
engines/asylum/resources/worldstats.h
diff --git a/engines/asylum/resources/special.cpp b/engines/asylum/resources/special.cpp
index f8e681649d..7021c2f96e 100644
--- a/engines/asylum/resources/special.cpp
+++ b/engines/asylum/resources/special.cpp
@@ -771,7 +771,7 @@ void Special::chapter11(Object *object, ActorIndex actorIndex) {
_vm->clearGameFlag(kGameFlag561);
}
- if (actor1->getTickCount() != -1 && actor1->getTickCount() < _vm->getTick()) {
+ if (actor1->getTickCount() != -1 && (uint32)actor1->getTickCount() < _vm->getTick()) {
actor1->setTickCount(-1);
actor1->show();
actor1->getPoint1()->x = actor0->getPoint2()->x + actor0->getPoint1()->x - actor1->getPoint2()->x;
@@ -967,10 +967,9 @@ void Special::chapter11(Object *object, ActorIndex actorIndex) {
}
}
- if (getWorld()->field_E8490 == -666)
+ if (getWorld()->field_E8490 == -666) {
getWorld()->field_E8490 = _vm->getTick() + 3000;
-
- if (getWorld()->field_E8490 < _vm->getTick()) {
+ } else if ((uint32)getWorld()->field_E8490 < _vm->getTick()) {
getWorld()->field_E8490 = -666;
if (_vm->isGameFlagSet(kGameFlag572)) {
_vm->clearGameFlag(kGameFlag565);
@@ -2036,7 +2035,7 @@ void Special::rock(ActorIndex actorIndex, GameFlag flag1, GameFlag flag2, GameFl
getSound()->playSound(getWorld()->soundResourceIds[0], false, Config.sfxVolume - 10);
_vm->setGameFlag(flag3);
getScene()->getActor(actorIndex)->show();
- } else if (_vm->getTick() > getWorld()->tickValueArray[actorIndex]) {
+ } else if (getWorld()->tickValueArray[actorIndex] == -666 || _vm->getTick() > (uint32)getWorld()->tickValueArray[actorIndex]) {
if (_vm->isGameFlagNotSet(flag4)) {
_vm->setGameFlag(flag4);
actor->setFrameIndex(0);
@@ -2082,7 +2081,7 @@ void Special::tentacle(ActorIndex actorIndex, GameFlag flag1, GameFlag flag2, Ga
if (_vm->isGameFlagSet(flag1)
&& _vm->isGameFlagNotSet(flag3)
&& !_vm->isGameFlagSet(flag2)
- && _vm->getTick() > getWorld()->tickValueArray[actorIndex + 10]) {
+ && (getWorld()->tickValueArray[actorIndex + 10] == -666 || _vm->getTick() > (uint32)getWorld()->tickValueArray[actorIndex + 10])) {
actor->getPoint1()->x = rect.left + rnd(rect.right - rect.left) - actor->getPoint2()->x;
actor->getPoint1()->y = rect.top + rnd(rect.bottom - rect.top) - actor->getPoint2()->y;
diff --git a/engines/asylum/resources/worldstats.cpp b/engines/asylum/resources/worldstats.cpp
index 846b2272e0..d0510a5a58 100644
--- a/engines/asylum/resources/worldstats.cpp
+++ b/engines/asylum/resources/worldstats.cpp
@@ -279,7 +279,7 @@ void WorldStats::load(Common::SeekableReadStream *stream) {
wheels[i] = getObjectById(id);
}
- tickCount1 = stream->readSint32LE();
+ tickCount1 = stream->readUint32LE();
for (int32 i = 0; i < ARRAYSIZE(field_E8660); i++)
field_E8660[i] = stream->readUint32LE();
@@ -453,7 +453,7 @@ void WorldStats::saveLoadWithSerializer(Common::Serializer &s) {
}
}
- s.syncAsSint32LE(tickCount1);
+ s.syncAsUint32LE(tickCount1);
for (int32 i = 0; i < ARRAYSIZE(field_E8660); i++)
s.syncAsUint32LE(field_E8660[i]);
diff --git a/engines/asylum/resources/worldstats.h b/engines/asylum/resources/worldstats.h
index a0bac0320e..675d0525a1 100644
--- a/engines/asylum/resources/worldstats.h
+++ b/engines/asylum/resources/worldstats.h
@@ -139,7 +139,7 @@ public:
uint32 field_E8610[6];
uint32 field_E8628[6];
Object *wheels[7];
- int32 tickCount1;
+ uint32 tickCount1;
uint32 field_E8660[6];
int32 dword_4563A0;
Commit: c6ab0e850363583a8aa10630fc98c3337d64dc76
https://github.com/scummvm/scummvm/commit/c6ab0e850363583a8aa10630fc98c3337d64dc76
Author: alxpnv (alxpnv22 at yahoo.com)
Date: 2021-05-17T15:37:54+02:00
Commit Message:
ASYLUM: remove getDebugger() declaration
Changed paths:
engines/asylum/asylum.h
diff --git a/engines/asylum/asylum.h b/engines/asylum/asylum.h
index 95ffc1c6da..f377c43cfd 100644
--- a/engines/asylum/asylum.h
+++ b/engines/asylum/asylum.h
@@ -77,7 +77,6 @@ protected:
// Engine APIs
virtual Common::Error run();
virtual bool hasFeature(EngineFeature f) const;
- virtual GUI::Debugger *getDebugger() { return _console; }
public:
enum StartGameType {
Commit: 48e164b2d7cb7b46444954008a0af58eb36dd8d5
https://github.com/scummvm/scummvm/commit/48e164b2d7cb7b46444954008a0af58eb36dd8d5
Author: alxpnv (alxpnv22 at yahoo.com)
Date: 2021-05-17T15:37:54+02:00
Commit Message:
ASYLUM: clean up includes
Changed paths:
engines/asylum/asylum.cpp
engines/asylum/asylum.h
engines/asylum/console.cpp
engines/asylum/console.h
engines/asylum/detection.cpp
engines/asylum/puzzles/board.h
engines/asylum/puzzles/boardkeyhidesto.h
engines/asylum/puzzles/boardsalvation.h
engines/asylum/puzzles/boardyouth.h
engines/asylum/puzzles/clock.h
engines/asylum/puzzles/fisherman.h
engines/asylum/puzzles/hivecontrol.h
engines/asylum/puzzles/hivemachine.h
engines/asylum/puzzles/lock.h
engines/asylum/puzzles/morguedoor.h
engines/asylum/puzzles/pipes.cpp
engines/asylum/puzzles/pipes.h
engines/asylum/puzzles/puzzle.h
engines/asylum/puzzles/puzzle11.h
engines/asylum/puzzles/puzzles.h
engines/asylum/puzzles/tictactoe.h
engines/asylum/puzzles/timemachine.h
engines/asylum/puzzles/vcr.h
engines/asylum/puzzles/wheel.h
engines/asylum/puzzles/writings.h
engines/asylum/resources/actor.h
engines/asylum/resources/data.cpp
engines/asylum/resources/data.h
engines/asylum/resources/encounters.h
engines/asylum/resources/object.h
engines/asylum/resources/polygons.h
engines/asylum/resources/reaction.h
engines/asylum/resources/script.h
engines/asylum/resources/special.h
engines/asylum/resources/worldstats.h
engines/asylum/respack.h
engines/asylum/staticres.h
engines/asylum/system/config.h
engines/asylum/system/cursor.h
engines/asylum/system/graphics.h
engines/asylum/system/savegame.cpp
engines/asylum/system/savegame.h
engines/asylum/system/screen.cpp
engines/asylum/system/screen.h
engines/asylum/system/sound.cpp
engines/asylum/system/sound.h
engines/asylum/system/speech.h
engines/asylum/system/text.cpp
engines/asylum/system/text.h
engines/asylum/views/menu.h
engines/asylum/views/scene.h
engines/asylum/views/scenetitle.h
engines/asylum/views/video.h
diff --git a/engines/asylum/asylum.cpp b/engines/asylum/asylum.cpp
index 26f2975e00..837e33a2d2 100644
--- a/engines/asylum/asylum.cpp
+++ b/engines/asylum/asylum.cpp
@@ -20,6 +20,10 @@
*
*/
+#include "common/debug-channels.h"
+
+#include "engines/util.h"
+
#include "asylum/asylum.h"
#include "asylum/resources/actor.h"
@@ -43,10 +47,6 @@
#include "asylum/respack.h"
-#include "common/debug-channels.h"
-
-#include "engines/util.h"
-
namespace Asylum {
AsylumEngine::AsylumEngine(OSystem *system, const ADGameDescription *gd) : Engine(system), _gameDescription(gd),
diff --git a/engines/asylum/asylum.h b/engines/asylum/asylum.h
index f377c43cfd..3909d0b1d8 100644
--- a/engines/asylum/asylum.h
+++ b/engines/asylum/asylum.h
@@ -20,23 +20,22 @@
*
*/
-#ifndef ASYLUM_ENGINE_H
-#define ASYLUM_ENGINE_H
-
-#include "asylum/resources/data.h"
-
-#include "asylum/console.h"
-#include "asylum/eventhandler.h"
-#include "asylum/shared.h"
+#ifndef ASYLUM_ASYLUM_H
+#define ASYLUM_ASYLUM_H
#include "common/random.h"
#include "common/scummsys.h"
#include "common/serializer.h"
#include "common/system.h"
-#include "engines/advancedDetector.h"
#include "engines/engine.h"
+#include "asylum/resources/data.h"
+
+#include "asylum/console.h"
+#include "asylum/eventhandler.h"
+#include "asylum/shared.h"
+
/**
* This is the namespace of the Asylum engine.
*
@@ -54,6 +53,9 @@
* Supported games:
* - Sanitarium
*/
+
+struct ADGameDescription;
+
namespace Asylum {
class Cursor;
@@ -264,4 +266,4 @@ private:
} // namespace Asylum
-#endif
+#endif // ASYLUM_ASYLUM_H
diff --git a/engines/asylum/console.cpp b/engines/asylum/console.cpp
index 2287304b48..d08fe98e49 100644
--- a/engines/asylum/console.cpp
+++ b/engines/asylum/console.cpp
@@ -20,6 +20,8 @@
*
*/
+#include "common/debug-channels.h"
+
#include "asylum/console.h"
#include "asylum/puzzles/puzzles.h"
@@ -41,8 +43,6 @@
#include "asylum/asylum.h"
#include "asylum/respack.h"
-#include "common/debug-channels.h"
-
namespace Asylum {
extern int g_debugActors;
diff --git a/engines/asylum/console.h b/engines/asylum/console.h
index a446bebcec..8efc418f73 100644
--- a/engines/asylum/console.h
+++ b/engines/asylum/console.h
@@ -95,4 +95,4 @@ private:
} // End of namespace Asylum
-#endif
+#endif // ASYLUM_CONSOLE_H
diff --git a/engines/asylum/detection.cpp b/engines/asylum/detection.cpp
index 40f40d883d..adfe5564dc 100644
--- a/engines/asylum/detection.cpp
+++ b/engines/asylum/detection.cpp
@@ -22,6 +22,7 @@
#include "engines/advancedDetector.h"
#include "base/plugins.h"
+
#include "asylum/detection_table.h"
class AsylumMetaEngineDetection : public AdvancedMetaEngineDetection {
diff --git a/engines/asylum/puzzles/board.h b/engines/asylum/puzzles/board.h
index cfd8d8ecae..df08899351 100644
--- a/engines/asylum/puzzles/board.h
+++ b/engines/asylum/puzzles/board.h
@@ -20,8 +20,8 @@
*
*/
-#ifndef ASYLUM_BOARD_H
-#define ASYLUM_BOARD_H
+#ifndef ASYLUM_PUZZLES_BOARD_H
+#define ASYLUM_PUZZLES_BOARD_H
#include "asylum/puzzles/puzzle.h"
@@ -99,4 +99,4 @@ private:
} // End of namespace Asylum
-#endif // ASYLUM_BOARD_H
+#endif // ASYLUM_PUZZLES_BOARD_H
diff --git a/engines/asylum/puzzles/boardkeyhidesto.h b/engines/asylum/puzzles/boardkeyhidesto.h
index a17554d719..9b778e355b 100644
--- a/engines/asylum/puzzles/boardkeyhidesto.h
+++ b/engines/asylum/puzzles/boardkeyhidesto.h
@@ -20,8 +20,8 @@
*
*/
-#ifndef ASYLUM_BOARDKEYHIDESTO_H
-#define ASYLUM_BOARDKEYHIDESTO_H
+#ifndef ASYLUM_PUZZLES_BOARDKEYHIDESTO_H
+#define ASYLUM_PUZZLES_BOARDKEYHIDESTO_H
#include "asylum/puzzles/board.h"
@@ -45,4 +45,4 @@ private:
} // End of namespace Asylum
-#endif // ASYLUM_BOARDKEYHIDESTO_H
+#endif // ASYLUM_PUZZLES_BOARDKEYHIDESTO_H
diff --git a/engines/asylum/puzzles/boardsalvation.h b/engines/asylum/puzzles/boardsalvation.h
index c2dafed81a..f29c81a2ae 100644
--- a/engines/asylum/puzzles/boardsalvation.h
+++ b/engines/asylum/puzzles/boardsalvation.h
@@ -20,8 +20,8 @@
*
*/
-#ifndef ASYLUM_BOARDSALVATION_H
-#define ASYLUM_BOARDSALVATION_H
+#ifndef ASYLUM_PUZZLES_BOARDSALVATION_H
+#define ASYLUM_PUZZLES_BOARDSALVATION_H
#include "asylum/puzzles/board.h"
@@ -51,4 +51,4 @@ private:
} // End of namespace Asylum
-#endif // ASYLUM_BOARDSALVATION_H
+#endif // ASYLUM_PUZZLES_BOARDSALVATION_H
diff --git a/engines/asylum/puzzles/boardyouth.h b/engines/asylum/puzzles/boardyouth.h
index 40c61e3caa..705c207b0c 100644
--- a/engines/asylum/puzzles/boardyouth.h
+++ b/engines/asylum/puzzles/boardyouth.h
@@ -20,8 +20,8 @@
*
*/
-#ifndef ASYLUM_BOARDYOUTH_H
-#define ASYLUM_BOARDYOUTH_H
+#ifndef ASYLUM_PUZZLES_BOARDYOUTH_H
+#define ASYLUM_PUZZLES_BOARDYOUTH_H
#include "asylum/puzzles/board.h"
@@ -45,4 +45,4 @@ private:
} // End of namespace Asylum
-#endif // ASYLUM_BOARDYOUTH_H
+#endif // ASYLUM_PUZZLES_BOARDYOUTH_H
diff --git a/engines/asylum/puzzles/clock.h b/engines/asylum/puzzles/clock.h
index 799663d76b..88bb381218 100644
--- a/engines/asylum/puzzles/clock.h
+++ b/engines/asylum/puzzles/clock.h
@@ -20,8 +20,8 @@
*
*/
-#ifndef ASYLUM_CLOCK_H
-#define ASYLUM_CLOCK_H
+#ifndef ASYLUM_PUZZLES_CLOCK_H
+#define ASYLUM_PUZZLES_CLOCK_H
#include "asylum/puzzles/puzzle.h"
@@ -62,4 +62,4 @@ private:
} // End of namespace Asylum
-#endif // ASYLUM_CLOCK_H
+#endif // ASYLUM_PUZZLES_CLOCK_H
diff --git a/engines/asylum/puzzles/fisherman.h b/engines/asylum/puzzles/fisherman.h
index 83175128a3..3f5ed431e8 100644
--- a/engines/asylum/puzzles/fisherman.h
+++ b/engines/asylum/puzzles/fisherman.h
@@ -20,8 +20,8 @@
*
*/
-#ifndef ASYLUM_FISHERMAN_H
-#define ASYLUM_FISHERMAN_H
+#ifndef ASYLUM_PUZZLES_FISHERMAN_H
+#define ASYLUM_PUZZLES_FISHERMAN_H
#include "asylum/puzzles/puzzle.h"
@@ -63,4 +63,4 @@ private:
} // End of namespace Asylum
-#endif // ASYLUM_FISHERMAN_H
+#endif // ASYLUM_PUZZLES_FISHERMAN_H
diff --git a/engines/asylum/puzzles/hivecontrol.h b/engines/asylum/puzzles/hivecontrol.h
index 361af0cd2e..9cf9553aff 100644
--- a/engines/asylum/puzzles/hivecontrol.h
+++ b/engines/asylum/puzzles/hivecontrol.h
@@ -20,13 +20,13 @@
*
*/
-#ifndef ASYLUM_HIVECONTROL_H
-#define ASYLUM_HIVECONTROL_H
-
-#include "asylum/puzzles/puzzle.h"
+#ifndef ASYLUM_PUZZLES_HIVECONTROL_H
+#define ASYLUM_PUZZLES_HIVECONTROL_H
#include "common/hashmap.h"
+#include "asylum/puzzles/puzzle.h"
+
namespace Asylum {
class AsylumEngine;
@@ -120,4 +120,4 @@ private:
} // End of namespace Asylum
-#endif // ASYLUM_HIVECONTROL_H
+#endif // ASYLUM_PUZZLES_HIVECONTROL_H
diff --git a/engines/asylum/puzzles/hivemachine.h b/engines/asylum/puzzles/hivemachine.h
index 2d1881863c..bf6995aa75 100644
--- a/engines/asylum/puzzles/hivemachine.h
+++ b/engines/asylum/puzzles/hivemachine.h
@@ -20,12 +20,12 @@
*
*/
-#ifndef ASYLUM_HIVEMACHINE_H
-#define ASYLUM_HIVEMACHINE_H
-
-#include "asylum/puzzles/puzzle.h"
+#ifndef ASYLUM_PUZZLES_HIVEMACHINE_H
+#define ASYLUM_PUZZLES_HIVEMACHINE_H
#include "common/array.h"
+
+#include "asylum/puzzles/puzzle.h"
#include "asylum/resources/polygons.h"
namespace Asylum {
@@ -75,4 +75,4 @@ private:
} // End of namespace Asylum
-#endif // ASYLUM_HIVEMACHINE_H
+#endif // ASYLUM_PUZZLES_HIVEMACHINE_H
diff --git a/engines/asylum/puzzles/lock.h b/engines/asylum/puzzles/lock.h
index 351d9833e5..145a47c6a6 100644
--- a/engines/asylum/puzzles/lock.h
+++ b/engines/asylum/puzzles/lock.h
@@ -20,8 +20,8 @@
*
*/
-#ifndef ASYLUM_LOCK_H
-#define ASYLUM_LOCK_H
+#ifndef ASYLUM_PUZZLES_LOCK_H
+#define ASYLUM_PUZZLES_LOCK_H
#include "asylum/puzzles/puzzle.h"
@@ -60,4 +60,4 @@ private:
} // End of namespace Asylum
-#endif // ASYLUM_LOCK_H
+#endif // ASYLUM_PUZZLES_LOCK_H
diff --git a/engines/asylum/puzzles/morguedoor.h b/engines/asylum/puzzles/morguedoor.h
index 3e705bb9ed..6f5fb97e65 100644
--- a/engines/asylum/puzzles/morguedoor.h
+++ b/engines/asylum/puzzles/morguedoor.h
@@ -20,8 +20,8 @@
*
*/
-#ifndef ASYLUM_MORGUEDOOR_H
-#define ASYLUM_MORGUEDOOR_H
+#ifndef ASYLUM_PUZZLES_MORGUEDOOR_H
+#define ASYLUM_PUZZLES_MORGUEDOOR_H
#include "asylum/puzzles/puzzle.h"
@@ -89,4 +89,4 @@ private:
} // End of namespace Asylum
-#endif // ASYLUM_MORGUEDOOR_H
+#endif // ASYLUM_PUZZLES_MORGUEDOOR_H
diff --git a/engines/asylum/puzzles/pipes.cpp b/engines/asylum/puzzles/pipes.cpp
index bb3acac7ec..46b7dcb10c 100644
--- a/engines/asylum/puzzles/pipes.cpp
+++ b/engines/asylum/puzzles/pipes.cpp
@@ -20,6 +20,8 @@
*
*/
+#include <common/math.h>
+
#include "asylum/puzzles/pipes.h"
#include "asylum/resources/worldstats.h"
@@ -32,8 +34,6 @@
#include "asylum/asylum.h"
-#include <common/math.h>
-
namespace Asylum {
const Common::Point connectorPoints[] = {
diff --git a/engines/asylum/puzzles/pipes.h b/engines/asylum/puzzles/pipes.h
index db2d7d1bbc..f41764e14b 100644
--- a/engines/asylum/puzzles/pipes.h
+++ b/engines/asylum/puzzles/pipes.h
@@ -20,10 +20,8 @@
*
*/
-#ifndef ASYLUM_PIPES_H
-#define ASYLUM_PIPES_H
-
-#include "asylum/puzzles/puzzle.h"
+#ifndef ASYLUM_PUZZLES_PIPES_H
+#define ASYLUM_PUZZLES_PIPES_H
#include "common/list.h"
#include "common/hashmap.h"
@@ -31,6 +29,8 @@
#include "common/random.h"
#include "common/str.h"
+#include "asylum/puzzles/puzzle.h"
+
namespace Asylum {
class AsylumEngine;
@@ -204,4 +204,4 @@ private:
} // End of namespace Asylum
-#endif // ASYLUM_PIPES_H
+#endif // ASYLUM_PUZZLES_PIPES_H
diff --git a/engines/asylum/puzzles/puzzle.h b/engines/asylum/puzzles/puzzle.h
index 9cb240045e..400ee97c50 100644
--- a/engines/asylum/puzzles/puzzle.h
+++ b/engines/asylum/puzzles/puzzle.h
@@ -20,15 +20,15 @@
*
*/
-#ifndef ASYLUM_PUZZLE_H
-#define ASYLUM_PUZZLE_H
-
-#include "asylum/eventhandler.h"
-#include "asylum/shared.h"
+#ifndef ASYLUM_PUZZLES_PUZZLE_H
+#define ASYLUM_PUZZLES_PUZZLE_H
#include "common/rect.h"
#include "common/serializer.h"
+#include "asylum/eventhandler.h"
+#include "asylum/shared.h"
+
namespace Asylum {
class AsylumEngine;
@@ -76,4 +76,4 @@ protected:
} // End of namespace Asylum
-#endif // ASYLUM_PUZZLE_H
+#endif // ASYLUM_PUZZLES_PUZZLE_H
diff --git a/engines/asylum/puzzles/puzzle11.h b/engines/asylum/puzzles/puzzle11.h
index b161dacdcb..7fa7a7774d 100644
--- a/engines/asylum/puzzles/puzzle11.h
+++ b/engines/asylum/puzzles/puzzle11.h
@@ -20,8 +20,8 @@
*
*/
-#ifndef ASYLUM_PUZZLE11_H
-#define ASYLUM_PUZZLE11_H
+#ifndef ASYLUM_PUZZLES_PUZZLE11_H
+#define ASYLUM_PUZZLES_PUZZLE11_H
#include "asylum/puzzles/puzzle.h"
@@ -57,4 +57,4 @@ private:
} // End of namespace Asylum
-#endif // ASYLUM_PUZZLE11_H
+#endif // ASYLUM_PUZZLES_PUZZLE11_H
diff --git a/engines/asylum/puzzles/puzzles.h b/engines/asylum/puzzles/puzzles.h
index 6a2568ddea..ff161b77a8 100644
--- a/engines/asylum/puzzles/puzzles.h
+++ b/engines/asylum/puzzles/puzzles.h
@@ -20,14 +20,14 @@
*
*/
-#ifndef ASYLUM_PUZZLES_H
-#define ASYLUM_PUZZLES_H
+#ifndef ASYLUM_PUZZLES_PUZZLES_H
+#define ASYLUM_PUZZLES_PUZZLES_H
+
+#include "common/serializer.h"
#include "asylum/console.h"
#include "asylum/shared.h"
-#include "common/serializer.h"
-
namespace Asylum {
class EventHandler;
@@ -70,4 +70,4 @@ private:
} // End of namespace Asylum
-#endif // ASYLUM_PUZZLES_H
+#endif // ASYLUM_PUZZLES_PUZZLES_H
diff --git a/engines/asylum/puzzles/tictactoe.h b/engines/asylum/puzzles/tictactoe.h
index 370c7c4c3b..6d4a7b97ed 100644
--- a/engines/asylum/puzzles/tictactoe.h
+++ b/engines/asylum/puzzles/tictactoe.h
@@ -20,8 +20,8 @@
*
*/
-#ifndef ASYLUM_TICTACTOE_H
-#define ASYLUM_TICTACTOE_H
+#ifndef ASYLUM_PUZZLES_TICTACTOE_H
+#define ASYLUM_PUZZLES_TICTACTOE_H
#include "asylum/puzzles/puzzle.h"
@@ -88,4 +88,4 @@ private:
} // End of namespace Asylum
-#endif // ASYLUM_TICTACTOE_H
+#endif // ASYLUM_PUZZLES_TICTACTOE_H
diff --git a/engines/asylum/puzzles/timemachine.h b/engines/asylum/puzzles/timemachine.h
index 43187d599d..4950210035 100644
--- a/engines/asylum/puzzles/timemachine.h
+++ b/engines/asylum/puzzles/timemachine.h
@@ -20,8 +20,8 @@
*
*/
-#ifndef ASYLUM_TIMEMACHINE_H
-#define ASYLUM_TIMEMACHINE_H
+#ifndef ASYLUM_PUZZLES_TIMEMACHINE_H
+#define ASYLUM_PUZZLES_TIMEMACHINE_H
#include "asylum/puzzles/puzzle.h"
@@ -74,4 +74,4 @@ private:
} // End of namespace Asylum
-#endif // ASYLUM_TIMEMACHINE_H
+#endif // ASYLUM_PUZZLES_TIMEMACHINE_H
diff --git a/engines/asylum/puzzles/vcr.h b/engines/asylum/puzzles/vcr.h
index 8c8021813c..5f79ee8c82 100644
--- a/engines/asylum/puzzles/vcr.h
+++ b/engines/asylum/puzzles/vcr.h
@@ -20,8 +20,8 @@
*
*/
-#ifndef ASYLUM_VCR_H
-#define ASYLUM_VCR_H
+#ifndef ASYLUM_PUZZLES_VCR_H
+#define ASYLUM_PUZZLES_VCR_H
#include "asylum/puzzles/puzzle.h"
@@ -146,4 +146,4 @@ private:
} // end of namespace Asylum
-#endif // ASYLUM_VCR_H
+#endif // ASYLUM_PUZZLES_VCR_H
diff --git a/engines/asylum/puzzles/wheel.h b/engines/asylum/puzzles/wheel.h
index 41f0478558..fcbd93b307 100644
--- a/engines/asylum/puzzles/wheel.h
+++ b/engines/asylum/puzzles/wheel.h
@@ -20,8 +20,8 @@
*
*/
-#ifndef ASYLUM_WHEEL_H
-#define ASYLUM_WHEEL_H
+#ifndef ASYLUM_PUZZLES_WHEEL_H
+#define ASYLUM_PUZZLES_WHEEL_H
#include "asylum/puzzles/puzzle.h"
@@ -72,4 +72,4 @@ private:
} // End of namespace Asylum
-#endif // ASYLUM_WHEEL_H
+#endif // ASYLUM_PUZZLES_WHEEL_H
diff --git a/engines/asylum/puzzles/writings.h b/engines/asylum/puzzles/writings.h
index a075ead6cf..61a06aba18 100644
--- a/engines/asylum/puzzles/writings.h
+++ b/engines/asylum/puzzles/writings.h
@@ -20,8 +20,8 @@
*
*/
-#ifndef ASYLUM_WRITINGS_H
-#define ASYLUM_WRITINGS_H
+#ifndef ASYLUM_PUZZLES_WRITINGS_H
+#define ASYLUM_PUZZLES_WRITINGS_H
#include "asylum/puzzles/puzzle.h"
#include "asylum/system/graphics.h"
@@ -52,4 +52,4 @@ private:
} // End of namespace Asylum
-#endif // ASYLUM_WRITINGS_H
+#endif // ASYLUM_PUZZLES_WRITINGS_H
diff --git a/engines/asylum/resources/actor.h b/engines/asylum/resources/actor.h
index 1e1ce8429c..d4061abfc5 100644
--- a/engines/asylum/resources/actor.h
+++ b/engines/asylum/resources/actor.h
@@ -20,16 +20,16 @@
*
*/
-#ifndef ASYLUM_ACTOR_H
-#define ASYLUM_ACTOR_H
-
-#include "asylum/shared.h"
+#ifndef ASYLUM_RESOURCES_ACTOR_H
+#define ASYLUM_RESOURCES_ACTOR_H
#include "common/array.h"
#include "common/rect.h"
#include "common/serializer.h"
#include "common/stream.h"
+#include "asylum/shared.h"
+
namespace Asylum {
class AsylumEngine;
@@ -641,4 +641,4 @@ private:
} // end of namespace Asylum
-#endif
+#endif // ASYLUM_RESOURCES_ACTOR_H
diff --git a/engines/asylum/resources/data.cpp b/engines/asylum/resources/data.cpp
index 6019218e30..2793e407db 100644
--- a/engines/asylum/resources/data.cpp
+++ b/engines/asylum/resources/data.cpp
@@ -20,10 +20,10 @@
*
*/
-#include "engines/asylum/resources/data.h"
-
#include "common/textconsole.h"
+#include "engines/asylum/resources/data.h"
+
namespace Asylum {
SharedData::SharedData() : crowsData(this) {
diff --git a/engines/asylum/resources/data.h b/engines/asylum/resources/data.h
index 779e904623..d9747c05f8 100644
--- a/engines/asylum/resources/data.h
+++ b/engines/asylum/resources/data.h
@@ -20,14 +20,14 @@
*
*/
-#ifndef ASYLUM_DATA_H
-#define ASYLUM_DATA_H
-
-#include "engines/asylum/shared.h"
+#ifndef ASYLUM_RESOURCES_DATA_H
+#define ASYLUM_RESOURCES_DATA_H
#include "common/rect.h"
#include "common/serializer.h"
+#include "engines/asylum/shared.h"
+
namespace Asylum {
//////////////////////////////////////////////////////////////////////////
@@ -279,4 +279,4 @@ private:
} // End of namespace Asylum
-#endif // ASYLUM_DATA_H
+#endif // ASYLUM_RESOURCES_DATA_H
diff --git a/engines/asylum/resources/encounters.h b/engines/asylum/resources/encounters.h
index c187a24c95..aba01bb112 100644
--- a/engines/asylum/resources/encounters.h
+++ b/engines/asylum/resources/encounters.h
@@ -20,15 +20,15 @@
*
*/
-#ifndef ASYLUM_ENCOUNTERS_H
-#define ASYLUM_ENCOUNTERS_H
-
-#include "asylum/eventhandler.h"
-#include "asylum/shared.h"
+#ifndef ASYLUM_RESOURCES_ENCOUNTERS_H
+#define ASYLUM_RESOURCES_ENCOUNTERS_H
#include "common/array.h"
#include "common/serializer.h"
+#include "asylum/eventhandler.h"
+#include "asylum/shared.h"
+
namespace Asylum {
class AsylumEngine;
@@ -336,4 +336,4 @@ private:
} // end of namespace Asylum
-#endif
+#endif // ASYLUM_RESOURCES_ENCOUNTERS_H
diff --git a/engines/asylum/resources/object.h b/engines/asylum/resources/object.h
index b6821b18ab..797a7fac89 100644
--- a/engines/asylum/resources/object.h
+++ b/engines/asylum/resources/object.h
@@ -20,17 +20,17 @@
*
*/
-#ifndef ASYLUM_OBJECT_H
-#define ASYLUM_OBJECT_H
-
-#include "asylum/shared.h"
-
-#include "asylum/system/sound.h"
+#ifndef ASYLUM_RESOURCES_OBJECT_H
+#define ASYLUM_RESOURCES_OBJECT_H
#include "common/rect.h"
#include "common/serializer.h"
#include "common/stream.h"
+#include "asylum/shared.h"
+
+#include "asylum/system/sound.h"
+
namespace Asylum {
class Actor;
@@ -241,4 +241,4 @@ private:
} // end of namespace Asylum
-#endif // ASYLUM_OBJECT_H
+#endif // ASYLUM_RESOURCES_OBJECT_H
diff --git a/engines/asylum/resources/polygons.h b/engines/asylum/resources/polygons.h
index b1e6498a67..ed3d0f51a8 100644
--- a/engines/asylum/resources/polygons.h
+++ b/engines/asylum/resources/polygons.h
@@ -20,8 +20,8 @@
*
*/
-#ifndef ASYLUM_POLYGONS_H
-#define ASYLUM_POLYGONS_H
+#ifndef ASYLUM_RESOURCES_POLYGONS_H
+#define ASYLUM_RESOURCES_POLYGONS_H
#include "common/array.h"
#include "common/rect.h"
@@ -67,4 +67,4 @@ private:
} // end of namespace Asylum
-#endif
+#endif // ASYLUM_RESOURCES_POLYGONS_H
diff --git a/engines/asylum/resources/reaction.h b/engines/asylum/resources/reaction.h
index cad7858df9..0ccef208ac 100644
--- a/engines/asylum/resources/reaction.h
+++ b/engines/asylum/resources/reaction.h
@@ -20,8 +20,8 @@
*
*/
-#ifndef ASYLUM_REACTION_H
-#define ASYLUM_REACTION_H
+#ifndef ASYLUM_RESOURCES_REACTION_H
+#define ASYLUM_RESOURCES_REACTION_H
#include "common/scummsys.h"
@@ -63,4 +63,4 @@ private:
} // End of namespace Asylum
-#endif // ASYLUM_REACTION_H
+#endif // ASYLUM_RESOURCES_REACTION_H
diff --git a/engines/asylum/resources/script.h b/engines/asylum/resources/script.h
index b99b06e0b8..26afd034c1 100644
--- a/engines/asylum/resources/script.h
+++ b/engines/asylum/resources/script.h
@@ -20,10 +20,8 @@
*
*/
-#ifndef ASYLUM_SCRIPT_H
-#define ASYLUM_SCRIPT_H
-
-#include "asylum/shared.h"
+#ifndef ASYLUM_RESOURCES_SCRIPT_H
+#define ASYLUM_RESOURCES_SCRIPT_H
#include "common/array.h"
#include "common/func.h"
@@ -31,6 +29,8 @@
#include "common/stack.h"
#include "common/stream.h"
+#include "asylum/shared.h"
+
namespace Asylum {
#define MAX_ACTION_COMMANDS 161
@@ -454,4 +454,4 @@ private:
} // end of namespace Asylum
-#endif // ASYLUM_SCRIPT_H
+#endif // ASYLUM_RESOURCES_SCRIPT_H
diff --git a/engines/asylum/resources/special.h b/engines/asylum/resources/special.h
index a1a758cbb3..136a0710a1 100644
--- a/engines/asylum/resources/special.h
+++ b/engines/asylum/resources/special.h
@@ -20,15 +20,15 @@
*
*/
-#ifndef ASYLUM_SPECIAL_H
-#define ASYLUM_SPECIAL_H
-
-#include "asylum/shared.h"
-#include "asylum/asylum.h"
+#ifndef ASYLUM_RESOURCES_SPECIAL_H
+#define ASYLUM_RESOURCES_SPECIAL_H
#include "common/scummsys.h"
#include "common/rect.h"
+#include "asylum/shared.h"
+#include "asylum/asylum.h"
+
namespace Asylum {
class Object;
@@ -112,4 +112,4 @@ private:
} // End of namespace Asylum
-#endif // ASYLUM_SPECIAL_H
+#endif // ASYLUM_RESOURCES_SPECIAL_H
diff --git a/engines/asylum/resources/worldstats.h b/engines/asylum/resources/worldstats.h
index 675d0525a1..fc6c0d63b3 100644
--- a/engines/asylum/resources/worldstats.h
+++ b/engines/asylum/resources/worldstats.h
@@ -20,15 +20,15 @@
*
*/
-#ifndef ASYLUM_WORLDSTATS_H
-#define ASYLUM_WORLDSTATS_H
-
-#include "asylum/system/sound.h"
+#ifndef ASYLUM_RESOURCES_WORLDSTATS_H
+#define ASYLUM_RESOURCES_WORLDSTATS_H
#include "common/array.h"
#include "common/rect.h"
#include "common/serializer.h"
+#include "asylum/system/sound.h"
+
namespace Asylum {
#define ACTORS_MAX_COUNT 50
@@ -162,4 +162,4 @@ private:
} // end of namespace Asylum
-#endif
+#endif // ASYLUM_RESOURCES_WORLDSTATS_H
diff --git a/engines/asylum/respack.h b/engines/asylum/respack.h
index 5f745ee5c0..cc9036b852 100644
--- a/engines/asylum/respack.h
+++ b/engines/asylum/respack.h
@@ -20,15 +20,15 @@
*
*/
-#ifndef ASYLUM_RESOURCEPACK_H
-#define ASYLUM_RESOURCEPACK_H
-
-#include "asylum/shared.h"
+#ifndef ASYLUM_RESPACK_H
+#define ASYLUM_RESPACK_H
#include "common/array.h"
#include "common/file.h"
#include "common/hashmap.h"
+#include "asylum/shared.h"
+
namespace Asylum {
class ResourceManager;
@@ -118,4 +118,4 @@ private:
} // end of namespace Asylum
-#endif
+#endif // ASYLUM_RESPACK_H
diff --git a/engines/asylum/staticres.h b/engines/asylum/staticres.h
index ea65efecb5..ca6e2e03b0 100644
--- a/engines/asylum/staticres.h
+++ b/engines/asylum/staticres.h
@@ -154,4 +154,4 @@ const uint8 angleTable03[256] = {
} // end of namespace Asylum
-#endif /* ASYLUM_STATICRES_H */
+#endif // ASYLUM_STATICRES_H
diff --git a/engines/asylum/system/config.h b/engines/asylum/system/config.h
index 7cb7eea214..40777f78ce 100644
--- a/engines/asylum/system/config.h
+++ b/engines/asylum/system/config.h
@@ -20,8 +20,8 @@
*
*/
-#ifndef ASYLUM_CONFIGURATIONMANAGER_H
-#define ASYLUM_CONFIGURATIONMANAGER_H
+#ifndef ASYLUM_SYSTEM_CONFIG_H
+#define ASYLUM_SYSTEM_CONFIG_H
#include "common/array.h"
#include "common/singleton.h"
@@ -106,4 +106,4 @@ private:
} // end of namespace Asylum
-#endif // ASYLUM_CONFIGURATIONMANAGER_H
+#endif // ASYLUM_SYSTEM_CONFIG_H
diff --git a/engines/asylum/system/cursor.h b/engines/asylum/system/cursor.h
index 9feecfe821..c9c18d0bb7 100644
--- a/engines/asylum/system/cursor.h
+++ b/engines/asylum/system/cursor.h
@@ -20,14 +20,14 @@
*
*/
-#ifndef ASYLUM_CURSOR_H
-#define ASYLUM_CURSOR_H
-
-#include "asylum/shared.h"
+#ifndef ASYLUM_SYSTEM_CURSOR_H
+#define ASYLUM_SYSTEM_CURSOR_H
#include "common/events.h"
#include "common/rect.h"
+#include "asylum/shared.h"
+
namespace Asylum {
class AsylumEngine;
@@ -163,4 +163,4 @@ private:
} // end of namespace Asylum
-#endif
+#endif // ASYLUM_SYSTEM_CURSOR_H
diff --git a/engines/asylum/system/graphics.h b/engines/asylum/system/graphics.h
index abd894d132..ac1f18706d 100644
--- a/engines/asylum/system/graphics.h
+++ b/engines/asylum/system/graphics.h
@@ -20,15 +20,15 @@
*
*/
-#ifndef ASYLUM_GRAPHICS_H
-#define ASYLUM_GRAPHICS_H
+#ifndef ASYLUM_SYSTEM_GRAPHICS_H
+#define ASYLUM_SYSTEM_GRAPHICS_H
-#include "asylum/shared.h"
+#include "common/rect.h"
+#include "common/array.h"
#include "graphics/surface.h"
-#include "common/rect.h"
-#include "common/array.h"
+#include "asylum/shared.h"
namespace Asylum {
@@ -114,4 +114,4 @@ private:
} // end of namespace Asylum
-#endif
+#endif // ASYLUM_SYSTEM_GRAPHICS_H
diff --git a/engines/asylum/system/savegame.cpp b/engines/asylum/system/savegame.cpp
index 1c3bb7e2e7..a10a625211 100644
--- a/engines/asylum/system/savegame.cpp
+++ b/engines/asylum/system/savegame.cpp
@@ -20,6 +20,8 @@
*
*/
+#include "common/file.h"
+
#include "asylum/system/savegame.h"
#include "asylum/puzzles/puzzles.h"
@@ -37,8 +39,6 @@
#include "asylum/asylum.h"
-#include "common/file.h"
-
namespace Asylum {
#define SAVEGAME_BUILD 851
diff --git a/engines/asylum/system/savegame.h b/engines/asylum/system/savegame.h
index d5fa4ba971..b1f5283d75 100644
--- a/engines/asylum/system/savegame.h
+++ b/engines/asylum/system/savegame.h
@@ -20,15 +20,15 @@
*
*/
-#ifndef ASYLUM_SAVEGAME_H
-#define ASYLUM_SAVEGAME_H
-
-#include "asylum/shared.h"
+#ifndef ASYLUM_SYSTEM_SAVEGAME_H
+#define ASYLUM_SYSTEM_SAVEGAME_H
#include "common/savefile.h"
#include "common/serializer.h"
#include "common/util.h"
+#include "asylum/shared.h"
+
namespace Asylum {
#define SAVEGAME_COUNT 25
@@ -258,4 +258,4 @@ private:
} // End of namespace Asylum
-#endif // ASYLUM_SAVEGAME_H
+#endif // ASYLUM_SYSTEM_SAVEGAME_H
diff --git a/engines/asylum/system/screen.cpp b/engines/asylum/system/screen.cpp
index 8217853047..4fd926fbc8 100644
--- a/engines/asylum/system/screen.cpp
+++ b/engines/asylum/system/screen.cpp
@@ -20,6 +20,9 @@
*
*/
+#include "common/scummsys.h"
+#include "common/timer.h"
+
#include "asylum/system/screen.h"
#include "asylum/resources/actor.h"
@@ -33,10 +36,6 @@
#include "asylum/asylum.h"
#include "asylum/respack.h"
-#include "common/timer.h"
-
-#include <stdarg.h> // For va_list etc.
-
namespace Asylum {
int g_debugDrawRects;
diff --git a/engines/asylum/system/screen.h b/engines/asylum/system/screen.h
index 0f16420573..91a305c8ab 100644
--- a/engines/asylum/system/screen.h
+++ b/engines/asylum/system/screen.h
@@ -20,10 +20,8 @@
*
*/
-#ifndef ASYLUM_SCREEN_H
-#define ASYLUM_SCREEN_H
-
-#include "asylum/shared.h"
+#ifndef ASYLUM_SYSTEM_SCREEN_H
+#define ASYLUM_SYSTEM_SCREEN_H
#include "common/array.h"
#include "common/rect.h"
@@ -31,6 +29,8 @@
#include "graphics/palette.h"
#include "graphics/surface.h"
+#include "asylum/shared.h"
+
namespace Asylum {
#define PALETTE_SIZE 256 * 3
@@ -204,4 +204,4 @@ private:
} // end of namespace Asylum
-#endif
+#endif // ASYLUM_SYSTEM_SCREEN_H
diff --git a/engines/asylum/system/sound.cpp b/engines/asylum/system/sound.cpp
index 359db585cd..3c4e29c2ab 100644
--- a/engines/asylum/system/sound.cpp
+++ b/engines/asylum/system/sound.cpp
@@ -20,6 +20,11 @@
*
*/
+#include "common/memstream.h"
+
+#include "audio/audiostream.h"
+#include "audio/decoders/adpcm.h"
+#include "audio/decoders/wave.h"
#include "asylum/system/config.h"
#include "asylum/system/sound.h"
@@ -32,12 +37,6 @@
#include "asylum/asylum.h"
#include "asylum/respack.h"
-#include "common/memstream.h"
-
-#include "audio/audiostream.h"
-#include "audio/decoders/adpcm.h"
-#include "audio/decoders/wave.h"
-
namespace Asylum {
Sound::Sound(AsylumEngine *engine, Audio::Mixer *mixer) : _vm(engine), _mixer(mixer), _musicVolume(-10000) {
diff --git a/engines/asylum/system/sound.h b/engines/asylum/system/sound.h
index bb93f3303f..28574a50f7 100644
--- a/engines/asylum/system/sound.h
+++ b/engines/asylum/system/sound.h
@@ -20,18 +20,18 @@
*
*/
-#ifndef ASYLUM_SOUND_H
-#define ASYLUM_SOUND_H
-
-#include "asylum/system/config.h"
-
-#include "asylum/shared.h"
+#ifndef ASYLUM_SYSTEM_SOUND_H
+#define ASYLUM_SYSTEM_SOUND_H
#include "common/array.h"
#include "common/rect.h"
#include "audio/mixer.h"
+#include "asylum/system/config.h"
+
+#include "asylum/shared.h"
+
namespace Asylum {
class AsylumEngine;
@@ -337,4 +337,4 @@ private:
} // end of namespace Asylum
-#endif
+#endif // ASYLUM_SYSTEM_SOUND_H
diff --git a/engines/asylum/system/speech.h b/engines/asylum/system/speech.h
index 779ebfbe0a..cca2a13bc5 100644
--- a/engines/asylum/system/speech.h
+++ b/engines/asylum/system/speech.h
@@ -20,13 +20,13 @@
*
*/
-#ifndef ASYLUM_SPEECH_H
-#define ASYLUM_SPEECH_H
-
-#include "asylum/shared.h"
+#ifndef ASYLUM_SYSTEM_SPEECH_H
+#define ASYLUM_SYSTEM_SPEECH_H
#include "common/scummsys.h"
+#include "asylum/shared.h"
+
namespace Asylum {
class AsylumEngine;
@@ -177,4 +177,4 @@ private:
} // end of namespace Asylum
-#endif
+#endif // ASYLUM_SYSTEM_SPEECH_H
diff --git a/engines/asylum/system/text.cpp b/engines/asylum/system/text.cpp
index 2b0c29b1fd..fae59e2aae 100644
--- a/engines/asylum/system/text.cpp
+++ b/engines/asylum/system/text.cpp
@@ -20,6 +20,8 @@
*
*/
+#include "common/rational.h"
+
#include "asylum/system/text.h"
#include "asylum/system/graphics.h"
@@ -28,8 +30,6 @@
#include "asylum/asylum.h"
#include "asylum/respack.h"
-#include "common/rational.h"
-
namespace Asylum {
Text::Text(AsylumEngine *engine) : _vm(engine) {
diff --git a/engines/asylum/system/text.h b/engines/asylum/system/text.h
index e8a386df6f..2844e1fd94 100644
--- a/engines/asylum/system/text.h
+++ b/engines/asylum/system/text.h
@@ -20,14 +20,14 @@
*
*/
-#ifndef ASYLUM_TEXT_H
-#define ASYLUM_TEXT_H
-
-#include "asylum/shared.h"
+#ifndef ASYLUM_SYSTEM_TEXT_H
+#define ASYLUM_SYSTEM_TEXT_H
#include "common/rect.h"
#include "common/scummsys.h"
+#include "asylum/shared.h"
+
namespace Asylum {
class AsylumEngine;
@@ -84,4 +84,4 @@ private:
} // end of namespace Asylum
-#endif
+#endif // ASYLUM_SYSTEM_TEXT_H
diff --git a/engines/asylum/views/menu.h b/engines/asylum/views/menu.h
index 2c1a5b7685..39a21dc198 100644
--- a/engines/asylum/views/menu.h
+++ b/engines/asylum/views/menu.h
@@ -20,8 +20,8 @@
*
*/
-#ifndef ASYLUM_MENU_H
-#define ASYLUM_MENU_H
+#ifndef ASYLUM_VIEWS_MENU_H
+#define ASYLUM_VIEWS_MENU_H
#include "asylum/eventhandler.h"
#include "asylum/shared.h"
@@ -239,4 +239,4 @@ private:
} // end of namespace Asylum
-#endif
+#endif // ASYLUM_VIEWS_MENU_H
diff --git a/engines/asylum/views/scene.h b/engines/asylum/views/scene.h
index a66f25bf6b..a686d19b01 100644
--- a/engines/asylum/views/scene.h
+++ b/engines/asylum/views/scene.h
@@ -20,17 +20,18 @@
*
*/
-#ifndef ASYLUM_SCENE_H
-#define ASYLUM_SCENE_H
-
-#include "asylum/eventhandler.h"
-#include "asylum/shared.h"
+#ifndef ASYLUM_VIEWS_SCENE_H
+#define ASYLUM_VIEWS_SCENE_H
#include "common/array.h"
#include "common/events.h"
#include "common/rational.h"
+
#include "graphics/surface.h"
+#include "asylum/eventhandler.h"
+#include "asylum/shared.h"
+
#define SCENE_FILE_MASK "scn.%03d"
#define MUSIC_FILE_MASK "mus.%03d"
@@ -470,4 +471,4 @@ private:
} // end of namespace Asylum
-#endif
+#endif // ASYLUM_VIEWS_SCENE_H
diff --git a/engines/asylum/views/scenetitle.h b/engines/asylum/views/scenetitle.h
index 526e555619..075b75b74c 100644
--- a/engines/asylum/views/scenetitle.h
+++ b/engines/asylum/views/scenetitle.h
@@ -20,8 +20,8 @@
*
*/
-#ifndef ASYLUM_SCENETITLE_H
-#define ASYLUM_SCENETITLE_H
+#ifndef ASYLUM_VIEWS_SCENETITLE_H
+#define ASYLUM_VIEWS_SCENETITLE_H
#include "common/scummsys.h"
@@ -52,4 +52,4 @@ private:
} // End of namespace Asylum
-#endif // ASYLUM_SCENETITLE_H
+#endif // ASYLUM_VIEWS_SCENETITLE_H
diff --git a/engines/asylum/views/video.h b/engines/asylum/views/video.h
index c292db794b..f06fe68f48 100644
--- a/engines/asylum/views/video.h
+++ b/engines/asylum/views/video.h
@@ -20,11 +20,8 @@
*
*/
-#ifndef ASYLUM_VIDEO_H
-#define ASYLUM_VIDEO_H
-
-#include "asylum/eventhandler.h"
-#include "asylum/shared.h"
+#ifndef ASYLUM_VIEWS_VIDEO_H
+#define ASYLUM_VIEWS_VIDEO_H
#include "common/array.h"
#include "common/events.h"
@@ -37,6 +34,9 @@
#include "video/smk_decoder.h"
+#include "asylum/eventhandler.h"
+#include "asylum/shared.h"
+
namespace Asylum {
class AsylumEngine;
@@ -106,4 +106,4 @@ private:
} // end of namespace Asylum
-#endif
+#endif // ASYLUM_VIEWS_VIDEO_H
Commit: ac43968c475653d714fa6711dc25960ce3865ba2
https://github.com/scummvm/scummvm/commit/ac43968c475653d714fa6711dc25960ce3865ba2
Author: alxpnv (alxpnv22 at yahoo.com)
Date: 2021-05-17T15:37:55+02:00
Commit Message:
ASYLUM: formatting
Changed paths:
engines/asylum/asylum.h
engines/asylum/console.cpp
engines/asylum/console.h
engines/asylum/puzzles/puzzle.cpp
engines/asylum/puzzles/puzzle.h
engines/asylum/puzzles/vcr.cpp
engines/asylum/puzzles/vcr.h
engines/asylum/resources/actor.cpp
engines/asylum/resources/object.cpp
engines/asylum/resources/object.h
engines/asylum/resources/script.cpp
engines/asylum/resources/script.h
engines/asylum/resources/worldstats.cpp
engines/asylum/resources/worldstats.h
engines/asylum/shared.h
engines/asylum/staticres.h
engines/asylum/system/speech.h
engines/asylum/system/text.cpp
engines/asylum/system/text.h
engines/asylum/views/menu.cpp
engines/asylum/views/menu.h
engines/asylum/views/scene.cpp
engines/asylum/views/scene.h
engines/asylum/views/video.cpp
engines/asylum/views/video.h
diff --git a/engines/asylum/asylum.h b/engines/asylum/asylum.h
index 3909d0b1d8..74a6ea963a 100644
--- a/engines/asylum/asylum.h
+++ b/engines/asylum/asylum.h
@@ -11,7 +11,7 @@
* 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
+ * 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
diff --git a/engines/asylum/console.cpp b/engines/asylum/console.cpp
index d08fe98e49..7b929c97fb 100644
--- a/engines/asylum/console.cpp
+++ b/engines/asylum/console.cpp
@@ -500,7 +500,7 @@ bool Console::cmdListObjects(int32 argc, const char **argv) {
debugPrintf("Total: %d\n", getWorld()->objects.size());
- } else if (Common::String(argv[1]) == "*"){
+ } else if (Common::String(argv[1]) == "*") {
for (uint32 i = 0; i < getWorld()->objects.size(); i++)
debugPrintf("%s", getWorld()->objects[i]->toString().c_str());
diff --git a/engines/asylum/console.h b/engines/asylum/console.h
index 8efc418f73..a29947c2fb 100644
--- a/engines/asylum/console.h
+++ b/engines/asylum/console.h
@@ -43,7 +43,7 @@ enum kDebugLevels {
kDebugLevelActor = 1 << 10,
kDebugLevelEncounter = 1 << 11,
kDebugLevelVideo = 1 << 12,
- kDebugLevelCommands = 1 << 13,
+ kDebugLevelCommands = 1 << 13
};
class AsylumEngine;
diff --git a/engines/asylum/puzzles/puzzle.cpp b/engines/asylum/puzzles/puzzle.cpp
index 9e8a39b1b7..d3d23c4c3c 100644
--- a/engines/asylum/puzzles/puzzle.cpp
+++ b/engines/asylum/puzzles/puzzle.cpp
@@ -11,7 +11,7 @@
* 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
+ * 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
diff --git a/engines/asylum/puzzles/puzzle.h b/engines/asylum/puzzles/puzzle.h
index 400ee97c50..3fa2e45271 100644
--- a/engines/asylum/puzzles/puzzle.h
+++ b/engines/asylum/puzzles/puzzle.h
@@ -11,7 +11,7 @@
* 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
+ * 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
diff --git a/engines/asylum/puzzles/vcr.cpp b/engines/asylum/puzzles/vcr.cpp
index ba57521e41..53072216ad 100644
--- a/engines/asylum/puzzles/vcr.cpp
+++ b/engines/asylum/puzzles/vcr.cpp
@@ -11,7 +11,7 @@
* 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
+ * 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
diff --git a/engines/asylum/puzzles/vcr.h b/engines/asylum/puzzles/vcr.h
index 5f79ee8c82..d978fd2a39 100644
--- a/engines/asylum/puzzles/vcr.h
+++ b/engines/asylum/puzzles/vcr.h
@@ -11,7 +11,7 @@
* 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
+ * 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
diff --git a/engines/asylum/resources/actor.cpp b/engines/asylum/resources/actor.cpp
index 8c1b2e0f32..15cffa62c2 100644
--- a/engines/asylum/resources/actor.cpp
+++ b/engines/asylum/resources/actor.cpp
@@ -3491,7 +3491,7 @@ bool Actor::processAction(const Common::Point &source, Common::Array<int> *actio
Common::Point src = source;
uint32 frameNumber = _frameNumber;
- switch (direction){
+ switch (direction) {
default:
return false;
diff --git a/engines/asylum/resources/object.cpp b/engines/asylum/resources/object.cpp
index a3fafb1aa0..b6cb45b060 100644
--- a/engines/asylum/resources/object.cpp
+++ b/engines/asylum/resources/object.cpp
@@ -11,7 +11,7 @@
* 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
+ * 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
@@ -41,8 +41,7 @@ Object::Object(AsylumEngine *engine) : x(0), y(0), flags(0), actionType(0),
_id(kObjectNone), _resourceId(kResourceNone), _field_20(0), _frameIndex(0), _frameCount(0),
_field_2C(0), _field_30(0), _field_34(0), _field_3C(0), _polygonIndex(0), _field_B4(0),
_tickCount(0), _tickCount2(0), _field_C0(0), _priority(0), _scriptIndex(0), _transparency(0),
- _field_688(0), _soundResourceId(kResourceNone), _field_6A4(kDirectionN)
-{
+ _field_688(0), _soundResourceId(kResourceNone), _field_6A4(kDirectionN) {
memset(&_name, 0, sizeof(_name));
memset(&_gameFlags, 0, sizeof(_gameFlags));
memset(&_randomResourceIds, 0, sizeof(_randomResourceIds));
@@ -217,27 +216,25 @@ bool Object::isOnScreen() {
}
bool Object::isVisible() const {
- if (flags & kObjectFlagEnabled) {
+ if (!(flags & kObjectFlagEnabled))
+ return false;
- // Check each game flag
- for (int32 i = 0; i < 10; i++) {
- int32 flag = _gameFlags[i];
- bool ok = false;
+ // Check each game flag
+ for (int32 i = 0; i < 10; i++) {
+ int32 flag = _gameFlags[i];
+ bool ok = false;
- if (flag <= 0)
- ok = _vm->isGameFlagNotSet((GameFlag)-flag);
- else
- ok = _vm->isGameFlagSet((GameFlag)flag);
+ if (flag <= 0)
+ ok = _vm->isGameFlagNotSet((GameFlag)-flag);
+ else
+ ok = _vm->isGameFlagSet((GameFlag)flag);
- if (!ok)
- return false;
- }
-
- // All flags were ok, we are done!
- return true;
+ if (!ok)
+ return false;
}
- return false;
+ // All flags were ok, we are done!
+ return true;
}
void Object::adjustCoordinates(Common::Point *point) {
diff --git a/engines/asylum/resources/object.h b/engines/asylum/resources/object.h
index 797a7fac89..c01df88d13 100644
--- a/engines/asylum/resources/object.h
+++ b/engines/asylum/resources/object.h
@@ -11,7 +11,7 @@
* 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
+ * 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
diff --git a/engines/asylum/resources/script.cpp b/engines/asylum/resources/script.cpp
index ee4be31e42..eb14672a56 100644
--- a/engines/asylum/resources/script.cpp
+++ b/engines/asylum/resources/script.cpp
@@ -11,7 +11,7 @@
* 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
+ * 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
diff --git a/engines/asylum/resources/script.h b/engines/asylum/resources/script.h
index 26afd034c1..38c5cb2dbd 100644
--- a/engines/asylum/resources/script.h
+++ b/engines/asylum/resources/script.h
@@ -11,7 +11,7 @@
* 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
+ * 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
diff --git a/engines/asylum/resources/worldstats.cpp b/engines/asylum/resources/worldstats.cpp
index d0510a5a58..a55995f117 100644
--- a/engines/asylum/resources/worldstats.cpp
+++ b/engines/asylum/resources/worldstats.cpp
@@ -11,7 +11,7 @@
* 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
+ * 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
diff --git a/engines/asylum/resources/worldstats.h b/engines/asylum/resources/worldstats.h
index fc6c0d63b3..15cddaf30f 100644
--- a/engines/asylum/resources/worldstats.h
+++ b/engines/asylum/resources/worldstats.h
@@ -11,7 +11,7 @@
* 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
+ * 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
diff --git a/engines/asylum/shared.h b/engines/asylum/shared.h
index ee1c8faec5..88d7983b7e 100644
--- a/engines/asylum/shared.h
+++ b/engines/asylum/shared.h
@@ -812,10 +812,10 @@ enum PuzzleId {
//////////////////////////////////////////////////////////////////////////
// Sub-integer partial access macros
//////////////////////////////////////////////////////////////////////////
-#define LOBYTE(d) (*((char*)&(d)))
-#define BYTE1(d) (*((char*)&(d)+1)) // Same as HIBYTE()
-#define BYTE2(d) (*((char*)&(d)+2))
-#define LOWORD(x) (*((int16*)&(x)))
+#define LOBYTE(d) (*((char *)&(d)))
+#define BYTE1(d) (*((char *)&(d) + 1)) // Same as HIBYTE()
+#define BYTE2(d) (*((char *)&(d) + 2))
+#define LOWORD(x) (*((int16 *)&(x)))
//////////////////////////////////////////////////////////////////////////
// Resource ID macros
diff --git a/engines/asylum/staticres.h b/engines/asylum/staticres.h
index ca6e2e03b0..05bfb576f1 100644
--- a/engines/asylum/staticres.h
+++ b/engines/asylum/staticres.h
@@ -11,7 +11,7 @@
* 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
+ * 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
diff --git a/engines/asylum/system/speech.h b/engines/asylum/system/speech.h
index cca2a13bc5..0dc0dcc895 100644
--- a/engines/asylum/system/speech.h
+++ b/engines/asylum/system/speech.h
@@ -11,7 +11,7 @@
* 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
+ * 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
diff --git a/engines/asylum/system/text.cpp b/engines/asylum/system/text.cpp
index fae59e2aae..29dc7fad9a 100644
--- a/engines/asylum/system/text.cpp
+++ b/engines/asylum/system/text.cpp
@@ -11,7 +11,7 @@
* 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
+ * 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
diff --git a/engines/asylum/system/text.h b/engines/asylum/system/text.h
index 2844e1fd94..f377802700 100644
--- a/engines/asylum/system/text.h
+++ b/engines/asylum/system/text.h
@@ -11,7 +11,7 @@
* 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
+ * 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
diff --git a/engines/asylum/views/menu.cpp b/engines/asylum/views/menu.cpp
index 0dcb7b8296..b4d2c261bd 100644
--- a/engines/asylum/views/menu.cpp
+++ b/engines/asylum/views/menu.cpp
@@ -11,7 +11,7 @@
* 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
+ * 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
@@ -1699,7 +1699,7 @@ void Menu::clickSaveGame() {
//////////////////////////////////////////////////////////////////////////
// Previous page
if (cursor.x >= 30 && cursor.x <= (30 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 1336)))
- && cursor.y >= 340 && cursor.y <= (340 + 24)) {
+ && cursor.y >= 340 && cursor.y <= (340 + 24)) {
if (_startIndex) {
_startIndex -= 12;
if (_startIndex < 0)
diff --git a/engines/asylum/views/menu.h b/engines/asylum/views/menu.h
index 39a21dc198..8dc87c4087 100644
--- a/engines/asylum/views/menu.h
+++ b/engines/asylum/views/menu.h
@@ -11,7 +11,7 @@
* 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
+ * 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
diff --git a/engines/asylum/views/scene.cpp b/engines/asylum/views/scene.cpp
index 400e5feac2..0239123148 100644
--- a/engines/asylum/views/scene.cpp
+++ b/engines/asylum/views/scene.cpp
@@ -11,7 +11,7 @@
* 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
+ * 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
@@ -2715,8 +2715,8 @@ void Scene::checkVisibleActorsPriority() {
}
void Scene::adjustActorPriority(ActorIndex index) {
- Actor* actor0 = getActor(0);
- Actor* actor = getActor(index);
+ Actor *actor0 = getActor(0);
+ Actor *actor = getActor(index);
if (rectIntersect(actor0->getPoint1()->x,
actor0->getPoint1()->y,
diff --git a/engines/asylum/views/scene.h b/engines/asylum/views/scene.h
index a686d19b01..ba25c4123c 100644
--- a/engines/asylum/views/scene.h
+++ b/engines/asylum/views/scene.h
@@ -11,7 +11,7 @@
* 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
+ * 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
diff --git a/engines/asylum/views/video.cpp b/engines/asylum/views/video.cpp
index a6db571ca7..29daa9b29f 100644
--- a/engines/asylum/views/video.cpp
+++ b/engines/asylum/views/video.cpp
@@ -11,7 +11,7 @@
* 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
+ * 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
diff --git a/engines/asylum/views/video.h b/engines/asylum/views/video.h
index f06fe68f48..9ad5e513be 100644
--- a/engines/asylum/views/video.h
+++ b/engines/asylum/views/video.h
@@ -11,7 +11,7 @@
* 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
+ * 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
Commit: 93f08cc43dd28f3392424aaa4edde49ab4d0e113
https://github.com/scummvm/scummvm/commit/93f08cc43dd28f3392424aaa4edde49ab4d0e113
Author: alxpnv (alxpnv22 at yahoo.com)
Date: 2021-05-17T15:37:55+02:00
Commit Message:
ASYLUM: fixes to the detection tables
Suggested by sev-
Changed paths:
engines/asylum/detection_table.h
diff --git a/engines/asylum/detection_table.h b/engines/asylum/detection_table.h
index 15dc0f8f0b..1a13ac1260 100644
--- a/engines/asylum/detection_table.h
+++ b/engines/asylum/detection_table.h
@@ -32,21 +32,17 @@ static const char *directoryGlobs[] = {
0
};
-
static const ADGameDescription gameDescriptions[] = {
{
// Sanitarium - English Demo
"asylum",
"Demo",
- {
- {"SNTRM.DAT", 0, "6a8079e0b49affc99d148624fbb584a1", 326},
- {"RES.000", 0, "57446ce089c6f9decb7f3faf41d09edf", 9022},
- {0,0,0,0}
- },
+ AD_ENTRY2s("SNTRM.DAT", "6a8079e0b49affc99d148624fbb584a1", 326,
+ "RES.000", "57446ce089c6f9decb7f3faf41d09edf", 9022),
Common::EN_ANY,
Common::kPlatformWindows,
- ADGF_DEMO|ADGF_UNSTABLE,
- GUIO1(GUIO_NONE)
+ ADGF_DEMO | ADGF_UNSTABLE | ADGF_DROPPLATFORM,
+ GUIO0()
},
{
"asylum",
@@ -55,12 +51,12 @@ static const ADGameDescription gameDescriptions[] = {
{"SNTRM.DAT", 0, "7cfcc457c1f579fbf9878ac175d29374", 8930},
{"RES.000", 0, "4d13f1412f9e7dd3eaf0a58f0e00e662", 272057},
{"SCN.006", 0, "71a5f49cbda597a11e877589075e27b5", 2918330},
- {0,0,0,0}
+ AD_LISTEND
},
Common::EN_ANY,
Common::kPlatformWindows,
- ADGF_UNSTABLE,
- GUIO1(GUIO_NONE)
+ ADGF_UNSTABLE | ADGF_DROPPLATFORM,
+ GUIO0()
},
{
"asylum",
@@ -69,12 +65,12 @@ static const ADGameDescription gameDescriptions[] = {
{"SNTRM.DAT", 0, "7cfcc457c1f579fbf9878ac175d29374", 8930},
{"RES.000", 0, "4d13f1412f9e7dd3eaf0a58f0e00e662", 272057},
{"SCN.006", 0, "3a5b54da08198012dc0614114782d5fb", 2918330},
- {0,0,0,0}
+ AD_LISTEND
},
Common::EN_ANY,
Common::kPlatformWindows,
- ADGF_UNSTABLE,
- GUIO1(GUIO_NONE)
+ ADGF_UNSTABLE | ADGF_DROPPLATFORM,
+ GUIO0()
},
{
"asylum",
@@ -83,12 +79,12 @@ static const ADGameDescription gameDescriptions[] = {
{"SNTRM.DAT", 0, "7cfcc457c1f579fbf9878ac175d29374", 8930},
{"RES.000", 0, "f58f8dc3e63663f174977d359e11132c", 272057},
{"SCN.006", 0, "3a5b54da08198012dc0614114782d5fb", 2918330},
- {0,0,0,0}
+ AD_LISTEND
},
Common::EN_ANY,
Common::kPlatformWindows,
- ADGF_UNSTABLE,
- GUIO1(GUIO_NONE)
+ ADGF_UNSTABLE | ADGF_DROPPLATFORM,
+ GUIO0()
},
{
"asylum",
@@ -97,12 +93,12 @@ static const ADGameDescription gameDescriptions[] = {
{"SNTRM.DAT", 0, "e09a12543c6ede1727c8ecffb74e7fd2", 8930},
{"RES.000", 0, "2a4677ee3fd7bfa3161e16cd59371238", 277931},
{"SCN.006", 0, "3a5b54da08198012dc0614114782d5fb", 2918330},
- {0,0,0,0}
+ AD_LISTEND
},
Common::FR_FRA,
Common::kPlatformWindows,
- ADGF_UNSTABLE,
- GUIO1(GUIO_NONE)
+ ADGF_UNSTABLE | ADGF_DROPPLATFORM,
+ GUIO0()
},
{
"asylum",
@@ -111,12 +107,12 @@ static const ADGameDescription gameDescriptions[] = {
{"SNTRM.DAT", 0, "7cfcc457c1f579fbf9878ac175d29374", 8930},
{"RES.000", 0, "1f8a262bf8b3035bd3cfda24068c4651", 263624},
{"SCN.006", 0, "3a5b54da08198012dc0614114782d5fb", 2918330},
- {0,0,0,0}
+ AD_LISTEND
},
Common::RU_RUS,
Common::kPlatformWindows,
- ADGF_UNSTABLE,
- GUIO1(GUIO_NONE)
+ ADGF_UNSTABLE | ADGF_DROPPLATFORM,
+ GUIO0()
},
AD_TABLE_END_MARKER
};
Commit: b4a0418525a1265e94e97b79c7d4609acc85368e
https://github.com/scummvm/scummvm/commit/b4a0418525a1265e94e97b79c7d4609acc85368e
Author: D G Turner (digitall at scummvm.org)
Date: 2021-05-17T15:37:55+02:00
Commit Message:
ASYLUM: Fix Uninitialized Variable Accesses Identified by Valgrind
Changed paths:
engines/asylum/resources/encounters.cpp
engines/asylum/resources/script.cpp
diff --git a/engines/asylum/resources/encounters.cpp b/engines/asylum/resources/encounters.cpp
index d8efe823af..a5d937da1a 100644
--- a/engines/asylum/resources/encounters.cpp
+++ b/engines/asylum/resources/encounters.cpp
@@ -79,7 +79,7 @@ Common::String Encounter::ScriptEntry::toString() {
}
Encounter::Encounter(AsylumEngine *engine) : _vm(engine),
- _index(0), _speechResourceId(0), _item(NULL), _objectId1(kObjectNone), _objectId2(kObjectNone), _objectId3(kObjectNone),
+ _index(0), _speechResourceId(0), _soundResourceId(kResourceNone), _item(NULL), _objectId1(kObjectNone), _objectId2(kObjectNone), _objectId3(kObjectNone),
_actorIndex(kActorInvalid), _shouldEnablePlayer(false), _wasPlayerDisabled(false), _isClosing(false), _isScriptRunning(false) {
memset(&_keywordIndexes, 0, sizeof(_keywordIndexes));
diff --git a/engines/asylum/resources/script.cpp b/engines/asylum/resources/script.cpp
index eb14672a56..57511289f2 100644
--- a/engines/asylum/resources/script.cpp
+++ b/engines/asylum/resources/script.cpp
@@ -293,6 +293,7 @@ void ScriptManager::reset(uint32 count) {
_exit = false;
_processNextEntry = false;
+ _lastProcessedCmd = NULL;
_currentScript = NULL;
_currentQueueEntry = NULL;
}
Commit: c78293e4ce65b5429c413164f21b9eb34a375d9b
https://github.com/scummvm/scummvm/commit/c78293e4ce65b5429c413164f21b9eb34a375d9b
Author: alxpnv (alxpnv22 at yahoo.com)
Date: 2021-05-17T15:37:55+02:00
Commit Message:
ASYLUM: simplify computation of inventory ring points
Changed paths:
engines/asylum/asylum.cpp
engines/asylum/asylum.h
engines/asylum/resources/actor.cpp
engines/asylum/views/scene.cpp
diff --git a/engines/asylum/asylum.cpp b/engines/asylum/asylum.cpp
index 837e33a2d2..877274c849 100644
--- a/engines/asylum/asylum.cpp
+++ b/engines/asylum/asylum.cpp
@@ -21,6 +21,7 @@
*/
#include "common/debug-channels.h"
+#include "common/rect.h"
#include "engines/util.h"
@@ -49,6 +50,21 @@
namespace Asylum {
+// inventory ring is a circle of radius 80 centered at (-20, 20)
+static const int16 inventoryRingPoints[36][2] = {
+ { -20, 100},
+ { -20, 100}, { -20, -60},
+ { -20, 100}, { -89, -20}, { 49, -20},
+ { -20, 100}, {-100, 20}, { -20, -60}, { 60, 20},
+ { -20, 100}, { -96, 45}, { -67, -45}, { 27, -45}, { 56, 45},
+ { -20, 100}, { -89, 60}, { -89, -20}, { -20, -60}, { 49, -20}, { 49, 60},
+ { -20, 100}, { -82, 70}, { -98, 3}, { -56, -51}, { 13, -53}, { 57, -1}, { 45, 67},
+ { -20, 100}, { -77, 77}, {-100, 20}, { -77, -37}, { -20, -60}, { 37, -37}, { 60, 20}, { 37, 77}
+};
+
+// first 8 triangular numbers
+static const uint32 inventoryRingOffsets[8] = {0, 1, 3, 6, 10, 15, 21, 28};
+
AsylumEngine::AsylumEngine(OSystem *system, const ADGameDescription *gd) : Engine(system), _gameDescription(gd),
_console(NULL), _cursor(NULL), _encounter(NULL), _menu(NULL), _reaction(NULL), _resource(NULL), _savegame(NULL),
_scene(NULL), _screen(NULL), _script(NULL), _special(NULL), _speech(NULL), _sound(NULL), _text(NULL),
@@ -56,7 +72,6 @@ AsylumEngine::AsylumEngine(OSystem *system, const ADGameDescription *gd) : Engin
// Init data
memset(&_gameFlags, 0, sizeof(_gameFlags));
- memset(&_sinCosTables, 0, sizeof(_sinCosTables));
_introPlayed = false;
_tickOffset = 0;
@@ -147,9 +162,6 @@ Common::Error AsylumEngine::run() {
_text = new Text(this);
_video = new VideoPlayer(this, _mixer);
- // Init tables
- initSinCosTables(80.0, 40, 40);
-
// Create main menu
_menu = new Menu(this);
_handler = _menu;
@@ -504,62 +516,17 @@ void AsylumEngine::notify(AsylumEventType type, int32 param1, int32 param2) {
_handler->handleEvent(evt);
}
-
-void AsylumEngine::initSinCosTables(double a2, int32 a3, int32 a4) {
- uint32 offset = 0;
- uint32 baseStep = 1;
-
- do {
- if (baseStep >= 1) {
- uint32 baseAngle = 90;
- int32 step = baseStep;
-
- int16 *val = &_sinCosTables[2 * offset];
-
- do {
- double angle = (double)(baseAngle % 360) * 3.141592653589 * 0.005555555555555556;
-
- *val = (int16)(cos(angle) * a2 - (a3 / 2.0));
- *(val + 1) = (int16)(sin(angle) * a2 + (a4 / 2.0));
-
- baseAngle += 360 / baseStep;
- val += 2;
- --step;
- } while (step);
-
- offset += baseStep;
- }
-
- ++baseStep;
-
- } while (baseStep <= 8);
-}
-
-int32 AsylumEngine::computeSinCosOffset(int32 val) const {
- int32 offset = 0;
- for (int32 i = val; i > 0; --i)
- offset += i;
-
- return offset - val;
-}
-
-Common::Point AsylumEngine::getSinCosValues(int32 index1, int32 index2) const {
+Common::Point AsylumEngine::getInventoryRingPoint(uint32 nPoints, uint32 index) const {
if (!_scene)
- error("[AsylumEngine::getSinCosValues] Subsystems not initialized properly!");
-
- Common::Point values;
-
- if (_scene->worldstats()->chapter == kChapter11) {
- int32 offset = computeSinCosOffset(8) + index2 + 3;
- values.x = _sinCosTables[2 * offset];
- values.y = _sinCosTables[2 * offset + 1];
- } else {
- int32 offset = computeSinCosOffset(index1) + index2;
- values.x = _sinCosTables[2 * offset];
- values.y = _sinCosTables[2 * offset + 1];
- }
+ error("[AsylumEngine::getInventoryRingPoint] Subsystems not initialized properly!");
+
+ const int16 (*pointPtr)[2];
+ if (_scene->worldstats()->chapter == kChapter11)
+ pointPtr = &inventoryRingPoints[inventoryRingOffsets[7] + index + 3];
+ else
+ pointPtr = &inventoryRingPoints[inventoryRingOffsets[nPoints - 1] + index];
- return values;
+ return Common::Point((*pointPtr)[0], (*pointPtr)[1]);
}
void AsylumEngine::updateReverseStereo() {
diff --git a/engines/asylum/asylum.h b/engines/asylum/asylum.h
index 74a6ea963a..4035b2ec8c 100644
--- a/engines/asylum/asylum.h
+++ b/engines/asylum/asylum.h
@@ -188,14 +188,14 @@ public:
void updateReverseStereo();
/**
- * Gets a sine cosine pair.
+ * Gets an inventory ring point
*
- * @param index1 The first index.
- * @param index2 The second index.
+ * @param nPoints Number of Points
+ * @param index Point index
*
- * @return The sine cosine values.
+ * @return Inventory ring point
*/
- Common::Point getSinCosValues(int32 index1, int32 index2) const;
+ Common::Point getInventoryRingPoint(uint32 nPoints, uint32 index) const;
// Serializable
void saveLoadWithSerializer(Common::Serializer &s);
@@ -230,7 +230,6 @@ private:
Puzzles *_puzzles;
SharedData _data;
int _gameFlags[130];
- int16 _sinCosTables[72];
bool _introPlayed;
int32 _tickOffset;
@@ -242,21 +241,6 @@ private:
*/
void playIntro();
- /**
- * Initializes the sine/cosine tables.
- */
- void initSinCosTables(double a2, int32 a3, int32 a4);
-
- /**
- * Calculate the offset into the sine/cosine tables.
- *
- * @param val The value.
- *
- * @return The calculated offset.
- */
- int32 computeSinCosOffset(int32 val) const;
-
-
// Debug
friend class Console;
Scene *_previousScene;
diff --git a/engines/asylum/resources/actor.cpp b/engines/asylum/resources/actor.cpp
index 15cffa62c2..321baeb3e2 100644
--- a/engines/asylum/resources/actor.cpp
+++ b/engines/asylum/resources/actor.cpp
@@ -2009,8 +2009,8 @@ void Actor::updateAndDraw() {
Common::Point coords;
adjustCoordinates(&coords);
- Common::Point sinCos = _vm->getSinCosValues(count, i);
- Common::Point point = coords + Common::Point(player->getPoint2()->x + sinCos.x, player->getPoint2()->y / 2 - sinCos.y);
+ Common::Point ringPoint = _vm->getInventoryRingPoint(count, i);
+ Common::Point point = coords + Common::Point(player->getPoint2()->x + ringPoint.x, player->getPoint2()->y / 2 - ringPoint.y);
if (mouse.x < point.x || mouse.x > (point.x + 40) || mouse.y < point.y || mouse.y > (point.y + 40)) {
getScreen()->addGraphicToQueue(getWorld()->cursorResourcesAlternate[_reaction[i] + 15],
diff --git a/engines/asylum/views/scene.cpp b/engines/asylum/views/scene.cpp
index 0239123148..8f91f2f210 100644
--- a/engines/asylum/views/scene.cpp
+++ b/engines/asylum/views/scene.cpp
@@ -1687,9 +1687,9 @@ void Scene::playerReaction() {
if (count > 0) {
for (uint32 i = 0; i < count; i++) {
- Common::Point ret = _vm->getSinCosValues(count, i);
- int32 x = point.x + player->getPoint2()->x + ret.x;
- int32 y = point.y + player->getPoint2()->y / 2 - ret.y;
+ Common::Point ringPoint = _vm->getInventoryRingPoint(count, i);
+ int32 x = point.x + player->getPoint2()->x + ringPoint.x;
+ int32 y = point.y + player->getPoint2()->y / 2 - ringPoint.y;
if (mouse.x >= x && mouse.x <= (x + 40) && mouse.y >= y && mouse.y <= (y + 40)) {
// Handle reaction
Commit: c524688f773c314ccddc7434d30ad4fb7f0c6f1f
https://github.com/scummvm/scummvm/commit/c524688f773c314ccddc7434d30ad4fb7f0c6f1f
Author: alxpnv (alxpnv22 at yahoo.com)
Date: 2021-05-17T15:37:55+02:00
Commit Message:
ASYLUM: simplify inventory voice system
Suggested by sev-
Changed paths:
engines/asylum/resources/reaction.cpp
engines/asylum/resources/reaction.h
diff --git a/engines/asylum/resources/reaction.cpp b/engines/asylum/resources/reaction.cpp
index fbcdfd39db..4b8896f7a2 100644
--- a/engines/asylum/resources/reaction.cpp
+++ b/engines/asylum/resources/reaction.cpp
@@ -33,447 +33,38 @@
namespace Asylum {
-Reaction::Reaction(AsylumEngine *engine) : _vm(engine) {}
-
-Reaction::~Reaction() {
- // Zero-out passed pointers
- _vm = NULL;
-}
-
-void Reaction::run(int32 reactionIndex) {
- //debugC(kDebugLevelSound, "[SPEC] Running special function for chapter %d",getWorld()->numChapter);
-
- switch (getWorld()->chapter) {
- default:
- case kChapterNone:
- // Do nothing
- break;
-
- case kChapter1:
- chapter1(reactionIndex);
- break;
-
- case kChapter2:
- chapter2(reactionIndex);
- break;
-
- case kChapter3:
- chapter3(reactionIndex);
- break;
-
- case kChapter4:
- chapter4(reactionIndex);
- break;
-
- case kChapter5:
- chapter5(reactionIndex);
- break;
-
- case kChapter6:
- chapter6(reactionIndex);
- break;
-
- case kChapter7:
- chapter7(reactionIndex);
- break;
-
- case kChapter8:
- chapter8(reactionIndex);
- break;
-
- case kChapter9:
- chapter9(reactionIndex);
- break;
-
- case kChapter10:
- chapter10(reactionIndex);
- break;
-
- case kChapter11:
- chapter11(reactionIndex);
- break;
-
- case kChapter12:
- case kChapter13:
- chapter12(reactionIndex);
- break;
- }
-}
-
-//////////////////////////////////////////////////////////////////////////
-// Reaction functions
-//////////////////////////////////////////////////////////////////////////
-void Reaction::chapter1(int32 reactionIndex) {
- switch (reactionIndex) {
- default:
- play(0);
- break;
-
- case 0:
- play(61);
- break;
-
- case 1:
- play(69);
- break;
-
- case 2:
- play(0);
- break;
- }
-}
-
-void Reaction::chapter2(int32 reactionIndex) {
- switch (reactionIndex) {
- default:
- play(0);
- break;
-
- case 0:
- play(107);
- break;
+static const int32 reactions[12][11] = {
+ { 61, 69, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+ {107, 134, 104, 113, -1, 112, 117, 109, 108, 111, 106},
+ {170, 182, 181, 172, 171, 169, 0, 0, 0, 0, 0},
+ { 61, -1, 66, 67, 68, 69, 70, 78, 77, 0, 0},
+ {197, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+ { 59, 81, 60, 84, 88, 54, 74, 139, 97, 121, 0},
+ {239, 234, 249, 259, 260, 272, 237, 262, 0, 0, 0},
+ { 58, 59, 60, 111, 75, 76, 77, 78, 0, 0, 0},
+ {284, 285, 286, 329, 330, 331, 332, 322, 0, 465, 0},
+ { -1, -1, -1, -1, -1, 0, 0, 0, 0, 0, 0},
+ { 69, 70, 78, 0, 0, 0, 0, 0, 0, 0, 0},
+ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
+};
- case 1:
- play(134);
- break;
+Reaction::Reaction(AsylumEngine *engine) : _vm(engine) {}
- case 2:
- play(104);
- break;
+void Reaction::run(uint32 reactionIndex) {
+ if (getWorld()->chapter == kChapterNone || reactionIndex > 10)
+ return;
- case 3:
- play(113);
- break;
-
- case 4:
+ if (getWorld()->chapter == kChapter2 && reactionIndex == 4)
play(_vm->isGameFlagSet(kGameFlag186) ? 362 : 110);
- break;
-
- case 5:
- play(112);
- break;
-
- case 6:
- play(117);
- break;
-
- case 7:
- play(109);
- break;
-
- case 8:
- play(108);
- break;
-
- case 9:
- play(111);
- break;
-
- case 10:
- play(106);
- break;
- }
-}
-
-void Reaction::chapter3(int32 reactionIndex) {
- switch (reactionIndex) {
- default:
- play(reactionIndex);
- break;
-
- case 0:
- play(170);
- break;
-
- case 1:
- play(182);
- break;
-
- case 2:
- play(181);
- break;
-
- case 3:
- play(172);
- break;
-
- case 4:
- play(171);
- break;
-
- case 5:
- play(169);
- break;
- }
-}
-
-void Reaction::chapter4(int32 reactionIndex) {
- switch (reactionIndex) {
- default:
- play(0);
- break;
-
- case 0:
- play(61);
- break;
-
- case 1:
+ else if (getWorld()->chapter == kChapter4 && reactionIndex == 1)
play((getScene()->getActor()->getNumberValue01() != 1) ? 65 : 64);
- break;
-
- case 2:
- play(66);
- break;
-
- case 3:
- play(67);
- break;
-
- case 4:
- play(68);
- break;
-
- case 5:
- play(69);
- break;
-
- case 6:
- play(70);
- break;
-
- case 7:
- play(78);
- break;
-
- case 8:
- play(77);
- break;
- }
-}
-
-void Reaction::chapter5(int32 reactionIndex) {
- if (reactionIndex)
- play(0);
- else
- play(197);
-}
-
-void Reaction::chapter6(int32 reactionIndex) {
- switch (reactionIndex) {
- default:
- play(0);
- break;
-
- case 0:
- play(59);
- break;
-
- case 1:
- play(81);
- break;
-
- case 2:
- play(60);
- break;
-
- case 3:
- play(84);
- break;
-
- case 4:
- play(88);
- break;
-
- case 5:
- play(54);
- break;
-
- case 6:
- play(74);
- break;
-
- case 7:
- play(139);
- break;
-
- case 8:
- play(97);
- break;
-
- case 9:
- play(121);
- break;
- }
-}
-
-void Reaction::chapter7(int32 reactionIndex) {
- switch (reactionIndex) {
- default:
- play(0);
- break;
-
- case 0:
- play(239);
- break;
-
- case 1:
- play(234);
- break;
-
- case 2:
- play(249);
- break;
-
- case 3:
- play(259);
- break;
-
- case 4:
- play(260);
- break;
-
- case 5:
- play(272);
- break;
-
- case 6:
- play(237);
- break;
-
- case 7:
- play(262);
- break;
- }
-}
-
-void Reaction::chapter8(int32 reactionIndex) {
- switch (reactionIndex) {
- default:
- play(0);
- break;
-
- case 0:
- play(58);
- break;
-
- case 1:
- play(59);
- break;
-
- case 2:
- play(60);
- break;
-
- case 3:
- play(111);
- break;
-
- case 4:
- play(75);
- break;
-
- case 5:
- play(76);
- break;
-
- case 6:
- play(77);
- break;
-
- case 7:
- play(78);
- break;
- }
-}
-
-void Reaction::chapter9(int32 reactionIndex) {
- switch (reactionIndex) {
- default:
- play(0);
- break;
-
- case 0:
- play(284);
- break;
-
- case 1:
- play(285);
- break;
-
- case 2:
- play(286);
- break;
-
- case 3:
- play(329);
- break;
-
- case 4:
- play(330);
- break;
-
- case 5:
- play(331);
- break;
-
- case 6:
- play(332);
- break;
-
- case 7:
- play(322);
- break;
-
- case 9:
- play(465);
- break;
- }
-}
-
-void Reaction::chapter10(int32 reactionIndex) {
- switch (reactionIndex) {
- default:
- play(0);
- break;
-
- case 0:
- case 1:
- case 2:
- case 3:
- case 4:
+ else if (getWorld()->chapter == kChapter10 && reactionIndex < 5)
play(91 + reactionIndex);
- break;
- }
-}
-
-void Reaction::chapter11(int32 reactionIndex) {
- switch (reactionIndex) {
- default:
- play(0);
- break;
-
- case 0:
- play(69);
- break;
-
- case 1:
- play(70);
- break;
-
- case 2:
- play(78);
- break;
- }
-}
-
-void Reaction::chapter12(int32) {
- play(0);
+ else
+ play(reactions[getWorld()->chapter - 1][reactionIndex]);
}
-//////////////////////////////////////////////////////////////////////////
-// Utils
-//////////////////////////////////////////////////////////////////////////
-void Reaction::play(int32 index) {
+void Reaction::play(uint32 index) {
ResourceId resourceId = kResourceNone;
switch (getWorld()->actorType) {
diff --git a/engines/asylum/resources/reaction.h b/engines/asylum/resources/reaction.h
index 0ccef208ac..0a95e91307 100644
--- a/engines/asylum/resources/reaction.h
+++ b/engines/asylum/resources/reaction.h
@@ -32,33 +32,14 @@ class AsylumEngine;
class Reaction {
public:
Reaction(AsylumEngine *engine);
- virtual ~Reaction();
+ virtual ~Reaction() {};
- void run(int32 reactionIndex);
+ void run(uint32 reactionIndex);
private:
AsylumEngine* _vm;
- //////////////////////////////////////////////////////////////////////////
- // Reaction functions
- //////////////////////////////////////////////////////////////////////////
- void chapter1(int32 reactionIndex);
- void chapter2(int32 reactionIndex);
- void chapter3(int32 reactionIndex);
- void chapter4(int32 reactionIndex);
- void chapter5(int32 reactionIndex);
- void chapter6(int32 reactionIndex);
- void chapter7(int32 reactionIndex);
- void chapter8(int32 reactionIndex);
- void chapter9(int32 reactionIndex);
- void chapter10(int32 reactionIndex);
- void chapter11(int32 reactionIndex);
- void chapter12(int32 reactionIndex);
-
- //////////////////////////////////////////////////////////////////////////
- // Utils
- //////////////////////////////////////////////////////////////////////////
- void play(int32 index);
+ void play(uint32 index);
};
} // End of namespace Asylum
Commit: 408a85436a8d49cb077900345bfc0af7aadb986b
https://github.com/scummvm/scummvm/commit/408a85436a8d49cb077900345bfc0af7aadb986b
Author: alxpnv (alxpnv22 at yahoo.com)
Date: 2021-05-17T15:37:55+02:00
Commit Message:
ASYLUM: (Hive Machine puzzle) get rid of the polygons previously used for hit testing
Requested by sev-
Changed paths:
engines/asylum/puzzles/hivemachine.cpp
engines/asylum/puzzles/hivemachine.h
diff --git a/engines/asylum/puzzles/hivemachine.cpp b/engines/asylum/puzzles/hivemachine.cpp
index 71c3541a37..75ce4a19e0 100644
--- a/engines/asylum/puzzles/hivemachine.cpp
+++ b/engines/asylum/puzzles/hivemachine.cpp
@@ -59,105 +59,6 @@ PuzzleHiveMachine::PuzzleHiveMachine(AsylumEngine *engine) : Puzzle(engine) {
_soundingNote = kMusicalNoteNone;
_notesNumber = 0;
_ok = false;
-
- _polygons[0].points.push_back(Common::Point(306, 108));
- _polygons[0].points.push_back(Common::Point(334, 111));
- _polygons[0].points.push_back(Common::Point(340, 112));
- _polygons[0].points.push_back(Common::Point(346, 120));
- _polygons[0].points.push_back(Common::Point(352, 127));
- _polygons[0].points.push_back(Common::Point(371, 142));
- _polygons[0].points.push_back(Common::Point(363, 160));
- _polygons[0].points.push_back(Common::Point(363, 172));
- _polygons[0].points.push_back(Common::Point(362, 182));
- _polygons[0].points.push_back(Common::Point(363, 190));
- _polygons[0].points.push_back(Common::Point(348, 202));
- _polygons[0].points.push_back(Common::Point(318, 210));
- _polygons[0].points.push_back(Common::Point(292, 194));
- _polygons[0].points.push_back(Common::Point(278, 193));
- _polygons[0].points.push_back(Common::Point(268, 180));
- _polygons[0].points.push_back(Common::Point(270, 162));
- _polygons[0].points.push_back(Common::Point(266, 152));
- _polygons[0].points.push_back(Common::Point(273, 137));
- _polygons[0].points.push_back(Common::Point(283, 120));
-
- _polygons[1].points.push_back(Common::Point(436, 171));
- _polygons[1].points.push_back(Common::Point(464, 181));
- _polygons[1].points.push_back(Common::Point(482, 201));
- _polygons[1].points.push_back(Common::Point(472, 228));
- _polygons[1].points.push_back(Common::Point(473, 245));
- _polygons[1].points.push_back(Common::Point(460, 262));
- _polygons[1].points.push_back(Common::Point(452, 262));
- _polygons[1].points.push_back(Common::Point(416, 244));
- _polygons[1].points.push_back(Common::Point(403, 231));
- _polygons[1].points.push_back(Common::Point(378, 220));
- _polygons[1].points.push_back(Common::Point(379, 215));
- _polygons[1].points.push_back(Common::Point(387, 201));
- _polygons[1].points.push_back(Common::Point(405, 177));
-
- _polygons[2].points.push_back(Common::Point(357, 249));
- _polygons[2].points.push_back(Common::Point(368, 252));
- _polygons[2].points.push_back(Common::Point(407, 277));
- _polygons[2].points.push_back(Common::Point(415, 283));
- _polygons[2].points.push_back(Common::Point(422, 294));
- _polygons[2].points.push_back(Common::Point(413, 314));
- _polygons[2].points.push_back(Common::Point(413, 324));
- _polygons[2].points.push_back(Common::Point(406, 337));
- _polygons[2].points.push_back(Common::Point(386, 343));
- _polygons[2].points.push_back(Common::Point(368, 350));
- _polygons[2].points.push_back(Common::Point(354, 347));
- _polygons[2].points.push_back(Common::Point(335, 347));
- _polygons[2].points.push_back(Common::Point(325, 339));
- _polygons[2].points.push_back(Common::Point(320, 319));
- _polygons[2].points.push_back(Common::Point(325, 308));
- _polygons[2].points.push_back(Common::Point(324, 292));
- _polygons[2].points.push_back(Common::Point(329, 286));
- _polygons[2].points.push_back(Common::Point(341, 272));
- _polygons[2].points.push_back(Common::Point(347, 253));
-
- _polygons[3].points.push_back(Common::Point(247, 249));
- _polygons[3].points.push_back(Common::Point(260, 263));
- _polygons[3].points.push_back(Common::Point(279, 279));
- _polygons[3].points.push_back(Common::Point(298, 290));
- _polygons[3].points.push_back(Common::Point(299, 308));
- _polygons[3].points.push_back(Common::Point(303, 322));
- _polygons[3].points.push_back(Common::Point(294, 337));
- _polygons[3].points.push_back(Common::Point(286, 342));
- _polygons[3].points.push_back(Common::Point(241, 342));
- _polygons[3].points.push_back(Common::Point(232, 338));
- _polygons[3].points.push_back(Common::Point(219, 315));
- _polygons[3].points.push_back(Common::Point(224, 284));
- _polygons[3].points.push_back(Common::Point(224, 267));
-
- _polygons[4].points.push_back(Common::Point(222, 156));
- _polygons[4].points.push_back(Common::Point(231, 164));
- _polygons[4].points.push_back(Common::Point(237, 174));
- _polygons[4].points.push_back(Common::Point(246, 184));
- _polygons[4].points.push_back(Common::Point(258, 187));
- _polygons[4].points.push_back(Common::Point(266, 183));
- _polygons[4].points.push_back(Common::Point(275, 195));
- _polygons[4].points.push_back(Common::Point(261, 198));
- _polygons[4].points.push_back(Common::Point(253, 205));
- _polygons[4].points.push_back(Common::Point(247, 215));
- _polygons[4].points.push_back(Common::Point(243, 232));
- _polygons[4].points.push_back(Common::Point(246, 247));
- _polygons[4].points.push_back(Common::Point(226, 261));
- _polygons[4].points.push_back(Common::Point(202, 247));
- _polygons[4].points.push_back(Common::Point(186, 236));
- _polygons[4].points.push_back(Common::Point(184, 227));
- _polygons[4].points.push_back(Common::Point(175, 217));
- _polygons[4].points.push_back(Common::Point(170, 210));
- _polygons[4].points.push_back(Common::Point(171, 196));
- _polygons[4].points.push_back(Common::Point(175, 186));
- _polygons[4].points.push_back(Common::Point(177, 180));
- _polygons[4].points.push_back(Common::Point(183, 172));
- _polygons[4].points.push_back(Common::Point(201, 158));
- _polygons[4].points.push_back(Common::Point(207, 158));
-
- _polygons[0].boundingRect = Common::Rect(264, 106, 370, 211);
- _polygons[1].boundingRect = Common::Rect(376, 171, 483, 264);
- _polygons[2].boundingRect = Common::Rect(317, 247, 424, 352);
- _polygons[3].boundingRect = Common::Rect(217, 247, 305, 345);
- _polygons[4].boundingRect = Common::Rect(168, 154, 278, 264);
}
PuzzleHiveMachine::~PuzzleHiveMachine() {
@@ -235,9 +136,21 @@ void PuzzleHiveMachine::updateCursor() {
}
int32 PuzzleHiveMachine::findRect() {
- for (uint32 i = 0; i < 5; ++i)
- if (_polygons[i].contains(getCursor()->position()))
- return i;
+ Common::Point mouse = getCursor()->position();
+ GraphicResource resource(_vm);
+
+ for (uint32 i = 0; i < 5; ++i) {
+ resource.load(getWorld()->graphicResourceIds[i + 13]);
+ GraphicFrame *frame = resource.getFrame(0);
+ Common::Point point(mouse.x - keyPoints[i].x, mouse.y - keyPoints[i].y);
+
+ if (frame->getRect().contains(point)) {
+ point.x -= frame->x;
+ point.y -= frame->y;
+ if (frame->surface.getPixel(point.x, point.y))
+ return i;
+ }
+ }
return -1;
}
diff --git a/engines/asylum/puzzles/hivemachine.h b/engines/asylum/puzzles/hivemachine.h
index bf6995aa75..29b2d04425 100644
--- a/engines/asylum/puzzles/hivemachine.h
+++ b/engines/asylum/puzzles/hivemachine.h
@@ -26,7 +26,6 @@
#include "common/array.h"
#include "asylum/puzzles/puzzle.h"
-#include "asylum/resources/polygons.h"
namespace Asylum {
@@ -53,7 +52,6 @@ private:
Common::Array<MusicalNote> _melody;
MusicalNote _soundingNote;
uint32 _notesNumber;
- Polygon _polygons[5];
bool _ok;
//////////////////////////////////////////////////////////////////////////
Commit: bf7755aa29049a9212f400e0f2f7e5ca97d594d8
https://github.com/scummvm/scummvm/commit/bf7755aa29049a9212f400e0f2f7e5ca97d594d8
Author: alxpnv (alxpnv22 at yahoo.com)
Date: 2021-05-17T15:37:56+02:00
Commit Message:
ASYLUM: fix integer overflow in Screen::graphicsSelectionSort()
Changed paths:
engines/asylum/system/screen.cpp
diff --git a/engines/asylum/system/screen.cpp b/engines/asylum/system/screen.cpp
index 4fd926fbc8..9529d978bd 100644
--- a/engines/asylum/system/screen.cpp
+++ b/engines/asylum/system/screen.cpp
@@ -712,6 +712,9 @@ void Screen::clearGraphicsInQueue() {
void Screen::graphicsSelectionSort() {
uint32 maxIdx;
+ if (!_queueItems.size())
+ return;
+
for (uint32 i = 0; i < _queueItems.size() - 1; i++) {
maxIdx = i;
Commit: 139d15347fe77e216391bbfffdb5d6578fac98c4
https://github.com/scummvm/scummvm/commit/139d15347fe77e216391bbfffdb5d6578fac98c4
Author: alxpnv (alxpnv22 at yahoo.com)
Date: 2021-05-17T15:37:56+02:00
Commit Message:
ASYLUM: remove an unused puzzle (Puzzle 11)
Changed paths:
R engines/asylum/puzzles/puzzle11.cpp
R engines/asylum/puzzles/puzzle11.h
engines/asylum/module.mk
engines/asylum/puzzles/puzzles.cpp
diff --git a/engines/asylum/module.mk b/engines/asylum/module.mk
index e466a05c04..30d9e426b1 100644
--- a/engines/asylum/module.mk
+++ b/engines/asylum/module.mk
@@ -16,7 +16,6 @@ MODULE_OBJS := \
puzzles/puzzles.o \
puzzles/tictactoe.o \
puzzles/timemachine.o \
- puzzles/puzzle11.o \
puzzles/vcr.o \
puzzles/wheel.o \
puzzles/writings.o \
diff --git a/engines/asylum/puzzles/puzzle11.cpp b/engines/asylum/puzzles/puzzle11.cpp
deleted file mode 100644
index 1e5b2c5b29..0000000000
--- a/engines/asylum/puzzles/puzzle11.cpp
+++ /dev/null
@@ -1,129 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-#include "asylum/puzzles/puzzle11.h"
-
-#include "asylum/resources/worldstats.h"
-
-#include "asylum/system/cursor.h"
-#include "asylum/system/graphics.h"
-#include "asylum/system/screen.h"
-
-#include "asylum/views/scene.h"
-
-#include "asylum/asylum.h"
-
-
-namespace Asylum {
-
-Puzzle11::Puzzle11(AsylumEngine *engine) : Puzzle(engine) {
- _counter = 0;
- memset(&_frameCounts, 0, sizeof(_frameCounts));
- memset(&_frameIndexes, 0, sizeof(_frameIndexes));
- _data_457298 = false;
- _data_45AA34 = false;
-}
-
-Puzzle11::~Puzzle11() {
-}
-
-void Puzzle11::saveLoadWithSerializer(Common::Serializer &s) {
- s.syncAsUint32LE(_counter);
-
- s.skip(8); // 2 int32 that do not seem to be used
-
- s.syncAsUint32LE(_frameIndexes[0]);
- s.syncAsUint32LE(_frameIndexes[3]);
-
- warning("[Puzzle11::saveLoadWithSerializer] Not implemented");
- s.skip(8);
- s.syncAsUint32LE(_frameIndexes[2]);
- s.skip(4);
- s.syncAsUint32LE(_frameIndexes[1]);
- s.syncAsUint32LE(_frameIndexes[4]);
- s.skip(28);
- s.syncAsUint32LE(_frameIndexes[5]);
- s.syncAsUint32LE(_frameIndexes[6]);
-}
-
-//////////////////////////////////////////////////////////////////////////
-// Event Handling
-//////////////////////////////////////////////////////////////////////////
-bool Puzzle11::init(const AsylumEvent &evt) {
- // FIXME! getPuzzleData()->timeMachineCounter = 0;
-
- getScreen()->setPalette(getWorld()->graphicResourceIds[12]);
- getScreen()->setGammaLevel(getWorld()->graphicResourceIds[12]);
- getCursor()->set(getWorld()->graphicResourceIds[60], -1, kCursorAnimationNone, 7);
-
- _data_45AA34 = false;
-
- _frameCounts[0] = GraphicResource::getFrameCount(_vm, getWorld()->graphicResourceIds[59]);
- _frameCounts[1] = GraphicResource::getFrameCount(_vm, getWorld()->graphicResourceIds[54]);
- _frameCounts[2] = GraphicResource::getFrameCount(_vm, getWorld()->graphicResourceIds[55]);
- _frameCounts[3] = GraphicResource::getFrameCount(_vm, getWorld()->graphicResourceIds[56]);
- _frameCounts[4] = GraphicResource::getFrameCount(_vm, getWorld()->graphicResourceIds[13]);
-
- mouseLeftDown(evt);
-
- return true;
-}
-
-bool Puzzle11::update(const AsylumEvent &) {
- getScreen()->clearGraphicsInQueue();
- getScreen()->draw(getWorld()->graphicResourceIds[11]);
- getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[15], _frameIndexes[0], Common::Point(122, 269), kDrawFlagNone, 0, 1);
- getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[16], _frameIndexes[1], Common::Point(524, 175), kDrawFlagNone, 0, 1);
- getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[18], _frameIndexes[2], Common::Point(359, 61), kDrawFlagNone, 0, 1);
- getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[14], _frameIndexes[3], Common::Point(115, 80), kDrawFlagNone, 0, 1);
- getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[17], _frameIndexes[4], Common::Point(238, 94), kDrawFlagNone, 0, 1);
-
- getScreen()->drawGraphicsInQueue();
- getScreen()->copyBackBufferToScreen();
- warning("[Puzzle11::update] Not implemented!");
-
- return true;
-}
-
-bool Puzzle11::mouseRightDown(const AsylumEvent &) {
- warning("[Puzzle11::mouseUp] Not implemented!");
-
- return false;
-}
-
-bool Puzzle11::mouseLeftUp(const AsylumEvent &) {
- getCursor()->hide();
- getSharedData()->setFlag(kFlag1, true);
- getScreen()->stopPaletteFade(0, 0, 0);
-
- _vm->switchEventHandler(getScene());
-
- return false;
-}
-
-bool Puzzle11::mouseLeftDown(const AsylumEvent &) {
- warning("[Puzzle11::mouseDown] Not implemented!");
-
- return true;
-}
-
-} // End of namespace Asylum
diff --git a/engines/asylum/puzzles/puzzle11.h b/engines/asylum/puzzles/puzzle11.h
deleted file mode 100644
index 7fa7a7774d..0000000000
--- a/engines/asylum/puzzles/puzzle11.h
+++ /dev/null
@@ -1,60 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef ASYLUM_PUZZLES_PUZZLE11_H
-#define ASYLUM_PUZZLES_PUZZLE11_H
-
-#include "asylum/puzzles/puzzle.h"
-
-namespace Asylum {
-
-class AsylumEngine;
-
-class Puzzle11 : public Puzzle {
-public:
- Puzzle11(AsylumEngine *engine);
- ~Puzzle11();
-
- // Serializable
- virtual void saveLoadWithSerializer(Common::Serializer &s);
-
-private:
- uint32 _counter;
- uint32 _frameCounts[5];
- uint32 _frameIndexes[7];
- bool _data_457298;
- bool _data_45AA34;
-
- //////////////////////////////////////////////////////////////////////////
- // Event Handling
- //////////////////////////////////////////////////////////////////////////
- bool init(const AsylumEvent &evt);
- bool update(const AsylumEvent &evt);
- bool key(const AsylumEvent &evt) { return keyExit(evt); }
- bool mouseLeftDown(const AsylumEvent &evt);
- bool mouseLeftUp(const AsylumEvent &evt);
- bool mouseRightDown(const AsylumEvent &evt);
-};
-
-} // End of namespace Asylum
-
-#endif // ASYLUM_PUZZLES_PUZZLE11_H
diff --git a/engines/asylum/puzzles/puzzles.cpp b/engines/asylum/puzzles/puzzles.cpp
index 1de5ce8210..4584f04e34 100644
--- a/engines/asylum/puzzles/puzzles.cpp
+++ b/engines/asylum/puzzles/puzzles.cpp
@@ -32,7 +32,6 @@
#include "asylum/puzzles/lock.h"
#include "asylum/puzzles/morguedoor.h"
#include "asylum/puzzles/pipes.h"
-#include "asylum/puzzles/puzzle11.h"
#include "asylum/puzzles/tictactoe.h"
#include "asylum/puzzles/timemachine.h"
#include "asylum/puzzles/vcr.h"
@@ -84,7 +83,7 @@ void Puzzles::initPuzzles() {
_puzzles[kPuzzleBoardYouth] = new PuzzleBoardYouth(_vm);
_puzzles[kPuzzleBoardKeyHidesTo] = new PuzzleBoardKeyHidesTo(_vm);
_puzzles[kPuzzleWritings] = new PuzzleWritings(_vm);
- _puzzles[kPuzzle11] = new Puzzle11(_vm);
+ _puzzles[kPuzzle11] = NULL;
_puzzles[kPuzzleMorgueDoor] = new PuzzleMorgueDoor(_vm);
_puzzles[kPuzzleClock] = new PuzzleClock(_vm);
_puzzles[kPuzzleTimeMachine] = new PuzzleTimeMachine(_vm);
@@ -104,7 +103,7 @@ void Puzzles::saveLoadWithSerializer(Common::Serializer &s) {
s.skip(8);
_puzzles[kPuzzleBoardKeyHidesTo]->saveLoadWithSerializer(s);
_puzzles[kPuzzleMorgueDoor]->saveLoadWithSerializer(s);
- _puzzles[kPuzzle11]->saveLoadWithSerializer(s);
+ s.skip(80); // skip Puzzle 11
_puzzles[kPuzzleTimeMachine]->saveLoadWithSerializer(s);
_puzzles[kPuzzleClock]->saveLoadWithSerializer(s);
_puzzles[kPuzzleFisherman]->saveLoadWithSerializer(s);
Commit: ec5b6935f886051b925f708a12535e631125929b
https://github.com/scummvm/scummvm/commit/ec5b6935f886051b925f708a12535e631125929b
Author: alxpnv (alxpnv22 at yahoo.com)
Date: 2021-05-17T15:37:56+02:00
Commit Message:
ASYLUM: change return type of PuzzleBoard::updateScreen() to void
Changed paths:
engines/asylum/puzzles/board.cpp
engines/asylum/puzzles/board.h
diff --git a/engines/asylum/puzzles/board.cpp b/engines/asylum/puzzles/board.cpp
index 5d7e6020ca..cbeb60d172 100644
--- a/engines/asylum/puzzles/board.cpp
+++ b/engines/asylum/puzzles/board.cpp
@@ -80,7 +80,7 @@ bool PuzzleBoard::init(const AsylumEvent &) {
return true;
}
-bool PuzzleBoard::updateScreen() {
+void PuzzleBoard::updateScreen() {
getScreen()->clearGraphicsInQueue();
getScreen()->draw(getWorld()->graphicResourceIds[_data.backgroundIndex]);
@@ -88,8 +88,6 @@ bool PuzzleBoard::updateScreen() {
getScreen()->drawGraphicsInQueue();
getScreen()->copyBackBufferToScreen();
-
- return true;
}
bool PuzzleBoard::update(const AsylumEvent &) {
diff --git a/engines/asylum/puzzles/board.h b/engines/asylum/puzzles/board.h
index df08899351..e4974525ad 100644
--- a/engines/asylum/puzzles/board.h
+++ b/engines/asylum/puzzles/board.h
@@ -72,7 +72,7 @@ protected:
//////////////////////////////////////////////////////////////////////////
// Helpers
//////////////////////////////////////////////////////////////////////////
- bool updateScreen();
+ void updateScreen();
int32 findRect();
bool stopSound();
void checkSlots();
@@ -84,7 +84,7 @@ private:
// Event Handling
//////////////////////////////////////////////////////////////////////////
bool init(const AsylumEvent &evt);
- bool activate(const AsylumEvent &evt) { return updateScreen(); }
+ bool activate(const AsylumEvent &evt) { return updateScreen(), true; }
bool update(const AsylumEvent &evt);
virtual bool mouseRightDown(const AsylumEvent &evt);
Commit: 77a35a5c75a7b06d68e5a57f2ebf0230c9e8df93
https://github.com/scummvm/scummvm/commit/77a35a5c75a7b06d68e5a57f2ebf0230c9e8df93
Author: alxpnv (alxpnv22 at yahoo.com)
Date: 2021-05-17T15:37:56+02:00
Commit Message:
ASYLUM: get rid of global constructors
Changed paths:
engines/asylum/asylum.cpp
engines/asylum/asylum.h
engines/asylum/puzzles/board.cpp
engines/asylum/puzzles/board.h
engines/asylum/puzzles/boardkeyhidesto.cpp
engines/asylum/puzzles/boardsalvation.cpp
engines/asylum/puzzles/boardyouth.cpp
engines/asylum/puzzles/clock.cpp
engines/asylum/puzzles/fisherman.cpp
engines/asylum/puzzles/hivemachine.cpp
engines/asylum/puzzles/lock.cpp
engines/asylum/puzzles/pipes.cpp
engines/asylum/puzzles/puzzle.cpp
engines/asylum/puzzles/puzzle.h
engines/asylum/puzzles/tictactoe.cpp
engines/asylum/puzzles/timemachine.cpp
engines/asylum/puzzles/vcr.cpp
engines/asylum/puzzles/vcr.h
engines/asylum/puzzles/wheel.cpp
engines/asylum/resources/actor.cpp
engines/asylum/resources/script.cpp
engines/asylum/resources/special.cpp
engines/asylum/resources/special.h
engines/asylum/staticres.h
engines/asylum/system/savegame.cpp
engines/asylum/system/screen.cpp
engines/asylum/system/screen.h
engines/asylum/views/menu.cpp
diff --git a/engines/asylum/asylum.cpp b/engines/asylum/asylum.cpp
index 877274c849..e413851378 100644
--- a/engines/asylum/asylum.cpp
+++ b/engines/asylum/asylum.cpp
@@ -583,4 +583,11 @@ bool AsylumEngine::isGameFlagNotSet(GameFlag flag) const {
return ((1 << (flag % FLAG_MASK)) & (unsigned int)_gameFlags[flag / 32]) >> (flag % FLAG_MASK) == 0;
}
+//////////////////////////////////////////////////////////////////////////
+// Misc
+//////////////////////////////////////////////////////////////////////////
+bool AsylumEngine::rectContains(const int16 (*rectPtr)[4], const Common::Point &p) const {
+ return ((*rectPtr)[0] <= p.x) && (p.x < (*rectPtr)[2]) && ((*rectPtr)[1] <= p.y) && (p.y < (*rectPtr)[3]);
+}
+
} // namespace Asylum
diff --git a/engines/asylum/asylum.h b/engines/asylum/asylum.h
index 4035b2ec8c..6b52dddbab 100644
--- a/engines/asylum/asylum.h
+++ b/engines/asylum/asylum.h
@@ -24,6 +24,7 @@
#define ASYLUM_ASYLUM_H
#include "common/random.h"
+#include "common/rect.h"
#include "common/scummsys.h"
#include "common/serializer.h"
#include "common/system.h"
@@ -168,6 +169,8 @@ public:
uint getRandom(uint max) { return max ? _rnd->getRandomNumber(max - 1) : 0; }
uint getRandomBit() { return _rnd->getRandomBit(); }
+ bool rectContains(const int16 (*rectPtr)[4], const Common::Point &p) const;
+
/**
* Switch message handler.
*
diff --git a/engines/asylum/puzzles/board.cpp b/engines/asylum/puzzles/board.cpp
index cbeb60d172..3ada19d237 100644
--- a/engines/asylum/puzzles/board.cpp
+++ b/engines/asylum/puzzles/board.cpp
@@ -177,8 +177,8 @@ int32 PuzzleBoard::findRect() {
Common::Point mousePos = getCursor()->position();
for (uint32 i = 0; i < _data.charMapSize; i++) {
- if (mousePos.x >= _data.charMap[i].position.x && mousePos.x < _data.charMap[i].position.x + 12
- && mousePos.y >= _data.charMap[i].position.y && mousePos.y < _data.charMap[i].position.y + 18)
+ if (mousePos.x >= _data.charMap[i].posX && mousePos.x < _data.charMap[i].posX + 12
+ && mousePos.y >= _data.charMap[i].posY && mousePos.y < _data.charMap[i].posY + 18)
if (!_charUsed[i])
return i;
}
diff --git a/engines/asylum/puzzles/board.h b/engines/asylum/puzzles/board.h
index e4974525ad..d3c15ac6fa 100644
--- a/engines/asylum/puzzles/board.h
+++ b/engines/asylum/puzzles/board.h
@@ -40,7 +40,7 @@ public:
struct CharMap {
char character;
- Common::Point position;
+ int16 posX, posY;
};
struct PuzzleData {
diff --git a/engines/asylum/puzzles/boardkeyhidesto.cpp b/engines/asylum/puzzles/boardkeyhidesto.cpp
index 540f6b8a69..8d39459755 100644
--- a/engines/asylum/puzzles/boardkeyhidesto.cpp
+++ b/engines/asylum/puzzles/boardkeyhidesto.cpp
@@ -35,16 +35,16 @@ static const PuzzleBoard::PuzzleData puzzleKeyHidesToData = {
3,
{{5, false}, {6, false}, {7, false}},
10,
- {{'I', Common::Point( 30, 53)},
- {'E', Common::Point(212, 71)},
- {'D', Common::Point( 31, 103)},
- {'H', Common::Point(447, 134)},
- {'S', Common::Point(240, 151)},
- {'E', Common::Point( 95, 167)},
- {'O', Common::Point(372, 182)},
- {'K', Common::Point(210, 215)},
- {'Y', Common::Point(440, 247)},
- {'T', Common::Point(479, 262)}},
+ {{'I', 30, 53},
+ {'E', 212, 71},
+ {'D', 31, 103},
+ {'H', 447, 134},
+ {'S', 240, 151},
+ {'E', 95, 167},
+ {'O', 372, 182},
+ {'K', 210, 215},
+ {'Y', 440, 247},
+ {'T', 479, 262}},
true,
"K E Y H I D E S T O "
};
diff --git a/engines/asylum/puzzles/boardsalvation.cpp b/engines/asylum/puzzles/boardsalvation.cpp
index 933c7583ce..dd8c054e77 100644
--- a/engines/asylum/puzzles/boardsalvation.cpp
+++ b/engines/asylum/puzzles/boardsalvation.cpp
@@ -39,16 +39,16 @@ static const PuzzleBoard::PuzzleData puzzleSalvationData = {
3,
{{0, false}, {1, false}, {2, false}},
9,
- {{'I', Common::Point( 61, 53)},
- {'S', Common::Point(322, 53)},
- {'A', Common::Point(529, 86)},
- {'L', Common::Point(256, 117)},
- {'V', Common::Point(251, 151)},
- {'A', Common::Point( 66, 199)},
- {'T', Common::Point(436, 229)},
- {'O', Common::Point(172, 262)},
- {'N', Common::Point(393, 296)},
- {'\0', Common::Point(0, 0)}},
+ {{'I', 61, 53},
+ {'S', 322, 53},
+ {'A', 529, 86},
+ {'L', 256, 117},
+ {'V', 251, 151},
+ {'A', 66, 199},
+ {'T', 436, 229},
+ {'O', 172, 262},
+ {'N', 393, 296},
+ {'\0', 0, 0}},
false,
"S A L V A T I O N "
};
diff --git a/engines/asylum/puzzles/boardyouth.cpp b/engines/asylum/puzzles/boardyouth.cpp
index dcdacb17ac..428a7ee2c4 100644
--- a/engines/asylum/puzzles/boardyouth.cpp
+++ b/engines/asylum/puzzles/boardyouth.cpp
@@ -35,16 +35,16 @@ static const PuzzleBoard::PuzzleData puzzleYouthData = {
2,
{{3, false}, {4, false}, {0, false}},
8,
- {{'E', Common::Point( 64, 55)},
- {'U', Common::Point( 26, 69)},
- {'T', Common::Point(135, 102)},
- {'O', Common::Point( 57, 134)},
- {'H', Common::Point(417, 152)},
- {'T', Common::Point(223, 181)},
- {'H', Common::Point(497, 198)},
- {'Y', Common::Point(435, 231)},
- {'\0', Common::Point(0, 0)},
- {'\0', Common::Point(0, 0)}},
+ {{'E', 64, 55},
+ {'U', 26, 69},
+ {'T', 135, 102},
+ {'O', 57, 134},
+ {'H', 417, 152},
+ {'T', 223, 181},
+ {'H', 497, 198},
+ {'Y', 435, 231},
+ {'\0', 0, 0},
+ {'\0', 0, 0}},
true,
"T H E Y O U T H "
};
diff --git a/engines/asylum/puzzles/clock.cpp b/engines/asylum/puzzles/clock.cpp
index 8687c8c61b..c23fbf77d4 100644
--- a/engines/asylum/puzzles/clock.cpp
+++ b/engines/asylum/puzzles/clock.cpp
@@ -40,25 +40,11 @@ const uint32 puzzleClockFrameIndexes[28] = {
11, 13, 15, 17, 0, 0, 182, 0
};
-const Common::Point puzzleClockPoints[3] = {
- Common::Point(322, 187),
- Common::Point(267, 109),
- Common::Point(274, 124)
-};
-
-const Common::Rect puzzleClockRects[12] = {
- Common::Rect(354, 121, 373, 142),
- Common::Rect(384, 119, 405, 146),
- Common::Rect(405, 135, 424, 160),
- Common::Rect(404, 168, 425, 193),
- Common::Rect(389, 205, 410, 236),
- Common::Rect(359, 240, 383, 270),
- Common::Rect(325, 255, 341, 284),
- Common::Rect(294, 253, 313, 284),
- Common::Rect(277, 237, 294, 264),
- Common::Rect(273, 201, 301, 235),
- Common::Rect(290, 168, 315, 195),
- Common::Rect(315, 133, 344, 162)
+const int16 puzzleClockRects[12][4] = {
+ {354, 121, 373, 142}, {384, 119, 405, 146}, {405, 135, 424, 160},
+ {404, 168, 425, 193}, {389, 205, 410, 236}, {359, 240, 383, 270},
+ {325, 255, 341, 284}, {294, 253, 313, 284}, {277, 237, 294, 264},
+ {273, 201, 301, 235}, {290, 168, 315, 195}, {315, 133, 344, 162}
};
PuzzleClock::PuzzleClock(AsylumEngine *engine) : Puzzle(engine) {
@@ -104,12 +90,12 @@ bool PuzzleClock::update(const AsylumEvent &evt) {
getScreen()->clearGraphicsInQueue();
getScreen()->draw(getWorld()->graphicResourceIds[5]);
- getScreen()->draw(getWorld()->graphicResourceIds[2], _frameIndexes[0], puzzleClockPoints[0]);
+ getScreen()->draw(getWorld()->graphicResourceIds[2], _frameIndexes[0], Common::Point(322, 187));
_frameIndexes[0]++;
_frameIndexes[0] %= GraphicResource::getFrameCount(_vm, getWorld()->graphicResourceIds[2]);
- getScreen()->draw(getWorld()->graphicResourceIds[4], _frameIndexes[1], puzzleClockPoints[1]);
- getScreen()->draw(getWorld()->graphicResourceIds[3], _frameIndexes[2], puzzleClockPoints[2]);
+ getScreen()->draw(getWorld()->graphicResourceIds[4], _frameIndexes[1], Common::Point(267, 109));
+ getScreen()->draw(getWorld()->graphicResourceIds[3], _frameIndexes[2], Common::Point(274, 124));
if (_currentFrameIndex == _frameIndexes[2]) {
if (_showCursor) {
@@ -177,7 +163,7 @@ void PuzzleClock::updateCursor() {
int32 PuzzleClock::findRect() {
for (uint32 i = 0; i < ARRAYSIZE(puzzleClockRects); i++) {
- if (puzzleClockRects[i].contains(getCursor()->position()))
+ if (_vm->rectContains(&puzzleClockRects[i], getCursor()->position()))
return i;
}
diff --git a/engines/asylum/puzzles/fisherman.cpp b/engines/asylum/puzzles/fisherman.cpp
index ed37d7795b..e38227214f 100644
--- a/engines/asylum/puzzles/fisherman.cpp
+++ b/engines/asylum/puzzles/fisherman.cpp
@@ -33,15 +33,15 @@
namespace Asylum {
-const Common::Point puzzleFishermanPolygons[31] = {
- Common::Point( 10, 53), Common::Point(113, 52), Common::Point(222, 46), Common::Point(328, 51),
- Common::Point(426, 51), Common::Point(523, 49), Common::Point(277, 398), Common::Point( 30, 44),
- Common::Point(112, 44), Common::Point( 93, 400), Common::Point( 0, 400), Common::Point(130, 44),
- Common::Point(210, 44), Common::Point(201, 400), Common::Point(112, 400), Common::Point(224, 44),
- Common::Point(315, 44), Common::Point(309, 400), Common::Point(219, 400), Common::Point(326, 44),
- Common::Point(411, 44), Common::Point(415, 400), Common::Point(326, 400), Common::Point(422, 44),
- Common::Point(506, 44), Common::Point(526, 400), Common::Point(434, 400), Common::Point(523, 44),
- Common::Point(607, 44), Common::Point(640, 400), Common::Point(545, 400)
+const int16 puzzleFishermanPolygons[31][2] = {
+ { 10, 53}, {113, 52}, {222, 46}, {328, 51},
+ {426, 51}, {523, 49}, {277, 398}, { 30, 44},
+ {112, 44}, { 93, 400}, { 0, 400}, {130, 44},
+ {210, 44}, {201, 400}, {112, 400}, {224, 44},
+ {315, 44}, {309, 400}, {219, 400}, {326, 44},
+ {411, 44}, {415, 400}, {326, 400}, {422, 44},
+ {506, 44}, {526, 400}, {434, 400}, {523, 44},
+ {607, 44}, {640, 400}, {545, 400}
};
PuzzleFisherman::PuzzleFisherman(AsylumEngine *engine) : Puzzle(engine) {
@@ -98,7 +98,7 @@ bool PuzzleFisherman::update(const AsylumEvent &) {
// Draw 7 graphics
for (uint32 i = 0; i < 6; i++) {
if (_state[i])
- getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[40 + i], 0, puzzleFishermanPolygons[i], kDrawFlagNone, 0, 1);
+ getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[40 + i], 0, &puzzleFishermanPolygons[i], kDrawFlagNone, 0, 1);
}
getScreen()->drawGraphicsInQueue();
@@ -151,10 +151,10 @@ bool PuzzleFisherman::mouseLeftDown(const AsylumEvent &evt) {
}
}
- if (puzzleFishermanPolygons[6].x < evt.mouse.x
- && puzzleFishermanPolygons[6].y < evt.mouse.y
- && puzzleFishermanPolygons[6].x + 70 > evt.mouse.x
- && puzzleFishermanPolygons[6].y + 30 > evt.mouse.y) {
+ if (puzzleFishermanPolygons[6][0] < evt.mouse.x
+ && puzzleFishermanPolygons[6][1] < evt.mouse.y
+ && puzzleFishermanPolygons[6][0] + 70 > evt.mouse.x
+ && puzzleFishermanPolygons[6][1] + 30 > evt.mouse.y) {
getSound()->playSound(getWorld()->graphicResourceIds[10], false, Config.sfxVolume - 10);
for (uint32 i = 0; i < 6; i++)
@@ -203,10 +203,10 @@ void PuzzleFisherman::updateCursor() {
if (found)
return;
- if (puzzleFishermanPolygons[6].x >= mousePos.x
- || puzzleFishermanPolygons[6].y >= mousePos.y
- || puzzleFishermanPolygons[6].x + 70 <= mousePos.x
- || puzzleFishermanPolygons[6].y + 30 <= mousePos.y) {
+ if (puzzleFishermanPolygons[6][0] >= mousePos.x
+ || puzzleFishermanPolygons[6][1] >= mousePos.y
+ || puzzleFishermanPolygons[6][0] + 70 <= mousePos.x
+ || puzzleFishermanPolygons[6][1] + 30 <= mousePos.y) {
if (getCursor()->getAnimation() != kCursorAnimationNone)
getCursor()->set(getWorld()->graphicResourceIds[47], -1, kCursorAnimationNone, 7);
else if (getCursor()->getAnimation() != kCursorAnimationMirror)
diff --git a/engines/asylum/puzzles/hivemachine.cpp b/engines/asylum/puzzles/hivemachine.cpp
index 75ce4a19e0..a8c64ef84c 100644
--- a/engines/asylum/puzzles/hivemachine.cpp
+++ b/engines/asylum/puzzles/hivemachine.cpp
@@ -34,21 +34,12 @@
namespace Asylum {
-const Common::Point keyPoints[] = {
- Common::Point(246, 106),
- Common::Point(377, 171),
- Common::Point(319, 250),
- Common::Point(220, 249),
- Common::Point(167, 154)
+const int16 keyPoints[5][2] = {
+ {246, 106}, {377, 171}, {319, 250}, {220, 249}, {167, 154}
};
-const Common::Point indicatorPoints[] = {
- Common::Point(260, 410),
- Common::Point(279, 411),
- Common::Point(298, 411),
- Common::Point(318, 412),
- Common::Point(338, 413),
- Common::Point(358, 413)
+const int16 indicatorPoints[6][2] = {
+ {260, 410}, {279, 411}, {298, 411}, {318, 412}, {338, 413}, {358, 413}
};
PuzzleHiveMachine::PuzzleHiveMachine(AsylumEngine *engine) : Puzzle(engine) {
@@ -142,7 +133,7 @@ int32 PuzzleHiveMachine::findRect() {
for (uint32 i = 0; i < 5; ++i) {
resource.load(getWorld()->graphicResourceIds[i + 13]);
GraphicFrame *frame = resource.getFrame(0);
- Common::Point point(mouse.x - keyPoints[i].x, mouse.y - keyPoints[i].y);
+ Common::Point point(mouse.x - keyPoints[i][0], mouse.y - keyPoints[i][1]);
if (frame->getRect().contains(point)) {
point.x -= frame->x;
@@ -186,7 +177,7 @@ void PuzzleHiveMachine::updateScreen() {
frameIndex = _frameIndex1;
} else
frameIndex = _frameIndex;
- getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[resourceId], frameIndex, keyPoints[i], kDrawFlagNone, 0, 1);
+ getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[resourceId], frameIndex, &keyPoints[i], kDrawFlagNone, 0, 1);
}
if (_counterKey)
@@ -197,7 +188,7 @@ void PuzzleHiveMachine::updateScreen() {
}
for (uint32 i = 0; i < _notesNumber; ++i)
- getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[84], 0, indicatorPoints[i], kDrawFlagNone, 0, 1);
+ getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[84], 0, &indicatorPoints[i], kDrawFlagNone, 0, 1);
_frameIndex = (_frameIndex + 1) % GraphicResource::getFrameCount(_vm, getWorld()->graphicResourceIds[13]);
if (_counterKey)
diff --git a/engines/asylum/puzzles/lock.cpp b/engines/asylum/puzzles/lock.cpp
index 1813dfe4bc..8e7849fec8 100644
--- a/engines/asylum/puzzles/lock.cpp
+++ b/engines/asylum/puzzles/lock.cpp
@@ -34,11 +34,11 @@
namespace Asylum {
-const Common::Point puzzleLockPolygons[16] = {
- Common::Point(159, 293), Common::Point(151, 318), Common::Point(179, 322), Common::Point(185, 298),
- Common::Point(212, 303), Common::Point(207, 327), Common::Point(234, 332), Common::Point(239, 308),
- Common::Point(149, 333), Common::Point(146, 365), Common::Point(172, 369), Common::Point(176, 338),
- Common::Point(202, 345), Common::Point(200, 375), Common::Point(226, 379), Common::Point(231, 347)
+const int16 puzzleLockPolygons[16][2] = {
+ {159, 293}, {151, 318}, {179, 322}, {185, 298},
+ {212, 303}, {207, 327}, {234, 332}, {239, 308},
+ {149, 333}, {146, 365}, {172, 369}, {176, 338},
+ {202, 345}, {200, 375}, {226, 379}, {231, 347}
};
PuzzleLock::PuzzleLock(AsylumEngine *engine) : Puzzle(engine) {
diff --git a/engines/asylum/puzzles/pipes.cpp b/engines/asylum/puzzles/pipes.cpp
index 46b7dcb10c..ecb51e1f8d 100644
--- a/engines/asylum/puzzles/pipes.cpp
+++ b/engines/asylum/puzzles/pipes.cpp
@@ -36,74 +36,27 @@
namespace Asylum {
-const Common::Point connectorPoints[] = {
- Common::Point(158, 59),
- Common::Point(163, 172),
- Common::Point(168, 272),
-
- Common::Point(202, 59),
- Common::Point(205, 132),
- Common::Point(206, 172),
-
- Common::Point(271, 60),
- Common::Point(272, 131),
- Common::Point(273, 262),
-
- Common::Point(318, 169),
- Common::Point(319, 206),
- Common::Point(318, 261),
-
- Common::Point(380, 72),
- Common::Point(360, 171),
- Common::Point(360, 206),
-
- Common::Point(428, 172),
- Common::Point(401, 242),
- Common::Point(399, 295),
-
- Common::Point(469, 119),
- Common::Point(466, 171),
- Common::Point(460, 294),
+const int16 connectorPoints[21][2] = {
+ {158, 59}, {163, 172}, {168, 272},
+ {202, 59}, {205, 132}, {206, 172},
+ {271, 60}, {272, 131}, {273, 262},
+ {318, 169}, {319, 206}, {318, 261},
+ {380, 72}, {360, 171}, {360, 206},
+ {428, 172}, {401, 242}, {399, 295},
+ {469, 119}, {466, 171}, {460, 294},
};
-const Common::Point peepholePoints[] = {
- Common::Point(140, 65),
- Common::Point(311, 44),
- Common::Point(387, 48),
- Common::Point(475, 72),
- Common::Point(189, 67),
- Common::Point(246, 66),
- Common::Point(169, 113),
- Common::Point(215, 106),
- Common::Point(280, 105),
- Common::Point(336, 95),
- Common::Point(434, 80),
- Common::Point(248, 136),
- Common::Point(303, 154),
- Common::Point(407, 125),
- Common::Point(470, 151),
- Common::Point(193, 180),
- Common::Point(347, 176),
- Common::Point(401, 177),
- Common::Point(245, 201),
- Common::Point(325, 196),
- Common::Point(347, 212),
- Common::Point(406, 213),
- Common::Point(431, 218),
- Common::Point(174, 228),
- Common::Point(217, 234),
- Common::Point(280, 227),
- Common::Point(325, 239),
- Common::Point(370, 244),
- Common::Point(467, 239),
- Common::Point(303, 267),
- Common::Point(405, 273),
- Common::Point(356, 293),
- Common::Point(436, 294),
- Common::Point(182, 317),
- Common::Point(277, 299),
- Common::Point(324, 291),
- Common::Point(461, 323)
+static const int16 peepholePoints[37][2] = {
+ {140, 65}, {311, 44}, {387, 48}, {475, 72},
+ {189, 67}, {246, 66}, {169, 113}, {215, 106},
+ {280, 105}, {336, 95}, {434, 80}, {248, 136},
+ {303, 154}, {407, 125}, {470, 151}, {193, 180},
+ {347, 176}, {401, 177}, {245, 201}, {325, 196},
+ {347, 212}, {406, 213}, {431, 218}, {174, 228},
+ {217, 234}, {280, 227}, {325, 239}, {370, 244},
+ {467, 239}, {303, 267}, {405, 273}, {356, 293},
+ {436, 294}, {182, 317}, {277, 299}, {324, 291},
+ {461, 323}
};
const uint32 peepholeResources[] = {15, 15, 15, 15, 32, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 32, 32, 15,
@@ -376,7 +329,7 @@ bool PuzzlePipes::update(const AsylumEvent &) {
getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[1], 0, Common::Point(0, 0), kDrawFlagNone, 0, 4);
for (uint32 i = 0; i < ARRAYSIZE(_connectors); ++i)
- getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[_connectorResources[_connectors[i].getState()]], 0, connectorPoints[i], kDrawFlagNone, 0, 1);
+ getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[_connectorResources[_connectors[i].getState()]], 0, &connectorPoints[i], kDrawFlagNone, 0, 1);
uint32 filled = 0;
for (uint32 i = 0; i < 4; ++i) {
@@ -396,7 +349,7 @@ bool PuzzlePipes::update(const AsylumEvent &) {
_frameIndex = (_frameIndex + 1) % GraphicResource::getFrameCount(_vm, getWorld()->graphicResourceIds[15]);
for (uint32 i = 0; i < ARRAYSIZE(_peepholes); ++i)
if (_peepholes[i].isConnected())
- getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[peepholeResources[i]], _frameIndex, peepholePoints[i], kDrawFlagNone, 0, 1);
+ getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[peepholeResources[i]], _frameIndex, &peepholePoints[i], kDrawFlagNone, 0, 1);
getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[2], _frameIndexLever, Common::Point(540, 90), kDrawFlagNone, 0, 1);
_isLeverReady = false;
@@ -599,7 +552,7 @@ void PuzzlePipes::updateCursor() {
int32 PuzzlePipes::findRect() {
for (uint32 i = 0; i < ARRAYSIZE(connectorPoints); ++i)
- if (Common::Rect(connectorPoints[i].x - 5, connectorPoints[i].y - 5, connectorPoints[i].x + 30, connectorPoints[i].y + 30).contains(getCursor()->position()))
+ if (Common::Rect(connectorPoints[i][0] - 5, connectorPoints[i][1] - 5, connectorPoints[i][0] + 30, connectorPoints[i][1] + 30).contains(getCursor()->position()))
return i;
for (uint32 i = 0; i < _spiders.size(); ++i)
diff --git a/engines/asylum/puzzles/puzzle.cpp b/engines/asylum/puzzles/puzzle.cpp
index d3d23c4c3c..25c13e62b1 100644
--- a/engines/asylum/puzzles/puzzle.cpp
+++ b/engines/asylum/puzzles/puzzle.cpp
@@ -120,16 +120,20 @@ void Puzzle::exitPuzzle() {
//////////////////////////////////////////////////////////////////////////
// Hit test functions
//////////////////////////////////////////////////////////////////////////
-bool Puzzle::hitTest(const Common::Point *polygonPoint, const Common::Point &point, uint32 index) const {
- Polygon polygon(polygonPoint[index], polygonPoint[index + 1], polygonPoint[index + 2], polygonPoint[index + 3]);
- return polygon.contains(point);
-}
+bool Puzzle::hitTest(const int16 (*polygonPoint)[2], const Common::Point &point, uint32 index) const {
+ Common::Point p1(polygonPoint[index + 0][0], polygonPoint[index + 0][1]),
+ p2(polygonPoint[index + 1][0], polygonPoint[index + 1][1]),
+ p3(polygonPoint[index + 2][0], polygonPoint[index + 2][1]),
+ p4(polygonPoint[index + 3][0], polygonPoint[index + 3][1]);
-bool Puzzle::hitTest(const Common::Point *polygonPoint, const Common::Point &point) const {
- Polygon polygon(polygonPoint[0], polygonPoint[1], polygonPoint[2], polygonPoint[3]);
+ Polygon polygon(p1, p2, p3, p4);
return polygon.contains(point);
}
+bool Puzzle::hitTest(const int16 (*polygonPoint)[2], const Common::Point &point) const {
+ return hitTest(polygonPoint, point, 0);
+}
+
} // end of namespace Asylum
diff --git a/engines/asylum/puzzles/puzzle.h b/engines/asylum/puzzles/puzzle.h
index 3fa2e45271..1217f45a31 100644
--- a/engines/asylum/puzzles/puzzle.h
+++ b/engines/asylum/puzzles/puzzle.h
@@ -70,8 +70,8 @@ protected:
//////////////////////////////////////////////////////////////////////////
// Hit test functions
//////////////////////////////////////////////////////////////////////////
- bool hitTest(const Common::Point *polygonPoint, const Common::Point &point, uint32 index) const;
- bool hitTest(const Common::Point *polygonPoint, const Common::Point &point) const;
+ bool hitTest(const int16 (*polygonPoint)[2], const Common::Point &point, uint32 index) const;
+ bool hitTest(const int16 (*polygonPoint)[2], const Common::Point &point) const;
};
} // End of namespace Asylum
diff --git a/engines/asylum/puzzles/tictactoe.cpp b/engines/asylum/puzzles/tictactoe.cpp
index 5fe6427715..accb845d16 100644
--- a/engines/asylum/puzzles/tictactoe.cpp
+++ b/engines/asylum/puzzles/tictactoe.cpp
@@ -35,28 +35,22 @@ namespace Asylum {
extern int g_debugPolygons;
-const Common::Point puzzleTicTacToePolygons[36] = {
- Common::Point( 27, 381), Common::Point(172, 368), Common::Point(190, 474), Common::Point( 36, 476),
- Common::Point(176, 362), Common::Point(294, 328), Common::Point(331, 456), Common::Point(191, 472),
- Common::Point(304, 327), Common::Point(426, 306), Common::Point(457, 440), Common::Point(340, 460),
- Common::Point( 26, 257), Common::Point(151, 238), Common::Point(169, 356), Common::Point( 27, 373),
- Common::Point(162, 234), Common::Point(275, 214), Common::Point(299, 321), Common::Point(173, 355),
- Common::Point(283, 210), Common::Point(403, 173), Common::Point(437, 294), Common::Point(305, 317),
- Common::Point( 22, 120), Common::Point(132, 126), Common::Point(146, 223), Common::Point( 25, 247),
- Common::Point(144, 119), Common::Point(247, 87), Common::Point(268, 205), Common::Point(159, 222),
- Common::Point(259, 84), Common::Point(380, 73), Common::Point(405, 169), Common::Point(281, 201)
+const int16 puzzleTicTacToePolygons[36][2] = {
+ { 27, 381}, {172, 368}, {190, 474}, { 36, 476},
+ {176, 362}, {294, 328}, {331, 456}, {191, 472},
+ {304, 327}, {426, 306}, {457, 440}, {340, 460},
+ { 26, 257}, {151, 238}, {169, 356}, { 27, 373},
+ {162, 234}, {275, 214}, {299, 321}, {173, 355},
+ {283, 210}, {403, 173}, {437, 294}, {305, 317},
+ { 22, 120}, {132, 126}, {146, 223}, { 25, 247},
+ {144, 119}, {247, 87}, {268, 205}, {159, 222},
+ {259, 84}, {380, 73}, {405, 169}, {281, 201}
};
-const Common::Point puzzleTicTacToePositions[9] = {
- Common::Point( 62, 367),
- Common::Point(193, 343),
- Common::Point(329, 319),
- Common::Point( 38, 247),
- Common::Point(167, 217),
- Common::Point(296, 193),
- Common::Point( 19, 121),
- Common::Point(147, 98),
- Common::Point(269, 70)
+const int16 puzzleTicTacToePositions[9][2] = {
+ { 62, 367}, {193, 343}, {329, 319},
+ { 38, 247}, {167, 217}, {296, 193},
+ { 19, 121}, {147, 98}, {269, 70}
};
static const struct {
@@ -210,17 +204,17 @@ void PuzzleTicTacToe::drawField() {
if (g_debugPolygons) {
for (uint32 p = 0; p < ARRAYSIZE(puzzleTicTacToePolygons) - 4; p += 4) {
- getScreen()->drawLine(puzzleTicTacToePolygons[p], puzzleTicTacToePolygons[p + 1]);
- getScreen()->drawLine(puzzleTicTacToePolygons[p + 1], puzzleTicTacToePolygons[p + 2]);
- getScreen()->drawLine(puzzleTicTacToePolygons[p + 2], puzzleTicTacToePolygons[p + 3]);
- getScreen()->drawLine(puzzleTicTacToePolygons[p + 3], puzzleTicTacToePolygons[p]);
+ getScreen()->drawLine(&puzzleTicTacToePolygons[p], &puzzleTicTacToePolygons[p + 1]);
+ getScreen()->drawLine(&puzzleTicTacToePolygons[p + 1], &puzzleTicTacToePolygons[p + 2]);
+ getScreen()->drawLine(&puzzleTicTacToePolygons[p + 2], &puzzleTicTacToePolygons[p + 3]);
+ getScreen()->drawLine(&puzzleTicTacToePolygons[p + 3], &puzzleTicTacToePolygons[p]);
}
}
// Draw X & O
for (int32 i = 0; i < ARRAYSIZE(puzzleTicTacToePositions); i++) {
char mark = _gameField[i];
- Common::Point point = puzzleTicTacToePositions[i];
+ Common::Point point = Common::Point(puzzleTicTacToePositions[i][0], puzzleTicTacToePositions[i][1]);
if (_lastMarkedField == i) {
if (mark == 'O')
diff --git a/engines/asylum/puzzles/timemachine.cpp b/engines/asylum/puzzles/timemachine.cpp
index 453769648d..1f05e70423 100644
--- a/engines/asylum/puzzles/timemachine.cpp
+++ b/engines/asylum/puzzles/timemachine.cpp
@@ -34,25 +34,16 @@
namespace Asylum {
-const Common::Rect puzzleTimeMachineRects[10] = {
- Common::Rect( 0, 241, 20, 276),
- Common::Rect( 0, 285, 20, 320),
- Common::Rect(117, 245, 137, 280),
- Common::Rect(117, 284, 137, 319),
- Common::Rect(236, 246, 256, 281),
- Common::Rect(236, 290, 256, 325),
- Common::Rect(356, 245, 376, 280),
- Common::Rect(356, 287, 376, 322),
- Common::Rect(476, 248, 496, 283),
- Common::Rect(475, 290, 495, 325)
+const int16 puzzleTimeMachineRects[10][4] = {
+ { 0, 241, 20, 276}, { 0, 285, 20, 320},
+ {117, 245, 137, 280}, {117, 284, 137, 319},
+ {236, 246, 256, 281}, {236, 290, 256, 325},
+ {356, 245, 376, 280}, {356, 287, 376, 322},
+ {476, 248, 496, 283}, {475, 290, 495, 325}
};
-const Common::Point puzzleTimeMachinePoints[5] = {
- Common::Point(-65, -30),
- Common::Point(-20, -68),
- Common::Point( 25, -106),
- Common::Point( 70, -144),
- Common::Point(115, -182)
+const int16 puzzleTimeMachinePoints[5][2] = {
+ {-65, -30}, {-20, -68}, { 25, -106}, { 70, -144}, {115, -182}
};
PuzzleTimeMachine::PuzzleTimeMachine(AsylumEngine *engine) : Puzzle(engine) {
@@ -105,7 +96,8 @@ void PuzzleTimeMachine::reset() {
_index = -1;
_index2 = 0;
- _point = _newPoint = puzzleTimeMachinePoints[0];
+ _point.x = _newPoint.x = puzzleTimeMachinePoints[0][0];
+ _point.y = _newPoint.y = puzzleTimeMachinePoints[0][1];
}
//////////////////////////////////////////////////////////////////////////
@@ -165,12 +157,12 @@ bool PuzzleTimeMachine::update(const AsylumEvent &) {
// Show all buttons
for (uint32 i = 0; i < ARRAYSIZE(puzzleTimeMachineRects); i += 2) {
if ((uint32)_index != i || _leftButtonClicked)
- getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[44 + i], 0, Common::Point(puzzleTimeMachineRects[i].left, puzzleTimeMachineRects[i].top), kDrawFlagNone, 0, 5);
+ getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[44 + i], 0, Common::Point(puzzleTimeMachineRects[i][0], puzzleTimeMachineRects[i][1]), kDrawFlagNone, 0, 5);
}
for (uint32 i = 1; i < ARRAYSIZE(puzzleTimeMachineRects); i += 2) {
if ((uint32)_index != i || _leftButtonClicked)
- getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[44 + i], 0, Common::Point(puzzleTimeMachineRects[i].left, puzzleTimeMachineRects[i].top), kDrawFlagNone, 0, 5);
+ getScreen()->addGraphicToQueue(getWorld()->graphicResourceIds[44 + i], 0, Common::Point(puzzleTimeMachineRects[i][0], puzzleTimeMachineRects[i][1]), kDrawFlagNone, 0, 5);
}
_leftButtonClicked = true;
@@ -216,7 +208,7 @@ bool PuzzleTimeMachine::mouseLeftDown(const AsylumEvent &evt) {
int32 index = -1;
for (uint32 i = 0; i < ARRAYSIZE(puzzleTimeMachineRects); i++) {
- if (puzzleTimeMachineRects[i].contains(evt.mouse)) {
+ if (_vm->rectContains(&puzzleTimeMachineRects[i], evt.mouse)) {
index = i;
break;
@@ -229,7 +221,8 @@ bool PuzzleTimeMachine::mouseLeftDown(const AsylumEvent &evt) {
getSound()->playSound(getWorld()->soundResourceIds[14]);
if ((_index2 / 2) != (uint32)index / 2) {
getSound()->playSound(getWorld()->soundResourceIds[16]);
- _newPoint = puzzleTimeMachinePoints[index / 2];
+ _newPoint.x = puzzleTimeMachinePoints[index / 2][0];
+ _newPoint.y = puzzleTimeMachinePoints[index / 2][1];
}
if (index % 2)
@@ -256,7 +249,7 @@ bool PuzzleTimeMachine::mouseRightDown(const AsylumEvent &) {
//////////////////////////////////////////////////////////////////////////
void PuzzleTimeMachine::updateCursor() {
for (uint32 i = 0; i < ARRAYSIZE(puzzleTimeMachineRects); i++) {
- if (puzzleTimeMachineRects[i].contains(getCursor()->position())) {
+ if (_vm->rectContains(&puzzleTimeMachineRects[i], getCursor()->position())) {
if (getCursor()->getAnimation() != kCursorAnimationMirror)
getCursor()->set(getWorld()->graphicResourceIds[62], -1, kCursorAnimationMirror, 7);
diff --git a/engines/asylum/puzzles/vcr.cpp b/engines/asylum/puzzles/vcr.cpp
index 53072216ad..2bcae6b815 100644
--- a/engines/asylum/puzzles/vcr.cpp
+++ b/engines/asylum/puzzles/vcr.cpp
@@ -162,8 +162,8 @@ bool PuzzleVCR::mouseLeftDown(const AsylumEvent &evt) {
//////////////////////////////////////////////////////////////////////////
Color jack = getJackOnHand();
if (jack != kNone) {
- if (evt.mouse.x >= (int32)puzzleVCRPolygons[kBlackJack].left && evt.mouse.x <= (int32)puzzleVCRPolygons[kYellowJack].right
- && evt.mouse.y >= (int32)puzzleVCRPolygons[kBlackJack].top && evt.mouse.y <= (int32)puzzleVCRPolygons[kYellowJack].bottom) {
+ if (evt.mouse.x >= (int32)puzzleVCRPolygons[kBlackJack][0] && evt.mouse.x <= (int32)puzzleVCRPolygons[kYellowJack][2]
+ && evt.mouse.y >= (int32)puzzleVCRPolygons[kBlackJack][1] && evt.mouse.y <= (int32)puzzleVCRPolygons[kYellowJack][3]) {
_jacksState[jack] = kOnTable;
getSound()->playSound(getWorld()->graphicResourceIds[50]);
@@ -578,8 +578,7 @@ void PuzzleVCR::updateStopButton() {
// Helpers
//////////////////////////////////////////////////////////////////////////
int PuzzleVCR::inPolygon(const Common::Point &point, int polygonIndex) const {
- return point.x >= puzzleVCRPolygons[polygonIndex].left && point.x <= puzzleVCRPolygons[polygonIndex].right
- && point.y >= puzzleVCRPolygons[polygonIndex].top && point.y <= puzzleVCRPolygons[polygonIndex].bottom;
+ return _vm->rectContains(&puzzleVCRPolygons[polygonIndex], point);
}
PuzzleVCR::Color PuzzleVCR::getJackOnHand() const {
diff --git a/engines/asylum/puzzles/vcr.h b/engines/asylum/puzzles/vcr.h
index d978fd2a39..97fd729c0d 100644
--- a/engines/asylum/puzzles/vcr.h
+++ b/engines/asylum/puzzles/vcr.h
@@ -36,17 +36,17 @@ typedef struct VCRDrawInfo {
Common::Point point;
} VCRDrawInfo;
-const Common::Rect puzzleVCRPolygons[10] = {
- Common::Rect(0x0F7, 0x157, 0x13A, 0x183), // rewind button region
- Common::Rect(0x14B, 0x15C, 0x17B, 0x18B), // stop button region
- Common::Rect(0x18C, 0x161, 0x1D2, 0x18F), // play button region
- Common::Rect(0x1FB, 0x156, 0x233, 0x185), // rec button region
- Common::Rect(0x154, 0x196, 0x173, 0x1AF), // red jack hole region
- Common::Rect(0x19A, 0x19B, 0x1B9, 0x1B3), // yellow jack hole region
- Common::Rect(0x1E3, 0x1A0, 0x202, 0x1BC), // black jack hole region
- Common::Rect(0x0, 0x19B, 0x3C, 0x1E0), // black jack on table region
- Common::Rect(0x4C, 0x1AC, 0x0A0, 0x1E0), // red jack on table region
- Common::Rect(0x0BB, 0x1B7, 0x0F0, 0x1E0) // yellow jack on table region
+const int16 puzzleVCRPolygons[10][4] = {
+ {0x0F7, 0x157, 0x13A, 0x183}, // rewind button region
+ {0x14B, 0x15C, 0x17B, 0x18B}, // stop button region
+ {0x18C, 0x161, 0x1D2, 0x18F}, // play button region
+ {0x1FB, 0x156, 0x233, 0x185}, // rec button region
+ {0x154, 0x196, 0x173, 0x1AF}, // red jack hole region
+ {0x19A, 0x19B, 0x1B9, 0x1B3}, // yellow jack hole region
+ {0x1E3, 0x1A0, 0x202, 0x1BC}, // black jack hole region
+ {0x0, 0x19B, 0x3C, 0x1E0}, // black jack on table region
+ {0x4C, 0x1AC, 0x0A0, 0x1E0}, // red jack on table region
+ {0x0BB, 0x1B7, 0x0F0, 0x1E0} // yellow jack on table region
};
//////////////////////////////////////////////////////////////////////////
diff --git a/engines/asylum/puzzles/wheel.cpp b/engines/asylum/puzzles/wheel.cpp
index 076f5ec5c1..1e129db2fb 100644
--- a/engines/asylum/puzzles/wheel.cpp
+++ b/engines/asylum/puzzles/wheel.cpp
@@ -64,70 +64,19 @@ const uint32 puzzleWheelClockResourceIndexes[16] = {
53
};
-const Common::Point puzzleWheelPoints[56] = {
- Common::Point( 0, 0),
- Common::Point( 0, 0),
- Common::Point( 0, 0),
- Common::Point(250, 254),
- Common::Point(122, 24),
- Common::Point(208, 68), // 5
- Common::Point(238, 160),
- Common::Point(218, 234),
- Common::Point(162, 228),
- Common::Point( 71, 222),
- Common::Point( 22, 165), // 10
- Common::Point( 35, 70),
- Common::Point(278, 0),
- Common::Point(536, 146),
- Common::Point(122, 24),
- Common::Point(208, 68), // 15
- Common::Point(238, 160),
- Common::Point(218, 234),
- Common::Point(162, 228),
- Common::Point( 71, 222),
- Common::Point( 22, 165), // 20
- Common::Point( 35, 70),
- Common::Point(342, 87),
- Common::Point(342, 87),
- Common::Point(342, 87),
- Common::Point(342, 87), // 25
- Common::Point(342, 87),
- Common::Point(342, 87),
- Common::Point(342, 87),
- Common::Point(342, 87),
- Common::Point(358, 268), // 30
- Common::Point(342, 87),
- Common::Point(342, 87),
- Common::Point(342, 87),
- Common::Point(342, 87),
- Common::Point(342, 87), // 35
- Common::Point(342, 87),
- Common::Point(342, 87),
- Common::Point(342, 87),
- Common::Point(342, 87),
- Common::Point(342, 87), // 40
- Common::Point(342, 87),
- Common::Point(342, 87),
- Common::Point(342, 87),
- Common::Point(342, 87),
- Common::Point(342, 87), // 45
- Common::Point(342, 87),
- Common::Point(536, 146),
- Common::Point(406, 106),
- Common::Point(402, 217),
- Common::Point(369, 128), // 50
- Common::Point(368, 197),
- Common::Point(452, 184),
- Common::Point(470, 144),
- Common::Point(442, 116),
- Common::Point(347, 166) // 55
+const int16 puzzleWheelPoints[56][2] = {
+ { 0, 0}, { 0, 0}, { 0, 0}, {250, 254}, {122, 24}, {208, 68}, {238, 160},
+ {218, 234}, {162, 228}, { 71, 222}, { 22, 165}, { 35, 70}, {278, 0}, {536, 146},
+ {122, 24}, {208, 68}, {238, 160}, {218, 234}, {162, 228}, { 71, 222}, { 22, 165},
+ { 35, 70}, {342, 87}, {342, 87}, {342, 87}, {342, 87}, {342, 87}, {342, 87},
+ {342, 87}, {342, 87}, {358, 268}, {342, 87}, {342, 87}, {342, 87}, {342, 87},
+ {342, 87}, {342, 87}, {342, 87}, {342, 87}, {342, 87}, {342, 87}, {342, 87},
+ {342, 87}, {342, 87}, {342, 87}, {342, 87}, {342, 87}, {536, 146}, {406, 106},
+ {402, 217}, {369, 128}, {368, 197}, {452, 184}, {470, 144}, {442, 116}, {347, 166}
};
-const Common::Rect puzzleWheelRects[4] = {
- Common::Rect(425, 268, 491, 407),
- Common::Rect(358, 268, 424, 407),
- Common::Rect(561, 251, 594, 324),
- Common::Rect(280, 276, 310, 400)
+const int16 puzzleWheelRects[4][4] = {
+ {425, 268, 491, 407}, {358, 268, 424, 407}, {561, 251, 594, 324}, {280, 276, 310, 400}
};
PuzzleWheel::PuzzleWheel(AsylumEngine *engine) : Puzzle(engine) {
@@ -186,7 +135,7 @@ bool PuzzleWheel::update(const AsylumEvent &) {
getScreen()->draw(getWorld()->graphicResourceIds[0]);
// Blinking red light
- getScreen()->draw(getWorld()->graphicResourceIds[12], (uint32)_frameIndexes[11], puzzleWheelPoints[12]);
+ getScreen()->draw(getWorld()->graphicResourceIds[12], (uint32)_frameIndexes[11], &puzzleWheelPoints[12]);
_frameIndexes[11] = (_frameIndexes[11] + 1) % (int32)GraphicResource::getFrameCount(_vm, getWorld()->graphicResourceIds[12]);
// Clock
@@ -196,7 +145,7 @@ bool PuzzleWheel::update(const AsylumEvent &) {
getScreen()->draw(getWorld()->graphicResourceIds[_resourceIndex + 22], 0, Common::Point(342, 87));
// Chain
- getScreen()->draw(getWorld()->graphicResourceIds[3], (uint32)_frameIndexes[0], puzzleWheelPoints[3]);
+ getScreen()->draw(getWorld()->graphicResourceIds[3], (uint32)_frameIndexes[0], &puzzleWheelPoints[3]);
// Update chain frame index
if (_moveChain) {
@@ -228,7 +177,7 @@ bool PuzzleWheel::update(const AsylumEvent &) {
pointIndex = 4 + i;
}
- getScreen()->draw(getWorld()->graphicResourceIds[resourceIndex], (uint32)_frameIndexes[frameIndex], puzzleWheelPoints[pointIndex]);
+ getScreen()->draw(getWorld()->graphicResourceIds[resourceIndex], (uint32)_frameIndexes[frameIndex], &puzzleWheelPoints[pointIndex]);
if (_frameIndexes[frameIndex] != (int32)GraphicResource::getFrameCount(_vm, getWorld()->graphicResourceIds[resourceIndex]) - 1)
++_frameIndexes[frameIndex];
@@ -239,7 +188,7 @@ bool PuzzleWheel::update(const AsylumEvent &) {
// Sparks
for (uint32 i = 0; i < 8; i++) {
if (_frameIndexesSparks[i] >= 0) {
- getScreen()->draw(getWorld()->graphicResourceIds[57 + i], (uint32)_frameIndexesSparks[i], puzzleWheelPoints[48 + i]);
+ getScreen()->draw(getWorld()->graphicResourceIds[57 + i], (uint32)_frameIndexesSparks[i], &puzzleWheelPoints[48 + i]);
if (_frameIndexesSparks[i] == (int32)GraphicResource::getFrameCount(_vm, getWorld()->graphicResourceIds[57 + i]) - 1)
_frameIndexesSparks[i] = -1;
@@ -250,9 +199,9 @@ bool PuzzleWheel::update(const AsylumEvent &) {
// Lever
if (_resourceIndexLever == 13)
- getScreen()->draw(getWorld()->graphicResourceIds[_resourceIndexLever], (uint32)_frameIndexes[10], puzzleWheelPoints[13]);
+ getScreen()->draw(getWorld()->graphicResourceIds[_resourceIndexLever], (uint32)_frameIndexes[10], &puzzleWheelPoints[13]);
else if (_resourceIndexLever == 54)
- getScreen()->draw(getWorld()->graphicResourceIds[_resourceIndexLever], (uint32)_frameIndexes[10], puzzleWheelPoints[47]);
+ getScreen()->draw(getWorld()->graphicResourceIds[_resourceIndexLever], (uint32)_frameIndexes[10], &puzzleWheelPoints[47]);
// Update lever frame index
if (_moveLever) {
@@ -276,7 +225,7 @@ bool PuzzleWheel::update(const AsylumEvent &) {
}
// Wheel
- getScreen()->draw(getWorld()->graphicResourceIds[30], _frameIndexWheel, puzzleWheelPoints[30]);
+ getScreen()->draw(getWorld()->graphicResourceIds[30], _frameIndexWheel, &puzzleWheelPoints[30]);
// Update wheel frame index
if (_showTurnedClock) {
@@ -366,7 +315,7 @@ void PuzzleWheel::updateCursor() {
int32 PuzzleWheel::findRect() {
for (uint32 i = 0; i < ARRAYSIZE(puzzleWheelRects); i++) {
- if (puzzleWheelRects[i].contains(getCursor()->position()))
+ if (_vm->rectContains(&puzzleWheelRects[i], getCursor()->position()))
return i;
}
diff --git a/engines/asylum/resources/actor.cpp b/engines/asylum/resources/actor.cpp
index 321baeb3e2..be0fe38c34 100644
--- a/engines/asylum/resources/actor.cpp
+++ b/engines/asylum/resources/actor.cpp
@@ -1698,8 +1698,8 @@ bool Actor::canMove(Common::Point *point, ActorDirection direction, uint32 dista
if (_field_944 == 1 || _field_944 == 4)
return true;
- int16 x = (hasDelta ? point->x : point->x + deltaPointsArray[direction].x);
- int16 y = (hasDelta ? point->y : point->y + deltaPointsArray[direction].y);
+ int16 x = (hasDelta ? point->x : point->x + deltaPointsArray[direction][0]);
+ int16 y = (hasDelta ? point->y : point->y + deltaPointsArray[direction][1]);
// Check scene rect
if (!_field_944) {
@@ -1725,8 +1725,8 @@ bool Actor::canMove(Common::Point *point, ActorDirection direction, uint32 dista
uint32 allowed = 0;
while (getScene()->findActionArea(kActionAreaType1, Common::Point(x, y), true) != -1) {
- x += deltaPointsArray[direction].x;
- y += deltaPointsArray[direction].y;
+ x += deltaPointsArray[direction][0];
+ y += deltaPointsArray[direction][1];
++allowed;
@@ -1901,8 +1901,8 @@ bool Actor::hasMoreReactions(int32 reactionIndex, int32 testNumberValue01) const
bool Actor::canMoveCheckActors(Common::Point *point, ActorDirection dir) {
int32 dist = getAbsoluteDistanceForFrame(dir, (_frameIndex >= _frameCount) ? 2 * _frameCount - (_frameIndex + 1) : _frameIndex);
- int32 x = point->x + deltaPointsArray[dir].x * dist - (_field_948 + 10);
- int32 y = point->y + deltaPointsArray[dir].y * dist - (_field_94C + 10);
+ int32 x = point->x + deltaPointsArray[dir][0] * dist - (_field_948 + 10);
+ int32 y = point->y + deltaPointsArray[dir][1] * dist - (_field_94C + 10);
int32 x1 = x + 2 * _field_948 + 20;
int32 y1 = y + 2 * _field_94C + 20;
@@ -3648,7 +3648,8 @@ bool Actor::checkPath(Common::Array<int> *actions, const Common::Point &point, A
return true;
// Initialize base coordinates
- Common::Point basePoint = deltaPointsArray[direction] + point;
+ Common::Point delta = Common::Point(deltaPointsArray[direction][0], deltaPointsArray[direction][1]);
+ Common::Point basePoint = delta + point;
Common::Rect rect = getWorld()->sceneRects[getWorld()->sceneRectIdx];
for (int16 i = 1; i < loopcount; i++) {
@@ -3658,7 +3659,7 @@ bool Actor::checkPath(Common::Array<int> *actions, const Common::Point &point, A
if (!rect.contains(basePoint))
return false;
- basePoint += deltaPointsArray[direction];
+ basePoint += delta;
}
return true;
diff --git a/engines/asylum/resources/script.cpp b/engines/asylum/resources/script.cpp
index 57511289f2..6c6059e943 100644
--- a/engines/asylum/resources/script.cpp
+++ b/engines/asylum/resources/script.cpp
@@ -997,8 +997,8 @@ IMPLEMENT_OPCODE(UpdateActor)
if (player->canMove(&point, newDirection, 3, false)) {
- point.x += (int16)(3 * deltaPointsArray[newDirection].x);
- point.y += (int16)(3 * deltaPointsArray[newDirection].y);
+ point.x += (int16)(3 * deltaPointsArray[newDirection][0]);
+ point.y += (int16)(3 * deltaPointsArray[newDirection][1]);
player->setPosition(point.x, point.y, actor->getDirection(), 0);
}
diff --git a/engines/asylum/resources/special.cpp b/engines/asylum/resources/special.cpp
index 7021c2f96e..e92704f225 100644
--- a/engines/asylum/resources/special.cpp
+++ b/engines/asylum/resources/special.cpp
@@ -40,20 +40,14 @@
namespace Asylum {
-static const Common::Rect actorRects[] = {
- Common::Rect(1100, 150, 1130, 245),
- Common::Rect( 848, 161, 884, 216),
- Common::Rect( 861, 334, 884, 413),
- Common::Rect( 600, 193, 621, 229),
- Common::Rect( 805, 156, 957, 225),
- Common::Rect( 641, 162, 791, 226),
- Common::Rect( 695, 159, 808, 213),
- Common::Rect( 925, 158, 1054, 224),
- Common::Rect(1158, 162, 1293, 248),
- Common::Rect(1319, 218, 1469, 351),
- Common::Rect( 430, 351, 508, 407),
- Common::Rect( 762, 339, 864, 398),
- Common::Rect( 962, 328, 1080, 373),
+static const int16 actorRects[13][4] = {
+ {1100, 150, 1130, 245}, { 848, 161, 884, 216},
+ { 861, 334, 884, 413}, { 600, 193, 621, 229},
+ { 805, 156, 957, 225}, { 641, 162, 791, 226},
+ { 695, 159, 808, 213}, { 925, 158, 1054, 224},
+ {1158, 162, 1293, 248}, {1319, 218, 1469, 351},
+ { 430, 351, 508, 407}, { 762, 339, 864, 398},
+ { 962, 328, 1080, 373},
};
static const int32 zapPatterns[9][16] = {
@@ -779,19 +773,19 @@ void Special::chapter11(Object *object, ActorIndex actorIndex) {
actor1->updateStatus(kActorStatusWalking2);
}
- tentacle(10, kGameFlag557, kGameFlag558, kGameFlag563, actorRects[0]);
- tentacle(11, kGameFlag722, kGameFlag723, kGameFlag724, actorRects[1]);
- tentacle(12, kGameFlag725, kGameFlag726, kGameFlag727, actorRects[2]);
- tentacle(13, kGameFlag728, kGameFlag729, kGameFlag730, actorRects[3]);
- rock(2, kGameFlag597, kGameFlag598, kGameFlag599, kGameFlag600, actorRects[6]);
- rock(3, kGameFlag684, kGameFlag685, kGameFlag686, kGameFlag687, actorRects[7]);
- rock(4, kGameFlag688, kGameFlag689, kGameFlag690, kGameFlag691, actorRects[8]);
- rock(5, kGameFlag692, kGameFlag693, kGameFlag694, kGameFlag695, actorRects[9]);
- rock(6, kGameFlag696, kGameFlag697, kGameFlag698, kGameFlag699, actorRects[10]);
- rock(7, kGameFlag700, kGameFlag701, kGameFlag702, kGameFlag703, actorRects[11]);
- rock(8, kGameFlag704, kGameFlag705, kGameFlag706, kGameFlag707, actorRects[12]);
- rock(16, kGameFlag1054, kGameFlag1055, kGameFlag1056, kGameFlag1057, actorRects[4]);
- rock(17, kGameFlag1058, kGameFlag1059, kGameFlag1060, kGameFlag1061, actorRects[5]);
+ tentacle(10, kGameFlag557, kGameFlag558, kGameFlag563, &actorRects[0]);
+ tentacle(11, kGameFlag722, kGameFlag723, kGameFlag724, &actorRects[1]);
+ tentacle(12, kGameFlag725, kGameFlag726, kGameFlag727, &actorRects[2]);
+ tentacle(13, kGameFlag728, kGameFlag729, kGameFlag730, &actorRects[3]);
+ rock(2, kGameFlag597, kGameFlag598, kGameFlag599, kGameFlag600, &actorRects[6]);
+ rock(3, kGameFlag684, kGameFlag685, kGameFlag686, kGameFlag687, &actorRects[7]);
+ rock(4, kGameFlag688, kGameFlag689, kGameFlag690, kGameFlag691, &actorRects[8]);
+ rock(5, kGameFlag692, kGameFlag693, kGameFlag694, kGameFlag695, &actorRects[9]);
+ rock(6, kGameFlag696, kGameFlag697, kGameFlag698, kGameFlag699, &actorRects[10]);
+ rock(7, kGameFlag700, kGameFlag701, kGameFlag702, kGameFlag703, &actorRects[11]);
+ rock(8, kGameFlag704, kGameFlag705, kGameFlag706, kGameFlag707, &actorRects[12]);
+ rock(16, kGameFlag1054, kGameFlag1055, kGameFlag1056, kGameFlag1057, &actorRects[4]);
+ rock(17, kGameFlag1058, kGameFlag1059, kGameFlag1060, kGameFlag1061, &actorRects[5]);
break;
case kObjectMonsterHurt:
@@ -2016,7 +2010,8 @@ void Special::checkOtherObject(Object *object, ObjectId otherObjectId, GameFlag
// Chapter 11 helpers
//////////////////////////////////////////////////////////////////////////
-void Special::rock(ActorIndex actorIndex, GameFlag flag1, GameFlag flag2, GameFlag flag3, GameFlag flag4, const Common::Rect &rect) {
+void Special::rock(ActorIndex actorIndex, GameFlag flag1, GameFlag flag2, GameFlag flag3, GameFlag flag4, const int16 (*rectPtr)[4]) {
+ Common::Rect rect((*rectPtr)[0], (*rectPtr)[1], (*rectPtr)[2], (*rectPtr)[3]);
Actor *actor = getScene()->getActor(actorIndex);
if (!(_vm->isGameFlagNotSet(flag1) && _vm->isGameFlagSet(flag2)))
@@ -2076,8 +2071,10 @@ void Special::rock(ActorIndex actorIndex, GameFlag flag1, GameFlag flag2, GameFl
}
}
-void Special::tentacle(ActorIndex actorIndex, GameFlag flag1, GameFlag flag2, GameFlag flag3, const Common::Rect &rect) {
+void Special::tentacle(ActorIndex actorIndex, GameFlag flag1, GameFlag flag2, GameFlag flag3, const int16 (*rectPtr)[4]) {
+ Common::Rect rect((*rectPtr)[0], (*rectPtr)[1], (*rectPtr)[2], (*rectPtr)[3]);
Actor *actor = getScene()->getActor(actorIndex);
+
if (_vm->isGameFlagSet(flag1)
&& _vm->isGameFlagNotSet(flag3)
&& !_vm->isGameFlagSet(flag2)
diff --git a/engines/asylum/resources/special.h b/engines/asylum/resources/special.h
index 136a0710a1..662b63f48b 100644
--- a/engines/asylum/resources/special.h
+++ b/engines/asylum/resources/special.h
@@ -106,8 +106,8 @@ private:
// Chapter 11 helpers
//////////////////////////////////////////////////////////////////////////
- void tentacle(ActorIndex actorIndex, GameFlag flag1, GameFlag flag2, GameFlag flag3, const Common::Rect &rect);
- void rock(ActorIndex actorIndex, GameFlag flag1, GameFlag flag2, GameFlag flag3, GameFlag flag4, const Common::Rect &rect);
+ void tentacle(ActorIndex actorIndex, GameFlag flag1, GameFlag flag2, GameFlag flag3, const int16 (*rectPtr)[4]);
+ void rock(ActorIndex actorIndex, GameFlag flag1, GameFlag flag2, GameFlag flag3, GameFlag flag4, const int16 (*rectPtr)[4]);
};
} // End of namespace Asylum
diff --git a/engines/asylum/staticres.h b/engines/asylum/staticres.h
index 05bfb576f1..ebecd2fd4e 100644
--- a/engines/asylum/staticres.h
+++ b/engines/asylum/staticres.h
@@ -28,18 +28,18 @@
namespace Asylum {
/** This fixes the menu icons text x position on screen */
-const Common::Rect menuRects[12] = {Common::Rect( 40, 19, 93, 68),
- Common::Rect( 140, 19, 193, 68),
- Common::Rect( 239, 19, 292, 68),
- Common::Rect( 340, 19, 393, 68),
- Common::Rect( 439, 19, 492, 68),
- Common::Rect( 538, 19, 591, 68),
- Common::Rect( 40, 400, 93, 449),
- Common::Rect( 140, 400, 193, 449),
- Common::Rect( 239, 400, 292, 449),
- Common::Rect( 340, 400, 393, 449),
- Common::Rect( 538, 400, 591, 449), // The last two icons are swapped
- Common::Rect( 439, 400, 492, 449)};
+const int16 menuRects[12][4] = {{ 40, 19, 93, 68},
+ {140, 19, 193, 68},
+ {239, 19, 292, 68},
+ {340, 19, 393, 68},
+ {439, 19, 492, 68},
+ {538, 19, 591, 68},
+ { 40, 400, 93, 449},
+ {140, 400, 193, 449},
+ {239, 400, 292, 449},
+ {340, 400, 393, 449},
+ {538, 400, 591, 449}, // The last two icons are swapped
+ {439, 400, 492, 449}};
const uint32 eyeFrameIndex[8] = {3, 5, 1, 7, 4, 8, 2, 6};
@@ -70,15 +70,9 @@ const int encounterPortrait2Index[80] = {32, 33, 34, 21, 22, 23, 24, 25, 26, 27,
4, 5, 6, 35, 33, 34, 35, 36, 37, 36};
// Delta array for points
-static Common::Point deltaPointsArray[8] = {
- Common::Point( 0, -1),
- Common::Point(-1, -1),
- Common::Point(-1, 0),
- Common::Point(-1, 1),
- Common::Point( 0, 1),
- Common::Point( 1, 1),
- Common::Point( 1, 0),
- Common::Point( 1, -1)
+static const int16 deltaPointsArray[8][2] = {
+ { 0, -1}, {-1, -1}, {-1, 0}, {-1, 1},
+ { 0, 1}, { 1, 1}, { 1, 0}, { 1, -1}
};
// We hardcode all the text resources here. It makes the resulting code easier,
diff --git a/engines/asylum/system/savegame.cpp b/engines/asylum/system/savegame.cpp
index a10a625211..acf96c78e2 100644
--- a/engines/asylum/system/savegame.cpp
+++ b/engines/asylum/system/savegame.cpp
@@ -51,7 +51,7 @@ namespace Asylum {
#define SAVEGAME_MOVIES "asylum.movies"
-static const Common::String savegame_version = "v1.01 FINAL";
+static const char *savegame_version = "v1.01 FINAL";
Savegame::Savegame(AsylumEngine *engine) : _vm(engine), _index(0), _valid(false) {
memset(&_moviesViewed, 0, sizeof(_moviesViewed));
@@ -249,7 +249,7 @@ bool Savegame::readHeader(Common::InSaveFile *file) {
// Original does not do any version check
// Until we can verify all versions have compatible savegames, we only handle the final patched version savegames
- if (version != savegame_version || build != SAVEGAME_BUILD) {
+ if (version != Common::String(savegame_version) || build != SAVEGAME_BUILD) {
_valid = false;
return false;
}
@@ -262,7 +262,7 @@ void Savegame::writeHeader(Common::OutSaveFile *file) const {
// We write saved games with a 1.01 final version (build 851)
write(file, SAVEGAME_VERSION_SIZE, "Version Length");
- write(file, savegame_version, SAVEGAME_VERSION_SIZE, "Version");
+ write(file, Common::String(savegame_version), SAVEGAME_VERSION_SIZE, "Version");
write(file, SAVEGAME_BUILD, "Build");
}
diff --git a/engines/asylum/system/screen.cpp b/engines/asylum/system/screen.cpp
index 9529d978bd..a104e6b7c9 100644
--- a/engines/asylum/system/screen.cpp
+++ b/engines/asylum/system/screen.cpp
@@ -85,6 +85,10 @@ void Screen::draw(ResourceId resourceId, uint32 frameIndex, const Common::Point
draw(resourceId, frameIndex, source, flags, kResourceNone, Common::Point(0, 0), colorKey);
}
+void Screen::draw(ResourceId resourceId, uint32 frameIndex, const int16 (*srcPtr)[2], DrawFlags flags, bool colorKey) {
+ draw(resourceId, frameIndex, Common::Point((*srcPtr)[0], (*srcPtr)[1]), flags, kResourceNone, Common::Point(0, 0), colorKey);
+}
+
void Screen::drawTransparent(ResourceId resourceId, uint32 frameIndex, const Common::Point &source, DrawFlags flags, uint32 transTableNum) {
byte *index = _transTable;
selectTransTable(transTableNum);
@@ -629,6 +633,10 @@ void Screen::addGraphicToQueue(ResourceId resourceId, uint32 frameIndex, const C
_queueItems.push_back(item);
}
+void Screen::addGraphicToQueue(ResourceId resourceId, uint32 frameIndex, const int16 (*pointPtr)[2], DrawFlags flags, int32 transTableNum, int32 priority) {
+ addGraphicToQueue(resourceId, frameIndex, Common::Point((*pointPtr)[0], (*pointPtr)[1]), flags, transTableNum, priority);
+}
+
void Screen::addGraphicToQueueMasked(ResourceId resourceId, uint32 frameIndex, const Common::Point &source, int32 resourceIdDestination, const Common::Point &destination, DrawFlags flags, int32 priority) {
GraphicQueueItem item;
item.priority = priority;
@@ -1230,6 +1238,10 @@ void Screen::drawLine(const Common::Point &source, const Common::Point &destinat
_backBuffer.drawLine(source.x, source.y, destination.x, destination.y, color);
}
+void Screen::drawLine(const int16 (*srcPtr)[2], const int16 (*dstPtr)[2], uint32 color) {
+ _backBuffer.drawLine((*srcPtr)[0], (*srcPtr)[1], (*dstPtr)[0], (*dstPtr)[1], color);
+}
+
void Screen::drawRect(const Common::Rect &rect, uint32 color) {
_backBuffer.frameRect(rect, color);
}
diff --git a/engines/asylum/system/screen.h b/engines/asylum/system/screen.h
index 91a305c8ab..2b2f56669b 100644
--- a/engines/asylum/system/screen.h
+++ b/engines/asylum/system/screen.h
@@ -78,6 +78,7 @@ public:
// Drawing
void draw(ResourceId resourceId);
void draw(ResourceId resourceId, uint32 frameIndex, const Common::Point &source, DrawFlags flags = kDrawFlagNone, bool colorKey = true);
+ void draw(ResourceId resourceId, uint32 frameIndex, const int16 (*srcPtr)[2], DrawFlags flags = kDrawFlagNone, bool colorKey = true);
void draw(GraphicResource *resource, uint32 frameIndex, const Common::Point &source, DrawFlags flags= kDrawFlagNone, bool colorKey = true);
void drawTransparent(ResourceId resourceId, uint32 frameIndex, const Common::Point &source, DrawFlags flags, uint32 transTableNum);
void drawTransparent(GraphicResource *resource, uint32 frameIndex, const Common::Point &source, DrawFlags flags, uint32 transTableNum);
@@ -116,6 +117,7 @@ public:
// Graphic queue
void addGraphicToQueue(ResourceId resourceId, uint32 frameIndex, const Common::Point &point, DrawFlags flags, int32 transTableNum, int32 priority);
+ void addGraphicToQueue(ResourceId resourceId, uint32 frameIndex, const int16 (*pointPtr)[2], DrawFlags flags, int32 transTableNum, int32 priority);
void addGraphicToQueueCrossfade(ResourceId resourceId, uint32 frameIndex, const Common::Point &source, int32 objectResourceId, const Common::Point &destination, uint32 transTableNum);
void addGraphicToQueueMasked(ResourceId resourceId, uint32 frameIndex, const Common::Point &source, int32 objectResourceId, const Common::Point &destination, DrawFlags flags, int32 priority);
void addGraphicToQueue(GraphicQueueItem const &item);
@@ -127,7 +129,8 @@ public:
void copyToBackBuffer(const byte *buffer, int32 pitch, int16 x, int16 y, uint16 width, uint16 height, bool mirrored = false);
// Debug
- void drawLine(const Common::Point &origin, const Common::Point &destination, uint32 color = 0xFF);
+ void drawLine(const Common::Point &source, const Common::Point &destination, uint32 color = 0xFF);
+ void drawLine(const int16 (*srcPtr)[2], const int16 (*dstPtr)[2], uint32 color = 0xFF);
void drawRect(const Common::Rect &rect, uint32 color = 0xFF);
void copyToBackBufferClipped(Graphics::Surface *surface, int16 x, int16 y);
diff --git a/engines/asylum/views/menu.cpp b/engines/asylum/views/menu.cpp
index b4d2c261bd..84de5fafde 100644
--- a/engines/asylum/views/menu.cpp
+++ b/engines/asylum/views/menu.cpp
@@ -179,7 +179,7 @@ void Menu::closeCredits() {
Menu::MenuScreen Menu::findMousePosition() {
for (uint i = 0; i < ARRAYSIZE(menuRects); i++)
- if (menuRects[i].contains(getCursor()->position()))
+ if (_vm->rectContains(&menuRects[i], getCursor()->position()))
return (MenuScreen)i;
return kMenuNone;
@@ -430,7 +430,9 @@ bool Menu::update() {
_iconFrames[icon] = (_iconFrames[icon] + 1) % GraphicResource::getFrameCount(_vm, MAKE_RESOURCE(kResourcePackShared, icon + 4));
// Draw text
- getText()->drawCentered(Common::Point(menuRects[icon].left - 5, menuRects[icon].bottom + 5), menuRects[icon].width(), MAKE_RESOURCE(kResourcePackText, 1309 + icon));
+ getText()->drawCentered(Common::Point(menuRects[icon][0] - 5, menuRects[icon][3] + 5),
+ menuRects[icon][2] - menuRects[icon][0],
+ MAKE_RESOURCE(kResourcePackText, 1309 + icon));
if (!_dword_455C74 || _currentIcon != icon) {
_dword_455C74 = true;
Commit: cf0049c23b79cb3dfdc585a12b5d55a2a919f624
https://github.com/scummvm/scummvm/commit/cf0049c23b79cb3dfdc585a12b5d55a2a919f624
Author: alxpnv (alxpnv22 at yahoo.com)
Date: 2021-05-17T15:37:56+02:00
Commit Message:
ASYLUM: (Pipes puzzle) use the engine-level random source
Changed paths:
engines/asylum/puzzles/pipes.cpp
engines/asylum/puzzles/pipes.h
diff --git a/engines/asylum/puzzles/pipes.cpp b/engines/asylum/puzzles/pipes.cpp
index ecb51e1f8d..6093d89fbc 100644
--- a/engines/asylum/puzzles/pipes.cpp
+++ b/engines/asylum/puzzles/pipes.cpp
@@ -223,13 +223,12 @@ void Connector::disconnect(Connector *connector) {
//////////////////////////////////////////////////////////////////////////
// Spider
//////////////////////////////////////////////////////////////////////////
-Spider::Spider(const Common::Rect &rect, Common::String id) {
+Spider::Spider(AsylumEngine *engine, const Common::Rect &rect) : _vm(engine) {
_boundingBox = rect;
- _rnd = new Common::RandomSource(Common::String("pipes_spider") + id);
_isAlive = true;
- _location.x = (int16)_rnd->getRandomNumber((uint16)(_boundingBox.right - _boundingBox.left)) + _boundingBox.left;
- _location.y = (int16)_rnd->getRandomNumber((uint16)(_boundingBox.bottom - _boundingBox.top)) + _boundingBox.top;
- _direction = Direction((uint32)1 << _rnd->getRandomNumber(3));
+ _location.x = (int16)rnd((uint16)(_boundingBox.right - _boundingBox.left + 1)) + _boundingBox.left;
+ _location.y = (int16)rnd((uint16)(_boundingBox.bottom - _boundingBox.top + 1)) + _boundingBox.top;
+ _direction = Direction((uint32)1 << rnd(4));
_stepsNumber = 0;
_steps = 0;
@@ -237,16 +236,16 @@ Spider::Spider(const Common::Rect &rect, Common::String id) {
}
void Spider::randomize(Direction excluded) {
- if (_rnd->getRandomNumber(5) == 5)
+ if (rnd(6) == 5)
_delta = Common::Point(0, 0);
else {
while (_direction == excluded)
- _direction = Direction((uint32)1 << _rnd->getRandomNumber(3));
+ _direction = Direction((uint32)1 << rnd(4));
_delta = Common::Point((_direction & kBinNum0010 ? 1 : 0) - (_direction & kBinNum1000 ? 1 : 0), (_direction & kBinNum0100 ? 1 : 0) - (_direction & kBinNum0001 ? 1 : 0));
}
- _stepsNumber = _rnd->getRandomNumber(maxStepsNumber - minStepsNumber) + minStepsNumber;
+ _stepsNumber = rnd(maxStepsNumber - minStepsNumber + 1) + minStepsNumber;
_steps = 0;
}
@@ -522,13 +521,13 @@ void PuzzlePipes::setup() {
_connectors[13].initGroup();
_connectors[15].initGroup();
- uint32 i = rnd(kBinNum0111);
+ uint32 i = rnd(kBinNum1000);
if (i & kBinNum0001)
- _spiders.push_back(new Spider(Common::Rect(-10, 45, 92, 315), "1"));
+ _spiders.push_back(new Spider(_vm, Common::Rect(-10, 45, 92, 315)));
if (i & kBinNum0010)
- _spiders.push_back(new Spider(Common::Rect(-10, 389, 149, 476), "2"));
+ _spiders.push_back(new Spider(_vm, Common::Rect(-10, 389, 149, 476)));
if (i & kBinNum0100)
- _spiders.push_back(new Spider(Common::Rect(544, 225, 650, 490), "3"));
+ _spiders.push_back(new Spider(_vm, Common::Rect(544, 225, 650, 490)));
if (i) {
_frameIndexSpider = new uint32[_spiders.size()];
diff --git a/engines/asylum/puzzles/pipes.h b/engines/asylum/puzzles/pipes.h
index f41764e14b..7221fd249e 100644
--- a/engines/asylum/puzzles/pipes.h
+++ b/engines/asylum/puzzles/pipes.h
@@ -133,8 +133,8 @@ private:
class Spider {
public:
- Spider(const Common::Rect &rect, Common::String id);
- ~Spider() { delete _rnd; }
+ Spider(AsylumEngine *engine, const Common::Rect &rect);
+ ~Spider() {}
bool isAlive() const { return _isAlive; }
bool isActive() const { return _delta != Common::Point(0, 0); }
@@ -147,7 +147,7 @@ public:
void smash() { _isAlive = false; }
private:
static const uint32 minStepsNumber = 20, maxStepsNumber = 200;
- Common::RandomSource *_rnd;
+ AsylumEngine *_vm;
bool _isAlive;
Common::Point _location;
Common::Point _delta;
Commit: aac8cee532b4117522e5b19af0e119d7a4c393b4
https://github.com/scummvm/scummvm/commit/aac8cee532b4117522e5b19af0e119d7a4c393b4
Author: alxpnv (alxpnv22 at yahoo.com)
Date: 2021-05-17T15:37:57+02:00
Commit Message:
ASYLUM: optimizations to the board puzzles
Suggested by sev-
Changed paths:
engines/asylum/puzzles/board.cpp
diff --git a/engines/asylum/puzzles/board.cpp b/engines/asylum/puzzles/board.cpp
index 3ada19d237..cdfae3f997 100644
--- a/engines/asylum/puzzles/board.cpp
+++ b/engines/asylum/puzzles/board.cpp
@@ -65,12 +65,12 @@ bool PuzzleBoard::init(const AsylumEvent &) {
getText()->loadFont(getWorld()->graphicResourceIds[35]);
// Prepare text to draw
- _text = "";
+ _text.clear();
for (uint32 i = 0; i < _data.soundResourceSize; i++) {
_data.soundResources[i].played = false;
_text += getText()->get(MAKE_RESOURCE(kResourcePackText, 1068 + _data.soundResources[i].index));
- _text += " ";
+ _text += ' ';
}
updateScreen();
Commit: 0d71da53a65a5a6bcd7db1df771b529cd5b9212d
https://github.com/scummvm/scummvm/commit/0d71da53a65a5a6bcd7db1df771b529cd5b9212d
Author: alxpnv (alxpnv22 at yahoo.com)
Date: 2021-05-17T15:37:57+02:00
Commit Message:
ASYLUM: remove a useless ifdef
Spotted by sev-
Changed paths:
engines/asylum/views/scene.cpp
diff --git a/engines/asylum/views/scene.cpp b/engines/asylum/views/scene.cpp
index 8f91f2f210..109cad8a8e 100644
--- a/engines/asylum/views/scene.cpp
+++ b/engines/asylum/views/scene.cpp
@@ -2198,10 +2198,8 @@ int32 Scene::findActionArea(ActionAreaType type, const Common::Point &pt, bool h
continue;
if (g_debugPolygons && highlight) {
-#ifdef DEBUG
// Highlight each polygon as it gets checked for action
debugHighlightPolygon(area->polygonIndex);
-#endif
}
bool found = false;
Commit: 179627fab4865b76969a9a2438155ed84efcca27
https://github.com/scummvm/scummvm/commit/179627fab4865b76969a9a2438155ed84efcca27
Author: alxpnv (alxpnv22 at yahoo.com)
Date: 2021-05-17T15:37:57+02:00
Commit Message:
ASYLUM: add some missing updateScreen() calls
Suggested by sev-
Changed paths:
engines/asylum/asylum.cpp
engines/asylum/views/scene.cpp
diff --git a/engines/asylum/asylum.cpp b/engines/asylum/asylum.cpp
index e413851378..8dc78fc05f 100644
--- a/engines/asylum/asylum.cpp
+++ b/engines/asylum/asylum.cpp
@@ -354,6 +354,7 @@ void AsylumEngine::playIntro() {
}
}
+ _system->updateScreen();
_system->delayMillis(100);
} while (_sound->isPlaying(introSpeech) && !skip);
diff --git a/engines/asylum/views/scene.cpp b/engines/asylum/views/scene.cpp
index 109cad8a8e..ebaaabcc1f 100644
--- a/engines/asylum/views/scene.cpp
+++ b/engines/asylum/views/scene.cpp
@@ -1835,6 +1835,7 @@ void Scene::playIntroSpeech() {
Common::Event ev;
_vm->getEventManager()->pollEvent(ev);
+ g_system->updateScreen();
g_system->delayMillis(100);
} while (getSound()->isPlaying(resourceId));
Commit: cf550f5ce2a6335f66d23c7227c7b5a9ffe433df
https://github.com/scummvm/scummvm/commit/cf550f5ce2a6335f66d23c7227c7b5a9ffe433df
Author: alxpnv (alxpnv22 at yahoo.com)
Date: 2021-05-17T15:37:57+02:00
Commit Message:
ASYLUM: convert AsylumEngine::_gameFlags to uint32
Changed paths:
engines/asylum/asylum.cpp
engines/asylum/asylum.h
engines/asylum/shared.h
diff --git a/engines/asylum/asylum.cpp b/engines/asylum/asylum.cpp
index 8dc78fc05f..089792054a 100644
--- a/engines/asylum/asylum.cpp
+++ b/engines/asylum/asylum.cpp
@@ -541,7 +541,7 @@ void AsylumEngine::saveLoadWithSerializer(Common::Serializer &s) {
// Game flags
for (uint32 i = 0; i < ARRAYSIZE(_gameFlags); i++)
- s.syncAsSint32LE(_gameFlags[i]);
+ s.syncAsUint32LE(_gameFlags[i]);
// The original has the script data in the middle of other shared data,
// so to be compatible with original savegames, we want to save it in
@@ -562,26 +562,24 @@ void AsylumEngine::saveLoadWithSerializer(Common::Serializer &s) {
//////////////////////////////////////////////////////////////////////////
// Game flags
//////////////////////////////////////////////////////////////////////////
-#define FLAG_MASK 0xFFFFFFE0
-
void AsylumEngine::setGameFlag(GameFlag flag) {
- _gameFlags[flag / 32] |= 1 << (flag % FLAG_MASK);
+ _gameFlags[flag / 32] |= 1 << (flag % 32);
}
void AsylumEngine::clearGameFlag(GameFlag flag) {
- _gameFlags[flag / 32] &= ~(1 << (uint32)(flag % FLAG_MASK));
+ _gameFlags[flag / 32] &= ~(1 << (flag % 32));
}
void AsylumEngine::toggleGameFlag(GameFlag flag) {
- _gameFlags[flag / 32] ^= 1 << (uint32)(flag % FLAG_MASK);
+ _gameFlags[flag / 32] ^= 1 << (flag % 32);
}
bool AsylumEngine::isGameFlagSet(GameFlag flag) const {
- return ((1 << (flag % FLAG_MASK)) & (unsigned int)_gameFlags[flag / 32]) >> (flag % FLAG_MASK) != 0;
+ return ((1 << (flag % 32)) & _gameFlags[flag / 32]) >> (flag % 32) != 0;
}
bool AsylumEngine::isGameFlagNotSet(GameFlag flag) const {
- return ((1 << (flag % FLAG_MASK)) & (unsigned int)_gameFlags[flag / 32]) >> (flag % FLAG_MASK) == 0;
+ return ((1 << (flag % 32)) & _gameFlags[flag / 32]) >> (flag % 32) == 0;
}
//////////////////////////////////////////////////////////////////////////
diff --git a/engines/asylum/asylum.h b/engines/asylum/asylum.h
index 6b52dddbab..cb34a5c768 100644
--- a/engines/asylum/asylum.h
+++ b/engines/asylum/asylum.h
@@ -232,7 +232,7 @@ private:
// Game data
Puzzles *_puzzles;
SharedData _data;
- int _gameFlags[130];
+ uint32 _gameFlags[130];
bool _introPlayed;
int32 _tickOffset;
diff --git a/engines/asylum/shared.h b/engines/asylum/shared.h
index 88d7983b7e..59b6fe0f11 100644
--- a/engines/asylum/shared.h
+++ b/engines/asylum/shared.h
@@ -28,7 +28,7 @@ namespace Asylum {
//////////////////////////////////////////////////////////////////////////
// Global
//////////////////////////////////////////////////////////////////////////
-enum GameFlag {
+enum GameFlag : uint32 {
kGameFlag0 = 0,
kGameFlag4 = 4,
Commit: ca1d7807305358afbfa2b00b0734a068b3d116f1
https://github.com/scummvm/scummvm/commit/ca1d7807305358afbfa2b00b0734a068b3d116f1
Author: alxpnv (alxpnv22 at yahoo.com)
Date: 2021-05-17T15:37:57+02:00
Commit Message:
ASYLUM: clean up metaengine.cpp
Changed paths:
engines/asylum/metaengine.cpp
diff --git a/engines/asylum/metaengine.cpp b/engines/asylum/metaengine.cpp
index f615568070..bfb170e002 100644
--- a/engines/asylum/metaengine.cpp
+++ b/engines/asylum/metaengine.cpp
@@ -37,25 +37,10 @@ public:
}
Common::Error createInstance(OSystem *syst, Engine **engine, const ADGameDescription *gd) const override;
- virtual bool hasFeature(MetaEngineFeature f) const override;
- virtual SaveStateList listSaves(const char *target) const override;
- virtual int getMaximumSaveSlot() const override;
- virtual void removeSaveState(const char *target, int slot) const override;
};
-bool AsylumMetaEngine::hasFeature(MetaEngineFeature f) const {
- return
- (f == kSupportsListSaves) ||
- (f == kSupportsLoadingDuringStartup) ||
- (f == kSupportsDeleteSave);
-}
-
bool Asylum::AsylumEngine::hasFeature(EngineFeature f) const {
- return
- (f == kSupportsReturnToLauncher) ||
- (f == kSupportsLoadingDuringRuntime) ||
- (f == kSupportsSavingDuringRuntime) ||
- (f == kSupportsSubtitleOptions);
+ return (f == kSupportsReturnToLauncher);
}
Common::Error AsylumMetaEngine::createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const {
@@ -65,19 +50,6 @@ Common::Error AsylumMetaEngine::createInstance(OSystem *syst, Engine **engine, c
return desc ? Common::kNoError : Common::kUnsupportedGameidError;
}
-SaveStateList AsylumMetaEngine::listSaves(const char * /*target*/) const {
- error("[AsylumMetaEngine::listSaves] Not implemented");
-}
-
-int AsylumMetaEngine::getMaximumSaveSlot() const {
- error("[AsylumMetaEngine::getMaximumSaveSlot] Not implemented");
-}
-
-void AsylumMetaEngine::removeSaveState(const char * /*target*/, int /*slot*/) const {
- error("[AsylumMetaEngine::removeSaveState] Not implemented");
-}
-
-
#if PLUGIN_ENABLED_DYNAMIC(ASYLUM)
REGISTER_PLUGIN_DYNAMIC(ASYLUM, PLUGIN_TYPE_ENGINE, AsylumMetaEngine);
#else
Commit: c81c0464504f01679ea335983939251b9d784ca2
https://github.com/scummvm/scummvm/commit/c81c0464504f01679ea335983939251b9d784ca2
Author: alxpnv (alxpnv22 at yahoo.com)
Date: 2021-05-17T15:37:58+02:00
Commit Message:
ASYLUM: clean up destructors
Changed paths:
engines/asylum/console.cpp
engines/asylum/puzzles/puzzle.cpp
engines/asylum/puzzles/puzzle.h
engines/asylum/puzzles/puzzles.cpp
engines/asylum/resources/actor.cpp
engines/asylum/resources/actor.h
engines/asylum/resources/encounters.cpp
engines/asylum/resources/encounters.h
engines/asylum/resources/object.cpp
engines/asylum/resources/object.h
engines/asylum/resources/script.cpp
engines/asylum/resources/special.cpp
engines/asylum/resources/special.h
engines/asylum/resources/worldstats.cpp
engines/asylum/system/cursor.cpp
engines/asylum/system/graphics.cpp
engines/asylum/system/savegame.cpp
engines/asylum/system/savegame.h
engines/asylum/system/screen.cpp
engines/asylum/system/sound.cpp
engines/asylum/system/speech.cpp
engines/asylum/system/speech.h
engines/asylum/system/text.cpp
engines/asylum/views/menu.cpp
engines/asylum/views/menu.h
engines/asylum/views/scene.cpp
engines/asylum/views/scenetitle.cpp
engines/asylum/views/scenetitle.h
engines/asylum/views/video.cpp
diff --git a/engines/asylum/console.cpp b/engines/asylum/console.cpp
index 7b929c97fb..2c75e2ec02 100644
--- a/engines/asylum/console.cpp
+++ b/engines/asylum/console.cpp
@@ -219,9 +219,6 @@ Console::Console(AsylumEngine *engine) : _vm(engine) {
Console::~Console() {
DebugMan.clearAllDebugChannels();
-
- // Zero passed pointers
- _vm = NULL;
}
//////////////////////////////////////////////////////////////////////////
diff --git a/engines/asylum/puzzles/puzzle.cpp b/engines/asylum/puzzles/puzzle.cpp
index 25c13e62b1..9b6ce637d0 100644
--- a/engines/asylum/puzzles/puzzle.cpp
+++ b/engines/asylum/puzzles/puzzle.cpp
@@ -38,11 +38,6 @@ namespace Asylum {
Puzzle::Puzzle(AsylumEngine *engine): _vm(engine) {
}
-Puzzle::~Puzzle() {
- // Zero passed pointers
- _vm = NULL;
-}
-
void Puzzle::saveLoadWithSerializer(Common::Serializer &) {
// By default, we do not save any data
}
diff --git a/engines/asylum/puzzles/puzzle.h b/engines/asylum/puzzles/puzzle.h
index 1217f45a31..1a78c6428d 100644
--- a/engines/asylum/puzzles/puzzle.h
+++ b/engines/asylum/puzzles/puzzle.h
@@ -42,7 +42,7 @@ struct GraphicQueueItem;
class Puzzle : public EventHandler, public Common::Serializable {
public:
Puzzle(AsylumEngine *engine);
- virtual ~Puzzle();
+ virtual ~Puzzle() {};
bool handleEvent(const AsylumEvent &evt);
diff --git a/engines/asylum/puzzles/puzzles.cpp b/engines/asylum/puzzles/puzzles.cpp
index 4584f04e34..379b151c2e 100644
--- a/engines/asylum/puzzles/puzzles.cpp
+++ b/engines/asylum/puzzles/puzzles.cpp
@@ -50,9 +50,6 @@ Puzzles::~Puzzles() {
// Cleanup puzzles
for (uint i = 0; i < ARRAYSIZE(_puzzles); i++)
delete _puzzles[i];
-
- // Zero passed pointers
- _vm = NULL;
}
void Puzzles::reset() {
diff --git a/engines/asylum/resources/actor.cpp b/engines/asylum/resources/actor.cpp
index be0fe38c34..9fb71ecbc1 100644
--- a/engines/asylum/resources/actor.cpp
+++ b/engines/asylum/resources/actor.cpp
@@ -113,13 +113,6 @@ Actor::Actor(AsylumEngine *engine, ActorIndex index) : _vm(engine), _index(index
_frameNumber = 0;
}
-Actor::~Actor() {
- // TODO destroy data
-
- // Zero passed pointers
- _vm = NULL;
-}
-
/////////////////////////////////////////////////////////////////////////
// Loading
//////////////////////////////////////////////////////////////////////////
diff --git a/engines/asylum/resources/actor.h b/engines/asylum/resources/actor.h
index d4061abfc5..0bf5b1e372 100644
--- a/engines/asylum/resources/actor.h
+++ b/engines/asylum/resources/actor.h
@@ -85,7 +85,7 @@ struct ActorData : public Common::Serializable {
class Actor : public Common::Serializable {
public:
Actor(AsylumEngine *engine, ActorIndex index);
- virtual ~Actor();
+ virtual ~Actor() {};
//////////////////////////////////////////////////////////////////////////
// Public variables & accessors
diff --git a/engines/asylum/resources/encounters.cpp b/engines/asylum/resources/encounters.cpp
index a5d937da1a..3ffd65a196 100644
--- a/engines/asylum/resources/encounters.cpp
+++ b/engines/asylum/resources/encounters.cpp
@@ -105,14 +105,6 @@ Encounter::Encounter(AsylumEngine *engine) : _vm(engine),
load();
}
-Encounter::~Encounter() {
- // Pointing to existing data
- _item = NULL;
-
- // Zero-out passed pointers
- _vm = NULL;
-}
-
//////////////////////////////////////////////////////////////////////////
// Data
//////////////////////////////////////////////////////////////////////////
diff --git a/engines/asylum/resources/encounters.h b/engines/asylum/resources/encounters.h
index aba01bb112..86a5d68aa8 100644
--- a/engines/asylum/resources/encounters.h
+++ b/engines/asylum/resources/encounters.h
@@ -85,7 +85,7 @@ public:
class Encounter : public EventHandler {
public:
Encounter(AsylumEngine *engine);
- virtual ~Encounter();
+ virtual ~Encounter() {};
void run(int32 encounterIndex, ObjectId objectId1, ObjectId objectId2, ActorIndex actorIndex);
diff --git a/engines/asylum/resources/object.cpp b/engines/asylum/resources/object.cpp
index b6cb45b060..00d946622b 100644
--- a/engines/asylum/resources/object.cpp
+++ b/engines/asylum/resources/object.cpp
@@ -47,11 +47,6 @@ Object::Object(AsylumEngine *engine) : x(0), y(0), flags(0), actionType(0),
memset(&_randomResourceIds, 0, sizeof(_randomResourceIds));
}
-Object::~Object() {
- // Zero passed pointers
- _vm = NULL;
-}
-
/////////////////////////////////////////////////////////////////////////
// Loading & destroying
/////////////////////////////////////////////////////////////////////////
diff --git a/engines/asylum/resources/object.h b/engines/asylum/resources/object.h
index c01df88d13..d57e199aff 100644
--- a/engines/asylum/resources/object.h
+++ b/engines/asylum/resources/object.h
@@ -39,7 +39,7 @@ class AsylumEngine;
class Object : public Common::Serializable {
public:
Object(AsylumEngine *engine);
- virtual ~Object();
+ virtual ~Object() {};
//////////////////////////////////////////////////////////////////////////
// Public variables & accessors
diff --git a/engines/asylum/resources/script.cpp b/engines/asylum/resources/script.cpp
index 6c6059e943..48bdbf7d94 100644
--- a/engines/asylum/resources/script.cpp
+++ b/engines/asylum/resources/script.cpp
@@ -218,12 +218,6 @@ ScriptManager::~ScriptManager() {
_scripts.clear();
_queue.reset();
-
- _currentScript = NULL;
- _currentQueueEntry = NULL;
-
- // Zero-out passed pointers
- _vm = NULL;
}
void ScriptManager::load(Common::SeekableReadStream *stream) {
diff --git a/engines/asylum/resources/special.cpp b/engines/asylum/resources/special.cpp
index e92704f225..72eb38fa3e 100644
--- a/engines/asylum/resources/special.cpp
+++ b/engines/asylum/resources/special.cpp
@@ -71,12 +71,6 @@ Special::Special(AsylumEngine *engine) : _vm(engine) {
_chapter5Counter = 0;
}
-Special::~Special() {
- // Zero-out passed pointers
- _vm = NULL;
-}
-
-
void Special::run(Object* object, ActorIndex index) {
switch (getWorld()->chapter) {
default:
diff --git a/engines/asylum/resources/special.h b/engines/asylum/resources/special.h
index 662b63f48b..15a0cbaa47 100644
--- a/engines/asylum/resources/special.h
+++ b/engines/asylum/resources/special.h
@@ -37,7 +37,7 @@ class Special {
public:
Special(AsylumEngine *engine);
- virtual ~Special();
+ ~Special() {};
void run(Object* object, ActorIndex index);
diff --git a/engines/asylum/resources/worldstats.cpp b/engines/asylum/resources/worldstats.cpp
index a55995f117..9940a44e92 100644
--- a/engines/asylum/resources/worldstats.cpp
+++ b/engines/asylum/resources/worldstats.cpp
@@ -99,9 +99,6 @@ WorldStats::~WorldStats() {
CLEAR_ARRAY(Object, objects);
CLEAR_ARRAY(Actor, actors);
CLEAR_ARRAY(ActionArea, actions);
-
- // Zero-out passed pointers
- _vm = NULL;
}
// Load necessary World Stats content
diff --git a/engines/asylum/system/cursor.cpp b/engines/asylum/system/cursor.cpp
index 0e98bd1634..9e5d13c278 100644
--- a/engines/asylum/system/cursor.cpp
+++ b/engines/asylum/system/cursor.cpp
@@ -40,9 +40,6 @@ Cursor::Cursor(AsylumEngine *engine) : _vm(engine),
Cursor::~Cursor() {
delete _cursorRes;
-
- // Zero-out passed pointers
- _vm = NULL;
}
void Cursor::hide() const {
diff --git a/engines/asylum/system/graphics.cpp b/engines/asylum/system/graphics.cpp
index e481316995..436c37ddc9 100644
--- a/engines/asylum/system/graphics.cpp
+++ b/engines/asylum/system/graphics.cpp
@@ -37,9 +37,6 @@ GraphicResource::GraphicResource(AsylumEngine *engine, ResourceId id) : _vm(engi
GraphicResource::~GraphicResource() {
clear();
-
- // Zero passed pointers
- _vm = NULL;
}
bool GraphicResource::load(ResourceId id) {
diff --git a/engines/asylum/system/savegame.cpp b/engines/asylum/system/savegame.cpp
index acf96c78e2..62be5f9aba 100644
--- a/engines/asylum/system/savegame.cpp
+++ b/engines/asylum/system/savegame.cpp
@@ -59,11 +59,6 @@ Savegame::Savegame(AsylumEngine *engine) : _vm(engine), _index(0), _valid(false)
memset(&_savegameToScene, 0, sizeof(_savegameToScene));
}
-Savegame::~Savegame() {
- // Zero passed pointers
- _vm = NULL;
-}
-
bool Savegame::hasSavegames() const {
for (uint i = 0; i < SAVEGAME_COUNT; i++)
if (isSavegamePresent(getFilename(i)))
diff --git a/engines/asylum/system/savegame.h b/engines/asylum/system/savegame.h
index b1f5283d75..315a2cb388 100644
--- a/engines/asylum/system/savegame.h
+++ b/engines/asylum/system/savegame.h
@@ -38,7 +38,7 @@ class AsylumEngine;
class Savegame {
public:
Savegame(AsylumEngine *engine);
- ~Savegame();
+ ~Savegame() {};
/**
* Checks if saved games are present
diff --git a/engines/asylum/system/screen.cpp b/engines/asylum/system/screen.cpp
index a104e6b7c9..6f48c3e0ee 100644
--- a/engines/asylum/system/screen.cpp
+++ b/engines/asylum/system/screen.cpp
@@ -66,12 +66,6 @@ Screen::~Screen() {
_backBuffer.free();
clearTransTables();
-
- _transTableBuffer = NULL;
- _transTable = NULL;
-
- // Zero-out passed pointers
- _vm = NULL;
}
//////////////////////////////////////////////////////////////////////////
diff --git a/engines/asylum/system/sound.cpp b/engines/asylum/system/sound.cpp
index 3c4e29c2ab..bfa88bd483 100644
--- a/engines/asylum/system/sound.cpp
+++ b/engines/asylum/system/sound.cpp
@@ -44,10 +44,6 @@ Sound::Sound(AsylumEngine *engine, Audio::Mixer *mixer) : _vm(engine), _mixer(mi
Sound::~Sound() {
cleanupQueue();
-
- // Zero-out passed pointers
- _vm = NULL;
- _mixer = NULL;
}
//////////////////////////////////////////////////////////////////////////
diff --git a/engines/asylum/system/speech.cpp b/engines/asylum/system/speech.cpp
index aee880ab38..7bc0f55b66 100644
--- a/engines/asylum/system/speech.cpp
+++ b/engines/asylum/system/speech.cpp
@@ -40,15 +40,6 @@ Speech::Speech(AsylumEngine *engine): _vm(engine), _textData(0), _textDataPos(0)
_textResourceId = kResourceNone;
}
-Speech::~Speech() {
- // Text resource data is disposed as part of the resource manager
- _textData = 0;
- _textDataPos = 0;
-
- // Zero-out passed pointers
- _vm = NULL;
-}
-
ResourceId Speech::play(ResourceId soundResourceId, ResourceId textResourceId) {
if (soundResourceId)
if (getSound()->isPlaying(_soundResourceId))
diff --git a/engines/asylum/system/speech.h b/engines/asylum/system/speech.h
index 0dc0dcc895..32bb0ac143 100644
--- a/engines/asylum/system/speech.h
+++ b/engines/asylum/system/speech.h
@@ -34,7 +34,7 @@ class AsylumEngine;
class Speech {
public:
Speech(AsylumEngine *engine);
- virtual ~Speech();
+ ~Speech() {};
/**
* Play speech
diff --git a/engines/asylum/system/text.cpp b/engines/asylum/system/text.cpp
index 29dc7fad9a..856207f138 100644
--- a/engines/asylum/system/text.cpp
+++ b/engines/asylum/system/text.cpp
@@ -40,9 +40,6 @@ Text::Text(AsylumEngine *engine) : _vm(engine) {
Text::~Text() {
delete _fontResource;
-
- // Zero-out passed pointers
- _vm = NULL;
}
ResourceId Text::loadFont(ResourceId resourceId) {
diff --git a/engines/asylum/views/menu.cpp b/engines/asylum/views/menu.cpp
index 84de5fafde..9838deb9f7 100644
--- a/engines/asylum/views/menu.cpp
+++ b/engines/asylum/views/menu.cpp
@@ -73,11 +73,6 @@ Menu::Menu(AsylumEngine *vm): _vm(vm) {
_prefixWidth = 0;
}
-Menu::~Menu() {
- // Zero-out passed pointers
- _vm = NULL;
-}
-
//////////////////////////////////////////////////////////////////////////
// Loading and setup
//////////////////////////////////////////////////////////////////////////
diff --git a/engines/asylum/views/menu.h b/engines/asylum/views/menu.h
index 8dc87c4087..f65eeef16d 100644
--- a/engines/asylum/views/menu.h
+++ b/engines/asylum/views/menu.h
@@ -38,7 +38,7 @@ class Text;
class Menu : public EventHandler {
public:
Menu(AsylumEngine *vm);
- ~Menu();
+ virtual ~Menu() {};
/**
* Shows the menu
diff --git a/engines/asylum/views/scene.cpp b/engines/asylum/views/scene.cpp
index ebaaabcc1f..12760a4e1a 100644
--- a/engines/asylum/views/scene.cpp
+++ b/engines/asylum/views/scene.cpp
@@ -84,9 +84,6 @@ Scene::~Scene() {
delete _polygons;
delete _ws;
-
- // Zero passed pointers
- _vm = NULL;
}
void Scene::enter(ResourcePackId packId) {
diff --git a/engines/asylum/views/scenetitle.cpp b/engines/asylum/views/scenetitle.cpp
index 060240deae..3694c50b25 100644
--- a/engines/asylum/views/scenetitle.cpp
+++ b/engines/asylum/views/scenetitle.cpp
@@ -39,11 +39,6 @@ SceneTitle::SceneTitle(AsylumEngine *engine): _vm(engine),
_start(0), _done(false), _spinnerFrameIndex(0), _spinnerProgress(0), _spinnerFrameCount(0) {
}
-SceneTitle::~SceneTitle() {
- // Zero passed pointers
- _vm = NULL;
-}
-
void SceneTitle::load() {
_start = _vm->getTick();
diff --git a/engines/asylum/views/scenetitle.h b/engines/asylum/views/scenetitle.h
index 075b75b74c..4e26b1eeca 100644
--- a/engines/asylum/views/scenetitle.h
+++ b/engines/asylum/views/scenetitle.h
@@ -33,7 +33,7 @@ class GraphicResource;
class SceneTitle {
public:
SceneTitle(AsylumEngine *engine);
- ~SceneTitle();
+ ~SceneTitle() {};
void load();
diff --git a/engines/asylum/views/video.cpp b/engines/asylum/views/video.cpp
index 29daa9b29f..c363b34e9f 100644
--- a/engines/asylum/views/video.cpp
+++ b/engines/asylum/views/video.cpp
@@ -43,9 +43,6 @@ VideoPlayer::VideoPlayer(AsylumEngine *engine, Audio::Mixer *mixer) : _vm(engine
VideoPlayer::~VideoPlayer() {
delete _smkDecoder;
-
- // Zero-out passed pointers
- _vm = NULL;
}
//////////////////////////////////////////////////////////////////////////
Commit: a2d249558824e093950342edf946b657259f4ae2
https://github.com/scummvm/scummvm/commit/a2d249558824e093950342edf946b657259f4ae2
Author: alxpnv (alxpnv22 at yahoo.com)
Date: 2021-05-17T15:37:58+02:00
Commit Message:
ASYLUM: add Keymapper support
Changed paths:
engines/asylum/asylum.cpp
engines/asylum/metaengine.cpp
engines/asylum/shared.h
engines/asylum/views/scene.cpp
engines/asylum/views/scene.h
diff --git a/engines/asylum/asylum.cpp b/engines/asylum/asylum.cpp
index 089792054a..327e6040ed 100644
--- a/engines/asylum/asylum.cpp
+++ b/engines/asylum/asylum.cpp
@@ -388,6 +388,12 @@ void AsylumEngine::handleEvents() {
default:
break;
+ case Common::EVENT_CUSTOM_ENGINE_ACTION_START:
+ // Handle custom actions
+ if (_handler)
+ _handler->handleEvent(ev);
+ break;
+
case Common::EVENT_KEYDOWN:
if ((ev.kbd.flags & Common::KBD_CTRL) && ev.kbd.keycode == Common::KEYCODE_d) {
_console->attach();
diff --git a/engines/asylum/metaengine.cpp b/engines/asylum/metaengine.cpp
index bfb170e002..5424941322 100644
--- a/engines/asylum/metaengine.cpp
+++ b/engines/asylum/metaengine.cpp
@@ -23,8 +23,13 @@
#include "engines/advancedDetector.h"
#include "base/plugins.h"
-#include "asylum/asylum.h"
+#include "backends/keymapper/action.h"
+#include "backends/keymapper/keymap.h"
+
+#include "common/translation.h"
+#include "asylum/asylum.h"
+#include "asylum/shared.h"
class AsylumMetaEngine : public AdvancedMetaEngine {
public:
@@ -37,6 +42,7 @@ public:
}
Common::Error createInstance(OSystem *syst, Engine **engine, const ADGameDescription *gd) const override;
+ Common::KeymapArray initKeymaps(const char *target) const override;
};
bool Asylum::AsylumEngine::hasFeature(EngineFeature f) const {
@@ -50,6 +56,47 @@ Common::Error AsylumMetaEngine::createInstance(OSystem *syst, Engine **engine, c
return desc ? Common::kNoError : Common::kUnsupportedGameidError;
}
+Common::KeymapArray AsylumMetaEngine::initKeymaps(const char *target) const {
+ using namespace Common;
+ using namespace Asylum;
+
+ Keymap *engineKeyMap = new Keymap(Keymap::kKeymapTypeGame, "asylum", "Sanitarium");
+
+ Action *act;
+
+ act = new Action("VERSION", _("Show version"));
+ act->setCustomEngineActionEvent(kAsylumActionShowVersion);
+ act->addDefaultInputMapping("v");
+ engineKeyMap->addAction(act);
+
+ act = new Action("LOAD", _("Quick load"));
+ act->setCustomEngineActionEvent(kAsylumActionQuickLoad);
+ act->addDefaultInputMapping("S+l");
+ engineKeyMap->addAction(act);
+
+ act = new Action("SAVE", _("Quick save"));
+ act->setCustomEngineActionEvent(kAsylumActionQuickSave);
+ act->addDefaultInputMapping("S+s");
+ engineKeyMap->addAction(act);
+
+ act = new Action("SARAH", _("Switch to Sarah"));
+ act->setCustomEngineActionEvent(kAsylumActionSwitchToSarah);
+ act->addDefaultInputMapping("s");
+ engineKeyMap->addAction(act);
+
+ act = new Action("GRIMWALL", _("Switch to Grimwall"));
+ act->setCustomEngineActionEvent(kAsylumActionSwitchToGrimwall);
+ act->addDefaultInputMapping("g");
+ engineKeyMap->addAction(act);
+
+ act = new Action("OLMEC", _("Switch to Olmec"));
+ act->setCustomEngineActionEvent(kAsylumActionSwitchToOlmec);
+ act->addDefaultInputMapping("o");
+ engineKeyMap->addAction(act);
+
+ return Keymap::arrayOf(engineKeyMap);
+}
+
#if PLUGIN_ENABLED_DYNAMIC(ASYLUM)
REGISTER_PLUGIN_DYNAMIC(ASYLUM, PLUGIN_TYPE_ENGINE, AsylumMetaEngine);
#else
diff --git a/engines/asylum/shared.h b/engines/asylum/shared.h
index 59b6fe0f11..ac5487d698 100644
--- a/engines/asylum/shared.h
+++ b/engines/asylum/shared.h
@@ -772,6 +772,18 @@ enum PuzzleId {
kPuzzleHiveControl
};
+//////////////////////////////////////////////////////////////////////////
+// Custom engine actions
+//////////////////////////////////////////////////////////////////////////
+enum AsylumAction {
+ kAsylumActionShowVersion,
+ kAsylumActionQuickLoad,
+ kAsylumActionQuickSave,
+ kAsylumActionSwitchToSarah,
+ kAsylumActionSwitchToGrimwall,
+ kAsylumActionSwitchToOlmec
+};
+
//////////////////////////////////////////////////////////////////////////
// Helpers
//////////////////////////////////////////////////////////////////////////
diff --git a/engines/asylum/views/scene.cpp b/engines/asylum/views/scene.cpp
index 12760a4e1a..6de99e84ee 100644
--- a/engines/asylum/views/scene.cpp
+++ b/engines/asylum/views/scene.cpp
@@ -308,6 +308,9 @@ bool Scene::handleEvent(const AsylumEvent &evt) {
case EVENT_ASYLUM_UPDATE:
return update();
+ case Common::EVENT_CUSTOM_ENGINE_ACTION_START:
+ return action((AsylumAction)evt.customType);
+
case Common::EVENT_KEYDOWN:
if (evt.kbd.flags & Common::KBD_CTRL)
_isCTRLPressed = true;
@@ -405,58 +408,37 @@ bool Scene::update() {
return true;
}
-bool Scene::key(const AsylumEvent &evt) {
- if (!_ws)
- error("[Scene::key] WorldStats not initialized properly");
-
- // TODO add support for debug commands
-
- //////////////////////////////////////////////////////////////////////////
- // Check for keyboard shortcuts
- if (evt.kbd.ascii == Config.keyShowVersion) {
+bool Scene::action(AsylumAction a) {
+ switch (a) {
+ case kAsylumActionShowVersion:
// TODO show version!
+ break;
- return true;
- }
-
- if (evt.kbd.ascii == Config.keyQuickLoad) {
+ case kAsylumActionQuickLoad:
getSaveLoad()->quickLoad();
+ break;
- return true;
- }
-
- if (evt.kbd.ascii == Config.keyQuickSave) {
+ case kAsylumActionQuickSave:
getSaveLoad()->quickSave();
+ break;
- return true;
- }
-
- if (evt.kbd.ascii == Config.keySwitchToSara) {
- if (getCursor()->isHidden() || _ws->chapter != kChapter9)
- return true;
-
- getScript()->queueScript(_ws->actions[_ws->getActionAreaIndexById(2206)]->scriptIndex, getSharedData()->getPlayerIndex());
-
- return true;
- }
-
- if (evt.kbd.ascii == Config.keySwitchToGrimwall) {
+ case kAsylumActionSwitchToSarah:
+ case kAsylumActionSwitchToGrimwall:
+ case kAsylumActionSwitchToOlmec:
if (getCursor()->isHidden() || _ws->chapter != kChapter9)
return true;
- getScript()->queueScript(_ws->actions[_ws->getActionAreaIndexById(2207)]->scriptIndex, getSharedData()->getPlayerIndex());
-
- return true;
+ getScript()->queueScript(_ws->actions[_ws->getActionAreaIndexById(2206 + a - kAsylumActionSwitchToSarah)]->scriptIndex,
+ getSharedData()->getPlayerIndex());
+ break;
}
- if (evt.kbd.ascii == Config.keySwitchToOlmec) {
- if (getCursor()->isHidden() || _ws->chapter != kChapter9)
- return true;
-
- getScript()->queueScript(_ws->actions[_ws->getActionAreaIndexById(2208)]->scriptIndex, getSharedData()->getPlayerIndex());
+ return true;
+}
- return true;
- }
+bool Scene::key(const AsylumEvent &evt) {
+ if (!_ws)
+ error("[Scene::key] WorldStats not initialized properly");
switch (evt.kbd.keycode) {
default:
diff --git a/engines/asylum/views/scene.h b/engines/asylum/views/scene.h
index ba25c4123c..69135a54b1 100644
--- a/engines/asylum/views/scene.h
+++ b/engines/asylum/views/scene.h
@@ -220,6 +220,7 @@ private:
void activate();
bool init();
bool update();
+ bool action(AsylumAction a);
bool key(const AsylumEvent &evt);
bool clickDown(const AsylumEvent &evt);
Commit: b7130bab21bea837da510aae124e19500b90cca2
https://github.com/scummvm/scummvm/commit/b7130bab21bea837da510aae124e19500b90cca2
Author: alxpnv (alxpnv22 at yahoo.com)
Date: 2021-05-17T15:37:58+02:00
Commit Message:
ASYLUM: fix savegame overwriting
Bug reported by digitall
Changed paths:
engines/asylum/views/menu.cpp
diff --git a/engines/asylum/views/menu.cpp b/engines/asylum/views/menu.cpp
index 9838deb9f7..9c21187ce3 100644
--- a/engines/asylum/views/menu.cpp
+++ b/engines/asylum/views/menu.cpp
@@ -1677,7 +1677,7 @@ void Menu::clickSaveGame() {
if (_dword_455C80) {
if (cursor.x < 247 || cursor.x > (247 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 1340)))
- || cursor.y < 273 || cursor.y > (247 + 24)) {
+ || cursor.y < 273 || cursor.y > (273 + 24)) {
if (cursor.x >= 369 && cursor.x <= (369 + getText()->getWidth(MAKE_RESOURCE(kResourcePackText, 1341)))
&& cursor.y >= 273 && cursor.y <= (273 + 24))
_dword_455C80 = false;
Commit: ba2ccee7011e1dcd7f22a67a718d92a9828ef71a
https://github.com/scummvm/scummvm/commit/ba2ccee7011e1dcd7f22a67a718d92a9828ef71a
Author: alxpnv (alxpnv22 at yahoo.com)
Date: 2021-05-17T15:37:58+02:00
Commit Message:
ASYLUM: fix Quick Load/Quick Save
Changed paths:
engines/asylum/system/savegame.cpp
engines/asylum/views/menu.cpp
diff --git a/engines/asylum/system/savegame.cpp b/engines/asylum/system/savegame.cpp
index 62be5f9aba..42b511f9ad 100644
--- a/engines/asylum/system/savegame.cpp
+++ b/engines/asylum/system/savegame.cpp
@@ -47,7 +47,7 @@ namespace Asylum {
#define SAVEGAME_NAME "asylum"
-#define SAVEGAME_QUICKSLOT 25
+#define SAVEGAME_QUICKSLOT 24
#define SAVEGAME_MOVIES "asylum.movies"
@@ -129,7 +129,7 @@ bool Savegame::quickLoad() {
return false;
_index = SAVEGAME_QUICKSLOT;
- _vm->startGame((ResourcePackId)(getSharedData()->cdNumber + 4), AsylumEngine::kStartGameLoad);
+ _vm->startGame(getScenePack(), AsylumEngine::kStartGameLoad);
return true;
}
@@ -157,7 +157,7 @@ bool Savegame::quickSave() {
_index = 24;
// Check if there is a quick save already
- if (isSavegamePresent(getFilename(SAVEGAME_QUICKSLOT))) {
+ if (!isSavegamePresent(getFilename(SAVEGAME_QUICKSLOT))) {
_names[_index] = getText()->get(MAKE_RESOURCE(kResourcePackText, 1342));
save();
@@ -214,7 +214,7 @@ bool Savegame::check() {
Common::String Savegame::getFilename(uint32 index) const {
if (index > SAVEGAME_COUNT - 1)
- error("[Savegame::getFilename] Invalid savegame index (was:%d, valid: [0-25])", index);
+ error("[Savegame::getFilename] Invalid savegame index (was:%d, valid: [0-24])", index);
return Common::String::format("%s%02d.sav", SAVEGAME_NAME, index);
}
@@ -491,21 +491,21 @@ void Savegame::loadMoviesViewed() {
//////////////////////////////////////////////////////////////////////////
void Savegame::setName(uint32 index, Common::String name) {
if (index >= ARRAYSIZE(_names))
- error("[Savegame::setName] Invalid index (was: %d, max: %d)", index, ARRAYSIZE(_names));
+ error("[Savegame::setName] Invalid index (was: %d, max: %d)", index, ARRAYSIZE(_names) - 1);
_names[index] = name;
}
Common::String Savegame::getName(uint32 index) const {
if (index >= ARRAYSIZE(_names))
- error("[Savegame::getName] Invalid index (was: %d, max: %d)", index, ARRAYSIZE(_names));
+ error("[Savegame::getName] Invalid index (was: %d, max: %d)", index, ARRAYSIZE(_names) - 1);
return _names[index];
}
bool Savegame::hasSavegame(uint32 index) const {
if (index >= ARRAYSIZE(_savegames))
- error("[Savegame::hasSavegame] Invalid index (was: %d, max: %d)", index, ARRAYSIZE(_savegames));
+ error("[Savegame::hasSavegame] Invalid index (was: %d, max: %d)", index, ARRAYSIZE(_savegames) - 1);
return _savegames[index];
}
diff --git a/engines/asylum/views/menu.cpp b/engines/asylum/views/menu.cpp
index 9c21187ce3..4b65289f5b 100644
--- a/engines/asylum/views/menu.cpp
+++ b/engines/asylum/views/menu.cpp
@@ -832,7 +832,7 @@ void Menu::updateLoadGame() {
else
getText()->loadFont(kFontBlue);
- getText()->setPosition(Common::Point(550, 347));
+ getText()->setPosition(Common::Point(550, 340));
getText()->draw(MAKE_RESOURCE(kResourcePackText, 1327));
}
@@ -992,7 +992,7 @@ void Menu::updateSaveGame() {
else
getText()->loadFont(kFontBlue);
- getText()->setPosition(Common::Point(550, 347));
+ getText()->setPosition(Common::Point(550, 340));
getText()->draw(MAKE_RESOURCE(kResourcePackText, 1337));
}
@@ -1102,7 +1102,7 @@ void Menu::updateDeleteGame() {
else
getText()->loadFont(kFontBlue);
- getText()->setPosition(Common::Point(550, 347));
+ getText()->setPosition(Common::Point(550, 340));
getText()->draw(MAKE_RESOURCE(kResourcePackText, 1347));
}
@@ -1651,6 +1651,7 @@ void Menu::clickLoadGame() {
getSaveLoad()->setIndex(saveIndex);
}
}
+ break;
}
} else if (cursor.x >= 30) {
snprintf((char *)&text, sizeof(text), "%d. %s ", index + _startIndex + 1, getSaveLoad()->getName((uint32)(index + _startIndex)).c_str());
@@ -1658,13 +1659,14 @@ void Menu::clickLoadGame() {
if (cursor.x <= (30 + getText()->getWidth((char *)&text))
&& cursor.y >= y
&& cursor.y <= (y + 24)) {
- uint32 saveIndex = (uint32)(index + _startIndex);
+ uint32 saveIndex = (uint32)(index + _startIndex);
if (saveIndex < 25) {
if (getSaveLoad()->hasSavegame(saveIndex)) {
_dword_455C80 = true;
getSaveLoad()->setIndex(saveIndex);
}
}
+ break;
}
}
@@ -1738,6 +1740,7 @@ void Menu::clickSaveGame() {
if (cursor.x <= (350 + getText()->getWidth((char *)&text))
&& cursor.y >= y
&& cursor.y <= (y + 24)
+ && getScene()
&& getWorld()->chapter != kChapterNone) {
if (index + _startIndex < 25) {
uint32 saveIndex = (uint32)(index + _startIndex + 6);
@@ -1752,6 +1755,7 @@ void Menu::clickSaveGame() {
getCursor()->hide();
}
}
+ break;
}
} else if (cursor.x >= 30) {
snprintf((char *)&text, sizeof(text), "%d. %s ", index + _startIndex + 1, getSaveLoad()->getName((uint32)(index + _startIndex)).c_str());
@@ -1774,6 +1778,7 @@ void Menu::clickSaveGame() {
getCursor()->hide();
}
}
+ break;
}
}
@@ -1850,20 +1855,22 @@ void Menu::clickDeleteGame() {
getSaveLoad()->setIndex(saveIndex + 6);
}
}
+ break;
}
} else if (cursor.x >= 30) {
snprintf((char *)&text, sizeof(text), "%d. %s ", index + _startIndex + 1, getSaveLoad()->getName((uint32)(index + _startIndex)).c_str());
if (cursor.x <= (30 + getText()->getWidth((char *)&text))
- && cursor.y >= y
- && cursor.y <= (y + 24)) {
- uint32 saveIndex = (uint32)(index + _startIndex);
- if (saveIndex < 25) {
- if (getSaveLoad()->hasSavegame(saveIndex)) {
- _dword_455C80 = true;
- getSaveLoad()->setIndex(saveIndex);
- }
+ && cursor.y >= y
+ && cursor.y <= (y + 24)) {
+ uint32 saveIndex = (uint32)(index + _startIndex);
+ if (saveIndex < 25) {
+ if (getSaveLoad()->hasSavegame(saveIndex)) {
+ _dword_455C80 = true;
+ getSaveLoad()->setIndex(saveIndex);
}
+ }
+ break;
}
}
More information about the Scummvm-git-logs
mailing list